changeset 494:af286cec8967

guild ..
author Gloval
date Thu, 28 Feb 2013 18:18:52 +0400
parents 59649750a054
children 90fdb47bfcba
files mm7_4.cpp mm7_data.h
diffstat 2 files changed, 77 insertions(+), 93 deletions(-) [+]
line wrap: on
line diff
--- a/mm7_4.cpp	Thu Feb 28 01:39:18 2013 +0400
+++ b/mm7_4.cpp	Thu Feb 28 18:18:52 2013 +0400
@@ -12273,11 +12273,11 @@
 
 
 //----- (004B5D7C) --------------------------------------------------------
-int __cdecl GuildDialog()
+void GuildDialog()
 {
   GUIWindow *v0; // ebx@1
   Player *v1; // edi@1
-  signed int v2; // ebx@1
+  signed int base_teach_price; // ebx@1
   int v3; // edi@6
   int result; // eax@11
   unsigned int v5; // ebx@13
@@ -12286,7 +12286,7 @@
   int v8; // esi@22
   signed int v9; // ecx@22
   char *v10; // eax@22
-  const char *v11; // ecx@26
+  const char *statusbar_string; // ecx@26
   POINT *v12; // esi@30
   int v13; // ecx@30
   void *v14; // ST1C_4@31
@@ -12327,12 +12327,12 @@
   char v49[100]; // [sp+19Ch] [bp-150h]@3
   POINT v50; // [sp+264h] [bp-88h]@30
   POINT v51; // [sp+26Ch] [bp-80h]@30
-  GUIWindow v52; // [sp+274h] [bp-78h]@1
+  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 v56; // [sp+2CCh] [bp-20h]@1
-  int v57; // [sp+2D0h] [bp-1Ch]@1
+  int main_text_color; // [sp+2CCh] [bp-20h]@1
+  int hi_text_color; // [sp+2D0h] [bp-1Ch]@1
   Player *v58; // [sp+2D4h] [bp-18h]@1
   unsigned __int8 uPlayerID; // [sp+2DBh] [bp-11h]@31
   char *Str; // [sp+2DCh] [bp-10h]@35
@@ -12341,19 +12341,19 @@
   int v63; // [sp+2E8h] [bp-4h]@1
 
   v0 = window_SpeakInHouse;
-  memcpy(&v52, window_SpeakInHouse, sizeof(v52));
+  memcpy(&working_window, window_SpeakInHouse, sizeof(GUIWindow));
   v58 = pPlayers[uActiveCharacter];
   v1 = v58;
-  v52.uFrameX = 483;
+  working_window.uFrameX = 483;
   v53 = 148;
   v54 = 334;
-  v56 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  v57 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  main_text_color = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+  hi_text_color = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
   //v2 = (signed __int64)(p2DEvents_minus1__20[13 * (unsigned int)v0->ptr_1C] * 500.0);
-  v2 = (signed __int64)(p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier * 500.0);
-  v63 = v2 * (100 - v1->GetMerchant()) / 100;
-  if ( v63 < v2 / 3 )
-    v63 = v2 / 3;
+  base_teach_price = (signed __int64)(p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier * 500.0);
+  v63 = base_teach_price * (100 - v1->GetMerchant()) / 100;
+  if ( v63 < base_teach_price / 3 )
+    v63 = base_teach_price / 3;
   strcpy(Dest, "");
   strcpy(v46, "");
   strcpy(v47, "");
@@ -12361,14 +12361,14 @@
   strcpy(v49, "");
   if ( dword_F8B19C != 1 )
   {
-    if ( dword_F8B19C != 18 )
+    if ( dword_F8B19C != 18 ) //buy skill
     {
       if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
       {
-        v3 = (int)(&v1->uIntelligence + dword_F8B19C);
+        v3 = (int)(&v1->uIntelligence + dword_F8B19C); //test skill
         if ( *(short *)v3 )
         {
-          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[403], pClassNames[dword_F8B19C + 20]);
+          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[403], pClassNames[dword_F8B19C + 20]); //"You already know the %s skill"
           ShowStatusBarString(pTmpBuf, 2u);
           pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
         }
@@ -12376,7 +12376,7 @@
         {
           if ( pParty->uNumGold < v63 )
           {
-            ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
+            ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); //"You don't have enough gold"
             HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
           }
           else
@@ -12386,17 +12386,8 @@
           }
         }
       }
-      /*result = pMessageQueue_50CBD0->uNumMessages;
-      if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-      {
-        pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
-        pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
-        result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
-        *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
-        ++pMessageQueue_50CBD0->uNumMessages;
-      }*/
       pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-      return 1; // void function actually
+      return;
     }
     pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
     v5 = 0;
@@ -12416,6 +12407,7 @@
       ++v6;
     }
     while ( v63 < 452 );
+
     v62 = 1680;
     v7 = 6;
     v63 = 32;
@@ -12432,8 +12424,8 @@
       ++v7;
     }
     while ( v63 < 452 );
-    result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-    if ( result )
+
+    if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
     {
       v8 = 0;
       v9 = 12;
@@ -12446,19 +12438,20 @@
         --v9;
       }
       while ( v9 );
+
       GetAsyncKeyState(17);
-      v11 = pGlobalTXT_LocalizationStrings[195];
+      statusbar_string = pGlobalTXT_LocalizationStrings[195]; //"Select the Item to Buy"
       if ( dword_F8B19C != 2 )
-        v11 = pGlobalTXT_LocalizationStrings[196];
-      DrawTextAtStatusBar(v11, 0);
+        statusbar_string = pGlobalTXT_LocalizationStrings[196]; //"Select the Special Item to Buy"	
+      DrawTextAtStatusBar(statusbar_string, 0);
       if ( !v8 )
 		  {
-        v52.DrawCurrentTime(
+        working_window.DrawCurrentTime(
                       __PAIR__(
                         *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)window_SpeakInHouse->ptr_1C + 44472],
                         *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)window_SpeakInHouse->ptr_1C + 44468])
                     - pParty->uTimePlayed);
-		return 0;
+		return;
 		  }
       v12 = pMouse->GetCursorPos(&v51);
       result = v12->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v50)->y];
@@ -12469,40 +12462,29 @@
         v15 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v13 + 12 * (int)v14));
         v16 = (int)window_SpeakInHouse->ptr_1C;
         uPlayerID = uActiveCharacter - 1;
-        v17 = v1->_490EEE(
-                (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14,
-                3,
-                v16,
-                2);
-        v18 = BuilDialogueString((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0);
-        v44 = 3;
-        v43 = v18;
-        v42 = v56;
-        v41 = 0;
-        v40 = 0;
-        v39 = &v52;
-LABEL_32:
-        v19 = pFontArrus->CalcTextHeight(v18, v39, v40, v41);
-        return (int)v52.DrawTitleText(pFontArrus, v5, (174 - v19) / 2 + 138, v42, v43, v44);
-      }
-    }
-    return result;
+        v17 = v1->_490EEE( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14, 3, v16,  2);
+        v18 = BuilDialogueString((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0);     
+        v19 = pFontArrus->CalcTextHeight(v18, &working_window, 0, 0);
+        working_window.DrawTitleText(pFontArrus, v5, (174 - v19) / 2 + 138,  main_text_color, v18, 3);
+        return;
+      }
+    }
+    return;
   }
   if ( !(unsigned __int16)_449B57_test_bit(
                             (unsigned __int8 *)v1->_guilds_member_bits,
                             word_4F0704[(unsigned int)window_SpeakInHouse->ptr_1C-139]) )
-  {
+  { //you must me member
     v36 = pNPCTopics[121].pText;
-    v37 = v57;
-    v38 = pFontArrus->CalcTextHeight(pNPCTopics[121].pText, &v52, 0, 0);
-    v52.DrawTitleText(pFontArrus, 0, (212 - v38) / 2 + 101, v37, v36, 3u);
-    result = (int)pDialogueWindow;
+    v37 = hi_text_color;
+    v38 = pFontArrus->CalcTextHeight(pNPCTopics[121].pText, &working_window, 0, 0);
+    working_window.DrawTitleText(pFontArrus, 0, (212 - v38) / 2 + 101, v37, v36, 3u);
     pDialogueWindow->pNumPresenceButton = 0;
-    return result;
-  }
-  result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-  if ( !result )
-    return result;
+    return;
+  }
+
+  if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
+    return;
   v20 = pDialogueWindow;
   v5 = 0;
   v62 = 0;
@@ -12511,13 +12493,18 @@
   v22 = v21 + pDialogueWindow->pNumPresenceButton;
   v61 = 0;
   if ( v21 >= v22 )
-    goto LABEL_64;
+	  sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); // "Seek knowledge elsewhere %s the %s"	
+	strcat(pTmpBuf, "\n \n");
+	strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further."
+	v19 = pFontArrus->CalcTextHeight(pTmpBuf, &working_window, 0, 0);
+	working_window.DrawTitleText(pFontArrus, v5, (174 - v19) / 2 + 138, hi_text_color, pTmpBuf, 3);
+	return;
   do
   {
     v23 = v20->GetControl(v21)->uControlParam;
     if ( v23 == 18 )
     {
-      v25 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[400], &v52, 0, 0);
+      v25 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[400], &working_window, 0, 0); //"Buy Spells"
       v62 += v25;
       ++v61;
     }
@@ -12532,7 +12519,7 @@
 
       //if ( *(&byte_4ED94C[37 * v58->uClass] + v23) && !*(&v58->uIntelligence + v23) )
       {
-        v24 = pFontArrus->CalcTextHeight(pClassNames[v23 + 20], &v52, 0, 0);
+        v24 = pFontArrus->CalcTextHeight(pClassNames[v23 + 20], &working_window, 0, 0);
         v62 += v24;
         ++v61;
         ++Str;
@@ -12544,31 +12531,25 @@
   if ( !v61 )
   {
 LABEL_64:
-    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v58->pName, pClassNames[v58->classType]);
+    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v58->pName, pClassNames[v58->classType]); // "Seek knowledge elsewhere %s the %s"	
     strcat(pTmpBuf, "\n \n");
-    strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
-    v18 = pTmpBuf;
-    v44 = 3;
-    v43 = pTmpBuf;
-    v42 = v57;
-    v41 = 0;
-    v40 = 0;
-    v39 = &v52;
-    goto LABEL_32;
+    strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further."
+	v19 = pFontArrus->CalcTextHeight(pTmpBuf, &working_window, 0, 0);
+	working_window.DrawTitleText(pFontArrus, v5, (174 - v19) / 2 + 138, hi_text_color, pTmpBuf, 3);
+	return;
   }
   if ( Str )
   {
-    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v63);
-    v52.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
+    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v63); //"Skill Cost: %lu"
+    working_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
   }
   v63 = (signed int)(149 - v62) / v61;
   if ( v63 > 32 )
     v63 = 32;
-  result = v20->pStartingPosActiveItem;
   v26 = (signed int)(149 - v61 * v63 - v62) / 2 - v63 / 2 + 162;
-  v62 = result;
+  v62 = v20->pStartingPosActiveItem;
   v55 = v26;
-  if ( result < result + v20->pNumPresenceButton )
+  if (v20->pStartingPosActiveItem < v20->pStartingPosActiveItem + v20->pNumPresenceButton )
   {
     v61 = 2;
     while ( 1 )
@@ -12592,17 +12573,21 @@
 LABEL_55:
         Str = v30;
         v28->uY = v63 + v55;
-        v31 = pFontArrus->CalcTextHeight(v30, &v52, 0, 0);
+        v31 = pFontArrus->CalcTextHeight(v30, &working_window, 0, 0);
         v32 = v28->uY;
         v28->uHeight = v31;
         v33 = v32 + v31 - 1;
         v28->uW = v33;
         v55 = v33;
-        v34 = v57;
+        v34 = hi_text_color;
         if ( pDialogueWindow->pCurrentPosActiveItem != v61 )
-          v34 = v56;
-        v52.DrawTitleText(pFontArrus, 0, v32, v34, Str, 3u);
-        goto LABEL_58;
+          v34 = main_text_color;
+        working_window.DrawTitleText(pFontArrus, 0, v32, v34, Str, 3u);
+		v35 = v20->pStartingPosActiveItem;
+		++v62;
+		++v61;
+		if ( (signed int)v62 >=v20->pNumPresenceButton +v20->pStartingPosActiveItem  )
+			return;
       }
       v28->uW = 0;
       v28->uHeight = 0;
@@ -12610,15 +12595,14 @@
 LABEL_58:
       v35 = v20->pStartingPosActiveItem;
       ++v62;
-      result = v20->pNumPresenceButton + v35;
       ++v61;
-      if ( (signed int)v62 >= result )
-        return result;
-    }
-    v30 = pGlobalTXT_LocalizationStrings[400];
+      if ( (signed int)v62 >=v20->pNumPresenceButton +v20->pStartingPosActiveItem  )
+        return;
+    }
+    v30 = pGlobalTXT_LocalizationStrings[400]; //"Buy Spells"
     goto LABEL_55;
   }
-  return result;
+  return;
 }
 
 
--- a/mm7_data.h	Thu Feb 28 01:39:18 2013 +0400
+++ b/mm7_data.h	Thu Feb 28 18:18:52 2013 +0400
@@ -2322,7 +2322,7 @@
 int __cdecl TrainingDialog();
 char *__cdecl JailDialog();
 int __cdecl MagicShopDialog();
-int __cdecl GuildDialog();
+void  GuildDialog();
 int __cdecl sub_4B6478();
 bool __fastcall sub_4B68EA(int a1);
 void __cdecl TravelByTransport();