Skip to content

Commit

Permalink
Preprocessor cleanup (#491)
Browse files Browse the repository at this point in the history
* Change expansion preprocessors
* Remove MANGOS definitions
* Rename core-specific preprocessors
  • Loading branch information
Foereaper authored Jul 25, 2024
1 parent a34affc commit 0844d57
Show file tree
Hide file tree
Showing 24 changed files with 170 additions and 214 deletions.
10 changes: 5 additions & 5 deletions ElunaConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* Please see the included DOCS/LICENSE.md for more information
*/

#if defined TRINITY || defined MANGOS
#if defined ELUNA_TRINITY
#include "Config.h"
#elif defined CMANGOS || defined VMANGOS
#else
#include "Config/Config.h"
#endif
#include "ElunaConfig.h"
Expand Down Expand Up @@ -45,7 +45,7 @@ void ElunaConfig::Initialize()

void ElunaConfig::SetConfig(ElunaConfigBoolValues index, char const* fieldname, bool defvalue)
{
#if defined TRINITY
#if defined ELUNA_TRINITY
SetConfig(index, sConfigMgr->GetBoolDefault(fieldname, defvalue));
#else
SetConfig(index, sConfig.GetBoolDefault(fieldname, defvalue));
Expand All @@ -54,9 +54,9 @@ void ElunaConfig::SetConfig(ElunaConfigBoolValues index, char const* fieldname,

void ElunaConfig::SetConfig(ElunaConfigStringValues index, char const* fieldname, std::string defvalue)
{
#if defined TRINITY
#if defined ELUNA_TRINITY
SetConfig(index, sConfigMgr->GetStringDefault(fieldname, defvalue));
#elif defined CMANGOS
#elif defined ELUNA_CMANGOS
SetConfig(index, sConfig.GetStringDefault(fieldname, defvalue));
#else
SetConfig(index, sConfig.GetStringDefault(fieldname, defvalue.c_str()));
Expand Down
43 changes: 18 additions & 25 deletions ElunaCreatureAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@
#define _ELUNA_CREATURE_AI_H

#include "LuaEngine.h"
#if defined CMANGOS
#if defined ELUNA_CMANGOS
#include "AI/BaseAI/CreatureAI.h"
#endif

#if defined TRINITY
#if defined ELUNA_TRINITY
struct ScriptedAI;
typedef ScriptedAI NativeScriptedAI;
#elif defined CMANGOS
#elif defined ELUNA_CMANGOS
class CreatureAI;
typedef CreatureAI NativeScriptedAI;
#elif defined VMANGOS
#elif defined ELUNA_VMANGOS
class BasicAI;
typedef BasicAI NativeScriptedAI;
#else
class AggressorAI;
typedef AggressorAI NativeScriptedAI;
#endif

struct ElunaCreatureAI : NativeScriptedAI
Expand All @@ -32,7 +29,7 @@ struct ElunaCreatureAI : NativeScriptedAI
bool justSpawned;
// used to delay movementinform hook (WP hook)
std::vector< std::pair<uint32, uint32> > movepoints;
#if !defined TRINITY
#if !defined ELUNA_TRINITY
#define me m_creature
#endif
ElunaCreatureAI(Creature* creature) : NativeScriptedAI(creature), justSpawned(true)
Expand All @@ -41,13 +38,13 @@ struct ElunaCreatureAI : NativeScriptedAI
~ElunaCreatureAI() { }

//Called at World update tick
#if !defined TRINITY
#if !defined ELUNA_TRINITY
void UpdateAI(const uint32 diff) override
#else
void UpdateAI(uint32 diff) override
#endif
{
#if !defined TRINITY
#if !defined ELUNA_TRINITY
if (justSpawned)
{
justSpawned = false;
Expand All @@ -67,16 +64,12 @@ struct ElunaCreatureAI : NativeScriptedAI

if (!me->GetEluna()->UpdateAI(me, diff))
{
#if defined MANGOS
if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE))
#else
if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
#endif
NativeScriptedAI::UpdateAI(diff);
}
}

#if defined TRINITY
#if defined ELUNA_TRINITY
// 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
Expand All @@ -95,15 +88,15 @@ struct ElunaCreatureAI : NativeScriptedAI
#endif

// Called at any Damage from any attacker (before damage apply)
#if defined TRINITY || defined CMANGOS
#if defined ELUNA_TRINITY || defined ELUNA_CMANGOS
void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damageType, SpellInfo const* spellInfo) override
#else
void DamageTaken(Unit* attacker, uint32& damage) override
#endif
{
if (!me->GetEluna()->DamageTaken(me, attacker, damage))
{
#if defined TRINITY || defined CMANGOS
#if defined ELUNA_TRINITY || defined ELUNA_CMANGOS
NativeScriptedAI::DamageTaken(attacker, damage, damageType, spellInfo);
#else
NativeScriptedAI::DamageTaken(attacker, damage);
Expand Down Expand Up @@ -154,7 +147,7 @@ struct ElunaCreatureAI : NativeScriptedAI
NativeScriptedAI::AttackStart(target);
}

#if defined TRINITY
#if defined ELUNA_TRINITY
// Called for reaction at stopping attack at no attackers or targets
void EnterEvadeMode(EvadeReason /*why*/) override
#else
Expand All @@ -165,7 +158,7 @@ struct ElunaCreatureAI : NativeScriptedAI
NativeScriptedAI::EnterEvadeMode();
}

#if defined TRINITY
#if defined ELUNA_TRINITY
// Called when creature appears in the world (spawn, respawn, grid load etc...)
void JustAppeared() override
{
Expand Down Expand Up @@ -202,7 +195,7 @@ struct ElunaCreatureAI : NativeScriptedAI
NativeScriptedAI::CorpseRemoved(respawnDelay);
}

#if !defined TRINITY && !defined VMANGOS
#if !defined ELUNA_TRINITY && !defined ELUNA_VMANGOS
// Enables use of MoveInLineOfSight
bool IsVisible(Unit* who) const override
{
Expand All @@ -217,9 +210,9 @@ struct ElunaCreatureAI : NativeScriptedAI
}

// Called when hit by a spell
#if defined TRINITY
#if defined ELUNA_TRINITY
void SpellHit(WorldObject* caster, SpellInfo const* spell) override
#elif defined VMANGOS
#elif defined ELUNA_VMANGOS
void SpellHit(Unit* caster, SpellInfo const* spell)
#else
void SpellHit(Unit* caster, SpellInfo const* spell) override
Expand All @@ -230,7 +223,7 @@ struct ElunaCreatureAI : NativeScriptedAI
}

// Called when spell hits a target
#if defined TRINITY
#if defined ELUNA_TRINITY
void SpellHitTarget(WorldObject* target, SpellInfo const* spell) override
#else
void SpellHitTarget(Unit* target, SpellInfo const* spell) override
Expand All @@ -240,7 +233,7 @@ struct ElunaCreatureAI : NativeScriptedAI
NativeScriptedAI::SpellHitTarget(target, spell);
}

#if defined TRINITY
#if defined ELUNA_TRINITY
// Called when the creature is summoned successfully by other creature
void IsSummonedBy(WorldObject* summoner) override
{
Expand Down Expand Up @@ -269,7 +262,7 @@ struct ElunaCreatureAI : NativeScriptedAI
}
#endif

#if defined MANGOS || defined CMANGOS
#if !defined ELUNA_TRINITY
#undef me
#endif
};
Expand Down
2 changes: 1 addition & 1 deletion ElunaEventMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "ElunaEventMgr.h"
#include "LuaEngine.h"
#if !defined CMANGOS
#if !defined ELUNA_CMANGOS
#include "Object.h"
#else
#include "Entities/Object.h"
Expand Down
6 changes: 3 additions & 3 deletions ElunaEventMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

#include "ElunaUtility.h"
#include "Common.h"
#if defined TRINITY
#if defined ELUNA_TRINITY
#include "Random.h"
#elif defined CMANGOS
#elif defined ELUNA_CMANGOS
#include "Util/Util.h"
#else
#include "Util.h"
#endif
#include <map>

#if defined TRINITY
#if defined ELUNA_TRINITY
#include "Define.h"
#else
#include "Platform/Define.h"
Expand Down
Loading

0 comments on commit 0844d57

Please sign in to comment.