mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-02-03 12:31:15 +00:00
isleapp: Use boolean return in LoadConfig
This to check if the config loaded correctly or not. Seems to be a good solution to the file loading issue. Maybe there's a better solution SetupWindow failing because of a config erroring seems a bit odd.
This commit is contained in:
parent
39f954adad
commit
43f58f04f3
@ -447,7 +447,10 @@ MxU8 IsleApp::MapMouseButtonFlagsToModifier(SDL_MouseButtonFlags p_flags)
|
|||||||
// FUNCTION: ISLE 0x4023e0
|
// FUNCTION: ISLE 0x4023e0
|
||||||
MxResult IsleApp::SetupWindow()
|
MxResult IsleApp::SetupWindow()
|
||||||
{
|
{
|
||||||
LoadConfig();
|
if (!LoadConfig()) {
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
SetupVideoFlags(
|
SetupVideoFlags(
|
||||||
m_fullScreen,
|
m_fullScreen,
|
||||||
m_flipSurfaces,
|
m_flipSurfaces,
|
||||||
@ -522,7 +525,7 @@ MxResult IsleApp::SetupWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: ISLE 0x4028d0
|
// FUNCTION: ISLE 0x4028d0
|
||||||
void IsleApp::LoadConfig()
|
bool IsleApp::LoadConfig()
|
||||||
{
|
{
|
||||||
char* prefPath = SDL_GetPrefPath("isledecomp", "isle");
|
char* prefPath = SDL_GetPrefPath("isledecomp", "isle");
|
||||||
char* iniConfig;
|
char* iniConfig;
|
||||||
@ -549,9 +552,11 @@ void IsleApp::LoadConfig()
|
|||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Loading sane defaults");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Loading sane defaults");
|
||||||
FILE* iniFP = fopen(iniConfig, "wb");
|
FILE* iniFP = fopen(iniConfig, "wb");
|
||||||
|
|
||||||
if (!iniFP) {
|
if (iniFP) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to write config at '%s': %s", iniConfig, strerror(errno));
|
|
||||||
fclose(iniFP);
|
fclose(iniFP);
|
||||||
|
} else {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to write config at '%s': %s", iniConfig, strerror(errno));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dict = iniparser_load(iniConfig);
|
dict = iniparser_load(iniConfig);
|
||||||
@ -639,6 +644,8 @@ void IsleApp::LoadConfig()
|
|||||||
iniparser_freedict(dict);
|
iniparser_freedict(dict);
|
||||||
delete[] iniConfig;
|
delete[] iniConfig;
|
||||||
SDL_free(prefPath);
|
SDL_free(prefPath);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: ISLE 0x402c20
|
// FUNCTION: ISLE 0x402c20
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user