From 348d79ef382025e0a1810d12af1b8602679076b8 Mon Sep 17 00:00:00 2001 From: Muzychenko Andrey <33288308+k4zmu2a@users.noreply.github.com> Date: Mon, 18 Oct 2021 09:31:47 +0300 Subject: [PATCH] Bugs and suggestions from PR# 48. --- SpaceCadetPinball/control.cpp | 6 +++--- SpaceCadetPinball/fullscrn.cpp | 11 ++++++----- SpaceCadetPinball/midi.cpp | 6 +++++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/SpaceCadetPinball/control.cpp b/SpaceCadetPinball/control.cpp index 5e401bb..56d8a3b 100644 --- a/SpaceCadetPinball/control.cpp +++ b/SpaceCadetPinball/control.cpp @@ -1019,7 +1019,7 @@ void control::LaunchRampControl(int code, TPinballComponent* caller) { sound = control_soundwave21_tag.Component; } - else if (someFlag <= 1 || someFlag > 3) + else if (someFlag < 1 || someFlag > 3) { sound = control_soundwave24_tag.Component; } @@ -2148,7 +2148,7 @@ void control::HyperspaceKickOutControl(int code, TPinballComponent* caller) } else { - if (someFlag <= 1 || someFlag > 3) + if (someFlag < 1 || someFlag > 3) { auto duration = control_soundwave41_tag.Component->Play(); control_soundwave36_1_tag.Component->Play(); @@ -2919,7 +2919,7 @@ void control::GameoverController(int code, TPinballComponent* caller) if (missionMsg & 0x200) { - int highscoreId = missionMsg % 4; + int highscoreId = missionMsg % 5; int highScore = pb::highscore_table[highscoreId].Score; auto nextHidhscoreId = highscoreId + 1; if (highScore > 0) diff --git a/SpaceCadetPinball/fullscrn.cpp b/SpaceCadetPinball/fullscrn.cpp index fa838c3..7b4be33 100644 --- a/SpaceCadetPinball/fullscrn.cpp +++ b/SpaceCadetPinball/fullscrn.cpp @@ -57,10 +57,11 @@ int fullscrn::enableFullscreen() { if (!display_changed) { - SDL_SetWindowFullscreen(winmain::MainWindow, SDL_WINDOW_FULLSCREEN_DESKTOP); - display_changed = 1; - if (display_changed) + if (SDL_SetWindowFullscreen(winmain::MainWindow, SDL_WINDOW_FULLSCREEN_DESKTOP) == 0) + { + display_changed = 1; return 1; + } } return 0; } @@ -69,8 +70,8 @@ int fullscrn::disableFullscreen() { if (display_changed) { - SDL_SetWindowFullscreen(winmain::MainWindow, 0); - display_changed = 0; + if (SDL_SetWindowFullscreen(winmain::MainWindow, 0) == 0) + display_changed = 0; } return 0; diff --git a/SpaceCadetPinball/midi.cpp b/SpaceCadetPinball/midi.cpp index 68a19a1..a049a67 100644 --- a/SpaceCadetPinball/midi.cpp +++ b/SpaceCadetPinball/midi.cpp @@ -316,7 +316,11 @@ std::vector* midi::MdsToMidi(std::string file) while (false); delete[] fileBuf; - if (returnCode && midiOut) + if (returnCode && midiOut) + { delete midiOut; + midiOut = nullptr; + } + return midiOut; }