diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/wage/design.cpp | 2 | ||||
-rw-r--r-- | engines/wage/entities.cpp | 73 | ||||
-rw-r--r-- | engines/wage/util.cpp | 16 | ||||
-rw-r--r-- | engines/wage/wage.h | 4 | ||||
-rw-r--r-- | engines/wage/world.cpp | 44 |
5 files changed, 78 insertions, 61 deletions
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp index f3616363b8..5017992a5c 100644 --- a/engines/wage/design.cpp +++ b/engines/wage/design.cpp @@ -53,7 +53,7 @@ namespace Wage { Design::Design(Common::SeekableReadStream *data) { - int len = READ_BE_UINT16(data); + int len = data->readUint16BE() - 2; _data = (byte *)malloc(len); for (int i = 0; i < len; i++) diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp index 57435f8ffb..c499283e07 100644 --- a/engines/wage/entities.cpp +++ b/engines/wage/entities.cpp @@ -62,7 +62,7 @@ Scene::Scene(String name, Common::SeekableReadStream *data) { _name = name; _design = new Design(data); - setDesignBounds(readRect(*data)); + setDesignBounds(readRect(data)); _worldY = data->readSint16BE(); _worldX = data->readSint16BE(); _blocked[Scene::NORTH] = (data->readByte() != 0); @@ -72,18 +72,19 @@ Scene::Scene(String name, Common::SeekableReadStream *data) { _soundFrequency = data->readSint16BE(); _soundType = data->readByte(); data->readByte(); // unknown - _messages[Scene::NORTH] = readPascalString(*data); - _messages[Scene::SOUTH] = readPascalString(*data); - _messages[Scene::EAST] = readPascalString(*data); - _messages[Scene::WEST] = readPascalString(*data); - _soundName = readPascalString(*data); + _messages[Scene::NORTH] = readPascalString(data); + _messages[Scene::SOUTH] = readPascalString(data); + _messages[Scene::EAST] = readPascalString(data); + _messages[Scene::WEST] = readPascalString(data); + _soundName = readPascalString(data); } Obj::Obj(String name, Common::SeekableReadStream *data) : _currentOwner(NULL), _currentScene(NULL) { _name = name; + _design = new Design(data); - setDesignBounds(readRect(*data)); + setDesignBounds(readRect(data)); int16 namePlural = data->readSint16BE(); @@ -92,7 +93,7 @@ Obj::Obj(String name, Common::SeekableReadStream *data) : _currentOwner(NULL), _ else if (namePlural == 0) _namePlural = false; else - error("Obj <%s> had weird namePlural set", name.c_str()); + error("Obj <%s> had weird namePlural set (%d)", name.c_str(), namePlural); if (data->readSint16BE() != 0) error("Obj <%s> had short set", name.c_str()); @@ -114,19 +115,19 @@ Obj::Obj(String name, Common::SeekableReadStream *data) : _currentOwner(NULL), _ else error("Obj <%s> had weird returnTo set", name.c_str()); - _sceneOrOwner = readPascalString(*data); - _clickMessage = readPascalString(*data); - _operativeVerb = readPascalString(*data); - _failureMessage = readPascalString(*data); - _useMessage = readPascalString(*data); - _sound = readPascalString(*data); + _sceneOrOwner = readPascalString(data); + _clickMessage = readPascalString(data); + _operativeVerb = readPascalString(data); + _failureMessage = readPascalString(data); + _useMessage = readPascalString(data); + _sound = readPascalString(data); } Chr::Chr(String name, Common::SeekableReadStream *data) { _name = name; _design = new Design(data); - setDesignBounds(readRect(*data)); + setDesignBounds(readRect(data)); _physicalStrength = data->readByte(); _physicalHp = data->readByte(); @@ -168,27 +169,27 @@ Chr::Chr(String name, Common::SeekableReadStream *data) { if (data->readSByte() == 1) _nameProperNoun = true; - _initialScene = readPascalString(*data); - _nativeWeapon1 = readPascalString(*data); - _operativeVerb1 = readPascalString(*data); - _nativeWeapon2 = readPascalString(*data); - _operativeVerb2 = readPascalString(*data); - - _initialComment = readPascalString(*data); - _scoresHitComment = readPascalString(*data); - _receivesHitComment = readPascalString(*data); - _makesOfferComment = readPascalString(*data); - _rejectsOfferComment = readPascalString(*data); - _acceptsOfferComment = readPascalString(*data); - _dyingWords = readPascalString(*data); - - _initialSound = readPascalString(*data); - _scoresHitSound = readPascalString(*data); - _receivesHitSound = readPascalString(*data); - _dyingSound = readPascalString(*data); - - _weaponSound1 = readPascalString(*data); - _weaponSound2 = readPascalString(*data); + _initialScene = readPascalString(data); + _nativeWeapon1 = readPascalString(data); + _operativeVerb1 = readPascalString(data); + _nativeWeapon2 = readPascalString(data); + _operativeVerb2 = readPascalString(data); + + _initialComment = readPascalString(data); + _scoresHitComment = readPascalString(data); + _receivesHitComment = readPascalString(data); + _makesOfferComment = readPascalString(data); + _rejectsOfferComment = readPascalString(data); + _acceptsOfferComment = readPascalString(data); + _dyingWords = readPascalString(data); + + _initialSound = readPascalString(data); + _scoresHitSound = readPascalString(data); + _receivesHitSound = readPascalString(data); + _dyingSound = readPascalString(data); + + _weaponSound1 = readPascalString(data); + _weaponSound2 = readPascalString(data); } } // End of namespace Wage diff --git a/engines/wage/util.cpp b/engines/wage/util.cpp index 1a6c01050b..0bed88e46f 100644 --- a/engines/wage/util.cpp +++ b/engines/wage/util.cpp @@ -51,19 +51,19 @@ namespace Wage { -Common::String readPascalString(Common::SeekableReadStream &in) { +Common::String readPascalString(Common::SeekableReadStream *in) { Common::String s; char *buf; int len; int i; - len = in.readSByte(); + len = in->readSByte(); if (len < 0) len += 256; buf = (char *)malloc(len + 1); for (i = 0; i < len; i++) { - buf[i] = in.readByte(); + buf[i] = in->readByte(); if (buf[i] == 0x0d) buf[i] = '\n'; } @@ -76,13 +76,13 @@ Common::String readPascalString(Common::SeekableReadStream &in) { return s; } -Common::Rect *readRect(Common::SeekableReadStream &in) { +Common::Rect *readRect(Common::SeekableReadStream *in) { int x1, y1, x2, y2; - y1 = in.readUint16BE(); - x1 = in.readUint16BE(); - y2 = in.readUint16BE() + 4; - x2 = in.readUint16BE() + 4; + y1 = in->readUint16BE(); + x1 = in->readUint16BE(); + y2 = in->readUint16BE() + 4; + x2 = in->readUint16BE() + 4; return new Common::Rect(x1, y1, x2, y2); } diff --git a/engines/wage/wage.h b/engines/wage/wage.h index 5958ea2584..516550f932 100644 --- a/engines/wage/wage.h +++ b/engines/wage/wage.h @@ -76,8 +76,8 @@ enum { // the current limitation is 32 debug levels (1 << 31 is the last one) }; -Common::String readPascalString(Common::SeekableReadStream &in); -Common::Rect *readRect(Common::SeekableReadStream &in); +Common::String readPascalString(Common::SeekableReadStream *in); +Common::Rect *readRect(Common::SeekableReadStream *in); class WageEngine : public Engine { public: diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp index 513bba98a7..5fe551fc0e 100644 --- a/engines/wage/world.cpp +++ b/engines/wage/world.cpp @@ -74,6 +74,8 @@ bool World::loadWorld(Common::MacResManager *resMan) { res = resMan->getResource(MKTAG('G','C','O','D'), resArray[0]); _globalScript = new Script(res); + // TODO: read creator + // Load main configuration if ((resArray = resMan->getResIDArray(MKTAG('V','E','R','S'))).size() == 0) return false; @@ -81,27 +83,33 @@ bool World::loadWorld(Common::MacResManager *resMan) { if (resArray.size() > 1) warning("Too many VERS resources"); - res = resMan->getResource(MKTAG('V','E','R','S'), resArray[0]); + if (resArray.size()) { + debug(3, "Loading version info"); - res->skip(10); - byte b = res->readByte(); - _weaponMenuDisabled = (b != 0); - if (b != 0 && b != 1) - error("Unexpected value for weapons menu"); + res = resMan->getResource(MKTAG('V','E','R','S'), resArray[0]); - res->skip(3); - _aboutMessage = readPascalString(*res); + res->skip(10); + byte b = res->readByte(); + _weaponMenuDisabled = (b != 0); + if (b != 0 && b != 1) + error("Unexpected value for weapons menu"); - if (!scumm_stricmp(resMan->getBaseFileName().c_str(), "Scepters")) - res->skip(1); // ???? + res->skip(3); + _aboutMessage = readPascalString(res); - _soundLibrary1 = readPascalString(*res); - _soundLibrary2 = readPascalString(*res); + if (!scumm_stricmp(resMan->getBaseFileName().c_str(), "Scepters")) + res->skip(1); // ???? - delete res; + _soundLibrary1 = readPascalString(res); + _soundLibrary2 = readPascalString(res); + + delete res; + } // Load scenes resArray = resMan->getResIDArray(MKTAG('A','S','C','N')); + debug(3, "Loading %d scenes", resArray.size()); + for (iter = resArray.begin(); iter != resArray.end(); ++iter) { res = resMan->getResource(MKTAG('A','S','C','N'), *iter); Scene *scene = new Scene(resMan->getResName(MKTAG('A','S','C','N'), *iter), res); @@ -112,7 +120,7 @@ bool World::loadWorld(Common::MacResManager *resMan) { res = resMan->getResource(MKTAG('A','T','X','T'), *iter); if (res != NULL) { - scene->_textBounds = readRect(*res); + scene->_textBounds = readRect(res); scene->_fontType = res->readUint16BE(); scene->_fontSize = res->readUint16BE(); @@ -132,6 +140,8 @@ bool World::loadWorld(Common::MacResManager *resMan) { // Load Objects resArray = resMan->getResIDArray(MKTAG('A','O','B','J')); + debug(3, "Loading %d objects", resArray.size()); + for (iter = resArray.begin(); iter != resArray.end(); ++iter) { res = resMan->getResource(MKTAG('A','O','B','J'), *iter); addObj(new Obj(resMan->getResName(MKTAG('A','O','B','J'), *iter), res)); @@ -139,6 +149,8 @@ bool World::loadWorld(Common::MacResManager *resMan) { // Load Characters resArray = resMan->getResIDArray(MKTAG('A','C','H','R')); + debug(3, "Loading %d characters", resArray.size()); + for (iter = resArray.begin(); iter != resArray.end(); ++iter) { res = resMan->getResource(MKTAG('A','C','H','R'), *iter); Chr *chr = new Chr(resMan->getResName(MKTAG('A','C','H','R'), *iter), res); @@ -151,6 +163,8 @@ bool World::loadWorld(Common::MacResManager *resMan) { // Load Sounds resArray = resMan->getResIDArray(MKTAG('A','S','N','D')); + debug(3, "Loading %d sounds", resArray.size()); + for (iter = resArray.begin(); iter != resArray.end(); ++iter) { res = resMan->getResource(MKTAG('A','S','N','D'), *iter); addSound(new Sound(resMan->getResName(MKTAG('A','S','N','D'), *iter), res)); @@ -167,6 +181,8 @@ bool World::loadWorld(Common::MacResManager *resMan) { res = resMan->getResource(MKTAG('P','A','T','#'), 900); if (res != NULL) { int count = res->readUint16BE(); + debug(3, "Loading %d patterns", count); + for (int i = 0; i < count; i++) { byte *pattern = (byte *)malloc(8); for (int j = 0; j < 8; j++) { |