changeset 496:0e20e886365d

guilds ....
author Gloval
date Fri, 01 Mar 2013 02:11:57 +0400
parents 90fdb47bfcba
children dd5124185551 d2a55c0a8dda
files Events.cpp GUIWindow.cpp GUIWindow.h Party.h mm7_2.cpp mm7_4.cpp mm7_data.cpp mm7_data.h
diffstat 8 files changed, 86 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/Events.cpp	Thu Feb 28 21:45:39 2013 +0400
+++ b/Events.cpp	Fri Mar 01 02:11:57 2013 +0400
@@ -1532,7 +1532,7 @@
 				//v7 = "";
 				break;
 			case EVENT_SpeakInHouse: 
-				if ( EnterHouse((enum HOUSE_ID)(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8))) )
+				if ( EnterHouse((enum HOUSE_ID)EVT_DWORD(_evt->v5)))
 					{
 					if ( pRenderer->pRenderD3D && !pRenderer->bWindowMode )
 						pRenderer->_49FD3A();
@@ -1542,10 +1542,10 @@
 					if ( uCurrentHouse_Animation != 167 )
 						v104 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
 					window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, v104, 0);
-					window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
-					window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
-					window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
-					window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
+					window_SpeakInHouse->CreateButton( 61, 424, 31, 0, 2, 94, 0x6Eu, 1, 49, "", 0);
+					window_SpeakInHouse->CreateButton(177, 424, 31, 0, 2, 94, 0x6Eu, 2, 50, "", 0);
+					window_SpeakInHouse->CreateButton(292, 424, 31, 0, 2, 94, 0x6Eu, 3, 51, "", 0);
+					window_SpeakInHouse->CreateButton(407, 424, 31, 0, 2, 94, 0x6Eu, 4, 52, "", 0);
 					window_SpeakInHouse->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
 					}
 				++curr_seq_num;
--- a/GUIWindow.cpp	Thu Feb 28 21:45:39 2013 +0400
+++ b/GUIWindow.cpp	Fri Mar 01 02:11:57 2013 +0400
@@ -403,7 +403,7 @@
   v1->pControlsTail = 0;
   v1->uNumControls = 0;
   v1->eWindowType = WINDOW_null;
-  v10 = v1->field_3C;
+  v10 = v1->numVisibleWindows;
   v11 = uNumVisibleWindows;
   while ( v10 < v11 )
   {
@@ -1778,9 +1778,9 @@
   pWindow->uFrameHeight = uHeight;
   pWindow->eWindowType = eWindowType;
   pWindow->field_44 = 0;
-  uNumVisibleWindows = v10;
-  pWindow->field_3C = v10;
-  pVisibleWindowsIdxs[v10] = uNextFreeWindowID + 1;
+  ++uNumVisibleWindows;
+  pWindow->numVisibleWindows = uNumVisibleWindows;
+  pVisibleWindowsIdxs[uNumVisibleWindows] = uNextFreeWindowID + 1;
   if ( (signed int)eWindowType <= 20 )
   {
     if (eWindowType != WINDOW_Chest)
@@ -1795,7 +1795,7 @@
           pCurrentScreen = SCREEN_NPC_DIALOGUE;
           pBtn_ExitCancel = pWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], //"Exit"
                          (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), 0);
-          if ( pWindow->ptr_1C != (void *)1 )
+          if ( pWindow->par1C != 1 )
           {
             num_menu_buttons = 0;
             v11 = LOBYTE(pFontArrus->uFontHeight) - 3;
--- a/GUIWindow.h	Thu Feb 28 21:45:39 2013 +0400
+++ b/GUIWindow.h	Fri Mar 01 02:11:57 2013 +0400
@@ -134,7 +134,10 @@
   unsigned int uFrameZ;
   unsigned int uFrameW;
   WindowType   eWindowType;
+  union{
   void *ptr_1C;
+  unsigned int par1C;
+	};
   unsigned int uNumControls;
   int field_24;
   int pNumPresenceButton; 
@@ -142,7 +145,7 @@
   int field_30;
   int field_34;
   int pStartingPosActiveItem;
-  int field_3C;
+  int numVisibleWindows;
   int field_40;
   int field_44;
   char *Hint;
--- a/Party.h	Thu Feb 28 21:45:39 2013 +0400
+++ b/Party.h	Fri Mar 01 02:11:57 2013 +0400
@@ -276,10 +276,11 @@
   unsigned int uFlags;
   ItemGen StandartItemsInShops[53][12];
   ItemGen SpecialItemsInShops[53][12];   //D0EC
-  int field_12A5C[2117];
-  char field_14B70[5000];
-  char field_15EF8[250];
-  char field_15FF2[130];
+  ItemGen SpellBooksInGuilds[32][12];
+  //int field_12A5C[2117];
+ // char field_14B70[5000];
+  //char field_15EF8[250];
+  //char field_15FF2[130];
   char pHireling1Name[100];
   char pHireling2Name[100];
   int armageddon_timer;
--- a/mm7_2.cpp	Thu Feb 28 21:45:39 2013 +0400
+++ b/mm7_2.cpp	Fri Mar 01 02:11:57 2013 +0400
@@ -1404,7 +1404,7 @@
       return result;
     }
   }
-  pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
+  pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
   v3 = 0;
   if ( dword_F8B19C == 2 )
   {
@@ -1944,7 +1944,7 @@
         return (POINT *)v104.DrawTitleText(pFontArrus, v3, (174 - v40) / 2 + 138, v88, v90, v92);
       }
     }
-    pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
+    pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
     v3 = 0;
     v114 = 0;
     if ( dword_F8B19C == 2 )
@@ -2378,7 +2378,7 @@
 		break;
 	case 2: //buy standart
 		{
-		pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
+		pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
 		v55 = 0;
 		v153 = 0;
 		for(int i=0; i<8; ++i)
@@ -2580,7 +2580,7 @@
 		break;
 	case 6:
 		{
-		pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
+		pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
 		DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[195], 0);
 		if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
 			return;
@@ -2709,7 +2709,7 @@
 	case 95:  //buy spesial
 		{
 
-		pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
+		pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
 
 		v11 = 0;
 		v61 = 0;
@@ -3608,10 +3608,10 @@
 
 
 //----- (004BC8D5) --------------------------------------------------------
-void sub_4BC8D5()
+void SpellBookGenerator()
 	{
   int v0; // esi@1
-  char *v1; // ebx@1
+  int v1; // ebx@1
   signed int v2; // edi@1
   signed int v3; // eax@2
   int v4; // esi@7
@@ -3620,12 +3620,12 @@
   int v7; // [sp+10h] [bp-4h]@0
 
  // v0 = v7;
-  v1 = (char *)window_SpeakInHouse->ptr_1C - 139;
+  v1 = window_SpeakInHouse->par1C - 139;
   v2 = 0;
-  do
+  for(int i=0; i<12; ++i) 
   {
     //v3 = p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C];
-    v3 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType;
+    v3 = p2DEvents[window_SpeakInHouse->par1C - 1].uType;
     if ( v3 < 5 )
       goto LABEL_12;
     if ( v3 <= 13 )
@@ -3664,13 +3664,14 @@
     }
     v5 = window_SpeakInHouse;
 
-    auto _u = (ItemGen *)&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + v2 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C;
+    ItemGen * _u = &pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i];
     _u->Reset();
-    *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v2 + 12 * (unsigned int)v5->ptr_1C)) = v0;
-    *(&pParty->pPlayers[1].pInstalledBeacons[1].field_10 + 9 * (v2++ + 12 * (unsigned int)v5->ptr_1C)) = 1;
-    *(&dword_F8B164 + v2) = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pItemsTable->pItems[v0].pIconName, TEXTURE_16BIT_PALETTE)];
-  }
-  while ( v2 < 12 );
+    pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].uItemID= v0;
+    pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].Identified();
+
+    ItemsInShopTexture[i] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pItemsTable->pItems[v0].pIconName, TEXTURE_16BIT_PALETTE)];
+  }
+ 
   return;
 }
 
@@ -3804,7 +3805,7 @@
   {
     v9 = pIcons_LOD->LoadTexture(off_4F03B8[in_current_building_type], TEXTURE_16BIT_PALETTE);
     //v3 = dword_F8B198;
-    dword_F8B164 = &pIcons_LOD->pTextures[v9];
+    ShopTexture = &pIcons_LOD->pTextures[v9];
 LABEL_13:
     v8 = window_SpeakInHouse;
   }
@@ -3836,7 +3837,8 @@
             v32 = 0;
             do
             {
-              v33 = *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v32 + 12 * (unsigned int)v8->ptr_1C));
+              //v33 = *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v32 + 12 * (unsigned int)v8->ptr_1C));
+				v33 = pParty->SpellBooksInGuilds[v8->par1C-139][v32].uItemID;
               if ( v33 )
               {
                 v34 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v33].pIconName, TEXTURE_16BIT_PALETTE);
@@ -3849,7 +3851,7 @@
           }
           else
           {
-            sub_4BC8D5();
+            SpellBookGenerator();
             v30 = window_SpeakInHouse->ptr_1C;
             v31 = pParty->uTimePlayed
                 + (signed __int64)((double)(0xA8C000
@@ -4312,11 +4314,11 @@
       && dword_F8B19C != 97
       && dword_F8B19C != 5
       && dword_F8B19C != 4
-      && dword_F8B164 )
-    {
-      dword_F8B164->Release();
+      && ShopTexture )
+    {
+      ShopTexture->Release();
       v0 = dword_F8B19C;
-      dword_F8B164 = 0;
+      ShopTexture = 0;
     }
     if ( v0 && v0 != 1 )
     {
--- a/mm7_4.cpp	Thu Feb 28 21:45:39 2013 +0400
+++ b/mm7_4.cpp	Fri Mar 01 02:11:57 2013 +0400
@@ -11719,7 +11719,7 @@
       return (int)v112.DrawTitleText(pFontArrus, v3, v6, v92, v95, v97);
     }
   }
-  pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
+  pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
   v3 = 0;
   v49 = 0;
   v122 = 0;
@@ -12339,8 +12339,8 @@
   v58 = pPlayers[uActiveCharacter];
   currPlayer = v58;
   working_window.uFrameX = 483;
-  v53 = 148;
-  v54 = 334;
+  working_window.uFrameWidth = 148;
+  working_window.uFrameZ = 334;
   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);
@@ -12359,10 +12359,10 @@
     {
       if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
       {
-        v3 = (int)(&currPlayer->uIntelligence + dword_F8B19C); //test skill
-        if ( *(short *)v3 )
-        {
-          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[403], pClassNames[dword_F8B19C + 20]); //"You already know the %s skill"
+        //v3 = (int)(&currPlayer->uIntelligence + dword_F8B19C); //test skill
+        if ( v58->pActiveSkills[dword_F8B19C-36] )
+        {
+          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[403], pClassNames[dword_F8B19C - 16]); //"You already know the %s skill"
           ShowStatusBarString(pTmpBuf, 2u);
           pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
         }
@@ -12376,21 +12376,23 @@
           else
           {
             Party::TakeGold(v63);
-            *(short *)v3 = 1;
+            v58->pActiveSkills[dword_F8B19C-36] = 1;
           }
         }
       }
       pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
       return;
     }
-    pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
+    pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
     v5 = 0;
     v6 = 0;
     v62 = 0;
     v63 = 32;
     do
     {
-      if ( *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v6 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)) )
+		if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v6].uItemID)
+     // if ( *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v6 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)) )
+	  
       {
         pRenderer->DrawTextureTransparent(v63, 0x5Au, ItemsInShopTexture[v6]);
         ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 230528), ItemsInShopTexture[v6], v6 + 1);
@@ -12407,7 +12409,8 @@
     v63 = 32;
     do
     {
-      if ( *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v7 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)) )
+	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);
@@ -12423,12 +12426,13 @@
     {
       v8 = 0;
       v9 = 12;
-      v10 = (char *)(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 108 * (unsigned int)window_SpeakInHouse->ptr_1C);
+     // v10 = (char *)(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 108 * (unsigned int)window_SpeakInHouse->ptr_1C);
+	//  v10 =
       do
       {
-        if ( *(int *)v10 )
+        if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v9].uItemID )
           ++v8;
-        v10 += 36;
+       // v10 += 36;
         --v9;
       }
       while ( v9 );
@@ -12484,13 +12488,15 @@
   v21 = pDialogueWindow->pStartingPosActiveItem;
   v22 = v21 + pDialogueWindow->pNumPresenceButton;
   v61 = 0;
-  if ( v21 >= v22 )
+  if ( pDialogueWindow->pStartingPosActiveItem >= pDialogueWindow->pStartingPosActiveItem+pDialogueWindow->pNumPresenceButton )
+	  {
 	  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;
@@ -12502,16 +12508,12 @@
     }
     else
     {
-      __debugbreak();
-      //pSkillAvailabilityPerClass[8 + v58->uClass][4 + v23]
-      // or
-      //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass][v23 - 36]
+     
+     if((byte_4ED970_skill_learn_ability_by_class_table[v58->classType][v23-36])&&(v58->pActiveSkills[v23-36]))
       // or
       //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass - 1][v23 + 1]
-
-      //if ( *(&byte_4ED94C[37 * v58->uClass] + v23) && !*(&v58->uIntelligence + v23) )
-      {
-        v24 = pFontArrus->CalcTextHeight(pClassNames[v23 + 20], &working_window, 0, 0);
+      {
+        v24 = pFontArrus->CalcTextHeight(pClassNames[v23 - 16], &working_window, 0, 0);
         v62 += v24;
         ++v61;
         ++Str;
@@ -12552,16 +12554,15 @@
       if ( v29 == 18 )
         break;
 
-      __debugbreak();
+    //  __debugbreak();
       //pSkillAvailabilityPerClass[8 + v58->uClass][4 + v23]
       // or
-      //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass][v23 - 36]
+      if ((byte_4ED970_skill_learn_ability_by_class_table[v58->classType][v29 - 36])&&(v58->pActiveSkills[v29-36]))
       // or
       //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass - 1][v23 + 1]
 
-      //if ( *(&byte_4ED94C[37 * v58->uClass] + v29) && !*(&v58->uIntelligence + v29) )
-      {
-        v30 = pClassNames[v29 + 20];
+      {
+        v30 = pClassNames[v29 -16];
 LABEL_55:
         Str = v30;
         v28->uY = v63 + v55;
--- a/mm7_data.cpp	Thu Feb 28 21:45:39 2013 +0400
+++ b/mm7_data.cpp	Fri Mar 01 02:11:57 2013 +0400
@@ -1690,7 +1690,15 @@
 char _4F0D38_TravelInfo[777]; // weak
 int dword_4F0E10[32];
 Vec2_int_ pMonsterArenaPlacements[20];
-__int16 word_4F0F30[777]; // weak
+__int16 word_4F0F30[32] ={ 4, 7, 10, 11,                                              
+						   4, 7, 10, 11,
+					       4, 7, 10, 11,
+						   4, 7, 10, 11,
+					       4, 7, 10, 11,
+					       4, 7, 10, 11,
+					       4, 7, 10, 11,
+					       7, 11,
+						   7, 11};
 char aS03d[777]; // idb
 char byte_4F0F98; // idb
 char sz[777]; // idb
@@ -2343,7 +2351,7 @@
 int dword_F8B144; // idb
 char byte_F8B148[16];
 __int16 word_F8B158[777]; // weak
-struct Texture *dword_F8B164; // idb
+struct Texture *ShopTexture; // idb
 struct Texture *ItemsInShopTexture[12];
 int in_current_building_type; // 0xF8B198
 int dword_F8B19C; // weak
--- a/mm7_data.h	Thu Feb 28 21:45:39 2013 +0400
+++ b/mm7_data.h	Fri Mar 01 02:11:57 2013 +0400
@@ -1022,7 +1022,7 @@
 extern char _4F0D38_TravelInfo[]; // weak
 extern int dword_4F0E10[32];
 extern Vec2_int_ pMonsterArenaPlacements[20];
-extern __int16 word_4F0F30[]; // weak
+extern __int16 word_4F0F30[32]; // weak
 extern char aS03d[]; // idb
 extern char byte_4F0F98; // idb
 extern char sz[]; // idb
@@ -1684,7 +1684,7 @@
 extern int dword_F8B144; // idb
 extern char byte_F8B148[16];
 extern __int16 word_F8B158[]; // weak
-extern struct Texture *dword_F8B164; // idb
+extern struct Texture *ShopTexture; // idb
 extern struct Texture *ItemsInShopTexture[12];
 extern int in_current_building_type; // weak
 extern int dword_F8B19C; // weak
@@ -2339,7 +2339,7 @@
 void __cdecl sub_4BBCDD();
 void __fastcall _4BBF61_summon_actor(int a1, __int16 x, int y, int z); // idb
 void __cdecl ArenaFight();
-void  sub_4BC8D5();
+void  SpellBookGenerator();
 struct GUIButton *__cdecl UI_CreateEndConversationButton();
 void __fastcall DrawLearnSkillDialog(signed int uMessageParam);
 signed int __cdecl sub_4BD8B5();