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 da8b886 commit 390d8c0
Show file tree
Hide file tree
Showing 46 changed files with 883 additions and 268 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=0 -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=0 -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=0 -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=0 -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 @@ -458,6 +458,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 @@ -850,7 +857,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 @@ -1466,7 +1476,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 @@ -1791,10 +1791,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
11 changes: 7 additions & 4 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,7 +260,8 @@ 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
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=2 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 @@ -212,7 +212,10 @@ void Creature::AddToWorld()
#ifdef ENABLE_ELUNA
if (!inWorld)
{
sEluna->OnAddToWorld(this);
if (Eluna* e = GetEluna())
{
e->OnAddToWorld(this);
}
}
#endif /* ENABLE_ELUNA */

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

Expand Down
40 changes: 32 additions & 8 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 @@ -252,7 +258,10 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa

// 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 @@ -286,7 +295,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 @@ -2262,7 +2274,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 @@ -2271,7 +2286,10 @@ void GameObject::SetGoState(GOState state)
{
SetByteValue(GAMEOBJECT_BYTES_1, 0, state);
#ifdef ENABLE_ELUNA
sEluna->OnGameObjectStateChanged(this, state);
if (Eluna* e = GetEluna())
{
e->OnGameObjectStateChanged(this, state);
}
#endif /* ENABLE_ELUNA */
UpdateCollisionState();
}
Expand Down Expand Up @@ -2782,7 +2800,10 @@ void GameObject::ForceGameObjectHealth(int32 diff, Unit* caster)
#ifdef ENABLE_ELUNA
if (caster && caster->ToPlayer())
{
sEluna->OnDamaged(this, caster->ToPlayer());
if (Eluna* e = caster->GetEluna())
{
e->OnDamaged(this, caster->ToPlayer());
}
}
#endif
if (m_useTimes > uint32(-diff))
Expand Down Expand Up @@ -2835,7 +2856,10 @@ void GameObject::ForceGameObjectHealth(int32 diff, Unit* caster)
#ifdef ENABLE_ELUNA
if(caster && caster->ToPlayer())
{
sEluna->OnDestroyed(this, caster->ToPlayer());
if (Eluna* e = caster->GetEluna())
{
e->OnDestroyed(this, caster->ToPlayer());
}
}
#endif
RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK_9 | GO_FLAG_UNK_10);
Expand Down
40 changes: 32 additions & 8 deletions src/game/Object/Guild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,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 @@ -274,7 +277,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 @@ -290,7 +296,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 @@ -304,7 +313,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 @@ -644,7 +656,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 @@ -897,7 +912,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 Expand Up @@ -1466,7 +1484,10 @@ bool Guild::MemberMoneyWithdraw(uint32 amount, uint32 LowGuid)

#ifdef ENABLE_ELUNA
Player* player = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, LowGuid));
sEluna->OnMemberWitdrawMoney(this, player, amount, false); // IsRepair not a part of Mangos, implement?
if (Eluna* e = sWorld.GetEluna())
{
e->OnMemberWitdrawMoney(this, player, amount, false); // IsRepair not a part of Mangos, implement?
}
#endif

return true;
Expand Down Expand Up @@ -1918,7 +1939,10 @@ void Guild::LogBankEvent(uint8 EventType, uint8 TabId, uint32 PlayerGuidLow, uin
}

#ifdef ENABLE_ELUNA
sEluna->OnBankEvent(this, EventType, TabId, PlayerGuidLow, ItemOrMoney, ItemStackCount, DestTabId);
if (Eluna* e = sWorld.GetEluna())
{
e->OnBankEvent(this, EventType, TabId, PlayerGuidLow, ItemOrMoney, ItemStackCount, DestTabId);
}
#endif

// save event to database
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 @@ -356,7 +356,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 */

if (uint32 newItemId = sObjectMgr.GetItemExpireConvert(GetEntry()))
Expand Down
Loading

0 comments on commit 390d8c0

Please sign in to comment.