changeset 1622:01c04ff9b7a5

m
author Ritor1
date Sun, 15 Sep 2013 19:12:34 +0600
parents 85a099ea7975
children a6642179aa33
files UI/UIHouses.cpp
diffstat 1 files changed, 104 insertions(+), 160 deletions(-) [+]
line wrap: on
line diff
--- a/UI/UIHouses.cpp	Sun Sep 15 00:46:00 2013 +0600
+++ b/UI/UIHouses.cpp	Sun Sep 15 19:12:34 2013 +0600
@@ -2816,44 +2816,19 @@
 //----- (004B705E) --------------------------------------------------------
 void TempleDialog()
 {
-    int pPrice; // edi@1
-    int result; // eax@4
-    unsigned int v9; // eax@9
-    int pTextHeight; // eax@11
-    int v11; // eax@12
-    GUIWindow *v12; // ecx@16
-    int v13; // edx@16
-    GUIButton *v14; // eax@19
-    GUIButton *v15; // edi@19
-    int v16; // eax@19
-    unsigned int v19; // ecx@21
-    int v20; // eax@21
-    unsigned __int16 pTextColor; // ax@21
-    double v24; // st7@28
-    unsigned int v25; // ebx@28
-    DDM_DLV_Header *v26; // edi@29
-    int v27; // eax@31
-    int v28; // eax@32
-    unsigned int v30; // edx@36
-    unsigned int v31; // edx@38
-    unsigned int v32; // edx@40
-    unsigned int v33; // edx@42
-    unsigned int v34; // edx@44
-    int v35; // edi@50
-    signed int v36; // eax@50
-    unsigned __int8 v37; // al@54
-    int v38; // ecx@54
-    GUIWindow *v39; // eax@56
-    unsigned __int8 v40; // al@61
-    GUIButton *pButton; // edi@64
-    int v47; // edi@71
-    unsigned int v52; // ecx@73
-    GUIWindow tample_window; // [sp+13Ch] [bp-88h]@1
-    unsigned int v62; // [sp+1B0h] [bp-14h]@8
-    unsigned __int8 index; // [sp+1B7h] [bp-Dh]@64
-    int v64; // [sp+1B8h] [bp-Ch]@6
-    unsigned int pCurrentItem; // [sp+1BCh] [bp-8h]@6
-    int all_text_height; // [sp+1C0h] [bp-4h]@6
+  int pPrice; // edi@1
+  int pTextHeight; // eax@11
+  unsigned __int16 pTextColor; // ax@21
+  DDM_DLV_Header *v26; // edi@29
+  unsigned int v30; // edx@36
+  int v35; // edi@50
+  GUIButton *pButton; // edi@64
+  int v47; // edi@71
+  GUIWindow tample_window; // [sp+13Ch] [bp-88h]@1
+  unsigned __int8 index; // [sp+1B7h] [bp-Dh]@64
+  int v64; // [sp+1B8h] [bp-Ch]@6
+  unsigned int pCurrentItem; // [sp+1BCh] [bp-8h]@6
+  int all_text_height; // [sp+1C0h] [bp-4h]@6
 
   memcpy(&tample_window, window_SpeakInHouse, sizeof(tample_window));
   tample_window.uFrameX = 483;
@@ -2887,7 +2862,7 @@
     v64 = (174 - (signed int)all_text_height) / (pDialogueWindow->pNumPresenceButton - index);
     if ( v64 > 32 )
       v64 = 32;
-    v47 = (174 - v64 * (pDialogueWindow->pNumPresenceButton - index) - (signed int)all_text_height) / 2 - v64 / 2 + 138;
+    all_text_height = (174 - v64 * (pDialogueWindow->pNumPresenceButton - index) - (signed int)all_text_height) / 2 - v64 / 2 + 138;
     if ( index + pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton )
     {
       uint i = index;
@@ -2895,16 +2870,15 @@
           (signed int)pCurrentItem < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++pCurrentItem )
       {
         pButton = pDialogueWindow->GetControl(pCurrentItem);
-        pButton->uY = v64 + v47;
+        pButton->uY = v64 + all_text_height;
         pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[1 * i], &tample_window, 0, 0);
-        v52 = pButton->uY;
         pButton->uHeight = pTextHeight;
-        v47 = v52 + pTextHeight - 1;
-        pButton->uW = v47;
+        pButton->uW = pButton->uY + pTextHeight - 1;
+        all_text_height = pButton->uW;
         pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu);
         if ( pDialogueWindow->pCurrentPosActiveItem != index + 2 )
           pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
-        tample_window.DrawTitleText(pFontArrus, 0, v52, pTextColor, pShopOptions[1 * i], 3);
+        tample_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pShopOptions[1 * i], 3);
         i++;
         index++;
       }
@@ -2916,12 +2890,11 @@
   {
     if ( !pPlayers[uActiveCharacter]->IsPlayerHealableByTemple() )
       return;
-    v25 = 0;
     if ( pParty->uNumGold < pPrice )
     {
-      ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);
+      ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);//"У вас не хватает золота"
       PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25);
+      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
       return;
     }
     Party::TakeGold(pPrice);
@@ -2929,21 +2902,18 @@
     memset(pPlayers[uActiveCharacter], 0, 0xA0u);
     pPlayers[uActiveCharacter]->sHealth = pPlayers[uActiveCharacter]->GetMaxHealth();
     pPlayers[uActiveCharacter]->sMana = pPlayers[uActiveCharacter]->GetMaxMana();
-    v36 = (signed int)window_SpeakInHouse->ptr_1C;
-    if ( v36 != 78 && (v36 <= 80 || v36 > 82) )
+    if ( (signed int)window_SpeakInHouse->ptr_1C != 78 && ((signed int)window_SpeakInHouse->ptr_1C <= 80 || (signed int)window_SpeakInHouse->ptr_1C > 82) )
     {
       if ( (unsigned int)pPlayers[uActiveCharacter]->pConditions[17] | v35 )
       {
-        v37 = LOBYTE(pPlayers[uActiveCharacter]->uPrevFace);
-        v38 = pPlayers[uActiveCharacter]->uPrevVoiceID;
-        pPlayers[uActiveCharacter]->uCurrentFace = v37;
-        pPlayers[uActiveCharacter]->uVoiceID = v38;
-        ReloadPlayerPortraits(uActiveCharacter - 1, (char)v37);
+        pPlayers[uActiveCharacter]->uCurrentFace = pPlayers[uActiveCharacter]->uPrevFace;
+        pPlayers[uActiveCharacter]->uVoiceID = pPlayers[uActiveCharacter]->uPrevVoiceID;
+        ReloadPlayerPortraits(uActiveCharacter - 1, pPlayers[uActiveCharacter]->uPrevFace);
       }
       pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x2), -1, 0, -1, 0, 0, 0, 0);
       pPlayers[uActiveCharacter]->PlaySound(SPEECH_82, 0);
       pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536);
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25);
+      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
       return;
     }
     if ( (unsigned int)pPlayers[uActiveCharacter]->pConditions[17] | v35 )
@@ -2958,117 +2928,105 @@
         pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x2), -1, 0, -1, 0, 0, 0, 0);
         pPlayers[uActiveCharacter]->PlaySound(SPEECH_82, 0);
         pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536);
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25);
+        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
         return;
       }
       pPlayers[uActiveCharacter]->uPrevFace = pPlayers[uActiveCharacter]->uCurrentFace;
       pPlayers[uActiveCharacter]->uPrevVoiceID = pPlayers[uActiveCharacter]->uVoiceID;
       pPlayers[uActiveCharacter]->SetCondition(0x11u, 1);
       pPlayers[uActiveCharacter]->uVoiceID = (pPlayers[uActiveCharacter]->GetSexByVoice() != 0) + 23;
-      v40 = (pPlayers[uActiveCharacter]->GetSexByVoice() != 0) + 23;
-      pPlayers[uActiveCharacter]->uCurrentFace = v40;
-      ReloadPlayerPortraits(uActiveCharacter - 1, (char)v40);
+      pPlayers[uActiveCharacter]->uCurrentFace = (pPlayers[uActiveCharacter]->GetSexByVoice() != 0) + 23;
+      ReloadPlayerPortraits(uActiveCharacter - 1, (pPlayers[uActiveCharacter]->GetSexByVoice() != 0) + 23);
       LODWORD(pPlayers[uActiveCharacter]->pConditions[17]) = LODWORD(pParty->uTimePlayed);
-      v39 = (GUIWindow *)HIDWORD(pParty->uTimePlayed);
+      //v39 = (GUIWindow *)HIDWORD(pParty->uTimePlayed);
     }
-    HIDWORD(pPlayers[uActiveCharacter]->pConditions[17]) = (int)v39;
+    //HIDWORD(pPlayers[uActiveCharacter]->pConditions[17]) = (int)v39;
+    pPlayers[uActiveCharacter]->pConditions[17] =pParty->uTimePlayed;
     pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x2), -1, 0, -1, 0, 0, 0, 0);
     pPlayers[uActiveCharacter]->PlaySound(SPEECH_82, 0);
     pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536);
-    pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25);
+    pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
     return;
   }
   //---------------------------------------------------
   if ( dialog_menu_id == HOUSE_DIALOGUE_TEMPLE_DONATE )
   {
-      v24 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
-      v25 = 0;
-      if ( pParty->uNumGold >= (unsigned int)(signed __int64)v24 )
+    pPrice = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
+    if ( pParty->uNumGold >= (unsigned int)pPrice )
+    {
+      Party::TakeGold((unsigned int)pPrice);
+      v26 = &pOutdoor->ddm;
+      if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
+        v26 = &pIndoor->dlv;
+      if ( v26->uReputation > -5 )
       {
-        Party::TakeGold((signed __int64)v24);
-        v26 = &pOutdoor->ddm;
-        if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
-          v26 = &pIndoor->dlv;
-        v27 = v26->uReputation;
-        //v66 = v26;
-        if ( v27 > -5 )
+        v26->uReputation = v26->uReputation - 1;
+        if ( v26->uReputation - 1 < -5 )
+          v26->uReputation = -5;
+      }
+      if ( (unsigned __int8)byte_F8B1EF[uActiveCharacter] == pParty->uDaysPlayed % 7 )
+      {
+        if ( v26->uReputation <= -5 )
         {
-          v28 = v27 - 1;
-          v26->uReputation = v28;
-          if ( v28 < -5 )
-            v26->uReputation = -5;
+          v30 = pParty->uDaysPlayed % 7 + 1;
+          LOBYTE(v30) = v30 | 0x80;
+          _42777D_CastSpell_UseWand_ShootArrow(SPELL_AIR_WIZARD_EYE, uActiveCharacter - 1, v30, 48, 0);
         }
-        if ( (unsigned __int8)byte_F8B1EF[uActiveCharacter] == pParty->uDaysPlayed % 7 )
+        if ( v26->uReputation <= -10 )
         {
-          if ( v26->uReputation <= -5 )
-          {
-            v30 = pParty->uDaysPlayed % 7 + 1;
-            LOBYTE(v30) = v30 | 0x80;
-            _42777D_CastSpell_UseWand_ShootArrow(SPELL_AIR_WIZARD_EYE, uActiveCharacter - 1, v30, 48, 0);
-          }
-          if ( v26->uReputation <= -10 )
-          {
-            v31 = pParty->uDaysPlayed % 7 + 1;
-            LOBYTE(v31) = v31 | 0x80;
-            _42777D_CastSpell_UseWand_ShootArrow(SPELL_SPIRIT_PRESERVATION, uActiveCharacter - 1, v31, 48, 0);
-            //v26 = v66;
-          }
-          if ( v26->uReputation <= -15 )
-          {
-            v32 = pParty->uDaysPlayed % 7 + 1;
-            LOBYTE(v32) = v32 | 0x80;
-            _42777D_CastSpell_UseWand_ShootArrow(SPELL_BODY_PROTECTION_FROM_MAGIC, uActiveCharacter - 1, v32, 48, 0);
-            //v26 = v66;
-          }
-          if ( v26->uReputation <= -20 )
-          {
-            v33 = pParty->uDaysPlayed % 7 + 1;
-            LOBYTE(v33) = v33 | 0x80;
-            _42777D_CastSpell_UseWand_ShootArrow(SPELL_LIGHT_HOUR_OF_POWER, uActiveCharacter - 1, v33, 48, 0);
-            //v26 = v66;
-          }
-          if ( v26->uReputation <= -25 )
-          {
-            v34 = pParty->uDaysPlayed % 7 + 1;
-            LOBYTE(v34) = v34 | 0x80;
-            _42777D_CastSpell_UseWand_ShootArrow(SPELL_LIGHT_DAY_OF_PROTECTION, uActiveCharacter - 1, v34, 48, 0);
-          }
+          v30 = pParty->uDaysPlayed % 7 + 1;
+          LOBYTE(v30) = v30 | 0x80;
+          _42777D_CastSpell_UseWand_ShootArrow(SPELL_SPIRIT_PRESERVATION, uActiveCharacter - 1, v30, 48, 0);
+        }
+        if ( v26->uReputation <= -15 )
+        {
+          v30 = pParty->uDaysPlayed % 7 + 1;
+          LOBYTE(v30) = v30 | 0x80;
+          _42777D_CastSpell_UseWand_ShootArrow(SPELL_BODY_PROTECTION_FROM_MAGIC, uActiveCharacter - 1, v30, 48, 0);
+        }
+        if ( v26->uReputation <= -20 )
+        {
+          v30 = pParty->uDaysPlayed % 7 + 1;
+          LOBYTE(v30) = v30 | 0x80;
+          _42777D_CastSpell_UseWand_ShootArrow(SPELL_LIGHT_HOUR_OF_POWER, uActiveCharacter - 1, v30, 48, 0);
         }
-        ++byte_F8B1EF[uActiveCharacter];
-        pPlayers[uActiveCharacter]->PlaySound(SPEECH_83, 0);
-        ShowStatusBarString(pGlobalTXT_LocalizationStrings[527], 2); // "Thank You!"
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25);
-        return;
+        if ( v26->uReputation <= -25 )
+        {
+          v30 = pParty->uDaysPlayed % 7 + 1;
+          LOBYTE(v30) = v30 | 0x80;
+          _42777D_CastSpell_UseWand_ShootArrow(SPELL_LIGHT_DAY_OF_PROTECTION, uActiveCharacter - 1, v30, 48, 0);
+        }
       }
-      ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);
-      PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25);
+      ++byte_F8B1EF[uActiveCharacter];
+      pPlayers[uActiveCharacter]->PlaySound(SPEECH_83, 0);
+      ShowStatusBarString(pGlobalTXT_LocalizationStrings[527], 2); // "Thank You!"
+      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
       return;
+    }
+    ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);//"У вас не хватает золота"
+    PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
+    pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+    return;
   }
   //------------------------------------------------
   if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS )
   {
     if ( HouseUI_CheckIfPlayerCanInteract() )
     {
-      //v61 = pDialogueWindow;
       all_text_height = 0;
       pCurrentItem = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
       v64 = (signed int)(pCurrentItem * (100 - pPlayers[uActiveCharacter]->GetMerchant())) / 100;
       if ( v64 < (signed int)pCurrentItem / 3 )
         v64 = (signed int)pCurrentItem / 3;
       pCurrentItem = 0;
-      //if ( (signed int)pDialogueWindow->pStartingPosActiveItem >= v8 )
-      //goto LABEL_78;
-      for ( v62 = pDialogueWindow->pStartingPosActiveItem; (signed int)v62 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++v62 )
+      for ( int i = pDialogueWindow->pStartingPosActiveItem; i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
       {
-        v9 = pDialogueWindow->GetControl(v62)->msg_param - 36;
-        if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v9] && !pPlayers[uActiveCharacter]->pActiveSkills[v9] )
+        if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pDialogueWindow->GetControl(i)->msg_param - 36]
+         && !pPlayers[uActiveCharacter]->pActiveSkills[pDialogueWindow->GetControl(i)->msg_param - 36] )
         {
-          all_text_height += pFontArrus->CalcTextHeight(pSkillNames[v9], &tample_window, 0, 0);
-          //v66 = (DDM_DLV_Header *)((char *)v66 + pTextHeight);
+          all_text_height += pFontArrus->CalcTextHeight(pSkillNames[pDialogueWindow->GetControl(i)->msg_param - 36], &tample_window, 0, 0);
           ++pCurrentItem;
         }
-        v11 = pDialogueWindow->pStartingPosActiveItem;
       }
       if ( pCurrentItem )
       {
@@ -3077,52 +3035,39 @@
         v64 = (149 - (signed int)all_text_height) / (signed int)pCurrentItem;
         if ( v64 > 32 )
           v64 = 32;
-        pCurrentItem = (signed int)(149 - pCurrentItem * v64 - (int)all_text_height) / 2 - v64 / 2 + 162;
-        v12 = pDialogueWindow;
-        result = pDialogueWindow->pStartingPosActiveItem;
-        v13 = result + pDialogueWindow->pNumPresenceButton;
-        v62 = pDialogueWindow->pStartingPosActiveItem;
-        if ( result < v13 )
+        all_text_height = (signed int)(149 - pCurrentItem * v64 - (int)all_text_height) / 2 - v64 / 2 + 162;
+        if ( pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton )
         {
-          all_text_height = 2;
-          while ( 1 )
+          pCurrentItem = 2;
+          for ( int i = pDialogueWindow->pStartingPosActiveItem;
+                    i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
           {
-            v14 = v12->GetControl(v62);
-            v15 = v14;
-            v16 = v14->msg_param - 36;
-            if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v16] || pPlayers[uActiveCharacter]->pActiveSkills[v16] )
+            pButton = pDialogueWindow->GetControl(i);
+            if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pButton->msg_param - 36]
+              || pPlayers[uActiveCharacter]->pActiveSkills[pButton->msg_param - 36] )
             {
-              v15->uW = 0;
-              v15->uHeight = 0;
-              v15->uY = 0;
+              pButton->uW = 0;
+              pButton->uHeight = 0;
+              pButton->uY = 0;
             }
             else
             {
-              v15->uY = v64 + pCurrentItem;
-              pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v16], &tample_window, 0, 0);
-              v19 = v15->uY;
-              v15->uHeight = pTextHeight;
-              v20 = v19 + pTextHeight - 1;
-              v15->uW = v20;
-              pCurrentItem = v20;
+              pButton->uY = v64 + all_text_height;
+              pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &tample_window, 0, 0);
+              pButton->uHeight = pTextHeight;
+              pButton->uW = pButton->uY + pTextHeight - 1;
+              all_text_height = pButton->uW;
               pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu);
-              if ( pDialogueWindow->pCurrentPosActiveItem != all_text_height )
+              if ( pDialogueWindow->pCurrentPosActiveItem != pCurrentItem )
                 pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
-              tample_window.DrawTitleText(pFontArrus, 0, v19, pTextColor, pSkillNames[v16], 3);
+              tample_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pSkillNames[pButton->msg_param - 36], 3);
             }
-            result = (int)pDialogueWindow;
-            ++v62;
-            //v66 = (DDM_DLV_Header *)((char *)v66 + 1);
-	        all_text_height++;
-            if ( (signed int)v62 >= pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem )
-              break;
-            v12 = pDialogueWindow;
+            pCurrentItem++;
           }
         }
       }
       else
       {
-LABEL_78:
         sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);
         strcat(pTmpBuf.data(), "\n \n");
         strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);
@@ -3137,7 +3082,6 @@
 //----- (004B4710) --------------------------------------------------------
 void TrainingDialog()
 {
-  //Player *v0; // ebx@1
   int color2; // eax@1
   //unsigned int v2; // ecx@1
   //int v3; // eax@1