changeset 1012:9e823ad5eaa6

second msg_queue returned
author Gloval
date Sun, 19 May 2013 12:13:42 +0400
parents f85a8305a57c
children 0cef8c6aa893 a704435d3285
files Actor.cpp GUIWindow.cpp GUIWindow.h Items.h Player.cpp Player.h mm7_5.cpp mm7_6.cpp mm7_data.cpp mm7_data.h
diffstat 10 files changed, 102 insertions(+), 114 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Sun May 19 10:16:23 2013 +0400
+++ b/Actor.cpp	Sun May 19 12:13:42 2013 +0400
@@ -3145,6 +3145,7 @@
     actor->pActorBuffs[i].Reset();
 
   ItemGen drop;
+  drop.Reset();
   switch (actor->pMonsterInfo.uID)
   {
     case MONSTER_HARPY_1: case MONSTER_HARPY_2: case MONSTER_HARPY_3:
--- a/GUIWindow.cpp	Sun May 19 10:16:23 2013 +0400
+++ b/GUIWindow.cpp	Sun May 19 12:13:42 2013 +0400
@@ -34,7 +34,7 @@
 struct GUIWindow pWindowList[20];
 
 struct GUIMessageQueue *pMessageQueue_50CBD0 = new GUIMessageQueue;
-
+struct GUIMessageQueue *pMessageQueue_50C9E8 = new GUIMessageQueue;
 
 // inlined
 //----- (mm6c::00420520) --------------------------------------------------
--- a/GUIWindow.h	Sun May 19 10:16:23 2013 +0400
+++ b/GUIWindow.h	Sun May 19 12:13:42 2013 +0400
@@ -443,7 +443,7 @@
 
 extern struct GUIMessageQueue *pMessageQueue_50CBD0; // idb
 
-
+extern struct GUIMessageQueue *pMessageQueue_50C9E8; // idb
 
 
 
--- a/Items.h	Sun May 19 10:16:23 2013 +0400
+++ b/Items.h	Sun May 19 12:13:42 2013 +0400
@@ -124,10 +124,10 @@
 struct ItemGen //0x24
 {
   //----- (0042EB25) --------------------------------------------------------
-  inline ItemGen()
-  {
-    Reset();
-  }
+ // inline ItemGen()
+ // {
+ //   Reset();
+ // }
 
   inline bool Broken()        {return uAttributes & ITEM_BROKEN;}
   inline bool Identified()    {return uAttributes & ITEM_IDENTIFIED;}
--- a/Player.cpp	Sun May 19 10:16:23 2013 +0400
+++ b/Player.cpp	Sun May 19 12:13:42 2013 +0400
@@ -479,97 +479,66 @@
 
 
 //----- (00421E75) --------------------------------------------------------
-unsigned int Player::GetItemIDAtInventoryIndex(int *a2)
-{
-  int v2; // eax@1
-  unsigned int result; // eax@3
-
-  v2 = *a2;
-  if ( *a2 >= 126 || v2 < 0 )
-  {
-    result = 0;
-  }
-  else
-  {
-    result = this->pInventoryIndices[v2];
-    if ( (result & 0x80000000u) != 0 )
-    {
-      *a2 = -1 - result;
-      result = this->pInventoryIndices[-1 - result];
-    }
-  }
-  return result;
+unsigned int Player::GetItemIDAtInventoryIndex(int *pitem_index)
+{
+  int item_idx; // eax@1
+  int inv_index; // eax@3
+
+  item_idx = *pitem_index;
+  if ( item_idx >125 || item_idx < 0 )
+  {
+    return 0;
+  }
+  
+    inv_index = this->pInventoryIndices[item_idx];
+    if ( inv_index < 0 )
+    {
+      *pitem_index = -1 - inv_index;
+      inv_index = this->pInventoryIndices[-1 - inv_index];
+    }
+
+  return inv_index;
 }
 
 
 
 //----- (004160CA) --------------------------------------------------------
-char Player::_4160CA(int a2)
-{
-  Player *v2; // esi@1
-  signed int v3; // edx@1
-  signed int v4; // ebx@1
-  ItemGen *v5; // eax@1
-  int v6; // edi@2
-  signed int i; // edx@8
-  ItemGen **v8; // ecx@9
-  __int16 v10[137]; // [sp+Ch] [bp-118h]@1
-  __int16 v11; // [sp+11Eh] [bp-6h]@1
-  int v12; // [sp+120h] [bp-4h]@1
-
-  auto a1 = this;
-
-  v12 = a2;
-  v2 = a1;
-  v3 = 0;
-  v10[0] = 0;
-  v4 = 0;
-  memset(&v10[1], 0, 0x110u);
-  v11 = 0;
-  v5 = a1->pInventoryItems;
-  do
-  {
-    v6 = 0;
-    if ( (signed int)v5->uItemID > 0 && (signed int)v5->uItemID <= 134 )
-      v10[v4++] = v3;
-    ++v3;
-    ++v5;
-  }
-  while ( v3 < 138 );
-  if ( v4 )
-  {
-    if ( v12 )
-    {
-      if ( v12 > 0 )
-      {
-        do
+void Player::ItemsEnchant( int enchant_count )
+    {
+  int avalible_items; // ebx@1
+  int i; // edx@8
+  __int16 item_index_tabl[138]; // [sp+Ch] [bp-118h]@1
+ 
+  avalible_items = 0;
+  memset (item_index_tabl,0,sizeof(item_index_tabl));
+
+  for (i=0; i<138; ++i)
+      {
+       if (( pOwnItems[i].uItemID>0)&&(pOwnItems[i].uItemID<= 134))
+           item_index_tabl[avalible_items++] = i;
+      }
+
+  if ( avalible_items )
+  {
+    if ( enchant_count )
+    {
+    for ( i = 0; i < enchant_count; ++i )
         {
-          LOWORD(v5) = 9 * v10[v6];
-          if ( !(BYTE1(v2->pInventoryItems[v10[v6]].uAttributes) & 2) )
-          {
-            v5 = (ItemGen *)((char *)&v2->pInventoryItems[v10[rand() % v4]] + 20);
-            v5->uItemID |= 2u;
-          }
-          ++v6;
+        if (!(pInventoryItems[item_index_tabl[i]].uAttributes&ITEM_ENCHANTED))
+                pInventoryItems[item_index_tabl[rand() % avalible_items]].uAttributes|=ITEM_ENCHANTED; 
         }
-        while ( v6 < v12 );
-      }
+       
     }
     else
     {
-      for ( i = 0; i < v4; ++i )
-      {
-        v8 = (ItemGen **)&v2->pInventoryItems[v10[i]].uAttributes;
-        v5 = *v8;
-        if ( !(BYTE1(v5) & 2) )
-        {
-          LOBYTE(v5) = (unsigned __int8)v5 | 2;
-          *v8 = v5;
-        }
-      }
-    }
-  }
-  return (char)v5;
+      for ( i = 0; i < avalible_items; ++i )
+      {
+        if (!(pInventoryItems[item_index_tabl[i]].uAttributes&ITEM_ENCHANTED))
+                pInventoryItems[item_index_tabl[i]].uAttributes|=ITEM_ENCHANTED;
+      }
+    }
+  }
+ ;
 }
 
 //----- (004948B1) --------------------------------------------------------
@@ -7775,7 +7744,7 @@
       dword_50C9EC[3 * dword_50C9E8 + 2] = a2 - 1;
       ++dword_50C9E8;
     }*/
-    pMessageQueue_50CBD0->AddMessage(UIMSG_92, 0, 0);
+    pMessageQueue_50C9E8->AddMessage(UIMSG_92, v24, a2 - 1);
     if ( pCurrentScreen
       && pGUIWindow_CurrentMenu
       && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null)
--- a/Player.h	Sun May 19 10:16:23 2013 +0400
+++ b/Player.h	Sun May 19 12:13:42 2013 +0400
@@ -554,7 +554,7 @@
   int _49327B(unsigned int uClass, int a3);
   void PlaySound(PlayerSpeech speech, int a3);
   void PlayEmotion(CHARACTER_EXPRESSION_ID expression, int a3);
-  char _4160CA(int a2);
+  void ItemsEnchant(int enchant_count);
   unsigned int GetItemIDAtInventoryIndex(int *a2);
   int _4B6FF9();
   int _4B824B(float a2);
@@ -683,8 +683,17 @@
   unsigned char _guilds_member_bits[64];
   PlayerSpells spellbook;
   char field_1F5[30]; // used to be [31]
-  ItemGen pInventoryItems[126];
-  ItemGen pEquippedItems[12];
+  union
+      {
+      struct  
+          {
+          ItemGen pInventoryItems[126];
+          ItemGen pEquippedItems[12];
+      };
+      ItemGen pOwnItems[138];
+      };
+  
+
   int pInventoryIndices[126];
   __int16 sResFireBase;
   __int16 sResAirBase;
--- a/mm7_5.cpp	Sun May 19 10:16:23 2013 +0400
+++ b/mm7_5.cpp	Sun May 19 12:13:42 2013 +0400
@@ -2803,7 +2803,8 @@
                     dword_50C9EC[3 * dword_50C9E8 + 2] = uActiveCharacter - 1;
                     ++dword_50C9E8;
                   }*/
-                  pMessageQueue_50CBD0->AddMessage(UIMSG_CastSpellFromBook, v103, uActiveCharacter - 1);
+                  pMessageQueue_50C9E8->AddMessage(UIMSG_CastSpellFromBook, v103, uActiveCharacter - 1);
+                //  pMessageQueue_50CBD0->AddMessage(UIMSG_CastSpellFromBook, v103, uActiveCharacter - 1);
                 }
                 else
                 {
@@ -3261,9 +3262,13 @@
       }
     }
   }
-  pMessageQueue_50CBD0->uNumMessages = dword_50C9E8;
-  memcpy(pMessageQueue_50CBD0->pMessages, dword_50C9EC, 12 * dword_50C9E8);
-  dword_50C9E8 = 0;
+  pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50C9E8->uNumMessages;//dword_50C9E8;
+  memcpy(pMessageQueue_50CBD0->pMessages, pMessageQueue_50C9E8->pMessages, sizeof(GUIMessage) * pMessageQueue_50C9E8->uNumMessages);
+  //memcpy(pMessageQueue_50CBD0->pMessages, dword_50C9EC, 12 * dword_50C9E8);
+  //dword_50C9E8 = 0;
+
+
+   pMessageQueue_50C9E8->uNumMessages=0;
   if ( dword_50C9DC )
   {
     /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
@@ -10891,7 +10896,7 @@
           v23 = 0;
         }
       }
-      v0->_4160CA(v23);
+      v0->ItemsEnchant(v23);
       pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
 
       pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
--- a/mm7_6.cpp	Sun May 19 10:16:23 2013 +0400
+++ b/mm7_6.cpp	Sun May 19 12:13:42 2013 +0400
@@ -8180,13 +8180,14 @@
             }
             else
             {
-              if ( dword_50C9E8 < 40 )
-              {
-                dword_50C9EC[3 * dword_50C9E8] = 25;
-                dword_50C9EC[3 * dword_50C9E8 + 1] = 0;
-                dword_50C9EC[3 * dword_50C9E8 + 2] = 0;
-                ++dword_50C9E8;
-              }
+            /*  if ( dword_50C9E8 < 40 )
+            {
+            dword_50C9EC[3 * dword_50C9E8] = 25;
+            dword_50C9EC[3 * dword_50C9E8 + 1] = 0;
+            dword_50C9EC[3 * dword_50C9E8 + 2] = 0;
+            ++dword_50C9E8;
+            }*/
+            pMessageQueue_50C9E8->AddMessage(UIMSG_CastQuickSpell, 0, 0);
             }
             break;
           case INPUT_Attack:
@@ -8225,12 +8226,13 @@
             }
             break;
           case INPUT_CharCycle:
-            if ( pCurrentScreen == SCREEN_SPELL_BOOK || dword_50C9E8 >= 40 )
+            if ( pCurrentScreen == SCREEN_SPELL_BOOK  )
               break;
-            dword_50C9EC[3 * dword_50C9E8] = 176;
+           /* dword_50C9EC[3 * dword_50C9E8] = 176;|| dword_50C9E8 >= 40
             dword_50C9EC[3 * dword_50C9E8 + 1] = 0;
             dword_50C9EC[3 * dword_50C9E8 + 2] = 0;
-            ++dword_50C9E8;
+            ++dword_50C9E8;*/
+            pMessageQueue_50C9E8->AddMessage(UIMSG_CycleCharacters, 0, 0);
             break;
           case INPUT_LookUp:
             if ( pEventTimer->bPaused )
@@ -8271,21 +8273,23 @@
             }
             break;
           case INPUT_ZoomIn:
-            if ( dword_50C9E8 >= 40 )
+            /*if ( dword_50C9E8 >= 40 )
               break;
             dword_50C9EC[3 * dword_50C9E8] = 367;
             dword_50C9EC[3 * dword_50C9E8 + 1] = 0;
             dword_50C9EC[3 * dword_50C9E8 + 2] = 0;
-            ++dword_50C9E8;
+            ++dword_50C9E8;*/
+              pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomOutBtn, 0, 0);
             break;
           case INPUT_ZoomOut:
-            if ( dword_50C9E8 < 40 )
+            /*if ( dword_50C9E8 < 40 )
             {
               dword_50C9EC[3 * dword_50C9E8] = 368;
               dword_50C9EC[3 * dword_50C9E8 + 1] = 0;
               dword_50C9EC[3 * dword_50C9E8 + 2] = 0;
               ++dword_50C9E8;
-            }
+            }*/
+              pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomInBtn, 0, 0);
             break;
           case INPUT_AlwaysRun:
             bAlwaysRun = bAlwaysRun == 0;
--- a/mm7_data.cpp	Sun May 19 10:16:23 2013 +0400
+++ b/mm7_data.cpp	Sun May 19 12:13:42 2013 +0400
@@ -1591,8 +1591,8 @@
 int dword_50C9D8; // weak
 int dword_50C9DC; // weak
 struct NPCData *ptr_50C9E0;
-int dword_50C9E8; // idb
-int dword_50C9EC[120]; // weak
+//int dword_50C9E8; // idb
+//int dword_50C9EC[120]; // weak
 int dword_50CDC8;
 int dword_50CDCC; // weak
 int bProcessorIsNotIntel; // weak
--- a/mm7_data.h	Sun May 19 10:16:23 2013 +0400
+++ b/mm7_data.h	Sun May 19 12:13:42 2013 +0400
@@ -1032,8 +1032,8 @@
 extern int dword_50C9D8; // weak
 extern int dword_50C9DC; // weak
 extern struct NPCData *ptr_50C9E0;
-extern int dword_50C9E8; // idb
-extern int dword_50C9EC[]; // 50C9EC
+//extern int dword_50C9E8; // idb
+//extern int dword_50C9EC[]; // 50C9EC
 extern int dword_50CDC8;
 extern int dword_50CDCC; // weak
 extern int bProcessorIsNotIntel; // weak