24 #include "../../station_map.h" |
24 #include "../../station_map.h" |
25 #include "../../command_func.h" |
25 #include "../../command_func.h" |
26 #include "trolly.h" |
26 #include "trolly.h" |
27 #include "../../town.h" |
27 #include "../../town.h" |
28 #include "../../industry.h" |
28 #include "../../industry.h" |
29 #include "../../station.h" |
29 #include "../../station_base.h" |
30 #include "../../engine.h" |
30 #include "../../engine_func.h" |
31 #include "../../gui.h" |
31 #include "../../gui.h" |
32 #include "../../depot.h" |
32 #include "../../depot.h" |
33 #include "../../vehicle_base.h" |
33 #include "../../vehicle_base.h" |
34 #include "../../vehicle_func.h" |
34 #include "../../vehicle_func.h" |
35 #include "../../date_func.h" |
35 #include "../../date_func.h" |
36 #include "../ai.h" |
36 #include "../ai.h" |
37 #include "../../order.h" |
|
38 #include "../../player_base.h" |
37 #include "../../player_base.h" |
39 #include "../../player_func.h" |
38 #include "../../player_func.h" |
40 |
39 |
41 #include "table/strings.h" |
40 #include "table/strings.h" |
42 |
41 |
552 FOR_ALL_VEHICLES(v) { |
551 FOR_ALL_VEHICLES(v) { |
553 if (v->owner == _current_player) { |
552 if (v->owner == _current_player) { |
554 const Order *order; |
553 const Order *order; |
555 |
554 |
556 FOR_VEHICLE_ORDERS(v, order) { |
555 FOR_VEHICLE_ORDERS(v, order) { |
557 if (order->type == OT_GOTO_STATION && GetStation(order->dest) == st) { |
556 if (order->IsType(OT_GOTO_STATION) && GetStation(order->GetDestination()) == st) { |
558 // This vehicle has this city in its list |
557 // This vehicle has this city in its list |
559 count++; |
558 count++; |
560 } |
559 } |
561 } |
560 } |
562 } |
561 } |
1183 } |
1182 } |
1184 |
1183 |
1185 // Very handy for AI, goto depot.. but yeah, it needs to be activated ;) |
1184 // Very handy for AI, goto depot.. but yeah, it needs to be activated ;) |
1186 if (_patches.gotodepot) { |
1185 if (_patches.gotodepot) { |
1187 idx = 0; |
1186 idx = 0; |
1188 order.type = OT_GOTO_DEPOT; |
1187 order.MakeGoToDepot(GetDepotByTile(_players_ainew[p->index].depot_tile)->index, ODTFB_PART_OF_ORDERS); |
1189 order.flags = OFB_UNLOAD; |
1188 AI_DoCommand(0, _players_ainew[p->index].veh_id + (idx << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER); |
1190 order.dest = GetDepotByTile(_players_ainew[p->index].depot_tile)->index; |
|
1191 AI_DoCommand(0, _players_ainew[p->index].veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER); |
|
1192 } |
1189 } |
1193 |
1190 |
1194 idx = 0; |
1191 idx = 0; |
1195 order.type = OT_GOTO_STATION; |
1192 order.MakeGoToStation(GetStationIndex(_players_ainew[p->index].to_tile)); |
1196 order.flags = 0; |
1193 if (_players_ainew[p->index].tbt == AI_TRUCK && _players_ainew[p->index].to_deliver) order.SetLoadType(OLFB_FULL_LOAD); |
1197 order.dest = GetStationIndex(_players_ainew[p->index].to_tile); |
1194 AI_DoCommand(0, _players_ainew[p->index].veh_id + (idx << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER); |
1198 if (_players_ainew[p->index].tbt == AI_TRUCK && _players_ainew[p->index].to_deliver) |
|
1199 order.flags |= OFB_FULL_LOAD; |
|
1200 AI_DoCommand(0, _players_ainew[p->index].veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER); |
|
1201 |
1195 |
1202 idx = 0; |
1196 idx = 0; |
1203 order.type = OT_GOTO_STATION; |
1197 order.MakeGoToStation(GetStationIndex(_players_ainew[p->index].from_tile)); |
1204 order.flags = 0; |
1198 if (_players_ainew[p->index].tbt == AI_TRUCK && _players_ainew[p->index].from_deliver) order.SetLoadType(OLFB_FULL_LOAD); |
1205 order.dest = GetStationIndex(_players_ainew[p->index].from_tile); |
1199 AI_DoCommand(0, _players_ainew[p->index].veh_id + (idx << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER); |
1206 if (_players_ainew[p->index].tbt == AI_TRUCK && _players_ainew[p->index].from_deliver) |
|
1207 order.flags |= OFB_FULL_LOAD; |
|
1208 AI_DoCommand(0, _players_ainew[p->index].veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER); |
|
1209 |
1200 |
1210 // Start the engines! |
1201 // Start the engines! |
1211 _players_ainew[p->index].state = AI_STATE_START_VEHICLE; |
1202 _players_ainew[p->index].state = AI_STATE_START_VEHICLE; |
1212 } |
1203 } |
1213 |
1204 |