23#include "table/strings.h"
30OrderBackup::~OrderBackup() =
default;
48 OrderBackupPool::PoolItem<&_order_backup_pool>(index), user(user), tile(v->tile), group(v->group_id)
57 this->
orders.assign(std::begin(v->Orders()), std::end(v->Orders()));
68 if (this->
clone !=
nullptr) {
100 if (ob->user ==
user)
delete ob;
116 if (v->
tile != ob->tile || ob->user !=
user)
continue;
163 if (ob->user !=
user)
continue;
186 if (from_gui && ob->user !=
user)
continue;
223 assert(v !=
nullptr);
225 if (ob->clone == v) {
229 if (ob->clone ==
nullptr)
delete ob;
245 for (
Order &order : ob->orders) {
248 if (ot == OT_GOTO_DEPOT && hangar && !
IsHangarTile(ob->tile))
continue;
249 if (ot == OT_IMPLICIT || (
IsHangarTile(ob->tile) && ot == OT_GOTO_DEPOT && !hangar)) ot = OT_GOTO_STATION;
250 if (ot == type && order.GetDestination() == destination) {
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Common return value for all commands.
Functions related to commands.
@ Execute
execute the given command
Command definitions related to engine groups.
static constexpr GroupID DEFAULT_GROUP
Ungrouped vehicles are in this group.
bool _networking
are we in networking mode?
bool _network_server
network-server is active
ClientID _network_own_client_id
Our client identifier.
Basic functions/variables used all over the place.
Network functions used by other parts of OpenTTD.
ClientID
'Unique' identifier to be given to clients
@ CLIENT_ID_SERVER
Servers always have this ID.
CommandCost CmdClearOrderBackup(DoCommandFlags flags, TileIndex tile, ClientID user_id)
Clear an OrderBackup.
Functions related to order backups.
Command definitions related to orders.
@ NearestDepot
Send the vehicle to the nearest depot.
Some methods of Pool are placed here in order to reduce compilation time and binary size.
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
A number of safeguards to prevent using unsafe methods.
Maps accessors for stations.
bool IsHangarTile(Tile t)
Is tile t an hangar tile?
Definition of base types and functions in a cross-platform compatible way.
std::string name
Name of vehicle.
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
VehicleOrderID cur_implicit_order_index
The index to the current implicit order.
void CopyConsistPropertiesFrom(const BaseConsist *src)
Copy properties of other BaseConsist.
Defines the traits of a command.
Data for backing up an order of a vehicle so it can be restored after a vehicle is rebuilt in the sam...
static void Reset(TileIndex tile=INVALID_TILE, bool from_gui=true)
Reset the OrderBackups from GUI/game logic.
static void Restore(Vehicle *v, uint32_t user)
Restore the data of this order to the given vehicle.
void DoRestore(Vehicle *v)
Restore the data of this order to the given vehicle.
static void Backup(const Vehicle *v, uint32_t user)
Create an order backup for the given vehicle.
static void ClearVehicle(const Vehicle *v)
Clear/update the (clone) vehicle from an order backup.
OrderBackup(OrderBackupID index)
Create an order backup for savegame loading.
const Vehicle * clone
Vehicle this vehicle was a clone of.
TileIndex tile
Tile of the depot where the order was changed.
uint32_t user
The user that requested the backup.
static void ClearGroup(GroupID group)
Clear the group of all backups having this group ID.
GroupID group
The group the vehicle was part of.
static void ResetOfUser(TileIndex tile, uint32_t user)
Reset an OrderBackup given a tile and user.
static void ResetUser(uint32_t user)
Reset an user's OrderBackup if needed.
std::vector< Order > orders
The actual orders if the vehicle was not a clone.
static void RemoveOrder(OrderType type, DestinationID destination, bool hangar)
Removes an order from all vehicles.
Templated helper to make a PoolID a single POD value.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static T * Create(Targs &&... args)
Creates a new T-object in the associated pool.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
const Tindex index
Index of this pool item.
Base class for all pools.
The information about a vehicle list.
bool IsOrderListShared() const
Check if we share our orders with another vehicle.
VehicleOrderID GetNumOrders() const
Get the number of orders this vehicle has.
OrderList * orders
Pointer to the order list for this vehicle.
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
Vehicle * FirstShared() const
Get the first vehicle of this vehicle chain.
TileIndex tile
Current tile index.
void UpdateRealOrderIndex()
Skip implicit orders until cur_real_order_index is a non-implicit order.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Base class for all vehicles.
bool IsUniqueVehicleName(const std::string &name)
Test if a name is unique among vehicle names.
Functions related to vehicles.
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
Window functions not directly related to making/drawing windows.
@ WC_STATION_LIST
Station list; Window numbers: