diff options
author | Miroslav Remák | 2018-08-29 18:24:06 +0200 |
---|---|---|
committer | Ľubomír Remák | 2018-08-29 19:13:55 +0200 |
commit | 81789162d3f76ef827eeff7e042ab79206b7b92f (patch) | |
tree | 895b7f8e6b7b945c32bf6d60108c6bbbdbfd873a | |
parent | ad73f65a2023d6b4afd4ddb49e2893104e5e410d (diff) | |
download | scummvm-rg350-81789162d3f76ef827eeff7e042ab79206b7b92f.tar.gz scummvm-rg350-81789162d3f76ef827eeff7e042ab79206b7b92f.tar.bz2 scummvm-rg350-81789162d3f76ef827eeff7e042ab79206b7b92f.zip |
MUTATIONOFJB: Disallow interaction with inactive doors.
-rw-r--r-- | engines/mutationofjb/gamedata.cpp | 8 | ||||
-rw-r--r-- | engines/mutationofjb/gamedata.h | 17 |
2 files changed, 22 insertions, 3 deletions
diff --git a/engines/mutationofjb/gamedata.cpp b/engines/mutationofjb/gamedata.cpp index 2c1ee5ab52..a669fcffbb 100644 --- a/engines/mutationofjb/gamedata.cpp +++ b/engines/mutationofjb/gamedata.cpp @@ -39,6 +39,10 @@ static bool readString(Common::ReadStream &stream, char *str) { return true; } +bool Door::isActive() { + return *_name != '\0'; +} + bool Door::loadFromStream(Common::ReadStream &stream) { readString(stream, _name); @@ -183,10 +187,10 @@ uint8 Scene::getNoStatics(bool ignoreNo) const { return (!ignoreNo ? MIN(_noStatics, static_cast<uint8>(ARRAYSIZE(_statics))) : ARRAYSIZE(_statics)); } -Door *Scene::findDoor(int16 x, int16 y, int *index) { +Door *Scene::findDoor(int16 x, int16 y, bool activeOnly, int *index) { for (int i = 0; i < getNoDoors(); ++i) { Door &door = _doors[i]; - if ((x >= door._x) && (x < door._x + door._width) && (y >= door._y) && (y < door._y + door._height)) { + if ((!activeOnly || door.isActive()) && (x >= door._x) && (x < door._x + door._width) && (y >= door._y) && (y < door._y + door._height)) { if (index) { *index = i + 1; } diff --git a/engines/mutationofjb/gamedata.h b/engines/mutationofjb/gamedata.h index 8a67db61e7..5d7dea1b05 100644 --- a/engines/mutationofjb/gamedata.h +++ b/engines/mutationofjb/gamedata.h @@ -83,6 +83,12 @@ struct Door { /* Unknown for now - likely not even used. */ uint8 _SP; + /** + * Check if this door can be interacted with. + * @return True if this door can be interacted with, false otherwise. + */ + bool isActive(); + bool loadFromStream(Common::ReadStream &stream); }; @@ -259,7 +265,16 @@ struct Scene { uint8 getNoObjects(bool ignoreNo = false) const; uint8 getNoStatics(bool ignoreNo = false) const; - Door *findDoor(int16 x, int16 y, int *index = nullptr); + /** + * Finds the door at the given position. By default, only active doors are considered. + * + * @param x X coordinate. + * @param y Y coordinate. + * @param activeOnly If true, consider only active doors; otherwise consider any. + * @param index Output parameter for the found door's ID. + * @return A door if found, nullptr otherwise. + */ + Door *findDoor(int16 x, int16 y, bool activeOnly = true, int *index = nullptr); /** * Finds the static at the given position. By default, only active statics are considered. * |