summaryrefslogtreecommitdiff
path: root/cheat/gmod/con_alias.hpp
diff options
context:
space:
mode:
authorboris <wzn@moneybot.cc>2018-11-28 16:00:02 +1300
committerboris <wzn@moneybot.cc>2018-11-28 16:00:02 +1300
commit3d412a4b30a9f7c7f51ea6562e694315948bd3da (patch)
tree26d67dfd1f3e5fd12903ad13e85d0cb8bcf8f21c /cheat/gmod/con_alias.hpp
parente4729e4393d90271a3814c7a79950a660c48325a (diff)
cleaned up
in short, the cheat and loader are now separate solutions. unused stuff was moved into the legacy solution in case anyone wants to compile it or whatever. i can change this back if you want to. also, i configured the loader to compile in x64, and have separate build types for linux and win64
Diffstat (limited to 'cheat/gmod/con_alias.hpp')
-rw-r--r--cheat/gmod/con_alias.hpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/cheat/gmod/con_alias.hpp b/cheat/gmod/con_alias.hpp
new file mode 100644
index 0000000..f00e7df
--- /dev/null
+++ b/cheat/gmod/con_alias.hpp
@@ -0,0 +1,60 @@
+#pragma once
+
+#include <string>
+#include "simple_settings.hpp"
+
+template< typename var_type = bool >
+class con_alias : public ISetting {
+public:
+ con_alias( hash_t hash, con_var< var_type >* var ) :
+ m_var( var ),
+ m_value( var_type{ } ),
+ m_name( hash ),
+ m_is_var( true ) { };
+
+ con_alias( hash_t hash ) :
+ m_name( hash ),
+ m_value( 0 ),
+ m_var( nullptr ),
+ m_is_var( false ) { };
+
+ con_alias( hash_t hash, var_type&& rhs ) :
+ m_name( hash ),
+ m_value( rhs ),
+ m_var( nullptr ),
+ m_is_var( false ) { };
+
+ virtual std::string get_string( ) override {
+ if( m_is_var )
+ return m_var->get_string( );
+ else
+ return std::to_string( m_value );
+ }
+
+ virtual void set_value( int value ) override {
+ set_value_internal( value );
+ }
+
+ virtual void set_value( float value ) override {
+ set_value_internal( value );
+ }
+
+ virtual void set_value( ulong_t value ) override {
+ set_value_internal( value );
+ }
+
+private:
+ template < typename t >
+ void set_value_internal( t&& val ) {
+ if( m_is_var )
+ m_var->set( val );
+ else
+ m_value = ( var_type )( val );
+ }
+
+private:
+ bool m_is_var;
+ hash_t m_name;
+ var_type m_value;
+ con_var< var_type >* m_var;
+}; \ No newline at end of file