This commit is contained in:
luis
2026-03-18 02:13:06 -03:00
parent 1eb0b1d8b7
commit 2a3de1833a
4 changed files with 38 additions and 8 deletions
+2 -8
View File
@@ -148,14 +148,8 @@ class TC_DATABASE_API Field
Optional<std::string_view> GetStringViewOrNull() const noexcept;
Optional<std::vector<uint8>> GetBinaryOrNull() const noexcept;
Optional<std::span<uint8 const>> GetBinaryViewOrNull() const noexcept;
template <size_t S>
Optional<std::array<uint8, S>> GetBinaryOrNull() const noexcept
{
Optional<std::array<uint8, S>> buf;
if (!IsNull())
GetBinarySizeChecked(buf.emplace().data(), S);
return buf;
}
DatabaseFieldTypes GetType() { return _meta->Type; }
private:
char const* _value; // Actual data in memory
@@ -952,6 +952,14 @@ void GameObject::AddToWorld()
EnableCollision(toggledState);
WorldObject::AddToWorld();
#ifdef ELUNA
if (Eluna* e = GetEluna())
{
e->OnAddToWorld(this);
e->OnSpawn(this);
}
#endif
}
}
@@ -960,6 +968,11 @@ void GameObject::RemoveFromWorld()
///- Remove the gameobject from the accessor
if (IsInWorld())
{
#ifdef ELUNA
if (Eluna* e = GetEluna())
e->OnRemoveFromWorld(this);
#endif
if (m_zoneScript)
m_zoneScript->OnGameObjectRemove(this);
@@ -1254,6 +1267,15 @@ GameObject* GameObject::CreateGameObjectFromDB(ObjectGuid::LowType spawnId, Map*
void GameObject::Update(uint32 diff)
{
#ifdef ELUNA
if (Eluna* e = GetEluna())
{
e->UpdateAI(this, diff);
if (elunaEvents)
elunaEvents->Update(diff);
}
#endif
WorldObject::Update(diff);
if (AI())
@@ -231,11 +231,17 @@ m_currMap(nullptr), m_InstanceId(0), _dbPhase(0), m_notifyflags(0), _heartbeatTi
#ifdef ELUNA
_eluna = nullptr;
elunaEvents = nullptr;
#endif
}
WorldObject::~WorldObject()
{
#ifdef ELUNA
delete elunaEvents;
elunaEvents = nullptr;
#endif
// this may happen because there are many !create/delete
if (IsStoredInWorldObjectGridContainer() && m_currMap)
{
@@ -1176,6 +1182,11 @@ void WorldObject::SetMap(Map* map)
m_currMap = map;
m_mapId = map->GetId();
m_InstanceId = map->GetInstanceId();
#ifdef ELUNA
if (Eluna* e = map->GetEluna())
if (!elunaEvents)
elunaEvents = new ElunaEventProcessor(e, this);
#endif
if (IsStoredInWorldObjectGridContainer())
m_currMap->AddWorldObject(this);
}
+3
View File
@@ -64,6 +64,7 @@ class WorldObject;
class ZoneScript;
#ifdef ELUNA
class Eluna;
class ElunaEventProcessor;
#endif
struct FactionTemplateEntry;
struct Loot;
@@ -578,6 +579,8 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
#ifdef ELUNA
Eluna* GetEluna() const { return _eluna; }
ElunaEventProcessor* elunaEvents;
LuaVal lua_data = LuaVal({});
private:
Eluna* _eluna;
#else