Permalink
Browse files

MUTATIONOFJB: Fix interaction with certain overlapped statics.

An active static overlapped by an inactive static with lower ID was not interactable. For example, this affected the scene with the sawfish, where the machine in the closet would be blocked by the closet itself.
  • Loading branch information...
MiroslavR committed Aug 29, 2018
1 parent 8033f62 commit 008bfeb4b989da1a96a6ea5977187f547ec2a549
Showing with 14 additions and 9 deletions.
  1. +2 −2 engines/mutationofjb/gamedata.cpp
  2. +10 −1 engines/mutationofjb/gamedata.h
  3. +2 −6 engines/mutationofjb/mutationofjb.cpp
@@ -197,10 +197,10 @@ Door *Scene::findDoor(int16 x, int16 y, int *index) {
return nullptr;
}

Static *Scene::findStatic(int16 x, int16 y, int *index) {
Static *Scene::findStatic(int16 x, int16 y, bool activeOnly, int *index) {
for (int i = 0; i < getNoStatics(); ++i) {
Static &stat = _statics[i];
if ((x >= stat._x) && (x < stat._x + stat._width) && (y >= stat._y) && (y < stat._y + stat._height)) {
if ((!activeOnly || stat._active) && (x >= stat._x) && (x < stat._x + stat._width) && (y >= stat._y) && (y < stat._y + stat._height)) {
if (index) {
*index = i + 1;
}
@@ -260,7 +260,16 @@ struct Scene {
uint8 getNoStatics(bool ignoreNo = false) const;

Door *findDoor(int16 x, int16 y, int *index = nullptr);
Static *findStatic(int16 x, int16 y, int *index = nullptr);
/**
* Finds the static at the given position. By default, only active statics are considered.
*
* @param x X coordinate.
* @param y Y coordinate.
* @param activeOnly If true, consider only active statics; otherwise consider any.
* @param index Output parameter for the found static's ID.
* @return A static if found, nullptr otherwise.
*/
Static *findStatic(int16 x, int16 y, bool activeOnly = true, int *index = nullptr);
Bitmap *findBitmap(int16 x, int16 y, int *index = nullptr);

void addExhaustedConvItem(uint8 context, uint8 convItemIndex, uint8 convGroupIndex);
@@ -138,9 +138,7 @@ void MutationOfJBEngine::handleNormalScene(const Common::Event &event) {
_game->changeScene(door->_destSceneId, _game->getGameData()._partB);
}
} else if (Static *const stat = scene->findStatic(x, y)) {
if (stat->_active == 1) {
_game->startActionSection(_game->getCurrentAction(), stat->_name);
}
_game->startActionSection(_game->getCurrentAction(), stat->_name);
}
break;
}
@@ -224,9 +222,7 @@ void MutationOfJBEngine::updateCursorHitTest(int16 x, int16 y) {
entityHit = true;
}
} else if (Static *const stat = scene->findStatic(x, y)) {
if (stat->_active == 1) {
entityHit = true;
}
entityHit = true;
}
bool cursorPaletteChange = false;
if ((_cursorState == CURSOR_ACTIVE && !entityHit) || (_cursorState == CURSOR_IDLE && entityHit)) {

0 comments on commit 008bfeb

Please sign in to comment.