summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-09-13 12:19:27 +0000
committertruelight <truelight@openttd.org>2005-09-13 12:19:27 +0000
commit4936e936544d89ea042fa7742de5f0f8eb126245 (patch)
tree1d0b1d986e906226e0a4c2b67110203eefaa8479
parent2264103610a5ddd81e50530e1a6afeb0aa28d37c (diff)
downloadopenttd-4936e936544d89ea042fa7742de5f0f8eb126245.tar.xz
(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..
-rw-r--r--ai/ai.c6
-rw-r--r--aircraft_cmd.c5
-rw-r--r--rail_cmd.c5
-rw-r--r--road_cmd.c2
-rw-r--r--station_cmd.c4
-rw-r--r--tunnelbridge_cmd.c4
-rw-r--r--variables.h2
7 files changed, 15 insertions, 13 deletions
diff --git a/ai/ai.c b/ai/ai.c
index 12b7b9eda..3fcd94cff 100644
--- a/ai/ai.c
+++ b/ai/ai.c
@@ -126,8 +126,12 @@ void AI_RunTick(byte player)
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;
+ }
}
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 147f7e861..825707dc1 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -253,10 +253,9 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
_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
diff --git a/rail_cmd.c b/rail_cmd.c
index 941b3141c..a9178c680 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -247,8 +247,7 @@ static uint32 CheckRailSlope(uint tileh, TrackBits rail_bits, TrackBits existing
)) { // 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 @@ int32 CmdBuildTrainDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
*/
if (tileh != 0 && (
- (!_patches.ainew_active && _is_ai_player) ||
+ _is_old_ai_player ||
!_patches.build_on_slopes ||
IsSteepTileh(tileh) ||
!CanBuildDepotByTileh(p2, tileh)
diff --git a/road_cmd.c b/road_cmd.c
index dd6b945f3..3b6eff3c1 100644
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -457,7 +457,7 @@ do_clear:;
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)) {
diff --git a/station_cmd.c b/station_cmd.c
index 6496cffb1..17c8162dd 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -779,7 +779,7 @@ int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invali
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 @@ int32 CmdBuildRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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;
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index 1dbe6c9f1..fa451b330 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -265,7 +265,7 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
// 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 @@ not_valid_below:;
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;
diff --git a/variables.h b/variables.h
index c7290e146..328991781 100644
--- a/variables.h
+++ b/variables.h
@@ -252,7 +252,7 @@ VARDEF byte _cur_month;
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;