diff UIHouses.cpp @ 651:2bf48d11d742

Training hall UI fixed
author Nomad
date Tue, 12 Mar 2013 03:10:35 +0200
parents 35ce4761382c
children 2535151505da 3f504ad074a8
line wrap: on
line diff
--- a/UIHouses.cpp	Mon Mar 11 23:52:33 2013 +0200
+++ b/UIHouses.cpp	Tue Mar 12 03:10:35 2013 +0200
@@ -3830,12 +3830,12 @@
 {
   Player *v0; // ebx@1
   int color2; // eax@1
-  unsigned int v2; // ecx@1
-  int v3; // eax@1
-  signed int v4; // edx@1
-  int v5; // edi@3
-  unsigned int v6; // esi@3
-  void *v7; // ecx@3
+  //unsigned int v2; // ecx@1
+  //int v3; // eax@1
+  //signed int v4; // edx@1
+  unsigned __int64 v5; // edi@3
+  //unsigned int v6; // esi@3
+  //void *v7; // ecx@3
   int v8; // edx@4
   double v9; // st7@6
   signed int v10; // esi@6
@@ -3894,12 +3894,12 @@
   int v63; // [sp-4h] [bp-88h]@52
   char *v64; // [sp-4h] [bp-88h]@63
   GUIWindow v65; // [sp+Ch] [bp-78h]@1
-  __int64 v66; // [sp+60h] [bp-24h]@3
+  //__int64 v66; // [sp+60h] [bp-24h]@3
   unsigned int white; // [sp+68h] [bp-1Ch]@1
   int v68; // [sp+6Ch] [bp-18h]@3
   int v69; // [sp+70h] [bp-14h]@6
-  unsigned int i; // [sp+74h] [bp-10h]@1
-  int v71; // [sp+78h] [bp-Ch]@1
+  //unsigned int i; // [sp+74h] [bp-10h]@1
+  //int v71; // [sp+78h] [bp-Ch]@1
   int v72; // [sp+7Ch] [bp-8h]@16
   int v73; // [sp+80h] [bp-4h]@14
 
@@ -3910,31 +3910,32 @@
   v65.uFrameZ = 334;
   white = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
   color2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
-  v2 = v0->uLevel;
-  v71 = color2;
-  v3 = 0;
-  v4 = 0;
-  for ( i = v2; v4 < (signed int)v2; ++v4 )
-    v3 += v4 + 1;
-  v5 = 1000 * v3;
-  v6 = HIDWORD(v0->uExperience);
-  v7 = window_SpeakInHouse->ptr_1C;
-  v68 = (unsigned __int16)word_4F0866[(signed int)v7];
-  v66 = 1000 * v3;
-  if ( (signed __int64)__PAIR__(v6, LODWORD(v0->uExperience)) >= v66 )
+  //v71 = color2;
+  //v2 = v0->uLevel;
+  //v3 = 0;
+  //v4 = 0;
+  //for ( i = v2; v4 < (signed int)v2; ++v4 )
+  //  v3 += v4 + 1;
+  //v5 = 1000 * v3;
+  v5 = 1000ui64 * v0->uLevel * (v0->uLevel + 1) / 2;  // E n = n(n + 1) / 2
+  //v6 = HIDWORD(v0->uExperience);
+  //v7 = window_SpeakInHouse->ptr_1C;
+  v68 = pMaxLevelPerTrainingHallType[(unsigned int)window_SpeakInHouse->ptr_1C - 89];
+  //v66 = 1000 * v3;
+  if (v0->uExperience >= v5)
   {
     v8 = v0->classType % 4 + 1;
     if ( v8 == 4 )
       v8 = 3;
-    v9 = (double)(signed int)i;
-    i = 0;
+    v9 = (double)v0->uLevel;
+    //i = 0;
     v69 = v8;
     //v10 = (signed __int64)(v9 * p2DEvents_minus1__20[13 * (signed int)v7] * (double)v8);
-    v10 = (signed __int64)(v9 * p2DEvents[(signed int)v7 - 1].fPriceMultiplier * (double)v8);
+    v10 = (signed __int64)(v9 * p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier * (double)v8);
     v11 = v10 * (100 - v0->GetMerchant()) / 100;
     if ( v11 < v10 / 3 )
       v11 = v10 / 3;
-    i = v11;
+    //i = v11;
   }
   result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
   if ( result )
@@ -3949,7 +3950,8 @@
           result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
           if ( result )
           {
-            i = 0;
+            //i = 0;
+            int _v0 = 0;
             v13 = pDialogueWindow;
             //v14 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0);
             v14 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
@@ -3967,7 +3969,7 @@
               if ( byte_4ED970_skill_learn_ability_by_class_table[v0->classType][v17] && !v0->pActiveSkills[v17] )
               {
                 v18 = pFontArrus->CalcTextHeight(pSkillNames[v17], &v65, 0, 0);
-                i += v18;
+                _v0 += v18;
                 ++v72;
               }
               ++v15;
@@ -3977,19 +3979,19 @@
             {
               sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v73);// "Skill Cost: %lu"
               v65.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
-              v73 = (signed int)(149 - i) / v72;
+              v73 = (signed int)(149 - _v0) / v72;
               if ( v73 > 32 )
                 v73 = 32;
               result = v13->pStartingPosActiveItem;
-              v19 = (signed int)(149 - v72 * v73 - i) / 2 - v73 / 2 + 162;
-              i = result;
+              v19 = (signed int)(149 - v72 * v73 - _v0) / 2 - v73 / 2 + 162;
+              int _v1 = result;
               v68 = v19;
               if ( result < result + v13->pNumPresenceButton )
               {
                 v72 = 2;
                 do
                 {
-                  v20 = v13->GetControl(i);
+                  v20 = v13->GetControl(_v1);
                   v21 = v20;
                   v22 = v20->uControlParam - 36;
                   if ( !byte_4ED970_skill_learn_ability_by_class_table[v0->classType][v22] || v0->pActiveSkills[v22] )
@@ -4002,24 +4004,24 @@
                   {
                     v23 = pSkillNames[v22];
                     v21->uY = v73 + v68;
-                    HIDWORD(v66) = (int)v23;
+                    //HIDWORD(v66) = (int)v23;
                     v24 = pFontArrus->CalcTextHeight(v23, &v65, 0, 0);
                     v25 = v21->uY;
                     v21->uHeight = v24;
                     v26 = v25 + v24 - 1;
                     v21->uW = v26;
                     v68 = v26;
-                    v27 = v71;
+                    v27 = color2;
                     if ( pDialogueWindow->pCurrentPosActiveItem != v72 )
                       v27 = white;
-                    v65.DrawTitleText(pFontArrus, 0, v25, v27, (char *)HIDWORD(v66), 3u);
+                    v65.DrawTitleText(pFontArrus, 0, v25, v27, v23, 3u);
                   }
                   v28 = v13->pStartingPosActiveItem;
-                  ++i;
+                  ++_v1;
                   result = v13->pNumPresenceButton + v28;
                   ++v72;
                 }
-                while ( (signed int)i < result );
+                while ( (signed int)_v1 < result );
               }
             }
             else
@@ -4029,7 +4031,7 @@
                                                 // "Seek knowledge elsewhere %s the %s"
               strcat(pTmpBuf, "\n \n");
               strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further."
-              v29 = v71;
+              v29 = color2;
               v30 = pFontArrus->CalcTextHeight(pTmpBuf, &v65, 0, 0);
               result = (int)v65.DrawTitleText(pFontArrus, 0, (174 - v30) / 2 + 138, v29, pTmpBuf, 3u);
             }
@@ -4040,7 +4042,7 @@
       if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
       {
         v31 = pNPCTopics[122].pText;
-        v32 = v71;
+        v32 = color2;
         v33 = pFontArrus->CalcTextHeight(pNPCTopics[122].pText, &v65, 0, 0);
         v65.DrawTitleText(pFontArrus, 0, (212 - v33) / 2 + 101, v32, v31, 3u);
         result = (int)pDialogueWindow;
@@ -4050,11 +4052,11 @@
       v34 = v0->uLevel;
       if ( v34 < v68 )
       {
-        if ( (signed __int64)v0->uExperience >= v66 )
+        if ( (signed __int64)v0->uExperience >= v5 )
         {
-          if ( pParty->uNumGold >= i )
+          if ( pParty->uNumGold >= v11)
           {
-            Party::TakeGold(i);
+            Party::TakeGold(v11);
             HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
             ++v0->uLevel;
             v0->uSkillPoints += v0->uLevel / 10 + 5;
@@ -4083,7 +4085,7 @@
                 pOutdoor->SetFog();
             }
             v0->PlaySound(SPEECH_87, 0);
-            sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[430], v0->pName, v0->uLevel, v0->uLevel / 10 + 5);// 
+            sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[430], v0->pName, v0->uLevel, v0->uLevel / 10 + 5);// 
                                                 // "%s is now Level %lu and has earned %lu Skill Points!"
             ShowStatusBarString(pTmpBuf, 2u);
             goto LABEL_56;
@@ -4106,12 +4108,12 @@
           pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
           return 1; // void function actually
         }
-        sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[538], v5 - LODWORD(v0->uExperience), v34 + 1);// 
+        sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[538], (unsigned int)(v5 - v0->uExperience), v34 + 1);// 
                                                 // "You need %d more experience to train to level %d"
         v35 = 0;
         v62 = 3;
         v60 = pTmpBuf;
-        v58 = v71;
+        v58 = color2;
         v36 = (212 - pFontArrus->CalcTextHeight(pTmpBuf, &v65, 0, 0)) / 2 + 88;
       }
       else
@@ -4122,7 +4124,7 @@
         v35 = 0;
         v62 = 3;
         v60 = pTmpBuf;
-        v58 = v71;
+        v58 = color2;
         v36 = (212 - pFontArrus->CalcTextHeight(pTmpBuf, &v65, 0, 0)) / 2 + 101;
       }
       v65.DrawTitleText(pFontArrus, v35, v36, v58, v60, v62);
@@ -4148,7 +4150,7 @@
             v46 = v0->uLevel;
             if ( v46 < v68 )
             {
-              if ( (signed __int64)v0->uExperience < v66 )
+              if ( (signed __int64)v0->uExperience < v5 )
               {
                 v64 = (char *)(v46 + 1);
                 v61 = (char *)(v5 - LODWORD(v0->uExperience));
@@ -4156,7 +4158,7 @@
               }
               else
               {
-                v64 = (char *)i;
+                v64 = (char *)v11;
                 v61 = (char *)(v46 + 1);
                 v59 = pGlobalTXT_LocalizationStrings[537];// "Train to level %d for %d gold"
               }
@@ -4167,7 +4169,7 @@
               v61 = pGlobalTXT_LocalizationStrings[536];// ""With your skills, you should be working here as a teacher.""
               v59 = "%s\n \n%s";
             }
-            sprintf(*v45, v59, v61, v64);
+            sprintfex(*v45, v59, v61, v64);
           }
           v47 = pFontArrus->CalcTextHeight(*v45, &v65, 0, 0);
           v43 = pDialogueWindow;
@@ -4177,7 +4179,7 @@
         }
         while ( v73 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
       }
-      HIDWORD(v66) = (174 - v72) / 2;
+      //HIDWORD(v66) = (174 - v72) / 2;
       result = v43->pStartingPosActiveItem;
       v48 = result + v43->pNumPresenceButton;
       v49 = (2 * (87 - (174 - v72) / 2) - v72) / 2 - (174 - v72) / 2 / 2 + 138;
@@ -4185,25 +4187,25 @@
       v73 = v43->pStartingPosActiveItem;
       if ( v50 ^ __OFSUB__(result, v48) )
       {
-        i = 2;
+        int _v3 = 2;
         v51 = pShopOptions;
         do
         {
           v52 = v43->GetControl(v73);
           v53 = v52;
-          v52->uY = HIDWORD(v66) + v49;
+          v52->uY = (174 - v72) / 2 + v49;
           v54 = pFontArrus->CalcTextHeight(*v51, &v65, 0, 0);
           v55 = v53->uY;
           v53->uHeight = v54;
           v56 = v54 + v55 - 1;
           v53->uW = v56;
           v49 = v56;
-          v57 = v71;
-          if ( pDialogueWindow->pCurrentPosActiveItem != i )
+          v57 = color2;
+          if ( pDialogueWindow->pCurrentPosActiveItem != _v3 )
             v57 = white;
           v65.DrawTitleText(pFontArrus, 0, v55, v57, *v51, 3u);
           v43 = pDialogueWindow;
-          ++i;
+          ++_v3;
           ++v51;
           ++v73;
           result = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;