Skip to content

Commit

Permalink
SYMBIAN: Can find and use game data placed by installer on any drive.
Browse files Browse the repository at this point in the history
Apply style fixes from #3170
  • Loading branch information
fedor4ever authored and sev- committed Jul 27, 2021
1 parent b4218c9 commit 10028c8
Showing 1 changed file with 34 additions and 23 deletions.
57 changes: 34 additions & 23 deletions backends/platform/symbian/src/SymbianOS.cpp
Expand Up @@ -31,7 +31,7 @@
#include <eikenv.h> // for CEikonEnv::Static()

#if (__GNUC__ && __cplusplus)
//If a pop has no matching push, the command-line options are restored.
// If a pop has no matching push, the command-line options are restored.
#pragma GCC diagnostic pop
#endif

Expand All @@ -57,12 +57,12 @@
////////// extern "C" ///////////////////////////////////////////////////
namespace Symbian {

// make this easily available everywhere
// Make this easily available everywhere.
char *GetExecutablePath() {
return CSDLApp::GetExecutablePathCStr();
}

} // namespace Symbian {
} // namespace Symbian.

////////// OSystem_SDL_Symbian //////////////////////////////////////////

Expand All @@ -77,68 +77,79 @@ void OSystem_SDL_Symbian::init() {
}

void OSystem_SDL_Symbian::initBackend() {
// Calculate the default savepath
// Calculate the default savepath.
Common::String savePath;
savePath = Symbian::GetExecutablePath();
savePath += DEFAULT_SAVE_PATH "\\";
_savefileManager = new DefaultSaveFileManager(savePath);

// If savepath has not already been set then set it
// If savepath has not already been set then set it.
if (!ConfMan.hasKey("savepath")) {
ConfMan.set("savepath", savePath);
}

#if !RELEASE_BUILD
_LIT(KDefaultBetaExtraPath,"!:\\DATA\\ScummVM\\BETA\\");
RFs _RFs = FsSession();
_RFs.SessionPath(_localpath);
_RFs.SetSessionPath(KDefaultBetaExtraPath);

Common::String extrapath;
ConfMan.registerDefault("extrapath", extrapath);
#endif

#if _DEBUG
#warning "set debuglevel = 20"
ConfMan.set("debuglevel", "20");
if (!ConfMan.hasKey("debuglevel"))
printf("debuglevel not set!\n");
#endif
// Ensure that the current set path (might have been altered by the user) exists
// Ensure that the current set path (might have been altered by the user) exists.
Common::String currentPath = ConfMan.get("savepath");
TFileName fname;
TPtrC8 ptr((const unsigned char*)currentPath.c_str(), currentPath.size());
fname.Copy(ptr);
BaflUtils::EnsurePathExistsL(FsSession(), fname);

ConfMan.setBool("FM_high_quality", false);
#if !defined(S60) || defined(S60V3) // S60 has low quality as default
#if !defined(S60) || defined(S60V3) // S60 has low quality as default.
ConfMan.setBool("FM_medium_quality", true);
#else
ConfMan.setBool("FM_medium_quality", false);
#endif
// Symbian OS should have joystick_num set to 0 in the ini file,
// but uiq devices might refuse opening the joystick
// but uiq devices might refuse opening the joystick.
ConfMan.setInt("joystick_num", 0);
ConfMan.setBool("fullscreen", true);
ConfMan.flushToDisk();

if (_mixerManager == nullptr) {
_mixerManager = new SymbianSdlMixerManager();

// Setup and start mixer
// Setup and start mixer.
_mixerManager->init();
}

// Call parent implementation of this method
// Call parent implementation of this method.
OSystem_SDL::initBackend();
}

void OSystem_SDL_Symbian::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
RFs rfs = FsSession();
TChar driveLetter;
TFileName extraPath;

#if !RELEASE_BUILD
_LIT(KDefaultBetaExtraPath,"!:\\DATA\\ScummVM\\BETA\\");
extraPath = KDefaultBetaExtraPath;
#else
_LIT(KDefaultExtraPath,"!:\\DATA\\ScummVM\\");
extraPath = KDefaultExtraPath;
Common::FSNode pluginsNode(Symbian::GetExecutablePath());
if (pluginsNode.exists() && pluginsNode.isDirectory()) {
s.add("SYMBIAN_DATAFOLDER", new Common::FSDirectory(Symbian::GetExecutablePath()), priority);
}
#endif

for (TInt i = EDriveA; i <= EDriveZ; i++) {
if (rfs.DriveToChar(i, driveLetter) != KErrNone)
continue;
extraPath[0] = driveLetter;
if(BaflUtils::FolderExists(rfs, extraPath)){
TBuf8<KMaxFileName> fileName8 = extraPath.Collapse();
s.add("SYMBIAN_DATAFOLDER" + driveLetter, new Common::FSDirectory((char *)fileName8.PtrZ()), priority);
}
}
}

void OSystem_SDL_Symbian::quitWithErrorMsg(const char * /*aMsg*/) {
Expand Down Expand Up @@ -169,9 +180,9 @@ Common::KeymapperDefaultBindings *OSystem_SDL_Symbian::getKeymapperDefaultBindin
}


// Symbian bsearch implementation is flawed
// Symbian bsearch implementation is flawed.
void* scumm_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) {
// Perform binary search
// Perform binary search.
size_t lo = 0;
size_t hi = nmemb;
while (lo < hi) {
Expand All @@ -189,7 +200,7 @@ void* scumm_bsearch(const void *key, const void *base, size_t nmemb, size_t size
return NULL;
}

/** Provide access to file server session. Lifetime managed bu UI framework. */
/** Provide access to file server session. Lifetime managed by UI framework. */
RFs &FsSession() {
return CEikonEnv::Static()->FsSession();
}
Expand Down

0 comments on commit 10028c8

Please sign in to comment.