From 9c821527ebec4f4b8f1e1280e5939f820db87ec4 Mon Sep 17 00:00:00 2001 From: Foereaper Date: Sat, 12 Sep 2020 18:05:11 +0200 Subject: [PATCH] Add GetRealmID --- GlobalMethods.h | 18 ++++++++++++++++++ LuaFunctions.cpp | 1 + 2 files changed, 19 insertions(+) diff --git a/GlobalMethods.h b/GlobalMethods.h index 5af4baf..8ac9702 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -51,6 +51,24 @@ namespace LuaGlobalFunctions return 1; } + /** + * Returns emulator .conf RealmID + * + * - for MaNGOS returns the realmID as it is stored in the core. + * - for TrinityCore returns the realmID as it is in the conf file. + * @return uint32 realm ID + */ + + int GetRealmID(lua_State* L) + { +#ifdef MANGOS + Eluna::Push(L, eWorld->GetRealmID()); +#else + Eluna::Push(L, sConfigMgr->GetIntDefault("RealmID", 1)); +#endif + return 1; + } + /** * Returns emulator version * diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index db06749..ed640f8 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -77,6 +77,7 @@ luaL_Reg GlobalMethods[] = // Getters { "GetLuaEngine", &LuaGlobalFunctions::GetLuaEngine }, { "GetCoreName", &LuaGlobalFunctions::GetCoreName }, + { "GetRealmID", &LuaGlobalFunctions::GetRealmID }, { "GetCoreVersion", &LuaGlobalFunctions::GetCoreVersion }, { "GetCoreExpansion", &LuaGlobalFunctions::GetCoreExpansion }, { "GetQuest", &LuaGlobalFunctions::GetQuest },