SCUMM: (IMS) - fix regression

Player::isFadingOut() was broken by recent fader code changes.
The function does not exist in original drivers, but is needed to
work around MI2 bug no. 385 (original interpreter bug).
This commit is contained in:
athrxx 2024-04-26 23:00:39 +02:00
parent 2393cd4428
commit ea3de9e8ed
2 changed files with 17 additions and 4 deletions

View File

@ -705,6 +705,18 @@ int IMuseInternal::stopAllSounds_internal() {
} }
int IMuseInternal::getSoundStatus_internal(int sound, bool ignoreFadeouts) const { int IMuseInternal::getSoundStatus_internal(int sound, bool ignoreFadeouts) const {
if (_game_id != GID_MONKEY2) {
// The whole fadeout checking / ignoring is not present in any of the original
// drivers, but necessary as a WORKAROUND for a bug in Monkey Island 2 that also
// happens with the original interpreter (bug no. 385: "No music if room
// transition is too fast"). The bug is caused by sloppy scripting, but probably
// wouldn't ever be seen on machines of that era, when the loading time for a
// room change would take longer than the fadeout time.
// Since the code is objectively wrong and the workaround is not known to be
// needed elsewhere, we restrict it to Monkey Island 2.
ignoreFadeouts = false;
}
const Player *player = _players; const Player *player = _players;
for (int i = ARRAYSIZE(_players); i; i--, player++) { for (int i = ARRAYSIZE(_players); i; i--, player++) {
if (player->isActive() && (!ignoreFadeouts || !player->isFadingOut())) { if (player->isActive() && (!ignoreFadeouts || !player->isFadingOut())) {

View File

@ -135,10 +135,11 @@ int Player::getMusicTimer() const {
} }
bool Player::isFadingOut() const { bool Player::isFadingOut() const {
int i; for (int i = 0; i < ARRAYSIZE(_parameterFaders); ++i) {
for (i = 0; i < ARRAYSIZE(_parameterFaders); ++i) { const ParameterFader &p = _parameterFaders[i];
if (_parameterFaders[i].param == ParameterFader::pfVolume && (_parameterFaders[i].incr || _parameterFaders[i].ifrac)) if (p.param == ParameterFader::pfVolume &&
return true; _volume + p.cntdwn * p.incr + ((p.irem + p.cntdwn * p.ifrac) / p.ttime) * p.dir == 0)
return true;
} }
return false; return false;
} }