Skip to content

Commit

Permalink
Change expansion preprocessors
Browse files Browse the repository at this point in the history
Requires changing cmake definitions to nummeric EXPANSION definition
  • Loading branch information
Foereaper committed Jul 23, 2024
1 parent a34affc commit df7c0ae
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 87 deletions.
93 changes: 39 additions & 54 deletions ElunaIncludes.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#if !defined CMANGOS
#include "AccountMgr.h"
#include "AuctionHouseMgr.h"
#include "Bag.h"
#include "Cell.h"
#include "CellImpl.h"
#include "Channel.h"
Expand Down Expand Up @@ -39,6 +40,28 @@
#include "TemporarySummon.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#if defined TRINITY
#include "Battleground.h"
#include "Config.h"
#include "DatabaseEnv.h"
#include "GitRevision.h"
#include "GroupMgr.h"
#include "MiscPackets.h"
#include "MotionMaster.h"
#include "ScriptedCreature.h"
#include "SpellHistory.h"
#include "SpellInfo.h"
#include "WeatherMgr.h"
#elif defined VMANGOS
#include "BasicAI.h"
#include "SQLStorages.h"
#endif // TRINITY
#if EXPANSION > CLASSIC
#include "ArenaTeam.h"
#endif
#if EXPANSION >= WOTLK
#include "Vehicle.h"
#endif
#else
#include "Accounts/AccountMgr.h"
#include "AuctionHouse/AuctionHouseMgr.h"
Expand Down Expand Up @@ -70,65 +93,27 @@
#include "Spells/SpellAuras.h"
#include "Spells/SpellMgr.h"
#include "Tools/Language.h"
#endif

#if defined TRINITY
#include "Bag.h"
#include "Battleground.h"
#include "Config.h"
#include "DatabaseEnv.h"
#include "GameEventMgr.h"
#include "GitRevision.h"
#include "GroupMgr.h"
#include "MiscPackets.h"
#include "MotionMaster.h"
#include "ScriptedCreature.h"
#include "SpellHistory.h"
#include "SpellInfo.h"
#include "WeatherMgr.h"
#else
#include "Config/Config.h"
#if defined CMANGOS && defined CATA
#include "AI/BaseAI/AggressorAI.h"
#include "Server/SQLStorages.h"
#elif defined CMANGOS
#include "AI/BaseAI/UnitAI.h"
#include "Server/SQLStorages.h"
#elif defined VMANGOS
#include "BasicAI.h"
#include "Bag.h"
#else
#include "AggressorAI.h"
#include "SQLStorages.h"
#if EXPANSION > CLASSIC
#include "Arena/ArenaTeam.h"
#endif
#include "BattleGroundMgr.h"
#if !defined CMANGOS
#include "SQLStorages.h"
#else
#include "Server/SQLStorages.h"
#if EXPANSION >= WOTLK
#include "Entities/Vehicle.h"
#endif
#if defined MANGOS
#include "GitRevision.h"
#else
#include "revision.h"
#if EXPANSION >= CATA
#include "AI/BaseAI/AggressorAI.h"
#endif
#endif

#if !defined TBC && !defined CLASSIC
#if !defined CMANGOS
#include "Vehicle.h"
#else
#include "Entities/Vehicle.h"
#endif
#if !defined TRINITY
#include "Config/Config.h"
#include "BattleGroundMgr.h"
#include "revision.h"
#endif

#if !defined CLASSIC
#if EXPANSION > CLASSIC
typedef Opcodes OpcodesList;
#if !defined CMANGOS
#include "ArenaTeam.h"
#else
#include "Arena/ArenaTeam.h"
#endif
#endif

/*
Expand All @@ -138,15 +123,15 @@ typedef Opcodes OpcodesList;
#if defined MANGOS
#define CORE_NAME "MaNGOS"
#define CORE_VERSION REVISION_NR
#if defined CATA
#if EXPANSION == CATA
#define NUM_MSG_TYPES NUM_OPCODE_HANDLERS
#endif
#endif

#if defined CMANGOS
#define CORE_NAME "cMaNGOS"
#define CORE_VERSION REVISION_DATE " " REVISION_ID
#if defined CATA
#if EXPANSION == CATA
#define NUM_MSG_TYPES MAX_OPCODE_TABLE_SIZE
#endif
#endif
Expand Down Expand Up @@ -191,15 +176,15 @@ typedef Opcodes OpcodesList;
#endif


#if (defined CATA && !defined MANGOS) || defined VMANGOS
#if EXPANSION >= CATA || defined VMANGOS
#define PLAYER_FIELD_LIFETIME_HONORABLE_KILLS PLAYER_FIELD_LIFETIME_HONORBALE_KILLS
#endif

#if defined TBC
#if EXPANSION == TBC
#define SPELL_AURA_MOD_KILL_XP_PCT SPELL_AURA_MOD_XP_PCT
#endif

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

Expand Down
8 changes: 0 additions & 8 deletions ElunaUtility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,8 @@ bool ElunaUtil::WorldObjectInRangeCheck::operator()(WorldObject* u)
{
if (i_obj_fact)
{
#if (defined TRINITY || CMANGOS || VMANGOS) && !defined CATA
if ((i_obj_fact->IsHostileTo(*target->GetFactionTemplateEntry())) != (i_hostile == 1))
return false;
#elif defined CATA && defined CMANGOS
if ((i_obj_fact->IsHostileTo(*target->GetFactionTemplateEntry())) != (i_hostile == 1))
return false;
#else
if ((i_obj_fact->IsHostileTo(*target->getFactionTemplateEntry())) != (i_hostile == 1))
return false;
#endif
}
else if (i_hostile == 1)
return false;
Expand Down
5 changes: 5 additions & 0 deletions ElunaUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@

#include "Common.h"

#define CLASSIC 0
#define TBC 1
#define WOTLK 2
#define CATA 3

#if !defined CMANGOS
#include "SharedDefines.h"
#include "ObjectGuid.h"
Expand Down
14 changes: 7 additions & 7 deletions LuaEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ class TemporarySummon;
typedef TemporarySummon TempSummon;
#endif

#if defined CLASSIC
#if EXPANSION == CLASSIC
typedef int Difficulty;
#endif

#if !defined CLASSIC && !defined TBC
#if EXPANSION >= 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 !defined CLASSIC && !defined TBC
#if EXPANSION >= 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 defined CATA
#if EXPANSION >= 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 !defined CLASSIC && !defined TBC
#if EXPANSION >= WOTLK
/* Vehicle */
void OnInstall(Vehicle* vehicle);
void OnUninstall(Vehicle* vehicle);
Expand Down Expand Up @@ -546,11 +546,11 @@ class ELUNA_GAME_API Eluna
void OnCreate(Guild* guild, Player* leader, const std::string& name);
void OnDisband(Guild* guild);
void OnMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, bool isRepair);
#if defined CATA
#if EXPANSION >= CATA
void OnMemberWitdrawMoney(Guild* guild, Player* player, uint64& amount, bool isRepair);
#endif
void OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount);
#if defined CATA
#if EXPANSION >= CATA
void OnMemberDepositMoney(Guild* guild, Player* player, uint64& amount);
#endif
void OnItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId, bool isDestBank, uint8 destContainer, uint8 destSlotId);
Expand Down
2 changes: 1 addition & 1 deletion LuaFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void RegisterFunctions(Eluna* E)
ElunaTemplate<Item>::SetMethods(E, LuaObject::ObjectMethods);
ElunaTemplate<Item>::SetMethods(E, LuaItem::ItemMethods);

#if !defined CLASSIC && !defined TBC
#if EXPANSION >= 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 !defined(CLASSIC) && !defined(TBC)
#if EXPANSION >= WOTLK
void Eluna::OnDestroyed(GameObject* pGameObject, WorldObject* attacker)
{
START_HOOK(GAMEOBJECT_EVENT_ON_DESTROYED, pGameObject->GetEntry());
Expand Down
22 changes: 11 additions & 11 deletions hooks/GossipHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using namespace Hooks;
bool Eluna::OnGossipHello(Player* pPlayer, GameObject* pGameObject)
{
START_HOOK_WITH_RETVAL(GameObjectGossipBindings, GOSSIP_EVENT_ON_HELLO, pGameObject->GetEntry(), false);
#if defined CMANGOS && !defined CATA
#if defined CMANGOS && EXPANSION < CATA
pPlayer->GetPlayerMenu()->ClearMenus();
#else
pPlayer->PlayerTalkClass->ClearMenus();
Expand All @@ -39,7 +39,7 @@ bool Eluna::OnGossipHello(Player* pPlayer, GameObject* pGameObject)
bool Eluna::OnGossipSelect(Player* pPlayer, GameObject* pGameObject, uint32 sender, uint32 action)
{
START_HOOK_WITH_RETVAL(GameObjectGossipBindings, GOSSIP_EVENT_ON_SELECT, pGameObject->GetEntry(), false);
#if defined CMANGOS && !defined CATA
#if defined CMANGOS && EXPANSION < CATA
pPlayer->GetPlayerMenu()->ClearMenus();
#else
pPlayer->PlayerTalkClass->ClearMenus();
Expand All @@ -54,7 +54,7 @@ bool Eluna::OnGossipSelect(Player* pPlayer, GameObject* pGameObject, uint32 send
bool Eluna::OnGossipSelectCode(Player* pPlayer, GameObject* pGameObject, uint32 sender, uint32 action, const char* code)
{
START_HOOK_WITH_RETVAL(GameObjectGossipBindings, GOSSIP_EVENT_ON_SELECT, pGameObject->GetEntry(), false);
#if defined CMANGOS && !defined CATA
#if defined CMANGOS && EXPANSION < CATA
pPlayer->GetPlayerMenu()->ClearMenus();
#else
pPlayer->PlayerTalkClass->ClearMenus();
Expand All @@ -70,7 +70,7 @@ bool Eluna::OnGossipSelectCode(Player* pPlayer, GameObject* pGameObject, uint32
void Eluna::HandleGossipSelectOption(Player* pPlayer, uint32 menuId, uint32 sender, uint32 action, const std::string& code)
{
START_HOOK(PlayerGossipBindings, GOSSIP_EVENT_ON_SELECT, menuId);
#if defined CMANGOS && !defined CATA
#if defined CMANGOS && EXPANSION < CATA
pPlayer->GetPlayerMenu()->ClearMenus();
#else
pPlayer->PlayerTalkClass->ClearMenus();
Expand All @@ -91,7 +91,7 @@ void Eluna::HandleGossipSelectOption(Player* pPlayer, uint32 menuId, uint32 send
bool Eluna::OnItemGossip(Player* pPlayer, Item* pItem, SpellCastTargets const& /*targets*/)
{
START_HOOK_WITH_RETVAL(ItemGossipBindings, GOSSIP_EVENT_ON_HELLO, pItem->GetEntry(), true);
#if defined CMANGOS && !defined CATA
#if defined CMANGOS && EXPANSION < CATA
pPlayer->GetPlayerMenu()->ClearMenus();
#else
pPlayer->PlayerTalkClass->ClearMenus();
Expand All @@ -104,7 +104,7 @@ bool Eluna::OnItemGossip(Player* pPlayer, Item* pItem, SpellCastTargets const& /
void Eluna::HandleGossipSelectOption(Player* pPlayer, Item* pItem, uint32 sender, uint32 action, const std::string& code)
{
START_HOOK(ItemGossipBindings, GOSSIP_EVENT_ON_SELECT, pItem->GetEntry());
#if defined CMANGOS && !defined CATA
#if defined CMANGOS && EXPANSION < CATA
pPlayer->GetPlayerMenu()->ClearMenus();
#else
pPlayer->PlayerTalkClass->ClearMenus();
Expand All @@ -125,7 +125,7 @@ void Eluna::HandleGossipSelectOption(Player* pPlayer, Item* pItem, uint32 sender
bool Eluna::OnGossipHello(Player* pPlayer, Creature* pCreature)
{
START_HOOK_WITH_RETVAL(CreatureGossipBindings, GOSSIP_EVENT_ON_HELLO, pCreature->GetEntry(), false);
#if defined CMANGOS && !defined CATA
#if defined CMANGOS && EXPANSION < CATA
pPlayer->GetPlayerMenu()->ClearMenus();
#else
pPlayer->PlayerTalkClass->ClearMenus();
Expand All @@ -138,7 +138,7 @@ bool Eluna::OnGossipHello(Player* pPlayer, Creature* pCreature)
bool Eluna::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 action)
{
START_HOOK_WITH_RETVAL(CreatureGossipBindings, GOSSIP_EVENT_ON_SELECT, pCreature->GetEntry(), false);
#if defined CMANGOS && !defined CATA
#if defined CMANGOS && EXPANSION < CATA
auto original_menu = *pPlayer->GetPlayerMenu();
pPlayer->GetPlayerMenu()->ClearMenus();
#else
Expand All @@ -151,7 +151,7 @@ bool Eluna::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender,
HookPush(action);
auto preventDefault = CallAllFunctionsBool(CreatureGossipBindings, key, true);
if (!preventDefault) {
#if defined CMANGOS && !defined CATA
#if defined CMANGOS && EXPANSION < CATA
*pPlayer->GetPlayerMenu() = original_menu;
#else
*pPlayer->PlayerTalkClass = original_menu;
Expand All @@ -163,7 +163,7 @@ bool Eluna::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender,
bool Eluna::OnGossipSelectCode(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 action, const char* code)
{
START_HOOK_WITH_RETVAL(CreatureGossipBindings, GOSSIP_EVENT_ON_SELECT, pCreature->GetEntry(), false);
#if defined CMANGOS && !defined CATA
#if defined CMANGOS && EXPANSION < CATA
auto original_menu = *pPlayer->GetPlayerMenu();
pPlayer->GetPlayerMenu()->ClearMenus();
#else
Expand All @@ -177,7 +177,7 @@ bool Eluna::OnGossipSelectCode(Player* pPlayer, Creature* pCreature, uint32 send
HookPush(code);
auto preventDefault = CallAllFunctionsBool(CreatureGossipBindings, key, true);
if (!preventDefault) {
#if defined CMANGOS && !defined CATA
#if defined CMANGOS && EXPANSION < CATA
*pPlayer->GetPlayerMenu() = original_menu;
#else
*pPlayer->PlayerTalkClass = original_menu;
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 defined CATA
#if EXPANSION >= 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 defined CATA
#if EXPANSION >= 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 defined CATA
#if EXPANSION >= CATA
void Eluna::OnMoneyChanged(Player* pPlayer, int64& amount)
{
START_HOOK(PLAYER_EVENT_ON_MONEY_CHANGE);
Expand Down
4 changes: 2 additions & 2 deletions 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 !defined(CLASSIC) && !defined(TBC)
#if EXPANSION >= WOTLK

using namespace Hooks;

Expand Down Expand Up @@ -58,4 +58,4 @@ void Eluna::OnRemovePassenger(Vehicle* vehicle, Unit* passenger)
CallAllFunctions(VehicleEventBindings, key);
}

#endif // !CLASSIC && !TBC
#endif

0 comments on commit df7c0ae

Please sign in to comment.