(svn r10314) -Codechange: Refer to vehicle names by index

This commit is contained in:
peter1138 2007-06-24 22:42:11 +00:00
parent ce91598e3c
commit fc7418d19d
13 changed files with 43 additions and 36 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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}
########

View File

@ -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 */

View File

@ -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;

View File

@ -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) {

View File

@ -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) {

View File

@ -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

View File

@ -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. */

View File

@ -27,6 +27,7 @@ enum {
SCC_STATION_NAME,
SCC_TOWN_NAME,
SCC_GROUP_NAME,
SCC_VEHICLE_NAME,
SCC_CURRENCY_COMPACT,
SCC_CURRENCY,

View File

@ -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;

View File

@ -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;

View File

@ -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);
}