From e63210616972e59d6e9e98989c489cbf760bcb79 Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Wed, 5 Aug 2009 17:58:14 +0000 Subject: [PATCH] * Made some type changes to struct/class members in game.cpp (uint -> int and uint16 -> uint) * Added enum constant kNoEscRoom for rooms that have no escape room defined * Fixed crash when ESC is pressed in rooms which have no escape room defined * Renamed kNotFound (used as a return value for Game::getObjectWithAnimation) to kObjectNotFound for clarity. svn-id: r43072 --- engines/draci/draci.cpp | 11 ++++++++--- engines/draci/game.cpp | 4 ++-- engines/draci/game.h | 37 +++++++++++++++++++++++-------------- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp index 87408dbccfd..aea3938f243 100644 --- a/engines/draci/draci.cpp +++ b/engines/draci/draci.cpp @@ -202,9 +202,14 @@ bool DraciEngine::handleEvents() { _game->_roomChange = true; } else if (event.kbd.keycode == Common::KEYCODE_ESCAPE) { - _game->setRoomNum(_game->getEscRoom()); - _game->setGateNum(0); - _game->_roomChange = true; + int escRoom = _game->getEscRoom(); + + // Check if there is an escape room defined for the current room + if (escRoom != kNoEscRoom) { + _game->setRoomNum(_game->getEscRoom()); + _game->setGateNum(0); + _game->_roomChange = true; + } } // Show walking map toggle else if (event.kbd.keycode == Common::KEYCODE_w) { diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index e9714d61245..d8152b0fcbf 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -264,7 +264,7 @@ void Game::loop() { // If there is an object under the cursor, display its title and enable // executing its look and use scripts - if (curObject != kNotFound) { + if (curObject != kObjectNotFound) { // Mark dirty rectangle to update the text titleAnim->markDirtyRect(surface); @@ -337,7 +337,7 @@ int Game::getObjectWithAnimation(int animID) { } } - return kNotFound; + return kObjectNotFound; } void Game::walkHero(int x, int y) { diff --git a/engines/draci/game.h b/engines/draci/game.h index 8b8be1e9ea3..c041490e042 100644 --- a/engines/draci/game.h +++ b/engines/draci/game.h @@ -43,8 +43,17 @@ enum StructSizes { personSize = sizeof(uint16) * 2 + sizeof(byte) }; + +// Used as a return value for Game::getObjectWithAnimation() if no object +// owns the animation in question enum { - kNotFound = -1 + kObjectNotFound = -1 +}; + +// Used as the value of the _escRoom field of the current room if there is +// no escape room defined +enum { + kNoEscRoom = -1 }; enum SpeechConstants { @@ -95,9 +104,9 @@ struct GameObject { bool _imInit, _imLook, _imUse; byte _walkDir; byte _z; - uint16 _lookX, _lookY, _useX, _useY; + uint _lookX, _lookY, _useX, _useY; byte _lookDir, _useDir; - uint16 _absNum; + uint _absNum; Common::Array _anims; GPL2Program _program; Common::String _title; @@ -106,26 +115,26 @@ struct GameObject { }; struct GameInfo { - byte _startRoom; - byte _mapRoom; - uint16 _numObjects; - uint16 _numIcons; + int _startRoom; + int _mapRoom; + uint _numObjects; + uint _numIcons; byte _numVariables; byte _numPersons; byte _numDialogs; - uint16 _maxIconWidth, _maxIconHeight; - uint16 _musicLength; - uint16 _crc[4]; - uint16 _numDialogBlocks; + uint _maxIconWidth, _maxIconHeight; + uint _musicLength; + uint _crc[4]; + uint _numDialogBlocks; }; struct Person { - uint16 _x, _y; + uint _x, _y; byte _fontColour; }; struct Room { - byte _roomNum; + int _roomNum; byte _music; WalkingMap _walkingMap; byte _palette; @@ -134,7 +143,7 @@ struct Room { bool _imInit, _imLook, _imUse; bool _mouseOn, _heroOn; double _pers0, _persStep; - byte _escRoom; + int _escRoom; byte _numGates; Common::Array _gates; GPL2Program _program;