mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: use std::source_location over __FILE__ and __LINE__ for Backup
This commit is contained in:
parent
381dee2e01
commit
bab5a8a787
|
@ -40,7 +40,7 @@
|
|||
/* Clients shouldn't start AIs */
|
||||
if (_networking && !_network_server) return;
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, company);
|
||||
Company *c = Company::Get(company);
|
||||
|
||||
AIConfig *config = c->ai_config.get();
|
||||
|
@ -81,7 +81,7 @@
|
|||
assert(_settings_game.difficulty.competitor_speed <= 4);
|
||||
if ((AI::frame_counter & ((1 << (4 - _settings_game.difficulty.competitor_speed)) - 1)) != 0) return;
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company);
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
if (c->is_ai) {
|
||||
PerformanceMeasurer framerate((PerformanceElement)(PFE_AI0 + c->index));
|
||||
|
@ -109,7 +109,7 @@
|
|||
if (_networking && !_network_server) return;
|
||||
PerformanceMeasurer::SetInactive((PerformanceElement)(PFE_AI0 + company));
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, company);
|
||||
Company *c = Company::Get(company);
|
||||
|
||||
delete c->ai_instance;
|
||||
|
@ -129,7 +129,7 @@
|
|||
* for the server owner to unpause the script again. */
|
||||
if (_network_dedicated) return;
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, company);
|
||||
Company::Get(company)->ai_instance->Pause();
|
||||
|
||||
cur_company.Restore();
|
||||
|
@ -137,7 +137,7 @@
|
|||
|
||||
/* static */ void AI::Unpause(CompanyID company)
|
||||
{
|
||||
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, company);
|
||||
Company::Get(company)->ai_instance->Unpause();
|
||||
|
||||
cur_company.Restore();
|
||||
|
@ -145,7 +145,7 @@
|
|||
|
||||
/* static */ bool AI::IsPaused(CompanyID company)
|
||||
{
|
||||
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, company);
|
||||
bool paused = Company::Get(company)->ai_instance->IsPaused();
|
||||
|
||||
cur_company.Restore();
|
||||
|
@ -259,7 +259,7 @@
|
|||
}
|
||||
|
||||
/* Queue the event */
|
||||
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, company);
|
||||
Company::Get(_current_company)->ai_instance->InsertEvent(event);
|
||||
cur_company.Restore();
|
||||
|
||||
|
@ -293,7 +293,7 @@
|
|||
|
||||
/* When doing emergency saving, an AI can be not fully initialised. */
|
||||
if (c->ai_instance != nullptr) {
|
||||
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, company);
|
||||
c->ai_instance->Save();
|
||||
cur_company.Restore();
|
||||
return;
|
||||
|
|
|
@ -1285,7 +1285,7 @@ void HandleMissingAircraftOrders(Aircraft *v)
|
|||
*/
|
||||
const Station *st = GetTargetAirportIfValid(v);
|
||||
if (st == nullptr) {
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner);
|
||||
CommandCost ret = Command<CMD_SEND_VEHICLE_TO_DEPOT>::Do(DC_EXEC, v->index, DepotCommand::None, {});
|
||||
cur_company.Restore();
|
||||
|
||||
|
@ -1651,7 +1651,7 @@ static void AircraftEventHandler_HeliTakeOff(Aircraft *v, const AirportFTAClass
|
|||
|
||||
/* Send the helicopter to a hangar if needed for replacement */
|
||||
if (v->NeedsAutomaticServicing()) {
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner);
|
||||
Command<CMD_SEND_VEHICLE_TO_DEPOT>::Do(DC_EXEC, v->index, DepotCommand::Service | DepotCommand::LocateHangar, {});
|
||||
cur_company.Restore();
|
||||
}
|
||||
|
@ -1702,7 +1702,7 @@ static void AircraftEventHandler_Landing(Aircraft *v, const AirportFTAClass *)
|
|||
|
||||
/* check if the aircraft needs to be replaced or renewed and send it to a hangar if needed */
|
||||
if (v->NeedsAutomaticServicing()) {
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner);
|
||||
Command<CMD_SEND_VEHICLE_TO_DEPOT>::Do(DC_EXEC, v->index, DepotCommand::Service, {});
|
||||
cur_company.Restore();
|
||||
}
|
||||
|
|
|
@ -372,7 +372,7 @@ protected:
|
|||
assert(AllClientIdsSet(args, std::index_sequence_for<Targs...>{}));
|
||||
}
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company);
|
||||
if (!InternalExecutePrepTest(cmd_flags, tile, cur_company)) {
|
||||
cur_company.Trash();
|
||||
return MakeResult(CMD_ERROR);
|
||||
|
|
|
@ -1255,7 +1255,7 @@ CommandCost CmdGiveMoney(DoCommandFlag flags, Money money, CompanyID dest_compan
|
|||
|
||||
if (flags & DC_EXEC) {
|
||||
/* Add money to company */
|
||||
Backup<CompanyID> cur_company(_current_company, dest_company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, dest_company);
|
||||
SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, -amount.GetCost()));
|
||||
cur_company.Restore();
|
||||
|
||||
|
|
|
@ -22,20 +22,18 @@ struct Backup {
|
|||
/**
|
||||
* Backup variable.
|
||||
* @param original Variable to backup.
|
||||
* @param file Filename for debug output. Use FILE_LINE macro.
|
||||
* @param line Linenumber for debug output. Use FILE_LINE macro.
|
||||
* @param location Source location for debug output.
|
||||
*/
|
||||
Backup(T &original, const char * const file, const int line) : original(original), valid(true), original_value(original), file(file), line(line) {}
|
||||
Backup(T &original, const std::source_location location = std::source_location::current()) : original(original), valid(true), original_value(original), location(location) {}
|
||||
|
||||
/**
|
||||
* Backup variable and switch to new value.
|
||||
* @param original Variable to backup.
|
||||
* @param new_value New value for variable.
|
||||
* @param file Filename for debug output. Use FILE_LINE macro.
|
||||
* @param line Linenumber for debug output. Use FILE_LINE macro.
|
||||
* @param location Source location for debug output.
|
||||
*/
|
||||
template <typename U>
|
||||
Backup(T &original, const U &new_value, const char * const file, const int line) : original(original), valid(true), original_value(original), file(file), line(line)
|
||||
Backup(T &original, const U &new_value, const std::source_location location = std::source_location::current()) : original(original), valid(true), original_value(original), location(location)
|
||||
{
|
||||
/* Note: We use a separate typename U, so type conversions are handled by assignment operator. */
|
||||
original = new_value;
|
||||
|
@ -51,7 +49,7 @@ struct Backup {
|
|||
{
|
||||
/* We cannot assert here, as missing restoration is 'normal' when exceptions are thrown.
|
||||
* Exceptions are especially used to abort world generation. */
|
||||
Debug(misc, 0, "{}:{}: Backed-up value was not restored!", this->file, this->line);
|
||||
Debug(misc, 0, "{}:{}: Backed-up value was not restored!", this->location.file_name(), this->location.line());
|
||||
this->Restore();
|
||||
}
|
||||
}
|
||||
|
@ -140,8 +138,7 @@ private:
|
|||
bool valid;
|
||||
T original_value;
|
||||
|
||||
const char * const file;
|
||||
const int line;
|
||||
const std::source_location location;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -60,9 +60,6 @@ void DumpDebugFacilityNames(std::back_insert_iterator<std::string> &output_itera
|
|||
void SetDebugString(const char *s, void (*error_func)(const std::string &));
|
||||
std::string GetDebugString();
|
||||
|
||||
/* Shorter form for passing filename and linenumber */
|
||||
#define FILE_LINE __FILE__, __LINE__
|
||||
|
||||
/** TicToc profiling.
|
||||
* Usage:
|
||||
* static TicToc::State state("A name", 1);
|
||||
|
|
|
@ -63,7 +63,7 @@ static void DisasterClearSquare(TileIndex tile)
|
|||
switch (GetTileType(tile)) {
|
||||
case MP_RAILWAY:
|
||||
if (Company::IsHumanID(GetTileOwner(tile)) && !IsRailDepot(tile)) {
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_WATER, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_WATER);
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC, tile);
|
||||
cur_company.Restore();
|
||||
|
||||
|
@ -73,7 +73,7 @@ static void DisasterClearSquare(TileIndex tile)
|
|||
break;
|
||||
|
||||
case MP_HOUSE: {
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE);
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC, tile);
|
||||
cur_company.Restore();
|
||||
break;
|
||||
|
|
|
@ -336,14 +336,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<CompanyID> cur_company(_current_company, old_owner, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, old_owner);
|
||||
/* 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 singleplayer mode, so we must pick some other company. */
|
||||
assert(!_networking);
|
||||
Backup<CompanyID> cur_company2(_current_company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company2(_current_company);
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
if (c->index != old_owner) {
|
||||
SetLocalCompany(c->index);
|
||||
|
@ -661,7 +661,7 @@ static void CompaniesGenStatistics()
|
|||
CompanyCheckBankrupt(c);
|
||||
}
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company);
|
||||
|
||||
/* Pay Infrastructure Maintenance, if enabled */
|
||||
if (_settings_game.economy.infrastructure_maintenance) {
|
||||
|
@ -824,7 +824,7 @@ void RecomputePrices()
|
|||
/** Let all companies pay the monthly interest on their loan. */
|
||||
static void CompaniesPayInterest()
|
||||
{
|
||||
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company);
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
cur_company.Change(c->index);
|
||||
|
||||
|
@ -1205,7 +1205,7 @@ CargoPayment::~CargoPayment()
|
|||
|
||||
if (this->visual_profit == 0 && this->visual_transfer == 0) return;
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, this->front->owner, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, this->front->owner);
|
||||
|
||||
SubtractMoneyFromCompany(CommandCost(this->front->GetExpenseType(true), -this->route_profit));
|
||||
this->front->profit_this_year += (this->visual_profit + this->visual_transfer) << 8;
|
||||
|
@ -1496,7 +1496,7 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
|
|||
Vehicle *v_start = v->GetFirstEnginePart();
|
||||
if (!IterateVehicleParts(v_start, IsEmptyAction())) return;
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner);
|
||||
|
||||
CargoTypes refit_mask = v->GetEngine()->info.refit_mask;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
Game::frame_counter++;
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company);
|
||||
cur_company.Change(OWNER_DEITY);
|
||||
Game::instance->GameLoop();
|
||||
cur_company.Restore();
|
||||
|
@ -85,7 +85,7 @@
|
|||
|
||||
config->AnchorUnchangeableSettings();
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company);
|
||||
cur_company.Change(OWNER_DEITY);
|
||||
|
||||
Game::info = info;
|
||||
|
@ -101,7 +101,7 @@
|
|||
|
||||
/* static */ void Game::Uninitialize(bool keepConfig)
|
||||
{
|
||||
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company);
|
||||
|
||||
delete Game::instance;
|
||||
Game::instance = nullptr;
|
||||
|
@ -161,7 +161,7 @@
|
|||
}
|
||||
|
||||
/* Queue the event */
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_DEITY, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_DEITY);
|
||||
Game::instance->InsertEvent(event);
|
||||
cur_company.Restore();
|
||||
|
||||
|
@ -211,7 +211,7 @@
|
|||
/* static */ void Game::Save()
|
||||
{
|
||||
if (Game::instance != nullptr && (!_networking || _network_server)) {
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_DEITY, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_DEITY);
|
||||
Game::instance->Save();
|
||||
cur_company.Restore();
|
||||
} else {
|
||||
|
|
|
@ -86,7 +86,7 @@ static void CleanupGeneration()
|
|||
static void _GenerateWorld()
|
||||
{
|
||||
/* Make sure everything is done via OWNER_NONE. */
|
||||
Backup<CompanyID> _cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||
Backup<CompanyID> _cur_company(_current_company, OWNER_NONE);
|
||||
|
||||
try {
|
||||
_generating_world = true;
|
||||
|
|
|
@ -1196,7 +1196,7 @@ std::unique_ptr<uint32_t[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel
|
|||
}
|
||||
|
||||
/* Temporarily disable screen animations while blitting - This prevents 40bpp_anim from writing to the animation buffer. */
|
||||
Backup<bool> disable_anim(_screen_disable_anim, true, FILE_LINE);
|
||||
Backup<bool> disable_anim(_screen_disable_anim, true);
|
||||
GfxBlitter<1, true>(sprite, 0, 0, BM_NORMAL, nullptr, real_sprite, zoom, &dpi);
|
||||
disable_anim.Restore();
|
||||
|
||||
|
|
|
@ -1105,7 +1105,7 @@ static bool SearchLumberMillTrees(TileIndex tile, void *)
|
|||
if (IsTileType(tile, MP_TREES) && GetTreeGrowth(tile) > 2) { ///< 3 and up means all fully grown trees
|
||||
/* found a tree */
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE);
|
||||
|
||||
_industry_sound_ctr = 1;
|
||||
_industry_sound_tile = tile;
|
||||
|
@ -1500,7 +1500,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<CompanyID> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN);
|
||||
ret = Command<CMD_LANDSCAPE_CLEAR>::Do(DC_NONE, cur_tile);
|
||||
cur_company.Restore();
|
||||
|
||||
|
@ -1642,7 +1642,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<CompanyID> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN);
|
||||
|
||||
for (TileIndex tile_walk : ta) {
|
||||
uint curh = TileHeight(tile_walk);
|
||||
|
@ -2081,7 +2081,7 @@ CommandCost CmdBuildIndustry(DoCommandFlag flags, TileIndex tile, IndustryType i
|
|||
if (prospect_success) {
|
||||
/* Prospected industries are build as OWNER_TOWN to not e.g. be build on owned land of the founder */
|
||||
IndustryAvailabilityCallType calltype = _current_company == OWNER_DEITY ? IACT_RANDOMCREATION : IACT_PROSPECTCREATION;
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN);
|
||||
for (int i = 0; i < 5000; i++) {
|
||||
/* We should not have more than one Random() in a function call
|
||||
* because parameter evaluation order is not guaranteed in the c++ standard
|
||||
|
@ -2383,7 +2383,7 @@ static Industry *PlaceIndustry(IndustryType type, IndustryAvailabilityCallType c
|
|||
*/
|
||||
static void PlaceInitialIndustry(IndustryType type, bool try_hard)
|
||||
{
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE);
|
||||
|
||||
IncreaseGeneratingWorldProgress(GWP_INDUSTRY);
|
||||
PlaceIndustry(type, IACT_MAPGENERATION, try_hard);
|
||||
|
@ -3023,7 +3023,7 @@ static IntervalTimer<TimerGameEconomy> _economy_industries_daily({TimerGameEcono
|
|||
return; // Nothing to do? get out
|
||||
}
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE);
|
||||
|
||||
/* perform the required industry changes for the day */
|
||||
|
||||
|
@ -3051,7 +3051,7 @@ static IntervalTimer<TimerGameEconomy> _economy_industries_daily({TimerGameEcono
|
|||
|
||||
static IntervalTimer<TimerGameEconomy> _economy_industries_monthly({TimerGameEconomy::MONTH, TimerGameEconomy::Priority::INDUSTRY}, [](auto)
|
||||
{
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE);
|
||||
|
||||
_industry_builder.EconomyMonthlyLoop();
|
||||
|
||||
|
|
|
@ -603,7 +603,7 @@ public:
|
|||
if (Town::GetNumItems() == 0) {
|
||||
ShowErrorMessage(STR_ERROR_CAN_T_GENERATE_INDUSTRIES, STR_ERROR_MUST_FOUND_TOWN_FIRST, WL_INFO);
|
||||
} else {
|
||||
Backup<bool> old_generating_world(_generating_world, true, FILE_LINE);
|
||||
Backup<bool> old_generating_world(_generating_world, true);
|
||||
BasePersistentStorageArray::SwitchMode(PSM_ENTER_GAMELOOP);
|
||||
GenerateIndustries();
|
||||
BasePersistentStorageArray::SwitchMode(PSM_LEAVE_GAMELOOP);
|
||||
|
@ -707,8 +707,8 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||
Backup<bool> old_generating_world(_generating_world, true, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE);
|
||||
Backup<bool> old_generating_world(_generating_world, true);
|
||||
_ignore_restrictions = true;
|
||||
|
||||
Command<CMD_BUILD_INDUSTRY>::Post(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY, &CcBuildIndustry, tile, this->selected_type, layout_index, false, seed);
|
||||
|
|
|
@ -241,7 +241,7 @@ CommandCost CmdChangeBankBalance(DoCommandFlag flags, TileIndex tile, Money delt
|
|||
|
||||
if (flags & DC_EXEC) {
|
||||
/* Change company bank balance of company. */
|
||||
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, company);
|
||||
SubtractMoneyFromCompany(CommandCost(expenses_type, -delta));
|
||||
cur_company.Restore();
|
||||
|
||||
|
|
|
@ -1284,7 +1284,7 @@ void NetworkClientRequestMove(CompanyID company_id, const std::string &pass)
|
|||
*/
|
||||
void NetworkClientsToSpectators(CompanyID cid)
|
||||
{
|
||||
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company);
|
||||
/* If our company is changing owner, go to spectators */
|
||||
if (cid == _local_company) SetLocalCompany(COMPANY_SPECTATOR);
|
||||
|
||||
|
|
|
@ -1475,7 +1475,7 @@ void StateGameLoop()
|
|||
|
||||
/* All these actions has to be done from OWNER_NONE
|
||||
* for multiplayer compatibility */
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE);
|
||||
|
||||
BasePersistentStorageArray::SwitchMode(PSM_ENTER_GAMELOOP);
|
||||
AnimateAnimatedTiles();
|
||||
|
|
|
@ -774,7 +774,7 @@ bool FloodHalftile(TileIndex t)
|
|||
|
||||
TrackBits to_remove = lower_track & rail_bits;
|
||||
if (to_remove != 0) {
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_WATER, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_WATER);
|
||||
flooded = Command<CMD_REMOVE_SINGLE_RAIL>::Do(DC_EXEC, t, FindFirstTrack(to_remove)).Succeeded();
|
||||
cur_company.Restore();
|
||||
if (!flooded) return flooded; // not yet floodable
|
||||
|
|
|
@ -1135,7 +1135,7 @@ static Trackdir FollowPreviousRoadVehicle(const RoadVehicle *v, const RoadVehicl
|
|||
static bool CanBuildTramTrackOnTile(CompanyID c, TileIndex t, RoadType rt, RoadBits r)
|
||||
{
|
||||
/* The 'current' company is not necessarily the owner of the vehicle. */
|
||||
Backup<CompanyID> cur_company(_current_company, c, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, c);
|
||||
|
||||
CommandCost ret = Command<CMD_BUILD_ROAD>::Do(DC_NO_WATER, t, r, rt, DRD_NONE, 0);
|
||||
|
||||
|
|
|
@ -1857,7 +1857,7 @@ bool AfterLoadGame()
|
|||
if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) {
|
||||
Owner o = GetTileOwner(t);
|
||||
if (o < MAX_COMPANIES && !Company::IsValidID(o)) {
|
||||
Backup<CompanyID> cur_company(_current_company, o, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, o);
|
||||
ChangeTileOwner(t, o, INVALID_OWNER);
|
||||
cur_company.Restore();
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
#include <numeric>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <source_location>
|
||||
#include <span>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
|
|
@ -268,7 +268,7 @@ std::tuple<CommandCost, Money, TileIndex> CmdTerraformLand(DoCommandFlag flags,
|
|||
bool indirectly_cleared = coa != nullptr && coa->first_tile != t;
|
||||
|
||||
/* Check tiletype-specific things, and add extra-cost */
|
||||
Backup<bool> old_generating_world(_generating_world, FILE_LINE);
|
||||
Backup<bool> old_generating_world(_generating_world);
|
||||
if (_game_mode == GM_EDITOR) old_generating_world.Change(true); // used to create green terraformed land
|
||||
DoCommandFlag tile_flags = flags | DC_AUTO | DC_FORCE_CLEAR_TILE;
|
||||
if (pass == 0) {
|
||||
|
|
|
@ -59,7 +59,7 @@ static void GenerateDesertArea(TileIndex end, TileIndex start)
|
|||
{
|
||||
if (_game_mode != GM_EDITOR) return;
|
||||
|
||||
Backup<bool> old_generating_world(_generating_world, true, FILE_LINE);
|
||||
Backup<bool> old_generating_world(_generating_world, true);
|
||||
|
||||
TileArea ta(start, end);
|
||||
for (TileIndex tile : ta) {
|
||||
|
@ -507,7 +507,7 @@ static void ResetLandscapeConfirmationCallback(Window *, bool confirmed)
|
|||
if (confirmed) {
|
||||
/* Set generating_world to true to get instant-green grass after removing
|
||||
* company property. */
|
||||
Backup<bool> old_generating_world(_generating_world, true, FILE_LINE);
|
||||
Backup<bool> old_generating_world(_generating_world, true);
|
||||
|
||||
/* Delete all companies */
|
||||
for (Company *c : Company::Iterate()) {
|
||||
|
|
|
@ -662,7 +662,7 @@ static void TileLoop_Town(TileIndex tile)
|
|||
}
|
||||
}
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN);
|
||||
|
||||
if ((hs->building_flags & BUILDING_HAS_1_TILE) &&
|
||||
HasBit(t->flags, TOWN_IS_GROWING) &&
|
||||
|
@ -1821,7 +1821,7 @@ static bool GrowTown(Town *t)
|
|||
};
|
||||
|
||||
/* Current "company" is a town */
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN);
|
||||
|
||||
TileIndex tile = t->xy; // The tile we are working with ATM
|
||||
|
||||
|
@ -2108,7 +2108,7 @@ std::tuple<CommandCost, Money, TownID> CmdFoundTown(DoCommandFlag flags, TileInd
|
|||
return { CommandCost(EXPENSES_OTHER), cost.GetCost(), INVALID_TOWN };
|
||||
}
|
||||
|
||||
Backup<bool> old_generating_world(_generating_world, true, FILE_LINE);
|
||||
Backup<bool> old_generating_world(_generating_world, true);
|
||||
UpdateNearestTownForRoadTiles(true);
|
||||
Town *t;
|
||||
if (random_location) {
|
||||
|
@ -2303,7 +2303,7 @@ static Town *CreateRandomTown(uint attempts, uint32_t townnameparts, TownSize si
|
|||
* placement is so bad it couldn't grow at all */
|
||||
if (t->cache.population > 0) return t;
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN);
|
||||
[[maybe_unused]] CommandCost rc = Command<CMD_DELETE_TOWN>::Do(DC_EXEC, t->index);
|
||||
cur_company.Restore();
|
||||
assert(rc.Succeeded());
|
||||
|
@ -3250,7 +3250,7 @@ static CommandCost TownActionRoadRebuild(Town *t, DoCommandFlag flags)
|
|||
*/
|
||||
static bool CheckClearTile(TileIndex tile)
|
||||
{
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE);
|
||||
CommandCost r = Command<CMD_LANDSCAPE_CLEAR>::Do(DC_NONE, tile);
|
||||
cur_company.Restore();
|
||||
return r.Succeeded();
|
||||
|
@ -3322,7 +3322,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<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE);
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC, statue_data.best_position);
|
||||
cur_company.Restore();
|
||||
BuildObject(OBJECT_STATUE, statue_data.best_position, _current_company, t);
|
||||
|
|
|
@ -1236,7 +1236,7 @@ public:
|
|||
break;
|
||||
|
||||
case WID_TF_MANY_RANDOM_TOWNS: {
|
||||
Backup<bool> old_generating_world(_generating_world, true, FILE_LINE);
|
||||
Backup<bool> old_generating_world(_generating_world, true);
|
||||
UpdateNearestTownForRoadTiles(true);
|
||||
if (!GenerateTowns(this->town_layout)) {
|
||||
ShowErrorMessage(STR_ERROR_CAN_T_GENERATE_TOWN, STR_ERROR_NO_SPACE_FOR_TOWN, WL_INFO);
|
||||
|
|
|
@ -1065,7 +1065,7 @@ void CallVehicleTicks()
|
|||
}
|
||||
}
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company);
|
||||
for (auto &it : _vehicles_to_autoreplace) {
|
||||
Vehicle *v = it.first;
|
||||
/* Autoreplace needs the current company set as the vehicle owner */
|
||||
|
@ -1618,7 +1618,7 @@ void VehicleEnterDepot(Vehicle *v)
|
|||
}
|
||||
|
||||
if (v->current_order.IsRefit()) {
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner);
|
||||
CommandCost cost = std::get<0>(Command<CMD_REFIT_VEHICLE>::Do(DC_EXEC, v->index, v->current_order.GetRefitCargo(), 0xFF, false, false, 0));
|
||||
cur_company.Restore();
|
||||
|
||||
|
|
|
@ -1120,7 +1120,7 @@ void DoFloodTile(TileIndex target)
|
|||
|
||||
bool flooded = false; // Will be set to true if something is changed.
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_WATER, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_WATER);
|
||||
|
||||
Slope tileh = GetTileSlope(target);
|
||||
if (tileh != SLOPE_FLAT) {
|
||||
|
@ -1183,7 +1183,7 @@ void DoFloodTile(TileIndex target)
|
|||
*/
|
||||
static void DoDryUp(TileIndex tile)
|
||||
{
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_WATER, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_WATER);
|
||||
|
||||
switch (GetTileType(tile)) {
|
||||
case MP_RAILWAY:
|
||||
|
|
Loading…
Reference in New Issue