summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-02-14 15:59:16 +0000
committerfrosch <frosch@openttd.org>2008-02-14 15:59:16 +0000
commit43c0f7ea8efdd6915b5ca1d311fa1186175b2e52 (patch)
treea43464406df621d20a7dd83755ef86ae3474e9ea /src/ai
parent739b118c6b79ca85be89aed3653abf046b1640f0 (diff)
downloadopenttd-43c0f7ea8efdd6915b5ca1d311fa1186175b2e52.tar.xz
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/default/default.cpp9
-rw-r--r--src/ai/trolly/trolly.cpp5
2 files changed, 6 insertions, 8 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp
index 95fab9619..077e2a849 100644
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -2639,8 +2639,7 @@ static CommandCost AiDoBuildDefaultRoadBlock(TileIndex tile, const AiDefaultBloc
_cleared_town = NULL;
if (p->mode == 2) {
- if (IsTileType(c, MP_ROAD) &&
- GetRoadTileType(c) == ROAD_TILE_NORMAL &&
+ if (IsNormalRoadTile(c) &&
(GetRoadBits(c, ROADTYPE_ROAD) & p->attr) != 0) {
roadflag |= 2;
@@ -2682,7 +2681,7 @@ clear_town_stuff:;
if (GetTileSlope(c, NULL) != SLOPE_FLAT) return CMD_ERROR;
- if (!IsTileType(c, MP_ROAD) || GetRoadTileType(c) != ROAD_TILE_NORMAL) {
+ if (!IsNormalRoadTile(c)) {
ret = DoCommand(c, 0, 0, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return CMD_ERROR;
}
@@ -2857,7 +2856,7 @@ static bool AiEnumFollowRoad(TileIndex tile, AiRoadEnum *a, int track, uint leng
if (dist <= a->best_dist) {
TileIndex tile2 = TILE_MASK(tile + TileOffsByDiagDir(_dir_by_track[track]));
- if (IsTileType(tile2, MP_ROAD) && GetRoadTileType(tile2) == ROAD_TILE_NORMAL) {
+ if (IsNormalRoadTile(tile2)) {
a->best_dist = dist;
a->best_tile = tile;
a->best_track = track;
@@ -3740,7 +3739,7 @@ pos_3:
if (IsLevelCrossing(tile)) goto is_rail_crossing;
- if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) {
+ if (IsRoadDepot(tile)) {
DiagDirection dir;
TileIndex t;
diff --git a/src/ai/trolly/trolly.cpp b/src/ai/trolly/trolly.cpp
index 8f62b7e95..1a5a0fce4 100644
--- a/src/ai/trolly/trolly.cpp
+++ b/src/ai/trolly/trolly.cpp
@@ -801,8 +801,7 @@ static void AiNew_State_FindDepot(Player *p)
for (j = DIAGDIR_BEGIN; j < DIAGDIR_END; j++) {
TileIndex t = tile + TileOffsByDiagDir(j);
- if (IsTileType(t, MP_ROAD) &&
- GetRoadTileType(t) == ROAD_TILE_DEPOT &&
+ if (IsRoadDepotTile(t) &&
IsTileOwner(t, _current_player) &&
GetRoadDepotDirection(t) == ReverseDiagDir(j)) {
_players_ainew[p->index].depot_tile = t;
@@ -1102,7 +1101,7 @@ static void AiNew_State_BuildDepot(Player *p)
CommandCost res;
assert(_players_ainew[p->index].state == AI_STATE_BUILD_DEPOT);
- if (IsTileType(_players_ainew[p->index].depot_tile, MP_ROAD) && GetRoadTileType(_players_ainew[p->index].depot_tile) == ROAD_TILE_DEPOT) {
+ if (IsRoadDepotTile(_players_ainew[p->index].depot_tile)) {
if (IsTileOwner(_players_ainew[p->index].depot_tile, _current_player)) {
// The depot is already built
_players_ainew[p->index].state = AI_STATE_BUILD_VEHICLE;