From 9e57068192eec55c9ed782f6fbc009a69e0d578d Mon Sep 17 00:00:00 2001 From: Ender's Games Date: Mon, 20 Aug 2018 14:21:23 -0400 Subject: [PATCH] Config: Only load modified game settings, don't save There is no reason to build a configuration file of duplicate settings. The user can acquire the defaults from the config section and only inject the changes into the game section. --- core/cfg/cfg.cpp | 15 ++++++++++++--- core/cfg/cfg.h | 1 + core/nullDC.cpp | 20 ++++++++++---------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/core/cfg/cfg.cpp b/core/cfg/cfg.cpp index f73eb7868..56cfa01cc 100644 --- a/core/cfg/cfg.cpp +++ b/core/cfg/cfg.cpp @@ -136,7 +136,7 @@ string cfgLoadStr(const wchar * Section, const wchar * Key, const wchar* Defaul { if(!cfgdb.has_entry(string(Section), string(Key))) { - cfgSaveStr(Section, Key, Default); + cfgSaveStr(Section, Key, Default); } return cfgdb.get(string(Section), string(Key), string(Default)); } @@ -155,11 +155,20 @@ s32 cfgLoadInt(const wchar * Section, const wchar * Key,s32 Default) { if(!cfgdb.has_entry(string(Section), string(Key))) { - cfgSaveInt(Section, Key, Default); + cfgSaveInt(Section, Key, Default); } return cfgdb.get_int(string(Section), string(Key), Default); } +s32 cfgGameInt(const wchar * Section, const wchar * Key,s32 Default) +{ + if(cfgdb.has_entry(string(Section), string(Key))) + { + return cfgdb.get_int(string(Section), string(Key), Default); + } + return Default; +} + void cfgSaveBool(const wchar * Section, const wchar * Key, bool BoolValue) { cfgdb.set_bool(string(Section), string(Key), BoolValue); @@ -173,7 +182,7 @@ bool cfgLoadBool(const wchar * Section, const wchar * Key,bool Default) { if(!cfgdb.has_entry(string(Section), string(Key))) { - cfgSaveBool(Section, Key, Default); + cfgSaveBool(Section, Key, Default); } return cfgdb.get_bool(string(Section), string(Key), Default); } diff --git a/core/cfg/cfg.h b/core/cfg/cfg.h index 6286728a2..b4bef336b 100644 --- a/core/cfg/cfg.h +++ b/core/cfg/cfg.h @@ -11,6 +11,7 @@ bool cfgOpen(); s32 cfgLoadInt(const wchar * lpSection, const wchar * lpKey,s32 Default); +s32 cfgGameInt(const wchar * lpSection, const wchar * lpKey,s32 Default); void cfgSaveInt(const wchar * lpSection, const wchar * lpKey, s32 Int); void cfgLoadStr(const wchar * lpSection, const wchar * lpKey, wchar * lpReturn,const wchar* lpDefault); string cfgLoadStr(const wchar * Section, const wchar * Key, const wchar* Default); diff --git a/core/nullDC.cpp b/core/nullDC.cpp index 5c6991537..24c610236 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -313,19 +313,19 @@ void LoadCustom() char *reios_id = reios_disk_id(); cfgSaveStr(reios_id, "software.name", reios_software_name); - settings.dynarec.idleskip = cfgLoadInt(reios_id,"Dynarec.idleskip", settings.dynarec.idleskip ? 1 : 0) != 0; - settings.dynarec.unstable_opt = cfgLoadInt(reios_id,"Dynarec.unstable-opt", settings.dynarec.unstable_opt); - settings.dynarec.safemode = cfgLoadInt(reios_id,"Dynarec.safemode", settings.dynarec.safemode); - settings.rend.ModifierVolumes = cfgLoadInt(reios_id,"rend.ModifierVolumes", settings.rend.ModifierVolumes); - settings.rend.Clipping = cfgLoadInt(reios_id,"rend.Clipping", settings.rend.Clipping); + settings.dynarec.idleskip = cfgGameInt(reios_id,"Dynarec.idleskip", settings.dynarec.idleskip ? 1 : 0) != 0; + settings.dynarec.unstable_opt = cfgGameInt(reios_id,"Dynarec.unstable-opt", settings.dynarec.unstable_opt); + settings.dynarec.safemode = cfgGameInt(reios_id,"Dynarec.safemode", settings.dynarec.safemode); + settings.rend.ModifierVolumes = cfgGameInt(reios_id,"rend.ModifierVolumes", settings.rend.ModifierVolumes); + settings.rend.Clipping = cfgGameInt(reios_id,"rend.Clipping", settings.rend.Clipping); - settings.pvr.subdivide_transp = cfgLoadInt(reios_id,"pvr.Subdivide", settings.pvr.subdivide_transp); + settings.pvr.subdivide_transp = cfgGameInt(reios_id,"pvr.Subdivide", settings.pvr.subdivide_transp); - settings.pvr.ta_skip = cfgLoadInt(reios_id,"ta.skip", settings.pvr.ta_skip); - settings.pvr.rend = cfgLoadInt(reios_id,"pvr.rend", settings.pvr.rend); + settings.pvr.ta_skip = cfgGameInt(reios_id,"ta.skip", settings.pvr.ta_skip); + settings.pvr.rend = cfgGameInt(reios_id,"pvr.rend", settings.pvr.rend); - settings.pvr.MaxThreads = cfgLoadInt(reios_id, "pvr.MaxThreads", settings.pvr.MaxThreads); - settings.pvr.SynchronousRender = cfgLoadInt(reios_id, "pvr.SynchronousRendering", settings.pvr.SynchronousRender); + settings.pvr.MaxThreads = cfgGameInt(reios_id, "pvr.MaxThreads", settings.pvr.MaxThreads); + settings.pvr.SynchronousRender = cfgGameInt(reios_id, "pvr.SynchronousRendering", settings.pvr.SynchronousRender); } void SaveSettings()