diff options
author | Eugene Sandulenko | 2013-06-11 01:17:11 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2013-09-06 14:48:11 +0300 |
commit | a116677e6e26ed9d0e8fcc40eaf88c0c40b25391 (patch) | |
tree | c8d1459b797109cc3da2b235a07d88c8deca2a2c | |
parent | f106d791983223906847343c4b1f1ec7ffcc05d5 (diff) | |
download | scummvm-rg350-a116677e6e26ed9d0e8fcc40eaf88c0c40b25391.tar.gz scummvm-rg350-a116677e6e26ed9d0e8fcc40eaf88c0c40b25391.tar.bz2 scummvm-rg350-a116677e6e26ed9d0e8fcc40eaf88c0c40b25391.zip |
FULLPIPE: Finish loading fullpipe.gam
-rw-r--r-- | engines/fullpipe/stateloader.cpp | 2 | ||||
-rw-r--r-- | engines/fullpipe/utils.cpp | 92 | ||||
-rw-r--r-- | engines/fullpipe/utils.h | 5 |
3 files changed, 59 insertions, 40 deletions
diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp index 4189183860..675a70c5a5 100644 --- a/engines/fullpipe/stateloader.cpp +++ b/engines/fullpipe/stateloader.cpp @@ -464,7 +464,7 @@ bool CGameVar::load(MfcArchive &file) { debug(0, "s --> %s", _value.stringValue); break; default: - error("Unknown var type"); + error("Unknown var type: %d (0x%x)", _varType, _varType); } _parentVarObj = (CGameVar *)file.readClass(); diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index a81665b48b..5df9a28500 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -41,7 +41,7 @@ char *MfcArchive::readPascalString(bool twoByte) { tmp = (char *)calloc(len + 1, 1); read(tmp, len); - debug(0, "readPascalString: %d <%s>", len, tmp); + debug(9, "readPascalString: %d <%s>", len, tmp); return tmp; } @@ -85,6 +85,26 @@ static const char *lookupObjectId(int id) { return ""; } +static CObject *createObject(int objectId) { + switch (objectId) { + case kNullObject: + return 0; + case kCInteraction: + return new CInteraction(); + case kMessageQueue: + return new MessageQueue(); + case kExCommand: + return new ExCommand(); + case kCObjstateCommand: + return new CObjstateCommand(); + case kCGameVar: + return new CGameVar(); + default: + error("Unknown objectId: %d", objectId); + } + + return 0; +} MfcArchive::MfcArchive() { for (int i = 0; classMap[i].name; i++) { @@ -93,45 +113,60 @@ MfcArchive::MfcArchive() { _lastIndex = 1; - _objectMap.push_back(kNullObject); + _objectMap.push_back(0); + _objectIdMap.push_back(kNullObject); } CObject *MfcArchive::readClass() { - CObject *res = parseClass(); + bool isCopyReturned; + CObject *res = parseClass(&isCopyReturned); - if (res) + if (res && !isCopyReturned) res->load(*this); return res; } -CObject *MfcArchive::parseClass() { +CObject *MfcArchive::parseClass(bool *isCopyReturned) { char *name; - int objectId; + int objectId = 0; + CObject *res = 0; uint obTag = readUint16LE(); - debug(0, "parseClass::obTag = %d (%04x) at 0x%08x", obTag, obTag, pos() - 2); + debug(7, "parseClass::obTag = %d (%04x) at 0x%08x", obTag, obTag, pos() - 2); if (obTag == 0xffff) { int schema = readUint16LE(); - debug(0, "parseClass::schema = %d", schema); + debug(7, "parseClass::schema = %d", schema); name = readPascalString(true); - debug(0, "parseClass::class <%s>", name); + debug(7, "parseClass::class <%s>", name); if (!_classMap.contains(name)) { error("Unknown class in MfcArchive: <%s>", name); } objectId = _classMap[name]; - _objectMap.push_back(objectId); - debug(0, "tag: %d 0x%x (%x)", _objectMap.size() - 1, _objectMap.size() - 1, objectId); - objectId = _classMap[name]; + debug(7, "tag: %d 0x%x (%x)", _objectMap.size() - 1, _objectMap.size() - 1, objectId); + + res = createObject(objectId); + _objectMap.push_back(res); + _objectIdMap.push_back(objectId); + + _objectMap.push_back(res); // Basically a hack, but behavior is all correct + _objectIdMap.push_back(objectId); + + *isCopyReturned = false; } else if ((obTag & 0x8000) == 0) { - objectId = _objectMap[obTag]; + if (_objectMap.size() < obTag) { + error("Object index too big: %d at 0x%08x", obTag, pos() - 2); + } + res = _objectMap[obTag]; + + *isCopyReturned = true; } else { obTag &= ~0x8000; @@ -140,35 +175,18 @@ CObject *MfcArchive::parseClass() { error("Object index too big: %d at 0x%08x", obTag, pos() - 2); } - debug(0, "parseClass::obTag <%s>", lookupObjectId(_objectMap[obTag])); + debug(7, "parseClass::obTag <%s>", lookupObjectId(_objectIdMap[obTag])); - objectId = _objectMap[obTag]; - } - - if (objectId) - _objectMap.push_back(objectId); + objectId = _objectIdMap[obTag]; - debug(0, "objectId: %d", objectId); + res = createObject(objectId); + _objectMap.push_back(res); + _objectIdMap.push_back(objectId); - switch (objectId) { - case kNullObject: - warning("parseClass: NULL object at 0x%08x", pos() - 2); - return 0; - case kCInteraction: - return new CInteraction(); - case kMessageQueue: - return new MessageQueue(); - case kExCommand: - return new ExCommand(); - case kCObjstateCommand: - return new CObjstateCommand(); - case kCGameVar: - return new CGameVar(); - default: - error("Unknown objectId: %d", objectId); + *isCopyReturned = false; } - return 0; + return res; } } // End of namespace Fullpipe diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h index a4e9413849..abf7efb250 100644 --- a/engines/fullpipe/utils.h +++ b/engines/fullpipe/utils.h @@ -34,7 +34,8 @@ typedef Common::HashMap<Common::String, int, Common::IgnoreCase_Hash, Common::Ig class MfcArchive : public Common::File { ClassMap _classMap; - Common::Array<int> _objectMap; + Common::Array<CObject *> _objectMap; + Common::Array<int> _objectIdMap; int _lastIndex; @@ -43,7 +44,7 @@ class MfcArchive : public Common::File { char *readPascalString(bool twoByte = false); int readCount(); - CObject *parseClass(); + CObject *parseClass(bool *isCopyReturned); CObject *readClass(); }; |