Guest User

blablabla

a guest
Sep 15th, 2019
145
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void CConfig::Save( const std::string& name ) {
  2. if( name.empty( ) )
  3. return;
  4.  
  5. CreateDirectoryA( u8"C:\\M0ne0N Free\\", NULL );
  6. std::string file = u8"C:\\M0ne0N Free\\" + name;
  7.  
  8. for( auto value : ints ) {
  9. WritePrivateProfileStringA( value->category.c_str( ), value->name.c_str( ), std::to_string( *value->value ).c_str( ), file.c_str( ) );
  10. }
  11.  
  12. for( auto value : floats ) WritePrivateProfileStringA( value->category.c_str( ), value->name.c_str( ), std::to_string( *value->value ).c_str( ), file.c_str( ) );
  13.  
  14. for( auto value : bools ) WritePrivateProfileStringA( value->category.c_str( ), value->name.c_str( ), *value->value ? "true" : "false", file.c_str( ) );
  15. }
  16.  
  17. void CConfig::Load( const std::string& name ) {
  18. if( name.empty( ) )
  19. return;
  20.  
  21. g_ClientState->ForceFullUpdate();
  22.  
  23. CreateDirectoryA( u8"C:\\M0ne0N Free\\", NULL );
  24. std::string file = u8"C:\\M0ne0N Free\\" + name;
  25.  
  26. char value_l[32] = { '\0' };
  27. for( auto value : ints ) {
  28. GetPrivateProfileStringA( value->category.c_str( ), value->name.c_str( ), "0", value_l, 32, file.c_str( ) ); *value->value = atoi( value_l );
  29. }
  30.  
  31. for( auto value : floats ) {
  32. GetPrivateProfileStringA( value->category.c_str( ), value->name.c_str( ), "0.0f", value_l, 32, file.c_str( ) ); *value->value = atof( value_l );
  33. }
  34.  
  35. for( auto value : bools ) {
  36. GetPrivateProfileStringA(value->category.c_str(), value->name.c_str(), "false", value_l, 32, file.c_str()); *value->value = !strcmp(value_l, "true");
  37.  
  38. }
  39. }
RAW Paste Data