diff mm7_1.cpp @ 1306:13b7be8b06a0

Слияние
author Ritor1
date Sun, 23 Jun 2013 14:27:57 +0600
parents dcc52e17b517 8c2f689b5f0b
children 65379a50e4eb
line wrap: on
line diff
--- a/mm7_1.cpp	Sun Jun 23 14:27:32 2013 +0600
+++ b/mm7_1.cpp	Sun Jun 23 14:27:57 2013 +0600
@@ -39,7 +39,7 @@
 #include "IconFrameTable.h"
 #include "TurnEngine.h"
 #include "texts.h"
-#include "UIHouses.h"
+#include "UI\UIHouses.h"
 #include "stru367.h"
 
 int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam);
@@ -66,294 +66,6 @@
   return ((__int64)a1 * (__int64)a2) >> 16;
 }
 
-//----- (004196A0) --------------------------------------------------------
-void CharacterUI_ReleaseButtons()
-{
-  GUIButton *i; // esi@2
-  GUIButton *j; // esi@7
-
-  if ( dword_507CC0_activ_ch )
-  {
-    dword_507CC0_activ_ch = 0;
-    for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = j )
-    {
-	  j=i->pNext;
-	  if ( BYTE1(i->field_1C) & 0x80 )
-	  {
-        i->Release();
-		pAllocator->FreeChunk(i);
-	  }
-    }
-    for ( j = pGUIWindow_CurrentMenu->pControlsHead; j; j = j->pNext )
-    {
-      if ( j->msg == UIMSG_InventoryLeftClick)
-      {
-        j->uX = dword_50698C_uX;
-        j->uY = dword_506988_uY;
-        j->uZ = dword_506984_uZ;
-        j->uW = dword_506980_uW;
-        pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(1, 0, 0, 0);
-      }
-    }
-  }
-}
-
-//----- (0041CD4F) --------------------------------------------------------
-bool UI_OnKeyDown(unsigned int vkKey)
-{
-  //unsigned int v1; // edi@1
-  //unsigned int v2; // eax@2
-  int v3; // esi@3
-  int v4; // ecx@10
-  GUIButton *pButton; // eax@11
-  int v6; // edx@12
-  int v7; // ecx@20
-  char v8; // zf@21
-  //GUIButton *v9; // ecx@24
-  int v10; // esi@24
-  //int v11; // edx@26
-  int v12; // edx@28
-  int v13; // esi@32
-  //GUIButton *v14; // eax@37
-  int v15; // edx@38
-  int v17; // ecx@50
-  int v18; // edx@50
-  //GUIButton *v19; // ecx@54
-  int v20; // esi@54
-  //int v21; // edx@56
-  int v22; // ecx@59
-  int v23; // edx@59
-  int v24; // ecx@60
-  int v25; // esi@63
-  //unsigned int v26; // [sp+Ch] [bp-14h]@1
-  //int v27; // [sp+10h] [bp-10h]@1
-  int v28; // [sp+14h] [bp-Ch]@10
-  int v29; // [sp+14h] [bp-Ch]@36
-  unsigned int uClickX; // [sp+18h] [bp-8h]@10
-  unsigned int uClickY; // [sp+1Ch] [bp-4h]@10
-
-  //v1 = 0;
-  //v27 = uNumVisibleWindows;
-  if ( uNumVisibleWindows < 0 )
-    return false;
-  //v2 = pMessageQueue_50CBD0->uNumMessages;
-  for (int i = uNumVisibleWindows; i >= 0; --i)
-  //while ( 1 )
-  {
-    v3 = pVisibleWindowsIdxs[i] - 1;
-    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;
-        }
-        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 )   //crashed at skill draw
-        //{
-        //  pMouse->GetClickPos(&uClickX, &uClickY);
-        //  v4 = pWindowList[v3].pStartingPosActiveItem;
-        //  v29 = v4 + pWindowList[v3].pNumPresenceButton; //num buttons more than buttons 
-        //  if ( v4 < v29 )
-        //  {
-        //    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) --------------------------------------------------------
 void __fastcall sub_41D20D_buff_remaining_time_string( int ecx0, struct GUIWindow *edx0, __int64 a3, struct GUIFont *a2 )
     {
@@ -423,64 +135,6 @@
   a1->DrawText(a2, 32, uY, 0, pTmpBuf.data(), 0, 0, 0);
 }
 
-//----- (0041F54A) --------------------------------------------------------
-void __cdecl LoadActualSkyFrame()
-{
-  if ( pTexture_RestUI_CurrentSkyFrame )
-    pTexture_RestUI_CurrentSkyFrame->Release();
-  if ( pTexture_RestUI_CurrentHourglassFrame )
-    pTexture_RestUI_CurrentHourglassFrame->Release();
-  pIcons_LOD->SyncLoadedFilesCount();
-  sprintf(pTmpBuf.data(), "TERRA%03d", pParty->uCurrentMinute / 6 + 10 * pParty->uCurrentHour);
-  pTexture_RestUI_CurrentSkyFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE);
-}
-
-//----- (0041F5BE) --------------------------------------------------------
-void __cdecl Sleep6Hours()
-{
-  if ( _506F18_num_hours_to_sleep < 6 )
-  {
-    pParty->pPlayers[3].SetAsleep(false);
-    pParty->pPlayers[2].SetAsleep(false);
-    pParty->pPlayers[1].SetAsleep(false);
-    pParty->pPlayers[0].SetAsleep(false);
-    if ( _506F18_num_hours_to_sleep )
-    {
-      Rest(_506F18_num_hours_to_sleep);
-      _506F18_num_hours_to_sleep = 0;
-      LoadActualSkyFrame();
-    }
-    if ( dword_506F14 == 2 )
-    {
-      pGUIWindow_CurrentMenu->Release();
-      pEventTimer->Resume();
-      if ( pTexture_RestUI_CurrentSkyFrame )
-        pTexture_RestUI_CurrentSkyFrame->Release();
-      if ( pTexture_RestUI_CurrentHourglassFrame )
-        pTexture_RestUI_CurrentHourglassFrame->Release();
-      pTexture_RestUI_CurrentHourglassFrame = 0;
-      pTexture_RestUI_CurrentSkyFrame = 0;
-      pIcons_LOD->_4114F2();
-      pIcons_LOD->SyncLoadedFilesCount();
-      pCurrentScreen = SCREEN_GAME;
-      viewparams->bRedrawGameUI = 1;
-      if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
-      {
-        pOutdoor->UpdateSunlightVectors();
-        pOutdoor->UpdateFog();
-      }
-    }
-    dword_506F14 = 0;
-  }
-  else
-  {
-    Rest(6u);
-    _506F18_num_hours_to_sleep -= 6;
-    LoadActualSkyFrame();
-  }
-  viewparams->bRedrawGameUI = 1;
-}
-
 //----- (0042038D) --------------------------------------------------------
 void __cdecl sub_42038D()
 {
@@ -509,631 +163,6 @@
   }
 }
 
-//----- (00420C05) --------------------------------------------------------
-void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal)
-{
-  unsigned int v2; // edi@1
-  int v3; // ebp@1
-  unsigned int v4; // esi@1
-  int v5; // ecx@6
-  NPCData *v6; // eax@6
-  signed int v7; // edx@8
-  signed int v8; // ebx@10
-  char *v9; // edi@11
-  signed int v10; // ecx@17
-  int v11; // eax@21
-  NPCData *v12; // ecx@21
-  unsigned int v13; // ecx@23
-  signed int v14; // [sp+Ch] [bp-4h]@6
-
-  v2 = 0;
-  v3 = 0;
-  v4 = uNumGold;
-  if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal )
-  {
-    if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 1 )
-    {
-      sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], uNumGold);// You found %lu gold!
-    }
-    else
-    {
-      if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 2 )
-        pTmpBuf2[0] = 0;
-    }
-  }
-  else
-  {
-    v14 = 0;
-    v5 = 0;
-    v6 = pParty->pHirelings;
-    do
-    {
-      if ( v6->pName )
-      {
-        v7 = v14++;
-        pTmpBuf[v7] = v5;
-      }
-      ++v6;
-      ++v5;
-    }
-    while ( (signed int)v6 < (signed int)&pParty->pPickedItem );
-    v8 = 0;
-    if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
-    {
-      v9 = (char *)pNPCStats->pNewNPCData;
-      do
-      {
-        if ( v9[8] & 0x80
-          && (!pParty->pHirelings[0].pName || strcmp(*(const char **)v9, pParty->pHirelings[0].pName))
-          && (!pParty->pHirelings[1].pName || strcmp(*(const char **)v9, pParty->pHirelings[1].pName)) )
-        {
-          v10 = v14++;
-          pTmpBuf[v10] = v8 + 2;
-        }
-        ++v8;
-        v9 += 76;
-      }
-      while ( v8 < (signed int)pNPCStats->uNumNewNPCs );
-      v2 = 0;
-    }
-    if ( v14 > 0 )
-    {
-      do
-      {
-        v11 = (unsigned __int8)pTmpBuf[v2];
-        v12 = &pNPCStats->pNPCData[v11 + 499];
-        if ( (unsigned __int8)pTmpBuf[v2] < 2 )
-          v12 = &pParty->pHirelings[v11];
-        v13 = v12->uProfession;
-        if ( v13 )
-          v3 += pNPCStats->pProfessions[v13].uHirePrice;//*(&pNPCStats->field_13A58 + 5 * v13);
-        ++v2;
-      }
-      while ( (signed int)v2 < v14 );
-    }
-    if ( CheckHiredNPCSpeciality(Factor) )
-      v4 += (signed int)(10 * v4) / 100;
-    if ( CheckHiredNPCSpeciality(Banker) )
-      v4 += (signed int)(20 * v4) / 100;
-    if ( CheckHiredNPCSpeciality(Pirate) )
-      v4 += (signed int)(10 * v4) / 100;
-    if ( v3 )
-    {
-      v3 = (signed int)(v4 * v3 / 100) / 100;
-      if ( v3 < 1 )
-        v3 = 1;
-      sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[466], v4, v3);// You found %lu gold (followers take %lu)!
-    }
-    else
-    {
-      sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], v4);// You found %lu gold!
-    }
-    v2 = 0;
-  }
-  pParty->uNumGold += v4 - v3;
-  pUIAnim_Gold->uAnimTime = v2;
-  pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Gold->uIconID].uAnimLength;
-  if ( pTmpBuf2[0] )
-    ShowStatusBarString(pTmpBuf2.data(), 2u);
-  pAudioPlayer->PlaySound(SOUND_GoldReceived, v2, v2, -1, v2, v2, v2, v2);
-}
-
-//----- (00420E01) --------------------------------------------------------
-void __cdecl OnChestLeftClick()
-{
-  int chest_id; // edi@1
-  POINT *v1; // esi@2
-  int v2; // eax@2
-  int v3; // ebx@4
-  int v4; // esi@6
-  int v5; // ecx@6
-  //SpriteObject v6; // [sp+Ch] [bp-80h]@1
-  POINT v7; // [sp+7Ch] [bp-10h]@2
-  POINT a2; // [sp+84h] [bp-8h]@2
-  
-  SpriteObject v6; // [sp+Ch] [bp-80h]@1
-  //SpriteObject::SpriteObject(&v6);
-
-  chest_id = pGUIWindow_CurrentMenu->par1C;
-  if ( pParty->pPickedItem.uItemID )
-  {
-    if ( Chest::PutItemInChest(-1, &pParty->pPickedItem, pGUIWindow_CurrentMenu->par1C) )
-      pMouse->RemoveHoldingItem();
-  }
-  else
-  {
-    v1 = pMouse->GetCursorPos(&a2);
-    v2 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v7)->y]] & 0xFFFF;
-    if ( v2 )
-    {
-      if ( v2 )
-        v3 = v2 - 1;
-      else
-        v3 = -1;
-      v4 = pChests[chest_id].pInventoryIndices[v3] - 1;
-      if ( pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uEquipType == EQUIP_GOLD )
-      {
-        party_finds_gold(pChests[chest_id].igChestItems[v4].uSpecEnchantmentType, 0); 
-        viewparams->bRedrawGameUI = 1;
-      }
-      else
-      {
-        pParty->SetHoldingItem(&pChests[chest_id].igChestItems[v4]);
-      }
-      sub_420B13(v4, v3);
-    }
-  }
-}
-
-
-
-//----- (00421B2C) --------------------------------------------------------
-bool __cdecl sub_421B2C_PlaceInInventory_or_DropPickedItem()
-{
-  unsigned int v0; // eax@2
-  Texture *v1; // ebx@2
-  int v2; // eax@3
-  Player *v3; // esi@5
-  int v4; // eax@6
-  unsigned __int16 v5; // dx@11
-  signed int v6; // eax@11
-  char *v7; // edi@12
-  __int16 v8; // ax@16
-  SpriteObject a1; // [sp+4h] [bp-78h]@11
-  int v11; // [sp+74h] [bp-8h]@2
-  int v12; // [sp+78h] [bp-4h]@5
-
-  if ( !pParty->pPickedItem.uItemID )
-    return 1;
-  v0 = pIcons_LOD->LoadTexture(
-         pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName,
-         TEXTURE_16BIT_PALETTE);
-  v1 = pIcons_LOD->GetTexture(v0);
-  v11 = areWeLoadingTexture;
-  if ( uActiveCharacter
-    && (v2 = pPlayers[uActiveCharacter]->AddItem(-1, pParty->pPickedItem.uItemID)) != 0 )
-  {
-    memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v2-1], &pParty->pPickedItem, 0x24u);
-	pMouse->RemoveHoldingItem();
-  }
-  else
-  {
-    v12 = 0;
-    v3 = pParty->pPlayers;
-	while ( v3 <= &pParty->pPlayers[3] )
-    {
-      v4 = v3->AddItem(-1, pParty->pPickedItem.uItemID);
-      if ( v4 )
-	  {
-		memcpy(&pParty->pPlayers[v12].pInventoryItems[v4], &pParty->pPickedItem, 0x24u);
-		pMouse->RemoveHoldingItem();
-		break;
-	  }
-	  ++v12;
-      ++v3;
-    }
-    if ( v12 == 4 )
-	{
-		v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
-		v6 = 0;
-		a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
-		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.spell_caster_pid = OBJECT_Player;
-		a1.uObjectDescID = v6;
-		a1.vPosition.y = pParty->vPosition.y;
-		a1.vPosition.x = pParty->vPosition.x;
-		a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
-		a1.uSoundID = 0;
-		a1.uFacing = 0;
-		a1.uAttributes = 8;
-		v8 = pIndoor->GetSector(
-			   pParty->vPosition.x,
-			   pParty->vPosition.y,
-			   pParty->sEyelevel + pParty->vPosition.z);
-		a1.uSpriteFrameID = 0;
-		a1.uSectorID = v8;
-		memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24));
-		a1.Create(pParty->sRotationY, 184, 200, 0);
-		pMouse->RemoveHoldingItem();
-	}
-  }
-  if ( !v11 )
-  {
-    v1->Release();
-    pIcons_LOD->SyncLoadedFilesCount();
-  }
-  return 1;
-}
-
-
-//----- (00421EA6) --------------------------------------------------------
-void __cdecl OnInventoryLeftClick()
-{
-  Player *v0; // ebx@1
-  signed int v1; // eax@2
-  signed int v2; // ecx@2
-  int v3; // eax@2
-  char v4; // sf@2
-  int v5; // eax@2
-  unsigned int v6; // eax@7
-  unsigned int v7; // esi@12
-  unsigned int v8; // eax@12
-  unsigned int v9; // eax@16
-  unsigned int v10; // eax@18
-  ItemGen this_; // [sp+Ch] [bp-3Ch]@1
-  POINT a2; // [sp+30h] [bp-18h]@4
-  unsigned int v13; // [sp+38h] [bp-10h]@13
-  unsigned int pY; // [sp+3Ch] [bp-Ch]@2
-  unsigned int pX; // [sp+40h] [bp-8h]@2
-  int a4; // [sp+44h] [bp-4h]@2
-
-  v0 = pPlayers[uActiveCharacter];
-  if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103 )
-  {
-    pMouse->GetClickPos(&pX, &pY);
-    pY = pY - 17;
-    v2 =pX - 14;
-    pX = v2;
-    v3 = 14 * (pY >> 5);
-    v2 >>= 5;
-    v4 = v2 + v3 < 0;
-    v5 = v2 + v3;
-    a4 = v5;
-    if ( !v4 )
-    {
-      if ( v5 <= 126 && pMouse->GetCursorPos(&a2)->x < 462
-            && pMouse->GetCursorPos(&a2)->x >= 14 )
-      {
-        if ( unk_50C9A0 )
-        {
-          v6 = v0->GetItemIDAtInventoryIndex(&a4);
-          if ( v6 )
-          {
-            *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu;
-            *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1;
-            *((int *)pGUIWindow_Settings->ptr_1C + 3) = v6 - 1;
-            *((short *)pGUIWindow_Settings->ptr_1C + 3) = a4;
-            ptr_50C9A4 = (ItemGen *)&v0->pInventoryItems[v6-1];
-            unk_50C9A0 = 0;
-            if ( pMessageQueue_50CBD0->uNumMessages )
-              pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
-            pMouse->SetCursorBitmap("MICON1");
-            dword_50C9D0 = 113;
-            dword_50C9D4 = 0;
-            dword_50C9D8 = 256;
-          }
-          return;
-        }
-        if ( ptr_50C9A4 )
-          return;
-        v7 = pParty->pPickedItem.uItemID;
-        v8 = v0->GetItemIDAtInventoryIndex(&a4);
-        if ( !v7 )
-        {
-          if ( !v8 )
-            return;
-          memcpy(&pParty->pPickedItem, &v0->pInventoryItems[v8-1], sizeof(pParty->pPickedItem));
-          v0->RemoveItemAtInventoryIndex(a4);
-          v9 = pParty->pPickedItem.uItemID;
-          pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName);
-          return;
-        }
-        v13 = v8;
-        if ( v8 )
-        {
-          a2.y = (LONG)&v0->pInventoryItems[v8-1];
-          memcpy(&this_, (const void *)a2.y, sizeof(this_));
-          v0->RemoveItemAtInventoryIndex(a4);
-          pX = v0->AddItem2(a4, &pParty->pPickedItem);
-          if ( !pX )
-          {
-            pX = v0->AddItem2(0xFFFFFFFFu, &pParty->pPickedItem);
-            if ( !pX )
-            {
-              v0->PutItemArInventoryIndex(&this_, v13 - 1, a4);
-              memcpy((void *)a2.y, &this_, sizeof(ItemGen));
-              return;
-            }
-          }
-          v9 = this_.uItemID;
-          memcpy(&pParty->pPickedItem, &this_, sizeof(pParty->pPickedItem));
-          pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName);
-          return;
-        }
-        v10 = v0->AddItem(a4, v7);
-        pX = v10;
-        if ( v10 || (v10 = v0->AddItem(-1, pParty->pPickedItem.uItemID), (pX = v10) != 0) )
-        {
-          memcpy(&v0->pInventoryItems[v10-1], &pParty->pPickedItem, 0x24u);
-          pMouse->RemoveHoldingItem();
-        }
-      }
-    }
-  }
-}
-
-//----- (0042213C) --------------------------------------------------------
-void OnGameViewportClick()
-{
-  signed int v0; // ebx@2
-  POINT *v1; // esi@3
-  signed int v2; // eax@9
-  BLVFace *v3; // eax@10
-  unsigned int v4; // eax@11
-  unsigned __int16 v5; // dx@14
-  signed int v6; // eax@14
-  char *v7; // esi@15
-  //int *v8; // eax@19
-  int v9; // eax@19
-  unsigned int v10; // eax@19
-  int v11; // ecx@21
-  ODMFace *v12; // eax@22
-  LevelDecoration *v13; // esi@24
-  __int16 v14; // ax@25
-  int v15; // ecx@29
-  signed int v16; // edx@30
-  Actor *v17; // esi@30
-  int v18; // ebx@47
-  unsigned __int16 v19; // ax@50
-  const char *v20; // eax@51
-  signed int v21; // eax@58
-  ItemGen *v22; // esi@62
-  unsigned int v23; // eax@62
-  SpriteObject a1; // [sp+Ch] [bp-80h]@1
-  //POINT v25; // [sp+7Ch] [bp-10h]@3
-  POINT a2; // [sp+84h] [bp-8h]@3
-
-  v1 = pMouse->GetCursorPos(&a2);
-  if ( pRenderer->pRenderD3D )
-    v0 = pGame->pVisInstance->get_picked_object_zbuf_val();
-  else
-  {
-    v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[v1->y]];
-  }
-
-  if ( PID_TYPE(v0) == OBJECT_Item)
-  {
-    a2.y = (signed int)(unsigned __int16)v0 >> 3;
-    v21 = (signed int)(unsigned __int16)v0 >> 3;
-    if ( !(pObjectList->pObjects[pSpriteObjects[v21].uObjectDescID].uFlags & 0x10) && a2.y < 1000 && pSpriteObjects[v21].uObjectDescID
-      && (unsigned int)v0 < 0x2000000 )
-    {
-      v22 = &pSpriteObjects[v21].stru_24;
-      v23 = pSpriteObjects[v21].stru_24.uItemID;
-      if ( pItemsTable->pItems[v23].uEquipType == 18 )
-      {
-        party_finds_gold(v22->uSpecEnchantmentType, 0);
-        viewparams->bRedrawGameUI = 1;
-      }
-      else
-      {
-        sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v23].pUnidentifiedName);
-        ShowStatusBarString(pTmpBuf2.data(), 2u);
-        if ( v22->uItemID == 506 )
-          _449B7E_toggle_bit(pParty->_quest_bits, 184, 1u);
-        if ( v22->uItemID == 455 )
-          _449B7E_toggle_bit(pParty->_quest_bits, 185, 1u);
-        if ( !pParty->AddItem(v22) )
-          pParty->SetHoldingItem(v22);
-      }
-      SpriteObject::OnInteraction(a2.y);
-      return;
-    }
-    v4 = pParty->pPickedItem.uItemID;
-    if ( !pParty->pPickedItem.uItemID )
-		return;
-    goto LABEL_14;
-  }
-  if ( PID_TYPE(v0) != OBJECT_Actor)
-  {
-    if ( PID_TYPE(v0) == OBJECT_Decoration)
-    {
-      v13 = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3];
-      if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[v13->uDecorationDescID].uRadius) >= 512 )
-	  {
-          v4 = pParty->pPickedItem.uItemID;
-          if ( !pParty->pPickedItem.uItemID )
-            return;
-          goto LABEL_14;
-	  }
-      v14 = v13->field_16_event_id;
-      if ( !v14 )
-      {
-        if ( pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].IsInteractive() )
-        {
-          v15 = stru_5E4C90._decor_events[v13->_idx_in_stru123 - 75] + 380;
-          activeLevelDecoration = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3];
-          EventProcessor(v15, 0, 1);
-          activeLevelDecoration = NULL;
-        }
-        return;
-      }
-      v11 = v14;
-    }
-    else
-    {
-      if ( PID_TYPE(v0) != OBJECT_BModel || HIWORD(v0) >= 512 )
-	  {
-          v4 = pParty->pPickedItem.uItemID;
-          if ( !pParty->pPickedItem.uItemID )
-            return;
-          goto LABEL_14;
-	  }
-      v2 = PID_ID(v0);
-      if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
-      {
-        v3 = &pIndoor->pFaces[v2];
-        if ( !(v3->uAttributes & 0x2000000) )
-        {
-LABEL_11:
-			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 )
-				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.spell_caster_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);
-
-            extern int UnprojectX(int);
-			v9 = UnprojectX(v1->x);
-			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->SyncLoadedFilesCount();
-			return;
-        }
-        v11 = pIndoor->pFaceExtras[v3->uFaceExtraID].uEventID;
-      }
-      else
-      {
-        v12 = &pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[v2 & 0x3F];
-        if ( !v12->Clickable())
-          goto LABEL_11;
-        v11 = v12->sCogTriggeredID;
-      }
-    }
-    EventProcessor(v11, (unsigned __int16)v0, 1);
-    return;
-  }
-  v16 = (signed int)(unsigned __int16)v0 >> 3;
-  a2.y = v16;
-  v17 = &pActors[v16];
-  if ( v17->uAIState == 5 )
-  {
-    if ( (unsigned int)v0 < 0x2000000 )
-    {
-      stru_50C198.LootActor(&pActors[v16]);
-      return;
-    }
-    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 ( HIWORD(v0) >= 512)
-	  {
-          v4 = pParty->pPickedItem.uItemID;
-          if ( !pParty->pPickedItem.uItemID )
-            return;
-          goto LABEL_14;
-	  }
-      if ( !v17->CanAct() )
-        return;
-      v18 = a2.y;
-      Actor::AI_FaceObject(a2.y, 4u, 0, 0);
-      if ( !v17->sNPC_ID )
-      {
-        v19 = pNPCStats->pGroups_copy[v17->uGroup];
-        if ( v19 )
-        {
-          v20 = pNPCStats->pCatchPhrases[v19];
-          if ( v20 )
-          {
-            pParty->uFlags |= 2u;
-            strcpy(byte_5B0938.data(), v20);
-            sub_4451A8_press_any_key(0, 0, 0);
-          }
-        }
-        return;
-      }
-      /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
-        return;
-      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_StartNPCDialogue;
-      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v18;
-LABEL_42:
-      *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-      ++pMessageQueue_50CBD0->uNumMessages;
-      return;*/
-      pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v18, 0);
-      return;
-    }
-    if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 )
-    {
-      pTurnEngine->field_18 |= 8u;
-      return;
-    }
-    /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-    {
-      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Attack;
-      goto LABEL_41;
-    }*/
-    pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0);
-  }
-  else
-  {
-    if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 )
-    {
-      pParty->uFlags |= PARTY_FLAGS_1_FALLING;
-      return;
-    }
-    if ( uActiveCharacter
-      && sub_427769_spell(pPlayers[uActiveCharacter]->uQuickSpell))
-    {
-      pMessageQueue_50CBD0->AddMessage(UIMSG_CastQuickSpell, 0, 0);
-      /*&& (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_CastQuickSpell;
-LABEL_41:
-      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
-      goto LABEL_42;*/
-    }
-  }
-}
-
 //----- (004226C2) --------------------------------------------------------
 bool PauseGameDrawing()
 {
@@ -1485,515 +514,6 @@
   while ( v1 );
 }
 
-//----- (00423B5D) --------------------------------------------------------
-int __fastcall sub_423B5D(unsigned int uFaceID)
-{
-  BLVFace *pFace; // ebx@1
-  //Vec3_short_ *v2; // esi@1
-  //int v3; // ST28_4@1
-  //__int16 v4; // ST2C_2@1
-  signed int v5; // esi@1
-  //Vec3_short_ *v6; // eax@4
-  signed int v7; // edi@5
-  signed int v8; // eax@5
-  signed int v9; // ecx@10
-  int v10; // eax@10
-  int v11; // edx@11
-  int v12; // ST28_4@12
-  signed int v13; // edx@12
-  signed __int64 v14; // qtt@12
-  char *v15; // ebx@12
-  int v16; // ST28_4@14
-  signed int v17; // eax@14
-  signed __int64 v18; // qtt@14
-  signed int v19; // edx@15
-  signed int v20; // edx@17
-  signed int v21; // ebx@19
-  signed int v22; // esi@20
-  int v23; // edi@21
-  int v24; // eax@21
-  int v25; // eax@22
-  int v26; // eax@22
-  signed int v27; // ST30_4@24
-  signed __int64 v28; // qtt@24
-  int v29; // ST18_4@25
-  int v30; // eax@26
-  int v31; // eax@27
-  int v32; // eax@27
-  signed int v33; // ST30_4@29
-  signed __int64 v34; // qtt@29
-  int v35; // ST30_4@30
-  signed int v36; // edi@31
-  unsigned int v37; // eax@31
-  bool v38; // edx@31
-  int v39; // ecx@31
-  int v40; // ecx@32
-  int v41; // esi@32
-  int v42; // eax@34
-  signed int v43; // ebx@41
-  unsigned int v44; // eax@41
-  signed int v45; // ecx@42
-  int v46; // esi@42
-  int v47; // eax@44
-  signed int v48; // edi@51
-  unsigned int v49; // eax@51
-  bool v50; // edx@51
-  int v51; // ecx@51
-  int v52; // ecx@52
-  int v53; // esi@52
-  int v54; // eax@54
-  int v55; // ebx@61
-  unsigned int v56; // eax@61
-  signed int v57; // ecx@62
-  int v58; // esi@62
-  int v59; // eax@64
-  char v61; // zf@72
-  signed int v62; // edx@75
-  int v63; // ecx@76
-  int v64; // esi@76
-  int v65; // ecx@83
-  signed int v66; // [sp+14h] [bp-14h]@3
-  int v67; // [sp+14h] [bp-14h]@34
-  int v68; // [sp+14h] [bp-14h]@44
-  int v69; // [sp+14h] [bp-14h]@54
-  int v70; // [sp+14h] [bp-14h]@64
-  signed int v71; // [sp+14h] [bp-14h]@75
-  //IndoorCameraD3D *_this; // [sp+18h] [bp-10h]@1
-  bool thisa; // [sp+18h] [bp-10h]@9
-  int thisb; // [sp+18h] [bp-10h]@12
-  int thisc; // [sp+18h] [bp-10h]@20
-  bool thisd; // [sp+18h] [bp-10h]@41
-  bool thise; // [sp+18h] [bp-10h]@61
-  int thisf; // [sp+18h] [bp-10h]@74
-  signed int v79; // [sp+1Ch] [bp-Ch]@9
-  int v80; // [sp+1Ch] [bp-Ch]@76
-  bool v81; // [sp+20h] [bp-8h]@10
-  bool v82; // [sp+20h] [bp-8h]@32
-  bool v83; // [sp+20h] [bp-8h]@42
-  bool v84; // [sp+20h] [bp-8h]@52
-  bool v85; // [sp+20h] [bp-8h]@62
-  signed int v86; // [sp+24h] [bp-4h]@9
-  signed int v87; // [sp+24h] [bp-4h]@19
-  signed int v88; // [sp+24h] [bp-4h]@31
-  signed int v89; // [sp+24h] [bp-4h]@41
-  signed int v90; // [sp+24h] [bp-4h]@51
-  signed int v91; // [sp+24h] [bp-4h]@61
-
-  pFace = &pIndoor->pFaces[uFaceID];
-  //_this = pGame->pIndoorCameraD3D;
-  //v2 = &pIndoor->pVertices[pFace->pVertexIDs[0]];
-  //v3 = *(_DWORD *)&pIndoor->pVertices[pFace->pVertexIDs[0]].x;
-  //v4 = pIndoor->pVertices[pFace->pVertexIDs[0]].z;
-  v5 = 0;
-  if ( pFace->pFacePlane_old.vNormal.x * (pIndoor->pVertices[pFace->pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x)
-     + pFace->pFacePlane_old.vNormal.y * (pIndoor->pVertices[pFace->pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y)
-     + pFace->pFacePlane_old.vNormal.z * (pIndoor->pVertices[pFace->pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z) < 0 )
-  {
-    stru_50B700.field_0 = 1;
-  }
-  else
-  {
-    stru_50B700.field_0 = 0;
-    if ( !(pFace->uAttributes & 1) )
-      return 0;
-  }
-  v66 = pFace->uNumVertices;
-  if ( (signed int)pFace->uNumVertices > 0 )
-  {
-    do
-    {
-      //v6 = &pIndoor->pVertices[pFace->pVertexIDs[v5]];
-      pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(pIndoor->pVertices[pFace->pVertexIDs[v5]].x,
-        pIndoor->pVertices[pFace->pVertexIDs[v5]].y, pIndoor->pVertices[pFace->pVertexIDs[v5]].z,
-        &stru_50B700._view_transformed_xs[v5 + 3], &stru_50B700._view_transformed_zs[v5 + 3],
-        &stru_50B700._view_transformed_ys[v5 + 3], 0);
-      ++v5;
-    }
-    while ( v5 < v66 );
-  }
-  v7 = v66;
-  v8 = 0;
-  if ( v66 <= 0 )
-    return 0;
-  do
-  {
-    if ( stru_50B700._view_transformed_xs[v8 + 3] >= 524288 )
-      break;
-    ++v8;
-  }
-  while ( v8 < v66 );
-  if ( v8 >= v66 )
-    return 0;
-  v79 = 0;
-  stru_50B700._view_transformed_xs[v66 + 3] = stru_50B700._view_transformed_xs[3];
-  stru_50B700._view_transformed_zs[v66 + 3] = stru_50B700._view_transformed_zs[3];
-  stru_50B700._view_transformed_ys[v66 + 3] = stru_50B700._view_transformed_ys[3];
-  thisa = stru_50B700._view_transformed_xs[3] >= 524288;
-  v86 = 1;
-  if ( v66 >= 1 )
-  {
-    do
-    {
-      v9 = v86;
-      v10 = stru_50B700._view_transformed_xs[v86 + 3];
-      v81 = v10 >= 524288;
-      if ( thisa ^ v81 )
-      {
-        v11 = stru_50B700._view_transformed_xs[v9 + 2];
-        if ( v10 >= 524288 )
-        {
-          v12 = v10 - v11;
-          v13 = 524288 - v11;
-          LODWORD(v14) = v13 << 16;
-          HIDWORD(v14) = v13 >> 16;
-          v15 = (char *)&stru_50B700._view_transformed_ys[v9 + 2];
-          stru_50B700._view_transformed_zs[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[v9 + 3]
-                                                                     - stru_50B700._view_transformed_zs[v9 + 2])
-                                                                    * v14
-                                                                    / v12) >> 16)
-                                                + stru_50B700._view_transformed_zs[v9 + 2];
-          thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[v9 + 3] - stru_50B700._view_transformed_ys[v9 + 2])
-                                   * v14
-                                   / v12) >> 16;
-        }
-        else
-        {
-          v16 = v11 - v10;
-          v17 = 524288 - v10;
-          LODWORD(v18) = v17 << 16;
-          HIDWORD(v18) = v17 >> 16;
-          v15 = (char *)&stru_50B700._view_transformed_ys[v9 + 3];
-          stru_50B700._view_transformed_zs[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[v9 + 2]
-                                                                     - stru_50B700._view_transformed_zs[v9 + 3])
-                                                                    * v18
-                                                                    / v16) >> 16)
-                                                + stru_50B700._view_transformed_zs[v9 + 3];
-          thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[v9 + 2] - stru_50B700._view_transformed_ys[v9 + 3])
-                                   * v18
-                                   / v16) >> 16;
-        }
-        v19 = v79++;
-        v7 = v66;
-        stru_50B700._view_transformed_ys[v19] = thisb + *(_DWORD *)v15;
-        stru_50B700._view_transformed_xs[v19] = 524288;
-      }
-      if ( v81 )
-      {
-        v20 = v79++;
-        stru_50B700._view_transformed_xs[v20] = stru_50B700._view_transformed_xs[v9 + 3];
-        stru_50B700._view_transformed_zs[v20] = stru_50B700._view_transformed_zs[v9 + 3];
-        stru_50B700._view_transformed_ys[v20] = stru_50B700._view_transformed_ys[v9 + 3];
-      }
-      ++v86;
-      thisa = v81;
-    }
-    while ( v86 <= v7 );
-  }
-  v87 = 0;
-  v21 = v79;
-  stru_50B700._view_transformed_xs[v79] = stru_50B700._view_transformed_xs[0];
-  stru_50B700._view_transformed_zs[v79] = stru_50B700._view_transformed_zs[0];
-  for ( stru_50B700._view_transformed_ys[v79] = stru_50B700._view_transformed_ys[0];
-        v87 < v79;
-        stru_50B700._screen_space_y[v22 + 12] = pBLVRenderParams->uViewportCenterY - v35 )
-  {
-    v22 = v87;
-    thisc = abs(stru_50B700._view_transformed_xs[v87]);
-    if ( abs(stru_50B700._view_transformed_zs[v87]) >> 13 <= thisc )
-    {
-      v27 = stru_50B700._view_transformed_zs[v22];
-      LODWORD(v28) = v27 << 16;
-      HIDWORD(v28) = v27 >> 16;
-      v26 = v28 / stru_50B700._view_transformed_xs[v22];
-      v23 = 0;
-    }
-    else
-    {
-      v23 = 0;
-      v24 = 0;
-      if ( stru_50B700._view_transformed_zs[v22] >= 0 )
-      {
-        LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0;
-        v26 = ((v24 - 1) & 0xFF800000) + 4194304;
-      }
-      else
-      {
-        LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0;
-        v25 = v24 - 1;
-        v26 = (v25 & 0x800000) - 4194304;
-      }
-    }
-    v29 = stru_50B700._view_transformed_ys[v22];
-    stru_50B700._screen_space_x[v22 + 12] = v26;
-    if ( abs(v29) >> 13 <= thisc )
-    {
-      v33 = stru_50B700._view_transformed_ys[v22];
-      LODWORD(v34) = v33 << 16;
-      HIDWORD(v34) = v33 >> 16;
-      v32 = v34 / stru_50B700._view_transformed_xs[v22];
-    }
-    else
-    {
-      v30 = 0;
-      if ( stru_50B700._view_transformed_ys[v22] >= v23 )
-      {
-        LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23;
-        v32 = ((v30 - 1) & 0xFF800000) + 4194304;
-      }
-      else
-      {
-        LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23;
-        v31 = v30 - 1;
-        v32 = (v31 & 0x800000) - 4194304;
-      }
-    }
-    stru_50B700._screen_space_y[v22 + 12] = v32;
-    stru_50B700._screen_space_x[v22 + 12] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40)
-                                                             * (signed __int64)stru_50B700._screen_space_x[v22 + 12]) >> 16;
-    v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)stru_50B700._screen_space_y[v22 + 12]) >> 16;
-    stru_50B700._screen_space_x[v22 + 12] = pBLVRenderParams->uViewportCenterX - stru_50B700._screen_space_x[v22 + 12];
-    ++v87;
-  }
-  v36 = 0;
-  stru_50B700._screen_space_x[v21 + 12] = stru_50B700._screen_space_x[12];
-  stru_50B700._screen_space_y[v21 + 12] = stru_50B700._screen_space_y[12];
-  v37 = pBLVRenderParams->uViewportX;
-  v38 = stru_50B700._screen_space_x[12] < (signed int)pBLVRenderParams->uViewportX;
-  LOBYTE(v38) = stru_50B700._screen_space_x[12] >= (signed int)pBLVRenderParams->uViewportX;
-  v39 = 1;
-  v88 = 1;
-  if ( v79 < 1 )
-    return 0;
-  do
-  {
-    v40 = v39;
-    v41 = stru_50B700._screen_space_x[v40 + 12];
-    v82 = v41 >= (signed int)v37;
-    if ( v38 ^ v82 )
-    {
-      if ( v41 >= (signed int)v37 )
-      {
-        v67 = (signed int)(v37 - stru_50B700._screen_space_x[v40 + 11])
-            * (signed __int64)(stru_50B700._screen_space_y[v40 + 12] - stru_50B700._screen_space_y[v40 + 11])
-            / (v41 - stru_50B700._screen_space_x[v40 + 11]);
-        v42 = stru_50B700._screen_space_y[v40 + 11];
-      }
-      else
-      {
-        v67 = (signed int)(v37 - v41)
-            * (signed __int64)(stru_50B700._screen_space_y[v40 + 11] - stru_50B700._screen_space_y[v40 + 12])
-            / (stru_50B700._screen_space_x[v40 + 11] - v41);
-        v42 = stru_50B700._screen_space_y[v40 + 12];
-      }
-      ++v36;
-      stru_50B700._screen_space_y[v36 + 8] = v67 + v42;
-      v37 = pBLVRenderParams->uViewportX;
-      stru_50B700._screen_space_x[v36 + 8] = pBLVRenderParams->uViewportX;
-    }
-    v38 = v82;
-    if ( v82 )
-    {
-      stru_50B700._screen_space_x[v36 + 9] = stru_50B700._screen_space_x[v40 + 12];
-      stru_50B700._screen_space_y[v36++ + 9] = stru_50B700._screen_space_y[v40 + 12];
-    }
-    v39 = v88++ + 1;
-  }
-  while ( v88 <= v79 );
-  if ( !v36
-    || (v43 = 0,
-        stru_50B700._screen_space_x[v36 + 9] = stru_50B700._screen_space_x[9],
-        stru_50B700._screen_space_y[v36 + 9] = stru_50B700._screen_space_y[9],
-        v44 = pBLVRenderParams->uViewportZ,
-        thisd = stru_50B700._screen_space_x[9] <= (signed int)pBLVRenderParams->uViewportZ,
-        v89 = 1,
-        v36 < 1) )
-    return 0;
-  do
-  {
-    v45 = v89;
-    v46 = stru_50B700._screen_space_x[v89 + 9];
-    v83 = v46 <= (signed int)v44;
-    if ( thisd ^ v83 )
-    {
-      if ( v46 <= (signed int)v44 )
-      {
-        v68 = (signed int)(v44 - stru_50B700._screen_space_x[v45 + 8])
-            * (signed __int64)(stru_50B700._screen_space_y[v45 + 9] - stru_50B700._screen_space_y[v45 + 8])
-            / (v46 - stru_50B700._screen_space_x[v45 + 8]);
-        v47 = stru_50B700._screen_space_y[v45 + 8];
-      }
-      else
-      {
-        v68 = (signed int)(v44 - v46)
-            * (signed __int64)(stru_50B700._screen_space_y[v45 + 8] - stru_50B700._screen_space_y[v45 + 9])
-            / (stru_50B700._screen_space_x[v45 + 8] - v46);
-        v47 = stru_50B700._screen_space_y[v45 + 9];
-      }
-      ++v43;
-      stru_50B700._screen_space_y[v43 + 5] = v68 + v47;
-      v44 = pBLVRenderParams->uViewportZ;
-      stru_50B700._screen_space_x[v43 + 5] = pBLVRenderParams->uViewportZ;
-    }
-    if ( v83 )
-    {
-      stru_50B700._screen_space_x[v43 + 6] = stru_50B700._screen_space_x[v45 + 9];
-      stru_50B700._screen_space_y[v43++ + 6] = stru_50B700._screen_space_y[v45 + 9];
-    }
-    ++v89;
-    thisd = v83;
-  }
-  while ( v89 <= v36 );
-  if ( !v43
-    || (v48 = 0,
-        stru_50B700._screen_space_x[v43 + 6] = stru_50B700._screen_space_x[6],
-        stru_50B700._screen_space_y[v43 + 6] = stru_50B700._screen_space_y[6],
-        v49 = pBLVRenderParams->uViewportY,
-        v50 = stru_50B700._screen_space_y[6] < (signed int)pBLVRenderParams->uViewportY,
-        LOBYTE(v50) = stru_50B700._screen_space_y[6] >= (signed int)pBLVRenderParams->uViewportY,
-        v51 = 1,
-        v90 = 1,
-        v43 < 1) )
-    return 0;
-  do
-  {
-    v52 = v51;
-    v53 = stru_50B700._screen_space_y[v52 + 6];
-    v84 = v53 >= (signed int)v49;
-    if ( v50 ^ v84 )
-    {
-      if ( v53 >= (signed int)v49 )
-      {
-        v69 = (signed int)(v49 - stru_50B700._screen_space_y[v52 + 5])
-            * (signed __int64)(stru_50B700._screen_space_x[v52 + 6] - stru_50B700._screen_space_x[v52 + 5])
-            / (v53 - stru_50B700._screen_space_y[v52 + 5]);
-        v54 = stru_50B700._screen_space_x[v52 + 5];
-      }
-      else
-      {
-        v69 = (signed int)(v49 - v53)
-            * (signed __int64)(stru_50B700._screen_space_x[v52 + 5] - stru_50B700._screen_space_x[v52 + 6])
-            / (stru_50B700._screen_space_y[v52 + 5] - v53);
-        v54 = stru_50B700._screen_space_x[v52 + 6];
-      }
-      ++v48;
-      stru_50B700._screen_space_x[v48 + 2] = v69 + v54;
-      v49 = pBLVRenderParams->uViewportY;
-      stru_50B700._screen_space_y[v48 + 2] = pBLVRenderParams->uViewportY;
-    }
-    v50 = v84;
-    if ( v84 )
-    {
-      stru_50B700._screen_space_x[v48 + 3] = stru_50B700._screen_space_x[v52 + 6];
-      stru_50B700._screen_space_y[v48++ + 3] = stru_50B700._screen_space_y[v52 + 6];
-    }
-    v51 = v90++ + 1;
-  }
-  while ( v90 <= v43 );
-  if ( !v48
-    || (v55 = 0,
-        stru_50B700._screen_space_x[v48 + 3] = stru_50B700._screen_space_x[3],
-        stru_50B700._screen_space_y[v48 + 3] = stru_50B700._screen_space_y[3],
-        v56 = pBLVRenderParams->uViewportW,
-        thise = stru_50B700._screen_space_y[3] <= (signed int)pBLVRenderParams->uViewportW,
-        v91 = 1,
-        v48 < 1) )
-    return 0;
-  do
-  {
-    v57 = v91;
-    v58 = stru_50B700._screen_space_y[v91 + 3];
-    v85 = v58 <= (signed int)v56;
-    if ( thise ^ v85 )
-    {
-      if ( v58 <= (signed int)v56 )
-      {
-        v70 = (signed int)(v56 - stru_50B700._screen_space_y[v57 + 2])
-            * (signed __int64)(stru_50B700._screen_space_x[v57 + 3] - stru_50B700._screen_space_x[v57 + 2])
-            / (v58 - stru_50B700._screen_space_y[v57 + 2]);
-        v59 = stru_50B700._screen_space_x[v57 + 2];
-      }
-      else
-      {
-        v70 = (signed int)(v56 - v58)
-            * (signed __int64)(stru_50B700._screen_space_x[v57 + 2] - stru_50B700._screen_space_x[v57 + 3])
-            / (stru_50B700._screen_space_y[v57 + 2] - v58);
-        v59 = stru_50B700._screen_space_x[v57 + 3];
-      }
-      ++v55;
-      //stru_50B700._screen_space_y[v55 + 59] = v70 + v59;
-	  stru_50B700._screen_space_x[v55 - 1] = v70 + v59;
-      v56 = pBLVRenderParams->uViewportW;
-      //stru_50B700._view_transformed_xs[v55 + 47] = pBLVRenderParams->uViewportW;
-	  stru_50B700._screen_space_y[v55 - 1] = pBLVRenderParams->uViewportW;
-    }
-    if ( v85 )
-    {
-      stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[v57 + 3];
-      stru_50B700._screen_space_y[v55++] = stru_50B700._screen_space_y[v57 + 3];
-    }
-    ++v91;
-    thise = v85;
-  }
-  while ( v91 <= v48 );
-  if ( !v55 )
-    return 0;
-  v61 = pRenderer->pRenderD3D == 0;
-  stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0];
-  stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0];
-  if ( v61 && v55 > 3 )
-  {
-    stru_50B700._screen_space_x[v55 + 1] = stru_50B700._screen_space_x[1];
-    stru_50B700._screen_space_y[v55 + 1] = stru_50B700._screen_space_y[1];
-    thisf = 2 * (stru_50B700.field_0 != 0) - 1;
-    if ( v55 > 0 )
-    {
-      v62 = 1;
-      v71 = 1;
-      do
-      {
-        v63 = v62 - 1;
-        v64 = v62 + 1;
-        v80 = v62 + 1;
-        if ( v62 - 1 >= v55 )
-          v63 -= v55;
-        if ( v62 >= v55 )
-          v62 -= v55;
-        if ( v64 >= v55 )
-          v64 -= v55;
-        if ( thisf
-           * ((stru_50B700._screen_space_y[v64] - stru_50B700._screen_space_y[v63])
-            * (stru_50B700._screen_space_x[v62] - stru_50B700._screen_space_x[v63])
-            - (stru_50B700._screen_space_y[v62] - stru_50B700._screen_space_y[v63])
-            * (stru_50B700._screen_space_x[v64] - stru_50B700._screen_space_x[v63])) < 0 )
-        {
-          v62 = v80;
-          v71 = v80;
-        }
-        else
-        {
-          v62 = v71;
-          v65 = v71;
-          if ( v71 < v55 || (v65 = v71 - v55, v71 - v55 < v55) )
-          {
-            memcpy(
-              &stru_50B700._screen_space_y[v65],
-              &stru_50B700._screen_space_y[v65 + 1],
-              4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
-            memcpy(
-              &stru_50B700._screen_space_x[v65],
-              &stru_50B700._screen_space_x[v65 + 1],
-              4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
-          }
-          --v55;
-        }
-      }
-      while ( v62 - 1 < v55 );
-    }
-    stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0];
-    stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0];
-  }
-  return v55;
-}
 //----- (00424579) --------------------------------------------------------
 int __fastcall sub_424579(int uFaceID, stru320 *a2)
 {
@@ -2266,339 +786,6 @@
   return result;*/
 }
 
-//----- (00424829) --------------------------------------------------------
-bool sub_424829(int pNumVertices, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, int uFaceID)
-{
-  //int v4; // edi@1
-  //BspRenderer_stru2 *v5; // ebx@1
-  int v6; // eax@3
-  int min_y; // esi@5
-  int max_y; // edx@5
-  //int v9; // ecx@6
-  int v10; // eax@12
-  //int v11; // edi@13
-  //int v12; // edx@18
-  int v13; // eax@22
-  //int v14; // edi@28
-  int v15; // ecx@29
-  //int v16; // edi@30
-  //int v17; // edx@35
-  int v18; // eax@39
-  int v19; // eax@44
-  int v20; // ecx@44
-  //int v21; // edi@45
-  int v22; // edi@46
-  //__int16 *v23; // ecx@47
-  int v24; // edx@48
-  //int v25; // eax@50
-  int v26; // eax@55
-  signed int v27; // edi@55
-  //int v28; // edx@56
-  int v29; // edx@57
-  //int v30; // eax@59
-  int v31; // eax@64
-  signed int v32; // edi@64
-  //int v33; // edx@65
-  int v34; // eax@66
-  int v35; // dx@66
-  __int16 v36; // dx@67
-  __int16 v37; // di@67
-  __int16 v38; // dx@67
-  //BspRenderer_stru2 *v39; // ecx@69
-  //int v40; // edx@69
-  //int v41; // edi@70
-  //__int16 *v42; // eax@76
-  //__int16 *v43; // eax@81
-  //__int16 *v45; // eax@87
-  int v46; // edx@87
-  //__int16 v47; // cx@88
-  //int v48; // eax@93
-  int v49; // esi@93
-  //__int16 *v50; // ecx@94
-  //int v51; // eax@95
-  //int v52; // eax@97
-  int v53; // [sp+Ch] [bp-34h]@44
-  int v54; // [sp+10h] [bp-30h]@0
-  int v55; // [sp+14h] [bp-2Ch]@12
-  //__int16 *v56; // [sp+14h] [bp-2Ch]@47
-  //__int16 v57; // [sp+14h] [bp-2Ch]@76
-  //__int16 v58; // [sp+14h] [bp-2Ch]@81
-  int v59; // [sp+14h] [bp-2Ch]@87
-  //BspRenderer_stru2 *v60; // [sp+18h] [bp-28h]@1
-  int v61; // [sp+1Ch] [bp-24h]@29
-  int v62; // [sp+20h] [bp-20h]@0
-  signed int v63; // [sp+24h] [bp-1Ch]@3
-  signed int v64; // [sp+28h] [bp-18h]@3
-  int v65; // [sp+2Ch] [bp-14h]@5
-  //int v66; // [sp+2Ch] [bp-14h]@39
-  //int v67; // [sp+30h] [bp-10h]@22
-  int v68; // [sp+34h] [bp-Ch]@12
-  int v69; // [sp+34h] [bp-Ch]@29
-  int v70; // [sp+34h] [bp-Ch]@46
-  int v71; // [sp+34h] [bp-Ch]@75
-  int v72; // [sp+34h] [bp-Ch]@80
-  //int v73; // [sp+38h] [bp-8h]@11
-  //int v74; // [sp+3Ch] [bp-4h]@1
-  //int a3a; // [sp+48h] [bp+8h]@76
-  //int a3b; // [sp+48h] [bp+8h]@87
-
-  //try graphic engine with function returning 1 always, and without
-  //return true;
-  if ( pNumVertices <= 1 )
-    return false;
-  min_y = stru_50B700._screen_space_y[0];
-  v65 = 0;
-  max_y = stru_50B700._screen_space_y[0];
-  if ( !stru_50B700.field_0 )
-  {
-    v63 = 1;
-    v64 = -1;
-  }
-  else 
-  {
-    v63 = -1;
-    v64 = 1;
-  }
-
-  for ( v6 = 1; v6 < pNumVertices; ++v6 )
-  {
-    if ( stru_50B700._screen_space_y[v6] >= min_y )
-    {
-      if ( stru_50B700._screen_space_y[v6] > max_y )
-        max_y = stru_50B700._screen_space_y[v6];
-    }
-    if ( stru_50B700._screen_space_y[v6] < min_y )
-    {
-      v65 = v6;
-      min_y = stru_50B700._screen_space_y[v6];
-    }
-  }
-  if ( max_y == min_y )
-    return false;
-
-  v10 = v65;
-  a2->_viewport_space_y = min_y;
-  a2->_viewport_space_w = max_y;
-  v55 = v65;
-
-  for ( v68 = 0; v68 < pNumVertices; ++v68 )
-  {
-    v10 += v64;
-    if ( v10 < pNumVertices )
-    {
-      if ( v10 < 0 )
-        v10 += pNumVertices;
-    }
-    else
-      v10 -= pNumVertices;
-    if ( stru_50B700._screen_space_y[v10] <= stru_50B700._screen_space_y[v65] )
-    {
-      v55 = v10;
-      v65 = v10;
-    }
-    if ( stru_50B700._screen_space_y[v10] == max_y )
-      break;
-  }
-  v13 = v55 + v64;
-  if ( v13 < pNumVertices )
-  {
-    if ( v13 < 0 )
-      v13 += pNumVertices;
-  }
-  else
-    v13 -= pNumVertices;
-  if ( stru_50B700._screen_space_y[v13] != stru_50B700._screen_space_y[v55] )
-  {
-    v62 = stru_50B700._screen_space_x[v55] << 16;
-    v54 = ((stru_50B700._screen_space_x[v13] - stru_50B700._screen_space_x[v55]) << 16) / (stru_50B700._screen_space_y[v13] - stru_50B700._screen_space_y[v55]);
-    a2->viewport_left_side[min_y] = LOWORD(stru_50B700._screen_space_x[v55]);
-  }
-  v15 = v65;
-  v61 = v65;
-
-  for ( v69 = 0; v69 < pNumVertices; ++v69 )
-  {
-    v15 += v63;
-    if ( v15 < pNumVertices )
-    {
-      if ( v15 < 0 )
-        v15 += pNumVertices;
-    }
-    else
-      v15 -= pNumVertices;
-    if ( stru_50B700._screen_space_y[v15] <= stru_50B700._screen_space_y[v65] )
-    {
-      v61 = v15;
-      v65 = v15;
-    }
-    if ( stru_50B700._screen_space_y[v15] == max_y )
-      break;
-  }
-  v18 = v63 + v61;
-  if ( v18 < pNumVertices )
-  {
-    if ( v18 < 0 )
-      v18 += pNumVertices;
-  }
-  else
-    v18 -= pNumVertices;
-  v19 = v18;
-  v20 = v61;
-  if ( stru_50B700._screen_space_y[v19] != stru_50B700._screen_space_y[v61] )
-  {
-    v61 = stru_50B700._screen_space_x[v20] << 16;
-    v53 = ((stru_50B700._screen_space_x[v19] - stru_50B700._screen_space_x[v20]) << 16) / stru_50B700._screen_space_y[v19] - stru_50B700._screen_space_y[v20];
-    a2->viewport_right_side[max_y] = LOWORD(stru_50B700._screen_space_x[v20]);
-  }
-  v22 = min_y;
-  if ( min_y <= max_y )
-  {
-    //v56 = &a2->array_3D8[v7];
-    //v23 = &a2->array_18[v7];
-    for ( v70 = min_y; v70 <= max_y; ++v70 )
-    {
-      v24 = v13;
-      if ( v22 >= stru_50B700._screen_space_y[v13] && v22 != max_y )
-      {
-        v13 = v64 + v13;
-        if ( v13 < pNumVertices )
-        {
-          if ( v13 < 0 )
-            v13 += pNumVertices;
-        }
-        else
-          v13 -= pNumVertices;
-        v26 = v13;
-        //v27 = stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24];
-        if ( stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24] > 0 )
-        {
-          v54 = ((stru_50B700._screen_space_x[v26] - stru_50B700._screen_space_x[v24]) << 16) / stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24];
-          v62 = stru_50B700._screen_space_x[v24] << 16;
-        }
-      }
-      v29 = v18;
-      if ( v70 >= stru_50B700._screen_space_y[v18] && v70 != max_y )
-      {
-        v18 += v63;
-        if ( v18 < pNumVertices )
-        {
-          if ( v18 < 0 )
-            v18 += pNumVertices;
-        }
-        else
-          v18 -= pNumVertices;
-        v31 = v18;
-        //v32 = stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29];
-        if ( stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29] > 0 )
-        {
-          v53 = ((stru_50B700._screen_space_x[v31] - stru_50B700._screen_space_x[v29]) << 16) / stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29];
-          v61 = stru_50B700._screen_space_x[v29] << 16;
-        }
-      }
-	  //v34 = (char *)a2->array_18 - (char *)a2->array_3D8;
-	  //v35 = *(__int16 *)((char *)&a2->array_3D8[v70] + v34);
-      //v35 = HIWORD(v62);
-      a2->viewport_left_side[v70] = HIWORD(v62);
-      a2->viewport_right_side[v70] = HIWORD(v61);
-      //v34 = &a2->array_3D8[v70];
-      //v35 = a2->array_3D8[v70];
-      if ( a2->viewport_left_side[v70] > a2->viewport_right_side[v70] )
-      {
-        v36 = a2->viewport_left_side[v70] ^ a2->viewport_right_side[v70];
-        v37 = a2->viewport_right_side[v70];
-        a2->viewport_left_side[v70] = v36;
-        v38 = v37 ^ v36;
-        a2->viewport_left_side[v70] ^= v38;
-        a2->viewport_right_side[v70] = v38;
-      }
-      //++v56;
-      v62 += v54;
-      v22 = v70 + 1;
-      v61 += v53;
-      //++v23;
-    }
-  }
-  if ( max_y < a3->_viewport_space_y )
-    return false;
-  if ( min_y > a3->_viewport_space_w )
-    return false;
-  if ( min_y < a3->_viewport_space_y )
-    min_y = a3->_viewport_space_y;
-  if ( max_y > a3->_viewport_space_w )
-    max_y = a3->_viewport_space_w;
-  if ( min_y <= max_y )
-  {
-    //a3a = (char *)a2 - (char *)a3;
-    //v42 = &a3->array_3D8[v7];
-    //v57 = *(__int16 *)((char *)v42 + a3a);
-    for ( v71 = min_y; v71 <= max_y; ++v71 )
-    {
-      if ( a2->viewport_left_side[v71] >= a3->viewport_left_side[v71] && a2->viewport_left_side[v71] <= a3->viewport_right_side[v71] )
-        break;
-      //++v57;
-      ++min_y;
-      //++v42;
-    }
-  }
-  if ( max_y < min_y )
-    return false;
-  //a3a = (char *)a2 - (char *)a3;
-  //v43 = &a3->array_3D8[v8];
-  //v58 = *(__int16 *)((char *)v43 + a3a);
-  for ( v72 = max_y; v72 >= min_y; --v72 )
-  {
-    if ( a2->viewport_right_side[v72] >= a3->viewport_left_side[v72] && a2->viewport_left_side[v72] <= a3->viewport_right_side[v72] )
-      break;
-    //--v58;
-    --max_y;
-    //--v43;
-    //v8 = v8;
-  }
-  if ( min_y >= max_y )
-    return false;
-  //a3b = (char *)a3 - (char *)a2;
-  v59 = min_y;
-  //v45 = &a2->array_18[v7];
-  
-  for ( v46 = max_y - min_y + 1; v46; --v46 )
-  {
-    //v47 = *(__int16 *)((char *)v45 + a3b);
-    if ( a2->viewport_left_side[v59] < a3->viewport_left_side[v59] )
-      a2->viewport_left_side[v59] = a3->viewport_left_side[v59];
-    if ( a2->viewport_right_side[v59] > a3->viewport_right_side[v59] )
-      a2->viewport_right_side[v59] = a3->viewport_right_side[v59];
-    ++v59;
-    //++v45;
-  }
-  a2->_viewport_space_y = min_y;
-  a2->_viewport_space_w = max_y;
-  a2->field_8 = a2->viewport_left_side[min_y];
-  //v48 = a2->viewport_right_side[v7];
-  a2->field_10 = min_y;
-  a2->field_14 = min_y;
-  a2->field_C = a2->viewport_right_side[min_y];
-  v49 = min_y + 1;
-  if ( v49 <= max_y )
-  {
-    //v50 = &a2->array_3D8[v49];
-    for ( v49; v49 <= max_y; ++v49 )
-    {
-      //v51 = a2->array_18[v49];
-      if ( a2->viewport_left_side[v49] < a2->field_8 )
-      {
-        a2->field_8 = a2->viewport_left_side[v49];
-        a2->field_10 = v49;
-      }
-      if ( a2->viewport_right_side[v49] > a2->field_C )
-      {
-        a2->field_C = a2->viewport_right_side[v49];
-        a2->field_14 = v49;
-      }
-      //++v50;
-    }
-  }
-  return true;
-}
 // 50B700: using guessed type int stru_50B700.field_0;
 
 //----- (00424CD7) --------------------------------------------------------