LUA/PERL - IsStanding() and IsCrouching() - Returns as bools

This commit is contained in:
Trust 2019-06-08 04:48:06 +00:00
parent 2690e4de4d
commit d23a6e646e
4 changed files with 70 additions and 0 deletions

View File

@ -791,7 +791,9 @@ public:
uint32 GetCharMaxLevelFromQGlobal();
uint32 GetCharMaxLevelFromBucket();
inline bool IsStanding() const {return (playeraction == 0);}
inline bool IsSitting() const {return (playeraction == 1);}
inline bool IsCrouching() const {return (playeraction == 2);}
inline bool IsBecomeNPC() const { return npcflag; }
inline uint8 GetBecomeNPCLevel() const { return npclevel; }
inline void SetBecomeNPC(bool flag) { npcflag = flag; }

View File

@ -615,11 +615,21 @@ void Lua_Client::UntrainDiscAll(bool update_client) {
self->UntrainDiscAll(update_client);
}
bool Lua_Client::IsStanding() {
Lua_Safe_Call_Bool();
return self->IsStanding();
}
bool Lua_Client::IsSitting() {
Lua_Safe_Call_Bool();
return self->IsSitting();
}
bool Lua_Client::IsCrouching() {
Lua_Safe_Call_Bool();
return self->IsCrouching();
}
void Lua_Client::SetFeigned(bool v) {
Lua_Safe_Call_Void();
self->SetFeigned(v);
@ -1621,7 +1631,9 @@ luabind::scope lua_register_client() {
.def("UntrainDisc", (void(Lua_Client::*)(int,bool))&Lua_Client::UntrainDisc)
.def("UntrainDiscAll", (void(Lua_Client::*)(void))&Lua_Client::UntrainDiscAll)
.def("UntrainDiscAll", (void(Lua_Client::*)(bool))&Lua_Client::UntrainDiscAll)
.def("IsStanding", (bool(Lua_Client::*)(void))&Lua_Client::IsStanding)
.def("IsSitting", (bool(Lua_Client::*)(void))&Lua_Client::IsSitting)
.def("IsCrouching", (bool(Lua_Client::*)(void))&Lua_Client::IsCrouching)
.def("SetFeigned", (void(Lua_Client::*)(bool))&Lua_Client::SetFeigned)
.def("GetFeigned", (bool(Lua_Client::*)(void))&Lua_Client::GetFeigned)
.def("AutoSplitEnabled", (bool(Lua_Client::*)(void))&Lua_Client::AutoSplitEnabled)

View File

@ -148,7 +148,9 @@ public:
void UntrainDisc(int slot, bool update_client);
void UntrainDiscAll();
void UntrainDiscAll(bool update_client);
bool IsStanding();
bool IsSitting();
bool IsCrouching();
void SetFeigned(bool v);
bool GetFeigned();
bool AutoSplitEnabled();

View File

@ -2596,6 +2596,32 @@ XS(XS_Client_UntrainDiscAll) {
XSRETURN_EMPTY;
}
XS(XS_Client_IsStanding); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_IsStanding)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Client::IsStanding(THIS)");
{
Client * THIS;
bool RETVAL;
if (sv_derived_from(ST(0), "Client")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(Client *,tmp);
}
else
Perl_croak(aTHX_ "THIS is not of type Client");
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->IsStanding();
ST(0) = boolSV(RETVAL);
sv_2mortal(ST(0));
}
XSRETURN(1);
}
XS(XS_Client_IsSitting); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_IsSitting) {
dXSARGS;
@ -2620,6 +2646,32 @@ XS(XS_Client_IsSitting) {
XSRETURN(1);
}
XS(XS_Client_IsCrouching); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_IsCrouching)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Client::IsCrouching(THIS)");
{
Client * THIS;
bool RETVAL;
if (sv_derived_from(ST(0), "Client")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(Client *,tmp);
}
else
Perl_croak(aTHX_ "THIS is not of type Client");
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->IsCrouching();
ST(0) = boolSV(RETVAL);
sv_2mortal(ST(0));
}
XSRETURN(1);
}
XS(XS_Client_IsBecomeNPC); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_IsBecomeNPC) {
dXSARGS;
@ -6338,7 +6390,9 @@ XS(boot_Client) {
newXSproto(strcpy(buf, "IsLD"), XS_Client_IsLD, file, "$");
newXSproto(strcpy(buf, "IsMedding"), XS_Client_IsMedding, file, "$");
newXSproto(strcpy(buf, "IsRaidGrouped"), XS_Client_IsRaidGrouped, file, "$");
newXSproto(strcpy(buf, "IsStanding"), XS_Client_IsStanding, file, "$");
newXSproto(strcpy(buf, "IsSitting"), XS_Client_IsSitting, file, "$");
newXSproto(strcpy(buf, "IsCrouching"), XS_Client_IsCrouching, file, "$");
newXSproto(strcpy(buf, "IsTaskActive"), XS_Client_IsTaskActive, file, "$$");
newXSproto(strcpy(buf, "IsTaskActivityActive"), XS_Client_IsTaskActivityActive, file, "$$$");
newXSproto(strcpy(buf, "IsTaskCompleted"), XS_Client_IsTaskCompleted, file, "$$");