changeset 1248:d3bf0d4fb753

aWinProc cleanup - fixing bad condition, exctracting common code from conditions, part 1
author Grumpy7
date Mon, 10 Jun 2013 03:41:30 +0200
parents 6279bf7a4d1a
children bbde4964e9b7
files mm7_2.cpp
diffstat 1 files changed, 126 insertions(+), 481 deletions(-) [+]
line wrap: on
line diff
--- a/mm7_2.cpp	Sun Jun 09 23:53:01 2013 +0200
+++ b/mm7_2.cpp	Mon Jun 10 03:41:30 2013 +0200
@@ -6074,492 +6074,137 @@
       if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_PRESS_ESCAPE_MESSAGE )
         return 0;
     }
+
     pArcomageGame->stru1.field_0 = 1;
-    if ( (unsigned __int16)GetAsyncKeyState(VK_SHIFT) >> 8 >= 0 )
+    if ( GetAsyncKeyState(VK_SHIFT) & 32768 ) // originally (char)((unsigned __int16)GetAsyncKeyState(VK_SHIFT) >> 8) >= 0
       v27 = MapVirtualKeyA((unsigned __int16)wParam, 2u);
     else
     {
       v13 = (unsigned __int16)MapVirtualKeyA((unsigned __int16)wParam, 2u);
-      if ( (signed int)(unsigned __int16)v13 > 54 )
-      {
-        if ( v13 > 61 )
-        {
-          if ( v13 == 91 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 123;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 92 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 124;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 93 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 125;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 96 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 126;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-        }
-        else
-        {
-          if ( v13 == 61 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 43;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 55 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 38;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 56 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 42;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 57 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 40;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 59 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 58;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-        }
-      }
-      else
-      {
-        if ( (unsigned __int16)v13 == 54 )
-        {
-          LOBYTE(pArcomageGame->stru1.field_8) = 94;
-          //goto LABEL_181;
-          if ( wParam == 27 )
-          {
-            pArcomageGame->GameOver = 1;
-            pArcomageGame->field_F4 = 1;
-            pArcomageGame->uGameResult = 2;
-            pArcomageGame->field_B0 = -2;
-            //goto _def_wnd_proc;
-            return DefWindowProcA(hWnd, Msg, wParam, lParam);
-          }
-          if ( wParam != 114 )
-          {
-            if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-              SendMessageA(hWnd, 0x111u, 0x68u, 0);
-            //goto _def_wnd_proc;
-            return DefWindowProcA(hWnd, Msg, wParam, lParam);
-          }
-          SendMessageA(hWnd, WM_COMMAND, 103, 0);
-          return 0;
-        }
-        if ( v13 > 49 )
-        {
-          if ( v13 == 50 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 64;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 51 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 35;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 52 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 36;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 53 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 37;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-        }
-        else
-        {
-          if ( v13 == 49 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 33;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 39 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 34;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 44 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 60;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 46 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 62;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 47 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 63;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 48 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 41;
-//LABEL_181:
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-        }
-      }
-      v27 = MapVirtualKeyA((unsigned __int16)wParam, 2u);
-    }
+      bool valSet = false;
+      if ( v13 == 91 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 123;
+        valSet = true;
+      }
+      if ( v13 == 92 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 124;
+        valSet = true;
+      }
+      if ( v13 == 93 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 125;
+        valSet = true;
+      }
+      if ( v13 == 96 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 126;
+        valSet = true;
+      }
+      if ( v13 == 61 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 43;
+        valSet = false;
+      }
+      if ( v13 == 55 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 38;
+        valSet = false;
+      }
+      if ( v13 == 56 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 42;
+        valSet = false;
+      }
+      if ( v13 == 57 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 40;
+        valSet = false;
+      }
+      if ( v13 == 59 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 58;
+        valSet = false;
+      }
+      if ( v13 == 54 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 94;
+        valSet = true;
+      }
+      if ( v13 == 50 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 64;
+        valSet = true;
+      }
+      if ( v13 == 51 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 35;
+        valSet = true;
+      }
+      if ( v13 == 52 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 36;
+        valSet = true;
+      }
+      if ( v13 == 53 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 37;
+        valSet = true;
+      }
+      if ( v13 == 49 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 33;
+        valSet = true;
+      }
+      if ( v13 == 39 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 34;
+        valSet = true;
+      }
+      if ( v13 == 44 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 60;
+        valSet = true;
+      }
+      if ( v13 == 46 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 62;
+        valSet = true;
+      }
+      if ( v13 == 47 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 63;
+        valSet = true;
+      }
+      if ( v13 == 48 )
+      {
+        LOBYTE(pArcomageGame->stru1.field_8) = 41;
+        valSet = true;
+      }
+      if (valSet)
+      {
+        if ( wParam == 27 )
+        {
+          pArcomageGame->GameOver = 1;
+          pArcomageGame->field_F4 = 1;
+          pArcomageGame->uGameResult = 2;
+          pArcomageGame->field_B0 = -2;
+          //goto _def_wnd_proc;
+          return DefWindowProcA(hWnd, Msg, wParam, lParam);
+        }
+        if ( wParam != 114 )
+        {
+          if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
+            SendMessageA(hWnd, 0x111u, 0x68u, 0);
+          //goto _def_wnd_proc;
+          return DefWindowProcA(hWnd, Msg, wParam, lParam);
+        }
+        SendMessageA(hWnd, WM_COMMAND, 103, 0);
+        return 0;
+      }
+    }
+    v27 = MapVirtualKeyA((unsigned __int16)wParam, 2u);
     LOBYTE(pArcomageGame->stru1.field_8) = v27;
     //goto LABEL_181;
     if ( wParam == 27 )