From 3d412a4b30a9f7c7f51ea6562e694315948bd3da Mon Sep 17 00:00:00 2001 From: boris Date: Wed, 28 Nov 2018 16:00:02 +1300 Subject: 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 --- cheat/tf2/con_alias.hpp | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 cheat/tf2/con_alias.hpp (limited to 'cheat/tf2/con_alias.hpp') diff --git a/cheat/tf2/con_alias.hpp b/cheat/tf2/con_alias.hpp new file mode 100644 index 0000000..c943c24 --- /dev/null +++ b/cheat/tf2/con_alias.hpp @@ -0,0 +1,60 @@ +#pragma once + +#include +#include "simple_settings.h" + +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 -- cgit v1.2.3