aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobia Tesan2016-03-05 23:50:59 +0100
committerTobia Tesan2016-03-06 11:36:46 +0100
commit5ad4eca257c975a895153d162ff6f3cdc1ef4afb (patch)
tree7bc1b698506ea8ff2274584c9cc1fc811ea71367
parent83f921fa8003022c59cffc88d5cf1838cb6c6da6 (diff)
downloadscummvm-rg350-5ad4eca257c975a895153d162ff6f3cdc1ef4afb.tar.gz
scummvm-rg350-5ad4eca257c975a895153d162ff6f3cdc1ef4afb.tar.bz2
scummvm-rg350-5ad4eca257c975a895153d162ff6f3cdc1ef4afb.zip
WINTERMUTE: Use array to store known broken absolute paths
Avoids an if() block that is getting longer
-rw-r--r--engines/wintermute/base/file/base_disk_file.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp
index b474c069db..74ed7960a1 100644
--- a/engines/wintermute/base/file/base_disk_file.cpp
+++ b/engines/wintermute/base/file/base_disk_file.cpp
@@ -113,15 +113,28 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) {
Common::String fixedFilename = filename;
correctSlashes(fixedFilename);
- // Absolute path: TODO: Add specific fallbacks here.
+ // HACK: There are a few games around which mistakenly refer to absolute paths in the scripts.
+ // The original interpreter on Windows usually simply ignores them when it can't find them.
+ // We try to turn the known ones into relative paths.
if (fixedFilename.contains(':')) {
- if (fixedFilename.hasPrefix("c:/windows/fonts/")) { // East Side Story refers to "c:\windows\fonts\framd.ttf"
- fixedFilename = filename.c_str() + 14;
- } else if (fixedFilename.hasPrefix("c:/carol6/svn/data/")) { // Carol Reed 6: Black Circle refers to "c:\carol6\svn\data\sprites\system\help.png"
- fixedFilename = fixedFilename.c_str() + 19;
- } else if (fixedFilename.hasPrefix("f:/dokument/spel 5/demo/data/")) { // Carol Reed 5 (non-demo) refers to "f:\dokument\spel 5\demo\data\scenes\credits\op_cred_00\op_cred_00.jpg"
- fixedFilename = fixedFilename.c_str() + 29;
- } else {
+ Common::String knownPrefixes[] = { // Known absolute paths
+ "c:/windows/fonts/", // East Side Story refers to "c:\windows\fonts\framd.ttf"
+ "c:/carol6/svn/data/", // Carol Reed 6: Black Circle refers to "c:\carol6\svn\data\sprites\system\help.png"
+ "f:/dokument/spel 5/demo/data/" // Carol Reed 5 (non-demo) refers to "f:\dokument\spel 5\demo\data\scenes\credits\op_cred_00\op_cred_00.jpg"
+ };
+
+ bool matched = false;
+
+ for (uint i = 0; i < ARRAYSIZE(knownPrefixes); i++) {
+ if (fixedFilename.hasPrefix(knownPrefixes[i])) {
+ fixedFilename = filename.c_str() + knownPrefixes[i].size();
+ matched = true;
+ }
+ }
+
+ if (!matched) {
+ // fixedFilename is unchanged and thus still broken, none of the above workarounds worked.
+ // We can only bail out
error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str());
}
}