Chore: Remove unused #if statement (TrinityCore, Mangos, AzerothCore, TBC, Classic, Mists, Cata) (#217)

This commit is contained in:
iThorgrim
2025-01-21 17:37:39 +01:00
committed by GitHub
parent 16173cb751
commit 2e89531b05
35 changed files with 60 additions and 2504 deletions

View File

@@ -9,12 +9,7 @@
#include "LuaEngine.h"
#if defined TRINITY || AZEROTHCORE
struct ScriptedAI;
#else
class AggressorAI;
typedef AggressorAI ScriptedAI;
#endif
struct ElunaCreatureAI : ScriptedAI
{
@@ -22,9 +17,6 @@ struct ElunaCreatureAI : ScriptedAI
bool justSpawned;
// used to delay movementinform hook (WP hook)
std::vector< std::pair<uint32, uint32> > movepoints;
#if defined MANGOS || defined CMANGOS
#define me m_creature
#endif
ElunaCreatureAI(Creature* creature) : ScriptedAI(creature), justSpawned(true)
{
@@ -32,22 +24,14 @@ struct ElunaCreatureAI : ScriptedAI
~ElunaCreatureAI() { }
//Called at World update tick
#ifndef TRINITY
void UpdateAI(const uint32 diff) override
#else
void UpdateAI(uint32 diff) override
#endif
{
#ifdef TRINITY
//Spawns are handled by Creature.cpp - in function Creature::Update()
#else
if (justSpawned)
{
justSpawned = false;
JustRespawned();
}
#endif
if (!movepoints.empty())
{
@@ -61,17 +45,11 @@ struct ElunaCreatureAI : ScriptedAI
if (!sEluna->UpdateAI(me, diff))
{
#if defined TRINITY || AZEROTHCORE
if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
ScriptedAI::UpdateAI(diff);
#else
if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE))
ScriptedAI::UpdateAI(diff);
#endif
}
}
#if defined TRINITY || AZEROTHCORE
// Called for reaction when initially engaged - this will always happen _after_ JustEnteredCombat
// Called at creature aggro either by MoveInLOS or Attack Start
void JustEngagedWith(Unit* target) override
@@ -79,34 +57,13 @@ struct ElunaCreatureAI : ScriptedAI
if (!sEluna->EnterCombat(me, target))
ScriptedAI::JustEngagedWith(target);
}
#else
//Called for reaction at enter to combat if not in combat yet (enemy can be NULL)
//Called at creature aggro either by MoveInLOS or Attack Start
void EnterCombat(Unit* target) override
{
if (!sEluna->EnterCombat(me, target))
ScriptedAI::EnterCombat(target);
}
#endif
// Called at any Damage from any attacker (before damage apply)
#if defined AZEROTHCORE
void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask) override
#elif defined TRINITY
void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damageType, SpellInfo const* spellInfo) override
#else
void DamageTaken(Unit* attacker, uint32& damage) override
#endif
{
if (!sEluna->DamageTaken(me, attacker, damage))
{
#if defined AZEROTHCORE
ScriptedAI::DamageTaken(attacker, damage, damagetype, damageSchoolMask);
#elif defined TRINITY
ScriptedAI::DamageTaken(attacker, damage, damageType, spellInfo);
#else
ScriptedAI::DamageTaken(attacker, damage);
#endif
}
}
@@ -160,21 +117,12 @@ struct ElunaCreatureAI : ScriptedAI
ScriptedAI::EnterEvadeMode();
}
#ifdef TRINITY
// Called when creature appears in the world (spawn, respawn, grid load etc...)
void JustAppeared() override
{
if (!sEluna->JustRespawned(me))
ScriptedAI::JustAppeared();
}
#else
// Called when creature is spawned or respawned (for reseting variables)
void JustRespawned() override
{
if (!sEluna->JustRespawned(me))
ScriptedAI::JustRespawned();
}
#endif
// Called at reaching home after evade
void JustReachedHome() override
@@ -197,14 +145,6 @@ struct ElunaCreatureAI : ScriptedAI
ScriptedAI::CorpseRemoved(respawnDelay);
}
#if !defined TRINITY && !AZEROTHCORE
// Enables use of MoveInLineOfSight
bool IsVisible(Unit* who) const override
{
return true;
}
#endif
void MoveInLineOfSight(Unit* who) override
{
if (!sEluna->MoveInLineOfSight(me, who))
@@ -212,44 +152,25 @@ struct ElunaCreatureAI : ScriptedAI
}
// Called when hit by a spell
#if defined TRINITY
void SpellHit(WorldObject* caster, SpellInfo const* spell) override
#else
void SpellHit(Unit* caster, SpellInfo const* spell) override
#endif
{
if (!sEluna->SpellHit(me, caster, spell))
ScriptedAI::SpellHit(caster, spell);
}
// Called when spell hits a target
#if defined TRINITY
void SpellHitTarget(WorldObject* target, SpellInfo const* spell) override
#else
void SpellHitTarget(Unit* target, SpellInfo const* spell) override
#endif
{
if (!sEluna->SpellHitTarget(me, target, spell))
ScriptedAI::SpellHitTarget(target, spell);
}
#if defined TRINITY || AZEROTHCORE
#if defined TRINITY || AZEROTHCORE
// Called when the creature is summoned successfully by other creature
void IsSummonedBy(WorldObject* summoner) override
{
if (!summoner->ToUnit() || !sEluna->OnSummoned(me, summoner->ToUnit()))
ScriptedAI::IsSummonedBy(summoner);
}
#else
// Called when the creature is summoned successfully by other creature
void IsSummonedBy(Unit* summoner) override
{
if (!sEluna->OnSummoned(me, summoner))
ScriptedAI::IsSummonedBy(summoner);
}
#endif
void SummonedCreatureDies(Creature* summon, Unit* killer) override
{
@@ -270,11 +191,6 @@ struct ElunaCreatureAI : ScriptedAI
if (!sEluna->OwnerAttacked(me, target))
ScriptedAI::OwnerAttacked(target);
}
#endif
#if defined MANGOS || defined CMANGOS
#undef me
#endif
};
#endif

View File

@@ -9,18 +9,10 @@
#include "ElunaUtility.h"
#include "Common.h"
#ifdef TRINITY
#include "Random.h"
#else
#include "Util.h"
#endif
#include <map>
#if defined(TRINITY) || AZEROTHCORE
#include "Define.h"
#else
#include "Platform/Define.h"
#endif
class Eluna;
class EventMgr;

View File

@@ -37,18 +37,7 @@
#include "TemporarySummon.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#if defined TRINITY
#include "SpellHistory.h"
#endif
#if defined AZEROTHCORE
#include "MapMgr.h"
#else
#include "MapManager.h"
#endif
#if defined TRINITY || defined AZEROTHCORE
#include "Config.h"
#include "GameEventMgr.h"
#include "GitRevision.h"
@@ -60,54 +49,17 @@
#include "MotionMaster.h"
#include "DatabaseEnv.h"
#include "Bag.h"
#else
#include "Config/Config.h"
#ifdef CMANGOS
#include "AI/AggressorAI.h"
#else
#include "AggressorAI.h"
#endif
#include "BattleGroundMgr.h"
#include "SQLStorages.h"
#include "revision.h"
#endif
#if (!defined(TBC) && !defined(CLASSIC))
#include "Vehicle.h"
#endif
#ifndef CLASSIC
#include "ArenaTeam.h"
#endif
#ifndef CLASSIC
typedef Opcodes OpcodesList;
#endif
/*
* Note: if you add or change a CORE_NAME or CORE_VERSION #define,
* please update LuaGlobalFunctions::GetCoreName or LuaGlobalFunctions::GetCoreVersion documentation example string.
*/
#ifdef MANGOS
#define CORE_NAME "MaNGOS"
#define CORE_VERSION REVISION_NR
#endif
#ifdef CMANGOS
#define CORE_NAME "cMaNGOS"
#define CORE_VERSION REVISION_DATE " " REVISION_TIME
#endif
#ifdef TRINITY
#define CORE_NAME "TrinityCore"
#define REGEN_TIME_FULL
#endif
#ifdef AZEROTHCORE
#define CORE_NAME "AzerothCore"
#endif
#if defined TRINITY || defined AZEROTHCORE
#define CORE_VERSION (GitRevision::GetFullVersion())
#define eWorld (sWorld)
#define eMapMgr (sMapMgr)
@@ -118,42 +70,5 @@ typedef Opcodes OpcodesList;
#define eAuctionMgr (sAuctionMgr)
#define eGameEventMgr (sGameEventMgr)
#define eObjectAccessor() ObjectAccessor::
#endif
#ifdef CATA
#define NUM_MSG_TYPES NUM_OPCODE_HANDLERS
#endif
#if !defined TRINITY && !AZEROTHCORE
#define eWorld (&sWorld)
#define eMapMgr (&sMapMgr)
#define eConfigMgr (&sConfig)
#define eGuildMgr (&sGuildMgr)
#define eObjectMgr (&sObjectMgr)
#define eAccountMgr (&sAccountMgr)
#define eAuctionMgr (&sAuctionMgr)
#define eGameEventMgr (&sGameEventMgr)
#define eObjectAccessor() sObjectAccessor.
#define SERVER_MSG_STRING SERVER_MSG_CUSTOM
#define TOTAL_LOCALES MAX_LOCALE
#define TARGETICONCOUNT TARGET_ICON_COUNT
#define MAX_TALENT_SPECS MAX_TALENT_SPEC_COUNT
#define TEAM_NEUTRAL TEAM_INDEX_NEUTRAL
#if defined(TBC) || defined(WOTLK) || defined(CATA)
#define PLAYER_FIELD_LIFETIME_HONORABLE_KILLS PLAYER_FIELD_LIFETIME_HONORBALE_KILLS
#endif
#ifdef TBC
#define SPELL_AURA_MOD_KILL_XP_PCT SPELL_AURA_MOD_XP_PCT
#endif
#if defined(CATA) || defined(MISTS) || (defined(WOTLK) && !defined(MANGOS))
#define UNIT_BYTE2_FLAG_SANCTUARY UNIT_BYTE2_FLAG_SUPPORTABLE
#endif
typedef TemporarySummon TempSummon;
typedef SpellEntry SpellInfo;
#endif // TRINITY
#endif // _ELUNA_INCLUDES_H

View File

@@ -9,7 +9,6 @@
#include "lmarshal.h"
#ifndef TRINITY
void ElunaInstanceAI::Initialize()
{
LOCK_ELUNA;
@@ -23,7 +22,6 @@ void ElunaInstanceAI::Initialize()
sEluna->OnInitialize(this);
}
#endif
void ElunaInstanceAI::Load(const char* data)
{
@@ -84,9 +82,7 @@ void ElunaInstanceAI::Load(const char* data)
lua_pop(L, 1);
// Stack: (empty)
#ifndef TRINITY
Initialize();
#endif
}
}
else
@@ -96,9 +92,7 @@ void ElunaInstanceAI::Load(const char* data)
lua_pop(L, 1);
// Stack: (empty)
#ifndef TRINITY
Initialize();
#endif
}
delete[] decodedData;
@@ -107,9 +101,7 @@ void ElunaInstanceAI::Load(const char* data)
{
ELUNA_LOG_ERROR("Error while decoding instance data: Data is not valid base-64");
#ifndef TRINITY
Initialize();
#endif
}
}

View File

@@ -8,15 +8,7 @@
#define _ELUNA_INSTANCE_DATA_H
#include "LuaEngine.h"
#if defined(TRINITY) || AZEROTHCORE
#include "InstanceScript.h"
#else
#include "InstanceData.h"
#endif
#ifdef TRINITY
#include "Map.h"
#endif
/*
* This class is a small wrapper around `InstanceData`,
@@ -64,35 +56,23 @@ private:
std::string lastSaveData;
public:
#ifdef TRINITY
ElunaInstanceAI(Map* map) : InstanceData(map->ToInstanceMap())
{
}
#else
ElunaInstanceAI(Map* map) : InstanceData(map)
{
}
#endif
#ifndef TRINITY
void Initialize() override;
#endif
/*
* These are responsible for serializing/deserializing the instance's
* data table to/from the core.
*/
void Load(const char* data) override;
#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
{
return Save();
}
const char* Save() const;
#else
const char* Save() const override;
#endif
/*
@@ -139,11 +119,7 @@ public:
sEluna->OnPlayerEnterInstance(this, player);
}
#if defined TRINITY || AZEROTHCORE
void OnGameObjectCreate(GameObject* gameobject) override
#else
void OnObjectCreate(GameObject* gameobject) override
#endif
{
sEluna->OnGameObjectCreate(this, gameobject);
}

View File

@@ -10,9 +10,6 @@
#include "Unit.h"
#include "GameObject.h"
#include "DBCStores.h"
#ifdef MANGOS
#include "Timer.h"
#endif
uint32 ElunaUtil::GetCurrTime()
{
@@ -72,26 +69,17 @@ bool ElunaUtil::WorldObjectInRangeCheck::operator()(WorldObject* u)
target = go->GetOwner();
if (target)
{
#ifdef CMANGOS
if (i_dead && (i_dead == 1) != target->isAlive())
return false;
#else
if (i_dead && (i_dead == 1) != target->IsAlive())
return false;
#endif
if (i_hostile)
{
if (!i_obj_unit)
{
if (i_obj_fact)
{
#if defined TRINITY || AZEROTHCORE
if ((i_obj_fact->IsHostileTo(*target->GetFactionTemplateEntry())) != (i_hostile == 1))
return false;
#else
if ((i_obj_fact->IsHostileTo(*target->getFactionTemplateEntry())) != (i_hostile == 1))
return false;
#endif
}
else if (i_hostile == 1)
return false;

View File

@@ -14,18 +14,9 @@
#include "Common.h"
#include "SharedDefines.h"
#include "ObjectGuid.h"
#ifdef TRINITY
#include "QueryResult.h"
#include "Log.h"
#ifdef CATA
#include "Object.h"
#endif
#else
#include "Database/QueryResult.h"
#include "Log.h"
#endif
#if defined(TRINITY) || defined(AZEROTHCORE)
typedef QueryResult ElunaQuery;
#define GET_GUID GetGUID
#define HIGHGUID_PLAYER HighGuid::Player
@@ -41,29 +32,11 @@ typedef QueryResult ElunaQuery;
#define HIGHGUID_MO_TRANSPORT HighGuid::Mo_Transport
#define HIGHGUID_INSTANCE HighGuid::Instance
#define HIGHGUID_GROUP HighGuid::Group
#endif
#ifdef TRINITY
#define ELUNA_LOG_INFO(...) TC_LOG_INFO("eluna", __VA_ARGS__);
#define ELUNA_LOG_ERROR(...) TC_LOG_ERROR("eluna", __VA_ARGS__);
#define ELUNA_LOG_DEBUG(...) TC_LOG_DEBUG("eluna", __VA_ARGS__);
#elif defined(AZEROTHCORE)
#define ELUNA_LOG_INFO(...) LOG_INFO("eluna", __VA_ARGS__);
#define ELUNA_LOG_ERROR(...) LOG_ERROR("eluna", __VA_ARGS__);
#define ELUNA_LOG_DEBUG(...) LOG_DEBUG("eluna", __VA_ARGS__);
#else
typedef QueryNamedResult ElunaQuery;
#define ASSERT MANGOS_ASSERT
#define ELUNA_LOG_INFO(...) sLog.outString(__VA_ARGS__);
#define ELUNA_LOG_ERROR(...) sLog.outErrorEluna(__VA_ARGS__);
#define ELUNA_LOG_DEBUG(...) sLog.outDebug(__VA_ARGS__);
#define GET_GUID GetObjectGuid
#define GetGameObjectTemplate GetGameObjectInfo
#define GetItemTemplate GetItemPrototype
#define GetTemplate GetProto
#endif
#if defined(TRINITY) || defined(AZEROTHCORE) || defined(MANGOS)
#ifndef MAKE_NEW_GUID
#define MAKE_NEW_GUID(l, e, h) ObjectGuid(h, e, l)
#endif
@@ -76,7 +49,6 @@ typedef QueryNamedResult ElunaQuery;
#ifndef GUID_HIPART
#define GUID_HIPART(guid) ObjectGuid(guid).GetHigh()
#endif
#endif
class Unit;
class WorldObject;

View File

@@ -5,9 +5,8 @@ extern "C"
#include "lauxlib.h"
};
#if defined TRINITY || defined AZEROTHCORE
#define CPPHTTPLIB_OPENSSL_SUPPORT
#endif
#include "libs/httplib.h"
#include "HttpManager.h"
#include "LuaEngine.h"

View File

@@ -16,35 +16,15 @@
#include "ElunaCreatureAI.h"
#include "ElunaInstanceAI.h"
#if defined(TRINITY_PLATFORM) && defined(TRINITY_PLATFORM_WINDOWS)
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
#define ELUNA_WINDOWS
#endif
#elif defined(AC_PLATFORM) && defined(AC_PLATFORM_WINDOWS)
#if AC_PLATFORM == AC_PLATFORM_WINDOWS
#define ELUNA_WINDOWS
#endif
#elif defined(PLATFORM) && defined(PLATFORM_WINDOWS)
#if PLATFORM == PLATFORM_WINDOWS
#define ELUNA_WINDOWS
#endif
#else
#error Eluna could not determine platform
#endif
// Some dummy includes containing BOOST_VERSION:
// ObjectAccessor.h Config.h Log.h
#if !defined MANGOS
#define USING_BOOST
#endif
#ifdef USING_BOOST
#include <boost/filesystem.hpp>
#else
#include <ace/ACE.h>
#include <ace/Dirent.h>
#include <ace/OS_NS_sys_stat.h>
#endif
extern "C"
{
@@ -72,11 +52,9 @@ void Eluna::Initialize()
LOCK_ELUNA;
ASSERT(!IsInitialized());
#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");
#endif
LoadScriptPaths();
@@ -109,11 +87,7 @@ void Eluna::LoadScriptPaths()
lua_scripts.clear();
lua_extensions.clear();
#if defined(AZEROTHCORE)
lua_folderpath = eConfigMgr->GetOption<std::string>("Eluna.ScriptPath", "lua_scripts");
#else
lua_folderpath = eConfigMgr->GetStringDefault("Eluna.ScriptPath", "lua_scripts");
#endif
#ifndef ELUNA_WINDOWS
if (lua_folderpath[0] == '~')
@@ -226,11 +200,7 @@ void Eluna::CloseLua()
void Eluna::OpenLua()
{
#if defined(AZEROTHCORE)
enabled = eConfigMgr->GetOption<bool>("Eluna.Enabled", true);
#else
enabled = eConfigMgr->GetBoolDefault("Eluna.Enabled", true);
#endif
if (!IsEnabled())
{
@@ -363,7 +333,6 @@ void Eluna::GetScripts(std::string path)
{
ELUNA_LOG_DEBUG("[Eluna]: GetScripts from path `{}`", path);
#ifdef USING_BOOST
boost::filesystem::path someDir(path);
boost::filesystem::directory_iterator end_iter;
@@ -405,53 +374,6 @@ void Eluna::GetScripts(std::string path)
}
}
}
#else
ACE_Dirent dir;
if (dir.open(path.c_str()) == -1) // Error opening directory, return
return;
lua_requirepath +=
path + "/?.lua;" +
path + "/?.ext;" +
path + "/?.dll;" +
path + "/?.so;";
ACE_DIRENT *directory = 0;
while ((directory = dir.read()))
{
// Skip the ".." and "." files.
if (ACE::isdotdir(directory->d_name))
continue;
std::string fullpath = path + "/" + directory->d_name;
// Check if file is hidden
#ifdef ELUNA_WINDOWS
DWORD dwAttrib = GetFileAttributes(fullpath.c_str());
if (dwAttrib != INVALID_FILE_ATTRIBUTES && (dwAttrib & FILE_ATTRIBUTE_HIDDEN))
continue;
#else
std::string name = directory->d_name;
if (name[0] == '.')
continue;
#endif
ACE_stat stat_buf;
if (ACE_OS::lstat(fullpath.c_str(), &stat_buf) == -1)
continue;
// load subfolder
if ((stat_buf.st_mode & S_IFMT) == (S_IFDIR))
{
GetScripts(fullpath);
continue;
}
// was file, try add
std::string filename = directory->d_name;
AddScriptPath(filename, fullpath);
}
#endif
}
static bool ScriptPathComparator(const LuaScript& first, const LuaScript& second)
@@ -540,11 +462,7 @@ void Eluna::RunScripts()
void Eluna::InvalidateObjects()
{
++callstackid;
#ifdef TRINITY
ASSERT(callstackid, "Callstackid overflow");
#else
ASSERT(callstackid && "Callstackid overflow");
#endif
}
void Eluna::Report(lua_State* _L)
@@ -600,12 +518,7 @@ bool Eluna::ExecuteCall(int params, int res)
ASSERT(false); // stack probably corrupt
}
#if defined(AZEROTHCORE)
bool usetrace = eConfigMgr->GetOption<bool>("Eluna.TraceBack", false);
#else
bool usetrace = eConfigMgr->GetBoolDefault("Eluna.TraceBack", false);
#endif
if (usetrace)
{
lua_pushcfunction(L, &StackTrace);

View File

@@ -14,9 +14,7 @@
#include "Group.h"
#include "Item.h"
#include "Chat.h"
#ifndef TRINITY
#include "Player.h"
#endif
#include "Weather.h"
#include "World.h"
#include "Hooks.h"
@@ -32,46 +30,23 @@ extern "C"
#include "lua.h"
};
#if defined(TRINITY) || AZEROTHCORE
struct ItemTemplate;
typedef BattlegroundTypeId BattleGroundTypeId;
#else
struct ItemPrototype;
typedef ItemPrototype ItemTemplate;
typedef SpellEffectIndex SpellEffIndex;
struct SpellEntry;
typedef SpellEntry SpellInfo;
#ifdef CLASSIC
typedef int Difficulty;
#endif
#endif
#ifndef AZEROTHCORE
struct AreaTriggerEntry;
#else
typedef AreaTrigger AreaTriggerEntry;
#endif
class AuctionHouseObject;
struct AuctionEntry;
#if defined(TRINITY) || AZEROTHCORE
class Battleground;
typedef Battleground BattleGround;
#endif
class Channel;
class Corpse;
class Creature;
class CreatureAI;
class GameObject;
#if defined(TRINITY) || AZEROTHCORE
class GameObjectAI;
#endif
class Guild;
class Group;
#if defined(TRINITY) || AZEROTHCORE
class InstanceScript;
typedef InstanceScript InstanceData;
#else
class InstanceData;
#endif
class ElunaInstanceAI;
class Item;
class Pet;
@@ -79,26 +54,12 @@ class Player;
class Quest;
class Spell;
class SpellCastTargets;
#if defined(TRINITY) || AZEROTHCORE
class TempSummon;
#else
class TemporarySummon;
typedef TemporarySummon TempSummon;
#endif
// class Transport;
class Unit;
class Weather;
class WorldPacket;
#ifndef CLASSIC
#ifndef TBC
#if defined(TRINITY) || AZEROTHCORE
class Vehicle;
#else
class VehicleInfo;
typedef VehicleInfo Vehicle;
#endif
#endif
#endif
struct lua_State;
class EventMgr;
@@ -121,13 +82,7 @@ struct LuaScript
#define ELUNA_STATE_PTR "Eluna State Ptr"
#define LOCK_ELUNA Eluna::Guard __guard(Eluna::GetLock())
#if defined(TRINITY)
#define ELUNA_GAME_API TC_GAME_API
#elif defined(AZEROTHCORE)
#define ELUNA_GAME_API AC_GAME_API
#else
#define ELUNA_GAME_API
#endif
class ELUNA_GAME_API Eluna
{
@@ -429,12 +384,8 @@ public:
bool OnQuestAccept(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest);
bool OnQuestReward(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest, uint32 opt);
void GetDialogStatus(const Player* pPlayer, const GameObject* pGameObject);
#ifndef CLASSIC
#ifndef TBC
void OnDestroyed(GameObject* pGameObject, WorldObject* attacker);
void OnDamaged(GameObject* pGameObject, WorldObject* attacker);
#endif
#endif
void OnLootStateChanged(GameObject* pGameObject, uint32 state);
void OnGameObjectStateChanged(GameObject* pGameObject, uint32 state);
void UpdateAI(GameObject* pGameObject, uint32 diff);
@@ -492,16 +443,12 @@ public:
void OnBattlegroundDesertion(Player* player, const BattlegroundDesertionType type);
void OnCreatureKilledByPet(Player* player, Creature* killed);
#ifndef CLASSIC
#ifndef TBC
/* Vehicle */
void OnInstall(Vehicle* vehicle);
void OnUninstall(Vehicle* vehicle);
void OnInstallAccessory(Vehicle* vehicle, Creature* accessory);
void OnAddPassenger(Vehicle* vehicle, Unit* passenger, int8 seatId);
void OnRemovePassenger(Vehicle* vehicle, Unit* passenger);
#endif
#endif
/* AreaTrigger */
bool OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* pTrigger);
@@ -560,11 +507,7 @@ 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();
@@ -574,11 +517,7 @@ 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);
};

View File

@@ -212,10 +212,8 @@ ElunaRegister<WorldObject> WorldObjectMethods[] =
// Getters
{ "GetName", &LuaWorldObject::GetName },
{ "GetMap", &LuaWorldObject::GetMap },
#if (!defined(TBC) && !defined(CLASSIC))
{ "GetPhaseMask", &LuaWorldObject::GetPhaseMask },
{ "SetPhaseMask", &LuaWorldObject::SetPhaseMask },
#endif
{ "GetInstanceId", &LuaWorldObject::GetInstanceId },
{ "GetAreaId", &LuaWorldObject::GetAreaId },
{ "GetZoneId", &LuaWorldObject::GetZoneId },
@@ -301,9 +299,7 @@ ElunaRegister<Unit> UnitMethods[] =
{ "GetCharmerGUID", &LuaUnit::GetCharmerGUID },
{ "GetCharmGUID", &LuaUnit::GetCharmGUID },
{ "GetPetGUID", &LuaUnit::GetPetGUID },
#if (!defined(TBC) && !defined(CLASSIC))
{ "GetCritterGUID", &LuaUnit::GetCritterGUID },
#endif
{ "GetControllerGUID", &LuaUnit::GetControllerGUID },
{ "GetControllerGUIDS", &LuaUnit::GetControllerGUIDS },
{ "GetStandState", &LuaUnit::GetStandState },
@@ -312,10 +308,8 @@ ElunaRegister<Unit> UnitMethods[] =
{ "GetSpeedRate", &LuaUnit::GetSpeedRate },
{ "GetStat", &LuaUnit::GetStat },
{ "GetBaseSpellPower", &LuaUnit::GetBaseSpellPower },
#if (!defined(TBC) && !defined(CLASSIC))
{ "GetVehicleKit", &LuaUnit::GetVehicleKit },
// {"GetVehicle", &LuaUnit::GetVehicle}, // :GetVehicle() - UNDOCUMENTED - Gets the Vehicle kit of the vehicle the unit is on
#endif
{ "GetMovementType", &LuaUnit::GetMovementType },
{ "GetAttackers", &LuaUnit::GetAttackers },
@@ -338,10 +332,8 @@ ElunaRegister<Unit> UnitMethods[] =
{"SetConfused", &LuaUnit::SetConfused},
{"SetFeared", &LuaUnit::SetFeared},
{ "SetPvP", &LuaUnit::SetPvP },
#if (!defined(TBC) && !defined(CLASSIC))
{ "SetFFA", &LuaUnit::SetFFA },
{ "SetSanctuary", &LuaUnit::SetSanctuary },
#endif
// {"SetCanFly", &LuaUnit::SetCanFly}, // :SetCanFly(apply) - UNDOCUMENTED
// {"SetVisible", &LuaUnit::SetVisible}, // :SetVisible(x) - UNDOCUMENTED
{ "SetOwnerGUID", &LuaUnit::SetOwnerGUID },
@@ -350,9 +342,7 @@ ElunaRegister<Unit> UnitMethods[] =
{ "SetCreatorGUID", &LuaUnit::SetCreatorGUID },
{ "SetMinionGUID", &LuaUnit::SetPetGUID },
{ "SetPetGUID", &LuaUnit::SetPetGUID },
#if (!defined(TBC) && !defined(CLASSIC))
{ "SetCritterGUID", &LuaUnit::SetCritterGUID },
#endif
{ "SetWaterWalk", &LuaUnit::SetWaterWalk },
{ "SetStandState", &LuaUnit::SetStandState },
{ "SetInCombatWith", &LuaUnit::SetInCombatWith },
@@ -401,18 +391,14 @@ ElunaRegister<Unit> UnitMethods[] =
{ "HasAura", &LuaUnit::HasAura },
{ "IsCasting", &LuaUnit::IsCasting },
{ "IsStandState", &LuaUnit::IsStandState },
#ifndef CLASSIC
{ "IsOnVehicle", &LuaUnit::IsOnVehicle },
#endif
// Other
{ "HandleStatModifier", &LuaUnit::HandleStatModifier },
{ "AddAura", &LuaUnit::AddAura },
{ "RemoveAura", &LuaUnit::RemoveAura },
{ "RemoveAllAuras", &LuaUnit::RemoveAllAuras },
#if !defined(CLASSIC)
{ "RemoveArenaAuras", &LuaUnit::RemoveArenaAuras },
#endif
{ "ClearInCombat", &LuaUnit::ClearInCombat },
{ "DeMorph", &LuaUnit::DeMorph },
{ "SendUnitWhisper", &LuaUnit::SendUnitWhisper },
@@ -451,9 +437,7 @@ ElunaRegister<Unit> UnitMethods[] =
{ "MoveConfused", &LuaUnit::MoveConfused },
{ "MoveFleeing", &LuaUnit::MoveFleeing },
{ "MoveTo", &LuaUnit::MoveTo },
#if (!defined(TBC) && !defined(CLASSIC))
{ "MoveJump", &LuaUnit::MoveJump },
#endif
{ "MoveStop", &LuaUnit::MoveStop },
{ "MoveExpire", &LuaUnit::MoveExpire },
{ "MoveClear", &LuaUnit::MoveClear },
@@ -479,10 +463,8 @@ ElunaRegister<Player> PlayerMethods[] =
{ "GetAccountId", &LuaPlayer::GetAccountId },
{ "GetAccountName", &LuaPlayer::GetAccountName },
{ "GetCompletedQuestsCount", &LuaPlayer::GetCompletedQuestsCount },
#if defined (TBC) || defined (WOTLK)
{ "GetArenaPoints", &LuaPlayer::GetArenaPoints },
{ "GetHonorPoints", &LuaPlayer::GetHonorPoints },
#endif
{ "GetLifetimeKills", &LuaPlayer::GetLifetimeKills },
{ "GetPlayerIP", &LuaPlayer::GetPlayerIP },
{ "GetLevelPlayedTime", &LuaPlayer::GetLevelPlayedTime },
@@ -497,11 +479,9 @@ ElunaRegister<Player> PlayerMethods[] =
{ "GetQuestLevel", &LuaPlayer::GetQuestLevel },
{ "GetChatTag", &LuaPlayer::GetChatTag },
{ "GetRestBonus", &LuaPlayer::GetRestBonus },
#ifdef WOTLK
{ "GetPhaseMaskForSpawn", &LuaPlayer::GetPhaseMaskForSpawn },
{ "GetAchievementPoints", &LuaPlayer::GetAchievementPoints },
{ "GetCompletedAchievementsCount", &LuaPlayer::GetCompletedAchievementsCount },
#endif
{ "GetReqKillOrCastCurrentCount", &LuaPlayer::GetReqKillOrCastCurrentCount },
{ "GetQuestStatus", &LuaPlayer::GetQuestStatus },
{ "GetInGameTime", &LuaPlayer::GetInGameTime },
@@ -509,10 +489,8 @@ ElunaRegister<Player> PlayerMethods[] =
{ "GetComboTarget", &LuaPlayer::GetComboTarget },
{ "GetGuildName", &LuaPlayer::GetGuildName },
{ "GetFreeTalentPoints", &LuaPlayer::GetFreeTalentPoints },
#if (!defined(TBC) && !defined(CLASSIC))
{ "GetActiveSpec", &LuaPlayer::GetActiveSpec },
{ "GetSpecsCount", &LuaPlayer::GetSpecsCount },
#endif
{ "GetSpellCooldownDelay", &LuaPlayer::GetSpellCooldownDelay },
{ "GetGuildRank", &LuaPlayer::GetGuildRank },
{ "GetDifficulty", &LuaPlayer::GetDifficulty },
@@ -536,9 +514,7 @@ ElunaRegister<Player> PlayerMethods[] =
{ "GetNextRandomRaidMember", &LuaPlayer::GetNextRandomRaidMember },
{ "GetOriginalGroup", &LuaPlayer::GetOriginalGroup },
{ "GetOriginalSubGroup", &LuaPlayer::GetOriginalSubGroup },
#if defined(TRINITY) || AZEROTHCORE
{ "GetChampioningFaction", &LuaPlayer::GetChampioningFaction },
#endif
{ "GetLatency", &LuaPlayer::GetLatency },
// {"GetRecruiterId", &LuaPlayer::GetRecruiterId}, // :GetRecruiterId() - UNDOCUMENTED - Returns player's recruiter's ID
{ "GetDbLocaleIndex", &LuaPlayer::GetDbLocaleIndex },
@@ -546,14 +522,7 @@ ElunaRegister<Player> PlayerMethods[] =
{ "GetCorpse", &LuaPlayer::GetCorpse },
{ "GetGossipTextId", &LuaPlayer::GetGossipTextId },
{ "GetQuestRewardStatus", &LuaPlayer::GetQuestRewardStatus },
#if defined(CLASSIC) || defined(TBC) || defined(WOTLK)
{ "GetShieldBlockValue", &LuaPlayer::GetShieldBlockValue },
#endif
#ifdef CLASSIC
{ "GetHonorStoredKills", &LuaPlayer::GetHonorStoredKills },
{ "GetRankPoints", &LuaPlayer::GetRankPoints },
{ "GetHonorLastWeekStandingPos", &LuaPlayer::GetHonorLastWeekStandingPos },
#endif
{ "GetPlayerSettingValue", &LuaPlayer::GetPlayerSettingValue },
{ "GetTrader", &LuaPlayer::GetTrader },
@@ -563,20 +532,11 @@ ElunaRegister<Player> PlayerMethods[] =
{ "AdvanceAllSkills", &LuaPlayer::AdvanceAllSkills },
{ "AddLifetimeKills", &LuaPlayer::AddLifetimeKills },
{ "SetCoinage", &LuaPlayer::SetCoinage },
#ifndef CLASSIC
{ "SetKnownTitle", &LuaPlayer::SetKnownTitle },
{ "UnsetKnownTitle", &LuaPlayer::UnsetKnownTitle },
#endif
{ "SetBindPoint", &LuaPlayer::SetBindPoint },
#if defined(TBC) || defined(WOTLK)
{ "SetArenaPoints", &LuaPlayer::SetArenaPoints },
{ "SetHonorPoints", &LuaPlayer::SetHonorPoints },
#endif
#ifdef CLASSIC
{ "SetHonorStoredKills", &LuaPlayer::SetHonorStoredKills },
{ "SetRankPoints", &LuaPlayer::SetRankPoints },
{ "SetHonorLastWeekStandingPos", &LuaPlayer::SetHonorLastWeekStandingPos },
#endif
{ "SetSpellPower", &LuaPlayer::SetSpellPower },
{ "SetLifetimeKills", &LuaPlayer::SetLifetimeKills },
{ "SetGameMaster", &LuaPlayer::SetGameMaster },
@@ -598,9 +558,6 @@ ElunaRegister<Player> PlayerMethods[] =
{ "SetPlayerLock", &LuaPlayer::SetPlayerLock },
{ "SetGender", &LuaPlayer::SetGender },
{ "SetSheath", &LuaPlayer::SetSheath },
#if !defined TRINITY && !AZEROTHCORE
{ "SetFFA", &LuaPlayer::SetFFA },
#endif
// Boolean
{ "HasTankSpec", &LuaPlayer::HasTankSpec },
@@ -613,15 +570,11 @@ ElunaRegister<Player> PlayerMethods[] =
{ "IsImmuneToDamage", &LuaPlayer::IsImmuneToDamage },
{ "IsAlliance", &LuaPlayer::IsAlliance },
{ "IsHorde", &LuaPlayer::IsHorde },
#ifndef CLASSIC
{ "HasTitle", &LuaPlayer::HasTitle },
#endif
{ "HasItem", &LuaPlayer::HasItem },
{ "Teleport", &LuaPlayer::Teleport },
{ "AddItem", &LuaPlayer::AddItem },
#ifndef CLASSIC
{ "IsInArenaTeam", &LuaPlayer::IsInArenaTeam },
#endif
{ "CanRewardQuest", &LuaPlayer::CanRewardQuest },
{ "CanCompleteRepeatableQuest", &LuaPlayer::CanCompleteRepeatableQuest },
{ "CanCompleteQuest", &LuaPlayer::CanCompleteQuest },
@@ -642,13 +595,9 @@ ElunaRegister<Player> PlayerMethods[] =
{ "HasAtLoginFlag", &LuaPlayer::HasAtLoginFlag },
// {"InRandomLfgDungeon", &LuaPlayer::InRandomLfgDungeon}, // :InRandomLfgDungeon() - UNDOCUMENTED - Returns true if the player is in a random LFG dungeon
// {"HasPendingBind", &LuaPlayer::HasPendingBind}, // :HasPendingBind() - UNDOCUMENTED - Returns true if the player has a pending instance bind
#if (!defined(TBC) && !defined(CLASSIC))
{ "HasAchieved", &LuaPlayer::HasAchieved },
{ "GetAchievementCriteriaProgress", &LuaPlayer::GetAchievementCriteriaProgress },
#if defined(TRINITY) || defined(AZEROTHCORE)
{ "SetAchievement", &LuaPlayer::SetAchievement },
#endif
#endif
{ "CanUninviteFromGroup", &LuaPlayer::CanUninviteFromGroup },
{ "IsRested", &LuaPlayer::IsRested },
// {"CanFlyInZone", &LuaPlayer::CanFlyInZone}, // :CanFlyInZone(mapid, zone) - UNDOCUMENTED - Returns true if the player can fly in the area
@@ -659,9 +608,7 @@ ElunaRegister<Player> PlayerMethods[] =
{ "HasQuestForGO", &LuaPlayer::HasQuestForGO },
{ "CanShareQuest", &LuaPlayer::CanShareQuest },
// {"HasReceivedQuestReward", &LuaPlayer::HasReceivedQuestReward}, // :HasReceivedQuestReward(entry) - UNDOCUMENTED - Returns true if the player has recieved the quest's reward
#if (!defined(TBC) && !defined(CLASSIC))
{ "HasTalent", &LuaPlayer::HasTalent },
#endif
{ "IsInSameGroupWith", &LuaPlayer::IsInSameGroupWith },
{ "IsInSameRaidWith", &LuaPlayer::IsInSameRaidWith },
{ "IsGroupVisibleFor", &LuaPlayer::IsGroupVisibleFor },
@@ -669,26 +616,18 @@ ElunaRegister<Player> PlayerMethods[] =
{ "IsHonorOrXPTarget", &LuaPlayer::IsHonorOrXPTarget },
{ "CanParry", &LuaPlayer::CanParry },
{ "CanBlock", &LuaPlayer::CanBlock },
#if (!defined(TBC) && !defined(CLASSIC))
{ "CanTitanGrip", &LuaPlayer::CanTitanGrip },
#endif
{ "InBattleground", &LuaPlayer::InBattleground },
#ifndef CLASSIC
{ "InArena", &LuaPlayer::InArena },
#endif
// {"IsOutdoorPvPActive", &LuaPlayer::IsOutdoorPvPActive}, // :IsOutdoorPvPActive() - UNDOCUMENTED - Returns true if the player is outdoor pvp active
// {"IsARecruiter", &LuaPlayer::IsARecruiter}, // :IsARecruiter() - UNDOCUMENTED - Returns true if the player is a recruiter
{ "CanUseItem", &LuaPlayer::CanUseItem },
{ "HasSpell", &LuaPlayer::HasSpell },
{ "HasSpellCooldown", &LuaPlayer::HasSpellCooldown },
{ "IsInWater", &LuaPlayer::IsInWater },
#ifndef CLASSIC
{ "CanFly", &LuaPlayer::CanFly },
#endif
{ "IsMoving", &LuaPlayer::IsMoving },
#ifndef CLASSIC
{ "IsFlying", &LuaPlayer::IsFlying },
#endif
// Gossip
{ "GossipMenuAddItem", &LuaPlayer::GossipMenuAddItem },
@@ -709,9 +648,7 @@ ElunaRegister<Player> PlayerMethods[] =
{ "RunCommand", &LuaPlayer::RunCommand },
{ "SetGlyph", &LuaPlayer::SetGlyph },
{ "GetGlyph", &LuaPlayer::GetGlyph },
#if !defined(CLASSIC)
{ "RemoveArenaSpellCooldowns", &LuaPlayer::RemoveArenaSpellCooldowns },
#endif
{ "RemoveItem", &LuaPlayer::RemoveItem },
{ "RemoveLifetimeKills", &LuaPlayer::RemoveLifetimeKills },
{ "ResurrectPlayer", &LuaPlayer::ResurrectPlayer },
@@ -739,9 +676,7 @@ ElunaRegister<Player> PlayerMethods[] =
// {"KilledPlayerCredit", &LuaPlayer::KilledPlayerCredit}, // :KilledPlayerCredit() - UNDOCUMENTED - Satisfies a player kill for the player
// {"KillGOCredit", &LuaPlayer::KillGOCredit}, // :KillGOCredit(GOEntry[, GUID]) - UNDOCUMENTED - Credits the player for destroying a GO, guid is optional
{ "TalkedToCreature", &LuaPlayer::TalkedToCreature },
#if (!defined(TBC) && !defined(CLASSIC))
{ "ResetPetTalents", &LuaPlayer::ResetPetTalents },
#endif
{ "AddComboPoints", &LuaPlayer::AddComboPoints },
// {"GainSpellComboPoints", &LuaPlayer::GainSpellComboPoints}, // :GainSpellComboPoints(amount) - UNDOCUMENTED - Player gains spell combo points
{ "ClearComboPoints", &LuaPlayer::ClearComboPoints },
@@ -758,18 +693,14 @@ ElunaRegister<Player> PlayerMethods[] =
{ "DurabilityPointLossForEquipSlot", &LuaPlayer::DurabilityPointLossForEquipSlot },
{ "DurabilityRepairAll", &LuaPlayer::DurabilityRepairAll },
{ "DurabilityRepair", &LuaPlayer::DurabilityRepair },
#if defined(TBC) || defined(WOTLK)
{ "ModifyHonorPoints", &LuaPlayer::ModifyHonorPoints },
{ "ModifyArenaPoints", &LuaPlayer::ModifyArenaPoints },
#endif
{ "LeaveBattleground", &LuaPlayer::LeaveBattleground },
// {"BindToInstance", &LuaPlayer::BindToInstance}, // :BindToInstance() - UNDOCUMENTED - Binds the player to the current instance
{ "UnbindInstance", &LuaPlayer::UnbindInstance },
{ "UnbindAllInstances", &LuaPlayer::UnbindAllInstances },
{ "RemoveFromBattlegroundRaid", &LuaPlayer::RemoveFromBattlegroundRaid },
#if (!defined(TBC) && !defined(CLASSIC))
{ "ResetAchievements", &LuaPlayer::ResetAchievements },
#endif
{ "KickPlayer", &LuaPlayer::KickPlayer },
{ "LogoutPlayer", &LuaPlayer::LogoutPlayer },
{ "SendTrainerList", &LuaPlayer::SendTrainerList },
@@ -795,14 +726,7 @@ ElunaRegister<Player> PlayerMethods[] =
{ "GroupInvite", &LuaPlayer::GroupInvite },
{ "GroupCreate", &LuaPlayer::GroupCreate },
{ "SendCinematicStart", &LuaPlayer::SendCinematicStart },
#if !defined(CLASSIC) && !defined(TBC)
{ "SendMovieStart", &LuaPlayer::SendMovieStart },
#endif
#ifdef CLASSIC
{ "UpdateHonor", &LuaPlayer::UpdateHonor },
{ "ResetHonor", &LuaPlayer::ResetHonor },
{ "ClearHonorInfo", &LuaPlayer::ClearHonorInfo },
#endif
{ "UpdatePlayerSetting", &LuaPlayer::UpdatePlayerSetting },
{ NULL, NULL }
@@ -820,18 +744,13 @@ ElunaRegister<Creature> 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 },
#if defined(TRINITY) || AZEROTHCORE
{ "GetWaypointPath", &LuaCreature::GetWaypointPath },
{ "GetLootMode", &LuaCreature::GetLootMode },
#endif
{ "GetLootRecipient", &LuaCreature::GetLootRecipient },
{ "GetLootRecipientGroup", &LuaCreature::GetLootRecipientGroup },
{ "GetNPCFlags", &LuaCreature::GetNPCFlags },
@@ -839,16 +758,12 @@ ElunaRegister<Creature> CreatureMethods[] =
{ "GetUnitFlagsTwo", &LuaCreature::GetUnitFlagsTwo },
{ "GetExtraFlags", &LuaCreature::GetExtraFlags },
{ "GetRank", &LuaCreature::GetRank },
#if defined(CLASSIC) || defined(TBC) || defined(WOTLK)
{ "GetShieldBlockValue", &LuaCreature::GetShieldBlockValue },
#endif
{ "GetDBTableGUIDLow", &LuaCreature::GetDBTableGUIDLow },
{ "GetCreatureFamily", &LuaCreature::GetCreatureFamily },
// Setters
#if defined(TRINITY) || defined(AZEROTHCORE)
{ "SetRegeneratingHealth", &LuaCreature::SetRegeneratingHealth },
#endif
{ "SetHover", &LuaCreature::SetHover },
{ "SetDisableGravity", &LuaCreature::SetDisableGravity },
{ "SetAggroEnabled", &LuaCreature::SetAggroEnabled },
@@ -859,15 +774,11 @@ ElunaRegister<Creature> CreatureMethods[] =
{ "SetWanderRadius", &LuaCreature::SetWanderRadius },
{ "SetInCombatWithZone", &LuaCreature::SetInCombatWithZone },
{ "SetDisableReputationGain", &LuaCreature::SetDisableReputationGain },
#if defined(TRINITY) || AZEROTHCORE
{ "SetLootMode", &LuaCreature::SetLootMode },
#endif
{ "SetNPCFlags", &LuaCreature::SetNPCFlags },
{ "SetUnitFlags", &LuaCreature::SetUnitFlags },
{ "SetUnitFlagsTwo", &LuaCreature::SetUnitFlagsTwo },
#if defined(TRINITY) || AZEROTHCORE
{ "SetReactState", &LuaCreature::SetReactState },
#endif
{ "SetDeathState", &LuaCreature::SetDeathState },
{ "SetWalk", &LuaCreature::SetWalk },
{ "SetHomePosition", &LuaCreature::SetHomePosition },
@@ -875,15 +786,11 @@ ElunaRegister<Creature> CreatureMethods[] =
// Boolean
{ "IsRegeneratingHealth", &LuaCreature::IsRegeneratingHealth },
#if defined(TRINITY) || defined(AZEROTHCORE)
{ "IsDungeonBoss", &LuaCreature::IsDungeonBoss },
#endif
{ "IsWorldBoss", &LuaCreature::IsWorldBoss },
{ "IsRacialLeader", &LuaCreature::IsRacialLeader },
{ "IsCivilian", &LuaCreature::IsCivilian },
#if defined(TRINITY) || AZEROTHCORE
{ "IsTrigger", &LuaCreature::IsTrigger },
#endif
{ "IsGuard", &LuaCreature::IsGuard },
{ "IsElite", &LuaCreature::IsElite },
{ "IsInEvadeMode", &LuaCreature::IsInEvadeMode },
@@ -891,9 +798,7 @@ ElunaRegister<Creature> CreatureMethods[] =
{ "CanWalk", &LuaCreature::CanWalk },
{ "CanSwim", &LuaCreature::CanSwim },
{ "CanAggro", &LuaCreature::CanAggro },
#if defined(TRINITY) || AZEROTHCORE
{ "CanStartAttack", &LuaCreature::CanStartAttack },
#endif
{ "HasSearchedAssistance", &LuaCreature::HasSearchedAssistance },
{ "IsTappedBy", &LuaCreature::IsTappedBy },
{ "HasLootRecipient", &LuaCreature::HasLootRecipient },
@@ -901,10 +806,8 @@ ElunaRegister<Creature> CreatureMethods[] =
{ "IsTargetableForAttack", &LuaCreature::IsTargetableForAttack },
{ "CanCompleteQuest", &LuaCreature::CanCompleteQuest },
{ "IsReputationGainDisabled", &LuaCreature::IsReputationGainDisabled },
#if defined(TRINITY) || AZEROTHCORE
{ "IsDamageEnoughForLootingAndReward", &LuaCreature::IsDamageEnoughForLootingAndReward },
{ "HasLootMode", &LuaCreature::HasLootMode },
#endif
{ "HasSpell", &LuaCreature::HasSpell },
{ "HasQuest", &LuaCreature::HasQuest },
{ "HasSpellCooldown", &LuaCreature::HasSpellCooldown },
@@ -918,11 +821,9 @@ ElunaRegister<Creature> CreatureMethods[] =
{ "DespawnOrUnsummon", &LuaCreature::DespawnOrUnsummon },
{ "Respawn", &LuaCreature::Respawn },
{ "AttackStart", &LuaCreature::AttackStart },
#if defined(TRINITY) || AZEROTHCORE
{ "AddLootMode", &LuaCreature::AddLootMode },
{ "ResetLootMode", &LuaCreature::ResetLootMode },
{ "RemoveLootMode", &LuaCreature::RemoveLootMode },
#endif
{ "SaveToDB", &LuaCreature::SaveToDB },
{ "SelectVictim", &LuaCreature::SelectVictim },
{ "MoveWaypoint", &LuaCreature::MoveWaypoint },
@@ -990,13 +891,9 @@ ElunaRegister<Item> ItemMethods[] =
{ "GetAllowableRace", &LuaItem::GetAllowableRace },
{ "GetItemLevel", &LuaItem::GetItemLevel },
{ "GetRequiredLevel", &LuaItem::GetRequiredLevel },
#ifdef WOTLK
{ "GetStatsCount", &LuaItem::GetStatsCount },
#endif
{ "GetRandomProperty", &LuaItem::GetRandomProperty },
#ifndef CLASSIC
{ "GetRandomSuffix", &LuaItem::GetRandomSuffix },
#endif
{ "GetItemSet", &LuaItem::GetItemSet },
{ "GetBagSize", &LuaItem::GetBagSize },
{ "GetItemTemplate", &LuaItem::GetItemTemplate },
@@ -1008,16 +905,12 @@ ElunaRegister<Item> ItemMethods[] =
// Boolean
{ "IsSoulBound", &LuaItem::IsSoulBound },
#if (!defined(TBC) && !defined(CLASSIC))
{ "IsBoundAccountWide", &LuaItem::IsBoundAccountWide },
#endif
{ "IsBoundByEnchant", &LuaItem::IsBoundByEnchant },
{ "IsNotBoundToPlayer", &LuaItem::IsNotBoundToPlayer },
{ "IsLocked", &LuaItem::IsLocked },
{ "IsBag", &LuaItem::IsBag },
#ifndef CLASSIC
{ "IsCurrencyToken", &LuaItem::IsCurrencyToken },
#endif
{ "IsNotEmptyBag", &LuaItem::IsNotEmptyBag },
{ "IsBroken", &LuaItem::IsBroken },
{ "CanBeTraded", &LuaItem::CanBeTraded },
@@ -1026,10 +919,8 @@ ElunaRegister<Item> ItemMethods[] =
{ "IsEquipped", &LuaItem::IsEquipped },
{ "HasQuest", &LuaItem::HasQuest },
{ "IsPotion", &LuaItem::IsPotion },
#if defined(CLASSIC) || defined(TBC) || defined(WOTLK)
{ "IsWeaponVellum", &LuaItem::IsWeaponVellum },
{ "IsArmorVellum", &LuaItem::IsArmorVellum },
#endif
{ "IsConjuredConsumable", &LuaItem::IsConjuredConsumable },
//{"IsRefundExpired", &LuaItem::IsRefundExpired}, // :IsRefundExpired() - UNDOCUMENTED - Returns true if the item's refund time has expired
{ "SetEnchantment", &LuaItem::SetEnchantment },
@@ -1126,9 +1017,7 @@ ElunaRegister<Quest> QuestMethods[] =
// Boolean
{ "HasFlag", &LuaQuest::HasFlag },
#ifndef CLASSIC
{ "IsDaily", &LuaQuest::IsDaily },
#endif
{ "IsRepeatable", &LuaQuest::IsRepeatable },
{ NULL, NULL }
@@ -1187,13 +1076,9 @@ ElunaRegister<Guild> GuildMethods[] =
{ "GetMemberCount", &LuaGuild::GetMemberCount },
// Setters
#ifndef CLASSIC
{ "SetBankTabText", &LuaGuild::SetBankTabText },
#endif
{ "SetMemberRank", &LuaGuild::SetMemberRank },
#if defined(CLASSIC) || defined(TBC) || defined(WOTLK)
{ "SetLeader", &LuaGuild::SetLeader },
#endif
// Other
{ "SendPacket", &LuaGuild::SendPacket },
@@ -1205,8 +1090,6 @@ ElunaRegister<Guild> GuildMethods[] =
{ NULL, NULL }
};
#ifndef CLASSIC
#ifndef TBC
ElunaRegister<Vehicle> VehicleMethods[] =
{
// Getters
@@ -1223,8 +1106,6 @@ ElunaRegister<Vehicle> VehicleMethods[] =
{ NULL, NULL }
};
#endif
#endif
ElunaRegister<ElunaQuery> QueryMethods[] =
{
@@ -1306,15 +1187,11 @@ ElunaRegister<Map> MapMethods[] =
{ "SetWeather", &LuaMap::SetWeather },
// Boolean
#ifndef CLASSIC
{ "IsArena", &LuaMap::IsArena },
#endif
{ "IsBattleground", &LuaMap::IsBattleground },
{ "IsDungeon", &LuaMap::IsDungeon },
{ "IsEmpty", &LuaMap::IsEmpty },
#ifndef CLASSIC
{ "IsHeroic", &LuaMap::IsHeroic },
#endif
{ "IsRaid", &LuaMap::IsRaid },
// Other
@@ -1349,9 +1226,6 @@ ElunaRegister<BattleGround> 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 },
@@ -1416,7 +1290,6 @@ ElunaRegister<Roll> RollMethods[] =
{ NULL, NULL }
};
#if (!defined(TBC) && !defined(CLASSIC))
// fix compile error about accessing vehicle destructor
template<> int ElunaTemplate<Vehicle>::CollectGarbage(lua_State* L)
{
@@ -1427,7 +1300,6 @@ template<> int ElunaTemplate<Vehicle>::CollectGarbage(lua_State* L)
delete obj;
return 0;
}
#endif
// Template by Mud from http://stackoverflow.com/questions/4484437/lua-integer-type/4485511#4485511
template<> int ElunaTemplate<unsigned long long>::Add(lua_State* L) { Eluna::Push(L, Eluna::CHECKVAL<unsigned long long>(L, 1) + Eluna::CHECKVAL<unsigned long long>(L, 2)); return 1; }
@@ -1521,12 +1393,8 @@ void RegisterFunctions(Eluna* E)
ElunaTemplate<ItemTemplate>::Register(E, "ItemTemplate");
ElunaTemplate<ItemTemplate>::SetMethods(E, ItemTemplateMethods);
#ifndef CLASSIC
#ifndef TBC
ElunaTemplate<Vehicle>::Register(E, "Vehicle");
ElunaTemplate<Vehicle>::SetMethods(E, VehicleMethods);
#endif
#endif
ElunaTemplate<Group>::Register(E, "Group");
ElunaTemplate<Group>::SetMethods(E, GroupMethods);

View File

@@ -29,11 +29,7 @@ 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);

View File

@@ -301,8 +301,6 @@ bool Eluna::SpellHitTarget(Creature* me, WorldObject* target, SpellInfo const* s
return CallAllFunctionsBool(CreatureEventBindings, CreatureUniqueBindings, entry_key, unique_key);
}
#if defined TRINITY || AZEROTHCORE
bool Eluna::SummonedCreatureDies(Creature* me, Creature* summon, Unit* killer)
{
START_HOOK_WITH_RETVAL(CREATURE_EVENT_ON_SUMMONED_CREATURE_DIED, me, false);
@@ -329,5 +327,3 @@ bool Eluna::OwnerAttacked(Creature* me, Unit* target)
Push(target);
return CallAllFunctionsBool(CreatureEventBindings, CreatureUniqueBindings, entry_key, unique_key);
}
#endif // TRINITY

View File

@@ -76,8 +76,6 @@ void Eluna::GetDialogStatus(const Player* pPlayer, const GameObject* pGameObject
CallAllFunctions(GameObjectEventBindings, key);
}
#ifndef CLASSIC
#ifndef TBC
void Eluna::OnDestroyed(GameObject* pGameObject, WorldObject* attacker)
{
START_HOOK(GAMEOBJECT_EVENT_ON_DESTROYED, pGameObject->GetEntry());
@@ -93,8 +91,6 @@ void Eluna::OnDamaged(GameObject* pGameObject, WorldObject* attacker)
Push(attacker);
CallAllFunctions(GameObjectEventBindings, key);
}
#endif
#endif
void Eluna::OnLootStateChanged(GameObject* pGameObject, uint32 state)
{

View File

@@ -74,11 +74,7 @@ bool Eluna::OnUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets)
data << guid;
data << ObjectGuid(uint64(0));
data << uint8(0);
#ifdef CMANGOS
pPlayer->GetSession()->SendPacket(data);
#else
pPlayer->GetSession()->SendPacket(&data);
#endif
return false;
}
@@ -87,7 +83,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);
#if defined TRINITY || AZEROTHCORE
if (GameObject* target = targets.GetGOTarget())
Push(target);
else if (Item* target = targets.GetItemTarget())
@@ -100,18 +96,6 @@ 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);
}

View File

@@ -116,14 +116,8 @@ bool Eluna::OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* pTrigger)
{
START_HOOK_WITH_RETVAL(TRIGGER_EVENT_ON_TRIGGER, false);
Push(pPlayer);
#ifdef TRINITY
Push(pTrigger->ID);
#elif AZEROTHCORE
Push(pTrigger->entry);
#else
Push(pTrigger->id);
#endif
return CallAllFunctionsBool(ServerEventBindings, key);
}
@@ -140,22 +134,10 @@ void Eluna::OnChange(Weather* /*weather*/, uint32 zone, WeatherState state, floa
// Auction House
void Eluna::OnAdd(AuctionHouseObject* /*ah*/, AuctionEntry* entry)
{
#ifdef AZEROTHCORE
Player* owner = eObjectAccessor()FindPlayer(entry->owner);
#else
Player* owner = eObjectAccessor()FindPlayer(MAKE_NEW_GUID(entry->owner, 0, HIGHGUID_PLAYER));
#endif
#ifdef TRINITY
Item* item = eAuctionMgr->GetAItem(entry->itemGUIDLow);
uint32 expiretime = entry->expire_time;
#elif AZEROTHCORE
Item* item = eAuctionMgr->GetAItem(entry->item_guid);
uint32 expiretime = entry->expire_time;
#else
Item* item = eAuctionMgr->GetAItem(entry->itemGuidLow);
uint32 expiretime = entry->expireTime;
#endif
if (!owner || !item)
return;
@@ -174,23 +156,10 @@ void Eluna::OnAdd(AuctionHouseObject* /*ah*/, AuctionEntry* entry)
void Eluna::OnRemove(AuctionHouseObject* /*ah*/, AuctionEntry* entry)
{
#ifdef AZEROTHCORE
Player* owner = eObjectAccessor()FindPlayer(entry->owner);
#else
Player* owner = eObjectAccessor()FindPlayer(MAKE_NEW_GUID(entry->owner, 0, HIGHGUID_PLAYER));
#endif
#ifdef TRINITY
Item* item = eAuctionMgr->GetAItem(entry->itemGUIDLow);
uint32 expiretime = entry->expire_time;
#elif AZEROTHCORE
Item* item = eAuctionMgr->GetAItem(entry->item_guid);
uint32 expiretime = entry->expire_time;
#else
Item* item = eAuctionMgr->GetAItem(entry->itemGuidLow);
uint32 expiretime = entry->expireTime;
#endif
if (!owner || !item)
return;
@@ -209,23 +178,10 @@ void Eluna::OnRemove(AuctionHouseObject* /*ah*/, AuctionEntry* entry)
void Eluna::OnSuccessful(AuctionHouseObject* /*ah*/, AuctionEntry* entry)
{
#ifdef AZEROTHCORE
Player* owner = eObjectAccessor()FindPlayer(entry->owner);
#else
Player* owner = eObjectAccessor()FindPlayer(MAKE_NEW_GUID(entry->owner, 0, HIGHGUID_PLAYER));
#endif
#ifdef TRINITY
Item* item = eAuctionMgr->GetAItem(entry->itemGUIDLow);
uint32 expiretime = entry->expire_time;
#elif AZEROTHCORE
Item* item = eAuctionMgr->GetAItem(entry->item_guid);
uint32 expiretime = entry->expire_time;
#else
Item* item = eAuctionMgr->GetAItem(entry->itemGuidLow);
uint32 expiretime = entry->expireTime;
#endif
if (!owner || !item)
return;
@@ -244,23 +200,10 @@ void Eluna::OnSuccessful(AuctionHouseObject* /*ah*/, AuctionEntry* entry)
void Eluna::OnExpire(AuctionHouseObject* /*ah*/, AuctionEntry* entry)
{
#ifdef AZEROTHCORE
Player* owner = eObjectAccessor()FindPlayer(entry->owner);
#else
Player* owner = eObjectAccessor()FindPlayer(MAKE_NEW_GUID(entry->owner, 0, HIGHGUID_PLAYER));
#endif
#ifdef TRINITY
Item* item = eAuctionMgr->GetAItem(entry->itemGUIDLow);
uint32 expiretime = entry->expire_time;
#elif AZEROTHCORE
Item* item = eAuctionMgr->GetAItem(entry->item_guid);
uint32 expiretime = entry->expire_time;
#else
Item* item = eAuctionMgr->GetAItem(entry->itemGuidLow);
uint32 expiretime = entry->expireTime;
#endif
if (!owner || !item)
return;
@@ -284,17 +227,11 @@ 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);
}

View File

@@ -10,9 +10,6 @@
#include "BindingMap.h"
#include "ElunaTemplate.h"
#ifndef CLASSIC
#ifndef TBC
using namespace Hooks;
#define START_HOOK(EVENT) \
@@ -61,6 +58,3 @@ void Eluna::OnRemovePassenger(Vehicle* vehicle, Unit* passenger)
Push(passenger);
CallAllFunctions(VehicleEventBindings, key);
}
#endif // CLASSIC
#endif // TBC

View File

@@ -39,11 +39,7 @@ namespace LuaAura
*/
int GetCasterGUID(lua_State* L, Aura* aura)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, aura->GetCasterGUID());
#else
Eluna::Push(L, aura->GetCasterGuid());
#endif
return 1;
}
@@ -65,11 +61,7 @@ namespace LuaAura
*/
int GetDuration(lua_State* L, Aura* aura)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, aura->GetDuration());
#else
Eluna::Push(L, aura->GetAuraDuration());
#endif
return 1;
}
@@ -94,11 +86,7 @@ namespace LuaAura
*/
int GetMaxDuration(lua_State* L, Aura* aura)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, aura->GetMaxDuration());
#else
Eluna::Push(L, aura->GetAuraMaxDuration());
#endif
return 1;
}
@@ -122,11 +110,7 @@ namespace LuaAura
*/
int GetOwner(lua_State* L, Aura* aura)
{
#if defined TRINITY || defined AZEROTHCORE
Eluna::Push(L, aura->GetOwner());
#else
Eluna::Push(L, aura->GetTarget());
#endif
return 1;
}
@@ -138,16 +122,7 @@ namespace LuaAura
int SetDuration(lua_State* L, Aura* aura)
{
int32 duration = Eluna::CHECKVAL<int32>(L, 2);
#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
#endif
return 0;
}
@@ -162,16 +137,7 @@ namespace LuaAura
int SetMaxDuration(lua_State* L, Aura* aura)
{
int32 duration = Eluna::CHECKVAL<int32>(L, 2);
#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
#endif
return 0;
}
@@ -186,11 +152,7 @@ namespace LuaAura
int SetStackAmount(lua_State* L, Aura* aura)
{
uint8 amount = Eluna::CHECKVAL<uint8>(L, 2);
#if defined TRINITY || defined AZEROTHCORE
aura->SetStackAmount(amount);
#else
aura->GetHolder()->SetStackAmount(amount);
#endif
return 0;
}
@@ -199,11 +161,7 @@ namespace LuaAura
*/
int Remove(lua_State* L, Aura* aura)
{
#if defined TRINITY || defined AZEROTHCORE
aura->Remove();
#else
aura->GetTarget()->RemoveSpellAuraHolder(aura->GetHolder(), AURA_REMOVE_BY_CANCEL);
#endif
Eluna::CHECKOBJ<ElunaObject>(L, 1)->Invalidate();
return 0;
}

View File

@@ -35,11 +35,7 @@ namespace LuaBattleGround
{
uint32 team = Eluna::CHECKVAL<uint32>(L, 2);
#ifndef AZEROTHCORE
Eluna::Push(L, bg->GetAlivePlayersCountByTeam((Team)team));
#else
Eluna::Push(L, bg->GetAlivePlayersCountByTeam((TeamId)team));
#endif
return 1;
}
@@ -68,19 +64,6 @@ namespace LuaBattleGround
return 1;
}
#ifndef AZEROTHCORE
/**
* Returns the bracket ID of the specific [BattleGround].
*
* @return [BattleGroundBracketId] bracketId
*/
int GetBracketId(lua_State* L, BattleGround* bg)
{
Eluna::Push(L, bg->GetBracketId());
return 1;
}
#endif
/**
* Returns the end time of the [BattleGround].
*
@@ -88,11 +71,7 @@ namespace LuaBattleGround
*/
int GetEndTime(lua_State* L, BattleGround* bg)
{
#ifdef CATA
Eluna::Push(L, bg->GetRemainingTime());
#else
Eluna::Push(L, bg->GetEndTime());
#endif
return 1;
}
@@ -106,11 +85,7 @@ namespace LuaBattleGround
{
uint32 team = Eluna::CHECKVAL<uint32>(L, 2);
#ifndef AZEROTHCORE
Eluna::Push(L, bg->GetFreeSlotsForTeam((Team)team));
#else
Eluna::Push(L, bg->GetFreeSlotsForTeam((TeamId)team));
#endif
return 1;
}
@@ -143,11 +118,7 @@ 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;
}
@@ -180,11 +151,7 @@ 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;
}
@@ -195,11 +162,7 @@ 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;
}

View File

@@ -21,11 +21,7 @@ namespace LuaCorpse
*/
int GetOwnerGUID(lua_State* L, Corpse* corpse)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, corpse->GetOwnerGUID());
#else
Eluna::Push(L, corpse->GetOwnerGuid());
#endif
return 1;
}

View File

@@ -22,17 +22,10 @@ namespace LuaCreature
*/
int IsRegeneratingHealth(lua_State* L, Creature* creature)
{
#if defined(AZEROTHCORE)
Eluna::Push(L, creature->isRegeneratingHealth());
#elif defined(TRINITY)
Eluna::Push(L, creature->CanRegenerateHealth());
#else
Eluna::Push(L, creature->IsRegeneratingHealth());
#endif
return 1;
}
#if defined(TRINITY) || defined(AZEROTHCORE)
/**
* Sets whether the [Creature] can regenerate health or not.
*
@@ -42,14 +35,9 @@ namespace LuaCreature
{
bool enable = Eluna::CHECKVAL<bool>(L, 2, true);
#if defined(AZEROTHCORE)
creature->SetRegeneratingHealth(enable);
#else
creature->SetRegenerateHealth(enable);
#endif
return 0;
}
#endif
/**
* Returns `true` if the [Creature] is set to not give reputation when killed,
@@ -74,11 +62,7 @@ namespace LuaCreature
{
uint32 quest_id = Eluna::CHECKVAL<uint32>(L, 2);
#if defined(TRINITY) || defined(AZEROTHCORE)
Eluna::Push(L, creature->hasInvolvedQuest(quest_id));
#else
Eluna::Push(L, creature->HasInvolvedQuest(quest_id));
#endif
return 1;
}
@@ -93,11 +77,7 @@ namespace LuaCreature
{
bool mustBeDead = Eluna::CHECKVAL<bool>(L, 2, false);
#ifdef MANGOS
Eluna::Push(L, creature->IsTargetableForAttack(mustBeDead));
#else
Eluna::Push(L, creature->isTargetableForAttack(mustBeDead));
#endif
return 1;
}
@@ -142,11 +122,7 @@ namespace LuaCreature
{
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
#if defined(TRINITY) || defined(AZEROTHCORE)
Eluna::Push(L, creature->isTappedBy(player));
#else
Eluna::Push(L, creature->IsTappedBy(player));
#endif
return 1;
}
@@ -158,11 +134,7 @@ namespace LuaCreature
*/
int HasLootRecipient(lua_State* L, Creature* creature)
{
#if defined(TRINITY) || defined(AZEROTHCORE)
Eluna::Push(L, creature->hasLootRecipient());
#else
Eluna::Push(L, creature->HasLootRecipient());
#endif
return 1;
}
@@ -174,12 +146,7 @@ namespace LuaCreature
*/
int CanAggro(lua_State* L, Creature* creature)
{
#if defined(TRINITY) || defined(AZEROTHCORE)
Eluna::Push(L, !creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC));
#else
// Eluna::Push(L, creature->CanInitiateAttack());
Eluna::Push(L, !creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE));
#endif
return 1;
}
@@ -227,11 +194,7 @@ namespace LuaCreature
*/
int IsElite(lua_State* L, Creature* creature)
{
#if defined(TRINITY) || defined(AZEROTHCORE)
Eluna::Push(L, creature->isElite());
#else
Eluna::Push(L, creature->IsElite());
#endif
return 1;
}
@@ -277,13 +240,11 @@ namespace LuaCreature
*
* @return bool isDungeonBoss
*/
#if defined(TRINITY) || defined(AZEROTHCORE)
int IsDungeonBoss(lua_State* L, Creature* creature)
{
Eluna::Push(L, creature->IsDungeonBoss());
return 1;
}
#endif
/**
* Returns `true` if the [Creature]'s rank is Boss,
@@ -293,11 +254,7 @@ namespace LuaCreature
*/
int IsWorldBoss(lua_State* L, Creature* creature)
{
#if defined(TRINITY) || defined(AZEROTHCORE)
Eluna::Push(L, creature->isWorldBoss());
#else
Eluna::Push(L, creature->IsWorldBoss());
#endif
return 1;
}
@@ -312,19 +269,10 @@ namespace LuaCreature
{
uint32 spell = Eluna::CHECKVAL<uint32>(L, 2);
#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 defined(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
return 1;
}
@@ -354,11 +302,7 @@ namespace LuaCreature
{
uint32 questId = Eluna::CHECKVAL<uint32>(L, 2);
#if defined(TRINITY) || defined(AZEROTHCORE)
Eluna::Push(L, creature->hasQuest(questId));
#else
Eluna::Push(L, creature->HasQuest(questId));
#endif
return 1;
}
@@ -373,11 +317,7 @@ namespace LuaCreature
{
uint32 spellId = Eluna::CHECKVAL<uint32>(L, 2);
#if defined(TRINITY)
Eluna::Push(L, creature->GetSpellHistory()->HasCooldown(spellId));
#else
Eluna::Push(L, creature->HasSpellCooldown(spellId));
#endif
return 1;
}
@@ -393,7 +333,6 @@ namespace LuaCreature
return 1;
}
#if defined(TRINITY) || defined(AZEROTHCORE)
/**
* Returns `true` if the [Creature] is an invisible trigger,
* and returns `false` otherwise.
@@ -428,12 +367,8 @@ namespace LuaCreature
int CanStartAttack(lua_State* L, Creature* creature) // TODO: Implement core side
{
Unit* target = Eluna::CHECKOBJ<Unit>(L, 2);
#ifndef AZEROTHCORE
bool force = Eluna::CHECKVAL<bool>(L, 3, true);
Eluna::Push(L, creature->CanStartAttack(target, force));
#else
Eluna::Push(L, creature->CanStartAttack(target));
#endif
return 1;
}
@@ -450,7 +385,6 @@ namespace LuaCreature
Eluna::Push(L, creature->HasLootMode(lootMode));
return 1;
}
#endif
/**
* Returns the time it takes for this [Creature] to respawn once killed.
@@ -474,15 +408,10 @@ namespace LuaCreature
*/
int GetWanderRadius(lua_State* L, Creature* creature)
{
#if defined(TRINITY) || defined(AZEROTHCORE)
Eluna::Push(L, creature->GetWanderDistance());
#else
Eluna::Push(L, creature->GetRespawnRadius());
#endif
return 1;
}
#if defined(TRINITY) || defined(AZEROTHCORE)
/**
* Returns the current waypoint path ID of the [Creature].
*
@@ -493,7 +422,6 @@ namespace LuaCreature
Eluna::Push(L, creature->GetWaypointPath());
return 1;
}
#endif
/**
* Returns the current waypoint ID of the [Creature].
@@ -502,13 +430,7 @@ namespace LuaCreature
*/
int GetCurrentWaypointId(lua_State* L, Creature* creature)
{
#if defined(TRINITY)
Eluna::Push(L, creature->GetCurrentWaypointInfo().first);
#elif defined(AZEROTHCORE)
Eluna::Push(L, creature->GetCurrentWaypointID());
#else
Eluna::Push(L, creature->GetMotionMaster()->getLastReachedWaypoint());
#endif
return 1;
}
@@ -533,35 +455,10 @@ namespace LuaCreature
{
Unit* target = Eluna::CHECKOBJ<Unit>(L, 2);
#if defined(TRINITY) || defined(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);
#endif
return 1;
}
#ifndef AZEROTHCORE
/**
* Returns the effective aggro range of the [Creature] for `target`.
*
* If this is smaller than the minimum aggro range set in the config file,
* that is used as the aggro range instead.
*
* @param [Unit] target
* @return float attackDistance
*/
int GetAttackDistance(lua_State* L, Creature* creature)
{
Unit* target = Eluna::CHECKOBJ<Unit>(L, 2);
Eluna::Push(L, creature->GetAttackDistance(target));
return 1;
}
#endif
/**
* Returns the [Group] that can loot this [Creature].
*
@@ -569,11 +466,7 @@ namespace LuaCreature
*/
int GetLootRecipientGroup(lua_State* L, Creature* creature)
{
#if defined(TRINITY) || defined(AZEROTHCORE)
Eluna::Push(L, creature->GetLootRecipientGroup());
#else
Eluna::Push(L, creature->GetGroupLootRecipient());
#endif
return 1;
}
@@ -642,19 +535,11 @@ namespace LuaCreature
{
uint32 spell = Eluna::CHECKVAL<uint32>(L, 2);
#if defined(TRINITY)
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell))
Eluna::Push(L, creature->GetSpellHistory()->GetRemainingCooldown(spellInfo));
else
Eluna::Push(L, 0);
#elif defined(AZEROTHCORE)
if (sSpellMgr->GetSpellInfo(spell))
Eluna::Push(L, creature->GetSpellCooldown(spell));
else
Eluna::Push(L, 0);
#else
Eluna::Push(L, creature->GetCreatureSpellCooldownDelay(spell));
#endif
return 1;
}
@@ -681,11 +566,7 @@ namespace LuaCreature
int GetHomePosition(lua_State* L, Creature* creature)
{
float x, y, z, o;
#if defined(TRINITY) || defined(AZEROTHCORE)
creature->GetHomePosition(x, y, z, o);
#else
creature->GetRespawnCoord(x, y, z, &o);
#endif
Eluna::Push(L, x);
Eluna::Push(L, y);
@@ -710,12 +591,7 @@ namespace LuaCreature
float z = Eluna::CHECKVAL<float>(L, 4);
float o = Eluna::CHECKVAL<float>(L, 5);
#if defined(TRINITY) || defined(AZEROTHCORE)
creature->SetHomePosition(x, y, z, o);
#else
creature->SetRespawnCoord(x, y, z, o);
#endif
return 0;
}
@@ -762,33 +638,19 @@ namespace LuaCreature
float dist = Eluna::CHECKVAL<float>(L, 5, 0.0f);
int32 aura = Eluna::CHECKVAL<int32>(L, 6, 0);
#if defined(CMANGOS)
ThreatList const& threatlist = creature->getThreatManager().getThreatList();
#elif defined(MANGOS)
ThreatList const& threatlist = creature->GetThreatManager().getThreatList();
#elif defined(TRINITY)
auto const& threatlist = creature->GetThreatManager().GetSortedThreatList();
#elif defined(AZEROTHCORE)
auto const& threatlist = creature->GetThreatMgr().GetThreatList();
#endif
#ifndef TRINITY
if (threatlist.empty())
return 1;
if (position >= threatlist.size())
return 1;
#endif
std::list<Unit*> targetList;
#if defined(TRINITY)
for (ThreatReference const* itr : threatlist)
#else
for (auto itr = threatlist.begin(); itr != threatlist.end(); ++itr)
#endif
{
#if defined(TRINITY)
Unit* target = itr->GetVictim();
#else
{
Unit* target = (*itr)->getTarget();
#endif
if (!target)
continue;
if (playerOnly && target->GetTypeId() != TYPEID_PLAYER)
@@ -857,25 +719,18 @@ namespace LuaCreature
*/
int GetAITargets(lua_State* L, Creature* creature)
{
#if defined(TRINITY)
auto const& threatlist = creature->GetThreatManager().GetThreatenedByMeList();
#elif defined(AZEROTHCORE)
auto const& threatlist = creature->GetThreatMgr().GetThreatList();
#else
ThreatList const& threatlist = creature->GetThreatManager().getThreatList();
#endif
auto const& threatlist = creature->GetThreatMgr().GetThreatList();
lua_createtable(L, threatlist.size(), 0);
int tbl = lua_gettop(L);
uint32 i = 0;
for (auto itr = threatlist.begin(); itr != threatlist.end(); ++itr)
{
#if defined(TRINITY)
Unit* target = itr->second->GetOwner();
#else
Unit* target = (*itr)->getTarget();
#endif
if (!target)
continue;
Eluna::Push(L, target);
lua_rawseti(L, tbl, ++i);
}
@@ -891,13 +746,7 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
*/
int GetAITargetsCount(lua_State* L, Creature* creature)
{
#if defined(TRINITY)
Eluna::Push(L, creature->GetThreatManager().GetThreatenedByMeList().size());
#elif defined(AZEROTHCORE)
Eluna::Push(L, creature->GetThreatMgr().GetThreatListSize());
#else
Eluna::Push(L, creature->GetThreatManager().getThreatList().size());
#endif
return 1;
}
@@ -949,11 +798,7 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
*/
int GetExtraFlags(lua_State* L, Creature* creature)
{
#if defined(TRINITY) || defined(AZEROTHCORE)
Eluna::Push(L, creature->GetCreatureTemplate()->flags_extra);
#else
Eluna::Push(L, creature->GetCreatureInfo()->ExtraFlags);
#endif
return 1;
}
@@ -968,7 +813,6 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
return 1;
}
#if defined(CLASSIC) || defined(TBC) || defined(WOTLK)
/**
* Returns the [Creature]'s shield block value.
*
@@ -979,15 +823,12 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
Eluna::Push(L, creature->GetShieldBlockValue());
return 1;
}
#endif
#if defined(TRINITY) || defined(AZEROTHCORE)
int GetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features
{
Eluna::Push(L, creature->GetLootMode());
return 1;
}
#endif
/**
* Returns the guid of the [Creature] that is used as the ID in the database
@@ -996,12 +837,7 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
*/
int GetDBTableGUIDLow(lua_State* L, Creature* creature)
{
#if defined(TRINITY) || defined(AZEROTHCORE)
Eluna::Push(L, creature->GetSpawnId());
#else
// on mangos based this is same as lowguid
Eluna::Push(L, creature->GetGUIDLow());
#endif
return 1;
}
@@ -1042,7 +878,6 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
return 0;
}
#if defined(TRINITY) || defined(AZEROTHCORE)
/**
* Sets the [Creature]'s ReactState to `state`.
*
@@ -1055,7 +890,6 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
creature->SetReactState((ReactStates)state);
return 0;
}
#endif
/**
* Makes the [Creature] able to fly if enabled.
@@ -1066,15 +900,10 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
{
bool disable = Eluna::CHECKVAL<bool>(L, 2);
#if defined(TRINITY) || defined(AZEROTHCORE)
creature->SetDisableGravity(disable);
#else
creature->SetLevitate(disable);
#endif
return 0;
}
#if defined(TRINITY) || defined(AZEROTHCORE)
int SetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features
{
uint16 lootMode = Eluna::CHECKVAL<uint16>(L, 2);
@@ -1082,7 +911,6 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
creature->SetLootMode(lootMode);
return 0;
}
#endif
/**
* Sets the [Creature]'s death state to `deathState`.
@@ -1093,11 +921,7 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
{
int32 state = Eluna::CHECKVAL<int32>(L, 2);
#if defined(TRINITY) || defined(AZEROTHCORE)
creature->setDeathState((DeathState)state);
#else
creature->SetDeathState((DeathState)state);
#endif
return 0;
}
@@ -1127,15 +951,10 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
uint32 off_hand = Eluna::CHECKVAL<uint32>(L, 3);
uint32 ranged = Eluna::CHECKVAL<uint32>(L, 4);
#if defined(TRINITY) || defined(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);
#else
creature->SetVirtualItem(VIRTUAL_ITEM_SLOT_0, main_hand);
creature->SetVirtualItem(VIRTUAL_ITEM_SLOT_1, off_hand);
creature->SetVirtualItem(VIRTUAL_ITEM_SLOT_2, ranged);
#endif
return 0;
}
@@ -1148,17 +967,10 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
{
bool allow = Eluna::CHECKVAL<bool>(L, 2, true);
#if defined(TRINITY) || defined(AZEROTHCORE)
if (allow)
creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC);
else
creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC);
#else
if (allow)
creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE);
else
creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE);
#endif
return 0;
}
@@ -1184,15 +996,9 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
*/
int SetInCombatWithZone(lua_State* /*L*/, Creature* creature)
{
#if defined(AZEROTHCORE)
if (creature->IsAIEnabled)
creature->AI()->DoZoneInCombat();
#elif defined(TRINITY)
if (creature->IsAIEnabled())
creature->AI()->DoZoneInCombat();
#else
creature->SetInCombatWithZone();
#endif
return 0;
}
@@ -1205,11 +1011,8 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
{
float dist = Eluna::CHECKVAL<float>(L, 2);
#if defined(TRINITY) || defined(AZEROTHCORE)
creature->SetWanderDistance(dist);
#else
creature->SetRespawnRadius(dist);
#endif
return 0;
}
@@ -1274,24 +1077,8 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
{
bool enable = Eluna::CHECKVAL<bool>(L, 2, true);
#if defined(TRINITY) || defined(AZEROTHCORE)
creature->SetHover(enable);
#else
// Copy paste from Aura::HandleAuraHover
// TODO: implement core side properly
WorldPacket data;
if (enable)
data.Initialize(SMSG_MOVE_SET_HOVER, 8 + 4);
else
data.Initialize(SMSG_MOVE_UNSET_HOVER, 8 + 4);
data << creature->GetPackGUID();
data << uint32(0);
#if defined(CMANGOS)
creature->SendMessageToSet(data, true);
#else
creature->SendMessageToSet(&data, true);
#endif
#endif
return 0;
}
@@ -1303,14 +1090,8 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
int DespawnOrUnsummon(lua_State* L, Creature* creature)
{
uint32 msTimeToDespawn = Eluna::CHECKVAL<uint32>(L, 2, 0);
#if defined(TRINITY)
creature->DespawnOrUnsummon(Milliseconds(msTimeToDespawn));
#elif defined(AZEROTHCORE)
creature->DespawnOrUnsummon(msTimeToDespawn);
#else
creature->ForcedDespawn(msTimeToDespawn);
#endif
return 0;
}
@@ -1337,11 +1118,8 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
*/
int MoveWaypoint(lua_State* /*L*/, Creature* creature)
{
#if defined(TRINITY) || defined(AZEROTHCORE)
creature->GetMotionMaster()->MovePath(creature->GetWaypointPath(), true);
#else
creature->GetMotionMaster()->MoveWaypoint();
#endif
return 0;
}
@@ -1405,11 +1183,7 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
*/
int SelectVictim(lua_State* L, Creature* creature)
{
#if defined(TRINITY) || defined(AZEROTHCORE)
Eluna::Push(L, creature->SelectVictim());
#else
Eluna::Push(L, creature->SelectHostileTarget());
#endif
return 1;
}
@@ -1424,15 +1198,10 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);
uint32 dataGuidLow = Eluna::CHECKVAL<uint32>(L, 3, 0);
#if defined(TRINITY) || defined(AZEROTHCORE)
creature->UpdateEntry(entry, dataGuidLow ? eObjectMgr->GetCreatureData(dataGuidLow) : NULL);
#else
creature->UpdateEntry(entry, ALLIANCE, dataGuidLow ? eObjectMgr->GetCreatureData(dataGuidLow) : NULL);
#endif
return 0;
}
#if defined(TRINITY) || defined(AZEROTHCORE)
/**
* Resets [Creature]'s loot mode to default
*/
@@ -1467,7 +1236,6 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
creature->AddLootMode(lootMode);
return 0;
}
#endif
/**
* Returns the [Creature]'s creature family ID (enumerated in CreatureFamily.dbc).
@@ -1527,15 +1295,10 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
{
uint32 entry = creature->GetEntry();
#if defined(TRINITY) || defined(AZEROTHCORE)
CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(entry);
if (cInfo)
Eluna::Push(L, cInfo->family);
#else
CreatureInfo const* cInfo = ObjectMgr::GetCreatureTemplate(entry);
if (cInfo)
Eluna::Push(L, cInfo->Family);
#endif
return 1;
}
};

View File

@@ -7,11 +7,7 @@
#ifndef QUERYMETHODS_H
#define QUERYMETHODS_H
#if defined TRINITY || defined AZEROTHCORE
#define RESULT (*result)
#else
#define RESULT result
#endif
/***
* The result of a database query.
@@ -45,11 +41,7 @@ namespace LuaQuery
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
CheckFields(L, result);
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, RESULT->Fetch()[col].IsNull());
#else
Eluna::Push(L, RESULT->Fetch()[col].IsNULL());
#endif
return 1;
}
@@ -286,13 +278,8 @@ namespace LuaQuery
lua_createtable(L, 0, col);
int tbl = lua_gettop(L);
#if !defined TRINITY && !AZEROTHCORE
const QueryFieldNames& names = RESULT->GetFieldNames();
#endif
for (uint32 i = 0; i < col; ++i)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, RESULT->GetFieldName(i));
std::string _str = row[i].Get<std::string>();
@@ -304,50 +291,12 @@ namespace LuaQuery
// MYSQL_TYPE_LONGLONG Interpreted as string for lua
switch (row[i].GetType())
{
#if defined TRINITY || 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:
Eluna::Push(L, str);
break;
}
}
#else
Eluna::Push(L, names[i]);
const char* str = row[i].GetString();
if (row[i].IsNULL() || !str)
Eluna::Push(L);
else
{
// MYSQL_TYPE_LONGLONG Interpreted as string for lua
switch (row[i].GetType())
{
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_INT24:
case MYSQL_TYPE_LONG:
case MYSQL_TYPE_FLOAT:
case MYSQL_TYPE_DOUBLE:
Eluna::Push(L, strtod(str, NULL));
break;
default:
@@ -355,8 +304,6 @@ namespace LuaQuery
break;
}
}
#endif
lua_rawset(L, tbl);
}

View File

@@ -22,11 +22,7 @@ namespace LuaGameObject
{
uint32 questId = Eluna::CHECKVAL<uint32>(L, 2);
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, go->hasQuest(questId));
#else
Eluna::Push(L, go->HasQuest(questId));
#endif
return 1;
}
@@ -145,11 +141,7 @@ namespace LuaGameObject
*/
int GetLootRecipientGroup(lua_State* L, GameObject* go)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, go->GetLootRecipientGroup());
#else
Eluna::Push(L, go->GetGroupLootRecipient());
#endif
return 1;
}
@@ -160,12 +152,7 @@ namespace LuaGameObject
*/
int GetDBTableGUIDLow(lua_State* L, GameObject* go)
{
#if defined(TRINITY) || defined(AZEROTHCORE)
Eluna::Push(L, go->GetSpawnId());
#else
// on mangos based this is same as lowguid
Eluna::Push(L, go->GetGUIDLow());
#endif
return 1;
}
@@ -192,13 +179,7 @@ namespace LuaGameObject
else if (state == 1)
go->SetGoState(GO_STATE_READY);
else if (state == 2)
{
#ifdef TRINITY
go->SetGoState(GO_STATE_DESTROYED);
#else
go->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE);
#endif
}
return 0;
}
@@ -249,20 +230,15 @@ namespace LuaGameObject
int i = 1;
int argAmount = lua_gettop(L);
#if defined TRINITY || defined AZEROTHCORE
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
#endif
uint8 addedItems = 0;
while (i + 2 <= argAmount)
{
uint32 entry = Eluna::CHECKVAL<uint32>(L, ++i);
uint32 amount = Eluna::CHECKVAL<uint32>(L, ++i);
#if defined TRINITY || AZEROTHCORE
ItemTemplate const* item_proto = eObjectMgr->GetItemTemplate(entry);
#else
ItemTemplate const* item_proto = ObjectMgr::GetItemPrototype(entry);
#endif
if (!item_proto)
{
luaL_error(L, "Item entry %d does not exist", entry);
@@ -275,25 +251,15 @@ namespace LuaGameObject
}
if (Item* item = Item::CreateItem(entry, amount))
{
#if defined TRINITY || AZEROTHCORE
item->SaveToDB(trans);
#else
item->SaveToDB();
#endif
LootStoreItem storeItem(item->GetEntry(), 0, 100, 0, LOOT_MODE_DEFAULT, 0, item->GetCount(), item->GetCount());
go->loot.AddItem(storeItem);
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, item->GetGUID().GetCounter());
#else
Eluna::Push(L, item->GetGUIDLow());
#endif
++addedItems;
}
}
#if defined TRINITY || AZEROTHCORE
CharacterDatabase.CommitTransaction(trans);
#endif
return addedItems;
}
@@ -320,11 +286,7 @@ namespace LuaGameObject
bool deldb = Eluna::CHECKVAL<bool>(L, 2, false);
// cs_gobject.cpp copy paste
#if defined TRINITY || AZEROTHCORE
ObjectGuid ownerGuid = go->GetOwnerGUID();
#else
ObjectGuid ownerGuid = go->GetOwnerGuid();
#endif
if (ownerGuid)
{
Unit* owner = eObjectAccessor()GetUnit(*go, ownerGuid);
@@ -335,13 +297,7 @@ namespace LuaGameObject
}
if (deldb)
{
#ifdef TRINITY
GameObject::DeleteFromDB(go->GetSpawnId());
#else
go->DeleteFromDB();
#endif
}
go->SetRespawnTime(0);
go->Delete();

View File

@@ -9,8 +9,6 @@
#include "BindingMap.h"
#ifdef AZEROTHCORE
#include "BanMgr.h"
#include "GameTime.h"
#include "SharedDefines.h"
@@ -24,8 +22,6 @@ enum BanMode
BAN_IP = 3
};
#endif
/***
* These functions can be used anywhere at any time, including at start-up.
*/
@@ -67,13 +63,7 @@ namespace LuaGlobalFunctions
int GetRealmID(lua_State* L)
{
#ifdef MANGOS
Eluna::Push(L, realmID);
#elif defined(AZEROTHCORE)
Eluna::Push(L, sConfigMgr->GetOption<uint32>("RealmID", 1));
#else
Eluna::Push(L, sConfigMgr->GetIntDefault("RealmID", 1));
#endif
return 1;
}
@@ -101,15 +91,7 @@ namespace LuaGlobalFunctions
*/
int GetCoreExpansion(lua_State* L)
{
#ifdef CLASSIC
Eluna::Push(L, 0);
#elif defined(TBC)
Eluna::Push(L, 1);
#elif defined(WOTLK)
Eluna::Push(L, 2);
#elif defined(CATA)
Eluna::Push(L, 3);
#endif
return 1;
}
@@ -196,13 +178,7 @@ namespace LuaGlobalFunctions
*/
int GetGameTime(lua_State* L)
{
#ifdef TRINITY
Eluna::Push(L, GameTime::GetGameTime());
#elif AZEROTHCORE
Eluna::Push(L, GameTime::GetGameTime().count());
#else
Eluna::Push(L, eWorld->GetGameTime());
#endif
return 1;
}
@@ -231,24 +207,8 @@ namespace LuaGlobalFunctions
int tbl = lua_gettop(L);
uint32 i = 0;
#if defined(MANGOS)
eObjectAccessor()DoForAllPlayers([&](Player* player){
if(player->IsInWorld())
{
if ((team == TEAM_NEUTRAL || player->GetTeamId() == team) && (!onlyGM || player->isGameMaster()))
{
Eluna::Push(L, player);
lua_rawseti(L, tbl, ++i);
}
}
});
#else
{
#if defined TRINITY || AZEROTHCORE
std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
#else
HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock());
#endif
const HashMapHolder<Player>::MapType& m = eObjectAccessor()GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator it = m.begin(); it != m.end(); ++it)
{
@@ -256,11 +216,8 @@ namespace LuaGlobalFunctions
{
if (!player->IsInWorld())
continue;
#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);
lua_rawseti(L, tbl, ++i);
@@ -268,7 +225,7 @@ namespace LuaGlobalFunctions
}
}
}
#endif
lua_settop(L, tbl); // push table to top of stack
return 1;
}
@@ -470,9 +427,7 @@ namespace LuaGlobalFunctions
std::ostringstream oss;
oss << "|c" << std::hex << ItemQualityColors[temp->Quality] << std::dec <<
"|Hitem:" << entry << ":0:" <<
#ifndef CLASSIC
"0:0:0:0:" <<
#endif
"0:0:0:0|h[" << name << "]|h|r";
Eluna::Push(L, oss.str());
@@ -538,19 +493,12 @@ namespace LuaGlobalFunctions
if (locale >= TOTAL_LOCALES)
return luaL_argerror(L, 2, "valid LocaleConstant expected");
#if defined TRINITY || AZEROTHCORE
AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaOrZoneId);
#else
AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaOrZoneId);
#endif
if (!areaEntry)
return luaL_argerror(L, 1, "valid Area or Zone ID expected");
#if defined(TRINITY)
Eluna::Push(L, areaEntry->AreaName[locale]);
#else
Eluna::Push(L, areaEntry->area_name[locale]);
#endif
return 1;
}
@@ -1284,16 +1232,14 @@ namespace LuaGlobalFunctions
int RunCommand(lua_State* L)
{
const char* command = Eluna::CHECKVAL<const char*>(L, 1);
#if defined TRINITY || AZEROTHCORE
eWorld->QueueCliCommand(new CliCommandHolder(nullptr, command, [](void*, std::string_view view)
{
std::string str = { view.begin(), view.end() };
str.erase(std::find_if(str.rbegin(), str.rend(), [](unsigned char ch) { return !std::isspace(ch); }).base(), str.end()); // Remove trailing spaces and line breaks
ELUNA_LOG_INFO("{}", str);
}, nullptr));
#elif defined MANGOS
eWorld->QueueCliCommand(new CliCommandHolder(0, SEC_CONSOLE, nullptr, command, nullptr, nullptr));
#endif
return 0;
}
@@ -1365,19 +1311,11 @@ namespace LuaGlobalFunctions
{
const char* query = Eluna::CHECKVAL<const char*>(L, 1);
#if defined TRINITY || AZEROTHCORE
ElunaQuery result = WorldDatabase.Query(query);
if (result)
Eluna::Push(L, new ElunaQuery(result));
else
Eluna::Push(L);
#else
ElunaQuery* result = WorldDatabase.QueryNamed(query);
if (result)
Eluna::Push(L, result);
else
Eluna::Push(L);
#endif
return 1;
}
@@ -1441,19 +1379,11 @@ namespace LuaGlobalFunctions
{
const char* query = Eluna::CHECKVAL<const char*>(L, 1);
#if defined TRINITY || AZEROTHCORE
QueryResult result = CharacterDatabase.Query(query);
if (result)
Eluna::Push(L, new QueryResult(result));
else
Eluna::Push(L);
#else
QueryNamedResult* result = CharacterDatabase.QueryNamed(query);
if (result)
Eluna::Push(L, result);
else
Eluna::Push(L);
#endif
return 1;
}
@@ -1510,19 +1440,11 @@ namespace LuaGlobalFunctions
{
const char* query = Eluna::CHECKVAL<const char*>(L, 1);
#if defined TRINITY || AZEROTHCORE
QueryResult result = LoginDatabase.Query(query);
if (result)
Eluna::Push(L, new QueryResult(result));
else
Eluna::Push(L);
#else
QueryNamedResult* result = LoginDatabase.QueryNamed(query);
if (result)
Eluna::Push(L, result);
else
Eluna::Push(L);
#endif
return 1;
}
@@ -1670,209 +1592,21 @@ namespace LuaGlobalFunctions
uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);
uint32 mapID = Eluna::CHECKVAL<uint32>(L, 3);
uint32 instanceID = Eluna::CHECKVAL<uint32>(L, 4);
float x = Eluna::CHECKVAL<float>(L, 5);
float y = Eluna::CHECKVAL<float>(L, 6);
float z = Eluna::CHECKVAL<float>(L, 7);
float o = Eluna::CHECKVAL<float>(L, 8);
bool save = Eluna::CHECKVAL<bool>(L, 9, false);
uint32 durorresptime = Eluna::CHECKVAL<uint32>(L, 10, 0);
#if (!defined(TBC) && !defined(CLASSIC))
uint32 phase = Eluna::CHECKVAL<uint32>(L, 11, PHASEMASK_NORMAL);
if (!phase)
{
Eluna::Push(L);
return 1;
}
#endif
#if !defined TRINITY && !AZEROTHCORE
Map* map = eMapMgr->FindMap(mapID, instanceID);
if (!map)
{
Eluna::Push(L);
return 1;
}
if (spawntype == 1) // spawn creature
{
if (save)
{
CreatureInfo const* cinfo = ObjectMgr::GetCreatureTemplate(entry);
if (!cinfo)
{
Eluna::Push(L);
return 1;
}
#if (defined(TBC) || defined(CLASSIC))
CreatureCreatePos pos(map, x, y, z, o);
#else
CreatureCreatePos pos(map, x, y, z, o, phase);
#endif
Creature* pCreature = new Creature;
// used guids from specially reserved range (can be 0 if no free values)
uint32 lowguid = eObjectMgr->GenerateStaticCreatureLowGuid();
if (!lowguid)
{
Eluna::Push(L);
return 1;
}
if (!pCreature->Create(lowguid, pos, cinfo))
{
delete pCreature;
Eluna::Push(L);
return 1;
}
#ifdef TBC
pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()));
#elif defined(CLASSIC)
pCreature->SaveToDB(map->GetId());
#else
pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), phase);
#endif
uint32 db_guid = pCreature->GetGUIDLow();
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
pCreature->LoadFromDB(db_guid, map);
map->Add(pCreature);
eObjectMgr->AddCreatureToGrid(db_guid, eObjectMgr->GetCreatureData(db_guid));
if (durorresptime)
pCreature->ForcedDespawn(durorresptime);
Eluna::Push(L, pCreature);
}
else
{
CreatureInfo const* cinfo = ObjectMgr::GetCreatureTemplate(entry);
if (!cinfo)
{
Eluna::Push(L);
return 1;
}
TemporarySummon* pCreature = new TemporarySummon(ObjectGuid(uint64(0)));
#if (defined(TBC) || defined(CLASSIC))
CreatureCreatePos pos(map, x, y, z, o);
#else
CreatureCreatePos pos(map, x, y, z, o, phase);
#endif
if (!pCreature->Create(map->GenerateLocalLowGuid(cinfo->GetHighGuid()), pos, cinfo, TEAM_NONE))
{
delete pCreature;
{
Eluna::Push(L);
return 1;
}
}
pCreature->SetRespawnCoord(pos);
// Active state set before added to map
pCreature->SetActiveObjectState(false);
// Also initializes the AI and MMGen
pCreature->Summon(durorresptime ? TEMPSPAWN_TIMED_OR_DEAD_DESPAWN : TEMPSPAWN_MANUAL_DESPAWN, durorresptime);
// Creature Linking, Initial load is handled like respawn
if (pCreature->IsLinkingEventTrigger())
map->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_RESPAWN, pCreature);
Eluna::Push(L, pCreature);
}
return 1;
}
if (spawntype == 2) // Spawn object
{
if (save)
{
const GameObjectInfo* gInfo = ObjectMgr::GetGameObjectInfo(entry);
if (!gInfo)
{
Eluna::Push(L);
return 1;
}
// used guids from specially reserved range (can be 0 if no free values)
uint32 db_lowGUID = eObjectMgr->GenerateStaticGameObjectLowGuid();
if (!db_lowGUID)
{
Eluna::Push(L);
return 1;
}
GameObject* pGameObj = new GameObject;
#if (defined(TBC) || defined(CLASSIC))
if (!pGameObj->Create(db_lowGUID, gInfo->id, map, x, y, z, o))
#else
if (!pGameObj->Create(db_lowGUID, gInfo->id, map, phase, x, y, z, o))
#endif
{
delete pGameObj;
Eluna::Push(L);
return 1;
}
if (durorresptime)
pGameObj->SetRespawnTime(durorresptime);
// fill the gameobject data and save to the db
#ifdef TBC
pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()));
#elif defined(CLASSIC)
pGameObj->SaveToDB(map->GetId());
#else
pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), phase);
#endif
// this will generate a new guid if the object is in an instance
if (!pGameObj->LoadFromDB(db_lowGUID, map))
{
delete pGameObj;
Eluna::Push(L);
return 1;
}
// DEBUG_LOG(GetMangosString(LANG_GAMEOBJECT_CURRENT), gInfo->name, db_lowGUID, x, y, z, o);
map->Add(pGameObj);
pGameObj->AIM_Initialize();
eObjectMgr->AddGameobjectToGrid(db_lowGUID, eObjectMgr->GetGOData(db_lowGUID));
Eluna::Push(L, pGameObj);
}
else
{
GameObject* pGameObj = new GameObject;
#if (defined(TBC) || defined(CLASSIC))
if (!pGameObj->Create(map->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), entry, map, x, y, z, o))
#else
if (!pGameObj->Create(map->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), entry, map, phase, x, y, z, o))
#endif
{
delete pGameObj;
Eluna::Push(L);
return 1;
}
pGameObj->SetRespawnTime(durorresptime / IN_MILLISECONDS);
map->Add(pGameObj);
pGameObj->AIM_Initialize();
Eluna::Push(L, pGameObj);
}
return 1;
}
#else
Map* map = eMapMgr->FindMap(mapID, instanceID);
if (!map)
{
@@ -1887,11 +1621,7 @@ namespace LuaGlobalFunctions
if (save)
{
Creature* creature = new Creature();
#ifndef AZEROTHCORE
if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, phase, entry, pos))
#else
if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, phase, entry, 0, x, y, z, o))
#endif
{
delete creature;
Eluna::Push(L);
@@ -1907,11 +1637,8 @@ namespace LuaGlobalFunctions
creature->CleanupsBeforeDelete();
delete creature;
creature = new Creature();
#ifndef AZEROTHCORE
if (!creature->LoadFromDB(db_guid, map, true, true))
#else
if (!creature->LoadFromDB(db_guid, map, true))
#endif
{
delete creature;
Eluna::Push(L);
@@ -1957,14 +1684,9 @@ namespace LuaGlobalFunctions
}
GameObject* object = new GameObject;
#ifndef AZEROTHCORE
uint32 guidLow = map->GenerateLowGuid<HighGuid::GameObject>();
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 = map->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);
@@ -1986,11 +1708,7 @@ 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);
@@ -2004,7 +1722,6 @@ namespace LuaGlobalFunctions
Eluna::Push(L, object);
return 1;
}
#endif
Eluna::Push(L);
return 1;
}
@@ -2044,25 +1761,10 @@ namespace LuaGlobalFunctions
uint32 incrtime = Eluna::CHECKVAL<uint32>(L, 4);
uint32 extendedcost = Eluna::CHECKVAL<uint32>(L, 5);
#if defined TRINITY || AZEROTHCORE
#ifdef CATA
if (!eObjectMgr->IsVendorItemValid(entry, item, maxcount, incrtime, extendedcost, 1))
return 0;
eObjectMgr->AddVendorItem(entry, item, maxcount, incrtime, extendedcost, 1);
#else
if (!eObjectMgr->IsVendorItemValid(entry, item, maxcount, incrtime, extendedcost))
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;
}
@@ -2079,11 +1781,7 @@ namespace LuaGlobalFunctions
if (!eObjectMgr->GetCreatureTemplate(entry))
return luaL_argerror(L, 1, "valid CreatureEntry expected");
#if defined(CATA) || defined(MISTS)
eObjectMgr->RemoveVendorItem(entry, item, 1);
#else
eObjectMgr->RemoveVendorItem(entry, item);
#endif
return 0;
}
@@ -2102,15 +1800,7 @@ namespace LuaGlobalFunctions
auto const& itemlist = items->m_items;
for (auto itr = itemlist.rbegin(); itr != itemlist.rend(); ++itr)
#if defined(CATA) || defined(MISTS)
eObjectMgr->RemoveVendorItem(entry, (*itr)->item, 1);
#else
#ifdef TRINITY
eObjectMgr->RemoveVendorItem(entry, itr->item);
#else
eObjectMgr->RemoveVendorItem(entry, (*itr)->item);
#endif
#endif
return 0;
}
@@ -2122,11 +1812,7 @@ namespace LuaGlobalFunctions
int Kick(lua_State* L)
{
Player* player = Eluna::CHECKOBJ<Player>(L, 1);
#ifdef TRINITY
player->GetSession()->KickPlayer("GlobalMethods::Kick Kick the player");
#else
player->GetSession()->KickPlayer();
#endif
return 0;
}
@@ -2162,13 +1848,8 @@ namespace LuaGlobalFunctions
switch (banMode)
{
case BAN_ACCOUNT:
#if defined TRINITY || AZEROTHCORE
if (!Utf8ToUpperOnlyLatin(nameOrIP))
return luaL_argerror(L, 2, "invalid account name");
#else
if (!AccountMgr::normalizeString(nameOrIP))
return luaL_argerror(L, 2, "invalid account name");
#endif
break;
case BAN_CHARACTER:
if (!normalizePlayerName(nameOrIP))
@@ -2207,15 +1888,9 @@ namespace LuaGlobalFunctions
case BanReturn::BAN_NOTFOUND:
Eluna::Push(L, 2);
break;
#ifdef AZEROTHCORE
case BanReturn::BAN_LONGER_EXISTS:
Eluna::Push(L, 3);
break;
#elif TRINITY
case BanReturn::BAN_EXISTS:
Eluna::Push(L, 3);
break;
#endif
}
return 1;
}
@@ -2274,32 +1949,19 @@ namespace LuaGlobalFunctions
MailSender sender(MAIL_NORMAL, senderGUIDLow, (MailStationery)stationary);
MailDraft draft(subject, text);
#if defined TRINITY || AZEROTHCORE
if (cod)
draft.AddCOD(cod);
if (money)
draft.AddMoney(money);
#else
if (cod)
draft.SetCOD(cod);
if (money)
draft.SetMoney(money);
#endif
#if defined TRINITY || defined AZEROTHCORE
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
#endif
uint8 addedItems = 0;
while (addedItems <= MAX_MAIL_ITEMS && i + 2 <= argAmount)
{
uint32 entry = Eluna::CHECKVAL<uint32>(L, ++i);
uint32 amount = Eluna::CHECKVAL<uint32>(L, ++i);
#if defined TRINITY || AZEROTHCORE
ItemTemplate const* item_proto = eObjectMgr->GetItemTemplate(entry);
#else
ItemTemplate const* item_proto = ObjectMgr::GetItemPrototype(entry);
#endif
if (!item_proto)
{
luaL_error(L, "Item entry %d does not exist", entry);
@@ -2312,28 +1974,16 @@ namespace LuaGlobalFunctions
}
if (Item* item = Item::CreateItem(entry, amount))
{
#if defined TRINITY || AZEROTHCORE
item->SaveToDB(trans);
#else
item->SaveToDB();
#endif
draft.AddItem(item);
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, item->GetGUID().GetCounter());
#else
Eluna::Push(L, item->GetGUIDLow());
#endif
++addedItems;
}
}
Player* receiverPlayer = eObjectAccessor()FindPlayer(MAKE_NEW_GUID(receiverGUIDLow, 0, HIGHGUID_PLAYER));
#if defined TRINITY || AZEROTHCORE
draft.SendMailTo(trans, MailReceiver(receiverPlayer, receiverGUIDLow), sender, MAIL_CHECK_MASK_NONE, delay);
CharacterDatabase.CommitTransaction(trans);
#else
draft.SendMailTo(MailReceiver(receiverPlayer, MAKE_NEW_GUID(receiverGUIDLow, 0, HIGHGUID_PLAYER)), sender);
#endif
return addedItems;
}
@@ -2489,16 +2139,6 @@ namespace LuaGlobalFunctions
// Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, node, key, value
}
TaxiPathNodeEntry entry;
#ifdef TRINITY
// mandatory
entry.ContinentID = Eluna::CHECKVAL<uint32>(L, start);
entry.Loc.X = Eluna::CHECKVAL<float>(L, start + 1);
entry.Loc.Y = Eluna::CHECKVAL<float>(L, start + 2);
entry.Loc.Z = Eluna::CHECKVAL<float>(L, start + 3);
// optional
entry.Flags = Eluna::CHECKVAL<uint32>(L, start + 4, 0);
entry.Delay = Eluna::CHECKVAL<uint32>(L, start + 5, 0);
#else
// mandatory
entry.mapid = Eluna::CHECKVAL<uint32>(L, start);
entry.x = Eluna::CHECKVAL<float>(L, start + 1);
@@ -2507,7 +2147,6 @@ namespace LuaGlobalFunctions
// optional
entry.actionFlag = Eluna::CHECKVAL<uint32>(L, start + 4, 0);
entry.delay = Eluna::CHECKVAL<uint32>(L, start + 5, 0);
#endif
nodes.push_back(entry);
@@ -2529,28 +2168,17 @@ namespace LuaGlobalFunctions
pathId = sTaxiPathNodesByPath.size();
if (sTaxiPathNodesByPath.size() <= pathId)
sTaxiPathNodesByPath.resize(pathId + 1);
sTaxiPathNodesByPath[pathId].clear();
sTaxiPathNodesByPath[pathId].resize(nodes.size());
static uint32 nodeId = 500;
uint32 startNode = nodeId;
uint32 index = 0;
for (std::list<TaxiPathNodeEntry>::iterator it = nodes.begin(); it != nodes.end(); ++it)
{
TaxiPathNodeEntry& entry = *it;
TaxiNodesEntry* nodeEntry = new TaxiNodesEntry();
#ifdef TRINITY
entry.PathID = pathId;
entry.NodeIndex = nodeId;
nodeEntry->ID = index;
nodeEntry->ContinentID = entry.ContinentID;
nodeEntry->Pos.X = entry.Loc.X;
nodeEntry->Pos.Y = entry.Loc.Y;
nodeEntry->Pos.Z = entry.Loc.Z;
nodeEntry->MountCreatureID[0] = mountH;
nodeEntry->MountCreatureID[1] = mountA;
sTaxiNodesStore.SetEntry(nodeId++, nodeEntry);
sTaxiPathNodesByPath[pathId][index++] = new TaxiPathNodeEntry(entry);
#else
entry.path = pathId;
entry.index = nodeId;
nodeEntry->ID = index;
@@ -2561,33 +2189,19 @@ 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)
return 1;
#ifndef AZEROTHCORE
sTaxiPathSetBySource[startNode][nodeId - 1] = TaxiPathBySourceAndDestination(pathId, price);
#endif
TaxiPathEntry* pathEntry = new TaxiPathEntry();
#ifdef TRINITY
pathEntry->FromTaxiNode = startNode;
pathEntry->ToTaxiNode = nodeId - 1;
pathEntry->Cost = price;
#else
pathEntry->from = startNode;
pathEntry->to = nodeId - 1;
pathEntry->price = price;
#endif
pathEntry->ID = pathId;
sTaxiPathStore.SetEntry(pathId, pathEntry);
#ifdef AZEROTHCORE
sTaxiPathSetBySource[startNode][nodeId - 1] = pathEntry;
#endif
Eluna::Push(L, pathId);
return 1;
}
@@ -3479,7 +3093,6 @@ namespace LuaGlobalFunctions
return 0;
}
#ifdef AZEROTHCORE
/**
* Gets the faction which is the current owner of Halaa in Nagrand
* 0 = Alliance
@@ -3530,6 +3143,5 @@ namespace LuaGlobalFunctions
return 0;
}
#endif
}
#endif

View File

@@ -149,13 +149,9 @@ namespace LuaGroup
if (player->GetGroupInvite())
player->UninviteFromGroup();
#if defined TRINITY || AZEROTHCORE
bool success = group->AddMember(player);
if (success)
group->BroadcastGroupUpdate();
#else
bool success = group->AddMember(player->GetObjectGuid(), player->GetName());
#endif
Eluna::Push(L, success);
return 1;
@@ -186,11 +182,7 @@ namespace LuaGroup
for (GroupReference* itr = group->GetFirstMember(); itr; itr = itr->next())
{
#if defined TRINITY || AZEROTHCORE
Player* member = itr->GetSource();
#else
Player* member = itr->getSource();
#endif
if (!member || !member->GetSession())
continue;
@@ -210,11 +202,7 @@ namespace LuaGroup
*/
int GetLeaderGUID(lua_State* L, Group* group)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, group->GetLeaderGUID());
#else
Eluna::Push(L, group->GetLeaderGuid());
#endif
return 1;
}
@@ -225,11 +213,7 @@ namespace LuaGroup
*/
int GetGUID(lua_State* L, Group* group)
{
#ifdef CLASSIC
Eluna::Push(L, group->GetId());
#else
Eluna::Push(L, group->GET_GUID());
#endif
return 1;
}
@@ -242,11 +226,8 @@ namespace LuaGroup
int GetMemberGUID(lua_State* L, Group* group)
{
const char* name = Eluna::CHECKVAL<const char*>(L, 2);
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, group->GetMemberGUID(name));
#else
Eluna::Push(L, group->GetMemberGuid(name));
#endif
return 1;
}
@@ -322,11 +303,7 @@ namespace LuaGroup
bool ignorePlayersInBg = Eluna::CHECKVAL<bool>(L, 3);
ObjectGuid ignore = Eluna::CHECKVAL<ObjectGuid>(L, 4);
#ifdef CMANGOS
group->BroadcastPacket(*data, ignorePlayersInBg, -1, ignore);
#else
group->BroadcastPacket(data, ignorePlayersInBg, -1, ignore);
#endif
return 0;
}
@@ -352,11 +329,7 @@ namespace LuaGroup
ObjectGuid guid = Eluna::CHECKVAL<ObjectGuid>(L, 2);
uint32 method = Eluna::CHECKVAL<uint32>(L, 3, 0);
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, group->RemoveMember(guid, (RemoveMethod)method));
#else
Eluna::Push(L, group->RemoveMember(guid, method));
#endif
return 1;
}
@@ -420,11 +393,7 @@ namespace LuaGroup
if (icon >= TARGETICONCOUNT)
return luaL_argerror(L, 2, "valid target icon expected");
#if (defined(CLASSIC) || defined(TBC))
group->SetTargetIcon(icon, target);
#else
group->SetTargetIcon(icon, setter, target);
#endif
return 0;
}

View File

@@ -25,22 +25,8 @@ namespace LuaGuild
int tbl = lua_gettop(L);
uint32 i = 0;
#if defined(MANGOS)
eObjectAccessor()DoForAllPlayers([&](Player* player)
{
if (player->IsInWorld() && player->GetGuildId() == guild->GetId())
{
Eluna::Push(L, player);
lua_rawseti(L, tbl, ++i);
}
});
#else
{
#if defined TRINITY || AZEROTHCORE
std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
#else
HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock());
#endif
const HashMapHolder<Player>::MapType& m = eObjectAccessor()GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator it = m.begin(); it != m.end(); ++it)
{
@@ -54,7 +40,7 @@ namespace LuaGuild
}
}
}
#endif
lua_settop(L, tbl); // push table to top of stack
return 1;
}
@@ -66,11 +52,7 @@ namespace LuaGuild
*/
int GetMemberCount(lua_State* L, Guild* guild)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, guild->GetMemberCount());
#else
Eluna::Push(L, guild->GetMemberSize());
#endif
return 1;
}
@@ -81,11 +63,7 @@ namespace LuaGuild
*/
int GetLeader(lua_State* L, Guild* guild)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, eObjectAccessor()FindPlayer(guild->GetLeaderGUID()));
#else
Eluna::Push(L, eObjectAccessor()FindPlayer(guild->GetLeaderGuid()));
#endif
return 1;
}
@@ -96,11 +74,7 @@ namespace LuaGuild
*/
int GetLeaderGUID(lua_State* L, Guild* guild)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, guild->GetLeaderGUID());
#else
Eluna::Push(L, guild->GetLeaderGuid());
#endif
return 1;
}
@@ -144,15 +118,10 @@ namespace LuaGuild
*/
int GetInfo(lua_State* L, Guild* guild)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, guild->GetInfo());
#else
Eluna::Push(L, guild->GetGINFO());
#endif
return 1;
}
#if defined(CLASSIC) || defined(TBC) || defined(WOTLK)
/**
* Sets the leader of this [Guild]
*
@@ -162,16 +131,10 @@ namespace LuaGuild
{
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
#if defined TRINITY || AZEROTHCORE
guild->HandleSetLeader(player->GetSession(), player->GetName());
#else
guild->SetLeader(player->GET_GUID());
#endif
return 0;
}
#endif
#ifndef CLASSIC
/**
* Sets the information of the bank tab specified
*
@@ -182,14 +145,9 @@ namespace LuaGuild
{
uint8 tabId = Eluna::CHECKVAL<uint8>(L, 2);
const char* text = Eluna::CHECKVAL<const char*>(L, 3);
#if defined TRINITY || AZEROTHCORE
guild->SetBankTabText(tabId, text);
#else
guild->SetGuildBankTabText(tabId, text);
#endif
return 0;
}
#endif
// SendPacketToGuild(packet)
/**
@@ -201,11 +159,7 @@ namespace LuaGuild
{
WorldPacket* data = Eluna::CHECKOBJ<WorldPacket>(L, 2);
#ifdef CMANGOS
guild->BroadcastPacket(*data);
#else
guild->BroadcastPacket(data);
#endif
return 0;
}
@@ -221,11 +175,7 @@ namespace LuaGuild
WorldPacket* data = Eluna::CHECKOBJ<WorldPacket>(L, 2);
uint8 ranked = Eluna::CHECKVAL<uint8>(L, 3);
#ifdef CMANGOS
guild->BroadcastPacketToRank(*data, ranked);
#else
guild->BroadcastPacketToRank(data, ranked);
#endif
return 0;
}
@@ -251,12 +201,7 @@ namespace LuaGuild
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
uint8 rankId = Eluna::CHECKVAL<uint8>(L, 3, GUILD_RANK_NONE);
#ifdef TRINITY
CharacterDatabaseTransaction trans(nullptr);
guild->AddMember(trans, player->GET_GUID(), rankId);
#else
guild->AddMember(player->GET_GUID(), rankId);
#endif
return 0;
}
@@ -271,14 +216,7 @@ namespace LuaGuild
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
bool isDisbanding = Eluna::CHECKVAL<bool>(L, 3, false);
#if defined TRINITY
CharacterDatabaseTransaction trans(nullptr);
guild->DeleteMember(trans, player->GET_GUID(), isDisbanding);
#elif defined AZEROTHCORE
guild->DeleteMember(player->GET_GUID(), isDisbanding);
#else
guild->DelMember(player->GET_GUID(), isDisbanding);
#endif
return 0;
}
@@ -293,12 +231,7 @@ namespace LuaGuild
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
uint8 newRank = Eluna::CHECKVAL<uint8>(L, 3);
#ifdef TRINITY
CharacterDatabaseTransaction trans(nullptr);
guild->ChangeMemberRank(trans, player->GET_GUID(), newRank);
#else
guild->ChangeMemberRank(player->GET_GUID(), newRank);
#endif
return 0;
}
};

View File

@@ -23,7 +23,6 @@ namespace LuaItem
return 1;
}
#if (!defined(TBC) && !defined(CLASSIC))
/**
* Returns 'true' if the [Item] is account bound, 'false' otherwise
*
@@ -34,7 +33,6 @@ namespace LuaItem
Eluna::Push(L, item->IsBoundAccountWide());
return 1;
}
#endif
/**
* Returns 'true' if the [Item] is bound to a [Player] by an enchant, 'false' otehrwise
@@ -83,7 +81,6 @@ namespace LuaItem
return 1;
}
#ifndef CLASSIC
/**
* Returns 'true' if the [Item] is a currency token, 'false' otherwise
*
@@ -94,7 +91,6 @@ namespace LuaItem
Eluna::Push(L, item->IsCurrencyToken());
return 1;
}
#endif
/**
* Returns 'true' if the [Item] is a not an empty bag, 'false' otherwise
@@ -125,12 +121,8 @@ namespace LuaItem
*/
int CanBeTraded(lua_State* L, Item* item)
{
#if (defined(TBC) || defined(CLASSIC))
Eluna::Push(L, item->CanBeTraded());
#else
bool mail = Eluna::CHECKVAL<bool>(L, 2, false);
Eluna::Push(L, item->CanBeTraded(mail));
#endif
return 1;
}
@@ -176,11 +168,7 @@ namespace LuaItem
int HasQuest(lua_State* L, Item* item)
{
uint32 quest = Eluna::CHECKVAL<uint32>(L, 2);
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, item->hasQuest(quest));
#else
Eluna::Push(L, item->HasQuest(quest));
#endif
return 1;
}
@@ -195,7 +183,6 @@ namespace LuaItem
return 1;
}
#if defined CLASSIC || defined(TBC) || defined(WOTLK)
/**
* Returns 'true' if the [Item] is a weapon vellum, 'false' otherwise
*
@@ -217,7 +204,6 @@ namespace LuaItem
Eluna::Push(L, item->IsArmorVellum());
return 1;
}
#endif
/**
* Returns 'true' if the [Item] is a conjured consumable, 'false' otherwise
@@ -270,49 +256,24 @@ namespace LuaItem
ObjectMgr::GetLocaleString(il->Name, static_cast<LocaleConstant>(locale), name);
}
#ifndef CLASSIC
if (int32 itemRandPropId = item->GetItemRandomPropertyId())
{
#if defined(CATA) || defined (MISTS)
char* suffix = NULL;
#else
#if TRINITY || AZEROTHCORE
std::array<char const*, 16> const* suffix = NULL;
#else
char* const* suffix = NULL;
#endif
#endif
if (itemRandPropId < 0)
{
const ItemRandomSuffixEntry* itemRandEntry = sItemRandomSuffixStore.LookupEntry(-item->GetItemRandomPropertyId());
if (itemRandEntry)
{
#if TRINITY || AZEROTHCORE
suffix = &itemRandEntry->Name;
#else
suffix = itemRandEntry->nameSuffix;
#endif
}
}
else
{
const ItemRandomPropertiesEntry* itemRandEntry = sItemRandomPropertiesStore.LookupEntry(item->GetItemRandomPropertyId());
if (itemRandEntry)
{
#if TRINITY || AZEROTHCORE
suffix = &itemRandEntry->Name;
#else
suffix = itemRandEntry->nameSuffix;
#endif
}
}
if (suffix)
{
#if TRINITY || AZEROTHCORE
const char* suffixName = (*suffix)[(name != temp->Name1) ? locale : uint8(DEFAULT_LOCALE)];
#else
const char* suffixName = suffix[(name != temp->Name1) ? locale : uint8(DEFAULT_LOCALE)];
#endif
if (strcmp(suffixName, "") != 0)
{
name += ' ';
@@ -320,19 +281,16 @@ namespace LuaItem
}
}
}
#endif
Player* owner = item->GetOwner();
std::ostringstream oss;
oss << "|c" << std::hex << ItemQualityColors[temp->Quality] << std::dec <<
"|Hitem:" << temp->ItemId << ":" <<
item->GetEnchantmentId(PERM_ENCHANTMENT_SLOT) << ":" <<
#ifndef CLASSIC
item->GetEnchantmentId(SOCK_ENCHANTMENT_SLOT) << ":" <<
item->GetEnchantmentId(SOCK_ENCHANTMENT_SLOT_2) << ":" <<
item->GetEnchantmentId(SOCK_ENCHANTMENT_SLOT_3) << ":" <<
item->GetEnchantmentId(BONUS_ENCHANTMENT_SLOT) << ":" <<
#endif
item->GetItemRandomPropertyId() << ":" << item->GetItemSuffixFactor() << ":" <<
(uint32)(owner ? owner->GetLevel() : 0) << "|h[" << name << "]|h|r";
@@ -342,11 +300,7 @@ namespace LuaItem
int GetOwnerGUID(lua_State* L, Item* item)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, item->GetOwnerGUID());
#else
Eluna::Push(L, item->GetOwnerGuid());
#endif
return 1;
}
@@ -597,13 +551,11 @@ namespace LuaItem
return 1;
}
#ifdef WOTLK
int GetStatsCount(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->StatsCount);
return 1;
}
#endif
/**
* Returns the random property ID of this [Item]
@@ -616,13 +568,11 @@ namespace LuaItem
return 1;
}
#ifndef CLASSIC
int GetRandomSuffix(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->RandomSuffix);
return 1;
}
#endif
/**
* Returns the item set ID of this [Item]
@@ -668,11 +618,7 @@ namespace LuaItem
int SetOwner(lua_State* L, Item* item)
{
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
#if defined TRINITY || AZEROTHCORE
item->SetOwnerGUID(player->GET_GUID());
#else
item->SetOwnerGuid(player->GET_GUID());
#endif
return 0;
}
@@ -774,12 +720,8 @@ namespace LuaItem
*/
int SaveToDB(lua_State* /*L*/, Item* item)
{
#if defined TRINITY || defined AZEROTHCORE
CharacterDatabaseTransaction trans = CharacterDatabaseTransaction(nullptr);
item->SaveToDB(trans);
#else
item->SaveToDB();
#endif
return 0;
}
};

View File

@@ -17,7 +17,6 @@
namespace LuaMap
{
#ifndef CLASSIC
/**
* Returns `true` if the [Map] is an arena [BattleGround], `false` otherwise.
*
@@ -28,7 +27,6 @@ namespace LuaMap
Eluna::Push(L, map->IsBattleArena());
return 1;
}
#endif
/**
* Returns `true` if the [Map] is a non-arena [BattleGround], `false` otherwise.
@@ -37,11 +35,7 @@ namespace LuaMap
*/
int IsBattleground(lua_State* L, Map* map)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, map->IsBattleground());
#else
Eluna::Push(L, map->IsBattleGround());
#endif
return 1;
}
@@ -67,7 +61,6 @@ namespace LuaMap
return 1;
}
#ifndef CLASSIC
/**
* Returns `true` if the [Map] is a heroic, `false` otherwise.
*
@@ -78,7 +71,6 @@ namespace LuaMap
Eluna::Push(L, map->IsHeroic());
return 1;
}
#endif
/**
* Returns `true` if the [Map] is a raid, `false` otherwise.
@@ -115,12 +107,8 @@ namespace LuaMap
{
float x = Eluna::CHECKVAL<float>(L, 2);
float y = Eluna::CHECKVAL<float>(L, 3);
#if (defined(TBC) || defined(CLASSIC))
float z = map->GetHeight(x, y, MAX_HEIGHT);
#else
uint32 phasemask = Eluna::CHECKVAL<uint32>(L, 4, 1);
float z = map->GetHeight(phasemask, x, y, MAX_HEIGHT);
#endif
if (z != INVALID_HEIGHT)
Eluna::Push(L, z);
return 1;
@@ -135,11 +123,7 @@ namespace LuaMap
*/
int GetDifficulty(lua_State* L, Map* map)
{
#ifndef CLASSIC
Eluna::Push(L, map->GetDifficulty());
#else
Eluna::Push(L, (Difficulty)0);
#endif
return 1;
}
@@ -190,13 +174,9 @@ namespace LuaMap
float x = Eluna::CHECKVAL<float>(L, 2);
float y = Eluna::CHECKVAL<float>(L, 3);
float z = Eluna::CHECKVAL<float>(L, 4);
#if defined TRINITY || defined AZEROTHCORE
float phasemask = Eluna::CHECKVAL<uint32>(L, 5, PHASEMASK_NORMAL);
Eluna::Push(L, map->GetAreaId(phasemask, x, y, z));
#else
Eluna::Push(L, map->GetTerrain()->GetAreaId(x, y, z));
#endif
return 1;
}
@@ -210,7 +190,6 @@ namespace LuaMap
{
ObjectGuid guid = Eluna::CHECKVAL<ObjectGuid>(L, 2);
#if defined TRINITY || AZEROTHCORE
switch (guid.GetHigh())
{
case HIGHGUID_PLAYER:
@@ -237,9 +216,6 @@ namespace LuaMap
default:
break;
}
#else
Eluna::Push(L, map->GetWorldObject(guid));
#endif
return 1;
}
@@ -267,19 +243,11 @@ namespace LuaMap
uint32 weatherType = Eluna::CHECKVAL<uint32>(L, 3);
float grade = Eluna::CHECKVAL<float>(L, 4);
#if defined TRINITY
if (Weather * weather = map->GetOrGenerateZoneDefaultWeather(zoneId))
weather->SetWeather((WeatherType)weatherType, grade);
#elif defined AZEROTHCORE
Weather* weather = WeatherMgr::FindWeather(zoneId);
if (!weather)
weather = WeatherMgr::AddWeather(zoneId);
if (weather)
weather->SetWeather((WeatherType)weatherType, grade);
#else
if (Weather::IsValidWeatherType(weatherType))
map->SetWeather(zoneId, (WeatherType)weatherType, grade, false);
#endif
return 0;
}
@@ -293,13 +261,9 @@ namespace LuaMap
*/
int GetInstanceData(lua_State* L, Map* map)
{
#if defined TRINITY || AZEROTHCORE
ElunaInstanceAI* iAI = NULL;
if (InstanceMap* inst = map->ToInstanceMap())
iAI = dynamic_cast<ElunaInstanceAI*>(inst->GetInstanceScript());
#else
ElunaInstanceAI* iAI = dynamic_cast<ElunaInstanceAI*>(map->GetInstanceData());
#endif
if (iAI)
Eluna::GetEluna(L)->PushInstanceData(L, iAI, false);
@@ -314,13 +278,9 @@ namespace LuaMap
*/
int SaveInstanceData(lua_State* /*L*/, Map* map)
{
#if defined TRINITY || AZEROTHCORE
ElunaInstanceAI* iAI = NULL;
if (InstanceMap* inst = map->ToInstanceMap())
iAI = dynamic_cast<ElunaInstanceAI*>(inst->GetInstanceScript());
#else
ElunaInstanceAI* iAI = dynamic_cast<ElunaInstanceAI*>(map->GetInstanceData());
#endif
if (iAI)
iAI->SaveToDB();
@@ -352,11 +312,7 @@ namespace LuaMap
Map::PlayerList const& players = map->GetPlayers();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
#if defined TRINITY || AZEROTHCORE
Player* player = itr->GetSource();
#else
Player* player = itr->getSource();
#endif
if (!player)
continue;
if (player->GetSession() && (team >= TEAM_NEUTRAL || player->GetTeamId() == team))

View File

@@ -58,9 +58,7 @@ namespace LuaObject
*/
int IsPlayer(lua_State* L, Object* obj)
{
#ifdef AZEROTHCORE //AC-only
Eluna::Push(L, obj->IsPlayer());
#endif
return 1;
}
@@ -146,11 +144,7 @@ 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;
}
@@ -199,11 +193,7 @@ namespace LuaObject
*/
int GetGUIDLow(lua_State* L, Object* obj)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, obj->GetGUID().GetCounter());
#else
Eluna::Push(L, obj->GetGUIDLow());
#endif
return 1;
}

File diff suppressed because it is too large Load Diff

View File

@@ -52,15 +52,10 @@ namespace LuaQuest
int HasFlag(lua_State* L, Quest* quest)
{
uint32 flag = Eluna::CHECKVAL<uint32>(L, 2);
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, quest->HasFlag(flag));
#else
Eluna::Push(L, quest->HasQuestFlag((QuestFlags)flag));
#endif
return 1;
}
#ifndef CLASSIC
/**
* Returns 'true' if the [Quest] is a daily quest, false otherwise.
*
@@ -71,7 +66,6 @@ namespace LuaQuest
Eluna::Push(L, quest->IsDaily());
return 1;
}
#endif
/**
* Returns 'true' if the [Quest] is repeatable, false otherwise.
@@ -157,11 +151,7 @@ namespace LuaQuest
*/
int GetFlags(lua_State* L, Quest* quest)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, quest->GetFlags());
#else
Eluna::Push(L, quest->GetQuestFlags());
#endif
return 1;
}

View File

@@ -100,11 +100,7 @@ namespace LuaSpell
*/
int GetDuration(lua_State* L, Spell* spell)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, spell->GetSpellInfo()->GetDuration());
#else
Eluna::Push(L, GetSpellDuration(spell->m_spellInfo));
#endif
return 1;
}
@@ -117,17 +113,11 @@ namespace LuaSpell
*/
int GetTargetDest(lua_State* L, Spell* spell)
{
#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);
Eluna::Push(L, z);
@@ -148,7 +138,6 @@ namespace LuaSpell
*/
int GetTarget(lua_State* L, Spell* spell)
{
#if defined TRINITY || AZEROTHCORE
if (GameObject* target = spell->m_targets.GetGOTarget())
Eluna::Push(L, target);
else if (Item* target = spell->m_targets.GetItemTarget())
@@ -159,16 +148,6 @@ 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;
}

View File

@@ -403,7 +403,6 @@ namespace LuaUnit
return 1;
}
#ifndef CLASSIC
/**
* Returns true if the [Unit] is on a [Vehicle].
*
@@ -414,7 +413,6 @@ namespace LuaUnit
Eluna::Push(L, unit->GetVehicle());
return 1;
}
#endif
/**
* Returns true if the [Unit] is in combat.
@@ -1166,7 +1164,6 @@ namespace LuaUnit
return 1;
}
#if (!defined(TBC) && !defined(CLASSIC))
/**
* Returns [Unit]'s [Vehicle] methods
*
@@ -1196,7 +1193,6 @@ namespace LuaUnit
Eluna::Push(L, unit->GetCritterGUID());
return 1;
}
#endif
/**
* Returns the [Unit]'s speed of given [UnitMoveType].
@@ -1752,7 +1748,6 @@ namespace LuaUnit
return 0;
}
#if (!defined(TBC) && !defined(CLASSIC))
/**
* Sets the [Unit]'s FFA flag on or off.
*
@@ -1804,7 +1799,6 @@ namespace LuaUnit
unit->SetCritterGUID(guid);
return 0;
}
#endif
/*int SetStunned(lua_State* L, Unit* unit)
{
@@ -2157,7 +2151,6 @@ namespace LuaUnit
return 0;
}
#if (!defined(TBC) && !defined(CLASSIC))
/**
* Makes the [Unit] jump to the coordinates
*
@@ -2180,7 +2173,6 @@ namespace LuaUnit
unit->GetMotionMaster()->MoveJump(pos, zSpeed, maxHeight, id);
return 0;
}
#endif
/**
* The [Unit] will whisper the message to a [Player]
@@ -2426,7 +2418,6 @@ namespace LuaUnit
return 0;
}
#if !defined(CLASSIC)
/**
* Removes all positive visible [Aura]'s from the [Unit].
*/
@@ -2435,7 +2426,6 @@ namespace LuaUnit
unit->RemoveArenaAuras();
return 0;
}
#endif
/**
* Adds the given unit state for the [Unit].

View File

@@ -6,8 +6,6 @@
#ifndef VEHICLEMETHODS_H
#define VEHICLEMETHODS_H
#ifndef CLASSIC
#ifndef TBC
/***
* Inherits all methods from: none
@@ -23,11 +21,7 @@ namespace LuaVehicle
int IsOnBoard(lua_State* L, Vehicle* vehicle)
{
Unit* passenger = Eluna::CHECKOBJ<Unit>(L, 2);
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, passenger->IsOnVehicle(vehicle->GetBase()));
#else
Eluna::Push(L, vehicle->HasOnBoard(passenger));
#endif
return 1;
}
@@ -38,11 +32,7 @@ namespace LuaVehicle
*/
int GetOwner(lua_State* L, Vehicle* vehicle)
{
#if defined TRINITY || AZEROTHCORE
Eluna::Push(L, vehicle->GetBase());
#else
Eluna::Push(L, vehicle->GetOwner());
#endif
return 1;
}
@@ -53,13 +43,7 @@ namespace LuaVehicle
*/
int GetEntry(lua_State* L, Vehicle* vehicle)
{
#ifdef TRINITY
Eluna::Push(L, vehicle->GetVehicleInfo()->ID);
#elif AZEROTHCORE
Eluna::Push(L, vehicle->GetVehicleInfo()->m_ID);
#else
Eluna::Push(L, vehicle->GetVehicleEntry()->m_ID);
#endif
return 1;
}
@@ -86,12 +70,8 @@ namespace LuaVehicle
{
Unit* passenger = Eluna::CHECKOBJ<Unit>(L, 2);
int8 seatId = Eluna::CHECKVAL<int8>(L, 3);
#if defined TRINITY || AZEROTHCORE
vehicle->AddPassenger(passenger, seatId);
#else
if (vehicle->CanBoard(passenger))
vehicle->Board(passenger, seatId);
#endif
return 0;
}
@@ -103,15 +83,9 @@ namespace LuaVehicle
int RemovePassenger(lua_State* L, Vehicle* vehicle)
{
Unit* passenger = Eluna::CHECKOBJ<Unit>(L, 2);
#if defined TRINITY || AZEROTHCORE
vehicle->RemovePassenger(passenger);
#else
vehicle->UnBoard(passenger, false);
#endif
return 0;
}
}
#endif // CLASSIC
#endif // TBC
#endif // VEHICLEMETHODS_H

View File

@@ -34,7 +34,6 @@ namespace LuaWorldObject
return 1;
}
#if (!defined(TBC) && !defined(CLASSIC))
/**
* Returns the current phase of the [WorldObject]
*
@@ -59,7 +58,6 @@ namespace LuaWorldObject
obj->SetPhaseMask(phaseMask, update);
return 0;
}
#endif
/**
* Returns the current instance ID of the [WorldObject]
@@ -183,17 +181,9 @@ namespace LuaWorldObject
Unit* target = NULL;
ElunaUtil::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_PLAYER, 0, hostile, dead);
#ifdef TRINITY
Trinity::UnitLastSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(obj, target, checker);
Cell::VisitAllObjects(obj, searcher, range);
#elif AZEROTHCORE
Acore::UnitLastSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(obj, target, checker);
Cell::VisitAllObjects(obj, searcher, range);
#else
MaNGOS::UnitLastSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(target, checker);
Cell::VisitWorldObjects(obj, searcher, range);
#endif
Eluna::Push(L, target);
return 1;
@@ -216,16 +206,9 @@ namespace LuaWorldObject
GameObject* target = NULL;
ElunaUtil::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_GAMEOBJECT, entry, hostile);
#ifdef TRINITY
Trinity::GameObjectLastSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(obj, target, checker);
Cell::VisitAllObjects(obj, searcher, range);
#elif AZEROTHCORE
Acore::GameObjectLastSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(obj, target, checker);
Cell::VisitAllObjects(obj, searcher, range);
#else
MaNGOS::GameObjectLastSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(target, checker);
Cell::VisitGridObjects(obj, searcher, range);
#endif
Eluna::Push(L, target);
return 1;
@@ -250,17 +233,9 @@ namespace LuaWorldObject
Creature* target = NULL;
ElunaUtil::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_UNIT, entry, hostile, dead);
#ifdef TRINITY
Trinity::CreatureLastSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(obj, target, checker);
Cell::VisitAllObjects(obj, searcher, range);
#elif AZEROTHCORE
Acore::CreatureLastSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(obj, target, checker);
Cell::VisitAllObjects(obj, searcher, range);
#else
MaNGOS::CreatureLastSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(target, checker);
Cell::VisitGridObjects(obj, searcher, range);
#endif
Eluna::Push(L, target);
return 1;
@@ -283,16 +258,9 @@ namespace LuaWorldObject
std::list<Player*> list;
ElunaUtil::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_PLAYER, 0, hostile, dead);
#ifdef TRINITY
Trinity::PlayerListSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(obj, list, checker);
Cell::VisitAllObjects(obj, searcher, range);
#elif AZEROTHCORE
Acore::PlayerListSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(obj, list, checker);
Cell::VisitAllObjects(obj, searcher, range);
#else
MaNGOS::PlayerListSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(list, checker);
Cell::VisitWorldObjects(obj, searcher, range);
#endif
lua_createtable(L, list.size(), 0);
int tbl = lua_gettop(L);
@@ -327,16 +295,9 @@ namespace LuaWorldObject
std::list<Creature*> list;
ElunaUtil::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_UNIT, entry, hostile, dead);
#ifdef TRINITY
Trinity::CreatureListSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(obj, list, checker);
Cell::VisitAllObjects(obj, searcher, range);
#elif defined AZEROTHCORE
Acore::CreatureListSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(obj, list, checker);
Cell::VisitAllObjects(obj, searcher, range);
#else
MaNGOS::CreatureListSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(list, checker);
Cell::VisitGridObjects(obj, searcher, range);
#endif
lua_createtable(L, list.size(), 0);
int tbl = lua_gettop(L);
@@ -369,16 +330,9 @@ namespace LuaWorldObject
std::list<GameObject*> list;
ElunaUtil::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_GAMEOBJECT, entry, hostile);
#ifdef TRINITY
Trinity::GameObjectListSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(obj, list, checker);
Cell::VisitAllObjects(obj, searcher, range);
#elif AZEROTHCORE
Acore::GameObjectListSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(obj, list, checker);
Cell::VisitAllObjects(obj, searcher, range);
#else
MaNGOS::GameObjectListSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(list, checker);
Cell::VisitGridObjects(obj, searcher, range);
#endif
lua_createtable(L, list.size(), 0);
int tbl = lua_gettop(L);
@@ -419,16 +373,9 @@ namespace LuaWorldObject
ElunaUtil::WorldObjectInRangeCheck checker(true, obj, range, type, entry, hostile, dead);
WorldObject* target = NULL;
#ifdef TRINITY
Trinity::WorldObjectLastSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(obj, target, checker);
Cell::VisitAllObjects(obj, searcher, range);
#elif AZEROTHCORE
Acore::WorldObjectLastSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(obj, target, checker);
Cell::VisitAllObjects(obj, searcher, range);
#else
MaNGOS::WorldObjectLastSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(target, checker);
Cell::VisitAllObjects(obj, searcher, range);
#endif
Eluna::Push(L, target);
return 1;
@@ -459,16 +406,9 @@ namespace LuaWorldObject
ElunaUtil::WorldObjectInRangeCheck checker(false, obj, range, type, entry, hostile, dead);
std::list<WorldObject*> list;
#ifdef TRINITY
Trinity::WorldObjectListSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(obj, list, checker);
Cell::VisitAllObjects(obj, searcher, range);
#elif AZEROTHCORE
Acore::WorldObjectListSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(obj, list, checker);
Cell::VisitAllObjects(obj, searcher, range);
#else
MaNGOS::WorldObjectListSearcher<ElunaUtil::WorldObjectInRangeCheck> searcher(list, checker);
Cell::VisitAllObjects(obj, searcher, range);
#endif
lua_createtable(L, list.size(), 0);
int tbl = lua_gettop(L);
@@ -658,7 +598,6 @@ namespace LuaWorldObject
int GetAngle(lua_State* L, WorldObject* obj)
{
WorldObject* target = Eluna::CHECKOBJ<WorldObject>(L, 2, false);
#if defined TRINITY && !AZEROTHCORE
if (target)
Eluna::Push(L, obj->GetAbsoluteAngle(target));
else
@@ -667,16 +606,7 @@ namespace LuaWorldObject
float y = Eluna::CHECKVAL<float>(L, 3);
Eluna::Push(L, obj->GetAbsoluteAngle(x, y));
}
#else
if (target)
Eluna::Push(L, obj->GetAngle(target));
else
{
float x = Eluna::CHECKVAL<float>(L, 2);
float y = Eluna::CHECKVAL<float>(L, 3);
Eluna::Push(L, obj->GetAngle(x, y));
}
#endif
return 1;
}
@@ -688,11 +618,7 @@ namespace LuaWorldObject
int SendPacket(lua_State* L, WorldObject* obj)
{
WorldPacket* data = Eluna::CHECKOBJ<WorldPacket>(L, 2);
#ifdef CMANGOS
obj->SendMessageToSet(*data, true);
#else
obj->SendMessageToSet(data, true);
#endif
return 0;
}
@@ -715,14 +641,8 @@ namespace LuaWorldObject
float z = Eluna::CHECKVAL<float>(L, 5);
float o = Eluna::CHECKVAL<float>(L, 6);
uint32 respawnDelay = Eluna::CHECKVAL<uint32>(L, 7, 30);
#ifdef TRINITY
QuaternionData rot = QuaternionData::fromEulerAnglesZYX(o, 0.f, 0.f);
Eluna::Push(L, obj->SummonGameObject(entry, Position(x, y, z, o), rot, Seconds(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;
}
@@ -762,7 +682,6 @@ namespace LuaWorldObject
uint32 spawnType = Eluna::CHECKVAL<uint32>(L, 7, 8);
uint32 despawnTimer = Eluna::CHECKVAL<uint32>(L, 8, 0);
#if defined TRINITY || AZEROTHCORE
TempSummonType type;
switch (spawnType)
{
@@ -793,49 +712,8 @@ namespace LuaWorldObject
default:
return luaL_argerror(L, 7, "valid SpawnType expected");
}
#else
TempSpawnType type;
switch (spawnType)
{
case 1:
type = TEMPSPAWN_TIMED_OR_DEAD_DESPAWN;
break;
case 2:
type = TEMPSPAWN_TIMED_OR_CORPSE_DESPAWN;
break;
case 3:
type = TEMPSPAWN_TIMED_DESPAWN;
break;
case 4:
type = TEMPSPAWN_TIMED_OOC_DESPAWN;
break;
case 5:
type = TEMPSPAWN_CORPSE_DESPAWN;
break;
case 6:
type = TEMPSPAWN_CORPSE_TIMED_DESPAWN;
break;
case 7:
type = TEMPSPAWN_DEAD_DESPAWN;
break;
case 8:
type = TEMPSPAWN_MANUAL_DESPAWN;
break;
case 9:
type = TEMPSPAWN_TIMED_OOC_OR_CORPSE_DESPAWN;
break;
case 10:
type = TEMPSPAWN_TIMED_OOC_OR_DEAD_DESPAWN;
break;
default:
return luaL_argerror(L, 7, "valid SpawnType expected");
}
#endif
#ifdef TRINITY
Eluna::Push(L, obj->SummonCreature(entry, x, y, z, o, type, Seconds(despawnTimer)));
#else
Eluna::Push(L, obj->SummonCreature(entry, x, y, z, o, type, despawnTimer));
#endif
return 1;
}
@@ -1119,11 +997,7 @@ namespace LuaWorldObject
WorldObject* target = Eluna::CHECKOBJ<WorldObject>(L, 2);
float arc = Eluna::CHECKVAL<float>(L, 3, static_cast<float>(M_PI));
#ifdef MANGOS
Eluna::Push(L, obj->IsInFront(target, arc));
#else
Eluna::Push(L, obj->isInFront(target, arc));
#endif
return 1;
}
@@ -1139,11 +1013,7 @@ namespace LuaWorldObject
WorldObject* target = Eluna::CHECKOBJ<WorldObject>(L, 2);
float arc = Eluna::CHECKVAL<float>(L, 3, static_cast<float>(M_PI));
#ifdef MANGOS
Eluna::Push(L, obj->IsInBack(target, arc));
#else
Eluna::Push(L, obj->isInBack(target, arc));
#endif
return 1;
}
@@ -1165,17 +1035,10 @@ namespace LuaWorldObject
WorldPacket data(SMSG_PLAY_MUSIC, 4);
data << uint32(musicid);
#ifdef CMANGOS
if (player)
player->SendDirectMessage(data);
else
obj->SendMessageToSet(data, true);
#else
if (player)
player->SendDirectMessage(&data);
else
obj->SendMessageToSet(&data, true);
#endif
return 0;
}