changeset 521:663c4f618f56

Awards tab corrrection
author Gloval
date Sat, 02 Mar 2013 01:42:05 +0400
parents 35f28d4c0ff9
children 8f7f651311bc
files GUIWindow.cpp Player.cpp mm7_1.cpp mm7_3.cpp mm7_5.cpp mm7_6.cpp mm7_data.cpp mm7_data.h stru179.h
diffstat 9 files changed, 134 insertions(+), 190 deletions(-) [+]
line wrap: on
line diff
--- a/GUIWindow.cpp	Fri Mar 01 23:43:21 2013 +0400
+++ b/GUIWindow.cpp	Sat Mar 02 01:42:05 2013 +0400
@@ -474,10 +474,10 @@
   InitializeBookFonts();
   v1->CreateButton(0x1DBu, 0x1BDu, 0x9Eu, 0x22u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], 0);
   pCurrentScreen = SCREEN_BOOKS;
-  dword_506524 = 0;
+  awards_count2 = 0;
   dword_506528 = 0;
   dword_50651C = 0;
-  dword_506520 = 0;  
+  awards_count = 0;  
   if ( v1->ptr_1C == (void *)177 )
   {
     byte_506360 = 0;
@@ -558,15 +558,15 @@
         pBtn_Book_2 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 38, pTex_tab_an_7b__zoot_on->uTextureHeight,
                         pTex_tab_an_7b__zoot_on->uTextureHeight, 1, 0, 0x47u, 0xAu, 0, pGlobalTXT_LocalizationStrings[193],// "Scroll Down"
                         pTex_tab_an_7b__zoot_on, 0);
-        dword_506520 = 0;
-        memset(&pStru179, 0, 0xFA0u);
+        awards_count = 0;
+        memset(&achievedAwardsIndex, 0, 4000);
         for ( i = dword_506528; i < 512; ++i )
         {
           v14 = (char *)pQuestTable[i-1];//(&dword_722F10)[4 * i];
-          if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, i) && v14 )
+          if ( _449B57_test_bit(pParty->_quest_bits, i) && v14 )
           {
-            v15 = dword_506520++;
-            pStru179.field_0[v15] = i;
+            v15 = awards_count++;
+            achievedAwardsIndex[v15] = i;
           }
         }
       }
@@ -610,7 +610,7 @@
                  pGlobalTXT_LocalizationStrings[662], pTexture_50636C, 0);// "Instructors"
           v10 = dword_506528;
           pBtn_Autonotes_Instructors = v9;
-          dword_506520 = 0;
+          awards_count = 0;
           while ( v10 < 196 )
           {
 			if ( dword_506568 == pAutonoteTxt[v10-1].eType)//dword_72371C[2 * v10] )
@@ -619,10 +619,10 @@
 			  v25 = (char *)pAutonoteTxt[v10-1].pText;
               if ( (short)v10 )
               {
-                if ( (unsigned __int16)_449B57_test_bit(pParty->_autonote_bits, v10) && v25 )
+                if ( _449B57_test_bit(pParty->_autonote_bits, v10) && v25 )
                 {
-                  v11 = dword_506520++;
-                  pStru179.field_0[v11] = (signed __int16)v10;
+                  v11 = awards_count++;
+                  achievedAwardsIndex[v11] = (signed __int16)v10;
                 }
               }
             }
@@ -704,7 +704,7 @@
                           pGlobalTXT_LocalizationStrings[193],
                           pTex_tab_an_7b__zoot_on,
                           0);
-          dword_506520 = 0;
+          awards_count = 0;
           v26.uFrameX = 48;
           v26.uFrameY = 70;
           v26.uFrameWidth = 360;
@@ -713,7 +713,7 @@
           v26.uFrameZ = 407;
           v26.uFrameHeight = v2 * 264 / v2;
           v26.uFrameW = v26.uFrameHeight + 69;
-          memset(&pStru179, 0, 0xFA0u);
+          memset(&achievedAwardsIndex, 0, 4000);
           memset(byte_5C6D50, 0, 0x64u);
           if ( dword_506528 < 29 )
           {
@@ -731,10 +731,10 @@
                   v8 = v7 + 1;
                   if ( (signed int)v7 + 1 > 0 )
                   {
-                    memset32((char *)&pStru179 + 4 * dword_506520 , i, v8);
+                    memset32((char *)&achievedAwardsIndex + 4 * awards_count , i, v8);
                     do
                     {
-                      LODWORD(v7) = dword_506520++;
+                      LODWORD(v7) = awards_count++;
                       byte_5C6D50[(int)v7] = BYTE4(v7);
                       ++HIDWORD(v7);
                     }
@@ -748,9 +748,9 @@
           }
         }
       }
-      v12 = dword_506520;
-      dword_506520 = 0;
-      dword_506524 = v12;
+      v12 = awards_count;
+      awards_count = 0;
+      awards_count2 = v12;
     }
   }
 }
--- a/Player.cpp	Fri Mar 01 23:43:21 2013 +0400
+++ b/Player.cpp	Sat Mar 02 01:42:05 2013 +0400
@@ -8868,9 +8868,8 @@
               return;
             case VAR_Award:
               v13 = pPlayers[uPlayerIdx + 1];
-              v33 = 0x80u >> ((signed __int16)val - 1) % 8;
-              if ( !((unsigned __int8)(0x80u >> ((signed __int16)val - 1) % 8) & v13->_guilds_member_bits[((signed __int16)val - 1) >> 3])
-                //&& dword_723E80_award_related[2 * val] )
+              if (_449B57_test_bit((unsigned __int8 *)pPlayers[uPlayerIdx + 1]->_guilds_member_bits, val) 
+             
 				&& pAwards[val].pText )
               {
                 v14 = pPlayers[uPlayerIdx + 1];
--- a/mm7_1.cpp	Fri Mar 01 23:43:21 2013 +0400
+++ b/mm7_1.cpp	Sat Mar 02 01:42:05 2013 +0400
@@ -612,11 +612,11 @@
 }
 
 //----- (0041A000) --------------------------------------------------------
-unsigned int __fastcall CharacterUI_AwardsTab_Draw(unsigned int uPlayerID)
-{
+void CharacterUI_AwardsTab_Draw( unsigned int uPlayerID )
+    {
   //unsigned int v1; // esi@1
   unsigned int v2; // ebx@1
-  unsigned int v3; // eax@1
+  unsigned int award_texture_id; // eax@1
   unsigned int result; // eax@1
   int v5; // eax@15
   char *v6; // ebx@15
@@ -637,15 +637,15 @@
   int v21; // [sp+C8h] [bp-8h]@14
   int v22; // [sp+CCh] [bp-4h]@40
 
-  auto player = pParty->pPlayers + uPlayerID - 1;
+  auto player = &pParty->pPlayers[uPlayerID - 1];
   //v1 = uPlayerID;
   v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-  v3 = pIcons_LOD->LoadTexture("fr_award", TEXTURE_16BIT_PALETTE);
-  pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v3 != -1 ? &pIcons_LOD->pTextures[v3] : 0));
-  sprintfex(pTmpBuf, "%s\xC" "%05d", pGlobalTXT_LocalizationStrings[23], v2);
-  sprintfex(Source, pGlobalTXT_LocalizationStrings[429], player->pName, pClassNames[player->classType]);
+  award_texture_id = pIcons_LOD->LoadTexture("fr_award", TEXTURE_16BIT_PALETTE);
+  pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(award_texture_id != -1 ? &pIcons_LOD->pTextures[award_texture_id] : 0));
+  sprintfex(pTmpBuf, "%s \f%05d", pGlobalTXT_LocalizationStrings[LOCSTR_AVARDS_FOR], v2);
+  sprintfex(Source, pGlobalTXT_LocalizationStrings[LOCSTR_S_THE_S], player->pName, pClassNames[player->classType]);
   strcat(pTmpBuf, Source);
-  strcat(pTmpBuf, "\xC" "00000");
+  strcat(pTmpBuf, "\f00000");
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, 18, 0, pTmpBuf, 0, 0, 0);
   result = dword_506528;
   a1.uFrameX = 12;
@@ -654,7 +654,7 @@
   a1.uFrameHeight = 290;
   a1.uFrameZ = 435;
   a1.uFrameW = 337;
-  if ( dword_506544 && dword_506520 + dword_506528 < dword_506524 )
+  if ( dword_506544 && awards_count + dword_506528 < awards_count2 )
     result = dword_506528++ + 1;
   if ( dword_506548 && result )
   {
@@ -663,16 +663,16 @@
   }
   if ( dword_50651C < 0 )
   {
-    result += dword_506520;
+    result += awards_count;
     dword_506528 = result;
-    if ( (signed int)(dword_506520 + result) <= dword_506524 )
+    if ( (signed int)(awards_count + result) <= awards_count2 )
       goto LABEL_14;
-    result = dword_506524 - dword_506520;
+    result = awards_count2 - awards_count;
     goto LABEL_13;
   }
   if ( dword_50651C > 0 )
   {
-    result -= dword_506520;
+    result -= awards_count;
     dword_506528 = result;
     if ( (result & 0x80000000u) != 0 )
     {
@@ -685,16 +685,16 @@
 LABEL_14:
   dword_506544 = 0;
   dword_506548 = 0;
-  dword_506520 = 0;
+  awards_count = 0;
   dword_50651C = 0;
   v21 = result;
-  if ( (signed int)result < dword_506524 )
+  if ( (signed int)result < awards_count2 )
   {
     while ( 1 )
     {
-      v5 = pStru179.field_0[v21];
-      v20 = 8 * pStru179.field_0[v21];
-      v6 = (char *)pAwards[(v20-1)/8].pText;//(char *)dword_723E80_award_related[v20 / 4];
+      v5 = achievedAwardsIndex[v21];
+      v20 = achievedAwardsIndex[v21];
+      v6 = (char *)pAwards[v20].pText;//(char *)dword_723E80_award_related[v20 / 4];
       if ( v5 != 1 )
         break;
       v17 = pParty->uFine;
@@ -702,8 +702,8 @@
       sprintf(pTmpBuf, v6, v17);
       v6 = pTmpBuf;
 LABEL_43:
-	  v14 = pAwards[v20/8-1].uSort;//dword_723E84[v20 / 4];
-      ++dword_506520;
+	  v14 = pAwards[v20].uSort;//dword_723E84[v20 / 4];
+      ++awards_count;
       v15 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(
               pAwardsTextColors[3 * v14 % 6],
               pAwardsTextColors[3 * v14 % 6 + 1],
@@ -716,10 +716,10 @@
         ++v21;
         a1.uFrameY = result;
         result = v21;
-        if ( v21 < dword_506524 )
+        if ( v21 < awards_count2 )
           continue;
       }
-      return result;
+      return;
     }
     if ( (v5 < 85 || v5 > 91) && (v5 < 103 || v5 > 104) )
       goto LABEL_43;
@@ -786,7 +786,7 @@
     v17 = v22;
     goto LABEL_42;
   }
-  return result;
+  return;
 }
 // 50651C: using guessed type int dword_50651C;
 // 506520: using guessed type int dword_506520;
@@ -4791,7 +4791,7 @@
   pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
   pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
   pWindow->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
-  sub_419100();
+  FillAwardsData();
   return pWindow;
 }
 
@@ -5014,7 +5014,7 @@
       viewparams->bRedrawGameUI = true;
       uActiveCharacter = uPlayerID;
       if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 102 )
-        sub_419100();
+        FillAwardsData();
       return;
     }
     //goto LABEL_23;
--- a/mm7_3.cpp	Fri Mar 01 23:43:21 2013 +0400
+++ b/mm7_3.cpp	Sat Mar 02 01:42:05 2013 +0400
@@ -16285,8 +16285,8 @@
 }
 
 //----- (00449B57) --------------------------------------------------------
-unsigned int __fastcall _449B57_test_bit(unsigned __int8 *a1, __int16 a2)
-{
+bool _449B57_test_bit( unsigned __int8 *a1, __int16 a2 )
+    {
   return a1[(a2 - 1) >> 3] & (0x80u >> (a2 - 1) % 8);
 }
 
--- a/mm7_5.cpp	Fri Mar 01 23:43:21 2013 +0400
+++ b/mm7_5.cpp	Sat Mar 02 01:42:05 2013 +0400
@@ -3174,7 +3174,7 @@
           pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 102;
           GUIWindow::Create(pCharacterScreen_AwardsBtn->uX, pCharacterScreen_AwardsBtn->uY, 0, 0, (WindowType)(WINDOW_HouseInterior|0x42),
             (int)pCharacterScreen_AwardsBtn, 0);
-          sub_419100();
+          FillAwardsData();
           continue;
         case UIMSG_AutonotesBook:
           switch ( uMessageParam )
@@ -13602,7 +13602,7 @@
     v0 = pViewport->uViewportX + 398;
   }
   pRenderer->DrawTextureTransparent(v0, v11, v13);
-  if ( dword_506544 || dword_506528 + dword_506520 >= dword_506524 )
+  if ( dword_506544 || dword_506528 + awards_count >= awards_count2 )
   {
     v14 = pTex_tab_an_7a__zoot_off;
     v12 = pViewport->uViewportY + 38;
@@ -13617,7 +13617,7 @@
   pRenderer->DrawTextureTransparent(v1, v12, v14);
   if ( !byte_5C6D50[dword_506528] )
   {
-    v2 = pStru179.field_0[dword_506528];
+    v2 = achievedAwardsIndex[dword_506528];
     a1.uFrameWidth = 460;
     a1.uFrameX = 8;
     a1.uFrameY = 8;
@@ -13636,12 +13636,12 @@
   a1.uFrameZ = 407;
   a1.uFrameHeight = v4 * 264 / v4;
   a1.uFrameW = a1.uFrameHeight + 69;
-  if ( dword_506544 && dword_506528 + dword_506520 < dword_506524 )
+  if ( dword_506544 && dword_506528 + awards_count < awards_count2 )
   {
     pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
     v5 = dword_50651C++;
-    dword_506528 += dword_506520;
-    byte_506130[v5] = dword_506520;
+    dword_506528 += awards_count;
+    byte_506130[v5] = awards_count;
   }
   if ( dword_506548 && dword_50651C )
   {
@@ -13649,15 +13649,15 @@
     --dword_50651C;
     dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
   }
-  if ( !dword_506520 || dword_506528 < 1 )
+  if ( !awards_count || dword_506528 < 1 )
   {
     dword_506528 = 0;
     dword_50651C = 0;
   }
   dword_506544 = 0;
-  v6 = pStru179.field_0[dword_506528];
+  v6 = achievedAwardsIndex[dword_506528];
   dword_506548 = 0;
-  dword_506520 = 0;
+  awards_count = 0;
   //v7 = *pStorylineText->StoreLine[v6].pText;//*(&pStorylineText->field_0 + 3 * v6);
   v7 = (int)pStorylineText->StoreLine[v6].pText;//*(&pStorylineText->field_0 + 3 * v6);
   v8 = BuilDialogueString(
@@ -13671,7 +13671,7 @@
   {
     v9 = pAutonoteFont->_44C6C2(v8, &a1, 1u, (unsigned __int8)byte_5C6D50[dword_506528]);
     LOBYTE(v8) = a1.DrawText(pAutonoteFont, 1, 0, 0, (const char *)v9, 0, a1.uFrameY + a1.uFrameHeight, 0);
-    ++dword_506520;
+    ++awards_count;
   }
   return (char)v8;
 }
@@ -13708,7 +13708,7 @@
     v0 = pViewport->uViewportX + 398;
   }
   pRenderer->DrawTextureTransparent(v0, v8, v10);
-  if ( dword_506544 || dword_506528 + dword_506520 >= dword_506524 )
+  if ( dword_506544 || dword_506528 + awards_count >= awards_count2 )
   {
     v11 = pTex_tab_an_7a__zoot_off;
     v9 = pViewport->uViewportY + 38;
@@ -13734,12 +13734,12 @@
   a1.uFrameHeight = 264;
   a1.uFrameZ = 407;
   a1.uFrameW = 333;
-  if ( dword_506544 && dword_506528 + dword_506520 < dword_506524 )
+  if ( dword_506544 && dword_506528 + awards_count < awards_count2 )
   {
     pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
     v2 = dword_50651C++;
-    dword_506528 += dword_506520;
-    byte_506130[v2] = dword_506520;
+    dword_506528 += awards_count;
+    byte_506130[v2] = awards_count;
   }
   if ( dword_506548 && dword_50651C )
   {
@@ -13747,7 +13747,7 @@
     --dword_50651C;
     dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
   }
-  if ( !dword_506520 || (v3 = dword_506528, dword_506528 < 1) )
+  if ( !awards_count || (v3 = dword_506528, dword_506528 < 1) )
   {
     v3 = 0;
     dword_50651C = 0;
@@ -13755,11 +13755,11 @@
   }
   dword_506544 = 0;
   dword_506548 = 0;
-  dword_506520 = 0;
-  while ( v3 < dword_506524 )
-  {
-    v4 = pStru179.field_0[v3];
-    ++dword_506520;
+  awards_count = 0;
+  while ( v3 < awards_count2 )
+  {
+    v4 = achievedAwardsIndex[v3];
+    ++awards_count;
     v5 = pQuestTable[v4-1];//(&dword_722F10)[4 * v4];
     a1.DrawText(pAutonoteFont, 1, 0, 0, pQuestTable[v4-1], 0, 0, 0);//(&dword_722F10)[4 * v4], 0, 0, 0);
     v6 = pAutonoteFont->CalcTextHeight(v5, &a1, 1, 0);
@@ -13826,7 +13826,7 @@
     v0 = pViewport->uViewportX + 398;
   }
   pRenderer->DrawTextureTransparent(v0, v17, v24);
-  if ( dword_506544 || dword_506528 + dword_506520 >= dword_506524 )
+  if ( dword_506544 || dword_506528 + awards_count >= awards_count2 )
   {
     v25 = pTex_tab_an_7a__zoot_off;
     v18 = pViewport->uViewportY + 38;
@@ -14000,10 +14000,10 @@
   a1.uFrameW = 333;
   if ( v31 )
   {
-    dword_506524 = 0;
+    awards_count2 = 0;
     dword_506528 = 0;
     dword_50651C = 0;
-    dword_506520 = 0;
+    awards_count = 0;
     v8 = 0;
     do
     {
@@ -14016,25 +14016,25 @@
         {
           if ( (unsigned __int16)_449B57_test_bit(pParty->_autonote_bits, v8) && v32 )
           {
-            v9 = dword_506520++;
-            pStru179.field_0[v9] = (signed __int16)v8;
+            v9 = awards_count++;
+            achievedAwardsIndex[v9] = (signed __int16)v8;
           }
         }
       }
       ++v8;
     }
     while ( v8 < 196 );
-    dword_506524 = dword_506520;
+    awards_count2 = awards_count;
   }
   else
   {
     if ( dword_506544 )
     {
-      v10 = dword_506520 + dword_506528;
-      if ( dword_506520 + dword_506528 < dword_506524 )
+      v10 = awards_count + dword_506528;
+      if ( awards_count + dword_506528 < awards_count2 )
       {
         v11 = dword_50651C++;
-        byte_506130[v11] = dword_506520;
+        byte_506130[v11] = awards_count;
         dword_506528 = v10;
         pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
       }
@@ -14045,7 +14045,7 @@
       dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
       pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
     }
-    if ( !dword_506520 || dword_506528 < 1 )
+    if ( !awards_count || dword_506528 < 1 )
     {
       dword_506528 = 0;
       dword_50651C = 0;
@@ -14055,16 +14055,16 @@
   dword_50652C = 0;
   dword_506544 = 0;
   dword_506548 = 0;
-  dword_506520 = 0;
+  awards_count = 0;
   dword_506530 = 0;
   dword_506534 = 0;
   dword_506538 = 0;
   dword_50653C = 0;
   dword_506540 = 0;
-  while ( v12 < dword_506524 )
-  {
-    v13 = pStru179.field_0[v12];
-    ++dword_506520;
+  while ( v12 < awards_count2 )
+  {
+    v13 = achievedAwardsIndex[v12];
+    ++awards_count;
     //v14 = (&dword_723718_autonote_related)[8 * v13];
 	v14 = pAutonoteTxt[v13-1].pText;
     //a1.DrawText(pAutonoteFont, 1, 0, 0, (&dword_723718_autonote_related)[8 * v13], 0, 0, 0);
@@ -17657,88 +17657,45 @@
 }
 
 //----- (00419100) --------------------------------------------------------
-int __cdecl sub_419100()
-{
-  Player *pPlayer; // esi@1
-  int v1; // ebx@1
-  unsigned __int8 *v2; // esi@1
-  int v3; // eax@4
-  int result; // eax@6
-  int v5; // esi@6
-  unsigned __int8 v6; // zf@6
-  unsigned __int8 v7; // sf@6
-  int v8; // edx@7
-  int v9; // ecx@7
-  unsigned __int8 v10; // of@7
-  stru179 *v11; // edi@9
-  int v12; // edx@11
-  char *v13; // [sp+Ch] [bp-8h]@2
-  signed int v14; // [sp+Ch] [bp-8h]@9
-  int i; // [sp+10h] [bp-4h]@10
-
-  pPlayer = pPlayers[uActiveCharacter];
-  memset(&pStru179, 0, 0xFA0u);
-  memset(pTmpBuf2, 0, 0x7D0u);
-  v1 = 0;
-  dword_506544 = 0;
-  dword_506548 = 0;
-  dword_506520 = 0;
-  dword_50651C = 0;
-  dword_506528 = 0;
-  v2 = (unsigned __int8 *)pPlayer->_guilds_member_bits;
-  do
-  {
-    v13 = (char *)pAwards[v1].pText;//dword_723E80_award_related[2 * v1];
-    if ( (unsigned __int16)_449B57_test_bit(v2, v1) && v13 )
-    {
-      v3 = dword_506520++;
-      pStru179.field_0[v3] = v1;
-    }
-    ++v1;
-  }
-  while ( v1 < 105 );
-  result = dword_506520;
-  v5 = 0;
-  v6 = dword_506520 == 0;
-  v7 = dword_506520 < 0;
-  dword_506524 = dword_506520;
-  dword_506520 = 0;
-  if ( !(v7 | v6) )
-  {
-    do
-    {
-      v8 = rand() % 16;
-      result = dword_506524;
-      v9 = dword_506524 + v5++;
-      v10 = v5 > dword_506524;//__OFSUB__(v5, dword_506524);
-      v7 = v5 - dword_506524 < 0;
-      pStru179.field_0[v9] = v8;
-    }
-    while ( v7 ^ v10 );
-    if ( result > 0 )
-    {
-      v14 = 1;
-      v11 = &pStru179;
-      do
-      {
-        for ( i = v14; i < result; ++i )
-        {
-          v12 = pStru179.field_0[i];
-          //if ( dword_723E84[2 * v12] < dword_723E84[2 * v11->field_0[0]] )
-		  if(pAwards[v12-1].uSort < pAwards[v11->field_0[0]].uSort)
-          {
-            pStru179.field_0[i] = v11->field_0[0];
-            v11->field_0[0] = v12;
-          }
-        }
-        ++v14;
-        v11 = (stru179 *)((char *)v11 + 4);
-      }
-      while ( v14 - 1 < result );
-    }
-  }
-  return result;
-}
+void FillAwardsData()
+    {
+    Player *pPlayer; // esi@1
+
+    pPlayer = pPlayers[uActiveCharacter];
+    memset(&achievedAwardsIndex, 0, 4000);
+    memset(pTmpBuf2, 0, 0x7D0u);
+    dword_506544 = 0;
+    dword_506548 = 0;
+    awards_count = 0;
+    dword_50651C = 0;
+    dword_506528 = 0;
+    for(int i=0; i<105; ++i)
+        {
+        if ( _449B57_test_bit((unsigned char*)&pPlayer->_guilds_member_bits, i) && pAwards[i].pText )
+            achievedAwardsIndex[awards_count++] = i;
+        }
+    awards_count2 = awards_count;
+    awards_count = 0;
+    //sort awards index 
+    if ( awards_count2>0 )
+        {
+        for(int i=0; i<awards_count2; ++i)
+            achievedAwardsIndex[awards_count2 + i] = rand() % 16;
+
+        for(int i=1; i<awards_count2-1; ++i)
+            {
+            for (int j = i; j < awards_count2-1; ++j )
+                {
+                int tmp=achievedAwardsIndex[j];
+                if(pAwards[j].uSort < pAwards[i].uSort)
+                    {
+                    achievedAwardsIndex[j] = achievedAwardsIndex[i];
+                    achievedAwardsIndex[i] = tmp;
+                    }
+                }
+            }
+        }
+    }
 
 
 //----- (00419220) --------------------------------------------------------
--- a/mm7_6.cpp	Fri Mar 01 23:43:21 2013 +0400
+++ b/mm7_6.cpp	Sat Mar 02 01:42:05 2013 +0400
@@ -7232,7 +7232,7 @@
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           goto play_sound_and_continue;
         HIDWORD(v733) = 0;
-        memset(&pStru179, 0, 0xFA0u);
+        memset(&achievedAwardsIndex, 0, 4000);
         _this = 0;
         v605 = (char *)pParty->pHirelings;
         do
@@ -7240,7 +7240,7 @@
           if ( *(int *)v605)
           {
             v606 = HIDWORD(v733)++;
-            pStru179.field_0[v606] = (int)((char *)&_this->uItemID + 1);
+            achievedAwardsIndex[v606] = (int)((char *)&_this->uItemID + 1);
           }
           _this = (ItemGen *)((char *)_this + 1);
           v605 += 76;
--- a/mm7_data.cpp	Fri Mar 01 23:43:21 2013 +0400
+++ b/mm7_data.cpp	Sat Mar 02 01:42:05 2013 +0400
@@ -48,8 +48,8 @@
 #include "stru279.h"
 stru279 stru_51076C;
 
-#include "stru179.h"
-stru179 pStru179;
+
+int achievedAwardsIndex[1000];
 
 #include "stru123.h"
 stru123 stru_5E4C90;
@@ -1832,8 +1832,8 @@
 Texture *dword_50640C[12]; // weak
 unsigned int uTextureID_506438;
 int dword_50651C; // weak
-int dword_506520; // weak
-int dword_506524; // weak
+int awards_count; // weak
+int awards_count2; // weak
 int dword_506528; // weak
 int dword_50652C; // weak
 int dword_506530; // weak
--- a/mm7_data.h	Fri Mar 01 23:43:21 2013 +0400
+++ b/mm7_data.h	Sat Mar 02 01:42:05 2013 +0400
@@ -1155,8 +1155,8 @@
 extern Texture *dword_50640C[]; // weak
 extern unsigned int uTextureID_506438;
 extern int dword_50651C; // weak
-extern int dword_506520; // weak
-extern int dword_506524; // weak
+extern int awards_count; // weak
+extern int awards_count2; // weak
 extern int dword_506528; // weak
 extern int dword_50652C; // weak
 extern int dword_506530; // weak
@@ -1410,7 +1410,7 @@
 extern char *pClassTXT_Raw;
 extern char *pStatsTXT_Raw;
 extern char *pSkillDescTXT_Raw;
-
+extern int achievedAwardsIndex[1000];
 extern struct FactionTable *pFactionTable;
 extern char byte_5C8D1A[]; // weak
 
@@ -1870,13 +1870,13 @@
 char __cdecl CharacterUI_SkillsTab_ShowHint();
 char __cdecl CharacterUI_StatsTab_ShowHint();
 char __fastcall CharacterUI_StatsTab_Draw(unsigned int uPlayerID); // idb
-int __cdecl sub_419100();
+void FillAwardsData();
 void __cdecl sub_419220();
 void __cdecl sub_419379();
 void __cdecl CharacterUI_SkillScreen_Draw();
 void __cdecl sub_4196A0();
 char __fastcall CharacterUI_SkillsTab_Draw(unsigned int uPlayerID); // idb
-unsigned int __fastcall CharacterUI_AwardsTab_Draw(unsigned int uPlayerID); // idb
+void CharacterUI_AwardsTab_Draw(unsigned int uPlayerID); // idb
 unsigned int __fastcall GetSizeInInventorySlots(unsigned int uNumPixels);
 void __fastcall CharacterUI_InventoryTab_Draw(unsigned int uPlayerID, char a2);
 void __cdecl draw_leather();
@@ -2045,7 +2045,7 @@
 char *__fastcall sub_44987B(const char *pMapName, unsigned int uStartingPointType); // idb
 void __thiscall TeleportToStartingPoint(unsigned int uPointType); // idb
 __int16 __fastcall sub_449A49_door_switch_animation(unsigned int uDoorID, int a2); // idb
-unsigned int __fastcall _449B57_test_bit(unsigned __int8 *a1, __int16 a2);
+bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2);
 void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle); // idb
 void __cdecl sub_44A56A();
 void __fastcall ShowStatusBarString(const char *pString, unsigned int uNumSeconds);
--- a/stru179.h	Fri Mar 01 23:43:21 2013 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-#pragma once
-
-
-/*  172 */
-#pragma pack(push, 1)
-struct stru179
-{
-  int field_0[1000];
-};
-#pragma pack(pop)
-
-extern struct stru179 pStru179;
\ No newline at end of file