Change Eluna to a global variable

Remove Eluna* from being passed. You can now get it through Eluna::GetEluna(L)
Change function call cleanup to lua_settop instead of manual loop
Explicitly delete the copy constructor and copy assignment operators
This commit is contained in:
Rochet2
2017-03-19 15:48:48 +02:00
parent 8d3433f4b5
commit b7c379a42c
23 changed files with 990 additions and 976 deletions

View File

@@ -17,7 +17,7 @@ namespace LuaItem
*
* @return bool isSoulBound
*/
int IsSoulBound(Eluna* /*E*/, lua_State* L, Item* item)
int IsSoulBound(lua_State* L, Item* item)
{
Eluna::Push(L, item->IsSoulBound());
return 1;
@@ -29,7 +29,7 @@ namespace LuaItem
*
* @return bool isAccountBound
*/
int IsBoundAccountWide(Eluna* /*E*/, lua_State* L, Item* item)
int IsBoundAccountWide(lua_State* L, Item* item)
{
Eluna::Push(L, item->IsBoundAccountWide());
return 1;
@@ -41,7 +41,7 @@ namespace LuaItem
*
* @return bool isBoundByEnchant
*/
int IsBoundByEnchant(Eluna* /*E*/, lua_State* L, Item* item)
int IsBoundByEnchant(lua_State* L, Item* item)
{
Eluna::Push(L, item->IsBoundByEnchant());
return 1;
@@ -53,7 +53,7 @@ namespace LuaItem
* @param [Player] player : the [Player] object to check the item against
* @return bool isNotBound
*/
int IsNotBoundToPlayer(Eluna* /*E*/, lua_State* L, Item* item)
int IsNotBoundToPlayer(lua_State* L, Item* item)
{
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
@@ -66,7 +66,7 @@ namespace LuaItem
*
* @return bool isLocked
*/
int IsLocked(Eluna* /*E*/, lua_State* L, Item* item)
int IsLocked(lua_State* L, Item* item)
{
Eluna::Push(L, item->IsLocked());
return 1;
@@ -77,7 +77,7 @@ namespace LuaItem
*
* @return bool isBag
*/
int IsBag(Eluna* /*E*/, lua_State* L, Item* item)
int IsBag(lua_State* L, Item* item)
{
Eluna::Push(L, item->IsBag());
return 1;
@@ -89,7 +89,7 @@ namespace LuaItem
*
* @return bool isCurrencyToken
*/
int IsCurrencyToken(Eluna* /*E*/, lua_State* L, Item* item)
int IsCurrencyToken(lua_State* L, Item* item)
{
Eluna::Push(L, item->IsCurrencyToken());
return 1;
@@ -101,7 +101,7 @@ namespace LuaItem
*
* @return bool isNotEmptyBag
*/
int IsNotEmptyBag(Eluna* /*E*/, lua_State* L, Item* item)
int IsNotEmptyBag(lua_State* L, Item* item)
{
Eluna::Push(L, item->IsNotEmptyBag());
return 1;
@@ -112,7 +112,7 @@ namespace LuaItem
*
* @return bool isBroken
*/
int IsBroken(Eluna* /*E*/, lua_State* L, Item* item)
int IsBroken(lua_State* L, Item* item)
{
Eluna::Push(L, item->IsBroken());
return 1;
@@ -123,7 +123,7 @@ namespace LuaItem
*
* @return bool isTradeable
*/
int CanBeTraded(Eluna* /*E*/, lua_State* L, Item* item)
int CanBeTraded(lua_State* L, Item* item)
{
#if (defined(TBC) || defined(CLASSIC))
Eluna::Push(L, item->CanBeTraded());
@@ -139,7 +139,7 @@ namespace LuaItem
*
* @return bool isInTrade
*/
int IsInTrade(Eluna* /*E*/, lua_State* L, Item* item)
int IsInTrade(lua_State* L, Item* item)
{
Eluna::Push(L, item->IsInTrade());
return 1;
@@ -150,7 +150,7 @@ namespace LuaItem
*
* @return bool isInBag
*/
int IsInBag(Eluna* /*E*/, lua_State* L, Item* item)
int IsInBag(lua_State* L, Item* item)
{
Eluna::Push(L, item->IsInBag());
return 1;
@@ -161,7 +161,7 @@ namespace LuaItem
*
* @return bool isEquipped
*/
int IsEquipped(Eluna* /*E*/, lua_State* L, Item* item)
int IsEquipped(lua_State* L, Item* item)
{
Eluna::Push(L, item->IsEquipped());
return 1;
@@ -173,7 +173,7 @@ namespace LuaItem
* @param uint32 questId : the [Quest] id to be checked
* @return bool hasQuest
*/
int HasQuest(Eluna* /*E*/, lua_State* L, Item* item)
int HasQuest(lua_State* L, Item* item)
{
uint32 quest = Eluna::CHECKVAL<uint32>(L, 2);
#ifndef TRINITY
@@ -189,7 +189,7 @@ namespace LuaItem
*
* @return bool isPotion
*/
int IsPotion(Eluna* /*E*/, lua_State* L, Item* item)
int IsPotion(lua_State* L, Item* item)
{
Eluna::Push(L, item->IsPotion());
return 1;
@@ -201,7 +201,7 @@ namespace LuaItem
*
* @return bool isWeaponVellum
*/
int IsWeaponVellum(Eluna* /*E*/, lua_State* L, Item* item)
int IsWeaponVellum(lua_State* L, Item* item)
{
Eluna::Push(L, item->IsWeaponVellum());
return 1;
@@ -212,7 +212,7 @@ namespace LuaItem
*
* @return bool isArmorVellum
*/
int IsArmorVellum(Eluna* /*E*/, lua_State* L, Item* item)
int IsArmorVellum(lua_State* L, Item* item)
{
Eluna::Push(L, item->IsArmorVellum());
return 1;
@@ -224,13 +224,13 @@ namespace LuaItem
*
* @return bool isConjuredConsumable
*/
int IsConjuredConsumable(Eluna* /*E*/, lua_State* L, Item* item)
int IsConjuredConsumable(lua_State* L, Item* item)
{
Eluna::Push(L, item->IsConjuredConsumable());
return 1;
}
/*int IsRefundExpired(Eluna* E, lua_State* L, Item* item)// TODO: Implement core support
/*int IsRefundExpired(lua_State* L, Item* item)// TODO: Implement core support
{
Eluna::Push(L, item->IsRefundExpired());
return 1;
@@ -257,7 +257,7 @@ namespace LuaItem
* @param [LocaleConstant] locale = DEFAULT_LOCALE : locale to return the [Item]'s name in
* @return string itemLink
*/
int GetItemLink(Eluna* /*E*/, lua_State* L, Item* item)
int GetItemLink(lua_State* L, Item* item)
{
uint8 locale = Eluna::CHECKVAL<uint8>(L, 2, DEFAULT_LOCALE);
if (locale >= TOTAL_LOCALES)
@@ -313,7 +313,7 @@ namespace LuaItem
return 1;
}
int GetOwnerGUID(Eluna* /*E*/, lua_State* L, Item* item)
int GetOwnerGUID(lua_State* L, Item* item)
{
#ifndef TRINITY
Eluna::Push(L, item->GetOwnerGuid());
@@ -328,7 +328,7 @@ namespace LuaItem
*
* @return [Player] player : the [Player] who owns the [Item]
*/
int GetOwner(Eluna* /*E*/, lua_State* L, Item* item)
int GetOwner(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetOwner());
return 1;
@@ -339,7 +339,7 @@ namespace LuaItem
*
* @return uint32 count
*/
int GetCount(Eluna* /*E*/, lua_State* L, Item* item)
int GetCount(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetCount());
return 1;
@@ -350,7 +350,7 @@ namespace LuaItem
*
* @return uint32 maxCount
*/
int GetMaxStackCount(Eluna* /*E*/, lua_State* L, Item* item)
int GetMaxStackCount(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetMaxStackCount());
return 1;
@@ -361,7 +361,7 @@ namespace LuaItem
*
* @return uint8 slot
*/
int GetSlot(Eluna* /*E*/, lua_State* L, Item* item)
int GetSlot(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetSlot());
return 1;
@@ -372,7 +372,7 @@ namespace LuaItem
*
* @return uint8 bagSlot
*/
int GetBagSlot(Eluna* /*E*/, lua_State* L, Item* item)
int GetBagSlot(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetBagSlot());
return 1;
@@ -384,7 +384,7 @@ namespace LuaItem
* @param [EnchantmentSlot] enchantSlot : the enchant slot specified
* @return uint32 enchantId : the id of the enchant slot specified
*/
int GetEnchantmentId(Eluna* /*E*/, lua_State* L, Item* item)
int GetEnchantmentId(lua_State* L, Item* item)
{
uint32 enchant_slot = Eluna::CHECKVAL<uint32>(L, 2);
@@ -401,7 +401,7 @@ namespace LuaItem
* @param uint32 spellIndex : the spell index specified
* @return uint32 spellId : the id of the spell
*/
int GetSpellId(Eluna* /*E*/, lua_State* L, Item* item)
int GetSpellId(lua_State* L, Item* item)
{
uint32 index = Eluna::CHECKVAL<uint32>(L, 2);
if (index >= MAX_ITEM_PROTO_SPELLS)
@@ -417,7 +417,7 @@ namespace LuaItem
* @param uint32 spellIndex : the spell index specified
* @return uint32 spellTrigger : the spell trigger of the specified index
*/
int GetSpellTrigger(Eluna* /*E*/, lua_State* L, Item* item)
int GetSpellTrigger(lua_State* L, Item* item)
{
uint32 index = Eluna::CHECKVAL<uint32>(L, 2);
if (index >= MAX_ITEM_PROTO_SPELLS)
@@ -432,7 +432,7 @@ namespace LuaItem
*
* @return uint32 class
*/
int GetClass(Eluna* /*E*/, lua_State* L, Item* item)
int GetClass(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->Class);
return 1;
@@ -443,7 +443,7 @@ namespace LuaItem
*
* @return uint32 subClass
*/
int GetSubClass(Eluna* /*E*/, lua_State* L, Item* item)
int GetSubClass(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->SubClass);
return 1;
@@ -454,7 +454,7 @@ namespace LuaItem
*
* @return string name
*/
int GetName(Eluna* /*E*/, lua_State* L, Item* item)
int GetName(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->Name1);
return 1;
@@ -465,7 +465,7 @@ namespace LuaItem
*
* @return uint32 displayId
*/
int GetDisplayId(Eluna* /*E*/, lua_State* L, Item* item)
int GetDisplayId(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->DisplayInfoID);
return 1;
@@ -476,7 +476,7 @@ namespace LuaItem
*
* @return uint32 quality
*/
int GetQuality(Eluna* /*E*/, lua_State* L, Item* item)
int GetQuality(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->Quality);
return 1;
@@ -487,7 +487,7 @@ namespace LuaItem
*
* @return uint32 count
*/
int GetBuyCount(Eluna* /*E*/, lua_State* L, Item* item)
int GetBuyCount(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->BuyCount);
return 1;
@@ -498,7 +498,7 @@ namespace LuaItem
*
* @return uint32 price
*/
int GetBuyPrice(Eluna* /*E*/, lua_State* L, Item* item)
int GetBuyPrice(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->BuyPrice);
return 1;
@@ -509,7 +509,7 @@ namespace LuaItem
*
* @return uint32 price
*/
int GetSellPrice(Eluna* /*E*/, lua_State* L, Item* item)
int GetSellPrice(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->SellPrice);
return 1;
@@ -520,7 +520,7 @@ namespace LuaItem
*
* @return uint32 inventoryType
*/
int GetInventoryType(Eluna* /*E*/, lua_State* L, Item* item)
int GetInventoryType(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->InventoryType);
return 1;
@@ -531,7 +531,7 @@ namespace LuaItem
*
* @return uint32 allowableClass
*/
int GetAllowableClass(Eluna* /*E*/, lua_State* L, Item* item)
int GetAllowableClass(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->AllowableClass);
return 1;
@@ -542,7 +542,7 @@ namespace LuaItem
*
* @return uint32 allowableRace
*/
int GetAllowableRace(Eluna* /*E*/, lua_State* L, Item* item)
int GetAllowableRace(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->AllowableRace);
return 1;
@@ -553,7 +553,7 @@ namespace LuaItem
*
* @return uint32 itemLevel
*/
int GetItemLevel(Eluna* /*E*/, lua_State* L, Item* item)
int GetItemLevel(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->ItemLevel);
return 1;
@@ -564,14 +564,14 @@ namespace LuaItem
*
* @return uint32 requiredLevel
*/
int GetRequiredLevel(Eluna* /*E*/, lua_State* L, Item* item)
int GetRequiredLevel(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->RequiredLevel);
return 1;
}
#ifdef WOTLK
int GetStatsCount(Eluna* /*E*/, lua_State* L, Item* item)
int GetStatsCount(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->StatsCount);
return 1;
@@ -583,14 +583,14 @@ namespace LuaItem
*
* @return uint32 randomPropertyId
*/
int GetRandomProperty(Eluna* /*E*/, lua_State* L, Item* item)
int GetRandomProperty(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->RandomProperty);
return 1;
}
#ifndef CLASSIC
int GetRandomSuffix(Eluna* /*E*/, lua_State* L, Item* item)
int GetRandomSuffix(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->RandomSuffix);
return 1;
@@ -602,7 +602,7 @@ namespace LuaItem
*
* @return uint32 itemSetId
*/
int GetItemSet(Eluna* /*E*/, lua_State* L, Item* item)
int GetItemSet(lua_State* L, Item* item)
{
Eluna::Push(L, item->GetTemplate()->ItemSet);
return 1;
@@ -613,7 +613,7 @@ namespace LuaItem
*
* @return uint32 bagSize
*/
int GetBagSize(Eluna* /*E*/, lua_State* L, Item* item)
int GetBagSize(lua_State* L, Item* item)
{
if (Bag* bag = item->ToBag())
Eluna::Push(L, bag->GetBagSize());
@@ -627,7 +627,7 @@ namespace LuaItem
*
* @param [Player] player : the [Player] specified
*/
int SetOwner(Eluna* /*E*/, lua_State* L, Item* item)
int SetOwner(lua_State* L, Item* item)
{
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
#ifndef TRINITY
@@ -643,7 +643,7 @@ namespace LuaItem
*
* @param bool setBinding
*/
int SetBinding(Eluna* /*E*/, lua_State* L, Item* item)
int SetBinding(lua_State* L, Item* item)
{
bool soulbound = Eluna::CHECKVAL<bool>(L, 2);
@@ -656,7 +656,7 @@ namespace LuaItem
*
* @param uint32 count
*/
int SetCount(Eluna* /*E*/, lua_State* L, Item* item)
int SetCount(lua_State* L, Item* item)
{
uint32 count = Eluna::CHECKVAL<uint32>(L, 2);
item->SetCount(count);
@@ -670,7 +670,7 @@ 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(Eluna* /*E*/, lua_State* L, Item* item)
int SetEnchantment(lua_State* L, Item* item)
{
Player* owner = item->GetOwner();
if (!owner)
@@ -704,7 +704,7 @@ 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(Eluna* /*E*/, lua_State* L, Item* item)
int ClearEnchantment(lua_State* L, Item* item)
{
Player* owner = item->GetOwner();
if (!owner)
@@ -732,7 +732,7 @@ namespace LuaItem
/**
* Saves the [Item] to the database
*/
int SaveToDB(Eluna* /*E*/, lua_State* /*L*/, Item* item)
int SaveToDB(lua_State* /*L*/, Item* item)
{
#ifndef TRINITY
item->SaveToDB();