Skip to content

Commit e58b802

Browse files
committed
Switch eluna event processor to unique pointers
1 parent 7a34531 commit e58b802

File tree

2 files changed

+3
-20
lines changed

2 files changed

+3
-20
lines changed

src/server/game/Entities/Object/Object.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -940,9 +940,6 @@ void MovementInfo::OutDebug()
940940
}
941941

942942
WorldObject::WorldObject(bool isWorldObject) : Object(), WorldLocation(), LastUsedScriptID(0),
943-
#ifdef ELUNA
944-
elunaEvents(NULL),
945-
#endif
946943
m_movementInfo(), m_name(), m_isActive(false), m_isFarVisible(false), m_isStoredInWorldObjectGridContainer(isWorldObject), m_zoneScript(nullptr),
947944
m_transport(nullptr), m_zoneId(0), m_areaId(0), m_staticFloorZ(VMAP_INVALID_HEIGHT), m_outdoors(false), m_liquidStatus(LIQUID_MAP_NO_WATER),
948945
m_currMap(nullptr), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL), m_notifyflags(0)
@@ -953,10 +950,6 @@ m_currMap(nullptr), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL), m_notifyflag
953950

954951
WorldObject::~WorldObject()
955952
{
956-
#ifdef ELUNA
957-
delete elunaEvents;
958-
elunaEvents = NULL;
959-
#endif
960953
// this may happen because there are many !create/delete
961954
if (IsStoredInWorldObjectGridContainer() && m_currMap)
962955
{
@@ -1832,19 +1825,9 @@ void WorldObject::SetMap(Map* map)
18321825
m_mapId = map->GetId();
18331826
m_InstanceId = map->GetInstanceId();
18341827
#ifdef ELUNA
1835-
//@todo: possibly look into cleanly clearing all pending events from previous map's event mgr.
1836-
1837-
// if multistate, delete elunaEvents and set to nullptr. events shouldn't move across states.
1838-
// in single state, the timed events should move across maps
1839-
if (!sElunaConfig->IsElunaCompatibilityMode())
1840-
{
1841-
delete elunaEvents;
1842-
elunaEvents = nullptr; // set to null in case map doesn't use eluna
1843-
}
1844-
18451828
if (Eluna* e = map->GetEluna())
1846-
if (!elunaEvents)
1847-
elunaEvents = new ElunaEventProcessor(e, this);
1829+
if (!elunaEvents || (elunaEvents && !sElunaConfig->IsElunaCompatibilityMode()))
1830+
elunaEvents = std::make_unique<ElunaEventProcessor>(e, this);
18481831
#endif
18491832
if (IsStoredInWorldObjectGridContainer())
18501833
m_currMap->AddWorldObject(this);

src/server/game/Entities/Object/Object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
568568
uint32 LastUsedScriptID;
569569

570570
#ifdef ELUNA
571-
ElunaEventProcessor* elunaEvents;
571+
std::unique_ptr <ElunaEventProcessor> elunaEvents;
572572

573573
Eluna* GetEluna() const;
574574

0 commit comments

Comments
 (0)