Changeset - r23674:a5bafa1a02c5
src/ai/ai_core.cpp
Show inline comments
 
@@ -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 {
src/ai/ai_gui.cpp
Show inline comments
 
@@ -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++) {
src/aircraft_cmd.cpp
Show inline comments
 
@@ -1233,7 +1233,7 @@ void HandleMissingAircraftOrders(Aircraf
 
	 */
 
	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_HeliTak
 

	
 
	/* 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
 

	
 
	/* 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();
 
	}
src/base_station_base.h
Show inline comments
 
@@ -60,7 +60,7 @@ struct BaseStation : StationPool::PoolIt
 
	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
src/command.cpp
Show inline comments
 
@@ -660,7 +660,7 @@ CommandCost DoCommandPInternal(TileIndex
 
		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;
src/company_base.h
Show inline comments
 
@@ -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.
 

	
src/company_cmd.cpp
Show inline comments
 
@@ -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
src/company_func.h
Show inline comments
 
@@ -32,8 +32,8 @@ void SubtractMoneyFromCompanyFract(Compa
 
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;
src/company_type.h
Show inline comments
 
@@ -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  
 

	
 
/** 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;
 

	
src/console_cmds.cpp
Show inline comments
 
@@ -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;
 
	}
 

	
src/disaster_vehicle.cpp
Show inline comments
 
@@ -62,7 +62,7 @@ static void DisasterClearSquare(TileInde
 
	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(TileInde
 
			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;
src/economy.cpp
Show inline comments
 
@@ -291,14 +291,14 @@ void ChangeOwnershipOfCompanyItems(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
 
		}
 

	
 
		/* 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 *
 
	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(TileInd
 

	
 
	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(TileIn
 
	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);
src/engine_base.h
Show inline comments
 
@@ -34,7 +34,7 @@ struct Engine : EnginePool::PoolItem<&_e
 
	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<&_e
 
	 * @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);
 
	}
src/game/game_core.cpp
Show inline comments
 
@@ -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 {
src/genworld.cpp
Show inline comments
 
@@ -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 {
src/goal.cpp
Show inline comments
 
@@ -79,7 +79,7 @@ CommandCost CmdCreateGoal(TileIndex tile
 

	
 
		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;
 
		}
src/goal_base.h
Show inline comments
 
@@ -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)
src/group.h
Show inline comments
 
@@ -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
src/industry.h
Show inline comments
 
@@ -57,7 +57,7 @@ struct Industry : IndustryPool::PoolItem
 
	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
 
	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
src/industry_cmd.cpp
Show inline comments
 
@@ -1077,7 +1077,7 @@ static bool SearchLumberMillTrees(TileIn
 
	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 CheckIfIndustryTilesA
 
				}
 

	
 
				/* 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 CheckIfCanLevelIndustryPlatf
 

	
 
	/* _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 t
 
	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(IndustryT
 
 */
 
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();
 

	
src/industry_gui.cpp
Show inline comments
 
@@ -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;
 

	
src/misc_cmd.cpp
Show inline comments
 
@@ -223,7 +223,7 @@ CommandCost CmdChangeBankBalance(TileInd
 

	
 
	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,
 

	
 
	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();
 
	}
src/network/network_client.cpp
Show inline comments
 
@@ -1232,7 +1232,7 @@ void NetworkClientRequestMove(CompanyID 
 
 */
 
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);
 

	
src/openttd.cpp
Show inline comments
 
@@ -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();
src/rail_cmd.cpp
Show inline comments
 
@@ -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
src/roadveh_cmd.cpp
Show inline comments
 
@@ -1126,7 +1126,7 @@ static Trackdir FollowPreviousRoadVehicl
 
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);
 

	
src/saveload/afterload.cpp
Show inline comments
 
@@ -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();
 
				}
src/saveload/waypoint_sl.cpp
Show inline comments
 
@@ -36,7 +36,7 @@ struct OldWaypoint {
 
	uint8 localidx;
 
	uint32 grfid;
 
	const StationSpec *spec;
 
	OwnerByte owner;
 
	Owner owner;
 

	
 
	size_t new_index;
 
};
src/script/api/script_cargomonitor.cpp
Show inline comments
 
@@ -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;
 

	
src/signs_base.h
Show inline comments
 
@@ -26,7 +26,7 @@ struct Sign : SignPool::PoolItem<&_sign_
 
	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();
src/story_base.h
Show inline comments
 
@@ -69,7 +69,7 @@ struct StoryPageElement : StoryPageEleme
 
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
 

	
src/subsidy_base.h
Show inline comments
 
@@ -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
src/town.h
Show inline comments
 
@@ -72,7 +72,7 @@ struct Town : TownPool::PoolItem<&_town_
 
	/* 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
 

	
src/town_cmd.cpp
Show inline comments
 
@@ -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 attem
 
		 * 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
 
 */
 
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
 
	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);
src/vehicle.cpp
Show inline comments
 
@@ -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();
 

	
src/vehicle_base.h
Show inline comments
 
@@ -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
src/water_cmd.cpp
Show inline comments
 
@@ -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:
0 comments (0 inline, 0 general)