From 39f70b7b843d926eeb534ac1de25cc38b13c493d Mon Sep 17 00:00:00 2001 From: navewindre Date: Mon, 3 Sep 2018 23:48:51 +0200 Subject: ah --- internal_rewrite/simple_settings.hpp | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'internal_rewrite/simple_settings.hpp') diff --git a/internal_rewrite/simple_settings.hpp b/internal_rewrite/simple_settings.hpp index 5d5636e..6371992 100644 --- a/internal_rewrite/simple_settings.hpp +++ b/internal_rewrite/simple_settings.hpp @@ -143,22 +143,38 @@ public: __declspec( noinline ) void load( const char* path, const char* file ) override { static char str[ MAX_PATH ]; + static char full_path[ MAX_PATH ]; + static bool taken = false; - GetModuleFileNameA( nullptr, str, MAX_PATH - 1 ); - PathRemoveFileSpecA( str ); - strcat_s< MAX_PATH >( str, "\\csgo\\cfg\\" ); - strcat_s< MAX_PATH >( str, file ); + if( !taken ) { + GetModuleFileNameA( nullptr, str, MAX_PATH - 1 ); + PathRemoveFileSpecA( str ); + strcat_s< MAX_PATH >( str, "\\csgo\\cfg\\" ); + + taken = true; + } + + memcpy( full_path, str, MAX_PATH ); + strcat_s< MAX_PATH >( full_path, file ); simple_load( path, std::to_string( name_ ).c_str( ), &value_, sizeof( value_ ), str ); } __declspec( noinline ) void save( const char* path, const char* file ) const override { static char str[ MAX_PATH ]; + static char full_path[ MAX_PATH ]; + static bool taken = false; + + if( !taken ) { + GetModuleFileNameA( nullptr, str, MAX_PATH - 1 ); + PathRemoveFileSpecA( str ); + strcat_s< MAX_PATH >( str, "\\csgo\\cfg\\" ); + + taken = true; + } - GetModuleFileNameA( nullptr, str, MAX_PATH - 1 ); - PathRemoveFileSpecA( str ); - strcat_s< MAX_PATH >( str, "\\csgo\\cfg\\" ); - strcat_s< MAX_PATH >( str, file ); + memcpy( full_path, str, MAX_PATH ); + strcat_s< MAX_PATH >( full_path, file ); simple_save( path, std::to_string( name_ ).c_str( ), &value_, sizeof( value_ ), str ); } -- cgit v1.2.3