diff options
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/bnetserver/Main.cpp | 12 | ||||
| -rw-r--r-- | src/server/bnetserver/Server/SslContext.cpp | 6 | ||||
| -rw-r--r-- | src/server/game/AuctionHouse/AuctionHouseMgr.cpp | 11 | ||||
| -rw-r--r-- | src/server/game/Maps/TerrainMgr.cpp | 4 | ||||
| -rw-r--r-- | src/server/worldserver/Main.cpp | 24 |
5 files changed, 26 insertions, 31 deletions
diff --git a/src/server/bnetserver/Main.cpp b/src/server/bnetserver/Main.cpp index cc28891ecef..bc838abb5b4 100644 --- a/src/server/bnetserver/Main.cpp +++ b/src/server/bnetserver/Main.cpp @@ -108,7 +108,7 @@ int main(int argc, char** argv) GOOGLE_PROTOBUF_VERIFY_VERSION; - auto protobufHandle = Trinity::make_unique_ptr_with_deleter(&dummy, [](void*) { google::protobuf::ShutdownProtobufLibrary(); }); + auto protobufHandle = Trinity::make_unique_ptr_with_deleter<[](void*) { google::protobuf::ShutdownProtobufLibrary(); }>(&dummy); #if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS Trinity::Service::Init(serviceLongName, serviceName, serviceDescription, &main, &m_ServiceStatus); @@ -166,7 +166,7 @@ int main(int argc, char** argv) OpenSSLCrypto::threadsSetup(boost::dll::program_location().remove_filename()); - auto opensslHandle = Trinity::make_unique_ptr_with_deleter(&dummy, [](void*) { OpenSSLCrypto::threadsCleanup(); }); + auto opensslHandle = Trinity::make_unique_ptr_with_deleter<[](void*) { OpenSSLCrypto::threadsCleanup(); }>(&dummy); // bnetserver PID file creation std::string pidFile = sConfigMgr->GetStringDefault("PidFile", ""); @@ -191,7 +191,7 @@ int main(int argc, char** argv) if (!StartDB()) return 1; - auto dbHandle = Trinity::make_unique_ptr_with_deleter(&dummy, [](void*) { StopDB(); }); + auto dbHandle = Trinity::make_unique_ptr_with_deleter<[](void*) { StopDB(); }>(&dummy); if (vm.count("update-databases-only")) return 0; @@ -219,7 +219,7 @@ int main(int argc, char** argv) return 1; } - auto sLoginServiceHandle = Trinity::make_unique_ptr_with_deleter(&sLoginService, [](Battlenet::LoginRESTService* service) { service->StopNetwork(); }); + auto sLoginServiceHandle = Trinity::make_unique_ptr_with_deleter<&Battlenet::LoginRESTService::StopNetwork>(&sLoginService); // Start the listening port (acceptor) for auth connections int32 bnport = sConfigMgr->GetIntDefault("BattlenetPort", 1119); @@ -232,7 +232,7 @@ int main(int argc, char** argv) // Get the list of realms for the server sRealmList->Initialize(*ioContext, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 10)); - auto sRealmListHandle = Trinity::make_unique_ptr_with_deleter(sRealmList, [](RealmList* realmList) { realmList->Close(); }); + auto sRealmListHandle = Trinity::make_unique_ptr_with_deleter<&RealmList::Close>(sRealmList); std::string bindIp = sConfigMgr->GetStringDefault("BindIP", "0.0.0.0"); @@ -242,7 +242,7 @@ int main(int argc, char** argv) return 1; } - auto sSessionMgrHandle = Trinity::make_unique_ptr_with_deleter(&sSessionMgr, [](Battlenet::SessionManager* sessMgr) { sessMgr->StopNetwork(); }); + auto sSessionMgrHandle = Trinity::make_unique_ptr_with_deleter<&Battlenet::SessionManager::StopNetwork>(&sSessionMgr); // Set signal handlers boost::asio::signal_set signals(*ioContext, SIGINT, SIGTERM); diff --git a/src/server/bnetserver/Server/SslContext.cpp b/src/server/bnetserver/Server/SslContext.cpp index e9192475a62..7920238c16e 100644 --- a/src/server/bnetserver/Server/SslContext.cpp +++ b/src/server/bnetserver/Server/SslContext.cpp @@ -30,7 +30,7 @@ namespace { auto CreatePasswordUiMethodFromPemCallback(::pem_password_cb* callback) { - return Trinity::make_unique_ptr_with_deleter(UI_UTIL_wrap_read_pem_callback(callback, 0), &::UI_destroy_method); + return Trinity::make_unique_ptr_with_deleter<&::UI_destroy_method>(UI_UTIL_wrap_read_pem_callback(callback, 0)); } auto OpenOpenSSLStore(boost::filesystem::path const& storePath, UI_METHOD const* passwordCallback, void* passwordCallbackData) @@ -45,7 +45,7 @@ auto OpenOpenSSLStore(boost::filesystem::path const& storePath, UI_METHOD const* uri += genericPath; - return Trinity::make_unique_ptr_with_deleter(OSSL_STORE_open(uri.c_str(), passwordCallback, passwordCallbackData, nullptr, nullptr), &::OSSL_STORE_close); + return Trinity::make_unique_ptr_with_deleter<&::OSSL_STORE_close>(OSSL_STORE_open(uri.c_str(), passwordCallback, passwordCallbackData, nullptr, nullptr)); } boost::system::error_code GetLastOpenSSLError() @@ -136,7 +136,7 @@ bool Battlenet::SslContext::Initialize() unsigned char* utf8TextRaw = nullptr; if (int utf8Length = ASN1_STRING_to_UTF8(&utf8TextRaw, text); utf8Length >= 0) { - auto utf8Text = Trinity::make_unique_ptr_with_deleter(utf8TextRaw, [](unsigned char* ptr) { ::OPENSSL_free(ptr); }); + auto utf8Text = Trinity::make_unique_ptr_with_deleter<[](unsigned char* ptr) { ::OPENSSL_free(ptr); } >(utf8TextRaw); if (std::string_view(reinterpret_cast<char const*>(utf8Text.get()), utf8Length) == "*.*") return true; } diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index d33c0348a30..b9576d9ce66 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -1530,18 +1530,13 @@ bool AuctionHouseObject::BuyCommodity(CharacterDatabaseTransaction trans, Player return false; } - auto quote = _commodityQuotes.find(player->GetGUID()); - if (quote == _commodityQuotes.end()) + auto quote = _commodityQuotes.extract(player->GetGUID()); + if (!quote) { player->GetSession()->SendAuctionCommandResult(0, AuctionCommand::PlaceBid, AuctionResult::CommodityPurchaseFailed, delayForNextAction); return false; } - std::shared_ptr<std::nullptr_t> removeQuote(nullptr, [this, quote](std::nullptr_t) - { - _commodityQuotes.erase(quote); - }); - uint64 totalPrice = 0; uint32 remainingQuantity = quantity; std::vector<AuctionPosting*> auctions; @@ -1573,7 +1568,7 @@ bool AuctionHouseObject::BuyCommodity(CharacterDatabaseTransaction trans, Player // something was bought between creating quote and finalizing transaction // but we allow lower price if new items were posted at lower price - if (totalPrice > quote->second.TotalPrice) + if (totalPrice > quote.mapped().TotalPrice) { player->GetSession()->SendAuctionCommandResult(0, AuctionCommand::PlaceBid, AuctionResult::CommodityPurchaseFailed, delayForNextAction); return false; diff --git a/src/server/game/Maps/TerrainMgr.cpp b/src/server/game/Maps/TerrainMgr.cpp index b2faa91a944..a18373dc248 100644 --- a/src/server/game/Maps/TerrainMgr.cpp +++ b/src/server/game/Maps/TerrainMgr.cpp @@ -51,7 +51,7 @@ void TerrainInfo::DiscoverGridMapFiles() { std::string tileListName = Trinity::StringFormat("{}maps/{:04}.tilelist", sWorld->GetDataPath(), GetId()); // tile list is optional - if (auto tileList = Trinity::make_unique_ptr_with_deleter(fopen(tileListName.c_str(), "rb"), &::fclose)) + if (auto tileList = Trinity::make_unique_ptr_with_deleter<&::fclose>(fopen(tileListName.c_str(), "rb"))) { u_map_magic mapMagic = { }; uint32 versionMagic = { }; @@ -79,7 +79,7 @@ bool TerrainInfo::ExistMap(uint32 mapid, int32 gx, int32 gy, bool log /*= true*/ std::string fileName = Trinity::StringFormat("{}maps/{:04}_{:02}_{:02}.map", sWorld->GetDataPath(), mapid, gx, gy); bool ret = false; - auto file = Trinity::make_unique_ptr_with_deleter(fopen(fileName.c_str(), "rb"), &::fclose); + auto file = Trinity::make_unique_ptr_with_deleter<&::fclose>(fopen(fileName.c_str(), "rb")); if (!file) { if (log) diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp index 5f846d79f59..870eb3d5b55 100644 --- a/src/server/worldserver/Main.cpp +++ b/src/server/worldserver/Main.cpp @@ -153,7 +153,7 @@ int main(int argc, char** argv) GOOGLE_PROTOBUF_VERIFY_VERSION; - auto protobufHandle = Trinity::make_unique_ptr_with_deleter(&dummy, [](void*) { google::protobuf::ShutdownProtobufLibrary(); }); + auto protobufHandle = Trinity::make_unique_ptr_with_deleter<[](void*) { google::protobuf::ShutdownProtobufLibrary(); }>(&dummy); #ifdef _WIN32 Trinity::Service::Init(serviceLongName, serviceName, serviceDescription, &main, &m_ServiceStatus); @@ -252,7 +252,7 @@ int main(int argc, char** argv) OpenSSLCrypto::threadsSetup(boost::dll::program_location().remove_filename()); - auto opensslHandle = Trinity::make_unique_ptr_with_deleter(&dummy, [](void*) { OpenSSLCrypto::threadsCleanup(); }); + auto opensslHandle = Trinity::make_unique_ptr_with_deleter<[](void*) { OpenSSLCrypto::threadsCleanup(); }>(&dummy); // Seed the OpenSSL's PRNG here. // That way it won't auto-seed when calling BigNumber::SetRand and slow down the first world login @@ -289,7 +289,7 @@ int main(int argc, char** argv) for (int i = 0; i < numThreads; ++i) threadPool->PostWork([ioContext]() { ioContext->run(); }); - auto ioContextStopHandle = Trinity::make_unique_ptr_with_deleter(ioContext.get(), [](Trinity::Asio::IoContext* ctx) { ctx->stop(); }); + auto ioContextStopHandle = Trinity::make_unique_ptr_with_deleter<&Trinity::Asio::IoContext::stop>(ioContext.get()); // Set process priority according to configuration settings SetProcessPriority("server.worldserver", sConfigMgr->GetIntDefault(CONFIG_PROCESSOR_AFFINITY, 0), sConfigMgr->GetBoolDefault(CONFIG_HIGH_PRIORITY, false)); @@ -298,7 +298,7 @@ int main(int argc, char** argv) if (!StartDB()) return 1; - auto dbHandle = Trinity::make_unique_ptr_with_deleter(&dummy, [](void*) { StopDB(); }); + auto dbHandle = Trinity::make_unique_ptr_with_deleter<[](void*) { StopDB(); }>(&dummy); if (vm.count("update-databases-only")) return 0; @@ -307,7 +307,7 @@ int main(int argc, char** argv) sRealmList->Initialize(*ioContext, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 10)); - auto sRealmListHandle = Trinity::make_unique_ptr_with_deleter(sRealmList, [](RealmList* realmList) { realmList->Close(); }); + auto sRealmListHandle = Trinity::make_unique_ptr_with_deleter<&RealmList::Close>(sRealmList); ///- Get the realm Id from the configuration file uint32 realmId = sConfigMgr->GetIntDefault("RealmID", 0); @@ -349,27 +349,27 @@ int main(int argc, char** argv) metric->Unload(); }); - auto scriptReloadMgrHandle = Trinity::make_unique_ptr_with_deleter(sScriptReloadMgr, [](ScriptReloadMgr* mgr) { mgr->Unload(); }); + auto scriptReloadMgrHandle = Trinity::make_unique_ptr_with_deleter<&ScriptReloadMgr::Unload>(sScriptReloadMgr); sScriptMgr->SetScriptLoader(AddScripts); - auto sScriptMgrHandle = Trinity::make_unique_ptr_with_deleter(sScriptMgr, [](ScriptMgr* mgr) { mgr->Unload(); }); + auto sScriptMgrHandle = Trinity::make_unique_ptr_with_deleter<&ScriptMgr::Unload>(sScriptMgr); // Initialize the World sSecretMgr->Initialize(SECRET_OWNER_WORLDSERVER); if (!sWorld->SetInitialWorldSettings()) return 1; - auto instanceLockMgrHandle = Trinity::make_unique_ptr_with_deleter(&sInstanceLockMgr, [](InstanceLockMgr* mgr) { mgr->Unload(); }); + auto instanceLockMgrHandle = Trinity::make_unique_ptr_with_deleter<&InstanceLockMgr::Unload>(&sInstanceLockMgr); - auto terrainMgrHandle = Trinity::make_unique_ptr_with_deleter(&sTerrainMgr, [](TerrainMgr* mgr) { mgr->UnloadAll(); }); + auto terrainMgrHandle = Trinity::make_unique_ptr_with_deleter<&TerrainMgr::UnloadAll>(&sTerrainMgr); - auto outdoorPvpMgrHandle = Trinity::make_unique_ptr_with_deleter(sOutdoorPvPMgr, [](OutdoorPvPMgr* mgr) { mgr->Die(); }); + auto outdoorPvpMgrHandle = Trinity::make_unique_ptr_with_deleter<&OutdoorPvPMgr::Die>(sOutdoorPvPMgr); // unload all grids (including locked in memory) - auto mapManagementHandle = Trinity::make_unique_ptr_with_deleter(sMapMgr, [](MapManager* mgr) { mgr->UnloadAll(); }); + auto mapManagementHandle = Trinity::make_unique_ptr_with_deleter<&MapManager::UnloadAll>(sMapMgr); // unload battleground templates before different singletons destroyed - auto battlegroundMgrHandle = Trinity::make_unique_ptr_with_deleter(sBattlegroundMgr, [](BattlegroundMgr* mgr) { mgr->DeleteAllBattlegrounds(); }); + auto battlegroundMgrHandle = Trinity::make_unique_ptr_with_deleter<&BattlegroundMgr::DeleteAllBattlegrounds>(sBattlegroundMgr); // Start the Remote Access port (acceptor) if enabled std::unique_ptr<AsyncAcceptor> raAcceptor; |
