From 31b7e7fa3d252e40612f2891326196da62bc2d6f Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 27 Jul 2020 17:51:36 +1000 Subject: [PATCH] - revert some inline if statement conversions when re-creating `dobonus()` as a ScreenJob. * Inline if statements were applying `DrawTexture()` calls to cases where they were not being called before, affecting animation. * Repaired issue where with high frame rates, the code behind `if (totalclock > (1000000000L) && totalclock < (1000000320L))` wasn't triggered because `totalclock` hadn't become `1000000001` yet. * Fixes #34. --- source/games/duke/src/2d_d.cpp | 45 +++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/source/games/duke/src/2d_d.cpp b/source/games/duke/src/2d_d.cpp index 66670d4e8..8bdd613ef 100644 --- a/source/games/duke/src/2d_d.cpp +++ b/source/games/duke/src/2d_d.cpp @@ -905,30 +905,41 @@ public: PrintSecrets(totalclock); } - if (totalclock > (1000000000L) && totalclock < (1000000320L)) + if (totalclock >= (1000000000L) && totalclock < (1000000320L)) { - int val = (totalclock >> 4) % 15; - if (val == 0) + switch ((totalclock >> 4) % 15) { - if (bonuscnt == 6) - { - bonuscnt++; - S_PlaySound(SHOTGUN_COCK, CHAN_AUTO, CHANF_UI); - S_PlaySound(BONUS_SPEECH1 + (rand() & 3), CHAN_AUTO, CHANF_UI); - } - } - //else - { - int tile = val == 2 || val == 3 ? gfx_offset + 4 : gfx_offset + 3; - DrawTexture(twod, tileGetTexture(tile), 199, 31, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TopLeft, true, TAG_DONE); + case 0: + if (bonuscnt == 6) + { + bonuscnt++; + S_PlaySound(SHOTGUN_COCK, CHAN_AUTO, CHANF_UI); + S_PlaySound(BONUS_SPEECH1 + (rand() & 3), CHAN_AUTO, CHANF_UI); + } + case 1: + case 4: + case 5: + DrawTexture(twod, tileGetTexture(gfx_offset + 3), 199, 31, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TopLeft, true, TAG_DONE); + break; + case 2: + case 3: + DrawTexture(twod, tileGetTexture(gfx_offset + 4), 199, 31, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TopLeft, true, TAG_DONE); + break; } } else if (totalclock > (10240 + 120L)) return 0; else { - int val = (totalclock >> 5) & 3; - int tile = val == 2 ? gfx_offset + 2 : gfx_offset + 1; - DrawTexture(twod, tileGetTexture(tile), 199, 31, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TopLeft, true, TAG_DONE); + switch((totalclock >> 5) & 3) + { + case 1: + case 3: + DrawTexture(twod, tileGetTexture(gfx_offset + 1), 199, 31, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TopLeft, true, TAG_DONE); + break; + case 2: + DrawTexture(twod, tileGetTexture(gfx_offset + 2), 199, 31, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_TopLeft, true, TAG_DONE); + break; + } } if (totalclock > 10240 && totalclock < 10240 + 10240)