Added struct GameObject (such structs are stored in OBJEKTY.DFW and used for in-game objects' info). Added Game::loadObject() for loading such objects into memory. Made Game's constructor load the object for the main hero.

svn-id: r41925
This commit is contained in:
Denis Kasak 2009-06-28 13:10:53 +00:00
parent 1e70f25fcf
commit d28bbe51bf
2 changed files with 76 additions and 1 deletions

View File

@ -121,8 +121,51 @@ Game::Game() {
// TODO: Why is this failing?
// assert(curOffset == _info->_numDialogBlocks);
loadObject(0, &_heroObj);
}
void Game::loadObject(uint16 objNum, GameObject *obj) {
Common::String path("OBJEKTY.DFW");
BArchive objArchive(path);
BAFile *file;
file = objArchive[objNum * 3];
Common::MemoryReadStream objReader(file->_data, file->_length);
obj->_init = objReader.readUint16LE();
obj->_look = objReader.readUint16LE();
obj->_use = objReader.readUint16LE();
obj->_canUse = objReader.readUint16LE();
obj->_imInit = objReader.readByte();
obj->_imLook = objReader.readByte();
obj->_imUse = objReader.readByte();
obj->_walkDir = objReader.readByte();
obj->_priority = objReader.readByte();
obj->_idxSeq = objReader.readUint16LE();
obj->_numSeq = objReader.readUint16LE();
obj->_lookX = objReader.readUint16LE();
obj->_lookY = objReader.readUint16LE();
obj->_useX = objReader.readUint16LE();
obj->_useY = objReader.readUint16LE();
obj->_lookDir = objReader.readByte();
obj->_useDir = objReader.readByte();
obj->_absNum = objNum;
obj->_animObj = 0;
obj->_seqTab = new uint16[obj->_numSeq];
file = objArchive[objNum * 3 + 1];
obj->_title = new byte[file->_length];
memcpy(obj->_title, file->_data, file->_length);
file = objArchive[objNum * 3 + 2];
obj->_program = new byte[file->_length];
memcpy(obj->_program, file->_data, file->_length);
obj->_progLen = file->_length;
}
Game::~Game() {
delete[] _persons;
delete[] _variables;
@ -130,6 +173,15 @@ Game::~Game() {
delete[] _itemStatus;
delete[] _objectStatus;
delete _info;
}
}
GameObject::~GameObject() {
if (_seqTab)
delete[] _seqTab;
if (_title)
delete[] _title;
if (_program)
delete[] _program;
}
}

View File

@ -34,6 +34,26 @@ enum StructSizes {
personSize = sizeof(uint16) * 2 + sizeof(byte)
};
struct GameObject {
GameObject() : _seqTab(NULL), _title(NULL), _program(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;
byte *_program;
byte *_title;
uint32 _progLen;
};
struct GameInfo {
byte _currentRoom;
byte _mapRoom;
@ -66,6 +86,9 @@ private:
int16 *_variables;
byte *_itemStatus;
byte *_objectStatus;
GameObject _heroObj;
void loadObject(uint16 numObj, GameObject *obj);
};
} // End of namespace Draci