Skip to content

Commit

Permalink
Merge 3416217 into 4602e95
Browse files Browse the repository at this point in the history
  • Loading branch information
Foereaper authored Mar 10, 2024
2 parents 4602e95 + 3416217 commit 1a2b2d0
Show file tree
Hide file tree
Showing 47 changed files with 527 additions and 384 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
cmake_minimum_required(VERSION 3.22 FATAL_ERROR)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

Expand All @@ -27,9 +27,9 @@ cmake_policy(SET CMP0042 NEW)
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0063 NEW)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
#set(CMAKE_CXX_STANDARD 17)
#set(CMAKE_CXX_STANDARD_REQUIRED ON)
#set(CMAKE_CXX_EXTENSIONS OFF)

set_property(GLOBAL
PROPERTY USE_FOLDERS ON
Expand Down
2 changes: 1 addition & 1 deletion cmake/PCHSupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function(ADD_CXX_PCH TARGET_NAME PRECOMPILED_HEADER PRECOMPILED_SOURCE)
set(COMPILER_FLAGS "${${CXX_FLAGS}} ${CMAKE_CXX_FLAGS}")
separate_arguments(COMPILER_FLAGS)

set(CXX_STD c++11)
set(CXX_STD c++17)

add_custom_command(
OUTPUT ${OUTPUT_NAME}
Expand Down
2 changes: 1 addition & 1 deletion dep
Submodule dep updated 1 files
+3 −4 acelite/CMakeLists.txt
6 changes: 4 additions & 2 deletions src/game/BattleGround/BattleGround.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,8 @@ 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 +1282,8 @@ void BattleGround::StartBattleGround()
sBattleGroundMgr.AddBattleGround(GetInstanceID(), GetTypeID(), this);

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

Expand Down
3 changes: 2 additions & 1 deletion src/game/BattleGround/BattleGroundMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,8 @@ uint32 BattleGroundMgr::CreateBattleGround(BattleGroundTypeId bgTypeId, uint32 M
AddBattleGround(bg->GetInstanceID(), bg->GetTypeID(), bg);

#ifdef ENABLE_ELUNA
sEluna->OnBGCreate(bg, bgTypeId, bg->GetInstanceID());
if (Eluna* e = bg->GetBgMap()->GetEluna())
e->OnBGCreate(bg, bgTypeId, bg->GetInstanceID());
#endif /* ENABLE_ELUNA */

// return some not-null value, bgTypeId is good enough for me
Expand Down
10 changes: 4 additions & 6 deletions src/game/Object/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,8 @@ void Creature::AddToWorld()

#ifdef ENABLE_ELUNA
if (!inWorld)
{
sEluna->OnAddToWorld(this);
}
if (Eluna* e = GetEluna())
e->OnAddToWorld(this);
#endif /* ENABLE_ELUNA */

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

///- Remove the creature from the accessor
Expand Down
20 changes: 12 additions & 8 deletions src/game/Object/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ 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 +135,8 @@ 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 +248,8 @@ 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 +283,8 @@ 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 +2312,8 @@ 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 +2322,8 @@ 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
18 changes: 12 additions & 6 deletions src/game/Object/Guild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ 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 +265,8 @@ 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 +282,8 @@ 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 +297,8 @@ 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 +623,8 @@ 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 +828,8 @@ 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
3 changes: 2 additions & 1 deletion src/game/Object/Item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ 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
36 changes: 29 additions & 7 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 @@ -932,7 +933,8 @@ 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 @@ -1580,8 +1582,19 @@ void WorldObject::SetMap(Map* map)
m_InstanceId = map->GetInstanceId();

#ifdef ENABLE_ELUNA
if (!elunaEvents)
elunaEvents = new ElunaEventProcessor(&Eluna::GEluna, this);
//@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())
{
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);
#endif
}

Expand Down Expand Up @@ -1640,10 +1653,9 @@ 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())
if (Unit* summoner = ToUnit())
e->OnSummoned(pCreature, summoner);
#endif /* ENABLE_ELUNA */

// Creature Linking, Initial load is handled like respawn
Expand Down Expand Up @@ -2058,3 +2070,13 @@ void WorldObject::SetActiveObjectState(bool active)
}
m_isActiveObject = active;
}

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

return nullptr;
}
#endif
10 changes: 10 additions & 0 deletions src/game/Object/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

#include <set>

#ifdef ENABLE_ELUNA
#include "LuaValue.h"
#endif

#define CONTACT_DISTANCE 0.5f
#define INTERACTION_DISTANCE 5.0f
#define ATTACK_DISTANCE 5.0f
Expand Down Expand Up @@ -78,7 +82,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 +695,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 1a2b2d0

Please sign in to comment.