summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Pigott <charlespigott@googlemail.com>2019-04-22 09:10:04 +0100
committerPeterN <peter@fuzzle.org>2019-04-29 17:40:22 +0100
commit5b34c8019f135afd9f20d043a489ab96f286038a (patch)
tree84b38701d78f2348ad1e54c5cb379fc15bdcfe67 /src
parentfcf06ba4c43bb9b7ac0b8541377a5240b3e01126 (diff)
downloadopenttd-5b34c8019f135afd9f20d043a489ab96f286038a.tar.xz
Codechange: Remove Company/OwnerByte types
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_core.cpp18
-rw-r--r--src/ai/ai_gui.cpp2
-rw-r--r--src/aircraft_cmd.cpp6
-rw-r--r--src/base_station_base.h2
-rw-r--r--src/command.cpp2
-rw-r--r--src/company_base.h2
-rw-r--r--src/company_cmd.cpp4
-rw-r--r--src/company_func.h4
-rw-r--r--src/company_type.h4
-rw-r--r--src/console_cmds.cpp3
-rw-r--r--src/disaster_vehicle.cpp4
-rw-r--r--src/economy.cpp18
-rw-r--r--src/engine_base.h4
-rw-r--r--src/game/game_core.cpp12
-rw-r--r--src/genworld.cpp2
-rw-r--r--src/goal.cpp2
-rw-r--r--src/goal_base.h12
-rw-r--r--src/group.h2
-rw-r--r--src/industry.h4
-rw-r--r--src/industry_cmd.cpp14
-rw-r--r--src/industry_gui.cpp2
-rw-r--r--src/misc_cmd.cpp4
-rw-r--r--src/network/network_client.cpp2
-rw-r--r--src/openttd.cpp2
-rw-r--r--src/rail_cmd.cpp2
-rw-r--r--src/roadveh_cmd.cpp2
-rw-r--r--src/saveload/afterload.cpp2
-rw-r--r--src/saveload/waypoint_sl.cpp2
-rw-r--r--src/script/api/script_cargomonitor.cpp8
-rw-r--r--src/signs_base.h2
-rw-r--r--src/story_base.h2
-rw-r--r--src/subsidy_base.h2
-rw-r--r--src/town.h2
-rw-r--r--src/town_cmd.cpp10
-rw-r--r--src/vehicle.cpp4
-rw-r--r--src/vehicle_base.h2
-rw-r--r--src/water_cmd.cpp4
37 files changed, 86 insertions, 89 deletions
diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp
index cc2eb42c8..23ee16c83 100644
--- a/src/ai/ai_core.cpp
+++ b/src/ai/ai_core.cpp
@@ -52,7 +52,7 @@
}
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);
c->ai_info = info;
@@ -76,7 +76,7 @@
assert(_settings_game.difficulty.competitor_speed <= 4);
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;
FOR_ALL_COMPANIES(c) {
if (c->is_ai) {
@@ -107,7 +107,7 @@
if (_networking && !_network_server) return;
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);
delete c->ai_instance;
@@ -127,7 +127,7 @@
* for the server owner to unpause the script again. */
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();
cur_company.Restore();
@@ -135,7 +135,7 @@
/* 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();
cur_company.Restore();
@@ -143,7 +143,7 @@
/* 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();
cur_company.Restore();
@@ -253,7 +253,7 @@
}
/* 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);
cur_company.Restore();
@@ -285,7 +285,7 @@
Company *c = Company::GetIfValid(company);
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();
cur_company.Restore();
} else {
@@ -299,7 +299,7 @@
Company *c = Company::GetIfValid(company);
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);
cur_company.Restore();
} else {
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index 4932c0f61..91f896904 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -810,7 +810,7 @@ struct AIConfigWindow : public Window {
if (_game_mode != GM_NORMAL) {
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;
for (CompanyID cid = COMPANY_FIRST; cid < (CompanyID)max_slot && cid < MAX_COMPANIES; cid++) {
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 409daf789..5cb350404 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -1233,7 +1233,7 @@ void HandleMissingAircraftOrders(Aircraft *v)
*/
const Station *st = GetTargetAirportIfValid(v);
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);
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 */
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);
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 */
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);
cur_company.Restore();
}
diff --git a/src/base_station_base.h b/src/base_station_base.h
index 70164b193..eaeb246ef 100644
--- a/src/base_station_base.h
+++ b/src/base_station_base.h
@@ -60,7 +60,7 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
StringID string_id; ///< Default name (town area) of station
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
uint8 num_specs; ///< Number of specs in the speclist
diff --git a/src/command.cpp b/src/command.cpp
index 7f5dd4309..8a92c3478 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -660,7 +660,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
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);
bool test_and_exec_can_differ = (cmd_flags & CMD_NO_TEST) != 0;
diff --git a/src/company_base.h b/src/company_base.h
index 309130f59..27ae96fce 100644
--- a/src/company_base.h
+++ b/src/company_base.h
@@ -72,7 +72,7 @@ struct CompanyProperties {
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.
- 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.
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index 3cf55cf1e..fe4163acd 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -43,8 +43,8 @@
void ClearEnginesHiddenFlagOfCompany(CompanyID cid);
-CompanyByte _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 _local_company; ///< Company controlled by the human player at this client. Can also be #COMPANY_SPECTATOR.
+CompanyID _current_company; ///< Company currently doing an action.
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
diff --git a/src/company_func.h b/src/company_func.h
index 29650d78c..99041b6d4 100644
--- a/src/company_func.h
+++ b/src/company_func.h
@@ -32,8 +32,8 @@ void SubtractMoneyFromCompanyFract(CompanyID company, CommandCost cost);
CommandCost CheckOwnership(Owner owner, TileIndex tile = 0);
CommandCost CheckTileOwnership(TileIndex tile);
-extern CompanyByte _local_company;
-extern CompanyByte _current_company;
+extern CompanyID _local_company;
+extern CompanyID _current_company;
extern Colours _company_colours[MAX_COMPANIES];
extern CompanyManagerFace _company_manager_face;
diff --git a/src/company_type.h b/src/company_type.h
index 771e6d8b9..576a57bf1 100644
--- a/src/company_type.h
+++ b/src/company_type.h
@@ -17,7 +17,7 @@
/**
* Enum for all companies/owners.
*/
-enum Owner {
+enum Owner : byte {
/* All companies below MAX_COMPANIES are playable
* companies, above, they are special, computer controlled 'companies' */
OWNER_BEGIN = 0x00, ///< First owner
@@ -45,10 +45,8 @@ static const uint MAX_HISTORY_QUARTERS = 24; ///< The maximum number
/** Define basic enum properties */
template <> struct EnumPropsT<Owner> : MakeEnumPropsT<Owner, byte, OWNER_BEGIN, OWNER_END, INVALID_OWNER> {};
-typedef TinyEnumT<Owner> OwnerByte;
typedef Owner CompanyID;
-typedef OwnerByte CompanyByte;
typedef uint16 CompanyMask;
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 2b74f1d00..740bbdde8 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -858,8 +858,7 @@ DEF_CONSOLE_CMD(ConNetworkReconnect)
default:
/* 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) */
- playas--;
- if (playas < COMPANY_FIRST || playas >= MAX_COMPANIES) return false;
+ if (playas < COMPANY_FIRST + 1 || playas > MAX_COMPANIES + 1) return false;
break;
}
diff --git a/src/disaster_vehicle.cpp b/src/disaster_vehicle.cpp
index f934ca3e6..57ca0e9f8 100644
--- a/src/disaster_vehicle.cpp
+++ b/src/disaster_vehicle.cpp
@@ -62,7 +62,7 @@ static void DisasterClearSquare(TileIndex tile)
switch (GetTileType(tile)) {
case MP_RAILWAY:
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);
cur_company.Restore();
@@ -72,7 +72,7 @@ static void DisasterClearSquare(TileIndex tile)
break;
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);
cur_company.Restore();
break;
diff --git a/src/economy.cpp b/src/economy.cpp
index b4b298836..ad48ce25e 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -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
* the client. This is needed as it needs to know whether "you" really
* 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 */
if (_networking) NetworkClientsToSpectators(old_owner);
if (old_owner == _local_company) {
/* Single player cheated to AI company.
* There are no spectators in single player, so we must pick some other company. */
assert(!_networking);
- Backup<CompanyByte> cur_company2(_current_company, FILE_LINE);
+ Backup<CompanyID> cur_company2(_current_company, FILE_LINE);
Company *c;
FOR_ALL_COMPANIES(c) {
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 */
- Backup<CompanyByte> cur_company2(_current_company, FILE_LINE);
+ Backup<CompanyID> cur_company2(_current_company, FILE_LINE);
c = Company::Get(old_owner);
for (i = 0; i < 4; i++) {
cur_company2.Change(c->share_owners[i]);
@@ -665,7 +665,7 @@ static void CompaniesGenStatistics()
CompanyCheckBankrupt(c);
}
- Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
+ Backup<CompanyID> cur_company(_current_company, FILE_LINE);
if (!_settings_game.economy.infrastructure_maintenance) {
Station *st;
@@ -835,7 +835,7 @@ static void CompaniesPayInterest()
{
const Company *c;
- Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
+ Backup<CompanyID> cur_company(_current_company, FILE_LINE);
FOR_ALL_COMPANIES(c) {
cur_company.Change(c->index);
@@ -1191,7 +1191,7 @@ CargoPayment::~CargoPayment()
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));
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();
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;
@@ -2042,7 +2042,7 @@ CommandCost CmdBuyShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1,
cost.AddCost(CalculateCompanyValue(c) >> 2);
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
*b = _current_company;
@@ -2089,7 +2089,7 @@ CommandCost CmdSellShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1
cost = -(cost - (cost >> 7));
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
*b = COMPANY_SPECTATOR;
InvalidateWindowData(WC_COMPANY, target_company);
diff --git a/src/engine_base.h b/src/engine_base.h
index 32c5c9bf6..a8dbb873c 100644
--- a/src/engine_base.h
+++ b/src/engine_base.h
@@ -34,7 +34,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
uint16 duration_phase_3; ///< Third reliability phase on months, decaying to #reliability_final.
byte flags; ///< Flags of the engine. @see EngineFlags
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.
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.
@@ -118,7 +118,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
* @param c Company to check.
* @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);
}
diff --git a/src/game/game_core.cpp b/src/game/game_core.cpp
index 181e8b6bb..394b77fb8 100644
--- a/src/game/game_core.cpp
+++ b/src/game/game_core.cpp
@@ -45,7 +45,7 @@
Game::frame_counter++;
- Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
+ Backup<CompanyID> cur_company(_current_company, FILE_LINE);
cur_company.Change(OWNER_DEITY);
Game::instance->GameLoop();
cur_company.Restore();
@@ -84,7 +84,7 @@
config->AnchorUnchangeableSettings();
- Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
+ Backup<CompanyID> cur_company(_current_company, FILE_LINE);
cur_company.Change(OWNER_DEITY);
Game::info = info;
@@ -98,7 +98,7 @@
/* 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;
Game::instance = nullptr;
@@ -158,7 +158,7 @@
}
/* 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);
cur_company.Restore();
@@ -207,7 +207,7 @@
/* static */ void Game::Save()
{
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();
cur_company.Restore();
} else {
@@ -218,7 +218,7 @@
/* static */ void Game::Load(int version)
{
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);
cur_company.Restore();
} else {
diff --git a/src/genworld.cpp b/src/genworld.cpp
index f09b183e9..6aaf1a6fe 100644
--- a/src/genworld.cpp
+++ b/src/genworld.cpp
@@ -97,7 +97,7 @@ static void CleanupGeneration()
static void _GenerateWorld()
{
/* 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);
try {
diff --git a/src/goal.cpp b/src/goal.cpp
index b545c84d2..30f640b4c 100644
--- a/src/goal.cpp
+++ b/src/goal.cpp
@@ -79,7 +79,7 @@ CommandCost CmdCreateGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
case GT_STORY_PAGE: {
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;
break;
}
diff --git a/src/goal_base.h b/src/goal_base.h
index f82afa5be..532c47ea3 100644
--- a/src/goal_base.h
+++ b/src/goal_base.h
@@ -21,12 +21,12 @@ extern GoalPool _goal_pool;
/** Struct about goals, current and completed */
struct Goal : GoalPool::PoolItem<&_goal_pool> {
- CompanyByte company; ///< Goal is for a specific company; INVALID_COMPANY if it is global
- GoalTypeByte type; ///< Type of the goal
- GoalTypeID dst; ///< Index of type
- char *text; ///< Text of the goal.
- char *progress; ///< Progress text of the goal.
- bool completed; ///< Is the goal completed or not?
+ CompanyID company; ///< Goal is for a specific company; INVALID_COMPANY if it is global
+ GoalTypeByte type; ///< Type of the goal
+ GoalTypeID dst; ///< Index of type
+ char *text; ///< Text of the goal.
+ char *progress; ///< Progress text of the goal.
+ bool completed; ///< Is the goal completed or not?
/**
* We need an (empty) constructor so struct isn't zeroed (as C++ standard states)
diff --git a/src/group.h b/src/group.h
index 6672cff67..57488d394 100644
--- a/src/group.h
+++ b/src/group.h
@@ -66,7 +66,7 @@ struct GroupStatistics {
/** Group data. */
struct Group : GroupPool::PoolItem<&_group_pool> {
char *name; ///< Group Name
- OwnerByte owner; ///< Group Owner
+ Owner owner; ///< Group Owner
VehicleType vehicle_type; ///< Vehicle type of the group
bool replace_protection; ///< If set to true, the global autoreplace have no effect on the group
diff --git a/src/industry.h b/src/industry.h
index 4822976f2..281672959 100644
--- a/src/industry.h
+++ b/src/industry.h
@@ -57,7 +57,7 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> {
uint16 counter; ///< used for animation and/or production (if available cargo)
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
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
@@ -65,7 +65,7 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> {
PartOfSubsidyByte part_of_subsidy; ///< NOSAVE: is this industry a source/destination of a subsidy?
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
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
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 9978145fa..06c6cde56 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -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
/* 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_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 */
- 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);
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.
* 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) {
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 (flags & DC_EXEC) {
/* 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
* 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. */
@@ -2128,7 +2128,7 @@ static Industry *PlaceIndustry(IndustryType type, IndustryAvailabilityCallType c
*/
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);
PlaceIndustry(type, IACT_MAPGENERATION, try_hard);
@@ -2760,7 +2760,7 @@ void IndustryDailyLoop()
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 */
@@ -2788,7 +2788,7 @@ void IndustryDailyLoop()
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();
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index f698ace57..f341f76d6 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -655,7 +655,7 @@ public:
return;
}
- Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
+ Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
_generating_world = true;
_ignore_restrictions = true;
diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp
index b78ec948b..f0ccfbd74 100644
--- a/src/misc_cmd.cpp
+++ b/src/misc_cmd.cpp
@@ -223,7 +223,7 @@ CommandCost CmdChangeBankBalance(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (flags & DC_EXEC) {
/* 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));
cur_company.Restore();
}
@@ -259,7 +259,7 @@ CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (flags & DC_EXEC) {
/* 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()));
cur_company.Restore();
}
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index 7ebbdef51..717e41b83 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -1232,7 +1232,7 @@ void NetworkClientRequestMove(CompanyID company_id, const char *pass)
*/
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 (cid == _local_company) SetLocalCompany(COMPANY_SPECTATOR);
diff --git a/src/openttd.cpp b/src/openttd.cpp
index b9bc7c985..243302d61 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -1377,7 +1377,7 @@ void StateGameLoop()
/* All these actions has to be done from OWNER_NONE
* 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);
AnimateAnimatedTiles();
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 6964a5aaf..0804a4d14 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -764,7 +764,7 @@ bool FloodHalftile(TileIndex t)
TrackBits to_remove = lower_track & rail_bits;
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();
cur_company.Restore();
if (!flooded) return flooded; // not yet floodable
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 7086d151d..9f98c3e88 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -1126,7 +1126,7 @@ static Trackdir FollowPreviousRoadVehicle(const RoadVehicle *v, const RoadVehicl
static bool CanBuildTramTrackOnTile(CompanyID c, TileIndex t, RoadBits r)
{
/* 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);
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 5e7521d26..9bdfa6b34 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -1835,7 +1835,7 @@ bool AfterLoadGame()
if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) {
Owner o = GetTileOwner(t);
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);
cur_company.Restore();
}
diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp
index 66ef145fc..70a1a2739 100644
--- a/src/saveload/waypoint_sl.cpp
+++ b/src/saveload/waypoint_sl.cpp
@@ -36,7 +36,7 @@ struct OldWaypoint {
uint8 localidx;
uint32 grfid;
const StationSpec *spec;
- OwnerByte owner;
+ Owner owner;
size_t new_index;
};
diff --git a/src/script/api/script_cargomonitor.cpp b/src/script/api/script_cargomonitor.cpp
index 3cb9b4a8e..e862fed3e 100644
--- a/src/script/api/script_cargomonitor.cpp
+++ b/src/script/api/script_cargomonitor.cpp
@@ -20,7 +20,7 @@
/* static */ int32 ScriptCargoMonitor::GetTownDeliveryAmount(ScriptCompany::CompanyID company, CargoID cargo, TownID town_id, bool keep_monitoring)
{
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 (!::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)
{
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 (!::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)
{
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 (!::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)
{
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 (!::Industry::IsValidID(industry_id)) return -1;
diff --git a/src/signs_base.h b/src/signs_base.h
index 3e7b4c465..a4ee0718b 100644
--- a/src/signs_base.h
+++ b/src/signs_base.h
@@ -26,7 +26,7 @@ struct Sign : SignPool::PoolItem<&_sign_pool> {
int32 x;
int32 y;
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();
diff --git a/src/story_base.h b/src/story_base.h
index 221dcafdf..4cc857b8d 100644
--- a/src/story_base.h
+++ b/src/story_base.h
@@ -69,7 +69,7 @@ struct StoryPageElement : StoryPageElementPool::PoolItem<&_story_page_element_po
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.
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
diff --git a/src/subsidy_base.h b/src/subsidy_base.h
index 780302e0a..6370a77e6 100644
--- a/src/subsidy_base.h
+++ b/src/subsidy_base.h
@@ -24,7 +24,7 @@ extern SubsidyPool _subsidy_pool;
struct Subsidy : SubsidyPool::PoolItem<&_subsidy_pool> {
CargoID cargo_type; ///< Cargo type involved in this subsidy, CT_INVALID for invalid subsidy
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 dst_type; ///< Destination of subsidised path (ST_INDUSTRY or ST_TOWN)
SourceID src; ///< Index of source. Either TownID or IndustryID
diff --git a/src/town.h b/src/town.h
index 310b4c439..8e8a6551d 100644
--- a/src/town.h
+++ b/src/town.h
@@ -72,7 +72,7 @@ struct Town : TownPool::PoolItem<&_town_pool> {
/* Company ratings. */
CompanyMask have_ratings; ///< which companies have a rating
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
int16 ratings[MAX_COMPANIES]; ///< ratings of each company for this town
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index ef87d82c5..f3acfb4a3 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -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) &&
HasBit(t->flags, TOWN_IS_GROWING) &&
@@ -1566,7 +1566,7 @@ static bool GrowTown(Town *t)
};
/* 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
@@ -2042,7 +2042,7 @@ static Town *CreateRandomTown(uint attempts, uint32 townnameparts, TownSize size
* placement is so bad it couldn't grow at all */
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);
cur_company.Restore();
assert(rc.Succeeded());
@@ -2940,7 +2940,7 @@ static CommandCost TownActionRoadRebuild(Town *t, DoCommandFlag flags)
*/
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);
cur_company.Restore();
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 (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);
cur_company.Restore();
BuildObject(OBJECT_STATUE, statue_data.best_position, _current_company, t);
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index e6df365b0..031b6f95e 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -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) {
v = it.first;
/* Autoreplace needs the current company set as the vehicle owner */
@@ -1514,7 +1514,7 @@ void VehicleEnterDepot(Vehicle *v)
}
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));
cur_company.Restore();
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index 9ccb67113..2b091c340 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -270,7 +270,7 @@ public:
int32 z_pos; ///< z coordinate.
Direction direction; ///< facing
- OwnerByte owner; ///< Which company owns the vehicle?
+ Owner owner; ///< Which company owns the vehicle?
/**
* currently displayed sprite index
* 0xfd == custom sprite, 0xfe == custom second head sprite
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index e3247ec66..b603d7411 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -1044,7 +1044,7 @@ void DoFloodTile(TileIndex target)
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);
if (tileh != SLOPE_FLAT) {
@@ -1105,7 +1105,7 @@ void DoFloodTile(TileIndex target)
*/
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)) {
case MP_RAILWAY: