Changeset - r11950:a7f580bd0289
[Not reviewed]
master
0 1 0
smatz - 15 years ago 2009-05-19 19:26:03
smatz@openttd.org
(svn r16359) -Codechange: don't abuse company 0 when determining 'cost to clear land' in the LandInfoWindow
1 file changed with 7 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/misc_gui.cpp
Show inline comments
 
@@ -101,20 +101,14 @@ public:
 
			SetDParamStr(0, this->landinfo_data[LAND_INFO_MULTICENTER_LINE]);
 
			DrawStringMultiLine(this->widget[LIW_BACKGROUND].left + 2, this->widget[LIW_BACKGROUND].right - 2, y, y + 22, STR_JUST_RAW_STRING, TC_FROMSTRING, SA_CENTER);
 
		}
 
	}
 

	
 
	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;
 

	
 
		td.build_date = INVALID_DATE;
 

	
 
@@ -155,22 +149,29 @@ public:
 
			GetString(this->landinfo_data[line_nr], td.owner_type[i], lastof(this->landinfo_data[line_nr]));
 
			line_nr++;
 
		}
 

	
 
		/* Cost to clear/revenue when cleared */
 
		StringID str = STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A;
 
		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);
 
		}
 
		}
 
		GetString(this->landinfo_data[line_nr], str, lastof(this->landinfo_data[line_nr]));
 
		line_nr++;
 

	
 
		/* Location */
 
		char tmp[16];
 
		snprintf(tmp, lengthof(tmp), "0x%.4X", tile);
0 comments (0 inline, 0 general)