(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is

no limit to the amount of names.
-Fix: NewGRF engines could not be renamed.
This commit is contained in:
peter1138
2008-01-12 19:58:06 +00:00
parent 74f9be8f2c
commit 0f7392bd61
38 changed files with 250 additions and 298 deletions

View File

@@ -552,20 +552,14 @@ static int CDECL VehicleNameSorter(const void *a, const void *b)
if (va != last_vehicle[0]) {
last_vehicle[0] = va;
if (IsCustomName(va->string_id)) {
GetString(last_name[0], va->string_id, lastof(last_name[0]));
} else {
last_name[0][0] = '\0';
}
SetDParam(0, va->index);
GetString(last_name[0], STR_VEHICLE_NAME, lastof(last_name[0]));
}
if (vb != last_vehicle[1]) {
last_vehicle[1] = vb;
if (IsCustomName(vb->string_id)) {
GetString(last_name[1], vb->string_id, lastof(last_name[1]));
} else {
last_name[1][0] = '\0';
}
SetDParam(1, vb->index);
GetString(last_name[1], STR_VEHICLE_NAME, lastof(last_name[1]));
}
r = strcmp(last_name[0], last_name[1]); // sort by name
@@ -1010,11 +1004,7 @@ static void DrawVehicleListWindow(Window *w)
DrawVehicleImage(v, x + 19, y + 6, INVALID_VEHICLE, w->widget[VLW_WIDGET_LIST].right - w->widget[VLW_WIDGET_LIST].left - 20, 0);
DrawString(x + 19, y + w->resize.step_height - 8, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, TC_FROMSTRING);
if ((v->type == VEH_TRAIN && v->string_id != STR_SV_TRAIN_NAME) ||
(v->type == VEH_ROAD && v->string_id != STR_SV_ROADVEH_NAME) ||
(v->type == VEH_SHIP && v->string_id != STR_SV_SHIP_NAME) ||
(v->type == VEH_AIRCRAFT && v->string_id != STR_SV_AIRCRAFT_NAME)) {
if (v->name != NULL) {
/* The vehicle got a name so we will print it */
SetDParam(0, v->index);
DrawString(x + 19, y, STR_01AB, TC_FROMSTRING);