aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scumm/resource.cpp7
-rw-r--r--scumm/scumm.cpp10
2 files changed, 11 insertions, 6 deletions
diff --git a/scumm/resource.cpp b/scumm/resource.cpp
index 46b420a2d0..15dd50fbfa 100644
--- a/scumm/resource.cpp
+++ b/scumm/resource.cpp
@@ -150,11 +150,12 @@ void ScummEngine::openRoom(const int room) {
// If we have substitute
if (_substResFileNameIndex > 0 && !(_platform == Common::kPlatformNES || _platform == Common::kPlatformC64)) {
char tmpBuf[128];
-
generateSubstResFileName(buf, tmpBuf, sizeof(tmpBuf));
strcpy(buf, tmpBuf);
- generateSubstResFileName(buf2, tmpBuf, sizeof(tmpBuf));
- strcpy(buf2, tmpBuf);
+ if (buf2[0]) {
+ generateSubstResFileName(buf2, tmpBuf, sizeof(tmpBuf));
+ strcpy(buf2, tmpBuf);
+ }
}
result = openResourceFile(buf, encByte);
diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp
index 89275cf53e..fe0de5a8da 100644
--- a/scumm/scumm.cpp
+++ b/scumm/scumm.cpp
@@ -3183,16 +3183,20 @@ static int generateSubstResFileName_(const char *filename, char *buf, int bufsiz
if (index <= 0)
return -1;
- char num = filename[strlen(filename) - 1];
+ size_t len = strlen(filename);
+ assert(len >= 5);
+
+ char num = filename[len - 1];
// In some cases we have .(a) and .(b) extensions
if (num == ')')
- num = filename[strlen(filename) - 2];
+ num = filename[len - 2];
const char *ext = NULL;
ext = strrchr(filename, '.');
- size_t len = (ext != NULL) ? ext - filename : strlen(filename);
+ if (ext)
+ len = ext - filename;
for (int i = index; substResFileNameTable[i].winName; i++) {
if (!scumm_strnicmp(filename, substResFileNameTable[i].winName, len)) {