diff options
author | peter1138 <peter1138@openttd.org> | 2006-04-21 07:06:31 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2006-04-21 07:06:31 +0000 |
commit | ae94d7b26fbdceab210d5ba7bf257f77ddb81a20 (patch) | |
tree | 3026f917cd75fdee6e3c6c96a37cde096ed4b5a7 | |
parent | 3660fab10a4785c37ead9a718c4e25c601e5c899 (diff) | |
download | openttd-ae94d7b26fbdceab210d5ba7bf257f77ddb81a20.tar.xz |
(svn r4496) - NewGRF: switch custom engine names from storing a char* to using the new StringID based text system. Vehicle name
translations now work.
-rw-r--r-- | newgrf.c | 3 | ||||
-rw-r--r-- | newgrf_engine.c | 18 | ||||
-rw-r--r-- | newgrf_engine.h | 2 |
3 files changed, 9 insertions, 14 deletions
@@ -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); |