Skip to content

Commit

Permalink
TC Retail Changes
Browse files Browse the repository at this point in the history
It compiles and runs!
  • Loading branch information
Niam5 committed Aug 9, 2024
1 parent 13591ed commit 5c24162
Show file tree
Hide file tree
Showing 27 changed files with 820 additions and 95 deletions.
4 changes: 4 additions & 0 deletions ElunaCreatureAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ struct ElunaCreatureAI : NativeScriptedAI

if (!me->GetEluna()->UpdateAI(me, diff))
{
#if ELUNA_EXPANSION < RETAIL
if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
#else
if (!me->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_NPC))
#endif
NativeScriptedAI::UpdateAI(diff);
}
}
Expand Down
10 changes: 9 additions & 1 deletion ElunaIncludes.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#include "CellImpl.h"
#include "Channel.h"
#include "Chat.h"
#if ELUNA_EXPANSION < RETAIL
#include "DBCStores.h"
#else
#include "DB2Stores.h"
#endif
#include "GameEventMgr.h"
#include "GossipDef.h"
#include "GridNotifiers.h"
Expand Down Expand Up @@ -113,7 +117,11 @@
#include "revision.h"
#endif

#if ELUNA_EXPANSION > CLASSIC
#if ELUNA_EXPANSION > CATA
typedef OpcodeServer OpcodesList;
#endif

#if !defined ELUNA_VMANGOS && ELUNA_EXPANSION < RETAIL
typedef Opcodes OpcodesList;
#endif

Expand Down
8 changes: 8 additions & 0 deletions ElunaInstanceAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,18 @@ class ElunaInstanceAI : public InstanceData
* These are responsible for serializing/deserializing the instance's
* data table to/from the core.
*/
#if ELUNA_EXPANSION == RETAIL
void Load(const char* data);
#else
void Load(const char* data) override;
#endif
#if defined ELUNA_TRINITY
// Simply calls Save, since the functions are a bit different in name and data types on different cores
#if ELUNA_EXPANSION == RETAIL
std::string GetSaveData()
#else
std::string GetSaveData() override
#endif
{
return Save();
}
Expand Down
9 changes: 9 additions & 0 deletions ElunaUtility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
#include "Object.h"
#include "Unit.h"
#include "GameObject.h"
#if ELUNA_EXPANSION == RETAIL
#include "DB2Stores.h"
#else
#include "DBCStores.h"
#endif
#else
#include "World/World.h"
#include "Entities/Object.h"
Expand Down Expand Up @@ -98,8 +102,13 @@ bool ElunaUtil::WorldObjectInRangeCheck::operator()(WorldObject* u)
{
if (i_obj_fact)
{
#if ELUNA_EXPANSION < RETAIL
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
15 changes: 12 additions & 3 deletions ElunaUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define TBC 1
#define WOTLK 2
#define CATA 3
#define RETAIL 9

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

#if !defined ELUNA_VMANGOS
#define USING_BOOST
Expand All @@ -55,18 +57,25 @@
typedef QueryResult ElunaQuery;
#define GET_GUID GetGUID
#define HIGHGUID_PLAYER HighGuid::Player
#define HIGHGUID_UNIT HighGuid::Unit
#define HIGHGUID_ITEM HighGuid::Item
#define HIGHGUID_GAMEOBJECT HighGuid::GameObject
#define HIGHGUID_PET HighGuid::Pet
#define HIGHGUID_TRANSPORT HighGuid::Transport
#define HIGHGUID_VEHICLE HighGuid::Vehicle
#define HIGHGUID_CONTAINER HighGuid::Container
#define HIGHGUID_DYNAMICOBJECT HighGuid::DynamicObject
#define HIGHGUID_CORPSE HighGuid::Corpse
#define HIGHGUID_MO_TRANSPORT HighGuid::Mo_Transport
#define HIGHGUID_INSTANCE HighGuid::Instance
#if ELUNA_EXPANSION < RETAIL
#define HIGHGUID_UNIT HighGuid::Unit
#define HIGHGUID_CONTAINER HighGuid::Container
#define HIGHGUID_MO_TRANSPORT HighGuid::Mo_Transport
#define HIGHGUID_GROUP HighGuid::Group
#else
#define HIGHGUID_UNIT HighGuid::Creature
//#define HIGHGUID_CONTAINER HighGuid::Container
#define HIGHGUID_MO_TRANSPORT HighGuid::Transport
//#define HIGHGUID_GROUP HighGuid::Group
#endif
#endif

#if defined ELUNA_TRINITY
Expand Down
6 changes: 4 additions & 2 deletions LuaEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,12 +798,14 @@ int Eluna::Register(uint8 regtype, uint32 entry, ObjectGuid guid, uint32 instanc
case Hooks::REGTYPE_PACKET:
if (event_id < Hooks::PACKET_EVENT_COUNT)
{
#if ELUNA_EXPANSION < RETAIL
if (entry >= NUM_MSG_TYPES)
{
luaL_unref(L, LUA_REGISTRYINDEX, functionRef);
luaL_error(L, "Couldn't find a creature with (ID: %d)!", entry);
return 0; // Stack: (empty)
}
#endif

auto key = EntryKey<Hooks::PacketEvents>((Hooks::PacketEvents)event_id, entry);
bindingID = PacketEventBindings->Insert(key, functionRef, shots);
Expand Down Expand Up @@ -984,13 +986,13 @@ int Eluna::Register(uint8 regtype, uint32 entry, ObjectGuid guid, uint32 instanc
void Eluna::UpdateEluna(uint32 diff)
{
if (reload && sElunaLoader->GetCacheState() == SCRIPT_CACHE_READY)
#if defined ELUNA_TRINITY
#if defined ELUNA_TRINITY && ELUNA_EXPANSION == WOTLK
if(!GetQueryProcessor().HasPendingCallbacks())
#endif
_ReloadEluna();

eventMgr->globalProcessor->Update(diff);
#if defined ELUNA_TRINITY
#if defined ELUNA_TRINITY && ELUNA_EXPANSION == WOTLK
GetQueryProcessor().ProcessReadyCallbacks();
#endif
}
Expand Down
10 changes: 10 additions & 0 deletions LuaEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,11 @@ class ELUNA_GAME_API Eluna
void OnResurrect(Player* pPlayer);
void OnQuestAbandon(Player* pPlayer, uint32 questId);
void OnQuestStatusChanged(Player* pPlayer, uint32 questId, uint8 status);
#if ELUNA_EXPANSION == RETAIL
void OnLearnTalents(Player* pPlayer, uint32 talentId, uint32 spellid);
#else
void OnLearnTalents(Player* pPlayer, uint32 talentId, uint32 talentRank, uint32 spellid);
#endif
void OnSkillChange(Player* pPlayer, uint32 skillId, uint32 skillValue);
void OnLearnSpell(Player* pPlayer, uint32 spellid);
InventoryResult OnCanUseItem(const Player* pPlayer, uint32 itemEntry);
Expand Down Expand Up @@ -529,15 +533,21 @@ class ELUNA_GAME_API Eluna
/* Weather */
void OnChange(Weather* weather, uint32 zone, WeatherState state, float grade);

#if ELUNA_EXPANSION < RETAIL
/* Auction House */
void OnAdd(AuctionHouseObject* ah, AuctionEntry* entry);
void OnRemove(AuctionHouseObject* ah, AuctionEntry* entry);
void OnSuccessful(AuctionHouseObject* ah, AuctionEntry* entry);
void OnExpire(AuctionHouseObject* ah, AuctionEntry* entry);
#endif

/* Guild */
void OnAddMember(Guild* guild, Player* player, uint32 plRank);
#if ELUNA_EXPANSION == RETAIL
void OnRemoveMember(Guild* guild, ObjectGuid guid, bool isDisbanding);
#else
void OnRemoveMember(Guild* guild, Player* player, bool isDisbanding);
#endif
void OnMOTDChanged(Guild* guild, const std::string& newMotd);
void OnInfoChanged(Guild* guild, const std::string& newInfo);
void OnCreate(Guild* guild, Player* leader, const std::string& name);
Expand Down
10 changes: 10 additions & 0 deletions hooks/GossipHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ bool Eluna::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender,
#if defined ELUNA_CMANGOS && ELUNA_EXPANSION < CATA
auto original_menu = *pPlayer->GetPlayerMenu();
pPlayer->GetPlayerMenu()->ClearMenus();
#elif defined ELUNA_TRINITY && ELUNA_EXPANSION == RETAIL
auto original_menu = pPlayer->PlayerTalkClass->GetGossipMenu().GetMenuId();
pPlayer->PlayerTalkClass->ClearMenus();
#else
auto original_menu = *pPlayer->PlayerTalkClass;
pPlayer->PlayerTalkClass->ClearMenus();
Expand All @@ -153,6 +156,8 @@ bool Eluna::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender,
if (!preventDefault) {
#if defined ELUNA_CMANGOS && ELUNA_EXPANSION < CATA
*pPlayer->GetPlayerMenu() = original_menu;
#elif defined ELUNA_TRINITY && ELUNA_EXPANSION == RETAIL
pPlayer->PlayerTalkClass->GetGossipMenu().SetMenuId(original_menu);
#else
*pPlayer->PlayerTalkClass = original_menu;
#endif
Expand All @@ -166,6 +171,9 @@ bool Eluna::OnGossipSelectCode(Player* pPlayer, Creature* pCreature, uint32 send
#if defined ELUNA_CMANGOS && ELUNA_EXPANSION < CATA
auto original_menu = *pPlayer->GetPlayerMenu();
pPlayer->GetPlayerMenu()->ClearMenus();
#elif defined ELUNA_TRINITY && ELUNA_EXPANSION == RETAIL
auto original_menu = pPlayer->PlayerTalkClass->GetGossipMenu().GetMenuId();
pPlayer->PlayerTalkClass->ClearMenus();
#else
auto original_menu = *pPlayer->PlayerTalkClass;
pPlayer->PlayerTalkClass->ClearMenus();
Expand All @@ -179,6 +187,8 @@ bool Eluna::OnGossipSelectCode(Player* pPlayer, Creature* pCreature, uint32 send
if (!preventDefault) {
#if defined ELUNA_CMANGOS && ELUNA_EXPANSION < CATA
*pPlayer->GetPlayerMenu() = original_menu;
#elif defined ELUNA_TRINITY && ELUNA_EXPANSION == RETAIL
pPlayer->PlayerTalkClass->GetGossipMenu().SetMenuId(original_menu);
#else
*pPlayer->PlayerTalkClass = original_menu;
#endif
Expand Down
11 changes: 11 additions & 0 deletions hooks/GuildHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ void Eluna::OnAddMember(Guild* guild, Player* player, uint32 plRank)
CallAllFunctions(GuildEventBindings, key);
}

#if ELUNA_EXPANSION == RETAIL
void Eluna::OnRemoveMember(Guild* guild, ObjectGuid guid, bool isDisbanding)
{
START_HOOK(GUILD_EVENT_ON_REMOVE_MEMBER);
HookPush(guild);
HookPush(guid);
HookPush(isDisbanding);
CallAllFunctions(GuildEventBindings, key);
}
#else
void Eluna::OnRemoveMember(Guild* guild, Player* player, bool isDisbanding)
{
START_HOOK(GUILD_EVENT_ON_REMOVE_MEMBER);
Expand All @@ -34,6 +44,7 @@ void Eluna::OnRemoveMember(Guild* guild, Player* player, bool isDisbanding)
HookPush(isDisbanding);
CallAllFunctions(GuildEventBindings, key);
}
#endif

void Eluna::OnMOTDChanged(Guild* guild, const std::string& newMotd)
{
Expand Down
12 changes: 12 additions & 0 deletions hooks/ItemHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ bool Eluna::OnUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets)

// Send equip error that shows no message
// This is a hack fix to stop spell casting visual bug when a spell is not cast on use
#if ELUNA_EXPANSION < RETAIL
pPlayer->SendEquipError(EQUIP_ERR_NONE, pItem, nullptr);
#else
pPlayer->SendEquipError(EQUIP_NONE_3, pItem, nullptr);
#endif
return false;
}

Expand Down Expand Up @@ -103,9 +107,17 @@ bool Eluna::OnItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targ

bool Eluna::OnExpire(Player* pPlayer, ItemTemplate const* pProto)
{
#if defined ELUNA_TRINITY && ELUNA_EXPANSION >= CATA
START_HOOK_WITH_RETVAL(ITEM_EVENT_ON_EXPIRE, pProto->BasicData->ID, false);
#else
START_HOOK_WITH_RETVAL(ITEM_EVENT_ON_EXPIRE, pProto->ItemId, false);
#endif
HookPush(pPlayer);
#if defined ELUNA_TRINITY && ELUNA_EXPANSION >= CATA
HookPush(pProto->BasicData->ID);
#else
HookPush(pProto->ItemId);
#endif
return CallAllFunctionsBool(ItemEventBindings, key);
}

Expand Down
11 changes: 11 additions & 0 deletions hooks/PlayerHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ using namespace Hooks;
if (!PlayerEventBindings->HasBindingsFor(key))\
return RETVAL;

#if ELUNA_EXPANSION == RETAIL
void Eluna::OnLearnTalents(Player* pPlayer, uint32 talentId, uint32 spellid)
{
START_HOOK(PLAYER_EVENT_ON_LEARN_TALENTS);
HookPush(pPlayer);
HookPush(talentId);
HookPush(spellid);
CallAllFunctions(PlayerEventBindings, key);
}
#else
void Eluna::OnLearnTalents(Player* pPlayer, uint32 talentId, uint32 talentRank, uint32 spellid)
{
START_HOOK(PLAYER_EVENT_ON_LEARN_TALENTS);
Expand All @@ -35,6 +45,7 @@ void Eluna::OnLearnTalents(Player* pPlayer, uint32 talentId, uint32 talentRank,
HookPush(spellid);
CallAllFunctions(PlayerEventBindings, key);
}
#endif

void Eluna::OnSkillChange(Player* pPlayer, uint32 skillId, uint32 skillValue)
{
Expand Down
2 changes: 2 additions & 0 deletions hooks/ServerHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ void Eluna::OnChange(Weather* /*weather*/, uint32 zone, WeatherState state, floa
CallAllFunctions(ServerEventBindings, key);
}

#if ELUNA_EXPANSION < RETAIL
// Auction House
void Eluna::OnAdd(AuctionHouseObject* /*ah*/, AuctionEntry* entry)
{
Expand Down Expand Up @@ -239,6 +240,7 @@ void Eluna::OnExpire(AuctionHouseObject* /*ah*/, AuctionEntry* entry)
HookPush(entry->bidder);
CallAllFunctions(ServerEventBindings, key);
}
#endif

void Eluna::OnOpenStateChange(bool open)
{
Expand Down
4 changes: 4 additions & 0 deletions methods/TrinityCore/BattleGroundMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ namespace LuaBattleGround
*/
int GetEndTime(Eluna* E, BattleGround* bg)
{
#if ELUNA_EXPANSION >= CATA
E->Push(bg->GetRemainingTime());
#else
E->Push(bg->GetEndTime());
#endif
return 1;
}

Expand Down
Loading

0 comments on commit 5c24162

Please sign in to comment.