diff options
author | Paul Gilbert | 2015-01-06 22:48:04 -0500 |
---|---|---|
committer | Paul Gilbert | 2015-01-06 22:48:04 -0500 |
commit | fa0d7722f1c7826887b6f2b28d2d6829c77c717a (patch) | |
tree | 77afae99bf94ce2e983d3256f71471353ea44104 | |
parent | 31f4f5b843400531d3e091ae0eb673d6dacc227d (diff) | |
download | scummvm-rg350-fa0d7722f1c7826887b6f2b28d2d6829c77c717a.tar.gz scummvm-rg350-fa0d7722f1c7826887b6f2b28d2d6829c77c717a.tar.bz2 scummvm-rg350-fa0d7722f1c7826887b6f2b28d2d6829c77c717a.zip |
XEEN: Work on loading sprites for monsters and objects in Map::load
-rw-r--r-- | engines/xeen/map.cpp | 70 | ||||
-rw-r--r-- | engines/xeen/map.h | 7 | ||||
-rw-r--r-- | engines/xeen/sprites.cpp | 20 | ||||
-rw-r--r-- | engines/xeen/sprites.h | 6 |
4 files changed, 91 insertions, 12 deletions
diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp index 5e98c519f4..f7620b1852 100644 --- a/engines/xeen/map.cpp +++ b/engines/xeen/map.cpp @@ -619,6 +619,16 @@ bool MobStruct::synchronize(Common::SeekableReadStream &s) { /*------------------------------------------------------------------------*/ +MazeObject::MazeObject() { + _number = 0; + _frame = 0; + _id = 0; + _direction = DIR_NORTH; + _flipped = false; +} + +/*------------------------------------------------------------------------*/ + MonsterObjectData::MonsterObjectData(XeenEngine *vm): _vm(vm) { } @@ -855,20 +865,60 @@ void Map::load(int mapId) { // TODO: Switch setting flags that don't seem to ever be used - // Reload object data, since prior loop iterations replaced the data - // for the main map with all the surrounding mazes - Common::String mobName = Common::String::format("maze%c%03u.mob", - (_vm->_party._mazeId >= 100) ? 'x' : '0', _vm->_party._mazeId); - File mobFile(mobName); - _mobData.synchronize(mobFile, _isOutdoors, _monsterData); - mobFile.close(); - // TODO: Loop loading moer data / other / cbr? data + // Load secondary bj file for the objects + Common::String filename; + for (uint i = 0; i < _mobData._objects.size(); ++i) { + if (_vm->_party._cloudsEnd && _mobData._objects[i]._id == 85 && + _vm->_party._mazeId == 27 && isDarkCc) { + // TODO: Flags set that don't seem to be used + } else if (_vm->_party._mazeId == 12 && _vm->_party._gameFlags[43] && + _mobData._objects[i]._id == 118 && !isDarkCc) { + filename = "085.obj"; + _mobData._objects[0]._id = 85; + } else { + filename = Common::String::format("%03u.%cbj", _mobData._objects[i]._id, + _mobData._objects[i]._id >= 100 ? 'o' : '0'); + } - if (_isOutdoors) { + // Read in the secondary object data + File f(filename); + Common::Array<byte> &b = _mobData._objects[i]._objBj; + b.resize(f.size()); + f.read(&b[0], f.size()); + } - } else { + // Load sprite resources for monster standard and attack animations + int monsterNum = 1; + int monsterImgNums[95]; + Common::fill(&monsterImgNums[0], &monsterImgNums[95], 0); + for (uint i = 0; i < _mobData._monsters.size(); ++i, ++monsterNum) { + MonsterStruct &monsterStruct = _monsterData[i]; + int monsterImgNum = monsterStruct._imageNumber; + filename = Common::String::format("%03u.mon", monsterImgNum); + + if (!monsterImgNums[monsterImgNum]) { + _mobData._monsters[i]._sprites.load(filename); + } else { + _mobData._monsters[i]._sprites = _mobData._monsters[ + monsterImgNums[monsterImgNum] - 1]._sprites; + } + + filename = Common::String::format("%03u.att", monsterImgNum); + if (!monsterImgNums[monsterImgNum]) { + _mobData._monsters[i]._attackSprites.load(filename); + monsterImgNums[monsterImgNum] = monsterNum; + } else { + _mobData._monsters[i]._attackSprites = _mobData._monsters[ + monsterImgNums[monsterImgNum] - 1]._attackSprites;; + } + } + // 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); } } diff --git a/engines/xeen/map.h b/engines/xeen/map.h index 882e495a58..c4ab348c91 100644 --- a/engines/xeen/map.h +++ b/engines/xeen/map.h @@ -24,6 +24,7 @@ #define XEEN_MAP_H #include "common/stream.h" +#include "common/array.h" #include "common/rect.h" #include "xeen/party.h" #include "xeen/sprites.h" @@ -199,12 +200,16 @@ public: }; struct MazeObject { +public: Common::Point _position; int _number; int _frame; int _id; Direction _direction; bool _flipped; + Common::Array<byte> _objBj; +public: + MazeObject(); }; struct MazeMonster { @@ -215,6 +220,8 @@ struct MazeMonster { int _hp; int _effect1, _effect2; int _effect3; + SpriteResource _sprites; + SpriteResource _attackSprites; }; class MonsterObjectData { diff --git a/engines/xeen/sprites.cpp b/engines/xeen/sprites.cpp index 598870dc57..74f2b1d04a 100644 --- a/engines/xeen/sprites.cpp +++ b/engines/xeen/sprites.cpp @@ -43,6 +43,21 @@ SpriteResource::~SpriteResource() { clear(); } +SpriteResource &SpriteResource::operator=(const SpriteResource &src) { + delete[] _data; + _index.clear(); + + _filesize = src._filesize; + _data = new byte[_filesize]; + Common::copy(src._data, src._data + _filesize, _data); + + _index.resize(src._index.size()); + for (uint i = 0; i < src._index.size(); ++i) + _index[i] = src._index[i]; + + return *this; +} + void SpriteResource::load(const Common::String &filename) { // Open the resource File f(filename); @@ -173,7 +188,10 @@ void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Poi destPos.x + xOffset + width, destPos.y + yOffset + height)); } -void SpriteResource::draw(XSurface &dest, int frame, const Common::Point &destPos) const { +void SpriteResource::draw(XSurface &dest, int frame, const Common::Point &destPos, int flags) const { + // TODO: Support the different flags + assert(!flags); + drawOffset(dest, _index[frame]._offset1, destPos); if (_index[frame]._offset2) drawOffset(dest, _index[frame]._offset2, destPos); diff --git a/engines/xeen/sprites.h b/engines/xeen/sprites.h index 998d5d3e79..7f937abe8c 100644 --- a/engines/xeen/sprites.h +++ b/engines/xeen/sprites.h @@ -33,6 +33,8 @@ namespace Xeen { class XeenEngine; +enum SpriteFlags { SPRFLAG_HORIZ_FLIPPED = 0x8000 }; + class SpriteResource { private: struct IndexEntry { @@ -49,11 +51,13 @@ public: virtual ~SpriteResource(); + SpriteResource &operator=(const SpriteResource &src); + void load(const Common::String &filename); void clear(); - void draw(XSurface &dest, int frame, const Common::Point &destPos) const; + void draw(XSurface &dest, int frame, const Common::Point &destPos, int flags = 0) const; void draw(XSurface &dest, int frame) const; |