* From Game::GameObject removed the following _idxSeq, _numSeq, _animObj, _seqTab (not used anymore), added Common::Array<int> _anims.

* Handled cylic animations properly
* Handled the Z coordinate properly

svn-id: r42244
This commit is contained in:
Denis Kasak 2009-07-07 21:18:28 +00:00
parent 9246e9cf4a
commit 586af0ab42
3 changed files with 14 additions and 19 deletions

View File

@ -201,7 +201,7 @@ void Game::loadRoom(uint roomNum) {
_vm->_screen->setPalette(f->_data, 0, kNumColours);
}
int Game::loadAnimation(uint animNum) {
int Game::loadAnimation(uint animNum, uint z) {
BAFile *animFile = _vm->_animationsArchive->getFile(animNum);
Common::MemoryReadStream animationReader(animFile->_data, animFile->_length);
@ -211,10 +211,10 @@ int Game::loadAnimation(uint animNum) {
// FIXME: handle these properly
animationReader.readByte(); // Memory logic field, not used
animationReader.readByte(); // Disable erasing field, not used
animationReader.readByte(); // Cyclic field, not used
bool cyclic = animationReader.readByte(); // Cyclic field, not used
animationReader.readByte(); // Relative field, not used
Animation *anim = _vm->_anims->addAnimation(animNum, 254, false);
Animation *anim = _vm->_anims->addAnimation(animNum, z, false);
for (uint i = 0; i < numFrames; ++i) {
uint spriteNum = animationReader.readUint16LE() - 1;
@ -236,8 +236,7 @@ int Game::loadAnimation(uint animNum) {
if (mirror)
sp->setMirrorOn();
// HACK: This is only for testing
anim->setLooping(true);
anim->setLooping(cyclic);
anim->addFrame(sp);
}
@ -262,8 +261,8 @@ void Game::loadObject(uint objNum) {
obj->_imUse = objReader.readByte();
obj->_walkDir = objReader.readByte();
obj->_priority = objReader.readByte();
obj->_idxSeq = objReader.readUint16LE();
obj->_numSeq = objReader.readUint16LE();
objReader.readUint16LE(); // idxSeq field, not used
objReader.readUint16LE(); // numSeq field, not used
obj->_lookX = objReader.readUint16LE();
obj->_lookY = objReader.readUint16LE();
obj->_useX = objReader.readUint16LE();
@ -272,10 +271,7 @@ void Game::loadObject(uint objNum) {
obj->_useDir = objReader.readByte();
obj->_absNum = objNum;
obj->_animObj = 0;
obj->_seqTab = new uint16[obj->_numSeq];
file = _vm->_objectsArchive->getFile(objNum * 3 + 1);
obj->_title = new byte[file->_length];
memcpy(obj->_title, file->_data, file->_length);
@ -327,8 +323,9 @@ void Game::changeRoom(uint roomNum) {
GameObject *obj = &_objects[i];
if (i != 0 && obj->_location == oldRoomNum) {
for (uint j = 0; j < obj->_numSeq; ++j) {
_vm->_anims->deleteAnimation(obj->_seqTab[j]);
for (uint j = 0; j < obj->_anims.size(); ++j) {
_vm->_anims->deleteAnimation(obj->_anims[j]);
obj->_anims.pop_back();
}
}
}
@ -352,7 +349,6 @@ Game::~Game() {
}
GameObject::~GameObject() {
delete[] _seqTab;
delete[] _title;
delete[] _program._bytecode;
}

View File

@ -45,19 +45,17 @@ enum StructSizes {
struct GameObject {
GameObject() : _seqTab(NULL), _title(NULL) {}
GameObject() : _title(NULL) {}
~GameObject();
uint16 _init, _look, _use, _canUse;
bool _imInit, _imLook, _imUse;
byte _walkDir;
byte _priority;
uint16 _idxSeq, _numSeq;
uint16 _lookX, _lookY, _useX, _useY;
byte _lookDir, _useDir;
uint16 _absNum;
byte _animObj;
uint16 *_seqTab;
Common::Array<int> _anims;
GPL2Program _program;
byte *_title;
byte _location;
@ -125,7 +123,7 @@ public:
}
void loadRoom(uint roomNum);
int loadAnimation(uint animNum);
int loadAnimation(uint animNum, uint z);
void loadOverlays();
void loadObject(uint numObj);

View File

@ -226,7 +226,8 @@ void Script::load(Common::Queue<int> &params) {
GameObject *obj = _vm->_game->getObject(objID);
obj->_seqTab[animID - obj->_idxSeq] = _vm->_game->loadAnimation(animID);
_vm->_game->loadAnimation(animID, obj->_priority);
obj->_anims.push_back(animID);
}
void Script::start(Common::Queue<int> &params) {