[Quest API] Add multiple augment related methods to Perl/Lua. (#1930)

* [Quest API] Add multiple augment related methods to Perl/Lua.
- Add $inventory->CountAugmentEquippedByID(item_id) to Perl.
- Add $inventory->HasAugmentEquippedByID(item_id) to Perl.
- Add $item->ContainsAugmentByID(item_id) to Perl.
- Add $item->CountAugmentByID(item_id) to Perl.
- Add inventory:CountAugmentEquippedByID(item_id) to Perl.
- Add inventory:HasAugmentEquippedByID(item_id) to Perl.
- Add item:ContainsAugmentByID(item_id) to Perl.
- Add item:CountAugmentByID(item_id) to Perl.

* Update inventory_profile.cpp
This commit is contained in:
Kinglykrab
2022-01-16 18:04:51 -05:00
committed by GitHub
parent 5ebbbf647b
commit 3a94132749
10 changed files with 160 additions and 0 deletions
+37
View File
@@ -168,6 +168,41 @@ XS(XS_QuestItem_GetID) {
XSRETURN(1);
}
XS(XS_QuestItem_ContainsAugmentByID); /* prototype to pass -Wmissing-prototypes */
XS(XS_QuestItem_ContainsAugmentByID) {
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: QuestItem::ContainsAugmentByID(THIS, uint32 item_id)"); // @categories Inventory and Items
{
EQ::ItemInstance *THIS;
uint32 item_id = (uint32) SvUV(ST(1));
bool contains_augment = false;
VALIDATE_THIS_IS_ITEM;
contains_augment = THIS->ContainsAugmentByID(item_id);
ST(0) = boolSV(contains_augment);
sv_2mortal(ST(0));
}
XSRETURN(1);
}
XS(XS_QuestItem_CountAugmentByID); /* prototype to pass -Wmissing-prototypes */
XS(XS_QuestItem_CountAugmentByID) {
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: QuestItem::CountAugmentByID(THIS, uint32 item_id)"); // @categories Inventory and Items
{
EQ::ItemInstance *THIS;
int quantity = 0;
uint32 item_id = (uint32) SvUV(ST(1));
dXSTARG;
VALIDATE_THIS_IS_ITEM;
quantity = THIS->CountAugmentByID(item_id);
XSprePUSH;
PUSHi((IV) quantity);
}
XSRETURN(1);
}
#ifdef __cplusplus
extern "C"
#endif
@@ -186,6 +221,8 @@ XS(boot_QuestItem) {
//add the strcpy stuff to get rid of const warnings....
XS_VERSION_BOOTCHECK;
newXSproto(strcpy(buf, "ContainsAugmentByID"), XS_QuestItem_ContainsAugmentByID, file, "$$");
newXSproto(strcpy(buf, "CountAugmentByID"), XS_QuestItem_CountAugmentByID, file, "$$");
newXSproto(strcpy(buf, "GetAugment"), XS_QuestItem_GetAugment, file, "$$");
newXSproto(strcpy(buf, "GetCharges"), XS_QuestItem_GetCharges, file, "$");
newXSproto(strcpy(buf, "GetID"), XS_QuestItem_GetID, file, "$");