aboutsummaryrefslogtreecommitdiff
path: root/src/server/game
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2024-10-01 21:03:44 +0200
committerShauren <shauren.trinity@gmail.com>2024-10-01 21:03:44 +0200
commitb13b5142f1009a71ff06786ac8c8db92891f566a (patch)
treeda6b6ab4b0b47e5ac9b219507c9049c4b59d798b /src/server/game
parent0d496b14d54d723090ea36760ee0e8d47e53891c (diff)
Core/Utilities: Extend make_unique_ptr_with_deleter functionality to allow it to create deleters with compile time constant functions (reduces its size to just sizeof(void*))
Diffstat (limited to 'src/server/game')
-rw-r--r--src/server/game/AuctionHouse/AuctionHouseMgr.cpp11
-rw-r--r--src/server/game/Maps/TerrainMgr.cpp4
2 files changed, 5 insertions, 10 deletions
diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
index 0cf8f1f9b33..09de6c3b0ef 100644
--- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
+++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
@@ -1532,18 +1532,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;
@@ -1575,7 +1570,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)