12 #include "../stdafx.h" 13 #include "../order_backup.h" 14 #include "../settings_type.h" 15 #include "../network/network.h" 19 #include "../safeguards.h" 27 uint8 old_flags = this->
flags;
40 case OT_GOTO_DEPOT:
case OT_GOTO_STATION:
case OT_LOADING:
break;
44 if (this->
GetType() != OT_GOTO_DEPOT) {
46 if ((old_flags & 2) != 0) {
48 }
else if ((old_flags & 4) == 0) {
58 if ((old_flags & 1) != 0) {
60 }
else if ((old_flags & 2) != 0) {
83 return Order(
GB(packed, 8, 8) << 16 |
GB(packed, 4, 4) << 8 |
GB(packed, 0, 4));
106 static const SaveLoad _order_desc[] = {
126 static void Save_ORDR()
130 FOR_ALL_ORDERS(order) {
131 SlSetArrayIndex(order->
index);
136 static void Load_ORDR()
146 len /=
sizeof(uint16);
147 uint16 *orders = MallocT<uint16>(len + 1);
149 SlArray(orders, len, SLE_UINT16);
151 for (
size_t i = 0; i < len; ++i) {
158 len /=
sizeof(uint32);
159 uint32 *orders = MallocT<uint32>(len + 1);
161 SlArray(orders, len, SLE_UINT32);
163 for (
size_t i = 0; i < len; ++i) {
164 new (i)
Order(orders[i]);
174 if (o->
IsType(OT_NOTHING)) {
181 if (prev != NULL) prev->
next = o;
197 static void Ptrs_ORDR()
211 static const SaveLoad _orderlist_desc[] = {
216 return _orderlist_desc;
219 static void Save_ORDL()
223 FOR_ALL_ORDER_LISTS(list) {
224 SlSetArrayIndex(list->
index);
225 SlObject(list, GetOrderListDescription());
229 static void Load_ORDL()
236 SlObject(list, GetOrderListDescription());
241 static void Ptrs_ORDL()
245 FOR_ALL_ORDER_LISTS(list) {
246 SlObject(list, GetOrderListDescription());
252 static const SaveLoad _order_backup_desc[] = {
272 return _order_backup_desc;
275 static void Save_BKOR()
284 SlSetArrayIndex(ob->
index);
285 SlObject(ob, GetOrderBackupDescription());
296 SlObject(ob, GetOrderBackupDescription());
300 static void Ptrs_BKOR()
304 SlObject(ob, GetOrderBackupDescription());
309 {
'BKOR', Save_BKOR, Load_BKOR, Ptrs_BKOR, NULL, CH_ARRAY},
310 {
'ORDR', Save_ORDR, Load_ORDR, Ptrs_ORDR, NULL, CH_ARRAY},
311 {
'ORDL', Save_ORDL, Load_ORDL, Ptrs_ORDL, NULL, CH_ARRAY |
CH_LAST},
#define SLE_CONDNULL(length, from, to)
Empty space in some savegame versions.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
bool _networking
are we in networking mode?
uint16 GetTravelTime() const
Get the time in ticks a vehicle will probably take to reach the destination (timetabled or not)...
Load as long as there is cargo that fits in the train.
#define SLE_CONDREF(base, variable, type, from, to)
Storage of a reference in some savegame versions.
void SetDepotOrderType(OrderDepotTypeFlags depot_order_type)
Set the cause to go to the depot.
#define SLE_REF(base, variable, type)
Storage of a reference in every version of a savegame.
void SetDepotActionType(OrderDepotActionFlags depot_service_type)
Set what we are going to do in the depot.
Unload all cargo that the station accepts.
Only service the vehicle.
Tindex index
Index of this pool item.
TTD savegame (can be detected incorrectly)
CargoID refit_cargo
Refit CargoID.
void SetUnloadType(OrderUnloadFlags unload_type)
Set how the consist must be unloaded.
size_t SlGetFieldLength()
Get the length of the current object.
Order * next
Pointer to next order. If NULL, end of list.
void SlArray(void *array, size_t length, VarType conv)
Save/Load an array.
Stop at the far end of the platform.
DestinationID dest
The destination of the order.
uint16 travel_time
How long in ticks the journey to this destination should take.
The vehicle will stop at any station it passes and the destination.
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
uint8 type
The type of order + non-stop flags.
void SetNonStopType(OrderNonStopFlags non_stop_type)
Set whether we must stop at stations or not.
#define FOR_ALL_ORDER_BACKUPS(var)
Iterator over all order backups.
Order UnpackOldOrder(uint16 packed)
Unpacks a order from savegames made with TTD(Patch)
The vehicle will not stop at any stations it passes including the destination.
void MakeDummy()
Makes this order a Dummy order.
Manually initiated order.
bool IsType(OrderType type) const
Check whether this order is of the given type.
ClientSettings _settings_client
The current settings for this game.
friend const struct SaveLoad * GetOrderDescription()
Saving and loading of orders.
uint8 flags
Load/unload types, depot order/action types.
SavegameType _savegame_type
type of savegame we are loading
Load/save a reference to an order.
Service the vehicle and then halt it.
void SetWaitTimetabled(bool timetabled)
Set if the wait time is explicitly timetabled (unless the order is conditional).
#define SL_MAX_VERSION
Highest possible savegame version.
static bool IsSavegameVersionBefore(uint16 major, byte minor=0)
Checks whether the savegame is below major.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
Load/save a reference to a vehicle.
Handlers and description of chunk.
Transfer all cargo onto the platform.
void SetLoadType(OrderLoadFlags load_type)
Set how the consist must be loaded.
uint16 GetWaitTime() const
Get the time in ticks a vehicle will probably wait at the destination (timetabled or not)...
#define SLE_END()
End marker of a struct/class save or load.
GUISettings gui
settings related to the GUI
bool sg_new_nonstop
ttdpatch compatible nonstop handling read from pre v93 savegames
uint16 wait_time
How long in ticks to wait at the destination.
void SetTravelTimetabled(bool timetabled)
Set if the travel time is explicitly timetabled (unless the order is conditional).
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Full load all cargoes of the consist.
void SlObject(void *object, const SaveLoad *sld)
Main SaveLoad function.
void AssignOrder(const Order &other)
Assign data to an order (from another order) This function makes sure that the index is maintained co...
The vehicle will not stop at any stations it passes except the destination.
bool _network_server
network-server is active
bool sg_full_load_any
new full load calculation, any cargo must be full read from pre v93 savegames
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
#define SLE_STR(base, variable, type, length)
Storage of a string in every savegame version.
OrderType GetType() const
Get the type of order of this order.
bool new_nonstop
ttdpatch compatible nonstop handling
Force unloading all cargo onto the platform, possibly not getting paid.
void ConvertFromOldSavegame()
Converts this order from an old savegame's version; it moves all bits to the new location.
Data for backing up an order of a vehicle so it can be restored after a vehicle is rebuilt in the sam...
This depot order is because of a regular order.
static Order UnpackVersion4Order(uint16 packed)
Unpacks a order from savegames with version 4 and lower.
uint16 max_speed
How fast the vehicle may go on the way to the destination.
Declaration of functions used in more save/load files.
Full load a single cargo of the consist.
This depot order is because of the servicing limit.
void SetStopLocation(OrderStopLocation stop_location)
Set where we must stop at the platform.
OrderDepotTypeFlags
Reasons that could cause us to go to the depot.
Last chunk in this array.