OpenTTD Source
20240919-master-gdf0233f4c2
|
Go to the documentation of this file.
10 #include "../stdafx.h"
16 #include "../order_backup.h"
17 #include "../settings_type.h"
18 #include "../network/network.h"
20 #include "../safeguards.h"
28 uint8_t old_flags = this->
flags;
41 case OT_GOTO_DEPOT:
case OT_GOTO_STATION:
case OT_LOADING:
break;
45 if (this->
GetType() != OT_GOTO_DEPOT) {
47 if ((old_flags & 2) != 0) {
49 }
else if ((old_flags & 4) == 0) {
59 if ((old_flags & 1) != 0) {
61 }
else if ((old_flags & 2) != 0) {
84 return Order(
GB(packed, 0, 4),
GB(packed, 4, 4),
GB(packed, 8, 8));
107 static const SaveLoad _order_desc[] = {
130 SlSetArrayIndex(order->index);
145 len /=
sizeof(uint16_t);
146 std::vector<uint16_t> orders(len);
148 SlCopy(&orders[0], len, SLE_UINT16);
150 for (
size_t i = 0; i < len; ++i) {
155 len /=
sizeof(uint32_t);
156 std::vector<uint32_t> orders(len);
158 SlCopy(&orders[0], len, SLE_UINT32);
160 for (
size_t i = 0; i < len; ++i) {
161 new (i)
Order(
GB(orders[i], 0, 8),
GB(orders[i], 8, 8),
GB(orders[i], 16, 16));
167 size_t order_index = o->
index;
169 if (o->IsType(OT_NOTHING)) {
176 if (prev !=
nullptr) prev->
next = o;
203 static const SaveLoad _orderlist_desc[] = {
207 return _orderlist_desc;
219 SlSetArrayIndex(list->index);
241 SlObject(list, GetOrderListDescription());
248 static const SaveLoad _order_backup_desc[] = {
267 return _order_backup_desc;
284 SlSetArrayIndex(ob->index);
305 SlObject(ob, GetOrderBackupDescription());
void MakeDummy()
Makes this order a Dummy order.
@ REF_ORDER
Load/save a reference to an order.
@ OUFB_UNLOAD
Force unloading all cargo onto the platform, possibly not getting paid.
@ SLV_5
5.0 1429 5.1 1440 5.2 1525 0.3.6
bool IsType(OrderType type) const
Check whether this order is of the given type.
const SaveLoadCompat _order_sl_compat[]
Original field order for _order_desc.
void SetLoadType(OrderLoadFlags load_type)
Set how the consist must be loaded.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
@ ODTFB_SERVICE
This depot order is because of the servicing limit.
std::span< const struct SaveLoad > SaveLoadTable
A table of SaveLoad entries.
@ OUFB_TRANSFER
Transfer all cargo onto the platform.
@ OLFB_FULL_LOAD
Full load all cargoes of the consist.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
bool sg_new_nonstop
ttdpatch compatible nonstop handling read from pre v93 savegames
@ SL_MIN_VERSION
First savegame version.
bool _network_server
network-server is active
void SlCopy(void *object, size_t length, VarType conv)
Copy a list of SL_VARs to/from a savegame.
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
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.
@ ODTF_MANUAL
Manually initiated order.
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...
@ SLV_192
192 26700 FS#6066 Fix saving of order backups
Handlers and description of chunk.
const SaveLoadCompat _orderlist_sl_compat[]
Original field order for _orderlist_desc.
void FixPointers() const override
Fix the pointers.
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.
const SaveLoadCompat _order_backup_sl_compat[]
Original field order for _order_backup_desc.
@ 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.
@ 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.
static Order UnpackVersion4Order(uint16_t packed)
Unpacks a order from savegames with version 4 and lower.
void Save() const override
Save the chunk.
#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.
bool _networking
are we in networking mode?
@ SL_MAX_VERSION
Highest possible saveload version.
void ConvertFromOldSavegame()
Converts this order from an old savegame's version; it moves all bits to the new location.
@ REF_VEHICLE
Load/save a reference to a vehicle.
void Save() const override
Save the chunk.
void Save() const override
Save the chunk.
@ 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.
uint8_t flags
Load/unload types, depot order/action types.
@ ODATFB_HALT
Service the vehicle and then halt it.
@ 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.
void FixPointers() const override
Fix the pointers.
@ 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...
void Load() const override
Load the chunk.
bool sg_full_load_any
new full load calculation, any cargo must be full read from pre v93 savegames
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
void SetDepotOrderType(OrderDepotTypeFlags depot_order_type)
Set the cause to go to the depot.
Order UnpackOldOrder(uint16_t packed)
Unpacks a order from savegames made with TTD(Patch)
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.
void Load() const override
Load the chunk.
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
@ ODATF_SERVICE_ONLY
Only service the vehicle.
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...
void FixPointers() const override
Fix the pointers.
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
Order * next
Pointer to next order. If nullptr, end of list.
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.
void Load() const override
Load the chunk.
GUISettings gui
settings related to the GUI
@ OLFB_NO_LOAD
Do not load anything.
@ SLV_TIMETABLE_START_TICKS_FIX
322 PR#11557 Fix for missing convert timetable start from a date to ticks.