--- a/ship_cmd.c Sun Jan 30 19:51:39 2005 +0000
+++ b/ship_cmd.c Sun Jan 30 20:50:06 2005 +0000
@@ -915,13 +915,15 @@
{
Vehicle *v;
- SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
+ if (!IsVehicleIndex(p1)) return CMD_ERROR;
v = GetVehicle(p1);
if (v->type != VEH_Ship || !CheckOwnership(v->owner))
return CMD_ERROR;
+ SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
+
if (!IsShipDepotTile(v->tile) || v->u.road.state != 0x80 || !(v->vehstatus&VS_STOPPED))
return_cmd_error(STR_980B_SHIP_MUST_BE_STOPPED_IN);
@@ -943,9 +945,11 @@
{
Vehicle *v;
+ if (!IsVehicleIndex(p1)) return CMD_ERROR;
+
v = GetVehicle(p1);
- if (!CheckOwnership(v->owner))
+ if (v->type != VEH_Ship || !CheckOwnership(v->owner))
return CMD_ERROR;
if (flags & DC_EXEC) {
@@ -969,9 +973,11 @@
Vehicle *v;
int depot;
+ if (!IsVehicleIndex(p1)) return CMD_ERROR;
+
v = GetVehicle(p1);
- if (!CheckOwnership(v->owner))
+ if (v->type != VEH_Ship || !CheckOwnership(v->owner))
return CMD_ERROR;
if (HASBIT(p2, 0)) v->set_for_replacement = true;
@@ -1007,9 +1013,11 @@
{
Vehicle *v;
+ if (!IsVehicleIndex(p1)) return CMD_ERROR;
+
v = GetVehicle(p1);
- if (!CheckOwnership(v->owner))
+ if (v->type != VEH_Ship || !CheckOwnership(v->owner))
return CMD_ERROR;
if (flags & DC_EXEC) {
@@ -1031,10 +1039,12 @@
byte SkipStoppedInDepotCheck = (p2 & 0x100) >> 8; //excludes the cargo value
p2 = p2 & 0xFF;
- SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN);
+
+ if (!IsVehicleIndex(p1)) return CMD_ERROR;
v = GetVehicle(p1);
- if (!CheckOwnership(v->owner))
+
+ if (v->type != VEH_Ship || !CheckOwnership(v->owner))
return CMD_ERROR;
if (!( SkipStoppedInDepotCheck )) {
@@ -1044,6 +1054,8 @@
return_cmd_error(STR_980B_SHIP_MUST_BE_STOPPED_IN);
}
+ SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN);
+
cost = 0;
if (IS_HUMAN_PLAYER(v->owner) && (byte)p2 != v->cargo_type) {
cost = _price.ship_base >> 7;