diff options
| author | Travis Howell | 2006-03-25 11:01:00 +0000 |
|---|---|---|
| committer | Travis Howell | 2006-03-25 11:01:00 +0000 |
| commit | ef6baca2ac40bc4652bba9a791db96ca07b2a6a9 (patch) | |
| tree | 9e670543b0bda20122253ed46f4aaf2d0f4d9800 /engines/scumm/he/script_v60he.cpp | |
| parent | a98aea6efd08840fed7fc2bd2e5d2826eb5e4897 (diff) | |
| download | scummvm-rg350-ef6baca2ac40bc4652bba9a791db96ca07b2a6a9.tar.gz scummvm-rg350-ef6baca2ac40bc4652bba9a791db96ca07b2a6a9.tar.bz2 scummvm-rg350-ef6baca2ac40bc4652bba9a791db96ca07b2a6a9.zip | |
Move convertFilePath() to ScummEngine_v60he, to allow use by earlier HE games
svn-id: r21450
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(); |
