mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-22 23:26:34 +00:00
(svn r4496) - NewGRF: switch custom engine names from storing a char* to using the new StringID based text system. Vehicle name
translations now work.
This commit is contained in:
parent
3660fab10a
commit
ae94d7b26f
3
newgrf.c
3
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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user