diff options
Diffstat (limited to 'engines/scumm/he/script_v60he.cpp')
-rw-r--r-- | engines/scumm/he/script_v60he.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/engines/scumm/he/script_v60he.cpp b/engines/scumm/he/script_v60he.cpp index e26dd413a4..0ccb12555b 100644 --- a/engines/scumm/he/script_v60he.cpp +++ b/engines/scumm/he/script_v60he.cpp @@ -399,6 +399,51 @@ const char *ScummEngine_v60he::getOpcodeDesc(byte i) { return _opcodesv60he[i].desc; } +int ScummEngine_v60he::convertFilePath(byte *dst, bool setFilePath) { + debug(1, "convertFilePath: original filePath is %s", dst); + + int len = resStrLen(dst) + 1; + if (dst[0] == ':') { + // Switch all : to / for portablity + int j = 0; + for (int i = 1; i < len; i++) { + if (dst[i] == ':') + dst[j++] = '/'; + else + dst[j++] = dst[i]; + } + } else { + // Switch all \ to / for portablity + for (int i = 0; i < len; i++) { + if (dst[i] == '\\') + dst[i] = '/'; + } + } + + // Strip path + int r = 0; + if (dst[0] == '.' && dst[1] == '/') { + r = 2; + } else if (dst[0] == 'c' && dst[1] == ':') { + for (r = len; r != 0; r--) { + if (dst[r - 1] == '/') + break; + } + } + + if (setFilePath) { + char filePath[256]; + sprintf(filePath, "%s", dst + r); + if (!Common::File::exists(filePath)) { + sprintf(filePath, "%s%s", _saveFileMan->getSavePath(), dst + r); + } + strcpy((char *)dst, filePath); + debug(1, "convertFilePath: filePath is %s", dst); + } + + return r; +} + void ScummEngine_v60he::o60_setState() { int state = pop(); int obj = pop(); |