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.
This commit is contained in:
Miroslav Remák 2018-08-29 18:10:44 +02:00 committed by Ľubomír Remák
parent 8033f62f93
commit ad73f65a20
3 changed files with 14 additions and 9 deletions

View file

@ -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;
}

View file

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

View file

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