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. */ |
1197 FOR_VEHICLE_ORDERS(v, order) if (order->type != OT_DUMMY) return true; |
1197 FOR_VEHICLE_ORDERS(v, order) if (order->type != OT_DUMMY) return true; |
1198 |
1198 |
1199 return false; |
1199 return false; |
1200 } |
1200 } |
1201 |
1201 |
1202 void InitializeOrders(void) |
1202 void InitializeOrders() |
1203 { |
1203 { |
1204 CleanPool(&_Order_pool); |
1204 CleanPool(&_Order_pool); |
1205 AddBlockToPool(&_Order_pool); |
1205 AddBlockToPool(&_Order_pool); |
1206 |
1206 |
1207 _backup_orders_tile = 0; |
1207 _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 */ |
1219 * 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), |
1220 SLE_CONDNULL(10, 5, 35), |
1221 SLE_END() |
1221 SLE_END() |
1222 }; |
1222 }; |
1223 |
1223 |
1224 static void Save_ORDR(void) |
1224 static void Save_ORDR() |
1225 { |
1225 { |
1226 Order *order; |
1226 Order *order; |
1227 |
1227 |
1228 FOR_ALL_ORDERS(order) { |
1228 FOR_ALL_ORDERS(order) { |
1229 SlSetArrayIndex(order->index); |
1229 SlSetArrayIndex(order->index); |
1230 SlObject(order, _order_desc); |
1230 SlObject(order, _order_desc); |
1231 } |
1231 } |
1232 } |
1232 } |
1233 |
1233 |
1234 static void Load_ORDR(void) |
1234 static void Load_ORDR() |
1235 { |
1235 { |
1236 if (CheckSavegameVersionOldStyle(5, 2)) { |
1236 if (CheckSavegameVersionOldStyle(5, 2)) { |
1237 /* Version older than 5.2 did not have a ->next pointer. Convert them |
1237 /* Version older than 5.2 did not have a ->next pointer. Convert them |
1238 (in the old days, the orderlist was 5000 items big) */ |
1238 (in the old days, the orderlist was 5000 items big) */ |
1239 uint len = SlGetFieldLength(); |
1239 uint len = SlGetFieldLength(); |