From 90c1619363d89e0ab041f72945b36cfde8b2917a Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 3 Nov 2018 11:54:21 +0000 Subject: gay shit --- internal_rewrite/simple_settings.hpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'internal_rewrite/simple_settings.hpp') diff --git a/internal_rewrite/simple_settings.hpp b/internal_rewrite/simple_settings.hpp index 8dcfaca..9dffa55 100644 --- a/internal_rewrite/simple_settings.hpp +++ b/internal_rewrite/simple_settings.hpp @@ -20,6 +20,7 @@ public: virtual void load( const char* path, const char* file ) = 0; virtual void save( const char* path, const char* file ) const = 0; + virtual void reset( ) const = 0; virtual void register_( ISettingNode* node_ptr ) = 0; virtual bool has_nodes( ) { return false; } virtual hash_t get_hash( ) { return 0; } @@ -59,6 +60,11 @@ public: x->save( full_path, file ); } + __declspec( noinline ) void reset( ) const override { + for( auto x : setting_nodes_ ) + x->reset( ); + } + auto& get_nodes( ) { return setting_nodes_; } @@ -115,6 +121,7 @@ public: WritePrivateProfileStringA( path, std::to_string( m_name ).c_str( ), m_value, file ); } + char* get( ) { return m_value; } @@ -129,13 +136,15 @@ class con_var : public ISetting { public: __declspec( noinline ) con_var( SettingHolder* holder_ptr, hash_t name ) : name_( name ), + original_{ }, is_float_( std::is_floating_point_v< T > ), is_integral_( std::is_integral_v< T > ) { holder_ptr->register_( this ); } - __declspec( noinline ) con_var( SettingHolder* holder_ptr, hash_t name , const T& rhs ) : + __declspec( noinline ) con_var( SettingHolder* holder_ptr, hash_t name, const T& rhs ) : value_( rhs ), name_( name ), + original_( value_ ), is_float_( std::is_floating_point_v< T > ), is_integral_( std::is_integral_v< T > ) { holder_ptr->register_( this ); @@ -181,6 +190,11 @@ public: simple_save( path, std::to_string( name_ ).c_str( ), &value_, sizeof( value_ ), full_path ); } + __declspec( noinline ) void reset( ) const override { + // now this is really epic. + memcpy( ( void* )&value_, ( void* )&original_, sizeof( original_ ) ); + } + __forceinline operator T&( ) { return value_; } __forceinline T* operator &( ) { return &value_; } @@ -261,4 +275,5 @@ private: bool is_float_; bool is_integral_; T value_; + T original_; }; \ No newline at end of file -- cgit v1.2.3