changeset 1580:1264fce1a17f

m
author Ritor1
date Tue, 10 Sep 2013 23:42:03 +0600
parents 6d759814a817
children a5fdf6cf8d74
files UI/UIHouses.cpp
diffstat 1 files changed, 139 insertions(+), 199 deletions(-) [+]
line wrap: on
line diff
--- a/UI/UIHouses.cpp	Sun Sep 08 19:16:37 2013 +0600
+++ b/UI/UIHouses.cpp	Tue Sep 10 23:42:03 2013 +0600
@@ -3888,42 +3888,15 @@
 //----- (004B2A74) --------------------------------------------------------
 void SimpleHouseAndBoatsDialog()
 {
-  char *v0; // esi@3
-  char *v1; // ST1C_4@3
   char *v2; // eax@3
-  const char *v3; // ST1C_4@5
-  int v4; // eax@5
   unsigned int i; // eax@5
-  NPCData *v6; // esi@6
-  unsigned __int16 v7; // bx@6
-  unsigned int v8; // eax@6
-  int v9; // eax@11
-  unsigned int v10; // ecx@12
-  int v11; // eax@12
-  int v12; // esi@12
-  char *v13; // eax@12
-  GUIWindow *v14; // ebx@13
+  NPCData *pNPC; // esi@6
   char *v15; // esi@14
-  GUIButton *v16; // eax@15
-  unsigned int v17; // ecx@15
+  GUIButton *pButton; // eax@15
   int v18; // ecx@17
-  int v19; // ecx@18
-  int v20; // ecx@19
-  int v21; // ecx@20
-  int v22; // ecx@21
-  unsigned int v23; // ecx@23
-  int v24; // ecx@35
-  int v25; // ecx@36
-  int v26; // ecx@37
-  int v27; // ecx@38
-  int v28; // ecx@39
   char *v29; // esi@42
-  unsigned int v30; // ST20_4@42
   int v31; // ST1C_4@42
-  unsigned int v32; // eax@42
-  char *v33; // eax@43
   int v34; // esi@51
-  int v35; // eax@51
   unsigned int v36; // edi@51
   GUIButton *v37; // eax@52
   int v38; // eax@52
@@ -3937,258 +3910,226 @@
   unsigned __int16 v46; // ax@60
   GUIFont *v47; // ebx@64
   int v48; // esi@64
-  char *v49; // eax@66
   GUIWindow w; // [sp+Ch] [bp-110h]@64
   GUIWindow v52; // [sp+60h] [bp-BCh]@13
-  GUIWindow a1; // [sp+B4h] [bp-68h]@1
-  unsigned int v54; // [sp+108h] [bp-14h]@14
-  int v55; // [sp+10Ch] [bp-10h]@6
-  int v56; // [sp+110h] [bp-Ch]@13
+  GUIWindow house_window; // [sp+B4h] [bp-68h]@1
   char *pInString; // [sp+114h] [bp-8h]@12
-  NPCData *v58; // [sp+118h] [bp-4h]@6
 
-  memcpy(&a1, pDialogueWindow, sizeof(a1));
+  memcpy(&house_window, pDialogueWindow, sizeof(house_window));
   if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic )
   {
-    v0 = pMapStats->pInfos[uHouse_ExitPic].pName;
-    v1 = pMapStats->pInfos[uHouse_ExitPic].pName;
-    a1.uFrameX = 493;
-    a1.uFrameWidth = 126;
-    a1.uFrameZ = 366;
-    a1.DrawTitleText(pFontCreate, 0, 2u, 0, v1, 3u);
-    a1.uFrameX = 483;
-    a1.uFrameWidth = 148;
-    a1.uFrameZ = 334;
+    house_window.uFrameX = 493;
+    house_window.uFrameWidth = 126;
+    house_window.uFrameZ = 366;
+    house_window.DrawTitleText(pFontCreate, 0, 2, 0, pMapStats->pInfos[uHouse_ExitPic].pName, 3);
+    house_window.uFrameX = 483;
+    house_window.uFrameWidth = 148;
+    house_window.uFrameZ = 334;
     v2 = pTransitionStrings[uHouse_ExitPic];
     if ( !v2 )
     {
-      sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[411], v0);
+      sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[411], pMapStats->pInfos[uHouse_ExitPic].pName);//Войти в ^Pv[%s]
       v2 = pTmpBuf.data();
     }
-    v3 = v2;
-    v4 = pFontCreate->CalcTextHeight(v2, &a1, 0, 0);
-    a1.DrawTitleText(pFontCreate, 0, (212 - v4) / 2 + 101, 0, v3, 3u);
+    house_window.DrawTitleText(pFontCreate, 0, (212 - pFontCreate->CalcTextHeight(v2, &house_window, 0, 0)) / 2 + 101, 0, v2, 3);
     return;
   }
-  a1.uFrameWidth -= 10;
-  a1.uFrameZ -= 10;
-  v58 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) )];//- 1
-  v6 = v58;
-  v55 = TargetColor(0xE1u, 0xCDu, 0x23u);
-  v7 = TargetColor(0x15u, 0x99u, 0xE9u);
-  v8 = v6->uProfession;
-  if ( v8 )
-    sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], v6->pName, aNPCProfessionNames[v8]);
+  house_window.uFrameWidth -= 10;
+  house_window.uFrameZ -= 10;
+  pNPC = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) )];//- 1
+  if ( pNPC->uProfession )
+    sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], pNPC->pName, aNPCProfessionNames[pNPC->uProfession]);//^Pi[%s] %s
   else
-    strcpy(pTmpBuf.data(), v6->pName);
-  a1.DrawTitleText(pFontCreate, 0x1E3u, 0x71u, v7, pTmpBuf.data(), 3u);
+    strcpy(pTmpBuf.data(), pNPC->pName);
+  house_window.DrawTitleText(pFontCreate, 483, 113, TargetColor(0x15u, 0x99u, 0xE9u), pTmpBuf.data(), 3);
   if ( !dword_591080 )
   {
     if ( !uDialogueType )
     {
-      v9 = v6->greet;
-      if ( v9 )
+      if ( pNPC->greet )
       {
-        v10 = v6->uFlags;
-        a1.uFrameWidth = game_viewport_width;
-        a1.uFrameZ = 452;
-        pInString = (char *)*(&pNPCStats->field_17884 + ((v10 & 3) == 2) + 2 * v9);
-        v11 = pFontArrus->CalcTextHeight(pInString, &a1, 13, 0);
-        v12 = v11 + 7;
-        pRenderer->GetLeather(8, 352 - (v11 + 7),
-          pIcons_LOD->GetTexture(uTextureID_Leather),
-          pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - (v11 + 7));
-        pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-        v13 = FitTextInAWindow(pInString, pFontArrus, &a1, 0xDu, 0);
-        pDialogueWindow->DrawText(pFontArrus, 13, 354 - v12, 0, v13, 0, 0, 0);
+        house_window.uFrameWidth = game_viewport_width;
+        house_window.uFrameZ = 452;
+        pInString = (char *)*(&pNPCStats->field_17884 + ((pNPC->uFlags & 3) == 2) + 2 * pNPC->greet);
+        pRenderer->GetLeather(8, 352 - (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7),
+           pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight
+           - (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7));
+        pRenderer->DrawTextureIndexed(8, 347 - (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7), pTexture_591428);
+        pDialogueWindow->DrawText(pFontArrus, 13, 354 - (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7),
+                                             0, FitTextInAWindow(pInString, pFontArrus, &house_window, 0xDu, 0), 0, 0, 0);
       }
     }
   }
-  v14 = pDialogueWindow;
   memcpy(&v52, pDialogueWindow, sizeof(v52));
   v52.uFrameX = 483;
   v52.uFrameWidth = 148;
   v52.uFrameZ = 334;
-  v56 = v52.pStartingPosActiveItem;
+  
   if ( v52.pStartingPosActiveItem < v52.pStartingPosActiveItem + v52.pNumPresenceButton )
   {
-    v15 = "";//(char *)v54;
-    while ( 1 )
+    v15 = "";
+    for ( int i = v52.pStartingPosActiveItem; i < v52.pStartingPosActiveItem + v52.pNumPresenceButton; ++i )
     {
-      v16 = v52.GetControl(v56);
-      v17 = v16->msg_param;
-      pInString = (char *)v16;
-      if ( (signed int)v17 > 24 )
+      pButton = v52.GetControl(i);
+      if ( (signed int)pButton->msg_param > 24 )
       {
-        v24 = v17 - 76;
-        if ( !v24 )
+        if ( pButton->msg_param == 76 )
         {
-          v15 = pGlobalTXT_LocalizationStrings[406];
-          goto LABEL_49;
+          v15 = pGlobalTXT_LocalizationStrings[406];//Нанять
+          strcpy(pButton->pButtonName, v15);
+          continue;
         }
-        v25 = v24 - 1;
-        if ( !v25 )
+        if ( pButton->msg_param == 77 )
         {
-          v15 = pGlobalTXT_LocalizationStrings[407];
-          goto LABEL_49;
+          strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[407]);//Подробнее
+          continue;
         }
-        v26 = v25 - 2;
-        if ( !v26 )
+        if ( pButton->msg_param == 79 )
         {
-          v33 = _4B254D_SkillMasteryTeacher((int)v52.ptr_1C);
-LABEL_44:
-          v15 = v33;
-          v16 = (GUIButton *)pInString;
-          goto LABEL_49;
+          strcpy(pButton->pButtonName, _4B254D_SkillMasteryTeacher((int)v52.ptr_1C));
+          continue;
         }
-        v27 = v26 - 3;
-        if ( !v27 )
+        if ( pButton->msg_param == 82 )
         {
-          v33 = (char *)ContractSelectText((int)v52.ptr_1C);
-          goto LABEL_44;
+          strcpy(pButton->pButtonName, ContractSelectText((int)v52.ptr_1C));
+          continue;
         }
-        v28 = v27 - 1;
-        if ( !v28 )
+        if ( pButton->msg_param == 83 )
         {
           v29 = pMonsterStats->pInfos[bountyHunting_monster_id_for_hunting].pName;
-          v30 = TargetColor(0xFFu, 0xFFu, 0xFFu);
           v31 = *(int *)v29;
-          v32 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
-          sprintfex(pTmpBuf.data(), "\f%05d%s\f%05d", v32, v31, v30);
+          sprintfex(pTmpBuf.data(), "\f%05d%s\f%05d", TargetColor(0xFFu, 0xFFu, 0x9Bu), v31, TargetColor(0xFFu, 0xFFu, 0xFFu));
           sprintfex(pTmpBuf2.data(), bountyHunting_text, pTmpBuf.data(), 100 * (unsigned __int8)v29[8]);
           current_npc_text = pTmpBuf2.data();
-          v15 = "";
-          v16 = (GUIButton *)pInString;
-          goto LABEL_49;
+          strcpy(pButton->pButtonName, "");
+          continue;
         }
-        if ( v28 != 10 )
+        if ( pButton->msg_param != 93 )
         {
-          v15 = "";
-          goto LABEL_49;
+          strcpy(pButton->pButtonName, "");
+          continue;
         }
       }
       else
       {
-        if ( v17 == 24 )
+        if ( pButton->msg_param == 24 )//evt_F
         {
-          v23 = v58->evt_F;
-LABEL_33:
-          v15 = (char *)pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+          v15 = (char *)pNPCTopics[pNPC->evt_F-1].pTopic;
           if ( !v15 )
           {
-            v16->msg_param = 0;
+            pButton->msg_param = 0;
             v15 = "";
           }
-          goto LABEL_49;
+          strcpy(pButton->pButtonName, v15);
+          continue;
         }
-        v18 = v17 - 13;
+        v18 = pButton->msg_param - 13;
         if ( v18 )
         {
-          v19 = v18 - 6;
-          if ( !v19 )
+          if ( pButton->msg_param == 19 )//evt_A
           {
-            v23 = v58->evt_A;
-            goto LABEL_33;
-          }
-          v20 = v19 - 1;
-          if ( !v20 )
-          {
-            v15 = (char *)pNPCTopics[v58->evt_B-1].pTopic;//(&dword_721660)[8 * v58->evtb];
+            v15 = (char *)pNPCTopics[pNPC->evt_A-1].pTopic;
             if ( !v15 )
             {
-              v16->msg_param = 0;
+              pButton->msg_param = 0;
+              v15 = "";
+            }
+            strcpy(pButton->pButtonName, v15);
+            continue;
+          }
+          if ( pButton->msg_param == 20 )//evt_B
+          {
+            v15 = (char *)pNPCTopics[pNPC->evt_B-1].pTopic;
+            if ( !v15 )
+            {
+              pButton->msg_param = 0;
               v15 = "";
             }
             if ( uDialogueType != 84 )
-              goto LABEL_49;
-            sprintf(pTmpBuf.data(), format_4E2D80, v55, pItemsTable->pItems[contract_approved].pUnidentifiedName);
+            {
+              strcpy(pButton->pButtonName, v15);
+              continue;
+            }
+            sprintf(pTmpBuf.data(), format_4E2D80, TargetColor(0xE1u, 0xCDu, 0x23u), pItemsTable->pItems[contract_approved].pUnidentifiedName);
             sprintf(pTmpBuf2.data(), current_npc_text, pTmpBuf.data());
             current_npc_text = pTmpBuf2.data();
-            v16 = (GUIButton *)pInString;
-            goto LABEL_49;
+            strcpy(pButton->pButtonName, v15);
+            continue;
           }
-          v21 = v20 - 1;
-          if ( !v21 )
+          if ( pButton->msg_param == 21 )//evt_C
           {
-            v23 = v58->evt_C;
-            goto LABEL_33;
+            v15 = (char *)pNPCTopics[pNPC->evt_C-1].pTopic;
+            if ( !v15 )
+            {
+              pButton->msg_param = 0;
+              v15 = "";
+            }
+            strcpy(pButton->pButtonName, v15);
+            continue;
           }
-          v22 = v21 - 1;
-          if ( !v22 )
-          {
-            v23 = v58->evt_D;
-            goto LABEL_33;
-          }
-          if ( v22 == 1 )
+          if ( pButton->msg_param == 22 )//evt_D
           {
-            v23 = v58->evt_E;
-            goto LABEL_33;
+            v15 = (char *)pNPCTopics[pNPC->evt_D-1].pTopic;
+            if ( !v15 )
+            {
+              pButton->msg_param = 0;
+              v15 = "";
+            }
+            strcpy(pButton->pButtonName, v15);
+            continue;
           }
-LABEL_41:
-          v15 = "";
-          goto LABEL_49;
+          if ( pButton->msg_param == 23 )//evt_E
+          {
+            v15 = (char *)pNPCTopics[pNPC->evt_E-1].pTopic;
+            if ( !v15 )
+            {
+              pButton->msg_param = 0;
+              v15 = "";
+            }
+            strcpy(pButton->pButtonName, v15);
+            continue;
+          }
+          strcpy(pButton->pButtonName, "");
+          continue;
         }
-        v15 = pGlobalTXT_LocalizationStrings[122];
-      }
-LABEL_49:
-      strcpy(v16->pButtonName, v15);
-      ++v56;
-      if ( v56 >= v52.pStartingPosActiveItem + v52.pNumPresenceButton )
-      {
-        v14 = pDialogueWindow;
-        break;
+        strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[122]);//Вступить
       }
     }
   }
   v34 = 0;
-  v54 = TargetColor(0xFFu, 0xFFu, 0xFFu);
-  v35 = TargetColor(0xE1u, 0xCDu, 0x23u);
-  v36 = v14->pStartingPosActiveItem;
-  v55 = v35;
-  for ( i = v36 + v14->pNumPresenceButton; (signed int)v36 < (signed int)i; i = pDialogueWindow->pNumPresenceButton
+  v36 = pDialogueWindow->pStartingPosActiveItem;
+  for ( i = v36 + pDialogueWindow->pNumPresenceButton; (signed int)v36 < (signed int)i; i = pDialogueWindow->pNumPresenceButton
                                                                     + pDialogueWindow->pStartingPosActiveItem )
   {
-    v37 = v14->GetControl(v36);
+    v37 = pDialogueWindow->GetControl(v36);
     v38 = pFontArrus->CalcTextHeight(v37->pButtonName, &v52, 0, 0);
-    v14 = pDialogueWindow;
     v34 += v38;
     ++v36;
   }
-  v39 = v14->pNumPresenceButton;
+  v39 = pDialogueWindow->pNumPresenceButton;
   if ( v39 )
   {
-    v58 = (NPCData *)((174 - v34) / v39);
-    if ( (signed int)v58 > 32 )
-      v58 = (NPCData *)32;
+    pNPC = (NPCData *)((174 - v34) / v39);
+    if ( (signed int)pNPC > 32 )
+      pNPC = (NPCData *)32;
     pInString = (char *)2;
-    v40 = (174 - (signed int)v58 * v39 - v34) / 2 - (signed int)v58 / 2 + 138;
-    v56 = v14->pStartingPosActiveItem;
-    i = v56;
-    if ( (signed int)i < (signed int)(i + v39) )
+    v40 = (174 - (signed int)pNPC * v39 - v34) / 2 - (signed int)pNPC / 2 + 138;
+    for ( i = pDialogueWindow->pStartingPosActiveItem; i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
     {
-      while ( 1 )
-      {
-        v41 = v14->GetControl(i);
-        v42 = v41;
-        v43 = v41->pButtonName;
-        v41->uY = (unsigned int)((char *)v58 + v40);
-        v44 = pFontArrus->CalcTextHeight(v41->pButtonName, &v52, 0, 0);
-        v45 = v42->uY;
-        v42->uHeight = v44;
-        v40 = v45 + v44 - 1;
-        v42->uW = v40;
-        v46 = v55;
-        if ( (char *)pDialogueWindow->pCurrentPosActiveItem != pInString )
-          v46 = v54;
-        v52.DrawTitleText(pFontArrus, 0, v45, v46, v43, 3u);
-        v14 = pDialogueWindow;
-        ++pInString;
-        ++v56;
-        i = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
-        if ( v56 >= (signed int)i )
-          break;
-        i = v56;
-      }
+      v41 = pDialogueWindow->GetControl(i);
+      v42 = v41;
+      v43 = v41->pButtonName;
+      v41->uY = (unsigned int)((char *)pNPC + v40);
+      v44 = pFontArrus->CalcTextHeight(v41->pButtonName, &v52, 0, 0);
+      v45 = v42->uY;
+      v42->uHeight = v44;
+      v40 = v45 + v44 - 1;
+      v42->uW = v40;
+      v46 = TargetColor(0xE1u, 0xCDu, 0x23u);
+      if ( (char *)pDialogueWindow->pCurrentPosActiveItem != pInString )
+        v46 = TargetColor(0xFFu, 0xFFu, 0xFFu);
+      v52.DrawTitleText(pFontArrus, 0, v45, v46, v43, 3);
+      ++pInString;
     }
   }
   if ( current_npc_text )
@@ -4203,9 +4144,8 @@
       v48 = pFontCreate->CalcTextHeight(current_npc_text, &w, 13, 0) + 7;
     }
     pRenderer->GetLeather(8, 352 - v48, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - v48);
-    pRenderer->DrawTextureIndexed(8u, 347 - v48, pTexture_591428);
-    v49 = FitTextInAWindow(current_npc_text, v47, &w, 13, 0);
-    a1.DrawText(v47, 13, 354 - v48, 0, v49, 0, 0, 0);
+    pRenderer->DrawTextureIndexed(8, 347 - v48, pTexture_591428);
+    house_window.DrawText(v47, 13, 354 - v48, 0, FitTextInAWindow(current_npc_text, v47, &w, 13, 0), 0, 0, 0);
   }
 }