[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.
This commit is contained in:
XTZGZoReX 2009-11-08 19:32:50 +01:00
parent 146657885d
commit b3f3ffa885
11 changed files with 32 additions and 32 deletions

View file

@ -258,7 +258,7 @@ void InstanceSaveManager::CleanupInstances()
bar.step(); bar.step();
// load reset times and clean expired instances // load reset times and clean expired instances
sInstanceSaveMgr.LoadResetTimes(); LoadResetTimes();
// clean character/group - instance binds with invalid group/characters // 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"); _DelHelper(CharacterDatabase, "character_instance.guid, instance", "character_instance", "LEFT JOIN characters ON character_instance.guid = characters.guid WHERE characters.guid IS NULL");

View file

@ -4099,7 +4099,7 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
continue; 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; break;
} }
@ -5111,11 +5111,11 @@ uint32 ObjectMgr::GetTaxiMountDisplayId( uint32 id, uint32 team, bool allowed_al
if (!mount_info) if (!mount_info)
return 0; return 0;
uint16 mount_id = sObjectMgr.ChooseDisplayId(team,mount_info); uint16 mount_id = ChooseDisplayId(team,mount_info);
if (!mount_id) if (!mount_id)
return 0; return 0;
CreatureModelInfo const *minfo = sObjectMgr.GetCreatureModelRandomGender(mount_id); CreatureModelInfo const *minfo = GetCreatureModelRandomGender(mount_id);
if (minfo) if (minfo)
mount_id = minfo->modelid; mount_id = minfo->modelid;

View file

@ -2260,8 +2260,8 @@ void SpellMgr::LoadSpellScriptTarget()
{ {
if( spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT || spellInfo->EffectImplicitTargetA[j] != TARGET_SELF && spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT ) 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 lower = GetBeginSpellScriptTarget(spellInfo->Id);
SpellScriptTarget::const_iterator upper = sSpellMgr.GetEndSpellScriptTarget(spellInfo->Id); SpellScriptTarget::const_iterator upper = GetEndSpellScriptTarget(spellInfo->Id);
if(lower==upper) 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); 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) // 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) if (saBounds.first != saBounds.second)
{ {
for(SpellAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) for(SpellAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)

View file

@ -242,7 +242,7 @@ World::AddSession_ (WorldSession* s)
s->SendAddonsInfo(); s->SendAddonsInfo();
WorldPacket pkt(SMSG_CLIENTCACHE_VERSION, 4); WorldPacket pkt(SMSG_CLIENTCACHE_VERSION, 4);
pkt << uint32(sWorld.getConfig(CONFIG_CLIENTCACHE_VERSION)); pkt << uint32(getConfig(CONFIG_CLIENTCACHE_VERSION));
s->SendPacket(&pkt); s->SendPacket(&pkt);
s->SendAccountDataTimes(GLOBAL_CACHE_MASK); s->SendAccountDataTimes(GLOBAL_CACHE_MASK);
@ -329,7 +329,7 @@ bool World::RemoveQueuedPlayer(WorldSession* sess)
pop_sess->SendAddonsInfo(); pop_sess->SendAddonsInfo();
WorldPacket pkt(SMSG_CLIENTCACHE_VERSION, 4); 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->SendPacket(&pkt);
pop_sess->SendAccountDataTimes(GLOBAL_CACHE_MASK); pop_sess->SendAccountDataTimes(GLOBAL_CACHE_MASK);
@ -1016,10 +1016,10 @@ void World::LoadConfigSettings(bool reload)
//visibility on continents //visibility on continents
m_MaxVisibleDistanceOnContinents = sConfig.GetFloatDefault("Visibility.Distance.Continents", DEFAULT_VISIBILITY_DISTANCE); 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)); sLog.outError("Visibility.Distance.Continents can't be less max aggro radius %f", 45*getRate(RATE_CREATURE_AGGRO));
m_MaxVisibleDistanceOnContinents = 45*sWorld.getRate(RATE_CREATURE_AGGRO); m_MaxVisibleDistanceOnContinents = 45*getRate(RATE_CREATURE_AGGRO);
} }
else if(m_MaxVisibleDistanceOnContinents + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) else if(m_MaxVisibleDistanceOnContinents + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE)
{ {
@ -1029,10 +1029,10 @@ void World::LoadConfigSettings(bool reload)
//visibility in instances //visibility in instances
m_MaxVisibleDistanceInInctances = sConfig.GetFloatDefault("Visibility.Distance.Instances", DEFAULT_VISIBILITY_INSTANCE); 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)); sLog.outError("Visibility.Distance.Instances can't be less max aggro radius %f",45*getRate(RATE_CREATURE_AGGRO));
m_MaxVisibleDistanceInInctances = 45*sWorld.getRate(RATE_CREATURE_AGGRO); m_MaxVisibleDistanceInInctances = 45*getRate(RATE_CREATURE_AGGRO);
} }
else if(m_MaxVisibleDistanceInInctances + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) else if(m_MaxVisibleDistanceInInctances + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE)
{ {
@ -1042,10 +1042,10 @@ void World::LoadConfigSettings(bool reload)
//visibility in BG/Arenas //visibility in BG/Arenas
m_MaxVisibleDistanceInBGArenas = sConfig.GetFloatDefault("Visibility.Distance.BGArenas", DEFAULT_VISIBILITY_BGARENAS); 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)); sLog.outError("Visibility.Distance.BGArenas can't be less max aggro radius %f",45*getRate(RATE_CREATURE_AGGRO));
m_MaxVisibleDistanceInBGArenas = 45*sWorld.getRate(RATE_CREATURE_AGGRO); m_MaxVisibleDistanceInBGArenas = 45*getRate(RATE_CREATURE_AGGRO);
} }
else if(m_MaxVisibleDistanceInBGArenas + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) else if(m_MaxVisibleDistanceInBGArenas + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE)
{ {

View file

@ -45,5 +45,3 @@ void WorldLog::Initialize()
i_file = fopen((logsDir+logname).c_str(), "w"); i_file = fopen((logsDir+logname).c_str(), "w");
} }
} }
#define sWorldLog WorldLog::Instance()

View file

@ -879,14 +879,14 @@ bool AuthSocket::_HandleRealmList()
delete result; delete result;
///- Update realm list if need ///- 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) ///- Circle through realms in the RealmList and construct the return packet (including # of user characters in each realm)
ByteBuffer pkt; ByteBuffer pkt;
pkt << (uint32) 0; pkt << (uint32) 0;
pkt << (uint16) RealmList::Instance().size(); pkt << (uint16) sRealmList.size();
RealmList::RealmMap::const_iterator i; 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; uint8 AmountOfCharacters;

View file

@ -190,8 +190,8 @@ extern int main(int argc, char **argv)
return 1; return 1;
///- Get the list of realms for the server ///- Get the list of realms for the server
RealmList::Instance().Initialize(sConfig.GetIntDefault("RealmsStateUpdateDelay", 20)); sRealmList.Initialize(sConfig.GetIntDefault("RealmsStateUpdateDelay", 20));
if (RealmList::Instance().size() == 0) if (sRealmList.size() == 0)
{ {
sLog.outError("No valid realms specified."); sLog.outError("No valid realms specified.");
return 1; return 1;

View file

@ -33,7 +33,7 @@ RealmList::RealmList( ) : m_UpdateInterval(0), m_NextUpdateTime(time(NULL))
{ {
} }
RealmList& RealmList::Instance() RealmList& sRealmList
{ {
static RealmList realmlist; static RealmList realmlist;
return realmlist; return realmlist;

View file

@ -64,5 +64,7 @@ class RealmList
time_t m_NextUpdateTime; time_t m_NextUpdateTime;
}; };
#define sRealmList RealmList::Instance()
#endif #endif
/// @} /// @}

View file

@ -767,7 +767,7 @@ void outstring_log(const char * str, ...)
vsnprintf(buf,256, str, ap); vsnprintf(buf,256, str, ap);
va_end(ap); va_end(ap);
MaNGOS::Singleton<Log>::Instance().outString(buf); sLog.outString(buf);
} }
void detail_log(const char * str, ...) void detail_log(const char * str, ...)
@ -781,7 +781,7 @@ void detail_log(const char * str, ...)
vsnprintf(buf,256, str, ap); vsnprintf(buf,256, str, ap);
va_end(ap); va_end(ap);
MaNGOS::Singleton<Log>::Instance().outDetail(buf); sLog.outDetail(buf);
} }
void debug_log(const char * str, ...) void debug_log(const char * str, ...)
@ -795,7 +795,7 @@ void debug_log(const char * str, ...)
vsnprintf(buf,256, str, ap); vsnprintf(buf,256, str, ap);
va_end(ap); va_end(ap);
MaNGOS::Singleton<Log>::Instance().outDebug(buf); sLog.outDebug(buf);
} }
void error_log(const char * str, ...) void error_log(const char * str, ...)
@ -809,7 +809,7 @@ void error_log(const char * str, ...)
vsnprintf(buf,256, str, ap); vsnprintf(buf,256, str, ap);
va_end(ap); va_end(ap);
MaNGOS::Singleton<Log>::Instance().outError(buf); sLog.outError(buf);
} }
void error_db_log(const char * str, ...) void error_db_log(const char * str, ...)
@ -823,5 +823,5 @@ void error_db_log(const char * str, ...)
vsnprintf(buf,256, str, ap); vsnprintf(buf,256, str, ap);
va_end(ap); va_end(ap);
MaNGOS::Singleton<Log>::Instance().outErrorDb(buf); sLog.outErrorDb(buf);
} }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "8792" #define REVISION_NR "8793"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__