summaryrefslogtreecommitdiff
path: root/ai
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-16 15:16:27 +0000
committertron <tron@openttd.org>2006-03-16 15:16:27 +0000
commitb8da06ddb11f234451864e0b454163ebb546e4cd (patch)
tree79a0e9518fd43cbe914bddcaebf4983201598bc8 /ai
parentd6134455a5aaa7b247545886be573a555cdfc2be (diff)
downloadopenttd-b8da06ddb11f234451864e0b454163ebb546e4cd.tar.xz
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
Diffstat (limited to 'ai')
-rw-r--r--ai/default/default.c9
-rw-r--r--ai/trolly/pathfinder.c6
2 files changed, 9 insertions, 6 deletions
diff --git a/ai/default/default.c b/ai/default/default.c
index c5d463e45..5d481b7e1 100644
--- a/ai/default/default.c
+++ b/ai/default/default.c
@@ -2157,8 +2157,7 @@ static bool AiRemoveTileAndGoForward(Player *p)
return true;
}
- if (!(_m[tile].m5 & 0x40)) {
-
+ if (IsBridgeRamp(tile)) {
// Check if the bridge points in the right direction.
// This is not really needed the first place AiRemoveTileAndGoForward is called.
if (DiagDirToAxis(GetBridgeRampDirection(tile)) != (p->ai.cur_dir_a & 1U)) return false;
@@ -3669,8 +3668,12 @@ pos_3:
CMD_REMOVE_ROAD);
}
} else if (IsTileType(tile, MP_TUNNELBRIDGE)) {
- if (!IsTileOwner(tile, _current_player) || (_m[tile].m5 & 0xC6) != 0x80)
+ if (!IsTileOwner(tile, _current_player) ||
+ !IsBridge(tile) ||
+ !IsBridgeRamp(tile) ||
+ GetBridgeTransportType(tile) != TRANSPORT_RAIL) {
return;
+ }
m5 = 0;
diff --git a/ai/trolly/pathfinder.c b/ai/trolly/pathfinder.c
index 128351f32..25b3683ad 100644
--- a/ai/trolly/pathfinder.c
+++ b/ai/trolly/pathfinder.c
@@ -2,6 +2,7 @@
#include "../../stdafx.h"
#include "../../openttd.h"
+#include "../../bridge_map.h"
#include "../../debug.h"
#include "../../functions.h"
#include "../../map.h"
@@ -44,8 +45,7 @@ static bool IsRoad(TileIndex tile)
(IsTileType(tile, MP_STREET) && !IsTileDepotType(tile, TRANSPORT_ROAD)) ||
(IsTileType(tile, MP_TUNNELBRIDGE) && (
(IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_ROAD) ||
- // road bridge?
- ((_m[tile].m5 & 0x80) != 0 && (_m[tile].m5 & 0x2) == 0x2)
+ (IsBridge(tile) && GetBridgeTransportType(tile) == TRANSPORT_ROAD)
));
}
@@ -234,7 +234,7 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr
if (IsTunnel(atile)) {
if (GetTunnelDirection(atile) != i) continue;
} else {
- if ((_m[atile].m5 & 1U) != DiagDirToAxis(i)) continue;
+ if (GetBridgeRampDirection(atile) != i) continue;
}
}
}