Skip to content

Commit

Permalink
Merge d09e7a9 into e4de3f4
Browse files Browse the repository at this point in the history
  • Loading branch information
Niam5 authored Aug 29, 2024
2 parents e4de3f4 + d09e7a9 commit 68fe95a
Show file tree
Hide file tree
Showing 44 changed files with 792 additions and 247 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 @@ -454,6 +454,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 @@ -774,7 +781,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 @@ -1281,7 +1291,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 @@ -1231,10 +1231,6 @@ uint32 BattleGroundMgr::CreateBattleGround(BattleGroundTypeId bgTypeId, uint32 M
// 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=0 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
30 changes: 24 additions & 6 deletions src/game/Object/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,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 @@ -248,7 +254,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 @@ -282,7 +291,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 @@ -2310,7 +2322,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 @@ -2319,7 +2334,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 @@ -159,7 +159,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 @@ -264,7 +267,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 @@ -280,7 +286,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 @@ -294,7 +303,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 @@ -619,7 +631,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 @@ -823,7 +838,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 @@ -331,7 +331,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 @@ -908,7 +909,7 @@ void Object::MarkForClientUpdate()

WorldObject::WorldObject() :
#ifdef ENABLE_ELUNA
elunaEvents(NULL),
elunaEvents(nullptr),
#endif /* ENABLE_ELUNA */
m_currMap(NULL),
m_mapId(0), m_InstanceId(0),
Expand All @@ -920,7 +921,7 @@ WorldObject::~WorldObject()
{
#ifdef ENABLE_ELUNA
delete elunaEvents;
elunaEvents = NULL;
elunaEvents = nullptr;
#endif /* ENABLE_ELUNA */
}

Expand All @@ -932,7 +933,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 @@ -1578,13 +1582,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 @@ -1644,7 +1641,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 @@ -2060,3 +2060,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 @@ -78,7 +81,9 @@ class UpdateMask;
class InstanceData;
class TerrainInfo;
#ifdef ENABLE_ELUNA
class Eluna;
class ElunaEventProcessor;
class LuaVal;
#endif /* ENABLE_ELUNA */
struct MangosStringLocale;

Expand Down Expand Up @@ -689,6 +694,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 68fe95a

Please sign in to comment.