47 order.refit_subtype = 0; |
47 order.refit_subtype = 0; |
48 order.index = 0; // avoid compiler warning |
48 order.index = 0; // avoid compiler warning |
49 |
49 |
50 // Sanity check |
50 // Sanity check |
51 // TTD stores invalid orders as OT_NOTHING with non-zero flags/station |
51 // TTD stores invalid orders as OT_NOTHING with non-zero flags/station |
52 if (order.type == OT_NOTHING && (order.flags != 0 || order.dest != 0)) { |
52 if (!order.IsValid() && (order.flags != 0 || order.dest != 0)) { |
53 order.type = OT_DUMMY; |
53 order.type = OT_DUMMY; |
54 order.flags = 0; |
54 order.flags = 0; |
55 } |
55 } |
56 |
56 |
57 return order; |
57 return order; |
107 * Allocate a new order |
107 * Allocate a new order |
108 * |
108 * |
109 * @return Order* if a free space is found, else NULL. |
109 * @return Order* if a free space is found, else NULL. |
110 * |
110 * |
111 */ |
111 */ |
112 static Order *AllocateOrder(void) |
112 static Order *AllocateOrder() |
113 { |
113 { |
114 Order *order; |
114 Order *order; |
115 |
115 |
116 /* We don't use FOR_ALL here, because FOR_ALL skips invalid items. |
116 /* We don't use FOR_ALL here, because FOR_ALL skips invalid items. |
117 * TODO - This is just a temporary stage, this will be removed. */ |
117 * TODO - This is just a temporary stage, this will be removed. */ |
118 for (order = GetOrder(0); order != NULL; order = (order->index + 1U < GetOrderPoolSize()) ? GetOrder(order->index + 1U) : NULL) { |
118 for (order = GetOrder(0); order != NULL; order = (order->index + 1U < GetOrderPoolSize()) ? GetOrder(order->index + 1U) : NULL) { |
119 if (!IsValidOrder(order)) { |
119 if (!order->IsValid()) { |
120 OrderID index = order->index; |
120 OrderID index = order->index; |
121 |
121 |
122 memset(order, 0, sizeof(*order)); |
122 memset(order, 0, sizeof(*order)); |
123 order->index = index; |
123 order->index = index; |
124 order->next = NULL; |
124 order->next = NULL; |
211 if (st->owner != OWNER_NONE && !CheckOwnership(st->owner)) { |
211 if (st->owner != OWNER_NONE && !CheckOwnership(st->owner)) { |
212 return CMD_ERROR; |
212 return CMD_ERROR; |
213 } |
213 } |
214 |
214 |
215 switch (v->type) { |
215 switch (v->type) { |
216 case VEH_Train: |
216 case VEH_TRAIN: |
217 if (!(st->facilities & FACIL_TRAIN)) return CMD_ERROR; |
217 if (!(st->facilities & FACIL_TRAIN)) return CMD_ERROR; |
218 break; |
218 break; |
219 |
219 |
220 case VEH_Road: |
220 case VEH_ROAD: |
221 if (v->cargo_type == CT_PASSENGERS) { |
221 if (v->cargo_type == CT_PASSENGERS) { |
222 if (!(st->facilities & FACIL_BUS_STOP)) return CMD_ERROR; |
222 if (!(st->facilities & FACIL_BUS_STOP)) return CMD_ERROR; |
223 } else { |
223 } else { |
224 if (!(st->facilities & FACIL_TRUCK_STOP)) return CMD_ERROR; |
224 if (!(st->facilities & FACIL_TRUCK_STOP)) return CMD_ERROR; |
225 } |
225 } |
226 break; |
226 break; |
227 |
227 |
228 case VEH_Ship: |
228 case VEH_SHIP: |
229 if (!(st->facilities & FACIL_DOCK)) return CMD_ERROR; |
229 if (!(st->facilities & FACIL_DOCK)) return CMD_ERROR; |
230 break; |
230 break; |
231 |
231 |
232 case VEH_Aircraft: |
232 case VEH_AIRCRAFT: |
233 if (!(st->facilities & FACIL_AIRPORT)) return CMD_ERROR; |
233 if (!(st->facilities & FACIL_AIRPORT)) return CMD_ERROR; |
234 break; |
234 break; |
235 |
235 |
236 default: return CMD_ERROR; |
236 default: return CMD_ERROR; |
237 } |
237 } |
252 case OF_NON_STOP | OF_FULL_LOAD: |
252 case OF_NON_STOP | OF_FULL_LOAD: |
253 case OF_NON_STOP | OF_FULL_LOAD | OF_TRANSFER: |
253 case OF_NON_STOP | OF_FULL_LOAD | OF_TRANSFER: |
254 case OF_NON_STOP | OF_UNLOAD: |
254 case OF_NON_STOP | OF_UNLOAD: |
255 case OF_NON_STOP | OF_UNLOAD | OF_TRANSFER: |
255 case OF_NON_STOP | OF_UNLOAD | OF_TRANSFER: |
256 case OF_NON_STOP | OF_TRANSFER: |
256 case OF_NON_STOP | OF_TRANSFER: |
257 if (v->type != VEH_Train) return CMD_ERROR; |
257 if (v->type != VEH_TRAIN) return CMD_ERROR; |
258 break; |
258 break; |
259 |
259 |
260 default: return CMD_ERROR; |
260 default: return CMD_ERROR; |
261 } |
261 } |
262 break; |
262 break; |
263 } |
263 } |
264 |
264 |
265 case OT_GOTO_DEPOT: { |
265 case OT_GOTO_DEPOT: { |
266 if (v->type == VEH_Aircraft) { |
266 if (v->type == VEH_AIRCRAFT) { |
267 const Station* st; |
267 const Station* st; |
268 |
268 |
269 if (!IsValidStationID(new_order.dest)) return CMD_ERROR; |
269 if (!IsValidStationID(new_order.dest)) return CMD_ERROR; |
270 st = GetStation(new_order.dest); |
270 st = GetStation(new_order.dest); |
271 |
271 |
281 dp = GetDepot(new_order.dest); |
281 dp = GetDepot(new_order.dest); |
282 |
282 |
283 if (!CheckOwnership(GetTileOwner(dp->xy))) return CMD_ERROR; |
283 if (!CheckOwnership(GetTileOwner(dp->xy))) return CMD_ERROR; |
284 |
284 |
285 switch (v->type) { |
285 switch (v->type) { |
286 case VEH_Train: |
286 case VEH_TRAIN: |
287 if (!IsTileDepotType(dp->xy, TRANSPORT_RAIL)) return CMD_ERROR; |
287 if (!IsTileDepotType(dp->xy, TRANSPORT_RAIL)) return CMD_ERROR; |
288 break; |
288 break; |
289 |
289 |
290 case VEH_Road: |
290 case VEH_ROAD: |
291 if (!IsTileDepotType(dp->xy, TRANSPORT_ROAD)) return CMD_ERROR; |
291 if (!IsTileDepotType(dp->xy, TRANSPORT_ROAD)) return CMD_ERROR; |
292 break; |
292 break; |
293 |
293 |
294 case VEH_Ship: |
294 case VEH_SHIP: |
295 if (!IsTileDepotType(dp->xy, TRANSPORT_WATER)) return CMD_ERROR; |
295 if (!IsTileDepotType(dp->xy, TRANSPORT_WATER)) return CMD_ERROR; |
296 break; |
296 break; |
297 |
297 |
298 default: return CMD_ERROR; |
298 default: return CMD_ERROR; |
299 } |
299 } |
307 case OF_PART_OF_ORDERS | OF_HALT_IN_DEPOT: |
307 case OF_PART_OF_ORDERS | OF_HALT_IN_DEPOT: |
308 break; |
308 break; |
309 |
309 |
310 case OF_NON_STOP | OF_PART_OF_ORDERS: |
310 case OF_NON_STOP | OF_PART_OF_ORDERS: |
311 case OF_NON_STOP | OF_PART_OF_ORDERS | OF_HALT_IN_DEPOT: |
311 case OF_NON_STOP | OF_PART_OF_ORDERS | OF_HALT_IN_DEPOT: |
312 if (v->type != VEH_Train) return CMD_ERROR; |
312 if (v->type != VEH_TRAIN) return CMD_ERROR; |
313 break; |
313 break; |
314 |
314 |
315 default: return CMD_ERROR; |
315 default: return CMD_ERROR; |
316 } |
316 } |
317 break; |
317 break; |
318 } |
318 } |
319 |
319 |
320 case OT_GOTO_WAYPOINT: { |
320 case OT_GOTO_WAYPOINT: { |
321 const Waypoint* wp; |
321 const Waypoint* wp; |
322 |
322 |
323 if (v->type != VEH_Train) return CMD_ERROR; |
323 if (v->type != VEH_TRAIN) return CMD_ERROR; |
324 |
324 |
325 if (!IsValidWaypointID(new_order.dest)) return CMD_ERROR; |
325 if (!IsValidWaypointID(new_order.dest)) return CMD_ERROR; |
326 wp = GetWaypoint(new_order.dest); |
326 wp = GetWaypoint(new_order.dest); |
327 |
327 |
328 if (!CheckOwnership(GetTileOwner(wp->xy))) return CMD_ERROR; |
328 if (!CheckOwnership(GetTileOwner(wp->xy))) return CMD_ERROR; |
351 |
351 |
352 /* XXX - This limit is only here because the backuppedorders can't |
352 /* XXX - This limit is only here because the backuppedorders can't |
353 * handle any more then this.. */ |
353 * handle any more then this.. */ |
354 if (v->num_orders >= MAX_BACKUP_ORDER_COUNT) return_cmd_error(STR_8832_TOO_MANY_ORDERS); |
354 if (v->num_orders >= MAX_BACKUP_ORDER_COUNT) return_cmd_error(STR_8832_TOO_MANY_ORDERS); |
355 |
355 |
356 if (v->type == VEH_Ship && |
356 if (v->type == VEH_SHIP && |
357 IsHumanPlayer(v->owner) && |
357 IsHumanPlayer(v->owner) && |
358 !_patches.new_pathfinding_all) { |
358 !_patches.new_pathfinding_all) { |
359 // Make sure the new destination is not too far away from the previous |
359 // Make sure the new destination is not too far away from the previous |
360 const Order *prev = NULL; |
360 const Order *prev = NULL; |
361 uint n = 0; |
361 uint n = 0; |
494 } else { |
494 } else { |
495 GetVehicleOrder(v, sel_ord - 1)->next = order->next; |
495 GetVehicleOrder(v, sel_ord - 1)->next = order->next; |
496 } |
496 } |
497 |
497 |
498 /* Give the item free */ |
498 /* Give the item free */ |
499 order->type = OT_NOTHING; |
499 order->Free(); |
500 order->next = NULL; |
|
501 |
500 |
502 u = GetFirstVehicleFromSharedList(v); |
501 u = GetFirstVehicleFromSharedList(v); |
503 DeleteOrderWarnings(u); |
502 DeleteOrderWarnings(u); |
504 for (; u != NULL; u = u->next_shared) { |
503 for (; u != NULL; u = u->next_shared) { |
505 u->num_orders--; |
504 u->num_orders--; |
551 VehicleOrderID b = v->cur_order_index + 1; |
550 VehicleOrderID b = v->cur_order_index + 1; |
552 if (b >= v->num_orders) b = 0; |
551 if (b >= v->num_orders) b = 0; |
553 |
552 |
554 v->cur_order_index = b; |
553 v->cur_order_index = b; |
555 |
554 |
556 if (v->type == VEH_Train) v->u.rail.days_since_order_progr = 0; |
555 if (v->type == VEH_TRAIN) v->u.rail.days_since_order_progr = 0; |
557 |
556 |
558 if (v->type == VEH_Road) ClearSlot(v); |
557 if (v->type == VEH_ROAD) ClearSlot(v); |
559 |
558 |
560 /* NON-stop flag is misused to see if a train is in a station that is |
559 /* NON-stop flag is misused to see if a train is in a station that is |
561 * on his order list or not */ |
560 * on his order list or not */ |
562 if (v->current_order.type == OT_LOADING && HASBIT(v->current_order.flags, OFB_NON_STOP)) |
561 if (v->current_order.type == OT_LOADING && HASBIT(v->current_order.flags, OFB_NON_STOP)) |
563 v->current_order.flags = 0; |
562 v->current_order.flags = 0; |
564 |
563 |
565 InvalidateVehicleOrder(v); |
564 InvalidateVehicleOrder(v); |
566 } |
565 } |
567 |
566 |
568 /* We have an aircraft/ship, they have a mini-schedule, so update them all */ |
567 /* We have an aircraft/ship, they have a mini-schedule, so update them all */ |
569 if (v->type == VEH_Aircraft) InvalidateWindowClasses(WC_AIRCRAFT_LIST); |
568 if (v->type == VEH_AIRCRAFT) InvalidateWindowClasses(WC_AIRCRAFT_LIST); |
570 if (v->type == VEH_Ship) InvalidateWindowClasses(WC_SHIPS_LIST); |
569 if (v->type == VEH_SHIP) InvalidateWindowClasses(WC_SHIPS_LIST); |
571 |
570 |
572 return 0; |
571 return 0; |
573 } |
572 } |
574 |
573 |
575 |
574 |
683 /* Sanity checks */ |
682 /* Sanity checks */ |
684 if (!CheckOwnership(src->owner) || dst->type != src->type || dst == src) |
683 if (!CheckOwnership(src->owner) || dst->type != src->type || dst == src) |
685 return CMD_ERROR; |
684 return CMD_ERROR; |
686 |
685 |
687 /* Trucks can't share orders with busses (and visa versa) */ |
686 /* Trucks can't share orders with busses (and visa versa) */ |
688 if (src->type == VEH_Road) { |
687 if (src->type == VEH_ROAD) { |
689 if (src->cargo_type != dst->cargo_type && (src->cargo_type == CT_PASSENGERS || dst->cargo_type == CT_PASSENGERS)) |
688 if (src->cargo_type != dst->cargo_type && (src->cargo_type == CT_PASSENGERS || dst->cargo_type == CT_PASSENGERS)) |
690 return CMD_ERROR; |
689 return CMD_ERROR; |
691 } |
690 } |
692 |
691 |
693 /* Is the vehicle already in the shared list? */ |
692 /* Is the vehicle already in the shared list? */ |
730 /* Sanity checks */ |
729 /* Sanity checks */ |
731 if (!CheckOwnership(src->owner) || dst->type != src->type || dst == src) |
730 if (!CheckOwnership(src->owner) || dst->type != src->type || dst == src) |
732 return CMD_ERROR; |
731 return CMD_ERROR; |
733 |
732 |
734 /* Trucks can't copy all the orders from busses (and visa versa) */ |
733 /* Trucks can't copy all the orders from busses (and visa versa) */ |
735 if (src->type == VEH_Road) { |
734 if (src->type == VEH_ROAD) { |
736 const Order *order; |
735 const Order *order; |
737 TileIndex required_dst = INVALID_TILE; |
736 TileIndex required_dst = INVALID_TILE; |
738 |
737 |
739 FOR_VEHICLE_ORDERS(src, order) { |
738 FOR_VEHICLE_ORDERS(src, order) { |
740 if (order->type == OT_GOTO_STATION) { |
739 if (order->type == OT_GOTO_STATION) { |
900 |
898 |
901 /* CMD_NO_TEST_IF_IN_NETWORK is used here, because CMD_INSERT_ORDER checks if the |
899 /* CMD_NO_TEST_IF_IN_NETWORK is used here, because CMD_INSERT_ORDER checks if the |
902 * order number is one more than the current amount of orders, and because |
900 * order number is one more than the current amount of orders, and because |
903 * in network the commands are queued before send, the second insert always |
901 * in network the commands are queued before send, the second insert always |
904 * fails in test mode. By bypassing the test-mode, that no longer is a problem. */ |
902 * fails in test mode. By bypassing the test-mode, that no longer is a problem. */ |
905 for (i = 0; bak->order[i].type != OT_NOTHING; i++) { |
903 for (i = 0; bak->order[i].IsValid(); i++) { |
906 if (!DoCommandP(0, v->index + (i << 16), PackOrder(&bak->order[i]), NULL, CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK)) |
904 if (!DoCommandP(0, v->index + (i << 16), PackOrder(&bak->order[i]), NULL, CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK)) |
907 break; |
905 break; |
908 } |
906 } |
909 |
907 |
910 /* Restore vehicle order-index and service interval */ |
908 /* Restore vehicle order-index and service interval */ |
949 |
947 |
950 static TileIndex GetStationTileForVehicle(const Vehicle* v, const Station* st) |
948 static TileIndex GetStationTileForVehicle(const Vehicle* v, const Station* st) |
951 { |
949 { |
952 switch (v->type) { |
950 switch (v->type) { |
953 default: NOT_REACHED(); |
951 default: NOT_REACHED(); |
954 case VEH_Train: return st->train_tile; |
952 case VEH_TRAIN: return st->train_tile; |
955 case VEH_Aircraft: return st->airport_tile; |
953 case VEH_AIRCRAFT: return st->airport_tile; |
956 case VEH_Ship: return st->dock_tile; |
954 case VEH_SHIP: return st->dock_tile; |
957 case VEH_Road: |
955 case VEH_ROAD: |
958 if (v->cargo_type == CT_PASSENGERS) { |
956 if (v->cargo_type == CT_PASSENGERS) { |
959 return (st->bus_stops != NULL) ? st->bus_stops->xy : 0; |
957 return (st->bus_stops != NULL) ? st->bus_stops->xy : 0; |
960 } else { |
958 } else { |
961 return (st->truck_stops != NULL) ? st->truck_stops->xy : 0; |
959 return (st->truck_stops != NULL) ? st->truck_stops->xy : 0; |
962 } |
960 } |
1061 if (v->last_station_visited == destination && type == OT_GOTO_STATION) { |
1059 if (v->last_station_visited == destination && type == OT_GOTO_STATION) { |
1062 v->last_station_visited = INVALID_STATION; |
1060 v->last_station_visited = INVALID_STATION; |
1063 } |
1061 } |
1064 |
1062 |
1065 order = &v->current_order; |
1063 order = &v->current_order; |
1066 if ((v->type == VEH_Aircraft && order->type == OT_GOTO_DEPOT ? OT_GOTO_STATION : order->type) == type && |
1064 if ((v->type == VEH_AIRCRAFT && order->type == OT_GOTO_DEPOT ? OT_GOTO_STATION : order->type) == type && |
1067 v->current_order.dest == destination) { |
1065 v->current_order.dest == destination) { |
1068 order->type = OT_DUMMY; |
1066 order->type = OT_DUMMY; |
1069 order->flags = 0; |
1067 order->flags = 0; |
1070 InvalidateWindow(WC_VEHICLE_VIEW, v->index); |
1068 InvalidateWindow(WC_VEHICLE_VIEW, v->index); |
1071 } |
1069 } |
1072 |
1070 |
1073 /* Clear the order from the order-list */ |
1071 /* Clear the order from the order-list */ |
1074 invalidate = false; |
1072 invalidate = false; |
1075 FOR_VEHICLE_ORDERS(v, order) { |
1073 FOR_VEHICLE_ORDERS(v, order) { |
1076 if ((v->type == VEH_Aircraft && order->type == OT_GOTO_DEPOT ? OT_GOTO_STATION : order->type) == type && |
1074 if ((v->type == VEH_AIRCRAFT && order->type == OT_GOTO_DEPOT ? OT_GOTO_STATION : order->type) == type && |
1077 order->dest == destination) { |
1075 order->dest == destination) { |
1078 order->type = OT_DUMMY; |
1076 order->type = OT_DUMMY; |
1079 order->flags = 0; |
1077 order->flags = 0; |
1080 invalidate = true; |
1078 invalidate = true; |
1081 } |
1079 } |
1110 * Delete all orders from a vehicle |
1108 * Delete all orders from a vehicle |
1111 * |
1109 * |
1112 */ |
1110 */ |
1113 void DeleteVehicleOrders(Vehicle *v) |
1111 void DeleteVehicleOrders(Vehicle *v) |
1114 { |
1112 { |
1115 Order *cur, *next; |
|
1116 |
|
1117 DeleteOrderWarnings(v); |
1113 DeleteOrderWarnings(v); |
1118 |
1114 |
1119 /* If we have a shared order-list, don't delete the list, but just |
1115 /* If we have a shared order-list, don't delete the list, but just |
1120 remove our pointer */ |
1116 remove our pointer */ |
1121 if (IsOrderListShared(v)) { |
1117 if (IsOrderListShared(v)) { |
1144 InvalidateVehicleOrder(u); |
1140 InvalidateVehicleOrder(u); |
1145 return; |
1141 return; |
1146 } |
1142 } |
1147 |
1143 |
1148 /* Remove the orders */ |
1144 /* Remove the orders */ |
1149 cur = v->orders; |
1145 Order *cur = v->orders; |
1150 v->orders = NULL; |
1146 v->orders = NULL; |
1151 v->num_orders = 0; |
1147 v->num_orders = 0; |
1152 |
1148 |
1153 if (cur != NULL) { |
1149 if (cur != NULL) { |
1154 /* Delete the vehicle list of shared orders, if any */ |
1150 /* Delete the vehicle list of shared orders, if any */ |
1155 WindowClass window_class = WC_NONE; |
1151 WindowClass window_class = WC_NONE; |
1156 |
1152 |
1157 switch (v->type) { |
1153 switch (v->type) { |
1158 default: NOT_REACHED(); |
1154 default: NOT_REACHED(); |
1159 case VEH_Train: window_class = WC_TRAINS_LIST; break; |
1155 case VEH_TRAIN: window_class = WC_TRAINS_LIST; break; |
1160 case VEH_Road: window_class = WC_ROADVEH_LIST; break; |
1156 case VEH_ROAD: window_class = WC_ROADVEH_LIST; break; |
1161 case VEH_Ship: window_class = WC_SHIPS_LIST; break; |
1157 case VEH_SHIP: window_class = WC_SHIPS_LIST; break; |
1162 case VEH_Aircraft: window_class = WC_AIRCRAFT_LIST; break; |
1158 case VEH_AIRCRAFT: window_class = WC_AIRCRAFT_LIST; break; |
1163 } |
1159 } |
1164 DeleteWindowById(window_class, (cur->index << 16) | (v->type << 11) | VLW_SHARED_ORDERS | v->owner); |
1160 DeleteWindowById(window_class, (cur->index << 16) | (v->type << 11) | VLW_SHARED_ORDERS | v->owner); |
1165 } |
1161 |
1166 |
1162 cur->FreeChain(); // Free the orders. |
1167 while (cur != NULL) { |
|
1168 next = cur->next; |
|
1169 DeleteOrder(cur); |
|
1170 cur = next; |
|
1171 } |
1163 } |
1172 } |
1164 } |
1173 |
1165 |
1174 /** |
1166 /** |
1175 * |
1167 * |
1197 FOR_VEHICLE_ORDERS(v, order) if (order->type != OT_DUMMY) return true; |
1189 FOR_VEHICLE_ORDERS(v, order) if (order->type != OT_DUMMY) return true; |
1198 |
1190 |
1199 return false; |
1191 return false; |
1200 } |
1192 } |
1201 |
1193 |
1202 void InitializeOrders(void) |
1194 void InitializeOrders() |
1203 { |
1195 { |
1204 CleanPool(&_Order_pool); |
1196 CleanPool(&_Order_pool); |
1205 AddBlockToPool(&_Order_pool); |
1197 AddBlockToPool(&_Order_pool); |
1206 |
1198 |
1207 _backup_orders_tile = 0; |
1199 _backup_orders_tile = 0; |
1219 * We will never use those free bytes, but we have to keep this line to allow loading of old savegames */ |
1211 * We will never use those free bytes, but we have to keep this line to allow loading of old savegames */ |
1220 SLE_CONDNULL(10, 5, 35), |
1212 SLE_CONDNULL(10, 5, 35), |
1221 SLE_END() |
1213 SLE_END() |
1222 }; |
1214 }; |
1223 |
1215 |
1224 static void Save_ORDR(void) |
1216 static void Save_ORDR() |
1225 { |
1217 { |
1226 Order *order; |
1218 Order *order; |
1227 |
1219 |
1228 FOR_ALL_ORDERS(order) { |
1220 FOR_ALL_ORDERS(order) { |
1229 SlSetArrayIndex(order->index); |
1221 SlSetArrayIndex(order->index); |
1230 SlObject(order, _order_desc); |
1222 SlObject(order, _order_desc); |
1231 } |
1223 } |
1232 } |
1224 } |
1233 |
1225 |
1234 static void Load_ORDR(void) |
1226 static void Load_ORDR() |
1235 { |
1227 { |
1236 if (CheckSavegameVersionOldStyle(5, 2)) { |
1228 if (CheckSavegameVersionOldStyle(5, 2)) { |
1237 /* Version older than 5.2 did not have a ->next pointer. Convert them |
1229 /* Version older than 5.2 did not have a ->next pointer. Convert them |
1238 (in the old days, the orderlist was 5000 items big) */ |
1230 (in the old days, the orderlist was 5000 items big) */ |
1239 uint len = SlGetFieldLength(); |
1231 uint len = SlGetFieldLength(); |
1272 } |
1264 } |
1273 |
1265 |
1274 /* Update all the next pointer */ |
1266 /* Update all the next pointer */ |
1275 for (i = 1; i < len; ++i) { |
1267 for (i = 1; i < len; ++i) { |
1276 /* The orders were built like this: |
1268 /* The orders were built like this: |
1277 * Vehicle one had order[0], and as long as order++.type was not |
1269 * While the order is valid, set the previous will get it's next pointer set |
1278 * OT_NOTHING, it was part of the order-list of that vehicle */ |
1270 * We start with index 1 because no order will have the first in it's next pointer */ |
1279 if (GetOrder(i)->type != OT_NOTHING) |
1271 if (GetOrder(i)->IsValid()) |
1280 GetOrder(i - 1)->next = GetOrder(i); |
1272 GetOrder(i - 1)->next = GetOrder(i); |
1281 } |
1273 } |
1282 } else { |
1274 } else { |
1283 int index; |
1275 int index; |
1284 |
1276 |