mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Remove Company/OwnerByte types
parent
fcf06ba4c4
commit
5b34c8019f
|
@ -52,7 +52,7 @@
|
||||||
}
|
}
|
||||||
config->AnchorUnchangeableSettings();
|
config->AnchorUnchangeableSettings();
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||||
Company *c = Company::Get(company);
|
Company *c = Company::Get(company);
|
||||||
|
|
||||||
c->ai_info = info;
|
c->ai_info = info;
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
assert(_settings_game.difficulty.competitor_speed <= 4);
|
assert(_settings_game.difficulty.competitor_speed <= 4);
|
||||||
if ((AI::frame_counter & ((1 << (4 - _settings_game.difficulty.competitor_speed)) - 1)) != 0) return;
|
if ((AI::frame_counter & ((1 << (4 - _settings_game.difficulty.competitor_speed)) - 1)) != 0) return;
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||||
const Company *c;
|
const Company *c;
|
||||||
FOR_ALL_COMPANIES(c) {
|
FOR_ALL_COMPANIES(c) {
|
||||||
if (c->is_ai) {
|
if (c->is_ai) {
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
if (_networking && !_network_server) return;
|
if (_networking && !_network_server) return;
|
||||||
PerformanceMeasurer::SetInactive((PerformanceElement)(PFE_AI0 + company));
|
PerformanceMeasurer::SetInactive((PerformanceElement)(PFE_AI0 + company));
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||||
Company *c = Company::Get(company);
|
Company *c = Company::Get(company);
|
||||||
|
|
||||||
delete c->ai_instance;
|
delete c->ai_instance;
|
||||||
|
@ -127,7 +127,7 @@
|
||||||
* for the server owner to unpause the script again. */
|
* for the server owner to unpause the script again. */
|
||||||
if (_network_dedicated) return;
|
if (_network_dedicated) return;
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||||
Company::Get(company)->ai_instance->Pause();
|
Company::Get(company)->ai_instance->Pause();
|
||||||
|
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
|
@ -135,7 +135,7 @@
|
||||||
|
|
||||||
/* static */ void AI::Unpause(CompanyID company)
|
/* static */ void AI::Unpause(CompanyID company)
|
||||||
{
|
{
|
||||||
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||||
Company::Get(company)->ai_instance->Unpause();
|
Company::Get(company)->ai_instance->Unpause();
|
||||||
|
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
|
@ -143,7 +143,7 @@
|
||||||
|
|
||||||
/* static */ bool AI::IsPaused(CompanyID company)
|
/* static */ bool AI::IsPaused(CompanyID company)
|
||||||
{
|
{
|
||||||
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||||
bool paused = Company::Get(company)->ai_instance->IsPaused();
|
bool paused = Company::Get(company)->ai_instance->IsPaused();
|
||||||
|
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
|
@ -253,7 +253,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Queue the event */
|
/* Queue the event */
|
||||||
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||||
Company::Get(_current_company)->ai_instance->InsertEvent(event);
|
Company::Get(_current_company)->ai_instance->InsertEvent(event);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@
|
||||||
Company *c = Company::GetIfValid(company);
|
Company *c = Company::GetIfValid(company);
|
||||||
assert(c != nullptr && c->ai_instance != nullptr);
|
assert(c != nullptr && c->ai_instance != nullptr);
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||||
c->ai_instance->Save();
|
c->ai_instance->Save();
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
} else {
|
} else {
|
||||||
|
@ -299,7 +299,7 @@
|
||||||
Company *c = Company::GetIfValid(company);
|
Company *c = Company::GetIfValid(company);
|
||||||
assert(c != nullptr && c->ai_instance != nullptr);
|
assert(c != nullptr && c->ai_instance != nullptr);
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||||
c->ai_instance->Load(version);
|
c->ai_instance->Load(version);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -810,7 +810,7 @@ struct AIConfigWindow : public Window {
|
||||||
if (_game_mode != GM_NORMAL) {
|
if (_game_mode != GM_NORMAL) {
|
||||||
return slot > 0 && slot <= GetGameSettings().difficulty.max_no_competitors;
|
return slot > 0 && slot <= GetGameSettings().difficulty.max_no_competitors;
|
||||||
}
|
}
|
||||||
if (Company::IsValidID(slot) || slot < 0) return false;
|
if (Company::IsValidID(slot)) return false;
|
||||||
|
|
||||||
int max_slot = GetGameSettings().difficulty.max_no_competitors;
|
int max_slot = GetGameSettings().difficulty.max_no_competitors;
|
||||||
for (CompanyID cid = COMPANY_FIRST; cid < (CompanyID)max_slot && cid < MAX_COMPANIES; cid++) {
|
for (CompanyID cid = COMPANY_FIRST; cid < (CompanyID)max_slot && cid < MAX_COMPANIES; cid++) {
|
||||||
|
|
|
@ -1233,7 +1233,7 @@ void HandleMissingAircraftOrders(Aircraft *v)
|
||||||
*/
|
*/
|
||||||
const Station *st = GetTargetAirportIfValid(v);
|
const Station *st = GetTargetAirportIfValid(v);
|
||||||
if (st == nullptr) {
|
if (st == nullptr) {
|
||||||
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, v->owner, FILE_LINE);
|
||||||
CommandCost ret = DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT);
|
CommandCost ret = DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
|
|
||||||
|
@ -1588,7 +1588,7 @@ static void AircraftEventHandler_HeliTakeOff(Aircraft *v, const AirportFTAClass
|
||||||
|
|
||||||
/* Send the helicopter to a hangar if needed for replacement */
|
/* Send the helicopter to a hangar if needed for replacement */
|
||||||
if (v->NeedsAutomaticServicing()) {
|
if (v->NeedsAutomaticServicing()) {
|
||||||
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, v->owner, FILE_LINE);
|
||||||
DoCommand(v->tile, v->index | DEPOT_SERVICE | DEPOT_LOCATE_HANGAR, 0, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT);
|
DoCommand(v->tile, v->index | DEPOT_SERVICE | DEPOT_LOCATE_HANGAR, 0, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
}
|
}
|
||||||
|
@ -1639,7 +1639,7 @@ static void AircraftEventHandler_Landing(Aircraft *v, const AirportFTAClass *apc
|
||||||
|
|
||||||
/* check if the aircraft needs to be replaced or renewed and send it to a hangar if needed */
|
/* check if the aircraft needs to be replaced or renewed and send it to a hangar if needed */
|
||||||
if (v->NeedsAutomaticServicing()) {
|
if (v->NeedsAutomaticServicing()) {
|
||||||
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, v->owner, FILE_LINE);
|
||||||
DoCommand(v->tile, v->index | DEPOT_SERVICE, 0, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT);
|
DoCommand(v->tile, v->index | DEPOT_SERVICE, 0, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
|
||||||
StringID string_id; ///< Default name (town area) of station
|
StringID string_id; ///< Default name (town area) of station
|
||||||
|
|
||||||
Town *town; ///< The town this station is associated with
|
Town *town; ///< The town this station is associated with
|
||||||
OwnerByte owner; ///< The owner of this station
|
Owner owner; ///< The owner of this station
|
||||||
StationFacility facilities; ///< The facilities that this station has
|
StationFacility facilities; ///< The facilities that this station has
|
||||||
|
|
||||||
uint8 num_specs; ///< Number of specs in the speclist
|
uint8 num_specs; ///< Number of specs in the speclist
|
||||||
|
|
|
@ -660,7 +660,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
|
||||||
return_dcpi(CMD_ERROR);
|
return_dcpi(CMD_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||||
if (exec_as_spectator) cur_company.Change(COMPANY_SPECTATOR);
|
if (exec_as_spectator) cur_company.Change(COMPANY_SPECTATOR);
|
||||||
|
|
||||||
bool test_and_exec_can_differ = (cmd_flags & CMD_NO_TEST) != 0;
|
bool test_and_exec_can_differ = (cmd_flags & CMD_NO_TEST) != 0;
|
||||||
|
|
|
@ -72,7 +72,7 @@ struct CompanyProperties {
|
||||||
TileIndex location_of_HQ; ///< Northern tile of HQ; #INVALID_TILE when there is none.
|
TileIndex location_of_HQ; ///< Northern tile of HQ; #INVALID_TILE when there is none.
|
||||||
TileIndex last_build_coordinate; ///< Coordinate of the last build thing by this company.
|
TileIndex last_build_coordinate; ///< Coordinate of the last build thing by this company.
|
||||||
|
|
||||||
OwnerByte share_owners[4]; ///< Owners of the 4 shares of the company. #INVALID_OWNER if nobody has bought them yet.
|
Owner share_owners[4]; ///< Owners of the 4 shares of the company. #INVALID_OWNER if nobody has bought them yet.
|
||||||
|
|
||||||
Year inaugurated_year; ///< Year of starting the company.
|
Year inaugurated_year; ///< Year of starting the company.
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,8 @@
|
||||||
|
|
||||||
void ClearEnginesHiddenFlagOfCompany(CompanyID cid);
|
void ClearEnginesHiddenFlagOfCompany(CompanyID cid);
|
||||||
|
|
||||||
CompanyByte _local_company; ///< Company controlled by the human player at this client. Can also be #COMPANY_SPECTATOR.
|
CompanyID _local_company; ///< Company controlled by the human player at this client. Can also be #COMPANY_SPECTATOR.
|
||||||
CompanyByte _current_company; ///< Company currently doing an action.
|
CompanyID _current_company; ///< Company currently doing an action.
|
||||||
Colours _company_colours[MAX_COMPANIES]; ///< NOSAVE: can be determined from company structs.
|
Colours _company_colours[MAX_COMPANIES]; ///< NOSAVE: can be determined from company structs.
|
||||||
CompanyManagerFace _company_manager_face; ///< for company manager face storage in openttd.cfg
|
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
|
uint _next_competitor_start; ///< the number of ticks before the next AI is started
|
||||||
|
|
|
@ -32,8 +32,8 @@ void SubtractMoneyFromCompanyFract(CompanyID company, CommandCost cost);
|
||||||
CommandCost CheckOwnership(Owner owner, TileIndex tile = 0);
|
CommandCost CheckOwnership(Owner owner, TileIndex tile = 0);
|
||||||
CommandCost CheckTileOwnership(TileIndex tile);
|
CommandCost CheckTileOwnership(TileIndex tile);
|
||||||
|
|
||||||
extern CompanyByte _local_company;
|
extern CompanyID _local_company;
|
||||||
extern CompanyByte _current_company;
|
extern CompanyID _current_company;
|
||||||
|
|
||||||
extern Colours _company_colours[MAX_COMPANIES];
|
extern Colours _company_colours[MAX_COMPANIES];
|
||||||
extern CompanyManagerFace _company_manager_face;
|
extern CompanyManagerFace _company_manager_face;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
/**
|
/**
|
||||||
* Enum for all companies/owners.
|
* Enum for all companies/owners.
|
||||||
*/
|
*/
|
||||||
enum Owner {
|
enum Owner : byte {
|
||||||
/* All companies below MAX_COMPANIES are playable
|
/* All companies below MAX_COMPANIES are playable
|
||||||
* companies, above, they are special, computer controlled 'companies' */
|
* companies, above, they are special, computer controlled 'companies' */
|
||||||
OWNER_BEGIN = 0x00, ///< First owner
|
OWNER_BEGIN = 0x00, ///< First owner
|
||||||
|
@ -45,10 +45,8 @@ static const uint MAX_HISTORY_QUARTERS = 24; ///< The maximum number
|
||||||
|
|
||||||
/** Define basic enum properties */
|
/** Define basic enum properties */
|
||||||
template <> struct EnumPropsT<Owner> : MakeEnumPropsT<Owner, byte, OWNER_BEGIN, OWNER_END, INVALID_OWNER> {};
|
template <> struct EnumPropsT<Owner> : MakeEnumPropsT<Owner, byte, OWNER_BEGIN, OWNER_END, INVALID_OWNER> {};
|
||||||
typedef TinyEnumT<Owner> OwnerByte;
|
|
||||||
|
|
||||||
typedef Owner CompanyID;
|
typedef Owner CompanyID;
|
||||||
typedef OwnerByte CompanyByte;
|
|
||||||
|
|
||||||
typedef uint16 CompanyMask;
|
typedef uint16 CompanyMask;
|
||||||
|
|
||||||
|
|
|
@ -858,8 +858,7 @@ DEF_CONSOLE_CMD(ConNetworkReconnect)
|
||||||
default:
|
default:
|
||||||
/* From a user pov 0 is a new company, internally it's different and all
|
/* From a user pov 0 is a new company, internally it's different and all
|
||||||
* companies are offset by one to ease up on users (eg companies 1-8 not 0-7) */
|
* companies are offset by one to ease up on users (eg companies 1-8 not 0-7) */
|
||||||
playas--;
|
if (playas < COMPANY_FIRST + 1 || playas > MAX_COMPANIES + 1) return false;
|
||||||
if (playas < COMPANY_FIRST || playas >= MAX_COMPANIES) return false;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ static void DisasterClearSquare(TileIndex tile)
|
||||||
switch (GetTileType(tile)) {
|
switch (GetTileType(tile)) {
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
if (Company::IsHumanID(GetTileOwner(tile)) && !IsRailDepot(tile)) {
|
if (Company::IsHumanID(GetTileOwner(tile)) && !IsRailDepot(tile)) {
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_WATER, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_WATER, FILE_LINE);
|
||||||
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ static void DisasterClearSquare(TileIndex tile)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_HOUSE: {
|
case MP_HOUSE: {
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||||
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -291,14 +291,14 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
|
||||||
/* We need to set _current_company to old_owner before we try to move
|
/* We need to set _current_company to old_owner before we try to move
|
||||||
* the client. This is needed as it needs to know whether "you" really
|
* the client. This is needed as it needs to know whether "you" really
|
||||||
* are the current local company. */
|
* are the current local company. */
|
||||||
Backup<CompanyByte> cur_company(_current_company, old_owner, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, old_owner, FILE_LINE);
|
||||||
/* In all cases, make spectators of clients connected to that company */
|
/* In all cases, make spectators of clients connected to that company */
|
||||||
if (_networking) NetworkClientsToSpectators(old_owner);
|
if (_networking) NetworkClientsToSpectators(old_owner);
|
||||||
if (old_owner == _local_company) {
|
if (old_owner == _local_company) {
|
||||||
/* Single player cheated to AI company.
|
/* Single player cheated to AI company.
|
||||||
* There are no spectators in single player, so we must pick some other company. */
|
* There are no spectators in single player, so we must pick some other company. */
|
||||||
assert(!_networking);
|
assert(!_networking);
|
||||||
Backup<CompanyByte> cur_company2(_current_company, FILE_LINE);
|
Backup<CompanyID> cur_company2(_current_company, FILE_LINE);
|
||||||
Company *c;
|
Company *c;
|
||||||
FOR_ALL_COMPANIES(c) {
|
FOR_ALL_COMPANIES(c) {
|
||||||
if (c->index != old_owner) {
|
if (c->index != old_owner) {
|
||||||
|
@ -332,7 +332,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sell all the shares that people have on this company */
|
/* Sell all the shares that people have on this company */
|
||||||
Backup<CompanyByte> cur_company2(_current_company, FILE_LINE);
|
Backup<CompanyID> cur_company2(_current_company, FILE_LINE);
|
||||||
c = Company::Get(old_owner);
|
c = Company::Get(old_owner);
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
cur_company2.Change(c->share_owners[i]);
|
cur_company2.Change(c->share_owners[i]);
|
||||||
|
@ -665,7 +665,7 @@ static void CompaniesGenStatistics()
|
||||||
CompanyCheckBankrupt(c);
|
CompanyCheckBankrupt(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||||
|
|
||||||
if (!_settings_game.economy.infrastructure_maintenance) {
|
if (!_settings_game.economy.infrastructure_maintenance) {
|
||||||
Station *st;
|
Station *st;
|
||||||
|
@ -835,7 +835,7 @@ static void CompaniesPayInterest()
|
||||||
{
|
{
|
||||||
const Company *c;
|
const Company *c;
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||||
FOR_ALL_COMPANIES(c) {
|
FOR_ALL_COMPANIES(c) {
|
||||||
cur_company.Change(c->index);
|
cur_company.Change(c->index);
|
||||||
|
|
||||||
|
@ -1191,7 +1191,7 @@ CargoPayment::~CargoPayment()
|
||||||
|
|
||||||
if (this->visual_profit == 0 && this->visual_transfer == 0) return;
|
if (this->visual_profit == 0 && this->visual_transfer == 0) return;
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, this->front->owner, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, this->front->owner, FILE_LINE);
|
||||||
|
|
||||||
SubtractMoneyFromCompany(CommandCost(this->front->GetExpenseType(true), -this->route_profit));
|
SubtractMoneyFromCompany(CommandCost(this->front->GetExpenseType(true), -this->route_profit));
|
||||||
this->front->profit_this_year += (this->visual_profit + this->visual_transfer) << 8;
|
this->front->profit_this_year += (this->visual_profit + this->visual_transfer) << 8;
|
||||||
|
@ -1478,7 +1478,7 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
|
||||||
Vehicle *v_start = v->GetFirstEnginePart();
|
Vehicle *v_start = v->GetFirstEnginePart();
|
||||||
if (!IterateVehicleParts(v_start, IsEmptyAction())) return;
|
if (!IterateVehicleParts(v_start, IsEmptyAction())) return;
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, v->owner, FILE_LINE);
|
||||||
|
|
||||||
CargoTypes refit_mask = v->GetEngine()->info.refit_mask;
|
CargoTypes refit_mask = v->GetEngine()->info.refit_mask;
|
||||||
|
|
||||||
|
@ -2042,7 +2042,7 @@ CommandCost CmdBuyShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
||||||
|
|
||||||
cost.AddCost(CalculateCompanyValue(c) >> 2);
|
cost.AddCost(CalculateCompanyValue(c) >> 2);
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
OwnerByte *b = c->share_owners;
|
Owner *b = c->share_owners;
|
||||||
|
|
||||||
while (*b != COMPANY_SPECTATOR) b++; // share owners is guaranteed to contain at least one COMPANY_SPECTATOR
|
while (*b != COMPANY_SPECTATOR) b++; // share owners is guaranteed to contain at least one COMPANY_SPECTATOR
|
||||||
*b = _current_company;
|
*b = _current_company;
|
||||||
|
@ -2089,7 +2089,7 @@ CommandCost CmdSellShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1
|
||||||
cost = -(cost - (cost >> 7));
|
cost = -(cost - (cost >> 7));
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
OwnerByte *b = c->share_owners;
|
Owner *b = c->share_owners;
|
||||||
while (*b != _current_company) b++; // share owners is guaranteed to contain company
|
while (*b != _current_company) b++; // share owners is guaranteed to contain company
|
||||||
*b = COMPANY_SPECTATOR;
|
*b = COMPANY_SPECTATOR;
|
||||||
InvalidateWindowData(WC_COMPANY, target_company);
|
InvalidateWindowData(WC_COMPANY, target_company);
|
||||||
|
|
|
@ -34,7 +34,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
|
||||||
uint16 duration_phase_3; ///< Third reliability phase on months, decaying to #reliability_final.
|
uint16 duration_phase_3; ///< Third reliability phase on months, decaying to #reliability_final.
|
||||||
byte flags; ///< Flags of the engine. @see EngineFlags
|
byte flags; ///< Flags of the engine. @see EngineFlags
|
||||||
CompanyMask preview_asked; ///< Bit for each company which has already been offered a preview.
|
CompanyMask preview_asked; ///< Bit for each company which has already been offered a preview.
|
||||||
CompanyByte preview_company;///< Company which is currently being offered a preview \c INVALID_COMPANY means no company.
|
CompanyID preview_company; ///< Company which is currently being offered a preview \c INVALID_COMPANY means no company.
|
||||||
byte preview_wait; ///< Daily countdown timer for timeout of offering the engine to the #preview_company company.
|
byte preview_wait; ///< Daily countdown timer for timeout of offering the engine to the #preview_company company.
|
||||||
CompanyMask company_avail; ///< Bit for each company whether the engine is available for that company.
|
CompanyMask company_avail; ///< Bit for each company whether the engine is available for that company.
|
||||||
CompanyMask company_hidden; ///< Bit for each company whether the engine is normally hidden in the build gui for that company.
|
CompanyMask company_hidden; ///< Bit for each company whether the engine is normally hidden in the build gui for that company.
|
||||||
|
@ -118,7 +118,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
|
||||||
* @param c Company to check.
|
* @param c Company to check.
|
||||||
* @return \c true iff the engine is hidden in the GUI for the given company.
|
* @return \c true iff the engine is hidden in the GUI for the given company.
|
||||||
*/
|
*/
|
||||||
inline bool IsHidden(CompanyByte c) const
|
inline bool IsHidden(CompanyID c) const
|
||||||
{
|
{
|
||||||
return c < MAX_COMPANIES && HasBit(this->company_hidden, c);
|
return c < MAX_COMPANIES && HasBit(this->company_hidden, c);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
Game::frame_counter++;
|
Game::frame_counter++;
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||||
cur_company.Change(OWNER_DEITY);
|
cur_company.Change(OWNER_DEITY);
|
||||||
Game::instance->GameLoop();
|
Game::instance->GameLoop();
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
|
|
||||||
config->AnchorUnchangeableSettings();
|
config->AnchorUnchangeableSettings();
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||||
cur_company.Change(OWNER_DEITY);
|
cur_company.Change(OWNER_DEITY);
|
||||||
|
|
||||||
Game::info = info;
|
Game::info = info;
|
||||||
|
@ -98,7 +98,7 @@
|
||||||
|
|
||||||
/* static */ void Game::Uninitialize(bool keepConfig)
|
/* static */ void Game::Uninitialize(bool keepConfig)
|
||||||
{
|
{
|
||||||
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||||
|
|
||||||
delete Game::instance;
|
delete Game::instance;
|
||||||
Game::instance = nullptr;
|
Game::instance = nullptr;
|
||||||
|
@ -158,7 +158,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Queue the event */
|
/* Queue the event */
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_DEITY, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_DEITY, FILE_LINE);
|
||||||
Game::instance->InsertEvent(event);
|
Game::instance->InsertEvent(event);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@
|
||||||
/* static */ void Game::Save()
|
/* static */ void Game::Save()
|
||||||
{
|
{
|
||||||
if (Game::instance != nullptr && (!_networking || _network_server)) {
|
if (Game::instance != nullptr && (!_networking || _network_server)) {
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_DEITY, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_DEITY, FILE_LINE);
|
||||||
Game::instance->Save();
|
Game::instance->Save();
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
} else {
|
} else {
|
||||||
|
@ -218,7 +218,7 @@
|
||||||
/* static */ void Game::Load(int version)
|
/* static */ void Game::Load(int version)
|
||||||
{
|
{
|
||||||
if (Game::instance != nullptr && (!_networking || _network_server)) {
|
if (Game::instance != nullptr && (!_networking || _network_server)) {
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_DEITY, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_DEITY, FILE_LINE);
|
||||||
Game::instance->Load(version);
|
Game::instance->Load(version);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -97,7 +97,7 @@ static void CleanupGeneration()
|
||||||
static void _GenerateWorld()
|
static void _GenerateWorld()
|
||||||
{
|
{
|
||||||
/* Make sure everything is done via OWNER_NONE. */
|
/* Make sure everything is done via OWNER_NONE. */
|
||||||
Backup<CompanyByte> _cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
Backup<CompanyID> _cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(_modal_progress_work_mutex, std::defer_lock);
|
std::unique_lock<std::mutex> lock(_modal_progress_work_mutex, std::defer_lock);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -79,7 +79,7 @@ CommandCost CmdCreateGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||||
|
|
||||||
case GT_STORY_PAGE: {
|
case GT_STORY_PAGE: {
|
||||||
if (!StoryPage::IsValidID(p2)) return CMD_ERROR;
|
if (!StoryPage::IsValidID(p2)) return CMD_ERROR;
|
||||||
CompanyByte story_company = StoryPage::Get(p2)->company;
|
CompanyID story_company = StoryPage::Get(p2)->company;
|
||||||
if (company == INVALID_COMPANY ? story_company != INVALID_COMPANY : story_company != INVALID_COMPANY && story_company != company) return CMD_ERROR;
|
if (company == INVALID_COMPANY ? story_company != INVALID_COMPANY : story_company != INVALID_COMPANY && story_company != company) return CMD_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,12 +21,12 @@ extern GoalPool _goal_pool;
|
||||||
|
|
||||||
/** Struct about goals, current and completed */
|
/** Struct about goals, current and completed */
|
||||||
struct Goal : GoalPool::PoolItem<&_goal_pool> {
|
struct Goal : GoalPool::PoolItem<&_goal_pool> {
|
||||||
CompanyByte company; ///< Goal is for a specific company; INVALID_COMPANY if it is global
|
CompanyID company; ///< Goal is for a specific company; INVALID_COMPANY if it is global
|
||||||
GoalTypeByte type; ///< Type of the goal
|
GoalTypeByte type; ///< Type of the goal
|
||||||
GoalTypeID dst; ///< Index of type
|
GoalTypeID dst; ///< Index of type
|
||||||
char *text; ///< Text of the goal.
|
char *text; ///< Text of the goal.
|
||||||
char *progress; ///< Progress text of the goal.
|
char *progress; ///< Progress text of the goal.
|
||||||
bool completed; ///< Is the goal completed or not?
|
bool completed; ///< Is the goal completed or not?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We need an (empty) constructor so struct isn't zeroed (as C++ standard states)
|
* We need an (empty) constructor so struct isn't zeroed (as C++ standard states)
|
||||||
|
|
|
@ -66,7 +66,7 @@ struct GroupStatistics {
|
||||||
/** Group data. */
|
/** Group data. */
|
||||||
struct Group : GroupPool::PoolItem<&_group_pool> {
|
struct Group : GroupPool::PoolItem<&_group_pool> {
|
||||||
char *name; ///< Group Name
|
char *name; ///< Group Name
|
||||||
OwnerByte owner; ///< Group Owner
|
Owner owner; ///< Group Owner
|
||||||
VehicleType vehicle_type; ///< Vehicle type of the group
|
VehicleType vehicle_type; ///< Vehicle type of the group
|
||||||
|
|
||||||
bool replace_protection; ///< If set to true, the global autoreplace have no effect on the group
|
bool replace_protection; ///< If set to true, the global autoreplace have no effect on the group
|
||||||
|
|
|
@ -57,7 +57,7 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> {
|
||||||
uint16 counter; ///< used for animation and/or production (if available cargo)
|
uint16 counter; ///< used for animation and/or production (if available cargo)
|
||||||
|
|
||||||
IndustryType type; ///< type of industry.
|
IndustryType type; ///< type of industry.
|
||||||
OwnerByte owner; ///< owner of the industry. Which SHOULD always be (imho) OWNER_NONE
|
Owner owner; ///< owner of the industry. Which SHOULD always be (imho) OWNER_NONE
|
||||||
byte random_colour; ///< randomized colour of the industry, for display purpose
|
byte random_colour; ///< randomized colour of the industry, for display purpose
|
||||||
Year last_prod_year; ///< last year of production
|
Year last_prod_year; ///< last year of production
|
||||||
byte was_cargo_delivered; ///< flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry
|
byte was_cargo_delivered; ///< flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry
|
||||||
|
@ -65,7 +65,7 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> {
|
||||||
PartOfSubsidyByte part_of_subsidy; ///< NOSAVE: is this industry a source/destination of a subsidy?
|
PartOfSubsidyByte part_of_subsidy; ///< NOSAVE: is this industry a source/destination of a subsidy?
|
||||||
StationList stations_near; ///< NOSAVE: List of nearby stations.
|
StationList stations_near; ///< NOSAVE: List of nearby stations.
|
||||||
|
|
||||||
OwnerByte founder; ///< Founder of the industry
|
Owner founder; ///< Founder of the industry
|
||||||
Date construction_date; ///< Date of the construction of the industry
|
Date construction_date; ///< Date of the construction of the industry
|
||||||
uint8 construction_type; ///< Way the industry was constructed (@see IndustryConstructionType)
|
uint8 construction_type; ///< Way the industry was constructed (@see IndustryConstructionType)
|
||||||
Date last_cargo_accepted_at[INDUSTRY_NUM_INPUTS]; ///< Last day each cargo type was accepted by this industry
|
Date last_cargo_accepted_at[INDUSTRY_NUM_INPUTS]; ///< Last day each cargo type was accepted by this industry
|
||||||
|
|
|
@ -1077,7 +1077,7 @@ static bool SearchLumberMillTrees(TileIndex tile, void *user_data)
|
||||||
if (IsTileType(tile, MP_TREES) && GetTreeGrowth(tile) > 2) { ///< 3 and up means all fully grown trees
|
if (IsTileType(tile, MP_TREES) && GetTreeGrowth(tile) > 2) { ///< 3 and up means all fully grown trees
|
||||||
/* found a tree */
|
/* found a tree */
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||||
|
|
||||||
_industry_sound_ctr = 1;
|
_industry_sound_ctr = 1;
|
||||||
_industry_sound_tile = tile;
|
_industry_sound_tile = tile;
|
||||||
|
@ -1436,7 +1436,7 @@ static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTil
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear the tiles as OWNER_TOWN to not affect town rating, and to not clear protected buildings */
|
/* Clear the tiles as OWNER_TOWN to not affect town rating, and to not clear protected buildings */
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
||||||
CommandCost ret = DoCommand(cur_tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR);
|
CommandCost ret = DoCommand(cur_tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
|
|
||||||
|
@ -1541,7 +1541,7 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, DoCommandFlag flags,
|
||||||
|
|
||||||
/* _current_company is OWNER_NONE for randomly generated industries and in editor, or the company who funded or prospected the industry.
|
/* _current_company is OWNER_NONE for randomly generated industries and in editor, or the company who funded or prospected the industry.
|
||||||
* Perform terraforming as OWNER_TOWN to disable autoslope and town ratings. */
|
* Perform terraforming as OWNER_TOWN to disable autoslope and town ratings. */
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
||||||
|
|
||||||
TILE_AREA_LOOP(tile_walk, ta) {
|
TILE_AREA_LOOP(tile_walk, ta) {
|
||||||
uint curh = TileHeight(tile_walk);
|
uint curh = TileHeight(tile_walk);
|
||||||
|
@ -1966,7 +1966,7 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
||||||
if (deity_prospect || (_game_mode != GM_EDITOR && _current_company != OWNER_DEITY && _settings_game.construction.raw_industry_construction == 2 && indspec->IsRawIndustry())) {
|
if (deity_prospect || (_game_mode != GM_EDITOR && _current_company != OWNER_DEITY && _settings_game.construction.raw_industry_construction == 2 && indspec->IsRawIndustry())) {
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
/* Prospected industries are build as OWNER_TOWN to not e.g. be build on owned land of the founder */
|
/* Prospected industries are build as OWNER_TOWN to not e.g. be build on owned land of the founder */
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
||||||
/* Prospecting has a chance to fail, however we cannot guarantee that something can
|
/* Prospecting has a chance to fail, however we cannot guarantee that something can
|
||||||
* be built on the map, so the chance gets lower when the map is fuller, but there
|
* be built on the map, so the chance gets lower when the map is fuller, but there
|
||||||
* is nothing we can really do about that. */
|
* is nothing we can really do about that. */
|
||||||
|
@ -2128,7 +2128,7 @@ static Industry *PlaceIndustry(IndustryType type, IndustryAvailabilityCallType c
|
||||||
*/
|
*/
|
||||||
static void PlaceInitialIndustry(IndustryType type, bool try_hard)
|
static void PlaceInitialIndustry(IndustryType type, bool try_hard)
|
||||||
{
|
{
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||||
|
|
||||||
IncreaseGeneratingWorldProgress(GWP_INDUSTRY);
|
IncreaseGeneratingWorldProgress(GWP_INDUSTRY);
|
||||||
PlaceIndustry(type, IACT_MAPGENERATION, try_hard);
|
PlaceIndustry(type, IACT_MAPGENERATION, try_hard);
|
||||||
|
@ -2760,7 +2760,7 @@ void IndustryDailyLoop()
|
||||||
return; // Nothing to do? get out
|
return; // Nothing to do? get out
|
||||||
}
|
}
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||||
|
|
||||||
/* perform the required industry changes for the day */
|
/* perform the required industry changes for the day */
|
||||||
|
|
||||||
|
@ -2788,7 +2788,7 @@ void IndustryDailyLoop()
|
||||||
|
|
||||||
void IndustryMonthlyLoop()
|
void IndustryMonthlyLoop()
|
||||||
{
|
{
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||||
|
|
||||||
_industry_builder.MonthlyLoop();
|
_industry_builder.MonthlyLoop();
|
||||||
|
|
||||||
|
|
|
@ -655,7 +655,7 @@ public:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||||
_generating_world = true;
|
_generating_world = true;
|
||||||
_ignore_restrictions = true;
|
_ignore_restrictions = true;
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@ CommandCost CmdChangeBankBalance(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
/* Change company bank balance of company. */
|
/* Change company bank balance of company. */
|
||||||
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||||
SubtractMoneyFromCompany(CommandCost(expenses_type, -delta));
|
SubtractMoneyFromCompany(CommandCost(expenses_type, -delta));
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
/* Add money to company */
|
/* Add money to company */
|
||||||
Backup<CompanyByte> cur_company(_current_company, dest_company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, dest_company, FILE_LINE);
|
||||||
SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, -amount.GetCost()));
|
SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, -amount.GetCost()));
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1232,7 +1232,7 @@ void NetworkClientRequestMove(CompanyID company_id, const char *pass)
|
||||||
*/
|
*/
|
||||||
void NetworkClientsToSpectators(CompanyID cid)
|
void NetworkClientsToSpectators(CompanyID cid)
|
||||||
{
|
{
|
||||||
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||||
/* If our company is changing owner, go to spectators */
|
/* If our company is changing owner, go to spectators */
|
||||||
if (cid == _local_company) SetLocalCompany(COMPANY_SPECTATOR);
|
if (cid == _local_company) SetLocalCompany(COMPANY_SPECTATOR);
|
||||||
|
|
||||||
|
|
|
@ -1377,7 +1377,7 @@ void StateGameLoop()
|
||||||
|
|
||||||
/* All these actions has to be done from OWNER_NONE
|
/* All these actions has to be done from OWNER_NONE
|
||||||
* for multiplayer compatibility */
|
* for multiplayer compatibility */
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||||
|
|
||||||
BasePersistentStorageArray::SwitchMode(PSM_ENTER_GAMELOOP);
|
BasePersistentStorageArray::SwitchMode(PSM_ENTER_GAMELOOP);
|
||||||
AnimateAnimatedTiles();
|
AnimateAnimatedTiles();
|
||||||
|
|
|
@ -764,7 +764,7 @@ bool FloodHalftile(TileIndex t)
|
||||||
|
|
||||||
TrackBits to_remove = lower_track & rail_bits;
|
TrackBits to_remove = lower_track & rail_bits;
|
||||||
if (to_remove != 0) {
|
if (to_remove != 0) {
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_WATER, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_WATER, FILE_LINE);
|
||||||
flooded = DoCommand(t, 0, FIND_FIRST_BIT(to_remove), DC_EXEC, CMD_REMOVE_SINGLE_RAIL).Succeeded();
|
flooded = DoCommand(t, 0, FIND_FIRST_BIT(to_remove), DC_EXEC, CMD_REMOVE_SINGLE_RAIL).Succeeded();
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
if (!flooded) return flooded; // not yet floodable
|
if (!flooded) return flooded; // not yet floodable
|
||||||
|
|
|
@ -1126,7 +1126,7 @@ static Trackdir FollowPreviousRoadVehicle(const RoadVehicle *v, const RoadVehicl
|
||||||
static bool CanBuildTramTrackOnTile(CompanyID c, TileIndex t, RoadBits r)
|
static bool CanBuildTramTrackOnTile(CompanyID c, TileIndex t, RoadBits r)
|
||||||
{
|
{
|
||||||
/* The 'current' company is not necessarily the owner of the vehicle. */
|
/* The 'current' company is not necessarily the owner of the vehicle. */
|
||||||
Backup<CompanyByte> cur_company(_current_company, c, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, c, FILE_LINE);
|
||||||
|
|
||||||
CommandCost ret = DoCommand(t, ROADTYPE_TRAM << 4 | r, 0, DC_NO_WATER, CMD_BUILD_ROAD);
|
CommandCost ret = DoCommand(t, ROADTYPE_TRAM << 4 | r, 0, DC_NO_WATER, CMD_BUILD_ROAD);
|
||||||
|
|
||||||
|
|
|
@ -1835,7 +1835,7 @@ bool AfterLoadGame()
|
||||||
if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) {
|
if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) {
|
||||||
Owner o = GetTileOwner(t);
|
Owner o = GetTileOwner(t);
|
||||||
if (o < MAX_COMPANIES && !Company::IsValidID(o)) {
|
if (o < MAX_COMPANIES && !Company::IsValidID(o)) {
|
||||||
Backup<CompanyByte> cur_company(_current_company, o, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, o, FILE_LINE);
|
||||||
ChangeTileOwner(t, o, INVALID_OWNER);
|
ChangeTileOwner(t, o, INVALID_OWNER);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ struct OldWaypoint {
|
||||||
uint8 localidx;
|
uint8 localidx;
|
||||||
uint32 grfid;
|
uint32 grfid;
|
||||||
const StationSpec *spec;
|
const StationSpec *spec;
|
||||||
OwnerByte owner;
|
Owner owner;
|
||||||
|
|
||||||
size_t new_index;
|
size_t new_index;
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
/* static */ int32 ScriptCargoMonitor::GetTownDeliveryAmount(ScriptCompany::CompanyID company, CargoID cargo, TownID town_id, bool keep_monitoring)
|
/* static */ int32 ScriptCargoMonitor::GetTownDeliveryAmount(ScriptCompany::CompanyID company, CargoID cargo, TownID town_id, bool keep_monitoring)
|
||||||
{
|
{
|
||||||
CompanyID cid = static_cast<CompanyID>(company);
|
CompanyID cid = static_cast<CompanyID>(company);
|
||||||
if (cid < OWNER_BEGIN || cid >= MAX_COMPANIES) return -1;
|
if (cid >= MAX_COMPANIES) return -1;
|
||||||
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
||||||
if (!::Town::IsValidID(town_id)) return -1;
|
if (!::Town::IsValidID(town_id)) return -1;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
/* static */ int32 ScriptCargoMonitor::GetIndustryDeliveryAmount(ScriptCompany::CompanyID company, CargoID cargo, IndustryID industry_id, bool keep_monitoring)
|
/* static */ int32 ScriptCargoMonitor::GetIndustryDeliveryAmount(ScriptCompany::CompanyID company, CargoID cargo, IndustryID industry_id, bool keep_monitoring)
|
||||||
{
|
{
|
||||||
CompanyID cid = static_cast<CompanyID>(company);
|
CompanyID cid = static_cast<CompanyID>(company);
|
||||||
if (cid < OWNER_BEGIN || cid >= MAX_COMPANIES) return -1;
|
if (cid >= MAX_COMPANIES) return -1;
|
||||||
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
||||||
if (!::Industry::IsValidID(industry_id)) return -1;
|
if (!::Industry::IsValidID(industry_id)) return -1;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
/* static */ int32 ScriptCargoMonitor::GetTownPickupAmount(ScriptCompany::CompanyID company, CargoID cargo, TownID town_id, bool keep_monitoring)
|
/* static */ int32 ScriptCargoMonitor::GetTownPickupAmount(ScriptCompany::CompanyID company, CargoID cargo, TownID town_id, bool keep_monitoring)
|
||||||
{
|
{
|
||||||
CompanyID cid = static_cast<CompanyID>(company);
|
CompanyID cid = static_cast<CompanyID>(company);
|
||||||
if (cid < OWNER_BEGIN || cid >= MAX_COMPANIES) return -1;
|
if (cid >= MAX_COMPANIES) return -1;
|
||||||
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
||||||
if (!::Town::IsValidID(town_id)) return -1;
|
if (!::Town::IsValidID(town_id)) return -1;
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
/* static */ int32 ScriptCargoMonitor::GetIndustryPickupAmount(ScriptCompany::CompanyID company, CargoID cargo, IndustryID industry_id, bool keep_monitoring)
|
/* static */ int32 ScriptCargoMonitor::GetIndustryPickupAmount(ScriptCompany::CompanyID company, CargoID cargo, IndustryID industry_id, bool keep_monitoring)
|
||||||
{
|
{
|
||||||
CompanyID cid = static_cast<CompanyID>(company);
|
CompanyID cid = static_cast<CompanyID>(company);
|
||||||
if (cid < OWNER_BEGIN || cid >= MAX_COMPANIES) return -1;
|
if (cid >= MAX_COMPANIES) return -1;
|
||||||
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
||||||
if (!::Industry::IsValidID(industry_id)) return -1;
|
if (!::Industry::IsValidID(industry_id)) return -1;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ struct Sign : SignPool::PoolItem<&_sign_pool> {
|
||||||
int32 x;
|
int32 x;
|
||||||
int32 y;
|
int32 y;
|
||||||
int32 z;
|
int32 z;
|
||||||
OwnerByte owner; // placed by this company. Anyone can delete them though. OWNER_NONE for gray signs from old games.
|
Owner owner; // placed by this company. Anyone can delete them though. OWNER_NONE for gray signs from old games.
|
||||||
|
|
||||||
Sign(Owner owner = INVALID_OWNER);
|
Sign(Owner owner = INVALID_OWNER);
|
||||||
~Sign();
|
~Sign();
|
||||||
|
|
|
@ -69,7 +69,7 @@ struct StoryPageElement : StoryPageElementPool::PoolItem<&_story_page_element_po
|
||||||
struct StoryPage : StoryPagePool::PoolItem<&_story_page_pool> {
|
struct StoryPage : StoryPagePool::PoolItem<&_story_page_pool> {
|
||||||
uint32 sort_value; ///< A number that increases for every created story page. Used for sorting. The id of a story page is the pool index.
|
uint32 sort_value; ///< A number that increases for every created story page. Used for sorting. The id of a story page is the pool index.
|
||||||
Date date; ///< Date when the page was created.
|
Date date; ///< Date when the page was created.
|
||||||
CompanyByte company; ///< StoryPage is for a specific company; INVALID_COMPANY if it is global
|
CompanyID company; ///< StoryPage is for a specific company; INVALID_COMPANY if it is global
|
||||||
|
|
||||||
char *title; ///< Title of story page
|
char *title; ///< Title of story page
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ extern SubsidyPool _subsidy_pool;
|
||||||
struct Subsidy : SubsidyPool::PoolItem<&_subsidy_pool> {
|
struct Subsidy : SubsidyPool::PoolItem<&_subsidy_pool> {
|
||||||
CargoID cargo_type; ///< Cargo type involved in this subsidy, CT_INVALID for invalid subsidy
|
CargoID cargo_type; ///< Cargo type involved in this subsidy, CT_INVALID for invalid subsidy
|
||||||
byte remaining; ///< Remaining months when this subsidy is valid
|
byte remaining; ///< Remaining months when this subsidy is valid
|
||||||
CompanyByte awarded; ///< Subsidy is awarded to this company; INVALID_COMPANY if it's not awarded to anyone
|
CompanyID awarded; ///< Subsidy is awarded to this company; INVALID_COMPANY if it's not awarded to anyone
|
||||||
SourceTypeByte src_type; ///< Source of subsidised path (ST_INDUSTRY or ST_TOWN)
|
SourceTypeByte src_type; ///< Source of subsidised path (ST_INDUSTRY or ST_TOWN)
|
||||||
SourceTypeByte dst_type; ///< Destination of subsidised path (ST_INDUSTRY or ST_TOWN)
|
SourceTypeByte dst_type; ///< Destination of subsidised path (ST_INDUSTRY or ST_TOWN)
|
||||||
SourceID src; ///< Index of source. Either TownID or IndustryID
|
SourceID src; ///< Index of source. Either TownID or IndustryID
|
||||||
|
|
|
@ -72,7 +72,7 @@ struct Town : TownPool::PoolItem<&_town_pool> {
|
||||||
/* Company ratings. */
|
/* Company ratings. */
|
||||||
CompanyMask have_ratings; ///< which companies have a rating
|
CompanyMask have_ratings; ///< which companies have a rating
|
||||||
uint8 unwanted[MAX_COMPANIES]; ///< how many months companies aren't wanted by towns (bribe)
|
uint8 unwanted[MAX_COMPANIES]; ///< how many months companies aren't wanted by towns (bribe)
|
||||||
CompanyByte exclusivity; ///< which company has exclusivity
|
CompanyID exclusivity; ///< which company has exclusivity
|
||||||
uint8 exclusive_counter; ///< months till the exclusivity expires
|
uint8 exclusive_counter; ///< months till the exclusivity expires
|
||||||
int16 ratings[MAX_COMPANIES]; ///< ratings of each company for this town
|
int16 ratings[MAX_COMPANIES]; ///< ratings of each company for this town
|
||||||
|
|
||||||
|
|
|
@ -599,7 +599,7 @@ static void TileLoop_Town(TileIndex tile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
||||||
|
|
||||||
if ((hs->building_flags & BUILDING_HAS_1_TILE) &&
|
if ((hs->building_flags & BUILDING_HAS_1_TILE) &&
|
||||||
HasBit(t->flags, TOWN_IS_GROWING) &&
|
HasBit(t->flags, TOWN_IS_GROWING) &&
|
||||||
|
@ -1566,7 +1566,7 @@ static bool GrowTown(Town *t)
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Current "company" is a town */
|
/* Current "company" is a town */
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
||||||
|
|
||||||
TileIndex tile = t->xy; // The tile we are working with ATM
|
TileIndex tile = t->xy; // The tile we are working with ATM
|
||||||
|
|
||||||
|
@ -2042,7 +2042,7 @@ static Town *CreateRandomTown(uint attempts, uint32 townnameparts, TownSize size
|
||||||
* placement is so bad it couldn't grow at all */
|
* placement is so bad it couldn't grow at all */
|
||||||
if (t->cache.population > 0) return t;
|
if (t->cache.population > 0) return t;
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
||||||
CommandCost rc = DoCommand(t->xy, t->index, 0, DC_EXEC, CMD_DELETE_TOWN);
|
CommandCost rc = DoCommand(t->xy, t->index, 0, DC_EXEC, CMD_DELETE_TOWN);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
assert(rc.Succeeded());
|
assert(rc.Succeeded());
|
||||||
|
@ -2940,7 +2940,7 @@ static CommandCost TownActionRoadRebuild(Town *t, DoCommandFlag flags)
|
||||||
*/
|
*/
|
||||||
static bool TryClearTile(TileIndex tile)
|
static bool TryClearTile(TileIndex tile)
|
||||||
{
|
{
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||||
CommandCost r = DoCommand(tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR);
|
CommandCost r = DoCommand(tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
return r.Succeeded();
|
return r.Succeeded();
|
||||||
|
@ -3012,7 +3012,7 @@ static CommandCost TownActionBuildStatue(Town *t, DoCommandFlag flags)
|
||||||
if (!CircularTileSearch(&tile, 9, SearchTileForStatue, &statue_data)) return_cmd_error(STR_ERROR_STATUE_NO_SUITABLE_PLACE);
|
if (!CircularTileSearch(&tile, 9, SearchTileForStatue, &statue_data)) return_cmd_error(STR_ERROR_STATUE_NO_SUITABLE_PLACE);
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||||
DoCommand(statue_data.best_position, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
DoCommand(statue_data.best_position, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
BuildObject(OBJECT_STATUE, statue_data.best_position, _current_company, t);
|
BuildObject(OBJECT_STATUE, statue_data.best_position, _current_company, t);
|
||||||
|
|
|
@ -1027,7 +1027,7 @@ void CallVehicleTicks()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||||
for (auto &it : _vehicles_to_autoreplace) {
|
for (auto &it : _vehicles_to_autoreplace) {
|
||||||
v = it.first;
|
v = it.first;
|
||||||
/* Autoreplace needs the current company set as the vehicle owner */
|
/* Autoreplace needs the current company set as the vehicle owner */
|
||||||
|
@ -1514,7 +1514,7 @@ void VehicleEnterDepot(Vehicle *v)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v->current_order.IsRefit()) {
|
if (v->current_order.IsRefit()) {
|
||||||
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, v->owner, FILE_LINE);
|
||||||
CommandCost cost = DoCommand(v->tile, v->index, v->current_order.GetRefitCargo() | 0xFF << 8, DC_EXEC, GetCmdRefitVeh(v));
|
CommandCost cost = DoCommand(v->tile, v->index, v->current_order.GetRefitCargo() | 0xFF << 8, DC_EXEC, GetCmdRefitVeh(v));
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
|
|
||||||
|
|
|
@ -270,7 +270,7 @@ public:
|
||||||
int32 z_pos; ///< z coordinate.
|
int32 z_pos; ///< z coordinate.
|
||||||
Direction direction; ///< facing
|
Direction direction; ///< facing
|
||||||
|
|
||||||
OwnerByte owner; ///< Which company owns the vehicle?
|
Owner owner; ///< Which company owns the vehicle?
|
||||||
/**
|
/**
|
||||||
* currently displayed sprite index
|
* currently displayed sprite index
|
||||||
* 0xfd == custom sprite, 0xfe == custom second head sprite
|
* 0xfd == custom sprite, 0xfe == custom second head sprite
|
||||||
|
|
|
@ -1044,7 +1044,7 @@ void DoFloodTile(TileIndex target)
|
||||||
|
|
||||||
bool flooded = false; // Will be set to true if something is changed.
|
bool flooded = false; // Will be set to true if something is changed.
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_WATER, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_WATER, FILE_LINE);
|
||||||
|
|
||||||
Slope tileh = GetTileSlope(target);
|
Slope tileh = GetTileSlope(target);
|
||||||
if (tileh != SLOPE_FLAT) {
|
if (tileh != SLOPE_FLAT) {
|
||||||
|
@ -1105,7 +1105,7 @@ void DoFloodTile(TileIndex target)
|
||||||
*/
|
*/
|
||||||
static void DoDryUp(TileIndex tile)
|
static void DoDryUp(TileIndex tile)
|
||||||
{
|
{
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_WATER, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, OWNER_WATER, FILE_LINE);
|
||||||
|
|
||||||
switch (GetTileType(tile)) {
|
switch (GetTileType(tile)) {
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
|
|
Loading…
Reference in New Issue