Re-order various structs to reduce holes/padding

pull/642/head
Jonathan G Rennison 3 months ago
parent b64a51876a
commit b01fd1607a

@ -65,25 +65,25 @@ struct StationRect : public Rect {
/** Base class for all station-ish types */
struct BaseStation : StationPool::PoolItem<&_station_pool> {
Owner owner; ///< The owner of this station
StationFacility facilities; ///< The facilities that this station has
TileIndex xy; ///< Base tile of the station
TrackedViewportSign sign; ///< NOSAVE: Dimensions of sign
byte delete_ctr; ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted.
mutable std::string cached_name; ///< NOSAVE: Cache of the resolved name of the station, if not using a custom name
TinyString name; ///< Custom name
StringID string_id; ///< Default name (town area) of station
mutable std::string cached_name; ///< NOSAVE: Cache of the resolved name of the station, if not using a custom name
Date build_date; ///< Date of construction
Town *town; ///< The town this station is associated with
Owner owner; ///< The owner of this station
StationFacility facilities; ///< The facilities that this station has
std::vector<StationSpecList> speclist; ///< List of rail station specs of this station.
std::vector<RoadStopSpecList> roadstop_speclist; ///< List of road stop specs of this station
Date build_date; ///< Date of construction
uint16_t random_bits; ///< Random bits assigned to this station
byte waiting_triggers; ///< Waiting triggers (NewGRF) for this station
byte delete_ctr; ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted.
uint8_t cached_anim_triggers; ///< NOSAVE: Combined animation trigger bitmask, used to determine if trigger processing should happen.
uint8_t cached_roadstop_anim_triggers; ///< NOSAVE: Combined animation trigger bitmask for road stops, used to determine if trigger processing should happen.
CargoTypes cached_cargo_triggers; ///< NOSAVE: Combined cargo trigger bitmask

@ -25,7 +25,7 @@ struct Backup {
* @param file Filename for debug output. Use FILE_LINE macro.
* @param line Linenumber for debug output. Use FILE_LINE macro.
*/
Backup(T &original, const char * const file, const int line) : original(original), valid(true), original_value(original), file(file), line(line) {}
Backup(T &original, const char * const file, const int line) : original(original), file(file), line(line), valid(true), original_value(original) {}
/**
* Backup variable and switch to new value.
@ -35,7 +35,7 @@ struct Backup {
* @param line Linenumber for debug output. Use FILE_LINE macro.
*/
template <typename U>
Backup(T &original, const U &new_value, const char * const file, const int line) : original(original), valid(true), original_value(original), file(file), line(line)
Backup(T &original, const U &new_value, const char * const file, const int line) : original(original), file(file), line(line), valid(true), original_value(original)
{
/* Note: We use a separate typename U, so type conversions are handled by assignment operator. */
original = new_value;
@ -137,11 +137,10 @@ struct Backup {
private:
T &original;
bool valid;
T original_value;
const char * const file;
const int line;
bool valid;
T original_value;
};
struct AutoRestoreBackupNoNewValueTag {};

@ -73,9 +73,9 @@ struct RemoveVia {
struct Departure {
DateTicksScaled scheduled_date; ///< The date this departure is scheduled to finish on (i.e. when the vehicle leaves the station)
Ticks lateness; ///< How delayed the departure is expected to be
CallAt terminus; ///< The station at which the vehicle will terminate following this departure
StationID via; ///< The station the departure should list as going via
StationID via2; ///< Secondary station the departure should list as going via
CallAt terminus; ///< The station at which the vehicle will terminate following this departure
std::vector<CallAt> calling_at; ///< The stations both called at and unloaded at by the vehicle after this departure before it terminates
std::vector<RemoveVia> remove_vias; ///< Vias to remove when using smart terminus.
DepartureStatus status; ///< Whether the vehicle has arrived yet for this departure
@ -83,7 +83,7 @@ struct Departure {
const Vehicle *vehicle; ///< The vehicle performing this departure
const Order *order; ///< The order corresponding to this departure
Ticks scheduled_waiting_time; ///< Scheduled waiting time if scheduled dispatch is used
Departure() : terminus(INVALID_STATION), via(INVALID_STATION), via2(INVALID_STATION), vehicle(nullptr), order(nullptr) { }
Departure() : via(INVALID_STATION), via2(INVALID_STATION), terminus(INVALID_STATION), vehicle(nullptr), order(nullptr) { }
inline bool operator==(const Departure& d) const {
if (this->calling_at.size() != d.calling_at.size()) return false;

@ -61,6 +61,9 @@ DECLARE_ENUM_AS_BIT_SET(IndustryControlFlags);
* Defines the internal data of a functional industry.
*/
struct Industry : IndustryPool::PoolItem<&_industry_pool> {
IndustryType type; ///< Type of industry.
Owner owner; ///< Owner of the industry. Which SHOULD always be (imho) OWNER_NONE
Date construction_date; ///< Date of the construction of the industry
TileArea location; ///< Location of the industry
Town *town; ///< Nearest town
Station *neutral_station; ///< Associated neutral station
@ -74,27 +77,25 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> {
std::array<byte, INDUSTRY_NUM_OUTPUTS> last_month_pct_transported{}; ///< percentage transported per cargo in the last full month
std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> last_month_production{}; ///< total units produced per cargo in the last full month
std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> last_month_transported{}; ///< total units transported per cargo in the last full month
StationList stations_near; ///< NOSAVE: List of nearby stations.
mutable std::string cached_name; ///< NOSAVE: Cache of the resolved name of the industry
uint16_t counter; ///< used for animation and/or production (if available cargo)
byte prod_level; ///< general production level
IndustryType type; ///< type of industry.
Owner owner; ///< owner of the industry. Which SHOULD always be (imho) OWNER_NONE
byte random_colour; ///< randomized colour of the industry, for display purpose
Year last_prod_year; ///< last year of production
byte was_cargo_delivered; ///< flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry
IndustryControlFlags ctlflags; ///< flags overriding standard behaviours
PartOfSubsidy part_of_subsidy; ///< NOSAVE: is this industry a source/destination of a subsidy?
StationList stations_near; ///< NOSAVE: List of nearby stations.
mutable std::string cached_name; ///< NOSAVE: Cache of the resolved name of the industry
Owner founder; ///< Founder of the industry
Date construction_date; ///< Date of the construction of the industry
uint8_t construction_type; ///< Way the industry was constructed (@see IndustryConstructionType)
Date last_cargo_accepted_at[INDUSTRY_NUM_INPUTS]; ///< Last day each cargo type was accepted by this industry
byte selected_layout; ///< Which tile layout was used when creating the industry
Owner exclusive_supplier; ///< Which company has exclusive rights to deliver cargo (INVALID_OWNER = anyone)
Owner exclusive_consumer; ///< Which company has exclusive rights to take cargo (INVALID_OWNER = anyone)
Date last_cargo_accepted_at[INDUSTRY_NUM_INPUTS]; ///< Last day each cargo type was accepted by this industry
std::string text; ///< General text with additional information.
uint16_t random; ///< Random value used for randomisation of all kinds of things

@ -76,7 +76,7 @@ public:
* @param scale Desired thickness of lines and size of station dots.
*/
LinkGraphOverlay(Window *w, WidgetID wid, CargoTypes cargo_mask, CompanyMask company_mask, uint scale) :
window(w), widget_id(wid), cargo_mask(cargo_mask), company_mask(company_mask), scale(scale), dirty(true)
window(w), widget_id(wid), cargo_mask(cargo_mask), scale(scale), company_mask(company_mask), dirty(true)
{}
bool RebuildCacheCheckChanged();
@ -105,11 +105,11 @@ protected:
Window *window; ///< Window to be drawn into.
const WidgetID widget_id; ///< ID of Widget in Window to be drawn to.
CargoTypes cargo_mask; ///< Bitmask of cargos to be displayed.
CompanyMask company_mask; ///< Bitmask of companies to be displayed.
LinkList cached_links; ///< Cache for links to reduce recalculation.
StationSupplyList cached_stations; ///< Cache for stations to be drawn.
Rect cached_region; ///< Region covered by cached_links and cached_stations.
uint scale; ///< Width of link lines.
CompanyMask company_mask; ///< Bitmask of companies to be displayed.
bool dirty; ///< Set if overlay should be rebuilt.
uint64_t last_update_number = 0; ///< Last window update number
uint64_t rebuild_counter = 0; ///< Rebuild counter

@ -30,7 +30,7 @@ enum TileContext : uint8_t {
/**
* Flags to enable register usage in sprite layouts.
*/
enum TileLayoutFlags {
enum TileLayoutFlags : uint16_t {
TLF_NOTHING = 0x00,
TLF_DODRAW = 0x01, ///< Only draw sprite if value of register TileLayoutRegisters::dodraw is non-zero.
@ -50,7 +50,7 @@ enum TileLayoutFlags {
TLF_KNOWN_FLAGS = 0xFF, ///< Known flags. Any unknown set flag will disable the GRF.
/** Flags which are still required after loading the GRF. */
TLF_DRAWING_FLAGS = ~TLF_CUSTOM_PALETTE,
TLF_DRAWING_FLAGS = (uint16_t)~TLF_CUSTOM_PALETTE,
/** Flags which do not work for the (first) ground sprite. */
TLF_NON_GROUND_FLAGS = TLF_BB_XY_OFFSET | TLF_BB_Z_OFFSET | TLF_CHILD_X_OFFSET | TLF_CHILD_Y_OFFSET,
@ -90,11 +90,11 @@ inline uint GetConstructionStageOffset(uint construction_stage, uint num_sprites
*/
struct TileLayoutRegisters {
TileLayoutFlags flags; ///< Flags defining which members are valid and to be used.
uint16_t max_sprite_offset; ///< Maximum offset to add to the sprite. (limited by size of the spriteset)
uint16_t max_palette_offset; ///< Maximum offset to add to the palette. (limited by size of the spriteset)
uint8_t dodraw; ///< Register deciding whether the sprite shall be drawn at all. Non-zero means drawing.
uint8_t sprite; ///< Register specifying a signed offset for the sprite.
uint8_t palette; ///< Register specifying a signed offset for the palette.
uint16_t max_sprite_offset; ///< Maximum offset to add to the sprite. (limited by size of the spriteset)
uint16_t max_palette_offset; ///< Maximum offset to add to the palette. (limited by size of the spriteset)
union {
uint8_t parent[3]; ///< Registers for signed offsets for the bounding box position of parent sprites.
uint8_t child[2]; ///< Registers for signed offsets for the position of child sprites.

@ -113,10 +113,11 @@ private:
friend void Load_VEOX(); ///< Saving and loading of orders.
friend void Save_VEOX(); ///< Saving and loading of orders.
std::unique_ptr<OrderExtraInfo> extra; ///< Extra order info
uint16_t flags; ///< Load/unload types, depot order/action types.
DestinationID dest; ///< The destination of the order.
std::unique_ptr<OrderExtraInfo> extra; ///< Extra order info
uint8_t type; ///< The type of order + non-stop flags
CargoID refit_cargo; ///< Refit CargoID
@ -720,9 +721,8 @@ private:
friend SaveLoadTable GetDispatchScheduleDescription(); ///< Saving and loading of dispatch schedules
std::vector<uint32_t> scheduled_dispatch; ///< Scheduled dispatch time
uint32_t scheduled_dispatch_duration = 0; ///< Scheduled dispatch duration
DateTicksScaled scheduled_dispatch_start_tick = -1; ///< Scheduled dispatch start tick
/// this counts to (DAY_TICK * _settings_game.economy.day_length_factor)
uint32_t scheduled_dispatch_duration = 0; ///< Scheduled dispatch duration
int32_t scheduled_dispatch_last_dispatch = INVALID_SCHEDULED_DISPATCH_OFFSET; ///< Last vehicle dispatched offset
int32_t scheduled_dispatch_max_delay = 0; ///< Maximum allowed delay
uint8_t scheduled_dispatch_flags = 0; ///< Flags
@ -858,10 +858,10 @@ private:
void ReindexOrderList();
Order *GetOrderAtFromList(int index) const;
Order *first; ///< First order of the order list.
std::vector<Order *> order_index; ///< NOSAVE: Vector index of order list.
VehicleOrderID num_manual_orders; ///< NOSAVE: How many manually added orders are there in the list.
uint num_vehicles; ///< NOSAVE: Number of vehicles that share this order list.
Order *first; ///< First order of the order list.
std::vector<Order *> order_index; ///< NOSAVE: Vector index of order list.
Vehicle *first_shared; ///< NOSAVE: pointer to the first vehicle in the shared order chain.
Ticks timetable_duration; ///< NOSAVE: Total timetabled duration of the order list.
@ -872,7 +872,7 @@ private:
public:
/** Default constructor producing an invalid order list. */
OrderList(VehicleOrderID num_orders = INVALID_VEH_ORDER_ID)
: first(nullptr), num_manual_orders(0), num_vehicles(0), first_shared(nullptr),
: num_manual_orders(0), num_vehicles(0), first(nullptr), first_shared(nullptr),
timetable_duration(0), total_duration(0) { }
/**

@ -38,10 +38,10 @@ struct CFollowTrackT
};
const VehicleType *m_veh; ///< moving vehicle
Owner m_veh_owner; ///< owner of the vehicle
TileIndex m_old_tile; ///< the origin (vehicle moved from) before move
Trackdir m_old_td; ///< the trackdir (the vehicle was on) before move
TileIndex m_new_tile; ///< the new tile (the vehicle has entered)
Owner m_veh_owner; ///< owner of the vehicle
Trackdir m_old_td; ///< the trackdir (the vehicle was on) before move
TrackdirBits m_new_td_bits; ///< the new set of available trackdirs
DiagDirection m_exitdir; ///< exit direction (leaving the old tile)
bool m_is_tunnel; ///< last turn passed tunnel

@ -125,8 +125,6 @@ struct CYapfRailNodeT
CYapfRailSegment *m_segment;
uint16_t m_num_signals_passed;
uint16_t m_num_signals_res_through_passed;
TileIndex m_last_non_reserve_through_signal_tile;
Trackdir m_last_non_reserve_through_signal_td;
union {
uint32_t m_inherited_flags;
struct {
@ -139,6 +137,8 @@ struct CYapfRailNodeT
} flags_u;
SignalType m_last_red_signal_type;
SignalType m_last_signal_type;
Trackdir m_last_non_reserve_through_signal_td;
TileIndex m_last_non_reserve_through_signal_tile;
inline void Set(CYapfRailNodeT *parent, TileIndex tile, Trackdir td, bool is_choice)
{

@ -88,6 +88,7 @@ enum TrainReservationLookAheadFlags {
struct TrainReservationLookAhead {
TileIndex reservation_end_tile; ///< Tile the reservation ends.
Trackdir reservation_end_trackdir; ///< The reserved trackdir on the end tile.
uint8_t zpos_refresh_remaining = 0; ///< Remaining position updates before next refresh of cached_zpos
int32_t current_position; ///< Current position of the train on the reservation
int32_t reservation_end_position; ///< Position of the end of the reservation
int32_t lookahead_end_position; ///< Position of the end of the reservation within the lookahead distance
@ -99,7 +100,6 @@ struct TrainReservationLookAhead {
ring_buffer<TrainReservationLookAheadItem> items;
ring_buffer<TrainReservationLookAheadCurve> curves;
int32_t cached_zpos = 0; ///< Cached z position as used in TrainDecelerationStats
uint8_t zpos_refresh_remaining = 0; ///< Remaining position updates before next refresh of cached_zpos
int32_t RealEndPosition() const
{

@ -144,15 +144,15 @@ struct PlanLine {
struct Plan : PlanPool::PoolItem<&_plan_pool> {
Owner owner;
Colours colour;
Date creation_date;
PlanLineVector lines;
PlanLine *temp_line;
std::string name;
TileIndex last_tile;
bool visible;
bool visible_by_all;
bool show_lines;
Date creation_date;
std::string name;
Colours colour;
Plan(Owner owner = INVALID_OWNER)
{

@ -66,14 +66,14 @@ struct RoadStop : RoadStopPool::PoolItem<&_roadstop_pool> {
void Rebuild(const RoadStop *rs, int side = -1);
};
TileIndex xy; ///< Position on the map
byte status; ///< Current status of the Stop, @see RoadStopSatusFlag. Access using *Bay and *Busy functions.
TileIndex xy; ///< Position on the map
struct RoadStop *next; ///< Next stop of the given type at this station
/** Initializes a RoadStop */
inline RoadStop(TileIndex tile = INVALID_TILE) :
xy(tile),
status((1 << RSSFB_BAY_COUNT) - 1)
status((1 << RSSFB_BAY_COUNT) - 1),
xy(tile)
{ }
~RoadStop();

@ -140,22 +140,20 @@ enum RoadVehicleFlags {
* Buses, trucks and trams belong to this class.
*/
struct RoadVehicle FINAL : public GroundVehicle<RoadVehicle, VEH_ROAD> {
std::unique_ptr<RoadVehPathCache> cached_path; ///< Cached path.
byte state; ///< @see RoadVehicleStates
byte frame;
uint16_t blocked_ctr;
byte overtaking; ///< Set to #RVSB_DRIVE_SIDE when overtaking, otherwise 0.
byte overtaking_ctr; ///< The length of the current overtake attempt.
std::unique_ptr<RoadVehPathCache> cached_path; ///< Cached path.
RoadTypes compatible_roadtypes; ///< Roadtypes this consist is powered on.
uint16_t crashed_ctr; ///< Animation counter when the vehicle has crashed. @see RoadVehIsCrashed
byte reverse_ctr;
RoadType roadtype; ///< Roadtype of this vehicle.
RoadTypes compatible_roadtypes; ///< Roadtypes this consist is powered on.
byte critical_breakdown_count; ///< Counter for the number of critical breakdowns since last service
uint8_t rvflags; ///< Road vehicle flags
RoadType roadtype; ///< Roadtype of this vehicle.
/** We don't want GCC to zero our struct! It already is zeroed and has an index! */
RoadVehicle() : GroundVehicleBase() {}
/** We want to 'destruct' the right class. */

@ -115,14 +115,14 @@ struct SettingDescEnumEntry {
/** Properties of config file settings. */
struct SettingDesc {
SettingDesc(const SaveLoad &save, const char *name, SettingFlag flags, OnGuiCtrl *guiproc, bool startup, const char *patx_name) :
name(name), flags(flags), guiproc(guiproc), startup(startup), save(save), patx_name(patx_name) {}
name(name), flags(flags), startup(startup), save(save), guiproc(guiproc), patx_name(patx_name) {}
virtual ~SettingDesc() = default;
const char *name; ///< Name of the setting. Used in configuration file and for console
SettingFlag flags; ///< Handles how a setting would show up in the GUI (text/currency, etc.)
OnGuiCtrl *guiproc; ///< Callback procedure for GUI operations
bool startup; ///< Setting has to be loaded directly at startup?
SaveLoad save; ///< Internal structure (going to savegame, parts to config)
OnGuiCtrl *guiproc; ///< Callback procedure for GUI operations
const char *patx_name; ///< Name to save/load setting from in PATX chunk, if nullptr save/load from PATS chunk as normal

@ -483,6 +483,7 @@ DECLARE_ENUM_AS_BIT_SET(TraceRestrictProgramActionsUsedFlags)
* Enumeration for TraceRestrictProgramInput::permitted_slot_operations
*/
enum TraceRestrictProgramInputSlotPermissions : uint8_t {
TRPISP_NONE = 0, ///< No permissions
TRPISP_ACQUIRE = 1 << 0, ///< Slot acquire and release (on reserve) are permitted
TRPISP_RELEASE_BACK = 1 << 1, ///< Slot release (back) is permitted
TRPISP_RELEASE_FRONT = 1 << 2, ///< Slot release (front) is permitted
@ -497,6 +498,7 @@ DECLARE_ENUM_AS_BIT_SET(TraceRestrictProgramInputSlotPermissions)
* Enumeration for TraceRestrictProgramInput::input_flags
*/
enum TraceRestrictProgramInputFlags : uint8_t {
TRPIF_NONE = 0, ///< No flags set
TRPIF_PASSED_STOP = 1 << 0, ///< Train has passed stop
};
DECLARE_ENUM_AS_BIT_SET(TraceRestrictProgramInputFlags)
@ -522,16 +524,15 @@ struct TraceRestrictProgramInput {
TileIndex tile; ///< Tile of restrict signal, for direction testing
Trackdir trackdir; ///< Track direction on tile of restrict signal, for direction testing
TraceRestrictProgramInputFlags input_flags; ///< Input flags
TraceRestrictProgramInputSlotPermissions permitted_slot_operations; ///< Permitted slot operations
PreviousSignalProc *previous_signal_callback; ///< Callback to retrieve tile and direction of previous signal, may be nullptr
const void *previous_signal_ptr; ///< Opaque pointer suitable to be passed to previous_signal_callback
TraceRestrictProgramInputSlotPermissions permitted_slot_operations; ///< Permitted slot operations
TraceRestrictProgramInputFlags input_flags; ///< Input flags
TraceRestrictSlotTemporaryState *slot_temporary_state = nullptr; ///< Slot temporary state, must be set when permitted_slot_operations includes TRPISP_ACQUIRE_TEMP_STATE
TraceRestrictProgramInput(TileIndex tile_, Trackdir trackdir_, PreviousSignalProc *previous_signal_callback_, const void *previous_signal_ptr_)
: tile(tile_), trackdir(trackdir_), previous_signal_callback(previous_signal_callback_), previous_signal_ptr(previous_signal_ptr_),
permitted_slot_operations(static_cast<TraceRestrictProgramInputSlotPermissions>(0)),
input_flags(static_cast<TraceRestrictProgramInputFlags>(0)) { }
: tile(tile_), trackdir(trackdir_), input_flags(TRPIF_NONE), permitted_slot_operations(TRPISP_NONE),
previous_signal_callback(previous_signal_callback_), previous_signal_ptr(previous_signal_ptr_) { }
};
/**
@ -551,8 +552,8 @@ struct TraceRestrictProgramResult {
* This is refcounted, see info at top of tracerestrict.cpp
*/
struct TraceRestrictProgram : TraceRestrictProgramPool::PoolItem<&_tracerestrictprogram_pool> {
std::vector<TraceRestrictItem> items;
uint32_t refcount;
std::vector<TraceRestrictItem> items;
TraceRestrictProgramActionsUsedFlags actions_used_flags;
private:
@ -1153,12 +1154,11 @@ static const uint MAX_LENGTH_TRACE_RESTRICT_SLOT_NAME_CHARS = 128; ///< The maxi
struct TraceRestrictSlot : TraceRestrictSlotPool::PoolItem<&_tracerestrictslot_pool> {
friend TraceRestrictSlotTemporaryState;
std::vector<VehicleID> occupants;
uint32_t max_occupancy = 1;
std::string name;
Owner owner;
VehicleType vehicle_type;
uint32_t max_occupancy = 1;
std::string name;
std::vector<VehicleID> occupants;
std::vector<SignalReference> progsig_dependants;
static void RebuildVehicleIndex();
@ -1202,10 +1202,9 @@ private:
* Counter type
*/
struct TraceRestrictCounter : TraceRestrictCounterPool::PoolItem<&_tracerestrictcounter_pool> {
Owner owner;
int32_t value = 0;
std::string name;
Owner owner;
std::vector<SignalReference> progsig_dependants;
TraceRestrictCounter(CompanyID owner = INVALID_COMPANY)

@ -131,6 +131,9 @@ struct TrainCache {
* 'Train' is either a loco or a wagon.
*/
struct Train FINAL : public GroundVehicle<Train, VEH_TRAIN> {
TrackBits track;
RailType railtype;
uint32_t flags;
TrainCache tcache;
/* Link between the two ends of a multiheaded engine */
@ -138,15 +141,10 @@ struct Train FINAL : public GroundVehicle<Train, VEH_TRAIN> {
std::unique_ptr<TrainReservationLookAhead> lookahead;
uint32_t flags;
uint16_t crash_anim_pos; ///< Crash animation counter, also used for realistic braking train brake overheating
RailTypes compatible_railtypes;
TrackBits track;
TrainForceProceeding force_proceed;
RailType railtype;
byte critical_breakdown_count; ///< Counter for the number of critical breakdowns since last service
RailTypes compatible_railtypes;
/** Ticks waiting in front of a signal, ticks being stuck or a counter for forced proceeding through signals. */
uint16_t wait_counter;
@ -155,6 +153,7 @@ struct Train FINAL : public GroundVehicle<Train, VEH_TRAIN> {
uint16_t tunnel_bridge_signal_num;
uint16_t speed_restriction;
uint16_t signal_speed_restriction;
uint16_t crash_anim_pos; ///< Crash animation counter, also used for realistic braking train brake overheating
/** We don't want GCC to zero our struct! It already is zeroed and has an index! */
Train() : GroundVehicleBase() {}

@ -268,6 +268,12 @@ struct ClosestDepot {
/** %Vehicle data structure. */
struct Vehicle : VehiclePool::PoolItem<&_vehicle_pool>, BaseVehicle, BaseConsist {
/* These are here for structure packing purposes */
CargoID cargo_type; ///< type of cargo this vehicle is carrying
EngineID engine_type; ///< The type of engine used for this vehicle.
TileIndex tile; ///< Current tile index
private:
Vehicle *next; ///< pointer to the next vehicle in the chain
Vehicle *previous; ///< NOSAVE: pointer to the previous vehicle in the chain
@ -287,7 +293,12 @@ public:
static void PreCleanPool();
TileIndex tile; ///< Current tile index
Money profit_this_year; ///< Profit this year << 8, low 8 bits are fract
Money profit_last_year; ///< Profit last year << 8, low 8 bits are fract
Money profit_lifetime; ///< Profit lifetime << 8, low 8 bits are fract
Money value; ///< Value of the vehicle
CargoPayment *cargo_payment; ///< The cargo payment we're currently in
/**
* Heading for this tile.
@ -296,13 +307,6 @@ public:
*/
TileIndex dest_tile;
Money profit_this_year; ///< Profit this year << 8, low 8 bits are fract
Money profit_last_year; ///< Profit last year << 8, low 8 bits are fract
Money profit_lifetime; ///< Profit lifetime << 8, low 8 bits are fract
Money value; ///< Value of the vehicle
CargoPayment *cargo_payment; ///< The cargo payment we're currently in
/* Used for timetabling. */
uint32_t current_loading_time; ///< How long loading took. Less than current_order_time if vehicle is early.
@ -318,6 +322,8 @@ public:
byte breakdown_severity; ///< severity of the breakdown. Note that lower means more severe
byte breakdown_type; ///< Type of breakdown
byte breakdown_chance_factor; ///< Improved breakdowns: current multiplier for breakdown_chance * 128, used for head vehicle only
Owner owner; ///< Which company owns the vehicle?
SpriteID colourmap; ///< NOSAVE: cached colour mapping
/* Related to age and service time */
@ -338,13 +344,13 @@ public:
int32_t z_pos; ///< z coordinate.
Direction direction; ///< facing
Owner owner; ///< Which company owns the vehicle?
/**
* currently displayed sprite index
* 0xfd == custom sprite, 0xfe == custom second head sprite
* 0xff == reserved for another custom sprite
*/
byte spritenum;
UnitID unitnumber; ///< unit number, for display purposes only
VehicleSpriteSeq sprite_seq; ///< Vehicle appearance.
Rect16 sprite_seq_bounds;
byte x_extent; ///< x-extent of vehicle bounding box
@ -354,39 +360,41 @@ public:
int8_t y_bb_offs; ///< y offset of vehicle bounding box
int8_t x_offs; ///< x offset for vehicle sprite
int8_t y_offs; ///< y offset for vehicle sprite
EngineID engine_type; ///< The type of engine used for this vehicle.
byte progress; ///< The percentage (if divided by 256) this vehicle already crossed the tile unit.
TextEffectID fill_percent_te_id; ///< a text-effect id to a loading indicator object
UnitID unitnumber; ///< unit number, for display purposes only
uint16_t load_unload_ticks; ///< Ticks to wait before starting next cycle.
uint16_t cur_speed; ///< current speed
byte subspeed; ///< fractional speed
byte acceleration; ///< used by train & aircraft
uint32_t motion_counter; ///< counter to occasionally play a vehicle sound. (Also used as virtual train client ID).
byte progress; ///< The percentage (if divided by 256) this vehicle already crossed the tile unit.
uint16_t random_bits; ///< Bits used for randomized variational spritegroups.
byte waiting_triggers; ///< Triggers to be yet matched before rerandomizing the random bits.
byte cargo_subtype; ///< Used for livery refits (NewGRF variations)
StationID last_station_visited; ///< The last station we stopped at.
StationID last_loading_station; ///< Last station the vehicle has stopped at and could possibly leave from with any cargo loaded. (See VF_LAST_LOAD_ST_SEP).
uint64_t last_loading_tick; ///< Last time (relative to _scaled_tick_counter) the vehicle has stopped at a station and could possibly leave with any cargo loaded. (See VF_LAST_LOAD_ST_SEP).
CargoID cargo_type; ///< type of cargo this vehicle is carrying
byte cargo_subtype; ///< Used for livery refits (NewGRF variations)
VehicleCargoList cargo; ///< The cargo this vehicle is carrying
uint16_t cargo_cap; ///< total capacity
uint16_t refit_cap; ///< Capacity left over from before last refit.
VehicleCargoList cargo; ///< The cargo this vehicle is carrying
uint16_t cargo_age_counter; ///< Ticks till cargo is aged next.
int8_t trip_occupancy; ///< NOSAVE: Occupancy of vehicle of the current trip (updated after leaving a station).
byte day_counter; ///< Increased by one for each day
byte tick_counter; ///< Increased by one for each tick
uint8_t order_occupancy_average; ///< NOSAVE: order occupancy average. 0 = invalid, 1 = n/a, 16-116 = 0-100%
uint16_t running_ticks; ///< Number of ticks this vehicle was not stopped this day
byte vehstatus; ///< Status
byte subtype; ///< subtype (Filled with values from #AircraftSubType/#DisasterSubType/#EffectVehicleType/#GroundVehicleSubtypeFlags)
GroupID group_id; ///< Index of group Pool array
uint8_t order_occupancy_average; ///< NOSAVE: order occupancy average. 0 = invalid, 1 = n/a, 16-116 = 0-100%
Order current_order; ///< The current order (+ status, like: loading)
union {
@ -394,9 +402,6 @@ public:
Order *old_orders; ///< Only used during conversion of old save games
};
uint16_t load_unload_ticks; ///< Ticks to wait before starting next cycle.
GroupID group_id; ///< Index of group Pool array
byte subtype; ///< subtype (Filled with values from #AircraftSubType/#DisasterSubType/#EffectVehicleType/#GroundVehicleSubtypeFlags)
Direction cur_image_valid_dir; ///< NOSAVE: direction for which cur_image does not need to be regenerated on the next tick
NewGRFCache grf_cache; ///< Cache of often used calculated NewGRF values

Loading…
Cancel
Save