diff options
Diffstat (limited to 'ai')
-rw-r--r-- | ai/default/default.c | 13 | ||||
-rw-r--r-- | ai/trolly/trolly.c | 6 |
2 files changed, 10 insertions, 9 deletions
diff --git a/ai/default/default.c b/ai/default/default.c index dd0700fd1..50b5c7674 100644 --- a/ai/default/default.c +++ b/ai/default/default.c @@ -4,6 +4,7 @@ #include "../../openttd.h" #include "../../functions.h" #include "../../map.h" +#include "../../road.h" #include "../../tile.h" #include "../../player.h" #include "../../vehicle.h" @@ -2506,12 +2507,12 @@ static int32 AiDoBuildDefaultRoadBlock(TileIndex tile, const AiDefaultBlockData if (p->mode == 2) { if (IsTileType(c, MP_STREET) && - (_m[c].m5 & 0xF0) == 0 && - (_m[c].m5 & p->attr) != 0) { + GetRoadType(c) == ROAD_NORMAL && + (GetRoadBits(c) & p->attr) != 0) { roadflag |= 2; // all bits are already built? - if ((_m[c].m5 & p->attr) == p->attr) continue; + if ((GetRoadBits(c) & p->attr) == p->attr) continue; } ret = DoCommandByTile(c, p->attr, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD); @@ -2548,7 +2549,7 @@ clear_town_stuff:; if (GetTileSlope(c, NULL) != 0) return CMD_ERROR; - if (!IsTileType(c, MP_STREET) || (_m[c].m5 & 0xF0) != 0) { + if (!IsTileType(c, MP_STREET) || GetRoadType(c) != ROAD_NORMAL) { ret = DoCommandByTile(c, 0, 0, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_LANDSCAPE_CLEAR); if (CmdFailed(ret)) return CMD_ERROR; } @@ -2726,7 +2727,7 @@ static bool AiEnumFollowRoad(TileIndex tile, AiRoadEnum *a, int track, uint leng if (dist <= a->best_dist) { TileIndex tile2 = TILE_MASK(tile + TileOffsByDir(_dir_by_track[track])); - if (IsTileType(tile2, MP_STREET) && GB(_m[tile2].m5, 4, 4) == 0) { + if (IsTileType(tile2, MP_STREET) && GetRoadType(tile2) == ROAD_NORMAL) { a->best_dist = dist; a->best_tile = tile; a->best_track = track; @@ -3631,7 +3632,7 @@ pos_3: if (IsLevelCrossing(tile)) goto is_rail_crossing; - if ((_m[tile].m5 & 0xF0) == 0x20) { // depot + if (GetRoadType(tile) == ROAD_DEPOT) { uint dir; // Check if there are any stations around. diff --git a/ai/trolly/trolly.c b/ai/trolly/trolly.c index c46324cd0..30eda929e 100644 --- a/ai/trolly/trolly.c +++ b/ai/trolly/trolly.c @@ -21,6 +21,7 @@ #include "../../openttd.h" #include "../../debug.h" #include "../../functions.h" +#include "../../road.h" #include "../../table/strings.h" #include "../../map.h" #include "../../tile.h" @@ -793,8 +794,7 @@ static void AiNew_State_FindDepot(Player *p) tile = p->ainew.path_info.route[i]; for (j = 0; j < 4; j++) { if (IsTileType(tile + TileOffsByDir(j), MP_STREET)) { - // Its a street, test if it is a depot - if (_m[tile + TileOffsByDir(j)].m5 & 0x20) { + if (GetRoadType(tile + TileOffsByDir(j)) == ROAD_DEPOT) { // We found a depot, is it ours? (TELL ME!!!) if (IsTileOwner(tile + TileOffsByDir(j), _current_player)) { // Now, is it pointing to the right direction......... @@ -1100,7 +1100,7 @@ static void AiNew_State_BuildDepot(Player *p) int res = 0; assert(p->ainew.state == AI_STATE_BUILD_DEPOT); - if (IsTileType(p->ainew.depot_tile, MP_STREET) && _m[p->ainew.depot_tile].m5 & 0x20) { + if (IsTileType(p->ainew.depot_tile, MP_STREET) && GetRoadType(p->ainew.depot_tile) == ROAD_DEPOT) { if (IsTileOwner(p->ainew.depot_tile, _current_player)) { // The depot is already builded! p->ainew.state = AI_STATE_BUILD_VEHICLE; |