aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/lab/resource.cpp36
-rw-r--r--engines/lab/resource.h2
2 files changed, 33 insertions, 5 deletions
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index f16fd533ca..096d29361f 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -175,22 +175,50 @@ Common::String Resource::translateFileName(const Common::String filename) {
upperFilename.deleteChar(0);
}
+ if (_vm->getPlatform() == Common::kPlatformDOS) {
+ // Some script of the DOS version uses names used in the Amiga (and Windows) version,
+ // which isn't limited to 8.3 characters. We need to parse upperFilename to detect
+ // the filename, and fix it if required so it matches a DOS filename.
+ while (upperFilename.contains('/') && upperFilename.size()) {
+ fileNameStrFinal += upperFilename[0];
+ upperFilename.deleteChar(0);
+ }
+
+ for (int i = 0; (i < 8) && upperFilename.size() && (upperFilename[0] != '.'); i++) {
+ fileNameStrFinal += upperFilename[0];
+ upperFilename.deleteChar(0);
+ }
+
+ // Remove the extra character in the filename
+ while (upperFilename.size() && (upperFilename[0] != '.'))
+ upperFilename.deleteChar(0);
+
+ // copy max 4 characters for the extension ('.foo')
+ for (int i = 0; (i < 4) && upperFilename.size(); i++) {
+ fileNameStrFinal += upperFilename[0];
+ upperFilename.deleteChar(0);
+ }
+
+ // Skip the extra characters of the extension
+ upperFilename.clear();
+ }
+
fileNameStrFinal += upperFilename;
return fileNameStrFinal;
}
-Common::File *Resource::openDataFile(const Common::String fileName, uint32 fileHeader) {
+Common::File *Resource::openDataFile(const Common::String filename, uint32 fileHeader) {
Common::File *dataFile = new Common::File();
- dataFile->open(translateFileName(fileName));
+ dataFile->open(translateFileName(filename));
if (!dataFile->isOpen())
- error("openDataFile: Couldn't open %s (%s)", translateFileName(fileName).c_str(), fileName.c_str());
+ error("openDataFile: Couldn't open %s (%s)", translateFileName(filename).c_str(), filename.c_str());
if (fileHeader > 0) {
uint32 headerTag = dataFile->readUint32BE();
if (headerTag != fileHeader) {
dataFile->close();
- error("openDataFile: Unexpected header in %s (%s) - expected: %d, got: %d", translateFileName(fileName).c_str(), fileName.c_str(), fileHeader, headerTag);
+ error("openDataFile: Unexpected header in %s (%s) - expected: %d, got: %d", translateFileName(filename).c_str(), filename.c_str(), fileHeader, headerTag);
}
}
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index 307eac3068..9a242b13e0 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -97,7 +97,7 @@ public:
Resource(LabEngine *vm);
~Resource() {}
- Common::File *openDataFile(const Common::String fileName, uint32 fileHeader = 0);
+ Common::File *openDataFile(const Common::String filename, uint32 fileHeader = 0);
void readRoomData(const Common::String fileName);
InventoryData *readInventory(const Common::String fileName);
void readViews(uint16 roomNum);