Added Game::changeRoom() method and Game::_currentRoom.

svn-id: r42036
This commit is contained in:
Denis Kasak 2009-07-02 20:29:14 +00:00
parent cac39d8295
commit 8bba3e6f10
2 changed files with 36 additions and 2 deletions

View File

@ -134,7 +134,7 @@ Game::Game(DraciEngine *vm) : _vm(vm) {
loadObject(1);
_vm->_script->run(getObject(1)->_program, getObject(1)->_init);
// changeRoom(_currentRoom);
changeRoom(_info->_currentRoom);
}
void Game::loadObject(uint16 objNum) {
@ -189,6 +189,38 @@ GameObject *Game::getObject(uint16 objNum) {
return _objects + objNum;
}
void Game::changeRoom(uint16 roomNum) {
// Convert to real index (indexes begin with 1 in the data files)
roomNum -= 1;
BAFile *f;
f = _vm->_roomsArchive->getFile(roomNum);
Common::MemoryReadStream roomReader(f->_data, f->_length);
roomReader.readUint32LE(); // Pointer to room program, not used
roomReader.readUint16LE(); // Program length, not used
roomReader.readUint32LE(); // Pointer to room title, not used
_currentRoom._music = roomReader.readByte();
_currentRoom._map = roomReader.readByte();
_currentRoom._palette = roomReader.readByte();
_currentRoom._numMasks = roomReader.readUint16LE();
_currentRoom._init = roomReader.readUint16LE();
_currentRoom._look = roomReader.readUint16LE();
_currentRoom._use = roomReader.readUint16LE();
_currentRoom._canUse = roomReader.readUint16LE();
_currentRoom._imInit = roomReader.readByte();
_currentRoom._imLook = roomReader.readByte();
_currentRoom._imUse = roomReader.readByte();
_currentRoom._mouseOn = roomReader.readByte();
_currentRoom._heroOn = roomReader.readByte();
roomReader.read(&_currentRoom._pers0, 12);
roomReader.read(&_currentRoom._persStep, 12);
_currentRoom._escRoom = roomReader.readByte();
_currentRoom._numGates = roomReader.readByte();
}
Game::~Game() {
delete[] _persons;
delete[] _variables;

View File

@ -105,9 +105,11 @@ private:
int16 *_variables;
byte *_itemStatus;
GameObject *_objects;
Room _currentRoom;
void loadObject(uint16 numObj);
GameObject *getObject(uint16 objNum);
void changeRoom(uint16 roomNum);
};
} // End of namespace Draci