aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/wage/design.cpp7
-rw-r--r--engines/wage/design.h2
-rw-r--r--engines/wage/entities.cpp193
-rw-r--r--engines/wage/entities.h12
-rw-r--r--engines/wage/world.cpp36
5 files changed, 124 insertions, 126 deletions
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index a3f5d95dc0..1442fa39a9 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -51,13 +51,16 @@
#include "wage/wage.h"
#include "wage/design.h"
+#include "common/stream.h"
+
namespace Wage {
-Design::Design(byte *data, int dataSize) {
+Design::Design(Common::SeekableReadStream *data) {
int len = READ_BE_UINT16(data);
_data = (byte *)malloc(len);
- memcpy(_data, data, len);
+ for (int i = 0; i < len; i++)
+ _data[i] = data->readByte();
}
Design::~Design() {
diff --git a/engines/wage/design.h b/engines/wage/design.h
index 1f16907261..e89b91d123 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -57,7 +57,7 @@ namespace Wage {
class Design {
public:
- Design(byte *data, int size);
+ Design(Common::SeekableReadStream *data);
~Design();
void setBounds(Common::Rect *bounds) {
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 10f1139659..688c11ac6a 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -61,40 +61,34 @@ void Designed::setDesignBounds(Common::Rect *bounds) {
_design->setBounds(bounds);
}
-Scene::Scene(String name, byte *data, int dataSize) {
+Scene::Scene(String name, Common::SeekableReadStream *data) {
_name = name;
- _design = new Design(data, dataSize);
-
- Common::MemoryReadStream in(data, dataSize);
-
- in.skip(in.readUint16BE() - 2); // Skip design.
- setDesignBounds(readRect(in));
- _worldY = in.readSint16BE();
- _worldX = in.readSint16BE();
- _blocked[Scene::NORTH] = (in.readByte() != 0);
- _blocked[Scene::SOUTH] = (in.readByte() != 0);
- _blocked[Scene::EAST] = (in.readByte() != 0);
- _blocked[Scene::WEST] = (in.readByte() != 0);
- _soundFrequency = in.readSint16BE();
- _soundType = in.readByte();
- in.readByte(); // unknown
- _messages[Scene::NORTH] = readPascalString(in);
- _messages[Scene::SOUTH] = readPascalString(in);
- _messages[Scene::EAST] = readPascalString(in);
- _messages[Scene::WEST] = readPascalString(in);
- _soundName = readPascalString(in);
+ _design = new Design(data);
+
+ setDesignBounds(readRect(*data));
+ _worldY = data->readSint16BE();
+ _worldX = data->readSint16BE();
+ _blocked[Scene::NORTH] = (data->readByte() != 0);
+ _blocked[Scene::SOUTH] = (data->readByte() != 0);
+ _blocked[Scene::EAST] = (data->readByte() != 0);
+ _blocked[Scene::WEST] = (data->readByte() != 0);
+ _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);
}
-Obj::Obj(String name, byte *data, int dataSize) : _currentOwner(NULL), _currentScene(NULL) {
+Obj::Obj(String name, Common::SeekableReadStream *data) : _currentOwner(NULL), _currentScene(NULL) {
_name = name;
- _design = new Design(data, dataSize);
+ _design = new Design(data);
- Common::MemoryReadStream in(data, dataSize);
+ setDesignBounds(readRect(*data));
- in.skip(in.readSint16BE() - 2); // Skip design.
- setDesignBounds(readRect(in));
-
- int16 namePlural = in.readSint16BE();
+ int16 namePlural = data->readSint16BE();
if (namePlural == 256)
_namePlural = true; // TODO: other flags?
@@ -103,19 +97,19 @@ Obj::Obj(String name, byte *data, int dataSize) : _currentOwner(NULL), _currentS
else
error("Obj <%s> had weird namePlural set", name.c_str());
- if (in.readSint16BE() != 0)
+ if (data->readSint16BE() != 0)
error("Obj <%s> had short set", name.c_str());
- if (in.readByte() != 0)
+ if (data->readByte() != 0)
error("Obj <%s> had byte set", name.c_str());
- _accuracy = in.readByte();
- _value = in.readByte();
- _type = in.readSByte();
- _damage = in.readByte();
- _attackType = in.readSByte();
- _numberOfUses = in.readSint16BE();
- int16 returnTo = in.readSint16BE();
+ _accuracy = data->readByte();
+ _value = data->readByte();
+ _type = data->readSByte();
+ _damage = data->readByte();
+ _attackType = data->readSByte();
+ _numberOfUses = data->readSint16BE();
+ int16 returnTo = data->readSint16BE();
if (returnTo == 256) // TODO any other possibilities?
_returnToRandomScene = true;
else if (returnTo == 0)
@@ -123,84 +117,81 @@ Obj::Obj(String name, byte *data, int dataSize) : _currentOwner(NULL), _currentS
else
error("Obj <%s> had weird returnTo set", name.c_str());
- _sceneOrOwner = readPascalString(in);
- _clickMessage = readPascalString(in);
- _operativeVerb = readPascalString(in);
- _failureMessage = readPascalString(in);
- _useMessage = readPascalString(in);
- _sound = readPascalString(in);
+ _sceneOrOwner = readPascalString(*data);
+ _clickMessage = readPascalString(*data);
+ _operativeVerb = readPascalString(*data);
+ _failureMessage = readPascalString(*data);
+ _useMessage = readPascalString(*data);
+ _sound = readPascalString(*data);
}
-Chr::Chr(String name, byte *data, int dataSize) {
+Chr::Chr(String name, Common::SeekableReadStream *data) {
_name = name;
- _design = new Design(data, dataSize);
-
- Common::MemoryReadStream in(data, dataSize);
+ _design = new Design(data);
- in.skip(in.readSint16BE() - 2); // Skip design.
- setDesignBounds(readRect(in));
+ setDesignBounds(readRect(*data));
- _physicalStrength = in.readByte();
- _physicalHp = in.readByte();
- _naturalArmor = in.readByte();
- _physicalAccuracy = in.readByte();
+ _physicalStrength = data->readByte();
+ _physicalHp = data->readByte();
+ _naturalArmor = data->readByte();
+ _physicalAccuracy = data->readByte();
- _spiritualStength = in.readByte();
- _spiritialHp = in.readByte();
- _resistanceToMagic = in.readByte();
- _spiritualAccuracy = in.readByte();
+ _spiritualStength = data->readByte();
+ _spiritialHp = data->readByte();
+ _resistanceToMagic = data->readByte();
+ _spiritualAccuracy = data->readByte();
- _runningSpeed = in.readByte();
- _rejectsOffers = in.readByte();
- _followsOpponent = in.readByte();
+ _runningSpeed = data->readByte();
+ _rejectsOffers = data->readByte();
+ _followsOpponent = data->readByte();
- in.readSByte(); // TODO: ???
- in.readSint32BE(); // TODO: ???
+ data->readSByte(); // TODO: ???
+ data->readSint32BE(); // TODO: ???
- _weaponDamage1 = in.readByte();
- _weaponDamage2 = in.readByte();
+ _weaponDamage1 = data->readByte();
+ _weaponDamage2 = data->readByte();
- in.readSByte(); // TODO: ???
+ data->readSByte(); // TODO: ???
- if (in.readSByte() == 1)
+ if (data->readSByte() == 1)
_playerCharacter = true;
- _maximumCarriedObjects = in.readByte();
- _returnTo = in.readSByte();
-
- _winningWeapons = in.readByte();
- _winningMagic = in.readByte();
- _winningRun = in.readByte();
- _winningOffer = in.readByte();
- _losingWeapons = in.readByte();
- _losingMagic = in.readByte();
- _losingRun = in.readByte();
- _losingOffer = in.readByte();
-
- _gender = in.readSByte();
- if (in.readSByte() == 1)
+ _maximumCarriedObjects = data->readByte();
+ _returnTo = data->readSByte();
+
+ _winningWeapons = data->readByte();
+ _winningMagic = data->readByte();
+ _winningRun = data->readByte();
+ _winningOffer = data->readByte();
+ _losingWeapons = data->readByte();
+ _losingMagic = data->readByte();
+ _losingRun = data->readByte();
+ _losingOffer = data->readByte();
+
+ _gender = data->readSByte();
+ if (data->readSByte() == 1)
_nameProperNoun = true;
- _initialScene = readPascalString(in);
- _nativeWeapon1 = readPascalString(in);
- _operativeVerb1 = readPascalString(in);
- _nativeWeapon2 = readPascalString(in);
- _operativeVerb2 = readPascalString(in);
-
- _initialComment = readPascalString(in);
- _scoresHitComment = readPascalString(in);
- _receivesHitComment = readPascalString(in);
- _makesOfferComment = readPascalString(in);
- _rejectsOfferComment = readPascalString(in);
- _acceptsOfferComment = readPascalString(in);
- _dyingWords = readPascalString(in);
-
- _initialSound = readPascalString(in);
- _scoresHitSound = readPascalString(in);
- _receivesHitSound = readPascalString(in);
- _dyingSound = readPascalString(in);
-
- _weaponSound1 = readPascalString(in);
- _weaponSound2 = readPascalString(in);
+ _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/entities.h b/engines/wage/entities.h
index f99d6d189a..3acde80988 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -143,7 +143,7 @@ public:
SHIELD_ARMOR = 2
};
- Chr(String name, byte *data, int dataSize);
+ Chr(String name, Common::SeekableReadStream *data);
int _index;
String _initialScene;
@@ -296,7 +296,7 @@ public:
class Obj : public Weapon, public Designed {
public:
Obj() : _currentOwner(NULL), _currentScene(NULL) {}
- Obj(String name, byte *data, int dataSize);
+ Obj(String name, Common::SeekableReadStream *data);
enum ObjectTypes {
REGULAR_WEAPON = 1,
@@ -381,7 +381,7 @@ public:
Common::List<Chr> _chrs;
Scene() {}
- Scene(String name, byte *data, int dataSize);
+ Scene(String name, Common::SeekableReadStream *data);
Common::Rect *getTextBounds() {
return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds);
@@ -443,11 +443,11 @@ taliesin(24):Wingdings(Decorative)
class Sound {
public:
- Sound(String name, byte *data, int dataSize) : _name(name), _data(data) {}
- ~Sound() { free(_data); }
+ Sound(String name, Common::SeekableReadStream *data) : _name(name), _data(data) {}
+ ~Sound() { }
String _name;
- byte *_data;
+ Common::SeekableReadStream *_data;
};
} // End of namespace Wage
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index a8bba1b448..bd1f8bc9c3 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -93,13 +93,13 @@ bool World::loadWorld(Common::MacResManager *resMan) {
error("Unexpected value for weapons menu");
res->skip(3);
- _aboutMessage = readPascalString(res);
+ _aboutMessage = readPascalString(*res);
- if (!scumm_stricmp(resMan->getFileName().c_str(), "Scepters"))
+ if (!scumm_stricmp(resMan->getBaseFileName().c_str(), "Scepters"))
res->skip(1); // ????
- _soundLibrary1 = readPascalString(res);
- _soundLibrary2 = readPascalString(res);
+ _soundLibrary1 = readPascalString(*res);
+ _soundLibrary2 = readPascalString(*res);
delete res;
@@ -107,22 +107,25 @@ bool World::loadWorld(Common::MacResManager *resMan) {
resArray = resMan->getResIDArray(MKTAG('A','S','C','N'));
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, res->size());
+ Scene *scene = new Scene(resMan->getResName(MKTAG('A','S','C','N'), *iter), res);
res = resMan->getResource(MKTAG('A','C','O','D'), *iter);
if (res != NULL)
- scene->_script = new Script(res, res->size());
+ scene->_script = new Script(res);
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();
- for (int i = 12; i < res->size(); i++)
- if (res[i] == 0x0d)
- res[i] = '\n';
- String text(&((char*)res)[12], res->size() - 12);
+ String text;
+ while (res->pos() < res->size()) {
+ char c = res->readByte();
+ if (c == 0x0d)
+ c = '\n';
+ text += c;
+ }
scene->_text = text;
delete res;
@@ -134,14 +137,14 @@ bool World::loadWorld(Common::MacResManager *resMan) {
resArray = resMan->getResIDArray(MKTAG('A','O','B','J'));
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, res->size()));
+ addObj(new Obj(resMan->getResName(MKTAG('A','O','B','J'), *iter), res));
}
// Load Characters
resArray = resMan->getResIDArray(MKTAG('A','C','H','R'));
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, res->size());
+ Chr *chr = new Chr(resMan->getResName(MKTAG('A','C','H','R'), *iter), res);
addChr(chr);
// TODO: What if there's more than one player character?
@@ -153,7 +156,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
resArray = resMan->getResIDArray(MKTAG('A','S','N','D'));
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, res->size()));
+ addSound(new Sound(resMan->getResName(MKTAG('A','S','N','D'), *iter), res));
}
if (_soundLibrary1.size() > 0) {
@@ -192,7 +195,8 @@ void World::loadExternalSounds(String fname) {
in.close();
Common::MacResManager *resMan;
- resMan = new Common::MacResManager(fname);
+ resMan = new Common::MacResManager();
+ resMan->open(fname);
Common::MacResIDArray resArray;
Common::SeekableReadStream *res;
@@ -201,7 +205,7 @@ void World::loadExternalSounds(String fname) {
resArray = resMan->getResIDArray(MKTAG('A','S','N','D'));
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, res->size()));
+ addSound(new Sound(resMan->getResName(MKTAG('A','S','N','D'), *iter), res));
}
}