ISLE.EXE: use iniparser for getting isle.mediaPath

This commit is contained in:
Anonymous Maarten 2024-12-29 18:07:55 +01:00
parent 559faffdb7
commit 19bf6166ee
2 changed files with 16 additions and 6 deletions

View File

@ -140,6 +140,10 @@ IsleApp::~IsleApp()
if (m_savePath) { if (m_savePath) {
delete[] m_savePath; delete[] m_savePath;
} }
if (m_mediaPath) {
delete[] m_mediaPath;
}
} }
// FUNCTION: ISLE 0x401260 // FUNCTION: ISLE 0x401260
@ -175,18 +179,16 @@ void IsleApp::Close()
MxS32 IsleApp::SetupLegoOmni() MxS32 IsleApp::SetupLegoOmni()
{ {
MxS32 result = FALSE; MxS32 result = FALSE;
char mediaPath[256];
GetProfileStringA("LEGO Island", "MediaPath", "", mediaPath, sizeof(mediaPath));
#ifdef COMPAT_MODE #ifdef COMPAT_MODE
MxS32 failure; MxS32 failure;
{ {
MxOmniCreateParam param(mediaPath, m_windowHandle, m_videoParam, MxOmniCreateFlags()); MxOmniCreateParam param(m_mediaPath, m_windowHandle, m_videoParam, MxOmniCreateFlags());
failure = Lego()->Create(param) == FAILURE; failure = Lego()->Create(param) == FAILURE;
} }
#else #else
MxS32 failure = MxS32 failure =
Lego()->Create(MxOmniCreateParam(mediaPath, m_windowHandle, m_videoParam, MxOmniCreateFlags())) == FAILURE; Lego()->Create(MxOmniCreateParam(m_mediaPath, m_windowHandle, m_videoParam, MxOmniCreateFlags())) == FAILURE;
#endif #endif
if (!failure) { if (!failure) {
@ -525,11 +527,14 @@ void IsleApp::LoadConfig()
iniConfig = new char[strlen(m_iniPath) + 1]; iniConfig = new char[strlen(m_iniPath) + 1];
strcpy(iniConfig, m_iniPath); strcpy(iniConfig, m_iniPath);
} }
else { else if (prefPath) {
iniConfig = new char[strlen(prefPath) + strlen("isle.ini") + 1](); iniConfig = new char[strlen(prefPath) + strlen("isle.ini") + 1]();
strcat(iniConfig, prefPath); strcat(iniConfig, prefPath);
strcat(iniConfig, "isle.ini"); strcat(iniConfig, "isle.ini");
} } else {
iniConfig = new char[strlen("isle.ini") + 1];
strcpy(iniConfig, "isle.ini");
}
SDL_Log("Reading configuration from \"%s\"", iniConfig); SDL_Log("Reading configuration from \"%s\"", iniConfig);
dictionary* dict = iniparser_load(iniConfig); dictionary* dict = iniparser_load(iniConfig);
@ -544,6 +549,10 @@ void IsleApp::LoadConfig()
strcpy(m_cdPath, cdPath); strcpy(m_cdPath, cdPath);
MxOmni::SetCD(m_cdPath); MxOmni::SetCD(m_cdPath);
const char *mediaPath = iniparser_getstring(dict, "isle:mediapath", cdPath);
m_mediaPath = new char[strlen(mediaPath) + 1];
strcpy(m_mediaPath, mediaPath);
m_flipSurfaces = iniparser_getboolean(dict, "isle:Flip Surfaces", m_flipSurfaces); m_flipSurfaces = iniparser_getboolean(dict, "isle:Flip Surfaces", m_flipSurfaces);
m_fullScreen = iniparser_getboolean(dict, "isle:Full Screen", m_fullScreen); m_fullScreen = iniparser_getboolean(dict, "isle:Full Screen", m_fullScreen);
m_wideViewAngle = iniparser_getboolean(dict, "isle:Wide View Angle", m_wideViewAngle); m_wideViewAngle = iniparser_getboolean(dict, "isle:Wide View Angle", m_wideViewAngle);

View File

@ -78,6 +78,7 @@ class IsleApp {
SDL_Cursor* m_cursorBusy; // 0x80 SDL_Cursor* m_cursorBusy; // 0x80
SDL_Cursor* m_cursorNo; // 0x84 SDL_Cursor* m_cursorNo; // 0x84
SDL_Cursor* m_cursorCurrent; // 0x88 SDL_Cursor* m_cursorCurrent; // 0x88
char* m_mediaPath;
char* m_iniPath; char* m_iniPath;
}; };