Skip to content

Commit 5f8e23d

Browse files
authored
Switch to using ElunaMgr (#26)
Implements ElunaLuaEngine/Eluna@4008d28
1 parent 0daefd4 commit 5f8e23d

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

src/server/game/LuaEngine

src/server/game/Maps/Map.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,12 @@ i_scriptLock(false), _respawnTimes(std::make_unique<RespawnListContainer>()), _r
284284
{
285285
m_parentMap = (_parent ? _parent : this);
286286
#ifdef ELUNA
287-
// lua state begins uninitialized
288-
eluna = nullptr;
289-
290287
if (sElunaConfig->IsElunaEnabled() && sElunaConfig->ShouldMapLoadEluna(id))
291288
if (!IsParentMap() || (IsParentMap() && !Instanceable()))
292-
eluna = std::make_unique<Eluna>(this);
289+
{
290+
_elunaInfo = { ElunaInfoKey::MakeKey(GetId(), GetInstanceId()) };
291+
sElunaMgr->Create(this, _elunaInfo);
292+
}
293293
#endif
294294
for (unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx)
295295
{

src/server/game/Maps/Map.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <mutex>
4141
#ifdef ELUNA
4242
#include "LuaValue.h"
43+
#include "ElunaMgr.h"
4344
#endif
4445

4546
class Battleground;
@@ -788,8 +789,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
788789
void AddFarSpellCallback(FarSpellCallback&& callback);
789790
bool IsParentMap() const { return GetParent() == this; }
790791
#ifdef ELUNA
791-
Eluna* GetEluna() const { return eluna.get(); }
792-
792+
Eluna* GetEluna() const { return sElunaMgr->Get(_elunaInfo); }
793793
LuaVal lua_data = LuaVal({});
794794
#endif
795795
private:
@@ -872,7 +872,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
872872

873873
MPSCQueue<FarSpellCallback> _farSpellCallbacks;
874874
#ifdef ELUNA
875-
std::unique_ptr<Eluna> eluna;
875+
ElunaInfo _elunaInfo;
876876
#endif
877877
};
878878

src/server/game/World/World.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2131,7 +2131,8 @@ void World::SetInitialWorldSettings()
21312131
if (sElunaConfig->IsElunaEnabled())
21322132
{
21332133
TC_LOG_INFO("server.loading", "Starting Eluna world state...");
2134-
eluna = std::make_unique<Eluna>(nullptr);
2134+
_elunaInfo = { ElunaInfoKey::MakeGlobalKey(0) };
2135+
sElunaMgr->Create(nullptr, _elunaInfo);
21352136
}
21362137
#endif
21372138

src/server/game/World/World.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
#include "ObjectGuid.h"
3030
#include "SharedDefines.h"
3131
#include "Timer.h"
32+
#ifdef ELUNA
33+
#include "ElunaMgr.h"
34+
#endif
3235

3336
#include <atomic>
3437
#include <list>
@@ -775,8 +778,7 @@ class TC_GAME_API World
775778
bool IsGuidAlert() { return _guidAlert; }
776779

777780
#ifdef ELUNA
778-
Eluna* GetEluna() const { return eluna.get(); }
779-
std::unique_ptr<Eluna> eluna;
781+
Eluna* GetEluna() const { return sElunaMgr->Get(_elunaInfo); }
780782
#endif
781783
protected:
782784
void _UpdateGameTime();
@@ -891,7 +893,9 @@ class TC_GAME_API World
891893
bool _guidAlert;
892894
uint32 _warnDiff;
893895
time_t _warnShutdownTime;
894-
896+
#ifdef ELUNA
897+
ElunaInfo _elunaInfo;
898+
#endif
895899
friend class debug_commandscript;
896900
};
897901

0 commit comments

Comments
 (0)