[Quest API] Add AddPlatinum(), GetCarriedPlatinum() and TakePlatinum() to Perl/Lua. (#2079)

* [Quest API] Add AddPlatinum(), GetCarriedPlatinum() and TakePlatinum() to Perl/Lua.
- Allows for easier NPC interactions.
- GetCarriedPlatinum() adds together all currencies in inventory based on conversion amounts so it works easily with removals/checks.
- Add $client->AddPlatinum(platinum, update_client) to Perl.
- Add $client->GetCarriedPlatinum() to Perl.
- Add $client->TakePlatinum(platinum, update_client) to Perl.
- Add client:AddPlatinum(platinum, update_client) to Lua.
- Add client:GetCarriedPlatinum() to Lua.
- Add client:TakePlatinum(platinum, update_client) to Lua.

* Formatting.
This commit is contained in:
Kinglykrab
2022-04-30 10:57:05 -04:00
committed by GitHub
parent b1311780a7
commit 1b7c12297d
8 changed files with 293 additions and 145 deletions
+87 -17
View File
@@ -1427,18 +1427,20 @@ XS(XS_Client_TakeMoneyFromPP); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_TakeMoneyFromPP) {
dXSARGS;
if (items < 2 || items > 3)
Perl_croak(aTHX_ "Usage: Client::TakeMoneyFromPP(THIS, uint32 copper, bool update_client = false)"); // @categories Currency and Points
Perl_croak(aTHX_ "Usage: Client::TakeMoneyFromPP(THIS, uint32 copper, [bool update_client = false])"); // @categories Currency and Points
{
Client *THIS;
bool RETVAL;
bool updateclient = false;
uint32 copper = (uint32) SvUV(ST(1));
bool has_money;
bool update_client = false;
uint32 copper = (uint32) SvUV(ST(1));
VALIDATE_THIS_IS_CLIENT;
if (items > 2)
updateclient = (bool) SvTRUE(ST(2));
RETVAL = THIS->TakeMoneyFromPP(copper, updateclient);
ST(0) = boolSV(RETVAL);
if (items == 3) {
update_client = (bool) SvTRUE(ST(2));
}
has_money = THIS->TakeMoneyFromPP(copper, update_client);
ST(0) = boolSV(has_money);
sv_2mortal(ST(0));
}
XSRETURN(1);
@@ -1447,17 +1449,22 @@ XS(XS_Client_TakeMoneyFromPP) {
XS(XS_Client_AddMoneyToPP); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_AddMoneyToPP) {
dXSARGS;
if (items != 6)
Perl_croak(aTHX_ "Usage: Client::AddMoneyToPP(THIS, uint32 copper, uint32 silver, uint32 gold, uint32 platinum, bool update_client)"); // @categories Currency and Points
if (items < 5 || items > 6)
Perl_croak(aTHX_ "Usage: Client::AddMoneyToPP(THIS, uint32 copper, uint32 silver, uint32 gold, uint32 platinum, [bool update_client = false])"); // @categories Currency and Points
{
Client *THIS;
uint32 copper = (uint32) SvUV(ST(1));
uint32 silver = (uint32) SvUV(ST(2));
uint32 gold = (uint32) SvUV(ST(3));
uint32 platinum = (uint32) SvUV(ST(4));
bool updateclient = (bool) SvTRUE(ST(5));
uint32 copper = (uint32) SvUV(ST(1));
uint32 silver = (uint32) SvUV(ST(2));
uint32 gold = (uint32) SvUV(ST(3));
uint32 platinum = (uint32) SvUV(ST(4));
bool update_client = false;
VALIDATE_THIS_IS_CLIENT;
THIS->AddMoneyToPP(copper, silver, gold, platinum, updateclient);
if (items == 6) {
update_client = (bool) SvTRUE(ST(5));
}
THIS->AddMoneyToPP(copper, silver, gold, platinum, update_client);
}
XSRETURN_EMPTY;
}
@@ -6115,6 +6122,66 @@ XS(XS_Client_AddItem) {
XSRETURN_EMPTY;
}
XS(XS_Client_AddPlatinum); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_AddPlatinum) {
dXSARGS;
if (items < 2 || items > 3)
Perl_croak(aTHX_ "Usage: Client::AddPlatinum(THIS, uint32 platinum, [bool update_client = false])"); // @categories Currency and Points
{
Client *THIS;
uint32 platinum = (uint32) SvUV(ST(1));
bool update_client = false;
VALIDATE_THIS_IS_CLIENT;
if (items == 3) {
update_client = (bool) SvTRUE(ST(2));
}
THIS->AddPlatinum(platinum, update_client);
}
XSRETURN_EMPTY;
}
XS(XS_Client_GetCarriedPlatinum); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_GetCarriedPlatinum) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Client::GetCarriedPlatinum(THIS)"); // @categories Currency and Points
{
Client *THIS;
int RETVAL;
dXSTARG;
VALIDATE_THIS_IS_CLIENT;
RETVAL = THIS->GetCarriedPlatinum();
XSprePUSH;
PUSHi((IV) RETVAL);
}
XSRETURN(1);
}
XS(XS_Client_TakePlatinum); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_TakePlatinum) {
dXSARGS;
if (items < 2 || items > 3)
Perl_croak(aTHX_ "Usage: Client::TakePlatinum(THIS, uint32 platinum, [bool update_client = false])"); // @categories Currency and Points
{
Client *THIS;
uint32 platinum = (uint32) SvUV(ST(1));
bool has_money = false;
bool update_client = false;
VALIDATE_THIS_IS_CLIENT;
if (items == 3) {
update_client = (bool) SvTRUE(ST(2));
}
has_money = THIS->TakePlatinum(platinum, update_client);
ST(0) = boolSV(has_money);
sv_2mortal(ST(0));
}
XSRETURN(1);
}
#ifdef __cplusplus
extern "C"
#endif
@@ -6144,7 +6211,8 @@ XS(boot_Client) {
newXSproto(strcpy(buf, "AddLDoNLoss"), XS_Client_AddLDoNLoss, file, "$$");
newXSproto(strcpy(buf, "AddLDoNWin"), XS_Client_AddLDoNWin, file, "$$");
newXSproto(strcpy(buf, "AddLevelBasedExp"), XS_Client_AddLevelBasedExp, file, "$$;$$");
newXSproto(strcpy(buf, "AddMoneyToPP"), XS_Client_AddMoneyToPP, file, "$$$$$$");
newXSproto(strcpy(buf, "AddMoneyToPP"), XS_Client_AddMoneyToPP, file, "$$$$$;$");
newXSproto(strcpy(buf, "AddPlatinum"), XS_Client_AddPlatinum, file, "$$;$");
newXSproto(strcpy(buf, "AddPVPPoints"), XS_Client_AddPVPPoints, file, "$$");
newXSproto(strcpy(buf, "AddSkill"), XS_Client_AddSkill, file, "$$$");
newXSproto(strcpy(buf, "Admin"), XS_Client_Admin, file, "$");
@@ -6212,6 +6280,7 @@ XS(boot_Client) {
newXSproto(strcpy(buf, "GetBindZ"), XS_Client_GetBindZ, file, "$$");
newXSproto(strcpy(buf, "GetBindZoneID"), XS_Client_GetBindZoneID, file, "$$");
newXSproto(strcpy(buf, "GetCarriedMoney"), XS_Client_GetCarriedMoney, file, "$");
newXSproto(strcpy(buf, "GetCarriedPlatinum"), XS_Client_GetCarriedPlatinum, file, "$");
newXSproto(strcpy(buf, "GetCharacterFactionLevel"), XS_Client_GetCharacterFactionLevel, file, "$$");
newXSproto(strcpy(buf, "GetClassBitmask"), XS_Client_GetClassBitmask, file, "$");
newXSproto(strcpy(buf, "GetClientMaxLevel"), XS_Client_GetClientMaxLevel, file, "$");
@@ -6427,6 +6496,7 @@ XS(boot_Client) {
newXSproto(strcpy(buf, "SummonItem"), XS_Client_SummonItem, file, "$$;$$$$$$$$");
newXSproto(strcpy(buf, "TGB"), XS_Client_TGB, file, "$");
newXSproto(strcpy(buf, "TakeMoneyFromPP"), XS_Client_TakeMoneyFromPP, file, "$$;$");
newXSproto(strcpy(buf, "TakePlatinum"), XS_Client_TakePlatinum, file, "$$;$");
newXSproto(strcpy(buf, "Thirsty"), XS_Client_Thirsty, file, "$");
newXSproto(strcpy(buf, "TrainDiscBySpellID"), XS_Client_TrainDiscBySpellID, file, "$$");
newXSproto(strcpy(buf, "UnFreeze"), XS_Client_UnFreeze, file, "$");