diff --git a/ship_cmd.c b/ship_cmd.c --- a/ship_cmd.c +++ b/ship_cmd.c @@ -878,16 +878,17 @@ int32 CmdBuildShip(int x, int y, uint32 if (!IsEngineBuildable(p1, VEH_Ship)) return CMD_ERROR; - if (!IsTileDepotType(tile, TRANSPORT_WATER)) return CMD_ERROR; - - if (_map_owner[tile] != _current_player) return CMD_ERROR; - SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); value = EstimateShipCost(p1); if (flags & DC_QUERY_COST) return value; + /* The ai_new queries the vehicle cost before building the route, + * so we must check against cheaters no sooner than now. --pasky */ + if (!IsTileDepotType(tile, TRANSPORT_WATER)) return CMD_ERROR; + if (_map_owner[tile] != _current_player) return CMD_ERROR; + v = AllocateVehicle(); if (v == NULL || IsOrderPoolFull() || (unit_num = GetFreeUnitNumber(VEH_Ship)) > _patches.max_ships) diff --git a/train_cmd.c b/train_cmd.c --- a/train_cmd.c +++ b/train_cmd.c @@ -542,9 +542,10 @@ int32 CmdBuildRailVehicle(int x, int y, if (!IsEngineBuildable(p1, VEH_Train)) return CMD_ERROR; - if (!IsTileDepotType(tile, TRANSPORT_RAIL)) return CMD_ERROR; - - if (_map_owner[tile] != _current_player) return CMD_ERROR; + if (!(flags & DC_QUERY_COST)) { + if (!IsTileDepotType(tile, TRANSPORT_RAIL)) return CMD_ERROR; + if (_map_owner[tile] != _current_player) return CMD_ERROR; + } _cmd_build_rail_veh_var1 = 0;