OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
10 #include "../stdafx.h"
11 #include "../order_backup.h"
12 #include "../settings_type.h"
13 #include "../network/network.h"
17 #include "../safeguards.h"
25 uint8 old_flags = this->
flags;
38 case OT_GOTO_DEPOT:
case OT_GOTO_STATION:
case OT_LOADING:
break;
42 if (this->
GetType() != OT_GOTO_DEPOT) {
44 if ((old_flags & 2) != 0) {
46 }
else if ((old_flags & 4) == 0) {
56 if ((old_flags & 1) != 0) {
58 }
else if ((old_flags & 2) != 0) {
81 return Order(
GB(packed, 8, 8) << 16 |
GB(packed, 4, 4) << 8 |
GB(packed, 0, 4));
104 static const SaveLoad _order_desc[] = {
124 static void Save_ORDR()
127 SlSetArrayIndex(order->index);
128 SlObject(order, GetOrderDescription());
132 static void Load_ORDR()
142 len /=
sizeof(uint16);
143 uint16 *orders = MallocT<uint16>(len + 1);
145 SlArray(orders, len, SLE_UINT16);
147 for (
size_t i = 0; i < len; ++i) {
154 len /=
sizeof(uint32);
155 uint32 *orders = MallocT<uint32>(len + 1);
157 SlArray(orders, len, SLE_UINT32);
159 for (
size_t i = 0; i < len; ++i) {
160 new (i)
Order(orders[i]);
168 size_t order_index = o->
index;
170 if (o->
IsType(OT_NOTHING)) {
177 if (prev !=
nullptr) prev->
next = o;
184 SlObject(order, GetOrderDescription());
189 static void Ptrs_ORDR()
201 static const SaveLoad _orderlist_desc[] = {
206 return _orderlist_desc;
209 static void Save_ORDL()
212 SlSetArrayIndex(list->index);
213 SlObject(list, GetOrderListDescription());
217 static void Load_ORDL()
224 SlObject(list, GetOrderListDescription());
229 static void Ptrs_ORDL()
232 SlObject(list, GetOrderListDescription());
238 static const SaveLoad _order_backup_desc[] = {
258 return _order_backup_desc;
261 static void Save_BKOR()
269 SlSetArrayIndex(ob->index);
270 SlObject(ob, GetOrderBackupDescription());
281 SlObject(ob, GetOrderBackupDescription());
285 static void Ptrs_BKOR()
288 SlObject(ob, GetOrderBackupDescription());
293 {
'BKOR', Save_BKOR, Load_BKOR, Ptrs_BKOR,
nullptr, CH_ARRAY},
294 {
'ORDR', Save_ORDR, Load_ORDR, Ptrs_ORDR,
nullptr, CH_ARRAY},
295 {
'ORDL', Save_ORDL, Load_ORDL, Ptrs_ORDL,
nullptr, CH_ARRAY |
CH_LAST},
void MakeDummy()
Makes this order a Dummy order.
@ REF_ORDER
Load/save a reference to an order.
Order UnpackOldOrder(uint16 packed)
Unpacks a order from savegames made with TTD(Patch)
@ OUFB_UNLOAD
Force unloading all cargo onto the platform, possibly not getting paid.
bool IsType(OrderType type) const
Check whether this order is of the given type.
void SetLoadType(OrderLoadFlags load_type)
Set how the consist must be loaded.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
@ SL_MIN_VERSION
First savegame version.
@ ODTFB_SERVICE
This depot order is because of the servicing limit.
@ OUFB_TRANSFER
Transfer all cargo onto the platform.
@ OLFB_FULL_LOAD
Full load all cargoes of the consist.
bool sg_new_nonstop
ttdpatch compatible nonstop handling read from pre v93 savegames
bool _network_server
network-server is active
bool new_nonstop
ttdpatch compatible nonstop handling
Tindex index
Index of this pool item.
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
#define SLE_STR(base, variable, type, length)
Storage of a string in every savegame version.
@ ODTF_MANUAL
Manually initiated order.
@ CH_LAST
Last chunk in this array.
OrderDepotTypeFlags
Reasons that could cause us to go to the depot.
ClientSettings _settings_client
The current settings for this game.
void AssignOrder(const Order &other)
Assign data to an order (from another order) This function makes sure that the index is maintained co...
Handlers and description of chunk.
#define SLE_CONDNULL(length, from, to)
Empty space in some savegame versions.
SavegameType _savegame_type
type of savegame we are loading
#define SLE_REF(base, variable, type)
Storage of a reference in every version of a savegame.
OrderType GetType() const
Get the type of order of this order.
@ ONSF_NO_STOP_AT_ANY_STATION
The vehicle will not stop at any stations it passes including the destination.
@ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS
The vehicle will not stop at any stations it passes except the destination.
@ SLV_5
5.0 1429 5.1 1440 5.2 1525 0.3.6
@ OLF_FULL_LOAD_ANY
Full load a single cargo of the consist.
@ ONSF_STOP_EVERYWHERE
The vehicle will stop at any station it passes and the destination.
@ OUF_UNLOAD_IF_POSSIBLE
Unload all cargo that the station accepts.
#define SLE_END()
End marker of a struct/class save or load.
#define SLE_CONDREF(base, variable, type, from, to)
Storage of a reference in some savegame versions.
@ ODTFB_PART_OF_ORDERS
This depot order is because of a regular order.
static bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor=0)
Checks whether the savegame is below major.
bool _networking
are we in networking mode?
void ConvertFromOldSavegame()
Converts this order from an old savegame's version; it moves all bits to the new location.
void SlObject(void *object, const SaveLoad *sld)
Main SaveLoad function.
@ REF_VEHICLE
Load/save a reference to a vehicle.
@ SLV_182
182 25115 FS#5492, r25259, r25296 Goal status
@ OLF_LOAD_IF_POSSIBLE
Load as long as there is cargo that fits in the train.
void SetStopLocation(OrderStopLocation stop_location)
Set where we must stop at the platform.
@ ODATFB_HALT
Service the vehicle and then halt it.
@ SL_MAX_VERSION
Highest possible saveload version.
@ SGT_TTD
TTD savegame (can be detected incorrectly)
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
@ OSL_PLATFORM_FAR_END
Stop at the far end of the platform.
size_t SlGetFieldLength()
Get the length of the current object.
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
bool sg_full_load_any
new full load calculation, any cargo must be full read from pre v93 savegames
void SetDepotOrderType(OrderDepotTypeFlags depot_order_type)
Set the cause to go to the depot.
void SetDepotActionType(OrderDepotActionFlags depot_service_type)
Set what we are going to do in the depot.
#define SLE_SSTR(base, variable, type)
Storage of a std::string in every savegame version.
@ ODATF_SERVICE_ONLY
Only service the vehicle.
@ SLV_192
192 26700 FS#6066 Fix saving of order backups
void SetUnloadType(OrderUnloadFlags unload_type)
Set how the consist must be unloaded.
Data for backing up an order of a vehicle so it can be restored after a vehicle is rebuilt in the sam...
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
static Order UnpackVersion4Order(uint16 packed)
Unpacks a order from savegames with version 4 and lower.
void SlArray(void *array, size_t length, VarType conv)
Save/Load an array.
Order * next
Pointer to next order. If nullptr, end of list.
uint8 flags
Load/unload types, depot order/action types.
void SetNonStopType(OrderNonStopFlags non_stop_type)
Set whether we must stop at stations or not.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
GUISettings gui
settings related to the GUI
@ OLFB_NO_LOAD
Do not load anything.