[Scummvm-cvs-logs] SF.net SVN: scummvm: [22266] scummvm/trunk/engines/scumm
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Mon May 1 14:32:03 CEST 2006
Revision: 22266
Author: fingolfin
Date: 2006-05-01 14:31:06 -0700 (Mon, 01 May 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=22266&view=rev
Log Message:
-----------
Some cleanup, and added a FIXME comment concerning the wrong usage of getSavePath()
Modified Paths:
--------------
scummvm/trunk/engines/scumm/he/script_v60he.cpp
scummvm/trunk/engines/scumm/he/script_v72he.cpp
scummvm/trunk/engines/scumm/plugin.cpp
Modified: scummvm/trunk/engines/scumm/he/script_v60he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v60he.cpp 2006-05-01 21:06:34 UTC (rev 22265)
+++ scummvm/trunk/engines/scumm/he/script_v60he.cpp 2006-05-01 21:31:06 UTC (rev 22266)
@@ -433,9 +433,12 @@
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 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 @@
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 @@
}
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);
Modified: scummvm/trunk/engines/scumm/he/script_v72he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v72he.cpp 2006-05-01 21:06:34 UTC (rev 22265)
+++ scummvm/trunk/engines/scumm/he/script_v72he.cpp 2006-05-01 21:31:06 UTC (rev 22266)
@@ -1710,16 +1710,15 @@
void ScummEngine_v72he::o72_openFile() {
int mode, slot, i;
- byte filename[256];
+ byte buffer[256];
mode = pop();
- copyScriptString(filename, sizeof(filename));
+ copyScriptString(buffer, sizeof(buffer));
+ debug(1, "Original filename %s", buffer);
- debug(1,"Original filename %s", filename);
+ const char *filename = (char *)buffer + convertFilePath(buffer);
+ debug(1, "Final filename to %s", filename);
- int r = convertFilePath(filename);
- debug(1,"Final filename to %s", filename + r);
-
slot = -1;
for (i = 1; i < 17; i++) {
if (_hInFileTable[i] == 0 && _hOutFileTable[i] == 0) {
@@ -1732,10 +1731,10 @@
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 @@
}
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);
Modified: scummvm/trunk/engines/scumm/plugin.cpp
===================================================================
--- scummvm/trunk/engines/scumm/plugin.cpp 2006-05-01 21:06:34 UTC (rev 22265)
+++ scummvm/trunk/engines/scumm/plugin.cpp 2006-05-01 21:31:06 UTC (rev 22266)
@@ -1302,13 +1302,13 @@
}
-
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);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list