diff --git a/GlobalMethods.h b/GlobalMethods.h index 70d1d1c..418fd86 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -46,27 +46,27 @@ namespace LuaGlobalFunctions { uint32 questId = Eluna::CHECKVAL(L, 1); - Eluna::Push(L, sObjectMgr->GetQuestTemplate(questId)); + Eluna::Push(L, eObjectMgr->GetQuestTemplate(questId)); return 1; } int GetPlayerByGUID(lua_State* L) { uint64 guid = Eluna::CHECKVAL(L, 1); - Eluna::Push(L, sObjectAccessor->FindPlayer(ObjectGuid(guid))); + Eluna::Push(L, eObjectAccessor->FindPlayer(ObjectGuid(guid))); return 1; } int GetPlayerByName(lua_State* L) { const char* message = Eluna::CHECKVAL(L, 1); - Eluna::Push(L, sObjectAccessor->FindPlayerByName(message)); + Eluna::Push(L, eObjectAccessor->FindPlayerByName(message)); return 1; } int GetGameTime(lua_State* L) { - time_t time = sWorld->GetGameTime(); + time_t time = eWorld->GetGameTime(); if (time < 0) Eluna::Push(L, int32(time)); else @@ -83,7 +83,7 @@ namespace LuaGlobalFunctions int tbl = lua_gettop(L); uint32 i = 0; - SessionMap const& sessions = sWorld->GetAllSessions(); + SessionMap const& sessions = eWorld->GetAllSessions(); for (SessionMap::const_iterator it = sessions.begin(); it != sessions.end(); ++it) { if (Player* player = it->second->GetPlayer()) @@ -112,7 +112,7 @@ namespace LuaGlobalFunctions uint32 instanceID = Eluna::CHECKVAL(L, 2, 0); uint32 team = Eluna::CHECKVAL(L, 3, TEAM_NEUTRAL); - Map* map = sMapMgr->FindMap(mapID, instanceID); + Map* map = eMapMgr->FindMap(mapID, instanceID); if (!map) return 1; @@ -146,7 +146,7 @@ namespace LuaGlobalFunctions int GetGuildByName(lua_State* L) { const char* name = Eluna::CHECKVAL(L, 1); - Eluna::Push(L, sGuildMgr->GetGuildByName(name)); + Eluna::Push(L, eGuildMgr->GetGuildByName(name)); return 1; } @@ -155,7 +155,7 @@ namespace LuaGlobalFunctions uint32 mapid = Eluna::CHECKVAL(L, 1); uint32 instance = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, sMapMgr->FindMap(mapid, instance)); + Eluna::Push(L, eMapMgr->FindMap(mapid, instance)); return 1; } @@ -163,13 +163,13 @@ namespace LuaGlobalFunctions { uint64 guid = Eluna::CHECKVAL(L, 1); - Eluna::Push(L, sGuildMgr->GetGuildByLeader(ObjectGuid(guid))); + Eluna::Push(L, eGuildMgr->GetGuildByLeader(ObjectGuid(guid))); return 1; } int GetPlayerCount(lua_State* L) { - Eluna::Push(L, sWorld->GetActiveSessionCount()); + Eluna::Push(L, eWorld->GetActiveSessionCount()); return 1; } @@ -229,12 +229,12 @@ namespace LuaGlobalFunctions if (loc_idx < 0 || loc_idx >= MAX_LOCALES) return luaL_argerror(L, 2, "valid LocaleConstant expected"); - const ItemTemplate* temp = sObjectMgr->GetItemTemplate(entry); + const ItemTemplate* temp = eObjectMgr->GetItemTemplate(entry); if (!temp) return luaL_argerror(L, 1, "valid ItemEntry expected"); std::string name = temp->Name1; - if (ItemLocale const* il = sObjectMgr->GetItemLocale(entry)) + if (ItemLocale const* il = eObjectMgr->GetItemLocale(entry)) ObjectMgr::GetLocaleString(il->Name, loc_idx, name); std::ostringstream oss; @@ -428,7 +428,7 @@ namespace LuaGlobalFunctions int SendWorldMessage(lua_State* L) { const char* message = Eluna::CHECKVAL(L, 1); - sWorld->SendServerMessage(SERVER_MSG_STRING, message); + eWorld->SendServerMessage(SERVER_MSG_STRING, message); return 0; } @@ -573,7 +573,7 @@ namespace LuaGlobalFunctions #endif #ifdef MANGOS - Map* map = sMapMgr->FindMap(mapID, instanceID); + Map* map = eMapMgr->FindMap(mapID, instanceID); if (!map) return 1; @@ -592,7 +592,7 @@ namespace LuaGlobalFunctions #endif Creature* pCreature = new Creature; // used guids from specially reserved range (can be 0 if no free values) - uint32 lowguid = sObjectMgr->GenerateStaticCreatureLowGuid(); + uint32 lowguid = eObjectMgr->GenerateStaticCreatureLowGuid(); if (!lowguid) return 1; @@ -616,7 +616,7 @@ namespace LuaGlobalFunctions pCreature->LoadFromDB(db_guid, map); map->Add(pCreature); - sObjectMgr->AddCreatureToGrid(db_guid, sObjectMgr->GetCreatureData(db_guid)); + eObjectMgr->AddCreatureToGrid(db_guid, eObjectMgr->GetCreatureData(db_guid)); if (durorresptime) pCreature->ForcedDespawn(durorresptime); @@ -668,7 +668,7 @@ namespace LuaGlobalFunctions return 1; // used guids from specially reserved range (can be 0 if no free values) - uint32 db_lowGUID = sObjectMgr->GenerateStaticGameObjectLowGuid(); + uint32 db_lowGUID = eObjectMgr->GenerateStaticGameObjectLowGuid(); if (!db_lowGUID) return 1; @@ -706,7 +706,7 @@ namespace LuaGlobalFunctions map->Add(pGameObj); - sObjectMgr->AddGameobjectToGrid(db_lowGUID, sObjectMgr->GetGOData(db_lowGUID)); + eObjectMgr->AddGameobjectToGrid(db_lowGUID, eObjectMgr->GetGOData(db_lowGUID)); Eluna::Push(L, pGameObj); } @@ -733,7 +733,7 @@ namespace LuaGlobalFunctions return 1; } #else - Map* map = sMapMgr->FindMap(mapID, instanceID); + Map* map = eMapMgr->FindMap(mapID, instanceID); if (!map) return 1; @@ -744,7 +744,7 @@ namespace LuaGlobalFunctions if (save) { Creature* creature = new Creature(); - if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, phase, entry, x, y, z, o)) + if (!creature->Create(eObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, phase, entry, x, y, z, o)) { delete creature; return 1; @@ -759,7 +759,7 @@ namespace LuaGlobalFunctions return 1; } - sObjectMgr->AddCreatureToGrid(db_lowguid, sObjectMgr->GetCreatureData(db_lowguid)); + eObjectMgr->AddCreatureToGrid(db_lowguid, eObjectMgr->GetCreatureData(db_lowguid)); Eluna::Push(L, creature); } else @@ -781,7 +781,7 @@ namespace LuaGlobalFunctions if (spawntype == 2) // Spawn object { - const GameObjectTemplate* objectInfo = sObjectMgr->GetGameObjectTemplate(entry); + const GameObjectTemplate* objectInfo = eObjectMgr->GetGameObjectTemplate(entry); if (!objectInfo) return 1; @@ -789,7 +789,7 @@ namespace LuaGlobalFunctions return 1; GameObject* object = new GameObject; - uint32 lowguid = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT); + uint32 lowguid = eObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT); if (!object->Create(lowguid, objectInfo->entry, map, phase, x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY)) { @@ -812,7 +812,7 @@ namespace LuaGlobalFunctions return 1; } - sObjectMgr->AddGameobjectToGrid(lowguid, sObjectMgr->GetGOData(lowguid)); + eObjectMgr->AddGameobjectToGrid(lowguid, eObjectMgr->GetGOData(lowguid)); } else map->AddToMap(object); @@ -844,22 +844,22 @@ namespace LuaGlobalFunctions uint32 extendedcost = Eluna::CHECKVAL(L, 5); #ifdef MANGOS - if (!sObjectMgr->IsVendorItemValid(false, "npc_vendor", entry, item, maxcount, incrtime, extendedcost, 0)) + if (!eObjectMgr->IsVendorItemValid(false, "npc_vendor", entry, item, maxcount, incrtime, extendedcost, 0)) return 0; #ifndef CLASSIC - sObjectMgr->AddVendorItem(entry, item, maxcount, incrtime, extendedcost); + eObjectMgr->AddVendorItem(entry, item, maxcount, incrtime, extendedcost); #else - sObjectMgr->AddVendorItem(entry, item, maxcount, incrtime); + eObjectMgr->AddVendorItem(entry, item, maxcount, incrtime); #endif #else #ifdef CATA - if (!sObjectMgr->IsVendorItemValid(entry, item, maxcount, incrtime, extendedcost, 1)) + if (!eObjectMgr->IsVendorItemValid(entry, item, maxcount, incrtime, extendedcost, 1)) return 0; - sObjectMgr->AddVendorItem(entry, item, maxcount, incrtime, extendedcost, 1); + eObjectMgr->AddVendorItem(entry, item, maxcount, incrtime, extendedcost, 1); #else - if (!sObjectMgr->IsVendorItemValid(entry, item, maxcount, incrtime, extendedcost)) + if (!eObjectMgr->IsVendorItemValid(entry, item, maxcount, incrtime, extendedcost)) return 0; - sObjectMgr->AddVendorItem(entry, item, maxcount, incrtime, extendedcost); + eObjectMgr->AddVendorItem(entry, item, maxcount, incrtime, extendedcost); #endif #endif return 0; @@ -869,13 +869,13 @@ namespace LuaGlobalFunctions { uint32 entry = Eluna::CHECKVAL(L, 1); uint32 item = Eluna::CHECKVAL(L, 2); - if (!sObjectMgr->GetCreatureTemplate(entry)) + if (!eObjectMgr->GetCreatureTemplate(entry)) return luaL_argerror(L, 1, "valid CreatureEntry expected"); #ifdef CATA - sObjectMgr->RemoveVendorItem(entry, item, 1); + eObjectMgr->RemoveVendorItem(entry, item, 1); #else - sObjectMgr->RemoveVendorItem(entry, item); + eObjectMgr->RemoveVendorItem(entry, item); #endif return 0; } @@ -884,16 +884,16 @@ namespace LuaGlobalFunctions { uint32 entry = Eluna::CHECKVAL(L, 1); - VendorItemData const* items = sObjectMgr->GetNpcVendorItemList(entry); + VendorItemData const* items = eObjectMgr->GetNpcVendorItemList(entry); if (!items || items->Empty()) return 0; VendorItemList const itemlist = items->m_items; for (VendorItemList::const_iterator itr = itemlist.begin(); itr != itemlist.end(); ++itr) #ifdef CATA - sObjectMgr->RemoveVendorItem(entry, (*itr)->item, 1); + eObjectMgr->RemoveVendorItem(entry, (*itr)->item, 1); #else - sObjectMgr->RemoveVendorItem(entry, (*itr)->item); + eObjectMgr->RemoveVendorItem(entry, (*itr)->item); #endif return 0; } @@ -932,7 +932,7 @@ namespace LuaGlobalFunctions return 0; } - switch (sWorld->BanAccount((BanMode)banMode, nameOrIP, duration, reason, whoBanned->GetSession() ? whoBanned->GetName() : "")) + switch (eWorld->BanAccount((BanMode)banMode, nameOrIP, duration, reason, whoBanned->GetSession() ? whoBanned->GetName() : "")) { case BAN_SUCCESS: if (duration > 0) @@ -950,7 +950,7 @@ namespace LuaGlobalFunctions int SaveAllPlayers(lua_State* L) { - sObjectAccessor->SaveAllPlayers(); + eObjectAccessor->SaveAllPlayers(); return 0; } @@ -980,7 +980,7 @@ namespace LuaGlobalFunctions #ifdef MANGOS ItemTemplate const* item_proto = ObjectMgr::GetItemPrototype(entry); #else - ItemTemplate const* item_proto = sObjectMgr->GetItemTemplate(entry); + ItemTemplate const* item_proto = eObjectMgr->GetItemTemplate(entry); #endif if (!item_proto) { @@ -1163,14 +1163,14 @@ namespace LuaGlobalFunctions { Corpse* corpse = Eluna::CHECKOBJ(L, 1); - sObjectAccessor->AddCorpse(corpse); + eObjectAccessor->AddCorpse(corpse); return 0; } int RemoveCorpse(lua_State* L) { Corpse* corpse = Eluna::CHECKOBJ(L, 1); - sObjectAccessor->RemoveCorpse(corpse); + eObjectAccessor->RemoveCorpse(corpse); return 1; } @@ -1179,13 +1179,13 @@ namespace LuaGlobalFunctions uint64 guid = Eluna::CHECKVAL(L, 1); bool insignia = Eluna::CHECKVAL(L, 2, false); - Eluna::Push(L, sObjectAccessor->ConvertCorpseForPlayer(ObjectGuid(guid), insignia)); + Eluna::Push(L, eObjectAccessor->ConvertCorpseForPlayer(ObjectGuid(guid), insignia)); return 0; } int RemoveOldCorpses(lua_State* L) { - sObjectAccessor->RemoveOldCorpses(); + eObjectAccessor->RemoveOldCorpses(); return 0; } @@ -1193,7 +1193,7 @@ namespace LuaGlobalFunctions { uint32 zoneId = Eluna::CHECKVAL(L, 1); #ifdef MANGOS - Weather* weather = sWorld->FindWeather(zoneId); + Weather* weather = eWorld->FindWeather(zoneId); #else Weather* weather = WeatherMgr::FindWeather(zoneId); #endif @@ -1205,7 +1205,7 @@ namespace LuaGlobalFunctions { uint32 zoneId = Eluna::CHECKVAL(L, 1); #ifdef MANGOS - Weather* weather = sWorld->AddWeather(zoneId); + Weather* weather = eWorld->AddWeather(zoneId); #else Weather* weather = WeatherMgr::AddWeather(zoneId); #endif @@ -1217,7 +1217,7 @@ namespace LuaGlobalFunctions { uint32 zoneId = Eluna::CHECKVAL(L, 1); #ifdef MANGOS - sWorld->RemoveWeather(zoneId); + eWorld->RemoveWeather(zoneId); #else WeatherMgr::RemoveWeather(zoneId); #endif diff --git a/GroupMethods.h b/GroupMethods.h index bee861a..377d5cb 100644 --- a/GroupMethods.h +++ b/GroupMethods.h @@ -126,9 +126,9 @@ namespace LuaGroup int GetLeader(lua_State* L, Group* group) { #ifdef MANGOS - Eluna::Push(L, sObjectAccessor->FindPlayer(group->GetLeaderGuid())); + Eluna::Push(L, eObjectAccessor->FindPlayer(group->GetLeaderGuid())); #else - Eluna::Push(L, sObjectAccessor->FindPlayer(group->GetLeaderGUID())); + Eluna::Push(L, eObjectAccessor->FindPlayer(group->GetLeaderGUID())); #endif return 1; } diff --git a/GuildMethods.h b/GuildMethods.h index d0500bd..9eee9c1 100644 --- a/GuildMethods.h +++ b/GuildMethods.h @@ -16,7 +16,7 @@ namespace LuaGuild int tbl = lua_gettop(L); uint32 i = 0; - SessionMap const& sessions = sWorld->GetAllSessions(); + SessionMap const& sessions = eWorld->GetAllSessions(); for (SessionMap::const_iterator it = sessions.begin(); it != sessions.end(); ++it) { if (Player* player = it->second->GetPlayer()) @@ -44,9 +44,9 @@ namespace LuaGuild int GetLeader(lua_State* L, Guild* guild) { #ifdef MANGOS - Eluna::Push(L, sObjectAccessor->FindPlayer(guild->GetLeaderGuid())); + Eluna::Push(L, eObjectAccessor->FindPlayer(guild->GetLeaderGuid())); #else - Eluna::Push(L, sObjectAccessor->FindPlayer(guild->GetLeaderGUID())); + Eluna::Push(L, eObjectAccessor->FindPlayer(guild->GetLeaderGUID())); #endif return 1; } diff --git a/HookMgr.cpp b/HookMgr.cpp index 6198483..d32e7b0 100644 --- a/HookMgr.cpp +++ b/HookMgr.cpp @@ -467,7 +467,7 @@ bool Eluna::OnCommand(Player* player, const char* text) std::transform(eluna.begin(), eluna.end(), eluna.begin(), ::tolower); if (std::string("eluna").find(eluna) == 0) { - sWorld->SendServerMessage(SERVER_MSG_STRING, "Reloading Eluna..."); + eWorld->SendServerMessage(SERVER_MSG_STRING, "Reloading Eluna..."); ReloadEluna(); return false; } diff --git a/Includes.h b/Includes.h index 1b74901..7eea620 100644 --- a/Includes.h +++ b/Includes.h @@ -5,13 +5,11 @@ */ // Required -#include "AccountMgr.h" #include "AuctionHouseMgr.h" #include "Cell.h" #include "CellImpl.h" #include "Chat.h" #include "Channel.h" -#include "Config.h" #include "DBCStores.h" #include "GossipDef.h" #include "GridNotifiers.h" diff --git a/ItemMethods.h b/ItemMethods.h index 6d222b4..fedd465 100644 --- a/ItemMethods.h +++ b/ItemMethods.h @@ -163,7 +163,7 @@ namespace LuaItem const ItemTemplate* temp = item->GetTemplate(); std::string name = temp->Name1; - if (ItemLocale const* il = sObjectMgr->GetItemLocale(temp->ItemId)) + if (ItemLocale const* il = eObjectMgr->GetItemLocale(temp->ItemId)) ObjectMgr::GetLocaleString(il->Name, loc_idx, name); #ifndef CLASSIC diff --git a/LuaEngine.cpp b/LuaEngine.cpp index 2e91442..6bc9a5b 100644 --- a/LuaEngine.cpp +++ b/LuaEngine.cpp @@ -17,11 +17,11 @@ extern void RegisterFunctions(lua_State* L); void Eluna::Initialize() { - uint32 oldMSTime = getMSTime(); + uint32 oldMSTime = GetCurrTime(); scripts.clear(); - std::string folderpath = sConfigMgr->GetStringDefault("Eluna.ScriptPath", "lua_scripts"); + std::string folderpath = eConfigMgr->GetStringDefault("Eluna.ScriptPath", "lua_scripts"); #if PLATFORM == PLATFORM_UNIX || PLATFORM == PLATFORM_APPLE if (folderpath[0] == '~') if (const char* home = getenv("HOME")) @@ -31,7 +31,7 @@ void Eluna::Initialize() GetScripts(folderpath, scripts); GetScripts(folderpath + "/extensions", scripts); - ELUNA_LOG_INFO("[Eluna]: Loaded %u scripts in %u ms", uint32(scripts.size()), GetMSTimeDiffToNow(oldMSTime)); + ELUNA_LOG_INFO("[Eluna]: Loaded %u scripts in %u ms", uint32(scripts.size()), GetTimeDiff(oldMSTime)); // Create global eluna new Eluna(); @@ -576,7 +576,7 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef) case REGTYPE_CREATURE: if (evt < CREATURE_EVENT_COUNT) { - if (!sObjectMgr->GetCreatureTemplate(id)) + if (!eObjectMgr->GetCreatureTemplate(id)) { luaL_unref(L, LUA_REGISTRYINDEX, functionRef); luaL_error(L, "Couldn't find a creature with (ID: %d)!", id); @@ -591,7 +591,7 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef) case REGTYPE_CREATURE_GOSSIP: if (evt < GOSSIP_EVENT_COUNT) { - if (!sObjectMgr->GetCreatureTemplate(id)) + if (!eObjectMgr->GetCreatureTemplate(id)) { luaL_unref(L, LUA_REGISTRYINDEX, functionRef); luaL_error(L, "Couldn't find a creature with (ID: %d)!", id); @@ -606,7 +606,7 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef) case REGTYPE_GAMEOBJECT: if (evt < GAMEOBJECT_EVENT_COUNT) { - if (!sObjectMgr->GetGameObjectTemplate(id)) + if (!eObjectMgr->GetGameObjectTemplate(id)) { luaL_unref(L, LUA_REGISTRYINDEX, functionRef); luaL_error(L, "Couldn't find a gameobject with (ID: %d)!", id); @@ -621,7 +621,7 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef) case REGTYPE_GAMEOBJECT_GOSSIP: if (evt < GOSSIP_EVENT_COUNT) { - if (!sObjectMgr->GetGameObjectTemplate(id)) + if (!eObjectMgr->GetGameObjectTemplate(id)) { luaL_unref(L, LUA_REGISTRYINDEX, functionRef); luaL_error(L, "Couldn't find a gameobject with (ID: %d)!", id); @@ -636,7 +636,7 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef) case REGTYPE_ITEM: if (evt < ITEM_EVENT_COUNT) { - if (!sObjectMgr->GetItemTemplate(id)) + if (!eObjectMgr->GetItemTemplate(id)) { luaL_unref(L, LUA_REGISTRYINDEX, functionRef); luaL_error(L, "Couldn't find a item with (ID: %d)!", id); @@ -651,7 +651,7 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef) case REGTYPE_ITEM_GOSSIP: if (evt < GOSSIP_EVENT_COUNT) { - if (!sObjectMgr->GetItemTemplate(id)) + if (!eObjectMgr->GetItemTemplate(id)) { luaL_unref(L, LUA_REGISTRYINDEX, functionRef); luaL_error(L, "Couldn't find a item with (ID: %d)!", id); diff --git a/LuaEngine.h b/LuaEngine.h index a6834a1..507f047 100644 --- a/LuaEngine.h +++ b/LuaEngine.h @@ -19,10 +19,13 @@ extern "C" #include "SharedDefines.h" #include #include -// enums +// enums & singletons #ifdef MANGOS +#include "AccountMgr.h" +#include "Config/Config.h" #include "Player.h" #else +#include "Config.h" #include "GameObjectAI.h" #endif #include "Group.h" @@ -34,7 +37,7 @@ extern "C" typedef SpellEffectIndex SpellEffIndex; typedef SpellEntry SpellInfo; typedef ItemPrototype ItemTemplate; -#define GetTemplate GetProto +#define GetTemplate GetProto #ifdef CLASSIC typedef int Difficulty; #endif @@ -61,6 +64,7 @@ class Player; class Quest; class Spell; class SpellCastTargets; +class TemporarySummon; class Transport; class Unit; class Weather; @@ -77,20 +81,13 @@ typedef VehicleInfo Vehicle; #endif #ifdef MANGOS -#undef sWorld -#undef sMapMgr -#undef sConfigMgr -#undef sGuildMgr -#undef sObjectMgr -#undef sAccountMgr -#undef sObjectAccessor -#define sWorld (&MaNGOS::Singleton::Instance()) -#define sMapMgr (&MapManager::Instance()) -#define sConfigMgr (&MaNGOS::Singleton::Instance()) -#define sGuildMgr (&MaNGOS::Singleton::Instance()) -#define sObjectMgr (&MaNGOS::Singleton::Instance()) -#define sAccountMgr (&MaNGOS::Singleton::Instance()) -#define sObjectAccessor (&ObjectAccessor::Instance()) +#define eWorld (&sWorld) +#define eMapMgr (&sMapMgr) +#define eConfigMgr (&sConfig) +#define eGuildMgr (&sGuildMgr) +#define eObjectMgr (&sObjectMgr) +#define eAccountMgr (&sAccountMgr) +#define eObjectAccessor (&sObjectAccessor) #define MAKE_NEW_GUID(l, e, h) ObjectGuid(h, e, l) #define GET_GUID GetObjectGuid #define GetGameObjectTemplate GetGameObjectInfo @@ -112,6 +109,7 @@ typedef TemporarySummon TempSummon; #define GUID_ENPART(guid) ObjectGuid(guid).GetEntry() #define GUID_LOPART(guid) ObjectGuid(guid).GetCounter() #define GUID_HIPART(guid) ObjectGuid(guid).GetHigh() +#define ASSERT MANGOS_ASSERT enum SelectAggroTarget { SELECT_TARGET_RANDOM = 0, // Just selects a random target @@ -128,6 +126,13 @@ enum SelectAggroTarget #define Opcodes OpcodesList #endif #else +#define eWorld (sWorld) +#define eMapMgr (sMapMgr) +#define eConfigMgr (sConfigMgr) +#define eGuildMgr (sGuildMgr) +#define eObjectMgr (sObjectMgr) +#define eAccountMgr (sAccountMgr) +#define eObjectAccessor (sObjectAccessor) #ifndef CATA typedef uint64 ObjectGuid; #endif @@ -493,6 +498,24 @@ public: return ElunaTemplate::check(L, narg, error); } + static inline uint32 GetCurrTime() + { +#ifdef MANGOS + return WorldTimer::getMSTime(); +#else + return getMSTime(); +#endif + } + + static inline uint32 GetTimeDiff(uint32 oldMSTime) + { +#ifdef MANGOS + return WorldTimer::getMSTimeDiff(oldMSTime, GetCurrTime()); +#else + return GetMSTimeDiffToNow(uint32 oldMSTime); +#endif + } + struct ObjectGUIDCheck { ObjectGUIDCheck(ObjectGuid guid): _guid(guid) {} diff --git a/PlayerMethods.h b/PlayerMethods.h index 27e5764..15c4260 100644 --- a/PlayerMethods.h +++ b/PlayerMethods.h @@ -115,7 +115,7 @@ namespace LuaPlayer else { uint32 entry = Eluna::CHECKVAL(L, 2); - const ItemTemplate* temp = sObjectMgr->GetItemTemplate(entry); + const ItemTemplate* temp = eObjectMgr->GetItemTemplate(entry); if (temp) Eluna::Push(L, player->CanUseItem(temp)); else @@ -722,7 +722,7 @@ namespace LuaPlayer { if (!player->GetGuildId()) return 1; - Eluna::Push(L, sGuildMgr->GetGuildNameById(player->GetGuildId())); + Eluna::Push(L, eGuildMgr->GetGuildNameById(player->GetGuildId())); return 1; } @@ -929,7 +929,7 @@ namespace LuaPlayer int GetGuild(lua_State* L, Player* player) { - Eluna::Push(L, sGuildMgr->GetGuildById(player->GetGuildId())); + Eluna::Push(L, eGuildMgr->GetGuildById(player->GetGuildId())); return 1; } @@ -948,7 +948,7 @@ namespace LuaPlayer int GetAccountName(lua_State* L, Player* player) { std::string accName; - if (sAccountMgr->GetName(player->GetSession()->GetAccountId(), accName)) + if (eAccountMgr->GetName(player->GetSession()->GetAccountId(), accName)) Eluna::Push(L, accName); return 1; } @@ -1410,7 +1410,7 @@ namespace LuaPlayer { uint32 entry = Eluna::CHECKVAL(L, 2); - Quest const* quest = sObjectMgr->GetQuestTemplate(entry); + Quest const* quest = eObjectMgr->GetQuestTemplate(entry); if (quest) player->RewardQuest(quest, 0, player); return 0; @@ -2240,7 +2240,7 @@ namespace LuaPlayer uint32 questId = Eluna::CHECKVAL(L, 2); bool activeAccept = Eluna::CHECKVAL(L, 3, true); - Quest const* quest = sObjectMgr->GetQuestTemplate(questId); + Quest const* quest = eObjectMgr->GetQuestTemplate(questId); if (!quest) return 0; diff --git a/WorldObjectMethods.h b/WorldObjectMethods.h index e6a1f51..4fc8148 100644 --- a/WorldObjectMethods.h +++ b/WorldObjectMethods.h @@ -306,13 +306,13 @@ namespace LuaWorldObject #else switch (GUID_HIPART(guid)) { - case HIGHGUID_PLAYER: Eluna::Push(L, sObjectAccessor->GetPlayer(*obj, ObjectGuid(guid))); break; + case HIGHGUID_PLAYER: Eluna::Push(L, eObjectAccessor->GetPlayer(*obj, ObjectGuid(guid))); break; case HIGHGUID_TRANSPORT: case HIGHGUID_MO_TRANSPORT: - case HIGHGUID_GAMEOBJECT: Eluna::Push(L, sObjectAccessor->GetGameObject(*obj, ObjectGuid(guid))); break; + case HIGHGUID_GAMEOBJECT: Eluna::Push(L, eObjectAccessor->GetGameObject(*obj, ObjectGuid(guid))); break; case HIGHGUID_VEHICLE: - case HIGHGUID_UNIT: Eluna::Push(L, sObjectAccessor->GetCreature(*obj, ObjectGuid(guid))); break; - case HIGHGUID_PET: Eluna::Push(L, sObjectAccessor->GetPet(*obj, ObjectGuid(guid))); break; + case HIGHGUID_UNIT: Eluna::Push(L, eObjectAccessor->GetCreature(*obj, ObjectGuid(guid))); break; + case HIGHGUID_PET: Eluna::Push(L, eObjectAccessor->GetPet(*obj, ObjectGuid(guid))); break; } #endif return 1;