From b3f3ffa885e27ed1b49f0fa1609d0d5d71e351af Mon Sep 17 00:00:00 2001 From: XTZGZoReX Date: Sun, 8 Nov 2009 19:32:50 +0100 Subject: [PATCH] [8793] Don't do operations through singleton if already in singleton context. * Also, some minor things: - Remove duplicate sWorldLog define. - Add sRealmList macro for RealmList::Instance(). - Use sLog macro in scripting log functions. --- src/game/InstanceSaveMgr.cpp | 2 +- src/game/ObjectMgr.cpp | 6 +++--- src/game/SpellMgr.cpp | 6 +++--- src/game/World.cpp | 22 +++++++++++----------- src/game/WorldLog.cpp | 2 -- src/realmd/AuthSocket.cpp | 6 +++--- src/realmd/Main.cpp | 4 ++-- src/realmd/RealmList.cpp | 2 +- src/realmd/RealmList.h | 2 ++ src/shared/Log.cpp | 10 +++++----- src/shared/revision_nr.h | 2 +- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/game/InstanceSaveMgr.cpp b/src/game/InstanceSaveMgr.cpp index c5a679cdb..8963de3f5 100644 --- a/src/game/InstanceSaveMgr.cpp +++ b/src/game/InstanceSaveMgr.cpp @@ -258,7 +258,7 @@ void InstanceSaveManager::CleanupInstances() bar.step(); // load reset times and clean expired instances - sInstanceSaveMgr.LoadResetTimes(); + LoadResetTimes(); // clean character/group - instance binds with invalid group/characters _DelHelper(CharacterDatabase, "character_instance.guid, instance", "character_instance", "LEFT JOIN characters ON character_instance.guid = characters.guid WHERE characters.guid IS NULL"); diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 20ec90844..8f111a0ad 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -4099,7 +4099,7 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename) continue; } - // if(!sObjectMgr.GetMangosStringLocale(tmp.dataint)) will checked after db_script_string loading + // if(!GetMangosStringLocale(tmp.dataint)) will checked after db_script_string loading break; } @@ -5111,11 +5111,11 @@ uint32 ObjectMgr::GetTaxiMountDisplayId( uint32 id, uint32 team, bool allowed_al if (!mount_info) return 0; - uint16 mount_id = sObjectMgr.ChooseDisplayId(team,mount_info); + uint16 mount_id = ChooseDisplayId(team,mount_info); if (!mount_id) return 0; - CreatureModelInfo const *minfo = sObjectMgr.GetCreatureModelRandomGender(mount_id); + CreatureModelInfo const *minfo = GetCreatureModelRandomGender(mount_id); if (minfo) mount_id = minfo->modelid; diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 8ac87a673..2d4d5590c 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -2260,8 +2260,8 @@ void SpellMgr::LoadSpellScriptTarget() { if( spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT || spellInfo->EffectImplicitTargetA[j] != TARGET_SELF && spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT ) { - SpellScriptTarget::const_iterator lower = sSpellMgr.GetBeginSpellScriptTarget(spellInfo->Id); - SpellScriptTarget::const_iterator upper = sSpellMgr.GetEndSpellScriptTarget(spellInfo->Id); + SpellScriptTarget::const_iterator lower = GetBeginSpellScriptTarget(spellInfo->Id); + SpellScriptTarget::const_iterator upper = GetEndSpellScriptTarget(spellInfo->Id); if(lower==upper) { sLog.outErrorDb("Spell (ID: %u) has effect EffectImplicitTargetA/EffectImplicitTargetB = %u (TARGET_SCRIPT), but does not have record in `spell_script_target`",spellInfo->Id,TARGET_SCRIPT); @@ -2849,7 +2849,7 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const *spell } // DB base check (if non empty then must fit at least single for allow) - SpellAreaMapBounds saBounds = sSpellMgr.GetSpellAreaMapBounds(spellInfo->Id); + SpellAreaMapBounds saBounds = GetSpellAreaMapBounds(spellInfo->Id); if (saBounds.first != saBounds.second) { for(SpellAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) diff --git a/src/game/World.cpp b/src/game/World.cpp index ce6244b35..f0cd0fdb5 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -242,7 +242,7 @@ World::AddSession_ (WorldSession* s) s->SendAddonsInfo(); WorldPacket pkt(SMSG_CLIENTCACHE_VERSION, 4); - pkt << uint32(sWorld.getConfig(CONFIG_CLIENTCACHE_VERSION)); + pkt << uint32(getConfig(CONFIG_CLIENTCACHE_VERSION)); s->SendPacket(&pkt); s->SendAccountDataTimes(GLOBAL_CACHE_MASK); @@ -329,7 +329,7 @@ bool World::RemoveQueuedPlayer(WorldSession* sess) pop_sess->SendAddonsInfo(); WorldPacket pkt(SMSG_CLIENTCACHE_VERSION, 4); - pkt << uint32(sWorld.getConfig(CONFIG_CLIENTCACHE_VERSION)); + pkt << uint32(getConfig(CONFIG_CLIENTCACHE_VERSION)); pop_sess->SendPacket(&pkt); pop_sess->SendAccountDataTimes(GLOBAL_CACHE_MASK); @@ -1016,10 +1016,10 @@ void World::LoadConfigSettings(bool reload) //visibility on continents m_MaxVisibleDistanceOnContinents = sConfig.GetFloatDefault("Visibility.Distance.Continents", DEFAULT_VISIBILITY_DISTANCE); - if(m_MaxVisibleDistanceOnContinents < 45*sWorld.getRate(RATE_CREATURE_AGGRO)) + if(m_MaxVisibleDistanceOnContinents < 45*getRate(RATE_CREATURE_AGGRO)) { - sLog.outError("Visibility.Distance.Continents can't be less max aggro radius %f", 45*sWorld.getRate(RATE_CREATURE_AGGRO)); - m_MaxVisibleDistanceOnContinents = 45*sWorld.getRate(RATE_CREATURE_AGGRO); + sLog.outError("Visibility.Distance.Continents can't be less max aggro radius %f", 45*getRate(RATE_CREATURE_AGGRO)); + m_MaxVisibleDistanceOnContinents = 45*getRate(RATE_CREATURE_AGGRO); } else if(m_MaxVisibleDistanceOnContinents + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) { @@ -1029,10 +1029,10 @@ void World::LoadConfigSettings(bool reload) //visibility in instances m_MaxVisibleDistanceInInctances = sConfig.GetFloatDefault("Visibility.Distance.Instances", DEFAULT_VISIBILITY_INSTANCE); - if(m_MaxVisibleDistanceInInctances < 45*sWorld.getRate(RATE_CREATURE_AGGRO)) + if(m_MaxVisibleDistanceInInctances < 45*getRate(RATE_CREATURE_AGGRO)) { - sLog.outError("Visibility.Distance.Instances can't be less max aggro radius %f",45*sWorld.getRate(RATE_CREATURE_AGGRO)); - m_MaxVisibleDistanceInInctances = 45*sWorld.getRate(RATE_CREATURE_AGGRO); + sLog.outError("Visibility.Distance.Instances can't be less max aggro radius %f",45*getRate(RATE_CREATURE_AGGRO)); + m_MaxVisibleDistanceInInctances = 45*getRate(RATE_CREATURE_AGGRO); } else if(m_MaxVisibleDistanceInInctances + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) { @@ -1042,10 +1042,10 @@ void World::LoadConfigSettings(bool reload) //visibility in BG/Arenas m_MaxVisibleDistanceInBGArenas = sConfig.GetFloatDefault("Visibility.Distance.BGArenas", DEFAULT_VISIBILITY_BGARENAS); - if(m_MaxVisibleDistanceInBGArenas < 45*sWorld.getRate(RATE_CREATURE_AGGRO)) + if(m_MaxVisibleDistanceInBGArenas < 45*getRate(RATE_CREATURE_AGGRO)) { - sLog.outError("Visibility.Distance.BGArenas can't be less max aggro radius %f",45*sWorld.getRate(RATE_CREATURE_AGGRO)); - m_MaxVisibleDistanceInBGArenas = 45*sWorld.getRate(RATE_CREATURE_AGGRO); + sLog.outError("Visibility.Distance.BGArenas can't be less max aggro radius %f",45*getRate(RATE_CREATURE_AGGRO)); + m_MaxVisibleDistanceInBGArenas = 45*getRate(RATE_CREATURE_AGGRO); } else if(m_MaxVisibleDistanceInBGArenas + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) { diff --git a/src/game/WorldLog.cpp b/src/game/WorldLog.cpp index aab743e0b..6b6f6f337 100644 --- a/src/game/WorldLog.cpp +++ b/src/game/WorldLog.cpp @@ -45,5 +45,3 @@ void WorldLog::Initialize() i_file = fopen((logsDir+logname).c_str(), "w"); } } - -#define sWorldLog WorldLog::Instance() diff --git a/src/realmd/AuthSocket.cpp b/src/realmd/AuthSocket.cpp index 64e615254..f1c1027b6 100644 --- a/src/realmd/AuthSocket.cpp +++ b/src/realmd/AuthSocket.cpp @@ -879,14 +879,14 @@ bool AuthSocket::_HandleRealmList() delete result; ///- Update realm list if need - RealmList::Instance().UpdateIfNeed(); + sRealmList.UpdateIfNeed(); ///- Circle through realms in the RealmList and construct the return packet (including # of user characters in each realm) ByteBuffer pkt; pkt << (uint32) 0; - pkt << (uint16) RealmList::Instance().size(); + pkt << (uint16) sRealmList.size(); RealmList::RealmMap::const_iterator i; - for( i = RealmList::Instance().begin(); i != RealmList::Instance().end(); ++i ) + for( i = sRealmList.begin(); i != sRealmList.end(); ++i ) { uint8 AmountOfCharacters; diff --git a/src/realmd/Main.cpp b/src/realmd/Main.cpp index 2cfe62abd..70f93f431 100644 --- a/src/realmd/Main.cpp +++ b/src/realmd/Main.cpp @@ -190,8 +190,8 @@ extern int main(int argc, char **argv) return 1; ///- Get the list of realms for the server - RealmList::Instance().Initialize(sConfig.GetIntDefault("RealmsStateUpdateDelay", 20)); - if (RealmList::Instance().size() == 0) + sRealmList.Initialize(sConfig.GetIntDefault("RealmsStateUpdateDelay", 20)); + if (sRealmList.size() == 0) { sLog.outError("No valid realms specified."); return 1; diff --git a/src/realmd/RealmList.cpp b/src/realmd/RealmList.cpp index f41344c00..23255eb60 100644 --- a/src/realmd/RealmList.cpp +++ b/src/realmd/RealmList.cpp @@ -33,7 +33,7 @@ RealmList::RealmList( ) : m_UpdateInterval(0), m_NextUpdateTime(time(NULL)) { } -RealmList& RealmList::Instance() +RealmList& sRealmList { static RealmList realmlist; return realmlist; diff --git a/src/realmd/RealmList.h b/src/realmd/RealmList.h index 1ab6d9371..936f83e4e 100644 --- a/src/realmd/RealmList.h +++ b/src/realmd/RealmList.h @@ -64,5 +64,7 @@ class RealmList time_t m_NextUpdateTime; }; +#define sRealmList RealmList::Instance() + #endif /// @} diff --git a/src/shared/Log.cpp b/src/shared/Log.cpp index a4166dcee..15600ed7a 100644 --- a/src/shared/Log.cpp +++ b/src/shared/Log.cpp @@ -767,7 +767,7 @@ void outstring_log(const char * str, ...) vsnprintf(buf,256, str, ap); va_end(ap); - MaNGOS::Singleton::Instance().outString(buf); + sLog.outString(buf); } void detail_log(const char * str, ...) @@ -781,7 +781,7 @@ void detail_log(const char * str, ...) vsnprintf(buf,256, str, ap); va_end(ap); - MaNGOS::Singleton::Instance().outDetail(buf); + sLog.outDetail(buf); } void debug_log(const char * str, ...) @@ -795,7 +795,7 @@ void debug_log(const char * str, ...) vsnprintf(buf,256, str, ap); va_end(ap); - MaNGOS::Singleton::Instance().outDebug(buf); + sLog.outDebug(buf); } void error_log(const char * str, ...) @@ -809,7 +809,7 @@ void error_log(const char * str, ...) vsnprintf(buf,256, str, ap); va_end(ap); - MaNGOS::Singleton::Instance().outError(buf); + sLog.outError(buf); } void error_db_log(const char * str, ...) @@ -823,5 +823,5 @@ void error_db_log(const char * str, ...) vsnprintf(buf,256, str, ap); va_end(ap); - MaNGOS::Singleton::Instance().outErrorDb(buf); + sLog.outErrorDb(buf); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index d1615903e..0e91d5c27 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8792" + #define REVISION_NR "8793" #endif // __REVISION_NR_H__