On load, use previous local company or first usable company
Instead of always using the first company slot
This commit is contained in:
@@ -44,6 +44,7 @@ void ClearEnginesHiddenFlagOfCompany(CompanyID cid);
|
||||
|
||||
CompanyID _local_company; ///< Company controlled by the human player at this client. Can also be #COMPANY_SPECTATOR.
|
||||
CompanyID _current_company; ///< Company currently doing an action.
|
||||
CompanyID _loaded_local_company; ///< Local company in loaded savegame
|
||||
Colours _company_colours[MAX_COMPANIES]; ///< NOSAVE: can be determined from company structs.
|
||||
CompanyManagerFace _company_manager_face; ///< for company manager face storage in openttd.cfg
|
||||
uint _next_competitor_start; ///< the number of ticks before the next AI is started
|
||||
@@ -1184,6 +1185,20 @@ int CompanyServiceInterval(const Company *c, VehicleType type)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default local company after loading a new game
|
||||
*/
|
||||
CompanyID GetDefaultLocalCompany()
|
||||
{
|
||||
if (_loaded_local_company >= COMPANY_FIRST && _loaded_local_company < MAX_COMPANIES && Company::IsValidID(_loaded_local_company)) {
|
||||
return _loaded_local_company;
|
||||
}
|
||||
for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
|
||||
if (Company::IsValidID(i)) return i;
|
||||
}
|
||||
return COMPANY_FIRST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get total sum of all owned road bits.
|
||||
* @return Combined total road road bits.
|
||||
|
Reference in New Issue
Block a user