mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r14812) -Codechange: use INVALID_TILE instead of 0 to mark company without HQ
This commit is contained in:
parent
6512d717e1
commit
afef22e3e7
|
@ -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);
|
||||
|
|
|
@ -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..
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue