diff --git a/ElunaCompat.cpp b/ElunaCompat.cpp
index 9dfdc79b6e..c7c5a62862 100644
--- a/ElunaCompat.cpp
+++ b/ElunaCompat.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 - 2022 Eluna Lua Engine
+ * Copyright (C) 2010 - 2024 Eluna Lua Engine
* This program is free software licensed under GPL version 3
* Please see the included DOCS/LICENSE.md for more information
*/
@@ -62,7 +62,7 @@ int lua_absindex(lua_State* L, int i) {
return i;
}
-#ifndef LUAJIT_VERSION
+#if !defined LUAJIT_VERSION
void* luaL_testudata(lua_State* L, int index, const char* tname) {
void* ud = lua_touserdata(L, index);
if (ud)
diff --git a/ElunaCompat.h b/ElunaCompat.h
index d4fc4fd4b0..db6ef2a223 100644
--- a/ElunaCompat.h
+++ b/ElunaCompat.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 - 2022 Eluna Lua Engine
+ * Copyright (C) 2010 - 2024 Eluna Lua Engine
* This program is free software licensed under GPL version 3
* Please see the included DOCS/LICENSE.md for more information
*/
@@ -27,7 +27,7 @@ extern "C"
#define lua_load(L, buf_read, dec_buf, str, NULL) \
lua_load(L, buf_read, dec_buf, str)
-#ifndef LUAJIT_VERSION
+#if !defined LUAJIT_VERSION
void* luaL_testudata(lua_State* L, int index, const char* tname);
void luaL_setmetatable(lua_State* L, const char* tname);
#define luaL_setfuncs(L, l, n) luaL_register(L, NULL, l)
diff --git a/ElunaConfig.cpp b/ElunaConfig.cpp
index 273fa58111..e5657bdc0a 100644
--- a/ElunaConfig.cpp
+++ b/ElunaConfig.cpp
@@ -45,20 +45,20 @@ void ElunaConfig::Initialize()
void ElunaConfig::SetConfig(ElunaConfigBoolValues index, char const* fieldname, bool defvalue)
{
-#ifdef TRINITY
+#if defined TRINITY
SetConfig(index, sConfigMgr->GetBoolDefault(fieldname, defvalue));
-#elif defined CMANGOS || defined VMANGOS || defined MANGOS
+#else
SetConfig(index, sConfig.GetBoolDefault(fieldname, defvalue));
#endif
}
void ElunaConfig::SetConfig(ElunaConfigStringValues index, char const* fieldname, std::string defvalue)
{
-#ifdef TRINITY
+#if defined TRINITY
SetConfig(index, sConfigMgr->GetStringDefault(fieldname, defvalue));
-#elif CMANGOS
+#elif defined CMANGOS
SetConfig(index, sConfig.GetStringDefault(fieldname, defvalue));
-#elif defined VMANGOS || defined MANGOS
+#else
SetConfig(index, sConfig.GetStringDefault(fieldname, defvalue.c_str()));
#endif
}
diff --git a/ElunaCreatureAI.h b/ElunaCreatureAI.h
index ec851c58d4..a1623b5c2b 100644
--- a/ElunaCreatureAI.h
+++ b/ElunaCreatureAI.h
@@ -8,52 +8,46 @@
#define _ELUNA_CREATURE_AI_H
#include "LuaEngine.h"
-#ifdef CMANGOS
+#if defined CMANGOS
#include "AI/BaseAI/CreatureAI.h"
#endif
-#if defined TRINITY || AZEROTHCORE
+#if defined TRINITY
struct ScriptedAI;
+typedef ScriptedAI NativeScriptedAI;
#elif defined CMANGOS
class CreatureAI;
+typedef CreatureAI NativeScriptedAI;
#elif defined VMANGOS
class BasicAI;
-typedef BasicAI ScriptedAI;
+typedef BasicAI NativeScriptedAI;
#else
class AggressorAI;
-typedef AggressorAI ScriptedAI;
+typedef AggressorAI NativeScriptedAI;
#endif
-#ifndef CMANGOS
-struct ElunaCreatureAI : ScriptedAI
-#else
-struct ElunaCreatureAI : CreatureAI
-#endif
+struct ElunaCreatureAI : NativeScriptedAI
{
// used to delay the spawn hook triggering on AI creation
bool justSpawned;
// used to delay movementinform hook (WP hook)
std::vector< std::pair > movepoints;
-#if defined MANGOS || defined CMANGOS || defined VMANGOS
+#if !defined TRINITY
#define me m_creature
#endif
-#ifndef CMANGOS
- ElunaCreatureAI(Creature* creature) : ScriptedAI(creature), justSpawned(true)
-#else
- ElunaCreatureAI(Creature* creature) : CreatureAI(creature), justSpawned(true)
-#endif
+ ElunaCreatureAI(Creature* creature) : NativeScriptedAI(creature), justSpawned(true)
{
}
~ElunaCreatureAI() { }
//Called at World update tick
-#ifndef TRINITY
+#if !defined TRINITY
void UpdateAI(const uint32 diff) override
#else
void UpdateAI(uint32 diff) override
#endif
{
-#ifndef TRINITY
+#if !defined TRINITY
if (justSpawned)
{
justSpawned = false;
@@ -61,66 +55,47 @@ struct ElunaCreatureAI : CreatureAI
JustRespawned();
}
#endif
-
if (!movepoints.empty())
{
for (auto& point : movepoints)
{
-#ifndef CMANGOS
- if (!me->GetEluna()->MovementInform(me, point.first, point.second))
- ScriptedAI::MovementInform(point.first, point.second);
-#else
if (!me->GetEluna()->MovementInform(me, point.first, point.second))
- CreatureAI::MovementInform(point.first, point.second);
-#endif
+ NativeScriptedAI::MovementInform(point.first, point.second);
}
movepoints.clear();
}
if (!me->GetEluna()->UpdateAI(me, diff))
{
-#if defined TRINITY || AZEROTHCORE || VMANGOS
- if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
- ScriptedAI::UpdateAI(diff);
-#elif defined CMANGOS
- if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
- CreatureAI::UpdateAI(diff);
-#else
+#if defined MANGOS
if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE))
- ScriptedAI::UpdateAI(diff);
+#else
+ if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
#endif
+ NativeScriptedAI::UpdateAI(diff);
}
}
-#ifdef TRINITY
+#if defined 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
{
if (!me->GetEluna()->EnterCombat(me, target))
- ScriptedAI::JustEngagedWith(target);
+ NativeScriptedAI::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
{
-#ifndef CMANGOS
- if (!me->GetEluna()->EnterCombat(me, target))
- ScriptedAI::EnterCombat(target);
-#else
if (!me->GetEluna()->EnterCombat(me, target))
- CreatureAI::EnterCombat(target);
-#endif
+ NativeScriptedAI::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) || CMANGOS) && !defined CATA)
- void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damageType, SpellInfo const* spellInfo) override
-#elif defined CATA && defined CMANGOS
+#if defined TRINITY || defined CMANGOS
void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damageType, SpellInfo const* spellInfo) override
#else
void DamageTaken(Unit* attacker, uint32& damage) override
@@ -128,14 +103,10 @@ struct ElunaCreatureAI : CreatureAI
{
if (!me->GetEluna()->DamageTaken(me, attacker, damage))
{
-#if defined AZEROTHCORE
- ScriptedAI::DamageTaken(attacker, damage, damagetype, damageSchoolMask);
-#elif defined TRINITY && !defined CATA
- ScriptedAI::DamageTaken(attacker, damage, damageType, spellInfo);
-#elif defined CMANGOS
- CreatureAI::DamageTaken(attacker, damage, damageType, spellInfo);
+#if defined TRINITY || defined CMANGOS
+ NativeScriptedAI::DamageTaken(attacker, damage, damageType, spellInfo);
#else
- ScriptedAI::DamageTaken(attacker, damage);
+ NativeScriptedAI::DamageTaken(attacker, damage);
#endif
}
}
@@ -143,49 +114,29 @@ struct ElunaCreatureAI : CreatureAI
//Called at creature death
void JustDied(Unit* killer) override
{
-#ifndef CMANGOS
if (!me->GetEluna()->JustDied(me, killer))
- ScriptedAI::JustDied(killer);
-#else
- if (!me->GetEluna()->JustDied(me, killer))
- CreatureAI::JustDied(killer);
-#endif
+ NativeScriptedAI::JustDied(killer);
}
//Called at creature killing another unit
void KilledUnit(Unit* victim) override
{
-#ifndef CMANGOS
- if (!me->GetEluna()->KilledUnit(me, victim))
- ScriptedAI::KilledUnit(victim);
-#else
if (!me->GetEluna()->KilledUnit(me, victim))
- CreatureAI::KilledUnit(victim);
-#endif
+ NativeScriptedAI::KilledUnit(victim);
}
// Called when the creature summon successfully other creature
void JustSummoned(Creature* summon) override
{
-#ifndef CMANGOS
- if (!me->GetEluna()->JustSummoned(me, summon))
- ScriptedAI::JustSummoned(summon);
-#else
if (!me->GetEluna()->JustSummoned(me, summon))
- CreatureAI::JustSummoned(summon);
-#endif
+ NativeScriptedAI::JustSummoned(summon);
}
// Called when a summoned creature is despawned
void SummonedCreatureDespawn(Creature* summon) override
{
-#ifndef CMANGOS
if (!me->GetEluna()->SummonedCreatureDespawn(me, summon))
- ScriptedAI::SummonedCreatureDespawn(summon);
-#else
- if (!me->GetEluna()->SummonedCreatureDespawn(me, summon))
- CreatureAI::SummonedCreatureDespawn(summon);
-#endif
+ NativeScriptedAI::SummonedCreatureDespawn(summon);
}
//Called at waypoint reached or PointMovement end
@@ -199,94 +150,59 @@ struct ElunaCreatureAI : CreatureAI
// Called before EnterCombat even before the creature is in combat.
void AttackStart(Unit* target) override
{
-#ifndef CMANGOS
- if (!me->GetEluna()->AttackStart(me, target))
- ScriptedAI::AttackStart(target);
-#else
if (!me->GetEluna()->AttackStart(me, target))
- CreatureAI::AttackStart(target);
-#endif
+ NativeScriptedAI::AttackStart(target);
}
-#ifdef TRINITY
+#if defined TRINITY
// Called for reaction at stopping attack at no attackers or targets
void EnterEvadeMode(EvadeReason /*why*/) override
- {
- if (!me->GetEluna()->EnterEvadeMode(me))
- ScriptedAI::EnterEvadeMode();
- }
#else
- // Called for reaction at stopping attack at no attackers or targets
void EnterEvadeMode() override
+#endif
{
-#ifndef CMANGOS
if (!me->GetEluna()->EnterEvadeMode(me))
- ScriptedAI::EnterEvadeMode();
-#else
- if (!me->GetEluna()->EnterEvadeMode(me))
- CreatureAI::EnterEvadeMode();
-#endif
+ NativeScriptedAI::EnterEvadeMode();
}
-#endif
-#ifdef TRINITY
+#if defined TRINITY
// Called when creature appears in the world (spawn, respawn, grid load etc...)
void JustAppeared() override
{
if (!me->GetEluna()->JustRespawned(me))
- ScriptedAI::JustAppeared();
+ NativeScriptedAI::JustAppeared();
}
#else
// Called when creature is spawned or respawned (for reseting variables)
void JustRespawned() override
{
-#ifndef CMANGOS
if (!me->GetEluna()->JustRespawned(me))
- ScriptedAI::JustRespawned();
-#else
- if (!me->GetEluna()->JustRespawned(me))
- CreatureAI::JustRespawned();
-#endif
+ NativeScriptedAI::JustRespawned();
}
#endif
// Called at reaching home after evade
void JustReachedHome() override
{
-#ifndef CMANGOS
- if (!me->GetEluna()->JustReachedHome(me))
- ScriptedAI::JustReachedHome();
-#else
if (!me->GetEluna()->JustReachedHome(me))
- CreatureAI::JustReachedHome();
-#endif
+ NativeScriptedAI::JustReachedHome();
}
// Called at text emote receive from player
void ReceiveEmote(Player* player, uint32 emoteId) override
{
-#ifndef CMANGOS
if (!me->GetEluna()->ReceiveEmote(me, player, emoteId))
- ScriptedAI::ReceiveEmote(player, emoteId);
-#else
- if (!me->GetEluna()->ReceiveEmote(me, player, emoteId))
- CreatureAI::ReceiveEmote(player, emoteId);
-#endif
+ NativeScriptedAI::ReceiveEmote(player, emoteId);
}
// called when the corpse of this creature gets removed
void CorpseRemoved(uint32& respawnDelay) override
{
-#ifndef CMANGOS
if (!me->GetEluna()->CorpseRemoved(me, respawnDelay))
- ScriptedAI::CorpseRemoved(respawnDelay);
-#else
- if (!me->GetEluna()->CorpseRemoved(me, respawnDelay))
- CreatureAI::CorpseRemoved(respawnDelay);
-#endif
+ NativeScriptedAI::CorpseRemoved(respawnDelay);
}
-#if !defined TRINITY && !AZEROTHCORE && !VMANGOS
+#if !defined TRINITY && !defined VMANGOS
// Enables use of MoveInLineOfSight
bool IsVisible(Unit* who) const override
{
@@ -296,13 +212,8 @@ struct ElunaCreatureAI : CreatureAI
void MoveInLineOfSight(Unit* who) override
{
-#ifndef CMANGOS
if (!me->GetEluna()->MoveInLineOfSight(me, who))
- ScriptedAI::MoveInLineOfSight(who);
-#else
- if (!me->GetEluna()->MoveInLineOfSight(me, who))
- CreatureAI::MoveInLineOfSight(who);
-#endif
+ NativeScriptedAI::MoveInLineOfSight(who);
}
// Called when hit by a spell
@@ -314,13 +225,8 @@ struct ElunaCreatureAI : CreatureAI
void SpellHit(Unit* caster, SpellInfo const* spell) override
#endif
{
-#ifndef CMANGOS
- if (!me->GetEluna()->SpellHit(me, caster, spell))
- ScriptedAI::SpellHit(caster, spell);
-#else
if (!me->GetEluna()->SpellHit(me, caster, spell))
- CreatureAI::SpellHit(caster, spell);
-#endif
+ NativeScriptedAI::SpellHit(caster, spell);
}
// Called when spell hits a target
@@ -330,13 +236,8 @@ struct ElunaCreatureAI : CreatureAI
void SpellHitTarget(Unit* target, SpellInfo const* spell) override
#endif
{
-#ifndef CMANGOS
- if (!me->GetEluna()->SpellHitTarget(me, target, spell))
- ScriptedAI::SpellHitTarget(target, spell);
-#else
if (!me->GetEluna()->SpellHitTarget(me, target, spell))
- CreatureAI::SpellHitTarget(target, spell);
-#endif
+ NativeScriptedAI::SpellHitTarget(target, spell);
}
#if defined TRINITY
@@ -344,27 +245,27 @@ struct ElunaCreatureAI : CreatureAI
void IsSummonedBy(WorldObject* summoner) override
{
if (!summoner->ToUnit() || !me->GetEluna()->OnSummoned(me, summoner->ToUnit()))
- ScriptedAI::IsSummonedBy(summoner);
+ NativeScriptedAI::IsSummonedBy(summoner);
}
void SummonedCreatureDies(Creature* summon, Unit* killer) override
{
if (!me->GetEluna()->SummonedCreatureDies(me, summon, killer))
- ScriptedAI::SummonedCreatureDies(summon, killer);
+ NativeScriptedAI::SummonedCreatureDies(summon, killer);
}
// Called when owner takes damage
void OwnerAttackedBy(Unit* attacker) override
{
if (!me->GetEluna()->OwnerAttackedBy(me, attacker))
- ScriptedAI::OwnerAttackedBy(attacker);
+ NativeScriptedAI::OwnerAttackedBy(attacker);
}
// Called when owner attacks something
void OwnerAttacked(Unit* target) override
{
if (!me->GetEluna()->OwnerAttacked(me, target))
- ScriptedAI::OwnerAttacked(target);
+ NativeScriptedAI::OwnerAttacked(target);
}
#endif
diff --git a/ElunaEventMgr.cpp b/ElunaEventMgr.cpp
index 5a91c264ac..7ee65316c2 100644
--- a/ElunaEventMgr.cpp
+++ b/ElunaEventMgr.cpp
@@ -6,7 +6,7 @@
#include "ElunaEventMgr.h"
#include "LuaEngine.h"
-#ifndef CMANGOS
+#if !defined CMANGOS
#include "Object.h"
#else
#include "Entities/Object.h"
diff --git a/ElunaEventMgr.h b/ElunaEventMgr.h
index 0d86521bc0..72a8f1d1cd 100644
--- a/ElunaEventMgr.h
+++ b/ElunaEventMgr.h
@@ -9,7 +9,7 @@
#include "ElunaUtility.h"
#include "Common.h"
-#ifdef TRINITY
+#if defined TRINITY
#include "Random.h"
#elif defined CMANGOS
#include "Util/Util.h"
@@ -18,7 +18,7 @@
#endif
#include