Core: Move FormationMgr to namespace

Also...
- Warning fixes
- Make Singleton constructors private
This commit is contained in:
Spp
2011-09-28 11:11:38 +02:00
parent 852ffcc139
commit cc06c41887
19 changed files with 69 additions and 50 deletions

View File

@@ -254,9 +254,12 @@ struct LfgPlayerBoot
class LFGMgr
{
friend class ACE_Singleton<LFGMgr, ACE_Null_Mutex>;
public:
private:
LFGMgr();
~LFGMgr();
public:
void Update(uint32 diff);
// Reward

View File

@@ -196,7 +196,7 @@ void Creature::RemoveFromWorld()
if (m_zoneScript)
m_zoneScript->OnCreatureRemove(this);
if (m_formation)
sFormationMgr->RemoveCreatureFromGroup(m_formation, this);
FormationMgr::RemoveCreatureFromGroup(m_formation, this);
Unit::RemoveFromWorld();
sObjectAccessor->RemoveObject(this);
}
@@ -223,7 +223,7 @@ void Creature::SearchFormation()
CreatureGroupInfoType::iterator frmdata = CreatureGroupMap.find(lowguid);
if (frmdata != CreatureGroupMap.end())
sFormationMgr->AddCreatureToGroup(frmdata->second->leaderGUID, this);
FormationMgr::AddCreatureToGroup(frmdata->second->leaderGUID, this);
}
void Creature::RemoveCorpse(bool setSpawnTime)

View File

@@ -26,7 +26,10 @@
CreatureGroupInfoType CreatureGroupMap;
void CreatureGroupManager::AddCreatureToGroup(uint32 groupId, Creature* member)
namespace FormationMgr
{
void AddCreatureToGroup(uint32 groupId, Creature* member)
{
Map* map = member->FindMap();
if (!map)
@@ -50,7 +53,7 @@ void CreatureGroupManager::AddCreatureToGroup(uint32 groupId, Creature* member)
}
}
void CreatureGroupManager::RemoveCreatureFromGroup(CreatureGroup* group, Creature* member)
void RemoveCreatureFromGroup(CreatureGroup* group, Creature* member)
{
sLog->outDebug(LOG_FILTER_UNITS, "Deleting member pointer to GUID: %u from group %u", group->GetId(), member->GetDBTableGUIDLow());
group->RemoveMember(member);
@@ -67,7 +70,7 @@ void CreatureGroupManager::RemoveCreatureFromGroup(CreatureGroup* group, Creatur
}
}
void CreatureGroupManager::LoadCreatureFormations()
void LoadCreatureFormations()
{
uint32 oldMSTime = getMSTime();
@@ -151,6 +154,8 @@ void CreatureGroupManager::LoadCreatureFormations()
sLog->outString();
}
} // Namespace
void CreatureGroup::AddMember(Creature* member)
{
sLog->outDebug(LOG_FILTER_UNITS, "CreatureGroup::AddMember: Adding unit GUID: %u.", member->GetGUIDLow());

View File

@@ -19,8 +19,11 @@
#ifndef _FORMATIONS_H
#define _FORMATIONS_H
#include "Common.h"
#include "Define.h"
#include "UnorderedMap.h"
#include <map>
class Creature;
class CreatureGroup;
struct FormationInfo
@@ -31,20 +34,16 @@ struct FormationInfo
uint8 groupAI;
};
class CreatureGroupManager
namespace FormationMgr
{
friend class ACE_Singleton<CreatureGroupManager, ACE_Null_Mutex>;
public:
void AddCreatureToGroup(uint32 group_id, Creature* creature);
void RemoveCreatureFromGroup(CreatureGroup* group, Creature* creature);
void LoadCreatureFormations();
void AddCreatureToGroup(uint32 group_id, Creature* creature);
void RemoveCreatureFromGroup(CreatureGroup* group, Creature* creature);
void LoadCreatureFormations();
};
#define sFormationMgr ACE_Singleton<CreatureGroupManager, ACE_Null_Mutex>::instance()
typedef UNORDERED_MAP<uint32/*memberDBGUID*/, FormationInfo*> CreatureGroupInfoType;
extern CreatureGroupInfoType CreatureGroupMap;
extern CreatureGroupInfoType CreatureGroupMap;
class CreatureGroup
{
@@ -59,7 +58,7 @@ class CreatureGroup
public:
//Group cannot be created empty
explicit CreatureGroup(uint32 id) : m_leader(NULL), m_groupID(id), m_Formed(false) {}
~CreatureGroup() { sLog->outDebug(LOG_FILTER_UNITS, "Destroying group"); }
~CreatureGroup() {}
Creature* getLeader() const { return m_leader; }
uint32 GetId() const { return m_groupID; }

View File

@@ -221,7 +221,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa
{
case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING:
m_goValue->Building.Health = goinfo->building.intactNumHits + goinfo->building.damagedNumHits;
m_goValue->Building.MaxHealth = goinfo->building.intactNumHits + goinfo->building.damagedNumHits;
m_goValue->Building.MaxHealth = m_goValue->Building.Health;
SetGoAnimProgress(255);
break;
case GAMEOBJECT_TYPE_TRANSPORT:

View File

@@ -139,9 +139,12 @@ class PlayerSocial
class SocialMgr
{
friend class ACE_Singleton<SocialMgr, ACE_Null_Mutex>;
SocialMgr();
public:
private:
SocialMgr();
~SocialMgr();
public:
// Misc
void RemovePlayerSocial(uint32 guid) { m_socialMap.erase(guid); }

View File

@@ -12120,7 +12120,7 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell) co
// can't attack unattackable units or GMs
if (target->HasUnitState(UNIT_STAT_UNATTACKABLE)
|| target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->isGameMaster())
|| (target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->isGameMaster()))
return false;
// can't attack own vehicle or passenger
@@ -12214,7 +12214,7 @@ bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) co
// can't assist unattackable units or GMs
if (target->HasUnitState(UNIT_STAT_UNATTACKABLE)
|| target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->isGameMaster())
|| (target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->isGameMaster()))
return false;
// can't assist own vehicle or passenger

View File

@@ -86,13 +86,13 @@ class ObjectAccessor
{
friend class ACE_Singleton<ObjectAccessor, ACE_Thread_Mutex>;
friend class WorldRunnable;
ObjectAccessor();
~ObjectAccessor();
ObjectAccessor(const ObjectAccessor&);
ObjectAccessor& operator=(const ObjectAccessor&);
private:
ObjectAccessor();
~ObjectAccessor();
ObjectAccessor(const ObjectAccessor&);
ObjectAccessor& operator=(const ObjectAccessor&);
public:
typedef UNORDERED_MAP<uint64, Corpse*> Player2CorpsesMapType;
typedef UNORDERED_MAP<Player*, UpdateData>::value_type UpdateDataValueType;

View File

@@ -1191,8 +1191,7 @@ class ObjectMgr
void LoadFactionChangeSpells();
void LoadFactionChangeReputations();
protected:
private:
// first free id for selected id type
uint32 m_auctionid;
uint64 m_equipmentSetGuid;

View File

@@ -23,6 +23,7 @@
class GroupMgr
{
friend class ACE_Singleton<GroupMgr, ACE_Null_Mutex>;
private:
GroupMgr();
~GroupMgr();

View File

@@ -118,6 +118,8 @@ class InstanceSaveManager
{
friend class ACE_Singleton<InstanceSaveManager, ACE_Thread_Mutex>;
friend class InstanceSave;
private:
InstanceSaveManager() : lock_instLists(false) {};
~InstanceSaveManager();
@@ -148,10 +150,12 @@ class InstanceSaveManager
ResetTimeByMapDifficultyMap::const_iterator itr = m_resetTimeByMapDifficulty.find(MAKE_PAIR32(mapid, d));
return itr != m_resetTimeByMapDifficulty.end() ? itr->second : 0;
}
void SetResetTimeFor(uint32 mapid, Difficulty d, time_t t)
{
m_resetTimeByMapDifficulty[MAKE_PAIR32(mapid, d)] = t;
}
ResetTimeByMapDifficultyMap const& GetResetTimeMap() const
{
return m_resetTimeByMapDifficulty;
@@ -160,7 +164,8 @@ class InstanceSaveManager
void Update();
InstanceSave* AddInstanceSave(uint32 mapId, uint32 instanceId, Difficulty difficulty, time_t resetTime, bool canReset, bool load = false);
InstanceSave* AddInstanceSave(uint32 mapId, uint32 instanceId, Difficulty difficulty, time_t resetTime,
bool canReset, bool load = false);
void RemoveInstanceSave(uint32 InstanceId);
static void DeleteInstanceFromDB(uint32 instanceid);
@@ -175,7 +180,6 @@ class InstanceSaveManager
static uint16 ResetTimeDelay[];
private:
void _ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool warn, time_t resetTime);
void _ResetInstance(uint32 mapid, uint32 instanceId);
void _ResetSave(InstanceSaveHashMap::iterator &itr);

View File

@@ -38,14 +38,13 @@ struct OutdoorPvPData
// class to handle player enter / leave / areatrigger / GO use events
class OutdoorPvPMgr
{
public:
friend class ACE_Singleton<OutdoorPvPMgr, ACE_Null_Mutex>;
// ctor
private:
OutdoorPvPMgr();
// dtor
~OutdoorPvPMgr();
public:
// create outdoor pvp events
void InitOutdoorPvP();
@@ -79,12 +78,11 @@ class OutdoorPvPMgr
void HandleDropFlag(Player* plr, uint32 spellId);
private:
typedef std::vector<OutdoorPvP*> OutdoorPvPSet;
typedef std::map<uint32 /* zoneid */, OutdoorPvP*> OutdoorPvPMap;
typedef std::map<OutdoorPvPTypes, OutdoorPvPData*> OutdoorPvPDataMap;
private:
// contains all initiated outdoor pvp events
// used when initing / cleaning up
OutdoorPvPSet m_OutdoorPvPSet;

View File

@@ -105,8 +105,10 @@ typedef std::pair<PooledQuestRelation::iterator, PooledQuestRelation::iterator>
class PoolMgr
{
friend class ACE_Singleton<PoolMgr, ACE_Null_Mutex>;
PoolMgr();
~PoolMgr() {};
private:
PoolMgr();
~PoolMgr() {};
public:
void LoadFromDB();
@@ -134,7 +136,8 @@ class PoolMgr
PooledQuestRelation mQuestCreatureRelation;
PooledQuestRelation mQuestGORelation;
protected:
private:
template<typename T>
void SpawnPool(uint32 pool_id, uint32 db_guid_or_pool_id);

View File

@@ -33,13 +33,13 @@
class WorldLog
{
friend class ACE_Singleton<WorldLog, ACE_Thread_Mutex>;
WorldLog();
WorldLog(const WorldLog &);
WorldLog& operator=(const WorldLog &);
ACE_Thread_Mutex Lock;
/// Close the file in destructor
~WorldLog();
private:
WorldLog();
~WorldLog();
WorldLog(const WorldLog &);
WorldLog& operator=(const WorldLog &);
ACE_Thread_Mutex Lock;
public:
void Initialize();

View File

@@ -843,6 +843,8 @@ void Spell::SelectEffectTypeImplicitTargets(uint8 effIndex)
if (targetMask & TARGET_FLAG_UNIT_MASK)
AddUnitTarget(m_caster, 1 << effIndex, false);
break;
default:
break;
}
}

View File

@@ -162,9 +162,11 @@ typedef std::map<uint32, GmTicket*> GmTicketList;
class TicketMgr
{
TicketMgr();
friend class ACE_Singleton<TicketMgr, ACE_Null_Mutex>;
private:
TicketMgr();
public:
void LoadTickets();
void LoadSurveys();

View File

@@ -1564,7 +1564,7 @@ void World::SetInitialWorldSettings()
sSmartWaypointMgr->LoadFromDB();
sLog->outString("Loading Creature Formations...");
sFormationMgr->LoadCreatureFormations();
FormationMgr::LoadCreatureFormations();
sLog->outString("Loading Conditions...");
sConditionMgr->LoadConditions();

View File

@@ -1666,7 +1666,7 @@ class spell_pursue : public SpellScriptLoader
caster->AI()->EnterEvadeMode();
}
void HandleScript(SpellEffIndex eff)
void HandleScript(SpellEffIndex /*eff*/)
{
Creature* caster = GetCaster()->ToCreature();
if (!caster)

View File

@@ -509,7 +509,7 @@ class instance_ulduar : public InstanceMapScript
}
}
void SetData64(uint32 type, uint64 data)
void SetData64(uint32 /*type*/, uint64 /*data*/)
{
}