summaryrefslogtreecommitdiff
path: root/ai/trolly
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-08 06:55:33 +0000
committertron <tron@openttd.org>2006-03-08 06:55:33 +0000
commitfbe939b31f8c7ea4e6e47d6d903625dd25c5e856 (patch)
tree5dc0e72ac096a8404e81f92e3e1480cb29c96061 /ai/trolly
parent313754011d04ad4913bf4028b78d75ceb359e9b3 (diff)
downloadopenttd-fbe939b31f8c7ea4e6e47d6d903625dd25c5e856.tar.xz
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
Diffstat (limited to 'ai/trolly')
-rw-r--r--ai/trolly/build.c6
-rw-r--r--ai/trolly/pathfinder.c2
-rw-r--r--ai/trolly/trolly.c7
-rw-r--r--ai/trolly/trolly.h2
4 files changed, 8 insertions, 9 deletions
diff --git a/ai/trolly/build.c b/ai/trolly/build.c
index 235166cab..2d0b25ec5 100644
--- a/ai/trolly/build.c
+++ b/ai/trolly/build.c
@@ -5,6 +5,7 @@
#include "../../debug.h"
#include "../../functions.h"
#include "../../map.h"
+#include "../../road_map.h"
#include "../../tile.h"
#include "../../command.h"
#include "trolly.h"
@@ -255,9 +256,8 @@ int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
return AI_DoCommand(tile, i, 0, flag, CMD_BUILD_ROAD_VEH);
}
-int AiNew_Build_Depot(Player *p, TileIndex tile, byte direction, byte flag)
+int AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag)
{
- static const byte _roadbits_by_dir[4] = {2,1,8,4};
int ret, ret2;
if (p->ainew.tbt == AI_TRAIN)
return AI_DoCommand(tile, 0, direction, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_TRAIN_DEPOT);
@@ -265,7 +265,7 @@ int AiNew_Build_Depot(Player *p, TileIndex tile, byte direction, byte flag)
ret = AI_DoCommand(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_DEPOT);
if (CmdFailed(ret)) return ret;
// Try to build the road from the depot
- ret2 = AI_DoCommand(tile + TileOffsByDir(direction), _roadbits_by_dir[direction], 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD);
+ ret2 = AI_DoCommand(tile + TileOffsByDir(direction), DiagDirToRoadBits(ReverseDiagDir(direction)), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD);
// If it fails, ignore it..
if (CmdFailed(ret2)) return ret;
return ret + ret2;
diff --git a/ai/trolly/pathfinder.c b/ai/trolly/pathfinder.c
index 1f77e611f..d5244a1da 100644
--- a/ai/trolly/pathfinder.c
+++ b/ai/trolly/pathfinder.c
@@ -372,7 +372,7 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr
extern uint GetRailFoundation(uint tileh, uint bits);
extern uint GetRoadFoundation(uint tileh, uint bits);
-extern uint GetBridgeFoundation(uint tileh, byte direction);
+extern uint GetBridgeFoundation(uint tileh, Axis); // XXX function declaration in .c
enum {
BRIDGE_NO_FOUNDATION = 1 << 0 | 1 << 3 | 1 << 6 | 1 << 9 | 1 << 12,
};
diff --git a/ai/trolly/trolly.c b/ai/trolly/trolly.c
index 6e8d68d8c..2ccee6fb1 100644
--- a/ai/trolly/trolly.c
+++ b/ai/trolly/trolly.c
@@ -1024,7 +1024,6 @@ static void AiNew_State_BuildPath(Player *p)
// This means we are done building!
if (p->ainew.tbt == AI_TRUCK && !_patches.roadveh_queue) {
- static const byte _roadbits_by_dir[4] = {2,1,8,4};
// If they not queue, they have to go up and down to try again at a station...
// We don't want that, so try building some road left or right of the station
int dir1, dir2, dir3;
@@ -1047,7 +1046,7 @@ static void AiNew_State_BuildPath(Player *p)
dir3 = p->ainew.to_direction;
}
- ret = AI_DoCommand(tile, _roadbits_by_dir[dir1], 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
+ ret = AI_DoCommand(tile, DiagDirToRoadBits(ReverseDiagDir(dir1)), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
if (!CmdFailed(ret)) {
dir1 = TileOffsByDir(dir1);
if (IsTileType(tile + dir1, MP_CLEAR) || IsTileType(tile + dir1, MP_TREES)) {
@@ -1059,7 +1058,7 @@ static void AiNew_State_BuildPath(Player *p)
}
}
- ret = AI_DoCommand(tile, _roadbits_by_dir[dir2], 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
+ ret = AI_DoCommand(tile, DiagDirToRoadBits(ReverseDiagDir(dir2)), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
if (!CmdFailed(ret)) {
dir2 = TileOffsByDir(dir2);
if (IsTileType(tile + dir2, MP_CLEAR) || IsTileType(tile + dir2, MP_TREES)) {
@@ -1071,7 +1070,7 @@ static void AiNew_State_BuildPath(Player *p)
}
}
- ret = AI_DoCommand(tile, _roadbits_by_dir[dir3^2], 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
+ ret = AI_DoCommand(tile, DiagDirToRoadBits(dir3), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
if (!CmdFailed(ret)) {
dir3 = TileOffsByDir(dir3);
if (IsTileType(tile + dir3, MP_CLEAR) || IsTileType(tile + dir3, MP_TREES)) {
diff --git a/ai/trolly/trolly.h b/ai/trolly/trolly.h
index b1a6ecce9..acf371896 100644
--- a/ai/trolly/trolly.h
+++ b/ai/trolly/trolly.h
@@ -256,6 +256,6 @@ int AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag)
int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag);
int AiNew_PickVehicle(Player *p);
int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag);
-int AiNew_Build_Depot(Player *p, TileIndex tile, byte direction, byte flag);
+int AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag);
#endif /* AI_TROLLY_H */