From 9b5499db9cf8ba05893455a276f55cc132e3bf73 Mon Sep 17 00:00:00 2001 From: ayase <137056643@qq.com> Date: Wed, 6 Jun 2018 23:42:46 +0800 Subject: [PATCH] AZEROTHCORE compatibility (#271) * Done Compatible AZEROTHCORE. * Fix TC build * Try fix whitespace (trailing and tabs2spaces) * Remove undefs and TC_LOG defines * Revert indentation change * Indentation and style change * Add more possible SQL types to query * change bg hooks OnBGEnd parameter type. --- AuraMethods.h | 48 +++---- BattleGroundHooks.cpp | 4 + BattleGroundMethods.h | 22 +++ CorpseMethods.h | 6 +- CreatureHooks.cpp | 2 +- CreatureMethods.h | 137 ++++++++++-------- ElunaCreatureAI.h | 26 ++-- ElunaEventMgr.h | 2 +- ElunaIncludes.h | 29 +++- ElunaInstanceAI.h | 8 +- ElunaQueryMethods.h | 30 ++-- ElunaUtility.cpp | 6 +- ElunaUtility.h | 8 ++ GameObjectMethods.h | 12 +- GlobalMethods.h | 98 +++++++++---- GroupMethods.h | 27 ++-- GuildMethods.h | 36 ++--- ItemHooks.cpp | 24 ++-- ItemMethods.h | 24 ++-- LuaEngine.cpp | 8 +- LuaEngine.h | 27 ++-- LuaFunctions.cpp | 20 +-- MapMethods.h | 34 +++-- ObjectMethods.h | 4 + PlayerMethods.h | 204 +++++++++++++++++--------- QuestMethods.h | 12 +- ServerHooks.cpp | 23 +++ SpellMethods.h | 38 ++--- UnitMethods.h | 323 ++++++++++++++++++++++++++---------------- VehicleMethods.h | 32 ++--- WorldObjectMethods.h | 105 +++++++++----- 31 files changed, 869 insertions(+), 510 deletions(-) diff --git a/AuraMethods.h b/AuraMethods.h index 01b116e..0bf3449 100644 --- a/AuraMethods.h +++ b/AuraMethods.h @@ -39,10 +39,10 @@ namespace LuaAura */ int GetCasterGUID(lua_State* L, Aura* aura) { -#ifndef TRINITY - Eluna::Push(L, aura->GetCasterGuid()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, aura->GetCasterGUID()); +#else + Eluna::Push(L, aura->GetCasterGuid()); #endif return 1; } @@ -65,10 +65,10 @@ namespace LuaAura */ int GetDuration(lua_State* L, Aura* aura) { -#ifndef TRINITY - Eluna::Push(L, aura->GetAuraDuration()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, aura->GetDuration()); +#else + Eluna::Push(L, aura->GetAuraDuration()); #endif return 1; } @@ -94,10 +94,10 @@ namespace LuaAura */ int GetMaxDuration(lua_State* L, Aura* aura) { -#ifndef TRINITY - Eluna::Push(L, aura->GetAuraMaxDuration()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, aura->GetMaxDuration()); +#else + Eluna::Push(L, aura->GetAuraMaxDuration()); #endif return 1; } @@ -122,10 +122,10 @@ namespace LuaAura */ int GetOwner(lua_State* L, Aura* aura) { -#ifndef TRINITY - Eluna::Push(L, aura->GetTarget()); -#else +#if defined TRINITY || defined AZEROTHCORE Eluna::Push(L, aura->GetOwner()); +#else + Eluna::Push(L, aura->GetTarget()); #endif return 1; } @@ -138,15 +138,15 @@ namespace LuaAura int SetDuration(lua_State* L, Aura* aura) { int32 duration = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY +#if defined TRINITY || defined AZEROTHCORE + aura->SetDuration(duration); +#else aura->GetHolder()->SetAuraDuration(duration); #if (defined(TBC) || defined(CLASSIC)) aura->GetHolder()->UpdateAuraDuration(); #else aura->GetHolder()->SendAuraUpdate(false); #endif -#else - aura->SetDuration(duration); #endif return 0; } @@ -162,15 +162,15 @@ namespace LuaAura int SetMaxDuration(lua_State* L, Aura* aura) { int32 duration = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY +#if defined TRINITY || defined AZEROTHCORE + aura->SetMaxDuration(duration); +#else aura->GetHolder()->SetAuraMaxDuration(duration); #if (defined(TBC) || defined(CLASSIC)) aura->GetHolder()->UpdateAuraDuration(); #else aura->GetHolder()->SendAuraUpdate(false); #endif -#else - aura->SetMaxDuration(duration); #endif return 0; } @@ -186,10 +186,10 @@ namespace LuaAura int SetStackAmount(lua_State* L, Aura* aura) { uint8 amount = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - aura->GetHolder()->SetStackAmount(amount); -#else +#if defined TRINITY || defined AZEROTHCORE aura->SetStackAmount(amount); +#else + aura->GetHolder()->SetStackAmount(amount); #endif return 0; } @@ -199,10 +199,10 @@ namespace LuaAura */ int Remove(lua_State* L, Aura* aura) { -#ifndef TRINITY - aura->GetTarget()->RemoveSpellAuraHolder(aura->GetHolder(), AURA_REMOVE_BY_CANCEL); -#else +#if defined TRINITY || defined AZEROTHCORE aura->Remove(); +#else + aura->GetTarget()->RemoveSpellAuraHolder(aura->GetHolder(), AURA_REMOVE_BY_CANCEL); #endif Eluna::CHECKOBJ(L, 1)->Invalidate(); return 0; diff --git a/BattleGroundHooks.cpp b/BattleGroundHooks.cpp index f172cb5..497256d 100644 --- a/BattleGroundHooks.cpp +++ b/BattleGroundHooks.cpp @@ -29,7 +29,11 @@ void Eluna::OnBGStart(BattleGround* bg, BattleGroundTypeId bgId, uint32 instance CallAllFunctions(BGEventBindings, key); } +#if AZEROTHCORE +void Eluna::OnBGEnd(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId, TeamId winner) +#else void Eluna::OnBGEnd(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId, Team winner) +#endif { START_HOOK(BG_EVENT_ON_END); Push(bg); diff --git a/BattleGroundMethods.h b/BattleGroundMethods.h index 9ae7d7f..c7226db 100644 --- a/BattleGroundMethods.h +++ b/BattleGroundMethods.h @@ -35,7 +35,11 @@ namespace LuaBattleGround { uint32 team = Eluna::CHECKVAL(L, 2); +#ifndef AZEROTHCORE Eluna::Push(L, bg->GetAlivePlayersCountByTeam((Team)team)); +#else + Eluna::Push(L, bg->GetAlivePlayersCountByTeam((TeamId)team)); +#endif return 1; } @@ -64,6 +68,7 @@ namespace LuaBattleGround return 1; } +#ifndef AZEROTHCORE /** * Returns the bracket ID of the specific [BattleGround]. * @@ -74,6 +79,7 @@ namespace LuaBattleGround Eluna::Push(L, bg->GetBracketId()); return 1; } +#endif /** * Returns the end time of the [BattleGround]. @@ -100,7 +106,11 @@ namespace LuaBattleGround { uint32 team = Eluna::CHECKVAL(L, 2); +#ifndef AZEROTHCORE Eluna::Push(L, bg->GetFreeSlotsForTeam((Team)team)); +#else + Eluna::Push(L, bg->GetFreeSlotsForTeam((TeamId)team)); +#endif return 1; } @@ -133,7 +143,11 @@ namespace LuaBattleGround */ int GetTypeId(lua_State* L, BattleGround* bg) { +#ifndef AZEROTHCORE Eluna::Push(L, bg->GetTypeID()); +#else + Eluna::Push(L, bg->GetBgTypeID()); +#endif return 1; } @@ -166,7 +180,11 @@ namespace LuaBattleGround */ int GetMaxPlayers(lua_State* L, BattleGround* bg) { +#ifndef AZEROTHCORE Eluna::Push(L, bg->GetMaxPlayers()); +#else + Eluna::Push(L, bg->GetMaxPlayersPerTeam() * 2); +#endif return 1; } @@ -177,7 +195,11 @@ namespace LuaBattleGround */ int GetMinPlayers(lua_State* L, BattleGround* bg) { +#ifndef AZEROTHCORE Eluna::Push(L, bg->GetMinPlayers()); +#else + Eluna::Push(L, bg->GetMaxPlayersPerTeam() * 2); +#endif return 1; } diff --git a/CorpseMethods.h b/CorpseMethods.h index 3aec562..852081e 100644 --- a/CorpseMethods.h +++ b/CorpseMethods.h @@ -21,10 +21,10 @@ namespace LuaCorpse */ int GetOwnerGUID(lua_State* L, Corpse* corpse) { -#ifndef TRINITY - Eluna::Push(L, corpse->GetOwnerGuid()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, corpse->GetOwnerGUID()); +#else + Eluna::Push(L, corpse->GetOwnerGuid()); #endif return 1; } diff --git a/CreatureHooks.cpp b/CreatureHooks.cpp index 51be71b..875d749 100644 --- a/CreatureHooks.cpp +++ b/CreatureHooks.cpp @@ -301,7 +301,7 @@ bool Eluna::SpellHitTarget(Creature* me, Unit* target, SpellInfo const* spell) return CallAllFunctionsBool(CreatureEventBindings, CreatureUniqueBindings, entry_key, unique_key); } -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE bool Eluna::SummonedCreatureDies(Creature* me, Creature* summon, Unit* killer) { diff --git a/CreatureMethods.h b/CreatureMethods.h index 1daaf53..b834a90 100644 --- a/CreatureMethods.h +++ b/CreatureMethods.h @@ -37,10 +37,10 @@ namespace LuaCreature { uint32 quest_id = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - Eluna::Push(L, creature->HasInvolvedQuest(quest_id)); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, creature->hasInvolvedQuest(quest_id)); +#else + Eluna::Push(L, creature->HasInvolvedQuest(quest_id)); #endif return 1; } @@ -105,7 +105,7 @@ namespace LuaCreature { Player* player = Eluna::CHECKOBJ(L, 2); -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, creature->isTappedBy(player)); #else Eluna::Push(L, creature->IsTappedBy(player)); @@ -121,10 +121,10 @@ namespace LuaCreature */ int HasLootRecipient(lua_State* L, Creature* creature) { -#ifndef TRINITY - Eluna::Push(L, creature->HasLootRecipient()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, creature->hasLootRecipient()); +#else + Eluna::Push(L, creature->HasLootRecipient()); #endif return 1; } @@ -137,7 +137,7 @@ namespace LuaCreature */ int CanAggro(lua_State* L, Creature* creature) { -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, !creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC)); #else // Eluna::Push(L, creature->CanInitiateAttack()); @@ -190,10 +190,10 @@ namespace LuaCreature */ int IsElite(lua_State* L, Creature* creature) { -#ifndef TRINITY - Eluna::Push(L, creature->IsElite()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, creature->isElite()); +#else + Eluna::Push(L, creature->IsElite()); #endif return 1; } @@ -242,10 +242,10 @@ namespace LuaCreature */ int IsWorldBoss(lua_State* L, Creature* creature) { -#ifndef TRINITY - Eluna::Push(L, creature->IsWorldBoss()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, creature->isWorldBoss()); +#else + Eluna::Push(L, creature->IsWorldBoss()); #endif return 1; } @@ -261,11 +261,16 @@ namespace LuaCreature { uint32 spell = Eluna::CHECKVAL(L, 2); -#ifdef TRINITY +#if defined TRINITY if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell)) Eluna::Push(L, info->GetCategory() && creature->GetSpellHistory()->HasCooldown(spell)); else Eluna::Push(L, false); +#elif AZEROTHCORE + if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell)) + Eluna::Push(L, info->GetCategory() && creature->HasSpellCooldown(spell)); + else + Eluna::Push(L, false); #else Eluna::Push(L, creature->HasCategoryCooldown(spell)); #endif @@ -298,10 +303,10 @@ namespace LuaCreature { uint32 questId = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - Eluna::Push(L, creature->HasQuest(questId)); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, creature->hasQuest(questId)); +#else + Eluna::Push(L, creature->HasQuest(questId)); #endif return 1; } @@ -337,7 +342,7 @@ namespace LuaCreature return 1; } -#ifdef TRINITY +#if defined(TRINITY) || AZEROTHCORE /** * Returns `true` if the [Creature] is an invisible trigger, * and returns `false` otherwise. @@ -372,9 +377,12 @@ namespace LuaCreature int CanStartAttack(lua_State* L, Creature* creature) // TODO: Implement core side { Unit* target = Eluna::CHECKOBJ(L, 2); +#ifndef AZEROTHCORE bool force = Eluna::CHECKVAL(L, 3, true); - Eluna::Push(L, creature->CanStartAttack(target, force)); +#else + Eluna::Push(L, creature->CanStartAttack(target)); +#endif return 1; } @@ -419,7 +427,7 @@ namespace LuaCreature return 1; } -#ifdef TRINITY +#if defined(TRINITY) || AZEROTHCORE /** * Returns the current waypoint path ID of the [Creature]. * @@ -441,6 +449,8 @@ namespace LuaCreature { #ifdef TRINITY Eluna::Push(L, creature->GetCurrentWaypointInfo().first); +#elif AZEROTHCORE + Eluna::Push(L, creature->GetCurrentWaypointID()); #else Eluna::Push(L, creature->GetMotionMaster()->getLastReachedWaypoint()); #endif @@ -468,16 +478,17 @@ namespace LuaCreature { Unit* target = Eluna::CHECKOBJ(L, 2); -#ifndef TRINITY +#if defined TRINITY || AZEROTHCORE + Eluna::Push(L, creature->GetAggroRange(target)); +#else float AttackDist = creature->GetAttackDistance(target); float ThreatRadius = sWorld.getConfig(CONFIG_FLOAT_THREAT_RADIUS); Eluna::Push(L, ThreatRadius > AttackDist ? ThreatRadius : AttackDist); -#else - Eluna::Push(L, creature->GetAggroRange(target)); #endif return 1; } +#ifndef AZEROTHCORE /** * Returns the effective aggro range of the [Creature] for `target`. * @@ -494,6 +505,7 @@ namespace LuaCreature Eluna::Push(L, creature->GetAttackDistance(target)); return 1; } +#endif /** * Returns the [Group] that can loot this [Creature]. @@ -502,10 +514,10 @@ namespace LuaCreature */ int GetLootRecipientGroup(lua_State* L, Creature* creature) { -#ifndef TRINITY - Eluna::Push(L, creature->GetGroupLootRecipient()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, creature->GetLootRecipientGroup()); +#else + Eluna::Push(L, creature->GetGroupLootRecipient()); #endif return 1; } @@ -580,6 +592,11 @@ namespace LuaCreature Eluna::Push(L, creature->GetSpellHistory()->GetRemainingCooldown(spellInfo)); else Eluna::Push(L, 0); +#elif AZEROTHCORE + if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell)) + Eluna::Push(L, creature->GetSpellCooldown(spell)); + else + Eluna::Push(L, 0); #else Eluna::Push(L, creature->GetCreatureSpellCooldownDelay(spell)); #endif @@ -609,10 +626,10 @@ namespace LuaCreature int GetHomePosition(lua_State* L, Creature* creature) { float x, y, z, o; -#ifndef TRINITY - creature->GetRespawnCoord(x, y, z, &o); -#else +#if defined TRINITY || AZEROTHCORE creature->GetHomePosition(x, y, z, o); +#else + creature->GetRespawnCoord(x, y, z, &o); #endif Eluna::Push(L, x); @@ -638,10 +655,10 @@ namespace LuaCreature float z = Eluna::CHECKVAL(L, 4); float o = Eluna::CHECKVAL(L, 5); -#ifndef TRINITY - creature->SetRespawnCoord(x, y, z, o); -#else +#if defined TRINITY || AZEROTHCORE creature->SetHomePosition(x, y, z, o); +#else + creature->SetRespawnCoord(x, y, z, o); #endif return 0; @@ -699,6 +716,10 @@ namespace LuaCreature #ifdef TRINITY auto const& threatlist = creature->GetThreatManager().GetThreatenedByMeList(); #endif +#ifdef AZEROTHCORE + auto const& threatlist = creature->getThreatManager().getThreatList(); +#endif + if (threatlist.empty()) return 1; if (position >= threatlist.size()) @@ -782,6 +803,8 @@ namespace LuaCreature { #ifdef TRINITY auto const& threatlist = creature->GetThreatManager().GetThreatenedByMeList(); +#elif defined AZEROTHCORE +auto const& threatlist = creature->getThreatManager().getThreatList(); #else ThreatList const& threatlist = creature->GetThreatManager().getThreatList(); #endif @@ -814,6 +837,8 @@ namespace LuaCreature { #ifdef TRINITY Eluna::Push(L, creature->GetThreatManager().GetThreatenedByMeList().size()); +#elif AZEROTHCORE + Eluna::Push(L, creature->getThreatManager().getThreatList().size()); #else Eluna::Push(L, creature->GetThreatManager().getThreatList().size()); #endif @@ -847,7 +872,7 @@ namespace LuaCreature } #endif -#ifdef TRINITY +#if defined(TRINITY) || AZEROTHCORE int GetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features { Eluna::Push(L, creature->GetLootMode()); @@ -894,7 +919,7 @@ namespace LuaCreature { bool disable = Eluna::CHECKVAL(L, 2); -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE creature->SetDisableGravity(disable); #else creature->SetLevitate(disable); @@ -902,7 +927,7 @@ namespace LuaCreature return 0; } -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE int SetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features { uint16 lootMode = Eluna::CHECKVAL(L, 2); @@ -921,10 +946,10 @@ namespace LuaCreature { int32 state = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - creature->SetDeathState((DeathState)state); -#else +#if defined TRINITY || AZEROTHCORE creature->setDeathState((DeathState)state); +#else + creature->SetDeathState((DeathState)state); #endif return 0; } @@ -955,7 +980,7 @@ namespace LuaCreature uint32 off_hand = Eluna::CHECKVAL(L, 3); uint32 ranged = Eluna::CHECKVAL(L, 4); -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, main_hand); creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, off_hand); creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, ranged); @@ -976,7 +1001,7 @@ namespace LuaCreature { bool allow = Eluna::CHECKVAL(L, 2, true); -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE if (allow) creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC); else @@ -1012,7 +1037,7 @@ namespace LuaCreature */ int SetInCombatWithZone(lua_State* /*L*/, Creature* creature) { -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE if (creature->IsAIEnabled) creature->AI()->DoZoneInCombat(); #else @@ -1095,7 +1120,7 @@ namespace LuaCreature { bool enable = Eluna::CHECKVAL(L, 2, true); -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE creature->SetHover(enable); #else // Copy paste from Aura::HandleAuraHover @@ -1125,10 +1150,10 @@ namespace LuaCreature { uint32 msTimeToDespawn = Eluna::CHECKVAL(L, 2, 0); -#ifndef TRINITY - creature->ForcedDespawn(msTimeToDespawn); -#else +#if defined TRINITY || AZEROTHCORE creature->DespawnOrUnsummon(msTimeToDespawn); +#else + creature->ForcedDespawn(msTimeToDespawn); #endif return 0; } @@ -1156,10 +1181,10 @@ namespace LuaCreature */ int MoveWaypoint(lua_State* /*L*/, Creature* creature) { -#ifndef TRINITY - creature->GetMotionMaster()->MoveWaypoint(); -#else +#if defined TRINITY || AZEROTHCORE creature->GetMotionMaster()->MovePath(creature->GetWaypointPath(), true); +#else + creature->GetMotionMaster()->MoveWaypoint(); #endif return 0; } @@ -1224,10 +1249,10 @@ namespace LuaCreature */ int SelectVictim(lua_State* L, Creature* creature) { -#ifndef TRINITY - Eluna::Push(L, creature->SelectHostileTarget()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, creature->SelectVictim()); +#else + Eluna::Push(L, creature->SelectHostileTarget()); #endif return 1; } @@ -1243,15 +1268,15 @@ namespace LuaCreature uint32 entry = Eluna::CHECKVAL(L, 2); uint32 dataGuidLow = Eluna::CHECKVAL(L, 3, 0); -#ifndef TRINITY - creature->UpdateEntry(entry, ALLIANCE, dataGuidLow ? eObjectMgr->GetCreatureData(dataGuidLow) : NULL); -#else +#if defined TRINITY || AZEROTHCORE creature->UpdateEntry(entry, dataGuidLow ? eObjectMgr->GetCreatureData(dataGuidLow) : NULL); +#else + creature->UpdateEntry(entry, ALLIANCE, dataGuidLow ? eObjectMgr->GetCreatureData(dataGuidLow) : NULL); #endif return 0; } -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE /** * Resets [Creature]'s loot mode to default */ diff --git a/ElunaCreatureAI.h b/ElunaCreatureAI.h index 4cd4b46..74dff8a 100644 --- a/ElunaCreatureAI.h +++ b/ElunaCreatureAI.h @@ -9,11 +9,11 @@ #include "LuaEngine.h" -#ifndef TRINITY +#if defined TRINITY || AZEROTHCORE +struct ScriptedAI; +#else class AggressorAI; typedef AggressorAI ScriptedAI; -#else -struct ScriptedAI; #endif struct ElunaCreatureAI : ScriptedAI @@ -22,7 +22,7 @@ struct ElunaCreatureAI : ScriptedAI bool justSpawned; // used to delay movementinform hook (WP hook) std::vector< std::pair > movepoints; -#ifndef TRINITY +#if defined MANGOS || defined CMANGOS #define me m_creature #endif @@ -60,7 +60,7 @@ struct ElunaCreatureAI : ScriptedAI if (!sEluna->UpdateAI(me, diff)) { -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC)) ScriptedAI::UpdateAI(diff); #else @@ -89,10 +89,20 @@ struct ElunaCreatureAI : ScriptedAI #endif // Called at any Damage from any attacker (before damage apply) +#if AZEROTHCORE + void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask) override +#else void DamageTaken(Unit* attacker, uint32& damage) override +#endif { if (!sEluna->DamageTaken(me, attacker, damage)) + { +#if AZEROTHCORE + ScriptedAI::DamageTaken(attacker, damage, damagetype, damageSchoolMask); +#else ScriptedAI::DamageTaken(attacker, damage); +#endif + } } //Called at creature death @@ -191,7 +201,7 @@ struct ElunaCreatureAI : ScriptedAI ScriptedAI::CorpseRemoved(respawnDelay); } -#ifndef TRINITY +#if !defined TRINITY && !AZEROTHCORE // Enables use of MoveInLineOfSight bool IsVisible(Unit* who) const override { @@ -219,7 +229,7 @@ struct ElunaCreatureAI : ScriptedAI ScriptedAI::SpellHitTarget(target, spell); } -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE // Called when the creature is summoned successfully by other creature void IsSummonedBy(Unit* summoner) override @@ -249,7 +259,7 @@ struct ElunaCreatureAI : ScriptedAI } #endif -#ifndef TRINITY +#if defined MANGOS || defined CMANGOS #undef me #endif }; diff --git a/ElunaEventMgr.h b/ElunaEventMgr.h index 434e9c1..013c8ea 100644 --- a/ElunaEventMgr.h +++ b/ElunaEventMgr.h @@ -16,7 +16,7 @@ #endif #include -#ifdef TRINITY +#if defined(TRINITY) || AZEROTHCORE #include "Define.h" #else #include "Platform/Define.h" diff --git a/ElunaIncludes.h b/ElunaIncludes.h index 2e450be..e3ea622 100644 --- a/ElunaIncludes.h +++ b/ElunaIncludes.h @@ -39,7 +39,14 @@ #include "WorldPacket.h" #include "WorldSession.h" -#ifdef TRINITY +#if defined TRINITY +#include "GitRevision.h" +#include "SpellHistory.h" +#include +#include +#endif + +#if defined TRINITY || defined AZEROTHCORE #include "Config.h" #include "GameEventMgr.h" #include "GroupMgr.h" @@ -47,13 +54,9 @@ #include "SpellInfo.h" #include "WeatherMgr.h" #include "Battleground.h" -#include "GitRevision.h" -#include "SpellHistory.h" #include "MotionMaster.h" #include "DatabaseEnv.h" #include "Bag.h" -#include -#include #else #include "Config/Config.h" #ifdef CMANGOS @@ -111,7 +114,21 @@ typedef Opcodes OpcodesList; #endif #endif -#ifndef TRINITY +#ifdef AZEROTHCORE +#define CORE_NAME "AzerothCore" +#define CORE_VERSION "" +#define eWorld (sWorld) +#define eMapMgr (sMapMgr) +#define eConfigMgr (sConfigMgr) +#define eGuildMgr (sGuildMgr) +#define eObjectMgr (sObjectMgr) +#define eAccountMgr (sAccountMgr) +#define eAuctionMgr (sAuctionMgr) +#define eGameEventMgr (sGameEventMgr) +#define eObjectAccessor() ObjectAccessor:: +#endif + +#if !defined TRINITY && !AZEROTHCORE #define eWorld (&sWorld) #define eMapMgr (&sMapMgr) #define eConfigMgr (&sConfig) diff --git a/ElunaInstanceAI.h b/ElunaInstanceAI.h index c28d6f4..2d532f7 100644 --- a/ElunaInstanceAI.h +++ b/ElunaInstanceAI.h @@ -8,7 +8,7 @@ #define _ELUNA_INSTANCE_DATA_H #include "LuaEngine.h" -#ifdef TRINITY +#if defined(TRINITY) || AZEROTHCORE #include "InstanceScript.h" #else #include "InstanceData.h" @@ -72,7 +72,7 @@ public: * data table to/from the core. */ void Load(const char* data) override; -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE // Simply calls Save, since the functions are a bit different in name and data types on different cores std::string GetSaveData() override { @@ -128,7 +128,7 @@ public: sEluna->OnPlayerEnterInstance(this, player); } -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE void OnGameObjectCreate(GameObject* gameobject) override #else void OnObjectCreate(GameObject* gameobject) override @@ -143,4 +143,4 @@ public: } }; -#endif // _ELUNA_INSTANCE_DATA_H \ No newline at end of file +#endif // _ELUNA_INSTANCE_DATA_H diff --git a/ElunaQueryMethods.h b/ElunaQueryMethods.h index 2f388c6..4b6546b 100644 --- a/ElunaQueryMethods.h +++ b/ElunaQueryMethods.h @@ -7,10 +7,10 @@ #ifndef QUERYMETHODS_H #define QUERYMETHODS_H -#ifndef TRINITY -#define RESULT result -#else +#if defined TRINITY || defined AZEROTHCORE #define RESULT (*result) +#else +#define RESULT result #endif /*** @@ -45,10 +45,10 @@ namespace LuaQuery uint32 col = Eluna::CHECKVAL(L, 2); CheckFields(L, result); -#ifndef TRINITY - Eluna::Push(L, RESULT->Fetch()[col].IsNULL()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, RESULT->Fetch()[col].IsNull()); +#else + Eluna::Push(L, RESULT->Fetch()[col].IsNULL()); #endif return 1; } @@ -291,13 +291,13 @@ namespace LuaQuery lua_createtable(L, 0, col); int tbl = lua_gettop(L); -#ifndef TRINITY +#if !defined TRINITY && !AZEROTHCORE const QueryFieldNames& names = RESULT->GetFieldNames(); #endif for (uint32 i = 0; i < col; ++i) { -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, RESULT->GetFieldName(i)); const char* str = row[i].GetCString(); @@ -308,12 +308,26 @@ namespace LuaQuery // MYSQL_TYPE_LONGLONG Interpreted as string for lua switch (row[i].GetType()) { +#ifndef AZEROTHCORE case DatabaseFieldTypes::Int8: case DatabaseFieldTypes::Int16: case DatabaseFieldTypes::Int32: case DatabaseFieldTypes::Int64: case DatabaseFieldTypes::Float: case DatabaseFieldTypes::Double: +#else + case MYSQL_TYPE_TINY: + case MYSQL_TYPE_YEAR: + case MYSQL_TYPE_SHORT: + case MYSQL_TYPE_INT24: + case MYSQL_TYPE_LONG: + case MYSQL_TYPE_LONGLONG: + case MYSQL_TYPE_BIT: + case MYSQL_TYPE_FLOAT: + case MYSQL_TYPE_DOUBLE: + case MYSQL_TYPE_DECIMAL: + case MYSQL_TYPE_NEWDECIMAL: +#endif Eluna::Push(L, strtod(str, NULL)); break; default: diff --git a/ElunaUtility.cpp b/ElunaUtility.cpp index c0ed224..439ba0c 100644 --- a/ElunaUtility.cpp +++ b/ElunaUtility.cpp @@ -13,7 +13,7 @@ uint32 ElunaUtil::GetCurrTime() { -#ifndef TRINITY +#if !defined TRINITY && !AZEROTHCORE return WorldTimer::getMSTime(); #else return getMSTime(); @@ -22,7 +22,7 @@ uint32 ElunaUtil::GetCurrTime() uint32 ElunaUtil::GetTimeDiff(uint32 oldMSTime) { -#ifndef TRINITY +#if !defined TRINITY && !AZEROTHCORE return WorldTimer::getMSTimeDiff(oldMSTime, GetCurrTime()); #else return GetMSTimeDiffToNow(oldMSTime); @@ -90,7 +90,7 @@ bool ElunaUtil::WorldObjectInRangeCheck::operator()(WorldObject* u) { if (i_obj_fact) { -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE if ((i_obj_fact->IsHostileTo(*target->GetFactionTemplateEntry())) != (i_hostile == 1)) return false; #else diff --git a/ElunaUtility.h b/ElunaUtility.h index 1bc277e..6263312 100644 --- a/ElunaUtility.h +++ b/ElunaUtility.h @@ -44,6 +44,12 @@ typedef QueryResult ElunaQuery; #define HIGHGUID_MO_TRANSPORT HighGuid::Mo_Transport #define HIGHGUID_INSTANCE HighGuid::Instance #define HIGHGUID_GROUP HighGuid::Group +#elif AZEROTHCORE +typedef QueryResult ElunaQuery; +#define ELUNA_LOG_INFO(...) sLog->outString(__VA_ARGS__); +#define ELUNA_LOG_ERROR(...) sLog->outError(__VA_ARGS__); +#define ELUNA_LOG_DEBUG(...) sLog->outDebug(LOG_FILTER_NONE,__VA_ARGS__); +#define GET_GUID GetGUID #else typedef QueryNamedResult ElunaQuery; #define ASSERT MANGOS_ASSERT @@ -56,6 +62,7 @@ typedef QueryNamedResult ElunaQuery; #define GetTemplate GetProto #endif +#ifdef TRINITY #ifndef MAKE_NEW_GUID #define MAKE_NEW_GUID(l, e, h) ObjectGuid(h, e, l) #endif @@ -68,6 +75,7 @@ typedef QueryNamedResult ElunaQuery; #ifndef GUID_HIPART #define GUID_HIPART(guid) ObjectGuid(guid).GetHigh() #endif +#endif class Unit; class WorldObject; diff --git a/GameObjectMethods.h b/GameObjectMethods.h index 4e3ac80..d97de7a 100644 --- a/GameObjectMethods.h +++ b/GameObjectMethods.h @@ -22,10 +22,10 @@ namespace LuaGameObject { uint32 questId = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - Eluna::Push(L, go->HasQuest(questId)); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, go->hasQuest(questId)); +#else + Eluna::Push(L, go->HasQuest(questId)); #endif return 1; } @@ -145,7 +145,7 @@ namespace LuaGameObject */ int GetLootRecipientGroup(lua_State* L, GameObject* go) { -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, go->GetLootRecipientGroup()); #else Eluna::Push(L, go->GetGroupLootRecipient()); @@ -162,6 +162,8 @@ namespace LuaGameObject { #ifdef TRINITY Eluna::Push(L, go->GetSpawnId()); +#elif AZEROTHCORE + Eluna::Push(L, go->GetDBTableGUIDLow()); #else // on mangos based this is same as lowguid Eluna::Push(L, go->GetGUIDLow()); @@ -251,7 +253,7 @@ namespace LuaGameObject bool deldb = Eluna::CHECKVAL(L, 2, false); // cs_gobject.cpp copy paste -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE ObjectGuid ownerGuid = go->GetOwnerGUID(); #else ObjectGuid ownerGuid = go->GetOwnerGuid(); diff --git a/GlobalMethods.h b/GlobalMethods.h index 3f6e186..809e32a 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -171,6 +171,8 @@ namespace LuaGlobalFunctions { #ifdef TRINITY boost::shared_lock lock(*HashMapHolder::GetLock()); +#elif AZEROTHCORE + TRINITY_READ_GUARD(HashMapHolder::LockType, *HashMapHolder::GetLock()); #else HashMapHolder::ReadGuard g(HashMapHolder::GetLock()); #endif @@ -181,10 +183,10 @@ namespace LuaGlobalFunctions { if (!player->IsInWorld()) continue; -#ifndef TRINITY - if ((team == TEAM_NEUTRAL || player->GetTeamId() == team) && (!onlyGM || player->isGameMaster())) -#else +#if defined TRINITY || AZEROTHCORE if ((team == TEAM_NEUTRAL || player->GetTeamId() == team) && (!onlyGM || player->IsGameMaster())) +#else + if ((team == TEAM_NEUTRAL || player->GetTeamId() == team) && (!onlyGM || player->isGameMaster())) #endif { Eluna::Push(L, player); @@ -456,7 +458,7 @@ namespace LuaGlobalFunctions if (locale >= TOTAL_LOCALES) return luaL_argerror(L, 2, "valid LocaleConstant expected"); -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaOrZoneId); #else AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaOrZoneId); @@ -1208,7 +1210,7 @@ namespace LuaGlobalFunctions { const char* query = Eluna::CHECKVAL(L, 1); -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE ElunaQuery result = WorldDatabase.Query(query); if (result) Eluna::Push(L, new ElunaQuery(result)); @@ -1259,7 +1261,7 @@ namespace LuaGlobalFunctions { const char* query = Eluna::CHECKVAL(L, 1); -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE QueryResult result = CharacterDatabase.Query(query); if (result) Eluna::Push(L, new QueryResult(result)); @@ -1310,7 +1312,7 @@ namespace LuaGlobalFunctions { const char* query = Eluna::CHECKVAL(L, 1); -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE QueryResult result = LoginDatabase.Query(query); if (result) Eluna::Push(L, new QueryResult(result)); @@ -1468,7 +1470,7 @@ namespace LuaGlobalFunctions } #endif -#ifndef TRINITY +#if !defined TRINITY && !AZEROTHCORE Map* map = eMapMgr->FindMap(mapID, instanceID); if (!map) { @@ -1668,7 +1670,11 @@ namespace LuaGlobalFunctions if (save) { Creature* creature = new Creature(); +#ifndef AZEROTHCORE if (!creature->Create(map->GenerateLowGuid(), map, phase, entry, pos)) +#else + if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, phase, entry, 0, x, y, z, o)) +#endif { delete creature; Eluna::Push(L); @@ -1677,14 +1683,21 @@ namespace LuaGlobalFunctions creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), phase); +#ifndef AZEROTHCORE uint32 db_guid = creature->GetSpawnId(); - +#else + uint32 db_guid = creature->GetDBTableGUIDLow(); +#endif // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells() // current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior creature->CleanupsBeforeDelete(); delete creature; creature = new Creature(); +#ifndef AZEROTHCORE if (!creature->LoadFromDB(db_guid, map, true, true)) +#else + if (!creature->LoadFromDB(db_guid, map)) +#endif { delete creature; Eluna::Push(L); @@ -1730,10 +1743,14 @@ namespace LuaGlobalFunctions } GameObject* object = new GameObject; +#ifndef AZEROTHCORE uint32 guidLow = map->GenerateLowGuid(); - QuaternionData rot = QuaternionData::fromEulerAnglesZYX(o, 0.f, 0.f); if (!object->Create(guidLow, objectInfo->entry, map, phase, Position(x, y, z, o), rot, 0, GO_STATE_READY)) +#else + uint32 guidLow = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT); + if (!object->Create(guidLow, entry, map, phase, x, y, z, o, G3D::Quat(0.0f, 0.0f, 0.0f, 0.0f), 100, GO_STATE_READY)) +#endif { delete object; Eluna::Push(L); @@ -1747,7 +1764,11 @@ namespace LuaGlobalFunctions { // fill the gameobject data and save to the db object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), phase); +#ifndef AZEROTHCORE guidLow = object->GetSpawnId(); +#else + guidLow = object->GetDBTableGUIDLow(); +#endif // delete the old object and do a clean load from DB with a fresh new GameObject instance. // this is required to avoid weird behavior and memory leaks @@ -1755,14 +1776,21 @@ namespace LuaGlobalFunctions object = new GameObject(); // this will generate a new lowguid if the object is in an instance +#ifndef AZEROTHCORE if (!object->LoadFromDB(guidLow, map, true)) +#else + if (!object->LoadFromDB(guidLow, map)) +#endif { delete object; Eluna::Push(L); return 1; } - +#ifndef AZEROTHCORE eObjectMgr->AddGameobjectToGrid(guidLow, eObjectMgr->GetGameObjectData(guidLow)); +#else + eObjectMgr->AddGameobjectToGrid(guidLow, eObjectMgr->GetGOData(guidLow)); +#endif } else map->AddToMap(object); @@ -1809,15 +1837,7 @@ namespace LuaGlobalFunctions uint32 incrtime = Eluna::CHECKVAL(L, 4); uint32 extendedcost = Eluna::CHECKVAL(L, 5); -#ifndef TRINITY - if (!eObjectMgr->IsVendorItemValid(false, "npc_vendor", entry, item, maxcount, incrtime, extendedcost, 0)) - return 0; -#ifndef CLASSIC - eObjectMgr->AddVendorItem(entry, item, maxcount, incrtime, extendedcost); -#else - eObjectMgr->AddVendorItem(entry, item, maxcount, incrtime); -#endif -#else +#if defined TRINITY || AZEROTHCORE #ifdef CATA if (!eObjectMgr->IsVendorItemValid(entry, item, maxcount, incrtime, extendedcost, 1)) return 0; @@ -1827,7 +1847,15 @@ namespace LuaGlobalFunctions return 0; eObjectMgr->AddVendorItem(entry, item, maxcount, incrtime, extendedcost); #endif +#else + if (!eObjectMgr->IsVendorItemValid(false, "npc_vendor", entry, item, maxcount, incrtime, extendedcost, 0)) + return 0; +#ifndef CLASSIC + eObjectMgr->AddVendorItem(entry, item, maxcount, incrtime, extendedcost); +#else + eObjectMgr->AddVendorItem(entry, item, maxcount, incrtime); #endif +#endif//TRINITY return 0; } @@ -1938,7 +1966,11 @@ namespace LuaGlobalFunctions return 0; } +#ifndef AZEROTHCORE eWorld->BanAccount((BanMode)banMode, nameOrIP, duration, reason, whoBanned); +#else + eWorld->BanAccount((BanMode)banMode, nameOrIP, std::to_string(duration) + "s", reason, whoBanned); +#endif return 0; } @@ -1995,7 +2027,7 @@ namespace LuaGlobalFunctions MailSender sender(MAIL_NORMAL, senderGUIDLow, (MailStationery)stationary); MailDraft draft(subject, text); -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE if (cod) draft.AddCOD(cod); if (money) @@ -2007,7 +2039,7 @@ namespace LuaGlobalFunctions draft.SetMoney(money); #endif -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE SQLTransaction trans = CharacterDatabase.BeginTransaction(); #endif uint8 addedItems = 0; @@ -2016,10 +2048,10 @@ namespace LuaGlobalFunctions uint32 entry = Eluna::CHECKVAL(L, ++i); uint32 amount = Eluna::CHECKVAL(L, ++i); -#ifndef TRINITY - ItemTemplate const* item_proto = ObjectMgr::GetItemPrototype(entry); -#else +#if defined TRINITY || AZEROTHCORE ItemTemplate const* item_proto = eObjectMgr->GetItemTemplate(entry); +#else + ItemTemplate const* item_proto = ObjectMgr::GetItemPrototype(entry); #endif if (!item_proto) { @@ -2033,21 +2065,21 @@ namespace LuaGlobalFunctions } if (Item* item = Item::CreateItem(entry, amount)) { -#ifndef TRINITY - item->SaveToDB(); -#else +#if defined TRINITY || AZEROTHCORE item->SaveToDB(trans); +#else + item->SaveToDB(); #endif draft.AddItem(item); ++addedItems; } } -#ifndef TRINITY - draft.SendMailTo(MailReceiver(MAKE_NEW_GUID(receiverGUIDLow, 0, HIGHGUID_PLAYER)), sender); -#else +#if defined TRINITY || AZEROTHCORE draft.SendMailTo(trans, MailReceiver(receiverGUIDLow), sender, MAIL_CHECK_MASK_NONE, delay); CharacterDatabase.CommitTransaction(trans); +#else + draft.SendMailTo(MailReceiver(MAKE_NEW_GUID(receiverGUIDLow, 0, HIGHGUID_PLAYER)), sender); #endif return 0; } @@ -2276,7 +2308,11 @@ namespace LuaGlobalFunctions nodeEntry->MountCreatureID[0] = mountH; nodeEntry->MountCreatureID[1] = mountA; sTaxiNodesStore.SetEntry(nodeId++, nodeEntry); +#ifndef AZEROTHCORE sTaxiPathNodesByPath[pathId].set(index++, new TaxiPathNodeEntry(entry)); +#else + sTaxiPathNodesByPath[pathId][index++] = new TaxiPathNodeEntry(entry); +#endif #endif } if (startNode >= nodeId) diff --git a/GroupMethods.h b/GroupMethods.h index 779d29e..38871f0 100644 --- a/GroupMethods.h +++ b/GroupMethods.h @@ -138,7 +138,7 @@ namespace LuaGroup if (Group* invitedgroup = player->GetGroupInvite()) player->UninviteFromGroup(); -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE bool success = group->AddMember(player); if (success) group->BroadcastGroupUpdate(); @@ -175,10 +175,10 @@ namespace LuaGroup for (GroupReference* itr = group->GetFirstMember(); itr; itr = itr->next()) { -#ifndef TRINITY - Player* member = itr->getSource(); -#else +#if defined TRINITY || AZEROTHCORE Player* member = itr->GetSource(); +#else + Player* member = itr->getSource(); #endif if (!member || !member->GetSession()) @@ -199,10 +199,10 @@ namespace LuaGroup */ int GetLeaderGUID(lua_State* L, Group* group) { -#ifndef TRINITY - Eluna::Push(L, group->GetLeaderGuid()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, group->GetLeaderGUID()); +#else + Eluna::Push(L, group->GetLeaderGuid()); #endif return 1; } @@ -231,10 +231,10 @@ namespace LuaGroup int GetMemberGUID(lua_State* L, Group* group) { const char* name = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - Eluna::Push(L, group->GetMemberGuid(name)); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, group->GetMemberGUID(name)); +#else + Eluna::Push(L, group->GetMemberGuid(name)); #endif return 1; } @@ -319,10 +319,10 @@ namespace LuaGroup uint64 guid = Eluna::CHECKVAL(L, 2); uint32 method = Eluna::CHECKVAL(L, 3, 0); -#ifndef TRINITY - Eluna::Push(L, group->RemoveMember(ObjectGuid(guid), method)); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, group->RemoveMember(ObjectGuid(guid), (RemoveMethod)method)); +#else + Eluna::Push(L, group->RemoveMember(ObjectGuid(guid), method)); #endif return 1; } @@ -401,4 +401,5 @@ namespace LuaGroup return 0; }*/ }; + #endif diff --git a/GuildMethods.h b/GuildMethods.h index 5cdc857..1e669e5 100644 --- a/GuildMethods.h +++ b/GuildMethods.h @@ -38,6 +38,8 @@ namespace LuaGuild { #ifdef TRINITY boost::shared_lock lock(*HashMapHolder::GetLock()); +#elif AZEROTHCORE + TRINITY_READ_GUARD(HashMapHolder::LockType, *HashMapHolder::GetLock()); #else HashMapHolder::ReadGuard g(HashMapHolder::GetLock()); #endif @@ -66,7 +68,7 @@ namespace LuaGuild */ int GetMemberCount(lua_State* L, Guild* guild) { -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, guild->GetMemberCount()); #else Eluna::Push(L, guild->GetMemberSize()); @@ -81,10 +83,10 @@ namespace LuaGuild */ int GetLeader(lua_State* L, Guild* guild) { -#ifndef TRINITY - Eluna::Push(L, eObjectAccessor()FindPlayer(guild->GetLeaderGuid())); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, eObjectAccessor()FindPlayer(guild->GetLeaderGUID())); +#else + Eluna::Push(L, eObjectAccessor()FindPlayer(guild->GetLeaderGuid())); #endif return 1; } @@ -96,10 +98,10 @@ namespace LuaGuild */ int GetLeaderGUID(lua_State* L, Guild* guild) { -#ifndef TRINITY - Eluna::Push(L, guild->GetLeaderGuid()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, guild->GetLeaderGUID()); +#else + Eluna::Push(L, guild->GetLeaderGuid()); #endif return 1; } @@ -144,10 +146,10 @@ namespace LuaGuild */ int GetInfo(lua_State* L, Guild* guild) { -#ifndef TRINITY - Eluna::Push(L, guild->GetGINFO()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, guild->GetInfo()); +#else + Eluna::Push(L, guild->GetGINFO()); #endif return 1; } @@ -162,10 +164,10 @@ namespace LuaGuild { Player* player = Eluna::CHECKOBJ(L, 2); -#ifndef TRINITY - guild->SetLeader(player->GET_GUID()); -#else +#if defined TRINITY || AZEROTHCORE guild->HandleSetLeader(player->GetSession(), player->GetName()); +#else + guild->SetLeader(player->GET_GUID()); #endif return 0; } @@ -182,10 +184,10 @@ namespace LuaGuild { uint8 tabId = Eluna::CHECKVAL(L, 2); const char* text = Eluna::CHECKVAL(L, 3); -#ifndef TRINITY - guild->SetGuildBankTabText(tabId, text); -#else +#if defined TRINITY || AZEROTHCORE guild->SetBankTabText(tabId, text); +#else + guild->SetGuildBankTabText(tabId, text); #endif return 0; } @@ -271,7 +273,7 @@ namespace LuaGuild Player* player = Eluna::CHECKOBJ(L, 2); bool isDisbanding = Eluna::CHECKVAL(L, 3, false); -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE SQLTransaction trans(nullptr); guild->DeleteMember(trans, player->GET_GUID(), isDisbanding); #else diff --git a/ItemHooks.cpp b/ItemHooks.cpp index 0dc4c86..1bf7c98 100644 --- a/ItemHooks.cpp +++ b/ItemHooks.cpp @@ -79,18 +79,7 @@ bool Eluna::OnItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targ START_HOOK_WITH_RETVAL(ITEM_EVENT_ON_USE, pItem->GetEntry(), true); Push(pPlayer); Push(pItem); -#ifndef TRINITY - if (GameObject* target = targets.getGOTarget()) - Push(target); - else if (Item* target = targets.getItemTarget()) - Push(target); - else if (Corpse* target = pPlayer->GetMap()->GetCorpse(targets.getCorpseTargetGuid())) - Push(target); - else if (Unit* target = targets.getUnitTarget()) - Push(target); - else - Push(); -#else +#if defined TRINITY || AZEROTHCORE if (GameObject* target = targets.GetGOTarget()) Push(target); else if (Item* target = targets.GetItemTarget()) @@ -103,6 +92,17 @@ bool Eluna::OnItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targ Push(target); else Push(); +#else + if (GameObject* target = targets.getGOTarget()) + Push(target); + else if (Item* target = targets.getItemTarget()) + Push(target); + else if (Corpse* target = pPlayer->GetMap()->GetCorpse(targets.getCorpseTargetGuid())) + Push(target); + else if (Unit* target = targets.getUnitTarget()) + Push(target); + else + Push(); #endif return CallAllFunctionsBool(ItemEventBindings, key, true); diff --git a/ItemMethods.h b/ItemMethods.h index fa4b1ef..f610989 100644 --- a/ItemMethods.h +++ b/ItemMethods.h @@ -176,10 +176,10 @@ namespace LuaItem int HasQuest(lua_State* L, Item* item) { uint32 quest = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - Eluna::Push(L, item->HasQuest(quest)); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, item->hasQuest(quest)); +#else + Eluna::Push(L, item->HasQuest(quest)); #endif return 1; } @@ -315,10 +315,10 @@ namespace LuaItem int GetOwnerGUID(lua_State* L, Item* item) { -#ifndef TRINITY - Eluna::Push(L, item->GetOwnerGuid()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, item->GetOwnerGUID()); +#else + Eluna::Push(L, item->GetOwnerGuid()); #endif return 1; } @@ -630,10 +630,10 @@ namespace LuaItem int SetOwner(lua_State* L, Item* item) { Player* player = Eluna::CHECKOBJ(L, 2); -#ifndef TRINITY - item->SetOwnerGuid(player->GET_GUID()); -#else +#if defined TRINITY || AZEROTHCORE item->SetOwnerGUID(player->GET_GUID()); +#else + item->SetOwnerGuid(player->GET_GUID()); #endif return 0; } @@ -736,11 +736,11 @@ namespace LuaItem */ int SaveToDB(lua_State* /*L*/, Item* item) { -#ifndef TRINITY - item->SaveToDB(); -#else +#if defined TRINITY || AZEROTHCORE SQLTransaction trans = SQLTransaction(NULL); item->SaveToDB(trans); +#else + item->SaveToDB(); #endif return 0; } diff --git a/LuaEngine.cpp b/LuaEngine.cpp index c8ae8c4..000d1ba 100644 --- a/LuaEngine.cpp +++ b/LuaEngine.cpp @@ -28,7 +28,7 @@ // Some dummy includes containing BOOST_VERSION: // ObjectAccessor.h Config.h Log.h -#ifndef MANGOS +#if !defined MANGOS && !defined AZEROTHCORE #define USING_BOOST #endif @@ -66,7 +66,7 @@ void Eluna::Initialize() LOCK_ELUNA; ASSERT(!IsInitialized()); -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE // For instance data the data column needs to be able to hold more than 255 characters (tinytext) // so we change it to TEXT automatically on startup CharacterDatabase.DirectExecute("ALTER TABLE `instance` CHANGE COLUMN `data` `data` TEXT NOT NULL"); @@ -519,7 +519,11 @@ void Eluna::RunScripts() void Eluna::InvalidateObjects() { ++callstackid; +#ifdef AZEROTHCORE + ASSERT(callstackid && "Callstackid overflow"); +#else ASSERT(callstackid, "Callstackid overflow"); +#endif } void Eluna::Report(lua_State* _L) diff --git a/LuaEngine.h b/LuaEngine.h index a45ae17..db372f9 100644 --- a/LuaEngine.h +++ b/LuaEngine.h @@ -13,7 +13,7 @@ #include "Group.h" #include "Item.h" -#ifndef TRINITY +#if defined(TRINITY) || AZEROTHCORE #include "Player.h" #endif #include "Weather.h" @@ -28,7 +28,7 @@ extern "C" #include "lua.h" }; -#ifdef TRINITY +#if defined(TRINITY) || AZEROTHCORE struct ItemTemplate; typedef BattlegroundTypeId BattleGroundTypeId; #else @@ -41,11 +41,14 @@ typedef SpellEntry SpellInfo; typedef int Difficulty; #endif #endif - +#ifndef AZEROTHCORE struct AreaTriggerEntry; +#else +typedef AreaTrigger AreaTriggerEntry; +#endif class AuctionHouseObject; struct AuctionEntry; -#ifdef TRINITY +#if defined(TRINITY) || AZEROTHCORE class Battleground; typedef Battleground BattleGround; #endif @@ -54,12 +57,12 @@ class Corpse; class Creature; class CreatureAI; class GameObject; -#ifdef TRINITY +#if defined(TRINITY) || AZEROTHCORE class GameObjectAI; #endif class Guild; class Group; -#ifdef TRINITY +#if defined(TRINITY) || AZEROTHCORE class InstanceScript; typedef InstanceScript InstanceData; #else @@ -72,7 +75,7 @@ class Player; class Quest; class Spell; class SpellCastTargets; -#ifdef TRINITY +#if defined(TRINITY) || AZEROTHCORE class TempSummon; #else class TemporarySummon; @@ -84,7 +87,7 @@ class Weather; class WorldPacket; #ifndef CLASSIC #ifndef TBC -#ifdef TRINITY +#if defined(TRINITY) || AZEROTHCORE class Vehicle; #else class VehicleInfo; @@ -526,7 +529,11 @@ public: /* World */ void OnOpenStateChange(bool open); +#ifndef AZEROTHCORE void OnConfigLoad(bool reload); +#else + void OnConfigLoad(bool reload, bool isBefore); +#endif void OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask); void OnShutdownCancel(); void OnStartup(); @@ -536,7 +543,11 @@ public: /* Battle Ground */ void OnBGStart(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId); +#if AZEROTHCORE + void OnBGEnd(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId, TeamId winner); +#else void OnBGEnd(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId, Team winner); +#endif void OnBGCreate(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId); void OnBGDestroy(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId); }; diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index b267d78..99ab856 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -502,7 +502,7 @@ ElunaRegister PlayerMethods[] = { "GetNextRandomRaidMember", &LuaPlayer::GetNextRandomRaidMember }, { "GetOriginalGroup", &LuaPlayer::GetOriginalGroup }, { "GetOriginalSubGroup", &LuaPlayer::GetOriginalSubGroup }, -#ifdef TRINITY +#if defined(TRINITY) || AZEROTHCORE { "GetChampioningFaction", &LuaPlayer::GetChampioningFaction }, #endif { "GetLatency", &LuaPlayer::GetLatency }, @@ -561,7 +561,7 @@ ElunaRegister PlayerMethods[] = { "SetPlayerLock", &LuaPlayer::SetPlayerLock }, { "SetGender", &LuaPlayer::SetGender }, { "SetSheath", &LuaPlayer::SetSheath }, -#ifndef TRINITY +#if !defined TRINITY && !AZEROTHCORE { "SetFFA", &LuaPlayer::SetFFA }, #endif @@ -765,13 +765,15 @@ ElunaRegister CreatureMethods[] = { "GetScriptId", &LuaCreature::GetScriptId }, { "GetAIName", &LuaCreature::GetAIName }, { "GetScriptName", &LuaCreature::GetScriptName }, +#ifndef AZEROTHCORE { "GetAttackDistance", &LuaCreature::GetAttackDistance }, +#endif { "GetAggroRange", &LuaCreature::GetAggroRange }, { "GetDefaultMovementType", &LuaCreature::GetDefaultMovementType }, { "GetRespawnDelay", &LuaCreature::GetRespawnDelay }, { "GetWanderRadius", &LuaCreature::GetWanderRadius }, { "GetCurrentWaypointId", &LuaCreature::GetCurrentWaypointId }, -#ifdef TRINITY +#if defined(TRINITY) || AZEROTHCORE { "GetWaypointPath", &LuaCreature::GetWaypointPath }, { "GetLootMode", &LuaCreature::GetLootMode }, #endif @@ -794,7 +796,7 @@ ElunaRegister CreatureMethods[] = { "SetWanderRadius", &LuaCreature::SetWanderRadius }, { "SetInCombatWithZone", &LuaCreature::SetInCombatWithZone }, { "SetDisableReputationGain", &LuaCreature::SetDisableReputationGain }, -#ifdef TRINITY +#if defined(TRINITY) || AZEROTHCORE { "SetLootMode", &LuaCreature::SetLootMode }, #endif { "SetNPCFlags", &LuaCreature::SetNPCFlags }, @@ -807,7 +809,7 @@ ElunaRegister CreatureMethods[] = { "IsWorldBoss", &LuaCreature::IsWorldBoss }, { "IsRacialLeader", &LuaCreature::IsRacialLeader }, { "IsCivilian", &LuaCreature::IsCivilian }, -#ifdef TRINITY +#if defined(TRINITY) || AZEROTHCORE { "IsTrigger", &LuaCreature::IsTrigger }, #endif { "IsGuard", &LuaCreature::IsGuard }, @@ -817,7 +819,7 @@ ElunaRegister CreatureMethods[] = { "CanWalk", &LuaCreature::CanWalk }, { "CanSwim", &LuaCreature::CanSwim }, { "CanAggro", &LuaCreature::CanAggro }, -#ifdef TRINITY +#if defined(TRINITY) || AZEROTHCORE { "CanStartAttack", &LuaCreature::CanStartAttack }, #endif { "HasSearchedAssistance", &LuaCreature::HasSearchedAssistance }, @@ -827,7 +829,7 @@ ElunaRegister CreatureMethods[] = { "IsTargetableForAttack", &LuaCreature::IsTargetableForAttack }, { "CanCompleteQuest", &LuaCreature::CanCompleteQuest }, { "IsReputationGainDisabled", &LuaCreature::IsReputationGainDisabled }, -#ifdef TRINITY +#if defined(TRINITY) || AZEROTHCORE { "IsDamageEnoughForLootingAndReward", &LuaCreature::IsDamageEnoughForLootingAndReward }, { "HasLootMode", &LuaCreature::HasLootMode }, #endif @@ -844,7 +846,7 @@ ElunaRegister CreatureMethods[] = { "DespawnOrUnsummon", &LuaCreature::DespawnOrUnsummon }, { "Respawn", &LuaCreature::Respawn }, { "AttackStart", &LuaCreature::AttackStart }, -#ifdef TRINITY +#if defined(TRINITY) || AZEROTHCORE { "AddLootMode", &LuaCreature::AddLootMode }, { "ResetLootMode", &LuaCreature::ResetLootMode }, { "RemoveLootMode", &LuaCreature::RemoveLootMode }, @@ -1249,7 +1251,9 @@ ElunaRegister BattleGroundMethods[] = { "GetAlivePlayersCountByTeam", &LuaBattleGround::GetAlivePlayersCountByTeam }, { "GetMap", &LuaBattleGround::GetMap }, { "GetBonusHonorFromKillCount", &LuaBattleGround::GetBonusHonorFromKillCount }, +#ifndef AZEROTHCORE { "GetBracketId", &LuaBattleGround::GetBracketId }, +#endif { "GetEndTime", &LuaBattleGround::GetEndTime }, { "GetFreeSlotsForTeam", &LuaBattleGround::GetFreeSlotsForTeam }, { "GetInstanceId", &LuaBattleGround::GetInstanceId }, diff --git a/MapMethods.h b/MapMethods.h index 8c1738e..8594863 100644 --- a/MapMethods.h +++ b/MapMethods.h @@ -37,10 +37,10 @@ namespace LuaMap */ int IsBattleground(lua_State* L, Map* map) { -#ifndef TRINITY - Eluna::Push(L, map->IsBattleGround()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, map->IsBattleground()); +#else + Eluna::Push(L, map->IsBattleGround()); #endif return 1; } @@ -190,10 +190,10 @@ namespace LuaMap float y = Eluna::CHECKVAL(L, 3); float z = Eluna::CHECKVAL(L, 4); -#ifndef TRINITY - Eluna::Push(L, map->GetTerrain()->GetAreaId(x, y, z)); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, map->GetAreaId(x, y, z)); +#else + Eluna::Push(L, map->GetTerrain()->GetAreaId(x, y, z)); #endif return 1; } @@ -207,13 +207,15 @@ namespace LuaMap { uint64 guid = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - Eluna::Push(L, map->GetWorldObject(ObjectGuid(guid))); -#else +#if defined TRINITY || AZEROTHCORE switch (GUID_HIPART(guid)) { case HIGHGUID_PLAYER: +#ifndef AZEROTHCORE Eluna::Push(L, eObjectAccessor()GetPlayer(map, ObjectGuid(guid))); +#else + Eluna::Push(L, map->GetPlayer(ObjectGuid(guid))); +#endif // !AZEROTHCORE break; case HIGHGUID_TRANSPORT: case HIGHGUID_MO_TRANSPORT: @@ -236,6 +238,8 @@ namespace LuaMap default: break; } +#else + Eluna::Push(L, map->GetWorldObject(ObjectGuid(guid))); #endif return 1; } @@ -263,7 +267,7 @@ namespace LuaMap uint32 weatherType = Eluna::CHECKVAL(L, 3); float grade = Eluna::CHECKVAL(L, 4); -#if defined(TRINITY) +#if defined TRINITY || AZEROTHCORE Weather* weather = WeatherMgr::FindWeather(zoneId); if (!weather) weather = WeatherMgr::AddWeather(zoneId); @@ -286,7 +290,7 @@ namespace LuaMap */ int GetInstanceData(lua_State* L, Map* map) { -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE ElunaInstanceAI* iAI = NULL; if (InstanceMap* inst = map->ToInstanceMap()) iAI = dynamic_cast(inst->GetInstanceScript()); @@ -307,7 +311,7 @@ namespace LuaMap */ int SaveInstanceData(lua_State* /*L*/, Map* map) { -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE ElunaInstanceAI* iAI = NULL; if (InstanceMap* inst = map->ToInstanceMap()) iAI = dynamic_cast(inst->GetInstanceScript()); @@ -345,10 +349,10 @@ namespace LuaMap Map::PlayerList const& players = map->GetPlayers(); for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) { -#ifndef TRINITY - Player* player = itr->getSource(); -#else +#if defined TRINITY || AZEROTHCORE Player* player = itr->GetSource(); +#else + Player* player = itr->getSource(); #endif if (!player) continue; diff --git a/ObjectMethods.h b/ObjectMethods.h index 7bd98bb..6bc89e5 100644 --- a/ObjectMethods.h +++ b/ObjectMethods.h @@ -133,7 +133,11 @@ namespace LuaObject */ int GetScale(lua_State* L, Object* obj) { +#ifndef AZEROTHCORE Eluna::Push(L, obj->GetObjectScale()); +#else + Eluna::Push(L, obj->GetFloatValue(OBJECT_FIELD_SCALE_X)); +#endif return 1; } diff --git a/PlayerMethods.h b/PlayerMethods.h index 01896d9..f8a6ea5 100644 --- a/PlayerMethods.h +++ b/PlayerMethods.h @@ -50,10 +50,10 @@ namespace LuaPlayer int HasAchieved(lua_State* L, Player* player) { uint32 achievementId = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - Eluna::Push(L, player->GetAchievementMgr().HasAchievement(achievementId)); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, player->HasAchieved(achievementId)); +#else + Eluna::Push(L, player->GetAchievementMgr().HasAchievement(achievementId)); #endif return 1; } @@ -403,10 +403,10 @@ namespace LuaPlayer */ int IsGM(lua_State* L, Player* player) { -#ifndef TRINITY - Eluna::Push(L, player->isGameMaster()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, player->IsGameMaster()); +#else + Eluna::Push(L, player->isGameMaster()); #endif return 1; } @@ -461,7 +461,11 @@ namespace LuaPlayer */ int IsHorde(lua_State* L, Player* player) { +#ifdef AZEROTHCORE + Eluna::Push(L, (player->GetTeamId() == TEAM_HORDE)); +#else Eluna::Push(L, (player->GetTeam() == HORDE)); +#endif return 1; } @@ -472,7 +476,11 @@ namespace LuaPlayer */ int IsAlliance(lua_State* L, Player* player) { +#ifdef AZEROTHCORE + Eluna::Push(L, (player->GetTeamId() == TEAM_ALLIANCE)); +#else Eluna::Push(L, (player->GetTeam() == ALLIANCE)); +#endif return 1; } @@ -626,10 +634,10 @@ namespace LuaPlayer */ int InBattlegroundQueue(lua_State* L, Player* player) { -#ifndef TRINITY - Eluna::Push(L, player->InBattleGroundQueue()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, player->InBattlegroundQueue()); +#else + Eluna::Push(L, player->InBattleGroundQueue()); #endif return 1; } @@ -654,10 +662,10 @@ namespace LuaPlayer */ int InBattleground(lua_State* L, Player* player) { -#ifndef TRINITY - Eluna::Push(L, player->InBattleGround()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, player->InBattleground()); +#else + Eluna::Push(L, player->InBattleGround()); #endif return 1; } @@ -848,7 +856,7 @@ namespace LuaPlayer return 1; } -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE /** * Returns the faction ID the [Player] is currently flagged as champion for * @@ -940,10 +948,10 @@ namespace LuaPlayer */ int GetBattlegroundTypeId(lua_State* L, Player* player) { -#ifndef TRINITY - Eluna::Push(L, player->GetBattleGroundTypeId()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, player->GetBattlegroundTypeId()); +#else + Eluna::Push(L, player->GetBattleGroundTypeId()); #endif return 1; } @@ -955,10 +963,10 @@ namespace LuaPlayer */ int GetBattlegroundId(lua_State* L, Player* player) { -#ifndef TRINITY - Eluna::Push(L, player->GetBattleGroundId()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, player->GetBattlegroundId()); +#else + Eluna::Push(L, player->GetBattleGroundId()); #endif return 1; } @@ -1183,10 +1191,10 @@ namespace LuaPlayer */ int GetComboTarget(lua_State* L, Player* player) { -#ifndef TRINITY - Eluna::Push(L, player->GetMap()->GetUnit(player->GetComboTargetGuid())); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, player->GetComboTarget()); +#else + Eluna::Push(L, player->GetMap()->GetUnit(player->GetComboTargetGuid())); #endif return 1; } @@ -1267,10 +1275,10 @@ namespace LuaPlayer { Quest* quest = Eluna::CHECKOBJ(L, 2); -#ifndef TRINITY - Eluna::Push(L, player->GetQuestLevelForPlayer(quest)); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, player->GetQuestLevel(quest)); +#else + Eluna::Push(L, player->GetQuestLevelForPlayer(quest)); #endif return 1; } @@ -1399,10 +1407,10 @@ namespace LuaPlayer */ int GetSelection(lua_State* L, Player* player) { -#ifndef TRINITY - Eluna::Push(L, player->GetMap()->GetUnit(player->GetSelectionGuid())); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, player->GetSelectedUnit()); +#else + Eluna::Push(L, player->GetMap()->GetUnit(player->GetSelectionGuid())); #endif return 1; } @@ -1551,7 +1559,11 @@ namespace LuaPlayer int GetAccountName(lua_State* L, Player* player) { std::string accName; +#ifndef AZEROTHCORE if (eAccountMgr->GetName(player->GetSession()->GetAccountId(), accName)) +#else + if (AccountMgr::GetName(player->GetSession()->GetAccountId(), accName)) +#endif Eluna::Push(L, accName); return 1; } @@ -2010,10 +2022,10 @@ namespace LuaPlayer uint32 areaId = Eluna::CHECKVAL(L, 6); WorldLocation loc(mapId, x, y, z); -#ifndef TRINITY - player->SetHomebindToLocation(loc, areaId); -#else +#if defined TRINITY || AZEROTHCORE player->SetHomebind(loc, areaId); +#else + player->SetHomebindToLocation(loc, areaId); #endif return 0; } @@ -2034,7 +2046,7 @@ namespace LuaPlayer } #endif -#ifndef TRINITY +#if !defined TRINITY && !AZEROTHCORE /** * Toggle the [Player]s FFA flag * @@ -2080,10 +2092,10 @@ namespace LuaPlayer */ int ResetAchievements(lua_State* /*L*/, Player* player) { -#ifndef TRINITY - player->GetAchievementMgr().Reset(); -#else +#if defined TRINITY || AZEROTHCORE player->ResetAchievements(); +#else + player->GetAchievementMgr().Reset(); #endif return 0; } @@ -2141,10 +2153,14 @@ namespace LuaPlayer */ int SaveToDB(lua_State* /*L*/, Player* player) { +#ifndef AZEROTHCORE player->SaveToDB(); +#else + player->SaveToDB(false, false); +#endif return 0; } - + /** * Sends a summon request to the player from the given summoner * @@ -2229,10 +2245,12 @@ namespace LuaPlayer { Unit* unit = Eluna::CHECKOBJ(L, 2); -#ifndef TRINITY - AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit); -#else +#ifdef TRINITY AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->GetFaction()); +#elif AZEROTHCORE + AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->getFaction()); +#else + AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit); #endif if (!ahEntry) return 0; @@ -2336,11 +2354,11 @@ namespace LuaPlayer { Player* plr = Eluna::CHECKOBJ(L, 2); -#ifndef TRINITY - player->GetSession()->SendGuildInvite(plr); -#else +#if defined TRINITY || AZEROTHCORE if (Guild* guild = player->GetGuild()) guild->HandleInviteMember(player->GetSession(), plr->GetName()); +#else + player->GetSession()->SendGuildInvite(plr); #endif return 0; } @@ -2363,10 +2381,10 @@ namespace LuaPlayer */ int RemoveFromBattlegroundRaid(lua_State* /*L*/, Player* player) { -#ifndef TRINITY - player->RemoveFromBattleGroundRaid(); -#else +#if defined TRINITY || AZEROTHCORE player->RemoveFromBattlegroundOrBattlefieldRaid(); +#else + player->RemoveFromBattleGroundRaid(); #endif return 0; } @@ -2386,8 +2404,12 @@ namespace LuaPlayer uint32 difficulty = Eluna::CHECKVAL(L, 3, 0); if (difficulty < MAX_DIFFICULTY) +#ifndef AZEROTHCORE player->UnbindInstance(map, (Difficulty)difficulty); #else + sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUIDLow(), map, Difficulty(difficulty), true, player); +#endif//AZEROTHCORE +#else//CLASSIC player->UnbindInstance(map); #endif return 0; @@ -2407,6 +2429,19 @@ namespace LuaPlayer else ++itr; } +#elif defined AZEROTHCORE + for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) + { + const BoundInstancesMap& binds = sInstanceSaveMgr->PlayerGetBoundInstances(player->GetGUIDLow(), Difficulty(i)); + for (BoundInstancesMap::const_iterator itr = binds.begin(); itr != binds.end();) + { + if (itr->first != player->GetMapId()) + //player->UnbindInstance(itr, Difficulty(i)); + sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUIDLow(), itr->first, Difficulty(i), true, player); + else + ++itr; + } + } #else for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { @@ -2430,9 +2465,12 @@ namespace LuaPlayer */ int LeaveBattleground(lua_State* L, Player* player) { +#ifndef AZEROTHCORE bool teleToEntryPoint = Eluna::CHECKVAL(L, 2, true); - player->LeaveBattleground(teleToEntryPoint); +#else + player->LeaveBattleground(); +#endif return 0; } @@ -2769,7 +2807,7 @@ namespace LuaPlayer // Add quest items for quests that require items for (uint8 x = 0; x < QUEST_ITEM_OBJECTIVES_COUNT; ++x) { -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE uint32 id = quest->RequiredItemId[x]; uint32 count = quest->RequiredItemCount[x]; #else @@ -2794,7 +2832,7 @@ namespace LuaPlayer // All creature/GO slain/cast (not required, but otherwise it will display "Creature slain 0/10") for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) { -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE int32 creature = quest->RequiredNpcOrGo[i]; uint32 creatureCount = quest->RequiredNpcOrGoCount[i]; @@ -2802,7 +2840,11 @@ namespace LuaPlayer { if (CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creature)) for (uint16 z = 0; z < creatureCount; ++z) +#ifndef AZEROTHCORE player->KilledMonster(creatureInfo, ObjectGuid::Empty); +#else + player->KilledMonster(creatureInfo, 0); +#endif } else if (creature < 0) for (uint16 z = 0; z < creatureCount; ++z) @@ -2841,7 +2883,7 @@ namespace LuaPlayer player->GetReputationMgr().SetReputation(factionEntry, repValue); } -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE // If the quest requires a SECOND reputation to complete if (uint32 repFaction = quest->GetRepObjectiveFaction2()) { @@ -2889,8 +2931,9 @@ namespace LuaPlayer if (!quest) return 0; -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE // check item starting quest (it can work incorrectly if added without item in inventory) +#ifndef AZEROTHCORE ItemTemplateContainer const& itc = sObjectMgr->GetItemTemplateStore(); auto itr = std::find_if(std::begin(itc), std::end(itc), [quest](ItemTemplateContainer::value_type const& value) { @@ -2899,7 +2942,13 @@ namespace LuaPlayer if (itr != std::end(itc)) return 0; +#else + ItemTemplateContainer const* itc = sObjectMgr->GetItemTemplateStore(); + ItemTemplateContainer::const_iterator result = find_if(itc->begin(), itc->end(), Finder(entry, &ItemTemplate::StartQuest)); + if (result != itc->end()) + return 0; +#endif // ok, normal (creature/GO starting) quest if (player->CanAddQuest(quest, true)) player->AddQuestAndCheckCompletion(quest, NULL); @@ -2953,7 +3002,7 @@ namespace LuaPlayer // we ignore unequippable quest items in this case, its' still be equipped player->TakeQuestSourceItem(logQuest, false); -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE if (quest->HasFlag(QUEST_FLAGS_FLAGS_PVP)) { player->pvpInfo.IsHostile = player->pvpInfo.IsInHostileArea || player->HasPvPForcingQuest(); @@ -2963,7 +3012,7 @@ namespace LuaPlayer } } -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE player->RemoveActiveQuest(entry, false); player->RemoveRewardedQuest(entry); #else @@ -3299,17 +3348,23 @@ namespace LuaPlayer float y = Eluna::CHECKVAL(L, 4); float z = Eluna::CHECKVAL(L, 5); float o = Eluna::CHECKVAL(L, 6); -#ifndef TRINITY +#if defined AZEROTHCORE + if (player->IsInFlight()) + { + player->GetMotionMaster()->MovementExpired(); + player->m_taxi.ClearTaxiDestinations(); + } +#elif defined TRINITY + if (player->IsInFlight()) + player->FinishTaxiFlight(); + else + player->SaveRecallPosition(); +#else if (player->IsTaxiFlying()) { player->GetMotionMaster()->MovementExpired(); player->m_taxi.ClearTaxiDestinations(); } -#else - if (player->IsInFlight()) - player->FinishTaxiFlight(); - else - player->SaveRecallPosition(); #endif Eluna::Push(L, player->TeleportTo(mapId, x, y, z, o)); return 1; @@ -3335,7 +3390,7 @@ namespace LuaPlayer uint32 itemId = Eluna::CHECKVAL(L, 2); uint32 itemCount = Eluna::CHECKVAL(L, 3, 1); -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE uint32 noSpaceForCount = 0; ItemPosCountVec dest; InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, itemCount, &noSpaceForCount); @@ -3344,8 +3399,11 @@ namespace LuaPlayer if (itemCount == 0 || dest.empty()) return 1; - +#ifndef AZEROTHCORE Item* item = player->StoreNewItem(dest, itemId, true, GenerateItemRandomPropertyId(itemId)); +#else + Item* item = player->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); +#endif if (item) player->SendNewItem(item, itemCount, true, false); Eluna::Push(L, item); @@ -3434,7 +3492,11 @@ namespace LuaPlayer return spellInfo && spellInfo->GetCategory() == category; }, update); #else +#ifndef AZEROTHCORE player->RemoveSpellCategoryCooldown(category, update); +#else + player->RemoveCategoryCooldown(category); +#endif #endif return 0; } @@ -3585,6 +3647,8 @@ namespace LuaPlayer #ifdef TRINITY player->LearnSpell(id, false); +#elif AZEROTHCORE + player->learnSpell(id); #else player->learnSpell(id, false); #endif @@ -3607,7 +3671,7 @@ namespace LuaPlayer player->SendTalentsInfoData(false); #endif -#ifndef TRINITY +#if !defined TRINITY && !AZEROTHCORE // if player has a pet, update owner talent auras if (player->GetPet()) player->GetPet()->CastOwnerTalentAuras(); @@ -3657,15 +3721,15 @@ namespace LuaPlayer bool _code = Eluna::CHECKVAL(L, 6, false); const char* _promptMsg = Eluna::CHECKVAL(L, 7, ""); uint32 _money = Eluna::CHECKVAL(L, 8, 0); -#ifndef TRINITY +#if defined TRINITY || AZEROTHCORE + player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, _icon, msg, _sender, _intid, _promptMsg, _money, _code); +#else #ifndef CLASSIC player->PlayerTalkClass->GetGossipMenu().AddMenuItem(_icon, msg, _sender, _intid, _promptMsg, _money, _code); #else player->PlayerTalkClass->GetGossipMenu().AddMenuItem(_icon, msg, _sender, _intid, _promptMsg, _code); #endif -#else - player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, _icon, msg, _sender, _intid, _promptMsg, _money, _code); -#endif +#endif//TRINITY return 0; } @@ -3676,10 +3740,10 @@ namespace LuaPlayer */ int GossipComplete(lua_State* /*L*/, Player* player) { -#ifndef TRINITY - player->PlayerTalkClass->CloseGossip(); -#else +#if defined TRINITY || AZEROTHCORE player->PlayerTalkClass->SendCloseGossip(); +#else + player->PlayerTalkClass->CloseGossip(); #endif return 0; } @@ -3928,7 +3992,7 @@ namespace LuaPlayer if (!group->IsCreated()) { group->RemoveInvite(player); -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE group->Create(player); sGroupMgr->AddGroup(group); #else @@ -3938,7 +4002,7 @@ namespace LuaPlayer #endif } -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE if (!group->AddMember(invited)) return 0; group->BroadcastGroupUpdate(); diff --git a/QuestMethods.h b/QuestMethods.h index 4427622..7ca026b 100644 --- a/QuestMethods.h +++ b/QuestMethods.h @@ -52,10 +52,10 @@ namespace LuaQuest int HasFlag(lua_State* L, Quest* quest) { uint32 flag = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - Eluna::Push(L, quest->HasQuestFlag((QuestFlags)flag)); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, quest->HasFlag(flag)); +#else + Eluna::Push(L, quest->HasQuestFlag((QuestFlags)flag)); #endif return 1; } @@ -157,10 +157,10 @@ namespace LuaQuest */ int GetFlags(lua_State* L, Quest* quest) { -#ifndef TRINITY - Eluna::Push(L, quest->GetQuestFlags()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, quest->GetFlags()); +#else + Eluna::Push(L, quest->GetQuestFlags()); #endif return 1; } diff --git a/ServerHooks.cpp b/ServerHooks.cpp index a6ecdda..b420d35 100644 --- a/ServerHooks.cpp +++ b/ServerHooks.cpp @@ -116,7 +116,11 @@ bool Eluna::OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* pTrigger) { START_HOOK_WITH_RETVAL(TRIGGER_EVENT_ON_TRIGGER, false); Push(pPlayer); +#ifndef AZEROTHCORE Push(pTrigger->id); +#else + Push(pTrigger->entry); +#endif return CallAllFunctionsBool(ServerEventBindings, key); } @@ -137,6 +141,9 @@ void Eluna::OnAdd(AuctionHouseObject* /*ah*/, AuctionEntry* entry) #ifdef TRINITY Item* item = eAuctionMgr->GetAItem(entry->itemGUIDLow); uint32 expiretime = entry->expire_time; +#elif AZEROTHCORE + Item* item = eAuctionMgr->GetAItem(entry->item_guidlow); + uint32 expiretime = entry->expire_time; #else Item* item = eAuctionMgr->GetAItem(entry->itemGuidLow); uint32 expiretime = entry->expireTime; @@ -164,6 +171,9 @@ void Eluna::OnRemove(AuctionHouseObject* /*ah*/, AuctionEntry* entry) #ifdef TRINITY Item* item = eAuctionMgr->GetAItem(entry->itemGUIDLow); uint32 expiretime = entry->expire_time; +#elif AZEROTHCORE + Item* item = eAuctionMgr->GetAItem(entry->item_guidlow); + uint32 expiretime = entry->expire_time; #else Item* item = eAuctionMgr->GetAItem(entry->itemGuidLow); uint32 expiretime = entry->expireTime; @@ -191,6 +201,9 @@ void Eluna::OnSuccessful(AuctionHouseObject* /*ah*/, AuctionEntry* entry) #ifdef TRINITY Item* item = eAuctionMgr->GetAItem(entry->itemGUIDLow); uint32 expiretime = entry->expire_time; +#elif AZEROTHCORE + Item* item = eAuctionMgr->GetAItem(entry->item_guidlow); + uint32 expiretime = entry->expire_time; #else Item* item = eAuctionMgr->GetAItem(entry->itemGuidLow); uint32 expiretime = entry->expireTime; @@ -218,6 +231,9 @@ void Eluna::OnExpire(AuctionHouseObject* /*ah*/, AuctionEntry* entry) #ifdef TRINITY Item* item = eAuctionMgr->GetAItem(entry->itemGUIDLow); uint32 expiretime = entry->expire_time; +#elif AZEROTHCORE + Item* item = eAuctionMgr->GetAItem(entry->item_guidlow); + uint32 expiretime = entry->expire_time; #else Item* item = eAuctionMgr->GetAItem(entry->itemGuidLow); uint32 expiretime = entry->expireTime; @@ -246,10 +262,17 @@ void Eluna::OnOpenStateChange(bool open) CallAllFunctions(ServerEventBindings, key); } +#ifndef AZEROTHCORE void Eluna::OnConfigLoad(bool reload) +#else +void Eluna::OnConfigLoad(bool reload, bool isBefore) +#endif { START_HOOK(WORLD_EVENT_ON_CONFIG_LOAD); Push(reload); +#ifdef AZEROTHCORE + Push(isBefore); +#endif CallAllFunctions(ServerEventBindings, key); } diff --git a/SpellMethods.h b/SpellMethods.h index a52fc60..2036c00 100644 --- a/SpellMethods.h +++ b/SpellMethods.h @@ -76,10 +76,10 @@ namespace LuaSpell */ int GetDuration(lua_State* L, Spell* spell) { -#ifndef TRINITY - Eluna::Push(L, GetSpellDuration(spell->m_spellInfo)); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, spell->GetSpellInfo()->GetDuration()); +#else + Eluna::Push(L, GetSpellDuration(spell->m_spellInfo)); #endif return 1; } @@ -93,16 +93,16 @@ namespace LuaSpell */ int GetTargetDest(lua_State* L, Spell* spell) { -#ifndef TRINITY - if (!(spell->m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)) - return 3; - float x, y, z; - spell->m_targets.getDestination(x, y, z); -#else +#if defined TRINITY || AZEROTHCORE if (!spell->m_targets.HasDst()) return 3; float x, y, z; spell->m_targets.GetDstPos()->GetPosition(x, y, z); +#else + if (!(spell->m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)) + return 3; + float x, y, z; + spell->m_targets.getDestination(x, y, z); #endif Eluna::Push(L, x); Eluna::Push(L, y); @@ -124,16 +124,7 @@ namespace LuaSpell */ int GetTarget(lua_State* L, Spell* spell) { -#ifndef TRINITY - if (GameObject* target = spell->m_targets.getGOTarget()) - Eluna::Push(L, target); - else if (Item* target = spell->m_targets.getItemTarget()) - Eluna::Push(L, target); - else if (Corpse* target = spell->GetCaster()->GetMap()->GetCorpse(spell->m_targets.getCorpseTargetGuid())) - Eluna::Push(L, target); - else if (Unit* target = spell->m_targets.getUnitTarget()) - Eluna::Push(L, target); -#else +#if defined TRINITY || AZEROTHCORE if (GameObject* target = spell->m_targets.GetGOTarget()) Eluna::Push(L, target); else if (Item* target = spell->m_targets.GetItemTarget()) @@ -144,6 +135,15 @@ namespace LuaSpell Eluna::Push(L, target); else if (WorldObject* target = spell->m_targets.GetObjectTarget()) Eluna::Push(L, target); +#else + if (GameObject* target = spell->m_targets.getGOTarget()) + Eluna::Push(L, target); + else if (Item* target = spell->m_targets.getItemTarget()) + Eluna::Push(L, target); + else if (Corpse* target = spell->GetCaster()->GetMap()->GetCorpse(spell->m_targets.getCorpseTargetGuid())) + Eluna::Push(L, target); + else if (Unit* target = spell->m_targets.getUnitTarget()) + Eluna::Push(L, target); #endif return 1; } diff --git a/UnitMethods.h b/UnitMethods.h index 21cbe45..9cea741 100644 --- a/UnitMethods.h +++ b/UnitMethods.h @@ -68,7 +68,7 @@ namespace LuaUnit */ int IsRooted(lua_State* L, Unit* unit) { -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, unit->isInRoots() || unit->HasUnitMovementFlag(MOVEMENTFLAG_ROOT)); #endif #ifdef CMANGOS @@ -102,10 +102,10 @@ namespace LuaUnit { Creature* creature = Eluna::CHECKOBJ(L, 2); -#ifndef TRINITY - Eluna::Push(L, unit->isInAccessablePlaceFor(creature)); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, unit->isInAccessiblePlaceFor(creature)); +#else + Eluna::Push(L, unit->isInAccessablePlaceFor(creature)); #endif return 1; } @@ -117,10 +117,10 @@ namespace LuaUnit */ int IsAuctioneer(lua_State* L, Unit* unit) { -#ifndef TRINITY - Eluna::Push(L, unit->isAuctioner()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, unit->IsAuctioner()); +#else + Eluna::Push(L, unit->isAuctioner()); #endif return 1; } @@ -425,10 +425,10 @@ namespace LuaUnit */ int IsOnVehicle(lua_State* L, Unit* unit) { -#ifndef TRINITY - Eluna::Push(L, unit->IsBoarded()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, unit->GetVehicle()); +#else + Eluna::Push(L, unit->IsBoarded()); #endif return 1; } @@ -542,7 +542,7 @@ namespace LuaUnit */ int IsCasting(lua_State* L, Unit* unit) { -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, unit->HasUnitState(UNIT_STATE_CASTING)); #else Eluna::Push(L, unit->IsNonMeleeSpellCasted(false)); @@ -559,10 +559,10 @@ namespace LuaUnit int HasUnitState(lua_State* L, Unit* unit) { uint32 state = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - Eluna::Push(L, unit->hasUnitState(state)); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, unit->HasUnitState(state)); +#else + Eluna::Push(L, unit->hasUnitState(state)); #endif return 1; } @@ -603,10 +603,10 @@ namespace LuaUnit */ int GetOwnerGUID(lua_State* L, Unit* unit) { -#ifndef TRINITY - Eluna::Push(L, unit->GetOwnerGuid()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, unit->GetOwnerGUID()); +#else + Eluna::Push(L, unit->GetOwnerGuid()); #endif return 1; } @@ -629,10 +629,10 @@ namespace LuaUnit */ int GetCreatorGUID(lua_State* L, Unit* unit) { -#ifndef TRINITY - Eluna::Push(L, unit->GetCreatorGuid()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, unit->GetCreatorGUID()); +#else + Eluna::Push(L, unit->GetCreatorGuid()); #endif return 1; } @@ -644,10 +644,10 @@ namespace LuaUnit */ int GetCharmerGUID(lua_State* L, Unit* unit) { -#ifndef TRINITY - Eluna::Push(L, unit->GetCharmerGuid()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, unit->GetCharmerGUID()); +#else + Eluna::Push(L, unit->GetCharmerGuid()); #endif return 1; } @@ -659,10 +659,10 @@ namespace LuaUnit */ int GetCharmGUID(lua_State* L, Unit* unit) { -#ifndef TRINITY - Eluna::Push(L, unit->GetCharmGuid()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, unit->GetCharmGUID()); +#else + Eluna::Push(L, unit->GetCharmGuid()); #endif return 1; } @@ -674,10 +674,10 @@ namespace LuaUnit */ int GetPetGUID(lua_State* L, Unit* unit) { -#ifndef TRINITY - Eluna::Push(L, unit->GetPetGuid()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, unit->GetPetGUID()); +#else + Eluna::Push(L, unit->GetPetGuid()); #endif return 1; } @@ -689,10 +689,10 @@ namespace LuaUnit */ int GetControllerGUID(lua_State* L, Unit* unit) { -#ifndef TRINITY - Eluna::Push(L, unit->GetCharmerOrOwnerGuid()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, unit->GetCharmerOrOwnerGUID()); +#else + Eluna::Push(L, unit->GetCharmerOrOwnerGuid()); #endif return 1; } @@ -704,10 +704,10 @@ namespace LuaUnit */ int GetControllerGUIDS(lua_State* L, Unit* unit) { -#ifndef TRINITY - Eluna::Push(L, unit->GetCharmerOrOwnerOrOwnGuid()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, unit->GetCharmerOrOwnerOrOwnGUID()); +#else + Eluna::Push(L, unit->GetCharmerOrOwnerOrOwnGuid()); #endif return 1; } @@ -753,10 +753,10 @@ namespace LuaUnit */ int GetVictim(lua_State* L, Unit* unit) { -#ifndef TRINITY - Eluna::Push(L, unit->getVictim()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, unit->GetVictim()); +#else + Eluna::Push(L, unit->getVictim()); #endif return 1; } @@ -851,6 +851,9 @@ namespace LuaUnit #ifdef TRINITY if (powerType == -1) return unit->GetPowerType(); +#elif AZEROTHCORE + if (powerType == -1) + return unit->getPowerType(); #else if (powerType == -1) return unit->GetPowerType(); @@ -977,6 +980,8 @@ namespace LuaUnit { #ifdef TRINITY Eluna::Push(L, unit->GetPowerType()); +#elif AZEROTHCORE + Eluna::Push(L, unit->getPowerType()); #else Eluna::Push(L, unit->GetPowerType()); #endif @@ -1001,10 +1006,10 @@ namespace LuaUnit */ int GetHealthPct(lua_State* L, Unit* unit) { -#ifndef TRINITY - Eluna::Push(L, unit->GetHealthPercent()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, unit->GetHealthPct()); +#else + Eluna::Push(L, unit->GetHealthPercent()); #endif return 1; } @@ -1169,10 +1174,10 @@ namespace LuaUnit int GetAura(lua_State* L, Unit* unit) { uint32 spellID = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - Eluna::Push(L, unit->GetAura(spellID, EFFECT_INDEX_0)); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, unit->GetAura(spellID)); +#else + Eluna::Push(L, unit->GetAura(spellID, EFFECT_INDEX_0)); #endif return 1; } @@ -1188,14 +1193,18 @@ namespace LuaUnit float range = Eluna::CHECKVAL(L, 2, SIZE_OF_GRIDS); std::list list; -#ifndef TRINITY - MaNGOS::AnyFriendlyUnitInObjectRangeCheck checker(unit, range); - MaNGOS::UnitListSearcher searcher(list, checker); - Cell::VisitGridObjects(unit, searcher, range); -#else +#ifdef TRINITY Trinity::AnyFriendlyUnitInObjectRangeCheck checker(unit, unit, range); Trinity::UnitListSearcher searcher(unit, list, checker); Cell::VisitAllObjects(unit, searcher, range); +#elif AZEROTHCORE + Trinity::AnyFriendlyUnitInObjectRangeCheck checker(unit, unit, range); + Trinity::UnitListSearcher searcher(unit, list, checker); + unit->VisitNearbyObject(range, searcher); +#else + MaNGOS::AnyFriendlyUnitInObjectRangeCheck checker(unit, range); + MaNGOS::UnitListSearcher searcher(list, checker); + Cell::VisitGridObjects(unit, searcher, range); #endif ElunaUtil::ObjectGUIDCheck guidCheck(unit->GET_GUID()); list.remove_if(guidCheck); @@ -1225,14 +1234,18 @@ namespace LuaUnit float range = Eluna::CHECKVAL(L, 2, SIZE_OF_GRIDS); std::list list; -#ifndef TRINITY - MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck checker(unit, range); - MaNGOS::UnitListSearcher searcher(list, checker); - Cell::VisitGridObjects(unit, searcher, range); -#else +#ifdef TRINITY Trinity::AnyUnfriendlyUnitInObjectRangeCheck checker(unit, unit, range); Trinity::UnitListSearcher searcher(unit, list, checker); Cell::VisitAllObjects(unit, searcher, range); +#elif AZEROTHCORE + Trinity::AnyUnfriendlyUnitInObjectRangeCheck checker(unit, unit, range); + Trinity::UnitListSearcher searcher(unit, list, checker); + unit->VisitNearbyObject(range, searcher); +#else + MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck checker(unit, range); + MaNGOS::UnitListSearcher searcher(list, checker); + Cell::VisitGridObjects(unit, searcher, range); #endif ElunaUtil::ObjectGUIDCheck guidCheck(unit->GET_GUID()); list.remove_if(guidCheck); @@ -1259,10 +1272,10 @@ namespace LuaUnit */ int GetVehicleKit(lua_State* L, Unit* unit) { -#ifndef TRINITY - Eluna::Push(L, unit->GetVehicleInfo()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, unit->GetVehicleKit()); +#else + Eluna::Push(L, unit->GetVehicleInfo()); #endif return 1; } @@ -1282,10 +1295,10 @@ namespace LuaUnit */ int GetCritterGUID(lua_State* L, Unit* unit) { -#ifndef TRINITY - Eluna::Push(L, unit->GetCritterGuid()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, unit->GetCritterGUID()); +#else + Eluna::Push(L, unit->GetCritterGuid()); #endif return 1; } @@ -1373,10 +1386,10 @@ namespace LuaUnit { uint64 guid = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - unit->SetOwnerGuid(ObjectGuid(guid)); -#else +#if defined TRINITY || AZEROTHCORE unit->SetOwnerGUID(ObjectGuid(guid)); +#else + unit->SetOwnerGuid(ObjectGuid(guid)); #endif return 0; } @@ -1459,10 +1472,10 @@ namespace LuaUnit bool forced = Eluna::CHECKVAL(L, 4, false); if (type >= MAX_MOVE_TYPE) return luaL_argerror(L, 2, "valid UnitMoveType expected"); -#ifndef TRINITY - unit->SetSpeedRate((UnitMoveType)type, rate, forced); -#else +#if defined TRINITY || AZEROTHCORE unit->SetSpeedRate((UnitMoveType)type, rate); +#else + unit->SetSpeedRate((UnitMoveType)type, rate, forced); #endif return 0; } @@ -1651,6 +1664,8 @@ namespace LuaUnit #ifdef TRINITY unit->SetPowerType((Powers)type); +#elif AZEROTHCORE + unit->setPowerType((Powers)type); #else unit->SetPowerType((Powers)type); #endif @@ -1713,10 +1728,10 @@ namespace LuaUnit int SetCreatorGUID(lua_State* L, Unit* unit) { uint64 guid = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - unit->SetCreatorGuid(ObjectGuid(guid)); -#else +#if defined TRINITY || AZEROTHCORE unit->SetCreatorGUID(ObjectGuid(guid)); +#else + unit->SetCreatorGuid(ObjectGuid(guid)); #endif return 0; } @@ -1729,10 +1744,10 @@ namespace LuaUnit int SetCharmerGUID(lua_State* L, Unit* unit) { uint64 guid = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - unit->SetCharmerGuid(ObjectGuid(guid)); -#else +#if defined TRINITY || AZEROTHCORE unit->SetCharmerGUID(ObjectGuid(guid)); +#else + unit->SetCharmerGuid(ObjectGuid(guid)); #endif return 0; } @@ -1745,10 +1760,10 @@ namespace LuaUnit int SetPetGUID(lua_State* L, Unit* unit) { uint64 guid = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - unit->SetPetGuid(ObjectGuid(guid)); -#else +#if defined TRINITY || AZEROTHCORE unit->SetPetGUID(ObjectGuid(guid)); +#else + unit->SetPetGuid(ObjectGuid(guid)); #endif return 0; } @@ -1761,10 +1776,10 @@ namespace LuaUnit int SetWaterWalk(lua_State* L, Unit* unit) { bool enable = Eluna::CHECKVAL(L, 2, true); -#ifndef TRINITY - unit->SetWaterWalk(enable); -#else +#if defined TRINITY || AZEROTHCORE unit->SetWaterWalking(enable); +#else + unit->SetWaterWalk(enable); #endif return 0; } @@ -1791,9 +1806,7 @@ namespace LuaUnit { bool apply = Eluna::CHECKVAL(L, 2, true); -#ifndef TRINITY - unit->SetFFAPvP(apply); -#else +#ifdef TRINITY if (apply) { unit->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); @@ -1806,6 +1819,21 @@ namespace LuaUnit for (Unit::ControlList::iterator itr = unit->m_Controlled.begin(); itr != unit->m_Controlled.end(); ++itr) (*itr)->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); } +#elif AZEROTHCORE + if (apply) + { + unit->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); + for (Unit::ControlSet::iterator itr = unit->m_Controlled.begin(); itr != unit->m_Controlled.end(); ++itr) + (*itr)->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); + } + else + { + unit->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); + for (Unit::ControlSet::iterator itr = unit->m_Controlled.begin(); itr != unit->m_Controlled.end(); ++itr) + (*itr)->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); + } +#else + unit->SetFFAPvP(apply); #endif return 0; } @@ -1834,10 +1862,10 @@ namespace LuaUnit int SetCritterGUID(lua_State* L, Unit* unit) { uint64 guid = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - unit->SetCritterGuid(ObjectGuid(guid)); -#else +#if defined TRINITY || AZEROTHCORE unit->SetCritterGUID(ObjectGuid(guid)); +#else + unit->SetCritterGuid(ObjectGuid(guid)); #endif return 0; } @@ -1858,10 +1886,10 @@ namespace LuaUnit int SetRooted(lua_State* L, Unit* unit) { bool apply = Eluna::CHECKVAL(L, 2, true); -#ifndef TRINITY - unit->SetRoot(apply); -#else +#if defined TRINITY || AZEROTHCORE unit->SetControlled(apply, UNIT_STATE_ROOT); +#else + unit->SetRoot(apply); #endif return 0; } @@ -1874,10 +1902,10 @@ namespace LuaUnit int SetConfused(lua_State* L, Unit* unit) { bool apply = Eluna::CHECKVAL(L, 2, true); -#ifndef TRINITY - unit->SetConfused(apply); -#else +#if defined TRINITY || AZEROTHCORE unit->SetControlled(apply, UNIT_STATE_CONFUSED); +#else + unit->SetConfused(apply); #endif return 0; } @@ -1890,10 +1918,10 @@ namespace LuaUnit int SetFeared(lua_State* L, Unit* unit) { bool apply = Eluna::CHECKVAL(L, 2, true); -#ifndef TRINITY - unit->SetFeared(apply); -#else +#if defined TRINITY || AZEROTHCORE unit->SetControlled(apply, UNIT_STATE_FLEEING); +#else + unit->SetFeared(apply); #endif return 0; } @@ -1919,6 +1947,8 @@ namespace LuaUnit { #ifdef TRINITY unit->GetThreatManager().ClearAllThreat(); +#elif AZEROTHCORE + unit->getThreatManager().clearReferences(); #else unit->GetThreatManager().clearReferences(); #endif @@ -1945,12 +1975,12 @@ namespace LuaUnit { if (unit->IsMounted()) { -#ifndef TRINITY - unit->Unmount(); - unit->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); -#else +#if defined TRINITY || AZEROTHCORE unit->Dismount(); unit->RemoveAurasByType(SPELL_AURA_MOUNTED); +#else + unit->Unmount(); + unit->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); #endif } @@ -2024,7 +2054,7 @@ namespace LuaUnit return luaL_argerror(L, 3, "valid Language expected"); WorldPacket data; -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE ChatHandler::BuildChatPacket(data, ChatMsg(type), Language(lang), unit, target, msg); #else ChatHandler::BuildChatPacket(data, ChatMsg(type), msg.c_str(), Language(lang), 0, unit->GET_GUID(), unit->GetName(), target->GET_GUID(), target->GetName()); @@ -2104,10 +2134,10 @@ namespace LuaUnit float radius = Eluna::CHECKVAL(L, 2); float x, y, z; unit->GetPosition(x, y, z); -#ifndef TRINITY - unit->GetMotionMaster()->MoveRandomAroundPoint(x, y, z, radius); -#else +#if defined TRINITY || AZEROTHCORE unit->GetMotionMaster()->MoveRandom(radius); +#else + unit->GetMotionMaster()->MoveRandomAroundPoint(x, y, z, radius); #endif return 0; } @@ -2335,7 +2365,7 @@ namespace LuaUnit #ifdef MANGOS SpellEntry const* spellEntry = sSpellStore.LookupEntry(spell); #endif -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spell); #endif if (!spellEntry) @@ -2419,6 +2449,9 @@ namespace LuaUnit #ifdef MANGOS unit->CastSpell(_x, _y, _z, spell, triggered); #endif +#ifdef AZEROTHCORE + unit->CastSpell(_x, _y, _z, spell, triggered); +#endif #ifdef TRINITY CastSpellExtraArgs args; if (triggered) @@ -2502,11 +2535,16 @@ namespace LuaUnit #endif #ifdef TRINITY SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spell); +#endif +#ifdef AZEROTHCORE + SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spell); #endif if (!spellEntry) return 1; -#ifndef TRINITY +#if defined TRINITY || AZEROTHCORE + Eluna::Push(L, unit->AddAura(spell, target)); +#else if (!IsSpellAppliesAura(spellEntry) && !IsSpellHaveEffect(spellEntry, SPELL_EFFECT_PERSISTENT_AREA_AURA)) return 1; @@ -2526,8 +2564,6 @@ namespace LuaUnit } } Eluna::Push(L, target->AddSpellAuraHolder(holder)); -#else - Eluna::Push(L, unit->AddAura(spell, target)); #endif return 1; } @@ -2564,10 +2600,10 @@ namespace LuaUnit { uint32 state = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - unit->addUnitState(state); -#else +#if defined TRINITY || AZEROTHCORE unit->AddUnitState(state); +#else + unit->addUnitState(state); #endif return 0; } @@ -2581,10 +2617,10 @@ namespace LuaUnit { uint32 state = Eluna::CHECKVAL(L, 2); -#ifndef TRINITY - unit->clearUnitState(state); -#else +#if defined TRINITY || AZEROTHCORE unit->ClearUnitState(state); +#else + unit->clearUnitState(state); #endif return 0; } @@ -2644,7 +2680,7 @@ namespace LuaUnit // flat melee damage without resistence/etc reduction if (school == MAX_SPELL_SCHOOL) { -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE Unit::DealDamage(unit, target, damage, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, durabilityloss); unit->SendAttackStateUpdate(HITINFO_AFFECTS_VICTIM, target, 1, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_HIT, 0); #else @@ -2656,7 +2692,7 @@ namespace LuaUnit SpellSchoolMask schoolmask = SpellSchoolMask(1 << school); -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE if (Unit::IsDamageReducedByArmor(schoolmask)) damage = Unit::CalcArmorReducedDamage(unit, target, damage, NULL, BASE_ATTACK); #else @@ -2705,6 +2741,35 @@ namespace LuaUnit unit->DealDamageMods(dmgInfo.target, dmgInfo.damage, &dmgInfo.absorb); #endif + unit->SendSpellNonMeleeDamageLog(&dmgInfo); + unit->DealSpellDamage(&dmgInfo, true); + return 0; +#elif AZEROTHCORE + if (!spell) + { + uint32 absorb = 0; + uint32 resist = 0; + unit->CalcAbsorbResist(unit, target, schoolmask, SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); + if (damage <= absorb + resist) + damage = 0; + else + damage -= absorb + resist; + + unit->DealDamageMods(target, damage, &absorb); + Unit::DealDamage(unit, target, damage, NULL, DIRECT_DAMAGE, schoolmask, NULL, false); + unit->SendAttackStateUpdate(HITINFO_AFFECTS_VICTIM, target, 0, schoolmask, damage, absorb, resist, VICTIMSTATE_HIT, 0); + return 0; + } + + if (!spell) + return 0; + + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell); + if (!spellInfo) + return 0; + + SpellNonMeleeDamage dmgInfo(unit, target, spell, spellInfo->GetSchoolMask()); + Unit::DealDamageMods(dmgInfo.target, dmgInfo.damage, &dmgInfo.absorb); unit->SendSpellNonMeleeDamageLog(&dmgInfo); unit->DealSpellDamage(&dmgInfo, true); return 0; @@ -2748,7 +2813,18 @@ namespace LuaUnit uint32 amount = Eluna::CHECKVAL(L, 4); bool critical = Eluna::CHECKVAL(L, 5, false); -#ifndef TRINITY +#ifdef TRINITY + if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell)) + { + HealInfo healInfo(unit, target, amount, info, info->GetSchoolMask()); + unit->HealBySpell(healInfo, critical); + } +#elif AZEROTHCORE + if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell)) + { + unit->HealBySpell(target, info, amount, critical); + } +#else #ifdef CMANGOS SpellEntry const* spellEntry = GetSpellStore()->LookupEntry(spell); #else @@ -2756,12 +2832,6 @@ namespace LuaUnit #endif if (spellEntry) unit->DealHeal(target, amount, spellEntry, critical); -#else - if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell)) - { - HealInfo healInfo(unit, target, amount, info, info->GetSchoolMask()); - unit->HealBySpell(healInfo, critical); - } #endif return 0; } @@ -2777,10 +2847,10 @@ namespace LuaUnit Unit* target = Eluna::CHECKOBJ(L, 2); bool durLoss = Eluna::CHECKVAL(L, 3, true); -#ifndef TRINITY - unit->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, durLoss); -#else +#if defined TRINITY || AZEROTHCORE Unit::Kill(unit, target, durLoss); +#else + unit->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, durLoss); #endif return 0; } @@ -2815,6 +2885,13 @@ namespace LuaUnit #ifdef TRINITY unit->GetThreatManager().AddThreat(victim, threat, spell ? sSpellMgr->GetSpellInfo(spell) : NULL, true, true); +#elif AZEROTHCORE + uint32 schoolMask = Eluna::CHECKVAL(L, 5, 0); + if (schoolMask > SPELL_SCHOOL_MASK_ALL) + { + return luaL_argerror(L, 4, "valid SpellSchoolMask expected"); + } + unit->AddThreat(victim, threat, (SpellSchoolMask)schoolMask, spell ? sSpellMgr->GetSpellInfo(spell) : NULL); #else #ifdef CMANGOS SpellEntry const* spellEntry = GetSpellStore()->LookupEntry(spell); diff --git a/VehicleMethods.h b/VehicleMethods.h index ce54c32..6dc78b2 100644 --- a/VehicleMethods.h +++ b/VehicleMethods.h @@ -23,10 +23,10 @@ namespace LuaVehicle int IsOnBoard(lua_State* L, Vehicle* vehicle) { Unit* passenger = Eluna::CHECKOBJ(L, 2); -#ifndef TRINITY - Eluna::Push(L, vehicle->HasOnBoard(passenger)); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, passenger->IsOnVehicle(vehicle->GetBase())); +#else + Eluna::Push(L, vehicle->HasOnBoard(passenger)); #endif return 1; } @@ -38,10 +38,10 @@ namespace LuaVehicle */ int GetOwner(lua_State* L, Vehicle* vehicle) { -#ifndef TRINITY - Eluna::Push(L, vehicle->GetOwner()); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, vehicle->GetBase()); +#else + Eluna::Push(L, vehicle->GetOwner()); #endif return 1; } @@ -53,10 +53,10 @@ namespace LuaVehicle */ int GetEntry(lua_State* L, Vehicle* vehicle) { -#ifndef TRINITY - Eluna::Push(L, vehicle->GetVehicleEntry()->m_ID); -#else +#if defined TRINITY || AZEROTHCORE Eluna::Push(L, vehicle->GetVehicleInfo()->m_ID); +#else + Eluna::Push(L, vehicle->GetVehicleEntry()->m_ID); #endif return 1; } @@ -84,11 +84,11 @@ namespace LuaVehicle { Unit* passenger = Eluna::CHECKOBJ(L, 2); int8 seatId = Eluna::CHECKVAL(L, 3); -#ifndef TRINITY +#if defined TRINITY || AZEROTHCORE + vehicle->AddPassenger(passenger, seatId); +#else if (vehicle->CanBoard(passenger)) vehicle->Board(passenger, seatId); -#else - vehicle->AddPassenger(passenger, seatId); #endif return 0; } @@ -101,10 +101,10 @@ namespace LuaVehicle int RemovePassenger(lua_State* L, Vehicle* vehicle) { Unit* passenger = Eluna::CHECKOBJ(L, 2); -#ifndef TRINITY - vehicle->UnBoard(passenger, false); -#else +#if defined TRINITY || AZEROTHCORE vehicle->RemovePassenger(passenger); +#else + vehicle->UnBoard(passenger, false); #endif return 0; } @@ -112,4 +112,4 @@ namespace LuaVehicle #endif // CLASSIC #endif // TBC -#endif // VEHICLEMETHODS_H \ No newline at end of file +#endif // VEHICLEMETHODS_H diff --git a/WorldObjectMethods.h b/WorldObjectMethods.h index b034585..96b2741 100644 --- a/WorldObjectMethods.h +++ b/WorldObjectMethods.h @@ -183,12 +183,16 @@ namespace LuaWorldObject Unit* target = NULL; ElunaUtil::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_PLAYER, 0, hostile, dead); -#ifndef TRINITY - MaNGOS::UnitLastSearcher searcher(target, checker); - Cell::VisitWorldObjects(obj, searcher, range); -#else +#ifdef TRINITY Trinity::UnitLastSearcher searcher(obj, target, checker); Cell::VisitAllObjects(obj, searcher, range); + +#elif AZEROTHCORE + Trinity::UnitLastSearcher searcher(obj, target, checker); + obj->VisitNearbyObject(range,searcher); +#else + MaNGOS::UnitLastSearcher searcher(target, checker); + Cell::VisitWorldObjects(obj, searcher, range); #endif Eluna::Push(L, target); @@ -212,12 +216,15 @@ namespace LuaWorldObject GameObject* target = NULL; ElunaUtil::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_GAMEOBJECT, entry, hostile); -#ifndef TRINITY - MaNGOS::GameObjectLastSearcher searcher(target, checker); - Cell::VisitGridObjects(obj, searcher, range); -#else +#ifdef TRINITY Trinity::GameObjectLastSearcher searcher(obj, target, checker); Cell::VisitAllObjects(obj, searcher, range); +#elif AZEROTHCORE + Trinity::GameObjectLastSearcher searcher(obj, target, checker); + obj->VisitNearbyObject(range, searcher); +#else + MaNGOS::GameObjectLastSearcher searcher(target, checker); + Cell::VisitGridObjects(obj, searcher, range); #endif Eluna::Push(L, target); @@ -243,12 +250,16 @@ namespace LuaWorldObject Creature* target = NULL; ElunaUtil::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_UNIT, entry, hostile, dead); -#ifndef TRINITY - MaNGOS::CreatureLastSearcher searcher(target, checker); - Cell::VisitGridObjects(obj, searcher, range); -#else +#ifdef TRINITY Trinity::CreatureLastSearcher searcher(obj, target, checker); Cell::VisitAllObjects(obj, searcher, range); +#elif AZEROTHCORE + Trinity::CreatureLastSearcher searcher(obj, target, checker); + obj->VisitNearbyObject(range, searcher); +#else + MaNGOS::CreatureLastSearcher searcher(target, checker); + Cell::VisitGridObjects(obj, searcher, range); + #endif Eluna::Push(L, target); @@ -272,12 +283,15 @@ namespace LuaWorldObject std::list list; ElunaUtil::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_PLAYER, 0, hostile, dead); -#ifndef TRINITY - MaNGOS::PlayerListSearcher searcher(list, checker); - Cell::VisitWorldObjects(obj, searcher, range); -#else +#ifdef TRINITY Trinity::PlayerListSearcher searcher(obj, list, checker); Cell::VisitAllObjects(obj, searcher, range); +#elif AZEROTHCORE + Trinity::PlayerListSearcher searcher(obj, list, checker); + obj->VisitNearbyObject(range, searcher); +#else + MaNGOS::PlayerListSearcher searcher(list, checker); + Cell::VisitWorldObjects(obj, searcher, range); #endif lua_createtable(L, list.size(), 0); @@ -313,12 +327,15 @@ namespace LuaWorldObject std::list list; ElunaUtil::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_UNIT, entry, hostile, dead); -#ifndef TRINITY - MaNGOS::CreatureListSearcher searcher(list, checker); - Cell::VisitGridObjects(obj, searcher, range); -#else +#ifdef TRINITY Trinity::CreatureListSearcher searcher(obj, list, checker); Cell::VisitAllObjects(obj, searcher, range); +#elif defined AZEROTHCORE + Trinity::CreatureListSearcher searcher(obj, list, checker); + obj->VisitNearbyObject(range, searcher); +#else + MaNGOS::CreatureListSearcher searcher(list, checker); + Cell::VisitGridObjects(obj, searcher, range); #endif lua_createtable(L, list.size(), 0); @@ -352,12 +369,15 @@ namespace LuaWorldObject std::list list; ElunaUtil::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_GAMEOBJECT, entry, hostile); -#ifndef TRINITY - MaNGOS::GameObjectListSearcher searcher(list, checker); - Cell::VisitGridObjects(obj, searcher, range); -#else +#ifdef TRINITY Trinity::GameObjectListSearcher searcher(obj, list, checker); Cell::VisitAllObjects(obj, searcher, range); +#elif AZEROTHCORE + Trinity::GameObjectListSearcher searcher(obj, list, checker); + obj->VisitNearbyObject(range, searcher); +#else + MaNGOS::GameObjectListSearcher searcher(list, checker); + Cell::VisitGridObjects(obj, searcher, range); #endif lua_createtable(L, list.size(), 0); @@ -399,12 +419,15 @@ namespace LuaWorldObject ElunaUtil::WorldObjectInRangeCheck checker(true, obj, range, type, entry, hostile, dead); WorldObject* target = NULL; -#ifndef TRINITY - MaNGOS::WorldObjectLastSearcher searcher(target, checker); - Cell::VisitAllObjects(obj, searcher, range); -#else +#ifdef TRINITY Trinity::WorldObjectLastSearcher searcher(obj, target, checker); Cell::VisitAllObjects(obj, searcher, range); +#elif AZEROTHCORE + Trinity::WorldObjectLastSearcher searcher(obj, target, checker); + obj->VisitNearbyObject(range, searcher); +#else + MaNGOS::WorldObjectLastSearcher searcher(target, checker); + Cell::VisitAllObjects(obj, searcher, range); #endif Eluna::Push(L, target); @@ -436,12 +459,15 @@ namespace LuaWorldObject ElunaUtil::WorldObjectInRangeCheck checker(false, obj, range, type, entry, hostile, dead); std::list list; -#ifndef TRINITY - MaNGOS::WorldObjectListSearcher searcher(list, checker); - Cell::VisitAllObjects(obj, searcher, range); -#else +#ifdef TRINITY Trinity::WorldObjectListSearcher searcher(obj, list, checker); Cell::VisitAllObjects(obj, searcher, range); +#elif AZEROTHCORE + Trinity::WorldObjectListSearcher searcher(obj, list, checker); + obj->VisitNearbyObject(range, searcher); +#else + MaNGOS::WorldObjectListSearcher searcher(list, checker); + Cell::VisitAllObjects(obj, searcher, range); #endif lua_createtable(L, list.size(), 0); @@ -632,8 +658,7 @@ namespace LuaWorldObject int GetAngle(lua_State* L, WorldObject* obj) { WorldObject* target = Eluna::CHECKOBJ(L, 2, false); - -#ifdef TRINITY +#if defined TRINITY && !AZEROTHCORE if (target) Eluna::Push(L, obj->GetAbsoluteAngle(target)); else @@ -690,11 +715,13 @@ namespace LuaWorldObject float z = Eluna::CHECKVAL(L, 5); float o = Eluna::CHECKVAL(L, 6); uint32 respawnDelay = Eluna::CHECKVAL(L, 7, 30); -#ifndef TRINITY - Eluna::Push(L, obj->SummonGameObject(entry, x, y, z, o, respawnDelay)); -#else +#ifdef TRINITY QuaternionData rot = QuaternionData::fromEulerAnglesZYX(o, 0.f, 0.f); Eluna::Push(L, obj->SummonGameObject(entry, Position(x, y, z, o), rot, respawnDelay)); +#elif AZEROTHCORE + Eluna::Push(L, obj->SummonGameObject(entry, x, y, z, o, 0, 0, 0, 0, respawnDelay)); +#else + Eluna::Push(L, obj->SummonGameObject(entry, x, y, z, o, respawnDelay)); #endif return 1; } @@ -748,7 +775,7 @@ namespace LuaWorldObject type = TEMPSUMMON_TIMED_DESPAWN; break; case 4: -#ifdef TRINITY +#if defined TRINITY || AZEROTHCORE type = TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT; #else type = TEMPSUMMON_TIMED_OOC_DESPAWN; @@ -766,7 +793,7 @@ namespace LuaWorldObject case 8: type = TEMPSUMMON_MANUAL_DESPAWN; break; -#ifndef TRINITY +#if !defined TRINITY && !AZEROTHCORE case 9: type = TEMPSUMMON_TIMED_OOC_OR_CORPSE_DESPAWN; break;