Memory: Get rid of some memory leaks, converted FormationMgr back to singleton
This commit is contained in:
@@ -199,7 +199,7 @@ void Creature::RemoveFromWorld()
|
|||||||
if (m_zoneScript)
|
if (m_zoneScript)
|
||||||
m_zoneScript->OnCreatureRemove(this);
|
m_zoneScript->OnCreatureRemove(this);
|
||||||
if (m_formation)
|
if (m_formation)
|
||||||
FormationMgr::RemoveCreatureFromGroup(m_formation, this);
|
sFormationMgr->RemoveCreatureFromGroup(m_formation, this);
|
||||||
Unit::RemoveFromWorld();
|
Unit::RemoveFromWorld();
|
||||||
sObjectAccessor->RemoveObject(this);
|
sObjectAccessor->RemoveObject(this);
|
||||||
}
|
}
|
||||||
@@ -224,9 +224,9 @@ void Creature::SearchFormation()
|
|||||||
if (!lowguid)
|
if (!lowguid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CreatureGroupInfoType::iterator frmdata = CreatureGroupMap.find(lowguid);
|
CreatureGroupInfoType::iterator frmdata = sFormationMgr->CreatureGroupMap.find(lowguid);
|
||||||
if (frmdata != CreatureGroupMap.end())
|
if (frmdata != sFormationMgr->CreatureGroupMap.end())
|
||||||
FormationMgr::AddCreatureToGroup(frmdata->second->leaderGUID, this);
|
sFormationMgr->AddCreatureToGroup(frmdata->second->leaderGUID, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::RemoveCorpse(bool setSpawnTime)
|
void Creature::RemoveCorpse(bool setSpawnTime)
|
||||||
|
|||||||
@@ -24,12 +24,13 @@
|
|||||||
|
|
||||||
#define MAX_DESYNC 5.0f
|
#define MAX_DESYNC 5.0f
|
||||||
|
|
||||||
CreatureGroupInfoType CreatureGroupMap;
|
FormationMgr::~FormationMgr()
|
||||||
|
|
||||||
namespace FormationMgr
|
|
||||||
{
|
{
|
||||||
|
for (CreatureGroupInfoType::iterator itr = CreatureGroupMap.begin(); itr != CreatureGroupMap.end(); ++itr)
|
||||||
|
delete itr->second;
|
||||||
|
}
|
||||||
|
|
||||||
void AddCreatureToGroup(uint32 groupId, Creature* member)
|
void FormationMgr::AddCreatureToGroup(uint32 groupId, Creature* member)
|
||||||
{
|
{
|
||||||
Map* map = member->FindMap();
|
Map* map = member->FindMap();
|
||||||
if (!map)
|
if (!map)
|
||||||
@@ -53,7 +54,7 @@ void AddCreatureToGroup(uint32 groupId, Creature* member)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveCreatureFromGroup(CreatureGroup* group, Creature* member)
|
void FormationMgr::RemoveCreatureFromGroup(CreatureGroup* group, Creature* member)
|
||||||
{
|
{
|
||||||
sLog->outDebug(LOG_FILTER_UNITS, "Deleting member pointer to GUID: %u from group %u", group->GetId(), member->GetDBTableGUIDLow());
|
sLog->outDebug(LOG_FILTER_UNITS, "Deleting member pointer to GUID: %u from group %u", group->GetId(), member->GetDBTableGUIDLow());
|
||||||
group->RemoveMember(member);
|
group->RemoveMember(member);
|
||||||
@@ -70,7 +71,7 @@ void RemoveCreatureFromGroup(CreatureGroup* group, Creature* member)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadCreatureFormations()
|
void FormationMgr::LoadCreatureFormations()
|
||||||
{
|
{
|
||||||
uint32 oldMSTime = getMSTime();
|
uint32 oldMSTime = getMSTime();
|
||||||
|
|
||||||
@@ -97,7 +98,7 @@ void LoadCreatureFormations()
|
|||||||
fields = result->Fetch();
|
fields = result->Fetch();
|
||||||
|
|
||||||
//Load group member data
|
//Load group member data
|
||||||
group_member = new FormationInfo;
|
group_member = new FormationInfo();
|
||||||
group_member->leaderGUID = fields[0].GetUInt32();
|
group_member->leaderGUID = fields[0].GetUInt32();
|
||||||
uint32 memberGUID = fields[1].GetUInt32();
|
uint32 memberGUID = fields[1].GetUInt32();
|
||||||
group_member->groupAI = fields[4].GetUInt8();
|
group_member->groupAI = fields[4].GetUInt8();
|
||||||
@@ -139,8 +140,6 @@ void LoadCreatureFormations()
|
|||||||
sLog->outString();
|
sLog->outString();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Namespace
|
|
||||||
|
|
||||||
void CreatureGroup::AddMember(Creature* member)
|
void CreatureGroup::AddMember(Creature* member)
|
||||||
{
|
{
|
||||||
sLog->outDebug(LOG_FILTER_UNITS, "CreatureGroup::AddMember: Adding unit GUID: %u.", member->GetGUIDLow());
|
sLog->outDebug(LOG_FILTER_UNITS, "CreatureGroup::AddMember: Adding unit GUID: %u.", member->GetGUIDLow());
|
||||||
@@ -152,7 +151,7 @@ void CreatureGroup::AddMember(Creature* member)
|
|||||||
m_leader = member;
|
m_leader = member;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_members[member] = CreatureGroupMap.find(member->GetDBTableGUIDLow())->second;
|
m_members[member] = sFormationMgr->CreatureGroupMap.find(member->GetDBTableGUIDLow())->second;
|
||||||
member->SetFormation(this);
|
member->SetFormation(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +166,7 @@ void CreatureGroup::RemoveMember(Creature* member)
|
|||||||
|
|
||||||
void CreatureGroup::MemberAttackStart(Creature* member, Unit* target)
|
void CreatureGroup::MemberAttackStart(Creature* member, Unit* target)
|
||||||
{
|
{
|
||||||
uint8 groupAI = CreatureGroupMap[member->GetDBTableGUIDLow()]->groupAI;
|
uint8 groupAI = sFormationMgr->CreatureGroupMap[member->GetDBTableGUIDLow()]->groupAI;
|
||||||
if (!groupAI)
|
if (!groupAI)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -34,17 +34,20 @@ struct FormationInfo
|
|||||||
uint8 groupAI;
|
uint8 groupAI;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace FormationMgr
|
typedef UNORDERED_MAP<uint32/*memberDBGUID*/, FormationInfo*> CreatureGroupInfoType;
|
||||||
|
|
||||||
|
class FormationMgr
|
||||||
{
|
{
|
||||||
|
friend class ACE_Singleton<FormationMgr, ACE_Null_Mutex>;
|
||||||
|
public:
|
||||||
|
FormationMgr() { }
|
||||||
|
~FormationMgr();
|
||||||
void AddCreatureToGroup(uint32 group_id, Creature* creature);
|
void AddCreatureToGroup(uint32 group_id, Creature* creature);
|
||||||
void RemoveCreatureFromGroup(CreatureGroup* group, Creature* creature);
|
void RemoveCreatureFromGroup(CreatureGroup* group, Creature* creature);
|
||||||
void LoadCreatureFormations();
|
void LoadCreatureFormations();
|
||||||
|
CreatureGroupInfoType CreatureGroupMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef UNORDERED_MAP<uint32/*memberDBGUID*/, FormationInfo*> CreatureGroupInfoType;
|
|
||||||
|
|
||||||
extern CreatureGroupInfoType CreatureGroupMap;
|
|
||||||
|
|
||||||
class CreatureGroup
|
class CreatureGroup
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -73,4 +76,6 @@ class CreatureGroup
|
|||||||
void MemberAttackStart(Creature* member, Unit* target);
|
void MemberAttackStart(Creature* member, Unit* target);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define sFormationMgr ACE_Singleton<FormationMgr, ACE_Null_Mutex>::instance()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -198,6 +198,12 @@ void GmTicket::TeleportTo(Player* player) const
|
|||||||
// Ticket manager
|
// Ticket manager
|
||||||
TicketMgr::TicketMgr() : _status(true), _lastTicketId(0), _lastSurveyId(0), _openTicketCount(0), _lastChange(time(NULL)) { }
|
TicketMgr::TicketMgr() : _status(true), _lastTicketId(0), _lastSurveyId(0), _openTicketCount(0), _lastChange(time(NULL)) { }
|
||||||
|
|
||||||
|
TicketMgr::~TicketMgr()
|
||||||
|
{
|
||||||
|
for (GmTicketList::const_iterator itr = _ticketList.begin(); itr != _ticketList.end(); ++itr)
|
||||||
|
delete itr->second;
|
||||||
|
}
|
||||||
|
|
||||||
void TicketMgr::Initialize() { SetStatus(sWorld->getBoolConfig(CONFIG_ALLOW_TICKETS)); }
|
void TicketMgr::Initialize() { SetStatus(sWorld->getBoolConfig(CONFIG_ALLOW_TICKETS)); }
|
||||||
|
|
||||||
void TicketMgr::ResetTickets()
|
void TicketMgr::ResetTickets()
|
||||||
@@ -217,9 +223,7 @@ void TicketMgr::LoadTickets()
|
|||||||
{
|
{
|
||||||
uint32 oldMSTime = getMSTime();
|
uint32 oldMSTime = getMSTime();
|
||||||
|
|
||||||
if (!_ticketList.empty())
|
|
||||||
for (GmTicketList::const_iterator itr = _ticketList.begin(); itr != _ticketList.end(); ++itr)
|
for (GmTicketList::const_iterator itr = _ticketList.begin(); itr != _ticketList.end(); ++itr)
|
||||||
if (itr->second)
|
|
||||||
delete itr->second;
|
delete itr->second;
|
||||||
_ticketList.clear();
|
_ticketList.clear();
|
||||||
|
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ class TicketMgr
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
TicketMgr();
|
TicketMgr();
|
||||||
|
~TicketMgr();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadTickets();
|
void LoadTickets();
|
||||||
|
|||||||
@@ -1589,7 +1589,7 @@ void World::SetInitialWorldSettings()
|
|||||||
sSmartWaypointMgr->LoadFromDB();
|
sSmartWaypointMgr->LoadFromDB();
|
||||||
|
|
||||||
sLog->outString("Loading Creature Formations...");
|
sLog->outString("Loading Creature Formations...");
|
||||||
FormationMgr::LoadCreatureFormations();
|
sFormationMgr->LoadCreatureFormations();
|
||||||
|
|
||||||
sLog->outString("Loading World States..."); // must be loaded before battleground, outdoor PvP and conditions
|
sLog->outString("Loading World States..."); // must be loaded before battleground, outdoor PvP and conditions
|
||||||
LoadWorldStates();
|
LoadWorldStates();
|
||||||
|
|||||||
@@ -1249,7 +1249,7 @@ public:
|
|||||||
group_member->leaderGUID = leaderGUID;
|
group_member->leaderGUID = leaderGUID;
|
||||||
group_member->groupAI = 0;
|
group_member->groupAI = 0;
|
||||||
|
|
||||||
CreatureGroupMap[lowguid] = group_member;
|
sFormationMgr->CreatureGroupMap[lowguid] = group_member;
|
||||||
creature->SearchFormation();
|
creature->SearchFormation();
|
||||||
|
|
||||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE_FORMATION);
|
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE_FORMATION);
|
||||||
|
|||||||
Reference in New Issue
Block a user