Skip to content

Commit

Permalink
Removal of Mangos wrappers
Browse files Browse the repository at this point in the history
Unfortunately mangos will not support multistate until larger fundamental changes are done to the emulator. Mangos will continue to use an old submodule for now.
  • Loading branch information
Foereaper committed Jul 23, 2024
1 parent a34affc commit f76146d
Show file tree
Hide file tree
Showing 31 changed files with 62 additions and 16,784 deletions.
4 changes: 2 additions & 2 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 TRINITY
#include "Config.h"
#elif defined CMANGOS || defined VMANGOS
#else
#include "Config/Config.h"
#endif
#include "ElunaConfig.h"
Expand Down
9 changes: 1 addition & 8 deletions ElunaCreatureAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ typedef CreatureAI NativeScriptedAI;
#elif defined VMANGOS
class BasicAI;
typedef BasicAI NativeScriptedAI;
#else
class AggressorAI;
typedef AggressorAI NativeScriptedAI;
#endif

struct ElunaCreatureAI : NativeScriptedAI
Expand Down Expand Up @@ -67,11 +64,7 @@ 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);
}
}
Expand Down Expand Up @@ -202,7 +195,7 @@ struct ElunaCreatureAI : NativeScriptedAI
NativeScriptedAI::CorpseRemoved(respawnDelay);
}

#if !defined TRINITY && !defined VMANGOS
#if defined CMANGOS
// Enables use of MoveInLineOfSight
bool IsVisible(Unit* who) const override
{
Expand Down
82 changes: 26 additions & 56 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,7 +40,24 @@
#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
#else
#include "AI/BaseAI/UnitAI.h"
#include "Accounts/AccountMgr.h"
#include "AuctionHouse/AuctionHouseMgr.h"
#include "Chat/Channel.h"
Expand All @@ -64,6 +82,7 @@
#include "Reputation/ReputationMgr.h"
#include "Server/DBCStores.h"
#include "Server/Opcodes.h"
#include "Server/SQLStorages.h"
#include "Server/WorldPacket.h"
#include "Server/WorldSession.h"
#include "Spells/Spell.h"
Expand All @@ -72,47 +91,11 @@
#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"
#endif
#if !defined TRINITY
#include "BattleGroundMgr.h"
#if !defined CMANGOS
#include "SQLStorages.h"
#else
#include "Server/SQLStorages.h"
#endif
#if defined MANGOS
#include "GitRevision.h"
#else
#include "Config/Config.h"
#include "revision.h"
#endif
#endif

#if !defined TBC && !defined CLASSIC
#if !defined CMANGOS
Expand All @@ -135,20 +118,9 @@ typedef Opcodes OpcodesList;
* Note: if you add or change a CORE_NAME or CORE_VERSION #define,
* please update LuaGlobalFunctions::GetCoreName or LuaGlobalFunctions::GetCoreVersion documentation example string.
*/
#if defined MANGOS
#define CORE_NAME "MaNGOS"
#define CORE_VERSION REVISION_NR
#if defined 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
#define NUM_MSG_TYPES MAX_OPCODE_TABLE_SIZE
#endif
#endif

#if defined VMANGOS
Expand Down Expand Up @@ -186,24 +158,22 @@ typedef Opcodes OpcodesList;
#define TOTAL_LOCALES MAX_LOCALE
#define TARGETICONCOUNT TARGET_ICON_COUNT
#define MAX_TALENT_SPECS MAX_TALENT_SPEC_COUNT
#if !defined VMANGOS
#define TEAM_NEUTRAL TEAM_INDEX_NEUTRAL
#endif


#if (defined CATA && !defined MANGOS) || defined VMANGOS
#if defined CMANGOS
#define TEAM_NEUTRAL TEAM_INDEX_NEUTRAL
#elif defined VMANGOS
#define PLAYER_FIELD_LIFETIME_HONORABLE_KILLS PLAYER_FIELD_LIFETIME_HONORBALE_KILLS
#endif

#if defined TBC
#define SPELL_AURA_MOD_KILL_XP_PCT SPELL_AURA_MOD_XP_PCT
#endif

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

#if !defined CMANGOS
#if defined VMANGOS
typedef TemporarySummon TempSummon;
#else
typedef TemporarySpawn TempSummon;
Expand Down
21 changes: 5 additions & 16 deletions ElunaUtility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@
#include "Server/DBCStores.h"
#include "Util/Timer.h"
#endif
#if defined MANGOS
#include "Timer.h"
#endif

uint32 ElunaUtil::GetCurrTime()
{
#if !defined CMANGOS && !defined VMANGOS
#if defined TRINITY
return getMSTime();
#else
return WorldTimer::getMSTime();
Expand All @@ -34,7 +31,7 @@ uint32 ElunaUtil::GetCurrTime()

uint32 ElunaUtil::GetTimeDiff(uint32 oldMSTime)
{
#if !defined CMANGOS && !defined VMANGOS
#if defined TRINITY
return GetMSTimeDiffToNow(oldMSTime);
#else
return WorldTimer::getMSTimeDiff(oldMSTime, WorldTimer::getMSTime());
Expand Down Expand Up @@ -67,10 +64,10 @@ ElunaUtil::WorldObjectInRangeCheck::WorldObjectInRangeCheck(bool nearest, WorldO
if (GameObject const* go = i_obj->ToGameObject())
i_obj_unit = go->GetOwner();
if (!i_obj_unit)
#if !defined VMANGOS
i_obj_fact = sFactionTemplateStore.LookupEntry(14);
#else
#if defined VMANGOS
i_obj_fact = sObjectMgr.GetFactionTemplateEntry(14);
#else
i_obj_fact = sFactionTemplateStore.LookupEntry(14);
#endif
}
WorldObject const& ElunaUtil::WorldObjectInRangeCheck::GetFocusObject() const
Expand Down Expand Up @@ -101,16 +98,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
2 changes: 1 addition & 1 deletion ElunaUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <mutex>
#include <memory>

#if !defined MANGOS && !defined VMANGOS
#if !defined VMANGOS
#define USING_BOOST
#endif

Expand Down
9 changes: 0 additions & 9 deletions LuaEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,6 @@ 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
void OnMoneyChanged(Player* pPlayer, int64& amount);
#endif
void OnGiveXP(Player* pPlayer, uint32& amount, Unit* pVictim);
void OnReputationChange(Player* pPlayer, uint32 factionID, int32& standing, bool incremental);
void OnDuelRequest(Player* pTarget, Player* pChallenger);
Expand Down Expand Up @@ -546,13 +543,7 @@ 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
void OnMemberWitdrawMoney(Guild* guild, Player* player, uint64& amount, bool isRepair);
#endif
void OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount);
#if defined 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);
void OnEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank);
void OnBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId);
Expand Down
5 changes: 5 additions & 0 deletions LuaValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef _LUA_VAL_H
#define _LUA_VAL_H

#pragma once

#include <unordered_map> // std::unordered_map
Expand Down Expand Up @@ -151,3 +154,5 @@ class LuaVal

LuaValVariant v;
};

#endif
23 changes: 11 additions & 12 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
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
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
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
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
pPlayer->GetPlayerMenu()->ClearMenus();
#else
pPlayer->PlayerTalkClass->ClearMenus();
Expand All @@ -104,12 +104,11 @@ 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
pPlayer->GetPlayerMenu()->ClearMenus();
#else
pPlayer->PlayerTalkClass->ClearMenus();
#endif

HookPush(pPlayer);
HookPush(pItem);
HookPush(sender);
Expand All @@ -125,7 +124,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
pPlayer->GetPlayerMenu()->ClearMenus();
#else
pPlayer->PlayerTalkClass->ClearMenus();
Expand All @@ -138,7 +137,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
auto original_menu = *pPlayer->GetPlayerMenu();
pPlayer->GetPlayerMenu()->ClearMenus();
#else
Expand All @@ -151,7 +150,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
*pPlayer->GetPlayerMenu() = original_menu;
#else
*pPlayer->PlayerTalkClass = original_menu;
Expand All @@ -163,7 +162,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
auto original_menu = *pPlayer->GetPlayerMenu();
pPlayer->GetPlayerMenu()->ClearMenus();
#else
Expand All @@ -177,7 +176,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
*pPlayer->GetPlayerMenu() = original_menu;
#else
*pPlayer->PlayerTalkClass = original_menu;
Expand Down
Loading

0 comments on commit f76146d

Please sign in to comment.