mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-11-27 13:14:01 +08:00
don't bypass local_storage when saving .ini files in settings_parser
This commit is contained in:
parent
68a65696e5
commit
6b71752fc0
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
//returns game appid
|
//returns game appid
|
||||||
uint32 create_localstorage_settings(Settings **settings_client_out, Settings **settings_server_out, Local_Storage **local_storage_out);
|
uint32 create_localstorage_settings(Settings **settings_client_out, Settings **settings_server_out, Local_Storage **local_storage_out);
|
||||||
void save_global_settings(const char *name, const char *language);
|
void save_global_settings(class Local_Storage *local_storage, const char *name, const char *language);
|
||||||
|
|
||||||
bool settings_disable_lan_only();
|
bool settings_disable_lan_only();
|
||||||
|
|
||||||
|
@ -53,24 +53,22 @@ typedef struct IniValue {
|
|||||||
};
|
};
|
||||||
} IniValue;
|
} IniValue;
|
||||||
|
|
||||||
static void save_global_ini_value(const char *filename, const char *section, const char *key, IniValue val, const char *comment = nullptr) {
|
static void save_global_ini_value(class Local_Storage *local_storage, const char *filename, const char *section, const char *key, IniValue val, const char *comment = nullptr) {
|
||||||
CSimpleIniA new_ini{};
|
CSimpleIniA new_ini{};
|
||||||
new_ini.SetUnicode();
|
new_ini.SetUnicode();
|
||||||
new_ini.SetSpaces(false);
|
new_ini.SetSpaces(false);
|
||||||
|
|
||||||
auto fullpath = utf8_decode(Local_Storage::get_user_appdata_path() + Local_Storage::settings_storage_folder + PATH_SEPARATOR + filename);
|
auto sz = local_storage->data_settings_size(filename);
|
||||||
if (!common_helpers::create_dir(fullpath)) return;
|
if (sz > 0) {
|
||||||
|
std::vector<char> ini_file_data(sz);
|
||||||
std::ifstream ini_file( fullpath, std::ios::binary | std::ios::in);
|
auto read = local_storage->get_data_settings(filename, &ini_file_data[0], ini_file_data.size());
|
||||||
if (ini_file.is_open()) {
|
if (read == sz) {
|
||||||
new_ini.LoadData(ini_file);
|
new_ini.LoadData(&ini_file_data[0], ini_file_data.size());
|
||||||
ini_file.close();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ofstream new_ini_file( fullpath, std::ios::binary | std::ios::out);
|
|
||||||
if (new_ini_file.is_open()) {
|
|
||||||
std::string comment_str{};
|
std::string comment_str{};
|
||||||
if (comment) {
|
if (comment && comment[0]) {
|
||||||
comment_str.append("# ").append(comment);
|
comment_str.append("# ").append(comment);
|
||||||
comment = comment_str.c_str();
|
comment = comment_str.c_str();
|
||||||
}
|
}
|
||||||
@ -96,9 +94,11 @@ static void save_global_ini_value(const char *filename, const char *section, con
|
|||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_ini.Save(new_ini_file, false);
|
std::string ini_buff{};
|
||||||
new_ini_file.close();
|
if (new_ini.Save(ini_buff, false) == SI_OK) {
|
||||||
|
local_storage->store_data_settings(filename, &ini_buff[0], ini_buff.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void merge_ini(const CSimpleIniA &new_ini, bool overwrite = false) {
|
static void merge_ini(const CSimpleIniA &new_ini, bool overwrite = false) {
|
||||||
@ -514,6 +514,7 @@ static uint16 parse_listen_port(class Local_Storage *local_storage)
|
|||||||
if (port == 0) {
|
if (port == 0) {
|
||||||
port = DEFAULT_PORT;
|
port = DEFAULT_PORT;
|
||||||
save_global_ini_value(
|
save_global_ini_value(
|
||||||
|
local_storage,
|
||||||
config_ini_main,
|
config_ini_main,
|
||||||
"main::connectivity", "listen_port", IniValue((long)port),
|
"main::connectivity", "listen_port", IniValue((long)port),
|
||||||
"change the UDP/TCP port the emulator listens on"
|
"change the UDP/TCP port the emulator listens on"
|
||||||
@ -529,6 +530,7 @@ static std::string parse_account_name(class Local_Storage *local_storage)
|
|||||||
if (!name || !name[0]) {
|
if (!name || !name[0]) {
|
||||||
name = DEFAULT_NAME;
|
name = DEFAULT_NAME;
|
||||||
save_global_ini_value(
|
save_global_ini_value(
|
||||||
|
local_storage,
|
||||||
config_ini_user,
|
config_ini_user,
|
||||||
"user::general", "account_name", IniValue(name),
|
"user::general", "account_name", IniValue(name),
|
||||||
"user account name"
|
"user account name"
|
||||||
@ -547,6 +549,7 @@ static CSteamID parse_user_steam_id(class Local_Storage *local_storage)
|
|||||||
char temp_text[32]{};
|
char temp_text[32]{};
|
||||||
snprintf(temp_text, sizeof(temp_text), "%llu", (uint64)user_id.ConvertToUint64());
|
snprintf(temp_text, sizeof(temp_text), "%llu", (uint64)user_id.ConvertToUint64());
|
||||||
save_global_ini_value(
|
save_global_ini_value(
|
||||||
|
local_storage,
|
||||||
config_ini_user,
|
config_ini_user,
|
||||||
"user::general", "account_steamid", IniValue(temp_text),
|
"user::general", "account_steamid", IniValue(temp_text),
|
||||||
"Steam64 format"
|
"Steam64 format"
|
||||||
@ -564,6 +567,7 @@ static std::string parse_current_language(class Local_Storage *local_storage)
|
|||||||
if (!lang || !lang[0]) {
|
if (!lang || !lang[0]) {
|
||||||
lang = DEFAULT_LANGUAGE;
|
lang = DEFAULT_LANGUAGE;
|
||||||
save_global_ini_value(
|
save_global_ini_value(
|
||||||
|
local_storage,
|
||||||
config_ini_user,
|
config_ini_user,
|
||||||
"user::general", "language", IniValue(lang),
|
"user::general", "language", IniValue(lang),
|
||||||
"the language reported to the game, default is 'english', check 'API language code' in https://partner.steamgames.com/doc/store/localization/languages"
|
"the language reported to the game, default is 'english', check 'API language code' in https://partner.steamgames.com/doc/store/localization/languages"
|
||||||
@ -1132,12 +1136,13 @@ static void parse_auto_accept_invite(class Settings *settings_client, class Sett
|
|||||||
}
|
}
|
||||||
|
|
||||||
// user::general::ip_country
|
// user::general::ip_country
|
||||||
static void parse_ip_country(class Settings *settings_client, class Settings *settings_server)
|
static void parse_ip_country(class Local_Storage *local_storage, class Settings *settings_client, class Settings *settings_server)
|
||||||
{
|
{
|
||||||
std::string line(common_helpers::to_upper(common_helpers::string_strip(ini.GetValue("user::general", "ip_country", ""))));
|
std::string line(common_helpers::to_upper(common_helpers::string_strip(ini.GetValue("user::general", "ip_country", ""))));
|
||||||
if (line.empty()) {
|
if (line.empty()) {
|
||||||
line = DEFAULT_IP_COUNTRY;
|
line = DEFAULT_IP_COUNTRY;
|
||||||
save_global_ini_value(
|
save_global_ini_value(
|
||||||
|
local_storage,
|
||||||
config_ini_user,
|
config_ini_user,
|
||||||
"user::general", "ip_country", IniValue(line.c_str()),
|
"user::general", "ip_country", IniValue(line.c_str()),
|
||||||
"ISO 3166-1-alpha-2 format, use this link to get the 'Alpha-2' country code: https://www.iban.com/country-codes"
|
"ISO 3166-1-alpha-2 format, use this link to get the 'Alpha-2' country code: https://www.iban.com/country-codes"
|
||||||
@ -1439,6 +1444,9 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
|
|||||||
std::set<std::string> supported_languages(parse_supported_languages(local_storage, language));
|
std::set<std::string> supported_languages(parse_supported_languages(local_storage, language));
|
||||||
|
|
||||||
bool steam_offline_mode = ini.GetBoolValue("main::connectivity", "offline", false);
|
bool steam_offline_mode = ini.GetBoolValue("main::connectivity", "offline", false);
|
||||||
|
if (steam_offline_mode) {
|
||||||
|
PRINT_DEBUG("setting emu to offline mode");
|
||||||
|
}
|
||||||
Settings *settings_client = new Settings(user_id, CGameID(appid), name, language, steam_offline_mode);
|
Settings *settings_client = new Settings(user_id, CGameID(appid), name, language, steam_offline_mode);
|
||||||
Settings *settings_server = new Settings(generate_steam_id_server(), CGameID(appid), name, language, steam_offline_mode);
|
Settings *settings_server = new Settings(generate_steam_id_server(), CGameID(appid), name, language, steam_offline_mode);
|
||||||
|
|
||||||
@ -1474,7 +1482,7 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
|
|||||||
parse_mods_folder(settings_client, settings_server, local_storage);
|
parse_mods_folder(settings_client, settings_server, local_storage);
|
||||||
load_gamecontroller_settings(settings_client);
|
load_gamecontroller_settings(settings_client);
|
||||||
parse_auto_accept_invite(settings_client, settings_server);
|
parse_auto_accept_invite(settings_client, settings_server);
|
||||||
parse_ip_country(settings_client, settings_server);
|
parse_ip_country(local_storage, settings_client, settings_server);
|
||||||
|
|
||||||
parse_overlay_general_config(settings_client, settings_server);
|
parse_overlay_general_config(settings_client, settings_server);
|
||||||
load_overlay_appearance(settings_client, settings_server, local_storage);
|
load_overlay_appearance(settings_client, settings_server, local_storage);
|
||||||
@ -1488,15 +1496,17 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
|
|||||||
return appid;
|
return appid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void save_global_settings(const char *name, const char *language)
|
void save_global_settings(class Local_Storage *local_storage, const char *name, const char *language)
|
||||||
{
|
{
|
||||||
save_global_ini_value(
|
save_global_ini_value(
|
||||||
|
local_storage,
|
||||||
config_ini_user,
|
config_ini_user,
|
||||||
"user::general", "account_name", IniValue(name),
|
"user::general", "account_name", IniValue(name),
|
||||||
"user account name"
|
"user account name"
|
||||||
);
|
);
|
||||||
|
|
||||||
save_global_ini_value(
|
save_global_ini_value(
|
||||||
|
local_storage,
|
||||||
config_ini_user,
|
config_ini_user,
|
||||||
"user::general", "language", IniValue(language),
|
"user::general", "language", IniValue(language),
|
||||||
"the language reported to the game, default is 'english', check 'API language code' in https://partner.steamgames.com/doc/store/localization/languages"
|
"the language reported to the game, default is 'english', check 'API language code' in https://partner.steamgames.com/doc/store/localization/languages"
|
||||||
|
@ -1482,7 +1482,7 @@ void Steam_Overlay::steam_run_callback()
|
|||||||
save_settings = false;
|
save_settings = false;
|
||||||
|
|
||||||
const char *language_text = valid_languages[current_language];
|
const char *language_text = valid_languages[current_language];
|
||||||
save_global_settings(username_text, language_text);
|
save_global_settings(get_steam_client()->local_storage, username_text, language_text);
|
||||||
get_steam_client()->settings_client->set_local_name(username_text);
|
get_steam_client()->settings_client->set_local_name(username_text);
|
||||||
get_steam_client()->settings_server->set_local_name(username_text);
|
get_steam_client()->settings_server->set_local_name(username_text);
|
||||||
get_steam_client()->settings_client->set_language(language_text);
|
get_steam_client()->settings_client->set_language(language_text);
|
||||||
|
Loading…
Reference in New Issue
Block a user