diff --git a/GroupHooks.cpp b/GroupHooks.cpp index 7203e3047e..0b5b88fb55 100644 --- a/GroupHooks.cpp +++ b/GroupHooks.cpp @@ -24,8 +24,7 @@ using namespace Hooks; return RETVAL;\ auto key = EventKey(EVENT);\ if (!GroupEventBindings->HasBindingsFor(key))\ - return RETVAL;\ - LOCK_ELUNA + return RETVAL; void Eluna::OnAddMember(Group* group, ObjectGuid guid) { @@ -91,7 +90,7 @@ void Eluna::OnCreate(Group* group, ObjectGuid leaderGuid, GroupType groupType) bool Eluna::OnMemberAccept(Group* group, Player* player) { START_HOOK_WITH_RETVAL(GROUP_EVENT_ON_MEMBER_ACCEPT, true); - Push(group); - Push(player); + HookPush(group); + HookPush(player); return CallAllFunctionsBool(GroupEventBindings, key, true); } diff --git a/LuaEngine.cpp b/LuaEngine.cpp index 76c2d1dffe..3b795d32bb 100644 --- a/LuaEngine.cpp +++ b/LuaEngine.cpp @@ -31,14 +31,9 @@ #error Eluna could not determine platform #endif -#ifdef ELUNA_WINDOWS -#include -#include -#endif - // Some dummy includes containing BOOST_VERSION: // ObjectAccessor.h Config.h Log.h -#if !defined MANGOS && !defined VMANGOS +#if !defined MANGOS #define USING_BOOST #endif @@ -52,7 +47,7 @@ extern "C" { -// Base lua libraries + // Base lua libraries #include "lua.h" #include "lualib.h" #include "lauxlib.h" @@ -80,33 +75,33 @@ void Eluna::_ReloadEluna() } Eluna::Eluna(int32 mapId) : -event_level(0), -push_counter(0), -enabled(false), -boundMapId(mapId), - -L(NULL), -eventMgr(NULL), - -ServerEventBindings(NULL), -PlayerEventBindings(NULL), -GuildEventBindings(NULL), -GroupEventBindings(NULL), -VehicleEventBindings(NULL), -BGEventBindings(NULL), - -PacketEventBindings(NULL), -CreatureEventBindings(NULL), -CreatureGossipBindings(NULL), -GameObjectEventBindings(NULL), -GameObjectGossipBindings(NULL), -ItemEventBindings(NULL), -ItemGossipBindings(NULL), -PlayerGossipBindings(NULL), -MapEventBindings(NULL), -InstanceEventBindings(NULL), - -CreatureUniqueBindings(NULL) + event_level(0), + push_counter(0), + enabled(false), + boundMapId(mapId), + + L(NULL), + eventMgr(NULL), + + ServerEventBindings(NULL), + PlayerEventBindings(NULL), + GuildEventBindings(NULL), + GroupEventBindings(NULL), + VehicleEventBindings(NULL), + BGEventBindings(NULL), + + PacketEventBindings(NULL), + CreatureEventBindings(NULL), + CreatureGossipBindings(NULL), + GameObjectEventBindings(NULL), + GameObjectGossipBindings(NULL), + ItemEventBindings(NULL), + ItemGossipBindings(NULL), + PlayerGossipBindings(NULL), + MapEventBindings(NULL), + InstanceEventBindings(NULL), + + CreatureUniqueBindings(NULL) { OpenLua(); eventMgr = new EventMgr(this); @@ -172,25 +167,25 @@ void Eluna::CreateBindStores() { DestroyBindStores(); - ServerEventBindings = new BindingMap< EventKey >(L); - PlayerEventBindings = new BindingMap< EventKey >(L); - GuildEventBindings = new BindingMap< EventKey >(L); - GroupEventBindings = new BindingMap< EventKey >(L); - VehicleEventBindings = new BindingMap< EventKey >(L); - BGEventBindings = new BindingMap< EventKey >(L); - - PacketEventBindings = new BindingMap< EntryKey >(L); - CreatureEventBindings = new BindingMap< EntryKey >(L); - CreatureGossipBindings = new BindingMap< EntryKey >(L); - GameObjectEventBindings = new BindingMap< EntryKey >(L); + ServerEventBindings = new BindingMap< EventKey >(L); + PlayerEventBindings = new BindingMap< EventKey >(L); + GuildEventBindings = new BindingMap< EventKey >(L); + GroupEventBindings = new BindingMap< EventKey >(L); + VehicleEventBindings = new BindingMap< EventKey >(L); + BGEventBindings = new BindingMap< EventKey >(L); + + PacketEventBindings = new BindingMap< EntryKey >(L); + CreatureEventBindings = new BindingMap< EntryKey >(L); + CreatureGossipBindings = new BindingMap< EntryKey >(L); + GameObjectEventBindings = new BindingMap< EntryKey >(L); GameObjectGossipBindings = new BindingMap< EntryKey >(L); - ItemEventBindings = new BindingMap< EntryKey >(L); - ItemGossipBindings = new BindingMap< EntryKey >(L); - PlayerGossipBindings = new BindingMap< EntryKey >(L); - MapEventBindings = new BindingMap< EntryKey >(L); - InstanceEventBindings = new BindingMap< EntryKey >(L); + ItemEventBindings = new BindingMap< EntryKey >(L); + ItemGossipBindings = new BindingMap< EntryKey >(L); + PlayerGossipBindings = new BindingMap< EntryKey >(L); + MapEventBindings = new BindingMap< EntryKey >(L); + InstanceEventBindings = new BindingMap< EntryKey >(L); - CreatureUniqueBindings = new BindingMap< UniqueObjectKey >(L); + CreatureUniqueBindings = new BindingMap< UniqueObjectKey >(L); } void Eluna::DestroyBindStores() @@ -332,7 +327,7 @@ void Eluna::Report(lua_State* _L) } // Borrowed from http://stackoverflow.com/questions/12256455/print-stacktrace-from-c-code-with-embedded-lua -int Eluna::StackTrace(lua_State *_L) +int Eluna::StackTrace(lua_State* _L) { // Stack: errmsg if (!lua_isstring(_L, -1)) /* 'message' not a string? */ @@ -483,14 +478,14 @@ void Eluna::Push(Unit const* unit) } switch (unit->GetTypeId()) { - case TYPEID_UNIT: - Push(unit->ToCreature()); - break; - case TYPEID_PLAYER: - Push(unit->ToPlayer()); - break; - default: - ElunaTemplate::Push(this, unit); + case TYPEID_UNIT: + Push(unit->ToCreature()); + break; + case TYPEID_PLAYER: + Push(unit->ToPlayer()); + break; + default: + ElunaTemplate::Push(this, unit); } } void Eluna::Push(WorldObject const* obj) @@ -502,20 +497,20 @@ void Eluna::Push(WorldObject const* obj) } switch (obj->GetTypeId()) { - case TYPEID_UNIT: - Push(obj->ToCreature()); - break; - case TYPEID_PLAYER: - Push(obj->ToPlayer()); - break; - case TYPEID_GAMEOBJECT: - Push(obj->ToGameObject()); - break; - case TYPEID_CORPSE: - Push(obj->ToCorpse()); - break; - default: - ElunaTemplate::Push(this, obj); + case TYPEID_UNIT: + Push(obj->ToCreature()); + break; + case TYPEID_PLAYER: + Push(obj->ToPlayer()); + break; + case TYPEID_GAMEOBJECT: + Push(obj->ToGameObject()); + break; + case TYPEID_CORPSE: + Push(obj->ToCorpse()); + break; + default: + ElunaTemplate::Push(this, obj); } } void Eluna::Push(Object const* obj) @@ -527,20 +522,20 @@ void Eluna::Push(Object const* obj) } switch (obj->GetTypeId()) { - case TYPEID_UNIT: - Push(obj->ToCreature()); - break; - case TYPEID_PLAYER: - Push(obj->ToPlayer()); - break; - case TYPEID_GAMEOBJECT: - Push(obj->ToGameObject()); - break; - case TYPEID_CORPSE: - Push(obj->ToCorpse()); - break; - default: - ElunaTemplate::Push(this, obj); + case TYPEID_UNIT: + Push(obj->ToCreature()); + break; + case TYPEID_PLAYER: + Push(obj->ToPlayer()); + break; + case TYPEID_GAMEOBJECT: + Push(obj->ToGameObject()); + break; + case TYPEID_CORPSE: + Push(obj->ToCorpse()); + break; + default: + ElunaTemplate::Push(this, obj); } } void Eluna::Push(ObjectGuid const guid) @@ -714,7 +709,7 @@ ElunaObject* Eluna::CHECKTYPE(lua_State* luastate, int narg, const char* tname, } template -static int cancelBinding(lua_State *L) +static int cancelBinding(lua_State* L) { uint64 bindingID = Eluna::CHECKVAL(L, lua_upvalueindex(1)); @@ -744,118 +739,87 @@ int Eluna::Register(lua_State* L, uint8 regtype, uint32 entry, ObjectGuid guid, switch (regtype) { - case Hooks::REGTYPE_SERVER: - if (event_id < Hooks::SERVER_EVENT_COUNT) - { - auto key = EventKey((Hooks::ServerEvents)event_id); - bindingID = ServerEventBindings->Insert(key, functionRef, shots); - createCancelCallback(this, bindingID, ServerEventBindings); - return 1; // Stack: callback - } - break; + case Hooks::REGTYPE_SERVER: + if (event_id < Hooks::SERVER_EVENT_COUNT) + { + auto key = EventKey((Hooks::ServerEvents)event_id); + bindingID = ServerEventBindings->Insert(key, functionRef, shots); + createCancelCallback(this, bindingID, ServerEventBindings); + return 1; // Stack: callback + } + break; - case Hooks::REGTYPE_PLAYER: - if (event_id < Hooks::PLAYER_EVENT_COUNT) - { - auto key = EventKey((Hooks::PlayerEvents)event_id); - bindingID = PlayerEventBindings->Insert(key, functionRef, shots); - createCancelCallback(this, bindingID, PlayerEventBindings); - return 1; // Stack: callback - } - break; + case Hooks::REGTYPE_PLAYER: + if (event_id < Hooks::PLAYER_EVENT_COUNT) + { + auto key = EventKey((Hooks::PlayerEvents)event_id); + bindingID = PlayerEventBindings->Insert(key, functionRef, shots); + createCancelCallback(this, bindingID, PlayerEventBindings); + return 1; // Stack: callback + } + break; - case Hooks::REGTYPE_GUILD: - if (event_id < Hooks::GUILD_EVENT_COUNT) - { - auto key = EventKey((Hooks::GuildEvents)event_id); - bindingID = GuildEventBindings->Insert(key, functionRef, shots); - createCancelCallback(this, bindingID, GuildEventBindings); - return 1; // Stack: callback - } - break; + case Hooks::REGTYPE_GUILD: + if (event_id < Hooks::GUILD_EVENT_COUNT) + { + auto key = EventKey((Hooks::GuildEvents)event_id); + bindingID = GuildEventBindings->Insert(key, functionRef, shots); + createCancelCallback(this, bindingID, GuildEventBindings); + return 1; // Stack: callback + } + break; - case Hooks::REGTYPE_GROUP: - if (event_id < Hooks::GROUP_EVENT_COUNT) - { - auto key = EventKey((Hooks::GroupEvents)event_id); - bindingID = GroupEventBindings->Insert(key, functionRef, shots); - createCancelCallback(this, bindingID, GroupEventBindings); - return 1; // Stack: callback - } - break; + case Hooks::REGTYPE_GROUP: + if (event_id < Hooks::GROUP_EVENT_COUNT) + { + auto key = EventKey((Hooks::GroupEvents)event_id); + bindingID = GroupEventBindings->Insert(key, functionRef, shots); + createCancelCallback(this, bindingID, GroupEventBindings); + return 1; // Stack: callback + } + break; - case Hooks::REGTYPE_VEHICLE: - if (event_id < Hooks::VEHICLE_EVENT_COUNT) - { - auto key = EventKey((Hooks::VehicleEvents)event_id); - bindingID = VehicleEventBindings->Insert(key, functionRef, shots); - createCancelCallback(this, bindingID, VehicleEventBindings); - return 1; // Stack: callback - } - break; + case Hooks::REGTYPE_VEHICLE: + if (event_id < Hooks::VEHICLE_EVENT_COUNT) + { + auto key = EventKey((Hooks::VehicleEvents)event_id); + bindingID = VehicleEventBindings->Insert(key, functionRef, shots); + createCancelCallback(this, bindingID, VehicleEventBindings); + return 1; // Stack: callback + } + break; - case Hooks::REGTYPE_BG: - if (event_id < Hooks::BG_EVENT_COUNT) - { - auto key = EventKey((Hooks::BGEvents)event_id); - bindingID = BGEventBindings->Insert(key, functionRef, shots); - createCancelCallback(this, bindingID, BGEventBindings); - return 1; // Stack: callback - } - break; + case Hooks::REGTYPE_BG: + if (event_id < Hooks::BG_EVENT_COUNT) + { + auto key = EventKey((Hooks::BGEvents)event_id); + bindingID = BGEventBindings->Insert(key, functionRef, shots); + createCancelCallback(this, bindingID, BGEventBindings); + return 1; // Stack: callback + } + break; - case Hooks::REGTYPE_PACKET: - if (event_id < Hooks::PACKET_EVENT_COUNT) + case Hooks::REGTYPE_PACKET: + if (event_id < Hooks::PACKET_EVENT_COUNT) + { + if (entry >= NUM_MSG_TYPES) { - if (entry >= NUM_MSG_TYPES) - { - luaL_unref(L, LUA_REGISTRYINDEX, functionRef); - luaL_error(L, "Couldn't find a creature with (ID: %d)!", entry); - return 0; // Stack: (empty) - } - - auto key = EntryKey((Hooks::PacketEvents)event_id, entry); - bindingID = PacketEventBindings->Insert(key, functionRef, shots); - createCancelCallback(this, bindingID, PacketEventBindings); - return 1; // Stack: callback + luaL_unref(L, LUA_REGISTRYINDEX, functionRef); + luaL_error(L, "Couldn't find a creature with (ID: %d)!", entry); + return 0; // Stack: (empty) } - break; - case Hooks::REGTYPE_CREATURE: - if (event_id < Hooks::CREATURE_EVENT_COUNT) - { - if (entry != 0) - { - if (!eObjectMgr->GetCreatureTemplate(entry)) - { - luaL_unref(L, LUA_REGISTRYINDEX, functionRef); - luaL_error(L, "Couldn't find a creature with (ID: %d)!", entry); - return 0; // Stack: (empty) - } - - auto key = EntryKey((Hooks::CreatureEvents)event_id, entry); - bindingID = CreatureEventBindings->Insert(key, functionRef, shots); - createCancelCallback(this, bindingID, CreatureEventBindings); - } - else - { - if (guid.IsEmpty()) - { - luaL_unref(L, LUA_REGISTRYINDEX, functionRef); - luaL_error(L, "guid was 0!"); - return 0; // Stack: (empty) - } - - auto key = UniqueObjectKey((Hooks::CreatureEvents)event_id, guid, instanceId); - bindingID = CreatureUniqueBindings->Insert(key, functionRef, shots); - createCancelCallback(this, bindingID, CreatureUniqueBindings); - } - return 1; // Stack: callback - } - break; + auto key = EntryKey((Hooks::PacketEvents)event_id, entry); + bindingID = PacketEventBindings->Insert(key, functionRef, shots); + createCancelCallback(this, bindingID, PacketEventBindings); + return 1; // Stack: callback + } + break; - case Hooks::REGTYPE_CREATURE_GOSSIP: - if (event_id < Hooks::GOSSIP_EVENT_COUNT) + case Hooks::REGTYPE_CREATURE: + if (event_id < Hooks::CREATURE_EVENT_COUNT) + { + if (entry != 0) { if (!eObjectMgr->GetCreatureTemplate(entry)) { @@ -864,108 +828,139 @@ int Eluna::Register(lua_State* L, uint8 regtype, uint32 entry, ObjectGuid guid, return 0; // Stack: (empty) } - auto key = EntryKey((Hooks::GossipEvents)event_id, entry); - bindingID = CreatureGossipBindings->Insert(key, functionRef, shots); - createCancelCallback(this, bindingID, CreatureGossipBindings); - return 1; // Stack: callback + auto key = EntryKey((Hooks::CreatureEvents)event_id, entry); + bindingID = CreatureEventBindings->Insert(key, functionRef, shots); + createCancelCallback(this, bindingID, CreatureEventBindings); } - break; - - case Hooks::REGTYPE_GAMEOBJECT: - if (event_id < Hooks::GAMEOBJECT_EVENT_COUNT) + else { - if (!eObjectMgr->GetGameObjectTemplate(entry)) + if (guid.IsEmpty()) { luaL_unref(L, LUA_REGISTRYINDEX, functionRef); - luaL_error(L, "Couldn't find a gameobject with (ID: %d)!", entry); + luaL_error(L, "guid was 0!"); return 0; // Stack: (empty) } - auto key = EntryKey((Hooks::GameObjectEvents)event_id, entry); - bindingID = GameObjectEventBindings->Insert(key, functionRef, shots); - createCancelCallback(this, bindingID, GameObjectEventBindings); - return 1; // Stack: callback + auto key = UniqueObjectKey((Hooks::CreatureEvents)event_id, guid, instanceId); + bindingID = CreatureUniqueBindings->Insert(key, functionRef, shots); + createCancelCallback(this, bindingID, CreatureUniqueBindings); } - break; + return 1; // Stack: callback + } + break; - case Hooks::REGTYPE_GAMEOBJECT_GOSSIP: - if (event_id < Hooks::GOSSIP_EVENT_COUNT) + case Hooks::REGTYPE_CREATURE_GOSSIP: + if (event_id < Hooks::GOSSIP_EVENT_COUNT) + { + if (!eObjectMgr->GetCreatureTemplate(entry)) { - if (!eObjectMgr->GetGameObjectTemplate(entry)) - { - luaL_unref(L, LUA_REGISTRYINDEX, functionRef); - luaL_error(L, "Couldn't find a gameobject with (ID: %d)!", entry); - return 0; // Stack: (empty) - } - - auto key = EntryKey((Hooks::GossipEvents)event_id, entry); - bindingID = GameObjectGossipBindings->Insert(key, functionRef, shots); - createCancelCallback(this, bindingID, GameObjectGossipBindings); - return 1; // Stack: callback + luaL_unref(L, LUA_REGISTRYINDEX, functionRef); + luaL_error(L, "Couldn't find a creature with (ID: %d)!", entry); + return 0; // Stack: (empty) } - break; - case Hooks::REGTYPE_ITEM: - if (event_id < Hooks::ITEM_EVENT_COUNT) - { - if (!eObjectMgr->GetItemTemplate(entry)) - { - luaL_unref(L, LUA_REGISTRYINDEX, functionRef); - luaL_error(L, "Couldn't find a item with (ID: %d)!", entry); - return 0; // Stack: (empty) - } - - auto key = EntryKey((Hooks::ItemEvents)event_id, entry); - bindingID = ItemEventBindings->Insert(key, functionRef, shots); - createCancelCallback(this, bindingID, ItemEventBindings); - return 1; // Stack: callback - } - break; + auto key = EntryKey((Hooks::GossipEvents)event_id, entry); + bindingID = CreatureGossipBindings->Insert(key, functionRef, shots); + createCancelCallback(this, bindingID, CreatureGossipBindings); + return 1; // Stack: callback + } + break; - case Hooks::REGTYPE_ITEM_GOSSIP: - if (event_id < Hooks::GOSSIP_EVENT_COUNT) + case Hooks::REGTYPE_GAMEOBJECT: + if (event_id < Hooks::GAMEOBJECT_EVENT_COUNT) + { + if (!eObjectMgr->GetGameObjectTemplate(entry)) { - if (!eObjectMgr->GetItemTemplate(entry)) - { - luaL_unref(L, LUA_REGISTRYINDEX, functionRef); - luaL_error(L, "Couldn't find a item with (ID: %d)!", entry); - return 0; // Stack: (empty) - } - - auto key = EntryKey((Hooks::GossipEvents)event_id, entry); - bindingID = ItemGossipBindings->Insert(key, functionRef, shots); - createCancelCallback(this, bindingID, ItemGossipBindings); - return 1; // Stack: callback + luaL_unref(L, LUA_REGISTRYINDEX, functionRef); + luaL_error(L, "Couldn't find a gameobject with (ID: %d)!", entry); + return 0; // Stack: (empty) } - break; - case Hooks::REGTYPE_PLAYER_GOSSIP: - if (event_id < Hooks::GOSSIP_EVENT_COUNT) + auto key = EntryKey((Hooks::GameObjectEvents)event_id, entry); + bindingID = GameObjectEventBindings->Insert(key, functionRef, shots); + createCancelCallback(this, bindingID, GameObjectEventBindings); + return 1; // Stack: callback + } + break; + + case Hooks::REGTYPE_GAMEOBJECT_GOSSIP: + if (event_id < Hooks::GOSSIP_EVENT_COUNT) + { + if (!eObjectMgr->GetGameObjectTemplate(entry)) { - auto key = EntryKey((Hooks::GossipEvents)event_id, entry); - bindingID = PlayerGossipBindings->Insert(key, functionRef, shots); - createCancelCallback(this, bindingID, PlayerGossipBindings); - return 1; // Stack: callback + luaL_unref(L, LUA_REGISTRYINDEX, functionRef); + luaL_error(L, "Couldn't find a gameobject with (ID: %d)!", entry); + return 0; // Stack: (empty) } - break; - case Hooks::REGTYPE_MAP: - if (event_id < Hooks::INSTANCE_EVENT_COUNT) + + auto key = EntryKey((Hooks::GossipEvents)event_id, entry); + bindingID = GameObjectGossipBindings->Insert(key, functionRef, shots); + createCancelCallback(this, bindingID, GameObjectGossipBindings); + return 1; // Stack: callback + } + break; + + case Hooks::REGTYPE_ITEM: + if (event_id < Hooks::ITEM_EVENT_COUNT) + { + if (!eObjectMgr->GetItemTemplate(entry)) { - auto key = EntryKey((Hooks::InstanceEvents)event_id, entry); - bindingID = MapEventBindings->Insert(key, functionRef, shots); - createCancelCallback(this, bindingID, MapEventBindings); - return 1; // Stack: callback + luaL_unref(L, LUA_REGISTRYINDEX, functionRef); + luaL_error(L, "Couldn't find a item with (ID: %d)!", entry); + return 0; // Stack: (empty) } - break; - case Hooks::REGTYPE_INSTANCE: - if (event_id < Hooks::INSTANCE_EVENT_COUNT) + + auto key = EntryKey((Hooks::ItemEvents)event_id, entry); + bindingID = ItemEventBindings->Insert(key, functionRef, shots); + createCancelCallback(this, bindingID, ItemEventBindings); + return 1; // Stack: callback + } + break; + + case Hooks::REGTYPE_ITEM_GOSSIP: + if (event_id < Hooks::GOSSIP_EVENT_COUNT) + { + if (!eObjectMgr->GetItemTemplate(entry)) { - auto key = EntryKey((Hooks::InstanceEvents)event_id, entry); - bindingID = InstanceEventBindings->Insert(key, functionRef, shots); - createCancelCallback(this, bindingID, InstanceEventBindings); - return 1; // Stack: callback + luaL_unref(L, LUA_REGISTRYINDEX, functionRef); + luaL_error(L, "Couldn't find a item with (ID: %d)!", entry); + return 0; // Stack: (empty) } - break; + + auto key = EntryKey((Hooks::GossipEvents)event_id, entry); + bindingID = ItemGossipBindings->Insert(key, functionRef, shots); + createCancelCallback(this, bindingID, ItemGossipBindings); + return 1; // Stack: callback + } + break; + + case Hooks::REGTYPE_PLAYER_GOSSIP: + if (event_id < Hooks::GOSSIP_EVENT_COUNT) + { + auto key = EntryKey((Hooks::GossipEvents)event_id, entry); + bindingID = PlayerGossipBindings->Insert(key, functionRef, shots); + createCancelCallback(this, bindingID, PlayerGossipBindings); + return 1; // Stack: callback + } + break; + case Hooks::REGTYPE_MAP: + if (event_id < Hooks::INSTANCE_EVENT_COUNT) + { + auto key = EntryKey((Hooks::InstanceEvents)event_id, entry); + bindingID = MapEventBindings->Insert(key, functionRef, shots); + createCancelCallback(this, bindingID, MapEventBindings); + return 1; // Stack: callback + } + break; + case Hooks::REGTYPE_INSTANCE: + if (event_id < Hooks::INSTANCE_EVENT_COUNT) + { + auto key = EntryKey((Hooks::InstanceEvents)event_id, entry); + bindingID = InstanceEventBindings->Insert(key, functionRef, shots); + createCancelCallback(this, bindingID, InstanceEventBindings); + return 1; // Stack: callback + } + break; } luaL_unref(L, LUA_REGISTRYINDEX, functionRef); std::ostringstream oss; @@ -1006,9 +1001,9 @@ int Eluna::CallOneFunction(int number_of_functions, int number_of_arguments, int ASSERT(number_of_functions > 0 && number_of_arguments > 0 && number_of_results >= 0); // Stack: event_id, [arguments], [functions] - int functions_top = lua_gettop(L); + int functions_top = lua_gettop(L); int first_function_index = functions_top - number_of_functions + 1; - int arguments_top = first_function_index - 1; + int arguments_top = first_function_index - 1; int first_argument_index = arguments_top - number_of_arguments + 1; // Copy the arguments from the bottom of the stack to the top. diff --git a/LuaEngine.h b/LuaEngine.h index 534dbc2706..b87f6566eb 100644 --- a/LuaEngine.h +++ b/LuaEngine.h @@ -191,14 +191,14 @@ class ELUNA_GAME_API Eluna // This is called on world update to reload eluna void _ReloadEluna(); - static int StackTrace(lua_State *_L); + static int StackTrace(lua_State* _L); static void Report(lua_State* _L); // Some helpers for hooks to call event handlers. // The bodies of the templates are in HookHelpers.h, so if you want to use them you need to #include "HookHelpers.h". template int SetupStack(BindingMap* bindings1, BindingMap* bindings2, const K1& key1, const K2& key2, int number_of_arguments); - int CallOneFunction(int number_of_functions, int number_of_arguments, int number_of_results); - void CleanUpStack(int number_of_arguments); + int CallOneFunction(int number_of_functions, int number_of_arguments, int number_of_results); + void CleanUpStack(int number_of_arguments); template void ReplaceArgument(T value, uint8 index); template void CallAllFunctions(BindingMap* bindings1, BindingMap* bindings2, const K1& key1, const K2& key2); template bool CallAllFunctionsBool(BindingMap* bindings1, BindingMap* bindings2, const K1& key1, const K2& key2, bool default_value = false); @@ -220,46 +220,46 @@ class ELUNA_GAME_API Eluna // Non-static pushes, to be used in hooks. // They up the pushed value counter for hook helper functions. - void HookPush() { Push(); ++push_counter; } - void HookPush(const long long value) { Push(value); ++push_counter; } - void HookPush(const unsigned long long value) { Push(value); ++push_counter; } - void HookPush(const long value) { Push(value); ++push_counter; } - void HookPush(const unsigned long value) { Push(value); ++push_counter; } - void HookPush(const int value) { Push(value); ++push_counter; } - void HookPush(const unsigned int value) { Push(value); ++push_counter; } - void HookPush(const bool value) { Push(value); ++push_counter; } - void HookPush(const float value) { Push(value); ++push_counter; } - void HookPush(const double value) { Push(value); ++push_counter; } - void HookPush(const std::string& value) { Push(value); ++push_counter; } - void HookPush(const char* value) { Push(value); ++push_counter; } - void HookPush(ObjectGuid const value) { Push(value); ++push_counter; } + void HookPush() { Push(); ++push_counter; } + void HookPush(const long long value) { Push(value); ++push_counter; } + void HookPush(const unsigned long long value) { Push(value); ++push_counter; } + void HookPush(const long value) { Push(value); ++push_counter; } + void HookPush(const unsigned long value) { Push(value); ++push_counter; } + void HookPush(const int value) { Push(value); ++push_counter; } + void HookPush(const unsigned int value) { Push(value); ++push_counter; } + void HookPush(const bool value) { Push(value); ++push_counter; } + void HookPush(const float value) { Push(value); ++push_counter; } + void HookPush(const double value) { Push(value); ++push_counter; } + void HookPush(const std::string& value) { Push(value); ++push_counter; } + void HookPush(const char* value) { Push(value); ++push_counter; } + void HookPush(ObjectGuid const value) { Push(value); ++push_counter; } template - void HookPush(T const* ptr) { Push(ptr); ++push_counter; } + void HookPush(T const* ptr) { Push(ptr); ++push_counter; } public: lua_State* L; EventMgr* eventMgr; - BindingMap< EventKey >* ServerEventBindings; - BindingMap< EventKey >* PlayerEventBindings; - BindingMap< EventKey >* GuildEventBindings; - BindingMap< EventKey >* GroupEventBindings; - BindingMap< EventKey >* VehicleEventBindings; - BindingMap< EventKey >* BGEventBindings; + BindingMap< EventKey >* ServerEventBindings; + BindingMap< EventKey >* PlayerEventBindings; + BindingMap< EventKey >* GuildEventBindings; + BindingMap< EventKey >* GroupEventBindings; + BindingMap< EventKey >* VehicleEventBindings; + BindingMap< EventKey >* BGEventBindings; - BindingMap< EntryKey >* PacketEventBindings; - BindingMap< EntryKey >* CreatureEventBindings; - BindingMap< EntryKey >* CreatureGossipBindings; + BindingMap< EntryKey >* PacketEventBindings; + BindingMap< EntryKey >* CreatureEventBindings; + BindingMap< EntryKey >* CreatureGossipBindings; BindingMap< EntryKey >* GameObjectEventBindings; - BindingMap< EntryKey >* GameObjectGossipBindings; - BindingMap< EntryKey >* ItemEventBindings; - BindingMap< EntryKey >* ItemGossipBindings; - BindingMap< EntryKey >* PlayerGossipBindings; - BindingMap< EntryKey >* MapEventBindings; - BindingMap< EntryKey >* InstanceEventBindings; + BindingMap< EntryKey >* GameObjectGossipBindings; + BindingMap< EntryKey >* ItemEventBindings; + BindingMap< EntryKey >* ItemGossipBindings; + BindingMap< EntryKey >* PlayerGossipBindings; + BindingMap< EntryKey >* MapEventBindings; + BindingMap< EntryKey >* InstanceEventBindings; - BindingMap< UniqueObjectKey >* CreatureUniqueBindings; + BindingMap< UniqueObjectKey >* CreatureUniqueBindings; // Never returns nullptr static Eluna* GetEluna(lua_State* L) @@ -339,7 +339,7 @@ class ELUNA_GAME_API Eluna { return ElunaTemplate::Check(luastate, narg, error); } - static ElunaObject* CHECKTYPE(lua_State* luastate, int narg, const char *tname, bool error = true); + static ElunaObject* CHECKTYPE(lua_State* luastate, int narg, const char* tname, bool error = true); CreatureAI* GetAI(Creature* creature); InstanceData* GetInstanceData(Map* map); diff --git a/PlayerHooks.cpp b/PlayerHooks.cpp index d8a3482ea1..a99f28674f 100644 --- a/PlayerHooks.cpp +++ b/PlayerHooks.cpp @@ -43,9 +43,9 @@ void Eluna::OnLearnTalents(Player* pPlayer, uint32 talentId, uint32 talentRank, void Eluna::OnSkillChange(Player* pPlayer, uint32 skillId, uint32 skillValue) { START_HOOK(PLAYER_EVENT_ON_SKILL_CHANGE); - Push(pPlayer); - Push(skillId); - Push(skillValue); + HookPush(pPlayer); + HookPush(skillId); + HookPush(skillValue); int valueIndex = lua_gettop(L) - 1; int n = SetupStack(PlayerEventBindings, key, 3); @@ -69,8 +69,8 @@ void Eluna::OnSkillChange(Player* pPlayer, uint32 skillId, uint32 skillValue) void Eluna::OnLearnSpell(Player* pPlayer, uint32 spellId) { START_HOOK(PLAYER_EVENT_ON_LEARN_SPELL); - Push(pPlayer); - Push(spellId); + HookPush(pPlayer); + HookPush(spellId); CallAllFunctions(PlayerEventBindings, key); } @@ -166,9 +166,9 @@ void Eluna::OnQuestAbandon(Player* pPlayer, uint32 questId) void Eluna::OnQuestStatusChanged(Player* pPlayer, uint32 questId, uint8 status) { START_HOOK(PLAYER_EVENT_ON_QUEST_STATUS_CHANGED); - Push(pPlayer); - Push(questId); - Push(status); + HookPush(pPlayer); + HookPush(questId); + HookPush(status); CallAllFunctions(PlayerEventBindings, key); } @@ -245,8 +245,8 @@ void Eluna::OnPlayerKilledByCreature(Creature* pKiller, Player* pKilled) void Eluna::OnPlayerKilledByEnvironment(Player* pKilled, uint8 damageType) { START_HOOK(PLAYER_EVENT_ON_ENVIRONMENTAL_DEATH); - Push(pKilled); - Push(damageType); + HookPush(pKilled); + HookPush(damageType); CallAllFunctions(PlayerEventBindings, key); } @@ -488,9 +488,9 @@ void Eluna::OnUpdateZone(Player* pPlayer, uint32 newZone, uint32 newArea) void Eluna::OnUpdateArea(Player* pPlayer, uint32 oldArea, uint32 newArea) { START_HOOK(PLAYER_EVENT_ON_UPDATE_AREA); - Push(pPlayer); - Push(oldArea); - Push(newArea); + HookPush(pPlayer); + HookPush(oldArea); + HookPush(newArea); CallAllFunctions(PlayerEventBindings, key); } @@ -504,32 +504,32 @@ void Eluna::OnMapChanged(Player* player) void Eluna::OnAchievementComplete(Player* player, uint32 achievementId) { START_HOOK(PLAYER_EVENT_ON_ACHIEVEMENT_COMPLETE); - Push(player); - Push(achievementId); + HookPush(player); + HookPush(achievementId); CallAllFunctions(PlayerEventBindings, key); } bool Eluna::OnTradeInit(Player* trader, Player* tradee) { START_HOOK_WITH_RETVAL(PLAYER_EVENT_ON_TRADE_INIT, true); - Push(trader); - Push(tradee); + HookPush(trader); + HookPush(tradee); return CallAllFunctionsBool(PlayerEventBindings, key, true); } bool Eluna::OnTradeAccept(Player* trader, Player* tradee) { START_HOOK_WITH_RETVAL(PLAYER_EVENT_ON_TRADE_ACCEPT, true); - Push(trader); - Push(tradee); + HookPush(trader); + HookPush(tradee); return CallAllFunctionsBool(PlayerEventBindings, key, true); } bool Eluna::OnSendMail(Player* sender, ObjectGuid recipientGuid) { START_HOOK_WITH_RETVAL(PLAYER_EVENT_ON_SEND_MAIL, true); - Push(sender); - Push(recipientGuid); + HookPush(sender); + HookPush(recipientGuid); return CallAllFunctionsBool(PlayerEventBindings, key, true); } diff --git a/TrinityCore/AuraMethods.h b/TrinityCore/AuraMethods.h index d8add26853..90da5c95f7 100644 --- a/TrinityCore/AuraMethods.h +++ b/TrinityCore/AuraMethods.h @@ -26,9 +26,9 @@ namespace LuaAura * * @return [Unit] caster */ - int GetCaster(lua_State* L, Aura* aura) + int GetCaster(Eluna* E, Aura* aura) { - Eluna::Push(L, aura->GetCaster()); + E->Push(aura->GetCaster()); return 1; } @@ -37,9 +37,9 @@ namespace LuaAura * * @return string caster_guid : the GUID of the Unit as a decimal string */ - int GetCasterGUID(lua_State* L, Aura* aura) + int GetCasterGUID(Eluna* E, Aura* aura) { - Eluna::Push(L, aura->GetCasterGUID()); + E->Push(aura->GetCasterGUID()); return 1; } @@ -48,9 +48,9 @@ namespace LuaAura * * @return uint32 caster_level */ - int GetCasterLevel(lua_State* L, Aura* aura) + int GetCasterLevel(Eluna* E, Aura* aura) { - Eluna::Push(L, aura->GetCaster()->GetLevel()); + E->Push(aura->GetCaster()->GetLevel()); return 1; } @@ -59,9 +59,9 @@ namespace LuaAura * * @return int32 duration : amount of time left in milliseconds */ - int GetDuration(lua_State* L, Aura* aura) + int GetDuration(Eluna* E, Aura* aura) { - Eluna::Push(L, aura->GetDuration()); + E->Push(aura->GetDuration()); return 1; } @@ -70,9 +70,9 @@ namespace LuaAura * * @return uint32 aura_id */ - int GetAuraId(lua_State* L, Aura* aura) + int GetAuraId(Eluna* E, Aura* aura) { - Eluna::Push(L, aura->GetId()); + E->Push(aura->GetId()); return 1; } @@ -84,9 +84,9 @@ namespace LuaAura * * @return int32 max_duration : the maximum duration of the Aura, in milliseconds */ - int GetMaxDuration(lua_State* L, Aura* aura) + int GetMaxDuration(Eluna* E, Aura* aura) { - Eluna::Push(L, aura->GetMaxDuration()); + E->Push(aura->GetMaxDuration()); return 1; } @@ -97,9 +97,9 @@ namespace LuaAura * * @return uint32 stack_amount */ - int GetStackAmount(lua_State* L, Aura* aura) + int GetStackAmount(Eluna* E, Aura* aura) { - Eluna::Push(L, aura->GetStackAmount()); + E->Push(aura->GetStackAmount()); return 1; } @@ -108,9 +108,9 @@ namespace LuaAura * * @return [Unit] owner */ - int GetOwner(lua_State* L, Aura* aura) + int GetOwner(Eluna* E, Aura* aura) { - Eluna::Push(L, aura->GetOwner()); + E->Push(aura->GetOwner()); return 1; } @@ -119,9 +119,9 @@ namespace LuaAura * * @param int32 duration : the new duration of the Aura, in milliseconds */ - int SetDuration(lua_State* L, Aura* aura) + int SetDuration(Eluna* E, Aura* aura) { - int32 duration = Eluna::CHECKVAL(L, 2); + int32 duration = Eluna::CHECKVAL(E->L, 2); aura->SetDuration(duration); return 0; @@ -135,9 +135,9 @@ namespace LuaAura * * @param int32 duration : the new maximum duration of the Aura, in milliseconds */ - int SetMaxDuration(lua_State* L, Aura* aura) + int SetMaxDuration(Eluna* E, Aura* aura) { - int32 duration = Eluna::CHECKVAL(L, 2); + int32 duration = Eluna::CHECKVAL(E->L, 2); aura->SetMaxDuration(duration); return 0; @@ -151,9 +151,9 @@ namespace LuaAura * * @param uint32 amount */ - int SetStackAmount(lua_State* L, Aura* aura) + int SetStackAmount(Eluna* E, Aura* aura) { - uint8 amount = Eluna::CHECKVAL(L, 2); + uint8 amount = Eluna::CHECKVAL(E->L, 2); aura->SetStackAmount(amount); return 0; @@ -162,10 +162,10 @@ namespace LuaAura /** * Remove this [Aura] from the [Unit] it is applied to. */ - int Remove(lua_State* L, Aura* aura) + int Remove(Eluna* E, Aura* aura) { aura->Remove(); - Eluna::CHECKOBJ(L, 1)->Invalidate(); + Eluna::CHECKOBJ(E->L, 1)->Invalidate(); return 0; } diff --git a/TrinityCore/BattleGroundMethods.h b/TrinityCore/BattleGroundMethods.h index 6ce153d821..34cf1552af 100644 --- a/TrinityCore/BattleGroundMethods.h +++ b/TrinityCore/BattleGroundMethods.h @@ -19,9 +19,9 @@ namespace LuaBattleGround * * @return string name */ - int GetName(lua_State* L, BattleGround* bg) + int GetName(Eluna* E, BattleGround* bg) { - Eluna::Push(L, bg->GetName()); + E->Push(bg->GetName()); return 1; } @@ -31,11 +31,11 @@ namespace LuaBattleGround * @param [Team] team : team ID * @return uint32 count */ - int GetAlivePlayersCountByTeam(lua_State* L, BattleGround* bg) + int GetAlivePlayersCountByTeam(Eluna* E, BattleGround* bg) { - uint32 team = Eluna::CHECKVAL(L, 2); + uint32 team = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, bg->GetAlivePlayersCountByTeam((Team)team)); + E->Push(bg->GetAlivePlayersCountByTeam((Team)team)); return 1; } @@ -44,9 +44,9 @@ namespace LuaBattleGround * * @return [Map] map */ - int GetMap(lua_State* L, BattleGround* bg) + int GetMap(Eluna* E, BattleGround* bg) { - Eluna::Push(L, static_cast(bg->GetBgMap())); + E->Push(static_cast(bg->GetBgMap())); return 1; } @@ -56,11 +56,11 @@ namespace LuaBattleGround * @param uint32 kills : amount of kills * @return uint32 bonusHonor */ - int GetBonusHonorFromKillCount(lua_State* L, BattleGround* bg) + int GetBonusHonorFromKillCount(Eluna* E, BattleGround* bg) { - uint32 kills = Eluna::CHECKVAL(L, 2); + uint32 kills = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, bg->GetBonusHonorFromKill(kills)); + E->Push(bg->GetBonusHonorFromKill(kills)); return 1; } @@ -69,9 +69,9 @@ namespace LuaBattleGround * * @return [BattleGroundBracketId] bracketId */ - int GetBracketId(lua_State* L, BattleGround* bg) + int GetBracketId(Eluna* E, BattleGround* bg) { - Eluna::Push(L, bg->GetBracketId()); + E->Push(bg->GetBracketId()); return 1; } @@ -80,12 +80,12 @@ namespace LuaBattleGround * * @return uint32 endTime */ - int GetEndTime(lua_State* L, BattleGround* bg) + int GetEndTime(Eluna* E, BattleGround* bg) { #ifdef CATA - Eluna::Push(L, bg->GetRemainingTime()); + E->Push(bg->GetRemainingTime()); #else - Eluna::Push(L, bg->GetEndTime()); + E->Push(bg->GetEndTime()); #endif return 1; } @@ -96,11 +96,11 @@ namespace LuaBattleGround * @param [Team] team : team ID * @return uint32 freeSlots */ - int GetFreeSlotsForTeam(lua_State* L, BattleGround* bg) + int GetFreeSlotsForTeam(Eluna* E, BattleGround* bg) { - uint32 team = Eluna::CHECKVAL(L, 2); + uint32 team = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, bg->GetFreeSlotsForTeam((Team)team)); + E->Push(bg->GetFreeSlotsForTeam((Team)team)); return 1; } @@ -109,9 +109,9 @@ namespace LuaBattleGround * * @return uint32 instanceId */ - int GetInstanceId(lua_State* L, BattleGround* bg) + int GetInstanceId(Eluna* E, BattleGround* bg) { - Eluna::Push(L, bg->GetInstanceID()); + E->Push(bg->GetInstanceID()); return 1; } @@ -120,9 +120,9 @@ namespace LuaBattleGround * * @return uint32 mapId */ - int GetMapId(lua_State* L, BattleGround* bg) + int GetMapId(Eluna* E, BattleGround* bg) { - Eluna::Push(L, bg->GetMapId()); + E->Push(bg->GetMapId()); return 1; } @@ -131,9 +131,9 @@ namespace LuaBattleGround * * @return [BattleGroundTypeId] typeId */ - int GetTypeId(lua_State* L, BattleGround* bg) + int GetTypeId(Eluna* E, BattleGround* bg) { - Eluna::Push(L, bg->GetTypeID()); + E->Push(bg->GetTypeID()); return 1; } @@ -142,9 +142,9 @@ namespace LuaBattleGround * * @return uint32 maxLevel */ - int GetMaxLevel(lua_State* L, BattleGround* bg) + int GetMaxLevel(Eluna* E, BattleGround* bg) { - Eluna::Push(L, bg->GetMaxLevel()); + E->Push(bg->GetMaxLevel()); return 1; } @@ -153,9 +153,9 @@ namespace LuaBattleGround * * @return uint32 minLevel */ - int GetMinLevel(lua_State* L, BattleGround* bg) + int GetMinLevel(Eluna* E, BattleGround* bg) { - Eluna::Push(L, bg->GetMinLevel()); + E->Push(bg->GetMinLevel()); return 1; } @@ -164,9 +164,9 @@ namespace LuaBattleGround * * @return uint32 maxPlayerCount */ - int GetMaxPlayers(lua_State* L, BattleGround* bg) + int GetMaxPlayers(Eluna* E, BattleGround* bg) { - Eluna::Push(L, bg->GetMaxPlayers()); + E->Push(bg->GetMaxPlayers()); return 1; } @@ -175,9 +175,9 @@ namespace LuaBattleGround * * @return uint32 minPlayerCount */ - int GetMinPlayers(lua_State* L, BattleGround* bg) + int GetMinPlayers(Eluna* E, BattleGround* bg) { - Eluna::Push(L, bg->GetMinPlayers()); + E->Push(bg->GetMinPlayers()); return 1; } @@ -186,9 +186,9 @@ namespace LuaBattleGround * * @return uint32 maxTeamPlayerCount */ - int GetMaxPlayersPerTeam(lua_State* L, BattleGround* bg) + int GetMaxPlayersPerTeam(Eluna* E, BattleGround* bg) { - Eluna::Push(L, bg->GetMaxPlayersPerTeam()); + E->Push(bg->GetMaxPlayersPerTeam()); return 1; } @@ -197,9 +197,9 @@ namespace LuaBattleGround * * @return uint32 minTeamPlayerCount */ - int GetMinPlayersPerTeam(lua_State* L, BattleGround* bg) + int GetMinPlayersPerTeam(Eluna* E, BattleGround* bg) { - Eluna::Push(L, bg->GetMinPlayersPerTeam()); + E->Push(bg->GetMinPlayersPerTeam()); return 1; } @@ -208,9 +208,9 @@ namespace LuaBattleGround * * @return [Team] team */ - int GetWinner(lua_State* L, BattleGround* bg) + int GetWinner(Eluna* E, BattleGround* bg) { - Eluna::Push(L, bg->GetWinner()); + E->Push(bg->GetWinner()); return 1; } @@ -219,9 +219,9 @@ namespace LuaBattleGround * * @return [BattleGroundStatus] status */ - int GetStatus(lua_State* L, BattleGround* bg) + int GetStatus(Eluna* E, BattleGround* bg) { - Eluna::Push(L, bg->GetStatus()); + E->Push(bg->GetStatus()); return 1; } diff --git a/TrinityCore/CorpseMethods.h b/TrinityCore/CorpseMethods.h index 4e724e4a59..60e1eca6c8 100644 --- a/TrinityCore/CorpseMethods.h +++ b/TrinityCore/CorpseMethods.h @@ -19,9 +19,9 @@ namespace LuaCorpse * * @return ObjectGuid ownerGUID */ - int GetOwnerGUID(lua_State* L, Corpse* corpse) + int GetOwnerGUID(Eluna* E, Corpse* corpse) { - Eluna::Push(L, corpse->GetOwnerGUID()); + E->Push(corpse->GetOwnerGUID()); return 1; } @@ -30,9 +30,9 @@ namespace LuaCorpse * * @return uint32 ghostTime */ - int GetGhostTime(lua_State* L, Corpse* corpse) + int GetGhostTime(Eluna* E, Corpse* corpse) { - Eluna::Push(L, corpse->GetGhostTime()); + E->Push(corpse->GetGhostTime()); return 1; } @@ -48,9 +48,9 @@ namespace LuaCorpse * * @return [CorpseType] corpseType */ - int GetType(lua_State* L, Corpse* corpse) + int GetType(Eluna* E, Corpse* corpse) { - Eluna::Push(L, corpse->GetType()); + E->Push(corpse->GetType()); return 1; } @@ -59,7 +59,7 @@ namespace LuaCorpse * * See [Corpse:GetGhostTime]. */ - int ResetGhostTime(lua_State* /*L*/, Corpse* corpse) + int ResetGhostTime(Eluna* /*E*/, Corpse* corpse) { corpse->ResetGhostTime(); return 0; @@ -68,7 +68,7 @@ namespace LuaCorpse /** * Saves the [Corpse] to the database. */ - int SaveToDB(lua_State* /*L*/, Corpse* corpse) + int SaveToDB(Eluna* /*E*/, Corpse* corpse) { corpse->SaveToDB(); return 0; diff --git a/TrinityCore/CreatureMethods.h b/TrinityCore/CreatureMethods.h index 5892cf896e..147fe51c96 100644 --- a/TrinityCore/CreatureMethods.h +++ b/TrinityCore/CreatureMethods.h @@ -20,12 +20,12 @@ namespace LuaCreature * * @return bool isRegenerating */ - int IsRegeneratingHealth(lua_State* L, Creature* creature) + int IsRegeneratingHealth(Eluna* E, Creature* creature) { #ifdef CATA - Eluna::Push(L, creature->isRegeneratingHealth()); + E->Push(creature->isRegeneratingHealth()); #else - Eluna::Push(L, creature->CanRegenerateHealth()); + E->Push(creature->CanRegenerateHealth()); #endif return 1; } @@ -35,9 +35,9 @@ namespace LuaCreature * * @param bool enable = true : `true` to enable health regeneration, `false` to disable it */ - int SetRegeneratingHealth(lua_State* L, Creature* creature) + int SetRegeneratingHealth(Eluna* E, Creature* creature) { - bool enable = Eluna::CHECKVAL(L, 2, true); + bool enable = Eluna::CHECKVAL(E->L, 2, true); creature->SetRegenerateHealth(enable); return 0; @@ -49,9 +49,9 @@ namespace LuaCreature * * @return bool reputationDisabled */ - int IsReputationGainDisabled(lua_State* L, Creature* creature) + int IsReputationGainDisabled(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->IsReputationGainDisabled()); + E->Push(creature->IsReputationGainDisabled()); return 1; } @@ -62,11 +62,11 @@ namespace LuaCreature * @param uint32 questID : the ID of a [Quest] * @return bool completesQuest */ - int CanCompleteQuest(lua_State* L, Creature* creature) + int CanCompleteQuest(Eluna* E, Creature* creature) { - uint32 quest_id = Eluna::CHECKVAL(L, 2); + uint32 quest_id = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, creature->hasInvolvedQuest(quest_id)); + E->Push(creature->hasInvolvedQuest(quest_id)); return 1; } @@ -77,11 +77,11 @@ namespace LuaCreature * @param bool mustBeDead = false : if `true`, only returns `true` if the [Creature] is also dead. Otherwise, it must be alive. * @return bool targetable */ - int IsTargetableForAttack(lua_State* L, Creature* creature) + int IsTargetableForAttack(Eluna* E, Creature* creature) { - bool mustBeDead = Eluna::CHECKVAL(L, 2, false); + bool mustBeDead = Eluna::CHECKVAL(E->L, 2, false); - Eluna::Push(L, creature->isTargetableForAttack(mustBeDead)); + E->Push(creature->isTargetableForAttack(mustBeDead)); return 1; } @@ -94,13 +94,13 @@ namespace LuaCreature * @param bool checkFaction = true : if `true`, the [Creature] must be the same faction as `friend` to assist * @return bool canAssist */ - int CanAssistTo(lua_State* L, Creature* creature) + int CanAssistTo(Eluna* E, Creature* creature) { - Unit* u = Eluna::CHECKOBJ(L, 2); - Unit* enemy = Eluna::CHECKOBJ(L, 3); - bool checkfaction = Eluna::CHECKVAL(L, 4, true); + Unit* u = Eluna::CHECKOBJ(E->L, 2); + Unit* enemy = Eluna::CHECKOBJ(E->L, 3); + bool checkfaction = Eluna::CHECKVAL(E->L, 4, true); - Eluna::Push(L, creature->CanAssistTo(u, enemy, checkfaction)); + E->Push(creature->CanAssistTo(u, enemy, checkfaction)); return 1; } @@ -110,9 +110,9 @@ namespace LuaCreature * * @return bool searchedForAssistance */ - int HasSearchedAssistance(lua_State* L, Creature* creature) + int HasSearchedAssistance(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->HasSearchedAssistance()); + E->Push(creature->HasSearchedAssistance()); return 1; } @@ -122,11 +122,11 @@ namespace LuaCreature * * @return bool tapped */ - int IsTappedBy(lua_State* L, Creature* creature) + int IsTappedBy(Eluna* E, Creature* creature) { - Player* player = Eluna::CHECKOBJ(L, 2); + Player* player = Eluna::CHECKOBJ(E->L, 2); - Eluna::Push(L, creature->isTappedBy(player)); + E->Push(creature->isTappedBy(player)); return 1; } @@ -136,9 +136,9 @@ namespace LuaCreature * * @return bool hasLootRecipient */ - int HasLootRecipient(lua_State* L, Creature* creature) + int HasLootRecipient(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->hasLootRecipient()); + E->Push(creature->hasLootRecipient()); return 1; } @@ -148,9 +148,9 @@ namespace LuaCreature * * @return bool canAggro */ - int CanAggro(lua_State* L, Creature* creature) + int CanAggro(Eluna* E, Creature* creature) { - Eluna::Push(L, !creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC)); + E->Push(!creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC)); return 1; } @@ -160,9 +160,9 @@ namespace LuaCreature * * @return bool canSwim */ - int CanSwim(lua_State* L, Creature* creature) + int CanSwim(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->CanSwim()); + E->Push(creature->CanSwim()); return 1; } @@ -172,9 +172,9 @@ namespace LuaCreature * * @return bool canWalk */ - int CanWalk(lua_State* L, Creature* creature) + int CanWalk(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->CanWalk()); + E->Push(creature->CanWalk()); return 1; } @@ -184,9 +184,9 @@ namespace LuaCreature * * @return bool inEvadeMode */ - int IsInEvadeMode(lua_State* L, Creature* creature) + int IsInEvadeMode(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->IsInEvadeMode()); + E->Push(creature->IsInEvadeMode()); return 1; } @@ -196,9 +196,9 @@ namespace LuaCreature * * @return bool isElite */ - int IsElite(lua_State* L, Creature* creature) + int IsElite(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->isElite()); + E->Push(creature->isElite()); return 1; } @@ -208,9 +208,9 @@ namespace LuaCreature * * @return bool isGuard */ - int IsGuard(lua_State* L, Creature* creature) + int IsGuard(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->IsGuard()); + E->Push(creature->IsGuard()); return 1; } @@ -220,9 +220,9 @@ namespace LuaCreature * * @return bool isCivilian */ - int IsCivilian(lua_State* L, Creature* creature) + int IsCivilian(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->IsCivilian()); + E->Push(creature->IsCivilian()); return 1; } @@ -232,9 +232,9 @@ namespace LuaCreature * * @return bool isLeader */ - int IsRacialLeader(lua_State* L, Creature* creature) + int IsRacialLeader(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->IsRacialLeader()); + E->Push(creature->IsRacialLeader()); return 1; } @@ -244,9 +244,9 @@ namespace LuaCreature * * @return bool isDungeonBoss */ - int IsDungeonBoss(lua_State* L, Creature* creature) + int IsDungeonBoss(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->IsDungeonBoss()); + E->Push(creature->IsDungeonBoss()); return 1; } @@ -257,9 +257,9 @@ namespace LuaCreature * * @return bool isWorldBoss */ - int IsWorldBoss(lua_State* L, Creature* creature) + int IsWorldBoss(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->isWorldBoss()); + E->Push(creature->isWorldBoss()); return 1; } @@ -270,14 +270,14 @@ namespace LuaCreature * @param uint32 spellId : the ID of a [Spell] * @return bool hasCooldown */ - int HasCategoryCooldown(lua_State* L, Creature* creature) + int HasCategoryCooldown(Eluna* E, Creature* creature) { - uint32 spell = Eluna::CHECKVAL(L, 2); + uint32 spell = Eluna::CHECKVAL(E->L, 2); if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell)) - Eluna::Push(L, info->GetCategory() && creature->GetSpellHistory()->HasCooldown(spell)); + E->Push(info->GetCategory() && creature->GetSpellHistory()->HasCooldown(spell)); else - Eluna::Push(L, false); + E->Push(false); return 1; } @@ -289,11 +289,11 @@ namespace LuaCreature * @param uint32 spellId : the ID of a [Spell] * @return bool hasSpell */ - int HasSpell(lua_State* L, Creature* creature) + int HasSpell(Eluna* E, Creature* creature) { - uint32 id = Eluna::CHECKVAL(L, 2); + uint32 id = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, creature->HasSpell(id)); + E->Push(creature->HasSpell(id)); return 1; } @@ -304,11 +304,11 @@ namespace LuaCreature * @param uint32 questId : the ID of a [Quest] * @return bool hasQuest */ - int HasQuest(lua_State* L, Creature* creature) + int HasQuest(Eluna* E, Creature* creature) { - uint32 questId = Eluna::CHECKVAL(L, 2); + uint32 questId = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, creature->hasQuest(questId)); + E->Push(creature->hasQuest(questId)); return 1; } @@ -319,11 +319,11 @@ namespace LuaCreature * @param uint32 spellId : the ID of a [Spell] * @return bool hasCooldown */ - int HasSpellCooldown(lua_State* L, Creature* creature) + int HasSpellCooldown(Eluna* E, Creature* creature) { - uint32 spellId = Eluna::CHECKVAL(L, 2); + uint32 spellId = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, creature->GetSpellHistory()->HasCooldown(spellId)); + E->Push(creature->GetSpellHistory()->HasCooldown(spellId)); return 1; } @@ -333,9 +333,9 @@ namespace LuaCreature * * @return bool canFly */ - int CanFly(lua_State* L, Creature* creature) + int CanFly(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->CanFly()); + E->Push(creature->CanFly()); return 1; } @@ -345,9 +345,9 @@ namespace LuaCreature * * @return bool canFly */ - int IsTrigger(lua_State* L, Creature* creature) + int IsTrigger(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->IsTrigger()); + E->Push(creature->IsTrigger()); return 1; } @@ -356,9 +356,9 @@ namespace LuaCreature * * @return bool isDamagedEnough */ - int IsDamageEnoughForLootingAndReward(lua_State* L, Creature* creature) + int IsDamageEnoughForLootingAndReward(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->IsDamageEnoughForLootingAndReward()); + E->Push(creature->IsDamageEnoughForLootingAndReward()); return 1; } @@ -370,12 +370,12 @@ namespace LuaCreature * @param [Unit] target * @param bool force = true : force [Creature] to attack */ - int CanStartAttack(lua_State* L, Creature* creature) + int CanStartAttack(Eluna* E, Creature* creature) { - Unit* target = Eluna::CHECKOBJ(L, 2); - bool force = Eluna::CHECKVAL(L, 3, true); + Unit* target = Eluna::CHECKOBJ(E->L, 2); + bool force = Eluna::CHECKVAL(E->L, 3, true); - Eluna::Push(L, creature->CanStartAttack(target, force)); + E->Push(creature->CanStartAttack(target, force)); return 1; } @@ -385,11 +385,11 @@ namespace LuaCreature * @param uint16 lootMode * @return bool hasLootMode */ - int HasLootMode(lua_State* L, Creature* creature) + int HasLootMode(Eluna* E, Creature* creature) { - uint16 lootMode = Eluna::CHECKVAL(L, 2); + uint16 lootMode = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, creature->HasLootMode(lootMode)); + E->Push(creature->HasLootMode(lootMode)); return 1; } @@ -401,9 +401,9 @@ namespace LuaCreature * * @return uint32 respawnDelay : the respawn delay, in seconds */ - int GetRespawnDelay(lua_State* L, Creature* creature) + int GetRespawnDelay(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->GetRespawnDelay()); + E->Push(creature->GetRespawnDelay()); return 1; } @@ -413,9 +413,9 @@ namespace LuaCreature * * @return float wanderRadius */ - int GetWanderRadius(lua_State* L, Creature* creature) + int GetWanderRadius(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->GetWanderDistance()); + E->Push(creature->GetWanderDistance()); return 1; } @@ -424,9 +424,9 @@ namespace LuaCreature * * @return uint32 pathId */ - int GetWaypointPath(lua_State* L, Creature* creature) + int GetWaypointPath(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->GetWaypointPath()); + E->Push(creature->GetWaypointPath()); return 1; } @@ -435,9 +435,9 @@ namespace LuaCreature * * @return uint32 wpId */ - int GetCurrentWaypointId(lua_State* L, Creature* creature) + int GetCurrentWaypointId(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->GetCurrentWaypointInfo().first); + E->Push(creature->GetCurrentWaypointInfo().first); return 1; } @@ -446,9 +446,9 @@ namespace LuaCreature * * @return [MovementGeneratorType] defaultMovementType */ - int GetDefaultMovementType(lua_State* L, Creature* creature) + int GetDefaultMovementType(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->GetDefaultMovementType()); + E->Push(creature->GetDefaultMovementType()); return 1; } @@ -458,11 +458,11 @@ namespace LuaCreature * @param [Unit] target * @return float aggroRange */ - int GetAggroRange(lua_State* L, Creature* creature) + int GetAggroRange(Eluna* E, Creature* creature) { - Unit* target = Eluna::CHECKOBJ(L, 2); + Unit* target = Eluna::CHECKOBJ(E->L, 2); - Eluna::Push(L, creature->GetAggroRange(target)); + E->Push(creature->GetAggroRange(target)); return 1; } @@ -475,11 +475,11 @@ namespace LuaCreature * @param [Unit] target * @return float attackDistance */ - int GetAttackDistance(lua_State* L, Creature* creature) + int GetAttackDistance(Eluna* E, Creature* creature) { - Unit* target = Eluna::CHECKOBJ(L, 2); + Unit* target = Eluna::CHECKOBJ(E->L, 2); - Eluna::Push(L, creature->GetAttackDistance(target)); + E->Push(creature->GetAttackDistance(target)); return 1; } @@ -489,9 +489,9 @@ namespace LuaCreature * * @return [Group] lootRecipientGroup : the group or `nil` */ - int GetLootRecipientGroup(lua_State* L, Creature* creature) + int GetLootRecipientGroup(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->GetLootRecipientGroup()); + E->Push(creature->GetLootRecipientGroup()); return 1; } @@ -500,9 +500,9 @@ namespace LuaCreature * * @return [Player] lootRecipient : the player or `nil` */ - int GetLootRecipient(lua_State* L, Creature* creature) + int GetLootRecipient(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->GetLootRecipient()); + E->Push(creature->GetLootRecipient()); return 1; } @@ -515,9 +515,9 @@ namespace LuaCreature * * @return string scriptName */ - int GetScriptName(lua_State* L, Creature* creature) + int GetScriptName(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->GetScriptName()); + E->Push(creature->GetScriptName()); return 1; } @@ -530,9 +530,9 @@ namespace LuaCreature * * @return string AIName */ - int GetAIName(lua_State* L, Creature* creature) + int GetAIName(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->GetAIName()); + E->Push(creature->GetAIName()); return 1; } @@ -544,9 +544,9 @@ namespace LuaCreature * * @return uint32 scriptID */ - int GetScriptId(lua_State* L, Creature* creature) + int GetScriptId(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->GetScriptId()); + E->Push(creature->GetScriptId()); return 1; } @@ -556,14 +556,14 @@ namespace LuaCreature * @param uint32 spellID * @return uint32 cooldown : the cooldown, in milliseconds */ - int GetCreatureSpellCooldownDelay(lua_State* L, Creature* creature) + int GetCreatureSpellCooldownDelay(Eluna* E, Creature* creature) { - uint32 spell = Eluna::CHECKVAL(L, 2); + uint32 spell = Eluna::CHECKVAL(E->L, 2); if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell)) - Eluna::Push(L, creature->GetSpellHistory()->GetRemainingCooldown(spellInfo)); + E->Push(creature->GetSpellHistory()->GetRemainingCooldown(spellInfo)); else - Eluna::Push(L, 0); + E->Push(0); return 1; } @@ -573,9 +573,9 @@ namespace LuaCreature * * @return uint32 corpseDelay : the delay, in seconds */ - int GetCorpseDelay(lua_State* L, Creature* creature) + int GetCorpseDelay(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->GetCorpseDelay()); + E->Push(creature->GetCorpseDelay()); return 1; } @@ -588,15 +588,15 @@ namespace LuaCreature * @return float z * @return float o */ - int GetHomePosition(lua_State* L, Creature* creature) + int GetHomePosition(Eluna* E, Creature* creature) { float x, y, z, o; creature->GetHomePosition(x, y, z, o); - Eluna::Push(L, x); - Eluna::Push(L, y); - Eluna::Push(L, z); - Eluna::Push(L, o); + E->Push(x); + E->Push(y); + E->Push(z); + E->Push(o); return 4; } @@ -609,12 +609,12 @@ namespace LuaCreature * @param float z * @param float o */ - int SetHomePosition(lua_State* L, Creature* creature) + int SetHomePosition(Eluna* E, Creature* creature) { - float x = Eluna::CHECKVAL(L, 2); - float y = Eluna::CHECKVAL(L, 3); - float z = Eluna::CHECKVAL(L, 4); - float o = Eluna::CHECKVAL(L, 5); + float x = Eluna::CHECKVAL(E->L, 2); + float y = Eluna::CHECKVAL(E->L, 3); + float z = Eluna::CHECKVAL(E->L, 4); + float o = Eluna::CHECKVAL(E->L, 5); creature->SetHomePosition(x, y, z, o); return 0; @@ -655,13 +655,13 @@ namespace LuaCreature * @param int32 aura = 0 : if positive, the target must have this [Aura]. If negative, the the target must not have this Aura * @return [Unit] target : the target, or `nil` */ - int GetAITarget(lua_State* L, Creature* creature) + int GetAITarget(Eluna* E, Creature* creature) { - uint32 targetType = Eluna::CHECKVAL(L, 2); - bool playerOnly = Eluna::CHECKVAL(L, 3, false); - uint32 position = Eluna::CHECKVAL(L, 4, 0); - float dist = Eluna::CHECKVAL(L, 5, 0.0f); - int32 aura = Eluna::CHECKVAL(L, 6, 0); + uint32 targetType = Eluna::CHECKVAL(E->L, 2); + bool playerOnly = Eluna::CHECKVAL(E->L, 3, false); + uint32 position = Eluna::CHECKVAL(E->L, 4, 0); + float dist = Eluna::CHECKVAL(E->L, 5, 0.0f); + int32 aura = Eluna::CHECKVAL(E->L, 6, 0); auto const& threatlist = creature->GetThreatManager().GetSortedThreatList(); std::list targetList; @@ -699,7 +699,7 @@ namespace LuaCreature std::list::const_iterator itr = targetList.begin(); if (position) std::advance(itr, position); - Eluna::Push(L, *itr); + E->Push(*itr); } break; case SELECT_TARGET_FARTHEST: @@ -708,7 +708,7 @@ namespace LuaCreature std::list::reverse_iterator ritr = targetList.rbegin(); if (position) std::advance(ritr, position); - Eluna::Push(L, *ritr); + E->Push(*ritr); } break; case SELECT_TARGET_RANDOM: @@ -718,11 +718,11 @@ namespace LuaCreature std::advance(itr, urand(0, position)); else std::advance(itr, urand(0, targetList.size() - 1)); - Eluna::Push(L, *itr); + E->Push(*itr); } break; default: - luaL_argerror(L, 2, "SelectAggroTarget expected"); + luaL_argerror(E->L, 2, "SelectAggroTarget expected"); break; } @@ -734,12 +734,12 @@ namespace LuaCreature * * @return table targets */ - int GetAITargets(lua_State* L, Creature* creature) + int GetAITargets(Eluna* E, Creature* creature) { auto const& threatlist = creature->GetThreatManager().GetSortedThreatList(); - lua_createtable(L, creature->GetThreatManager().GetThreatListSize(), 0); - int tbl = lua_gettop(L); + lua_createtable(E->L, creature->GetThreatManager().GetThreatListSize(), 0); + int tbl = lua_gettop(E->L); uint32 i = 0; for (ThreatReference const* itr : threatlist) @@ -747,11 +747,11 @@ namespace LuaCreature Unit* target = itr->GetVictim(); if (!target) continue; - Eluna::Push(L, target); - lua_rawseti(L, tbl, ++i); + E->Push(target); + lua_rawseti(E->L, tbl, ++i); } - lua_settop(L, tbl); + lua_settop(E->L, tbl); return 1; } @@ -760,9 +760,9 @@ namespace LuaCreature * * @return double targetsCount */ - int GetAITargetsCount(lua_State* L, Creature* creature) + int GetAITargetsCount(Eluna* E, Creature* creature) { - Eluna::Push(L, (double)creature->GetThreatManager().GetThreatListSize()); + E->Push((double)creature->GetThreatManager().GetThreatListSize()); return 1; } @@ -774,9 +774,9 @@ namespace LuaCreature * * @return [NPCFlags] npcFlags */ - int GetNPCFlags(lua_State* L, Creature* creature) + int GetNPCFlags(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->GetUInt32Value(UNIT_NPC_FLAGS)); + E->Push(creature->GetUInt32Value(UNIT_NPC_FLAGS)); return 1; } @@ -788,9 +788,9 @@ namespace LuaCreature * * @return [ExtraFlags] extraFlags */ - int GetExtraFlags(lua_State* L, Creature* creature) + int GetExtraFlags(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->GetCreatureTemplate()->flags_extra); + E->Push(creature->GetCreatureTemplate()->flags_extra); return 1; } @@ -800,16 +800,16 @@ namespace LuaCreature * * @return uint32 shieldBlockValue */ - int GetShieldBlockValue(lua_State* L, Creature* creature) + int GetShieldBlockValue(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->GetShieldBlockValue()); + E->Push(creature->GetShieldBlockValue()); return 1; } #endif - int GetLootMode(lua_State* L, Creature* creature) + int GetLootMode(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->GetLootMode()); + E->Push(creature->GetLootMode()); return 1; } @@ -819,9 +819,9 @@ namespace LuaCreature * * @return uint32 dbguid */ - int GetDBTableGUIDLow(lua_State* L, Creature* creature) + int GetDBTableGUIDLow(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->GetSpawnId()); + E->Push(creature->GetSpawnId()); return 1; } @@ -830,9 +830,9 @@ namespace LuaCreature * * @param [NPCFlags] flags */ - int SetNPCFlags(lua_State* L, Creature* creature) + int SetNPCFlags(Eluna* E, Creature* creature) { - uint32 flags = Eluna::CHECKVAL(L, 2); + uint32 flags = Eluna::CHECKVAL(E->L, 2); creature->SetUInt32Value(UNIT_NPC_FLAGS, flags); return 0; @@ -843,9 +843,9 @@ namespace LuaCreature * * @param [ReactState] state */ - int SetReactState(lua_State* L, Creature* creature) + int SetReactState(Eluna* E, Creature* creature) { - uint32 state = Eluna::CHECKVAL(L, 2); + uint32 state = Eluna::CHECKVAL(E->L, 2); creature->SetReactState((ReactStates)state); return 0; @@ -856,17 +856,17 @@ namespace LuaCreature * * @param bool disable */ - int SetDisableGravity(lua_State* L, Creature* creature) + int SetDisableGravity(Eluna* E, Creature* creature) { - bool disable = Eluna::CHECKVAL(L, 2); + bool disable = Eluna::CHECKVAL(E->L, 2); creature->SetDisableGravity(disable); return 0; } - int SetLootMode(lua_State* L, Creature* creature) + int SetLootMode(Eluna* E, Creature* creature) { - uint16 lootMode = Eluna::CHECKVAL(L, 2); + uint16 lootMode = Eluna::CHECKVAL(E->L, 2); creature->SetLootMode(lootMode); return 0; @@ -877,9 +877,9 @@ namespace LuaCreature * * @param [DeathState] deathState */ - int SetDeathState(lua_State* L, Creature* creature) + int SetDeathState(Eluna* E, Creature* creature) { - int32 state = Eluna::CHECKVAL(L, 2); + int32 state = Eluna::CHECKVAL(E->L, 2); creature->setDeathState((DeathState)state); return 0; @@ -890,9 +890,9 @@ namespace LuaCreature * * @param bool enable = true : `true` to enable walking, `false` for running */ - int SetWalk(lua_State* L, Creature* creature) // TODO: Move same to Player ? + int SetWalk(Eluna* E, Creature* creature) // TODO: Move same to Player ? { - bool enable = Eluna::CHECKVAL(L, 2, true); + bool enable = Eluna::CHECKVAL(E->L, 2, true); creature->SetWalk(enable); return 0; @@ -905,11 +905,11 @@ namespace LuaCreature * @param uint32 off_hand : off hand [Item]'s entry * @param uint32 ranged : ranged [Item]'s entry */ - int SetEquipmentSlots(lua_State* L, Creature* creature) + int SetEquipmentSlots(Eluna* E, Creature* creature) { - uint32 main_hand = Eluna::CHECKVAL(L, 2); - uint32 off_hand = Eluna::CHECKVAL(L, 3); - uint32 ranged = Eluna::CHECKVAL(L, 4); + uint32 main_hand = Eluna::CHECKVAL(E->L, 2); + uint32 off_hand = Eluna::CHECKVAL(E->L, 3); + uint32 ranged = Eluna::CHECKVAL(E->L, 4); creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, main_hand); creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, off_hand); @@ -922,9 +922,9 @@ namespace LuaCreature * * @param bool allow = true : `true` to allow aggro, `false` to disable aggro */ - int SetAggroEnabled(lua_State* L, Creature* creature) + int SetAggroEnabled(Eluna* E, Creature* creature) { - bool allow = Eluna::CHECKVAL(L, 2, true); + bool allow = Eluna::CHECKVAL(E->L, 2, true); if (allow) creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC); @@ -939,9 +939,9 @@ namespace LuaCreature * * @param bool disable = true : `true` to disable reputation, `false` to enable */ - int SetDisableReputationGain(lua_State* L, Creature* creature) + int SetDisableReputationGain(Eluna* E, Creature* creature) { - bool disable = Eluna::CHECKVAL(L, 2, true); + bool disable = Eluna::CHECKVAL(E->L, 2, true); creature->SetDisableReputationGain(disable); return 0; @@ -953,7 +953,7 @@ namespace LuaCreature * This is used by raid bosses to prevent Players from using out-of-combat * actions once the encounter has begun. */ - int SetInCombatWithZone(lua_State* /*L*/, Creature* creature) + int SetInCombatWithZone(Eluna* /*E*/, Creature* creature) { if (creature->IsAIEnabled()) creature->AI()->DoZoneInCombat(); @@ -966,9 +966,9 @@ namespace LuaCreature * * @param float distance */ - int SetWanderRadius(lua_State* L, Creature* creature) + int SetWanderRadius(Eluna* E, Creature* creature) { - float dist = Eluna::CHECKVAL(L, 2); + float dist = Eluna::CHECKVAL(E->L, 2); creature->SetWanderDistance(dist); return 0; @@ -979,9 +979,9 @@ namespace LuaCreature * * @param uint32 delay : the delay, in seconds */ - int SetRespawnDelay(lua_State* L, Creature* creature) + int SetRespawnDelay(Eluna* E, Creature* creature) { - uint32 delay = Eluna::CHECKVAL(L, 2); + uint32 delay = Eluna::CHECKVAL(E->L, 2); creature->SetRespawnDelay(delay); return 0; @@ -992,9 +992,9 @@ namespace LuaCreature * * @param [MovementGeneratorType] type */ - int SetDefaultMovementType(lua_State* L, Creature* creature) + int SetDefaultMovementType(Eluna* E, Creature* creature) { - int32 type = Eluna::CHECKVAL(L, 2); + int32 type = Eluna::CHECKVAL(E->L, 2); creature->SetDefaultMovementType((MovementGeneratorType)type); return 0; @@ -1005,9 +1005,9 @@ namespace LuaCreature * * @param bool enable = true : `true` to disable searching, `false` to allow */ - int SetNoSearchAssistance(lua_State* L, Creature* creature) + int SetNoSearchAssistance(Eluna* E, Creature* creature) { - bool val = Eluna::CHECKVAL(L, 2, true); + bool val = Eluna::CHECKVAL(E->L, 2, true); creature->SetNoSearchAssistance(val); return 0; @@ -1018,9 +1018,9 @@ namespace LuaCreature * * @param bool enable = true : `true` to disable calling for help, `false` to enable */ - int SetNoCallAssistance(lua_State* L, Creature* creature) + int SetNoCallAssistance(Eluna* E, Creature* creature) { - bool val = Eluna::CHECKVAL(L, 2, true); + bool val = Eluna::CHECKVAL(E->L, 2, true); creature->SetNoCallAssistance(val); return 0; @@ -1031,9 +1031,9 @@ namespace LuaCreature * * @param bool enable = true : `true` to enable hovering, `false` to disable */ - int SetHover(lua_State* L, Creature* creature) + int SetHover(Eluna* E, Creature* creature) { - bool enable = Eluna::CHECKVAL(L, 2, true); + bool enable = Eluna::CHECKVAL(E->L, 2, true); creature->SetHover(enable); return 0; @@ -1044,9 +1044,9 @@ namespace LuaCreature * * @param uint32 delay = 0 : dely to despawn in milliseconds */ - int DespawnOrUnsummon(lua_State* L, Creature* creature) + int DespawnOrUnsummon(Eluna* E, Creature* creature) { - uint32 msTimeToDespawn = Eluna::CHECKVAL(L, 2, 0); + uint32 msTimeToDespawn = Eluna::CHECKVAL(E->L, 2, 0); creature->DespawnOrUnsummon(Milliseconds(msTimeToDespawn)); return 0; @@ -1055,7 +1055,7 @@ namespace LuaCreature /** * Respawn this [Creature]. */ - int Respawn(lua_State* /*L*/, Creature* creature) + int Respawn(Eluna* /*E*/, Creature* creature) { creature->Respawn(); return 0; @@ -1064,7 +1064,7 @@ namespace LuaCreature /** * Remove this [Creature]'s corpse. */ - int RemoveCorpse(lua_State* /*L*/, Creature* creature) + int RemoveCorpse(Eluna* /*E*/, Creature* creature) { creature->RemoveCorpse(); return 0; @@ -1073,7 +1073,7 @@ namespace LuaCreature /** * Make the [Creature] start following its waypoint path. */ - int MoveWaypoint(lua_State* /*L*/, Creature* creature) + int MoveWaypoint(Eluna* /*E*/, Creature* creature) { creature->GetMotionMaster()->MovePath(creature->GetWaypointPath(), true); return 0; @@ -1082,7 +1082,7 @@ namespace LuaCreature /** * Make the [Creature] call for assistance in combat from other nearby [Creature]s. */ - int CallAssistance(lua_State* /*L*/, Creature* creature) + int CallAssistance(Eluna* /*E*/, Creature* creature) { creature->CallAssistance(); return 0; @@ -1093,9 +1093,9 @@ namespace LuaCreature * * @param float radius */ - int CallForHelp(lua_State* L, Creature* creature) + int CallForHelp(Eluna* E, Creature* creature) { - float radius = Eluna::CHECKVAL(L, 2); + float radius = Eluna::CHECKVAL(E->L, 2); creature->CallForHelp(radius); return 0; @@ -1104,7 +1104,7 @@ namespace LuaCreature /** * Make the [Creature] flee combat to get assistance from a nearby friendly [Creature]. */ - int FleeToGetAssistance(lua_State* /*L*/, Creature* creature) + int FleeToGetAssistance(Eluna* /*E*/, Creature* creature) { creature->DoFleeToGetAssistance(); return 0; @@ -1115,9 +1115,9 @@ namespace LuaCreature * * @param [Unit] target */ - int AttackStart(lua_State* L, Creature* creature) + int AttackStart(Eluna* E, Creature* creature) { - Unit* target = Eluna::CHECKOBJ(L, 2); + Unit* target = Eluna::CHECKOBJ(E->L, 2); creature->AI()->AttackStart(target); return 0; @@ -1126,7 +1126,7 @@ namespace LuaCreature /** * Save the [Creature] in the database. */ - int SaveToDB(lua_State* /*L*/, Creature* creature) + int SaveToDB(Eluna* /*E*/, Creature* creature) { creature->SaveToDB(); return 0; @@ -1137,9 +1137,9 @@ namespace LuaCreature * * This should be called every update cycle for the Creature's AI. */ - int SelectVictim(lua_State* L, Creature* creature) + int SelectVictim(Eluna* E, Creature* creature) { - Eluna::Push(L, creature->SelectVictim()); + E->Push(creature->SelectVictim()); return 1; } @@ -1149,10 +1149,10 @@ namespace LuaCreature * @param uint32 entry : the Creature ID to transform into * @param uint32 dataGUIDLow = 0 : use this Creature's model and equipment instead of the defaults */ - int UpdateEntry(lua_State* L, Creature* creature) + int UpdateEntry(Eluna* E, Creature* creature) { - uint32 entry = Eluna::CHECKVAL(L, 2); - uint32 dataGuidLow = Eluna::CHECKVAL(L, 3, 0); + uint32 entry = Eluna::CHECKVAL(E->L, 2); + uint32 dataGuidLow = Eluna::CHECKVAL(E->L, 3, 0); creature->UpdateEntry(entry, dataGuidLow ? eObjectMgr->GetCreatureData(dataGuidLow) : NULL); return 0; @@ -1161,7 +1161,7 @@ namespace LuaCreature /** * Resets [Creature]'s loot mode to default */ - int ResetLootMode(lua_State* /*L*/, Creature* creature) + int ResetLootMode(Eluna* /*E*/, Creature* creature) { creature->ResetLootMode(); return 0; @@ -1172,9 +1172,9 @@ namespace LuaCreature * * @param uint16 lootMode */ - int RemoveLootMode(lua_State* L, Creature* creature) + int RemoveLootMode(Eluna* E, Creature* creature) { - uint16 lootMode = Eluna::CHECKVAL(L, 2); + uint16 lootMode = Eluna::CHECKVAL(E->L, 2); creature->RemoveLootMode(lootMode); return 0; @@ -1185,9 +1185,9 @@ namespace LuaCreature * * @param uint16 lootMode */ - int AddLootMode(lua_State* L, Creature* creature) + int AddLootMode(Eluna* E, Creature* creature) { - uint16 lootMode = Eluna::CHECKVAL(L, 2); + uint16 lootMode = Eluna::CHECKVAL(E->L, 2); creature->AddLootMode(lootMode); return 0; @@ -1247,13 +1247,13 @@ namespace LuaCreature * * @return [CreatureFamily] creatureFamily */ - int GetCreatureFamily(lua_State* L, Creature* creature) + int GetCreatureFamily(Eluna* E, Creature* creature) { uint32 entry = creature->GetEntry(); CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(entry); if (cInfo) - Eluna::Push(L, cInfo->family); + E->Push(cInfo->family); return 1; } diff --git a/TrinityCore/ElunaQueryMethods.h b/TrinityCore/ElunaQueryMethods.h index 99587f54f5..282ac31afe 100644 --- a/TrinityCore/ElunaQueryMethods.h +++ b/TrinityCore/ElunaQueryMethods.h @@ -18,15 +18,15 @@ */ namespace LuaQuery { - static void CheckFields(lua_State* L, ElunaQuery* result) + static void CheckFields(Eluna* E, ElunaQuery* result) { - uint32 field = Eluna::CHECKVAL(L, 2); + uint32 field = Eluna::CHECKVAL(E->L, 2); uint32 count = RESULT->GetFieldCount(); if (field >= count) { char arr[256]; sprintf(arr, "trying to access invalid field index %u. There are %u fields available and the indexes start from 0", field, count); - luaL_argerror(L, 2, arr); + luaL_argerror(E->L, 2, arr); } } @@ -36,12 +36,12 @@ namespace LuaQuery * @param uint32 column * @return bool isNull */ - int IsNull(lua_State* L, ElunaQuery* result) + int IsNull(Eluna* E, ElunaQuery* result) { - uint32 col = Eluna::CHECKVAL(L, 2); - CheckFields(L, result); + uint32 col = Eluna::CHECKVAL(E->L, 2); + CheckFields(E, result); - Eluna::Push(L, RESULT->Fetch()[col].IsNull()); + E->Push(RESULT->Fetch()[col].IsNull()); return 1; } @@ -50,9 +50,9 @@ namespace LuaQuery * * @return uint32 columnCount */ - int GetColumnCount(lua_State* L, ElunaQuery* result) + int GetColumnCount(Eluna* E, ElunaQuery* result) { - Eluna::Push(L, RESULT->GetFieldCount()); + E->Push(RESULT->GetFieldCount()); return 1; } @@ -61,12 +61,12 @@ namespace LuaQuery * * @return uint32 rowCount */ - int GetRowCount(lua_State* L, ElunaQuery* result) + int GetRowCount(Eluna* E, ElunaQuery* result) { if (RESULT->GetRowCount() > (uint32)-1) - Eluna::Push(L, (uint32)-1); + E->Push((uint32)-1); else - Eluna::Push(L, (uint32)(RESULT->GetRowCount())); + E->Push((uint32)(RESULT->GetRowCount())); return 1; } @@ -76,11 +76,11 @@ namespace LuaQuery * @param uint32 column * @return bool data */ - int GetBool(lua_State* L, ElunaQuery* result) + int GetBool(Eluna* E, ElunaQuery* result) { - uint32 col = Eluna::CHECKVAL(L, 2); - CheckFields(L, result); - Eluna::Push(L, RESULT->Fetch()[col].GetBool()); + uint32 col = Eluna::CHECKVAL(E->L, 2); + CheckFields(E, result); + E->Push(RESULT->Fetch()[col].GetBool()); return 1; } @@ -90,11 +90,11 @@ namespace LuaQuery * @param uint32 column * @return uint8 data */ - int GetUInt8(lua_State* L, ElunaQuery* result) + int GetUInt8(Eluna* E, ElunaQuery* result) { - uint32 col = Eluna::CHECKVAL(L, 2); - CheckFields(L, result); - Eluna::Push(L, RESULT->Fetch()[col].GetUInt8()); + uint32 col = Eluna::CHECKVAL(E->L, 2); + CheckFields(E, result); + E->Push(RESULT->Fetch()[col].GetUInt8()); return 1; } @@ -104,11 +104,11 @@ namespace LuaQuery * @param uint32 column * @return uint16 data */ - int GetUInt16(lua_State* L, ElunaQuery* result) + int GetUInt16(Eluna* E, ElunaQuery* result) { - uint32 col = Eluna::CHECKVAL(L, 2); - CheckFields(L, result); - Eluna::Push(L, RESULT->Fetch()[col].GetUInt16()); + uint32 col = Eluna::CHECKVAL(E->L, 2); + CheckFields(E, result); + E->Push(RESULT->Fetch()[col].GetUInt16()); return 1; } @@ -118,11 +118,11 @@ namespace LuaQuery * @param uint32 column * @return uint32 data */ - int GetUInt32(lua_State* L, ElunaQuery* result) + int GetUInt32(Eluna* E, ElunaQuery* result) { - uint32 col = Eluna::CHECKVAL(L, 2); - CheckFields(L, result); - Eluna::Push(L, RESULT->Fetch()[col].GetUInt32()); + uint32 col = Eluna::CHECKVAL(E->L, 2); + CheckFields(E, result); + E->Push(RESULT->Fetch()[col].GetUInt32()); return 1; } @@ -132,11 +132,11 @@ namespace LuaQuery * @param uint32 column * @return uint64 data */ - int GetUInt64(lua_State* L, ElunaQuery* result) + int GetUInt64(Eluna* E, ElunaQuery* result) { - uint32 col = Eluna::CHECKVAL(L, 2); - CheckFields(L, result); - Eluna::Push(L, RESULT->Fetch()[col].GetUInt64()); + uint32 col = Eluna::CHECKVAL(E->L, 2); + CheckFields(E, result); + E->Push(RESULT->Fetch()[col].GetUInt64()); return 1; } @@ -146,11 +146,11 @@ namespace LuaQuery * @param uint32 column * @return int8 data */ - int GetInt8(lua_State* L, ElunaQuery* result) + int GetInt8(Eluna* E, ElunaQuery* result) { - uint32 col = Eluna::CHECKVAL(L, 2); - CheckFields(L, result); - Eluna::Push(L, RESULT->Fetch()[col].GetInt8()); + uint32 col = Eluna::CHECKVAL(E->L, 2); + CheckFields(E, result); + E->Push(RESULT->Fetch()[col].GetInt8()); return 1; } @@ -160,11 +160,11 @@ namespace LuaQuery * @param uint32 column * @return int16 data */ - int GetInt16(lua_State* L, ElunaQuery* result) + int GetInt16(Eluna* E, ElunaQuery* result) { - uint32 col = Eluna::CHECKVAL(L, 2); - CheckFields(L, result); - Eluna::Push(L, RESULT->Fetch()[col].GetInt16()); + uint32 col = Eluna::CHECKVAL(E->L, 2); + CheckFields(E, result); + E->Push(RESULT->Fetch()[col].GetInt16()); return 1; } @@ -174,11 +174,11 @@ namespace LuaQuery * @param uint32 column * @return int32 data */ - int GetInt32(lua_State* L, ElunaQuery* result) + int GetInt32(Eluna* E, ElunaQuery* result) { - uint32 col = Eluna::CHECKVAL(L, 2); - CheckFields(L, result); - Eluna::Push(L, RESULT->Fetch()[col].GetInt32()); + uint32 col = Eluna::CHECKVAL(E->L, 2); + CheckFields(E, result); + E->Push(RESULT->Fetch()[col].GetInt32()); return 1; } @@ -188,11 +188,11 @@ namespace LuaQuery * @param uint32 column * @return int64 data */ - int GetInt64(lua_State* L, ElunaQuery* result) + int GetInt64(Eluna* E, ElunaQuery* result) { - uint32 col = Eluna::CHECKVAL(L, 2); - CheckFields(L, result); - Eluna::Push(L, RESULT->Fetch()[col].GetInt64()); + uint32 col = Eluna::CHECKVAL(E->L, 2); + CheckFields(E, result); + E->Push(RESULT->Fetch()[col].GetInt64()); return 1; } @@ -202,11 +202,11 @@ namespace LuaQuery * @param uint32 column * @return float data */ - int GetFloat(lua_State* L, ElunaQuery* result) + int GetFloat(Eluna* E, ElunaQuery* result) { - uint32 col = Eluna::CHECKVAL(L, 2); - CheckFields(L, result); - Eluna::Push(L, RESULT->Fetch()[col].GetFloat()); + uint32 col = Eluna::CHECKVAL(E->L, 2); + CheckFields(E, result); + E->Push(RESULT->Fetch()[col].GetFloat()); return 1; } @@ -216,11 +216,11 @@ namespace LuaQuery * @param uint32 column * @return double data */ - int GetDouble(lua_State* L, ElunaQuery* result) + int GetDouble(Eluna* E, ElunaQuery* result) { - uint32 col = Eluna::CHECKVAL(L, 2); - CheckFields(L, result); - Eluna::Push(L, RESULT->Fetch()[col].GetDouble()); + uint32 col = Eluna::CHECKVAL(E->L, 2); + CheckFields(E, result); + E->Push(RESULT->Fetch()[col].GetDouble()); return 1; } @@ -230,12 +230,12 @@ namespace LuaQuery * @param uint32 column * @return string data */ - int GetString(lua_State* L, ElunaQuery* result) + int GetString(Eluna* E, ElunaQuery* result) { - uint32 col = Eluna::CHECKVAL(L, 2); - CheckFields(L, result); + uint32 col = Eluna::CHECKVAL(E->L, 2); + CheckFields(E, result); - Eluna::Push(L, RESULT->Fetch()[col].GetCString()); + E->Push(RESULT->Fetch()[col].GetCString()); return 1; } @@ -248,9 +248,9 @@ namespace LuaQuery * * @return bool hadNextRow */ - int NextRow(lua_State* L, ElunaQuery* result) + int NextRow(Eluna* E, ElunaQuery* result) { - Eluna::Push(L, RESULT->NextRow()); + E->Push(RESULT->NextRow()); return 1; } @@ -271,21 +271,21 @@ namespace LuaQuery * * @return table rowData : table filled with row columns and data where `T[column] = data` */ - int GetRow(lua_State* L, ElunaQuery* result) + int GetRow(Eluna* E, ElunaQuery* result) { uint32 col = RESULT->GetFieldCount(); Field* row = RESULT->Fetch(); - lua_createtable(L, 0, col); - int tbl = lua_gettop(L); + lua_createtable(E->L, 0, col); + int tbl = lua_gettop(E->L); for (uint32 i = 0; i < col; ++i) { - Eluna::Push(L, RESULT->GetFieldName(i)); + E->Push(RESULT->GetFieldName(i)); const char* str = row[i].GetCString(); if (row[i].IsNull() || !str) - Eluna::Push(L); + E->Push(); else { // MYSQL_TYPE_LONGLONG Interpreted as string for lua @@ -297,17 +297,17 @@ namespace LuaQuery case DatabaseFieldTypes::Int64: case DatabaseFieldTypes::Float: case DatabaseFieldTypes::Double: - Eluna::Push(L, strtod(str, NULL)); + E->Push(strtod(str, NULL)); break; default: - Eluna::Push(L, str); + E->Push(str); break; } } - lua_rawset(L, tbl); + lua_rawset(E->L, tbl); } - lua_settop(L, tbl); + lua_settop(E->L, tbl); return 1; } diff --git a/TrinityCore/GameObjectMethods.h b/TrinityCore/GameObjectMethods.h index 2cf1b7a6ad..a3e84fc751 100644 --- a/TrinityCore/GameObjectMethods.h +++ b/TrinityCore/GameObjectMethods.h @@ -18,11 +18,11 @@ namespace LuaGameObject * @param uint32 questId : quest entry Id to check * @return bool hasQuest */ - int HasQuest(lua_State* L, GameObject* go) + int HasQuest(Eluna* E, GameObject* go) { - uint32 questId = Eluna::CHECKVAL(L, 2); + uint32 questId = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, go->hasQuest(questId)); + E->Push(go->hasQuest(questId)); return 1; } @@ -31,9 +31,9 @@ namespace LuaGameObject * * @return bool isSpawned */ - int IsSpawned(lua_State* L, GameObject* go) + int IsSpawned(Eluna* E, GameObject* go) { - Eluna::Push(L, go->isSpawned()); + E->Push(go->isSpawned()); return 1; } @@ -42,9 +42,9 @@ namespace LuaGameObject * * @return bool isTransport */ - int IsTransport(lua_State* L, GameObject* go) + int IsTransport(Eluna* E, GameObject* go) { - Eluna::Push(L, go->IsTransport()); + E->Push(go->IsTransport()); return 1; } @@ -53,15 +53,15 @@ namespace LuaGameObject * * @return bool isActive */ - int IsActive(lua_State* L, GameObject* go) + int IsActive(Eluna* E, GameObject* go) { - Eluna::Push(L, go->isActiveObject()); + E->Push(go->isActiveObject()); return 1; } - int IsDestructible(lua_State* L, GameObject* go) + int IsDestructible(Eluna* E, GameObject* go) { - Eluna::Push(L, go->IsDestructibleBuilding()); + E->Push(go->IsDestructibleBuilding()); return 1; } @@ -70,9 +70,9 @@ namespace LuaGameObject * * @return uint32 displayId */ - int GetDisplayId(lua_State* L, GameObject* go) + int GetDisplayId(Eluna* E, GameObject* go) { - Eluna::Push(L, go->GetDisplayId()); + E->Push(go->GetDisplayId()); return 1; } @@ -91,9 +91,9 @@ namespace LuaGameObject * * @return [GOState] goState */ - int GetGoState(lua_State* L, GameObject* go) + int GetGoState(Eluna* E, GameObject* go) { - Eluna::Push(L, go->GetGoState()); + E->Push(go->GetGoState()); return 1; } @@ -113,9 +113,9 @@ namespace LuaGameObject * * @return [LootState] lootState */ - int GetLootState(lua_State* L, GameObject* go) + int GetLootState(Eluna* E, GameObject* go) { - Eluna::Push(L, go->getLootState()); + E->Push(go->getLootState()); return 1; } @@ -126,9 +126,9 @@ namespace LuaGameObject * * @return [Player] player */ - int GetLootRecipient(lua_State* L, GameObject* go) + int GetLootRecipient(Eluna* E, GameObject* go) { - Eluna::Push(L, go->GetLootRecipient()); + E->Push(go->GetLootRecipient()); return 1; } @@ -139,9 +139,9 @@ namespace LuaGameObject * * @return [Group] group */ - int GetLootRecipientGroup(lua_State* L, GameObject* go) + int GetLootRecipientGroup(Eluna* E, GameObject* go) { - Eluna::Push(L, go->GetLootRecipientGroup()); + E->Push(go->GetLootRecipientGroup()); return 1; } @@ -150,9 +150,9 @@ namespace LuaGameObject * * @return uint32 dbguid */ - int GetDBTableGUIDLow(lua_State* L, GameObject* go) + int GetDBTableGUIDLow(Eluna* E, GameObject* go) { - Eluna::Push(L, go->GetSpawnId()); + E->Push(go->GetSpawnId()); return 1; } @@ -170,9 +170,9 @@ namespace LuaGameObject * * @param [GOState] state : all available go states can be seen above */ - int SetGoState(lua_State* L, GameObject* go) + int SetGoState(Eluna* E, GameObject* go) { - uint32 state = Eluna::CHECKVAL(L, 2, 0); + uint32 state = Eluna::CHECKVAL(E->L, 2, 0); if (state == 0) go->SetGoState(GO_STATE_ACTIVE); @@ -206,9 +206,9 @@ namespace LuaGameObject * * @param [LootState] state : all available loot states can be seen above */ - int SetLootState(lua_State* L, GameObject* go) + int SetLootState(Eluna* E, GameObject* go) { - uint32 state = Eluna::CHECKVAL(L, 2, 0); + uint32 state = Eluna::CHECKVAL(E->L, 2, 0); if (state == 0) go->SetLootState(GO_NOT_READY); @@ -226,7 +226,7 @@ namespace LuaGameObject * Saves [GameObject] to the database * */ - int SaveToDB(lua_State* /*L*/, GameObject* go) + int SaveToDB(Eluna* E, GameObject* go) { go->SaveToDB(); return 0; @@ -239,9 +239,9 @@ namespace LuaGameObject * * @param bool deleteFromDB : if true, it will delete the [GameObject] from the database */ - int RemoveFromWorld(lua_State* L, GameObject* go) + int RemoveFromWorld(Eluna* E, GameObject* go) { - bool deldb = Eluna::CHECKVAL(L, 2, false); + bool deldb = Eluna::CHECKVAL(E->L, 2, false); // cs_gobject.cpp copy paste ObjectGuid ownerGuid = go->GetOwnerGUID(); @@ -260,7 +260,7 @@ namespace LuaGameObject go->SetRespawnTime(0); go->Delete(); - Eluna::CHECKOBJ(L, 1)->Invalidate(); + Eluna::CHECKOBJ(E->L, 1)->Invalidate(); return 0; } @@ -269,9 +269,9 @@ namespace LuaGameObject * * @param uint32 delay = 0 : cooldown time in seconds to restore the [GameObject] back to normal. 0 for infinite duration */ - int UseDoorOrButton(lua_State* L, GameObject* go) + int UseDoorOrButton(Eluna* E, GameObject* go) { - uint32 delay = Eluna::CHECKVAL(L, 2, 0); + uint32 delay = Eluna::CHECKVAL(E->L, 2, 0); go->UseDoorOrButton(delay); return 0; @@ -282,7 +282,7 @@ namespace LuaGameObject * * The gameobject may be automatically respawned by the core */ - int Despawn(lua_State* /*L*/, GameObject* go) + int Despawn(Eluna* E, GameObject* go) { go->SetLootState(GO_JUST_DEACTIVATED); return 0; @@ -291,7 +291,7 @@ namespace LuaGameObject /** * Respawns a [GameObject] */ - int Respawn(lua_State* /*L*/, GameObject* go) + int Respawn(Eluna* E, GameObject* go) { go->Respawn(); return 0; @@ -304,9 +304,9 @@ namespace LuaGameObject * * @param int32 delay = 0 : cooldown time in seconds to respawn or despawn the object. 0 means never */ - int SetRespawnTime(lua_State* L, GameObject* go) + int SetRespawnTime(Eluna* E, GameObject* go) { - int32 respawn = Eluna::CHECKVAL(L, 2); + int32 respawn = Eluna::CHECKVAL(E->L, 2); go->SetRespawnTime(respawn); return 0; diff --git a/TrinityCore/GlobalMethods.h b/TrinityCore/GlobalMethods.h index fde19dc247..6633c317a8 100644 --- a/TrinityCore/GlobalMethods.h +++ b/TrinityCore/GlobalMethods.h @@ -21,9 +21,9 @@ namespace LuaGlobalFunctions * * @return string engineName */ - int GetLuaEngine(lua_State* L) + int GetLuaEngine(Eluna* E) { - Eluna::Push(L, "ElunaEngine"); + E->Push("ElunaEngine"); return 1; } @@ -34,9 +34,9 @@ namespace LuaGlobalFunctions * * @return string coreName */ - int GetCoreName(lua_State* L) + int GetCoreName(Eluna* E) { - Eluna::Push(L, CORE_NAME); + E->Push(CORE_NAME); return 1; } @@ -48,9 +48,9 @@ namespace LuaGlobalFunctions * @return uint32 realm ID */ - int GetRealmID(lua_State* L) + int GetRealmID(Eluna* E) { - Eluna::Push(L, sConfigMgr->GetIntDefault("RealmID", 1)); + E->Push(sConfigMgr->GetIntDefault("RealmID", 1)); return 1; } @@ -63,9 +63,9 @@ namespace LuaGlobalFunctions * * @return string version */ - int GetCoreVersion(lua_State* L) + int GetCoreVersion(Eluna* E) { - Eluna::Push(L, CORE_VERSION); + E->Push(CORE_VERSION); return 1; } @@ -76,12 +76,12 @@ namespace LuaGlobalFunctions * * @return int32 expansion */ - int GetCoreExpansion(lua_State* L) + int GetCoreExpansion(Eluna* E) { #ifdef WOTLK - Eluna::Push(L, 2); + E->Push(2); #elif CATA - Eluna::Push(L, 3); + E->Push(3); #endif return 1; } @@ -92,11 +92,11 @@ namespace LuaGlobalFunctions * @param uint32 questId : [Quest] entry ID * @return [Quest] quest */ - int GetQuest(lua_State* L) + int GetQuest(Eluna* E) { - uint32 questId = Eluna::CHECKVAL(L, 1); + uint32 questId = Eluna::CHECKVAL(E->L, 1); - Eluna::Push(L, eObjectMgr->GetQuestTemplate(questId)); + E->Push(eObjectMgr->GetQuestTemplate(questId)); return 1; } @@ -106,10 +106,10 @@ namespace LuaGlobalFunctions * @param ObjectGuid guid : guid of the [Player], you can get it with [Object:GetGUID] * @return [Player] player */ - int GetPlayerByGUID(lua_State* L) + int GetPlayerByGUID(Eluna* E) { - ObjectGuid guid = Eluna::CHECKVAL(L, 1); - Eluna::Push(L, eObjectAccessor()FindPlayer(guid)); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 1); + E->Push(eObjectAccessor()FindPlayer(guid)); return 1; } @@ -119,10 +119,10 @@ namespace LuaGlobalFunctions * @param string name : name of the [Player] * @return [Player] player */ - int GetPlayerByName(lua_State* L) + int GetPlayerByName(Eluna* E) { - const char* name = Eluna::CHECKVAL(L, 1); - Eluna::Push(L, eObjectAccessor()FindPlayerByName(name)); + const char* name = Eluna::CHECKVAL(E->L, 1); + E->Push(eObjectAccessor()FindPlayerByName(name)); return 1; } @@ -131,9 +131,9 @@ namespace LuaGlobalFunctions * * @return uint32 time */ - int GetGameTime(lua_State* L) + int GetGameTime(Eluna* E) { - Eluna::Push(L, GameTime::GetGameTime()); + E->Push(GameTime::GetGameTime()); return 1; } @@ -153,13 +153,13 @@ namespace LuaGlobalFunctions * @param bool onlyGM = false : optional check if GM only * @return table worldPlayers */ - int GetPlayersInWorld(lua_State* L) + int GetPlayersInWorld(Eluna* E) { - uint32 team = Eluna::CHECKVAL(L, 1, TEAM_NEUTRAL); - bool onlyGM = Eluna::CHECKVAL(L, 2, false); + uint32 team = Eluna::CHECKVAL(E->L, 1, TEAM_NEUTRAL); + bool onlyGM = Eluna::CHECKVAL(E->L, 2, false); - lua_newtable(L); - int tbl = lua_gettop(L); + lua_newtable(E->L); + int tbl = lua_gettop(E->L); uint32 i = 0; std::shared_lock lock(*HashMapHolder::GetLock()); @@ -173,13 +173,13 @@ namespace LuaGlobalFunctions if ((team == TEAM_NEUTRAL || player->GetTeamId() == team) && (!onlyGM || player->IsGameMaster())) { - Eluna::Push(L, player); - lua_rawseti(L, tbl, ++i); + E->Push(player); + lua_rawseti(E->L, tbl, ++i); } } } - lua_settop(L, tbl); // push table to top of stack + lua_settop(E->L, tbl); // push table to top of stack return 1; } @@ -189,10 +189,10 @@ namespace LuaGlobalFunctions * @param string name * @return [Guild] guild : the Guild, or `nil` if it doesn't exist */ - int GetGuildByName(lua_State* L) + int GetGuildByName(Eluna* E) { - const char* name = Eluna::CHECKVAL(L, 1); - Eluna::Push(L, eGuildMgr->GetGuildByName(name)); + const char* name = Eluna::CHECKVAL(E->L, 1); + E->Push(eGuildMgr->GetGuildByName(name)); return 1; } @@ -203,12 +203,12 @@ namespace LuaGlobalFunctions * @param uint32 instanceId = 0 : required if the map is an instance, otherwise don't pass anything * @return [Map] map : the Map, or `nil` if it doesn't exist */ - int GetMapById(lua_State* L) + int GetMapById(Eluna* E) { - uint32 mapid = Eluna::CHECKVAL(L, 1); - uint32 instance = Eluna::CHECKVAL(L, 2, 0); + uint32 mapid = Eluna::CHECKVAL(E->L, 1); + uint32 instance = Eluna::CHECKVAL(E->L, 2, 0); - Eluna::Push(L, eMapMgr->FindMap(mapid, instance)); + E->Push(eMapMgr->FindMap(mapid, instance)); return 1; } @@ -218,11 +218,11 @@ namespace LuaGlobalFunctions * @param ObjectGuid guid : the guid of a [Guild] leader * @return [Guild] guild, or `nil` if it doesn't exist */ - int GetGuildByLeaderGUID(lua_State* L) + int GetGuildByLeaderGUID(Eluna* E) { - ObjectGuid guid = Eluna::CHECKVAL(L, 1); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 1); - Eluna::Push(L, eGuildMgr->GetGuildByLeader(guid)); + E->Push(eGuildMgr->GetGuildByLeader(guid)); return 1; } @@ -231,9 +231,9 @@ namespace LuaGlobalFunctions * * @return uint32 count */ - int GetPlayerCount(lua_State* L) + int GetPlayerCount(Eluna* E) { - Eluna::Push(L, eWorld->GetActiveSessionCount()); + E->Push(eWorld->GetActiveSessionCount()); return 1; } @@ -247,10 +247,10 @@ namespace LuaGlobalFunctions * @param uint32 lowguid : low GUID of the [Player] * @return ObjectGuid guid */ - int GetPlayerGUID(lua_State* L) + int GetPlayerGUID(Eluna* E) { - uint32 lowguid = Eluna::CHECKVAL(L, 1); - Eluna::Push(L, MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER)); + uint32 lowguid = Eluna::CHECKVAL(E->L, 1); + E->Push(MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER)); return 1; } @@ -263,10 +263,10 @@ namespace LuaGlobalFunctions * @param uint32 lowguid : low GUID of the [Item] * @return ObjectGuid guid */ - int GetItemGUID(lua_State* L) + int GetItemGUID(Eluna* E) { - uint32 lowguid = Eluna::CHECKVAL(L, 1); - Eluna::Push(L, MAKE_NEW_GUID(lowguid, 0, HIGHGUID_ITEM)); + uint32 lowguid = Eluna::CHECKVAL(E->L, 1); + E->Push(MAKE_NEW_GUID(lowguid, 0, HIGHGUID_ITEM)); return 1; } @@ -281,11 +281,11 @@ namespace LuaGlobalFunctions * @param uint32 entry : entry ID of the [GameObject] * @return ObjectGuid guid */ - int GetObjectGUID(lua_State* L) + int GetObjectGUID(Eluna* E) { - uint32 lowguid = Eluna::CHECKVAL(L, 1); - uint32 entry = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, MAKE_NEW_GUID(lowguid, entry, HIGHGUID_GAMEOBJECT)); + uint32 lowguid = Eluna::CHECKVAL(E->L, 1); + uint32 entry = Eluna::CHECKVAL(E->L, 2); + E->Push(MAKE_NEW_GUID(lowguid, entry, HIGHGUID_GAMEOBJECT)); return 1; } @@ -300,11 +300,11 @@ namespace LuaGlobalFunctions * @param uint32 entry : entry ID of the [Creature] * @return ObjectGuid guid */ - int GetUnitGUID(lua_State* L) + int GetUnitGUID(Eluna* E) { - uint32 lowguid = Eluna::CHECKVAL(L, 1); - uint32 entry = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, MAKE_NEW_GUID(lowguid, entry, HIGHGUID_UNIT)); + uint32 lowguid = Eluna::CHECKVAL(E->L, 1); + uint32 entry = Eluna::CHECKVAL(E->L, 2); + E->Push(MAKE_NEW_GUID(lowguid, entry, HIGHGUID_UNIT)); return 1; } @@ -327,11 +327,11 @@ namespace LuaGlobalFunctions * @param ObjectGuid guid : GUID of an [Object] * @return uint32 lowguid : low GUID of the [Object] */ - int GetGUIDLow(lua_State* L) + int GetGUIDLow(Eluna* E) { - ObjectGuid guid = Eluna::CHECKVAL(L, 1); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 1); - Eluna::Push(L, guid.GetCounter()); + E->Push(guid.GetCounter()); return 1; } @@ -355,16 +355,16 @@ namespace LuaGlobalFunctions * @param [LocaleConstant] locale = DEFAULT_LOCALE : locale to return the [Item] name in * @return string itemLink */ - int GetItemLink(lua_State* L) + int GetItemLink(Eluna* E) { - uint32 entry = Eluna::CHECKVAL(L, 1); - uint8 locale = Eluna::CHECKVAL(L, 2, DEFAULT_LOCALE); + uint32 entry = Eluna::CHECKVAL(E->L, 1); + uint8 locale = Eluna::CHECKVAL(E->L, 2, DEFAULT_LOCALE); if (locale >= TOTAL_LOCALES) - return luaL_argerror(L, 2, "valid LocaleConstant expected"); + return luaL_argerror(E->L, 2, "valid LocaleConstant expected"); const ItemTemplate* temp = eObjectMgr->GetItemTemplate(entry); if (!temp) - return luaL_argerror(L, 1, "valid ItemEntry expected"); + return luaL_argerror(E->L, 1, "valid ItemEntry expected"); #ifdef CATA std::string name = temp->ExtendedData->Display->Str[locale]; @@ -384,7 +384,7 @@ namespace LuaGlobalFunctions "0:0:0:0:" << "0:0:0:0|h[" << name << "]|h|r"; - Eluna::Push(L, oss.str()); + E->Push(oss.str()); return 1; } @@ -398,10 +398,10 @@ namespace LuaGlobalFunctions * @param ObjectGuid guid : GUID of an [Object] * @return int32 typeId : type ID of the [Object] */ - int GetGUIDType(lua_State* L) + int GetGUIDType(Eluna* E) { - ObjectGuid guid = Eluna::CHECKVAL(L, 1); - Eluna::Push(L, static_cast(guid.GetHigh())); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 1); + E->Push(static_cast(guid.GetHigh())); return 1; } @@ -413,10 +413,10 @@ namespace LuaGlobalFunctions * @param ObjectGuid guid : GUID of an [Creature] or [GameObject] * @return uint32 entry : entry ID, or `0` if `guid` is not a [Creature] or [GameObject] */ - int GetGUIDEntry(lua_State* L) + int GetGUIDEntry(Eluna* E) { - ObjectGuid guid = Eluna::CHECKVAL(L, 1); - Eluna::Push(L, guid.GetEntry()); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 1); + E->Push(guid.GetEntry()); return 1; } @@ -440,18 +440,18 @@ namespace LuaGlobalFunctions * @param [LocaleConstant] locale = DEFAULT_LOCALE : locale to return the name in * @return string areaOrZoneName */ - int GetAreaName(lua_State* L) + int GetAreaName(Eluna* E) { - uint32 areaOrZoneId = Eluna::CHECKVAL(L, 1); - uint8 locale = Eluna::CHECKVAL(L, 2, DEFAULT_LOCALE); + uint32 areaOrZoneId = Eluna::CHECKVAL(E->L, 1); + uint8 locale = Eluna::CHECKVAL(E->L, 2, DEFAULT_LOCALE); if (locale >= TOTAL_LOCALES) - return luaL_argerror(L, 2, "valid LocaleConstant expected"); + return luaL_argerror(E->L, 2, "valid LocaleConstant expected"); AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaOrZoneId); if (!areaEntry) - return luaL_argerror(L, 1, "valid Area or Zone ID expected"); + return luaL_argerror(E->L, 1, "valid Area or Zone ID expected"); - Eluna::Push(L, areaEntry->AreaName[locale]); + E->Push(areaEntry->AreaName[locale]); return 1; } @@ -460,70 +460,70 @@ namespace LuaGlobalFunctions * * @return table activeEvents */ - int GetActiveGameEvents(lua_State* L) + int GetActiveGameEvents(Eluna* E) { - lua_newtable(L); - int tbl = lua_gettop(L); + lua_newtable(E->L); + int tbl = lua_gettop(E->L); uint32 counter = 1; GameEventMgr::ActiveEvents const& activeEvents = eGameEventMgr->GetActiveEventList(); for (GameEventMgr::ActiveEvents::const_iterator i = activeEvents.begin(); i != activeEvents.end(); ++i) { - Eluna::Push(L, *i); - lua_rawseti(L, tbl, counter); + E->Push(*i); + lua_rawseti(E->L, tbl, counter); counter++; } - lua_settop(L, tbl); + lua_settop(E->L, tbl); return 1; } - static int RegisterEntryHelper(lua_State* L, int regtype) + static int RegisterEntryHelper(Eluna* E, int regtype) { - uint32 id = Eluna::CHECKVAL(L, 1); - uint32 ev = Eluna::CHECKVAL(L, 2); - luaL_checktype(L, 3, LUA_TFUNCTION); - uint32 shots = Eluna::CHECKVAL(L, 4, 0); + uint32 id = Eluna::CHECKVAL(E->L, 1); + uint32 ev = Eluna::CHECKVAL(E->L, 2); + luaL_checktype(E->L, 3, LUA_TFUNCTION); + uint32 shots = Eluna::CHECKVAL(E->L, 4, 0); - lua_pushvalue(L, 3); - int functionRef = luaL_ref(L, LUA_REGISTRYINDEX); + lua_pushvalue(E->L, 3); + int functionRef = luaL_ref(E->L, LUA_REGISTRYINDEX); if (functionRef >= 0) - return Eluna::GetEluna(L)->Register(L, regtype, id, ObjectGuid(), 0, ev, functionRef, shots); + return E->Register(E->L, regtype, id, ObjectGuid(), 0, ev, functionRef, shots); else - luaL_argerror(L, 3, "unable to make a ref to function"); + luaL_argerror(E->L, 3, "unable to make a ref to function"); return 0; } - static int RegisterEventHelper(lua_State* L, int regtype) + static int RegisterEventHelper(Eluna* E, int regtype) { - uint32 ev = Eluna::CHECKVAL(L, 1); - luaL_checktype(L, 2, LUA_TFUNCTION); - uint32 shots = Eluna::CHECKVAL(L, 3, 0); + uint32 ev = Eluna::CHECKVAL(E->L, 1); + luaL_checktype(E->L, 2, LUA_TFUNCTION); + uint32 shots = Eluna::CHECKVAL(E->L, 3, 0); - lua_pushvalue(L, 2); - int functionRef = luaL_ref(L, LUA_REGISTRYINDEX); + lua_pushvalue(E->L, 2); + int functionRef = luaL_ref(E->L, LUA_REGISTRYINDEX); if (functionRef >= 0) - return Eluna::GetEluna(L)->Register(L, regtype, 0, ObjectGuid(), 0, ev, functionRef, shots); + return E->Register(E->L, regtype, 0, ObjectGuid(), 0, ev, functionRef, shots); else - luaL_argerror(L, 2, "unable to make a ref to function"); + luaL_argerror(E->L, 2, "unable to make a ref to function"); return 0; } - static int RegisterUniqueHelper(lua_State* L, int regtype) + static int RegisterUniqueHelper(Eluna* E, int regtype) { - ObjectGuid guid = Eluna::CHECKVAL(L, 1); - uint32 instanceId = Eluna::CHECKVAL(L, 2); - uint32 ev = Eluna::CHECKVAL(L, 3); - luaL_checktype(L, 4, LUA_TFUNCTION); - uint32 shots = Eluna::CHECKVAL(L, 5, 0); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 1); + uint32 instanceId = Eluna::CHECKVAL(E->L, 2); + uint32 ev = Eluna::CHECKVAL(E->L, 3); + luaL_checktype(E->L, 4, LUA_TFUNCTION); + uint32 shots = Eluna::CHECKVAL(E->L, 5, 0); - lua_pushvalue(L, 4); - int functionRef = luaL_ref(L, LUA_REGISTRYINDEX); + lua_pushvalue(E->L, 4); + int functionRef = luaL_ref(E->L, LUA_REGISTRYINDEX); if (functionRef >= 0) - return Eluna::GetEluna(L)->Register(L, regtype, 0, guid, instanceId, ev, functionRef, shots); + return E->Register(E->L, regtype, 0, guid, instanceId, ev, functionRef, shots); else - luaL_argerror(L, 4, "unable to make a ref to function"); + luaL_argerror(E->L, 4, "unable to make a ref to function"); return 0; } @@ -597,9 +597,9 @@ namespace LuaGlobalFunctions * * @return function cancel : a function that cancels the binding when called */ - int RegisterServerEvent(lua_State* L) + int RegisterServerEvent(Eluna* E) { - return RegisterEventHelper(L, Hooks::REGTYPE_SERVER); + return RegisterEventHelper(E, Hooks::REGTYPE_SERVER); } /** @@ -676,9 +676,9 @@ namespace LuaGlobalFunctions * * @return function cancel : a function that cancels the binding when called */ - int RegisterPlayerEvent(lua_State* L) + int RegisterPlayerEvent(Eluna* E) { - return RegisterEventHelper(L, Hooks::REGTYPE_PLAYER); + return RegisterEventHelper(E, Hooks::REGTYPE_PLAYER); } /** @@ -713,9 +713,9 @@ namespace LuaGlobalFunctions * * @return function cancel : a function that cancels the binding when called */ - int RegisterGuildEvent(lua_State* L) + int RegisterGuildEvent(Eluna* E) { - return RegisterEventHelper(L, Hooks::REGTYPE_GUILD); + return RegisterEventHelper(E, Hooks::REGTYPE_GUILD); } /** @@ -746,9 +746,9 @@ namespace LuaGlobalFunctions * * @return function cancel : a function that cancels the binding when called */ - int RegisterGroupEvent(lua_State* L) + int RegisterGroupEvent(Eluna* E) { - return RegisterEventHelper(L, Hooks::REGTYPE_GROUP); + return RegisterEventHelper(E, Hooks::REGTYPE_GROUP); } /** @@ -774,9 +774,9 @@ namespace LuaGlobalFunctions * * @return function cancel : a function that cancels the binding when called */ - int RegisterBGEvent(lua_State* L) + int RegisterBGEvent(Eluna* E) { - return RegisterEventHelper(L, Hooks::REGTYPE_BG); + return RegisterEventHelper(E, Hooks::REGTYPE_BG); } /** @@ -803,9 +803,9 @@ namespace LuaGlobalFunctions * * @return function cancel : a function that cancels the binding when called */ - int RegisterPacketEvent(lua_State* L) + int RegisterPacketEvent(Eluna* E) { - return RegisterEntryHelper(L, Hooks::REGTYPE_PACKET); + return RegisterEntryHelper(E, Hooks::REGTYPE_PACKET); } /** @@ -830,9 +830,9 @@ namespace LuaGlobalFunctions * * @return function cancel : a function that cancels the binding when called */ - int RegisterCreatureGossipEvent(lua_State* L) + int RegisterCreatureGossipEvent(Eluna* E) { - return RegisterEntryHelper(L, Hooks::REGTYPE_CREATURE_GOSSIP); + return RegisterEntryHelper(E, Hooks::REGTYPE_CREATURE_GOSSIP); } /** @@ -857,9 +857,9 @@ namespace LuaGlobalFunctions * * @return function cancel : a function that cancels the binding when called */ - int RegisterGameObjectGossipEvent(lua_State* L) + int RegisterGameObjectGossipEvent(Eluna* E) { - return RegisterEntryHelper(L, Hooks::REGTYPE_GAMEOBJECT_GOSSIP); + return RegisterEntryHelper(E, Hooks::REGTYPE_GAMEOBJECT_GOSSIP); } /** @@ -888,9 +888,9 @@ namespace LuaGlobalFunctions * * @return function cancel : a function that cancels the binding when called */ - int RegisterItemEvent(lua_State* L) + int RegisterItemEvent(Eluna* E) { - return RegisterEntryHelper(L, Hooks::REGTYPE_ITEM); + return RegisterEntryHelper(E, Hooks::REGTYPE_ITEM); } /** @@ -915,9 +915,9 @@ namespace LuaGlobalFunctions * * @return function cancel : a function that cancels the binding when called */ - int RegisterItemGossipEvent(lua_State* L) + int RegisterItemGossipEvent(Eluna* E) { - return RegisterEntryHelper(L, Hooks::REGTYPE_ITEM_GOSSIP); + return RegisterEntryHelper(E, Hooks::REGTYPE_ITEM_GOSSIP); } /** @@ -942,9 +942,9 @@ namespace LuaGlobalFunctions * @param function function : function to register * @param uint32 shots = 0 : the number of times the function will be called, 0 means "always call this function" */ - int RegisterMapEvent(lua_State* L) + int RegisterMapEvent(Eluna* E) { - return RegisterEntryHelper(L, Hooks::REGTYPE_MAP); + return RegisterEntryHelper(E, Hooks::REGTYPE_MAP); } /** @@ -969,9 +969,9 @@ namespace LuaGlobalFunctions * @param function function : function to register * @param uint32 shots = 0 : the number of times the function will be called, 0 means "always call this function" */ - int RegisterInstanceEvent(lua_State* L) + int RegisterInstanceEvent(Eluna* E) { - return RegisterEntryHelper(L, Hooks::REGTYPE_INSTANCE); + return RegisterEntryHelper(E, Hooks::REGTYPE_INSTANCE); } /** @@ -998,9 +998,9 @@ namespace LuaGlobalFunctions * * @return function cancel : a function that cancels the binding when called */ - int RegisterPlayerGossipEvent(lua_State* L) + int RegisterPlayerGossipEvent(Eluna* E) { - return RegisterEntryHelper(L, Hooks::REGTYPE_PLAYER_GOSSIP); + return RegisterEntryHelper(E, Hooks::REGTYPE_PLAYER_GOSSIP); } /** @@ -1060,9 +1060,9 @@ namespace LuaGlobalFunctions * * @return function cancel : a function that cancels the binding when called */ - int RegisterCreatureEvent(lua_State* L) + int RegisterCreatureEvent(Eluna* E) { - return RegisterEntryHelper(L, Hooks::REGTYPE_CREATURE); + return RegisterEntryHelper(E, Hooks::REGTYPE_CREATURE); } /** @@ -1123,9 +1123,9 @@ namespace LuaGlobalFunctions * * @return function cancel : a function that cancels the binding when called */ - int RegisterUniqueCreatureEvent(lua_State* L) + int RegisterUniqueCreatureEvent(Eluna* E) { - return RegisterUniqueHelper(L, Hooks::REGTYPE_CREATURE); + return RegisterUniqueHelper(E, Hooks::REGTYPE_CREATURE); } /** @@ -1162,17 +1162,17 @@ namespace LuaGlobalFunctions * * @return function cancel : a function that cancels the binding when called */ - int RegisterGameObjectEvent(lua_State* L) + int RegisterGameObjectEvent(Eluna* E) { - return RegisterEntryHelper(L, Hooks::REGTYPE_GAMEOBJECT); + return RegisterEntryHelper(E, Hooks::REGTYPE_GAMEOBJECT); } /** * Reloads the Lua engine. */ - int ReloadEluna(lua_State* /*L*/) + int ReloadEluna(Eluna* E) { - Eluna::ReloadEluna(); + E->ReloadEluna(); return 0; } @@ -1181,9 +1181,9 @@ namespace LuaGlobalFunctions * * @param string command : the command to run */ - int RunCommand(lua_State* L) + int RunCommand(Eluna* E) { - const char* command = Eluna::CHECKVAL(L, 1); + const char* command = Eluna::CHECKVAL(E->L, 1); // ignores output of the command #ifdef CATA eWorld->QueueCliCommand(new CliCommandHolder(nullptr, command, nullptr, [](void*, bool) {})); @@ -1198,9 +1198,9 @@ namespace LuaGlobalFunctions * * @param string message : message to send */ - int SendWorldMessage(lua_State* L) + int SendWorldMessage(Eluna* E) { - const char* message = Eluna::CHECKVAL(L, 1); + const char* message = Eluna::CHECKVAL(E->L, 1); eWorld->SendServerMessage(SERVER_MSG_STRING, message); return 0; } @@ -1222,15 +1222,15 @@ namespace LuaGlobalFunctions * @param string sql : query to execute * @return [ElunaQuery] results or nil if no rows found or nil if no rows found */ - int WorldDBQuery(lua_State* L) + int WorldDBQuery(Eluna* E) { - const char* query = Eluna::CHECKVAL(L, 1); + const char* query = Eluna::CHECKVAL(E->L, 1); ElunaQuery result = WorldDatabase.Query(query); if (result) - Eluna::Push(L, new ElunaQuery(result)); + E->Push(new ElunaQuery(result)); else - Eluna::Push(L); + E->Push(E->L); return 1; } @@ -1248,9 +1248,9 @@ namespace LuaGlobalFunctions * * @param string sql : query to execute */ - int WorldDBExecute(lua_State* L) + int WorldDBExecute(Eluna* E) { - const char* query = Eluna::CHECKVAL(L, 1); + const char* query = Eluna::CHECKVAL(E->L, 1); WorldDatabase.Execute(query); return 0; } @@ -1266,15 +1266,15 @@ namespace LuaGlobalFunctions * @param string sql : query to execute * @return [ElunaQuery] results or nil if no rows found */ - int CharDBQuery(lua_State* L) + int CharDBQuery(Eluna* E) { - const char* query = Eluna::CHECKVAL(L, 1); + const char* query = Eluna::CHECKVAL(E->L, 1); QueryResult result = CharacterDatabase.Query(query); if (result) - Eluna::Push(L, new QueryResult(result)); + E->Push(new QueryResult(result)); else - Eluna::Push(L); + E->Push(E->L); return 1; } @@ -1292,9 +1292,9 @@ namespace LuaGlobalFunctions * * @param string sql : query to execute */ - int CharDBExecute(lua_State* L) + int CharDBExecute(Eluna* E) { - const char* query = Eluna::CHECKVAL(L, 1); + const char* query = Eluna::CHECKVAL(E->L, 1); CharacterDatabase.Execute(query); return 0; } @@ -1310,15 +1310,15 @@ namespace LuaGlobalFunctions * @param string sql : query to execute * @return [ElunaQuery] results or nil if no rows found */ - int AuthDBQuery(lua_State* L) + int AuthDBQuery(Eluna* E) { - const char* query = Eluna::CHECKVAL(L, 1); + const char* query = Eluna::CHECKVAL(E->L, 1); QueryResult result = LoginDatabase.Query(query); if (result) - Eluna::Push(L, new QueryResult(result)); + E->Push(new QueryResult(result)); else - Eluna::Push(L); + E->Push(E->L); return 1; } @@ -1336,9 +1336,9 @@ namespace LuaGlobalFunctions * * @param string sql : query to execute */ - int AuthDBExecute(lua_State* L) + int AuthDBExecute(Eluna* E) { - const char* query = Eluna::CHECKVAL(L, 1); + const char* query = Eluna::CHECKVAL(E->L, 1); LoginDatabase.Execute(query); return 0; } @@ -1361,33 +1361,33 @@ namespace LuaGlobalFunctions * @param uint32 repeats = 1 : how many times for the event to repeat, 0 is infinite * @return int eventId : unique ID for the timed event used to cancel it or nil */ - int CreateLuaEvent(lua_State* L) + int CreateLuaEvent(Eluna* E) { - luaL_checktype(L, 1, LUA_TFUNCTION); + luaL_checktype(E->L, 1, LUA_TFUNCTION); uint32 min, max; - if (lua_istable(L, 2)) + if (lua_istable(E->L, 2)) { - Eluna::Push(L, 1); - lua_gettable(L, 2); - min = Eluna::CHECKVAL(L, -1); - Eluna::Push(L, 2); - lua_gettable(L, 2); - max = Eluna::CHECKVAL(L, -1); - lua_pop(L, 2); + E->Push(1); + lua_gettable(E->L, 2); + min = Eluna::CHECKVAL(E->L, -1); + E->Push(2); + lua_gettable(E->L, 2); + max = Eluna::CHECKVAL(E->L, -1); + lua_pop(E->L, 2); } else - min = max = Eluna::CHECKVAL(L, 2); - uint32 repeats = Eluna::CHECKVAL(L, 3, 1); + min = max = Eluna::CHECKVAL(E->L, 2); + uint32 repeats = Eluna::CHECKVAL(E->L, 3, 1); if (min > max) - return luaL_argerror(L, 2, "min is bigger than max delay"); + return luaL_argerror(E->L, 2, "min is bigger than max delay"); - lua_pushvalue(L, 1); - int functionRef = luaL_ref(L, LUA_REGISTRYINDEX); + lua_pushvalue(E->L, 1); + int functionRef = luaL_ref(E->L, LUA_REGISTRYINDEX); if (functionRef != LUA_REFNIL && functionRef != LUA_NOREF) { - Eluna::GetEluna(L)->eventMgr->globalProcessor->AddEvent(functionRef, min, max, repeats); - Eluna::Push(L, functionRef); + E->eventMgr->globalProcessor->AddEvent(functionRef, min, max, repeats); + E->Push(functionRef); } return 1; } @@ -1398,16 +1398,16 @@ namespace LuaGlobalFunctions * @param int eventId : event Id to remove * @param bool all_Events = false : remove from all events, not just global */ - int RemoveEventById(lua_State* L) + int RemoveEventById(Eluna* E) { - int eventId = Eluna::CHECKVAL(L, 1); - bool all_Events = Eluna::CHECKVAL(L, 1, false); + int eventId = Eluna::CHECKVAL(E->L, 1); + bool all_Events = Eluna::CHECKVAL(E->L, 1, false); // not thread safe if (all_Events) - Eluna::GetEluna(L)->eventMgr->SetState(eventId, LUAEVENT_STATE_ABORT); + E->eventMgr->SetState(eventId, LUAEVENT_STATE_ABORT); else - Eluna::GetEluna(L)->eventMgr->globalProcessor->SetState(eventId, LUAEVENT_STATE_ABORT); + E->eventMgr->globalProcessor->SetState(eventId, LUAEVENT_STATE_ABORT); return 0; } @@ -1416,15 +1416,15 @@ namespace LuaGlobalFunctions * * @param bool all_Events = false : remove all events, not just global */ - int RemoveEvents(lua_State* L) + int RemoveEvents(Eluna* E) { - bool all_Events = Eluna::CHECKVAL(L, 1, false); + bool all_Events = Eluna::CHECKVAL(E->L, 1, false); // not thread safe if (all_Events) - Eluna::GetEluna(L)->eventMgr->SetStates(LUAEVENT_STATE_ABORT); + E->eventMgr->SetStates(LUAEVENT_STATE_ABORT); else - Eluna::GetEluna(L)->eventMgr->globalProcessor->SetStates(LUAEVENT_STATE_ABORT); + E->eventMgr->globalProcessor->SetStates(LUAEVENT_STATE_ABORT); return 0; } @@ -1444,30 +1444,30 @@ namespace LuaGlobalFunctions * @param uint32 phase = 1 : phase to put the [Creature] or [GameObject] in * @return [WorldObject] worldObject : returns [Creature] or [GameObject] */ - int PerformIngameSpawn(lua_State* L) + int PerformIngameSpawn(Eluna* E) { - int spawntype = Eluna::CHECKVAL(L, 1); - uint32 entry = Eluna::CHECKVAL(L, 2); - uint32 mapID = Eluna::CHECKVAL(L, 3); - uint32 instanceID = Eluna::CHECKVAL(L, 4); - float x = Eluna::CHECKVAL(L, 5); - float y = Eluna::CHECKVAL(L, 6); - float z = Eluna::CHECKVAL(L, 7); - float o = Eluna::CHECKVAL(L, 8); - bool save = Eluna::CHECKVAL(L, 9, false); - uint32 durorresptime = Eluna::CHECKVAL(L, 10, 0); - uint32 phase = Eluna::CHECKVAL(L, 11, PHASEMASK_NORMAL); + int spawntype = Eluna::CHECKVAL(E->L, 1); + uint32 entry = Eluna::CHECKVAL(E->L, 2); + uint32 mapID = Eluna::CHECKVAL(E->L, 3); + uint32 instanceID = Eluna::CHECKVAL(E->L, 4); + float x = Eluna::CHECKVAL(E->L, 5); + float y = Eluna::CHECKVAL(E->L, 6); + float z = Eluna::CHECKVAL(E->L, 7); + float o = Eluna::CHECKVAL(E->L, 8); + bool save = Eluna::CHECKVAL(E->L, 9, false); + uint32 durorresptime = Eluna::CHECKVAL(E->L, 10, 0); + uint32 phase = Eluna::CHECKVAL(E->L, 11, PHASEMASK_NORMAL); if (!phase) { - Eluna::Push(L); + E->Push(E->L); return 1; } Map* map = eMapMgr->FindMap(mapID, instanceID); if (!map) { - Eluna::Push(L); + E->Push(E->L); return 1; } @@ -1485,7 +1485,7 @@ namespace LuaGlobalFunctions #endif { delete creature; - Eluna::Push(L); + E->Push(E->L); return 1; } @@ -1506,12 +1506,12 @@ namespace LuaGlobalFunctions if (!creature->LoadFromDB(db_guid, map, true, true)) { delete creature; - Eluna::Push(L); + E->Push(E->L); return 1; } eObjectMgr->AddCreatureToGrid(db_guid, eObjectMgr->GetCreatureData(db_guid)); - Eluna::Push(L, creature); + E->Push(creature); } else { @@ -1524,7 +1524,7 @@ namespace LuaGlobalFunctions #endif if (!creature) { - Eluna::Push(L); + E->Push(E->L); return 1; } @@ -1533,7 +1533,7 @@ namespace LuaGlobalFunctions else creature->SetTempSummonType(TEMPSUMMON_MANUAL_DESPAWN); - Eluna::Push(L, creature); + E->Push(creature); } return 1; @@ -1544,13 +1544,13 @@ namespace LuaGlobalFunctions const GameObjectTemplate* objectInfo = eObjectMgr->GetGameObjectTemplate(entry); if (!objectInfo) { - Eluna::Push(L); + E->Push(E->L); return 1; } if (objectInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(objectInfo->displayId)) { - Eluna::Push(L); + E->Push(E->L); return 1; } @@ -1564,7 +1564,7 @@ namespace LuaGlobalFunctions #endif { delete object; - Eluna::Push(L); + E->Push(E->L); return 1; } @@ -1590,18 +1590,18 @@ namespace LuaGlobalFunctions if (!object->LoadFromDB(guidLow, map, true)) { delete object; - Eluna::Push(L); + E->Push(E->L); return 1; } eObjectMgr->AddGameobjectToGrid(guidLow, eObjectMgr->GetGameObjectData(guidLow)); } else map->AddToMap(object); - Eluna::Push(L, object); + E->Push(object); return 1; } - Eluna::Push(L); + E->Push(E->L); return 1; } @@ -1612,14 +1612,14 @@ namespace LuaGlobalFunctions * @param uint32 size : the size of the packet * @return [WorldPacket] packet */ - int CreatePacket(lua_State* L) + int CreatePacket(Eluna* E) { - uint32 opcode = Eluna::CHECKVAL(L, 1); - size_t size = Eluna::CHECKVAL(L, 2); + uint32 opcode = Eluna::CHECKVAL(E->L, 1); + size_t size = Eluna::CHECKVAL(E->L, 2); if (opcode >= NUM_MSG_TYPES) - return luaL_argerror(L, 1, "valid opcode expected"); + return luaL_argerror(E->L, 1, "valid opcode expected"); - Eluna::Push(L, new WorldPacket((OpcodesList)opcode, size)); + E->Push(new WorldPacket((OpcodesList)opcode, size)); return 1; } @@ -1632,13 +1632,13 @@ namespace LuaGlobalFunctions * @param uint32 incrtime : combined with maxcount, incrtime tells how often (in seconds) the vendor list is refreshed and the limited [Item] copies are restocked * @param uint32 extendedcost : unique cost of an [Item], such as conquest points for example */ - int AddVendorItem(lua_State* L) + int AddVendorItem(Eluna* E) { - uint32 entry = Eluna::CHECKVAL(L, 1); - uint32 item = Eluna::CHECKVAL(L, 2); - int maxcount = Eluna::CHECKVAL(L, 3); - uint32 incrtime = Eluna::CHECKVAL(L, 4); - uint32 extendedcost = Eluna::CHECKVAL(L, 5); + uint32 entry = Eluna::CHECKVAL(E->L, 1); + uint32 item = Eluna::CHECKVAL(E->L, 2); + int maxcount = Eluna::CHECKVAL(E->L, 3); + uint32 incrtime = Eluna::CHECKVAL(E->L, 4); + uint32 extendedcost = Eluna::CHECKVAL(E->L, 5); #ifdef CATA VendorItem vItem; @@ -1665,12 +1665,12 @@ namespace LuaGlobalFunctions * @param uint32 entry : [Creature] entry Id * @param uint32 item : [Item] entry Id */ - int VendorRemoveItem(lua_State* L) + int VendorRemoveItem(Eluna* E) { - uint32 entry = Eluna::CHECKVAL(L, 1); - uint32 item = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 1); + uint32 item = Eluna::CHECKVAL(E->L, 2); if (!eObjectMgr->GetCreatureTemplate(entry)) - return luaL_argerror(L, 1, "valid CreatureEntry expected"); + return luaL_argerror(E->L, 1, "valid CreatureEntry expected"); #ifdef CATA eObjectMgr->RemoveVendorItem(entry, item, 1); @@ -1686,9 +1686,9 @@ namespace LuaGlobalFunctions * * @param uint32 entry : [Creature] entry Id */ - int VendorRemoveAllItems(lua_State* L) + int VendorRemoveAllItems(Eluna* E) { - uint32 entry = Eluna::CHECKVAL(L, 1); + uint32 entry = Eluna::CHECKVAL(E->L, 1); VendorItemData const* items = eObjectMgr->GetNpcVendorItemList(entry); if (!items || items->Empty()) @@ -1710,9 +1710,9 @@ namespace LuaGlobalFunctions * * @param [Player] player : [Player] to kick */ - int Kick(lua_State* L) + int Kick(Eluna* E) { - Player* player = Eluna::CHECKOBJ(L, 1); + Player* player = Eluna::CHECKOBJ(E->L, 1); #ifndef CATA player->GetSession()->KickPlayer("GlobalMethods::Kick Kick the player"); @@ -1739,13 +1739,13 @@ namespace LuaGlobalFunctions * @param string whoBanned = "" : the [Player]'s name that banned the account, character or IP, this is optional * @return int result : status of the ban. 0 if success, 1 if syntax error, 2 if target not found, 3 if a longer ban already exists, nil if unknown result */ - int Ban(lua_State* L) + int Ban(Eluna* E) { - int banMode = Eluna::CHECKVAL(L, 1); - std::string nameOrIP = Eluna::CHECKVAL(L, 2); - uint32 duration = Eluna::CHECKVAL(L, 3); - const char* reason = Eluna::CHECKVAL(L, 4, ""); - const char* whoBanned = Eluna::CHECKVAL(L, 5, ""); + int banMode = Eluna::CHECKVAL(E->L, 1); + std::string nameOrIP = Eluna::CHECKVAL(E->L, 2); + uint32 duration = Eluna::CHECKVAL(E->L, 3); + const char* reason = Eluna::CHECKVAL(E->L, 4, ""); + const char* whoBanned = Eluna::CHECKVAL(E->L, 5, ""); const int BAN_ACCOUNT = 0; const int BAN_CHARACTER = 1; @@ -1757,21 +1757,21 @@ namespace LuaGlobalFunctions { case BAN_ACCOUNT: if (!Utf8ToUpperOnlyLatin(nameOrIP)) - return luaL_argerror(L, 2, "invalid account name"); + return luaL_argerror(E->L, 2, "invalid account name"); mode = BanMode::BAN_ACCOUNT; break; case BAN_CHARACTER: if (!normalizePlayerName(nameOrIP)) - return luaL_argerror(L, 2, "invalid character name"); + return luaL_argerror(E->L, 2, "invalid character name"); mode = BanMode::BAN_CHARACTER; break; case BAN_IP: if (!IsIPAddress(nameOrIP.c_str())) - return luaL_argerror(L, 2, "invalid ip"); + return luaL_argerror(E->L, 2, "invalid ip"); mode = BanMode::BAN_IP; break; default: - return luaL_argerror(L, 1, "unknown banmode"); + return luaL_argerror(E->L, 1, "unknown banmode"); } BanReturn result; @@ -1779,16 +1779,16 @@ namespace LuaGlobalFunctions switch (result) { case BanReturn::BAN_SUCCESS: - Eluna::Push(L, 0); + E->Push(0); break; case BanReturn::BAN_SYNTAX_ERROR: - Eluna::Push(L, 1); + E->Push(1); break; case BanReturn::BAN_NOTFOUND: - Eluna::Push(L, 2); + E->Push(2); break; case BanReturn::BAN_EXISTS: - Eluna::Push(L, 3); + E->Push(3); break; } return 1; @@ -1797,7 +1797,7 @@ namespace LuaGlobalFunctions /** * Saves all [Player]s. */ - int SaveAllPlayers(lua_State* /*L*/) + int SaveAllPlayers(Eluna* /*E*/) { eObjectAccessor()SaveAllPlayers(); return 0; @@ -1832,18 +1832,18 @@ namespace LuaGlobalFunctions * @param uint32 amount = 0 : amount of the [Item] to send with mail * @return uint32 itemGUIDlow : low GUID of the item. Up to 12 values returned, returns nil if no further items are sent */ - int SendMail(lua_State* L) + int SendMail(Eluna* E) { int i = 0; - std::string subject = Eluna::CHECKVAL(L, ++i); - std::string text = Eluna::CHECKVAL(L, ++i); - uint32 receiverGUIDLow = Eluna::CHECKVAL(L, ++i); - uint32 senderGUIDLow = Eluna::CHECKVAL(L, ++i, 0); - uint32 stationary = Eluna::CHECKVAL(L, ++i, MAIL_STATIONERY_DEFAULT); - uint32 delay = Eluna::CHECKVAL(L, ++i, 0); - uint32 money = Eluna::CHECKVAL(L, ++i, 0); - uint32 cod = Eluna::CHECKVAL(L, ++i, 0); - int argAmount = lua_gettop(L); + std::string subject = Eluna::CHECKVAL(E->L, ++i); + std::string text = Eluna::CHECKVAL(E->L, ++i); + uint32 receiverGUIDLow = Eluna::CHECKVAL(E->L, ++i); + uint32 senderGUIDLow = Eluna::CHECKVAL(E->L, ++i, 0); + uint32 stationary = Eluna::CHECKVAL(E->L, ++i, MAIL_STATIONERY_DEFAULT); + uint32 delay = Eluna::CHECKVAL(E->L, ++i, 0); + uint32 money = Eluna::CHECKVAL(E->L, ++i, 0); + uint32 cod = Eluna::CHECKVAL(E->L, ++i, 0); + int argAmount = lua_gettop(E->L); MailSender sender(MAIL_NORMAL, senderGUIDLow, (MailStationery)stationary); MailDraft draft(subject, text); @@ -1857,13 +1857,13 @@ namespace LuaGlobalFunctions uint8 addedItems = 0; while (addedItems <= MAX_MAIL_ITEMS && i + 2 <= argAmount) { - uint32 entry = Eluna::CHECKVAL(L, ++i); - uint32 amount = Eluna::CHECKVAL(L, ++i); + uint32 entry = Eluna::CHECKVAL(E->L, ++i); + uint32 amount = Eluna::CHECKVAL(E->L, ++i); ItemTemplate const* item_proto = eObjectMgr->GetItemTemplate(entry); if (!item_proto) { - luaL_error(L, "Item entry %d does not exist", entry); + luaL_error(E->L, "Item entry %d does not exist", entry); continue; } #ifdef CATA @@ -1872,14 +1872,14 @@ namespace LuaGlobalFunctions if (amount < 1 || (item_proto->MaxCount > 0 && amount > uint32(item_proto->MaxCount))) #endif { - luaL_error(L, "Item entry %d has invalid amount %d", entry, amount); + luaL_error(E->L, "Item entry %d has invalid amount %d", entry, amount); continue; } if (Item* item = Item::CreateItem(entry, amount)) { item->SaveToDB(trans); draft.AddItem(item); - Eluna::Push(L, item->GetGUID().GetCounter()); + E->Push(item->GetGUID().GetCounter()); ++addedItems; } } @@ -1898,11 +1898,11 @@ namespace LuaGlobalFunctions * @param uint32 b * @return uint32 result */ - int bit_and(lua_State* L) + int bit_and(Eluna* E) { - uint32 a = Eluna::CHECKVAL(L, 1); - uint32 b = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, a & b); + uint32 a = Eluna::CHECKVAL(E->L, 1); + uint32 b = Eluna::CHECKVAL(E->L, 2); + E->Push(a & b); return 1; } @@ -1913,11 +1913,11 @@ namespace LuaGlobalFunctions * @param uint32 b * @return uint32 result */ - int bit_or(lua_State* L) + int bit_or(Eluna* E) { - uint32 a = Eluna::CHECKVAL(L, 1); - uint32 b = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, a | b); + uint32 a = Eluna::CHECKVAL(E->L, 1); + uint32 b = Eluna::CHECKVAL(E->L, 2); + E->Push(a | b); return 1; } @@ -1928,11 +1928,11 @@ namespace LuaGlobalFunctions * @param uint32 b * @return uint32 result */ - int bit_lshift(lua_State* L) + int bit_lshift(Eluna* E) { - uint32 a = Eluna::CHECKVAL(L, 1); - uint32 b = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, a << b); + uint32 a = Eluna::CHECKVAL(E->L, 1); + uint32 b = Eluna::CHECKVAL(E->L, 2); + E->Push(a << b); return 1; } @@ -1943,11 +1943,11 @@ namespace LuaGlobalFunctions * @param uint32 b * @return uint32 result */ - int bit_rshift(lua_State* L) + int bit_rshift(Eluna* E) { - uint32 a = Eluna::CHECKVAL(L, 1); - uint32 b = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, a >> b); + uint32 a = Eluna::CHECKVAL(E->L, 1); + uint32 b = Eluna::CHECKVAL(E->L, 2); + E->Push(a >> b); return 1; } @@ -1958,11 +1958,11 @@ namespace LuaGlobalFunctions * @param uint32 b * @return uint32 result */ - int bit_xor(lua_State* L) + int bit_xor(Eluna* E) { - uint32 a = Eluna::CHECKVAL(L, 1); - uint32 b = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, a ^ b); + uint32 a = Eluna::CHECKVAL(E->L, 1); + uint32 b = Eluna::CHECKVAL(E->L, 2); + E->Push(a ^ b); return 1; } @@ -1972,10 +1972,10 @@ namespace LuaGlobalFunctions * @param uint32 a * @return uint32 result */ - int bit_not(lua_State* L) + int bit_not(Eluna* E) { - uint32 a = Eluna::CHECKVAL(L, 1); - Eluna::Push(L, ~a); + uint32 a = Eluna::CHECKVAL(E->L, 1); + E->Push(~a); return 1; } @@ -2001,70 +2001,70 @@ namespace LuaGlobalFunctions * @param uint32 pathId = 0 : path Id of the taxi path * @return uint32 actualPathId */ - int AddTaxiPath(lua_State* L) + int AddTaxiPath(Eluna* E) { - luaL_checktype(L, 1, LUA_TTABLE); - uint32 mountA = Eluna::CHECKVAL(L, 2); - uint32 mountH = Eluna::CHECKVAL(L, 3); - uint32 price = Eluna::CHECKVAL(L, 4, 0); - uint32 pathId = Eluna::CHECKVAL(L, 5, 0); - lua_pushvalue(L, 1); + luaL_checktype(E->L, 1, LUA_TTABLE); + uint32 mountA = Eluna::CHECKVAL(E->L, 2); + uint32 mountH = Eluna::CHECKVAL(E->L, 3); + uint32 price = Eluna::CHECKVAL(E->L, 4, 0); + uint32 pathId = Eluna::CHECKVAL(E->L, 5, 0); + lua_pushvalue(E->L, 1); // Stack: {nodes}, mountA, mountH, price, pathid, {nodes} std::list nodes; - int start = lua_gettop(L); + int start = lua_gettop(E->L); int end = start; - Eluna::Push(L); + E->Push(E->L); // Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, nil - while (lua_next(L, -2) != 0) + while (lua_next(E->L, -2) != 0) { // Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, key, value - luaL_checktype(L, -1, LUA_TTABLE); - Eluna::Push(L); + luaL_checktype(E->L, -1, LUA_TTABLE); + E->Push(E->L); // Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, key, value, nil - while (lua_next(L, -2) != 0) + while (lua_next(E->L, -2) != 0) { // Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, key, value, key2, value2 - lua_insert(L, end++); + lua_insert(E->L, end++); // Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, value2, key, value, key2 } // Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, value2, key, value if (start == end) continue; if (end - start < 4) // no mandatory args, dont add - return luaL_argerror(L, 1, "all waypoints do not have mandatory arguments"); + return luaL_argerror(E->L, 1, "all waypoints do not have mandatory arguments"); while (end - start < 8) // fill optional args with 0 { - Eluna::Push(L, 0); - lua_insert(L, end++); + E->Push(0); + lua_insert(E->L, end++); // Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, node, key, value } TaxiPathNodeEntry entry; // mandatory - entry.ContinentID = Eluna::CHECKVAL(L, start); - entry.Loc.X = Eluna::CHECKVAL(L, start + 1); - entry.Loc.Y = Eluna::CHECKVAL(L, start + 2); - entry.Loc.Z = Eluna::CHECKVAL(L, start + 3); + entry.ContinentID = Eluna::CHECKVAL(E->L, start); + entry.Loc.X = Eluna::CHECKVAL(E->L, start + 1); + entry.Loc.Y = Eluna::CHECKVAL(E->L, start + 2); + entry.Loc.Z = Eluna::CHECKVAL(E->L, start + 3); // optional - entry.Flags = Eluna::CHECKVAL(L, start + 4, 0); - entry.Delay = Eluna::CHECKVAL(L, start + 5, 0); + entry.Flags = Eluna::CHECKVAL(E->L, start + 4, 0); + entry.Delay = Eluna::CHECKVAL(E->L, start + 5, 0); nodes.push_back(entry); while (end != start) // remove args - if (!lua_isnone(L, --end)) - lua_remove(L, end); + if (!lua_isnone(E->L, --end)) + lua_remove(E->L, end); // Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, key, value - lua_pop(L, 1); + lua_pop(E->L, 1); // Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, key } // Stack: {nodes}, mountA, mountH, price, pathid, {nodes} - lua_pop(L, 1); + lua_pop(E->L, 1); // Stack: {nodes}, mountA, mountH, price, pathid if (nodes.size() < 2) @@ -2107,7 +2107,7 @@ namespace LuaGlobalFunctions sTaxiPathStore.SetEntry(pathId, pathEntry); - Eluna::Push(L, pathId); + E->Push(pathId); return 1; } @@ -2137,12 +2137,12 @@ namespace LuaGlobalFunctions * @param uint8 slot : the slot the [Item] is in within the bag, you can get this with [Item:GetSlot] * @return bool isInventoryPos */ - int IsInventoryPos(lua_State* L) + int IsInventoryPos(Eluna* E) { - uint8 bag = Eluna::CHECKVAL(L, 1); - uint8 slot = Eluna::CHECKVAL(L, 2); + uint8 bag = Eluna::CHECKVAL(E->L, 1); + uint8 slot = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, Player::IsInventoryPos(bag, slot)); + E->Push(Player::IsInventoryPos(bag, slot)); return 1; } @@ -2155,12 +2155,12 @@ namespace LuaGlobalFunctions * @param uint8 slot : the slot the [Item] is in within the bag, you can get this with [Item:GetSlot] * @return bool isEquipmentPosition */ - int IsEquipmentPos(lua_State* L) + int IsEquipmentPos(Eluna* E) { - uint8 bag = Eluna::CHECKVAL(L, 1); - uint8 slot = Eluna::CHECKVAL(L, 2); + uint8 bag = Eluna::CHECKVAL(E->L, 1); + uint8 slot = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, Player::IsEquipmentPos(bag, slot)); + E->Push(Player::IsEquipmentPos(bag, slot)); return 1; } @@ -2173,12 +2173,12 @@ namespace LuaGlobalFunctions * @param uint8 slot : the slot the [Item] is in within the bag, you can get this with [Item:GetSlot] * @return bool isBankPosition */ - int IsBankPos(lua_State* L) + int IsBankPos(Eluna* E) { - uint8 bag = Eluna::CHECKVAL(L, 1); - uint8 slot = Eluna::CHECKVAL(L, 2); + uint8 bag = Eluna::CHECKVAL(E->L, 1); + uint8 slot = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, Player::IsBankPos(bag, slot)); + E->Push(Player::IsBankPos(bag, slot)); return 1; } @@ -2191,12 +2191,12 @@ namespace LuaGlobalFunctions * @param uint8 slot : the slot the [Item] is in within the bag, you can get this with [Item:GetSlot] * @return bool isBagPosition */ - int IsBagPos(lua_State* L) + int IsBagPos(Eluna* E) { - uint8 bag = Eluna::CHECKVAL(L, 1); - uint8 slot = Eluna::CHECKVAL(L, 2); + uint8 bag = Eluna::CHECKVAL(E->L, 1); + uint8 slot = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, Player::IsBagPos((bag << 8) + slot)); + E->Push(Player::IsBagPos((bag << 8) + slot)); return 1; } @@ -2206,11 +2206,11 @@ namespace LuaGlobalFunctions * @param uint16 eventId : the event id to check. * @return bool isActive */ - int IsGameEventActive(lua_State* L) + int IsGameEventActive(Eluna* E) { - uint16 eventId = Eluna::CHECKVAL(L, 1); + uint16 eventId = Eluna::CHECKVAL(E->L, 1); - Eluna::Push(L, eGameEventMgr->IsActiveEvent(eventId)); + E->Push(eGameEventMgr->IsActiveEvent(eventId)); return 1; } @@ -2219,9 +2219,9 @@ namespace LuaGlobalFunctions * * @return uint32 currTime : the current time, in milliseconds */ - int GetCurrTime(lua_State* L) + int GetCurrTime(Eluna* E) { - Eluna::Push(L, ElunaUtil::GetCurrTime()); + E->Push(ElunaUtil::GetCurrTime()); return 1; } @@ -2231,22 +2231,22 @@ namespace LuaGlobalFunctions * @param uint32 oldTime : an old timestamp, in milliseconds * @return uint32 timeDiff : the difference, in milliseconds */ - int GetTimeDiff(lua_State* L) + int GetTimeDiff(Eluna* E) { - uint32 oldtimems = Eluna::CHECKVAL(L, 1); + uint32 oldtimems = Eluna::CHECKVAL(E->L, 1); - Eluna::Push(L, ElunaUtil::GetTimeDiff(oldtimems)); + E->Push(ElunaUtil::GetTimeDiff(oldtimems)); return 1; } - static std::string GetStackAsString(lua_State* L) + static std::string GetStackAsString(Eluna* E) { std::ostringstream oss; - int top = lua_gettop(L); + int top = lua_gettop(E->L); for (int i = 1; i <= top; ++i) { - oss << luaL_tolstring(L, i, NULL); - lua_pop(L, 1); + oss << luaL_tolstring(E->L, i, NULL); + lua_pop(E->L, 1); } return oss.str(); } @@ -2256,9 +2256,9 @@ namespace LuaGlobalFunctions * * @param ... */ - int PrintInfo(lua_State* L) + int PrintInfo(Eluna* E) { - ELUNA_LOG_INFO("%s", GetStackAsString(L).c_str()); + ELUNA_LOG_INFO("%s", GetStackAsString(E).c_str()); return 0; } @@ -2267,9 +2267,9 @@ namespace LuaGlobalFunctions * * @param ... */ - int PrintError(lua_State* L) + int PrintError(Eluna* E) { - ELUNA_LOG_ERROR("%s", GetStackAsString(L).c_str()); + ELUNA_LOG_ERROR("%s", GetStackAsString(E).c_str()); return 0; } @@ -2278,9 +2278,9 @@ namespace LuaGlobalFunctions * * @param ... */ - int PrintDebug(lua_State* L) + int PrintDebug(Eluna* E) { - ELUNA_LOG_DEBUG("%s", GetStackAsString(L).c_str()); + ELUNA_LOG_DEBUG("%s", GetStackAsString(E).c_str()); return 0; } @@ -2290,10 +2290,10 @@ namespace LuaGlobalFunctions * @param uint16 eventId : the event id to start. * @param bool force = false : set `true` to force start the event. */ - int StartGameEvent(lua_State* L) + int StartGameEvent(Eluna* E) { - uint16 eventId = Eluna::CHECKVAL(L, 1); - bool force = Eluna::CHECKVAL(L, 2, false); + uint16 eventId = Eluna::CHECKVAL(E->L, 1); + bool force = Eluna::CHECKVAL(E->L, 2, false); eGameEventMgr->StartEvent(eventId, force); return 0; @@ -2305,10 +2305,10 @@ namespace LuaGlobalFunctions * @param uint16 eventId : the event id to stop. * @param bool force = false : set `true` to force stop the event. */ - int StopGameEvent(lua_State* L) + int StopGameEvent(Eluna* E) { - uint16 eventId = Eluna::CHECKVAL(L, 1); - bool force = Eluna::CHECKVAL(L, 2, false); + uint16 eventId = Eluna::CHECKVAL(E->L, 1); + bool force = Eluna::CHECKVAL(E->L, 2, false); eGameEventMgr->StopEvent(eventId, force); return 0; @@ -2328,21 +2328,21 @@ namespace LuaGlobalFunctions * @param string n_str * @return int64 value */ - int CreateLongLong(lua_State* L) + int CreateLongLong(Eluna* E) { long long init = 0; - if (lua_isstring(L, 1)) + if (lua_isstring(E->L, 1)) { - std::string str = Eluna::CHECKVAL(L, 1); + std::string str = Eluna::CHECKVAL(E->L, 1); std::istringstream iss(str); iss >> init; if (iss.bad()) - return luaL_argerror(L, 1, "long long (as string) could not be converted"); + return luaL_argerror(E->L, 1, "long long (as string) could not be converted"); } - else if (!lua_isnoneornil(L, 1)) - init = Eluna::CHECKVAL(L, 1); + else if (!lua_isnoneornil(E->L, 1)) + init = Eluna::CHECKVAL(E->L, 1); - Eluna::Push(L, init); + E->Push(init); return 1; } @@ -2360,21 +2360,21 @@ namespace LuaGlobalFunctions * @param string n_str * @return uint64 value */ - int CreateULongLong(lua_State* L) + int CreateULongLong(Eluna* E) { unsigned long long init = 0; - if (lua_isstring(L, 1)) + if (lua_isstring(E->L, 1)) { - std::string str = Eluna::CHECKVAL(L, 1); + std::string str = Eluna::CHECKVAL(E->L, 1); std::istringstream iss(str); iss >> init; if (iss.bad()) - return luaL_argerror(L, 1, "unsigned long long (as string) could not be converted"); + return luaL_argerror(E->L, 1, "unsigned long long (as string) could not be converted"); } - else if (!lua_isnoneornil(L, 1)) - init = Eluna::CHECKVAL(L, 1); + else if (!lua_isnoneornil(E->L, 1)) + init = Eluna::CHECKVAL(E->L, 1); - Eluna::Push(L, init); + E->Push(init); return 1; } @@ -2389,18 +2389,18 @@ namespace LuaGlobalFunctions * @proto (event_type) * @param uint32 event_type : the event whose handlers will be cleared, see [Global:RegisterBGEvent] */ - int ClearBattleGroundEvents(lua_State* L) + int ClearBattleGroundEvents(Eluna* E) { typedef EventKey Key; - if (lua_isnoneornil(L, 1)) + if (lua_isnoneornil(E->L, 1)) { - Eluna::GetEluna(L)->BGEventBindings->Clear(); + E->BGEventBindings->Clear(); } else { - uint32 event_type = Eluna::CHECKVAL(L, 1); - Eluna::GetEluna(L)->BGEventBindings->Clear(Key((Hooks::BGEvents)event_type)); + uint32 event_type = Eluna::CHECKVAL(E->L, 1); + E->BGEventBindings->Clear(Key((Hooks::BGEvents)event_type)); } return 0; } @@ -2420,23 +2420,22 @@ namespace LuaGlobalFunctions * @param uint32 entry : the ID of one or more [Creature]s whose handlers will be cleared * @param uint32 event_type : the event whose handlers will be cleared, see [Global:RegisterCreatureEvent] */ - int ClearCreatureEvents(lua_State* L) + int ClearCreatureEvents(Eluna* E) { typedef EntryKey Key; - if (lua_isnoneornil(L, 2)) + if (lua_isnoneornil(E->L, 2)) { - uint32 entry = Eluna::CHECKVAL(L, 1); + uint32 entry = Eluna::CHECKVAL(E->L, 1); - Eluna* E = Eluna::GetEluna(L); for (uint32 i = 1; i < Hooks::CREATURE_EVENT_COUNT; ++i) E->CreatureEventBindings->Clear(Key((Hooks::CreatureEvents)i, entry)); } else { - uint32 entry = Eluna::CHECKVAL(L, 1); - uint32 event_type = Eluna::CHECKVAL(L, 2); - Eluna::GetEluna(L)->CreatureEventBindings->Clear(Key((Hooks::CreatureEvents)event_type, entry)); + uint32 entry = Eluna::CHECKVAL(E->L, 1); + uint32 event_type = Eluna::CHECKVAL(E->L, 2); + E->CreatureEventBindings->Clear(Key((Hooks::CreatureEvents)event_type, entry)); } return 0; } @@ -2457,25 +2456,24 @@ namespace LuaGlobalFunctions * @param uint32 instance_id : the instance ID of a single [Creature] whose handlers will be cleared * @param uint32 event_type : the event whose handlers will be cleared, see [Global:RegisterCreatureEvent] */ - int ClearUniqueCreatureEvents(lua_State* L) + int ClearUniqueCreatureEvents(Eluna* E) { typedef UniqueObjectKey Key; - if (lua_isnoneornil(L, 3)) + if (lua_isnoneornil(E->L, 3)) { - ObjectGuid guid = Eluna::CHECKVAL(L, 1); - uint32 instanceId = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 1); + uint32 instanceId = Eluna::CHECKVAL(E->L, 2); - Eluna* E = Eluna::GetEluna(L); for (uint32 i = 1; i < Hooks::CREATURE_EVENT_COUNT; ++i) E->CreatureUniqueBindings->Clear(Key((Hooks::CreatureEvents)i, guid, instanceId)); } else { - ObjectGuid guid = Eluna::CHECKVAL(L, 1); - uint32 instanceId = Eluna::CHECKVAL(L, 2); - uint32 event_type = Eluna::CHECKVAL(L, 3); - Eluna::GetEluna(L)->CreatureUniqueBindings->Clear(Key((Hooks::CreatureEvents)event_type, guid, instanceId)); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 1); + uint32 instanceId = Eluna::CHECKVAL(E->L, 2); + uint32 event_type = Eluna::CHECKVAL(E->L, 3); + E->CreatureUniqueBindings->Clear(Key((Hooks::CreatureEvents)event_type, guid, instanceId)); } return 0; } @@ -2495,23 +2493,22 @@ namespace LuaGlobalFunctions * @param uint32 entry : the ID of a [Creature] whose handlers will be cleared * @param uint32 event_type : the event whose handlers will be cleared, see [Global:RegisterCreatureGossipEvent] */ - int ClearCreatureGossipEvents(lua_State* L) + int ClearCreatureGossipEvents(Eluna* E) { typedef EntryKey Key; - if (lua_isnoneornil(L, 2)) + if (lua_isnoneornil(E->L, 2)) { - uint32 entry = Eluna::CHECKVAL(L, 1); + uint32 entry = Eluna::CHECKVAL(E->L, 1); - Eluna* E = Eluna::GetEluna(L); for (uint32 i = 1; i < Hooks::GOSSIP_EVENT_COUNT; ++i) E->CreatureGossipBindings->Clear(Key((Hooks::GossipEvents)i, entry)); } else { - uint32 entry = Eluna::CHECKVAL(L, 1); - uint32 event_type = Eluna::CHECKVAL(L, 2); - Eluna::GetEluna(L)->CreatureGossipBindings->Clear(Key((Hooks::GossipEvents)event_type, entry)); + uint32 entry = Eluna::CHECKVAL(E->L, 1); + uint32 event_type = Eluna::CHECKVAL(E->L, 2); + E->CreatureGossipBindings->Clear(Key((Hooks::GossipEvents)event_type, entry)); } return 0; } @@ -2531,23 +2528,22 @@ namespace LuaGlobalFunctions * @param uint32 entry : the ID of a [GameObject] whose handlers will be cleared * @param uint32 event_type : the event whose handlers will be cleared, see [Global:RegisterGameObjectEvent] */ - int ClearGameObjectEvents(lua_State* L) + int ClearGameObjectEvents(Eluna* E) { typedef EntryKey Key; - if (lua_isnoneornil(L, 2)) + if (lua_isnoneornil(E->L, 2)) { - uint32 entry = Eluna::CHECKVAL(L, 1); + uint32 entry = Eluna::CHECKVAL(E->L, 1); - Eluna* E = Eluna::GetEluna(L); for (uint32 i = 1; i < Hooks::GAMEOBJECT_EVENT_COUNT; ++i) E->GameObjectEventBindings->Clear(Key((Hooks::GameObjectEvents)i, entry)); } else { - uint32 entry = Eluna::CHECKVAL(L, 1); - uint32 event_type = Eluna::CHECKVAL(L, 2); - Eluna::GetEluna(L)->GameObjectEventBindings->Clear(Key((Hooks::GameObjectEvents)event_type, entry)); + uint32 entry = Eluna::CHECKVAL(E->L, 1); + uint32 event_type = Eluna::CHECKVAL(E->L, 2); + E->GameObjectEventBindings->Clear(Key((Hooks::GameObjectEvents)event_type, entry)); } return 0; } @@ -2567,23 +2563,22 @@ namespace LuaGlobalFunctions * @param uint32 entry : the ID of a [GameObject] whose handlers will be cleared * @param uint32 event_type : the event whose handlers will be cleared, see [Global:RegisterGameObjectGossipEvent] */ - int ClearGameObjectGossipEvents(lua_State* L) + int ClearGameObjectGossipEvents(Eluna* E) { typedef EntryKey Key; - if (lua_isnoneornil(L, 2)) + if (lua_isnoneornil(E->L, 2)) { - uint32 entry = Eluna::CHECKVAL(L, 1); + uint32 entry = Eluna::CHECKVAL(E->L, 1); - Eluna* E = Eluna::GetEluna(L); for (uint32 i = 1; i < Hooks::GOSSIP_EVENT_COUNT; ++i) E->GameObjectGossipBindings->Clear(Key((Hooks::GossipEvents)i, entry)); } else { - uint32 entry = Eluna::CHECKVAL(L, 1); - uint32 event_type = Eluna::CHECKVAL(L, 2); - Eluna::GetEluna(L)->GameObjectGossipBindings->Clear(Key((Hooks::GossipEvents)event_type, entry)); + uint32 entry = Eluna::CHECKVAL(E->L, 1); + uint32 event_type = Eluna::CHECKVAL(E->L, 2); + E->GameObjectGossipBindings->Clear(Key((Hooks::GossipEvents)event_type, entry)); } return 0; } @@ -2599,18 +2594,18 @@ namespace LuaGlobalFunctions * @proto (event_type) * @param uint32 event_type : the event whose handlers will be cleared, see [Global:RegisterGroupEvent] */ - int ClearGroupEvents(lua_State* L) + int ClearGroupEvents(Eluna* E) { typedef EventKey Key; - if (lua_isnoneornil(L, 1)) + if (lua_isnoneornil(E->L, 1)) { - Eluna::GetEluna(L)->GroupEventBindings->Clear(); + E->GroupEventBindings->Clear(); } else { - uint32 event_type = Eluna::CHECKVAL(L, 1); - Eluna::GetEluna(L)->GroupEventBindings->Clear(Key((Hooks::GroupEvents)event_type)); + uint32 event_type = Eluna::CHECKVAL(E->L, 1); + E->GroupEventBindings->Clear(Key((Hooks::GroupEvents)event_type)); } return 0; } @@ -2626,18 +2621,18 @@ namespace LuaGlobalFunctions * @proto (event_type) * @param uint32 event_type : the event whose handlers will be cleared, see [Global:RegisterGuildEvent] */ - int ClearGuildEvents(lua_State* L) + int ClearGuildEvents(Eluna* E) { typedef EventKey Key; - if (lua_isnoneornil(L, 1)) + if (lua_isnoneornil(E->L, 1)) { - Eluna::GetEluna(L)->GuildEventBindings->Clear(); + E->GuildEventBindings->Clear(); } else { - uint32 event_type = Eluna::CHECKVAL(L, 1); - Eluna::GetEluna(L)->GuildEventBindings->Clear(Key((Hooks::GuildEvents)event_type)); + uint32 event_type = Eluna::CHECKVAL(E->L, 1); + E->GuildEventBindings->Clear(Key((Hooks::GuildEvents)event_type)); } return 0; } @@ -2657,23 +2652,22 @@ namespace LuaGlobalFunctions * @param uint32 entry : the ID of an [Item] whose handlers will be cleared * @param uint32 event_type : the event whose handlers will be cleared, see [Global:RegisterItemEvent] */ - int ClearItemEvents(lua_State* L) + int ClearItemEvents(Eluna* E) { typedef EntryKey Key; - if (lua_isnoneornil(L, 2)) + if (lua_isnoneornil(E->L, 2)) { - uint32 entry = Eluna::CHECKVAL(L, 1); + uint32 entry = Eluna::CHECKVAL(E->L, 1); - Eluna* E = Eluna::GetEluna(L); for (uint32 i = 1; i < Hooks::ITEM_EVENT_COUNT; ++i) E->ItemEventBindings->Clear(Key((Hooks::ItemEvents)i, entry)); } else { - uint32 entry = Eluna::CHECKVAL(L, 1); - uint32 event_type = Eluna::CHECKVAL(L, 2); - Eluna::GetEluna(L)->ItemEventBindings->Clear(Key((Hooks::ItemEvents)event_type, entry)); + uint32 entry = Eluna::CHECKVAL(E->L, 1); + uint32 event_type = Eluna::CHECKVAL(E->L, 2); + E->ItemEventBindings->Clear(Key((Hooks::ItemEvents)event_type, entry)); } return 0; } @@ -2693,23 +2687,22 @@ namespace LuaGlobalFunctions * @param uint32 entry : the ID of an [Item] whose handlers will be cleared * @param uint32 event_type : the event whose handlers will be cleared, see [Global:RegisterItemGossipEvent] */ - int ClearItemGossipEvents(lua_State* L) + int ClearItemGossipEvents(Eluna* E) { typedef EntryKey Key; - if (lua_isnoneornil(L, 2)) + if (lua_isnoneornil(E->L, 2)) { - uint32 entry = Eluna::CHECKVAL(L, 1); + uint32 entry = Eluna::CHECKVAL(E->L, 1); - Eluna* E = Eluna::GetEluna(L); for (uint32 i = 1; i < Hooks::GOSSIP_EVENT_COUNT; ++i) E->ItemGossipBindings->Clear(Key((Hooks::GossipEvents)i, entry)); } else { - uint32 entry = Eluna::CHECKVAL(L, 1); - uint32 event_type = Eluna::CHECKVAL(L, 2); - Eluna::GetEluna(L)->ItemGossipBindings->Clear(Key((Hooks::GossipEvents)event_type, entry)); + uint32 entry = Eluna::CHECKVAL(E->L, 1); + uint32 event_type = Eluna::CHECKVAL(E->L, 2); + E->ItemGossipBindings->Clear(Key((Hooks::GossipEvents)event_type, entry)); } return 0; } @@ -2726,23 +2719,22 @@ namespace LuaGlobalFunctions * @param uint32 opcode : the type of [WorldPacket] whose handlers will be cleared * @param uint32 event_type : the event whose handlers will be cleared, see [Global:RegisterPacketEvent] */ - int ClearPacketEvents(lua_State* L) + int ClearPacketEvents(Eluna* E) { typedef EntryKey Key; - if (lua_isnoneornil(L, 2)) + if (lua_isnoneornil(E->L, 2)) { - uint32 entry = Eluna::CHECKVAL(L, 1); + uint32 entry = Eluna::CHECKVAL(E->L, 1); - Eluna* E = Eluna::GetEluna(L); for (uint32 i = 1; i < Hooks::PACKET_EVENT_COUNT; ++i) E->PacketEventBindings->Clear(Key((Hooks::PacketEvents)i, entry)); } else { - uint32 entry = Eluna::CHECKVAL(L, 1); - uint32 event_type = Eluna::CHECKVAL(L, 2); - Eluna::GetEluna(L)->PacketEventBindings->Clear(Key((Hooks::PacketEvents)event_type, entry)); + uint32 entry = Eluna::CHECKVAL(E->L, 1); + uint32 event_type = Eluna::CHECKVAL(E->L, 2); + E->PacketEventBindings->Clear(Key((Hooks::PacketEvents)event_type, entry)); } return 0; } @@ -2758,18 +2750,18 @@ namespace LuaGlobalFunctions * @proto (event_type) * @param uint32 event_type : the event whose handlers will be cleared, see [Global:RegisterPlayerEvent] */ - int ClearPlayerEvents(lua_State* L) + int ClearPlayerEvents(Eluna* E) { typedef EventKey Key; - if (lua_isnoneornil(L, 1)) + if (lua_isnoneornil(E->L, 1)) { - Eluna::GetEluna(L)->PlayerEventBindings->Clear(); + E->PlayerEventBindings->Clear(); } else { - uint32 event_type = Eluna::CHECKVAL(L, 1); - Eluna::GetEluna(L)->PlayerEventBindings->Clear(Key((Hooks::PlayerEvents)event_type)); + uint32 event_type = Eluna::CHECKVAL(E->L, 1); + E->PlayerEventBindings->Clear(Key((Hooks::PlayerEvents)event_type)); } return 0; } @@ -2786,23 +2778,22 @@ namespace LuaGlobalFunctions * @param uint32 entry : the low GUID of a [Player] whose handlers will be cleared * @param uint32 event_type : the event whose handlers will be cleared, see [Global:RegisterPlayerGossipEvent] */ - int ClearPlayerGossipEvents(lua_State* L) + int ClearPlayerGossipEvents(Eluna* E) { typedef EntryKey Key; - if (lua_isnoneornil(L, 2)) + if (lua_isnoneornil(E->L, 2)) { - uint32 entry = Eluna::CHECKVAL(L, 1); + uint32 entry = Eluna::CHECKVAL(E->L, 1); - Eluna* E = Eluna::GetEluna(L); for (uint32 i = 1; i < Hooks::GOSSIP_EVENT_COUNT; ++i) E->PlayerGossipBindings->Clear(Key((Hooks::GossipEvents)i, entry)); } else { - uint32 entry = Eluna::CHECKVAL(L, 1); - uint32 event_type = Eluna::CHECKVAL(L, 2); - Eluna::GetEluna(L)->PlayerGossipBindings->Clear(Key((Hooks::GossipEvents)event_type, entry)); + uint32 entry = Eluna::CHECKVAL(E->L, 1); + uint32 event_type = Eluna::CHECKVAL(E->L, 2); + E->PlayerGossipBindings->Clear(Key((Hooks::GossipEvents)event_type, entry)); } return 0; } @@ -2818,18 +2809,18 @@ namespace LuaGlobalFunctions * @proto (event_type) * @param uint32 event_type : the event whose handlers will be cleared, see [Global:RegisterServerEvent] */ - int ClearServerEvents(lua_State* L) + int ClearServerEvents(Eluna* E) { typedef EventKey Key; - if (lua_isnoneornil(L, 1)) + if (lua_isnoneornil(E->L, 1)) { - Eluna::GetEluna(L)->ServerEventBindings->Clear(); + E->ServerEventBindings->Clear(); } else { - uint32 event_type = Eluna::CHECKVAL(L, 1); - Eluna::GetEluna(L)->ServerEventBindings->Clear(Key((Hooks::ServerEvents)event_type)); + uint32 event_type = Eluna::CHECKVAL(E->L, 1); + E->ServerEventBindings->Clear(Key((Hooks::ServerEvents)event_type)); } return 0; } @@ -2846,23 +2837,22 @@ namespace LuaGlobalFunctions * @param uint32 map_id : the ID of a [Map] * @param uint32 event_type : the event whose handlers will be cleared, see [Global:RegisterPlayerGossipEvent] */ - int ClearMapEvents(lua_State* L) + int ClearMapEvents(Eluna* E) { typedef EntryKey Key; - if (lua_isnoneornil(L, 2)) + if (lua_isnoneornil(E->L, 2)) { - uint32 entry = Eluna::CHECKVAL(L, 1); + uint32 entry = Eluna::CHECKVAL(E->L, 1); - Eluna* E = Eluna::GetEluna(L); for (uint32 i = 1; i < Hooks::INSTANCE_EVENT_COUNT; ++i) E->MapEventBindings->Clear(Key((Hooks::InstanceEvents)i, entry)); } else { - uint32 entry = Eluna::CHECKVAL(L, 1); - uint32 event_type = Eluna::CHECKVAL(L, 2); - Eluna::GetEluna(L)->MapEventBindings->Clear(Key((Hooks::InstanceEvents)event_type, entry)); + uint32 entry = Eluna::CHECKVAL(E->L, 1); + uint32 event_type = Eluna::CHECKVAL(E->L, 2); + E->MapEventBindings->Clear(Key((Hooks::InstanceEvents)event_type, entry)); } return 0; @@ -2880,29 +2870,28 @@ namespace LuaGlobalFunctions * @param uint32 entry : the ID of an instance of a [Map] * @param uint32 event_type : the event whose handlers will be cleared, see [Global:RegisterInstanceEvent] */ - int ClearInstanceEvents(lua_State* L) + int ClearInstanceEvents(Eluna* E) { typedef EntryKey Key; - if (lua_isnoneornil(L, 2)) + if (lua_isnoneornil(E->L, 2)) { - uint32 entry = Eluna::CHECKVAL(L, 1); + uint32 entry = Eluna::CHECKVAL(E->L, 1); - Eluna* E = Eluna::GetEluna(L); for (uint32 i = 1; i < Hooks::INSTANCE_EVENT_COUNT; ++i) E->InstanceEventBindings->Clear(Key((Hooks::InstanceEvents)i, entry)); } else { - uint32 entry = Eluna::CHECKVAL(L, 1); - uint32 event_type = Eluna::CHECKVAL(L, 2); - Eluna::GetEluna(L)->InstanceEventBindings->Clear(Key((Hooks::InstanceEvents)event_type, entry)); + uint32 entry = Eluna::CHECKVAL(E->L, 1); + uint32 event_type = Eluna::CHECKVAL(E->L, 2); + E->InstanceEventBindings->Clear(Key((Hooks::InstanceEvents)event_type, entry)); } return 0; } - luaL_Reg GlobalMethods[] = + ElunaGlobal::ElunaRegister GlobalMethods[] = { // Hooks { "RegisterPacketEvent", &LuaGlobalFunctions::RegisterPacketEvent }, diff --git a/TrinityCore/GroupMethods.h b/TrinityCore/GroupMethods.h index e095aab456..e2b0bdc488 100644 --- a/TrinityCore/GroupMethods.h +++ b/TrinityCore/GroupMethods.h @@ -18,10 +18,10 @@ namespace LuaGroup * @param ObjectGuid guid : guid of a possible leader * @return bool isLeader */ - int IsLeader(lua_State* L, Group* group) + int IsLeader(Eluna* E, Group* group) { - ObjectGuid guid = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, group->IsLeader(guid)); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 2); + E->Push(group->IsLeader(guid)); return 1; } @@ -30,9 +30,9 @@ namespace LuaGroup * * @return bool isFull */ - int IsFull(lua_State* L, Group* group) + int IsFull(Eluna* E, Group* group) { - Eluna::Push(L, group->IsFull()); + E->Push(group->IsFull()); return 1; } @@ -41,9 +41,9 @@ namespace LuaGroup * * @return bool isLFGGroup */ - int IsLFGGroup(lua_State* L, Group* group) + int IsLFGGroup(Eluna* E, Group* group) { - Eluna::Push(L, group->isLFGGroup()); + E->Push(group->isLFGGroup()); return 1; } @@ -52,9 +52,9 @@ namespace LuaGroup * * @return bool isRaid */ - int IsRaidGroup(lua_State* L, Group* group) + int IsRaidGroup(Eluna* E, Group* group) { - Eluna::Push(L, group->isRaidGroup()); + E->Push(group->isRaidGroup()); return 1; } @@ -63,9 +63,9 @@ namespace LuaGroup * * @return bool isBG */ - int IsBGGroup(lua_State* L, Group* group) + int IsBGGroup(Eluna* E, Group* group) { - Eluna::Push(L, group->isBGGroup()); + E->Push(group->isBGGroup()); return 1; } @@ -75,10 +75,10 @@ namespace LuaGroup * @param ObjectGuid guid : guid of a player * @return bool isMember */ - int IsMember(lua_State* L, Group* group) + int IsMember(Eluna* E, Group* group) { - ObjectGuid guid = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, group->IsMember(guid)); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 2); + E->Push(group->IsMember(guid)); return 1; } @@ -88,10 +88,10 @@ namespace LuaGroup * @param ObjectGuid guid : guid of a player * @return bool isAssistant */ - int IsAssistant(lua_State* L, Group* group) + int IsAssistant(Eluna* E, Group* group) { - ObjectGuid guid = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, group->IsAssistant(guid)); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 2); + E->Push(group->IsAssistant(guid)); return 1; } @@ -102,11 +102,11 @@ namespace LuaGroup * @param [Player] player2 : second [Player] to check * @return bool sameSubGroup */ - int SameSubGroup(lua_State* L, Group* group) + int SameSubGroup(Eluna* E, Group* group) { - Player* player1 = Eluna::CHECKOBJ(L, 2); - Player* player2 = Eluna::CHECKOBJ(L, 3); - Eluna::Push(L, group->SameSubGroup(player1, player2)); + Player* player1 = Eluna::CHECKOBJ(E->L, 2); + Player* player2 = Eluna::CHECKOBJ(E->L, 3); + E->Push(group->SameSubGroup(player1, player2)); return 1; } @@ -116,17 +116,17 @@ namespace LuaGroup * @param uint8 subGroup : subGroup ID to check * @return bool hasFreeSlot */ - int HasFreeSlotSubGroup(lua_State* L, Group* group) + int HasFreeSlotSubGroup(Eluna* E, Group* group) { - uint8 subGroup = Eluna::CHECKVAL(L, 2); + uint8 subGroup = Eluna::CHECKVAL(E->L, 2); if (subGroup >= MAX_RAID_SUBGROUPS) { - luaL_argerror(L, 2, "valid subGroup ID expected"); + luaL_argerror(E->L, 2, "valid subGroup ID expected"); return 0; } - Eluna::Push(L, group->HasFreeSlotSubGroup(subGroup)); + E->Push(group->HasFreeSlotSubGroup(subGroup)); return 1; } @@ -136,13 +136,13 @@ namespace LuaGroup * @param [Player] player : [Player] to add to the group * @return bool added : true if member was added */ - int AddMember(lua_State* L, Group* group) + int AddMember(Eluna* E, Group* group) { - Player* player = Eluna::CHECKOBJ(L, 2); + Player* player = Eluna::CHECKOBJ(E->L, 2); if (player->GetGroup() || !group->IsCreated() || group->IsFull()) { - Eluna::Push(L, false); + E->Push(false); return 1; } @@ -153,13 +153,13 @@ namespace LuaGroup if (success) group->BroadcastGroupUpdate(); - Eluna::Push(L, success); + E->Push(success); return 1; } - int IsBFGroup(lua_State* L, Group* group) + int IsBFGroup(Eluna* E, Group* group) { - Eluna::Push(L, group->isBFGroup()); + E->Push(group->isBFGroup()); return 1; } @@ -168,10 +168,10 @@ namespace LuaGroup * * @return table groupPlayers : table of [Player]s */ - int GetMembers(lua_State* L, Group* group) + int GetMembers(Eluna* E, Group* group) { - lua_newtable(L); - int tbl = lua_gettop(L); + lua_newtable(E->L); + int tbl = lua_gettop(E->L); uint32 i = 0; for (GroupReference* itr = group->GetFirstMember(); itr; itr = itr->next()) @@ -180,11 +180,11 @@ namespace LuaGroup if (!member || !member->GetSession()) continue; - Eluna::Push(L, member); - lua_rawseti(L, tbl, ++i); + E->Push(member); + lua_rawseti(E->L, tbl, ++i); } - lua_settop(L, tbl); // push table to top of stack + lua_settop(E->L, tbl); // push table to top of stack return 1; } @@ -193,9 +193,9 @@ namespace LuaGroup * * @return ObjectGuid leaderGUID */ - int GetLeaderGUID(lua_State* L, Group* group) + int GetLeaderGUID(Eluna* E, Group* group) { - Eluna::Push(L, group->GetLeaderGUID()); + E->Push(group->GetLeaderGUID()); return 1; } @@ -204,9 +204,9 @@ namespace LuaGroup * * @return ObjectGuid groupGUID */ - int GetGUID(lua_State* L, Group* group) + int GetGUID(Eluna* E, Group* group) { - Eluna::Push(L, group->GET_GUID()); + E->Push(group->GET_GUID()); return 1; } @@ -216,10 +216,10 @@ namespace LuaGroup * @param string name : the [Player]'s name * @return ObjectGuid memberGUID */ - int GetMemberGUID(lua_State* L, Group* group) + int GetMemberGUID(Eluna* E, Group* group) { - const char* name = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, group->GetMemberGUID(name)); + const char* name = Eluna::CHECKVAL(E->L, 2); + E->Push(group->GetMemberGUID(name)); return 1; } @@ -228,9 +228,9 @@ namespace LuaGroup * * @return uint32 memberCount */ - int GetMembersCount(lua_State* L, Group* group) + int GetMembersCount(Eluna* E, Group* group) { - Eluna::Push(L, group->GetMembersCount()); + E->Push(group->GetMembersCount()); return 1; } @@ -240,10 +240,10 @@ namespace LuaGroup * @param ObjectGuid guid : guid of the player * @return uint8 subGroupID : a valid subgroup ID or MAX_RAID_SUBGROUPS+1 */ - int GetMemberGroup(lua_State* L, Group* group) + int GetMemberGroup(Eluna* E, Group* group) { - ObjectGuid guid = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, group->GetMemberGroup(guid)); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 2); + E->Push(group->GetMemberGroup(guid)); return 1; } @@ -263,10 +263,10 @@ namespace LuaGroup * @return uint8 flags */ #ifndef CATA - int GetMemberFlags(lua_State* L, Group* group) + int GetMemberFlags(Eluna* E, Group* group) { - ObjectGuid guid = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, group->GetMemberFlags(guid)); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 2); + E->Push(group->GetMemberFlags(guid)); return 1; } #endif @@ -276,9 +276,9 @@ namespace LuaGroup * * @param ObjectGuid guid : guid of the new leader */ - int SetLeader(lua_State* L, Group* group) + int SetLeader(Eluna* E, Group* group) { - ObjectGuid guid = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 2); group->ChangeLeader(guid); group->SendUpdate(); return 0; @@ -291,11 +291,11 @@ namespace LuaGroup * @param bool ignorePlayersInBg : ignores [Player]s in a battleground * @param ObjectGuid ignore : ignore a [Player] by their GUID */ - int SendPacket(lua_State* L, Group* group) + int SendPacket(Eluna* E, Group* group) { - WorldPacket* data = Eluna::CHECKOBJ(L, 2); - bool ignorePlayersInBg = Eluna::CHECKVAL(L, 3); - ObjectGuid ignore = Eluna::CHECKVAL(L, 4); + WorldPacket* data = Eluna::CHECKOBJ(E->L, 2); + bool ignorePlayersInBg = Eluna::CHECKVAL(E->L, 3); + ObjectGuid ignore = Eluna::CHECKVAL(E->L, 4); group->BroadcastPacket(data, ignorePlayersInBg, -1, ignore); return 0; @@ -318,12 +318,12 @@ namespace LuaGroup * @param [RemoveMethod] method : method used to remove the player * @return bool removed */ - int RemoveMember(lua_State* L, Group* group) + int RemoveMember(Eluna* E, Group* group) { - ObjectGuid guid = Eluna::CHECKVAL(L, 2); - uint32 method = Eluna::CHECKVAL(L, 3, 0); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 2); + uint32 method = Eluna::CHECKVAL(E->L, 3, 0); - Eluna::Push(L, group->RemoveMember(guid, (RemoveMethod)method)); + E->Push(group->RemoveMember(guid, (RemoveMethod)method)); return 1; } @@ -331,7 +331,7 @@ namespace LuaGroup * Disbands this [Group] * */ - int Disband(lua_State* /*L*/, Group* group) + int Disband(Eluna* /*E*/, Group* group) { group->Disband(); return 0; @@ -341,7 +341,7 @@ namespace LuaGroup * Converts this [Group] to a raid [Group] * */ - int ConvertToRaid(lua_State* /*L*/, Group* group) + int ConvertToRaid(Eluna* /*E*/, Group* group) { group->ConvertToRaid(); return 0; @@ -353,14 +353,14 @@ namespace LuaGroup * @param ObjectGuid guid : guid of the player to move * @param uint8 groupID : the subGroup's ID */ - int SetMembersGroup(lua_State* L, Group* group) + int SetMembersGroup(Eluna* E, Group* group) { - ObjectGuid guid = Eluna::CHECKVAL(L, 2); - uint8 subGroup = Eluna::CHECKVAL(L, 3); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 2); + uint8 subGroup = Eluna::CHECKVAL(E->L, 3); if (subGroup >= MAX_RAID_SUBGROUPS) { - luaL_argerror(L, 3, "valid subGroup ID expected"); + luaL_argerror(E->L, 3, "valid subGroup ID expected"); return 0; } @@ -378,20 +378,20 @@ namespace LuaGroup * @param ObjectGuid target : GUID of the icon target, 0 is to clear the icon * @param ObjectGuid setter : GUID of the icon setter */ - int SetTargetIcon(lua_State* L, Group* group) + int SetTargetIcon(Eluna* E, Group* group) { - uint8 icon = Eluna::CHECKVAL(L, 2); - ObjectGuid target = Eluna::CHECKVAL(L, 3); - ObjectGuid setter = Eluna::CHECKVAL(L, 4, ObjectGuid()); + uint8 icon = Eluna::CHECKVAL(E->L, 2); + ObjectGuid target = Eluna::CHECKVAL(E->L, 3); + ObjectGuid setter = Eluna::CHECKVAL(E->L, 4, ObjectGuid()); if (icon >= TARGET_ICONS_COUNT) - return luaL_argerror(L, 2, "valid target icon expected"); + return luaL_argerror(E->L, 2, "valid target icon expected"); group->SetTargetIcon(icon, setter, target); return 0; } - int ConvertToLFG(lua_State* /*L*/, Group* group) + int ConvertToLFG(Eluna* /*E*/, Group* group) { group->ConvertToLFG(); return 0; @@ -414,11 +414,11 @@ namespace LuaGroup * @param [GroupMemberFlags] flag : the flag to set or unset */ #ifndef CATA - int SetMemberFlag(lua_State* L, Group* group) + int SetMemberFlag(Eluna* E, Group* group) { - ObjectGuid target = Eluna::CHECKVAL(L, 2); - bool apply = Eluna::CHECKVAL(L, 3); - GroupMemberFlags flag = static_cast(Eluna::CHECKVAL(L, 4)); + ObjectGuid target = Eluna::CHECKVAL(E->L, 2); + bool apply = Eluna::CHECKVAL(E->L, 3); + GroupMemberFlags flag = static_cast(Eluna::CHECKVAL(E->L, 4)); group->SetGroupMemberFlag(target, apply, flag); return 0; diff --git a/TrinityCore/GuildMethods.h b/TrinityCore/GuildMethods.h index 8437510a08..48ca7d2533 100644 --- a/TrinityCore/GuildMethods.h +++ b/TrinityCore/GuildMethods.h @@ -19,10 +19,10 @@ namespace LuaGuild * * @return table guildPlayers : table of [Player]s */ - int GetMembers(lua_State* L, Guild* guild) + int GetMembers(Eluna* E, Guild* guild) { - lua_newtable(L); - int tbl = lua_gettop(L); + lua_newtable(E->L); + int tbl = lua_gettop(E->L); uint32 i = 0; std::shared_lock lock(*HashMapHolder::GetLock()); @@ -33,13 +33,13 @@ namespace LuaGuild { if (player->IsInWorld() && player->GetGuildId() == guild->GetId()) { - Eluna::Push(L, player); - lua_rawseti(L, tbl, ++i); + E->Push(player); + lua_rawseti(E->L, tbl, ++i); } } } - lua_settop(L, tbl); // push table to top of stack + lua_settop(E->L, tbl); // push table to top of stack return 1; } @@ -48,9 +48,9 @@ namespace LuaGuild * * @return uint32 memberCount */ - int GetMemberCount(lua_State* L, Guild* guild) + int GetMemberCount(Eluna* E, Guild* guild) { - Eluna::Push(L, guild->GetMemberCount()); + E->Push(guild->GetMemberCount()); return 1; } @@ -59,9 +59,9 @@ namespace LuaGuild * * @return [Player] leader */ - int GetLeader(lua_State* L, Guild* guild) + int GetLeader(Eluna* E, Guild* guild) { - Eluna::Push(L, eObjectAccessor()FindPlayer(guild->GetLeaderGUID())); + E->Push(eObjectAccessor()FindPlayer(guild->GetLeaderGUID())); return 1; } @@ -70,9 +70,9 @@ namespace LuaGuild * * @return ObjectGuid leaderGUID */ - int GetLeaderGUID(lua_State* L, Guild* guild) + int GetLeaderGUID(Eluna* E, Guild* guild) { - Eluna::Push(L, guild->GetLeaderGUID()); + E->Push(guild->GetLeaderGUID()); return 1; } @@ -81,9 +81,9 @@ namespace LuaGuild * * @return uint32 entryId */ - int GetId(lua_State* L, Guild* guild) + int GetId(Eluna* E, Guild* guild) { - Eluna::Push(L, guild->GetId()); + E->Push(guild->GetId()); return 1; } @@ -92,9 +92,9 @@ namespace LuaGuild * * @return string guildName */ - int GetName(lua_State* L, Guild* guild) + int GetName(Eluna* E, Guild* guild) { - Eluna::Push(L, guild->GetName()); + E->Push(guild->GetName()); return 1; } @@ -103,9 +103,9 @@ namespace LuaGuild * * @return string guildMOTD */ - int GetMOTD(lua_State* L, Guild* guild) + int GetMOTD(Eluna* E, Guild* guild) { - Eluna::Push(L, guild->GetMOTD()); + E->Push(guild->GetMOTD()); return 1; } @@ -114,9 +114,9 @@ namespace LuaGuild * * @return string guildInfo */ - int GetInfo(lua_State* L, Guild* guild) + int GetInfo(Eluna* E, Guild* guild) { - Eluna::Push(L, guild->GetInfo()); + E->Push(guild->GetInfo()); return 1; } @@ -126,9 +126,9 @@ namespace LuaGuild * * @param [Player] leader : the [Player] leader to change */ - int SetLeader(lua_State* L, Guild* guild) + int SetLeader(Eluna* E, Guild* guild) { - Player* player = Eluna::CHECKOBJ(L, 2); + Player* player = Eluna::CHECKOBJ(E->L, 2); guild->HandleSetLeader(player->GetSession(), player->GetName()); return 0; @@ -141,10 +141,10 @@ namespace LuaGuild * @param uint8 tabId : the ID of the tab specified * @param string info : the information to be set to the bank tab */ - int SetBankTabText(lua_State* L, Guild* guild) + int SetBankTabText(Eluna* E, Guild* guild) { - uint8 tabId = Eluna::CHECKVAL(L, 2); - const char* text = Eluna::CHECKVAL(L, 3); + uint8 tabId = Eluna::CHECKVAL(E->L, 2); + const char* text = Eluna::CHECKVAL(E->L, 3); guild->SetBankTabText(tabId, text); return 0; @@ -156,9 +156,9 @@ namespace LuaGuild * * @param [WorldPacket] packet : the [WorldPacket] to be sent to the [Player]s */ - int SendPacket(lua_State* L, Guild* guild) + int SendPacket(Eluna* E, Guild* guild) { - WorldPacket* data = Eluna::CHECKOBJ(L, 2); + WorldPacket* data = Eluna::CHECKOBJ(E->L, 2); guild->BroadcastPacket(data); return 0; @@ -171,10 +171,10 @@ namespace LuaGuild * @param [WorldPacket] packet : the [WorldPacket] to be sent to the [Player]s * @param uint8 rankId : the rank ID */ - int SendPacketToRanked(lua_State* L, Guild* guild) + int SendPacketToRanked(Eluna* E, Guild* guild) { - WorldPacket* data = Eluna::CHECKOBJ(L, 2); - uint8 ranked = Eluna::CHECKVAL(L, 3); + WorldPacket* data = Eluna::CHECKOBJ(E->L, 2); + uint8 ranked = Eluna::CHECKVAL(E->L, 3); guild->BroadcastPacketToRank(data, ranked); return 0; @@ -183,7 +183,7 @@ namespace LuaGuild /** * Disbands the [Guild] */ - int Disband(lua_State* /*L*/, Guild* guild) + int Disband(Eluna* /*E*/, Guild* guild) { guild->Disband(); return 0; @@ -197,10 +197,10 @@ namespace LuaGuild * @param [Player] player : the [Player] to be added to the guild * @param uint8 rankId : the rank ID */ - int AddMember(lua_State* L, Guild* guild) + int AddMember(Eluna* E, Guild* guild) { - Player* player = Eluna::CHECKOBJ(L, 2); - uint8 rankId = Eluna::CHECKVAL(L, 3, GUILD_RANK_NONE); + Player* player = Eluna::CHECKOBJ(E->L, 2); + uint8 rankId = Eluna::CHECKVAL(E->L, 3, GUILD_RANK_NONE); CharacterDatabaseTransaction trans(nullptr); @@ -214,10 +214,10 @@ namespace LuaGuild * @param [Player] player : the [Player] to be removed from the guild * @param bool isDisbanding : default 'false', should only be set to 'true' if the guild is triggered to disband */ - int DeleteMember(lua_State* L, Guild* guild) + int DeleteMember(Eluna* E, Guild* guild) { - Player* player = Eluna::CHECKOBJ(L, 2); - bool isDisbanding = Eluna::CHECKVAL(L, 3, false); + Player* player = Eluna::CHECKOBJ(E->L, 2); + bool isDisbanding = Eluna::CHECKVAL(E->L, 3, false); CharacterDatabaseTransaction trans(nullptr); @@ -231,10 +231,10 @@ namespace LuaGuild * @param [Player] player : the [Player] to be promoted/demoted * @param uint8 rankId : the rank ID */ - int SetMemberRank(lua_State* L, Guild* guild) + int SetMemberRank(Eluna* E, Guild* guild) { - Player* player = Eluna::CHECKOBJ(L, 2); - uint8 newRank = Eluna::CHECKVAL(L, 3); + Player* player = Eluna::CHECKOBJ(E->L, 2); + uint8 newRank = Eluna::CHECKVAL(E->L, 3); CharacterDatabaseTransaction trans(nullptr); diff --git a/TrinityCore/ItemMethods.h b/TrinityCore/ItemMethods.h index 2d6398727b..c16efc57f0 100644 --- a/TrinityCore/ItemMethods.h +++ b/TrinityCore/ItemMethods.h @@ -17,9 +17,9 @@ namespace LuaItem * * @return bool isSoulBound */ - int IsSoulBound(lua_State* L, Item* item) + int IsSoulBound(Eluna* E, Item* item) { - Eluna::Push(L, item->IsSoulBound()); + E->Push(item->IsSoulBound()); return 1; } @@ -28,9 +28,9 @@ namespace LuaItem * * @return bool isAccountBound */ - int IsBoundAccountWide(lua_State* L, Item* item) + int IsBoundAccountWide(Eluna* E, Item* item) { - Eluna::Push(L, item->IsBoundAccountWide()); + E->Push(item->IsBoundAccountWide()); return 1; } @@ -39,9 +39,9 @@ namespace LuaItem * * @return bool isBoundByEnchant */ - int IsBoundByEnchant(lua_State* L, Item* item) + int IsBoundByEnchant(Eluna* E, Item* item) { - Eluna::Push(L, item->IsBoundByEnchant()); + E->Push(item->IsBoundByEnchant()); return 1; } @@ -51,11 +51,11 @@ namespace LuaItem * @param [Player] player : the [Player] object to check the item against * @return bool isNotBound */ - int IsNotBoundToPlayer(lua_State* L, Item* item) + int IsNotBoundToPlayer(Eluna* E, Item* item) { - Player* player = Eluna::CHECKOBJ(L, 2); + Player* player = Eluna::CHECKOBJ(E->L, 2); - Eluna::Push(L, item->IsBindedNotWith(player)); + E->Push(item->IsBindedNotWith(player)); return 1; } @@ -64,9 +64,9 @@ namespace LuaItem * * @return bool isLocked */ - int IsLocked(lua_State* L, Item* item) + int IsLocked(Eluna* E, Item* item) { - Eluna::Push(L, item->IsLocked()); + E->Push(item->IsLocked()); return 1; } @@ -75,9 +75,9 @@ namespace LuaItem * * @return bool isBag */ - int IsBag(lua_State* L, Item* item) + int IsBag(Eluna* E, Item* item) { - Eluna::Push(L, item->IsBag()); + E->Push(item->IsBag()); return 1; } @@ -86,9 +86,9 @@ namespace LuaItem * * @return bool isCurrencyToken */ - int IsCurrencyToken(lua_State* L, Item* item) + int IsCurrencyToken(Eluna* E, Item* item) { - Eluna::Push(L, item->IsCurrencyToken()); + E->Push(item->IsCurrencyToken()); return 1; } @@ -97,9 +97,9 @@ namespace LuaItem * * @return bool isNotEmptyBag */ - int IsNotEmptyBag(lua_State* L, Item* item) + int IsNotEmptyBag(Eluna* E, Item* item) { - Eluna::Push(L, item->IsNotEmptyBag()); + E->Push(item->IsNotEmptyBag()); return 1; } @@ -108,9 +108,9 @@ namespace LuaItem * * @return bool isBroken */ - int IsBroken(lua_State* L, Item* item) + int IsBroken(Eluna* E, Item* item) { - Eluna::Push(L, item->IsBroken()); + E->Push(item->IsBroken()); return 1; } @@ -119,11 +119,11 @@ namespace LuaItem * * @return bool isTradeable */ - int CanBeTraded(lua_State* L, Item* item) + int CanBeTraded(Eluna* E, Item* item) { - bool mail = Eluna::CHECKVAL(L, 2, false); + bool mail = Eluna::CHECKVAL(E->L, 2, false); - Eluna::Push(L, item->CanBeTraded(mail)); + E->Push(item->CanBeTraded(mail)); return 1; } @@ -132,9 +132,9 @@ namespace LuaItem * * @return bool isInTrade */ - int IsInTrade(lua_State* L, Item* item) + int IsInTrade(Eluna* E, Item* item) { - Eluna::Push(L, item->IsInTrade()); + E->Push(item->IsInTrade()); return 1; } @@ -143,9 +143,9 @@ namespace LuaItem * * @return bool isInBag */ - int IsInBag(lua_State* L, Item* item) + int IsInBag(Eluna* E, Item* item) { - Eluna::Push(L, item->IsInBag()); + E->Push(item->IsInBag()); return 1; } @@ -154,9 +154,9 @@ namespace LuaItem * * @return bool isEquipped */ - int IsEquipped(lua_State* L, Item* item) + int IsEquipped(Eluna* E, Item* item) { - Eluna::Push(L, item->IsEquipped()); + E->Push(item->IsEquipped()); return 1; } @@ -166,11 +166,11 @@ namespace LuaItem * @param uint32 questId : the [Quest] id to be checked * @return bool hasQuest */ - int HasQuest(lua_State* L, Item* item) + int HasQuest(Eluna* E, Item* item) { - uint32 quest = Eluna::CHECKVAL(L, 2); + uint32 quest = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, item->hasQuest(quest)); + E->Push(item->hasQuest(quest)); return 1; } @@ -179,9 +179,9 @@ namespace LuaItem * * @return bool isPotion */ - int IsPotion(lua_State* L, Item* item) + int IsPotion(Eluna* E, Item* item) { - Eluna::Push(L, item->IsPotion()); + E->Push(item->IsPotion()); return 1; } @@ -191,9 +191,9 @@ namespace LuaItem * * @return bool isWeaponVellum */ - int IsWeaponVellum(lua_State* L, Item* item) + int IsWeaponVellum(Eluna* E, Item* item) { - Eluna::Push(L, item->IsWeaponVellum()); + E->Push(item->IsWeaponVellum()); return 1; } @@ -202,9 +202,9 @@ namespace LuaItem * * @return bool isArmorVellum */ - int IsArmorVellum(lua_State* L, Item* item) + int IsArmorVellum(Eluna* E, Item* item) { - Eluna::Push(L, item->IsArmorVellum()); + E->Push(item->IsArmorVellum()); return 1; } #endif @@ -214,16 +214,16 @@ namespace LuaItem * * @return bool isConjuredConsumable */ - int IsConjuredConsumable(lua_State* L, Item* item) + int IsConjuredConsumable(Eluna* E, Item* item) { - Eluna::Push(L, item->IsConjuredConsumable()); + E->Push(item->IsConjuredConsumable()); return 1; } #ifndef CATA - int IsRefundExpired(lua_State* L, Item* item) + int IsRefundExpired(Eluna* E, Item* item) { - Eluna::Push(L, item->IsRefundExpired()); + E->Push(item->IsRefundExpired()); return 1; } #endif @@ -249,11 +249,11 @@ namespace LuaItem * @param [LocaleConstant] locale = DEFAULT_LOCALE : locale to return the [Item]'s name in * @return string itemLink */ - int GetItemLink(lua_State* L, Item* item) + int GetItemLink(Eluna* E, Item* item) { - uint8 locale = Eluna::CHECKVAL(L, 2, DEFAULT_LOCALE); + uint8 locale = Eluna::CHECKVAL(E->L, 2, DEFAULT_LOCALE); if (locale >= TOTAL_LOCALES) - return luaL_argerror(L, 2, "valid LocaleConstant expected"); + return luaL_argerror(E->L, 2, "valid LocaleConstant expected"); const ItemTemplate* temp = item->GetTemplate(); #ifdef CATA @@ -311,13 +311,13 @@ namespace LuaItem item->GetItemRandomPropertyId() << ":" << item->GetItemSuffixFactor() << ":" << (uint32)item->GetOwner()->GetLevel() << "|h[" << name << "]|h|r"; - Eluna::Push(L, oss.str()); + E->Push(oss.str()); return 1; } - int GetOwnerGUID(lua_State* L, Item* item) + int GetOwnerGUID(Eluna* E, Item* item) { - Eluna::Push(L, item->GetOwnerGUID()); + E->Push(item->GetOwnerGUID()); return 1; } @@ -326,9 +326,9 @@ namespace LuaItem * * @return [Player] player : the [Player] who owns the [Item] */ - int GetOwner(lua_State* L, Item* item) + int GetOwner(Eluna* E, Item* item) { - Eluna::Push(L, item->GetOwner()); + E->Push(item->GetOwner()); return 1; } @@ -337,9 +337,9 @@ namespace LuaItem * * @return uint32 count */ - int GetCount(lua_State* L, Item* item) + int GetCount(Eluna* E, Item* item) { - Eluna::Push(L, item->GetCount()); + E->Push(item->GetCount()); return 1; } @@ -348,9 +348,9 @@ namespace LuaItem * * @return uint32 maxCount */ - int GetMaxStackCount(lua_State* L, Item* item) + int GetMaxStackCount(Eluna* E, Item* item) { - Eluna::Push(L, item->GetMaxStackCount()); + E->Push(item->GetMaxStackCount()); return 1; } @@ -359,9 +359,9 @@ namespace LuaItem * * @return uint8 slot */ - int GetSlot(lua_State* L, Item* item) + int GetSlot(Eluna* E, Item* item) { - Eluna::Push(L, item->GetSlot()); + E->Push(item->GetSlot()); return 1; } @@ -370,9 +370,9 @@ namespace LuaItem * * @return uint8 bagSlot */ - int GetBagSlot(lua_State* L, Item* item) + int GetBagSlot(Eluna* E, Item* item) { - Eluna::Push(L, item->GetBagSlot()); + E->Push(item->GetBagSlot()); return 1; } @@ -382,14 +382,14 @@ namespace LuaItem * @param [EnchantmentSlot] enchantSlot : the enchant slot specified * @return uint32 enchantId : the id of the enchant slot specified */ - int GetEnchantmentId(lua_State* L, Item* item) + int GetEnchantmentId(Eluna* E, Item* item) { - uint32 enchant_slot = Eluna::CHECKVAL(L, 2); + uint32 enchant_slot = Eluna::CHECKVAL(E->L, 2); if (enchant_slot >= MAX_INSPECTED_ENCHANTMENT_SLOT) - return luaL_argerror(L, 2, "valid EnchantmentSlot expected"); + return luaL_argerror(E->L, 2, "valid EnchantmentSlot expected"); - Eluna::Push(L, item->GetEnchantmentId(EnchantmentSlot(enchant_slot))); + E->Push(item->GetEnchantmentId(EnchantmentSlot(enchant_slot))); return 1; } @@ -399,16 +399,16 @@ namespace LuaItem * @param uint32 spellIndex : the spell index specified * @return uint32 spellId : the id of the spell */ - int GetSpellId(lua_State* L, Item* item) + int GetSpellId(Eluna* E, Item* item) { - uint32 index = Eluna::CHECKVAL(L, 2); + uint32 index = Eluna::CHECKVAL(E->L, 2); if (index >= MAX_ITEM_PROTO_SPELLS) - return luaL_argerror(L, 2, "valid SpellIndex expected"); + return luaL_argerror(E->L, 2, "valid SpellIndex expected"); #ifdef CATA - Eluna::Push(L, item->GetTemplate()->ExtendedData->SpellID[index]); + E->Push(item->GetTemplate()->ExtendedData->SpellID[index]); #else - Eluna::Push(L, item->GetTemplate()->Spells[index].SpellId); + E->Push(item->GetTemplate()->Spells[index].SpellId); #endif return 1; } @@ -419,16 +419,16 @@ namespace LuaItem * @param uint32 spellIndex : the spell index specified * @return uint32 spellTrigger : the spell trigger of the specified index */ - int GetSpellTrigger(lua_State* L, Item* item) + int GetSpellTrigger(Eluna* E, Item* item) { - uint32 index = Eluna::CHECKVAL(L, 2); + uint32 index = Eluna::CHECKVAL(E->L, 2); if (index >= MAX_ITEM_PROTO_SPELLS) - return luaL_argerror(L, 2, "valid SpellIndex expected"); + return luaL_argerror(E->L, 2, "valid SpellIndex expected"); #ifdef CATA - Eluna::Push(L, item->GetTemplate()->ExtendedData->SpellTrigger[index]); + E->Push(item->GetTemplate()->ExtendedData->SpellTrigger[index]); #else - Eluna::Push(L, item->GetTemplate()->Spells[index].SpellTrigger); + E->Push(item->GetTemplate()->Spells[index].SpellTrigger); #endif return 1; } @@ -438,12 +438,12 @@ namespace LuaItem * * @return uint32 class */ - int GetClass(lua_State* L, Item* item) + int GetClass(Eluna* E, Item* item) { #ifdef CATA - Eluna::Push(L, item->GetTemplate()->GetClass()); + E->Push(item->GetTemplate()->GetClass()); #else - Eluna::Push(L, item->GetTemplate()->Class); + E->Push(item->GetTemplate()->Class); #endif return 1; } @@ -453,12 +453,12 @@ namespace LuaItem * * @return uint32 subClass */ - int GetSubClass(lua_State* L, Item* item) + int GetSubClass(Eluna* E, Item* item) { #ifdef CATA - Eluna::Push(L, item->GetTemplate()->GetSubClass()); + E->Push(item->GetTemplate()->GetSubClass()); #else - Eluna::Push(L, item->GetTemplate()->SubClass); + E->Push(item->GetTemplate()->SubClass); #endif return 1; } @@ -468,12 +468,12 @@ namespace LuaItem * * @return string name */ - int GetName(lua_State* L, Item* item) + int GetName(Eluna* E, Item* item) { #ifdef CATA - Eluna::Push(L, item->GetTemplate()->GetDefaultLocaleName()); + E->Push(item->GetTemplate()->GetDefaultLocaleName()); #else - Eluna::Push(L, item->GetTemplate()->Name1); + E->Push(item->GetTemplate()->Name1); #endif return 1; } @@ -483,12 +483,12 @@ namespace LuaItem * * @return uint32 displayId */ - int GetDisplayId(lua_State* L, Item* item) + int GetDisplayId(Eluna* E, Item* item) { #ifdef CATA - Eluna::Push(L, item->GetTemplate()->GetDisplayID()); + E->Push(item->GetTemplate()->GetDisplayID()); #else - Eluna::Push(L, item->GetTemplate()->DisplayInfoID); + E->Push(item->GetTemplate()->DisplayInfoID); #endif return 1; } @@ -498,12 +498,12 @@ namespace LuaItem * * @return uint32 quality */ - int GetQuality(lua_State* L, Item* item) + int GetQuality(Eluna* E, Item* item) { #ifdef CATA - Eluna::Push(L, item->GetTemplate()->GetQuality()); + E->Push(item->GetTemplate()->GetQuality()); #else - Eluna::Push(L, item->GetTemplate()->Quality); + E->Push(item->GetTemplate()->Quality); #endif return 1; } @@ -513,12 +513,12 @@ namespace LuaItem * * @return uint32 count */ - int GetBuyCount(lua_State* L, Item* item) + int GetBuyCount(Eluna* E, Item* item) { #ifdef CATA - Eluna::Push(L, item->GetTemplate()->GetBuyCount()); + E->Push(item->GetTemplate()->GetBuyCount()); #else - Eluna::Push(L, item->GetTemplate()->BuyCount); + E->Push(item->GetTemplate()->BuyCount); #endif return 1; } @@ -528,12 +528,12 @@ namespace LuaItem * * @return uint32 price */ - int GetBuyPrice(lua_State* L, Item* item) + int GetBuyPrice(Eluna* E, Item* item) { #ifdef CATA - Eluna::Push(L, item->GetTemplate()->GetBuyPrice()); + E->Push(item->GetTemplate()->GetBuyPrice()); #else - Eluna::Push(L, item->GetTemplate()->BuyPrice); + E->Push(item->GetTemplate()->BuyPrice); #endif return 1; } @@ -543,12 +543,12 @@ namespace LuaItem * * @return uint32 price */ - int GetSellPrice(lua_State* L, Item* item) + int GetSellPrice(Eluna* E, Item* item) { #ifdef CATA - Eluna::Push(L, item->GetTemplate()->GetSellPrice()); + E->Push(item->GetTemplate()->GetSellPrice()); #else - Eluna::Push(L, item->GetTemplate()->SellPrice); + E->Push(item->GetTemplate()->SellPrice); #endif return 1; } @@ -558,12 +558,12 @@ namespace LuaItem * * @return uint32 inventoryType */ - int GetInventoryType(lua_State* L, Item* item) + int GetInventoryType(Eluna* E, Item* item) { #ifdef CATA - Eluna::Push(L, item->GetTemplate()->GetInventoryType()); + E->Push(item->GetTemplate()->GetInventoryType()); #else - Eluna::Push(L, item->GetTemplate()->InventoryType); + E->Push(item->GetTemplate()->InventoryType); #endif return 1; } @@ -573,12 +573,12 @@ namespace LuaItem * * @return uint32 allowableClass */ - int GetAllowableClass(lua_State* L, Item* item) + int GetAllowableClass(Eluna* E, Item* item) { #ifdef CATA - Eluna::Push(L, item->GetTemplate()->GetAllowableClass()); + E->Push(item->GetTemplate()->GetAllowableClass()); #else - Eluna::Push(L, item->GetTemplate()->AllowableClass); + E->Push(item->GetTemplate()->AllowableClass); #endif return 1; } @@ -588,12 +588,12 @@ namespace LuaItem * * @return uint32 allowableRace */ - int GetAllowableRace(lua_State* L, Item* item) + int GetAllowableRace(Eluna* E, Item* item) { #ifdef CATA - Eluna::Push(L, item->GetTemplate()->GetAllowableRace()); + E->Push(item->GetTemplate()->GetAllowableRace()); #else - Eluna::Push(L, item->GetTemplate()->AllowableRace); + E->Push(item->GetTemplate()->AllowableRace); #endif return 1; } @@ -603,12 +603,12 @@ namespace LuaItem * * @return uint32 itemLevel */ - int GetItemLevel(lua_State* L, Item* item) + int GetItemLevel(Eluna* E, Item* item) { #ifdef CATA - Eluna::Push(L, item->GetTemplate()->GetBaseItemLevel()); + E->Push(item->GetTemplate()->GetBaseItemLevel()); #else - Eluna::Push(L, item->GetTemplate()->ItemLevel); + E->Push(item->GetTemplate()->ItemLevel); #endif return 1; } @@ -618,20 +618,20 @@ namespace LuaItem * * @return uint32 requiredLevel */ - int GetRequiredLevel(lua_State* L, Item* item) + int GetRequiredLevel(Eluna* E, Item* item) { #ifdef CATA - Eluna::Push(L, item->GetTemplate()->GetRequiredLevel()); + E->Push(item->GetTemplate()->GetRequiredLevel()); #else - Eluna::Push(L, item->GetTemplate()->RequiredLevel); + E->Push(item->GetTemplate()->RequiredLevel); #endif return 1; } #ifdef WOTLK - int GetStatsCount(lua_State* L, Item* item) + int GetStatsCount(Eluna* E, Item* item) { - Eluna::Push(L, item->GetTemplate()->StatsCount); + E->Push(item->GetTemplate()->StatsCount); return 1; } #endif @@ -641,22 +641,22 @@ namespace LuaItem * * @return uint32 randomPropertyId */ - int GetRandomProperty(lua_State* L, Item* item) + int GetRandomProperty(Eluna* E, Item* item) { #ifdef CATA - Eluna::Push(L, item->GetTemplate()->GetRandomProperty()); + E->Push(item->GetTemplate()->GetRandomProperty()); #else - Eluna::Push(L, item->GetTemplate()->RandomProperty); + E->Push(item->GetTemplate()->RandomProperty); #endif return 1; } - int GetRandomSuffix(lua_State* L, Item* item) + int GetRandomSuffix(Eluna* E, Item* item) { #ifdef CATA - Eluna::Push(L, item->GetTemplate()->GetRandomSuffix()); + E->Push(item->GetTemplate()->GetRandomSuffix()); #else - Eluna::Push(L, item->GetTemplate()->RandomSuffix); + E->Push(item->GetTemplate()->RandomSuffix); #endif return 1; } @@ -666,12 +666,12 @@ namespace LuaItem * * @return uint32 itemSetId */ - int GetItemSet(lua_State* L, Item* item) + int GetItemSet(Eluna* E, Item* item) { #ifdef CATA - Eluna::Push(L, item->GetTemplate()->GetItemSet()); + E->Push(item->GetTemplate()->GetItemSet()); #else - Eluna::Push(L, item->GetTemplate()->ItemSet); + E->Push(item->GetTemplate()->ItemSet); #endif return 1; } @@ -681,12 +681,12 @@ namespace LuaItem * * @return uint32 bagSize */ - int GetBagSize(lua_State* L, Item* item) + int GetBagSize(Eluna* E, Item* item) { if (Bag* bag = item->ToBag()) - Eluna::Push(L, bag->GetBagSize()); + E->Push(bag->GetBagSize()); else - Eluna::Push(L, 0); + E->Push(0); return 1; } @@ -695,9 +695,9 @@ namespace LuaItem * * @param [Player] player : the [Player] specified */ - int SetOwner(lua_State* L, Item* item) + int SetOwner(Eluna* E, Item* item) { - Player* player = Eluna::CHECKOBJ(L, 2); + Player* player = Eluna::CHECKOBJ(E->L, 2); item->SetOwnerGUID(player->GET_GUID()); return 0; @@ -708,9 +708,9 @@ namespace LuaItem * * @param bool setBinding */ - int SetBinding(lua_State* L, Item* item) + int SetBinding(Eluna* E, Item* item) { - bool soulbound = Eluna::CHECKVAL(L, 2); + bool soulbound = Eluna::CHECKVAL(E->L, 2); item->SetBinding(soulbound); item->SetState(ITEM_CHANGED, item->GetOwner()); @@ -723,9 +723,9 @@ namespace LuaItem * * @param uint32 count */ - int SetCount(lua_State* L, Item* item) + int SetCount(Eluna* E, Item* item) { - uint32 count = Eluna::CHECKVAL(L, 2); + uint32 count = Eluna::CHECKVAL(E->L, 2); item->SetCount(count); return 0; } @@ -737,30 +737,30 @@ namespace LuaItem * @param uint32 enchantSlot : the slot for the enchant to be applied to * @return bool enchantmentSuccess : if enchantment is successfully set to specified slot, returns 'true', otherwise 'false' */ - int SetEnchantment(lua_State* L, Item* item) + int SetEnchantment(Eluna* E, Item* item) { Player* owner = item->GetOwner(); if (!owner) { - Eluna::Push(L, false); + E->Push(false); return 1; } - uint32 enchant = Eluna::CHECKVAL(L, 2); + uint32 enchant = Eluna::CHECKVAL(E->L, 2); if (!sSpellItemEnchantmentStore.LookupEntry(enchant)) { - Eluna::Push(L, false); + E->Push(false); return 1; } - EnchantmentSlot slot = (EnchantmentSlot)Eluna::CHECKVAL(L, 3); + EnchantmentSlot slot = (EnchantmentSlot)Eluna::CHECKVAL(E->L, 3); if (slot >= MAX_INSPECTED_ENCHANTMENT_SLOT) - return luaL_argerror(L, 2, "valid EnchantmentSlot expected"); + return luaL_argerror(E->L, 2, "valid EnchantmentSlot expected"); owner->ApplyEnchantment(item, slot, false); item->SetEnchantment(slot, enchant, 0, 0); owner->ApplyEnchantment(item, slot, true); - Eluna::Push(L, true); + E->Push(true); return 1; } @@ -771,35 +771,35 @@ namespace LuaItem * @param uint32 enchantSlot : the slot for the enchant to be removed from * @return bool enchantmentRemoved : if enchantment is successfully removed from specified slot, returns 'true', otherwise 'false' */ - int ClearEnchantment(lua_State* L, Item* item) + int ClearEnchantment(Eluna* E, Item* item) { Player* owner = item->GetOwner(); if (!owner) { - Eluna::Push(L, false); + E->Push(false); return 1; } - EnchantmentSlot slot = (EnchantmentSlot)Eluna::CHECKVAL(L, 2); + EnchantmentSlot slot = (EnchantmentSlot)Eluna::CHECKVAL(E->L, 2); if (slot >= MAX_INSPECTED_ENCHANTMENT_SLOT) - return luaL_argerror(L, 2, "valid EnchantmentSlot expected"); + return luaL_argerror(E->L, 2, "valid EnchantmentSlot expected"); if (!item->GetEnchantmentId(slot)) { - Eluna::Push(L, false); + E->Push(false); return 1; } owner->ApplyEnchantment(item, slot, false); item->ClearEnchantment(slot); - Eluna::Push(L, true); + E->Push(true); return 1; } /** * Saves the [Item] to the database */ - int SaveToDB(lua_State* /*L*/, Item* item) + int SaveToDB(Eluna* /*E*/, Item* item) { CharacterDatabaseTransaction trans = CharacterDatabaseTransaction(nullptr); item->SaveToDB(trans); diff --git a/TrinityCore/MapMethods.h b/TrinityCore/MapMethods.h index 4384cce751..4b7c5d36c8 100644 --- a/TrinityCore/MapMethods.h +++ b/TrinityCore/MapMethods.h @@ -22,9 +22,9 @@ namespace LuaMap * * @return bool isArena */ - int IsArena(lua_State* L, Map* map) + int IsArena(Eluna* E, Map* map) { - Eluna::Push(L, map->IsBattleArena()); + E->Push(map->IsBattleArena()); return 1; } @@ -33,9 +33,9 @@ namespace LuaMap * * @return bool isBattleGround */ - int IsBattleground(lua_State* L, Map* map) + int IsBattleground(Eluna* E, Map* map) { - Eluna::Push(L, map->IsBattleground()); + E->Push(map->IsBattleground()); return 1; } @@ -44,9 +44,9 @@ namespace LuaMap * * @return bool isDungeon */ - int IsDungeon(lua_State* L, Map* map) + int IsDungeon(Eluna* E, Map* map) { - Eluna::Push(L, map->IsDungeon()); + E->Push(map->IsDungeon()); return 1; } @@ -55,9 +55,9 @@ namespace LuaMap * * @return bool isEmpty */ - int IsEmpty(lua_State* L, Map* map) + int IsEmpty(Eluna* E, Map* map) { - Eluna::Push(L, map->isEmpty()); + E->Push(map->isEmpty()); return 1; } @@ -66,9 +66,9 @@ namespace LuaMap * * @return bool isHeroic */ - int IsHeroic(lua_State* L, Map* map) + int IsHeroic(Eluna* E, Map* map) { - Eluna::Push(L, map->IsHeroic()); + E->Push(map->IsHeroic()); return 1; } @@ -77,9 +77,9 @@ namespace LuaMap * * @return bool isRaid */ - int IsRaid(lua_State* L, Map* map) + int IsRaid(Eluna* E, Map* map) { - Eluna::Push(L, map->IsRaid()); + E->Push(map->IsRaid()); return 1; } @@ -88,9 +88,9 @@ namespace LuaMap * * @return string mapName */ - int GetName(lua_State* L, Map* map) + int GetName(Eluna* E, Map* map) { - Eluna::Push(L, map->GetMapName()); + E->Push(map->GetMapName()); return 1; } @@ -103,20 +103,20 @@ namespace LuaMap * @param float y * @return float z */ - int GetHeight(lua_State* L, Map* map) + int GetHeight(Eluna* E, Map* map) { - float x = Eluna::CHECKVAL(L, 2); - float y = Eluna::CHECKVAL(L, 3); + float x = Eluna::CHECKVAL(E->L, 2); + float y = Eluna::CHECKVAL(E->L, 3); #ifdef CATA PhaseShift phase; float z = map->GetHeight(phase, x, y, MAX_HEIGHT); #else - uint32 phasemask = Eluna::CHECKVAL(L, 4, 1); + uint32 phasemask = Eluna::CHECKVAL(E->L, 4, 1); float z = map->GetHeight(phasemask, x, y, MAX_HEIGHT); #endif if (z != INVALID_HEIGHT) - Eluna::Push(L, z); + E->Push(z); return 1; } @@ -127,9 +127,9 @@ namespace LuaMap * * @return int32 difficulty */ - int GetDifficulty(lua_State* L, Map* map) + int GetDifficulty(Eluna* E, Map* map) { - Eluna::Push(L, map->GetDifficulty()); + E->Push(map->GetDifficulty()); return 1; } @@ -138,9 +138,9 @@ namespace LuaMap * * @return uint32 instanceId */ - int GetInstanceId(lua_State* L, Map* map) + int GetInstanceId(Eluna* E, Map* map) { - Eluna::Push(L, map->GetInstanceId()); + E->Push(map->GetInstanceId()); return 1; } @@ -149,9 +149,9 @@ namespace LuaMap * * @return uint32 playerCount */ - int GetPlayerCount(lua_State* L, Map* map) + int GetPlayerCount(Eluna* E, Map* map) { - Eluna::Push(L, map->GetPlayersCountExceptGMs()); + E->Push(map->GetPlayersCountExceptGMs()); return 1; } @@ -160,9 +160,9 @@ namespace LuaMap * * @return uint32 mapId */ - int GetMapId(lua_State* L, Map* map) + int GetMapId(Eluna* E, Map* map) { - Eluna::Push(L, map->GetId()); + E->Push(map->GetId()); return 1; } @@ -175,18 +175,18 @@ namespace LuaMap * @param uint32 phasemask = PHASEMASK_NORMAL * @return uint32 areaId */ - int GetAreaId(lua_State* L, Map* map) + int GetAreaId(Eluna* E, Map* map) { - float x = Eluna::CHECKVAL(L, 2); - float y = Eluna::CHECKVAL(L, 3); - float z = Eluna::CHECKVAL(L, 4); + float x = Eluna::CHECKVAL(E->L, 2); + float y = Eluna::CHECKVAL(E->L, 3); + float z = Eluna::CHECKVAL(E->L, 4); #ifdef CATA PhaseShift phase; - Eluna::Push(L, map->GetAreaId(phase, x, y, z)); + E->Push(map->GetAreaId(phase, x, y, z)); #else - float phasemask = Eluna::CHECKVAL(L, 5, PHASEMASK_NORMAL); + float phasemask = Eluna::CHECKVAL(E->L, 5, PHASEMASK_NORMAL); - Eluna::Push(L, map->GetAreaId(phasemask, x, y, z)); + E->Push(map->GetAreaId(phasemask, x, y, z)); #endif return 1; } @@ -197,32 +197,32 @@ namespace LuaMap * @param ObjectGuid guid * @return [WorldObject] object */ - int GetWorldObject(lua_State* L, Map* map) + int GetWorldObject(Eluna* E, Map* map) { - ObjectGuid guid = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 2); switch (guid.GetHigh()) { case HIGHGUID_PLAYER: - Eluna::Push(L, eObjectAccessor()GetPlayer(map, guid)); + E->Push(eObjectAccessor()GetPlayer(map, guid)); break; case HIGHGUID_TRANSPORT: case HIGHGUID_MO_TRANSPORT: case HIGHGUID_GAMEOBJECT: - Eluna::Push(L, map->GetGameObject(guid)); + E->Push(map->GetGameObject(guid)); break; case HIGHGUID_VEHICLE: case HIGHGUID_UNIT: - Eluna::Push(L, map->GetCreature(guid)); + E->Push(map->GetCreature(guid)); break; case HIGHGUID_PET: - Eluna::Push(L, map->GetPet(guid)); + E->Push(map->GetPet(guid)); break; case HIGHGUID_DYNAMICOBJECT: - Eluna::Push(L, map->GetDynamicObject(guid)); + E->Push(map->GetDynamicObject(guid)); break; case HIGHGUID_CORPSE: - Eluna::Push(L, map->GetCorpse(guid)); + E->Push(map->GetCorpse(guid)); break; default: break; @@ -248,12 +248,12 @@ namespace LuaMap * @param [WeatherType] type : the [WeatherType], see above available weather types * @param float grade : the intensity/grade of the [Weather], ranges from 0 to 1 */ - int SetWeather(lua_State* L, Map* map) + int SetWeather(Eluna* E, Map* map) { (void)map; // ensure that the variable is referenced in order to pass compiler checks - uint32 zoneId = Eluna::CHECKVAL(L, 2); - uint32 weatherType = Eluna::CHECKVAL(L, 3); - float grade = Eluna::CHECKVAL(L, 4); + uint32 zoneId = Eluna::CHECKVAL(E->L, 2); + uint32 weatherType = Eluna::CHECKVAL(E->L, 3); + float grade = Eluna::CHECKVAL(E->L, 4); if (Weather * weather = map->GetOrGenerateZoneDefaultWeather(zoneId)) weather->SetWeather((WeatherType)weatherType, grade); @@ -268,16 +268,16 @@ namespace LuaMap * * @return table instance_data : instance data table, or `nil` */ - int GetInstanceData(lua_State* L, Map* map) + int GetInstanceData(Eluna* E, Map* map) { ElunaInstanceAI* iAI = NULL; if (InstanceMap* inst = map->ToInstanceMap()) iAI = dynamic_cast(inst->GetInstanceScript()); if (iAI) - Eluna::GetEluna(L)->PushInstanceData(L, iAI, false); + E->PushInstanceData(E->L, iAI, false); else - Eluna::Push(L); // nil + E->Push(); // nil return 1; } @@ -285,7 +285,7 @@ namespace LuaMap /** * Saves the [Map]'s instance data to the database. */ - int SaveInstanceData(lua_State* /*L*/, Map* map) + int SaveInstanceData(Eluna* /*E*/, Map* map) { ElunaInstanceAI* iAI = NULL; if (InstanceMap* inst = map->ToInstanceMap()) @@ -310,12 +310,12 @@ namespace LuaMap * @param [TeamId] team : optional check team of the [Player], Alliance, Horde or Neutral (All) * @return table mapPlayers */ - int GetPlayers(lua_State* L, Map* map) + int GetPlayers(Eluna* E, Map* map) { - uint32 team = Eluna::CHECKVAL(L, 2, TEAM_NEUTRAL); + uint32 team = Eluna::CHECKVAL(E->L, 2, TEAM_NEUTRAL); - lua_newtable(L); - int tbl = lua_gettop(L); + lua_newtable(E->L); + int tbl = lua_gettop(E->L); uint32 i = 0; Map::PlayerList const& players = map->GetPlayers(); @@ -327,12 +327,12 @@ namespace LuaMap if (player->GetSession() && (team >= TEAM_NEUTRAL || player->GetTeamId() == team)) { - Eluna::Push(L, player); - lua_rawseti(L, tbl, ++i); + E->Push(player); + lua_rawseti(E->L, tbl, ++i); } } - lua_settop(L, tbl); + lua_settop(E->L, tbl); return 1; } diff --git a/TrinityCore/ObjectMethods.h b/TrinityCore/ObjectMethods.h index 91ef891e3e..6bd6da7485 100644 --- a/TrinityCore/ObjectMethods.h +++ b/TrinityCore/ObjectMethods.h @@ -31,12 +31,12 @@ namespace LuaObject * @param uint32 flag : the flag to check for in the flags data * @return bool hasFlag */ - int HasFlag(lua_State* L, Object* obj) + int HasFlag(Eluna* E, Object* obj) { - uint16 index = Eluna::CHECKVAL(L, 2); - uint32 flag = Eluna::CHECKVAL(L, 3); + uint16 index = Eluna::CHECKVAL(E->L, 2); + uint32 flag = Eluna::CHECKVAL(E->L, 3); - Eluna::Push(L, obj->HasFlag(index, flag)); + E->Push(obj->HasFlag(index, flag)); return 1; } @@ -45,9 +45,9 @@ namespace LuaObject * * @return bool inWorld */ - int IsInWorld(lua_State* L, Object* obj) + int IsInWorld(Eluna* E, Object* obj) { - Eluna::Push(L, obj->IsInWorld()); + E->Push(obj->IsInWorld()); return 1; } @@ -57,10 +57,10 @@ namespace LuaObject * @param uint16 index * @return int32 value */ - int GetInt32Value(lua_State* L, Object* obj) + int GetInt32Value(Eluna* E, Object* obj) { - uint16 index = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, obj->GetInt32Value(index)); + uint16 index = Eluna::CHECKVAL(E->L, 2); + E->Push(obj->GetInt32Value(index)); return 1; } @@ -70,10 +70,10 @@ namespace LuaObject * @param uint16 index * @return uint32 value */ - int GetUInt32Value(lua_State* L, Object* obj) + int GetUInt32Value(Eluna* E, Object* obj) { - uint16 index = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, obj->GetUInt32Value(index)); + uint16 index = Eluna::CHECKVAL(E->L, 2); + E->Push(obj->GetUInt32Value(index)); return 1; } @@ -83,10 +83,10 @@ namespace LuaObject * @param uint16 index * @return float value */ - int GetFloatValue(lua_State* L, Object* obj) + int GetFloatValue(Eluna* E, Object* obj) { - uint16 index = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, obj->GetFloatValue(index)); + uint16 index = Eluna::CHECKVAL(E->L, 2); + E->Push(obj->GetFloatValue(index)); return 1; } @@ -99,11 +99,11 @@ namespace LuaObject * @param uint8 offset : should be 0, 1, 2, or 3 * @return uint8 value */ - int GetByteValue(lua_State* L, Object* obj) + int GetByteValue(Eluna* E, Object* obj) { - uint16 index = Eluna::CHECKVAL(L, 2); - uint8 offset = Eluna::CHECKVAL(L, 3); - Eluna::Push(L, obj->GetByteValue(index, offset)); + uint16 index = Eluna::CHECKVAL(E->L, 2); + uint8 offset = Eluna::CHECKVAL(E->L, 3); + E->Push(obj->GetByteValue(index, offset)); return 1; } @@ -116,11 +116,11 @@ namespace LuaObject * @param uint8 offset : should be 0 or 1 * @return uint16 value */ - int GetUInt16Value(lua_State* L, Object* obj) + int GetUInt16Value(Eluna* E, Object* obj) { - uint16 index = Eluna::CHECKVAL(L, 2); - uint8 offset = Eluna::CHECKVAL(L, 3); - Eluna::Push(L, obj->GetUInt16Value(index, offset)); + uint16 index = Eluna::CHECKVAL(E->L, 2); + uint8 offset = Eluna::CHECKVAL(E->L, 3); + E->Push(obj->GetUInt16Value(index, offset)); return 1; } @@ -131,9 +131,9 @@ namespace LuaObject * * @return float scale */ - int GetScale(lua_State* L, Object* obj) + int GetScale(Eluna* E, Object* obj) { - Eluna::Push(L, obj->GetObjectScale()); + E->Push(obj->GetObjectScale()); return 1; } @@ -144,9 +144,9 @@ namespace LuaObject * * @return uint32 entry */ - int GetEntry(lua_State* L, Object* obj) + int GetEntry(Eluna* E, Object* obj) { - Eluna::Push(L, obj->GetEntry()); + E->Push(obj->GetEntry()); return 1; } @@ -162,9 +162,9 @@ namespace LuaObject * * @return ObjectGuid guid */ - int GetGUID(lua_State* L, Object* obj) + int GetGUID(Eluna* E, Object* obj) { - Eluna::Push(L, obj->GET_GUID()); + E->Push(obj->GET_GUID()); return 1; } @@ -180,9 +180,9 @@ namespace LuaObject * * @return uint32 guidLow */ - int GetGUIDLow(lua_State* L, Object* obj) + int GetGUIDLow(Eluna* E, Object* obj) { - Eluna::Push(L, obj->GetGUID().GetCounter()); + E->Push(obj->GetGUID().GetCounter()); return 1; } @@ -203,9 +203,9 @@ namespace LuaObject * * @return uint8 typeID */ - int GetTypeId(lua_State* L, Object* obj) + int GetTypeId(Eluna* E, Object* obj) { - Eluna::Push(L, obj->GetTypeId()); + E->Push(obj->GetTypeId()); return 1; } @@ -215,10 +215,10 @@ namespace LuaObject * @param uint16 index * @return uint64 value */ - int GetUInt64Value(lua_State* L, Object* obj) + int GetUInt64Value(Eluna* E, Object* obj) { - uint16 index = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, obj->GetUInt64Value(index)); + uint16 index = Eluna::CHECKVAL(E->L, 2); + E->Push(obj->GetUInt64Value(index)); return 1; } @@ -232,10 +232,10 @@ namespace LuaObject * @param uint16 index * @param uint32 value */ - int SetFlag(lua_State* L, Object* obj) + int SetFlag(Eluna* E, Object* obj) { - uint16 index = Eluna::CHECKVAL(L, 2); - uint32 flag = Eluna::CHECKVAL(L, 3); + uint16 index = Eluna::CHECKVAL(E->L, 2); + uint32 flag = Eluna::CHECKVAL(E->L, 3); obj->SetFlag(index, flag); return 0; @@ -247,10 +247,10 @@ namespace LuaObject * @param uint16 index * @param int32 value */ - int SetInt32Value(lua_State* L, Object* obj) + int SetInt32Value(Eluna* E, Object* obj) { - uint16 index = Eluna::CHECKVAL(L, 2); - int32 value = Eluna::CHECKVAL(L, 3); + uint16 index = Eluna::CHECKVAL(E->L, 2); + int32 value = Eluna::CHECKVAL(E->L, 3); obj->SetInt32Value(index, value); return 0; } @@ -261,10 +261,10 @@ namespace LuaObject * @param uint16 index * @param uint32 value */ - int SetUInt32Value(lua_State* L, Object* obj) + int SetUInt32Value(Eluna* E, Object* obj) { - uint16 index = Eluna::CHECKVAL(L, 2); - uint32 value = Eluna::CHECKVAL(L, 3); + uint16 index = Eluna::CHECKVAL(E->L, 2); + uint32 value = Eluna::CHECKVAL(E->L, 3); obj->SetUInt32Value(index, value); return 0; } @@ -275,10 +275,10 @@ namespace LuaObject * @param uint16 index * @param uint32 value */ - int UpdateUInt32Value(lua_State* L, Object* obj) + int UpdateUInt32Value(Eluna* E, Object* obj) { - uint16 index = Eluna::CHECKVAL(L, 2); - uint32 value = Eluna::CHECKVAL(L, 3); + uint16 index = Eluna::CHECKVAL(E->L, 2); + uint32 value = Eluna::CHECKVAL(E->L, 3); obj->UpdateUInt32Value(index, value); return 0; } @@ -289,10 +289,10 @@ namespace LuaObject * @param uint16 index * @param float value */ - int SetFloatValue(lua_State* L, Object* obj) + int SetFloatValue(Eluna* E, Object* obj) { - uint16 index = Eluna::CHECKVAL(L, 2); - float value = Eluna::CHECKVAL(L, 3); + uint16 index = Eluna::CHECKVAL(E->L, 2); + float value = Eluna::CHECKVAL(E->L, 3); obj->SetFloatValue(index, value); return 0; @@ -305,11 +305,11 @@ namespace LuaObject * @param uint8 offset : should be 0, 1, 2, or 3 * @param uint8 value */ - int SetByteValue(lua_State* L, Object* obj) + int SetByteValue(Eluna* E, Object* obj) { - uint16 index = Eluna::CHECKVAL(L, 2); - uint8 offset = Eluna::CHECKVAL(L, 3); - uint8 value = Eluna::CHECKVAL(L, 4); + uint16 index = Eluna::CHECKVAL(E->L, 2); + uint8 offset = Eluna::CHECKVAL(E->L, 3); + uint8 value = Eluna::CHECKVAL(E->L, 4); obj->SetByteValue(index, offset, value); return 0; } @@ -321,11 +321,11 @@ namespace LuaObject * @param uint8 offset : should be 0 or 1 * @param uint16 value */ - int SetUInt16Value(lua_State* L, Object* obj) + int SetUInt16Value(Eluna* E, Object* obj) { - uint16 index = Eluna::CHECKVAL(L, 2); - uint8 offset = Eluna::CHECKVAL(L, 3); - uint16 value = Eluna::CHECKVAL(L, 4); + uint16 index = Eluna::CHECKVAL(E->L, 2); + uint8 offset = Eluna::CHECKVAL(E->L, 3); + uint16 value = Eluna::CHECKVAL(E->L, 4); obj->SetUInt16Value(index, offset, value); return 0; } @@ -337,11 +337,11 @@ namespace LuaObject * @param uint8 offset : should be 0 or 1 * @param int16 value */ - int SetInt16Value(lua_State* L, Object* obj) + int SetInt16Value(Eluna* E, Object* obj) { - uint16 index = Eluna::CHECKVAL(L, 2); - uint8 offset = Eluna::CHECKVAL(L, 3); - int16 value = Eluna::CHECKVAL(L, 4); + uint16 index = Eluna::CHECKVAL(E->L, 2); + uint8 offset = Eluna::CHECKVAL(E->L, 3); + int16 value = Eluna::CHECKVAL(E->L, 4); obj->SetInt16Value(index, offset, value); return 0; } @@ -351,9 +351,9 @@ namespace LuaObject * * @param float scale */ - int SetScale(lua_State* L, Object* obj) + int SetScale(Eluna* E, Object* obj) { - float size = Eluna::CHECKVAL(L, 2); + float size = Eluna::CHECKVAL(E->L, 2); obj->SetObjectScale(size); return 0; @@ -365,10 +365,10 @@ namespace LuaObject * @param uint16 index * @param uint64 value */ - int SetUInt64Value(lua_State* L, Object* obj) + int SetUInt64Value(Eluna* E, Object* obj) { - uint16 index = Eluna::CHECKVAL(L, 2); - uint64 value = Eluna::CHECKVAL(L, 3); + uint16 index = Eluna::CHECKVAL(E->L, 2); + uint64 value = Eluna::CHECKVAL(E->L, 3); obj->SetUInt64Value(index, value); return 0; } @@ -379,10 +379,10 @@ namespace LuaObject * @param uint16 index * @param uint32 flag */ - int RemoveFlag(lua_State* L, Object* obj) + int RemoveFlag(Eluna* E, Object* obj) { - uint16 index = Eluna::CHECKVAL(L, 2); - uint32 flag = Eluna::CHECKVAL(L, 3); + uint16 index = Eluna::CHECKVAL(E->L, 2); + uint32 flag = Eluna::CHECKVAL(E->L, 3); obj->RemoveFlag(index, flag); return 0; @@ -395,9 +395,9 @@ namespace LuaObject * * @return [Corpse] corpse : the [Object] as a [Corpse], or `nil` */ - int ToCorpse(lua_State* L, Object* obj) + int ToCorpse(Eluna* E, Object* obj) { - Eluna::Push(L, obj->ToCorpse()); + E->Push(obj->ToCorpse()); return 1; } @@ -408,9 +408,9 @@ namespace LuaObject * * @return [GameObject] gameObject : the [Object] as a [GameObject], or `nil` */ - int ToGameObject(lua_State* L, Object* obj) + int ToGameObject(Eluna* E, Object* obj) { - Eluna::Push(L, obj->ToGameObject()); + E->Push(obj->ToGameObject()); return 1; } @@ -421,9 +421,9 @@ namespace LuaObject * * @return [Unit] unit : the [Object] as a [Unit], or `nil` */ - int ToUnit(lua_State* L, Object* obj) + int ToUnit(Eluna* E, Object* obj) { - Eluna::Push(L, obj->ToUnit()); + E->Push(obj->ToUnit()); return 1; } @@ -434,9 +434,9 @@ namespace LuaObject * * @return [Creature] creature : the [Object] as a [Creature], or `nil` */ - int ToCreature(lua_State* L, Object* obj) + int ToCreature(Eluna* E, Object* obj) { - Eluna::Push(L, obj->ToCreature()); + E->Push(obj->ToCreature()); return 1; } @@ -447,9 +447,9 @@ namespace LuaObject * * @return [Player] player : the [Object] as a [Player], or `nil` */ - int ToPlayer(lua_State* L, Object* obj) + int ToPlayer(Eluna* E, Object* obj) { - Eluna::Push(L, obj->ToPlayer()); + E->Push(obj->ToPlayer()); return 1; } diff --git a/TrinityCore/PlayerMethods.h b/TrinityCore/PlayerMethods.h index 1e7fbfb15c..344d952802 100644 --- a/TrinityCore/PlayerMethods.h +++ b/TrinityCore/PlayerMethods.h @@ -17,9 +17,9 @@ namespace LuaPlayer * * @return bool canTitanGrip */ - int CanTitanGrip(lua_State* L, Player* player) + int CanTitanGrip(Eluna* E, Player* player) { - Eluna::Push(L, player->CanTitanGrip()); + E->Push(player->CanTitanGrip()); return 1; } @@ -30,16 +30,16 @@ namespace LuaPlayer * @param uint8 spec : specified spec. 0 for primary, 1 for secondary. * @return bool hasTalent */ - int HasTalent(lua_State* L, Player* player) + int HasTalent(Eluna* E, Player* player) { - uint32 spellId = Eluna::CHECKVAL(L, 2); + uint32 spellId = Eluna::CHECKVAL(E->L, 2); uint8 maxSpecs = MAX_TALENT_SPECS; - uint8 spec = Eluna::CHECKVAL(L, 3); + uint8 spec = Eluna::CHECKVAL(E->L, 3); if (spec >= maxSpecs) return 1; - Eluna::Push(L, player->HasTalent(spellId, spec)); + E->Push(player->HasTalent(spellId, spec)); return 1; } @@ -49,11 +49,11 @@ namespace LuaPlayer * @param uint32 achievementId * @return bool hasAchieved */ - int HasAchieved(lua_State* L, Player* player) + int HasAchieved(Eluna* E, Player* player) { - uint32 achievementId = Eluna::CHECKVAL(L, 2); + uint32 achievementId = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->HasAchieved(achievementId)); + E->Push(player->HasAchieved(achievementId)); return 1; } @@ -63,11 +63,11 @@ namespace LuaPlayer * @param uint32 questId * @return bool hasQuest */ - int HasQuest(lua_State* L, Player* player) + int HasQuest(Eluna* E, Player* player) { - uint32 quest = Eluna::CHECKVAL(L, 2); + uint32 quest = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->IsActiveQuest(quest)); + E->Push(player->IsActiveQuest(quest)); return 1; } @@ -77,11 +77,11 @@ namespace LuaPlayer * @param uint32 skill * @return bool hasSkill */ - int HasSkill(lua_State* L, Player* player) + int HasSkill(Eluna* E, Player* player) { - uint32 skill = Eluna::CHECKVAL(L, 2); + uint32 skill = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->HasSkill(skill)); + E->Push(player->HasSkill(skill)); return 1; } @@ -91,11 +91,11 @@ namespace LuaPlayer * @param uint32 spellId * @return bool hasSpell */ - int HasSpell(lua_State* L, Player* player) + int HasSpell(Eluna* E, Player* player) { - uint32 id = Eluna::CHECKVAL(L, 2); + uint32 id = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->HasSpell(id)); + E->Push(player->HasSpell(id)); return 1; } @@ -105,11 +105,11 @@ namespace LuaPlayer * @param uint32 flag * @return bool hasLoginFlag */ - int HasAtLoginFlag(lua_State* L, Player* player) + int HasAtLoginFlag(Eluna* E, Player* player) { - uint32 flag = Eluna::CHECKVAL(L, 2); + uint32 flag = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->HasAtLoginFlag((AtLoginFlags)flag)); + E->Push(player->HasAtLoginFlag((AtLoginFlags)flag)); return 1; } @@ -119,11 +119,11 @@ namespace LuaPlayer * @param int32 entry : entry of a [GameObject] * @return bool hasQuest */ - int HasQuestForGO(lua_State* L, Player* player) + int HasQuestForGO(Eluna* E, Player* player) { - int32 entry = Eluna::CHECKVAL(L, 2); + int32 entry = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->HasQuestForGO(entry)); + E->Push(player->HasQuestForGO(entry)); return 1; } @@ -133,12 +133,12 @@ namespace LuaPlayer * @param uint32 titleId * @return bool hasTitle */ - int HasTitle(lua_State* L, Player* player) + int HasTitle(Eluna* E, Player* player) { - uint32 id = Eluna::CHECKVAL(L, 2); + uint32 id = Eluna::CHECKVAL(E->L, 2); CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); if (titleInfo) - Eluna::Push(L, player->HasTitle(titleInfo)); + E->Push(player->HasTitle(titleInfo)); return 1; } @@ -150,12 +150,12 @@ namespace LuaPlayer * @param bool check_bank = false : determines if the item can be in player bank * @return bool hasItem */ - int HasItem(lua_State* L, Player* player) + int HasItem(Eluna* E, Player* player) { - uint32 itemId = Eluna::CHECKVAL(L, 2); - uint32 count = Eluna::CHECKVAL(L, 3, 1); - bool check_bank = Eluna::CHECKVAL(L, 4, false); - Eluna::Push(L, player->HasItemCount(itemId, count, check_bank)); + uint32 itemId = Eluna::CHECKVAL(E->L, 2); + uint32 count = Eluna::CHECKVAL(E->L, 3, 1); + bool check_bank = Eluna::CHECKVAL(E->L, 4, false); + E->Push(player->HasItemCount(itemId, count, check_bank)); return 1; } @@ -165,11 +165,11 @@ namespace LuaPlayer * @param uint32 entry : entry of the item * @return bool hasQuest */ - int HasQuestForItem(lua_State* L, Player* player) + int HasQuestForItem(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->HasQuestForItem(entry)); + E->Push(player->HasQuestForItem(entry)); return 1; } @@ -182,19 +182,19 @@ namespace LuaPlayer * @param uint32 entry : entry of the item * @return bool canUse */ - int CanUseItem(lua_State* L, Player* player) + int CanUseItem(Eluna* E, Player* player) { - Item* item = Eluna::CHECKOBJ(L, 2, false); + Item* item = Eluna::CHECKOBJ(E->L, 2, false); if (item) - Eluna::Push(L, player->CanUseItem(item) == EQUIP_ERR_OK); + E->Push(player->CanUseItem(item) == EQUIP_ERR_OK); else { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); const ItemTemplate* temp = eObjectMgr->GetItemTemplate(entry); if (temp) - Eluna::Push(L, player->CanUseItem(temp) == EQUIP_ERR_OK); + E->Push(player->CanUseItem(temp) == EQUIP_ERR_OK); else - Eluna::Push(L, false); + E->Push(false); } return 1; } @@ -205,11 +205,11 @@ namespace LuaPlayer * @param uint32 spellId * @return bool hasSpellCooldown */ - int HasSpellCooldown(lua_State* L, Player* player) + int HasSpellCooldown(Eluna* E, Player* player) { - uint32 spellId = Eluna::CHECKVAL(L, 2); + uint32 spellId = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->GetSpellHistory()->HasCooldown(spellId)); + E->Push(player->GetSpellHistory()->HasCooldown(spellId)); return 1; } @@ -219,11 +219,11 @@ namespace LuaPlayer * @param uint32 entryId * @return bool hasSpellCooldown */ - int CanShareQuest(lua_State* L, Player* player) + int CanShareQuest(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->CanShareQuest(entry)); + E->Push(player->CanShareQuest(entry)); return 1; } @@ -232,12 +232,12 @@ namespace LuaPlayer * * @return bool canSpeak */ - int CanSpeak(lua_State* L, Player* player) + int CanSpeak(Eluna* E, Player* player) { #ifndef CATA - Eluna::Push(L, player->GetSession()->CanSpeak()); + E->Push(player->GetSession()->CanSpeak()); #else - Eluna::Push(L, player->CanSpeak()); + E->Push(player->CanSpeak()); #endif return 1; } @@ -247,9 +247,9 @@ namespace LuaPlayer * * @return bool canUninviteFromGroup */ - int CanUninviteFromGroup(lua_State* L, Player* player) + int CanUninviteFromGroup(Eluna* E, Player* player) { - Eluna::Push(L, player->CanUninviteFromGroup() == ERR_PARTY_RESULT_OK); + E->Push(player->CanUninviteFromGroup() == ERR_PARTY_RESULT_OK); return 1; } @@ -258,9 +258,9 @@ namespace LuaPlayer * * @return bool canFly */ - int CanFly(lua_State* L, Player* player) + int CanFly(Eluna* E, Player* player) { - Eluna::Push(L, player->CanFly()); + E->Push(player->CanFly()); return 1; } @@ -269,9 +269,9 @@ namespace LuaPlayer * * @return bool isInWater */ - int IsInWater(lua_State* L, Player* player) + int IsInWater(Eluna* E, Player* player) { - Eluna::Push(L, player->IsInWater()); + E->Push(player->IsInWater()); return 1; } @@ -280,9 +280,9 @@ namespace LuaPlayer * * @return bool isMoving */ - int IsMoving(lua_State* L, Player* player) // enable for unit when mangos support it + int IsMoving(Eluna* E, Player* player) // enable for unit when mangos support it { - Eluna::Push(L, player->isMoving()); + E->Push(player->isMoving()); return 1; } @@ -291,9 +291,9 @@ namespace LuaPlayer * * @return bool isFlying */ - int IsFlying(lua_State* L, Player* player) // enable for unit when mangos support it + int IsFlying(Eluna* E, Player* player) // enable for unit when mangos support it { - Eluna::Push(L, player->IsFlying()); + E->Push(player->IsFlying()); return 1; } @@ -302,9 +302,9 @@ namespace LuaPlayer * * @return bool isInGroup */ - int IsInGroup(lua_State* L, Player* player) + int IsInGroup(Eluna* E, Player* player) { - Eluna::Push(L, (player->GetGroup() != NULL)); + E->Push((player->GetGroup() != NULL)); return 1; } @@ -313,9 +313,9 @@ namespace LuaPlayer * * @return bool isInGuild */ - int IsInGuild(lua_State* L, Player* player) + int IsInGuild(Eluna* E, Player* player) { - Eluna::Push(L, (player->GetGuildId() != 0)); + E->Push((player->GetGuildId() != 0)); return 1; } @@ -326,9 +326,9 @@ namespace LuaPlayer * * @return bool isGM */ - int IsGM(lua_State* L, Player* player) + int IsGM(Eluna* E, Player* player) { - Eluna::Push(L, player->IsGameMaster()); + E->Push(player->IsGameMaster()); return 1; } @@ -338,13 +338,13 @@ namespace LuaPlayer * @param uint32 type * @return bool isInArenaTeam */ - int IsInArenaTeam(lua_State* L, Player* player) + int IsInArenaTeam(Eluna* E, Player* player) { - uint32 type = Eluna::CHECKVAL(L, 2); + uint32 type = Eluna::CHECKVAL(E->L, 2); if (type < MAX_ARENA_SLOT && player->GetArenaTeamId(type)) - Eluna::Push(L, true); + E->Push(true); else - Eluna::Push(L, false); + E->Push(false); return 1; } @@ -353,9 +353,9 @@ namespace LuaPlayer * * @return bool isImmune */ - int IsImmuneToDamage(lua_State* L, Player* player) + int IsImmuneToDamage(Eluna* E, Player* player) { - Eluna::Push(L, player->isTotalImmune()); + E->Push(player->isTotalImmune()); return 1; } @@ -365,11 +365,11 @@ namespace LuaPlayer * @param uint32 entry * @return bool canComplete */ - int CanCompleteQuest(lua_State* L, Player* player) + int CanCompleteQuest(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->CanCompleteQuest(entry)); + E->Push(player->CanCompleteQuest(entry)); return 1; } @@ -380,15 +380,15 @@ namespace LuaPlayer * @param uint32 entry * @return bool canComplete */ - int CanCompleteRepeatableQuest(lua_State* L, Player* player) + int CanCompleteRepeatableQuest(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); Quest const* qInfo = sObjectMgr->GetQuestTemplate(entry); if (qInfo) - Eluna::Push(L, player->CanCompleteRepeatableQuest(qInfo)); + E->Push(player->CanCompleteRepeatableQuest(qInfo)); else - Eluna::Push(L, false); + E->Push(false); return 1; } @@ -399,15 +399,15 @@ namespace LuaPlayer * @param uint32 entry * @return bool canReward */ - int CanRewardQuest(lua_State* L, Player* player) + int CanRewardQuest(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); Quest const* qInfo = sObjectMgr->GetQuestTemplate(entry); if (qInfo) - Eluna::Push(L, player->CanRewardQuest(qInfo, true)); + E->Push(player->CanRewardQuest(qInfo, true)); else - Eluna::Push(L, false); + E->Push(false); return 1; } @@ -418,9 +418,9 @@ namespace LuaPlayer * * @return bool isHorde */ - int IsHorde(lua_State* L, Player* player) + int IsHorde(Eluna* E, Player* player) { - Eluna::Push(L, (player->GetTeam() == HORDE)); + E->Push((player->GetTeam() == HORDE)); return 1; } @@ -429,9 +429,9 @@ namespace LuaPlayer * * @return bool isAlliance */ - int IsAlliance(lua_State* L, Player* player) + int IsAlliance(Eluna* E, Player* player) { - Eluna::Push(L, (player->GetTeam() == ALLIANCE)); + E->Push((player->GetTeam() == ALLIANCE)); return 1; } @@ -440,9 +440,9 @@ namespace LuaPlayer * * @return bool isDND */ - int IsDND(lua_State* L, Player* player) + int IsDND(Eluna* E, Player* player) { - Eluna::Push(L, player->isDND()); + E->Push(player->isDND()); return 1; } @@ -451,9 +451,9 @@ namespace LuaPlayer * * @return bool isAFK */ - int IsAFK(lua_State* L, Player* player) + int IsAFK(Eluna* E, Player* player) { - Eluna::Push(L, player->isAFK()); + E->Push(player->isAFK()); return 1; } @@ -462,16 +462,16 @@ namespace LuaPlayer * * @return bool isFalling */ - int IsFalling(lua_State* L, Player* player) + int IsFalling(Eluna* E, Player* player) { - Eluna::Push(L, player->IsFalling()); + E->Push(player->IsFalling()); return 1; } - int IsGroupVisibleFor(lua_State* L, Player* player) + int IsGroupVisibleFor(Eluna* E, Player* player) { - Player* target = Eluna::CHECKOBJ(L, 2); - Eluna::Push(L, player->IsGroupVisibleFor(target)); + Player* target = Eluna::CHECKOBJ(E->L, 2); + E->Push(player->IsGroupVisibleFor(target)); return 1; } @@ -481,10 +481,10 @@ namespace LuaPlayer * @param [Player] player * @return bool isInSameRaidWith */ - int IsInSameRaidWith(lua_State* L, Player* player) + int IsInSameRaidWith(Eluna* E, Player* player) { - Player* target = Eluna::CHECKOBJ(L, 2); - Eluna::Push(L, player->IsInSameRaidWith(target)); + Player* target = Eluna::CHECKOBJ(E->L, 2); + E->Push(player->IsInSameRaidWith(target)); return 1; } @@ -494,10 +494,10 @@ namespace LuaPlayer * @param [Player] player * @return bool isInSameGroupWith */ - int IsInSameGroupWith(lua_State* L, Player* player) + int IsInSameGroupWith(Eluna* E, Player* player) { - Player* target = Eluna::CHECKOBJ(L, 2); - Eluna::Push(L, player->IsInSameGroupWith(target)); + Player* target = Eluna::CHECKOBJ(E->L, 2); + E->Push(player->IsInSameGroupWith(target)); return 1; } @@ -507,11 +507,11 @@ namespace LuaPlayer * @param [Unit] unit * @return bool isHonorOrXPTarget */ - int IsHonorOrXPTarget(lua_State* L, Player* player) + int IsHonorOrXPTarget(Eluna* E, Player* player) { - Unit* victim = Eluna::CHECKOBJ(L, 2); + Unit* victim = Eluna::CHECKOBJ(E->L, 2); - Eluna::Push(L, player->isHonorOrXPTarget(victim)); + E->Push(player->isHonorOrXPTarget(victim)); return 1; } @@ -521,17 +521,17 @@ namespace LuaPlayer * @param [Player] player * @return bool isVisibleForPlayer */ - int IsVisibleForPlayer(lua_State* L, Player* player) + int IsVisibleForPlayer(Eluna* E, Player* player) { - Player* target = Eluna::CHECKOBJ(L, 2); + Player* target = Eluna::CHECKOBJ(E->L, 2); - Eluna::Push(L, player->IsVisibleGloballyFor(target)); + E->Push(player->IsVisibleGloballyFor(target)); return 1; } - int IsGMVisible(lua_State* L, Player* player) + int IsGMVisible(Eluna* E, Player* player) { - Eluna::Push(L, player->isGMVisible()); + E->Push(player->isGMVisible()); return 1; } @@ -540,15 +540,15 @@ namespace LuaPlayer * * @return bool isTaxiCheater */ - int IsTaxiCheater(lua_State* L, Player* player) + int IsTaxiCheater(Eluna* E, Player* player) { - Eluna::Push(L, player->isTaxiCheater()); + E->Push(player->isTaxiCheater()); return 1; } - int IsGMChat(lua_State* L, Player* player) + int IsGMChat(Eluna* E, Player* player) { - Eluna::Push(L, player->isGMChat()); + E->Push(player->isGMChat()); return 1; } @@ -557,9 +557,9 @@ namespace LuaPlayer * * @return bool isAcceptingWhispers */ - int IsAcceptingWhispers(lua_State* L, Player* player) + int IsAcceptingWhispers(Eluna* E, Player* player) { - Eluna::Push(L, player->isAcceptWhispers()); + E->Push(player->isAcceptWhispers()); return 1; } @@ -568,9 +568,9 @@ namespace LuaPlayer * * @return bool isRested */ - int IsRested(lua_State* L, Player* player) + int IsRested(Eluna* E, Player* player) { - Eluna::Push(L, player->GetRestBonus() > 0.0f); + E->Push(player->GetRestBonus() > 0.0f); return 1; } @@ -579,9 +579,9 @@ namespace LuaPlayer * * @return bool inBattlegroundQueue */ - int InBattlegroundQueue(lua_State* L, Player* player) + int InBattlegroundQueue(Eluna* E, Player* player) { - Eluna::Push(L, player->InBattlegroundQueue()); + E->Push(player->InBattlegroundQueue()); return 1; } @@ -590,9 +590,9 @@ namespace LuaPlayer * * @return bool inArena */ - int InArena(lua_State* L, Player* player) + int InArena(Eluna* E, Player* player) { - Eluna::Push(L, player->InArena()); + E->Push(player->InArena()); return 1; } @@ -601,9 +601,9 @@ namespace LuaPlayer * * @return bool inBattleGround */ - int InBattleground(lua_State* L, Player* player) + int InBattleground(Eluna* E, Player* player) { - Eluna::Push(L, player->InBattleground()); + E->Push(player->InBattleground()); return 1; } @@ -612,9 +612,9 @@ namespace LuaPlayer * * @return bool canBlock */ - int CanBlock(lua_State* L, Player* player) + int CanBlock(Eluna* E, Player* player) { - Eluna::Push(L, player->CanBlock()); + E->Push(player->CanBlock()); return 1; } @@ -623,73 +623,73 @@ namespace LuaPlayer * * @return bool canParry */ - int CanParry(lua_State* L, Player* player) + int CanParry(Eluna* E, Player* player) { - Eluna::Push(L, player->CanParry()); + E->Push(player->CanParry()); return 1; } - int HasReceivedQuestReward(lua_State* L, Player* player) + int HasReceivedQuestReward(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->IsQuestRewarded(entry)); + E->Push(player->IsQuestRewarded(entry)); return 1; } - int IsOutdoorPvPActive(lua_State* L, Player* player) + int IsOutdoorPvPActive(Eluna* E, Player* player) { - Eluna::Push(L, player->IsOutdoorPvPActive()); + E->Push(player->IsOutdoorPvPActive()); return 1; } - int IsImmuneToEnvironmentalDamage(lua_State* L, Player* player) + int IsImmuneToEnvironmentalDamage(Eluna* E, Player* player) { - Eluna::Push(L, player->IsImmuneToEnvironmentalDamage()); + E->Push(player->IsImmuneToEnvironmentalDamage()); return 1; } - int InRandomLfgDungeon(lua_State* L, Player* player) + int InRandomLfgDungeon(Eluna* E, Player* player) { - Eluna::Push(L, player->inRandomLfgDungeon()); + E->Push(player->inRandomLfgDungeon()); return 1; } - int IsUsingLfg(lua_State* L, Player* player) + int IsUsingLfg(Eluna* E, Player* player) { - Eluna::Push(L, player->isUsingLfg()); + E->Push(player->isUsingLfg()); return 1; } - int IsNeverVisible(lua_State* L, Player* player) + int IsNeverVisible(Eluna* E, Player* player) { // Possibly add a bool var here #ifdef CATA - Eluna::Push(L, player->IsNeverVisible()); + E->Push(player->IsNeverVisible()); #else - Eluna::Push(L, player->IsNeverVisible(true)); + E->Push(player->IsNeverVisible(true)); #endif return 1; } - /*int CanFlyInZone(lua_State* L, Player* player) + /*int CanFlyInZone(Eluna* E, Player* player) { - uint32 mapid = Eluna::CHECKVAL(L, 2); - uint32 zone = Eluna::CHECKVAL(L, 2); + uint32 mapid = Eluna::CHECKVAL(E->L, 2); + uint32 zone = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->IsKnowHowFlyIn(mapid, zone)); + E->Push(player->IsKnowHowFlyIn(mapid, zone)); return 1; }*/ - int HasPendingBind(lua_State* L, Player* player) + int HasPendingBind(Eluna* E, Player* player) { - Eluna::Push(L, player->HasPendingBind()); + E->Push(player->HasPendingBind()); return 1; } - int IsARecruiter(lua_State* L, Player* player) + int IsARecruiter(Eluna* E, Player* player) { - Eluna::Push(L, player->GetSession()->IsARecruiter() || (player->GetSession()->GetRecruiterId() != 0)); + E->Push(player->GetSession()->IsARecruiter() || (player->GetSession()->GetRecruiterId() != 0)); return 1; } @@ -698,9 +698,9 @@ namespace LuaPlayer * * @return uint8 specCount */ - int GetSpecsCount(lua_State* L, Player* player) + int GetSpecsCount(Eluna* E, Player* player) { - Eluna::Push(L, player->GetSpecsCount()); + E->Push(player->GetSpecsCount()); return 1; } @@ -709,9 +709,9 @@ namespace LuaPlayer * * @return uint32 specId */ - int GetActiveSpec(lua_State* L, Player* player) + int GetActiveSpec(Eluna* E, Player* player) { - Eluna::Push(L, player->GetActiveSpec()); + E->Push(player->GetActiveSpec()); return 1; } @@ -721,9 +721,9 @@ namespace LuaPlayer * * @return uint32 phasemask */ - int GetPhaseMaskForSpawn(lua_State* L, Player* player) + int GetPhaseMaskForSpawn(Eluna* E, Player* player) { - Eluna::Push(L, player->GetPhaseMaskForSpawn()); + E->Push(player->GetPhaseMaskForSpawn()); return 1; } @@ -732,9 +732,9 @@ namespace LuaPlayer * * @return uint32 arenaPoints */ - int GetArenaPoints(lua_State* L, Player* player) + int GetArenaPoints(Eluna* E, Player* player) { - Eluna::Push(L, player->GetArenaPoints()); + E->Push(player->GetArenaPoints()); return 1; } @@ -743,9 +743,9 @@ namespace LuaPlayer * * @return uint32 honorPoints */ - int GetHonorPoints(lua_State* L, Player* player) + int GetHonorPoints(Eluna* E, Player* player) { - Eluna::Push(L, player->GetHonorPoints()); + E->Push(player->GetHonorPoints()); return 1; } @@ -754,9 +754,9 @@ namespace LuaPlayer * * @return uint32 blockValue */ - int GetShieldBlockValue(lua_State* L, Player* player) + int GetShieldBlockValue(Eluna* E, Player* player) { - Eluna::Push(L, player->GetShieldBlockValue()); + E->Push(player->GetShieldBlockValue()); return 1; } #endif @@ -767,14 +767,14 @@ namespace LuaPlayer * @param uint32 spellId * @return uint32 spellCooldownDelay */ - int GetSpellCooldownDelay(lua_State* L, Player* player) + int GetSpellCooldownDelay(Eluna* E, Player* player) { - uint32 spellId = Eluna::CHECKVAL(L, 2); + uint32 spellId = Eluna::CHECKVAL(E->L, 2); if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId)) - Eluna::Push(L, player->GetSpellHistory()->GetRemainingCooldown(spellInfo)); + E->Push(player->GetSpellHistory()->GetRemainingCooldown(spellInfo)); else - Eluna::Push(L, 0); + E->Push(0); return 1; } @@ -784,9 +784,9 @@ namespace LuaPlayer * * @return uint32 latency */ - int GetLatency(lua_State* L, Player* player) + int GetLatency(Eluna* E, Player* player) { - Eluna::Push(L, player->GetSession()->GetLatency()); + E->Push(player->GetSession()->GetLatency()); return 1; } @@ -795,9 +795,9 @@ namespace LuaPlayer * * @return uint32 championingFaction */ - int GetChampioningFaction(lua_State* L, Player* player) + int GetChampioningFaction(Eluna* E, Player* player) { - Eluna::Push(L, player->GetChampioningFaction()); + E->Push(player->GetChampioningFaction()); return 1; } @@ -806,9 +806,9 @@ namespace LuaPlayer * * @return uint8 subGroup */ - int GetOriginalSubGroup(lua_State* L, Player* player) + int GetOriginalSubGroup(Eluna* E, Player* player) { - Eluna::Push(L, player->GetOriginalSubGroup()); + E->Push(player->GetOriginalSubGroup()); return 1; } @@ -817,9 +817,9 @@ namespace LuaPlayer * * @return [Group] group */ - int GetOriginalGroup(lua_State* L, Player* player) + int GetOriginalGroup(Eluna* E, Player* player) { - Eluna::Push(L, player->GetOriginalGroup()); + E->Push(player->GetOriginalGroup()); return 1; } @@ -829,11 +829,11 @@ namespace LuaPlayer * @param float radius * @return [Player] player */ - int GetNextRandomRaidMember(lua_State* L, Player* player) + int GetNextRandomRaidMember(Eluna* E, Player* player) { - float radius = Eluna::CHECKVAL(L, 2); + float radius = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->GetNextRandomRaidMember(radius)); + E->Push(player->GetNextRandomRaidMember(radius)); return 1; } @@ -842,9 +842,9 @@ namespace LuaPlayer * * @return uint8 subGroup */ - int GetSubGroup(lua_State* L, Player* player) + int GetSubGroup(Eluna* E, Player* player) { - Eluna::Push(L, player->GetSubGroup()); + E->Push(player->GetSubGroup()); return 1; } @@ -853,9 +853,9 @@ namespace LuaPlayer * * @return [Group] group */ - int GetGroupInvite(lua_State* L, Player* player) + int GetGroupInvite(Eluna* E, Player* player) { - Eluna::Push(L, player->GetGroupInvite()); + E->Push(player->GetGroupInvite()); return 1; } @@ -865,11 +865,11 @@ namespace LuaPlayer * @param uint32 xp * @return uint32 xpBonus */ - int GetXPRestBonus(lua_State* L, Player* player) + int GetXPRestBonus(Eluna* E, Player* player) { - uint32 xp = Eluna::CHECKVAL(L, 2); + uint32 xp = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->GetXPRestBonus(xp)); + E->Push(player->GetXPRestBonus(xp)); return 1; } @@ -878,9 +878,9 @@ namespace LuaPlayer * * @return [BattleGroundTypeId] typeId */ - int GetBattlegroundTypeId(lua_State* L, Player* player) + int GetBattlegroundTypeId(Eluna* E, Player* player) { - Eluna::Push(L, player->GetBattlegroundTypeId()); + E->Push(player->GetBattlegroundTypeId()); return 1; } @@ -889,9 +889,9 @@ namespace LuaPlayer * * @return uint32 battleGroundId */ - int GetBattlegroundId(lua_State* L, Player* player) + int GetBattlegroundId(Eluna* E, Player* player) { - Eluna::Push(L, player->GetBattlegroundId()); + E->Push(player->GetBattlegroundId()); return 1; } @@ -901,11 +901,11 @@ namespace LuaPlayer * @param uint32 faction * @return [ReputationRank] rank */ - int GetReputationRank(lua_State* L, Player* player) + int GetReputationRank(Eluna* E, Player* player) { - uint32 faction = Eluna::CHECKVAL(L, 2); + uint32 faction = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->GetReputationRank(faction)); + E->Push(player->GetReputationRank(faction)); return 1; } @@ -914,9 +914,9 @@ namespace LuaPlayer * * @return uint16 drunkValue */ - int GetDrunkValue(lua_State* L, Player* player) + int GetDrunkValue(Eluna* E, Player* player) { - Eluna::Push(L, player->GetDrunkValue()); + E->Push(player->GetDrunkValue()); return 1; } @@ -926,11 +926,11 @@ namespace LuaPlayer * @param uint32 skill * @param int16 bonusVal */ - int GetSkillTempBonusValue(lua_State* L, Player* player) + int GetSkillTempBonusValue(Eluna* E, Player* player) { - uint32 skill = Eluna::CHECKVAL(L, 2); + uint32 skill = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->GetSkillTempBonusValue(skill)); + E->Push(player->GetSkillTempBonusValue(skill)); return 1; } @@ -940,11 +940,11 @@ namespace LuaPlayer * @param uint32 skill * @param int16 bonusVal */ - int GetSkillPermBonusValue(lua_State* L, Player* player) + int GetSkillPermBonusValue(Eluna* E, Player* player) { - uint32 skill = Eluna::CHECKVAL(L, 2); + uint32 skill = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->GetSkillPermBonusValue(skill)); + E->Push(player->GetSkillPermBonusValue(skill)); return 1; } @@ -954,11 +954,11 @@ namespace LuaPlayer * @param uint32 skill * @return uint16 pureVal */ - int GetPureSkillValue(lua_State* L, Player* player) + int GetPureSkillValue(Eluna* E, Player* player) { - uint32 skill = Eluna::CHECKVAL(L, 2); + uint32 skill = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->GetPureSkillValue(skill)); + E->Push(player->GetPureSkillValue(skill)); return 1; } @@ -968,11 +968,11 @@ namespace LuaPlayer * @param uint32 skill * @return uint16 baseVal */ - int GetBaseSkillValue(lua_State* L, Player* player) + int GetBaseSkillValue(Eluna* E, Player* player) { - uint32 skill = Eluna::CHECKVAL(L, 2); + uint32 skill = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->GetBaseSkillValue(skill)); + E->Push(player->GetBaseSkillValue(skill)); return 1; } @@ -982,11 +982,11 @@ namespace LuaPlayer * @param uint32 skill * @return uint16 val */ - int GetSkillValue(lua_State* L, Player* player) + int GetSkillValue(Eluna* E, Player* player) { - uint32 skill = Eluna::CHECKVAL(L, 2); + uint32 skill = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->GetSkillValue(skill)); + E->Push(player->GetSkillValue(skill)); return 1; } @@ -996,11 +996,11 @@ namespace LuaPlayer * @param uint32 skill * @return uint16 pureVal */ - int GetPureMaxSkillValue(lua_State* L, Player* player) + int GetPureMaxSkillValue(Eluna* E, Player* player) { - uint32 skill = Eluna::CHECKVAL(L, 2); + uint32 skill = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->GetPureMaxSkillValue(skill)); + E->Push(player->GetPureMaxSkillValue(skill)); return 1; } @@ -1010,11 +1010,11 @@ namespace LuaPlayer * @param uint32 skill * @return uint16 val */ - int GetMaxSkillValue(lua_State* L, Player* player) + int GetMaxSkillValue(Eluna* E, Player* player) { - uint32 skill = Eluna::CHECKVAL(L, 2); + uint32 skill = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->GetMaxSkillValue(skill)); + E->Push(player->GetMaxSkillValue(skill)); return 1; } @@ -1023,9 +1023,9 @@ namespace LuaPlayer * * @return float bonus */ - int GetManaBonusFromIntellect(lua_State* L, Player* player) + int GetManaBonusFromIntellect(Eluna* E, Player* player) { - Eluna::Push(L, player->GetManaBonusFromIntellect()); + E->Push(player->GetManaBonusFromIntellect()); return 1; } @@ -1034,9 +1034,9 @@ namespace LuaPlayer * * @return float bonus */ - int GetHealthBonusFromStamina(lua_State* L, Player* player) + int GetHealthBonusFromStamina(Eluna* E, Player* player) { - Eluna::Push(L, player->GetHealthBonusFromStamina()); + E->Push(player->GetHealthBonusFromStamina()); return 1; } @@ -1046,11 +1046,11 @@ namespace LuaPlayer * @param bool isRaid = true : argument is TrinityCore only * @return int32 difficulty */ - int GetDifficulty(lua_State* L, Player* player) + int GetDifficulty(Eluna* E, Player* player) { - bool isRaid = Eluna::CHECKVAL(L, 2, true); + bool isRaid = Eluna::CHECKVAL(E->L, 2, true); - Eluna::Push(L, player->GetDifficulty(isRaid)); + E->Push(player->GetDifficulty(isRaid)); return 1; } @@ -1059,12 +1059,12 @@ namespace LuaPlayer * * @return uint32 guildRank */ - int GetGuildRank(lua_State* L, Player* player) // TODO: Move to Guild Methods + int GetGuildRank(Eluna* E, Player* player) // TODO: Move to Guild Methods { #ifdef CATA - Eluna::Push(L, player->GetGuildRank()); + E->Push(player->GetGuildRank()); #else - Eluna::Push(L, player->GetRank()); + E->Push(player->GetRank()); #endif return 1; } @@ -1074,9 +1074,9 @@ namespace LuaPlayer * * @return uint32 freeTalentPointAmt */ - int GetFreeTalentPoints(lua_State* L, Player* player) + int GetFreeTalentPoints(Eluna* E, Player* player) { - Eluna::Push(L, player->GetFreeTalentPoints()); + E->Push(player->GetFreeTalentPoints()); return 1; } @@ -1085,11 +1085,11 @@ namespace LuaPlayer * * @return string guildName */ - int GetGuildName(lua_State* L, Player* player) + int GetGuildName(Eluna* E, Player* player) { if (!player->GetGuildId()) return 1; - Eluna::Push(L, eGuildMgr->GetGuildNameById(player->GetGuildId())); + E->Push(eGuildMgr->GetGuildNameById(player->GetGuildId())); return 1; } @@ -1099,11 +1099,11 @@ namespace LuaPlayer * @param uint32 faction * @return int32 reputationAmt */ - int GetReputation(lua_State* L, Player* player) + int GetReputation(Eluna* E, Player* player) { - uint32 faction = Eluna::CHECKVAL(L, 2); + uint32 faction = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->GetReputationMgr().GetReputation(faction)); + E->Push(player->GetReputationMgr().GetReputation(faction)); return 1; } @@ -1112,9 +1112,9 @@ namespace LuaPlayer * * @return [Unit] target */ - int GetComboTarget(lua_State* L, Player* player) + int GetComboTarget(Eluna* E, Player* player) { - Eluna::Push(L, player->GetComboTarget()); + E->Push(player->GetComboTarget()); return 1; } @@ -1123,9 +1123,9 @@ namespace LuaPlayer * * @return uint8 comboPoints */ - int GetComboPoints(lua_State* L, Player* player) + int GetComboPoints(Eluna* E, Player* player) { - Eluna::Push(L, player->GetComboPoints()); + E->Push(player->GetComboPoints()); return 1; } @@ -1134,9 +1134,9 @@ namespace LuaPlayer * * @return uint32 inGameTime */ - int GetInGameTime(lua_State* L, Player* player) + int GetInGameTime(Eluna* E, Player* player) { - Eluna::Push(L, player->GetInGameTime()); + E->Push(player->GetInGameTime()); return 1; } @@ -1146,11 +1146,11 @@ namespace LuaPlayer * @param uint32 questId * @return [QuestStatus] questStatus */ - int GetQuestStatus(lua_State* L, Player* player) + int GetQuestStatus(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->GetQuestStatus(entry)); + E->Push(player->GetQuestStatus(entry)); return 1; } @@ -1160,11 +1160,11 @@ namespace LuaPlayer * @param uint32 questId * @return bool questRewardStatus */ - int GetQuestRewardStatus(lua_State* L, Player* player) + int GetQuestRewardStatus(Eluna* E, Player* player) { - uint32 questId = Eluna::CHECKVAL(L, 2); + uint32 questId = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->GetQuestRewardStatus(questId)); + E->Push(player->GetQuestRewardStatus(questId)); return 1; } @@ -1175,12 +1175,12 @@ namespace LuaPlayer * @param int32 entry : entry of required [Creature] * @return uint16 count */ - int GetReqKillOrCastCurrentCount(lua_State* L, Player* player) + int GetReqKillOrCastCurrentCount(Eluna* E, Player* player) { - uint32 questId = Eluna::CHECKVAL(L, 2); - int32 entry = Eluna::CHECKVAL(L, 3); + uint32 questId = Eluna::CHECKVAL(E->L, 2); + int32 entry = Eluna::CHECKVAL(E->L, 3); - Eluna::Push(L, player->GetReqKillOrCastCurrentCount(questId, entry)); + E->Push(player->GetReqKillOrCastCurrentCount(questId, entry)); return 1; } @@ -1190,11 +1190,11 @@ namespace LuaPlayer * @param uint32 questId * @return [QuestStatus] questRewardStatus */ - int GetQuestLevel(lua_State* L, Player* player) + int GetQuestLevel(Eluna* E, Player* player) { - Quest* quest = Eluna::CHECKOBJ(L, 2); + Quest* quest = Eluna::CHECKOBJ(E->L, 2); - Eluna::Push(L, player->GetQuestLevel(quest)); + E->Push(player->GetQuestLevel(quest)); return 1; } @@ -1204,14 +1204,14 @@ namespace LuaPlayer * @param uint8 slot * @return [Item] item */ - int GetEquippedItemBySlot(lua_State* L, Player* player) + int GetEquippedItemBySlot(Eluna* E, Player* player) { - uint8 slot = Eluna::CHECKVAL(L, 2); + uint8 slot = Eluna::CHECKVAL(E->L, 2); if (slot >= EQUIPMENT_SLOT_END) return 1; Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); - Eluna::Push(L, item); + E->Push(item); return 1; } @@ -1220,9 +1220,9 @@ namespace LuaPlayer * * @return float restBonus */ - int GetRestBonus(lua_State* L, Player* player) + int GetRestBonus(Eluna* E, Player* player) { - Eluna::Push(L, player->GetRestBonus()); + E->Push(player->GetRestBonus()); return 1; } @@ -1231,9 +1231,9 @@ namespace LuaPlayer * * @return uint8 tag */ - int GetChatTag(lua_State* L, Player* player) + int GetChatTag(Eluna* E, Player* player) { - Eluna::Push(L, player->GetChatTag()); + E->Push(player->GetChatTag()); return 1; } @@ -1262,12 +1262,12 @@ namespace LuaPlayer * @param uint8 slot : the slot the [Item] is in within the bag, you can get this with [Item:GetSlot] * @return [Item] item : [Item] or nil */ - int GetItemByPos(lua_State* L, Player* player) + int GetItemByPos(Eluna* E, Player* player) { - uint8 bag = Eluna::CHECKVAL(L, 2); - uint8 slot = Eluna::CHECKVAL(L, 3); + uint8 bag = Eluna::CHECKVAL(E->L, 2); + uint8 slot = Eluna::CHECKVAL(E->L, 3); - Eluna::Push(L, player->GetItemByPos(bag, slot)); + E->Push(player->GetItemByPos(bag, slot)); return 1; } @@ -1279,11 +1279,11 @@ namespace LuaPlayer * @param ObjectGuid guid : an item guid * @return [Item] item */ - int GetItemByGUID(lua_State* L, Player* player) + int GetItemByGUID(Eluna* E, Player* player) { - ObjectGuid guid = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->GetItemByGuid(guid)); + E->Push(player->GetItemByGuid(guid)); return 1; } @@ -1293,11 +1293,11 @@ namespace LuaPlayer * @param ObjectGuid guid : an item guid * @return [Item] item */ - int GetMailItem(lua_State* L, Player* player) + int GetMailItem(Eluna* E, Player* player) { - ObjectGuid guid = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->GetMItem(guid.GetCounter())); + E->Push(player->GetMItem(guid.GetCounter())); return 1; } @@ -1309,11 +1309,11 @@ namespace LuaPlayer * @param uint32 entryId * @return [Item] item */ - int GetItemByEntry(lua_State* L, Player* player) + int GetItemByEntry(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, player->GetItemByEntry(entry)); + E->Push(player->GetItemByEntry(entry)); return 1; } @@ -1323,10 +1323,10 @@ namespace LuaPlayer * @param [WorldObject] object * @return uint32 textId : key to npc_text database table */ - int GetGossipTextId(lua_State* L, Player* player) + int GetGossipTextId(Eluna* E, Player* player) { - WorldObject* obj = Eluna::CHECKOBJ(L, 2); - Eluna::Push(L, player->GetGossipTextId(obj)); + WorldObject* obj = Eluna::CHECKOBJ(E->L, 2); + E->Push(player->GetGossipTextId(obj)); return 1; } @@ -1335,9 +1335,9 @@ namespace LuaPlayer * * @return [Unit] unit */ - int GetSelection(lua_State* L, Player* player) + int GetSelection(Eluna* E, Player* player) { - Eluna::Push(L, player->GetSelectedUnit()); + E->Push(player->GetSelectedUnit()); return 1; } @@ -1346,9 +1346,9 @@ namespace LuaPlayer * * @return [AccountTypes] gmRank */ - int GetGMRank(lua_State* L, Player* player) + int GetGMRank(Eluna* E, Player* player) { - Eluna::Push(L, player->GetSession()->GetSecurity()); + E->Push(player->GetSession()->GetSecurity()); return 1; } @@ -1357,9 +1357,9 @@ namespace LuaPlayer * * @return uint32 coinage */ - int GetCoinage(lua_State* L, Player* player) + int GetCoinage(Eluna* E, Player* player) { - Eluna::Push(L, player->GetMoney()); + E->Push(player->GetMoney()); return 1; } @@ -1368,9 +1368,9 @@ namespace LuaPlayer * * @return uint32 guildId */ - int GetGuildId(lua_State* L, Player* player) + int GetGuildId(Eluna* E, Player* player) { - Eluna::Push(L, player->GetGuildId()); + E->Push(player->GetGuildId()); return 1; } @@ -1379,9 +1379,9 @@ namespace LuaPlayer * * @return [TeamId] teamId */ - int GetTeam(lua_State* L, Player* player) + int GetTeam(Eluna* E, Player* player) { - Eluna::Push(L, player->GetTeamId()); + E->Push(player->GetTeamId()); return 1; } @@ -1392,11 +1392,11 @@ namespace LuaPlayer * @param bool checkinBank = false : also counts the items in player's bank if true * @return uint32 itemamount */ - int GetItemCount(lua_State* L, Player* player) + int GetItemCount(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); - bool checkinBank = Eluna::CHECKVAL(L, 3, false); - Eluna::Push(L, player->GetItemCount(entry, checkinBank)); + uint32 entry = Eluna::CHECKVAL(E->L, 2); + bool checkinBank = Eluna::CHECKVAL(E->L, 3, false); + E->Push(player->GetItemCount(entry, checkinBank)); return 1; } @@ -1405,9 +1405,9 @@ namespace LuaPlayer * * @return uint32 lifeTimeKils */ - int GetLifetimeKills(lua_State* L, Player* player) + int GetLifetimeKills(Eluna* E, Player* player) { - Eluna::Push(L, player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS)); + E->Push(player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS)); return 1; } @@ -1416,9 +1416,9 @@ namespace LuaPlayer * * @return string ip */ - int GetPlayerIP(lua_State* L, Player* player) + int GetPlayerIP(Eluna* E, Player* player) { - Eluna::Push(L, player->GetSession()->GetRemoteAddress()); + E->Push(player->GetSession()->GetRemoteAddress()); return 1; } @@ -1427,9 +1427,9 @@ namespace LuaPlayer * * @return uint32 currLevelPlayTime */ - int GetLevelPlayedTime(lua_State* L, Player* player) + int GetLevelPlayedTime(Eluna* E, Player* player) { - Eluna::Push(L, player->GetLevelPlayedTime()); + E->Push(player->GetLevelPlayedTime()); return 1; } @@ -1438,9 +1438,9 @@ namespace LuaPlayer * * @return uint32 totalPlayTime */ - int GetTotalPlayedTime(lua_State* L, Player* player) + int GetTotalPlayedTime(Eluna* E, Player* player) { - Eluna::Push(L, player->GetTotalPlayedTime()); + E->Push(player->GetTotalPlayedTime()); return 1; } @@ -1449,9 +1449,9 @@ namespace LuaPlayer * * @return [Guild] guild */ - int GetGuild(lua_State* L, Player* player) + int GetGuild(Eluna* E, Player* player) { - Eluna::Push(L, eGuildMgr->GetGuildById(player->GetGuildId())); + E->Push(eGuildMgr->GetGuildById(player->GetGuildId())); return 1; } @@ -1460,9 +1460,9 @@ namespace LuaPlayer * * @return [Group] group */ - int GetGroup(lua_State* L, Player* player) + int GetGroup(Eluna* E, Player* player) { - Eluna::Push(L, player->GetGroup()); + E->Push(player->GetGroup()); return 1; } @@ -1471,9 +1471,9 @@ namespace LuaPlayer * * @return uint32 accountId */ - int GetAccountId(lua_State* L, Player* player) + int GetAccountId(Eluna* E, Player* player) { - Eluna::Push(L, player->GetSession()->GetAccountId()); + E->Push(player->GetSession()->GetAccountId()); return 1; } @@ -1482,11 +1482,11 @@ namespace LuaPlayer * * @return string accountName */ - int GetAccountName(lua_State* L, Player* player) + int GetAccountName(Eluna* E, Player* player) { std::string accName; if (eAccountMgr->GetName(player->GetSession()->GetAccountId(), accName)) - Eluna::Push(L, accName); + E->Push(accName); return 1; } @@ -1496,9 +1496,9 @@ namespace LuaPlayer * * @return [Corpse] corpse */ - int GetCorpse(lua_State* L, Player* player) + int GetCorpse(Eluna* E, Player* player) { - Eluna::Push(L, player->GetCorpse()); + E->Push(player->GetCorpse()); return 1; } @@ -1507,9 +1507,9 @@ namespace LuaPlayer * * @return int localeIndex */ - int GetDbLocaleIndex(lua_State* L, Player* player) + int GetDbLocaleIndex(Eluna* E, Player* player) { - Eluna::Push(L, player->GetSession()->GetSessionDbLocaleIndex()); + E->Push(player->GetSession()->GetSessionDbLocaleIndex()); return 1; } @@ -1518,33 +1518,33 @@ namespace LuaPlayer * * @return [LocaleConstant] locale */ - int GetDbcLocale(lua_State* L, Player* player) + int GetDbcLocale(Eluna* E, Player* player) { - Eluna::Push(L, player->GetSession()->GetSessionDbcLocale()); + E->Push(player->GetSession()->GetSessionDbcLocale()); return 1; } - int GetRecruiterId(lua_State* L, Player* player) + int GetRecruiterId(Eluna* E, Player* player) { - Eluna::Push(L, player->GetSession()->GetRecruiterId()); + E->Push(player->GetSession()->GetRecruiterId()); return 1; } - int GetSelectedPlayer(lua_State* L, Player* player) + int GetSelectedPlayer(Eluna* E, Player* player) { - Eluna::Push(L, player->GetSelectedPlayer()); + E->Push(player->GetSelectedPlayer()); return 1; } - int GetSelectedUnit(lua_State* L, Player* player) + int GetSelectedUnit(Eluna* E, Player* player) { - Eluna::Push(L, player->GetSelectedUnit()); + E->Push(player->GetSelectedUnit()); return 1; } - int GetNearbyGameObject(lua_State* L, Player* player) + int GetNearbyGameObject(Eluna* E, Player* player) { - Eluna::Push(L, ChatHandler(player->GetSession()).GetNearbyGameObject()); + E->Push(ChatHandler(player->GetSession()).GetNearbyGameObject()); return 1; } @@ -1554,9 +1554,9 @@ namespace LuaPlayer * * @return uint32 count */ - int GetMailCount(lua_State* L, Player* player) + int GetMailCount(Eluna* E, Player* player) { - Eluna::Push(L, player->GetMailSize()); + E->Push(player->GetMailSize()); return 1; } @@ -1565,9 +1565,9 @@ namespace LuaPlayer * * @return uint32 xp */ - int GetXP(lua_State* L, Player* player) + int GetXP(Eluna* E, Player* player) { - Eluna::Push(L, player->GetXP()); + E->Push(player->GetXP()); return 1; } @@ -1576,9 +1576,9 @@ namespace LuaPlayer * * @return uint32 xp */ - int GetXPForNextLevel(lua_State* L, Player* player) + int GetXPForNextLevel(Eluna* E, Player* player) { - Eluna::Push(L, player->GetXPForNextLevel()); + E->Push(player->GetXPForNextLevel()); return 1; } #endif @@ -1588,9 +1588,9 @@ namespace LuaPlayer * * @param bool apply = true : lock if true and unlock if false */ - int SetPlayerLock(lua_State* L, Player* player) + int SetPlayerLock(Eluna* E, Player* player) { - bool apply = Eluna::CHECKVAL(L, 2, true); + bool apply = Eluna::CHECKVAL(E->L, 2, true); if (apply) { @@ -1610,9 +1610,9 @@ namespace LuaPlayer * * @param uint32 flag */ - int SetAtLoginFlag(lua_State* L, Player* player) + int SetAtLoginFlag(Eluna* E, Player* player) { - uint32 flag = Eluna::CHECKVAL(L, 2); + uint32 flag = Eluna::CHECKVAL(E->L, 2); player->SetAtLoginFlag((AtLoginFlags)flag); return 0; @@ -1623,9 +1623,9 @@ namespace LuaPlayer * * @param uint32 sheatheState */ - int SetSheath(lua_State* L, Player* player) + int SetSheath(Eluna* E, Player* player) { - uint32 sheathed = Eluna::CHECKVAL(L, 2); + uint32 sheathed = Eluna::CHECKVAL(E->L, 2); if (sheathed >= MAX_SHEATH_STATE) return 0; @@ -1638,9 +1638,9 @@ namespace LuaPlayer * * @param uint8 drunkValue */ - int SetDrunkValue(lua_State* L, Player* player) + int SetDrunkValue(Eluna* E, Player* player) { - uint8 newDrunkValue = Eluna::CHECKVAL(L, 2); + uint8 newDrunkValue = Eluna::CHECKVAL(E->L, 2); player->SetDrunkValue(newDrunkValue); return 0; @@ -1651,9 +1651,9 @@ namespace LuaPlayer * * @param uint8 raceId */ - int SetFactionForRace(lua_State* L, Player* player) + int SetFactionForRace(Eluna* E, Player* player) { - uint8 race = Eluna::CHECKVAL(L, 2); + uint8 race = Eluna::CHECKVAL(E->L, 2); player->SetFactionForRace(race); return 0; @@ -1667,12 +1667,12 @@ namespace LuaPlayer * @param uint16 currVal * @param uint16 maxVal */ - int SetSkill(lua_State* L, Player* player) + int SetSkill(Eluna* E, Player* player) { - uint16 id = Eluna::CHECKVAL(L, 2); - uint16 step = Eluna::CHECKVAL(L, 3); - uint16 currVal = Eluna::CHECKVAL(L, 4); - uint16 maxVal = Eluna::CHECKVAL(L, 5); + uint16 id = Eluna::CHECKVAL(E->L, 2); + uint16 step = Eluna::CHECKVAL(E->L, 3); + uint16 currVal = Eluna::CHECKVAL(E->L, 4); + uint16 maxVal = Eluna::CHECKVAL(E->L, 5); player->SetSkill(id, step, currVal, maxVal); return 0; @@ -1683,9 +1683,9 @@ namespace LuaPlayer * * @param uint8 rank */ - int SetGuildRank(lua_State* L, Player* player) // TODO: Move to Guild Methods + int SetGuildRank(Eluna* E, Player* player) // TODO: Move to Guild Methods { - uint8 rank = Eluna::CHECKVAL(L, 2); + uint8 rank = Eluna::CHECKVAL(E->L, 2); if (!player->GetGuildId()) return 0; @@ -1703,9 +1703,9 @@ namespace LuaPlayer * * @param uint32 talentPointAmt */ - int SetFreeTalentPoints(lua_State* L, Player* player) + int SetFreeTalentPoints(Eluna* E, Player* player) { - uint32 points = Eluna::CHECKVAL(L, 2); + uint32 points = Eluna::CHECKVAL(E->L, 2); player->SetFreeTalentPoints(points); player->SendTalentsInfoData(false); @@ -1718,10 +1718,10 @@ namespace LuaPlayer * @param uint32 factionId * @param int32 reputationValue */ - int SetReputation(lua_State* L, Player* player) + int SetReputation(Eluna* E, Player* player) { - uint32 faction = Eluna::CHECKVAL(L, 2); - int32 value = Eluna::CHECKVAL(L, 3); + uint32 faction = Eluna::CHECKVAL(E->L, 2); + int32 value = Eluna::CHECKVAL(E->L, 3); FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction); player->GetReputationMgr().SetReputation(factionEntry, value); @@ -1734,10 +1734,10 @@ namespace LuaPlayer * @param uint32 entry : entry of a quest * @param uint32 status */ - int SetQuestStatus(lua_State* L, Player* player) + int SetQuestStatus(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); - uint32 status = Eluna::CHECKVAL(L, 3); + uint32 entry = Eluna::CHECKVAL(E->L, 2); + uint32 status = Eluna::CHECKVAL(E->L, 3); if (status >= MAX_QUEST_STATUS) return 0; @@ -1750,9 +1750,9 @@ namespace LuaPlayer * * @param float restBonus */ - int SetRestBonus(lua_State* L, Player* player) + int SetRestBonus(Eluna* E, Player* player) { - float bonus = Eluna::CHECKVAL(L, 2); + float bonus = Eluna::CHECKVAL(E->L, 2); player->SetRestBonus(bonus); return 0; @@ -1763,9 +1763,9 @@ namespace LuaPlayer * * @param bool acceptWhispers = true */ - int SetAcceptWhispers(lua_State* L, Player* player) + int SetAcceptWhispers(Eluna* E, Player* player) { - bool on = Eluna::CHECKVAL(L, 2, true); + bool on = Eluna::CHECKVAL(E->L, 2, true); player->SetAcceptWhispers(on); return 0; @@ -1776,9 +1776,9 @@ namespace LuaPlayer * * @param bool on = true */ - int SetPvPDeath(lua_State* L, Player* player) + int SetPvPDeath(Eluna* E, Player* player) { - bool on = Eluna::CHECKVAL(L, 2, true); + bool on = Eluna::CHECKVAL(E->L, 2, true); player->SetPvPDeath(on); return 0; @@ -1789,9 +1789,9 @@ namespace LuaPlayer * * @param bool gmVisible = true */ - int SetGMVisible(lua_State* L, Player* player) + int SetGMVisible(Eluna* E, Player* player) { - bool on = Eluna::CHECKVAL(L, 2, true); + bool on = Eluna::CHECKVAL(E->L, 2, true); player->SetGMVisible(on); return 0; @@ -1802,9 +1802,9 @@ namespace LuaPlayer * * @param bool taxiCheat = true */ - int SetTaxiCheat(lua_State* L, Player* player) + int SetTaxiCheat(Eluna* E, Player* player) { - bool on = Eluna::CHECKVAL(L, 2, true); + bool on = Eluna::CHECKVAL(E->L, 2, true); player->SetTaxiCheater(on); return 0; @@ -1815,9 +1815,9 @@ namespace LuaPlayer * * @param bool on = true */ - int SetGMChat(lua_State* L, Player* player) + int SetGMChat(Eluna* E, Player* player) { - bool on = Eluna::CHECKVAL(L, 2, true); + bool on = Eluna::CHECKVAL(E->L, 2, true); player->SetGMChat(on); return 0; @@ -1828,9 +1828,9 @@ namespace LuaPlayer * * @param bool setGmMode = true */ - int SetGameMaster(lua_State* L, Player* player) + int SetGameMaster(Eluna* E, Player* player) { - bool on = Eluna::CHECKVAL(L, 2, true); + bool on = Eluna::CHECKVAL(E->L, 2, true); player->SetGameMaster(on); return 0; @@ -1844,9 +1844,9 @@ namespace LuaPlayer * * @param [Gender] gender */ - int SetGender(lua_State* L, Player* player) + int SetGender(Eluna* E, Player* player) { - uint32 _gender = Eluna::CHECKVAL(L, 2); + uint32 _gender = Eluna::CHECKVAL(E->L, 2); Gender gender; switch (_gender) @@ -1858,7 +1858,7 @@ namespace LuaPlayer gender = GENDER_FEMALE; break; default: - return luaL_argerror(L, 2, "valid Gender expected"); + return luaL_argerror(E->L, 2, "valid Gender expected"); } player->SetByteValue(UNIT_FIELD_BYTES_0, 2, gender); @@ -1873,9 +1873,9 @@ namespace LuaPlayer * * @param uint32 arenaPoints */ - int SetArenaPoints(lua_State* L, Player* player) + int SetArenaPoints(Eluna* E, Player* player) { - uint32 arenaP = Eluna::CHECKVAL(L, 2); + uint32 arenaP = Eluna::CHECKVAL(E->L, 2); player->SetArenaPoints(arenaP); return 0; } @@ -1885,9 +1885,9 @@ namespace LuaPlayer * * @param uint32 honorPoints */ - int SetHonorPoints(lua_State* L, Player* player) + int SetHonorPoints(Eluna* E, Player* player) { - uint32 honorP = Eluna::CHECKVAL(L, 2); + uint32 honorP = Eluna::CHECKVAL(E->L, 2); player->SetHonorPoints(honorP); return 0; } @@ -1898,9 +1898,9 @@ namespace LuaPlayer * * @param uint32 honorableKills */ - int SetLifetimeKills(lua_State* L, Player* player) + int SetLifetimeKills(Eluna* E, Player* player) { - uint32 val = Eluna::CHECKVAL(L, 2); + uint32 val = Eluna::CHECKVAL(E->L, 2); player->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, val); return 0; } @@ -1910,9 +1910,9 @@ namespace LuaPlayer * * @param uint32 copperAmt */ - int SetCoinage(lua_State* L, Player* player) + int SetCoinage(Eluna* E, Player* player) { - uint32 amt = Eluna::CHECKVAL(L, 2); + uint32 amt = Eluna::CHECKVAL(E->L, 2); player->SetMoney(amt); return 0; } @@ -1926,13 +1926,13 @@ namespace LuaPlayer * @param uint32 mapId : Map ID * @param uint32 areaId : Area ID */ - int SetBindPoint(lua_State* L, Player* player) + int SetBindPoint(Eluna* E, Player* player) { - float x = Eluna::CHECKVAL(L, 2); - float y = Eluna::CHECKVAL(L, 3); - float z = Eluna::CHECKVAL(L, 4); - uint32 mapId = Eluna::CHECKVAL(L, 5); - uint32 areaId = Eluna::CHECKVAL(L, 6); + float x = Eluna::CHECKVAL(E->L, 2); + float y = Eluna::CHECKVAL(E->L, 3); + float z = Eluna::CHECKVAL(E->L, 4); + uint32 mapId = Eluna::CHECKVAL(E->L, 5); + uint32 areaId = Eluna::CHECKVAL(E->L, 6); WorldLocation loc(mapId, x, y, z); @@ -1946,9 +1946,9 @@ namespace LuaPlayer * * @param uint32 titleId */ - int SetKnownTitle(lua_State* L, Player* player) + int SetKnownTitle(Eluna* E, Player* player) { - uint32 id = Eluna::CHECKVAL(L, 2); + uint32 id = Eluna::CHECKVAL(E->L, 2); CharTitlesEntry const* t = sCharTitlesStore.LookupEntry(id); if (t) player->SetTitle(t, false); @@ -1960,9 +1960,9 @@ namespace LuaPlayer * * @param uint32 achievementid */ - int SetAchievement(lua_State* L, Player* player) + int SetAchievement(Eluna* E, Player* player) { - uint32 id = Eluna::CHECKVAL(L, 2); + uint32 id = Eluna::CHECKVAL(E->L, 2); AchievementEntry const* t = sAchievementStore.LookupEntry(id); if (t) player->CompletedAchievement(t); @@ -1974,9 +1974,9 @@ namespace LuaPlayer * * @param bool applyFFA = true */ - int SetFFA(lua_State* L, Player* player) + int SetFFA(Eluna* E, Player* player) { - bool apply = Eluna::CHECKVAL(L, 2, true); + bool apply = Eluna::CHECKVAL(E->L, 2, true); if(apply) #ifdef CATA @@ -1993,9 +1993,9 @@ namespace LuaPlayer #ifndef CATA - int SetMovement(lua_State* L, Player* player) + int SetMovement(Eluna* E, Player* player) { - int32 pType = Eluna::CHECKVAL(L, 2); + int32 pType = Eluna::CHECKVAL(E->L, 2); player->SetMovement((PlayerMovementType)pType); return 0; @@ -2005,7 +2005,7 @@ namespace LuaPlayer /** * Resets the [Player]s pets talent points */ - int ResetPetTalents(lua_State* /*L*/, Player* player) + int ResetPetTalents(Eluna* /*E*/, Player* player) { player->ResetPetTalents(); player->SendTalentsInfoData(true); @@ -2015,7 +2015,7 @@ namespace LuaPlayer /** * Reset the [Player]s completed achievements */ - int ResetAchievements(lua_State* /*L*/, Player* player) + int ResetAchievements(Eluna* /*E*/, Player* player) { player->ResetAchievements(); return 0; @@ -2026,9 +2026,9 @@ namespace LuaPlayer * * @param ObjectGuid guid = playerguid : guid of the mailbox window sender */ - int SendShowMailBox(lua_State* L, Player* player) + int SendShowMailBox(Eluna* E, Player* player) { - ObjectGuid guid = Eluna::CHECKVAL(L, 2, player->GET_GUID()); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 2, player->GET_GUID()); player->GetSession()->SendShowMailBox(guid); return 0; @@ -2040,9 +2040,9 @@ namespace LuaPlayer * * @param int32 amount */ - int ModifyArenaPoints(lua_State* L, Player* player) + int ModifyArenaPoints(Eluna* E, Player* player) { - int32 amount = Eluna::CHECKVAL(L, 2); + int32 amount = Eluna::CHECKVAL(E->L, 2); player->ModifyArenaPoints(amount); return 0; @@ -2053,9 +2053,9 @@ namespace LuaPlayer * * @param int32 amount */ - int ModifyHonorPoints(lua_State* L, Player* player) + int ModifyHonorPoints(Eluna* E, Player* player) { - int32 amount = Eluna::CHECKVAL(L, 2); + int32 amount = Eluna::CHECKVAL(E->L, 2); player->ModifyHonorPoints(amount); return 0; @@ -2065,7 +2065,7 @@ namespace LuaPlayer /** * Saves the [Player] to the database */ - int SaveToDB(lua_State* /*L*/, Player* player) + int SaveToDB(Eluna* /*E*/, Player* player) { player->SaveToDB(); return 0; @@ -2076,9 +2076,9 @@ namespace LuaPlayer * * @param [Unit] summoner */ - int SummonPlayer(lua_State* L, Player* player) + int SummonPlayer(Eluna* E, Player* player) { - Unit* summoner = Eluna::CHECKOBJ(L, 2); + Unit* summoner = Eluna::CHECKOBJ(E->L, 2); player->SendSummonRequestFrom(summoner); return 0; @@ -2089,9 +2089,9 @@ namespace LuaPlayer * * @param uint32 muteTime */ - int Mute(lua_State* L, Player* player) + int Mute(Eluna* E, Player* player) { - uint32 muteseconds = Eluna::CHECKVAL(L, 2); + uint32 muteseconds = Eluna::CHECKVAL(E->L, 2); /*const char* reason = luaL_checkstring(E, 2);*/ // Mangos does not have a reason field in database. time_t muteTime = time(NULL) + muteseconds; @@ -2111,9 +2111,9 @@ namespace LuaPlayer * * @param uint32 entry : quest entry */ - int RewardQuest(lua_State* L, Player* player) + int RewardQuest(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); Quest const* quest = eObjectMgr->GetQuestTemplate(entry); @@ -2130,9 +2130,9 @@ namespace LuaPlayer * * @param [Unit] sender */ - int SendAuctionMenu(lua_State* L, Player* player) + int SendAuctionMenu(Eluna* E, Player* player) { - Unit* unit = Eluna::CHECKOBJ(L, 2); + Unit* unit = Eluna::CHECKOBJ(E->L, 2); AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->GetFaction()); if (!ahEntry) @@ -2152,9 +2152,9 @@ namespace LuaPlayer * * @param [Creature] sender */ - int SendTaxiMenu(lua_State* L, Player* player) + int SendTaxiMenu(Eluna* E, Player* player) { - Creature* creature = Eluna::CHECKOBJ(L, 2); + Creature* creature = Eluna::CHECKOBJ(E->L, 2); player->GetSession()->SendTaxiMenu(creature); return 0; @@ -2163,7 +2163,7 @@ namespace LuaPlayer /** * Sends a spirit resurrection request to the [Player] */ - int SendSpiritResurrect(lua_State* /*L*/, Player* player) + int SendSpiritResurrect(Eluna* /*E*/, Player* player) { player->GetSession()->SendSpiritResurrect(); return 0; @@ -2174,9 +2174,9 @@ namespace LuaPlayer * * @param [WorldObject] sender */ - int SendTabardVendorActivate(lua_State* L, Player* player) + int SendTabardVendorActivate(Eluna* E, Player* player) { - WorldObject* obj = Eluna::CHECKOBJ(L, 2); + WorldObject* obj = Eluna::CHECKOBJ(E->L, 2); player->GetSession()->SendTabardVendorActivate(obj->GET_GUID()); return 0; @@ -2187,9 +2187,9 @@ namespace LuaPlayer * * @param [WorldObject] sender */ - int SendShowBank(lua_State* L, Player* player) + int SendShowBank(Eluna* E, Player* player) { - WorldObject* obj = Eluna::CHECKOBJ(L, 2); + WorldObject* obj = Eluna::CHECKOBJ(E->L, 2); player->GetSession()->SendShowBank(obj->GET_GUID()); return 0; @@ -2200,9 +2200,9 @@ namespace LuaPlayer * * @param [WorldObject] sender */ - int SendListInventory(lua_State* L, Player* player) + int SendListInventory(Eluna* E, Player* player) { - WorldObject* obj = Eluna::CHECKOBJ(L, 2); + WorldObject* obj = Eluna::CHECKOBJ(E->L, 2); player->GetSession()->SendListInventory(obj->GET_GUID()); return 0; @@ -2213,9 +2213,9 @@ namespace LuaPlayer * * @param [Creature] sender */ - int SendTrainerList(lua_State* L, Player* player) + int SendTrainerList(Eluna* E, Player* player) { - Creature* obj = Eluna::CHECKOBJ(L, 2); + Creature* obj = Eluna::CHECKOBJ(E->L, 2); #ifdef CATA player->GetSession()->SendTrainerList(obj, NULL); @@ -2230,9 +2230,9 @@ namespace LuaPlayer * * @param [Player] invitee */ - int SendGuildInvite(lua_State* L, Player* player) + int SendGuildInvite(Eluna* E, Player* player) { - Player* plr = Eluna::CHECKOBJ(L, 2); + Player* plr = Eluna::CHECKOBJ(E->L, 2); if (Guild* guild = player->GetGuild()) guild->HandleInviteMember(player->GetSession(), plr->GetName()); @@ -2246,10 +2246,10 @@ namespace LuaPlayer * @param uint32 field * @param uint32 value */ - int SendUpdateWorldState(lua_State* L, Player* player) + int SendUpdateWorldState(Eluna* E, Player* player) { - uint32 field = Eluna::CHECKVAL(L, 2); - uint32 value = Eluna::CHECKVAL(L, 3); + uint32 field = Eluna::CHECKVAL(E->L, 2); + uint32 value = Eluna::CHECKVAL(E->L, 3); player->SendUpdateWorldState(field, value); return 0; @@ -2260,9 +2260,9 @@ namespace LuaPlayer * * @param bool saveToDb = true */ - int LogoutPlayer(lua_State* L, Player* player) + int LogoutPlayer(Eluna* E, Player* player) { - bool save = Eluna::CHECKVAL(L, 2, true); + bool save = Eluna::CHECKVAL(E->L, 2, true); player->GetSession()->LogoutPlayer(save); return 0; @@ -2271,7 +2271,7 @@ namespace LuaPlayer /** * Forcefully removes the [Player] from a [BattleGround] raid group */ - int RemoveFromBattlegroundRaid(lua_State* /*L*/, Player* player) + int RemoveFromBattlegroundRaid(Eluna* /*E*/, Player* player) { player->RemoveFromBattlegroundOrBattlefieldRaid(); return 0; @@ -2285,10 +2285,10 @@ namespace LuaPlayer * @param uint32 map = true * @param uint32 difficulty = 0 */ - int UnbindInstance(lua_State* L, Player* player) + int UnbindInstance(Eluna* E, Player* player) { - uint32 map = Eluna::CHECKVAL(L, 2); - uint32 difficulty = Eluna::CHECKVAL(L, 3, 0); + uint32 map = Eluna::CHECKVAL(E->L, 2); + uint32 difficulty = Eluna::CHECKVAL(E->L, 3, 0); if (difficulty < MAX_DIFFICULTY) player->UnbindInstance(map, (Difficulty)difficulty); @@ -2299,7 +2299,7 @@ namespace LuaPlayer /** * Unbinds the [Player] from his instances except the one he currently is in. */ - int UnbindAllInstances(lua_State* /*L*/, Player* player) + int UnbindAllInstances(Eluna* /*E*/, Player* player) { for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { @@ -2320,10 +2320,9 @@ namespace LuaPlayer * * @param bool teleToEntry = true */ - int LeaveBattleground(lua_State* L, Player* player) + int LeaveBattleground(Eluna* E, Player* player) { - (void)L; // ensure that the variable is referenced in order to pass compiler checks - bool teleToEntryPoint = Eluna::CHECKVAL(L, 2, true); + bool teleToEntryPoint = Eluna::CHECKVAL(E->L, 2, true); player->LeaveBattleground(teleToEntryPoint); return 0; @@ -2336,11 +2335,11 @@ namespace LuaPlayer * @param bool cost = true * @param float discountMod = 1.0 */ - int DurabilityRepair(lua_State* L, Player* player) + int DurabilityRepair(Eluna* E, Player* player) { - uint16 position = Eluna::CHECKVAL(L, 2); - bool takeCost = Eluna::CHECKVAL(L, 3, true); - float discountMod = Eluna::CHECKVAL(L, 4, 1.0f); + uint16 position = Eluna::CHECKVAL(E->L, 2); + bool takeCost = Eluna::CHECKVAL(E->L, 3, true); + float discountMod = Eluna::CHECKVAL(E->L, 4, 1.0f); player->DurabilityRepair(position, takeCost, discountMod); return 0; @@ -2353,11 +2352,11 @@ namespace LuaPlayer * @param float discountMod = 1.0 * @param bool guidBank = false */ - int DurabilityRepairAll(lua_State* L, Player* player) + int DurabilityRepairAll(Eluna* E, Player* player) { - bool takeCost = Eluna::CHECKVAL(L, 2, true); - float discountMod = Eluna::CHECKVAL(L, 3, 1.0f); - bool guildBank = Eluna::CHECKVAL(L, 4, false); + bool takeCost = Eluna::CHECKVAL(E->L, 2, true); + float discountMod = Eluna::CHECKVAL(E->L, 3, 1.0f); + bool guildBank = Eluna::CHECKVAL(E->L, 4, false); player->DurabilityRepairAll(takeCost, discountMod, guildBank); return 0; @@ -2368,9 +2367,9 @@ namespace LuaPlayer * * @param int32 slot */ - int DurabilityPointLossForEquipSlot(lua_State* L, Player* player) + int DurabilityPointLossForEquipSlot(Eluna* E, Player* player) { - int32 slot = Eluna::CHECKVAL(L, 2); + int32 slot = Eluna::CHECKVAL(E->L, 2); if (slot >= EQUIPMENT_SLOT_START && slot < EQUIPMENT_SLOT_END) player->DurabilityPointLossForEquipSlot((EquipmentSlots)slot); @@ -2385,10 +2384,10 @@ namespace LuaPlayer * @param int32 points * @param bool inventory = true */ - int DurabilityPointsLossAll(lua_State* L, Player* player) + int DurabilityPointsLossAll(Eluna* E, Player* player) { - int32 points = Eluna::CHECKVAL(L, 2); - bool inventory = Eluna::CHECKVAL(L, 3, true); + int32 points = Eluna::CHECKVAL(E->L, 2); + bool inventory = Eluna::CHECKVAL(E->L, 3, true); player->DurabilityPointsLossAll(points, inventory); return 0; @@ -2400,10 +2399,10 @@ namespace LuaPlayer * @param [Item] item * @param int32 points */ - int DurabilityPointsLoss(lua_State* L, Player* player) + int DurabilityPointsLoss(Eluna* E, Player* player) { - Item* item = Eluna::CHECKOBJ(L, 2); - int32 points = Eluna::CHECKVAL(L, 3); + Item* item = Eluna::CHECKOBJ(E->L, 2); + int32 points = Eluna::CHECKVAL(E->L, 3); player->DurabilityPointsLoss(item, points); return 0; @@ -2415,10 +2414,10 @@ namespace LuaPlayer * @param [Item] item * @param double percent */ - int DurabilityLoss(lua_State* L, Player* player) + int DurabilityLoss(Eluna* E, Player* player) { - Item* item = Eluna::CHECKOBJ(L, 2); - double percent = Eluna::CHECKVAL(L, 3); + Item* item = Eluna::CHECKOBJ(E->L, 2); + double percent = Eluna::CHECKVAL(E->L, 3); player->DurabilityLoss(item, percent); return 0; @@ -2430,10 +2429,10 @@ namespace LuaPlayer * @param double percent * @param bool inventory = true */ - int DurabilityLossAll(lua_State* L, Player* player) + int DurabilityLossAll(Eluna* E, Player* player) { - double percent = Eluna::CHECKVAL(L, 2); - bool inventory = Eluna::CHECKVAL(L, 3, true); + double percent = Eluna::CHECKVAL(E->L, 2); + bool inventory = Eluna::CHECKVAL(E->L, 3, true); player->DurabilityLossAll(percent, inventory); return 0; @@ -2442,7 +2441,7 @@ namespace LuaPlayer /** * Kills the [Player] */ - int KillPlayer(lua_State* /*L*/, Player* player) + int KillPlayer(Eluna* /*E*/, Player* player) { player->KillPlayer(); return 0; @@ -2451,7 +2450,7 @@ namespace LuaPlayer /** * Forces the [Player] to leave a [Group] */ - int RemoveFromGroup(lua_State* /*L*/, Player* player) + int RemoveFromGroup(Eluna* /*E*/, Player* player) { if (!player->GetGroup()) return 0; @@ -2465,12 +2464,12 @@ namespace LuaPlayer * * @return uint32 resetCost */ - int ResetTalentsCost(lua_State* L, Player* player) + int ResetTalentsCost(Eluna* E, Player* player) { #ifdef CATA - Eluna::Push(L, player->GetNextResetTalentsCost()); + E->Push(player->GetNextResetTalentsCost()); #else - Eluna::Push(L, player->ResetTalentsCost()); + E->Push(player->ResetTalentsCost()); #endif return 1; } @@ -2480,9 +2479,9 @@ namespace LuaPlayer * * @param bool noCost = true */ - int ResetTalents(lua_State* L, Player* player) + int ResetTalents(Eluna* E, Player* player) { - bool no_cost = Eluna::CHECKVAL(L, 2, true); + bool no_cost = Eluna::CHECKVAL(E->L, 2, true); player->ResetTalents(no_cost); player->SendTalentsInfoData(false); @@ -2494,9 +2493,9 @@ namespace LuaPlayer * * @param uint32 entry : entry of a [Spell] */ - int RemoveSpell(lua_State* L, Player* player) + int RemoveSpell(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); player->RemoveSpell(entry); return 0; @@ -2505,7 +2504,7 @@ namespace LuaPlayer /** * Clears the [Player]s combo points */ - int ClearComboPoints(lua_State* /*L*/, Player* player) + int ClearComboPoints(Eluna* /*E*/, Player* player) { player->ClearComboPoints(); return 0; @@ -2517,10 +2516,10 @@ namespace LuaPlayer * @param [Unit] target * @param int8 count */ - int AddComboPoints(lua_State* L, Player* player) + int AddComboPoints(Eluna* E, Player* player) { - Unit* target = Eluna::CHECKOBJ(L, 2); - int8 count = Eluna::CHECKVAL(L, 3); + Unit* target = Eluna::CHECKOBJ(E->L, 2); + int8 count = Eluna::CHECKVAL(E->L, 3); player->AddComboPoints(target, count); return 0; @@ -2532,10 +2531,10 @@ namespace LuaPlayer * @param uint32 entry : entry of a [Creature] * @param [Creature] creature */ - int TalkedToCreature(lua_State* L, Player* player) + int TalkedToCreature(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); - Creature* creature = Eluna::CHECKOBJ(L, 3); + uint32 entry = Eluna::CHECKVAL(E->L, 2); + Creature* creature = Eluna::CHECKOBJ(E->L, 3); player->TalkedToCreature(entry, creature->GET_GUID()); return 0; @@ -2546,9 +2545,9 @@ namespace LuaPlayer * * @param uint32 entry : entry of a [Creature] */ - int KilledMonsterCredit(lua_State* L, Player* player) + int KilledMonsterCredit(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); player->KilledMonsterCredit(entry, player->GET_GUID()); return 0; @@ -2560,10 +2559,10 @@ namespace LuaPlayer * @param uint32 quest : entry of a quest * @param [WorldObject] obj */ - int GroupEventHappens(lua_State* L, Player* player) + int GroupEventHappens(Eluna* E, Player* player) { - uint32 questId = Eluna::CHECKVAL(L, 2); - WorldObject* obj = Eluna::CHECKOBJ(L, 3); + uint32 questId = Eluna::CHECKVAL(E->L, 2); + WorldObject* obj = Eluna::CHECKOBJ(E->L, 3); player->GroupEventHappens(questId, obj); return 0; @@ -2574,9 +2573,9 @@ namespace LuaPlayer * * @param uint32 quest : entry of a [Quest] */ - int AreaExploredOrEventHappens(lua_State* L, Player* player) + int AreaExploredOrEventHappens(Eluna* E, Player* player) { - uint32 questId = Eluna::CHECKVAL(L, 2); + uint32 questId = Eluna::CHECKVAL(E->L, 2); player->AreaExploredOrEventHappens(questId); return 0; @@ -2587,9 +2586,9 @@ namespace LuaPlayer * * @param uint32 entry : entry of a [Quest] */ - int FailQuest(lua_State* L, Player* player) + int FailQuest(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); player->FailQuest(entry); return 0; @@ -2600,9 +2599,9 @@ namespace LuaPlayer * * @param uint32 entry : quest entry */ - int IncompleteQuest(lua_State* L, Player* player) + int IncompleteQuest(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); player->IncompleteQuest(entry); return 0; @@ -2615,9 +2614,9 @@ namespace LuaPlayer * * @param uint32 entry : quest entry */ - int CompleteQuest(lua_State* L, Player* player) + int CompleteQuest(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); Quest const* quest = eObjectMgr->GetQuestTemplate(entry); @@ -2708,9 +2707,9 @@ namespace LuaPlayer * * @param uint32 entry : quest entry */ - int AddQuest(lua_State* L, Player* player) + int AddQuest(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); Quest const* quest = eObjectMgr->GetQuestTemplate(entry); @@ -2747,9 +2746,9 @@ namespace LuaPlayer * * @param uint32 entry : quest entry */ - int RemoveQuest(lua_State* L, Player* player) + int RemoveQuest(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); Quest const* quest = eObjectMgr->GetQuestTemplate(entry); @@ -2788,11 +2787,11 @@ namespace LuaPlayer * @param [Player] receiver : is the [Player] that will receive the whisper, if TrinityCore * @param ObjectGuid guid : is the GUID of a [Player] that will receive the whisper, not TrinityCore */ - int Whisper(lua_State* L, Player* player) + int Whisper(Eluna* E, Player* player) { - std::string text = Eluna::CHECKVAL(L, 2); - uint32 lang = Eluna::CHECKVAL(L, 3); - Player* receiver = Eluna::CHECKOBJ(L, 4); + std::string text = Eluna::CHECKVAL(E->L, 2); + uint32 lang = Eluna::CHECKVAL(E->L, 3); + Player* receiver = Eluna::CHECKOBJ(E->L, 4); player->Whisper(text, (Language)lang, receiver); return 0; @@ -2803,9 +2802,9 @@ namespace LuaPlayer * * @param string emoteText */ - int TextEmote(lua_State* L, Player* player) + int TextEmote(Eluna* E, Player* player) { - std::string text = Eluna::CHECKVAL(L, 2); + std::string text = Eluna::CHECKVAL(E->L, 2); player->TextEmote(text); return 0; @@ -2817,10 +2816,10 @@ namespace LuaPlayer * @param string text : text for the [Player] to yells * @param uint32 lang : language the [Player] will speak */ - int Yell(lua_State* L, Player* player) + int Yell(Eluna* E, Player* player) { - std::string text = Eluna::CHECKVAL(L, 2); - uint32 lang = Eluna::CHECKVAL(L, 3); + std::string text = Eluna::CHECKVAL(E->L, 2); + uint32 lang = Eluna::CHECKVAL(E->L, 3); player->Yell(text, (Language)lang); return 0; @@ -2832,10 +2831,10 @@ namespace LuaPlayer * @param string text : text for the [Player] to say * @param uint32 lang : language the [Player] will speak */ - int Say(lua_State* L, Player* player) + int Say(Eluna* E, Player* player) { - std::string text = Eluna::CHECKVAL(L, 2); - uint32 lang = Eluna::CHECKVAL(L, 3); + std::string text = Eluna::CHECKVAL(E->L, 2); + uint32 lang = Eluna::CHECKVAL(E->L, 3); player->Say(text, (Language)lang); return 0; @@ -2847,10 +2846,10 @@ namespace LuaPlayer * @param uint32 xp : experience to give * @param [Unit] victim = nil */ - int GiveXP(lua_State* L, Player* player) + int GiveXP(Eluna* E, Player* player) { - uint32 xp = Eluna::CHECKVAL(L, 2); - Unit* victim = Eluna::CHECKOBJ(L, 3, false); + uint32 xp = Eluna::CHECKVAL(E->L, 2); + Unit* victim = Eluna::CHECKOBJ(E->L, 3, false); player->GiveXP(xp, victim); return 0; @@ -2859,7 +2858,7 @@ namespace LuaPlayer /** * Toggle the [Player]s 'Do Not Disturb' flag */ - int ToggleDND(lua_State* /*L*/, Player* player) + int ToggleDND(Eluna* /*E*/, Player* player) { player->ToggleDND(); return 0; @@ -2868,7 +2867,7 @@ namespace LuaPlayer /** * Toggle the [Player]s 'Away From Keyboard' flag */ - int ToggleAFK(lua_State* /*L*/, Player* player) + int ToggleAFK(Eluna* /*E*/, Player* player) { player->ToggleAFK(); return 0; @@ -2915,18 +2914,18 @@ namespace LuaPlayer * @param uint32 slot : equipment slot to equip the item to The slot can be [EquipmentSlots] or [InventorySlots] * @return [Item] equippedItem : item or nil if equipping failed */ - int EquipItem(lua_State* L, Player* player) + int EquipItem(Eluna* E, Player* player) { uint16 dest = 0; - Item* item = Eluna::CHECKOBJ(L, 2, false); - uint32 slot = Eluna::CHECKVAL(L, 3); + Item* item = Eluna::CHECKOBJ(E->L, 2, false); + uint32 slot = Eluna::CHECKVAL(E->L, 3); if (slot >= INVENTORY_SLOT_BAG_END) return 1; if (!item) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); item = Item::CreateItem(entry, 1, player); if (!item) return 1; @@ -2948,7 +2947,7 @@ namespace LuaPlayer player->RemoveItem(item->GetBagSlot(), item->GetSlot(), true); } - Eluna::Push(L, player->EquipItem(dest, item, true)); + E->Push(player->EquipItem(dest, item, true)); player->AutoUnequipOffhandIfNeed(); return 1; } @@ -2963,24 +2962,24 @@ namespace LuaPlayer * @param uint32 slot : equipment slot to test * @return bool canEquip */ - int CanEquipItem(lua_State* L, Player* player) + int CanEquipItem(Eluna* E, Player* player) { - Item* item = Eluna::CHECKOBJ(L, 2, false); - uint32 slot = Eluna::CHECKVAL(L, 3); + Item* item = Eluna::CHECKOBJ(E->L, 2, false); + uint32 slot = Eluna::CHECKVAL(E->L, 3); if (slot >= EQUIPMENT_SLOT_END) { - Eluna::Push(L, false); + E->Push(false); return 1; } if (!item) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); uint16 dest; InventoryResult msg = player->CanEquipNewItem(slot, dest, entry, false); if (msg != EQUIP_ERR_OK) { - Eluna::Push(L, false); + E->Push(false); return 1; } } @@ -2990,11 +2989,11 @@ namespace LuaPlayer InventoryResult msg = player->CanEquipItem(slot, dest, item, false); if (msg != EQUIP_ERR_OK) { - Eluna::Push(L, false); + E->Push(false); return 1; } } - Eluna::Push(L, true); + E->Push(true); return 1; } @@ -3003,9 +3002,9 @@ namespace LuaPlayer * * @param uint32 titleId */ - int UnsetKnownTitle(lua_State* L, Player* player) + int UnsetKnownTitle(Eluna* E, Player* player) { - uint32 id = Eluna::CHECKVAL(L, 2); + uint32 id = Eluna::CHECKVAL(E->L, 2); CharTitlesEntry const* t = sCharTitlesStore.LookupEntry(id); if (t) player->SetTitle(t, true); @@ -3016,7 +3015,7 @@ namespace LuaPlayer /** * Advances all of the [Player]s weapon skills to the maximum amount available */ - int AdvanceSkillsToMax(lua_State* /*L*/, Player* player) + int AdvanceSkillsToMax(Eluna* /*E*/, Player* player) { player->UpdateWeaponsSkillsToMaxSkillsForLevel(); return 0; @@ -3028,9 +3027,9 @@ namespace LuaPlayer * * @param uint32 skillStep */ - int AdvanceAllSkills(lua_State* L, Player* player) + int AdvanceAllSkills(Eluna* E, Player* player) { - uint32 step = Eluna::CHECKVAL(L, 2); + uint32 step = Eluna::CHECKVAL(E->L, 2); if (!step) return 0; @@ -3056,10 +3055,10 @@ namespace LuaPlayer * @param uint32 skillId * @param uint32 skillStep */ - int AdvanceSkill(lua_State* L, Player* player) + int AdvanceSkill(Eluna* E, Player* player) { - uint32 _skillId = Eluna::CHECKVAL(L, 2); - uint32 _step = Eluna::CHECKVAL(L, 3); + uint32 _skillId = Eluna::CHECKVAL(E->L, 2); + uint32 _step = Eluna::CHECKVAL(E->L, 3); if (_skillId && _step) { if (player->HasSkill(_skillId)) @@ -3077,13 +3076,13 @@ namespace LuaPlayer * @param float zCoord * @param float orientation */ - int Teleport(lua_State* L, Player* player) + int Teleport(Eluna* E, Player* player) { - uint32 mapId = Eluna::CHECKVAL(L, 2); - float x = Eluna::CHECKVAL(L, 3); - float y = Eluna::CHECKVAL(L, 4); - float z = Eluna::CHECKVAL(L, 5); - float o = Eluna::CHECKVAL(L, 6); + uint32 mapId = Eluna::CHECKVAL(E->L, 2); + float x = Eluna::CHECKVAL(E->L, 3); + float y = Eluna::CHECKVAL(E->L, 4); + float z = Eluna::CHECKVAL(E->L, 5); + float o = Eluna::CHECKVAL(E->L, 6); #ifdef CATA if (player->IsInFlight()) @@ -3100,13 +3099,13 @@ namespace LuaPlayer player->SaveRecallPosition(); #endif - Eluna::Push(L, player->TeleportTo(mapId, x, y, z, o)); + E->Push(player->TeleportTo(mapId, x, y, z, o)); return 1; } - int AddLifetimeKills(lua_State* L, Player* player) + int AddLifetimeKills(Eluna* E, Player* player) { - uint32 val = Eluna::CHECKVAL(L, 2); + uint32 val = Eluna::CHECKVAL(E->L, 2); uint32 currentKills = player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS); player->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, currentKills + val); return 0; @@ -3119,10 +3118,10 @@ namespace LuaPlayer * @param uint32 itemCount = 1 : amount of the item to add * @return [Item] item : the item that was added or nil */ - int AddItem(lua_State* L, Player* player) + int AddItem(Eluna* E, Player* player) { - uint32 itemId = Eluna::CHECKVAL(L, 2); - uint32 itemCount = Eluna::CHECKVAL(L, 3, 1); + uint32 itemId = Eluna::CHECKVAL(E->L, 2); + uint32 itemCount = Eluna::CHECKVAL(E->L, 3, 1); uint32 noSpaceForCount = 0; ItemPosCountVec dest; @@ -3138,7 +3137,7 @@ namespace LuaPlayer if (item) player->SendNewItem(item, itemCount, true, false); - Eluna::Push(L, item); + E->Push(item); return 1; } @@ -3151,13 +3150,13 @@ namespace LuaPlayer * @param uint32 entry : entry of the item to remove * @param uint32 itemCount = 1 : amount of the item to remove */ - int RemoveItem(lua_State* L, Player* player) + int RemoveItem(Eluna* E, Player* player) { - Item* item = Eluna::CHECKOBJ(L, 2, false); - uint32 itemCount = Eluna::CHECKVAL(L, 3); + Item* item = Eluna::CHECKOBJ(E->L, 2, false); + uint32 itemCount = Eluna::CHECKVAL(E->L, 3); if (!item) { - uint32 itemId = Eluna::CHECKVAL(L, 2); + uint32 itemId = Eluna::CHECKVAL(E->L, 2); player->DestroyItemCount(itemId, itemCount, true); } else @@ -3165,7 +3164,7 @@ namespace LuaPlayer bool all = itemCount >= item->GetCount(); player->DestroyItemCount(item, itemCount, true); if (all) - Eluna::CHECKOBJ(L, 2)->Invalidate(); + Eluna::CHECKOBJ(E->L, 2)->Invalidate(); } return 0; } @@ -3175,9 +3174,9 @@ namespace LuaPlayer * * @param uint32 val : kills to remove */ - int RemoveLifetimeKills(lua_State* L, Player* player) + int RemoveLifetimeKills(Eluna* E, Player* player) { - uint32 val = Eluna::CHECKVAL(L, 2); + uint32 val = Eluna::CHECKVAL(E->L, 2); uint32 currentKills = player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS); if (val > currentKills) val = currentKills; @@ -3191,10 +3190,10 @@ namespace LuaPlayer * @param uint32 spellId * @param bool update = true */ - int ResetSpellCooldown(lua_State* L, Player* player) + int ResetSpellCooldown(Eluna* E, Player* player) { - uint32 spellId = Eluna::CHECKVAL(L, 2); - bool update = Eluna::CHECKVAL(L, 3, true); + uint32 spellId = Eluna::CHECKVAL(E->L, 2); + bool update = Eluna::CHECKVAL(E->L, 3, true); player->GetSpellHistory()->ResetCooldown(spellId, update); return 0; @@ -3206,10 +3205,10 @@ namespace LuaPlayer * @param uint32 category * @param bool update = true */ - int ResetTypeCooldowns(lua_State* L, Player* player) + int ResetTypeCooldowns(Eluna* E, Player* player) { - uint32 category = Eluna::CHECKVAL(L, 2); - bool update = Eluna::CHECKVAL(L, 3, true); + uint32 category = Eluna::CHECKVAL(E->L, 2); + bool update = Eluna::CHECKVAL(E->L, 3, true); (void)update; // ensure that the variable is referenced in order to pass compiler checks player->GetSpellHistory()->ResetCooldowns([category](SpellHistory::CooldownStorageType::iterator itr) -> bool @@ -3224,7 +3223,7 @@ namespace LuaPlayer /** * Resets all of the [Player]'s cooldowns */ - int ResetAllCooldowns(lua_State* /*L*/, Player* player) + int ResetAllCooldowns(Eluna* /*E*/, Player* player) { player->GetSpellHistory()->ResetAllCooldowns(); return 0; @@ -3235,9 +3234,9 @@ namespace LuaPlayer * * @param string message */ - int SendBroadcastMessage(lua_State* L, Player* player) + int SendBroadcastMessage(Eluna* E, Player* player) { - const char* message = Eluna::CHECKVAL(L, 2); + const char* message = Eluna::CHECKVAL(E->L, 2); if (std::string(message).length() > 0) ChatHandler(player->GetSession()).SendSysMessage(message); return 0; @@ -3248,9 +3247,9 @@ namespace LuaPlayer * * @param string message */ - int SendAreaTriggerMessage(lua_State* L, Player* player) + int SendAreaTriggerMessage(Eluna* E, Player* player) { - std::string msg = Eluna::CHECKVAL(L, 2); + std::string msg = Eluna::CHECKVAL(E->L, 2); if (msg.length() > 0) player->GetSession()->SendAreaTriggerMessage("%s", msg.c_str()); return 0; @@ -3261,9 +3260,9 @@ namespace LuaPlayer * * @param string message */ - int SendNotification(lua_State* L, Player* player) + int SendNotification(Eluna* E, Player* player) { - std::string msg = Eluna::CHECKVAL(L, 2); + std::string msg = Eluna::CHECKVAL(E->L, 2); if (msg.length() > 0) player->GetSession()->SendNotification("%s", msg.c_str()); return 0; @@ -3275,10 +3274,10 @@ namespace LuaPlayer * @param [WorldPacket] packet * @param bool selfOnly = true */ - int SendPacket(lua_State* L, Player* player) + int SendPacket(Eluna* E, Player* player) { - WorldPacket* data = Eluna::CHECKOBJ(L, 2); - bool selfOnly = Eluna::CHECKVAL(L, 3, true); + WorldPacket* data = Eluna::CHECKOBJ(E->L, 2); + bool selfOnly = Eluna::CHECKVAL(E->L, 3, true); if (selfOnly) player->GetSession()->SendPacket(data); @@ -3297,12 +3296,12 @@ namespace LuaPlayer * @param [Player] receiver * */ - int SendAddonMessage(lua_State* L, Player* player) + int SendAddonMessage(Eluna* E, Player* player) { - std::string prefix = Eluna::CHECKVAL(L, 2); - std::string message = Eluna::CHECKVAL(L, 3); - uint8 channel = Eluna::CHECKVAL(L, 4); - Player* receiver = Eluna::CHECKOBJ(L, 5); + std::string prefix = Eluna::CHECKVAL(E->L, 2); + std::string message = Eluna::CHECKVAL(E->L, 3); + uint8 channel = Eluna::CHECKVAL(E->L, 4); + Player* receiver = Eluna::CHECKOBJ(E->L, 5); std::string fullmsg = prefix + "\t" + message; @@ -3323,7 +3322,7 @@ namespace LuaPlayer /** * Kicks the [Player] from the server */ - int KickPlayer(lua_State* /*L*/, Player* player) + int KickPlayer(Eluna* /*E*/, Player* player) { #ifndef CATA player->GetSession()->KickPlayer("PlayerMethods::KickPlayer Kick the player"); @@ -3338,9 +3337,9 @@ namespace LuaPlayer * * @param int32 copperAmt : negative to remove, positive to add */ - int ModifyMoney(lua_State* L, Player* player) + int ModifyMoney(Eluna* E, Player* player) { - int32 amt = Eluna::CHECKVAL(L, 2); + int32 amt = Eluna::CHECKVAL(E->L, 2); player->ModifyMoney(amt); return 1; @@ -3351,9 +3350,9 @@ namespace LuaPlayer * * @param uint32 spellId */ - int LearnSpell(lua_State* L, Player* player) + int LearnSpell(Eluna* E, Player* player) { - uint32 id = Eluna::CHECKVAL(L, 2); + uint32 id = Eluna::CHECKVAL(E->L, 2); player->LearnSpell(id, false); return 0; @@ -3365,10 +3364,10 @@ namespace LuaPlayer * @param uint32 talent_id * @param uint32 talentRank */ - int LearnTalent(lua_State* L, Player* player) + int LearnTalent(Eluna* E, Player* player) { - uint32 id = Eluna::CHECKVAL(L, 2); - uint32 rank = Eluna::CHECKVAL(L, 3); + uint32 id = Eluna::CHECKVAL(E->L, 2); + uint32 rank = Eluna::CHECKVAL(E->L, 3); player->LearnTalent(id, rank); player->SendTalentsInfoData(false); @@ -3378,7 +3377,7 @@ namespace LuaPlayer /** * Remove cooldowns on spells that have less than 10 minutes of cooldown from the [Player], similarly to when you enter an arena. */ - int RemoveArenaSpellCooldowns(lua_State* /*L*/, Player* player) + int RemoveArenaSpellCooldowns(Eluna* /*E*/, Player* player) { player->RemoveArenaSpellCooldowns(); return 0; @@ -3390,10 +3389,10 @@ namespace LuaPlayer * @param float healthPercent = 100.0f * @param bool ressSickness = false */ - int ResurrectPlayer(lua_State* L, Player* player) + int ResurrectPlayer(Eluna* E, Player* player) { - float percent = Eluna::CHECKVAL(L, 2, 100.0f); - bool sickness = Eluna::CHECKVAL(L, 3, false); + float percent = Eluna::CHECKVAL(E->L, 2, 100.0f); + bool sickness = Eluna::CHECKVAL(E->L, 3, false); player->ResurrectPlayer(percent, sickness); player->SpawnCorpseBones(); return 0; @@ -3417,15 +3416,15 @@ namespace LuaPlayer * @param string popup = nil : if non empty string, a popup with given text shown on click * @param uint32 money = 0 : required money in copper */ - int GossipMenuAddItem(lua_State* L, Player* player) + int GossipMenuAddItem(Eluna* E, Player* player) { - uint32 _icon = Eluna::CHECKVAL(L, 2); - const char* msg = Eluna::CHECKVAL(L, 3); - uint32 _sender = Eluna::CHECKVAL(L, 4); - uint32 _intid = Eluna::CHECKVAL(L, 5); - bool _code = Eluna::CHECKVAL(L, 6, false); - const char* _promptMsg = Eluna::CHECKVAL(L, 7, ""); - uint32 _money = Eluna::CHECKVAL(L, 8, 0); + uint32 _icon = Eluna::CHECKVAL(E->L, 2); + const char* msg = Eluna::CHECKVAL(E->L, 3); + uint32 _sender = Eluna::CHECKVAL(E->L, 4); + uint32 _intid = Eluna::CHECKVAL(E->L, 5); + bool _code = Eluna::CHECKVAL(E->L, 6, false); + const char* _promptMsg = Eluna::CHECKVAL(E->L, 7, ""); + uint32 _money = Eluna::CHECKVAL(E->L, 8, 0); player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, GossipOptionIcon(_icon), msg, _sender, _intid, _promptMsg, _money, _code); return 0; @@ -3436,7 +3435,7 @@ namespace LuaPlayer * * See also: [Player:GossipMenuAddItem], [Player:GossipAddQuests], [Player:GossipSendMenu], [Player:GossipClearMenu] */ - int GossipComplete(lua_State* /*L*/, Player* player) + int GossipComplete(Eluna* /*E*/, Player* player) { player->PlayerTalkClass->SendCloseGossip(); return 0; @@ -3456,13 +3455,13 @@ namespace LuaPlayer * @param [Object] sender : object acting as the source of the sent gossip menu * @param uint32 menu_id : if sender is a [Player] then menu_id is mandatory */ - int GossipSendMenu(lua_State* L, Player* player) + int GossipSendMenu(Eluna* E, Player* player) { - uint32 npc_text = Eluna::CHECKVAL(L, 2); - Object* sender = Eluna::CHECKOBJ(L, 3); + uint32 npc_text = Eluna::CHECKVAL(E->L, 2); + Object* sender = Eluna::CHECKOBJ(E->L, 3); if (sender->GetTypeId() == TYPEID_PLAYER) { - uint32 menu_id = Eluna::CHECKVAL(L, 4); + uint32 menu_id = Eluna::CHECKVAL(E->L, 4); player->PlayerTalkClass->GetGossipMenu().SetMenuId(menu_id); } @@ -3478,7 +3477,7 @@ namespace LuaPlayer * Note: This is needed when you show a gossip menu without using gossip hello or select hooks which do this automatically. * Usually this is needed when using [Player] is the sender of a Gossip Menu. */ - int GossipClearMenu(lua_State* /*L*/, Player* player) + int GossipClearMenu(Eluna* /*E*/, Player* player) { player->PlayerTalkClass->ClearMenus(); return 0; @@ -3489,9 +3488,9 @@ namespace LuaPlayer * * @param uint32 pathId : pathId from DBC or [Global:AddTaxiPath] */ - int StartTaxi(lua_State* L, Player* player) + int StartTaxi(Eluna* E, Player* player) { - uint32 pathId = Eluna::CHECKVAL(L, 2); + uint32 pathId = Eluna::CHECKVAL(E->L, 2); player->ActivateTaxiPathTo(pathId); return 0; @@ -3507,14 +3506,14 @@ namespace LuaPlayer * @param uint32 data * @param string iconText */ - int GossipSendPOI(lua_State* L, Player* player) + int GossipSendPOI(Eluna* E, Player* player) { - float x = Eluna::CHECKVAL(L, 2); - float y = Eluna::CHECKVAL(L, 3); - uint32 icon = Eluna::CHECKVAL(L, 4); - uint32 flags = Eluna::CHECKVAL(L, 5); - uint32 data = Eluna::CHECKVAL(L, 6); - std::string iconText = Eluna::CHECKVAL(L, 7); + float x = Eluna::CHECKVAL(E->L, 2); + float y = Eluna::CHECKVAL(E->L, 3); + uint32 icon = Eluna::CHECKVAL(E->L, 4); + uint32 flags = Eluna::CHECKVAL(E->L, 5); + uint32 data = Eluna::CHECKVAL(E->L, 6); + std::string iconText = Eluna::CHECKVAL(E->L, 7); WorldPacket packet(SMSG_GOSSIP_POI, 4 + 4 + 4 + 4 + 4 + 10); packet << flags; @@ -3533,9 +3532,9 @@ namespace LuaPlayer * * @param [WorldObject] source : a questgiver with quests */ - int GossipAddQuests(lua_State* L, Player* player) + int GossipAddQuests(Eluna* E, Player* player) { - WorldObject* source = Eluna::CHECKOBJ(L, 2); + WorldObject* source = Eluna::CHECKOBJ(E->L, 2); if (source->GetTypeId() == TYPEID_UNIT) { @@ -3556,10 +3555,10 @@ namespace LuaPlayer * @param uint32 questId : entry of a quest * @param bool activateAccept = true : auto finish the quest */ - int SendQuestTemplate(lua_State* L, Player* player) + int SendQuestTemplate(Eluna* E, Player* player) { - uint32 questId = Eluna::CHECKVAL(L, 2); - bool activateAccept = Eluna::CHECKVAL(L, 3, true); + uint32 questId = Eluna::CHECKVAL(E->L, 2); + bool activateAccept = Eluna::CHECKVAL(E->L, 3, true); Quest const* quest = eObjectMgr->GetQuestTemplate(questId); if (!quest) @@ -3577,7 +3576,7 @@ namespace LuaPlayer /** * Converts [Player]'s corpse to bones */ - int SpawnBones(lua_State* /*L*/, Player* player) + int SpawnBones(Eluna* /*E*/, Player* player) { player->SpawnCorpseBones(); return 0; @@ -3588,9 +3587,9 @@ namespace LuaPlayer * * @param [Player] looter */ - int RemovedInsignia(lua_State* L, Player* player) + int RemovedInsignia(Eluna* E, Player* player) { - Player* looter = Eluna::CHECKOBJ(L, 2); + Player* looter = Eluna::CHECKOBJ(E->L, 2); player->RemovedInsignia(looter); return 0; } @@ -3601,13 +3600,13 @@ namespace LuaPlayer * @param [Player] invited : player to invite to group * @return bool success : true if the player was invited to a group */ - int GroupInvite(lua_State* L, Player* player) + int GroupInvite(Eluna* E, Player* player) { - Player* invited = Eluna::CHECKOBJ(L, 2); + Player* invited = Eluna::CHECKOBJ(E->L, 2); if (invited->GetGroup() || invited->GetGroupInvite()) { - Eluna::Push(L, false); + E->Push(false); return 1; } @@ -3647,7 +3646,7 @@ namespace LuaPlayer invited->GetSession()->SendPacket(&data); } - Eluna::Push(L, success); + E->Push(success); return 1; } @@ -3657,9 +3656,9 @@ namespace LuaPlayer * @param [Player] invited : player to add to group * @return [Group] createdGroup : the created group or nil */ - int GroupCreate(lua_State* L, Player* player) + int GroupCreate(Eluna* E, Player* player) { - Player* invited = Eluna::CHECKOBJ(L, 2); + Player* invited = Eluna::CHECKOBJ(E->L, 2); if (player->GetGroup() || invited->GetGroup()) return 0; @@ -3690,7 +3689,7 @@ namespace LuaPlayer group->BroadcastGroupUpdate(); - Eluna::Push(L, group); + E->Push(group); return 1; } @@ -3699,9 +3698,9 @@ namespace LuaPlayer * * @param uint32 CinematicSequenceId : entry of a cinematic */ - int SendCinematicStart(lua_State* L, Player* player) + int SendCinematicStart(Eluna* E, Player* player) { - uint32 CinematicSequenceId = Eluna::CHECKVAL(L, 2); + uint32 CinematicSequenceId = Eluna::CHECKVAL(E->L, 2); player->SendCinematicStart(CinematicSequenceId); return 0; @@ -3712,82 +3711,82 @@ namespace LuaPlayer * * @param uint32 MovieId : entry of a movie */ - int SendMovieStart(lua_State* L, Player* player) + int SendMovieStart(Eluna* E, Player* player) { - uint32 MovieId = Eluna::CHECKVAL(L, 2); + uint32 MovieId = Eluna::CHECKVAL(E->L, 2); player->SendMovieStart(MovieId); return 0; } - int BindToInstance(lua_State* /*L*/, Player* player) + int BindToInstance(Eluna* /*E*/, Player* player) { player->BindToInstance(); return 0; } - int AddTalent(lua_State* L, Player* player) + int AddTalent(Eluna* E, Player* player) { - uint32 spellId = Eluna::CHECKVAL(L, 2); - uint8 spec = Eluna::CHECKVAL(L, 3); - bool learning = Eluna::CHECKVAL(L, 4, true); + uint32 spellId = Eluna::CHECKVAL(E->L, 2); + uint8 spec = Eluna::CHECKVAL(E->L, 3); + bool learning = Eluna::CHECKVAL(E->L, 4, true); if (spec >= MAX_TALENT_SPECS) - Eluna::Push(L, false); + E->Push(false); else - Eluna::Push(L, player->AddTalent(spellId, spec, learning)); + E->Push(player->AddTalent(spellId, spec, learning)); return 1; } - /*int GainSpellComboPoints(lua_State* L, Player* player) + /*int GainSpellComboPoints(Eluna* E, Player* player) { - int8 count = Eluna::CHECKVAL(L, 2); + int8 count = Eluna::CHECKVAL(E->L, 2); player->GainSpellComboPoints(count); return 0; }*/ - int KillGOCredit(lua_State* L, Player* player) + int KillGOCredit(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); - ObjectGuid guid = Eluna::CHECKVAL(L, 3); + uint32 entry = Eluna::CHECKVAL(E->L, 2); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 3); player->KillCreditGO(entry, guid); return 0; } - int KilledPlayerCredit(lua_State* /*L*/, Player* player) + int KilledPlayerCredit(Eluna* /*E*/, Player* player) { player->KilledPlayerCredit(); return 0; } - int RemoveRewardedQuest(lua_State* L, Player* player) + int RemoveRewardedQuest(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); player->RemoveRewardedQuest(entry); return 0; } - int RemoveActiveQuest(lua_State* L, Player* player) + int RemoveActiveQuest(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(E->L, 2); player->RemoveActiveQuest(entry); return 0; } - int SummonPet(lua_State* L, Player* player) + int SummonPet(Eluna* E, Player* player) { - uint32 entry = Eluna::CHECKVAL(L, 2); - float x = Eluna::CHECKVAL(L, 3); - float y = Eluna::CHECKVAL(L, 4); - float z = Eluna::CHECKVAL(L, 5); - float o = Eluna::CHECKVAL(L, 6); - uint32 petType = Eluna::CHECKVAL(L, 7); - uint32 despwtime = Eluna::CHECKVAL(L, 8); + uint32 entry = Eluna::CHECKVAL(E->L, 2); + float x = Eluna::CHECKVAL(E->L, 3); + float y = Eluna::CHECKVAL(E->L, 4); + float z = Eluna::CHECKVAL(E->L, 5); + float o = Eluna::CHECKVAL(E->L, 6); + uint32 petType = Eluna::CHECKVAL(E->L, 7); + uint32 despwtime = Eluna::CHECKVAL(E->L, 8); if (petType >= MAX_PET_TYPE) return 0; @@ -3796,10 +3795,10 @@ namespace LuaPlayer return 0; } - int RemovePet(lua_State* L, Player* player) + int RemovePet(Eluna* E, Player* player) { - int mode = Eluna::CHECKVAL(L, 2, PET_SAVE_AS_DELETED); - bool returnreagent = Eluna::CHECKVAL(L, 2, false); + int mode = Eluna::CHECKVAL(E->L, 2, PET_SAVE_AS_DELETED); + bool returnreagent = Eluna::CHECKVAL(E->L, 2, false); if (!player->GetPet()) return 0; diff --git a/TrinityCore/QuestMethods.h b/TrinityCore/QuestMethods.h index dc425cd097..180c2ac34b 100644 --- a/TrinityCore/QuestMethods.h +++ b/TrinityCore/QuestMethods.h @@ -49,11 +49,11 @@ namespace LuaQuest * @param [QuestFlags] flag : all available flags can be seen above * @return bool hasFlag */ - int HasFlag(lua_State* L, Quest* quest) + int HasFlag(Eluna* E, Quest* quest) { - uint32 flag = Eluna::CHECKVAL(L, 2); + uint32 flag = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, quest->HasFlag(flag)); + E->Push(quest->HasFlag(flag)); return 1; } @@ -62,9 +62,9 @@ namespace LuaQuest * * @return bool isDaily */ - int IsDaily(lua_State* L, Quest* quest) + int IsDaily(Eluna* E, Quest* quest) { - Eluna::Push(L, quest->IsDaily()); + E->Push(quest->IsDaily()); return 1; } @@ -73,9 +73,9 @@ namespace LuaQuest * * @return bool isRepeatable */ - int IsRepeatable(lua_State* L, Quest* quest) + int IsRepeatable(Eluna* E, Quest* quest) { - Eluna::Push(L, quest->IsRepeatable()); + E->Push(quest->IsRepeatable()); return 1; } @@ -84,9 +84,9 @@ namespace LuaQuest * * @return uint32 entryId */ - int GetId(lua_State* L, Quest* quest) + int GetId(Eluna* E, Quest* quest) { - Eluna::Push(L, quest->GetQuestId()); + E->Push(quest->GetQuestId()); return 1; } @@ -95,9 +95,9 @@ namespace LuaQuest * * @return uint32 level */ - int GetLevel(lua_State* L, Quest* quest) + int GetLevel(Eluna* E, Quest* quest) { - Eluna::Push(L, quest->GetQuestLevel()); + E->Push(quest->GetQuestLevel()); return 1; } @@ -106,9 +106,9 @@ namespace LuaQuest * * @return uint32 minLevel */ - int GetMinLevel(lua_State* L, Quest* quest) + int GetMinLevel(Eluna* E, Quest* quest) { - Eluna::Push(L, quest->GetMinLevel()); + E->Push(quest->GetMinLevel()); return 1; } @@ -117,9 +117,9 @@ namespace LuaQuest * * @return int32 entryId */ - int GetNextQuestId(lua_State* L, Quest* quest) + int GetNextQuestId(Eluna* E, Quest* quest) { - Eluna::Push(L, quest->GetNextQuestId()); + E->Push(quest->GetNextQuestId()); return 1; } @@ -128,9 +128,9 @@ namespace LuaQuest * * @return int32 entryId */ - int GetPrevQuestId(lua_State* L, Quest* quest) + int GetPrevQuestId(Eluna* E, Quest* quest) { - Eluna::Push(L, quest->GetPrevQuestId()); + E->Push(quest->GetPrevQuestId()); return 1; } @@ -139,9 +139,9 @@ namespace LuaQuest * * @return int32 entryId */ - int GetNextQuestInChain(lua_State* L, Quest* quest) + int GetNextQuestInChain(Eluna* E, Quest* quest) { - Eluna::Push(L, quest->GetNextQuestInChain()); + E->Push(quest->GetNextQuestInChain()); return 1; } @@ -150,9 +150,9 @@ namespace LuaQuest * * @return [QuestFlags] flags */ - int GetFlags(lua_State* L, Quest* quest) + int GetFlags(Eluna* E, Quest* quest) { - Eluna::Push(L, quest->GetFlags()); + E->Push(quest->GetFlags()); return 1; } @@ -163,19 +163,19 @@ namespace LuaQuest * * @return uint32 type */ - int GetType(lua_State* L, Quest* quest) + int GetType(Eluna* E, Quest* quest) { #ifdef CATA - Eluna::Push(L, quest->GetQuestType()); + E->Push(quest->GetQuestType()); #else - Eluna::Push(L, quest->GetType()); + E->Push(quest->GetType()); #endif return 1; } - int GetMaxLevel(lua_State* L, Quest* quest) + int GetMaxLevel(Eluna* E, Quest* quest) { - Eluna::Push(L, quest->GetMaxLevel()); + E->Push(quest->GetMaxLevel()); return 1; } diff --git a/TrinityCore/SpellMethods.h b/TrinityCore/SpellMethods.h index c4389319e4..e2175a12b3 100644 --- a/TrinityCore/SpellMethods.h +++ b/TrinityCore/SpellMethods.h @@ -19,9 +19,9 @@ namespace LuaSpell * * @return bool isAutoRepeating */ - int IsAutoRepeat(lua_State* L, Spell* spell) + int IsAutoRepeat(Eluna* E, Spell* spell) { - Eluna::Push(L, spell->IsAutoRepeat()); + E->Push(spell->IsAutoRepeat()); return 1; } @@ -30,9 +30,9 @@ namespace LuaSpell * * @return [Unit] caster */ - int GetCaster(lua_State* L, Spell* spell) + int GetCaster(Eluna* E, Spell* spell) { - Eluna::Push(L, spell->GetCaster()); + E->Push(spell->GetCaster()); return 1; } @@ -41,9 +41,9 @@ namespace LuaSpell * * @return int32 castTime */ - int GetCastTime(lua_State* L, Spell* spell) + int GetCastTime(Eluna* E, Spell* spell) { - Eluna::Push(L, spell->GetCastTime()); + E->Push(spell->GetCastTime()); return 1; } @@ -52,9 +52,9 @@ namespace LuaSpell * * @return uint32 entryId */ - int GetEntry(lua_State* L, Spell* spell) + int GetEntry(Eluna* E, Spell* spell) { - Eluna::Push(L, spell->m_spellInfo->Id); + E->Push(spell->m_spellInfo->Id); return 1; } @@ -63,9 +63,9 @@ namespace LuaSpell * * @return uint32 powerCost */ - int GetPowerCost(lua_State* L, Spell* spell) + int GetPowerCost(Eluna* E, Spell* spell) { - Eluna::Push(L, spell->GetPowerCost()); + E->Push(spell->GetPowerCost()); return 1; } @@ -74,9 +74,9 @@ namespace LuaSpell * * @return int32 duration */ - int GetDuration(lua_State* L, Spell* spell) + int GetDuration(Eluna* E, Spell* spell) { - Eluna::Push(L, spell->GetSpellInfo()->GetDuration()); + E->Push(spell->GetSpellInfo()->GetDuration()); return 1; } @@ -87,7 +87,7 @@ namespace LuaSpell * @return float y : y coordinate of the [Spell] * @return float z : z coordinate of the [Spell] */ - int GetTargetDest(lua_State* L, Spell* spell) + int GetTargetDest(Eluna* E, Spell* spell) { if (!spell->m_targets.HasDst()) return 3; @@ -95,9 +95,9 @@ namespace LuaSpell float x, y, z; spell->m_targets.GetDstPos()->GetPosition(x, y, z); - Eluna::Push(L, x); - Eluna::Push(L, y); - Eluna::Push(L, z); + E->Push(x); + E->Push(y); + E->Push(z); return 3; } @@ -113,18 +113,18 @@ namespace LuaSpell * * @return [Object] target */ - int GetTarget(lua_State* L, Spell* spell) + int GetTarget(Eluna* E, Spell* spell) { if (GameObject* target = spell->m_targets.GetGOTarget()) - Eluna::Push(L, target); + E->Push(target); else if (Item* target = spell->m_targets.GetItemTarget()) - Eluna::Push(L, target); + E->Push(target); else if (Corpse* target = spell->m_targets.GetCorpseTarget()) - Eluna::Push(L, target); + E->Push(target); else if (Unit* target = spell->m_targets.GetUnitTarget()) - Eluna::Push(L, target); + E->Push(target); else if (WorldObject* target = spell->m_targets.GetObjectTarget()) - Eluna::Push(L, target); + E->Push(target); return 1; } @@ -133,9 +133,9 @@ namespace LuaSpell * * @param bool repeat : set variable to 'true' for spell to automatically repeat */ - int SetAutoRepeat(lua_State* L, Spell* spell) + int SetAutoRepeat(Eluna* E, Spell* spell) { - bool repeat = Eluna::CHECKVAL(L, 2); + bool repeat = Eluna::CHECKVAL(E->L, 2); spell->SetAutoRepeat(repeat); return 0; } @@ -145,9 +145,9 @@ namespace LuaSpell * * @param bool skipCheck = false : skips initial checks to see if the [Spell] can be casted or not, this is optional */ - int Cast(lua_State* L, Spell* spell) + int Cast(Eluna* E, Spell* spell) { - bool skipCheck = Eluna::CHECKVAL(L, 2, false); + bool skipCheck = Eluna::CHECKVAL(E->L, 2, false); spell->cast(skipCheck); return 0; } @@ -155,7 +155,7 @@ namespace LuaSpell /** * Cancels the [Spell]. */ - int Cancel(lua_State* /*L*/, Spell* spell) + int Cancel(Eluna* /*E*/, Spell* spell) { spell->cancel(); return 0; @@ -164,7 +164,7 @@ namespace LuaSpell /** * Finishes the [Spell]. */ - int Finish(lua_State* /*L*/, Spell* spell) + int Finish(Eluna* /*E*/, Spell* spell) { spell->finish(); return 0; diff --git a/TrinityCore/UnitMethods.h b/TrinityCore/UnitMethods.h index 24183c81f7..19e6691a3a 100644 --- a/TrinityCore/UnitMethods.h +++ b/TrinityCore/UnitMethods.h @@ -19,12 +19,12 @@ namespace LuaUnit * @param bool meleeAttack = false: attack with melee or not * @return didAttack : if the [Unit] did not attack */ - int Attack(lua_State* L, Unit* unit) + int Attack(Eluna* E, Unit* unit) { - Unit* who = Eluna::CHECKOBJ(L, 2); - bool meleeAttack = Eluna::CHECKVAL(L, 3, false); + Unit* who = Eluna::CHECKOBJ(E->L, 2); + bool meleeAttack = Eluna::CHECKVAL(E->L, 3, false); - Eluna::Push(L, unit->Attack(who, meleeAttack)); + E->Push(unit->Attack(who, meleeAttack)); return 1; } @@ -33,9 +33,9 @@ namespace LuaUnit * * @return bool isAttacking : if the [Unit] wasn't attacking already */ - int AttackStop(lua_State* L, Unit* unit) + int AttackStop(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->AttackStop()); + E->Push(unit->AttackStop()); return 1; } @@ -44,9 +44,9 @@ namespace LuaUnit * * @return bool isStanding */ - int IsStandState(lua_State* L, Unit* unit) + int IsStandState(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsStandState()); + E->Push(unit->IsStandState()); return 1; } @@ -55,9 +55,9 @@ namespace LuaUnit * * @return bool isMounted */ - int IsMounted(lua_State* L, Unit* unit) + int IsMounted(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsMounted()); + E->Push(unit->IsMounted()); return 1; } @@ -66,9 +66,9 @@ namespace LuaUnit * * @return bool isRooted */ - int IsRooted(lua_State* L, Unit* unit) + int IsRooted(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsRooted() || unit->HasUnitMovementFlag(MOVEMENTFLAG_ROOT)); + E->Push(unit->IsRooted() || unit->HasUnitMovementFlag(MOVEMENTFLAG_ROOT)); return 1; } @@ -77,9 +77,9 @@ namespace LuaUnit * * @return bool hasFullHealth */ - int IsFullHealth(lua_State* L, Unit* unit) + int IsFullHealth(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsFullHealth()); + E->Push(unit->IsFullHealth()); return 1; } @@ -90,11 +90,11 @@ namespace LuaUnit * @param float radius * @return bool isAccessible */ - int IsInAccessiblePlaceFor(lua_State* L, Unit* unit) + int IsInAccessiblePlaceFor(Eluna* E, Unit* unit) { - Creature* creature = Eluna::CHECKOBJ(L, 2); + Creature* creature = Eluna::CHECKOBJ(E->L, 2); - Eluna::Push(L, unit->isInAccessiblePlaceFor(creature)); + E->Push(unit->isInAccessiblePlaceFor(creature)); return 1; } @@ -103,9 +103,9 @@ namespace LuaUnit * * @return bool isAuctioneer */ - int IsAuctioneer(lua_State* L, Unit* unit) + int IsAuctioneer(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsAuctioner()); + E->Push(unit->IsAuctioner()); return 1; } @@ -114,9 +114,9 @@ namespace LuaUnit * * @return bool isGuildMaster */ - int IsGuildMaster(lua_State* L, Unit* unit) + int IsGuildMaster(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsGuildMaster()); + E->Push(unit->IsGuildMaster()); return 1; } @@ -125,9 +125,9 @@ namespace LuaUnit * * @return bool isInnkeeper */ - int IsInnkeeper(lua_State* L, Unit* unit) + int IsInnkeeper(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsInnkeeper()); + E->Push(unit->IsInnkeeper()); return 1; } @@ -136,9 +136,9 @@ namespace LuaUnit * * @return bool isTrainer */ - int IsTrainer(lua_State* L, Unit* unit) + int IsTrainer(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsTrainer()); + E->Push(unit->IsTrainer()); return 1; } @@ -147,9 +147,9 @@ namespace LuaUnit * * @return bool hasGossip */ - int IsGossip(lua_State* L, Unit* unit) + int IsGossip(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsGossip()); + E->Push(unit->IsGossip()); return 1; } @@ -158,9 +158,9 @@ namespace LuaUnit * * @return bool isTaxi */ - int IsTaxi(lua_State* L, Unit* unit) + int IsTaxi(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsTaxi()); + E->Push(unit->IsTaxi()); return 1; } @@ -169,9 +169,9 @@ namespace LuaUnit * * @return bool isSpiritHealer */ - int IsSpiritHealer(lua_State* L, Unit* unit) + int IsSpiritHealer(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsSpiritHealer()); + E->Push(unit->IsSpiritHealer()); return 1; } @@ -180,9 +180,9 @@ namespace LuaUnit * * @return bool isSpiritGuide */ - int IsSpiritGuide(lua_State* L, Unit* unit) + int IsSpiritGuide(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsSpiritGuide()); + E->Push(unit->IsSpiritGuide()); return 1; } @@ -191,9 +191,9 @@ namespace LuaUnit * * @return bool isTabardDesigner */ - int IsTabardDesigner(lua_State* L, Unit* unit) + int IsTabardDesigner(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsTabardDesigner()); + E->Push(unit->IsTabardDesigner()); return 1; } @@ -202,9 +202,9 @@ namespace LuaUnit * * @return bool isTabardDesigner */ - int IsServiceProvider(lua_State* L, Unit* unit) + int IsServiceProvider(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsServiceProvider()); + E->Push(unit->IsServiceProvider()); return 1; } @@ -213,9 +213,9 @@ namespace LuaUnit * * @return bool isSpiritService */ - int IsSpiritService(lua_State* L, Unit* unit) + int IsSpiritService(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsSpiritService()); + E->Push(unit->IsSpiritService()); return 1; } @@ -224,9 +224,9 @@ namespace LuaUnit * * @return bool isAlive */ - int IsAlive(lua_State* L, Unit* unit) + int IsAlive(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsAlive()); + E->Push(unit->IsAlive()); return 1; } @@ -235,9 +235,9 @@ namespace LuaUnit * * @return bool isDead */ - int IsDead(lua_State* L, Unit* unit) + int IsDead(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->isDead()); + E->Push(unit->isDead()); return 1; } @@ -246,9 +246,9 @@ namespace LuaUnit * * @return bool isDying */ - int IsDying(lua_State* L, Unit* unit) + int IsDying(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->isDying()); + E->Push(unit->isDying()); return 1; } @@ -257,9 +257,9 @@ namespace LuaUnit * * @return bool isBanker */ - int IsBanker(lua_State* L, Unit* unit) + int IsBanker(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsBanker()); + E->Push(unit->IsBanker()); return 1; } @@ -268,9 +268,9 @@ namespace LuaUnit * * @return bool isVendor */ - int IsVendor(lua_State* L, Unit* unit) + int IsVendor(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsVendor()); + E->Push(unit->IsVendor()); return 1; } @@ -279,9 +279,9 @@ namespace LuaUnit * * @return bool isBattleMaster */ - int IsBattleMaster(lua_State* L, Unit* unit) + int IsBattleMaster(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsBattleMaster()); + E->Push(unit->IsBattleMaster()); return 1; } @@ -290,9 +290,9 @@ namespace LuaUnit * * @return bool isCharmed */ - int IsCharmed(lua_State* L, Unit* unit) + int IsCharmed(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsCharmed()); + E->Push(unit->IsCharmed()); return 1; } @@ -301,9 +301,9 @@ namespace LuaUnit * * @return bool isArmorer */ - int IsArmorer(lua_State* L, Unit* unit) + int IsArmorer(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsArmorer()); + E->Push(unit->IsArmorer()); return 1; } @@ -312,9 +312,9 @@ namespace LuaUnit * * @return bool isAttackingPlayer */ - int IsAttackingPlayer(lua_State* L, Unit* unit) + int IsAttackingPlayer(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->isAttackingPlayer()); + E->Push(unit->isAttackingPlayer()); return 1; } @@ -323,9 +323,9 @@ namespace LuaUnit * * @return bool isPvP */ - int IsPvPFlagged(lua_State* L, Unit* unit) + int IsPvPFlagged(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsPvP()); + E->Push(unit->IsPvP()); return 1; } @@ -334,9 +334,9 @@ namespace LuaUnit * * @return bool isOnVehicle */ - int IsOnVehicle(lua_State* L, Unit* unit) + int IsOnVehicle(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetVehicle()); + E->Push(unit->GetVehicle()); return 1; } @@ -345,9 +345,9 @@ namespace LuaUnit * * @return bool inCombat */ - int IsInCombat(lua_State* L, Unit* unit) + int IsInCombat(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsInCombat()); + E->Push(unit->IsInCombat()); return 1; } @@ -356,9 +356,9 @@ namespace LuaUnit * * @return bool underWater */ - int IsUnderWater(lua_State* L, Unit* unit) + int IsUnderWater(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsUnderWater()); + E->Push(unit->IsUnderWater()); return 1; } @@ -367,9 +367,9 @@ namespace LuaUnit * * @return bool inWater */ - int IsInWater(lua_State* L, Unit* unit) + int IsInWater(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsInWater()); + E->Push(unit->IsInWater()); return 1; } @@ -378,9 +378,9 @@ namespace LuaUnit * * @return bool notMoving */ - int IsStopped(lua_State* L, Unit* unit) + int IsStopped(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsStopped()); + E->Push(unit->IsStopped()); return 1; } @@ -389,9 +389,9 @@ namespace LuaUnit * * @return bool questGiver */ - int IsQuestGiver(lua_State* L, Unit* unit) + int IsQuestGiver(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsQuestGiver()); + E->Push(unit->IsQuestGiver()); return 1; } @@ -401,9 +401,9 @@ namespace LuaUnit * @param int32 healthpct : percentage in integer from * @return bool isBelow */ - int HealthBelowPct(lua_State* L, Unit* unit) + int HealthBelowPct(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->HealthBelowPct(Eluna::CHECKVAL(L, 2))); + E->Push(unit->HealthBelowPct(Eluna::CHECKVAL(E->L, 2))); return 1; } @@ -413,9 +413,9 @@ namespace LuaUnit * @param int32 healthpct : percentage in integer from * @return bool isAbove */ - int HealthAbovePct(lua_State* L, Unit* unit) + int HealthAbovePct(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->HealthAbovePct(Eluna::CHECKVAL(L, 2))); + E->Push(unit->HealthAbovePct(Eluna::CHECKVAL(E->L, 2))); return 1; } @@ -425,11 +425,11 @@ namespace LuaUnit * @param uint32 spell : entry of the aura spell * @return bool hasAura */ - int HasAura(lua_State* L, Unit* unit) + int HasAura(Eluna* E, Unit* unit) { - uint32 spell = Eluna::CHECKVAL(L, 2); + uint32 spell = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, unit->HasAura(spell)); + E->Push(unit->HasAura(spell)); return 1; } @@ -438,9 +438,9 @@ namespace LuaUnit * * @return bool isCasting */ - int IsCasting(lua_State* L, Unit* unit) + int IsCasting(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->HasUnitState(UNIT_STATE_CASTING)); + E->Push(unit->HasUnitState(UNIT_STATE_CASTING)); return 1; } @@ -450,29 +450,29 @@ namespace LuaUnit * @param [UnitState] state : an unit state * @return bool hasState */ - int HasUnitState(lua_State* L, Unit* unit) + int HasUnitState(Eluna* E, Unit* unit) { - uint32 state = Eluna::CHECKVAL(L, 2); + uint32 state = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, unit->HasUnitState(state)); + E->Push(unit->HasUnitState(state)); return 1; } - int IsVisible(lua_State* L, Unit* unit) + int IsVisible(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsVisible()); + E->Push(unit->IsVisible()); return 1; } - int IsMoving(lua_State* L, Unit* unit) + int IsMoving(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->isMoving()); + E->Push(unit->isMoving()); return 1; } - int IsFlying(lua_State* L, Unit* unit) + int IsFlying(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->IsFlying()); + E->Push(unit->IsFlying()); return 1; } @@ -481,9 +481,9 @@ namespace LuaUnit * * @return [Unit] owner */ - int GetOwner(lua_State* L, Unit* unit) + int GetOwner(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetOwner()); + E->Push(unit->GetOwner()); return 1; } @@ -492,9 +492,9 @@ namespace LuaUnit * * @return ObjectGuid ownerGUID */ - int GetOwnerGUID(lua_State* L, Unit* unit) + int GetOwnerGUID(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetOwnerGUID()); + E->Push(unit->GetOwnerGUID()); return 1; } @@ -503,9 +503,9 @@ namespace LuaUnit * * @return uint32 mountId : displayId of the mount */ - int GetMountId(lua_State* L, Unit* unit) + int GetMountId(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetMountDisplayId()); + E->Push(unit->GetMountDisplayId()); return 1; } @@ -514,9 +514,9 @@ namespace LuaUnit * * @return ObjectGuid creatorGUID */ - int GetCreatorGUID(lua_State* L, Unit* unit) + int GetCreatorGUID(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetCreatorGUID()); + E->Push(unit->GetCreatorGUID()); return 1; } @@ -525,9 +525,9 @@ namespace LuaUnit * * @return ObjectGuid charmerGUID */ - int GetCharmerGUID(lua_State* L, Unit* unit) + int GetCharmerGUID(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetCharmerGUID()); + E->Push(unit->GetCharmerGUID()); return 1; } @@ -536,9 +536,9 @@ namespace LuaUnit * * @return ObjectGuid charmedGUID */ - int GetCharmGUID(lua_State* L, Unit* unit) + int GetCharmGUID(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetCharmedGUID()); + E->Push(unit->GetCharmedGUID()); return 1; } @@ -547,9 +547,9 @@ namespace LuaUnit * * @return ObjectGuid petGUID */ - int GetPetGUID(lua_State* L, Unit* unit) + int GetPetGUID(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetPetGUID()); + E->Push(unit->GetPetGUID()); return 1; } @@ -558,9 +558,9 @@ namespace LuaUnit * * @return ObjectGuid controllerGUID */ - int GetControllerGUID(lua_State* L, Unit* unit) + int GetControllerGUID(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetCharmerOrOwnerGUID()); + E->Push(unit->GetCharmerOrOwnerGUID()); return 1; } @@ -569,9 +569,9 @@ namespace LuaUnit * * @return ObjectGuid controllerGUID */ - int GetControllerGUIDS(lua_State* L, Unit* unit) + int GetControllerGUIDS(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetCharmerOrOwnerOrOwnGUID()); + E->Push(unit->GetCharmerOrOwnerOrOwnGUID()); return 1; } @@ -581,14 +581,14 @@ namespace LuaUnit * @param uint32 statType * @return float stat */ - int GetStat(lua_State* L, Unit* unit) + int GetStat(Eluna* E, Unit* unit) { - uint32 stat = Eluna::CHECKVAL(L, 2); + uint32 stat = Eluna::CHECKVAL(E->L, 2); if (stat >= MAX_STATS) return 1; - Eluna::Push(L, unit->GetStat((Stats)stat)); + E->Push(unit->GetStat((Stats)stat)); return 1; } @@ -598,14 +598,14 @@ namespace LuaUnit * @param uint32 spellSchool * @return uint32 spellPower */ - int GetBaseSpellPower(lua_State* L, Unit* unit) + int GetBaseSpellPower(Eluna* E, Unit* unit) { - uint32 spellschool = Eluna::CHECKVAL(L, 2); + uint32 spellschool = Eluna::CHECKVAL(E->L, 2); if (spellschool >= MAX_SPELL_SCHOOL) return 1; - Eluna::Push(L, unit->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + spellschool)); + E->Push(unit->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + spellschool)); return 1; } @@ -614,9 +614,9 @@ namespace LuaUnit * * @return [Unit] victim */ - int GetVictim(lua_State* L, Unit* unit) + int GetVictim(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetVictim()); + E->Push(unit->GetVictim()); return 1; } @@ -636,13 +636,13 @@ namespace LuaUnit * @param [CurrentSpellTypes] spellType * @return [Spell] castedSpell */ - int GetCurrentSpell(lua_State* L, Unit* unit) + int GetCurrentSpell(Eluna* E, Unit* unit) { - uint32 type = Eluna::CHECKVAL(L, 2); + uint32 type = Eluna::CHECKVAL(E->L, 2); if (type >= CURRENT_MAX_SPELL) - return luaL_argerror(L, 2, "valid CurrentSpellTypes expected"); + return luaL_argerror(E->L, 2, "valid CurrentSpellTypes expected"); - Eluna::Push(L, unit->GetCurrentSpell(type)); + E->Push(unit->GetCurrentSpell(type)); return 1; } @@ -651,9 +651,9 @@ namespace LuaUnit * * @return uint8 standState */ - int GetStandState(lua_State* L, Unit* unit) + int GetStandState(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetStandState()); + E->Push(unit->GetStandState()); return 1; } @@ -662,9 +662,9 @@ namespace LuaUnit * * @return uint32 displayId */ - int GetDisplayId(lua_State* L, Unit* unit) + int GetDisplayId(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetDisplayId()); + E->Push(unit->GetDisplayId()); return 1; } @@ -673,9 +673,9 @@ namespace LuaUnit * * @return uint32 displayId */ - int GetNativeDisplayId(lua_State* L, Unit* unit) + int GetNativeDisplayId(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetNativeDisplayId()); + E->Push(unit->GetNativeDisplayId()); return 1; } @@ -684,9 +684,9 @@ namespace LuaUnit * * @return uint8 level */ - int GetLevel(lua_State* L, Unit* unit) + int GetLevel(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetLevel()); + E->Push(unit->GetLevel()); return 1; } @@ -695,19 +695,19 @@ namespace LuaUnit * * @return uint32 healthAmount */ - int GetHealth(lua_State* L, Unit* unit) + int GetHealth(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetHealth()); + E->Push(unit->GetHealth()); return 1; } - Powers PowerSelectorHelper(lua_State* L, Unit* unit, int powerType = -1) + Powers PowerSelectorHelper(Eluna* E, Unit* unit, int powerType = -1) { if (powerType == -1) return unit->GetPowerType(); if (powerType < 0 || powerType >= int(MAX_POWERS)) - luaL_argerror(L, 2, "valid Powers expected"); + luaL_argerror(E->L, 2, "valid Powers expected"); return (Powers)powerType; } @@ -732,12 +732,12 @@ namespace LuaUnit * @param int type = -1 : a valid power type from [Powers] or -1 for the [Unit]'s current power type * @return uint32 powerAmount */ - int GetPower(lua_State* L, Unit* unit) + int GetPower(Eluna* E, Unit* unit) { - int type = Eluna::CHECKVAL(L, 2, -1); - Powers power = PowerSelectorHelper(L, unit, type); + int type = Eluna::CHECKVAL(E->L, 2, -1); + Powers power = PowerSelectorHelper(E, unit, type); - Eluna::Push(L, unit->GetPower(power)); + E->Push(unit->GetPower(power)); return 1; } @@ -761,12 +761,12 @@ namespace LuaUnit * @param int type = -1 : a valid power type from [Powers] or -1 for the [Unit]'s current power type * @return uint32 maxPowerAmount */ - int GetMaxPower(lua_State* L, Unit* unit) + int GetMaxPower(Eluna* E, Unit* unit) { - int type = Eluna::CHECKVAL(L, 2, -1); - Powers power = PowerSelectorHelper(L, unit, type); + int type = Eluna::CHECKVAL(E->L, 2, -1); + Powers power = PowerSelectorHelper(E, unit, type); - Eluna::Push(L, unit->GetMaxPower(power)); + E->Push(unit->GetMaxPower(power)); return 1; } @@ -790,14 +790,14 @@ namespace LuaUnit * @param int type = -1 : a valid power type from [Powers] or -1 for the [Unit]'s current power type * @return float powerPct */ - int GetPowerPct(lua_State* L, Unit* unit) + int GetPowerPct(Eluna* E, Unit* unit) { - int type = Eluna::CHECKVAL(L, 2, -1); - Powers power = PowerSelectorHelper(L, unit, type); + int type = Eluna::CHECKVAL(E->L, 2, -1); + Powers power = PowerSelectorHelper(E, unit, type); float percent = ((float)unit->GetPower(power) / (float)unit->GetMaxPower(power)) * 100.0f; - Eluna::Push(L, percent); + E->Push(percent); return 1; } @@ -820,9 +820,9 @@ namespace LuaUnit * * @return [Powers] powerType */ - int GetPowerType(lua_State* L, Unit* unit) + int GetPowerType(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetPowerType()); + E->Push(unit->GetPowerType()); return 1; } @@ -831,9 +831,9 @@ namespace LuaUnit * * @return uint32 maxHealth */ - int GetMaxHealth(lua_State* L, Unit* unit) + int GetMaxHealth(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetMaxHealth()); + E->Push(unit->GetMaxHealth()); return 1; } @@ -842,9 +842,9 @@ namespace LuaUnit * * @return float healthPct */ - int GetHealthPct(lua_State* L, Unit* unit) + int GetHealthPct(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetHealthPct()); + E->Push(unit->GetHealthPct()); return 1; } @@ -853,9 +853,9 @@ namespace LuaUnit * * @return uint8 gender : 0 for male, 1 for female and 2 for none */ - int GetGender(lua_State* L, Unit* unit) + int GetGender(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetGender()); + E->Push(unit->GetGender()); return 1; } @@ -864,9 +864,9 @@ namespace LuaUnit * * @return [Races] race */ - int GetRace(lua_State* L, Unit* unit) + int GetRace(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetRace()); + E->Push(unit->GetRace()); return 1; } @@ -875,9 +875,9 @@ namespace LuaUnit * * @return [Classes] class */ - int GetClass(lua_State* L, Unit* unit) + int GetClass(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetClass()); + E->Push(unit->GetClass()); return 1; } @@ -886,9 +886,9 @@ namespace LuaUnit * * @return uint32 racemask */ - int GetRaceMask(lua_State* L, Unit* unit) + int GetRaceMask(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetRaceMask()); + E->Push(unit->GetRaceMask()); return 1; } @@ -897,9 +897,9 @@ namespace LuaUnit * * @return uint32 classmask */ - int GetClassMask(lua_State* L, Unit* unit) + int GetClassMask(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetClassMask()); + E->Push(unit->GetClassMask()); return 1; } @@ -927,9 +927,9 @@ namespace LuaUnit * * @return [CreatureType] creatureType */ - int GetCreatureType(lua_State* L, Unit* unit) + int GetCreatureType(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetCreatureType()); + E->Push(unit->GetCreatureType()); return 1; } @@ -954,17 +954,17 @@ namespace LuaUnit * @param [LocaleConstant] locale = DEFAULT_LOCALE * @return string className : class name or nil */ - int GetClassAsString(lua_State* L, Unit* unit) + int GetClassAsString(Eluna* E, Unit* unit) { - uint8 locale = Eluna::CHECKVAL(L, 2, DEFAULT_LOCALE); + uint8 locale = Eluna::CHECKVAL(E->L, 2, DEFAULT_LOCALE); if (locale >= TOTAL_LOCALES) - return luaL_argerror(L, 2, "valid LocaleConstant expected"); + return luaL_argerror(E->L, 2, "valid LocaleConstant expected"); const ChrClassesEntry* entry = sChrClassesStore.LookupEntry(unit->GetClass()); if (!entry) return 1; - Eluna::Push(L, entry->Name[locale]); + E->Push(entry->Name[locale]); return 1; } @@ -989,17 +989,17 @@ namespace LuaUnit * @param [LocaleConstant] locale = DEFAULT_LOCALE : locale to return the race name in * @return string raceName : race name or nil */ - int GetRaceAsString(lua_State* L, Unit* unit) + int GetRaceAsString(Eluna* E, Unit* unit) { - uint8 locale = Eluna::CHECKVAL(L, 2, DEFAULT_LOCALE); + uint8 locale = Eluna::CHECKVAL(E->L, 2, DEFAULT_LOCALE); if (locale >= TOTAL_LOCALES) - return luaL_argerror(L, 2, "valid LocaleConstant expected"); + return luaL_argerror(E->L, 2, "valid LocaleConstant expected"); const ChrRacesEntry* entry = sChrRacesStore.LookupEntry(unit->GetRace()); if (!entry) return 1; - Eluna::Push(L, entry->Name[locale]); + E->Push(entry->Name[locale]); return 1; } @@ -1008,9 +1008,9 @@ namespace LuaUnit * * @return uint32 faction */ - int GetFaction(lua_State* L, Unit* unit) + int GetFaction(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetFaction()); + E->Push(unit->GetFaction()); return 1; } @@ -1020,11 +1020,11 @@ namespace LuaUnit * @param uint32 spellID : entry of the aura spell * @return [Aura] aura : aura object or nil */ - int GetAura(lua_State* L, Unit* unit) + int GetAura(Eluna* E, Unit* unit) { - uint32 spellID = Eluna::CHECKVAL(L, 2); + uint32 spellID = Eluna::CHECKVAL(E->L, 2); - Eluna::Push(L, unit->GetAura(spellID)); + E->Push(unit->GetAura(spellID)); return 1; } @@ -1034,9 +1034,9 @@ namespace LuaUnit * @param float range = 533.333 : search radius * @return table friendyUnits : table filled with friendly units */ - int GetFriendlyUnitsInRange(lua_State* L, Unit* unit) + int GetFriendlyUnitsInRange(Eluna* E, Unit* unit) { - float range = Eluna::CHECKVAL(L, 2, SIZE_OF_GRIDS); + float range = Eluna::CHECKVAL(E->L, 2, SIZE_OF_GRIDS); std::list list; Trinity::AnyFriendlyUnitInObjectRangeCheck checker(unit, unit, range); @@ -1046,17 +1046,17 @@ namespace LuaUnit ElunaUtil::ObjectGUIDCheck guidCheck(unit->GET_GUID()); list.remove_if(guidCheck); - lua_createtable(L, list.size(), 0); - int tbl = lua_gettop(L); + lua_createtable(E->L, list.size(), 0); + int tbl = lua_gettop(E->L); uint32 i = 0; for (std::list::const_iterator it = list.begin(); it != list.end(); ++it) { - Eluna::Push(L, *it); - lua_rawseti(L, tbl, ++i); + E->Push(*it); + lua_rawseti(E->L, tbl, ++i); } - lua_settop(L, tbl); + lua_settop(E->L, tbl); return 1; } @@ -1066,9 +1066,9 @@ namespace LuaUnit * @param float range = 533.333 : search radius * @return table unfriendyUnits : table filled with unfriendly units */ - int GetUnfriendlyUnitsInRange(lua_State* L, Unit* unit) + int GetUnfriendlyUnitsInRange(Eluna* E, Unit* unit) { - float range = Eluna::CHECKVAL(L, 2, SIZE_OF_GRIDS); + float range = Eluna::CHECKVAL(E->L, 2, SIZE_OF_GRIDS); std::list list; Trinity::AnyUnfriendlyUnitInObjectRangeCheck checker(unit, unit, range); @@ -1078,17 +1078,17 @@ namespace LuaUnit ElunaUtil::ObjectGUIDCheck guidCheck(unit->GET_GUID()); list.remove_if(guidCheck); - lua_createtable(L, list.size(), 0); - int tbl = lua_gettop(L); + lua_createtable(E->L, list.size(), 0); + int tbl = lua_gettop(E->L); uint32 i = 0; for (std::list::const_iterator it = list.begin(); it != list.end(); ++it) { - Eluna::Push(L, *it); - lua_rawseti(L, tbl, ++i); + E->Push(*it); + lua_rawseti(E->L, tbl, ++i); } - lua_settop(L, tbl); + lua_settop(E->L, tbl); return 1; } @@ -1097,15 +1097,15 @@ namespace LuaUnit * * @return [Vehicle] vehicle */ - int GetVehicleKit(lua_State* L, Unit* unit) + int GetVehicleKit(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetVehicleKit()); + E->Push(unit->GetVehicleKit()); return 1; } - int GetVehicle(lua_State* L, Unit* unit) + int GetVehicle(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetVehicle()); + E->Push(unit->GetVehicle()); return 1; } @@ -1114,9 +1114,9 @@ namespace LuaUnit * * @return ObjectGuid critterGuid */ - int GetCritterGUID(lua_State* L, Unit* unit) + int GetCritterGUID(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetCritterGUID()); + E->Push(unit->GetCritterGUID()); return 1; } @@ -1141,13 +1141,13 @@ namespace LuaUnit * @param [UnitMoveType] type * @return float speed */ - int GetSpeed(lua_State* L, Unit* unit) + int GetSpeed(Eluna* E, Unit* unit) { - uint32 type = Eluna::CHECKVAL(L, 2); + uint32 type = Eluna::CHECKVAL(E->L, 2); if (type >= MAX_MOVE_TYPE) - return luaL_argerror(L, 2, "valid UnitMoveType expected"); + return luaL_argerror(E->L, 2, "valid UnitMoveType expected"); - Eluna::Push(L, unit->GetSpeed((UnitMoveType)type)); + E->Push(unit->GetSpeed((UnitMoveType)type)); return 1; } @@ -1183,9 +1183,9 @@ namespace LuaUnit * * @return [MovementGeneratorType] movementType */ - int GetMovementType(lua_State* L, Unit* unit) + int GetMovementType(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->GetMotionMaster()->GetCurrentMovementGeneratorType()); + E->Push(unit->GetMotionMaster()->GetCurrentMovementGeneratorType()); return 1; } @@ -1194,9 +1194,9 @@ namespace LuaUnit * * @param ObjectGuid guid : new owner guid */ - int SetOwnerGUID(lua_State* L, Unit* unit) + int SetOwnerGUID(Eluna* E, Unit* unit) { - ObjectGuid guid = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 2); unit->SetOwnerGUID(guid); return 0; @@ -1207,9 +1207,9 @@ namespace LuaUnit * * @param bool apply = true : true if set on, false if off */ - int SetPvP(lua_State* L, Unit* unit) + int SetPvP(Eluna* E, Unit* unit) { - bool apply = Eluna::CHECKVAL(L, 2, true); + bool apply = Eluna::CHECKVAL(E->L, 2, true); unit->SetPvP(apply); return 0; @@ -1227,11 +1227,11 @@ namespace LuaUnit * * @param [SheathState] sheathState : valid SheathState */ - int SetSheath(lua_State* L, Unit* unit) + int SetSheath(Eluna* E, Unit* unit) { - uint32 sheathed = Eluna::CHECKVAL(L, 2); + uint32 sheathed = Eluna::CHECKVAL(E->L, 2); if (sheathed >= MAX_SHEATH_STATE) - return luaL_argerror(L, 2, "valid SheathState expected"); + return luaL_argerror(E->L, 2, "valid SheathState expected"); unit->SetSheath((SheathState)sheathed); return 0; @@ -1242,9 +1242,9 @@ namespace LuaUnit * * @param string name : new name */ - int SetName(lua_State* L, Unit* unit) + int SetName(Eluna* E, Unit* unit) { - const char* name = Eluna::CHECKVAL(L, 2); + const char* name = Eluna::CHECKVAL(E->L, 2); if (std::string(name).length() > 0) unit->SetName(name); return 0; @@ -1273,14 +1273,14 @@ namespace LuaUnit * @param float rate * @param bool forced = false */ - int SetSpeed(lua_State* L, Unit* unit) + int SetSpeed(Eluna* E, Unit* unit) { - uint32 type = Eluna::CHECKVAL(L, 2); - float rate = Eluna::CHECKVAL(L, 3); - bool forced = Eluna::CHECKVAL(L, 4, false); + uint32 type = Eluna::CHECKVAL(E->L, 2); + float rate = Eluna::CHECKVAL(E->L, 3); + bool forced = Eluna::CHECKVAL(E->L, 4, false); (void)forced; // ensure that the variable is referenced in order to pass compiler checks if (type >= MAX_MOVE_TYPE) - return luaL_argerror(L, 2, "valid UnitMoveType expected"); + return luaL_argerror(E->L, 2, "valid UnitMoveType expected"); unit->SetSpeedRate((UnitMoveType)type, rate); return 0; @@ -1291,9 +1291,9 @@ namespace LuaUnit * * @param uint32 faction : new faction ID */ - int SetFaction(lua_State* L, Unit* unit) + int SetFaction(Eluna* E, Unit* unit) { - uint32 factionId = Eluna::CHECKVAL(L, 2); + uint32 factionId = Eluna::CHECKVAL(E->L, 2); unit->SetFaction(factionId); return 0; @@ -1304,12 +1304,12 @@ namespace LuaUnit * * @param uint8 level : new level */ - int SetLevel(lua_State* L, Unit* unit) + int SetLevel(Eluna* E, Unit* unit) { - uint8 newlevel = Eluna::CHECKVAL(L, 2); + uint8 newlevel = Eluna::CHECKVAL(E->L, 2); if (newlevel < 1) - return luaL_argerror(L, 2, "level cannot be below 1"); + return luaL_argerror(E->L, 2, "level cannot be below 1"); if (Player* player = unit->ToPlayer()) { @@ -1328,9 +1328,9 @@ namespace LuaUnit * * @param uint32 health : new health */ - int SetHealth(lua_State* L, Unit* unit) + int SetHealth(Eluna* E, Unit* unit) { - uint32 amt = Eluna::CHECKVAL(L, 2); + uint32 amt = Eluna::CHECKVAL(E->L, 2); unit->SetHealth(amt); return 0; } @@ -1340,9 +1340,9 @@ namespace LuaUnit * * @param uint32 maxHealth : new max health */ - int SetMaxHealth(lua_State* L, Unit* unit) + int SetMaxHealth(Eluna* E, Unit* unit) { - uint32 amt = Eluna::CHECKVAL(L, 2); + uint32 amt = Eluna::CHECKVAL(E->L, 2); unit->SetMaxHealth(amt); return 0; } @@ -1367,11 +1367,11 @@ namespace LuaUnit * @param uint32 amount : new power amount * @param int type = -1 : a valid power type from [Powers] or -1 for the [Unit]'s current power type */ - int SetPower(lua_State* L, Unit* unit) + int SetPower(Eluna* E, Unit* unit) { - uint32 amt = Eluna::CHECKVAL(L, 2); - int type = Eluna::CHECKVAL(L, 3, -1); - Powers power = PowerSelectorHelper(L, unit, type); + uint32 amt = Eluna::CHECKVAL(E->L, 2); + int type = Eluna::CHECKVAL(E->L, 3, -1); + Powers power = PowerSelectorHelper(E, unit, type); unit->SetPower(power, amt); return 0; @@ -1397,11 +1397,11 @@ namespace LuaUnit * @param int32 amount : amount to modify * @param int type = -1 : a valid power type from [Powers] or -1 for the [Unit]'s current power type */ - int ModifyPower(lua_State* L, Unit* unit) + int ModifyPower(Eluna* E, Unit* unit) { - int32 amt = Eluna::CHECKVAL(L, 2); - int type = Eluna::CHECKVAL(L, 3, -1); - Powers power = PowerSelectorHelper(L, unit, type); + int32 amt = Eluna::CHECKVAL(E->L, 2); + int type = Eluna::CHECKVAL(E->L, 3, -1); + Powers power = PowerSelectorHelper(E, unit, type); unit->ModifyPower(power, amt); return 0; @@ -1427,11 +1427,11 @@ namespace LuaUnit * @param int type = -1 : a valid power type from [Powers] or -1 for the [Unit]'s current power type * @param uint32 maxPower : new max power amount */ - int SetMaxPower(lua_State* L, Unit* unit) + int SetMaxPower(Eluna* E, Unit* unit) { - int type = Eluna::CHECKVAL(L, 2, -1); - uint32 amt = Eluna::CHECKVAL(L, 3); - Powers power = PowerSelectorHelper(L, unit, type); + int type = Eluna::CHECKVAL(E->L, 2, -1); + uint32 amt = Eluna::CHECKVAL(E->L, 3); + Powers power = PowerSelectorHelper(E, unit, type); unit->SetMaxPower(power, amt); return 0; @@ -1456,11 +1456,11 @@ namespace LuaUnit * * @param [Powers] type : a valid power type */ - int SetPowerType(lua_State* L, Unit* unit) + int SetPowerType(Eluna* E, Unit* unit) { - uint32 type = Eluna::CHECKVAL(L, 2); + uint32 type = Eluna::CHECKVAL(E->L, 2); if (type >= int(MAX_POWERS)) - return luaL_argerror(L, 2, "valid Powers expected"); + return luaL_argerror(E->L, 2, "valid Powers expected"); unit->SetPowerType((Powers)type); return 0; @@ -1471,9 +1471,9 @@ namespace LuaUnit * * @param uint32 displayId */ - int SetDisplayId(lua_State* L, Unit* unit) + int SetDisplayId(Eluna* E, Unit* unit) { - uint32 model = Eluna::CHECKVAL(L, 2); + uint32 model = Eluna::CHECKVAL(E->L, 2); unit->SetDisplayId(model); return 0; } @@ -1483,9 +1483,9 @@ namespace LuaUnit * * @param uint32 displayId */ - int SetNativeDisplayId(lua_State* L, Unit* unit) + int SetNativeDisplayId(Eluna* E, Unit* unit) { - uint32 model = Eluna::CHECKVAL(L, 2); + uint32 model = Eluna::CHECKVAL(E->L, 2); #ifndef CATA unit->SetNativeDisplayId(model); #else @@ -1499,9 +1499,9 @@ namespace LuaUnit * * @param uint32 orientation */ - int SetFacing(lua_State* L, Unit* unit) + int SetFacing(Eluna* E, Unit* unit) { - float o = Eluna::CHECKVAL(L, 2); + float o = Eluna::CHECKVAL(E->L, 2); unit->SetFacingTo(o); return 0; } @@ -1511,9 +1511,9 @@ namespace LuaUnit * * @param [WorldObject] target */ - int SetFacingToObject(lua_State* L, Unit* unit) + int SetFacingToObject(Eluna* E, Unit* unit) { - WorldObject* obj = Eluna::CHECKOBJ(L, 2); + WorldObject* obj = Eluna::CHECKOBJ(E->L, 2); unit->SetFacingToObject(obj); return 0; } @@ -1523,9 +1523,9 @@ namespace LuaUnit * * @param ObjectGuid guid */ - int SetCreatorGUID(lua_State* L, Unit* unit) + int SetCreatorGUID(Eluna* E, Unit* unit) { - ObjectGuid guid = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 2); unit->SetCreatorGUID(guid); return 0; @@ -1536,9 +1536,9 @@ namespace LuaUnit * * @param ObjectGuid guid */ - int SetPetGUID(lua_State* L, Unit* unit) + int SetPetGUID(Eluna* E, Unit* unit) { - ObjectGuid guid = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 2); unit->SetPetGUID(guid); return 0; @@ -1549,9 +1549,9 @@ namespace LuaUnit * * @param bool enable = true */ - int SetWaterWalk(lua_State* L, Unit* unit) + int SetWaterWalk(Eluna* E, Unit* unit) { - bool enable = Eluna::CHECKVAL(L, 2, true); + bool enable = Eluna::CHECKVAL(E->L, 2, true); unit->SetWaterWalking(enable); return 0; @@ -1562,9 +1562,9 @@ namespace LuaUnit * * @param uint8 state : stand state */ - int SetStandState(lua_State* L, Unit* unit) + int SetStandState(Eluna* E, Unit* unit) { - uint8 state = Eluna::CHECKVAL(L, 2); + uint8 state = Eluna::CHECKVAL(E->L, 2); unit->SetStandState(UnitStandStateType(state)); return 0; @@ -1575,9 +1575,9 @@ namespace LuaUnit * * @param [Unit] enemy : the [Unit] to start combat with */ - int SetInCombatWith(lua_State* L, Unit* unit) + int SetInCombatWith(Eluna* E, Unit* unit) { - Unit* enemy = Eluna::CHECKOBJ(L, 2); + Unit* enemy = Eluna::CHECKOBJ(E->L, 2); unit->SetInCombatWith(enemy); return 0; } @@ -1587,9 +1587,9 @@ namespace LuaUnit * * @param bool apply = true */ - int SetFFA(lua_State* L, Unit* unit) + int SetFFA(Eluna* E, Unit* unit) { - bool apply = Eluna::CHECKVAL(L, 2, true); + bool apply = Eluna::CHECKVAL(E->L, 2, true); if (apply) { @@ -1612,9 +1612,9 @@ namespace LuaUnit * * @param bool apply = true */ - int SetSanctuary(lua_State* L, Unit* unit) + int SetSanctuary(Eluna* E, Unit* unit) { - bool apply = Eluna::CHECKVAL(L, 2, true); + bool apply = Eluna::CHECKVAL(E->L, 2, true); if (apply) { @@ -1628,17 +1628,17 @@ namespace LuaUnit return 0; } - int SetCritterGUID(lua_State* L, Unit* unit) + int SetCritterGUID(Eluna* E, Unit* unit) { - ObjectGuid guid = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 2); unit->SetCritterGUID(guid); return 0; } - int SetStunned(lua_State* L, Unit* unit) + int SetStunned(Eluna* E, Unit* unit) { - bool apply = Eluna::CHECKVAL(L, 2, true); + bool apply = Eluna::CHECKVAL(E->L, 2, true); unit->SetControlled(apply, UNIT_STATE_STUNNED); return 0; } @@ -1648,9 +1648,9 @@ namespace LuaUnit * * @param bool apply = true */ - int SetRooted(lua_State* L, Unit* unit) + int SetRooted(Eluna* E, Unit* unit) { - bool apply = Eluna::CHECKVAL(L, 2, true); + bool apply = Eluna::CHECKVAL(E->L, 2, true); unit->SetControlled(apply, UNIT_STATE_ROOT); return 0; @@ -1661,9 +1661,9 @@ namespace LuaUnit * * @param bool apply = true */ - int SetConfused(lua_State* L, Unit* unit) + int SetConfused(Eluna* E, Unit* unit) { - bool apply = Eluna::CHECKVAL(L, 2, true); + bool apply = Eluna::CHECKVAL(E->L, 2, true); unit->SetControlled(apply, UNIT_STATE_CONFUSED); return 0; @@ -1674,25 +1674,25 @@ namespace LuaUnit * * @param bool apply = true */ - int SetFeared(lua_State* L, Unit* unit) + int SetFeared(Eluna* E, Unit* unit) { - bool apply = Eluna::CHECKVAL(L, 2, true); + bool apply = Eluna::CHECKVAL(E->L, 2, true); unit->SetControlled(apply, UNIT_STATE_FLEEING); return 0; } - int SetCanFly(lua_State* L, Unit* unit) + int SetCanFly(Eluna* E, Unit* unit) { - bool apply = Eluna::CHECKVAL(L, 2, true); + bool apply = Eluna::CHECKVAL(E->L, 2, true); unit->SetCanFly(apply); return 0; } - int SetVisible(lua_State* L, Unit* unit) + int SetVisible(Eluna* E, Unit* unit) { - bool x = Eluna::CHECKVAL(L, 2, true); + bool x = Eluna::CHECKVAL(E->L, 2, true); unit->SetVisible(x); return 0; @@ -1701,7 +1701,7 @@ namespace LuaUnit /** * Clears the [Unit]'s threat list. */ - int ClearThreatList(lua_State* /*L*/, Unit* unit) + int ClearThreatList(Eluna* /*E*/, Unit* unit) { unit->GetThreatManager().ClearAllThreat(); return 0; @@ -1712,9 +1712,9 @@ namespace LuaUnit * * @param uint32 displayId */ - int Mount(lua_State* L, Unit* unit) + int Mount(Eluna* E, Unit* unit) { - uint32 displayId = Eluna::CHECKVAL(L, 2); + uint32 displayId = Eluna::CHECKVAL(E->L, 2); unit->Mount(displayId); return 0; @@ -1723,7 +1723,7 @@ namespace LuaUnit /** * Dismounts the [Unit]. */ - int Dismount(lua_State* /*L*/, Unit* unit) + int Dismount(Eluna* /*E*/, Unit* unit) { if (unit->IsMounted()) { @@ -1739,9 +1739,9 @@ namespace LuaUnit * * @param uint32 emoteId */ - int PerformEmote(lua_State* L, Unit* unit) + int PerformEmote(Eluna* E, Unit* unit) { - Emote emote = static_cast(Eluna::CHECKVAL(L, 2)); + Emote emote = static_cast(Eluna::CHECKVAL(E->L, 2)); unit->HandleEmoteCommand(emote); return 0; } @@ -1751,9 +1751,9 @@ namespace LuaUnit * * @param uint32 emoteId */ - int EmoteState(lua_State* L, Unit* unit) + int EmoteState(Eluna* E, Unit* unit) { - uint32 emoteId = Eluna::CHECKVAL(L, 2); + uint32 emoteId = Eluna::CHECKVAL(E->L, 2); unit->SetUInt32Value(UNIT_NPC_EMOTESTATE, emoteId); return 0; @@ -1764,9 +1764,9 @@ namespace LuaUnit * * @return int32 percentage */ - int CountPctFromCurHealth(lua_State* L, Unit* unit) + int CountPctFromCurHealth(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->CountPctFromCurHealth(Eluna::CHECKVAL(L, 2))); + E->Push(unit->CountPctFromCurHealth(Eluna::CHECKVAL(E->L, 2))); return 1; } @@ -1775,9 +1775,9 @@ namespace LuaUnit * * @return int32 percentage */ - int CountPctFromMaxHealth(lua_State* L, Unit* unit) + int CountPctFromMaxHealth(Eluna* E, Unit* unit) { - Eluna::Push(L, unit->CountPctFromMaxHealth(Eluna::CHECKVAL(L, 2))); + E->Push(unit->CountPctFromMaxHealth(Eluna::CHECKVAL(E->L, 2))); return 1; } @@ -1789,17 +1789,17 @@ namespace LuaUnit * @param string msg * @param [Player] target */ - int SendChatMessageToPlayer(lua_State* L, Unit* unit) + int SendChatMessageToPlayer(Eluna* E, Unit* unit) { - uint8 type = Eluna::CHECKVAL(L, 2); - uint32 lang = Eluna::CHECKVAL(L, 3); - std::string msg = Eluna::CHECKVAL(L, 4); - Player* target = Eluna::CHECKOBJ(L, 5); + uint8 type = Eluna::CHECKVAL(E->L, 2); + uint32 lang = Eluna::CHECKVAL(E->L, 3); + std::string msg = Eluna::CHECKVAL(E->L, 4); + Player* target = Eluna::CHECKOBJ(E->L, 5); if (type >= MAX_CHAT_MSG_TYPE) - return luaL_argerror(L, 2, "valid ChatMsg expected"); + return luaL_argerror(E->L, 2, "valid ChatMsg expected"); if (lang >= LANGUAGES_COUNT) - return luaL_argerror(L, 3, "valid Language expected"); + return luaL_argerror(E->L, 3, "valid Language expected"); WorldPacket data; ChatHandler::BuildChatPacket(data, ChatMsg(type), Language(lang), unit, target, msg); @@ -1811,7 +1811,7 @@ namespace LuaUnit /** * Stops the [Unit]'s movement */ - int MoveStop(lua_State* /*L*/, Unit* unit) + int MoveStop(Eluna* /*E*/, Unit* unit) { unit->StopMoving(); return 0; @@ -1822,9 +1822,8 @@ namespace LuaUnit * * @param bool reset = true : cleans movement */ - int MoveExpire(lua_State* L, Unit* unit) + int MoveExpire(Eluna* /*E*/, Unit* unit) { - (void) L; // ensure that the variable is referenced in order to pass compiler checks unit->GetMotionMaster()->Clear(); return 0; } @@ -1834,9 +1833,8 @@ namespace LuaUnit * * @param bool reset = true : clean movement */ - int MoveClear(lua_State* L, Unit* unit) + int MoveClear(Eluna* /*E*/, Unit* unit) { - (void) L; // ensure that the variable is referenced in order to pass compiler checks unit->GetMotionMaster()->Clear(); return 0; } @@ -1844,7 +1842,7 @@ namespace LuaUnit /** * The [Unit] will be idle */ - int MoveIdle(lua_State* /*L*/, Unit* unit) + int MoveIdle(Eluna* /*E*/, Unit* unit) { unit->GetMotionMaster()->MoveIdle(); return 0; @@ -1855,9 +1853,9 @@ namespace LuaUnit * * @param float radius : limit on how far the [Unit] will move at random */ - int MoveRandom(lua_State* L, Unit* unit) + int MoveRandom(Eluna* E, Unit* unit) { - float radius = Eluna::CHECKVAL(L, 2); + float radius = Eluna::CHECKVAL(E->L, 2); float x, y, z; unit->GetPosition(x, y, z); unit->GetMotionMaster()->MoveRandom(radius); @@ -1867,7 +1865,7 @@ namespace LuaUnit /** * The [Unit] will move to its set home location */ - int MoveHome(lua_State* /*L*/, Unit* unit) + int MoveHome(Eluna* /*E*/, Unit* unit) { unit->GetMotionMaster()->MoveTargetedHome(); return 0; @@ -1880,11 +1878,11 @@ namespace LuaUnit * @param float dist = 0 : distance to start following * @param float angle = 0 */ - int MoveFollow(lua_State* L, Unit* unit) + int MoveFollow(Eluna* E, Unit* unit) { - Unit* target = Eluna::CHECKOBJ(L, 2); - float dist = Eluna::CHECKVAL(L, 3, 0.0f); - float angle = Eluna::CHECKVAL(L, 4, 0.0f); + Unit* target = Eluna::CHECKOBJ(E->L, 2); + float dist = Eluna::CHECKVAL(E->L, 3, 0.0f); + float angle = Eluna::CHECKVAL(E->L, 4, 0.0f); unit->GetMotionMaster()->MoveFollow(target, dist, angle); return 0; } @@ -1896,11 +1894,11 @@ namespace LuaUnit * @param float dist = 0 : distance start chasing * @param float angle = 0 */ - int MoveChase(lua_State* L, Unit* unit) + int MoveChase(Eluna* E, Unit* unit) { - Unit* target = Eluna::CHECKOBJ(L, 2); - float dist = Eluna::CHECKVAL(L, 3, 0.0f); - float angle = Eluna::CHECKVAL(L, 4, 0.0f); + Unit* target = Eluna::CHECKOBJ(E->L, 2); + float dist = Eluna::CHECKVAL(E->L, 3, 0.0f); + float angle = Eluna::CHECKVAL(E->L, 4, 0.0f); unit->GetMotionMaster()->MoveChase(target, dist, angle); return 0; } @@ -1908,7 +1906,7 @@ namespace LuaUnit /** * The [Unit] will move confused */ - int MoveConfused(lua_State* /*L*/, Unit* unit) + int MoveConfused(Eluna* /*E*/, Unit* unit) { unit->GetMotionMaster()->MoveConfused(); return 0; @@ -1920,10 +1918,10 @@ namespace LuaUnit * @param [Unit] target * @param uint32 time = 0 : flee delay */ - int MoveFleeing(lua_State* L, Unit* unit) + int MoveFleeing(Eluna* E, Unit* unit) { - Unit* target = Eluna::CHECKOBJ(L, 2); - uint32 time = Eluna::CHECKVAL(L, 3, 0); + Unit* target = Eluna::CHECKOBJ(E->L, 2); + uint32 time = Eluna::CHECKVAL(E->L, 3, 0); unit->GetMotionMaster()->MoveFleeing(target, time); return 0; } @@ -1937,13 +1935,13 @@ namespace LuaUnit * @param float z * @param bool genPath = true : if true, generates path */ - int MoveTo(lua_State* L, Unit* unit) + int MoveTo(Eluna* E, Unit* unit) { - uint32 id = Eluna::CHECKVAL(L, 2); - float x = Eluna::CHECKVAL(L, 3); - float y = Eluna::CHECKVAL(L, 4); - float z = Eluna::CHECKVAL(L, 5); - bool genPath = Eluna::CHECKVAL(L, 6, true); + uint32 id = Eluna::CHECKVAL(E->L, 2); + float x = Eluna::CHECKVAL(E->L, 3); + float y = Eluna::CHECKVAL(E->L, 4); + float z = Eluna::CHECKVAL(E->L, 5); + bool genPath = Eluna::CHECKVAL(E->L, 6, true); unit->GetMotionMaster()->MovePoint(id, x, y, z, genPath); return 0; @@ -1959,14 +1957,14 @@ namespace LuaUnit * @param float maxHeight : maximum height * @param uint32 id = 0 : unique movement Id */ - int MoveJump(lua_State* L, Unit* unit) + int MoveJump(Eluna* E, Unit* unit) { - float x = Eluna::CHECKVAL(L, 2); - float y = Eluna::CHECKVAL(L, 3); - float z = Eluna::CHECKVAL(L, 4); - float zSpeed = Eluna::CHECKVAL(L, 5); - float maxHeight = Eluna::CHECKVAL(L, 6); - uint32 id = Eluna::CHECKVAL(L, 7, 0); + float x = Eluna::CHECKVAL(E->L, 2); + float y = Eluna::CHECKVAL(E->L, 3); + float z = Eluna::CHECKVAL(E->L, 4); + float zSpeed = Eluna::CHECKVAL(E->L, 5); + float maxHeight = Eluna::CHECKVAL(E->L, 6); + uint32 id = Eluna::CHECKVAL(E->L, 7, 0); Position pos(x, y, z); @@ -1982,13 +1980,13 @@ namespace LuaUnit * @param [Player] receiver : specific [Unit] to receive the message * @param bool bossWhisper = false : is a boss whisper */ - int SendUnitWhisper(lua_State* L, Unit* unit) + int SendUnitWhisper(Eluna* E, Unit* unit) { - const char* msg = Eluna::CHECKVAL(L, 2); - uint32 lang = Eluna::CHECKVAL(L, 3); + const char* msg = Eluna::CHECKVAL(E->L, 2); + uint32 lang = Eluna::CHECKVAL(E->L, 3); (void)lang; // ensure that the variable is referenced in order to pass compiler checks - Player* receiver = Eluna::CHECKOBJ(L, 4); - bool bossWhisper = Eluna::CHECKVAL(L, 5, false); + Player* receiver = Eluna::CHECKOBJ(E->L, 4); + bool bossWhisper = Eluna::CHECKVAL(E->L, 5, false); if (std::string(msg).length() > 0) unit->Whisper(msg, (Language)lang, receiver, bossWhisper); @@ -2003,11 +2001,11 @@ namespace LuaUnit * @param [Unit] receiver = nil : specific [Unit] to receive the message * @param bool bossEmote = false : is a boss emote */ - int SendUnitEmote(lua_State* L, Unit* unit) + int SendUnitEmote(Eluna* E, Unit* unit) { - const char* msg = Eluna::CHECKVAL(L, 2); - Unit* receiver = Eluna::CHECKOBJ(L, 3, false); - bool bossEmote = Eluna::CHECKVAL(L, 4, false); + const char* msg = Eluna::CHECKVAL(E->L, 2); + Unit* receiver = Eluna::CHECKOBJ(E->L, 3, false); + bool bossEmote = Eluna::CHECKVAL(E->L, 4, false); if (std::string(msg).length() > 0) unit->TextEmote(msg, receiver, bossEmote); @@ -2021,10 +2019,10 @@ namespace LuaUnit * @param string msg : message for the [Unit] to say * @param uint32 language : language for the [Unit] to speak */ - int SendUnitSay(lua_State* L, Unit* unit) + int SendUnitSay(Eluna* E, Unit* unit) { - const char* msg = Eluna::CHECKVAL(L, 2); - uint32 language = Eluna::CHECKVAL(L, 3); + const char* msg = Eluna::CHECKVAL(E->L, 2); + uint32 language = Eluna::CHECKVAL(E->L, 3); if (std::string(msg).length() > 0) unit->Say(msg, (Language)language, unit); @@ -2038,10 +2036,10 @@ namespace LuaUnit * @param string msg : message for the [Unit] to yell * @param uint32 language : language for the [Unit] to speak */ - int SendUnitYell(lua_State* L, Unit* unit) + int SendUnitYell(Eluna* E, Unit* unit) { - const char* msg = Eluna::CHECKVAL(L, 2); - uint32 language = Eluna::CHECKVAL(L, 3); + const char* msg = Eluna::CHECKVAL(E->L, 2); + uint32 language = Eluna::CHECKVAL(E->L, 3); if (std::string(msg).length() > 0) unit->Yell(msg, (Language)language, unit); @@ -2052,7 +2050,7 @@ namespace LuaUnit /** * Unmorphs the [Unit] setting it's display ID back to the native display ID. */ - int DeMorph(lua_State* /*L*/, Unit* unit) + int DeMorph(Eluna* /*E*/, Unit* unit) { unit->DeMorph(); return 0; @@ -2065,11 +2063,11 @@ namespace LuaUnit * @param uint32 spell : entry of a spell * @param bool triggered = false : if true the spell is instant and has no cost */ - int CastSpell(lua_State* L, Unit* unit) + int CastSpell(Eluna* E, Unit* unit) { - Unit* target = Eluna::CHECKOBJ(L, 2, false); - uint32 spell = Eluna::CHECKVAL(L, 3); - bool triggered = Eluna::CHECKVAL(L, 4, false); + Unit* target = Eluna::CHECKOBJ(E->L, 2, false); + uint32 spell = Eluna::CHECKVAL(E->L, 3); + bool triggered = Eluna::CHECKVAL(E->L, 4, false); SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spell); if (!spellEntry) @@ -2092,19 +2090,19 @@ namespace LuaUnit * @param [Item] castItem = nil * @param ObjectGuid originalCaster = ObjectGuid() */ - int CastCustomSpell(lua_State* L, Unit* unit) + int CastCustomSpell(Eluna* E, Unit* unit) { - Unit* target = Eluna::CHECKOBJ(L, 2, false); - uint32 spell = Eluna::CHECKVAL(L, 3); - bool triggered = Eluna::CHECKVAL(L, 4, false); - bool has_bp0 = !lua_isnoneornil(L, 5); - int32 bp0 = Eluna::CHECKVAL(L, 5, 0); - bool has_bp1 = !lua_isnoneornil(L, 6); - int32 bp1 = Eluna::CHECKVAL(L, 6, 0); - bool has_bp2 = !lua_isnoneornil(L, 7); - int32 bp2 = Eluna::CHECKVAL(L, 7, 0); - Item* castItem = Eluna::CHECKOBJ(L, 8, false); - ObjectGuid originalCaster = Eluna::CHECKVAL(L, 9, ObjectGuid()); + Unit* target = Eluna::CHECKOBJ(E->L, 2, false); + uint32 spell = Eluna::CHECKVAL(E->L, 3); + bool triggered = Eluna::CHECKVAL(E->L, 4, false); + bool has_bp0 = !lua_isnoneornil(E->L, 5); + int32 bp0 = Eluna::CHECKVAL(E->L, 5, 0); + bool has_bp1 = !lua_isnoneornil(E->L, 6); + int32 bp1 = Eluna::CHECKVAL(E->L, 6, 0); + bool has_bp2 = !lua_isnoneornil(E->L, 7); + int32 bp2 = Eluna::CHECKVAL(E->L, 7, 0); + Item* castItem = Eluna::CHECKOBJ(E->L, 8, false); + ObjectGuid originalCaster = Eluna::CHECKVAL(E->L, 9, ObjectGuid()); CastSpellExtraArgs args; if (has_bp0) @@ -2133,13 +2131,13 @@ namespace LuaUnit * @param uint32 spell : entry of a spell * @param bool triggered = true : if true the spell is instant and has no cost */ - int CastSpellAoF(lua_State* L, Unit* unit) + int CastSpellAoF(Eluna* E, Unit* unit) { - float _x = Eluna::CHECKVAL(L, 2); - float _y = Eluna::CHECKVAL(L, 3); - float _z = Eluna::CHECKVAL(L, 4); - uint32 spell = Eluna::CHECKVAL(L, 5); - bool triggered = Eluna::CHECKVAL(L, 6, true); + float _x = Eluna::CHECKVAL(E->L, 2); + float _y = Eluna::CHECKVAL(E->L, 3); + float _z = Eluna::CHECKVAL(E->L, 4); + uint32 spell = Eluna::CHECKVAL(E->L, 5); + bool triggered = Eluna::CHECKVAL(E->L, 6, true); CastSpellExtraArgs args; if (triggered) @@ -2152,7 +2150,7 @@ namespace LuaUnit /** * Clears the [Unit]'s combat */ - int ClearInCombat(lua_State* /*L*/, Unit* unit) + int ClearInCombat(Eluna* /*E*/, Unit* unit) { unit->ClearInCombat(); return 0; @@ -2163,9 +2161,9 @@ namespace LuaUnit * * @param uint32 spell = 0 : entry of a spell */ - int StopSpellCast(lua_State* L, Unit* unit) + int StopSpellCast(Eluna* E, Unit* unit) { - uint32 spellId = Eluna::CHECKVAL(L, 2, 0); + uint32 spellId = Eluna::CHECKVAL(E->L, 2, 0); unit->CastStop(spellId); return 0; } @@ -2178,10 +2176,10 @@ namespace LuaUnit * @param int32 spellType : type of spell to interrupt * @param bool delayed = true : skips if the spell is delayed */ - int InterruptSpell(lua_State* L, Unit* unit) + int InterruptSpell(Eluna* E, Unit* unit) { - int spellType = Eluna::CHECKVAL(L, 2); - bool delayed = Eluna::CHECKVAL(L, 3, true); + int spellType = Eluna::CHECKVAL(E->L, 2); + bool delayed = Eluna::CHECKVAL(E->L, 3, true); switch (spellType) { case 0: @@ -2197,7 +2195,7 @@ namespace LuaUnit spellType = CURRENT_AUTOREPEAT_SPELL; break; default: - return luaL_argerror(L, 2, "valid CurrentSpellTypes expected"); + return luaL_argerror(E->L, 2, "valid CurrentSpellTypes expected"); } unit->InterruptSpell((CurrentSpellTypes)spellType, delayed); @@ -2211,16 +2209,16 @@ namespace LuaUnit * @param [Unit] target : aura will be applied on the target * @return [Aura] aura */ - int AddAura(lua_State* L, Unit* unit) + int AddAura(Eluna* E, Unit* unit) { - uint32 spell = Eluna::CHECKVAL(L, 2); - Unit* target = Eluna::CHECKOBJ(L, 3); + uint32 spell = Eluna::CHECKVAL(E->L, 2); + Unit* target = Eluna::CHECKOBJ(E->L, 3); SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spell); if (!spellEntry) return 1; - Eluna::Push(L, unit->AddAura(spell, target)); + E->Push(unit->AddAura(spell, target)); return 1; } @@ -2229,9 +2227,9 @@ namespace LuaUnit * * @param uint32 spell : entry of a spell */ - int RemoveAura(lua_State* L, Unit* unit) + int RemoveAura(Eluna* E, Unit* unit) { - uint32 spellId = Eluna::CHECKVAL(L, 2); + uint32 spellId = Eluna::CHECKVAL(E->L, 2); unit->RemoveAurasDueToSpell(spellId); return 0; } @@ -2241,7 +2239,7 @@ namespace LuaUnit * * Note: talents and racials are also auras, use with caution */ - int RemoveAllAuras(lua_State* /*L*/, Unit* unit) + int RemoveAllAuras(Eluna* /*E*/, Unit* unit) { unit->RemoveAllAuras(); return 0; @@ -2250,7 +2248,7 @@ namespace LuaUnit /** * Removes all positive visible [Aura]'s from the [Unit]. */ - int RemoveArenaAuras(lua_State* /*L*/, Unit* unit) + int RemoveArenaAuras(Eluna* /*E*/, Unit* unit) { unit->RemoveArenaAuras(); return 0; @@ -2261,9 +2259,9 @@ namespace LuaUnit * * @param [UnitState] state */ - int AddUnitState(lua_State* L, Unit* unit) + int AddUnitState(Eluna* E, Unit* unit) { - uint32 state = Eluna::CHECKVAL(L, 2); + uint32 state = Eluna::CHECKVAL(E->L, 2); unit->AddUnitState(state); return 0; @@ -2274,9 +2272,9 @@ namespace LuaUnit * * @param [UnitState] state */ - int ClearUnitState(lua_State* L, Unit* unit) + int ClearUnitState(Eluna* E, Unit* unit) { - uint32 state = Eluna::CHECKVAL(L, 2); + uint32 state = Eluna::CHECKVAL(E->L, 2); unit->ClearUnitState(state); return 0; @@ -2290,12 +2288,12 @@ namespace LuaUnit * @param float z * @param float o : orientation */ - int NearTeleport(lua_State* L, Unit* unit) + int NearTeleport(Eluna* E, Unit* unit) { - float x = Eluna::CHECKVAL(L, 2); - float y = Eluna::CHECKVAL(L, 3); - float z = Eluna::CHECKVAL(L, 4); - float o = Eluna::CHECKVAL(L, 5); + float x = Eluna::CHECKVAL(E->L, 2); + float y = Eluna::CHECKVAL(E->L, 3); + float z = Eluna::CHECKVAL(E->L, 4); + float o = Eluna::CHECKVAL(E->L, 5); unit->NearTeleportTo(x, y, z, o); return 0; @@ -2324,15 +2322,15 @@ namespace LuaUnit * @param [SpellSchools] school = MAX_SPELL_SCHOOL : school the damage is done in or MAX_SPELL_SCHOOL for direct damage * @param uint32 spell = 0 : spell that inflicts the damage */ - int DealDamage(lua_State* L, Unit* unit) + int DealDamage(Eluna* E, Unit* unit) { - Unit* target = Eluna::CHECKOBJ(L, 2); - uint32 damage = Eluna::CHECKVAL(L, 3); - bool durabilityloss = Eluna::CHECKVAL(L, 4, true); - uint32 school = Eluna::CHECKVAL(L, 5, MAX_SPELL_SCHOOL); - uint32 spell = Eluna::CHECKVAL(L, 6, 0); + Unit* target = Eluna::CHECKOBJ(E->L, 2); + uint32 damage = Eluna::CHECKVAL(E->L, 3); + bool durabilityloss = Eluna::CHECKVAL(E->L, 4, true); + uint32 school = Eluna::CHECKVAL(E->L, 5, MAX_SPELL_SCHOOL); + uint32 spell = Eluna::CHECKVAL(E->L, 6, 0); if (school > MAX_SPELL_SCHOOL) - return luaL_argerror(L, 6, "valid SpellSchool expected"); + return luaL_argerror(E->L, 6, "valid SpellSchool expected"); // flat melee damage without resistence/etc reduction if (school == MAX_SPELL_SCHOOL) @@ -2390,12 +2388,12 @@ namespace LuaUnit * @param uint32 amount : amount to heal * @param bool critical = false : if true, heal is logged as critical */ - int DealHeal(lua_State* L, Unit* unit) + int DealHeal(Eluna* E, Unit* unit) { - Unit* target = Eluna::CHECKOBJ(L, 2); - uint32 spell = Eluna::CHECKVAL(L, 3); - uint32 amount = Eluna::CHECKVAL(L, 4); - bool critical = Eluna::CHECKVAL(L, 5, false); + Unit* target = Eluna::CHECKOBJ(E->L, 2); + uint32 spell = Eluna::CHECKVAL(E->L, 3); + uint32 amount = Eluna::CHECKVAL(E->L, 4); + bool critical = Eluna::CHECKVAL(E->L, 5, false); if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell)) { @@ -2412,10 +2410,10 @@ namespace LuaUnit * @param [Unit] target : [Unit] to kill * @param bool durLoss = true : when true, the target's items suffer durability loss */ - int Kill(lua_State* L, Unit* unit) + int Kill(Eluna* E, Unit* unit) { - Unit* target = Eluna::CHECKOBJ(L, 2); - bool durLoss = Eluna::CHECKVAL(L, 3, true); + Unit* target = Eluna::CHECKOBJ(E->L, 2); + bool durLoss = Eluna::CHECKVAL(E->L, 3, true); Unit::Kill(unit, target, durLoss); return 0; @@ -2443,43 +2441,43 @@ namespace LuaUnit * @param [SpellSchoolMask] schoolMask = 0 : [SpellSchoolMask] of the threat causer * @param uint32 spell = 0 : spell entry used for threat */ - int AddThreat(lua_State* L, Unit* unit) + int AddThreat(Eluna* E, Unit* unit) { - Unit* victim = Eluna::CHECKOBJ(L, 2); - float threat = Eluna::CHECKVAL(L, 3, true); - uint32 spell = Eluna::CHECKVAL(L, 4, 0); + Unit* victim = Eluna::CHECKOBJ(E->L, 2); + float threat = Eluna::CHECKVAL(E->L, 3, true); + uint32 spell = Eluna::CHECKVAL(E->L, 4, 0); unit->GetThreatManager().AddThreat(victim, threat, spell ? sSpellMgr->GetSpellInfo(spell) : NULL, true, true); return 0; } - int RestoreDisplayId(lua_State* /*L*/, Unit* unit) + int RestoreDisplayId(Eluna* /*E*/, Unit* unit) { unit->RestoreDisplayId(); return 0; } - int RestoreFaction(lua_State* /*L*/, Unit* unit) + int RestoreFaction(Eluna* /*E*/, Unit* unit) { unit->RestoreFaction(); return 0; } - int RemoveBindSightAuras(lua_State* /*L*/, Unit* unit) + int RemoveBindSightAuras(Eluna* /*E*/, Unit* unit) { unit->RemoveBindSightAuras(); return 0; } - int RemoveCharmAuras(lua_State* /*L*/, Unit* unit) + int RemoveCharmAuras(Eluna* /*E*/, Unit* unit) { unit->RemoveCharmAuras(); return 0; } - int DisableMelee(lua_State* L, Unit* unit) + int DisableMelee(Eluna* E, Unit* unit) { - bool apply = Eluna::CHECKVAL(L, 2, true); + bool apply = Eluna::CHECKVAL(E->L, 2, true); if (apply) unit->AddUnitState(UNIT_STATE_CANNOT_AUTOATTACK); @@ -2489,14 +2487,14 @@ namespace LuaUnit return 0; } - /*int SummonGuardian(lua_State* L, Unit* unit) + /*int SummonGuardian(Eluna* E, Unit* unit) { - uint32 entry = Eluna::CHECKVAL(L, 2); - float x = Eluna::CHECKVAL(L, 3); - float y = Eluna::CHECKVAL(L, 4); - float z = Eluna::CHECKVAL(L, 5); - float o = Eluna::CHECKVAL(L, 6); - uint32 desp = Eluna::CHECKVAL(L, 7, 0); + uint32 entry = Eluna::CHECKVAL(E->L, 2); + float x = Eluna::CHECKVAL(E->L, 3); + float y = Eluna::CHECKVAL(E->L, 4); + float z = Eluna::CHECKVAL(E->L, 5); + float o = Eluna::CHECKVAL(E->L, 6); + uint32 desp = Eluna::CHECKVAL(E->L, 7, 0); SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(61); if (!properties) @@ -2525,7 +2523,7 @@ namespace LuaUnit } summon->AI()->EnterEvadeMode(); - Eluna::Push(L, summon); + E->Push(summon); return 1; }*/ diff --git a/TrinityCore/VehicleMethods.h b/TrinityCore/VehicleMethods.h index 57f8372e69..995c681bee 100644 --- a/TrinityCore/VehicleMethods.h +++ b/TrinityCore/VehicleMethods.h @@ -18,11 +18,11 @@ namespace LuaVehicle * @param [Unit] passenger * @return bool isOnBoard */ - int IsOnBoard(lua_State* L, Vehicle* vehicle) + int IsOnBoard(Eluna* E, Vehicle* vehicle) { - Unit* passenger = Eluna::CHECKOBJ(L, 2); + Unit* passenger = Eluna::CHECKOBJ(E->L, 2); - Eluna::Push(L, passenger->IsOnVehicle(vehicle->GetBase())); + E->Push(passenger->IsOnVehicle(vehicle->GetBase())); return 1; } @@ -31,9 +31,9 @@ namespace LuaVehicle * * @return [Unit] owner */ - int GetOwner(lua_State* L, Vehicle* vehicle) + int GetOwner(Eluna* E, Vehicle* vehicle) { - Eluna::Push(L, vehicle->GetBase()); + E->Push(vehicle->GetBase()); return 1; } @@ -42,9 +42,9 @@ namespace LuaVehicle * * @return uint32 entry */ - int GetEntry(lua_State* L, Vehicle* vehicle) + int GetEntry(Eluna* E, Vehicle* vehicle) { - Eluna::Push(L, vehicle->GetVehicleInfo()->ID); + E->Push(vehicle->GetVehicleInfo()->ID); return 1; } @@ -54,10 +54,10 @@ namespace LuaVehicle * @param int8 seat * @return [Unit] passenger */ - int GetPassenger(lua_State* L, Vehicle* vehicle) + int GetPassenger(Eluna* E, Vehicle* vehicle) { - int8 seatId = Eluna::CHECKVAL(L, 2); - Eluna::Push(L, vehicle->GetPassenger(seatId)); + int8 seatId = Eluna::CHECKVAL(E->L, 2); + E->Push(vehicle->GetPassenger(seatId)); return 1; } @@ -67,10 +67,10 @@ namespace LuaVehicle * @param [Unit] passenger * @param int8 seat */ - int AddPassenger(lua_State* L, Vehicle* vehicle) + int AddPassenger(Eluna* E, Vehicle* vehicle) { - Unit* passenger = Eluna::CHECKOBJ(L, 2); - int8 seatId = Eluna::CHECKVAL(L, 3); + Unit* passenger = Eluna::CHECKOBJ(E->L, 2); + int8 seatId = Eluna::CHECKVAL(E->L, 3); #ifndef CATA vehicle->AddPassenger(passenger, seatId); @@ -85,9 +85,9 @@ namespace LuaVehicle * * @param [Unit] passenger */ - int RemovePassenger(lua_State* L, Vehicle* vehicle) + int RemovePassenger(Eluna* E, Vehicle* vehicle) { - Unit* passenger = Eluna::CHECKOBJ(L, 2); + Unit* passenger = Eluna::CHECKOBJ(E->L, 2); vehicle->RemovePassenger(passenger); return 0; diff --git a/TrinityCore/WorldObjectMethods.h b/TrinityCore/WorldObjectMethods.h index 03d9aa396c..502fffd792 100644 --- a/TrinityCore/WorldObjectMethods.h +++ b/TrinityCore/WorldObjectMethods.h @@ -17,9 +17,9 @@ namespace LuaWorldObject * * @return string name */ - int GetName(lua_State* L, WorldObject* obj) + int GetName(Eluna* E, WorldObject* obj) { - Eluna::Push(L, obj->GetName()); + E->Push(obj->GetName()); return 1; } @@ -28,9 +28,9 @@ namespace LuaWorldObject * * @return [Map] mapObject */ - int GetMap(lua_State* L, WorldObject* obj) + int GetMap(Eluna* E, WorldObject* obj) { - Eluna::Push(L, obj->GetMap()); + E->Push(obj->GetMap()); return 1; } @@ -39,13 +39,13 @@ namespace LuaWorldObject * * @return uint32 phase */ - int GetPhaseMask(lua_State* L, WorldObject* obj) + int GetPhaseMask(Eluna* E, WorldObject* obj) { #ifdef CATA EventMap event; - Eluna::Push(L, event.GetPhaseMask()); + E->Push(event.GetPhaseMask()); #else - Eluna::Push(L, obj->GetPhaseMask()); + E->Push(obj->GetPhaseMask()); #endif return 1; } @@ -56,14 +56,14 @@ namespace LuaWorldObject * @param uint32 phaseMask * @param bool update = true : update visibility to nearby objects */ - int SetPhaseMask(lua_State* L, WorldObject* obj) + int SetPhaseMask(Eluna* E, WorldObject* obj) { - uint32 phaseMask = Eluna::CHECKVAL(L, 2); + uint32 phaseMask = Eluna::CHECKVAL(E->L, 2); #ifdef CATA EventMap event; event.SetPhase(phaseMask); #else - bool update = Eluna::CHECKVAL(L, 3, true); + bool update = Eluna::CHECKVAL(E->L, 3, true); obj->SetPhaseMask(phaseMask, update); #endif return 0; @@ -74,9 +74,9 @@ namespace LuaWorldObject * * @return uint32 instanceId */ - int GetInstanceId(lua_State* L, WorldObject* obj) + int GetInstanceId(Eluna* E, WorldObject* obj) { - Eluna::Push(L, obj->GetInstanceId()); + E->Push(obj->GetInstanceId()); return 1; } @@ -85,9 +85,9 @@ namespace LuaWorldObject * * @return uint32 areaId */ - int GetAreaId(lua_State* L, WorldObject* obj) + int GetAreaId(Eluna* E, WorldObject* obj) { - Eluna::Push(L, obj->GetAreaId()); + E->Push(obj->GetAreaId()); return 1; } @@ -96,9 +96,9 @@ namespace LuaWorldObject * * @return uint32 zoneId */ - int GetZoneId(lua_State* L, WorldObject* obj) + int GetZoneId(Eluna* E, WorldObject* obj) { - Eluna::Push(L, obj->GetZoneId()); + E->Push(obj->GetZoneId()); return 1; } @@ -107,9 +107,9 @@ namespace LuaWorldObject * * @return uint32 mapId */ - int GetMapId(lua_State* L, WorldObject* obj) + int GetMapId(Eluna* E, WorldObject* obj) { - Eluna::Push(L, obj->GetMapId()); + E->Push(obj->GetMapId()); return 1; } @@ -118,9 +118,9 @@ namespace LuaWorldObject * * @return float x */ - int GetX(lua_State* L, WorldObject* obj) + int GetX(Eluna* E, WorldObject* obj) { - Eluna::Push(L, obj->GetPositionX()); + E->Push(obj->GetPositionX()); return 1; } @@ -129,9 +129,9 @@ namespace LuaWorldObject * * @return float y */ - int GetY(lua_State* L, WorldObject* obj) + int GetY(Eluna* E, WorldObject* obj) { - Eluna::Push(L, obj->GetPositionY()); + E->Push(obj->GetPositionY()); return 1; } @@ -140,9 +140,9 @@ namespace LuaWorldObject * * @return float z */ - int GetZ(lua_State* L, WorldObject* obj) + int GetZ(Eluna* E, WorldObject* obj) { - Eluna::Push(L, obj->GetPositionZ()); + E->Push(obj->GetPositionZ()); return 1; } @@ -151,9 +151,9 @@ namespace LuaWorldObject * * @return float orientation / facing */ - int GetO(lua_State* L, WorldObject* obj) + int GetO(Eluna* E, WorldObject* obj) { - Eluna::Push(L, obj->GetOrientation()); + E->Push(obj->GetOrientation()); return 1; } @@ -165,12 +165,12 @@ namespace LuaWorldObject * @return float z : z coordinate (height) of the [WorldObject] * @return float o : facing / orientation of the [WorldObject] */ - int GetLocation(lua_State* L, WorldObject* obj) + int GetLocation(Eluna* E, WorldObject* obj) { - Eluna::Push(L, obj->GetPositionX()); - Eluna::Push(L, obj->GetPositionY()); - Eluna::Push(L, obj->GetPositionZ()); - Eluna::Push(L, obj->GetOrientation()); + E->Push(obj->GetPositionX()); + E->Push(obj->GetPositionY()); + E->Push(obj->GetPositionZ()); + E->Push(obj->GetOrientation()); return 4; } @@ -183,18 +183,18 @@ namespace LuaWorldObject * * @return [Player] nearestPlayer */ - int GetNearestPlayer(lua_State* L, WorldObject* obj) + int GetNearestPlayer(Eluna* E, WorldObject* obj) { - float range = Eluna::CHECKVAL(L, 2, SIZE_OF_GRIDS); - uint32 hostile = Eluna::CHECKVAL(L, 3, 0); - uint32 dead = Eluna::CHECKVAL(L, 4, 1); + float range = Eluna::CHECKVAL(E->L, 2, SIZE_OF_GRIDS); + uint32 hostile = Eluna::CHECKVAL(E->L, 3, 0); + uint32 dead = Eluna::CHECKVAL(E->L, 4, 1); Unit* target = NULL; ElunaUtil::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_PLAYER, 0, hostile, dead); Trinity::UnitLastSearcher searcher(obj, target, checker); Cell::VisitAllObjects(obj, searcher, range); - Eluna::Push(L, target); + E->Push(target); return 1; } @@ -207,18 +207,18 @@ namespace LuaWorldObject * * @return [GameObject] nearestGameObject */ - int GetNearestGameObject(lua_State* L, WorldObject* obj) + int GetNearestGameObject(Eluna* E, WorldObject* obj) { - float range = Eluna::CHECKVAL(L, 2, SIZE_OF_GRIDS); - uint32 entry = Eluna::CHECKVAL(L, 3, 0); - uint32 hostile = Eluna::CHECKVAL(L, 4, 0); + float range = Eluna::CHECKVAL(E->L, 2, SIZE_OF_GRIDS); + uint32 entry = Eluna::CHECKVAL(E->L, 3, 0); + uint32 hostile = Eluna::CHECKVAL(E->L, 4, 0); GameObject* target = NULL; ElunaUtil::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_GAMEOBJECT, entry, hostile); Trinity::GameObjectLastSearcher searcher(obj, target, checker); Cell::VisitAllObjects(obj, searcher, range); - Eluna::Push(L, target); + E->Push(target); return 1; } @@ -232,19 +232,19 @@ namespace LuaWorldObject * * @return [Creature] nearestCreature */ - int GetNearestCreature(lua_State* L, WorldObject* obj) + int GetNearestCreature(Eluna* E, WorldObject* obj) { - float range = Eluna::CHECKVAL(L, 2, SIZE_OF_GRIDS); - uint32 entry = Eluna::CHECKVAL(L, 3, 0); - uint32 hostile = Eluna::CHECKVAL(L, 4, 0); - uint32 dead = Eluna::CHECKVAL(L, 5, 1); + float range = Eluna::CHECKVAL(E->L, 2, SIZE_OF_GRIDS); + uint32 entry = Eluna::CHECKVAL(E->L, 3, 0); + uint32 hostile = Eluna::CHECKVAL(E->L, 4, 0); + uint32 dead = Eluna::CHECKVAL(E->L, 5, 1); Creature* target = NULL; ElunaUtil::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_UNIT, entry, hostile, dead); Trinity::CreatureLastSearcher searcher(obj, target, checker); Cell::VisitAllObjects(obj, searcher, range); - Eluna::Push(L, target); + E->Push(target); return 1; } @@ -257,28 +257,28 @@ namespace LuaWorldObject * * @return table playersInRange : table of [Player]s */ - int GetPlayersInRange(lua_State* L, WorldObject* obj) + int GetPlayersInRange(Eluna* E, WorldObject* obj) { - float range = Eluna::CHECKVAL(L, 2, SIZE_OF_GRIDS); - uint32 hostile = Eluna::CHECKVAL(L, 3, 0); - uint32 dead = Eluna::CHECKVAL(L, 4, 1); + float range = Eluna::CHECKVAL(E->L, 2, SIZE_OF_GRIDS); + uint32 hostile = Eluna::CHECKVAL(E->L, 3, 0); + uint32 dead = Eluna::CHECKVAL(E->L, 4, 1); std::list list; ElunaUtil::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_PLAYER, 0, hostile, dead); Trinity::PlayerListSearcher searcher(obj, list, checker); Cell::VisitAllObjects(obj, searcher, range); - lua_createtable(L, list.size(), 0); - int tbl = lua_gettop(L); + lua_createtable(E->L, list.size(), 0); + int tbl = lua_gettop(E->L); uint32 i = 0; for (std::list::const_iterator it = list.begin(); it != list.end(); ++it) { - Eluna::Push(L, *it); - lua_rawseti(L, tbl, ++i); + E->Push(*it); + lua_rawseti(E->L, tbl, ++i); } - lua_settop(L, tbl); + lua_settop(E->L, tbl); return 1; } @@ -292,29 +292,29 @@ namespace LuaWorldObject * * @return table creaturesInRange : table of [Creature]s */ - int GetCreaturesInRange(lua_State* L, WorldObject* obj) + int GetCreaturesInRange(Eluna* E, WorldObject* obj) { - float range = Eluna::CHECKVAL(L, 2, SIZE_OF_GRIDS); - uint32 entry = Eluna::CHECKVAL(L, 3, 0); - uint32 hostile = Eluna::CHECKVAL(L, 4, 0); - uint32 dead = Eluna::CHECKVAL(L, 5, 1); + float range = Eluna::CHECKVAL(E->L, 2, SIZE_OF_GRIDS); + uint32 entry = Eluna::CHECKVAL(E->L, 3, 0); + uint32 hostile = Eluna::CHECKVAL(E->L, 4, 0); + uint32 dead = Eluna::CHECKVAL(E->L, 5, 1); std::list list; ElunaUtil::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_UNIT, entry, hostile, dead); Trinity::CreatureListSearcher searcher(obj, list, checker); Cell::VisitAllObjects(obj, searcher, range); - lua_createtable(L, list.size(), 0); - int tbl = lua_gettop(L); + lua_createtable(E->L, list.size(), 0); + int tbl = lua_gettop(E->L); uint32 i = 0; for (std::list::const_iterator it = list.begin(); it != list.end(); ++it) { - Eluna::Push(L, *it); - lua_rawseti(L, tbl, ++i); + E->Push(*it); + lua_rawseti(E->L, tbl, ++i); } - lua_settop(L, tbl); + lua_settop(E->L, tbl); return 1; } @@ -327,28 +327,28 @@ namespace LuaWorldObject * * @return table gameObjectsInRange : table of [GameObject]s */ - int GetGameObjectsInRange(lua_State* L, WorldObject* obj) + int GetGameObjectsInRange(Eluna* E, WorldObject* obj) { - float range = Eluna::CHECKVAL(L, 2, SIZE_OF_GRIDS); - uint32 entry = Eluna::CHECKVAL(L, 3, 0); - uint32 hostile = Eluna::CHECKVAL(L, 4, 0); + float range = Eluna::CHECKVAL(E->L, 2, SIZE_OF_GRIDS); + uint32 entry = Eluna::CHECKVAL(E->L, 3, 0); + uint32 hostile = Eluna::CHECKVAL(E->L, 4, 0); std::list list; ElunaUtil::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_GAMEOBJECT, entry, hostile); Trinity::GameObjectListSearcher searcher(obj, list, checker); Cell::VisitAllObjects(obj, searcher, range); - lua_createtable(L, list.size(), 0); - int tbl = lua_gettop(L); + lua_createtable(E->L, list.size(), 0); + int tbl = lua_gettop(E->L); uint32 i = 0; for (std::list::const_iterator it = list.begin(); it != list.end(); ++it) { - Eluna::Push(L, *it); - lua_rawseti(L, tbl, ++i); + E->Push(*it); + lua_rawseti(E->L, tbl, ++i); } - lua_settop(L, tbl); + lua_settop(E->L, tbl); return 1; } @@ -364,13 +364,13 @@ namespace LuaWorldObject * * @return [WorldObject] worldObject */ - int GetNearObject(lua_State* L, WorldObject* obj) + int GetNearObject(Eluna* E, WorldObject* obj) { - float range = Eluna::CHECKVAL(L, 2, SIZE_OF_GRIDS); - uint16 type = Eluna::CHECKVAL(L, 3, 0); // TypeMask - uint32 entry = Eluna::CHECKVAL(L, 4, 0); - uint32 hostile = Eluna::CHECKVAL(L, 5, 0); // 0 none, 1 hostile, 2 friendly - uint32 dead = Eluna::CHECKVAL(L, 6, 1); // 0 both, 1 alive, 2 dead + float range = Eluna::CHECKVAL(E->L, 2, SIZE_OF_GRIDS); + uint16 type = Eluna::CHECKVAL(E->L, 3, 0); // TypeMask + uint32 entry = Eluna::CHECKVAL(E->L, 4, 0); + uint32 hostile = Eluna::CHECKVAL(E->L, 5, 0); // 0 none, 1 hostile, 2 friendly + uint32 dead = Eluna::CHECKVAL(E->L, 6, 1); // 0 both, 1 alive, 2 dead float x, y, z; obj->GetPosition(x, y, z); @@ -380,7 +380,7 @@ namespace LuaWorldObject Trinity::WorldObjectLastSearcher searcher(obj, target, checker); Cell::VisitAllObjects(obj, searcher, range); - Eluna::Push(L, target); + E->Push(target); return 1; } @@ -396,13 +396,13 @@ namespace LuaWorldObject * * @return table worldObjectList : table of [WorldObject]s */ - int GetNearObjects(lua_State* L, WorldObject* obj) + int GetNearObjects(Eluna* E, WorldObject* obj) { - float range = Eluna::CHECKVAL(L, 2, SIZE_OF_GRIDS); - uint16 type = Eluna::CHECKVAL(L, 3, 0); // TypeMask - uint32 entry = Eluna::CHECKVAL(L, 4, 0); - uint32 hostile = Eluna::CHECKVAL(L, 5, 0); // 0 none, 1 hostile, 2 friendly - uint32 dead = Eluna::CHECKVAL(L, 6, 1); // 0 both, 1 alive, 2 dead + float range = Eluna::CHECKVAL(E->L, 2, SIZE_OF_GRIDS); + uint16 type = Eluna::CHECKVAL(E->L, 3, 0); // TypeMask + uint32 entry = Eluna::CHECKVAL(E->L, 4, 0); + uint32 hostile = Eluna::CHECKVAL(E->L, 5, 0); // 0 none, 1 hostile, 2 friendly + uint32 dead = Eluna::CHECKVAL(E->L, 6, 1); // 0 both, 1 alive, 2 dead float x, y, z; obj->GetPosition(x, y, z); @@ -412,17 +412,17 @@ namespace LuaWorldObject Trinity::WorldObjectListSearcher searcher(obj, list, checker); Cell::VisitAllObjects(obj, searcher, range); - lua_createtable(L, list.size(), 0); - int tbl = lua_gettop(L); + lua_createtable(E->L, list.size(), 0); + int tbl = lua_gettop(E->L); uint32 i = 0; for (std::list::const_iterator it = list.begin(); it != list.end(); ++it) { - Eluna::Push(L, *it); - lua_rawseti(L, tbl, ++i); + E->Push(*it); + lua_rawseti(E->L, tbl, ++i); } - lua_settop(L, tbl); + lua_settop(E->L, tbl); return 1; } @@ -441,17 +441,17 @@ namespace LuaWorldObject * * @return float dist : the distance in yards */ - int GetDistance(lua_State* L, WorldObject* obj) + int GetDistance(Eluna* E, WorldObject* obj) { - WorldObject* target = Eluna::CHECKOBJ(L, 2, false); + WorldObject* target = Eluna::CHECKOBJ(E->L, 2, false); if (target) - Eluna::Push(L, obj->GetDistance(target)); + E->Push(obj->GetDistance(target)); else { - float X = Eluna::CHECKVAL(L, 2); - float Y = Eluna::CHECKVAL(L, 3); - float Z = Eluna::CHECKVAL(L, 4); - Eluna::Push(L, obj->GetDistance(X, Y, Z)); + float X = Eluna::CHECKVAL(E->L, 2); + float Y = Eluna::CHECKVAL(E->L, 3); + float Z = Eluna::CHECKVAL(E->L, 4); + E->Push(obj->GetDistance(X, Y, Z)); } return 1; } @@ -471,11 +471,11 @@ namespace LuaWorldObject * * @return float dist : the distance in yards */ - int GetExactDistance(lua_State* L, WorldObject* obj) + int GetExactDistance(Eluna* E, WorldObject* obj) { float x, y, z; obj->GetPosition(x, y, z); - WorldObject* target = Eluna::CHECKOBJ(L, 2, false); + WorldObject* target = Eluna::CHECKOBJ(E->L, 2, false); if (target) { float x2, y2, z2; @@ -486,12 +486,12 @@ namespace LuaWorldObject } else { - x -= Eluna::CHECKVAL(L, 2); - y -= Eluna::CHECKVAL(L, 3); - z -= Eluna::CHECKVAL(L, 4); + x -= Eluna::CHECKVAL(E->L, 2); + y -= Eluna::CHECKVAL(E->L, 3); + z -= Eluna::CHECKVAL(E->L, 4); } - Eluna::Push(L, std::sqrt(x*x + y*y + z*z)); + E->Push(std::sqrt(x*x + y*y + z*z)); return 1; } @@ -509,16 +509,16 @@ namespace LuaWorldObject * * @return float dist : the distance in yards */ - int GetDistance2d(lua_State* L, WorldObject* obj) + int GetDistance2d(Eluna* E, WorldObject* obj) { - WorldObject* target = Eluna::CHECKOBJ(L, 2, false); + WorldObject* target = Eluna::CHECKOBJ(E->L, 2, false); if (target) - Eluna::Push(L, obj->GetDistance2d(target)); + E->Push(obj->GetDistance2d(target)); else { - float X = Eluna::CHECKVAL(L, 2); - float Y = Eluna::CHECKVAL(L, 3); - Eluna::Push(L, obj->GetDistance2d(X, Y)); + float X = Eluna::CHECKVAL(E->L, 2); + float Y = Eluna::CHECKVAL(E->L, 3); + E->Push(obj->GetDistance2d(X, Y)); } return 1; } @@ -537,11 +537,11 @@ namespace LuaWorldObject * * @return float dist : the distance in yards */ - int GetExactDistance2d(lua_State* L, WorldObject* obj) + int GetExactDistance2d(Eluna* E, WorldObject* obj) { float x, y, z; obj->GetPosition(x, y, z); - WorldObject* target = Eluna::CHECKOBJ(L, 2, false); + WorldObject* target = Eluna::CHECKOBJ(E->L, 2, false); if (target) { float x2, y2, z2; @@ -551,11 +551,11 @@ namespace LuaWorldObject } else { - x -= Eluna::CHECKVAL(L, 2); - y -= Eluna::CHECKVAL(L, 3); + x -= Eluna::CHECKVAL(E->L, 2); + y -= Eluna::CHECKVAL(E->L, 3); } - Eluna::Push(L, std::sqrt(x*x + y*y)); + E->Push(std::sqrt(x*x + y*y)); return 1; } @@ -569,17 +569,17 @@ namespace LuaWorldObject * @return float y * @return float z */ - int GetRelativePoint(lua_State* L, WorldObject* obj) + int GetRelativePoint(Eluna* E, WorldObject* obj) { - float dist = Eluna::CHECKVAL(L, 2); - float rad = Eluna::CHECKVAL(L, 3); + float dist = Eluna::CHECKVAL(E->L, 2); + float rad = Eluna::CHECKVAL(E->L, 3); float x, y, z; obj->GetClosePoint(x, y, z, 0.0f, dist, rad); - Eluna::Push(L, x); - Eluna::Push(L, y); - Eluna::Push(L, z); + E->Push(x); + E->Push(y); + E->Push(z); return 3; } @@ -597,26 +597,26 @@ namespace LuaWorldObject * * @return float angle : angle in radians in range 0..2*pi */ - int GetAngle(lua_State* L, WorldObject* obj) + int GetAngle(Eluna* E, WorldObject* obj) { - WorldObject* target = Eluna::CHECKOBJ(L, 2, false); + WorldObject* target = Eluna::CHECKOBJ(E->L, 2, false); #ifndef CATA if (target) - Eluna::Push(L, obj->GetAbsoluteAngle(target)); + E->Push(obj->GetAbsoluteAngle(target)); else { - float x = Eluna::CHECKVAL(L, 2); - float y = Eluna::CHECKVAL(L, 3); - Eluna::Push(L, obj->GetAbsoluteAngle(x, y)); + float x = Eluna::CHECKVAL(E->L, 2); + float y = Eluna::CHECKVAL(E->L, 3); + E->Push(obj->GetAbsoluteAngle(x, y)); } #else if (target) - Eluna::Push(L, obj->GetAngle(target)); + E->Push(obj->GetAngle(target)); else { - float x = Eluna::CHECKVAL(L, 2); - float y = Eluna::CHECKVAL(L, 3); - Eluna::Push(L, obj->GetAngle(x, y)); + float x = Eluna::CHECKVAL(E->L, 2); + float y = Eluna::CHECKVAL(E->L, 3); + E->Push(obj->GetAngle(x, y)); } #endif @@ -628,9 +628,9 @@ namespace LuaWorldObject * * @param [WorldPacket] packet */ - int SendPacket(lua_State* L, WorldObject* obj) + int SendPacket(Eluna* E, WorldObject* obj) { - WorldPacket* data = Eluna::CHECKOBJ(L, 2); + WorldPacket* data = Eluna::CHECKOBJ(E->L, 2); obj->SendMessageToSet(data, true); return 0; @@ -647,22 +647,22 @@ namespace LuaWorldObject * @param uint32 respawnDelay = 30 : respawn time in seconds * @return [GameObject] gameObject */ - int SummonGameObject(lua_State* L, WorldObject* obj) + int SummonGameObject(Eluna* E, WorldObject* obj) { - uint32 entry = Eluna::CHECKVAL(L, 2); - float x = Eluna::CHECKVAL(L, 3); - float y = Eluna::CHECKVAL(L, 4); - float z = Eluna::CHECKVAL(L, 5); - float o = Eluna::CHECKVAL(L, 6); - uint32 respawnDelay = Eluna::CHECKVAL(L, 7, 30); + uint32 entry = Eluna::CHECKVAL(E->L, 2); + float x = Eluna::CHECKVAL(E->L, 3); + float y = Eluna::CHECKVAL(E->L, 4); + float z = Eluna::CHECKVAL(E->L, 5); + float o = Eluna::CHECKVAL(E->L, 6); + uint32 respawnDelay = Eluna::CHECKVAL(E->L, 7, 30); #ifndef CATA QuaternionData rot = QuaternionData::fromEulerAnglesZYX(o, 0.f, 0.f); - Eluna::Push(L, obj->SummonGameObject(entry, Position(x, y, z, o), rot, Seconds(respawnDelay))); + E->Push(obj->SummonGameObject(entry, Position(x, y, z, o), rot, Seconds(respawnDelay))); #else QuaternionData rot = QuaternionData::fromEulerAnglesZYX(o, 0.f, 0.f); - Eluna::Push(L, obj->SummonGameObject(entry, x, y, z, o, rot, respawnDelay)); + E->Push(obj->SummonGameObject(entry, x, y, z, o, rot, respawnDelay)); #endif return 1; } @@ -693,15 +693,15 @@ namespace LuaWorldObject * @param uint32 despawnTimer = 0 : despawn time in milliseconds * @return [Creature] spawnedCreature */ - int SpawnCreature(lua_State* L, WorldObject* obj) + int SpawnCreature(Eluna* E, WorldObject* obj) { - uint32 entry = Eluna::CHECKVAL(L, 2); - float x = Eluna::CHECKVAL(L, 3); - float y = Eluna::CHECKVAL(L, 4); - float z = Eluna::CHECKVAL(L, 5); - float o = Eluna::CHECKVAL(L, 6); - uint32 spawnType = Eluna::CHECKVAL(L, 7, 8); - uint32 despawnTimer = Eluna::CHECKVAL(L, 8, 0); + uint32 entry = Eluna::CHECKVAL(E->L, 2); + float x = Eluna::CHECKVAL(E->L, 3); + float y = Eluna::CHECKVAL(E->L, 4); + float z = Eluna::CHECKVAL(E->L, 5); + float o = Eluna::CHECKVAL(E->L, 6); + uint32 spawnType = Eluna::CHECKVAL(E->L, 7, 8); + uint32 despawnTimer = Eluna::CHECKVAL(E->L, 8, 0); TempSummonType type; switch (spawnType) @@ -731,13 +731,13 @@ namespace LuaWorldObject type = TEMPSUMMON_MANUAL_DESPAWN; break; default: - return luaL_argerror(L, 7, "valid SpawnType expected"); + return luaL_argerror(E->L, 7, "valid SpawnType expected"); } #ifndef CATA - Eluna::Push(L, obj->SummonCreature(entry, x, y, z, o, type, Milliseconds(despawnTimer))); + E->Push(obj->SummonCreature(entry, x, y, z, o, type, Milliseconds(despawnTimer))); #else - Eluna::Push(L, obj->SummonCreature(entry, x, y, z, o, type, despawnTimer)); + E->Push(obj->SummonCreature(entry, x, y, z, o, type, despawnTimer)); #endif return 1; } @@ -767,33 +767,33 @@ namespace LuaWorldObject * @param uint32 repeats = 1 : how many times for the event to repeat, 0 is infinite * @return int eventId : unique ID for the timed event used to cancel it or nil */ - int RegisterEvent(lua_State* L, WorldObject* obj) + int RegisterEvent(Eluna* E, WorldObject* obj) { - luaL_checktype(L, 2, LUA_TFUNCTION); + luaL_checktype(E->L, 2, LUA_TFUNCTION); uint32 min, max; - if (lua_istable(L, 3)) + if (lua_istable(E->L, 3)) { - Eluna::Push(L, 1); - lua_gettable(L, 3); - min = Eluna::CHECKVAL(L, -1); - Eluna::Push(L, 2); - lua_gettable(L, 3); - max = Eluna::CHECKVAL(L, -1); - lua_pop(L, 2); + E->Push(1); + lua_gettable(E->L, 3); + min = Eluna::CHECKVAL(E->L, -1); + E->Push(2); + lua_gettable(E->L, 3); + max = Eluna::CHECKVAL(E->L, -1); + lua_pop(E->L, 2); } else - min = max = Eluna::CHECKVAL(L, 3); - uint32 repeats = Eluna::CHECKVAL(L, 4, 1); + min = max = Eluna::CHECKVAL(E->L, 3); + uint32 repeats = Eluna::CHECKVAL(E->L, 4, 1); if (min > max) - return luaL_argerror(L, 3, "min is bigger than max delay"); + return luaL_argerror(E->L, 3, "min is bigger than max delay"); - lua_pushvalue(L, 2); - int functionRef = luaL_ref(L, LUA_REGISTRYINDEX); + lua_pushvalue(E->L, 2); + int functionRef = luaL_ref(E->L, LUA_REGISTRYINDEX); if (functionRef != LUA_REFNIL && functionRef != LUA_NOREF) { obj->elunaEvents->AddEvent(functionRef, min, max, repeats); - Eluna::Push(L, functionRef); + E->Push(functionRef); } return 1; } @@ -803,9 +803,9 @@ namespace LuaWorldObject * * @param int eventId : event Id to remove */ - int RemoveEventById(lua_State* L, WorldObject* obj) + int RemoveEventById(Eluna* E, WorldObject* obj) { - int eventId = Eluna::CHECKVAL(L, 2); + int eventId = Eluna::CHECKVAL(E->L, 2); obj->elunaEvents->SetState(eventId, LUAEVENT_STATE_ABORT); return 0; } @@ -814,7 +814,7 @@ namespace LuaWorldObject * Removes all timed events from a [WorldObject] * */ - int RemoveEvents(lua_State* /*L*/, WorldObject* obj) + int RemoveEvents(Eluna* /*E*/, WorldObject* obj) { obj->elunaEvents->SetStates(LUAEVENT_STATE_ABORT); return 0; @@ -832,18 +832,18 @@ namespace LuaWorldObject * @param float z * @return bool isInLoS */ - int IsWithinLoS(lua_State* L, WorldObject* obj) + int IsWithinLoS(Eluna* E, WorldObject* obj) { - WorldObject* target = Eluna::CHECKOBJ(L, 2, false); + WorldObject* target = Eluna::CHECKOBJ(E->L, 2, false); if (target) - Eluna::Push(L, obj->IsWithinLOSInMap(target)); + E->Push(obj->IsWithinLOSInMap(target)); else { - float x = Eluna::CHECKVAL(L, 2); - float y = Eluna::CHECKVAL(L, 3); - float z = Eluna::CHECKVAL(L, 4); - Eluna::Push(L, obj->IsWithinLOS(x, y, z)); + float x = Eluna::CHECKVAL(E->L, 2); + float y = Eluna::CHECKVAL(E->L, 3); + float z = Eluna::CHECKVAL(E->L, 4); + E->Push(obj->IsWithinLOS(x, y, z)); } return 1; @@ -855,10 +855,10 @@ namespace LuaWorldObject * @param [WorldObject] worldobject * @return bool isInMap */ - int IsInMap(lua_State* L, WorldObject* obj) + int IsInMap(Eluna* E, WorldObject* obj) { - WorldObject* target = Eluna::CHECKOBJ(L, 2, true); - Eluna::Push(L, obj->IsInMap(target)); + WorldObject* target = Eluna::CHECKOBJ(E->L, 2, true); + E->Push(obj->IsInMap(target)); return 1; } @@ -873,13 +873,13 @@ namespace LuaWorldObject * @param float distance * @return bool isInDistance */ - int IsWithinDist3d(lua_State* L, WorldObject* obj) + int IsWithinDist3d(Eluna* E, WorldObject* obj) { - float x = Eluna::CHECKVAL(L, 2); - float y = Eluna::CHECKVAL(L, 3); - float z = Eluna::CHECKVAL(L, 4); - float dist = Eluna::CHECKVAL(L, 5); - Eluna::Push(L, obj->IsWithinDist3d(x, y, z, dist)); + float x = Eluna::CHECKVAL(E->L, 2); + float y = Eluna::CHECKVAL(E->L, 3); + float z = Eluna::CHECKVAL(E->L, 4); + float dist = Eluna::CHECKVAL(E->L, 5); + E->Push(obj->IsWithinDist3d(x, y, z, dist)); return 1; } @@ -894,12 +894,12 @@ namespace LuaWorldObject * @param float distance * @return bool isInDistance */ - int IsWithinDist2d(lua_State* L, WorldObject* obj) + int IsWithinDist2d(Eluna* E, WorldObject* obj) { - float x = Eluna::CHECKVAL(L, 2); - float y = Eluna::CHECKVAL(L, 3); - float dist = Eluna::CHECKVAL(L, 4); - Eluna::Push(L, obj->IsWithinDist2d(x, y, dist)); + float x = Eluna::CHECKVAL(E->L, 2); + float y = Eluna::CHECKVAL(E->L, 3); + float dist = Eluna::CHECKVAL(E->L, 4); + E->Push(obj->IsWithinDist2d(x, y, dist)); return 1; } @@ -913,12 +913,12 @@ namespace LuaWorldObject * @param bool is3D = true : if false, only x,y coordinates used for checking * @return bool isInDistance */ - int IsWithinDist(lua_State* L, WorldObject* obj) + int IsWithinDist(Eluna* E, WorldObject* obj) { - WorldObject* target = Eluna::CHECKOBJ(L, 2, true); - float distance = Eluna::CHECKVAL(L, 3); - bool is3D = Eluna::CHECKVAL(L, 4, true); - Eluna::Push(L, obj->IsWithinDist(target, distance, is3D)); + WorldObject* target = Eluna::CHECKOBJ(E->L, 2, true); + float distance = Eluna::CHECKVAL(E->L, 3); + bool is3D = Eluna::CHECKVAL(E->L, 4, true); + E->Push(obj->IsWithinDist(target, distance, is3D)); return 1; } @@ -932,13 +932,13 @@ namespace LuaWorldObject * @param bool is3D = true : if false, only x,y coordinates used for checking * @return bool isInDistance */ - int IsWithinDistInMap(lua_State* L, WorldObject* obj) + int IsWithinDistInMap(Eluna* E, WorldObject* obj) { - WorldObject* target = Eluna::CHECKOBJ(L, 2); - float distance = Eluna::CHECKVAL(L, 3); - bool is3D = Eluna::CHECKVAL(L, 4, true); + WorldObject* target = Eluna::CHECKOBJ(E->L, 2); + float distance = Eluna::CHECKVAL(E->L, 3); + bool is3D = Eluna::CHECKVAL(E->L, 4, true); - Eluna::Push(L, obj->IsWithinDistInMap(target, distance, is3D)); + E->Push(obj->IsWithinDistInMap(target, distance, is3D)); return 1; } @@ -953,14 +953,14 @@ namespace LuaWorldObject * @param bool is3D = true : if false, only x,y coordinates used for checking * @return bool isInDistance */ - int IsInRange(lua_State* L, WorldObject* obj) + int IsInRange(Eluna* E, WorldObject* obj) { - WorldObject* target = Eluna::CHECKOBJ(L, 2); - float minrange = Eluna::CHECKVAL(L, 3); - float maxrange = Eluna::CHECKVAL(L, 4); - bool is3D = Eluna::CHECKVAL(L, 5, true); + WorldObject* target = Eluna::CHECKOBJ(E->L, 2); + float minrange = Eluna::CHECKVAL(E->L, 3); + float maxrange = Eluna::CHECKVAL(E->L, 4); + bool is3D = Eluna::CHECKVAL(E->L, 5, true); - Eluna::Push(L, obj->IsInRange(target, minrange, maxrange, is3D)); + E->Push(obj->IsInRange(target, minrange, maxrange, is3D)); return 1; } @@ -975,14 +975,14 @@ namespace LuaWorldObject * @param float maxrange * @return bool isInDistance */ - int IsInRange2d(lua_State* L, WorldObject* obj) + int IsInRange2d(Eluna* E, WorldObject* obj) { - float x = Eluna::CHECKVAL(L, 2); - float y = Eluna::CHECKVAL(L, 3); - float minrange = Eluna::CHECKVAL(L, 4); - float maxrange = Eluna::CHECKVAL(L, 5); + float x = Eluna::CHECKVAL(E->L, 2); + float y = Eluna::CHECKVAL(E->L, 3); + float minrange = Eluna::CHECKVAL(E->L, 4); + float maxrange = Eluna::CHECKVAL(E->L, 5); - Eluna::Push(L, obj->IsInRange2d(x, y, minrange, maxrange)); + E->Push(obj->IsInRange2d(x, y, minrange, maxrange)); return 1; } @@ -998,15 +998,15 @@ namespace LuaWorldObject * @param float maxrange * @return bool isInDistance */ - int IsInRange3d(lua_State* L, WorldObject* obj) + int IsInRange3d(Eluna* E, WorldObject* obj) { - float x = Eluna::CHECKVAL(L, 2); - float y = Eluna::CHECKVAL(L, 3); - float z = Eluna::CHECKVAL(L, 4); - float minrange = Eluna::CHECKVAL(L, 5); - float maxrange = Eluna::CHECKVAL(L, 6); + float x = Eluna::CHECKVAL(E->L, 2); + float y = Eluna::CHECKVAL(E->L, 3); + float z = Eluna::CHECKVAL(E->L, 4); + float minrange = Eluna::CHECKVAL(E->L, 5); + float maxrange = Eluna::CHECKVAL(E->L, 6); - Eluna::Push(L, obj->IsInRange3d(x, y, z, minrange, maxrange)); + E->Push(obj->IsInRange3d(x, y, z, minrange, maxrange)); return 1; } @@ -1017,12 +1017,12 @@ namespace LuaWorldObject * @param float arc = pi * @return bool isInFront */ - int IsInFront(lua_State* L, WorldObject* obj) + int IsInFront(Eluna* E, WorldObject* obj) { - WorldObject* target = Eluna::CHECKOBJ(L, 2); - float arc = Eluna::CHECKVAL(L, 3, static_cast(M_PI)); + WorldObject* target = Eluna::CHECKOBJ(E->L, 2); + float arc = Eluna::CHECKVAL(E->L, 3, static_cast(M_PI)); - Eluna::Push(L, obj->isInFront(target, arc)); + E->Push(obj->isInFront(target, arc)); return 1; } @@ -1033,12 +1033,12 @@ namespace LuaWorldObject * @param float arc = pi * @return bool isInBack */ - int IsInBack(lua_State* L, WorldObject* obj) + int IsInBack(Eluna* E, WorldObject* obj) { - WorldObject* target = Eluna::CHECKOBJ(L, 2); - float arc = Eluna::CHECKVAL(L, 3, static_cast(M_PI)); + WorldObject* target = Eluna::CHECKOBJ(E->L, 2); + float arc = Eluna::CHECKVAL(E->L, 3, static_cast(M_PI)); - Eluna::Push(L, obj->isInBack(target, arc)); + E->Push(obj->isInBack(target, arc)); return 1; } @@ -1053,10 +1053,10 @@ namespace LuaWorldObject * @param uint32 music : entry of a music * @param [Player] player = nil : [Player] to play the music to */ - int PlayMusic(lua_State* L, WorldObject* obj) + int PlayMusic(Eluna* E, WorldObject* obj) { - uint32 musicid = Eluna::CHECKVAL(L, 2); - Player* player = Eluna::CHECKOBJ(L, 3, false); + uint32 musicid = Eluna::CHECKVAL(E->L, 2); + Player* player = Eluna::CHECKOBJ(E->L, 3, false); WorldPacket data(SMSG_PLAY_MUSIC, 4); data << uint32(musicid); @@ -1080,10 +1080,10 @@ namespace LuaWorldObject * @param uint32 sound : entry of a sound * @param [Player] player = nil : [Player] to play the sound to */ - int PlayDirectSound(lua_State* L, WorldObject* obj) + int PlayDirectSound(Eluna* E, WorldObject* obj) { - uint32 soundId = Eluna::CHECKVAL(L, 2); - Player* player = Eluna::CHECKOBJ(L, 3, false); + uint32 soundId = Eluna::CHECKVAL(E->L, 2); + Player* player = Eluna::CHECKOBJ(E->L, 3, false); if (!sSoundEntriesStore.LookupEntry(soundId)) return 0; @@ -1107,10 +1107,10 @@ namespace LuaWorldObject * @param uint32 sound : entry of a sound * @param [Player] player = nil : [Player] to play the sound to */ - int PlayDistanceSound(lua_State* L, WorldObject* obj) + int PlayDistanceSound(Eluna* E, WorldObject* obj) { - uint32 soundId = Eluna::CHECKVAL(L, 2); - Player* player = Eluna::CHECKOBJ(L, 3, false); + uint32 soundId = Eluna::CHECKVAL(E->L, 2); + Player* player = Eluna::CHECKOBJ(E->L, 3, false); if (!sSoundEntriesStore.LookupEntry(soundId)) return 0; diff --git a/TrinityCore/WorldPacketMethods.h b/TrinityCore/WorldPacketMethods.h index b1ea86b73c..2844da6047 100644 --- a/TrinityCore/WorldPacketMethods.h +++ b/TrinityCore/WorldPacketMethods.h @@ -25,9 +25,9 @@ namespace LuaPacket * * @return uint16 opcode */ - int GetOpcode(lua_State* L, WorldPacket* packet) + int GetOpcode(Eluna* E, WorldPacket* packet) { - Eluna::Push(L, packet->GetOpcode()); + E->Push(packet->GetOpcode()); return 1; } @@ -36,9 +36,9 @@ namespace LuaPacket * * @return uint32 size */ - int GetSize(lua_State* L, WorldPacket* packet) + int GetSize(Eluna* E, WorldPacket* packet) { - Eluna::Push(L, packet->size()); + E->Push(packet->size()); return 1; } @@ -47,11 +47,11 @@ namespace LuaPacket * * @param [Opcodes] opcode : see Opcodes.h for all known opcodes */ - int SetOpcode(lua_State* L, WorldPacket* packet) + int SetOpcode(Eluna* E, WorldPacket* packet) { - uint32 opcode = Eluna::CHECKVAL(L, 2); + uint32 opcode = Eluna::CHECKVAL(E->L, 2); if (opcode >= NUM_MSG_TYPES) - return luaL_argerror(L, 2, "valid opcode expected"); + return luaL_argerror(E->L, 2, "valid opcode expected"); packet->SetOpcode((OpcodesList)opcode); return 0; @@ -62,11 +62,11 @@ namespace LuaPacket * * @return int8 value */ - int ReadByte(lua_State* L, WorldPacket* packet) + int ReadByte(Eluna* E, WorldPacket* packet) { int8 _byte; (*packet) >> _byte; - Eluna::Push(L, _byte); + E->Push(_byte); return 1; } @@ -75,11 +75,11 @@ namespace LuaPacket * * @return uint8 value */ - int ReadUByte(lua_State* L, WorldPacket* packet) + int ReadUByte(Eluna* E, WorldPacket* packet) { uint8 _ubyte; (*packet) >> _ubyte; - Eluna::Push(L, _ubyte); + E->Push(_ubyte); return 1; } @@ -88,11 +88,11 @@ namespace LuaPacket * * @return int16 value */ - int ReadShort(lua_State* L, WorldPacket* packet) + int ReadShort(Eluna* E, WorldPacket* packet) { int16 _short; (*packet) >> _short; - Eluna::Push(L, _short); + E->Push(_short); return 1; } @@ -101,11 +101,11 @@ namespace LuaPacket * * @return uint16 value */ - int ReadUShort(lua_State* L, WorldPacket* packet) + int ReadUShort(Eluna* E, WorldPacket* packet) { uint16 _ushort; (*packet) >> _ushort; - Eluna::Push(L, _ushort); + E->Push(_ushort); return 1; } @@ -114,11 +114,11 @@ namespace LuaPacket * * @return int32 value */ - int ReadLong(lua_State* L, WorldPacket* packet) + int ReadLong(Eluna* E, WorldPacket* packet) { int32 _long; (*packet) >> _long; - Eluna::Push(L, _long); + E->Push(_long); return 1; } @@ -127,11 +127,11 @@ namespace LuaPacket * * @return uint32 value */ - int ReadULong(lua_State* L, WorldPacket* packet) + int ReadULong(Eluna* E, WorldPacket* packet) { uint32 _ulong; (*packet) >> _ulong; - Eluna::Push(L, _ulong); + E->Push(_ulong); return 1; } @@ -140,11 +140,11 @@ namespace LuaPacket * * @return float value */ - int ReadFloat(lua_State* L, WorldPacket* packet) + int ReadFloat(Eluna* E, WorldPacket* packet) { float _val; (*packet) >> _val; - Eluna::Push(L, _val); + E->Push(_val); return 1; } @@ -153,11 +153,11 @@ namespace LuaPacket * * @return double value */ - int ReadDouble(lua_State* L, WorldPacket* packet) + int ReadDouble(Eluna* E, WorldPacket* packet) { double _val; (*packet) >> _val; - Eluna::Push(L, _val); + E->Push(_val); return 1; } @@ -166,11 +166,11 @@ namespace LuaPacket * * @return ObjectGuid value : value returned as string */ - int ReadGUID(lua_State* L, WorldPacket* packet) + int ReadGUID(Eluna* E, WorldPacket* packet) { ObjectGuid guid; (*packet) >> guid; - Eluna::Push(L, guid); + E->Push(guid); return 1; } @@ -179,11 +179,11 @@ namespace LuaPacket * * @return string value */ - int ReadString(lua_State* L, WorldPacket* packet) + int ReadString(Eluna* E, WorldPacket* packet) { std::string _val; (*packet) >> _val; - Eluna::Push(L, _val); + E->Push(_val); return 1; } @@ -192,9 +192,9 @@ namespace LuaPacket * * @param ObjectGuid value : the value to be written to the [WorldPacket] */ - int WriteGUID(lua_State* L, WorldPacket* packet) + int WriteGUID(Eluna* E, WorldPacket* packet) { - ObjectGuid guid = Eluna::CHECKVAL(L, 2); + ObjectGuid guid = Eluna::CHECKVAL(E->L, 2); (*packet) << guid; return 0; } @@ -204,9 +204,9 @@ namespace LuaPacket * * @param string value : the string to be written to the [WorldPacket] */ - int WriteString(lua_State* L, WorldPacket* packet) + int WriteString(Eluna* E, WorldPacket* packet) { - std::string _val = Eluna::CHECKVAL(L, 2); + std::string _val = Eluna::CHECKVAL(E->L, 2); (*packet) << _val; return 0; } @@ -216,9 +216,9 @@ namespace LuaPacket * * @param int8 value : the int8 value to be written to the [WorldPacket] */ - int WriteByte(lua_State* L, WorldPacket* packet) + int WriteByte(Eluna* E, WorldPacket* packet) { - int8 byte = Eluna::CHECKVAL(L, 2); + int8 byte = Eluna::CHECKVAL(E->L, 2); (*packet) << byte; return 0; } @@ -228,9 +228,9 @@ namespace LuaPacket * * @param uint8 value : the uint8 value to be written to the [WorldPacket] */ - int WriteUByte(lua_State* L, WorldPacket* packet) + int WriteUByte(Eluna* E, WorldPacket* packet) { - uint8 byte = Eluna::CHECKVAL(L, 2); + uint8 byte = Eluna::CHECKVAL(E->L, 2); (*packet) << byte; return 0; } @@ -240,9 +240,9 @@ namespace LuaPacket * * @param int16 value : the int16 value to be written to the [WorldPacket] */ - int WriteShort(lua_State* L, WorldPacket* packet) + int WriteShort(Eluna* E, WorldPacket* packet) { - int16 _short = Eluna::CHECKVAL(L, 2); + int16 _short = Eluna::CHECKVAL(E->L, 2); (*packet) << _short; return 0; } @@ -252,9 +252,9 @@ namespace LuaPacket * * @param uint16 value : the uint16 value to be written to the [WorldPacket] */ - int WriteUShort(lua_State* L, WorldPacket* packet) + int WriteUShort(Eluna* E, WorldPacket* packet) { - uint16 _ushort = Eluna::CHECKVAL(L, 2); + uint16 _ushort = Eluna::CHECKVAL(E->L, 2); (*packet) << _ushort; return 0; } @@ -264,9 +264,9 @@ namespace LuaPacket * * @param int32 value : the int32 value to be written to the [WorldPacket] */ - int WriteLong(lua_State* L, WorldPacket* packet) + int WriteLong(Eluna* E, WorldPacket* packet) { - int32 _long = Eluna::CHECKVAL(L, 2); + int32 _long = Eluna::CHECKVAL(E->L, 2); (*packet) << _long; return 0; } @@ -276,9 +276,9 @@ namespace LuaPacket * * @param uint32 value : the uint32 value to be written to the [WorldPacket] */ - int WriteULong(lua_State* L, WorldPacket* packet) + int WriteULong(Eluna* E, WorldPacket* packet) { - uint32 _ulong = Eluna::CHECKVAL(L, 2); + uint32 _ulong = Eluna::CHECKVAL(E->L, 2); (*packet) << _ulong; return 0; } @@ -288,9 +288,9 @@ namespace LuaPacket * * @param float value : the float value to be written to the [WorldPacket] */ - int WriteFloat(lua_State* L, WorldPacket* packet) + int WriteFloat(Eluna* E, WorldPacket* packet) { - float _val = Eluna::CHECKVAL(L, 2); + float _val = Eluna::CHECKVAL(E->L, 2); (*packet) << _val; return 0; } @@ -300,9 +300,9 @@ namespace LuaPacket * * @param double value : the double value to be written to the [WorldPacket] */ - int WriteDouble(lua_State* L, WorldPacket* packet) + int WriteDouble(Eluna* E, WorldPacket* packet) { - double _val = Eluna::CHECKVAL(L, 2); + double _val = Eluna::CHECKVAL(E->L, 2); (*packet) << _val; return 0; }