diff UIHouses.cpp @ 893:4676774b225c

GuildDialogue fix
author Ritor1
date Wed, 03 Apr 2013 14:27:43 +0600
parents b6573b99ca40
children 10fa7dad1391 addae461eeb4
line wrap: on
line diff
--- a/UIHouses.cpp	Wed Apr 03 10:01:53 2013 +0600
+++ b/UIHouses.cpp	Wed Apr 03 14:27:43 2013 +0600
@@ -666,7 +666,7 @@
   signed int v32; // edi@209
   int v33; // eax@210
   unsigned int v34; // eax@211
-  Player *v35; // edi@227
+  //Player *v35; // edi@227
   signed int v36; // esi@227
   int v37; // ecx@227
   int v38; // esi@230
@@ -783,9 +783,8 @@
 	case 15:
 	case 16:
 		{
-        if ( (signed __int64)__PAIR__(
-                                *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472],
-                                *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44468]) >= (signed __int64)pParty->uTimePlayed )
+        if ( *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472] >= (signed __int64)pParty->uTimePlayed &&
+            *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44468] >= (signed __int64)pParty->uTimePlayed )
         {
 			v32 = 0;
 			do
@@ -814,7 +813,7 @@
 			*(int *)&stru_AA1058[3].pSounds[8 * (int)v30 + 44468] = v31;
 			*(int *)&stru_AA1058[3].pSounds[8 * (int)v30 + 44472] = HIDWORD(v31);
         }
-        return;
+        //return;
 		break;
 		}
 	case 17:
@@ -824,7 +823,8 @@
 			v10 = (int)((char *)v8->ptr_1C - 102);
 			v56 = v10;
 			v11 = 8 * v10 + 11325428;
-			if ( (signed __int64)__PAIR__(pParty->field_3C.field_0[2 * v10 + 1], pParty->field_3C.field_0[2 * v10]) >= (signed __int64)pParty->uTimePlayed )
+			if ( pParty->field_3C.field_0[2 * v10 + 1] >= (signed __int64)pParty->uTimePlayed
+			     && pParty->field_3C.field_0[2 * v10] >= (signed __int64)pParty->uTimePlayed )
 			{
 				v13 = 0;
 			}
@@ -1477,7 +1477,7 @@
 		{
 		if( uMessageParam >= 36 && uMessageParam <= 72 )
 		{
-			v35 = pPlayers[uActiveCharacter];
+			//v35 = pPlayers[uActiveCharacter];
 			//v36 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)v8->ptr_1C] * 500.0);
 			v36 = (signed __int64)(p2DEvents[(unsigned int)v8->ptr_1C - 1].flt_24 * 500.0);
 			v37 = v36 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
@@ -1485,15 +1485,15 @@
 			v37 = v36 / 3;
 
 			//if (false)
-			if(byte_4ED970_skill_learn_ability_by_class_table[v35->classType][uMessageParam-36])
+			if(byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][uMessageParam-36])
 			//if ( *(&byte_4ED94C[37 * v35->uClass] + v55) )
 			{
-			v38 = (int)(&v35->uIntelligence + uMessageParam);
-			if ( !*(short *)v38 )
+			//v38 = (int)(&pPlayers[uActiveCharacter]->uIntelligence + uMessageParam);
+			if ( !pPlayers[uActiveCharacter]->pActiveSkills[uMessageParam - 36] )
 			{
 				if ( pParty->uNumGold < v37 )
 				{
-				ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
+				ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);
 				if ( in_current_building_type == BildingType_Training || in_current_building_type == BildingType_Tavern )
 					v39 = 4;
 				else
@@ -1504,8 +1504,8 @@
 				{
 				Party::TakeGold(v37);
 				dword_F8B1E4 = 1;
-				*(short *)v38 = 1;
-				v35->PlaySound(SPEECH_78, 0);
+				pPlayers[uActiveCharacter]->pActiveSkills[uMessageParam - 36] = 1;
+				pPlayers[uActiveCharacter]->PlaySound(SPEECH_78, 0);
 				}
 			}
 			}
@@ -4594,84 +4594,73 @@
 //----- (004B5D7C) --------------------------------------------------------
 void GuildDialog()
 {
-  //GUIWindow *pWindow; // ebx@1
-        //Player *currPlayer; // edi@1
-        signed int base_teach_price; // ebx@1
-        int v3; // edi@6
-        int result; // eax@11
-        //unsigned int v5; // ebx@13
-        int v6; // esi@13
-        signed int v7; // esi@17
-        int v8; // esi@22
-        signed int v9; // ecx@22
-        char *v10; // eax@22
-        const char *statusbar_string; // ecx@26
-        POINT *v12; // esi@30
-        int v13; // ecx@30
-        void *v14; // ST1C_4@31
-        ItemGen *v15; // ST18_4@31
-        int v16; // ST10_4@31
-        int v17; // eax@31
-        char *v18; // edx@31
-        int v19; // eax@32
-        //GUIWindow *v20; // edi@35
-        int pActiveItem; // esi@35
-        int v22; // eax@35
-        unsigned int v23; // eax@36
-        int v24; // eax@39
-        int v25; // eax@40
-        int v26; // ecx@47
-        GUIButton *pButton; // eax@49
-        //GUIButton *v28; // esi@49
-        unsigned int v29; // eax@49
-        char *pText; // eax@52
-        int pTextHeight; // eax@55
-        unsigned int v32; // ecx@55
-        int v33; // eax@55
-        unsigned __int16 pTextColor; // ax@55
-        int v35; // eax@58
-        const char *v36; // ST20_4@61
-        unsigned __int16 v37; // ST1C_2@61
-        int v38; // eax@61
-        GUIWindow *v39; // [sp-18h] [bp-304h]@31
-        int v40; // [sp-14h] [bp-300h]@31
-        int v41; // [sp-10h] [bp-2FCh]@31
-        unsigned __int16 v42; // [sp-Ch] [bp-2F8h]@31
-        char *v43; // [sp-8h] [bp-2F4h]@31
-        unsigned int v44; // [sp-4h] [bp-2F0h]@31
-        char Dest[100]; // [sp+Ch] [bp-2E0h]@3
-        char v46[100]; // [sp+70h] [bp-27Ch]@3
-        char v47[100]; // [sp+D4h] [bp-218h]@3
-        char v48[100]; // [sp+138h] [bp-1B4h]@3
-        char v49[100]; // [sp+19Ch] [bp-150h]@3
-        POINT v50; // [sp+264h] [bp-88h]@30
-        POINT v51; // [sp+26Ch] [bp-80h]@30
-        GUIWindow working_window; // [sp+274h] [bp-78h]@1
-        signed int v53; // [sp+27Ch] [bp-70h]@1
-        signed int v54; // [sp+284h] [bp-68h]@1
-        //int v55; // [sp+2C8h] [bp-24h]@47
-        int pColorWhite; // [sp+2CCh] [bp-20h]@1
-        int pColorYellow; // [sp+2D0h] [bp-1Ch]@1
-        int v58; // [sp+2D4h] [bp-18h]@1
-        unsigned __int8 uPlayerID; // [sp+2DBh] [bp-11h]@31
+  signed int base_teach_price; // ebx@1
+  int v3; // edi@6
+  int result; // eax@11
+  int v6; // esi@13
+  signed int v7; // esi@17
+  int v8; // esi@22
+  signed int v9; // ecx@22
+  char *v10; // eax@22
+  const char *statusbar_string; // ecx@26
+  POINT *v12; // esi@30
+  int v13; // ecx@30
+  void *v14; // ST1C_4@31
+  ItemGen *v15; // ST18_4@31
+  int v16; // ST10_4@31
+  int v17; // eax@31
+  char *v18; // edx@31
+  int v19; // eax@32
+  int pActiveItem; // esi@35
+  int v22; // eax@35
+  unsigned int v23; // eax@36
+  int v24; // eax@39
+  int v25; // eax@40
+  int v26; // ecx@47
+  GUIButton *pButton; // eax@49
+  unsigned int v29; // eax@49
+  char *pText; // eax@52
+  int pTextHeight; // eax@55
+  unsigned int v32; // ecx@55
+  int v33; // eax@55
+  unsigned __int16 pTextColor; // ax@55
+  int v35; // eax@58
+  const char *v36; // ST20_4@61
+  unsigned __int16 v37; // ST1C_2@61
+  int v38; // eax@61
+  int v40; // [sp-14h] [bp-300h]@31
+  int v41; // [sp-10h] [bp-2FCh]@31
+  unsigned __int16 v42; // [sp-Ch] [bp-2F8h]@31
+  char *v43; // [sp-8h] [bp-2F4h]@31
+  unsigned int v44; // [sp-4h] [bp-2F0h]@31
+  char Dest[100]; // [sp+Ch] [bp-2E0h]@3
+  char v46[100]; // [sp+70h] [bp-27Ch]@3
+  char v47[100]; // [sp+D4h] [bp-218h]@3
+  char v48[100]; // [sp+138h] [bp-1B4h]@3
+  char v49[100]; // [sp+19Ch] [bp-150h]@3
+  POINT v50; // [sp+264h] [bp-88h]@30
+  POINT v51; // [sp+26Ch] [bp-80h]@30
+  GUIWindow working_window; // [sp+274h] [bp-78h]@1
+  signed int v53; // [sp+27Ch] [bp-70h]@1
+  signed int v54; // [sp+284h] [bp-68h]@1
+  int pColorWhite; // [sp+2CCh] [bp-20h]@1
+  int pColorYellow; // [sp+2D0h] [bp-1Ch]@1
+  int v58; // [sp+2D4h] [bp-18h]@1
+  unsigned __int8 uPlayerID; // [sp+2DBh] [bp-11h]@31
   bool pSkillFlag; // [sp+2DCh] [bp-10h]@35
-        int v61; // [sp+2E0h] [bp-Ch]@35
+  int v61; // [sp+2E0h] [bp-Ch]@35
   int pItemNum;
-        unsigned int v62; // [sp+2E4h] [bp-8h]@13
-        int v63; // [sp+2E8h] [bp-4h]@1
+  unsigned int v62; // [sp+2E4h] [bp-8h]@13
+  int v63; // [sp+2E8h] [bp-4h]@1
   int pNumActivItem;
   int all_text_height;
 
-  //pWindow = window_SpeakInHouse;//Ritor1: in process
   memcpy(&working_window, window_SpeakInHouse, sizeof(GUIWindow));
-  //v58 = pPlayers[uActiveCharacter];
-  //currPlayer = pPlayers[uActiveCharacter];
   working_window.uFrameX = 483;
   working_window.uFrameWidth = 148;
   working_window.uFrameZ = 334;
   pColorWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
   pColorYellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-  //v2 = (signed __int64)(p2DEvents_minus1__20[13 * (unsigned int)v0->ptr_1C] * 500.0);
   base_teach_price = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier * 500.0);
   v63 = base_teach_price * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
   if ( v63 < base_teach_price / 3 )
@@ -4712,7 +4701,6 @@
       return;
     }
     pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
-    //v5 = 0;
     v6 = 0;
     v62 = 0;
     v63 = 32;
@@ -4736,11 +4724,9 @@
     do
     {
       if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v7].uItemID)
-                 // if ( *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v7 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)) )
       {
         pRenderer->DrawTextureTransparent(v63, 0xFAu, ItemsInShopTexture[v7]);
         ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 638448), ItemsInShopTexture[v7], v7 + 1);
-           //currPlayer = v58;
       }
       v63 += 70;
       v62 += 280;
@@ -4751,13 +4737,10 @@
     {
       v8 = 0;
       v9 = 12;
-                       // v10 = (char *)(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 108 * (unsigned int)window_SpeakInHouse->ptr_1C);
-                       //  v10 =
       do
       {
         if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v9].uItemID )
           ++v8;
-                           // v10 += 36;
         --v9;
       }
       while ( v9 );
@@ -4800,8 +4783,6 @@
   }
   if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
     return;
-  //v20 = pDialogueWindow;
-  //v5 = 0;
   v61 = 0;
   pSkillFlag = false;
   pActiveItem = pDialogueWindow->pStartingPosActiveItem;
@@ -4827,13 +4808,8 @@
     }
     else
     {
-      if( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v23-36] && pPlayers[uActiveCharacter]->pActiveSkills[v23-36] )
-      {
-        all_text_height += pFontArrus->CalcTextHeight(pSkillNames[v23 - 36], &working_window, 0, 0);
-        v61++;
-        pSkillFlag = true;
-      }
-      if( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v23 - 36] && !pPlayers[uActiveCharacter]->pActiveSkills[v23 - 36] )
+      if( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v23 - 36] 
+          && !pPlayers[uActiveCharacter]->pActiveSkills[v23 - 36] )
       {
         all_text_height += pFontArrus->CalcTextHeight(pSkillNames[v23 - 36], &working_window, 0, 0);
         v61++;
@@ -4862,14 +4838,12 @@
     v58 = 32;
   v26 = (149 - v61 * v58 - all_text_height) / 2 - v58 / 2 + 162;
   pNumActivItem = pDialogueWindow->pStartingPosActiveItem;
-  //v55 = v26;
   if (pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton )
   {
     pItemNum = 2;
     do
     {
       pButton = pDialogueWindow->GetControl(pItemNum);
-      //v28 = v27;
       v29 = pButton->msg_param;
       if ( v29 == 18 )
       {
@@ -4888,7 +4862,8 @@
       }
       else
       {
-        if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v29 - 36] && !pPlayers[uActiveCharacter]->pActiveSkills[v23-36] )
+        if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v29 - 36] 
+             && !pPlayers[uActiveCharacter]->pActiveSkills[v29 - 36] )
         {
           pButton->uY = v58 + v26;
           pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v29 - 36], &working_window, 0, 0);
@@ -4902,13 +4877,13 @@
             pTextColor = pColorWhite;
           working_window.DrawTitleText(pFontArrus, 0, v32, pTextColor, pSkillNames[v29 - 36], 3);
         }
-		else
-		{
+        else
+        {
           pButton->uW = 0;
           pButton->uHeight = 0;
           pButton->uY = 0;
-		}
-	  }
+        }
+      }
       ++pItemNum;
     }
     while ( pItemNum < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );