Skip to content

Commit

Permalink
Remove use of ConfigSaveSection
Browse files Browse the repository at this point in the history
Known front-ends have been modified to save configuration after plugin
initialization but before running the game. Now it is no longer
necessary for individual plugins to save their config.

Removing calls to ConfigSaveSection from within plugins makes the
mupen64plus-ui-console '--nosaveoptions' parameter work.

I was unable to test complete operation with this patch, due to:
#43

...but I was able to get past the plugin initialization phase, which
verifies that the code change works as desired.
  • Loading branch information
bugfood committed Jan 24, 2019
1 parent 6224403 commit 21d7bb4
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions module.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ static m64p_handle l_ConfigRsp;

ptr_ConfigOpenSection ConfigOpenSection = NULL;
ptr_ConfigDeleteSection ConfigDeleteSection = NULL;
ptr_ConfigSaveSection ConfigSaveSection = NULL;
ptr_ConfigSetParameter ConfigSetParameter = NULL;
ptr_ConfigGetParameter ConfigGetParameter = NULL;
ptr_ConfigSetDefaultFloat ConfigSetDefaultFloat;
Expand Down Expand Up @@ -105,7 +104,7 @@ EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Con
{
ptr_CoreGetAPIVersions CoreAPIVersionFunc;

int ConfigAPIVersion, DebugAPIVersion, VidextAPIVersion, bSaveConfig;
int ConfigAPIVersion, DebugAPIVersion, VidextAPIVersion;
float fConfigParamsVersion = 0.0f;

if (l_PluginInit)
Expand Down Expand Up @@ -134,7 +133,6 @@ EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Con
/* Get the core config function pointers from the library handle */
ConfigOpenSection = (ptr_ConfigOpenSection) osal_dynlib_getproc(CoreLibHandle, "ConfigOpenSection");
ConfigDeleteSection = (ptr_ConfigDeleteSection) osal_dynlib_getproc(CoreLibHandle, "ConfigDeleteSection");
ConfigSaveSection = (ptr_ConfigSaveSection) osal_dynlib_getproc(CoreLibHandle, "ConfigSaveSection");
ConfigSetParameter = (ptr_ConfigSetParameter) osal_dynlib_getproc(CoreLibHandle, "ConfigSetParameter");
ConfigGetParameter = (ptr_ConfigGetParameter) osal_dynlib_getproc(CoreLibHandle, "ConfigGetParameter");
ConfigSetDefaultFloat = (ptr_ConfigSetDefaultFloat) osal_dynlib_getproc(CoreLibHandle, "ConfigSetDefaultFloat");
Expand All @@ -146,10 +144,6 @@ EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Con
!ConfigSetDefaultBool || !ConfigGetParamBool || !ConfigSetDefaultFloat)
return M64ERR_INCOMPATIBLE;

/* ConfigSaveSection was added in Config API v2.1.0 */
if (ConfigAPIVersion >= 0x020100 && !ConfigSaveSection)
return M64ERR_INCOMPATIBLE;

/* get a configuration section handle */
if (ConfigOpenSection("rsp-cxd4", &l_ConfigRsp) != M64ERR_SUCCESS)
{
Expand All @@ -158,28 +152,24 @@ EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Con
}

/* check the section version number */
bSaveConfig = 0;
if (ConfigGetParameter(l_ConfigRsp, "Version", M64TYPE_FLOAT, &fConfigParamsVersion, sizeof(float)) != M64ERR_SUCCESS)
{
DebugMessage(M64MSG_WARNING, "No version number in 'rsp-cxd4' config section. Setting defaults.");
ConfigDeleteSection("rsp-cxd4");
ConfigOpenSection("rsp-cxd4", &l_ConfigRsp);
bSaveConfig = 1;
}
else if (((int) fConfigParamsVersion) != ((int) CONFIG_PARAM_VERSION))
{
DebugMessage(M64MSG_WARNING, "Incompatible version %.2f in 'rsp-cxd4' config section: current is %.2f. Setting defaults.", fConfigParamsVersion, (float) CONFIG_PARAM_VERSION);
ConfigDeleteSection("rsp-cxd4");
ConfigOpenSection("rsp-cxd4", &l_ConfigRsp);
bSaveConfig = 1;
}
else if ((CONFIG_PARAM_VERSION - fConfigParamsVersion) >= 0.0001f)
{
/* handle upgrades */
float fVersion = CONFIG_PARAM_VERSION;
ConfigSetParameter(l_ConfigRsp, "Version", M64TYPE_FLOAT, &fVersion);
DebugMessage(M64MSG_INFO, "Updating parameter set version in 'rsp-cxd4' config section to %.2f", fVersion);
bSaveConfig = 1;
}

#ifndef HLEVIDEO
Expand All @@ -194,9 +184,6 @@ EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Con
ConfigSetDefaultBool(l_ConfigRsp, "WaitForCPUHost", 0, "Force CPU-RSP signals synchronization");
ConfigSetDefaultBool(l_ConfigRsp, "SupportCPUSemaphoreLock", 0, "Support CPU-RSP semaphore lock");

if (bSaveConfig && ConfigAPIVersion >= 0x020100)
ConfigSaveSection("rsp-cxd4");

l_PluginInit = 1;
return M64ERR_SUCCESS;
}
Expand Down Expand Up @@ -674,4 +661,4 @@ DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
}
return TRUE;
}
#endif
#endif

0 comments on commit 21d7bb4

Please sign in to comment.