Get rid of Trinity Singleton and Threading patterns and replace them with ACE_Singletons and ACE_GUARD_x macro´s with ACE_Thread_Mutex´es respectively.

Also get rid of unused CountedReference class that used Trinity threading pattern.

--HG--
branch : trunk
This commit is contained in:
Machiavelli
2010-06-25 00:18:01 +02:00
parent a6b9e716a6
commit 0f7657b68c
109 changed files with 349 additions and 1221 deletions
+3 -6
View File
@@ -21,22 +21,19 @@
#include "Creature.h"
#include "CreatureAISelector.h"
#include "PassiveAI.h"
#include "SingletonImp.h"
#include "MovementGenerator.h"
#include "Pet.h"
#include "TemporarySummon.h"
#include "CreatureAIFactory.h"
#include "ScriptMgr.h"
INSTANTIATE_SINGLETON_1(CreatureAIRegistry);
INSTANTIATE_SINGLETON_1(MovementGeneratorRegistry);
namespace FactorySelector
{
CreatureAI* selectAI(Creature *creature)
{
const CreatureAICreator *ai_factory = NULL;
CreatureAIRegistry &ai_registry(CreatureAIRepository::Instance());
CreatureAIRegistry& ai_registry(*CreatureAIRepository::instance());
if (creature->isPet())
ai_factory = ai_registry.GetRegistryItem("PetAI");
@@ -106,7 +103,7 @@ namespace FactorySelector
MovementGenerator* selectMovementGenerator(Creature *creature)
{
MovementGeneratorRegistry &mv_registry(MovementGeneratorRepository::Instance());
MovementGeneratorRegistry& mv_registry(*MovementGeneratorRepository::instance());
assert(creature->GetCreatureInfo() != NULL);
const MovementGeneratorCreator *mv_factory = mv_registry.GetRegistryItem(creature->GetDefaultMovementType());
@@ -23,13 +23,10 @@
#include "CreatureEventAIMgr.h"
#include "ObjectMgr.h"
#include "ProgressBar.h"
#include "SingletonImp.h"
#include "ObjectDefines.h"
#include "GridDefines.h"
#include "ConditionMgr.h"
INSTANTIATE_SINGLETON_1(CreatureEventAIMgr);
// -------------------
void CreatureEventAIMgr::LoadCreatureEventAI_Texts()
{
@@ -24,8 +24,9 @@
class CreatureEventAIMgr
{
friend class ACE_Singleton<CreatureEventAIMgr, ACE_Null_Mutex>;
CreatureEventAIMgr(){};
public:
CreatureEventAIMgr(){};
~CreatureEventAIMgr(){};
void LoadCreatureEventAI_Texts();
@@ -42,5 +43,5 @@ class CreatureEventAIMgr
CreatureEventAI_TextMap m_CreatureEventAI_TextMap;
};
#define CreatureEAI_Mgr Trinity::Singleton<CreatureEventAIMgr>::Instance()
#define CreatureEAI_Mgr (*ACE_Singleton<CreatureEventAIMgr, ACE_Null_Mutex>::instance())
#endif
+1 -3
View File
@@ -19,7 +19,7 @@
*/
#include "DatabaseEnv.h"
#include "SingletonImp.h"
#include "AccountMgr.h"
#include "ObjectAccessor.h"
@@ -29,8 +29,6 @@
extern DatabaseType LoginDatabase;
INSTANTIATE_SINGLETON_1(AccountMgr);
AccountMgr::AccountMgr()
{}
+1 -2
View File
@@ -24,7 +24,6 @@
#include <string>
#include "Common.h"
#include "Singleton.h"
enum AccountOpResult
{
@@ -59,6 +58,6 @@ class AccountMgr
static bool normalizeString(std::string& utf8str);
};
#define accmgr Trinity::Singleton<AccountMgr>::Instance()
#define accmgr (*ACE_Singleton<AccountMgr, ACE_Null_Mutex>::instance())
#endif
@@ -22,7 +22,7 @@
#include "World.h"
#include "WorldPacket.h"
#include "DatabaseEnv.h"
#include "SingletonImp.h"
#include "AchievementMgr.h"
#include "ArenaTeam.h"
@@ -41,8 +41,6 @@
#include "Map.h"
#include "InstanceData.h"
INSTANTIATE_SINGLETON_1(AchievementGlobalMgr);
namespace Trinity
{
class AchievementChatBuilder
@@ -965,7 +963,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
if (!miscvalue1)
continue;
Map const* map = GetPlayer()->IsInWorld() ? GetPlayer()->GetMap() : MapManager::Instance().FindMap(GetPlayer()->GetMapId(), GetPlayer()->GetInstanceId());
Map const* map = GetPlayer()->IsInWorld() ? GetPlayer()->GetMap() : sMapMgr.FindMap(GetPlayer()->GetMapId(), GetPlayer()->GetInstanceId());
if (!map || !map->IsDungeon())
continue;
@@ -22,7 +22,7 @@
#include <string>
#include "Common.h"
#include "Singleton.h"
#include "ace/Singleton.h"
#include "DatabaseEnv.h"
#include "DBCEnums.h"
#include "DBCStores.h"
@@ -342,6 +342,6 @@ class AchievementGlobalMgr
AchievementRewardLocales m_achievementRewardLocales;
};
#define achievementmgr Trinity::Singleton<AchievementGlobalMgr>::Instance()
#define achievementmgr (*ACE_Singleton<AchievementGlobalMgr, ACE_Null_Mutex>::instance())
#endif
+1 -3
View File
@@ -19,7 +19,7 @@
*/
#include "DatabaseEnv.h"
#include "SingletonImp.h"
#include "AddonMgr.h"
#include "ObjectAccessor.h"
@@ -30,8 +30,6 @@
extern DatabaseType LoginDatabase;
INSTANTIATE_SINGLETON_1(AddonMgr);
AddonMgr::AddonMgr()
{
}
+4 -3
View File
@@ -22,7 +22,7 @@
#define _ADDONMGR_H
#include "Common.h"
#include "Singleton.h"
#include "ace/Singleton.h"
#include <string>
@@ -68,9 +68,10 @@ typedef std::list<SavedAddon> SavedAddonsList;
class AddonMgr
{
friend class ACE_Singleton<AddonMgr, ACE_Null_Mutex>;
AddonMgr();
public:
AddonMgr();
~AddonMgr();
void LoadFromDB();
@@ -83,7 +84,7 @@ class AddonMgr
SavedAddonsList m_knownAddons; // Known addons.
};
#define sAddonMgr Trinity::Singleton<AddonMgr>::Instance()
#define sAddonMgr (*ACE_Singleton<AddonMgr, ACE_Null_Mutex>::instance())
#endif
@@ -3,8 +3,7 @@
#include "AuctionHouseBot.h"
#include <vector>
#include "SingletonImp.h"
INSTANTIATE_SINGLETON_1(AuctionHouseBot);
using namespace std;
vector<uint32> npcItems;
@@ -693,7 +692,7 @@ void AuctionHouseBot::Update()
WorldSession _session(AHBplayerAccount, NULL, SEC_PLAYER, true, 0, LOCALE_enUS);
Player _AHBplayer(&_session);
_AHBplayer.Initialize(AHBplayerGUID);
ObjectAccessor::Instance().AddObject(&_AHBplayer);
sObjectAccessor.AddObject(&_AHBplayer);
// Add New Bids
if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
@@ -725,7 +724,7 @@ void AuctionHouseBot::Update()
addNewAuctionBuyerBotBid(&_AHBplayer, &NeutralConfig, &_session);
_lastrun_n = _newrun;
}
ObjectAccessor::Instance().RemoveObject(&_AHBplayer);
sObjectAccessor.RemoveObject(&_AHBplayer);
}
void AuctionHouseBot::Initialize()
@@ -1207,9 +1207,11 @@ private:
inline uint32 minValue(uint32 a, uint32 b) { return a <= b ? a : b; };
void addNewAuctions(Player *AHBplayer, AHBConfig *config);
void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, WorldSession *session);
friend class ACE_Singleton<AuctionHouseBot, ACE_Null_Mutex>;
AuctionHouseBot();
public:
AuctionHouseBot();
~AuctionHouseBot();
void Update();
void Initialize();
@@ -1220,6 +1222,6 @@ public:
uint32 GetAHBplayerGUID() { return AHBplayerGUID; };
};
#define auctionbot Trinity::Singleton<AuctionHouseBot>::Instance()
#define auctionbot (*ACE_Singleton<AuctionHouseBot, ACE_Null_Mutex>::instance())
#endif
@@ -24,7 +24,7 @@
#include "WorldSession.h"
#include "DatabaseEnv.h"
#include "SQLStorage.h"
#include "SingletonImp.h"
#include "DBCStores.h"
#include "AccountMgr.h"
@@ -35,8 +35,6 @@
#include "ProgressBar.h"
#include <vector>
INSTANTIATE_SINGLETON_1(AuctionHouseMgr);
using namespace std;
AuctionHouseMgr::AuctionHouseMgr()
+34 -32
View File
@@ -21,7 +21,7 @@
#ifndef _AUCTION_HOUSE_MGR_H
#define _AUCTION_HOUSE_MGR_H
#include "Singleton.h"
#include "ace/Singleton.h"
#include "SharedDefines.h"
@@ -121,51 +121,53 @@ class AuctionHouseObject
class AuctionHouseMgr
{
public:
friend class ACE_Singleton<AuctionHouseMgr, ACE_Null_Mutex>;
AuctionHouseMgr();
~AuctionHouseMgr();
public:
~AuctionHouseMgr();
typedef UNORDERED_MAP<uint32, Item*> ItemMap;
typedef UNORDERED_MAP<uint32, Item*> ItemMap;
AuctionHouseObject* GetAuctionsMap(uint32 factionTemplateId);
AuctionHouseObject* GetBidsMap(uint32 factionTemplateId);
AuctionHouseObject* GetAuctionsMap(uint32 factionTemplateId);
AuctionHouseObject* GetBidsMap(uint32 factionTemplateId);
Item* GetAItem(uint32 id)
{
ItemMap::const_iterator itr = mAitems.find(id);
if (itr != mAitems.end())
Item* GetAItem(uint32 id)
{
return itr->second;
ItemMap::const_iterator itr = mAitems.find(id);
if (itr != mAitems.end())
{
return itr->second;
}
return NULL;
}
return NULL;
}
//auction messages
void SendAuctionWonMail(AuctionEntry * auction);
void SendAuctionSalePendingMail(AuctionEntry * auction);
void SendAuctionSuccessfulMail(AuctionEntry * auction);
void SendAuctionExpiredMail(AuctionEntry * auction);
static uint32 GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem);
static AuctionHouseEntry const* GetAuctionHouseEntry(uint32 factionTemplateId);
//auction messages
void SendAuctionWonMail(AuctionEntry * auction);
void SendAuctionSalePendingMail(AuctionEntry * auction);
void SendAuctionSuccessfulMail(AuctionEntry * auction);
void SendAuctionExpiredMail(AuctionEntry * auction);
static uint32 GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem);
static AuctionHouseEntry const* GetAuctionHouseEntry(uint32 factionTemplateId);
public:
public:
//load first auction items, because of check if item exists, when loading
void LoadAuctionItems();
void LoadAuctions();
void LoadAuctionItems();
void LoadAuctions();
void AddAItem(Item* it);
bool RemoveAItem(uint32 id);
void AddAItem(Item* it);
bool RemoveAItem(uint32 id);
void Update();
void Update();
private:
AuctionHouseObject mHordeAuctions;
AuctionHouseObject mAllianceAuctions;
AuctionHouseObject mNeutralAuctions;
private:
AuctionHouseObject mHordeAuctions;
AuctionHouseObject mAllianceAuctions;
AuctionHouseObject mNeutralAuctions;
ItemMap mAitems;
ItemMap mAitems;
};
#define auctionmgr Trinity::Singleton<AuctionHouseMgr>::Instance()
#define auctionmgr (*ACE_Singleton<AuctionHouseMgr, ACE_Null_Mutex>::instance())
#endif
@@ -323,7 +323,7 @@ void BattleGround::Update(uint32 diff)
plr->ResurrectPlayer(1.0f);
plr->CastSpell(plr, 6962, true);
plr->CastSpell(plr, SPELL_SPIRIT_HEAL_MANA, true);
ObjectAccessor::Instance().ConvertCorpseForPlayer(*itr);
sObjectAccessor.ConvertCorpseForPlayer(*itr);
}
m_ResurrectQueue.clear();
}
@@ -1525,7 +1525,7 @@ Creature* BattleGround::AddCreature(uint32 entry, uint32 type, uint32 teamval, f
/*
void BattleGround::SpawnBGCreature(uint32 type, uint32 respawntime)
{
Map * map = MapManager::Instance().FindMap(GetMapId(),GetInstanceId());
Map * map = sMapMgr.FindMap(GetMapId(),GetInstanceId());
if (!map)
return false;
@@ -22,7 +22,7 @@
#include "ObjectMgr.h"
#include "World.h"
#include "WorldPacket.h"
#include "SingletonImp.h"
#include "ArenaTeam.h"
#include "BattleGroundMgr.h"
@@ -49,8 +49,6 @@
#include "SharedDefines.h"
#include "Formulas.h"
INSTANTIATE_SINGLETON_1(BattleGroundMgr);
/*********************************************************/
/*** BATTLEGROUND QUEUE SYSTEM ***/
/*********************************************************/
@@ -1630,7 +1628,7 @@ BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeI
}
// generate a new instance id
bg->SetInstanceID(MapManager::Instance().GenerateInstanceId()); // set instance id
bg->SetInstanceID(sMapMgr.GenerateInstanceId()); // set instance id
bg->SetClientInstanceID(CreateClientVisibleInstanceId(isRandom ? BATTLEGROUND_RB : bgTypeId, bracketEntry->GetBracketId()));
// reset the new bg (set status to status_wait_queue from status_none)
@@ -22,7 +22,7 @@
#define __BATTLEGROUNDMGR_H
#include "Common.h"
#include "Singleton.h"
#include "ace/Singleton.h"
#include "DBCEnums.h"
#include "BattleGround.h"
@@ -180,9 +180,12 @@ class BGQueueRemoveEvent : public BasicEvent
class BattleGroundMgr
{
/// Todo: Thread safety?
/* Construction */
friend class ACE_Singleton<BattleGroundMgr, ACE_Null_Mutex>;
BattleGroundMgr();
public:
/* Construction */
BattleGroundMgr();
~BattleGroundMgr();
void Update(uint32 diff);
@@ -271,6 +274,6 @@ class BattleGroundMgr
bool m_Testing;
};
#define sBattleGroundMgr Trinity::Singleton<BattleGroundMgr>::Instance()
#define sBattleGroundMgr (*ACE_Singleton<BattleGroundMgr, ACE_Null_Mutex>::instance())
#endif
+4 -7
View File
@@ -17,21 +17,18 @@
*/
#include "ChannelMgr.h"
#include "SingletonImp.h"
#include "World.h"
INSTANTIATE_SINGLETON_1(AllianceChannelMgr);
INSTANTIATE_SINGLETON_1(HordeChannelMgr);
#include "World.h"
ChannelMgr* channelMgr(uint32 team)
{
if (sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
return &Trinity::Singleton<AllianceChannelMgr>::Instance(); // cross-faction
return ACE_Singleton<AllianceChannelMgr, ACE_Null_Mutex>::instance(); // cross-faction
if (team == ALLIANCE)
return &Trinity::Singleton<AllianceChannelMgr>::Instance();
return ACE_Singleton<AllianceChannelMgr, ACE_Null_Mutex>::instance();
if (team == HORDE)
return &Trinity::Singleton<HordeChannelMgr>::Instance();
return ACE_Singleton<HordeChannelMgr, ACE_Null_Mutex>::instance();
return NULL;
}
+1 -1
View File
@@ -22,7 +22,7 @@
#include "Common.h"
#include "Channel.h"
#include "Singleton.h"
#include "ace/Singleton.h"
#include <map>
#include <string>
+2 -2
View File
@@ -165,8 +165,8 @@ bool ChatHandler::HandleGMListIngameCommand(const char* /*args*/)
{
bool first = true;
ObjectAccessor::Guard guard(*HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType &m = ObjectAccessor::Instance().GetPlayers();
ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, *HashMapHolder<Player>::GetLock(), true);
HashMapHolder<Player>::MapType &m = sObjectAccessor.GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
{
AccountTypes itr_sec = itr->second->GetSession()->GetSecurity();
+5 -5
View File
@@ -2381,7 +2381,7 @@ bool ChatHandler::HandleWhispersCommand(const char* args)
//Save all players in the world
bool ChatHandler::HandleSaveAllCommand(const char* /*args*/)
{
ObjectAccessor::Instance().SaveAllPlayers();
sObjectAccessor.SaveAllPlayers();
SendSysMessage(LANG_PLAYERS_SAVED);
return true;
}
@@ -2502,7 +2502,7 @@ bool ChatHandler::HandleTeleNameCommand(const char * args)
PSendSysMessage(LANG_TELEPORTING_TO, nameLink.c_str(), GetTrinityString(LANG_OFFLINE), tele->name.c_str());
Player::SavePositionInDB(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation,
MapManager::Instance().GetZoneId(tele->mapId,tele->position_x,tele->position_y,tele->position_z),target_guid);
sMapMgr.GetZoneId(tele->mapId,tele->position_x,tele->position_y,tele->position_z),target_guid);
}
return true;
@@ -2768,7 +2768,7 @@ bool ChatHandler::HandleGoXYCommand(const char* args)
else
_player->SaveRecallPosition();
Map const *map = MapManager::Instance().CreateBaseMap(mapid);
Map const *map = sMapMgr.CreateBaseMap(mapid);
float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
_player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
@@ -2861,7 +2861,7 @@ bool ChatHandler::HandleGoZoneXYCommand(const char* args)
// update to parent zone if exist (client map show only zones without parents)
AreaTableEntry const* zoneEntry = areaEntry->zone ? GetAreaEntryByAreaID(areaEntry->zone) : areaEntry;
Map const *map = MapManager::Instance().CreateBaseMap(zoneEntry->mapid);
Map const *map = sMapMgr.CreateBaseMap(zoneEntry->mapid);
if (map->Instanceable())
{
@@ -2936,7 +2936,7 @@ bool ChatHandler::HandleGoGridCommand(const char* args)
else
_player->SaveRecallPosition();
Map const *map = MapManager::Instance().CreateBaseMap(mapid);
Map const *map = sMapMgr.CreateBaseMap(mapid);
float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
_player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
+1 -1
View File
@@ -2844,7 +2844,7 @@ bool ChatHandler::HandleWpModifyCommand(const char* args)
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
wpCreature2->LoadFromDB(wpCreature2->GetDBTableGUIDLow(), map);
map->Add(wpCreature2);
//MapManager::Instance().GetMap(npcCreature->GetMapId())->Add(wpCreature2);
//sMapMgr.GetMap(npcCreature->GetMapId())->Add(wpCreature2);
}
WorldDatabase.PExecuteLog("UPDATE waypoint_data SET position_x = '%f',position_y = '%f',position_z = '%f' where id = '%u' AND point='%u'",
+6 -6
View File
@@ -689,7 +689,7 @@ bool ChatHandler::HandleReloadConfigCommand(const char* /*args*/)
{
sLog.outString("Re-Loading config settings...");
sWorld.LoadConfigSettings(true);
MapManager::Instance().InitializeVisibilityDistanceInfo();
sMapMgr.InitializeVisibilityDistanceInfo();
SendGlobalGMSysMessage("World config settings reloaded.");
return true;
}
@@ -4513,7 +4513,7 @@ bool ChatHandler::HandleReviveCommand(const char *args)
}
else
// will resurrected at login without corpse
ObjectAccessor::Instance().ConvertCorpseForPlayer(target_guid);
sObjectAccessor.ConvertCorpseForPlayer(target_guid);
return true;
}
@@ -5533,8 +5533,8 @@ bool ChatHandler::HandleResetAllCommand(const char * args)
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE (at_login & '%u') = '0'",atLogin,atLogin);
ObjectAccessor::Guard guard(*HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType const& plist = ObjectAccessor::Instance().GetPlayers();
ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, *HashMapHolder<Player>::GetLock(), true);
HashMapHolder<Player>::MapType const& plist = sObjectAccessor.GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr)
itr->second->SetAtLoginFlag(atLogin);
@@ -7020,8 +7020,8 @@ bool ChatHandler::HandleInstanceUnbindCommand(const char *args)
bool ChatHandler::HandleInstanceStatsCommand(const char* /*args*/)
{
PSendSysMessage("instances loaded: %d", MapManager::Instance().GetNumInstances());
PSendSysMessage("players in instances: %d", MapManager::Instance().GetNumPlayersInInstances());
PSendSysMessage("instances loaded: %d", sMapMgr.GetNumInstances());
PSendSysMessage("players in instances: %d", sMapMgr.GetNumPlayersInInstances());
PSendSysMessage("instance saves: %d", sInstanceSaveManager.GetNumInstanceSaves());
PSendSysMessage("players bound: %d", sInstanceSaveManager.GetNumBoundPlayersTotal());
PSendSysMessage("groups bound: %d", sInstanceSaveManager.GetNumBoundGroupsTotal());
+1 -3
View File
@@ -19,7 +19,7 @@
*/
#include "SingletonImp.h"
#include "Player.h"
#include "SpellAuras.h"
#include "SpellMgr.h"
@@ -29,8 +29,6 @@
#include "InstanceData.h"
#include "ConditionMgr.h"
INSTANTIATE_SINGLETON_1(ConditionMgr);
// Checks if player meets the condition
// Can have CONDITION_SOURCE_TYPE_NONE && !mReferenceId if called from a special event (ie: eventAI)
bool Condition::Meets(Player * player, Unit* targetOverride)
+4 -2
View File
@@ -121,8 +121,10 @@ typedef std::map<uint32, ConditionList > ConditionReferenceMap;//only used for r
class ConditionMgr
{
friend class ACE_Singleton<ConditionMgr, ACE_Null_Mutex>;
ConditionMgr();
public:
ConditionMgr();
~ConditionMgr();
void LoadConditions(bool isReload = false);
@@ -165,6 +167,6 @@ class ConditionMgr
std::list<Condition*> m_AllocatedMemory; // some garbage collection :)
};
#define sConditionMgr Trinity::Singleton<ConditionMgr>::Instance()
#define sConditionMgr (*ACE_Singleton<ConditionMgr, ACE_Null_Mutex>::instance())
#endif
+1 -1
View File
@@ -19,7 +19,7 @@
*/
#include "DBCStores.h"
#include "SingletonImp.h"
#include "Logging/Log.h"
#include "ProgressBar.h"
#include "SharedDefines.h"
+1 -3
View File
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "SingletonImp.h"
#include "Common.h"
#include "SharedDefines.h"
#include "Group.h"
@@ -24,8 +24,6 @@
#include "ObjectMgr.h"
#include "WorldPacket.h"
INSTANTIATE_SINGLETON_1(LFGMgr);
/*********************************************************/
/*** LFG QUEUES ***/
/*********************************************************/
+33 -32
View File
@@ -20,7 +20,7 @@
#define _LFGMGR_H
#include "Common.h"
#include "Singleton.h"
#include "ace/Singleton.h"
#include "Group.h"
#include "LFG.h"
@@ -237,43 +237,44 @@ typedef std::map<uint8, LFGQueue *> LFGQueueMap;
class LFGMgr
{
public:
friend class ACE_Singleton<LFGMgr, ACE_Null_Mutex>;
LFGMgr();
~LFGMgr();
public:
~LFGMgr();
void InitLFG();
void SendLfgPlayerInfo(Player *plr);
void SendLfgPartyInfo(Player *plr);
void Join(Player *plr);
void Leave(Player *plr, Group *grp = NULL);
void UpdateRoleCheck(Group *grp, Player *plr = NULL);
void Update(uint32 diff);
void InitLFG();
void SendLfgPlayerInfo(Player *plr);
void SendLfgPartyInfo(Player *plr);
void Join(Player *plr);
void Leave(Player *plr, Group *grp = NULL);
void UpdateRoleCheck(Group *grp, Player *plr = NULL);
void Update(uint32 diff);
private:
void BuildLfgRoleCheck(WorldPacket &data, LfgRoleCheck *pRoleCheck);
void BuildAvailableRandomDungeonList(WorldPacket &data, Player *plr);
void BuildRewardBlock(WorldPacket &data, uint32 dungeon, Player *plr);
void BuildPlayerLockDungeonBlock(WorldPacket &data, LfgLockStatusSet *lockSet);
void BuildPartyLockDungeonBlock(WorldPacket &data, LfgLockStatusMap *lockMap);
bool CheckGroupRoles(LfgRolesMap &groles, bool removeLeaderFlag = true);
private:
void BuildLfgRoleCheck(WorldPacket &data, LfgRoleCheck *pRoleCheck);
void BuildAvailableRandomDungeonList(WorldPacket &data, Player *plr);
void BuildRewardBlock(WorldPacket &data, uint32 dungeon, Player *plr);
void BuildPlayerLockDungeonBlock(WorldPacket &data, LfgLockStatusSet *lockSet);
void BuildPartyLockDungeonBlock(WorldPacket &data, LfgLockStatusMap *lockMap);
bool CheckGroupRoles(LfgRolesMap &groles, bool removeLeaderFlag = true);
LfgLockStatusMap* GetPartyLockStatusDungeons(Player *plr, LfgDungeonSet *dungeons);
LfgLockStatusSet* GetPlayerLockStatusDungeons(Player *plr, LfgDungeonSet *dungeons);
LfgDungeonSet* GetRandomDungeons(uint8 level, uint8 expansion);
LfgDungeonSet* GetDungeonsByRandom(uint32 randomdungeon);
LfgDungeonSet* GetAllDungeons();
LfgReward* GetRandomDungeonReward(uint32 dungeon, bool done, uint8 level);
uint8 GetDungeonGroupType(uint32 dungeon);
LfgLockStatusMap* GetPartyLockStatusDungeons(Player *plr, LfgDungeonSet *dungeons);
LfgLockStatusSet* GetPlayerLockStatusDungeons(Player *plr, LfgDungeonSet *dungeons);
LfgDungeonSet* GetRandomDungeons(uint8 level, uint8 expansion);
LfgDungeonSet* GetDungeonsByRandom(uint32 randomdungeon);
LfgDungeonSet* GetAllDungeons();
LfgReward* GetRandomDungeonReward(uint32 dungeon, bool done, uint8 level);
uint8 GetDungeonGroupType(uint32 dungeon);
LfgRewardList m_RewardList;
LfgRewardList m_RewardDoneList;
LfgDungeonMap m_DungeonsMap;
LfgRewardList m_RewardList;
LfgRewardList m_RewardDoneList;
LfgDungeonMap m_DungeonsMap;
LFGQueueMap m_Queues;
LfgRoleCheckMap m_RoleChecks;
uint32 m_QueueTimer;
bool m_update;
LFGQueueMap m_Queues;
LfgRoleCheckMap m_RoleChecks;
uint32 m_QueueTimer;
bool m_update;
};
#define sLFGMgr Trinity::Singleton<LFGMgr>::Instance()
#define sLFGMgr (*ACE_Singleton<LFGMgr, ACE_Null_Mutex>::instance())
#endif
+2 -2
View File
@@ -54,7 +54,7 @@ void Corpse::AddToWorld()
{
///- Register the corpse for guid lookup
if (!IsInWorld())
ObjectAccessor::Instance().AddObject(this);
sObjectAccessor.AddObject(this);
Object::AddToWorld();
}
@@ -63,7 +63,7 @@ void Corpse::RemoveFromWorld()
{
///- Remove the corpse from the accessor
if (IsInWorld())
ObjectAccessor::Instance().RemoveObject(this);
sObjectAccessor.RemoveObject(this);
Object::RemoveFromWorld();
}
@@ -49,7 +49,7 @@
#include "Vehicle.h"
#include "SpellAuraEffects.h"
// apply implementation of the singletons
#include "SingletonImp.h"
TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const
{
@@ -185,7 +185,7 @@ void Creature::AddToWorld()
{
if (m_zoneScript)
m_zoneScript->OnCreatureCreate(this, true);
ObjectAccessor::Instance().AddObject(this);
sObjectAccessor.AddObject(this);
Unit::AddToWorld();
SearchFormation();
AIM_Initialize();
@@ -203,7 +203,7 @@ void Creature::RemoveFromWorld()
if (m_formation)
formation_mgr.RemoveCreatureFromGroup(m_formation, this);
Unit::RemoveFromWorld();
ObjectAccessor::Instance().RemoveObject(this);
sObjectAccessor.RemoveObject(this);
}
}
@@ -2410,7 +2410,7 @@ time_t Creature::GetLinkedCreatureRespawnTime() const
if (data->mapid == GetMapId()) // look up on the same map
targetMap = GetMap();
else // it shouldn't be instanceable map here
targetMap = MapManager::Instance().FindMap(data->mapid);
targetMap = sMapMgr.FindMap(data->mapid);
}
if (targetMap)
return objmgr.GetCreatureRespawnTime(targetGuid,targetMap->GetInstanceId());
+1 -1
View File
@@ -700,7 +700,7 @@ class Creature : public Unit, public GridObject<Creature>
bool DisableReputationGain;
CreatureInfo const* m_creatureInfo; // in difficulty mode > 0 can different from ObjMgr::GetCreatureTemplate(GetEntry())
CreatureInfo const* m_creatureInfo; // in difficulty mode > 0 can different from objmgr.::GetCreatureTemplate(GetEntry())
CreatureData const* m_creatureData;
uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
@@ -22,13 +22,11 @@
#include "CreatureGroups.h"
#include "ObjectMgr.h"
#include "ProgressBar.h"
#include "SingletonImp.h"
#include "CreatureAI.h"
#define MAX_DESYNC 5.0f
INSTANTIATE_SINGLETON_1(CreatureGroupManager);
CreatureGroupInfoType CreatureGroupMap;
void CreatureGroupManager::AddCreatureToGroup(uint32 groupId, Creature *member)
@@ -35,12 +35,15 @@ struct FormationInfo
class CreatureGroupManager
{
friend class ACE_Singleton<CreatureGroupManager, ACE_Null_Mutex>;
public:
void AddCreatureToGroup(uint32 group_id, Creature *creature);
void RemoveCreatureFromGroup(CreatureGroup *group, Creature *creature);
void LoadCreatureFormations();
};
#define formation_mgr (*ACE_Singleton<CreatureGroupManager, ACE_Null_Mutex>::instance())
typedef UNORDERED_MAP<uint32/*memberDBGUID*/, FormationInfo*> CreatureGroupInfoType;
extern CreatureGroupInfoType CreatureGroupMap;
@@ -73,6 +76,4 @@ class CreatureGroup
void MemberAttackStart(Creature* member, Unit *target);
};
#define formation_mgr Trinity::Singleton<CreatureGroupManager>::Instance()
#endif
@@ -46,7 +46,7 @@ void DynamicObject::AddToWorld()
///- Register the dynamicObject for guid lookup
if (!IsInWorld())
{
ObjectAccessor::Instance().AddObject(this);
sObjectAccessor.AddObject(this);
WorldObject::AddToWorld();
}
}
@@ -69,7 +69,7 @@ void DynamicObject::RemoveFromWorld()
}
}
WorldObject::RemoveFromWorld();
ObjectAccessor::Instance().RemoveObject(this);
sObjectAccessor.RemoveObject(this);
}
}
@@ -117,7 +117,7 @@ void GameObject::AddToWorld()
if (m_zoneScript)
m_zoneScript->OnGameObjectCreate(this, true);
ObjectAccessor::Instance().AddObject(this);
sObjectAccessor.AddObject(this);
WorldObject::AddToWorld();
}
}
@@ -139,7 +139,7 @@ void GameObject::RemoveFromWorld()
sLog.outError("Delete GameObject (GUID: %u Entry: %u) that have references in not found creature %u GO list. Crash possible later.",GetGUIDLow(),GetGOInfo()->id,GUID_LOPART(owner_guid));
}
WorldObject::RemoveFromWorld();
ObjectAccessor::Instance().RemoveObject(this);
sObjectAccessor.RemoveObject(this);
}
}
+15 -15
View File
@@ -110,7 +110,7 @@ Object::~Object()
{
sLog.outCrash("Object::~Object - guid="UI64FMTD", typeid=%d, entry=%u deleted but still in update list!!", GetGUID(), GetTypeId(), GetEntry());
assert(false);
ObjectAccessor::Instance().RemoveUpdateObject(this);
sObjectAccessor.RemoveUpdateObject(this);
}
delete [] m_uint32Values;
@@ -731,7 +731,7 @@ void Object::ClearUpdateMask(bool remove)
if (m_objectUpdated)
{
if (remove)
ObjectAccessor::Instance().RemoveUpdateObject(this);
sObjectAccessor.RemoveUpdateObject(this);
m_objectUpdated = false;
}
}
@@ -804,7 +804,7 @@ void Object::SetInt32Value(uint16 index, int32 value)
{
if (!m_objectUpdated)
{
ObjectAccessor::Instance().AddUpdateObject(this);
sObjectAccessor.AddUpdateObject(this);
m_objectUpdated = true;
}
}
@@ -823,7 +823,7 @@ void Object::SetUInt32Value(uint16 index, uint32 value)
{
if (!m_objectUpdated)
{
ObjectAccessor::Instance().AddUpdateObject(this);
sObjectAccessor.AddUpdateObject(this);
m_objectUpdated = true;
}
}
@@ -849,7 +849,7 @@ void Object::SetUInt64Value(uint16 index, const uint64 &value)
{
if (!m_objectUpdated)
{
ObjectAccessor::Instance().AddUpdateObject(this);
sObjectAccessor.AddUpdateObject(this);
m_objectUpdated = true;
}
}
@@ -868,7 +868,7 @@ bool Object::AddUInt64Value(uint16 index, const uint64 &value)
{
if (!m_objectUpdated)
{
ObjectAccessor::Instance().AddUpdateObject(this);
sObjectAccessor.AddUpdateObject(this);
m_objectUpdated = true;
}
}
@@ -889,7 +889,7 @@ bool Object::RemoveUInt64Value(uint16 index, const uint64 &value)
{
if (!m_objectUpdated)
{
ObjectAccessor::Instance().AddUpdateObject(this);
sObjectAccessor.AddUpdateObject(this);
m_objectUpdated = true;
}
}
@@ -910,7 +910,7 @@ void Object::SetFloatValue(uint16 index, float value)
{
if (!m_objectUpdated)
{
ObjectAccessor::Instance().AddUpdateObject(this);
sObjectAccessor.AddUpdateObject(this);
m_objectUpdated = true;
}
}
@@ -936,7 +936,7 @@ void Object::SetByteValue(uint16 index, uint8 offset, uint8 value)
{
if (!m_objectUpdated)
{
ObjectAccessor::Instance().AddUpdateObject(this);
sObjectAccessor.AddUpdateObject(this);
m_objectUpdated = true;
}
}
@@ -962,7 +962,7 @@ void Object::SetUInt16Value(uint16 index, uint8 offset, uint16 value)
{
if (!m_objectUpdated)
{
ObjectAccessor::Instance().AddUpdateObject(this);
sObjectAccessor.AddUpdateObject(this);
m_objectUpdated = true;
}
}
@@ -1031,7 +1031,7 @@ void Object::SetFlag(uint16 index, uint32 newFlag)
{
if (!m_objectUpdated)
{
ObjectAccessor::Instance().AddUpdateObject(this);
sObjectAccessor.AddUpdateObject(this);
m_objectUpdated = true;
}
}
@@ -1052,7 +1052,7 @@ void Object::RemoveFlag(uint16 index, uint32 oldFlag)
{
if (!m_objectUpdated)
{
ObjectAccessor::Instance().AddUpdateObject(this);
sObjectAccessor.AddUpdateObject(this);
m_objectUpdated = true;
}
}
@@ -1077,7 +1077,7 @@ void Object::SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
{
if (!m_objectUpdated)
{
ObjectAccessor::Instance().AddUpdateObject(this);
sObjectAccessor.AddUpdateObject(this);
m_objectUpdated = true;
}
}
@@ -1102,7 +1102,7 @@ void Object::RemoveByteFlag(uint16 index, uint8 offset, uint8 oldFlag)
{
if (!m_objectUpdated)
{
ObjectAccessor::Instance().AddUpdateObject(this);
sObjectAccessor.AddUpdateObject(this);
m_objectUpdated = true;
}
}
@@ -1502,7 +1502,7 @@ void Object::ForceValuesUpdateAtIndex(uint32 i)
{
if (!m_objectUpdated)
{
ObjectAccessor::Instance().AddUpdateObject(this);
sObjectAccessor.AddUpdateObject(this);
m_objectUpdated = true;
}
}
+2 -2
View File
@@ -74,7 +74,7 @@ void Pet::AddToWorld()
if (!IsInWorld())
{
///- Register the pet for guid lookup
ObjectAccessor::Instance().AddObject(this);
sObjectAccessor.AddObject(this);
Unit::AddToWorld();
AIM_Initialize();
}
@@ -98,7 +98,7 @@ void Pet::RemoveFromWorld()
{
///- Don't call the function for Creature, normal mobs + totems go in a different storage
Unit::RemoveFromWorld();
ObjectAccessor::Instance().RemoveObject(this);
sObjectAccessor.RemoveObject(this);
}
}
+18 -18
View File
@@ -587,7 +587,7 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c
return false;
}
SetMap(MapManager::Instance().CreateMap(info->mapId, this, 0));
SetMap(sMapMgr.CreateMap(info->mapId, this, 0));
uint8 powertype = cEntry->powerType;
@@ -1822,12 +1822,12 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
// Check enter rights before map getting to avoid creating instance copy for player
// this check not dependent from map instance copy and same for all instance copies of selected map
if (!MapManager::Instance().CanPlayerEnter(mapid, this, false))
if (!sMapMgr.CanPlayerEnter(mapid, this, false))
return false;
// If the map is not created, assume it is possible to enter it.
// It will be created in the WorldPortAck.
Map *map = MapManager::Instance().FindMap(mapid);
Map *map = sMapMgr.FindMap(mapid);
if (!map || map->CanEnter(this))
{
//lets reset near teleport flag if it wasn't reset during chained teleports
@@ -4255,7 +4255,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
// convert corpse to bones if exist (to prevent exiting Corpse in World without DB entry)
// bones will be deleted by corpse/bones deleting thread shortly
ObjectAccessor::Instance().ConvertCorpseForPlayer(playerguid);
sObjectAccessor.ConvertCorpseForPlayer(playerguid);
// remove from guild
uint32 guildId = GetGuildIdFromDB(playerguid);
@@ -4684,19 +4684,19 @@ void Player::CreateCorpse()
corpse->SaveToDB();
// register for player, but not show
ObjectAccessor::Instance().AddCorpse(corpse);
sObjectAccessor.AddCorpse(corpse);
}
void Player::SpawnCorpseBones()
{
if (ObjectAccessor::Instance().ConvertCorpseForPlayer(GetGUID()))
if (sObjectAccessor.ConvertCorpseForPlayer(GetGUID()))
if (!GetSession()->PlayerLogoutWithSave()) // at logout we will already store the player
SaveToDB(); // prevent loading as ghost without corpse
}
Corpse* Player::GetCorpse() const
{
return ObjectAccessor::Instance().GetCorpseForPlayerGUID(GetGUID());
return sObjectAccessor.GetCorpseForPlayerGUID(GetGUID());
}
void Player::DurabilityLossAll(double percent, bool inventory)
@@ -6758,7 +6758,7 @@ uint32 Player::GetZoneIdFromDB(uint64 guid)
float posy = fields[2].GetFloat();
float posz = fields[3].GetFloat();
zone = MapManager::Instance().GetZoneId(map,posx,posy,posz);
zone = sMapMgr.GetZoneId(map,posx,posy,posz);
if (zone > 0)
CharacterDatabase.PExecute("UPDATE characters SET zone='%u' WHERE guid='%u'", zone, guidLow);
@@ -8013,7 +8013,7 @@ void Player::RemovedInsignia(Player* looterPlr)
// We have to convert player corpse to bones, not to be able to resurrect there
// SpawnCorpseBones isn't handy, 'cos it saves player while he in BG
Corpse *bones = ObjectAccessor::Instance().ConvertCorpseForPlayer(GetGUID(),true);
Corpse *bones = sObjectAccessor.ConvertCorpseForPlayer(GetGUID(),true);
if (!bones)
return;
@@ -13680,7 +13680,7 @@ void Player::PrepareQuestMenu(uint64 guid)
{
//we should obtain map pointer from GetMap() in 99% of cases. Special case
//only for quests which cast teleport spells on player
Map * _map = IsInWorld() ? GetMap() : MapManager::Instance().FindMap(GetMapId(), GetInstanceId());
Map * _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId());
ASSERT(_map);
GameObject *pGameObject = _map->GetGameObject(guid);
if (pGameObject)
@@ -13855,7 +13855,7 @@ Quest const * Player::GetNextQuest(uint64 guid, Quest const *pQuest)
{
//we should obtain map pointer from GetMap() in 99% of cases. Special case
//only for quests which cast teleport spells on player
Map * _map = IsInWorld() ? GetMap() : MapManager::Instance().FindMap(GetMapId(), GetInstanceId());
Map * _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId());
ASSERT(_map);
GameObject *pGameObject = _map->GetGameObject(guid);
if (pGameObject)
@@ -15955,7 +15955,7 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder)
}
else
{
for (MapManager::TransportSet::iterator iter = MapManager::Instance().m_Transports.begin(); iter != MapManager::Instance().m_Transports.end(); ++iter)
for (MapManager::TransportSet::iterator iter = sMapMgr.m_Transports.begin(); iter != sMapMgr.m_Transports.end(); ++iter)
{
if ((*iter)->GetGUIDLow() == transGUID)
{
@@ -16038,7 +16038,7 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder)
// NOW player must have valid map
// load the player's map here if it's not already loaded
Map *map = MapManager::Instance().CreateMap(mapId, this, instanceId);
Map *map = sMapMgr.CreateMap(mapId, this, instanceId);
if (!map)
{
@@ -16056,14 +16056,14 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder)
RelocateToHomebind();
}
map = MapManager::Instance().CreateMap(mapId, this, 0);
map = sMapMgr.CreateMap(mapId, this, 0);
if (!map)
{
PlayerInfo const *info = objmgr.GetPlayerInfo(getRace(), getClass());
mapId = info->mapId;
Relocate(info->positionX,info->positionY,info->positionZ,0.0f);
sLog.outError("ERROR: Player (guidlow %d) have invalid coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.",guid,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation());
map = MapManager::Instance().CreateMap(mapId, this, 0);
map = sMapMgr.CreateMap(mapId, this, 0);
if (!map)
{
sLog.outError("ERROR: Player (guidlow %d) has invalid default map coordinates (X: %f Y: %f Z: %f O: %f). or instance couldn't be created",guid,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation());
@@ -16532,7 +16532,7 @@ void Player::_LoadGlyphAuras()
void Player::LoadCorpse()
{
if (isAlive())
ObjectAccessor::Instance().ConvertCorpseForPlayer(GetGUID());
sObjectAccessor.ConvertCorpseForPlayer(GetGUID());
else
{
if (Corpse *corpse = GetCorpse())
@@ -17446,7 +17446,7 @@ bool Player::CheckInstanceLoginValid()
}
// do checks for satisfy accessreqs, instance full, encounter in progress (raid), perm bind group != perm bind player
return MapManager::Instance().CanPlayerEnter(GetMap()->GetId(), this, true);
return sMapMgr.CanPlayerEnter(GetMap()->GetId(), this, true);
}
bool Player::_LoadHomeBind(QueryResult_AutoPtr result)
@@ -18285,7 +18285,7 @@ void Player::ResetInstances(uint8 method, bool isRaid)
}
// if the map is loaded, reset it
Map *map = MapManager::Instance().FindMap(p->GetMapId(), p->GetInstanceId());
Map *map = sMapMgr.FindMap(p->GetMapId(), p->GetInstanceId());
if (map && map->IsDungeon())
if (!((InstanceMap*)map)->Reset(method))
{
@@ -19,7 +19,7 @@
*/
#include "SocialMgr.h"
#include "SingletonImp.h"
#include "DatabaseEnv.h"
#include "Opcodes.h"
#include "WorldPacket.h"
@@ -28,8 +28,6 @@
#include "World.h"
#include "Util.h"
INSTANTIATE_SINGLETON_1(SocialMgr);
PlayerSocial::PlayerSocial()
{
m_playerGUID = 0;
+4 -3
View File
@@ -21,7 +21,7 @@
#ifndef __TRINITY_SOCIALMGR_H
#define __TRINITY_SOCIALMGR_H
#include "Singleton.h"
#include "ace/Singleton.h"
#include "DatabaseEnv.h"
#include "Common.h"
@@ -139,8 +139,9 @@ class PlayerSocial
class SocialMgr
{
friend class ACE_Singleton<SocialMgr, ACE_Null_Mutex>;
SocialMgr();
public:
SocialMgr();
~SocialMgr();
// Misc
void RemovePlayerSocial(uint32 guid) { m_socialMap.erase(guid); }
@@ -156,6 +157,6 @@ class SocialMgr
SocialMap m_socialMap;
};
#define sSocialMgr Trinity::Singleton<SocialMgr>::Instance()
#define sSocialMgr (*ACE_Singleton<SocialMgr, ACE_Null_Mutex>::instance())
#endif
@@ -106,7 +106,7 @@ void MapManager::LoadTransports()
m_TransportsByMap[*i].insert(t);
//If we someday decide to use the grid to track transports, here:
t->SetMap(MapManager::Instance().CreateMap(mapid, t, 0));
t->SetMap(sMapMgr.CreateMap(mapid, t, 0));
//t->GetMap()->Add<GameObject>((GameObject *)t);
++count;
@@ -455,7 +455,7 @@ void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
//yes, you're right
ResetMap();
Map * newMap = MapManager::Instance().CreateMap(newMapid, this, 0);
Map * newMap = sMapMgr.CreateMap(newMapid, this, 0);
SetMap(newMap);
assert (GetMap());
+1 -1
View File
@@ -14062,7 +14062,7 @@ void Unit::StopMoving()
// send explicit stop packet
// rely on vmaps here because for example stormwind is in air
//float z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true);
//float z = sMapMgr.GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true);
//if (fabs(GetPositionZ() - z) < 2.0f)
// Relocate(GetPositionX(), GetPositionY(), z);
//Relocate(GetPositionX(), GetPositionY(),GetPositionZ());
+5 -8
View File
@@ -27,13 +27,10 @@
#include "Language.h"
#include "Log.h"
#include "MapManager.h"
#include "SingletonImp.h"
#include "GossipDef.h"
#include "Player.h"
#include "BattleGroundMgr.h"
INSTANTIATE_SINGLETON_1(GameEventMgr);
bool GameEventMgr::CheckOneGameEvent(uint16 entry) const
{
switch(mGameEvent[entry].state)
@@ -1270,7 +1267,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
objmgr.AddCreatureToGrid(*itr, data);
// Spawn if necessary (loaded grids only)
Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(data->mapid));
Map* map = const_cast<Map*>(sMapMgr.CreateBaseMap(data->mapid));
// We use spawn coords to spawn
if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY))
{
@@ -1298,7 +1295,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
objmgr.AddGameobjectToGrid(*itr, data);
// Spawn if necessary (loaded grids only)
// this base map checked as non-instanced and then only existed
Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(data->mapid));
Map* map = const_cast<Map*>(sMapMgr.CreateBaseMap(data->mapid));
// We use current coords to unspawn, not spawn coords since creature can have changed grid
if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY))
{
@@ -1345,7 +1342,7 @@ void GameEventMgr::GameEventUnspawn(int16 event_id)
{
objmgr.RemoveCreatureFromGrid(*itr, data);
if (Creature* pCreature = ObjectAccessor::Instance().GetObjectInWorld(MAKE_NEW_GUID(*itr, data->id, HIGHGUID_UNIT), (Creature*)NULL))
if (Creature* pCreature = sObjectAccessor.GetObjectInWorld(MAKE_NEW_GUID(*itr, data->id, HIGHGUID_UNIT), (Creature*)NULL))
pCreature->AddObjectToRemoveList();
}
}
@@ -1366,7 +1363,7 @@ void GameEventMgr::GameEventUnspawn(int16 event_id)
{
objmgr.RemoveGameobjectFromGrid(*itr, data);
if (GameObject* pGameobject = ObjectAccessor::Instance().GetObjectInWorld(MAKE_NEW_GUID(*itr, data->id, HIGHGUID_GAMEOBJECT), (GameObject*)NULL))
if (GameObject* pGameobject = sObjectAccessor.GetObjectInWorld(MAKE_NEW_GUID(*itr, data->id, HIGHGUID_GAMEOBJECT), (GameObject*)NULL))
pGameobject->AddObjectToRemoveList();
}
}
@@ -1392,7 +1389,7 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate)
continue;
// Update if spawned
Creature* pCreature = ObjectAccessor::Instance().GetObjectInWorld(MAKE_NEW_GUID(itr->first, data->id,HIGHGUID_UNIT), (Creature*)NULL);
Creature* pCreature = sObjectAccessor.GetObjectInWorld(MAKE_NEW_GUID(itr->first, data->id,HIGHGUID_UNIT), (Creature*)NULL);
if (pCreature)
{
if (activate)
+5 -3
View File
@@ -24,7 +24,7 @@
#include "Common.h"
#include "SharedDefines.h"
#include "Define.h"
#include "Singleton.h"
#include "ace/Singleton.h"
#define max_ge_check_delay DAY // 1 day in seconds
@@ -92,9 +92,11 @@ class Creature;
class GameEventMgr
{
friend class ACE_Singleton<GameEventMgr, ACE_Null_Mutex>;
GameEventMgr();
public:
GameEventMgr();
~GameEventMgr() {};
typedef std::set<uint16> ActiveEvents;
typedef std::vector<GameEventData> GameEventDataMap;
ActiveEvents const& GetActiveEventList() const { return m_ActiveEvents; }
@@ -172,7 +174,7 @@ class GameEventMgr
GameEventGuidMap mGameEventGameobjectGuids;
};
#define gameeventmgr Trinity::Singleton<GameEventMgr>::Instance()
#define gameeventmgr (*ACE_Singleton<GameEventMgr, ACE_Null_Mutex>::instance())
bool IsHolidayActive(HolidayIds id);
bool IsEventActive(uint16 event_id);
+2 -2
View File
@@ -53,7 +53,7 @@ static void CorpsesEraseCallBack(QueryResult_AutoPtr result, bool bones)
/// Resurrectable - convert corpses to bones
if (!bones)
{
if (!ObjectAccessor::Instance().ConvertCorpseForPlayer(player_guid))
if (!sObjectAccessor.ConvertCorpseForPlayer(player_guid))
{
sLog.outDebug("Corpse %u not found in world or bones creating forbidden. Delete from DB.",guidlow);
CharacterDatabase.PExecute("DELETE FROM corpse WHERE guid = '%u'",guidlow);
@@ -62,7 +62,7 @@ static void CorpsesEraseCallBack(QueryResult_AutoPtr result, bool bones)
else
///- or delete bones
{
MapManager::Instance().RemoveBonesFromMap(mapid, guid, positionX, positionY);
sMapMgr.RemoveBonesFromMap(mapid, guid, positionX, positionY);
///- remove bones from the database
CharacterDatabase.PExecute("DELETE FROM corpse WHERE guid = '%u'",guidlow);
+9 -13
View File
@@ -20,7 +20,7 @@
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "SingletonImp.h"
#include "Player.h"
#include "Creature.h"
#include "GameObject.h"
@@ -41,10 +41,6 @@
#include <cmath>
#define CLASS_LOCK Trinity::ClassLevelLockable<ObjectAccessor, ACE_Thread_Mutex>
INSTANTIATE_SINGLETON_2(ObjectAccessor, CLASS_LOCK);
INSTANTIATE_CLASS_MUTEX(ObjectAccessor, ACE_Thread_Mutex);
ObjectAccessor::ObjectAccessor()
{
}
@@ -151,7 +147,7 @@ Player* ObjectAccessor::FindPlayer(uint64 guid)
Player* ObjectAccessor::FindPlayerByName(const char* name)
{
Guard guard(*HashMapHolder<Player>::GetLock());
ACE_GUARD_RETURN(LockType, g, *HashMapHolder<Player>::GetLock(), NULL);
HashMapHolder<Player>::MapType& m = HashMapHolder<Player>::GetContainer();
for (HashMapHolder<Player>::MapType::iterator iter = m.begin(); iter != m.end(); ++iter)
if (iter->second->IsInWorld() && strcmp(name, iter->second->GetName()) == 0)
@@ -162,7 +158,7 @@ Player* ObjectAccessor::FindPlayerByName(const char* name)
void ObjectAccessor::SaveAllPlayers()
{
Guard guard(*HashMapHolder<Player>::GetLock());
ACE_GUARD(LockType, g, *HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType& m = HashMapHolder<Player>::GetContainer();
for (HashMapHolder<Player>::MapType::iterator itr = m.begin(); itr != m.end(); ++itr)
itr->second->SaveToDB();
@@ -175,7 +171,7 @@ Pet* ObjectAccessor::GetPet(uint64 guid)
Corpse* ObjectAccessor::GetCorpseForPlayerGUID(uint64 guid)
{
Guard guard(i_corpseGuard);
ACE_GUARD_RETURN(LockType, guard, i_corpseGuard, NULL);
Player2CorpsesMapType::iterator iter = i_player2corpse.find(guid);
if (iter == i_player2corpse.end())
@@ -197,7 +193,7 @@ void ObjectAccessor::RemoveCorpse(Corpse* corpse)
// Critical section
{
Guard guard(i_corpseGuard);
ACE_GUARD(LockType, g, i_corpseGuard);
Player2CorpsesMapType::iterator iter = i_player2corpse.find(corpse->GetOwnerGUID());
if (iter == i_player2corpse.end()) // TODO: Fix this
@@ -219,7 +215,7 @@ void ObjectAccessor::AddCorpse(Corpse* corpse)
// Critical section
{
Guard guard(i_corpseGuard);
ACE_GUARD(LockType, g, i_corpseGuard);
assert(i_player2corpse.find(corpse->GetOwnerGUID()) == i_player2corpse.end());
i_player2corpse[corpse->GetOwnerGUID()] = corpse;
@@ -234,7 +230,7 @@ void ObjectAccessor::AddCorpse(Corpse* corpse)
void ObjectAccessor::AddCorpsesToGrid(GridPair const& gridpair, GridType& grid, Map* map)
{
Guard guard(i_corpseGuard);
ACE_GUARD(LockType, g, i_corpseGuard);
for (Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter)
{
@@ -274,7 +270,7 @@ Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool /*insign
// done in removecorpse
// remove resurrectable corpse from grid object registry (loaded state checked into call)
// do not load the map if it's not loaded
//Map *map = MapManager::Instance().FindMap(corpse->GetMapId(), corpse->GetInstanceId());
//Map *map = sMapMgr.FindMap(corpse->GetMapId(), corpse->GetInstanceId());
//if (map)
// map->Remove(corpse, false);
@@ -333,7 +329,7 @@ void ObjectAccessor::Update(uint32 /*diff*/)
// Critical section
{
Guard guard(i_updateGuard);
ACE_GUARD(LockType, g, i_updateGuard);
while (!i_objects.empty())
{
+10 -11
View File
@@ -22,10 +22,9 @@
#define TRINITY_OBJECTACCESSOR_H
#include "Define.h"
#include "Singleton.h"
#include <ace/Singleton.h>
#include <ace/Thread_Mutex.h>
#include "UnorderedMap.h"
#include "ThreadingModel.h"
#include "UpdateData.h"
@@ -50,23 +49,22 @@ class HashMapHolder
typedef UNORDERED_MAP<uint64, T*> MapType;
typedef ACE_Thread_Mutex LockType;
typedef Trinity::GeneralLock<LockType> Guard;
static void Insert(T* o)
{
Guard guard(i_lock);
ACE_GUARD(LockType, Guard, i_lock);
m_objectMap[o->GetGUID()] = o;
}
static void Remove(T* o)
{
Guard guard(i_lock);
ACE_GUARD(LockType, Guard, i_lock);
m_objectMap.erase(o->GetGUID());
}
static T* Find(uint64 guid)
{
Guard guard(i_lock);
ACE_GUARD_RETURN(LockType, Guard, i_lock, NULL);
typename MapType::iterator itr = m_objectMap.find(guid);
return (itr != m_objectMap.end()) ? itr->second : NULL;
}
@@ -84,9 +82,9 @@ class HashMapHolder
static MapType m_objectMap;
};
class ObjectAccessor : public Trinity::Singleton<ObjectAccessor, Trinity::ClassLevelLockable<ObjectAccessor, ACE_Thread_Mutex> >
class ObjectAccessor
{
friend class Trinity::OperatorNew<ObjectAccessor>;
friend class ACE_Singleton<ObjectAccessor, ACE_Thread_Mutex>;
ObjectAccessor();
~ObjectAccessor();
ObjectAccessor(const ObjectAccessor&);
@@ -220,13 +218,13 @@ class ObjectAccessor : public Trinity::Singleton<ObjectAccessor, Trinity::ClassL
void AddUpdateObject(Object* obj)
{
Guard guard(i_updateGuard);
ACE_GUARD(LockType, Guard, i_updateGuard);
i_objects.insert(obj);
}
void RemoveUpdateObject(Object* obj)
{
Guard guard(i_updateGuard);
ACE_GUARD(LockType, Guard, i_updateGuard);
i_objects.erase(obj);
}
@@ -239,7 +237,6 @@ class ObjectAccessor : public Trinity::Singleton<ObjectAccessor, Trinity::ClassL
Corpse* ConvertCorpseForPlayer(uint64 player_guid, bool insignia = false);
typedef ACE_Thread_Mutex LockType;
typedef Trinity::GeneralLock<LockType> Guard;
private:
@@ -254,4 +251,6 @@ class ObjectAccessor : public Trinity::Singleton<ObjectAccessor, Trinity::ClassL
LockType i_updateGuard;
LockType i_corpseGuard;
};
#define sObjectAccessor (*ACE_Singleton<ObjectAccessor, ACE_Thread_Mutex>::instance())
#endif
+5 -9
View File
@@ -22,8 +22,6 @@
#include "DatabaseEnv.h"
#include "SQLStorage.h"
#include "SQLStorageImpl.h"
#include "SingletonImp.h"
#include "Log.h"
#include "MapManager.h"
#include "ObjectMgr.h"
@@ -48,8 +46,6 @@
#include "Vehicle.h"
#include "AchievementMgr.h"
INSTANTIATE_SINGLETON_1(ObjectMgr);
ScriptMapMap sQuestEndScripts;
ScriptMapMap sQuestStartScripts;
ScriptMapMap sSpellScripts;
@@ -1412,7 +1408,7 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float
if (!goinfo)
return 0;
Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(mapId));
Map* map = const_cast<Map*>(sMapMgr.CreateBaseMap(mapId));
if (!map)
return 0;
@@ -1473,7 +1469,7 @@ bool ObjectMgr::MoveCreData(uint32 guid, uint32 mapId, Position pos)
AddCreatureToGrid(guid, &data);
// Spawn if necessary (loaded grids only)
if (Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(mapId)))
if (Map* map = const_cast<Map*>(sMapMgr.CreateBaseMap(mapId)))
{
// We use spawn coords to spawn
if (!map->Instanceable() && map->IsLoaded(data.posX, data.posY))
@@ -1524,7 +1520,7 @@ uint32 ObjectMgr::AddCreData(uint32 entry, uint32 /*team*/, uint32 mapId, float
AddCreatureToGrid(guid, &data);
// Spawn if necessary (loaded grids only)
if (Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(mapId)))
if (Map* map = const_cast<Map*>(sMapMgr.CreateBaseMap(mapId)))
{
// We use spawn coords to spawn
if (!map->Instanceable() && !map->IsRemovalGrid(x, y))
@@ -5547,7 +5543,7 @@ void ObjectMgr::LoadGraveyardZones()
WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float z, uint32 MapId, uint32 team)
{
// search for zone associated closest graveyard
uint32 zoneId = MapManager::Instance().GetZoneId(MapId,x,y,z);
uint32 zoneId = sMapMgr.GetZoneId(MapId,x,y,z);
// Simulate std. algorithm:
// found some graveyard associated to (ghost_zone,ghost_map)
@@ -6608,7 +6604,7 @@ void ObjectMgr::LoadCorpses()
continue;
}
ObjectAccessor::Instance().AddCorpse(corpse);
sObjectAccessor.AddCorpse(corpse);
++count;
}
+7 -7
View File
@@ -37,7 +37,7 @@
#include "Map.h"
#include "ObjectAccessor.h"
#include "ObjectDefines.h"
#include "Singleton.h"
#include "ace/Singleton.h"
#include "SQLStorage.h"
#include "Vehicle.h"
#include "ObjectMgr.h"
@@ -354,11 +354,11 @@ class PlayerDumpReader;
class ObjectMgr
{
friend class PlayerDumpReader;
friend class ACE_Singleton<ObjectMgr, ACE_Null_Mutex>;
ObjectMgr();
~ObjectMgr();
public:
ObjectMgr();
~ObjectMgr();
typedef UNORDERED_MAP<uint32, Item*> ItemMap;
typedef std::set< Group * > GroupSet;
@@ -382,7 +382,7 @@ class ObjectMgr
typedef std::vector<std::string> ScriptNameMap;
Player* GetPlayer(const char* name) const { return ObjectAccessor::Instance().FindPlayerByName(name);}
Player* GetPlayer(const char* name) const { return sObjectAccessor.FindPlayerByName(name);}
Player* GetPlayer(uint64 guid) const { return ObjectAccessor::FindPlayer(guid); }
static GameObjectInfo const *GetGameObjectInfo(uint32 id) { return sGOStorage.LookupEntry<GameObjectInfo>(id); }
@@ -1083,7 +1083,7 @@ class ObjectMgr
};
#define objmgr Trinity::Singleton<ObjectMgr>::Instance()
#define objmgr (*ACE_Singleton<ObjectMgr, ACE_Null_Mutex>::instance())
// scripting access functions
bool LoadTrinityStrings(DatabaseType& db, char const* table,int32 start_value = MAX_CREATURE_AI_TEXT_STRING_ID, int32 end_value = std::numeric_limits<int32>::min());
+1 -6
View File
@@ -33,7 +33,6 @@
*/
#include "Define.h"
#include "ThreadingModel.h"
#include "TypeContainer.h"
#include "TypeContainerVisitor.h"
@@ -44,8 +43,7 @@ template
<
class ACTIVE_OBJECT,
class WORLD_OBJECT_TYPES,
class GRID_OBJECT_TYPES,
class ThreadModel = Trinity::SingleThreaded<ACTIVE_OBJECT>
class GRID_OBJECT_TYPES
>
class Grid
{
@@ -131,9 +129,6 @@ class Grid
}*/
private:
typedef typename ThreadModel::Lock Guard;
typedef typename ThreadModel::VolatileType VolatileType;
TypeMapContainer<GRID_OBJECT_TYPES> i_container;
TypeMapContainer<WORLD_OBJECT_TYPES> i_objects;
//typedef std::set<void*> ActiveGridObjects;
+4 -5
View File
@@ -74,14 +74,13 @@ template
unsigned int N,
class ACTIVE_OBJECT,
class WORLD_OBJECT_TYPES,
class GRID_OBJECT_TYPES,
class ThreadModel = Trinity::SingleThreaded<ACTIVE_OBJECT>
class GRID_OBJECT_TYPES
>
class NGrid
{
public:
typedef Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES, ThreadModel> GridType;
typedef Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> GridType;
NGrid(uint32 id, int32 x, int32 y, time_t expiry, bool unload = true)
: i_gridId(id), i_x(x), i_y(y), i_cellstate(GRID_STATE_INVALID), i_GridObjectDataLoaded(false)
{
@@ -109,7 +108,7 @@ class NGrid
int32 getX() const { return i_x; }
int32 getY() const { return i_y; }
void link(GridRefManager<NGrid<N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES, ThreadModel> >* pTo)
void link(GridRefManager<NGrid<N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> >* pTo)
{
i_Reference.link(pTo, this);
}
@@ -178,7 +177,7 @@ class NGrid
uint32 i_gridId;
GridInfo i_GridInfo;
GridReference<NGrid<N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES, ThreadModel> > i_Reference;
GridReference<NGrid<N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> > i_Reference;
int32 i_x;
int32 i_y;
grid_state_t i_cellstate;
+1 -1
View File
@@ -151,7 +151,7 @@ void LoadHelper(CellCorpseSet const& cell_corpses, CellPair &cell, CorpseMapType
uint32 player_guid = itr->first;
Corpse *obj = ObjectAccessor::Instance().GetCorpseForPlayerGUID(player_guid);
Corpse *obj = sObjectAccessor.GetCorpseForPlayerGUID(player_guid);
if (!obj)
continue;
+1 -1
View File
@@ -1724,7 +1724,7 @@ void Group::ResetInstances(uint8 method, bool isRaid, Player* SendMsgTo)
bool isEmpty = true;
// if the map is loaded, reset it
Map *map = MapManager::Instance().FindMap(p->GetMapId(), p->GetInstanceId());
Map *map = sMapMgr.FindMap(p->GetMapId(), p->GetInstanceId());
if (map && map->IsDungeon() && !(method == INSTANCE_RESET_GROUP_DISBAND && !p->CanReset()))
{
if (p->CanReset())
+3 -11
View File
@@ -21,7 +21,6 @@
#include "Common.h"
#include "SQLStorage.h"
#include "Player.h"
#include "GridNotifiers.h"
#include "Log.h"
@@ -40,14 +39,7 @@
#include "Group.h"
#include "InstanceData.h"
#include "ProgressBar.h"
#include "Singleton.h"
#include "SingletonImp.h"
INSTANTIATE_SINGLETON_1(InstanceSaveManager);
InstanceSaveManager::InstanceSaveManager() : lock_instLists(false)
{
}
InstanceSaveManager::~InstanceSaveManager()
{
@@ -173,7 +165,7 @@ void InstanceSave::SaveToDB()
// save instance data too
std::string data;
Map *map = MapManager::Instance().FindMap(GetMapId(),m_instanceid);
Map *map = sMapMgr.FindMap(GetMapId(),m_instanceid);
if (map)
{
assert(map->IsDungeon());
@@ -615,7 +607,7 @@ void InstanceSaveManager::_ResetSave(InstanceSaveHashMap::iterator &itr)
void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId)
{
sLog.outDebug("InstanceSaveMgr::_ResetInstance %u, %u", mapid, instanceId);
Map *map = (MapInstanced*)MapManager::Instance().CreateBaseMap(mapid);
Map *map = (MapInstanced*)sMapMgr.CreateBaseMap(mapid);
if (!map->Instanceable())
return;
@@ -679,7 +671,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b
}
// note: this isn't fast but it's meant to be executed very rarely
Map const *map = MapManager::Instance().CreateBaseMap(mapid); // _not_ include difficulty
Map const *map = sMapMgr.CreateBaseMap(mapid); // _not_ include difficulty
MapInstanced::InstancedMaps &instMaps = ((MapInstanced*)map)->GetInstancedMaps();
MapInstanced::InstancedMaps::iterator mitr;
for (mitr = instMaps.begin(); mitr != instMaps.end(); ++mitr)
+7 -5
View File
@@ -23,7 +23,7 @@
#define __InstanceSaveMgr_H
#include "Define.h"
#include "Singleton.h"
#include "ace/Singleton.h"
#include "ace/Thread_Mutex.h"
#include <list>
#include <map>
@@ -117,13 +117,14 @@ class InstanceSave
typedef UNORDERED_MAP<uint32 /*PAIR32(map,difficulty)*/,time_t /*resetTime*/> ResetTimeByMapDifficultyMap;
class InstanceSaveManager : public Trinity::Singleton<InstanceSaveManager, Trinity::ClassLevelLockable<InstanceSaveManager, ACE_Thread_Mutex> >
class InstanceSaveManager
{
friend class ACE_Singleton<InstanceSaveManager, ACE_Null_Mutex>;
friend class InstanceSave;
public:
InstanceSaveManager();
InstanceSaveManager() : lock_instLists(false) {};
~InstanceSaveManager();
typedef UNORDERED_MAP<uint32 /*InstanceId*/, InstanceSave*> InstanceSaveHashMap;
typedef UNORDERED_MAP<uint32 /*mapId*/, InstanceSaveHashMap> InstanceSaveMapMap;
@@ -176,6 +177,7 @@ class InstanceSaveManager : public Trinity::Singleton<InstanceSaveManager, Trini
uint32 GetNumBoundGroupsTotal();
private:
void _ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool warn, uint32 timeleft);
void _ResetInstance(uint32 mapid, uint32 instanceId);
void _ResetSave(InstanceSaveHashMap::iterator &itr);
@@ -189,5 +191,5 @@ class InstanceSaveManager : public Trinity::Singleton<InstanceSaveManager, Trini
ResetTimeQueue m_resetTimeQueue;
};
#define sInstanceSaveManager Trinity::Singleton<InstanceSaveManager>::Instance()
#define sInstanceSaveManager (*ACE_Singleton<InstanceSaveManager, ACE_Thread_Mutex>::instance())
#endif
+10 -10
View File
@@ -325,7 +325,7 @@ void Map::DeleteFromWorld(T* obj)
template<>
void Map::DeleteFromWorld(Player* pl)
{
ObjectAccessor::Instance().RemoveObject(pl);
sObjectAccessor.RemoveObject(pl);
delete pl;
}
@@ -334,7 +334,7 @@ Map::EnsureGridCreated(const GridPair &p)
{
if (!getNGrid(p.x_coord, p.y_coord))
{
Guard guard(*this);
ACE_GUARD(ACE_Thread_Mutex, Guard, Lock);
if (!getNGrid(p.x_coord, p.y_coord))
{
sLog.outDebug("Creating grid[%u,%u] for map %u instance %u", p.x_coord, p.y_coord, GetId(), i_InstanceId);
@@ -395,7 +395,7 @@ bool Map::EnsureGridLoaded(const Cell &cell)
loader.LoadN();
// Add resurrectable corpses to world object list in grid
ObjectAccessor::Instance().AddCorpsesToGrid(GridPair(cell.GridX(),cell.GridY()),(*grid)(cell.CellX(), cell.CellY()), this);
sObjectAccessor.AddCorpsesToGrid(GridPair(cell.GridX(),cell.GridY()),(*grid)(cell.CellX(), cell.CellY()), this);
setGridObjectDataLoaded(true,cell.GridX(), cell.GridY());
return true;
@@ -828,7 +828,7 @@ bool Map::RemoveBones(uint64 guid, float x, float y)
{
if (IsRemovalGrid(x, y))
{
Corpse * corpse = ObjectAccessor::Instance().GetObjectInWorld(GetId(), x, y, guid, (Corpse*)NULL);
Corpse * corpse = sObjectAccessor.GetObjectInWorld(GetId(), x, y, guid, (Corpse*)NULL);
if (corpse && corpse->GetTypeId() == TYPEID_CORPSE && corpse->GetType() == CORPSE_BONES)
corpse->DeleteBonesFromWorld();
else
@@ -2069,7 +2069,7 @@ void Map::SendInitSelf(Player * player)
void Map::SendInitTransports(Player * player)
{
// Hack to send out transports
MapManager::TransportMap& tmap = MapManager::Instance().m_TransportsByMap;
MapManager::TransportMap& tmap = sMapMgr.m_TransportsByMap;
// no transports at map
if (tmap.find(player->GetMapId()) == tmap.end())
@@ -2096,7 +2096,7 @@ void Map::SendInitTransports(Player * player)
void Map::SendRemoveTransports(Player * player)
{
// Hack to send out transports
MapManager::TransportMap& tmap = MapManager::Instance().m_TransportsByMap;
MapManager::TransportMap& tmap = sMapMgr.m_TransportsByMap;
// no transports at map
if (tmap.find(player->GetMapId()) == tmap.end())
@@ -2196,7 +2196,7 @@ void Map::RemoveAllObjectsInRemoveList()
{
case TYPEID_CORPSE:
{
Corpse* corpse = ObjectAccessor::Instance().GetCorpse(*obj, obj->GetGUID());
Corpse* corpse = sObjectAccessor.GetCorpse(*obj, obj->GetGUID());
if (!corpse)
sLog.outError("Tried to delete corpse/bones %u that is not in map.", obj->GetGUIDLow());
else
@@ -2408,7 +2408,7 @@ bool InstanceMap::Add(Player *player)
// Is it needed?
{
Guard guard(*this);
ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, Lock, false);
// Check moved to void WorldSession::HandleMoveWorldportAckOpcode()
//if (!CanEnter(player))
//return false;
@@ -2733,7 +2733,7 @@ bool BattleGroundMap::CanEnter(Player * player)
bool BattleGroundMap::Add(Player * player)
{
{
Guard guard(*this);
ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, Lock, false);
//Check moved to void WorldSession::HandleMoveWorldportAckOpcode()
//if (!CanEnter(player))
//return false;
@@ -2877,7 +2877,7 @@ void Map::ScriptsProcess()
source = HashMapHolder<Corpse>::Find(step.sourceGUID);
break;
case HIGHGUID_MO_TRANSPORT:
for (MapManager::TransportSet::iterator iter = MapManager::Instance().m_Transports.begin(); iter != MapManager::Instance().m_Transports.end(); ++iter)
for (MapManager::TransportSet::iterator iter = sMapMgr.m_Transports.begin(); iter != sMapMgr.m_Transports.end(); ++iter)
{
if ((*iter)->GetGUID() == step.sourceGUID)
{
+2 -3
View File
@@ -22,7 +22,6 @@
#define TRINITY_MAP_H
#include "Define.h"
#include "ThreadingModel.h"
#include "ace/RW_Thread_Mutex.h"
#include "ace/Thread_Mutex.h"
@@ -239,7 +238,7 @@ typedef UNORDERED_MAP<Creature*, CreatureMover> CreatureMoveList;
typedef std::map<uint32/*leaderDBGUID*/, CreatureGroup*> CreatureGroupHolderType;
class Map : public GridRefManager<NGridType>, public Trinity::ObjectLevelLockable<Map, ACE_Thread_Mutex>
class Map : public GridRefManager<NGridType>
{
friend class MapReference;
public:
@@ -490,7 +489,7 @@ class Map : public GridRefManager<NGridType>, public Trinity::ObjectLevelLockabl
protected:
void SetUnloadReferenceLock(const GridPair &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadReferenceLock(on); }
typedef Trinity::ObjectLevelLockable<Map, ACE_Thread_Mutex>::Lock Guard;
ACE_Thread_Mutex Lock;
MapEntry const* i_mapEntry;
uint8 i_spawnMode;
+3 -3
View File
@@ -170,7 +170,7 @@ Map* MapInstanced::CreateInstance(const uint32 mapId, Player * player)
{
// if no instanceId via group members or instance saves is found
// the instance will be created for the first time
NewInstanceId = MapManager::Instance().GenerateInstanceId();
NewInstanceId = sMapMgr.GenerateInstanceId();
Difficulty diff = player->GetGroup() ? player->GetGroup()->GetDifficulty(IsRaid()) : player->GetDifficulty(IsRaid());
map = CreateInstance(NewInstanceId, NULL, diff);
@@ -183,7 +183,7 @@ Map* MapInstanced::CreateInstance(const uint32 mapId, Player * player)
InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave *save, Difficulty difficulty)
{
// load/create a map
Guard guard(*this);
ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, NULL);
// make sure we have a valid map id
const MapEntry* entry = sMapStore.LookupEntry(GetId());
@@ -219,7 +219,7 @@ InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave *save,
BattleGroundMap* MapInstanced::CreateBattleGround(uint32 InstanceId, BattleGround* bg)
{
// load/create a map
Guard guard(*this);
ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, NULL);
sLog.outDebug("MapInstanced::CreateBattleGround: map bg %d for %d created.", InstanceId, GetId());
+5 -10
View File
@@ -20,7 +20,6 @@
#include "MapManager.h"
#include "InstanceSaveMgr.h"
#include "SingletonImp.h"
#include "DatabaseEnv.h"
#include "Log.h"
#include "ObjectAccessor.h"
@@ -37,10 +36,6 @@
#include "Language.h"
#include "WorldPacket.h"
#define CLASS_LOCK Trinity::ClassLevelLockable<MapManager, ACE_Thread_Mutex>
INSTANTIATE_SINGLETON_2(MapManager, CLASS_LOCK);
INSTANTIATE_CLASS_MUTEX(MapManager, ACE_Thread_Mutex);
extern GridState* si_GridStates[]; // debugging code, should be deleted some day
MapManager::MapManager()
@@ -116,7 +111,7 @@ Map* MapManager::_createBaseMap(uint32 id)
if (m == NULL)
{
Guard guard(*this);
ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, NULL);
const MapEntry* entry = sMapStore.LookupEntry(id);
if (entry && entry->Instanceable())
@@ -236,7 +231,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck)
InstanceGroupBind* boundedInstance = pGroup->GetBoundInstance(player);
if (boundedInstance && boundedInstance->save)
{
if (Map *boundedMap = MapManager::Instance().FindMap(mapid,boundedInstance->save->GetInstanceId()))
if (Map *boundedMap = sMapMgr.FindMap(mapid,boundedInstance->save->GetInstanceId()))
{
// Player permanently bounded to different instance than groups one
InstancePlayerBind* playerBoundedInstance = player->GetBoundInstance(mapid, player->GetDungeonDifficulty());
@@ -307,7 +302,7 @@ void MapManager::Update(uint32 diff)
for (iter = i_maps.begin(); iter != i_maps.end(); ++iter)
iter->second->DelayedUpdate(i_timer.GetCurrent());
ObjectAccessor::Instance().Update(i_timer.GetCurrent());
sObjectAccessor.Update(i_timer.GetCurrent());
for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter)
(*iter)->Update(i_timer.GetCurrent());
@@ -361,7 +356,7 @@ void MapManager::InitMaxInstanceId()
uint32 MapManager::GetNumInstances()
{
Guard guard(*this);
ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, NULL);
uint32 ret = 0;
for (MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr)
@@ -378,7 +373,7 @@ uint32 MapManager::GetNumInstances()
uint32 MapManager::GetNumPlayersInInstances()
{
Guard guard(*this);
ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, NULL);
uint32 ret = 0;
for (MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr)
+5 -5
View File
@@ -22,7 +22,7 @@
#define TRINITY_MAPMANAGER_H
#include "Define.h"
#include "Singleton.h"
#include "ace/Singleton.h"
#include "ace/Thread_Mutex.h"
#include "Common.h"
#include "Map.h"
@@ -31,10 +31,9 @@
class Transport;
class MapManager : public Trinity::Singleton<MapManager, Trinity::ClassLevelLockable<MapManager, ACE_Thread_Mutex> >
class MapManager
{
friend class Trinity::OperatorNew<MapManager>;
friend class ACE_Singleton<MapManager, ACE_Thread_Mutex>;
typedef UNORDERED_MAP<uint32, Map*> MapMapType;
typedef std::pair<UNORDERED_MAP<uint32, Map*>::iterator, bool> MapMapPair;
@@ -162,7 +161,7 @@ class MapManager : public Trinity::Singleton<MapManager, Trinity::ClassLevelLock
return (iter == i_maps.end() ? NULL : iter->second);
}
typedef Trinity::ClassLevelLockable<MapManager, ACE_Thread_Mutex>::Lock Guard;
ACE_Thread_Mutex Lock;
uint32 i_gridCleanUpDelay;
MapMapType i_maps;
IntervalTimer i_timer;
@@ -170,4 +169,5 @@ class MapManager : public Trinity::Singleton<MapManager, Trinity::ClassLevelLock
uint32 i_MaxInstanceId;
MapUpdater m_updater;
};
#define sMapMgr (*ACE_Singleton<MapManager, ACE_Thread_Mutex>::instance())
#endif
+1 -1
View File
@@ -22,7 +22,7 @@
#define TRINITY_MOVEMENTGENERATOR_H
#include "Define.h"
#include "Singleton.h"
#include "ace/Singleton.h"
#include "ObjectRegistry.h"
#include "FactoryHolder.h"
#include "Common.h"
@@ -343,7 +343,7 @@ void FlightPathMovementGenerator::InitEndGridInfo()
void FlightPathMovementGenerator::PreloadEndGrid()
{
// used to preload the final grid where the flightmaster is
Map *endMap = MapManager::Instance().FindMap(m_endMapId);
Map *endMap = sMapMgr.FindMap(m_endMapId);
// Load the grid
if (endMap)
+1 -1
View File
@@ -165,7 +165,7 @@ bool OPvPCapturePoint::DelCreature(uint32 type)
// explicit removal from map
// beats me why this is needed, but with the recent removal "cleanup" some creatures stay in the map if "properly" deleted
// so this is a big fat workaround, if AddObjectToRemoveList and DoDelayedMovesAndRemoves worked correctly, this wouldn't be needed
//if (Map * map = MapManager::Instance().FindMap(cr->GetMapId()))
//if (Map * map = sMapMgr.FindMap(cr->GetMapId()))
// map->Remove(cr,false);
// delete respawn time for this creature
WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE guid = '%u'", guid);
@@ -25,9 +25,6 @@
#include "OutdoorPvPEP.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "SingletonImp.h"
INSTANTIATE_SINGLETON_1(OutdoorPvPMgr);
OutdoorPvPMgr::OutdoorPvPMgr()
{
+2 -2
View File
@@ -22,7 +22,7 @@
#define OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL 1000
#include "OutdoorPvP.h"
#include "Singleton.h"
#include "ace/Singleton.h"
class Player;
class GameObject;
@@ -79,7 +79,7 @@ private:
uint32 m_UpdateTimer;
};
#define sOutdoorPvPMgr Trinity::Singleton<OutdoorPvPMgr>::Instance()
#define sOutdoorPvPMgr (*ACE_Singleton<OutdoorPvPMgr, ACE_Null_Mutex>::instance())
#endif /*OUTDOOR_PVP_MGR_H_*/
+6 -9
View File
@@ -21,9 +21,6 @@
#include "ProgressBar.h"
#include "Log.h"
#include "MapManager.h"
#include "SingletonImp.h"
INSTANTIATE_SINGLETON_1(PoolHandler);
////////////////////////////////////////////////////////////
// template class SpawnedPoolData
@@ -201,7 +198,7 @@ void PoolGroup<Creature>::Despawn1Object(uint32 guid)
{
objmgr.RemoveCreatureFromGrid(guid, data);
if (Creature* pCreature = ObjectAccessor::Instance().GetObjectInWorld(MAKE_NEW_GUID(guid, data->id, HIGHGUID_UNIT), (Creature*)NULL))
if (Creature* pCreature = sObjectAccessor.GetObjectInWorld(MAKE_NEW_GUID(guid, data->id, HIGHGUID_UNIT), (Creature*)NULL))
pCreature->AddObjectToRemoveList();
}
}
@@ -214,7 +211,7 @@ void PoolGroup<GameObject>::Despawn1Object(uint32 guid)
{
objmgr.RemoveGameobjectFromGrid(guid, data);
if (GameObject* pGameobject = ObjectAccessor::Instance().GetObjectInWorld(MAKE_NEW_GUID(guid, data->id, HIGHGUID_GAMEOBJECT), (GameObject*)NULL))
if (GameObject* pGameobject = sObjectAccessor.GetObjectInWorld(MAKE_NEW_GUID(guid, data->id, HIGHGUID_GAMEOBJECT), (GameObject*)NULL))
pGameobject->AddObjectToRemoveList();
}
}
@@ -297,7 +294,7 @@ void PoolGroup<Creature>::Spawn1Object(PoolObject* obj)
objmgr.AddCreatureToGrid(obj->guid, data);
// Spawn if necessary (loaded grids only)
Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(data->mapid));
Map* map = const_cast<Map*>(sMapMgr.CreateBaseMap(data->mapid));
// We use spawn coords to spawn
if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY))
{
@@ -323,7 +320,7 @@ void PoolGroup<GameObject>::Spawn1Object(PoolObject* obj)
objmgr.AddGameobjectToGrid(obj->guid, data);
// Spawn if necessary (loaded grids only)
// this base map checked as non-instanced and then only existed
Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(data->mapid));
Map* map = const_cast<Map*>(sMapMgr.CreateBaseMap(data->mapid));
// We use current coords to unspawn, not spawn coords since creature can have changed grid
if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY))
{
@@ -355,7 +352,7 @@ template <>
void PoolGroup<Creature>::ReSpawn1Object(PoolObject* obj)
{
if (CreatureData const* data = objmgr.GetCreatureData(obj->guid))
if (Creature* pCreature = ObjectAccessor::Instance().GetObjectInWorld(MAKE_NEW_GUID(obj->guid, data->id, HIGHGUID_UNIT), (Creature*)NULL))
if (Creature* pCreature = sObjectAccessor.GetObjectInWorld(MAKE_NEW_GUID(obj->guid, data->id, HIGHGUID_UNIT), (Creature*)NULL))
pCreature->GetMap()->Add(pCreature);
}
@@ -364,7 +361,7 @@ template <>
void PoolGroup<GameObject>::ReSpawn1Object(PoolObject* obj)
{
if (GameObjectData const* data = objmgr.GetGOData(obj->guid))
if (GameObject* pGameobject = ObjectAccessor::Instance().GetObjectInWorld(MAKE_NEW_GUID(obj->guid, data->id, HIGHGUID_GAMEOBJECT), (GameObject*)NULL))
if (GameObject* pGameobject = sObjectAccessor.GetObjectInWorld(MAKE_NEW_GUID(obj->guid, data->id, HIGHGUID_GAMEOBJECT), (GameObject*)NULL))
pGameobject->GetMap()->Add(pGameobject);
}
+6 -5
View File
@@ -20,7 +20,7 @@
#define TRINITY_POOLHANDLER_H
#include "Define.h"
#include "Singleton.h"
#include "ace/Singleton.h"
#include "Creature.h"
#include "GameObject.h"
@@ -89,10 +89,11 @@ class PoolGroup
class PoolHandler
{
public:
PoolHandler();
~PoolHandler() {};
friend class ACE_Singleton<PoolHandler, ACE_Null_Mutex>;
PoolHandler();
~PoolHandler() {};
public:
void LoadFromDB();
void Initialize();
@@ -134,7 +135,7 @@ class PoolHandler
SpawnedPoolData mSpawnedData;
};
#define poolhandler Trinity::Singleton<PoolHandler>::Instance()
#define poolhandler (*ACE_Singleton<PoolHandler, ACE_Null_Mutex>::instance())
// Method that tell if the creature is part of a pool and return the pool id if yes
template<>
-3
View File
@@ -10,9 +10,6 @@
#include "ProgressBar.h"
#include "ScriptLoader.h"
#include "ScriptSystem.h"
#include "SingletonImp.h"
INSTANTIATE_SINGLETON_1(ScriptMgr);
int num_sc_scripts;
Script *m_scripts[MAX_SCRIPTS];
+3 -2
View File
@@ -94,8 +94,9 @@ struct Script
class ScriptMgr
{
friend class ACE_Singleton<ScriptMgr, ACE_Null_Mutex>;
ScriptMgr();
public:
ScriptMgr();
~ScriptMgr();
void ScriptsInit();
@@ -158,6 +159,6 @@ void DoScriptText(int32 textEntry, WorldObject* pSource, Unit *pTarget = NULL);
#define FUNC_PTR(name, callconvention, returntype, parameters) typedef returntype(callconvention *name)parameters;
#endif
#define sScriptMgr Trinity::Singleton<ScriptMgr>::Instance()
#define sScriptMgr (*ACE_Singleton<ScriptMgr, ACE_Null_Mutex>::instance())
#endif
@@ -19,16 +19,11 @@
*/
#include "zlib.h"
#include "AddonHandler.h"
#include "DatabaseEnv.h"
#include "SingletonImp.h"
#include "Opcodes.h"
#include "Log.h"
INSTANTIATE_SINGLETON_1( AddonHandler );
AddonHandler::AddonHandler()
{
}
@@ -23,19 +23,20 @@
#include "Common.h"
#include "ConfigEnv.h"
#include "Singleton.h"
#include "ace/Singleton.h"
#include "WorldPacket.h"
class AddonHandler
{
/* Construction */
friend class ACE_Singleton<AddonHandler, ACE_Null_Mutex>;
AddonHandler();
public:
/* Construction */
AddonHandler();
~AddonHandler();
//built addon packet
//build addon packet
bool BuildAddonPacket(WorldPacket* Source, WorldPacket* Target);
};
#define sAddOnHandler Trinity::Singleton<AddonHandler>::Instance()
#define sAddOnHandler ACE_Singleton<AddonHandler, ACE_Null_Mutex>::instance()
#endif
@@ -91,7 +91,7 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recv_data)
if (!normalizePlayerName(Invitedname))
return;
player = ObjectAccessor::Instance().FindPlayerByName(Invitedname.c_str());
player = sObjectAccessor.FindPlayerByName(Invitedname.c_str());
}
if (!player)
@@ -18,8 +18,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "SingletonImp.h"
#include "ObjectMgr.h" // for normalizePlayerName
#include "ChannelMgr.h"
@@ -719,7 +719,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
pCurrChar->TeleportTo(pCurrChar->m_homebindMapId, pCurrChar->m_homebindX, pCurrChar->m_homebindY, pCurrChar->m_homebindZ, pCurrChar->GetOrientation());
}
ObjectAccessor::Instance().AddObject(pCurrChar);
sObjectAccessor.AddObject(pCurrChar);
//sLog.outDebug("Player %s added to Map.",pCurrChar->GetName());
pCurrChar->SendInitialPacketsAfterAddToMap();
@@ -75,7 +75,7 @@ void WorldSession::HandleGuildInviteOpcode(WorldPacket& recvPacket)
recvPacket >> Invitedname;
if (normalizePlayerName(Invitedname))
player = ObjectAccessor::Instance().FindPlayerByName(Invitedname.c_str());
player = sObjectAccessor.FindPlayerByName(Invitedname.c_str());
if (!player)
{
@@ -232,8 +232,8 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data)
data << uint32(clientcount); // clientcount place holder, listed count
data << uint32(clientcount); // clientcount place holder, online count
ObjectAccessor::Guard guard(*HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType& m = ObjectAccessor::Instance().GetPlayers();
ACE_GUARD(ACE_Thread_Mutex, g, *HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
{
if (security == SEC_PLAYER)
@@ -935,7 +935,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data)
return;
// check if player can enter instance : instance not full, and raid instance not in encounter fight
if (!MapManager::Instance().CanPlayerEnter(at->target_mapId, GetPlayer(), false))
if (!sMapMgr.CanPlayerEnter(at->target_mapId, GetPlayer(), false))
return;
GetPlayer()->TeleportTo(at->target_mapId,at->target_X,at->target_Y,at->target_Z,at->target_Orientation,TELE_TO_NOT_LEAVE_TRANSPORT);
@@ -75,7 +75,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
}
// relocate the player to the teleport destination
Map * newMap = MapManager::Instance().CreateMap(loc.GetMapId(), GetPlayer(), 0);
Map * newMap = sMapMgr.CreateMap(loc.GetMapId(), GetPlayer(), 0);
// the CanEnter checks are done in TeleporTo but conditions may change
// while the player is in transit, for example the map may get full
if (!newMap || !newMap->CanEnter(GetPlayer()))
@@ -302,7 +302,7 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data)
if (plMover && !plMover->GetTransport())
{
// elevators also cause the client to send MOVEMENTFLAG_ONTRANSPORT - just unmount if the guid can be found in the transport list
for (MapManager::TransportSet::const_iterator iter = MapManager::Instance().m_Transports.begin(); iter != MapManager::Instance().m_Transports.end(); ++iter)
for (MapManager::TransportSet::const_iterator iter = sMapMgr.m_Transports.begin(); iter != sMapMgr.m_Transports.end(); ++iter)
{
if ((*iter)->GetGUID() == movementInfo.t_guid)
{
@@ -302,7 +302,7 @@ void WorldSession::HandleCorpseQueryOpcode(WorldPacket & /*recv_data*/)
if (corpseMapEntry->IsDungeon() && corpseMapEntry->entrance_map >= 0)
{
// if corpse map have entrance
if (Map const* entranceMap = MapManager::Instance().CreateBaseMap(corpseMapEntry->entrance_map))
if (Map const* entranceMap = sMapMgr.CreateBaseMap(corpseMapEntry->entrance_map))
{
mapid = corpseMapEntry->entrance_map;
x = corpseMapEntry->entrance_x;
+2 -10
View File
@@ -23,14 +23,9 @@
*/
#include "WorldLog.h"
#include "SingletonImp.h"
#include "ConfigEnv.h"
#include "Log.h"
#define CLASS_LOCK Trinity::ClassLevelLockable<WorldLog, ACE_Thread_Mutex>
INSTANTIATE_SINGLETON_2(WorldLog, CLASS_LOCK);
INSTANTIATE_CLASS_MUTEX(WorldLog, ACE_Thread_Mutex);
WorldLog::WorldLog() : i_file(NULL)
{
Initialize();
@@ -67,7 +62,7 @@ void WorldLog::outTimestampLog(char const *fmt, ...)
{
if (LogWorld())
{
Guard guard(*this);
ACE_GUARD(ACE_Thread_Mutex, Guard, Lock);
ASSERT(i_file);
Log::outTimestamp(i_file);
@@ -95,7 +90,7 @@ void WorldLog::outLog(char const *fmt, ...)
{
if (LogWorld())
{
Guard guard(*this);
ACE_GUARD(ACE_Thread_Mutex, Guard, Lock);
ASSERT(i_file);
va_list args;
@@ -117,6 +112,3 @@ void WorldLog::outLog(char const *fmt, ...)
va_end(ap2);
}
}
#define sWorldLog WorldLog::Instance()
+5 -5
View File
@@ -26,19 +26,19 @@
#define TRINITY_WORLDLOG_H
#include "Common.h"
#include "Singleton.h"
#include "ace/Singleton.h"
#include "Errors.h"
#include <stdarg.h>
/// %Log packets to a file
class WorldLog : public Trinity::Singleton<WorldLog, Trinity::ClassLevelLockable<WorldLog, ACE_Thread_Mutex> >
class WorldLog
{
friend class Trinity::OperatorNew<WorldLog>;
friend class ACE_Singleton<WorldLog, ACE_Thread_Mutex>;
WorldLog();
WorldLog(const WorldLog &);
WorldLog& operator=(const WorldLog &);
typedef Trinity::ClassLevelLockable<WorldLog, ACE_Thread_Mutex>::Lock Guard;
ACE_Thread_Mutex Lock;
/// Close the file in destructor
~WorldLog();
@@ -57,7 +57,7 @@ class WorldLog : public Trinity::Singleton<WorldLog, Trinity::ClassLevelLockable
bool m_dbWorld;
};
#define sWorldLog WorldLog::Instance()
#define sWorldLog (*ACE_Singleton<WorldLog, ACE_Thread_Mutex>::instance())
#endif
/// @}
@@ -21,7 +21,6 @@
#include "DatabaseEnv.h"
#include "Log.h"
#include "ProgressBar.h"
#include "SingletonImp.h"
#include "World.h"
#include "Util.h"
#include "SkillDiscovery.h"
-1
View File
@@ -41,7 +41,6 @@
#include "MapManager.h"
#include "ObjectAccessor.h"
#include "CellImpl.h"
#include "SingletonImp.h"
#include "SharedDefines.h"
#include "LootMgr.h"
#include "VMapFactory.h"
+1 -1
View File
@@ -1164,7 +1164,7 @@ void SpellMgr::LoadSpellTargetPositions()
// additional requirements
if (spellInfo->Effect[i]==SPELL_EFFECT_BIND && spellInfo->EffectMiscValue[i])
{
uint32 area_id = MapManager::Instance().GetAreaId(st.target_mapId, st.target_X, st.target_Y, st.target_Z);
uint32 area_id = sMapMgr.GetAreaId(st.target_mapId, st.target_X, st.target_Y, st.target_Z);
if (area_id != uint32(spellInfo->EffectMiscValue[i]))
{
sLog.outErrorDb("Spell (Id: %u) listed in `spell_target_position` expected point to zone %u bit point to zone %u.",Spell_ID, spellInfo->EffectMiscValue[i], area_id);
+6 -9
View File
@@ -48,7 +48,6 @@
#include "ItemEnchantmentMgr.h"
#include "MapManager.h"
#include "CreatureAIRegistry.h"
#include "SingletonImp.h"
#include "BattleGroundMgr.h"
#include "OutdoorPvPMgr.h"
#include "TemporarySummon.h"
@@ -72,8 +71,6 @@
#include "LFGMgr.h"
#include "ConditionMgr.h"
INSTANTIATE_SINGLETON_1(World);
volatile bool World::m_stopEvent = false;
uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE;
volatile uint32 World::m_worldLoopCounter = 0;
@@ -635,7 +632,7 @@ void World::LoadConfigSettings(bool reload)
m_configs[CONFIG_INTERVAL_GRIDCLEAN] = MIN_GRID_DELAY;
}
if (reload)
MapManager::Instance().SetGridCleanUpDelay(m_configs[CONFIG_INTERVAL_GRIDCLEAN]);
sMapMgr.SetGridCleanUpDelay(m_configs[CONFIG_INTERVAL_GRIDCLEAN]);
m_configs[CONFIG_INTERVAL_MAPUPDATE] = sConfig.GetIntDefault("MapUpdateInterval", 100);
if (m_configs[CONFIG_INTERVAL_MAPUPDATE] < MIN_MAP_UPDATE_DELAY)
@@ -644,7 +641,7 @@ void World::LoadConfigSettings(bool reload)
m_configs[CONFIG_INTERVAL_MAPUPDATE] = MIN_MAP_UPDATE_DELAY;
}
if (reload)
MapManager::Instance().SetMapUpdateInterval(m_configs[CONFIG_INTERVAL_MAPUPDATE]);
sMapMgr.SetMapUpdateInterval(m_configs[CONFIG_INTERVAL_MAPUPDATE]);
m_configs[CONFIG_INTERVAL_CHANGEWEATHER] = sConfig.GetIntDefault("ChangeWeatherInterval", 10 * MINUTE * IN_MILISECONDS);
@@ -1666,7 +1663,7 @@ void World::SetInitialWorldSettings()
///- Initialize MapManager
sLog.outString("Starting Map System");
MapManager::Instance().Initialize();
sMapMgr.Initialize();
sLog.outString("Starting Game Event system...");
uint32 nextGameEvent = gameeventmgr.Initialize();
@@ -1693,7 +1690,7 @@ void World::SetInitialWorldSettings()
//Not sure if this can be moved up in the sequence (with static data loading) as it uses MapManager
sLog.outString("Loading Transports...");
MapManager::Instance().LoadTransports();
sMapMgr.LoadTransports();
sLog.outString("Deleting expired bans...");
LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate <= UNIX_TIMESTAMP() AND unbandate<>bandate");
@@ -1945,12 +1942,12 @@ void World::Update(uint32 diff)
/// <li> Handle all other objects
///- Update objects when the timer has passed (maps, transport, creatures,...)
MapManager::Instance().Update(diff); // As interval = 0
sMapMgr.Update(diff); // As interval = 0
/*if (m_timers[WUPDATE_OBJECTS].Passed())
{
m_timers[WUPDATE_OBJECTS].Reset();
MapManager::Instance().DoDelayedMovesAndRemoves();
sMapMgr.DoDelayedMovesAndRemoves();
}*/
static uint32 autobroadcaston = 0;
+2 -2
View File
@@ -27,7 +27,7 @@
#include "Common.h"
#include "Timer.h"
#include "Singleton.h"
#include <ace/Singleton.h>
#include "SharedDefines.h"
#include "ace/Atomic_Op.h"
#include "QueryResult.h"
@@ -779,6 +779,6 @@ class World
extern uint32 realmID;
#define sWorld Trinity::Singleton<World>::Instance()
#define sWorld (*ACE_Singleton<World, ACE_Null_Mutex>::instance())
#endif
/// @}
@@ -189,9 +189,9 @@ struct boss_victor_nefariusAI : public ScriptedAI
//Trinity::Singleton<MapManager>::Instance().GetMap(me->GetMapId(), me)->GetPlayers().begin();
/*
list <Player*>::const_iterator i = MapManager::Instance().GetMap(me->GetMapId(), me)->GetPlayers().begin();
list <Player*>::const_iterator i = sMapMgr.GetMap(me->GetMapId(), me)->GetPlayers().begin();
for (i = MapManager::Instance().GetMap(me->GetMapId(), me)->GetPlayers().begin(); i != MapManager::Instance().GetMap(me->GetMapId(), me)->GetPlayers().end(); ++i)
for (i = sMapMgr.GetMap(me->GetMapId(), me)->GetPlayers().begin(); i != sMapMgr.GetMap(me->GetMapId(), me)->GetPlayers().end(); ++i)
{
AttackStart((*i));
}
@@ -288,7 +288,7 @@ struct boss_victor_nefariusAI : public ScriptedAI
if (SpawnedAdds >= 42)
{
//Teleport Victor Nefarius way out of the map
//MapManager::Instance().GetMap(me->GetMapId(), me)->CreatureRelocation(me,0,0,-5000,0);
//sMapMgr.GetMap(me->GetMapId(), me)->CreatureRelocation(me,0,0,-5000,0);
//Inturrupt any spell casting
me->InterruptNonMeleeSpells(false);
-2
View File
@@ -12,7 +12,6 @@
set(shared_STAT_SRCS
Logging/Log.cpp
Policies/ObjectLifeTime.cpp
Threading/DelayExecutor.cpp
Threading/Threading.cpp
Utilities/ProgressBar.cpp
@@ -37,7 +36,6 @@ include_directories(
${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic
${CMAKE_SOURCE_DIR}/src/server/shared/Logging
${CMAKE_SOURCE_DIR}/src/server/shared/Packets
${CMAKE_SOURCE_DIR}/src/server/shared/Policies
${CMAKE_SOURCE_DIR}/src/server/shared/Threading
${CMAKE_SOURCE_DIR}/src/server/shared/Utilities
${MYSQL_INCLUDE_DIR}
@@ -19,9 +19,6 @@
*/
#include "ConfigEnv.h"
#include "Policies/SingletonImp.h"
INSTANTIATE_SINGLETON_1(Config);
Config::Config() : mIgnoreCase(true), mConf(NULL)
{
+4 -3
View File
@@ -21,15 +21,16 @@
#ifndef CONFIG_H
#define CONFIG_H
#include <Policies/Singleton.h>
#include <ace/Singleton.h>
#include "Define.h"
class DOTCONFDocument;
class Config
{
friend class ACE_Singleton<Config, ACE_Null_Mutex>;
Config();
public:
Config();
~Config();
bool SetSource(const char *file, bool ignorecase = true);
@@ -47,7 +48,7 @@ class Config
DOTCONFDocument *mConf;
};
#define sConfig Trinity::Singleton<Config>::Instance()
#define sConfig (*ACE_Singleton<Config, ACE_Null_Mutex>::instance())
#endif
-1
View File
@@ -25,7 +25,6 @@
#include "Updates/UpdateFields.h"
#include "Utilities/Util.h"
#include "Policies/SingletonImp.h"
#include "Define.h"
#include "Threading/Threading.h"
#include "Database/SqlDelayThread.h"
-1
View File
@@ -24,7 +24,6 @@
#include "Threading/Threading.h"
#include "Dynamic/UnorderedMap.h"
#include "Database/SqlDelayThread.h"
#include "Policies/Singleton.h"
#include "ace/Thread_Mutex.h"
#include "ace/Guard_T.h"
@@ -17,9 +17,6 @@
*/
#include "MemoryLeaks.h"
#include "Policies/SingletonImp.h"
INSTANTIATE_SINGLETON_1( MemoryManager ) ;
MemoryManager::MemoryManager( )
{
+3 -2
View File
@@ -39,10 +39,11 @@
#endif
#include "Policies/Singleton.h"
#include "ace/Singleton.h"
struct MemoryManager : public Trinity::Singleton < MemoryManager >
struct MemoryManager
{
MemoryManager();
};
#define sMemoryManager ACE_Singleton<MemoryManager, ACE_Null_Mutex>::instance()
#endif
@@ -1,100 +0,0 @@
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef TRINITY_REFERENCE_H
#define TRINITY_REFERENCE_H
/**
* Referencer<T>
* Referencer is an object that holds a reference holder that hold a reference
* counted object. When an object's reference count drop to zero, it removes
* the object. This is a non intrusive mechanism and any object at any point
* in time can be referenced. When and object is reference counted, do not
* pass the object directly to other methods but rather, pass its
* reference around. Objects can be reference counted in both single threaded
* model and multi-threaded model
*/
#include <stdexcept>
#include "Define.h"
#include "ThreadingModel.h"
#include "ReferenceHolder.h"
template
<
typename T,
class THREADING_MODEL = Trinity::SingleThreaded<T>
>
class Referencer
{
typedef typename THREADING_MODEL::Lock Lock;
typedef ReferenceHolder<T, THREADING_MODEL> ReferenceeHolder;
public:
/// Constructs a referencer.
Referencer(T *ref = NULL);
/// Copy constructor
Referencer(const Referencer &obj) : i_holder(NULL) { *this = obj; }
/// Destructor
~Referencer();
/// Referencee accessor
T* referencee(void) { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
const T* referencee(void) const { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
//T& referencee(void){ return _referencee(); }
//const T& referencee(void) const { return const_cast<Referencer *>(this)->_referencee(); }
operator T&(void) { return _referencee(); }
operator const T&(void) const { return *const_cast<Referencer *>(this)->_referencee(); }
/// cast operators
T* operator*() { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
T const * operator*() const { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
/// overload operators
T* operator->() { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
const T * operator->() const { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
/// operator =
Referencer& operator=(const Referencer &obj);
Referencer& operator=(T *);
/// returns true if i_referencee is null
bool isNull(void) const { return i_holder == NULL; }
private:
T& _referencee(void)
{
if( i_holder == NULL )
throw std::runtime_error("Invalid access to null pointer");
return *i_holder->i_referencee;
}
void deReference(ReferenceeHolder *);
void addReference(ReferenceeHolder *);
// private data
ReferenceeHolder *i_holder;
};
#endif
@@ -1,42 +0,0 @@
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef TRINITY_REFERENCEHOLDER_H
#define TRINITY_REFERENCEHOLDER_H
/** ReferenceHolder holds the actualy referenced obejct as well the refence
count. The ReferenecHolder implements as a policy base object and
will decided by the Reference class to be consnsitent.
*/
template
<
typename T,
class THREADING_MODEL
>
struct ReferenceHolder : public THREADING_MODEL
{
explicit ReferenceHolder(T *ref) : i_referencee(ref), i_referenceCount(0) {}
T *i_referencee;
unsigned int i_referenceCount;
typedef typename THREADING_MODEL::Lock Lock;
};
#endif
@@ -1,133 +0,0 @@
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef TRINITY_REFERENCEIMPL_H
#define TRINITY_REFERENCEIMPL_H
#include "Reference.h"
template
<
typename T,
class THREADING_MODEL
>
Referencer<T, THREADING_MODEL>::Referencer(T *ref)
: i_holder(NULL)
{
if( ref != NULL )
{
i_holder = new ReferenceeHolder(ref);
++i_holder->i_referenceCount;
}
}
template
<
typename T,
class THREADING_MODEL
>
Referencer<T, THREADING_MODEL>::~Referencer()
{
if( i_holder != NULL )
deReference(i_holder);
i_holder = NULL;
}
template
<
typename T,
class THREADING_MODEL
>
Referencer<T, THREADING_MODEL>&
Referencer<T, THREADING_MODEL>::operator=(const Referencer<T, THREADING_MODEL> &obj)
{
if( i_holder != NULL )
deReference(i_holder);
if( obj.i_holder != NULL )
addReference(obj.i_holder);
i_holder = obj.i_holder;
return *this;
}
template
<
typename T,
class THREADING_MODEL
>
Referencer<T, THREADING_MODEL>&
Referencer<T, THREADING_MODEL>::operator=(T *ref)
{
if( i_holder != NULL )
deReference(i_holder);
i_holder = NULL;
if( ref != NULL )
{
i_holder = new ReferenceeHolder(ref);
++i_holder->i_referenceCount;
}
return *this;
}
template
<
typename T,
class THREADING_MODEL
>
void
Referencer<T, THREADING_MODEL>::deReference(ReferenceHolder<T, THREADING_MODEL> *holder)
{
assert( holder != NULL && holder->i_referenceCount > 0);
bool delete_object = false;
{
// The guard is within the scope due to the guard
// must release earlier than expected.
Lock guard(*holder);
Guard(&guard);
--holder->i_referenceCount;
if( holder->i_referenceCount == 0 )
delete_object = true;
}
if( delete_object )
{
delete holder->i_referencee;
delete holder;
}
}
template
<
typename T,
class THREADING_MODEL
>
void
Referencer<T, THREADING_MODEL>::addReference(ReferenceHolder<T, THREADING_MODEL> *holder)
{
assert( i_holder != NULL );
Lock guard(*holder);
Guard(&guard);
++holder->i_referenceCount;
}
#endif
+4 -4
View File
@@ -24,7 +24,6 @@
#include "Define.h"
#include "Dynamic/TypeList.h"
#include "ObjectRegistry.h"
#include "Policies/SingletonImp.h"
/** FactoryHolder holds a factory object of a specific type
*/
@@ -33,14 +32,15 @@ class FactoryHolder
{
public:
typedef ObjectRegistry<FactoryHolder<T, Key >, Key > FactoryHolderRegistry;
typedef Trinity::Singleton<FactoryHolderRegistry > FactoryHolderRepository;
friend class ACE_Singleton<FactoryHolderRegistry, ACE_Null_Mutex>;
typedef ACE_Singleton<FactoryHolderRegistry, ACE_Null_Mutex> FactoryHolderRepository;
FactoryHolder(Key k) : i_key(k) {}
virtual ~FactoryHolder() {}
inline Key key() const { return i_key; }
void RegisterSelf(void) { FactoryHolderRepository::Instance().InsertItem(this, i_key); }
void DeregisterSelf(void) { FactoryHolderRepository::Instance().RemoveItem(this, false); }
void RegisterSelf(void) { FactoryHolderRepository::instance()->InsertItem(this, i_key); }
void DeregisterSelf(void) { FactoryHolderRepository::instance()->RemoveItem(this, false); }
/// Abstract Factory create method
virtual T* Create(void *data = NULL) const = 0;
+4 -6
View File
@@ -23,7 +23,7 @@
#include "Define.h"
#include "Dynamic/UnorderedMap.h"
#include "Policies/Singleton.h"
#include "ace/Singleton.h"
#include <string>
#include <vector>
@@ -94,11 +94,6 @@ class ObjectRegistry
return i_registeredObjects;
}
private:
RegistryMapType i_registeredObjects;
friend class Trinity::OperatorNew<ObjectRegistry<T, Key> >;
// protected for friend use since it should be a singleton
ObjectRegistry() {}
~ObjectRegistry()
{
@@ -106,6 +101,9 @@ class ObjectRegistry
delete iter->second;
i_registeredObjects.clear();
}
private:
RegistryMapType i_registeredObjects;
};
#endif
-3
View File
@@ -20,15 +20,12 @@
#include "Common.h"
#include "Log.h"
#include "Policies/SingletonImp.h"
#include "Configuration/ConfigEnv.h"
#include "Util.h"
#include <stdarg.h>
#include <stdio.h>
INSTANTIATE_SINGLETON_1( Log );
Log::Log() :
raLogfile(NULL), logfile(NULL), gmLogfile(NULL), charLogfile(NULL),
dberLogfile(NULL), chatLogfile(NULL), m_gmlog_per_account(false),
+5 -5
View File
@@ -22,7 +22,7 @@
#define TRINITYCORE_LOG_H
#include "Common.h"
#include "Policies/Singleton.h"
#include <ace/Singleton.h>
#include "Database/DatabaseEnv.h"
class Config;
@@ -82,9 +82,9 @@ enum ColorTypes
const int Colors = int(WHITE)+1;
class Log : public Trinity::Singleton<Log, Trinity::ClassLevelLockable<Log, ACE_Thread_Mutex> >
class Log
{
friend class Trinity::OperatorNew<Log>;
friend class ACE_Singleton<Log, ACE_Thread_Mutex>;
Log();
~Log();
@@ -172,10 +172,10 @@ class Log : public Trinity::Singleton<Log, Trinity::ClassLevelLockable<Log, ACE_
std::string m_dumpsDir;
};
#define sLog Trinity::Singleton<Log>::Instance()
#define sLog (*ACE_Singleton<Log, ACE_Thread_Mutex>::instance())
#ifdef TRINITY_DEBUG
#define DEBUG_LOG Trinity::Singleton<Log>::Instance().outDebug
#define DEBUG_LOG sLog.outDebug
#else
#define DEBUG_LOG
#endif
-110
View File
@@ -1,110 +0,0 @@
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef TRINITY_CREATIONPOLICY_H
#define TRINITY_CREATIONPOLICY_H
#include <stdlib.h>
#include "Define.h"
namespace Trinity
{
/**
* OperatorNew policy creates an object on the heap using new.
*/
template <class T>
class OperatorNew
{
public:
static T* Create(void) { return (new T); }
static void Destroy(T *obj) { delete obj; }
};
/**
* LocalStaticCreation policy creates an object on the stack
* the first time call Create.
*/
template <class T>
class LocalStaticCreation
{
union MaxAlign
{
char t_[sizeof(T)];
short int shortInt_;
int int_;
long int longInt_;
float float_;
double double_;
long double longDouble_;
struct Test;
int Test::* pMember_;
int (Test::*pMemberFn_)(int);
};
public:
static T* Create(void)
{
static MaxAlign si_localStatic;
return new(&si_localStatic) T;
}
static void Destroy(T *obj) { obj->~T(); }
};
/**
* CreateUsingMalloc by pass the memory manger.
*/
template<class T>
class CreateUsingMalloc
{
public:
static T* Create()
{
void* p = ::malloc(sizeof(T));
if (!p) return 0;
return new(p) T;
}
static void Destroy(T* p)
{
p->~T();
::free(p);
}
};
/**
* CreateOnCallBack creates the object base on the call back.
*/
template<class T, class CALL_BACK>
class CreateOnCallBack
{
public:
static T* Create()
{
return CALL_BACK::createCallBack();
}
static void Destroy(T *p)
{
CALL_BACK::destroyCallBack(p);
}
};
}
#endif

Some files were not shown because too many files have changed in this diff Show More