From eb1472a82d8007a1deddc25ae81f872e7a91abe5 Mon Sep 17 00:00:00 2001 From: rubidium Date: Thu, 21 Jun 2007 14:54:51 +0000 Subject: (svn r10247) -Fix (r10210): *always* call SetDParamMoney when you want to place money in some string. --- src/aircraft_gui.cpp | 10 +++++----- src/bridge_gui.cpp | 2 +- src/build_vehicle_gui.cpp | 18 +++++++++--------- src/command.cpp | 2 +- src/economy.cpp | 2 +- src/engine_gui.cpp | 16 ++++++++-------- src/graph_gui.cpp | 6 +++--- src/group_gui.cpp | 4 ++-- src/industry_gui.cpp | 2 +- src/main_gui.cpp | 2 +- src/misc_cmd.cpp | 8 ++++---- src/misc_gui.cpp | 8 ++++---- src/network/network_gui.cpp | 6 +++--- src/player_gui.cpp | 16 ++++++++-------- src/players.cpp | 2 +- src/roadveh_gui.cpp | 10 +++++----- src/ship_gui.cpp | 10 +++++----- src/town_gui.cpp | 2 +- src/train_cmd.cpp | 2 +- src/train_gui.cpp | 12 ++++++------ src/variables.h | 2 ++ src/vehicle_gui.cpp | 6 +++--- 22 files changed, 75 insertions(+), 73 deletions(-) (limited to 'src') diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp index b63365361..a9e647a7d 100644 --- a/src/aircraft_gui.cpp +++ b/src/aircraft_gui.cpp @@ -92,7 +92,7 @@ static void AircraftDetailsWndProc(Window *w, WindowEvent *e) SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED); SetDParam(2, v->max_age / 366); - SetDParam(3, _price.aircraft_running * AircraftVehInfo(v->engine_type)->running_cost >> 8); + SetDParamMoney(3, _price.aircraft_running * AircraftVehInfo(v->engine_type)->running_cost >> 8); DrawString(2, 15, STR_A00D_AGE_RUNNING_COST_YR, 0); } @@ -104,8 +104,8 @@ static void AircraftDetailsWndProc(Window *w, WindowEvent *e) /* Draw profit */ { - SetDParam(0, v->profit_this_year); - SetDParam(1, v->profit_last_year); + SetDParamMoney(0, v->profit_this_year); + SetDParamMoney(1, v->profit_last_year); DrawString(2, 35, STR_A00F_PROFIT_THIS_YEAR_LAST_YEAR, 0); } @@ -125,7 +125,7 @@ static void AircraftDetailsWndProc(Window *w, WindowEvent *e) /* Draw Transfer credits text */ { - SetDParam(0, v->cargo_feeder_share); + SetDParamMoney(0, v->cargo_feeder_share); DrawString(60, 101, STR_FEEDER_CARGO_VALUE, 0); } @@ -139,7 +139,7 @@ static void AircraftDetailsWndProc(Window *w, WindowEvent *e) if (IsNormalAircraft(v)) { SetDParam(0, GetCustomEngineName(v->engine_type)); SetDParam(1, v->build_year); - SetDParam(2, v->value); + SetDParamMoney(2, v->value); DrawString(60, y, STR_A011_BUILT_VALUE, 0); y += 10; diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 238ac1698..c850d6d2c 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -47,7 +47,7 @@ static void BuildBridgeWndProc(Window *w, WindowEvent *e) for (uint i = 0; i < 4 && i + w->vscroll.pos < _bridgedata.count; i++) { const Bridge *b = &_bridge[_bridgedata.indexes[i + w->vscroll.pos]]; - SetDParam(2, _bridgedata.costs[i + w->vscroll.pos]); + SetDParamMoney(2, _bridgedata.costs[i + w->vscroll.pos]); SetDParam(1, b->speed * 10 / 16); SetDParam(0, b->material); DrawSprite(b->sprite, b->pal, 3, 15 + i * 22); diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 94647881d..16b6d5df8 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -434,7 +434,7 @@ static const StringID _sort_listing[][11] = {{ static int DrawRailWagonPurchaseInfo(int x, int y, EngineID engine_number, const RailVehicleInfo *rvi) { /* Purchase cost */ - SetDParam(0, (GetEngineProperty(engine_number, 0x17, rvi->base_cost) * _price.build_railwagon) >> 8); + SetDParamMoney(0, (GetEngineProperty(engine_number, 0x17, rvi->base_cost) * _price.build_railwagon) >> 8); DrawString(x, y, STR_PURCHASE_INFO_COST, 0); y += 10; @@ -464,7 +464,7 @@ static int DrawRailEnginePurchaseInfo(int x, int y, EngineID engine_number, cons uint weight = GetEngineProperty(engine_number, 0x16, rvi->weight); /* Purchase Cost - Engine weight */ - SetDParam(0, GetEngineProperty(engine_number, 0x17, rvi->base_cost) * (_price.build_railvehicle >> 3) >> 5); + SetDParamMoney(0, GetEngineProperty(engine_number, 0x17, rvi->base_cost) * (_price.build_railvehicle >> 3) >> 5); SetDParam(1, weight << multihead); DrawString(x, y, STR_PURCHASE_INFO_COST_WEIGHT, 0); y += 10; @@ -483,7 +483,7 @@ static int DrawRailEnginePurchaseInfo(int x, int y, EngineID engine_number, cons } /* Running cost */ - SetDParam(0, (GetEngineProperty(engine_number, 0x0D, rvi->running_cost_base) * _price.running_rail[rvi->running_cost_class] >> 8) << multihead); + SetDParamMoney(0, (GetEngineProperty(engine_number, 0x0D, rvi->running_cost_base) * _price.running_rail[rvi->running_cost_class] >> 8) << multihead); DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0); y += 10; @@ -504,13 +504,13 @@ static int DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number, const R bool refittable = (_engine_info[engine_number].refit_mask != 0); /* Purchase cost - Max speed */ - SetDParam(0, GetEngineProperty(engine_number, 0x11, rvi->base_cost) * (_price.roadveh_base >> 3) >> 5); + SetDParamMoney(0, GetEngineProperty(engine_number, 0x11, rvi->base_cost) * (_price.roadveh_base >> 3) >> 5); SetDParam(1, rvi->max_speed * 10 / 32); DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0); y += 10; /* Running cost */ - SetDParam(0, rvi->running_cost * _price.roadveh_running >> 8); + SetDParamMoney(0, rvi->running_cost * _price.roadveh_running >> 8); DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0); y += 10; @@ -528,7 +528,7 @@ static int DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number, const R static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const ShipVehicleInfo *svi) { /* Purchase cost - Max speed */ - SetDParam(0, GetEngineProperty(engine_number, 0x0A, svi->base_cost) * (_price.ship_base >> 3) >> 5); + SetDParamMoney(0, GetEngineProperty(engine_number, 0x0A, svi->base_cost) * (_price.ship_base >> 3) >> 5); SetDParam(1, GetEngineProperty(engine_number, 0x0B, svi->max_speed) * 10 / 32); DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0); y += 10; @@ -541,7 +541,7 @@ static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const Ship y += 10; /* Running cost */ - SetDParam(0, GetEngineProperty(engine_number, 0x0F, svi->running_cost) * _price.ship_running >> 8); + SetDParamMoney(0, GetEngineProperty(engine_number, 0x0F, svi->running_cost) * _price.ship_running >> 8); DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0); y += 10; @@ -554,7 +554,7 @@ static int DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number, const CargoID cargo; /* Purchase cost - Max speed */ - SetDParam(0, GetEngineProperty(engine_number, 0x0B, avi->base_cost) * (_price.aircraft_base >> 3) >> 5); + SetDParamMoney(0, GetEngineProperty(engine_number, 0x0B, avi->base_cost) * (_price.aircraft_base >> 3) >> 5); SetDParam(1, avi->max_speed * 10 / 16); DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0); y += 10; @@ -576,7 +576,7 @@ static int DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number, const y += 10; /* Running cost */ - SetDParam(0, GetEngineProperty(engine_number, 0x0E, avi->running_cost) * _price.aircraft_running >> 8); + SetDParamMoney(0, GetEngineProperty(engine_number, 0x0E, avi->running_cost) * _price.aircraft_running >> 8); DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0); y += 10; diff --git a/src/command.cpp b/src/command.cpp index 3aa93777c..ce138c4f2 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -569,7 +569,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, if (IsLocalPlayer() && _game_mode != GM_EDITOR) { if (res2.GetCost() != 0) ShowCostOrIncomeAnimation(x, y, GetSlopeZ(x, y), res2.GetCost()); if (_additional_cash_required != 0) { - SetDParam(0, _additional_cash_required); + SetDParamMoney(0, _additional_cash_required); ShowErrorMessage(STR_0003_NOT_ENOUGH_CASH_REQUIRES, error_part1, x, y); if (res2.GetCost() == 0) goto callb_err; } diff --git a/src/economy.cpp b/src/economy.cpp index b9813a7ea..b12a912e1 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1773,7 +1773,7 @@ static void DoAcquireCompany(Player *p) SetDParam(0, p->name_1); SetDParam(1, p->name_2); - SetDParam(2, p->bankrupt_value); + SetDParamMoney(2, 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 */ diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index b2446fbe3..e601e5162 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -120,12 +120,12 @@ static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw) const RailVehicleInfo *rvi = RailVehInfo(engine); uint multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD) ? 1 : 0; - SetDParam(0, (_price.build_railvehicle >> 3) * rvi->base_cost >> 5); + SetDParamMoney(0, (_price.build_railvehicle >> 3) * rvi->base_cost >> 5); SetDParam(2, rvi->max_speed * 10 / 16); SetDParam(3, rvi->power << multihead); SetDParam(1, rvi->weight << multihead); - SetDParam(4, rvi->running_cost_base * _price.running_rail[rvi->running_cost_class] >> 8 << multihead); + SetDParamMoney(4, rvi->running_cost_base * _price.running_rail[rvi->running_cost_class] >> 8 << multihead); if (rvi->capacity != 0) { SetDParam(5, rvi->cargo_type); @@ -139,11 +139,11 @@ static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw) static void DrawAircraftEngineInfo(EngineID engine, int x, int y, int maxw) { const AircraftVehicleInfo *avi = AircraftVehInfo(engine); - SetDParam(0, (_price.aircraft_base >> 3) * avi->base_cost >> 5); + SetDParamMoney(0, (_price.aircraft_base >> 3) * avi->base_cost >> 5); SetDParam(1, avi->max_speed * 10 / 16); SetDParam(2, avi->passenger_capacity); SetDParam(3, avi->mail_capacity); - SetDParam(4, avi->running_cost * _price.aircraft_running >> 8); + SetDParamMoney(4, avi->running_cost * _price.aircraft_running >> 8); DrawStringMultiCenter(x, y, STR_A02E_COST_MAX_SPEED_CAPACITY, maxw); } @@ -152,9 +152,9 @@ static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw) { const RoadVehicleInfo *rvi = RoadVehInfo(engine); - SetDParam(0, (_price.roadveh_base >> 3) * rvi->base_cost >> 5); + SetDParamMoney(0, (_price.roadveh_base >> 3) * rvi->base_cost >> 5); SetDParam(1, rvi->max_speed * 10 / 32); - SetDParam(2, rvi->running_cost * _price.roadveh_running >> 8); + SetDParamMoney(2, rvi->running_cost * _price.roadveh_running >> 8); SetDParam(3, rvi->cargo_type); SetDParam(4, rvi->capacity); @@ -164,11 +164,11 @@ static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw) static void DrawShipEngineInfo(EngineID engine, int x, int y, int maxw) { const ShipVehicleInfo *svi = ShipVehInfo(engine); - SetDParam(0, svi->base_cost * (_price.ship_base >> 3) >> 5); + SetDParamMoney(0, svi->base_cost * (_price.ship_base >> 3) >> 5); SetDParam(1, svi->max_speed * 10 / 32); SetDParam(2, svi->cargo_type); SetDParam(3, svi->capacity); - SetDParam(4, svi->running_cost * _price.ship_running >> 8); + SetDParamMoney(4, svi->running_cost * _price.ship_running >> 8); DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw); } diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 99c0941f6..152c66f43 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -64,7 +64,7 @@ struct GraphDrawer { uint height; ///< The height of the graph in pixels. StringID format_str_y_axis; byte colors[GRAPH_MAX_DATASETS]; - int64 cost[GRAPH_MAX_DATASETS][24]; ///< last 2 years + Money cost[GRAPH_MAX_DATASETS][24]; ///< last 2 years }; static void DrawGraph(const GraphDrawer *gw) @@ -132,7 +132,7 @@ static void DrawGraph(const GraphDrawer *gw) for (int i = 0; i < gw->num_dataset; i++) { if (!HASBIT(gw->excluded_data, i)) { for (int j = 0; j < gw->num_on_x_axis; j++) { - int64 datapoint = gw->cost[i][j]; + Money datapoint = gw->cost[i][j]; if (datapoint != INVALID_DATAPOINT) { /* For now, if the graph has negative values the scaling is @@ -214,7 +214,7 @@ static void DrawGraph(const GraphDrawer *gw) uint prev_y = INVALID_DATAPOINT_POS; for (int j = 0; j < gw->num_on_x_axis; j++) { - int64 datapoint = gw->cost[i][j]; + Money datapoint = gw->cost[i][j]; if (datapoint != INVALID_DATAPOINT) { /* XXX: This can overflow if x_axis_offset * datapoint is diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 4d19ba925..b7b15a81e 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -461,8 +461,8 @@ static void GroupWndProc(Window *w, WindowEvent *e) STR_PROFIT_GOOD_THIS_YEAR_GOOD_LAST_YEAR; } - SetDParam(0, v->profit_this_year); - SetDParam(1, v->profit_last_year); + SetDParamMoney(0, v->profit_this_year); + SetDParamMoney(1, v->profit_last_year); DrawString(x + 19, y2 + w->resize.step_height - 8, str, 0); if (IsValidGroupID(v->group_id)) { diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index dca4ef7ac..4eb80d87e 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -39,7 +39,7 @@ static void BuildIndustryWndProc(Window *w, WindowEvent *e) if (_thd.place_mode == 1 && _thd.window_class == WC_BUILD_INDUSTRY) { int ind_type = _build_industry_types[_opt_ptr->landscape][WP(w, def_d).data_1]; - SetDParam(0, (_price.build_industry >> 8) * GetIndustrySpec(ind_type)->cost_multiplier); + SetDParamMoney(0, (_price.build_industry >> 8) * GetIndustrySpec(ind_type)->cost_multiplier); DrawStringCentered(85, w->height - 21, STR_482F_COST, 0); } break; diff --git a/src/main_gui.cpp b/src/main_gui.cpp index a7896b62d..4c468dc1a 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -2208,7 +2208,7 @@ static void StatusBarWndProc(Window *w, WindowEvent *e) if (p != NULL) { /* Draw player money */ - SetDParam64(0, p->player_money); + SetDParamMoney(0, p->player_money); DrawStringCentered(570, 1, p->player_money >= 0 ? STR_0004 : STR_0005, 0); } diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp index 69ecbf29d..ac546aa08 100644 --- a/src/misc_cmd.cpp +++ b/src/misc_cmd.cpp @@ -129,7 +129,7 @@ CommandCost CmdIncreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) Player *p = GetPlayer(_current_player); if (p->current_loan >= _economy.max_loan) { - SetDParam(0, _economy.max_loan); + SetDParamMoney(0, _economy.max_loan); return_cmd_error(STR_702B_MAXIMUM_PERMITTED_LOAN); } @@ -173,7 +173,7 @@ CommandCost CmdDecreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) switch (p2) { default: return CMD_ERROR; // Invalid method case 0: // Pay back one step - loan = min(p->current_loan, (IsHumanPlayer(_current_player) || _patches.ainew_active) ? LOAN_INTERVAL : LOAN_INTERVAL_OLD_AI); + loan = min(p->current_loan, (Money)(IsHumanPlayer(_current_player) || _patches.ainew_active) ? LOAN_INTERVAL : LOAN_INTERVAL_OLD_AI); break; case 1: // Pay back as much as possible loan = max(min(p->current_loan, p->player_money), (Money)LOAN_INTERVAL); @@ -182,7 +182,7 @@ CommandCost CmdDecreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) } if (p->player_money < loan) { - SetDParam(0, loan); + SetDParamMoney(0, loan); return_cmd_error(STR_702E_REQUIRED); } @@ -307,7 +307,7 @@ CommandCost CmdMoneyCheat(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdGiveMoney(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { const Player *p = GetPlayer(_current_player); - CommandCost amount(min((Money)p1, 20000000LL)); + CommandCost amount(min((Money)p1, (Money)20000000LL)); SET_EXPENSES_TYPE(EXPENSES_OTHER); diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 64fba654c..5d887cc17 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -122,7 +122,7 @@ static void Place_LandInfo(TileIndex tile) str = STR_01A4_COST_TO_CLEAR_N_A; if (CmdSucceeded(costclear)) { - SetDParam(0, costclear.GetCost()); + SetDParamMoney(0, costclear.GetCost()); str = STR_01A5_COST_TO_CLEAR; } GetString(_landinfo_data[2], str, lastof(_landinfo_data[2])); @@ -618,7 +618,7 @@ void ShowEstimatedCostOrIncome(Money cost, int x, int y) cost = -cost; msg = STR_0807_ESTIMATED_INCOME; } - SetDParam(0, cost); + SetDParamMoney(0, cost); ShowErrorMessage(INVALID_STRING_ID, msg, x, y); } @@ -632,7 +632,7 @@ void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost) cost = -cost; msg = STR_0803_INCOME; } - SetDParam(0, cost); + SetDParamMoney(0, cost); AddTextEffect(msg, pt.x, pt.y, 0x250); } @@ -640,7 +640,7 @@ void ShowFeederIncomeAnimation(int x, int y, int z, Money cost) { Point pt = RemapCoords(x,y,z); - SetDParam(0, cost); + SetDParamMoney(0, cost); AddTextEffect(STR_FEEDER, pt.x, pt.y, 0x250); } diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index d5a3f147a..112efdf73 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -894,15 +894,15 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e) DrawString(x, y, STR_NETWORK_INAUGURATION_YEAR, 2); // inauguration year y += 10; - SetDParam64(0, _network_player_info[nd->company].company_value); + SetDParamMoney(0, _network_player_info[nd->company].company_value); DrawString(x, y, STR_NETWORK_VALUE, 2); // company value y += 10; - SetDParam64(0, _network_player_info[nd->company].money); + SetDParamMoney(0, _network_player_info[nd->company].money); DrawString(x, y, STR_NETWORK_CURRENT_BALANCE, 2); // current balance y += 10; - SetDParam64(0, _network_player_info[nd->company].income); + SetDParamMoney(0, _network_player_info[nd->company].income); DrawString(x, y, STR_NETWORK_LAST_YEARS_INCOME, 2); // last year's income y += 10; diff --git a/src/player_gui.cpp b/src/player_gui.cpp index a56d05c78..7324e097e 100644 --- a/src/player_gui.cpp +++ b/src/player_gui.cpp @@ -60,14 +60,14 @@ static void DrawPlayerEconomyStats(const Player *p, byte mode) str = STR_701E; if (cost < 0) { cost = -cost; str++; } - SetDParam64(0, cost); + SetDParamMoney(0, cost); DrawStringRightAligned(x, 27 + i * 10, str, 0); } } str = STR_701E; if (sum < 0) { sum = -sum; str++; } - SetDParam64(0, sum); + SetDParamMoney(0, sum); DrawStringRightAligned(x, 27 + 13 * 10 + 2, str, 0); GfxFillRect(x - 75, 27 + 10 * 13, x, 27 + 10 * 13, 215); @@ -80,27 +80,27 @@ static void DrawPlayerEconomyStats(const Player *p, byte mode) y = 171; /* draw max loan aligned to loan below (y += 10) */ - SetDParam64(0, (uint64)_economy.max_loan); + SetDParamMoney(0, _economy.max_loan); DrawString(202, y + 10, STR_MAX_LOAN, 0); } else { y = 15; } DrawString(2, y, STR_7026_BANK_BALANCE, 0); - SetDParam64(0, p->player_money); + SetDParamMoney(0, p->player_money); DrawStringRightAligned(182, y, STR_7028, 0); y += 10; DrawString(2, y, STR_7027_LOAN, 0); - SetDParam64(0, p->current_loan); + SetDParamMoney(0, p->current_loan); DrawStringRightAligned(182, y, STR_7028, 0); y += 12; GfxFillRect(182 - 75, y - 2, 182, y - 2, 215); - SetDParam64(0, p->player_money - p->current_loan); + SetDParamMoney(0, p->player_money - p->current_loan); DrawStringRightAligned(182, y, STR_7028, 0); } @@ -778,7 +778,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e) SetDParam(1, p->president_name_2); DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, 94); - SetDParam64(0, CalculateCompanyValue(p)); + SetDParamMoney(0, CalculateCompanyValue(p)); DrawString(110, 114, STR_7076_COMPANY_VALUE, 0); DrawCompanyOwnerText(p); @@ -947,7 +947,7 @@ static void BuyCompanyWndProc(Window *w, WindowEvent *e) SetDParam(0, p->name_1); SetDParam(1, p->name_2); - SetDParam(2, p->bankrupt_value); + SetDParamMoney(2, p->bankrupt_value); DrawStringMultiCenter(214, 65, STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT, 238); break; } diff --git a/src/players.cpp b/src/players.cpp index 56c117c94..9a4f61ce1 100644 --- a/src/players.cpp +++ b/src/players.cpp @@ -178,7 +178,7 @@ bool CheckPlayerHasMoney(CommandCost cost) if (cost.GetCost() > 0) { PlayerID pid = _current_player; if (IsValidPlayer(pid) && cost.GetCost() > GetPlayer(pid)->player_money) { - SetDParam(0, cost.GetCost()); + SetDParamMoney(0, cost.GetCost()); _error_message = STR_0003_NOT_ENOUGH_CASH_REQUIRES; return false; } diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp index a07203f0b..34ecf19ff 100644 --- a/src/roadveh_gui.cpp +++ b/src/roadveh_gui.cpp @@ -92,7 +92,7 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e) SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED); SetDParam(2, v->max_age / 366); - SetDParam(3, RoadVehInfo(v->engine_type)->running_cost * _price.roadveh_running >> 8); + SetDParamMoney(3, RoadVehInfo(v->engine_type)->running_cost * _price.roadveh_running >> 8); DrawString(2, 15, STR_900D_AGE_RUNNING_COST_YR, 0); } @@ -104,8 +104,8 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e) /* Draw profit */ { - SetDParam(0, v->profit_this_year); - SetDParam(1, v->profit_last_year); + SetDParamMoney(0, v->profit_this_year); + SetDParamMoney(1, v->profit_last_year); DrawString(2, 35, STR_900F_PROFIT_THIS_YEAR_LAST_YEAR, 0); } @@ -120,7 +120,7 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e) SetDParam(0, GetCustomEngineName(v->engine_type)); SetDParam(1, v->build_year); - SetDParam(2, v->value); + SetDParamMoney(2, v->value); DrawString(34, 57 + y_offset, STR_9011_BUILT_VALUE, 0); if (RoadVehHasArticPart(v)) { @@ -182,7 +182,7 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e) } /* Draw Transfer credits text */ - SetDParam(0, v->cargo_feeder_share); + SetDParamMoney(0, v->cargo_feeder_share); DrawString(34, 90 + y_offset, STR_FEEDER_CARGO_VALUE, 0); /* Draw service interval text */ diff --git a/src/ship_gui.cpp b/src/ship_gui.cpp index 4cca7e17d..670edc0ed 100644 --- a/src/ship_gui.cpp +++ b/src/ship_gui.cpp @@ -50,7 +50,7 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e) SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED); SetDParam(2, v->max_age / 366); - SetDParam(3, ShipVehInfo(v->engine_type)->running_cost * _price.ship_running >> 8); + SetDParamMoney(3, ShipVehInfo(v->engine_type)->running_cost * _price.ship_running >> 8); DrawString(2, 15, STR_9812_AGE_RUNNING_COST_YR, 0); } @@ -62,8 +62,8 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e) /* Draw profit */ { - SetDParam(0, v->profit_this_year); - SetDParam(1, v->profit_last_year); + SetDParamMoney(0, v->profit_this_year); + SetDParamMoney(1, v->profit_last_year); DrawString(2, 35, STR_9814_PROFIT_THIS_YEAR_LAST_YEAR, 0); } @@ -85,7 +85,7 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e) SetDParam(1, v->build_year); SetDParam(0, GetCustomEngineName(v->engine_type)); - SetDParam(2, v->value); + SetDParamMoney(2, v->value); DrawString(74, 57, STR_9816_BUILT_VALUE, 0); SetDParam(0, v->cargo_type); @@ -102,7 +102,7 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e) DrawString(74, 78, str, 0); /* Draw Transfer credits text */ - SetDParam(0, v->cargo_feeder_share); + SetDParamMoney(0, v->cargo_feeder_share); DrawString(74, 89, STR_FEEDER_CARGO_VALUE, 0); } break; diff --git a/src/town_gui.cpp b/src/town_gui.cpp index bb46c0c17..8cb690c6b 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -175,7 +175,7 @@ static void TownAuthorityWndProc(Window *w, WindowEvent *e) int i = WP(w,def_d).data_1; if (i != -1) { - SetDParam(1, (_price.build_industry >> 8) * _town_action_costs[i]); + SetDParamMoney(1, (_price.build_industry >> 8) * _town_action_costs[i]); SetDParam(0, STR_2046_SMALL_ADVERTISING_CAMPAIGN + i); DrawStringMultiLine(2, 159, STR_204D_INITIATE_A_SMALL_LOCAL + i, 313); } diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 1d5a88877..228ccfb02 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -3422,7 +3422,7 @@ void TrainsYearlyLoop() if (v->type == VEH_TRAIN && IsFrontEngine(v)) { /* show warning if train is not generating enough income last 2 years (corresponds to a red icon in the vehicle list) */ if (_patches.train_income_warn && v->owner == _local_player && v->age >= 730 && v->profit_this_year < 0) { - SetDParam(1, v->profit_this_year); + SetDParamMoney(1, v->profit_this_year); SetDParam(0, v->unitnumber); AddNewsItem( STR_TRAIN_IS_UNPROFITABLE, diff --git a/src/train_gui.cpp b/src/train_gui.cpp index 1a1a475c8..d8bc63231 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -345,12 +345,12 @@ static void TrainDetailsInfoTab(const Vehicle *v, int x, int y) { if (RailVehInfo(v->engine_type)->railveh_type == RAILVEH_WAGON) { SetDParam(0, GetCustomEngineName(v->engine_type)); - SetDParam(1, v->value); + SetDParamMoney(1, v->value); DrawString(x, y, STR_882D_VALUE, 0x10); } else { SetDParam(0, GetCustomEngineName(v->engine_type)); SetDParam(1, v->build_year); - SetDParam(2, v->value); + SetDParamMoney(2, v->value); DrawString(x, y, STR_882C_BUILT_VALUE, 0x10); } } @@ -423,7 +423,7 @@ static void DrawTrainDetailsWindow(Window *w) SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED); SetDParam(2, v->max_age / 366); - SetDParam(3, GetTrainRunningCost(v) >> 8); + SetDParamMoney(3, GetTrainRunningCost(v) >> 8); DrawString(x, 15, STR_885D_AGE_RUNNING_COST_YR, 0); SetDParam(2, v->u.rail.cached_max_speed * 10 / 16); @@ -434,8 +434,8 @@ static void DrawTrainDetailsWindow(Window *w) STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE : STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED, 0); - SetDParam(0, v->profit_this_year); - SetDParam(1, v->profit_last_year); + SetDParamMoney(0, v->profit_this_year); + SetDParamMoney(1, v->profit_last_year); DrawString(x, 35, STR_885F_PROFIT_THIS_YEAR_LAST_YEAR, 0); SetDParam(0, 100 * (v->reliability>>8) >> 8); @@ -504,7 +504,7 @@ static void DrawTrainDetailsWindow(Window *w) DrawString(x, y + 2, FreightWagonMult(i) > 1 ? STR_TOTAL_CAPACITY_MULT : STR_013F_TOTAL_CAPACITY, 0); } } - SetDParam(0, v->cargo_feeder_share); + SetDParamMoney(0, v->cargo_feeder_share); DrawString(x, y + 15, STR_FEEDER_CARGO_VALUE, 0); } } diff --git a/src/variables.h b/src/variables.h index d62c6f250..de6a0b738 100644 --- a/src/variables.h +++ b/src/variables.h @@ -367,6 +367,8 @@ static inline void SetDParam64(uint n, uint64 v) _decode_parameters[n + 1] = v >> 32; } +static inline void SetDParamMoney(uint n, Money m) { SetDParam64(n, (uint64)m); } + static inline uint32 GetDParam(uint n) { assert(n < lengthof(_decode_parameters)); diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index b9bd7bb31..c90c490bf 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -346,7 +346,7 @@ static void VehicleRefitWndProc(Window *w, WindowEvent *e) if (CmdSucceeded(cost)) { SetDParam(0, WP(w, refit_d).cargo->cargo); SetDParam(1, _returned_refit_capacity); - SetDParam(2, cost.GetCost()); + SetDParamMoney(2, cost.GetCost()); DrawString(2, w->widget[5].top + 1, STR_9840_NEW_CAPACITY_COST_OF_REFIT, 0); } } @@ -1005,8 +1005,8 @@ static void DrawVehicleListWindow(Window *w) const Vehicle *v = vl->sort_list[i]; StringID str; - SetDParam(0, v->profit_this_year); - SetDParam(1, v->profit_last_year); + SetDParamMoney(0, v->profit_this_year); + SetDParamMoney(1, v->profit_last_year); DrawVehicleImage(v, x + 19, y + 6, w->widget[VLW_WIDGET_LIST].right - w->widget[VLW_WIDGET_LIST].left - 20, 0, INVALID_VEHICLE); DrawString(x + 19, y + w->resize.step_height - 8, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0); -- cgit v1.2.3-54-g00ecf