summaryrefslogtreecommitdiff
path: root/ai
diff options
context:
space:
mode:
Diffstat (limited to 'ai')
-rw-r--r--ai/default/default.c15
-rw-r--r--ai/trolly/trolly.c5
2 files changed, 11 insertions, 9 deletions
diff --git a/ai/default/default.c b/ai/default/default.c
index 4ba475e06..e87079dc5 100644
--- a/ai/default/default.c
+++ b/ai/default/default.c
@@ -7,6 +7,7 @@
#include "../../map.h"
#include "../../rail_map.h"
#include "../../road_map.h"
+#include "../../station_map.h"
#include "../../tile.h"
#include "../../player.h"
#include "../../tunnel_map.h"
@@ -2313,11 +2314,11 @@ static void AiStateBuildRail(Player *p)
p->ai.banned_tile_count = 0;
}
-static int AiGetStationIdByDef(TileIndex tile, int id)
+static StationID AiGetStationIdByDef(TileIndex tile, int id)
{
const AiDefaultBlockData *p = _default_rail_track_data[id]->data;
while (p->mode != 1) p++;
- return _m[TILE_ADD(tile, ToTileIndexDiff(p->tileoffs))].m2;
+ return GetStationIndex(TILE_ADD(tile, ToTileIndexDiff(p->tileoffs)));
}
static void AiStateBuildRailVeh(Player *p)
@@ -3096,11 +3097,11 @@ static void AiStateBuildRoad(Player *p)
p->ai.banned_tile_count = 0;
}
-static int AiGetStationIdFromRoadBlock(TileIndex tile, int id)
+static StationID AiGetStationIdFromRoadBlock(TileIndex tile, int id)
{
const AiDefaultBlockData *p = _road_default_block_data[id]->data;
while (p->mode != 1) p++;
- return _m[TILE_ADD(tile, ToTileIndexDiff(p->tileoffs))].m2;
+ return GetStationIndex(TILE_ADD(tile, ToTileIndexDiff(p->tileoffs)));
}
static void AiStateBuildRoadVehicles(Player *p)
@@ -3406,11 +3407,11 @@ static void AiStateBuildDefaultAirportBlocks(Player *p)
p->ai.state = AIS_BUILD_AIRCRAFT_VEHICLES;
}
-static int AiGetStationIdFromAircraftBlock(TileIndex tile, int id)
+static StationID AiGetStationIdFromAircraftBlock(TileIndex tile, int id)
{
const AiDefaultBlockData *p = _airport_default_block_data[id];
while (p->mode != 1) p++;
- return _m[TILE_ADD(tile, ToTileIndexDiff(p->tileoffs))].m2;
+ return GetStationIndex(TILE_ADD(tile, ToTileIndexDiff(p->tileoffs)));
}
static void AiStateBuildAircraftVehicles(Player *p)
@@ -3431,7 +3432,7 @@ static void AiStateBuildAircraftVehicles(Player *p)
/* XXX - Have the AI pick the hangar terminal in an airport. Eg get airport-type
* and offset to the FIRST depot because the AI picks the st->xy tile */
- tile += ToTileIndexDiff(GetAirport(GetStation(_m[tile].m2)->airport_type)->airport_depots[0]);
+ tile += ToTileIndexDiff(GetAirport(GetStationByTile(tile)->airport_type)->airport_depots[0]);
if (CmdFailed(DoCommandByTile(tile, veh, 0, DC_EXEC, CMD_BUILD_AIRCRAFT))) return;
loco_id = _new_aircraft_id;
diff --git a/ai/trolly/trolly.c b/ai/trolly/trolly.c
index 57cac9698..eac7793ae 100644
--- a/ai/trolly/trolly.c
+++ b/ai/trolly/trolly.c
@@ -22,6 +22,7 @@
#include "../../debug.h"
#include "../../functions.h"
#include "../../road_map.h"
+#include "../../station_map.h"
#include "../../table/strings.h"
#include "../../map.h"
#include "../../tile.h"
@@ -1202,7 +1203,7 @@ static void AiNew_State_GiveOrders(Player *p)
idx = 0;
order.type = OT_GOTO_STATION;
order.flags = 0;
- order.station = _m[p->ainew.to_tile].m2;
+ order.station = GetStationIndex(p->ainew.to_tile);
if (p->ainew.tbt == AI_TRUCK && p->ainew.to_deliver)
order.flags |= OF_FULL_LOAD;
AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
@@ -1210,7 +1211,7 @@ static void AiNew_State_GiveOrders(Player *p)
idx = 0;
order.type = OT_GOTO_STATION;
order.flags = 0;
- order.station = _m[p->ainew.from_tile].m2;
+ order.station = GetStationIndex(p->ainew.from_tile);
if (p->ainew.tbt == AI_TRUCK && p->ainew.from_deliver)
order.flags |= OF_FULL_LOAD;
AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);