changeset 949:c0d0656aa662

Awards
author Nomad
date Wed, 01 May 2013 20:04:24 +0200
parents 5a2dbb00c399
children 840b78f6c2d3
files Arcomage.cpp Awards.h GUIWindow.cpp Game.cpp NPC.cpp Party.h Player.cpp Player.h Render.cpp UIBooks.cpp UICharacter.cpp UIHouses.cpp UIMainMenu.cpp UIOptions.cpp UIPartyCreation.cpp UIPopup.cpp UIRest.cpp UISaveLoad.cpp UiGame.cpp Viewport.cpp mm7_1.cpp mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp mm7_6.cpp mm7_data.cpp mm7_data.h
diffstat 28 files changed, 535 insertions(+), 537 deletions(-) [+]
line wrap: on
line diff
--- a/Arcomage.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/Arcomage.cpp	Wed May 01 20:04:24 2013 +0200
@@ -5710,13 +5710,13 @@
     do
     {
       if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v11, 1) )
-        _449B7E_toggle_bit((unsigned char *)v11, 103, 1u);
+        _449B7E_toggle_bit((unsigned char *)v11, PLAYER_GUILD_BITS__ARCOMAGE_WIN, 1);
       v11 += 6972;
     }
     while ( (signed int)v11 < (signed int)((char *)&pParty->StandartItemsInShops[36] + 2) );
-    ++pParty->field_874;
-    if ( pParty->field_874 > 1000000 )
-      pParty->field_874 = 1000000;
+    ++pParty->uNumArcomageWins;
+    if ( pParty->uNumArcomageWins > 1000000 )
+      pParty->uNumArcomageWins = 1000000;
   }
   else
   {
@@ -5724,13 +5724,13 @@
     do
     {
       if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v12, 1) )
-        _449B7E_toggle_bit((unsigned char *)v12, 104, 1u);
+        _449B7E_toggle_bit((unsigned char *)v12, PLAYER_GUILD_BITS__ARCOMAGE_LOSE, 1);
       v12 += 6972;
     }
     while ( (signed int)v12 < (signed int)((char *)&pParty->StandartItemsInShops[36] + 2) );
-    ++pParty->field_878;
-    if ( pParty->field_878 > 1000000 )
-      pParty->field_878 = 1000000;
+    ++pParty->uNumArcomageLoses;
+    if ( pParty->uNumArcomageLoses > 1000000 )
+      pParty->uNumArcomageLoses = 1000000;
   }
   return 0;
 }
--- a/Awards.h	Wed May 01 17:31:10 2013 +0200
+++ b/Awards.h	Wed May 01 20:04:24 2013 +0200
@@ -5,8 +5,123 @@
 #pragma pack(push, 1)
 struct Award
 {
-  const char *pText;
-  unsigned int uSort;
+  const char   *pText;
+  unsigned int  uPriority;
 };
 #pragma pack(pop)
-extern Award pAwards[104];
\ No newline at end of file
+extern Award pAwards[104];
+
+
+
+enum AwardType: unsigned __int32
+{
+    Award_Invalid = 0
+  , Award_Fine = 1
+  , Award_EmeraldIsle_CompletedMainQuest = 2
+  , Award_EmeraldIsle_FoundMissingCompetitors = 3
+  , Award_Harmondale_CastleCleared = 4
+  , Award_BarrowDowns_RescuedMiners = 5
+  , Award_Erathia_RescuedLorenSteel = 6
+  , Award_Avlee_BroughtFakeLorenSteelToErathia = 7
+  , Award_Avlee_BroughtFortRiverstridePlans = 8
+  , Award_Erathia_DeliveredFakePlansToElves = 9
+  , Award_Promotion_Rogue = 10
+  , Award_Promotion_Rogue_Honorary = 11
+  , Award_Promotion_Spy = 12
+  , Award_Promotion_Spy_Honorary = 13
+  , Award_Promotion_Assassin = 14
+  , Award_Promotion_Assassin_Honorary = 15
+  , Award_Promotion_Chevalier = 16
+  , Award_Promotion_Chevalier_Honorary = 17
+  , Award_Promotion_Champion = 18
+  , Award_Promotion_Champion_Honorary = 19
+  , Award_Promotion_BlackKnight = 20
+  , Award_Promotion_BlackKnight_Honorary = 21
+  , Award_Promotion_Initiate = 22
+  , Award_Promotion_Initiate_Honorary = 23
+  , Award_Promotion_Master = 24
+  , Award_Promotion_Master_Honorary = 25
+  , Award_Promotion_Ninja = 26
+  , Award_Promotion_Ninja_Honorary = 27
+  , Award_Promotion_Hunter = 28
+  , Award_Promotion_Hunter_Honorary = 29
+  , Award_Promotion_RangerLord = 30
+  , Award_Promotion_RangerLord_Honorary = 31
+  , Award_Promotion_BountyHunter = 32
+  , Award_Promotion_BountyHunter_Honorary = 33
+  , Award_Promotion_WarriorMage = 34
+  , Award_Promotion_WarriorMage_Honorary = 35
+  , Award_Promotion_MasterArcher = 36
+  , Award_Promotion_MasterArcher_Honorary = 37
+  , Award_Promotion_Sniper = 38
+  , Award_Promotion_Sniper_Honorary = 39
+  , Award_Promotion_Crusader = 40
+  , Award_Promotion_Crusader_Honorary = 41
+  , Award_Promotion_Hero = 42
+  , Award_Promotion_Hero_Honorary = 43
+  , Award_Promotion_Villian = 44
+  , Award_Promotion_Villian_Honorary = 45
+  , Award_Celestia_SurvivedWallOfMist = 46
+  , Award_47 = 47
+  , Award_KilledXenofex = 48
+  , Award_Tatalia_SolvedWineCellarMystery = 49
+  , Award_Membership_ElementalGuilds = 50
+  , Award_Membership_SelfGuilds = 51
+  , Award_Membership_AirGuild = 52
+  , Award_Membership_EarthGuild = 53
+  , Award_Membership_FireGuild = 54
+  , Award_Membership_WaterGuild = 55
+  , Award_Membership_BodyGuild = 56
+  , Award_Membership_MindGuild = 57
+  , Award_Membership_SpiritGuild = 58
+  , Award_Membership_LightGuild = 59
+  , Award_Membership_DarkGuild = 60
+  , Award_Avlee_RetrievedForestHeart = 61
+  , Award_Promotion_Priest = 62
+  , Award_Promotion_Priest_Honorary = 63
+  , Award_Promotion_PriestOfLight = 64
+  , Award_Promotion_PriestOfLight_Honorary = 65
+  , Award_Promotion_PriestOfDark = 66
+  , Award_Promotion_PriestOfDark_Honorary = 67
+  , Award_Promotion_GreatDruid = 68
+  , Award_Promotion_GreatDruid_Honorary = 69
+  , Award_Promotion_ArchDruid = 70
+  , Award_Promotion_ArchDruid_Honorary = 71
+  , Award_Promotion_Warlock = 72
+  , Award_Promotion_Warlock_Honorary = 73
+  , Award_Promotion_Wizard = 74
+  , Award_Promotion_Wizard_Honorary = 75
+  , Award_Promotion_Archmage = 76
+  , Award_Promotion_Archmage_Honorary = 77
+  , Award_Promotion_Lich = 78
+  , Award_Promotion_Lich_Honorary = 79
+  , Award_ThePit_RetrievedSoulJars = 80
+  , Award_Celestia_KilledTolberti = 81
+  , Award_ThePit_ClearedKlankersLab = 82
+  , Award_ThePit_KilledRobertTheWise = 83
+  , Award_ThePit_SurvivedBreedingZone = 84
+  , Award_Deaths = 85
+  , Award_BountiesCollected = 86
+  , Award_PrisonTerms = 87
+  , Award_Arena_PageWins = 88
+  , Award_Arena_SquireWins = 89
+  , Award_Arena_KnightWins = 90
+  , Award_Arena_LordWins = 91
+  , Award_Harmondale_ReturnedLanterOfLight = 92
+  , Award_Nighon_RetrievedHaldarsRemains = 93
+  , Award_Harmondale_ReturnedDavriksSignetRing = 94
+  , Award_Erathia_ReturnedParsonsQuill = 95
+  , Award_RetrievedFaeriePipes = 96
+  , Award_BarrowDowns_KilledTroglodytesInLowerCity = 97
+  , Award_Deyja_KilledAllGriffins = 98
+  , Award_Bracada_RetrievedSeasonsStole = 99
+  , Award_Avlee_PlacedThreeStatuettes = 100
+  , Award_101 = 101
+  , Award_ArcomageChampion = 102
+  , Award_ArcomageWins = 103
+  , Award_ArcomageLoses = 104
+
+};
+extern AwardType achieved_awards[1000];
+extern int       num_achieved_awards;
+extern int       num_achieved_awards_2;
\ No newline at end of file
--- a/GUIWindow.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/GUIWindow.cpp	Wed May 01 20:04:24 2013 +0200
@@ -21,6 +21,7 @@
 #include "UIHouses.h"
 #include "texts.h"
 #include "Autonotes.h"
+#include "Awards.h"
 
 
 #include "mm7_data.h"
@@ -137,7 +138,7 @@
       v12 = v20 * LOBYTE(v1->uFontHeight) + 40;
       v13 = *v16;
       ++v20;
-      v14 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(
+      v14 = TargetColor(
               (unsigned __int8)*(v8 - 1),
               (unsigned __int8)*v8,
               (unsigned __int8)v8[1]);
@@ -224,7 +225,7 @@
   }
 
   pRenderer->DrawTextureTransparent(uFrameX + 24, uFrameY + 24, v13);
-  v16 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v16 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   sprintf(pTmpBuf, "\f%05d", v16);
   sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[429], pPlayer->pName, pClassNames[pPlayer->classType]);
   strcat(pTmpBuf, pTmpBuf2);
@@ -258,7 +259,7 @@
     {
       v35 = buff->uExpireTime - pParty->uTimePlayed;
       v36 = uFramesetIDa++ * pFontComic->uFontHeight + 134;
-      v38 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(
+      v38 = TargetColor(
               _4E2AD8_ui_colors[i * 3],
               _4E2AD8_ui_colors[i * 3 + 1],
               _4E2AD8_ui_colors[i * 3 + 2]);
@@ -470,10 +471,10 @@
   InitializeBookFonts();
   v1->CreateButton(0x1DBu, 0x1BDu, 0x9Eu, 0x22u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], 0); // Close
   pCurrentScreen = SCREEN_BOOKS;
-  awards_count2 = 0;
+  num_achieved_awards_2 = 0;
   dword_506528 = 0;
   dword_50651C = 0;
-  awards_count = 0; 
+  num_achieved_awards = 0; 
   switch (v1->par1C)
       {
   case WINDOW_Lloyd:{
@@ -562,20 +563,20 @@
                                      pTex_tab_an_7b__zoot_on->uTextureHeight, pTex_tab_an_7b__zoot_on->uTextureHeight,
                                      1, 0, UIMSG_AutonotesBook, 0xAu, 0, pGlobalTXT_LocalizationStrings[193],// "Scroll Down"
                                      pTex_tab_an_7b__zoot_on, 0);
-      awards_count = 0;
-      memset(&achievedAwardsIndex, 0, 4000);
+      num_achieved_awards = 0;
+      memset(achieved_awards, 0, 4000);
       for ( i = dword_506528; i < 512; ++i )
           {
           v14 = (char *)pQuestTable[i-1];//(&dword_722F10)[4 * i];
           if ( _449B57_test_bit(pParty->_quest_bits, i) && v14 )
               {
-              v15 = awards_count++;
-              achievedAwardsIndex[v15] = i;
+              v15 = num_achieved_awards++;
+              achieved_awards[v15] = (AwardType)i;
               }
           }
-      v12 = awards_count;
-      awards_count = 0;
-      awards_count2 = v12;
+      v12 = num_achieved_awards;
+      num_achieved_awards = 0;
+      num_achieved_awards_2 = v12;
       }
       break;
   case WINDOW_AutonotesBook:
@@ -610,7 +611,7 @@
 
       v9 = pBtn_Autonotes_Instructors;
       v10 = dword_506528;
-      awards_count = 0;
+      num_achieved_awards = 0;
       while ( v10 < 196 )
           {
           if ( dword_506568 == pAutonoteTxt[v10-1].eType)//dword_72371C[2 * v10] )
@@ -621,8 +622,8 @@
                   {
                   if ( _449B57_test_bit(pParty->_autonote_bits, v10) && v25 )
                       {
-                      v11 = awards_count++;
-                      achievedAwardsIndex[v11] = (signed __int16)v10;
+                      v11 = num_achieved_awards++;
+                      achieved_awards[v11] = (AwardType)v10;
                       }
                   }
               }
@@ -679,7 +680,7 @@
       pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1,  pTex_tab_an_6b__zoom_on->uTextureWidth,  pTex_tab_an_6b__zoom_on->uTextureHeight, 1, 0, UIMSG_AutonotesBook, 11, 0, pGlobalTXT_LocalizationStrings[192], pTex_tab_an_6b__zoom_on, 0);
       pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_tab_an_7b__zoot_on->uTextureHeight, pTex_tab_an_7b__zoot_on->uTextureHeight, 1, 0, UIMSG_AutonotesBook, 10, 0, pGlobalTXT_LocalizationStrings[193], pTex_tab_an_7b__zoot_on, 0);
 
-      awards_count = 0;
+      num_achieved_awards = 0;
       v26.uFrameX = 48;
       v26.uFrameY = 70;
       v26.uFrameWidth = 360;
@@ -688,7 +689,7 @@
       v26.uFrameZ = 407;
       v26.uFrameHeight = v2 * 264 / v2;
       v26.uFrameW = v26.uFrameHeight + 69;
-      memset(&achievedAwardsIndex, 0, 4000);
+      memset(&achieved_awards, 0, 4000);
       memset(byte_5C6D50, 0, 0x64u);
       if ( dword_506528 < 29 )
           {
@@ -706,10 +707,10 @@
                       v8 = v7 + 1;
                       if ( (signed int)v7 + 1 > 0 )
                           {
-                          memset32((char *)&achievedAwardsIndex + 4 * awards_count , i, v8);
+                          memset32((char *)&achieved_awards + 4 * num_achieved_awards , i, v8);
                           do
                               {
-                              LODWORD(v7) = awards_count++;
+                              LODWORD(v7) = num_achieved_awards++;
                               byte_5C6D50[(int)v7] = BYTE4(v7);
                               ++HIDWORD(v7);
                               }
@@ -1005,8 +1006,8 @@
   memcpy(&pWindow, this, sizeof(pWindow));
   pWindow.uFrameWidth -= 18;
   pWindow.uFrameZ -= 18;
-  pWhiteColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  pColor2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u);
+  pWhiteColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  pColor2 = TargetColor(0x15u, 0x99u, 0xE9u);
   pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
   pRenderer->DrawTextureTransparent(0x1D4u, 0, &pIcons_LOD->pTextures[uTextureID_right_panel_loop]);
   if ( pDialogueNPCCount != uNumDialogueNPCPortraits || !uHouse_ExitPic )
@@ -1265,7 +1266,7 @@
     sprintf(pTmpBuf2, "%d %s ", v17, v11);
     strcat(pTmpBuf, pTmpBuf2);
   }
-  v12 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v12 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   v13 = pFontArrus->CalcTextHeight(pTmpBuf, v15, 0, 0);
   v15->DrawTitleText(pFontArrus, 0, (212 - v13) / 2 + 101, v12, pTmpBuf, 3u);
 }
--- a/Game.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/Game.cpp	Wed May 01 20:04:24 2013 +0200
@@ -199,17 +199,17 @@
   if (render_framerate)
   {
     sprintf(pTmpBuf, "FPS: % .4f", framerate);
-    pPrimaryWindow->DrawText(pFontArrus, 494, 0, GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0), pTmpBuf, 0, 0, 0);
+    pPrimaryWindow->DrawText(pFontArrus, 494, 0, TargetColor(0, 0, 0), pTmpBuf, 0, 0, 0);
   }
 
   if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
   {
     auto sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
     sprintf(pTmpBuf, "Party Sector ID:        %u/%u\n", sector_id, pIndoor->uNumSectors);
-    pPrimaryWindow->DrawText(pFontArrus, 16, 16, GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF);
+    pPrimaryWindow->DrawText(pFontArrus, 16, 16, TargetColor(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF);
   }
   sprintf(pTmpBuf, "Party Position:         % d % d % d", pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
-  pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16, GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF);
+  pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16, TargetColor(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF);
   
   if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
   {
@@ -224,7 +224,7 @@
     auto floor_level = ODM_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z, 0, &on_water, &_a6, false);
     sprintf(pTmpBuf, "ODM_GetFloorLevel: %d   on_water: %s    a6 = %d\n", floor_level, on_water ? "true" : "false", _a6);
   }
-  pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16 + 16, GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF);
+  pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16 + 16, TargetColor(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF);
 
   GUI_UpdateWindows();
   pParty->UpdatePlayersAndHirelingsEmotions();
--- a/NPC.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/NPC.cpp	Wed May 01 20:04:24 2013 +0200
@@ -958,8 +958,7 @@
 
 //----- (004763E0) --------------------------------------------------------
 void  InitializeAwards()
-	{
-
+{
 	int i;
 	char* test_string;
 	unsigned char c;
@@ -974,7 +973,7 @@
 	pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0);
 	strtok(pAwardsTXT_Raw, "\r");
 
-	for (i=1; i<104; ++i)
+	for (i=1; i<105; ++i)
 		{
 		test_string = strtok(NULL, "\r") + 1;
 		break_loop = false;
@@ -997,7 +996,7 @@
 				if (decode_step==1)
 					pAwards[i].pText=RemoveQuotes(test_string);
 				else if (decode_step==2)
-					pAwards[i].uSort=atoi(test_string);
+					pAwards[i].uPriority = atoi(test_string);
 				}
 			else
 				{ 
@@ -1007,7 +1006,6 @@
 			test_string=tmp_pos+1;
 			} while ((decode_step<3)&&!break_loop);
 		}
-
 	}
 // 7241C8: using guessed type int dword_7241C8;
 
--- a/Party.h	Wed May 01 17:31:10 2013 +0200
+++ b/Party.h	Wed May 01 20:04:24 2013 +0200
@@ -252,8 +252,8 @@
   unsigned char _autonote_bits[12];
   char field_80A[74];
   char field_854[32];
-  int field_874;
-  int field_878;
+  int uNumArcomageWins;
+  int uNumArcomageLoses;
   unsigned int bTurnBasedModeOn;
   int field_880;
   int uFlags2;
--- a/Player.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/Player.cpp	Wed May 01 20:04:24 2013 +0200
@@ -3281,7 +3281,7 @@
   unsigned int result; // eax@2
 
   if ( CanTrainToNextLevel() )
-    result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
+    result = TargetColor(0, 0xFFu, 0);
   else
     result = 0;
   return result;
@@ -6919,9 +6919,9 @@
   __int16 uGreen; // [sp+8h] [bp-8h]@1
   __int16 uRed; // [sp+Ch] [bp-4h]@1
 
-  uRed = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x23u, 0);
-  uGreen = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
-  uWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+  uRed = TargetColor(0xFFu, 0x23u, 0);
+  uGreen = TargetColor(0, 0xFFu, 0);
+  uWhite = TargetColor(0xFFu, 0xFFu, 0xFFu);
   pBaseAttrValue = StatTable[GetRace()][uStat].uBaseValue;
 
   switch (uStat)
--- a/Player.h	Wed May 01 17:31:10 2013 +0200
+++ b/Player.h	Wed May 01 20:04:24 2013 +0200
@@ -14,7 +14,9 @@
 #define PLAYER_BUFF_REGENERATION    12
 
 
-#define PLAYER_GUID_BITS__SPIRIT_MEMBERSHIP 58
+#define PLAYER_GUILD_BITS__SPIRIT_MEMBERSHIP 58
+#define PLAYER_GUILD_BITS__ARCOMAGE_WIN      103
+#define PLAYER_GUILD_BITS__ARCOMAGE_LOSE     104
 
 
 /*  301 */
--- a/Render.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/Render.cpp	Wed May 01 20:04:24 2013 +0200
@@ -9427,7 +9427,7 @@
         v11 = v20 - v21;
       }
     }
-    teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu);
+    teal = TargetColor(0, 0xFFu, 0xFFu);
     if ( v11 > 0 )
     {
       v22 = a4a;
--- a/UIBooks.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/UIBooks.cpp	Wed May 01 20:04:24 2013 +0200
@@ -409,7 +409,7 @@
     v0 = pViewport->uViewportTL_X + 398;
   }
   pRenderer->DrawTextureTransparent(v0, v11, v13);
-  if ( dword_506544 || dword_506528 + awards_count >= awards_count2 )
+  if ( dword_506544 || dword_506528 + num_achieved_awards >= num_achieved_awards_2 )
   {
     v14 = pTex_tab_an_7a__zoot_off;
     v12 = pViewport->uViewportTL_Y + 38;
@@ -424,7 +424,7 @@
   pRenderer->DrawTextureTransparent(v1, v12, v14);
   if ( !byte_5C6D50[dword_506528] )
   {
-    v2 = achievedAwardsIndex[dword_506528];
+    v2 = achieved_awards[dword_506528];
     a1.uFrameWidth = game_viewport_width;
     a1.uFrameX = game_viewport_x;
     a1.uFrameY = game_viewport_y;
@@ -443,12 +443,12 @@
   a1.uFrameZ = 407;
   a1.uFrameHeight = v4 * 264 / v4;
   a1.uFrameW = a1.uFrameHeight + 69;
-  if ( dword_506544 && dword_506528 + awards_count < awards_count2 )
+  if ( dword_506544 && dword_506528 + num_achieved_awards < num_achieved_awards_2 )
   {
     pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
     v5 = dword_50651C++;
-    dword_506528 += awards_count;
-    byte_506130[v5] = awards_count;
+    dword_506528 += num_achieved_awards;
+    byte_506130[v5] = num_achieved_awards;
   }
   if ( dword_506548 && dword_50651C )
   {
@@ -456,15 +456,15 @@
     --dword_50651C;
     dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
   }
-  if ( !awards_count || dword_506528 < 1 )
+  if ( !num_achieved_awards || dword_506528 < 1 )
   {
     dword_506528 = 0;
     dword_50651C = 0;
   }
   dword_506544 = 0;
-  v6 = achievedAwardsIndex[dword_506528];
+  v6 = achieved_awards[dword_506528];
   dword_506548 = 0;
-  awards_count = 0;
+  num_achieved_awards = 0;
   //v7 = *pStorylineText->StoreLine[v6].pText;//*(&pStorylineText->field_0 + 3 * v6);
   v7 = (int)pStorylineText->StoreLine[v6].pText;//*(&pStorylineText->field_0 + 3 * v6);
   v8 = BuilDialogueString(
@@ -478,7 +478,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);
-    ++awards_count;
+    ++num_achieved_awards;
   }
   return (char)v8;
 }
@@ -515,7 +515,7 @@
     v0 = pViewport->uViewportTL_X + 398;
   }
   pRenderer->DrawTextureTransparent(v0, v8, v10);
-  if ( dword_506544 || dword_506528 + awards_count >= awards_count2 )
+  if ( dword_506544 || dword_506528 + num_achieved_awards >= num_achieved_awards_2 )
   {
     v11 = pTex_tab_an_7a__zoot_off;
     v9 = pViewport->uViewportTL_Y + 38;
@@ -541,12 +541,12 @@
   a1.uFrameHeight = 264;
   a1.uFrameZ = 407;
   a1.uFrameW = 333;
-  if ( dword_506544 && dword_506528 + awards_count < awards_count2 )
+  if ( dword_506544 && dword_506528 + num_achieved_awards < num_achieved_awards_2 )
   {
     pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
     v2 = dword_50651C++;
-    dword_506528 += awards_count;
-    byte_506130[v2] = awards_count;
+    dword_506528 += num_achieved_awards;
+    byte_506130[v2] = num_achieved_awards;
   }
   if ( dword_506548 && dword_50651C )
   {
@@ -554,7 +554,7 @@
     --dword_50651C;
     dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
   }
-  if ( !awards_count || (v3 = dword_506528, dword_506528 < 1) )
+  if ( !num_achieved_awards || (v3 = dword_506528, dword_506528 < 1) )
   {
     v3 = 0;
     dword_50651C = 0;
@@ -562,11 +562,11 @@
   }
   dword_506544 = 0;
   dword_506548 = 0;
-  awards_count = 0;
-  while ( v3 < awards_count2 )
+  num_achieved_awards = 0;
+  while ( v3 < num_achieved_awards_2 )
   {
-    v4 = achievedAwardsIndex[v3];
-    ++awards_count;
+    v4 = achieved_awards[v3];
+    ++num_achieved_awards;
     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);
@@ -633,7 +633,7 @@
     v0 = pViewport->uViewportTL_X + 398;
   }
   pRenderer->DrawTextureTransparent(v0, v17, v24);
-  if ( dword_506544 || dword_506528 + awards_count >= awards_count2 )
+  if ( dword_506544 || dword_506528 + num_achieved_awards >= num_achieved_awards_2 )
   {
     v25 = pTex_tab_an_7a__zoot_off;
     v18 = pViewport->uViewportTL_Y + 38;
@@ -807,10 +807,10 @@
   a1.uFrameW = 333;
   if ( v31 )
   {
-    awards_count2 = 0;
+    num_achieved_awards_2 = 0;
     dword_506528 = 0;
     dword_50651C = 0;
-    awards_count = 0;
+    num_achieved_awards = 0;
     v8 = 0;
     do
     {
@@ -823,25 +823,25 @@
         {
           if ( (unsigned __int16)_449B57_test_bit(pParty->_autonote_bits, v8) && v32 )
           {
-            v9 = awards_count++;
-            achievedAwardsIndex[v9] = (signed __int16)v8;
+            v9 = num_achieved_awards++;
+            achieved_awards[v9] = (AwardType)v8;
           }
         }
       }
       ++v8;
     }
     while ( v8 < 196 );
-    awards_count2 = awards_count;
+    num_achieved_awards_2 = num_achieved_awards;
   }
   else
   {
     if ( dword_506544 )
     {
-      v10 = awards_count + dword_506528;
-      if ( awards_count + dword_506528 < awards_count2 )
+      v10 = num_achieved_awards + dword_506528;
+      if ( num_achieved_awards + dword_506528 < num_achieved_awards_2 )
       {
         v11 = dword_50651C++;
-        byte_506130[v11] = awards_count;
+        byte_506130[v11] = num_achieved_awards;
         dword_506528 = v10;
         pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
       }
@@ -852,7 +852,7 @@
       dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
       pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
     }
-    if ( !awards_count || dword_506528 < 1 )
+    if ( !num_achieved_awards || dword_506528 < 1 )
     {
       dword_506528 = 0;
       dword_50651C = 0;
@@ -862,16 +862,16 @@
   dword_50652C = 0;
   dword_506544 = 0;
   dword_506548 = 0;
-  awards_count = 0;
+  num_achieved_awards = 0;
   dword_506530 = 0;
   dword_506534 = 0;
   dword_506538 = 0;
   dword_50653C = 0;
   dword_506540 = 0;
-  while ( v12 < awards_count2 )
+  while ( v12 < num_achieved_awards_2 )
   {
-    v13 = achievedAwardsIndex[v12];
-    ++awards_count;
+    v13 = achieved_awards[v12];
+    ++num_achieved_awards;
     //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);
@@ -1199,8 +1199,8 @@
         }
     else
         {
-        black = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0);
-        teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu);
+        black = TargetColor(0, 0, 0);
+        teal = TargetColor(0, 0xFFu, 0xFFu);
         v7 = pIndoor->pMapOutlines;
         uNumBlueFacesInBLVMinimap = 0;
         v8 = pIndoor->pMapOutlines->uNumOutlines == 0;
@@ -1381,7 +1381,7 @@
             }
         pRenderer->DrawTransparentRedShade(v47, v49, (Texture *)(pTextureIDs_pMapDirs[v50] != -1 ? (int)&pIcons_LOD->pTextures[pTextureIDs_pMapDirs[v50]] : 0));
         }
-    result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+    result = TargetColor(0xFFu, 0xFFu, 0xFFu);
     v95 = 0;
     v86 = result;
     if ( (signed int)uNumLevelDecorations > 0 )
@@ -1448,7 +1448,7 @@
         teal = v60 >> 16;
         v63 = (signed __int16)v61;
         a4a = map_texture_16;
-        result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xCu, 0xCu, 0xCu);
+        result = TargetColor(0xCu, 0xCu, 0xCu);
         screenCenter_X = 0;
         for ( i = result; screenCenter_X < (signed int)v95; result = screenCenter_X )
             {
--- a/UICharacter.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/UICharacter.cpp	Wed May 01 20:04:24 2013 +0200
@@ -143,11 +143,11 @@
     char *v92; // [sp+3Ch] [bp-4h]@114
 
     v1 = uPlayerID;
-    a5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-    v84 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xAFu, 0xFFu);
+    a5 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+    v84 = TargetColor(0, 0xAFu, 0xFFu);
     v85 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem;
-    v86 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
-    v79 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
+    v86 = TargetColor(0xFFu, 0, 0);
+    v79 = TargetColor(0, 0xFFu, 0);
     pPlayer = &pParty->pPlayers[v1-1];
     v3 = pIcons_LOD->LoadTexture("fr_skill", TEXTURE_16BIT_PALETTE);
     pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(v3));
@@ -218,7 +218,7 @@
             if ( HIBYTE(v87) & 1 )
                 {
                 if ( !v15 )
-                    v15 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+                    v15 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
                 v54 = uY;
                 v50 = v58;
                 v46 = pGlobalTXT_LocalizationStrings[96];
@@ -237,7 +237,7 @@
                     v16 = pGlobalTXT_LocalizationStrings[433];
                 v88 = v16;
                 if ( !v15 )
-                    v15 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+                    v15 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
                 v54 = uY;
                 v50 = v58;
                 v46 = v88;
@@ -307,7 +307,7 @@
                 if ( HIBYTE(v21) & 1 )
                     {
                     if ( !v24 )
-                        v24 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+                        v24 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
                     v55 = v23;
                     v51 = v59;
                     v47 = pGlobalTXT_LocalizationStrings[96];
@@ -328,7 +328,7 @@
                         v26 = pGlobalTXT_LocalizationStrings[433];
                     v89 = v26;
                     if ( !v24 )
-                        v24 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+                        v24 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
                     v55 = v23;
                     v51 = v59;
                     v47 = v89;
@@ -407,7 +407,7 @@
                     if ( (pPlayer->pActiveSkills[v64] >> 8) & 1 )
                         {
                         if ( !v34 )
-                            v34 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+                            v34 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
                         v56 = uYb;
                         v52 = v60;
                         v48 = pGlobalTXT_LocalizationStrings[96];
@@ -427,7 +427,7 @@
                             v35 = pGlobalTXT_LocalizationStrings[433];
                         v91 = v35;
                         if ( !v34 )
-                            v34 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+                            v34 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
                         v56 = uYb;
                         v52 = v60;
                         v48 = v91;
@@ -502,7 +502,7 @@
                         if ( HIBYTE(v40) & 1 )
                             {
                             if ( !v43 )
-                                v43 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+                                v43 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
                             v57 = v42;
                             v53 = v61;
                             v49 = pGlobalTXT_LocalizationStrings[96];
@@ -523,7 +523,7 @@
                                 v44 = pGlobalTXT_LocalizationStrings[433];
                             v92 = v44;
                             if ( !v43 )
-                                v43 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+                                v43 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
                             v57 = v42;
                             v53 = v61;
                             v49 = v92;
@@ -547,40 +547,61 @@
                         0,
                         0);
                     return (char)v38;
-    }
+}
+
+
+
+
+
+    
+unsigned int GetAwardColor(unsigned int priority)
+{
+  static unsigned __int8 pAwardsTextColors[6][3] =
+  {
+    {248, 108, 160},
+    {112, 220, 248},
+    {192, 192, 240},
+    { 64, 244,  96},
+    {232, 244,  96},
+    {240, 252, 192}
+  };
+
+  return TargetColor(pAwardsTextColors[priority % 6][0],
+                     pAwardsTextColors[priority % 6][1],
+                     pAwardsTextColors[priority % 6][2]);
+}
+
 
 //----- (0041A000) --------------------------------------------------------
-void 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 award_texture_id; // eax@1
+    //unsigned int v2; // ebx@1
+    //unsigned int award_texture_id; // eax@1
     unsigned int result; // eax@1
     int v5; // eax@15
     char *v6; // ebx@15
     int v7; // eax@23
     int v8; // eax@24
     int v9; // eax@25
-    int v10; // eax@27
+    //int v10; // eax@27
     int v11; // eax@32
     int v12; // eax@33
     int v13; // eax@34
-    signed int v14; // eax@43
-    unsigned int v15; // eax@43
-    int v16; // eax@43
-    int v17; // [sp-4h] [bp-D4h]@16
+    //signed int v14; // eax@43
+    //unsigned int v15; // eax@43
+    //int v16; // eax@43
+    //int v17; // [sp-4h] [bp-D4h]@16
     char Source[100]; // [sp+Ch] [bp-C4h]@1
     GUIWindow a1; // [sp+70h] [bp-60h]@1
-    unsigned int v20; // [sp+C4h] [bp-Ch]@15
-    int v21; // [sp+C8h] [bp-8h]@14
-    int v22; // [sp+CCh] [bp-4h]@40
+    //unsigned int v20; // [sp+C4h] [bp-Ch]@15
+    //int v21; // [sp+C8h] [bp-8h]@14
+    //int v22; // [sp+CCh] [bp-4h]@40
 
     auto player = &pParty->pPlayers[uPlayerID - 1];
     //v1 = uPlayerID;
-    v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-    award_texture_id = pIcons_LOD->LoadTexture("fr_award", TEXTURE_16BIT_PALETTE);
-    pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(award_texture_id));
-    sprintfex(pTmpBuf, "%s \f%05d", pGlobalTXT_LocalizationStrings[LOCSTR_AVARDS_FOR], v2);
+    pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->LoadTexturePtr("fr_award", TEXTURE_16BIT_PALETTE));
+    sprintfex(pTmpBuf, "%s \f%05d", pGlobalTXT_LocalizationStrings[LOCSTR_AVARDS_FOR], TargetColor(0xFF, 0xFF, 0x9B));
     sprintfex(Source, pGlobalTXT_LocalizationStrings[LOCSTR_S_THE_S], player->pName, pClassNames[player->classType]);
     strcat(pTmpBuf, Source);
     strcat(pTmpBuf, "\f00000");
@@ -592,7 +613,7 @@
     a1.uFrameHeight = 290;
     a1.uFrameZ = 435;
     a1.uFrameW = 337;
-    if ( dword_506544 && awards_count + dword_506528 < awards_count2 )
+    if ( dword_506544 && num_achieved_awards + dword_506528 < num_achieved_awards_2 )
         result = dword_506528++ + 1;
     if ( dword_506548 && result )
         {
@@ -601,17 +622,17 @@
         }
     if ( dword_50651C < 0 )
         {
-        result += awards_count;
+        result += num_achieved_awards;
         dword_506528 = result;
-        if ( (signed int)(awards_count + result) > awards_count2 )
+        if ( (signed int)(num_achieved_awards + result) > num_achieved_awards_2 )
             {
-            result = awards_count2 - awards_count;
+            result = num_achieved_awards_2 - num_achieved_awards;
             dword_506528 = result;
             }
         }
     else if ( dword_50651C > 0 )
         {
-        result -= awards_count;
+        result -= num_achieved_awards;
         dword_506528 = result;
         if ( (result & 0x80000000u) != 0 )
             {
@@ -622,105 +643,42 @@
     //LABEL_14:
     dword_506544 = 0;
     dword_506548 = 0;
-    awards_count = 0;
+    num_achieved_awards = 0;
     dword_50651C = 0;
-    v21 = result;
-    if ( (signed int)result < awards_count2 )
-        {
-        while ( 1 )
+
+
+    for (uint i = result; i < num_achieved_awards_2; ++i)
+    {
+      v5 = achieved_awards[i];
+      v6 = (char *)pAwards[v5].pText;//(char *)dword_723E80_award_related[v20 / 4];
+
+            pTmpBuf[0] = 0;
+            switch (v5)
             {
-            v5 = achievedAwardsIndex[v21];
-            v20 = achievedAwardsIndex[v21];
-            v6 = (char *)pAwards[v20].pText;//(char *)dword_723E80_award_related[v20 / 4];
-            if ( v5 != 1 )
-                {
-                if (!( (v5 < 85 || v5 > 91) && (v5 < 103 || v5 > 104) ))
-                    {
-                    if ( v5 > 89 )
-                        {
-                        if ( v5 == 90 )
-                            {
-                            v10 = (unsigned __int8)pParty->uNumArenaKnightWins;
-                            v22 = v10;
-                            }
-                        else if ( v5 == 91 )
-                            {
-                            v10 = (unsigned __int8)pParty->uNumArenaLordWins;
-                            v22 = v10;
-                            }
-                        else if ( v5 == 103 )
-                            {
-                            v10 = pParty->field_874;
-                            v22 = v10;
-                            }
-                        else if ( v5 == 104 )
-                            {
-                            v10 = pParty->field_878;
-                            v22 = v10;
-                            }
-                        }
-                    else
-                        {
-                        if ( v5 == 89 )
-                            {
-                            v10 = (unsigned __int8)pParty->uNumArenaSquireWins;
-                            v22 = v10;
-                            }
-                        else if ( v5 == 85 )
-                            {
-                            v10 = pParty->uNumDeaths;
-                            v22 = v10;
-                            }
-                        else if ( v5 == 86 )
-                            {
-                            v10 = pParty->uNumBountiesCollected;
-                            v22 = v10;
-                            }
-                        else if ( v5 == 87 )
-                            {
-                            v10 = pParty->uNumPrisonTerms;
-                            v22 = v10;
-                            }
-                        else if ( v5 == 88)
-                            {
-                            v10 = (unsigned __int8)pParty->uNumArenaPageWins;
-                            v22 = v10;
-                            }
-                        }
-                    v17 = v22;
-                    sprintf(pTmpBuf, v6, v17);
-                    v6 = pTmpBuf;
-                    }
-                }
-            else
-                {
-                v17 = pParty->uFine;
-                sprintf(pTmpBuf, v6, v17);
-                v6 = pTmpBuf;
-                }
-            v14 = pAwards[v20].uSort;//dword_723E84[v20 / 4];
-            ++awards_count;
-            v15 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(
-                pAwardsTextColors[3 * v14 % 6],
-                pAwardsTextColors[3 * v14 % 6 + 1],
-                pAwardsTextColors[3 * v14 % 6 + 2]);
-            a1.DrawText(pFontArrus, 0, 0, v15, v6, 0, 0, 0);
-            v16 = pFontArrus->CalcTextHeight(v6, &a1, 0, 0);
-            result = v16 + a1.uFrameY + 4;
-            if ( (signed int)result <= (signed int)a1.uFrameHeight )
-                {
-                ++v21;
-                a1.uFrameY = result;
-                result = v21;
-                if ( v21 < awards_count2 )
-                    continue;
-                }
-            return;
+              case Award_Arena_PageWins:    sprintf(pTmpBuf, v6, pParty->uNumArenaPageWins);     break;
+              case Award_Arena_SquireWins:  sprintf(pTmpBuf, v6, pParty->uNumArenaSquireWins);   break;
+              case Award_Arena_KnightWins:  sprintf(pTmpBuf, v6, pParty->uNumArenaKnightWins);   break;
+              case Award_Arena_LordWins:    sprintf(pTmpBuf, v6, pParty->uNumArenaLordWins);     break;
+              case Award_ArcomageWins:      sprintf(pTmpBuf, v6, pParty->uNumArcomageWins);      break;
+              case Award_ArcomageLoses:     sprintf(pTmpBuf, v6, pParty->uNumArcomageLoses);     break;
+              case Award_Deaths:            sprintf(pTmpBuf, v6, pParty->uNumDeaths);            break;
+              case Award_BountiesCollected: sprintf(pTmpBuf, v6, pParty->uNumBountiesCollected); break;
+              case Award_Fine:              sprintf(pTmpBuf, v6, pParty->uFine);                 break;
+              case Award_PrisonTerms:       sprintf(pTmpBuf, v6, pParty->uNumPrisonTerms);       break;
             }
 
+            if (*pTmpBuf)
+              v6 = pTmpBuf;
+
+
+            a1.DrawText(pFontArrus, 0, 0, GetAwardColor(pAwards[v5].uPriority), v6, 0, 0, 0);
+            a1.uFrameY = pFontArrus->CalcTextHeight(v6, &a1, 0, 0) + a1.uFrameY + 4;
+            if (a1.uFrameY > a1.uFrameHeight)
+              break;
+
+            ++num_achieved_awards;
         }
-    return;
-    }
+ }
 
 
 
@@ -977,9 +935,9 @@
         //unsigned int v49; // [sp+28h] [bp-4h]@1
 
         v0 = 0;
-        v47 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-        //v49 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
-        v46 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
+        v47 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+        //v49 = TargetColor(0xFFu, 0, 0);
+        v46 = TargetColor(0, 0xFFu, 0);
         //v1 = pIcons_LOD->LoadTexture("quikref", TEXTURE_16BIT_PALETTE);
         pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->LoadTexturePtr("quikref", TEXTURE_16BIT_PALETTE));
         v43 = 0;
@@ -999,7 +957,7 @@
             if ( pPlayer->GetActualLevel() <= v4 )
                 v5 = pPlayer->GetExperienceDisplayColor();
             else
-                v5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, v0);
+                v5 = TargetColor(0, 0xFFu, v0);
             pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, 0x2Fu, v5, pTmpBuf, 84, v0);
             v6 = v45 + 47;
             if ( v43 == v0 )
@@ -1097,9 +1055,9 @@
             if ( v38 >= 0 )
                 {
                 if ( v38 <= 5 )
-                    v39 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0xFF);
+                    v39 = TargetColor(0xFF, 0xFF, 0xFF);
                 else
-                    v39 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0, 0);
+                    v39 = TargetColor(0xFF, 0, 0);
                 }
             else
                 v39 = v46;
@@ -2634,129 +2592,70 @@
                         pGUIWindow_CurrentMenu->_41D08F(a2, 1, 0, a5);
     }
 
-    //----- (00418511) --------------------------------------------------------
-    char __fastcall CharacterUI_StatsTab_Draw(unsigned int uPlayerID)
-        {
+//----- (00418511) --------------------------------------------------------
+char __fastcall CharacterUI_StatsTab_Draw(unsigned int uPlayerID)
+{
         Player *pPlayer; // edi@1
-        unsigned int v2; // eax@1
-        unsigned int v3; // eax@1
         unsigned int v4; // eax@2
-        int v5; // ST20_4@4
-        int v6; // ST1C_4@4
         int v7; // ebp@4
         int v8; // eax@4
         unsigned int v9; // eax@4
         int v10; // ST34_4@4
-        int v11; // ST20_4@4
-        int v12; // ST1C_4@4
         int v13; // ebp@4
         int v14; // eax@4
         unsigned int v15; // eax@4
-        int v16; // ST34_4@4
-        int v17; // ST20_4@4
-        int v18; // ST1C_4@4
         int v19; // ebp@4
         int v20; // eax@4
         unsigned int v21; // eax@4
-        int v22; // ST34_4@4
-        int v23; // ST20_4@4
-        int v24; // ST1C_4@4
         int v25; // ebp@4
         int v26; // eax@4
         unsigned int v27; // eax@4
-        int v28; // ST34_4@4
-        int v29; // ST20_4@4
-        int v30; // ST1C_4@4
         int v31; // ebp@4
         int v32; // eax@4
         unsigned int v33; // eax@4
-        int v34; // ST34_4@4
-        int v35; // ST20_4@4
-        int v36; // ST1C_4@4
         int v37; // ebp@4
         int v38; // eax@4
         unsigned int v39; // eax@4
-        int v40; // ST34_4@4
-        int v41; // ST20_4@4
-        int v42; // ST1C_4@4
         int v43; // ebp@4
         int v44; // eax@4
         unsigned int v45; // eax@4
-        int v46; // ebp@4
-        signed int v47; // ST20_4@6
-        int v48; // ST1C_4@6
         signed int v49; // eax@6
         unsigned int v50; // eax@6
-        int v51; // ST20_4@8
-        int v52; // ST1C_4@8
         int v53; // eax@8
         unsigned int v54; // eax@8
-        int v55; // ST34_4@8
-        int v56; // ST20_4@8
-        int v57; // ST1C_4@8
         int v58; // ebp@8
         int v59; // eax@8
         unsigned int v60; // eax@8
-        unsigned int v61; // ebp@8
         unsigned int v62; // eax@8
-        char *v63; // ST20_4@8
         signed int v64; // eax@8
-        unsigned int v65; // ebp@8
         unsigned __int8 v66; // al@8
         char *v67; // eax@9
-        unsigned int v68; // ST20_4@11
-        unsigned int v69; // ST1C_4@11
         signed int v70; // ebp@11
         signed int v71; // eax@11
         unsigned int v72; // eax@11
-        int v73; // ST20_4@13
-        int v74; // ST1C_4@13
         int v75; // ebp@13
         int v76; // eax@13
         unsigned int v77; // eax@13
         char *v78; // ecx@14
-        int v79; // ST20_4@16
-        char *v80; // ST40_4@16
         unsigned int v81; // eax@16
-        int v82; // ST34_4@16
         int v83; // eax@16
-        int v84; // ST34_4@16
         char *v85; // eax@16
-        int v86; // ST34_4@16
         int v87; // eax@16
-        int v88; // ST34_4@16
         char *v89; // eax@16
         int v90; // eax@16
-        int v91; // ST20_4@19
         unsigned int v92; // eax@19
         int v93; // eax@19
-        int v94; // ST20_4@22
         unsigned int v95; // eax@22
         int v96; // eax@22
-        int v97; // ST20_4@25
         unsigned int v98; // eax@25
         int v99; // eax@25
-        int v100; // ST20_4@27
         unsigned int v101; // eax@27
         int v102; // eax@27
-        int v103; // ST20_4@30
         unsigned int v104; // eax@30
-        char *v105; // ST20_4@32
         unsigned int v106; // eax@32
         int v107; // eax@33
-        int v108; // ST20_4@36
         unsigned int v109; // eax@36
-        char *v110; // ST20_4@38
         unsigned int v111; // eax@38
-        int uY; // [sp+10h] [bp-10h]@6
-        int uYa; // [sp+10h] [bp-10h]@11
-        int uYb; // [sp+10h] [bp-10h]@13
-        int uYc; // [sp+10h] [bp-10h]@16
-        int uYd; // [sp+10h] [bp-10h]@19
-        int uYe; // [sp+10h] [bp-10h]@22
-        int uYf; // [sp+10h] [bp-10h]@25
-        int uYg; // [sp+10h] [bp-10h]@27
-        int uYh; // [sp+10h] [bp-10h]@33
         const char *a2; // [sp+14h] [bp-Ch]@4
         const char *a2a; // [sp+14h] [bp-Ch]@6
         const char *a2b; // [sp+14h] [bp-Ch]@11
@@ -2772,275 +2671,262 @@
         int v134; // [sp+18h] [bp-8h]@25
         int v135; // [sp+18h] [bp-8h]@27
         int v136; // [sp+18h] [bp-8h]@33
-        int v137; // [sp+1Ch] [bp-4h]@27
-        int v138; // [sp+1Ch] [bp-4h]@33
 
         pPlayer = &pParty->pPlayers[uPlayerID-1];
-        v2 = pIcons_LOD->LoadTexture("fr_stats", TEXTURE_16BIT_PALETTE);
-        pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(v2));
-        v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-        sprintf(pTmpBuf, "\f%05d", v3);
+        pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->LoadTexturePtr("fr_stats", TEXTURE_16BIT_PALETTE));
+        sprintf(pTmpBuf, "\f%05d", TargetColor(0xFF, 0xFF, 0x9B));
         sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[429], pPlayer->pName, pClassNames[pPlayer->classType]);//^Pi[%s] %s
         strcat(pTmpBuf, pTmpBuf2);
         if ( pPlayer->uSkillPoints )
-            v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
+            v4 = TargetColor(0, 0xFFu, 0);
         else
             v4 = 0xFFFFu;
         sprintf(pTmpBuf2,  "\f00000\r180%s: \f%05d%d\f00000\n\n\n", pGlobalTXT_LocalizationStrings[207], v4, pPlayer->uSkillPoints);//Skill points
         strcat(pTmpBuf, pTmpBuf2);
         pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, 18, 0, pTmpBuf, 0, 0, 0);
-        v5 = pPlayer->GetBaseStrength();
-        v6 = pPlayer->GetActualMight();
+
+        v10 = 53;
         v7 = pPlayer->GetBaseStrength();
         v8 = pPlayer->GetActualMight();
         v9 = UI_GetHealthManaStringColor(v8, v7);
-        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[144], v9, v6, v5);//Might
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, 53, 0, pTmpBuf, 0, 0, 0);
-        v10 = LOBYTE(pFontArrus->uFontHeight) + 51;
-        v11 = pPlayer->GetBaseIntelligence();
-        v12 = pPlayer->GetActualIntelligence();
+        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[144], v9, v8, v7);//Might
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v13 = pPlayer->GetBaseIntelligence();
         v14 = pPlayer->GetActualIntelligence();
         v15 = UI_GetHealthManaStringColor(v14, v13);
-        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[116], v15, v12, v11);//Intellect
+        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[116], v15, v14, v13);//Intellect
         pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
-        v16 = LOBYTE(pFontArrus->uFontHeight) + v10 - 2;
-        v17 = pPlayer->GetBaseWillpower();
-        v18 = pPlayer->GetActualWillpower();
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v19 = pPlayer->GetBaseWillpower();
         v20 = pPlayer->GetActualWillpower();
         v21 = UI_GetHealthManaStringColor(v20, v19);
-        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[163], v21, v18, v17);//
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v16, 0, pTmpBuf, 0, 0, 0);
-        v22 = LOBYTE(pFontArrus->uFontHeight) + v16 - 2;
-        v23 = pPlayer->GetBaseEndurance();
-        v24 = pPlayer->GetActualEndurance();
+        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[163], v21, v20, v19);//
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v25 = pPlayer->GetBaseEndurance();
         v26 = pPlayer->GetActualEndurance();
         v27 = UI_GetHealthManaStringColor(v26, v25);
-        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[75], v27, v24, v23);//
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v22, 0, pTmpBuf, 0, 0, 0);
-        v28 = LOBYTE(pFontArrus->uFontHeight) + v22 - 2;
-        v29 = pPlayer->GetBaseAccuracy();
-        v30 = pPlayer->GetActualAccuracy();
+        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[75], v27, v26, v25);//
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v31 = pPlayer->GetBaseAccuracy();
         v32 = pPlayer->GetActualAccuracy();
         v33 = UI_GetHealthManaStringColor(v32, v31);
-        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[1], v33, v30, v29);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v28, 0, pTmpBuf, 0, 0, 0);
-        v34 = LOBYTE(pFontArrus->uFontHeight) + v28 - 2;
-        v35 = pPlayer->GetBaseSpeed();
-        v36 = pPlayer->GetActualSpeed();
+        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[1], v33, v32, v31);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v37 = pPlayer->GetBaseSpeed();
         v38 = pPlayer->GetActualSpeed();
         v39 = UI_GetHealthManaStringColor(v38, v37);
-        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[211], v39, v36, v35);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v34, 0, pTmpBuf, 0, 0, 0);
-        v40 = LOBYTE(pFontArrus->uFontHeight) + v34 - 2;
-        v41 = pPlayer->GetBaseLuck();
-        v42 = pPlayer->GetActualLuck();
+        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[211], v39, v38, v37);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v43 = pPlayer->GetBaseLuck();
         v44 = pPlayer->GetActualLuck();
         v45 = UI_GetHealthManaStringColor(v44, v43);
-        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n\n", pGlobalTXT_LocalizationStrings[136], v45, v42, v41);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v40, 0, pTmpBuf, 0, 0, 0);
+        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n\n", pGlobalTXT_LocalizationStrings[136], v45, v44, v43);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+
         a2 = "%s\f%05u\r424%d\f00000 /\t185%d\n";
-        v46 = v40 + 2 * LOBYTE(pFontArrus->uFontHeight) + 5;
+        v10 += 2 * LOBYTE(pFontArrus->uFontHeight) + 5;
         if ( pPlayer->GetMaxHealth() >= 1000 )
             a2 = "%s\f%05u\r388%d\f00000 / %d\n";
-        v47 = pPlayer->GetMaxHealth();
-        v48 = pPlayer->sHealth;
         v49 = pPlayer->GetMaxHealth();
         v50 = UI_GetHealthManaStringColor(pPlayer->sHealth, v49);
-        sprintf(pTmpBuf, a2, pGlobalTXT_LocalizationStrings[108], v50, v48, v47);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v46, 0, pTmpBuf, 0, 0, 0);
+        sprintf(pTmpBuf, a2, pGlobalTXT_LocalizationStrings[108], v50, pPlayer->sHealth, v49);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+
         a2a = "%s\f%05u\r424%d\f00000 /\t185%d\n";
-        uY = LOBYTE(pFontArrus->uFontHeight) + v46 - 2;
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         if ( pPlayer->GetMaxMana() >= 1000 )
             a2a = "%s\f%05u\r388%d\f00000 / %d\n";
-        v51 = pPlayer->GetMaxMana();
-        v52 = pPlayer->sMana;
         v53 = pPlayer->GetMaxMana();
         v54 = UI_GetHealthManaStringColor(pPlayer->sMana, v53);
-        sprintf(pTmpBuf, a2a, pGlobalTXT_LocalizationStrings[212], v54, v52, v51);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, uY, 0, pTmpBuf, 0, 0, 0);
-        v55 = LOBYTE(pFontArrus->uFontHeight) + uY - 2;
-        v56 = pPlayer->GetBaseAC();
-        v57 = pPlayer->GetActualAC();
+        sprintf(pTmpBuf, a2a, pGlobalTXT_LocalizationStrings[212], v54, pPlayer->sMana, v53);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v58 = pPlayer->GetBaseAC();
         v59 = pPlayer->GetActualAC();
         v60 = UI_GetHealthManaStringColor(v59, v58);
-        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n\n", pGlobalTXT_LocalizationStrings[12], v60, v57, v56);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v55, 0, pTmpBuf, 0, 0, 0);
-        v61 = v55 + 2 * LOBYTE(pFontArrus->uFontHeight) - 2;
+        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n\n", pGlobalTXT_LocalizationStrings[12], v60, v59, v58);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += 2 * LOBYTE(pFontArrus->uFontHeight) - 2;
         v62 = pPlayer->GetMajorConditionIdx();
-        v63 = aCharacterConditionNames[v62];
         v64 = GetConditionDrawColor(v62);
-        sprintf(pTmpBuf, "%s: \f%05d%s\n", pGlobalTXT_LocalizationStrings[47], v64, v63);
-        pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x1Au, v61, 0, pTmpBuf, 226, 0);
-        v65 = LOBYTE(pFontArrus->uFontHeight) + v61 - 1;
+        sprintf(pTmpBuf, "%s: \f%05d%s\n", pGlobalTXT_LocalizationStrings[47], v64, aCharacterConditionNames[v62]);
+        pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x1Au, v10, 0, pTmpBuf, 226, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) + - 1;
         v66 = pPlayer->uQuickSpell;
         if ( v66 )
             v67 = pSpellStats->pInfos[v66].pShortName;
         else
             v67 = pGlobalTXT_LocalizationStrings[153];
         sprintf(pTmpBuf, "%s: %s", pGlobalTXT_LocalizationStrings[172], v67);
-        pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x1Au, v65, 0, pTmpBuf, 226, 0);
-        v68 = pPlayer->GetBaseAge();
-        v69 = pPlayer->GetActualAge();
+        pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x1Au, v10, 0, pTmpBuf, 226, 0);
+
+        v10 = 50;
         v70 = pPlayer->GetBaseAge();
         v71 = pPlayer->GetActualAge();
         v72 = UI_GetHealthManaStringColor(v71, v70);
-        sprintf(pTmpBuf, "%s\f%05u\t100%d\f00000 / %d\n", pGlobalTXT_LocalizationStrings[5], v72, v69, v68);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, 50, 0, pTmpBuf, 0, 0, 0);
+        sprintf(pTmpBuf, "%s\f%05u\t100%d\f00000 / %d\n", pGlobalTXT_LocalizationStrings[5], v72, v71, v70);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
         a2b = "%s\f%05u\t100%d\f00000 / %d\n";
-        uYa = LOBYTE(pFontArrus->uFontHeight) + 48;
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         if ( pPlayer->GetBaseLevel() > 99 )
             a2b = format_4E2E68;
-        v73 = pPlayer->GetBaseLevel();
-        v74 = pPlayer->GetActualLevel();
         v75 = pPlayer->GetBaseLevel();
         v76 = pPlayer->GetActualLevel();
         v77 = UI_GetHealthManaStringColor(v76, v75);
-        sprintf(pTmpBuf, a2b, pGlobalTXT_LocalizationStrings[131], v77, v74, v73);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYa, 0, pTmpBuf, 0, 0, 0);
-        uYb = uYa + LOBYTE(pFontArrus->uFontHeight) - 2;
+        sprintf(pTmpBuf, a2b, pGlobalTXT_LocalizationStrings[131], v77, v76, v75);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         if ( (signed __int64)pPlayer->uExperience <= 9999999 )
             v78 = pGlobalTXT_LocalizationStrings[83];
         else
             v78 = pGlobalTXT_LocalizationStrings[17];
-        v79 = LODWORD(pPlayer->uExperience);
-        v80 = v78;
         v81 = pPlayer->GetExperienceDisplayColor();
-        sprintf(pTmpBuf, "%s\r180\f%05d%lu\f00000\n\n", v80, v81, v79);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYb, 0, pTmpBuf, 0, 0, 0);
-        v82 = uYb + 2 * LOBYTE(pFontArrus->uFontHeight);
+        sprintf(pTmpBuf, "%s\r180\f%05d%lu\f00000\n\n", v78, v81, LODWORD(pPlayer->uExperience));
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += 2 * LOBYTE(pFontArrus->uFontHeight);
         v83 = pPlayer->GetActualAttack(0);
         sprintf(pTmpBuf, "%s\t100%+d\n", pGlobalTXT_LocalizationStrings[18], v83);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v82, 0, pTmpBuf, 0, 0, 0);
-        v84 = v82 + LOBYTE(pFontArrus->uFontHeight) - 2;
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v85 = pPlayer->GetMeleeDamageString();
         sprintf(pTmpBuf, "%s\t100 %s\n", pGlobalTXT_LocalizationStrings[53], v85);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v84, 0, pTmpBuf, 0, 0, 0);
-        v86 = v84 + LOBYTE(pFontArrus->uFontHeight) - 2;
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v87 = pPlayer->GetRangedAttack();
         sprintf(pTmpBuf, "%s\t100%+d\n", pGlobalTXT_LocalizationStrings[203], v87);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v86, 0, pTmpBuf, 0, 0, 0);
-        v88 = v86 + LOBYTE(pFontArrus->uFontHeight) - 2;
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v89 = pPlayer->GetRangedDamageString();
         sprintf(pTmpBuf, "%s\t100 %s\n\n", pGlobalTXT_LocalizationStrings[53], v89);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v88, 0, pTmpBuf, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
         a2c = format_4E2E10;
-        uYc = v88 + 2 * LOBYTE(pFontArrus->uFontHeight) - 4;
+        v10 += 2 * LOBYTE(pFontArrus->uFontHeight) - 4;
         v131 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE);
         v90 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE);
         if ( v131 > 99 || v90 > 99 )
             a2c = format_4E2E68;
-        v91 = v90;
         v92 = UI_GetHealthManaStringColor(v131, v90);
-        sprintf(pTmpBuf, a2c, pGlobalTXT_LocalizationStrings[87], v92, v131, v91);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYc, 0, pTmpBuf, 0, 0, 0);
+        sprintf(pTmpBuf, a2c, pGlobalTXT_LocalizationStrings[87], v92, v131, v90);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
         a2d = format_4E2E10;
-        uYd = uYc + LOBYTE(pFontArrus->uFontHeight) - 2;
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v132 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_AIR);
         v93 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_AIR);
         if ( v132 > 99 || v93 > 99 )
             a2d = format_4E2E68;
-        v94 = v93;
         v95 = UI_GetHealthManaStringColor(v132, v93);
-        sprintf(pTmpBuf, a2d, pGlobalTXT_LocalizationStrings[6], v95, v132, v94);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYd, 0, pTmpBuf, 0, 0, 0);
+        sprintf(pTmpBuf, a2d, pGlobalTXT_LocalizationStrings[6], v95, v132, v93);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
         a2e = format_4E2E10;
-        uYe = uYd + LOBYTE(pFontArrus->uFontHeight) - 2;
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v133 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_WATER);
         v96 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_WATER);
         if ( v133 > 99 || v96 > 99 )
             a2e = format_4E2E68;
-        v97 = v96;
         v98 = UI_GetHealthManaStringColor(v133, v96);
-        sprintf(pTmpBuf, a2e, pGlobalTXT_LocalizationStrings[240], v98, v133, v97);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYe, 0, pTmpBuf, 0, 0, 0);
+        sprintf(pTmpBuf, a2e, pGlobalTXT_LocalizationStrings[240], v98, v133, v96);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
         a2f = format_4E2E10;
-        uYf = uYe + LOBYTE(pFontArrus->uFontHeight) - 2;
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v134 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH);
         v99 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH);
         if ( v134 > 99 )
             a2f = format_4E2E68;
-        v100 = v99;
         v101 = UI_GetHealthManaStringColor(v134, v99);
-        sprintf(pTmpBuf, a2f, pGlobalTXT_LocalizationStrings[70], v101, v134, v100);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYf, 0, pTmpBuf, 0, 0, 0);
+        sprintf(pTmpBuf, a2f, pGlobalTXT_LocalizationStrings[70], v101, v134, v99);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
         a2g = format_4E2E10;
-        uYg = uYf + LOBYTE(pFontArrus->uFontHeight) - 2;
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v135 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND);
         v102 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_MIND);
-        v137 = v102;
         if ( v135 > 99 || v102 > 99 )
             a2g = format_4E2E68;
-        v103 = v102;
         v104 = UI_GetHealthManaStringColor(v135, v102);
-        sprintf(pTmpBuf, a2g, pGlobalTXT_LocalizationStrings[142], v104, v135, v103);
-        if ( pPlayer->classType == PLAYER_CLASS_LICH && v137 == 200 )
-            {
-            v105 = pGlobalTXT_LocalizationStrings[625];
+        sprintf(pTmpBuf, a2g, pGlobalTXT_LocalizationStrings[142], v104, v135, v102);
+        if ( pPlayer->classType == PLAYER_CLASS_LICH && v102 == 200 )
+        {
             v106 = UI_GetHealthManaStringColor(v135, 200);
-            sprintf(pTmpBuf, format_4E2E00, pGlobalTXT_LocalizationStrings[142], v106, v105);
-            }
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYg, 0, pTmpBuf, 0, 0, 0);
+            sprintf(pTmpBuf, format_4E2E00, pGlobalTXT_LocalizationStrings[142], v106, pGlobalTXT_LocalizationStrings[625]);
+        }
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
         a2h = format_4E2E10;
-        uYh = uYg + LOBYTE(pFontArrus->uFontHeight) - 2;
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v136 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY);
         v107 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_BODY);
-        v138 = v107;
         if ( v136 > 99 || v107 > 99 )
             a2h = format_4E2E68;
-        v108 = v107;
         v109 = UI_GetHealthManaStringColor(v136, v107);
-        sprintf(pTmpBuf, a2h, pGlobalTXT_LocalizationStrings[29], v109, v136, v108);
-        if ( pPlayer->classType == PLAYER_CLASS_LICH && v138 == 200 )
-            {
-            v110 = pGlobalTXT_LocalizationStrings[625];
+        sprintf(pTmpBuf, a2h, pGlobalTXT_LocalizationStrings[29], v109, v136, v107);
+        if ( pPlayer->classType == PLAYER_CLASS_LICH && v107 == 200 )
+        {
             v111 = UI_GetHealthManaStringColor(v136, 200);
-            sprintf(pTmpBuf, format_4E2E00, pGlobalTXT_LocalizationStrings[29], v111, v110);
-            }
-        return pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYh, 0, pTmpBuf, 0, 0, 0);
+            sprintf(pTmpBuf, format_4E2E00, pGlobalTXT_LocalizationStrings[29], v111, pGlobalTXT_LocalizationStrings[625]);
         }
+        return pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+}
 
-    //----- (00419100) --------------------------------------------------------
-    void FillAwardsData()
-        {
-        Player *pPlayer; // esi@1
+//----- (00419100) --------------------------------------------------------
+void FillAwardsData()
+{
+        auto pPlayer = pPlayers[uActiveCharacter];
 
-        pPlayer = pPlayers[uActiveCharacter];
-        memset(&achievedAwardsIndex, 0, 4000);
+        memset(achieved_awards, 0, 4000);
+        num_achieved_awards = 0;
+
         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;
+        for (int i = 0; i < 105; ++i)
+        {
+            if ( _449B57_test_bit(pPlayer->_guilds_member_bits, i) && pAwards[i].pText )
+                achieved_awards[num_achieved_awards++] = (AwardType)i;
+        }
+        num_achieved_awards_2 = num_achieved_awards;
+        num_achieved_awards = 0;
+
         //sort awards index 
-        if ( awards_count2>0 )
-            {
-            for(int i=0; i<awards_count2; ++i)
-                achievedAwardsIndex[awards_count2 + i] = rand() % 16;
+        if (num_achieved_awards_2 > 0)
+        {
+            for(int i=0; i<num_achieved_awards_2; ++i)
+                achieved_awards[num_achieved_awards_2 + i] = (AwardType)(rand() % 16);
 
-            for(int i=1; i<awards_count2-1; ++i)
+            for(int i=1; i<num_achieved_awards_2-1; ++i)
                 {
-                for (int j = i; j < awards_count2-1; ++j )
+                for (int j = i; j < num_achieved_awards_2-1; ++j )
                     {
-                    int tmp=achievedAwardsIndex[j];
-                    if(pAwards[j].uSort < pAwards[i].uSort)
+                    auto tmp=achieved_awards[j];
+                    if (pAwards[j].uPriority < pAwards[i].uPriority)
                         {
-                        achievedAwardsIndex[j] = achievedAwardsIndex[i];
-                        achievedAwardsIndex[i] = tmp;
+                        achieved_awards[j] = achieved_awards[i];
+                        achieved_awards[i] = tmp;
                         }
                     }
                 }
--- a/UIHouses.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/UIHouses.cpp	Wed May 01 20:04:24 2013 +0200
@@ -621,7 +621,7 @@
   v5.uFrameX = 483;
   v5.uFrameWidth = 148;
   v5.uFrameZ = 334;
-  v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v2 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   v3 = pFontArrus->CalcTextHeight(v0, &v5, 0, 0);
   v5.DrawTitleText(pFontArrus, 0, (310 - v3) / 2 + 18, v2, v1, 3u);
 }
@@ -1733,8 +1733,8 @@
   v53.uFrameX = 483;
   v53.uFrameWidth = 148;
   v53.uFrameZ = 334;
-  auto color_default = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255);
-  auto color_selected = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 155);
+  auto color_default = TargetColor(255, 255, 255);
+  auto color_selected = TargetColor(255, 255, 155);
   v3 = 52 * (unsigned int)v0->ptr_1C;
   //v59 = (GUIWindow *)((((p2DEvents_minus1___00[v3 / 2] != 27) - 1) & 0xFFFFFFE7) + 50);
   //v59 = (GUIWindow *)((((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != BildingType_Stables) - 1) & 0xFFFFFFE7) + 50);
@@ -2031,8 +2031,8 @@
   _this.uFrameX = 483;
   _this.uFrameWidth = 148;
   _this.uFrameZ = 334;
-  v28 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  v30 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v28 = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  v30 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   sprintf(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[605], pParty->uFine);
   _this.DrawTitleText(pFontArrus, 0, 0x104u, v30, pTmpBuf, 3u);
   switch(dialog_menu_id)
@@ -2092,9 +2092,9 @@
 	case HOUSE_DIALOGUE_TOWNHALL_99:
 		{
 		v5 = &pMonsterStats->pInfos[word_F8B1A0];
-		v6 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+		v6 = TargetColor(0xFFu, 0xFFu, 0xFFu);
 		v7 = v5->pName;
-		v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+		v8 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
 		sprintf(pTmpBuf, &byte_4F0F98, v8, v7, v6);
 		sprintf(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * v5->uLevel);
 		current_npc_text = pTmpBuf2;
@@ -2201,8 +2201,8 @@
   _this.uFrameX = 483;
   _this.uFrameWidth = 148;
   _this.uFrameZ = 334;
-  *(int *)v13 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  *(int *)v14 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  *(int *)v13 = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  *(int *)v14 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   sprintf(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[25], pParty->uNumGoldInBank);
   _this.DrawTitleText(pFontArrus, 0, 0xDCu, v14[0], pTmpBuf, 3u);
   switch(dialog_menu_id)
@@ -2429,8 +2429,8 @@
   dialog_window.uFrameX = 483;
   dialog_window.uFrameWidth = 148;
   dialog_window.uFrameZ = 334;
-  pColorWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  pColorYellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  pColorYellow = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   v2 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
   *(float *)&v83 = v2;
   *(float *)&v89 = v2 * v2;
@@ -2878,8 +2878,8 @@
   dialog_window.uFrameX = 483;
   dialog_window.uFrameWidth = 148;
   dialog_window.uFrameZ = 334;
-  pColorWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  pColorYellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
+  pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  pColorYellow = TargetColor(0xE1u, 0xCDu, 0x23u);
 
   switch(dialog_menu_id)
   {
@@ -3409,8 +3409,8 @@
   dialog_window.uFrameX = 483;
   dialog_window.uFrameWidth = 148;
   dialog_window.uFrameZ = 334;
-  pColorWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  pColorYellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
+  pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  pColorYellow = TargetColor(0xE1u, 0xCDu, 0x23u);
   switch(dialog_menu_id)
   {
     case HOUSE_DIALOGUE_MAIN:
@@ -3998,8 +3998,8 @@
   dialog_window.uFrameX = 483;
   dialog_window.uFrameWidth = 148;
   dialog_window.uFrameZ = 334;
-  pWhiteColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  pYellowColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
+  pWhiteColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  pYellowColor = TargetColor(0xE1u, 0xCDu, 0x23u);
   switch (dialog_menu_id)
   {
     case HOUSE_DIALOGUE_MAIN:
@@ -4496,8 +4496,8 @@
   working_window.uFrameX = 483;
   working_window.uFrameWidth = 148;
   working_window.uFrameZ = 334;
-  pColorWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  pColorYellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  pColorYellow = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   base_teach_price = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier * 500.0);
   v63 = base_teach_price * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
   if ( v63 < base_teach_price / 3 )
@@ -4799,8 +4799,8 @@
     v57.uFrameX = 483;
     v57.uFrameWidth = 148;
     v57.uFrameZ = 334;
-    HIDWORD(v58) = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-    HIDWORD(v59) = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+    HIDWORD(v58) = TargetColor(0xFFu, 0xFFu, 0xFFu);
+    HIDWORD(v59) = TargetColor(0xFFu, 0xFFu, 0x9Bu);
     v1 = pPlayers[uActiveCharacter];
     //v2 = pPlayers[uActiveCharacter]->_4B807C(p2DEvents_minus1__20[13 * (unsigned int)v0->ptr_1C]);
     v2 = pPlayers[uActiveCharacter]->_4B807C(p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier);
@@ -5190,8 +5190,8 @@
   v65.uFrameX = 483;
   v65.uFrameWidth = 148;
   v65.uFrameZ = 334;
-  white = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255);
-  color2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
+  white = TargetColor(255, 255, 255);
+  color2 = TargetColor(0xE1u, 0xCDu, 0x23u);
   //v71 = color2;
   //v2 = v0->uLevel;
   //v3 = 0;
@@ -5600,8 +5600,8 @@
   dialog_window.uFrameX = 483;
   dialog_window.uFrameWidth = 148;
   dialog_window.uFrameZ = 334;
-  pWhiteColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255);
-  pYellowColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(225, 205, 35);
+  pWhiteColor = TargetColor(255, 255, 255);
+  pYellowColor = TargetColor(225, 205, 35);
   if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN)
   {
     if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
--- a/UIMainMenu.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/UIMainMenu.cpp	Wed May 01 20:04:24 2013 +0200
@@ -307,12 +307,12 @@
         v7 = pAllocator->AllocNamedChunk(pTexture2.pPixels, 2 * pTexture2.uNumPixels, "scrollermap");
         pNumPixels = pTexture2.uNumPixels;
         pTexture2.pPixels = (unsigned __int16 *)v7;
-        teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu);
+        teal = TargetColor(0, 0xFFu, 0xFFu);
         fill_pixels_fast(teal, pTexture2.pPixels, pNumPixels);
         pTexture2.field_20 = 0;
         pTexture2.field_22 = 0;
-        pColor1 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x70u, 0x8Fu, 0xFEu);
-        pColor2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xECu, 0xE6u, 0x9Cu);
+        pColor1 = TargetColor(0x70u, 0x8Fu, 0xFEu);
+        pColor2 = TargetColor(0xECu, 0xE6u, 0x9Cu);
         pString = (char *)operator new(2 * pSize);
         strncpy(pString, ptr, pSize);
         pString[pSize]=0;
--- a/UIOptions.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/UIOptions.cpp	Wed May 01 20:04:24 2013 +0200
@@ -118,7 +118,7 @@
     const char *v62; // [sp-10h] [bp-24h]@16
     unsigned int a5; // [sp+10h] [bp-4h]@1
 
-    v0 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+    v0 = TargetColor(0xFFu, 0xFFu, 0xFFu);
     a5 = v0;
     if ( byte_4E28FC )
         {
@@ -134,7 +134,7 @@
         if ( v1 == 15 )
             byte_4E28FC = 1;
         }
-    v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v1, 0, 0);
+    v2 = TargetColor(v1, 0, 0);
     v3 = pGUIWindow_CurrentMenu;
     dword_507C08 = v2;
     if ( pGUIWindow_CurrentMenu->field_40 == 2 )
@@ -297,9 +297,9 @@
     unsigned int result; // eax@1
 
     v1 = _this;
-    v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
-    v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFu, 0, 0);
-    result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+    v2 = TargetColor(0xE1u, 0xCDu, 0x23u);
+    v3 = TargetColor(0xFu, 0, 0);
+    result = TargetColor(0xFFu, 0xFFu, 0xFFu);
     if ( dword_506E68 == v1 )
         {
         if ( GetTickCount() % 0x3E8 <= 0x1F4 )
@@ -338,7 +338,7 @@
         v3.uFrameHeight = 79;
         v3.uFrameZ = 232;
         v3.uFrameW = 268;
-        v1 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+        v1 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
         v3.DrawTitleText(pFontSmallnum, 0, 0, v1, v0, 3u);
         }
 
--- a/UIPartyCreation.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/UIPartyCreation.cpp	Wed May 01 20:04:24 2013 +0200
@@ -225,10 +225,10 @@
   //Player *pPlayer;
   const char *pSkillName;
 
-  uColor1 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xD1, 0xBB, 0x61);
-  uColorTeal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xF7, 0xF7);
-  uColorGreen = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFF, 0);
-  uColorWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0xFF);
+  uColor1 = TargetColor(0xD1, 0xBB, 0x61);
+  uColorTeal = TargetColor(0, 0xF7, 0xF7);
+  uColorGreen = TargetColor(0, 0xFF, 0);
+  uColorWhite = TargetColor(0xFF, 0xFF, 0xFF);
   pRenderer->BeginScene();
   pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
   uPlayerCreationUI_SkySliderPos = (GetTickCount() % 12800) / 20;
--- a/UIPopup.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/UIPopup.cpp	Wed May 01 20:04:24 2013 +0200
@@ -226,7 +226,7 @@
     char *Str; // [sp+270h] [bp-8h]@65
 
     v1 = inspect_item;
-    var88 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+    var88 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
     if (!inspect_item->uItemID)
         return;
 
@@ -330,7 +330,7 @@
         wHintWindow.DrawTitleText(pFontArrus, 0, 0xCu, var88, v16, 3u);
         v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[32], &wHintWindow, 0, 0); //"Broken Item"
         v18 = v17 >> 1;
-        v19 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x19u, 0x19u);
+        v19 = TargetColor(0xFFu, 0x19u, 0x19u);
         wHintWindow.DrawTitleText(pFontArrus, 0x64u, ((signed int)wHintWindow.uFrameHeight >> 1) - v18, v19, pGlobalTXT_LocalizationStrings[32], 3); //"Broken Item"
         pRenderer->ResetTextureClipRect();
         if ( !areWeLoadingTexture )
@@ -354,7 +354,7 @@
         wHintWindow.DrawTitleText(pFontArrus, 0, 0xCu, var88, item_desc->pUnidentifiedName, 3u);
         v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[232], &wHintWindow, 0, 0); ///"Not Identified"
         v18 = v17 >> 1;
-        v19 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x19u, 0x19u);
+        v19 = TargetColor(0xFFu, 0x19u, 0x19u);
         wHintWindow.DrawTitleText(pFontArrus, 0x64u, ((signed int)wHintWindow.uFrameHeight >> 1) - v18, v19, pGlobalTXT_LocalizationStrings[232], 3);
         pRenderer->ResetTextureClipRect();
         if ( !areWeLoadingTexture )
@@ -728,7 +728,7 @@
   v106.uParentBillboardID = -1;
   v3 = &pActors[v2];
   v121 = v3;
-  v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 255, 0x9Bu);
+  v4 = TargetColor(0xE1u, 255, 0x9Bu);
   //v5 = v3->sNPC_ID;
   a5 = v4;
   v6 = GetNPCData(v3->sNPC_ID);
@@ -954,7 +954,7 @@
   }
   if(!v121->sNPC_ID || (v121->sNPC_ID && !v6->uProfession))
     strncpy(pTmpBuf, v72, v77);
-  v39 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v39 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   a1->DrawTitleText(pFontComic, 0, 0xCu, v39, pTmpBuf, 3u);
   Actor::DrawHealthBar(v121, a1);
   v119 = 0;
@@ -1501,7 +1501,7 @@
         sprintf(Source, "\f%05d", v13);
         strcat(a2, Source);
         strcat(a2, "%s\t%03d:\t%03d%s\t000\n\n");
-        v14 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+        v14 = TargetColor(0xFFu, 0xFFu, 0xFFu);
         sprintf(Source, "\f%05d", v14);
         strcat(a2, Source);
         strcat(a2, "%s: +%d");
@@ -1815,7 +1815,7 @@
         v7 = v2->pName;
         a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
         a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1;
-        v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+        v8 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
         a1.DrawTitleText(pFontArrus, 0x78u, 0xCu, v8, v7, 3u);
         a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2, 0, 0, 0);
         a1.uFrameWidth = 108;
@@ -2192,7 +2192,7 @@
                 pWindow.uFrameHeight -= 12;
                 pWindow.uFrameZ = pWindow.uFrameX + pWindow.uFrameWidth - 1;
                 pWindow.uFrameW = pWindow.uFrameY + pWindow.uFrameHeight - 1;
-                pColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0x9B);
+                pColor = TargetColor(0xFF, 0xFF, 0x9B);
                 sprintf(pTmpBuf, format_4E2D80, pColor, pStr);//"\f%05d%s\f00000\n"
                 pWindow.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf, 3);
                 pWindow.DrawText(pFontSmallnum, 1, pFontLucida->uFontHeight, 0, pHint, 0, 0, 0);
--- a/UIRest.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/UIRest.cpp	Wed May 01 20:04:24 2013 +0200
@@ -131,8 +131,8 @@
     int a5; // [sp+E0h] [bp-4h]@1
 
     v0 = 0;
-    a5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xAu, 0, 0);
-    *(int *)a9 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE6u, 0xD6u, 0xC1u);
+    a5 = TargetColor(0xAu, 0, 0);
+    *(int *)a9 = TargetColor(0xE6u, 0xD6u, 0xC1u);
     ppPlayers = &pPlayers[1];
     do
         {
--- a/UISaveLoad.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/UISaveLoad.cpp	Wed May 01 20:04:24 2013 +0200
@@ -89,8 +89,8 @@
 
   v1 = 255;
   a4 = a1;
-  GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0xFF);
-  GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0x9B);
+  TargetColor(0xFF, 0xFF, 0xFF);
+  TargetColor(0xFF, 0xFF, 0x9B);
   pRenderer->BeginScene();
   if ( GetCurrentMenuID() != MENU_SAVELOAD && GetCurrentMenuID() != MENU_LOADINGPROC )
   {
@@ -222,7 +222,7 @@
       if ( pFilesID >= (signed int)pSaveFiles )
         break;
       short clr;
-      HIDWORD(pAMPM2) = clr = (pFilesID == uLoadGameUI_SelectedSlot ? GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v1, v1, 0x64) : 0);
+      HIDWORD(pAMPM2) = clr = (pFilesID == uLoadGameUI_SelectedSlot ? TargetColor(v1, v1, 0x64) : 0);
       if ( pGUIWindow_CurrentMenu->field_40 != 1 || pFilesID != uLoadGameUI_SelectedSlot )
       {
         pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, 0x1B, a4, clr, pSlotName, 185, 0);
--- a/UiGame.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/UiGame.cpp	Wed May 01 20:04:24 2013 +0200
@@ -1508,8 +1508,8 @@
   uCenterX = (uX + uZ) / 2;
   uCenterY = (uY + uW) / 2;
   lPitch = pRenderer->uTargetSurfacePitch;
-  GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0);
-  uBlue = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0xFFu);
+  TargetColor(0, 0, 0);
+  uBlue = TargetColor(0, 0, 0xFFu);
   auto bWizardEyeActive = pParty->WizardEyeActive();
   auto uWizardEyeSkillLevel = pParty->WizardEyeSkillLevel();
   if (CheckHiredNPCSpeciality(Cartographer))
@@ -1690,8 +1690,8 @@
   uint arrow_idx = floorf(0.5f + 7 * angle);
   pRenderer->DrawTextureTransparent(uCenterX - 3, uCenterY - 3, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[arrow_idx]));
 
-  flagsb = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 255);
-  v60 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 0, 0);
+  flagsb = TargetColor(0, 0, 255);
+  v60 = TargetColor(255, 0, 0);
   if (bWizardEyeActive)
   {
     //uZe = 0;
@@ -1750,9 +1750,9 @@
 
 
 LABEL_85:
-    v63 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 0, 0);
-    v61 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 255, 0);
-    v65 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 0);
+    v63 = TargetColor(255, 0, 0);
+    v61 = TargetColor(0, 255, 0);
+    v65 = TargetColor(255, 255, 0);
     uZf = 0;
     if ( (signed int)uNumActors > 0 )
     {
@@ -1812,7 +1812,7 @@
   }
 
 
-  flagsd = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255);
+  flagsd = TargetColor(255, 255, 255);
   uZg = 0;
   if ( (signed int)uNumLevelDecorations > 0 )
   {
--- a/Viewport.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/Viewport.cpp	Wed May 01 20:04:24 2013 +0200
@@ -172,7 +172,7 @@
 void ViewingParams::InitGrayPalette()
     {
     for  (unsigned short i=0; i<256; ++i)
-        pPalette[i]=GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(i, i, i);
+        pPalette[i]=TargetColor(i, i, i);
     }
 
 //----- (00443365) --------------------------------------------------------
--- a/mm7_1.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/mm7_1.cpp	Wed May 01 20:04:24 2013 +0200
@@ -1410,7 +1410,7 @@
         pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchC");
         pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID);
       }
-      v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xC8u, 0, 0);
+      v3 = TargetColor(0xC8u, 0, 0);
       v4 = 0;
       v6 = 0;
       v5 = 10;
@@ -1506,7 +1506,7 @@
         pTexture_591428 = pIcons_LOD->LoadTexturePtr("endcap", TEXTURE_16BIT_PALETTE);
 
       }
-      v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xAu, 0, 0);
+      v3 = TargetColor(0xAu, 0, 0);
       v4 = 214;
       v5 = 230;
       v6 = 193;
@@ -1557,7 +1557,7 @@
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507698], "edge_top-b", 2);
       pIcons_LOD->ReloadTexture(pTexture_591428, "endcap-b", 2);
     }
-    v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0xC8u);
+    v3 = TargetColor(0, 0, 0xC8u);
     v5 = 255;
     v4 = 225;
     v6 = 255;
@@ -1565,7 +1565,7 @@
   else assert(false);
 
   uGameUIFontMain = v3;
-  uGameUIFontShadow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v5, v4, v6);
+  uGameUIFontShadow = TargetColor(v5, v4, v6);
 }
 
 //----- (00423AEE) --------------------------------------------------------
--- a/mm7_2.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/mm7_2.cpp	Wed May 01 20:04:24 2013 +0200
@@ -5525,7 +5525,7 @@
               v4 = 255;
               v1 = 15;
               v2 = 235;
-              return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
+              return TargetColor(v2, v1, v4);
             }
             goto LABEL_21;
           }
@@ -5545,7 +5545,7 @@
           v4 = v2;
 LABEL_30:
           v1 = v2;
-          return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
+          return TargetColor(v2, v1, v4);
         }
         goto LABEL_15;
       }
@@ -5556,7 +5556,7 @@
         v1 = 128;
 LABEL_32:
         v2 = 0;
-        return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
+        return TargetColor(v2, v1, v4);
       }
       goto LABEL_11;
     }
@@ -5569,7 +5569,7 @@
       v1 = 85;
 LABEL_23:
       v2 = 255;
-      return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
+      return TargetColor(v2, v1, v4);
     }
   }
   if ( a1 >= 23 )
@@ -5577,7 +5577,7 @@
   v4 = 255;
   v1 = 212;
   v2 = 150;
-  return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
+  return TargetColor(v2, v1, v4);
 }
 
 //----- (004583B0) --------------------------------------------------------
@@ -9875,7 +9875,7 @@
   a1.uFrameZ = a1.uFrameWidth + a1.uFrameX - 1;
   a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1;
   v1 = pItemsTable->pItems[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C + 700].pName;
-  v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v2 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   sprintf(pTmpBuf, format_4E2D80, v2, v1);
   a1.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf, 3u);
   return a1.DrawText(
--- a/mm7_3.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/mm7_3.cpp	Wed May 01 20:04:24 2013 +0200
@@ -12581,9 +12581,9 @@
   v51.uFrameWidth -= 10;
   v51.uFrameZ -= 10;
   //v54 = v1;
-  GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
-  v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u);
+  TargetColor(0xFFu, 0xFFu, 0xFFu);
+  TargetColor(0xE1u, 0xCDu, 0x23u);
+  v2 = TargetColor(0x15u, 0x99u, 0xE9u);
   pRenderer->DrawTextureIndexed(477, 0, pTexture_Dialogue_Background);
   pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_right_panel_loop != -1 ? &pIcons_LOD->pTextures[uTextureID_right_panel_loop] : 0));
   pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, (Texture *)(uTextureID_50795C != -1 ? &pIcons_LOD->pTextures[uTextureID_50795C] : 0));
@@ -12819,8 +12819,8 @@
 
 
   v32 = 0;
-  //pInString = (char *)GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  v33 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
+  //pInString = (char *)TargetColor(0xFFu, 0xFFu, 0xFFu);
+  v33 = TargetColor(0xE1u, 0xCDu, 0x23u);
   v34 = pDialogueWindow;
   //v54 = v33;
   v35 = pDialogueWindow->pStartingPosActiveItem;
@@ -12864,7 +12864,7 @@
         v43->uW = v42;
         v47 = v33;
         if ( (unsigned __int16 *)pDialogueWindow->pCurrentPosActiveItem != v46 )
-          v47 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+          v47 = TargetColor(0xFFu, 0xFFu, 0xFFu);
         v52.DrawTitleText(pFontArrus, 0, v45, v47, Str, 3u);
         v34 = pDialogueWindow;
         ++v55;
--- a/mm7_4.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/mm7_4.cpp	Wed May 01 20:04:24 2013 +0200
@@ -3485,7 +3485,7 @@
 
   a1[0] = 0;
   pPlayer = &pParty->pPlayers[v6];
-  v59 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 155);
+  v59 = TargetColor(255, 255, 155);
   //v61 = pPlayer;
   memset(pTmpBuf2, 0, sizeof(pTmpBuf2));
 
@@ -6218,7 +6218,7 @@
   v7 = pSpellStats->pInfos[v1].pName;
   a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
   a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1;
-  v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v8 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   a1.DrawTitleText(pFontArrus, 0x78u, 0xCu, v8, v7, 3u);
   a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2, 0, 0, 0);
   a1.uFrameZ = a1.uFrameX + 107;
@@ -6253,7 +6253,7 @@
     sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[427], pPlayer->pName, pGlobalTXT_LocalizationStrings[562]);// 
                                                 // "%s is in no condition to %s"
                                                 // "do anything"
-    v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 0x9Bu);
+    v2 = TargetColor(255, 255, 0x9Bu);
     v3 = pFontArrus->CalcTextHeight(pTmpBuf, &v4, 0, 0);
     v4.DrawTitleText(pFontArrus, 0, (212 - v3) / 2 + 101, v2, pTmpBuf, 3u);
     result = 0;
@@ -7286,8 +7286,8 @@
   a1.uFrameZ -= 10;
   v58 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)];
   v6 = v58;
-  v55 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
-  v7 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u);
+  v55 = TargetColor(0xE1u, 0xCDu, 0x23u);
+  v7 = TargetColor(0x15u, 0x99u, 0xE9u);
   v8 = v6->uProfession;
   if ( v8 )
     sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v6->pName, aNPCProfessionNames[v8]);
@@ -7366,9 +7366,9 @@
         if ( !v28 )
         {
           v29 = (char *)&pMonsterStats + 88 * word_F8B1A0;
-          v30 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+          v30 = TargetColor(0xFFu, 0xFFu, 0xFFu);
           v31 = *(int *)v29;
-          v32 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+          v32 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
           sprintf(pTmpBuf, &byte_4F0F98, v32, v31, v30);
           sprintf(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * (unsigned __int8)v29[8]);
           current_npc_text = pTmpBuf2;
@@ -7451,8 +7451,8 @@
     }
   }
   v34 = 0;
-  v54 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  v35 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
+  v54 = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  v35 = TargetColor(0xE1u, 0xCDu, 0x23u);
   v36 = v14->pStartingPosActiveItem;
   v55 = v35;
   for ( i = v36 + v14->pNumPresenceButton; (signed int)v36 < (signed int)i; i = pDialogueWindow->pNumPresenceButton
@@ -8365,8 +8365,8 @@
   v28.uFrameX = 483;
   v28.uFrameWidth = 148;
   v28.uFrameZ = 334;
-  v30 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  v31 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v30 = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  v31 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   v2 = 52 * (unsigned int)v0->ptr_1C;
   //v32 = (unsigned __int8)(((p2DEvents_minus1___00[v2 / 2] != 18) - 1) & 0x96) + 100;
   v32 = (unsigned __int8)(((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != 18) - 1) & 0x96) + 100;
--- a/mm7_5.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/mm7_5.cpp	Wed May 01 20:04:24 2013 +0200
@@ -9381,11 +9381,11 @@
 //----- (0040DEDB) --------------------------------------------------------
 unsigned int __stdcall R8G8B8_to_TargetFormat(int uColor)
 {
-  return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat((unsigned __int8)uColor, BYTE1(uColor), BYTE2(uColor));
+  return TargetColor((unsigned __int8)uColor, BYTE1(uColor), BYTE2(uColor));
 }
 
 //----- (0040DEF3) --------------------------------------------------------
-unsigned short GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat( unsigned __int16 r, unsigned __int16 g, unsigned __int16 b )
+unsigned short TargetColor( unsigned __int16 r, unsigned __int16 g, unsigned __int16 b )
     {
   return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) + 
                            LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) + 
@@ -10150,7 +10150,7 @@
 
   v0 = pParty->uCurrentHour;
   v6 = pMapStats->GetMapInfo(pCurrentMapName);
-  a5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x4Bu, 0x4Bu, 0x4Bu);
+  a5 = TargetColor(0x4Bu, 0x4Bu, 0x4Bu);
   pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_13);
   v7 = (unsigned __int8)pDayMoonPhase[pParty->uDaysPlayed];
   if ( (signed int)v0 <= 12 )
@@ -10272,13 +10272,13 @@
 //----- (00414162) --------------------------------------------------------
 void __cdecl uGameUIFontMain_initialize()
 {
-  uGameUIFontMain = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xAu, 0, 0);
+  uGameUIFontMain = TargetColor(0xAu, 0, 0);
 }
 
 //----- (00414174) --------------------------------------------------------
 void __cdecl uGameUIFontShadow_initialize()
 {
-  uGameUIFontShadow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE6u, 214u, 193u);
+  uGameUIFontShadow = TargetColor(0xE6u, 214u, 193u);
 }
 
 
@@ -11230,7 +11230,7 @@
           v11 = pTmpBuf;
           strcpy(pTmpBuf, v12);
         }
-        v13 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+        v13 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
         a1.DrawTitleText(pFontArrus, 0, 0xCu, v13, v11, 3u);
         a1.uFrameWidth -= 24;
         a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
@@ -11451,7 +11451,7 @@
     v2 = 255;
     v3 = 0;
   }
-  return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v3, v2, v6);
+  return TargetColor(v3, v2, v6);
 }
 
 //----- (00417939) --------------------------------------------------------
@@ -11465,9 +11465,9 @@
 
   v1 = uConditionIdx;
   v2 = 65535;
-  v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
-  v6 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x23u, 0);
-  v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
+  v3 = TargetColor(0xE1u, 0xCDu, 0x23u);
+  v6 = TargetColor(0xFFu, 0x23u, 0);
+  v4 = TargetColor(0, 0xFFu, 0);
   switch ( v1 )
   {
     case 0u:
@@ -11525,7 +11525,7 @@
   Dst.uFrameHeight -= 12;
   Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
   Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
-  v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v4 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   sprintf(pTmpBuf, format_4E2D80, v4, v3);
   Dst.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf, 3u);
   return Dst.DrawText(pFontSmallnum, 1, LOBYTE(pFontLucida->uFontHeight), 0, v2, 0, 0, 0);
@@ -11540,9 +11540,9 @@
   unsigned int red; // [sp+10h] [bp-8h]@1
   unsigned int white; // [sp+14h] [bp-4h]@1
 
-  white = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  red = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
-  yellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0);
+  white = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  red = TargetColor(0xFFu, 0, 0);
+  yellow = TargetColor(0xFFu, 0xFFu, 0);
   if ( !(uPlayerClass % 4) )
   {
     if ( byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level )
--- a/mm7_6.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/mm7_6.cpp	Wed May 01 20:04:24 2013 +0200
@@ -7292,7 +7292,7 @@
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 		HIDWORD(v733) = 0;
-		memset(&achievedAwardsIndex, 0, 4000);
+		memset(&achieved_awards, 0, 4000);
 		_this = 0;
 		v605 = (char *)pParty->pHirelings;
 		do
@@ -7300,7 +7300,7 @@
 			if ( *(int *)v605)
 			{
 			v606 = HIDWORD(v733)++;
-			achievedAwardsIndex[v606] = (int)((char *)&_this->uItemID + 1);
+			achieved_awards[v606] = (AwardType)(int)((char *)&_this->uItemID + 1);
 			}
 			_this = (ItemGen *)((char *)_this + 1);
 			v605 += 76;
@@ -7310,6 +7310,7 @@
 		if ( (signed int)pNPCStats->uNumNewNPCs > 0)
 		{
 			v730 = (int)pNPCStats->pNewNPCData;
+            __debugbreak(); // data offset
 			HIDWORD(v733) = 4 * HIDWORD(v733) + 6043152;
 			do
 			{
--- a/mm7_data.cpp	Wed May 01 17:31:10 2013 +0200
+++ b/mm7_data.cpp	Wed May 01 20:04:24 2013 +0200
@@ -43,7 +43,6 @@
 struct ViewingParams *viewparams = new ViewingParams;
 
 
-int achievedAwardsIndex[1000];
 
 #include "stru123.h"
 stru123 stru_5E4C90;
@@ -56,6 +55,9 @@
 
 #include "Awards.h"
 Award pAwards[104];
+AwardType achieved_awards[1000];
+int num_achieved_awards;
+int num_achieved_awards_2;
 
 #include "stru159.h"
 
@@ -509,7 +511,6 @@
 int pWeaponSkills[9]={3, 5, 2, 6, 4, 0, 1, 31, 7};
 int pMiscSkills[12]={35, 33, 24, 21, 32, 36, 29, 25, 22, 26, 23, 34};
 int pMagicSkills[9]={12, 13, 14, 15, 16, 17, 18, 19, 20};
-unsigned __int8 pAwardsTextColors[20];
 unsigned int pHealthBarPos[4] = {22, 137, 251, 366};
 unsigned int pManaBarPos[4] = {102, 217, 331, 447};
 char _4E2AD8_ui_colors[72];
@@ -1489,8 +1490,6 @@
 Texture *dword_50640C[12]; // weak
 unsigned int uExitCancelTextureId;
 int dword_50651C; // 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	Wed May 01 17:31:10 2013 +0200
+++ b/mm7_data.h	Wed May 01 20:04:24 2013 +0200
@@ -442,7 +442,6 @@
 extern int pWeaponSkills[9];
 extern int pMiscSkills[12];
 extern int pMagicSkills[9];
-extern unsigned __int8 pAwardsTextColors[20];
 extern unsigned int pHealthBarPos[4];
 extern unsigned int pManaBarPos[4];
 extern char _4E2AD8_ui_colors[72];
@@ -919,8 +918,6 @@
 extern Texture *dword_50640C[]; // weak
 extern unsigned int uExitCancelTextureId;
 extern int dword_50651C; // 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
@@ -1175,7 +1172,6 @@
 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
 
@@ -1544,7 +1540,7 @@
 void __fastcall intToString(int val, char *pOut);
 // int __cdecl crt_retnull_sub();
 unsigned int __stdcall R8G8B8_to_TargetFormat(int uColor); // idb
-unsigned short GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(unsigned __int16 r, unsigned __int16 g, unsigned __int16 b); // idb
+unsigned short TargetColor(unsigned __int16 r, unsigned __int16 g, unsigned __int16 b); // idb
 void __cdecl CallRenderPresent();
 void __thiscall DoBlt_Copy(unsigned __int16 *pPixels); // idb
 int __stdcall retzero_sub_40DFA7(int); // weak