summaryrefslogtreecommitdiff
path: root/internal_rewrite/simple_settings.hpp
diff options
context:
space:
mode:
authornavewindre <boneyaard@gmail.com>2018-09-02 00:10:54 +0200
committernavewindre <boneyaard@gmail.com>2018-09-02 00:10:54 +0200
commita2712607137b820e4f4a875636b04e32b59a53c9 (patch)
tree18eb47286b33baf93629f6a8f939bde5f01e85f5 /internal_rewrite/simple_settings.hpp
parent25ecefe33613fb1d12e005efa73f92dc16090624 (diff)
a
Diffstat (limited to 'internal_rewrite/simple_settings.hpp')
-rw-r--r--internal_rewrite/simple_settings.hpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/internal_rewrite/simple_settings.hpp b/internal_rewrite/simple_settings.hpp
index 31701cd..74b4d43 100644
--- a/internal_rewrite/simple_settings.hpp
+++ b/internal_rewrite/simple_settings.hpp
@@ -3,10 +3,13 @@
#include <memory>
#include <vector>
#include <string>
+#include <Shlwapi.h>
#include "util.hpp"
#include "fnv.hpp"
+#pragma comment( lib, "Shlwapi.lib" )
+
//nama stuff
extern void simple_save( const char* path, const char* name, const void* src, size_t size, const char* filename );
extern void simple_load( const char* path, const char* name, void* dest, size_t size, const char* filename );
@@ -91,10 +94,24 @@ public:
};
__declspec( noinline ) void load( const char* path, const char* file ) override {
+ static char str[ MAX_PATH ];
+
+ GetModuleFileNameA( nullptr, str, MAX_PATH - 1 );
+ PathRemoveFileSpecA( str );
+ strcat_s< MAX_PATH >( str, path );
+ strcat_s< MAX_PATH >( str, "\\" );
+
GetPrivateProfileStringA( path, std::to_string( m_name ).c_str( ), "", m_value, L, file );
}
__declspec( noinline ) void save( const char* path, const char* file ) const override {
+ static char str[ MAX_PATH ];
+
+ GetModuleFileNameA( nullptr, str, MAX_PATH - 1 );
+ PathRemoveFileSpecA( str );
+ strcat_s< MAX_PATH >( str, path );
+ strcat_s< MAX_PATH >( str, "\\" );
+
WritePrivateProfileStringA( path, std::to_string( m_name ).c_str( ), m_value, file );
}
@@ -124,9 +141,25 @@ public:
holder_ptr->register_( this );
}
- __declspec( noinline ) void load( const char* path, const char* file ) override { simple_load( path, std::to_string( name_ ).c_str( ), &value_, sizeof( value_ ), file ); }
+ __declspec( noinline ) void load( const char* path, const char* file ) override {
+ static char str[ MAX_PATH ];
+
+ GetModuleFileNameA( nullptr, str, MAX_PATH - 1 );
+ PathRemoveFileSpecA( str );
+ strcat_s< MAX_PATH >( str, "\\" );
+
+ simple_load( str, std::to_string( name_ ).c_str( ), &value_, sizeof( value_ ), file );
+ }
+
+ __declspec( noinline ) void save( const char* path, const char* file ) const override {
+ static char str[ MAX_PATH ];
- __declspec( noinline ) void save( const char* path, const char* file ) const override { simple_save( path, std::to_string( name_ ).c_str( ), &value_, sizeof( value_ ), file ); }
+ GetModuleFileNameA( nullptr, str, MAX_PATH - 1 );
+ PathRemoveFileSpecA( str );
+ strcat_s< MAX_PATH >( str, "\\" );
+
+ simple_save( str, std::to_string( name_ ).c_str( ), &value_, sizeof( value_ ), file );
+ }
__forceinline operator T&( ) { return value_; }
__forceinline T* operator &( ) { return &value_; }