mem leaks fix
This commit is contained in:
@@ -418,6 +418,11 @@ bool CraftingOrderMgr::IsIgnoring(ObjectGuid owner, ObjectGuid other) const
|
||||
return std::find(it->second.begin(), it->second.end(), other) != it->second.end();
|
||||
}
|
||||
|
||||
void CraftingOrderMgr::ClearIgnoreList(ObjectGuid owner)
|
||||
{
|
||||
_ignoreLists.erase(owner);
|
||||
}
|
||||
|
||||
bool CraftingOrderMgr::ReportPlayer(uint64 orderId, ObjectGuid reporter, ObjectGuid reported, int32 reportType,
|
||||
int32 majorCategory, int32 minorCategoryFlags, std::string const& comment) const
|
||||
{
|
||||
|
||||
@@ -118,6 +118,8 @@ public:
|
||||
// needed (it is re-synced every session). Used to reject personal orders aimed at an ignored crafter.
|
||||
void SetIgnoreList(ObjectGuid owner, std::vector<ObjectGuid> ignored);
|
||||
bool IsIgnoring(ObjectGuid owner, ObjectGuid other) const;
|
||||
// Drops the session-only ignore list of a player that is leaving the world.
|
||||
void ClearIgnoreList(ObjectGuid owner);
|
||||
|
||||
// Records a player report filed against a participant of a crafting order (CMSG_CRAFTING_ORDER_REPORT_PLAYER).
|
||||
// The report is persisted to `crafting_order_reports` (character DB) for GM review; there is no client response.
|
||||
|
||||
@@ -1463,8 +1463,14 @@ namespace
|
||||
uint32 BattlemasterListID = 0;
|
||||
uint16 Bracket = 0;
|
||||
bool TournamentRules = false;
|
||||
time_t CreatedTime = 0;
|
||||
};
|
||||
|
||||
// The client's war-game prompt times out on its own, so a challenge that was
|
||||
// ignored (or whose opponent logged off) will never be answered. Expire it
|
||||
// instead of keeping one entry per opponent leader for the whole uptime.
|
||||
constexpr uint32 WAR_GAME_REQUEST_TIMEOUT = 2 * MINUTE;
|
||||
|
||||
std::unordered_map<ObjectGuid /*opponentLeader*/, WargamePendingRequest> g_wargameRequests;
|
||||
}
|
||||
|
||||
@@ -1472,6 +1478,16 @@ void WorldSession::HandleStartWarGame(WorldPackets::Battleground::StartWarGame&
|
||||
{
|
||||
Player* initiator = _player;
|
||||
|
||||
// Drop challenges nobody answered; the prompt is long gone by now.
|
||||
time_t const now = GameTime::GetGameTime();
|
||||
for (auto itr = g_wargameRequests.begin(); itr != g_wargameRequests.end();)
|
||||
{
|
||||
if (now >= time_t(itr->second.CreatedTime) + WAR_GAME_REQUEST_TIMEOUT)
|
||||
itr = g_wargameRequests.erase(itr);
|
||||
else
|
||||
++itr;
|
||||
}
|
||||
|
||||
// Only a party leader may issue a war-game challenge on behalf of their group.
|
||||
Group* group = initiator->GetGroup();
|
||||
if (!group || group->GetLeaderGUID() != initiator->GetGUID())
|
||||
@@ -1501,6 +1517,7 @@ void WorldSession::HandleStartWarGame(WorldPackets::Battleground::StartWarGame&
|
||||
req.BattlemasterListID = packet.BattlemasterListID;
|
||||
req.Bracket = packet.Bracket;
|
||||
req.TournamentRules = packet.TournamentRules;
|
||||
req.CreatedTime = now;
|
||||
|
||||
// Prompt the opposing leader to accept or decline.
|
||||
WorldPackets::Battleground::CheckWargameEntry check;
|
||||
|
||||
@@ -677,6 +677,12 @@ Optional<HousingMgr::PendingPlotTeleport> HousingMgr::TakePendingPlotTeleport(Ob
|
||||
return pending;
|
||||
}
|
||||
|
||||
void HousingMgr::RemovePendingPlotTeleport(ObjectGuid playerGuid)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_pendingPlotTeleportsLock);
|
||||
_pendingPlotTeleports.erase(playerGuid);
|
||||
}
|
||||
|
||||
Position HousingMgr::GetDefaultHousePosition(NeighborhoodPlotData const& plot) const
|
||||
{
|
||||
// A never-moved house root sits at local (0,0,0) under the plot room (the GO row turned half a revolution).
|
||||
|
||||
@@ -275,6 +275,8 @@ public:
|
||||
};
|
||||
void SetPendingPlotTeleport(ObjectGuid playerGuid, WorldLocation const& dest, uint32 neighborhoodId);
|
||||
Optional<PendingPlotTeleport> TakePendingPlotTeleport(ObjectGuid playerGuid);
|
||||
// Drops a teleport that was never consumed (the caster left the world first).
|
||||
void RemovePendingPlotTeleport(ObjectGuid playerGuid);
|
||||
// Find a plot by its cornerstone GO entry within a specific neighborhood map
|
||||
NeighborhoodPlotData const* GetPlotByCornerstoneEntry(uint32 neighborhoodMapId, uint32 cornerstoneGoEntry) const;
|
||||
|
||||
|
||||
@@ -88,6 +88,12 @@ namespace ScriptHelpers
|
||||
{
|
||||
return player && s_forceClearedPlayers.erase(player->GetGUID().GetCounter()) > 0;
|
||||
}
|
||||
|
||||
void EraseFakePartyCleared(Player* player)
|
||||
{
|
||||
if (player)
|
||||
s_forceClearedPlayers.erase(player->GetGUID().GetCounter());
|
||||
}
|
||||
//WowCommunity
|
||||
|
||||
void SendClearFakeParty(Player* player)
|
||||
|
||||
@@ -68,6 +68,10 @@ namespace ScriptHelpers
|
||||
// when the bot composition hash is unchanged.
|
||||
TC_GAME_API bool ConsumeFakePartyCleared(Player* player);
|
||||
|
||||
// Same bookkeeping, without reporting a hit: used when a player leaves the
|
||||
// world, so a clear nobody consumed does not survive the session.
|
||||
TC_GAME_API void EraseFakePartyCleared(Player* player);
|
||||
|
||||
// Wrapper function to send a party member full state packet for a bot to a player
|
||||
// This constructs the packet internally in the core to avoid linking issues with dynamic loading
|
||||
// Takes raw bot data instead of PartyMemberStats to avoid needing PartyPackets.h in scripts
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "ChatPackets.h"
|
||||
#include "ClientConfigPackets.h"
|
||||
#include "Containers.h"
|
||||
#include "CraftingOrderMgr.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DB2Stores.h"
|
||||
#include "GameTime.h"
|
||||
@@ -53,8 +54,10 @@
|
||||
#include "Random.h"
|
||||
#include "RBAC.h"
|
||||
#include "RealmList.h"
|
||||
#include "ScriptHelpers.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "SocialMgr.h"
|
||||
#include "WeeklyRewardsMgr.h"
|
||||
#include "World.h"
|
||||
#include "WorldSocket.h"
|
||||
#include <boost/circular_buffer.hpp>
|
||||
@@ -582,6 +585,14 @@ void WorldSession::LogoutPlayer(bool save)
|
||||
sLFGListMgr.UnregisterSearch(_player->GetGUID());
|
||||
// The house finder ignore list is DB backed, drop the cached copy with the session.
|
||||
sHousingMgr.RemoveIgnoredNeighborhoods(_player->GetGUID());
|
||||
// A pending housing teleport that was never taken dies with the session.
|
||||
sHousingMgr.RemovePendingPlotTeleport(_player->GetGUID());
|
||||
// Crafting-order ignore lists are session-only; drop them with the session.
|
||||
sCraftingOrderMgr.ClearIgnoreList(_player->GetGUID());
|
||||
// Bot-roster clears nobody consumed must not outlive the session.
|
||||
ScriptHelpers::EraseFakePartyCleared(_player);
|
||||
// The Great Vault cache is written through on every change, so drop it here.
|
||||
sWeeklyRewardsMgr.UnloadCharacter(_player->GetGUID());
|
||||
//WowCommunity
|
||||
if (!_player->GetLootGUID().IsEmpty())
|
||||
DoLootReleaseAll();
|
||||
|
||||
@@ -246,6 +246,11 @@ void WeeklyRewardsMgr::SaveVault(ObjectGuid guid)
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
|
||||
void WeeklyRewardsMgr::UnloadCharacter(ObjectGuid guid)
|
||||
{
|
||||
_vaults.erase(guid);
|
||||
}
|
||||
|
||||
void WeeklyRewardsMgr::RecordActivity(Player* player, WeeklyRewards::ActivityType type, uint32 level)
|
||||
{
|
||||
if (!player || type >= WeeklyRewards::ActivityType::Max)
|
||||
|
||||
@@ -128,6 +128,8 @@ public:
|
||||
|
||||
void LoadCharacter(ObjectGuid guid); // lazy load on demand
|
||||
void SaveVault(ObjectGuid guid);
|
||||
// Drop the cached vault of a character that is leaving the world (it is saved on every mutation).
|
||||
void UnloadCharacter(ObjectGuid guid);
|
||||
|
||||
// --- Great Vault slots ---
|
||||
|
||||
|
||||
@@ -174,7 +174,9 @@ public:
|
||||
|
||||
void OnLogout(Player* player) override
|
||||
{
|
||||
_messengers.erase(player->GetGUID()); // the personal summon despawns with the player / on its own timer
|
||||
// the personal summon despawns with the player / on its own timer
|
||||
std::lock_guard<std::mutex> guard(_messengersLock);
|
||||
_messengers.erase(player->GetGUID());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
+27
-3
@@ -37,6 +37,7 @@
|
||||
#include "Creature.h"
|
||||
#include "Log.h"
|
||||
#include "Map.h"
|
||||
#include "MapManager.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Player.h"
|
||||
@@ -534,11 +535,34 @@ namespace FSBBattleground
|
||||
}
|
||||
}
|
||||
|
||||
std::unordered_map<BattlegroundMap*, std::vector<ObjectGuid>> SpawnedBotGuids;
|
||||
// Spawned bot guids are only needed while their battleground map lives, but
|
||||
// nothing tells this module when the map goes away. Store the map identity
|
||||
// with the list and drop entries whose map no longer exists whenever a bot
|
||||
// is spawned, so the store cannot grow across battlegrounds (a recycled
|
||||
// BattlegroundMap* must not inherit the previous instance's guids either).
|
||||
struct SpawnedBotGuidsEntry
|
||||
{
|
||||
uint32 MapId = 0;
|
||||
uint32 InstanceId = 0;
|
||||
std::vector<ObjectGuid> Guids;
|
||||
};
|
||||
|
||||
std::unordered_map<BattlegroundMap*, SpawnedBotGuidsEntry> SpawnedBotGuids;
|
||||
|
||||
void AddBotSpawnGuid(BattlegroundMap* battlegroundMap, ObjectGuid guid)
|
||||
{
|
||||
SpawnedBotGuids[battlegroundMap].push_back(guid);
|
||||
for (auto itr = SpawnedBotGuids.begin(); itr != SpawnedBotGuids.end();)
|
||||
{
|
||||
if (sMapMgr->FindMap(itr->second.MapId, itr->second.InstanceId) != itr->first)
|
||||
itr = SpawnedBotGuids.erase(itr);
|
||||
else
|
||||
++itr;
|
||||
}
|
||||
|
||||
SpawnedBotGuidsEntry& entry = SpawnedBotGuids[battlegroundMap];
|
||||
entry.MapId = battlegroundMap->GetId();
|
||||
entry.InstanceId = battlegroundMap->GetInstanceId();
|
||||
entry.Guids.push_back(guid);
|
||||
}
|
||||
|
||||
void ClearSpawnedBotGuids(BattlegroundMap* battlegroundMap)
|
||||
@@ -658,7 +682,7 @@ namespace FSBBattleground
|
||||
{
|
||||
static std::vector<ObjectGuid> const empty;
|
||||
auto it = SpawnedBotGuids.find(battlegroundMap);
|
||||
return it != SpawnedBotGuids.end() ? it->second : empty;
|
||||
return it != SpawnedBotGuids.end() ? it->second.Guids : empty;
|
||||
}
|
||||
|
||||
Unit* FindFriendlyAssistTarget(Creature* bot, float range)
|
||||
|
||||
@@ -2621,6 +2621,11 @@ struct FesteringStrikeBlight
|
||||
return true;
|
||||
}
|
||||
|
||||
static void Clear(ObjectGuid casterGuid)
|
||||
{
|
||||
Charges().erase(casterGuid);
|
||||
}
|
||||
|
||||
private:
|
||||
static std::unordered_map<ObjectGuid, uint32>& Charges()
|
||||
{
|
||||
@@ -2629,6 +2634,28 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
// The blight is only consumed by Scourge Strike, so a caster that logs out with
|
||||
// charges left would otherwise keep its GUID in the map for the whole uptime.
|
||||
class player_dk_festering_strike_cleanup : public PlayerScript
|
||||
{
|
||||
public:
|
||||
player_dk_festering_strike_cleanup() : PlayerScript("player_dk_festering_strike_cleanup") { }
|
||||
|
||||
void OnLogout(Player* player) override
|
||||
{
|
||||
// Only a Death Knight can apply Festering Strike's blight.
|
||||
if (player->GetClass() != CLASS_DEATH_KNIGHT)
|
||||
return;
|
||||
|
||||
FesteringStrikeBlight::Clear(player->GetGUID());
|
||||
}
|
||||
|
||||
void OnDelete(ObjectGuid guid, uint32 /*accountId*/) override
|
||||
{
|
||||
FesteringStrikeBlight::Clear(guid);
|
||||
}
|
||||
};
|
||||
|
||||
class spell_dk_festering_strike : public SpellScript
|
||||
{
|
||||
bool Validate(SpellInfo const* /*spellInfo*/) override
|
||||
@@ -3414,6 +3441,7 @@ void AddSC_deathknight_spell_scripts()
|
||||
|
||||
new player_dk_frostreaper_cleanup();
|
||||
new player_dk_on_a_paler_horse();
|
||||
new player_dk_festering_strike_cleanup();
|
||||
|
||||
RegisterAreaTriggerAI(at_dk_death_and_decay);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user