From bab5a8a78713299a4ea6be0ac6b94830c031fd57 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Wed, 17 Jan 2024 03:33:23 +0100 Subject: [PATCH] Codechange: use std::source_location over __FILE__ and __LINE__ for Backup --- src/ai/ai_core.cpp | 16 ++++++++-------- src/aircraft_cmd.cpp | 6 +++--- src/command_func.h | 2 +- src/company_cmd.cpp | 2 +- src/core/backup_type.hpp | 15 ++++++--------- src/debug.h | 3 --- src/disaster_vehicle.cpp | 4 ++-- src/economy.cpp | 12 ++++++------ src/game/game_core.cpp | 10 +++++----- src/genworld.cpp | 2 +- src/gfx.cpp | 2 +- src/industry_cmd.cpp | 14 +++++++------- src/industry_gui.cpp | 6 +++--- src/misc_cmd.cpp | 2 +- src/network/network_client.cpp | 2 +- src/openttd.cpp | 2 +- src/rail_cmd.cpp | 2 +- src/roadveh_cmd.cpp | 2 +- src/saveload/afterload.cpp | 2 +- src/stdafx.h | 1 + src/terraform_cmd.cpp | 2 +- src/terraform_gui.cpp | 4 ++-- src/town_cmd.cpp | 12 ++++++------ src/town_gui.cpp | 2 +- src/vehicle.cpp | 4 ++-- src/water_cmd.cpp | 4 ++-- 26 files changed, 65 insertions(+), 70 deletions(-) diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp index d1cc955395..c62f05f929 100644 --- a/src/ai/ai_core.cpp +++ b/src/ai/ai_core.cpp @@ -40,7 +40,7 @@ /* Clients shouldn't start AIs */ if (_networking && !_network_server) return; - Backup cur_company(_current_company, company, FILE_LINE); + Backup 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 cur_company(_current_company, FILE_LINE); + Backup 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 cur_company(_current_company, company, FILE_LINE); + Backup 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 cur_company(_current_company, company, FILE_LINE); + Backup 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 cur_company(_current_company, company, FILE_LINE); + Backup 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 cur_company(_current_company, company, FILE_LINE); + Backup cur_company(_current_company, company); bool paused = Company::Get(company)->ai_instance->IsPaused(); cur_company.Restore(); @@ -259,7 +259,7 @@ } /* Queue the event */ - Backup cur_company(_current_company, company, FILE_LINE); + Backup 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 cur_company(_current_company, company, FILE_LINE); + Backup cur_company(_current_company, company); c->ai_instance->Save(); cur_company.Restore(); return; diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 14a7eceeda..ba1e8fbfa8 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -1285,7 +1285,7 @@ void HandleMissingAircraftOrders(Aircraft *v) */ const Station *st = GetTargetAirportIfValid(v); if (st == nullptr) { - Backup cur_company(_current_company, v->owner, FILE_LINE); + Backup cur_company(_current_company, v->owner); CommandCost ret = Command::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 cur_company(_current_company, v->owner, FILE_LINE); + Backup cur_company(_current_company, v->owner); Command::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 cur_company(_current_company, v->owner, FILE_LINE); + Backup cur_company(_current_company, v->owner); Command::Do(DC_EXEC, v->index, DepotCommand::Service, {}); cur_company.Restore(); } diff --git a/src/command_func.h b/src/command_func.h index f0da57c65e..ddf68aaf11 100644 --- a/src/command_func.h +++ b/src/command_func.h @@ -372,7 +372,7 @@ protected: assert(AllClientIdsSet(args, std::index_sequence_for{})); } - Backup cur_company(_current_company, FILE_LINE); + Backup cur_company(_current_company); if (!InternalExecutePrepTest(cmd_flags, tile, cur_company)) { cur_company.Trash(); return MakeResult(CMD_ERROR); diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index d6844c58e9..6c936d7138 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -1255,7 +1255,7 @@ CommandCost CmdGiveMoney(DoCommandFlag flags, Money money, CompanyID dest_compan if (flags & DC_EXEC) { /* Add money to company */ - Backup cur_company(_current_company, dest_company, FILE_LINE); + Backup cur_company(_current_company, dest_company); SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, -amount.GetCost())); cur_company.Restore(); diff --git a/src/core/backup_type.hpp b/src/core/backup_type.hpp index 62e6d31329..b6b5de558d 100644 --- a/src/core/backup_type.hpp +++ b/src/core/backup_type.hpp @@ -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 - 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; }; /** diff --git a/src/debug.h b/src/debug.h index fbd39683c6..de91c21e39 100644 --- a/src/debug.h +++ b/src/debug.h @@ -60,9 +60,6 @@ void DumpDebugFacilityNames(std::back_insert_iterator &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); diff --git a/src/disaster_vehicle.cpp b/src/disaster_vehicle.cpp index 60b93eaf11..833226eab7 100644 --- a/src/disaster_vehicle.cpp +++ b/src/disaster_vehicle.cpp @@ -63,7 +63,7 @@ static void DisasterClearSquare(TileIndex tile) switch (GetTileType(tile)) { case MP_RAILWAY: if (Company::IsHumanID(GetTileOwner(tile)) && !IsRailDepot(tile)) { - Backup cur_company(_current_company, OWNER_WATER, FILE_LINE); + Backup cur_company(_current_company, OWNER_WATER); Command::Do(DC_EXEC, tile); cur_company.Restore(); @@ -73,7 +73,7 @@ static void DisasterClearSquare(TileIndex tile) break; case MP_HOUSE: { - Backup cur_company(_current_company, OWNER_NONE, FILE_LINE); + Backup cur_company(_current_company, OWNER_NONE); Command::Do(DC_EXEC, tile); cur_company.Restore(); break; diff --git a/src/economy.cpp b/src/economy.cpp index 27d43e1d63..3a3755fa6e 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -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 cur_company(_current_company, old_owner, FILE_LINE); + Backup 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 cur_company2(_current_company, FILE_LINE); + Backup 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 cur_company(_current_company, FILE_LINE); + Backup 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 cur_company(_current_company, FILE_LINE); + Backup 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 cur_company(_current_company, this->front->owner, FILE_LINE); + Backup 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 cur_company(_current_company, v->owner, FILE_LINE); + Backup cur_company(_current_company, v->owner); CargoTypes refit_mask = v->GetEngine()->info.refit_mask; diff --git a/src/game/game_core.cpp b/src/game/game_core.cpp index c7763429ff..a5cdb2575b 100644 --- a/src/game/game_core.cpp +++ b/src/game/game_core.cpp @@ -43,7 +43,7 @@ Game::frame_counter++; - Backup cur_company(_current_company, FILE_LINE); + Backup cur_company(_current_company); cur_company.Change(OWNER_DEITY); Game::instance->GameLoop(); cur_company.Restore(); @@ -85,7 +85,7 @@ config->AnchorUnchangeableSettings(); - Backup cur_company(_current_company, FILE_LINE); + Backup cur_company(_current_company); cur_company.Change(OWNER_DEITY); Game::info = info; @@ -101,7 +101,7 @@ /* static */ void Game::Uninitialize(bool keepConfig) { - Backup cur_company(_current_company, FILE_LINE); + Backup cur_company(_current_company); delete Game::instance; Game::instance = nullptr; @@ -161,7 +161,7 @@ } /* Queue the event */ - Backup cur_company(_current_company, OWNER_DEITY, FILE_LINE); + Backup 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 cur_company(_current_company, OWNER_DEITY, FILE_LINE); + Backup cur_company(_current_company, OWNER_DEITY); Game::instance->Save(); cur_company.Restore(); } else { diff --git a/src/genworld.cpp b/src/genworld.cpp index b657273f95..d6b8de88ff 100644 --- a/src/genworld.cpp +++ b/src/genworld.cpp @@ -86,7 +86,7 @@ static void CleanupGeneration() static void _GenerateWorld() { /* Make sure everything is done via OWNER_NONE. */ - Backup _cur_company(_current_company, OWNER_NONE, FILE_LINE); + Backup _cur_company(_current_company, OWNER_NONE); try { _generating_world = true; diff --git a/src/gfx.cpp b/src/gfx.cpp index 4d6f5a0602..4601d444da 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -1196,7 +1196,7 @@ std::unique_ptr DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel } /* Temporarily disable screen animations while blitting - This prevents 40bpp_anim from writing to the animation buffer. */ - Backup disable_anim(_screen_disable_anim, true, FILE_LINE); + Backup disable_anim(_screen_disable_anim, true); GfxBlitter<1, true>(sprite, 0, 0, BM_NORMAL, nullptr, real_sprite, zoom, &dpi); disable_anim.Restore(); diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 0264e6cbd0..635d609e30 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -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 cur_company(_current_company, OWNER_NONE, FILE_LINE); + Backup 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 cur_company(_current_company, OWNER_TOWN, FILE_LINE); + Backup cur_company(_current_company, OWNER_TOWN); ret = Command::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 cur_company(_current_company, OWNER_TOWN, FILE_LINE); + Backup 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 cur_company(_current_company, OWNER_TOWN, FILE_LINE); + Backup 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 cur_company(_current_company, OWNER_NONE, FILE_LINE); + Backup cur_company(_current_company, OWNER_NONE); IncreaseGeneratingWorldProgress(GWP_INDUSTRY); PlaceIndustry(type, IACT_MAPGENERATION, try_hard); @@ -3023,7 +3023,7 @@ static IntervalTimer _economy_industries_daily({TimerGameEcono return; // Nothing to do? get out } - Backup cur_company(_current_company, OWNER_NONE, FILE_LINE); + Backup cur_company(_current_company, OWNER_NONE); /* perform the required industry changes for the day */ @@ -3051,7 +3051,7 @@ static IntervalTimer _economy_industries_daily({TimerGameEcono static IntervalTimer _economy_industries_monthly({TimerGameEconomy::MONTH, TimerGameEconomy::Priority::INDUSTRY}, [](auto) { - Backup cur_company(_current_company, OWNER_NONE, FILE_LINE); + Backup cur_company(_current_company, OWNER_NONE); _industry_builder.EconomyMonthlyLoop(); diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 03b279edfa..097e63cc40 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -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 old_generating_world(_generating_world, true, FILE_LINE); + Backup old_generating_world(_generating_world, true); BasePersistentStorageArray::SwitchMode(PSM_ENTER_GAMELOOP); GenerateIndustries(); BasePersistentStorageArray::SwitchMode(PSM_LEAVE_GAMELOOP); @@ -707,8 +707,8 @@ public: return; } - Backup cur_company(_current_company, OWNER_NONE, FILE_LINE); - Backup old_generating_world(_generating_world, true, FILE_LINE); + Backup cur_company(_current_company, OWNER_NONE); + Backup old_generating_world(_generating_world, true); _ignore_restrictions = true; Command::Post(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY, &CcBuildIndustry, tile, this->selected_type, layout_index, false, seed); diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp index d1d79f024b..04cc7e8f96 100644 --- a/src/misc_cmd.cpp +++ b/src/misc_cmd.cpp @@ -241,7 +241,7 @@ CommandCost CmdChangeBankBalance(DoCommandFlag flags, TileIndex tile, Money delt if (flags & DC_EXEC) { /* Change company bank balance of company. */ - Backup cur_company(_current_company, company, FILE_LINE); + Backup cur_company(_current_company, company); SubtractMoneyFromCompany(CommandCost(expenses_type, -delta)); cur_company.Restore(); diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index db49083974..a9a4706768 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -1284,7 +1284,7 @@ void NetworkClientRequestMove(CompanyID company_id, const std::string &pass) */ void NetworkClientsToSpectators(CompanyID cid) { - Backup cur_company(_current_company, FILE_LINE); + Backup cur_company(_current_company); /* 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 94c9b6e748..207ff37b41 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1475,7 +1475,7 @@ void StateGameLoop() /* All these actions has to be done from OWNER_NONE * for multiplayer compatibility */ - Backup cur_company(_current_company, OWNER_NONE, FILE_LINE); + Backup cur_company(_current_company, OWNER_NONE); BasePersistentStorageArray::SwitchMode(PSM_ENTER_GAMELOOP); AnimateAnimatedTiles(); diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 21480eb1af..fdf1c1f0e1 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -774,7 +774,7 @@ bool FloodHalftile(TileIndex t) TrackBits to_remove = lower_track & rail_bits; if (to_remove != 0) { - Backup cur_company(_current_company, OWNER_WATER, FILE_LINE); + Backup cur_company(_current_company, OWNER_WATER); flooded = Command::Do(DC_EXEC, t, FindFirstTrack(to_remove)).Succeeded(); cur_company.Restore(); if (!flooded) return flooded; // not yet floodable diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 6674425845..32150cc714 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -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 cur_company(_current_company, c, FILE_LINE); + Backup cur_company(_current_company, c); CommandCost ret = Command::Do(DC_NO_WATER, t, r, rt, DRD_NONE, 0); diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index a16269aa6f..810e48befe 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -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 cur_company(_current_company, o, FILE_LINE); + Backup cur_company(_current_company, o); ChangeTileOwner(t, o, INVALID_OWNER); cur_company.Restore(); } diff --git a/src/stdafx.h b/src/stdafx.h index 5fc27f4dcc..3051047555 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -71,6 +71,7 @@ #include #include #include +#include #include #include #include diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp index b7b2da67e9..00c7ef0681 100644 --- a/src/terraform_cmd.cpp +++ b/src/terraform_cmd.cpp @@ -268,7 +268,7 @@ std::tuple CmdTerraformLand(DoCommandFlag flags, bool indirectly_cleared = coa != nullptr && coa->first_tile != t; /* Check tiletype-specific things, and add extra-cost */ - Backup old_generating_world(_generating_world, FILE_LINE); + Backup 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) { diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 0fe5e2b053..164eb4c224 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -59,7 +59,7 @@ static void GenerateDesertArea(TileIndex end, TileIndex start) { if (_game_mode != GM_EDITOR) return; - Backup old_generating_world(_generating_world, true, FILE_LINE); + Backup 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 old_generating_world(_generating_world, true, FILE_LINE); + Backup old_generating_world(_generating_world, true); /* Delete all companies */ for (Company *c : Company::Iterate()) { diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index d8d4009fd2..909fb7fc52 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -662,7 +662,7 @@ static void TileLoop_Town(TileIndex tile) } } - Backup cur_company(_current_company, OWNER_TOWN, FILE_LINE); + Backup 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 cur_company(_current_company, OWNER_TOWN, FILE_LINE); + Backup cur_company(_current_company, OWNER_TOWN); TileIndex tile = t->xy; // The tile we are working with ATM @@ -2108,7 +2108,7 @@ std::tuple CmdFoundTown(DoCommandFlag flags, TileInd return { CommandCost(EXPENSES_OTHER), cost.GetCost(), INVALID_TOWN }; } - Backup old_generating_world(_generating_world, true, FILE_LINE); + Backup 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 cur_company(_current_company, OWNER_TOWN, FILE_LINE); + Backup cur_company(_current_company, OWNER_TOWN); [[maybe_unused]] CommandCost rc = Command::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 cur_company(_current_company, OWNER_NONE, FILE_LINE); + Backup cur_company(_current_company, OWNER_NONE); CommandCost r = Command::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 cur_company(_current_company, OWNER_NONE, FILE_LINE); + Backup cur_company(_current_company, OWNER_NONE); Command::Do(DC_EXEC, statue_data.best_position); cur_company.Restore(); BuildObject(OBJECT_STATUE, statue_data.best_position, _current_company, t); diff --git a/src/town_gui.cpp b/src/town_gui.cpp index e82ed1eb2d..3a46990641 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -1236,7 +1236,7 @@ public: break; case WID_TF_MANY_RANDOM_TOWNS: { - Backup old_generating_world(_generating_world, true, FILE_LINE); + Backup 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); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index bdf76efa6c..ca5780140d 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1065,7 +1065,7 @@ void CallVehicleTicks() } } - Backup cur_company(_current_company, FILE_LINE); + Backup 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 cur_company(_current_company, v->owner, FILE_LINE); + Backup cur_company(_current_company, v->owner); CommandCost cost = std::get<0>(Command::Do(DC_EXEC, v->index, v->current_order.GetRefitCargo(), 0xFF, false, false, 0)); cur_company.Restore(); diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 7b3703ed77..f6f9e5837a 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -1120,7 +1120,7 @@ void DoFloodTile(TileIndex target) bool flooded = false; // Will be set to true if something is changed. - Backup cur_company(_current_company, OWNER_WATER, FILE_LINE); + Backup 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 cur_company(_current_company, OWNER_WATER, FILE_LINE); + Backup cur_company(_current_company, OWNER_WATER); switch (GetTileType(tile)) { case MP_RAILWAY: