changeset 2102:0db53678ff48

RasterLine2D, DIALOGUE_EVT_A etc.
author Ritor1
date Tue, 17 Dec 2013 21:34:20 +0600
parents ee2724b9ca05
children 2318216e5206
files GUIWindow.h Render.cpp Render.h UI/UiGame.cpp mm7_2.cpp mm7_4.cpp
diffstat 6 files changed, 276 insertions(+), 365 deletions(-) [+]
line wrap: on
line diff
--- a/GUIWindow.h	Mon Dec 16 18:43:42 2013 +0600
+++ b/GUIWindow.h	Tue Dec 17 21:34:20 2013 +0600
@@ -231,16 +231,21 @@
   DIALOGUE_USE_NPC_ABILITY = 9,
   DIALOGUE_13 = 0xD,
   DIALOGUE_18 = 0x12,
-  DIALOGUE_19 = 19,
-  DIALOGUE_20 = 20,
-  DIALOGUE_21 = 21,
-  DIALOGUE_22 = 22,
-  DIALOGUE_23 = 23,
-  DIALOGUE_24 = 0x18,
+  DIALOGUE_EVT_A = 19,
+  DIALOGUE_EVT_B = 20,
+  DIALOGUE_EVT_C = 21,
+  DIALOGUE_EVT_D = 22,
+  DIALOGUE_EVT_E = 23,
+  DIALOGUE_EVT_F = 0x18,
   DIALOGUE_76 = 76,
   DIALOGUE_PROFESSION_DETAILS = 77,
-  DIALOGUE_ARENA_WELCOME = 0x59,
-  DIALOGUE_ARENA_FIGHT_NOT_OVER_YET = 0x5A,
+  DIALOGUE_84 = 84,
+  DIALOGUE_ARENA_SELECT_PAGE = 85,
+  DIALOGUE_ARENA_SELECT_SQUIRE = 86,
+  DIALOGUE_ARENA_SELECT_KNIGHT = 87,
+  DIALOGUE_ARENA_SELECT_CHAMPION = 88,
+  DIALOGUE_ARENA_WELCOME = 89,
+  DIALOGUE_ARENA_FIGHT_NOT_OVER_YET = 90,
   DIALOGUE_ARENA_REWARD = 0x5B,
   DIALOGUE_ARENA_ALREADY_WON = 0x5C,
 };
--- a/Render.cpp	Mon Dec 16 18:43:42 2013 +0600
+++ b/Render.cpp	Tue Dec 17 21:34:20 2013 +0600
@@ -3561,16 +3561,11 @@
 }
 
 //----- (004A0BEE) --------------------------------------------------------
-char Render::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor)
-{
-  signed int v8; // ebx@5
-  signed int v10; // ecx@9
-  signed int v11; // esi@13
+void Render::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor)
+{
   signed int v12; // eax@17
-  int v13; // eax@21
-  int v16; // eax@27
-  signed int v19; // qax@41
-  int v20; // edi@41
+  //signed int v19; // qax@41
+  //int v20; // edi@41
   unsigned int v21; // edi@46
   int v22; // esi@47
   int v23; // ebx@47
@@ -3586,46 +3581,44 @@
   __int64 v36; // [sp+14h] [bp-8h]@1
   signed int v37; // [sp+18h] [bp-4h]@28
   unsigned int uXa; // [sp+24h] [bp+8h]@49
-  unsigned int uYa; // [sp+28h] [bp+Ch]@28
+  //unsigned int uYa; // [sp+28h] [bp+Ch]@28
   int uYb; // [sp+28h] [bp+Ch]@47
-  int uZa; // [sp+2Ch] [bp+10h]@38
+  //int uZa; // [sp+2Ch] [bp+10h]@38
+  bool left_border;
 
   v36 = 0i64;
   if ( uX < this->raster_clip_x )// x выходит за рамки левой границы
-    HIDWORD(v36) = 8;
+    HIDWORD(v36) = 8; //left_border = true;
   if ( uX > this->raster_clip_z )// x выходит за рамки правой границы
-    HIDWORD(v36) |= 4;
+    HIDWORD(v36) |= 4;//right_border = true;
 
   if ( uZ < this->raster_clip_x )// z выходит за рамки левой границы
-    LODWORD(v36) = 8;
+    LODWORD(v36) = 8;//
   if ( uZ > this->raster_clip_z )// z выходит за рамки правой границы
     LODWORD(v36) |= 4;
 
   if ( uY < this->raster_clip_y )// y выходит за рамки верхней границы
-    HIDWORD(v36) |= 2;
+    HIDWORD(v36) |= 2;//upper_border = true;
   if ( uY > this->raster_clip_w )// y выходит за рамки нижней границы
-    HIDWORD(v36) |= 1;
+    HIDWORD(v36) |= 1;//bottom_border = true;
 
   if ( uW < this->raster_clip_y )// w выходит за рамки верхней границы
     LODWORD(v36) |= 2;
   if ( uW > this->raster_clip_w )// w выходит за рамки нижней границы
     LODWORD(v36) |= 1;
 
-  v8 = uY;
-  v11 = uW;
-  v10 = uZ;
-
-  LOBYTE(v12) = v36;
+  //LOBYTE(v12) = v36;
   if ( (unsigned int)v36 & HIDWORD(v36) )
-    return v12;
-  if ( !v36 )
+    return;
+
+  if ( !v36 ) //полностью в рамках
   {
 LABEL_46:
     v21 = pRenderer->uTargetSurfacePitch;
     if ( pRenderer->uTargetSurfacePitch )
     {
       v12 = uX + uY * pRenderer->uTargetSurfacePitch;
-      v22 = v11 - v8;
+      v22 = uW - uY;
       v23 = v22;
       uYb = v22;
       if ( v22 < 0 )
@@ -3634,7 +3627,7 @@
         uYb = -v22;
         v21 = -pRenderer->uTargetSurfacePitch;
       }
-      uXa = v10 - uX;
+      uXa = uZ - uX;
       if ( (uXa & 0x80000000u) == 0 )
       {
         v24 = 1;
@@ -3715,89 +3708,80 @@
         }
       }
     }
-    return v12;
-  }
-  if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )
-  {
-    if ( BYTE4(v36) & 8 )
-    {
-      v13 = ((uW - uY) * (this->raster_clip_x - uX)) / (uZ - uX);
-      v8 = v13 + uY;
+    return;
+  }
+
+  if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )//левая и 
+  {
+    if ( BYTE4(v36) & 8 )//left_border = true;
+    {
+      uY += ((uW - uY) * (this->raster_clip_x - uX)) / (uZ - uX);
       uX = this->raster_clip_x;
-      goto LABEL_24;
-    }
-    v10 = this->raster_clip_x;
-    v11 = ((uY - uW) * (this->raster_clip_x - uZ)) / (uX - uZ) + uW;
-  }
-LABEL_24:
+    }
+    else
+    {
+      uZ = this->raster_clip_x;
+      uW += ((uY - uW) * (this->raster_clip_x - uZ)) / (uX - uZ);
+    }
+  }
   if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 )
   {
-    //v15 = this->raster_clip_z;
-    if ( BYTE4(v36) & 4 )
-    {
-      v8 += ((v11 - v8) * (this->raster_clip_z - uX)) / (v10 - uX);
+    if ( BYTE4(v36) & 4 ) //right_border = true
+    {
+      uY += ((uW - uY) * (this->raster_clip_z - uX)) / (uZ - uX);
       uX = this->raster_clip_z;
     }
     else
     {
-      v16 = ((v8 - v11) * (this->raster_clip_z - v10)) / (uX - v10);
-      v10 = this->raster_clip_z;
-      v11 += v16;
+      uW += ((uY - uW) * (this->raster_clip_z - uZ)) / (uX - uZ);
+      uY = this->raster_clip_z;
     }
   }
   v37 = 0;
-  uYa = this->raster_clip_y;
-  if ( v8 < this->raster_clip_y )
+  if ( uY < this->raster_clip_y )
     v37 = 2;
-  if ( v8 > this->raster_clip_w )
+  if ( uY > this->raster_clip_w )
     v37 |= 1;
 
-  if ( v11 >= this->raster_clip_y )
+  if ( uW >= this->raster_clip_y )
     v12 = 0;
   else
     v12 = 2;
-  if ( v11 > this->raster_clip_w )
-    LOBYTE(v12) = v12 | 1;
+  if ( uW > this->raster_clip_w )
+    v12 |= 1;
 
   if ( !(v12 & v37) )
   {
     v12 ^= v37;
-    uZa = v12;
     if ( v12 & 2 )
     {
       if ( v37 & 2 )
       {
-        uX += ((v10 - uX) * (uYa - v8)) / (v11 - v8);
-        LOBYTE(v12) = (char)this;
-        v8 = this->raster_clip_y;
+        uX += ((uZ - uX) * (this->raster_clip_y - uY)) / (uW - uY);
+        uY = this->raster_clip_y;
       }
       else
       {
-        v19 = (uX - v10) * (uYa - v11);
-        v20 = v8 - v11;
-        v11 = uYa;
-        v12 = v19 / v20;
-        v10 += v12;
-      }
-    }
-    if ( uZa & 1 )
+        uZ += (uX - uZ) * (this->raster_clip_y - uW) / (uY - uW);
+        uW = this->raster_clip_y;
+      }
+    }
+    if ( v12 & 1 )
     {
       if ( v37 & 1 )
       {
-        uX += ((v10 - uX) * (this->raster_clip_w - v8)) / (v11 - v8);
-        LOBYTE(v12) = (char)this;
-        v8 = this->raster_clip_w;
+        uX += ((uZ - uX) * (this->raster_clip_w - uY)) / (uW - uY);
+        uY = this->raster_clip_w;
       }
       else
       {
-        v12 = ((uX - v10) * (this->raster_clip_w - v11)) / (v8 - v11);
-        v11 = this->raster_clip_w;
-        v10 += v12;
+        uZ += ((uX - uZ) * (this->raster_clip_w - uW)) / (uY - uW);
+        uW = this->raster_clip_w;
       }
     }
     goto LABEL_46;
   }
-  return v12;
+  return;
 }
 
 //----- (004A0E80) --------------------------------------------------------
--- a/Render.h	Mon Dec 16 18:43:42 2013 +0600
+++ b/Render.h	Tue Dec 17 21:34:20 2013 +0600
@@ -292,7 +292,7 @@
   void CreateSomeTexture();
   bool InitializeFullscreen();
   bool SwitchToWindow();
-  char RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor);
+  void RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor);
   void ClearZBuffer(int a2, int a3);
   void SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW);
   void ParseTargetPixelFormat();
--- a/UI/UiGame.cpp	Mon Dec 16 18:43:42 2013 +0600
+++ b/UI/UiGame.cpp	Tue Dec 17 21:34:20 2013 +0600
@@ -421,7 +421,7 @@
     break;
 
     default:
-      if (uDialogueType > DIALOGUE_18 && uDialogueType < DIALOGUE_23 && !byte_5B0938[0])
+      if (uDialogueType > DIALOGUE_18 && uDialogueType < DIALOGUE_EVT_E && !byte_5B0938[0])
       {
         pInString = (char *)current_npc_text;
       }
@@ -1985,10 +1985,10 @@
         long long _a = (uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x);
         uint _b = ((unsigned int)((unsigned __int64)_a >> 16) << 16);
         int _c = ((signed int)(_b - uZoom * pParty->vPosition.x) >> 16);
-        pX = uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16);
-        pY = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16);
-        pZ = uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16);
-        pW = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16);
+        pX = uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex1ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16);
+        pY = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex1ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16);
+        pZ = uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex2ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16);
+        pW = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex2ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16);
         v15 = abs(pOutline->sZ - pParty->vPosition.z) / 8;
         if ( v15 > 100 )
           v15 = 100;
--- a/mm7_2.cpp	Mon Dec 16 18:43:42 2013 +0600
+++ b/mm7_2.cpp	Tue Dec 17 21:34:20 2013 +0600
@@ -5512,19 +5512,19 @@
         if ( !v83 )
           SpriteObject::OnInteraction(uLayingItemID);
         v134 = 0;
-        v72 = uLayingItemID;
+        //v72 = uLayingItemID;
         v132 = pSpriteObjects[uLayingItemID].field_61;
         pSpriteObjects[uLayingItemID].vVelocity.z = 0;
         pSpriteObjects[uLayingItemID].vVelocity.y = 0;
         pSpriteObjects[uLayingItemID].vVelocity.x = 0;
         pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
-        AttackerInfo.Add(PID(OBJECT_Item,v72), 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v132, v134);
+        AttackerInfo.Add(PID(OBJECT_Item, uLayingItemID), 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v132, v134);
         if ( !pSpriteObjects[uLayingItemID].uSoundID )
           v78 = 0;
         else
           v78 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
         v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
-        pAudioPlayer->PlaySound((SoundID)v125, pSpriteObjects[uLayingItemID].vPosition.x, v66, -1, v66, v78, v66, v66);
+        pAudioPlayer->PlaySound((SoundID)v125, pSpriteObjects[uLayingItemID].vPosition.x, 0, -1, 0, v78, 0, 0);
         return 0;
       }
       if ( pSpriteObjects[uLayingItemID].uType == 4100 || pSpriteObjects[uLayingItemID].uType == 6010 )
--- a/mm7_4.cpp	Mon Dec 16 18:43:42 2013 +0600
+++ b/mm7_4.cpp	Tue Dec 17 21:34:20 2013 +0600
@@ -2287,28 +2287,29 @@
   uDialogueType = 84;
   current_npc_text = (char *)pNPCTopics[667].pText;
   v0 = _4F0882_evt_VAR_PlayerItemInHands_vals.data();
-  while ( 1 )
+  //while ( 1 )
+  for ( uint i = 0; i <= 53; i++ )
   {
     if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, *v0) )
     {
-      v1 = 0;
-      v2 = pParty->pPlayers.data();
-      do
+      //v1 = 0;
+      //v2 = pParty->pPlayers.data();
+      for ( uint pl = 0; pl < 4; pl++ )
       {
-        LOBYTE(v3) = v2->CompareVariable(VAR_PlayerItemInHands, *(v0+1));
-        if ( v3 )
+        //LOBYTE(v3) = pParty->pPlayers[pl].CompareVariable(VAR_PlayerItemInHands, *(v0+1));
+        if ( pParty->pPlayers[pl].CompareVariable(VAR_PlayerItemInHands, *(v0+1)) )
           break;
-        ++v2;
-        ++v1;
+        //++v2;
+        //++v1;
       }
-      while ( (signed int)v2 < (signed int)pParty->pHirelings.data() );
-      if ( v1 == 4 )
-        break;
+      //while ( (signed int)v2 < (signed int)pParty->pHirelings.data() );
+      //if ( v1 == 4 )
+        //break;
     }
     ++v11;
-    v0 += 2;
-    if ( v0 > &_4F0882_evt_VAR_PlayerItemInHands_vals[53] )
-	  break;
+    //v0 += 2;
+    //if ( v0 > &_4F0882_evt_VAR_PlayerItemInHands_vals[53] )
+	  //break;
   }
   if ( v0 <= &_4F0882_evt_VAR_PlayerItemInHands_vals[53] )
   {
@@ -2320,41 +2321,35 @@
   if ( contract_approved == 601 )
   {
     v5 = 0;
-    v12 = pParty->pPlayers.data();//[0].uClass;
+    //v12 = pParty->pPlayers.data();//[0].uClass;
     v9 = 0;
-    while ( 1 )
+    //while ( 1 )
+    for ( uint i = 0; i < 4; i++ )
     {
-      if ( v12->classType == PLAYER_CLASS_LICH )
+      if ( pParty->pPlayers[i].classType == PLAYER_CLASS_LICH )
       {
         v10 = 0;
-        v6 = pParty->pPlayers.data();//[0].pInventoryItems[0].field_1A;
-        do
+        //v6 = pParty->pPlayers.data();//[0].pInventoryItems[0].field_1A;
+        for ( uint pl = 0; pl < 4; pl++ )
         {
-		  v7 = v6->pInventoryItemList.data();
-          v8 = 138;
-          do
+          for ( v8 = 0; v8 < 126; v8++ )//138
           {
-			if ( v7->uItemID == ITEM_LICH_JAR_FULL )
+            if ( pParty->pPlayers[pl].pInventoryItemList[v8].uItemID == ITEM_LICH_JAR_FULL )
             {
-			  if ( !v7->uHolderPlayer )
-				  v9 = v7;
-			  if ( v7->uHolderPlayer == v5 )
+              if ( !pParty->pPlayers[pl].pInventoryItemList[v8].uHolderPlayer )
+                v9 = &pParty->pPlayers[pl].pInventoryItemList[v8];
+              if ( pParty->pPlayers[pl].pInventoryItemList[v8].uHolderPlayer == v5 )
                 v10 = 1;
             }
-            ++v7;
-            --v8;
           }
-          while ( v8 );
-          ++v6;
         }
-		while ( v6 <= &pParty->pPlayers[3] );
         if ( !v10 )
           break;
       }
-      ++v12;
+//      ++v12;
       ++v5;
-	  if ( v12 > &pParty->pPlayers[3] )
-        return;
+	//  if ( v12 > &pParty->pPlayers[3] )
+      //  return;
     }
     if ( v9 )
 	  v9->uHolderPlayer = v5;
@@ -2375,8 +2370,8 @@
   signed int v9; // esi@8
   int v10; // eax@8
   char *v11; // ecx@8
-  int v12; // edi@9
-  char *v13; // edx@9
+  //int v12; // edi@9
+  //char *v13; // edx@9
   signed int v14; // edi@10
   unsigned int v16; // eax@29
   //int v17; // eax@36
@@ -2435,27 +2430,23 @@
   if ( v6 < v2 + 2 )
   {
     //v8 = v33;
-    v9 = 0;
+    
     v10 = pClassType - pClassType % 4;
     v11 = &byte_4ED970_skill_learn_ability_by_class_table[pClassType - pClassType % 4][v3];
-    do
+    for ( v9 = 0; v9 < 4; ++v9 )
     {
-      v12 = (unsigned __int8)*v11;
-      v13 = &v28[4 * v9];
-      *(int *)v13 = 0;
-      if ( v12 < v34 )
+      v28[4 * v9] = 0;
+      if ( (unsigned __int8)*v11 < v34 )
       {
         v14 = 1;
       }
       else
       {
         v14 = 1;
-        *(int *)v13 = 1;
+        v28[4 * v9] = 1;
       }
-      ++v9;
       v11 += 37;
     }
-    while ( v9 < 4 );
     __debugbreak(); // warning C4700: uninitialized local variable 'v29' used
     if ( v29 == v14 )
     {
@@ -2763,20 +2754,18 @@
 //----- (004B3FE5) --------------------------------------------------------
 void __fastcall _4B3FE5_training_dialogue(int a4)
 {
-  int v1; // edi@1
   const char *v2; // edi@1
-  
+
   __debugbreak();
-  v1 = a4;
   uDialogueType = 78;
   current_npc_text = (char *)pNPCTopics[a4 + 168].pText;
   _4B254D_SkillMasteryTeacher(a4);
   pDialogueWindow->Release();
-  pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15Eu, WINDOW_MainMenu, v1, 0);
-  v2 = "";
-  pBtn_ExitCancel = pDialogueWindow->CreateButton( 0x1D7u, 0x1BDu, 0xA9u,  0x23u,   1,  0, UIMSG_Escape, 0,   0,
+  pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, a4, 0);
+  pBtn_ExitCancel = pDialogueWindow->CreateButton( 471, 445, 169,  35,   1,  0, UIMSG_Escape, 0,   0,
                  pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
+  v2 = "";
   if ( contract_approved )
     v2 = pGlobalTXT_LocalizationStrings[535];
   pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x4Fu, 0, v2, 0);
@@ -2789,10 +2778,8 @@
 //----- (004B46A5) --------------------------------------------------------
 void __fastcall DrawTextAtStatusBar( const char *Str, int a5 )
 {
-  int v4; // eax@1
   pRenderer->DrawTextureRGB(0, 352, pTexture_StatusBar);
-  v4 = pFontLucida->AlignText_Center(450, Str);
-  pPrimaryWindow->DrawText(pFontLucida, v4 + 11, 357, a5, Str, 0, 0, 0);
+  pPrimaryWindow->DrawText(pFontLucida, pFontLucida->AlignText_Center(450, Str) + 11, 357, a5, Str, 0, 0, 0);
 }
 
 //----- (004B46F8) --------------------------------------------------------
@@ -2810,235 +2797,170 @@
 //----- (004BC49B) --------------------------------------------------------
 void OnSelectNPCDialogueOption(DIALOGUE_TYPE newDialogueType)
 {
-	//unsigned int v1; // esi@1
-    NPCData *speakingNPC; // ebp@1
-    //unsigned int v3; // eax@1
-    int npc_event_id; // ecx@10
-    signed int v5; // edi@14
-    char *v6; // esi@15
-    const char *v7; // ecx@22
-    signed int v8; // edi@37
-    //unsigned int v9; // eax@56
-    unsigned int v10; // ecx@57
-    void *v11; // [sp-Ch] [bp-1Ch]@46
-    int v12; // [sp-8h] [bp-18h]@46
-    char *v13; // [sp-8h] [bp-18h]@60
-    size_t v14; // [sp-4h] [bp-14h]@46
-    const char *v15; // [sp-4h] [bp-14h]@60
-
-    //v1 = _this;
-	speakingNPC = GetNPCData(sDialogue_SpeakingActorNPC_ID);
-    //v3 = v1;
-	uDialogueType = newDialogueType;
-	if (!speakingNPC->uFlags)
-	{
-		speakingNPC->uFlags = 1;
-		//v3 = uDialogueType;
-	}
-
-	if(newDialogueType == DIALOGUE_PROFESSION_DETAILS)
-	{
-		dialogue_show_profession_details = ~dialogue_show_profession_details;
-	}
-	else if(newDialogueType == DIALOGUE_76)
-	{
-		if (speakingNPC->Hired())
-		{
-			v8 = 0;
-			if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
-			{
-				v6 = (char *)pNPCStats->pNewNPCData;
-				while ( !(v6[8] & 0x80) || strcmp(speakingNPC->pName, *(const char **)v6) )
-				{
-					++v8;
-					v6 += 76;
-					if ( v8 >= (signed int)pNPCStats->uNumNewNPCs )
-						break;
-				}
-				if( v8 < (signed int)pNPCStats->uNumNewNPCs )
-					v6[8] &= 0x7Fu;
-			}
-			if ( pParty->pHirelings[0].pName && !_stricmp(pParty->pHirelings[0].pName, speakingNPC->pName) )
-			{
-				v11 = pParty->pHirelings.data();
-				memset(v11, 0, sizeof(NPCData));
-			}
-			else if ( pParty->pHirelings[1].pName && !_stricmp(pParty->pHirelings[1].pName, speakingNPC->pName) )
-			{
-				v11 = &pParty->pHirelings[1];
-				memset(v11, 0, sizeof(NPCData));
-			}
-			pParty->hirelingScrollPosition = 0;
-			pParty->CountHirelings();
-			dword_591084 = 0;
-			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-			dword_7241C8 = 0;
-			return;
-		}
-		if ( pParty->pHirelings[0].pName && pParty->pHirelings[1].pName )
-		{
-			v7 = pGlobalTXT_LocalizationStrings[533]; // ""I cannot join you, you're party is full""
-			ShowStatusBarString(v7, 2u);
-		}
-		else
-		{
-			//v9 = v2->uProfession;
-			if ( speakingNPC->uProfession != 51 )
-			{
-				v10 = pNPCStats->pProfessions[speakingNPC->uProfession - 1].uHirePrice;
-																	if ( pParty->uNumGold < v10 )
-			{
-				ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold"
-				dialogue_show_profession_details = false;
-				uDialogueType = 13;
-				if ( uActiveCharacter )
-					pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0);
-				v7 = pGlobalTXT_LocalizationStrings[155];
-				ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
-				if ( !dword_7241C8 )
-					pGame->Draw();
-				dword_7241C8 = 0;
-				return;
-			}
-				Party::TakeGold(v10);
-			}
-			LOBYTE(speakingNPC->uFlags) |= 0x80u;
-			if ( pParty->pHirelings[0].pName )
-			{
-				memcpy(&pParty->pHirelings[1], speakingNPC, sizeof(pParty->pHirelings[1]));
-				v15 = speakingNPC->pName;
-				v13 = pParty->pHireling2Name;
-			}
-			else
-			{
-				memcpy(pParty->pHirelings.data(), speakingNPC, 0x4Cu);
-				v15 = speakingNPC->pName;
-				v13 = pParty->pHireling1Name;
-			}
-			strcpy(v13, v15);
-			pParty->hirelingScrollPosition = 0;
-			pParty->CountHirelings();
+  NPCData *speakingNPC; // ebp@1
+  int npc_event_id; // ecx@10
+  char *v13; // [sp-8h] [bp-18h]@60
 
-			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-
-			if ( sDialogue_SpeakingActorNPC_ID >= 0 )
-				pDialogue_SpeakingActor->uAIState = Removed;
-			if ( uActiveCharacter )
-				pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0);
-		}
-	}
-	else if ( (signed int)newDialogueType > 84 && (signed int)newDialogueType <= 88 )
-	{
-		ArenaFight();
-		return;
-	}
-	else if(newDialogueType == DIALOGUE_USE_NPC_ABILITY)
-	{
-		if (UseNPCSkill((NPCProf)speakingNPC->uProfession) == 0)
-		{
-			if ( speakingNPC->uProfession != GateMaster )
-				speakingNPC->bHasUsedTheAbility = 1;
-
-			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-		}
-		else
-			ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2); //"Your packs are already full!"
-	}
-	else if(newDialogueType == DIALOGUE_13)
-	{
-		if (!speakingNPC->Hired())
-		{
-			sub_4B3E1E();
-			dialogue_show_profession_details = false;
-		}
-		else
-		{
-			v5 = 0;
-			if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
-			{
-				v6 = (char *)pNPCStats->pNewNPCData;
-				while ( !(v6[8] & 0x80) || strcmp(speakingNPC->pName, *(const char **)v6) )
-				{
-					++v5;
-					v6 += 76;
-					if ( v5 >= (signed int)pNPCStats->uNumNewNPCs )
-						break;
-				}
-				if ( v5 < (signed int)pNPCStats->uNumNewNPCs )
-					v6[8] &= 0x7Fu;
-			}
-			if ( pParty->pHirelings[0].pName && !_stricmp(pParty->pHirelings[0].pName, speakingNPC->pName) )
-			{
-				v11 = pParty->pHirelings.data();
-				memset(v11, 0, sizeof(NPCData));
-			}
-			else if ( pParty->pHirelings[1].pName && !_stricmp(pParty->pHirelings[1].pName, speakingNPC->pName) )
-			{
-				v11 = &pParty->pHirelings[1];
-				memset(v11, 0, sizeof(NPCData));
-			}
-			pParty->hirelingScrollPosition = 0;
-			pParty->CountHirelings();
-			dword_591084 = 0;
-			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-			dword_7241C8 = 0;
-			return;
-		}
-	}
-	else if(newDialogueType >= 19 && newDialogueType <= 24)
-	{
-		switch(newDialogueType)
-		{
-			case DIALOGUE_19:  npc_event_id = speakingNPC->evt_A; break;
-			case DIALOGUE_20:  npc_event_id = speakingNPC->evt_B; break;
-			case DIALOGUE_21:  npc_event_id = speakingNPC->evt_C; break;
-			case DIALOGUE_22:	 npc_event_id = speakingNPC->evt_D; break;
-			case DIALOGUE_23:  npc_event_id = speakingNPC->evt_E; break;
-			case DIALOGUE_24:	 npc_event_id = speakingNPC->evt_F; break;
-		}
-		if ( (npc_event_id >= 200) && (npc_event_id <= 310) )
-			_4B3FE5_training_dialogue(npc_event_id); //200-310
-		else if (( npc_event_id >= 400) && (npc_event_id <= 410) )
-		{ //400-410
-			dword_F8B1D8 = newDialogueType;
-			DrawJoinGuildWindow(npc_event_id - 400);
-		}
-		else
-		{
-			switch ( npc_event_id )
-			{
-				case 139:
-					OracleDialogue();
-					break;
-				case 311:
-					CheckBountyRespawnAndAward();
-					break;
-				case 399:
-					Arena_SelectionFightLevel();
-					break;
-				default:
-					activeLevelDecoration = (LevelDecoration*)1;
-					current_npc_text = 0;
-					EventProcessor(npc_event_id, 0, 1);
-					activeLevelDecoration = NULL;
-					break;
-			}
-		}
-	}
-	if ( !dword_7241C8 )
-		pGame->Draw();
-	dword_7241C8 = 0;
+  speakingNPC = GetNPCData(sDialogue_SpeakingActorNPC_ID);
+  uDialogueType = newDialogueType;
+  if (!speakingNPC->uFlags)
+    speakingNPC->uFlags = 1;
+  if(newDialogueType == DIALOGUE_PROFESSION_DETAILS)
+    dialogue_show_profession_details = ~dialogue_show_profession_details;
+  else if(newDialogueType == DIALOGUE_76)
+  {
+    if (speakingNPC->Hired())
+    {
+      if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
+      {
+        for ( uint i = 0; i < (unsigned int)pNPCStats->uNumNewNPCs; ++i )
+        {
+          if ( pNPCStats->pNewNPCData[i].uFlags & 0x80 && !strcmp(speakingNPC->pName, pNPCStats->pNewNPCData[i].pName) )
+            pNPCStats->pNewNPCData[i].uFlags &= 0x7Fu;
+        }
+      }
+      if ( pParty->pHirelings[0].pName && !_stricmp(pParty->pHirelings[0].pName, speakingNPC->pName) )
+        memset(&pParty->pHirelings[0], 0, sizeof(NPCData));
+      else if ( pParty->pHirelings[1].pName && !_stricmp(pParty->pHirelings[1].pName, speakingNPC->pName) )
+        memset(&pParty->pHirelings[1], 0, sizeof(NPCData));
+      pParty->hirelingScrollPosition = 0;
+      pParty->CountHirelings();
+      dword_591084 = 0;
+      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+      dword_7241C8 = 0;
+      return;
+    }
+    if ( pParty->pHirelings[0].pName && pParty->pHirelings[1].pName )
+      ShowStatusBarString(pGlobalTXT_LocalizationStrings[533], 2);// ""I cannot join you, you're party is full""
+    else
+    {
+      if ( speakingNPC->uProfession != 51 )
+      {
+        if ( pParty->uNumGold < pNPCStats->pProfessions[speakingNPC->uProfession - 1].uHirePrice )
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold"
+          dialogue_show_profession_details = false;
+          uDialogueType = 13;
+          if ( uActiveCharacter )
+            pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0);
+          if ( !dword_7241C8 )
+            pGame->Draw();
+          dword_7241C8 = 0;
+          return;
+        }
+        Party::TakeGold(pNPCStats->pProfessions[speakingNPC->uProfession - 1].uHirePrice);
+      }
+      LOBYTE(speakingNPC->uFlags) |= 0x80u;
+      if ( pParty->pHirelings[0].pName )
+      {
+        memcpy(&pParty->pHirelings[1], speakingNPC, sizeof(pParty->pHirelings[1]));
+        v13 = pParty->pHireling2Name;
+      }
+      else
+      {
+        memcpy(&pParty->pHirelings[0], speakingNPC, sizeof(pParty->pHirelings[0]));
+        v13 = pParty->pHireling1Name;
+      }
+      strcpy(v13, speakingNPC->pName);
+      pParty->hirelingScrollPosition = 0;
+      pParty->CountHirelings();
+      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+      if ( sDialogue_SpeakingActorNPC_ID >= 0 )
+        pDialogue_SpeakingActor->uAIState = Removed;
+      if ( uActiveCharacter )
+        pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0);
+    }
+  }
+  else if ( (signed int)newDialogueType > DIALOGUE_84 && (signed int)newDialogueType <= DIALOGUE_ARENA_SELECT_CHAMPION ) //выбор уровня сложности боя
+  {
+    ArenaFight();
+    return;
+  }
+  else if(newDialogueType == DIALOGUE_USE_NPC_ABILITY)
+  {
+    if (UseNPCSkill((NPCProf)speakingNPC->uProfession) == 0)
+    {
+      if ( speakingNPC->uProfession != GateMaster )
+        speakingNPC->bHasUsedTheAbility = 1;
+      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+    }
+    else
+      ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2); //"Your packs are already full!"
+  }
+  else if(newDialogueType == DIALOGUE_13)
+  {
+    if (!speakingNPC->Hired())
+    {
+      sub_4B3E1E();
+      dialogue_show_profession_details = false;
+    }
+    else
+    {
+      for ( uint i = 0; i < (signed int)pNPCStats->uNumNewNPCs; ++i )
+      {
+        if ( pNPCStats->pNewNPCData[i].uFlags & 0x80 && !strcmp(speakingNPC->pName, pNPCStats->pNewNPCData[i].pName) )
+          pNPCStats->pNewNPCData[i].uFlags &= 0x7Fu;
+      }
+      if ( pParty->pHirelings[0].pName && !_stricmp(pParty->pHirelings[0].pName, speakingNPC->pName) )
+        memset(&pParty->pHirelings[0], 0, sizeof(NPCData));
+      else if ( pParty->pHirelings[1].pName && !_stricmp(pParty->pHirelings[1].pName, speakingNPC->pName) )
+        memset(&pParty->pHirelings[1], 0, sizeof(NPCData));
+      pParty->hirelingScrollPosition = 0;
+      pParty->CountHirelings();
+      dword_591084 = 0;
+      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+      dword_7241C8 = 0;
+      return;
+    }
+  }
+  else if(newDialogueType >= DIALOGUE_EVT_A && newDialogueType <= DIALOGUE_EVT_F)
+  {
+    switch(newDialogueType)
+    {
+      case DIALOGUE_EVT_A:  npc_event_id = speakingNPC->evt_A; break;
+      case DIALOGUE_EVT_B:  npc_event_id = speakingNPC->evt_B; break;
+      case DIALOGUE_EVT_C:  npc_event_id = speakingNPC->evt_C; break;
+      case DIALOGUE_EVT_D:  npc_event_id = speakingNPC->evt_D; break;
+      case DIALOGUE_EVT_E:  npc_event_id = speakingNPC->evt_E; break;
+      case DIALOGUE_EVT_F:  npc_event_id = speakingNPC->evt_F; break;
+    }
+    if ( (npc_event_id >= 200) && (npc_event_id <= 310) )
+      _4B3FE5_training_dialogue(npc_event_id); //200-310
+    else if (( npc_event_id >= 400) && (npc_event_id <= 410) )
+    { //400-410
+      dword_F8B1D8 = newDialogueType;
+      DrawJoinGuildWindow(npc_event_id - 400);
+    }
+    else
+    {
+      switch ( npc_event_id )
+      {
+        case 139:
+          OracleDialogue();
+          break;
+        case 311:
+          CheckBountyRespawnAndAward();
+          break;
+        case 399:
+          Arena_SelectionFightLevel();
+          break;
+        default:
+          activeLevelDecoration = (LevelDecoration*)1;
+          current_npc_text = 0;
+          EventProcessor(npc_event_id, 0, 1);
+          activeLevelDecoration = NULL;
+          break;
+      }
+    }
+  }
+  if ( !dword_7241C8 )
+    pGame->Draw();
+  dword_7241C8 = 0;
 }
 
 //----- (004BDAAF) --------------------------------------------------------
 bool MerchandiseTest(ItemGen *item, int _2da_idx)
 {
-  int v6; // edx@8
-  int v7; // edx@9
-  int v8; // edx@10
-  unsigned __int8 v9; // zf@16
-  char v10; // sf@16
-  unsigned __int8 v11; // of@16
   bool test;
 
   if ( (p2DEvents[_2da_idx - 1].uType != 4 || (signed int)item->uItemID < 740 || (signed int)item->uItemID > 771)