Skip to content

Commit

Permalink
Chore: Remove unused #if statement (TrinityCore, Mangos, AzerothCore,…
Browse files Browse the repository at this point in the history
… TBC, Classic, Mists, Cata) (#217)
  • Loading branch information
iThorgrim authored Jan 21, 2025
1 parent 16173cb commit 2e89531
Show file tree
Hide file tree
Showing 35 changed files with 60 additions and 2,504 deletions.
84 changes: 0 additions & 84 deletions src/LuaEngine/ElunaCreatureAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,29 @@

#include "LuaEngine.h"

#if defined TRINITY || AZEROTHCORE
struct ScriptedAI;
#else
class AggressorAI;
typedef AggressorAI ScriptedAI;
#endif

struct ElunaCreatureAI : ScriptedAI
{
// used to delay the spawn hook triggering on AI creation
bool justSpawned;
// used to delay movementinform hook (WP hook)
std::vector< std::pair<uint32, uint32> > movepoints;
#if defined MANGOS || defined CMANGOS
#define me m_creature
#endif

ElunaCreatureAI(Creature* creature) : ScriptedAI(creature), justSpawned(true)
{
}
~ElunaCreatureAI() { }

//Called at World update tick
#ifndef TRINITY
void UpdateAI(const uint32 diff) override
#else
void UpdateAI(uint32 diff) override
#endif
{
#ifdef TRINITY
//Spawns are handled by Creature.cpp - in function Creature::Update()
#else
if (justSpawned)
{
justSpawned = false;

JustRespawned();
}
#endif

if (!movepoints.empty())
{
Expand All @@ -61,52 +45,25 @@ struct ElunaCreatureAI : ScriptedAI

if (!sEluna->UpdateAI(me, diff))
{
#if defined TRINITY || AZEROTHCORE
if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
ScriptedAI::UpdateAI(diff);
#else
if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE))
ScriptedAI::UpdateAI(diff);
#endif
}
}

#if defined TRINITY || AZEROTHCORE
// Called for reaction when initially engaged - this will always happen _after_ JustEnteredCombat
// Called at creature aggro either by MoveInLOS or Attack Start
void JustEngagedWith(Unit* target) override
{
if (!sEluna->EnterCombat(me, target))
ScriptedAI::JustEngagedWith(target);
}
#else
//Called for reaction at enter to combat if not in combat yet (enemy can be NULL)
//Called at creature aggro either by MoveInLOS or Attack Start
void EnterCombat(Unit* target) override
{
if (!sEluna->EnterCombat(me, target))
ScriptedAI::EnterCombat(target);
}
#endif

// Called at any Damage from any attacker (before damage apply)
#if defined AZEROTHCORE
void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask) override
#elif defined TRINITY
void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damageType, SpellInfo const* spellInfo) override
#else
void DamageTaken(Unit* attacker, uint32& damage) override
#endif
{
if (!sEluna->DamageTaken(me, attacker, damage))
{
#if defined AZEROTHCORE
ScriptedAI::DamageTaken(attacker, damage, damagetype, damageSchoolMask);
#elif defined TRINITY
ScriptedAI::DamageTaken(attacker, damage, damageType, spellInfo);
#else
ScriptedAI::DamageTaken(attacker, damage);
#endif
}
}

Expand Down Expand Up @@ -160,21 +117,12 @@ struct ElunaCreatureAI : ScriptedAI
ScriptedAI::EnterEvadeMode();
}

#ifdef TRINITY
// Called when creature appears in the world (spawn, respawn, grid load etc...)
void JustAppeared() override
{
if (!sEluna->JustRespawned(me))
ScriptedAI::JustAppeared();
}
#else
// Called when creature is spawned or respawned (for reseting variables)
void JustRespawned() override
{
if (!sEluna->JustRespawned(me))
ScriptedAI::JustRespawned();
}
#endif

// Called at reaching home after evade
void JustReachedHome() override
Expand All @@ -197,59 +145,32 @@ struct ElunaCreatureAI : ScriptedAI
ScriptedAI::CorpseRemoved(respawnDelay);
}

#if !defined TRINITY && !AZEROTHCORE
// Enables use of MoveInLineOfSight
bool IsVisible(Unit* who) const override
{
return true;
}
#endif

void MoveInLineOfSight(Unit* who) override
{
if (!sEluna->MoveInLineOfSight(me, who))
ScriptedAI::MoveInLineOfSight(who);
}

// Called when hit by a spell
#if defined TRINITY
void SpellHit(WorldObject* caster, SpellInfo const* spell) override
#else
void SpellHit(Unit* caster, SpellInfo const* spell) override
#endif
{
if (!sEluna->SpellHit(me, caster, spell))
ScriptedAI::SpellHit(caster, spell);
}

// Called when spell hits a target
#if defined TRINITY
void SpellHitTarget(WorldObject* target, SpellInfo const* spell) override
#else
void SpellHitTarget(Unit* target, SpellInfo const* spell) override
#endif
{
if (!sEluna->SpellHitTarget(me, target, spell))
ScriptedAI::SpellHitTarget(target, spell);
}

#if defined TRINITY || AZEROTHCORE

#if defined TRINITY || AZEROTHCORE
// Called when the creature is summoned successfully by other creature
void IsSummonedBy(WorldObject* summoner) override
{
if (!summoner->ToUnit() || !sEluna->OnSummoned(me, summoner->ToUnit()))
ScriptedAI::IsSummonedBy(summoner);
}
#else
// Called when the creature is summoned successfully by other creature
void IsSummonedBy(Unit* summoner) override
{
if (!sEluna->OnSummoned(me, summoner))
ScriptedAI::IsSummonedBy(summoner);
}
#endif

void SummonedCreatureDies(Creature* summon, Unit* killer) override
{
Expand All @@ -270,11 +191,6 @@ struct ElunaCreatureAI : ScriptedAI
if (!sEluna->OwnerAttacked(me, target))
ScriptedAI::OwnerAttacked(target);
}
#endif

#if defined MANGOS || defined CMANGOS
#undef me
#endif
};

#endif
8 changes: 0 additions & 8 deletions src/LuaEngine/ElunaEventMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,10 @@

#include "ElunaUtility.h"
#include "Common.h"
#ifdef TRINITY
#include "Random.h"
#else
#include "Util.h"
#endif
#include <map>

#if defined(TRINITY) || AZEROTHCORE
#include "Define.h"
#else
#include "Platform/Define.h"
#endif

class Eluna;
class EventMgr;
Expand Down
85 changes: 0 additions & 85 deletions src/LuaEngine/ElunaIncludes.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,7 @@
#include "TemporarySummon.h"
#include "WorldPacket.h"
#include "WorldSession.h"

#if defined TRINITY
#include "SpellHistory.h"
#endif

#if defined AZEROTHCORE
#include "MapMgr.h"
#else
#include "MapManager.h"
#endif

#if defined TRINITY || defined AZEROTHCORE
#include "Config.h"
#include "GameEventMgr.h"
#include "GitRevision.h"
Expand All @@ -60,54 +49,17 @@
#include "MotionMaster.h"
#include "DatabaseEnv.h"
#include "Bag.h"
#else
#include "Config/Config.h"
#ifdef CMANGOS
#include "AI/AggressorAI.h"
#else
#include "AggressorAI.h"
#endif
#include "BattleGroundMgr.h"
#include "SQLStorages.h"
#include "revision.h"
#endif

#if (!defined(TBC) && !defined(CLASSIC))
#include "Vehicle.h"
#endif

#ifndef CLASSIC
#include "ArenaTeam.h"
#endif

#ifndef CLASSIC
typedef Opcodes OpcodesList;
#endif

/*
* Note: if you add or change a CORE_NAME or CORE_VERSION #define,
* please update LuaGlobalFunctions::GetCoreName or LuaGlobalFunctions::GetCoreVersion documentation example string.
*/
#ifdef MANGOS
#define CORE_NAME "MaNGOS"
#define CORE_VERSION REVISION_NR
#endif

#ifdef CMANGOS
#define CORE_NAME "cMaNGOS"
#define CORE_VERSION REVISION_DATE " " REVISION_TIME
#endif

#ifdef TRINITY
#define CORE_NAME "TrinityCore"
#define REGEN_TIME_FULL
#endif

#ifdef AZEROTHCORE
#define CORE_NAME "AzerothCore"
#endif

#if defined TRINITY || defined AZEROTHCORE
#define CORE_VERSION (GitRevision::GetFullVersion())
#define eWorld (sWorld)
#define eMapMgr (sMapMgr)
Expand All @@ -118,42 +70,5 @@ typedef Opcodes OpcodesList;
#define eAuctionMgr (sAuctionMgr)
#define eGameEventMgr (sGameEventMgr)
#define eObjectAccessor() ObjectAccessor::
#endif

#ifdef CATA
#define NUM_MSG_TYPES NUM_OPCODE_HANDLERS
#endif

#if !defined TRINITY && !AZEROTHCORE
#define eWorld (&sWorld)
#define eMapMgr (&sMapMgr)
#define eConfigMgr (&sConfig)
#define eGuildMgr (&sGuildMgr)
#define eObjectMgr (&sObjectMgr)
#define eAccountMgr (&sAccountMgr)
#define eAuctionMgr (&sAuctionMgr)
#define eGameEventMgr (&sGameEventMgr)
#define eObjectAccessor() sObjectAccessor.
#define SERVER_MSG_STRING SERVER_MSG_CUSTOM
#define TOTAL_LOCALES MAX_LOCALE
#define TARGETICONCOUNT TARGET_ICON_COUNT
#define MAX_TALENT_SPECS MAX_TALENT_SPEC_COUNT
#define TEAM_NEUTRAL TEAM_INDEX_NEUTRAL

#if defined(TBC) || defined(WOTLK) || defined(CATA)
#define PLAYER_FIELD_LIFETIME_HONORABLE_KILLS PLAYER_FIELD_LIFETIME_HONORBALE_KILLS
#endif

#ifdef TBC
#define SPELL_AURA_MOD_KILL_XP_PCT SPELL_AURA_MOD_XP_PCT
#endif

#if defined(CATA) || defined(MISTS) || (defined(WOTLK) && !defined(MANGOS))
#define UNIT_BYTE2_FLAG_SANCTUARY UNIT_BYTE2_FLAG_SUPPORTABLE
#endif

typedef TemporarySummon TempSummon;
typedef SpellEntry SpellInfo;
#endif // TRINITY

#endif // _ELUNA_INCLUDES_H
8 changes: 0 additions & 8 deletions src/LuaEngine/ElunaInstanceAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "lmarshal.h"


#ifndef TRINITY
void ElunaInstanceAI::Initialize()
{
LOCK_ELUNA;
Expand All @@ -23,7 +22,6 @@ void ElunaInstanceAI::Initialize()

sEluna->OnInitialize(this);
}
#endif

void ElunaInstanceAI::Load(const char* data)
{
Expand Down Expand Up @@ -84,9 +82,7 @@ void ElunaInstanceAI::Load(const char* data)
lua_pop(L, 1);
// Stack: (empty)

#ifndef TRINITY
Initialize();
#endif
}
}
else
Expand All @@ -96,9 +92,7 @@ void ElunaInstanceAI::Load(const char* data)
lua_pop(L, 1);
// Stack: (empty)

#ifndef TRINITY
Initialize();
#endif
}

delete[] decodedData;
Expand All @@ -107,9 +101,7 @@ void ElunaInstanceAI::Load(const char* data)
{
ELUNA_LOG_ERROR("Error while decoding instance data: Data is not valid base-64");

#ifndef TRINITY
Initialize();
#endif
}
}

Expand Down
Loading

0 comments on commit 2e89531

Please sign in to comment.