Skip to content

Commit

Permalink
XEEN: Implemented map loading of wall item sprites
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jan 7, 2015
1 parent fa0d772 commit be53adb
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 11 deletions.
44 changes: 36 additions & 8 deletions engines/xeen/map.cpp
Expand Up @@ -629,19 +629,38 @@ MazeObject::MazeObject() {

/*------------------------------------------------------------------------*/

MazeMonster::MazeMonster() {
_frame = 0;
_id = 0;
_refId = 0;
_hp = 0;
_effect1 = _effect2 = 0;
_effect3 = 0;
}

/*------------------------------------------------------------------------*/

MazeWallItem::MazeWallItem() {
_id = 0;
_direction = DIR_NORTH;
}

/*------------------------------------------------------------------------*/

MonsterObjectData::MonsterObjectData(XeenEngine *vm): _vm(vm) {
}

void MonsterObjectData::synchronize(Common::SeekableReadStream &s,
bool isOutdoors, MonsterData monsterData) {
_objects.clear();
_monsters.clear();
_wallPicIds.clear();
_wallImages.clear();
_wallItems.clear();
Common::Array<int> objectSprites;
Common::Array<int> monsterIds;
Common::Array<int> wallPicIds;
Common::Array<MobStruct> objData;
Common::Array<MobStruct> monData;
Common::Array<MobStruct> wallItemData;
byte b;

for (int i = 0; i < 16; ++i) {
Expand All @@ -654,7 +673,7 @@ void MonsterObjectData::synchronize(Common::SeekableReadStream &s,
}
for (int i = 0; i < 16; ++i) {
if ((b = s.readByte()) != 0xff)
_wallPicIds.push_back(b);
wallPicIds.push_back(b);
}

MobStruct mobStruct;
Expand All @@ -664,7 +683,7 @@ void MonsterObjectData::synchronize(Common::SeekableReadStream &s,
monData.push_back(mobStruct);
if (!isOutdoors) {
while (mobStruct.synchronize(s))
_wallImages.push_back(mobStruct);
wallItemData.push_back(mobStruct);
}

// Merge up objects
Expand Down Expand Up @@ -693,6 +712,16 @@ void MonsterObjectData::synchronize(Common::SeekableReadStream &s,
if (mon._animationEffect)
dest._effect3 = _vm->getRandomNumber(7);
}

// Merge up wall items
_wallItems.clear();
for (uint i = 0; i < wallItemData.size(); ++i) {
MazeWallItem &dest = _wallItems[i];
dest._position = wallItemData[i]._pos;
dest._id = wallItemData[i]._id;
dest._refId = wallPicIds[dest._id];
dest._direction = wallItemData[i]._direction;
}
}

/*------------------------------------------------------------------------*/
Expand Down Expand Up @@ -915,10 +944,9 @@ void Map::load(int mapId) {
}

// Load wall picture sprite resources
for (uint i = 0; i < _mobData._wallImages.size(); ++i) {
filename = Common::String::format("%03u.pic", _mobData._wallImages[i]._id);
// TODO: Form WallImages struct like _monsters and _objects has
//_mobData._wallImages[i]._sprites.load(filename);
for (uint i = 0; i < _mobData._wallItems.size(); ++i) {
filename = Common::String::format("%03u.pic", _mobData._wallItems[i]._refId);
_mobData._wallItems[i]._sprites.load(filename);
}
}

Expand Down
18 changes: 15 additions & 3 deletions engines/xeen/map.h
Expand Up @@ -208,7 +208,7 @@ struct MazeObject {
Direction _direction;
bool _flipped;
Common::Array<byte> _objBj;
public:

MazeObject();
};

Expand All @@ -222,6 +222,19 @@ struct MazeMonster {
int _effect3;
SpriteResource _sprites;
SpriteResource _attackSprites;

MazeMonster();
};

class MazeWallItem {
public:
Common::Point _position;
int _id;
int _refId;
Direction _direction;
SpriteResource _sprites;
public:
MazeWallItem();
};

class MonsterObjectData {
Expand All @@ -230,8 +243,7 @@ class MonsterObjectData {
public:
Common::Array<MazeObject> _objects;
Common::Array<MazeMonster> _monsters;
Common::Array<int> _wallPicIds;
Common::Array<MobStruct> _wallImages;
Common::Array<MazeWallItem> _wallItems;
public:
MonsterObjectData(XeenEngine *vm);

Expand Down

0 comments on commit be53adb

Please sign in to comment.