Eluna remove crash possibility of using ReloadEluna global function on returning hooks, restrict the use of the reload command

This commit is contained in:
Rochet2
2014-06-10 23:31:57 +03:00
committed by Foereaper
parent 37a0161f29
commit 45c5c876dd
5 changed files with 30 additions and 14 deletions

View File

@@ -304,6 +304,12 @@ void Eluna::OnShutdownCancel()
void Eluna::OnWorldUpdate(uint32 diff)
{
if (reload)
{
ReloadEluna();
return;
}
m_EventMgr->Update(diff);
EVENT_BEGIN(ServerEventBindings, WORLD_EVENT_ON_UPDATE, return);
Push(L, diff);
@@ -458,24 +464,27 @@ bool Eluna::OnRemove(Player* pPlayer, Item* item)
bool Eluna::OnCommand(Player* player, const char* text)
{
std::string fullcmd(text);
char* creload = strtok((char*)text, " ");
char* celuna = strtok(NULL, "");
if (creload && celuna)
if (player->GetSession()->GetSecurity() >= SEC_ADMINISTRATOR)
{
std::string reload(creload);
std::string eluna(celuna);
std::transform(reload.begin(), reload.end(), reload.begin(), ::tolower);
if (reload == "reload")
char* creload = strtok((char*)text, " ");
char* celuna = strtok(NULL, "");
if (creload && celuna)
{
std::transform(eluna.begin(), eluna.end(), eluna.begin(), ::tolower);
if (std::string("eluna").find(eluna) == 0)
std::string reload(creload);
std::string eluna(celuna);
std::transform(reload.begin(), reload.end(), reload.begin(), ::tolower);
if (reload == "reload")
{
eWorld->SendServerMessage(SERVER_MSG_STRING, "Reloading Eluna...");
ReloadEluna();
return false;
std::transform(eluna.begin(), eluna.end(), eluna.begin(), ::tolower);
if (std::string("eluna").find(eluna) == 0)
{
Eluna::reload = true;
return false;
}
}
}
}
bool result = true;
EVENT_BEGIN(PlayerEventBindings, PLAYER_EVENT_ON_COMMAND, return result);
Push(L, player);