From cbaf5587d62459df3ddd0a4312cb549649c30a4a Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 7 Jun 2010 07:13:35 -0600 Subject: * shared lib builds again under Linux. --HG-- branch : trunk --- src/server/shared/Logging/Log.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/server/shared/Logging/Log.cpp') diff --git a/src/server/shared/Logging/Log.cpp b/src/server/shared/Logging/Log.cpp index 187b9eaa79b..e701e073d5c 100644 --- a/src/server/shared/Logging/Log.cpp +++ b/src/server/shared/Logging/Log.cpp @@ -21,7 +21,7 @@ #include "Common.h" #include "Log.h" #include "Policies/SingletonImp.h" -#include "Config/ConfigEnv.h" +#include "Configuration/ConfigEnv.h" #include "Util.h" #include -- cgit v1.2.3 From c9b20170a34feeaae4d57c6feba374b653223824 Mon Sep 17 00:00:00 2001 From: Xanadu Date: Tue, 22 Jun 2010 02:53:04 +0200 Subject: Cleanup of logging - removed a few duplicit functions from olden times, fixed a typo. --HG-- branch : trunk --- src/server/game/AI/ScriptedAI/ScriptedCreature.cpp | 8 +-- src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp | 36 +++++----- .../game/AI/ScriptedAI/ScriptedFollowerAI.cpp | 20 +++--- src/server/game/AI/ScriptedAI/ScriptedInstance.h | 10 +-- src/server/game/Instances/InstanceData.cpp | 8 +-- src/server/game/Scripting/ScriptMgr.cpp | 54 +++++++-------- src/server/game/Scripting/ScriptSystem.cpp | 66 +++++++++---------- .../BlackrockDepths/blackrock_depths.cpp | 2 +- .../BlackrockDepths/instance_blackrock_depths.cpp | 4 +- .../BlackwingLair/boss_victor_nefarius.cpp | 2 +- .../Karazhan/boss_shade_of_aran.cpp | 2 +- .../EasternKingdoms/Karazhan/bosses_opera.cpp | 6 +- .../scripts/EasternKingdoms/Karazhan/karazhan.cpp | 8 +-- .../scripts/EasternKingdoms/Karazhan/karazhan.h | 2 +- .../MagistersTerrace/boss_selin_fireheart.cpp | 8 +-- .../instance_magisters_terrace.cpp | 2 +- .../EasternKingdoms/ScarletEnclave/chapter1.cpp | 12 ++-- .../Stratholme/instance_stratholme.cpp | 14 ++-- .../SunwellPlateau/boss_brutallus.cpp | 6 +- .../SunwellPlateau/boss_kalecgos.cpp | 2 +- .../SunwellPlateau/boss_kiljaeden.cpp | 4 +- .../SunwellPlateau/instance_sunwell_plateau.cpp | 2 +- .../EasternKingdoms/Uldaman/boss_archaedas.cpp | 8 +-- .../EasternKingdoms/Uldaman/instance_uldaman.cpp | 2 +- .../EasternKingdoms/ZulAman/boss_janalai.cpp | 4 +- .../EasternKingdoms/ZulAman/instance_zulaman.cpp | 8 +-- .../EasternKingdoms/ZulGurub/boss_arlokk.cpp | 2 +- .../CavernsOfTime/BattleForMountHyjal/hyjal.cpp | 4 +- .../CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp | 8 +-- .../BattleForMountHyjal/instance_hyjal.cpp | 2 +- .../CavernsOfTime/DarkPortal/dark_portal.cpp | 4 +- .../DarkPortal/instance_dark_portal.cpp | 10 +-- .../instance_old_hillsbrad.cpp | 20 +++--- .../RazorfenKraul/instance_razorfen_kraul.cpp | 2 +- .../Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp | 4 +- src/server/scripts/Kalimdor/azuremyst_isle.cpp | 2 +- .../scripts/Northrend/Naxxramas/boss_gothik.cpp | 2 +- .../Northrend/ObsidianSanctum/boss_sartharion.cpp | 4 +- .../UtgardeKeep/instance_utgarde_keep.cpp | 2 +- .../ShadowLabyrinth/instance_shadow_labyrinth.cpp | 8 +-- .../scripts/Outland/BlackTemple/boss_illidan.cpp | 2 +- .../Outland/BlackTemple/boss_shade_of_akama.cpp | 16 ++--- .../Outland/BlackTemple/illidari_council.cpp | 6 +- .../Outland/BlackTemple/instance_black_temple.cpp | 2 +- .../SteamVault/instance_steam_vault.cpp | 4 +- .../instance_hellfire_ramparts.cpp | 2 +- .../Outland/TempestKeep/Eye/boss_kaelthas.cpp | 6 +- src/server/scripts/Outland/hellfire_peninsula.cpp | 2 +- src/server/scripts/Outland/netherstorm.cpp | 2 +- src/server/scripts/World/go_scripts.cpp | 2 +- src/server/scripts/World/item_scripts.cpp | 2 +- src/server/scripts/World/npc_professions.cpp | 2 +- src/server/scripts/World/npcs_special.cpp | 8 +-- src/server/shared/Logging/Log.cpp | 76 +--------------------- src/server/shared/Logging/Log.h | 6 -- 55 files changed, 216 insertions(+), 296 deletions(-) (limited to 'src/server/shared/Logging/Log.cpp') diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index a10d576e309..9ab9e06b624 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -153,7 +153,7 @@ void ScriptedAI::DoPlaySoundToSet(WorldObject* pSource, uint32 uiSoundId) if (!GetSoundEntriesStore()->LookupEntry(uiSoundId)) { - error_log("TSCR: Invalid soundId %u used in DoPlaySoundToSet (Source: TypeId %u, GUID %u)", uiSoundId, pSource->GetTypeId(), pSource->GetGUIDLow()); + sLog.outError("TSCR: Invalid soundId %u used in DoPlaySoundToSet (Source: TypeId %u, GUID %u)", uiSoundId, pSource->GetTypeId(), pSource->GetGUIDLow()); return; } @@ -398,7 +398,7 @@ void ScriptedAI::DoResetThreat() { if (!me->CanHaveThreatList() || me->getThreatManager().isThreatListEmpty()) { - error_log("TSCR: DoResetThreat called for creature that either cannot have threat list or has empty threat list (me entry = %d)", me->GetEntry()); + sLog.outError("TSCR: DoResetThreat called for creature that either cannot have threat list or has empty threat list (me entry = %d)", me->GetEntry()); return; } @@ -441,7 +441,7 @@ void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float fX, float fY, float fZ, flo if (!pUnit || pUnit->GetTypeId() != TYPEID_PLAYER) { if (pUnit) - error_log("TSCR: Creature %u (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: %u) to x: %f y:%f z: %f o: %f. Aborted.", me->GetGUID(), me->GetEntry(), pUnit->GetTypeId(), pUnit->GetGUID(), fX, fY, fZ, fO); + sLog.outError("TSCR: Creature %u (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: %u) to x: %f y:%f z: %f o: %f. Aborted.", me->GetGUID(), me->GetEntry(), pUnit->GetTypeId(), pUnit->GetGUID(), fX, fY, fZ, fO); return; } @@ -578,7 +578,7 @@ bool ScriptedAI::EnterEvadeIfOutOfCombatArea(const uint32 uiDiff) return false; break; default: - error_log("TSCR: EnterEvadeIfOutOfCombatArea used for creature entry %u, but does not have any definition.", me->GetEntry()); + sLog.outError("TSCR: EnterEvadeIfOutOfCombatArea used for creature entry %u, but does not have any definition.", me->GetEntry()); return false; } diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp index 217dd066310..0549858d1c7 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp @@ -177,7 +177,7 @@ void npc_escortAI::EnterEvadeMode() { AddEscortState(STATE_ESCORT_RETURNING); ReturnToLastPoint(); - debug_log("TSCR: EscortAI has left combat and is now returning to last point"); + sLog.outDebug("TSCR: EscortAI has left combat and is now returning to last point"); } else { @@ -224,7 +224,7 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff) { if (DespawnAtEnd) { - debug_log("TSCR: EscortAI reached end of waypoints"); + sLog.outDebug("TSCR: EscortAI reached end of waypoints"); if (m_bCanReturnToStart) { @@ -235,7 +235,7 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff) m_uiWPWaitTimer = 0; - debug_log("TSCR: EscortAI are returning home to spawn location: %u, %f, %f, %f", POINT_HOME, fRetX, fRetY, fRetZ); + sLog.outDebug("TSCR: EscortAI are returning home to spawn location: %u, %f, %f, %f", POINT_HOME, fRetX, fRetY, fRetZ); return; } @@ -251,7 +251,7 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff) } else { - debug_log("TSCR: EscortAI reached end of waypoints with Despawn off"); + sLog.outDebug("TSCR: EscortAI reached end of waypoints with Despawn off"); return; } @@ -260,7 +260,7 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff) if (!HasEscortState(STATE_ESCORT_PAUSED)) { me->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z); - debug_log("TSCR: EscortAI start waypoint %u (%f, %f, %f).", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z); + sLog.outDebug("TSCR: EscortAI start waypoint %u (%f, %f, %f).", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z); WaypointStart(CurrentWP->id); @@ -278,7 +278,7 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff) { if (DespawnAtFar && !IsPlayerOrGroupInRange()) { - debug_log("TSCR: EscortAI failed because player/group was to far away or not found"); + sLog.outDebug("TSCR: EscortAI failed because player/group was to far away or not found"); if (m_bCanInstantRespawn) { @@ -316,7 +316,7 @@ void npc_escortAI::MovementInform(uint32 uiMoveType, uint32 uiPointId) //Combat start position reached, continue waypoint movement if (uiPointId == POINT_LAST_POINT) { - debug_log("TSCR: EscortAI has returned to original position before combat"); + sLog.outDebug("TSCR: EscortAI has returned to original position before combat"); if (m_bIsRunning && me->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE)) me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); @@ -330,7 +330,7 @@ void npc_escortAI::MovementInform(uint32 uiMoveType, uint32 uiPointId) } else if (uiPointId == POINT_HOME) { - debug_log("TSCR: EscortAI has returned to original home location and will continue from beginning of waypoint list."); + sLog.outDebug("TSCR: EscortAI has returned to original home location and will continue from beginning of waypoint list."); CurrentWP = WaypointList.begin(); m_uiWPWaitTimer = 1; @@ -340,11 +340,11 @@ void npc_escortAI::MovementInform(uint32 uiMoveType, uint32 uiPointId) //Make sure that we are still on the right waypoint if (CurrentWP->id != uiPointId) { - error_log("TSCR ERROR: EscortAI reached waypoint out of order %u, expected %u, creature entry %u", uiPointId, CurrentWP->id, me->GetEntry()); + sLog.outError("TSCR ERROR: EscortAI reached waypoint out of order %u, expected %u, creature entry %u", uiPointId, CurrentWP->id, me->GetEntry()); return; } - debug_log("TSCR: EscortAI Waypoint %u reached", CurrentWP->id); + sLog.outDebug("TSCR: EscortAI Waypoint %u reached", CurrentWP->id); //Call WP function WaypointReached(CurrentWP->id); @@ -415,14 +415,14 @@ void npc_escortAI::SetRun(bool bRun) if (!m_bIsRunning) me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); else - debug_log("TSCR: EscortAI attempt to set run mode, but is already running."); + sLog.outDebug("TSCR: EscortAI attempt to set run mode, but is already running."); } else { if (m_bIsRunning) me->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); else - debug_log("TSCR: EscortAI attempt to set walk mode, but is already walking."); + sLog.outDebug("TSCR: EscortAI attempt to set walk mode, but is already walking."); } m_bIsRunning = bRun; } @@ -432,13 +432,13 @@ void npc_escortAI::Start(bool bIsActiveAttacker, bool bRun, uint64 uiPlayerGUID, { if (me->getVictim()) { - error_log("TSCR ERROR: EscortAI attempt to Start while in combat. Scriptname: %s, creature entry: %u", me->GetScriptName().c_str(), me->GetEntry()); + sLog.outError("TSCR ERROR: EscortAI attempt to Start while in combat. Scriptname: %s, creature entry: %u", me->GetScriptName().c_str(), me->GetEntry()); return; } if (HasEscortState(STATE_ESCORT_ESCORTING)) { - error_log("TSCR: EscortAI attempt to Start while already escorting."); + sLog.outError("TSCR: EscortAI attempt to Start while already escorting."); return; } @@ -454,7 +454,7 @@ void npc_escortAI::Start(bool bIsActiveAttacker, bool bRun, uint64 uiPlayerGUID, if (WaypointList.empty()) { - error_db_log("TSCR: EscortAI Start with 0 waypoints (possible missing entry in script_waypoint. Quest: %u).", pQuest ? pQuest->GetQuestId() : 0); + sLog.outErrorDb("TSCR: EscortAI Start with 0 waypoints (possible missing entry in script_waypoint. Quest: %u).", pQuest ? pQuest->GetQuestId() : 0); return; } @@ -469,19 +469,19 @@ void npc_escortAI::Start(bool bIsActiveAttacker, bool bRun, uint64 uiPlayerGUID, m_bCanReturnToStart = bCanLoopPath; if (m_bCanReturnToStart && m_bCanInstantRespawn) - debug_log("TSCR: EscortAI is set to return home after waypoint end and instant respawn at waypoint end. Creature will never despawn."); + sLog.outDebug("TSCR: EscortAI is set to return home after waypoint end and instant respawn at waypoint end. Creature will never despawn."); if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE) { me->GetMotionMaster()->MovementExpired(); me->GetMotionMaster()->MoveIdle(); - debug_log("TSCR: EscortAI start with WAYPOINT_MOTION_TYPE, changed to MoveIdle."); + sLog.outDebug("TSCR: EscortAI start with WAYPOINT_MOTION_TYPE, changed to MoveIdle."); } //disable npcflags me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); - debug_log("TSCR: EscortAI started with %u waypoints. ActiveAttacker = %d, Run = %d, PlayerGUID = %u", WaypointList.size(), m_bIsActiveAttacker, m_bIsRunning, m_uiPlayerGUID); + sLog.outDebug("TSCR: EscortAI started with %u waypoints. ActiveAttacker = %d, Run = %d, PlayerGUID = %u", WaypointList.size(), m_bIsActiveAttacker, m_bIsRunning, m_uiPlayerGUID); CurrentWP = WaypointList.begin(); diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp index b4a51f9eb27..6147edac45c 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp @@ -164,7 +164,7 @@ void FollowerAI::EnterEvadeMode() if (HasFollowState(STATE_FOLLOW_INPROGRESS)) { - debug_log("TSCR: FollowerAI left combat, returning to CombatStartPosition."); + sLog.outDebug("TSCR: FollowerAI left combat, returning to CombatStartPosition."); if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) { @@ -190,7 +190,7 @@ void FollowerAI::UpdateAI(const uint32 uiDiff) { if (HasFollowState(STATE_FOLLOW_COMPLETE) && !HasFollowState(STATE_FOLLOW_POSTEVENT)) { - debug_log("TSCR: FollowerAI is set completed, despawns."); + sLog.outDebug("TSCR: FollowerAI is set completed, despawns."); me->ForcedDespawn(); return; } @@ -201,7 +201,7 @@ void FollowerAI::UpdateAI(const uint32 uiDiff) { if (HasFollowState(STATE_FOLLOW_RETURNING)) { - debug_log("TSCR: FollowerAI is returning to leader."); + sLog.outDebug("TSCR: FollowerAI is returning to leader."); RemoveFollowState(STATE_FOLLOW_RETURNING); me->GetMotionMaster()->MoveFollow(pPlayer, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); @@ -230,7 +230,7 @@ void FollowerAI::UpdateAI(const uint32 uiDiff) if (bIsMaxRangeExceeded) { - debug_log("TSCR: FollowerAI failed because player/group was to far away or not found"); + sLog.outDebug("TSCR: FollowerAI failed because player/group was to far away or not found"); me->ForcedDespawn(); return; } @@ -273,13 +273,13 @@ void FollowerAI::StartFollow(Player* pLeader, uint32 uiFactionForFollower, const { if (me->getVictim()) { - debug_log("TSCR: FollowerAI attempt to StartFollow while in combat."); + sLog.outDebug("TSCR: FollowerAI attempt to StartFollow while in combat."); return; } if (HasFollowState(STATE_FOLLOW_INPROGRESS)) { - error_log("TSCR: FollowerAI attempt to StartFollow while already following."); + sLog.outError("TSCR: FollowerAI attempt to StartFollow while already following."); return; } @@ -295,7 +295,7 @@ void FollowerAI::StartFollow(Player* pLeader, uint32 uiFactionForFollower, const { me->GetMotionMaster()->Clear(); me->GetMotionMaster()->MoveIdle(); - debug_log("TSCR: FollowerAI start with WAYPOINT_MOTION_TYPE, set to MoveIdle."); + sLog.outDebug("TSCR: FollowerAI start with WAYPOINT_MOTION_TYPE, set to MoveIdle."); } me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); @@ -304,7 +304,7 @@ void FollowerAI::StartFollow(Player* pLeader, uint32 uiFactionForFollower, const me->GetMotionMaster()->MoveFollow(pLeader, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); - debug_log("TSCR: FollowerAI start follow %s (GUID %u)", pLeader->GetName(), m_uiLeaderGUID); + sLog.outDebug("TSCR: FollowerAI start follow %s (GUID %u)", pLeader->GetName(), m_uiLeaderGUID); } Player* FollowerAI::GetLeaderForFollower() @@ -323,7 +323,7 @@ Player* FollowerAI::GetLeaderForFollower() if (pMember && pMember->isAlive() && me->IsWithinDistInMap(pMember, MAX_PLAYER_DISTANCE)) { - debug_log("TSCR: FollowerAI GetLeader changed and returned new leader."); + sLog.outDebug("TSCR: FollowerAI GetLeader changed and returned new leader."); m_uiLeaderGUID = pMember->GetGUID(); return pMember; break; @@ -333,7 +333,7 @@ Player* FollowerAI::GetLeaderForFollower() } } - debug_log("TSCR: FollowerAI GetLeader can not find suitable leader."); + sLog.outDebug("TSCR: FollowerAI GetLeader can not find suitable leader."); return NULL; } diff --git a/src/server/game/AI/ScriptedAI/ScriptedInstance.h b/src/server/game/AI/ScriptedAI/ScriptedInstance.h index 25593e05300..8a9b8c4c5a3 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedInstance.h +++ b/src/server/game/AI/ScriptedAI/ScriptedInstance.h @@ -8,11 +8,11 @@ #include "InstanceData.h" #include "Map.h" -#define OUT_SAVE_INST_DATA debug_log("TSCR: Saving Instance Data for Instance %s (Map %d, Instance Id %d)", instance->GetMapName(), instance->GetId(), instance->GetInstanceId()) -#define OUT_SAVE_INST_DATA_COMPLETE debug_log("TSCR: Saving Instance Data for Instance %s (Map %d, Instance Id %d) completed.", instance->GetMapName(), instance->GetId(), instance->GetInstanceId()) -#define OUT_LOAD_INST_DATA(a) debug_log("TSCR: Loading Instance Data for Instance %s (Map %d, Instance Id %d). Input is '%s'", instance->GetMapName(), instance->GetId(), instance->GetInstanceId(), a) -#define OUT_LOAD_INST_DATA_COMPLETE debug_log("TSCR: Instance Data Load for Instance %s (Map %d, Instance Id: %d) is complete.",instance->GetMapName(), instance->GetId(), instance->GetInstanceId()) -#define OUT_LOAD_INST_DATA_FAIL error_log("TSCR: Unable to load Instance Data for Instance %s (Map %d, Instance Id: %d).",instance->GetMapName(), instance->GetId(), instance->GetInstanceId()) +#define OUT_SAVE_INST_DATA sLog.outDebug("TSCR: Saving Instance Data for Instance %s (Map %d, Instance Id %d)", instance->GetMapName(), instance->GetId(), instance->GetInstanceId()) +#define OUT_SAVE_INST_DATA_COMPLETE sLog.outDebug("TSCR: Saving Instance Data for Instance %s (Map %d, Instance Id %d) completed.", instance->GetMapName(), instance->GetId(), instance->GetInstanceId()) +#define OUT_LOAD_INST_DATA(a) sLog.outDebug("TSCR: Loading Instance Data for Instance %s (Map %d, Instance Id %d). Input is '%s'", instance->GetMapName(), instance->GetId(), instance->GetInstanceId(), a) +#define OUT_LOAD_INST_DATA_COMPLETE sLog.outDebug("TSCR: Instance Data Load for Instance %s (Map %d, Instance Id: %d) is complete.",instance->GetMapName(), instance->GetId(), instance->GetInstanceId()) +#define OUT_LOAD_INST_DATA_FAIL sLog.outError("TSCR: Unable to load Instance Data for Instance %s (Map %d, Instance Id: %d).",instance->GetMapName(), instance->GetId(), instance->GetInstanceId()) #define ScriptedInstance InstanceData diff --git a/src/server/game/Instances/InstanceData.cpp b/src/server/game/Instances/InstanceData.cpp index 5392ad4cbd1..7408efe97e5 100644 --- a/src/server/game/Instances/InstanceData.cpp +++ b/src/server/game/Instances/InstanceData.cpp @@ -43,7 +43,7 @@ void InstanceData::HandleGameObject(uint64 GUID, bool open, GameObject *go) if (go) go->SetGoState(open ? GO_STATE_ACTIVE : GO_STATE_READY); else - debug_log("TSCR: InstanceData: HandleGameObject failed"); + sLog.outDebug("TSCR: InstanceData: HandleGameObject failed"); } bool InstanceData::IsEncounterInProgress() const @@ -263,7 +263,7 @@ void InstanceData::DoUseDoorOrButton(uint64 uiGuid, uint32 uiWithRestoreTime, bo pGo->ResetDoorOrButton(); } else - error_log("SD2: Script call DoUseDoorOrButton, but gameobject entry %u is type %u.",pGo->GetEntry(),pGo->GetGoType()); + sLog.outError("SD2: Script call DoUseDoorOrButton, but gameobject entry %u is type %u.",pGo->GetEntry(),pGo->GetGoType()); } } @@ -294,7 +294,7 @@ void InstanceData::DoUpdateWorldState(uint32 uiStateId, uint32 uiStateData) pPlayer->SendUpdateWorldState(uiStateId, uiStateData); } else - debug_log("TSCR: DoUpdateWorldState attempt send data but no players in map."); + sLog.outDebug("TSCR: DoUpdateWorldState attempt send data but no players in map."); } // Send Notify to all players in instance @@ -318,7 +318,7 @@ void InstanceData::DoCompleteAchievement(uint32 achievement) if (!pAE) { - error_log("TSCR: DoCompleteAchievement called for not existing achievement %u", achievement); + sLog.outError("TSCR: DoCompleteAchievement called for not existing achievement %u", achievement); return; } diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index b41f6a215f8..88e5b7284c0 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -45,22 +45,22 @@ ScriptMgr::~ScriptMgr() void ScriptMgr::ScriptsInit() { //Trinity Script startup - /*outstring_log(" _____ _ _ _ ____ _ _"); - outstring_log("|_ _| __(_)_ __ (_) |_ _ _/ ___| ___ _ __(_)_ __ | |_ "); - outstring_log(" | || '__| | '_ \\| | __| | | \\___ \\ / __| \'__| | \'_ \\| __|"); - outstring_log(" | || | | | | | | | |_| |_| |___) | (__| | | | |_) | |_ "); - outstring_log(" |_||_| |_|_| |_|_|\\__|\\__, |____/ \\___|_| |_| .__/ \\__|"); - outstring_log(" |___/ |_| "); - outstring_log(""); - outstring_log("");*/ + /*sLog.outString(" _____ _ _ _ ____ _ _"); + sLog.outString("|_ _| __(_)_ __ (_) |_ _ _/ ___| ___ _ __(_)_ __ | |_ "); + sLog.outString(" | || '__| | '_ \\| | __| | | \\___ \\ / __| \'__| | \'_ \\| __|"); + sLog.outString(" | || | | | | | | | |_| |_| |___) | (__| | | | |_) | |_ "); + sLog.outString(" |_||_| |_|_| |_|_|\\__|\\__, |____/ \\___|_| |_| .__/ \\__|"); + sLog.outString(" |___/ |_| "); + sLog.outString(""); + sLog.outString("");*/ //Load database (must be called after SD2Config.SetSource). LoadDatabase(); - outstring_log("Loading C++ scripts"); + sLog.outString("Loading C++ scripts"); barGoLink bar(1); bar.step(); - outstring_log(""); + sLog.outString(""); for (uint16 i =0; i> Loaded %i C++ Scripts.", num_sc_scripts); + sLog.outString(">> Loaded %i C++ Scripts.", num_sc_scripts); - outstring_log(">> Load Overriden SQL Data."); + sLog.outString(">> Load Overriden SQL Data."); LoadOverridenSQLData(); } @@ -82,13 +82,13 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget) { if (!pSource) { - error_log("TSCR: DoScriptText entry %i, invalid Source pointer.", iTextEntry); + sLog.outError("TSCR: DoScriptText entry %i, invalid Source pointer.", iTextEntry); return; } if (iTextEntry >= 0) { - error_log("TSCR: DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative.", pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), iTextEntry); + sLog.outError("TSCR: DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative.", pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), iTextEntry); return; } @@ -96,11 +96,11 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget) if (!pData) { - error_log("TSCR: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.", pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), iTextEntry); + sLog.outError("TSCR: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.", pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), iTextEntry); return; } - debug_log("TSCR: DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u", iTextEntry, pData->uiSoundId, pData->uiType, pData->uiLanguage, pData->uiEmote); + sLog.outDebug("TSCR: DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u", iTextEntry, pData->uiSoundId, pData->uiType, pData->uiLanguage, pData->uiEmote); if (pData->uiSoundId) { @@ -109,7 +109,7 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget) pSource->SendPlaySound(pData->uiSoundId, false); } else - error_log("TSCR: DoScriptText entry %i tried to process invalid sound id %u.", iTextEntry, pData->uiSoundId); + sLog.outError("TSCR: DoScriptText entry %i tried to process invalid sound id %u.", iTextEntry, pData->uiSoundId); } if (pData->uiEmote) @@ -117,7 +117,7 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget) if (pSource->GetTypeId() == TYPEID_UNIT || pSource->GetTypeId() == TYPEID_PLAYER) ((Unit*)pSource)->HandleEmoteCommand(pData->uiEmote); else - error_log("TSCR: DoScriptText entry %i tried to process emote for invalid TypeId (%u).", iTextEntry, pSource->GetTypeId()); + sLog.outError("TSCR: DoScriptText entry %i tried to process emote for invalid TypeId (%u).", iTextEntry, pSource->GetTypeId()); } switch(pData->uiType) @@ -139,7 +139,7 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget) if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER) pSource->MonsterWhisper(iTextEntry, pTarget->GetGUID()); else - error_log("TSCR: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", iTextEntry); + sLog.outError("TSCR: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", iTextEntry); } break; case CHAT_TYPE_BOSS_WHISPER: @@ -147,7 +147,7 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget) if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER) pSource->MonsterWhisper(iTextEntry, pTarget->GetGUID(), true); else - error_log("TSCR: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", iTextEntry); + sLog.outError("TSCR: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", iTextEntry); } break; case CHAT_TYPE_ZONE_YELL: @@ -165,7 +165,7 @@ void Script::RegisterSelf() // somebody forgot to allocate memory for a script by a method like this: newscript = new Script if (m_scripts[i] == this) { - error_log("ScriptName: '%s' - Forgot to allocate memory, so this script and/or the script before that can't work.", Name.c_str()); + sLog.outError("ScriptName: '%s' - Forgot to allocate memory, so this script and/or the script before that can't work.", Name.c_str()); // don't register it // and don't delete it because its memory is used for another script return; @@ -200,14 +200,14 @@ void Script::RegisterSelf() else { // TODO: write a better error message than this one :) - error_log("ScriptName: '%s' already assigned with the same ScriptName, so the script can't work.", Name.c_str()); + sLog.outError("ScriptName: '%s' already assigned with the same ScriptName, so the script can't work.", Name.c_str()); delete this; } } else { if (Name.find("example") == std::string::npos) - error_db_log("TrinityScript: RegisterSelf, but script named %s does not have ScriptName assigned in database.",(this)->Name.c_str()); + sLog.outErrorDb("TrinityScript: RegisterSelf, but script named %s does not have ScriptName assigned in database.",(this)->Name.c_str()); delete this; } } @@ -326,7 +326,7 @@ bool ScriptMgr::GossipHello (Player * pPlayer, Creature* pCreature) bool ScriptMgr::GossipSelect(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction) { - debug_log("TSCR: Gossip selection, sender: %d, action: %d", uiSender, uiAction); + sLog.outDebug("TSCR: Gossip selection, sender: %d, action: %d", uiSender, uiAction); Script *tmpscript = m_scripts[pCreature->GetScriptId()]; if (!tmpscript || !tmpscript->pGossipSelect) return false; @@ -337,7 +337,7 @@ bool ScriptMgr::GossipSelect(Player* pPlayer, Creature* pCreature, uint32 uiSend bool ScriptMgr::GossipSelectWithCode(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction, const char* sCode) { - debug_log("TSCR: Gossip selection with code, sender: %d, action: %d", uiSender, uiAction); + sLog.outDebug("TSCR: Gossip selection with code, sender: %d, action: %d", uiSender, uiAction); Script *tmpscript = m_scripts[pCreature->GetScriptId()]; if (!tmpscript || !tmpscript->pGossipSelectWithCode) return false; @@ -350,7 +350,7 @@ bool ScriptMgr::GOSelect(Player* pPlayer, GameObject* pGO, uint32 uiSender, uint { if (!pGO) return false; - debug_log("TSCR: Gossip selection, sender: %d, action: %d", uiSender, uiAction); + sLog.outDebug("TSCR: Gossip selection, sender: %d, action: %d", uiSender, uiAction); Script *tmpscript = m_scripts[pGO->GetGOInfo()->ScriptId]; if (!tmpscript || !tmpscript->pGOSelect) return false; @@ -363,7 +363,7 @@ bool ScriptMgr::GOSelectWithCode(Player* pPlayer, GameObject* pGO, uint32 uiSend { if (!pGO) return false; - debug_log("TSCR: Gossip selection, sender: %d, action: %d",uiSender, uiAction); + sLog.outDebug("TSCR: Gossip selection, sender: %d, action: %d",uiSender, uiAction); Script *tmpscript = m_scripts[pGO->GetGOInfo()->ScriptId]; if (!tmpscript || !tmpscript->pGOSelectWithCode) return false; diff --git a/src/server/game/Scripting/ScriptSystem.cpp b/src/server/game/Scripting/ScriptSystem.cpp index fcd5c81add4..54a14228bc1 100644 --- a/src/server/game/Scripting/ScriptSystem.cpp +++ b/src/server/game/Scripting/ScriptSystem.cpp @@ -43,24 +43,24 @@ void SystemMgr::LoadVersion() { Field* pFields = Result->Fetch(); - outstring_log("TSCR: Database version is: %s", pFields[0].GetString()); - outstring_log(""); + sLog.outString("TSCR: Database version is: %s", pFields[0].GetString()); + sLog.outString(""); } else { - error_log("TSCR: Missing `version`.`script_version` information."); - outstring_log(""); + sLog.outError("TSCR: Missing `version`.`script_version` information."); + sLog.outString(""); } } void SystemMgr::LoadScriptTexts() { - outstring_log("TSCR: Loading Script Texts..."); + sLog.outString("TSCR: Loading Script Texts..."); LoadTrinityStrings(WorldDatabase,"script_texts",TEXT_SOURCE_RANGE,1+(TEXT_SOURCE_RANGE*2)); QueryResult_AutoPtr Result = WorldDatabase.Query("SELECT entry, sound, type, language, emote FROM script_texts"); - outstring_log("TSCR: Loading Script Texts additional data..."); + sLog.outString("TSCR: Loading Script Texts additional data..."); if (Result) { @@ -81,52 +81,52 @@ void SystemMgr::LoadScriptTexts() if (iId >= 0) { - error_db_log("TSCR: Entry %i in table `script_texts` is not a negative value.", iId); + sLog.outErrorDb("TSCR: Entry %i in table `script_texts` is not a negative value.", iId); continue; } if (iId > TEXT_SOURCE_RANGE || iId <= TEXT_SOURCE_RANGE*2) { - error_db_log("TSCR: Entry %i in table `script_texts` is out of accepted entry range for table.", iId); + sLog.outErrorDb("TSCR: Entry %i in table `script_texts` is out of accepted entry range for table.", iId); continue; } if (pTemp.uiSoundId) { if (!GetSoundEntriesStore()->LookupEntry(pTemp.uiSoundId)) - error_db_log("TSCR: Entry %i in table `script_texts` has soundId %u but sound does not exist.", iId, pTemp.uiSoundId); + sLog.outErrorDb("TSCR: Entry %i in table `script_texts` has soundId %u but sound does not exist.", iId, pTemp.uiSoundId); } if (!GetLanguageDescByID(pTemp.uiLanguage)) - error_db_log("TSCR: Entry %i in table `script_texts` using Language %u but Language does not exist.", iId, pTemp.uiLanguage); + sLog.outErrorDb("TSCR: Entry %i in table `script_texts` using Language %u but Language does not exist.", iId, pTemp.uiLanguage); if (pTemp.uiType > CHAT_TYPE_ZONE_YELL) - error_db_log("TSCR: Entry %i in table `script_texts` has Type %u but this Chat Type does not exist.", iId, pTemp.uiType); + sLog.outErrorDb("TSCR: Entry %i in table `script_texts` has Type %u but this Chat Type does not exist.", iId, pTemp.uiType); m_mTextDataMap[iId] = pTemp; ++uiCount; } while (Result->NextRow()); - outstring_log(""); - outstring_log(">> Loaded %u additional Script Texts data.", uiCount); + sLog.outString(""); + sLog.outString(">> Loaded %u additional Script Texts data.", uiCount); } else { barGoLink bar(1); bar.step(); - outstring_log(""); - outstring_log(">> Loaded 0 additional Script Texts data. DB table `script_texts` is empty."); + sLog.outString(""); + sLog.outString(">> Loaded 0 additional Script Texts data. DB table `script_texts` is empty."); } } void SystemMgr::LoadScriptTextsCustom() { - outstring_log("TSCR: Loading Custom Texts..."); + sLog.outString("TSCR: Loading Custom Texts..."); LoadTrinityStrings(WorldDatabase,"custom_texts",TEXT_SOURCE_RANGE*2,1+(TEXT_SOURCE_RANGE*3)); QueryResult_AutoPtr Result = WorldDatabase.Query("SELECT entry, sound, type, language, emote FROM custom_texts"); - outstring_log("TSCR: Loading Custom Texts additional data..."); + sLog.outString("TSCR: Loading Custom Texts additional data..."); if (Result) { @@ -147,41 +147,41 @@ void SystemMgr::LoadScriptTextsCustom() if (iId >= 0) { - error_db_log("TSCR: Entry %i in table `custom_texts` is not a negative value.", iId); + sLog.outErrorDb("TSCR: Entry %i in table `custom_texts` is not a negative value.", iId); continue; } if (iId > TEXT_SOURCE_RANGE*2 || iId <= TEXT_SOURCE_RANGE*3) { - error_db_log("TSCR: Entry %i in table `custom_texts` is out of accepted entry range for table.", iId); + sLog.outErrorDb("TSCR: Entry %i in table `custom_texts` is out of accepted entry range for table.", iId); continue; } if (pTemp.uiSoundId) { if (!GetSoundEntriesStore()->LookupEntry(pTemp.uiSoundId)) - error_db_log("TSCR: Entry %i in table `custom_texts` has soundId %u but sound does not exist.", iId, pTemp.uiSoundId); + sLog.outErrorDb("TSCR: Entry %i in table `custom_texts` has soundId %u but sound does not exist.", iId, pTemp.uiSoundId); } if (!GetLanguageDescByID(pTemp.uiLanguage)) - error_db_log("TSCR: Entry %i in table `custom_texts` using Language %u but Language does not exist.", iId, pTemp.uiLanguage); + sLog.outErrorDb("TSCR: Entry %i in table `custom_texts` using Language %u but Language does not exist.", iId, pTemp.uiLanguage); if (pTemp.uiType > CHAT_TYPE_ZONE_YELL) - error_db_log("TSCR: Entry %i in table `custom_texts` has Type %u but this Chat Type does not exist.", iId, pTemp.uiType); + sLog.outErrorDb("TSCR: Entry %i in table `custom_texts` has Type %u but this Chat Type does not exist.", iId, pTemp.uiType); m_mTextDataMap[iId] = pTemp; ++uiCount; } while (Result->NextRow()); - outstring_log(""); - outstring_log(">> Loaded %u additional Custom Texts data.", uiCount); + sLog.outString(""); + sLog.outString(">> Loaded %u additional Custom Texts data.", uiCount); } else { barGoLink bar(1); bar.step(); - outstring_log(""); - outstring_log(">> Loaded 0 additional Custom Texts data. DB table `custom_texts` is empty."); + sLog.outString(""); + sLog.outString(">> Loaded 0 additional Custom Texts data. DB table `custom_texts` is empty."); } } @@ -197,7 +197,7 @@ void SystemMgr::LoadScriptWaypoints() if (Result) uiCreatureCount = Result->GetRowCount(); - outstring_log("TSCR: Loading Script Waypoints for %u creature(s)...", uiCreatureCount); + sLog.outString("TSCR: Loading Script Waypoints for %u creature(s)...", uiCreatureCount); Result = WorldDatabase.Query("SELECT entry, pointid, location_x, location_y, location_z, waittime FROM script_waypoint ORDER BY pointid"); @@ -224,25 +224,25 @@ void SystemMgr::LoadScriptWaypoints() if (!pCInfo) { - error_db_log("TSCR: DB table script_waypoint has waypoint for non-existant creature entry %u", pTemp.uiCreatureEntry); + sLog.outErrorDb("TSCR: DB table script_waypoint has waypoint for non-existant creature entry %u", pTemp.uiCreatureEntry); continue; } if (!pCInfo->ScriptID) - error_db_log("TSCR: DB table script_waypoint has waypoint for creature entry %u, but creature does not have ScriptName defined and then useless.", pTemp.uiCreatureEntry); + sLog.outErrorDb("TSCR: DB table script_waypoint has waypoint for creature entry %u, but creature does not have ScriptName defined and then useless.", pTemp.uiCreatureEntry); m_mPointMoveMap[uiEntry].push_back(pTemp); ++uiNodeCount; } while (Result->NextRow()); - outstring_log(""); - outstring_log(">> Loaded %u Script Waypoint nodes.", uiNodeCount); + sLog.outString(""); + sLog.outString(">> Loaded %u Script Waypoint nodes.", uiNodeCount); } else { barGoLink bar(1); bar.step(); - outstring_log(""); - outstring_log(">> Loaded 0 Script Waypoints. DB table `script_waypoint` is empty."); + sLog.outString(""); + sLog.outString(">> Loaded 0 Script Waypoints. DB table `script_waypoint` is empty."); } } diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp index 09ed6a1c4b0..a27f28e8d9c 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp @@ -214,7 +214,7 @@ struct npc_grimstoneAI : public npc_escortAI if (pInstance) { pInstance->SetData(TYPE_RING_OF_LAW,DONE); - debug_log("TSCR: npc_grimstone: event reached end and set complete."); + sLog.outDebug("TSCR: npc_grimstone: event reached end and set complete."); } break; } diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/instance_blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/instance_blackrock_depths.cpp index 6c865ee214d..3dd048ce449 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/instance_blackrock_depths.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/instance_blackrock_depths.cpp @@ -207,7 +207,7 @@ struct instance_blackrock_depths : public ScriptedInstance void SetData64(uint32 type, uint64 data) { - debug_log("TSCR: Instance Blackrock Depths: SetData64 update (Type: %u Data %u)", type, data); + sLog.outDebug("TSCR: Instance Blackrock Depths: SetData64 update (Type: %u Data %u)", type, data); switch(type) { @@ -223,7 +223,7 @@ struct instance_blackrock_depths : public ScriptedInstance void SetData(uint32 type, uint32 data) { - debug_log("TSCR: Instance Blackrock Depths: SetData update (Type: %u Data %u)", type, data); + sLog.outDebug("TSCR: Instance Blackrock Depths: SetData update (Type: %u Data %u)", type, data); switch(type) { diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_victor_nefarius.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_victor_nefarius.cpp index 74d118033c6..b079dd94a58 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_victor_nefarius.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_victor_nefarius.cpp @@ -312,7 +312,7 @@ struct boss_victor_nefariusAI : public ScriptedAI Nefarian->setFaction(103); NefarianGUID = Nefarian->GetGUID(); } - else error_log("TSCR: Blackwing Lair: Unable to spawn nefarian properly."); + else sLog.outError("TSCR: Blackwing Lair: Unable to spawn nefarian properly."); } AddSpawnTimer = 4000; diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp index 19bf7d235ed..e7c26491cb0 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp @@ -534,7 +534,7 @@ CreatureAI* GetAI_water_elemental(Creature* pCreature) // CONVERT TO ACID CreatureAI* GetAI_shadow_of_aran(Creature* pCreature) { - outstring_log("TSCR: Convert simpleAI script for Creature Entry %u to ACID", pCreature->GetEntry()); + sLog.outString("TSCR: Convert simpleAI script for Creature Entry %u to ACID", pCreature->GetEntry()); SimpleAI* ai = new SimpleAI (pCreature); ai->Spell[0].Enabled = true; diff --git a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp index 11e87b9e82e..bf4db4d9d01 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp @@ -1154,7 +1154,7 @@ void boss_julianneAI::DamageTaken(Unit* /*done_by*/, uint32 &damage) if (Phase == PHASE_ROMULO) { - error_log("TSCR: boss_julianneAI: cannot take damage in PHASE_ROMULO, why was i here?"); + sLog.outError("TSCR: boss_julianneAI: cannot take damage in PHASE_ROMULO, why was i here?"); damage = 0; return; } @@ -1188,7 +1188,7 @@ void boss_julianneAI::DamageTaken(Unit* /*done_by*/, uint32 &damage) return; } } - error_log("TSCR: boss_julianneAI: DamageTaken reach end of code, that should not happen."); + sLog.outError("TSCR: boss_julianneAI: DamageTaken reach end of code, that should not happen."); } void boss_romuloAI::DamageTaken(Unit* /*done_by*/, uint32 &damage) @@ -1242,7 +1242,7 @@ void boss_romuloAI::DamageTaken(Unit* /*done_by*/, uint32 &damage) } } - error_log("TSCR: boss_romuloAI: DamageTaken reach end of code, that should not happen."); + sLog.outError("TSCR: boss_romuloAI: DamageTaken reach end of code, that should not happen."); } void boss_julianneAI::UpdateAI(const uint32 diff) diff --git a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp index 321a65c2544..a388600b51d 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp @@ -220,7 +220,7 @@ struct npc_barnesAI : public npc_escortAI void PrepareEncounter() { - debug_log("TSCR: Barnes Opera Event - Introduction complete - preparing encounter %d", m_uiEventId); + sLog.outDebug("TSCR: Barnes Opera Event - Introduction complete - preparing encounter %d", m_uiEventId); uint8 index = 0; uint8 count = 0; @@ -371,17 +371,17 @@ bool GossipSelect_npc_barnes(Player* pPlayer, Creature* pCreature, uint32 /*uiSe case GOSSIP_ACTION_INFO_DEF+3: pPlayer->CLOSE_GOSSIP_MENU(); pBarnesAI->m_uiEventId = EVENT_OZ; - outstring_log("TSCR: player (GUID %i) manually set Opera event to EVENT_OZ",pPlayer->GetGUID()); + sLog.outString("TSCR: player (GUID %i) manually set Opera event to EVENT_OZ",pPlayer->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+4: pPlayer->CLOSE_GOSSIP_MENU(); pBarnesAI->m_uiEventId = EVENT_HOOD; - outstring_log("TSCR: player (GUID %i) manually set Opera event to EVENT_HOOD",pPlayer->GetGUID()); + sLog.outString("TSCR: player (GUID %i) manually set Opera event to EVENT_HOOD",pPlayer->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+5: pPlayer->CLOSE_GOSSIP_MENU(); pBarnesAI->m_uiEventId = EVENT_RAJ; - outstring_log("TSCR: player (GUID %i) manually set Opera event to EVENT_RAJ",pPlayer->GetGUID()); + sLog.outString("TSCR: player (GUID %i) manually set Opera event to EVENT_RAJ",pPlayer->GetGUID()); break; } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.h b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.h index 56a6b106332..86562fd06df 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.h +++ b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.h @@ -48,6 +48,6 @@ enum OperaEvents EVENT_RAJ = 3 }; -#define ERROR_INST_DATA(a) error_log("TSCR: Instance Data for Karazhan not set properly. Encounter for Creature Entry %u may not work properly.", a->GetEntry()); +#define ERROR_INST_DATA(a) sLog.outError("TSCR: Instance Data for Karazhan not set properly. Encounter for Creature Entry %u may not work properly.", a->GetEntry()); #endif diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp index 7dc8db7ce15..15be0f2f87a 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp @@ -63,7 +63,7 @@ struct boss_selin_fireheartAI : public ScriptedAI for (uint8 i = 0; i < size; ++i) { uint64 guid = pInstance->GetData64(DATA_FEL_CRYSTAL); - debug_log("TSCR: Selin: Adding Fel Crystal %u to list", guid); + sLog.outDebug("TSCR: Selin: Adding Fel Crystal %u to list", guid); Crystals.push_back(guid); } } @@ -108,7 +108,7 @@ struct boss_selin_fireheartAI : public ScriptedAI // Small door opened after event are expected to be closed by default // Set Inst data for encounter pInstance->SetData(DATA_SELIN_EVENT, NOT_STARTED); - } else error_log(ERROR_INST_DATA); + } else sLog.outError(ERROR_INST_DATA); DrainLifeTimer = 3000 + rand()%4000; DrainManaTimer = DrainLifeTimer + 5000; @@ -208,7 +208,7 @@ struct boss_selin_fireheartAI : public ScriptedAI else { // Make an error message in case something weird happened here - error_log("TSCR: Selin Fireheart unable to drain crystal as the crystal is either dead or despawned"); + sLog.outError("TSCR: Selin Fireheart unable to drain crystal as the crystal is either dead or despawned"); DrainingCrystal = false; } } @@ -340,7 +340,7 @@ struct mob_fel_crystalAI : public ScriptedAI } } } - } else error_log(ERROR_INST_DATA); + } else sLog.outError(ERROR_INST_DATA); } }; diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp index 715261f8239..ff8b0b88786 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp @@ -169,7 +169,7 @@ struct instance_magisters_terrace : public ScriptedInstance { if (FelCrystals.empty()) { - error_log("TSCR: Magisters Terrace: No Fel Crystals loaded in Inst Data"); + sLog.outError("TSCR: Magisters Terrace: No Fel Crystals loaded in Inst Data"); return 0; } diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp index f801f7e872e..9dcfc4ad459 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp @@ -199,7 +199,7 @@ void npc_unworthy_initiateAI::UpdateAI(const uint32 diff) anchorGUID = anchor->GetGUID(); } else - error_log("npc_unworthy_initiateAI: unable to find anchor!"); + sLog.outError("npc_unworthy_initiateAI: unable to find anchor!"); float dist = 99.0f; GameObject *prison = NULL; @@ -219,7 +219,7 @@ void npc_unworthy_initiateAI::UpdateAI(const uint32 diff) if (prison) prison->ResetDoorOrButton(); else - error_log("npc_unworthy_initiateAI: unable to find prison!"); + sLog.outError("npc_unworthy_initiateAI: unable to find prison!"); } return; case PHASE_TO_EQUIP: @@ -230,7 +230,7 @@ void npc_unworthy_initiateAI::UpdateAI(const uint32 diff) else { me->GetMotionMaster()->MovePoint(1, anchorX, anchorY, me->GetPositionZ()); - //debug_log("npc_unworthy_initiateAI: move to %f %f %f", anchorX, anchorY, me->GetPositionZ()); + //sLog.outDebug("npc_unworthy_initiateAI: move to %f %f %f", anchorX, anchorY, me->GetPositionZ()); phase = PHASE_EQUIPING; wait_timer = 0; } @@ -989,9 +989,9 @@ bool GOHello_go_inconspicuous_mine_car(Player* pPlayer, GameObject* /*pGO*/) { car->AI()->SetGUID(miner->GetGUID()); CAST_AI(npc_scarlet_minerAI, miner->AI())->InitCartQuest(pPlayer); - } else error_log("TSCR: GOHello_go_inconspicuous_mine_car vehicle entry is not correct."); - } else error_log("TSCR: GOHello_go_inconspicuous_mine_car player is not on the vehicle."); - } else error_log("TSCR: GOHello_go_inconspicuous_mine_car Scarlet Miner cant be found by script."); + } else sLog.outError("TSCR: GOHello_go_inconspicuous_mine_car vehicle entry is not correct."); + } else sLog.outError("TSCR: GOHello_go_inconspicuous_mine_car player is not on the vehicle."); + } else sLog.outError("TSCR: GOHello_go_inconspicuous_mine_car Scarlet Miner cant be found by script."); } return true; } diff --git a/src/server/scripts/EasternKingdoms/Stratholme/instance_stratholme.cpp b/src/server/scripts/EasternKingdoms/Stratholme/instance_stratholme.cpp index 191be16cd19..ce5794237f1 100644 --- a/src/server/scripts/EasternKingdoms/Stratholme/instance_stratholme.cpp +++ b/src/server/scripts/EasternKingdoms/Stratholme/instance_stratholme.cpp @@ -112,7 +112,7 @@ struct instance_stratholme : public ScriptedInstance return true; } - debug_log("TSCR: Instance Stratholme: Cannot open slaugther square yet."); + sLog.outDebug("TSCR: Instance Stratholme: Cannot open slaugther square yet."); return false; } @@ -208,7 +208,7 @@ struct instance_stratholme : public ScriptedInstance break; Encounter[0] = data; BaronRun_Timer = 2700000; - debug_log("TSCR: Instance Stratholme: Baron run in progress."); + sLog.outDebug("TSCR: Instance Stratholme: Baron run in progress."); break; case FAIL: //may add code to remove aura from players, but in theory the time should be up already and removed. @@ -266,10 +266,10 @@ struct instance_stratholme : public ScriptedInstance //UpdateGoState(ziggurat4GUID,0,true); if (Creature* pBaron = instance->GetCreature(baronGUID)) pBaron->SummonCreature(C_RAMSTEIN,4032.84,-3390.24,119.73,4.71,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,1800000); - debug_log("TSCR: Instance Stratholme: Ramstein spawned."); + sLog.outDebug("TSCR: Instance Stratholme: Ramstein spawned."); } else - debug_log("TSCR: Instance Stratholme: %u Abomnation left to kill.",count); + sLog.outDebug("TSCR: Instance Stratholme: %u Abomnation left to kill.",count); } if (data == NOT_STARTED) @@ -278,7 +278,7 @@ struct instance_stratholme : public ScriptedInstance if (data == DONE) { SlaugtherSquare_Timer = 300000; - debug_log("TSCR: Instance Stratholme: Slaugther event will continue in 5 minutes."); + sLog.outDebug("TSCR: Instance Stratholme: Slaugther event will continue in 5 minutes."); } Encounter[4] = data; break; @@ -419,7 +419,7 @@ struct instance_stratholme : public ScriptedInstance if (GetData(TYPE_BARON_RUN) != DONE) SetData(TYPE_BARON_RUN, FAIL); BaronRun_Timer = 0; - debug_log("TSCR: Instance Stratholme: Baron run event reached end. Event has state %u.",GetData(TYPE_BARON_RUN)); + sLog.outDebug("TSCR: Instance Stratholme: Baron run event reached end. Event has state %u.",GetData(TYPE_BARON_RUN)); } else BaronRun_Timer -= diff; } @@ -434,7 +434,7 @@ struct instance_stratholme : public ScriptedInstance HandleGameObject(ziggurat4GUID, true); HandleGameObject(ziggurat5GUID, true); - debug_log("TSCR: Instance Stratholme: Black guard sentries spawned. Opening gates to baron."); + sLog.outDebug("TSCR: Instance Stratholme: Black guard sentries spawned. Opening gates to baron."); } SlaugtherSquare_Timer = 0; } else SlaugtherSquare_Timer -= diff; diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp index 52ded56c5ae..2bf2967c914 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp @@ -143,7 +143,7 @@ struct boss_brutallusAI : public ScriptedAI { if (!Intro || IsIntro) return; - error_log("Start Intro"); + sLog.outError("Start Intro"); Creature *Madrigosa = Unit::GetCreature(*me, pInstance ? pInstance->GetData64(DATA_MADRIGOSA) : 0); if (Madrigosa) { @@ -158,7 +158,7 @@ struct boss_brutallusAI : public ScriptedAI }else { //Madrigosa not found, end intro - error_log("Madrigosa was not found"); + sLog.outError("Madrigosa was not found"); EndIntro(); } } @@ -168,7 +168,7 @@ struct boss_brutallusAI : public ScriptedAI me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); Intro = false; IsIntro = false; - error_log("End Intro"); + sLog.outError("End Intro"); } void AttackStart(Unit* pWho) diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index 3c1ae1a1723..c41b213bd6a 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -260,7 +260,7 @@ struct boss_kalecgosAI : public ScriptedAI } else { - error_log("TSCR: Didn't find Shathrowar. Kalecgos event reseted."); + sLog.outError("TSCR: Didn't find Shathrowar. Kalecgos event reseted."); EnterEvadeMode(); return; } diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp index 7bd3273d9f2..d80153c14f5 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp @@ -727,7 +727,7 @@ struct boss_kiljaedenAI : public Scripted_NoMovementAI if (pRandomPlayer) DoCast(pRandomPlayer, SPELL_LEGION_LIGHTNING, false); else - error_log("try to cast SPELL_LEGION_LIGHTNING on invalid target"); + sLog.outError("try to cast SPELL_LEGION_LIGHTNING on invalid target"); Timer[TIMER_LEGION_LIGHTNING] = (Phase == PHASE_SACRIFICE) ? 18000 : 30000; // 18 seconds in PHASE_SACRIFICE Timer[TIMER_SOUL_FLAY] = 2500; @@ -1341,7 +1341,7 @@ struct mob_sinster_reflectionAI : public ScriptedAI DoMeleeAttackIfReady(); break; } - debug_log("Sinister-Timer"); + sLog.outDebug("Sinister-Timer"); for (uint8 i = 0; i < 3; ++i) uiTimer[i] -= diff; } diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp index 5ad630840ea..12e94c2f33d 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp @@ -110,7 +110,7 @@ struct instance_sunwell_plateau : public ScriptedInstance } } - debug_log("TSCR: Instance Sunwell Plateau: GetPlayerInMap, but PlayerList is empty!"); + sLog.outDebug("TSCR: Instance Sunwell Plateau: GetPlayerInMap, but PlayerList is empty!"); return NULL; } diff --git a/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp b/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp index 3641f901453..957dbec7ba5 100644 --- a/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp +++ b/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp @@ -436,7 +436,7 @@ bool GOHello_go_altar_of_the_keepers(Player* pPlayer, GameObject* /*pGo*/) //if (altarOfTheKeeperCounter < NUMBER_NEEDED_TO_ACTIVATE) //{ - //error_log("not enough people yet, altarOfTheKeeperCounter = %d", altarOfTheKeeperCounter); + //sLog.outError("not enough people yet, altarOfTheKeeperCounter = %d", altarOfTheKeeperCounter); // return false; // not enough people yet //} /* @@ -446,7 +446,7 @@ bool GOHello_go_altar_of_the_keepers(Player* pPlayer, GameObject* /*pGo*/) for (uint8 x = 0; x < 5; ++x) { pTarget = Unit::GetUnit(*pPlayer, altarOfTheKeeperCount[x]); - //error_log("number of people currently activating it: %d", x+1); + //sLog.outError("number of people currently activating it: %d", x+1); if (!pTarget) continue; if (pTarget->IsNonMeleeSpellCasted(true)) @@ -457,11 +457,11 @@ bool GOHello_go_altar_of_the_keepers(Player* pPlayer, GameObject* /*pGo*/) if (count < NUMBER_NEEDED_TO_ACTIVATE) { - //error_log("still not enough people"); + //sLog.outError("still not enough people"); return true; // not enough people } */ - //error_log ("activating stone keepers"); + //sLog.outError ("activating stone keepers"); pInstance->SetData(NULL,1); // activate the Stone Keepers return true; } diff --git a/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp b/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp index 9720d6caa79..f09f9268395 100644 --- a/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp +++ b/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp @@ -215,7 +215,7 @@ struct instance_uldaman : public ScriptedInstance void SetData (uint32 /*type*/, uint32 data) { - //error_log ("SetData: data = %d", data); + //sLog.outError ("SetData: data = %d", data); if (data == 0) OpenDoor (altarOfTheKeeperTempleDoor); if (data == 0) OpenDoor (archaedasTempleDoor); if (data == 3) OpenDoor (ancientVaultDoor); diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp index 64ad50ea70f..9ab4937163a 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp @@ -242,7 +242,7 @@ struct boss_janalaiAI : public ScriptedAI cell.Visit(pair, cSearcher, *(me->GetMap())); } - //error_log("Eggs %d at middle", templist.size()); + //sLog.outError("Eggs %d at middle", templist.size()); if (!templist.size()) return false; @@ -508,7 +508,7 @@ struct mob_amanishi_hatcherAI : public ScriptedAI cell.Visit(pair, cSearcher, *(me->GetMap())); } - //error_log("Eggs %d at %d", templist.size(), side); + //sLog.outError("Eggs %d at %d", templist.size(), side); for (std::list::const_iterator i = templist.begin(); i != templist.end() && num > 0; ++i) if ((*i)->GetDisplayId() != 11686) diff --git a/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp b/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp index 4758faf1ddf..1f74fdf4d7f 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp @@ -172,7 +172,7 @@ struct instance_zulaman : public ScriptedInstance ss << "S " << BossKilled << " " << ChestLooted << " " << QuestMinute; char* data = new char[ss.str().length()+1]; strcpy(data, ss.str().c_str()); - //error_log("TSCR: Zul'aman saved, %s.", data); + //sLog.outError("TSCR: Zul'aman saved, %s.", data); return data; } @@ -180,17 +180,17 @@ struct instance_zulaman : public ScriptedInstance { if (!load) return; std::istringstream ss(load); - //error_log("TSCR: Zul'aman loaded, %s.", ss.str().c_str()); + //sLog.outError("TSCR: Zul'aman loaded, %s.", ss.str().c_str()); char dataHead; // S uint16 data1, data2, data3; ss >> dataHead >> data1 >> data2 >> data3; - //error_log("TSCR: Zul'aman loaded, %d %d %d.", data1, data2, data3); + //sLog.outError("TSCR: Zul'aman loaded, %d %d %d.", data1, data2, data3); if (dataHead == 'S') { BossKilled = data1; ChestLooted = data2; QuestMinute = data3; - } else error_log("TSCR: Zul'aman: corrupted save data."); + } else sLog.outError("TSCR: Zul'aman: corrupted save data."); } void SetData(uint32 type, uint32 data) diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp index ecc458c19c5..a309028b67d 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp @@ -170,7 +170,7 @@ struct boss_arlokkAI : public ScriptedAI MarkedTargetGUID = pMarkedTarget->GetGUID(); } else - error_log("TSCR: boss_arlokk could not accuire pMarkedTarget."); + sLog.outError("TSCR: boss_arlokk could not accuire pMarkedTarget."); m_uiMark_Timer = 15000; } diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp index c2c040dc696..a72598c0e7d 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp @@ -105,7 +105,7 @@ bool GossipSelect_npc_jaina_proudmoore(Player* pPlayer, Creature* pCreature, uin break; case GOSSIP_ACTION_INFO_DEF: ai->Debug = !ai->Debug; - debug_log("TSCR: HyjalAI - Debug mode has been toggled"); + sLog.outDebug("TSCR: HyjalAI - Debug mode has been toggled"); break; } return true; @@ -175,7 +175,7 @@ bool GossipSelect_npc_thrall(Player* pPlayer, Creature* pCreature, uint32 /*uiSe break; case GOSSIP_ACTION_INFO_DEF: ai->Debug = !ai->Debug; - debug_log("TSCR: HyjalAI - Debug mode has been toggled"); + sLog.outDebug("TSCR: HyjalAI - Debug mode has been toggled"); break; } return true; diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp index 6f12692d164..c329c659419 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp @@ -400,7 +400,7 @@ void hyjalAI::Reset() pInstance->DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, 0); pInstance->SetData(DATA_RESET_TRASH_COUNT, 0); } - } else error_log(ERROR_INST_DATA); + } else sLog.outError(ERROR_INST_DATA); //Visibility DoHide = true; @@ -531,7 +531,7 @@ void hyjalAI::SummonNextWave(Wave wave[18], uint32 Count, float Base[4][3]) if (!pInstance) { - error_log(ERROR_INST_DATA); + sLog.outError(ERROR_INST_DATA); return; } InfernalCount = 0;//reset infernal count every new wave @@ -561,7 +561,7 @@ void hyjalAI::SummonNextWave(Wave wave[18], uint32 Count, float Base[4][3]) else { NextWaveTimer = 15000; - debug_log("TSCR: HyjalAI: debug mode is enabled. Next Wave in 15 seconds"); + sLog.outDebug("TSCR: HyjalAI: debug mode is enabled. Next Wave in 15 seconds"); } } else @@ -605,7 +605,7 @@ uint32 hyjalAI::GetInstanceData(uint32 Event) { if (pInstance) return pInstance->GetData(Event); - else error_log(ERROR_INST_DATA); + else sLog.outError(ERROR_INST_DATA); return 0; } diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp index 07decc11387..54007a11ecd 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp @@ -248,7 +248,7 @@ struct instance_mount_hyjal : public ScriptedInstance break; } - debug_log("TSCR: Instance Hyjal: Instance data updated for event %u (Data=%u)",type,data); + sLog.outDebug("TSCR: Instance Hyjal: Instance data updated for event %u (Data=%u)",type,data); if (data == DONE) { diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/dark_portal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/dark_portal.cpp index fdeb56f4c54..b31c265575e 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/dark_portal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/dark_portal.cpp @@ -305,7 +305,7 @@ struct npc_time_riftAI : public ScriptedAI mRiftWaveCount = 0; entry = PortalWaves[mWaveId].PortalMob[mRiftWaveCount]; - debug_log("TSCR: npc_time_rift: summoning wave Creature (Wave %u, Entry %u).",mRiftWaveCount,entry); + sLog.outDebug("TSCR: npc_time_rift: summoning wave Creature (Wave %u, Entry %u).",mRiftWaveCount,entry); ++mRiftWaveCount; @@ -330,7 +330,7 @@ struct npc_time_riftAI : public ScriptedAI if (me->IsNonMeleeSpellCasted(false)) return; - debug_log("TSCR: npc_time_rift: not casting anylonger, i need to die."); + sLog.outDebug("TSCR: npc_time_rift: not casting anylonger, i need to die."); me->setDeathState(JUST_DIED); if (pInstance->GetData(TYPE_RIFT) == IN_PROGRESS) diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/instance_dark_portal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/instance_dark_portal.cpp index a98d5f80eee..58120d6dc55 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/instance_dark_portal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/instance_dark_portal.cpp @@ -178,7 +178,7 @@ struct instance_dark_portal : public ScriptedInstance { if (data == IN_PROGRESS) { - debug_log("TSCR: Instance Dark Portal: Starting event."); + sLog.outDebug("TSCR: Instance Dark Portal: Starting event."); InitWorldState(); m_auiEncounter[1] = IN_PROGRESS; NextPortal_Timer = 15000; @@ -187,7 +187,7 @@ struct instance_dark_portal : public ScriptedInstance if (data == DONE) { //this may be completed further out in the post-event - debug_log("TSCR: Instance Dark Portal: Event completed."); + sLog.outDebug("TSCR: Instance Dark Portal: Event completed."); Map::PlayerList const& players = instance->GetPlayers(); if (!players.isEmpty()) @@ -252,7 +252,7 @@ struct instance_dark_portal : public ScriptedInstance if (entry == RIFT_BOSS) entry = RandRiftBoss(); - debug_log("TSCR: Instance Dark Portal: Summoning rift boss entry %u.",entry); + sLog.outDebug("TSCR: Instance Dark Portal: Summoning rift boss entry %u.",entry); Position pos; me->GetRandomNearPosition(pos, 10.0f); @@ -263,7 +263,7 @@ struct instance_dark_portal : public ScriptedInstance if (Creature *summon = me->SummonCreature(entry, pos, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000)) return summon; - debug_log("TSCR: Instance Dark Portal: What just happened there? No boss, no loot, no fun..."); + sLog.outDebug("TSCR: Instance Dark Portal: What just happened there? No boss, no loot, no fun..."); return NULL; } @@ -276,7 +276,7 @@ struct instance_dark_portal : public ScriptedInstance if (tmp >= CurrentRiftId) ++tmp; - debug_log("TSCR: Instance Dark Portal: Creating Time Rift at locationId %i (old locationId was %u).",tmp,CurrentRiftId); + sLog.outDebug("TSCR: Instance Dark Portal: Creating Time Rift at locationId %i (old locationId was %u).",tmp,CurrentRiftId); CurrentRiftId = tmp; diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/instance_old_hillsbrad.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/instance_old_hillsbrad.cpp index 463461dcc1d..c6511af2a65 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/instance_old_hillsbrad.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/instance_old_hillsbrad.cpp @@ -71,7 +71,7 @@ struct instance_old_hillsbrad : public ScriptedInstance } } - debug_log("TSCR: Instance Old Hillsbrad: GetPlayerInMap, but PlayerList is empty!"); + sLog.outDebug("TSCR: Instance Old Hillsbrad: GetPlayerInMap, but PlayerList is empty!"); return NULL; } @@ -111,7 +111,7 @@ struct instance_old_hillsbrad : public ScriptedInstance if (!pPlayer) { - debug_log("TSCR: Instance Old Hillsbrad: SetData (Type: %u Data %u) cannot find any player.", type, data); + sLog.outDebug("TSCR: Instance Old Hillsbrad: SetData (Type: %u Data %u) cannot find any player.", type, data); return; } @@ -127,7 +127,7 @@ struct instance_old_hillsbrad : public ScriptedInstance ++mBarrelCount; DoUpdateWorldState(WORLD_STATE_OH, mBarrelCount); - debug_log("TSCR: Instance Old Hillsbrad: go_barrel_old_hillsbrad count %u",mBarrelCount); + sLog.outDebug("TSCR: Instance Old Hillsbrad: go_barrel_old_hillsbrad count %u",mBarrelCount); m_auiEncounter[0] = IN_PROGRESS; @@ -148,7 +148,7 @@ struct instance_old_hillsbrad : public ScriptedInstance { ++mThrallEventCount; m_auiEncounter[1] = NOT_STARTED; - debug_log("TSCR: Instance Old Hillsbrad: Thrall event failed %u times. Resetting all sub-events.",mThrallEventCount); + sLog.outDebug("TSCR: Instance Old Hillsbrad: Thrall event failed %u times. Resetting all sub-events.",mThrallEventCount); m_auiEncounter[2] = NOT_STARTED; m_auiEncounter[3] = NOT_STARTED; m_auiEncounter[4] = NOT_STARTED; @@ -161,29 +161,29 @@ struct instance_old_hillsbrad : public ScriptedInstance m_auiEncounter[3] = data; m_auiEncounter[4] = data; m_auiEncounter[5] = data; - debug_log("TSCR: Instance Old Hillsbrad: Thrall event failed %u times. Resetting all sub-events.",mThrallEventCount); + sLog.outDebug("TSCR: Instance Old Hillsbrad: Thrall event failed %u times. Resetting all sub-events.",mThrallEventCount); } } else m_auiEncounter[1] = data; - debug_log("TSCR: Instance Old Hillsbrad: Thrall escort event adjusted to data %u.",data); + sLog.outDebug("TSCR: Instance Old Hillsbrad: Thrall escort event adjusted to data %u.",data); break; } case TYPE_THRALL_PART1: m_auiEncounter[2] = data; - debug_log("TSCR: Instance Old Hillsbrad: Thrall event part I adjusted to data %u.",data); + sLog.outDebug("TSCR: Instance Old Hillsbrad: Thrall event part I adjusted to data %u.",data); break; case TYPE_THRALL_PART2: m_auiEncounter[3] = data; - debug_log("TSCR: Instance Old Hillsbrad: Thrall event part II adjusted to data %u.",data); + sLog.outDebug("TSCR: Instance Old Hillsbrad: Thrall event part II adjusted to data %u.",data); break; case TYPE_THRALL_PART3: m_auiEncounter[4] = data; - debug_log("TSCR: Instance Old Hillsbrad: Thrall event part III adjusted to data %u.",data); + sLog.outDebug("TSCR: Instance Old Hillsbrad: Thrall event part III adjusted to data %u.",data); break; case TYPE_THRALL_PART4: m_auiEncounter[5] = data; - debug_log("TSCR: Instance Old Hillsbrad: Thrall event part IV adjusted to data %u.",data); + sLog.outDebug("TSCR: Instance Old Hillsbrad: Thrall event part IV adjusted to data %u.",data); break; } } diff --git a/src/server/scripts/Kalimdor/RazorfenKraul/instance_razorfen_kraul.cpp b/src/server/scripts/Kalimdor/RazorfenKraul/instance_razorfen_kraul.cpp index eddf965a99e..7ba2ebd5bc2 100644 --- a/src/server/scripts/Kalimdor/RazorfenKraul/instance_razorfen_kraul.cpp +++ b/src/server/scripts/Kalimdor/RazorfenKraul/instance_razorfen_kraul.cpp @@ -53,7 +53,7 @@ struct instance_razorfen_kraul : public ScriptedInstance return plr; } } - debug_log("TSCR: Instance Razorfen Kraul: GetPlayerInMap, but PlayerList is empty!"); + sLog.outDebug("TSCR: Instance Razorfen Kraul: GetPlayerInMap, but PlayerList is empty!"); return NULL; } diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp index 9e53596c9fe..44a6409982a 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp @@ -168,7 +168,7 @@ struct eye_of_cthunAI : public Scripted_NoMovementAI { pInst = c->GetInstanceData(); if (!pInst) - error_log("TSCR: No Instance eye_of_cthunAI"); + sLog.outError("TSCR: No Instance eye_of_cthunAI"); } ScriptedInstance* pInst; @@ -460,7 +460,7 @@ struct cthunAI : public Scripted_NoMovementAI pInst = c->GetInstanceData(); if (!pInst) - error_log("TSCR: No Instance eye_of_cthunAI"); + sLog.outError("TSCR: No Instance eye_of_cthunAI"); } ScriptedInstance* pInst; diff --git a/src/server/scripts/Kalimdor/azuremyst_isle.cpp b/src/server/scripts/Kalimdor/azuremyst_isle.cpp index 780f1f41f0c..e1a63062439 100644 --- a/src/server/scripts/Kalimdor/azuremyst_isle.cpp +++ b/src/server/scripts/Kalimdor/azuremyst_isle.cpp @@ -512,7 +512,7 @@ struct npc_geezleAI : public ScriptedAI else (*itr)->Respawn(); } - } else error_log("SD2 ERROR: FlagList is empty!"); + } else sLog.outError("SD2 ERROR: FlagList is empty!"); } void UpdateAI(const uint32 diff) diff --git a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp index b815e0172ec..ac774c6512e 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp @@ -182,7 +182,7 @@ struct boss_gothikAI : public BossAI if (LiveTriggerGUID.size() < POS_LIVE || DeadTriggerGUID.size() < POS_DEAD) { - error_log("Script Gothik: cannot summon triggers!"); + sLog.outError("Script Gothik: cannot summon triggers!"); EnterEvadeMode(); return; } diff --git a/src/server/scripts/Northrend/ObsidianSanctum/boss_sartharion.cpp b/src/server/scripts/Northrend/ObsidianSanctum/boss_sartharion.cpp index c238e55675b..37dbce59c74 100644 --- a/src/server/scripts/Northrend/ObsidianSanctum/boss_sartharion.cpp +++ b/src/server/scripts/Northrend/ObsidianSanctum/boss_sartharion.cpp @@ -633,7 +633,7 @@ struct dummy_dragonAI : public ScriptedAI if (!pInstance || uiType != POINT_MOTION_TYPE) return; - debug_log("dummy_dragonAI: %s reached point %u", me->GetName(), uiPointId); + sLog.outDebug("dummy_dragonAI: %s reached point %u", me->GetName(), uiPointId); //if healers messed up the raid and we was already initialized if (pInstance->GetData(TYPE_SARTHARION_EVENT) != IN_PROGRESS) @@ -790,7 +790,7 @@ struct dummy_dragonAI : public ScriptedAI me->GetMotionMaster()->MovePoint(m_uiWaypointId, m_aDragonCommon[m_uiWaypointId].m_fX, m_aDragonCommon[m_uiWaypointId].m_fY, m_aDragonCommon[m_uiWaypointId].m_fZ); - debug_log("dummy_dragonAI: %s moving to point %u", me->GetName(), m_uiWaypointId); + sLog.outDebug("dummy_dragonAI: %s moving to point %u", me->GetName(), m_uiWaypointId); m_uiMoveNextTimer = 0; } else diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/instance_utgarde_keep.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/instance_utgarde_keep.cpp index 67fb0a09755..3e39de32fba 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/instance_utgarde_keep.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/instance_utgarde_keep.cpp @@ -109,7 +109,7 @@ struct instance_utgarde_keep : public ScriptedInstance } } - debug_log("TSCR: Instance Utgarde Keep: GetPlayerInMap, but PlayerList is empty!"); + sLog.outDebug("TSCR: Instance Utgarde Keep: GetPlayerInMap, but PlayerList is empty!"); return NULL; } diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/instance_shadow_labyrinth.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/instance_shadow_labyrinth.cpp index 9b4ecca6579..f3f754ec296 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/instance_shadow_labyrinth.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/instance_shadow_labyrinth.cpp @@ -96,7 +96,7 @@ struct instance_shadow_labyrinth : public ScriptedInstance if (pCreature->isAlive()) { ++m_uiFelOverseerCount; - debug_log("TSCR: Shadow Labyrinth: counting %u Fel Overseers.",m_uiFelOverseerCount); + sLog.outDebug("TSCR: Shadow Labyrinth: counting %u Fel Overseers.",m_uiFelOverseerCount); } break; } @@ -113,7 +113,7 @@ struct instance_shadow_labyrinth : public ScriptedInstance case TYPE_OVERSEER: if (uiData != DONE) { - error_log("TSCR: Shadow Labyrinth: TYPE_OVERSEER did not expect other data than DONE"); + sLog.outError("TSCR: Shadow Labyrinth: TYPE_OVERSEER did not expect other data than DONE"); return; } if (m_uiFelOverseerCount) @@ -121,11 +121,11 @@ struct instance_shadow_labyrinth : public ScriptedInstance --m_uiFelOverseerCount; if (m_uiFelOverseerCount) - debug_log("TSCR: Shadow Labyrinth: %u Fel Overseers left to kill.",m_uiFelOverseerCount); + sLog.outDebug("TSCR: Shadow Labyrinth: %u Fel Overseers left to kill.",m_uiFelOverseerCount); else { m_auiEncounter[1] = DONE; - debug_log("TSCR: Shadow Labyrinth: TYPE_OVERSEER == DONE"); + sLog.outDebug("TSCR: Shadow Labyrinth: TYPE_OVERSEER == DONE"); } } break; diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index 590e51d9eab..64fed0967d9 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -2065,7 +2065,7 @@ void boss_illidan_stormrageAI::SummonMaiev() { EnterEvadeMode(); me->MonsterTextEmote(EMOTE_UNABLE_TO_SUMMON, 0); - error_log("SD2 ERROR: Unable to summon Maiev Shadowsong (entry: 23197). Check your database to see if you have the proper SQL for Maiev Shadowsong (entry: 23197)"); + sLog.outError("SD2 ERROR: Unable to summon Maiev Shadowsong (entry: 23197). Check your database to see if you have the proper SQL for Maiev Shadowsong (entry: 23197)"); } } diff --git a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp index 663faceb672..38ce3f2590d 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp @@ -276,7 +276,7 @@ struct boss_shade_of_akamaAI : public ScriptedAI GridSearcherSucceeded = true; } } - } else error_log("SD2 ERROR: No Channelers are stored in the list. This encounter will not work properly"); + } else sLog.outError("SD2 ERROR: No Channelers are stored in the list. This encounter will not work properly"); } } @@ -293,13 +293,13 @@ struct boss_shade_of_akamaAI : public ScriptedAI if (reseting) return; - debug_log("TSCR: Increasing Death Count for Shade of Akama encounter"); + sLog.outDebug("TSCR: Increasing Death Count for Shade of Akama encounter"); ++DeathCount; me->RemoveAuraFromStack(SPELL_SHADE_SOUL_CHANNEL_2); if (guid) { if (Sorcerers.empty()) - error_log("SD2 ERROR: Shade of Akama - attempt to remove guid %u from Sorcerers list but list is already empty", guid); + sLog.outError("SD2 ERROR: Shade of Akama - attempt to remove guid %u from Sorcerers list but list is already empty", guid); else Sorcerers.remove(guid); } } @@ -351,17 +351,17 @@ struct boss_shade_of_akamaAI : public ScriptedAI { CAST_AI(mob_ashtongue_channelerAI, (*itr)->AI())->ShadeGUID = me->GetGUID(); Channelers.push_back((*itr)->GetGUID()); - debug_log("TSCR: Shade of Akama Grid Search found channeler %u. Adding to list", (*itr)->GetGUID()); + sLog.outDebug("TSCR: Shade of Akama Grid Search found channeler %u. Adding to list", (*itr)->GetGUID()); } } - else error_log("SD2 ERROR: Grid Search was unable to find any channelers. Shade of Akama encounter will be buggy"); + else sLog.outError("SD2 ERROR: Grid Search was unable to find any channelers. Shade of Akama encounter will be buggy"); } void SetSelectableChannelers() { if (Channelers.empty()) { - error_log("SD2 ERROR: Channeler List is empty, Shade of Akama encounter will be buggy"); + sLog.outError("SD2 ERROR: Channeler List is empty, Shade of Akama encounter will be buggy"); return; } @@ -485,7 +485,7 @@ void mob_ashtongue_channelerAI::JustDied(Unit* /*killer*/) Creature* Shade = (Unit::GetCreature((*me), ShadeGUID)); if (Shade && Shade->isAlive()) CAST_AI(boss_shade_of_akamaAI, Shade->AI())->IncrementDeathCount(); - else error_log("SD2 ERROR: Channeler dead but unable to increment DeathCount for Shade of Akama."); + else sLog.outError("SD2 ERROR: Channeler dead but unable to increment DeathCount for Shade of Akama."); } void mob_ashtongue_sorcererAI::JustDied(Unit* /*killer*/) @@ -493,7 +493,7 @@ void mob_ashtongue_sorcererAI::JustDied(Unit* /*killer*/) Creature* Shade = (Unit::GetCreature((*me), ShadeGUID)); if (Shade && Shade->isAlive()) CAST_AI(boss_shade_of_akamaAI, Shade->AI())->IncrementDeathCount(me->GetGUID()); - else error_log("SD2 ERROR: Sorcerer dead but unable to increment DeathCount for Shade of Akama."); + else sLog.outError("SD2 ERROR: Sorcerer dead but unable to increment DeathCount for Shade of Akama."); } struct npc_akamaAI : public ScriptedAI diff --git a/src/server/scripts/Outland/BlackTemple/illidari_council.cpp b/src/server/scripts/Outland/BlackTemple/illidari_council.cpp index 132da7d7bd1..52ccd1c6434 100644 --- a/src/server/scripts/Outland/BlackTemple/illidari_council.cpp +++ b/src/server/scripts/Outland/BlackTemple/illidari_council.cpp @@ -143,7 +143,7 @@ struct mob_blood_elf_council_voice_triggerAI : public ScriptedAI Council[1] = pInstance->GetData64(DATA_VERASDARKSHADOW); Council[2] = pInstance->GetData64(DATA_LADYMALANDE); Council[3] = pInstance->GetData64(DATA_HIGHNETHERMANCERZEREVOR); - } else error_log(ERROR_INST_DATA); + } else sLog.outError(ERROR_INST_DATA); } void EnterCombat(Unit* /*who*/) {} @@ -375,7 +375,7 @@ struct boss_illidari_councilAI : public ScriptedAI } else { - error_log(ERROR_INST_DATA); + sLog.outError(ERROR_INST_DATA); EnterEvadeMode(); return; } @@ -423,7 +423,7 @@ struct boss_illidari_councilAI : public ScriptedAI { if (!pInstance) { - error_log(ERROR_INST_DATA); + sLog.outError(ERROR_INST_DATA); return; } diff --git a/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp b/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp index 5af96257887..384c9b32ff8 100644 --- a/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp +++ b/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp @@ -124,7 +124,7 @@ struct instance_black_temple : public ScriptedInstance } } - debug_log("TSCR: Instance Black Temple: GetPlayerInMap, but PlayerList is empty!"); + sLog.outDebug("TSCR: Instance Black Temple: GetPlayerInMap, but PlayerList is empty!"); return NULL; } diff --git a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/instance_steam_vault.cpp b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/instance_steam_vault.cpp index 2669c8ed48d..5d60bc7f3e6 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/instance_steam_vault.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/instance_steam_vault.cpp @@ -119,7 +119,7 @@ struct instance_steam_vault : public ScriptedInstance if (GetData(TYPE_MEKGINEER_STEAMRIGGER) == SPECIAL) HandleGameObject(MainChambersDoor, true); - debug_log("TSCR: Instance Steamvault: Access panel used."); + sLog.outDebug("TSCR: Instance Steamvault: Access panel used."); } m_auiEncounter[0] = data; break; @@ -131,7 +131,7 @@ struct instance_steam_vault : public ScriptedInstance if (GetData(TYPE_HYDROMANCER_THESPIA) == SPECIAL) HandleGameObject(MainChambersDoor, true); - debug_log("TSCR: Instance Steamvault: Access panel used."); + sLog.outDebug("TSCR: Instance Steamvault: Access panel used."); } m_auiEncounter[1] = data; break; diff --git a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/instance_hellfire_ramparts.cpp b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/instance_hellfire_ramparts.cpp index 76425e351cf..500892129c2 100644 --- a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/instance_hellfire_ramparts.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/instance_hellfire_ramparts.cpp @@ -51,7 +51,7 @@ struct instance_ramparts : public ScriptedInstance void SetData(uint32 uiType, uint32 uiData) { - debug_log("TSCR: Instance Ramparts: SetData received for type %u with data %u",uiType,uiData); + sLog.outDebug("TSCR: Instance Ramparts: SetData received for type %u with data %u",uiType,uiData); switch(uiType) { diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp index 276fe844e32..671821d8924 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp @@ -356,7 +356,7 @@ struct boss_kaelthasAI : public ScriptedAI if (!m_auiAdvisorGuid[0] || !m_auiAdvisorGuid[1] || !m_auiAdvisorGuid[2] || !m_auiAdvisorGuid[3]) { - error_log("TSCR: Kael'Thas One or more advisors missing, Skipping Phases 1-3"); + sLog.outError("TSCR: Kael'Thas One or more advisors missing, Skipping Phases 1-3"); DoScriptText(SAY_PHASE4_INTRO2, me); @@ -678,7 +678,7 @@ struct boss_kaelthasAI : public ScriptedAI Advisor = Unit::GetCreature((*me), m_auiAdvisorGuid[i]); if (!Advisor) - error_log("SD2: Kael'Thas Advisor %u does not exist. Possibly despawned? Incorrectly Killed?", i); + sLog.outError("SD2: Kael'Thas Advisor %u does not exist. Possibly despawned? Incorrectly Killed?", i); else CAST_AI(advisorbase_ai, Advisor->AI())->Revive(pTarget); } @@ -763,7 +763,7 @@ struct boss_kaelthasAI : public ScriptedAI if (me->getThreatManager().getThreatList().size() >= 2) for (uint32 i = 0; i < 3; ++i) { - debug_log("SD2: Kael'Thas mind control not supported."); + sLog.outDebug("SD2: Kael'Thas mind control not supported."); //DoCast(pUnit, SPELL_MIND_CONTROL); } diff --git a/src/server/scripts/Outland/hellfire_peninsula.cpp b/src/server/scripts/Outland/hellfire_peninsula.cpp index bafca52e463..8c3355d5238 100644 --- a/src/server/scripts/Outland/hellfire_peninsula.cpp +++ b/src/server/scripts/Outland/hellfire_peninsula.cpp @@ -140,7 +140,7 @@ struct npc_ancestral_wolfAI : public npc_escortAI if (pCreature->GetOwner() && pCreature->GetOwner()->GetTypeId() == TYPEID_PLAYER) Start(false, false, pCreature->GetOwner()->GetGUID()); else - error_log("TRINITY: npc_ancestral_wolf can not obtain owner or owner is not a player."); + sLog.outError("TRINITY: npc_ancestral_wolf can not obtain owner or owner is not a player."); pCreature->SetSpeed(MOVE_WALK, 1.5f); Reset(); diff --git a/src/server/scripts/Outland/netherstorm.cpp b/src/server/scripts/Outland/netherstorm.cpp index a44839eba90..7c5254cace6 100644 --- a/src/server/scripts/Outland/netherstorm.cpp +++ b/src/server/scripts/Outland/netherstorm.cpp @@ -463,7 +463,7 @@ struct npc_commander_dawnforgeAI : public ScriptedAI return true; } - debug_log("TSCR: npc_commander_dawnforge event already in progress, need to wait."); + sLog.outDebug("TSCR: npc_commander_dawnforge event already in progress, need to wait."); return false; } diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index d8dd8c3d391..65e1fc9fb17 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -259,7 +259,7 @@ bool GOHello_go_ethereum_prison(Player *pPlayer, GameObject *pGO) if (Spell) pCreature->CastSpell(pPlayer, Spell, false); else - error_log("TSCR: go_ethereum_prison summoned Creature (entry %u) but faction (%u) are not expected by script.", pCreature->GetEntry(), pCreature->getFaction()); + sLog.outError("TSCR: go_ethereum_prison summoned Creature (entry %u) but faction (%u) are not expected by script.", pCreature->GetEntry(), pCreature->getFaction()); } } } diff --git a/src/server/scripts/World/item_scripts.cpp b/src/server/scripts/World/item_scripts.cpp index cae4233775b..ccca8ce70af 100644 --- a/src/server/scripts/World/item_scripts.cpp +++ b/src/server/scripts/World/item_scripts.cpp @@ -139,7 +139,7 @@ bool ItemUse_item_flying_machine(Player* pPlayer, Item* pItem, SpellCastTargets if (pPlayer->GetBaseSkillValue(SKILL_RIDING) == 300) return false; - debug_log("TSCR: Player attempt to use item %u, but did not meet riding requirement",itemId); + sLog.outDebug("TSCR: Player attempt to use item %u, but did not meet riding requirement",itemId); pPlayer->SendEquipError(EQUIP_ERR_ERR_CANT_EQUIP_SKILL,pItem,NULL); return true; } diff --git a/src/server/scripts/World/npc_professions.cpp b/src/server/scripts/World/npc_professions.cpp index 9d33584847b..5acd8472c44 100644 --- a/src/server/scripts/World/npc_professions.cpp +++ b/src/server/scripts/World/npc_professions.cpp @@ -238,7 +238,7 @@ bool EquippedOk(Player* pPlayer, uint32 spellId) if (pItem->GetProto()->RequiredSpell == reqSpell) { //player has item equipped that require specialty. Not allow to unlearn, player has to unequip first - debug_log("TSCR: player attempt to unlearn spell %u, but item %u is equipped.",reqSpell,pItem->GetProto()->ItemId); + sLog.outDebug("TSCR: player attempt to unlearn spell %u, but item %u is equipped.",reqSpell,pItem->GetProto()->ItemId); return false; } } diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index 86aaac1413b..625f6485fc6 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -123,7 +123,7 @@ struct npc_air_force_botsAI : public ScriptedAI } if (!m_pSpawnAssoc) - error_db_log("TCSR: Creature template entry %u has ScriptName npc_air_force_bots, but it's not handled by that script", pCreature->GetEntry()); + sLog.outErrorDb("TCSR: Creature template entry %u has ScriptName npc_air_force_bots, but it's not handled by that script", pCreature->GetEntry()); else { CreatureInfo const* spawnedTemplate = GetCreatureTemplateStore(m_pSpawnAssoc->m_uiSpawnedCreatureEntry); @@ -131,7 +131,7 @@ struct npc_air_force_botsAI : public ScriptedAI if (!spawnedTemplate) { m_pSpawnAssoc = NULL; - error_db_log("TCSR: Creature template entry %u does not exist in DB, which is required by npc_air_force_bots", m_pSpawnAssoc->m_uiSpawnedCreatureEntry); + sLog.outErrorDb("TCSR: Creature template entry %u does not exist in DB, which is required by npc_air_force_bots", m_pSpawnAssoc->m_uiSpawnedCreatureEntry); return; } } @@ -150,7 +150,7 @@ struct npc_air_force_botsAI : public ScriptedAI m_uiSpawnedGUID = pSummoned->GetGUID(); else { - error_db_log("TCSR: npc_air_force_bots: wasn't able to spawn Creature %u", m_pSpawnAssoc->m_uiSpawnedCreatureEntry); + sLog.outErrorDb("TCSR: npc_air_force_bots: wasn't able to spawn Creature %u", m_pSpawnAssoc->m_uiSpawnedCreatureEntry); m_pSpawnAssoc = NULL; } @@ -787,7 +787,7 @@ void npc_doctorAI::UpdateAI(const uint32 diff) case DOCTOR_ALLIANCE: patientEntry = AllianceSoldierId[rand()%3]; break; case DOCTOR_HORDE: patientEntry = HordeSoldierId[rand()%3]; break; default: - error_log("TSCR: Invalid entry for Triage doctor. Please check your database"); + sLog.outError("TSCR: Invalid entry for Triage doctor. Please check your database"); return; } diff --git a/src/server/shared/Logging/Log.cpp b/src/server/shared/Logging/Log.cpp index e701e073d5c..0f27400dce2 100644 --- a/src/server/shared/Logging/Log.cpp +++ b/src/server/shared/Logging/Log.cpp @@ -450,7 +450,7 @@ void Log::outCrash(const char * err, ...) va_list ap; va_start(ap, err); - vutf8printf(stdout, err, &ap); + vutf8printf(stderr, err, &ap); va_end(ap); if (m_colored) @@ -530,7 +530,6 @@ void Log::outArena(const char * str, ...) va_end(ap); fflush(arenaLogFile); } - fflush(stdout); } void Log::outErrorDb(const char * err, ...) @@ -902,7 +901,6 @@ void Log::outRemote(const char * str, ...) va_end(ap); fflush(raLogfile); } - fflush(stdout); } void Log::outChat(const char * str, ...) @@ -930,76 +928,4 @@ void Log::outChat(const char * str, ...) fflush(chatLogfile); va_end(ap); } - fflush(stdout); -} - -void outstring_log(const char * str, ...) -{ - if (!str) - return; - - char buf[256]; - va_list ap; - va_start(ap, str); - vsnprintf(buf,256, str, ap); - va_end(ap); - - Trinity::Singleton::Instance().outString(buf); } - -void detail_log(const char * str, ...) -{ - if (!str) - return; - - char buf[256]; - va_list ap; - va_start(ap, str); - vsnprintf(buf,256, str, ap); - va_end(ap); - - Trinity::Singleton::Instance().outDetail(buf); -} - -void debug_log(const char * str, ...) -{ - if (!str) - return; - - char buf[256]; - va_list ap; - va_start(ap, str); - vsnprintf(buf,256, str, ap); - va_end(ap); - - Trinity::Singleton::Instance().outDebug(buf); -} - -void error_log(const char * str, ...) -{ - if (!str) - return; - - char buf[256]; - va_list ap; - va_start(ap, str); - vsnprintf(buf,256, str, ap); - va_end(ap); - - Trinity::Singleton::Instance().outError(buf); -} - -void error_db_log(const char * str, ...) -{ - if (!str) - return; - - char buf[256]; - va_list ap; - va_start(ap, str); - vsnprintf(buf,256, str, ap); - va_end(ap); - - Trinity::Singleton::Instance().outErrorDb(buf); -} - diff --git a/src/server/shared/Logging/Log.h b/src/server/shared/Logging/Log.h index deb6c55e4e0..53ce4e601b5 100644 --- a/src/server/shared/Logging/Log.h +++ b/src/server/shared/Logging/Log.h @@ -180,11 +180,5 @@ class Log : public Trinity::Singleton Date: Fri, 25 Jun 2010 00:18:01 +0200 Subject: 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. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --HG-- branch : trunk --- src/server/game/AI/CreatureAISelector.cpp | 9 +- src/server/game/AI/EventAI/CreatureEventAIMgr.cpp | 3 - src/server/game/AI/EventAI/CreatureEventAIMgr.h | 5 +- src/server/game/Accounts/AccountMgr.cpp | 4 +- src/server/game/Accounts/AccountMgr.h | 3 +- src/server/game/Achievements/AchievementMgr.cpp | 6 +- src/server/game/Achievements/AchievementMgr.h | 4 +- src/server/game/Addons/AddonMgr.cpp | 4 +- src/server/game/Addons/AddonMgr.h | 7 +- .../AuctionHouseBot/AuctionHouseBot.cpp | 7 +- .../AuctionHouse/AuctionHouseBot/AuctionHouseBot.h | 6 +- src/server/game/AuctionHouse/AuctionHouseMgr.cpp | 4 +- src/server/game/AuctionHouse/AuctionHouseMgr.h | 66 +++++----- src/server/game/BattleGrounds/BattleGround.cpp | 4 +- src/server/game/BattleGrounds/BattleGroundMgr.cpp | 6 +- src/server/game/BattleGrounds/BattleGroundMgr.h | 11 +- src/server/game/Chat/Channels/ChannelMgr.cpp | 11 +- src/server/game/Chat/Channels/ChannelMgr.h | 2 +- src/server/game/Chat/Commands/Level0.cpp | 4 +- src/server/game/Chat/Commands/Level1.cpp | 10 +- src/server/game/Chat/Commands/Level2.cpp | 2 +- src/server/game/Chat/Commands/Level3.cpp | 12 +- src/server/game/Conditions/ConditionMgr.cpp | 4 +- src/server/game/Conditions/ConditionMgr.h | 6 +- src/server/game/DataStores/DBCStores.cpp | 2 +- src/server/game/DungeonFinding/LFGMgr.cpp | 4 +- src/server/game/DungeonFinding/LFGMgr.h | 65 +++++----- src/server/game/Entities/Corpse/Corpse.cpp | 4 +- src/server/game/Entities/Creature/Creature.cpp | 8 +- src/server/game/Entities/Creature/Creature.h | 2 +- .../game/Entities/Creature/CreatureGroups.cpp | 4 +- src/server/game/Entities/Creature/CreatureGroups.h | 5 +- .../game/Entities/DynamicObject/DynamicObject.cpp | 4 +- src/server/game/Entities/GameObject/GameObject.cpp | 4 +- src/server/game/Entities/Object/Object.cpp | 30 ++--- src/server/game/Entities/Pet/Pet.cpp | 4 +- src/server/game/Entities/Player/Player.cpp | 36 +++--- src/server/game/Entities/Player/SocialMgr.cpp | 4 +- src/server/game/Entities/Player/SocialMgr.h | 7 +- src/server/game/Entities/Transport/Transport.cpp | 4 +- src/server/game/Entities/Unit/Unit.cpp | 2 +- src/server/game/Events/GameEventMgr.cpp | 13 +- src/server/game/Events/GameEventMgr.h | 8 +- src/server/game/Globals/GlobalEvents.cpp | 4 +- src/server/game/Globals/ObjectAccessor.cpp | 22 ++-- src/server/game/Globals/ObjectAccessor.h | 21 ++-- src/server/game/Globals/ObjectMgr.cpp | 14 +-- src/server/game/Globals/ObjectMgr.h | 14 +-- src/server/game/Grids/Grid.h | 7 +- src/server/game/Grids/NGrid.h | 9 +- src/server/game/Grids/ObjectGridLoader.cpp | 2 +- src/server/game/Groups/Group.cpp | 2 +- src/server/game/Instances/InstanceSaveMgr.cpp | 14 +-- src/server/game/Instances/InstanceSaveMgr.h | 12 +- src/server/game/Maps/Map.cpp | 20 ++-- src/server/game/Maps/Map.h | 5 +- src/server/game/Maps/MapInstanced.cpp | 6 +- src/server/game/Maps/MapManager.cpp | 15 +-- src/server/game/Maps/MapManager.h | 10 +- src/server/game/Movement/MovementGenerator.h | 2 +- .../WaypointMovementGenerator.cpp | 2 +- src/server/game/OutdoorPvP/OutdoorPvP.cpp | 2 +- src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp | 3 - src/server/game/OutdoorPvP/OutdoorPvPMgr.h | 4 +- src/server/game/Pools/PoolHandler.cpp | 15 +-- src/server/game/Pools/PoolHandler.h | 11 +- src/server/game/Scripting/ScriptMgr.cpp | 3 - src/server/game/Scripting/ScriptMgr.h | 5 +- .../game/Server/Protocol/Handlers/AddonHandler.cpp | 5 - .../game/Server/Protocol/Handlers/AddonHandler.h | 13 +- .../Server/Protocol/Handlers/ArenaTeamHandler.cpp | 2 +- .../Server/Protocol/Handlers/ChannelHandler.cpp | 2 - .../Server/Protocol/Handlers/CharacterHandler.cpp | 2 +- .../game/Server/Protocol/Handlers/GuildHandler.cpp | 2 +- .../game/Server/Protocol/Handlers/MiscHandler.cpp | 6 +- .../Server/Protocol/Handlers/MovementHandler.cpp | 4 +- .../game/Server/Protocol/Handlers/QueryHandler.cpp | 2 +- src/server/game/Server/Protocol/WorldLog.cpp | 12 +- src/server/game/Server/Protocol/WorldLog.h | 10 +- src/server/game/Skills/SkillDiscovery.cpp | 1 - src/server/game/Spells/Spell.cpp | 1 - src/server/game/Spells/SpellMgr.cpp | 2 +- src/server/game/World/World.cpp | 15 +-- src/server/game/World/World.h | 4 +- .../BlackwingLair/boss_victor_nefarius.cpp | 6 +- src/server/shared/CMakeLists.txt | 2 - src/server/shared/Configuration/Config.cpp | 3 - src/server/shared/Configuration/Config.h | 7 +- src/server/shared/Database/Database.cpp | 1 - src/server/shared/Database/Database.h | 1 - src/server/shared/Debugging/MemoryLeaks.cpp | 3 - src/server/shared/Debugging/MemoryLeaks.h | 5 +- .../shared/Dynamic/CountedReference/Reference.h | 100 ---------------- .../Dynamic/CountedReference/ReferenceHolder.h | 42 ------- .../Dynamic/CountedReference/ReferenceImpl.h | 133 --------------------- src/server/shared/Dynamic/FactoryHolder.h | 8 +- src/server/shared/Dynamic/ObjectRegistry.h | 10 +- src/server/shared/Logging/Log.cpp | 3 - src/server/shared/Logging/Log.h | 10 +- src/server/shared/Policies/CreationPolicy.h | 110 ----------------- src/server/shared/Policies/ObjectLifeTime.cpp | 36 ------ src/server/shared/Policies/ObjectLifeTime.h | 53 -------- src/server/shared/Policies/Singleton.h | 65 ---------- src/server/shared/Policies/SingletonImp.h | 93 -------------- src/server/shared/Policies/ThreadingModel.h | 130 -------------------- src/server/worldserver/Master.cpp | 3 - src/server/worldserver/Master.h | 3 +- .../worldserver/WorldThread/WorldRunnable.cpp | 2 +- win/VC90/shared.vcproj | 24 ---- 109 files changed, 349 insertions(+), 1221 deletions(-) delete mode 100644 src/server/shared/Dynamic/CountedReference/Reference.h delete mode 100644 src/server/shared/Dynamic/CountedReference/ReferenceHolder.h delete mode 100644 src/server/shared/Dynamic/CountedReference/ReferenceImpl.h delete mode 100644 src/server/shared/Policies/CreationPolicy.h delete mode 100644 src/server/shared/Policies/ObjectLifeTime.cpp delete mode 100644 src/server/shared/Policies/ObjectLifeTime.h delete mode 100644 src/server/shared/Policies/Singleton.h delete mode 100644 src/server/shared/Policies/SingletonImp.h delete mode 100644 src/server/shared/Policies/ThreadingModel.h (limited to 'src/server/shared/Logging/Log.cpp') diff --git a/src/server/game/AI/CreatureAISelector.cpp b/src/server/game/AI/CreatureAISelector.cpp index 79977fab5b1..8283baf87f9 100644 --- a/src/server/game/AI/CreatureAISelector.cpp +++ b/src/server/game/AI/CreatureAISelector.cpp @@ -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()); diff --git a/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp b/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp index 8c71f5e5765..9f4105050ae 100644 --- a/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp @@ -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() { diff --git a/src/server/game/AI/EventAI/CreatureEventAIMgr.h b/src/server/game/AI/EventAI/CreatureEventAIMgr.h index ef191b22463..3c8181e9e74 100644 --- a/src/server/game/AI/EventAI/CreatureEventAIMgr.h +++ b/src/server/game/AI/EventAI/CreatureEventAIMgr.h @@ -24,8 +24,9 @@ class CreatureEventAIMgr { + friend class ACE_Singleton; + CreatureEventAIMgr(){}; public: - CreatureEventAIMgr(){}; ~CreatureEventAIMgr(){}; void LoadCreatureEventAI_Texts(); @@ -42,5 +43,5 @@ class CreatureEventAIMgr CreatureEventAI_TextMap m_CreatureEventAI_TextMap; }; -#define CreatureEAI_Mgr Trinity::Singleton::Instance() +#define CreatureEAI_Mgr (*ACE_Singleton::instance()) #endif diff --git a/src/server/game/Accounts/AccountMgr.cpp b/src/server/game/Accounts/AccountMgr.cpp index 18372677120..54f80114131 100644 --- a/src/server/game/Accounts/AccountMgr.cpp +++ b/src/server/game/Accounts/AccountMgr.cpp @@ -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() {} diff --git a/src/server/game/Accounts/AccountMgr.h b/src/server/game/Accounts/AccountMgr.h index f770e24d902..a0e181cf4a0 100644 --- a/src/server/game/Accounts/AccountMgr.h +++ b/src/server/game/Accounts/AccountMgr.h @@ -24,7 +24,6 @@ #include #include "Common.h" -#include "Singleton.h" enum AccountOpResult { @@ -59,6 +58,6 @@ class AccountMgr static bool normalizeString(std::string& utf8str); }; -#define accmgr Trinity::Singleton::Instance() +#define accmgr (*ACE_Singleton::instance()) #endif diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index 41b9acfff2c..137c22634fa 100644 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -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; diff --git a/src/server/game/Achievements/AchievementMgr.h b/src/server/game/Achievements/AchievementMgr.h index 97dbc86396e..0eedf971c20 100644 --- a/src/server/game/Achievements/AchievementMgr.h +++ b/src/server/game/Achievements/AchievementMgr.h @@ -22,7 +22,7 @@ #include #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::Instance() +#define achievementmgr (*ACE_Singleton::instance()) #endif diff --git a/src/server/game/Addons/AddonMgr.cpp b/src/server/game/Addons/AddonMgr.cpp index b7b1d2e9333..9bc28f845ac 100644 --- a/src/server/game/Addons/AddonMgr.cpp +++ b/src/server/game/Addons/AddonMgr.cpp @@ -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() { } diff --git a/src/server/game/Addons/AddonMgr.h b/src/server/game/Addons/AddonMgr.h index 0d648794416..90232cc3f2b 100644 --- a/src/server/game/Addons/AddonMgr.h +++ b/src/server/game/Addons/AddonMgr.h @@ -22,7 +22,7 @@ #define _ADDONMGR_H #include "Common.h" -#include "Singleton.h" +#include "ace/Singleton.h" #include @@ -68,9 +68,10 @@ typedef std::list SavedAddonsList; class AddonMgr { + friend class ACE_Singleton; + AddonMgr(); public: - AddonMgr(); ~AddonMgr(); void LoadFromDB(); @@ -83,7 +84,7 @@ class AddonMgr SavedAddonsList m_knownAddons; // Known addons. }; -#define sAddonMgr Trinity::Singleton::Instance() +#define sAddonMgr (*ACE_Singleton::instance()) #endif diff --git a/src/server/game/AuctionHouse/AuctionHouseBot/AuctionHouseBot.cpp b/src/server/game/AuctionHouse/AuctionHouseBot/AuctionHouseBot.cpp index e9cf8f21ab2..ce621e689cd 100644 --- a/src/server/game/AuctionHouse/AuctionHouseBot/AuctionHouseBot.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseBot/AuctionHouseBot.cpp @@ -3,8 +3,7 @@ #include "AuctionHouseBot.h" #include -#include "SingletonImp.h" -INSTANTIATE_SINGLETON_1(AuctionHouseBot); + using namespace std; vector 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() diff --git a/src/server/game/AuctionHouse/AuctionHouseBot/AuctionHouseBot.h b/src/server/game/AuctionHouse/AuctionHouseBot/AuctionHouseBot.h index f29a8762513..853955a43a0 100644 --- a/src/server/game/AuctionHouse/AuctionHouseBot/AuctionHouseBot.h +++ b/src/server/game/AuctionHouse/AuctionHouseBot/AuctionHouseBot.h @@ -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(); public: - AuctionHouseBot(); ~AuctionHouseBot(); void Update(); void Initialize(); @@ -1220,6 +1222,6 @@ public: uint32 GetAHBplayerGUID() { return AHBplayerGUID; }; }; -#define auctionbot Trinity::Singleton::Instance() +#define auctionbot (*ACE_Singleton::instance()) #endif diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index 744df2cb6e7..38874336cc4 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -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 -INSTANTIATE_SINGLETON_1(AuctionHouseMgr); - using namespace std; AuctionHouseMgr::AuctionHouseMgr() diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.h b/src/server/game/AuctionHouse/AuctionHouseMgr.h index 7048e419c36..f0eda8f4fc4 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.h +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.h @@ -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(); - ~AuctionHouseMgr(); + + public: + ~AuctionHouseMgr(); - typedef UNORDERED_MAP ItemMap; + typedef UNORDERED_MAP 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::Instance() +#define auctionmgr (*ACE_Singleton::instance()) #endif diff --git a/src/server/game/BattleGrounds/BattleGround.cpp b/src/server/game/BattleGrounds/BattleGround.cpp index 591417c8fea..86125ac5bfe 100644 --- a/src/server/game/BattleGrounds/BattleGround.cpp +++ b/src/server/game/BattleGrounds/BattleGround.cpp @@ -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; diff --git a/src/server/game/BattleGrounds/BattleGroundMgr.cpp b/src/server/game/BattleGrounds/BattleGroundMgr.cpp index ea2d0c2f920..84891dcf2df 100644 --- a/src/server/game/BattleGrounds/BattleGroundMgr.cpp +++ b/src/server/game/BattleGrounds/BattleGroundMgr.cpp @@ -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) diff --git a/src/server/game/BattleGrounds/BattleGroundMgr.h b/src/server/game/BattleGrounds/BattleGroundMgr.h index 5319ce85752..40dfc39b5e5 100644 --- a/src/server/game/BattleGrounds/BattleGroundMgr.h +++ b/src/server/game/BattleGrounds/BattleGroundMgr.h @@ -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(); + public: - /* Construction */ - BattleGroundMgr(); ~BattleGroundMgr(); void Update(uint32 diff); @@ -271,6 +274,6 @@ class BattleGroundMgr bool m_Testing; }; -#define sBattleGroundMgr Trinity::Singleton::Instance() +#define sBattleGroundMgr (*ACE_Singleton::instance()) #endif diff --git a/src/server/game/Chat/Channels/ChannelMgr.cpp b/src/server/game/Chat/Channels/ChannelMgr.cpp index b26a42aa2b1..b72a2698d3a 100644 --- a/src/server/game/Chat/Channels/ChannelMgr.cpp +++ b/src/server/game/Chat/Channels/ChannelMgr.cpp @@ -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::Instance(); // cross-faction + return ACE_Singleton::instance(); // cross-faction if (team == ALLIANCE) - return &Trinity::Singleton::Instance(); + return ACE_Singleton::instance(); if (team == HORDE) - return &Trinity::Singleton::Instance(); + return ACE_Singleton::instance(); return NULL; } diff --git a/src/server/game/Chat/Channels/ChannelMgr.h b/src/server/game/Chat/Channels/ChannelMgr.h index 1997eb76108..c4e872de6b6 100644 --- a/src/server/game/Chat/Channels/ChannelMgr.h +++ b/src/server/game/Chat/Channels/ChannelMgr.h @@ -22,7 +22,7 @@ #include "Common.h" #include "Channel.h" -#include "Singleton.h" +#include "ace/Singleton.h" #include #include diff --git a/src/server/game/Chat/Commands/Level0.cpp b/src/server/game/Chat/Commands/Level0.cpp index bed8e3ee23f..53f2341c5af 100644 --- a/src/server/game/Chat/Commands/Level0.cpp +++ b/src/server/game/Chat/Commands/Level0.cpp @@ -165,8 +165,8 @@ bool ChatHandler::HandleGMListIngameCommand(const char* /*args*/) { bool first = true; - ObjectAccessor::Guard guard(*HashMapHolder::GetLock()); - HashMapHolder::MapType &m = ObjectAccessor::Instance().GetPlayers(); + ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, *HashMapHolder::GetLock(), true); + HashMapHolder::MapType &m = sObjectAccessor.GetPlayers(); for (HashMapHolder::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) { AccountTypes itr_sec = itr->second->GetSession()->GetSecurity(); diff --git a/src/server/game/Chat/Commands/Level1.cpp b/src/server/game/Chat/Commands/Level1.cpp index a9f1e7d9c15..771339645fe 100644 --- a/src/server/game/Chat/Commands/Level1.cpp +++ b/src/server/game/Chat/Commands/Level1.cpp @@ -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()); diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp index 5d67ec06660..90c7d5ef8ae 100644 --- a/src/server/game/Chat/Commands/Level2.cpp +++ b/src/server/game/Chat/Commands/Level2.cpp @@ -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'", diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp index 009a4483f83..3ddf9b84365 100644 --- a/src/server/game/Chat/Commands/Level3.cpp +++ b/src/server/game/Chat/Commands/Level3.cpp @@ -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::GetLock()); - HashMapHolder::MapType const& plist = ObjectAccessor::Instance().GetPlayers(); + ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, *HashMapHolder::GetLock(), true); + HashMapHolder::MapType const& plist = sObjectAccessor.GetPlayers(); for (HashMapHolder::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()); diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index cb35d35c63f..2e81aad1859 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -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) diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index 2c7c44ecf7f..bb9fc2708fa 100644 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -121,8 +121,10 @@ typedef std::map ConditionReferenceMap;//only used for r class ConditionMgr { + friend class ACE_Singleton; + ConditionMgr(); + public: - ConditionMgr(); ~ConditionMgr(); void LoadConditions(bool isReload = false); @@ -165,6 +167,6 @@ class ConditionMgr std::list m_AllocatedMemory; // some garbage collection :) }; -#define sConditionMgr Trinity::Singleton::Instance() +#define sConditionMgr (*ACE_Singleton::instance()) #endif diff --git a/src/server/game/DataStores/DBCStores.cpp b/src/server/game/DataStores/DBCStores.cpp index dc5a5b831fd..bc127cb309c 100755 --- a/src/server/game/DataStores/DBCStores.cpp +++ b/src/server/game/DataStores/DBCStores.cpp @@ -19,7 +19,7 @@ */ #include "DBCStores.h" -#include "SingletonImp.h" + #include "Logging/Log.h" #include "ProgressBar.h" #include "SharedDefines.h" diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 1a2c9c9767c..6c089a83bc3 100644 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -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 ***/ /*********************************************************/ diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h index a3d6fedc695..88d33743fa9 100644 --- a/src/server/game/DungeonFinding/LFGMgr.h +++ b/src/server/game/DungeonFinding/LFGMgr.h @@ -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 LFGQueueMap; class LFGMgr { -public: + friend class ACE_Singleton; 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::Instance() +#define sLFGMgr (*ACE_Singleton::instance()) #endif diff --git a/src/server/game/Entities/Corpse/Corpse.cpp b/src/server/game/Entities/Corpse/Corpse.cpp index 6d9e11104ab..2811cfa129f 100644 --- a/src/server/game/Entities/Corpse/Corpse.cpp +++ b/src/server/game/Entities/Corpse/Corpse.cpp @@ -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(); } diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 62300e43a39..6570a418be9 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -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()); diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index a7c17561516..ae37ba56fd3 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -700,7 +700,7 @@ class Creature : public Unit, public GridObject 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 diff --git a/src/server/game/Entities/Creature/CreatureGroups.cpp b/src/server/game/Entities/Creature/CreatureGroups.cpp index 25aab942916..7bd05123ec5 100644 --- a/src/server/game/Entities/Creature/CreatureGroups.cpp +++ b/src/server/game/Entities/Creature/CreatureGroups.cpp @@ -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) diff --git a/src/server/game/Entities/Creature/CreatureGroups.h b/src/server/game/Entities/Creature/CreatureGroups.h index 521586b7457..4aa49571b5d 100644 --- a/src/server/game/Entities/Creature/CreatureGroups.h +++ b/src/server/game/Entities/Creature/CreatureGroups.h @@ -35,12 +35,15 @@ struct FormationInfo class CreatureGroupManager { + friend class ACE_Singleton; public: void AddCreatureToGroup(uint32 group_id, Creature *creature); void RemoveCreatureFromGroup(CreatureGroup *group, Creature *creature); void LoadCreatureFormations(); }; +#define formation_mgr (*ACE_Singleton::instance()) + typedef UNORDERED_MAP CreatureGroupInfoType; extern CreatureGroupInfoType CreatureGroupMap; @@ -73,6 +76,4 @@ class CreatureGroup void MemberAttackStart(Creature* member, Unit *target); }; -#define formation_mgr Trinity::Singleton::Instance() - #endif diff --git a/src/server/game/Entities/DynamicObject/DynamicObject.cpp b/src/server/game/Entities/DynamicObject/DynamicObject.cpp index 5c13fe47cb7..529710eda90 100644 --- a/src/server/game/Entities/DynamicObject/DynamicObject.cpp +++ b/src/server/game/Entities/DynamicObject/DynamicObject.cpp @@ -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); } } diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 364bc8ec29c..8783a8b5199 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -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); } } diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 4e32b48d6b8..fe4b8673b8f 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -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; } } diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index ed4bd4d6f96..3e3eea67cca 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -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); } } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 56d22c7b49e..e3ddcd81f0b 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -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)) { diff --git a/src/server/game/Entities/Player/SocialMgr.cpp b/src/server/game/Entities/Player/SocialMgr.cpp index a64692895a3..0de95352d19 100644 --- a/src/server/game/Entities/Player/SocialMgr.cpp +++ b/src/server/game/Entities/Player/SocialMgr.cpp @@ -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; diff --git a/src/server/game/Entities/Player/SocialMgr.h b/src/server/game/Entities/Player/SocialMgr.h index 092ab09dc15..dbed6e93006 100644 --- a/src/server/game/Entities/Player/SocialMgr.h +++ b/src/server/game/Entities/Player/SocialMgr.h @@ -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(); 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::Instance() +#define sSocialMgr (*ACE_Singleton::instance()) #endif diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index e1577237125..2a82b5c33df 100644 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -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 *)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()); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 0ee16010393..9d0bce23fd5 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -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()); diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index 25cd624b3c5..f22db3c8187 100644 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -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(MapManager::Instance().CreateBaseMap(data->mapid)); + Map* map = const_cast(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(MapManager::Instance().CreateBaseMap(data->mapid)); + Map* map = const_cast(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) diff --git a/src/server/game/Events/GameEventMgr.h b/src/server/game/Events/GameEventMgr.h index 21178805859..656be331edc 100644 --- a/src/server/game/Events/GameEventMgr.h +++ b/src/server/game/Events/GameEventMgr.h @@ -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(); public: - GameEventMgr(); ~GameEventMgr() {}; + typedef std::set ActiveEvents; typedef std::vector GameEventDataMap; ActiveEvents const& GetActiveEventList() const { return m_ActiveEvents; } @@ -172,7 +174,7 @@ class GameEventMgr GameEventGuidMap mGameEventGameobjectGuids; }; -#define gameeventmgr Trinity::Singleton::Instance() +#define gameeventmgr (*ACE_Singleton::instance()) bool IsHolidayActive(HolidayIds id); bool IsEventActive(uint16 event_id); diff --git a/src/server/game/Globals/GlobalEvents.cpp b/src/server/game/Globals/GlobalEvents.cpp index acdd91248bc..e83441cf3bb 100644 --- a/src/server/game/Globals/GlobalEvents.cpp +++ b/src/server/game/Globals/GlobalEvents.cpp @@ -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); diff --git a/src/server/game/Globals/ObjectAccessor.cpp b/src/server/game/Globals/ObjectAccessor.cpp index 73aca9865f8..b82944d8327 100644 --- a/src/server/game/Globals/ObjectAccessor.cpp +++ b/src/server/game/Globals/ObjectAccessor.cpp @@ -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 -#define CLASS_LOCK Trinity::ClassLevelLockable -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::GetLock()); + ACE_GUARD_RETURN(LockType, g, *HashMapHolder::GetLock(), NULL); HashMapHolder::MapType& m = HashMapHolder::GetContainer(); for (HashMapHolder::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::GetLock()); + ACE_GUARD(LockType, g, *HashMapHolder::GetLock()); HashMapHolder::MapType& m = HashMapHolder::GetContainer(); for (HashMapHolder::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()) { diff --git a/src/server/game/Globals/ObjectAccessor.h b/src/server/game/Globals/ObjectAccessor.h index e3295428505..fc128d6a4e0 100644 --- a/src/server/game/Globals/ObjectAccessor.h +++ b/src/server/game/Globals/ObjectAccessor.h @@ -22,10 +22,9 @@ #define TRINITY_OBJECTACCESSOR_H #include "Define.h" -#include "Singleton.h" +#include #include #include "UnorderedMap.h" -#include "ThreadingModel.h" #include "UpdateData.h" @@ -50,23 +49,22 @@ class HashMapHolder typedef UNORDERED_MAP MapType; typedef ACE_Thread_Mutex LockType; - typedef Trinity::GeneralLock 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 > +class ObjectAccessor { - friend class Trinity::OperatorNew; + friend class ACE_Singleton; ObjectAccessor(); ~ObjectAccessor(); ObjectAccessor(const ObjectAccessor&); @@ -220,13 +218,13 @@ class ObjectAccessor : public Trinity::Singleton Guard; private: @@ -254,4 +251,6 @@ class ObjectAccessor : public Trinity::Singleton::instance()) #endif diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index bab1add0132..00fbc83244c 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -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(MapManager::Instance().CreateBaseMap(mapId)); + Map* map = const_cast(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(MapManager::Instance().CreateBaseMap(mapId))) + if (Map* map = const_cast(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(MapManager::Instance().CreateBaseMap(mapId))) + if (Map* map = const_cast(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; } diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index b1a5bd0e1cd..320bf12cb21 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -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(); + ~ObjectMgr(); + public: - ObjectMgr(); - ~ObjectMgr(); - typedef UNORDERED_MAP ItemMap; typedef std::set< Group * > GroupSet; @@ -382,7 +382,7 @@ class ObjectMgr typedef std::vector 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(id); } @@ -1083,7 +1083,7 @@ class ObjectMgr }; -#define objmgr Trinity::Singleton::Instance() +#define objmgr (*ACE_Singleton::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::min()); diff --git a/src/server/game/Grids/Grid.h b/src/server/game/Grids/Grid.h index fd2cc28c184..2e300ac5e38 100644 --- a/src/server/game/Grids/Grid.h +++ b/src/server/game/Grids/Grid.h @@ -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 +class GRID_OBJECT_TYPES > class Grid { @@ -131,9 +129,6 @@ class Grid }*/ private: - typedef typename ThreadModel::Lock Guard; - typedef typename ThreadModel::VolatileType VolatileType; - TypeMapContainer i_container; TypeMapContainer i_objects; //typedef std::set ActiveGridObjects; diff --git a/src/server/game/Grids/NGrid.h b/src/server/game/Grids/NGrid.h index 8c539519211..1411ac71c4a 100644 --- a/src/server/game/Grids/NGrid.h +++ b/src/server/game/Grids/NGrid.h @@ -74,14 +74,13 @@ template unsigned int N, class ACTIVE_OBJECT, class WORLD_OBJECT_TYPES, -class GRID_OBJECT_TYPES, -class ThreadModel = Trinity::SingleThreaded +class GRID_OBJECT_TYPES > class NGrid { public: - typedef Grid GridType; + typedef Grid 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 >* pTo) + void link(GridRefManager >* pTo) { i_Reference.link(pTo, this); } @@ -178,7 +177,7 @@ class NGrid uint32 i_gridId; GridInfo i_GridInfo; - GridReference > i_Reference; + GridReference > i_Reference; int32 i_x; int32 i_y; grid_state_t i_cellstate; diff --git a/src/server/game/Grids/ObjectGridLoader.cpp b/src/server/game/Grids/ObjectGridLoader.cpp index ab69d9a966b..f0da10975ac 100644 --- a/src/server/game/Grids/ObjectGridLoader.cpp +++ b/src/server/game/Grids/ObjectGridLoader.cpp @@ -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; diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 53fa9a3ecdb..2977515959b 100644 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -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()) diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp index c62038cfbf0..7b5ccf1c46a 100644 --- a/src/server/game/Instances/InstanceSaveMgr.cpp +++ b/src/server/game/Instances/InstanceSaveMgr.cpp @@ -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) diff --git a/src/server/game/Instances/InstanceSaveMgr.h b/src/server/game/Instances/InstanceSaveMgr.h index 3d8bfb70ebf..66751cc4f10 100644 --- a/src/server/game/Instances/InstanceSaveMgr.h +++ b/src/server/game/Instances/InstanceSaveMgr.h @@ -23,7 +23,7 @@ #define __InstanceSaveMgr_H #include "Define.h" -#include "Singleton.h" +#include "ace/Singleton.h" #include "ace/Thread_Mutex.h" #include #include @@ -117,13 +117,14 @@ class InstanceSave typedef UNORDERED_MAP ResetTimeByMapDifficultyMap; -class InstanceSaveManager : public Trinity::Singleton > +class InstanceSaveManager { + friend class ACE_Singleton; friend class InstanceSave; public: - InstanceSaveManager(); + InstanceSaveManager() : lock_instLists(false) {}; ~InstanceSaveManager(); - + typedef UNORDERED_MAP InstanceSaveHashMap; typedef UNORDERED_MAP InstanceSaveMapMap; @@ -176,6 +177,7 @@ class InstanceSaveManager : public Trinity::Singleton::Instance() +#define sInstanceSaveManager (*ACE_Singleton::instance()) #endif diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index a0656bee38c..960e1e4cef4 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -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::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) { diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index d17dc10ec07..4d25381fbe1 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -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 CreatureMoveList; typedef std::map CreatureGroupHolderType; -class Map : public GridRefManager, public Trinity::ObjectLevelLockable +class Map : public GridRefManager { friend class MapReference; public: @@ -490,7 +489,7 @@ class Map : public GridRefManager, public Trinity::ObjectLevelLockabl protected: void SetUnloadReferenceLock(const GridPair &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadReferenceLock(on); } - typedef Trinity::ObjectLevelLockable::Lock Guard; + ACE_Thread_Mutex Lock; MapEntry const* i_mapEntry; uint8 i_spawnMode; diff --git a/src/server/game/Maps/MapInstanced.cpp b/src/server/game/Maps/MapInstanced.cpp index 0736bfa6fb3..008baeb79d9 100644 --- a/src/server/game/Maps/MapInstanced.cpp +++ b/src/server/game/Maps/MapInstanced.cpp @@ -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()); diff --git a/src/server/game/Maps/MapManager.cpp b/src/server/game/Maps/MapManager.cpp index 42233db4a9a..46b604388c5 100644 --- a/src/server/game/Maps/MapManager.cpp +++ b/src/server/game/Maps/MapManager.cpp @@ -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 -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) diff --git a/src/server/game/Maps/MapManager.h b/src/server/game/Maps/MapManager.h index c3380811c18..47cb9d2f795 100644 --- a/src/server/game/Maps/MapManager.h +++ b/src/server/game/Maps/MapManager.h @@ -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 > +class MapManager { - - friend class Trinity::OperatorNew; + friend class ACE_Singleton; typedef UNORDERED_MAP MapMapType; typedef std::pair::iterator, bool> MapMapPair; @@ -162,7 +161,7 @@ class MapManager : public Trinity::Singletonsecond); } - typedef Trinity::ClassLevelLockable::Lock Guard; + ACE_Thread_Mutex Lock; uint32 i_gridCleanUpDelay; MapMapType i_maps; IntervalTimer i_timer; @@ -170,4 +169,5 @@ class MapManager : public Trinity::Singleton::instance()) #endif diff --git a/src/server/game/Movement/MovementGenerator.h b/src/server/game/Movement/MovementGenerator.h index 650b4fc3196..9699f6951c2 100644 --- a/src/server/game/Movement/MovementGenerator.h +++ b/src/server/game/Movement/MovementGenerator.h @@ -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" diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp index 4cadfe1cfb6..416b775ef7e 100644 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp @@ -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) diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.cpp b/src/server/game/OutdoorPvP/OutdoorPvP.cpp index 71659a20be7..b19dc01ccd9 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvP.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvP.cpp @@ -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); diff --git a/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp b/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp index f9dbedb30dc..1ec2bcb6a9c 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp @@ -25,9 +25,6 @@ #include "OutdoorPvPEP.h" #include "ObjectMgr.h" #include "Player.h" -#include "SingletonImp.h" - -INSTANTIATE_SINGLETON_1(OutdoorPvPMgr); OutdoorPvPMgr::OutdoorPvPMgr() { diff --git a/src/server/game/OutdoorPvP/OutdoorPvPMgr.h b/src/server/game/OutdoorPvP/OutdoorPvPMgr.h index a78583100ec..2a18a602da9 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvPMgr.h +++ b/src/server/game/OutdoorPvP/OutdoorPvPMgr.h @@ -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::Instance() +#define sOutdoorPvPMgr (*ACE_Singleton::instance()) #endif /*OUTDOOR_PVP_MGR_H_*/ diff --git a/src/server/game/Pools/PoolHandler.cpp b/src/server/game/Pools/PoolHandler.cpp index 731d71c6b19..4a7c99216bd 100644 --- a/src/server/game/Pools/PoolHandler.cpp +++ b/src/server/game/Pools/PoolHandler.cpp @@ -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::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::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::Spawn1Object(PoolObject* obj) objmgr.AddCreatureToGrid(obj->guid, data); // Spawn if necessary (loaded grids only) - Map* map = const_cast(MapManager::Instance().CreateBaseMap(data->mapid)); + Map* map = const_cast(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::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(MapManager::Instance().CreateBaseMap(data->mapid)); + Map* map = const_cast(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::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::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); } diff --git a/src/server/game/Pools/PoolHandler.h b/src/server/game/Pools/PoolHandler.h index df62badd9c8..156bc47a2a9 100644 --- a/src/server/game/Pools/PoolHandler.h +++ b/src/server/game/Pools/PoolHandler.h @@ -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(); + ~PoolHandler() {}; + public: void LoadFromDB(); void Initialize(); @@ -134,7 +135,7 @@ class PoolHandler SpawnedPoolData mSpawnedData; }; -#define poolhandler Trinity::Singleton::Instance() +#define poolhandler (*ACE_Singleton::instance()) // Method that tell if the creature is part of a pool and return the pool id if yes template<> diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 88e5b7284c0..70b1ff6be64 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -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]; diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index 250bbf5526a..bcb26381809 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -94,8 +94,9 @@ struct Script class ScriptMgr { + friend class ACE_Singleton; + 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::Instance() +#define sScriptMgr (*ACE_Singleton::instance()) #endif diff --git a/src/server/game/Server/Protocol/Handlers/AddonHandler.cpp b/src/server/game/Server/Protocol/Handlers/AddonHandler.cpp index b54c119270f..13fbd266ea4 100644 --- a/src/server/game/Server/Protocol/Handlers/AddonHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/AddonHandler.cpp @@ -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() { } diff --git a/src/server/game/Server/Protocol/Handlers/AddonHandler.h b/src/server/game/Server/Protocol/Handlers/AddonHandler.h index 2c9394c947d..68620751da3 100644 --- a/src/server/game/Server/Protocol/Handlers/AddonHandler.h +++ b/src/server/game/Server/Protocol/Handlers/AddonHandler.h @@ -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(); + public: - /* Construction */ - AddonHandler(); ~AddonHandler(); - //built addon packet + //build addon packet bool BuildAddonPacket(WorldPacket* Source, WorldPacket* Target); }; -#define sAddOnHandler Trinity::Singleton::Instance() +#define sAddOnHandler ACE_Singleton::instance() #endif diff --git a/src/server/game/Server/Protocol/Handlers/ArenaTeamHandler.cpp b/src/server/game/Server/Protocol/Handlers/ArenaTeamHandler.cpp index 1d93090d255..3c26e17bddd 100644 --- a/src/server/game/Server/Protocol/Handlers/ArenaTeamHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/ArenaTeamHandler.cpp @@ -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) diff --git a/src/server/game/Server/Protocol/Handlers/ChannelHandler.cpp b/src/server/game/Server/Protocol/Handlers/ChannelHandler.cpp index 73f01f46c4c..442fe55b194 100644 --- a/src/server/game/Server/Protocol/Handlers/ChannelHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/ChannelHandler.cpp @@ -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" diff --git a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp index 141f3605ee2..ca08d197c3f 100644 --- a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp @@ -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(); diff --git a/src/server/game/Server/Protocol/Handlers/GuildHandler.cpp b/src/server/game/Server/Protocol/Handlers/GuildHandler.cpp index 6803fe63a86..4db1961e7af 100644 --- a/src/server/game/Server/Protocol/Handlers/GuildHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/GuildHandler.cpp @@ -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) { diff --git a/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp b/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp index e4d329e6afc..3bc5e8d507f 100644 --- a/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp @@ -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::GetLock()); - HashMapHolder::MapType& m = ObjectAccessor::Instance().GetPlayers(); + ACE_GUARD(ACE_Thread_Mutex, g, *HashMapHolder::GetLock()); + HashMapHolder::MapType& m = sObjectAccessor.GetPlayers(); for (HashMapHolder::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); diff --git a/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp b/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp index 1b850434726..56a8c9cd6da 100644 --- a/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp @@ -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) { diff --git a/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp b/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp index 05cbcf81f2f..fc2c3baf735 100644 --- a/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp @@ -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; diff --git a/src/server/game/Server/Protocol/WorldLog.cpp b/src/server/game/Server/Protocol/WorldLog.cpp index a9000f8e65c..e66bff0b504 100644 --- a/src/server/game/Server/Protocol/WorldLog.cpp +++ b/src/server/game/Server/Protocol/WorldLog.cpp @@ -23,14 +23,9 @@ */ #include "WorldLog.h" -#include "SingletonImp.h" #include "ConfigEnv.h" #include "Log.h" -#define CLASS_LOCK Trinity::ClassLevelLockable -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() - diff --git a/src/server/game/Server/Protocol/WorldLog.h b/src/server/game/Server/Protocol/WorldLog.h index 8a3c96b3b15..fd228ce4559 100644 --- a/src/server/game/Server/Protocol/WorldLog.h +++ b/src/server/game/Server/Protocol/WorldLog.h @@ -26,19 +26,19 @@ #define TRINITY_WORLDLOG_H #include "Common.h" -#include "Singleton.h" +#include "ace/Singleton.h" #include "Errors.h" #include /// %Log packets to a file -class WorldLog : public Trinity::Singleton > +class WorldLog { - friend class Trinity::OperatorNew; + friend class ACE_Singleton; WorldLog(); WorldLog(const WorldLog &); WorldLog& operator=(const WorldLog &); - typedef Trinity::ClassLevelLockable::Lock Guard; + ACE_Thread_Mutex Lock; /// Close the file in destructor ~WorldLog(); @@ -57,7 +57,7 @@ class WorldLog : public Trinity::Singleton::instance()) #endif /// @} diff --git a/src/server/game/Skills/SkillDiscovery.cpp b/src/server/game/Skills/SkillDiscovery.cpp index f0bfb5bc0ba..fb34cff150c 100644 --- a/src/server/game/Skills/SkillDiscovery.cpp +++ b/src/server/game/Skills/SkillDiscovery.cpp @@ -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" diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 7a975f021ff..a62e602fe49 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -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" diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index f89a0650729..19702f1b8f7 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -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); diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 2b6f84fbc1e..7d0b91e38de 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -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) ///
  • 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; diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index c53cab1124f..7266cf7e770 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -27,7 +27,7 @@ #include "Common.h" #include "Timer.h" -#include "Singleton.h" +#include #include "SharedDefines.h" #include "ace/Atomic_Op.h" #include "QueryResult.h" @@ -779,6 +779,6 @@ class World extern uint32 realmID; -#define sWorld Trinity::Singleton::Instance() +#define sWorld (*ACE_Singleton::instance()) #endif /// @} diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_victor_nefarius.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_victor_nefarius.cpp index b079dd94a58..f611c21e2bf 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_victor_nefarius.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_victor_nefarius.cpp @@ -189,9 +189,9 @@ struct boss_victor_nefariusAI : public ScriptedAI //Trinity::Singleton::Instance().GetMap(me->GetMapId(), me)->GetPlayers().begin(); /* - list ::const_iterator i = MapManager::Instance().GetMap(me->GetMapId(), me)->GetPlayers().begin(); + list ::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); diff --git a/src/server/shared/CMakeLists.txt b/src/server/shared/CMakeLists.txt index 04fbfbea60f..0fd58e63588 100644 --- a/src/server/shared/CMakeLists.txt +++ b/src/server/shared/CMakeLists.txt @@ -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} diff --git a/src/server/shared/Configuration/Config.cpp b/src/server/shared/Configuration/Config.cpp index 39830104a7c..3979cbc36aa 100644 --- a/src/server/shared/Configuration/Config.cpp +++ b/src/server/shared/Configuration/Config.cpp @@ -19,9 +19,6 @@ */ #include "ConfigEnv.h" -#include "Policies/SingletonImp.h" - -INSTANTIATE_SINGLETON_1(Config); Config::Config() : mIgnoreCase(true), mConf(NULL) { diff --git a/src/server/shared/Configuration/Config.h b/src/server/shared/Configuration/Config.h index bfcb324ee62..50cd4609b25 100644 --- a/src/server/shared/Configuration/Config.h +++ b/src/server/shared/Configuration/Config.h @@ -21,15 +21,16 @@ #ifndef CONFIG_H #define CONFIG_H -#include +#include #include "Define.h" class DOTCONFDocument; class Config { + friend class ACE_Singleton; + Config(); public: - Config(); ~Config(); bool SetSource(const char *file, bool ignorecase = true); @@ -47,7 +48,7 @@ class Config DOTCONFDocument *mConf; }; -#define sConfig Trinity::Singleton::Instance() +#define sConfig (*ACE_Singleton::instance()) #endif diff --git a/src/server/shared/Database/Database.cpp b/src/server/shared/Database/Database.cpp index 2dd2f9bbda4..1fb2f831a9f 100644 --- a/src/server/shared/Database/Database.cpp +++ b/src/server/shared/Database/Database.cpp @@ -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" diff --git a/src/server/shared/Database/Database.h b/src/server/shared/Database/Database.h index 655479c85fe..762abfd2ede 100644 --- a/src/server/shared/Database/Database.h +++ b/src/server/shared/Database/Database.h @@ -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" diff --git a/src/server/shared/Debugging/MemoryLeaks.cpp b/src/server/shared/Debugging/MemoryLeaks.cpp index ef7e36c3b57..c591dabb866 100644 --- a/src/server/shared/Debugging/MemoryLeaks.cpp +++ b/src/server/shared/Debugging/MemoryLeaks.cpp @@ -17,9 +17,6 @@ */ #include "MemoryLeaks.h" -#include "Policies/SingletonImp.h" - -INSTANTIATE_SINGLETON_1( MemoryManager ) ; MemoryManager::MemoryManager( ) { diff --git a/src/server/shared/Debugging/MemoryLeaks.h b/src/server/shared/Debugging/MemoryLeaks.h index bc722f241bd..4b13e4d3d90 100644 --- a/src/server/shared/Debugging/MemoryLeaks.h +++ b/src/server/shared/Debugging/MemoryLeaks.h @@ -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::instance() #endif diff --git a/src/server/shared/Dynamic/CountedReference/Reference.h b/src/server/shared/Dynamic/CountedReference/Reference.h deleted file mode 100644 index bdc06a572c9..00000000000 --- a/src/server/shared/Dynamic/CountedReference/Reference.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2010 Trinity - * - * 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 - * 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 -#include "Define.h" -#include "ThreadingModel.h" -#include "ReferenceHolder.h" - -template -< -typename T, -class THREADING_MODEL = Trinity::SingleThreaded -> -class Referencer -{ - typedef typename THREADING_MODEL::Lock Lock; - typedef ReferenceHolder 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(this)->_referencee(); } - operator T&(void) { return _referencee(); } - operator const T&(void) const { return *const_cast(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 - diff --git a/src/server/shared/Dynamic/CountedReference/ReferenceHolder.h b/src/server/shared/Dynamic/CountedReference/ReferenceHolder.h deleted file mode 100644 index 597e9854be0..00000000000 --- a/src/server/shared/Dynamic/CountedReference/ReferenceHolder.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2010 Trinity - * - * 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 - diff --git a/src/server/shared/Dynamic/CountedReference/ReferenceImpl.h b/src/server/shared/Dynamic/CountedReference/ReferenceImpl.h deleted file mode 100644 index cde330179e3..00000000000 --- a/src/server/shared/Dynamic/CountedReference/ReferenceImpl.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2010 Trinity - * - * 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::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::~Referencer() -{ - if( i_holder != NULL ) - deReference(i_holder); - i_holder = NULL; -} - -template -< -typename T, -class THREADING_MODEL -> -Referencer& -Referencer::operator=(const Referencer &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& -Referencer::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::deReference(ReferenceHolder *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::addReference(ReferenceHolder *holder) -{ - assert( i_holder != NULL ); - Lock guard(*holder); - Guard(&guard); - - ++holder->i_referenceCount; -} -#endif - diff --git a/src/server/shared/Dynamic/FactoryHolder.h b/src/server/shared/Dynamic/FactoryHolder.h index fd5925f5f75..096bdad1783 100644 --- a/src/server/shared/Dynamic/FactoryHolder.h +++ b/src/server/shared/Dynamic/FactoryHolder.h @@ -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, Key > FactoryHolderRegistry; - typedef Trinity::Singleton FactoryHolderRepository; + friend class ACE_Singleton; + typedef ACE_Singleton 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; diff --git a/src/server/shared/Dynamic/ObjectRegistry.h b/src/server/shared/Dynamic/ObjectRegistry.h index eaf8e1acd2d..11052a9f0a7 100644 --- a/src/server/shared/Dynamic/ObjectRegistry.h +++ b/src/server/shared/Dynamic/ObjectRegistry.h @@ -23,7 +23,7 @@ #include "Define.h" #include "Dynamic/UnorderedMap.h" -#include "Policies/Singleton.h" +#include "ace/Singleton.h" #include #include @@ -94,11 +94,6 @@ class ObjectRegistry return i_registeredObjects; } - private: - RegistryMapType i_registeredObjects; - friend class Trinity::OperatorNew >; - - // 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 diff --git a/src/server/shared/Logging/Log.cpp b/src/server/shared/Logging/Log.cpp index 0f27400dce2..7a34eaa0c0d 100644 --- a/src/server/shared/Logging/Log.cpp +++ b/src/server/shared/Logging/Log.cpp @@ -20,15 +20,12 @@ #include "Common.h" #include "Log.h" -#include "Policies/SingletonImp.h" #include "Configuration/ConfigEnv.h" #include "Util.h" #include #include -INSTANTIATE_SINGLETON_1( Log ); - Log::Log() : raLogfile(NULL), logfile(NULL), gmLogfile(NULL), charLogfile(NULL), dberLogfile(NULL), chatLogfile(NULL), m_gmlog_per_account(false), diff --git a/src/server/shared/Logging/Log.h b/src/server/shared/Logging/Log.h index 53ce4e601b5..fb584d42c27 100644 --- a/src/server/shared/Logging/Log.h +++ b/src/server/shared/Logging/Log.h @@ -22,7 +22,7 @@ #define TRINITYCORE_LOG_H #include "Common.h" -#include "Policies/Singleton.h" +#include #include "Database/DatabaseEnv.h" class Config; @@ -82,9 +82,9 @@ enum ColorTypes const int Colors = int(WHITE)+1; -class Log : public Trinity::Singleton > +class Log { - friend class Trinity::OperatorNew; + friend class ACE_Singleton; Log(); ~Log(); @@ -172,10 +172,10 @@ class Log : public Trinity::Singleton::Instance() +#define sLog (*ACE_Singleton::instance()) #ifdef TRINITY_DEBUG -#define DEBUG_LOG Trinity::Singleton::Instance().outDebug +#define DEBUG_LOG sLog.outDebug #else #define DEBUG_LOG #endif diff --git a/src/server/shared/Policies/CreationPolicy.h b/src/server/shared/Policies/CreationPolicy.h deleted file mode 100644 index cc38d704e99..00000000000 --- a/src/server/shared/Policies/CreationPolicy.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2010 Trinity - * - * 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 -#include "Define.h" - -namespace Trinity -{ - /** - * OperatorNew policy creates an object on the heap using new. - */ - template - 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 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 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 CreateOnCallBack - { - public: - static T* Create() - { - return CALL_BACK::createCallBack(); - } - - static void Destroy(T *p) - { - CALL_BACK::destroyCallBack(p); - } - }; -} -#endif - diff --git a/src/server/shared/Policies/ObjectLifeTime.cpp b/src/server/shared/Policies/ObjectLifeTime.cpp deleted file mode 100644 index fd16873ae92..00000000000 --- a/src/server/shared/Policies/ObjectLifeTime.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2010 Trinity - * - * 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 - */ - -#include -#include "ObjectLifeTime.h" - -namespace Trinity -{ - extern "C" void external_wrapper(void *p) - { - std::atexit( (void (*)())p ); - } - - void at_exit( void (*func)() ) - { - external_wrapper((void*)func); - } -} - diff --git a/src/server/shared/Policies/ObjectLifeTime.h b/src/server/shared/Policies/ObjectLifeTime.h deleted file mode 100644 index 205434cb613..00000000000 --- a/src/server/shared/Policies/ObjectLifeTime.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2010 Trinity - * - * 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_OBJECTLIFETIME_H -#define TRINITY_OBJECTLIFETIME_H - -#include -#include "Define.h" - -typedef void (* Destroyer)(void); - -namespace Trinity -{ - void at_exit( void (*func)() ); - - template - class ObjectLifeTime - { - public: - static void ScheduleCall(void (*destroyer)() ) - { - at_exit( destroyer ); - } - - DECLSPEC_NORETURN static void OnDeadReference(void) ATTR_NORETURN; - - }; - - template - void ObjectLifeTime::OnDeadReference(void) // We don't handle Dead Reference for now - { - throw std::runtime_error("Dead Reference"); - } -} -#endif - diff --git a/src/server/shared/Policies/Singleton.h b/src/server/shared/Policies/Singleton.h deleted file mode 100644 index da898558ca5..00000000000 --- a/src/server/shared/Policies/Singleton.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2010 Trinity - * - * 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_SINGLETON_H -#define TRINITY_SINGLETON_H - -/** - * @brief class Singleton - */ - -#include "CreationPolicy.h" -#include "ThreadingModel.h" -#include "ObjectLifeTime.h" - -namespace Trinity -{ - template - < - typename T, - class ThreadingModel = Trinity::SingleThreaded, - class CreatePolicy = Trinity::OperatorNew, - class LifeTimePolicy = Trinity::ObjectLifeTime - > - class Singleton - { - public: - static T& Instance(); - - protected: - Singleton() {}; - - private: - - // Prohibited actions...this does not prevent hijacking. - Singleton(const Singleton &); - Singleton& operator=(const Singleton &); - - // Singleton Helpers - static void DestroySingleton(); - - // data structure - typedef typename ThreadingModel::Lock Guard; - static T *si_instance; - static bool si_destroyed; - }; -} -#endif - diff --git a/src/server/shared/Policies/SingletonImp.h b/src/server/shared/Policies/SingletonImp.h deleted file mode 100644 index 3e985cd5c64..00000000000 --- a/src/server/shared/Policies/SingletonImp.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2010 Trinity - * - * 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_SINGLETONIMPL_H -#define TRINITY_SINGLETONIMPL_H - -#include "Singleton.h" - -// avoid the using namespace here cuz -// its a .h file afterall - -template -< -typename T, -class ThreadingModel, -class CreatePolicy, -class LifeTimePolicy -> -T& -Trinity::Singleton::Instance() -{ - if( !si_instance ) - { - // double-checked Locking pattern - Guard(); - if( !si_instance ) - { - if( si_destroyed ) - { - si_destroyed = false; - LifeTimePolicy::OnDeadReference(); - } - si_instance = CreatePolicy::Create(); - LifeTimePolicy::ScheduleCall(&DestroySingleton); - } - } - - return *si_instance; -} - -template -< -typename T, -class ThreadingModel, -class CreatePolicy, -class LifeTimePolicy -> -void -Trinity::Singleton::DestroySingleton() -{ - CreatePolicy::Destroy(si_instance); - si_instance = NULL; - si_destroyed = true; -} - -#define INSTANTIATE_SINGLETON_1(TYPE) \ - template class Trinity::Singleton, Trinity::OperatorNew, Trinity::ObjectLifeTime >; \ - template<> TYPE* Trinity::Singleton, Trinity::OperatorNew, Trinity::ObjectLifeTime >::si_instance = 0; \ - template<> bool Trinity::Singleton, Trinity::OperatorNew, Trinity::ObjectLifeTime >::si_destroyed = false - -#define INSTANTIATE_SINGLETON_2(TYPE, THREADINGMODEL) \ - template class Trinity::Singleton, Trinity::ObjectLifeTime >; \ - template<> TYPE* Trinity::Singleton, Trinity::ObjectLifeTime >::si_instance = 0; \ - template<> bool Trinity::Singleton, Trinity::ObjectLifeTime >::si_destroyed = false - -#define INSTANTIATE_SINGLETON_3(TYPE, THREADINGMODEL, CREATIONPOLICY ) \ - template class Trinity::Singleton >; \ - template<> TYPE* Trinity::Singleton >::si_instance = 0; \ - template<> bool Trinity::Singleton >::si_destroyed = false - -#define INSTANTIATE_SINGLETON_4(TYPE, THREADINGMODEL, CREATIONPOLICY, OBJECTLIFETIME) \ - template class Trinity::Singleton; \ - template<> TYPE* Trinity::Singleton::si_instance = 0; \ - template<> bool Trinity::Singleton::si_destroyed = false -#endif - diff --git a/src/server/shared/Policies/ThreadingModel.h b/src/server/shared/Policies/ThreadingModel.h deleted file mode 100644 index a792bf1b7d7..00000000000 --- a/src/server/shared/Policies/ThreadingModel.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2010 Trinity - * - * 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_THREADINGMODEL_H -#define TRINITY_THREADINGMODEL_H - -/** - * @class ThreadingModel - * - */ - -#include "Define.h" - -namespace Trinity -{ - inline void Guard(void *) {} - - template class GeneralLock - { - public: - GeneralLock(MUTEX &m) : i_mutex(m) - { - i_mutex.acquire(); - } - - ~GeneralLock() - { - i_mutex.release(); - } - private: - GeneralLock(const GeneralLock &); - GeneralLock& operator=(const GeneralLock &); - MUTEX &i_mutex; - }; - - template - class SingleThreaded - { - public: - - struct Lock // empty object - { - Lock() {} - Lock(const T &) {} - Lock(const SingleThreaded &) // for single threaded we ignore this - { - } - }; - - typedef T VolatileType; - }; - - // object level lockable - template - class ObjectLevelLockable - { - public: - ObjectLevelLockable() : i_mtx() {} - - friend class Lock; - - class Lock - { - public: - Lock(ObjectLevelLockable &host) : i_lock(host.i_mtx) - { - } - - private: - GeneralLock i_lock; - }; - - typedef volatile T VolatileType; - - private: - // prevent the compiler creating a copy construct - ObjectLevelLockable(const ObjectLevelLockable &); - ObjectLevelLockable& operator=(const ObjectLevelLockable &); - - MUTEX i_mtx; - }; - - template - class ClassLevelLockable - { - public: - class Lock; - friend class Lock; - typedef volatile T VolatileType; - - ClassLevelLockable() {} - - class Lock - { - public: - Lock(T& /*host*/) { ClassLevelLockable::si_mtx.acquire(); } - Lock(ClassLevelLockable &) { ClassLevelLockable::si_mtx.acquire(); } - Lock() { ClassLevelLockable::si_mtx.acquire(); } - ~Lock() { ClassLevelLockable::si_mtx.release(); } - }; - - private: - static MUTEX si_mtx; - }; - -} - -template MUTEX Trinity::ClassLevelLockable::si_mtx; - -#define INSTANTIATE_CLASS_MUTEX(CTYPE,MUTEX) \ - template class Trinity::ClassLevelLockable -#endif - diff --git a/src/server/worldserver/Master.cpp b/src/server/worldserver/Master.cpp index 332a607dcad..fb2d828e284 100644 --- a/src/server/worldserver/Master.cpp +++ b/src/server/worldserver/Master.cpp @@ -33,7 +33,6 @@ #include "WorldSocketMgr.h" #include "Configuration/ConfigEnv.h" #include "Database/DatabaseEnv.h" -#include "SingletonImp.h" #include "CliRunnable.h" #include "Log.h" @@ -58,8 +57,6 @@ extern int m_ServiceStatus; /// \todo Warning disabling not useful under VC++2005. Can somebody say on which compiler it is useful? #pragma warning(disable:4305) -INSTANTIATE_SINGLETON_1( Master ); - volatile uint32 Master::m_masterLoopCounter = 0; /// Handle cored's termination signals diff --git a/src/server/worldserver/Master.h b/src/server/worldserver/Master.h index 76ff2af1457..00628827e2a 100644 --- a/src/server/worldserver/Master.h +++ b/src/server/worldserver/Master.h @@ -26,7 +26,6 @@ #define _MASTER_H #include "Common.h" -#include "Policies/Singleton.h" /// Start the server class Master @@ -43,6 +42,6 @@ class Master void clearOnlineAccounts(); }; -#define sMaster Trinity::Singleton::Instance() +#define sMaster (*ACE_Singleton::instance()) #endif /// @} diff --git a/src/server/worldserver/WorldThread/WorldRunnable.cpp b/src/server/worldserver/WorldThread/WorldRunnable.cpp index 3531873ec0c..69639da62fa 100644 --- a/src/server/worldserver/WorldThread/WorldRunnable.cpp +++ b/src/server/worldserver/WorldThread/WorldRunnable.cpp @@ -90,7 +90,7 @@ void WorldRunnable::run() sWorldSocketMgr->StopNetwork(); - MapManager::Instance().UnloadAll(); // unload all grids (including locked in memory) + sMapMgr.UnloadAll(); // unload all grids (including locked in memory) ///- End the database thread WorldDatabase.ThreadEnd(); // free mySQL thread resources diff --git a/win/VC90/shared.vcproj b/win/VC90/shared.vcproj index 2c7310a7929..536939f9d5a 100644 --- a/win/VC90/shared.vcproj +++ b/win/VC90/shared.vcproj @@ -588,22 +588,6 @@ RelativePath="..\..\src\server\shared\Dynamic\UnorderedMap.h" > - - - - - - - - @@ -641,14 +625,6 @@ > - - - - -- cgit v1.2.3