Mercurial > hg > openttd
changeset 7058:74d401c66902 draft
(svn r10323) -Codechange: reference company name, number and player (president) name
by index
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Mon, 25 Jun 2007 13:30:38 +0000 |
parents | 9120898eaf3b |
children | 88ca8902530e |
files | src/economy.cpp src/functions.h src/graph_gui.cpp src/group_gui.cpp src/lang/english.txt src/main_gui.cpp src/misc_gui.cpp src/openttd.cpp src/player_gui.cpp src/players.cpp src/screenshot.cpp src/station_gui.cpp src/strgen/strgen.cpp src/strings.cpp src/subsidy_gui.cpp src/table/control_codes.h src/town_cmd.cpp src/town_gui.cpp src/vehicle_gui.cpp |
diffstat | 19 files changed, 114 insertions(+), 140 deletions(-) [+] |
line wrap: on
line diff
--- a/src/economy.cpp +++ b/src/economy.cpp @@ -478,8 +478,7 @@ DeletePlayerWindows(owner); /* Show bankrupt news */ - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); + SetDParam(0, p->index); AddNewsItem( (StringID)(owner | NB_BBANKRUPT), NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0); if (IsHumanPlayer(owner)) { @@ -516,8 +515,7 @@ DrawPlayerFace(p->face, p->player_color, 2, 23); GfxFillRect(3, 23, 3 + 91, 23 + 118, PALETTE_TO_STRUCT_GREY | (1 << USE_COLORTABLE)); - SetDParam(0, p->president_name_1); - SetDParam(1, p->president_name_2); + SetDParam(0, p->index); DrawStringMultiCenter(49, 148, STR_7058_PRESIDENT, 94); @@ -525,8 +523,7 @@ case NB_BTROUBLE: DrawStringCentered(w->width>>1, 1, STR_7056_TRANSPORT_COMPANY_IN_TROUBLE, 0); - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); + SetDParam(0, p->index); DrawStringMultiCenter( ((w->width - 101) >> 1) + 98, @@ -540,10 +537,9 @@ DrawStringCentered(w->width>>1, 1, STR_7059_TRANSPORT_COMPANY_MERGER, 0); COPY_IN_DPARAM(0,WP(w,news_d).ni->params, 2); - SetDParam(2, p->name_1); - SetDParam(3, p->name_2); + SetDParam(2, p->index); price = WP(w,news_d).ni->params[2]; - SetDParam(4, price); + SetDParam(3, price); DrawStringMultiCenter( ((w->width - 101) >> 1) + 98, 90, @@ -564,9 +560,8 @@ case NB_BNEWCOMPANY: DrawStringCentered(w->width>>1, 1, STR_705E_NEW_TRANSPORT_COMPANY_LAUNCHED, 0); - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); - COPY_IN_DPARAM(2,WP(w,news_d).ni->params, 2); + SetDParam(0, p->index); + COPY_IN_DPARAM(1,WP(w,news_d).ni->params, 2); DrawStringMultiCenter( ((w->width - 101) >> 1) + 98, 90, @@ -587,16 +582,14 @@ case NB_BTROUBLE: SetDParam(0, STR_7056_TRANSPORT_COMPANY_IN_TROUBLE); SetDParam(1, STR_7057_WILL_BE_SOLD_OFF_OR_DECLARED); - SetDParam(2, p->name_1); - SetDParam(3, p->name_2); + SetDParam(2, p->index); return STR_02B6; case NB_BMERGER: SetDParam(0, STR_7059_TRANSPORT_COMPANY_MERGER); SetDParam(1, STR_705A_HAS_BEEN_SOLD_TO_FOR); COPY_IN_DPARAM(2,ni->params, 2); - SetDParam(4, p->name_1); - SetDParam(5, p->name_2); - COPY_IN_DPARAM(6,ni->params + 2, 1); + SetDParam(4, p->index); + COPY_IN_DPARAM(5,ni->params + 2, 1); return STR_02B6; case NB_BBANKRUPT: SetDParam(0, STR_705C_BANKRUPT); @@ -606,9 +599,8 @@ case NB_BNEWCOMPANY: SetDParam(0, STR_705E_NEW_TRANSPORT_COMPANY_LAUNCHED); SetDParam(1, STR_705F_STARTS_CONSTRUCTION_NEAR); - SetDParam(2, p->name_1); - SetDParam(3, p->name_2); - COPY_IN_DPARAM(4,ni->params, 2); + SetDParam(2, p->index); + COPY_IN_DPARAM(3,ni->params, 2); return STR_02B6; default: NOT_REACHED(); @@ -1302,8 +1294,7 @@ InjectDParam(2); p = GetPlayer(_current_player); - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); + SetDParam(0, p->index); AddNewsItem( STR_2031_SERVICE_SUBSIDY_AWARDED + _opt.diff.subsidy_multiplier, NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_SUBSIDIES, 0), @@ -1731,9 +1722,8 @@ int i; Money value; - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); - SetDParam(2, p->bankrupt_value); + SetDParam(0, p->index); + SetDParam(1, p->bankrupt_value); AddNewsItem( (StringID)(_current_player | NB_BMERGER), NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0); /* original code does this a little bit differently */
--- a/src/functions.h +++ b/src/functions.h @@ -25,7 +25,6 @@ void SubtractMoneyFromPlayerFract(PlayerID player, CommandCost cost); bool CheckOwnership(Owner owner); bool CheckTileOwnership(TileIndex tile); -StringID GetPlayerNameString(PlayerID player, uint index); /* standard */ void ShowInfo(const char *str);
--- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -270,9 +270,8 @@ DrawPlayerIcon(p->index, 4, 18 + p->index * 12); - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); - SetDParam(2, GetPlayerNameString(p->index, 3)); + SetDParam(0, p->index); + SetDParam(1, p->index); DrawString(21, 17 + p->index * 12, STR_7021, HASBIT(_legend_excluded_players, p->index) ? 0x10 : 0xC); } break; @@ -875,10 +874,9 @@ for (uint i = 0; i != pl_num; i++) { p = plist[i]; SetDParam(0, i + STR_01AC_1ST); - SetDParam(1, p->name_1); - SetDParam(2, p->name_2); - SetDParam(3, GetPlayerNameString(p->index, 4)); - SetDParam(5, GetPerformanceTitleFromValue(p->old_economy[1].performance_history)); + SetDParam(1, p->index); + SetDParam(2, p->index); + SetDParam(3, GetPerformanceTitleFromValue(p->old_economy[1].performance_history)); DrawString(2, 15 + i * 10, i == 0 ? STR_7054 : STR_7055, 0); DrawPlayerIcon(p->index, 27, 16 + i * 10);
--- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -344,9 +344,8 @@ /* If selected_group == DEFAULT_GROUP, draw the standard caption We list all vehicles */ if (IsDefaultGroupID(gv->group_sel)) { - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); - SetDParam(2, gv->l.list_length); + SetDParam(0, p->index); + SetDParam(1, gv->l.list_length); switch (gv->vehicle_type) { case VEH_TRAIN:
--- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1714,7 +1714,7 @@ STR_2021_SHOW_INFORMATION_ON_LOCAL :{BLACK}Show information on local authority STR_2022_LOCAL_AUTHORITY :{WHITE}{TOWN} local authority STR_2023_TRANSPORT_COMPANY_RATINGS :{BLACK}Transport company ratings: -STR_2024 :{YELLOW}{COMPANY}{PLAYERNAME}: {ORANGE}{STRING} +STR_2024 :{YELLOW}{COMPANY}{COMPANYNUM}: {ORANGE}{STRING} STR_2025_SUBSIDIES :{WHITE}Subsidies STR_2026_SUBSIDIES_ON_OFFER_FOR :{BLACK}Subsidies on offer for services taking: STR_2027_FROM_TO :{ORANGE}{STRING} from {STRING2} to {STRING2} @@ -2162,7 +2162,7 @@ ##id 0x7000 STR_7000 : -STR_7001 :{WHITE}{COMPANY} {BLACK}{PLAYERNAME} +STR_7001 :{WHITE}{COMPANY} {BLACK}{COMPANYNUM} STR_7002_PLAYER :(Player {COMMA}) STR_7004_NEW_FACE :{BLACK}New Face STR_7005_COLOR_SCHEME :{BLACK}Colour Scheme @@ -2174,7 +2174,7 @@ STR_700B_PRESIDENT_S_NAME :Manager's Name STR_700C_CAN_T_CHANGE_COMPANY_NAME :{WHITE}Can't change company name... STR_700D_CAN_T_CHANGE_PRESIDENT :{WHITE}Can't change manager's name... -STR_700E_FINANCES :{WHITE}{COMPANY} Finances {BLACK}{PLAYERNAME} +STR_700E_FINANCES :{WHITE}{COMPANY} Finances {BLACK}{COMPANYNUM} STR_700F_EXPENDITURE_INCOME :{WHITE}Expenditure/Income STR_7010 :{WHITE}{NUM} STR_7011_CONSTRUCTION :{GOLD}Construction @@ -2193,7 +2193,7 @@ STR_701E :{BLACK}-{CURRENCY} STR_701F :{BLACK}+{CURRENCY} STR_7020_TOTAL :{WHITE}Total: -STR_7021 :{COMPANY}{PLAYERNAME} +STR_7021 :{COMPANY}{COMPANYNUM} STR_7022_INCOME_GRAPH :{WHITE}Income Graph STR_CURRCOMPACT :{CURRCOMPACT} STR_7024 :{COMMA} @@ -2242,8 +2242,8 @@ STR_7051_COMPANY_PERFORMANCE_RATINGS :{WHITE}Company performance ratings (maximum rating=1000) STR_7052_COMPANY_VALUES :{WHITE}Company values STR_7053_COMPANY_LEAGUE_TABLE :{WHITE}Company League Table -STR_7054 :{WHITE}{STRING}{SETX 45}{ORANGE}{COMPANY} {BLACK}{PLAYERNAME} '{STRING}' -STR_7055 :{YELLOW}{STRING}{SETX 45}{ORANGE}{COMPANY} {BLACK}{PLAYERNAME} '{STRING}' +STR_7054 :{WHITE}{STRING}{SETX 45}{ORANGE}{COMPANY} {BLACK}{COMPANYNUM} '{STRING}' +STR_7055 :{YELLOW}{STRING}{SETX 45}{ORANGE}{COMPANY} {BLACK}{COMPANYNUM} '{STRING}' STR_7056_TRANSPORT_COMPANY_IN_TROUBLE :{BLACK}{BIGFONT}Transport company in trouble! STR_7057_WILL_BE_SOLD_OFF_OR_DECLARED :{BLACK}{BIGFONT}{COMPANY} will be sold off or declared bankrupt unless performance increases soon! STR_7058_PRESIDENT :{BLACK}{PLAYERNAME}{}(Manager) @@ -3339,7 +3339,9 @@ 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_COMPANY_NAME :{COMPANY} STR_GROUP_NAME :{GROUP} +STR_PLAYER_NAME :{PLAYERNAME} STR_SIGN_NAME :{SIGN} STR_VEHICLE_NAME :{VEHICLE}
--- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -605,9 +605,8 @@ DrawPlayerIcon(p->index, x + 2, y + 1); - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); - SetDParam(2, GetPlayerNameString(p->index, 3)); + SetDParam(0, p->index); + SetDParam(1, p->index); color = (p->index == sel) ? 0xC : 0x10; if (chk&1) color = 14; @@ -2227,8 +2226,7 @@ } else { if (p != NULL) { /* This is the default text */ - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); + SetDParam(0, p->index); DrawStringCentered(320, 1, STR_02BA, 0); } }
--- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -1416,9 +1416,8 @@ Let's use the name of player #0 for now. */ const Player *p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST); - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); - SetDParam(2, _date); + SetDParam(0, p->index); + SetDParam(1, _date); GetString(_edit_str_buf, STR_4004, lastof(_edit_str_buf)); SanitizeFilename(_edit_str_buf); }
--- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1012,11 +1012,8 @@ #endif /* PSP */ if (_patches.keep_all_autosave && _local_player != PLAYER_SPECTATOR) { - const Player *p = GetPlayer(_local_player); - - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); - SetDParam(2, _date); + SetDParam(0, _local_player); + SetDParam(1, _date); GetString(buf, STR_4004, lastof(buf)); ttd_strlcpy(buf, ".sav", sizeof(buf)); } else {
--- a/src/player_gui.cpp +++ b/src/player_gui.cpp @@ -165,10 +165,9 @@ SetWindowWidgetDisabledState(w, 7, p->current_loan == 0); } - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); - SetDParam(2, GetPlayerNameString(player, 3)); - SetDParam(4, LOAN_INTERVAL); + SetDParam(0, p->index); + SetDParam(1, p->index); + SetDParam(2, LOAN_INTERVAL); DrawWindowWidgets(w); DrawPlayerEconomyStats(p, (byte)WP(w, def_d).data_1); @@ -708,9 +707,8 @@ if (amt != 0) { num++; - SetDParam(num * 3 + 0, amt * 25); - SetDParam(num * 3 + 1, p2->name_1); - SetDParam(num * 3 + 2, p2->name_2); + SetDParam(num * 2 + 0, amt * 25); + SetDParam(num * 2 + 1, p2->index); if (num != 0) break; } @@ -757,9 +755,8 @@ } } - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); - SetDParam(2, GetPlayerNameString((PlayerID)w->window_number, 3)); + SetDParam(0, p->index); + SetDParam(1, p->index); DrawWindowWidgets(w); @@ -774,8 +771,7 @@ DrawPlayerFace(p->face, p->player_color, 2, 16); - SetDParam(0, p->president_name_1); - SetDParam(1, p->president_name_2); + SetDParam(0, p->index); DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, 94); SetDParam(0, CalculateCompanyValue(p)); @@ -812,16 +808,16 @@ case PCW_WIDGET_PRESIDENT_NAME: { const Player *p = GetPlayer((PlayerID)w->window_number); WP(w, def_d).byte_1 = 0; - SetDParam(0, p->president_name_2); - ShowQueryString(p->president_name_1, STR_700B_PRESIDENT_S_NAME, 31, 94, w, CS_ALPHANUMERAL); + SetDParam(0, p->index); + ShowQueryString(STR_PLAYER_NAME, STR_700B_PRESIDENT_S_NAME, 31, 94, w, CS_ALPHANUMERAL); break; } case PCW_WIDGET_COMPANY_NAME: { Player *p = GetPlayer((PlayerID)w->window_number); WP(w, def_d).byte_1 = 1; - SetDParam(0, p->name_2); - ShowQueryString(p->name_1, STR_700A_COMPANY_NAME, 31, 150, w, CS_ALPHANUMERAL); + SetDParam(0, p->index); + ShowQueryString(STR_COMPANY_NAME, STR_700A_COMPANY_NAME, 31, 150, w, CS_ALPHANUMERAL); break; } @@ -939,15 +935,13 @@ switch (e->event) { case WE_PAINT: { Player *p = GetPlayer((PlayerID)w->window_number); - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); + SetDParam(0, p->index); DrawWindowWidgets(w); DrawPlayerFace(p->face, p->player_color, 2, 16); - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); - SetDParam(2, p->bankrupt_value); + SetDParam(0, p->index); + SetDParam(1, p->bankrupt_value); DrawStringMultiCenter(214, 65, STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT, 238); break; } @@ -1028,16 +1022,13 @@ /* We need to get performance from last year because the image is shown * at the start of the new year when these things have already been copied */ if (WP(w, highscore_d).background_img == SPR_TYCOON_IMG2_BEGIN) { // Tycoon of the century \o/ - SetDParam(0, p->president_name_1); - SetDParam(1, p->president_name_2); - SetDParam(2, p->name_1); - SetDParam(3, p->name_2); - SetDParam(4, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history)); + SetDParam(0, p->index); + SetDParam(1, p->index); + SetDParam(2, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history)); DrawStringMultiCenter(x + (640 / 2), y + 107, STR_021C_OF_ACHIEVES_STATUS, 640); } else { - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); - SetDParam(2, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history)); + SetDParam(0, p->index); + SetDParam(1, EndGameGetPerformanceTitleFromValue(p->old_economy[0].performance_history)); DrawStringMultiCenter(x + (640 / 2), y + 157, STR_021B_ACHIEVES_STATUS, 640); } } break;
--- a/src/players.cpp +++ b/src/players.cpp @@ -246,8 +246,8 @@ } else { const Player* p = GetPlayer(owner); - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); + SetDParam(0, STR_COMPANY_NAME); + SetDParam(1, p->index); } } else { const Town* t = ClosestTownFromTile(tile, (uint)-1); @@ -414,15 +414,15 @@ p->president_name_2 = Random(); p->president_name_1 = SPECSTR_PRESIDENT_NAME; - SetDParam(0, p->president_name_2); - GetString(buffer, p->president_name_1, lastof(buffer)); + SetDParam(0, p->index); + GetString(buffer, STR_PLAYER_NAME, lastof(buffer)); if (strlen(buffer) >= 32 || GetStringBoundingBox(buffer).width >= 94) continue; FOR_ALL_PLAYERS(pp) { if (pp->is_active && p != pp) { - SetDParam(0, pp->president_name_2); - GetString(buffer2, pp->president_name_1, lastof(buffer2)); + SetDParam(0, pp->index); + GetString(buffer2, STR_PLAYER_NAME, lastof(buffer2)); if (strcmp(buffer2, buffer) == 0) goto restart; } @@ -555,16 +555,6 @@ MaybeStartNewPlayer(); } -/** index is the next parameter in _decode_parameters to set up */ -StringID GetPlayerNameString(PlayerID player, uint index) -{ - if (IsHumanPlayer(player) && IsValidPlayer(player)) { - SetDParam(index, player+1); - return STR_7002_PLAYER; - } - return STR_EMPTY; -} - extern void ShowPlayerFinances(PlayerID player); void PlayersYearlyLoop() @@ -917,8 +907,7 @@ DeletePlayerWindows(p->index); /* Show the bankrupt news */ - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); + SetDParam(0, p->index); AddNewsItem( (StringID)(p->index | NB_BBANKRUPT), NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0); /* Remove the company */ @@ -1002,10 +991,8 @@ if (hs[i].score <= score) { /* move all elements one down starting from the replaced one */ memmove(&hs[i + 1], &hs[i], sizeof(HighScore) * (lengthof(_highscore_table[0]) - i - 1)); - SetDParam(0, p->president_name_1); - SetDParam(1, p->president_name_2); - SetDParam(2, p->name_1); - SetDParam(3, p->name_2); + SetDParam(0, p->index); + SetDParam(1, p->index); GetString(hs[i].company, STR_HIGHSCORE_NAME, lastof(hs[i].company)); // get manager/company name string hs[i].score = score; hs[i].title = EndGameGetPerformanceTitleFromValue(score); @@ -1047,10 +1034,8 @@ for (i = 0; i < lengthof(_highscore_table[LAST_HS_ITEM]) && i < count; i++) { HighScore* hs = &_highscore_table[LAST_HS_ITEM][i]; - SetDParam(0, pl[i]->president_name_1); - SetDParam(1, pl[i]->president_name_2); - SetDParam(2, pl[i]->name_1); - SetDParam(3, pl[i]->name_2); + SetDParam(0, pl[i]->index); + SetDParam(1, pl[i]->index); GetString(hs->company, STR_HIGHSCORE_NAME, lastof(hs->company)); // get manager/company name string hs->score = pl[i]->old_economy[0].performance_history; hs->title = EndGameGetPerformanceTitleFromValue(hs->score);
--- a/src/screenshot.cpp +++ b/src/screenshot.cpp @@ -531,10 +531,8 @@ if (_game_mode == GM_EDITOR || _game_mode == GM_MENU || _local_player == PLAYER_SPECTATOR) { ttd_strlcpy(_screenshot_name, "screenshot", lengthof(_screenshot_name)); } else { - const Player* p = GetPlayer(_local_player); - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); - SetDParam(2, _date); + SetDParam(0, _local_player); + SetDParam(1, _date); GetString(_screenshot_name, STR_4004, lastof(_screenshot_name)); }
--- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -309,10 +309,8 @@ SetVScrollCount(w, sl->list_length); /* draw widgets, with player's name in the caption */ - const Player* p = GetPlayer(owner); - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); - SetDParam(2, w->vscroll.count); + SetDParam(0, owner); + SetDParam(1, w->vscroll.count); DrawWindowWidgets(w); /* draw sorting criteria string */
--- a/src/strgen/strgen.cpp +++ b/src/strgen/strgen.cpp @@ -461,11 +461,6 @@ {"REV", EmitSingleChar, SCC_REVISION, 0, 0}, // openttd revision string {"SHORTCARGO", EmitSingleChar, SCC_CARGO_SHORT, 2, 0}, // short cargo description, only ### tons, or ### litres - // These are special versions of {STRING1} - // The first string includes the second string. - {"COMPANY", EmitSingleChar, SCC_STRING1, 2, 0}, - {"PLAYERNAME", 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 {"STRING3", EmitSingleChar, SCC_STRING3, 3, C_CASE}, // included string that consumes THREE arguments @@ -506,6 +501,9 @@ {"GROUP", EmitSingleChar, SCC_GROUP_NAME, 1, 0}, {"SIGN", EmitSingleChar, SCC_SIGN_NAME, 1, 0}, {"VEHICLE", EmitSingleChar, SCC_VEHICLE_NAME, 1, 0}, + {"COMPANY", EmitSingleChar, SCC_COMPANY_NAME, 1, 0}, + {"COMPANYNUM", EmitSingleChar, SCC_COMPANY_NUM, 1, 0}, + {"PLAYERNAME", EmitSingleChar, SCC_PLAYER_NAME, 1, 0}, // 0x9D is used for the pseudo command SETCASE // 0x9E is used for case switching
--- a/src/strings.cpp +++ b/src/strings.cpp @@ -880,6 +880,34 @@ break; } + case SCC_COMPANY_NAME: { // {COMPANY} + const Player *p = GetPlayer((PlayerID)GetInt32(&argv)); + int64 args[1]; + args[0] = p->name_2; + buff = GetStringWithArgs(buff, p->name_1, args, last); + break; + } + + case SCC_COMPANY_NUM: { // {COMPANYNUM} + PlayerID player = (PlayerID)GetInt32(&argv); + + /* Nothing is added for AI or inactive players */ + if (IsHumanPlayer(player) && IsValidPlayer(player)) { + int64 args[1]; + args[0] = player + 1; + buff = GetStringWithArgs(buff, STR_7002_PLAYER, args, last); + } + break; + } + + case SCC_PLAYER_NAME: { // {PLAYERNAME} + const Player *p = GetPlayer((PlayerID)GetInt32(&argv)); + int64 args[1]; + args[0] = p->president_name_2; + buff = GetStringWithArgs(buff, p->president_name_1, 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. */
--- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -122,14 +122,12 @@ for (s = _subsidies; s != endof(_subsidies); s++) { if (s->cargo_type != CT_INVALID && s->age >= 12) { - const Player *p; int xt; SetupSubsidyDecodeParam(s, 1); - p = GetPlayer(GetStation(s->to)->owner); - SetDParam(3, p->name_1); - SetDParam(4, p->name_2); + PlayerID player = GetStation(s->to)->owner; + SetDParam(3, player); xt = DrawString(x + 2, y, STR_202C_FROM_TO, 0);
--- a/src/table/control_codes.h +++ b/src/table/control_codes.h @@ -29,6 +29,9 @@ SCC_GROUP_NAME, SCC_VEHICLE_NAME, SCC_SIGN_NAME, + SCC_COMPANY_NAME, + SCC_COMPANY_NUM, + SCC_PLAYER_NAME, SCC_CURRENCY_COMPACT, SCC_CURRENCY,
--- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -1934,15 +1934,10 @@ static void TownActionRoadRebuild(Town* t) { - const Player* p; - t->road_build_months = 6; SetDParam(0, t->index); - - p = GetPlayer(_current_player); - SetDParam(1, p->name_1); - SetDParam(2, p->name_2); + SetDParam(1, _current_player); AddNewsItem(STR_2055_TRAFFIC_CHAOS_IN_ROAD_REBUILDING, NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_GENERAL, 0), t->xy, 0);
--- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -127,9 +127,8 @@ if (p->is_active && (HASBIT(t->have_ratings, p->index) || t->exclusivity == p->index)) { DrawPlayerIcon(p->index, 2, y); - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); - SetDParam(2, GetPlayerNameString(p->index, 3)); + SetDParam(0, p->index); + SetDParam(1, p->index); r = t->ratings[p->index]; (str = STR_3035_APPALLING, r <= RATING_APPALLING) || // Apalling @@ -141,7 +140,7 @@ (str++, r <= RATING_EXCELLENT) || // Excellent (str++, true); // Outstanding - SetDParam(4, str); + SetDParam(2, str); if (t->exclusivity == p->index) { // red icon for player with exclusive rights DrawSprite(SPR_BLOT, PALETTE_TO_RED, 18, y); }
--- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -957,9 +957,8 @@ break; case VLW_STANDARD: /* Company Name */ - SetDParam(0, p->name_1); - SetDParam(1, p->name_2); - SetDParam(2, w->vscroll.count); + SetDParam(0, p->index); + SetDParam(1, w->vscroll.count); break; case VLW_STATION_LIST: /* Station Name */