diff options
author | Denis Kasak | 2009-07-25 03:28:04 +0000 |
---|---|---|
committer | Denis Kasak | 2009-07-25 03:28:04 +0000 |
commit | d28658984dcceb7c090af9f7040d1490239a820b (patch) | |
tree | 93da0bc4e38c273f4c27f7eb4be3e461bcab0493 /engines/draci | |
parent | b7e97efb7fbd26c91693082339466308c52e7e08 (diff) | |
download | scummvm-rg350-d28658984dcceb7c090af9f7040d1490239a820b.tar.gz scummvm-rg350-d28658984dcceb7c090af9f7040d1490239a820b.tar.bz2 scummvm-rg350-d28658984dcceb7c090af9f7040d1490239a820b.zip |
* 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
Diffstat (limited to 'engines/draci')
-rw-r--r-- | engines/draci/draci.cpp | 3 | ||||
-rw-r--r-- | engines/draci/draci.h | 1 | ||||
-rw-r--r-- | engines/draci/game.cpp | 25 | ||||
-rw-r--r-- | engines/draci/game.h | 17 | ||||
-rw-r--r-- | engines/draci/script.cpp | 8 |
5 files changed, 44 insertions, 10 deletions
diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp index 88fe731b40..deaa39bba1 100644 --- a/engines/draci/draci.cpp +++ b/engines/draci/draci.cpp @@ -53,6 +53,7 @@ const Common::String roomsPath("MIST.DFW"); const Common::String animationsPath("ANIM.DFW"); const Common::String iconsPath("HRA.DFW"); const Common::String walkingMapsPath("MAPY.DFW"); +const Common::String initPath("INIT.DFW"); DraciEngine::DraciEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst) { @@ -81,6 +82,7 @@ int DraciEngine::init() { initGraphics(kScreenWidth, kScreenHeight, false); // Open game's archives + _initArchive = new BArchive(initPath); _objectsArchive = new BArchive(objectsPath); _spritesArchive = new BArchive(spritesPath); _paletteArchive = new BArchive(palettePath); @@ -227,6 +229,7 @@ DraciEngine::~DraciEngine() { delete _script; delete _anims; + delete _initArchive; delete _paletteArchive; delete _objectsArchive; delete _spritesArchive; diff --git a/engines/draci/draci.h b/engines/draci/draci.h index 630ce0c29a..e6b78f310a 100644 --- a/engines/draci/draci.h +++ b/engines/draci/draci.h @@ -68,6 +68,7 @@ public: BArchive *_overlaysArchive; BArchive *_animationsArchive; BArchive *_walkingMapsArchive; + BArchive *_initArchive; Common::RandomSource _rnd; }; 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; } diff --git a/engines/draci/game.h b/engines/draci/game.h index 2cee3e024d..6be44cdd68 100644 --- a/engines/draci/game.h +++ b/engines/draci/game.h @@ -132,6 +132,12 @@ struct Room { GPL2Program _program; }; +enum LoopStatus { + kStatusGate, kStatusOrdinary, kStatusInventory, + kStatusDialogue, kStatusTalk, kStatusStrange, + kStatusFade +}; + class Game { public: @@ -185,15 +191,22 @@ public: int getMarkedAnimationIndex(); void setMarkedAnimationIndex(int index); + void setLoopStatus(LoopStatus status); + LoopStatus getLoopStatus(); + private: DraciEngine *_vm; - int *_variables; + GameInfo _info; - Person *_persons; uint *_dialogOffsets; + + int *_variables; byte *_iconStatus; + Person *_persons; GameObject *_objects; + Room _currentRoom; + LoopStatus _loopStatus; int _markedAnimationIndex; //!< Used by the Mark GPL command }; diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp index 1d491b0efa..ad601f093d 100644 --- a/engines/draci/script.cpp +++ b/engines/draci/script.cpp @@ -265,6 +265,10 @@ int Script::funcIsObjAway(int objID) { /* GPL commands */ void Script::load(Common::Queue<int> ¶ms) { + if (_vm->_game->getLoopStatus() == kStatusInventory) { + return; + } + int objID = params.pop() - 1; int animID = params.pop() - 1; @@ -275,6 +279,10 @@ void Script::load(Common::Queue<int> ¶ms) { } void Script::start(Common::Queue<int> ¶ms) { + if (_vm->_game->getLoopStatus() == kStatusInventory) { + return; + } + int objID = params.pop() - 1; int animID = params.pop() - 1; |