Codechange: Replace separate Station/RoadStopSpecList with template struct.

Reduces duplication and simplifies reuse.

Additionally naming an item that is used in a list as a ...List was
pretty weird.
This commit is contained in:
Peter Nelson
2024-03-02 13:49:55 +00:00
committed by Peter Nelson
parent 278c3a7db1
commit 41b3314d76
2 changed files with 13 additions and 18 deletions

View File

@@ -19,16 +19,11 @@
typedef Pool<BaseStation, StationID, 32, 64000> StationPool;
extern StationPool _station_pool;
struct StationSpecList {
const StationSpec *spec;
uint32_t grfid; ///< GRF ID of this custom station
uint16_t localidx; ///< Station ID within GRF of station
};
struct RoadStopSpecList {
const RoadStopSpec *spec;
uint32_t grfid; ///< GRF ID of this custom road stop
uint16_t localidx; ///< Station ID within GRF of road stop
template <typename T>
struct SpecMapping {
const T *spec; ///< Custom spec.
uint32_t grfid; ///< GRF ID of this custom spec.
uint16_t localidx; ///< Local ID within GRF of this custom spec.
};
struct RoadStopTileData {
@@ -74,8 +69,8 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
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
std::vector<SpecMapping<StationSpec>> speclist; ///< List of rail station specs of this station.
std::vector<SpecMapping<RoadStopSpec>> roadstop_speclist; ///< List of road stop specs of this station
TimerGameCalendar::Date build_date; ///< Date of construction