#include "stdafx.h"
#include "debug.h"
#include "command_func.h"
#include "company_func.h"
#include "news_func.h"
#include "vehicle_gui.h"
#include "cargotype.h"
#include "station_map.h"
#include "vehicle_base.h"
#include "strings_func.h"
#include "functions.h"
#include "window_func.h"
#include "newgrf_cargo.h"
#include "timetable.h"
#include "vehicle_func.h"
#include "oldpool_func.h"
#include "depot_base.h"
#include "settings_type.h"
#include "table/strings.h"
Go to the source code of this file.
Functions | |
assert_compile (sizeof(DestinationID) >=sizeof(DepotID)) | |
DEFINE_OLD_POOL_GENERIC (Order, Order) | |
DEFINE_OLD_POOL_GENERIC (OrderList, OrderList) | |
void | InvalidateVehicleOrder (const Vehicle *v, int data) |
Updates the widgets of a vehicle which contains the order-data. | |
static bool | OrderGoesToStation (const Vehicle *v, const Order *o) |
Checks whether the order goes to a station or not, i.e. | |
static void | DeleteOrderWarnings (const Vehicle *v) |
Delete all news items regarding defective orders about a vehicle This could kill still valid warnings (for example about void order when just another order gets added), but assume the company will notice the problems, when (s)he's changing the orders. | |
static TileIndex | GetOrderLocation (const Order &o) |
static uint | GetOrderDistance (const Order *prev, const Order *cur, const Vehicle *v, int conditional_depth=0) |
CommandCost | CmdInsertOrder (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Add an order to the orderlist of a vehicle. | |
static CommandCost | DecloneOrder (Vehicle *dst, DoCommandFlag flags) |
Declone an order-list. | |
CommandCost | CmdDeleteOrder (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Delete an order from the orderlist of a vehicle. | |
CommandCost | CmdSkipToOrder (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Goto order of order-list. | |
CommandCost | CmdMoveOrder (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Move an order inside the orderlist. | |
CommandCost | CmdModifyOrder (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Modify an order in the orderlist of a vehicle. | |
CommandCost | CmdCloneOrder (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Clone/share/copy an order-list of an other vehicle. | |
CommandCost | CmdOrderRefit (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Add/remove refit orders from an order. | |
void | BackupVehicleOrders (const Vehicle *v, BackuppedOrders *bak) |
Backup a vehicle order-list, so you can replace a vehicle without losing the order-list. | |
void | RestoreVehicleOrders (const Vehicle *v, const BackuppedOrders *bak) |
Restore vehicle orders that are backupped via BackupVehicleOrders. | |
CommandCost | CmdRestoreOrderIndex (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Restore the current order-index of a vehicle and sets service-interval. | |
static TileIndex | GetStationTileForVehicle (const Vehicle *v, const Station *st) |
void | CheckOrders (const Vehicle *v) |
Check the orders of a vehicle, to see if there are invalid orders and stuff. | |
void | RemoveOrderFromAllVehicles (OrderType type, DestinationID destination) |
Removes an order from all vehicles. | |
bool | VehicleHasDepotOrders (const Vehicle *v) |
Checks if a vehicle has a GOTO_DEPOT in his order list. | |
void | DeleteVehicleOrders (Vehicle *v, bool keep_orderlist) |
Delete all orders from a vehicle. | |
Date | GetServiceIntervalClamped (uint index) |
Get the service interval domain. | |
static bool | CheckForValidOrders (const Vehicle *v) |
Check if a vehicle has any valid orders. | |
static bool | OrderConditionCompare (OrderConditionComparator occ, int variable, int value) |
Compare the variable and value based on the given comparator. | |
VehicleOrderID | ProcessConditionalOrder (const Order *order, const Vehicle *v) |
Process a conditional order and determine the next order. | |
bool | UpdateOrderDest (Vehicle *v, const Order *order, int conditional_depth) |
Update the vehicle's destination tile from an order. | |
bool | ProcessOrders (Vehicle *v) |
Handle the orders of a vehicle and determine the next place to go to if needed. | |
void | InitializeOrders () |
Variables | |
TileIndex | _backup_orders_tile |
BackuppedOrders | _backup_orders_data |
Definition in file order_cmd.cpp.
void BackupVehicleOrders | ( | const Vehicle * | v, | |
BackuppedOrders * | bak | |||
) |
Backup a vehicle order-list, so you can replace a vehicle without losing the order-list.
Definition at line 1241 of file order_cmd.cpp.
static bool CheckForValidOrders | ( | const Vehicle * | v | ) | [static] |
Check if a vehicle has any valid orders.
Definition at line 1568 of file order_cmd.cpp.
Referenced by ProcessOrders().
void CheckOrders | ( | const Vehicle * | v | ) |
Check the orders of a vehicle, to see if there are invalid orders and stuff.
Definition at line 1398 of file order_cmd.cpp.
References _settings_client, AddNewsItem(), GetLastVehicleOrder(), ClientSettings::gui, INVALID_TILE, NS_ADVICE, and GUISettings::order_review_system.
CommandCost CmdCloneOrder | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Clone/share/copy an order-list of an other vehicle.
tile | unused | |
flags | operation to perform | |
p1 | various bitstuffed elements
| |
p2 | mode of cloning: CO_SHARE, CO_COPY, or CO_UNSHARE |
Definition at line 1072 of file order_cmd.cpp.
References PoolItem< T, Tid, Tpool >::CanAllocateItem(), CanVehicleUseStation(), CC_PASSENGERS, CMD_ERROR, DC_EXEC, DecloneOrder(), DeleteVehicleOrders(), OrderList::first, GB(), GetWindowClassForVehicleType(), InvalidateVehicleOrder(), InvalidateWindowClassesData(), IsValidVehicleID(), OrderGoesToStation(), OrderList::OrderList(), and return_cmd_error.
CommandCost CmdDeleteOrder | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Delete an order from the orderlist of a vehicle.
tile | unused | |
flags | operation to perform | |
p1 | the ID of the vehicle | |
p2 | the order to delete (max 255) |
Definition at line 669 of file order_cmd.cpp.
References CMD_ERROR, DC_EXEC, DecloneOrder(), DeleteOrderWarnings(), GetWindowClassForVehicleType(), INVALID_VEH_ORDER_ID, InvalidateVehicleOrder(), InvalidateWindowClassesData(), IsValidVehicleID(), max(), and ONSF_STOP_EVERYWHERE.
CommandCost CmdInsertOrder | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Add an order to the orderlist of a vehicle.
tile | unused | |
flags | operation to perform | |
p1 | various bitstuffed elements
| |
p2 | packed order to insert |
Definition at line 434 of file order_cmd.cpp.
References _settings_game, Station::Airport(), PoolItem< T, Tid, Tpool >::CanAllocateItem(), CanVehicleUseStation(), CMD_ERROR, DC_EXEC, DeleteOrderWarnings(), GB(), OrderList::GetNumOrders(), GetTileOwner(), GetWindowClassForVehicleType(), INVALID_VEH_ORDER_ID, InvalidateVehicleOrder(), InvalidateWindowClassesData(), IsRailDepotTile(), IsValidVehicleID(), MAX_VEH_ORDER_ID, AirportFTAClass::nof_depots, OCC_EQUALS, OCC_IS_FALSE, OCC_IS_TRUE, OCV_LOAD_PERCENTAGE, OCV_RELIABILITY, OCV_REQUIRES_SERVICE, OCV_UNCONDITIONALLY, ODATFB_HALT, ODATFB_NEAREST_DEPOT, ODTFB_PART_OF_ORDERS, ODTFB_SERVICE, OLF_FULL_LOAD_ANY, OLF_LOAD_IF_POSSIBLE, OLFB_FULL_LOAD, OLFB_NO_LOAD, ONSF_STOP_EVERYWHERE, OrderList::OrderList(), OUF_UNLOAD_IF_POSSIBLE, OUFB_NO_UNLOAD, OUFB_TRANSFER, OUFB_UNLOAD, Station::owner, OWNER_NONE, PathfinderSettings::pathfinder_for_ships, GameSettings::pf, return_cmd_error, and VPF_NPF.
CommandCost CmdModifyOrder | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Modify an order in the orderlist of a vehicle.
tile | unused | |
flags | operation to perform | |
p1 | various bitstuffed elements
| |
p2 | various bitstuffed elements
|
Definition at line 855 of file order_cmd.cpp.
References CMD_ERROR, DA_ALWAYS_GO, DA_SERVICE, DA_STOP, DC_EXEC, DeleteOrderWarnings(), GB(), InvalidateVehicleOrder(), IsValidVehicleID(), MOF_COND_COMPARATOR, MOF_COND_DESTINATION, MOF_COND_VALUE, MOF_COND_VARIABLE, MOF_DEPOT_ACTION, MOF_LOAD, MOF_NON_STOP, MOF_UNLOAD, OCC_EQUALS, OCC_IS_FALSE, OCC_IS_TRUE, OCV_LOAD_PERCENTAGE, OCV_RELIABILITY, OCV_REQUIRES_SERVICE, OCV_UNCONDITIONALLY, ODATFB_HALT, ODTFB_SERVICE, OLFB_NO_LOAD, OUFB_NO_UNLOAD, OUFB_TRANSFER, and OUFB_UNLOAD.
CommandCost CmdMoveOrder | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Move an order inside the orderlist.
tile | unused | |
p1 | the ID of the vehicle | |
p2 | order to move and target bit 0-15 : the order to move bit 16-31 : the target order |
Definition at line 777 of file order_cmd.cpp.
References CMD_ERROR, DC_EXEC, DeleteOrderWarnings(), GB(), GetWindowClassForVehicleType(), InvalidateVehicleOrder(), InvalidateWindowClassesData(), and IsValidVehicleID().
CommandCost CmdOrderRefit | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Add/remove refit orders from an order.
tile | Not used | |
flags | operation to perform | |
p1 | VehicleIndex of the vehicle having the order | |
p2 | bitmask
|
Definition at line 1200 of file order_cmd.cpp.
References CMD_ERROR, DC_EXEC, GB(), InvalidateVehicleOrder(), IsValidVehicleID(), and ODTFB_PART_OF_ORDERS.
CommandCost CmdRestoreOrderIndex | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Restore the current order-index of a vehicle and sets service-interval.
tile | unused | |
flags | operation to perform | |
p1 | the ID of the vehicle | |
p2 | various bistuffed elements
|
Definition at line 1356 of file order_cmd.cpp.
References CMD_ERROR, DC_EXEC, GB(), GetServiceIntervalClamped(), and IsValidVehicleID().
CommandCost CmdSkipToOrder | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Goto order of order-list.
tile | unused | |
flags | operation to perform | |
p1 | The ID of the vehicle which order is skipped | |
p2 | the selected order to which we want to skip |
Definition at line 737 of file order_cmd.cpp.
References CMD_ERROR, DC_EXEC, InvalidateVehicleOrder(), InvalidateWindowClasses(), and IsValidVehicleID().
static CommandCost DecloneOrder | ( | Vehicle * | dst, | |
DoCommandFlag | flags | |||
) | [static] |
Declone an order-list.
*dst | delete the orders of this vehicle | |
flags | execution flags |
Definition at line 653 of file order_cmd.cpp.
References DC_EXEC, DeleteVehicleOrders(), GetWindowClassForVehicleType(), InvalidateVehicleOrder(), and InvalidateWindowClassesData().
Referenced by CmdCloneOrder(), and CmdDeleteOrder().
void DeleteVehicleOrders | ( | Vehicle * | v, | |
bool | keep_orderlist | |||
) |
Delete all orders from a vehicle.
Definition at line 1541 of file order_cmd.cpp.
References DeleteOrderWarnings().
Referenced by CmdCloneOrder(), CmdMoveRailVehicle(), CmdSellRailWagon(), and DecloneOrder().
Date GetServiceIntervalClamped | ( | uint | index | ) |
Get the service interval domain.
Get the new proposed service interval for the vehicle is indeed, clamped within the given bounds.
index | proposed service interval |
Definition at line 1556 of file order_cmd.cpp.
References _settings_game, Clamp(), VehicleSettings::servint_ispercent, and GameSettings::vehicle.
Referenced by CmdChangeServiceInt(), and CmdRestoreOrderIndex().
void InvalidateVehicleOrder | ( | const Vehicle * | v, | |
int | data | |||
) |
Updates the widgets of a vehicle which contains the order-data.
Definition at line 167 of file order_cmd.cpp.
References InvalidateWindow(), and InvalidateWindowData().
Referenced by CmdCloneOrder(), CmdDeleteOrder(), CmdInsertOrder(), CmdModifyOrder(), CmdMoveOrder(), CmdOrderRefit(), CmdSkipToOrder(), DecloneOrder(), ProcessOrders(), and RemoveOrderFromAllVehicles().
static bool OrderGoesToStation | ( | const Vehicle * | v, | |
const Order * | o | |||
) | [inline, static] |
Checks whether the order goes to a station or not, i.e.
whether the destination is a station
v | the vehicle to check for | |
o | the order to check |
Definition at line 379 of file order_cmd.cpp.
References ODATFB_NEAREST_DEPOT.
Referenced by CmdCloneOrder().
VehicleOrderID ProcessConditionalOrder | ( | const Order * | order, | |
const Vehicle * | v | |||
) |
Process a conditional order and determine the next order.
order | the order the vehicle currently has | |
v | the vehicle to update |
Definition at line 1601 of file order_cmd.cpp.
References CalcPercentVehicleFilled(), DAYS_IN_LEAP_YEAR, INVALID_VEH_ORDER_ID, OCV_AGE, OCV_LOAD_PERCENTAGE, OCV_MAX_SPEED, OCV_RELIABILITY, OCV_REQUIRES_SERVICE, OCV_UNCONDITIONALLY, and OrderConditionCompare().
Referenced by VehicleOrderSaver::SwitchToNextOrder(), and UpdateOrderDest().
bool ProcessOrders | ( | Vehicle * | v | ) |
Handle the orders of a vehicle and determine the next place to go to if needed.
v | the vehicle to do this for. |
Reversing because of order change is allowed only just after leaving a station (and the difficulty setting to allowed, of course) this can be detected because only after OT_LEAVESTATION, current_order will be reset to nothing. (That also happens if no order, but in that case it won't hit the point in code where may_reverse is checked)
Definition at line 1708 of file order_cmd.cpp.
References CheckForValidOrders(), GetStationIndex(), GetWindowClassForVehicleType(), INVALID_TILE, InvalidateVehicleOrder(), InvalidateWindowClasses(), IsTileType(), MP_STATION, ODTFB_PART_OF_ORDERS, ONSF_NO_STOP_AT_DESTINATION_STATION, and UpdateOrderDest().
void RemoveOrderFromAllVehicles | ( | OrderType | type, | |
DestinationID | destination | |||
) |
Removes an order from all vehicles.
Triggers when, say, a station is removed.
type | The type of the order (OT_GOTO_[STATION|DEPOT|WAYPOINT]). | |
destination | The destination. Can be a StationID, DepotID or WaypointID. |
Definition at line 1475 of file order_cmd.cpp.
References INVALID_VEH_ORDER_ID, InvalidateVehicleOrder(), InvalidateWindow(), and ODATFB_NEAREST_DEPOT.
Referenced by Station::~Station().
void RestoreVehicleOrders | ( | const Vehicle * | v, | |
const BackuppedOrders * | bak | |||
) |
Restore vehicle orders that are backupped via BackupVehicleOrders.
Definition at line 1292 of file order_cmd.cpp.
References _settings_game, CMD_ADD_VEHICLE_GROUP, CMD_CHANGE_TIMETABLE, CMD_CLONE_ORDER, CMD_INSERT_ORDER, CMD_MODIFY_ORDER, CMD_NO_TEST_IF_IN_NETWORK, CMD_RENAME_VEHICLE, CMD_RESTORE_ORDER_INDEX, DoCommandP(), MOF_LOAD, GameSettings::order, and OrderSettings::timetabling.
Referenced by CcBuildAircraft().
bool UpdateOrderDest | ( | Vehicle * | v, | |
const Order * | order, | |||
int | conditional_depth | |||
) |
Update the vehicle's destination tile from an order.
order | the order the vehicle currently has | |
v | the vehicle to update |
Definition at line 1627 of file order_cmd.cpp.
References AircraftNextAirportPos_and_Order(), CMD_REVERSE_TRAIN_DIRECTION, DC_EXEC, DoCommand(), INVALID_VEH_ORDER_ID, ODATFB_NEAREST_DEPOT, ODTFB_SERVICE, ProcessConditionalOrder(), and UpdateOrderDest().
Referenced by ProcessOrders(), VehicleOrderSaver::SwitchToNextOrder(), and UpdateOrderDest().
bool VehicleHasDepotOrders | ( | const Vehicle * | v | ) |
Checks if a vehicle has a GOTO_DEPOT in his order list.
Definition at line 1524 of file order_cmd.cpp.
Referenced by CheckSendAircraftToHangarForReplacement().