ai/trolly/trolly.c
changeset 4389 18d6ccfb5335
parent 4354 10f4ce894eb1
child 4527 fa30d19685c2
equal deleted inserted replaced
4388:c8a66d26e146 4389:18d6ccfb5335
   553 	FOR_ALL_VEHICLES(v) {
   553 	FOR_ALL_VEHICLES(v) {
   554 		if (v->owner == _current_player) {
   554 		if (v->owner == _current_player) {
   555 			const Order *order;
   555 			const Order *order;
   556 
   556 
   557 			FOR_VEHICLE_ORDERS(v, order) {
   557 			FOR_VEHICLE_ORDERS(v, order) {
   558 				if (order->type == OT_GOTO_STATION && GetStation(order->station) == st) {
   558 				if (order->type == OT_GOTO_STATION && GetStation(order->dest.station) == st) {
   559 					// This vehicle has this city in its list
   559 					// This vehicle has this city in its list
   560 					count++;
   560 					count++;
   561 				}
   561 				}
   562 			}
   562 			}
   563 		}
   563 		}
  1190 	// Very handy for AI, goto depot.. but yeah, it needs to be activated ;)
  1190 	// Very handy for AI, goto depot.. but yeah, it needs to be activated ;)
  1191 	if (_patches.gotodepot) {
  1191 	if (_patches.gotodepot) {
  1192 		idx = 0;
  1192 		idx = 0;
  1193 		order.type = OT_GOTO_DEPOT;
  1193 		order.type = OT_GOTO_DEPOT;
  1194 		order.flags = OF_UNLOAD;
  1194 		order.flags = OF_UNLOAD;
  1195 		order.station = GetDepotByTile(p->ainew.depot_tile)->index;
  1195 		order.dest.depot = GetDepotByTile(p->ainew.depot_tile)->index;
  1196 		AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
  1196 		AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
  1197 	}
  1197 	}
  1198 
  1198 
  1199 	idx = 0;
  1199 	idx = 0;
  1200 	order.type = OT_GOTO_STATION;
  1200 	order.type = OT_GOTO_STATION;
  1201 	order.flags = 0;
  1201 	order.flags = 0;
  1202 	order.station = GetStationIndex(p->ainew.to_tile);
  1202 	order.dest.station = GetStationIndex(p->ainew.to_tile);
  1203 	if (p->ainew.tbt == AI_TRUCK && p->ainew.to_deliver)
  1203 	if (p->ainew.tbt == AI_TRUCK && p->ainew.to_deliver)
  1204 		order.flags |= OF_FULL_LOAD;
  1204 		order.flags |= OF_FULL_LOAD;
  1205 	AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
  1205 	AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
  1206 
  1206 
  1207 	idx = 0;
  1207 	idx = 0;
  1208 	order.type = OT_GOTO_STATION;
  1208 	order.type = OT_GOTO_STATION;
  1209 	order.flags = 0;
  1209 	order.flags = 0;
  1210 	order.station = GetStationIndex(p->ainew.from_tile);
  1210 	order.dest.station = GetStationIndex(p->ainew.from_tile);
  1211 	if (p->ainew.tbt == AI_TRUCK && p->ainew.from_deliver)
  1211 	if (p->ainew.tbt == AI_TRUCK && p->ainew.from_deliver)
  1212 		order.flags |= OF_FULL_LOAD;
  1212 		order.flags |= OF_FULL_LOAD;
  1213 	AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
  1213 	AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
  1214 
  1214 
  1215 	// Start the engines!
  1215 	// Start the engines!