mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Eluna remove crash possibility of using ReloadEluna global function on returning hooks, restrict the use of the reload command
This commit is contained in:
@@ -421,7 +421,7 @@ namespace LuaGlobalFunctions
|
||||
|
||||
int ReloadEluna(lua_State* L)
|
||||
{
|
||||
Eluna::ReloadEluna();
|
||||
Eluna::reload = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
13
HookMgr.cpp
13
HookMgr.cpp
@@ -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,6 +464,8 @@ bool Eluna::OnRemove(Player* pPlayer, Item* item)
|
||||
bool Eluna::OnCommand(Player* player, const char* text)
|
||||
{
|
||||
std::string fullcmd(text);
|
||||
if (player->GetSession()->GetSecurity() >= SEC_ADMINISTRATOR)
|
||||
{
|
||||
char* creload = strtok((char*)text, " ");
|
||||
char* celuna = strtok(NULL, "");
|
||||
if (creload && celuna)
|
||||
@@ -470,12 +478,13 @@ bool Eluna::OnCommand(Player* player, const char* text)
|
||||
std::transform(eluna.begin(), eluna.end(), eluna.begin(), ::tolower);
|
||||
if (std::string("eluna").find(eluna) == 0)
|
||||
{
|
||||
eWorld->SendServerMessage(SERVER_MSG_STRING, "Reloading Eluna...");
|
||||
ReloadEluna();
|
||||
Eluna::reload = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool result = true;
|
||||
EVENT_BEGIN(PlayerEventBindings, PLAYER_EVENT_ON_COMMAND, return result);
|
||||
Push(L, player);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
Eluna::ScriptPaths Eluna::scripts;
|
||||
Eluna* Eluna::GEluna = NULL;
|
||||
bool Eluna::reload = false;
|
||||
|
||||
extern void RegisterFunctions(lua_State* L);
|
||||
|
||||
@@ -45,8 +46,11 @@ void Eluna::Uninitialize()
|
||||
|
||||
void Eluna::ReloadEluna()
|
||||
{
|
||||
eWorld->SendServerMessage(SERVER_MSG_STRING, "Reloading Eluna...");
|
||||
Uninitialize();
|
||||
Initialize();
|
||||
|
||||
reload = false;
|
||||
}
|
||||
|
||||
Eluna::Eluna():
|
||||
|
||||
@@ -353,6 +353,7 @@ public:
|
||||
typedef std::set<std::string> ScriptPaths;
|
||||
|
||||
static Eluna* GEluna;
|
||||
static bool reload;
|
||||
|
||||
lua_State* L;
|
||||
int userdata_table;
|
||||
@@ -380,6 +381,8 @@ public:
|
||||
static ScriptPaths scripts;
|
||||
static void Initialize();
|
||||
static void Uninitialize();
|
||||
// Use Eluna::reload = true; instead.
|
||||
// This will be called on next update
|
||||
static void ReloadEluna();
|
||||
void static GetScripts(std::string path, ScriptPaths& scripts);
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ void RegisterGlobals(lua_State* L)
|
||||
lua_register(L, "GetMapById", &LuaGlobalFunctions::GetMapById); // GetMapById(mapId, instance) - Returns map object of id specified. UNDOCUMENTED
|
||||
|
||||
// Other
|
||||
lua_register(L, "ReloadEluna", &LuaGlobalFunctions::ReloadEluna); // ReloadEluna() - Reload's Eluna engine.
|
||||
lua_register(L, "ReloadEluna", &LuaGlobalFunctions::ReloadEluna); // ReloadEluna() - Reload's Eluna engine. Warning! Reloading should be used only for testing.
|
||||
lua_register(L, "SendWorldMessage", &LuaGlobalFunctions::SendWorldMessage); // SendWorldMessage(msg) - Sends a broadcast message to everyone
|
||||
lua_register(L, "WorldDBQuery", &LuaGlobalFunctions::WorldDBQuery); // WorldDBQuery(sql) - Executes given SQL query to world database instantly and returns a QueryResult object
|
||||
lua_register(L, "WorldDBExecute", &LuaGlobalFunctions::WorldDBExecute); // WorldDBExecute(sql) - Executes given SQL query to world database (not instant)
|
||||
|
||||
Reference in New Issue
Block a user