diff options
author | smatz <smatz@openttd.org> | 2009-05-19 19:26:03 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2009-05-19 19:26:03 +0000 |
commit | 00bc2659f24b07851291d56d170174ed27581bc7 (patch) | |
tree | af016b82c8193846ccdf7bdf533bc225dad60744 | |
parent | ec76117379c31454cc0724f05a97ce33c4f88f88 (diff) | |
download | openttd-00bc2659f24b07851291d56d170174ed27581bc7.tar.xz |
(svn r16359) -Codechange: don't abuse company 0 when determining 'cost to clear land' in the LandInfoWindow
-rw-r--r-- | src/misc_gui.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 94ca288f7..e373373a6 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -104,14 +104,8 @@ public: } 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); - 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 */ TileDesc td; AcceptedCargo ac; @@ -158,15 +152,22 @@ public: /* Cost to clear/revenue when cleared */ StringID str = STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A; - 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; + Company *c = Company::GetIfValid(_local_company); + if (c != NULL) { + Money old_money = c->money; + c->money = INT64_MAX; + CommandCost costclear = DoCommand(tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR); + c->money = old_money; + 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])); line_nr++; |