summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/airport_gui.cpp6
-rw-r--r--src/newgrf.cpp7
-rw-r--r--src/newgrf_airport.cpp8
-rw-r--r--src/newgrf_class.h2
-rw-r--r--src/newgrf_class_func.h26
-rw-r--r--src/newgrf_object.cpp4
-rw-r--r--src/object_gui.cpp4
-rw-r--r--src/rail_gui.cpp4
-rw-r--r--src/station_cmd.cpp4
9 files changed, 19 insertions, 46 deletions
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp
index e6591935c..893e3b5fb 100644
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -208,7 +208,7 @@ class BuildAirportWindow : public PickerWindowBase {
DropDownList *list = new DropDownList();
for (uint i = 0; i < AirportClass::GetCount(); i++) {
- list->push_back(new DropDownListStringItem(AirportClass::GetName((AirportClassID)i), i, false));
+ list->push_back(new DropDownListStringItem(AirportClass::Get((AirportClassID)i)->name, i, false));
}
return list;
@@ -242,7 +242,7 @@ public:
{
switch (widget) {
case WID_AP_CLASS_DROPDOWN:
- SetDParam(0, AirportClass::GetName(_selected_airport_class));
+ SetDParam(0, AirportClass::Get(_selected_airport_class)->name);
break;
case WID_AP_LAYOUT_NUM:
@@ -269,7 +269,7 @@ public:
case WID_AP_CLASS_DROPDOWN: {
Dimension d = {0, 0};
for (uint i = 0; i < AirportClass::GetCount(); i++) {
- SetDParam(0, AirportClass::GetName((AirportClassID)i));
+ SetDParam(0, AirportClass::Get((AirportClassID)i)->name);
d = maxdim(d, GetStringBoundingBox(STR_BLACK_STRING));
}
d.width += padding.width;
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 1f796b258..4f825d591 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -3809,8 +3809,9 @@ static ChangeInfoResult ObjectChangeInfo(uint id, int numinfo, int prop, ByteRea
case 0x09: { // Class name
StringID class_name = buf->ReadWord();
- ObjectClass::SetName(spec->cls_id, class_name);
- _string_to_grf_mapping[&ObjectClass::classes[spec->cls_id].name] = _cur.grffile->grfid;
+ ObjectClass *objclass = ObjectClass::Get(spec->cls_id);
+ objclass->name = class_name;
+ _string_to_grf_mapping[&objclass->name] = _cur.grffile->grfid;
break;
}
@@ -5351,7 +5352,7 @@ static void FeatureNewName(ByteReader *buf)
grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8));
} else {
StationClassID cls_id = _cur.grffile->stations[GB(id, 0, 8)]->cls_id;
- StationClass::SetName(cls_id, AddGRFString(_cur.grffile->grfid, id, lang, new_scheme, false, name, STR_UNDEFINED));
+ StationClass::Get(cls_id)->name = AddGRFString(_cur.grffile->grfid, id, lang, new_scheme, false, name, STR_UNDEFINED);
}
break;
diff --git a/src/newgrf_airport.cpp b/src/newgrf_airport.cpp
index 174a79402..d526f6d54 100644
--- a/src/newgrf_airport.cpp
+++ b/src/newgrf_airport.cpp
@@ -25,10 +25,10 @@
template <typename Tspec, typename Tid, Tid Tmax>
/* static */ void NewGRFClass<Tspec, Tid, Tmax>::InsertDefaults()
{
- AirportClass::SetName(AirportClass::Allocate('SMAL'), STR_AIRPORT_CLASS_SMALL);
- AirportClass::SetName(AirportClass::Allocate('LARG'), STR_AIRPORT_CLASS_LARGE);
- AirportClass::SetName(AirportClass::Allocate('HUB_'), STR_AIRPORT_CLASS_HUB);
- AirportClass::SetName(AirportClass::Allocate('HELI'), STR_AIRPORT_CLASS_HELIPORTS);
+ AirportClass::Get(AirportClass::Allocate('SMAL'))->name = STR_AIRPORT_CLASS_SMALL;
+ AirportClass::Get(AirportClass::Allocate('LARG'))->name = STR_AIRPORT_CLASS_LARGE;
+ AirportClass::Get(AirportClass::Allocate('HUB_'))->name = STR_AIRPORT_CLASS_HUB;
+ AirportClass::Get(AirportClass::Allocate('HELI'))->name = STR_AIRPORT_CLASS_HELIPORTS;
}
INSTANTIATE_NEWGRF_CLASS_METHODS(AirportClass, AirportSpec, AirportClassID, APC_MAX)
diff --git a/src/newgrf_class.h b/src/newgrf_class.h
index 81ea4f879..95c589d17 100644
--- a/src/newgrf_class.h
+++ b/src/newgrf_class.h
@@ -32,11 +32,9 @@ struct NewGRFClass {
static void InsertDefaults();
static Tid Allocate(uint32 global_id);
- static void SetName(Tid cls_id, StringID name);
static void Assign(Tspec *spec);
static NewGRFClass *Get(Tid cls_id);
- static StringID GetName(Tid cls_id);
static uint GetCount();
static uint GetCount(Tid cls_id);
static const Tspec *Get(Tid cls_id, uint index);
diff --git a/src/newgrf_class_func.h b/src/newgrf_class_func.h
index 15cacd4e2..0165b518c 100644
--- a/src/newgrf_class_func.h
+++ b/src/newgrf_class_func.h
@@ -65,18 +65,6 @@ DEFINE_NEWGRF_CLASS_METHOD(Tid)::Allocate(uint32 global_id)
}
/**
- * Set the name of a particular class.
- * @param cls_id The id for the class.
- * @pre index < GetCount(cls_id)
- * @param name The new name for the class.
- */
-DEFINE_NEWGRF_CLASS_METHOD(void)::SetName(Tid cls_id, StringID name)
-{
- assert(cls_id < Tmax);
- classes[cls_id].name = name;
-}
-
-/**
* Assign a spec to one of the classes.
* @param spec The spec to assign.
* @note The spec must have a valid class id set.
@@ -105,18 +93,6 @@ NewGRFClass<Tspec, Tid, Tmax> *NewGRFClass<Tspec, Tid, Tmax>::Get(Tid cls_id)
}
/**
- * Get the name of a particular class.
- * @param cls_id The class to get the name of.
- * @pre index < GetCount(cls_id)
- * @return The name of said class.
- */
-DEFINE_NEWGRF_CLASS_METHOD(StringID)::GetName(Tid cls_id)
-{
- assert(cls_id < Tmax);
- return classes[cls_id].name;
-}
-
-/**
* Get the number of allocated classes.
* @return The number of classes.
*/
@@ -186,10 +162,8 @@ DEFINE_NEWGRF_CLASS_METHOD(const Tspec *)::GetByGrf(uint32 grfid, byte local_id,
#define INSTANTIATE_NEWGRF_CLASS_METHODS(name, Tspec, Tid, Tmax) \
template void name::Reset(); \
template Tid name::Allocate(uint32 global_id); \
- template void name::SetName(Tid cls_id, StringID name); \
template void name::Assign(Tspec *spec); \
template NewGRFClass<Tspec, Tid, Tmax> *name::Get(Tid cls_id); \
- template StringID name::GetName(Tid cls_id); \
template uint name::GetCount(); \
template uint name::GetCount(Tid cls_id); \
template const Tspec *name::Get(Tid cls_id, uint index); \
diff --git a/src/newgrf_object.cpp b/src/newgrf_object.cpp
index f77519881..1c92c4293 100644
--- a/src/newgrf_object.cpp
+++ b/src/newgrf_object.cpp
@@ -103,12 +103,12 @@ template <typename Tspec, typename Tid, Tid Tmax>
if (_game_mode != GM_EDITOR) return;
ObjectClassID cls = ObjectClass::Allocate('LTHS');
- ObjectClass::SetName(cls, STR_OBJECT_CLASS_LTHS);
+ ObjectClass::Get(cls)->name = STR_OBJECT_CLASS_LTHS;
_object_specs[OBJECT_LIGHTHOUSE].cls_id = cls;
ObjectClass::Assign(&_object_specs[OBJECT_LIGHTHOUSE]);
cls = ObjectClass::Allocate('TRNS');
- ObjectClass::SetName(cls, STR_OBJECT_CLASS_TRNS);
+ ObjectClass::Get(cls)->name = STR_OBJECT_CLASS_TRNS;
_object_specs[OBJECT_TRANSMITTER].cls_id = cls;
ObjectClass::Assign(&_object_specs[OBJECT_TRANSMITTER]);
}
diff --git a/src/object_gui.cpp b/src/object_gui.cpp
index 241fcdca6..5813517e9 100644
--- a/src/object_gui.cpp
+++ b/src/object_gui.cpp
@@ -78,7 +78,7 @@ public:
switch (widget) {
case WID_BO_CLASS_LIST: {
for (uint i = 0; i < ObjectClass::GetCount(); i++) {
- size->width = max(size->width, GetStringBoundingBox(ObjectClass::GetName((ObjectClassID)i)).width);
+ size->width = max(size->width, GetStringBoundingBox(ObjectClass::Get((ObjectClassID)i)->name).width);
}
size->width += padding.width;
this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
@@ -156,7 +156,7 @@ public:
case WID_BO_CLASS_LIST: {
int y = r.top;
for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < ObjectClass::GetCount(); i++) {
- SetDParam(0, ObjectClass::GetName((ObjectClassID)i));
+ SetDParam(0, ObjectClass::Get((ObjectClassID)i)->name);
DrawString(r.left + WD_MATRIX_LEFT, r.right + WD_MATRIX_RIGHT, y + WD_MATRIX_TOP, STR_JUST_STRING,
((int)i == _selected_object_class) ? TC_WHITE : TC_BLACK);
y += this->line_height;
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index cf10d4824..bf8671000 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -1026,7 +1026,7 @@ public:
Dimension d = {0, 0};
for (uint i = 0; i < StationClass::GetCount(); i++) {
if (i == STAT_CLASS_WAYP) continue;
- SetDParam(0, StationClass::GetName((StationClassID)i));
+ SetDParam(0, StationClass::Get((StationClassID)i)->name);
d = maxdim(d, GetStringBoundingBox(STR_BLACK_STRING));
}
size->width = max(size->width, d.width + padding.width);
@@ -1104,7 +1104,7 @@ public:
for (uint i = 0; i < StationClass::GetCount(); i++) {
if (i == STAT_CLASS_WAYP) continue;
if (this->vscroll->IsVisible(statclass)) {
- SetDParam(0, StationClass::GetName((StationClassID)i));
+ SetDParam(0, StationClass::Get((StationClassID)i)->name);
DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, row * this->line_height + r.top + WD_MATRIX_TOP, STR_JUST_STRING,
(StationClassID)i == _railstation.station_class ? TC_WHITE : TC_BLACK);
row++;
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index c0774556f..08b1cad1d 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2912,7 +2912,7 @@ static void GetTileDesc_Station(TileIndex tile, TileDesc *td)
const StationSpec *spec = GetStationSpec(tile);
if (spec != NULL) {
- td->station_class = StationClass::GetName(spec->cls_id);
+ td->station_class = StationClass::Get(spec->cls_id)->name;
td->station_name = spec->name;
if (spec->grf_prop.grffile != NULL) {
@@ -2927,7 +2927,7 @@ static void GetTileDesc_Station(TileIndex tile, TileDesc *td)
if (IsAirport(tile)) {
const AirportSpec *as = Station::GetByTile(tile)->airport.GetSpec();
- td->airport_class = AirportClass::GetName(as->cls_id);
+ td->airport_class = AirportClass::Get(as->cls_id)->name;
td->airport_name = as->name;
const AirportTileSpec *ats = AirportTileSpec::GetByTile(tile);