changeset 594:badd65dff4e7

Merge
author Nomad
date Wed, 06 Mar 2013 16:14:21 +0200
parents 8ef867ae88b9 (current diff) 829fb49eee05 (diff)
children 55d6b756e03a
files
diffstat 5 files changed, 903 insertions(+), 850 deletions(-) [+]
line wrap: on
line diff
--- a/Indoor.cpp	Wed Mar 06 16:12:38 2013 +0200
+++ b/Indoor.cpp	Wed Mar 06 16:14:21 2013 +0200
@@ -372,20 +372,19 @@
     _this.uFlags |= INDOOR_CAMERA_DRAW_D3D_OUTLINES;
 
   _this.field_0_timer = pEventTimer->uTotalGameTimeElapsed;
-  _this.vPosition.x = pParty->vPosition.x - ((unsigned __int64)(stru_5C6E00->Cos(pParty->sRotationY) * (signed __int64)pParty->y_rotation_granularity) >> 16);
-  v2 = stru_5C6E00->Sin(pParty->sRotationY);
-  v3 = (unsigned __int64)(v2 * (signed __int64)pParty->y_rotation_granularity) >> 16;
   _this.field_1C_mb_fov = 65;
-  _this.vPosition.y = pParty->vPosition.y - v3;
+  _this.vPosition.x = pParty->vPosition.x - ((stru_5C6E00->Cos(pParty->sRotationY) * (signed __int64)pParty->y_rotation_granularity) >> 16);
+  _this.vPosition.y = pParty->vPosition.y - ((stru_5C6E00->Sin(pParty->sRotationY) * (signed __int64)pParty->y_rotation_granularity) >> 16);
+  _this.vPosition.z = pParty->vPosition.z + pParty->sEyelevel;
+  _this.sRotationX = pParty->sRotationX;
   _this.sRotationY = pParty->sRotationY;
-  _this.sRotationX = pParty->sRotationX;
   _this.pRenderTarget = pRenderer->pTargetSurface;
   _this.uViewportX = pViewport->uScreenX;
   _this.uViewportY = pViewport->uScreenY;
   _this.uViewportZ = pViewport->uScreenZ;
   _this.uViewportW = pViewport->uScreenW;
   _this.field_3C = pViewport->field_30;
-  _this.vPosition.z = pParty->vPosition.z + pParty->sEyelevel;
+
   _this.uTargetWidth = 640;
   _this.uTargetHeight = 480;
   _this.pTargetZ = pRenderer->pActiveZBuffer;
@@ -507,15 +506,8 @@
     if (!pVertices ||
         (pGame->pStru9Instance->_498377(a4, 4u, pVertices, static_vertices_F7C228, &uNumVerticesa), uNumVerticesa) )
     {
-      if (pGame->pIndoorCameraD3D->_437285_prolly_colide_vertices_against_frustrum(
-                     static_vertices_F7C228,
-                     &uNumVerticesa,
-                     static_vertices_F7B628,
-                     pGame->pIndoorCameraD3D->std__vector_000034_prolly_frustrum,
-                     4,
-                     false,
-                     0) != 1
-                || uNumVerticesa )
+      if (pGame->pIndoorCameraD3D->_437285_prolly_colide_vertices_against_frustrum(static_vertices_F7C228, &uNumVerticesa,
+                     static_vertices_F7B628, pGame->pIndoorCameraD3D->std__vector_000034_prolly_frustrum, 4, false, 0) != 1 || uNumVerticesa )
       {
         a4a = SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel);
         v17 = (248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) | (((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) | ((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) << 8)) << 8);
@@ -535,26 +527,12 @@
           stru_F7B60C.face_plane.dist = pFace->pFacePlane.dist;
         }
 
-        if (stru_F8AD28.uNumLightsApplied > 0 &&
-            !(pFace->uAttributes & 0x400000))
-          pGame->pLightmapBuilder->ApplyLights(
-                    &stru_F8AD28,
-                    &stru_F7B60C,
-                    uNumVerticesa,
-                    array_507D30,
-                    pVertices,
-                    0);
+        if (stru_F8AD28.uNumLightsApplied > 0 && !pFace->uAttributes)
+            //!(pFace->uAttributes & 0x400000))
+          pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0);
 
         if (pDecalBuilder->uNumDecals > 0)
-          pDecalBuilder->ApplyDecals(
-                    a4a,
-                    1,
-                    &stru_F7B60C,
-                    uNumVerticesa,
-                    array_507D30,
-                    pVertices,
-                    0,
-                    pFace->uSectorID);
+          pDecalBuilder->ApplyDecals(a4a, 1, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0, pFace->uSectorID);
 
         if (pFace->Animated() &&
             pFace->uBitmapID == pRenderer->hd_water_tile_id )
@@ -579,18 +557,16 @@
           v23 = pFace->uBitmapID;
           goto LABEL_42;
         }
-        else if (pFace->uAttributes & 0x4000)
+        else if (pFace->uAttributes)//(pFace->uAttributes & 0x4000)
         {
-            v23 = pTextureFrameTable->GetFrameTexture(
-                            pFace->uBitmapID,
-                            pBLVRenderParams->field_0_timer_);
+          v23 = pTextureFrameTable->GetFrameTexture(pFace->uBitmapID, pBLVRenderParams->field_0_timer_);
 LABEL_42:
-                    v27 = pBitmaps_LOD->pHardwareTextures[v23];
-                    if (pFace->uAttributes & 0x400000)
-                      _479A53_draw_some_blv_poly(uNumVerticesa, uFaceID);
-                    else
-                      pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | 6, v17, 0);
-                    return;
+          v27 = pBitmaps_LOD->pHardwareTextures[v23];
+          if (pFace->uAttributes & 0x400000)
+            _479A53_draw_some_blv_poly(uNumVerticesa, uFaceID);
+          else
+            pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | 6, v17, 0);
+          return;
         }
       }
     }
--- a/MM7.vcxproj.filters	Wed Mar 06 16:12:38 2013 +0200
+++ b/MM7.vcxproj.filters	Wed Mar 06 16:14:21 2013 +0200
@@ -149,7 +149,6 @@
     <ClInclude Include="stru314.h" />
     <ClInclude Include="SaveLoad.h" />
     <ClInclude Include="stru287.h" />
-    <ClInclude Include="stru179.h" />
     <ClInclude Include="Awards.h" />
     <ClInclude Include="Autonotes.h" />
     <ClInclude Include="stru160.h" />
@@ -201,7 +200,6 @@
     <ClInclude Include="resource.h" />
     <ClInclude Include="stru346.h" />
     <ClInclude Include="texts.h" />
-    <ClInclude Include="SpriteObject.h" />
   </ItemGroup>
   <ItemGroup>
     <Filter Include="lib">
--- a/Render.cpp	Wed Mar 06 16:12:38 2013 +0200
+++ b/Render.cpp	Wed Mar 06 16:14:21 2013 +0200
@@ -1744,8 +1744,7 @@
 
   v63 = 0;
   // basic optimizations
-  unsigned int uStartX, uEndX,
-               uStartZ, uEndZ;
+  unsigned int uStartX, uEndX, uStartZ, uEndZ;
   if (pIndoorCamera->sRotationY >= 0 && pIndoorCamera->sRotationY <= 1024)
   {
     uStartX = 0, uEndX = 128;
--- a/mm7_1.cpp	Wed Mar 06 16:12:38 2013 +0200
+++ b/mm7_1.cpp	Wed Mar 06 16:14:21 2013 +0200
@@ -664,24 +664,23 @@
   {
     result += awards_count;
     dword_506528 = result;
-    if ( (signed int)(awards_count + result) <= awards_count2 )
-      goto LABEL_14;
-    result = awards_count2 - awards_count;
-    goto LABEL_13;
+    if ( (signed int)(awards_count + result) > awards_count2 )
+	{
+		result = awards_count2 - awards_count;
+		dword_506528 = result;
+	}
   }
-  if ( dword_50651C > 0 )
+  else if ( dword_50651C > 0 )
   {
     result -= awards_count;
     dword_506528 = result;
     if ( (result & 0x80000000u) != 0 )
     {
       result = 0;
-LABEL_13:
       dword_506528 = result;
-      goto LABEL_14;
     }
   }
-LABEL_14:
+//LABEL_14:
   dword_506544 = 0;
   dword_506548 = 0;
   awards_count = 0;
@@ -695,12 +694,71 @@
       v20 = achievedAwardsIndex[v21];
       v6 = (char *)pAwards[v20].pText;//(char *)dword_723E80_award_related[v20 / 4];
       if ( v5 != 1 )
-        break;
-      v17 = pParty->uFine;
-LABEL_42:
-      sprintf(pTmpBuf, v6, v17);
-      v6 = pTmpBuf;
-LABEL_43:
+	  {
+		if (!( (v5 < 85 || v5 > 91) && (v5 < 103 || v5 > 104) ))
+		{
+			if ( v5 > 89 )
+			{
+			  if ( v5 == 90 )
+			  {
+				v10 = (unsigned __int8)pParty->uNumArenaKnightWins;
+				v22 = v10;
+			  }
+			  else if ( v5 == 91 )
+			  {
+				v10 = (unsigned __int8)pParty->uNumArenaLordWins;
+				v22 = v10;
+			  }
+			  else if ( v5 == 103 )
+			  {
+				v10 = pParty->field_874;
+				v22 = v10;
+			  }
+			  else if ( v5 == 104 )
+			  {
+				v10 = pParty->field_878;
+				v22 = v10;
+			  }
+			}
+			else
+			{
+			  if ( v5 == 89 )
+			  {
+				v10 = (unsigned __int8)pParty->uNumArenaSquireWins;
+				v22 = v10;
+			  }
+			  else if ( v5 == 85 )
+			  {
+				v10 = pParty->uNumDeaths;
+				v22 = v10;
+			  }
+			  else if ( v5 == 86 )
+			  {
+				v10 = pParty->uNumBountiesCollected;
+				v22 = v10;
+			  }
+			  else if ( v5 == 87 )
+			  {
+				v10 = pParty->uNumPrisonTerms;
+				v22 = v10;
+			  }
+			  else if ( v5 == 88)
+			  {
+				v10 = (unsigned __int8)pParty->uNumArenaPageWins;
+				v22 = v10;
+			  }
+			}
+			v17 = v22;
+			sprintf(pTmpBuf, v6, v17);
+			v6 = pTmpBuf;
+		}
+	  }
+	  else
+	  {
+        v17 = pParty->uFine;
+        sprintf(pTmpBuf, v6, v17);
+        v6 = pTmpBuf;
+	  }
 	  v14 = pAwards[v20].uSort;//dword_723E84[v20 / 4];
       ++awards_count;
       v15 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(
@@ -720,70 +778,7 @@
       }
       return;
     }
-    if ( (v5 < 85 || v5 > 91) && (v5 < 103 || v5 > 104) )
-      goto LABEL_43;
-    if ( v5 > 89 )
-    {
-      v11 = v5 - 90;
-      if ( !v11 )
-      {
-        v10 = (unsigned __int8)pParty->uNumArenaKnightWins;
-        goto LABEL_40;
-      }
-      v12 = v11 - 1;
-      if ( !v12 )
-      {
-        v10 = (unsigned __int8)pParty->uNumArenaLordWins;
-        goto LABEL_40;
-      }
-      v13 = v12 - 12;
-      if ( !v13 )
-      {
-        v10 = pParty->field_874;
-        goto LABEL_40;
-      }
-      if ( v13 == 1 )
-      {
-        v10 = pParty->field_878;
-        goto LABEL_40;
-      }
-    }
-    else
-    {
-      if ( v5 == 89 )
-      {
-        v10 = (unsigned __int8)pParty->uNumArenaSquireWins;
-        goto LABEL_40;
-      }
-      v7 = v5 - 85;
-      if ( !v7 )
-      {
-        v10 = pParty->uNumDeaths;
-        goto LABEL_40;
-      }
-      v8 = v7 - 1;
-      if ( !v8 )
-      {
-        v10 = pParty->uNumBountiesCollected;
-        goto LABEL_40;
-      }
-      v9 = v8 - 1;
-      if ( !v9 )
-      {
-        v10 = pParty->uNumPrisonTerms;
-        goto LABEL_40;
-      }
-      if ( v9 == 1 )
-      {
-        v10 = (unsigned __int8)pParty->uNumArenaPageWins;
-LABEL_40:
-        v22 = v10;
-        goto LABEL_41;
-      }
-    }
-LABEL_41:
-    v17 = v22;
-    goto LABEL_42;
+
   }
   return;
 }
@@ -1205,7 +1200,8 @@
         v7 = pIcons_LOD->LoadTexture("ib-cd1-d", TEXTURE_16BIT_PALETTE);
         pTexture = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0);
         pButton = pCharacterScreen_StatsBtn;
-        break;
+        pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture);
+		break;
       case WINDOW_CharacterWindow_Skills:                                // skills
         if ( dword_507CC0 != uActiveCharacter )
         {
@@ -1217,7 +1213,8 @@
         v6 = pIcons_LOD->LoadTexture("ib-cd2-d", TEXTURE_16BIT_PALETTE);
         pTexture = (Texture *)(v6 != -1 ? (int)&pIcons_LOD->pTextures[v6] : 0);
         pButton = pCharacterScreen_SkillsBtn;
-        break;
+        pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture);
+		break;
       case WINDOW_CharacterWindow_Awards:                                // awards
         sub_4196A0();
         sub_419379();
@@ -1226,20 +1223,20 @@
         v5 = pIcons_LOD->LoadTexture("ib-cd4-d", TEXTURE_16BIT_PALETTE);
         pTexture = (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0);
         pButton = pCharacterScreen_AwardsBtn;
+		pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture);
         break;
-      default:                                                            // inventory and other
-        if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] != 103 )
-          goto LABEL_13;
+	  case WINDOW_CharacterWindow_Inventory:                                                        // inventory and other
         sub_4196A0();
         sub_419379();
         CharacterUI_InventoryTab_Draw(v1, 0);
         v2 = pIcons_LOD->LoadTexture("ib-cd3-d", TEXTURE_16BIT_PALETTE);
         pTexture = (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0);
         pButton = pCharacterScreen_InventoryBtn;
+		pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture);
         break;
+	  default:
+		break;
     }
-    pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture);
-LABEL_13:
     if ( bRingsShownInCharScreen )
       CharacterUI_DrawPaperdollWithRingOverlay(v1);
     else
@@ -1321,17 +1318,14 @@
     if ( v5 <= (signed int)(signed __int64)(0.34 * v6) )
     {
       v7 = uTextureID_mhp_red;
-LABEL_9:
       v9 = v7;
-      goto LABEL_10;
     }
-    if ( v5 <= (signed int)(signed __int64)(v6 * 0.67) )
+    else if ( v5 <= (signed int)(signed __int64)(v6 * 0.67) )
     {
       v7 = uTextureID_mhp_yel;
-      goto LABEL_9;
+      v9 = v7;
     }
   }
-LABEL_10:
   v8 = a2->uFrameX + (signed int)(a2->uFrameWidth - v4) / 2;
   pRenderer->Clip(v8, a2->uFrameY + 32, v8 + v4, a2->uFrameY + 52);
   pRenderer->DrawTextureIndexed(
@@ -1386,61 +1380,59 @@
   {
     v1 = &pParty->pPlayers[v16];
     v11 = v1;
-    if ( v1->sHealth <= 0 )
-      goto LABEL_24;
-    v11 = &pParty->pPlayers[v16];
-    v2 = (double)v1->sHealth;
-    v3 = v2 / (double)v1->GetMaxHealth();
-    if ( v3 <= 0.5 )
-    {
-      if ( v3 <= 0.25 )
-      {
-        if ( v3 <= 0.0 )
-          goto LABEL_24;
-        if ( v16 == 2 || v16 == 3 )
-          v17 = 2;
-        else
-          v17 = 0;
-        pRenderer->Clip(
-          v17 + pHealthBarPos[v16],
-          (unsigned __int64)(signed __int64)((1.0 - v3) * v15) + 402,
-          v17 + pHealthBarPos[v16] + v13->uTextureWidth,
-          v13->uTextureHeight + 402);
-        v9 = v13;
-      }
-      else
-      {
-        if ( v16 == 2 || v16 == 3 )
-          v17 = 2;
-        else
-          v17 = 0;
-        pRenderer->Clip(
-          v17 + pHealthBarPos[v16],
-          (unsigned __int64)(signed __int64)((1.0 - v3) * v15) + 402,
-          v17 + pHealthBarPos[v16] + v14->uTextureWidth,
-          v14->uTextureHeight + 402);
-        v9 = v14;
-      }
-    }
-    else
-    {
-      if ( v3 > 1.0 )
-        v3 = 1.0;
-      v4 = (signed __int64)((1.0 - v3) * v15);
-      if ( v16 == 2 || v16 == 3 )
-        v17 = 2;
-      else
-        v17 = 0;
-      pRenderer->Clip(
-        v17 + pHealthBarPos[v16],
-        v4 + 402,
-        v17 + pHealthBarPos[v16] + v0->uTextureWidth,
-        v0->uTextureHeight + 402);
-      v9 = v0;
-    }
-    pRenderer->DrawTextureIndexed(v17 + pHealthBarPos[v16], 0x192u, v9);
-    pRenderer->ResetClip();
-LABEL_24:
+    if ( v1->sHealth > 0 )
+	{
+		v11 = &pParty->pPlayers[v16];
+		v2 = (double)v1->sHealth;
+		v3 = v2 / (double)v1->GetMaxHealth();
+		if( v3 > 0.5 )
+		{
+		  if ( v3 > 1.0 )
+			v3 = 1.0;
+		  v4 = (signed __int64)((1.0 - v3) * v15);
+		  if ( v16 == 2 || v16 == 3 )
+			v17 = 2;
+		  else
+			v17 = 0;
+		  pRenderer->Clip(
+			v17 + pHealthBarPos[v16],
+			v4 + 402,
+			v17 + pHealthBarPos[v16] + v0->uTextureWidth,
+			v0->uTextureHeight + 402);
+		  v9 = v0;
+		}
+		else if ( v3 > 0.25 )
+		{
+			if ( v16 == 2 || v16 == 3 )
+			  v17 = 2;
+			else
+			  v17 = 0;
+			pRenderer->Clip(
+			  v17 + pHealthBarPos[v16],
+			  (unsigned __int64)(signed __int64)((1.0 - v3) * v15) + 402,
+			  v17 + pHealthBarPos[v16] + v14->uTextureWidth,
+			  v14->uTextureHeight + 402);
+			v9 = v14;
+		}
+		else if ( v3 > 0.0 )
+		{
+			if ( v16 == 2 || v16 == 3 )
+				v17 = 2;
+			else
+				v17 = 0;
+			pRenderer->Clip(
+				v17 + pHealthBarPos[v16],
+				(unsigned __int64)(signed __int64)((1.0 - v3) * v15) + 402,
+				v17 + pHealthBarPos[v16] + v13->uTextureWidth,
+				v13->uTextureHeight + 402);
+			v9 = v13;
+		}
+		if( v3 > 0.0 )
+		{
+		  pRenderer->DrawTextureIndexed(v17 + pHealthBarPos[v16], 0x192u, v9);
+		  pRenderer->ResetClip();
+		}
+	}
     v5 = v11;
     v12 = v11->sMana;
     if ( v12 > 0 )
@@ -1939,214 +1931,241 @@
   while ( 1 )
   {
     v3 = pVisibleWindowsIdxs[v27] - 1;
-    if ( pWindowList[v3].field_44 == v1 )
-      goto LABEL_47;
-    if ( v26 != 34 )
-      break;
-    if ( pWindowList[v3].field_30 != v1 )
-    {
-      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 )
-            goto LABEL_66;
-          ++v4;
-          if ( v4 >= v29 )
-          {
-LABEL_45:
-            v1 = 0;
-            goto LABEL_46;
-          }
-        }
-      }
-      goto LABEL_46;
-    }
-LABEL_47:
+    if ( pWindowList[v3].field_44 != v1 )
+	{
+		switch(v26)
+		{
+			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, v1, v1, -1, v1, v1, v1, v1);
+					v2 = pMessageQueue_50CBD0->uNumMessages;
+				  }
+				}
+				if ( pWindowList[v3].field_30 != v1 )
+				{
+					break;
+				}
+				v9 = pWindowList[v3].pControlsHead;
+				v13 = pWindowList[v3].pCurrentPosActiveItem;
+				if ( v13 > (signed int)v1 )
+				{
+				  do
+				  {
+					v9 = v9->pNext;
+					--v13;
+				  }
+				  while ( v13 );
+				}
+				v11 = v9->uControlParam;
+				/*if ( (signed int)v2 < 40 )
+				{
+				  pMessageQueue_50CBD0->pMessages[v2].eType = (UIMessageType)v9->uControlID;
+				  pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v11;
+				  *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = v1;
+				  v2 = pMessageQueue_50CBD0->uNumMessages + 1;
+				  ++pMessageQueue_50CBD0->uNumMessages;
+				}*/
+				pMessageQueue_50CBD0->AddMessage((UIMessageType)v9->uControlID, v11, v1);
+				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, v1, v1, -1, v1, v1, v1, v1);
+						v2 = pMessageQueue_50CBD0->uNumMessages;
+					}
+				}
+				if ( pWindowList[v3].field_30 != v1 )
+				{
+					break;
+				}
+				v9 = pWindowList[v3].pControlsHead;
+				v10 = pWindowList[v3].pCurrentPosActiveItem;
+				if ( v10 > (signed int)v1 )
+				{
+					do
+					{
+						v9 = v9->pNext;
+						--v10;
+					}
+					while ( v10 );
+				}
+				v11 = v9->uControlParam;
+				pMessageQueue_50CBD0->AddMessage((UIMessageType)v9->uControlID, v11, v1);
+				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 != v1 )
+					return 1;
+				v19 = pWindowList[v3].pControlsHead;
+				v20 = pWindowList[v3].pCurrentPosActiveItem;
+				if ( v20 > (signed int)v1 )
+				{
+					do
+					{
+						v19 = v19->pNext;
+						--v20;
+					}
+					while ( v20 );
+				}
+				v21 = v19->uControlParam;
+				pMessageQueue_50CBD0->AddMessage((UIMessageType)v19->uControlID, v21, v1);
+				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;
+							--v27;
+							if ( v27 < 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 == v1;
+				pWindowList[v3].pCurrentPosActiveItem = v24;
+				if ( !v8 )
+					return 1;
+				v19 = pWindowList[v3].pControlsHead;
+				v25 = pWindowList[v3].pCurrentPosActiveItem;
+				if ( v25 > (signed int)v1 )
+				{
+					do
+					{
+						v19 = v19->pNext;
+						--v25;
+					}
+					while ( v25 );
+				}
+				v21 = v19->uControlParam;
+				/*if ( (signed int)v2 < 40 )
+				{
+				pMessageQueue_50CBD0->pMessages[v2].eType = (UIMessageType)v19->uControlID;
+				pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v21;
+				*(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = v1;
+				++pMessageQueue_50CBD0->uNumMessages;
+				}*/
+				pMessageQueue_50CBD0->AddMessage((UIMessageType)v19->uControlID, v21, v1);
+				return 1;
+				}
+			case VK_NEXT:
+				{
+				if ( pWindowList[v3].field_30 != v1 )
+				{
+					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;
+				}
+			
+		}
+	}
     --v27;
     if ( v27 < 0 )
       return 0;
   }
-  if ( v26 == 37 )
-  {
-    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, v1, v1, -1, v1, v1, v1, v1);
-        v2 = pMessageQueue_50CBD0->uNumMessages;
-      }
-    }
-    if ( pWindowList[v3].field_30 != v1 )
-      goto LABEL_47;
-    v9 = pWindowList[v3].pControlsHead;
-    v13 = pWindowList[v3].pCurrentPosActiveItem;
-    if ( v13 > (signed int)v1 )
-    {
-      do
-      {
-        v9 = v9->pNext;
-        --v13;
-      }
-      while ( v13 );
-    }
-LABEL_26:
-    v11 = v9->uControlParam;
-    /*if ( (signed int)v2 < 40 )
-    {
-      pMessageQueue_50CBD0->pMessages[v2].eType = (UIMessageType)v9->uControlID;
-      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v11;
-      *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = v1;
-      v2 = pMessageQueue_50CBD0->uNumMessages + 1;
-      ++pMessageQueue_50CBD0->uNumMessages;
-    }*/
-    pMessageQueue_50CBD0->AddMessage((UIMessageType)v9->uControlID, v11, v1);
-    goto LABEL_47;
-  }
-  if ( v26 != 38 )
-  {
-    if ( v26 == 39 )
-    {
-      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, v1, v1, -1, v1, v1, v1, v1);
-          v2 = pMessageQueue_50CBD0->uNumMessages;
-        }
-      }
-      if ( pWindowList[v3].field_30 != v1 )
-        goto LABEL_47;
-      v9 = pWindowList[v3].pControlsHead;
-      v10 = pWindowList[v3].pCurrentPosActiveItem;
-      if ( v10 > (signed int)v1 )
-      {
-        do
-        {
-          v9 = v9->pNext;
-          --v10;
-        }
-        while ( v10 );
-      }
-      goto LABEL_26;
-    }
-    if ( v26 == 40 )
-    {
-      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 != v1 )
-        return 1;
-      v19 = pWindowList[v3].pControlsHead;
-      v20 = pWindowList[v3].pCurrentPosActiveItem;
-      if ( v20 > (signed int)v1 )
-      {
-        do
-        {
-          v19 = v19->pNext;
-          --v20;
-        }
-        while ( v20 );
-      }
-      goto LABEL_56;
-    }
-    if ( v26 == 41 )
-    {
-      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 )
-            goto LABEL_45;
-        }
-LABEL_66:
-        pWindowList[v3].pCurrentPosActiveItem = v4;
-        return 1;
-      }
-LABEL_46:
-      v2 = pMessageQueue_50CBD0->uNumMessages;
-      goto LABEL_47;
-    }
-    goto LABEL_47;
-  }
-  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 == v1;
-  pWindowList[v3].pCurrentPosActiveItem = v24;
-  if ( !v8 )
-    return 1;
-  v19 = pWindowList[v3].pControlsHead;
-  v25 = pWindowList[v3].pCurrentPosActiveItem;
-  if ( v25 > (signed int)v1 )
-  {
-    do
-    {
-      v19 = v19->pNext;
-      --v25;
-    }
-    while ( v25 );
-  }
-LABEL_56:
-  v21 = v19->uControlParam;
-  /*if ( (signed int)v2 < 40 )
-  {
-    pMessageQueue_50CBD0->pMessages[v2].eType = (UIMessageType)v19->uControlID;
-    pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v21;
-    *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = v1;
-    ++pMessageQueue_50CBD0->uNumMessages;
-  }*/
-  pMessageQueue_50CBD0->AddMessage((UIMessageType)v19->uControlID, v21, v1);
-  return 1;
+
 }
 
 //----- (0041D20D) --------------------------------------------------------
@@ -2416,7 +2435,13 @@
       v18 = v17 >> 1;
       v19 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x19u, 0x19u);
       wHintWindow.DrawTitleText(pFontArrus, 0x64u, ((signed int)wHintWindow.uFrameHeight >> 1) - v18, v19, pGlobalTXT_LocalizationStrings[32], 3); //"Broken Item"
-       goto LABEL_116;
+      pRenderer->ResetClip();
+      if ( !areWeLoadingTexture )
+        {
+        v73->Release();
+        pIcons_LOD->_40F9C5();
+        }
+      return;
     }
     if (!inspect_item->Identified())
     {
@@ -2434,7 +2459,13 @@
       v18 = v17 >> 1;
       v19 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x19u, 0x19u);
       wHintWindow.DrawTitleText(pFontArrus, 0x64u, ((signed int)wHintWindow.uFrameHeight >> 1) - v18, v19, pGlobalTXT_LocalizationStrings[232], 3);
-      goto LABEL_116;
+      pRenderer->ResetClip();
+      if ( !areWeLoadingTexture )
+          {
+          v73->Release();
+          pIcons_LOD->_40F9C5();
+          }
+      return;
     }
 
     sprintfex(out_text, pGlobalTXT_LocalizationStrings[463], item_desc->pUnidentifiedName); //"Type: %s"
@@ -2479,37 +2510,35 @@
         if (item_desc->uDamageDice) //"Armor"	
           sprintfex(out_text + 100, "%s: +%d", pGlobalTXT_LocalizationStrings[11], item_desc->uDamageDice + item_desc->uDamageMod);
       break;
-      
+      case EQUIP_POTION:
+          if ( inspect_item->uEncantmentType )
+              sprintf(out_text + 200,  "%s: %d",pGlobalTXT_LocalizationStrings[449] , inspect_item->uEncantmentType); //"Power"
+          break;
+      case EQUIP_REAGENT:
+         sprintf(out_text + 200, "%s: %d", pGlobalTXT_LocalizationStrings[449], pItemsTable->pItems[inspect_item->uItemID].uDamageDice); //"Power"
+         break;
     }
 
-    if ( v77 )
-      goto LABEL_65;
-    if  (item_desc->uEquipType==EQUIP_POTION)
-        {        
-        if ( inspect_item->uEnchantmentType )
-            sprintf(out_text + 200,  "%s: %d",pGlobalTXT_LocalizationStrings[449] , inspect_item->uEnchantmentType); //"Power"
-        }
-    else if  (item_desc->uEquipType== EQUIP_REAGENT)
-        {sprintf(out_text + 200, "%s: %d", pGlobalTXT_LocalizationStrings[449], pItemsTable->pItems[inspect_item->uItemID].uDamageDice); //"Power"
-        }
-    else if ( inspect_item->uEnchantmentType )
-     {
-        sprintf(out_text + 200, "%s: %s +%d", pGlobalTXT_LocalizationStrings[210],
-             pItemsTable->pEnchantments[inspect_item->uEnchantmentType-1].pBonusStat, inspect_item->_bonus_strength); //"Special"
-    }
-    else  if ( inspect_item->uSpecEnchantmentType )
-      {      
-        sprintf(out_text + 200, "%s: %s", pGlobalTXT_LocalizationStrings[210], 
-            pItemsTable->pSpecialEnchantments[inspect_item->uSpecEnchantmentType-1].pBonusStatement, inspect_item->_bonus_strength);
-      }
+    if ( !v77 )
+	{
+    //v23 = item_desc->uEquipType;
+		if ( inspect_item->uEncantmentType )
+		 {
+			sprintf(out_text + 200, "%s: %s +%d", pGlobalTXT_LocalizationStrings[210],
+				 pItemsTable->pEnchantments[inspect_item->uEncantmentType-1].pBonusStat, inspect_item->_bonus_strength); //"Special"
+		}
+		else  if ( inspect_item->uSpecEnchantmentType )
+		  {      
+			sprintf(out_text + 200, "%s: %s", pGlobalTXT_LocalizationStrings[210], 
+				pItemsTable->pSpecialEnchantments[inspect_item->uSpecEnchantmentType-1].pBonusStatement, inspect_item->_bonus_strength);
+		  }
     
-    else if ( inspect_item->uNumCharges )
-        {
-        sprintf(out_text + 200, "%s: %lu", pGlobalTXT_LocalizationStrings[464], inspect_item->uNumCharges); //"Charges"
-
-        }
-
-LABEL_65:
+		else if ( inspect_item->uNumCharges )
+			{
+			sprintf(out_text + 200, "%s: %lu", pGlobalTXT_LocalizationStrings[464], inspect_item->uNumCharges); //"Charges"
+
+			}
+	}
     wHintWindow.uFrameWidth -= 12;
     v85 = 3;
     wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1;
@@ -2536,7 +2565,7 @@
         wHintWindow.uFrameHeight = v73->uTextureHeight + v81 + 54;
         if ( (signed int)Str > (signed int)wHintWindow.uFrameHeight )
             wHintWindow.uFrameHeight = (unsigned int)Str;
-        if ( inspect_item->uAttributes & 8 && (inspect_item->uSpecEnchantmentType || inspect_item->uEnchantmentType) )
+        if ( inspect_item->uAttributes & 8 && (inspect_item->uSpecEnchantmentType || inspect_item->uEncantmentType) )
             wHintWindow.uFrameHeight += LOBYTE(pFontComic->uFontHeight);
         v85 = 0;
         if ( pFontArrus->uFontHeight )
@@ -2604,7 +2633,7 @@
                 }
             else
                 {
-                if ( (inspect_item->uAttributes & 8) && (inspect_item->uSpecEnchantmentType || inspect_item->uEnchantmentType) )
+                if ( (inspect_item->uAttributes & 8) && (inspect_item->uSpecEnchantmentType || inspect_item->uEncantmentType) )
                     {
                     sub_493F79(&v67, inspect_item->uExpireTime - pParty->uTimePlayed);
                     strcpy(pTmpBuf, "Duration:");
@@ -2643,7 +2672,15 @@
                 else
                     {
                     if ( !(BYTE1(v38) & 2) )
-                        goto LABEL_116;
+					{
+						pRenderer->ResetClip();
+						if ( !areWeLoadingTexture )
+							{
+							v73->Release();
+							pIcons_LOD->_40F9C5();
+							}
+						return;
+					}
                     v61 = 0;
                     v56 = 0;
                     v51 = 0;
@@ -2657,7 +2694,6 @@
                 v41 = v39 + 132;
                 }
             wHintWindow.DrawText(v40, v41, v42, v44, v47, v51, v56, v61);
-LABEL_116:
             pRenderer->ResetClip();
             if ( !areWeLoadingTexture )
                 {
@@ -3156,132 +3192,139 @@
     v74 = 0;
     v69 = 0;
     v66 = pGlobalTXT_LocalizationStrings[630];
-    goto LABEL_123;
+    a1->DrawText((GUIFont *)a2, 28, v50, a5, v66, v69, v74, v78);
   }
-  a4 = 0;
-  v51 = &v121->pActorBuffs[1];
-  v222 = 0;
-  v120 = &v121->pActorBuffs[1];
-  do
+  else
   {
-    if ( (signed __int64)v51->uExpireTime > 0 )
-    {
-      switch ( (int)v51 )
-      {
-        case 0u:
-          v124 = 60;
-          a4 = pGlobalTXT_LocalizationStrings[591];
-          break;
-        case 1u:
-          v124 = 82;
-          a4 = pGlobalTXT_LocalizationStrings[649];
-          break;
-        case 2u:
-          v124 = 92;
-          a4 = pGlobalTXT_LocalizationStrings[592];
-          break;
-        case 3u:
-          v124 = 63;
-          a4 = pGlobalTXT_LocalizationStrings[4];
-          break;
-        case 4u:
-          v52 = pGlobalTXT_LocalizationStrings[220];
-          goto LABEL_100;
-        case 5u:
-          v52 = pGlobalTXT_LocalizationStrings[162];
-LABEL_100:
-          a4 = v52;
-          v124 = 81;
-          break;
-        case 6u:
-          v53 = pGlobalTXT_LocalizationStrings[593];
-          v124 = 35;
-          goto LABEL_103;
-        case 8u:
-          v53 = pGlobalTXT_LocalizationStrings[608];
-          v124 = 62;
-LABEL_103:
-          a4 = v53;
-          break;
-        case 7u:
-        case 9u:
-          a4 = 0;
-          v124 = 0;
-          goto LABEL_119;
-        case 0xAu:
-          v124 = 47;
-          a4 = pGlobalTXT_LocalizationStrings[221];
-          break;
-        case 0xBu:
-          v124 = 66;
-          a4 = pGlobalTXT_LocalizationStrings[607];
-          break;
-        case 0xCu:
-          v124 = 85;
-          a4 = pGlobalTXT_LocalizationStrings[610];
-          break;
-        case 0xDu:
-          v124 = 86;
-          a4 = pGlobalTXT_LocalizationStrings[609];
-          break;
-        case 0xEu:
-          v124 = 17;
-          a4 = pGlobalTXT_LocalizationStrings[279];
-          break;
-        case 0xFu:
-          v124 = 38;
-          a4 = pGlobalTXT_LocalizationStrings[442];
-          break;
-        case 0x10u:
-          v124 = 46;
-          a4 = pGlobalTXT_LocalizationStrings[443];
-          break;
-        case 0x11u:
-          v124 = 51;
-          a4 = pGlobalTXT_LocalizationStrings[440];
-          break;
-        case 0x12u:
-          v124 = 5;
-          a4 = pGlobalTXT_LocalizationStrings[441];
-          break;
-        case 0x13u:
-          v124 = 95;
-          a4 = pGlobalTXT_LocalizationStrings[229];
-          break;
-        case 0x14u:
-          v124 = 73;
-          a4 = pGlobalTXT_LocalizationStrings[228];
-          break;
-        default:
-          a4 = 0;
-          break;
-      }
-      if ( a4 )
-      {
-        v54 = a4;
-        v55 = GetSpellColor(v124);
-        a1->DrawText((GUIFont *)a2, 28, v50, v55, v54, 0, 0, 0);
-        v50 = v50 + BYTE5(a2->pConditions[0]) - 3;
-        v51 = v120;
-      }
-    }
-LABEL_119:
-    ++v51;
-    v222 = (IDirectDrawSurface *)((char *)v222 + 1);
-    v120 = v51;
-
-    __debugbreak(); // fix condition
-  }
-  //while ( (signed int)((char *)&v222->lpVtbl + 1) < 22 );
-  while (true);
-  if ( !a4 )
-  {
-    v78 = 0;
-    v74 = 0;
-    v69 = 0;
-    v66 = pGlobalTXT_LocalizationStrings[153];
-LABEL_123:
-    a1->DrawText((GUIFont *)a2, 28, v50, a5, v66, v69, v74, v78);
+	  a4 = 0;
+	  v51 = &v121->pActorBuffs[1];
+	  v222 = 0;
+	  v120 = &v121->pActorBuffs[1];
+	  do
+	  {
+		if ( (signed __int64)v51->uExpireTime > 0 )
+		{
+		  switch ( (int)v51 )
+		  {
+			case 0u:
+			  v124 = 60;
+			  a4 = pGlobalTXT_LocalizationStrings[591];
+			  break;
+			case 1u:
+			  v124 = 82;
+			  a4 = pGlobalTXT_LocalizationStrings[649];
+			  break;
+			case 2u:
+			  v124 = 92;
+			  a4 = pGlobalTXT_LocalizationStrings[592];
+			  break;
+			case 3u:
+			  v124 = 63;
+			  a4 = pGlobalTXT_LocalizationStrings[4];
+			  break;
+			case 4u:
+			  v52 = pGlobalTXT_LocalizationStrings[220];
+			  a4 = v52;
+			  v124 = 81;
+			  break;
+			case 5u:
+			  v52 = pGlobalTXT_LocalizationStrings[162];
+			  a4 = v52;
+			  v124 = 81;
+			  break;
+			case 6u:
+			  v53 = pGlobalTXT_LocalizationStrings[593];
+			  v124 = 35;
+			  a4 = v53;
+			  break;
+			case 8u:
+			  v53 = pGlobalTXT_LocalizationStrings[608];
+			  v124 = 62;
+			  a4 = v53;
+			  break;
+			case 7u:
+			case 9u:
+			  a4 = 0;
+			  v124 = 0;
+			  ++v51;
+			  v222 = (IDirectDrawSurface *)((char *)v222 + 1);
+			  v120 = v51;
+			  __debugbreak(); // fix condition
+			  continue;
+			case 0xAu:
+			  v124 = 47;
+			  a4 = pGlobalTXT_LocalizationStrings[221];
+			  break;
+			case 0xBu:
+			  v124 = 66;
+			  a4 = pGlobalTXT_LocalizationStrings[607];
+			  break;
+			case 0xCu:
+			  v124 = 85;
+			  a4 = pGlobalTXT_LocalizationStrings[610];
+			  break;
+			case 0xDu:
+			  v124 = 86;
+			  a4 = pGlobalTXT_LocalizationStrings[609];
+			  break;
+			case 0xEu:
+			  v124 = 17;
+			  a4 = pGlobalTXT_LocalizationStrings[279];
+			  break;
+			case 0xFu:
+			  v124 = 38;
+			  a4 = pGlobalTXT_LocalizationStrings[442];
+			  break;
+			case 0x10u:
+			  v124 = 46;
+			  a4 = pGlobalTXT_LocalizationStrings[443];
+			  break;
+			case 0x11u:
+			  v124 = 51;
+			  a4 = pGlobalTXT_LocalizationStrings[440];
+			  break;
+			case 0x12u:
+			  v124 = 5;
+			  a4 = pGlobalTXT_LocalizationStrings[441];
+			  break;
+			case 0x13u:
+			  v124 = 95;
+			  a4 = pGlobalTXT_LocalizationStrings[229];
+			  break;
+			case 0x14u:
+			  v124 = 73;
+			  a4 = pGlobalTXT_LocalizationStrings[228];
+			  break;
+			default:
+			  a4 = 0;
+			  break;
+		  }
+		  if ( a4 )
+		  {
+			v54 = a4;
+			v55 = GetSpellColor(v124);
+			a1->DrawText((GUIFont *)a2, 28, v50, v55, v54, 0, 0, 0);
+			v50 = v50 + BYTE5(a2->pConditions[0]) - 3;
+			v51 = v120;
+		  }
+		}
+
+		++v51;
+		v222 = (IDirectDrawSurface *)((char *)v222 + 1);
+		v120 = v51;
+
+		__debugbreak(); // fix condition
+	  }
+	  //while ( (signed int)((char *)&v222->lpVtbl + 1) < 22 );
+	  while (true);
+	  if ( !a4 )
+	  {
+		v78 = 0;
+		v74 = 0;
+		v69 = 0;
+		v66 = pGlobalTXT_LocalizationStrings[153];
+		a1->DrawText((GUIFont *)a2, 28, v50, a5, v66, v69, v74, v78);
+	  }
   }
   v56 = pFontSmallnum;
   a4 = (char *)v106.uViewportY;
@@ -3348,42 +3391,47 @@
     v76 = 0;
     v71 = pGlobalTXT_LocalizationStrings[628];
     v68 = "%s\f%05u\t080%s\n";
-    goto LABEL_144;
-  }
-  v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[628];
-  v59 = v121;
-  v114 = v121->pMonsterInfo.uSpell1ID;
-  if ( v114 && v121->pMonsterInfo.uSpell2ID )
-    v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[629];
-  if ( v114 )
-  {
-    sprintf(pTmpBuf, "%s\f%05u\t060%s\n", v120, 0, pSpellStats->pInfos[v114].pShortName);
-    a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
-    v58 = LOBYTE(v56->uFontHeight);
-    a4 = &a4[v58 - 3];
-    v59 = v121;
-  }
-  v60 = v59->pMonsterInfo.uSpell2ID;
-  if ( v60 )
-  {
-    sprintf(pTmpBuf, "\f%05u\t060%s\n", 0, pSpellStats->pInfos[v60].pShortName);
-    a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
-    v58 = LOBYTE(v56->uFontHeight);
-    a4 = &a4[v58 - 3];
-    v59 = v121;
-  }
-  if ( !v59->pMonsterInfo.uSpell1ID && !v59->pMonsterInfo.uSpell2ID )
-  {
-    v80 = pGlobalTXT_LocalizationStrings[153];
-    v76 = 0;
-    v71 = pGlobalTXT_LocalizationStrings[628];
-    v68 = "%s\f%05u\t060%s\n";
-LABEL_144:
     sprintf(pTmpBuf, v68, v71, v76, v80);
     a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
     v58 = LOBYTE(v56->uFontHeight);
     a4 = &a4[v58 - 3];
   }
+  else
+  {
+	  v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[628];
+	  v59 = v121;
+	  v114 = v121->pMonsterInfo.uSpell1ID;
+	  if ( v114 && v121->pMonsterInfo.uSpell2ID )
+		v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[629];
+	  if ( v114 )
+	  {
+		sprintf(pTmpBuf, "%s\f%05u\t060%s\n", v120, 0, pSpellStats->pInfos[v114].pShortName);
+		a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
+		v58 = LOBYTE(v56->uFontHeight);
+		a4 = &a4[v58 - 3];
+		v59 = v121;
+	  }
+	  v60 = v59->pMonsterInfo.uSpell2ID;
+	  if ( v60 )
+	  {
+		sprintf(pTmpBuf, "\f%05u\t060%s\n", 0, pSpellStats->pInfos[v60].pShortName);
+		a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
+		v58 = LOBYTE(v56->uFontHeight);
+		a4 = &a4[v58 - 3];
+		v59 = v121;
+	  }
+	  if ( !v59->pMonsterInfo.uSpell1ID && !v59->pMonsterInfo.uSpell2ID )
+	  {
+		v80 = pGlobalTXT_LocalizationStrings[153];
+		v76 = 0;
+		v71 = pGlobalTXT_LocalizationStrings[628];
+		v68 = "%s\f%05u\t060%s\n";
+		sprintf(pTmpBuf, v68, v71, v76, v80);
+		a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
+		v58 = LOBYTE(v56->uFontHeight);
+		a4 = &a4[v58 - 3];
+	  }
+  }
   a4 = &a4[v58 - 3];
   a1->DrawText(v56, 150, (int)a4, a5, pGlobalTXT_LocalizationStrings[626], 0, 0, 0);
   a4 = &a4[LOBYTE(v56->uFontHeight) - 3];
@@ -4286,9 +4334,131 @@
     return;
   }
   v1 = uNumVisibleWindows;
-  if ( uNumVisibleWindows <= 0 )
+  if ( uNumVisibleWindows > 0 )
   {
-LABEL_38:
+	  while ( 1 )                                   // some other fullscreen ui
+	  {
+		pWindow = &pWindowList[pVisibleWindowsIdxs[v1] - 1];
+		if ( (signed int)pX >= (signed int)pWindow->uFrameX
+		  && (signed int)pX <= (signed int)pWindow->uFrameZ
+		  && (signed int)pY >= (signed int)pWindow->uFrameY
+		  && (signed int)pY <= (signed int)pWindow->uFrameW )
+		{
+		  for ( pButton = pWindow->pControlsHead; ; pButton = pButton->pNext )
+		  {
+			if ( !pButton )
+			  break;
+			if ( pButton->uButtonType == 1 )
+			{
+			  if ( (signed int)pX >= (signed int)pButton->uX
+				&& (signed int)pX <= (signed int)pButton->uZ
+				&& (signed int)pY >= (signed int)pButton->uY
+				&& (signed int)pY <= (signed int)pButton->uW )
+			  {
+	//LABEL_24:
+				pMessageType1 = (UIMessageType)pButton->field_1C;
+				if ( pMessageType1 )
+				{
+				  v12 = pButton->uControlParam;
+				  pMessageQueue_50CBD0->AddMessage(pMessageType1, v12, 0);
+				  /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+				  {
+					pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = pMessageType1;
+					pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v12;
+					*(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+	//LABEL_27:
+					++pMessageQueue_50CBD0->uNumMessages;
+				  }*/
+				}
+	//LABEL_28:
+				v13 = pButton->pButtonName;
+	//_set_status_and_ret:
+				sub_41C0B8_set_status_string(v13);
+	//LABEL_131:
+				uLastPointedObjectID = 1;
+				return;
+			  }
+			}
+			else
+			{
+			  if ( pButton->uButtonType == 2 )
+			  {
+				v45 = pX - pButton->uX;
+				v45 = pY - pButton->uY;
+				if ( (double)(signed int)pButton->uWidth != 0.0 )
+				{
+				  if ( (double)(signed int)pButton->uHeight != 0.0 )
+				  {
+					//UNDEF(v8);
+					//if ( v9 | v10 )
+					  //goto LABEL_24;
+					//{
+					  pMessageType1 = (UIMessageType)pButton->field_1C;
+					  if ( pMessageType1 )
+					  {
+						v12 = pButton->uControlParam;
+						pMessageQueue_50CBD0->AddMessage(pMessageType1, v12, 0);
+						/*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+						{
+						  pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = pMessageType1;
+						  pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v12;
+						  *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+						  ++pMessageQueue_50CBD0->uNumMessages;
+						}*/
+					  }
+					  v13 = pButton->pButtonName;
+					  sub_41C0B8_set_status_string(v13);
+					  uLastPointedObjectID = 1;
+					  return;
+					//}
+				  }
+				}
+			  }
+			  else                                  // click on skill
+			  {
+				if ( pButton->uButtonType == 3
+				  && (signed int)pX >= (signed int)pButton->uX
+				  && (signed int)pX <= (signed int)pButton->uZ
+				  && (signed int)pY >= (signed int)pButton->uY
+				  && (signed int)pY <= (signed int)pButton->uW )
+				{
+	//LABEL_19:
+				  pPlayer = pPlayers[uActiveCharacter];
+				  v5 = LOBYTE(pPlayer->pActiveSkills[pButton->uControlParam]);
+				  v6 = pPlayer->uSkillPoints;
+				  v7 = (v5 & 0x3F) + 1;
+				  if ( v6 < v7 )
+				  {
+					v41 = v7 - v6;
+					v39 = pGlobalTXT_LocalizationStrings[469];// "You need %d more Skill Points to advance here"
+				  }
+				  else
+				  {
+					v41 = v7;
+					v39 = pGlobalTXT_LocalizationStrings[468];// "Clicking here will spend %d Skill Points"
+				  }
+				  sprintf(Str1, v39, v41);
+				  v13 = Str1;
+				  //goto _set_status_and_ret;
+				  sub_41C0B8_set_status_string(v13);
+				  uLastPointedObjectID = 1;
+				  return;
+				}
+			  }
+			}
+		  }
+		}
+		if ( pWindow->uFrameHeight == 480 )
+		  break;
+		--v1;
+		if ( v1 <= 0 )
+		{
+		  break;
+		}
+	  }
+  }
+  if ( uNumVisibleWindows <= 0 || (uNumVisibleWindows > 0 && pWindow->uFrameHeight != 480 && v1 <= 0))
+  {
     if ( pCurrentScreen == SCREEN_CHEST )
     {
       sub_42038D();
@@ -4501,126 +4671,6 @@
     uLastPointedObjectID = pMouse->uPointingObjectID;
     return;
   }
-  while ( 1 )                                   // some other fullscreen ui
-  {
-    pWindow = &pWindowList[pVisibleWindowsIdxs[v1] - 1];
-    if ( (signed int)pX >= (signed int)pWindow->uFrameX
-      && (signed int)pX <= (signed int)pWindow->uFrameZ
-      && (signed int)pY >= (signed int)pWindow->uFrameY
-      && (signed int)pY <= (signed int)pWindow->uFrameW )
-    {
-      for ( pButton = pWindow->pControlsHead; ; pButton = pButton->pNext )
-      {
-        if ( !pButton )
-          break;
-        if ( pButton->uButtonType == 1 )
-        {
-          if ( (signed int)pX >= (signed int)pButton->uX
-            && (signed int)pX <= (signed int)pButton->uZ
-            && (signed int)pY >= (signed int)pButton->uY
-            && (signed int)pY <= (signed int)pButton->uW )
-          {
-//LABEL_24:
-            pMessageType1 = (UIMessageType)pButton->field_1C;
-            if ( pMessageType1 )
-            {
-              v12 = pButton->uControlParam;
-              pMessageQueue_50CBD0->AddMessage(pMessageType1, v12, 0);
-              /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-              {
-                pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = pMessageType1;
-                pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v12;
-                *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-//LABEL_27:
-                ++pMessageQueue_50CBD0->uNumMessages;
-              }*/
-            }
-//LABEL_28:
-            v13 = pButton->pButtonName;
-//_set_status_and_ret:
-            sub_41C0B8_set_status_string(v13);
-//LABEL_131:
-            uLastPointedObjectID = 1;
-            return;
-          }
-        }
-        else
-        {
-          if ( pButton->uButtonType == 2 )
-          {
-            v45 = pX - pButton->uX;
-            v45 = pY - pButton->uY;
-            if ( (double)(signed int)pButton->uWidth != 0.0 )
-            {
-              if ( (double)(signed int)pButton->uHeight != 0.0 )
-              {
-                //UNDEF(v8);
-                //if ( v9 | v10 )
-                  //goto LABEL_24;
-                //{
-                  pMessageType1 = (UIMessageType)pButton->field_1C;
-                  if ( pMessageType1 )
-                  {
-                    v12 = pButton->uControlParam;
-                    pMessageQueue_50CBD0->AddMessage(pMessageType1, v12, 0);
-                    /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-                    {
-                      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = pMessageType1;
-                      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v12;
-                      *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-                      ++pMessageQueue_50CBD0->uNumMessages;
-                    }*/
-                  }
-                  v13 = pButton->pButtonName;
-                  sub_41C0B8_set_status_string(v13);
-                  uLastPointedObjectID = 1;
-                  return;
-                //}
-              }
-            }
-          }
-          else                                  // click on skill
-          {
-            if ( pButton->uButtonType == 3
-              && (signed int)pX >= (signed int)pButton->uX
-              && (signed int)pX <= (signed int)pButton->uZ
-              && (signed int)pY >= (signed int)pButton->uY
-              && (signed int)pY <= (signed int)pButton->uW )
-            {
-//LABEL_19:
-              pPlayer = pPlayers[uActiveCharacter];
-              v5 = LOBYTE(pPlayer->pActiveSkills[pButton->uControlParam]);
-              v6 = pPlayer->uSkillPoints;
-              v7 = (v5 & 0x3F) + 1;
-              if ( v6 < v7 )
-              {
-                v41 = v7 - v6;
-                v39 = pGlobalTXT_LocalizationStrings[469];// "You need %d more Skill Points to advance here"
-              }
-              else
-              {
-                v41 = v7;
-                v39 = pGlobalTXT_LocalizationStrings[468];// "Clicking here will spend %d Skill Points"
-              }
-              sprintf(Str1, v39, v41);
-              v13 = Str1;
-              //goto _set_status_and_ret;
-              sub_41C0B8_set_status_string(v13);
-              uLastPointedObjectID = 1;
-              return;
-            }
-          }
-        }
-      }
-    }
-    if ( pWindow->uFrameHeight == 480 )
-      break;
-    --v1;
-    if ( v1 <= 0 )
-    {
-      goto LABEL_38;
-    }
-  }
 }
 
 
@@ -4842,14 +4892,13 @@
 
     if (!player->CanAct())
     {
-      if ( pPlayers[uActiveCharacter]->CanAct())
-        goto LABEL_9;
       player = pPlayers[uActiveCharacter];
     }
-    player->PlaySound(SPEECH_NoRoom, 0);
+    if(playerCanAct() || !pPlayers[uActiveCharacter]->CanAct())
+		player->PlaySound(SPEECH_NoRoom, 0);
   }
 
-LABEL_9:
+//LABEL_9:
   if (pCurrentScreen == SCREEN_GAME)
   {
     viewparams->bRedrawGameUI = true;
@@ -5009,7 +5058,8 @@
           memcpy(&pParty->pPickedItem, &v0->pInventoryItems[v8-1], sizeof(pParty->pPickedItem));
           v0->RemoveItemAtInventoryIndex(a4);
           v9 = pParty->pPickedItem.uItemID;
-          goto LABEL_24;
+          pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName);
+          return;
         }
         v13 = v8;
         if ( v8 )
@@ -5030,7 +5080,6 @@
           }
           v9 = this_.uItemID;
           memcpy(&pParty->pPickedItem, &this_, sizeof(pParty->pPickedItem));
-LABEL_24:
           pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName);
           return;
         }
@@ -5116,7 +5165,10 @@
       SpriteObject::OnInteraction(a2.y);
       return;
     }
-    goto LABEL_13;
+    v4 = pParty->pPickedItem.uItemID;
+    if ( !pParty->pPickedItem.uItemID )
+		return;
+    goto LABEL_14;
   }
   if ( (v0 & 7) != OBJECT_Actor)
   {
@@ -5124,7 +5176,12 @@
     {
       v13 = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3];
       if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[v13->uDecorationDescID].uRadius) >= 512 )
-        goto LABEL_13;
+	  {
+          v4 = pParty->pPickedItem.uItemID;
+          if ( !pParty->pPickedItem.uItemID )
+            return;
+          goto LABEL_14;
+	  }
       v14 = v13->field_16_event_id;
       if ( !v14 )
       {
@@ -5142,7 +5199,12 @@
     else
     {
       if ( (v0 & 7) != OBJECT_BModel || (unsigned int)v0 >= 0x2000000 )
-        goto LABEL_13;
+	  {
+          v4 = pParty->pPickedItem.uItemID;
+          if ( !pParty->pPickedItem.uItemID )
+            return;
+          goto LABEL_14;
+	  }
       v2 = (signed int)(unsigned __int16)v0 >> 3;
       if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
       {
@@ -5150,61 +5212,61 @@
         if ( !(v3->uAttributes & 0x2000000) )
         {
 LABEL_11:
-          v4 = pParty->pPickedItem.uItemID;
-          if ( pParty->pPickedItem.uItemID )
-          {
+			v4 = pParty->pPickedItem.uItemID;
+			if ( !pParty->pPickedItem.uItemID )
+			{
+				ShowNothingHereStatus();
+				v4 = pParty->pPickedItem.uItemID;
+				if ( !pParty->pPickedItem.uItemID )
+					return;
+			}
 LABEL_14:
-            v5 = pItemsTable->pItems[v4].uSpriteID;
-            v6 = 0;
-            a1.uType = v5;
-            if ( (signed int)pObjectList->uNumObjects <= 0 )
-            {
-LABEL_18:
-              LOWORD(v6) = 0;
-            }
-            else
-            {
-              v7 = (char *)&pObjectList->pObjects->uObjectID;
-              while ( v5 != *(short *)v7 )
-              {
-                ++v6;
-                v7 += 56;
-                if ( v6 >= (signed int)pObjectList->uNumObjects )
-                  goto LABEL_18;
-              }
-            }
-            a1.uObjectDescID = v6;
-            a1.vPosition.y = pParty->vPosition.y;
-            a1.field_58_pid = OBJECT_Player;
-            a1.vPosition.x = pParty->vPosition.x;
-            a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
-            a1.uSoundID = 0;
-            a1.uFacing = 0;
-            a1.uAttributes = 8;
-            a1.uSectorID = pIndoor->GetSector(
-                             pParty->vPosition.x,
-                             pParty->vPosition.y,
-                             pParty->sEyelevel + pParty->vPosition.z);
-            a1.uSpriteFrameID = 0;
-            memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u);
-            v8 = (int *)pMouse->GetCursorPos(&v25);
-            v9 = UnprojectX(*v8);
-            a1.Create(pParty->sRotationY + v9, 184, 200, 0);
-            v10 = pIcons_LOD->LoadTexture(
-                    pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName,
-                    TEXTURE_16BIT_PALETTE);
-            if (v10 != -1)
-              pIcons_LOD->pTextures[v10].Release();
-            pMouse->RemoveHoldingItem();
-            pIcons_LOD->_40F9C5();
-            return;
-          }
-          ShowNothingHereStatus();
-LABEL_13:
-          v4 = pParty->pPickedItem.uItemID;
-          if ( !pParty->pPickedItem.uItemID )
-            return;
-          goto LABEL_14;
+			v5 = pItemsTable->pItems[v4].uSpriteID;
+			v6 = 0;
+			a1.uType = v5;
+			if ( (signed int)pObjectList->uNumObjects <= 0 )
+			{
+				LOWORD(v6) = 0;
+			}
+			else
+			{
+				v7 = (char *)&pObjectList->pObjects->uObjectID;
+				while ( v5 != *(short *)v7 )
+				{
+					++v6;
+					v7 += 56;
+					if ( v6 >= (signed int)pObjectList->uNumObjects )
+					{
+						LOWORD(v6) = 0;
+						break;
+					}
+				}
+			}
+			a1.uObjectDescID = v6;
+			a1.vPosition.y = pParty->vPosition.y;
+			a1.field_58_pid = OBJECT_Player;
+			a1.vPosition.x = pParty->vPosition.x;
+			a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
+			a1.uSoundID = 0;
+			a1.uFacing = 0;
+			a1.uAttributes = 8;
+			a1.uSectorID = pIndoor->GetSector(
+								pParty->vPosition.x,
+								pParty->vPosition.y,
+								pParty->sEyelevel + pParty->vPosition.z);
+			a1.uSpriteFrameID = 0;
+			memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u);
+			v8 = (int *)pMouse->GetCursorPos(&v25);
+			v9 = UnprojectX(*v8);
+			a1.Create(pParty->sRotationY + v9, 184, 200, 0);
+			v10 = pIcons_LOD->LoadTexture(
+					pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName,
+					TEXTURE_16BIT_PALETTE);
+			if (v10 != -1)
+				pIcons_LOD->pTextures[v10].Release();
+			pMouse->RemoveHoldingItem();
+			pIcons_LOD->_40F9C5();
+			return;
         }
         v11 = pIndoor->pFaceExtras[v3->uFaceExtraID].uEventID;
       }
@@ -5229,14 +5291,22 @@
       stru_50C198.LootActor(&pActors[v16]);
       return;
     }
-    goto LABEL_13;
+    v4 = pParty->pPickedItem.uItemID;
+    if ( !pParty->pPickedItem.uItemID )
+		return;
+    goto LABEL_14;
   }
   if ( GetAsyncKeyState(VK_SHIFT) >= 0 )
   {
     if ( !v17->GetActorsRelation(0) && !(BYTE2(v17->uAttributes) & 8) )
     {
       if ( (unsigned int)v0 >= 0x2000000 )
-        goto LABEL_13;
+	  {
+          v4 = pParty->pPickedItem.uItemID;
+          if ( !pParty->pPickedItem.uItemID )
+            return;
+          goto LABEL_14;
+	  }
       if ( !v17->CanAct() )
         return;
       v18 = a2.y;
--- a/mm7_3.cpp	Wed Mar 06 16:12:38 2013 +0200
+++ b/mm7_3.cpp	Wed Mar 06 16:14:21 2013 +0200
@@ -6166,47 +6166,38 @@
   array_50AC10[3].vWorldViewProjX = pViewport->uViewportZ;
   array_50AC10[3].vWorldViewProjY = v38;
 
-  v36 = (double)(pViewport->uViewportZ - pViewport->uViewportX) * 0.5;
+  /*v36 = (double)(pViewport->uViewportZ - pViewport->uViewportX) * 0.5;
   v33 = 65536 / (signed int)(v36 / tan(0.6457717418670654) + 0.5);
 
   for (int i = 0; i < _this.uNumVertices; ++i)
   {
-     v29 = floorf(array_50AC10[i].vWorldViewProjY + 0.5f);
-     v39 = (unsigned __int64)(_this.ptr_38->field_14 * v33 * (v30 - v29)) / 65536;
-     v8 = v39 + _this.ptr_38->field_C;
-
-     v39 = (unsigned __int64)(_this.ptr_38->field_20 * v33 * (v30 - v29)) / 65536;
-     v36 = v39 + _this.ptr_38->field_18;
-
-      v9 = (unsigned __int64)(_this.v_18.z * v33 * (v30 - v29)) / 65536;
-      v10 = _this.v_18.x + v9;
-      v39 = _this.v_18.x + v9;
-      if ( _this.v_18.x + v9 > 0 )
-      {
-        v10 = 0;
-        v39 = 0;
-      }
-      v11 = (signed __int64)array_50AC10[i].vWorldViewProjX;
-      v38 = v10;
-      v12 = array_50AC10[i].vWorldViewProjY - 1.0;
-      v13 = v33 * (pViewport->uScreenCenterX - v11);
-      v34 = -_this.field_24;
-      v32 = (signed __int64)v12;
-      v14 = v33 * (v30 - v32);
-      while ( 1 )
-      {
-        v40 = v14;
-        if ( !v10 )
-          goto LABEL_12;
-        v37 = abs(v34 >> 14);
-        v15 = abs(v10);
-        if ( v37 <= v15 || v32 <= pViewport->uViewportY )
-        {
-          if ( v39 <= 0 )
-            break;
-        }
-        v14 = v40;
-LABEL_12:
+    v29 = floorf(array_50AC10[i].vWorldViewProjY + 0.5f);
+    v39 = (unsigned __int64)(_this.ptr_38->field_14 * v33 * (v30 - v29)) / 65536;
+    v8 = v39 + _this.ptr_38->field_C;
+
+    v39 = (unsigned __int64)(_this.ptr_38->field_20 * v33 * (v30 - v29)) / 65536;
+    v36 = v39 + _this.ptr_38->field_18;
+
+    v9 = (unsigned __int64)(_this.v_18.z * v33 * (v30 - v29)) / 65536;
+    v10 = _this.v_18.x + v9;
+    v39 = _this.v_18.x + v9;
+    if ( _this.v_18.x + v9 > 0 )
+    {
+      v10 = 0;
+      v39 = 0;
+    }
+    v11 = (signed __int64)array_50AC10[i].vWorldViewProjX;
+    v38 = v10;
+    v12 = array_50AC10[i].vWorldViewProjY - 1.0;
+    v13 = v33 * (pViewport->uScreenCenterX - v11);
+    v34 = -_this.field_24;
+    v32 = (signed __int64)v12;
+    v14 = v33 * (v30 - v32);
+    while ( 1 )
+    {
+      //v40 = v14;
+      if ( !v10 )
+      {
         v37 = _this.v_18.z;
         v16 = (unsigned __int64)(_this.v_18.z * (signed __int64)v14) >> 16;
         --v32;
@@ -6216,47 +6207,66 @@
         v38 = _this.v_18.x + v16;
         break;
       }
-      LODWORD(v17) = v34 << 16;
-      HIDWORD(v17) = v34 >> 16;
-      v18 = v17 / v38;
-      if ( v18 < 0 )
-        v18 = pOutdoorCamera->shading_dist_mist;
-
-      v37 += ((unsigned __int64)(_this.ptr_38->field_10 * v13) >> 16);
-      v36 += ((unsigned __int64)(_this.ptr_38->field_1C * v13) >> 16);
-      v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + (signed int)((unsigned __int64)(v37 * v18) >> 16) / 8;
-      v36 = 224 * pMiscTimer->uTotalGameTimeElapsed + (signed int)((unsigned __int64)(v36 * v18) >> 16) / 8;
-
-      array_50AC10[i].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
-      array_50AC10[i]._rhw = 1.0 / (double)(v17 / 65536);
-      array_50AC10[i].u = (double)v35 / (65536.0 * pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID].uTextureWidth);
-      array_50AC10[i].v = (double)v36 / (65536.0 * pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID].uTextureWidth);
-    }
-
-     float t = (GetTickCount() % 96000) / 96000.0f;
-
- array_50AC10[0].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
- array_50AC10[0]._rhw = 1;
- array_50AC10[0].u = 0;
- array_50AC10[0].v = 0 + t;
-
- array_50AC10[1].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
- array_50AC10[1]._rhw = 1;
- array_50AC10[1].u = 0;
- array_50AC10[1].v = 1 + t;
- 
- array_50AC10[2].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
- array_50AC10[2]._rhw = 1;
- array_50AC10[2].u = 1;
- array_50AC10[2].v = 0 + t;
-
- array_50AC10[3].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
- array_50AC10[3]._rhw = 1;
- array_50AC10[3].u = 1;
- array_50AC10[3].v = 1 + t;
- pRenderer->DrawStrip(_this.uNumVertices, &_this,
-          pBitmaps_LOD->pHardwareTextures[_this.uTileBitmapID]);
-        return;
+      v37 = abs(v34 >> 14);
+      v15 = abs(v10);
+      if ( v37 <= v15 || v32 <= pViewport->uViewportY )
+      {
+        if ( v39 <= 0 )
+          break;
+      }
+      //v14 = v40;
+      v37 = _this.v_18.z;
+      v16 = (unsigned __int64)(_this.v_18.z * v14) >> 16;
+      --v32;
+      v14 += v33;
+      v10 = _this.v_18.x + v16;
+      v39 = _this.v_18.x + v16;
+      v38 = _this.v_18.x + v16;
+      break;
+    }
+    LODWORD(v17) = v34 << 16;
+    HIDWORD(v17) = v34 >> 16;
+    v18 = v17 / v38;
+    if ( v18 < 0 )
+      v18 = pOutdoorCamera->shading_dist_mist;
+
+    v37 += ((unsigned __int64)(_this.ptr_38->field_10 * v13) >> 16);
+    v36 += ((unsigned __int64)(_this.ptr_38->field_1C * v13) >> 16);
+    v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + (signed int)((unsigned __int64)(v37 * v18) >> 16) / 8;
+    v36 = 224 * pMiscTimer->uTotalGameTimeElapsed + (signed int)((unsigned __int64)(v36 * v18) >> 16) / 8;
+	*/
+    //array_50AC10[i].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
+    //array_50AC10[i]._rhw = 1;
+    //array_50AC10[i].u = (double)v35 / (65536.0 * pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID].uTextureWidth);
+    //array_50AC10[i].v = (double)v36 / (65536.0 * pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID].uTextureWidth);
+    //}
+    if ( _this.uNumVertices > 0)
+    {
+      float t = (GetTickCount() % 96000) / 96000.0f;
+
+      array_50AC10[0].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
+      array_50AC10[0]._rhw = 1;
+      array_50AC10[0].u = 0;
+      array_50AC10[0].v = 0 + t;
+
+      array_50AC10[1].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
+      array_50AC10[1]._rhw = 1;
+      array_50AC10[1].u = 0;
+      array_50AC10[1].v = 1 + t;
+
+      array_50AC10[2].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
+      array_50AC10[2]._rhw = 1;
+      array_50AC10[2].u = 1;
+      array_50AC10[2].v = 0 + t;
+
+      array_50AC10[3].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
+      array_50AC10[3]._rhw = 1;
+      array_50AC10[3].u = 1;
+      array_50AC10[3].v = 1 + t;
+      pRenderer->DrawStrip(_this.uNumVertices, &_this, pBitmaps_LOD->pHardwareTextures[_this.uTileBitmapID]);
+      return;
+    //}
+  }
 }