Skip to content

Commit

Permalink
Switch eluna event processor to unique pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
Foereaper committed Feb 24, 2025
1 parent 7a34531 commit e58b802
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
21 changes: 2 additions & 19 deletions src/server/game/Entities/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -940,9 +940,6 @@ void MovementInfo::OutDebug()
}

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

WorldObject::~WorldObject()
{
#ifdef ELUNA
delete elunaEvents;
elunaEvents = NULL;
#endif
// this may happen because there are many !create/delete
if (IsStoredInWorldObjectGridContainer() && m_currMap)
{
Expand Down Expand Up @@ -1832,19 +1825,9 @@ void WorldObject::SetMap(Map* map)
m_mapId = map->GetId();
m_InstanceId = map->GetInstanceId();
#ifdef ELUNA
//@todo: possibly look into cleanly clearing all pending events from previous map's event mgr.

// if multistate, delete elunaEvents and set to nullptr. events shouldn't move across states.
// in single state, the timed events should move across maps
if (!sElunaConfig->IsElunaCompatibilityMode())

This comment has been minimized.

Copy link
@Shauren

Shauren Feb 24, 2025

Contributor

If it is possible for map->GetEluna() to return nullptr then this branch should be kept (and changed to just assign nullptr/reset on unique_ptr)

This comment has been minimized.

Copy link
@Foereaper

Foereaper Feb 25, 2025

Author Member

Good call, I had forgotten that we implemented the OnlyOnMaps config option, I'll re-add the check later today to cover those edge cases

{
delete elunaEvents;
elunaEvents = nullptr; // set to null in case map doesn't use eluna
}

if (Eluna* e = map->GetEluna())
if (!elunaEvents)
elunaEvents = new ElunaEventProcessor(e, this);
if (!elunaEvents || (elunaEvents && !sElunaConfig->IsElunaCompatibilityMode()))
elunaEvents = std::make_unique<ElunaEventProcessor>(e, this);
#endif
if (IsStoredInWorldObjectGridContainer())
m_currMap->AddWorldObject(this);
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Entities/Object/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
uint32 LastUsedScriptID;

#ifdef ELUNA
ElunaEventProcessor* elunaEvents;
std::unique_ptr <ElunaEventProcessor> elunaEvents;

Eluna* GetEluna() const;

Expand Down

0 comments on commit e58b802

Please sign in to comment.