From 8ad6a0f500e613621dff522f0e19ef3e7c1137c2 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Tue, 13 Aug 2019 18:34:09 +0300 Subject: [PATCH] Actually expose network statistics functions. Include an int version just inc ase a 32 bit float would overflow. --- source/Entity/Player.cpp | 21 ++++++++++++++++++--- source/Entity/Player.hpp | 7 ++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/source/Entity/Player.cpp b/source/Entity/Player.cpp index 598b20a8..efaa8393 100644 --- a/source/Entity/Player.cpp +++ b/source/Entity/Player.cpp @@ -402,12 +402,25 @@ void CPlayer::SetOptionEx(Int32 option_id, bool toggle, Int32 header, LightObj & } // ------------------------------------------------------------------------------------------------ -Float64 CPlayer::GetNetworkStatistics(Int32 option_id) const +SQFloat CPlayer::GetNetworkStatisticsF(Int32 option_id) const { // Validate the managed identifier Validate(); - // Return the requested information - return _Func->GetNetworkStatistics(m_ID, static_cast< vcmpNetworkStatisticsOption >(option_id)); + // Retrieve the requested information + double value = _Func->GetNetworkStatistics(m_ID, static_cast< vcmpNetworkStatisticsOption >(option_id)); + // Return it in the proper type + return static_cast< SQFloat >(value); +} + +// ------------------------------------------------------------------------------------------------ +SQInteger CPlayer::GetNetworkStatisticsI(Int32 option_id) const +{ + // Validate the managed identifier + Validate(); + // Retrieve the requested information + double value = _Func->GetNetworkStatistics(m_ID, static_cast< vcmpNetworkStatisticsOption >(option_id)); + // Return it in the proper type + return static_cast< SQInteger >(value); } // ------------------------------------------------------------------------------------------------ @@ -2811,6 +2824,8 @@ void Register_CPlayer(HSQUIRRELVM vm) .Func(_SC("GetOption"), &CPlayer::GetOption) .Func(_SC("SetOption"), &CPlayer::SetOption) .Func(_SC("SetOptionEx"), &CPlayer::SetOptionEx) + .Func(_SC("GetNetworkStatisticsF"), &CPlayer::GetNetworkStatisticsF) + .Func(_SC("GetNetworkStatisticsI"), &CPlayer::GetNetworkStatisticsI) .Func(_SC("WorldCompatible"), &CPlayer::IsWorldCompatible) .Func(_SC("SetColor"), &CPlayer::SetColorEx) .Func(_SC("SetColour"), &CPlayer::SetColorEx) diff --git a/source/Entity/Player.hpp b/source/Entity/Player.hpp index fcda63b4..85a1b6eb 100644 --- a/source/Entity/Player.hpp +++ b/source/Entity/Player.hpp @@ -328,7 +328,12 @@ public: /* -------------------------------------------------------------------------------------------- * Retrieve network statistics related to the managed player entity. */ - Float64 GetNetworkStatistics(Int32 option_id) const; + SQFloat GetNetworkStatisticsF(Int32 option_id) const; + + /* -------------------------------------------------------------------------------------------- + * Retrieve network statistics related to the managed player entity. + */ + SQInteger GetNetworkStatisticsI(Int32 option_id) const; /* -------------------------------------------------------------------------------------------- * Retrieve the world in which the managed player entity exists.