diff options
author | Paul Gilbert | 2015-01-07 22:11:18 -0500 |
---|---|---|
committer | Paul Gilbert | 2015-01-07 22:11:18 -0500 |
commit | 96d086ab9cc28a2145072487b60036f916b28774 (patch) | |
tree | 93b880f20ecb1d2730c90cbe3b684ecaf3d07845 /engines/xeen/files.cpp | |
parent | cd7c00ca8c93258d7b6c3ef92fc32452df1052cb (diff) | |
download | scummvm-rg350-96d086ab9cc28a2145072487b60036f916b28774.tar.gz scummvm-rg350-96d086ab9cc28a2145072487b60036f916b28774.tar.bz2 scummvm-rg350-96d086ab9cc28a2145072487b60036f916b28774.zip |
XEEN: Add prefix support to CC files, initial save state fixes
Diffstat (limited to 'engines/xeen/files.cpp')
-rw-r--r-- | engines/xeen/files.cpp | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/engines/xeen/files.cpp b/engines/xeen/files.cpp index b1358d4cdc..79387f2e24 100644 --- a/engines/xeen/files.cpp +++ b/engines/xeen/files.cpp @@ -39,6 +39,14 @@ uint16 BaseCCArchive::convertNameToId(const Common::String &resourceName) const Common::String name = resourceName; name.toUppercase(); + // Check if a resource number is being directly specified + if (name.size() == 4) { + char *endPtr; + uint16 num = (uint16)strtol(name.c_str(), &endPtr, 16); + if (!*endPtr) + return num; + } + const byte *msgP = (const byte *)name.c_str(); int total = *msgP++; for (; *msgP; total += *msgP++) { @@ -121,7 +129,15 @@ int BaseCCArchive::listMembers(Common::ArchiveMemberList &list) const { /*------------------------------------------------------------------------*/ CCArchive::CCArchive(const Common::String &filename, bool encoded): - _filename(filename), _encoded(encoded) { + BaseCCArchive(), _filename(filename), _encoded(encoded) { + File f(filename); + loadIndex(&f); +} + +CCArchive::CCArchive(const Common::String &filename, const Common::String &prefix, + bool encoded): BaseCCArchive(), _filename(filename), + _prefix(prefix), _encoded(encoded) { + _prefix.toLowercase(); File f(filename); loadIndex(&f); } @@ -129,6 +145,25 @@ CCArchive::CCArchive(const Common::String &filename, bool encoded): CCArchive::~CCArchive() { } +bool CCArchive::getHeaderEntry(const Common::String &resourceName, CCEntry &ccEntry) const { + Common::String resName = resourceName; + + if (!_prefix.empty() && resName.contains('|')) { + resName.toLowercase(); + Common::String prefix = _prefix + "|"; + + if (!strncmp(resName.c_str(), prefix.c_str(), prefix.size())) + // Matching CC prefix, so strip it off and allow processing to + // continue onto the base getHeaderEntry method + resName = Common::String(resName.c_str() + prefix.size()); + else + // Not matching prefix, so don't allow a match + return false; + } + + return BaseCCArchive::getHeaderEntry(resName, ccEntry); +} + Common::SeekableReadStream *CCArchive::createReadStreamForMember(const Common::String &name) const { CCEntry ccEntry; @@ -166,9 +201,9 @@ FileManager::FileManager(XeenEngine *vm) { _isDarkCc = vm->getGameID() != GType_Clouds; if (_isDarkCc) - SearchMan.add("dark", new CCArchive("dark.cc")); - SearchMan.add("xeen", new CCArchive("xeen.cc")); - SearchMan.add("intro", new CCArchive("intro.cc")); + SearchMan.add("dark", new CCArchive("dark.cc", "dark", true)); + SearchMan.add("xeen", new CCArchive("xeen.cc", "xeen", true)); + SearchMan.add("intro", new CCArchive("intro.cc", "intro", true)); } /*------------------------------------------------------------------------*/ @@ -181,4 +216,9 @@ void File::openFile(const Common::String &filename) { error("Could not open file - %s", filename.c_str()); } +void File::openFile(const Common::String &filename, Common::Archive &archive) { + if (!Common::File::open(filename, archive)) + error("Could not open file - %s", filename.c_str()); +} + } // End of namespace Xeen |