DIRECTOR: Refactor scoreCachedPaletteId to frames loading

Move caching logic of scoreCachedPaletteId from Score to Frame.
This commit is contained in:
Harishankar Kumar 2023-07-17 01:14:06 +05:30 committed by Eugene Sandulenko
parent e13eba2162
commit b1da9423b9
2 changed files with 6 additions and 6 deletions

View File

@ -210,6 +210,8 @@ void Frame::readMainChannelsD2(Common::MemoryReadStreamEndian &stream, uint16 of
} else {
_mainChannels.palette.paletteId = CastMemberID(paletteId, DEFAULT_CAST_LIB);
}
if (!_mainChannels.palette.paletteId.isNull())
_mainChannels.scoreCachedPaletteId = _mainChannels.palette.paletteId;
}
break;
case 18:
@ -463,6 +465,8 @@ void Frame::readMainChannelsD4(Common::MemoryReadStreamEndian &stream, uint16 of
} else {
_mainChannels.palette.paletteId = CastMemberID(paletteId, DEFAULT_CAST_LIB);
}
if (!_mainChannels.palette.paletteId.isNull())
_mainChannels.scoreCachedPaletteId = _mainChannels.palette.paletteId;
}
break;
case 22:
@ -740,6 +744,8 @@ void Frame::readMainChannelsD5(Common::MemoryReadStreamEndian &stream, uint16 of
int16 paletteCastLib = stream.readSint16();
int16 paletteId = stream.readSint16(); // 26
_mainChannels.palette.paletteId = CastMemberID(paletteId, paletteCastLib);
if (!_mainChannels.palette.paletteId.isNull())
_mainChannels.scoreCachedPaletteId = _mainChannels.palette.paletteId;
}
break;
case 28:

View File

@ -1528,12 +1528,6 @@ bool Score::readOneFrame() {
debugC(4, kDebugLoading, "%s", _currentFrame->formatChannelInfo().c_str());
}
// Precache the current palette ID, as this carries forward to frames to the right
// of the instruction
if (!_currentFrame->_mainChannels.palette.paletteId.isNull())
_currentPaletteId = _currentFrame->_mainChannels.palette.paletteId;
_currentFrame->_mainChannels.scoreCachedPaletteId = _currentPaletteId;
debugC(8, kDebugLoading, "Score::readOneFrame(): Frame %d actionId: %s", _curFrameNumber, _currentFrame->_mainChannels.actionId.asString().c_str());
return true;
} else {