summaryrefslogtreecommitdiff
path: root/ai
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-14 12:00:11 +0000
committertron <tron@openttd.org>2006-03-14 12:00:11 +0000
commit273533d4c705f98a15e1376a77f34a5978ec55f6 (patch)
treee2311e3c6295b3d9db10baea067278eaaa657869 /ai
parentb1cc36da3a828c496b82d5055b5e0214d0699081 (diff)
downloadopenttd-273533d4c705f98a15e1376a77f34a5978ec55f6.tar.xz
(svn r3857) Add and use GetBridgeRampDirection()
Note: This slightly changes the behavior of GetAnyRoadBits() to only return a road piece for the start of the bridge ramp instead of a full ROAD_[XY]
Diffstat (limited to 'ai')
-rw-r--r--ai/default/default.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/ai/default/default.c b/ai/default/default.c
index 7ba7fb137..9cfa14f10 100644
--- a/ai/default/default.c
+++ b/ai/default/default.c
@@ -2,6 +2,7 @@
#include "../../stdafx.h"
#include "../../openttd.h"
+#include "../../bridge_map.h"
#include "../../functions.h"
#include "../../map.h"
#include "../../rail_map.h"
@@ -2161,7 +2162,7 @@ static bool AiRemoveTileAndGoForward(Player *p)
// Check if the bridge points in the right direction.
// This is not really needed the first place AiRemoveTileAndGoForward is called.
- if ((_m[tile].m5 & 1) != (p->ai.cur_dir_a & 1)) return false;
+ if (DiagDirToAxis(GetBridgeRampDirection(tile)) != (p->ai.cur_dir_a & 1U)) return false;
// Find other side of bridge.
offs = TileOffsByDir(p->ai.cur_dir_a);
@@ -3673,18 +3674,18 @@ pos_3:
CMD_REMOVE_ROAD);
}
} else if (IsTileType(tile, MP_TUNNELBRIDGE)) {
- byte b;
-
if (!IsTileOwner(tile, _current_player) || (_m[tile].m5 & 0xC6) != 0x80)
return;
m5 = 0;
- b = _m[tile].m5 & 0x21;
- if (b == 0) goto pos_0;
- if (b == 1) goto pos_3;
- if (b == 0x20) goto pos_2;
- goto pos_1;
+ switch (GetBridgeRampDirection(tile)) {
+ default:
+ case DIAGDIR_NE: goto pos_2;
+ case DIAGDIR_SE: goto pos_3;
+ case DIAGDIR_SW: goto pos_0;
+ case DIAGDIR_NW: goto pos_1;
+ }
}
}