mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 05:38:56 +00:00
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
This commit is contained in:
parent
21412b821c
commit
a8ab2c7cff
@ -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) );
|
||||
}
|
||||
|
@ -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; }
|
||||
|
Loading…
Reference in New Issue
Block a user