WAGE: Switch to the common readPascalString

This commit is contained in:
Eugene Sandulenko 2017-01-14 12:46:27 +01:00
parent 0b95b734b8
commit 95d0477674
4 changed files with 36 additions and 59 deletions

View File

@ -123,11 +123,11 @@ Scene::Scene(Common::String name, Common::SeekableReadStream *data) {
_soundFrequency = data->readSint16BE();
_soundType = data->readByte();
data->readByte(); // unknown
_messages[NORTH] = readPascalString(data);
_messages[SOUTH] = readPascalString(data);
_messages[EAST] = readPascalString(data);
_messages[WEST] = readPascalString(data);
_soundName = readPascalString(data);
_messages[NORTH] = data->readPascalString();
_messages[SOUTH] = data->readPascalString();
_messages[EAST] = data->readPascalString();
_messages[WEST] = data->readPascalString();
_soundName = data->readPascalString();
_visited = false;
@ -229,12 +229,12 @@ Obj::Obj(Common::String name, Common::SeekableReadStream *data, int resourceId)
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 = data->readPascalString();
_clickMessage = data->readPascalString();
_operativeVerb = data->readPascalString();
_failureMessage = data->readPascalString();
_useMessage = data->readPascalString();
_sound = data->readPascalString();
delete data;
}
@ -329,27 +329,27 @@ Chr::Chr(Common::String name, Common::SeekableReadStream *data) {
else
_nameProperNoun = false;
_initialScene = readPascalString(data);
_nativeWeapon1 = readPascalString(data);
_operativeVerb1 = readPascalString(data);
_nativeWeapon2 = readPascalString(data);
_operativeVerb2 = readPascalString(data);
_initialScene = data->readPascalString();
_nativeWeapon1 = data->readPascalString();
_operativeVerb1 = data->readPascalString();
_nativeWeapon2 = data->readPascalString();
_operativeVerb2 = data->readPascalString();
_initialComment = readPascalString(data);
_scoresHitComment = readPascalString(data);
_receivesHitComment = readPascalString(data);
_makesOfferComment = readPascalString(data);
_rejectsOfferComment = readPascalString(data);
_acceptsOfferComment = readPascalString(data);
_dyingWords = readPascalString(data);
_initialComment = data->readPascalString();
_scoresHitComment = data->readPascalString();
_receivesHitComment = data->readPascalString();
_makesOfferComment = data->readPascalString();
_rejectsOfferComment = data->readPascalString();
_acceptsOfferComment = data->readPascalString();
_dyingWords = data->readPascalString();
_initialSound = readPascalString(data);
_scoresHitSound = readPascalString(data);
_receivesHitSound = readPascalString(data);
_dyingSound = readPascalString(data);
_initialSound = data->readPascalString();
_scoresHitSound = data->readPascalString();
_receivesHitSound = data->readPascalString();
_dyingSound = data->readPascalString();
_weaponSound1 = readPascalString(data);
_weaponSound2 = readPascalString(data);
_weaponSound1 = data->readPascalString();
_weaponSound2 = data->readPascalString();
for (int i = 0; i < NUMBER_OF_ARMOR_TYPES; i++)
_armor[i] = NULL;

View File

@ -51,28 +51,6 @@
namespace Wage {
Common::String readPascalString(Common::SeekableReadStream *in) {
Common::String s;
char *buf;
int len;
int i;
len = in->readByte();
buf = (char *)malloc(len + 1);
for (i = 0; i < len; i++) {
buf[i] = in->readByte();
if (buf[i] == 0x0d)
buf[i] = '\n';
}
buf[i] = 0;
s = buf;
free(buf);
return s;
}
Common::Rect *readRect(Common::SeekableReadStream *in) {
int x1, y1, x2, y2;

View File

@ -103,7 +103,6 @@ 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);
const char *getIndefiniteArticle(const Common::String &word);
const char *prependGenderSpecificPronoun(int gender);

View File

@ -156,13 +156,13 @@ bool World::loadWorld(Common::MacResManager *resMan) {
error("Unexpected value for weapons menu");
res->skip(3);
_aboutMessage = readPascalString(res);
_aboutMessage = res->readPascalString();
if (!scumm_stricmp(resMan->getBaseFileName().c_str(), "Scepters"))
res->skip(1); // ????
_soundLibrary1 = readPascalString(res);
_soundLibrary2 = readPascalString(res);
_soundLibrary1 = res->readPascalString();
_soundLibrary2 = res->readPascalString();
delete res;
}
@ -337,8 +337,8 @@ void World::addSound(Sound *sound) {
Common::StringArray *World::readMenu(Common::SeekableReadStream *res) {
res->skip(10);
int enableFlags = res->readUint32BE();
Common::String menuName = readPascalString(res);
Common::String menuItem = readPascalString(res);
Common::String menuName = res->readPascalString();
Common::String menuItem = res->readPascalString();
int menuItemNumber = 1;
Common::String menu;
byte itemData[4];
@ -363,7 +363,7 @@ Common::StringArray *World::readMenu(Common::SeekableReadStream *res) {
menu += '/';
menu += (char)itemData[1];
}
menuItem = readPascalString(res);
menuItem = res->readPascalString();
menuItemNumber++;
}
@ -408,7 +408,7 @@ Common::String *World::loadStringFromDITL(Common::MacResManager *resMan, int res
for (int i = 0; i <= itemCount; i++) {
// int placeholder; short rect[4]; byte flags; pstring str;
res->skip(13);
Common::String message = readPascalString(res);
Common::String message = res->readPascalString();
if (i == itemIndex) {
Common::String *msg = new Common::String(message);
delete res;