From f64cf4f831b6a3b9f2b5076d7ba2ea8ee26f3cb9 Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 3 Jan 2021 23:23:46 -0800 Subject: [PATCH] Invert t comparison with -1 and un-nest rest of function This is also another conditional where the rest of the function is nested. Furthermore, in order to not repeat ourselves, I've also decided to unconditionally assign currentsong to t, because if t is -1 currentsong gets assigned to -1 anyway - so it's the same thing, but it's much easier to see and think about. --- desktop_version/src/Music.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index 107b4a31..cf6b4e57 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -193,9 +193,12 @@ void musicclass::play(int t, const double position_sec /*= 0.0*/, const int fade return; } - if (t != -1) + currentsong = t; + + if (t == -1) { - currentsong = t; + return; + } if (!INBOUNDS_VEC(t, musicTracks)) { @@ -237,11 +240,6 @@ void musicclass::play(int t, const double position_sec /*= 0.0*/, const int fade } songStart = SDL_GetPerformanceCounter(); - } - else - { - currentsong = -1; - } } void musicclass::resume(const int fadein_ms /*= 0*/)