Merge branch 'master' of github.com:TrinityCore/TrinityCore into 4.3.4

Conflicts:
	src/server/game/World/World.cpp
	src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp
	src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp
This commit is contained in:
Vincent-Michael
2013-07-15 18:04:04 +02:00
29 changed files with 525 additions and 492 deletions
+11 -11
View File
@@ -96,7 +96,7 @@ extern int main(int argc, char **argv)
++c;
}
if (!ConfigMgr::Load(cfg_file))
if (!sConfigMgr->LoadInitial(cfg_file))
{
printf("Invalid or missing configuration file : %s\n", cfg_file);
printf("Verify that the file exists and has \'[authserver]\' written in the top of the file!\n");
@@ -118,7 +118,7 @@ extern int main(int argc, char **argv)
TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "Max allowed open files is %d", ACE::max_handles());
// authserver PID file creation
std::string pidfile = ConfigMgr::GetStringDefault("PidFile", "");
std::string pidfile = sConfigMgr->GetStringDefault("PidFile", "");
if (!pidfile.empty())
{
uint32 pid = CreatePIDFile(pidfile);
@@ -135,7 +135,7 @@ extern int main(int argc, char **argv)
return 1;
// Get the list of realms for the server
sRealmList->Initialize(ConfigMgr::GetIntDefault("RealmsStateUpdateDelay", 20));
sRealmList->Initialize(sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 20));
if (sRealmList->size() == 0)
{
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "No valid realms specified.");
@@ -145,14 +145,14 @@ extern int main(int argc, char **argv)
// Launch the listening network socket
RealmAcceptor acceptor;
int32 rmport = ConfigMgr::GetIntDefault("RealmServerPort", 3724);
int32 rmport = sConfigMgr->GetIntDefault("RealmServerPort", 3724);
if (rmport < 0 || rmport > 0xFFFF)
{
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Specified port out of allowed range (1-65535)");
return 1;
}
std::string bind_ip = ConfigMgr::GetStringDefault("BindIP", "0.0.0.0");
std::string bind_ip = sConfigMgr->GetStringDefault("BindIP", "0.0.0.0");
ACE_INET_Addr bind_addr(uint16(rmport), bind_ip.c_str());
@@ -175,7 +175,7 @@ extern int main(int argc, char **argv)
{
HANDLE hProcess = GetCurrentProcess();
uint32 Aff = ConfigMgr::GetIntDefault("UseProcessors", 0);
uint32 Aff = sConfigMgr->GetIntDefault("UseProcessors", 0);
if (Aff > 0)
{
ULONG_PTR appAff;
@@ -195,7 +195,7 @@ extern int main(int argc, char **argv)
}
bool Prio = ConfigMgr::GetBoolDefault("ProcessPriority", false);
bool Prio = sConfigMgr->GetBoolDefault("ProcessPriority", false);
if (Prio)
{
@@ -209,7 +209,7 @@ extern int main(int argc, char **argv)
#endif
// maximum counter for next ping
uint32 numLoops = (ConfigMgr::GetIntDefault("MaxPingTime", 30) * (MINUTE * 1000000 / 100000));
uint32 numLoops = (sConfigMgr->GetIntDefault("MaxPingTime", 30) * (MINUTE * 1000000 / 100000));
uint32 loopCounter = 0;
// Wait for termination signal
@@ -241,21 +241,21 @@ bool StartDB()
{
MySQL::Library_Init();
std::string dbstring = ConfigMgr::GetStringDefault("LoginDatabaseInfo", "");
std::string dbstring = sConfigMgr->GetStringDefault("LoginDatabaseInfo", "");
if (dbstring.empty())
{
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Database not specified");
return false;
}
int32 worker_threads = ConfigMgr::GetIntDefault("LoginDatabase.WorkerThreads", 1);
int32 worker_threads = sConfigMgr->GetIntDefault("LoginDatabase.WorkerThreads", 1);
if (worker_threads < 1 || worker_threads > 32)
{
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Improper value specified for LoginDatabase.WorkerThreads, defaulting to 1.");
worker_threads = 1;
}
int32 synch_threads = ConfigMgr::GetIntDefault("LoginDatabase.SynchThreads", 1);
int32 synch_threads = sConfigMgr->GetIntDefault("LoginDatabase.SynchThreads", 1);
if (synch_threads < 1 || synch_threads > 32)
{
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Improper value specified for LoginDatabase.SynchThreads, defaulting to 1.");
+3 -3
View File
@@ -682,7 +682,7 @@ bool AuthSocket::_HandleLogonProof()
TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "'%s:%d' [AuthChallenge] account %s tried to login with invalid password!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
uint32 MaxWrongPassCount = ConfigMgr::GetIntDefault("WrongPass.MaxCount", 0);
uint32 MaxWrongPassCount = sConfigMgr->GetIntDefault("WrongPass.MaxCount", 0);
if (MaxWrongPassCount > 0)
{
//Increment number of failed logins by one and if it reaches the limit temporarily ban that account or IP
@@ -699,8 +699,8 @@ bool AuthSocket::_HandleLogonProof()
if (failed_logins >= MaxWrongPassCount)
{
uint32 WrongPassBanTime = ConfigMgr::GetIntDefault("WrongPass.BanTime", 600);
bool WrongPassBanType = ConfigMgr::GetBoolDefault("WrongPass.BanType", false);
uint32 WrongPassBanTime = sConfigMgr->GetIntDefault("WrongPass.BanTime", 600);
bool WrongPassBanType = sConfigMgr->GetBoolDefault("WrongPass.BanType", false);
if (WrongPassBanType)
{
+2 -2
View File
@@ -439,7 +439,7 @@ void AccountMgr::LoadRBAC()
TC_LOG_DEBUG(LOG_FILTER_RBAC, "AccountMgr::LoadRBAC: Loading default groups");
// Load default groups to be added to any RBAC Object.
std::string defaultGroups = ConfigMgr::GetStringDefault("RBAC.DefaultGroups", "");
std::string defaultGroups = sConfigMgr->GetStringDefault("RBAC.DefaultGroups", "");
Tokenizer tokens(defaultGroups, ',');
for (Tokenizer::const_iterator itr = tokens.begin(); itr != tokens.end(); ++itr)
if (uint32 groupId = atoi(*itr))
@@ -448,7 +448,7 @@ void AccountMgr::LoadRBAC()
void AccountMgr::UpdateAccountAccess(RBACData* rbac, uint32 accountId, uint8 securityLevel, int32 realmId)
{
int32 serverRealmId = realmId != -1 ? realmId : ConfigMgr::GetIntDefault("RealmID", 0);
int32 serverRealmId = realmId != -1 ? realmId : sConfigMgr->GetIntDefault("RealmID", 0);
bool needDelete = false;
if (!rbac)
{
@@ -1630,7 +1630,7 @@ struct WintergraspWorkshopData
// Found associate graveyard and update it
if (m_Type < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
if (m_WG && m_WG->GetGraveyardById(m_Type))
if (m_WG->GetGraveyardById(m_Type))
m_WG->GetGraveyardById(m_Type)->GiveControlTo(TEAM_ALLIANCE);
m_TeamControl = team;
@@ -1668,7 +1668,7 @@ struct WintergraspWorkshopData
// Update graveyard control
if (m_Type < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
if (m_WG && m_WG->GetGraveyardById(m_Type))
if (m_WG->GetGraveyardById(m_Type))
m_WG->GetGraveyardById(m_Type)->GiveControlTo(TEAM_HORDE);
m_TeamControl = team;
+1 -1
View File
@@ -2539,7 +2539,7 @@ bool Guild::Validate()
_SetLeaderGUID(pLeader);
// Check config if multiple guildmasters are allowed
if (!ConfigMgr::GetBoolDefault("Guild.AllowMultipleGuildMaster", 0))
if (!sConfigMgr->GetBoolDefault("Guild.AllowMultipleGuildMaster", 0))
for (Members::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
if (itr->second->GetRankId() == GR_GUILDMASTER && !itr->second->IsSamePlayer(m_leaderGuid))
itr->second->ChangeRank(GR_OFFICER);
@@ -35,13 +35,13 @@ PacketLog::~PacketLog()
void PacketLog::Initialize()
{
std::string logsDir = ConfigMgr::GetStringDefault("LogsDir", "");
std::string logsDir = sConfigMgr->GetStringDefault("LogsDir", "");
if (!logsDir.empty())
if ((logsDir.at(logsDir.length()-1) != '/') && (logsDir.at(logsDir.length()-1) != '\\'))
logsDir.push_back('/');
std::string logname = ConfigMgr::GetStringDefault("PacketLogFile", "");
std::string logname = sConfigMgr->GetStringDefault("PacketLogFile", "");
if (!logname.empty())
_file = fopen((logsDir + logname).c_str(), "wb");
}
+4 -4
View File
@@ -230,9 +230,9 @@ WorldSocketMgr::~WorldSocketMgr()
int
WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address)
{
m_UseNoDelay = ConfigMgr::GetBoolDefault ("Network.TcpNodelay", true);
m_UseNoDelay = sConfigMgr->GetBoolDefault ("Network.TcpNodelay", true);
int num_threads = ConfigMgr::GetIntDefault ("Network.Threads", 1);
int num_threads = sConfigMgr->GetIntDefault ("Network.Threads", 1);
if (num_threads <= 0)
{
@@ -247,9 +247,9 @@ WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address)
TC_LOG_DEBUG(LOG_FILTER_GENERAL, "Max allowed socket connections %d", ACE::max_handles());
// -1 means use default
m_SockOutKBuff = ConfigMgr::GetIntDefault ("Network.OutKBuff", -1);
m_SockOutKBuff = sConfigMgr->GetIntDefault ("Network.OutKBuff", -1);
m_SockOutUBuff = ConfigMgr::GetIntDefault ("Network.OutUBuff", 65536);
m_SockOutUBuff = sConfigMgr->GetIntDefault ("Network.OutUBuff", 65536);
if (m_SockOutUBuff <= 0)
{
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -281,7 +281,7 @@ public:
if (name.empty())
continue;
char const* activeStr = target && target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->bit_index
char const* activeStr = target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->bit_index
? handler->GetTrinityString(LANG_ACTIVE)
: "";
+1 -1
View File
@@ -153,7 +153,7 @@ public:
sWorld->SetPlayerSecurityLimit(SEC_ADMINISTRATOR);
else if (strncmp(paramStr, "reset", limit) == 0)
{
sWorld->SetPlayerAmountLimit(ConfigMgr::GetIntDefault("PlayerLimit", 100));
sWorld->SetPlayerAmountLimit(sConfigMgr->GetIntDefault("PlayerLimit", 100));
sWorld->LoadDBAllowedSecurityLevel();
}
else
@@ -246,23 +246,29 @@ class instance_stratholme : public InstanceMapScript
case TYPE_BARONESS:
EncounterState[1] = data;
if (data == IN_PROGRESS)
{
HandleGameObject(ziggurat1GUID, true);
if (data == IN_PROGRESS) //change to DONE when crystals implemented
//change to DONE when crystals implemented
StartSlaugtherSquare();
}
break;
case TYPE_NERUB:
EncounterState[2] = data;
if (data == IN_PROGRESS)
{
HandleGameObject(ziggurat2GUID, true);
if (data == IN_PROGRESS) //change to DONE when crystals implemented
//change to DONE when crystals implemented
StartSlaugtherSquare();
}
break;
case TYPE_PALLID:
EncounterState[3] = data;
if (data == IN_PROGRESS)
{
HandleGameObject(ziggurat3GUID, true);
if (data == IN_PROGRESS) //change to DONE when crystals implemented
//change to DONE when crystals implemented
StartSlaugtherSquare();
}
break;
case TYPE_RAMSTEIN:
if (data == IN_PROGRESS)
@@ -556,8 +556,8 @@ public:
if (i->GetSource() && i->GetSource()->GetPositionZ() < DEMON_REALM_Z + 5)
++SpectralPlayers;
}
uint8 MaxSpectralPlayers = MAX_PLAYERS_IN_SPECTRAL_REALM;
if (player->HasAura(AURA_SPECTRAL_EXHAUSTION) || (MaxSpectralPlayers && SpectralPlayers >= MaxSpectralPlayers))
if (player->HasAura(AURA_SPECTRAL_EXHAUSTION) || SpectralPlayers >= MAX_PLAYERS_IN_SPECTRAL_REALM)
player->GetSession()->SendNotification(GO_FAILED);
else
player->CastSpell(player, SPELL_TELEPORT_SPECTRAL, true);
@@ -318,7 +318,8 @@ class boss_lich_king_toc : public CreatureScript
_instance->SetData(TYPE_EVENT, 5080);
break;
case 5080:
if (GameObject* go = _instance->instance->GetGameObject(_instance->GetData64(GO_ARGENT_COLISEUM_FLOOR)))
{
if (GameObject* go = GameObject::GetGameObject(*me, _instance->GetData64(GO_ARGENT_COLISEUM_FLOOR)))
{
go->SetDisplayId(DISPLAYID_DESTROYED_FLOOR);
go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED | GO_FLAG_NODESPAWN);
@@ -328,18 +329,17 @@ class boss_lich_king_toc : public CreatureScript
me->CastSpell(me, SPELL_CORPSE_TELEPORT, false);
me->CastSpell(me, SPELL_DESTROY_FLOOR_KNOCKUP, false);
if (_instance)
{
_instance->SetBossState(BOSS_LICH_KING, DONE);
Creature* temp = Unit::GetCreature(*me, _instance->GetData64(NPC_ANUBARAK));
if (!temp || !temp->IsAlive())
temp = me->SummonCreature(NPC_ANUBARAK, AnubarakLoc[0].GetPositionX(), AnubarakLoc[0].GetPositionY(), AnubarakLoc[0].GetPositionZ(), 3, TEMPSUMMON_CORPSE_TIMED_DESPAWN, DESPAWN_TIME);
_instance->SetBossState(BOSS_LICH_KING, DONE);
Creature* temp = Unit::GetCreature(*me, _instance->GetData64(NPC_ANUBARAK));
if (!temp || !temp->IsAlive())
temp = me->SummonCreature(NPC_ANUBARAK, AnubarakLoc[0].GetPositionX(), AnubarakLoc[0].GetPositionY(), AnubarakLoc[0].GetPositionZ(), 3, TEMPSUMMON_CORPSE_TIMED_DESPAWN, DESPAWN_TIME);
_instance->SetData(TYPE_EVENT, 0);
_instance->SetData(TYPE_EVENT, 0);
}
me->DespawnOrUnsummon();
_updateTimer = 20*IN_MILLISECONDS;
break;
}
default:
break;
}
@@ -354,9 +354,7 @@ public:
void MovementInform(uint32 type, uint32 id) OVERRIDE
{
if (type == POINT_MOTION_TYPE && id == 0)
{
me->SetDisableGravity(false); // Needed this for proper animation after spawn, the summon in air fall to ground bug leave no other option for now, if this isn't used the drake will only walk on move.
}
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -388,9 +386,7 @@ public:
}
else WelcomeSequelTimer -= diff;
}
}
if (me->HasAuraType(SPELL_AURA_CONTROL_VEHICLE))
{
if (instance->GetBossState(DATA_UROM_EVENT) == DONE)
{
if (!(SpecialOff))
@@ -403,9 +399,7 @@ public:
else SpecialTimer -= diff;
}
}
}
if (me->HasAuraType(SPELL_AURA_CONTROL_VEHICLE))
{
if (!(HealthWarningOff))
{
if (me->GetHealthPct() <= 40.0f)
@@ -414,9 +408,7 @@ public:
HealthWarningOff = true;
}
}
}
if (me->HasAuraType(SPELL_AURA_CONTROL_VEHICLE))
{
if (HealthWarningOff)
{
if (WarningTimer <= diff)
@@ -427,6 +419,7 @@ public:
else WarningTimer -= diff;
}
}
if (!(me->HasAuraType(SPELL_AURA_CONTROL_VEHICLE)))
{
if (!(DisableTakeOff))
@@ -234,7 +234,9 @@ public:
{
if (currentPhase == PHASE_NONE)
{
instance->SetData(DATA_GORTOK_PALEHOOF_EVENT, IN_PROGRESS);
if (instance)
instance->SetData(DATA_GORTOK_PALEHOOF_EVENT, IN_PROGRESS);
me->SummonCreature(NPC_STASIS_CONTROLLER, moveLocs[5].x, moveLocs[5].y, moveLocs[5].z, 0, TEMPSUMMON_CORPSE_DESPAWN);
}
Phase move = PHASE_NONE;
@@ -72,7 +72,7 @@ enum Spells
// Ashtongue Spiritbinder
SPELL_SPIRIT_MEND = 42025,
SPELL_CHAIN_HEAL = 42027,
SPELL_SPIRIT_HEAL = 42317
SPELL_SPIRITBINDER_SPIRIT_HEAL = 42317
};
enum Creatures
@@ -1189,7 +1189,7 @@ public:
switch (eventId)
{
case EVENT_SPIRIT_HEAL:
DoCast(me, SPELL_SPIRIT_HEAL);
DoCast(me, SPELL_SPIRITBINDER_SPIRIT_HEAL);
events.ScheduleEvent(EVENT_SPIRIT_HEAL, urand (13000, 16000));
break;
default:
@@ -113,7 +113,7 @@ class boss_grand_warlock_nethekurse : public CreatureScript
instance->SetBossState(DATA_NETHEKURSE, DONE);
}
void SetData(uint32 data, uint32 value)
void SetData(uint32 data, uint32 value) OVERRIDE
{
if (data != SETDATA_DATA)
return;
@@ -340,9 +340,9 @@ class npc_fel_orc_convert : public CreatureScript
{
if (instance->GetBossState(DATA_NETHEKURSE) != IN_PROGRESS)
return;
if (instance->GetData64(NPC_GRAND_WARLOCK_NETHEKURSE))
if (Creature* Kurse = Unit::GetCreature(*me, instance->GetData64(NPC_GRAND_WARLOCK_NETHEKURSE)))
Kurse->AI()->SetData(SETDATA_DATA, SETDATA_PEON_DEATH);
if (Creature* Kurse = Unit::GetCreature(*me, instance->GetData64(NPC_GRAND_WARLOCK_NETHEKURSE)))
Kurse->AI()->SetData(SETDATA_DATA, SETDATA_PEON_DEATH);
}
}
@@ -404,4 +404,3 @@ void AddSC_boss_grand_warlock_nethekurse()
new npc_fel_orc_convert();
new npc_lesser_shadow_fissure();
}
@@ -447,4 +447,3 @@ void AddSC_boss_warbringer_omrogg()
new boss_warbringer_omrogg();
new npc_omrogg_heads();
}
@@ -319,4 +319,3 @@ void AddSC_boss_warchief_kargath_bladefist()
{
new boss_warchief_kargath_bladefist();
}
@@ -49,7 +49,7 @@ class instance_shattered_halls : public InstanceMapScript
nethekurseDoor2GUID = 0;
}
void OnGameObjectCreate(GameObject* go)
void OnGameObjectCreate(GameObject* go) OVERRIDE
{
switch (go->GetEntry())
{
@@ -62,7 +62,7 @@ class instance_shattered_halls : public InstanceMapScript
}
}
void OnCreatureCreate(Creature* creature)
void OnCreatureCreate(Creature* creature) OVERRIDE
{
switch (creature->GetEntry())
{
@@ -72,7 +72,7 @@ class instance_shattered_halls : public InstanceMapScript
}
}
bool SetBossState(uint32 type, EncounterState state)
bool SetBossState(uint32 type, EncounterState state) OVERRIDE
{
if (!InstanceScript::SetBossState(type, state))
return false;
@@ -168,4 +168,3 @@ void AddSC_instance_shattered_halls()
{
new instance_shattered_halls();
}
@@ -75,11 +75,8 @@ enum WaitEventType
class boss_alar : public CreatureScript
{
public:
boss_alar() : CreatureScript("boss_alar") { }
boss_alar()
: CreatureScript("boss_alar")
{
}
struct boss_alarAI : public ScriptedAI
{
boss_alarAI(Creature* creature) : ScriptedAI(creature)
@@ -162,7 +159,6 @@ class boss_alar : public CreatureScript
void MoveInLineOfSight(Unit* /*who*/) OVERRIDE {}
void AttackStart(Unit* who) OVERRIDE
{
if (Phase1)
@@ -462,11 +458,7 @@ class boss_alar : public CreatureScript
class npc_ember_of_alar : public CreatureScript
{
public:
npc_ember_of_alar()
: CreatureScript("npc_ember_of_alar")
{
}
npc_ember_of_alar() : CreatureScript("npc_ember_of_alar") { }
struct npc_ember_of_alarAI : public ScriptedAI
{
@@ -484,10 +476,12 @@ class npc_ember_of_alar : public CreatureScript
{
toDie = false;
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
DoZoneInCombat();
}
void EnterEvadeMode() OVERRIDE
{
me->setDeathState(JUST_DIED);
@@ -541,11 +535,7 @@ class npc_ember_of_alar : public CreatureScript
class npc_flame_patch_alar : public CreatureScript
{
public:
npc_flame_patch_alar()
: CreatureScript("npc_flame_patch_alar")
{
}
npc_flame_patch_alar() : CreatureScript("npc_flame_patch_alar") { }
struct npc_flame_patch_alarAI : public ScriptedAI
{
@@ -570,4 +560,3 @@ void AddSC_boss_alar()
new npc_ember_of_alar();
new npc_flame_patch_alar();
}
+56 -51
View File
@@ -17,72 +17,79 @@
*/
#include "Config.h"
#include <ace/Auto_Ptr.h>
#include <ace/Configuration_Import_Export.h>
#include <ace/Thread_Mutex.h>
#include "Errors.h"
namespace ConfigMgr
// Defined here as it must not be exposed to end-users.
bool ConfigMgr::GetValueHelper(const char* name, ACE_TString &result)
{
GuardType guard(_configLock);
namespace
{
typedef ACE_Thread_Mutex LockType;
typedef ACE_Guard<LockType> GuardType;
std::string _filename;
ACE_Auto_Ptr<ACE_Configuration_Heap> _config;
LockType m_configLock;
// Defined here as it must not be exposed to end-users.
bool GetValueHelper(const char* name, ACE_TString &result)
{
GuardType guard(m_configLock);
if (_config.get() == 0)
return false;
ACE_TString section_name;
ACE_Configuration_Section_Key section_key;
const ACE_Configuration_Section_Key &root_key = _config->root_section();
int i = 0;
while (_config->enumerate_sections(root_key, i, section_name) == 0)
{
_config->open_section(root_key, section_name.c_str(), 0, section_key);
if (_config->get_string_value(section_key, name, result) == 0)
return true;
++i;
}
if (_config.get() == 0)
return false;
ACE_TString section_name;
ACE_Configuration_Section_Key section_key;
const ACE_Configuration_Section_Key &root_key = _config->root_section();
int i = 0;
while (_config->enumerate_sections(root_key, i, section_name) == 0)
{
_config->open_section(root_key, section_name.c_str(), 0, section_key);
if (_config->get_string_value(section_key, name, result) == 0)
return true;
++i;
}
return false;
}
bool Load(const char* file)
bool ConfigMgr::LoadInitial(char const* file)
{
GuardType guard(m_configLock);
ASSERT(file);
if (file)
_filename = file;
GuardType guard(_configLock);
_config.reset(new ACE_Configuration_Heap);
_filename = file;
_config.reset(new ACE_Configuration_Heap());
if (_config->open() == 0)
{
ACE_Ini_ImpExp config_importer(*_config.get());
if (config_importer.import_config(_filename.c_str()) == 0)
if (LoadData(_filename.c_str()))
return true;
}
_config.reset();
return false;
}
std::string GetStringDefault(const char* name, const std::string &def)
bool ConfigMgr::LoadMore(char const* file)
{
ASSERT(file);
ASSERT(_config);
GuardType guard(_configLock);
return LoadData(file);
}
bool ConfigMgr::Reload()
{
return LoadInitial(_filename.c_str());
}
bool ConfigMgr::LoadData(char const* file)
{
ACE_Ini_ImpExp config_importer(*_config.get());
if (config_importer.import_config(file) == 0)
return true;
return false;
}
std::string ConfigMgr::GetStringDefault(const char* name, const std::string &def)
{
ACE_TString val;
return GetValueHelper(name, val) ? val.c_str() : def;
}
bool GetBoolDefault(const char* name, bool def)
bool ConfigMgr::GetBoolDefault(const char* name, bool def)
{
ACE_TString val;
@@ -93,22 +100,20 @@ bool GetBoolDefault(const char* name, bool def)
val == "1");
}
int GetIntDefault(const char* name, int def)
int ConfigMgr::GetIntDefault(const char* name, int def)
{
ACE_TString val;
return GetValueHelper(name, val) ? atoi(val.c_str()) : def;
}
float GetFloatDefault(const char* name, float def)
float ConfigMgr::GetFloatDefault(const char* name, float def)
{
ACE_TString val;
return GetValueHelper(name, val) ? (float)atof(val.c_str()) : def;
}
const std::string & GetFilename()
std::string const& ConfigMgr::GetFilename()
{
GuardType guard(m_configLock);
GuardType guard(_configLock);
return _filename;
}
} // namespace
+45 -4
View File
@@ -20,17 +20,58 @@
#define CONFIG_H
#include <string>
#include <map>
#include <ace/Singleton.h>
#include <ace/Configuration_Import_Export.h>
#include <ace/Thread_Mutex.h>
#include <AutoPtr.h>
namespace ConfigMgr
typedef Trinity::AutoPtr<ACE_Configuration_Heap, ACE_Null_Mutex> Config;
class ConfigMgr
{
bool Load(const char *file = NULL);
friend class ACE_Singleton<ConfigMgr, ACE_Null_Mutex>;
friend class ConfigLoader;
ConfigMgr() { }
~ConfigMgr() { }
public:
/// Method used only for loading main configuration files (authserver.conf and worldserver.conf)
bool LoadInitial(char const* file);
/**
* This method loads additional configuration files
* It is recommended to use this method in WorldScript::OnConfigLoad hooks
*
* @return true if loading was successful
*/
bool LoadMore(char const* file);
bool Reload();
std::string GetStringDefault(const char* name, const std::string& def);
bool GetBoolDefault(const char* name, bool def);
int GetIntDefault(const char* name, int def);
float GetFloatDefault(const char* name, float def);
const std::string & GetFilename();
}
std::string const& GetFilename();
private:
bool GetValueHelper(const char* name, ACE_TString &result);
bool LoadData(char const* file);
typedef ACE_Thread_Mutex LockType;
typedef ACE_Guard<LockType> GuardType;
std::string _filename;
Config _config;
LockType _configLock;
ConfigMgr(ConfigMgr const&);
ConfigMgr& operator=(ConfigMgr const&);
};
#define sConfigMgr ACE_Singleton<ConfigMgr, ACE_Null_Mutex>::instance()
#endif
+8 -8
View File
@@ -48,13 +48,13 @@ uint8 Log::NextAppenderId()
int32 GetConfigIntDefault(std::string base, const char* name, int32 value)
{
base.append(name);
return ConfigMgr::GetIntDefault(base.c_str(), value);
return sConfigMgr->GetIntDefault(base.c_str(), value);
}
std::string GetConfigStringDefault(std::string base, const char* name, const char* value)
{
base.append(name);
return ConfigMgr::GetStringDefault(base.c_str(), value);
return sConfigMgr->GetStringDefault(base.c_str(), value);
}
// Returns default logger if the requested logger is not found
@@ -83,7 +83,7 @@ void Log::CreateAppenderFromConfig(const char* name)
// if type = Console. optional1 = Color
std::string options = "Appender.";
options.append(name);
options = ConfigMgr::GetStringDefault(options.c_str(), "");
options = sConfigMgr->GetStringDefault(options.c_str(), "");
Tokenizer tokens(options, ',');
Tokenizer::const_iterator iter = tokens.begin();
uint8 size = tokens.size();
@@ -173,7 +173,7 @@ void Log::CreateLoggerFromConfig(const char* name)
std::string options = "Logger.";
options.append(name);
options = ConfigMgr::GetStringDefault(options.c_str(), "");
options = sConfigMgr->GetStringDefault(options.c_str(), "");
if (options.empty())
{
@@ -235,7 +235,7 @@ void Log::CreateLoggerFromConfig(const char* name)
void Log::ReadAppendersFromConfig()
{
std::istringstream ss(ConfigMgr::GetStringDefault("Appenders", ""));
std::istringstream ss(sConfigMgr->GetStringDefault("Appenders", ""));
std::string name;
do
@@ -249,7 +249,7 @@ void Log::ReadAppendersFromConfig()
void Log::ReadLoggersFromConfig()
{
std::istringstream ss(ConfigMgr::GetStringDefault("Loggers", ""));
std::istringstream ss(sConfigMgr->GetStringDefault("Loggers", ""));
std::string name;
do
@@ -457,11 +457,11 @@ void Log::LoadFromConfig()
{
Close();
if (ConfigMgr::GetBoolDefault("Log.Async.Enable", false))
if (sConfigMgr->GetBoolDefault("Log.Async.Enable", false))
worker = new LogWorker();
AppenderId = 0;
m_logsDir = ConfigMgr::GetStringDefault("LogsDir", "");
m_logsDir = sConfigMgr->GetStringDefault("LogsDir", "");
if (!m_logsDir.empty())
if ((m_logsDir.at(m_logsDir.length() - 1) != '/') && (m_logsDir.at(m_logsDir.length() - 1) != '\\'))
m_logsDir.push_back('/');
@@ -141,7 +141,7 @@ void CliRunnable::run()
rl_event_hook = cli_hook_func;
#endif
if (ConfigMgr::GetBoolDefault("BeepAtStart", true))
if (sConfigMgr->GetBoolDefault("BeepAtStart", true))
printf("\a"); // \a = Alert
// print this here the first time
+1 -1
View File
@@ -129,7 +129,7 @@ extern int main(int argc, char **argv)
++c;
}
if (!ConfigMgr::Load(cfg_file))
if (!sConfigMgr->LoadInitial(cfg_file))
{
printf("Invalid or missing configuration file : %s\n", cfg_file);
printf("Verify that the file exists and has \'[worldserver]' written in the top of the file!\n");
+19 -19
View File
@@ -138,7 +138,7 @@ int Master::Run()
TC_LOG_INFO(LOG_FILTER_WORLDSERVER, "http://TrinityCore.org \\/__/\n");
/// worldserver PID file creation
std::string pidfile = ConfigMgr::GetStringDefault("PidFile", "");
std::string pidfile = sConfigMgr->GetStringDefault("PidFile", "");
if (!pidfile.empty())
{
uint32 pid = CreatePIDFile(pidfile);
@@ -182,9 +182,9 @@ int Master::Run()
ACE_Based::Thread* cliThread = NULL;
#ifdef _WIN32
if (ConfigMgr::GetBoolDefault("Console.Enable", true) && (m_ServiceStatus == -1)/* need disable console in service mode*/)
if (sConfigMgr->GetBoolDefault("Console.Enable", true) && (m_ServiceStatus == -1)/* need disable console in service mode*/)
#else
if (ConfigMgr::GetBoolDefault("Console.Enable", true))
if (sConfigMgr->GetBoolDefault("Console.Enable", true))
#endif
{
///- Launch CliRunnable thread
@@ -198,7 +198,7 @@ int Master::Run()
{
HANDLE hProcess = GetCurrentProcess();
uint32 Aff = ConfigMgr::GetIntDefault("UseProcessors", 0);
uint32 Aff = sConfigMgr->GetIntDefault("UseProcessors", 0);
if (Aff > 0)
{
ULONG_PTR appAff;
@@ -222,7 +222,7 @@ int Master::Run()
}
}
bool Prio = ConfigMgr::GetBoolDefault("ProcessPriority", false);
bool Prio = sConfigMgr->GetBoolDefault("ProcessPriority", false);
//if (Prio && (m_ServiceStatus == -1) /* need set to default process priority class in service mode*/)
if (Prio)
@@ -237,15 +237,15 @@ int Master::Run()
//Start soap serving thread
ACE_Based::Thread* soap_thread = NULL;
if (ConfigMgr::GetBoolDefault("SOAP.Enabled", false))
if (sConfigMgr->GetBoolDefault("SOAP.Enabled", false))
{
TCSoapRunnable* runnable = new TCSoapRunnable();
runnable->setListenArguments(ConfigMgr::GetStringDefault("SOAP.IP", "127.0.0.1"), uint16(ConfigMgr::GetIntDefault("SOAP.Port", 7878)));
runnable->setListenArguments(sConfigMgr->GetStringDefault("SOAP.IP", "127.0.0.1"), uint16(sConfigMgr->GetIntDefault("SOAP.Port", 7878)));
soap_thread = new ACE_Based::Thread(runnable);
}
///- Start up freeze catcher thread
if (uint32 freeze_delay = ConfigMgr::GetIntDefault("MaxCoreStuckTime", 0))
if (uint32 freeze_delay = sConfigMgr->GetIntDefault("MaxCoreStuckTime", 0))
{
FreezeDetectorRunnable* fdr = new FreezeDetectorRunnable();
fdr->SetDelayTime(freeze_delay * 1000);
@@ -255,7 +255,7 @@ int Master::Run()
///- Launch the world listener socket
uint16 wsport = uint16(sWorld->getIntConfig(CONFIG_PORT_WORLD));
std::string bind_ip = ConfigMgr::GetStringDefault("BindIP", "0.0.0.0");
std::string bind_ip = sConfigMgr->GetStringDefault("BindIP", "0.0.0.0");
if (sWorldSocketMgr->StartNetwork(wsport, bind_ip.c_str()) == -1)
{
@@ -357,14 +357,14 @@ bool Master::_StartDB()
std::string dbstring;
uint8 async_threads, synch_threads;
dbstring = ConfigMgr::GetStringDefault("WorldDatabaseInfo", "");
dbstring = sConfigMgr->GetStringDefault("WorldDatabaseInfo", "");
if (dbstring.empty())
{
TC_LOG_ERROR(LOG_FILTER_WORLDSERVER, "World database not specified in configuration file");
return false;
}
async_threads = uint8(ConfigMgr::GetIntDefault("WorldDatabase.WorkerThreads", 1));
async_threads = uint8(sConfigMgr->GetIntDefault("WorldDatabase.WorkerThreads", 1));
if (async_threads < 1 || async_threads > 32)
{
TC_LOG_ERROR(LOG_FILTER_WORLDSERVER, "World database: invalid number of worker threads specified. "
@@ -372,7 +372,7 @@ bool Master::_StartDB()
return false;
}
synch_threads = uint8(ConfigMgr::GetIntDefault("WorldDatabase.SynchThreads", 1));
synch_threads = uint8(sConfigMgr->GetIntDefault("WorldDatabase.SynchThreads", 1));
///- Initialise the world database
if (!WorldDatabase.Open(dbstring, async_threads, synch_threads))
{
@@ -381,14 +381,14 @@ bool Master::_StartDB()
}
///- Get character database info from configuration file
dbstring = ConfigMgr::GetStringDefault("CharacterDatabaseInfo", "");
dbstring = sConfigMgr->GetStringDefault("CharacterDatabaseInfo", "");
if (dbstring.empty())
{
TC_LOG_ERROR(LOG_FILTER_WORLDSERVER, "Character database not specified in configuration file");
return false;
}
async_threads = uint8(ConfigMgr::GetIntDefault("CharacterDatabase.WorkerThreads", 1));
async_threads = uint8(sConfigMgr->GetIntDefault("CharacterDatabase.WorkerThreads", 1));
if (async_threads < 1 || async_threads > 32)
{
TC_LOG_ERROR(LOG_FILTER_WORLDSERVER, "Character database: invalid number of worker threads specified. "
@@ -396,7 +396,7 @@ bool Master::_StartDB()
return false;
}
synch_threads = uint8(ConfigMgr::GetIntDefault("CharacterDatabase.SynchThreads", 2));
synch_threads = uint8(sConfigMgr->GetIntDefault("CharacterDatabase.SynchThreads", 2));
///- Initialise the Character database
if (!CharacterDatabase.Open(dbstring, async_threads, synch_threads))
@@ -406,14 +406,14 @@ bool Master::_StartDB()
}
///- Get login database info from configuration file
dbstring = ConfigMgr::GetStringDefault("LoginDatabaseInfo", "");
dbstring = sConfigMgr->GetStringDefault("LoginDatabaseInfo", "");
if (dbstring.empty())
{
TC_LOG_ERROR(LOG_FILTER_WORLDSERVER, "Login database not specified in configuration file");
return false;
}
async_threads = uint8(ConfigMgr::GetIntDefault("LoginDatabase.WorkerThreads", 1));
async_threads = uint8(sConfigMgr->GetIntDefault("LoginDatabase.WorkerThreads", 1));
if (async_threads < 1 || async_threads > 32)
{
TC_LOG_ERROR(LOG_FILTER_WORLDSERVER, "Login database: invalid number of worker threads specified. "
@@ -421,7 +421,7 @@ bool Master::_StartDB()
return false;
}
synch_threads = uint8(ConfigMgr::GetIntDefault("LoginDatabase.SynchThreads", 1));
synch_threads = uint8(sConfigMgr->GetIntDefault("LoginDatabase.SynchThreads", 1));
///- Initialise the login database
if (!LoginDatabase.Open(dbstring, async_threads, synch_threads))
{
@@ -430,7 +430,7 @@ bool Master::_StartDB()
}
///- Get the realm Id from the configuration file
realmID = ConfigMgr::GetIntDefault("RealmID", 0);
realmID = sConfigMgr->GetIntDefault("RealmID", 0);
if (!realmID)
{
TC_LOG_ERROR(LOG_FILTER_WORLDSERVER, "Realm ID not defined in configuration file");
@@ -56,13 +56,13 @@ RARunnable::~RARunnable()
void RARunnable::run()
{
if (!ConfigMgr::GetBoolDefault("Ra.Enable", false))
if (!sConfigMgr->GetBoolDefault("Ra.Enable", false))
return;
ACE_Acceptor<RASocket, ACE_SOCK_ACCEPTOR> acceptor;
uint16 raport = uint16(ConfigMgr::GetIntDefault("Ra.Port", 3443));
std::string stringip = ConfigMgr::GetStringDefault("Ra.IP", "0.0.0.0");
uint16 raport = uint16(sConfigMgr->GetIntDefault("Ra.Port", 3443));
std::string stringip = sConfigMgr->GetStringDefault("Ra.IP", "0.0.0.0");
ACE_INET_Addr listen_addr(raport, stringip.c_str());
if (acceptor.open(listen_addr, m_Reactor) == -1)
@@ -32,7 +32,7 @@
RASocket::RASocket()
{
_minLevel = uint8(ConfigMgr::GetIntDefault("RA.MinLevel", 3));
_minLevel = uint8(sConfigMgr->GetIntDefault("RA.MinLevel", 3));
_commandExecuting = false;
}