summaryrefslogtreecommitdiff
path: root/src/ai/trolly/build.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-01-09 16:40:02 +0000
committerrubidium <rubidium@openttd.org>2008-01-09 16:40:02 +0000
commitb4337eba83e34ddaac29684d78202ae9623e9240 (patch)
tree9569d5da425e71768a78a6ffdbad415f3fb38811 /src/ai/trolly/build.cpp
parenta27a240b879ab555f36695ba30c9dea0e2a6817e (diff)
downloadopenttd-b4337eba83e34ddaac29684d78202ae9623e9240.tar.xz
(svn r11792) -Codechange: move some (virtually) globally included AI related structs to a place where they are only included a few times.
Diffstat (limited to 'src/ai/trolly/build.cpp')
-rw-r--r--src/ai/trolly/build.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/ai/trolly/build.cpp b/src/ai/trolly/build.cpp
index d54575666..388a40b66 100644
--- a/src/ai/trolly/build.cpp
+++ b/src/ai/trolly/build.cpp
@@ -70,7 +70,7 @@ CommandCost AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, by
if (type2 == 0 && type != 0) type2 = type;
// Now, simply, build the bridge!
- if (p->ainew.tbt == AI_TRAIN) {
+ if (_players_ainew[p->index].tbt == AI_TRAIN) {
return AI_DoCommand(tile_a, tile_b, (0x00 << 8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
} else {
return AI_DoCommand(tile_a, tile_b, ((0x80 | ROADTYPES_ROAD) << 8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
@@ -144,7 +144,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
res = AI_DoCommand(route[part], 0, dir, flag, CMD_BUILD_SINGLE_RAIL);
if (CmdFailed(res)) {
// Problem.. let's just abort it all!
- p->ainew.state = AI_STATE_NOTHING;
+ _players_ainew[p->index].state = AI_STATE_NOTHING;
return CommandCost();
}
cost.AddCost(res);
@@ -200,7 +200,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
if (CmdFailed(res) && flag == DC_EXEC && !IsTileType(route[part], MP_ROAD) && !EnsureNoVehicleOnGround(route[part])) {
// Problem.. let's just abort it all!
DEBUG(ai, 0, "[BuidPath] route building failed at tile 0x%X, aborting", route[part]);
- p->ainew.state = AI_STATE_NOTHING;
+ _players_ainew[p->index].state = AI_STATE_NOTHING;
return CommandCost();
}
@@ -226,7 +226,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
// It returns INVALID_ENGINE if not suitable engine is found
EngineID AiNew_PickVehicle(Player *p)
{
- if (p->ainew.tbt == AI_TRAIN) {
+ if (_players_ainew[p->index].tbt == AI_TRAIN) {
// Not supported yet
return INVALID_ENGINE;
} else {
@@ -244,7 +244,7 @@ EngineID AiNew_PickVehicle(Player *p)
CommandCost ret;
/* Skip vehicles which can't take our cargo type */
- if (rvi->cargo_type != p->ainew.cargo && !CanRefitTo(i, p->ainew.cargo)) continue;
+ if (rvi->cargo_type != _players_ainew[p->index].cargo && !CanRefitTo(i, _players_ainew[p->index].cargo)) continue;
// Is it availiable?
// Also, check if the reliability of the vehicle is above the AI_VEHICLE_MIN_RELIABILTY
@@ -272,20 +272,20 @@ void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2)
Player* p = GetPlayer(_current_player);
if (success) {
- p->ainew.state = AI_STATE_GIVE_ORDERS;
- p->ainew.veh_id = _new_vehicle_id;
+ _players_ainew[p->index].state = AI_STATE_GIVE_ORDERS;
+ _players_ainew[p->index].veh_id = _new_vehicle_id;
- if (GetVehicle(p->ainew.veh_id)->cargo_type != p->ainew.cargo) {
+ if (GetVehicle(_players_ainew[p->index].veh_id)->cargo_type != _players_ainew[p->index].cargo) {
/* Cargo type doesn't match, so refit it */
- if (CmdFailed(DoCommand(tile, p->ainew.veh_id, p->ainew.cargo, DC_EXEC, CMD_REFIT_ROAD_VEH))) {
+ if (CmdFailed(DoCommand(tile, _players_ainew[p->index].veh_id, _players_ainew[p->index].cargo, DC_EXEC, CMD_REFIT_ROAD_VEH))) {
/* Refit failed, so sell the vehicle */
- DoCommand(tile, p->ainew.veh_id, 0, DC_EXEC, CMD_SELL_ROAD_VEH);
- p->ainew.state = AI_STATE_NOTHING;
+ DoCommand(tile, _players_ainew[p->index].veh_id, 0, DC_EXEC, CMD_SELL_ROAD_VEH);
+ _players_ainew[p->index].state = AI_STATE_NOTHING;
}
}
} else {
/* XXX this should be handled more gracefully */
- p->ainew.state = AI_STATE_NOTHING;
+ _players_ainew[p->index].state = AI_STATE_NOTHING;
}
}
@@ -296,7 +296,7 @@ CommandCost AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
EngineID i = AiNew_PickVehicle(p);
if (i == INVALID_ENGINE) return CMD_ERROR;
- if (p->ainew.tbt == AI_TRAIN) return CMD_ERROR;
+ if (_players_ainew[p->index].tbt == AI_TRAIN) return CMD_ERROR;
if (flag & DC_EXEC) {
return AI_DoCommandCc(tile, i, 0, flag, CMD_BUILD_ROAD_VEH, CcAI);
@@ -308,7 +308,7 @@ CommandCost AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
CommandCost AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag)
{
CommandCost ret, ret2;
- if (p->ainew.tbt == AI_TRAIN) {
+ if (_players_ainew[p->index].tbt == AI_TRAIN) {
return AI_DoCommand(tile, 0, direction, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_TRAIN_DEPOT);
} else {
ret = AI_DoCommand(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_DEPOT);