(svn r2948) -Fix: the old AI needs a special flag that triggers all kind of special
authortruelight
Tue, 13 Sep 2005 12:19:27 +0000
changeset 2422 897a01f7c624
parent 2421 8bc8ff3a5eb5
child 2423 4266590b549d
(svn r2948) -Fix: the old AI needs a special flag that triggers all kind of special
abilities you really don't want to know about (free bridges, etc..)
I removed this flag some revisions ago, but the Aircraft part
depends on it, so I re-enabled it again..
ai/ai.c
aircraft_cmd.c
rail_cmd.c
road_cmd.c
station_cmd.c
tunnelbridge_cmd.c
variables.h
--- a/ai/ai.c	Tue Sep 13 09:23:23 2005 +0000
+++ b/ai/ai.c	Tue Sep 13 12:19:27 2005 +0000
@@ -126,8 +126,12 @@
 
 	if (_patches.ainew_active)
 		AiNewDoGameLoop(p);
-	else
+	else {
+		/* Enable all kind of cheats the old AI needs in order to operate correctly... */
+		_is_old_ai_player = true;
 		AiDoGameLoop(p);
+		_is_old_ai_player = false;
+	}
 }
 
 
--- a/aircraft_cmd.c	Tue Sep 13 09:23:23 2005 +0000
+++ b/aircraft_cmd.c	Tue Sep 13 12:19:27 2005 +0000
@@ -253,10 +253,9 @@
 
 		_new_aircraft_id = v->index;
 
-		// the AI doesn't click on a tile to build airplanes, so the below code will
+		// the old AI doesn't click on a tile to build airplanes, so the below code will
 		// never work. Therefore just assume the AI's planes always come from Hangar0
-		// On hold for NewAI
-		v->u.air.pos = (!_patches.ainew_active && _is_ai_player) ? 0:MAX_ELEMENTS;
+		v->u.air.pos = _is_old_ai_player ? 0 : MAX_ELEMENTS;
 
 		/* When we click on hangar we know the tile (it is in var 'tile')it is on. By that we know
 			its position in the array of depots the airport has.....we can search
--- a/rail_cmd.c	Tue Sep 13 09:23:23 2005 +0000
+++ b/rail_cmd.c	Tue Sep 13 12:19:27 2005 +0000
@@ -247,8 +247,7 @@
 				)) { // partly up
 			if (existing != 0) {
 				return 0;
-			} else if (!_patches.build_on_slopes ||
-					(_is_ai_player && !_patches.ainew_active)) {
+			} else if (!_patches.build_on_slopes || _is_old_ai_player) {
 				return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
 			} else {
 				return _price.terraform;
@@ -679,7 +678,7 @@
 	*/
 
 	if (tileh != 0 && (
-			(!_patches.ainew_active && _is_ai_player) ||
+			_is_old_ai_player ||
 			!_patches.build_on_slopes ||
 			IsSteepTileh(tileh) ||
 			!CanBuildDepotByTileh(p2, tileh)
--- a/road_cmd.c	Tue Sep 13 09:23:23 2005 +0000
+++ b/road_cmd.c	Tue Sep 13 12:19:27 2005 +0000
@@ -457,7 +457,7 @@
 	cost = CheckRoadSlope(ti.tileh, &pieces, existing);
 	if (CmdFailed(cost)) return_cmd_error(STR_1800_LAND_SLOPED_IN_WRONG_DIRECTION);
 
-	if (cost && (!_patches.build_on_slopes || (!_patches.ainew_active && _is_ai_player)))
+	if (cost && (!_patches.build_on_slopes || _is_old_ai_player))
 		return CMD_ERROR;
 
 	if (!(ti.type == MP_STREET && (ti.map5 & 0xF0) == 0)) {
--- a/station_cmd.c	Tue Sep 13 09:23:23 2005 +0000
+++ b/station_cmd.c	Tue Sep 13 12:19:27 2005 +0000
@@ -779,7 +779,7 @@
 				b) the build_on_slopes switch is disabled
 		*/
 		if (IsSteepTileh(tileh) ||
-			(((!_patches.ainew_active && _is_ai_player) || !_patches.build_on_slopes)
+			((_is_old_ai_player || !_patches.build_on_slopes)
 			&& tileh != 0)) {
 
 			_error_message = STR_0007_FLAT_LAND_REQUIRED;
@@ -1009,7 +1009,7 @@
 
 		if (st->train_tile != 0) {
 			// check if we want to expanding an already existing station?
-			if ((!_patches.ainew_active && _is_ai_player) || !_patches.join_stations)
+			if (_is_old_ai_player || !_patches.join_stations)
 				return_cmd_error(STR_3005_TOO_CLOSE_TO_ANOTHER_RAILROAD);
 			if (!CanExpandRailroadStation(st, finalvalues, direction))
 				return CMD_ERROR;
--- a/tunnelbridge_cmd.c	Tue Sep 13 09:23:23 2005 +0000
+++ b/tunnelbridge_cmd.c	Tue Sep 13 12:19:27 2005 +0000
@@ -265,7 +265,7 @@
 
 
 	// Towns are not allowed to use bridges on slopes.
-	allow_on_slopes = ((!_is_ai_player || _patches.ainew_active)
+	allow_on_slopes = (!_is_old_ai_player
 	                   && _current_player != OWNER_TOWN && _patches.build_on_slopes);
 
 	/* Try and clear the start landscape */
@@ -410,7 +410,7 @@
 
 		bridge_len += 2;	// begin and end tiles/ramps
 
-		if (_current_player < MAX_PLAYERS && !(_is_ai_player && !_patches.ainew_active))
+		if (_current_player < MAX_PLAYERS && !_is_old_ai_player)
 			bridge_len = CalcBridgeLenCostFactor(bridge_len);
 
 		cost += ((int64)bridge_len * _price.build_bridge * b->price) >> 8;
--- a/variables.h	Tue Sep 13 09:23:23 2005 +0000
+++ b/variables.h	Tue Sep 13 12:19:27 2005 +0000
@@ -252,7 +252,7 @@
 
 VARDEF uint32 _frame_counter;
 
-VARDEF bool _is_ai_player; // current player is an AI player? - Can be removed if new AI is done
+VARDEF bool _is_old_ai_player; // current player is an oldAI player? (enables a lot of cheats..)
 
 VARDEF bool _do_autosave;
 VARDEF int _autosave_ctr;