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 c95eac2 commit ef8aaa1
Show file tree
Hide file tree
Showing 27 changed files with 560 additions and 259 deletions.
4 changes: 4 additions & 0 deletions ElunaCreatureAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ struct ElunaCreatureAI : CreatureAI
if (!me->GetEluna()->UpdateAI(me, diff))
{
#if defined TRINITY || AZEROTHCORE || VMANGOS
#ifdef RETAIL
if (!me->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_NPC))
#else
if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
#endif
ScriptedAI::UpdateAI(diff);
#elif defined CMANGOS
if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
Expand Down
6 changes: 4 additions & 2 deletions ElunaIncludes.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
#include "CellImpl.h"
#include "Chat.h"
#include "Channel.h"
#ifndef RETAIL
#include "DBCStores.h"
#if defined CATA && defined TRINITY
#endif
#if (defined CATA || defined RETAIL) && defined TRINITY
#include "DB2Stores.h"
#endif
#include "GameEventMgr.h"
Expand Down Expand Up @@ -141,7 +143,7 @@
#endif
#endif

#if (defined(TRINITY) && defined(CATA))
#if (defined CATA || defined RETAIL) && defined TRINITY
typedef OpcodeServer OpcodesList;

#elif !defined CLASSIC
Expand Down
8 changes: 8 additions & 0 deletions ElunaInstanceAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,18 @@ class ElunaInstanceAI : public InstanceData
* These are responsible for serializing/deserializing the instance's
* data table to/from the core.
*/
#if defined(TRINITY) && defined(RETAIL)
void Load(const char* data);
#else
void Load(const char* data) override;
#endif
#if defined TRINITY || AZEROTHCORE
// Simply calls Save, since the functions are a bit different in name and data types on different cores
#if defined(TRINITY) && defined(RETAIL)
std::string GetSaveData()
#else
std::string GetSaveData() override
#endif
{
return Save();
}
Expand Down
12 changes: 8 additions & 4 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"
#ifdef RETAIL
#include "DB2Stores.h"
#else
#include "DBCStores.h"
#endif
#else
#include "World/World.h"
#include "Entities/Object.h"
Expand Down Expand Up @@ -101,12 +105,12 @@ bool ElunaUtil::WorldObjectInRangeCheck::operator()(WorldObject* u)
{
if (i_obj_fact)
{
#if ((defined TRINITY || AZEROTHCORE || CMANGOS || VMANGOS) && !defined CATA)
if ((i_obj_fact->IsHostileTo(*target->GetFactionTemplateEntry())) != (i_hostile == 1))
return false;
#elif defined CATA && defined TRINITY
#if ((defined CATA || RETAIL) && defined TRINITY)
if ((i_obj_fact->IsHostileTo(target->GetFactionTemplateEntry())) != (i_hostile == 1))
return false;
#elif ((defined TRINITY || AZEROTHCORE || 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;
Expand Down
14 changes: 4 additions & 10 deletions ElunaUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,21 @@
typedef QueryResult ElunaQuery;
#define GET_GUID GetGUID
#define HIGHGUID_PLAYER HighGuid::Player
#define HIGHGUID_UNIT HighGuid::Unit
#define HIGHGUID_UNIT HighGuid::Creature
#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_CONTAINER HighGuid::Container
#define HIGHGUID_DYNAMICOBJECT HighGuid::DynamicObject
#define HIGHGUID_CORPSE HighGuid::Corpse
#define HIGHGUID_MO_TRANSPORT HighGuid::Mo_Transport
#define HIGHGUID_MO_TRANSPORT HighGuid::Transport
#define HIGHGUID_INSTANCE HighGuid::Instance
#define HIGHGUID_GROUP HighGuid::Group
//#define HIGHGUID_GROUP HighGuid::Group
#endif

#ifdef TRINITY
#ifdef WOTLK
#include "fmt/printf.h"
#define ELUNA_LOG_TC_FMT(TC_LOG_MACRO, ...) \
try { \
Expand All @@ -84,11 +83,6 @@ typedef QueryResult ElunaQuery;
#define ELUNA_LOG_INFO(...) ELUNA_LOG_TC_FMT(TC_LOG_INFO, __VA_ARGS__);
#define ELUNA_LOG_ERROR(...) ELUNA_LOG_TC_FMT(TC_LOG_ERROR, __VA_ARGS__);
#define ELUNA_LOG_DEBUG(...) ELUNA_LOG_TC_FMT(TC_LOG_DEBUG, __VA_ARGS__);
#else
#define ELUNA_LOG_INFO(...) TC_LOG_INFO("eluna", __VA_ARGS__);
#define ELUNA_LOG_ERROR(...) TC_LOG_ERROR("eluna", __VA_ARGS__);
#define ELUNA_LOG_DEBUG(...) TC_LOG_DEBUG("eluna", __VA_ARGS__);
#endif
#elif defined(AZEROTHCORE)
#define ELUNA_LOG_INFO(...) LOG_INFO("eluna", __VA_ARGS__);
#define ELUNA_LOG_ERROR(...) LOG_ERROR("eluna", __VA_ARGS__);
Expand Down
9 changes: 5 additions & 4 deletions LuaEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "ElunaUtility.h"
#include "ElunaCreatureAI.h"
#include "ElunaInstanceAI.h"
#include <sstream>

extern "C"
{
Expand Down Expand Up @@ -786,12 +787,12 @@ int Eluna::Register(uint8 regtype, uint32 entry, ObjectGuid guid, uint32 instanc
case Hooks::REGTYPE_PACKET:
if (event_id < Hooks::PACKET_EVENT_COUNT)
{
if (entry >= NUM_MSG_TYPES)
/*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)
}
}*/

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

eventMgr->globalProcessor->Update(diff);
#ifdef TRINITY
#if defined TRINITY && defined WOTLK
GetQueryProcessor().ProcessReadyCallbacks();
#endif
}
Expand Down
23 changes: 16 additions & 7 deletions LuaEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,11 @@ class ELUNA_GAME_API Eluna
void OnResurrect(Player* pPlayer);
void OnQuestAbandon(Player* pPlayer, uint32 questId);
void OnQuestStatusChanged(Player* pPlayer, uint32 questId, uint8 status);
#ifdef 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 @@ -506,7 +510,7 @@ class ELUNA_GAME_API Eluna
void OnFreeTalentPointsChanged(Player* pPlayer, uint32 newPoints);
void OnTalentsReset(Player* pPlayer, bool noCost);
void OnMoneyChanged(Player* pPlayer, int32& amount);
#ifdef CATA
#if defined CATA || defined RETAIL
void OnMoneyChanged(Player* pPlayer, int64& amount);
#endif
void OnGiveXP(Player* pPlayer, uint32& amount, Unit* pVictim);
Expand Down Expand Up @@ -552,24 +556,29 @@ class ELUNA_GAME_API Eluna
void OnChange(Weather* weather, uint32 zone, WeatherState state, float grade);

/* 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);
//void OnAdd(AuctionHouseObject* ah, AuctionEntry* entry);
//void OnAdd(AuctionHouseObject* ah, AuctionPosting* entry);
//void OnRemove(AuctionHouseObject* ah, AuctionEntry* entry);
//void OnSuccessful(AuctionHouseObject* ah, AuctionEntry* entry);
//void OnExpire(AuctionHouseObject* ah, AuctionEntry* entry);

/* Guild */
void OnAddMember(Guild* guild, Player* player, uint32 plRank);
#ifdef 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);
void OnDisband(Guild* guild);
void OnMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, bool isRepair);
#ifdef CATA
#if defined CATA || defined RETAIL
void OnMemberWitdrawMoney(Guild* guild, Player* player, uint64& amount, bool isRepair);
#endif
void OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount);
#ifdef CATA
#if defined CATA || defined RETAIL
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
8 changes: 4 additions & 4 deletions hooks/GossipHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ bool Eluna::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender,
auto original_menu = *pPlayer->GetPlayerMenu();
pPlayer->GetPlayerMenu()->ClearMenus();
#else
auto original_menu = *pPlayer->PlayerTalkClass;
auto original_menu = pPlayer->PlayerTalkClass->GetGossipMenu().GetMenuId();
pPlayer->PlayerTalkClass->ClearMenus();
#endif
HookPush(pPlayer);
Expand All @@ -154,7 +154,7 @@ bool Eluna::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender,
#if defined CMANGOS && !defined(CATA)
*pPlayer->GetPlayerMenu() = original_menu;
#else
*pPlayer->PlayerTalkClass = original_menu;
pPlayer->PlayerTalkClass->GetGossipMenu().SetMenuId(original_menu);
#endif
}
return preventDefault;
Expand All @@ -167,7 +167,7 @@ bool Eluna::OnGossipSelectCode(Player* pPlayer, Creature* pCreature, uint32 send
auto original_menu = *pPlayer->GetPlayerMenu();
pPlayer->GetPlayerMenu()->ClearMenus();
#else
auto original_menu = *pPlayer->PlayerTalkClass;
auto original_menu = pPlayer->PlayerTalkClass->GetGossipMenu().GetMenuId();
pPlayer->PlayerTalkClass->ClearMenus();
#endif
HookPush(pPlayer);
Expand All @@ -180,7 +180,7 @@ bool Eluna::OnGossipSelectCode(Player* pPlayer, Creature* pCreature, uint32 send
#if defined CMANGOS &&!defined(CATA)
*pPlayer->GetPlayerMenu() = original_menu;
#else
*pPlayer->PlayerTalkClass = original_menu;
pPlayer->PlayerTalkClass->GetGossipMenu().SetMenuId(original_menu);
#endif
}
return preventDefault;
Expand Down
15 changes: 13 additions & 2 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);
}

#ifdef 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 Expand Up @@ -94,7 +105,7 @@ void Eluna::OnMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, b
CleanUpStack(4);
}

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

#ifdef CATA
#if defined CATA || defined RETAIL
void Eluna::OnMemberDepositMoney(Guild* guild, Player* player, uint64& amount)
{
START_HOOK(GUILD_EVENT_ON_MONEY_DEPOSIT);
Expand Down
14 changes: 11 additions & 3 deletions hooks/ItemHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ bool Eluna::OnUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets)
WorldPacket data(SMSG_INVENTORY_CHANGE_FAILURE, 18);
data << uint8(59); // EQUIP_ERR_NONE / EQUIP_ERR_CANT_BE_DISENCHANTED
data << guid;
data << ObjectGuid(uint64(0));
data << uint64(0);
data << uint8(0);
#ifdef CMANGOS
pPlayer->GetSession()->SendPacket(data);
Expand Down Expand Up @@ -112,9 +112,17 @@ bool Eluna::OnItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targ

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

Expand Down
13 changes: 12 additions & 1 deletion 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;

#ifdef 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 Expand Up @@ -280,7 +291,7 @@ void Eluna::OnMoneyChanged(Player* pPlayer, int32& amount)
CleanUpStack(2);
}

#ifdef CATA
#if defined CATA || defined RETAIL
void Eluna::OnMoneyChanged(Player* pPlayer, int64& amount)
{
START_HOOK(PLAYER_EVENT_ON_MONEY_CHANGE);
Expand Down
Loading

0 comments on commit ef8aaa1

Please sign in to comment.