changeset 979:8b46828a64f4

Knight error fix
author Ritor1
date Thu, 09 May 2013 13:04:27 +0600
parents 9334a8c59c8d
children a079c489118d
files mm7_1.cpp
diffstat 1 files changed, 211 insertions(+), 215 deletions(-) [+]
line wrap: on
line diff
--- a/mm7_1.cpp	Thu May 09 02:26:04 2013 +0600
+++ b/mm7_1.cpp	Thu May 09 13:04:27 2013 +0600
@@ -112,20 +112,20 @@
   //unsigned int v2; // eax@2
   int v3; // esi@3
   int v4; // ecx@10
-  GUIButton *v5; // eax@11
+  GUIButton *pButton; // eax@11
   int v6; // edx@12
   int v7; // ecx@20
   char v8; // zf@21
-  GUIButton *v9; // ecx@24
+  //GUIButton *v9; // ecx@24
   int v10; // esi@24
   //int v11; // edx@26
   int v12; // edx@28
   int v13; // esi@32
-  GUIButton *v14; // eax@37
+  //GUIButton *v14; // eax@37
   int v15; // edx@38
   int v17; // ecx@50
   int v18; // edx@50
-  GUIButton *v19; // ecx@54
+  //GUIButton *v19; // ecx@54
   int v20; // esi@54
   //int v21; // edx@56
   int v22; // ecx@59
@@ -142,7 +142,7 @@
   //v1 = 0;
   //v27 = uNumVisibleWindows;
   if ( uNumVisibleWindows < 0 )
-    return 0;
+    return false;
   //v2 = pMessageQueue_50CBD0->uNumMessages;
   for (int i = uNumVisibleWindows; i >= 0; --i)
   //while ( 1 )
@@ -151,218 +151,214 @@
     if (!pWindowList[v3].receives_keyboard_input)
       continue;
 
-		switch (vkKey)
-		{
-			case VK_LEFT:
-				{
-				v12 = pWindowList[v3].field_34;
-				if ( pWindowList[v3].pCurrentPosActiveItem - pWindowList[v3].pStartingPosActiveItem - v12 >= 0 )
-				{
-				  v8 = pCurrentScreen == SCREEN_PARTY_CREATION;
-				  pWindowList[v3].pCurrentPosActiveItem -= v12;
-				  if ( v8 )
-				  {
-					pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
-					//v2 = pMessageQueue_50CBD0->uNumMessages;
-				  }
-				}
-				if ( pWindowList[v3].field_30 != 0 )
-				{
-					break;
-				}
-				v9 = pWindowList[v3].pControlsHead;
-				v13 = pWindowList[v3].pCurrentPosActiveItem;
-				if ( v13 > 0)
-				{
-				  do
-				  {
-					v9 = v9->pNext;
-					--v13;
-				  }
-				  while ( v13 );
-				}
-
-                pMessageQueue_50CBD0->AddMessage(v9->msg, v9->msg_param, 0);
-				break;
-				}
-			case VK_RIGHT:
-				{
-				v7 = pWindowList[v3].pCurrentPosActiveItem + pWindowList[v3].field_34;
-				if ( v7 < pWindowList[v3].pNumPresenceButton + pWindowList[v3].pStartingPosActiveItem )
-				{
-					v8 = pCurrentScreen == SCREEN_PARTY_CREATION;
-					pWindowList[v3].pCurrentPosActiveItem = v7;
-					if ( v8 )
-					{
-						pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
-						//v2 = pMessageQueue_50CBD0->uNumMessages;
-					}
-				}
-				if ( pWindowList[v3].field_30 != 0 )
-				{
-					break;
-				}
-				v9 = pWindowList[v3].pControlsHead;
-				v10 = pWindowList[v3].pCurrentPosActiveItem;
-				if ( v10 > 0)
-				{
-					do
-					{
-						v9 = v9->pNext;
-						--v10;
-					}
-					while ( v10 );
-				}
-				pMessageQueue_50CBD0->AddMessage(v9->msg, v9->msg_param, 0);
-				break;				
-				}
-			case VK_DOWN:
-				{
-				v17 = pWindowList[v3].pStartingPosActiveItem;
-				v18 = pWindowList[v3].pCurrentPosActiveItem;
-				if ( v18 >= pWindowList[v3].pNumPresenceButton + v17 - 1 )
-					pWindowList[v3].pCurrentPosActiveItem = v17;
-				else
-					pWindowList[v3].pCurrentPosActiveItem = v18 + 1;
-				if ( pWindowList[v3].field_30 != 0 )
-					return 1;
-				v19 = pWindowList[v3].pControlsHead;
-				v20 = pWindowList[v3].pCurrentPosActiveItem;
-				if ( v20 > 0)
-				{
-					do
-					{
-						v19 = v19->pNext;
-						--v20;
-					}
-					while ( v20 );
-				}
-				pMessageQueue_50CBD0->AddMessage(v19->msg, v19->msg_param, 0);
-				return 1;
-				}
-			case VK_SELECT:
-				{
-				pMouse->GetClickPos(&uClickX, &uClickY);
-				v4 = pWindowList[v3].pStartingPosActiveItem;
-				v28 = v4 + pWindowList[v3].pNumPresenceButton;
-				if ( v4 < v4 + pWindowList[v3].pNumPresenceButton )
-				{
-					while ( 1 )
-					{
-						v5 = pWindowList[v3].pControlsHead;
-						if ( v4 > 0 )
-						{
-							v6 = v4;
-							do
-							{
-								v5 = v5->pNext;
-								--v6;
-							}
-							while ( v6 );
-						}
-						if ( (signed int)uClickX >= (signed int)v5->uX
-						&& (signed int)uClickX <= (signed int)v5->uZ
-						&& (signed int)uClickY >= (signed int)v5->uY
-						&& (signed int)uClickY <= (signed int)v5->uW )
-							break;
-						++v4;
-						if ( v4 >= v28 )
-						{
-							//v1 = 0;
-							//v2 = pMessageQueue_50CBD0->uNumMessages;
-							--i;
-							if ( i < 0 )
-  								return 0;
-							continue;
-						}
-					}
-					pWindowList[v3].pCurrentPosActiveItem = v4;
-					return 1;
-				}
-				//v2 = pMessageQueue_50CBD0->uNumMessages;
-				break;
-				}
-			case VK_UP:
-				{
-				v22 = pWindowList[v3].pCurrentPosActiveItem;
-				v23 = pWindowList[v3].pStartingPosActiveItem;
-				if ( v22 <= v23 )
-					v24 = pWindowList[v3].pNumPresenceButton + v23 - 1;
-				else
-					v24 = v22 - 1;
-				v8 = pWindowList[v3].field_30 == 0;
-				pWindowList[v3].pCurrentPosActiveItem = v24;
-				if ( !v8 )
-					return 1;
-				v19 = pWindowList[v3].pControlsHead;
-				v25 = pWindowList[v3].pCurrentPosActiveItem;
-				if ( v25 > 0)
-				{
-					do
-					{
-						v19 = v19->pNext;
-						--v25;
-					}
-					while ( v25 );
-				}
-
-				pMessageQueue_50CBD0->AddMessage(v19->msg, v19->msg_param, 0);
-				return 1;
-				}
-			case VK_NEXT:
-				{
-				if ( pWindowList[v3].field_30 != 0 )
-				{
-					pMouse->GetClickPos(&uClickX, &uClickY);
-					v4 = pWindowList[v3].pStartingPosActiveItem;
-					v29 = v4 + pWindowList[v3].pNumPresenceButton;
-					if ( v4 < v4 + pWindowList[v3].pNumPresenceButton )
-					{
-						while ( 1 )
-						{
-							v14 = pWindowList[v3].pControlsHead;
-							if ( v4 > 0 )
-							{
-								v15 = v4;
-								do
-								{
-									v14 = v14->pNext;
-									--v15;
-								}
-								while ( v15 );
-							}
-							if ( (signed int)uClickX >= (signed int)v14->uX
-							&& (signed int)uClickX <= (signed int)v14->uZ
-							&& (signed int)uClickY >= (signed int)v14->uY
-							&& (signed int)uClickY <= (signed int)v14->uW )
-							{
-								pWindowList[v3].pCurrentPosActiveItem = v4;
-								return 1;
-							}
-							++v4;
-							if ( v4 >= v29 )
-							{
-								//v1 = 0;
-								//v2 = pMessageQueue_50CBD0->uNumMessages;
-								break;
-							}
-						}
-					}
-					else
-					{
-						//v2 = pMessageQueue_50CBD0->uNumMessages;
-					}
-				}
-				break;
-				}
-			default:
-				{
-				break;
-				}
-			
+    switch (vkKey)
+    {
+      case VK_LEFT:
+      {
+        v12 = pWindowList[v3].field_34;
+        if ( pWindowList[v3].pCurrentPosActiveItem - pWindowList[v3].pStartingPosActiveItem - v12 >= 0 )
+        {
+          v8 = pCurrentScreen == SCREEN_PARTY_CREATION;
+          pWindowList[v3].pCurrentPosActiveItem -= v12;
+          if ( v8 )
+          {
+            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
+            //v2 = pMessageQueue_50CBD0->uNumMessages;
+          }
+        }
+        if ( pWindowList[v3].field_30 != 0 )
+        {
+          break;
+        }
+        pButton = pWindowList[v3].pControlsHead;
+        v13 = pWindowList[v3].pCurrentPosActiveItem;
+        if ( v13 > 0)
+        {
+          do
+          {
+            pButton = pButton->pNext;
+            --v13;
+          }
+          while ( v13 );
+        }
+        pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0);
+        break;
+      }
+      case VK_RIGHT:
+      {
+        v7 = pWindowList[v3].pCurrentPosActiveItem + pWindowList[v3].field_34;
+        if ( v7 < pWindowList[v3].pNumPresenceButton + pWindowList[v3].pStartingPosActiveItem )
+        {
+          v8 = pCurrentScreen == SCREEN_PARTY_CREATION;
+          pWindowList[v3].pCurrentPosActiveItem = v7;
+          if ( v8 )
+          {
+            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
+            //v2 = pMessageQueue_50CBD0->uNumMessages;
+          }
+        }
+        if ( pWindowList[v3].field_30 != 0 )
+        {
+          break;
+        }
+        pButton = pWindowList[v3].pControlsHead;
+        v10 = pWindowList[v3].pCurrentPosActiveItem;
+        if ( v10 > 0)
+        {
+          do
+          {
+            pButton = pButton->pNext;
+            --v10;
+          }
+          while ( v10 );
+        }
+        pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0);
+        break;
+      }
+      case VK_DOWN:
+      {
+        v17 = pWindowList[v3].pStartingPosActiveItem;
+        v18 = pWindowList[v3].pCurrentPosActiveItem;
+        if ( v18 >= pWindowList[v3].pNumPresenceButton + v17 - 1 )
+          pWindowList[v3].pCurrentPosActiveItem = v17;
+        else
+          pWindowList[v3].pCurrentPosActiveItem = v18 + 1;
+        if ( pWindowList[v3].field_30 != 0 )
+          return true;
+        pButton = pWindowList[v3].pControlsHead;
+        v20 = pWindowList[v3].pCurrentPosActiveItem;
+        if ( v20 > 0)
+        {
+          do
+          {
+            pButton = pButton->pNext;
+            --v20;
+          }
+          while ( v20 );
         }
+        pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0);
+        return true;
+      }
+      case VK_SELECT:
+      {
+        pMouse->GetClickPos(&uClickX, &uClickY);
+        v4 = pWindowList[v3].pStartingPosActiveItem;
+        v28 = v4 + pWindowList[v3].pNumPresenceButton;
+        if ( v4 < v4 + pWindowList[v3].pNumPresenceButton )
+        {
+          while ( 1 )
+          {
+            pButton = pWindowList[v3].pControlsHead;
+            if ( v4 > 0 )
+            {
+              v6 = v4;
+              do
+              {
+                pButton = pButton->pNext;
+                --v6;
+              }
+              while ( v6 );
+            }
+            if ( (signed int)uClickX >= (signed int)pButton->uX//test for StatsTab in PlayerCreation Window
+               && (signed int)uClickX <= (signed int)pButton->uZ
+               && (signed int)uClickY >= (signed int)pButton->uY
+               && (signed int)uClickY <= (signed int)pButton->uW )
+              break;
+            ++v4;
+            if ( v4 >= v28 )
+            {
+              //v1 = 0;
+              //v2 = pMessageQueue_50CBD0->uNumMessages;
+              //--i;
+              //if ( i < 0 )
+                return false;
+              //continue;
+            }
+          }
+          pWindowList[v3].pCurrentPosActiveItem = v4;
+          return true;
+        }
+        //v2 = pMessageQueue_50CBD0->uNumMessages;
+        break;
+      }
+      case VK_UP:
+      {
+        v22 = pWindowList[v3].pCurrentPosActiveItem;
+        v23 = pWindowList[v3].pStartingPosActiveItem;
+        if ( v22 <= v23 )
+          v24 = pWindowList[v3].pNumPresenceButton + v23 - 1;
+        else
+          v24 = v22 - 1;
+        v8 = pWindowList[v3].field_30 == 0;
+        pWindowList[v3].pCurrentPosActiveItem = v24;
+        if ( !v8 )
+          return true;
+        pButton = pWindowList[v3].pControlsHead;
+        v25 = pWindowList[v3].pCurrentPosActiveItem;
+        if ( v25 > 0)
+        {
+          do
+          {
+            pButton = pButton->pNext;
+            --v25;
+          }
+          while ( v25 );
+        }
+        pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0);
+        return true;
+      }
+      case VK_NEXT:
+      {
+        if ( pWindowList[v3].field_30 != 0 )
+        {
+          pMouse->GetClickPos(&uClickX, &uClickY);
+          v4 = pWindowList[v3].pStartingPosActiveItem;
+          v29 = v4 + pWindowList[v3].pNumPresenceButton;
+          if ( v4 < v4 + pWindowList[v3].pNumPresenceButton )
+          {
+            while ( 1 )
+            {
+              pButton = pWindowList[v3].pControlsHead;
+              if ( v4 > 0 )
+              {
+                v15 = v4;
+                do
+                {
+                  pButton = pButton->pNext;
+                  --v15;
+                }
+                while ( v15 );
+              }
+              if ( (signed int)uClickX >= (signed int)pButton->uX
+                && (signed int)uClickX <= (signed int)pButton->uZ
+                && (signed int)uClickY >= (signed int)pButton->uY
+                && (signed int)uClickY <= (signed int)pButton->uW )
+              {
+                pWindowList[v3].pCurrentPosActiveItem = v4;
+                return true;
+              }
+              ++v4;
+              if ( v4 >= v29 )
+              {
+                //v1 = 0;
+                //v2 = pMessageQueue_50CBD0->uNumMessages;
+                break;
+              }
+            }
+          }
+          else
+          {
+            //v2 = pMessageQueue_50CBD0->uNumMessages;
+          }
+        }
+        break;
+      }
+      default:
+      {
+        break;
+      }
+    }
   }
-
 }
 
 //----- (0041D20D) --------------------------------------------------------