diff mm7_2.cpp @ 576:1bd8758f50b8

Слияние
author Ritor1
date Mon, 04 Mar 2013 09:22:38 +0600
parents 0ca16f606be8
children b8339415fa98 9caf59edb1ee
line wrap: on
line diff
--- a/mm7_2.cpp	Mon Mar 04 09:22:29 2013 +0600
+++ b/mm7_2.cpp	Mon Mar 04 09:22:38 2013 +0600
@@ -21,7 +21,7 @@
 #include "Viewport.h"
 #include "FrameTableInc.h"
 #include "Math.h"
-#include "LayingItem.h"
+#include "SpriteObject.h"
 #include "ObjectList.h"
 #include "Chest.h"
 #include "PaletteManager.h"
@@ -29,6 +29,7 @@
 #include "SaveLoad.h"
 #include "stru123.h"
 #include "stru287.h"
+#include "stru176.h"
 #include "Time.h"
 #include "IconFrameTable.h"
 #include "GUIProgressBar.h"
@@ -53,6 +54,7 @@
 #include "texts.h"
 
 #include "mm7_data.h"
+#include "MM7.h"
 
 
 //----- (004B4F4F) --------------------------------------------------------
@@ -148,141 +150,144 @@
   v30 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
   sprintf(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[605], pParty->uFine);
   _this.DrawTitleText(pFontArrus, 0, 0x104u, v30, pTmpBuf, 3u);
-  if ( dword_F8B19C == 1 )
-  {
-    v11 = 1;
-    pOutString = 0;
-    pShopOptions[0] = pGlobalTXT_LocalizationStrings[604];
-    if ( pParty->uFine )
-    {
-      pShopOptions[1] = pGlobalTXT_LocalizationStrings[603];
-      v11 = 2;
-    }
-    for ( i = 0; i < v11; ++i )
-    {
-      v13 = pFontArrus->CalcTextHeight(pShopOptions[i], &_this, 0, 0);
-      pOutString = (GUIFont *)((char *)pOutString + v13);
-    }
-    v29 = (100 - (signed int)pOutString) / v11;
-    v14 = pDialogueWindow;
-    v15 = 80 - v11 * (100 - (signed int)pOutString) / v11 - (signed int)pOutString;
-    v16 = v15 - HIDWORD(v15);
-    LODWORD(v15) = pDialogueWindow->pStartingPosActiveItem;
-    HIDWORD(v15) = v15 + pDialogueWindow->pNumPresenceButton;
-    v17 = (v16 >> 1) - v29 / 2 + 158;
-    v18 = -pDialogueWindow->pNumPresenceButton < 0;
-    pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem;
-    if ( v18 ^ __OFSUB__((int)v15, HIDWORD(v15)) )
-    {
-      v31 = 2;
-      v19 = pShopOptions;
-      do
-      {
-        v20 = v14->GetControl((unsigned int)pOutString);
-        v21 = v20;
-        v20->uY = v29 + v17;
-        v22 = pFontArrus->CalcTextHeight(*v19, &_this, 0, 0);
-        v23 = v21->uY;
-        v21->uHeight = v22;
-        v17 = v23 + v22 - 1;
-        v21->uW = v17;
-        v24 = v30;
-        if ( pDialogueWindow->pCurrentPosActiveItem != v31 )
-          v24 = v28;
-        _this.DrawTitleText(pFontArrus, 0, v23, v24, *v19, 3u);
-        v14 = pDialogueWindow;
-        ++v31;
-        ++v19;
-        pOutString = (GUIFont *)((char *)pOutString + 1);
-      }
-      while ( (signed int)pOutString < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
-    }
-  }
-  else
-  {
-    if ( dword_F8B19C != 99 )
-    {
-      if ( dword_F8B19C != 100 )
-        return;
-      v0 = window_SpeakInHouse;
-      if ( window_SpeakInHouse->field_40 == 1 )
-      {
-        sprintf(pTmpBuf, "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]);
-        _this.DrawTitleText(pFontArrus, 0, 0x92u, v30, pTmpBuf, 3u);
-        _this.DrawTitleText(pFontArrus, 0, 0xBAu, v28, (const char *)pKeyActionMap->pPressedKeysBuffer, 3u);
-        v3 = pFontArrus;
-        v4 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
-        _this.DrawFlashingInputCursor(v4 / 2 + 80, 185, v3);
-        return;
-      }
-      if ( window_SpeakInHouse->field_40 == 2 )
-      {
-        v1 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
-        v2 = v1;
-        if ( v1 <= 0 )
-        {
-LABEL_8:
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-          /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-          {
-            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
-            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
-            *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-            ++pMessageQueue_50CBD0->uNumMessages;
-          }*/
-          return;
-        }
-        if ( v1 > pParty->uNumGold )
-        {
-          HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
-          v2 = pParty->uNumGold;
-        }
-        if ( v2 > pParty->uFine )
-          v2 = pParty->uFine;
-        Party::TakeGold(v2);
-        pParty->uFine -= v2;
-        if ( pParty->uFine < 0 )
-          pParty->uFine = 0;
-        if ( uActiveCharacter )
-          pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0);
-        v0 = window_SpeakInHouse;
-      }
-      else
-      {
-        if ( window_SpeakInHouse->field_40 != 3 )
-          return;
-      }
-      v0->field_40 = 0;
-      goto LABEL_8;
-    }
-    v5 = &pMonsterStats->pInfos[word_F8B1A0];
-    v6 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-    v7 = v5->pName;
-    v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-    sprintf(pTmpBuf, &byte_4F0F98, v8, v7, v6);
-    sprintf(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * v5->uLevel);
-    ptr_F8B1E8 = pTmpBuf2;
-    memcpy(&a1, pDialogueWindow, sizeof(a1));
-    w.uFrameWidth = 458;
-    w.uFrameZ = 457;
-    pOutString = pFontArrus;
-    v9 = pFontArrus->CalcTextHeight(pTmpBuf2, &w, 13, 0) + 7;
-    if ( 352 - v9 < 8 )
-    {
-      pOutString = pFontCreate;
-      v9 = pFontCreate->CalcTextHeight(ptr_F8B1E8, &w, 13, 0) + 7;
-    }
-
-    auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0);
-    pRenderer->_4A6A68(
-      8u,
-      352 - v9,
-      pTex,
-      (pTex ? pTex->uTextureHeight : 26) - v9);
-    pRenderer->DrawTextureIndexed(8u, 347 - v9, pTexture_591428);
-    v10 = FitTextInAWindow(ptr_F8B1E8, pOutString, &w, 0xDu, 0);
-    a1.DrawText(pOutString, 13, 354 - v9, 0, v10, 0, 0, 0);
-  }
+  switch(dword_F8B19C)
+  {
+	case 1:
+		{
+		v11 = 1;
+		pOutString = 0;
+		pShopOptions[0] = pGlobalTXT_LocalizationStrings[604];
+		if ( pParty->uFine )
+		{
+			pShopOptions[1] = pGlobalTXT_LocalizationStrings[603];
+			v11 = 2;
+		}
+		for ( i = 0; i < v11; ++i )
+		{
+			v13 = pFontArrus->CalcTextHeight(pShopOptions[i], &_this, 0, 0);
+			pOutString = (GUIFont *)((char *)pOutString + v13);
+		}
+		v29 = (100 - (signed int)pOutString) / v11;
+		v14 = pDialogueWindow;
+		v15 = 80 - v11 * (100 - (signed int)pOutString) / v11 - (signed int)pOutString;
+		v16 = v15 - HIDWORD(v15);
+		LODWORD(v15) = pDialogueWindow->pStartingPosActiveItem;
+		HIDWORD(v15) = v15 + pDialogueWindow->pNumPresenceButton;
+		v17 = (v16 >> 1) - v29 / 2 + 158;
+		v18 = -pDialogueWindow->pNumPresenceButton < 0;
+		pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem;
+		if ( v18 ^ __OFSUB__((int)v15, HIDWORD(v15)) )
+		{
+			v31 = 2;
+			v19 = pShopOptions;
+			do
+			{
+				v20 = v14->GetControl((unsigned int)pOutString);
+				v21 = v20;
+				v20->uY = v29 + v17;
+				v22 = pFontArrus->CalcTextHeight(*v19, &_this, 0, 0);
+				v23 = v21->uY;
+				v21->uHeight = v22;
+				v17 = v23 + v22 - 1;
+				v21->uW = v17;
+				v24 = v30;
+				if ( pDialogueWindow->pCurrentPosActiveItem != v31 )
+					v24 = v28;
+				_this.DrawTitleText(pFontArrus, 0, v23, v24, *v19, 3u);
+				v14 = pDialogueWindow;
+				++v31;
+				++v19;
+				pOutString = (GUIFont *)((char *)pOutString + 1);
+			}
+			while ( (signed int)pOutString < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
+		}
+		break;
+		}
+	case 99:
+		{
+		v5 = &pMonsterStats->pInfos[word_F8B1A0];
+		v6 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+		v7 = v5->pName;
+		v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+		sprintf(pTmpBuf, &byte_4F0F98, v8, v7, v6);
+		sprintf(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * v5->uLevel);
+		ptr_F8B1E8 = pTmpBuf2;
+		memcpy(&a1, pDialogueWindow, sizeof(a1));
+		w.uFrameWidth = 458;
+		w.uFrameZ = 457;
+		pOutString = pFontArrus;
+		v9 = pFontArrus->CalcTextHeight(pTmpBuf2, &w, 13, 0) + 7;
+		if ( 352 - v9 < 8 )
+		{
+			pOutString = pFontCreate;
+			v9 = pFontCreate->CalcTextHeight(ptr_F8B1E8, &w, 13, 0) + 7;
+		}
+
+		auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0);
+		pRenderer->_4A6A68(8u, 352 - v9, pTex, (pTex ? pTex->uTextureHeight : 26) - v9);
+		pRenderer->DrawTextureIndexed(8u, 347 - v9, pTexture_591428);
+		v10 = FitTextInAWindow(ptr_F8B1E8, pOutString, &w, 0xDu, 0);
+		a1.DrawText(pOutString, 13, 354 - v9, 0, v10, 0, 0, 0);
+		break;
+		}
+	case 100:
+		{
+		v0 = window_SpeakInHouse;
+		if ( window_SpeakInHouse->field_40 == 1 )
+		{
+			sprintf(pTmpBuf, "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]);
+			_this.DrawTitleText(pFontArrus, 0, 0x92u, v30, pTmpBuf, 3u);
+			_this.DrawTitleText(pFontArrus, 0, 0xBAu, v28, (const char *)pKeyActionMap->pPressedKeysBuffer, 3u);
+			v3 = pFontArrus;
+			v4 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
+			_this.DrawFlashingInputCursor(v4 / 2 + 80, 185, v3);
+			return;
+		}
+		if ( window_SpeakInHouse->field_40 == 2 )
+		{
+			v1 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
+			v2 = v1;
+			if ( v1 <= 0 )
+			{
+			//LABEL_8:
+				pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+				/*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+				{
+				pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
+				pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
+				*(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+				++pMessageQueue_50CBD0->uNumMessages;
+				}*/
+				return;
+			}
+			if ( v1 > pParty->uNumGold )
+			{
+				HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
+				v2 = pParty->uNumGold;
+			}
+			if ( v2 > pParty->uFine )
+				v2 = pParty->uFine;
+			Party::TakeGold(v2);
+			pParty->uFine -= v2;
+			if ( pParty->uFine < 0 )
+				pParty->uFine = 0;
+			if ( uActiveCharacter )
+				pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0);
+			v0 = window_SpeakInHouse;
+		}
+		if ( window_SpeakInHouse->field_40 == 3 )
+		{
+			v0->field_40 = 0;
+			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+		}
+		break;
+		}
+	default:
+		{
+		break;
+		}
+  }
+  return;
 }
 // F8B19C: using guessed type int dword_F8B19C;
 // F8B1A0: using guessed type __int16 word_F8B1A0;
@@ -314,105 +319,127 @@
   *(int *)v14 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
   sprintf(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[25], pParty->uNumGoldInBank);
   _this.DrawTitleText(pFontArrus, 0, 0xDCu, v14[0], pTmpBuf, 3u);
-  if ( dword_F8B19C != 1 )
-  {
-    if ( dword_F8B19C == 7 )
-    {
-      v0 = window_SpeakInHouse;
-      if ( window_SpeakInHouse->field_40 != 1 )
-      {
-        v1 = window_SpeakInHouse->field_40 - 2;
-        if ( window_SpeakInHouse->field_40 == 2 )
-        {
-          v6 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
-          v7 = v6;
-          if ( !v6 )
-          {
-LABEL_17:
-            pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-            /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-            {
-              pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
-              pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
-              *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-              ++pMessageQueue_50CBD0->uNumMessages;
-            }*/
-            return;
-          }
-          if ( v6 > pParty->uNumGold )
-          {
-            HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
-            v7 = pParty->uNumGold;
-          }
-          if ( v7 )
-          {
-            Party::TakeGold(v7);
-            pParty->uNumGoldInBank += v7;
-            if ( uActiveCharacter )
-              pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0);
-          }
-          v0 = window_SpeakInHouse;
-LABEL_16:
-          v0->field_40 = 0;
-          goto LABEL_17;
-        }
-LABEL_15:
-        if ( v1 != 1 )
-          return;
-        goto LABEL_16;
-      }
-      v11 = pGlobalTXT_LocalizationStrings[112];
-      v10 = pGlobalTXT_LocalizationStrings[60];
-    }
-    else
-    {
-      if ( dword_F8B19C != 8 )
-        return;
-      v0 = window_SpeakInHouse;
-      if ( window_SpeakInHouse->field_40 != 1 )
-      {
-        v1 = window_SpeakInHouse->field_40 - 2;
-        if ( window_SpeakInHouse->field_40 == 2 )
-        {
-          window_SpeakInHouse->field_40 = 0;
-          v2 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
-          v3 = v2;
-          if ( v2 )
-          {
-            if ( v2 > pParty->uNumGoldInBank )
-            {
-              HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
-              v3 = pParty->uNumGoldInBank;
-            }
-            if ( v3 )
-            {
-              Party::SetGold(pParty->uNumGold + v3);
-              pParty->uNumGoldInBank -= v3;
-            }
-          }
-          goto LABEL_17;
-        }
-        goto LABEL_15;
-      }
-      v11 = pGlobalTXT_LocalizationStrings[112];
-      v10 = pGlobalTXT_LocalizationStrings[244];
-    }
-    sprintf(pTmpBuf, "%s\n%s", v10, v11);
-    _this.DrawTitleText(pFontArrus, 0, 0x92u, v14[0], pTmpBuf, 3u);
-    _this.DrawTitleText(pFontArrus, 0, 0xBAu, v13[0], (const char *)pKeyActionMap->pPressedKeysBuffer, 3u);
-    v4 = pFontArrus;
-    v5 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
-    _this.DrawFlashingInputCursor(v5 / 2 + 80, 185, v4);
-    return;
-  }
-  v8 = v14[0];
-  if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
-    v8 = v13[0];
-  _this.DrawTitleText(pFontArrus, 0, 0x92u, v8, pGlobalTXT_LocalizationStrings[60], 3u);
-  v9 = v14[0];
-  if ( pDialogueWindow->pCurrentPosActiveItem != 3 )
-    v9 = v13[0];
-  _this.DrawTitleText(pFontArrus, 0, 0xB0u, v9, pGlobalTXT_LocalizationStrings[244], 3u);
+  switch(dword_F8B19C)
+  {
+	case 1:
+		{
+		v8 = v14[0];
+		if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
+			v8 = v13[0];
+		_this.DrawTitleText(pFontArrus, 0, 0x92u, v8, pGlobalTXT_LocalizationStrings[60], 3u);
+		v9 = v14[0];
+		if ( pDialogueWindow->pCurrentPosActiveItem != 3 )
+			v9 = v13[0];
+		_this.DrawTitleText(pFontArrus, 0, 0xB0u, v9, pGlobalTXT_LocalizationStrings[244], 3u);
+		break;
+		}
+	case 7:
+		{
+		v0 = window_SpeakInHouse;
+		if ( window_SpeakInHouse->field_40 != 1 )
+		{
+			v1 = window_SpeakInHouse->field_40 - 2;
+			if ( window_SpeakInHouse->field_40 == 2 )
+			{
+				v6 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
+				v7 = v6;
+				if ( !v6 )
+				{
+//LABEL_17:
+					pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+					/*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+					{
+						pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
+						pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
+						*(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+						++pMessageQueue_50CBD0->uNumMessages;
+					}*/
+					return;
+				}
+				if ( v6 > pParty->uNumGold )
+				{
+					HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
+					v7 = pParty->uNumGold;
+				}
+				if ( v7 )
+				{
+					Party::TakeGold(v7);
+					pParty->uNumGoldInBank += v7;
+					if ( uActiveCharacter )
+						pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0);
+				}
+				v0 = window_SpeakInHouse;
+				v0->field_40 = 0;
+				pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+				return;
+			}
+			if ( v1 != 1 )
+				return;
+			v0->field_40 = 0;
+			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+			return;      
+		}
+		v11 = pGlobalTXT_LocalizationStrings[112];
+		v10 = pGlobalTXT_LocalizationStrings[60];
+		sprintf(pTmpBuf, "%s\n%s", v10, v11);
+		_this.DrawTitleText(pFontArrus, 0, 0x92u, v14[0], pTmpBuf, 3u);
+		_this.DrawTitleText(pFontArrus, 0, 0xBAu, v13[0], (const char *)pKeyActionMap->pPressedKeysBuffer, 3u);
+		v4 = pFontArrus;
+		v5 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
+		_this.DrawFlashingInputCursor(v5 / 2 + 80, 185, v4);
+		break;
+		}
+
+	case 8:
+		{
+		v0 = window_SpeakInHouse;
+		if ( window_SpeakInHouse->field_40 != 1 )
+		{
+			v1 = window_SpeakInHouse->field_40 - 2;
+			if ( window_SpeakInHouse->field_40 == 2 )
+			{
+				window_SpeakInHouse->field_40 = 0;
+				v2 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
+				v3 = v2;
+				if ( v2 )
+				{
+					if ( v2 > pParty->uNumGoldInBank )
+					{
+						HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
+						v3 = pParty->uNumGoldInBank;
+					}
+					if ( v3 )
+					{
+						Party::SetGold(pParty->uNumGold + v3);
+						pParty->uNumGoldInBank -= v3;
+					}
+				}
+				pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+				return;
+			}
+			if ( v1 != 1 )
+				return;
+			v0->field_40 = 0;
+			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+			return;  
+		}
+		v11 = pGlobalTXT_LocalizationStrings[112];
+		v10 = pGlobalTXT_LocalizationStrings[244];
+		sprintf(pTmpBuf, "%s\n%s", v10, v11);
+		_this.DrawTitleText(pFontArrus, 0, 0x92u, v14[0], pTmpBuf, 3u);
+		_this.DrawTitleText(pFontArrus, 0, 0xBAu, v13[0], (const char *)pKeyActionMap->pPressedKeysBuffer, 3u);
+		v4 = pFontArrus;
+		v5 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
+		_this.DrawFlashingInputCursor(v5 / 2 + 80, 185, v4);
+		return;
+		break;
+		}
+
+	default:
+		{
+		break;
+		}
+  }
 }
 // F8B19C: using guessed type int dword_F8B19C;
 
@@ -543,41 +570,57 @@
     v7 = 1;
     v83 = 1;
   }
-  if ( dword_F8B19C > 101 )
-  {
-    if ( dword_F8B19C == 102 )
-    {
-      v65 = pFontArrus;
-      pOutString = pFontArrus;
-      strcpy(pTmpBuf, pNPCTopics[354].pText);
-      v78.uFrameWidth = 460;
-      v78.uFrameZ = 452;
-      v62 = v65->CalcTextHeight(pTmpBuf, &v78, 12, 0) + 7;
-      if ( 352 - v62 < 8 )
-      {
-        pOutString = pFontCreate;
-        v62 = pFontCreate->CalcTextHeight(pTmpBuf, &v78, 12, 0) + 7;
-      }
-
-      auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0);
-      pRenderer->_4A6A68(
-        8u,
-        352 - v62,
-        pTex,
-        (pTex ? pTex->uTextureHeight : 26) - v62);
-
-      pRenderer->DrawTextureIndexed(8u, 347 - v62, pTexture_591428);
-      v73 = 0;
-      v70 = 0;
-      v68 = 0;
-      v63 = FitTextInAWindow(pTmpBuf, pOutString, &v78, 0xCu, 0);
-      v64 = pOutString;
-    }
-    else
-    {
-      if ( dword_F8B19C != 103 )
-      {
-        if ( dword_F8B19C != 104 || pArcomageGame->bGameInProgress == 1 )
+  switch(dword_F8B19C)
+  {
+	case 102:
+		{
+		v65 = pFontArrus;
+		pOutString = pFontArrus;
+		strcpy(pTmpBuf, pNPCTopics[354].pText);
+		v78.uFrameWidth = 460;
+		v78.uFrameZ = 452;
+		v62 = v65->CalcTextHeight(pTmpBuf, &v78, 12, 0) + 7;
+		if ( 352 - v62 < 8 )
+		{
+			pOutString = pFontCreate;
+			v62 = pFontCreate->CalcTextHeight(pTmpBuf, &v78, 12, 0) + 7;
+		}
+
+		auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0);
+		pRenderer->_4A6A68(8u, 352 - v62, pTex, (pTex ? pTex->uTextureHeight : 26) - v62);
+
+		pRenderer->DrawTextureIndexed(8u, 347 - v62, pTexture_591428);
+		v73 = 0;
+		v70 = 0;
+		v68 = 0;
+		v63 = FitTextInAWindow(pTmpBuf, pOutString, &v78, 0xCu, 0);
+		v64 = pOutString;
+		window_SpeakInHouse->DrawText(v64, 12, 354 - v62, 0, v63, v68, v70, v73);
+		break;
+		}
+	case 103:
+		{
+		strcpy(pTmpBuf, pNPCTopics[(uint)window_SpeakInHouse->ptr_1C + 247].pText);
+		v78.uFrameWidth = 460;
+		v78.uFrameZ = 452;
+		v61 = pFontArrus->CalcTextHeight(pTmpBuf, &v78, 12, 0);
+		v62 = v61 + 7;
+
+		auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : nullptr);
+		pRenderer->_4A6A68(8u, 352 - (v61 + 7), pTex, (pTex ? pTex->uTextureHeight : 26) - (v61 + 7));
+
+		pRenderer->DrawTextureIndexed(8u, 347 - v62, pTexture_591428);
+		v73 = 0;
+		v70 = 0;
+		v68 = 0;
+		v63 = FitTextInAWindow(pTmpBuf, pFontArrus, &v78, 0xCu, 0);
+		v64 = pFontArrus;
+		window_SpeakInHouse->DrawText(v64, 12, 354 - v62, 0, v63, v68, v70, v73);
+		break;
+		}
+	case 104:
+		{
+		if ( pArcomageGame->bGameInProgress == 1 )
           return;
         v26 = pTmpBuf;
         if ( pArcomageGame->uGameResult )
@@ -592,42 +635,16 @@
           v72 = pGlobalTXT_LocalizationStrings[639];// A tie!
         }
         strcpy(pTmpBuf, v72);
-LABEL_97:
+//LABEL_97:
         v71 = 3;
         v69 = v26;
         v67 = v84[0];
         v66 = (174 - pFontArrus->CalcTextHeight(v26, &v79, 0, 0)) / 2 + 138;
-        goto LABEL_98;
-      }
-      strcpy(pTmpBuf, pNPCTopics[(uint)window_SpeakInHouse->ptr_1C + 247].pText);
-      v78.uFrameWidth = 460;
-      v78.uFrameZ = 452;
-      v61 = pFontArrus->CalcTextHeight(pTmpBuf, &v78, 12, 0);
-      v62 = v61 + 7;
-
-      auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : nullptr);
-      pRenderer->_4A6A68(
-        8u,
-        352 - (v61 + 7),
-        pTex,
-        (pTex ? pTex->uTextureHeight : 26) - (v61 + 7));
-
-      pRenderer->DrawTextureIndexed(8u, 347 - v62, pTexture_591428);
-      v73 = 0;
-      v70 = 0;
-      v68 = 0;
-      v63 = FitTextInAWindow(pTmpBuf, pFontArrus, &v78, 0xCu, 0);
-      v64 = pFontArrus;
-    }
-    window_SpeakInHouse->DrawText(v64, 12, 354 - v62, 0, v63, v68, v70, v73);
-    return;
-  }
-  if ( dword_F8B19C != 101 )
-  {
-    if ( dword_F8B19C != 1 )
-    {
-      if ( dword_F8B19C == 15 )
-      {
+        v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71);
+		break;
+		}
+	case 15:
+		{
         if ( pParty->uNumGold >= (unsigned int)pOutString )
         {
           Party::TakeGold((unsigned int)pOutString);
@@ -650,96 +667,106 @@
           ++pMessageQueue_50CBD0->uNumMessages;
           return;
         }
-      }
-      else
-      {
-        if ( dword_F8B19C != 16 )
-        {
-          if ( dword_F8B19C != 96 || !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
-            return;
-          v8 = pDialogueWindow;
-          *(float *)&v89 = 0.0;
-
-          //v9 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0);
-          v9 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
-
-          pOutString = (GUIFont *)(v9 * (100 - v85->GetMerchant()) / 100);
-          if ( (signed int)pOutString < v9 / 3 )
-            pOutString = (GUIFont *)(v9 / 3);
-          v10 = v8->pStartingPosActiveItem;
-          v11 = v10 + v8->pNumPresenceButton;
-          v86 = 0;
-          if ( (signed int)v10 < v11 )
-          {
-            do
-            {
-              v12 = v8->GetControl(v10)->uControlParam - 36;
-              if ( byte_4ED970_skill_learn_ability_by_class_table[v85->classType][v12] && !v85->pActiveSkills[v12] )
-              {
-                v13 = pFontArrus->CalcTextHeight(pSkillNames[v12], &v79, 0, 0);
-                v89 += v13;
-                ++v86;
-              }
-              ++v10;
-            }
-            while ( (signed int)v10 < v8->pStartingPosActiveItem + v8->pNumPresenceButton );
-            if ( v86 )
-            {
-              sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], pOutString);
-              v79.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
-              pOutString = (GUIFont *)((149 - v89) / v86);
-              if ( (149 - v89) / v86 > 32 )
-                pOutString = (GUIFont *)32;
-              v14 = (149 - v86 * (signed int)pOutString - v89) / 2 - (signed int)pOutString / 2 + 162;
-              v89 = v8->pStartingPosActiveItem;
-              v83 = v14;
-              if ( v89 < v89 + v8->pNumPresenceButton )
-              {
-                v86 = 2;
-                do
-                {
-                  v15 = v8->GetControl(v89);
-                  v16 = v15;
-                  v17 = v15->uControlParam - 36;
-                  if ( !byte_4ED970_skill_learn_ability_by_class_table[v85->classType][v17] || v85->pActiveSkills[v17] )
-                  {
-                    v16->uW = 0;
-                    v16->uHeight = 0;
-                    v16->uY = 0;
-                  }
-                  else
-                  {
-                    v18 = pSkillNames[v17];
-                    v16->uY = (unsigned int)((char *)pOutString + v83);
-                    Str[1] = v18;
-                    v19 = pFontArrus->CalcTextHeight(v18, &v79, 0, 0);
-                    v20 = v16->uY;
-                    v21 = v86;
-                    v16->uHeight = v19;
-                    v22 = v19 + v20 - 1;
-                    v16->uW = v22;
-                    v83 = v22;
-                    v23 = v84[0];
-                    if ( pDialogueWindow->pCurrentPosActiveItem != v21 )
-                      v23 = v81;
-                    v79.DrawTitleText(pFontArrus, 0, v20, v23, Str[1], 3u);
-                  }
-                  v24 = v8->pNumPresenceButton;
-                  ++v89;
-                  v25 = v8->pStartingPosActiveItem + v24;
-                  ++v86;
-                }
-                while ( v89 < v25 );
-              }
-              return;
-            }
-          }
-          v26 = pTmpBuf;
-          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v85->pName, pClassNames[v85->classType]);
-          strcat(pTmpBuf, "\n \n");
-          strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
-          goto LABEL_97;
-        }
+		ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
+        HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 4);
+        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0);
+		break;
+		}
+	case 96:
+		{
+		if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
+			return;
+		v8 = pDialogueWindow;
+		*(float *)&v89 = 0.0;
+
+		//v9 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0);
+		v9 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
+
+		pOutString = (GUIFont *)(v9 * (100 - v85->GetMerchant()) / 100);
+		if ( (signed int)pOutString < v9 / 3 )
+			pOutString = (GUIFont *)(v9 / 3);
+		v10 = v8->pStartingPosActiveItem;
+		v11 = v10 + v8->pNumPresenceButton;
+		v86 = 0;
+		if ( (signed int)v10 < v11 )
+		{
+			do
+			{
+				v12 = v8->GetControl(v10)->uControlParam - 36;
+				if ( byte_4ED970_skill_learn_ability_by_class_table[v85->classType][v12] && !v85->pActiveSkills[v12] )
+				{
+					v13 = pFontArrus->CalcTextHeight(pSkillNames[v12], &v79, 0, 0);
+					v89 += v13;
+					++v86;
+				}
+				++v10;
+			}
+			while ( (signed int)v10 < v8->pStartingPosActiveItem + v8->pNumPresenceButton );
+			if ( v86 )
+			{
+				sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], pOutString);
+				v79.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
+				pOutString = (GUIFont *)((149 - v89) / v86);
+				if ( (149 - v89) / v86 > 32 )
+					pOutString = (GUIFont *)32;
+				v14 = (149 - v86 * (signed int)pOutString - v89) / 2 - (signed int)pOutString / 2 + 162;
+				v89 = v8->pStartingPosActiveItem;
+				v83 = v14;
+				if ( v89 < v89 + v8->pNumPresenceButton )
+				{
+					v86 = 2;
+					do
+					{
+						v15 = v8->GetControl(v89);
+						v16 = v15;
+						v17 = v15->uControlParam - 36;
+						if ( !byte_4ED970_skill_learn_ability_by_class_table[v85->classType][v17] || v85->pActiveSkills[v17] )
+						{
+							v16->uW = 0;
+							v16->uHeight = 0;
+							v16->uY = 0;
+						}
+						else
+						{
+							v18 = pSkillNames[v17];
+							v16->uY = (unsigned int)((char *)pOutString + v83);
+							Str[1] = v18;
+							v19 = pFontArrus->CalcTextHeight(v18, &v79, 0, 0);
+							v20 = v16->uY;
+							v21 = v86;
+							v16->uHeight = v19;
+							v22 = v19 + v20 - 1;
+							v16->uW = v22;
+							v83 = v22;
+							v23 = v84[0];
+							if ( pDialogueWindow->pCurrentPosActiveItem != v21 )
+								v23 = v81;
+							v79.DrawTitleText(pFontArrus, 0, v20, v23, Str[1], 3u);
+						}
+						v24 = v8->pNumPresenceButton;
+						++v89;
+						v25 = v8->pStartingPosActiveItem + v24;
+						++v86;
+					}
+					while ( v89 < v25 );
+				}
+				return;
+			}
+		}
+		v26 = pTmpBuf;
+		sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v85->pName, pClassNames[v85->classType]);
+		strcat(pTmpBuf, "\n \n");
+		strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
+		v71 = 3;
+		v69 = v26;
+		v67 = v84[0];
+		v66 = (174 - pFontArrus->CalcTextHeight(v26, &v79, 0, 0)) / 2 + 138;
+		v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71);
+		return;
+		break;
+		}
+	case 16:
+		{
         *(_QWORD *)Str = pParty->uNumFoodRations;
         //if ( (double)pParty->uNumFoodRations >= p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C] )
         if ( (double)pParty->uNumFoodRations >= p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier )
@@ -747,7 +774,8 @@
           ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2u);
           if ( uActiveCharacter )
             pPlayers[uActiveCharacter]->PlaySound(SPEECH_67, 0);
-          goto LABEL_43;
+          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0);
+          return;
         }
         if ( pParty->uNumGold >= v7 )
         {
@@ -756,172 +784,193 @@
           pParty->uNumFoodRations = (signed __int64)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
           HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 3);
           v5 = 1;
-LABEL_43:
+//LABEL_43:
           pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0);
           return;
           //goto LABEL_51;
         }
-      }
-      ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
-      HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 4);
-      goto LABEL_43;
-    }
-    if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
-      return;
-    v28 = *(int *)v84;
-    if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
-      v28 = v81;
-    sprintf(Dest, format_4E2DC8, v28);
-    sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[178], pOutString);
-    strcat(Dest, pTmpBuf2);
-    v90 = pFontArrus->CalcTextHeight(Dest, &v79, 0, 0);
-    strcat(Dest, "\n \n");
-    v29 = *(int *)v84;
-    if ( pDialogueWindow->pCurrentPosActiveItem != 3 )
-      v29 = v81;
-    sprintf(a1, format_4E2DC8, v29);
-    sprintf(pTmpBuf2,
-      pGlobalTXT_LocalizationStrings[86],
-      //(signed __int64)p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C],
-      (signed __int64)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier,
-      v83);
-    strcat(a1, pTmpBuf2);
-    v88 = pFontArrus->CalcTextHeight(a1, &v79, 0, 0);
-    strcat(a1, "\n \n");
-    v30 = *(int *)v84;
-    if ( pDialogueWindow->pCurrentPosActiveItem != 4 )
-      v30 = v81;
-    sprintf(v77, format_4E2DC8, v30);
-    strcat(v77, pGlobalTXT_LocalizationStrings[160]);
-    v82 = pFontArrus->CalcTextHeight(v77, &v79, 0, 0);
-    strcat(v77, "\n \n");
-    v75[0] = 0;
-    v87 = 0;
-    v31 = (signed int)window_SpeakInHouse->ptr_1C;
-    if ( v31 >= 108 && v31 <= 120 )
-    {
-      v32 = *(int *)v84;
-      if ( pDialogueWindow->pCurrentPosActiveItem != 5 )
-        v32 = v81;
-      sprintf(v75, format_4E2DC8, v32);
-      strcat(v75, pGlobalTXT_LocalizationStrings[611]);
-      v87 = pFontArrus->CalcTextHeight(v75, &v79, 0, 0);
-    }
-    v33 = pDialogueWindow;
-    Str[1] = (char *)pDialogueWindow;
-    v34 = pDialogueWindow->pStartingPosActiveItem;
-    v35 = v34 + pDialogueWindow->pNumPresenceButton;
-    v36 = LOBYTE(pFontArrus->uFontHeight) - 3;
-    v37 = -pDialogueWindow->pNumPresenceButton < 0;
-    pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem;
-    if ( !(v37 ^ __OFSUB__(v34, v35)) )
-    {
-LABEL_75:
-      sprintf(pTmpBuf, "%s%s%s%s", &Dest, &a1, &v77, &v75);
-      v71 = 3;
-      v69 = pTmpBuf;
-      v67 = 0;
-      v66 = 146;
-LABEL_98:
-      v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71);
-      return;
-    }
-    while ( 1 )
-    {
-      v38 = v33->GetControl((unsigned int)pOutString);
-      if ( v38->uControlParam == 15 )
-      {
-        v46 = v90;
-        v38->uHeight = v90;
-        v38->uY = 146;
-        v41 = v46 + 145;
-        goto LABEL_73;
-      }
-      if ( v38->uControlParam == 16 )
-      {
-        v44 = v88;
-        v45 = v90 + v36 + 146;
-        v38->uHeight = v88;
-        v38->uY = v45;
-        v41 = v45 + v44 - 1;
-        goto LABEL_73;
-      }
-      if ( v38->uControlParam == 96 )
-        break;
-      if ( v38->uControlParam == 101 )
-      {
-        v39 = v90 + 3 * v36 + v87 + v88 + 146;
-        v33 = (GUIWindow *)Str[1];
-        v40 = v87;
-        v38->uHeight = v87;
-        v38->uY = v39;
-        v41 = v39 + v40 - 1;
-LABEL_73:
-        v38->uW = v41;
-      }
-      v47 = v33->pStartingPosActiveItem;
-      pOutString = (GUIFont *)((char *)pOutString + 1);
-      if ( (signed int)pOutString >= v33->pNumPresenceButton + v47 )
-        goto LABEL_75;
-    }
-    v42 = v90 + v88 + 2 * v36 + 146;
-    v43 = v82;
-    v38->uY = v42;
-    v38->uHeight = v43;
-    v41 = v43 + v42 - 1;
-    goto LABEL_73;
-  }
-  if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
-  {
-    v48 = 2;
-    pShopOptions[0] = pGlobalTXT_LocalizationStrings[620];
-    pOutString = 0;
-    pShopOptions[1] = pGlobalTXT_LocalizationStrings[622];
-    if ( pParty->HasItem(0x28Bu) )
-    {
-      pShopOptions[2] = pGlobalTXT_LocalizationStrings[621];
-      v48 = 3;
-    }
-    for ( i = 0; i < v48; ++i )
-    {
-      v50 = pFontArrus->CalcTextHeight(pShopOptions[i], &v79, 0, 0);
-      pOutString = (GUIFont *)((char *)pOutString + v50);
-    }
-    v86 = (174 - (signed int)pOutString) / v48;
-    v51 = pDialogueWindow;
-    v52 = 174 - v48 * (174 - (signed int)pOutString) / v48 - (signed int)pOutString;
-    v53 = v52 - HIDWORD(v52);
-    LODWORD(v52) = pDialogueWindow->pStartingPosActiveItem;
-    HIDWORD(v52) = v52 + pDialogueWindow->pNumPresenceButton;
-    v54 = (v53 >> 1) - v86 / 2 + 138;
-    v37 = -pDialogueWindow->pNumPresenceButton < 0;
-    v89 = pDialogueWindow->pStartingPosActiveItem;
-    if ( v37 ^ __OFSUB__((int)v52, HIDWORD(v52)) )
-    {
-      v85 = (Player *)2;
-      pOutString = (GUIFont *)pShopOptions;
-      do
-      {
-        v55 = v51->GetControl(v89);
-        v56 = (const char **)pOutString;
-        v55->uY = v86 + v54;
-        v57 = pFontArrus->CalcTextHeight(*v56, &v79, 0, 0);
-        v58 = v55->uY;
-        v59 = v85;
-        v55->uHeight = v57;
-        v54 = v57 + v58 - 1;
-        v55->uW = v54;
-        v60 = v84[0];
-        if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v59 )
-          v60 = v81;
-        v79.DrawTitleText(pFontArrus, 0, v58, v60, *(const char **)&pOutString->cFirstChar, 3u);
-        v51 = pDialogueWindow;
-        v85 = (Player *)((char *)v85 + 1);
-        pOutString = (GUIFont *)((char *)pOutString + 4);
-        ++v89;
-      }
-      while ( v89 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
-    }
+		ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
+        HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 4);
+        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0);
+		break;
+		}
+	case 1:
+		{
+		if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
+		  return;
+		v28 = *(int *)v84;
+		if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
+		  v28 = v81;
+		sprintf(Dest, format_4E2DC8, v28);
+		sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[178], pOutString);
+		strcat(Dest, pTmpBuf2);
+		v90 = pFontArrus->CalcTextHeight(Dest, &v79, 0, 0);
+		strcat(Dest, "\n \n");
+		v29 = *(int *)v84;
+		if ( pDialogueWindow->pCurrentPosActiveItem != 3 )
+		  v29 = v81;
+		sprintf(a1, format_4E2DC8, v29);
+		sprintf(pTmpBuf2,
+		  pGlobalTXT_LocalizationStrings[86],
+		  //(signed __int64)p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C],
+		  (signed __int64)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier,
+		  v83);
+		strcat(a1, pTmpBuf2);
+		v88 = pFontArrus->CalcTextHeight(a1, &v79, 0, 0);
+		strcat(a1, "\n \n");
+		v30 = *(int *)v84;
+		if ( pDialogueWindow->pCurrentPosActiveItem != 4 )
+		  v30 = v81;
+		sprintf(v77, format_4E2DC8, v30);
+		strcat(v77, pGlobalTXT_LocalizationStrings[160]);
+		v82 = pFontArrus->CalcTextHeight(v77, &v79, 0, 0);
+		strcat(v77, "\n \n");
+		v75[0] = 0;
+		v87 = 0;
+		v31 = (signed int)window_SpeakInHouse->ptr_1C;
+		if ( v31 >= 108 && v31 <= 120 )
+		{
+		  v32 = *(int *)v84;
+		  if ( pDialogueWindow->pCurrentPosActiveItem != 5 )
+			v32 = v81;
+		  sprintf(v75, format_4E2DC8, v32);
+		  strcat(v75, pGlobalTXT_LocalizationStrings[611]);
+		  v87 = pFontArrus->CalcTextHeight(v75, &v79, 0, 0);
+		}
+		v33 = pDialogueWindow;
+		Str[1] = (char *)pDialogueWindow;
+		v34 = pDialogueWindow->pStartingPosActiveItem;
+		v35 = v34 + pDialogueWindow->pNumPresenceButton;
+		v36 = LOBYTE(pFontArrus->uFontHeight) - 3;
+		v37 = -pDialogueWindow->pNumPresenceButton < 0;
+		pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem;
+		if ( !(v37 ^ __OFSUB__(v34, v35)) )
+		{
+	//LABEL_75:
+		  sprintf(pTmpBuf, "%s%s%s%s", &Dest, &a1, &v77, &v75);
+		  v71 = 3;
+		  v69 = pTmpBuf;
+		  v67 = 0;
+		  v66 = 146;
+	//LABEL_98:
+		  v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71);
+		  return;
+		}
+		while ( 1 )
+		{
+		  v38 = v33->GetControl((unsigned int)pOutString);
+		  if ( v38->uControlParam == 15 )
+		  {
+			v46 = v90;
+			v38->uHeight = v90;
+			v38->uY = 146;
+			v41 = v46 + 145;
+			v38->uW = v41;
+		  }
+		  else if ( v38->uControlParam == 16 )
+		  {
+			v44 = v88;
+			v45 = v90 + v36 + 146;
+			v38->uHeight = v88;
+			v38->uY = v45;
+			v41 = v45 + v44 - 1;
+			v38->uW = v41;
+		  }
+		  else if ( v38->uControlParam == 96 )
+		  {
+			v42 = v90 + v88 + 2 * v36 + 146;
+			v43 = v82;
+			v38->uY = v42;
+			v38->uHeight = v43;
+			v41 = v43 + v42 - 1;
+			v38->uW = v41;
+		  }
+		  else if ( v38->uControlParam == 101 )
+		  {
+			v39 = v90 + 3 * v36 + v87 + v88 + 146;
+			v33 = (GUIWindow *)Str[1];
+			v40 = v87;
+			v38->uHeight = v87;
+			v38->uY = v39;
+			v41 = v39 + v40 - 1;
+	//LABEL_73:
+			v38->uW = v41;
+		  }
+		  v47 = v33->pStartingPosActiveItem;
+		  pOutString = (GUIFont *)((char *)pOutString + 1);
+		  if ( (signed int)pOutString >= v33->pNumPresenceButton + v47 )
+		  {
+			  sprintf(pTmpBuf, "%s%s%s%s", &Dest, &a1, &v77, &v75);
+			  v71 = 3;
+			  v69 = pTmpBuf;
+			  v67 = 0;
+			  v66 = 146;
+			  v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71);
+			  return;
+		  }
+		}
+		break;
+		}
+	case 101:
+		{
+		if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
+		{
+			v48 = 2;
+			pShopOptions[0] = pGlobalTXT_LocalizationStrings[620];
+			pOutString = 0;
+			pShopOptions[1] = pGlobalTXT_LocalizationStrings[622];
+			if ( pParty->HasItem(0x28Bu) )
+			{
+				pShopOptions[2] = pGlobalTXT_LocalizationStrings[621];
+				v48 = 3;
+			}
+			for ( i = 0; i < v48; ++i )
+			{
+				v50 = pFontArrus->CalcTextHeight(pShopOptions[i], &v79, 0, 0);
+				pOutString = (GUIFont *)((char *)pOutString + v50);
+			}
+			v86 = (174 - (signed int)pOutString) / v48;
+			v51 = pDialogueWindow;
+			v52 = 174 - v48 * (174 - (signed int)pOutString) / v48 - (signed int)pOutString;
+			v53 = v52 - HIDWORD(v52);
+			LODWORD(v52) = pDialogueWindow->pStartingPosActiveItem;
+			HIDWORD(v52) = v52 + pDialogueWindow->pNumPresenceButton;
+			v54 = (v53 >> 1) - v86 / 2 + 138;
+			v37 = -pDialogueWindow->pNumPresenceButton < 0;
+			v89 = pDialogueWindow->pStartingPosActiveItem;
+			if ( v37 ^ __OFSUB__((int)v52, HIDWORD(v52)) )
+			{
+				v85 = (Player *)2;
+				pOutString = (GUIFont *)pShopOptions;
+				do
+				{
+					v55 = v51->GetControl(v89);
+					v56 = (const char **)pOutString;
+					v55->uY = v86 + v54;
+					v57 = pFontArrus->CalcTextHeight(*v56, &v79, 0, 0);
+					v58 = v55->uY;
+					v59 = v85;
+					v55->uHeight = v57;
+					v54 = v57 + v58 - 1;
+					v55->uW = v54;
+					v60 = v84[0];
+					if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v59 )
+						v60 = v81;
+					v79.DrawTitleText(pFontArrus, 0, v58, v60, *(const char **)&pOutString->cFirstChar, 3u);
+					v51 = pDialogueWindow;
+					v85 = (Player *)((char *)v85 + 1);
+					pOutString = (GUIFont *)((char *)pOutString + 4);
+					++v89;
+				}
+				while ( v89 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
+			}
+		}
+		break;
+		}
+	default:
+		{
+		break;
+		}
   }
 }
 
@@ -1667,66 +1716,65 @@
   v104.uFrameZ = 334;
   v108 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
   v106 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
-  if ( dword_F8B19C == 1 )
-  {
-    result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-    if ( result )
-    {
-      pShopOptions[0] = pGlobalTXT_LocalizationStrings[134];
-      pShopOptions[1] = pGlobalTXT_LocalizationStrings[152];
-      pShopOptions[2] = pGlobalTXT_LocalizationStrings[159];
-      v72 = 0;
-      pShopOptions[3] = pGlobalTXT_LocalizationStrings[160];
-      v73 = pShopOptions;
-      do
-      {
-        v74 = pFontArrus->CalcTextHeight(*v73, &v104, 0, 0);
-        ++v73;
-        v72 += v74;
-      }
-      while ( (signed int)v73 < (signed int)&unk_F8B1C8 );
-      v75 = pDialogueWindow;
-      Str = (char *)((174 - v72) / 4);
-      result = (POINT *)pDialogueWindow->pStartingPosActiveItem;
-      v76 = (int)((char *)result + pDialogueWindow->pNumPresenceButton);
-      v77 = (174 - 4 * (174 - v72) / 4 - v72) / 2 - (174 - v72) / 4 / 2 + 138;
-      v28 = -pDialogueWindow->pNumPresenceButton < 0;
-      v112 = pDialogueWindow->pStartingPosActiveItem;
-      if ( v28 ^ __OFSUB__((int)result, v76) )
-      {
-        _this = (Player *)2;
-        v111 = (const char **)pShopOptions;
-        do
-        {
-          v78 = v75->GetControl(v112);
-          v79 = v111;
-          v78->uY = (unsigned int)&Str[v77];
-          v80 = pFontArrus->CalcTextHeight(*v79, &v104, 0, 0);
-          v81 = v78->uY;
-          v82 = _this;
-          v78->uHeight = v80;
-          v77 = v81 + v80 - 1;
-          v78->uW = v77;
-          v83 = v106;
-          if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v82 )
-            v83 = v108;
-          v104.DrawTitleText(pFontArrus, 0, v81, v83, *v111, 3u);
-          v75 = pDialogueWindow;
-          _this = (Player *)((char *)_this + 1);
-          ++v111;
-          ++v112;
-          result = (POINT *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
-        }
-        while ( (signed int)v112 < (signed int)result );
-      }
-    }
-  }
-  else
-  {
-    if ( dword_F8B19C != 2 )
-    {
-      if ( dword_F8B19C == 3 )
-      {
+  switch(dword_F8B19C)
+  {
+	case 1:
+		{
+		result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
+		if ( result )
+		{
+		  pShopOptions[0] = pGlobalTXT_LocalizationStrings[134];
+		  pShopOptions[1] = pGlobalTXT_LocalizationStrings[152];
+		  pShopOptions[2] = pGlobalTXT_LocalizationStrings[159];
+		  v72 = 0;
+		  pShopOptions[3] = pGlobalTXT_LocalizationStrings[160];
+		  v73 = pShopOptions;
+		  do
+		  {
+			v74 = pFontArrus->CalcTextHeight(*v73, &v104, 0, 0);
+			++v73;
+			v72 += v74;
+		  }
+		  while ( (signed int)v73 < (signed int)&unk_F8B1C8 );
+		  v75 = pDialogueWindow;
+		  Str = (char *)((174 - v72) / 4);
+		  result = (POINT *)pDialogueWindow->pStartingPosActiveItem;
+		  v76 = (int)((char *)result + pDialogueWindow->pNumPresenceButton);
+		  v77 = (174 - 4 * (174 - v72) / 4 - v72) / 2 - (174 - v72) / 4 / 2 + 138;
+		  v28 = -pDialogueWindow->pNumPresenceButton < 0;
+		  v112 = pDialogueWindow->pStartingPosActiveItem;
+		  if ( v28 ^ __OFSUB__((int)result, v76) )
+		  {
+			_this = (Player *)2;
+			v111 = (const char **)pShopOptions;
+			do
+			{
+			  v78 = v75->GetControl(v112);
+			  v79 = v111;
+			  v78->uY = (unsigned int)&Str[v77];
+			  v80 = pFontArrus->CalcTextHeight(*v79, &v104, 0, 0);
+			  v81 = v78->uY;
+			  v82 = _this;
+			  v78->uHeight = v80;
+			  v77 = v81 + v80 - 1;
+			  v78->uW = v77;
+			  v83 = v106;
+			  if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v82 )
+				v83 = v108;
+			  v104.DrawTitleText(pFontArrus, 0, v81, v83, *v111, 3u);
+			  v75 = pDialogueWindow;
+			  _this = (Player *)((char *)_this + 1);
+			  ++v111;
+			  ++v112;
+			  result = (POINT *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
+			}
+			while ( (signed int)v112 < (signed int)result );
+		  }
+		}
+		return result;
+		}
+	case 3:
+		{
         draw_leather();
         CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
         DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);
@@ -1748,11 +1796,19 @@
         v45 = _this->_490EEE(v87, 4, v44, 3);
         v39 = v113;
         v38 = (char *)pMerchantsSellPhrases[v45];
-        goto LABEL_45;
-      }
-      if ( dword_F8B19C == 4 )
-      {
-        draw_leather();
+        v21 = BuilDialogueString(v38, v39, v87, (char *)v89, v91, v93);
+        v92 = 3;
+        v90 = v21;
+        v88 = v108;
+        v86 = v3;
+        v85 = v3;
+        v84 = &v104;
+        v40 = pFontArrus->CalcTextHeight(v21, v84, v85, v86);
+        return (POINT *)v104.DrawTitleText(pFontArrus, v3, (174 - v40) / 2 + 138, v88, v90, v92);
+		}
+	case 4:
+		{
+		draw_leather();
         CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
         DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);
         result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
@@ -1776,14 +1832,14 @@
           v42 = _this->_490EEE(v37, 4, v41, 4);
           v39 = v113;
           v38 = (char *)pMerchantsIdentifyPhrases[v42];
-          goto LABEL_45;
-        }
-        v89 = window_SpeakInHouse->ptr_1C;
-        v38 = "%24";
-        v87 = v37;
-LABEL_44:
-        v39 = uActiveCharacter - 1;
-LABEL_45:
+        }
+		else
+		{
+			v89 = window_SpeakInHouse->ptr_1C;
+			v38 = "%24";
+			v87 = v37;
+	        v39 = uActiveCharacter - 1;
+		}
         v21 = BuilDialogueString(v38, v39, v87, (char *)v89, v91, v93);
         v92 = 3;
         v90 = v21;
@@ -1791,11 +1847,12 @@
         v86 = v3;
         v85 = v3;
         v84 = &v104;
-        goto LABEL_46;
-      }
-      if ( dword_F8B19C == 94 )
-      {
-        draw_leather();
+        v40 = pFontArrus->CalcTextHeight(v21, v84, v85, v86);
+        return (POINT *)v104.DrawTitleText(pFontArrus, v3, (174 - v40) / 2 + 138, v88, v90, v92);
+		}
+	case 94:
+		{
+		draw_leather();
         CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
         pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];
         pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];
@@ -1844,13 +1901,294 @@
           while ( (signed int)v112 < (signed int)result );
         }
         return result;
-      }
-      if ( dword_F8B19C != 95 )
-      {
-        result = (POINT *)(dword_F8B19C - 96);
-        if ( dword_F8B19C != 96
-          || (result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) == 0 )
-          return result;
+		}
+	case 2:
+		{
+		pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
+		v3 = 0;
+		v114 = 0;
+		do
+		{
+			// if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
+			if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID);
+			{
+				v46 = ItemsInShopTexture[v114];
+				v47 = 152 - v46->uTextureHeight;
+				if ( (signed int)v47 < 1 )
+					v47 = 0;
+				v48 = 75 * v114 - v46->uTextureWidth / 2 + 40;
+				if ( v114 )
+				{
+					if ( v114 == 5 )
+					{
+						v49 = ItemsInShopTexture[5]->uTextureWidth;
+						if ( (signed int)v48 > 457 - v49 )
+						v48 = 457 - v49;
+					}
+				}
+				else if ( (signed int)v48 < 18 )
+					v48 = 18;
+				pRenderer->DrawTextureTransparent(v48, v47, v46);
+				sub_40F92A(&pRenderer->pActiveZBuffer[v48 + 640 * v47], ItemsInShopTexture[v114], v114 + 1);
+	        }
+			++v114;
+		}
+		while ( v114 < 6 );
+		v114 = 0;
+		do
+		{
+			//  if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 54] )
+			if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114+1].uItemID);
+			{
+			  v50 = ItemsInShopTexture[v114 + 6];
+			  v51 = 308 - v50->uTextureHeight;
+			  if ( (signed int)v51 < 1 )
+				v51 = 0;
+			  v52 = 75 * v114 - v50->uTextureWidth / 2 + 40;
+			  if ( v114 )
+			  {
+				if ( v114 == 5 )
+				{
+				  v53 = ItemsInShopTexture[11]->uTextureWidth;
+				  if ( (signed int)v52 > 457 - v53 )
+					v52 = 457 - v53;
+				}
+			  }
+			  else
+			  {
+				if ( (signed int)v52 < 18 )
+				  v52 = 18;
+			  }
+			  pRenderer->DrawTextureTransparent(v52, v51, v50);
+			  sub_40F92A(&pRenderer->pActiveZBuffer[v52 + 640 * v51], ItemsInShopTexture[v114 + 6], v114 + 7);
+			}
+			++v114;
+		}
+		while ( v114 < 6 );
+		result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
+		if ( result )
+		{
+			v62 = 0;
+			v109 = 0;
+			do
+			{
+			 // if ( pParty->field_777C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
+				if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID);
+					++v109;
+				++v62;
+			}
+			while ( v62 < 12 );
+			v63 = GetAsyncKeyState(17);
+			v64 = _this->CanSteal();
+			Str = (char *)v64;
+			if ( v63 && v64 )
+			{
+				v65 = pGlobalTXT_LocalizationStrings[185];
+			}
+			else if ( dword_F8B19C == 2 )
+			{
+				v65 = pGlobalTXT_LocalizationStrings[195];
+			}
+			else
+			{
+				v65 = pGlobalTXT_LocalizationStrings[196];
+			}
+			DrawTextAtStatusBar(v65, 0);
+			if ( !v109 )
+			{
+				v104.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
+				return 0;
+			}
+			v66 = pMouse->GetCursorPos(&v98);
+			result = (POINT *)(v66->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v96)->y]);
+			if ( pRenderer->pActiveZBuffer[(int)result] & 0xFFFF )
+			{
+				v67 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1;
+				v109 = v67;
+				v68 = (int)window_SpeakInHouse->ptr_1C;
+				//  v69 = 9 * (v67 + 12 * v68);
+				v70 = (ItemGen *)&pParty->StandartItemsInShops[v68][v67];
+				if ( dword_F8B19C != 2 )
+					v70 = &pParty->SpecialItemsInShops[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724];
+				if ( !v63 || !Str )
+				{
+					v93 = 0;
+					v91 = 2;
+					v89 = window_SpeakInHouse->ptr_1C;
+					v87 = v70;
+					v113 = uActiveCharacter - 1;
+					v71 = _this->_490EEE(v70, 4, v68, 2);
+					v39 = v113;
+					v38 = (char *)pMerchantsBuyPhrases[v71];
+				}
+				else
+				{
+					v38 = pGlobalTXT_LocalizationStrings[181];
+					v93 = 0;
+					v91 = 2;
+					v89 = window_SpeakInHouse->ptr_1C;
+					v87 = v70;
+					v39 = uActiveCharacter - 1;
+				}
+				v21 = BuilDialogueString(v38, v39, v87, (char *)v89, v91, v93);
+				v92 = 3;
+				v90 = v21;
+				v88 = v108;
+				v86 = v3;
+				v85 = v3;
+				v84 = &v104;
+				v40 = pFontArrus->CalcTextHeight(v21, v84, v85, v86);
+				return (POINT *)v104.DrawTitleText(pFontArrus, v3, (174 - v40) / 2 + 138, v88, v90, v92);
+			}
+		}
+		return result;
+		}
+	case 95:
+		{
+		pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
+		v3 = 0;
+		v114 = 0;
+		do
+		{
+			//if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+			if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID)
+			{
+			  v54 = ItemsInShopTexture[v114];
+			  v55 = 152 - v54->uTextureHeight;
+			  if ( (signed int)v55 < 1 )
+				v55 = 0;
+			  v56 = 75 * v114 - v54->uTextureWidth / 2 + 40;
+			  if ( v114 )
+			  {
+				if ( v114 == 5 )
+				{
+				  v57 = ItemsInShopTexture[5]->uTextureWidth;
+				  if ( (signed int)v56 > 457 - v57 )
+					v56 = 457 - v57;
+				}
+			  }
+			  else
+			  {
+				if ( (signed int)v56 < 18 )
+				  v56 = 18;
+			  }
+			  pRenderer->DrawTextureTransparent(v56, v55, v54);
+			  sub_40F92A(&pRenderer->pActiveZBuffer[v56 + 640 * v55], ItemsInShopTexture[v114], v114 + 1);
+			}
+			++v114;
+		}
+		while ( v114 < 6 );
+		v114 = 0;
+		do
+		{
+		// if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 778] )   //weak 
+			if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v114].uItemID) //not itemid
+			{
+				v58 = ItemsInShopTexture[v114 + 6];
+				v59 = 308 - v58->uTextureHeight;
+				if ( (signed int)v59 < 1 )
+				v59 = 0;
+				v60 = 75 * v114 - v58->uTextureWidth / 2 + 40;
+				if ( v114 )
+				{
+					if ( v114 == 5 )
+					{
+						v61 = ItemsInShopTexture[11]->uTextureWidth;
+						if ( (signed int)v60 > 457 - v61 )
+						v60 = 457 - v61;
+					}
+				}
+				else
+				{
+					if ( (signed int)v60 < 18 )
+						v60 = 18;
+				}
+				pRenderer->DrawTextureTransparent(v60, v59, v58);
+				sub_40F92A(&pRenderer->pActiveZBuffer[v60 + 640 * v59], ItemsInShopTexture[v114 + 6], v114 + 7);
+			}
+			++v114;
+		}
+		while ( v114 < 6 );
+		result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
+		if ( result )
+		{
+			v62 = 0;
+			v109 = 0;
+			do
+			{
+				//if ( pParty->field_C59C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+				if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID)
+					++v109;
+				++v62;
+			}
+			while ( v62 < 12 );
+				v63 = GetAsyncKeyState(17);
+			v64 = _this->CanSteal();
+			Str = (char *)v64;
+			if ( v63 && v64 )
+			{
+				v65 = pGlobalTXT_LocalizationStrings[185];
+			}
+			else
+			{
+				v65 = pGlobalTXT_LocalizationStrings[195];
+				if ( dword_F8B19C != 2 )
+					v65 = pGlobalTXT_LocalizationStrings[196];
+			}
+			DrawTextAtStatusBar(v65, 0);
+			if ( !v109 )
+			{
+				v104.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
+				return 0;
+			}
+			v66 = pMouse->GetCursorPos(&v98);
+			result = (POINT *)(v66->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v96)->y]);
+			if ( pRenderer->pActiveZBuffer[(int)result] & 0xFFFF )
+			{
+				v67 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1;
+				v109 = v67;
+				v68 = (int)window_SpeakInHouse->ptr_1C;
+				//  v69 = 9 * (v67 + 12 * v68);
+				v70 = (ItemGen *)&pParty->StandartItemsInShops[v68][v67];
+				if ( dword_F8B19C != 2 )
+					v70 = &pParty->SpecialItemsInShops[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724];
+				if ( !v63 || !Str )
+				{
+					v93 = 0;
+					v91 = 2;
+					v89 = window_SpeakInHouse->ptr_1C;
+					v87 = v70;
+					v113 = uActiveCharacter - 1;
+					v71 = _this->_490EEE(v70, 4, v68, 2);
+					v39 = v113;
+					v38 = (char *)pMerchantsBuyPhrases[v71];
+				}
+				else
+				{
+					v38 = pGlobalTXT_LocalizationStrings[181];
+					v93 = 0;
+					v91 = 2;
+					v89 = window_SpeakInHouse->ptr_1C;
+					v87 = v70;
+					v39 = uActiveCharacter - 1;
+				}
+				v21 = BuilDialogueString(v38, v39, v87, (char *)v89, v91, v93);
+				v92 = 3;
+				v90 = v21;
+				v88 = v108;
+				v86 = v3;
+				v85 = v3;
+				v84 = &v104;
+				v40 = pFontArrus->CalcTextHeight(v21, v84, v85, v86);
+				return (POINT *)v104.DrawTitleText(pFontArrus, v3, (174 - v40) / 2 + 138, v88, v90, v92);
+			}
+		}
+		return result;
+		}
+	case 96:
+		{
+        if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
+          return 0;
         v2 = pDialogueWindow;
         v3 = 0;
         v4 = window_SpeakInHouse->ptr_1C;
@@ -1939,221 +2277,14 @@
         v86 = 0;
         v85 = 0;
         v84 = &v104;
-LABEL_46:
         v40 = pFontArrus->CalcTextHeight(v21, v84, v85, v86);
         return (POINT *)v104.DrawTitleText(pFontArrus, v3, (174 - v40) / 2 + 138, v88, v90, v92);
-      }
-    }
-    pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
-    v3 = 0;
-    v114 = 0;
-    if ( dword_F8B19C == 2 )
-    {
-      do
-      {
-       // if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
-	  if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID);
-        {
-          v46 = ItemsInShopTexture[v114];
-          v47 = 152 - v46->uTextureHeight;
-          if ( (signed int)v47 < 1 )
-            v47 = 0;
-          v48 = 75 * v114 - v46->uTextureWidth / 2 + 40;
-          if ( v114 )
-          {
-            if ( v114 == 5 )
-            {
-              v49 = ItemsInShopTexture[5]->uTextureWidth;
-              if ( (signed int)v48 > 457 - v49 )
-                v48 = 457 - v49;
-            }
-          }
-          else
-          {
-            if ( (signed int)v48 < 18 )
-              v48 = 18;
-          }
-          pRenderer->DrawTextureTransparent(v48, v47, v46);
-          sub_40F92A(&pRenderer->pActiveZBuffer[v48 + 640 * v47], ItemsInShopTexture[v114], v114 + 1);
-        }
-        ++v114;
-      }
-      while ( v114 < 6 );
-      v114 = 0;
-      do
-      {
-      //  if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 54] )
-	  if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114+1].uItemID);
-        {
-          v50 = ItemsInShopTexture[v114 + 6];
-          v51 = 308 - v50->uTextureHeight;
-          if ( (signed int)v51 < 1 )
-            v51 = 0;
-          v52 = 75 * v114 - v50->uTextureWidth / 2 + 40;
-          if ( v114 )
-          {
-            if ( v114 == 5 )
-            {
-              v53 = ItemsInShopTexture[11]->uTextureWidth;
-              if ( (signed int)v52 > 457 - v53 )
-                v52 = 457 - v53;
-            }
-          }
-          else
-          {
-            if ( (signed int)v52 < 18 )
-              v52 = 18;
-          }
-          pRenderer->DrawTextureTransparent(v52, v51, v50);
-          sub_40F92A(&pRenderer->pActiveZBuffer[v52 + 640 * v51], ItemsInShopTexture[v114 + 6], v114 + 7);
-        }
-        ++v114;
-      }
-      while ( v114 < 6 );
-    }
-    else
-    {
-      do
-      {
-        //if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
-	  if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID)
-        {
-          v54 = ItemsInShopTexture[v114];
-          v55 = 152 - v54->uTextureHeight;
-          if ( (signed int)v55 < 1 )
-            v55 = 0;
-          v56 = 75 * v114 - v54->uTextureWidth / 2 + 40;
-          if ( v114 )
-          {
-            if ( v114 == 5 )
-            {
-              v57 = ItemsInShopTexture[5]->uTextureWidth;
-              if ( (signed int)v56 > 457 - v57 )
-                v56 = 457 - v57;
-            }
-          }
-          else
-          {
-            if ( (signed int)v56 < 18 )
-              v56 = 18;
-          }
-          pRenderer->DrawTextureTransparent(v56, v55, v54);
-          sub_40F92A(&pRenderer->pActiveZBuffer[v56 + 640 * v55], ItemsInShopTexture[v114], v114 + 1);
-        }
-        ++v114;
-      }
-      while ( v114 < 6 );
-      v114 = 0;
-      do
-      {
-       // if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 778] )   //weak 
-	     if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v114].uItemID) //not itemid
-        {
-          v58 = ItemsInShopTexture[v114 + 6];
-          v59 = 308 - v58->uTextureHeight;
-          if ( (signed int)v59 < 1 )
-            v59 = 0;
-          v60 = 75 * v114 - v58->uTextureWidth / 2 + 40;
-          if ( v114 )
-          {
-            if ( v114 == 5 )
-            {
-              v61 = ItemsInShopTexture[11]->uTextureWidth;
-              if ( (signed int)v60 > 457 - v61 )
-                v60 = 457 - v61;
-            }
-          }
-          else
-          {
-            if ( (signed int)v60 < 18 )
-              v60 = 18;
-          }
-          pRenderer->DrawTextureTransparent(v60, v59, v58);
-          sub_40F92A(&pRenderer->pActiveZBuffer[v60 + 640 * v59], ItemsInShopTexture[v114 + 6], v114 + 7);
-        }
-        ++v114;
-      }
-      while ( v114 < 6 );
-    }
-    result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-    if ( result )
-    {
-      v62 = 0;
-      v109 = 0;
-      if ( dword_F8B19C == 2 )
-      {
-        do
-        {
-         // if ( pParty->field_777C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
-		if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID);
-            ++v109;
-          ++v62;
-        }
-        while ( v62 < 12 );
-      }
-      else
-      {
-        do
-        {
-          //if ( pParty->field_C59C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
-		if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID)
-            ++v109;
-          ++v62;
-        }
-        while ( v62 < 12 );
-      }
-      v63 = GetAsyncKeyState(17);
-      v64 = _this->CanSteal();
-      Str = (char *)v64;
-      if ( v63 && v64 )
-      {
-        v65 = pGlobalTXT_LocalizationStrings[185];
-      }
-      else
-      {
-        v65 = pGlobalTXT_LocalizationStrings[195];
-        if ( dword_F8B19C != 2 )
-          v65 = pGlobalTXT_LocalizationStrings[196];
-      }
-      DrawTextAtStatusBar(v65, 0);
-      if ( !v109 )
-		  {
-        v104.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
-		return 0;
-		  }
-      v66 = pMouse->GetCursorPos(&v98);
-      result = (POINT *)(v66->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v96)->y]);
-      if ( pRenderer->pActiveZBuffer[(int)result] & 0xFFFF )
-      {
-        v67 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1;
-        v109 = v67;
-        v68 = (int)window_SpeakInHouse->ptr_1C;
-      //  v69 = 9 * (v67 + 12 * v68);
-        v70 = (ItemGen *)&pParty->StandartItemsInShops[v68][v67];
-        if ( dword_F8B19C != 2 )
-          v70 = &pParty->SpecialItemsInShops[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724];
-        if ( !v63 || !Str )
-        {
-          v93 = 0;
-          v91 = 2;
-          v89 = window_SpeakInHouse->ptr_1C;
-          v87 = v70;
-          v113 = uActiveCharacter - 1;
-          v71 = _this->_490EEE(v70, 4, v68, 2);
-          v39 = v113;
-          v38 = (char *)pMerchantsBuyPhrases[v71];
-          goto LABEL_45;
-        }
-        v38 = pGlobalTXT_LocalizationStrings[181];
-        v93 = 0;
-        v91 = 2;
-        v89 = window_SpeakInHouse->ptr_1C;
-        v87 = v70;
-        goto LABEL_44;
-      }
-    }
-  }
-  return result;
+		}
+	default:
+		{
+			return (POINT *)dword_F8B19C - 96;
+		}
+  }
 }
 
 
@@ -2189,7 +2320,7 @@
 	GUIButton *v26; // esi@26
 	int v27; // eax@26
 	unsigned int v28; // ecx@26
-	Player *v29; // edx@26
+	int v29; // edx@26
 	unsigned __int16 v30; // ax@26
 	signed int v31; // esi@31
 	unsigned int v32; // eax@33
@@ -2358,12 +2489,12 @@
 					v25->uY = v146 + v23;
 					v27 = pFontArrus->CalcTextHeight(*v16, &v144, 0, 0);
 					v28 = v26->uY;
-					v29 = _this;
+					v29 = th;
 					v26->uHeight = v27;
 					v23 = v28 + v27 - 1;
 					v26->uW = v23;
 					v30 = v147;
-					if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v29 )
+					if ( pDialogueWindow->pCurrentPosActiveItem != v29 )
 						v30 = v148;
 					v144.DrawTitleText(pFontArrus, 0, v28, v30, *v16, 3u);
 					v20 = pDialogueWindow;
@@ -3157,7 +3288,7 @@
   pDialogueWindow->Release();
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, 0, 0);
   pBtn_ExitCancel = pDialogueWindow->CreateButton(471u, 445u, 169u, 35u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[34],// "Cancel"
-                 (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), 0);
+                 (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
   pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, 0, 0x53u, 0, "", 0);
   pDialogueWindow->_41D08F(1, 1, 0, 2);
@@ -3299,7 +3430,7 @@
     pDialogueWindow->pControlsTail = 0;
     pDialogueWindow->uNumControls = 0;
     pBtn_ExitCancel = pDialogueWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79],
-                   (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), 0);
+                   (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0);
     pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x55u, 0, "", 0);
     pDialogueWindow->CreateButton(0x1E0u, 0xBEu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x56u, 0, "", 0);
     pDialogueWindow->CreateButton(0x1E0u, 0xDCu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x57u, 0, "", 0);
@@ -3683,7 +3814,7 @@
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0);
   pBtn_ExitCancel = pDialogueWindow->CreateButton( 471, 445,  169, 35, 1, 0,  0x71u,  0,  0,
                  pGlobalTXT_LocalizationStrings[74],  //"End Conversation"
-                 (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : NULL),
+                 (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : NULL),
                  0);
   return pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, 0x51u, 0, 0, "", 0);
 }
@@ -3730,7 +3861,7 @@
   int v37; // ecx@227
   int v38; // esi@230
   int v39; // edx@235
-  void *v40; // edi@243
+  int v40; // edi@243
   unsigned __int64 v41; // qax@243
   void *v42; // eax@244
   signed int v43; // edi@244
@@ -4188,14 +4319,14 @@
     GenerateStandartShopItems();
     GenerateSpecialShopItems();
     v8 = window_SpeakInHouse;
-    v40 = window_SpeakInHouse->ptr_1C;
+    v40 = window_SpeakInHouse->par1C;
     //v3 = dword_F8B198;
     v41 = pParty->uTimePlayed
         //+ (signed __int64)((double)(11059200 * (signed int)p2DEvents_minus1[26 * (unsigned int)ptr_507BC0->ptr_1C])
         + (signed __int64)((double)(11059200 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C)
                          * 0.033333335);
-    pParty->field_3C.field_50[2 * (int)v40] = v41;
-    pParty->field_3C.field_50[2 * (int)v40 + 1] = HIDWORD(v41);
+    pParty->field_3C.field_50[v40] = v41;
+   
   }
   v42 = v8->ptr_1C;
   v43 = 0;
@@ -4304,7 +4435,7 @@
     pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
   pKeyActionMap->_459ED1(3);
   pKeyActionMap->ResetKeys();
-  GlobalEventInfo = 0;
+  activeLevelDecoration = NULL;
   ptr_F8B1E8 = 0;
   if ( pDialogueNPCCount )
   {
@@ -7872,7 +8003,7 @@
   //int v28; // eax@35
   //int v29; // esi@35
   //__int16 v30; // ax@35
-  LayingItem a1a; // [sp+Ch] [bp-7Ch]@1
+  SpriteObject a1a; // [sp+Ch] [bp-7Ch]@1
   //int v32; // [sp+7Ch] [bp-Ch]@1
   //int v33; // [sp+80h] [bp-8h]@1
   int v34; // [sp+84h] [bp-4h]@1
@@ -7932,7 +8063,7 @@
 LABEL_20:
                 v15 = 0;
                 v16 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID;
-                a1a.uItemType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID;
+                a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID;
                 if ( (signed int)pObjectList->uNumObjects <= 0 )
                 {
 LABEL_24:
@@ -7977,7 +8108,7 @@
     return result;
   v23 = 0;
   v24 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID;
-  a1a.uItemType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID;
+  a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID;
   if ( (signed int)pObjectList->uNumObjects <= 0 )
   {
 LABEL_33:
@@ -8025,14 +8156,14 @@
   unsigned __int16 v9; // cx@1
   char *v10; // edx@2
   unsigned __int16 v11; // ax@5
-  LayingItem a1; // [sp+8h] [bp-70h]@1
+  SpriteObject a1; // [sp+8h] [bp-70h]@1
 
   v6 = ecx0;
   v7 = a2;
   pItemsTable->GenerateItem(v6, v7, &a1.stru_24);
   v8 = 0;
   v9 = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID;
-  a1.uItemType = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID;
+  a1.uType = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID;
   if ( (signed int)pObjectList->uNumObjects <= 0 )
   {
 LABEL_5:
@@ -9328,26 +9459,18 @@
   const char **v4; // ebx@2
   unsigned int result; // eax@6
 
-  v2 = this;
   v3 = 1;
-  if ( (signed int)this->uNumMaps <= 1 )
-  {
-LABEL_6:
-    result = 0;
-  }
-  else
-  {
-    v4 = (const char **)&this->pInfos[1].pFilename;
-    while ( !*v4 || _strcmpi(*v4, Str2) )
+  if ( (signed int)uNumMaps <= 1 )
+     return 0;
+  
+    while ( !*this->pInfos[v3].pFilename || _strcmpi(this->pInfos[v3].pFilename, Str2) )
     {
       ++v3;
-      v4 += 17;
-      if ( (signed int)v3 >= (signed int)v2->uNumMaps )
-        goto LABEL_6;
-    }
-    result = v3;
-  }
-  return result;
+      if ( (signed int)v3 >= (signed int)uNumMaps )
+        return 0;
+    }
+    return v3;
+
 }
 
 //----- (004547E4) --------------------------------------------------------
@@ -12215,7 +12338,7 @@
   _strrev(Str1);
 
   for (uint i = 0; i < 1000; ++i)
-    pLayingItems[i].uObjectDescID = 0;
+    pSpriteObjects[i].uObjectDescID = 0;
 
   v5 = pMapStats->GetMapInfo(pCurrentMapName);
   bUnderwater = 0;
@@ -13128,6 +13251,112 @@
 
 
 
+void IntegrityTest()
+{
+  assert(sizeof(RenderVertexSoft) == 0x30);
+  assert(sizeof(RenderBillboard) == 0x34);
+  assert(sizeof(Texture) == 0x48);
+  assert(sizeof(RGBTexture) == 0x28);
+  assert(sizeof(LODFile_IconsBitmaps) == 0x11BB8 + 4); // + virtual dtor ptr
+  assert(sizeof(AudioPlayer) == 0xC84);
+  assert(sizeof(SoundDesc) == 0x78);
+  assert(sizeof(stru339_spell_sound) == 0xAFD8);
+  assert(sizeof(VideoPlayer) == 0x108 + 4);
+  assert(sizeof(MovieHeader) == 0x2C);
+  assert(sizeof(DecorationDesc) == 0x54);
+  assert(sizeof(ObjectDesc) == 0x38);
+  assert(sizeof(OverlayDesc) == 0x8);
+  assert(sizeof(ChestDesc) == 0x24);
+  assert(sizeof(TileDesc) == 0x1A);
+  assert(sizeof(MonsterDesc) == 0x98);
+  assert(sizeof(Timer) == 0x28);
+  assert(sizeof(OtherOverlay) == 0x14);
+  assert(sizeof(ItemGen) == 0x24);
+  assert(sizeof(SpriteObject) == 0x70);
+  assert(sizeof(ItemDesc) == 0x30);
+  assert(sizeof(ItemsTable) == 0x117A0);
+  assert(sizeof(Chest) == 0x14CC);
+  assert(sizeof(MapInfo) == 0x44);
+  assert(sizeof(SpellInfo) == 0x24);
+  assert(sizeof(SpellData) == 0x14);
+  assert(sizeof(SpellBuff) == 0x10);
+  assert(sizeof(AIDirection) == 0x1C);
+  assert(sizeof(ActorJob) == 0xC);
+  assert(sizeof(Actor) == 0x344);
+  assert(sizeof(LevelDecoration) == 0x20);
+  assert(sizeof(KeyboardActionMapping) == 0x20C);
+  assert(sizeof(UIAnimation) == 0xD);
+  assert(sizeof(SpawnPointMM7) == 0x18);
+  assert(sizeof(ODMFace) == 0x134);
+  assert(sizeof(BSPNode) == 0x8);
+  assert(sizeof(BSPModel) == 0xBC);
+  assert(sizeof(OutdoorLocation) == 0x1C28C);
+  assert(sizeof(BLVFace) == 0x60);
+  assert(sizeof(BLVFaceExtra) == 0x24);
+  assert(sizeof(BLVSector) == 0x74);
+  assert(sizeof(BLVLightMM7) == 0x10);
+  assert(sizeof(BLVDoor) == 0x50);
+  assert(sizeof(IndoorLocation) == 0x690);
+  assert(sizeof(OutdoorCamera) == 0x74);
+  assert(sizeof(Mouse) == 0x114);
+  assert(sizeof(Particle_) == 0x68);
+  assert(sizeof(Particle) == 0x68);
+  assert(sizeof(ParticleEngine) == 0xE430);
+  assert(sizeof(Lightmap) == 0xC1C);
+  assert(sizeof(LightmapBuilder) == 0x3CBC38);
+  assert(sizeof(Vis_SelectionList) == 0x2008);
+  assert(sizeof(Vis) == 0x20D0);
+  assert(sizeof(PlayerBuffAnim) == 0x10);
+  assert(sizeof(ProjectileAnim) == 0x1C);
+  assert(sizeof(stru6) == 0x5F8);
+  assert(sizeof(IndoorCameraD3D_Vec3) == 0x10);
+  assert(sizeof(IndoorCameraD3D_Vec4) == 0x18); //should be 14 (10 vec3 + 4 vdtor)  but 18 coz of his +4 from own vdtor, but it is odd since vdtor already present from vec3
+  assert(sizeof(IndoorCameraD3D) == 0x1A1384);
+  assert(sizeof(StationaryLight) == 0xC);
+  assert(sizeof(LightsStack_StationaryLight_) == 0x12C8);
+  assert(sizeof(MobileLight) == 0x12);
+  assert(sizeof(LightsStack_MobileLight_) == 0x1C28);
+  assert(sizeof(Game) == 0xE78);
+  assert(sizeof(stru141) == 0xA8);
+  assert(sizeof(ActionQueue) == 0x7C);
+  assert(sizeof(NPCData) == 0x4C);
+  assert(sizeof(NPCStats) == 0x17FFC);
+  assert(sizeof(BspRenderer) == 0x53740);
+  assert(sizeof(PaletteManager) == 0x267AF0);
+  assert(sizeof(ViewingParams) == 0x26C);
+  assert(sizeof(IndoorCamera) == 0x50);
+  assert(sizeof(Bloodsplat) == 0x28);
+  assert(sizeof(BloodsplatContainer) == 0xA0C);
+  assert(sizeof(stru167) == 0x18);
+  assert(sizeof(EventIndex) == 0xC);
+  assert(sizeof(_2devent) == 0x34);
+  assert(sizeof(stru176) == 0x20);
+  assert(sizeof(SavegameHeader) == 0x64);
+  assert(sizeof(SavegameList) == 0x3138);
+  assert(sizeof(StorylineText) == 0x168);
+  assert(sizeof(FactionTable) == 0x1EF1);
+  assert(sizeof(Decal) == 0xC20);
+  assert(sizeof(DecalBuilder) == 0x30C038);
+  assert(sizeof(MonsterInfo) == 0x58);
+  assert(sizeof(MonsterStats) == 0x5BA0);
+  assert(sizeof(RenderD3D) == 0x148);
+  assert(sizeof(Render) == 0x129844);
+  assert(sizeof(Player) == 0x1B3C);
+  assert(sizeof(Party_stru0) == 0x678);
+  assert(sizeof(Party) == 0x16238);
+  assert(sizeof(GUIButton) == 0xBC);
+  assert(sizeof(GUIWindow) == 0x54);
+  assert(sizeof(GUIProgressBar) == 0x1B8);
+  assert(sizeof(GUIFont) == 0x1020);
+  assert(sizeof(stru262_TurnBased) == 0x40);
+  assert(sizeof(ArcomageGame) == 0xFA);
+  assert(sizeof(stru277) == 0x14);
+  assert(sizeof(ArcomageCard) == 0x6C);
+  assert(sizeof(stru320) == 0x3FC);
+  assert(sizeof(TravelInfo) == 0x20);
+  assert(sizeof(stru336) == 0x798);
+}
+
 bool new_sky = false;
 
 //----- (00462C94) --------------------------------------------------------
@@ -13145,9 +13374,11 @@
   unsigned int startms; // [sp+8h] [bp-24h]@55
   RECT Rect; // [sp+Ch] [bp-20h]@15
   int a2[4]; // [sp+1Ch] [bp-10h]@15
-
+  
+  IntegrityTest();
   char test[1024];
-  //sprintfex(test, "^Pi[%s]: ^R[;;]", "");
+  sprintfex(test, "^Pi[%s]: ^R[;;]", "");
+
 
   if (pCmdLine && *pCmdLine)
   {
@@ -14939,12 +15170,12 @@
       v17 = a1 >> 3;
       v26 = a1 >> 3;
       v18 = a1 >> 3;
-      if ( pObjectList->pObjects[pLayingItems[v18].uObjectDescID].uFlags & 0x10
+      if ( pObjectList->pObjects[pSpriteObjects[v18].uObjectDescID].uFlags & 0x10
         || v17 >= 1000
-        || !pLayingItems[v18].uObjectDescID )
+        || !pSpriteObjects[v18].uObjectDescID )
         return 1;
-      v19 = &pLayingItems[v18].stru_24;
-      v20 = pLayingItems[v18].stru_24.uItemID;
+      v19 = &pSpriteObjects[v18].stru_24;
+      v20 = pSpriteObjects[v18].stru_24.uItemID;
       if ( pItemsTable->pItems[v20].uEquipType == EQUIP_GOLD)
       {
         party_finds_gold(v19->uSpecEnchantmentType, 0);
@@ -14966,7 +15197,7 @@
           pParty->SetHoldingItem(v19);
         v21 = v26;
       }
-      LayingItem::OnItemPickup(v21);
+      SpriteObject::OnInteraction(v21);
       break;
 
     case OBJECT_Actor:
@@ -15028,9 +15259,9 @@
         v10 = v8->_idx_in_stru123;
         v24 = 1;
         v11 = stru_5E4C90._decor_events[v10 - 75] + 380;
-        GlobalEventInfo = (int)v8;
+        activeLevelDecoration = v8;
         EventProcessor(v11, 0, 1);
-        GlobalEventInfo = 0;
+        activeLevelDecoration = NULL;
       }
       break;
 
@@ -15442,9 +15673,9 @@
     {
       if ( v20 >= 0x3E8 )
         return 0;
-      if ( !(pLayingItems[v20].uAttributes & 0x10) )
-      {
-        v23 = pLayingItems[v20].stru_24.GetDisplayName();
+      if ( !(pSpriteObjects[v20].uAttributes & 0x10) )
+      {
+        v23 = pSpriteObjects[v20].stru_24.GetDisplayName();
 LABEL_36:
         v24 = v23;
         goto LABEL_51;
@@ -15591,9 +15822,9 @@
 
 
 //----- (0046BEF1) --------------------------------------------------------
-void LayingItem::_46BEF1_apply_spells()
-{
-  LayingItem *v1; // edi@1
+void SpriteObject::_46BEF1_apply_spells()
+{
+  SpriteObject *v1; // edi@1
   Actor *v2; // esi@2
   __int16 v3; // fps@4
   unsigned __int8 v4; // c0@4
@@ -15635,7 +15866,7 @@
 //----- (0046BFFA) --------------------------------------------------------
 bool __fastcall _46BFFA_check_object_intercept(unsigned int uLayingItemID, signed int a2)
 {
-  LayingItem *v2; // esi@1
+  SpriteObject *v2; // esi@1
   ObjectDesc *v3; // ebx@1
   unsigned __int16 v5; // cx@9
   unsigned __int16 v6; // cx@14
@@ -15788,7 +16019,7 @@
   unsigned int v153; // [sp+28h] [bp-4h]@1
 
   v153 = uLayingItemID;
-  v2 = &pLayingItems[uLayingItemID];
+  v2 = &pSpriteObjects[uLayingItemID];
   v3 = &pObjectList->pObjects[v2->uObjectDescID];
   v145 = a2;
   v151 = a2 & 7;
@@ -15813,8 +16044,8 @@
   }
   if ( v151 == OBJECT_BModel && (v2->field_58_pid & 7) != OBJECT_Player)
     BYTE2(pActors[v2->field_58_pid >> 3].uAttributes) |= 4u;
-  v6 = v2->uItemType;
-  v7 = v2->uItemType;
+  v6 = v2->uType;
+  v7 = v2->uType;
   if ( v7 > 3060 )
   {
     if ( v7 > 6090 )
@@ -15833,7 +16064,7 @@
             v98 = v6 + 1;
             v99 = pObjectList->uNumObjects;
             v32 = 0;
-            v2->uItemType = v98;
+            v2->uType = v98;
             v146 = 0;
             if ( (signed int)v99 > 0 )
             {
@@ -15877,7 +16108,7 @@
           if ( !v138 )
           {
             v109 = pObjectList->uNumObjects;
-            ++v2->uItemType;
+            ++v2->uType;
             v110 = 0;
             if ( (signed int)v109 <= 0 )
             {
@@ -15887,7 +16118,7 @@
             else
             {
               v111 = (char *)&pObjectList->pObjects->uObjectID;
-              while ( v2->uItemType != *(short *)v111 )
+              while ( v2->uType != *(short *)v111 )
               {
                 ++v110;
                 v111 += 56;
@@ -15898,7 +16129,7 @@
             }
             v2->uObjectDescID = v112;
             if ( !v112 )
-              LayingItem::OnItemPickup(v153);
+              SpriteObject::OnInteraction(v153);
             v2->vVelocity.z = 0;
             v2->vVelocity.y = 0;
             v2->vVelocity.x = 0;
@@ -15921,7 +16152,7 @@
             goto LABEL_269;
           }
 LABEL_246:
-          LayingItem::OnItemPickup(v153);
+          SpriteObject::OnInteraction(v153);
           return 0;
         }
         v106 = v145;
@@ -15966,7 +16197,7 @@
                 if ( stru_50C198.GetMagicalResistance(&pActors[v139], v107) )
                 {
                   v138 = 0;
-                  if ( v2->uItemType == 8030 )
+                  if ( v2->uType == 8030 )
                   {
                     pActors[v108].uAIState = Standing;
                     pActors[v108].UpdateAnimation();
@@ -16002,13 +16233,13 @@
           && MonsterStats::BelongsToSupertype(pActors[v145 >> 3].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
           sub_43A97E(v153, v145);
         v93 = pObjectList->uNumObjects;
-        ++v2->uItemType;
+        ++v2->uType;
         v9 = 0;
         v52 = 0;
         if ( (signed int)v93 > 0 )
         {
           v94 = (char *)&pObjectList->pObjects->uObjectID;
-          while ( v2->uItemType != *(short *)v94 )
+          while ( v2->uType != *(short *)v94 )
           {
             ++v52;
             v94 += 56;
@@ -16048,7 +16279,7 @@
             v56 = 0;
             v44 = pObjectList->uNumObjects == 0;
             v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-            v2->uItemType = v54;
+            v2->uType = v54;
             if ( v20 | v44 )
             {
 LABEL_102:
@@ -16068,7 +16299,7 @@
             }
             v2->uObjectDescID = v58;
             if ( !v58 )
-              LayingItem::OnItemPickup(v153);
+              SpriteObject::OnInteraction(v153);
             v14 = v153;
             v2->vVelocity.z = 0;
             v2->vVelocity.y = 0;
@@ -16104,7 +16335,7 @@
           v61 = 0;
           v44 = pObjectList->uNumObjects == 0;
           v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-          v2->uItemType = v59;
+          v2->uType = v59;
           if ( v20 | v44 )
           {
 LABEL_111:
@@ -16124,7 +16355,7 @@
           }
           v2->uObjectDescID = v63;
           if ( !v63 )
-            LayingItem::OnItemPickup(v153);
+            SpriteObject::OnInteraction(v153);
           v64 = v2->uFacing - stru_5C6E00->uIntegerDoublePi;
           v44 = v2->field_50 == 4;
           v2->vVelocity.z = 0;
@@ -16147,7 +16378,7 @@
 LABEL_160:
           v14 = v153;
 LABEL_34:
-          LayingItem::OnItemPickup(v14);
+          SpriteObject::OnInteraction(v14);
           goto LABEL_35;
         }
         if ( v151 == 6 || v151 == 5 || (v66 = 0, !v151) )
@@ -16157,7 +16388,7 @@
         v69 = 0;
         v44 = pObjectList->uNumObjects == 0;
         v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-        v2->uItemType = v67;
+        v2->uType = v67;
         if ( v20 | v44 )
         {
 LABEL_128:
@@ -16177,7 +16408,7 @@
         }
         v2->uObjectDescID = v71;
         if ( !v71 )
-          LayingItem::OnItemPickup(v153);
+          SpriteObject::OnInteraction(v153);
         v134 = 0;
         v72 = v153;
         v132 = 0;
@@ -16213,7 +16444,7 @@
         v86 = 0;
         v44 = pObjectList->uNumObjects == 0;
         v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-        v2->uItemType = v84;
+        v2->uType = v84;
         if ( v20 | v44 )
         {
 LABEL_155:
@@ -16233,7 +16464,7 @@
         }
         v2->uObjectDescID = v88;
         if ( !v88 )
-          LayingItem::OnItemPickup(v153);
+          SpriteObject::OnInteraction(v153);
         v89 = v2->uFacing - stru_5C6E00->uIntegerDoublePi;
         v2->vVelocity.z = 0;
         v2->vVelocity.y = 0;
@@ -16260,7 +16491,7 @@
         v81 = 0;
         v44 = pObjectList->uNumObjects == 0;
         v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-        v2->uItemType = 4091;
+        v2->uType = 4091;
         if ( v20 | v44 )
         {
 LABEL_144:
@@ -16280,7 +16511,7 @@
         }
         v2->uObjectDescID = v83;
         if ( !v83 )
-          LayingItem::OnItemPickup(v153);
+          SpriteObject::OnInteraction(v153);
         v134 = 0;
         v72 = v153;
         v132 = v2->field_61;
@@ -16302,7 +16533,7 @@
     {
       sub_43A97E(v153, v145);
       v23 = pObjectList->uNumObjects;
-      ++v2->uItemType;
+      ++v2->uType;
       v18 = 0;
       v24 = 0;
       if ( (signed int)v23 <= 0 )
@@ -16313,7 +16544,7 @@
       else
       {
         v25 = (char *)&pObjectList->pObjects->uObjectID;
-        while ( v2->uItemType != *(short *)v25 )
+        while ( v2->uType != *(short *)v25 )
         {
           ++v24;
           v25 += 56;
@@ -16325,7 +16556,7 @@
 LABEL_42:
       v2->uObjectDescID = v22;
       if ( v22 == v18 )
-        LayingItem::OnItemPickup(v153);
+        SpriteObject::OnInteraction(v153);
       v2->vVelocity.z = v18;
       v2->vVelocity.y = v18;
       v2->vVelocity.x = v18;
@@ -16346,7 +16577,7 @@
         case 540:
           sub_43A97E(v153, v145);
           v8 = pObjectList->uNumObjects;
-          ++v2->uItemType;
+          ++v2->uType;
           v9 = 0;
           v10 = 0;
           if ( (signed int)v8 <= 0 )
@@ -16371,7 +16602,7 @@
           v19 = 0;
           v44 = pObjectList->uNumObjects == 0;
           v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-          v2->uItemType = 600;
+          v2->uType = 600;
           if ( v20 | v44 )
             goto LABEL_41;
           v21 = (char *)&pObjectList->pObjects->uObjectID;
@@ -16387,7 +16618,7 @@
         default:
           return 0;
       }
-      while ( v2->uItemType != *(short *)v11 )
+      while ( v2->uType != *(short *)v11 )
       {
         ++v10;
         v11 += 56;
@@ -16402,8 +16633,8 @@
 LABEL_24:
       v2->uObjectDescID = v12;
       if ( !v12 )
-        LayingItem::OnItemPickup(v153);
-      v44 = v2->uItemType == 555;
+        SpriteObject::OnInteraction(v153);
+      v44 = v2->uType == 555;
       v2->vVelocity.z = 0;
       v2->vVelocity.y = 0;
       v2->vVelocity.x = 0;
@@ -16433,13 +16664,13 @@
 LABEL_93:
     sub_43A97E(v153, v145);
     v51 = pObjectList->uNumObjects;
-    ++v2->uItemType;
+    ++v2->uType;
     v9 = 0;
     v52 = 0;
     if ( (signed int)v51 > 0 )
     {
       v53 = (char *)&pObjectList->pObjects->uObjectID;
-      while ( v2->uItemType != *(short *)v53 )
+      while ( v2->uType != *(short *)v53 )
       {
         ++v52;
         v53 += 56;
@@ -16453,7 +16684,7 @@
 LABEL_182:
     v2->uObjectDescID = v95;
     if ( v95 == (short)v9 )
-      LayingItem::OnItemPickup(v153);
+      SpriteObject::OnInteraction(v153);
     v96 = v2->uSoundID;
     v2->vVelocity.z = v9;
     v2->vVelocity.y = v9;
@@ -16478,7 +16709,7 @@
     v34 = 0;
     v44 = pObjectList->uNumObjects == 0;
     v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-    v2->uItemType = 601;
+    v2->uType = 601;
     if ( v20 | v44 )
     {
 LABEL_69:
@@ -16498,7 +16729,7 @@
     }
     v2->uObjectDescID = v36;
     if ( !v36 )
-      LayingItem::OnItemPickup(v153);
+      SpriteObject::OnInteraction(v153);
     v37 = v2->vPosition.z;
     v2->vVelocity.z = 0;
     v38 = 8 * v153;
@@ -16538,7 +16769,7 @@
       v30 = v6 + 1;
       v31 = pObjectList->uNumObjects;
       v32 = 0;
-      v2->uItemType = v30;
+      v2->uType = v30;
       v146 = 0;
       if ( (signed int)v31 > 0 )
       {
@@ -16555,7 +16786,7 @@
 LABEL_196:
         v2->uObjectDescID = v46;
         if ( v46 == (short)v32 )
-          LayingItem::OnItemPickup(v153);
+          SpriteObject::OnInteraction(v153);
         v100 = v2->field_61;
         v101 = v2->vPosition.z;
         v2->uSpriteFrameID = v32;
@@ -16600,12 +16831,12 @@
   {
     sub_43A97E(v153, v145);
     v122 = pObjectList->uNumObjects;
-    ++v2->uItemType;
+    ++v2->uType;
     v52 = 0;
     if ( (signed int)v122 > 0 )
     {
       v123 = (char *)&pObjectList->pObjects->uObjectID;
-      while ( v2->uItemType != *(short *)v123 )
+      while ( v2->uType != *(short *)v123 )
       {
         ++v52;
         v123 += 56;
@@ -16623,7 +16854,7 @@
   v119 = 0;
   v44 = pObjectList->uNumObjects == 0;
   v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-  v2->uItemType = v117;
+  v2->uType = v117;
   if ( v20 | v44 )
   {
 LABEL_255:
@@ -16643,7 +16874,7 @@
   }
   v2->uObjectDescID = v121;
   if ( !v121 )
-    LayingItem::OnItemPickup(v153);
+    SpriteObject::OnInteraction(v153);
   v2->vVelocity.z = 0;
   v2->vVelocity.y = 0;
   v2->vVelocity.x = 0;