aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/he/script_v60he.cpp
diff options
context:
space:
mode:
authorTravis Howell2006-03-25 11:01:00 +0000
committerTravis Howell2006-03-25 11:01:00 +0000
commitef6baca2ac40bc4652bba9a791db96ca07b2a6a9 (patch)
tree9e670543b0bda20122253ed46f4aaf2d0f4d9800 /engines/scumm/he/script_v60he.cpp
parenta98aea6efd08840fed7fc2bd2e5d2826eb5e4897 (diff)
downloadscummvm-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.cpp45
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();