Codechange: Add station/roadstop class labels for DFLT/WAYP.

This avoids repeating the same multichar literal value.
This commit is contained in:
Peter Nelson 2024-05-07 12:13:47 +01:00
parent 5fa31cf49f
commit 89d05d87c2
No known key found for this signature in database
GPG Key ID: 8EF8F0A467DF75ED
4 changed files with 14 additions and 8 deletions

View File

@ -31,10 +31,10 @@ template <>
void RoadStopClass::InsertDefaults()
{
/* Set up initial data */
RoadStopClass::Get(RoadStopClass::Allocate('DFLT'))->name = STR_STATION_CLASS_DFLT;
RoadStopClass::Get(RoadStopClass::Allocate('DFLT'))->Insert(nullptr);
RoadStopClass::Get(RoadStopClass::Allocate('WAYP'))->name = STR_STATION_CLASS_WAYP;
RoadStopClass::Get(RoadStopClass::Allocate('WAYP'))->Insert(nullptr);
RoadStopClass::Get(RoadStopClass::Allocate(ROADSTOP_CLASS_LABEL_DEFAULT))->name = STR_STATION_CLASS_DFLT;
RoadStopClass::Get(RoadStopClass::Allocate(ROADSTOP_CLASS_LABEL_DEFAULT))->Insert(nullptr);
RoadStopClass::Get(RoadStopClass::Allocate(ROADSTOP_CLASS_LABEL_WAYPOINT))->name = STR_STATION_CLASS_WAYP;
RoadStopClass::Get(RoadStopClass::Allocate(ROADSTOP_CLASS_LABEL_WAYPOINT))->Insert(nullptr);
}
template <>

View File

@ -22,6 +22,9 @@
/** The maximum amount of roadstops a single GRF is allowed to add */
static const int NUM_ROADSTOPS_PER_GRF = UINT16_MAX - 1;
static const uint32_t ROADSTOP_CLASS_LABEL_DEFAULT = 'DFLT';
static const uint32_t ROADSTOP_CLASS_LABEL_WAYPOINT = 'WAYP';
enum RoadStopClassID : uint16_t {
ROADSTOP_CLASS_BEGIN = 0, ///< The lowest valid value
ROADSTOP_CLASS_DFLT = 0, ///< Default road stop class.

View File

@ -32,10 +32,10 @@ template <>
/* static */ void StationClass::InsertDefaults()
{
/* Set up initial data */
StationClass::Get(StationClass::Allocate('DFLT'))->name = STR_STATION_CLASS_DFLT;
StationClass::Get(StationClass::Allocate('DFLT'))->Insert(nullptr);
StationClass::Get(StationClass::Allocate('WAYP'))->name = STR_STATION_CLASS_WAYP;
StationClass::Get(StationClass::Allocate('WAYP'))->Insert(nullptr);
StationClass::Get(StationClass::Allocate(STATION_CLASS_LABEL_DEFAULT))->name = STR_STATION_CLASS_DFLT;
StationClass::Get(StationClass::Allocate(STATION_CLASS_LABEL_DEFAULT))->Insert(nullptr);
StationClass::Get(StationClass::Allocate(STATION_CLASS_LABEL_WAYPOINT))->name = STR_STATION_CLASS_WAYP;
StationClass::Get(StationClass::Allocate(STATION_CLASS_LABEL_WAYPOINT))->Insert(nullptr);
}
template <>

View File

@ -79,6 +79,9 @@ struct StationResolverObject : public ResolverObject {
uint32_t GetDebugID() const override;
};
static const uint32_t STATION_CLASS_LABEL_DEFAULT = 'DFLT';
static const uint32_t STATION_CLASS_LABEL_WAYPOINT = 'WAYP';
enum StationClassID : uint16_t {
STAT_CLASS_BEGIN = 0, ///< the lowest valid value
STAT_CLASS_DFLT = 0, ///< Default station class.