Skip to content

Commit

Permalink
Cata Preservation Project Changes
Browse files Browse the repository at this point in the history
Cata Preservation Project Changes
  • Loading branch information
Niam5 committed Sep 16, 2023
1 parent bcb6487 commit 112d10e
Show file tree
Hide file tree
Showing 21 changed files with 492 additions and 6 deletions.
8 changes: 5 additions & 3 deletions ElunaCreatureAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ struct ElunaCreatureAI : CreatureAI
// Called at any Damage from any attacker (before damage apply)
#if defined AZEROTHCORE
void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask) override
#elif defined(TRINITY) || CMANGOS
#elif ((defined (TRINITY) || CMANGOS) && !defined CATA)
void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damageType, SpellInfo const* spellInfo) override
#elif defined CATA && defined CMANGOS
void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damageType, SpellInfo const* spellInfo) override
#else
void DamageTaken(Unit* attacker, uint32& damage) override
Expand All @@ -127,7 +129,7 @@ struct ElunaCreatureAI : CreatureAI
{
#if defined AZEROTHCORE
ScriptedAI::DamageTaken(attacker, damage, damagetype, damageSchoolMask);
#elif defined TRINITY
#elif defined TRINITY && !defined CATA
ScriptedAI::DamageTaken(attacker, damage, damageType, spellInfo);
#elif defined CMANGOS
CreatureAI::DamageTaken(attacker, damage, damageType, spellInfo);
Expand Down Expand Up @@ -341,7 +343,7 @@ struct ElunaCreatureAI : CreatureAI

#if defined TRINITY || AZEROTHCORE

#if defined TRINITY
#if defined TRINITY && !defined CATA
// Called when the creature is summoned successfully by other creature
void IsSummonedBy(WorldObject* summoner) override
{
Expand Down
11 changes: 10 additions & 1 deletion ElunaIncludes.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#include "Chat.h"
#include "Channel.h"
#include "DBCStores.h"
#if defined CATA && defined TRINITY
#include "DB2Stores.h"
#endif
#include "GameEventMgr.h"
#include "GossipDef.h"
#include "GridNotifiers.h"
Expand Down Expand Up @@ -134,7 +137,10 @@
#endif
#endif

#ifndef CLASSIC
#if (defined(TRINITY) && defined(CATA))
typedef OpcodeServer OpcodesList;

#elif !defined CLASSIC
typedef Opcodes OpcodesList;
#endif

Expand All @@ -161,6 +167,9 @@ typedef Opcodes OpcodesList;
#ifdef TRINITY
#define CORE_NAME "TrinityCore"
#define REGEN_TIME_FULL
#ifdef CATA
#define NUM_MSG_TYPES NUM_OPCODE_HANDLERS
#endif
#endif

#ifdef AZEROTHCORE
Expand Down
8 changes: 7 additions & 1 deletion ElunaUtility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ bool ElunaUtil::WorldObjectInRangeCheck::operator()(WorldObject* u)
{
if (i_obj_fact)
{
#if defined TRINITY || AZEROTHCORE || CMANGOS
#if ((defined TRINITY || AZEROTHCORE || CMANGOS) && !defined CATA)
if ((i_obj_fact->IsHostileTo(*target->GetFactionTemplateEntry())) != (i_hostile == 1))
return false;
#elif defined CATA && defined TRINITY
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
Expand Down
11 changes: 11 additions & 0 deletions GroupHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ void Eluna::OnDisband(Group* group)
CallAllFunctions(GroupEventBindings, key);
}

#if defined (TRINITY) && defined (CATA)
void Eluna::OnCreate(Group* group, ObjectGuid leaderGuid, GroupFlags groupType)
{
START_HOOK(GROUP_EVENT_ON_CREATE);
Push(group);
Push(leaderGuid);
Push(groupType);
CallAllFunctions(GroupEventBindings, key);
}
#else
void Eluna::OnCreate(Group* group, ObjectGuid leaderGuid, GroupType groupType)
{
START_HOOK(GROUP_EVENT_ON_CREATE);
Expand All @@ -69,3 +79,4 @@ void Eluna::OnCreate(Group* group, ObjectGuid leaderGuid, GroupType groupType)
Push(groupType);
CallAllFunctions(GroupEventBindings, key);
}
#endif
57 changes: 57 additions & 0 deletions GuildHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,35 @@ void Eluna::OnMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, b
CleanUpStack(4);
}

#ifdef CATA
void Eluna::OnMemberWitdrawMoney(Guild* guild, Player* player, uint64& amount, bool isRepair)
{
START_HOOK(GUILD_EVENT_ON_MONEY_WITHDRAW);
Push(guild);
Push(player);
Push(amount);
Push(isRepair); // isRepair not a part of Mangos, implement?
int amountIndex = lua_gettop(L) - 1;
int n = SetupStack(GuildEventBindings, key, 4);

while (n > 0)
{
int r = CallOneFunction(n--, 4, 1);

if (lua_isnumber(L, r))
{
amount = CHECKVAL<uint32>(L, r);
// Update the stack for subsequent calls.
ReplaceArgument(amount, amountIndex);
}

lua_pop(L, 1);
}

CleanUpStack(4);
}
#endif

void Eluna::OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount)
{
START_HOOK(GUILD_EVENT_ON_MONEY_DEPOSIT);
Expand All @@ -123,6 +152,34 @@ void Eluna::OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount)
CleanUpStack(3);
}

#ifdef CATA
void Eluna::OnMemberDepositMoney(Guild* guild, Player* player, uint64& amount)
{
START_HOOK(GUILD_EVENT_ON_MONEY_DEPOSIT);
Push(guild);
Push(player);
Push(amount);
int amountIndex = lua_gettop(L);
int n = SetupStack(GuildEventBindings, key, 3);

while (n > 0)
{
int r = CallOneFunction(n--, 3, 1);

if (lua_isnumber(L, r))
{
amount = CHECKVAL<uint32>(L, r);
// Update the stack for subsequent calls.
ReplaceArgument(amount, amountIndex);
}

lua_pop(L, 1);
}

CleanUpStack(3);
}
#endif

void Eluna::OnItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId,
bool isDestBank, uint8 destContainer, uint8 destSlotId)
{
Expand Down
8 changes: 8 additions & 0 deletions ItemHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,17 @@ bool Eluna::OnItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targ

bool Eluna::OnExpire(Player* pPlayer, ItemTemplate const* pProto)
{
#if defined TRINITY && 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
Push(pPlayer);
#if defined TRINITY && CATA
Push(pProto->BasicData->ID);
#else
Push(pProto->ItemId);
#endif
return CallAllFunctionsBool(ItemEventBindings, key);
}

Expand Down
13 changes: 13 additions & 0 deletions LuaEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ 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
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 @@ -518,7 +521,13 @@ 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);
#ifdef CATA
void OnMemberWitdrawMoney(Guild* guild, Player* player, uint64& amount, bool isRepair);
#endif
void OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount);
#ifdef 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 All @@ -529,7 +538,11 @@ class ELUNA_GAME_API Eluna
void OnRemoveMember(Group* group, ObjectGuid guid, uint8 method);
void OnChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid);
void OnDisband(Group* group);
#if defined (TRINITY) && defined (CATA)
void OnCreate(Group* group, ObjectGuid leaderGuid, GroupFlags groupType);
#else
void OnCreate(Group* group, ObjectGuid leaderGuid, GroupType groupType);
#endif

/* Map */
void OnCreate(Map* map);
Expand Down
27 changes: 27 additions & 0 deletions PlayerHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,33 @@ void Eluna::OnMoneyChanged(Player* pPlayer, int32& amount)
CleanUpStack(2);
}

#ifdef CATA
void Eluna::OnMoneyChanged(Player* pPlayer, int64& amount)
{
START_HOOK(PLAYER_EVENT_ON_MONEY_CHANGE);
Push(pPlayer);
Push(amount);
int amountIndex = lua_gettop(L);
int n = SetupStack(PlayerEventBindings, key, 2);

while (n > 0)
{
int r = CallOneFunction(n--, 2, 1);

if (lua_isnumber(L, r))
{
amount = CHECKVAL<int32>(L, r);
// Update the stack for subsequent calls.
ReplaceArgument(amount, amountIndex);
}

lua_pop(L, 1);
}

CleanUpStack(2);
}
#endif

void Eluna::OnGiveXP(Player* pPlayer, uint32& amount, Unit* pVictim)
{
START_HOOK(PLAYER_EVENT_ON_GIVE_XP);
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Core sources and forks with required modifications for Eluna:

[AzerothCore Eluna Module](https://github.com/azerothcore/mod-eluna)

[Cataclysm Preservation Project](https://github.com/Niam5/ElunaCataPreservation) - maintained by [Niam5](https://github.com/Niam5)

## Links

* [MaNGOS](http://getmangos.eu/)
Expand Down
4 changes: 4 additions & 0 deletions TrinityCore/BattleGroundMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ namespace LuaBattleGround
*/
int GetEndTime(lua_State* L, BattleGround* bg)
{
#ifdef CATA
Eluna::Push(L, bg->GetRemainingTime());
#else
Eluna::Push(L, bg->GetEndTime());
#endif
return 1;
}

Expand Down
10 changes: 10 additions & 0 deletions TrinityCore/CreatureMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ namespace LuaCreature
*/
int IsRegeneratingHealth(lua_State* L, Creature* creature)
{
#ifdef CATA
Eluna::Push(L, creature->isRegeneratingHealth());
#else
Eluna::Push(L, creature->CanRegenerateHealth());
#endif
return 1;
}

Expand Down Expand Up @@ -790,6 +794,7 @@ namespace LuaCreature
return 1;
}

#ifndef CATA
/**
* Returns the [Creature]'s shield block value.
*
Expand All @@ -800,6 +805,7 @@ namespace LuaCreature
Eluna::Push(L, creature->GetShieldBlockValue());
return 1;
}
#endif

int GetLootMode(lua_State* L, Creature* creature)
{
Expand Down Expand Up @@ -1276,7 +1282,11 @@ namespace LuaCreature
{ "GetLootRecipientGroup", &LuaCreature::GetLootRecipientGroup },
{ "GetNPCFlags", &LuaCreature::GetNPCFlags },
{ "GetExtraFlags", &LuaCreature::GetExtraFlags },
#ifndef CATA
{ "GetShieldBlockValue", &LuaCreature::GetShieldBlockValue },
#else
{ "GetShieldBlockValue", nullptr },
#endif
{ "GetDBTableGUIDLow", &LuaCreature::GetDBTableGUIDLow },
{ "GetCreatureFamily", &LuaCreature::GetCreatureFamily },

Expand Down
6 changes: 6 additions & 0 deletions TrinityCore/GameObjectMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,13 @@ namespace LuaGameObject
else if (state == 1)
go->SetGoState(GO_STATE_READY);
else if (state == 2)
{
#ifndef CATA
go->SetGoState(GO_STATE_DESTROYED);
#else
go->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE);
#endif
}

return 0;
}
Expand Down
Loading

0 comments on commit 112d10e

Please sign in to comment.