From d28658984dcceb7c090af9f7040d1490239a820b Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Sat, 25 Jul 2009 03:28:04 +0000 Subject: * Added DraciEngine::_initArchive and made Game use it. Fixes a memory bug because Game uses pointers from the init archive which should outlive it (but didn't previously). * Added support for setting loop status to Game. * Made some GPL commands check whether we are in the correct loop status before executing. svn-id: r42731 --- engines/draci/game.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'engines/draci/game.cpp') diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index 3f91bf1697..d7ae538209 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -39,14 +39,13 @@ static double real_to_double(byte real[6]); Game::Game(DraciEngine *vm) : _vm(vm) { unsigned int i; - Common::String path("INIT.DFW"); - BArchive initArchive(path); + BArchive *initArchive = _vm->_initArchive; BAFile *file; // Read in persons - file = initArchive.getFile(5); + file = initArchive->getFile(5); Common::MemoryReadStream personData(file->_data, file->_length); unsigned int numPersons = file->_length / personSize; @@ -63,7 +62,7 @@ Game::Game(DraciEngine *vm) : _vm(vm) { // Read in dialog offsets - file = initArchive.getFile(4); + file = initArchive->getFile(4); Common::MemoryReadStream dialogData(file->_data, file->_length); unsigned int numDialogs = file->_length / sizeof(uint16); @@ -80,7 +79,7 @@ Game::Game(DraciEngine *vm) : _vm(vm) { // Read in game info - file = initArchive.getFile(3); + file = initArchive->getFile(3); Common::MemoryReadStream gameData(file->_data, file->_length); _info._startRoom = gameData.readByte() - 1; @@ -105,7 +104,7 @@ Game::Game(DraciEngine *vm) : _vm(vm) { // Read in variables - file = initArchive.getFile(2); + file = initArchive->getFile(2); unsigned int numVariables = file->_length / sizeof (int16); _variables = new int[numVariables]; @@ -120,13 +119,13 @@ Game::Game(DraciEngine *vm) : _vm(vm) { // Read in item icon status - file = initArchive.getFile(1); + file = initArchive->getFile(1); _iconStatus = file->_data; uint numIcons = file->_length; // Read in object status - file = initArchive.getFile(0); + file = initArchive->getFile(0); unsigned int numObjects = file->_length; _objects = new GameObject[numObjects]; @@ -153,6 +152,8 @@ Game::Game(DraciEngine *vm) : _vm(vm) { } void Game::init() { + _loopStatus = kStatusOrdinary; + loadObject(kDragonObject); GameObject *dragon = getObject(kDragonObject); @@ -521,6 +522,14 @@ void Game::changeRoom(uint roomNum) { loadOverlays(); } +void Game::setLoopStatus(LoopStatus status) { + _loopStatus = status; +} + +LoopStatus Game::getLoopStatus() { + return _loopStatus; +} + int Game::getRoomNum() { return _currentRoom._roomNum; } -- cgit v1.2.3