Improved pushing so that a single userdata is used per object pushed.
Made everything use the singleton less, allowing more free code and easier to implement multithreading later.
Made macros for hookmgr and fixed the issue with hooks called inside hooks.
This commit is contained in:
Rochet2
2014-06-01 23:58:28 +03:00
committed by Foereaper
parent e131f36d39
commit b1f85bfc21
25 changed files with 3169 additions and 3666 deletions

View File

@@ -12,134 +12,134 @@ namespace LuaItem
/* BOOLEAN */
int IsSoulBound(lua_State* L, Item* item)
{
sEluna->Push(L, item->IsSoulBound());
Eluna::Push(L, item->IsSoulBound());
return 1;
}
#if (!defined(TBC) && !defined(CLASSIC))
int IsBoundAccountWide(lua_State* L, Item* item)
{
sEluna->Push(L, item->IsBoundAccountWide());
Eluna::Push(L, item->IsBoundAccountWide());
return 1;
}
#endif
int IsBoundByEnchant(lua_State* L, Item* item)
{
sEluna->Push(L, item->IsBoundByEnchant());
Eluna::Push(L, item->IsBoundByEnchant());
return 1;
}
int IsNotBoundToPlayer(lua_State* L, Item* item)
{
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
sEluna->Push(L, item->IsBindedNotWith(player));
Eluna::Push(L, item->IsBindedNotWith(player));
return 1;
}
int IsLocked(lua_State* L, Item* item)
{
sEluna->Push(L, item->IsLocked());
Eluna::Push(L, item->IsLocked());
return 1;
}
int IsBag(lua_State* L, Item* item)
{
sEluna->Push(L, item->IsBag());
Eluna::Push(L, item->IsBag());
return 1;
}
#ifndef CLASSIC
int IsCurrencyToken(lua_State* L, Item* item)
{
sEluna->Push(L, item->IsCurrencyToken());
Eluna::Push(L, item->IsCurrencyToken());
return 1;
}
#endif
int IsNotEmptyBag(lua_State* L, Item* item)
{
sEluna->Push(L, item->IsNotEmptyBag());
Eluna::Push(L, item->IsNotEmptyBag());
return 1;
}
int IsBroken(lua_State* L, Item* item)
{
sEluna->Push(L, item->IsBroken());
Eluna::Push(L, item->IsBroken());
return 1;
}
int CanBeTraded(lua_State* L, Item* item)
{
#if (defined(TBC) || defined(CLASSIC))
sEluna->Push(L, item->CanBeTraded());
Eluna::Push(L, item->CanBeTraded());
#else
bool mail = sEluna->CHECKVAL<bool>(L, 2, false);
sEluna->Push(L, item->CanBeTraded(mail));
bool mail = Eluna::CHECKVAL<bool>(L, 2, false);
Eluna::Push(L, item->CanBeTraded(mail));
#endif
return 1;
}
int IsInTrade(lua_State* L, Item* item)
{
sEluna->Push(L, item->IsInTrade());
Eluna::Push(L, item->IsInTrade());
return 1;
}
int IsInBag(lua_State* L, Item* item)
{
sEluna->Push(L, item->IsInBag());
Eluna::Push(L, item->IsInBag());
return 1;
}
int IsEquipped(lua_State* L, Item* item)
{
sEluna->Push(L, item->IsEquipped());
Eluna::Push(L, item->IsEquipped());
return 1;
}
int HasQuest(lua_State* L, Item* item)
{
uint32 quest = sEluna->CHECKVAL<uint32>(L, 2);
uint32 quest = Eluna::CHECKVAL<uint32>(L, 2);
#ifdef MANGOS
sEluna->Push(L, item->HasQuest(quest));
Eluna::Push(L, item->HasQuest(quest));
#else
sEluna->Push(L, item->hasQuest(quest));
Eluna::Push(L, item->hasQuest(quest));
#endif
return 1;
}
int IsPotion(lua_State* L, Item* item)
{
sEluna->Push(L, item->IsPotion());
Eluna::Push(L, item->IsPotion());
return 1;
}
#ifndef CATA
int IsWeaponVellum(lua_State* L, Item* item)
{
sEluna->Push(L, item->IsWeaponVellum());
Eluna::Push(L, item->IsWeaponVellum());
return 1;
}
int IsArmorVellum(lua_State* L, Item* item)
{
sEluna->Push(L, item->IsArmorVellum());
Eluna::Push(L, item->IsArmorVellum());
return 1;
}
#endif
int IsConjuredConsumable(lua_State* L, Item* item)
{
sEluna->Push(L, item->IsConjuredConsumable());
Eluna::Push(L, item->IsConjuredConsumable());
return 1;
}
/*
int IsRefundExpired(lua_State* L, Item* item)// TODO: Implement core support
{
sEluna->Push(L, item->IsRefundExpired());
Eluna::Push(L, item->IsRefundExpired());
return 1;
}
*/
@@ -157,7 +157,7 @@ namespace LuaItem
// LOCALE_esMX = 7,
// LOCALE_ruRU = 8
int loc_idx = sEluna->CHECKVAL<int>(L, 2, DEFAULT_LOCALE);
int loc_idx = Eluna::CHECKVAL<int>(L, 2, DEFAULT_LOCALE);
if (loc_idx < 0 || loc_idx >= MAX_LOCALES)
return luaL_argerror(L, 2, "valid LocaleConstant expected");
@@ -211,212 +211,212 @@ namespace LuaItem
item->GetItemRandomPropertyId() << ":" << item->GetItemSuffixFactor() << ":" <<
(uint32)item->GetOwner()->getLevel() << "|h[" << name << "]|h|r";
sEluna->Push(L, oss.str());
Eluna::Push(L, oss.str());
return 1;
}
int GetGUID(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetGUIDLow());
Eluna::Push(L, item->GetGUIDLow());
return 1;
}
int GetOwnerGUID(lua_State* L, Item* item)
{
#ifdef MANGOS
sEluna->Push(L, item->GetOwnerGuid());
Eluna::Push(L, item->GetOwnerGuid());
#else
sEluna->Push(L, item->GetOwnerGUID());
Eluna::Push(L, item->GetOwnerGUID());
#endif
return 1;
}
int GetOwner(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetOwner());
Eluna::Push(L, item->GetOwner());
return 1;
}
int GetCount(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetCount());
Eluna::Push(L, item->GetCount());
return 1;
}
int GetMaxStackCount(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetMaxStackCount());
Eluna::Push(L, item->GetMaxStackCount());
return 1;
}
int GetSlot(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetSlot());
Eluna::Push(L, item->GetSlot());
return 1;
}
int GetBagSlot(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetBagSlot());
Eluna::Push(L, item->GetBagSlot());
return 1;
}
int GetGUIDLow(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetGUIDLow());
Eluna::Push(L, item->GetGUIDLow());
return 1;
}
int GetEnchantmentId(lua_State* L, Item* item)
{
uint32 enchant_slot = sEluna->CHECKVAL<uint32>(L, 2);
uint32 enchant_slot = Eluna::CHECKVAL<uint32>(L, 2);
if (enchant_slot >= MAX_INSPECTED_ENCHANTMENT_SLOT)
return luaL_argerror(L, 2, "valid EnchantmentSlot expected");
sEluna->Push(L, item->GetEnchantmentId(EnchantmentSlot(enchant_slot)));
Eluna::Push(L, item->GetEnchantmentId(EnchantmentSlot(enchant_slot)));
return 1;
}
int GetSpellId(lua_State* L, Item* item)
{
uint32 index = sEluna->CHECKVAL<uint32>(L, 2);
uint32 index = Eluna::CHECKVAL<uint32>(L, 2);
if (index >= MAX_ITEM_PROTO_SPELLS)
return luaL_argerror(L, 2, "valid SpellIndex expected");
sEluna->Push(L, item->GetTemplate()->Spells[index].SpellId);
Eluna::Push(L, item->GetTemplate()->Spells[index].SpellId);
return 1;
}
int GetSpellTrigger(lua_State* L, Item* item)
{
uint32 index = sEluna->CHECKVAL<uint32>(L, 2);
uint32 index = Eluna::CHECKVAL<uint32>(L, 2);
if (index >= MAX_ITEM_PROTO_SPELLS)
return luaL_argerror(L, 2, "valid SpellIndex expected");
sEluna->Push(L, item->GetTemplate()->Spells[index].SpellTrigger);
Eluna::Push(L, item->GetTemplate()->Spells[index].SpellTrigger);
return 1;
}
int GetClass(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetTemplate()->Class);
Eluna::Push(L, item->GetTemplate()->Class);
return 1;
}
int GetSubClass(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetTemplate()->SubClass);
Eluna::Push(L, item->GetTemplate()->SubClass);
return 1;
}
int GetName(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetTemplate()->Name1);
Eluna::Push(L, item->GetTemplate()->Name1);
return 1;
}
int GetDisplayId(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetTemplate()->DisplayInfoID);
Eluna::Push(L, item->GetTemplate()->DisplayInfoID);
return 1;
}
int GetQuality(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetTemplate()->Quality);
Eluna::Push(L, item->GetTemplate()->Quality);
return 1;
}
int GetBuyCount(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetTemplate()->BuyCount);
Eluna::Push(L, item->GetTemplate()->BuyCount);
return 1;
}
int GetBuyPrice(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetTemplate()->BuyPrice);
Eluna::Push(L, item->GetTemplate()->BuyPrice);
return 1;
}
int GetSellPrice(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetTemplate()->SellPrice);
Eluna::Push(L, item->GetTemplate()->SellPrice);
return 1;
}
int GetInventoryType(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetTemplate()->InventoryType);
Eluna::Push(L, item->GetTemplate()->InventoryType);
return 1;
}
int GetAllowableClass(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetTemplate()->AllowableClass);
Eluna::Push(L, item->GetTemplate()->AllowableClass);
return 1;
}
int GetAllowableRace(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetTemplate()->AllowableRace);
Eluna::Push(L, item->GetTemplate()->AllowableRace);
return 1;
}
int GetItemLevel(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetTemplate()->ItemLevel);
Eluna::Push(L, item->GetTemplate()->ItemLevel);
return 1;
}
int GetRequiredLevel(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetTemplate()->RequiredLevel);
Eluna::Push(L, item->GetTemplate()->RequiredLevel);
return 1;
}
#ifdef WOTLK
int GetStatsCount(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetTemplate()->StatsCount);
Eluna::Push(L, item->GetTemplate()->StatsCount);
return 1;
}
#endif
int GetRandomProperty(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetTemplate()->RandomProperty);
Eluna::Push(L, item->GetTemplate()->RandomProperty);
return 1;
}
#ifndef CLASSIC
int GetRandomSuffix(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetTemplate()->RandomSuffix);
Eluna::Push(L, item->GetTemplate()->RandomSuffix);
return 1;
}
#endif
int GetItemSet(lua_State* L, Item* item)
{
sEluna->Push(L, item->GetTemplate()->ItemSet);
Eluna::Push(L, item->GetTemplate()->ItemSet);
return 1;
}
int GetBagSize(lua_State* L, Item* item)
{
if (Bag* bag = item->ToBag())
sEluna->Push(L, bag->GetBagSize());
Eluna::Push(L, bag->GetBagSize());
else
sEluna->Push(L, 0);
Eluna::Push(L, 0);
return 1;
}
/* SETTERS */
int SetOwner(lua_State* L, Item* item)
{
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
#ifdef MANGOS
item->SetOwnerGuid(player->GET_GUID());
#else
@@ -427,7 +427,7 @@ namespace LuaItem
int SetBinding(lua_State* L, Item* item)
{
bool soulbound = sEluna->CHECKVAL<bool>(L, 2);
bool soulbound = Eluna::CHECKVAL<bool>(L, 2);
item->SetBinding(soulbound);
return 0;
@@ -435,7 +435,7 @@ namespace LuaItem
int SetCount(lua_State* L, Item* item)
{
uint32 count = sEluna->CHECKVAL<uint32>(L, 2);
uint32 count = Eluna::CHECKVAL<uint32>(L, 2);
item->SetCount(count);
return 0;
}
@@ -445,25 +445,25 @@ namespace LuaItem
Player* owner = item->GetOwner();
if (!owner)
{
sEluna->Push(L, false);
Eluna::Push(L, false);
return 1;
}
uint32 enchant = sEluna->CHECKVAL<uint32>(L, 2);
uint32 enchant = Eluna::CHECKVAL<uint32>(L, 2);
if (!sSpellItemEnchantmentStore.LookupEntry(enchant))
{
sEluna->Push(L, false);
Eluna::Push(L, false);
return 1;
}
EnchantmentSlot slot = (EnchantmentSlot)sEluna->CHECKVAL<uint32>(L, 3);
EnchantmentSlot slot = (EnchantmentSlot)Eluna::CHECKVAL<uint32>(L, 3);
if (slot >= MAX_INSPECTED_ENCHANTMENT_SLOT)
return luaL_argerror(L, 2, "valid EnchantmentSlot expected");
owner->ApplyEnchantment(item, slot, false);
item->SetEnchantment(slot, enchant, 0, 0);
owner->ApplyEnchantment(item, slot, true);
sEluna->Push(L, true);
Eluna::Push(L, true);
return 1;
}
@@ -473,23 +473,23 @@ namespace LuaItem
Player* owner = item->GetOwner();
if (!owner)
{
sEluna->Push(L, false);
Eluna::Push(L, false);
return 1;
}
EnchantmentSlot slot = (EnchantmentSlot)sEluna->CHECKVAL<uint32>(L, 2);
EnchantmentSlot slot = (EnchantmentSlot)Eluna::CHECKVAL<uint32>(L, 2);
if (slot >= MAX_INSPECTED_ENCHANTMENT_SLOT)
return luaL_argerror(L, 2, "valid EnchantmentSlot expected");
if (!item->GetEnchantmentId(slot))
{
sEluna->Push(L, false);
Eluna::Push(L, false);
return 1;
}
owner->ApplyEnchantment(item, slot, false);
item->ClearEnchantment(slot);
sEluna->Push(L, true);
Eluna::Push(L, true);
return 1;
}