summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--newgrf.c3
-rw-r--r--newgrf_engine.c18
-rw-r--r--newgrf_engine.h2
3 files changed, 9 insertions, 14 deletions
diff --git a/newgrf.c b/newgrf.c
index f276c12d8..7269c5d6e 100644
--- a/newgrf.c
+++ b/newgrf.c
@@ -1762,8 +1762,7 @@ static void VehicleNewName(byte *buf, int len)
case GSF_ROAD:
case GSF_SHIP:
case GSF_AIRCRAFT:
- SetCustomEngineName(id, name);
- /*SetCustomEngineName(id, AddGRFString(_cur_grffile->grfid, id, lang, name));*/
+ SetCustomEngineName(id, AddGRFString(_cur_grffile->grfid, id, lang, name));
break;
#if 0
diff --git a/newgrf_engine.c b/newgrf_engine.c
index 2b4d28812..f30c7ebba 100644
--- a/newgrf_engine.c
+++ b/newgrf_engine.c
@@ -607,28 +607,24 @@ void TriggerVehicle(Vehicle *veh, VehicleTrigger trigger)
DoTriggerVehicle(veh, trigger, 0, true);
}
-static char *_engine_custom_names[TOTAL_NUM_ENGINES];
+StringID _engine_custom_names[TOTAL_NUM_ENGINES];
-void SetCustomEngineName(EngineID engine, const char *name)
+void SetCustomEngineName(EngineID engine, StringID name)
{
- _engine_custom_names[engine] = strdup(name);
+ _engine_custom_names[engine] = name;
}
void UnloadCustomEngineNames(void)
{
- char **i;
- for (i = _engine_custom_names; i != endof(_engine_custom_names); i++) {
- free(*i);
- *i = NULL;
+ EngineID i;
+ for (i = 0; i < TOTAL_NUM_ENGINES; i++) {
+ _engine_custom_names[i] = 0;
}
}
StringID GetCustomEngineName(EngineID engine)
{
- if (!_engine_custom_names[engine])
- return _engine_name_strings[engine];
- ttd_strlcpy(_userstring, _engine_custom_names[engine], lengthof(_userstring));
- return STR_SPEC_USERSTRING;
+ return _engine_custom_names[engine] == 0 ? _engine_name_strings[engine] : _engine_custom_names[engine];
}
// Functions for changing the order of vehicle purchase lists
diff --git a/newgrf_engine.h b/newgrf_engine.h
index a822fec26..eac7e2f6f 100644
--- a/newgrf_engine.h
+++ b/newgrf_engine.h
@@ -34,7 +34,7 @@ typedef enum VehicleTrigger {
} VehicleTrigger;
void TriggerVehicle(Vehicle *veh, VehicleTrigger trigger);
-void SetCustomEngineName(EngineID engine, const char *name);
+void SetCustomEngineName(EngineID engine, StringID name);
StringID GetCustomEngineName(EngineID engine);
void UnloadWagonOverrides(void);