From 08cac51d5f883a97d759e58bbe95d5eed24b52f5 Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Mon, 29 Jan 2024 16:10:16 -0800 Subject: [PATCH] NSClient: add `void SetInfoKeyFloat(string, float)` and `float GetInfoKeyFloat(string)` methods --- src/shared/NSClient.h | 5 +++++ src/shared/NSClient.qc | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/shared/NSClient.h b/src/shared/NSClient.h index 47c241cd..34f68100 100644 --- a/src/shared/NSClient.h +++ b/src/shared/NSClient.h @@ -71,6 +71,11 @@ public: /** Get the string value of an InfoKey. */ nonvirtual string GetInfoKey(string); + /** Floating point based version of SetInfoKey(). */ + nonvirtual void SetInfoKeyFloat(string, float); + /** Floating point based version of GetInfoKey(). */ + nonvirtual float GetInfoKeyFloat(string); + /* overrides */ virtual void Save(float); virtual void Restore(string,string); diff --git a/src/shared/NSClient.qc b/src/shared/NSClient.qc index 2365eb93..9b6de012 100644 --- a/src/shared/NSClient.qc +++ b/src/shared/NSClient.qc @@ -75,6 +75,18 @@ NSClient::GetInfoKey(string strKey) return infokey(this, strKey); } +void +NSClient::SetInfoKeyFloat(string strKey, float floatValue) +{ + forceinfokey(this, strKey, ftos(floatValue)); +} + +float +NSClient::GetInfoKeyFloat(string strKey) +{ + return infokeyf(this, strKey); +} + #endif void