diff options
-rw-r--r-- | src/ai/default/default.cpp | 2 | ||||
-rw-r--r-- | src/ai/trolly/trolly.cpp | 2 | ||||
-rw-r--r-- | src/company_base.h | 2 | ||||
-rw-r--r-- | src/company_cmd.cpp | 2 | ||||
-rw-r--r-- | src/company_gui.cpp | 10 | ||||
-rw-r--r-- | src/oldloader.cpp | 4 | ||||
-rw-r--r-- | src/openttd.cpp | 12 | ||||
-rw-r--r-- | src/unmovable_cmd.cpp | 6 |
8 files changed, 23 insertions, 17 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp index 2dc322d4d..8cbbafdaa 100644 --- a/src/ai/default/default.cpp +++ b/src/ai/default/default.cpp @@ -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); diff --git a/src/ai/trolly/trolly.cpp b/src/ai/trolly/trolly.cpp index 17918b2ca..c761d8a87 100644 --- a/src/ai/trolly/trolly.cpp +++ b/src/ai/trolly/trolly.cpp @@ -106,7 +106,7 @@ static void AiNew_State_WakeUp(Company *c) { 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.. diff --git a/src/company_base.h b/src/company_base.h index b92db880b..ee93dd91a 100644 --- a/src/company_base.h +++ b/src/company_base.h @@ -56,7 +56,7 @@ struct Company : PoolItem<Company, CompanyByte, &_Company_pool> { 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]; diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index 6cba226c6..8dc65f4c9 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -53,7 +53,7 @@ HighScore _highscore_table[5][5]; // 4 difficulty-settings (+ network); top 5 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; } diff --git a/src/company_gui.cpp b/src/company_gui.cpp index ea3fb2267..0eb616911 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -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); diff --git a/src/oldloader.cpp b/src/oldloader.cpp index cb55afc50..2a02f069e 100644 --- a/src/oldloader.cpp +++ b/src/oldloader.cpp @@ -1015,13 +1015,11 @@ static bool LoadOldCompany(LoadgameState *ls, int num) * 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' diff --git a/src/openttd.cpp b/src/openttd.cpp index 6bb681788..ec2eeb209 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -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. */ diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp index e2efec469..71e514c2f 100644 --- a/src/unmovable_cmd.cpp +++ b/src/unmovable_cmd.cpp @@ -51,7 +51,7 @@ static CommandCost DestroyCompanyHQ(CompanyID cid, uint32 flags) 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 score) 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 tile, uint32 flags, uint32 p1, uint32 p2 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)); } |