summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2007-06-24 22:42:11 +0000
committerpeter1138 <peter1138@openttd.org>2007-06-24 22:42:11 +0000
commitfc7418d19d831e7ebc0e7c5b5651d58e76158fe0 (patch)
treed9368d95af8a7f09cc32a4f7eb328fb63e863059
parentce91598e3ce045fcc3aeed3a3f07821d96605e9f (diff)
downloadopenttd-fc7418d19d831e7ebc0e7c5b5651d58e76158fe0.tar.xz
(svn r10314) -Codechange: Refer to vehicle names by index
-rw-r--r--src/aircraft_gui.cpp10
-rw-r--r--src/autoreplace_cmd.cpp4
-rw-r--r--src/lang/english.txt6
-rw-r--r--src/order_cmd.cpp4
-rw-r--r--src/order_gui.cpp3
-rw-r--r--src/roadveh_gui.cpp10
-rw-r--r--src/ship_gui.cpp10
-rw-r--r--src/strgen/strgen.cpp2
-rw-r--r--src/strings.cpp11
-rw-r--r--src/table/control_codes.h1
-rw-r--r--src/timetable_gui.cpp3
-rw-r--r--src/train_gui.cpp10
-rw-r--r--src/vehicle_gui.cpp5
13 files changed, 43 insertions, 36 deletions
diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp
index 5ddea35fd..85ba43443 100644
--- a/src/aircraft_gui.cpp
+++ b/src/aircraft_gui.cpp
@@ -80,8 +80,7 @@ static void AircraftDetailsWndProc(Window *w, WindowEvent *e)
SetWindowWidgetDisabledState(w, 5, !_patches.servint_aircraft);
SetWindowWidgetDisabledState(w, 6, !_patches.servint_aircraft);
- SetDParam(0, v->string_id);
- SetDParam(1, v->unitnumber);
+ SetDParam(0, v->index);
DrawWindowWidgets(w);
/* Draw running cost */
@@ -173,8 +172,8 @@ static void AircraftDetailsWndProc(Window *w, WindowEvent *e)
switch (e->we.click.widget) {
case 2: /* rename */
v = GetVehicle(w->window_number);
- SetDParam(0, v->unitnumber);
- ShowQueryString(v->string_id, STR_A030_NAME_AIRCRAFT, 31, 150, w, CS_ALPHANUMERAL);
+ SetDParam(0, v->index);
+ ShowQueryString(STR_VEHICLE_NAME, STR_A030_NAME_AIRCRAFT, 31, 150, w, CS_ALPHANUMERAL);
break;
case 5: /* increase int */
mod = _ctrl_pressed? 5 : 10;
@@ -272,8 +271,7 @@ static void AircraftViewWndProc(Window *w, WindowEvent *e)
/* draw widgets & caption */
- SetDParam(0, v->string_id);
- SetDParam(1, v->unitnumber);
+ SetDParam(0, v->index);
DrawWindowWidgets(w);
if (v->vehstatus & VS_CRASHED) {
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index 88df05c5c..ede105d9f 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -17,6 +17,7 @@
#include "aircraft.h"
#include "cargotype.h"
#include "group.h"
+#include "strings.h"
/*
@@ -241,7 +242,8 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
if (!IsCustomName(old_v->string_id)) {
vehicle_name[0] = '\0';
} else {
- GetName(vehicle_name, old_v->string_id & 0x7FF, lastof(vehicle_name));
+ SetDParam(0, old_v->index);
+ GetString(vehicle_name, STR_VEHICLE_NAME, lastof(vehicle_name));
}
} else { // flags & DC_EXEC not set
CommandCost tmp_move;
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 410889c90..372b2e518 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -495,7 +495,7 @@ STR_01A7_OWNER :{BLACK}Owner: {
STR_01A8_LOCAL_AUTHORITY :{BLACK}Local authority: {LTBLUE}{STRING1}
STR_01A9_NONE :None
STR_01AA_NAME :{BLACK}Name
-STR_01AB :{BLACK}{TINYFONT}{STRING}
+STR_01AB :{BLACK}{TINYFONT}{VEHICLE}
############ range for days starts
STR_01AC_1ST :1st
@@ -2594,7 +2594,7 @@ STR_8107_MAGLEV_LOCOMOTIVE :maglev locomoti
##id 0x8800
STR_8800_TRAIN_DEPOT :{WHITE}{TOWN} Train Depot
STR_8801_CITIZENS_CELEBRATE_FIRST :{BLACK}{BIGFONT}Citizens celebrate . . .{}First train arrives at {STATION}!
-STR_8802_DETAILS :{WHITE}{STRING1} (Details)
+STR_8802_DETAILS :{WHITE}{VEHICLE} (Details)
STR_8803_TRAIN_IN_THE_WAY :{WHITE}Train in the way
STR_8804 :{SETX 10}{COMMA}: {STRING1} {STRING1}
STR_8805 :{RIGHTARROW}{SETX 10}{COMMA}: {STRING1} {STRING1}
@@ -3340,4 +3340,6 @@ STR_PROFIT_BAD_THIS_YEAR_GOOD_LAST_YEAR :{TINYFONT}{BLAC
STR_PROFIT_GOOD_THIS_YEAR_BAD_LAST_YEAR :{TINYFONT}{BLACK}Profit this year: {GREEN}{CURRENCY} {BLACK}(last year: {RED}{CURRENCY}{BLACK})
STR_PROFIT_BAD_THIS_YEAR_BAD_LAST_YEAR :{TINYFONT}{BLACK}Profit this year: {RED}{CURRENCY} {BLACK}(last year: {RED}{CURRENCY}{BLACK})
+STR_VEHICLE_NAME :{VEHICLE}
+
########
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 7b14f912f..13f16ef8f 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -18,6 +18,7 @@
#include "saveload.h"
#include "vehicle_gui.h"
#include "cargotype.h"
+#include "strings.h"
/**
* Called if a new block is added to the order-pool
@@ -974,7 +975,8 @@ void BackupVehicleOrders(const Vehicle *v, BackuppedOrders *bak)
if (!IsCustomName(v->string_id)) {
bak->name[0] = '\0';
} else {
- GetName(bak->name, v->string_id & 0x7FF, lastof(bak->name));
+ SetDParam(0, v->index);
+ GetString(bak->name, STR_VEHICLE_NAME, lastof(bak->name));
}
/* If we have shared orders, store it on a special way */
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index d769162f9..ac08f9538 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -176,8 +176,7 @@ static void DrawOrdersWindow(Window *w)
}
}
- SetDParam(0, v->string_id);
- SetDParam(1, v->unitnumber);
+ SetDParam(0, v->index);
DrawWindowWidgets(w);
y = 15;
diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp
index d97b20dbb..ab94fb855 100644
--- a/src/roadveh_gui.cpp
+++ b/src/roadveh_gui.cpp
@@ -80,8 +80,7 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e)
SetWindowWidgetDisabledState(w, 5, !_patches.servint_roadveh);
SetWindowWidgetDisabledState(w, 6, !_patches.servint_roadveh);
- SetDParam(0, v->string_id);
- SetDParam(1, v->unitnumber);
+ SetDParam(0, v->index);
DrawWindowWidgets(w);
/* Draw running cost */
@@ -199,8 +198,8 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e)
switch (e->we.click.widget) {
case 2: /* rename */
v = GetVehicle(w->window_number);
- SetDParam(0, v->unitnumber);
- ShowQueryString(v->string_id, STR_902C_NAME_ROAD_VEHICLE, 31, 150, w, CS_ALPHANUMERAL);
+ SetDParam(0, v->index);
+ ShowQueryString(STR_VEHICLE_NAME, STR_902C_NAME_ROAD_VEHICLE, 31, 150, w, CS_ALPHANUMERAL);
break;
case 5: /* increase int */
@@ -283,8 +282,7 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e)
_engine_info[v->engine_type].refit_mask == 0);
/* draw widgets & caption */
- SetDParam(0, v->string_id);
- SetDParam(1, v->unitnumber);
+ SetDParam(0, v->index);
DrawWindowWidgets(w);
if (v->u.road.crashed_ctr != 0) {
diff --git a/src/ship_gui.cpp b/src/ship_gui.cpp
index 53eee6784..68e2acb17 100644
--- a/src/ship_gui.cpp
+++ b/src/ship_gui.cpp
@@ -38,8 +38,7 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e)
SetWindowWidgetDisabledState(w, 5, !_patches.servint_ships);
SetWindowWidgetDisabledState(w, 6, !_patches.servint_ships);
- SetDParam(0, v->string_id);
- SetDParam(1, v->unitnumber);
+ SetDParam(0, v->index);
DrawWindowWidgets(w);
/* Draw running cost */
@@ -113,8 +112,8 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e)
switch (e->we.click.widget) {
case 2: /* rename */
v = GetVehicle(w->window_number);
- SetDParam(0, v->unitnumber);
- ShowQueryString(v->string_id, STR_9831_NAME_SHIP, 31, 150, w, CS_ALPHANUMERAL);
+ SetDParam(0, v->index);
+ ShowQueryString(STR_VEHICLE_NAME, STR_9831_NAME_SHIP, 31, 150, w, CS_ALPHANUMERAL);
break;
case 5: /* increase int */
mod = _ctrl_pressed? 5 : 10;
@@ -208,8 +207,7 @@ static void ShipViewWndProc(Window *w, WindowEvent *e)
SetWindowWidgetDisabledState(w, 11, !is_localplayer);
/* draw widgets & caption */
- SetDParam(0, v->string_id);
- SetDParam(1, v->unitnumber);
+ SetDParam(0, v->index);
DrawWindowWidgets(w);
if (v->breakdown_ctr == 1) {
diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp
index 2433f7394..e6be06104 100644
--- a/src/strgen/strgen.cpp
+++ b/src/strgen/strgen.cpp
@@ -465,7 +465,6 @@ static const CmdStruct _cmd_structs[] = {
// The first string includes the second string.
{"COMPANY", EmitSingleChar, SCC_STRING1, 2, 0},
{"PLAYERNAME", EmitSingleChar, SCC_STRING1, 1, 0},
- {"VEHICLE", EmitSingleChar, SCC_STRING1, 1, 0},
{"STRING1", EmitSingleChar, SCC_STRING1, 1, C_CASE}, // included string that consumes ONE argument
{"STRING2", EmitSingleChar, SCC_STRING2, 2, C_CASE}, // included string that consumes TWO arguments
@@ -505,6 +504,7 @@ static const CmdStruct _cmd_structs[] = {
{"STATION", EmitSingleChar, SCC_STATION_NAME, 1, 0},
{"TOWN", EmitSingleChar, SCC_TOWN_NAME, 1, 0},
{"GROUP", EmitSingleChar, SCC_GROUP_NAME, 1, 0},
+ {"VEHICLE", EmitSingleChar, SCC_VEHICLE_NAME, 1, 0},
// 0x9D is used for the pseudo command SETCASE
// 0x9E is used for case switching
diff --git a/src/strings.cpp b/src/strings.cpp
index bb97c899c..2b1c5bb44 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -29,6 +29,7 @@
#include "group.h"
#include "debug.h"
#include "newgrf_townname.h"
+#include "vehicle.h"
/* for opendir/readdir/closedir */
# include "fios.h"
@@ -861,6 +862,16 @@ static char* FormatString(char* buff, const char* str, const int64* argv, uint c
break;
}
+ case SCC_VEHICLE_NAME: { // {VEHICLE}
+ const Vehicle *v = GetVehicle(GetInt32(&argv));
+
+ int64 args[1];
+ args[0] = v->unitnumber;
+
+ buff = GetStringWithArgs(buff, v->string_id, args, last);
+ break;
+ }
+
case SCC_SETCASE: { // {SETCASE}
/* This is a pseudo command, it's outputted when someone does {STRING.ack}
* The modifier is added to all subsequent GetStringWithArgs that accept the modifier. */
diff --git a/src/table/control_codes.h b/src/table/control_codes.h
index eb24f5766..8eb737f40 100644
--- a/src/table/control_codes.h
+++ b/src/table/control_codes.h
@@ -27,6 +27,7 @@ enum {
SCC_STATION_NAME,
SCC_TOWN_NAME,
SCC_GROUP_NAME,
+ SCC_VEHICLE_NAME,
SCC_CURRENCY_COMPACT,
SCC_CURRENCY,
diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp
index 5b3d2f99f..02a8436da 100644
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -73,8 +73,7 @@ static void DrawTimetableWindow(Window *w)
DisableWindowWidget(w, 8);
}
- SetDParam(0, v->string_id);
- SetDParam(1, v->unitnumber);
+ SetDParam(0, v->index);
DrawWindowWidgets(w);
int y = 15;
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index 095e51739..78b48bbe0 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -169,8 +169,7 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
}
/* draw widgets & caption */
- SetDParam(0, v->string_id);
- SetDParam(1, v->unitnumber);
+ SetDParam(0, v->index);
DrawWindowWidgets(w);
if (v->u.rail.crash_anim_pos != 0) {
@@ -412,8 +411,7 @@ static void DrawTrainDetailsWindow(Window *w)
SetWindowWidgetDisabledState(w, 6, !_patches.servint_trains);
SetWindowWidgetDisabledState(w, 7, !_patches.servint_trains);
- SetDParam(0, v->string_id);
- SetDParam(1, v->unitnumber);
+ SetDParam(0, v->index);
DrawWindowWidgets(w);
SetDParam(1, v->age / 366);
@@ -520,8 +518,8 @@ static void TrainDetailsWndProc(Window *w, WindowEvent *e)
switch (e->we.click.widget) {
case 2: /* name train */
v = GetVehicle(w->window_number);
- SetDParam(0, v->unitnumber);
- ShowQueryString(v->string_id, STR_8865_NAME_TRAIN, 31, 150, w, CS_ALPHANUMERAL);
+ SetDParam(0, v->index);
+ ShowQueryString(STR_VEHICLE_NAME, STR_8865_NAME_TRAIN, 31, 150, w, CS_ALPHANUMERAL);
break;
case 6: /* inc serv interval */
mod = _ctrl_pressed? 5 : 10;
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index b9bd7bb31..a2c3d6936 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -331,8 +331,7 @@ static void VehicleRefitWndProc(Window *w, WindowEvent *e)
SetVScrollCount(w, WP(w, refit_d).list->num_lines);
- SetDParam(0, v->string_id);
- SetDParam(1, v->unitnumber);
+ SetDParam(0, v->index);
DrawWindowWidgets(w);
WP(w, refit_d).cargo = DrawVehicleRefitWindow(WP(w, refit_d).list, WP(w, refit_d).sel, w->vscroll.pos, w->vscroll.cap, w->resize.step_height);
@@ -1017,7 +1016,7 @@ static void DrawVehicleListWindow(Window *w)
(v->type == VEH_AIRCRAFT && v->string_id != STR_SV_AIRCRAFT_NAME)) {
/* The vehicle got a name so we will print it */
- SetDParam(0, v->string_id);
+ SetDParam(0, v->index);
DrawString(x + 19, y, STR_01AB, 0);
}