diff options
author | Max Horn | 2006-05-01 21:31:06 +0000 |
---|---|---|
committer | Max Horn | 2006-05-01 21:31:06 +0000 |
commit | 77c29d0ab20de8fbdd7954602f3759d110eea2dd (patch) | |
tree | e5691b97406ba519feb935d8fdc4a01a883c8c5a | |
parent | 7e3df42510a2da4de6bc41a3d41ea1f8ddbcd54f (diff) | |
download | scummvm-rg350-77c29d0ab20de8fbdd7954602f3759d110eea2dd.tar.gz scummvm-rg350-77c29d0ab20de8fbdd7954602f3759d110eea2dd.tar.bz2 scummvm-rg350-77c29d0ab20de8fbdd7954602f3759d110eea2dd.zip |
Some cleanup, and added a FIXME comment concerning the wrong usage of getSavePath()
svn-id: r22266
-rw-r--r-- | engines/scumm/he/script_v60he.cpp | 24 | ||||
-rw-r--r-- | engines/scumm/he/script_v72he.cpp | 17 | ||||
-rw-r--r-- | engines/scumm/plugin.cpp | 2 |
3 files changed, 24 insertions, 19 deletions
diff --git a/engines/scumm/he/script_v60he.cpp b/engines/scumm/he/script_v60he.cpp index d8fe03f702..da8f8fbad6 100644 --- a/engines/scumm/he/script_v60he.cpp +++ b/engines/scumm/he/script_v60he.cpp @@ -433,9 +433,12 @@ int ScummEngine_v60he::convertFilePath(byte *dst, bool setFilePath) { if (setFilePath) { char filePath[256]; - sprintf(filePath, "%s", dst + r); + strncpy(filePath, (char *)dst + r, sizeof(filePath)); if (!Common::File::exists(filePath)) { - sprintf(filePath, "%s%s", _saveFileMan->getSavePath(), dst + r); + // FIXME: Using getSavePath() to generate filepaths used with + // File::open is not portable! + strncpy(filePath, _saveFileMan->getSavePath(), sizeof(filePath)); + strncat(filePath, (char *)dst + r, sizeof(filePath)); } strcpy((char *)dst, filePath); debug(1, "convertFilePath: filePath is %s", dst); @@ -986,17 +989,20 @@ void virtScreenSavePackByte(vsPackCtx *ctx, uint8 *&dst, int len, uint8 b) { void ScummEngine_v60he::o60_openFile() { int mode, len, slot, i, r; - byte filename[100]; + byte buffer[100]; + const char *filename; - convertMessageToString(_scriptPointer, filename, sizeof(filename)); + convertMessageToString(_scriptPointer, buffer, sizeof(buffer)); len = resStrLen(_scriptPointer); _scriptPointer += len + 1; - for (r = strlen((char*)filename); r != 0; r--) { - if (filename[r - 1] == '\\') + for (r = strlen((char*)buffer); r != 0; r--) { + if (buffer[r - 1] == '\\') break; } + + filename = (char *)buffer + r; mode = pop(); slot = -1; @@ -1011,10 +1017,10 @@ void ScummEngine_v60he::o60_openFile() { switch(mode) { case 1: // TODO / FIXME: Consider using listSavefiles to avoid unneccessary openForLoading calls - _hInFileTable[slot] = _saveFileMan->openForLoading((char*)filename + r); + _hInFileTable[slot] = _saveFileMan->openForLoading(filename); if (_hInFileTable[slot] == 0) { Common::File *f = new Common::File(); - f->open((char*)filename + r, Common::File::kFileReadMode); + f->open(filename, Common::File::kFileReadMode); if (!f->isOpen()) delete f; else @@ -1022,7 +1028,7 @@ void ScummEngine_v60he::o60_openFile() { } break; case 2: - _hOutFileTable[slot] = _saveFileMan->openForSaving((char*)filename + r); + _hOutFileTable[slot] = _saveFileMan->openForSaving(filename); break; default: error("o60_openFile(): wrong open file mode %d", mode); diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp index ea0657f6b8..fe91e82ccd 100644 --- a/engines/scumm/he/script_v72he.cpp +++ b/engines/scumm/he/script_v72he.cpp @@ -1710,15 +1710,14 @@ void ScummEngine_v72he::o72_jumpToScript() { void ScummEngine_v72he::o72_openFile() { int mode, slot, i; - byte filename[256]; + byte buffer[256]; mode = pop(); - copyScriptString(filename, sizeof(filename)); - - debug(1,"Original filename %s", filename); + copyScriptString(buffer, sizeof(buffer)); + debug(1, "Original filename %s", buffer); - int r = convertFilePath(filename); - debug(1,"Final filename to %s", filename + r); + const char *filename = (char *)buffer + convertFilePath(buffer); + debug(1, "Final filename to %s", filename); slot = -1; for (i = 1; i < 17; i++) { @@ -1732,10 +1731,10 @@ void ScummEngine_v72he::o72_openFile() { switch(mode) { case 1: // TODO / FIXME: Consider using listSavefiles to avoid unneccessary openForLoading calls - _hInFileTable[slot] = _saveFileMan->openForLoading((char*)filename + r); + _hInFileTable[slot] = _saveFileMan->openForLoading(filename); if (_hInFileTable[slot] == 0) { Common::File *f = new Common::File(); - f->open((char*)filename + r, Common::File::kFileReadMode); + f->open(filename, Common::File::kFileReadMode); if (!f->isOpen()) delete f; else @@ -1743,7 +1742,7 @@ void ScummEngine_v72he::o72_openFile() { } break; case 2: - _hOutFileTable[slot] = _saveFileMan->openForSaving((char*)filename + r); + _hOutFileTable[slot] = _saveFileMan->openForSaving(filename); break; default: error("o72_openFile(): wrong open file mode %d", mode); diff --git a/engines/scumm/plugin.cpp b/engines/scumm/plugin.cpp index 61cd5a418b..5764820e22 100644 --- a/engines/scumm/plugin.cpp +++ b/engines/scumm/plugin.cpp @@ -1302,13 +1302,13 @@ PluginError Engine_SCUMM_create(OSystem *syst, Engine **engine) { } - FilesystemNode dir; if (ConfMan.hasKey("path") ) dir = FilesystemNode(ConfMan.get("path")); FSList fslist = dir.listDir(FilesystemNode::kListFilesOnly); Common::List<DetectorResult> results; + // Invoke the detector, but fixed to the specified gameid. detectGames(fslist, results, gameid); |