(svn r1946) Fix: [AInew] Allow DC_QUERY_COST even on tiles with no depot built. This is used by the ai_new for deciding if it can afford the vehicles before actually building the depot. Was broken in r1728. Signed-Off-By: TrueLight ;-)
authorpasky
Sun, 06 Mar 2005 16:53:00 +0000
changeset 1442 a166ae688746
parent 1441 3c9130c733f3
child 1443 2b8e1b123d91
(svn r1946) Fix: [AInew] Allow DC_QUERY_COST even on tiles with no depot built. This is used by the ai_new for deciding if it can afford the vehicles before actually building the depot. Was broken in r1728. Signed-Off-By: TrueLight ;-)
roadveh_cmd.c
--- a/roadveh_cmd.c	Sun Mar 06 16:23:32 2005 +0000
+++ b/roadveh_cmd.c	Sun Mar 06 16:53:00 2005 +0000
@@ -121,16 +121,17 @@
 
 	if (!IsEngineBuildable(p1, VEH_Road)) return CMD_ERROR;
 
-	if (!IsTileDepotType(tile, TRANSPORT_ROAD)) return CMD_ERROR;
-
-	if (_map_owner[tile] != _current_player) return CMD_ERROR;
-
 	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
 
 	cost = EstimateRoadVehCost(p1);
 	if (flags & DC_QUERY_COST)
 		return cost;
 
+	/* 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_ROAD)) return CMD_ERROR;
+	if (_map_owner[tile] != _current_player) return CMD_ERROR;
+
 	v = AllocateVehicle();
 	if (v == NULL || IsOrderPoolFull())
 		return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);