From 8fe509c8382c650975b1d69d84efd9448eb9bc79 Mon Sep 17 00:00:00 2001 From: Rochet2 Date: Sun, 29 Jun 2014 14:16:59 +0300 Subject: [PATCH] Eluna add mangos support. Notice that old MANGOS is now CMANGOS --- CreatureMethods.h | 24 +++++++++++++++++---- LuaEngine.h | 2 +- PlayerMethods.h | 4 ++++ UnitMethods.h | 54 +++++++++++++++++++++++++++++------------------ 4 files changed, 58 insertions(+), 26 deletions(-) diff --git a/CreatureMethods.h b/CreatureMethods.h index 5d5849c..2158f44 100644 --- a/CreatureMethods.h +++ b/CreatureMethods.h @@ -42,7 +42,11 @@ namespace LuaCreature { Unit* target = Eluna::CHECKOBJ(L, 2); +#ifdef MANGOS + Eluna::Push(L, creature->IsTargetableForAttack(target)); +#else Eluna::Push(L, creature->isTargetableForAttack(target)); +#endif return 1; } @@ -333,7 +337,11 @@ namespace LuaCreature float dist = Eluna::CHECKVAL(L, 5, 0.0f); int32 aura = Eluna::CHECKVAL(L, 6, 0); +#ifdef MANGOS + ThreatList const& threatlist = creature->GetThreatManager().getThreatList(); +#else ThreatList const& threatlist = creature->getThreatManager().getThreatList(); +#endif if (threatlist.empty()) return 1; if (position >= threatlist.size()) @@ -407,11 +415,15 @@ namespace LuaCreature lua_newtable(L); int tbl = lua_gettop(L); uint32 i = 0; - - ThreatList const& threatList = creature->getThreatManager().getThreatList(); - if (threatList.empty()) + +#ifdef MANGOS + ThreatList const& threatlist = creature->GetThreatManager().getThreatList(); +#else + ThreatList const& threatlist = creature->getThreatManager().getThreatList(); +#endif + if (threatlist.empty()) return 1; - for (ThreatList::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) + for (ThreatList::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { Unit* target = (*itr)->getTarget(); if (!target) @@ -428,7 +440,11 @@ namespace LuaCreature int GetAITargetsCount(lua_State* L, Creature* creature) { +#ifdef MANGOS + Eluna::Push(L, creature->GetThreatManager().getThreatList().size()); +#else Eluna::Push(L, creature->getThreatManager().getThreatList().size()); +#endif return 1; } diff --git a/LuaEngine.h b/LuaEngine.h index 7051d81..e8b525e 100644 --- a/LuaEngine.h +++ b/LuaEngine.h @@ -484,7 +484,7 @@ public: return false; if (Unit* unit = u->ToUnit()) { -#ifndef TRINITY +#ifdef CMANGOS if (!unit->isAlive()) return false; #else diff --git a/PlayerMethods.h b/PlayerMethods.h index af78dd8..d8868cc 100644 --- a/PlayerMethods.h +++ b/PlayerMethods.h @@ -331,7 +331,11 @@ namespace LuaPlayer int IsTaxiCheater(lua_State* L, Player* player) { +#ifdef MANGOS + Eluna::Push(L, player->IsTaxiCheater()); +#else Eluna::Push(L, player->isTaxiCheater()); +#endif return 1; } diff --git a/UnitMethods.h b/UnitMethods.h index cb72750..71f1af7 100644 --- a/UnitMethods.h +++ b/UnitMethods.h @@ -49,10 +49,14 @@ namespace LuaUnit int IsRooted(lua_State* L, Unit* unit) { -#ifndef TRINITY - Eluna::Push(L, unit->isInRoots() || unit->IsRooted()); -#else +#ifdef TRINITY Eluna::Push(L, unit->isInRoots() || unit->HasUnitMovementFlag(MOVEMENTFLAG_ROOT)); +#endif +#ifdef CMANGOS + Eluna::Push(L, unit->isInRoots() || unit->IsRooted()); +#endif +#ifdef MANGOS + Eluna::Push(L, unit->IsInRoots() || unit->IsRooted()); #endif return 1; } @@ -96,7 +100,7 @@ namespace LuaUnit int IsGuildMaster(lua_State* L, Unit* unit) { -#ifndef TRINITY +#ifdef CMANGOS Eluna::Push(L, unit->isGuildMaster()); #else Eluna::Push(L, unit->IsGuildMaster()); @@ -106,7 +110,7 @@ namespace LuaUnit int IsInnkeeper(lua_State* L, Unit* unit) { -#ifndef TRINITY +#ifdef CMANGOS Eluna::Push(L, unit->isInnkeeper()); #else Eluna::Push(L, unit->IsInnkeeper()); @@ -116,7 +120,7 @@ namespace LuaUnit int IsTrainer(lua_State* L, Unit* unit) { -#ifndef TRINITY +#ifdef CMANGOS Eluna::Push(L, unit->isTrainer()); #else Eluna::Push(L, unit->IsTrainer()); @@ -126,7 +130,7 @@ namespace LuaUnit int IsGossip(lua_State* L, Unit* unit) { -#ifndef TRINITY +#ifdef CMANGOS Eluna::Push(L, unit->isGossip()); #else Eluna::Push(L, unit->IsGossip()); @@ -136,7 +140,7 @@ namespace LuaUnit int IsTaxi(lua_State* L, Unit* unit) { -#ifndef TRINITY +#ifdef CMANGOS Eluna::Push(L, unit->isTaxi()); #else Eluna::Push(L, unit->IsTaxi()); @@ -146,7 +150,7 @@ namespace LuaUnit int IsSpiritHealer(lua_State* L, Unit* unit) { -#ifndef TRINITY +#ifdef CMANGOS Eluna::Push(L, unit->isSpiritHealer()); #else Eluna::Push(L, unit->IsSpiritHealer()); @@ -156,7 +160,7 @@ namespace LuaUnit int IsSpiritGuide(lua_State* L, Unit* unit) { -#ifndef TRINITY +#ifdef CMANGOS Eluna::Push(L, unit->isSpiritGuide()); #else Eluna::Push(L, unit->IsSpiritGuide()); @@ -166,7 +170,7 @@ namespace LuaUnit int IsTabardDesigner(lua_State* L, Unit* unit) { -#ifndef TRINITY +#ifdef CMANGOS Eluna::Push(L, unit->isTabardDesigner()); #else Eluna::Push(L, unit->IsTabardDesigner()); @@ -176,7 +180,7 @@ namespace LuaUnit int IsServiceProvider(lua_State* L, Unit* unit) { -#ifndef TRINITY +#ifdef CMANGOS Eluna::Push(L, unit->isServiceProvider()); #else Eluna::Push(L, unit->IsServiceProvider()); @@ -186,7 +190,7 @@ namespace LuaUnit int IsSpiritService(lua_State* L, Unit* unit) { -#ifndef TRINITY +#ifdef CMANGOS Eluna::Push(L, unit->isSpiritService()); #else Eluna::Push(L, unit->IsSpiritService()); @@ -196,7 +200,7 @@ namespace LuaUnit int IsAlive(lua_State* L, Unit* unit) { -#ifndef TRINITY +#ifdef CMANGOS Eluna::Push(L, unit->isAlive()); #else Eluna::Push(L, unit->IsAlive()); @@ -206,7 +210,11 @@ namespace LuaUnit int IsDead(lua_State* L, Unit* unit) { +#ifdef MANGOS + Eluna::Push(L, unit->IsDead()); +#else Eluna::Push(L, unit->isDead()); +#endif return 1; } @@ -218,7 +226,7 @@ namespace LuaUnit int IsBanker(lua_State* L, Unit* unit) { -#ifndef TRINITY +#ifdef CMANGOS Eluna::Push(L, unit->isBanker()); #else Eluna::Push(L, unit->IsBanker()); @@ -228,7 +236,7 @@ namespace LuaUnit int IsVendor(lua_State* L, Unit* unit) { -#ifndef TRINITY +#ifdef CMANGOS Eluna::Push(L, unit->isVendor()); #else Eluna::Push(L, unit->IsVendor()); @@ -238,7 +246,7 @@ namespace LuaUnit int IsBattleMaster(lua_State* L, Unit* unit) { -#ifndef TRINITY +#ifdef CMANGOS Eluna::Push(L, unit->isBattleMaster()); #else Eluna::Push(L, unit->IsBattleMaster()); @@ -248,7 +256,7 @@ namespace LuaUnit int IsCharmed(lua_State* L, Unit* unit) { -#ifndef TRINITY +#ifdef CMANGOS Eluna::Push(L, unit->isCharmed()); #else Eluna::Push(L, unit->IsCharmed()); @@ -258,7 +266,7 @@ namespace LuaUnit int IsArmorer(lua_State* L, Unit* unit) { -#ifndef TRINITY +#ifdef CMANGOS Eluna::Push(L, unit->isArmorer()); #else Eluna::Push(L, unit->IsArmorer()); @@ -292,7 +300,7 @@ namespace LuaUnit int IsInCombat(lua_State* L, Unit* unit) { -#ifndef TRINITY +#ifdef CMANGOS Eluna::Push(L, unit->isInCombat()); #else Eluna::Push(L, unit->IsInCombat()); @@ -320,7 +328,7 @@ namespace LuaUnit int IsQuestGiver(lua_State* L, Unit* unit) { -#ifndef TRINITY +#ifdef CMANGOS Eluna::Push(L, unit->isQuestGiver()); #else Eluna::Push(L, unit->IsQuestGiver()); @@ -1174,7 +1182,11 @@ namespace LuaUnit /* OTHER */ int ClearThreatList(lua_State* /*L*/, Unit* unit) { +#ifdef MANGOS + unit->GetThreatManager().clearReferences(); +#else unit->getThreatManager().clearReferences(); +#endif return 0; }