changeset 916:897b10712a1a

UIShop_Buy_Identify_Repair little clean and rename
author Ritor1
date Thu, 25 Apr 2013 17:37:00 +0600
parents 9efbe4bff7ac
children ae9e2a339b09
files Player.cpp Player.h Vis.cpp Vis.h mm7_2.cpp mm7_4.cpp mm7_5.cpp
diffstat 7 files changed, 296 insertions(+), 558 deletions(-) [+]
line wrap: on
line diff
--- a/Player.cpp	Tue Apr 23 09:18:22 2013 +0600
+++ b/Player.cpp	Thu Apr 25 17:37:00 2013 +0600
@@ -366,7 +366,7 @@
 }
 
 //----- (004B8179) --------------------------------------------------------
-int Player::_4B8179(float a2)
+int Player::GetPriceIdentification(float a2)
 {
   signed int v2; // esi@1
   int v3; // ecx@1
@@ -383,7 +383,7 @@
 }
 
 //----- (004B81C3) --------------------------------------------------------
-int Player::_4B81C3(int a2, float a3)
+int Player::GetPriceRepair(int a2, float a3)
 {
   signed int v3; // esi@1
   int v4; // ecx@1
@@ -1886,14 +1886,14 @@
   }
   if ( a5 == 4 )
   {
-    v22 = v27->_4B8179(*v14);
+    v22 = v27->GetPriceIdentification(*v14);
     goto LABEL_35;
   }
   if ( a5 == 5 )
   {
     v20 = *v14;
     v21 = pItem->GetValue();
-    v22 = v27->_4B81C3(v21, v20);
+    v22 = v27->GetPriceRepair(v21, v20);
 LABEL_35:
     v17 = v22;
     goto LABEL_39;
--- a/Player.h	Tue Apr 23 09:18:22 2013 +0600
+++ b/Player.h	Thu Apr 25 17:37:00 2013 +0600
@@ -559,8 +559,8 @@
   int _4B8265(int a2, float a3);
   int _4B8233(int a2, float a3);
   int _4B8213(int a2, float a3);
-  int _4B81C3(int a2, float a3);
-  int _4B8179(float a2);
+  int GetPriceRepair(int a2, float a3);
+  int GetPriceIdentification(float a2);
   int GetBuyingPrice(unsigned int uRealValue, float price_multiplier);
   int _4B8102(int a2, float a3);
   int _4B807C(float a2);
--- a/Vis.cpp	Tue Apr 23 09:18:22 2013 +0600
+++ b/Vis.cpp	Thu Apr 25 17:37:00 2013 +0600
@@ -24,23 +24,23 @@
 
 
 //----- (004C1026) --------------------------------------------------------
-Vis_ObjectInfo *Vis::_4C1026(BLVFace *face, unsigned int a3, float pick_depth)
+Vis_ObjectInfo *Vis::DetermineFacetIntersection(BLVFace *face, unsigned int a3, float pick_depth)
 {
   char *v4; // eax@4
   signed int v5; // ecx@4
   RenderVertexSoft pRay[2]; // [sp+20h] [bp-70h]@17
   int v20; // [sp+84h] [bp-Ch]@10
 
-  static Vis_SelectionList static_sub_4C1026_stru_F8FE00;
-  static_sub_4C1026_stru_F8FE00.uNumPointers = 0;
+  static Vis_SelectionList static_DetermineFacetIntersection_stru_F8FE00;
+  static_DetermineFacetIntersection_stru_F8FE00.uNumPointers = 0;
 
   static bool _init_flag = false;
-  static RenderVertexSoft static_sub_4C1026_array_F8F200[64];
+  static RenderVertexSoft static_DetermineFacetIntersection_array_F8F200[64];
   if (!_init_flag)
   {
     _init_flag = true;
     for (uint i = 0; i < 64; ++i)
-      static_sub_4C1026_array_F8F200[i].flt_2C = 0.0f;
+      static_DetermineFacetIntersection_array_F8F200[i].flt_2C = 0.0f;
   }
 
   if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
@@ -49,9 +49,9 @@
     {
       for ( int i = 0; i < face->uNumVertices; i++)
       {
-        static_sub_4C1026_array_F8F200[i].vWorldPosition.x = (double)pIndoor->pVertices[face->pVertexIDs[i]].x;
-        static_sub_4C1026_array_F8F200[i].vWorldPosition.y = (double)pIndoor->pVertices[face->pVertexIDs[i]].y;
-        static_sub_4C1026_array_F8F200[i].vWorldPosition.z = (double)pIndoor->pVertices[face->pVertexIDs[i]].z;
+        static_DetermineFacetIntersection_array_F8F200[i].vWorldPosition.x = (double)pIndoor->pVertices[face->pVertexIDs[i]].x;
+        static_DetermineFacetIntersection_array_F8F200[i].vWorldPosition.y = (double)pIndoor->pVertices[face->pVertexIDs[i]].y;
+        static_DetermineFacetIntersection_array_F8F200[i].vWorldPosition.z = (double)pIndoor->pVertices[face->pVertexIDs[i]].z;
       }
     }
   }
@@ -61,48 +61,48 @@
     auto v = (Vec3_int_ *)pOutdoor->pBModels[bmodel_id].pVertices.pVertices;
     for (uint i = 0; i < face->uNumVertices; ++i)
     {
-      static_sub_4C1026_array_F8F200[i].vWorldPosition.x = v[face->pVertexIDs[i]].x;
-      static_sub_4C1026_array_F8F200[i].vWorldPosition.y = v[face->pVertexIDs[i]].y;
-      static_sub_4C1026_array_F8F200[i].vWorldPosition.z = v[face->pVertexIDs[i]].z;
+      static_DetermineFacetIntersection_array_F8F200[i].vWorldPosition.x = v[face->pVertexIDs[i]].x;
+      static_DetermineFacetIntersection_array_F8F200[i].vWorldPosition.y = v[face->pVertexIDs[i]].y;
+      static_DetermineFacetIntersection_array_F8F200[i].vWorldPosition.z = v[face->pVertexIDs[i]].z;
     }
   }
   else assert(false);
 
-  pGame->pIndoorCameraD3D->ViewTransform(static_sub_4C1026_array_F8F200, face->uNumVertices);
-  pGame->pIndoorCameraD3D->Project(static_sub_4C1026_array_F8F200, face->uNumVertices, 1);
+  pGame->pIndoorCameraD3D->ViewTransform(static_DetermineFacetIntersection_array_F8F200, face->uNumVertices);
+  pGame->pIndoorCameraD3D->Project(static_DetermineFacetIntersection_array_F8F200, face->uNumVertices, 1);
 
   //v15 = this;
-  SortVectors_x(static_sub_4C1026_array_F8F200, 0, face->uNumVertices - 1);
-  if (static_sub_4C1026_array_F8F200[0].vWorldViewPosition.x > pick_depth)
+  SortVectors_x(static_DetermineFacetIntersection_array_F8F200, 0, face->uNumVertices - 1);
+  if (static_DetermineFacetIntersection_array_F8F200[0].vWorldViewPosition.x > pick_depth)
     return nullptr;
 
   float screenspace_center_x,
         screenspace_center_y;
-  GetPolygonScreenSpaceCenter(static_sub_4C1026_array_F8F200, face->uNumVertices, &screenspace_center_x, &screenspace_center_y);
-  if (IsPolygonOccludedByBillboard(static_sub_4C1026_array_F8F200, face->uNumVertices, screenspace_center_x, screenspace_center_y))
+  GetPolygonScreenSpaceCenter(static_DetermineFacetIntersection_array_F8F200, face->uNumVertices, &screenspace_center_x, &screenspace_center_y);
+  if (IsPolygonOccludedByBillboard(static_DetermineFacetIntersection_array_F8F200, face->uNumVertices, screenspace_center_x, screenspace_center_y))
     return nullptr;
 
   CastPickRay(pRay, screenspace_center_x, screenspace_center_y, pick_depth);
 
   if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
-    PickOutdoorFaces_Mouse(pick_depth, pRay, &static_sub_4C1026_stru_F8FE00, &vis_face_filter, true);
+    PickOutdoorFaces_Mouse(pick_depth, pRay, &static_DetermineFacetIntersection_stru_F8FE00, &vis_face_filter, true);
   else if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
-    PickIndoorFaces_Mouse(pick_depth, pRay, &static_sub_4C1026_stru_F8FE00, &vis_face_filter);
+    PickIndoorFaces_Mouse(pick_depth, pRay, &static_DetermineFacetIntersection_stru_F8FE00, &vis_face_filter);
   else assert(false);
 
-  static_sub_4C1026_stru_F8FE00.create_object_pointers();
-  sort_object_pointers(static_sub_4C1026_stru_F8FE00.object_pointers, 0, static_sub_4C1026_stru_F8FE00.uNumPointers - 1);
-  if (!static_sub_4C1026_stru_F8FE00.uNumPointers)
+  static_DetermineFacetIntersection_stru_F8FE00.create_object_pointers();
+  sort_object_pointers(static_DetermineFacetIntersection_stru_F8FE00.object_pointers, 0, static_DetermineFacetIntersection_stru_F8FE00.uNumPointers - 1);
+  if (!static_DetermineFacetIntersection_stru_F8FE00.uNumPointers)
     return nullptr;
 
-  if (!static_sub_4C1026_stru_F8FE00.sub_4C2551(2, a3))
+  if (!static_DetermineFacetIntersection_stru_F8FE00.sub_4C2551(2, a3))
     return nullptr;
 
-  if (static_sub_4C1026_stru_F8FE00.uNumPointers)
-    return static_sub_4C1026_stru_F8FE00.object_pointers[0];
+  if (static_DetermineFacetIntersection_stru_F8FE00.uNumPointers)
+    return static_DetermineFacetIntersection_stru_F8FE00.object_pointers[0];
   else return nullptr;
 }
-// F91E08: using guessed type char static_sub_4C1026_byte_F91E08__init_flags;
+// F91E08: using guessed type char static_DetermineFacetIntersection_byte_F91E08__init_flags;
 
 //----- (004C12C3) --------------------------------------------------------
 bool Vis::IsPolygonOccludedByBillboard(RenderVertexSoft *vertices, int num_vertices, float x, float y)
@@ -214,7 +214,7 @@
 {
   for (uint i = 0; i < pRenderer->uNumBillboardsToDraw; ++i)
   {
-    auto d3d_billboard = pRenderer->pBillboardRenderListD3D + i;
+    auto d3d_billboard = &pRenderer->pBillboardRenderListD3D[i];
     if (is_part_of_selection((void *)i, filter) && IsPointInsideD3DBillboard(d3d_billboard, fX, fY))
     {
       if (DoesRayIntersectBillboard(fPickDepth, i))
@@ -366,7 +366,7 @@
     auto bmodel = &pOutdoor->pBModels[i];
     for (uint j = 0; j < bmodel->uNumFaces; ++j)
     {
-      auto face = bmodel->pFaces + j;
+      auto face = &bmodel->pFaces[j];
       if (is_part_of_selection(face, filter))
       {
         BLVFace blv_face;
@@ -375,7 +375,7 @@
         RenderVertexSoft intersection;
         if (Intersect_Ray_Face(pRay, pRay + 1, &fDepth, &intersection, &blv_face, i))
         {
-          pGame->pIndoorCameraD3D->ViewTransform(&intersection, 1u);
+          pGame->pIndoorCameraD3D->ViewTransform(&intersection, 1);
           int v13 = _48B561_mess_with_scaling_along_z(/*v12, */intersection.vWorldViewPosition.x);
           v13 += PID(OBJECT_BModel, j | (i << 6));
 
@@ -1819,7 +1819,7 @@
         {
           if ( is_part_of_selection(pFace, filter) )
           {
-            v8 = _4C1026(pFace, PID(OBJECT_BModel, pFaceID), pick_depth);
+            v8 = DetermineFacetIntersection(pFace, PID(OBJECT_BModel, pFaceID), pick_depth);
             if ( v8 )
               list->AddObject(v8->object, v8->object_type, v8->sZValue);
           }
@@ -1844,7 +1844,7 @@
     auto bmodel = pOutdoor->pBModels + i;
     for (uint j = 0; j < bmodel->uNumFaces; ++j)
     {
-      auto face = bmodel->pFaces + j;
+      auto face = &bmodel->pFaces[j];
 
       if (is_part_of_selection(face, filter) )
       {
@@ -1852,7 +1852,7 @@
         blv_face.FromODM(face);
 
         int pid = PID(OBJECT_BModel, j | (i << 6));
-        if (auto object_info = _4C1026(&blv_face, pid, pick_depth))
+        if (auto object_info = DetermineFacetIntersection(&blv_face, pid, pick_depth))
           list->AddObject(object_info->object, object_info->object_type, object_info->sZValue);
       }
     }
--- a/Vis.h	Tue Apr 23 09:18:22 2013 +0600
+++ b/Vis.h	Thu Apr 25 17:37:00 2013 +0600
@@ -100,7 +100,7 @@
 
   bool is_part_of_selection(void *uD3DBillboardIdx_or_pBLVFace_or_pODMFace, Vis_SelectionFilter *filter);
   bool DoesRayIntersectBillboard(float fDepth, unsigned int uD3DBillboardIdx);
-  Vis_ObjectInfo *_4C1026(struct BLVFace *face, unsigned int a3, float pick_depth);
+  Vis_ObjectInfo *DetermineFacetIntersection(struct BLVFace *face, unsigned int a3, float pick_depth);
   bool IsPolygonOccludedByBillboard(struct RenderVertexSoft *vertices, int num_vertices, float x, float y);
   void GetPolygonCenter(struct RenderVertexD3D3 *pVertices, unsigned int uNumVertices, float *pCenterX, float *pCenterY);
   void GetPolygonScreenSpaceCenter(struct RenderVertexSoft *vertices, int num_vertices, float *out_center_x, float *out_center_y);
--- a/mm7_2.cpp	Tue Apr 23 09:18:22 2013 +0600
+++ b/mm7_2.cpp	Thu Apr 25 17:37:00 2013 +0600
@@ -890,91 +890,28 @@
 //----- (004BDB56) --------------------------------------------------------
 void __cdecl UIShop_Buy_Identify_Repair()
 {
-  Player *v0; // edi@1
-  signed int v1; // esi@9
-  unsigned int v2; // eax@11
-  int v3; // esi@12
-  float v4; // ST1C_4@12
-  signed int v5; // eax@12
-  signed int v6; // eax@12
-  char v7; // zf@12
   int v8; // eax@15
-  const char *v9; // ecx@15
-  signed int v10; // esi@18
-  unsigned int v11; // esi@20
-  int v12; // esi@21
-  void *v13; // ecx@26
-  signed int v14; // esi@31
+  unsigned int pItemID; // esi@20
+  ItemGen *item; // esi@21
   unsigned int v15; // eax@33
-  GUIWindow *v16; // esi@34
-  POINT *v17; // esi@37
+  POINT *pCursorPos; // esi@37
   int v18; // ecx@37
-  void *v19; // eax@38
-  ItemGen *v20; // esi@38
-  float v21; // ST1C_4@38
-  signed int v22; // eax@38
-  int v23; // ebx@38
-  int v24; // edx@39
-  int v25; // eax@40
-  int v26; // ebx@41
-  Player *v27; // ecx@43
-  POINT *v28; // esi@49
-  int v29; // ecx@49
-  void *v30; // eax@50
-  int v31; // ecx@50
-  ItemGen *v32; // esi@51
-  //float v33; // ST1C_4@53
-  //signed int v34; // eax@53
-  //int v35; // eax@53
-  //bool v36; // eax@53
-  unsigned int v37; // eax@53
-  int v38; // eax@55
+  float pPriceMultiplier; // ST1C_4@38
+  int taken_item; // eax@40
+  ItemGen *bought_item; // esi@51
+  int party_reputation; // eax@55
   int v39; // eax@63
-  //int v40; // eax@64
-  int v41; // edx@66
   int v42; // esi@74
   signed int v43; // ebx@74
-  int v44; // ecx@74
   unsigned __int16 *pSkill; // esi@77
-  signed int v46; // [sp-18h] [bp-CCh]@36
-  unsigned int v47; // [sp-14h] [bp-C8h]@36
-  signed int v48; // [sp-10h] [bp-C4h]@36
-  signed int v49; // [sp-Ch] [bp-C0h]@36
-  int v50; // [sp-8h] [bp-BCh]@36
-  int v51; // [sp-4h] [bp-B8h]@28
-  unsigned int v52; // [sp-4h] [bp-B8h]@36
-  int v53; // [sp+0h] [bp-B4h]@16
-  unsigned int v54; // [sp+0h] [bp-B4h]@25
   int v55; // [sp+0h] [bp-B4h]@26
-  int v56; // [sp+0h] [bp-B4h]@36
-  //POINT v57; // [sp+10h] [bp-A4h]@49
-  //POINT v58; // [sp+18h] [bp-9Ch]@18
-  POINT v59; // [sp+20h] [bp-94h]@49
-  POINT v60; // [sp+28h] [bp-8Ch]@9
-  POINT v61; // [sp+30h] [bp-84h]@37
-  POINT v62; // [sp+38h] [bp-7Ch]@18
-  POINT v63; // [sp+40h] [bp-74h]@37
-  //POINT v64; // [sp+48h] [bp-6Ch]@19
-  POINT v65; // [sp+50h] [bp-64h]@32
-  //POINT v66; // [sp+58h] [bp-5Ch]@18
-  POINT v67; // [sp+60h] [bp-54h]@31
-  POINT a2; // [sp+68h] [bp-4Ch]@9
-  POINT v69; // [sp+70h] [bp-44h]@31
-  POINT v70; // [sp+78h] [bp-3Ch]@9
-  POINT v71; // [sp+80h] [bp-34h]@31
-  POINT v72; // [sp+88h] [bp-2Ch]@10
-  //bool v73; // [sp+90h] [bp-24h]@53
-  int v74; // [sp+94h] [bp-20h]@53
+  POINT cursor; // [sp+40h] [bp-74h]@37
   int a6; // [sp+98h] [bp-1Ch]@57
   int a3; // [sp+9Ch] [bp-18h]@53
-  //Player *v77; // [sp+A0h] [bp-14h]@1
   unsigned int uNumSeconds; // [sp+A4h] [bp-10h]@53
   unsigned int v79; // [sp+A8h] [bp-Ch]@9
-  int v80; // [sp+ACh] [bp-8h]@12
-  ItemGen *_this; // [sp+B0h] [bp-4h]@13
-
-  v0 = pPlayers[uActiveCharacter];
-  //v77 = pPlayers[uActiveCharacter];
+  int uPriceItemService; // [sp+ACh] [bp-8h]@12
+
   if ( pCurrentScreen == SCREEN_E )
   {
     sub_421EA6_OnInventoryLeftClick();
@@ -996,34 +933,29 @@
     }
     case HOUSE_DIALOGUE_GUILD_BUY_BOOKS:
     {
-      v17 = pMouse->GetCursorPos(&v63);
-      v18 = pRenderer->pActiveZBuffer[v17->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v61)->y]] & 0xFFFF;
+      pCursorPos = pMouse->GetCursorPos(&cursor);
+      v18 = pRenderer->pActiveZBuffer[pCursorPos->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&cursor)->y]] & 0xFFFF;
       if ( !v18 )
         return;
-      v20 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)window_SpeakInHouse->ptr_1C));
-      v21 = p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
-      _this = v20;
-      v22 = v20->GetValue();
-      v23 = pPlayers[uActiveCharacter]->GetBuyingPrice(v22, v21);
-      v80 = v23;
+      bought_item = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)window_SpeakInHouse->ptr_1C));
+      pPriceMultiplier = p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
+      uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), pPriceMultiplier);
       GetAsyncKeyState(VK_CONTROL);
-      if ( pParty->uNumGold < v23 )
-      {
-        v24 = 2;
-        PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v24);
+      if ( pParty->uNumGold < uPriceItemService )
+      {
+        PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2);
         ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);
         return;
       }
-      v25 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, v20->uItemID);
-      if ( v25 )
-      {
-        v26 = 1;
-        v20->SetIdentified();
-        memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v25-1], v20, 0x24u);
-        dword_F8B1E4 = v26;
-        Party::TakeGold(v80);
-        viewparams->bRedrawGameUI = v26;
-        _this->Reset();
+      taken_item = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, bought_item->uItemID);
+      if ( taken_item )
+      {
+        bought_item->SetIdentified();
+        memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[taken_item - 1], bought_item, 0x24u);
+        dword_F8B1E4 = 1;
+        Party::TakeGold(uPriceItemService);
+        viewparams->bRedrawGameUI = 1;
+        bought_item->Reset();
         pRenderer->ClearZBuffer(0, 479);
         pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0);
         return;
@@ -1034,17 +966,15 @@
     }
     case HOUSE_DIALOGUE_SHOP_SELL:
     {
-      v14 = pMouse->GetCursorPos(&v71)->x - 14;
-      v79 = (v14 >> 5) + 14 * ((pMouse->GetCursorPos(&v69)->y - 17) >> 5);
-      if ( pMouse->GetCursorPos(&v67)->x <= 13
-        || pMouse->GetCursorPos(&v65)->x >= 462
+      v79 = ((pMouse->GetCursorPos(&cursor)->x - 14) >> 5) + 14 * ((pMouse->GetCursorPos(&cursor)->y - 17) >> 5);
+      if ( pMouse->GetCursorPos(&cursor)->x <= 13
+        || pMouse->GetCursorPos(&cursor)->x >= 462
         || (v15 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79), !v15) )
           return;
-      v16 = window_SpeakInHouse;
-      if ( MerchandiseTest(&pPlayers[uActiveCharacter]->pInventoryItems[v15-1], (int)window_SpeakInHouse->ptr_1C) )
+      if ( MerchandiseTest(&pPlayers[uActiveCharacter]->pInventoryItems[v15 - 1], (int)window_SpeakInHouse->ptr_1C) )
       {
         dword_F8B1E4 = 1;
-        pPlayers[uActiveCharacter]->SalesProcess(v79, v15 - 1, (int)v16->ptr_1C);
+        pPlayers[uActiveCharacter]->SalesProcess(v79, v15 - 1, (int)window_SpeakInHouse->ptr_1C);
         viewparams->bRedrawGameUI = 1;
         pRenderer->ClearZBuffer(0, 479);
         pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)77, 0);
@@ -1056,33 +986,29 @@
     }
     case HOUSE_DIALOGUE_SHOP_IDENTIFY:
     {
-      pMouse->GetCursorPos(&v62);
-      v10 = v62.x - 14;
-      v79 = (v10 >> 5) + 14 * ((v62.y - 17) >> 5);
-      if (v62.x > 13  && v62.x < 462)
-      {
-        v11 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79);
-        if ( v11 )
-        {
-          //v80 = v0->_4B8179(p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C]);
-          v80 = pPlayers[uActiveCharacter]->_4B8179(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier);
-          v12 = (int)&pPlayers[uActiveCharacter]->pInventoryItems[v11-1];
-          if ( !(*(char *)(v12 + 20) & 1) )
-          {
-            _this = (ItemGen *)window_SpeakInHouse->ptr_1C;
-            if ( MerchandiseTest((ItemGen *)v12, (int)_this) )
+      pMouse->GetCursorPos(&cursor);
+      v79 = ((cursor.x - 14) >> 5) + 14 * ((cursor.y - 17) >> 5);
+      if (cursor.x > 13  && cursor.x < 462)
+      {
+        pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79);
+        if ( pItemID )
+        {
+          uPriceItemService = pPlayers[uActiveCharacter]->GetPriceIdentification(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier);
+          item = &pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1];
+          if ( !(item->uAttributes & 1) )
+          {
+            if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) )
             {
-              if ( pParty->uNumGold >= v80 )
+              if ( pParty->uNumGold >= uPriceItemService )
               {
                 dword_F8B1E4 = 1;
-                Party::TakeGold(v80);
-                *(int *)(v12 + 20) |= 1u;
+                Party::TakeGold(uPriceItemService);
+                item->uAttributes |= 1;
                 pPlayers[uActiveCharacter]->PlaySound(SPEECH_73, 0);
-                v9 = pGlobalTXT_LocalizationStrings[569];
-                ShowStatusBarString(v9, 2);
+                ShowStatusBarString(pGlobalTXT_LocalizationStrings[569], 2);
                 return;
               }
-              PlayHouseSound((unsigned int)_this, (HouseSoundID)2);
+              PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2);
               return;
             }
             pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
@@ -1097,41 +1023,34 @@
     }
     case HOUSE_DIALOGUE_SHOP_REPAIR:
     {
-      v1 = pMouse->GetCursorPos(&a2)->x - 14;
-      v79 = (v1 >> 5) + 14 * ((pMouse->GetCursorPos(&v70)->y - 17) >> 5);
-      if ( pMouse->GetCursorPos(&v60)->x > 13 )
-      {
-        if ( pMouse->GetCursorPos(&v72)->x < 462 )
-        {
-          v2 = v0->GetItemIDAtInventoryIndex((int *)&v79);
-          if ( v2 )
-          {
-            v3 = (int)&v0->pInventoryItems[v2-1];
-            //v4 = p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C];
-            v4 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
-            auto _v = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v2-1];
-            v5 = _v->GetValue();
-            v6 = pPlayers[uActiveCharacter]->_4B81C3(v5, v4);
-            v7 = (*(char *)(v3 + 20) & 2) == 0;
-            v80 = v6;
-            if ( !v7 )
+      v79 = ((pMouse->GetCursorPos(&cursor)->x - 14) >> 5) + 14 * ((pMouse->GetCursorPos(&cursor)->y - 17) >> 5);
+      if ( pMouse->GetCursorPos(&cursor)->x > 13 )
+      {
+        if ( pMouse->GetCursorPos(&cursor)->x < 462 )
+        {
+          pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79);
+          if ( pItemID )
+          {
+            item = &pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1];
+            pPriceMultiplier = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
+            auto _v = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1];
+            uPriceItemService = pPlayers[uActiveCharacter]->GetPriceRepair(_v->GetValue(), pPriceMultiplier);
+            if ( item->uAttributes & 2 )
             {
-              _this = (ItemGen *)window_SpeakInHouse->ptr_1C;
-              if ( MerchandiseTest((ItemGen *)v3, (int)_this) )
+              if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) )
               {
-                if ( pParty->uNumGold >= v80 )
+                if ( pParty->uNumGold >= uPriceItemService )
                 {
                   dword_F8B1E4 = 1;
-                  Party::TakeGold(v80);
-                  v8 = *(int *)(v3 + 20);
+                  Party::TakeGold(uPriceItemService);
+                  v8 = item->uAttributes;
                   LOBYTE(v8) = v8 & 0xFD;
-                  *(int *)(v3 + 20) = v8 | 1;
+                  item->uAttributes = v8 | 1;
                   pPlayers[uActiveCharacter]->PlaySound(SPEECH_74, 0);
-                  v9 = pGlobalTXT_LocalizationStrings[570];
-                  ShowStatusBarString(v9, 2);
+                  ShowStatusBarString(pGlobalTXT_LocalizationStrings[570], 2);
                   return;
                 }
-                PlayHouseSound((unsigned int)_this, (HouseSoundID)2);
+                PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2);
                 return;
               }
               pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
@@ -1148,42 +1067,25 @@
     case HOUSE_DIALOGUE_SHOP_BUY_STANDARD:
     case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL:
     {
-      v28 = pMouse->GetCursorPos(&v59);
-      v29 = pRenderer->pActiveZBuffer[v28->x + pSRZBufferLineOffsets[v28->y]] & 0xFFFF;
-      if ( !v29 )
+      pCursorPos = pMouse->GetCursorPos(&cursor);
+      v18 = pRenderer->pActiveZBuffer[pCursorPos->x + pSRZBufferLineOffsets[pCursorPos->y]] & 0xFFFF;
+      if ( !v18 )
         return;
-      v30 = window_SpeakInHouse->ptr_1C;
-      // v31 = 9 * (v29 - 1 + 12 * (int)v30);
       if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
-      {
-        v32 = (ItemGen *)&pParty->StandartItemsInShops[(int)v30][v29 - 1];
-        _this = (ItemGen *)&pParty->StandartItemsInShops[(int)v30][v29 - 1];
-      }
+        bought_item = (ItemGen *)&pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1];
       else
-      {
-        _this =&pParty->SpecialItemsInShops[(int)v30][v29-1]; //(ItemGen *)&pParty->field_C59C[v31 + 724];
-        v32 = &pParty->SpecialItemsInShops[(int)v30][v29-1];//(ItemGen *)&pParty->field_C59C[v31 + 724];
-      }
-      //v33 = p2DEvents_minus1__20[13 * (signed int)v30];
-      //v33 = p2DEvents[(signed int)v30 - 1].fPriceMultiplier;
-      //v34 = v32->GetValue();
-      v80 = pPlayers[uActiveCharacter]->GetBuyingPrice(v32->GetValue(), p2DEvents[(unsigned int)v30 - 1].fPriceMultiplier);
-      //LOWORD(v35) = GetAsyncKeyState(VK_CONTROL);
-      v74 = GetAsyncKeyState(VK_CONTROL);
-      //v36 = v0->CanSteal();
+        bought_item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1];//(ItemGen *)&pParty->field_C59C[v31 + 724];
+      uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier);
       uNumSeconds = 0;
       a3 = 0;
-      //v73 = v0->CanSteal();
-      v37 = pMapStats->GetMapInfo(pCurrentMapName);
-      if ( v37 )
-        a3 = pMapStats->pInfos[v37]._steal_perm;
-      v38 = GetPartyReputation();
-      v26 = 1;
+      if ( pMapStats->GetMapInfo(pCurrentMapName) )
+        a3 = pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)]._steal_perm;
+      party_reputation = GetPartyReputation();
       if (pPlayers[uActiveCharacter]->CanSteal())
       {
-        if ( v74 )
-        {
-          uNumSeconds = pPlayers[uActiveCharacter]->StealFromShop(v32, a3, v38, 0, &a6);
+        if ( GetAsyncKeyState(VK_CONTROL) )
+        {
+          uNumSeconds = pPlayers[uActiveCharacter]->StealFromShop(bought_item, a3, party_reputation, 0, &a6);
           if ( !uNumSeconds )
           {
             sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, 0, a6);
@@ -1191,56 +1093,49 @@
           }
         }
       }
-      if ( pParty->uNumGold < v80 )
-      {
-        v24 = 2;
+      if ( pParty->uNumGold < uPriceItemService )
+      {
         if ( uNumSeconds != 2 )
         {
           if ( uNumSeconds != 1 )
           {
-            PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v24);
+            PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2);
             ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold"
             return;
           }
         }
       }
-      v39 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, v32->uItemID);
+      v39 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, bought_item->uItemID);
       if ( v39 )
       {
-        v32->SetIdentified();
-        v7 = pPlayers[uActiveCharacter]->CanSteal();
-        //v40 = (int)((char *)v0 + 36 * v39);
-        //memcpy((void *)(v40 + 496), v32, 0x24u);
-        memcpy(&v0->pInventoryItems[v39 - 1], v32, sizeof(ItemGen));
-        if ( v7 )
-        {
-          if ( v74 )
-          {
-            v41 = uNumSeconds;
+        bought_item->SetIdentified();
+        memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v39 - 1], bought_item, sizeof(ItemGen));
+        if ( pPlayers[uActiveCharacter]->CanSteal() )
+        {
+          if ( GetAsyncKeyState(VK_CONTROL) )
+          {
             if ( uNumSeconds == 1 || uNumSeconds == 2 )
             {
-              //*(char *)(v40 + 517) |= 1u;
               pPlayers[uActiveCharacter]->pInventoryItems[v39 - 1].SetStolen();
-              sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, v41, a6);
-              viewparams->bRedrawGameUI = v26;
-              _this->Reset();
+              sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, uNumSeconds, a6);
+              viewparams->bRedrawGameUI = 1;
+              bought_item->Reset();
               pRenderer->ClearZBuffer(0, 479);
               pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0);
               return;
             }
           }
         }
-        dword_F8B1E4 = v26;
-        Party::TakeGold(v80);
-        viewparams->bRedrawGameUI = v26;
-        _this->Reset();
+        dword_F8B1E4 = 1;
+        Party::TakeGold(uPriceItemService);
+        viewparams->bRedrawGameUI = 1;
+        bought_item->Reset();
         pRenderer->ClearZBuffer(0, 479);
         pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0);
         return;
       }
       pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0);
-      v9 = pGlobalTXT_LocalizationStrings[563];   // "Pack is Full!"
-      ShowStatusBarString(v9, 2);
+      ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 2); // "Pack is Full!"
       break;
     }
     default:// if click video screen in shop
@@ -1251,15 +1146,15 @@
         v42 = dialog_menu_id - 36;
         //v43 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0);
         v43 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
-        v44 = v43 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
-        if ( v44 < v43 / 3 )
-          v44 = v43 / 3;
+        uPriceItemService = v43 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
+        if ( uPriceItemService < v43 / 3 )
+          uPriceItemService = v43 / 3;
         if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v42] )
         {
           pSkill = &pPlayers[uActiveCharacter]->pActiveSkills[v42];
           if ( !*pSkill )
           {
-            if ( pParty->uNumGold < v44 )
+            if ( pParty->uNumGold < uPriceItemService )
             {
               ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold"
               if ( in_current_building_type == BildingType_Training )
@@ -1269,7 +1164,7 @@
               PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v55);
               return;
             }
-            Party::TakeGold(v44);
+            Party::TakeGold(uPriceItemService);
             dword_F8B1E4 = 1;
            *pSkill = 1;
             pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)78, 0);
@@ -9466,7 +9361,7 @@
   int v1; // ecx@1
   unsigned int v2; // edi@1
   unsigned int v3; // edx@4
-  unsigned int v4; // esi@5
+  unsigned int pSkillType; // esi@5
   unsigned __int16 v5; // ax@7
   unsigned int v6; // edi@19
   int v7; // esi@27
@@ -9508,24 +9403,24 @@
   unsigned int v50; // [sp+38h] [bp-14h]@50
   int v51; // [sp+3Ch] [bp-10h]@1
   unsigned int v52; // [sp+40h] [bp-Ch]@5
-  int v53; // [sp+44h] [bp-8h]@1
-  unsigned int v54; // [sp+48h] [bp-4h]@1
+  //int v53; // [sp+44h] [bp-8h]@1
+  //unsigned int v54; // [sp+48h] [bp-4h]@1
 
   v51 = 0;
   _this.Reset();
   //v0 = pPlayers[uActiveCharacter];
   v1 = pPlayers[uActiveCharacter]->pEquipment.uMainHand;
   v2 = pPlayers[uActiveCharacter]->pEquipment.uShield;
-  v54 = pPlayers[uActiveCharacter]->pEquipment.uShield;
-  v53 = v1;
-  if ( v1 && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1-1]].uEquipType == 1 )
+  //v54 = pPlayers[uActiveCharacter]->pEquipment.uShield;
+  //v53 = v1;
+  if ( v1 && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1 - 1]].uEquipType == 1 )
     v51 = v1;
   v3 = pParty->pPickedItem.uItemID;
   if ( pParty->pPickedItem.uItemID )
   {
     v52 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType;
-    v4 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSkillType;
-    if ( v4 == 4 )
+    pSkillType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSkillType;
+    if ( pSkillType == 4 )
     {
       if ( v2 )
       {
@@ -9540,7 +9435,7 @@
     }
     else
     {
-      if ( (v4 == 8 || v4 == 1 || v4 == 2)
+      if ( (pSkillType == 8 || pSkillType == 1 || pSkillType == 2)
         && v1
         && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1-1]].uSkillType == 4 )
 	  {
@@ -9575,7 +9470,7 @@
       case 8u:
       case 9u:
       case 0xBu:
-        if ( !pPlayers[uActiveCharacter]->HasSkill(v4) )
+        if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) )
         {
           pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0);
           return;
@@ -9637,21 +9532,21 @@
 			pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
 			return;
 		}
-        if ( !pPlayers[uActiveCharacter]->HasSkill(v4) )
+        if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) )
         {
           pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0);
           return;
         }
-        if ( v54 )
-        {
-          --v54;
+        if ( v2 )
+        {
+          --v2;
           memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
-          v12 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v54);
+          v12 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v2);
           *(char *)(v12 + 556) = 0;
           pParty->pPickedItem.Reset();
           pParty->SetHoldingItem((ItemGen *)(v12 + 532));
           _this.uBodyAnchor = 1;
-          v13 = v54 + 1;
+          v13 = v2 + 1;
           v14 = v51 == 0;
           memcpy((void *)(v12 + 532), &_this, 0x24u);
           pPlayers[uActiveCharacter]->pEquipment.uShield = v13;
@@ -9673,7 +9568,7 @@
 	        return;
           }
           memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
-          v15 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v53 - 1));
+          v15 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v1 - 1));
           *(char *)(v15 + 556) = 0;
           pParty->pPickedItem.Reset();
           pParty->SetHoldingItem((ItemGen *)(v15 + 532));
@@ -9693,14 +9588,14 @@
 			pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
 			return;
 		}
-        if ( !pPlayers[uActiveCharacter]->HasSkill(v4) )
+        if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) )
         {
           pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0);
           return;
         }
         v50 = 0;
-        if ( v4 == 2 && (unsigned __int16)(pPlayers[uActiveCharacter]->pActiveSkills[2] & 0xFFC0)
-          || v4 == 1 && (signed int)SkillToMastery(pPlayers[uActiveCharacter]->pActiveSkills[1]) >= 3 )
+        if ( pSkillType == 2 && (unsigned __int16)(pPlayers[uActiveCharacter]->pActiveSkills[2] & 0xFFC0)
+          || pSkillType == 1 && (signed int)SkillToMastery(pPlayers[uActiveCharacter]->pActiveSkills[1]) >= 3 )
         {
           if (pAsyncMouse)
           {
@@ -9717,16 +9612,16 @@
           {
             if ( !v51 )
             {
-              if ( v54 )
+              if ( v2 )
               {
-                --v54;
+                --v2;
                 memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
-                v20 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v54);
+                v20 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v2);
                 *(char *)(v20 + 556) = 0;
                 pParty->pPickedItem.Reset();
                 pParty->SetHoldingItem((ItemGen *)(v20 + 532));
                 _this.uBodyAnchor = 1;
-                v21 = v54 + 1;
+                v21 = v2 + 1;
                 v14 = v52 == 12;
                 memcpy((void *)(v20 + 532), &_this, 0x24u);
                 pPlayers[uActiveCharacter]->pEquipment.uShield = v21;
@@ -9737,9 +9632,7 @@
 				if ( v50 )
                 {
                 __debugbreak();  // looks like offset in player's inventory and wand_lut much like case in 0042ECB5
-				  stru_A750F8[uActiveCharacter - 1]._494836(
-					*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50),
-					uActiveCharacter - 1 + 9);
+				  stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9);
                 }
 				break;
               }
@@ -9758,14 +9651,13 @@
 			  if ( v50 )
               {
                 __debugbreak();  // looks like offset in player's inventory and wand_lut much like case in 0042ECB5
-				stru_A750F8[uActiveCharacter - 1]._494836(
-				*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9);
+				stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9);
               }
 			  break;
             }
           }
         }
-        if ( !v53 )
+        if ( !v1 )
         {
           v26 = pPlayers[uActiveCharacter]->FindFreeInventorySlot();
           if ( (v26 & 0x80000000u) != 0 )
@@ -9782,20 +9674,18 @@
 			  if ( v50 )
               {
                 __debugbreak();  // looks like offset in player's inventory and wand_lut much like case in 0042ECB5
-				stru_A750F8[uActiveCharacter - 1]._494836(
-				*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50),
-				uActiveCharacter - 1 + 9);
+				stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9);
               }
 			  break;
         }
-        --v53;
+        --v1;
         memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
-        v24 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v53);
+        v24 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v1);
         *(char *)(v24 + 556) = 0;
         pParty->pPickedItem.Reset();
         pParty->SetHoldingItem((ItemGen *)(v24 + 532));
         _this.uBodyAnchor = 2;
-        v25 = v53 + 1;
+        v25 = v1 + 1;
         v14 = v52 == 12;
         memcpy((void *)(v24 + 532), &_this, 0x24u);
         pPlayers[uActiveCharacter]->pEquipment.uMainHand = v25;
@@ -9806,9 +9696,7 @@
         if ( v50 )
         {
                 __debugbreak();  // looks like offset in player's inventory and wand_lut much like case in 0042ECB5
-          stru_A750F8[uActiveCharacter - 1]._494836(
-            *((int *)&pSpellDatas[66].uNormalLevelRecovery + v50),
-            uActiveCharacter - 1 + 9);
+          stru_A750F8[uActiveCharacter - 1]._494836( *((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9);
         }
         break;
       case 1u:
@@ -9817,26 +9705,26 @@
 			pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
 			return;
 		}
-        if ( !pPlayers[uActiveCharacter]->HasSkill(v4) )
+        if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) )
         {
           pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0);
           return;
         }
-        if ( v53 )
-        {
-          if ( v54 )
+        if ( v1 )
+        {
+          if ( v2 )
           {
 			pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
 			return;
           }
-          --v53;
+          --v1;
           memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
-          v27 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v53);
+          v27 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v1);
           *(char *)(v27 + 556) = 0;
           pParty->pPickedItem.Reset();
           pParty->SetHoldingItem((ItemGen *)(v27 + 532));
           _this.uBodyAnchor = 2;
-          v28 = v53 + 1;
+          v28 = v1 + 1;
           memcpy((void *)(v27 + 532), &_this, 0x24u);
           pPlayers[uActiveCharacter]->pEquipment.uMainHand = v28;
         }
@@ -9845,10 +9733,10 @@
           v52 = pPlayers[uActiveCharacter]->FindFreeInventorySlot();
           if ( (v52 & 0x80000000u) == 0 )
           {
-            if ( v54 )
+            if ( v2 )
             {
               memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
-              v29 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v54 - 1));
+              v29 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v2 - 1));
               *(char *)(v29 + 556) = 0;
               pParty->pPickedItem.Reset();
               pParty->SetHoldingItem((ItemGen *)(v29 + 532));
@@ -9936,7 +9824,7 @@
     v35 = pPlayers[uActiveCharacter]->pEquipment.uBow;
     if ( v35 )
     {
-      auto _a = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v35-1];
+      auto _a = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v35 - 1];
       pParty->SetHoldingItem(_a);
       _a->Reset();
       pPlayers[uActiveCharacter]->pEquipment.uBow = 0;
--- a/mm7_4.cpp	Tue Apr 23 09:18:22 2013 +0600
+++ b/mm7_4.cpp	Thu Apr 25 17:37:00 2013 +0600
@@ -3768,7 +3768,7 @@
           {
             v32 = *v26;
             v33 = a3->GetValue();
-            v29 = pPlayer->_4B81C3(v33, v32);
+            v29 = pPlayer->GetPriceRepair(v33, v32);
           }
           else
           {
@@ -3792,7 +3792,7 @@
         v34 = *v26;
 
       v48 = v34;
-      v29 = pPlayer->_4B8179(v48);
+      v29 = pPlayer->GetPriceIdentification(v48);
       goto _continue_sprintf;
           }
 
@@ -3808,7 +3808,7 @@
             //v34 = p2DEvents_minus1__20[13 * (signed int)a4];
             v34 = p2DEvents[(signed int)a4 - 1].fPriceMultiplier;
             v48 = v34;
-            v29 = pPlayer->_4B8179(v48);
+            v29 = pPlayer->GetPriceIdentification(v48);
             goto _continue_sprintf;
           }
 
--- a/mm7_5.cpp	Tue Apr 23 09:18:22 2013 +0600
+++ b/mm7_5.cpp	Thu Apr 25 17:37:00 2013 +0600
@@ -56,8 +56,8 @@
   //NPCData *pNPCData0; // eax@18
   //int v6; // edx@20
   //int v7; // ecx@29
-  unsigned int v8; // edx@59
-  unsigned int v9; // ecx@60
+  //unsigned int v8; // edx@59
+  //unsigned int v9; // ecx@60
   unsigned int v10; // ecx@73
   //unsigned int v11; // eax@75
   unsigned __int8 v12; // sf@75
@@ -127,8 +127,8 @@
   int v76; // esi@535
   int v77; // eax@537
   Player *pPlayer2; // ecx@549
-  int v79; // ecx@550
-  unsigned int v80; // edx@550
+  //int v79; // ecx@550
+  //unsigned int v80; // edx@550
   signed int v81; // eax@552
   POINT *pPoint2; // eax@553
   signed int v83; // ecx@554
@@ -137,14 +137,14 @@
   unsigned int v86; // eax@583
   const char *v87; // ecx@595
   const char *v88; // ecx@596
-  unsigned int v89; // eax@598
+  //unsigned int v89; // eax@598
   unsigned int v90; // eax@602
   int v91; // edx@605
   int v92; // eax@605
   int v93; // edx@605
   int pPlayerNum; // edx@611
   int v95; // eax@611
-  const char *v96; // ecx@621
+  //const char *v96; // ecx@621
   unsigned int v97; // eax@624
   int v98; // eax@636
   unsigned __int8 v99; // al@643
@@ -178,42 +178,42 @@
   int v127; // [sp-1Ch] [bp-618h]@107
   unsigned int v128; // [sp-1Ch] [bp-618h]@711
   int v129; // [sp-18h] [bp-614h]@86
-  signed int v130; // [sp-18h] [bp-614h]@107
+  //signed int v130; // [sp-18h] [bp-614h]@107
   int v131; // [sp-14h] [bp-610h]@86
-  unsigned int v132; // [sp-14h] [bp-610h]@107
-  unsigned int v133; // [sp-10h] [bp-60Ch]@60
+  //unsigned int v132; // [sp-14h] [bp-610h]@107
+  //unsigned int v133; // [sp-10h] [bp-60Ch]@60
   unsigned int v134; // [sp-10h] [bp-60Ch]@86
-  signed int v135; // [sp-10h] [bp-60Ch]@107
+  //signed int v135; // [sp-10h] [bp-60Ch]@107
   unsigned int v136; // [sp-10h] [bp-60Ch]@121
-  unsigned int v137; // [sp-Ch] [bp-608h]@60
+  //unsigned int v137; // [sp-Ch] [bp-608h]@60
   unsigned int v138; // [sp-Ch] [bp-608h]@86
-  signed int v139; // [sp-Ch] [bp-608h]@107
+  //signed int v139; // [sp-Ch] [bp-608h]@107
   unsigned int v140; // [sp-Ch] [bp-608h]@121
   enum WindowType pWindowType; // [sp-8h] [bp-604h]@56
-  enum WindowType pWindowType1; // [sp-8h] [bp-604h]@60
+  //enum WindowType pWindowType1; // [sp-8h] [bp-604h]@60
   unsigned __int8 v143; // [sp-8h] [bp-604h]@86
-  int v144; // [sp-8h] [bp-604h]@107
+  //int v144; // [sp-8h] [bp-604h]@107
   enum WindowType pWindowType2; // [sp-8h] [bp-604h]@121
-  const char *v146; // [sp-8h] [bp-604h]@449
-  unsigned int v147; // [sp-8h] [bp-604h]@550
+  //const char *v146; // [sp-8h] [bp-604h]@449
+  //unsigned int v147; // [sp-8h] [bp-604h]@550
   //int v148; // [sp-4h] [bp-600h]@56
   GUIButton *pButton2; // [sp-4h] [bp-600h]@59
   const char *v150; // [sp-4h] [bp-600h]@86
-  unsigned int v151; // [sp-4h] [bp-600h]@107
+  //unsigned int v151; // [sp-4h] [bp-600h]@107
   int v152; // [sp-4h] [bp-600h]@121
   int v153; // [sp-4h] [bp-600h]@135
   int v154; // [sp-4h] [bp-600h]@149
   int v155; // [sp-4h] [bp-600h]@165
   int v156; // [sp-4h] [bp-600h]@204
-  const char *v157; // [sp-4h] [bp-600h]@444
+  //const char *v157; // [sp-4h] [bp-600h]@444
   unsigned int v158; // [sp-4h] [bp-600h]@449
-  __int16 v159; // [sp-4h] [bp-600h]@550
+  //__int16 v159; // [sp-4h] [bp-600h]@550
   int v160; // [sp-4h] [bp-600h]@599
   const char *v161; // [sp-4h] [bp-600h]@637
   //int v162; // [sp+0h] [bp-5FCh]@56
-  int v163; // [sp+0h] [bp-5FCh]@59
+  //int v163; // [sp+0h] [bp-5FCh]@59
   Texture *pTexture; // [sp+0h] [bp-5FCh]@86
-  int v165; // [sp+0h] [bp-5FCh]@107
+  //int v165; // [sp+0h] [bp-5FCh]@107
   int v166; // [sp+0h] [bp-5FCh]@121
   int v167; // [sp+0h] [bp-5FCh]@135
   int v168; // [sp+0h] [bp-5FCh]@149
@@ -223,7 +223,7 @@
   KeyToggleType pKeyToggleType; // [sp+0h] [bp-5FCh]@287
   char *v173; // [sp+0h] [bp-5FCh]@444
   char *v174; // [sp+0h] [bp-5FCh]@449
-  int v175; // [sp+0h] [bp-5FCh]@550
+  //int v175; // [sp+0h] [bp-5FCh]@550
   int v176; // [sp+0h] [bp-5FCh]@599
   const char *v177; // [sp+0h] [bp-5FCh]@629
   char *v178; // [sp+0h] [bp-5FCh]@637
@@ -1248,7 +1248,7 @@
                         }
                       }
                       break;
-                    case SCREEN_REST:
+                    case SCREEN_REST://close rest screen
                       if ( dword_506F14 )
                       {
                         Rest(_506F18_num_hours_to_sleep);
@@ -1749,10 +1749,8 @@
           if ( v45 == 3 )
           {
             v47 = pActors[v46].uAIState == Dead;
-            //goto LABEL_400;
             if ( !v47 )
               continue;
-            //goto LABEL_415;
             v51 = pGUIWindow_Settings->ptr_1C;
             *((char *)v51 + 8) &= 0xBFu;
             *((short *)v51 + 2) = uMessageParam;
@@ -1770,10 +1768,8 @@
           if ( v45 == 2 )
           {
             v47 = (pObjectList->pObjects[pSpriteObjects[v46].uObjectDescID].uFlags & 0x10) == 0;
-//LABEL_400:
             if ( !v47 )
               continue;
-            //goto LABEL_415;
             v51 = pGUIWindow_Settings->ptr_1C;
             *((char *)v51 + 8) &= 0xBFu;
             *((short *)v51 + 2) = uMessageParam;
@@ -1924,16 +1920,11 @@
         continue;
 
         case UIMSG_B2:
-          v165 = 0;
-          v151 = 0;
-          v144 = 0;
-          v139 = 0;
+			__debugbreak;//UIMSG_B2 -???
           bRecallingBeacon = uMessageParam;
-          v135 = -1;
-          v132 = 0;
-          v130 = 0;
           v127 = uMessageParam + 204;
-          goto _play_sound_and_continue;
+          pAudioPlayer->PlaySound((SoundID)v127, 0, 0, -1, 0, 0, 0, 0);
+          continue;
         case UIMSG_B4:
           if ( !pGUIWindow_CurrentMenu )
             continue;
@@ -1944,8 +1935,9 @@
             if ( !*((int *)&pSavegameThumbnails->pPixels + 10 * uMessageParam) )
               continue;
             v173 = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(pPlayer->pInstalledBeacons[uMessageParam].field_18))].pName;
-            v157 = pGlobalTXT_LocalizationStrings[474];// "Recall to %s"
-            goto _sprintex_2args_draw_status_and_continue;
+            sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[474], v173);// "Recall to %s"
+            sub_41C0B8_set_status_string(pTmpBuf);
+            continue;
           }
           v59 = pMapStats->GetMapInfo(pCurrentMapName);
           thise = "Not in Map Stats";
@@ -1953,18 +1945,17 @@
             thise = pMapStats->pInfos[v59].pName;
           if ( !*((int *)&pSavegameThumbnails->pPixels + 10 * uMessageParam) || !v59 )
           {
-            v173 = thise;
-            v157 = pGlobalTXT_LocalizationStrings[476];// "Set to %s"
-            goto _sprintex_2args_draw_status_and_continue;
+            sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[476], thise);// "Set to %s"
+            sub_41C0B8_set_status_string(pTmpBuf);
+            continue;
           }
           v174 = pMapStats->pInfos[sub_410D99_get_map_index(*(short *)(uNumSeconds + 26))].pName;
           v158 = (unsigned int)thise;
-          v146 = pGlobalTXT_LocalizationStrings[475];// "Set %s over %s"
-//_sprintex_draw_status_and_continue:
-          sprintf(pTmpBuf, v146, v158, v174);
+          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[475], v158, v174);// "Set %s over %s"
           sub_41C0B8_set_status_string(pTmpBuf);
           continue;
         case UIMSG_B5:
+			__debugbreak;//UIMSG_B5 - ???
           dword_50CDC8 = v0;
           //goto LABEL_453;
           pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
@@ -2179,9 +2170,9 @@
                     default:
                     if ( uMessageParam != 5 )
                     {
-                      v173 = v200;
-                      v157 = pGlobalTXT_LocalizationStrings[35];
-                      goto _sprintex_2args_draw_status_and_continue;
+                      sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[35], v200);
+                      sub_41C0B8_set_status_string(pTmpBuf);
+                      continue;
                     }
                     v69 = pMapStats->pInfos[8].pName;
                     break;
@@ -2191,10 +2182,9 @@
                 {
                   v69 = pMapStats->pInfos[21].pName;
                 }
-                v200 = v69;
-                v173 = v200;
-                v157 = pGlobalTXT_LocalizationStrings[35];
-                goto _sprintex_2args_draw_status_and_continue;
+                sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[35], v69);
+                sub_41C0B8_set_status_string(pTmpBuf);
+                continue;
               }
               v68 = 210;
               break;
@@ -2230,9 +2220,9 @@
                 if ( uMessageParam != 5 )
                   //goto LABEL_519;
                   {
-                   v173 = v200;
-                   v157 = pGlobalTXT_LocalizationStrings[35];
-                   goto _sprintex_2args_draw_status_and_continue;
+                    sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[35], v200);
+                    sub_41C0B8_set_status_string(pTmpBuf);
+                    continue;
                   }
                 v69 = pMapStats->pInfos[8].pName;
                 break;
@@ -2242,11 +2232,9 @@
           {
             v69 = pMapStats->pInfos[21].pName;
           }
-          v200 = v69;
-//LABEL_519:
-          v173 = v200;
-          v157 = pGlobalTXT_LocalizationStrings[35];
-          goto _sprintex_2args_draw_status_and_continue;
+          sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[35], v69);
+          sub_41C0B8_set_status_string(pTmpBuf);
+          continue;
         case UIMSG_ShowFinalWindow:
           sprintf(pFinalMessage, "%s\n \n%s\n \n%s", pGlobalTXT_LocalizationStrings[151],// "Congratulations Adventurer."
             pGlobalTXT_LocalizationStrings[118],// "We hope that you've enjoyed playing Might and Magic VII as much as we did making it. We have saved this screen as MM7_WIN.PCX in your MM7 directory. You can print it out as proof of your accomplishment."
@@ -2255,10 +2243,12 @@
           uGameState = GAME_STATE_FINAL_WINDOW;
           continue;
         case UIMSG_C4:
+			__debugbreak;
           uGameState = 0;
           strcpy((char *)pKeyActionMap->pPressedKeysBuffer, "2");
           goto LABEL_524;
         case UIMSG_DD:
+          __debugbreak;
 LABEL_524:
           sprintf(pTmpBuf, "%s", pKeyActionMap->pPressedKeysBuffer);
           memcpy(&v216, txt_file_frametable_parser((const char *)pKeyActionMap->pPressedKeysBuffer, &v218), sizeof(v216));
@@ -2499,24 +2489,12 @@
             _42ECB5_PlayerAttacksActor();
           continue;
         case UIMSG_ExitRest:
-          v163 = (int)pGlobalTXT_LocalizationStrings[81];// "Exit Rest"
-          pButton = pButton_RestUI_Exit;
-          pButton2 = pButton_RestUI_Exit;
-          pWindowType1 = (WindowType)96;
-          //goto LABEL_731;
-          v8 = pButton->uY;
-          v9 = pButton->uX;
-          //goto LABEL_732;
-          v137 = 0;
-          v133 = 0;
-          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, (WindowType)96, (int)pButton_RestUI_Exit, (int)pGlobalTXT_LocalizationStrings[81]);// "Exit Rest"
           continue;
         case UIMSG_Wait5Minutes:
           if ( dword_506F14 == 2 )
-            //goto LABEL_621;
-          {
-            v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!"
-            ShowStatusBarString(v96, 2);
+          {
+            ShowStatusBarString(pGlobalTXT_LocalizationStrings[477], 2);// "You are already resting!"
             pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
             continue;
           }
@@ -2527,10 +2505,8 @@
           continue;
         case UIMSG_Wait1Hour:
           if ( dword_506F14 == 2 )
-            //goto LABEL_621;
-          {
-            v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!"
-            ShowStatusBarString(v96, 2);
+          {
+            ShowStatusBarString(pGlobalTXT_LocalizationStrings[477], 2);// "You are already resting!"
             pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
             continue;
           }
@@ -2546,7 +2522,6 @@
           _506F18_num_hours_to_sleep = v86;
           if ( uMessageParam == 111 || uMessageParam == 114 || uMessageParam == 116 )
             _506F18_num_hours_to_sleep = v86 + 720;
-          //goto LABEL_615;
           dword_506F14 = 2;
           pParty->RestAndHeal();
           pParty->days_played_without_rest = 0;
@@ -2561,34 +2536,28 @@
           if ( pCurrentScreen )
             continue;
           if ( sub_42F4DA() )
-            //goto LABEL_594;
           {
             if ( pParty->bTurnBasedModeOn == v0 )
             {
-              v87 = pGlobalTXT_LocalizationStrings[478];// "You can't rest in turn-based mode!"
-              ShowStatusBarString(v87, 2u);
+              ShowStatusBarString(pGlobalTXT_LocalizationStrings[478], 2);// "You can't rest in turn-based mode!"
               continue;
             }
             v88 = pGlobalTXT_LocalizationStrings[480];// "There are hostile enemies near!"
             if ( pParty->uFlags & 0x88 )
               v88 = pGlobalTXT_LocalizationStrings[479];// "You can't rest here!"
-            ShowStatusBarString(v88, 2u);
-            v89 = uActiveCharacter;
+            ShowStatusBarString(v88, 2);
             if ( !uActiveCharacter )
             {
               v1 = "";
               v0 = 1;
               continue;
             }
-            v176 = 0;
-            v160 = 13;
-            goto LABEL_619;
+            pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)13, 0);
+            continue;
           }
           if ( pParty->bTurnBasedModeOn == v0 )
-            //goto LABEL_595;
-          {
-            v87 = pGlobalTXT_LocalizationStrings[478];// "You can't rest in turn-based mode!"
-            ShowStatusBarString(v87, 2u);
+          {
+            ShowStatusBarString(pGlobalTXT_LocalizationStrings[478], 2);// "You can't rest in turn-based mode!"
             continue;
           }
           if ( !(pParty->uFlags & 0x88) )
@@ -2596,36 +2565,27 @@
             RestUI_Initialize();
             continue;
           }
-//LABEL_594:
           if ( pParty->bTurnBasedModeOn == v0 )
           {
-//LABEL_595:
-            v87 = pGlobalTXT_LocalizationStrings[478];// "You can't rest in turn-based mode!"
-            //goto _draw_status_string_and_continue;
-            ShowStatusBarString(v87, 2u);
+            ShowStatusBarString(pGlobalTXT_LocalizationStrings[478], 2);// "You can't rest in turn-based mode!"
             continue;
           }
           v88 = pGlobalTXT_LocalizationStrings[480];// "There are hostile enemies near!"
           if ( pParty->uFlags & 0x88 )
             v88 = pGlobalTXT_LocalizationStrings[479];// "You can't rest here!"
           ShowStatusBarString(v88, 2u);
-          v89 = uActiveCharacter;
           if ( !uActiveCharacter )
-            //goto LABEL_90;
           {
             v1 = "";
             v0 = 1;
             continue;
           }
-          v176 = 0;
-          v160 = 13;
-          goto LABEL_619;
+          pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)13, 0);
+          continue;
         case UIMSG_Rest8Hour:
           if ( dword_506F14 )
-            //goto LABEL_621;
-          {
-            v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!"
-            ShowStatusBarString(v96, 2);
+          {
+            ShowStatusBarString(pGlobalTXT_LocalizationStrings[477], 2);// "You are already resting!"
             pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
             continue;
           }
@@ -2633,13 +2593,7 @@
           {
             ShowStatusBarString(pGlobalTXT_LocalizationStrings[482], 2u);// "You don't have enough food to rest"
             if ( uActiveCharacter && pPlayers[uActiveCharacter]->CanAct() )
-            {
-              v89 = uActiveCharacter;
-              v176 = 0;
-              v160 = SPEECH_108;
-LABEL_619:
-              pPlayers[v89]->PlaySound((PlayerSpeech)v160, v176);
-            }
+              pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_108, 0);
           }
           else
           {
@@ -2679,21 +2633,13 @@
                   ++pMessageQueue_50CBD0->uNumMessages;
                 }*/
                 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-                ShowStatusBarString(pGlobalTXT_LocalizationStrings[481], 2u);// "Encounter!"
-                v165 = 0;
-                v151 = 0;
-                v144 = 0;
-                v139 = 0;
-                v135 = -1;
-                v132 = 0;
-                v130 = 0;
-                v127 = 227;
-                goto _play_sound_and_continue;
+                ShowStatusBarString(pGlobalTXT_LocalizationStrings[481], 2);// "Encounter!"
+                pAudioPlayer->PlaySound((SoundID)227, 0, 0, -1, 0, 0, 0, 0);
+                continue;
               }
             }
             Party::TakeFood(uRestUI_FoodRequiredToRest);
             _506F18_num_hours_to_sleep = 480;
-//LABEL_615:
             dword_506F14 = 2;
             pParty->RestAndHeal();
             pParty->days_played_without_rest = 0;
@@ -2706,9 +2652,7 @@
         case UIMSG_AlreadyResting:
           if ( dword_506F14 == 2 )
           {
-//LABEL_621:
-            v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!"
-            ShowStatusBarString(v96, 2);
+            ShowStatusBarString(pGlobalTXT_LocalizationStrings[477], 2);// "You are already resting!"
             pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
             continue;
           }
@@ -2719,12 +2663,11 @@
           _506F18_num_hours_to_sleep = 60 * v97 - pParty->uCurrentMinute;
           continue;
         case UIMSG_4E:
+			__debugbreak;//UIMSG_4E -???
           if ( quick_spell_at_page && byte_506550 )
           {
             v173 = pSpellStats->pInfos[quick_spell_at_page + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage].pName;
-            v157 = pGlobalTXT_LocalizationStrings[483];
-_sprintex_2args_draw_status_and_continue:
-            sprintfex(pTmpBuf, v157, v173);
+            sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[483], v173);
           }
           else
           {
@@ -2734,7 +2677,6 @@
               v177 = pGlobalTXT_LocalizationStrings[484];// "Select a spell then click here to set a QuickSpell"
             strcpy(pTmpBuf, v177);
           }
-//_set_status_string_pTmpBuf_and_continue:
           sub_41C0B8_set_status_string(pTmpBuf);
           continue;
         case UIMSG_SPellbook_ShowHightlightedSpellInfo:
@@ -2756,27 +2698,20 @@
           }
           sprintfex(pTmpBuf, v161, v178);
           sub_41C0B8_set_status_string(pTmpBuf);
-          //goto LABEL_91;
           v0 = 1;
           continue;
         case UIMSG_58:
+			__debugbreak;//UIMSG_58 - ???
           GUIWindow::Create(pBtn_InstallRemoveSpell->uX, pBtn_InstallRemoveSpell->uY, 0, 0, WINDOW_5A, (int)pBtn_InstallRemoveSpell, 0);
           if ( !uActiveCharacter )
             continue;
           pPlayer10 = pPlayers[uActiveCharacter];
           if ( !byte_506550 || !quick_spell_at_page )
           {
-            v165 = 0;
-            v151 = 0;
-            v144 = 0;
-            v139 = 0;
-            v135 = -1;
-            v132 = 0;
             pPlayer10->uQuickSpell = 0;
-            v130 = 0;
             quick_spell_at_page = 0;
-            v127 = 203;
-            goto _play_sound_and_continue;
+            pAudioPlayer->PlaySound((SoundID)203, 0, 0, -1, 0, 0, 0, 0);
+            continue;
           }
           v99 = quick_spell_at_page + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage;
           pPlayers[uActiveCharacter]->uQuickSpell = v99;
@@ -2786,6 +2721,7 @@
           byte_506550 = 0;
           continue;
         case UIMSG_33:
+			__debugbreak;//UIMSG_33 - ???
           if ( !uActiveCharacter )
             continue;
           pPlayer3 = pPlayers[uActiveCharacter];
@@ -2809,15 +2745,9 @@
           while ( v101 < 9 );
           if ( !pNPCData4 )
           {
-            v165 = 0;
-            v151 = 0;
-            v144 = 0;
-            v139 = 0;
-            v135 = -1;
-            v132 = 0;
-            v130 = 0;
             v127 = rand() % 2 + 204;
-            goto _play_sound_and_continue;
+            pAudioPlayer->PlaySound((SoundID)v127, 0, 0, -1, 0, 0, 0, 0);
+            continue;
           }
           if ( GetAsyncKeyState(16) )
           {
@@ -2834,30 +2764,18 @@
           sub_41140B();
           pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = LOBYTE(v217[uAction]);
           pGUIWindow_CurrentMenu->OpenSpellBook();
-          v165 = 0;
-          v151 = 0;
-          v144 = 0;
-          v139 = 0;
-          v135 = -1;
-          v132 = 0;
-          v130 = 0;
           v127 = rand() % 2 + 204;
-          goto _play_sound_and_continue;
+          pAudioPlayer->PlaySound((SoundID)v127, 0, 0, -1, 0, 0, 0, 0);
+          continue;
         case UIMSG_OpenSpellbookPage:
           if ( pTurnEngine->field_4 == 3 || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->lastOpenedSpellbookPage )
             continue;
           sub_41140B();
           pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = uMessageParam;
           pGUIWindow_CurrentMenu->OpenSpellBook();
-          v165 = 0;
-          v151 = 0;
-          v144 = 0;
-          v139 = 0;
-          v135 = -1;
-          v132 = 0;
-          v130 = 0;
           v127 = rand() % 2 + 204;
-          goto _play_sound_and_continue;
+          pAudioPlayer->PlaySound((SoundID)v127, 0, 0, -1, 0, 0, 0, 0);
+          continue;
         case UIMSG_SelectSpell:
         {
           if (pTurnEngine->field_4 == 3)
@@ -2901,17 +2819,9 @@
         continue;
 
         case UIMSG_92:
+			__debugbreak;//UIMSG_92 - ???
           if ( pTurnEngine->field_4 != 3 )
-          {
-            v175 = 0;
-            v159 = v0;
-            v147 = 133;
-//LABEL_678:
-            v80 = v199;
-            v79 = uMessageParam;
-//LABEL_679:
-            _42777D_CastSpell_UseWand_ShootArrow(v79, v80, v147, v159, v175);
-          }
+            _42777D_CastSpell_UseWand_ShootArrow(uMessageParam, v199, 133, v0, 0);
           continue;
         case UIMSG_SpellBookWindow:
           if ( pTurnEngine->field_4 == 3 )
@@ -2919,16 +2829,7 @@
           if ( bUnderwater == 1 )
           {
             ShowStatusBarString(pGlobalTXT_LocalizationStrings[652], 2);// "You can not do that while you are underwater!"
-            v165 = 0;
-            v151 = 0;
-            v144 = 0;
-            v139 = 0;
-            v135 = -1;
-            v132 = 0;
-            v130 = 0;
-            v127 = 27;
-_play_sound_and_continue:
-            pAudioPlayer->PlaySound((SoundID)v127, v130, v132, v135, v139, v144, v151, v165);
+            pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
           }
           else
           {
@@ -2953,7 +2854,6 @@
                  || pCurrentScreen > SCREEN_67) )
               {
                 pGUIWindow_CurrentMenu->Release();
-//LABEL_693:
                 GUIWindow::Create(0x1DCu, 0x1C2u, 0, 0, WINDOW_5A, (int)pBtn_CastSpell, 0);
                 pCurrentScreen = SCREEN_SPELL_BOOK;
                 pEventTimer->Pause();
@@ -3010,18 +2910,19 @@
           pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
           continue;
         case UIMSG_C0:
+			__debugbreak;//UIMSG_C0 - ???
           dword_50651C = v0;
           if ( pMouse->GetCursorPos(&v211)->y > 178 )
             dword_50651C = -1;
           continue;
         case UIMSG_A9:
+			__debugbreak;
           GUIWindow::Create(pBtn_Up->uX, pBtn_Up->uY, 0, 0, WINDOW_5B, (int)pBtn_Up, 0);
-//LABEL_707:
           dword_506548 = v0;
           continue;
         case UIMSG_AA:
+			__debugbreak;
           GUIWindow::Create(pBtn_Down->uX, pBtn_Down->uY, 0, 0, WINDOW_5B, (int)pBtn_Down, 0);
-//LABEL_709:
           dword_506544 = v0;
           continue;
         case UIMSG_ChangeDetaliz:
@@ -3052,37 +2953,19 @@
           OnPaperdollLeftClick();
           continue;
         case UIMSG_73:
+			__debugbreak;
           pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 100;
           sub_4196A0();
           sub_419379();
-          pButton = pCharacterScreen_StatsBtn;
-          //goto LABEL_716;
-          v163 = 0;
-          pButton2 = pButton;
-          pWindowType1 = (WindowType)91;
-          v8 = pButton->uY;
-          v9 = pButton->uX;
-          //goto LABEL_732;
-          v137 = 0;
-          v133 = 0;
-          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          GUIWindow::Create(pCharacterScreen_StatsBtn->uX, pCharacterScreen_StatsBtn->uY, 0, 0, (WindowType)91, (int)pCharacterScreen_StatsBtn, 0);
           continue;
         case UIMSG_72:
+			__debugbreak;
           pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 101;
           sub_4196A0();
           sub_419379();
           CharacterUI_SkillScreen_Draw();
-          pButton = pCharacterScreen_SkillsBtn;
-          //goto LABEL_716;
-          v163 = 0;
-          pButton2 = pButton;
-          pWindowType1 = (WindowType)91;
-          v8 = pButton->uY;
-          v9 = pButton->uX;
-          //goto LABEL_732;
-          v137 = 0;
-          v133 = 0;
-          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          GUIWindow::Create(pCharacterScreen_SkillsBtn->uX, pCharacterScreen_SkillsBtn->uY, 0, 0, (WindowType)91, (int)pCharacterScreen_SkillsBtn, 0);
           continue;
         case UIMSG_SkillUp:
           pPlayer4 = pPlayers[uActiveCharacter];
@@ -3100,52 +2983,26 @@
               *(short *)v105 = uNumSeconds + 1;
               pPlayer4->uSkillPoints -= pPlayer4->pActiveSkills[uMessageParam] & 0x3F;
               pPlayer4->PlaySound(SPEECH_14, 0);
-              v165 = 0;
-              v151 = 0;
-              v144 = 0;
-              v139 = 0;
-              v135 = -1;
-              v132 = 0;
-              v130 = 0;
-              v127 = 20001;
-              goto _play_sound_and_continue;
+              pAudioPlayer->PlaySound((SoundID)20001, 0, 0, -1, 0, 0, 0, 0);
+              continue;
             }
             v87 = pGlobalTXT_LocalizationStrings[487];// "You have already mastered this skill!"
           }
-//_draw_status_string_and_continue:
-          ShowStatusBarString(v87, 2u);
+          ShowStatusBarString(v87, 2);
           continue;
         case UIMSG_74:
+			__debugbreak;
           pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
           sub_419379();
           sub_4196A0();
-          pButton = pCharacterScreen_InventoryBtn;
-//LABEL_716:
-          v163 = 0;
-          pButton2 = pButton;
-          pWindowType1 = (WindowType)91;
-          //goto LABEL_731;
-          v8 = pButton->uY;
-          v9 = pButton->uX;
-          //goto LABEL_732;
-          v137 = 0;
-          v133 = 0;
-          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          GUIWindow::Create(pCharacterScreen_InventoryBtn->uX, pCharacterScreen_InventoryBtn->uY, 0, 0, (WindowType)91, (int)pCharacterScreen_InventoryBtn, 0);
           continue;
         case UIMSG_A8:
-          pButton = pCharacterScreen_ExitBtn;
-          v163 = 0;
-          pButton2 = pCharacterScreen_ExitBtn;
-          pWindowType1 = (WindowType)97;
-          //goto LABEL_731;
-          v8 = pButton->uY;
-          v9 = pButton->uX;
-          //goto LABEL_732;
-          v137 = 0;
-          v133 = 0;
-          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+			__debugbreak;
+          GUIWindow::Create(pCharacterScreen_ExitBtn->uX, pCharacterScreen_ExitBtn->uY, 0, 0, (WindowType)97, (int)pCharacterScreen_ExitBtn, 0);
           continue;
         case UIMSG_75:
+			__debugbreak;
           sub_419379();
           sub_4196A0();
           sub_419220();
@@ -3160,11 +3017,9 @@
             default:
               continue;
             case 11:
-              //goto LABEL_707;
               dword_506548 = v0;
               continue;
             case 10:
-              //goto LABEL_709;
               dword_506544 = v0;
               continue;
             case 0:
@@ -3208,16 +3063,7 @@
               dword_50652C = v0;
               break;
           }
-          v163 = v0;
-          pButton2 = pButton;
-          pWindowType1 = (WindowType)92;
-//LABEL_731:
-          v8 = pButton->uY;
-          v9 = pButton->uX;
-          //goto LABEL_732;
-          v137 = 0;
-          v133 = 0;
-          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, (WindowType)92, (int)pButton, v0);
           continue;
         case UIMSG_SelectCharacter:
           if ( pMessageQueue_50CBD0->uNumMessages )
@@ -3227,9 +3073,7 @@
         case UIMSG_ShowStatus_Funds:
           v174 = (char *)pParty->uNumGoldInBank;
           v158 = pParty->uNumGold + pParty->uNumGoldInBank;
-          v146 = pGlobalTXT_LocalizationStrings[489];// "You have %d total gold, %d in the Bank""
-          //goto _sprintex_draw_status_and_continue;
-          sprintfex(pTmpBuf, v146, v158, v174);
+          sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[489], v158, v174);// "You have %d total gold, %d in the Bank"
           sub_41C0B8_set_status_string(pTmpBuf);
           continue;
         case UIMSG_ShowStatus_DateTime:
@@ -3275,6 +3119,7 @@
           sub_41C0B8_set_status_string(pTmpBuf);
           continue;
         case UIMSG_C:
+			__debugbreak;
           if ( pCurrentScreen == SCREEN_F )
           {
             sub_421EA6_OnInventoryLeftClick();
@@ -3286,8 +3131,8 @@
           sub_421EA6_OnInventoryLeftClick();
           continue;
         case UIMSG_A:
+			__debugbreak;
           if ( !pRenderer->pRenderD3D )
-            //goto LABEL_772;
           {
             if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -3337,11 +3182,13 @@
           }*/
           continue;
         case UIMSG_E:
+			__debugbreak;
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           OnGameViewportClick();
           continue;
         case UIMSG_F:
+			__debugbreak;
           if ( pRenderer->pRenderD3D )
           {
             LOWORD(v116) = pGame->pVisInstance->get_picked_object_zbuf_val();
@@ -3356,6 +3203,7 @@
           GUIWindow::Create(0, 0, 0, 0, (WindowType)15, (int)pButton2, 0);
           continue;
         case UIMSG_54:
+			__debugbreak;
           pButton2 = (GUIButton *)uMessageParam;
           GUIWindow::Create(0, 0, 0, 0, (WindowType)22, (int)pButton2, 0);
           continue;
@@ -3365,6 +3213,7 @@
           OnPressSpace();
           continue;
         case UIMSG_16F:
+			__debugbreak;
           if ( pCurrentScreen )
             continue;
           pParty->uFlags |= 2u;
@@ -3388,6 +3237,7 @@
           viewparams->field_28 = 11;
           goto LABEL_788;
         case UIMSG_170:
+			__debugbreak;
           if ( pCurrentScreen )
             continue;
           pParty->uFlags |= 2u;