diff options
author | Filippos Karapetis | 2007-05-08 17:32:31 +0000 |
---|---|---|
committer | Filippos Karapetis | 2007-05-08 17:32:31 +0000 |
commit | a8ab2c7cff4588ea32d7b9a3dfcfd763d53247b1 (patch) | |
tree | f304b9a8d7fd5fb4898e2c3836c2fa2e36ffc352 /engines/saga | |
parent | 21412b821c968b3d23f4c7fd120f19a1af50b67f (diff) | |
download | scummvm-rg350-a8ab2c7cff4588ea32d7b9a3dfcfd763d53247b1.tar.gz scummvm-rg350-a8ab2c7cff4588ea32d7b9a3dfcfd763d53247b1.tar.bz2 scummvm-rg350-a8ab2c7cff4588ea32d7b9a3dfcfd763d53247b1.zip |
Moved functions getDoorState, setDoorState, getBGMaskType and validBGMaskPoint to scene.h and disabled some sanity checks to improve the speed of the pathfinding algorithm, after discussing with h00ligan
svn-id: r26789
Diffstat (limited to 'engines/saga')
-rw-r--r-- | engines/saga/scene.cpp | 36 | ||||
-rw-r--r-- | engines/saga/scene.h | 54 |
2 files changed, 50 insertions, 40 deletions
diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp index a3c6e375b0..74cae1f4cf 100644 --- a/engines/saga/scene.cpp +++ b/engines/saga/scene.cpp @@ -502,28 +502,6 @@ void Scene::getBGInfo(BGInfo &bgInfo) { bgInfo.bounds.setHeight(_bg.h); } -int Scene::getBGMaskType(const Point &testPoint) { - uint offset; - if (!_bgMask.loaded) { - return 0; - } - offset = testPoint.x + testPoint.y * _bgMask.w; - if (offset >= _bgMask.buf_len) { - error("Scene::getBGMaskType offset 0x%X exceed bufferLength 0x%X", offset, (int)_bgMask.buf_len); - } - - return (_bgMask.buf[offset] >> 4) & 0x0f; -} - -bool Scene::validBGMaskPoint(const Point &testPoint) { - if (!_bgMask.loaded) { - error("Scene::validBGMaskPoint _bgMask not loaded"); - } - - return !((testPoint.x < 0) || (testPoint.x >= _bgMask.w) || - (testPoint.y < 0) || (testPoint.y >= _bgMask.h)); -} - bool Scene::canWalk(const Point &testPoint) { int maskType; @@ -571,20 +549,6 @@ void Scene::getBGMaskInfo(int &width, int &height, byte *&buffer, size_t &buffer bufferLength = _bgMask.buf_len; } -void Scene::setDoorState(int doorNumber, int doorState) { - if ((doorNumber < 0) || (doorNumber >= SCENE_DOORS_MAX)) - error("Scene::setDoorState wrong doorNumber"); - - _sceneDoors[doorNumber] = doorState; -} - -int Scene::getDoorState(int doorNumber) { - if ((doorNumber < 0) || (doorNumber >= SCENE_DOORS_MAX)) - error("Scene::getDoorState wrong doorNumber"); - - return _sceneDoors[doorNumber]; -} - void Scene::initDoorsState() { memcpy(_sceneDoors, initSceneDoors, sizeof (_sceneDoors) ); } diff --git a/engines/saga/scene.h b/engines/saga/scene.h index 34be75767a..ce76bde4a2 100644 --- a/engines/saga/scene.h +++ b/engines/saga/scene.h @@ -34,6 +34,8 @@ namespace Saga { +//#define SCENE_DEBUG // for scene debugging + #define SCENE_DOORS_MAX 16 #define NO_CHAPTER_CHANGE -2 @@ -233,13 +235,55 @@ class Scene { void getBGMaskInfo(int &width, int &height, byte *&buffer, size_t &bufferLength); int isBGMaskPresent() { return _bgMask.loaded; } - int getBGMaskType(const Point &testPoint); - bool validBGMaskPoint(const Point &testPoint); + + int getBGMaskType(const Point &testPoint) { + uint offset; + if (!_bgMask.loaded) { + return 0; + } + offset = testPoint.x + testPoint.y * _bgMask.w; + + #ifdef SCENE_DEBUG + if (offset >= _bgMask.buf_len) { + error("Scene::getBGMaskType offset 0x%X exceed bufferLength 0x%X", offset, (int)_bgMask.buf_len); + } + #endif + + return (_bgMask.buf[offset] >> 4) & 0x0f; + } + + bool validBGMaskPoint(const Point &testPoint) { + #ifdef SCENE_DEBUG + if (!_bgMask.loaded) { + error("Scene::validBGMaskPoint _bgMask not loaded"); + } + #endif + + return !((testPoint.x < 0) || (testPoint.x >= _bgMask.w) || + (testPoint.y < 0) || (testPoint.y >= _bgMask.h)); + } + bool canWalk(const Point &testPoint); bool offscreenPath(Point &testPoint); - void setDoorState(int doorNumber, int doorState); - int getDoorState(int doorNumber); + void setDoorState(int doorNumber, int doorState) { + #ifdef SCENE_DEBUG + if ((doorNumber < 0) || (doorNumber >= SCENE_DOORS_MAX)) + error("Scene::setDoorState wrong doorNumber"); + #endif + + _sceneDoors[doorNumber] = doorState; + } + + int getDoorState(int doorNumber) { + #ifdef SCENE_DEBUG + if ((doorNumber < 0) || (doorNumber >= SCENE_DOORS_MAX)) + error("Scene::getDoorState wrong doorNumber"); + #endif + + return _sceneDoors[doorNumber]; + } + void initDoorsState(); void getBGInfo(BGInfo &bgInfo); @@ -257,9 +301,11 @@ class Scene { bool isSceneLoaded() const { return _sceneLoaded; } int getSceneResourceId(int sceneNumber) { + #ifdef SCENE_DEBUG if ((sceneNumber < 0) || (sceneNumber >= _sceneCount)) { error("getSceneResourceId: wrong sceneNumber %i", sceneNumber); } + #endif return _sceneLUT[sceneNumber]; } int currentSceneNumber() const { return _sceneNumber; } |