mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-28 04:34:50 +00:00
* Fixed extracting visibility and location of object from its status byte
* Added Game::getRoomNum() which returns the current room number * Made Game::loadRoom() execute the room's startup script, load the room's objects and run their init scripts as well svn-id: r42194
This commit is contained in:
parent
3b75b8003d
commit
79c42abf08
@ -121,10 +121,10 @@ Game::Game(DraciEngine *vm) : _vm(vm) {
|
||||
byte tmp = objStatus.readByte();
|
||||
|
||||
// Set object visibility
|
||||
_objects[i]._visible = tmp & 1;
|
||||
_objects[i]._visible = tmp & (1 << 7);
|
||||
|
||||
// Set object location
|
||||
_objects[i]._location = tmp & ~1;
|
||||
_objects[i]._location = (~(1 << 7) & tmp) - 1;
|
||||
}
|
||||
|
||||
assert(numDialogs == _info->_numDialogs);
|
||||
@ -172,6 +172,32 @@ void Game::loadRoom(uint roomNum) {
|
||||
_currentRoom._escRoom = roomReader.readByte() - 1;
|
||||
_currentRoom._numGates = roomReader.readByte();
|
||||
|
||||
for (uint i = 0; i < _info->_numObjects; ++i) {
|
||||
debugC(1, kDraciLogicDebugLevel,
|
||||
"Checking if object %d (%d) is at the current location (%d)", i,
|
||||
_objects[i]._location, roomNum);
|
||||
|
||||
if (_objects[i]._location == roomNum) {
|
||||
debugC(1, kDraciLogicDebugLevel, "Loading object %d from room %d", i, roomNum);
|
||||
loadObject(i);
|
||||
}
|
||||
}
|
||||
|
||||
// We can't do this in the above loop because some objects' scripts reference
|
||||
// other objects that may not yet be loaded
|
||||
for (uint i = 0; i < _info->_numObjects; ++i) {
|
||||
if (_objects[i]._location == roomNum) {
|
||||
_vm->_script->run(getObject(i)->_program, getObject(i)->_init);
|
||||
}
|
||||
}
|
||||
|
||||
f = _vm->_roomsArchive->getFile(roomNum * 4 + 3);
|
||||
_currentRoom._program._bytecode = new byte[f->_length];
|
||||
_currentRoom._program._length = f->_length;
|
||||
memcpy(_currentRoom._program._bytecode, f->_data, f->_length);
|
||||
|
||||
_vm->_script->run(_currentRoom._program, _currentRoom._init);
|
||||
|
||||
f = _vm->_paletteArchive->getFile(_currentRoom._palette);
|
||||
_vm->_screen->setPalette(f->_data, 0, kNumColours);
|
||||
}
|
||||
@ -295,7 +321,13 @@ void Game::loadOverlays() {
|
||||
void Game::changeRoom(uint roomNum) {
|
||||
_currentRoom._roomNum = roomNum;
|
||||
loadRoom(roomNum);
|
||||
loadOverlays();
|
||||
loadOverlays();
|
||||
|
||||
_vm->_script->run(_currentRoom._program, _currentRoom._init);
|
||||
}
|
||||
|
||||
int Game::getRoomNum() {
|
||||
return _currentRoom._roomNum;
|
||||
}
|
||||
|
||||
Game::~Game() {
|
||||
|
@ -91,6 +91,7 @@ struct Room {
|
||||
double _pers0, _persStep;
|
||||
byte _escRoom;
|
||||
byte _numGates;
|
||||
GPL2Program _program;
|
||||
};
|
||||
|
||||
class Game {
|
||||
@ -103,6 +104,8 @@ public:
|
||||
|
||||
void changeRoom(uint roomNum);
|
||||
|
||||
int getRoomNum();
|
||||
|
||||
void loadRoom(uint roomNum);
|
||||
int loadAnimation(uint animNum);
|
||||
void loadOverlays();
|
||||
@ -118,7 +121,7 @@ private:
|
||||
uint16 *_dialogOffsets;
|
||||
int16 *_variables;
|
||||
byte *_itemStatus;
|
||||
GameObject *_objects;
|
||||
GameObject *_objects;
|
||||
Room _currentRoom;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user