* 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
This commit is contained in:
Denis Kasak 2009-08-05 17:58:14 +00:00
parent 1363a0680a
commit e632106169
3 changed files with 33 additions and 19 deletions

View File

@ -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) {

View File

@ -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) {

View File

@ -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<int> _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<int> _gates;
GPL2Program _program;