From 64998a398d992c58a78f2e74f340f130b8a796f0 Mon Sep 17 00:00:00 2001 From: Kinglykrab Date: Thu, 8 Sep 2016 21:59:15 -0400 Subject: [PATCH] Added GetAAPercent() to Perl and Lua. --- zone/client.h | 1 + zone/lua_client.cpp | 6 ++++++ zone/lua_client.h | 1 + zone/perl_client.cpp | 27 +++++++++++++++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/zone/client.h b/zone/client.h index df7c1fce3..da2188fc7 100644 --- a/zone/client.h +++ b/zone/client.h @@ -796,6 +796,7 @@ public: void SendClearAA(); inline uint32 GetMaxAAXP(void) const { return max_AAXP; } inline uint32 GetAAXP() const { return m_pp.expAA; } + inline uint32 GetAAPercent() const { return m_epp.perAA; } int16 CalcAAFocus(focusType type, const AA::Rank &rank, uint16 spell_id); void SetAATitle(const char *Title); void SetTitleSuffix(const char *txt); diff --git a/zone/lua_client.cpp b/zone/lua_client.cpp index 6c2345856..403ca82aa 100644 --- a/zone/lua_client.cpp +++ b/zone/lua_client.cpp @@ -185,6 +185,11 @@ uint32 Lua_Client::GetAAExp() { return self->GetAAXP(); } +uint32 Lua_Client::GetAAPercent() { + Lua_Safe_Call_Int(); + return self->GetAAPercent(); +} + uint32 Lua_Client::GetTotalSecondsPlayed() { Lua_Safe_Call_Int(); return self->GetTotalSecondsPlayed(); @@ -1377,6 +1382,7 @@ luabind::scope lua_register_client() { .def("GetWeight", (int(Lua_Client::*)(void))&Lua_Client::GetWeight) .def("GetEXP", (uint32(Lua_Client::*)(void))&Lua_Client::GetEXP) .def("GetAAExp", (uint32(Lua_Client::*)(void))&Lua_Client::GetAAExp) + .def("GetAAPercent", (uint32(Lua_Client::*)(void))&Lua_Client::GetAAPercent) .def("GetTotalSecondsPlayed", (uint32(Lua_Client::*)(void))&Lua_Client::GetTotalSecondsPlayed) .def("UpdateLDoNPoints", (void(Lua_Client::*)(int,uint32))&Lua_Client::UpdateLDoNPoints) .def("SetDeity", (void(Lua_Client::*)(int))&Lua_Client::SetDeity) diff --git a/zone/lua_client.h b/zone/lua_client.h index 36ea2b8a4..a0a5a9083 100644 --- a/zone/lua_client.h +++ b/zone/lua_client.h @@ -63,6 +63,7 @@ public: int GetWeight(); uint32 GetEXP(); uint32 GetAAExp(); + uint32 GetAAPercent(); uint32 GetTotalSecondsPlayed(); void UpdateLDoNPoints(int points, uint32 theme); void SetDeity(int v); diff --git a/zone/perl_client.cpp b/zone/perl_client.cpp index 76c085714..de334d5d0 100644 --- a/zone/perl_client.cpp +++ b/zone/perl_client.cpp @@ -871,6 +871,32 @@ XS(XS_Client_GetAAExp) XSRETURN(1); } +XS(XS_Client_GetAAPercent); +XS(XS_Client_GetAAPercent) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Client::GetAAPercent(THIS)"); + { + Client* THIS; + uint32 RETVAL; + dXSTARG; + + 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->GetAAPercent(); + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + XS(XS_Client_GetTotalSecondsPlayed); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_GetTotalSecondsPlayed) { @@ -6465,6 +6491,7 @@ XS(boot_Client) newXSproto(strcpy(buf, "GetWeight"), XS_Client_GetWeight, file, "$"); newXSproto(strcpy(buf, "GetEXP"), XS_Client_GetEXP, file, "$"); newXSproto(strcpy(buf, "GetAAExp"), XS_Client_GetAAExp, file, "$"); + newXSproto(strcpy(buf, "GetAAPercent"), XS_Client_GetAAPercent, file, "$"); newXSproto(strcpy(buf, "GetTotalSecondsPlayed"), XS_Client_GetTotalSecondsPlayed, file, "$"); newXSproto(strcpy(buf, "UpdateLDoNPoints"), XS_Client_UpdateLDoNPoints, file, "$$$"); newXSproto(strcpy(buf, "SetDeity"), XS_Client_SetDeity, file, "$$");