changeset 1460:ff2118028c71

renaming _guilds_member_bits to _achieved_awards_bits
author Gloval
date Wed, 21 Aug 2013 20:58:36 +0400
parents 9dc33590f93e
children 845907a747d3
files Actor.cpp Arcomage.cpp NPC.cpp Player.cpp Player.h UI/Books/UISpellBook.cpp UI/UICharacter.cpp UI/UIGuilds.cpp UI/UIHouses.cpp mm7_4.cpp
diffstat 10 files changed, 79 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Wed Aug 14 00:40:51 2013 +0400
+++ b/Actor.cpp	Wed Aug 21 20:58:36 2013 +0400
@@ -2084,8 +2084,8 @@
     {
       if ( pParty->uFine )
       {
-        if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)(*ppPlayers)->_guilds_member_bits, 1) )
-          _449B7E_toggle_bit((unsigned char *)(*ppPlayers)->_guilds_member_bits, 1, 1u);
+        if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)(*ppPlayers)->_achieved_awards_bits, 1) )
+          _449B7E_toggle_bit((unsigned char *)(*ppPlayers)->_achieved_awards_bits, 1, 1u);
       }
       ++ppPlayers;
     }
--- a/Arcomage.cpp	Wed Aug 14 00:40:51 2013 +0400
+++ b/Arcomage.cpp	Wed Aug 21 20:58:36 2013 +0400
@@ -3935,7 +3935,7 @@
    
     for (int i=0; i<4; ++i  )
     {
-      v11 = (char *)&pParty->pPlayers[i]._guilds_member_bits;
+      v11 = (char *)&pParty->pPlayers[i]._achieved_awards_bits;
       if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v11, 1) )
         _449B7E_toggle_bit((unsigned char *)v11, PLAYER_GUILD_BITS__ARCOMAGE_WIN, 1);
       
@@ -3949,7 +3949,7 @@
   {
   for (int i=0; i<4; ++i  )
       {
-      v12 = (char *)&pParty->pPlayers[i]._guilds_member_bits;
+      v12 = (char *)&pParty->pPlayers[i]._achieved_awards_bits;
       if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v12, 1) )
         _449B7E_toggle_bit((unsigned char *)v12, PLAYER_GUILD_BITS__ARCOMAGE_LOSE, 1);
     }
--- a/NPC.cpp	Wed Aug 14 00:40:51 2013 +0400
+++ b/NPC.cpp	Wed Aug 21 20:58:36 2013 +0400
@@ -1563,7 +1563,7 @@
   gold_transaction_amount = price_for_membership[pEventCode];
   if ( pPlayers[uActiveCharacter]->CanAct() )
   {
-    if ( (unsigned __int16)_449B57_test_bit((unsigned __int8 *)pPlayers[uActiveCharacter]->_guilds_member_bits, dword_F8B1AC_award_bit_number) )
+    if ( (unsigned __int16)_449B57_test_bit((unsigned __int8 *)pPlayers[uActiveCharacter]->_achieved_awards_bits, dword_F8B1AC_award_bit_number) )
     {
       return pNPCTopics[dialogue_base+13].pText;
     }
--- a/Player.cpp	Wed Aug 14 00:40:51 2013 +0400
+++ b/Player.cpp	Wed Aug 21 20:58:36 2013 +0400
@@ -641,13 +641,13 @@
     switch ( uClass )
     {
       case 0x1Au:
-        return(_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 65));
+        return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 65));
       case 0x1Bu:
-        return(_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 67));
+        return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 67));
       case 0x22u:
-        return(_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 77));
+        return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 77));
       case 0x23u:
-        return(_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 79));
+        return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 79));
         break;
       default:
         assert("Should not be able to get here" && false);
@@ -5406,7 +5406,7 @@
   uExperience = 251 + rand() % 100;
   uBirthYear = 1147 - rand() % 6;
   memset(pActiveSkills, 0, sizeof(pActiveSkills));
-  memset(_guilds_member_bits, 0, 64);
+  memset(_achieved_awards_bits, 0, 64);
   memset(&spellbook, 0, sizeof(PlayerSpells));
 
   for (uint i = 0; i < 37; ++i)
@@ -6715,7 +6715,7 @@
           goto _j_cmp_against_arg;
         case VAR_Award:
           test_bit_value = 0x80u >> ((signed __int16)pValue - 1) % 8;
-          our_bit_value = this->_guilds_member_bits[((signed __int16)pValue - 1) /8];
+          our_bit_value = this->_achieved_awards_bits[((signed __int16)pValue - 1) /8];
           if ( !((unsigned __int8)test_bit_value & our_bit_value) )
             return true;
           return false;
@@ -7177,7 +7177,7 @@
         return;
       case VAR_Award:
         if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & 
-			  pPlayers[currPlayerId + 1]->_guilds_member_bits[((signed __int16)var_value - 1)/ 8])
+			  pPlayers[currPlayerId + 1]->_achieved_awards_bits[((signed __int16)var_value - 1)/ 8])
               //&& dword_723E80_award_related[2 * a3] )
 		    && pAwards[var_value].pText )
         {
@@ -7185,7 +7185,7 @@
           DrawPlayerBuffAnimBasedOnCondition(currPlayerId);
           PlaySoundBasedOnCondition(currPlayerId);
         }
-        _449B7E_toggle_bit((unsigned char *)this->_guilds_member_bits, var_value, 1u);
+        _449B7E_toggle_bit((unsigned char *)this->_achieved_awards_bits, var_value, 1u);
         return;
       case VAR_Experience:
         this->uExperience = var_value;
@@ -7599,7 +7599,7 @@
               return;
             case VAR_Award:
               v13 = pPlayers[uPlayerIdx + 1];
-              if (_449B57_test_bit((unsigned __int8 *)pPlayers[uPlayerIdx + 1]->_guilds_member_bits, val) 
+              if (_449B57_test_bit((unsigned __int8 *)pPlayers[uPlayerIdx + 1]->_achieved_awards_bits, val) 
              
 				&& pAwards[val].pText )
               {
@@ -7608,7 +7608,7 @@
                 v3 = 1;
                 v14->PlaySound(SPEECH_96, 0);
               }
-              v15 = (char *)v4->_guilds_member_bits;
+              v15 = (char *)v4->_achieved_awards_bits;
               goto LABEL_44;
             case VAR_Experience:
               v16 = __CFADD__(val, LODWORD(Dst->uExperience));
@@ -8234,7 +8234,7 @@
           this->sAgeModifier -= (signed __int16)pValue;
           return result;
         case VAR_Award:
-          _449B7E_toggle_bit((unsigned char *)this->_guilds_member_bits, (signed __int16)pValue, 0);
+          _449B7E_toggle_bit((unsigned char *)this->_achieved_awards_bits, (signed __int16)pValue, 0);
           return result;
         case VAR_Experience:
           v12 = (char *)&this->uExperience;
--- a/Player.h	Wed Aug 14 00:40:51 2013 +0400
+++ b/Player.h	Wed Aug 21 20:58:36 2013 +0400
@@ -697,7 +697,7 @@
     };
     unsigned __int16 pActiveSkills[37];
   };
-  unsigned char _guilds_member_bits[64];
+  unsigned char _achieved_awards_bits[64];
   PlayerSpells spellbook;
   char field__1F5[2]; // used to be [31]
   int pure_luck_used;      
--- a/UI/Books/UISpellBook.cpp	Wed Aug 14 00:40:51 2013 +0400
+++ b/UI/Books/UISpellBook.cpp	Wed Aug 21 20:58:36 2013 +0400
@@ -97,7 +97,7 @@
   {
     for ( uint i = 1; i <= 11; ++i )
     {
-      if (player->_guilds_member_bits[(11 * player->lastOpenedSpellbookPage) + i + 63] )
+      if (player->_achieved_awards_bits[(11 * player->lastOpenedSpellbookPage) + i + 63] )
       {
         if ( SBPageSSpellsTextureList[i] != PendingTexture )
         {
--- a/UI/UICharacter.cpp	Wed Aug 14 00:40:51 2013 +0400
+++ b/UI/UICharacter.cpp	Wed Aug 21 20:58:36 2013 +0400
@@ -563,7 +563,7 @@
 //----- (0041A000) --------------------------------------------------------
 void CharacterUI_AwardsTab_Draw(Player *player)
 {
-  unsigned int result; // eax@1
+  int items_per_page; // eax@1
   char *v6; // ebx@15
   char Source[100]; // [sp+Ch] [bp-C4h]@1
   GUIWindow awards_window; // [sp+70h] [bp-60h]@1
@@ -575,7 +575,7 @@
   strcat(pTmpBuf.data(), "\f00000");
 
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, 18, 0, pTmpBuf.data(), 0, 0, 0);
-  result = books_primary_item_per_page;
+  items_per_page = books_primary_item_per_page;
   awards_window.uFrameX = 12;
   awards_window.uFrameY = 48;
   awards_window.uFrameWidth = 424;
@@ -583,31 +583,31 @@
   awards_window.uFrameZ = 435;
   awards_window.uFrameW = 337;
   if (BtnDown_flag && num_achieved_awards + books_primary_item_per_page < full_num_items_in_book)
-    result = books_primary_item_per_page++ + 1;
-  if (BtnUp_flag && result)
+    items_per_page = books_primary_item_per_page++ + 1;
+  if (BtnUp_flag && items_per_page)
   {
-    --result;
-    books_primary_item_per_page = result;
+    --items_per_page;
+    books_primary_item_per_page = items_per_page;
   }
 
   if ( books_page_number < 0 )
   {
-    result += num_achieved_awards;
-    books_primary_item_per_page = result;
-    if ( (signed int)(num_achieved_awards + result) > full_num_items_in_book )
+    items_per_page += num_achieved_awards;
+    books_primary_item_per_page = items_per_page;
+    if ( (signed int)(num_achieved_awards + items_per_page) > full_num_items_in_book )
     {
-      result = full_num_items_in_book - num_achieved_awards;
-      books_primary_item_per_page = result;
+      items_per_page = full_num_items_in_book - num_achieved_awards;
+      books_primary_item_per_page = items_per_page;
     }
   }
   else if ( books_page_number > 0 )
   {
-    result -= num_achieved_awards;
-    books_primary_item_per_page = result;
-    if ( (result & 0x80000000u) != 0 )
+    items_per_page -= num_achieved_awards;
+    books_primary_item_per_page = items_per_page;
+    if ( items_per_page < 0 )
     {
-      result = 0;
-      books_primary_item_per_page = result;
+      items_per_page = 0;
+      books_primary_item_per_page = items_per_page;
     }
   }
   BtnDown_flag = 0;
@@ -615,7 +615,7 @@
   num_achieved_awards = 0;
   books_page_number = 0;
 
-  for ( int i = result; i < full_num_items_in_book; ++i)
+  for ( int i = items_per_page; i < full_num_items_in_book; ++i)
   {
     v6 = (char *)pAwards[achieved_awards[i]].pText;//(char *)dword_723E80_award_related[v20 / 4];
     pTmpBuf[0] = 0;
@@ -2345,31 +2345,52 @@
 //----- (00419100) --------------------------------------------------------
 void FillAwardsData()
 {
-        auto pPlayer = pPlayers[uActiveCharacter];
+    Player* pPlayer = pPlayers[uActiveCharacter];
 
-        memset(achieved_awards.data(), 0, 4000);
-        num_achieved_awards = 0;
+    memset(achieved_awards.data(), 0, 4000);
+    num_achieved_awards = 0;
 
-        memset(pTmpBuf2.data(), 0, 0x7D0u);
-        BtnDown_flag = 0;
-        BtnUp_flag = 0;
-        books_page_number = 0;
-        books_primary_item_per_page = 0;
-        for (int i = 0; i < 105; ++i)
+    memset(pTmpBuf2.data(), 0, 0x7D0u);
+    BtnDown_flag = 0;
+    BtnUp_flag = 0;
+    books_page_number = 0;
+    books_primary_item_per_page = 0;
+    for (int i = 1; i < 105; ++i)
+    {
+        if ( _449B57_test_bit(pPlayer->_achieved_awards_bits, i) && pAwards[i].pText )
         {
-            if ( _449B57_test_bit(pPlayer->_guilds_member_bits, i) && pAwards[i].pText )
-            {
-                achieved_awards[num_achieved_awards++] = (AwardType)i;
-            }
+            achieved_awards[num_achieved_awards++] = (AwardType)i;
         }
-        full_num_items_in_book = num_achieved_awards;
-        num_achieved_awards = 0;
+    }
+    full_num_items_in_book = num_achieved_awards;
+    num_achieved_awards = 0;
+
+    //sort awards index 
 
-        //sort awards index 
-        if (full_num_items_in_book > 0)
+    if (full_num_items_in_book>0)
         {
-            std::stable_sort(achieved_awards.begin(), achieved_awards.end(), awardSort);
+            for (int i = 0; i< full_num_items_in_book; ++i)
+                achieved_awards[full_num_items_in_book+i] = (AwardType)(rand()%16);
+            for (int i = 1; i< full_num_items_in_book; ++i)
+                {
+                for (int j = i; j< full_num_items_in_book; ++j)
+                    {
+                    AwardType tmp;
+                    if (pAwards[achieved_awards[j]].uPriority < pAwards[achieved_awards[i]].uPriority)
+                        {
+                        tmp= achieved_awards[j];
+                        achieved_awards[j] = achieved_awards[i];
+                        achieved_awards[i] = tmp;
+                        }
+                    }
+                }
         }
+
+
+    //  if (full_num_items_in_book > 0)
+    /* {
+        std::stable_sort(achieved_awards.begin(), achieved_awards.end(), awardSort);
+    }*/
     }
 
 
--- a/UI/UIGuilds.cpp	Wed Aug 14 00:40:51 2013 +0400
+++ b/UI/UIGuilds.cpp	Wed Aug 21 20:58:36 2013 +0400
@@ -191,7 +191,7 @@
     }
     return;
   }
-  if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)pPlayers[uActiveCharacter]->_guilds_member_bits,
+  if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)pPlayers[uActiveCharacter]->_achieved_awards_bits,
             guild_mambership_flags[(unsigned int)window_SpeakInHouse->ptr_1C-139]) )
   { //you must me member
     v38 = pFontArrus->CalcTextHeight(pNPCTopics[121].pText, &working_window, 0, 0);
--- a/UI/UIHouses.cpp	Wed Aug 14 00:40:51 2013 +0400
+++ b/UI/UIHouses.cpp	Wed Aug 21 20:58:36 2013 +0400
@@ -937,7 +937,7 @@
 			v19 = guild_mambership_flags[uHouseID - HOUSE_FIRE_GUILD_INITIATE_EMERALD_ISLE]; //guilds flags 
 			//v20 = uHouseID;
 			//if ( !((unsigned __int8)(0x80u >> v19 % 8) & pPlayers[uActiveCharacter]->_guilds_member_bits[v19 /8]) )
-			if(_449B57_test_bit(pPlayers[uActiveCharacter]->_guilds_member_bits,v19))
+			if(_449B57_test_bit(pPlayers[uActiveCharacter]->_achieved_awards_bits,v19))
             {
 				PlayHouseSound(uHouseID, HouseSound_Greeting_2);
 				return 1;
@@ -4017,7 +4017,7 @@
     pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v5);
     return; // void func
   }
-  if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v1->_guilds_member_bits, word_4F0754[2 * (unsigned int)window_SpeakInHouse->ptr_1C]) )
+  if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v1->_achieved_awards_bits, word_4F0754[2 * (unsigned int)window_SpeakInHouse->ptr_1C]) )
   {
     v24 = pNPCTopics[171].pText;
     v25 = v31;
--- a/mm7_4.cpp	Wed Aug 14 00:40:51 2013 +0400
+++ b/mm7_4.cpp	Wed Aug 21 20:58:36 2013 +0400
@@ -2000,7 +2000,7 @@
           break;
         case 8:
           v63 = 0;
-          v20 = (unsigned __int8 *)pPlayer->_guilds_member_bits;
+          v20 = (unsigned __int8 *)pPlayer->_achieved_awards_bits;
           for ( uint i = 0; i < 28; ++i )
           {
             if ( (unsigned __int16)_449B57_test_bit(v20, word_4EE150[i]) )
@@ -2927,7 +2927,7 @@
     if ( pParty->uFine )
     {
       //v10 = result->_guilds_member_bits;
-      result = (Player *)_449B57_test_bit((unsigned __int8 *)result->_guilds_member_bits, 1);
+      result = (Player *)_449B57_test_bit((unsigned __int8 *)result->_achieved_awards_bits, 1);
       if ( !(short)result )
 		  __debugbreak();
         //result = (Player *)_449B7E_toggle_bit((unsigned char *)v10, 1, 1u);