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 /engines/scumm/he/script_v60he.cpp | |
| 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
Diffstat (limited to 'engines/scumm/he/script_v60he.cpp')
| -rw-r--r-- | engines/scumm/he/script_v60he.cpp | 24 |
1 files changed, 15 insertions, 9 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); |
