XEEN: Bugfix for bad mob data, WOXCD top of witches tower

This commit is contained in:
Paul Gilbert 2020-05-06 17:42:18 -07:00
parent 23161b27dc
commit 912b2f03eb
3 changed files with 19 additions and 2 deletions

View File

@ -36,6 +36,7 @@ For a more comprehensive changelog of the latest experimental code, see:
Xeen:
- Add missing sprite drawer for enemies hit by Energy Blast.
- Fixed freeze due to bad mob data at the top of Witches Tower
Linux port:
- Added option to use the system file browser instead of the ScummVM file browser.

View File

@ -244,13 +244,18 @@ public:
class XeenSerializer : public Common::Serializer {
private:
Common::SeekableReadStream *_in;
int _filesize;
public:
XeenSerializer(Common::SeekableReadStream *in, Common::WriteStream *out) :
Common::Serializer(in, out), _in(in) {}
Common::Serializer(in, out), _in(in), _filesize(-1) {}
SYNC_AS(Sint8, Byte, int8, 1)
bool finished() const { return _in != nullptr && _in->pos() >= _in->size(); }
bool finished() {
if (_in && _filesize == -1)
_filesize = _in->size();
return _in != nullptr && _in->pos() >= _filesize;
}
};
/**

View File

@ -477,6 +477,9 @@ void MonsterObjectData::synchronize(XeenSerializer &s, MonsterData &monsterData)
_objects.push_back(obj);
mobStruct.synchronize(s);
if (s.finished())
// WORKAROUND: If end of data abnormally reached
return;
} while (mobStruct._id != 255 || mobStruct._pos.x != -1);
// Load monsters
@ -486,6 +489,10 @@ void MonsterObjectData::synchronize(XeenSerializer &s, MonsterData &monsterData)
mobStruct.synchronize(s);
while (mobStruct._id != 255 || mobStruct._pos.x != -1) {
if (s.finished())
// WORKAROUND: If end of data abnormally reached
return;
MazeMonster mon;
mon._position = mobStruct._pos;
mon._id = mobStruct._id;
@ -514,6 +521,10 @@ void MonsterObjectData::synchronize(XeenSerializer &s, MonsterData &monsterData)
// Load wall items. Unlike the previous two arrays, this has no dummy entry for an empty array
mobStruct.synchronize(s);
while (mobStruct._id != 255 || mobStruct._pos.x != -1) {
if (s.finished())
// WORKAROUND: If end of data abnormally reached
return;
if (mobStruct._id < (int)_wallItemSprites.size()) {
MazeWallItem wi;
wi._position = mobStruct._pos;