OpenTTD Source: src/saveload/order_sl.cpp File Reference

OpenTTD Source 15.3

Data Structures | Functions | Variables
order_sl.cpp File Reference

Code handling saving and loading of orders. More...

`#include "../stdafx.h"`
`#include "saveload.h"`
`#include "compat/order_sl_compat.h"`
`#include "saveload_internal.h"`
`#include "../order_backup.h"`
`#include "../settings_type.h"`
`#include "../network/network.h"`
`#include "../safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | ORDRChunkHandler
class | SlOrders< T >
struct | ORDLChunkHandler
struct | BKORChunkHandler

## Functions
static Order | UnpackVersion4Order (uint16_t packed)
| Unpacks a order from savegames with version 4 and lower.
Order | UnpackOldOrder (uint16_t packed)
| Unpacks a order from savegames made with TTD(Patch)
void | ClearOldOrders ()
| Clear all old orders.
OldOrderSaveLoadItem * | GetOldOrder (size_t ref_index)
| Get a pointer to an old order with the given reference index.
OldOrderSaveLoadItem & | AllocateOldOrder (size_t pool_index)
| Allocate an old order with the given pool index.
SaveLoadTable | GetOrderDescription ()
SaveLoadTable | GetOrderListDescription ()
SaveLoadTable | GetOrderBackupDescription ()
const ChunkHandlerTable | _order_chunk_handlers (order_chunk_handlers)

## Variables
static std::vector< OldOrderSaveLoadItem > | _old_order_saveload_pool
| Temporary storage for conversion from old order pool.
static const BKORChunkHandler | BKOR
static const ORDRChunkHandler | ORDR
static const ORDLChunkHandler | ORDL
static const ChunkHandlerRef | order_chunk_handlers []

## Detailed Description

Code handling saving and loading of orders.

Definition in file order_sl.cpp.

## Function Documentation

## ◆ AllocateOldOrder()

OldOrderSaveLoadItem & AllocateOldOrder | ( | size_t | pool_index | ) |

Allocate an old order with the given pool index.

Parameters

  pool_index | Pool index (zero-based) to allocate.

Returns
  Reference to allocated old order.

Definition at line 137 of file order_sl.cpp.

References _old_order_saveload_pool.

Referenced by ORDRChunkHandler::Load().

## ◆ ClearOldOrders()

void ClearOldOrders | ( |  | ) |

Clear all old orders.

Definition at line 114 of file order_sl.cpp.

References _old_order_saveload_pool.

Referenced by AfterLoadGame(), and ResetSaveloadData().

## ◆ GetOldOrder()

OldOrderSaveLoadItem * GetOldOrder | ( | size_t | ref_index | ) |

Get a pointer to an old order with the given reference index.

Parameters

  ref_index | Reference index (one-based) to get.

Returns
  Pointer to old order, or nullptr if not present.

Definition at line 125 of file order_sl.cpp.

References _old_order_saveload_pool.

Referenced by ORDLChunkHandler::FixPointers(), BKORChunkHandler::FixPointers(), and ORDRChunkHandler::Load().

## ◆ GetOrderBackupDescription()

SaveLoadTable GetOrderBackupDescription | ( |  | ) |

Definition at line 296 of file order_sl.cpp.

## ◆ GetOrderDescription()

SaveLoadTable GetOrderDescription | ( |  | ) |

Definition at line 144 of file order_sl.cpp.

## ◆ GetOrderListDescription()

SaveLoadTable GetOrderListDescription | ( |  | ) |

Definition at line 240 of file order_sl.cpp.

## ◆ UnpackOldOrder()

Order UnpackOldOrder | ( | uint16_t | packed | ) |

Unpacks a order from savegames made with TTD(Patch)

Parameters

  packed | packed order

Returns
  unpacked order

Definition at line 95 of file order_sl.cpp.

References Order::IsType(), Order::MakeDummy(), and UnpackVersion4Order().

## ◆ UnpackVersion4Order()

static Order UnpackVersion4Order | ( | uint16_t | packed | ) |
| static

Unpacks a order from savegames with version 4 and lower.

Parameters

  packed | packed order

Returns
  unpacked order

Definition at line 85 of file order_sl.cpp.

References GB().

Referenced by ORDRChunkHandler::Load(), and UnpackOldOrder().

## Variable Documentation

## ◆ _old_order_saveload_pool

std::vector<OldOrderSaveLoadItem> _old_order_saveload_pool
| static

Temporary storage for conversion from old order pool.

Definition at line 109 of file order_sl.cpp.

Referenced by AllocateOldOrder(), ClearOldOrders(), GetOldOrder(), and ORDRChunkHandler::Load().

## ◆ BKOR

const BKORChunkHandler BKOR
| static

Definition at line 372 of file order_sl.cpp.

## ◆ order_chunk_handlers

const ChunkHandlerRef order_chunk_handlers[]
| static

Initial value:
= {
BKOR,
ORDR,
ORDL,
}

Definition at line 375 of file order_sl.cpp.

## ◆ ORDL

const ORDLChunkHandler ORDL
| static

Definition at line 374 of file order_sl.cpp.

## ◆ ORDR

const ORDRChunkHandler ORDR
| static

Definition at line 373 of file order_sl.cpp.