NANCY: Fix crash loading scene with PuzzleData

A scene that contains one of the puzzles that have an
associated PuzzleData struct would previously crash on load,
because loading from a save would clear the PuzzleData
struct after the pointer to it was acquired by the puzzle.
This commit adds second calls to getPuzzleData() in
those puzzles, ensuring the pointer will be correct.
This commit is contained in:
Kaloyan Chehlarski 2024-07-21 23:05:37 +02:00
parent c07720c1c0
commit dd6e641f9c
6 changed files with 18 additions and 0 deletions

View File

@ -118,6 +118,9 @@ void AssemblyPuzzle::readData(Common::SeekableReadStream &stream) {
void AssemblyPuzzle::execute() {
switch (_state) {
case kBegin:
_puzzleState = (AssemblyPuzzleData *)NancySceneState.getPuzzleData(AssemblyPuzzleData::getTag());
assert(_puzzleState);
init();
registerGraphics();

View File

@ -97,6 +97,9 @@ void RiddlePuzzle::readData(Common::SeekableReadStream &stream) {
void RiddlePuzzle::execute() {
switch (_state) {
case kBegin: {
_puzzleState = (RiddlePuzzleData *)NancySceneState.getPuzzleData(RiddlePuzzleData::getTag());
assert(_puzzleState);
init();
registerGraphics();
_nextBlinkTime = g_nancy->getTotalPlayTime() + _cursorBlinkTime;

View File

@ -194,6 +194,9 @@ void RippedLetterPuzzle::readData(Common::SeekableReadStream &stream) {
void RippedLetterPuzzle::execute() {
switch (_state) {
case kBegin:
_puzzleState = (RippedLetterPuzzleData *)NancySceneState.getPuzzleData(RippedLetterPuzzleData::getTag());
assert(_puzzleState);
init();
registerGraphics();

View File

@ -109,6 +109,9 @@ void SliderPuzzle::readData(Common::SeekableReadStream &stream) {
void SliderPuzzle::execute() {
switch (_state) {
case kBegin:
_puzzleState = (SliderPuzzleData *)NancySceneState.getPuzzleData(SliderPuzzleData::getTag());
assert(_puzzleState);
init();
registerGraphics();
if (!_puzzleState->playerHasTriedPuzzle || !_retainState) {

View File

@ -192,6 +192,9 @@ void SoundEqualizerPuzzle::readData(Common::SeekableReadStream &stream) {
void SoundEqualizerPuzzle::execute() {
switch(_state) {
case kBegin:
_puzzleState = (SoundEqualizerPuzzleData *)NancySceneState.getPuzzleData(SoundEqualizerPuzzleData::getTag());
assert(_puzzleState);
init();
registerGraphics();

View File

@ -96,6 +96,9 @@ void TowerPuzzle::readData(Common::SeekableReadStream &stream) {
void TowerPuzzle::execute() {
switch (_state) {
case kBegin:
_puzzleState = (TowerPuzzleData *)NancySceneState.getPuzzleData(TowerPuzzleData::getTag());
assert(_puzzleState);
init();
registerGraphics();
_numRings = _numRingsByDifficulty[NancySceneState.getDifficulty()];