From 186a08261392f95a53606369d98018810d6f66ef Mon Sep 17 00:00:00 2001 From: PeterN Date: Sat, 2 Sep 2023 21:56:36 +0100 Subject: [PATCH] Codechange: Reorder some high-use structs to reduce their size. (#11201) This reduces GoodsEntry from 144 to 136 bytes (thereby reducing Station from 9704 bytes to 9192 bytes), and CargoPacket from 40 bytes to 32 bytes. (cherry picked from commit bd150df9148c346f7fa133ca3f286257c015ae32) --- src/cargopacket.cpp | 4 ++-- src/cargopacket.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp index c9ec6b4510..901f7c6127 100644 --- a/src/cargopacket.cpp +++ b/src/cargopacket.cpp @@ -121,9 +121,9 @@ CargoPacket::CargoPacket(StationID source, TileIndex source_xy, uint16 count, So count(count), days_in_transit(0), feeder_share(0), - source_id(source_id), source_xy(source_xy), loaded_at_xy(0), + source_id(source_id), source(source), source_type(source_type) { @@ -148,9 +148,9 @@ CargoPacket::CargoPacket(uint16 count, uint16 days_in_transit, StationID source, count(count), days_in_transit(days_in_transit), feeder_share(feeder_share), - source_id(source_id), source_xy(source_xy), loaded_at_xy(loaded_at_xy), + source_id(source_id), source(source), source_type(source_type) { diff --git a/src/cargopacket.h b/src/cargopacket.h index bae3618268..054ee7bf76 100644 --- a/src/cargopacket.h +++ b/src/cargopacket.h @@ -61,12 +61,12 @@ private: uint16 count; ///< The amount of cargo in this packet. uint16 days_in_transit; ///< Amount of days this packet has been in transit. Money feeder_share; ///< Value of feeder pickup to be paid for on delivery of cargo. - SourceID source_id; ///< Index of source, INVALID_SOURCE if unknown/invalid. TileIndex source_xy; ///< The origin of the cargo (first station in feeder chain). union { TileIndex loaded_at_xy; ///< Location where this cargo has been loaded into the vehicle. StationID_32bit next_station; ///< Station where the cargo wants to go next. }; + SourceID source_id; ///< Index of source, INVALID_SOURCE if unknown/invalid. StationID source; ///< The station where the cargo came from first. SourceType source_type; ///< Type of \c source_id. uint8 flags = 0; ///< NOSAVE: temporary flags