Changeset - r10555:6bae964dabbf
[Not reviewed]
master
0 8 0
smatz - 15 years ago 2009-01-03 17:11:52
smatz@openttd.org
(svn r14812) -Codechange: use INVALID_TILE instead of 0 to mark company without HQ
8 files changed with 23 insertions and 17 deletions:
0 comments (0 inline, 0 general)
src/ai/default/default.cpp
Show inline comments
 
@@ -3956,7 +3956,7 @@ static void AiBuildCompanyHQ(Company *c)
 
{
 
	TileIndex tile;
 

	
 
	if (c->location_of_HQ == 0 &&
 
	if (c->location_of_HQ == INVALID_TILE &&
 
			c->last_build_coordinate != 0) {
 
		tile = AdjustTileCoordRandomly(c->last_build_coordinate, 8);
 
		DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_COMPANY_HQ);
src/ai/trolly/trolly.cpp
Show inline comments
 
@@ -106,7 +106,7 @@ static void AiNew_State_WakeUp(Company *
 
{
 
	assert(_companies_ainew[c->index].state == AI_STATE_WAKE_UP);
 
	// First, check if we have a HQ
 
	if (c->location_of_HQ == 0) {
 
	if (c->location_of_HQ == INVALID_TILE) {
 
		// We have no HQ yet, build one on a random place
 
		// Random till we found a place for it!
 
		// TODO: this should not be on a random place..
src/company_base.h
Show inline comments
 
@@ -56,7 +56,7 @@ struct Company : PoolItem<Company, Compa
 

	
 
	uint32 cargo_types; ///< which cargo types were transported the last year
 

	
 
	TileIndex location_of_HQ;
 
	TileIndex location_of_HQ; ///< northern tile of HQ ; INVALID_TILE when there is none
 
	TileIndex last_build_coordinate;
 

	
 
	OwnerByte share_owners[4];
src/company_cmd.cpp
Show inline comments
 
@@ -53,7 +53,7 @@ HighScore _highscore_table[5][5]; // 4 d
 

	
 
DEFINE_OLD_POOL_GENERIC(Company, Company)
 

	
 
Company::Company(uint16 name_1, bool is_ai) : name_1(name_1), is_ai(is_ai)
 
Company::Company(uint16 name_1, bool is_ai) : name_1(name_1), location_of_HQ(INVALID_TILE), is_ai(is_ai)
 
{
 
	for (uint j = 0; j < 4; j++) this->share_owners[j] = COMPANY_SPECTATOR;
 
}
src/company_gui.cpp
Show inline comments
 
@@ -1180,10 +1180,10 @@ struct CompanyWindow : Window
 
		this->SetWidgetHiddenState(CW_WIDGET_COLOR_SCHEME,   !local);
 
		this->SetWidgetHiddenState(CW_WIDGET_PRESIDENT_NAME, !local);
 
		this->SetWidgetHiddenState(CW_WIDGET_COMPANY_NAME,   !local);
 
		this->widget[CW_WIDGET_BUILD_VIEW_HQ].data = (local && c->location_of_HQ == 0) ? STR_706F_BUILD_HQ : STR_7072_VIEW_HQ;
 
		if (local && c->location_of_HQ != 0) this->widget[CW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; //HQ is already built.
 
		this->SetWidgetDisabledState(CW_WIDGET_BUILD_VIEW_HQ, !local && c->location_of_HQ == 0);
 
		this->SetWidgetHiddenState(CW_WIDGET_RELOCATE_HQ,      !local || c->location_of_HQ == 0);
 
		this->widget[CW_WIDGET_BUILD_VIEW_HQ].data = (local && c->location_of_HQ == INVALID_TILE) ? STR_706F_BUILD_HQ : STR_7072_VIEW_HQ;
 
		if (local && c->location_of_HQ != INVALID_TILE) this->widget[CW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; //HQ is already built.
 
		this->SetWidgetDisabledState(CW_WIDGET_BUILD_VIEW_HQ, !local && c->location_of_HQ == INVALID_TILE);
 
		this->SetWidgetHiddenState(CW_WIDGET_RELOCATE_HQ,      !local || c->location_of_HQ == INVALID_TILE);
 
		this->SetWidgetHiddenState(CW_WIDGET_BUY_SHARE,        local);
 
		this->SetWidgetHiddenState(CW_WIDGET_SELL_SHARE,       local);
 
		this->SetWidgetHiddenState(CW_WIDGET_COMPANY_PASSWORD, !local || !_networking);
 
@@ -1263,7 +1263,7 @@ struct CompanyWindow : Window
 

	
 
			case CW_WIDGET_BUILD_VIEW_HQ: {
 
				TileIndex tile = GetCompany((CompanyID)this->window_number)->location_of_HQ;
 
				if (tile == 0) {
 
				if (tile == INVALID_TILE) {
 
					if ((byte)this->window_number != _local_company) return;
 
					SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, this);
 
					SetTileSelectSize(2, 2);
src/oldloader.cpp
Show inline comments
 
@@ -1015,13 +1015,11 @@ static bool LoadOldCompany(LoadgameState
 
	 * was always 893288 pounds. In the newer versions this is correct,
 
	 * but correct for those oldies
 
	 * Ps: this also means that if you had exact 893288 pounds, you will go back
 
	 * to 10000.. this is a very VERY small chance ;) */
 
	 * to 100000.. this is a very VERY small chance ;) */
 
	if (c->money == 893288) c->money = c->current_loan = 100000;
 

	
 
	_company_colours[num] = c->colour;
 
	c->inaugurated_year -= ORIGINAL_BASE_YEAR;
 
	if (c->location_of_HQ == 0xFFFF)
 
		c->location_of_HQ = 0;
 

	
 
	/* State 20 for AI companies is sell vehicle. Since the AI struct is not
 
	 * really figured out as of now, _companies_ai[c->index].cur_veh; needed for 'sell vehicle'
src/openttd.cpp
Show inline comments
 
@@ -1446,14 +1446,22 @@ bool AfterLoadGame()
 
	/* From this point the old names array is cleared. */
 
	ResetOldNames();
 

	
 
	/* no station is determined by 'tile == INVALID_TILE' now (instead of '0') */
 
	if (CheckSavegameVersion(105)) {
 
	if (CheckSavegameVersion(106)) {
 
		/* no station is determined by 'tile == INVALID_TILE' now (instead of '0') */
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
			if (st->airport_tile == 0) st->airport_tile = INVALID_TILE;
 
			if (st->dock_tile    == 0) st->dock_tile    = INVALID_TILE;
 
			if (st->train_tile   == 0) st->train_tile   = INVALID_TILE;
 
		}
 

	
 
		/* the same applies to Company::location_of_HQ */
 
		Company *c;
 
		FOR_ALL_COMPANIES(c) {
 
			if (c->location_of_HQ == 0 || (CheckSavegameVersion(4) && c->location_of_HQ == 0xFFFF)) {
 
				c->location_of_HQ = INVALID_TILE;
 
			}
 
		}
 
	}
 

	
 
	/* convert road side to my format. */
src/unmovable_cmd.cpp
Show inline comments
 
@@ -51,7 +51,7 @@ static CommandCost DestroyCompanyHQ(Comp
 
		DoClearSquare(t + TileDiffXY(0, 1));
 
		DoClearSquare(t + TileDiffXY(1, 0));
 
		DoClearSquare(t + TileDiffXY(1, 1));
 
		c->location_of_HQ = 0; // reset HQ position
 
		c->location_of_HQ = INVALID_TILE; // reset HQ position
 
		InvalidateWindow(WC_COMPANY, cid);
 
	}
 

	
 
@@ -64,7 +64,7 @@ void UpdateCompanyHQ(Company *c, uint sc
 
	byte val;
 
	TileIndex tile = c->location_of_HQ;
 

	
 
	if (tile == 0) return;
 
	if (tile == INVALID_TILE) return;
 

	
 
	(val = 0, score < 170) ||
 
	(val++, score < 350) ||
 
@@ -96,7 +96,7 @@ CommandCost CmdBuildCompanyHQ(TileIndex 
 
	cost = CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL);
 
	if (CmdFailed(cost)) return cost;
 

	
 
	if (c->location_of_HQ != 0) { // Moving HQ
 
	if (c->location_of_HQ != INVALID_TILE) { // Moving HQ
 
		cost.AddCost(DestroyCompanyHQ(_current_company, flags));
 
	}
 

	
0 comments (0 inline, 0 general)