mirror of https://github.com/OpenTTD/OpenTTD
(svn r16359) -Codechange: don't abuse company 0 when determining 'cost to clear land' in the LandInfoWindow
parent
ec76117379
commit
00bc2659f2
|
@ -104,14 +104,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
LandInfoWindow(TileIndex tile) : Window(&_land_info_desc) {
|
LandInfoWindow(TileIndex tile) : Window(&_land_info_desc) {
|
||||||
Company *c = Company::Get(Company::IsValidID(_local_company) ? _local_company : COMPANY_FIRST);
|
|
||||||
Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
|
Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
|
||||||
|
|
||||||
Money old_money = c->money;
|
|
||||||
c->money = INT64_MAX;
|
|
||||||
CommandCost costclear = DoCommand(tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR);
|
|
||||||
c->money = old_money;
|
|
||||||
|
|
||||||
/* Because build_date is not set yet in every TileDesc, we make sure it is empty */
|
/* Because build_date is not set yet in every TileDesc, we make sure it is empty */
|
||||||
TileDesc td;
|
TileDesc td;
|
||||||
AcceptedCargo ac;
|
AcceptedCargo ac;
|
||||||
|
@ -158,15 +152,22 @@ public:
|
||||||
|
|
||||||
/* Cost to clear/revenue when cleared */
|
/* Cost to clear/revenue when cleared */
|
||||||
StringID str = STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A;
|
StringID str = STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A;
|
||||||
if (CmdSucceeded(costclear)) {
|
Company *c = Company::GetIfValid(_local_company);
|
||||||
Money cost = costclear.GetCost();
|
if (c != NULL) {
|
||||||
if (cost < 0) {
|
Money old_money = c->money;
|
||||||
cost = -cost; // Negate negative cost to a positive revenue
|
c->money = INT64_MAX;
|
||||||
str = STR_REVENUE_WHEN_CLEARED;
|
CommandCost costclear = DoCommand(tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR);
|
||||||
} else {
|
c->money = old_money;
|
||||||
str = STR_LAND_AREA_INFORMATION_COST_TO_CLEAR;
|
if (CmdSucceeded(costclear)) {
|
||||||
|
Money cost = costclear.GetCost();
|
||||||
|
if (cost < 0) {
|
||||||
|
cost = -cost; // Negate negative cost to a positive revenue
|
||||||
|
str = STR_REVENUE_WHEN_CLEARED;
|
||||||
|
} else {
|
||||||
|
str = STR_LAND_AREA_INFORMATION_COST_TO_CLEAR;
|
||||||
|
}
|
||||||
|
SetDParam(0, cost);
|
||||||
}
|
}
|
||||||
SetDParam(0, cost);
|
|
||||||
}
|
}
|
||||||
GetString(this->landinfo_data[line_nr], str, lastof(this->landinfo_data[line_nr]));
|
GetString(this->landinfo_data[line_nr], str, lastof(this->landinfo_data[line_nr]));
|
||||||
line_nr++;
|
line_nr++;
|
||||||
|
|
Loading…
Reference in New Issue