Skip to content

Commit

Permalink
[Eluna] Update Eluna to latest and reenable Eluna tests (#204)
Browse files Browse the repository at this point in the history
* [Eluna] Update to latest Eluna

Adds multistate support and defaults it to on

Co-Authored-By: Foe <[email protected]>

* [Eluna] Fix BG crash

* [Eluna] Fix elunaEvent init and de-init

Co-Authored-By: Foe <[email protected]>

* Enable Eluna tests

---------

Co-authored-by: Foe <[email protected]>
  • Loading branch information
2 people authored and billy1arm committed Aug 30, 2024
1 parent 0e23f6a commit 2135a80
Show file tree
Hide file tree
Showing 44 changed files with 801 additions and 250 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/core_windows_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ jobs:
shell: bash
run: |
mkdir -p build && cd build
cmake .. -DCMAKE_SYSTEM_VERSION=10.0.22621.0 -DBUILD_TOOLS:BOOL=1 -DBUILD_MANGOSD:BOOL=1 -DBUILD_REALMD:BOOL=1 -DSOAP:BOOL=1 -DSCRIPT_LIB_ELUNA:BOOL=0 -DSCRIPT_LIB_SD3:BOOL=1 -DPLAYERBOTS:BOOL=1 -DUSE_STORMLIB:BOOL=1
cmake .. -DCMAKE_SYSTEM_VERSION=10.0.22621.0 -DBUILD_TOOLS:BOOL=1 -DBUILD_MANGOSD:BOOL=1 -DBUILD_REALMD:BOOL=1 -DSOAP:BOOL=1 -DSCRIPT_LIB_ELUNA:BOOL=1 -DSCRIPT_LIB_SD3:BOOL=1 -DPLAYERBOTS:BOOL=1 -DUSE_STORMLIB:BOOL=1
cmake --build . --config Release --parallel 4
2 changes: 1 addition & 1 deletion apps/ci/ci-compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ time test -d _install || mkdir _install
time cd _build

# Run CMake Configurations
time cmake .. -DCMAKE_INSTALL_PREFIX=../_install -DBUILD_TOOLS:BOOL=1 -DBUILD_MANGOSD:BOOL=1 -DBUILD_REALMD:BOOL=1 -DSOAP:BOOL=1 -DSCRIPT_LIB_ELUNA:BOOL=0 -DSCRIPT_LIB_SD3:BOOL=1 -DPLAYERBOTS:BOOL=1 -DUSE_STORMLIB:BOOL=1
time cmake .. -DCMAKE_INSTALL_PREFIX=../_install -DBUILD_TOOLS:BOOL=1 -DBUILD_MANGOSD:BOOL=1 -DBUILD_REALMD:BOOL=1 -DSOAP:BOOL=1 -DSCRIPT_LIB_ELUNA:BOOL=1 -DSCRIPT_LIB_SD3:BOOL=1 -DPLAYERBOTS:BOOL=1 -DUSE_STORMLIB:BOOL=1

# Compile the Project
time make -j 6
17 changes: 15 additions & 2 deletions src/game/BattleGround/BattleGround.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,13 @@ void BattleGround::Update(uint32 diff)
{
m_Events |= BG_STARTING_EVENT_4;

#ifdef ENABLE_ELUNA
if (Eluna* e = this->GetBgMap()->GetEluna())
{
e->OnBGCreate(this, GetTypeID(), GetInstanceID());
}
#endif /* ENABLE_ELUNA */

StartingEventOpenDoors();

SendMessageToAll(m_StartMessageIds[BG_STARTING_EVENT_FOURTH], CHAT_MSG_BG_SYSTEM_NEUTRAL);
Expand Down Expand Up @@ -793,7 +800,10 @@ void BattleGround::UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player*
void BattleGround::EndBattleGround(Team winner)
{
#ifdef ENABLE_ELUNA
sEluna->OnBGEnd(this, GetTypeID(), GetInstanceID(), winner);
if (Eluna* e = GetBgMap()->GetEluna())
{
e->OnBGEnd(this, GetTypeID(), GetInstanceID(), winner);
}
#endif /* ENABLE_ELUNA */
this->RemoveFromBGFreeSlotQueue();

Expand Down Expand Up @@ -1428,7 +1438,10 @@ void BattleGround::StartBattleGround()
sBattleGroundMgr.AddBattleGround(GetInstanceID(), GetTypeID(), this);

#ifdef ENABLE_ELUNA
sEluna->OnBGStart(this, GetTypeID(), GetInstanceID());
if (Eluna* e = GetBgMap()->GetEluna())
{
e->OnBGCreate(this, GetTypeID(), GetInstanceID());
}
#endif /* ENABLE_ELUNA */
}

Expand Down
4 changes: 0 additions & 4 deletions src/game/BattleGround/BattleGroundMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1716,10 +1716,6 @@ uint32 BattleGroundMgr::CreateBattleGround(BattleGroundTypeId bgTypeId, bool IsA
// add bg to update list
AddBattleGround(bg->GetInstanceID(), bg->GetTypeID(), bg);

#ifdef ENABLE_ELUNA
sEluna->OnBGCreate(bg, bgTypeId, bg->GetInstanceID());
#endif /* ENABLE_ELUNA */

// return some not-null value, bgTypeId is good enough for me
return bgTypeId;
}
Expand Down
13 changes: 8 additions & 5 deletions src/game/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ if(SCRIPT_LIB_ELUNA)
file(GLOB SRC_GRP_ELUNA
${CMAKE_SOURCE_DIR}/src/modules/Eluna/*.cpp
${CMAKE_SOURCE_DIR}/src/modules/Eluna/*.h
${CMAKE_SOURCE_DIR}/src/modules/Eluna/Mangos/*.cpp
${CMAKE_SOURCE_DIR}/src/modules/Eluna/Mangos/*.h
${CMAKE_SOURCE_DIR}/src/modules/Eluna/hooks/*.cpp
${CMAKE_SOURCE_DIR}/src/modules/Eluna/hooks/*.h
${CMAKE_SOURCE_DIR}/src/modules/Eluna/methods/Mangos/*.cpp
${CMAKE_SOURCE_DIR}/src/modules/Eluna/methods/Mangos/*.h
)
source_group("Eluna" FILES ${SRC_GRP_ELUNA})
endif()
Expand Down Expand Up @@ -258,8 +260,9 @@ target_include_directories(game
WorldHandlers
$<$<BOOL:${SCRIPT_LIB_ELUNA}>:
${CMAKE_SOURCE_DIR}/src/modules/Eluna
${CMAKE_SOURCE_DIR}/src/modules/Eluna/Mangos
>
${CMAKE_SOURCE_DIR}/src/modules/Eluna/hooks
${CMAKE_SOURCE_DIR}/src/modules/Eluna/methods/Mangos
>
$<$<BOOL:${PLAYERBOTS}>:
${CMAKE_SOURCE_DIR}/src/modules/Bots
${CMAKE_SOURCE_DIR}/src/modules/Bots/playerbot
Expand All @@ -272,7 +275,7 @@ target_compile_definitions(game
$<$<BOOL:${SOAP}>:ENABLE_SOAP>
$<$<BOOL:${SCRIPT_LIB_SD3}>:ENABLE_SD3>
$<$<BOOL:${PLAYERBOTS}>:ENABLE_PLAYERBOTS>
$<$<BOOL:${SCRIPT_LIB_ELUNA}>:ENABLE_ELUNA>
$<$<BOOL:${SCRIPT_LIB_ELUNA}>:ENABLE_ELUNA ELUNA_EXPANSION=1 ELUNA_MANGOS>
)

target_link_libraries(game
Expand Down
10 changes: 8 additions & 2 deletions src/game/Object/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ void Creature::AddToWorld()
#ifdef ENABLE_ELUNA
if (!inWorld)
{
sEluna->OnAddToWorld(this);
if (Eluna* e = GetEluna())
{
e->OnAddToWorld(this);
}
}
#endif /* ENABLE_ELUNA */

Expand All @@ -222,7 +225,10 @@ void Creature::RemoveFromWorld()
#ifdef ENABLE_ELUNA
if (IsInWorld())
{
sEluna->OnRemoveFromWorld(this);
if (Eluna* e = GetEluna())
{
e->OnRemoveFromWorld(this);
}
}
#endif /* ENABLE_ELUNA */

Expand Down
30 changes: 24 additions & 6 deletions src/game/Object/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ void GameObject::AddToWorld()
#ifdef ENABLE_ELUNA
if (!inWorld)
{
sEluna->OnAddToWorld(this);
if (Eluna* e = GetEluna())
{
e->OnAddToWorld(this);
}
}
#endif /* ENABLE_ELUNA */
}
Expand All @@ -136,7 +139,10 @@ void GameObject::RemoveFromWorld()
if (IsInWorld())
{
#ifdef ENABLE_ELUNA
sEluna->OnRemoveFromWorld(this);
if (Eluna* e = GetEluna())
{
e->OnRemoveFromWorld(this);
}
#endif /* ENABLE_ELUNA */

// Notify the outdoor pvp script
Expand Down Expand Up @@ -253,7 +259,10 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, float x, float

// Used by Eluna
#ifdef ENABLE_ELUNA
sEluna->OnSpawn(this);
if (Eluna* e = GetEluna())
{
e->OnSpawn(this);
}
#endif /* ENABLE_ELUNA */

// Notify the battleground or outdoor pvp script
Expand Down Expand Up @@ -287,7 +296,10 @@ void GameObject::Update(uint32 update_diff, uint32 p_time)

// Used by Eluna
#ifdef ENABLE_ELUNA
sEluna->UpdateAI(this, update_diff);
if (Eluna* e = GetEluna())
{
e->UpdateAI(this, update_diff);
}
#endif /* ENABLE_ELUNA */

switch (m_lootState)
Expand Down Expand Up @@ -2342,7 +2354,10 @@ void GameObject::SetLootState(LootState state)
{
m_lootState = state;
#ifdef ENABLE_ELUNA
sEluna->OnLootStateChanged(this, state);
if (Eluna* e = GetEluna())
{
e->OnLootStateChanged(this, state);
}
#endif /* ENABLE_ELUNA */
UpdateCollisionState();
}
Expand All @@ -2351,7 +2366,10 @@ void GameObject::SetGoState(GOState state)
{
SetByteValue(GAMEOBJECT_STATE, 0, state);
#ifdef ENABLE_ELUNA
sEluna->OnGameObjectStateChanged(this, state);
if (Eluna* e = GetEluna())
{
e->OnGameObjectStateChanged(this, state);
}
#endif /* ENABLE_ELUNA */
UpdateCollisionState();
}
Expand Down
30 changes: 24 additions & 6 deletions src/game/Object/Guild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ bool Guild::Create(Player* leader, std::string gname)

// Used by Eluna
#ifdef ENABLE_ELUNA
sEluna->OnCreate(this, leader, gname.c_str());
if (Eluna* e = sWorld.GetEluna())
{
e->OnCreate(this, leader, gname.c_str());
}
#endif /* ENABLE_ELUNA */

return AddMember(m_LeaderGuid, (uint32)GR_GUILDMASTER);
Expand Down Expand Up @@ -281,7 +284,10 @@ bool Guild::AddMember(ObjectGuid plGuid, uint32 plRank)

// Used by Eluna
#ifdef ENABLE_ELUNA
sEluna->OnAddMember(this, pl, newmember.RankId);
if (Eluna* e = sWorld.GetEluna())
{
e->OnAddMember(this, pl, newmember.RankId);
}
#endif /* ENABLE_ELUNA */

return true;
Expand All @@ -297,7 +303,10 @@ void Guild::SetMOTD(std::string motd)

// Used by Eluna
#ifdef ENABLE_ELUNA
sEluna->OnMOTDChanged(this, motd);
if (Eluna* e = sWorld.GetEluna())
{
e->OnMOTDChanged(this, motd);
}
#endif /* ENABLE_ELUNA */
}

Expand All @@ -311,7 +320,10 @@ void Guild::SetGINFO(std::string ginfo)

// Used by Eluna
#ifdef ENABLE_ELUNA
sEluna->OnInfoChanged(this, ginfo);
if (Eluna* e = sWorld.GetEluna())
{
e->OnInfoChanged(this, ginfo);
}
#endif /* ENABLE_ELUNA */
}

Expand Down Expand Up @@ -659,7 +671,10 @@ bool Guild::DelMember(ObjectGuid guid, bool isDisbanding)

// Used by Eluna
#ifdef ENABLE_ELUNA
sEluna->OnRemoveMember(this, player, isDisbanding); // IsKicked not a part of Mangos, implement?
if (Eluna* e = sWorld.GetEluna())
{
e->OnRemoveMember(this, player, isDisbanding); // IsKicked not a part of Mangos, implement?
}
#endif /* ENABLE_ELUNA */

return members.empty();
Expand Down Expand Up @@ -879,7 +894,10 @@ void Guild::Disband()

// Used by Eluna
#ifdef ENABLE_ELUNA
sEluna->OnDisband(this);
if (Eluna* e = sWorld.GetEluna())
{
e->OnDisband(this);
}
#endif /* ENABLE_ELUNA */

sGuildMgr.RemoveGuild(m_Id);
Expand Down
5 changes: 4 additions & 1 deletion src/game/Object/Item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,10 @@ void Item::UpdateDuration(Player* owner, uint32 diff)
{
// Used by Eluna
#ifdef ENABLE_ELUNA
sEluna->OnExpire(owner, GetProto());
if (Eluna* e = owner->GetEluna())
{
e->OnExpire(owner, GetProto());
}
#endif /* ENABLE_ELUNA */
owner->DestroyItem(GetBagSlot(), GetSlot(), true);
return;
Expand Down
34 changes: 23 additions & 11 deletions src/game/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

#ifdef ENABLE_ELUNA
#include "LuaEngine.h"
#include "ElunaConfig.h"
#include "ElunaEventMgr.h"
#endif /* ENABLE_ELUNA */

Expand Down Expand Up @@ -1002,7 +1003,7 @@ void Object::MarkForClientUpdate()

WorldObject::WorldObject() :
#ifdef ENABLE_ELUNA
elunaEvents(NULL),
elunaEvents(nullptr),
#endif /* ENABLE_ELUNA */
m_transportInfo(NULL),
m_currMap(NULL),
Expand All @@ -1015,7 +1016,7 @@ WorldObject::~WorldObject()
{
#ifdef ENABLE_ELUNA
delete elunaEvents;
elunaEvents = NULL;
elunaEvents = nullptr;
#endif /* ENABLE_ELUNA */
}

Expand All @@ -1027,7 +1028,10 @@ void WorldObject::CleanupsBeforeDelete()
void WorldObject::Update(uint32 update_diff, uint32 /*time_diff*/)
{
#ifdef ENABLE_ELUNA
elunaEvents->Update(update_diff);
if (elunaEvents) // can be null on maps without eluna
{
elunaEvents->Update(update_diff);
}
#endif /* ENABLE_ELUNA */
}

Expand Down Expand Up @@ -1675,13 +1679,6 @@ void WorldObject::SetMap(Map* map)
// lets save current map's Id/instanceId
m_mapId = map->GetId();
m_InstanceId = map->GetInstanceId();

#ifdef ENABLE_ELUNA
if (!elunaEvents)
{
elunaEvents = new ElunaEventProcessor(&Eluna::GEluna, this);
}
#endif
}

void WorldObject::ResetMap()
Expand Down Expand Up @@ -1748,7 +1745,10 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
#ifdef ENABLE_ELUNA
if (Unit* summoner = ToUnit())
{
sEluna->OnSummoned(pCreature, summoner);
if (Eluna* e = GetEluna())
{
e->OnSummoned(pCreature, summoner);
}
}
#endif /* ENABLE_ELUNA */

Expand Down Expand Up @@ -2182,3 +2182,15 @@ void WorldObject::SetActiveObjectState(bool active)
}
m_isActiveObject = active;
}

#ifdef ENABLE_ELUNA
Eluna* WorldObject::GetEluna() const
{
if (IsInWorld())
{
return GetMap()->GetEluna();
}

return nullptr;
}
#endif /* ENABLE_ELUNA */
9 changes: 9 additions & 0 deletions src/game/Object/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#include "ObjectGuid.h"
#include "Camera.h"
#include "GameTime.h"
#ifdef ENABLE_ELUNA
#include "LuaValue.h"
#endif /* ENABLE_ELUNA */

#include <set>

Expand Down Expand Up @@ -76,7 +79,9 @@ class UpdateMask;
class InstanceData;
class TerrainInfo;
#ifdef ENABLE_ELUNA
class Eluna;
class ElunaEventProcessor;
class LuaVal;
#endif /* ENABLE_ELUNA */
class TransportInfo;
struct MangosStringLocale;
Expand Down Expand Up @@ -695,6 +700,10 @@ class WorldObject : public Object

#ifdef ENABLE_ELUNA
ElunaEventProcessor* elunaEvents;

Eluna* GetEluna() const;

LuaVal lua_data = LuaVal({});
#endif /* ENABLE_ELUNA */

protected:
Expand Down
Loading

0 comments on commit 2135a80

Please sign in to comment.