Skip to content

Commit

Permalink
Change expansion defines to have prefix and add MaNGOS defines
Browse files Browse the repository at this point in the history
MaNGOS uses the CLASSIC, TBC, etc defines as a way to control their multiversion core code so redefining them in Eluna was causing issues.
  • Loading branch information
Niam5 committed Aug 29, 2024
1 parent 5ca638f commit a19a6af
Show file tree
Hide file tree
Showing 21 changed files with 120 additions and 124 deletions.
6 changes: 5 additions & 1 deletion ElunaCreatureAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#if defined ELUNA_TRINITY
struct ScriptedAI;
typedef ScriptedAI NativeScriptedAI;
#elif defined ELUNA_CMANGOS
#elif defined ELUNA_CMANGOS || ELUNA_MANGOS
class CreatureAI;
typedef CreatureAI NativeScriptedAI;
#elif defined ELUNA_VMANGOS
Expand Down Expand Up @@ -64,7 +64,11 @@ struct ElunaCreatureAI : NativeScriptedAI

if (!me->GetEluna()->UpdateAI(me, diff))
{
#if !defined ELUNA_MANGOS
if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
#else
if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE))
#endif
NativeScriptedAI::UpdateAI(diff);
}
}
Expand Down
35 changes: 25 additions & 10 deletions ElunaIncludes.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@
#elif defined ELUNA_VMANGOS
#include "BasicAI.h"
#include "SQLStorages.h"
#elif defined ELUNA_MANGOS
#include "SQLStorages.h"
#endif // ELUNA_TRINITY
#if ELUNA_EXPANSION > CLASSIC
#if ELUNA_EXPANSION > EXP_CLASSIC
#include "ArenaTeam.h"
#endif
#if ELUNA_EXPANSION >= WOTLK
#if ELUNA_EXPANSION >= EXP_WOTLK
#include "Vehicle.h"
#endif
#else
Expand Down Expand Up @@ -94,13 +96,13 @@
#include "Spells/SpellMgr.h"
#include "Tools/Language.h"
#include "Server/SQLStorages.h"
#if ELUNA_EXPANSION > CLASSIC
#if ELUNA_EXPANSION > EXP_CLASSIC
#include "Arena/ArenaTeam.h"
#endif
#if ELUNA_EXPANSION >= WOTLK
#if ELUNA_EXPANSION >= EXP_WOTLK
#include "Entities/Vehicle.h"
#endif
#if ELUNA_EXPANSION >= CATA
#if ELUNA_EXPANSION >= EXP_CATA
#include "AI/BaseAI/AggressorAI.h"
#else
#include "AI/BaseAI/UnitAI.h"
Expand All @@ -110,10 +112,15 @@
#if !defined ELUNA_TRINITY
#include "Config/Config.h"
#include "BattleGroundMgr.h"
#if !defined ELUNA_MANGOS
#include "revision.h"
#else
#include "GitRevision.h"
#include "revision_data.h"
#endif
#endif

#if ELUNA_EXPANSION > CLASSIC
#if ELUNA_EXPANSION > EXP_CLASSIC
typedef Opcodes OpcodesList;
#endif

Expand All @@ -124,7 +131,7 @@ typedef Opcodes OpcodesList;
#if defined ELUNA_CMANGOS
#define CORE_NAME "cMaNGOS"
#define CORE_VERSION REVISION_DATE " " REVISION_ID
#if ELUNA_EXPANSION == CATA
#if ELUNA_EXPANSION == EXP_CATA
#define NUM_MSG_TYPES MAX_OPCODE_TABLE_SIZE
#endif
#endif
Expand All @@ -135,6 +142,14 @@ typedef Opcodes OpcodesList;
#define DEFAULT_LOCALE LOCALE_enUS
#endif

#if defined ELUNA_MANGOS
#define CORE_NAME "MaNGOS"
#define CORE_VERSION PROJECT_REVISION_NR
#if ELUNA_EXPANSION >= EXP_CATA
#define NUM_MSG_TYPES NUM_OPCODE_HANDLERS
#endif
#endif

#if defined ELUNA_TRINITY
#define CORE_NAME "TrinityCore"
#define REGEN_TIME_FULL
Expand Down Expand Up @@ -169,15 +184,15 @@ typedef Opcodes OpcodesList;
#endif


#if ELUNA_EXPANSION >= CATA || defined ELUNA_VMANGOS
#if ELUNA_EXPANSION >= EXP_CATA || defined ELUNA_VMANGOS
#define PLAYER_FIELD_LIFETIME_HONORABLE_KILLS PLAYER_FIELD_LIFETIME_HONORBALE_KILLS
#endif

#if ELUNA_EXPANSION == TBC
#if ELUNA_EXPANSION == EXP_TBC
#define SPELL_AURA_MOD_KILL_XP_PCT SPELL_AURA_MOD_XP_PCT
#endif

#if ELUNA_EXPANSION >= WOTLK
#if ELUNA_EXPANSION >= EXP_WOTLK
#define UNIT_BYTE2_FLAG_SANCTUARY UNIT_BYTE2_FLAG_SUPPORTABLE
#endif

Expand Down
2 changes: 1 addition & 1 deletion ElunaLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace fs = std::filesystem;
#include <Windows.h>
#endif

#if defined ELUNA_TRINITY
#if defined ELUNA_TRINITY || ELUNA_MANGOS
#include "MapManager.h"
#elif defined ELUNA_CMANGOS
#include "Maps/MapManager.h"
Expand Down
8 changes: 6 additions & 2 deletions ElunaUtility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

uint32 ElunaUtil::GetCurrTime()
{
#if defined ELUNA_TRINITY
#if defined ELUNA_TRINITY || ELUNA_MANGOS
return getMSTime();
#else
return WorldTimer::getMSTime();
Expand All @@ -31,7 +31,7 @@ uint32 ElunaUtil::GetCurrTime()

uint32 ElunaUtil::GetTimeDiff(uint32 oldMSTime)
{
#if defined ELUNA_TRINITY
#if defined ELUNA_TRINITY || ELUNA_MANGOS
return GetMSTimeDiffToNow(oldMSTime);
#else
return WorldTimer::getMSTimeDiff(oldMSTime, WorldTimer::getMSTime());
Expand Down Expand Up @@ -98,7 +98,11 @@ bool ElunaUtil::WorldObjectInRangeCheck::operator()(WorldObject* u)
{
if (i_obj_fact)
{
#if !defined ELUNA_MANGOS
if ((i_obj_fact->IsHostileTo(*target->GetFactionTemplateEntry())) != (i_hostile == 1))
#else
if ((i_obj_fact->IsHostileTo(*target->getFactionTemplateEntry())) != (i_hostile == 1))
#endif
return false;
}
else if (i_hostile == 1)
Expand Down
10 changes: 5 additions & 5 deletions ElunaUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

#include "Common.h"

#define CLASSIC 0
#define TBC 1
#define WOTLK 2
#define CATA 3
#define EXP_CLASSIC 0
#define EXP_TBC 1
#define EXP_WOTLK 2
#define EXP_CATA 3

#if !defined ELUNA_CMANGOS
#include "SharedDefines.h"
Expand All @@ -35,7 +35,7 @@
#include <mutex>
#include <memory>

#if !defined ELUNA_VMANGOS
#if defined ELUNA_TRINITY || ELUNA_CMANGOS
#define USING_BOOST
#endif

Expand Down
14 changes: 7 additions & 7 deletions LuaEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ class TemporarySpawn;
typedef TemporarySpawn TempSummon;
#endif

#if defined ELUNA_VMANGOS
#if defined ELUNA_VMANGOS || ELUNA_MANGOS
class TemporarySummon;
typedef TemporarySummon TempSummon;
#endif

#if ELUNA_EXPANSION == CLASSIC
#if ELUNA_EXPANSION == EXP_CLASSIC
typedef int Difficulty;
#endif

#if ELUNA_EXPANSION >= WOTLK
#if ELUNA_EXPANSION >= EXP_WOTLK
class VehicleInfo;
typedef VehicleInfo Vehicle;
#endif
Expand Down Expand Up @@ -461,7 +461,7 @@ class ELUNA_GAME_API Eluna
bool OnQuestAccept(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest);
bool OnQuestReward(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest, uint32 opt);
void GetDialogStatus(const Player* pPlayer, const GameObject* pGameObject);
#if ELUNA_EXPANSION >= WOTLK
#if ELUNA_EXPANSION >= EXP_WOTLK
void OnDestroyed(GameObject* pGameObject, WorldObject* attacker);
void OnDamaged(GameObject* pGameObject, WorldObject* attacker);
#endif
Expand Down Expand Up @@ -489,7 +489,7 @@ class ELUNA_GAME_API Eluna
void OnFreeTalentPointsChanged(Player* pPlayer, uint32 newPoints);
void OnTalentsReset(Player* pPlayer, bool noCost);
void OnMoneyChanged(Player* pPlayer, int32& amount);
#if ELUNA_EXPANSION >= CATA
#if ELUNA_EXPANSION >= EXP_CATA
void OnMoneyChanged(Player* pPlayer, int64& amount);
#endif
void OnGiveXP(Player* pPlayer, uint32& amount, Unit* pVictim);
Expand Down Expand Up @@ -517,7 +517,7 @@ class ELUNA_GAME_API Eluna
void HandleGossipSelectOption(Player* pPlayer, uint32 menuId, uint32 sender, uint32 action, const std::string& code);
void OnAchievementComplete(Player* pPlayer, uint32 achievementId);

#if ELUNA_EXPANSION >= WOTLK
#if ELUNA_EXPANSION >= EXP_WOTLK
/* Vehicle */
void OnInstall(Vehicle* vehicle);
void OnUninstall(Vehicle* vehicle);
Expand Down Expand Up @@ -547,7 +547,7 @@ class ELUNA_GAME_API Eluna
void OnDisband(Guild* guild);
void OnMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, bool isRepair);
void OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount);
#if ELUNA_EXPANSION >= CATA
#if ELUNA_EXPANSION >= EXP_CATA
void OnMemberWitdrawMoney(Guild* guild, Player* player, uint64& amount, bool isRepair);
void OnMemberDepositMoney(Guild* guild, Player* player, uint64& amount);
#endif
Expand Down
2 changes: 1 addition & 1 deletion LuaFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void RegisterFunctions(Eluna* E)
ElunaTemplate<Item>::SetMethods(E, LuaObject::ObjectMethods);
ElunaTemplate<Item>::SetMethods(E, LuaItem::ItemMethods);

#if ELUNA_EXPANSION >= WOTLK
#if ELUNA_EXPANSION >= EXP_WOTLK
ElunaTemplate<Vehicle>::Register(E, "Vehicle");
ElunaTemplate<Vehicle>::SetMethods(E, LuaVehicle::VehicleMethods);
#endif
Expand Down
2 changes: 1 addition & 1 deletion hooks/GameObjectHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void Eluna::GetDialogStatus(const Player* pPlayer, const GameObject* pGameObject
CallAllFunctions(GameObjectEventBindings, key);
}

#if ELUNA_EXPANSION >= WOTLK
#if ELUNA_EXPANSION >= EXP_WOTLK
void Eluna::OnDestroyed(GameObject* pGameObject, WorldObject* attacker)
{
START_HOOK(GAMEOBJECT_EVENT_ON_DESTROYED, pGameObject->GetEntry());
Expand Down
4 changes: 2 additions & 2 deletions hooks/GuildHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void Eluna::OnMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, b
CleanUpStack(4);
}

#if ELUNA_EXPANSION >= CATA
#if ELUNA_EXPANSION >= EXP_CATA
void Eluna::OnMemberWitdrawMoney(Guild* guild, Player* player, uint64& amount, bool isRepair)
{
START_HOOK(GUILD_EVENT_ON_MONEY_WITHDRAW);
Expand Down Expand Up @@ -149,7 +149,7 @@ void Eluna::OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount)
CleanUpStack(3);
}

#if ELUNA_EXPANSION >= CATA
#if ELUNA_EXPANSION >= EXP_CATA
void Eluna::OnMemberDepositMoney(Guild* guild, Player* player, uint64& amount)
{
START_HOOK(GUILD_EVENT_ON_MONEY_DEPOSIT);
Expand Down
2 changes: 1 addition & 1 deletion hooks/PlayerHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ void Eluna::OnMoneyChanged(Player* pPlayer, int32& amount)
CleanUpStack(2);
}

#if ELUNA_EXPANSION >= CATA
#if ELUNA_EXPANSION >= EXP_CATA
void Eluna::OnMoneyChanged(Player* pPlayer, int64& amount)
{
START_HOOK(PLAYER_EVENT_ON_MONEY_CHANGE);
Expand Down
2 changes: 1 addition & 1 deletion hooks/VehicleHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "BindingMap.h"
#include "ElunaTemplate.h"

#if ELUNA_EXPANSION >= WOTLK
#if ELUNA_EXPANSION >= EXP_WOTLK

using namespace Hooks;

Expand Down
Loading

0 comments on commit a19a6af

Please sign in to comment.