changeset 956:e9292c58644a

Слияние
author Ritor1
date Thu, 02 May 2013 11:03:26 +0600
parents 21cc2b274220 (current diff) a92a34f9aef5 (diff)
children 1a47a988c0b8
files UIHouses.cpp UIRest.cpp mm7_4.cpp mm7_5.cpp stru272.h stru277.h stru279.h stru287.h stru351.h
diffstat 48 files changed, 2849 insertions(+), 3209 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/Actor.cpp	Thu May 02 11:03:26 2013 +0600
@@ -14,7 +14,7 @@
 #include "FactionTable.h"
 #include "TurnEngine.h"
 #include "MapInfo.h"
-#include "stru277.h"
+#include "CastSpellInfo.h"
 #include "Time.h"
 #include "LOD.h"
 #include "Party.h"
@@ -173,7 +173,7 @@
   NPCData *v5; // ebp@1
   unsigned int v6; // eax@1
   //signed int v7; // eax@3
-  unsigned int v8; // eax@8
+  //unsigned int v8; // eax@8
   int v9; // esi@8
   int v10; // eax@11
   GUIWindow *v11; // ecx@19
@@ -202,18 +202,6 @@
   v6 = v4->uFlags;
   if ( (v6 & 3) != 2 )
     v5->uFlags = v6 + 1;
-  /*v7 = const_2();
-  sprintf(pContainer, "evt%02d", v7);
-  if (pParty->alignment == PartyAlignment_Good)
-  {
-    v14 = "-b";
-    strcat(pContainer, v14);
-  }
-  else if ( pParty->uAlignment == 2 )
-  {
-    v14 = "-c";
-    strcat(pContainer, v14);
-  }*/
 
   switch (pParty->alignment)
   {
@@ -222,13 +210,12 @@
     case PartyAlignment_Evil:    sprintf(pContainer, "evt%02d-c", const_2()); break;
   }
 
-  v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
   pDialogueNPCCount = 0;
   uNumDialogueNPCPortraits = 1;
-  pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v8];
+  pTexture_Dialogue_Background = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
   sprintf(pContainer, "npc%03u", v5->uPortraitID);
   v9 = 0;
-  pDialogueNPCPortraits[0] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)];
+  pDialogueNPCPortraits[0] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
   dword_591084 = areWeLoadingTexture;
   uTextureID_right_panel_loop = uTextureID_right_panel;
   if ( !v5->Hired() && v5->Location2D >= 0 )
@@ -270,7 +257,7 @@
   }
   if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) != 0 )
     v9 = 4;
-  v11 = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)10, v9, 0);
+  v11 = GUIWindow::Create(0, 0, 640, 480, WINDOW_Rest, v9, 0);
   pDialogueWindow = v11;
   if (v5->Hired())
   {
@@ -281,15 +268,11 @@
       {
         if ( v12 <= 12 || v12 > 32 && (v12 <= 34 || v12 > 38 && (v12 <= 43 || v12 == 52)) )
         {
-          v11->CreateButton(
-            0x1E0u,
-            0xFAu,
-            0x8Cu,
-            LOBYTE(pFontArrus->uFontHeight) - 3,
+          v11->CreateButton(480, 250, 140, LOBYTE(pFontArrus->uFontHeight) - 3,
             1,
             0,
             UIMSG_SelectNPCDialogueOption,
-            9u,
+            9,
             0,
             "",
             0);
@@ -298,10 +281,12 @@
       }
     }
   }
-  pDialogueWindow->CreateButton(61u, 424u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0);
-  pDialogueWindow->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 2u, 0x32u, "", 0);
-  pDialogueWindow->CreateButton(292u, 424u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 3u, 0x33u, "", 0);
-  pDialogueWindow->CreateButton(407u, 424u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 4u, 0x34u, "", 0);
+
+  pDialogueWindow->CreateButton( 61, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0);
+  pDialogueWindow->CreateButton(177, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0);
+  pDialogueWindow->CreateButton(292, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0);
+  pDialogueWindow->CreateButton(407, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0);
+
   if (v17 && uActiveCharacter && !v5->Hired())
   {
     if (pParty->uCurrentHour < 5 || pParty->uCurrentHour > 21)
@@ -581,7 +566,7 @@
               v10 = v105;
 LABEL_29:
               spellnuma = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
-              a1.uType = stru_4E3ACC[15].field_0;
+              a1.uType = stru_4E3ACC[15].uType;
               v118 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v10 - 1);
               v11 = 0;
               if ( (signed int)pObjectList->uNumObjects <= 0 )
@@ -592,7 +577,7 @@
               else
               {
                 v12 = &pObjectList->pObjects->uObjectID;
-                while ( stru_4E3ACC[15].field_0 != *v12 )
+                while ( stru_4E3ACC[15].uType != *v12 )
                 {
                   ++v11;
                   v12 += 28;
@@ -660,7 +645,7 @@
               return;
             }
 LABEL_159:
-            a1.uType = stru_4E3ACC[spellnum].field_0;
+            a1.uType = stru_4E3ACC[spellnum].uType;
             v119 = 0.0;
             if ( (signed int)pObjectList->uNumObjects <= 0 )
             {
@@ -806,7 +791,7 @@
                 pitch = stru_5C6E00->Atan2(v31, (signed __int64)spellnumc);
               }
               a1.stru_24.Reset();
-              a1.uType = stru_4E3ACC[9].field_0;
+              a1.uType = stru_4E3ACC[9].uType;
               spellnumd = 0;
               if ( (signed int)pObjectList->uNumObjects <= 0 )
               {
@@ -1350,7 +1335,7 @@
   v70 = v108;
 LABEL_179:
   spellnume = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
-  a1.uType = stru_4E3ACC[SPELL_DARK_SHARPMETAL].field_0;
+  a1.uType = stru_4E3ACC[SPELL_DARK_SHARPMETAL].uType;
   v116 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v70 - 1);
   v71 = 0;
   if ( (signed int)pObjectList->uNumObjects <= 0 )
@@ -1361,7 +1346,7 @@
   else
   {
     v72 = &pObjectList->pObjects->uObjectID;
-    while ( stru_4E3ACC[SPELL_DARK_SHARPMETAL].field_0 != *v72 )
+    while ( stru_4E3ACC[SPELL_DARK_SHARPMETAL].uType != *v72 )
     {
       ++v71;
       v72 += 28;
@@ -2446,7 +2431,7 @@
   result = pPlayer->CanAct();
   if ( result )
   {
-    pStru277->_427D48(v1);
+    pCastSpellInfo->_427D48(v1);
     v4 = 0;
     v5 = pMapStats->GetMapInfo(pCurrentMapName);
     if ( v5 )
--- a/Arcomage.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/Arcomage.cpp	Thu May 02 11:03:26 2013 +0600
@@ -11,13 +11,52 @@
 #include "Party.h"
 #include "GUIWindow.h"
 #include "Events2D.h"
-#include "stru272.h"
 #include "VectorTypes.h"
 #include "texts.h"
 #include "mm7_data.h"
 
 
 
+void sub_409BE8();
+
+
+
+
+/*  388 */
+#pragma pack(push, 1)
+struct stru348
+{
+  __int16 field_0;
+  __int16 field_2;
+  __int16 field_4;
+  __int16 field_6;
+  __int16 field_8;
+  __int16 field_A;
+  __int16 field_C;
+  __int16 field_E;
+  __int16 field_10;
+  __int16 field_12;
+  int field_14;
+};
+#pragma pack(pop)
+stru348 stru_4E1890[13] =
+{
+  { 30, 100, 15,  5,  2,  2,  2, 10, 10, 10,  0},
+  { 50, 150, 20,  5,  2,  2,  2,  5,  5,  5,  1},
+  { 50, 150, 20,  5,  2,  2,  2,  5,  5,  5,  2},
+  { 75, 200, 25, 10,  3,  3,  3,  5,  5,  5,  2},
+  { 75, 200, 20, 10,  3,  3,  3,  5,  5,  5,  1},
+  {100, 300, 30, 15,  4,  4,  4, 10, 10, 10,  1},
+  {100, 300, 30, 15,  4,  4,  4, 10, 10, 10,  2},
+  {150, 400, 20, 10,  5,  5,  5, 25, 25, 25,  0},
+  {200, 500, 20, 10,  1,  1,  1, 15, 15, 15,  2},
+  {100, 300, 20, 50,  1,  1,  5,  5,  5, 25,  0},
+  {125, 350, 10, 20,  3,  1,  2, 15,  5, 10,  2},
+  {125, 350, 10, 20,  3,  1,  2, 15,  5, 10,  1},
+  {100, 300, 50, 50,  5,  3,  5, 20, 10, 20,  0}
+};
+
+
 
 
 ArcomageGame *pArcomageGame = new ArcomageGame;
@@ -26,6 +65,8 @@
 
 
 
+stru272 array_4FAC10[10];
+
 
 
 /*  267 */
@@ -1400,12 +1441,9 @@
   }
   while ( (signed int)v4 <= (signed int)&unk_4FAA20 );
 }
-// 40DFA7: using guessed type uint __stdcall retzero_sub_40DFA7(uint);
-// 4E1874: using guessed type int dword_4E1874;
-// 4FAA24: using guessed type char byte_4FAA24;
-// 4FAA2C: using guessed type char byte_4FAA2C;
-// 4FAA70: using guessed type int dword_4FAA70;
-// 4FAA77: using guessed type char am_byte_4FAA77;
+
+
+
 
 //----- (00409FE9) --------------------------------------------------------
 char __cdecl am_409FE9()
@@ -5672,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
   {
@@ -5686,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;
 }
@@ -5797,3 +5835,37 @@
   v1->bGameInProgress = 0;
   v1->field_F9 = 0;
 }
+
+
+
+
+
+
+//----- (00409BE8) --------------------------------------------------------
+void __cdecl sub_409BE8()
+{
+  void *v0; // eax@1
+  stru348 *v1; // eax@1
+  int v2; // ecx@1
+  int v3; // eax@1
+
+  v0 = window_SpeakInHouse->ptr_1C;
+  dword_4E1874 = 5;
+  v1 = &stru_4E1890[(int)((char *)v0 - 108)];
+  amuint_4E1860 = v1->field_4;
+  amuint_4E1864 = v1->field_6;
+  amuint_4E1868 = v1->field_8 - 1;
+  amuint_4E186C = v1->field_A - 1;
+  amuint_4E1870 = v1->field_C - 1;
+  amuint_505884 = v1->field_E;
+  amuint_505888 = v1->field_10;
+  amuint_50588C = v1->field_12;
+  dword_4E1878 = 1;
+  dword_4E187C = 1;
+  dword_4E1880 = 1;
+  dword_4E1884 = v1->field_0;
+  v2 = v1->field_2;
+  v3 = v1->field_14;
+  dword_4E1888 = v2;
+  dword_4DF3A4 = v3;
+}
\ No newline at end of file
--- a/Arcomage.h	Thu May 02 11:02:48 2013 +0600
+++ b/Arcomage.h	Thu May 02 11:03:26 2013 +0600
@@ -130,4 +130,73 @@
 
 extern ArcomageGame *pArcomageGame;
 extern ArcomageCard pCards[87];
-extern ArcomageGame_stru0 stru_505708[2];
\ No newline at end of file
+extern ArcomageGame_stru0 stru_505708[2];
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*  270 */
+#pragma pack(push, 1)
+struct stru272_stru0         // ARCOMAGE stuff
+{
+  int _40DFFE();
+  int _40E01A(int a2);
+  int _40E0F5(char a2, char a3);
+  int _40E133();
+  int _40E2A7();
+
+  int field_0;
+  int field_4;
+  int field_8;
+  int field_C;
+  int field_10;
+  int field_14;
+  int field_18;
+  int field_1C;
+  int field_20;
+  int field_24;
+  float field_28;
+  float field_2C;
+  float field_30;
+  int field_34;
+  int field_38;
+  int field_3C;
+  int field_40;
+  int field_44;
+  int field_48;
+  int field_4C;
+  int field_50;
+  int field_54;
+  char field_58;
+  char field_59;
+  char field_5A;
+  char field_5B;
+};
+#pragma pack(pop)
+
+
+/*  266 */
+#pragma pack(push, 1)
+struct stru272
+{
+  void _40DFD1();
+
+  struct stru272_stru0 *ptr_0;
+  char field_4[4264];
+};
+#pragma pack(pop)
+
+
+extern stru272 array_4FAC10[10];
\ No newline at end of file
--- a/Awards.h	Thu May 02 11:02:48 2013 +0600
+++ b/Awards.h	Thu May 02 11:03:26 2013 +0600
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CastSpellInfo.h	Thu May 02 11:03:26 2013 +0600
@@ -0,0 +1,38 @@
+#pragma once
+
+
+
+/*  271 */
+#pragma pack(push, 1)
+struct CastSpellInfo
+{
+  //----- (00426987) --------------------------------------------------------
+  inline CastSpellInfo()
+  {
+    field_8 = 0;
+    spellnum = 0;
+    field_6 = 0;
+    uPlayerID_2 = 0;
+    uPlayerID = 0;
+    sound_id = 0;
+  }
+
+  void _427D48(unsigned int uPlayerID);
+  unsigned int PushCastSpellInfo(__int16 a2, __int16 uPlayerID, __int16 skill_level, __int16 a5, int sound_id);
+  struct GUIWindow *sub_4219BE();
+  void _427E01_cast_spell();
+
+  __int16 spellnum;
+  unsigned __int16 uPlayerID;
+  __int16 uPlayerID_2;
+  __int16 field_6;
+  __int16 field_8;
+  __int16 forced_spell_skill_level;
+  int spell_target_pid;
+  int sound_id;
+};
+#pragma pack(pop)
+
+
+extern CastSpellInfo pCastSpellInfo[10];
+extern CastSpellInfo stru_50CDB4; // idb
--- a/Chest.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/Chest.cpp	Thu May 02 11:03:26 2013 +0600
@@ -239,11 +239,11 @@
   }
   dword_507CD8 = 0;
 
-  pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Chest, uChestID, 0);
-  pChestWindow = pGUIWindow_CurrentMenu;
-  pBtn_ExitCancel = pChestWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1,  0,  UIMSG_Escape,  0, 0,  pGlobalTXT_LocalizationStrings[79],// Exit
-                 (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0),   0);
-  pChestWindow->CreateButton(7u, 8u, 460u, 343u, 1, 0, UIMSG_C, 0, 0, "", 0);
+  pChestWindow = pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Chest, uChestID, 0);
+
+  pBtn_ExitCancel = pChestWindow->CreateButton(471, 445, 169,  35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], pIcons_LOD->GetTexture(uExitCancelTextureId),   0);// Exit
+                    pChestWindow->CreateButton(  7,   8, 460, 343, 1, 0, UIMSG_C,      0, 0, "", 0);
+
   pCurrentScreen = SCREEN_CHEST;
   pEventTimer->Pause();
   return 1;
@@ -282,7 +282,7 @@
     chestHeghtCells = pChestHeightsByType[chestBitmapId];
     sprintf(pTmpBuf, "chest%02d", pChestList->pChests[chestBitmapId].uTextureID);
     v5 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE);
-    pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0));
+    pRenderer->DrawTextureIndexed(8u, 8u, pIcons_LOD->GetTexture(v5));
 
     for (item_counter = 0; item_counter< chestWidthCells * chestHeghtCells; ++item_counter)
         {
@@ -292,9 +292,9 @@
             item_texture_id = pIcons_LOD->LoadTexture(
                 //pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName,
                 pItemsTable->pItems[pChests[uChestID].igChestItems[chest_item_index-1].uItemID].pIconName, TEXTURE_16BIT_PALETTE);
-            item_texture = (Texture *)(item_texture_id != -1 ? &pIcons_LOD->pTextures[item_texture_id] : 0);
-            itemPixelWidth = (item_texture_id != -1 ? pIcons_LOD->pTextures[item_texture_id].uTextureWidth : 24);
-            itemPixelHeght = (item_texture_id != -1 ? pIcons_LOD->pTextures[item_texture_id].uTextureHeight : 26);
+            item_texture = pIcons_LOD->GetTexture(item_texture_id);
+            itemPixelWidth = item_texture->uTextureWidth;
+            itemPixelHeght = item_texture->uTextureHeight;
             if ( itemPixelWidth < 14 )
                 itemPixelWidth = 14;
             v12 = itemPixelWidth - 14;
@@ -309,8 +309,7 @@
             sub_40F92A(&v16[itemPixelPosX + pSRZBufferLineOffsets[itemPixelPosY]], item_texture, item_counter + 1);
             }
         }
-    pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY,
-        (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0));
+    pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pIcons_LOD->GetTexture(uExitCancelTextureId));
     }
 
 
@@ -336,8 +335,8 @@
     chest_cell_heght = pChestHeightsByType[pChests[uChestID].uChestBitmapID];
     chest_cell_width = pChestWidthsByType[pChests[uChestID].uChestBitmapID];
     item_texture_id = pIcons_LOD->LoadTexture(pItemsTable->pItems[item_id].pIconName, TEXTURE_16BIT_PALETTE);
-    item_texture = (Texture *)(item_texture_id != -1 ? (int)&pIcons_LOD->pTextures[item_texture_id] : 0);
-    v6 = (item_texture_id != -1 ? pIcons_LOD->pTextures[item_texture_id].uTextureWidth : 24);
+    item_texture = pIcons_LOD->GetTexture(item_texture_id);
+    v6 = item_texture->uTextureWidth;
     if ( v6 < 14 )
         v6 = 14;
     texture_cell_width = (v6 - 14 >> 5) + 1;
@@ -417,7 +416,7 @@
   int result; // eax@11
   unsigned int v7; // eax@12
   int v8; // edx@12
-  int v9; // ecx@12
+  Texture *v9; // ecx@12
   signed int v10; // eax@12
   signed int v11; // edi@14
   unsigned int v12; // esi@14
@@ -464,11 +463,11 @@
     }
     v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v4->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
     HIWORD(v8) = 0;
-    v9 = v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0;
-    v10 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
+    v9 = pIcons_LOD->GetTexture(v7);
+    v10 = v9->uTextureWidth;
     if ( v10 < 14 )
       v10 = 14;
-    v11 = *(short *)(v9 + 26);
+    v11 = v9->uTextureHeight;
     v12 = ((v10 - 14) >> 5) + 1;
     if ( v11 < 14 )
       v11 = 14;
@@ -539,8 +538,8 @@
         pChests[ uChestID].igChestItems[item_at_cell].uMaxCharges = v6;
         }
     v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
-    v8 = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0);
-    v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
+    v8 = pIcons_LOD->GetTexture(v7);
+    v9 = v8->uTextureWidth;
     if ( v9 < 14 )
         v9 = 14;
     v10 = v8->uTextureHeight;
@@ -773,8 +772,8 @@
     //v17 = pChestWidthsByType[*(short *)((char *)v2 + (int)pChests)];
 	v17 = pChestWidthsByType[pChests[v20].uChestBitmapID];
     v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v3->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
-    v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0);
-    v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24);
+    v5 = pIcons_LOD->GetTexture(v4);
+    v6 = v5->uTextureWidth;
     if ( v6 < 14 )
         v6 = 14;
     v7 = v6 - 14;
--- a/Events.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/Events.cpp	Thu May 02 11:03:26 2013 +0600
@@ -600,11 +600,11 @@
                   {
                     pAudioPlayer->StopChannels(-1, -1);
                     window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 170, 0);
-                    window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0);
-                    window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, 0x32u, "", 0);
-                    window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, 0x33u, "", 0);
-                    window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, 0x34u, "", 0);
-                    window_SpeakInHouse->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, 9u, "", 0);
+                    window_SpeakInHouse->CreateButton( 61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, '1',  "", 0);
+                    window_SpeakInHouse->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, '2',  "", 0);
+                    window_SpeakInHouse->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, '3',  "", 0);
+                    window_SpeakInHouse->CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, '4',  "", 0);
+                    window_SpeakInHouse->CreateButton(  0,   0,  0, 0, 1,  0, UIMSG_CycleCharacters, 0, '\t', "", 0);
                     current_npc_text = pNPCTopics[90].pText;
                   }
                 }
@@ -1384,11 +1384,11 @@
 					if ( uCurrentHouse_Animation != 167 )
 						v104 = EVT_DWORD(_evt->v5);
 					window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, v104, 0);
-					window_SpeakInHouse->CreateButton( 61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, 49, "", 0);
-					window_SpeakInHouse->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, 50, "", 0);
-					window_SpeakInHouse->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, 51, "", 0);
-					window_SpeakInHouse->CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, 52, "", 0);
-					window_SpeakInHouse->CreateButton(  0,   0,  0, 0, 1,  0, UIMSG_CycleCharacters, 0, 9u, "", 0);
+					window_SpeakInHouse->CreateButton( 61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1,  '1', "", 0);
+					window_SpeakInHouse->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2,  '2', "", 0);
+					window_SpeakInHouse->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3,  '3', "", 0);
+					window_SpeakInHouse->CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4,  '4', "", 0);
+					window_SpeakInHouse->CreateButton(  0,   0,  0, 0, 1,  0, UIMSG_CycleCharacters, 0, '\t', "", 0);
 					}
 				++curr_seq_num;
 				v4 = v124;
--- a/GUIWindow.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/GUIWindow.cpp	Thu May 02 11:03:26 2013 +0600
@@ -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,21 +471,23 @@
   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:{
       byte_506360 = 0;
-      pTexture_CurrentBook = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("lb_bordr", TEXTURE_16BIT_PALETTE)];
-      pTexture_LloydBeacons[0] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbmap", TEXTURE_16BIT_PALETTE)];
-      pTexture_50635C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbmap", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6b__zoom_on  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
-      pBtn_Book_1 = v1->CreateButton(415, 13, 39, 36, 1, 0, UIMSG_B2, 0, 0, pGlobalTXT_LocalizationStrings[375], 0);
-      pBtn_Book_2 = v1->CreateButton(415, 48, 39, 36, 1, 0, UIMSG_B2, 1, 0, pGlobalTXT_LocalizationStrings[523], 0);
+      pTexture_CurrentBook = pIcons_LOD->LoadTexturePtr("lb_bordr", TEXTURE_16BIT_PALETTE);
+      pTexture_LloydBeacons[0] = pIcons_LOD->LoadTexturePtr("sbmap", TEXTURE_16BIT_PALETTE);
+      pTexture_50635C = pIcons_LOD->LoadTexturePtr("sbmap", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6b__zoom_on  = pIcons_LOD->LoadTexturePtr("tab-an-6b", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6a__zoom_off = pIcons_LOD->LoadTexturePtr("tab-an-6a", TEXTURE_16BIT_PALETTE);
+
+      pBtn_Book_1 = v1->CreateButton(415, 13, 39, 36, 1, 0, UIMSG_B2, 0, 0, pGlobalTXT_LocalizationStrings[375], 0); // Set Beacon
+      pBtn_Book_2 = v1->CreateButton(415, 48, 39, 36, 1, 0, UIMSG_B2, 1, 0, pGlobalTXT_LocalizationStrings[523], 0); // Recall Beacon
+
       v17 = &pParty->pPlayers[_506348_current_lloyd_playerid];
       v23 = 1;
       v18 = v17->pActiveSkills[14];
@@ -524,8 +527,7 @@
 
     case WINDOW_TownPortal:
     {
-      pTexture_CurrentBook = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("townport", TEXTURE_16BIT_PALETTE)];
-
+      pTexture_CurrentBook        = pIcons_LOD->LoadTexturePtr("townport", TEXTURE_16BIT_PALETTE);
       pTexture_TownPortalIcons[0] = pIcons_LOD->LoadTexturePtr("tpharmndy", TEXTURE_16BIT_PALETTE);
       pTexture_TownPortalIcons[1] = pIcons_LOD->LoadTexturePtr("tpelf", TEXTURE_16BIT_PALETTE);
       pTexture_TownPortalIcons[2] = pIcons_LOD->LoadTexturePtr("tpwarlock", TEXTURE_16BIT_PALETTE);
@@ -546,74 +548,70 @@
     break;
 
   case WINDOW_QuestBook:
-      {
-      pTexture_CurrentBook = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture( "sbquiknot", TEXTURE_16BIT_PALETTE)];
-      pSpellBookPagesTextr_10 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture( "divbar", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6b__zoom_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_7b__zoot_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7b", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7a", TEXTURE_16BIT_PALETTE)];
-      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, 0xBu, 0, pGlobalTXT_LocalizationStrings[192],// "Scroll Up"
-          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, 0xAu, 0, pGlobalTXT_LocalizationStrings[193],// "Scroll Down"
-          pTex_tab_an_7b__zoot_on, 0);
-      awards_count = 0;
-      memset(&achievedAwardsIndex, 0, 4000);
+  {
+      pTexture_CurrentBook    = pIcons_LOD->LoadTexturePtr("sbquiknot", TEXTURE_16BIT_PALETTE);
+      pSpellBookPagesTextr_10 = pIcons_LOD->LoadTexturePtr( "divbar", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6b__zoom_on = pIcons_LOD->LoadTexturePtr("tab-an-6b", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_7b__zoot_on = pIcons_LOD->LoadTexturePtr("tab-an-7b", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6a__zoom_off = pIcons_LOD->LoadTexturePtr("tab-an-6a", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_7a__zoot_off = pIcons_LOD->LoadTexturePtr("tab-an-7a", TEXTURE_16BIT_PALETTE);
+      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, 0xBu, 0, pGlobalTXT_LocalizationStrings[192],// "Scroll Up"
+                                     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, 0xAu, 0, pGlobalTXT_LocalizationStrings[193],// "Scroll Down"
+                                     pTex_tab_an_7b__zoot_on, 0);
+      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:
       {
-      pTexture_AutonotesBook   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbautnot", TEXTURE_16BIT_PALETTE)];
-      pSpellBookPagesTextr_10     = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("divbar", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6b__zoom_on  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_7b__zoot_on  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7b", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7a", TEXTURE_16BIT_PALETTE)];
-      pTexture_506394 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-1b", TEXTURE_16BIT_PALETTE)];
-      pTexture_506390 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-1a", TEXTURE_16BIT_PALETTE)];
-      pTexture_50638C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-2b", TEXTURE_16BIT_PALETTE)];
-      pTexture_506388 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-2a", TEXTURE_16BIT_PALETTE)];
-      pTexture_506384 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-3b", TEXTURE_16BIT_PALETTE)];
-      pTexture_506380 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-3a", TEXTURE_16BIT_PALETTE)];
-      pTexture_50637C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-5b", TEXTURE_16BIT_PALETTE)];
-      pTexture_506378 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-5a", TEXTURE_16BIT_PALETTE)];
-      pTexture_506374 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-4b", TEXTURE_16BIT_PALETTE)];
-      pTexture_506370 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-4a", TEXTURE_16BIT_PALETTE)];
-      pTexture_50636C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-8b", TEXTURE_16BIT_PALETTE)];
-      pTexture_506368 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-8a", TEXTURE_16BIT_PALETTE)];
-      pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 0xBu, 0,
-          pGlobalTXT_LocalizationStrings[193], pTex_tab_an_6b__zoom_on, 0);
-      pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 0xAu, 0,
-          pGlobalTXT_LocalizationStrings[192], pTex_tab_an_7b__zoot_on, 0);
-      pBtn_Book_3 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 2u, 0,
-          pGlobalTXT_LocalizationStrings[85], pTexture_506394, 0);// "Potion Notes"
-      pBtn_Book_4 = v1->CreateButton(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 3u, 0,
-          pGlobalTXT_LocalizationStrings[137], pTexture_50638C, 0);// "Fountain Notes"
-      pBtn_Book_5 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 4u, 0,
-          pGlobalTXT_LocalizationStrings[8], pTexture_506384, 0);// "Obelisk Notes"
-      pBtn_Book_6 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 5u, 0,
-          pGlobalTXT_LocalizationStrings[141], pTexture_50637C, 0);// "Seer Notes"
-      pBtn_Autonotes_Misc = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 6u, 0,
-          pGlobalTXT_LocalizationStrings[123], pTexture_506374, 0);// "Miscellaneous Notes"
-      v9 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 7u, 0,
-          pGlobalTXT_LocalizationStrings[662], pTexture_50636C, 0);// "Instructors"
+      pTexture_AutonotesBook   = pIcons_LOD->LoadTexturePtr("sbautnot", TEXTURE_16BIT_PALETTE);
+      pSpellBookPagesTextr_10  = pIcons_LOD->LoadTexturePtr("divbar", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6b__zoom_on  = pIcons_LOD->LoadTexturePtr("tab-an-6b", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_7b__zoot_on  = pIcons_LOD->LoadTexturePtr("tab-an-7b", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6a__zoom_off = pIcons_LOD->LoadTexturePtr("tab-an-6a", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_7a__zoot_off = pIcons_LOD->LoadTexturePtr("tab-an-7a", TEXTURE_16BIT_PALETTE);
+      pTexture_506394 = pIcons_LOD->LoadTexturePtr("tab-an-1b", TEXTURE_16BIT_PALETTE);
+      pTexture_506390 = pIcons_LOD->LoadTexturePtr("tab-an-1a", TEXTURE_16BIT_PALETTE);
+      pTexture_50638C = pIcons_LOD->LoadTexturePtr("tab-an-2b", TEXTURE_16BIT_PALETTE);
+      pTexture_506388 = pIcons_LOD->LoadTexturePtr("tab-an-2a", TEXTURE_16BIT_PALETTE);
+      pTexture_506384 = pIcons_LOD->LoadTexturePtr("tab-an-3b", TEXTURE_16BIT_PALETTE);
+      pTexture_506380 = pIcons_LOD->LoadTexturePtr("tab-an-3a", TEXTURE_16BIT_PALETTE);
+      pTexture_50637C = pIcons_LOD->LoadTexturePtr("tab-an-5b", TEXTURE_16BIT_PALETTE);
+      pTexture_506378 = pIcons_LOD->LoadTexturePtr("tab-an-5a", TEXTURE_16BIT_PALETTE);
+      pTexture_506374 = pIcons_LOD->LoadTexturePtr("tab-an-4b", TEXTURE_16BIT_PALETTE);
+      pTexture_506370 = pIcons_LOD->LoadTexturePtr("tab-an-4a", TEXTURE_16BIT_PALETTE);
+      pTexture_50636C = pIcons_LOD->LoadTexturePtr("tab-an-8b", TEXTURE_16BIT_PALETTE);
+      pTexture_506368 = pIcons_LOD->LoadTexturePtr("tab-an-8a", TEXTURE_16BIT_PALETTE);
+
+      pBtn_Book_1                = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1,   50, 34, 1, 0, UIMSG_AutonotesBook, 11, 0, pGlobalTXT_LocalizationStrings[193], pTex_tab_an_6b__zoom_on, 0);
+      pBtn_Book_2                = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38,  50, 34, 1, 0, UIMSG_AutonotesBook, 10, 0, pGlobalTXT_LocalizationStrings[192], pTex_tab_an_7b__zoot_on, 0);
+      pBtn_Book_3                = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, 50, 34, 1, 0, UIMSG_AutonotesBook,  2, 0, pGlobalTXT_LocalizationStrings[85], pTexture_506394, 0); // "Potion Notes"
+      pBtn_Book_4                = v1->CreateButton(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, 50, 34, 1, 0, UIMSG_AutonotesBook,  3, 0, pGlobalTXT_LocalizationStrings[137], pTexture_50638C, 0); // "Fountain Notes"
+      pBtn_Book_5                = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, 50, 34, 1, 0, UIMSG_AutonotesBook,  4, 0, pGlobalTXT_LocalizationStrings[8], pTexture_506384, 0); // "Obelisk Notes"
+      pBtn_Book_6                = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, 50, 34, 1, 0, UIMSG_AutonotesBook,  5, 0, pGlobalTXT_LocalizationStrings[141], pTexture_50637C, 0); // "Seer Notes"
+      pBtn_Autonotes_Misc        = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, 50, 34, 1, 0, UIMSG_AutonotesBook,  6, 0, pGlobalTXT_LocalizationStrings[123], pTexture_506374, 0); // "Miscellaneous Notes"
+      pBtn_Autonotes_Instructors = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, 50, 34, 1, 0, UIMSG_AutonotesBook,  7, 0, pGlobalTXT_LocalizationStrings[662], pTexture_50636C, 0); // "Instructors"
+
+      v9 = pBtn_Autonotes_Instructors;
       v10 = dword_506528;
-      pBtn_Autonotes_Instructors = v9;
-      awards_count = 0;
+      num_achieved_awards = 0;
       while ( v10 < 196 )
           {
           if ( dword_506568 == pAutonoteTxt[v10-1].eType)//dword_72371C[2 * v10] )
@@ -624,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;
                       }
                   }
               }
@@ -633,79 +631,56 @@
           }
       }
       break;
+
   case WINDOW_MapsBook:
-      {
+  {
       dword_506364 = 1;
-      pSpellBookPagesTextr_12 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbmap", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6b__zoom_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoom-on", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_7b__zoot_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoot-on", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoom-off", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoot-off", TEXTURE_16BIT_PALETTE)];
-      pTexture_506394 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabNon", TEXTURE_16BIT_PALETTE)];
-      pTexture_506390 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabNoff", TEXTURE_16BIT_PALETTE)];
-      pTexture_50638C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabSon", TEXTURE_16BIT_PALETTE)];
-      pTexture_506388 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabSoff", TEXTURE_16BIT_PALETTE)];
-      pTexture_506384 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabEon", TEXTURE_16BIT_PALETTE)];
-      pTexture_506380 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabEoff", TEXTURE_16BIT_PALETTE)];
-      pTexture_50637C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabWon", TEXTURE_16BIT_PALETTE)];
-      pTexture_506378 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabWoff", TEXTURE_16BIT_PALETTE)];
-      pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 0, 0,
-          pGlobalTXT_LocalizationStrings[251], pTex_tab_an_6b__zoom_on, 0);// "Zoom In"
-      pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 1, 0,
-          pGlobalTXT_LocalizationStrings[252], pTex_tab_an_7b__zoot_on, 0);// "Zoom Out"
-      pBtn_Book_3 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 113, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 2, 0,
-          pGlobalTXT_LocalizationStrings[192], (Texture *)"", 0);// Scroll Up
-      pBtn_Book_4 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 150, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 3, 0,
-          pGlobalTXT_LocalizationStrings[193], (Texture *)"", 0);// Scroll Down
-      pBtn_Book_5 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 4, 0,
-          pGlobalTXT_LocalizationStrings[573], (Texture *)"", 0);// "Scroll Right"
-      pBtn_Book_6 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 5, 0,
-          pGlobalTXT_LocalizationStrings[572], (Texture *)"", 0);// "Scroll Left"
+      pSpellBookPagesTextr_12  = pIcons_LOD->LoadTexturePtr("sbmap", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6b__zoom_on  = pIcons_LOD->LoadTexturePtr("zoom-on", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_7b__zoot_on  = pIcons_LOD->LoadTexturePtr("zoot-on", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6a__zoom_off = pIcons_LOD->LoadTexturePtr("zoom-off", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_7a__zoot_off = pIcons_LOD->LoadTexturePtr("zoot-off", TEXTURE_16BIT_PALETTE);
+      pTexture_506394 = pIcons_LOD->LoadTexturePtr("tabNon", TEXTURE_16BIT_PALETTE);
+      pTexture_506390 = pIcons_LOD->LoadTexturePtr("tabNoff", TEXTURE_16BIT_PALETTE);
+      pTexture_50638C = pIcons_LOD->LoadTexturePtr("tabSon", TEXTURE_16BIT_PALETTE);
+      pTexture_506388 = pIcons_LOD->LoadTexturePtr("tabSoff", TEXTURE_16BIT_PALETTE);
+      pTexture_506384 = pIcons_LOD->LoadTexturePtr("tabEon", TEXTURE_16BIT_PALETTE);
+      pTexture_506380 = pIcons_LOD->LoadTexturePtr("tabEoff", TEXTURE_16BIT_PALETTE);
+      pTexture_50637C = pIcons_LOD->LoadTexturePtr("tabWon", TEXTURE_16BIT_PALETTE);
+      pTexture_506378 = pIcons_LOD->LoadTexturePtr("tabWoff", TEXTURE_16BIT_PALETTE);
+
+      pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1,   50, 34, 1, 0, UIMSG_AutonotesBook, 0, 0, pGlobalTXT_LocalizationStrings[251], pTex_tab_an_6b__zoom_on, 0);// "Zoom In"
+      pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38,  50, 34, 1, 0, UIMSG_AutonotesBook, 1, 0, pGlobalTXT_LocalizationStrings[252], pTex_tab_an_7b__zoot_on, 0);// "Zoom Out"
+      pBtn_Book_3 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 113, 50, 34, 1, 0, UIMSG_AutonotesBook, 2, 0, pGlobalTXT_LocalizationStrings[192], (Texture *)"", 0);// Scroll Up
+      pBtn_Book_4 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 150, 50, 34, 1, 0, UIMSG_AutonotesBook, 3, 0, pGlobalTXT_LocalizationStrings[193], (Texture *)"", 0);// Scroll Down
+      pBtn_Book_5 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, 50, 34, 1, 0, UIMSG_AutonotesBook, 4, 0, pGlobalTXT_LocalizationStrings[573], (Texture *)"", 0);// "Scroll Right"
+      pBtn_Book_6 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, 50, 34, 1, 0, UIMSG_AutonotesBook, 5, 0, pGlobalTXT_LocalizationStrings[572], (Texture *)"", 0);// "Scroll Left"
       }
       break;
-  case WINDOW_CalendarBook: {
-      pSpellBookPagesTextr_13 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbdate-time", TEXTURE_16BIT_PALETTE)];
-      pTex_moon_new = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_new", TEXTURE_16BIT_PALETTE)];
-      pTex_moon_4   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_4", TEXTURE_16BIT_PALETTE)];
-      pTex_moon_2   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_2", TEXTURE_16BIT_PALETTE)];
-      pTex_moon_2_2 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_2", TEXTURE_16BIT_PALETTE)];
-      pTex_moon_ful = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_ful", TEXTURE_16BIT_PALETTE)];
+
+  case WINDOW_CalendarBook:
+  {
+      pSpellBookPagesTextr_13 = pIcons_LOD->LoadTexturePtr("sbdate-time", TEXTURE_16BIT_PALETTE);
+      pTex_moon_new = pIcons_LOD->LoadTexturePtr("moon_new", TEXTURE_16BIT_PALETTE);
+      pTex_moon_4   = pIcons_LOD->LoadTexturePtr("moon_4", TEXTURE_16BIT_PALETTE);
+      pTex_moon_2   = pIcons_LOD->LoadTexturePtr("moon_2", TEXTURE_16BIT_PALETTE);
+      pTex_moon_2_2 = pIcons_LOD->LoadTexturePtr("moon_2", TEXTURE_16BIT_PALETTE);
+      pTex_moon_ful = pIcons_LOD->LoadTexturePtr("moon_ful", TEXTURE_16BIT_PALETTE);
       }
       break;
+
   case WINDOW_HistoryBook:
-      {
-      pSpellBookPagesTextr_11 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbplayrnot", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6b__zoom_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_7b__zoot_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7b", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7a", TEXTURE_16BIT_PALETTE)];
-      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,
-          0xBu,
-          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,
-          0xAu,
-          0,
-          pGlobalTXT_LocalizationStrings[193],
-          pTex_tab_an_7b__zoot_on,
-          0);
-      awards_count = 0;
+  {
+      pSpellBookPagesTextr_11  = pIcons_LOD->LoadTexturePtr("sbplayrnot", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6b__zoom_on  = pIcons_LOD->LoadTexturePtr("tab-an-6b", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_7b__zoot_on  = pIcons_LOD->LoadTexturePtr("tab-an-7b", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6a__zoom_off = pIcons_LOD->LoadTexturePtr("tab-an-6a", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_7a__zoot_off = pIcons_LOD->LoadTexturePtr("tab-an-7a", TEXTURE_16BIT_PALETTE);
+
+      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);
+
+      num_achieved_awards = 0;
       v26.uFrameX = 48;
       v26.uFrameY = 70;
       v26.uFrameWidth = 360;
@@ -714,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 )
           {
@@ -732,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);
                               }
@@ -881,11 +856,11 @@
   if ( !pIcons_LOD->uNumPrevLoadedFiles )
     pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
   pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
-  pSpellBookPagesTextr_9 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("book", TEXTURE_16BIT_PALETTE)];
-  pTexture_pagemask = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("pagemask", TEXTURE_16BIT_PALETTE)];
-  pTexture_506448   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ib-m5-u", TEXTURE_16BIT_PALETTE)];
-  ptr_506440        = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ib-m5-d", TEXTURE_16BIT_PALETTE)];
-  pTexture_50643C   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ib-m6-u",TEXTURE_16BIT_PALETTE)];
+  pSpellBookPagesTextr_9 = pIcons_LOD->LoadTexturePtr("book", TEXTURE_16BIT_PALETTE);
+  pTexture_pagemask = pIcons_LOD->LoadTexturePtr("pagemask", TEXTURE_16BIT_PALETTE);
+  pTexture_506448   = pIcons_LOD->LoadTexturePtr("ib-m5-u", TEXTURE_16BIT_PALETTE);
+  ptr_506440        = pIcons_LOD->LoadTexturePtr("ib-m5-d", TEXTURE_16BIT_PALETTE);
+  pTexture_50643C   = pIcons_LOD->LoadTexturePtr("ib-m6-u",TEXTURE_16BIT_PALETTE);
   //v0 = 1;
 
   static const char *texNames[9] =
@@ -914,7 +889,7 @@
   if ( !pIcons_LOD->uNumPrevLoadedFiles )
     pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
   pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
-  pTexture_mapbordr = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("mapbordr", TEXTURE_16BIT_PALETTE)];
+  pTexture_mapbordr = pIcons_LOD->LoadTexturePtr("mapbordr", TEXTURE_16BIT_PALETTE);
   pBookFont = LoadFont("book.fnt", "FONTPAL", NULL);
   pBook2Font = LoadFont("book2.fnt", "FONTPAL", NULL);
   pAutonoteFont = LoadFont("autonote.fnt", "FONTPAL", NULL);
@@ -987,31 +962,24 @@
   }
   //while ( (signed int)v3 < 11 );
 
-  CreateButton(0, 0, 0, 0, 1, 0, UIMSG_33, 0, 9u, "", 0);
+  CreateButton(0, 0, 0, 0, 1, 0, UIMSG_33, 0, '\t', "", 0);
   if ( a2 )
     _41D08F(a2, 0, 0, 0);
-  if (pPlayer->pActiveSkills[PLAYER_SKILL_FIRE])
-    CreateButton(0x18Fu, 0xAu, 0x32u, 0x24u, 1, 0, UIMSG_OpenSpellbookPage, 0, 0, aSpellSchoolNames[0], 0);
-  if (pPlayer->pActiveSkills[PLAYER_SKILL_AIR])
-    CreateButton(0x18Fu, 0x2Eu, 0x32u, 0x24u, 1, 0, UIMSG_OpenSpellbookPage, 1u, 0, aSpellSchoolNames[1], 0);
-  if (pPlayer->pActiveSkills[PLAYER_SKILL_WATER])
-    CreateButton(0x18Fu, 0x53u, 0x32u, 0x24u, 1, 0, UIMSG_OpenSpellbookPage, 2u, 0, aSpellSchoolNames[2], 0);
-  if (pPlayer->pActiveSkills[PLAYER_SKILL_EARTH])
-    CreateButton(0x18Fu, 0x79u, 0x32u, 0x24u, 1, 0, UIMSG_OpenSpellbookPage, 3u, 0, aSpellSchoolNames[3], 0);
-  if (pPlayer->pActiveSkills[PLAYER_SKILL_SPIRIT])
-    CreateButton(0x18Fu, 0x9Eu, 0x32u, 0x24u, 1, 0, UIMSG_OpenSpellbookPage, 4u, 0, aSpellSchoolNames[4], 0);
-  if (pPlayer->pActiveSkills[PLAYER_SKILL_MIND])
-    CreateButton(0x190u, 0xC4u, 0x32u, 0x24u, 1, 0, UIMSG_OpenSpellbookPage, 5u, 0, aSpellSchoolNames[5], 0);
-  if (pPlayer->pActiveSkills[PLAYER_SKILL_BODY])
-    CreateButton(0x190u, 0xEAu, 0x32u, 0x24u, 1, 0, UIMSG_OpenSpellbookPage, 6u, 0, aSpellSchoolNames[6], 0);
-  if (pPlayer->pActiveSkills[PLAYER_SKILL_LIGHT])
-    CreateButton(0x190u, 0x10Fu, 0x32u, 0x24u, 1, 0, UIMSG_OpenSpellbookPage, 7u, 0, aSpellSchoolNames[7], 0);
-  if (pPlayer->pActiveSkills[PLAYER_SKILL_DARK])
-    CreateButton(0x190u, 0x133u, 0x32u, 0x24u, 1, 0, UIMSG_OpenSpellbookPage, 8u, 0, aSpellSchoolNames[8], 0);
-  CreateButton(0x1DCu, 0x1C2u, pTexture_506444->uTextureWidth, pTexture_506444->uTextureHeight, 1, 78, UIMSG_58, 0, 0, "", 0);
-  pBtn_InstallRemoveSpell = CreateButton(0x1DCu, 0x1C2u, 0x30u, 0x20u, 1, 78, UIMSG_58, 0, 0, "", pTexture_506444, 0);
-  CreateButton(0x231u, 0x1C2u, ptr_506440->uTextureWidth, ptr_506440->uTextureHeight, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], 0);
-  pBtn_CloseBook = CreateButton(0x231u, 0x1C2u, 0x30u, 0x20u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], ptr_506440, 0);
+
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_FIRE])   CreateButton(399,  10, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 0, 0, aSpellSchoolNames[0], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_AIR])    CreateButton(399,  46, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 1, 0, aSpellSchoolNames[1], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_WATER])  CreateButton(399,  83, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 2, 0, aSpellSchoolNames[2], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_EARTH])  CreateButton(399, 121, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 3, 0, aSpellSchoolNames[3], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_SPIRIT]) CreateButton(399, 158, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 4, 0, aSpellSchoolNames[4], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_MIND])   CreateButton(400, 196, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 5, 0, aSpellSchoolNames[5], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_BODY])   CreateButton(400, 234, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 6, 0, aSpellSchoolNames[6], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_LIGHT])  CreateButton(400, 271, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 7, 0, aSpellSchoolNames[7], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_DARK])   CreateButton(400, 307, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 8, 0, aSpellSchoolNames[8], 0);
+
+                            CreateButton(476, 450, pTexture_506444->uTextureWidth, pTexture_506444->uTextureHeight, 1, 78, UIMSG_58,     0, 0, "", 0);
+  pBtn_InstallRemoveSpell = CreateButton(476, 450, 48,                             32,                              1, 78, UIMSG_58,     0, 0, "", pTexture_506444, 0);
+                            CreateButton(561, 450, ptr_506440->uTextureWidth,      ptr_506440->uTextureHeight,      1,  0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], 0);
+  pBtn_CloseBook          = CreateButton(561, 450, 48,                             32,                              1,  0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], ptr_506440, 0);
 }
 // 50640C: using guessed type int dword_50640C[];
 
@@ -1038,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 )
@@ -1298,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);
 }
@@ -1894,16 +1862,16 @@
             pWindow->_41D08F(num_menu_buttons, 1, 0, 1);
           }
           break;
+
         case WINDOW_ChangeLocation:
           pMainScreenNum = pCurrentScreen;
           pCurrentScreen = SCREEN_CHANGE_LOCATION;
-          pBtn_ExitCancel = pWindow->CreateButton(0x236u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_5B, 0, 0x4Eu, pGlobalTXT_LocalizationStrings[156],//   
-                         pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);
-          pBtn_YES = pWindow->CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_OnTravelByFoot, 0, 0x59u, pWindow->Hint,
-                         pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0);
-          pWindow->CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 0x3Fu, 0x49u, 1, 0, UIMSG_OnTravelByFoot, 1u, 0x20u, pWindow->Hint, 0, 0, 0);
-          pWindow->CreateButton(8u, 8u, 0x1CCu, 0x158u, 1, 0, UIMSG_OnTravelByFoot, 1u, 0, pWindow->Hint, 0);
+          pBtn_ExitCancel = pWindow->CreateButton(                  566,                   445,  75,  33, 1, 0, UIMSG_5B,             0, 'N', pGlobalTXT_LocalizationStrings[156], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);//   
+          pBtn_YES        = pWindow->CreateButton(                  486,                   445,  75,  33, 1, 0, UIMSG_OnTravelByFoot, 0, 'Y', pWindow->Hint, pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0);
+                            pWindow->CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0],  63,  73, 1, 0, UIMSG_OnTravelByFoot, 1, ' ', pWindow->Hint, 0, 0, 0);
+                            pWindow->CreateButton(                    8,                     8, 460, 344, 1, 0, UIMSG_OnTravelByFoot, 1,   0, pWindow->Hint, 0);
           break;
+
         case WINDOW_SpellBook: //   
           InitializeBookTextures();
           pWindow->OpenSpellBook();
@@ -1917,10 +1885,10 @@
       return pWindow;
     }
 //LABEL_62:
-    pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0);
-    pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, 0x32u, "", 0);
-    pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, 0x33u, "", 0);
-    pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, 0x34u, "", 0);
+    pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, '1', "", 0);
+    pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, '2', "", 0);
+    pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, '3', "", 0);
+    pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, '4', "", 0);
     pWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, 9u, "", 0);
     return pWindow;
   }
@@ -1969,12 +1937,10 @@
     {
       pMainScreenNum = pCurrentScreen;
       pCurrentScreen = SCREEN_INPUT_BLV;
-      pBtn_ExitCancel = pWindow->CreateButton(0x236u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_19C, 0, 0x4Eu, pGlobalTXT_LocalizationStrings[34],//
-                     pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);
-      pBtn_YES = pWindow->CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_TransitionUI_Confirm, 0, 0x59u, pWindow->Hint,
-                     pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0);
-      pWindow->CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 0x3Fu, 0x49u, 1, 0, UIMSG_TransitionUI_Confirm, 1, 0x20u, pWindow->Hint, 0);
-      pWindow->CreateButton(8u, 8u, 0x1CCu, 0x158u, 1, 0, UIMSG_TransitionUI_Confirm, 1u, 0, pWindow->Hint, 0);
+      pBtn_ExitCancel = pWindow->CreateButton(0x236u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_19C, 0, 'N', pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);//
+      pBtn_YES        = pWindow->CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_TransitionUI_Confirm, 0, 'Y', pWindow->Hint, pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0);
+                        pWindow->CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 0x3Fu, 0x49u, 1, 0, UIMSG_TransitionUI_Confirm, 1, 0x20u, pWindow->Hint, 0);
+                        pWindow->CreateButton(8, 8, 0x1CCu, 0x158u, 1, 0, UIMSG_TransitionUI_Confirm, 1u, 0, pWindow->Hint, 0);
       return pWindow;
     }
     if (eWindowType == WINDOW_1B)
@@ -1988,18 +1954,18 @@
     if (eWindowType == WINDOW_Scroll)
       //goto LABEL_62;
     {
-      pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0);
-      pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, 0x32u, "", 0);
-      pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, 0x33u, "", 0);
-      pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, 0x34u, "", 0);
-      pWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, 9u, "", 0);
+      pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, '1', "", 0);
+      pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, '2', "", 0);
+      pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, '3', "", 0);
+      pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, '4', "", 0);
+      pWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, '\t', "", 0);
       return pWindow;
     }
     if (eWindowType == WINDOW_CastSpell_InInventory)
     {
       pMouse->SetCursorBitmap("MICON2");
       pBtn_ExitCancel = pWindow->CreateButton(0x188u, 0x13Eu, 0x4Bu, 0x21u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],//
-                     (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), 0);
+                     pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[39], 2);// 
       ++pIcons_LOD->uTexturePacksCount;
       pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
--- a/GUIWindow.h	Thu May 02 11:02:48 2013 +0600
+++ b/GUIWindow.h	Thu May 02 11:03:26 2013 +0600
@@ -262,7 +262,7 @@
   WINDOW_Book = 0x9,
   WINDOW_Dialogue = 0xA,
   WINDOW_QuickReference = 12,
-  WINDOW_Rest = 0x10,
+  WINDOW_Rest = 16,
   WINDOW_ChangeLocation = 17,
   WINDOW_SpellBook = 0x12,
   WINDOW_GreetingNPC = 19,
--- a/Game.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/Game.cpp	Thu May 02 11:03:26 2013 +0600
@@ -9,7 +9,6 @@
 #include "Time.h"
 #include "Outdoor.h"
 #include "Overlays.h"
-#include "stru279.h"
 #include "AudioPlayer.h"
 #include "LOD.h"
 #include "OSInfo.h"
@@ -200,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)
   {
@@ -225,11 +224,11 @@
     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();
-  ++stru_51076C.field_8;
+
   _unused_5B5924_is_travel_ui_drawn = false;
   if (v4)
     pMouse->bRedraw = true;
@@ -767,7 +766,6 @@
     WriteWindowsRegistryInt("window X", Rect.left);
     WriteWindowsRegistryInt("window Y", Rect.top);
   }
-  WriteWindowsRegistryInt("debug flags", stru_51076C.registry_debug_flags);
   WriteWindowsRegistryInt("valAlwaysRun", bAlwaysRun);
   pItemsTable->Release();
   pNPCStats->Release();
--- a/Indoor.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/Indoor.cpp	Thu May 02 11:03:26 2013 +0600
@@ -1206,7 +1206,7 @@
 
   v1 = &pIndoor->pFaces[uFaceID];
   v2 = &pIndoor->pFaceExtras[v1->uFaceExtraID];
-  v3 = (Texture *)(v1->uBitmapID != -1 ? (int)&pBitmaps_LOD->pTextures[v1->uBitmapID] : 0);
+  v3 = pBitmaps_LOD->GetTexture(v1->uBitmapID);
   stru_F8AD28.pDeltaUV[0] = v2->sTextureDeltaU;
   stru_F8AD28.pDeltaUV[1] = v2->sTextureDeltaV;
   v4 = GetTickCount();
@@ -1619,7 +1619,7 @@
     v1 = pTextureFrameTable->GetFrameTexture(this->uBitmapID, pBLVRenderParams->field_0_timer_);
   else
     v1 = uBitmapID;
-  return (Texture *)(v1 != -1 ? (int)&pBitmaps_LOD->pTextures[v1] : 0);
+  return pBitmaps_LOD->GetTexture(v1);
 }
 
 
@@ -3705,7 +3705,7 @@
             {
               v52 = v15->uBitmapID;
               if ( v52 != -1 )
-                v28->sTextureDeltaV -= v82 + (v52 != -1 ? pBitmaps_LOD->pTextures[v52].uTextureHeight : 26);
+                v28->sTextureDeltaV -= v82 + pBitmaps_LOD->GetTexture(v52)->uTextureHeight;
             }
           }
           if ( BYTE2(v15->uAttributes) & 4 )
--- a/Items.h	Thu May 02 11:02:48 2013 +0600
+++ b/Items.h	Thu May 02 11:03:26 2013 +0600
@@ -387,4 +387,19 @@
 	+10 Water Resistance and +2 Alchemy skill.	70
 	Prevents damage from drowning.	71
 	Prevents damage from falling.	72
-*/
\ No newline at end of file
+*/
+
+
+/*  391 */
+#pragma pack(push, 1)
+struct stru351_summoned_item
+{
+  int field_0_expire_second;
+  int field_4_expire_minute;
+  int field_8_expire_hour;
+  int field_C_expire_day;
+  int field_10_expire_week;
+  int field_14_exprie_month;
+  int field_18_expire_year;
+};
+#pragma pack(pop)
\ No newline at end of file
--- a/LOD.h	Thu May 02 11:02:48 2013 +0600
+++ b/LOD.h	Thu May 02 11:03:26 2013 +0600
@@ -162,8 +162,7 @@
   inline Texture *GetTexture(int idx)
   {
     assert(idx < 1000);
-    if (idx == -1)
-      return nullptr;
+    if (idx == -1) return nullptr; // we need to return dummy texture here
     return pTextures + idx;
   }
 
--- a/MM7.h	Thu May 02 11:02:48 2013 +0600
+++ b/MM7.h	Thu May 02 11:03:26 2013 +0600
@@ -32,33 +32,6 @@
 
 #include "VectorTypes.h"
 #include "IndoorCameraD3D.h"
-/*#include "LOD.h"
-#include "Texture.h"
-#include "Mouse.h"
-#include "Overlays.h"
-#include "Game.h"
-#include "Items.h"
-#include "Actor.h"
-#include "Arcomage.h"
-#include "Render.h"
-#include "Time.h"
-#include "GUIWindow.h"
-#include "GUIButton.h"
-#include "GUIProgressBar.h"
-#include "GUIFont.h"
-#include "NPC.h"
-#include "PaletteManager.h"
-#include "Party.h"
-#include "AudioPlayer.h"
-#include "VideoPlayer.h"
-#include "Chest.h"
-#include "Allocator.h"
-#include "IndoorCamera.h"
-#include "Party.h"
-#include "Outdoor.h"
-
-#include "mm7_data.h"
-*/
 
 
 
@@ -66,35 +39,8 @@
 
 
 
-/*  285 */
-#pragma pack(push, 1)
-struct stru289
-{
-  //----- (0046263C) --------------------------------------------------------
-  inline stru289()
-  {
-    this->field_64 = 2;
-    this->field_74 = 0;
-    this->field_70 = 0;
-    this->field_6C = 0;
-    this->field_68 = 0;
-  }
-
-
-  char field_0[100];
-  int field_64;
-  int field_68;
-  int field_6C;
-  int field_70;
-  int field_74;
-};
-#pragma pack(pop)
-extern stru289 stru_6BE158;
-
-
-
 /*  288 */
-#pragma pack(push, 1)
+/*#pragma pack(push, 1)
 struct CheckHRESULT_stru0
 {
   void CheckHRESULT(HRESULT a2, const char *Str, int a4, unsigned int uType);
@@ -105,7 +51,7 @@
 
   void (__thiscall ***vdestructor_ptr)(CheckHRESULT_stru0 *, bool);
 };
-#pragma pack(pop)
+#pragma pack(pop)*/
 
 
 
@@ -141,40 +87,10 @@
 
 
 
-/*  369 */
-#pragma pack(push, 1)
-
-#pragma pack(pop)
-extern int paperdoll_Weapon[4][16][2];
-
-/*  371 */ // stru331 - deleted
 
 
-/*  372 */
-#pragma pack(push, 1)
-/*struct stru332
-{
-  unsigned int texids[11];
-  int texid1;
-  int texid2;
-  int texid3;
-  int texid4;
-  int texid5;
-};*/
-#pragma pack(pop)
-extern int paperdoll_helm_texture[2][16];
 
 
-/*  373 */
-#pragma pack(push, 1)
-/*struct stru333
-{
-  unsigned int texids[5];
-  int texid1;
-  int texid2;
-};*/
-#pragma pack(pop)
-extern int paperdoll_belt_texture[2][7];
 
 
 /*  374 */
@@ -204,38 +120,3 @@
 };
 #pragma pack(pop)
 
-
-
-
-
-
-
-
-
-
-
-
-
-/*  388 */
-#pragma pack(push, 1)
-struct stru348
-{
-  __int16 field_0;
-  __int16 field_2;
-  __int16 field_4;
-  __int16 field_6;
-  __int16 field_8;
-  __int16 field_A;
-  __int16 field_C;
-  __int16 field_E;
-  __int16 field_10;
-  __int16 field_12;
-  int field_14;
-};
-#pragma pack(pop)
-
-extern stru348 stru_4E1890[13];
-
-
-
-
--- a/NPC.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/NPC.cpp	Thu May 02 11:03:26 2013 +0600
@@ -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.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/Party.cpp	Thu May 02 11:03:26 2013 +0600
@@ -8,7 +8,6 @@
 #include "Mouse.h"
 #include "PlayerFrameTable.h"
 #include "TurnEngine.h"
-#include "stru279.h"
 #include "Viewport.h"
 #include "Actor.h"
 #include "GUIWindow.h"
@@ -917,10 +916,6 @@
   //unsigned int v10; // edi@62
   //signed int v11; // [sp+0h] [bp-4h]@2
 
-  if (dword_A75070 == stru_51076C.field_8) // stru_51076C.field_8 is incremented each time after this function is called, so this is useless
-    return;
-
-  dword_A75070 = stru_51076C.field_8;
   //v1 = this->pPlayers;//(char *)&this->pPlayers[0].uExpressionID;
   for (int i = 0; i < 4; ++i)
   {
--- a/Party.h	Thu May 02 11:02:48 2013 +0600
+++ b/Party.h	Thu May 02 11:03:26 2013 +0600
@@ -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	Thu May 02 11:02:48 2013 +0600
+++ b/Player.cpp	Thu May 02 11:03:26 2013 +0600
@@ -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;
@@ -6594,6 +6594,7 @@
           spellbook.pBodySpellbook.bIsSpellAvailable[8] = true;
           spellbook.pBodySpellbook.bIsSpellAvailable[9] = true;
           spellbook.pBodySpellbook.bIsSpellAvailable[10] = true;
+          spellbook.pMindSpellbook.bIsSpellAvailable[0] = true;
           spellbook.pMindSpellbook.bIsSpellAvailable[1] = true;
           spellbook.pMindSpellbook.bIsSpellAvailable[2] = true;
           spellbook.pMindSpellbook.bIsSpellAvailable[3] = true;
@@ -6604,6 +6605,7 @@
           spellbook.pMindSpellbook.bIsSpellAvailable[8] = true;
           spellbook.pMindSpellbook.bIsSpellAvailable[9] = true;
           spellbook.pMindSpellbook.bIsSpellAvailable[10] = true;
+          spellbook.pSpiritSpellbook.bIsSpellAvailable[0] = true;
           spellbook.pSpiritSpellbook.bIsSpellAvailable[1] = true;
           spellbook.pSpiritSpellbook.bIsSpellAvailable[2] = true;
           spellbook.pSpiritSpellbook.bIsSpellAvailable[3] = true;
@@ -6917,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	Thu May 02 11:02:48 2013 +0600
+++ b/Player.h	Thu May 02 11:03:26 2013 +0600
@@ -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 */
@@ -577,6 +579,26 @@
   inline bool Cursed()     {return pConditions[Condition::Condition_Cursed] != 0;}
   inline bool Pertified()  {return pConditions[Condition::Condition_Pertified] != 0;}
 
+  inline void SetCursed(bool state)      {pConditions[Condition::Condition_Cursed] = state;}
+  inline void SetWeak(bool state)        {pConditions[Condition::Condition_Weak] = state;}
+  inline void SetAsleep(bool state)      {pConditions[Condition::Condition_Sleep] = state;}
+  inline void SetAfraid(bool state)      {pConditions[Condition::Condition_Fear] = state;}
+  inline void SetDrunk(bool state)       {pConditions[Condition::Condition_Drunk] = state;}
+  inline void SetInsane(bool state)      {pConditions[Condition::Condition_Insane] = state;}
+  inline void SetPoison1(bool state)     {pConditions[Condition::Condition_Poison1] = state;}
+  inline void SetDisease1(bool state)    {pConditions[Condition::Condition_Disease1] = state;}
+  inline void SetPoison2(bool state)     {pConditions[Condition::Condition_Poison2] = state;}
+  inline void SetDisease2(bool state)    {pConditions[Condition::Condition_Disease2] = state;}
+  inline void SetPoison3(bool state)     {pConditions[Condition::Condition_Poison3] = state;}
+  inline void SetDisease3(bool state)    {pConditions[Condition::Condition_Disease3] = state;}
+  inline void SetParalyzed(bool state)   {pConditions[Condition::Condition_Paralyzed] = state;}
+  inline void SetUnconcious(bool state)  {pConditions[Condition::Condition_Unconcious] = state;}
+  inline void SetDead(bool state)        {pConditions[Condition::Condition_Dead] = state;}
+  inline void SetPertified(bool state)   {pConditions[Condition::Condition_Pertified] = state;}
+  inline void SetEradicated(bool state)  {pConditions[Condition::Condition_Eradicated] = state;}
+  inline void SetZombie(bool state)      {pConditions[Condition::Condition_Zombie] = state;}
+
+
 
 
   __int64 pConditions[20];
--- a/Render.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/Render.cpp	Thu May 02 11:03:26 2013 +0600
@@ -9427,7 +9427,7 @@
         v11 = v20 - v21;
       }
     }
-    teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu);
+    teal = TargetColor(0, 0xFFu, 0xFFu);
     if ( v11 > 0 )
     {
       v22 = a4a;
--- a/Spells.h	Thu May 02 11:02:48 2013 +0600
+++ b/Spells.h	Thu May 02 11:03:26 2013 +0600
@@ -208,7 +208,7 @@
 #pragma pack(push, 1)
 struct stru324_spell
 {
-  __int16 field_0;
+  __int16 uType;
   __int16 field_2;
 };
 #pragma pack(pop)
--- a/Texture.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/Texture.cpp	Thu May 02 11:03:26 2013 +0600
@@ -43,11 +43,6 @@
 Texture *pTex_tab_an_7b__zoot_on;
 Texture *pTex_tab_an_6b__zoom_on;
 Texture *pTexture_TownPortalIcons[6]; // [0]Harmonale, [1]Pierpont, [2]Nighon, [3]Evenmorn Island, [4]Celestia, [5]The Pit
-//Texture *pTexture_TownPortalElf;
-//Texture *pTexture_TownPortalWarlock;
-//Texture *pTexture_TownPortalIsland;
-//Texture *pTexture_TownPortalHeaven;
-//Texture *pTexture_TownPortalHell;
 Texture *dword_5063D8[12];
 Texture *dword_506408[12];
 Texture *pTexture_50643C; // idb
@@ -186,15 +181,6 @@
 unsigned int uTextureID_507C50; // weak
 unsigned int uTextureID_507C54; // weak
 unsigned int uTextureID_507C58; // weak
-unsigned int uTextureID_ControlBG[23];
-//unsigned int uTextureID_Con_Smoo[3]; // weak
-//unsigned int uTextureID_Con_ArrL; // weak
-//unsigned int uTextureID_Con_ArrR; // weak
-//unsigned int uTextureID_Option04; // weak
-//unsigned int pTextureIDs_SoundLevels[10];
-//unsigned int uTextureID_Option03; // weak
-//unsigned int uTextureID_Option01;
-//unsigned int uTextureID_Option02; // weak
 
 
 unsigned int uTextureID_detaliz_close_button; // weak
--- a/Texture.h	Thu May 02 11:02:48 2013 +0600
+++ b/Texture.h	Thu May 02 11:03:26 2013 +0600
@@ -145,11 +145,7 @@
 extern Texture *pTex_tab_an_7b__zoot_on;
 extern Texture *pTex_tab_an_6b__zoom_on;
 extern Texture *pTexture_TownPortalIcons[]; // [0]Harmonale, [1]Pierpont, [2]Nighon, [3]Evenmorn Island, [4]Celestia, [5]The Pit
-//extern Texture *pTexture_TownPortalElf;
-//extern Texture *pTexture_TownPortalWarlock;
-//extern Texture *pTexture_TownPortalIsland;
-//extern Texture *pTexture_TownPortalHeaven;
-//extern Texture *pTexture_TownPortalHell;
+
 extern Texture *dword_5063D8[];
 extern Texture *dword_506408[];
 extern Texture *pTexture_50643C; // idb
@@ -288,15 +284,27 @@
 extern unsigned int uTextureID_507C50; // weak
 extern unsigned int uTextureID_507C54; // weak
 extern unsigned int uTextureID_507C58; // weak
-extern unsigned int uTextureID_ControlBG[23]; // weak
-//extern unsigned int uTextureID_Con_Smoo[3]; // weak
-//extern unsigned int uTextureID_Con_ArrL; // weak
-//extern unsigned int uTextureID_Con_ArrR; // weak
-//extern unsigned int uTextureID_Option04; // weak
-//extern unsigned int pTextureIDs_SoundLevels[10];
-//extern unsigned int uTextureID_Option03; // weak
-//extern unsigned int uTextureID_Option01;
-//extern unsigned int uTextureID_Option02; // weak
+
+
+struct OptionsMenuSkin
+{
+       OptionsMenuSkin();
+  void Relaease();
+
+  unsigned int uTextureID_Background;      // 507C60
+  unsigned int uTextureID_TurnSpeed[3];    // 507C64
+  unsigned int uTextureID_ArrowLeft;       // 507C70
+  unsigned int uTextureID_ArrowRight;      // 507C74
+  unsigned int uTextureID_unused_0;        // 507C78
+  unsigned int uTextureID_unused_1;        // 507C7C
+  unsigned int uTextureID_unused_2;        // 507C80
+  unsigned int uTextureID_FlipOnExit;      // 507C84
+  unsigned int uTextureID_SoundLevels[10]; // 507C88
+  unsigned int uTextureID_AlwaysRun;       // 507CB0
+  unsigned int uTextureID_WalkSound;       // 507CB4
+  unsigned int uTextureID_ShowDamage;      // 507CB8
+};
+extern OptionsMenuSkin options_menu_skin; // 507C60
 
 
 extern unsigned int uTextureID_detaliz_close_button; // weak
--- a/UIBooks.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/UIBooks.cpp	Thu May 02 11:03:26 2013 +0600
@@ -33,16 +33,13 @@
 #include "Awards.h"
 #include "Autonotes.h"
 #include "stru160.h"
-#include "stru279.h"
 #include "TurnEngine.h"
-#include "stru277.h"
+#include "CastSpellInfo.h"
 #include "Weather.h"
-#include "stru272.h"
 #include "stru298.h"
 #include "StorylineTextTable.h"
 #include "Events2D.h"
 #include "texts.h"
-#include "stru351.h"
 
 #include "mm7_data.h"
 
@@ -412,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;
@@ -427,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;
@@ -446,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 )
   {
@@ -459,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(
@@ -481,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;
 }
@@ -518,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;
@@ -544,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 )
   {
@@ -557,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;
@@ -565,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);
@@ -636,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;
@@ -810,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
     {
@@ -826,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);
       }
@@ -855,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;
@@ -865,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);
@@ -1202,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;
@@ -1384,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 )
@@ -1451,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 )
             {
@@ -1523,34 +1520,17 @@
 
 
 //----- (00413CC6) --------------------------------------------------------
-void __thiscall SellectDrawBook(unsigned int uBook)
+void DrawCurrentBook(unsigned int uBook)
 {
-  enum WindowType pWindowType; // esi@1
-
-  pWindowType = (enum WindowType)uBook;
-  pRenderer->DrawTextureIndexed(471u, 445u, (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0));
-  switch ( pWindowType )
+  pRenderer->DrawTextureIndexed(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId));
+  switch ((enum WindowType)uBook)
   {
-    case WINDOW_Lloyd: // 177
-      DrawLloydBeaconsScreen();
-      break;
-    case WINDOW_TownPortal: //195
-      DrawTownPortalScreen();
-      break;
-    case WINDOW_QuestBook: //200
-      DrawBook_Quests();
-      break;
-    case WINDOW_AutonotesBook: //201
-      DrawBook_Autonotes();
-      break;
-    case WINDOW_MapsBook://202
-      DrawBook_Maps();
-      break;
-    case WINDOW_CalendarBook://203
-      DrawBook_Calendar();
-      break;
-    case WINDOW_HistoryBook://224
-      DrawBook_History();
-      break;
+    case WINDOW_Lloyd:         DrawLloydBeaconsScreen(); break;
+    case WINDOW_TownPortal:    DrawTownPortalScreen();   break;
+    case WINDOW_QuestBook:     DrawBook_Quests();        break;
+    case WINDOW_AutonotesBook: DrawBook_Autonotes();     break;
+    case WINDOW_MapsBook:      DrawBook_Maps();          break;
+    case WINDOW_CalendarBook:  DrawBook_Calendar();      break;
+    case WINDOW_HistoryBook:   DrawBook_History();       break;
   }
 }
--- a/UICharacter.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/UICharacter.cpp	Thu May 02 11:03:26 2013 +0600
@@ -33,16 +33,13 @@
 #include "Awards.h"
 #include "Autonotes.h"
 #include "stru160.h"
-#include "stru279.h"
 #include "TurnEngine.h"
-#include "stru277.h"
+#include "CastSpellInfo.h"
 #include "Weather.h"
-#include "stru272.h"
 #include "stru298.h"
 #include "StorylineTextTable.h"
 #include "Events2D.h"
 #include "texts.h"
-#include "stru351.h"
 
 #include "mm7_data.h"
 
@@ -146,14 +143,14 @@
     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(8u, 8u, (Texture *)(v3 != -1 ? (int)&pIcons_LOD->pTextures[v3] : 0));
+    pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(v3));
     v4 = v79;
     if ( !pPlayer->uSkillPoints )
         v4 = 65535;
@@ -221,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];
@@ -240,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;
@@ -310,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];
@@ -331,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;
@@ -410,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];
@@ -430,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;
@@ -505,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];
@@ -526,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;
@@ -550,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(8u, 8u, (Texture *)(award_texture_id != -1 ? &pIcons_LOD->pTextures[award_texture_id] : 0));
-    sprintfex(pTmpBuf, "%s \f%05d", pGlobalTXT_LocalizationStrings[LOCSTR_AVARDS_FOR], v2);
+    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");
@@ -595,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 )
         {
@@ -604,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 )
             {
@@ -625,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;
-    }
+ }
 
 
 
@@ -774,11 +729,11 @@
         pPlayer = pPlayers[uPlayerID];
         v3 = a2;
         pPlayer2 = pPlayers[uPlayerID];
-        pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_507958 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507958] : 0));
+        pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_507958));
         if ( v3 )
             {
             v4 = pIcons_LOD->LoadTexture("fr_strip", TEXTURE_16BIT_PALETTE);
-            pRenderer->DrawTextureIndexed(8u, 0x131u, (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0));
+            pRenderer->DrawTextureIndexed(8u, 0x131u, pIcons_LOD->GetTexture(v4));
             }
         uCellID = 0;
         v26 = (int)pPlayer->pInventoryIndices;
@@ -795,8 +750,8 @@
                     {
                     v6 = pIcons_LOD->LoadTexture(pItemsTable->pItems[pItem->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
                     uTextureId = v6;
-                    v7 = (Texture *)(v6 != -1 ? (int)&pIcons_LOD->pTextures[v6] : 0);
-                    v8 = (v6 != -1 ? pIcons_LOD->pTextures[v6].uTextureWidth : 24);
+                    v7 = pIcons_LOD->GetTexture(v6);
+                    v8 = v7->uTextureWidth;
                     v9 = v7->uTextureHeight;
                     v10 = v7->uTextureWidth;
                     v11 = v7->uTextureWidth;
@@ -840,7 +795,7 @@
                         if ( (unsigned __int8)(v16 & 0xF0) == 32 )
                             {
                             v20 = "sp28a";
-                            pTexture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v20, TEXTURE_16BIT_PALETTE)];
+                            pTexture = pIcons_LOD->LoadTexturePtr(v20, TEXTURE_16BIT_PALETTE);
                             dword_50C9A8 -= pEventTimer->uTimeElapsed;
                             if ( dword_50C9A8 <= 0 )
                                 {
@@ -860,7 +815,7 @@
                         if ( (unsigned __int8)(v16 & 0xF0) == 64 )
                             {
                             v20 = "sp30a";
-                            pTexture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v20, TEXTURE_16BIT_PALETTE)];
+                            pTexture = pIcons_LOD->LoadTexturePtr(v20, TEXTURE_16BIT_PALETTE);
                             dword_50C9A8 -= pEventTimer->uTimeElapsed;
                             if ( dword_50C9A8 <= 0 )
                                 {
@@ -880,7 +835,7 @@
                         if ( (unsigned __int8)(v16 & 0xF0) == 128 )
                             {
                             v20 = "sp91a";
-                            pTexture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v20, TEXTURE_16BIT_PALETTE)];
+                            pTexture = pIcons_LOD->LoadTexturePtr(v20, TEXTURE_16BIT_PALETTE);
                             dword_50C9A8 -= pEventTimer->uTimeElapsed;
                             if ( dword_50C9A8 <= 0 )
                                 {
@@ -899,7 +854,7 @@
                             }
                         }
                     v20 = "sptext01";
-                    pTexture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v20, TEXTURE_16BIT_PALETTE)];
+                    pTexture = pIcons_LOD->LoadTexturePtr(v20, TEXTURE_16BIT_PALETTE);
                     dword_50C9A8 -= pEventTimer->uTimeElapsed;
                     if ( dword_50C9A8 <= 0 )
                         {
@@ -980,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;
@@ -1002,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 )
@@ -1100,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;
@@ -1135,7 +1090,7 @@
         sub_419379();
         CharacterUI_StatsTab_Draw(uPlayerIdx);
         v7 = pIcons_LOD->LoadTexture("ib-cd1-d", TEXTURE_16BIT_PALETTE);
-        pTexture = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0);
+        pTexture = pIcons_LOD->GetTexture(v7);
         pButton = pCharacterScreen_StatsBtn;
         pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture);
         break;
@@ -1148,7 +1103,7 @@
         sub_419379();
         CharacterUI_SkillsTab_Draw(uPlayerIdx);
         v6 = pIcons_LOD->LoadTexture("ib-cd2-d", TEXTURE_16BIT_PALETTE);
-        pTexture = (Texture *)(v6 != -1 ? (int)&pIcons_LOD->pTextures[v6] : 0);
+        pTexture = pIcons_LOD->GetTexture(v6);
         pButton = pCharacterScreen_SkillsBtn;
         pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture);
         break;
@@ -1158,7 +1113,7 @@
         sub_419220();
         CharacterUI_AwardsTab_Draw(uPlayerIdx);
         v5 = pIcons_LOD->LoadTexture("ib-cd4-d", TEXTURE_16BIT_PALETTE);
-        pTexture = (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0);
+        pTexture = pIcons_LOD->GetTexture(v5);
         pButton = pCharacterScreen_AwardsBtn;
         pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture);
         break;
@@ -1167,7 +1122,7 @@
         sub_419379();
         CharacterUI_InventoryTab_Draw(uPlayerIdx, 0);
         v2 = pIcons_LOD->LoadTexture("ib-cd3-d", TEXTURE_16BIT_PALETTE);
-        pTexture = (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0);
+        pTexture = pIcons_LOD->GetTexture(v2);
         pButton = pCharacterScreen_InventoryBtn;
         pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture);
         break;
@@ -1253,7 +1208,7 @@
   int pY_ArmorShoulder; // ecx@237
   int v106; // edx@238
   int v107; // edx@239
-  int v108; // edx@240
+  int v108; // edx@240papredoll_flying_feet
   int v109; // edi@250
   char *v110; // edx@250
   unsigned int pCloakCollarNum; // eax@259
@@ -1350,17 +1305,14 @@
   pRenderer->DrawTextureIndexed(0x1D3u, 0, pIcons_LOD->GetTexture(uTextureID_BACKDOLL));//
   if ( IsPlayerWearingWatersuit[uPlayerID] )//
   {
-    pRenderer->DrawTextureTransparent(pPaperdoll_BodyX, pPaperdoll_BodyY,
-            (Texture *)(papredoll_dbods[uPlayerID - 1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbods[uPlayerID - 1]] : 0));
+    pRenderer->DrawTextureTransparent(pPaperdoll_BodyX, pPaperdoll_BodyY, pIcons_LOD->GetTexture(papredoll_dbods[uPlayerID - 1]));
     if ( !bRingsShownInCharScreen )
-      pRenderer->DrawMaskToZBuffer(pPaperdoll_BodyX, pPaperdoll_BodyY,
-                 (Texture *)(papredoll_dbods[uPlayerID - 1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbods[uPlayerID - 1]] : 0),
-                 pPlayers[uPlayerID]->pEquipment.uArmor);
+      pRenderer->DrawMaskToZBuffer(pPaperdoll_BodyX, pPaperdoll_BodyY, pIcons_LOD->GetTexture(papredoll_dbods[uPlayerID - 1]), pPlayers[uPlayerID]->pEquipment.uArmor);
     v6 = pPlayers[uPlayerID]->pEquipment.uMainHand;
     if ( !v6 || (v7 = *(int *)&pPlayers[uPlayerID]->pInventoryItems[v6-1], pItemsTable->pItems[v7].uEquipType != 1)
          && (pItemsTable->pItems[v7].uSkillType != 4 || pPlayers[uPlayerID]->pEquipment.uShield) )
          pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_LeftHand[pBodyComplection][1],
-         (Texture *)(papredoll_dlads[uPlayerID - 1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dlads[uPlayerID - 1]] : 0));
+         pIcons_LOD->GetTexture(papredoll_dlads[uPlayerID - 1]));
     pMainHandNum4 = pPlayers[uPlayerID]->pEquipment.uMainHand;
     if ( pMainHandNum4 )
     {
@@ -1375,15 +1327,15 @@
       if ( !( item_MainHand4->uAttributes & 0xF0 ) )
       {
         v18 = v14 + 1;
-        v19 = (char *)&pIcons_LOD->pTextures[v14];
+        v19 = (char *)pIcons_LOD->GetTexture(v14);
         if ( item_MainHand4->uAttributes & 2 )
-          pRenderer->DrawTransparentRedShade(pX_MainHand4, pY_MainHand4, (Texture *)(v18 != 0 ? (int)v19 : 0));
+          pRenderer->DrawTransparentRedShade(pX_MainHand4, pY_MainHand4, (Texture *)v19);
         else
         {
           if ( item_MainHand4->uAttributes & 1 )
-            pRenderer->DrawTextureTransparent(pX_MainHand4, pY_MainHand4, (Texture *)(v18 != 0 ? (int)v19 : 0));
+            pRenderer->DrawTextureTransparent(pX_MainHand4, pY_MainHand4, (Texture *)v19);
           else
-            pRenderer->DrawTransparentGreenShade(pX_MainHand4, pY_MainHand4, (Texture *)(v18 != 0 ? (int)v19 : 0));
+            pRenderer->DrawTransparentGreenShade(pX_MainHand4, pY_MainHand4, (Texture *)v19);
         }
       }
       if ( item_MainHand4->uAttributes & 0xF0 )
@@ -1396,7 +1348,7 @@
           v167 = "sp30a";
         if ( (item_MainHand4->uAttributes & 0xF0) == 128 )
           v167 = "sp91a";
-        v16 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v167, TEXTURE_16BIT_PALETTE)];
+        v16 = pIcons_LOD->LoadTexturePtr(v167, TEXTURE_16BIT_PALETTE);
         dword_50C9A8 -= pEventTimer->uTimeElapsed;
         if ( dword_50C9A8 <= 0 )
         {
@@ -1405,10 +1357,10 @@
           ptr_50C9A4 = 0;
         }
         v17 = (double)GetTickCount() * 0.1;
-        pRenderer->_4A63E6(pX_MainHand4, pY_MainHand4, (Texture *)(v14 != -1 ? (int)&pIcons_LOD->pTextures[v14] : 0), v16, (signed __int64)v17, 0, 255);
+        pRenderer->_4A63E6(pX_MainHand4, pY_MainHand4, pIcons_LOD->GetTexture(v14), v16, (signed __int64)v17, 0, 255);
       }
       if ( !bRingsShownInCharScreen )
-        pRenderer->DrawMaskToZBuffer(pX_MainHand4, pY_MainHand4, (Texture *)(v18 != 0 ? (int)v19 : 0), pMainHandNum4);
+        pRenderer->DrawMaskToZBuffer(pX_MainHand4, pY_MainHand4, (Texture *)v19, pMainHandNum4);
     }
   }
   else//  
@@ -1423,14 +1375,14 @@
       if ( !(itemBow->uAttributes & 0xF0) )//    
       {
         if ( itemBow->uAttributes & 2 )
-          pRenderer->DrawTransparentRedShade(pX_Bow, pY_Bow, (Texture *)(pBowTextureNum != -1 ? (int)&pIcons_LOD->pTextures[pBowTextureNum] : 0));
+          pRenderer->DrawTransparentRedShade(pX_Bow, pY_Bow, pIcons_LOD->GetTexture(pBowTextureNum));
         else
         {
-          v30 = (char *)&pIcons_LOD->pTextures[pBowTextureNum];
+          v30 = (char *)pIcons_LOD->GetTexture(pBowTextureNum);
           if ( !(itemBow->uAttributes & 1) )//   
-            pRenderer->DrawTransparentGreenShade(pX_Bow, pY_Bow, (Texture *)(pBowTextureNum != -1 ? (int)v30 : 0));
+            pRenderer->DrawTransparentGreenShade(pX_Bow, pY_Bow, (Texture *)v30);
           else //  
-            pRenderer->DrawTextureTransparent(pX_Bow, pY_Bow, (Texture *)(pBowTextureNum != -1 ? (int)v30 : 0));
+            pRenderer->DrawTextureTransparent(pX_Bow, pY_Bow, (Texture *)v30);
         }
       }
       else
@@ -1443,7 +1395,7 @@
           v168 = "sp30a";
         if ( (itemBow->uAttributes & 0xF0) == 128 )
           v168 = "sp91a";
-        a2b = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v168, TEXTURE_16BIT_PALETTE)];
+        a2b = pIcons_LOD->LoadTexturePtr(v168, TEXTURE_16BIT_PALETTE);
         dword_50C9A8 -= pEventTimer->uTimeElapsed;
         if ( dword_50C9A8 <= 0 )
         {
@@ -1452,10 +1404,10 @@
           ptr_50C9A4 = 0;
         }
         v28 = (double)GetTickCount() * 0.1;
-        pRenderer->_4A63E6(pX_Bow, pY_Bow, (Texture *)(pBowTextureNum != -1 ? (int)&pIcons_LOD->pTextures[pBowTextureNum] : 0), a2b, (signed __int64)v28, 0, 255);
+        pRenderer->_4A63E6(pX_Bow, pY_Bow, pIcons_LOD->GetTexture(pBowTextureNum), a2b, (signed __int64)v28, 0, 255);
       }
       if ( !bRingsShownInCharScreen )
-        pRenderer->DrawMaskToZBuffer(pX_Bow, pY_Bow, (Texture *)(pBowTextureNum != -1 ? (int)&pIcons_LOD->pTextures[pBowTextureNum] : 0), pBowNum);
+        pRenderer->DrawMaskToZBuffer(pX_Bow, pY_Bow, pIcons_LOD->GetTexture(pBowTextureNum), pBowNum);
     }
     pCloakNum = pPlayers[uPlayerID]->pEquipment.uCloak;//  
     if ( pCloakNum )
@@ -1491,9 +1443,9 @@
         {
           v41 = v35 + 1;
           if ( item_Cloak->uAttributes & 2 )
-            pRenderer->DrawTransparentRedShade(pX_Cloak, pY_Cloak, (Texture *)(v41 != 0 ? (int)&pIcons_LOD->pTextures[v35] : 0));
+            pRenderer->DrawTransparentRedShade(pX_Cloak, pY_Cloak, pIcons_LOD->GetTexture(v35));
           else
-            pRenderer->DrawTextureTransparent(pX_Cloak, pY_Cloak, (Texture *)(v41 != 0 ? (int)&pIcons_LOD->pTextures[v35] : 0));
+            pRenderer->DrawTextureTransparent(pX_Cloak, pY_Cloak, pIcons_LOD->GetTexture(v35));
         }
         else
         {
@@ -1505,7 +1457,7 @@
             v169 = "sp30a";
           if ( (item_Cloak->uAttributes & 0xF0) == 128 )
             v169 = "sp91a";
-          v39 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v169, TEXTURE_16BIT_PALETTE)];
+          v39 = pIcons_LOD->LoadTexturePtr(v169, TEXTURE_16BIT_PALETTE);
           dword_50C9A8 -= pEventTimer->uTimeElapsed;
           if ( dword_50C9A8 <= 0 )
           {
@@ -1514,14 +1466,14 @@
             ptr_50C9A4 = 0;
           }
           v40 = (double)GetTickCount() * 0.1;
-          pRenderer->_4A63E6(pX_Cloak, pY_Cloak, (Texture *)(v35 != -1 ? (int)&pIcons_LOD->pTextures[v35] : 0), v39, (signed __int64)v40, 0, 255);
+          pRenderer->_4A63E6(pX_Cloak, pY_Cloak, pIcons_LOD->GetTexture(v35), v39, (signed __int64)v40, 0, 255);
         }
         if ( !bRingsShownInCharScreen )
-          pRenderer->DrawMaskToZBuffer(pX_Cloak, pY_Cloak, (Texture *)(v41 != 0 ? (int)&pIcons_LOD->pTextures[v35] : 0), pCloakNum);
+          pRenderer->DrawMaskToZBuffer(pX_Cloak, pY_Cloak, pIcons_LOD->GetTexture(v35), pCloakNum);
       }
     }
     pRenderer->DrawTextureTransparent(pPaperdoll_BodyX, pPaperdoll_BodyY,// 
-            (Texture *)(papredoll_dbods[uPlayerID - 1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbods[uPlayerID - 1]] : 0));
+            pIcons_LOD->GetTexture(papredoll_dbods[uPlayerID - 1]));
     pArmorNum = pPlayers[uPlayerID]->pEquipment.uArmor;//  
     if ( pArmorNum )
     {
@@ -1553,14 +1505,14 @@
         {
           v53 = v48 + 1;
           if ( item_Armor->uAttributes & 2 )
-            pRenderer->DrawTransparentRedShade(pX_Armor, pY_Armor, (Texture *)(v53 != 0 ? (int)&pIcons_LOD->pTextures[v48] : 0));
+            pRenderer->DrawTransparentRedShade(pX_Armor, pY_Armor, pIcons_LOD->GetTexture(v48));
           else
           {
             v55 = (char *)&pIcons_LOD->pTextures[v48];
             if ( !(item_Armor->uAttributes & 1) )
-              pRenderer->DrawTransparentGreenShade(pX_Armor, pY_Armor, (Texture *)(v53 != 0 ? (int)v55 : 0));
+              pRenderer->DrawTransparentGreenShade(pX_Armor, pY_Armor, (Texture *)v55);
             else
-              pRenderer->DrawTextureTransparent(pX_Armor, pY_Armor, (Texture *)(v53 != 0 ? (int)v55 : 0));
+              pRenderer->DrawTextureTransparent(pX_Armor, pY_Armor, (Texture *)v55);
           }
         }
         else
@@ -1573,7 +1525,7 @@
             v170 = "sp30a";
           if ( (item_Armor->uAttributes & 0xF0) == 128 )
             v170 = "sp91a";
-          v51 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v170, TEXTURE_16BIT_PALETTE)];
+          v51 = pIcons_LOD->LoadTexturePtr(v170, TEXTURE_16BIT_PALETTE);
           dword_50C9A8 -= pEventTimer->uTimeElapsed;
           if ( dword_50C9A8 <= 0 )
           {
@@ -1582,7 +1534,7 @@
             ptr_50C9A4 = 0;
           }
           v52 = (double)GetTickCount() * 0.1;
-          pRenderer->_4A63E6(pX_Armor, pY_Armor, (Texture *)(v48 != -1 ? (int)&pIcons_LOD->pTextures[v48] : 0), v51, (signed __int64)v52, 0, 255);
+          pRenderer->_4A63E6(pX_Armor, pY_Armor, pIcons_LOD->GetTexture(v48), v51, (signed __int64)v52, 0, 255);
         }
         if ( pPlayers[uPlayerID]->pEquipment.uMainHand //  
           && (pPlayers[uPlayerID]->GetEquippedItemEquipType(EQUIP_MAIN_HAND) == EQUIP_MAIN_HAND ||
@@ -1604,15 +1556,15 @@
           if ( !(item_Armor->uAttributes & 0xF0) )
           {
             v98 = v94 + 1;
-            v99 = (char *)&pIcons_LOD->pTextures[v94];
+            v99 = (char *)pIcons_LOD->GetTexture(v94);
             if ( item_Armor->uAttributes & 2 )
-              pRenderer->DrawTransparentRedShade(pX_shoulder, pY_shoulder, (Texture *)(v98 != 0 ? (int)v99 : 0));
+              pRenderer->DrawTransparentRedShade(pX_shoulder, pY_shoulder, (Texture *)v99);
             else
             {
               if ( item_Armor->uAttributes & 1 )
-                pRenderer->DrawTextureTransparent(pX_shoulder, pY_shoulder, (Texture *)(v98 != 0 ? (int)v99 : 0));
+                pRenderer->DrawTextureTransparent(pX_shoulder, pY_shoulder, (Texture *)v99);
               else
-                pRenderer->DrawTransparentGreenShade(pX_shoulder, pY_shoulder, (Texture *)(v98 != 0 ? (int)v99 : 0));
+                pRenderer->DrawTransparentGreenShade(pX_shoulder, pY_shoulder, (Texture *)v99);
             }
           }
           else
@@ -1629,7 +1581,7 @@
                   v173 = "sp30a";
                 if ( (item_Armor->uAttributes & 0xF0) == 128 )
                   v173 = "sp91a";
-                v96 = (char *)&pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v173, TEXTURE_16BIT_PALETTE)];
+                v96 = (char *)pIcons_LOD->LoadTexturePtr(v173, TEXTURE_16BIT_PALETTE);
                 dword_50C9A8 -= pEventTimer->uTimeElapsed;
                 if ( dword_50C9A8 <= 0 )
                 {
@@ -1638,7 +1590,7 @@
                   ptr_50C9A4 = 0;
                 }
                 v97 = (double)GetTickCount();
-                pRenderer->_4A63E6(pX_shoulder, pY_shoulder, (Texture *)(v94 != -1 ? (int)&pIcons_LOD->pTextures[v94] : 0), (Texture *)v96, (signed __int64)(v97 * 0.1), 0, 255);
+                pRenderer->_4A63E6(pX_shoulder, pY_shoulder, pIcons_LOD->GetTexture(v94), (Texture *)v96, (signed __int64)(v97 * 0.1), 0, 255);
               }
             }
           }
@@ -1653,15 +1605,15 @@
             if ( !(item_Armor->uAttributes & 0xF0) )
             {
               v109 = v94 + 1;
-              v110 = (char *)&pIcons_LOD->pTextures[v94];
+              v110 = (char *)pIcons_LOD->GetTexture(v94);
               if ( item_Armor->uAttributes & 2 )
-                pRenderer->DrawTransparentRedShade(pX_ArmorShoulder, pY_ArmorShoulder, (Texture *)(v109 != 0 ? (int)v110 : 0));
+                pRenderer->DrawTransparentRedShade(pX_ArmorShoulder, pY_ArmorShoulder, (Texture *)v110);
               else
               {
                 if ( item_Armor->uAttributes & 1 )
-                  pRenderer->DrawTextureTransparent(pX_ArmorShoulder, pY_ArmorShoulder, (Texture *)(v109 != 0 ? (int)v110 : 0));
+                  pRenderer->DrawTextureTransparent(pX_ArmorShoulder, pY_ArmorShoulder, (Texture *)v110);
                 else
-                  pRenderer->DrawTransparentGreenShade(pX_ArmorShoulder, pY_ArmorShoulder, (Texture *)(v109 != 0 ? (int)v110 : 0));
+                  pRenderer->DrawTransparentGreenShade(pX_ArmorShoulder, pY_ArmorShoulder, (Texture *)v110);
               }
             }
             else
@@ -1674,7 +1626,7 @@
                 v178 = "sp30a";
               if ( (item_Armor->uAttributes & 0xF0) == 128 )
                 v178 = "sp91a";
-              v96 = (char *)&pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v178, TEXTURE_16BIT_PALETTE)];
+              v96 = (char *)pIcons_LOD->LoadTexturePtr(v178, TEXTURE_16BIT_PALETTE);
               dword_50C9A8 -= pEventTimer->uTimeElapsed;
               if ( dword_50C9A8 <= 0 )
               {
@@ -1683,12 +1635,12 @@
                 ptr_50C9A4 = 0;
               }
               v97 = (double)GetTickCount();
-              pRenderer->_4A63E6(pX_ArmorShoulder, pY_ArmorShoulder, (Texture *)(v94 != -1 ? (int)&pIcons_LOD->pTextures[v94] : 0), (Texture *)v96, (signed __int64)(v97 * 0.1), 0, 255);
+              pRenderer->_4A63E6(pX_ArmorShoulder, pY_ArmorShoulder, pIcons_LOD->GetTexture(v94), (Texture *)v96, (signed __int64)(v97 * 0.1), 0, 255);
             }
           }
         }
         if ( !bRingsShownInCharScreen )
-          pRenderer->DrawMaskToZBuffer(pX_Armor, pY_Armor, (Texture *)(v53 != 0 ? (int)v55 : 0), pArmorNum);
+          pRenderer->DrawMaskToZBuffer(pX_Armor, pY_Armor, (Texture *)v55, pArmorNum);
       }
     }
     pBootNum = pPlayers[uPlayerID]->pEquipment.uBoot;// 
@@ -1717,15 +1669,15 @@
         if ( !(item_Boot->uAttributes & 0xF0) )
         {
           v65 = v59 + 1;
-          v66 = (char *)&pIcons_LOD->pTextures[v59];
+          v66 = (char *)pIcons_LOD->GetTexture(v59);
           if ( item_Boot->uAttributes & 2 )
-            pRenderer->DrawTransparentRedShade(pX_Boot, pY_Boot, (Texture *)(v65 != 0 ? (int)v66 : 0));
+            pRenderer->DrawTransparentRedShade(pX_Boot, pY_Boot, (Texture *)v66);
           else
           {
             if ( item_Boot->uAttributes & 1 )
-              pRenderer->DrawTextureTransparent(pX_Boot, pY_Boot, (Texture *)(v65 != 0 ? (int)v66 : 0));
+              pRenderer->DrawTextureTransparent(pX_Boot, pY_Boot, (Texture *)v66);
             else
-              pRenderer->DrawTransparentGreenShade(pX_Boot, pY_Boot, (Texture *)(v65 != 0 ? (int)v66 : 0));
+              pRenderer->DrawTransparentGreenShade(pX_Boot, pY_Boot, (Texture *)v66);
           }
         }
         else
@@ -1738,7 +1690,7 @@
             v171 = "sp30a";
           if ( (item_Boot->uAttributes & 0xF0) == 128 )
             v171 = "sp91a";
-          v63 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v171, TEXTURE_16BIT_PALETTE)];
+          v63 = pIcons_LOD->LoadTexturePtr(v171, TEXTURE_16BIT_PALETTE);
           dword_50C9A8 -= pEventTimer->uTimeElapsed;
           if ( dword_50C9A8 <= 0 )
           {
@@ -1747,10 +1699,10 @@
             ptr_50C9A4 = 0;
           }
           v64 = (double)GetTickCount() * 0.1;
-          pRenderer->_4A63E6(pX_Boot, pY_Boot, (Texture *)(v59 != -1 ? (int)&pIcons_LOD->pTextures[v59] : 0), v63, (signed __int64)v64, 0, 255);
+          pRenderer->_4A63E6(pX_Boot, pY_Boot, pIcons_LOD->GetTexture(v59), v63, (signed __int64)v64, 0, 255);
         }
         if ( !bRingsShownInCharScreen )
-          pRenderer->DrawMaskToZBuffer(pX_Boot, pY_Boot, (Texture *)(v65 != 0 ? (int)v66 : 0), pBootNum);
+          pRenderer->DrawMaskToZBuffer(pX_Boot, pY_Boot, (Texture *)v66, pBootNum);
       }
     }
     pMainHandNum = pPlayers[uPlayerID]->pEquipment.uMainHand;
@@ -1758,7 +1710,7 @@
         && (pItemsTable->pItems[v70].uSkillType != 4 || pPlayers[uPlayerID]->pEquipment.uShield) )
       pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[pBodyComplection][0],
             pPaperdoll_BodyY + pPaperdoll_LeftHand[pBodyComplection][1],
-                     (Texture *)(papredoll_dlads[uPlayerID - 1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dlads[uPlayerID - 1]] : 0));
+                     pIcons_LOD->GetTexture(papredoll_dlads[uPlayerID - 1]));
         pBeltNum = pPlayers[uPlayerID]->pEquipment.uBelt;//  
         if ( pBeltNum )
         {
@@ -1786,18 +1738,18 @@
           if ( !(item_Belt->uAttributes & 0xF0) )
           {
             v79 = v75 + 1;
-            v80 = (char *)&pIcons_LOD->pTextures[v75];
+            v80 = (char *)pIcons_LOD->GetTexture(v75);
             if ( item_Belt->uAttributes & 2 )
-              pRenderer->DrawTransparentRedShade(pX_Belt, pY_Belt, (Texture *)(v79 != 0 ? (int)v80 : 0));
+              pRenderer->DrawTransparentRedShade(pX_Belt, pY_Belt, (Texture *)v80);
             else
             {
               if ( item_Belt->uAttributes & 1 )
-                pRenderer->DrawTextureTransparent(pX_Belt, pY_Belt, (Texture *)(v79 != 0 ? (int)v80 : 0));
+                pRenderer->DrawTextureTransparent(pX_Belt, pY_Belt, (Texture *)v80);
               else
-                pRenderer->DrawTransparentGreenShade(pX_Belt, pY_Belt, (Texture *)(v79 != 0 ? (int)v80 : 0));
+                pRenderer->DrawTransparentGreenShade(pX_Belt, pY_Belt, (Texture *)v80);
             }
             if ( !bRingsShownInCharScreen )
-              pRenderer->DrawMaskToZBuffer(pX_Belt, pY_Belt, (Texture *)(v79 != 0 ? (int)v80 : 0), pBeltNum);
+              pRenderer->DrawMaskToZBuffer(pX_Belt, pY_Belt, (Texture *)v80, pBeltNum);
           }
           else
           {
@@ -1809,7 +1761,7 @@
               v172 = "sp30a";
             if ( (item_Belt->uAttributes & 0xF0) == 128 )
               v172 = "sp91a";
-            v77 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v172, TEXTURE_16BIT_PALETTE)];
+            v77 = pIcons_LOD->LoadTexturePtr(v172, TEXTURE_16BIT_PALETTE);
             dword_50C9A8 -= pEventTimer->uTimeElapsed;
             if ( dword_50C9A8 <= 0 )
             {
@@ -1818,7 +1770,7 @@
               ptr_50C9A4 = 0;
             }
             v78 = (double)GetTickCount() * 0.1;
-            pRenderer->_4A63E6(pX_Belt, pY_Belt, (Texture *)(v75 != -1 ? (int)&pIcons_LOD->pTextures[v75] : 0), v77, (signed __int64)v78, 0, 255);
+            pRenderer->_4A63E6(pX_Belt, pY_Belt, pIcons_LOD->GetTexture(v75), v77, (signed __int64)v78, 0, 255);
           }
         }
       }
@@ -1830,7 +1782,7 @@
              || pItemsTable->pItems[v83].uSkillType == 4 && !pPlayers[uPlayerID]->pEquipment.uShield )
           pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0],
              pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1],
-             (Texture *)(papredoll_dlaus[uPlayerID - 1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dlaus[uPlayerID - 1]] : 0));
+             pIcons_LOD->GetTexture(papredoll_dlaus[uPlayerID - 1]));
       }
       pCloakCollarNum = pPlayers[uPlayerID]->pEquipment.uCloak;//  
       if ( pCloakCollarNum )
@@ -1866,13 +1818,13 @@
             if ( !(item_CloakCollar->uAttributes & 0xF0) )
             {
               v119 = v116 + 1;
-              v120 = (char *)&pIcons_LOD->pTextures[v116];
+              v120 = (char *)pIcons_LOD->GetTexture(v116);
               if ( item_CloakCollar->uAttributes & 2 )
-                pRenderer->DrawTransparentRedShade(pX_CloakCollar, pY_CloakCollar, (Texture *)(v119 != 0 ? (int)v120 : 0));
+                pRenderer->DrawTransparentRedShade(pX_CloakCollar, pY_CloakCollar, (Texture *)v120);
               else
-                pRenderer->DrawTextureTransparent(pX_CloakCollar, pY_CloakCollar, (Texture *)(v119 != 0 ? (int)v120 : 0));
+                pRenderer->DrawTextureTransparent(pX_CloakCollar, pY_CloakCollar, (Texture *)v120);
               if ( !bRingsShownInCharScreen )
-                pRenderer->DrawMaskToZBuffer(pX_CloakCollar, pY_CloakCollar, (Texture *)(v119 != 0 ? (int)v120 : 0), pCloakCollarNum);
+                pRenderer->DrawMaskToZBuffer(pX_CloakCollar, pY_CloakCollar, (Texture *)v120, pCloakCollarNum);
             }
             else
             {
@@ -1884,7 +1836,7 @@
                 v179 = "sp30a";
               if ( (item_CloakCollar->uAttributes & 0xF0) == 128 )
                 v179 = "sp91a";
-              a2i = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v179, TEXTURE_16BIT_PALETTE)];
+              a2i = pIcons_LOD->LoadTexturePtr(v179, TEXTURE_16BIT_PALETTE);
               dword_50C9A8 -= pEventTimer->uTimeElapsed;
               if ( dword_50C9A8 <= 0 )
               {
@@ -1893,7 +1845,7 @@
                 ptr_50C9A4 = 0;
               }
               v118 = (double)GetTickCount() * 0.1;
-              pRenderer->_4A63E6(pX_CloakCollar, pY_CloakCollar, (Texture *)(v116 != -1 ? (int)&pIcons_LOD->pTextures[v116] : 0), a2i, (signed __int64)v118, 0, 255);
+              pRenderer->_4A63E6(pX_CloakCollar, pY_CloakCollar, pIcons_LOD->GetTexture(v116), a2i, (signed __int64)v118, 0, 255);
             }
           }
         }
@@ -1904,7 +1856,7 @@
         if ( v122 != pIcons_LOD->FindTextureByName("Pending") )
           pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_Beards[2 * pPlayers[uPlayerID]->uFace - 24],
                      pPaperdoll_BodyY + pPaperdoll_Beards[2 * pPlayers[uPlayerID]->uFace - 23],
-                     (Texture *)(v122 != -1 ? (int)&pIcons_LOD->pTextures[v122] : 0));
+                     pIcons_LOD->GetTexture(v122));
       }
     pHelmNum = pPlayers[uPlayerID]->pEquipment.uHelm;// 
     if ( pHelmNum )
@@ -1948,7 +1900,7 @@
             v180 = "sp30a";
           if ( (item_Helm->uAttributes & 0xF0) == 128 )
             v180 = "sp91a";
-          v129 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v180, TEXTURE_16BIT_PALETTE)];
+          v129 = pIcons_LOD->LoadTexturePtr(v180, TEXTURE_16BIT_PALETTE);
           dword_50C9A8 -= pEventTimer->uTimeElapsed;
           if ( dword_50C9A8 <= 0 )
           {
@@ -1957,24 +1909,24 @@
             ptr_50C9A4 = 0;
           }
           v130 = (double)GetTickCount() * 0.1;
-          pRenderer->_4A63E6(pX_Helm, pY_Helm, (Texture *)(v127 != -1 ? (int)&pIcons_LOD->pTextures[v127] : 0), v129, (signed __int64)v130, 0, 255);
+          pRenderer->_4A63E6(pX_Helm, pY_Helm, pIcons_LOD->GetTexture(v127), v129, (signed __int64)v130, 0, 255);
         }
         else
         {
           v131 = v127 + 1;
-          v132 = (char *)&pIcons_LOD->pTextures[v127];
+          v132 = (char *)pIcons_LOD->GetTexture(v127);
           if ( item_Helm->uAttributes & 2 )
-            pRenderer->DrawTransparentRedShade(pX_Helm, pY_Helm, (Texture *)(v131 != 0 ? (int)v132 : 0));
+            pRenderer->DrawTransparentRedShade(pX_Helm, pY_Helm, (Texture *)v132);
           else
           {
             if ( item_Helm->uAttributes & 1 )
-              pRenderer->DrawTextureTransparent(pX_Helm, pY_Helm, (Texture *)(v131 != 0 ? (int)v132 : 0));
+              pRenderer->DrawTextureTransparent(pX_Helm, pY_Helm, (Texture *)v132);
             else
-              pRenderer->DrawTransparentGreenShade(pX_Helm, pY_Helm, (Texture *)(v131 != 0 ? (int)v132 : 0));
+              pRenderer->DrawTransparentGreenShade(pX_Helm, pY_Helm, (Texture *)v132);
           }
         }
         if ( !bRingsShownInCharScreen )
-          pRenderer->DrawMaskToZBuffer(pX_Helm, pY_Helm, (Texture *)(v131 != 0 ? (int)v132 : 0), pHelmNum);
+          pRenderer->DrawMaskToZBuffer(pX_Helm, pY_Helm, (Texture *)v132, pHelmNum);
       }
     }
     pMainHandNum3 = pPlayers[uPlayerID]->pEquipment.uMainHand;//weapon in right hand
@@ -1991,15 +1943,15 @@
       if ( !(item_MainHand3->uAttributes & 0xF0) )
       {
         v142 = v138 + 1;
-        v143 = (char *)&pIcons_LOD->pTextures[v138];
+        v143 = (char *)pIcons_LOD->GetTexture(v138);
         if ( item_MainHand3->uAttributes & 2 )
-          pRenderer->DrawTransparentRedShade(pX_MainHand3, pY_MainHand3, (Texture *)(v142 != 0 ? (int)v143 : 0));
+          pRenderer->DrawTransparentRedShade(pX_MainHand3, pY_MainHand3, (Texture *)v143);
         else
         {
           if ( item_MainHand3->uAttributes & 1 )
-            pRenderer->DrawTextureTransparent(pX_MainHand3, pY_MainHand3, (Texture *)(v142 != 0 ? (int)v143 : 0));
+            pRenderer->DrawTextureTransparent(pX_MainHand3, pY_MainHand3, (Texture *)v143);
           else
-            pRenderer->DrawTransparentGreenShade(pX_MainHand3, pY_MainHand3, (Texture *)(v142 != 0 ? (int)v143 : 0));
+            pRenderer->DrawTransparentGreenShade(pX_MainHand3, pY_MainHand3, (Texture *)v143);
         }
       }
       else
@@ -2012,7 +1964,7 @@
            v182 = "sp30a";
         if ( (item_MainHand3->uAttributes & 0xF0) == 128 )
           v182 = "sp91a";
-        v140 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v182, TEXTURE_16BIT_PALETTE)];
+        v140 = pIcons_LOD->LoadTexturePtr(v182, TEXTURE_16BIT_PALETTE);
         dword_50C9A8 -= pEventTimer->uTimeElapsed;
         if ( dword_50C9A8 <= 0 )
         {
@@ -2021,10 +1973,10 @@
           ptr_50C9A4 = 0;
         }
         v141 = (double)GetTickCount() * 0.1;
-        pRenderer->_4A63E6(pX_MainHand3, pY_MainHand3, (Texture *)(v138 != -1 ? (int)&pIcons_LOD->pTextures[v138] : 0), v140, (signed __int64)v141, 0, 255);
+        pRenderer->_4A63E6(pX_MainHand3, pY_MainHand3, pIcons_LOD->GetTexture(v138), v140, (signed __int64)v141, 0, 255);
       }
       if ( !bRingsShownInCharScreen )
-        pRenderer->DrawMaskToZBuffer(pX_MainHand3, pY_MainHand3, (Texture *)(v142 != 0 ? (int)v143 : 0), pMainHandNum3);
+        pRenderer->DrawMaskToZBuffer(pX_MainHand3, pY_MainHand3, (Texture *)v143, pMainHandNum3);
     }
     pShieldNum = pPlayers[uPlayerID]->pEquipment.uShield;//  
     if ( pShieldNum )
@@ -2064,14 +2016,14 @@
       if ( !(item_Shield->uAttributes & 0xF0) )
       {
         if ( item_Shield->uAttributes & 2 )
-          pRenderer->DrawTransparentRedShade(pX_Shield, pY_Shield, (Texture *)(v153 != -1 ? (int)&pIcons_LOD->pTextures[v153] : 0));
+          pRenderer->DrawTransparentRedShade(pX_Shield, pY_Shield, pIcons_LOD->GetTexture(v153));
         else
         {
-          v160 = (char *)&pIcons_LOD->pTextures[v153];
+          v160 = (char *)pIcons_LOD->GetTexture(v153);
           if ( !(item_Shield->uAttributes & 1) )
-          pRenderer->DrawTransparentGreenShade(pX_Shield, pY_Shield, (Texture *)(v153 != -1 ? (int)v160 : 0));
+          pRenderer->DrawTransparentGreenShade(pX_Shield, pY_Shield, (Texture *)v160);
           else
-            pRenderer->DrawTextureTransparent(pX_Shield, pY_Shield, (Texture *)(v153 != -1 ? (int)v160 : 0));
+            pRenderer->DrawTextureTransparent(pX_Shield, pY_Shield, (Texture *)v160);
         }
       }
       else
@@ -2084,7 +2036,7 @@
           v183 = "sp30a";
         if ( (item_Shield->uAttributes & 0xF0) == 128 )
           v183 = "sp91a";
-        v157 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v183, TEXTURE_16BIT_PALETTE)];
+        v157 = pIcons_LOD->LoadTexturePtr(v183, TEXTURE_16BIT_PALETTE);
         dword_50C9A8 -= pEventTimer->uTimeElapsed;
         if ( dword_50C9A8 <= 0 )
         {
@@ -2093,29 +2045,26 @@
           ptr_50C9A4 = 0;
         }
         v158 = (double)GetTickCount() * 0.1;
-        pRenderer->_4A63E6(pX_Shield, pY_Shield, (Texture *)(v153 != -1 ? (int)&pIcons_LOD->pTextures[v153] : 0), v157, (signed __int64)v158, 0, 255);
+        pRenderer->_4A63E6(pX_Shield, pY_Shield, pIcons_LOD->GetTexture(v153), v157, (signed __int64)v158, 0, 255);
         if ( v245 )
           pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdollLeftEmptyHand[pBodyComplection][0],
-                 pPaperdoll_BodyY + pPaperdollLeftEmptyHand[pBodyComplection][1],
-                 (Texture *)(papredoll_dlhs[uPlayerID - 1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dlhs[uPlayerID - 1]] : 0));
+                 pPaperdoll_BodyY + pPaperdollLeftEmptyHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_dlhs[uPlayerID - 1]));
       }
       if ( !bRingsShownInCharScreen )
-        pRenderer->DrawMaskToZBuffer(pX_Shield, pY_Shield, (Texture *)(v153 != -1 ? (int)&pIcons_LOD->pTextures[v153] : 0), pShieldNum);
+        pRenderer->DrawMaskToZBuffer(pX_Shield, pY_Shield, pIcons_LOD->GetTexture(v153), pShieldNum);
     }
   }
-  pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_RightHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_RightHand[pBodyComplection][1],
-             (Texture *)(papredoll_drhs[uPlayerID - 1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_drhs[uPlayerID - 1]] : 0));
+  pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_RightHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_RightHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_drhs[uPlayerID - 1]));
   pMainHandNum5 = pPlayers[uPlayerID]->pEquipment.uMainHand;
   if ( pMainHandNum5 )
   {
     item_MainHand5 = &pPlayers[uPlayerID]->pInventoryItems[pMainHandNum5 - 1];
     if ( pItemsTable->pItems[item_MainHand5->uItemID].uEquipType == 1 || pItemsTable->pItems[item_MainHand5->uItemID].uSkillType == 4 && !pPlayers[uPlayerID]->pEquipment.uShield )
-      pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1],
-                 (Texture *)(papredoll_dlhus[uPlayerID - 1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dlhus[uPlayerID - 1]] : 0));
+      pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_dlhus[uPlayerID - 1]));
   }
   if ( !bRingsShownInCharScreen )// 
-    pRenderer->DrawTextureTransparent(603, 299, (Texture *)(uTextureID_MAGNIF_B != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_MAGNIF_B] : 0));
-  pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_right_panel_loop != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_right_panel_loop] : 0));//
+    pRenderer->DrawTextureTransparent(603, 299, pIcons_LOD->GetTexture(uTextureID_MAGNIF_B));
+  pRenderer->DrawTextureTransparent(468, 0, pIcons_LOD->GetTexture(uTextureID_right_panel_loop));//
 }
 
 //----- (0043E825) --------------------------------------------------------
@@ -2123,13 +2072,13 @@
 {
   int v3; // ecx@1
   unsigned int pItemTextureNum; // ebx@3
-  int v9; // edi@17
+  //int v9; // edi@17
   char v13; // sf@24
   unsigned __int8 v14; // of@24
   unsigned int pItemNum; // eax@25
-  int v20; // edi@40
-  int v21; // eax@41
-  int v33; // esi@61
+  //int v20; // edi@40
+  //int v21; // eax@41
+  //int v33; // esi@61
   const char *spell_texture_name; // [sp-8h] [bp-38h]@8
   Texture *spell_texture; // [sp+10h] [bp-20h]@14
   int v41; // [sp+10h] [bp-20h]@26
@@ -2140,10 +2089,9 @@
 
   pIcons_LOD->LoadTexture("sptext01", TEXTURE_16BIT_PALETTE);
   CharacterUI_DrawPaperdoll(uPlayerID);
-  pRenderer->DrawTextureTransparent(0x1D9u, 0, (Texture *)(uTextureID_BACKHAND != -1 ? &pIcons_LOD->pTextures[uTextureID_BACKHAND] : 0));
-  pRenderer->DrawTextureTransparent(0x1D4u, 0, (Texture *)(uTextureID_right_panel_loop != -1 ? &pIcons_LOD->pTextures[uTextureID_right_panel_loop] : 0));
-  pRenderer->DrawTextureIndexed(pCharacterScreen_DetalizBtn->uX, pCharacterScreen_DetalizBtn->uY,
-     (Texture *)(uTextureID_detaliz_close_button != -1 ? &pIcons_LOD->pTextures[uTextureID_detaliz_close_button] : 0));
+  pRenderer->DrawTextureTransparent(0x1D9u, 0, pIcons_LOD->GetTexture(uTextureID_BACKHAND));
+  pRenderer->DrawTextureTransparent(0x1D4u, 0, pIcons_LOD->GetTexture(uTextureID_right_panel_loop));
+  pRenderer->DrawTextureIndexed(pCharacterScreen_DetalizBtn->uX, pCharacterScreen_DetalizBtn->uY, pIcons_LOD->GetTexture(uTextureID_detaliz_close_button));
   v3 = 0;
   v48 = 0;
   do
@@ -2165,7 +2113,7 @@
           spell_texture_name = "sp30a";
         if ( (item->uAttributes & 0xF0) == 128 )
           spell_texture_name = "sp91a";
-        spell_texture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(spell_texture_name, TEXTURE_16BIT_PALETTE)];
+        spell_texture = pIcons_LOD->LoadTexturePtr(spell_texture_name, TEXTURE_16BIT_PALETTE);
         dword_50C9A8 -= pEventTimer->uTimeElapsed;
         if ( dword_50C9A8 <= 0 )
         {
@@ -2173,21 +2121,18 @@
           item->uAttributes &= 0xFu;
           ptr_50C9A4 = 0;
         }
-        pRenderer->_4A63E6(pX_Ring, pY_Ring, (Texture *)(pItemTextureNum != -1 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0), spell_texture, GetTickCount() * 0.1, 0, 255);
+        pRenderer->_4A63E6(pX_Ring, pY_Ring, pIcons_LOD->GetTexture(pItemTextureNum), spell_texture, GetTickCount() * 0.1, 0, 255);
       }
       else
       {
-        v9 = pItemTextureNum + 1;
-        if ( item->uAttributes & 2 )
-          pRenderer->DrawTransparentRedShade(pX_Ring, pY_Ring, (Texture *)(v9 != 0 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0));
+        if (item->Broken())
+          pRenderer->DrawTransparentRedShade(pX_Ring, pY_Ring, pIcons_LOD->GetTexture(pItemTextureNum));
+        else if (!item->Identified())
+          pRenderer->DrawTransparentGreenShade(pX_Ring, pY_Ring, pIcons_LOD->GetTexture(pItemTextureNum));
         else
-        {
-          if ( (item->uAttributes & 1) == 0 )
-            pRenderer->DrawTransparentGreenShade(pX_Ring, pY_Ring, (Texture *)(v9 != 0 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0));
-          else
-            pRenderer->DrawTextureTransparent(pX_Ring, pY_Ring, (Texture *)(v9 != 0 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0));
-        }
-        pRenderer->_4A601E(pX_Ring, pY_Ring, (Texture *)(v9 != 0 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0), pItemNum);
+          pRenderer->DrawTextureTransparent(pX_Ring, pY_Ring, pIcons_LOD->GetTexture(pItemTextureNum));
+
+        pRenderer->_4A601E(pX_Ring, pY_Ring, pIcons_LOD->GetTexture(pItemTextureNum), pItemNum);
       }
     }
     v3++;
@@ -2213,7 +2158,7 @@
         spell_texture_name = "sp30a";
       if ( (item->uAttributes & 0xF0) == 128 )
         spell_texture_name = "sp91a";
-      spell_texture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(spell_texture_name, TEXTURE_16BIT_PALETTE)];
+      spell_texture = pIcons_LOD->LoadTexturePtr(spell_texture_name, TEXTURE_16BIT_PALETTE);
       dword_50C9A8 -= pEventTimer->uTimeElapsed;
       if ( dword_50C9A8 <= 0 )
       {
@@ -2221,25 +2166,18 @@
         item->uAttributes &= 0xFu;
         ptr_50C9A4 = 0;
       }
-      pRenderer->_4A63E6(493, 91, (Texture *)(pItemTextureNum != -1 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0), spell_texture, GetTickCount() * 0.1, 0, 255);
+      pRenderer->_4A63E6(493, 91, pIcons_LOD->GetTexture(pItemTextureNum), spell_texture, GetTickCount() * 0.1, 0, 255);
     }
     else
     {
-      v20 = pItemTextureNum + 1;
-      if ( item->uAttributes & 2 )
-      {
-        v21 = 9 * pItemTextureNum;
-        pRenderer->DrawTransparentRedShade(493, 91, (Texture *)(v20 != 0 ? (int)&pIcons_LOD->pTextures[8 * v21 / 0x48u] : 0));
-      }
+      if (item->Broken())
+        pRenderer->DrawTransparentRedShade(493, 91, pIcons_LOD->GetTexture(pItemTextureNum));
+      else if (!item->Identified())
+        pRenderer->DrawTransparentGreenShade(493, 91, pIcons_LOD->GetTexture(pItemTextureNum));
       else
-      {
-        v21 = 9 * pItemTextureNum;
-        if ( !(item->uAttributes & 1) )
-          pRenderer->DrawTransparentGreenShade(493, 91, (Texture *)(v20 != 0 ? (int)&pIcons_LOD->pTextures[8 * v21 / 0x48u] : 0));
-        else
-          pRenderer->DrawTextureTransparent(493, 91, (Texture *)(v20 != 0 ? (int)&pIcons_LOD->pTextures[8 * v21 / 0x48u] : 0));
-      }
-      pRenderer->_4A601E(493, 91, (Texture *)(v20 != 0 ? (int)&pIcons_LOD->pTextures[8 * v21 / 0x48u] : 0), v41);
+        pRenderer->DrawTextureTransparent(493, 91, pIcons_LOD->GetTexture(pItemTextureNum));
+
+      pRenderer->_4A601E(493, 91, pIcons_LOD->GetTexture(pItemTextureNum), v41);
     }
   }
   pItemNum = pPlayers[uPlayerID]->pEquipment.uGlove;
@@ -2249,17 +2187,14 @@
   pItemTextureNum = pIcons_LOD->LoadTexture(pItemsTable->pItems[item->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
   if ( !(item->uAttributes & 0xF0) )
   {
-    v33 = pItemTextureNum + 1;
-    if ( item->uAttributes & 2 )
-      pRenderer->DrawTransparentRedShade(586, 88, (Texture *)(v33 != 0 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0));
+    if (item->Broken())
+      pRenderer->DrawTransparentRedShade(586, 88, pIcons_LOD->GetTexture(pItemTextureNum));
+    else if (!item->Identified())
+      pRenderer->DrawTransparentGreenShade(586, 88, pIcons_LOD->GetTexture(pItemTextureNum));
     else
-    {
-      if ( !(item->uAttributes & 1) )
-        pRenderer->DrawTransparentGreenShade(586, 88, (Texture *)(v33 != 0 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0));
-      else
-        pRenderer->DrawTextureTransparent(586, 88, (Texture *)(v33 != 0 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0));
-    }
-    pRenderer->_4A601E(586, 88, (Texture *)(v33 != 0 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0), pItemNum);
+      pRenderer->DrawTextureTransparent(586, 88, pIcons_LOD->GetTexture(pItemTextureNum));
+
+    pRenderer->_4A601E(586, 88,pIcons_LOD->GetTexture(pItemTextureNum), pItemNum);
   }
   else
   {
@@ -2271,7 +2206,7 @@
       spell_texture_name = "sp30a";
     if ( (item->uAttributes & 0xF0) == 128 )
       spell_texture_name = "sp91a";
-    spell_texture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(spell_texture_name, TEXTURE_16BIT_PALETTE)];
+    spell_texture = pIcons_LOD->LoadTexturePtr(spell_texture_name, TEXTURE_16BIT_PALETTE);
     dword_50C9A8 -= pEventTimer->uTimeElapsed;
     if ( dword_50C9A8 <= 0 )
     {
@@ -2424,6 +2359,8 @@
     if (Player_has_item(ITEM_RARE_VAMPIRES_CAPE, player, 1))          byte_5111F6[15] = 1;
     if (Player_has_item(ITEM_ELVEN_CHAINMAIL, player, 1))             byte_5111F6[16] = 1;
   }
+
+
   for (uint i = 0; i < 2; ++i)
   {
     for ( uint j = 0; j < 5; ++j )//Belt
@@ -2457,7 +2394,7 @@
     if ( sub_43EDB9_get_some_race_sex_relation_2(i) )
     {
       GetItemTextureFilename(pContainer, 524, i + 1, 0);
-      paperdoll_belt_texture[i][6] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);//Titans belt
+      paperdoll_belt_texture[i][5] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);//Titans belt
       pItemTXTNum = 66;
       for ( v32 = 0; v32 < 13; ++v32 )//simple armor
       {
@@ -2655,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
@@ -2793,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, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0));
-        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	Thu May 02 11:02:48 2013 +0600
+++ b/UIHouses.cpp	Thu May 02 11:03:26 2013 +0600
@@ -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;
@@ -2109,8 +2109,8 @@
 			v9 = pFontCreate->CalcTextHeight(current_npc_text, &w, 13, 0) + 7;
 		}
 
-		auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0);
-		pRenderer->_4A6A68(8u, 352 - v9, pTex, (pTex ? pTex->uTextureHeight : 26) - v9);
+		auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather);
+		pRenderer->_4A6A68(8u, 352 - v9, pTex, pTex->uTextureHeight - v9);
 		pRenderer->DrawTextureIndexed(8u, 347 - v9, pTexture_591428);
 		v10 = FitTextInAWindow(current_npc_text, pOutString, &w, 0xDu, 0);
 		a1.DrawText(pOutString, 13, 354 - v9, 0, v10, 0, 0, 0);
@@ -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;
@@ -2550,8 +2550,8 @@
         pOutString = pFontCreate;
         pTextHeight = pFontCreate->CalcTextHeight(pTmpBuf, &dialog_window, 12, 0) + 7;
       }
-      auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0);
-      pRenderer->_4A6A68(8, 352 - pTextHeight, pTex, (pTex ? pTex->uTextureHeight : 26) - pTextHeight);
+      auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather);
+      pRenderer->_4A6A68(8, 352 - pTextHeight, pTex, pTex->uTextureHeight - pTextHeight);
       pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428);
       v63 = FitTextInAWindow(pTmpBuf, pOutString, &dialog_window, 0xCu, 0);
       window_SpeakInHouse->DrawText(pOutString, 12, 354 - pTextHeight, 0, v63, 0, 0, 0);
@@ -2564,8 +2564,8 @@
       dialog_window.uFrameZ = 452;
       v61 = pFontArrus->CalcTextHeight(pTmpBuf, &dialog_window, 12, 0);
       pTextHeight = v61 + 7;
-      auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : nullptr);
-      pRenderer->_4A6A68(8, 352 - (v61 + 7), pTex, (pTex ? pTex->uTextureHeight : 26) - (v61 + 7));
+      auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather);
+      pRenderer->_4A6A68(8, 352 - (v61 + 7), pTex, pTex->uTextureHeight - (v61 + 7));
       pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428);
       v63 = FitTextInAWindow(pTmpBuf, pFontArrus, &dialog_window, 0xCu, 0);
       window_SpeakInHouse->DrawText(pFontArrus, 12, 354 - pTextHeight, 0, v63, 0, 0, 0);
@@ -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	Thu May 02 11:02:48 2013 +0600
+++ b/UIMainMenu.cpp	Thu May 02 11:03:26 2013 +0600
@@ -33,16 +33,13 @@
 #include "Awards.h"
 #include "Autonotes.h"
 #include "stru160.h"
-#include "stru279.h"
 #include "TurnEngine.h"
-#include "stru277.h"
+#include "CastSpellInfo.h"
 #include "Weather.h"
-#include "stru272.h"
 #include "stru298.h"
 #include "StorylineTextTable.h"
 #include "Events2D.h"
 #include "texts.h"
-#include "stru351.h"
 
 #include "mm7_data.h"
 
@@ -145,7 +142,7 @@
     uTextureID_mhp_red = pIcons_LOD->LoadTexture("mhp_red", TEXTURE_16BIT_PALETTE);
     uTextureID_mhp_yel = pIcons_LOD->LoadTexture("mhp_yel", TEXTURE_16BIT_PALETTE);
     uTextureID_Leather = pIcons_LOD->LoadTexture("LEATHER", TEXTURE_16BIT_PALETTE);
-    pTexture_Leather = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ibground", TEXTURE_16BIT_PALETTE)];
+    pTexture_Leather = pIcons_LOD->LoadTexturePtr("ibground", TEXTURE_16BIT_PALETTE);
     uTextureID_x_x_u = pIcons_LOD->LoadTexture("x_x_u", TEXTURE_16BIT_PALETTE);
     uTextureID_BUTTDESC2 = pIcons_LOD->LoadTexture("BUTTESC2", TEXTURE_16BIT_PALETTE);
     uTextureID_x_ok_u = pIcons_LOD->LoadTexture("x_ok_u", TEXTURE_16BIT_PALETTE);
@@ -155,10 +152,10 @@
 
     pPrimaryWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
     pPrimaryWindow->CreateButton(7u, 8u, 0x1CCu, 0x157u, 1, 0, UIMSG_A, 0, 0, "", 0);
-    pPrimaryWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 1, 0x31u, "", 0);
-    pPrimaryWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 2, 0x32u, "", 0);
-    pPrimaryWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 3, 0x33u, "", 0);
-    pPrimaryWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 4, 0x34u, "", 0);
+    pPrimaryWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0);
+    pPrimaryWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0);
+    pPrimaryWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0);
+    pPrimaryWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0);
     pPrimaryWindow->CreateButton(0x18u, 0x194u, 5u, 0x31u, 1, 93, UIMSG_0, 1u, 0, "", 0);
     pPrimaryWindow->CreateButton(0x8Bu, 0x194u, 5u, 0x31u, 1, 93, UIMSG_0, 2u, 0, "", 0);
     pPrimaryWindow->CreateButton(0xFFu, 0x194u, 5u, 0x31u, 1, 93, UIMSG_0, 3u, 0, "", 0);
@@ -169,22 +166,22 @@
     pPrimaryWindow->CreateButton(0x1BBu, 0x194u, 5u, 0x31u, 1, 93, UIMSG_0, 4u, 0, "", 0);
 
     uTextureID_ib_td1_A = pIcons_LOD->LoadTexture("ib-td1-A", TEXTURE_16BIT_PALETTE);
-    v6 = (Texture *)(uTextureID_ib_td1_A != -1 ? &pIcons_LOD->pTextures[uTextureID_ib_td1_A] : 0);
+    v6 = pIcons_LOD->GetTexture(uTextureID_ib_td1_A);
     v8 = pKeyActionMap->GetActionVKey(INPUT_Quest);
     pBtn_Quests = pPrimaryWindow->CreateButton(0x1EBu, 0x161u, v6->uTextureWidth, v6->uTextureHeight, 1, 0, UIMSG_OpenQuestBook, 0, v8, pGlobalTXT_LocalizationStrings[174], v6, 0); //Quests
 
     uTextureID_ib_td2_A = pIcons_LOD->LoadTexture("ib-td2-A", TEXTURE_16BIT_PALETTE);
-    v10 = (Texture *)(uTextureID_ib_td2_A != -1 ? &pIcons_LOD->pTextures[uTextureID_ib_td2_A] : 0);
+    v10 = pIcons_LOD->GetTexture(uTextureID_ib_td2_A);
     v12 = pKeyActionMap->GetActionVKey(INPUT_Autonotes);
     pBtn_Autonotes = pPrimaryWindow->CreateButton(0x20Fu, 0x161u, v10->uTextureWidth, v10->uTextureHeight, 1, 0, UIMSG_OpenAutonotes, 0, v12, pGlobalTXT_LocalizationStrings[154], v10, 0);//Autonotes
 
     v14 = pIcons_LOD->LoadTexture("ib-td3-A", TEXTURE_16BIT_PALETTE);
-    v15 = (Texture *)(v14 != -1 ? &pIcons_LOD->pTextures[v14] : 0);
+    v15 = pIcons_LOD->GetTexture(v14);
     v17 = pKeyActionMap->GetActionVKey(INPUT_Mapbook);
     pBtn_Maps = pPrimaryWindow->CreateButton(0x222u, 0x161u, v15->uTextureWidth, v15->uTextureHeight, 1, 0, UIMSG_OpenMapBook, 0, v17, pGlobalTXT_LocalizationStrings[139], v15, 0); //Maps
 
     uTextureID_ib_td4_A = pIcons_LOD->LoadTexture("ib-td4-A", TEXTURE_16BIT_PALETTE);
-    v20 = (Texture *)(uTextureID_ib_td4_A != -1 ? &pIcons_LOD->pTextures[uTextureID_ib_td4_A] : 0);
+    v20 = pIcons_LOD->GetTexture(uTextureID_ib_td4_A);
     v22 = pKeyActionMap->GetActionVKey(INPUT_TimeCal);
     pBtn_Calendar = pPrimaryWindow->CreateButton(0x23Au, 0x161u, v20->uTextureWidth, v20->uTextureHeight, 1, 0, UIMSG_OpenCalendar, 0, v22,
         pGlobalTXT_LocalizationStrings[78],//Calendar
@@ -192,10 +189,10 @@
 
     uTextureID_ib_td5_A = pIcons_LOD->LoadTexture("ib-td5-A", TEXTURE_16BIT_PALETTE);
     pBtn_History = pPrimaryWindow->CreateButton(0x258u, 0x169u,
-        (uTextureID_ib_td5_A != -1 ? pIcons_LOD->pTextures[uTextureID_ib_td5_A].uTextureWidth : 24),
-        (uTextureID_ib_td5_A != -1 ? pIcons_LOD->pTextures[uTextureID_ib_td5_A].uTextureHeight : 26),
+        pIcons_LOD->GetTexture(uTextureID_ib_td5_A)->uTextureWidth,
+        pIcons_LOD->GetTexture(uTextureID_ib_td5_A)->uTextureHeight,
         1, 0, UIMSG_OpenHistoryBook, 0, 0x48u, pGlobalTXT_LocalizationStrings[602],//History
-        (Texture *)(uTextureID_ib_td5_A != -1 ? &pIcons_LOD->pTextures[uTextureID_ib_td5_A] : 0), 0);
+        pIcons_LOD->GetTexture(uTextureID_ib_td5_A), 0);
 
     bFlashAutonotesBook = 0;
     bFlashQuestBook = 0;
@@ -210,41 +207,35 @@
     pBtn_ZoomOut = pPrimaryWindow->CreateButton(519, 136, v29->uTextureWidth, v29->uTextureHeight, 2, 0, UIMSG_16F, 0, v33, pGlobalTXT_LocalizationStrings[251], // Zoom Out
         v29, 0);
     pPrimaryWindow->CreateButton(0x1E1u, 0, 0x99u, 0x43u, 1, 92, UIMSG_0, 0, 0, "", 0);
-    pPrimaryWindow->CreateButton(0x1EBu, 0x95u, 0x40u, 0x4Au, 1, 0, UIMSG_StartHireling1Dialogue, 0, 0x35u, "", 0);
-    pPrimaryWindow->CreateButton(0x231u, 0x95u, 0x40u, 0x4Au, 1, 0, UIMSG_StartHireling2Dialogue, 0, 0x36u, "", 0);
+    pPrimaryWindow->CreateButton(0x1EBu, 0x95u, 0x40u, 0x4Au, 1, 0, UIMSG_StartHireling1Dialogue, 0, '5', "", 0);
+    pPrimaryWindow->CreateButton(0x231u, 0x95u, 0x40u, 0x4Au, 1, 0, UIMSG_StartHireling2Dialogue, 0, '6', "", 0);
     pPrimaryWindow->CreateButton(0x1DCu, 0x142u, 0x4Du, 0x11u, 1, 100, UIMSG_0, 0, 0, "", 0);
     pPrimaryWindow->CreateButton(0x22Bu, 0x142u, 0x4Du, 0x11u, 1, 101, UIMSG_0, 0, 0, "", 0);
     pBtn_CastSpell = pPrimaryWindow->CreateButton(0x1DCu, 0x1C2u,
-        (uTextureID_Btn_CastSpell != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_CastSpell].uTextureWidth : 24),
-        (uTextureID_Btn_CastSpell != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_CastSpell].uTextureHeight : 26),
-        1, 0, UIMSG_SpellBookWindow, 0, 0x43u, pGlobalTXT_LocalizationStrings[38],
-        (Texture *)(uTextureID_Btn_CastSpell != -1 ? &pIcons_LOD->pTextures[uTextureID_Btn_CastSpell] : 0),
+        pIcons_LOD->GetTexture(uTextureID_Btn_CastSpell)->uTextureWidth,
+        pIcons_LOD->GetTexture(uTextureID_Btn_CastSpell)->uTextureHeight,
+        1, 0, UIMSG_SpellBookWindow, 0, 0x43u, pGlobalTXT_LocalizationStrings[38], pIcons_LOD->GetTexture(uTextureID_Btn_CastSpell),
         0);
     pBtn_Rest = pPrimaryWindow->CreateButton(0x206u, 0x1C2u,
-        (uTextureID_Btn_Rest != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_Rest].uTextureWidth : 24),
-        (uTextureID_Btn_Rest != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_Rest].uTextureHeight : 26),
-        1, 0, UIMSG_RestWindow, 0, 0x52u, pGlobalTXT_LocalizationStrings[182],
-        (Texture *)(uTextureID_Btn_Rest != -1 ? &pIcons_LOD->pTextures[uTextureID_Btn_Rest] : 0), 0);
+        pIcons_LOD->GetTexture(uTextureID_Btn_Rest)->uTextureWidth,
+        pIcons_LOD->GetTexture(uTextureID_Btn_Rest)->uTextureHeight,
+        1, 0, UIMSG_RestWindow, 0, 0x52u, pGlobalTXT_LocalizationStrings[182], pIcons_LOD->GetTexture(uTextureID_Btn_Rest), 0);
     pBtn_QuickReference = pPrimaryWindow->CreateButton(0x230u, 0x1C2u,
-        (uTextureID_Btn_QuickReference != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_QuickReference].uTextureWidth : 24),
-        (uTextureID_Btn_QuickReference != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_QuickReference].uTextureHeight : 26),
-        1, 0, UIMSG_QuickReference, 0, 0x5Au, pGlobalTXT_LocalizationStrings[173],
-        (Texture *)(uTextureID_Btn_QuickReference != -1 ? &pIcons_LOD->pTextures[uTextureID_Btn_QuickReference] : 0), 0);
+        pIcons_LOD->GetTexture(uTextureID_Btn_QuickReference)->uTextureWidth,
+        pIcons_LOD->GetTexture(uTextureID_Btn_QuickReference)->uTextureHeight,
+        1, 0, UIMSG_QuickReference, 0, 0x5Au, pGlobalTXT_LocalizationStrings[173], pIcons_LOD->GetTexture(uTextureID_Btn_QuickReference), 0);
     pBtn_GameSettings = pPrimaryWindow->CreateButton(0x25Au, 0x1C2u,
-        (uTextureID_Btn_GameSettings != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_GameSettings].uTextureWidth : 24),
-        (uTextureID_Btn_GameSettings != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_GameSettings].uTextureHeight : 26),
-        1, 0, UIMSG_GameMenuButton, 0, 0, pGlobalTXT_LocalizationStrings[93],
-        (Texture *)(uTextureID_Btn_GameSettings != -1 ? &pIcons_LOD->pTextures[uTextureID_Btn_GameSettings] : 0), 0);
+        pIcons_LOD->GetTexture(uTextureID_Btn_GameSettings)->uTextureWidth,
+        pIcons_LOD->GetTexture(uTextureID_Btn_GameSettings)->uTextureHeight,
+        1, 0, UIMSG_GameMenuButton, 0, 0, pGlobalTXT_LocalizationStrings[93], pIcons_LOD->GetTexture(uTextureID_Btn_GameSettings), 0);
     pBtn_NPCLeft = pPrimaryWindow->CreateButton(0x1D5u, 0xB2u,
-        (uTextureID_Btn_NPCLeft != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_NPCLeft].uTextureWidth : 24),
-        (uTextureID_Btn_NPCLeft != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_NPCLeft].uTextureHeight : 26),
-        1, 0, UIMSG_ScrollNPCPanel, 0, 0, "",
-        pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft), 0);
+        pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureWidth,
+        pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureHeight,
+        1, 0, UIMSG_ScrollNPCPanel, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft), 0);
     pBtn_NPCRight = pPrimaryWindow->CreateButton(0x272u, 0xB2u,
-        (uTextureID_Btn_NPCRight != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_NPCRight].uTextureWidth : 24),
-        (uTextureID_Btn_NPCRight != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_NPCRight].uTextureHeight : 26),
-        1, 0, UIMSG_ScrollNPCPanel, 1u, 0, "",
-        pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight), 0);
+        pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight)->uTextureWidth,
+        pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight)->uTextureHeight,
+        1, 0, UIMSG_ScrollNPCPanel, 1u, 0, "", pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight), 0);
     LoadPartyBuffIcons();
 }
 
@@ -316,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	Thu May 02 11:02:48 2013 +0600
+++ b/UIOptions.cpp	Thu May 02 11:03:26 2013 +0600
@@ -33,21 +33,24 @@
 #include "Awards.h"
 #include "Autonotes.h"
 #include "stru160.h"
-#include "stru279.h"
 #include "TurnEngine.h"
-#include "stru277.h"
+#include "CastSpellInfo.h"
 #include "Weather.h"
-#include "stru272.h"
 #include "stru298.h"
 #include "StorylineTextTable.h"
 #include "Events2D.h"
 #include "texts.h"
-#include "stru351.h"
 
 #include "mm7_data.h"
 
 
 
+
+OptionsMenuSkin options_menu_skin; // 507C60
+
+
+
+
 //----- (004142D3) --------------------------------------------------------
 char __cdecl GameMenuUI_DrawKeyBindings()
     {
@@ -111,14 +114,11 @@
     const char *v57; // ST0C_4@17
     unsigned int v58; // eax@17
     unsigned int v59; // eax@18
-    int v61; // [sp-14h] [bp-28h]@16
+    //int v61; // [sp-14h] [bp-28h]@16
     const char *v62; // [sp-10h] [bp-24h]@16
-    int v63; // [sp-Ch] [bp-20h]@16
-    int v64; // [sp-8h] [bp-1Ch]@16
-    unsigned int v65; // [sp-4h] [bp-18h]@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 )
@@ -161,135 +161,130 @@
             dword_506E68 = -1;
             v3->field_40 = 0;
         }
-    pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_Optkb[0] != -1 ? &pIcons_LOD->pTextures[uTextureID_Optkb[0]] : 0));
+    pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_Optkb[0]));
     if ( KeyboardPageNum == 1 )
-        {
-        pRenderer->DrawTextureIndexed(0x13, 0x12E, (Texture *)(uTextureID_Optkb[3] != -1 ? &pIcons_LOD->pTextures[uTextureID_Optkb[3]] : 0));
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 142, v0, ascii_4E2D5C, 0, 0, 0);
+    {
+        pRenderer->DrawTextureIndexed(0x13, 0x12E, pIcons_LOD->GetTexture(uTextureID_Optkb[3]));
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 142, v0, "Ш", 0, 0, 0);
         v6 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[0]);
         v7 = sub_414D24(0);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 142, v7, v6, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 163, v0, ascii_4E2D50, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 163, v0, "", 0, 0, 0);
         v8 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[1]);
         v9 = sub_414D24(1);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 163, v9, v8, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 184, v0, ascii_4E2D48, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 184, v0, "", 0, 0, 0);
         v10 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[2]);
         v11 = sub_414D24(2);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 184, v11, v10, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 205, v0, ascii_4E2D40, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 205, v0, "", 0, 0, 0);
         v12 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[3]);
         v13 = sub_414D24(3);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 205, v13, v12, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 226, v0, ascii_4E2D38, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 226, v0, "", 0, 0, 0);
         v14 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[4]);
         v15 = sub_414D24(4);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 226, v15, v14, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 247, v0, ascii_4E2D30, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 247, v0, "", 0, 0, 0);
         v16 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[5]);
         v17 = sub_414D24(5);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 247, v17, v16, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 268, v0, ascii_4E2D28, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 268, v0, ".", 0, 0, 0);
         v18 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[6]);
         v19 = sub_414D24(6);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 268, v19, v18, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 142, v0, ascii_4E2D1C, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 142, v0, ". .", 0, 0, 0);
         v20 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[7]);
         v21 = sub_414D24(7);
         v22 = 350;
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 142, v21, v20, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 163, a5, ascii_4E2D14, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 163, a5, "", 0, 0, 0);
         v23 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[8]);
         v24 = sub_414D24(8);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 163, v24, v23, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 184, a5, ascii_4E2D0C, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 184, a5, ".", 0, 0, 0);
         v25 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[9]);
         v26 = sub_414D24(9);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 184, v26, v25, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 205, a5, ascii_4E2D04, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 205, a5, ".", 0, 0, 0);
         v27 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[10]);
         v28 = sub_414D24(10);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 205, v28, v27, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 226, a5, ascii_4E2CFC, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 226, a5, "", 0, 0, 0);
         v29 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[11]);
         v30 = sub_414D24(11);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 226, v30, v29, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 247, a5, ascii_4E2CF0, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 247, a5, ". ", 0, 0, 0);
         v31 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[12]);
         v32 = sub_414D24(12);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 247, v32, v31, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 268, a5, ascii_4E2CE8, 0, 0, 0);
-        v65 = 0;
-        v64 = 0;
-        v63 = 0;
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 268, a5, "", 0, 0, 0);
+
         v62 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[13]);
-        v61 = 13;
+        v59 = sub_414D24(13);
         }
     else
         {
-        pRenderer->DrawTextureIndexed(0x7F, 0x12E, (Texture *)(uTextureID_Optkb[4] != -1 ? &pIcons_LOD->pTextures[uTextureID_Optkb[4]] : 0));
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 142, v0, ascii_4E2CDC, 0, 0, 0);
+        pRenderer->DrawTextureIndexed(0x7F, 0x12E, pIcons_LOD->GetTexture(uTextureID_Optkb[4]));
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 142, v0, ". ", 0, 0, 0);
         v33 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[14]);
         v34 = sub_414D24(14);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 142, v34, v33, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 163, v0, ascii_4E2CD4, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 163, v0, "", 0, 0, 0);
         v35 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[15]);
         v36 = sub_414D24(15);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 163, v36, v35, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 184, v0, ascii_4E2CC8, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 184, v0, ". ", 0, 0, 0);
         v37 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[16]);
         v38 = sub_414D24(16);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 184, v38, v37, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 205, v0, ascii_4E2CBC, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 205, v0, "", 0, 0, 0);
         v39 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[17]);
         v40 = sub_414D24(17);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 205, v40, v39, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 226, v0, ascii_4E2CB0, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 226, v0, "", 0, 0, 0);
         v41 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[18]);
         v42 = sub_414D24(18);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 226, v42, v41, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 247, v0, ascii_4E2CA4, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 247, v0, "", 0, 0, 0);
         v43 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[19]);
         v44 = sub_414D24(19);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 247, v44, v43, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 268, v0, ascii_4E2C9C, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 268, v0, ". ", 0, 0, 0);
         v45 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[20]);
         v46 = sub_414D24(20);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 268, v46, v45, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 142, v0, ascii_4E2C90, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 142, v0, ". ", 0, 0, 0);
         v47 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[21]);
         v48 = sub_414D24(21);
         v22 = 350;
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 142, v48, v47, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 163, a5, ascii_4E2C84, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 163, a5, ". Ш", 0, 0, 0);
         v49 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[22]);
         v50 = sub_414D24(22);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 163, v50, v49, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 184, a5, ascii_4E2C7C, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 184, a5, "", 0, 0, 0);
         v51 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[23]);
         v52 = sub_414D24(23);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 184, v52, v51, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 205, a5, ascii_4E2C70, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 205, a5, "", 0, 0, 0);
         v53 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[24]);
         v54 = sub_414D24(24);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 205, v54, v53, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 226, a5, ascii_4E2C68, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 226, a5, ". ", 0, 0, 0);
         v55 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[25]);
         v56 = sub_414D24(25);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 226, v56, v55, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 247, a5, ascii_4E2C5C, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 247, a5, ". ", 0, 0, 0);
         v57 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[26]);
         v58 = sub_414D24(26);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 247, v58, v57, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 268, a5, ascii_4E2C54, 0, 0, 0);
-        v65 = 0;
-        v64 = 0;
-        v63 = 0;
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 268, a5, "", 0, 0, 0);
+
         v62 = pKeyActionMap->GetVKeyDisplayName(pWindowList_at_506F50_minus1_indexing[0]);
-        v61 = 27;
+        v59 = sub_414D24(27);
         }
-    v59 = sub_414D24(v61);
-    return pGUIWindow_CurrentMenu->DrawText(pFontLucida, v22, 268, v59, v62, v63, v64, v65);
+    return pGUIWindow_CurrentMenu->DrawText(pFontLucida, v22, 268, v59, v62, 0, 0, 0);
     }
 
 
@@ -302,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 )
@@ -319,102 +314,119 @@
         }
     return result;
     }
-// 506E68: using guessed type int dword_506E68;
-// 506E6C: using guessed type __int16 word_506E6C[18];
-// 507C08: using guessed type int dword_507C08;
 
 //----- (00414D9A) --------------------------------------------------------
-void __cdecl GameMenuUI_DrawVideoOptions()
-    {
+void GameMenuUI_DrawVideoOptions()
+{
     const char *v0; // ST0C_4@3
     unsigned __int16 v1; // ax@3
-    int v2; // eax@10
+    //int v2; // eax@10
     GUIWindow v3; // [sp+8h] [bp-54h]@3
 
-    pRenderer->DrawTextureIndexed(
-        8u,
-        8u,
-        (Texture *)(uTextureID_507C10 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C10] : 0));
+    pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_507C10));
     if ( !pRenderer->bWindowMode && GammaController::IsGammaSupported() )
         {
         pRenderer->DrawTextureIndexed(
             17 * uGammaPos + 42,
-            162u,
-            (Texture *)(pTextureIDs_GammaPositions[uGammaPos] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_GammaPositions[uGammaPos]] : 0));
+            162,
+            pIcons_LOD->GetTexture(pTextureIDs_GammaPositions[uGammaPos]));
         pRenderer->DrawTextureRGB(0x112u, 0xA9u, &stru_506E40);
         v3.uFrameX = 22;
-        v0 = pGlobalTXT_LocalizationStrings[226];
+        v0 = pGlobalTXT_LocalizationStrings[226]; // "Gamma controls the relative ""brightness"" of the game.  May vary depending on your monitor."
         v3.uFrameY = 190;
         v3.uFrameWidth = 211;
         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);
         }
-    if ( !pRenderer->pRenderD3D )
-        {
-        pRenderer->DrawTextureIndexed(
-            0x14u,
-            0x119u,
-            (Texture *)(uTextureID_507C50 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C50] : 0));
-        pRenderer->DrawTextureIndexed(
-            0x14u,
-            0x12Fu,
-            (Texture *)(uTextureID_507C54 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C54] : 0));
-        v2 = uTextureID_507C58;
-        goto LABEL_12;
-        }
-    if ( pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS )
-        pRenderer->DrawTextureIndexed(
-        0x14u,
-        0x119u,
-        (Texture *)(uTextureID_507C14 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C14] : 0));
-    if ( pRenderer->bUseColoredLights )
-        pRenderer->DrawTextureIndexed(
-        0x14u,
-        0x12Fu,
-        (Texture *)(uTextureID_507C18 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C18] : 0));
-    if ( pRenderer->bTinting )
-        {
-        v2 = uTextureID_507C1C;
-LABEL_12:
-        pRenderer->DrawTextureIndexed(0x14u, 0x145u, (Texture *)(v2 != -1 ? &pIcons_LOD->pTextures[v2] : 0));
-        }
+
+    if (!pRenderer->pRenderD3D)
+    {
+      pRenderer->DrawTextureIndexed(20, 281, pIcons_LOD->GetTexture(uTextureID_507C50));
+      pRenderer->DrawTextureIndexed(20, 303, pIcons_LOD->GetTexture(uTextureID_507C54));
+      pRenderer->DrawTextureIndexed(20, 325, pIcons_LOD->GetTexture(uTextureID_507C58));
     }
+    else
+    {
+      if (pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS)
+        pRenderer->DrawTextureIndexed(20, 281, pIcons_LOD->GetTexture(uTextureID_507C14));
+      if (pRenderer->bUseColoredLights)
+        pRenderer->DrawTextureIndexed(20, 303, pIcons_LOD->GetTexture(uTextureID_507C18));
+      if (pRenderer->bTinting)
+        pRenderer->DrawTextureIndexed(20, 325, pIcons_LOD->GetTexture(uTextureID_507C1C));
+    }
+}
 
 
 
 //----- (00414F82) --------------------------------------------------------
-void __cdecl DrawGameOptions()
-    {
-    signed int v0; // eax@1
+void DrawGameOptions()
+{
+  pRenderer->DrawTextureIndexed(8,   8, pIcons_LOD->GetTexture(uTextureID_Options));
+  pRenderer->DrawTextureIndexed(8, 132, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_Background));
+
+  switch (uTurnSpeed)
+  {
+    default:   pRenderer->DrawTextureIndexed(BtnTurnCoord[0], 270, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[0]));
+    case 64:   pRenderer->DrawTextureIndexed(BtnTurnCoord[1], 270, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[1]));
+    case 128:  pRenderer->DrawTextureIndexed(BtnTurnCoord[2], 270, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[2]));
+  }
+
+  if (bWalkSound)  pRenderer->DrawTextureIndexed( 20, 303, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_WalkSound));
+  if (bShowDamage) pRenderer->DrawTextureIndexed(128, 303, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ShowDamage));
+  if (bFlipOnExit) pRenderer->DrawTextureIndexed(128, 325, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_FlipOnExit));
+  if (bAlwaysRun)  pRenderer->DrawTextureIndexed( 20, 325, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_AlwaysRun));
+
+  pRenderer->DrawTextureIndexed(265 + 17 * uSoundVolumeMultiplier,  162, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_SoundLevels[uSoundVolumeMultiplier]));
+  pRenderer->DrawTextureIndexed(265 + 17 * uMusicVolimeMultiplier,  216, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_SoundLevels[uMusicVolimeMultiplier]));
+  pRenderer->DrawTextureIndexed(265 + 17 * uVoicesVolumeMultiplier, 270, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_SoundLevels[uVoicesVolumeMultiplier]));
+}
+
+
+
+
+
+
+
+
+
 
-    pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_Options != -1 ? &pIcons_LOD->pTextures[uTextureID_Options] : 0));
-    pRenderer->DrawTextureIndexed(8, 132, (Texture *)(uTextureID_ControlBG[0] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[0]] : 0));
-    v0 = 0;
-    if ( uTurnSpeed == 128 )
-        {
-        v0 = 2;
-        }
-    else
-        {
-        if ( uTurnSpeed == 64 )
-            v0 = 1;
-        }
-    pRenderer->DrawTextureIndexed(BtnTurnCoord[v0], 270, (Texture *)(uTextureID_ControlBG[v0 + 1] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[v0 + 1]] : 0));
-    if ( bWalkSound )
-        pRenderer->DrawTextureIndexed(20, 303, (Texture *)(uTextureID_ControlBG[21] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[21]] : 0));
-    if ( bShowDamage )
-        pRenderer->DrawTextureIndexed(128, 303, (Texture *)(uTextureID_ControlBG[22] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[22]] : 0));
-    if ( bFlipOnExit )
-        pRenderer->DrawTextureIndexed(128, 325, (Texture *)(uTextureID_ControlBG[9] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[9]] : 0));
-    if ( bAlwaysRun )
-        pRenderer->DrawTextureIndexed(20, 325, (Texture *)(uTextureID_ControlBG[20] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[20]] : 0));
-    pRenderer->DrawTextureIndexed(17 * (char)uSoundVolumeMultiplier + 265, 162,
-        (Texture *)(uTextureID_ControlBG[(char)uSoundVolumeMultiplier + 10] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[(char)uSoundVolumeMultiplier + 10]] : 0));
-    pRenderer->DrawTextureIndexed(17 * (char)uMusicVolimeMultiplier + 265, 216,
-        (Texture *)(uTextureID_ControlBG[(char)uMusicVolimeMultiplier + 10] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[(char)uMusicVolimeMultiplier + 10]] : 0));
-    pRenderer->DrawTextureIndexed(17 * (char)uVoicesVolumeMultiplier + 265, 270,
-        (Texture *)(uTextureID_ControlBG[(char)uVoicesVolumeMultiplier + 10] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[(char)uVoicesVolumeMultiplier + 10]] : 0));
-    }
\ No newline at end of file
+OptionsMenuSkin::OptionsMenuSkin():
+  uTextureID_Background(0),
+  uTextureID_ArrowLeft(0),
+  uTextureID_ArrowRight(0),
+  uTextureID_unused_0(0), uTextureID_unused_1(0), uTextureID_unused_2(0),
+  uTextureID_FlipOnExit(0),
+  uTextureID_AlwaysRun(0),
+  uTextureID_WalkSound(0),
+  uTextureID_ShowDamage(0)
+{
+    for (uint i = 0; i < 3; ++i)  uTextureID_TurnSpeed[i] = 0;
+    for (uint i = 0; i < 10; ++i) uTextureID_SoundLevels[i] = 0;
+} 
+
+void OptionsMenuSkin::Relaease()
+{
+  #define RELEASE(id) \
+  {\
+    if (id)\
+      pIcons_LOD->GetTexture(id)->Release();\
+    id = 0;\
+  }
+
+  RELEASE(uTextureID_Background);
+  for (uint i = 0; i < 3; ++i)
+    RELEASE(uTextureID_TurnSpeed[i]);
+  RELEASE(uTextureID_ArrowLeft);
+  RELEASE(uTextureID_ArrowRight);
+  RELEASE(uTextureID_FlipOnExit);
+  for (uint i = 0; i < 10; ++i)
+    RELEASE(uTextureID_SoundLevels[i]);
+  RELEASE(uTextureID_AlwaysRun);
+  RELEASE(uTextureID_WalkSound);
+  RELEASE(uTextureID_ShowDamage);
+
+  #undef RELEASE
+}
--- a/UIPartyCreation.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/UIPartyCreation.cpp	Thu May 02 11:03:26 2013 +0600
@@ -33,16 +33,13 @@
 #include "Awards.h"
 #include "Autonotes.h"
 #include "stru160.h"
-#include "stru279.h"
 #include "TurnEngine.h"
-#include "stru277.h"
+#include "CastSpellInfo.h"
 #include "Weather.h"
-#include "stru272.h"
 #include "stru298.h"
 #include "StorylineTextTable.h"
 #include "Events2D.h"
 #include "texts.h"
-#include "stru351.h"
 
 #include "mm7_data.h"
 
@@ -228,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;
@@ -566,8 +563,8 @@
   unsigned int v0; // ebx@5
   unsigned int v1; // eax@6
   int v2; // ecx@6
-  unsigned int v3; // eax@8
-  signed int v4; // ecx@8
+  //unsigned int v3; // eax@8
+  //signed int v4; // ecx@8
   signed int uControlParam; // [sp+10h] [bp-Ch]@7
   unsigned int uControlParama; // [sp+10h] [bp-Ch]@9
   unsigned int uControlParamb; // [sp+10h] [bp-Ch]@11
@@ -608,70 +605,73 @@
     pPlayerPortraits[uX] = &pIcons_LOD->pTextures[v1];
 
   }
-  pTexture_PlayerFaceMask = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("FACEMASK", TEXTURE_16BIT_PALETTE)];
-  pTexture_buttminu  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("buttminu", TEXTURE_16BIT_PALETTE)];
-  pTexture_buttplus  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("buttplus", TEXTURE_16BIT_PALETTE)];
-  pTexture_pressrigh = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("presrigh", TEXTURE_16BIT_PALETTE)];
-  pTexture_presleft  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("presleft", TEXTURE_16BIT_PALETTE)];
+  pTexture_PlayerFaceMask = pIcons_LOD->LoadTexturePtr("FACEMASK", TEXTURE_16BIT_PALETTE);
+  pTexture_buttminu  = pIcons_LOD->LoadTexturePtr("buttminu", TEXTURE_16BIT_PALETTE);
+  pTexture_buttplus  = pIcons_LOD->LoadTexturePtr("buttplus", TEXTURE_16BIT_PALETTE);
+  pTexture_pressrigh = pIcons_LOD->LoadTexturePtr("presrigh", TEXTURE_16BIT_PALETTE);
+  pTexture_presleft  = pIcons_LOD->LoadTexturePtr("presleft", TEXTURE_16BIT_PALETTE);
   uControlParam = 1;
   do
   {
     sprintf(pTmpBuf, "arrowl%d", uControlParam);
-    pTextures_arrowl[uControlParam] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE)];
+    pTextures_arrowl[uControlParam] = pIcons_LOD->LoadTexturePtr(pTmpBuf, TEXTURE_16BIT_PALETTE);
+
     sprintf(pTmpBuf, "arrowr%d", uControlParam);
-    v3 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE);
-    v4 = uControlParam++;
-    pTextures_arrowr[v4] = &pIcons_LOD->pTextures[v3];
+    pTextures_arrowr[uControlParam] = pIcons_LOD->LoadTexturePtr(pTmpBuf, TEXTURE_16BIT_PALETTE);
   }
-  while ( uControlParam < 20 );
+  while ( ++uControlParam < 20 );
   pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
   uControlParama = 0;
   uXa = 8;
   do
   {
-    pGUIWindow_CurrentMenu->CreateButton(uXa, 120u, 145u, 25u, 1, 0, UIMSG_PlayerCreationChangeName, uControlParama, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXa, 120, 145, 25, 1, 0, UIMSG_PlayerCreationChangeName, uControlParama, 0, "", 0);
     uXa += 158;
     ++uControlParama;
   }
   while ( (signed int)uXa < 640 );
-  pCreationUI_BtnPressLeft[0] = pGUIWindow_CurrentMenu->CreateButton(10, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev, 0, 0, "", pTexture_presleft, 0);
-  pCreationUI_BtnPressLeft[1] = pGUIWindow_CurrentMenu->CreateButton(169, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev, 1, 0, "", pTexture_presleft, 0);
-  pCreationUI_BtnPressLeft[2] = pGUIWindow_CurrentMenu->CreateButton(327, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev, 2, 0, "", pTexture_presleft, 0);
-  pCreationUI_BtnPressLeft[3] = pGUIWindow_CurrentMenu->CreateButton(486, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev, 3, 0, "", pTexture_presleft, 0);
-  pCreationUI_BtnPressRight[0] = pGUIWindow_CurrentMenu->CreateButton(74, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext, 0, 0, "", pTexture_pressrigh, 0);
-  pCreationUI_BtnPressRight[1] = pGUIWindow_CurrentMenu->CreateButton(233, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext, 1, 0, "", pTexture_pressrigh, 0);
-  pCreationUI_BtnPressRight[2] = pGUIWindow_CurrentMenu->CreateButton(391, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext, 2, 0, "", pTexture_pressrigh, 0);
-  pCreationUI_BtnPressRight[3] = pGUIWindow_CurrentMenu->CreateButton(549, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext, 3, 0, "", pTexture_pressrigh, 0);
-  pCreationUI_BtnPressLeft2[0] = pGUIWindow_CurrentMenu->CreateButton(10, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 0, 0, "", pTexture_presleft, 0);
-  pCreationUI_BtnPressLeft2[1] = pGUIWindow_CurrentMenu->CreateButton(169, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 1, 0, "", pTexture_presleft, 0);
-  pCreationUI_BtnPressLeft2[2] = pGUIWindow_CurrentMenu->CreateButton(327, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 2, 0, "", pTexture_presleft, 0);
-  pCreationUI_BtnPressLeft2[3] = pGUIWindow_CurrentMenu->CreateButton(486, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 3, 0, "", pTexture_presleft, 0);
-  pCreationUI_BtnPressRight2[0] = pGUIWindow_CurrentMenu->CreateButton(74, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoiceNext, 0, 0, "", pTexture_pressrigh, 0);
+
+  pCreationUI_BtnPressLeft[0]   = pGUIWindow_CurrentMenu->CreateButton( 10,  32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev,  0, 0, "", pTexture_presleft, 0);
+  pCreationUI_BtnPressLeft[1]   = pGUIWindow_CurrentMenu->CreateButton(169,  32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev,  1, 0, "", pTexture_presleft, 0);
+  pCreationUI_BtnPressLeft[2]   = pGUIWindow_CurrentMenu->CreateButton(327,  32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev,  2, 0, "", pTexture_presleft, 0);
+  pCreationUI_BtnPressLeft[3]   = pGUIWindow_CurrentMenu->CreateButton(486,  32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev,  3, 0, "", pTexture_presleft, 0);
+  pCreationUI_BtnPressRight[0]  = pGUIWindow_CurrentMenu->CreateButton( 74,  32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext,  0, 0, "", pTexture_pressrigh, 0);
+  pCreationUI_BtnPressRight[1]  = pGUIWindow_CurrentMenu->CreateButton(233,  32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext,  1, 0, "", pTexture_pressrigh, 0);
+  pCreationUI_BtnPressRight[2]  = pGUIWindow_CurrentMenu->CreateButton(391,  32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext,  2, 0, "", pTexture_pressrigh, 0);
+  pCreationUI_BtnPressRight[3]  = pGUIWindow_CurrentMenu->CreateButton(549,  32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext,  3, 0, "", pTexture_pressrigh, 0);
+  pCreationUI_BtnPressLeft2[0]  = pGUIWindow_CurrentMenu->CreateButton( 10, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 0, 0, "", pTexture_presleft, 0);
+  pCreationUI_BtnPressLeft2[1]  = pGUIWindow_CurrentMenu->CreateButton(169, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 1, 0, "", pTexture_presleft, 0);
+  pCreationUI_BtnPressLeft2[2]  = pGUIWindow_CurrentMenu->CreateButton(327, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 2, 0, "", pTexture_presleft, 0);
+  pCreationUI_BtnPressLeft2[3]  = pGUIWindow_CurrentMenu->CreateButton(486, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 3, 0, "", pTexture_presleft, 0);
+  pCreationUI_BtnPressRight2[0] = pGUIWindow_CurrentMenu->CreateButton( 74, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoiceNext, 0, 0, "", pTexture_pressrigh, 0);
   pCreationUI_BtnPressRight2[1] = pGUIWindow_CurrentMenu->CreateButton(233, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoiceNext, 1, 0, "", pTexture_pressrigh, 0);
   pCreationUI_BtnPressRight2[2] = pGUIWindow_CurrentMenu->CreateButton(391, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoiceNext, 2, 0, "", pTexture_pressrigh, 0);
   pCreationUI_BtnPressRight2[3] = pGUIWindow_CurrentMenu->CreateButton(549, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoiceNext, 3, 0, "", pTexture_pressrigh, 0);
+
   uControlParamb = 0;
   uXb = 8;
   do
   {
-    pGUIWindow_CurrentMenu->CreateButton(uXb, 308, 150, v0, 1, 0, UIMSG_48, uControlParamb, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(uXb, v0 + 308, 150, v0, 1, 0, UIMSG_49, uControlParamb, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(uXb, 2 * v0 + 308, 150u, v0, 1, 0, UIMSG_PlayerCreationRemoveUpSkill, uControlParamb, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(uXb, 3 * v0 + 308, 150u, v0, 1, 0, UIMSG_PlayerCreationRemoveDownSkill, uControlParamb, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXb, 308,          150, v0, 1, 0, UIMSG_48,                            uControlParamb, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXb, v0 + 308,     150, v0, 1, 0, UIMSG_49,                            uControlParamb, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXb, 2 * v0 + 308, 150, v0, 1, 0, UIMSG_PlayerCreationRemoveUpSkill,   uControlParamb, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXb, 3 * v0 + 308, 150, v0, 1, 0, UIMSG_PlayerCreationRemoveDownSkill, uControlParamb, 0, "", 0);
     uXb += 158;
     ++uControlParamb;
   }
   while ( (signed int)uXb < 640 );
-  pGUIWindow_CurrentMenu->CreateButton(5u, 21u, 0x99u, 0x16Du, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 0, 0x31u, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(163u, 21u, 0x99u, 0x16Du, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 1u, 0x32u, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(321u, 21u, 0x99u, 0x16Du, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 2u, 0x33u, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(479u, 21u, 0x99u, 0x16Du, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 3u, 0x34u, "", 0);
+
+  pGUIWindow_CurrentMenu->CreateButton(  5, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 0, 0x31u, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(163, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 1, 0x32u, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(321, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 2, 0x33u, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(479, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 3, 0x34u, "", 0);
+
   uXc = 23;
   uControlParamc = 2;
   do
   {
-    pGUIWindow_CurrentMenu->CreateButton(uXc, 169, 120, 20, 1, 0, UIMSG_0, uControlParamc - 2, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(uXc, v0 + 169, 120, 20, 1, 0, UIMSG_0, uControlParamc - 1, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXc, 169,          120, 20, 1, 0, UIMSG_0, uControlParamc - 2, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXc, v0 + 169,     120, 20, 1, 0, UIMSG_0, uControlParamc - 1, 0, "", 0);
     pGUIWindow_CurrentMenu->CreateButton(uXc, 2 * v0 + 169, 120, 20, 1, 0, UIMSG_0, uControlParamc, 0, "", 0);
     pGUIWindow_CurrentMenu->CreateButton(uXc, 3 * v0 + 169, 120, 20, 1, 0, UIMSG_0, uControlParamc + 1, 0, "", 0);
     pGUIWindow_CurrentMenu->CreateButton(uXc, 4 * v0 + 169, 120, 20, 1, 0, UIMSG_0, uControlParamc + 2, 0, "", 0);
@@ -682,15 +682,15 @@
   }
   while ( (signed int)uControlParamc < 30 );
   pGUIWindow_CurrentMenu->_41D08F(28, 0, 7, 40);
-  pGUIWindow_CurrentMenu->CreateButton(323, 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(323, v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0xC, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(323, 417,          65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0,    0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(323, v0 + 417,     65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0xC,  0, "", 0);
   pGUIWindow_CurrentMenu->CreateButton(323, 2 * v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x14, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(388, 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x18, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(388, v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x1C, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(388, 417,          65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x18, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(388, v0 + 417,     65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x1C, 0, "", 0);
   pGUIWindow_CurrentMenu->CreateButton(388, 2 * v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x20, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(453, 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x10, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(453, v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 8, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(453, 2 * v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 4, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(453, 417,          65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x10, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(453, v0 + 417,     65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 8,    0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(453, 2 * v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 4,    0, "", 0);
   uControlParamd = 0;
   do
   {
@@ -702,12 +702,11 @@
     ++uControlParamd;
   }
   while ( uControlParamd < 9 );
-  pPlayerCreationUI_BtnOK = pGUIWindow_CurrentMenu->CreateButton(580, 431, 51, 39, 1, 0, UIMSG_PlayerCreationClickOK, 0, 0xD, "",
-                              (Texture *)(uTextureID_BUTTMAKE != -1 ? &pIcons_LOD->pTextures[uTextureID_BUTTMAKE] : 0), 0);
-  pPlayerCreationUI_BtnReset = pGUIWindow_CurrentMenu->CreateButton(527, 431, 51, 39, 1, 0, UIMSG_PlayerCreationClickReset, 0, 0x43, "",
-                                 (Texture *)(uTextureID_BUTTMAKE2 != -1 ? &pIcons_LOD->pTextures[uTextureID_BUTTMAKE2] : 0), 0);
+  pPlayerCreationUI_BtnOK    = pGUIWindow_CurrentMenu->CreateButton(580, 431, 51, 39, 1, 0, UIMSG_PlayerCreationClickOK, 0, 0xD, "", pIcons_LOD->GetTexture(uTextureID_BUTTMAKE), 0);
+  pPlayerCreationUI_BtnReset = pGUIWindow_CurrentMenu->CreateButton(527, 431, 51, 39, 1, 0, UIMSG_PlayerCreationClickReset, 0, 0x43, "", pIcons_LOD->GetTexture(uTextureID_BUTTMAKE2), 0);
   pPlayerCreationUI_BtnMinus = pGUIWindow_CurrentMenu->CreateButton(523, 393, 20, 35, 1, 0, UIMSG_PlayerCreationClickMinus, 0, 0x2D, "", pTexture_buttminu, 0);
-  pPlayerCreationUI_BtnPlus = pGUIWindow_CurrentMenu->CreateButton(613, 393, 20, 35, 1, 0, UIMSG_PlayerCreationClickPlus, 1, 0x2B, "", pTexture_buttplus, 0);
+  pPlayerCreationUI_BtnPlus  = pGUIWindow_CurrentMenu->CreateButton(613, 393, 20, 35, 1, 0, UIMSG_PlayerCreationClickPlus, 1, 0x2B, "", pTexture_buttplus, 0);
+
   pFontCChar = LoadFont("cchar.fnt", "FONTPAL", NULL);
 }
 // 4E28F8: using guessed type int pCurrentScreen;
--- a/UIPopup.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/UIPopup.cpp	Thu May 02 11:03:26 2013 +0600
@@ -33,16 +33,13 @@
 #include "Awards.h"
 #include "Autonotes.h"
 #include "stru160.h"
-#include "stru279.h"
 #include "TurnEngine.h"
-#include "stru277.h"
+#include "CastSpellInfo.h"
 #include "Weather.h"
-#include "stru272.h"
 #include "stru298.h"
 #include "StorylineTextTable.h"
 #include "Events2D.h"
 #include "texts.h"
-#include "stru351.h"
 
 #include "mm7_data.h"
 
@@ -75,13 +72,12 @@
     a2a = uX;
     a4 = uX + uWidth;
     pRenderer->SetTextureClipRect(uX, v4, uX + uWidth, v4 + uHeight);
-    v5 = (Texture *)(uTextureID_Parchment != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Parchment] : 0);
-    uTileWidth = (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureWidth : 24);
-    v13 = (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureWidth : 24);
-    uTileHeight = (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureHeight : 26);
-    if ( (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureWidth : 24)
-        && (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureHeight : 26) )
-        {
+    v5 = pIcons_LOD->GetTexture(uTextureID_Parchment);
+    uTileWidth = v5->uTextureWidth;
+    v13 = v5->uTextureWidth;
+    uTileHeight = v5->uTextureHeight;
+    if ( v5->uTextureWidth && v5->uTextureHeight)
+    {
         uNumXTiles = (signed int)uWidth / uTileWidth;
         if ( (signed int)uWidth % uTileWidth )
             ++uNumXTiles;
@@ -109,59 +105,29 @@
             }
             while ( v8 < (signed int)uHeight / uTileHeight );
             a5a = v4 + uHeight - 32;
-            pRenderer->DrawTextureTransparent(
-                a2a,
-                v4,
-                (Texture *)(uTextureID_5076AC != -1 ? &pIcons_LOD->pTextures[uTextureID_5076AC] : 0));
-            pRenderer->DrawTextureTransparent(
-                a2a,
-                a5a,
-                (Texture *)(uTextureID_5076B4 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076B4] : 0));
-            pRenderer->DrawTextureTransparent(
-                a4 - 32,
-                v4,
-                (Texture *)(uTextureID_5076A8 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A8] : 0));
-            pRenderer->DrawTextureTransparent(
-                a4 - 32,
-                a5a,
-                (Texture *)(uTextureID_5076B0 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_5076B0] : 0));
+            pRenderer->DrawTextureTransparent(a2a, v4, pIcons_LOD->GetTexture(uTextureID_5076AC));
+            pRenderer->DrawTextureTransparent(a2a, a5a, pIcons_LOD->GetTexture(uTextureID_5076B4));
+            pRenderer->DrawTextureTransparent(a4 - 32, v4, pIcons_LOD->GetTexture(uTextureID_5076A8));
+            pRenderer->DrawTextureTransparent(a4 - 32, a5a, pIcons_LOD->GetTexture(uTextureID_5076B0));
             uNumXTilesb = a2a + 32;
             v22 = v4 + uHeight - 10;
             if ( (signed int)uWidth > 64 )
                 {
                 pRenderer->SetTextureClipRect(a2a + 32, v4, a4 - 32, v4 + uHeight);
-                pRenderer->DrawTextureTransparent(
-                    uNumXTilesb,
-                    v4,
-                    (Texture *)(uTextureID_507698 != -1 ? &pIcons_LOD->pTextures[uTextureID_507698] : 0));
-                pRenderer->DrawTextureTransparent(
-                    uNumXTilesb,
-                    v22,
-                    (Texture *)(uTextureID_5076A4 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A4] : 0));
+                pRenderer->DrawTextureTransparent(uNumXTilesb, v4, pIcons_LOD->GetTexture(uTextureID_507698));
+                pRenderer->DrawTextureTransparent(uNumXTilesb, v22, pIcons_LOD->GetTexture(uTextureID_5076A4));
                 if ( (signed int)uWidth > 512 )
                     {
-                    pRenderer->DrawTextureTransparent(
-                        a2a + 544,
-                        v4,
-                        (Texture *)(uTextureID_507698 != -1 ? &pIcons_LOD->pTextures[uTextureID_507698] : 0));
-                    pRenderer->DrawTextureTransparent(
-                        a2a + 544,
-                        v22,
-                        (Texture *)(uTextureID_5076A4 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A4] : 0));
+                    pRenderer->DrawTextureTransparent(a2a + 544, v4, pIcons_LOD->GetTexture(uTextureID_507698));
+                    pRenderer->DrawTextureTransparent(a2a + 544, v22, pIcons_LOD->GetTexture(uTextureID_5076A4));
                     }
                 }
             v9 = v4 + 32;
             if ( (signed int)uHeight > 64 )
                 {
                 pRenderer->SetTextureClipRect(a2a, v9, a4, a5a);
-                pRenderer->DrawTextureTransparent(
-                    a2a,
-                    v9,
-                    (Texture *)(uTextureID_5076A0 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A0] : 0));
-                pRenderer->DrawTextureTransparent(
-                    a4 - 10,
-                    v9,
-                    (Texture *)(uTextureID_50769C != -1 ? &pIcons_LOD->pTextures[uTextureID_50769C] : 0));
+                pRenderer->DrawTextureTransparent(a2a, v9, pIcons_LOD->GetTexture(uTextureID_5076A0));
+                pRenderer->DrawTextureTransparent(a4 - 10, v9, pIcons_LOD->GetTexture(uTextureID_50769C));
                 }
             pRenderer->ResetTextureClipRect();
         }
@@ -260,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;
 
@@ -364,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 )
@@ -388,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 )
@@ -762,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);
@@ -988,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;
@@ -1535,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");
@@ -1849,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;
@@ -2226,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	Thu May 02 11:02:48 2013 +0600
+++ b/UIRest.cpp	Thu May 02 11:03:26 2013 +0600
@@ -33,16 +33,13 @@
 #include "Awards.h"
 #include "Autonotes.h"
 #include "stru160.h"
-#include "stru279.h"
 #include "TurnEngine.h"
-#include "stru277.h"
+#include "CastSpellInfo.h"
 #include "Weather.h"
-#include "stru272.h"
 #include "stru298.h"
 #include "StorylineTextTable.h"
 #include "Events2D.h"
 #include "texts.h"
-#include "stru351.h"
 
 #include "mm7_data.h"
 
@@ -51,69 +48,69 @@
 //----- (0041F6C1) --------------------------------------------------------
 void __cdecl RestUI_Initialize()
 {
-  Player *pPlayer; // eax@10
+    Player *v0; // eax@10
 
-  if ( !dword_506F14 )
-    pAudioPlayer->StopChannels(-1, -1);
-  if ( pCurrentScreen )
-  {
-    pGUIWindow_CurrentMenu->Release();
-    pCurrentScreen = SCREEN_GAME;
-    viewparams->bRedrawGameUI = 1;
-  }
-  pEventTimer->Pause();
-  if ( dword_506F14 != 2 )
-    GUIWindow::Create(518, 450, 0, 0, (enum WindowType)90, (int)pBtn_Rest, 0);
-  _506F18_num_hours_to_sleep = 0;
-  dword_506F14 = 0;
-  uRestUI_FoodRequiredToRest = 2;
-  if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
-    uRestUI_FoodRequiredToRest = pOutdoor->GetNumFoodRequiredToRestInCurrentPos(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
-  if ( PartyHasDragon() )
-  {
-    pPlayer = pParty->pPlayers;//[0].uClass; this incorrect
-    while ( pPlayer <= &pParty->pPlayers[3] )
-    {
-      ++pPlayer;
-      if ( pPlayer > &pParty->pPlayers[3] )
-        break;
-    }
-    if (pPlayer->classType == PLAYER_CLASS_WARLOCK)
-      ++uRestUI_FoodRequiredToRest;
-  }
-  if ( CheckHiredNPCSpeciality(Porter) )
-    --uRestUI_FoodRequiredToRest;
-  if ( CheckHiredNPCSpeciality(QuarterMaster) )
-    uRestUI_FoodRequiredToRest -= 2;
-  if ( CheckHiredNPCSpeciality(Gypsy) )
-    --uRestUI_FoodRequiredToRest;
-  if ( uRestUI_FoodRequiredToRest < 1 )
-    uRestUI_FoodRequiredToRest = 1;
-  if ( !_strcmpi(pCurrentMapName, "d29.blv") && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 98) )
-    uRestUI_FoodRequiredToRest = 0;
-  ++pIcons_LOD->uTexturePacksCount;
-  if ( !pIcons_LOD->uNumPrevLoadedFiles )
-    pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
-  pCurrentScreen = SCREEN_REST;
-  _507CD4_RestUI_hourglass_anim_controller = 0;
-  uTextureID_RestUI_restmain = pIcons_LOD->LoadTexture("restmain", TEXTURE_16BIT_PALETTE);
-  uTextureID_RestUI_restb1 = pIcons_LOD->LoadTexture("restb1", TEXTURE_16BIT_PALETTE);
-  uTextureID_RestUI_restb2 = pIcons_LOD->LoadTexture("restb2", TEXTURE_16BIT_PALETTE);
-  uTextureID_RestUI_restb3 = pIcons_LOD->LoadTexture("restb3", TEXTURE_16BIT_PALETTE);
-  uTextureID_RestUI_restb4 = pIcons_LOD->LoadTexture("restb4", TEXTURE_16BIT_PALETTE);
-  uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE);
-  LoadActualSkyFrame();
-  pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, (enum WindowType)16, 0, 0);
-  pButton_RestUI_Exit = pGUIWindow_CurrentMenu->CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest, 0, 0, "",
-        (Texture *)(uTextureID_RestUI_restexit != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restexit] : 0), 0);
-  pButton_RestUI_Main = pGUIWindow_CurrentMenu->CreateButton(24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour, 0, 0x52u, "",
-        (Texture *)(uTextureID_RestUI_restb4 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb4] : 0), 0);
-  pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton(61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 0x44u, "",
-        (Texture *)(uTextureID_RestUI_restb1 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb1] : 0), 0);
-  pButton_RestUI_Wait1Hour = pGUIWindow_CurrentMenu->CreateButton(61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 0x48u, "",
-        (Texture *)(uTextureID_RestUI_restb2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb2] : 0), 0);
-  pButton_RestUI_Wait5Minutes = pGUIWindow_CurrentMenu->CreateButton(61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 0x4Du, "",
-        (Texture *)(uTextureID_RestUI_restb3 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb3] : 0), 0);
+    if ( !dword_506F14 )
+        pAudioPlayer->StopChannels(-1, -1);
+    if ( pCurrentScreen )
+        {
+        pGUIWindow_CurrentMenu->Release();
+        pCurrentScreen = SCREEN_GAME;
+        viewparams->bRedrawGameUI = 1;
+        }
+    pEventTimer->Pause();
+    if ( dword_506F14 != 2 )
+        GUIWindow::Create(518u, 450u, 0, 0, (enum WindowType)90, (int)pBtn_Rest, 0);
+    _506F18_num_hours_to_sleep = 0;
+    dword_506F14 = 0;
+    uRestUI_FoodRequiredToRest = 2;
+    if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+        uRestUI_FoodRequiredToRest = pOutdoor->GetNumFoodRequiredToRestInCurrentPos(
+        pParty->vPosition.x,
+        pParty->vPosition.y,
+        pParty->vPosition.z);
+    if ( PartyHasDragon() )
+        {
+        v0 = pParty->pPlayers;//[0].uClass;
+        while ( v0 <= &pParty->pPlayers[3] )
+            {
+            ++v0;
+            if ( v0 > &pParty->pPlayers[3] )
+                break;
+            }
+        if(v0->classType == PLAYER_CLASS_WARLOCK)
+            ++uRestUI_FoodRequiredToRest;
+        }
+    if ( CheckHiredNPCSpeciality(Porter) )
+        --uRestUI_FoodRequiredToRest;
+    if ( CheckHiredNPCSpeciality(QuarterMaster) )
+        uRestUI_FoodRequiredToRest -= 2;
+    if ( CheckHiredNPCSpeciality(Gypsy) )
+        --uRestUI_FoodRequiredToRest;
+    if ( uRestUI_FoodRequiredToRest < 1 )
+        uRestUI_FoodRequiredToRest = 1;
+    if ( !_strcmpi(pCurrentMapName, "d29.blv") && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 98) )
+        uRestUI_FoodRequiredToRest = 0;
+    ++pIcons_LOD->uTexturePacksCount;
+    if ( !pIcons_LOD->uNumPrevLoadedFiles )
+        pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
+    pCurrentScreen = SCREEN_REST;
+    _507CD4_RestUI_hourglass_anim_controller = 0;
+    uTextureID_RestUI_restmain = pIcons_LOD->LoadTexture("restmain", TEXTURE_16BIT_PALETTE);
+    uTextureID_RestUI_restb1 = pIcons_LOD->LoadTexture("restb1", TEXTURE_16BIT_PALETTE);
+    uTextureID_RestUI_restb2 = pIcons_LOD->LoadTexture("restb2", TEXTURE_16BIT_PALETTE);
+    uTextureID_RestUI_restb3 = pIcons_LOD->LoadTexture("restb3", TEXTURE_16BIT_PALETTE);
+    uTextureID_RestUI_restb4 = pIcons_LOD->LoadTexture("restb4", TEXTURE_16BIT_PALETTE);
+    uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE);
+
+    LoadActualSkyFrame();
+
+    pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Rest, 0, 0);
+    pButton_RestUI_Exit          = pGUIWindow_CurrentMenu->CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest,       0, 0,     "", pIcons_LOD->GetTexture(uTextureID_RestUI_restexit), 0);
+    pButton_RestUI_Main          = pGUIWindow_CurrentMenu->CreateButton( 24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour,      0, 0x52u, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0);
+    pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton( 61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 0x44u, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb1), 0);
+    pButton_RestUI_Wait1Hour     = pGUIWindow_CurrentMenu->CreateButton( 61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour,      0, 0x48u, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb2), 0);
+    pButton_RestUI_Wait5Minutes  = pGUIWindow_CurrentMenu->CreateButton( 61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes,   0, 0x4Du, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb3), 0);
 }
 
 //----- (0041FA01) --------------------------------------------------------
@@ -134,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
         {
@@ -147,10 +144,7 @@
         while ( (signed int)ppPlayers <= (signed int)&pPlayers[4] );
         if ( v0 )
             {
-            pRenderer->DrawTextureIndexed(
-                8u,
-                8u,
-                (Texture *)(uTextureID_RestUI_restmain != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restmain] : 0));
+            pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_RestUI_restmain));
             v10 = pParty->uCurrentHour;
             dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem;
             if ( (signed int)pParty->uCurrentHour <= 12 )
--- a/UISaveLoad.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/UISaveLoad.cpp	Thu May 02 11:03:26 2013 +0600
@@ -33,16 +33,13 @@
 #include "Awards.h"
 #include "Autonotes.h"
 #include "stru160.h"
-#include "stru279.h"
 #include "TurnEngine.h"
-#include "stru277.h"
+#include "CastSpellInfo.h"
 #include "Weather.h"
-#include "stru272.h"
 #include "stru298.h"
 #include "StorylineTextTable.h"
 #include "Events2D.h"
 #include "texts.h"
-#include "stru351.h"
 
 #include "mm7_data.h"
 
@@ -92,12 +89,12 @@
 
   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 )
   {
-    pRenderer->DrawTextureIndexed(8, 8, uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0);
+    pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave));
     if ( a4 )
     {
       v2 = uTextureID_save_up;
@@ -108,9 +105,9 @@
       v2 = uTextureID_load_up;
       v3 = uTextureID_LS_loadU;
     }
-    pRenderer->DrawTextureIndexed(241, 302, (Texture *)(v3 != -1 ? &pIcons_LOD->pTextures[v3] : 0));
-    pRenderer->DrawTextureIndexed(18, 139, (Texture *)(v2 != -1 ? &pIcons_LOD->pTextures[v2] : 0));
-    pRenderer->DrawTextureIndexed(351, 302, (Texture *)(uTextureID_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_u] : 0));
+    pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(v3));
+    pRenderer->DrawTextureIndexed (18, 139, pIcons_LOD->GetTexture(v2));
+    pRenderer->DrawTextureIndexed(351, 302, pIcons_LOD->GetTexture(uTextureID_x_u));
     v1 = 255;
   }
   if ( pSavegameUsedSlots[uLoadGameUI_SelectedSlot] )
@@ -225,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);
@@ -267,7 +264,7 @@
 
 //----- (0045E361) --------------------------------------------------------
 void __fastcall GameUI_DrawLoadMenu(unsigned int uDialogueType)
-    {
+{
     unsigned int v1; // ebp@5
     unsigned int v2; // eax@5
     //signed int v3; // ebp@11
@@ -299,7 +296,7 @@
     uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE);
     if ( uDialogueType_ )
         {
-        pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
+        pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave));
         if ( pCurrentScreen == SCREEN_SAVEGAME )
             {
             v1 = uTextureID_save_up;
@@ -310,9 +307,9 @@
             v1 = uTextureID_load_up;
             v2 = uTextureID_LS_loadU;
             }
-        pRenderer->DrawTextureIndexed(241, 302, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0));
-        pRenderer->DrawTextureIndexed(18, 141, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0));
-        pRenderer->DrawTextureIndexed(351, 302, (Texture *)(uTextureID_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_u] : 0));
+        pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(v2));
+        pRenderer->DrawTextureIndexed( 18, 141, pIcons_LOD->GetTexture(v1));
+        pRenderer->DrawTextureIndexed(351, 302, pIcons_LOD->GetTexture(uTextureID_x_u));
         }
     else
         {
@@ -382,20 +379,15 @@
     pGUIWindow_CurrentMenu->CreateButton(21, 282, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 4, 0, "", 0);
     pGUIWindow_CurrentMenu->CreateButton(21, 303, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 5, 0, "", 0);
     pGUIWindow_CurrentMenu->CreateButton(21, 324, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 6, 0, "", 0);
-    pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(241, 302, 105, 40, 1, 0, UIMSG_LoadSlot, 0, 0, "",
-        pIcons_LOD->GetTexture(uTextureID_LS_), 0);
-    pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "",
-        pIcons_LOD->GetTexture(uTextureID_x_d), 0);
-    pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton(215, 199, 17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "",
-        pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0);
-    pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 0x143, 0x11, 0x11, 1, 0, UIMSG_DownArrow, uNumSavegameFiles, 0, "",
-        pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0);
-
-    }
+    pBtnLoadSlot  = pGUIWindow_CurrentMenu->CreateButton(241, 302, 105, 40, 1, 0, UIMSG_LoadSlot, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_LS_), 0);
+    pBtnCancel    = pGUIWindow_CurrentMenu->CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_x_d), 0);
+    pBtnArrowUp   = pGUIWindow_CurrentMenu->CreateButton(215, 199,  17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0);
+    pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 323,  17, 17, 1, 0, UIMSG_DownArrow, uNumSavegameFiles, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0);
+}
 
 //----- (0045E93E) --------------------------------------------------------
 void  GameUI_DrawSaveMenu()
-    {
+{
     unsigned int v0; // ebp@4
     unsigned int v1; // eax@4
     char *v3; // eax@7
@@ -414,22 +406,20 @@
     uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE);
     uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE);
     uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE);
-    pRenderer->DrawTextureIndexed( 8u, 8u,
-        (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
+    pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave));
     if ( pCurrentScreen == SCREEN_SAVEGAME )
-        {
+    {
         v0 = uTextureID_save_up;
         v1 = uTextureID_LS_saveU;
         }
     else
-        {
+    {
         v0 = uTextureID_load_up;
         v1 = uTextureID_LS_loadU;
         }
-    pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0));
-    pRenderer->DrawTextureIndexed(0x15Fu, 0x12Eu,
-        (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0));
-    pRenderer->DrawTextureIndexed(0x12u, 0x8Du, (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0));
+    pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, pIcons_LOD->GetTexture(v1));
+    pRenderer->DrawTextureIndexed(0x15Fu, 0x12Eu, pIcons_LOD->GetTexture(uTextureID_x_u));
+    pRenderer->DrawTextureIndexed(0x12u, 0x8Du, pIcons_LOD->GetTexture(v0));
     pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);
     pRenderer->Present();
     pSavegameList->Initialize(1u);
@@ -475,19 +465,15 @@
     uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
     uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
     pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_17, 0, 0);
-    pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(21u, 218u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 1u, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(21u, 238u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 2u, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(21u, 258u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 3u, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(21u, 278u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 4u, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(21u, 298u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 5u, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(21u, 318u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 6u, 0, "", 0);
-    pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0x69u, 0x28u, 1, 0, UIMSG_LoadSlot, 0, 0, "",
-        (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0), 0);
-    pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(0x15Eu, 0x12Eu, 0x69u, 0x28u, 1, 0, UIMSG_Cancel, 0, 0, "",
-        (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0), 0);
-    pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0xC7u, 0x11u, 0x11u, 1, 0, UIMSG_ArrowUp, 0, 0, "",
-        (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0), 0);
-    pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0x143u, 0x11u, 0x11u, 1, 0, UIMSG_DownArrow, 0x22u, 0, "",
-        (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), 0);
-    }
+    pGUIWindow_CurrentMenu->CreateButton(21, 198, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21, 218, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 1, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21, 238, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 2, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21, 258, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 3, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21, 278, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 4, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21, 298, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 5, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21, 318, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 6, 0, "", 0);
+    pBtnLoadSlot  = pGUIWindow_CurrentMenu->CreateButton(241, 302, 105, 40, 1, 0, UIMSG_LoadSlot, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_LS_), 0);
+    pBtnCancel    = pGUIWindow_CurrentMenu->CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_x_d), 0);
+    pBtnArrowUp   = pGUIWindow_CurrentMenu->CreateButton(215, 199,  17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0);
+    pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 323,  17, 17, 1, 0, UIMSG_DownArrow, 34, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0);
+}
--- a/UiGame.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/UiGame.cpp	Thu May 02 11:03:26 2013 +0600
@@ -34,16 +34,13 @@
 #include "Awards.h"
 #include "Autonotes.h"
 #include "stru160.h"
-#include "stru279.h"
 #include "TurnEngine.h"
-#include "stru277.h"
+#include "CastSpellInfo.h"
 #include "Weather.h"
-#include "stru272.h"
 #include "stru298.h"
 #include "StorylineTextTable.h"
 #include "Events2D.h"
 #include "texts.h"
-#include "stru351.h"
 #include "UIHouses.h"
 
 #include "mm7_data.h"
@@ -134,26 +131,15 @@
     }
   }
   v8 = a2->uFrameX + (signed int)(a2->uFrameWidth - v4) / 2;
+
   pRenderer->SetTextureClipRect(v8, a2->uFrameY + 32, v8 + v4, a2->uFrameY + 52);
-  pRenderer->DrawTextureIndexed(
-    v8,
-    v3->uFrameY + 32,
-    (Texture *)(uTextureID_mhp_bd != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_mhp_bd] : 0));
+  pRenderer->DrawTextureIndexed(v8, v3->uFrameY + 32, pIcons_LOD->GetTexture(uTextureID_mhp_bd));
   pRenderer->SetTextureClipRect(v8, v3->uFrameY + 32, v8 + v10, v3->uFrameY + 52);
-  pRenderer->DrawTextureIndexed(
-    v8,
-    v3->uFrameY + 34,
-    (Texture *)(v9 != -1 ? (int)&pIcons_LOD->pTextures[v9] : 0));
-  pRenderer->ResetTextureClipRect();
+  pRenderer->DrawTextureIndexed(v8, v3->uFrameY + 34, pIcons_LOD->GetTexture(v9));
 
-  pRenderer->DrawTextureIndexed(
-    v8 - 5,
-    v3->uFrameY + 32,
-    (Texture *)(uTextureID_mhp_capl != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_mhp_capl] : 0));
-  pRenderer->DrawTextureIndexed(
-    v8 + v4,
-    v3->uFrameY + 32,
-    (Texture *)(uTextureID_mhp_capr != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_mhp_capr] : 0));
+  pRenderer->ResetTextureClipRect();
+  pRenderer->DrawTextureIndexed(v8 - 5, v3->uFrameY + 32, pIcons_LOD->GetTexture(uTextureID_mhp_capl));
+  pRenderer->DrawTextureIndexed(v8 + v4, v3->uFrameY + 32, pIcons_LOD->GetTexture(uTextureID_mhp_capr));
 }
 
 //----- (0041B0C9) --------------------------------------------------------
@@ -178,12 +164,12 @@
   signed int v16; // [sp+24h] [bp-8h]@1
   signed int v17; // [sp+28h] [bp-4h]@8
 
-  v0 = (Texture *)(uTextureID_BarGreen != -1 ? &pIcons_LOD->pTextures[uTextureID_BarGreen] : 0);
-  v14 = (Texture *)(uTextureID_BarYellow != -1 ? &pIcons_LOD->pTextures[uTextureID_BarYellow] : 0);
-  v13 = (Texture *)(uTextureID_BarRed != -1 ? &pIcons_LOD->pTextures[uTextureID_BarRed] : 0);
+  v0 = pIcons_LOD->GetTexture(uTextureID_BarGreen);
+  v14 = pIcons_LOD->GetTexture(uTextureID_BarYellow);
+  v13 = pIcons_LOD->GetTexture(uTextureID_BarRed);
   v16 = 0;
-  v10 = (Texture *)(uTextureID_BarBlue != -1 ? &pIcons_LOD->pTextures[uTextureID_BarBlue] : 0);
-  v15 = (double)(uTextureID_BarGreen != -1 ? pIcons_LOD->pTextures[uTextureID_BarGreen].uTextureHeight : 26);
+  v10 = pIcons_LOD->GetTexture(uTextureID_BarBlue);
+  v15 = v0->uTextureHeight;
   do
   {
     v1 = &pParty->pPlayers[v16];
@@ -266,8 +252,7 @@
 //----- (0041B3B6) --------------------------------------------------------
 void __cdecl draw_right_panel()
 {
-  pRenderer->DrawTextureTransparent(pViewport->uViewportBR_X, 0,
-    (Texture *)(uTextureID_right_panel != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_right_panel] : 0));
+  pRenderer->DrawTextureTransparent(pViewport->uViewportBR_X, 0, pIcons_LOD->GetTexture(uTextureID_right_panel));
 }
 
 //----- (0041B3E2) --------------------------------------------------------
@@ -1241,45 +1226,46 @@
   bRingsShownInCharScreen = 0;
   CharacterUI_LoadPaperdollTextures();
   pCurrentScreen = v1;
+
   pWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_CharacterRecord, uActiveCharacter, 0);
   pCharacterScreen_StatsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 12, pViewport->uViewportTL_Y + 308,
-                                (papredoll_dbrds[9] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[9]].uTextureWidth : 24),
-                                (papredoll_dbrds[9] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[9]].uTextureHeight : 26),
-                                1, 0, UIMSG_73, 0, 0x53u, pGlobalTXT_LocalizationStrings[216],// Stats
-                                (Texture *)(papredoll_dbrds[10] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[10]] : 0),
-                                papredoll_dbrds[9] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[9]] : 0, 0);
+                                pIcons_LOD->GetTexture(papredoll_dbrds[9])->uTextureWidth,
+                                pIcons_LOD->GetTexture(papredoll_dbrds[9])->uTextureHeight,
+                                1, 0, UIMSG_73, 0, 'S', pGlobalTXT_LocalizationStrings[216],// Stats
+                                pIcons_LOD->GetTexture(papredoll_dbrds[10]),
+                                pIcons_LOD->GetTexture(papredoll_dbrds[9]), 0);
   pCharacterScreen_SkillsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 102, pViewport->uViewportTL_Y + 308,
-                                 (papredoll_dbrds[7] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[7]].uTextureWidth : 24),
-                                 (papredoll_dbrds[7] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[7]].uTextureHeight : 26),
-                                 1, 0, UIMSG_72, 0, 0x4Bu, pGlobalTXT_LocalizationStrings[205],//Skills
-                                 (Texture *)(papredoll_dbrds[8] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[8]] : 0),
-                                 papredoll_dbrds[7] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[7]] : 0, 0);
+                                 pIcons_LOD->GetTexture(papredoll_dbrds[7])->uTextureWidth,
+                                 pIcons_LOD->GetTexture(papredoll_dbrds[7])->uTextureHeight,
+                                 1, 0, UIMSG_72, 0, 'K', pGlobalTXT_LocalizationStrings[205],//Skills
+                                 pIcons_LOD->GetTexture(papredoll_dbrds[8]),
+                                 pIcons_LOD->GetTexture(papredoll_dbrds[7]), 0);
   pCharacterScreen_InventoryBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 192, pViewport->uViewportTL_Y + 308,
-                                    (papredoll_dbrds[5] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[5]].uTextureWidth : 24),
-                                    (papredoll_dbrds[5] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[5]].uTextureHeight : 26),
-                                    1, 0, UIMSG_74, 0, 0x49u, pGlobalTXT_LocalizationStrings[120], //Inventory
-                                    (Texture *)(papredoll_dbrds[6] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[6]] : 0),
-                                    papredoll_dbrds[5] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[5]] : 0, 0);
+                                    pIcons_LOD->GetTexture(papredoll_dbrds[5])->uTextureWidth,
+                                    pIcons_LOD->GetTexture(papredoll_dbrds[5])->uTextureHeight,
+                                    1, 0, UIMSG_74, 0, 'I', pGlobalTXT_LocalizationStrings[120], //Inventory
+                                    pIcons_LOD->GetTexture(papredoll_dbrds[6]),
+                                    pIcons_LOD->GetTexture(papredoll_dbrds[5]), 0);
   pCharacterScreen_AwardsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 282, pViewport->uViewportTL_Y + 308,
-                                 (papredoll_dbrds[3] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[3]].uTextureWidth : 24),
-                                 (papredoll_dbrds[3] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[3]].uTextureHeight : 26),
-                                 1, 0, UIMSG_75, 0, 0x41u, pGlobalTXT_LocalizationStrings[22], //Awards
-                                 (Texture *)(papredoll_dbrds[4] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[4]] : 0),
-                                 papredoll_dbrds[3] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[3]] : 0, 0);
+                                 pIcons_LOD->GetTexture(papredoll_dbrds[3])->uTextureWidth,
+                                 pIcons_LOD->GetTexture(papredoll_dbrds[3])->uTextureHeight,
+                                 1, 0, UIMSG_75, 0, 'A', pGlobalTXT_LocalizationStrings[22], //Awards
+                                 pIcons_LOD->GetTexture(papredoll_dbrds[4]),
+                                 pIcons_LOD->GetTexture(papredoll_dbrds[3]), 0);
   pCharacterScreen_ExitBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 371, pViewport->uViewportTL_Y + 308,
-                 (papredoll_dbrds[1] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[1]].uTextureWidth : 24),
-                 (papredoll_dbrds[1] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[1]].uTextureHeight : 26),
+                 pIcons_LOD->GetTexture(papredoll_dbrds[1])->uTextureWidth,
+                 pIcons_LOD->GetTexture(papredoll_dbrds[1])->uTextureHeight,
                  1, 0, UIMSG_A8, 0, 0, pGlobalTXT_LocalizationStrings[79],//Exit
-                 (Texture *)(papredoll_dbrds[2] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[2]] : 0),
-                 papredoll_dbrds[1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[1]] : 0, 0);
+                 pIcons_LOD->GetTexture(papredoll_dbrds[2]),
+                 pIcons_LOD->GetTexture(papredoll_dbrds[1]), 0);
   pWindow->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, UIMSG_InventoryLeftClick, 0, 0, "", 0);
   pCharacterScreen_DetalizBtn = pWindow->CreateButton(0x258u, 0x12Cu, 0x1Eu, 0x1Eu, 1, 0, UIMSG_ChangeDetaliz, 0, 0, pGlobalTXT_LocalizationStrings[64], 0);
   pCharacterScreen_DollBtn = pWindow->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, UIMSG_ClickPaperdoll, 0, 0, "", 0);
-  pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0);
-  pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, 0x32u, "", 0);
-  pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, 0x33u, "", 0);
-  pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, 0x34u, "", 0);
-  pWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, 9u, "", 0);
+  pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0);
+  pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0);
+  pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0);
+  pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0);
+  pWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, '\t', "", 0);
   FillAwardsData();
   return pWindow;
 }
@@ -1418,8 +1404,7 @@
                             if ( pParty->uFlags & 0x20 )
                                 v16 = dword_5079C8;
                             }
-                        pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[PID_ID(pElem->uPackedID)] - 4,
-                            0x181u, (Texture *)(v16 != -1 ? &pIcons_LOD->pTextures[v16] : 0));
+                        pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[PID_ID(pElem->uPackedID)] - 4, 0x181u, pIcons_LOD->GetTexture(v16));
                         }
                     }
                 }
@@ -1442,8 +1427,7 @@
                     if ( pParty->uFlags & 0x20 )
                         v19 = dword_5079C8;
                     }
-                pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] - 4,
-                    0x181u, (Texture *)(v19 != -1 ? &pIcons_LOD->pTextures[v19] : 0));
+                pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] - 4, 0x181u, pIcons_LOD->GetTexture(v19));
                 }
             }
         }
@@ -1524,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))
@@ -1706,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;
@@ -1766,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 )
     {
@@ -1828,7 +1812,7 @@
   }
 
 
-  flagsd = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255);
+  flagsd = TargetColor(255, 255, 255);
   uZg = 0;
   if ( (signed int)uNumLevelDecorations > 0 )
   {
@@ -1868,11 +1852,11 @@
     }
     while ( uZg < (signed int)uNumLevelDecorations );
   }
-  pRenderer->DrawTextureTransparent(0x1D4u, 0, (Texture *)(dword_5079D8 != -1 ? &pIcons_LOD->pTextures[dword_5079D8] : 0));
+  pRenderer->DrawTextureTransparent(0x1D4u, 0, pIcons_LOD->GetTexture(dword_5079D8));
   uZooma = (double)pParty->sRotationY * 0.1171875;
   //v50 = uZooma + 6.7553994e15;
   pRenderer->SetTextureClipRect(541, 0, 567, 480);
-  pRenderer->DrawTextureIndexed(floorf(uZooma + 0.5f) + 285, 136, (Texture *)(dword_5079B4 != -1 ? &pIcons_LOD->pTextures[dword_5079B4] : 0));
+  pRenderer->DrawTextureIndexed(floorf(uZooma + 0.5f) + 285, 136, pIcons_LOD->GetTexture(dword_5079B4));
   pRenderer->ResetTextureClipRect();
 }
 
@@ -1962,14 +1946,14 @@
       {
         sprintf(pContainer, "NPC%03d", pNPCStats->pNPCData[(unsigned __int8)v7 + 499].uPortraitID);
         v15 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-        pRenderer->DrawTextureIndexed(pHiredNPCsIconsOffsetsX[v23], pHiredNPCsIconsOffsetsY[v23], (Texture *)(v15 != -1 ? &pIcons_LOD->pTextures[v15] : 0));
+        pRenderer->DrawTextureIndexed(pHiredNPCsIconsOffsetsX[v23], pHiredNPCsIconsOffsetsY[v23], pIcons_LOD->GetTexture(v15));
       }
       else
       {
         sprintf(pContainer, "NPC%03d", pParty->pHirelings[(unsigned __int8)v7].uPortraitID);
         v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
         v9 = v23;
-        pRenderer->DrawTextureIndexed(pHiredNPCsIconsOffsetsX[v9], pHiredNPCsIconsOffsetsY[v9], (Texture *)(v8 != -1 ? &pIcons_LOD->pTextures[v8] : 0));
+        pRenderer->DrawTextureIndexed(pHiredNPCsIconsOffsetsX[v9], pHiredNPCsIconsOffsetsY[v9], pIcons_LOD->GetTexture(v8));
         v10 = (unsigned __int8)pTmpBuf[i];
         if ( pParty->pHirelings[v10].evt_A == 1 )
         {
--- a/Viewport.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/Viewport.cpp	Thu May 02 11:03:26 2013 +0600
@@ -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	Thu May 02 11:02:48 2013 +0600
+++ b/mm7_1.cpp	Thu May 02 11:03:26 2013 +0600
@@ -39,16 +39,13 @@
 #include "Awards.h"
 #include "Autonotes.h"
 #include "stru160.h"
-#include "stru279.h"
 #include "TurnEngine.h"
-#include "stru277.h"
+#include "CastSpellInfo.h"
 #include "Weather.h"
-#include "stru272.h"
 #include "stru298.h"
 #include "StorylineTextTable.h"
 #include "Events2D.h"
 #include "texts.h"
-#include "stru351.h"
 #include "UIHouses.h"
 #include "mm7_data.h"
 
@@ -449,7 +446,7 @@
     pTexture_RestUI_CurrentHourglassFrame->Release();
   pIcons_LOD->_40F9C5();
   sprintf(pTmpBuf, "TERRA%03d", pParty->uCurrentMinute / 6 + 10 * pParty->uCurrentHour);
-  pTexture_RestUI_CurrentSkyFrame = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE)];
+  pTexture_RestUI_CurrentSkyFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf, TEXTURE_16BIT_PALETTE);
 }
 
 //----- (0041F5BE) --------------------------------------------------------
@@ -682,7 +679,7 @@
 }
 
 //----- (004219BE) --------------------------------------------------------
-GUIWindow *stru277::sub_4219BE()
+GUIWindow *CastSpellInfo::sub_4219BE()
 {
   int v1; // esi@1
   GUIWindow *v2; // ebx@1
@@ -697,15 +694,14 @@
   v2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell_InInventory, v1, 0);
   pCharacterScreen_ExitBtn = v2->CreateButton(394, 318, 75, 33, 1, 0, UIMSG_A8, 0, 0,
                  pGlobalTXT_LocalizationStrings[79], // Close
-                 (Texture *)(papredoll_dbrds[2] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[2]] : 0),
-                 papredoll_dbrds[1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[1]] : 0,
-                 0);
+                 pIcons_LOD->GetTexture(papredoll_dbrds[2]),
+                 pIcons_LOD->GetTexture(papredoll_dbrds[1]), 0);
   v2->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, UIMSG_InventoryLeftClick, 0, 0, "", 0);
   pCharacterScreen_DollBtn = v2->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, UIMSG_ClickPaperdoll, 0, 0, "", 0);
-  v2->CreateButton(61u, 424u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0);
-  v2->CreateButton(177u, 424u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, 0x32u, "", 0);
-  v2->CreateButton(292u, 424u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, 0x33u, "", 0);
-  v2->CreateButton(407u, 424u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, 0x34u, "", 0);
+  v2->CreateButton( 61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0);
+  v2->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0);
+  v2->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0);
+  v2->CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0);
   return v2;
 }
 
@@ -730,7 +726,7 @@
   v0 = pIcons_LOD->LoadTexture(
          pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName,
          TEXTURE_16BIT_PALETTE);
-  v1 = (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0);
+  v1 = pIcons_LOD->GetTexture(v0);
   v11 = areWeLoadingTexture;
   if ( uActiveCharacter
     && (v2 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID)) != 0 )
@@ -1414,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;
@@ -1507,10 +1503,10 @@
         uTextureID_5076A0 = pIcons_LOD->LoadTexture("edge_lf", TEXTURE_16BIT_PALETTE);
         uTextureID_50769C = pIcons_LOD->LoadTexture("edge_rt", TEXTURE_16BIT_PALETTE);
         uTextureID_507698 = pIcons_LOD->LoadTexture("edge_top", TEXTURE_16BIT_PALETTE);
-        pTexture_591428 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("endcap", TEXTURE_16BIT_PALETTE)];
+        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;
@@ -1561,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;
@@ -1569,7 +1565,7 @@
   else assert(false);
 
   uGameUIFontMain = v3;
-  uGameUIFontShadow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v5, v4, v6);
+  uGameUIFontShadow = TargetColor(v5, v4, v6);
 }
 
 //----- (00423AEE) --------------------------------------------------------
--- a/mm7_2.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/mm7_2.cpp	Thu May 02 11:03:26 2013 +0600
@@ -27,7 +27,6 @@
 #include "DecorationList.h"
 #include "SaveLoad.h"
 #include "stru123.h"
-#include "stru287.h"
 #include "stru176.h"
 #include "Time.h"
 #include "IconFrameTable.h"
@@ -38,15 +37,13 @@
 #include "Awards.h"
 #include "Autonotes.h"
 #include "stru160.h"
-#include "stru279.h"
 #include "TurnEngine.h"
 #include "FactionTable.h"
 #include "StorylineTextTable.h"
 #include "Random.h"
-#include "stru277.h"
+#include "CastSpellInfo.h"
 #include "stru298.h"
 #include "stru12.h"
-#include "stru351.h"
 #include "Events2D.h"
 #include "stru159.h"
 #include "Log.h"
@@ -293,7 +290,7 @@
   pDialogueWindow->Release();
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, 0, 0);
   pBtn_ExitCancel = pDialogueWindow->CreateButton(471u, 445u, 169u, 35u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],// "Cancel"
-                 (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0);
+                 pIcons_LOD->GetTexture(uExitCancelTextureId), 0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
   pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, UIMSG_0, 0x53u, 0, "", 0);
   pDialogueWindow->_41D08F(1, 1, 0, 2);
@@ -436,7 +433,7 @@
     pDialogueWindow->pControlsTail = 0;
     pDialogueWindow->uNumControls = 0;
     pBtn_ExitCancel = pDialogueWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79],
-                   (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0);
+                   pIcons_LOD->GetTexture(uExitCancelTextureId), 0);
     pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 0x55u, 0, "", 0);
     pDialogueWindow->CreateButton(0x1E0u, 0xBEu, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 0x56u, 0, "", 0);
     pDialogueWindow->CreateButton(0x1E0u, 0xDCu, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 0x57u, 0, "", 0);
@@ -581,12 +578,8 @@
       pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1,
       pRenderer->uTargetGMask | pRenderer->uTargetBMask);
 
-  auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : nullptr);
-  pRenderer->_4A6A68(
-    8u,
-    352 - v0,
-    pTex,
-    (pTex ? pTex->uTextureHeight : 26) - v0);
+  auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather);
+  pRenderer->_4A6A68(8, 352 - v0, pTex, pTex->uTextureHeight - v0);
 
   pRenderer->DrawTextureIndexed(8u, 347 - v0, pTexture_591428);
   v1 = FitTextInAWindow(pGlobalTXT_LocalizationStrings[575], pFontArrus, &window, 0xDu, 0);
@@ -773,7 +766,7 @@
     item_spellbook->Reset();
     pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].uItemID = pItemNum;
     pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].Identified();
-    ItemsInShopTexture[i] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pItemsTable->pItems[pItemNum].pIconName, TEXTURE_16BIT_PALETTE)];
+    ItemsInShopTexture[i] = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[pItemNum].pIconName, TEXTURE_16BIT_PALETTE);
   }
   return;
 }
@@ -5532,7 +5525,7 @@
               v4 = 255;
               v1 = 15;
               v2 = 235;
-              return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
+              return TargetColor(v2, v1, v4);
             }
             goto LABEL_21;
           }
@@ -5552,7 +5545,7 @@
           v4 = v2;
 LABEL_30:
           v1 = v2;
-          return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
+          return TargetColor(v2, v1, v4);
         }
         goto LABEL_15;
       }
@@ -5563,7 +5556,7 @@
         v1 = 128;
 LABEL_32:
         v2 = 0;
-        return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
+        return TargetColor(v2, v1, v4);
       }
       goto LABEL_11;
     }
@@ -5576,7 +5569,7 @@
       v1 = 85;
 LABEL_23:
       v2 = 255;
-      return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
+      return TargetColor(v2, v1, v4);
     }
   }
   if ( a1 >= 23 )
@@ -5584,7 +5577,7 @@
   v4 = 255;
   v1 = 212;
   v2 = 150;
-  return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
+  return TargetColor(v2, v1, v4);
 }
 
 //----- (004583B0) --------------------------------------------------------
@@ -6653,17 +6646,15 @@
 
   pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
   auto pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE);
-  pMainMenu_BtnNew = pWindow_MainMenu->CreateButton(495, 172, pNew->uTextureWidth, pNew->uTextureHeight, 1, 0, 
-                                                    UIMSG_MainMenu_ShowPartyCreationWnd, 0, 78, "", pNew, 0);
   auto pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE);
-  pMainMenu_BtnLoad = pWindow_MainMenu->CreateButton(495, 227, pLoad->uTextureWidth, pLoad->uTextureHeight, 1, 0, 
-                                                     UIMSG_MainMenu_ShowLoadWindow, 1, 76, "", pLoad, 0);
   auto pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE);
-  pMainMenu_BtnCredits = pWindow_MainMenu->CreateButton(495, 282, pCredits->uTextureWidth, pCredits->uTextureHeight, 1, 0, 
-                                                         UIMSG_ShowCredits, 2, 67, "", pCredits, 0);
   auto pExit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE);
-  pMainMenu_BtnExit = pWindow_MainMenu->CreateButton(495, 337, pExit->uTextureWidth, pExit->uTextureHeight, 1, 0, 
-                                                        UIMSG_ExitToWindows, 3, 0, "", pExit, 0);
+
+  pMainMenu_BtnNew     = pWindow_MainMenu->CreateButton(495, 172, pNew->uTextureWidth,     pNew->uTextureHeight,     1, 0, UIMSG_MainMenu_ShowPartyCreationWnd, 0, 'N', "", pNew, 0);
+  pMainMenu_BtnLoad    = pWindow_MainMenu->CreateButton(495, 227, pLoad->uTextureWidth,    pLoad->uTextureHeight,    1, 0, UIMSG_MainMenu_ShowLoadWindow,       1, 'L', "", pLoad, 0);
+  pMainMenu_BtnCredits = pWindow_MainMenu->CreateButton(495, 282, pCredits->uTextureWidth, pCredits->uTextureHeight, 1, 0, UIMSG_ShowCredits,                   2, 'C', "", pCredits, 0);
+  pMainMenu_BtnExit    = pWindow_MainMenu->CreateButton(495, 337, pExit->uTextureWidth,    pExit->uTextureHeight,    1, 0, UIMSG_ExitToWindows,                 3, 0, "", pExit, 0);
+
   pTexture_PCX.Release();
   pTexture_PCX.Load("title.pcx", 0);
   SetCurrentMenuID(MENU_MAIN);
@@ -6825,8 +6816,79 @@
         GUI_HandleHotkey(wParam);
     }
     return DefWindowProcA(hWnd, Msg, wParam, lParam);
+
+    case WM_COMMAND:
+    {
+      switch (wParam)
+      {
+        case 103:  pRenderer->SavePCXScreenshot();  return 0;
+
+        case 101:  // Quit game
+        case 40001:
+        {
+          v38 = 0;
+          v37 = 0;
+          v36 = 2;
+          v35 = ::hWnd;
+          SendMessageA(::hWnd, WM_DESTROY, v37, v38);
+        }
+        return 0;
+
+
+        case 104:
+          pRenderer->ChangeBetweenWinFullscreenModes();
+          if ( pArcomageGame->bGameInProgress )
+            pArcomageGame->field_F6 = 1;
+        return 0;
+
+        //SubMenu "Party"
+        case 40007:  pParty->SetGold(pParty->uNumGold + 10000); return 0;
+        case 40008:  GivePartyExp(20000);  return 0;
+        case 40013:  pParty->SetGold(0);   return 0;
+
+        case 40059:
+          for (uint i = 0; i < 4; ++i)
+            pParty->pPlayers[i].uSkillPoints = 50;
+        return 0;
+        
+        case 40029:  pPlayers[uActiveCharacter]->SetPertified(true);  return 0;
+        case 40030:  pPlayers[uActiveCharacter]->SetWeak(true);       return 0;
+        case 40031:  pPlayers[uActiveCharacter]->SetPoison3(true);    return 0;
+        case 40032:  pPlayers[uActiveCharacter]->SetPoison2(true);    return 0;
+        case 40033:  pPlayers[uActiveCharacter]->SetPoison1(true);    return 0;
+        case 40034:  pPlayers[uActiveCharacter]->SetDisease3(true);   return 0;
+        case 40035:  pPlayers[uActiveCharacter]->SetDisease2(true);   return 0;
+        case 40036:  pPlayers[uActiveCharacter]->SetDisease1(true);   return 0;
+        case 40037:  pPlayers[uActiveCharacter]->SetCursed(true);     return 0;
+        case 40038:  pPlayers[uActiveCharacter]->SetInsane(true);     return 0;
+        case 40039:  pPlayers[uActiveCharacter]->SetDrunk(true);      return 0;
+        case 40040:  pPlayers[uActiveCharacter]->SetUnconcious(true); return 0;
+        case 40041:  pPlayers[uActiveCharacter]->SetDead(true);       return 0;
+        case 40042:  pPlayers[uActiveCharacter]->SetEradicated(true); return 0;
+        case 40043:  pPlayers[uActiveCharacter]->SetAsleep(true);     return 0;
+        case 40044:  pPlayers[uActiveCharacter]->SetAfraid(true);     return 0;
+        case 40045:  pPlayers[uActiveCharacter]->SetParalyzed(true);  return 0;
+        case 40073:  pPlayers[uActiveCharacter]->SetZombie(true);     return 0;
+
+        case 40006:  pParty->SetFood(pParty->uNumFoodRations + 20);   return 0;
+
+        case 40062:  pParty->alignment = PartyAlignment_Good;   return 0;
+        case 40063:  pParty->alignment = PartyAlignment_Neutral;   return 0;
+        case 40064:  pParty->alignment = PartyAlignment_Evil;   return 0;
+
+        //SubMenu "Time"
+        case 40009:  pParty->uTimePlayed += (signed __int64)((double)(7680 * (24 * 60)) * 0.033333335);   return 0;
+        case 40010:  pParty->uTimePlayed += (signed __int64)((double)(7680 * (7 * (24 * 60))) * 0.033333335);   return 0;
+        case 40011:  pParty->uTimePlayed += (signed __int64)((double)(7680 * (28 * (24 * 60))) * 0.033333335);   return 0;
+        case 40012:  pParty->uTimePlayed += (signed __int64)((double)(7680 * (12 * (28 * (24 * 60)))) * 0.033333335);   return 0;// this incorrect
+
+        //SubMenu "Items"
+        case 40015:  /* generate item level 1*/;   return 0;
+
+      }
+    }
+    return DefWindowProcA(hWnd, Msg, wParam, lParam);
   };
-  
 
   if ( Msg > WM_SYSCOMMAND )
   {
@@ -7067,33 +7129,7 @@
         //goto _def_wnd_proc;
         return DefWindowProcA(hWnd, Msg, wParam, lParam);
       }
-      if ( Msg != WM_COMMAND )
-        //goto _def_wnd_proc;
         return DefWindowProcA(hWnd, Msg, wParam, lParam);
-      if ( wParam != 101 )
-      {
-        if ( wParam == 103 )
-        {
-          pRenderer->SavePCXScreenshot();
-          return 0;
-        }
-        if ( wParam == 104 )
-        {
-          pRenderer->ChangeBetweenWinFullscreenModes();
-          if ( pArcomageGame->bGameInProgress )
-            pArcomageGame->field_F6 = 1;
-          return 0;
-        }
-        if ( wParam != 40001 )
-          return DefWindowProcA(hWnd, Msg, wParam, lParam);
-      }
-      v38 = 0;
-      v37 = 0;
-      v36 = 2;
-      v35 = ::hWnd;
-//LABEL_104:
-      SendMessageA(::hWnd, WM_DESTROY, v37, v38);
-      return 0;
     }
     if ( dword_506E68 != -1 )
     {
@@ -7984,7 +8020,7 @@
   pEventTimer->Pause();
   pMiscTimer->Pause();
   pParty->uFlags = 2;
-  pStru277->_427D48(1);
+  pCastSpellInfo->_427D48(1);
   ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows();
   DoPrepareWorld(0, (v1 == 0) + 1);
   pMiscTimer->Resume();
@@ -9206,7 +9242,7 @@
   assert(sizeof(GUIFont) == 0x1020);
   assert(sizeof(stru262_TurnBased) == 0x40);
   assert(sizeof(ArcomageGame) == 0xFB);
-  assert(sizeof(stru277) == 0x14);
+  assert(sizeof(CastSpellInfo) == 0x14);
   assert(sizeof(ArcomageCard) == 0x6C);
   assert(sizeof(stru320) == 0x3FC);
   assert(sizeof(TravelInfo) == 0x20);
@@ -9280,7 +9316,6 @@
     if (wcsstr(pCmdLine, L"-new_sky"))
       new_sky = true;
   }
-  stru_51076C.registry_debug_flags = ReadWindowsRegistryInt("debug flags", 0);
 
 
   /*v8 = _4AC1C9_get_cpu_speed(0, (Vec4_int_ *)a2);
@@ -9857,7 +9892,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	Thu May 02 11:02:48 2013 +0600
+++ b/mm7_3.cpp	Thu May 02 11:03:26 2013 +0600
@@ -26,14 +26,12 @@
 #include "DecorationList.h"
 #include "SaveLoad.h"
 #include "stru123.h"
-#include "stru287.h"
 #include "Time.h"
 #include "IconFrameTable.h"
 #include "TurnEngine.h"
 #include "Awards.h"
 #include "Autonotes.h"
 #include "stru160.h"
-#include "stru279.h"
 #include "Weather.h"
 #include "stru220.h"
 #include "Events2D.h"
@@ -4550,9 +4548,9 @@
         v48 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed);
         v9 = v48;
       }
-      pFaceTexture = (Texture *)(v9 != -1 ? (int)&pBitmaps_LOD->pTextures[v9] : 0);
+      pFaceTexture = pBitmaps_LOD->GetTexture(v9);
       v7->pTexture = pFaceTexture;
-      v12 = (v9 != -1 ? pBitmaps_LOD->pTextures[v9].uTextureWidth : 24);
+      v12 = pFaceTexture->uTextureWidth;
       v49 = v12;
       v49 = pFaceTexture->uTextureHeight;
       v10 = (pFace->uAttributes & 0x10) == 0;
@@ -11522,34 +11520,36 @@
   v10.uViewportZ = 639;
   v10.uViewportW = 479;
   v12 = 0;
-  v3 = (char *)&pOtherOverlayList->pOverlays[0].field_C;
-  do
-  {
-    if ( *((short *)v3 - 3) > 0 )
-    {
-      result = *((short *)v3 - 6);
-      if ( result >= 300 )
-      {
-        v4 = result;
-        v5 = result == v2 + 320 | result == v2 + 330 | result == v2 + 340 | result == v2 + 350;
-        result = v2 + 310;
-        if ( v4 == v2 + 310 | v5 )
-        {
-          if ( !*(short *)v3 )
-          {
-            v6 = pSpriteFrameTable->GetFrame(
-                   pOverlayList->pOverlays[*((short *)v3 - 5)].uSpriteFramesetID,
-                   *((short *)v3 - 4));
+  //v3 = (char *)&pOtherOverlayList->pOverlays[0].field_C;
+  //do
+  for ( uint i = 0; i < 50; ++i )
+  {
+    if ( pOtherOverlayList->pOverlays[i].field_6 > 0 )
+    {
+      result = pOtherOverlayList->pOverlays[i].field_0;
+      if ( pOtherOverlayList->pOverlays[i].field_0 >= 300 )
+      {
+        //v4 = result;
+        v5 = pOtherOverlayList->pOverlays[i].field_0 == v2 + 320 
+           | pOtherOverlayList->pOverlays[i].field_0 == v2 + 330 | pOtherOverlayList->pOverlays[i].field_0 == v2 + 340 
+           | pOtherOverlayList->pOverlays[i].field_0 == v2 + 350;
+        pOtherOverlayList->pOverlays[i].field_0 = v2 + 310;
+        if ( pOtherOverlayList->pOverlays[i].field_0 == v2 + 310 | v5 )
+        {
+          if ( !pOtherOverlayList->pOverlays[i].field_0 )
+          {
+            v6 = pSpriteFrameTable->GetFrame(pOverlayList->pOverlays[pOtherOverlayList->pOverlays[i].field_2].uSpriteFramesetID,
+                   pOtherOverlayList->pOverlays[i].field_4);
             v7 = v6;
-            v11 = *((int *)v3 + 1);
+            v11 = pOtherOverlayList->pOverlays[i].field_E;
             v13 = v6->scale;
             v13 = (unsigned __int64)(v11 * (signed __int64)v13) >> 16;
-            v10.uScreenSpaceX = *((short *)v3 - 2);
-            v10.uScreenSpaceY = *((short *)v3 - 1);
+            v10.uScreenSpaceX = pOtherOverlayList->pOverlays[i].field_8;
+            v10.uScreenSpaceY = pOtherOverlayList->pOverlays[i].field_A;
             v10._screenspace_x_scaler_packedfloat = v13;
             v10._screenspace_y_scaler_packedfloat = v13;
             v10.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v6->uPaletteIndex, 0, 1);
-            v8 = *((short *)v3 - 5);
+            v8 = pOtherOverlayList->pOverlays[i].field_2;
             v10.sZValue = 0;
             v10.uFlags = 0;
             v9 = pOverlayList->pOverlays[v8].uOverlayType;
@@ -11563,9 +11563,9 @@
         }
       }
     }
-    v3 += 20;
-  }
-  while ( (signed int)v3 < (signed int)&pOverlayList->pOverlays );
+    //v3 += 20;
+  }
+  //while ( (signed int)v3 < (signed int)&pOverlayList->pOverlays );
   return result;
 }
 
@@ -12316,8 +12316,8 @@
     default: assert(false);
   }
 
-  pTexture_Dialogue_Background = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)];
-  pTexture_outside = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("outside", TEXTURE_16BIT_PALETTE)];
+  pTexture_Dialogue_Background = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
+  pTexture_outside = pIcons_LOD->LoadTexturePtr("outside", TEXTURE_16BIT_PALETTE);
   v1 = pMapStats->GetMapInfo(pCurrentMapName);
   if ( v1 )
     sprintfex(sHouseName, pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v1].pName);// "Leave %s"
@@ -12482,11 +12482,11 @@
     dword_5C3418 = v4;
     dword_5C341C = v3;
     _591094_decoration = activeLevelDecoration;
-    pGUIWindow2 = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_GreetingNPC, a4, 0);
-    pGUIWindow2->CreateButton(61u, 424u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0);
-    pGUIWindow2->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 2u, 0x32u, "", 0);
-    pGUIWindow2->CreateButton(292u, 424u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 3u, 0x33u, "", 0);
-    pGUIWindow2->CreateButton(407u, 424u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 4u, 0x34u, "", 0);
+    pGUIWindow2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_GreetingNPC, a4, 0);
+    pGUIWindow2->CreateButton( 61, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0);
+    pGUIWindow2->CreateButton(177, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0);
+    pGUIWindow2->CreateButton(292, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0);
+    pGUIWindow2->CreateButton(407, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0);
   }
 }
 
@@ -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;
@@ -13716,7 +13716,7 @@
   SpriteObject a1; // [sp+38h] [bp-7Ch]@12
   //SpriteObject::SpriteObject(&a1);
 
-  a1.uType = stru_4E3ACC[spellnum].field_0;
+  a1.uType = stru_4E3ACC[spellnum].uType;
   if ( spellnum > 58 )
   {
     if ( spellnum == 69 )
--- a/mm7_4.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/mm7_4.cpp	Thu May 02 11:03:26 2013 +0600
@@ -28,7 +28,6 @@
 #include "DecorationList.h"
 #include "SaveLoad.h"
 #include "stru123.h"
-#include "stru287.h"
 #include "Time.h"
 #include "IconFrameTable.h"
 #include "GUIProgressBar.h"
@@ -38,15 +37,13 @@
 #include "Awards.h"
 #include "Autonotes.h"
 #include "stru160.h"
-#include "stru279.h"
 #include "TurnEngine.h"
 #include "FactionTable.h"
 #include "StorylineTextTable.h"
 #include "Random.h"
-#include "stru277.h"
+#include "CastSpellInfo.h"
 #include "stru298.h"
 #include "stru12.h"
-#include "stru351.h"
 #include "Events2D.h"
 #include "stru159.h"
 #include "texts.h"
@@ -2103,7 +2100,7 @@
       else
       {
         v11 = &pObjectList->pObjects->uObjectID;
-        while ( stru_4E3ACC[8].field_0 != *v11 )
+        while ( stru_4E3ACC[8].uType != *v11 )
         {
           ++v10;
           v11 += 28;
@@ -3488,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));
 
@@ -6221,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;
@@ -6256,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;
@@ -7334,8 +7331,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]);
@@ -7414,9 +7411,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;
@@ -7499,8 +7496,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
@@ -7850,10 +7847,9 @@
   ContractSelectText(pEventCode);
   pDialogueWindow->Release();
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15E, WINDOW_MainMenu, pEventCode, 0);
-  pBtn_ExitCancel = pDialogueWindow->CreateButton(0x1D7, 0x1BD, 0xA9, 0x23, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34], // Cancel
-                 pIcons_LOD->GetTexture(uExitCancelTextureId), 0);
-  pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
-  pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x52u, 0, pGlobalTXT_LocalizationStrings[122], 0);
+  pBtn_ExitCancel = pDialogueWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape,                    0, 0, pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uExitCancelTextureId), 0); // Cancel
+                    pDialogueWindow->CreateButton(  0,   0,   0,  0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
+                    pDialogueWindow->CreateButton(480, 160, 140, 30, 1, 0, UIMSG_ClickNPCTopic,             0x52u, 0, pGlobalTXT_LocalizationStrings[122], 0);
   pDialogueWindow->_41D08F(1, 1, 0, 2);
   dialog_menu_id = HOUSE_DIALOGUE_OTHER;
 }
@@ -7873,9 +7869,7 @@
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15Eu, WINDOW_MainMenu, v1, 0);
   v2 = "";
   pBtn_ExitCancel = pDialogueWindow->CreateButton( 0x1D7u, 0x1BDu, 0xA9u,  0x23u,   1,  0, UIMSG_Escape, 0,   0,
-                 pGlobalTXT_LocalizationStrings[34],
-                 (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0),
-                 0);
+                 pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
   if ( contract_approved )
     v2 = pGlobalTXT_LocalizationStrings[535];
@@ -7898,7 +7892,7 @@
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15Eu, WINDOW_MainMenu, 0, 0);
   pBtn_ExitCancel = pDialogueWindow->CreateButton( 0x1D7u, 0x1BDu,  0xA9u,   0x23u,  1,  0,  UIMSG_Escape,  0,   0,
                  pGlobalTXT_LocalizationStrings[34], //"Cancel"
-                 (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0),
+                 pIcons_LOD->GetTexture(uExitCancelTextureId),
                  0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
   if ( pNPCStats->pProfessions[v1->uProfession].pBenefits)//*(&pNPCStats->field_13A5C + 5 * v1->uProfession) )
@@ -7934,14 +7928,10 @@
     pDialogueWindow->Release();
     pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
     sprintfex(sHouseName, pGlobalTXT_LocalizationStrings[LOCSTR_ENTER_S], pMapStats->pInfos[uHouse_ExitPic].pName);
-    pBtn_ExitCancel = pDialogueWindow->CreateButton( 566, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0x4Eu,
-                   pGlobalTXT_LocalizationStrings[34],// "Cancel"
-                   (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0),0);
-    pBtn_YES = pDialogueWindow->CreateButton( 486u, 445u,  75u, 33u, 1, 0,  UIMSG_BF,  1u,  0x59u,
-                   sHouseName,
-                   (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0), 0);
+    pBtn_ExitCancel = pDialogueWindow->CreateButton(566, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 'N', pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);// "Cancel"
+    pBtn_YES        = pDialogueWindow->CreateButton(486, 445, 75, 33, 1, 0, UIMSG_BF,     1, 'Y', sHouseName, pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0);
     pDialogueWindow->CreateButton( pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 63u, 73u, 1, 0,  UIMSG_BF, 1u, 0x20u,  sHouseName, 0);
-    pDialogueWindow->CreateButton(8u, 8u, 460u, 344u, 1, 0, UIMSG_BF, 1u, 0x59u, sHouseName, 0);
+    pDialogueWindow->CreateButton(8, 8, 460, 344, 1, 0, UIMSG_BF, 1, 0x59u, sHouseName, 0);
   }
   else
   {
@@ -7958,7 +7948,7 @@
     pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0);
     pBtn_ExitCancel = pDialogueWindow->CreateButton(  471u,  445u,  169u, 35u,  1,   0, UIMSG_Escape,  0,  0,
                    pGlobalTXT_LocalizationStrings[74],// "End Conversation"
-                   (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0),   0);
+                   pIcons_LOD->GetTexture(uExitCancelTextureId),   0);
     pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
     if ( pDialogueNPCCount == 1 && dword_591080 )
     {
@@ -8420,8 +8410,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;
@@ -9157,7 +9147,7 @@
   v12 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
   v13 = pHouse_ExitPictures[v10];
   pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v12];
-  pTexture_outside = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v13, TEXTURE_16BIT_PALETTE)];
+  pTexture_outside = pIcons_LOD->LoadTexturePtr(v13, TEXTURE_16BIT_PALETTE);
   if ( v9 )
   {
     if ( !v23 )
--- a/mm7_5.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/mm7_5.cpp	Thu May 02 11:03:26 2013 +0600
@@ -32,11 +32,9 @@
 #include "Awards.h"
 #include "Autonotes.h"
 #include "stru160.h"
-#include "stru279.h"
 #include "TurnEngine.h"
-#include "stru277.h"
+#include "CastSpellInfo.h"
 #include "Weather.h"
-#include "stru272.h"
 #include "stru298.h"
 #include "StorylineTextTable.h"
 #include "Events2D.h"
@@ -531,78 +529,76 @@
           pGUIWindow_CurrentMenu->Release();
           viewparams->field_48 = v0;
           pCurrentScreen = SCREEN_OPTIONS;
-          uTextureID_ControlBG[0] = pIcons_LOD->LoadTexture("ControlBG", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[3] = pIcons_LOD->LoadTexture("con_16x", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[2] = pIcons_LOD->LoadTexture("con_32x", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[4] = pIcons_LOD->LoadTexture("con_ArrL", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[5] = pIcons_LOD->LoadTexture("con_ArrR", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[1] = pIcons_LOD->LoadTexture("con_Smoo", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[19] = pIcons_LOD->LoadTexture("convol00", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[10] = pIcons_LOD->LoadTexture("convol10", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[11] = pIcons_LOD->LoadTexture("convol20", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[12] = pIcons_LOD->LoadTexture("convol30", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[13] = pIcons_LOD->LoadTexture("convol40", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[14] = pIcons_LOD->LoadTexture("convol50", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[15] = pIcons_LOD->LoadTexture("convol60", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[16] = pIcons_LOD->LoadTexture("convol70", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[17] = pIcons_LOD->LoadTexture("convol80", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[18] = pIcons_LOD->LoadTexture("convol90", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[9] = pIcons_LOD->LoadTexture("option04", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[20] = pIcons_LOD->LoadTexture("option03", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[22] = pIcons_LOD->LoadTexture("option02", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[21] = pIcons_LOD->LoadTexture("option01", TEXTURE_16BIT_PALETTE);
+
+          options_menu_skin.uTextureID_Background     = pIcons_LOD->LoadTexture("ControlBG", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_TurnSpeed[2]   = pIcons_LOD->LoadTexture("con_16x", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_TurnSpeed[1]   = pIcons_LOD->LoadTexture("con_32x", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_TurnSpeed[0]   = pIcons_LOD->LoadTexture("con_Smoo", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_ArrowLeft      = pIcons_LOD->LoadTexture("con_ArrL", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_ArrowRight     = pIcons_LOD->LoadTexture("con_ArrR", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[0] = pIcons_LOD->LoadTexture("convol10", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[1] = pIcons_LOD->LoadTexture("convol20", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[2] = pIcons_LOD->LoadTexture("convol30", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[3] = pIcons_LOD->LoadTexture("convol40", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[4] = pIcons_LOD->LoadTexture("convol50", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[5] = pIcons_LOD->LoadTexture("convol60", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[6] = pIcons_LOD->LoadTexture("convol70", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[7] = pIcons_LOD->LoadTexture("convol80", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[8] = pIcons_LOD->LoadTexture("convol90", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[9] = pIcons_LOD->LoadTexture("convol00", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_FlipOnExit     = pIcons_LOD->LoadTexture("option04", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_AlwaysRun      = pIcons_LOD->LoadTexture("option03", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_ShowDamage     = pIcons_LOD->LoadTexture("option02", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_WalkSound      = pIcons_LOD->LoadTexture("option01", TEXTURE_16BIT_PALETTE);
+
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Options, 0, 0);
           pGUIWindow_CurrentMenu->CreateButton(22, 270,
-                                               pIcons_LOD->GetTexture(uTextureID_ControlBG[3])->uTextureWidth,
-                                               pIcons_LOD->GetTexture(uTextureID_ControlBG[3])->uTextureHeight,
-                                               v0, 0,
-                                               UIMSG_SetTurnSpeed, 0x80,
-                                               0, v1, 0);
-          pGUIWindow_CurrentMenu->CreateButton(0x5Du, 270,
-                                               pIcons_LOD->GetTexture(uTextureID_ControlBG[2])->uTextureWidth,
-                                               pIcons_LOD->GetTexture(uTextureID_ControlBG[2])->uTextureHeight,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[2])->uTextureWidth,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[2])->uTextureHeight,
+                                               v0, 0, UIMSG_SetTurnSpeed, 0x80, 0, v1, 0);
+          pGUIWindow_CurrentMenu->CreateButton(93, 270,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[1])->uTextureWidth,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[1])->uTextureHeight,
                                                v0, 0, UIMSG_SetTurnSpeed, 0x40u, 0, v1, 0);
-          pGUIWindow_CurrentMenu->CreateButton(0xA4u, 270,
-                                               pIcons_LOD->GetTexture(uTextureID_ControlBG[1])->uTextureWidth,
-                                               pIcons_LOD->GetTexture(uTextureID_ControlBG[1])->uTextureHeight,
+          pGUIWindow_CurrentMenu->CreateButton(164, 270,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[0])->uTextureWidth,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[0])->uTextureHeight,
                                                v0, 0, UIMSG_SetTurnSpeed, 0, 0, v1, 0);
-          pGUIWindow_CurrentMenu->CreateButton(0x14u, 0x12Fu,
-                                               pIcons_LOD->GetTexture(uTextureID_ControlBG[21])->uTextureWidth,
-                                               pIcons_LOD->GetTexture(uTextureID_ControlBG[21])->uTextureHeight,
+
+          pGUIWindow_CurrentMenu->CreateButton(20, 303,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_WalkSound)->uTextureWidth,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_WalkSound)->uTextureHeight,
                                                v0, 0, UIMSG_ToggleWalkSound, 0, 0, v1, 0);
-          pGUIWindow_CurrentMenu->CreateButton(0x80u, 0x12Fu,
-            (uTextureID_ControlBG[22] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[22]].uTextureWidth : 24),
-            (uTextureID_ControlBG[22] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[22]].uTextureHeight : 26),
-            v0, 0, UIMSG_ToggleShowDamage, 0, 0, v1, 0);
-          pGUIWindow_CurrentMenu->CreateButton(0x14u, 0x145u,
-            (uTextureID_ControlBG[20] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[20]].uTextureWidth : 24),
-            (uTextureID_ControlBG[20] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[20]].uTextureHeight : 26),
-            v0, 0, UIMSG_ToggleAlwaysRun, 0, 0, v1, 0);
-          pGUIWindow_CurrentMenu->CreateButton(0x80u, 0x145u,
-            (uTextureID_ControlBG[9] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[9]].uTextureWidth : 24),
-            (uTextureID_ControlBG[9] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[9]].uTextureHeight : 26),
-            v0, 0, UIMSG_ToggleFlipOnExit, 0, 0, v1, 0);
-          pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(243, 162, 16, 16, v0, 0, UIMSG_ChangeSoundVolume, 4, 0, v1,
-                         &pIcons_LOD->pTextures[uTextureID_ControlBG[4]], 0);
-          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0x1B3u, 0xA2u, 0x10u, 0x10u, v0, 0, UIMSG_ChangeSoundVolume, 5, 0, v1,
-                         &pIcons_LOD->pTextures[uTextureID_ControlBG[5]], 0);
-          pGUIWindow_CurrentMenu->CreateButton(0x107u, 0xA2u, 0xACu, 0x11u, v0, 0, UIMSG_ChangeSoundVolume, 0, 0, v1, 0);
-          pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(0xF3u, 0xD8u, 0x10u, 0x10u, v0, 0, UIMSG_ChangeMusicVolume, 4, 0, v1,
-                         &pIcons_LOD->pTextures[uTextureID_ControlBG[4]], 0);
-          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0x1B3u, 0xD8u, 0x10u, 0x10u, v0, 0, UIMSG_ChangeMusicVolume, 5, 0, v1,
-                         &pIcons_LOD->pTextures[uTextureID_ControlBG[5]], 0);
-          pGUIWindow_CurrentMenu->CreateButton(0x107u, 0xD8u, 0xACu, 0x11u, v0, 0, UIMSG_ChangeMusicVolume, 0, 0, v1, 0);
-          pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(0xF3u, 0x10Eu, 0x10u, 0x10u, v0, 0, UIMSG_ChangeVoiceVolume, 4, 0, v1,
-                         &pIcons_LOD->pTextures[uTextureID_ControlBG[4]], 0);
-          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0x1B3u, 0x10Eu, 0x10u, 0x10u, v0, 0, UIMSG_ChangeVoiceVolume, 5u, 0, v1,
-                         &pIcons_LOD->pTextures[uTextureID_ControlBG[5]], 0);
-          pGUIWindow_CurrentMenu->CreateButton(0x107u, 0x10Eu, 0xACu, 0x11u, v0, 0, UIMSG_ChangeVoiceVolume, 0, 0, v1, 0);
-          pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, v0, 0, UIMSG_Escape, 0, 0,
-            pGlobalTXT_LocalizationStrings[619],// "Return to Game"
-            0);
-          pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x8Cu, 0xD6u, 0x28u, v0, 0, UIMSG_OpenKeyMappingOptions, 0, 0x4Bu, v1, 0);
-          pGUIWindow_CurrentMenu->CreateButton(19, 194, 214, 40, v0, 0, UIMSG_OpenVideoOptions, 0, 86, v1, 0);
-          continue;
+          pGUIWindow_CurrentMenu->CreateButton(128, 303,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ShowDamage)->uTextureWidth,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ShowDamage)->uTextureHeight,
+                                               v0, 0, UIMSG_ToggleShowDamage, 0, 0, v1, 0);
+          pGUIWindow_CurrentMenu->CreateButton(20, 325,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_AlwaysRun)->uTextureWidth,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_AlwaysRun)->uTextureHeight,
+                                               v0, 0, UIMSG_ToggleAlwaysRun, 0, 0, v1, 0);
+          pGUIWindow_CurrentMenu->CreateButton(128, 325,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_FlipOnExit)->uTextureWidth,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_FlipOnExit)->uTextureHeight,
+                                               v0, 0, UIMSG_ToggleFlipOnExit, 0, 0, v1, 0);
+
+          pBtn_SliderLeft  = pGUIWindow_CurrentMenu->CreateButton(243, 162, 16, 16, v0, 0, UIMSG_ChangeSoundVolume, 4, 0, v1, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowLeft), 0);
+          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(435, 162, 16, 16, v0, 0, UIMSG_ChangeSoundVolume, 5, 0, v1, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowRight), 0);
+          pGUIWindow_CurrentMenu->CreateButton(263, 162, 172, 17, v0, 0, UIMSG_ChangeSoundVolume, 0, 0, v1, 0);
+
+          pBtn_SliderLeft  = pGUIWindow_CurrentMenu->CreateButton(243, 216, 16, 16, v0, 0, UIMSG_ChangeMusicVolume, 4, 0, v1, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowLeft), 0);
+          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(435, 216, 16, 16, v0, 0, UIMSG_ChangeMusicVolume, 5, 0, v1, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowRight), 0);
+          pGUIWindow_CurrentMenu->CreateButton(263, 216, 172, 17, v0, 0, UIMSG_ChangeMusicVolume, 0, 0, v1, 0);
+
+          pBtn_SliderLeft  = pGUIWindow_CurrentMenu->CreateButton(243, 270, 16, 16, v0, 0, UIMSG_ChangeVoiceVolume, 4, 0, v1, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowLeft), 0);
+          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(435, 270, 16, 16, v0, 0, UIMSG_ChangeVoiceVolume, 5, 0, v1, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowRight), 0);
+          pGUIWindow_CurrentMenu->CreateButton(263, 270, 172, 17, v0, 0, UIMSG_ChangeVoiceVolume, 0, 0, v1, 0);
+
+          pGUIWindow_CurrentMenu->CreateButton(241, 302, 214, 40, v0, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[619], 0); // "Return to Game"
+          pGUIWindow_CurrentMenu->CreateButton( 19, 140, 214, 40, v0, 0, UIMSG_OpenKeyMappingOptions, 0, 0x4Bu, v1, 0);
+          pGUIWindow_CurrentMenu->CreateButton( 19, 194, 214, 40, v0, 0, UIMSG_OpenVideoOptions, 0, 86, v1, 0);
+          continue;
+
         case UIMSG_OpenKeyMappingOptions://Open
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -1128,15 +1124,8 @@
                       pEventTimer->Resume();
                       continue;
                     case SCREEN_OPTIONS://Close
-                      thisa = (signed int)&uTextureID_ControlBG;
-                      do
-                      {
-                        if ( *(int *)thisa )
-                          pIcons_LOD->pTextures[*(int *)thisa].Release();
-                        thisa += 4;
-                      }
-                      while ( thisa < (signed int)&dword_507CBC );
-                      memset(&uTextureID_ControlBG, 0, 0x5Cu);
+                      options_menu_skin.Relaease();
+
                       pIcons_LOD->_40F9C5();
                       WriteWindowsRegistryInt("soundflag", (char)uSoundVolumeMultiplier);
                       WriteWindowsRegistryInt("musicflag", (char)uMusicVolimeMultiplier);
@@ -1657,7 +1646,7 @@
           {
             pParty->field_6E4 = 0;
             pParty->field_6E0 = 0;
-            pStru277->_427D48(v0);
+            pCastSpellInfo->_427D48(v0);
             sub_44603D();
             pEventTimer->Pause();
             pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_Box);
@@ -3309,7 +3298,7 @@
       }
     }
   }
-  pStru277->_427E01_cast_spell();
+  pCastSpellInfo->_427E01_cast_spell();
 }
 
 //----- (004356FF) --------------------------------------------------------
@@ -3462,10 +3451,10 @@
         case UIMSG_PlayerCreation_FacePrev:
         {
             pPlayer = &pParty->pPlayers[uNum];
-            unsigned char v12 = (char)((int)pPlayer->uFace - 1) < 0;
-            --pPlayer->uFace;
-            if ( v12 )
+            if (!pPlayer->uFace)
               pPlayer->uFace = 19;
+            else
+              pPlayer->uFace -= 1;
             pPlayer->uVoiceID = pPlayer->uFace;
             pPlayer->SetInitialStats();
             pPlayer->SetSexByVoice();
@@ -4595,7 +4584,7 @@
   PlayerEquipment *v57; // [sp+48h] [bp-24h]@10
   //int v58; // [sp+4Ch] [bp-20h]@10
   int v59; // [sp+50h] [bp-1Ch]@1
-  //unsigned int uActorID_Monster_; // [sp+54h] [bp-18h]@1
+  unsigned int uActorID_Monster_; // [sp+54h] [bp-18h]@1
   int v61; // [sp+58h] [bp-14h]@1
   bool v62; // [sp+5Ch] [bp-10h]@1
   int uDamageAmount; // [sp+60h] [bp-Ch]@1
@@ -4604,7 +4593,7 @@
 
   //v3 = a1;
   v4 = 0;
-  //uActorID_Monster_ = uActorID_Monster;
+  uActorID_Monster_ = uActorID_Monster;
   //v54 = a1;
   uDamageAmount = 0;
   a4 = 0;
@@ -4626,7 +4615,7 @@
 
   assert(PID_ID(abs(a1)) < 4);
   auto player = &pParty->pPlayers[PID_ID(a1)];
-  pMonster = &pActors[uActorID_Monster];
+  pMonster = &pActors[uActorID_Monster_];
   //uPlayerID = pMonster->IsAlive();
   if (pMonster->IsNotAlive())
     return;
@@ -4675,10 +4664,10 @@
         break;
       }
     }
-    //v50 = pMonster->pMonsterInfo.uID;
+    v50 = pMonster->pMonsterInfo.uID;
     a2 = 4;
     //v27 = player->CalculateMeleeDamageTo(0, 0, v50);
-    uDamageAmount = player->CalculateMeleeDamageTo(0, 0, pMonster->pMonsterInfo.uID);
+    uDamageAmount = player->CalculateMeleeDamageTo(0, 0, v50);
     //if ( !v57 )
       goto LABEL_67;
     //goto LABEL_69;
@@ -4689,7 +4678,7 @@
   v61 = v4->field_60_distance_related_prolly_lod;
   if ( !v19 )
   {
-    //v9 = v4;
+    //v9 = (SpriteObject *)uDamageAmount;
 	v50 = pParty->vPosition.x - v4->vPosition.x;
     //v55 = abs(v50);
     pMonsterName = (char *)(pParty->vPosition.y - v4->vPosition.y);
@@ -4882,8 +4871,8 @@
   }
   if ( pMonster->sCurrentHP > 0 )
   {
-    Actor::Stun(uActorID_Monster, a1, 0);
-    Actor::AggroSurroundingPeasants(uActorID_Monster, 1);
+    Actor::Stun(uActorID_Monster_, a1, 0);
+    Actor::AggroSurroundingPeasants(uActorID_Monster_, 1);
     if ( bShowDamage )
     {
       v50 = uDamageAmount;
@@ -4927,9 +4916,9 @@
         }
       }
     }
-    Actor::Die(uActorID_Monster);
-    Actor::ApplyFineForKillingPeasant(uActorID_Monster);
-    Actor::AggroSurroundingPeasants(uActorID_Monster, 1);
+    Actor::Die(uActorID_Monster_);
+    Actor::ApplyFineForKillingPeasant(uActorID_Monster_);
+    Actor::AggroSurroundingPeasants(uActorID_Monster_, 1);
     if ( pMonster->pMonsterInfo.uExp )
       GivePartyExp(pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].uExp);
     v40 = SPEECH_51;
@@ -5002,7 +4991,7 @@
     pMonster->vVelocity.y = 50 * LOWORD(pVelocity->y);
     pMonster->vVelocity.z = 50 * LOWORD(pVelocity->z);
   }
-  Actor::AddBloodsplatOnDamageOverlay(uActorID_Monster, 1, v61);
+  Actor::AddBloodsplatOnDamageOverlay(uActorID_Monster_, 1, v61);
 }
 // 4D864C: using guessed type char byte_4D864C;
 
@@ -9319,49 +9308,6 @@
   return v5;
 }
 
-//----- (00409BE8) --------------------------------------------------------
-void __cdecl sub_409BE8()
-{
-  void *v0; // eax@1
-  stru348 *v1; // eax@1
-  int v2; // ecx@1
-  int v3; // eax@1
-
-  v0 = window_SpeakInHouse->ptr_1C;
-  dword_4E1874 = 5;
-  v1 = &stru_4E1890[(int)((char *)v0 - 108)];
-  amuint_4E1860 = v1->field_4;
-  amuint_4E1864 = v1->field_6;
-  amuint_4E1868 = v1->field_8 - 1;
-  amuint_4E186C = v1->field_A - 1;
-  amuint_4E1870 = v1->field_C - 1;
-  amuint_505884 = v1->field_E;
-  amuint_505888 = v1->field_10;
-  amuint_50588C = v1->field_12;
-  dword_4E1878 = 1;
-  dword_4E187C = 1;
-  dword_4E1880 = 1;
-  dword_4E1884 = v1->field_0;
-  v2 = v1->field_2;
-  v3 = v1->field_14;
-  dword_4E1888 = v2;
-  dword_4DF3A4 = v3;
-}
-// 4DF3A4: using guessed type int dword_4DF3A4;
-// 4E1860: using guessed type int amuint_4E1860;
-// 4E1864: using guessed type int amuint_4E1864;
-// 4E1868: using guessed type int amuint_4E1868;
-// 4E186C: using guessed type int amuint_4E186C;
-// 4E1870: using guessed type int amuint_4E1870;
-// 4E1874: using guessed type int dword_4E1874;
-// 4E1878: using guessed type int dword_4E1878;
-// 4E187C: using guessed type int dword_4E187C;
-// 4E1880: using guessed type int dword_4E1880;
-// 4E1884: using guessed type int dword_4E1884;
-// 4E1888: using guessed type int dword_4E1888;
-// 505884: using guessed type int amuint_505884;
-// 505888: using guessed type int amuint_505888;
-// 50588C: using guessed type int amuint_50588C;
 
 //----- (0040D75D) --------------------------------------------------------
 char __fastcall pPrimaryWindow_draws_text(int a1, const char *pText, int *pXY)
@@ -9435,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) + 
@@ -10204,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 )
@@ -10326,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);
 }
 
 
@@ -10531,7 +10477,7 @@
 			}
 		case WINDOW_Book:
 			{
-			SellectDrawBook((unsigned int)pWindow->ptr_1C);
+			DrawCurrentBook((unsigned int)pWindow->ptr_1C);
 			break;
 			}
 		case WINDOW_QuickReference:
@@ -11284,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;
@@ -11505,7 +11451,7 @@
     v2 = 255;
     v3 = 0;
   }
-  return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v3, v2, v6);
+  return TargetColor(v3, v2, v6);
 }
 
 //----- (00417939) --------------------------------------------------------
@@ -11519,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:
@@ -11579,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);
@@ -11594,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	Thu May 02 11:02:48 2013 +0600
+++ b/mm7_6.cpp	Thu May 02 11:03:26 2013 +0600
@@ -31,11 +31,9 @@
 #include "Awards.h"
 #include "Autonotes.h"
 #include "stru160.h"
-#include "stru279.h"
 #include "TurnEngine.h"
-#include "stru277.h"
+#include "CastSpellInfo.h"
 #include "Weather.h"
-#include "stru272.h"
 #include "stru298.h"
 #include "texts.h"
 #include "StorylineTextTable.h"
@@ -1110,7 +1108,7 @@
     || (v2 = 300.0 < p[1].vWorldViewPosition.x,
         v3 = 0,
         v4 = 300.0 == p[1].vWorldViewPosition.x,
-        BYTE1(result) = HIBYTE(v1),
+        //BYTE1(result) = HIBYTE(v1),
         !(v2 | v4)) )
   {
     if ( p->vWorldViewPosition.x < 300.0 )
@@ -1118,17 +1116,17 @@
       v6 = 300.0 < p[1].vWorldViewPosition.x;
       v7 = 0;
       v8 = 300.0 == p[1].vWorldViewPosition.x;
-      BYTE1(result) = HIBYTE(v1);
+      //BYTE1(result) = HIBYTE(v1);
       if ( !(v6 | v8) )
       {
-        LOBYTE(result) = 0;
-        return result;
+        //LOBYTE(result) = 0;
+        return false;
       }
     }
     v9 = 300.0 < p->vWorldViewPosition.x;
     v10 = 0;
     v11 = 300.0 == p->vWorldViewPosition.x;
-    BYTE1(result) = HIBYTE(v1);
+    //BYTE1(result) = HIBYTE(v1);
     if ( v9 | v11 )
     {
       v16 = 1.0 / (p->vWorldViewPosition.x - p[1].vWorldViewPosition.x);
@@ -1150,8 +1148,8 @@
       p->vWorldViewPosition.z = v15 * v14 + p->vWorldViewPosition.z;
     }
   }
-  LOBYTE(result) = 1;
-  return result;
+  //LOBYTE(result) = 1;
+  return true;
 }
 
 //----- (004268E3) --------------------------------------------------------
@@ -1186,7 +1184,6 @@
   LOWORD(v2) = (a1 >> 5) & 0x7E0;
   return ((unsigned __int8)a1 >> 3) | v2 | v1;
 }
-
 //----- (00426947) --------------------------------------------------------
 void __cdecl sub_426947()
 {
@@ -1249,7 +1246,7 @@
         if ( v11 )
         {
           LOBYTE(v7) = v6->GetLearningPercent();
-          v1b = v11 + v11 * v7 / 100;
+          v1b = v11 + v11 * (char)v7 / 100;
           //v8 = __CFADD__((int)v1, LODWORD(v6->uExperience));
 		  //need review
           LODWORD(v6->uExperience) += v1b;
@@ -2251,19 +2248,19 @@
 
     if (a5 & 0x3CA)
     {
-      assert(sizeof(pStru277) / sizeof(*pStru277) == 10);
+      assert(sizeof(pCastSpellInfo) / sizeof(*pCastSpellInfo) == 10);
       for (uint i = 0; i < 10; ++i)
-        if (pStru277[i].field_8 & 0x3CA)
+        if (pCastSpellInfo[i].field_8 & 0x3CA)
         {
-          pStru277[i].spellnum = 0;
+          pCastSpellInfo[i].spellnum = 0;
           break;
         }
     }
       
-    assert(sizeof(pStru277) / sizeof(*pStru277) == 10);
+    assert(sizeof(pCastSpellInfo) / sizeof(*pCastSpellInfo) == 10);
     for (uint i = 0; i < 10; ++i)
     {
-      auto spell = pStru277 + i;
+      auto spell = pCastSpellInfo + i;
       if (!spell->spellnum)
         continue;
 
@@ -2279,14 +2276,14 @@
       }
     }
 
-    int result = pStru277->PushStru277(a1, uPlayerID, a4, a5, a6);
+    int result = pCastSpellInfo->PushCastSpellInfo(a1, uPlayerID, a4, a5, a6);
     if ( result != -1 )
     {
       if ( a5 & 2 )
       {
         if ( pGUIWindow_Settings )
           return;
-        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0);
+        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pCastSpellInfo[result], 0);
         pGUIWindow_Settings->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_45, 0, 0x31u, "", 0);
         pGUIWindow_Settings->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_45, 1u, 0x32u, "", 0);
         pGUIWindow_Settings->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_45, 2u, 0x33u, "", 0);
@@ -2299,7 +2296,7 @@
         if ( pGUIWindow_Settings )
           return;
 
-        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0);
+        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pCastSpellInfo[result], 0);
         pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_46, 0, 0, "", 0);
         sub_421B2C_PlaceInInventory_or_DropPickedItem();
         return;
@@ -2309,7 +2306,7 @@
         if ( pGUIWindow_Settings )
           return;
 
-        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0);
+        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pCastSpellInfo[result], 0);
         pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_BE, 0, 0, "", 0);
         sub_421B2C_PlaceInInventory_or_DropPickedItem();
         return;
@@ -2321,7 +2318,7 @@
         ++pIcons_LOD->uTexturePacksCount;
         if ( !pIcons_LOD->uNumPrevLoadedFiles )
           pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
-        pGUIWindow_Settings = pStru277[result].sub_4219BE();
+        pGUIWindow_Settings = pCastSpellInfo[result].sub_4219BE();
         unk_50C9A0 = 1;
         some_active_character = uActiveCharacter;
         sub_421B2C_PlaceInInventory_or_DropPickedItem();
@@ -2331,7 +2328,7 @@
       {
         if ( pGUIWindow_Settings )
           return;
-        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0);
+        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pCastSpellInfo[result], 0);
         pGUIWindow_Settings->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_8D, 0, 0x31u, "", 0);
         pGUIWindow_Settings->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_8D, 1, 0x32u, "", 0);
         pGUIWindow_Settings->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_8D, 2, 0x33u, "", 0);
@@ -2341,7 +2338,7 @@
       }
       if ( HIBYTE(a5) & 2 && !pGUIWindow_Settings )
       {
-        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0);
+        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pCastSpellInfo[result], 0);
         pBtn_NPCLeft = pGUIWindow_Settings->CreateButton(469, 178,
                        pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureWidth,
                        pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureHeight,
@@ -2367,9 +2364,9 @@
 }
 
 //----- (00427D48) --------------------------------------------------------
-void stru277::_427D48(unsigned int uPlayerID)
+void CastSpellInfo::_427D48(unsigned int uPlayerID)
 {
-  stru277 *v2; // esi@1
+  CastSpellInfo *v2; // esi@1
   signed int v3; // ebx@1
 
   v2 = this;
@@ -2396,11 +2393,11 @@
 }
 
 //----- (00427DA0) --------------------------------------------------------
-unsigned int stru277::PushStru277(__int16 a2, __int16 uPlayerID, __int16 skill_level, __int16 a5, int spell_sound_id)
+unsigned int CastSpellInfo::PushCastSpellInfo(__int16 a2, __int16 uPlayerID, __int16 skill_level, __int16 a5, int spell_sound_id)
 {
   unsigned int result; // eax@1
-  stru277 *v7; // edx@1
-  stru277 *v8; // ecx@5
+  CastSpellInfo *v7; // edx@1
+  CastSpellInfo *v8; // ecx@5
 
   result = 0;
   v7 = this;
@@ -2428,11 +2425,11 @@
 }
 
 //----- (00427E01) --------------------------------------------------------
-void stru277::_427E01_cast_spell()
+void CastSpellInfo::_427E01_cast_spell()
 {
   //int v1; // esi@1
   int v2; // edi@1
-  stru277 *v3; // ebx@2
+  CastSpellInfo *pCastSpell; // ebx@2
   //signed int v4; // eax@8
   //__int16 v5; // ax@9
   signed int v6; // eax@14
@@ -3140,7 +3137,7 @@
   //int v708; // [sp+D84h] [bp-100h]@1127
   //int v709; // [sp+D88h] [bp-FCh]@1127
   char v710; // [sp+D8Ch] [bp-F8h]@1156
-  stru277 *v711; // [sp+D90h] [bp-F4h]@1
+  //stru277 *v711; // [sp+D90h] [bp-F4h]@1
   __int64 v712; // [sp+D94h] [bp-F0h]@991
   int v713; // [sp+D9Ch] [bp-E8h]@324
   int n; // [sp+DA0h] [bp-E4h]@1
@@ -3169,11 +3166,11 @@
   signed int a2; // [sp+E7Ch] [bp-8h]@14
   int amount; // [sp+E80h] [bp-4h]@1
 
-  auto ecx0 = this;
-
-  v711 = ecx0;
-
-  SpriteObject a1; // [sp+DDCh] [bp-A8h]@1
+  //auto ecx0 = this;
+
+  //v711 = ecx0;
+
+  SpriteObject pSpellSprite; // [sp+DDCh] [bp-A8h]@1
   //SpriteObject::SpriteObject(&a1);
 
   //v1 = 0;
@@ -3186,28 +3183,28 @@
   //while ( 1 )
   for(n = 0; n < 10; ++n)
   {
-    v3 = &v711[n];
-    HIDWORD(v733) = (int)v3;
-    if ( v3->spellnum == 0 )
+    pCastSpell = &this[n];
+    HIDWORD(v733) = (int)pCastSpell;
+    if ( pCastSpell->spellnum == 0 )
       continue;
 
     if (pParty->Invisible())
       pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
 
-    if ( v3->field_8 & 0x3CA )
+    if ( pCastSpell->field_8 & 0x3CA )
     {
-      if ( !pParty->pPlayers[v3->uPlayerID].CanAct() )
-        v711->_427D48(1u);
+      if ( !pParty->pPlayers[pCastSpell->uPlayerID].CanAct() )
+        this->_427D48(1);
       continue;
     }
-    pPlayer = &pParty->pPlayers[v3->uPlayerID];
-
-    a2 = v3->spell_target_pid;
-    if (!a2)
+    pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID];
+
+    a2 = pCastSpell->spell_target_pid;
+    if (!pCastSpell->spell_target_pid)
     {
-      if (v3->spellnum == SPELL_LIGHT_DESTROY_UNDEAD ||
-          v3->spellnum == SPELL_SPIRIT_TURN_UNDEAD ||
-          v3->spellnum == SPELL_DARK_CONTROL_UNDEAD )
+      if (pCastSpell->spellnum == SPELL_LIGHT_DESTROY_UNDEAD ||
+          pCastSpell->spellnum == SPELL_SPIRIT_TURN_UNDEAD ||
+          pCastSpell->spellnum == SPELL_DARK_CONTROL_UNDEAD )
         v666 = 1;
       else
         v666 = 0;
@@ -3219,12 +3216,12 @@
     }
 
 
-    a1.uType = stru_4E3ACC[v3->spellnum].field_0;
-    if (a1.uType)
+    pSpellSprite.uType = stru_4E3ACC[pCastSpell->spellnum].uType;
+    if (pSpellSprite.uType)
     {
       if (PID_TYPE(a2) == OBJECT_Actor)
       {
-        memcpy(&v715, Actor::GetDirectionInfo(PID(OBJECT_Player, v3->uPlayerID + 1), a2, &a3, 0), sizeof(v715));
+        memcpy(&v715, Actor::GetDirectionInfo(PID(OBJECT_Player, pCastSpell->uPlayerID + 1), a2, &a3, 0), sizeof(v715));
         v2 = v723;
       }
       else
@@ -3236,34 +3233,34 @@
 
     LODWORD(v725) = 0;
     _this = 0;
-    if (v3->forced_spell_skill_level)
+    if (pCastSpell->forced_spell_skill_level)
     {
-      v11 = v3->forced_spell_skill_level;
+      v11 = pCastSpell->forced_spell_skill_level;
       v723 = v11 & 0x3F;
       v2 = v723;
     }
     else
     {
       //v667 = PLAYER_SKILL_STAFF;
-      if (v3->spellnum < SPELL_AIR_WIZARD_EYE)
+      if (pCastSpell->spellnum < SPELL_AIR_WIZARD_EYE)
         v667 = PLAYER_SKILL_FIRE;
-      else if (v3->spellnum < SPELL_WATER_AWAKEN)
+      else if (pCastSpell->spellnum < SPELL_WATER_AWAKEN)
         v667 = PLAYER_SKILL_AIR;
-      else if (v3->spellnum < SPELL_EARTH_STUN)
+      else if (pCastSpell->spellnum < SPELL_EARTH_STUN)
         v667 = PLAYER_SKILL_WATER;
-      else if (v3->spellnum < SPELL_SPIRIT_DETECT_LIFE)
+      else if (pCastSpell->spellnum < SPELL_SPIRIT_DETECT_LIFE)
         v667 = PLAYER_SKILL_EARTH;
-      else if (v3->spellnum < SPELL_MIND_REMOVE_FEAR)
+      else if (pCastSpell->spellnum < SPELL_MIND_REMOVE_FEAR)
         v667 = PLAYER_SKILL_SPIRIT;
-      else if (v3->spellnum < SPELL_BODY_CURE_WEAKNESS)
+      else if (pCastSpell->spellnum < SPELL_BODY_CURE_WEAKNESS)
         v667 = PLAYER_SKILL_MIND;
-      else if (v3->spellnum < SPELL_LIGHT_LIGHT_BOLT)
+      else if (pCastSpell->spellnum < SPELL_LIGHT_LIGHT_BOLT)
         v667 = PLAYER_SKILL_BODY;
-      else if (v3->spellnum < SPELL_DARK_REANIMATE)
+      else if (pCastSpell->spellnum < SPELL_DARK_REANIMATE)
         v667 = PLAYER_SKILL_LIGHT;
-      else if (v3->spellnum < SPELL_BOW_ARROW)
+      else if (pCastSpell->spellnum < SPELL_BOW_ARROW)
         v667 = PLAYER_SKILL_DARK;
-      else if (v3->spellnum == SPELL_BOW_ARROW)
+      else if (pCastSpell->spellnum == SPELL_BOW_ARROW)
         v667 = PLAYER_SKILL_BOW;
       else assert(false && "Unknown spell");
 
@@ -3289,136 +3286,125 @@
       }
     }
 
-    if (v3->forced_spell_skill_level)
+    if (pCastSpell->forced_spell_skill_level)
       uRequiredMana = 0;
     else 
-      uRequiredMana = pSpellDatas[v3->spellnum].mana_per_skill[v731 - 1];
-    sRecoveryTime = pSpellDatas[v3->spellnum].recovery_per_skill[v731 - 1];
+      uRequiredMana = pSpellDatas[pCastSpell->spellnum].mana_per_skill[v731 - 1];
+    sRecoveryTime = pSpellDatas[pCastSpell->spellnum].recovery_per_skill[v731 - 1];
 
     if (LODWORD(v725) == PLAYER_SKILL_DARK && pParty->uCurrentHour == 0 && pParty->uCurrentMinute == 0 ||
         LODWORD(v725) == PLAYER_SKILL_LIGHT && pParty->uCurrentHour == 12 && pParty->uCurrentMinute == 0)
       uRequiredMana = 0;
 
-    if (v3->spellnum < SPELL_BOW_ARROW && pPlayer->sMana < uRequiredMana)
-	{
-		ShowStatusBarString(pGlobalTXT_LocalizationStrings[586], 2u); // "Not enough spell points"
-		v3->spellnum = 0;
-		continue;
-	}
-	v730 = v3->spellnum;
-	if (pPlayer->Cursed() && v3->spellnum < SPELL_BOW_ARROW && rand() % 100 < 50)
-	{
-		if (!pParty->bTurnBasedModeOn)
-		{
-			//v646 = pPlayer;
-			pPlayer->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333));
-			//v647 = n;
-		}
-		else
-		{
-			//v647 = n;
-			//v646 = pPlayer;
-			//v648 = sRecoveryTime;
-			//v649 = pPlayer;
-			pParty->pTurnBasedPlayerRecoveryTimes[v711[n].uPlayerID] = 100;
-			pPlayer->SetRecoveryTime(sRecoveryTime);
-			pTurnEngine->_40471C();
-		}
-		ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); // "Spell failed"
-		pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-		v711[n].spellnum = 0;
-		pPlayer->sMana -= uRequiredMana;
-		return;
-	}
-
-	switch ( v3->spellnum )
-	{
-		case SPELL_101:
-		assert(false && "Unknown spell effect #101 (prolly flaming bow arrow");
-		case SPELL_BOW_ARROW:
-			{
-			v17 = pPlayer;
-			_this = (ItemGen *)1;
-			if ( (signed int)SkillToMastery(pPlayer->pActiveSkills[PLAYER_SKILL_BOW]) >= 3 )
-				_this = (ItemGen *)2;
-			sRecoveryTime = v17->GetAttackRecoveryTime(true);
-			a1.stru_24.Reset();
-			a1.spell_level = v2;
-			a1.spell_id = v3->spellnum;
-			a1.spell_skill = v731;
-			a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-			if ( v17->WearsItem(510, 2) )
-				a1.uObjectDescID = pObjectList->ObjectIDByItemID(0xBD6u);
-			a1.vPosition.x = pParty->vPosition.x;
-			a1.vPosition.y = pParty->vPosition.y;
-			a1.uAttributes = 0;
-			a1.uSpriteFrameID = 0;
-			a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
-			a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-			a1.spell_target_pid = a2;
-			a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
-			a1.uFacing = LOWORD(v715.uYawAngle);
-			a1.uSoundID = LOWORD(v3->sound_id);
-			v20 = &pParty->pPlayers[v3->uPlayerID];
-			memcpy(&a1.stru_24, &v20[v20->pEquipment.uBow], sizeof(a1.stru_24));
-			a1.uAttributes = 256;
+    if (pCastSpell->spellnum < SPELL_BOW_ARROW && pPlayer->sMana < uRequiredMana)
+    {
+      ShowStatusBarString(pGlobalTXT_LocalizationStrings[586], 2u); // "Not enough spell points"
+      pCastSpell->spellnum = 0;
+      continue;
+    }
+    v730 = pCastSpell->spellnum;
+    if (pPlayer->Cursed() && pCastSpell->spellnum < SPELL_BOW_ARROW && rand() % 100 < 50)
+    {
+      if (!pParty->bTurnBasedModeOn)
+      {
+        //v646 = pPlayer;
+        pPlayer->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333));
+        //v647 = n;
+      }
+      else
+      {
+        //v647 = n;
+        //v646 = pPlayer;
+        //v648 = sRecoveryTime;
+        //v649 = pPlayer;
+        pParty->pTurnBasedPlayerRecoveryTimes[this[n].uPlayerID] = 100;
+        pPlayer->SetRecoveryTime(sRecoveryTime);
+        pTurnEngine->_40471C();
+      }
+      ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); // "Spell failed"
+      pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+      this[n].spellnum = 0;
+      pPlayer->sMana -= uRequiredMana;
+      return;
+    }
+
+    switch ( pCastSpell->spellnum )
+    {
+      case SPELL_101:
+        assert(false && "Unknown spell effect #101 (prolly flaming bow arrow");
+      case SPELL_BOW_ARROW:
+      {
+        v17 = pPlayer;
+        _this = (ItemGen *)1;
+        if ( (signed int)SkillToMastery(pPlayer->pActiveSkills[PLAYER_SKILL_BOW]) >= 3 )
+          _this = (ItemGen *)2;
+        sRecoveryTime = v17->GetAttackRecoveryTime(true);
+        pSpellSprite.stru_24.Reset();
+        pSpellSprite.spell_level = v2;
+        pSpellSprite.spell_id = pCastSpell->spellnum;
+        pSpellSprite.spell_skill = v731;
+        pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+        if ( v17->WearsItem(510, 2) )
+          pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(0xBD6u);
+        pSpellSprite.vPosition.x = pParty->vPosition.x;
+        pSpellSprite.vPosition.y = pParty->vPosition.y;
+        pSpellSprite.uAttributes = 0;
+        pSpellSprite.uSpriteFrameID = 0;
+        pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+        pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+        pSpellSprite.spell_target_pid = a2;
+        pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
+        pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
+        pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
+        v20 = &pParty->pPlayers[pCastSpell->uPlayerID];
+        memcpy(&pSpellSprite.stru_24, &v20[v20->pEquipment.uBow], sizeof(pSpellSprite.stru_24));
+        pSpellSprite.uAttributes = 256;
+        if ( pParty->bTurnBasedModeOn == 1 )
+          pSpellSprite.uAttributes = 260;
+        for ( i = 0; i < (signed int)_this; ++i )
+        {
+          if ( i )
+            pSpellSprite.vPosition.z += 32;
+          pSpellSprite.uSectorID = pIndoor->GetSector(pSpellSprite.vPosition.x, pSpellSprite.vPosition.y, pSpellSprite.vPosition.z);
+          if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed,
+               pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
+            ++pTurnEngine->field_1C;
+        }
+        break;
+      }
+      case SPELL_LASER_PROJECTILE:
+      {
+			sRecoveryTime = pPlayer->GetAttackRecoveryTime(0);
+			pSpellSprite.stru_24.Reset();
+			pSpellSprite.spell_id = pCastSpell->spellnum;
+			pSpellSprite.spell_level = v723;
+			pSpellSprite.spell_skill = v731;
+			pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+			pSpellSprite.vPosition.x = pParty->vPosition.x;
+			pSpellSprite.vPosition.y = pParty->vPosition.y;
+			pSpellSprite.uAttributes = 0;
+			pSpellSprite.uSpriteFrameID = 0;
+			pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
+			pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+			pSpellSprite.spell_target_pid = a2;
+			pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
+			pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
+			pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
+			memcpy(&pSpellSprite.stru_24,
+				&pParty->pPlayers[pCastSpell->uPlayerID].spellbook.pDarkSpellbook.bIsSpellAvailable[36
+					* pParty->pPlayers[pCastSpell->uPlayerID].pEquipment.uMainHand + 5], sizeof(pSpellSprite.stru_24));
+			v23 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pSpellSprite.vPosition.z);
+			HIBYTE(pSpellSprite.uAttributes) |= 1u;
+			pSpellSprite.uSectorID = v23;
 			if ( pParty->bTurnBasedModeOn == 1 )
-				a1.uAttributes = 260;
-			for ( i = 0; i < (signed int)_this; ++i )
-			{
-				if ( i )
-				a1.vPosition.z += 32;
-				a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z);
-				if ( a1.Create(
-						v715.uYawAngle,
-						v715.uPitchAngle,
-						pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
-						v3->uPlayerID + 1) != -1
-				&& pParty->bTurnBasedModeOn == 1 )
+				LOBYTE(pSpellSprite.uAttributes) |= 4u;
+			if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed,
+					pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
 				++pTurnEngine->field_1C;
-			}
-			break;
-			}
-		case SPELL_LASER_PROJECTILE:
-			{
-			sRecoveryTime = pPlayer->GetAttackRecoveryTime(0);
-			a1.stru_24.Reset();
-			a1.spell_id = v3->spellnum;
-			a1.spell_level = v723;
-			a1.spell_skill = v731;
-			a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-			a1.vPosition.x = pParty->vPosition.x;
-			a1.vPosition.y = pParty->vPosition.y;
-			a1.uAttributes = 0;
-			a1.uSpriteFrameID = 0;
-			a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
-			a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-			a1.spell_target_pid = a2;
-			a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
-			a1.uFacing = LOWORD(v715.uYawAngle);
-			a1.uSoundID = LOWORD(v3->sound_id);
-			memcpy(
-				&a1.stru_24,
-				&pParty->pPlayers[v3->uPlayerID].spellbook.pDarkSpellbook.bIsSpellAvailable[36
-																				* pParty->pPlayers[v3->uPlayerID].pEquipment.uMainHand
-																				+ 5],
-				sizeof(a1.stru_24));
-			v23 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, a1.vPosition.z);
-			HIBYTE(a1.uAttributes) |= 1u;
-			a1.uSectorID = v23;
-			if ( pParty->bTurnBasedModeOn == 1 )
-				LOBYTE(a1.uAttributes) |= 4u;
-			if ( a1.Create(
-					v715.uYawAngle,
-					v715.uPitchAngle,
-					pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
-					v3->uPlayerID + 1) != -1
-				&& pParty->bTurnBasedModeOn == 1 )
-				++pTurnEngine->field_1C;
-			break;
-			}
-		case SPELL_FIRE_TORCH_LIGHT:
-			{
+			break;
+      }
+      case SPELL_FIRE_TORCH_LIGHT:
+      {
 			LODWORD(v733) = 3600 * v2;
 
 			switch (v731)
@@ -3430,16 +3416,14 @@
 				default:
 				assert(false);
 			}
-
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
-
 			pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)3600 * v2 * 4.2666669), v731, amount, 0, 0);
 			LODWORD(v727) = 1;
 			break;
-			}
-		case SPELL_FIRE_FIRE_SPIKE:
-		{
+      }
+      case SPELL_FIRE_FIRE_SPIKE:
+      {
 		v29 = v731 - 2;
 		if ( v29 )
 		{
@@ -3469,7 +3453,7 @@
 		for (uint i = 0; i < uNumSpriteObjects; ++i)
 		{
 			auto object = pSpriteObjects + i;
-			if (object->uType && object->spell_id == SPELL_FIRE_FIRE_SPIKE && object->spell_caster_pid == PID(OBJECT_Player, v3->uPlayerID))
+			if (object->uType && object->spell_id == SPELL_FIRE_FIRE_SPIKE && object->spell_caster_pid == PID(OBJECT_Player, pCastSpell->uPlayerID))
 			++_v733;
 			/*v33 = (char *)&pSpriteObjects[0].field_48;
 			v730 = uNumSpriteObjects;
@@ -3486,49 +3470,44 @@
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
-
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-		a1.vPosition.y = pParty->vPosition.y;
-		a1.vPosition.x = pParty->vPosition.x;
-		a1.uAttributes = 0;
-		a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
-		a1.uSectorID = pIndoor->GetSector(
-							pParty->vPosition.x,
-							pParty->vPosition.y,
-							pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
-		a1.uSpriteFrameID = 0;
-		a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-		a1.spell_target_pid = a2;
-		a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
-		a1.uFacing = LOWORD(v715.uYawAngle);
-		a1.uSoundID = LOWORD(v3->sound_id);
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+		pSpellSprite.vPosition.y = pParty->vPosition.y;
+		pSpellSprite.vPosition.x = pParty->vPosition.x;
+		pSpellSprite.uAttributes = 0;
+		pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+		pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
+		pSpellSprite.uSpriteFrameID = 0;
+		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+		pSpellSprite.spell_target_pid = a2;
+		pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
+		pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
+		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 		if ( pParty->bTurnBasedModeOn == 1 )
-			LOBYTE(a1.uAttributes) |= 4u;
-		v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
-			if ( a1.Create(pParty->sRotationY, pParty->sRotationX + 10, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
+			LOBYTE(pSpellSprite.uAttributes) |= 4u;
+		v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
+		if ( pSpellSprite.Create(pParty->sRotationY, pParty->sRotationX + 10, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
 			++pTurnEngine->field_1C;
 		LODWORD(v727) = 1;
 		break;
-		}
-
-		case SPELL_AIR_IMPLOSION:
-		{
+      }
+      case SPELL_AIR_IMPLOSION:
+      {
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 		if (!a2)
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		if (PID_TYPE(a2) != OBJECT_Actor)
@@ -3539,33 +3518,31 @@
 		v697.x = 0;
 		v697.y = 0;
 		v697.z = 0;
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-		a1.uAttributes = 0;
-		a1.uSectorID = 0;
-		a1.uSpriteFrameID = 0;
-		a1.field_60_distance_related_prolly_lod = 0;
-		a1.uFacing = 0;
-		a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-		a1.uSoundID = LOWORD(v3->sound_id);
-		a1.vPosition.x = pActors[PID_ID(a2)].vPosition.x;
-		a1.vPosition.z = pActors[PID_ID(a2)].vPosition.z;
-		a1.vPosition.y = pActors[PID_ID(a2)].vPosition.y;
-		a1.spell_target_pid = PID(OBJECT_Actor, PID_ID(a2));
-		auto obj_id = a1.Create(0, 0, 0, 0);
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+		pSpellSprite.uAttributes = 0;
+		pSpellSprite.uSectorID = 0;
+		pSpellSprite.uSpriteFrameID = 0;
+		pSpellSprite.field_60_distance_related_prolly_lod = 0;
+		pSpellSprite.uFacing = 0;
+		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
+		pSpellSprite.vPosition.x = pActors[PID_ID(a2)].vPosition.x;
+		pSpellSprite.vPosition.z = pActors[PID_ID(a2)].vPosition.z;
+		pSpellSprite.vPosition.y = pActors[PID_ID(a2)].vPosition.y;
+		pSpellSprite.spell_target_pid = PID(OBJECT_Actor, PID_ID(a2));
+		auto obj_id = pSpellSprite.Create(0, 0, 0, 0);
 		DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v697);
 		LODWORD(v727) = 1;
 		break;
-		}
-
-		case SPELL_EARTH_MASS_DISTORTION:
-		{
+      }
+      case SPELL_EARTH_MASS_DISTORTION:
+      {
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
-
 		if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 3u) )
 		{
 			LODWORD(v727) = 1;
@@ -3575,32 +3552,29 @@
 		v704.x = 0;
 		v704.y = 0;
 		v704.z = 0;
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-		a1.uAttributes = 0;
-		a1.uSectorID = 0;
-		a1.uSpriteFrameID = 0;
-		a1.field_60_distance_related_prolly_lod = 0;
-		a1.uFacing = 0;
-		a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-		a1.uSoundID = LOWORD(v3->sound_id);
-		a1.vPosition.x = pActors[PID_ID(a2)].vPosition.x;
-		a1.vPosition.y = pActors[PID_ID(a2)].vPosition.y;
-		a1.vPosition.z = pActors[PID_ID(a2)].vPosition.z;
-		a1.spell_target_pid = PID(OBJECT_Actor, (int)v726);
-
-		auto obj_id = a1.Create(0, 0, 0, 0);
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+		pSpellSprite.uAttributes = 0;
+		pSpellSprite.uSectorID = 0;
+		pSpellSprite.uSpriteFrameID = 0;
+		pSpellSprite.field_60_distance_related_prolly_lod = 0;
+		pSpellSprite.uFacing = 0;
+		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
+		pSpellSprite.vPosition.x = pActors[PID_ID(a2)].vPosition.x;
+		pSpellSprite.vPosition.y = pActors[PID_ID(a2)].vPosition.y;
+		pSpellSprite.vPosition.z = pActors[PID_ID(a2)].vPosition.z;
+		pSpellSprite.spell_target_pid = PID(OBJECT_Actor, (int)v726);
+		auto obj_id = pSpellSprite.Create(0, 0, 0, 0);
 		DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v704);
-
 		LODWORD(v727) = 1;
 		break;
-		}
-
-		case SPELL_LIGHT_DESTROY_UNDEAD:
-		{
+      }
+      case SPELL_LIGHT_DESTROY_UNDEAD:
+      {
 		if ( !pPlayer->CanCastSpell(uRequiredMana) || !a2 || PID_TYPE(a2) != OBJECT_Actor)
 			break;
 		//v730 = a2 >> 3;
@@ -3608,128 +3582,129 @@
 		v691.x = 0;
 		v691.y = 0;
 		v691.z = 0;
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-		a1.vPosition.x = pActors[PID_ID(a2)].vPosition.x;
-		a1.vPosition.y = pActors[PID_ID(a2)].vPosition.y;
-		a1.vPosition.z = pActors[PID_ID(a2)].vPosition.z;
-		a1.uAttributes = 0;
-		a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z);
-		a1.uSpriteFrameID = 0;
-		a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-		a1.spell_target_pid = a2;
-		a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
-		a1.uFacing = LOWORD(v715.uYawAngle);
-		a1.uAttributes |= 0x80u;
-		a1.uSoundID = LOWORD(v3->sound_id);
-
-		auto obj_id = a1.Create(0, 0, 0, 0);
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+		pSpellSprite.vPosition.x = pActors[PID_ID(a2)].vPosition.x;
+		pSpellSprite.vPosition.y = pActors[PID_ID(a2)].vPosition.y;
+		pSpellSprite.vPosition.z = pActors[PID_ID(a2)].vPosition.z;
+		pSpellSprite.uAttributes = 0;
+		pSpellSprite.uSectorID = pIndoor->GetSector(pSpellSprite.vPosition.x, pSpellSprite.vPosition.y, pSpellSprite.vPosition.z);
+		pSpellSprite.uSpriteFrameID = 0;
+		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+		pSpellSprite.spell_target_pid = a2;
+		pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
+		pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
+		pSpellSprite.uAttributes |= 0x80u;
+		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
+		auto obj_id = pSpellSprite.Create(0, 0, 0, 0);
 		if ( !MonsterStats::BelongsToSupertype(*(short *)(HIDWORD(v733) + 96), MONSTER_SUPERTYPE_UNDEAD) )
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v691);
 		LODWORD(v727) = 1;
 		break;
-		}
-
-
-		case SPELL_FIRE_FIRE_BOLT:
-		case SPELL_FIRE_FIREBALL:
-		case SPELL_FIRE_INCINERATE:
-		case SPELL_AIR_LIGHNING_BOLT:
-		case SPELL_WATER_ICE_BOLT:
-		case SPELL_WATER_ICE_BLAST:
-		case SPELL_EARTH_STUN:
-		case SPELL_EARTH_DEADLY_SWARM:
-		case SPELL_MIND_MIND_BLAST:
-		case SPELL_MIND_PSYCHIC_SHOCK:
-		case SPELL_BODY_HARM:
-		case SPELL_LIGHT_LIGHT_BOLT:
-		case SPELL_DARK_DRAGON_BREATH:
-			{
+      }
+      case SPELL_FIRE_FIRE_BOLT:
+      case SPELL_FIRE_FIREBALL:
+      case SPELL_FIRE_INCINERATE:
+      case SPELL_AIR_LIGHNING_BOLT:
+      case SPELL_WATER_ICE_BOLT:
+      case SPELL_WATER_ICE_BLAST:
+      case SPELL_EARTH_STUN:
+      case SPELL_EARTH_DEADLY_SWARM:
+      case SPELL_MIND_MIND_BLAST:
+      case SPELL_MIND_PSYCHIC_SHOCK:
+      case SPELL_BODY_HARM:
+      case SPELL_LIGHT_LIGHT_BOLT:
+      case SPELL_DARK_DRAGON_BREATH:
+      {
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
-			a1.stru_24.Reset();
-			a1.spell_id = v3->spellnum;
-			a1.spell_level = v2;
-			a1.spell_skill = v731;
-			a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-			a1.vPosition.y = pParty->vPosition.y;
-			a1.vPosition.x = pParty->vPosition.x;
-			a1.uAttributes = 0;
-			a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+			pSpellSprite.stru_24.Reset();
+			pSpellSprite.spell_id = pCastSpell->spellnum;
+			pSpellSprite.spell_level = v2;
+			pSpellSprite.spell_skill = v731;
+			pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+			pSpellSprite.vPosition.y = pParty->vPosition.y;
+			pSpellSprite.vPosition.x = pParty->vPosition.x;
+			pSpellSprite.uAttributes = 0;
+			pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
 			if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
-				a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x,
-												pParty->vPosition.y,
-												pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
-			else a1.uSectorID = 0;
-
-			a1.uSpriteFrameID = 0;
-			a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-			a1.spell_target_pid = a2;
-			a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
-			a1.uFacing = LOWORD(v715.uYawAngle);
-			a1.uSoundID = LOWORD(v3->sound_id);
+				pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
+			else
+				pSpellSprite.uSectorID = 0;
+			pSpellSprite.uSpriteFrameID = 0;
+			pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+			pSpellSprite.spell_target_pid = a2;
+			pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
+			pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
+			pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 			if ( pParty->bTurnBasedModeOn == 1 )
-				LOBYTE(a1.uAttributes) |= 4u;
-			if ( v3->spellnum == SPELL_AIR_LIGHNING_BOLT )
-				LOBYTE(a1.uAttributes) |= 0x40u;
-
-				v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
-				if ( a1.Create(v715.uYawAngle, v715.uPitchAngle, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
+				LOBYTE(pSpellSprite.uAttributes) |= 4u;
+			if ( pCastSpell->spellnum == SPELL_AIR_LIGHNING_BOLT )
+				LOBYTE(pSpellSprite.uAttributes) |= 0x40u;
+			v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
+			if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
 				++pTurnEngine->field_1C;
 			LODWORD(v727) = 1;
 			break;
-			}
-		case SPELL_WATER_ACID_BURST:
-		case SPELL_EARTH_BLADES:
-		case SPELL_BODY_FLYING_FIST:
-		case SPELL_DARK_TOXIC_CLOUD:
-			{
+      }
+      case SPELL_WATER_ACID_BURST:
+      case SPELL_EARTH_BLADES:
+      case SPELL_BODY_FLYING_FIST:
+      case SPELL_DARK_TOXIC_CLOUD:
+      {
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
-			a1.stru_24.Reset();
-			a1.spell_id = v3->spellnum;
-			a1.spell_level = v2;
-			a1.spell_skill = v731;
-			a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
+			pSpellSprite.stru_24.Reset();
+			pSpellSprite.spell_id = pCastSpell->spellnum;
+			pSpellSprite.spell_level = v2;
+			pSpellSprite.spell_skill = v731;
+			pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
 			v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
-			a1.vPosition.y = pParty->vPosition.y;
+			pSpellSprite.vPosition.y = pParty->vPosition.y;
 			v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
 			v660 = pParty->vPosition.y;
 			goto LABEL_153;
-			}
-		case SPELL_LIGHT_SUNRAY:
-			{
+      }
+      case SPELL_LIGHT_SUNRAY:
+      {
 			if ( uCurrentlyLoadedLevelType == LEVEL_Indoor
 				|| uCurrentlyLoadedLevelType == LEVEL_Outdoor && (pParty->uCurrentHour < 5 || pParty->uCurrentHour >= 0x15) )
 			{
 				ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
 				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-				v3->spellnum = 0;
+				pCastSpell->spellnum = 0;
 				continue;
 			}
 			if ( pPlayer->CanCastSpell(uRequiredMana) )
-				goto LABEL_152;
-			break;
-			}
-
-		case SPELL_LIGHT_PARALYZE:
-		{
+			{
+				pSpellSprite.stru_24.Reset();
+				pSpellSprite.spell_id = pCastSpell->spellnum;
+				pSpellSprite.spell_skill = v731;
+				pSpellSprite.spell_level = v2;
+				pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+				pSpellSprite.vPosition.y = pParty->vPosition.y;
+				v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+				v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+				v660 = pParty->vPosition.y;
+				goto LABEL_153;
+			}
+			break;
+      }
+      case SPELL_LIGHT_PARALYZE:
+      {
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
-
-		if (PID_TYPE(a2) != OBJECT_Actor ||
-			(v730 = PID_ID(a2),
-				v721 = (int)&pActors[PID_ID(a2)],
-				!stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 9u)) )
+		if (PID_TYPE(a2) != OBJECT_Actor || (v730 = PID_ID(a2), v721 = (int)&pActors[PID_ID(a2)],
+				!stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 9)) )
 		{
 		LODWORD(v727) = 1;
 		break;
@@ -3744,10 +3719,9 @@
 		*(short *)(v55 + 150) = 0;
 		v661 = (Actor *)v55;
 		goto LABEL_165;
-		}
-
-		case SPELL_EARTH_SLOW:
-			{
+      }
+      case SPELL_EARTH_SLOW:
+      {
 			if ( v731 == 2 )
 			{
 				v57 = 300 * v2;
@@ -3793,10 +3767,9 @@
 			v672 = 0;
 			v661 = (Actor *)LODWORD(v718);
 			goto LABEL_165;
-			}
-
-		case SPELL_MIND_CHARM:
-		{
+      }
+      case SPELL_MIND_CHARM:
+      {
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 
@@ -3821,50 +3794,49 @@
 		//((SpellBuff *)((char *)&pActors[0].pActorBuffs[1] + v730))->Apply(
 		pActors[PID_ID(a2)].pActorBuffs[1].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(power << 7) * 0.033333335),
 			v731, 0, 0, 0);
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		v60 = pObjectList->ObjectIDByItemID(a1.uType);
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
 		v61 = PID_ID(a2);
 		goto LABEL_1086;
-		}
-
-		case SPELL_DARK_SHRINKING_RAY:
-			{
+      }
+      case SPELL_DARK_SHRINKING_RAY:
+      {
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
-			a1.stru_24.Reset();
-			a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-			a1.vPosition.x = pParty->vPosition.x;
-			a1.vPosition.y = pParty->vPosition.y;
-			a1.uAttributes = 0;
-			a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
-			a1.uSectorID = pIndoor->GetSector(
+			pSpellSprite.stru_24.Reset();
+			pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+			pSpellSprite.vPosition.x = pParty->vPosition.x;
+			pSpellSprite.vPosition.y = pParty->vPosition.y;
+			pSpellSprite.uAttributes = 0;
+			pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+			pSpellSprite.uSectorID = pIndoor->GetSector(
 								pParty->vPosition.x,
 								pParty->vPosition.y,
 								pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
-			a1.uSpriteFrameID = 0;
-			a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-			a1.spell_target_pid = a2;
-			a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
-			a1.uFacing = LOWORD(v715.uYawAngle);
-			a1.uSoundID = LOWORD(v3->sound_id);
-			a1.spell_skill = v731;
-			a1.spell_id = SPELL_FIRE_PROTECTION_FROM_FIRE;
-			a1.spell_level = 300 * v2;
+			pSpellSprite.uSpriteFrameID = 0;
+			pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+			pSpellSprite.spell_target_pid = a2;
+			pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
+			pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
+			pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
+			pSpellSprite.spell_skill = v731;
+			pSpellSprite.spell_id = SPELL_FIRE_PROTECTION_FROM_FIRE;
+			pSpellSprite.spell_level = 300 * v2;
 				if ( pParty->bTurnBasedModeOn == 1 )
-				LOBYTE(a1.uAttributes) |= 4u;
-
-				v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
-
-				if ( a1.Create(v715.uYawAngle, v715.uPitchAngle, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
+				LOBYTE(pSpellSprite.uAttributes) |= 4u;
+
+				v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
+
+				if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
 				++pTurnEngine->field_1C;
 			LODWORD(v727) = 1;
 			break;
-			}
-		case SPELL_FIRE_FIRE_AURA:
-			{
+      }
+      case SPELL_FIRE_FIRE_AURA:
+      {
 			v63 = v731 - 1;
 			if ( !v63 )
 			{
@@ -3898,7 +3870,7 @@
 	LABEL_196:
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
-			v730c = &pParty->pPlayers[v3->uPlayerID_2].pInventoryItems[a2];
+			v730c = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItems[a2];
 			auto _itm = &pItemsTable->pItems[v730c->uItemID];
 			v730c->UpdateTempBonus(pParty->uTimePlayed);
 			if ( v730c->uItemID < 64 || v730c->uItemID > 65 
@@ -3930,12 +3902,11 @@
 
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
-			}
-
-		case SPELL_BODY_REGENERATION:
-		{
+      }
+      case SPELL_BODY_REGENERATION:
+      {
 		v70 = v731 - 1;
 		LODWORD(v733) = 3600 * v2;
 		if ( v70 && (v71 = v70 - 1) != 0 )
@@ -3958,90 +3929,87 @@
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2);
-
-		pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_REGENERATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)v733 * 4.2666669), v731, amount, 0, 0);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
+
+		pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_REGENERATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)v733 * 4.2666669), v731, amount, 0, 0);
 		LODWORD(v727) = 1;
 		break;
-		}
-
-		case SPELL_FIRE_PROTECTION_FROM_FIRE:
-		case SPELL_AIR_PROTECTION_FROM_AIR:
-		case SPELL_WATER_PROTECTION_FROM_WATER:
-		case SPELL_EARTH_PROTECTION_FROM_EARTH:
-		case SPELL_MIND_PROTECTION_FROM_MIND:
-		case SPELL_BODY_PROTECTION_FROM_BODY:
-			{
-			v76 = v731 - 1;
-			LODWORD(v733) = 3600 * v2;
-			if ( v76 )
-			{
-				v77 = v76 - 1;
-				if ( v77 )
-				{
-				v78 = v77 - 1;
-				if ( v78 )
-				{
-					if ( v78 != 1 )
-					goto LABEL_232;
-					v79 = 4 * v2;
-				}
-				else
-				{
-					v79 = 3 * v2;
-				}
-				}
-				else
-				{
-				v79 = 2 * v2;
-				}
-				amount = v79;
-			}
-			else
-			{
-				amount = v2;
-			}
-	LABEL_232:
-			//v80 = v3->spellnum;
-			switch (v3->spellnum)
-			{
-				case SPELL_FIRE_PROTECTION_FROM_FIRE:
-				LODWORD(v725) = PARTY_BUFF_RESIST_FIRE;
-				break;
-				case SPELL_AIR_PROTECTION_FROM_AIR:
-				LODWORD(v725) = PARTY_BUFF_RESIST_AIR;
-				break;
-				case SPELL_WATER_PROTECTION_FROM_WATER:
-				LODWORD(v725) = PARTY_BUFF_RESIST_WATER;
-				break;
-				case SPELL_EARTH_PROTECTION_FROM_EARTH:
-				LODWORD(v725) = PARTY_BUFF_RESIST_EARTH;
-				break;
-				case SPELL_MIND_PROTECTION_FROM_MIND:
-				LODWORD(v725) = PARTY_BUFF_RESIST_MIND;
-				break;
-				case SPELL_BODY_PROTECTION_FROM_BODY:
-				LODWORD(v725) = PARTY_BUFF_RESIST_BODY;
-				break;
-				default:
-				assert(false);
-				continue;
-			}
-			if ( !pPlayer->CanCastSpell(uRequiredMana) )
-				break;
-
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3);
-
-			v90 = (double)(signed int)v733 * 4.2666669;
-			pParty->pPartyBuffs[LODWORD(v725)].Apply(pParty->uTimePlayed + (signed int)(signed __int64)v90, v731, amount, 0, 0);
-			LODWORD(v727) = 1;
-			break;
-			}
-		case SPELL_FIRE_HASTE:
-			{
+      }
+      case SPELL_FIRE_PROTECTION_FROM_FIRE:
+      case SPELL_AIR_PROTECTION_FROM_AIR:
+      case SPELL_WATER_PROTECTION_FROM_WATER:
+      case SPELL_EARTH_PROTECTION_FROM_EARTH:
+      case SPELL_MIND_PROTECTION_FROM_MIND:
+      case SPELL_BODY_PROTECTION_FROM_BODY:
+      {
+        v76 = v731 - 1;
+        LODWORD(v733) = 3600 * v2;
+        if ( v76 )
+        {
+          v77 = v76 - 1;
+          if ( v77 )
+          {
+            v78 = v77 - 1;
+            if ( v78 )
+            {
+              if ( v78 != 1 )
+                goto LABEL_232;
+              v79 = 4 * v2;
+            }
+            else
+            {
+              v79 = 3 * v2;
+            }
+          }
+          else
+          {
+            v79 = 2 * v2;
+          }
+          amount = v79;
+        }
+        else
+        {
+          amount = v2;
+        }
+LABEL_232:
+        //v80 = v3->spellnum;
+        switch (pCastSpell->spellnum)
+        {
+          case SPELL_FIRE_PROTECTION_FROM_FIRE:
+            LODWORD(v725) = PARTY_BUFF_RESIST_FIRE;
+            break;
+          case SPELL_AIR_PROTECTION_FROM_AIR:
+            LODWORD(v725) = PARTY_BUFF_RESIST_AIR;
+            break;
+          case SPELL_WATER_PROTECTION_FROM_WATER:
+            LODWORD(v725) = PARTY_BUFF_RESIST_WATER;
+            break;
+          case SPELL_EARTH_PROTECTION_FROM_EARTH:
+            LODWORD(v725) = PARTY_BUFF_RESIST_EARTH;
+            break;
+          case SPELL_MIND_PROTECTION_FROM_MIND:
+            LODWORD(v725) = PARTY_BUFF_RESIST_MIND;
+            break;
+          case SPELL_BODY_PROTECTION_FROM_BODY:
+            LODWORD(v725) = PARTY_BUFF_RESIST_BODY;
+            break;
+          default:
+            assert(false);
+            continue;
+        }
+        if ( !pPlayer->CanCastSpell(uRequiredMana) )
+          break;
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
+        v90 = (double)(signed int)v733 * 4.2666669;
+        pParty->pPartyBuffs[LODWORD(v725)].Apply(pParty->uTimePlayed + (signed int)(signed __int64)v90, v731, amount, 0, 0);
+        LODWORD(v727) = 1;
+        break;
+      }
+      case SPELL_FIRE_HASTE:
+      {
 			if ( v731 <= 0 )
 				goto LABEL_254;
 			if ( v731 <= 2 )
@@ -4078,16 +4046,16 @@
 				{
 				pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0);
 
-				pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0);
-				pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1);
-				pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2);
-				pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3);
+				pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
+				pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
+				pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
+				pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
 				}
 			}
 			break;
-			}
-		case SPELL_SPIRIT_BLESS:
-			{
+      }
+      case SPELL_SPIRIT_BLESS:
+      {
 			v101 = v731 - 1;
 			if ( v101 && (v102 = v101 - 1) != 0 )
 			{
@@ -4114,11 +4082,11 @@
 				break;
 			if ( v731 == 1 )
 			{
-				v108 = v3->uPlayerID_2;
-				v109 = v3->spellnum;
+				v108 = pCastSpell->uPlayerID_2;
+				v109 = pCastSpell->spellnum;
 				v110 = pGame->GetStru6();
 				pGame->GetStru6()->SetPlayerBuffAnim(v109, v108);
-				v111 = pOtherOverlayList->_4418B1(10000, v3->uPlayerID_2 + 310, 0, 65536);
+				v111 = pOtherOverlayList->_4418B1(10000, pCastSpell->uPlayerID_2 + 310, 0, 65536);
 				//v668 = 0;
 				v716 = v111;
 				//v658 = v111;
@@ -4130,7 +4098,7 @@
 			//HIDWORD(v650) = HIDWORD(v28);
 	//LABEL_104:
 			//LODWORD(v650) = v28;
-			pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_BLESS].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), 1, amount, v111, 0);
+			pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_BLESS].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), 1, amount, v111, 0);
 			LODWORD(v727) = 1;
 			break;
 			}
@@ -4139,7 +4107,7 @@
 			v730b = pParty->pPlayers;//[0].pPlayerBuffs[1];
 			do
 			{
-				pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v105);
+				pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, v105);
 				v716 = pOtherOverlayList->_4418B1(10000, v105 + 310, 0, 65536);
 				v730b->pPlayerBuffs[1].Apply(pParty->uTimePlayed + v717, v731, amount, v716, 0);
 				++v730b;
@@ -4185,24 +4153,24 @@
 				v701.x = 0;
 				v701.y = 0;
 				v701.z = 0;
-				a1.stru_24.Reset();
+				pSpellSprite.stru_24.Reset();
 				v119 = HIDWORD(v733);
-				a1.spell_id = *(int *)HIDWORD(v733);
-				a1.spell_level = v723;
-				a1.spell_skill = v731;
-				a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-				a1.uAttributes = 0;
-				a1.uSectorID = 0;
-				a1.uSpriteFrameID = 0;
-				a1.field_60_distance_related_prolly_lod = 0;
-				a1.spell_caster_pid = PID(OBJECT_Player, *(short *)(v119 + 2));
-				a1.uFacing = 0;
-				a1.uSoundID = *(short *)(v119 + 16);
-				a1.vPosition.x = v112->vPosition.x;
-				a1.vPosition.y = v112->vPosition.y;
-				a1.vPosition.z = v112->vPosition.z - (unsigned int)(signed __int64)((double)(signed int)v112->uActorHeight * unk_4D8548);
-				a1.spell_target_pid = PID(OBJECT_Actor, a2);
-				v122 = a1.Create(0, 0, 0, 0);
+				pSpellSprite.spell_id = *(int *)HIDWORD(v733);
+				pSpellSprite.spell_level = v723;
+				pSpellSprite.spell_skill = v731;
+				pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+				pSpellSprite.uAttributes = 0;
+				pSpellSprite.uSectorID = 0;
+				pSpellSprite.uSpriteFrameID = 0;
+				pSpellSprite.field_60_distance_related_prolly_lod = 0;
+				pSpellSprite.spell_caster_pid = PID(OBJECT_Player, *(short *)(v119 + 2));
+				pSpellSprite.uFacing = 0;
+				pSpellSprite.uSoundID = *(short *)(v119 + 16);
+				pSpellSprite.vPosition.x = v112->vPosition.x;
+				pSpellSprite.vPosition.y = v112->vPosition.y;
+				pSpellSprite.vPosition.z = v112->vPosition.z - (unsigned int)(signed __int64)((double)(signed int)v112->uActorHeight * unk_4D8548);
+				pSpellSprite.spell_target_pid = PID(OBJECT_Actor, a2);
+				v122 = pSpellSprite.Create(0, 0, 0, 0);
 				DamageMonsterFromParty(PID(OBJECT_Item, v122), PID_ID(a2), &v701);
 				LODWORD(v727) = 1;
 				}
@@ -4212,7 +4180,7 @@
 				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
 				*(int *)HIDWORD(v733) = 0;
 				}
-				v3 = (stru277 *)HIDWORD(v733);
+				pCastSpell = (CastSpellInfo *)HIDWORD(v733);
 			}
 			break;
 		}
@@ -4241,7 +4209,7 @@
 			}
 			LODWORD(v733) = v126;
 	LABEL_296:
-			v127 = v3->spellnum;
+			v127 = pCastSpell->spellnum;
 			if ( v127 == 17 )
 			{
 				amount = 0;
@@ -4264,10 +4232,10 @@
 			}
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
 			v90 = (double)(signed int)((int)v733 << 7) * 0.033333335;
 	//LABEL_304:
 			pParty->pPartyBuffs[LODWORD(v725)].Apply(pParty->uTimePlayed + (signed int)(signed __int64)v90, v731, amount, 0, 0);
@@ -4285,10 +4253,10 @@
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
 
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
 
 			pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, 0, 0);
 			LODWORD(v727) = 1;
@@ -4310,7 +4278,7 @@
 			{
 				ShowStatusBarString(pGlobalTXT_LocalizationStrings[491], 2);  // Can't cast Meteor Shower indoors!
 				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-				v3->spellnum = 0;
+				pCastSpell->spellnum = 0;
 				continue;
 			}
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
@@ -4343,13 +4311,13 @@
 				auto _this_cpy = (int)_this;
 				do
 				{
-				v157 = rand();
+				//v157 = rand();
 				v158 = (double)SLODWORD(v718);
 				v718 = v158;
 				v159 = (double)v721;
 				*(float *)&v721 = v159;
-				a2 = v157 % 1000;
-				*((float *)&v733 + 1) = (double)(v157 % 1000) + *(float *)&y - *(float *)&v732;
+				a2 = rand() % 1000;
+				*((float *)&v733 + 1) = (double)(rand() % 1000) + *(float *)&y - *(float *)&v732;
 				v725 = v159 * v159;
 				*(float *)&_this = v158 * v158;
 				if ( sqrt(*((float *)&v733 + 1) * *((float *)&v733 + 1) + *(float *)&_this + v725) <= 1.0 )
@@ -4364,35 +4332,31 @@
 							stru_5C6E00->Atan2(x, (signed __int64)*((float *)&v733 + 1)),
 							stru_5C6E00->Atan2((signed __int64)v718, (signed __int64)*(float *)&v721));
 				}
-				a1.stru_24.Reset();
-				a1.spell_id = v3->spellnum;
-				a1.spell_level = v2;
-				a1.spell_skill = v731;
-				a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-				a1.uAttributes = 0;
-				a1.vPosition.x = uRequiredMana;
-				a1.vPosition.y = LODWORD(v727);
-				a1.uSectorID = 0;
-				a1.vPosition.z = a2 + v713;
-				a1.uSpriteFrameID = 0;
-				a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-				a1.spell_target_pid = v730;
-				a1.field_60_distance_related_prolly_lod = stru_50C198._427546(a2 + 2500);
-				a1.uFacing = v687;
-				a1.uSoundID = LOWORD(v3->sound_id);
+				pSpellSprite.stru_24.Reset();
+				pSpellSprite.spell_id = pCastSpell->spellnum;
+				pSpellSprite.spell_level = v2;
+				pSpellSprite.spell_skill = v731;
+				pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+				pSpellSprite.uAttributes = 0;
+				pSpellSprite.vPosition.x = uRequiredMana;
+				pSpellSprite.vPosition.y = LODWORD(v727);
+				pSpellSprite.uSectorID = 0;
+				pSpellSprite.vPosition.z = a2 + v713;
+				pSpellSprite.uSpriteFrameID = 0;
+				pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+				pSpellSprite.spell_target_pid = v730;
+				pSpellSprite.field_60_distance_related_prolly_lod = stru_50C198._427546(a2 + 2500);
+				pSpellSprite.uFacing = v687;
+				pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 				if ( pParty->bTurnBasedModeOn == 1 )
-					a1.uAttributes = 4;
-				if ( a1.Create(
-						v687,
-						SHIDWORD(v687),
-						pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
-						0) != -1
+					pSpellSprite.uAttributes = 4;
+				if ( pSpellSprite.Create(v687, SHIDWORD(v687), pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, 0) != -1
 					&& pParty->bTurnBasedModeOn == 1 )
 					++pTurnEngine->field_1C;
 				LODWORD(v718) = rand() % 1024 - 512;
-				v160 = rand();
+				//v160 = rand();
 				v14 = _this_cpy-- == 1;
-				v721 = (unsigned __int64)(v160 % 1024) - 512;
+				v721 = (unsigned __int64)(rand() % 1024) - 512;
 				}
 				while ( !v14 );
 			}
@@ -4406,7 +4370,7 @@
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[492], 2); // Can't cast Inferno outdoors!
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
@@ -4415,32 +4379,32 @@
 		v700.z = 0;
 		v700.y = 0;
 		v700.x = 0;
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-		a1.uAttributes = 0;
-		a1.uSectorID = 0;
-		a1.uSpriteFrameID = 0;
-		a1.field_60_distance_related_prolly_lod = 0;
-		a1.uFacing = 0;
-		a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-		a1.uSoundID = LOWORD(v3->sound_id);
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+		pSpellSprite.uAttributes = 0;
+		pSpellSprite.uSectorID = 0;
+		pSpellSprite.uSpriteFrameID = 0;
+		pSpellSprite.field_60_distance_related_prolly_lod = 0;
+		pSpellSprite.uFacing = 0;
+		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 		a2 = 0;
 		if ( (signed int)_v726 > 0 )
 		{
 			do
 			{
 			v162 = dword_50BF30[a2];
-			a1.vPosition.x = pActors[v162].vPosition.x;
-			a1.vPosition.y = pActors[v162].vPosition.y;
-			a1.vPosition.z = pActors[v162].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v162].uActorHeight * unk_4D8548);
-			a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
-			v164 = a1.Create(0, 0, 0, 0);
+			pSpellSprite.vPosition.x = pActors[v162].vPosition.x;
+			pSpellSprite.vPosition.y = pActors[v162].vPosition.y;
+			pSpellSprite.vPosition.z = pActors[v162].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v162].uActorHeight * unk_4D8548);
+			pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
+			v164 = pSpellSprite.Create(0, 0, 0, 0);
 			v165 = a2;
 			DamageMonsterFromParty(PID(OBJECT_Item, v164), dword_50BF30[a2], &v700);
-			pGame->GetStru6()->_4A81CA(&a1);
+			pGame->GetStru6()->_4A81CA(&pSpellSprite);
 			pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFF3C1Eu, 0x40u);
 			a2 = v165 + 1;
 			}
@@ -4494,10 +4458,10 @@
 			do
 				pOtherOverlayList->_4418B1(2010, v174++ + 100, 0, 65536);
 			while ( v174 < 4 );
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
 
 			pParty->pPartyBuffs[PARTY_BUFF_FEATHER_FALL].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0);
 			LODWORD(v727) = 1;
@@ -4534,36 +4498,36 @@
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 		auto _v726 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-		a1.vPosition.y = pParty->vPosition.y;
-		a1.vPosition.x = pParty->vPosition.x;
-		a1.uAttributes = 0;
-		a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
-		a1.uSectorID = pIndoor->GetSector(
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+		pSpellSprite.vPosition.y = pParty->vPosition.y;
+		pSpellSprite.vPosition.x = pParty->vPosition.x;
+		pSpellSprite.uAttributes = 0;
+		pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+		pSpellSprite.uSectorID = pIndoor->GetSector(
 							pParty->vPosition.x,
 							pParty->vPosition.y,
 							pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
-		a1.uSpriteFrameID = 0;
-		a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-		a1.spell_target_pid = a2;
-		a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
-		a1.uSoundID = LOWORD(v3->sound_id);
+		pSpellSprite.uSpriteFrameID = 0;
+		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+		pSpellSprite.spell_target_pid = a2;
+		pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
+		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 		if ( pParty->bTurnBasedModeOn == 1 )
-			LOBYTE(a1.uAttributes) |= 4u;
+			LOBYTE(pSpellSprite.uAttributes) |= 4u;
 		v188 = (signed int)_v726 / -2;
 		v189 = (signed int)_v726 / 2;
 		while ( v188 <= v189 )
 		{
-			a1.uFacing = v188 + LOWORD(v715.uYawAngle);
-			if ( a1.Create(
+			pSpellSprite.uFacing = v188 + LOWORD(v715.uYawAngle);
+			if ( pSpellSprite.Create(
 					(signed __int16)(v188 + LOWORD(v715.uYawAngle)),
 					v715.uPitchAngle,
-					pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
-					v3->uPlayerID + 1) != -1
+					pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed,
+					pCastSpell->uPlayerID + 1) != -1
 			&& pParty->bTurnBasedModeOn == 1 )
 			++pTurnEngine->field_1C;
 			v188 += _v726 / (amount - 1);
@@ -4597,15 +4561,17 @@
 			if ( !v192 )
 			{
 				amount = v2;
-				goto LABEL_391;
+				//goto LABEL_391;
+				v195 = 600 * v2;
+				goto LABEL_392;
 			}
 			v193 = v192 - 1;
 			if ( !v193 )
 			{
 				v196 = 2 * v2;
-	LABEL_389:
+	//LABEL_389:
 				amount = v196;
-	LABEL_391:
+	//LABEL_391:
 				v195 = 600 * v2;
 				goto LABEL_392;
 			}
@@ -4613,7 +4579,10 @@
 			if ( !v194 )
 			{
 				v196 = 3 * v2;
-				goto LABEL_389;
+				//goto LABEL_389;
+				amount = v196;
+				v195 = 600 * v2;
+				goto LABEL_392;
 			}
 			if ( v194 != 1 )
 				goto LABEL_393;
@@ -4626,15 +4595,15 @@
 			{
 				ShowStatusBarString(pGlobalTXT_LocalizationStrings[638], 2);  // There are hostile creatures nearby!
 				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-				v3->spellnum = 0;
+				pCastSpell->spellnum = 0;
 				continue;
 			}
 			if ( pPlayer->CanCastSpell(uRequiredMana) )
 			{
-				pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0);
-				pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1);
-				pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2);
-				pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3);
+				pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
+				pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
+				pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
+				pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
 
 				pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, 0, 0);
 				LODWORD(v727) = 1;
@@ -4649,7 +4618,7 @@
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
 			break;
 		}
-		if ( !pPlayers[v3->uPlayerID + 1]->GetMaxMana() )
+		if ( !pPlayers[pCastSpell->uPlayerID + 1]->GetMaxMana() )
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);  // Spell failed
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
@@ -4665,7 +4634,7 @@
 			pOtherOverlayList->_4418B1(2090, v205++ + 100, 0, 65536);
 		while ( v205 < 4 );
 		v206 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536);
-		v207 = v3->uPlayerID + 1;
+		v207 = pCastSpell->uPlayerID + 1;
 		v716 = v206;
 
 		pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, v206, v207);
@@ -4680,7 +4649,7 @@
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[495], 2);  // Can't cast Starburst indoors!
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
@@ -4734,32 +4703,28 @@
 						stru_5C6E00->Atan2(v684, (signed __int64)*((float *)&v733 + 1)),
 						stru_5C6E00->Atan2((signed __int64)v216, (signed __int64)*(float *)&uRequiredMana));
 			}
-			a1.stru_24.Reset();
-			a1.spell_id = v3->spellnum;
-			a1.spell_level = v2;
-			a1.spell_skill = v731;
-			a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-			a1.uAttributes = 0;
-			a1.vPosition.x = LODWORD(v718);
-			a1.vPosition.y = v713;
-			a1.uSectorID = 0;
-			a1.vPosition.z = (int)((char *)_this + LODWORD(v725));
-			a1.uSpriteFrameID = 0;
-			a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-			a1.spell_target_pid = v730;
-			__debugbreak();
-			a1.field_60_distance_related_prolly_lod = stru_50C198._427546((int)&_this[69].uNumCharges);
-			a1.uFacing = v685;
-			a1.uSoundID = LOWORD(v3->sound_id);
+			pSpellSprite.stru_24.Reset();
+			pSpellSprite.spell_id = pCastSpell->spellnum;
+			pSpellSprite.spell_level = v2;
+			pSpellSprite.spell_skill = v731;
+			pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+			pSpellSprite.uAttributes = 0;
+			pSpellSprite.vPosition.x = LODWORD(v718);
+			pSpellSprite.vPosition.y = v713;
+			pSpellSprite.uSectorID = 0;
+			pSpellSprite.vPosition.z = (int)((char *)_this + LODWORD(v725));
+			pSpellSprite.uSpriteFrameID = 0;
+			pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+			pSpellSprite.spell_target_pid = v730;
+			//__debugbreak();//
+			pSpellSprite.field_60_distance_related_prolly_lod = stru_50C198._427546((int)&_this[69].uNumCharges);
+			pSpellSprite.uFacing = v685;
+			pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 			if ( pParty->bTurnBasedModeOn == 1 )
-			a1.uAttributes = 4;
-			if ( a1.Create(
-					v685,
-					SHIDWORD(v685),
-					pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
-					0) != -1
-			&& pParty->bTurnBasedModeOn == 1 )
-			++pTurnEngine->field_1C;
+			pSpellSprite.uAttributes = 4;
+			if ( pSpellSprite.Create(v685, SHIDWORD(v685), pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, 0) != -1
+                   && pParty->bTurnBasedModeOn == 1 )
+              ++pTurnEngine->field_1C;
 			v721 = rand() % 1024 - 512;
 			v218 = rand();
 			v14 = a2-- == 1;
@@ -4857,59 +4822,52 @@
 			HIDWORD(v733) = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
 			if ( amount == 1 )
 			{
-	LABEL_152:
-				a1.stru_24.Reset();
-				a1.spell_id = v3->spellnum;
-				a1.spell_skill = v731;
-				a1.spell_level = v2;
-				a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-				a1.vPosition.y = pParty->vPosition.y;
+				pSpellSprite.stru_24.Reset();
+				pSpellSprite.spell_id = pCastSpell->spellnum;
+				pSpellSprite.spell_skill = v731;
+				pSpellSprite.spell_level = v2;
+				pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+				pSpellSprite.vPosition.y = pParty->vPosition.y;
 				v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
 				v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
 				v660 = pParty->vPosition.y;
 	LABEL_153:
-				a1.uAttributes = 0;
-				a1.vPosition.x = pParty->vPosition.x;
-				a1.vPosition.z = v51;
+				pSpellSprite.uAttributes = 0;
+				pSpellSprite.vPosition.x = pParty->vPosition.x;
+				pSpellSprite.vPosition.z = v51;
 				v52 = pIndoor->GetSector(pParty->vPosition.x, v660, v671);
-				a1.uSpriteFrameID = 0;
-				a1.uSectorID = v52;
-				a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-				a1.spell_target_pid = a2;
-				a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
-				a1.uFacing = LOWORD(v715.uYawAngle);
-				a1.uSoundID = LOWORD(v3->sound_id);
-
+				pSpellSprite.uSpriteFrameID = 0;
+				pSpellSprite.uSectorID = v52;
+				pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+				pSpellSprite.spell_target_pid = a2;
+				pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
+				pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
+				pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 				if ( pParty->bTurnBasedModeOn == 1 )
-				LOBYTE(a1.uAttributes) |= 4u;
-
-				v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
-
-				if ( a1.Create(v715.uYawAngle, v715.uPitchAngle, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
-				++pTurnEngine->field_1C;
+					LOBYTE(pSpellSprite.uAttributes) |= 4u;
+				v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
+				if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
+					++pTurnEngine->field_1C;
 			}
 			else
 			{
-				a1.stru_24.Reset();
-				a1.spell_id = v3->spellnum;
-				a1.spell_level = v2;
-				a1.spell_skill = v731;
-				a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-				a1.vPosition.y = pParty->vPosition.y;
-				a1.vPosition.x = pParty->vPosition.x;
-				a1.uAttributes = 0;
-				a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
-				a1.uSectorID = pIndoor->GetSector(
-								pParty->vPosition.x,
-								pParty->vPosition.y,
-								pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
-				a1.uSpriteFrameID = 0;
-				a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-				a1.spell_target_pid = a2;
-				a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
-				a1.uSoundID = LOWORD(v3->sound_id);
+				pSpellSprite.stru_24.Reset();
+				pSpellSprite.spell_id = pCastSpell->spellnum;
+				pSpellSprite.spell_level = v2;
+				pSpellSprite.spell_skill = v731;
+				pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+				pSpellSprite.vPosition.y = pParty->vPosition.y;
+				pSpellSprite.vPosition.x = pParty->vPosition.x;
+				pSpellSprite.uAttributes = 0;
+				pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+				pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
+				pSpellSprite.uSpriteFrameID = 0;
+				pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+				pSpellSprite.spell_target_pid = a2;
+				pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
+				pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 				if ( pParty->bTurnBasedModeOn == 1 )
-				LOBYTE(a1.uAttributes) |= 4u;
+				LOBYTE(pSpellSprite.uAttributes) |= 4u;
 				v227 = SHIDWORD(v733) / -2;
 				y = (char *)(SHIDWORD(v733) / 2);
 				if ( SHIDWORD(v733) / -2 <= SHIDWORD(v733) / 2 )
@@ -4917,12 +4875,12 @@
 				v228 = v715.uYawAngle;
 				do
 				{
-					a1.uFacing = v227 + v228;
-					if ( a1.Create(
+					pSpellSprite.uFacing = v227 + v228;
+					if ( pSpellSprite.Create(
 							v227 + v228,
 							v715.uPitchAngle,
-							pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
-							v3->uPlayerID + 1) != -1
+							pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed,
+							pCastSpell->uPlayerID + 1) != -1
 					&& pParty->bTurnBasedModeOn == 1 )
 					++pTurnEngine->field_1C;
 					v227 += SHIDWORD(v733) / (amount - 1);
@@ -4935,7 +4893,7 @@
 		}
 		case SPELL_WATER_WATER_WALK:
 			{
-		if ( !pPlayers[v3->uPlayerID + 1]->GetMaxMana() )
+		if ( !pPlayers[pCastSpell->uPlayerID + 1]->GetMaxMana() )
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);  // Spell failed
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
@@ -4949,17 +4907,17 @@
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 		v716 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536);
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0);
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1);
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2);
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
 
 		pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply(
 			pParty->uTimePlayed + (signed int)(signed __int64)((double)(v229 << 7) * 0.033333335),
 			v731,
 			amount,
 			v716,
-			v3->uPlayerID + 1);
+			pCastSpell->uPlayerID + 1);
 		if ( v731 == 4 )
 			pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags = 1;
 		LODWORD(v727) = 1;
@@ -4969,7 +4927,7 @@
 			{
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
-		v240 = (char *)&pParty->pPlayers[v3->uPlayerID_2].pInventoryItems[a2];
+		v240 = (char *)&pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItems[a2];
 		y = v240;
 		if ( pItemsTable->pItems[*(int *)v240].uEquipType != 12 || v240[20] & 2 )
 		{
@@ -4979,7 +4937,7 @@
 
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);  // Spell failed
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		if ( v731 == 1 || v731 == 2 )
@@ -5018,7 +4976,7 @@
 			dword_50C9D8 = 1;
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u);
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			v2 = v723;
 			continue;
 		}
@@ -5034,7 +4992,7 @@
 		uRequiredMana = 0;
 		HIDWORD(v733) = 10 * v2;
 		v730 = 1;
-		v244 = (char *)&pParty->pPlayers[v3->uPlayerID_2];
+		v244 = (char *)&pParty->pPlayers[pCastSpell->uPlayerID_2];
 		if ( v731 == 1 )
 		{
 			v245 = (int)&v244[36 * a2 + 532];
@@ -5097,7 +5055,7 @@
 								LODWORD(v727) = 1;
 								break;
 							}
-							goto LABEL_615;
+							goto LABEL_616;
 							}
 LABEL_613:
 							v316 = _this->uItemID;
@@ -5122,9 +5080,8 @@
 				v317 = pGlobalTXT_LocalizationStrings[585];
 			ShowStatusBarString(v317, 2u);
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			__debugbreak(); // decompilation error;  most probably v318 is the caster, filled in case 54
-			//v318 = v726;
-			v3->spellnum = 0;
+			v318 =  &pParty->pPlayers[pCastSpell->uPlayerID_2];
+			pCastSpell->spellnum = 0;
 			v318->PlaySound(SPEECH_43, 0);
 			}
 			break;
@@ -5227,7 +5184,8 @@
 					break;
 				}
 				}
-				goto LABEL_525;
+				++*(int *)(v245 + 12);
+				goto LABEL_612;
 			}
 			}
 			else
@@ -5326,12 +5284,10 @@
 					break;
 				}
 				}
-LABEL_525:
 				++*(int *)(v245 + 12);
 				goto LABEL_612;
 			}
 			}
-LABEL_615:
 			//v1 = 0;
 			goto LABEL_616;
 		}
@@ -5360,7 +5316,7 @@
 
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		v292 = *(char *)(LODWORD(v725) + 28);
@@ -5375,7 +5331,7 @@
 
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		if ( rand() % 100 >= 80 )
@@ -5460,10 +5416,10 @@
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
-		town_portal_caster_id = LOBYTE(v3->uPlayerID);
+		town_portal_caster_id = LOBYTE(pCastSpell->uPlayerID);
 		pMessageQueue_50CBD0->AddMessage(UIMSG_OnCastTownPortal, 0, 0);
 		LODWORD(v727) = 1;
 		break;
@@ -5475,7 +5431,7 @@
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		v319 = uRequiredMana;
@@ -5484,12 +5440,12 @@
 			pEventTimer->Pause();
 			pMessageQueue_50CBD0->AddMessage(UIMSG_B1, 0, 0);
 			qword_506350 = (signed int)v733;
-			_506348_current_lloyd_playerid = v3->uPlayerID;
+			_506348_current_lloyd_playerid = pCastSpell->uPlayerID;
 			::uRequiredMana = v319;
 			::sRecoveryTime = sRecoveryTime;
-			dword_50633C = v3->sound_id;
-			dword_506338 = v3->spellnum;
-			LOBYTE(v3->field_8) |= 0x20u;
+			dword_50633C = pCastSpell->sound_id;
+			dword_506338 = pCastSpell->spellnum;
+			LOBYTE(pCastSpell->field_8) |= 0x20u;
 		}
 		break;
 			}
@@ -5514,7 +5470,7 @@
 LABEL_634:
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
-		v323 = v3->uPlayerID_2;
+		v323 = pCastSpell->uPlayerID_2;
 		v324 = (char *)&pParty->pPlayers[v323].pConditions[15];
 		if ( !pParty->pPlayers[v323].pConditions[15] )
 		{
@@ -5531,36 +5487,37 @@
 		v732 = amount << 7;
 		v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335);
 		v656 = 15;
-		goto LABEL_640;
+		v325 = &pParty->pPlayers[v323];
+		goto LABEL_641;
 		}
 		case SPELL_EARTH_ROCK_BLAST:
 			{
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-		a1.vPosition.y = pParty->vPosition.y;
-		a1.vPosition.x = pParty->vPosition.x;
-		a1.uAttributes = 0;
-		a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
-		a1.uSectorID = pIndoor->GetSector(
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+		pSpellSprite.vPosition.y = pParty->vPosition.y;
+		pSpellSprite.vPosition.x = pParty->vPosition.x;
+		pSpellSprite.uAttributes = 0;
+		pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+		pSpellSprite.uSectorID = pIndoor->GetSector(
 							pParty->vPosition.x,
 							pParty->vPosition.y,
 							pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
-		a1.uSpriteFrameID = 0;
-		a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-		a1.spell_target_pid = a2;
-		a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
-		a1.uFacing = LOWORD(pParty->sRotationY);
-		a1.uSoundID = LOWORD(v3->sound_id);
+		pSpellSprite.uSpriteFrameID = 0;
+		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+		pSpellSprite.spell_target_pid = a2;
+		pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
+		pSpellSprite.uFacing = LOWORD(pParty->sRotationY);
+		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 		if ( pParty->bTurnBasedModeOn == 1 )
-			LOBYTE(a1.uAttributes) |= 4u;
-
-		v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
-			if ( a1.Create(pParty->sRotationY, pParty->sRotationX, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
+			LOBYTE(pSpellSprite.uAttributes) |= 4u;
+
+		v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
+			if ( pSpellSprite.Create(pParty->sRotationY, pParty->sRotationX, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 )
 			++pTurnEngine->field_1C;
 		LODWORD(v727) = 1;
 		break;
@@ -5571,33 +5528,33 @@
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
-		a1.uType = 4090;
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-		a1.vPosition.x = pParty->vPosition.x;
-		a1.vPosition.y = pParty->vPosition.y;
-		a1.uAttributes = 0;
-		a1.uSectorID = 0;
-		a1.uSpriteFrameID = 0;
-		a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
-		a1.field_60_distance_related_prolly_lod = 0;
-		a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-		a1.spell_target_pid = a2;
-		a1.uFacing = LOWORD(pParty->sRotationY);
-		a1.uSoundID = LOWORD(v3->sound_id);
+		pSpellSprite.uType = 4090;
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+		pSpellSprite.vPosition.x = pParty->vPosition.x;
+		pSpellSprite.vPosition.y = pParty->vPosition.y;
+		pSpellSprite.uAttributes = 0;
+		pSpellSprite.uSectorID = 0;
+		pSpellSprite.uSpriteFrameID = 0;
+		pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+		pSpellSprite.field_60_distance_related_prolly_lod = 0;
+		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+		pSpellSprite.spell_target_pid = a2;
+		pSpellSprite.uFacing = LOWORD(pParty->sRotationY);
+		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 		if ( pParty->bTurnBasedModeOn == 1 )
-			a1.uAttributes = 4;
-
-		v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
-			if ( a1.Create(pParty->sRotationY, stru_5C6E00->uIntegerHalfPi / 2, v659, 0) != -1 && pParty->bTurnBasedModeOn == 1 )
+			pSpellSprite.uAttributes = 4;
+
+		v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed;
+			if ( pSpellSprite.Create(pParty->sRotationY, stru_5C6E00->uIntegerHalfPi / 2, v659, 0) != -1 && pParty->bTurnBasedModeOn == 1 )
 			++pTurnEngine->field_1C;
 		LODWORD(v727) = 1;
 		break;
@@ -5620,10 +5577,10 @@
 		LODWORD(v733) = v330;
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0);
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1);
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2);
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
 
 			pParty->pPartyBuffs[PARTY_BUFF_DETECT_LIFE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0);
 		LODWORD(v727) = 1;
@@ -5658,12 +5615,12 @@
 LABEL_667:
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
-		v342 = v3->spell_target_pid;
+		v342 = pCastSpell->spell_target_pid;
 		if ( v342 == 0 )
 		{
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2);
-
-			pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, v731, amount, 0, 0);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
+
+			pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, v731, amount, 0, 0);
 			LODWORD(v727) = 1;
 			break;
 		}
@@ -5706,7 +5663,7 @@
 LABEL_679:
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
-		v351 = &pParty->pPlayers[v3->uPlayerID_2];
+		v351 = &pParty->pPlayers[pCastSpell->uPlayerID_2];
 		if ( !v351->pConditions[0] )
 		{
 		LODWORD(v727) = 1;
@@ -5721,13 +5678,13 @@
 		{
 			v732 = amount << 7;
 			v351->DiscardConditionIfLastsLongerThan(0, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
-			if ( HIDWORD(pParty->pPlayers[v3->uPlayerID_2].pConditions[0]) | LODWORD(pParty->pPlayers[v3->uPlayerID_2].pConditions[0]) )
+			if ( HIDWORD(pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[0]) | LODWORD(pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[0]) )
 			{
 			LODWORD(v727) = 1;
 			break;
 			}
 		}
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
 		LODWORD(v727) = 1;
 		break;
 			}
@@ -5743,9 +5700,9 @@
 			break;
 		if ( v731 == 1 || v731 == 2 )
 		{
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2);
-
-			pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
+
+			pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0);
 		LODWORD(v727) = 1;
 		break;
 		}
@@ -5754,7 +5711,7 @@
 		v357 = pParty->pPlayers;//[0].pPlayerBuffs[11];
 		do
 		{
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, a2);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, a2);
 			v357->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + v717, v731, 0, 0, 0);
 			++a2;
 			++v357;// = (SpellBuff *)((char *)v357 + 6972);
@@ -5775,30 +5732,30 @@
 			break;
 		auto _v726 = sub_46A6AC((int)dword_50BF30, 100, 4096);
 		pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFFFFFFu, 0xC0u);
-		++a1.uType;
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-		a1.uAttributes = 0;
-		a1.uSectorID = 0;
-		a1.uSpriteFrameID = 0;
-		a1.field_60_distance_related_prolly_lod = 0;
-		a1.uFacing = 0;
-		a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-		a1.uSoundID = LOWORD(v3->sound_id);
+		++pSpellSprite.uType;
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+		pSpellSprite.uAttributes = 0;
+		pSpellSprite.uSectorID = 0;
+		pSpellSprite.uSpriteFrameID = 0;
+		pSpellSprite.field_60_distance_related_prolly_lod = 0;
+		pSpellSprite.uFacing = 0;
+		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 		for ( a2 = 0; a2 < (signed int)_v726; ++a2 )
 		{
 			v369 = &pActors[dword_50BF30[a2]];
 			if ( MonsterStats::BelongsToSupertype(v369->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
 			{
-			a1.vPosition.x = v369->vPosition.x;
-			a1.vPosition.y = v369->vPosition.y;
-			a1.vPosition.z = v369->vPosition.z - (unsigned int)(signed __int64)((double)v369->uActorHeight * unk_4D8548);
-
-			a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
-			a1.Create(0, 0, 0, 0);
+			pSpellSprite.vPosition.x = v369->vPosition.x;
+			pSpellSprite.vPosition.y = v369->vPosition.y;
+			pSpellSprite.vPosition.z = v369->vPosition.z - (unsigned int)(signed __int64)((double)v369->uActorHeight * unk_4D8548);
+
+			pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
+			pSpellSprite.Create(0, 0, 0, 0);
 			v369->pActorBuffs[4].Apply(
 				pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335),
 				v731, 0, 0, 0);
@@ -5817,8 +5774,8 @@
 			amount = 86400 * v2;
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
-		pOtherOverlayList->_4418B1(5080, v3->uPlayerID_2 + 100, 0, 65536);
-		v373 = v3->uPlayerID_2;
+		pOtherOverlayList->_4418B1(5080, pCastSpell->uPlayerID_2 + 100, 0, 65536);
+		v373 = pCastSpell->uPlayerID_2;
 		if ( !(HIDWORD(pParty->pPlayers[v373].pConditions[14]) | LODWORD(pParty->pPlayers[v373].pConditions[14])) )
 		{
 		LODWORD(v727) = 1;
@@ -5828,24 +5785,24 @@
 		pParty->pPlayers[v373].sHealth = 1;
 		if ( v14 )
 		{
-			v374 = v3->uPlayerID_2;
+			v374 = pCastSpell->uPlayerID_2;
 			LODWORD(pParty->pPlayers[v374].pConditions[14]) = 0;
 			HIDWORD(pParty->pPlayers[v374].pConditions[14]) = 0;
-			v376 = v3->uPlayerID_2;
+			v376 = pCastSpell->uPlayerID_2;
 			LODWORD(pParty->pPlayers[v376].pConditions[13]) = 0;
 			HIDWORD(pParty->pPlayers[v376].pConditions[13]) = 0;
 		}
 		else
 		{
 			*(float *)&a2 = (double)(amount << 7) * 0.033333335;
-			pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(
+			pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(
 			0xEu,
 			(signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
-			pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(
+			pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(
 			0xDu,
 			(signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
 		}
-		v377 = &pParty->pPlayers[v3->uPlayerID_2];
+		v377 = &pParty->pPlayers[pCastSpell->uPlayerID_2];
 		goto LABEL_720;
 			}
 		case SPELL_SPIRIT_SHARED_LIFE:
@@ -5896,7 +5853,7 @@
 			}
 			v388 = HIDWORD(v733);
 
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, LOWORD(v682[HIDWORD(v733)]) - 1);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, LOWORD(v682[HIDWORD(v733)]) - 1);
 			HIDWORD(v733) = v388 + 1;
 			}
 			while ( v388 + 1 < v730 );
@@ -5910,19 +5867,20 @@
 		if ( !v392 )
 		{
 			v395 = 180 * v2;
-			goto LABEL_750;
+			amount = v395;
+			goto LABEL_751;
 		}
 		v393 = v392 - 1;
 		if ( !v393 )
 		{
 			v395 = 10800 * v2;
-			goto LABEL_750;
+			amount = v395;
+			goto LABEL_751;
 		}
 		v394 = v393 - 1;
 		if ( !v394 )
 		{
 			v395 = 259200 * v2;
-LABEL_750:
 			amount = v395;
 			goto LABEL_751;
 		}
@@ -5931,7 +5889,7 @@
 LABEL_751:
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
-		v396 = v3->uPlayerID_2;
+		v396 = pCastSpell->uPlayerID_2;
 		if ( HIDWORD(pParty->pPlayers[v396].pConditions[16]) | LODWORD(pParty->pPlayers[v396].pConditions[16])
 			|| HIDWORD(pParty->pPlayers[v396].pConditions[14]) | LODWORD(pParty->pPlayers[v396].pConditions[14]) )
 		{
@@ -5939,31 +5897,31 @@
 			pParty->pPlayers[v396].PlaySound(SPEECH_25, 0);
 			if ( v731 == 4 )
 			{
-			v397 = v3->uPlayerID_2;
+			v397 = pCastSpell->uPlayerID_2;
 			LODWORD(pParty->pPlayers[v397].pConditions[16]) = 0;
 			HIDWORD(pParty->pPlayers[v397].pConditions[16]) = 0;
-			v398 = v3->uPlayerID_2;
+			v398 = pCastSpell->uPlayerID_2;
 			LODWORD(pParty->pPlayers[v398].pConditions[14]) = 0;
 			HIDWORD(pParty->pPlayers[v398].pConditions[14]) = 0;
-			v399 = v3->uPlayerID_2;
+			v399 = pCastSpell->uPlayerID_2;
 			LODWORD(pParty->pPlayers[v399].pConditions[13]) = 0;
 			HIDWORD(pParty->pPlayers[v399].pConditions[13]) = 0;
 			}
 			else
 			{
 			*(float *)&a2 = (double)(amount << 7) * 0.033333335;
-			pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0x10u,
+			pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0x10u,
 				(signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
-			pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0xEu,
+			pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0xEu,
 				(signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
-			pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0xDu,
+			pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0xDu,
 				(signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
 			}
-			pParty->pPlayers[v3->uPlayerID_2].SetCondition(1u, 1);
-
-			pParty->pPlayers[v3->uPlayerID_2].sHealth = 1;
-
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2);
+			pParty->pPlayers[pCastSpell->uPlayerID_2].SetCondition(1u, 1);
+
+			pParty->pPlayers[pCastSpell->uPlayerID_2].sHealth = 1;
+
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
 		}
 		LODWORD(v727) = 1;
 		break;
@@ -5993,8 +5951,8 @@
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2);
-		v323 = v3->uPlayerID_2;
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
+		v323 = pCastSpell->uPlayerID_2;
 		v324 = (char *)&pParty->pPlayers[v323].pConditions[12];
 		if ( !pParty->pPlayers[v323].pConditions[12] )
 		{
@@ -6010,7 +5968,8 @@
 		}
 		v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335);
 		v656 = 12;
-		goto LABEL_640;
+		v325 = &pParty->pPlayers[v323];
+		goto LABEL_641;
 
 			}
 		case SPELL_MIND_REMOVE_FEAR:
@@ -6042,8 +6001,8 @@
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2);
-		v323 = v3->uPlayerID_2;
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
+		v323 = pCastSpell->uPlayerID_2;
 		v324 = (char *)&pParty->pPlayers[v323].pConditions[3];
 		if ( !pParty->pPlayers[v323].pConditions[3] )
 		{
@@ -6059,7 +6018,8 @@
 		}
 		v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335);
 		v656 = 3;
-		goto LABEL_640;
+		v325 = &pParty->pPlayers[v323];
+		goto LABEL_641;
 			}
 		case SPELL_MIND_TELEPATHY:
 			{
@@ -6111,33 +6071,68 @@
 			{
 			v422 = v683.GetDisplayName();
 			sprintf(pTmpBuf2, "(%s), and %d gold", v422, v675);
-			goto LABEL_807;
+			ShowStatusBarString(pTmpBuf2, 2u);
+			pSpellSprite.stru_24.Reset();
+			pSpellSprite.spell_id = pCastSpell->spellnum;
+			pSpellSprite.spell_level = v2;
+			pSpellSprite.spell_skill = v731;
+			pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+			pSpellSprite.vPosition.x = *(short *)(v730 + 142);
+			pSpellSprite.vPosition.y = *(short *)(v730 + 144);
+			v676 = *(short *)(v730 + 138);
+			v665 = pSpellSprite.vPosition.y;
+			pSpellSprite.vPosition.z = *(short *)(v730 + 138);
+			v657 = pSpellSprite.vPosition.x;
+			goto LABEL_1087;
 			}
 			v664 = "%d gold";
-			goto LABEL_803;
+			sprintf(pTmpBuf2, v664, v675);
+			ShowStatusBarString(pTmpBuf2, 2u);
+			pSpellSprite.stru_24.Reset();
+			pSpellSprite.spell_id = pCastSpell->spellnum;
+			pSpellSprite.spell_level = v2;
+			pSpellSprite.spell_skill = v731;
+			pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+			pSpellSprite.vPosition.x = *(short *)(v730 + 142);
+			pSpellSprite.vPosition.y = *(short *)(v730 + 144);
+			v676 = *(short *)(v730 + 138);
+			v665 = pSpellSprite.vPosition.y;
+			pSpellSprite.vPosition.z = *(short *)(v730 + 138);
+			v657 = pSpellSprite.vPosition.x;
+			goto LABEL_1087;
 		}
 		if (v683.uItemID)
 		{
 			v675 = v683.GetDisplayName();
 			v664 = "(%s)";
-LABEL_803:
 			sprintf(pTmpBuf2, v664, v675);
-			goto LABEL_807;
+			ShowStatusBarString(pTmpBuf2, 2u);
+			pSpellSprite.stru_24.Reset();
+			pSpellSprite.spell_id = pCastSpell->spellnum;
+			pSpellSprite.spell_level = v2;
+			pSpellSprite.spell_skill = v731;
+			pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+			pSpellSprite.vPosition.x = *(short *)(v730 + 142);
+			pSpellSprite.vPosition.y = *(short *)(v730 + 144);
+			v676 = *(short *)(v730 + 138);
+			v665 = pSpellSprite.vPosition.y;
+			pSpellSprite.vPosition.z = *(short *)(v730 + 138);
+			v657 = pSpellSprite.vPosition.x;
+			goto LABEL_1087;
 		}
 		strcpy(pTmpBuf2, "nothing");
-LABEL_807:
 		ShowStatusBarString(pTmpBuf2, 2u);
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-		a1.vPosition.x = *(short *)(v730 + 142);
-		a1.vPosition.y = *(short *)(v730 + 144);
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+		pSpellSprite.vPosition.x = *(short *)(v730 + 142);
+		pSpellSprite.vPosition.y = *(short *)(v730 + 144);
 		v676 = *(short *)(v730 + 138);
-		v665 = a1.vPosition.y;
-		a1.vPosition.z = *(short *)(v730 + 138);
-		v657 = a1.vPosition.x;
+		v665 = pSpellSprite.vPosition.y;
+		pSpellSprite.vPosition.z = *(short *)(v730 + 138);
+		v657 = pSpellSprite.vPosition.x;
 		goto LABEL_1087;
 			}
 		case SPELL_MIND_BERSERK:
@@ -6177,11 +6172,11 @@
 			v731, 0, 0, 0);
 			pActors[v426].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
 		}
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		v60 = pObjectList->ObjectIDByItemID(a1.uType);
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
 		v61 = v426;
 		goto LABEL_1086;
 
@@ -6206,11 +6201,11 @@
 			pActors[PID_ID(a2)].pActorBuffs[12].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335),
 			v731, 0, 0, 0);
 		}
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		v60 = pObjectList->ObjectIDByItemID(a1.uType);
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
 		v61 = PID_ID(a2);
 		goto LABEL_1086;
 			}
@@ -6226,30 +6221,30 @@
 			break;
 		auto _v726 = sub_46A6AC((int)dword_50BF30, 100, 4096);
 		pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xA0A0Au, 0xC0u);
-		++a1.uType;
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-		a1.uAttributes = 0;
-		a1.uSectorID = 0;
-		a1.uSpriteFrameID = 0;
-		a1.field_60_distance_related_prolly_lod = 0;
-		a1.uFacing = 0;
-		a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-		a1.uSoundID = LOWORD(v3->sound_id);
+		++pSpellSprite.uType;
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+		pSpellSprite.uAttributes = 0;
+		pSpellSprite.uSectorID = 0;
+		pSpellSprite.uSpriteFrameID = 0;
+		pSpellSprite.field_60_distance_related_prolly_lod = 0;
+		pSpellSprite.uFacing = 0;
+		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 		for ( a2 = 0; a2 < (signed int)_v726; ++a2 )
 		{
 			v433 = &pActors[dword_50BF30[a2]];
 			if ( MonsterStats::BelongsToSupertype(v433->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
 			break;
-			a1.vPosition.x = v433->vPosition.x;
-			a1.vPosition.y = v433->vPosition.y;
-			a1.vPosition.z = v433->vPosition.z - (unsigned int)(signed __int64)((double)v433->uActorHeight * unk_4D8548);
-
-			a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
-			a1.Create(0, 0, 0, 0);
+			pSpellSprite.vPosition.x = v433->vPosition.x;
+			pSpellSprite.vPosition.y = v433->vPosition.y;
+			pSpellSprite.vPosition.z = v433->vPosition.z - (unsigned int)(signed __int64)((double)v433->uActorHeight * unk_4D8548);
+
+			pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
+			pSpellSprite.Create(0, 0, 0, 0);
 			if ( stru_50C198.GetMagicalResistance(v433, 7u) )
 			{
 			v433->pActorBuffs[4].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335),
@@ -6270,24 +6265,24 @@
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2);
-		v440 = v3->uPlayerID_2;
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
+		v440 = pCastSpell->uPlayerID_2;
 		if ( HIDWORD(pParty->pPlayers[v440].pConditions[5]) | LODWORD(pParty->pPlayers[v440].pConditions[5]) )
 		{
 			if ( !(HIDWORD(pParty->pPlayers[v440].pConditions[1]) | LODWORD(pParty->pPlayers[v440].pConditions[1])) )
 			pParty->pPlayers[v440].PlaySound(SPEECH_25, 0);
 			if ( v731 == 4 )
 			{
-			v441 = v3->uPlayerID_2;
+			v441 = pCastSpell->uPlayerID_2;
 			LODWORD(pParty->pPlayers[v441].pConditions[5]) = 0;
 			HIDWORD(pParty->pPlayers[v441].pConditions[5]) = 0;
 			}
 			else
 			{
-			pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(5u,
+			pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(5u,
 				(signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
 			}
-			v377 = &pParty->pPlayers[v3->uPlayerID_2];
+			v377 = &pParty->pPlayers[pCastSpell->uPlayerID_2];
 LABEL_720:
 			v377->SetCondition(1, 0);
 		}
@@ -6411,8 +6406,8 @@
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2);
-		v323 = v3->uPlayerID_2;
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
+		v323 = pCastSpell->uPlayerID_2;
 		v324 = (char *)&pParty->pPlayers[v323].pConditions[1];
 		if ( !pParty->pPlayers[v323].pConditions[1] )
 		{
@@ -6428,7 +6423,6 @@
 		}
 		v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335);
 		v656 = 1;
-LABEL_640:
 		v325 = &pParty->pPlayers[v323];
 		goto LABEL_641;
 			}
@@ -6457,11 +6451,11 @@
 		amount = v459;
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
-		v460 = v3->spell_target_pid;
+		v460 = pCastSpell->spell_target_pid;
 		if (!v460)
 		{
-			pParty->pPlayers[v3->uPlayerID_2].Heal(amount);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2);
+			pParty->pPlayers[pCastSpell->uPlayerID_2].Heal(amount);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
 		}
 		else
 		{
@@ -6515,8 +6509,8 @@
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2);
-		v470 = v3->uPlayerID_2;
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
+		v470 = pCastSpell->uPlayerID_2;
 		if ( !(HIDWORD(pParty->pPlayers[v470].pConditions[6]) | LODWORD(pParty->pPlayers[v470].pConditions[6]))
 			&& !(HIDWORD(pParty->pPlayers[v470].pConditions[8]) | LODWORD(pParty->pPlayers[v470].pConditions[8]))
 			&& !(HIDWORD(pParty->pPlayers[v470].pConditions[10]) | LODWORD(pParty->pPlayers[v470].pConditions[10])) )
@@ -6528,10 +6522,10 @@
 		{
 			LODWORD(pParty->pPlayers[v470].pConditions[6]) = 0;
 			HIDWORD(pParty->pPlayers[v470].pConditions[6]) = 0;
-			v471 = v3->uPlayerID_2;
+			v471 = pCastSpell->uPlayerID_2;
 			LODWORD(pParty->pPlayers[v471].pConditions[8]) = 0;
 			HIDWORD(pParty->pPlayers[v471].pConditions[8]) = 0;
-			v472 = v3->uPlayerID_2;
+			v472 = pCastSpell->uPlayerID_2;
 			LODWORD(pParty->pPlayers[v472].pConditions[10]) = 0;
 			HIDWORD(pParty->pPlayers[v472].pConditions[10]) = 0;
 			LODWORD(v727) = 1;
@@ -6541,7 +6535,7 @@
 		pParty->pPlayers[v470].DiscardConditionIfLastsLongerThan(
 			6u,
 			(signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
-		pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(
+		pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(
 			8u,
 			(signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
 		v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2);
@@ -6556,10 +6550,10 @@
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0);
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1);
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2);
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
 
 		pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, 0, 0);
 			LODWORD(v727) = 1;
@@ -6573,10 +6567,10 @@
 			break;
 		if ( v731 == 4 )
 		{
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
 			v732 = (int)v733 << 7;
 			v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
 			pParty->pPlayers[0].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4u, v2, v2, 0);
@@ -6587,9 +6581,9 @@
 			LODWORD(v727) = 1;
 			break;
 		}
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2);
-
-		pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, v2, 0);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
+
+		pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, v2, 0);
 			LODWORD(v727) = 1;
 			break;
 			}
@@ -6603,8 +6597,8 @@
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2);
-		v498 = v3->uPlayerID_2;
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
+		v498 = pCastSpell->uPlayerID_2;
 		if ( !(HIDWORD(pParty->pPlayers[v498].pConditions[7]) | LODWORD(pParty->pPlayers[v498].pConditions[7]))
 			&& !(HIDWORD(pParty->pPlayers[v498].pConditions[9]) | LODWORD(pParty->pPlayers[v498].pConditions[9]))
 			&& !(HIDWORD(pParty->pPlayers[v498].pConditions[11]) | LODWORD(pParty->pPlayers[v498].pConditions[11])) )
@@ -6616,10 +6610,10 @@
 		{
 			LODWORD(pParty->pPlayers[v498].pConditions[7]) = 0;
 			HIDWORD(pParty->pPlayers[v498].pConditions[7]) = 0;
-			v499 = v3->uPlayerID_2;
+			v499 = pCastSpell->uPlayerID_2;
 			LODWORD(pParty->pPlayers[v499].pConditions[9]) = 0;
 			HIDWORD(pParty->pPlayers[v499].pConditions[9]) = 0;
-			v500 = v3->uPlayerID_2;
+			v500 = pCastSpell->uPlayerID_2;
 			LODWORD(pParty->pPlayers[v500].pConditions[11]) = 0;
 			HIDWORD(pParty->pPlayers[v500].pConditions[11]) = 0;
 		}
@@ -6629,13 +6623,13 @@
 			pParty->pPlayers[v498].DiscardConditionIfLastsLongerThan(
 			7u,
 			(signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
-			pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(
+			pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(
 			9u,
 			(signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
 			v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2);
 			v656 = 11;
 LABEL_937:
-			v325 = &pParty->pPlayers[v3->uPlayerID_2];
+			v325 = &pParty->pPlayers[pCastSpell->uPlayerID_2];
 LABEL_641:
 			v325->DiscardConditionIfLastsLongerThan(v656, v663);
 		}
@@ -6651,7 +6645,7 @@
 		int v1 = 0;
 		do
 		{
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v1);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, v1);
 			v501->Heal(amount);
 			++v501;
 			++v1;
@@ -6668,34 +6662,34 @@
 
 		pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xAFF0Au, 0xC0u);
 		v505 = sub_46A6AC((int)dword_50BF30, 100, 4096);
-		++a1.uType;
+		++pSpellSprite.uType;
 		HIDWORD(v733) = v505;
 		v688.x = 0;
 		v688.y = 0;
 		v688.z = 0;
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-		a1.uAttributes = 0;
-		a1.uSectorID = 0;
-		a1.uSpriteFrameID = 0;
-		a1.field_60_distance_related_prolly_lod = 0;
-		a1.uFacing = 0;
-		a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-		a1.uSoundID = LOWORD(v3->sound_id);
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+		pSpellSprite.uAttributes = 0;
+		pSpellSprite.uSectorID = 0;
+		pSpellSprite.uSpriteFrameID = 0;
+		pSpellSprite.field_60_distance_related_prolly_lod = 0;
+		pSpellSprite.uFacing = 0;
+		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 		a2 = 0;
 		if ( SHIDWORD(v733) > 0 )
 		{
 			do
 			{
 			v507 = dword_50BF30[a2];
-			a1.vPosition.x = pActors[v507].vPosition.x;
-			a1.vPosition.y = pActors[v507].vPosition.y;
-			a1.vPosition.z = pActors[v507].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v507].uActorHeight * unk_4D8548);
-			a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
-			v509 = a1.Create(0, 0, 0, 0);
+			pSpellSprite.vPosition.x = pActors[v507].vPosition.x;
+			pSpellSprite.vPosition.y = pActors[v507].vPosition.y;
+			pSpellSprite.vPosition.z = pActors[v507].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v507].uActorHeight * unk_4D8548);
+			pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
+			v509 = pSpellSprite.Create(0, 0, 0, 0);
 			v510 = a2;
 			DamageMonsterFromParty(PID(OBJECT_Item, v509), dword_50BF30[a2], (Vec3_int_ *)&v688);
 			a2 = v510 + 1;
@@ -6705,11 +6699,11 @@
 		for ( a2 = 0; a2 < SHIDWORD(v733); ++a2 )
 		{
 			v511 = &pActors[dword_50BF30[a2]];
-			a1.vPosition.x = v511->vPosition.x;
-			a1.vPosition.y = v511->vPosition.y;
-			a1.vPosition.z = v511->vPosition.z - (unsigned int)(signed __int64)((double)v511->uActorHeight * unk_4D8548);
-			a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
-			a1.Create(0, 0, 0, 0);
+			pSpellSprite.vPosition.x = v511->vPosition.x;
+			pSpellSprite.vPosition.y = v511->vPosition.y;
+			pSpellSprite.vPosition.z = v511->vPosition.z - (unsigned int)(signed __int64)((double)v511->uActorHeight * unk_4D8548);
+			pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
+			pSpellSprite.Create(0, 0, 0, 0);
 			v513 = v511->pActorBuffs;
 			for (int _v726 = 22; _v726 != 0; --_v726)
 			{
@@ -6754,7 +6748,7 @@
 			do
 			{
 			v519 = v518->uAIState;
-			if ( v518->uAIState != 5 && v519 != 11 && v519 != 19 && PID(OBJECT_Player, v3->uPlayerID) == v518->uSummonerID )
+			if ( v518->uAIState != 5 && v519 != 11 && v519 != 19 && PID(OBJECT_Player, pCastSpell->uPlayerID) == v518->uSummonerID )
 				++HIDWORD(v733);
 			++v518;
 			--_v726;
@@ -6765,12 +6759,12 @@
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[648], 2);  // This character can't summon any more monsters!
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
-		sub_44FA4C_spawn_light_elemental(v3->uPlayerID, v731, v733);
+		sub_44FA4C_spawn_light_elemental(pCastSpell->uPlayerID, v731, v733);
 			LODWORD(v727) = 1;
 			break;
 			}
@@ -6803,10 +6797,10 @@
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0);
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1);
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2);
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
 
 		pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, 0, 0);
 		LODWORD(v727) = 1;
@@ -6819,39 +6813,39 @@
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[497], 2);  // Can't cast Prismatic Light outdoors!
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 		v531 = sub_46A6AC((int)dword_50BF30, 100, 4096);
-		++a1.uType;
+		++pSpellSprite.uType;
 		v694.x = 0;
 		v694.y = 0;
 		v694.z = 0;
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-		a1.uAttributes = 0;
-		a1.uSectorID = 0;
-		a1.uSpriteFrameID = 0;
-		a1.field_60_distance_related_prolly_lod = 0;
-		a1.uFacing = 0;
-		a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-		a1.uSoundID = LOWORD(v3->sound_id);
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+		pSpellSprite.uAttributes = 0;
+		pSpellSprite.uSectorID = 0;
+		pSpellSprite.uSpriteFrameID = 0;
+		pSpellSprite.field_60_distance_related_prolly_lod = 0;
+		pSpellSprite.uFacing = 0;
+		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 		a2 = 0;
 		if ( (signed int)v531 > 0 )
 		{
 			do
 			{
 			v533 = dword_50BF30[a2];
-			a1.vPosition.x = pActors[v533].vPosition.x;
-			a1.vPosition.y = pActors[v533].vPosition.y;
-			a1.vPosition.z = pActors[v533].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v533].uActorHeight * unk_4D8548);
-			a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
-			v535 = a1.Create(0, 0, 0, 0);
+			pSpellSprite.vPosition.x = pActors[v533].vPosition.x;
+			pSpellSprite.vPosition.y = pActors[v533].vPosition.y;
+			pSpellSprite.vPosition.z = pActors[v533].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v533].uActorHeight * unk_4D8548);
+			pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
+			v535 = pSpellSprite.Create(0, 0, 0, 0);
 			v536 = a2;
 			DamageMonsterFromParty(PID(OBJECT_Item, v535), dword_50BF30[a2], &v694);
 			a2 = v536 + 1;
@@ -6881,10 +6875,10 @@
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0);
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1);
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2);
-		pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
+		pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
 
 		v732 = v730 << 7;
 		v549 = (double)(v730 << 7) * 0.033333335;
@@ -6941,10 +6935,10 @@
 		*((float *)&v733 + 1) = (double)v732 * 0.033333335;
 		do
 		{
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2);
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3);
 
 			//((SpellBuff *)(v553 + 6056))->Apply(
 			v553->pPlayerBuffs[4].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), v731, v730, 0, 0);
@@ -6973,7 +6967,7 @@
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
@@ -6996,7 +6990,7 @@
 			*(int *)(_this->uItemID + 6460) = v565;
 			v567 = (*v566)->GetMaxMana();
 			*(int *)(_this->uItemID + 6464) = v567;
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, a2);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, a2);
 			++a2;
 			_this = (ItemGen *)((char *)_this + 4);
 		}
@@ -7037,16 +7031,16 @@
 		amount = v575;
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
-		v576 = v3->spell_target_pid;
+		v576 = pCastSpell->spell_target_pid;
 		if (!v576)
 		{
-			v585 = (char *)&pParty->pPlayers[v3->uPlayerID_2];
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2);
+			v585 = (char *)&pParty->pPlayers[pCastSpell->uPlayerID_2];
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
 			if ( *((_QWORD *)v585 + 14) )
 			{
 			((Player *)v585)->SetCondition(0x11u, 1);
 			v587 = ((Player *)v585)->GetSexByVoice();
-			ReloadPlayerPortraits(v3->uPlayerID_2, (v587 != 0) + 23);
+			ReloadPlayerPortraits(pCastSpell->uPlayerID_2, (v587 != 0) + 23);
 			*((_QWORD *)v585 + 17) = pParty->uTimePlayed;
 			}
 			break;
@@ -7057,7 +7051,7 @@
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[496], 2);  // No valid target exists!
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		v578 = (int)&pActors[(int)v577];
@@ -7066,29 +7060,29 @@
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
-		++a1.uType;
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-		a1.uAttributes = 0;
-		a1.uSectorID = 0;
-		a1.uSpriteFrameID = 0;
-		a1.field_60_distance_related_prolly_lod = 0;
+		++pSpellSprite.uType;
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+		pSpellSprite.uAttributes = 0;
+		pSpellSprite.uSectorID = 0;
+		pSpellSprite.uSpriteFrameID = 0;
+		pSpellSprite.field_60_distance_related_prolly_lod = 0;
 		v581 = v721;
-		a1.uFacing = 0;
-		a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-		a1.uSoundID = LOWORD(v3->sound_id);
-		a1.vPosition.x = *(short *)(v721 + 142);
-		a1.vPosition.y = *(short *)(v721 + 144);
+		pSpellSprite.uFacing = 0;
+		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
+		pSpellSprite.vPosition.x = *(short *)(v721 + 142);
+		pSpellSprite.vPosition.y = *(short *)(v721 + 144);
 		v732 = *(short *)(v721 + 138);
-		a1.vPosition.z = *(short *)(v721 + 146) - (unsigned int)(signed __int64)((double)v732 * unk_4D8548);
-		a1.spell_target_pid = PID(OBJECT_Actor, (int)v577);
-		a1.Create(0, 0, 0, 0);
+		pSpellSprite.vPosition.z = *(short *)(v721 + 146) - (unsigned int)(signed __int64)((double)v732 * unk_4D8548);
+		pSpellSprite.spell_target_pid = PID(OBJECT_Actor, (int)v577);
+		pSpellSprite.Create(0, 0, 0, 0);
 		if ( *(char *)(v581 + 52) > amount )
 			break;
 		Actor::Resurrect((unsigned int)v577);
@@ -7125,7 +7119,7 @@
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 		__debugbreak();
-		HIDWORD(v733) = (int)(char *)&pParty + 6972 * v3->uPlayerID_2 + 36 * a2 + 3040;
+		HIDWORD(v733) = (int)(char *)&pParty + 6972 * pCastSpell->uPlayerID_2 + 36 * a2 + 3040;
 		v732 = (signed int)&pItemsTable->pItems[*(int *)HIDWORD(v733)].pIconName;
 		((ItemGen *)HIDWORD(v733))->UpdateTempBonus(pParty->uTimePlayed);
 		if ( *(int *)HIDWORD(v733) >= 64 && *(int *)HIDWORD(v733) <= 65
@@ -7141,7 +7135,7 @@
 
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		v592 = HIDWORD(v733);
@@ -7179,26 +7173,26 @@
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 		auto _v726 = ((signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360);
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-		a1.vPosition.x = pParty->vPosition.x;
-		a1.vPosition.y = pParty->vPosition.y;
-		a1.uAttributes = 0;
-		a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
-		a1.uSectorID = pIndoor->GetSector(
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+		pSpellSprite.vPosition.x = pParty->vPosition.x;
+		pSpellSprite.vPosition.y = pParty->vPosition.y;
+		pSpellSprite.uAttributes = 0;
+		pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
+		pSpellSprite.uSectorID = pIndoor->GetSector(
 							pParty->vPosition.x,
 							pParty->vPosition.y,
 							pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2);
-		a1.uSpriteFrameID = 0;
-		a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-		a1.spell_target_pid = a2;
-		a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
-		a1.uSoundID = LOWORD(v3->sound_id);
+		pSpellSprite.uSpriteFrameID = 0;
+		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+		pSpellSprite.spell_target_pid = a2;
+		pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
+		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 		if ( pParty->bTurnBasedModeOn == 1 )
-			LOBYTE(a1.uAttributes) |= 4u;
+			LOBYTE(pSpellSprite.uAttributes) |= 4u;
 		v596 = (signed int)_v726 / -2;
 		y = (char *)((signed int)_v726 / 2);
 		if ( (signed int)_v726 / -2 <= (signed int)_v726 / 2 )
@@ -7206,12 +7200,12 @@
 			v597 = v715.uYawAngle;
 			do
 			{
-			a1.uFacing = v596 + v597;
-			if ( a1.Create(
+			pSpellSprite.uFacing = v596 + v597;
+			if ( pSpellSprite.Create(
 					v596 + v597,
 					v715.uPitchAngle,
-					pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
-					v3->uPlayerID + 1) != -1
+					pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed,
+					pCastSpell->uPlayerID + 1) != -1
 				&& pParty->bTurnBasedModeOn == 1 )
 				++pTurnEngine->field_1C;
 			v596 += _v726 / (amount - 1);
@@ -7229,12 +7223,12 @@
 		if ( v731 == 1 || v731 == 2 )
 		{
 			v598 = 180 * v2;
-			goto LABEL_1081;
+			LODWORD(v733) = v598;
+			goto LABEL_1082;
 		}
 		if ( v731 == 3 )
 		{
 			v598 = 300 * v2;
-LABEL_1081:
 			LODWORD(v733) = v598;
 			goto LABEL_1082;
 		}
@@ -7253,51 +7247,51 @@
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		pActors[PID_ID(a2)].pActorBuffs[9].Reset();
 		pActors[PID_ID(a2)].pActorBuffs[1].Reset();
 		pActors[PID_ID(a2)].pActorBuffs[12].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335),
 			v731, 0, 0, 0);
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		v60 = pObjectList->ObjectIDByItemID(a1.uType);
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
 		v61 = PID_ID(a2);
 LABEL_1086:
 		v600 = pActors[v61].vPosition.y;
 		v601 = pActors[v61].vPosition.x;
-		a1.uObjectDescID = v60;
-		a1.vPosition.x = v601;
+		pSpellSprite.uObjectDescID = v60;
+		pSpellSprite.vPosition.x = v601;
 		v602 = pActors[v61].uActorHeight;
 		v603 = pActors[v61].vPosition.z;
-		a1.vPosition.y = v600;
+		pSpellSprite.vPosition.y = v600;
 		v676 = v603 + v602;
 		v665 = v600;
-		a1.vPosition.z = v603 + v602;
+		pSpellSprite.vPosition.z = v603 + v602;
 		v657 = v601;
 LABEL_1087:
-		a1.uAttributes = 0;
-		a1.uSectorID = pIndoor->GetSector(v657, v665, v676);
-		a1.uSpriteFrameID = 0;
-		a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-		a1.spell_target_pid = a2;
-		a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
-		a1.uFacing = LOWORD(v715.uYawAngle);
-		LOBYTE(a1.uAttributes) |= 0x80u;
-		a1.uSoundID = LOWORD(v3->sound_id);
-		a1.Create(0, 0, 0, v3->uPlayerID + 1);
-			LODWORD(v727) = 1;
-			break;
-			}
+		pSpellSprite.uAttributes = 0;
+		pSpellSprite.uSectorID = pIndoor->GetSector(v657, v665, v676);
+		pSpellSprite.uSpriteFrameID = 0;
+		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+		pSpellSprite.spell_target_pid = a2;
+		pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
+		pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
+		LOBYTE(pSpellSprite.uAttributes) |= 0x80u;
+		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
+		pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1);
+		LODWORD(v727) = 1;
+		break;
+		}
 		case SPELL_DARK_SACRIFICE:
 			{
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 		HIDWORD(v733) = 0;
-		memset(&achievedAwardsIndex, 0, 4000);
+		memset(&achieved_awards, 0, 4000);
 		_this = 0;
 		v605 = (char *)pParty->pHirelings;
 		do
@@ -7305,7 +7299,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;
@@ -7315,6 +7309,7 @@
 		if ( (signed int)pNPCStats->uNumNewNPCs > 0)
 		{
 			v730 = (int)pNPCStats->pNewNPCData;
+            __debugbreak(); // data offset
 			HIDWORD(v733) = 4 * HIDWORD(v733) + 6043152;
 			do
 			{
@@ -7331,14 +7326,14 @@
 			}
 			while ( (signed int)this < (signed int)pNPCStats->uNumNewNPCs );
 		}
-		v608 = v3->uPlayerID_2;
+		v608 = pCastSpell->uPlayerID_2;
 		if ( v608 != 4 && v608 != 5
 			|| (v609 = (signed int)*(&pFontCChar + v608 + (unsigned __int8)pParty->field_709), v609 <= 0)
 			|| v609 >= 3 )
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		v610 = 76 * v609;
@@ -7385,9 +7380,9 @@
 			break;
 		if ( v731 != 3 && v731 != 4 )
 		{
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2);
-
-			pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v615, v716, 0);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2);
+
+			pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v615, v716, 0);
 			LODWORD(v727) = 1;
 			break;
 		}
@@ -7396,7 +7391,7 @@
 		v619 = pParty->pPlayers;//[0].pPlayerBuffs[10];
 		do
 		{
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, a2);
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, a2);
 			v619->pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + v717, v731, amount, v716, 0);
 			++a2;
 			++v619;
@@ -7415,18 +7410,18 @@
 		v707.x = 0;
 		v707.y = 0;
 		v707.z = 0;
-		a1.stru_24.Reset();
-		a1.spell_id = v3->spellnum;
-		a1.spell_level = v2;
-		a1.spell_skill = v731;
-		a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType);
-		a1.uAttributes = 0;
-		a1.uSectorID = 0;
-		a1.uSpriteFrameID = 0;
-		a1.field_60_distance_related_prolly_lod = 0;
-		a1.uFacing = 0;
-		a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID);
-		a1.uSoundID = LOWORD(v3->sound_id);
+		pSpellSprite.stru_24.Reset();
+		pSpellSprite.spell_id = pCastSpell->spellnum;
+		pSpellSprite.spell_level = v2;
+		pSpellSprite.spell_skill = v731;
+		pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
+		pSpellSprite.uAttributes = 0;
+		pSpellSprite.uSectorID = 0;
+		pSpellSprite.uSpriteFrameID = 0;
+		pSpellSprite.field_60_distance_related_prolly_lod = 0;
+		pSpellSprite.uFacing = 0;
+		pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
+		pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 		a2 = 0;
 		int _v726 = 0;
 		if ( SHIDWORD(v733) > 0 )
@@ -7435,12 +7430,12 @@
 			do
 			{
 			v625 = dword_50BF30[a2];
-			a1.vPosition.x = pActors[v625].vPosition.x;
-			a1.vPosition.y = pActors[v625].vPosition.y;
+			pSpellSprite.vPosition.x = pActors[v625].vPosition.x;
+			pSpellSprite.vPosition.y = pActors[v625].vPosition.y;
 			//v732 = pActors[v625].uActorHeight;
-			a1.vPosition.z = pActors[v625].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v625].uActorHeight * unk_4D8548);
-			a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
-			v627 = a1.Create(0, 0, 0, 0);
+			pSpellSprite.vPosition.z = pActors[v625].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v625].uActorHeight * unk_4D8548);
+			pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
+			v627 = pSpellSprite.Create(0, 0, 0, 0);
 			v628 = a2;
 			DamageMonsterFromParty(PID(OBJECT_Item, v627), dword_50BF30[a2], &v707);
 			a2 = v628 + 1;
@@ -7481,7 +7476,7 @@
 				v726->sHealth = v726->GetMaxHealth();
 			v635 = HIDWORD(v733);
 
-			pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, WORD2(v733));
+			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, WORD2(v733));
 			HIDWORD(v733) = v635 + 1;
 			}
 			while ( v635 + 1 < v730 );
@@ -7497,7 +7492,7 @@
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[499], 2);  // Can't cast Armageddon indoors!
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		v640 = v731 - 2;
@@ -7507,7 +7502,7 @@
 		{
 			ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
 			pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-			v3->spellnum = 0;
+			pCastSpell->spellnum = 0;
 			continue;
 		}
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
@@ -7537,10 +7532,10 @@
 		default:
 		break;
 	}
-	if ( v3->field_8 & 0x20 )
+	if ( pCastSpell->field_8 & 0x20 )
 	{
 		if ( v727 != 0.0 )
-			pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[v3->spellnum], 0, 0, -1, 0, v3->sound_id, 0, 0);
+			pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->spellnum], 0, 0, -1, 0, pCastSpell->sound_id, 0, 0);
 	}
 	else
 	{
@@ -7549,7 +7544,7 @@
 		if ( pParty->bTurnBasedModeOn )
 		{
 			v645 = sRecoveryTime;
-			pParty->pTurnBasedPlayerRecoveryTimes[v3->uPlayerID] = sRecoveryTime;
+			pParty->pTurnBasedPlayerRecoveryTimes[pCastSpell->uPlayerID] = sRecoveryTime;
 			pPlayer->SetRecoveryTime(v645);
 			if ( !some_active_character )
 				pTurnEngine->_40471C();
@@ -7563,13 +7558,13 @@
 		{
 			pPlayer->PlaySound(SPEECH_49, 0);
 			if ( v727 != 0.0 )
-				pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[v3->spellnum], 0, 0, -1, 0, v3->sound_id, 0,	0);
-			v3->spellnum = 0;
+				pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->spellnum], 0, 0, -1, 0, pCastSpell->sound_id, 0,	0);
+			pCastSpell->spellnum = 0;
 			v2 = v723;
 			continue;
 		}
 	}
-	v3->spellnum = 0;
+	pCastSpell->spellnum = 0;
 	v2 = v723;
 	continue;
 
@@ -7789,7 +7784,7 @@
   if (!player->CanAct())
     return;
 
-  pStru277->_427D48(uActiveCharacter);
+  pCastSpellInfo->_427D48(uActiveCharacter);
     //v3 = 0;
   if (pParty->Invisible())
     pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
@@ -8798,7 +8793,7 @@
                 v24 = v6->GetAttackRecoveryTime(false);
                 if ( !pParty->bTurnBasedModeOn )
                   pPlayers[uActiveCharacter]->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v24 * 2.133333333333333));
-                pStru277->_427D48(uActiveCharacter);
+                pCastSpellInfo->_427D48(uActiveCharacter);
                 pTurnEngine->_40471C();
               }
             }
--- a/mm7_data.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/mm7_data.cpp	Thu May 02 11:03:26 2013 +0600
@@ -34,38 +34,30 @@
 #include "TurnEngine.h"
 struct stru262_TurnBased *pTurnEngine = new stru262_TurnBased;
 
-#include "stru277.h"
-stru277 pStru277[10];
-stru277 stru_50CDB4; // idb
+#include "CastSpellInfo.h"
+CastSpellInfo pCastSpellInfo[10];
+CastSpellInfo stru_50CDB4; // idb
 
 #include "Viewport.h"
 struct Viewport *pViewport = new Viewport;
 struct ViewingParams *viewparams = new ViewingParams;
 
-#include "stru272.h"
-stru272 array_4FAC10[10];
 
 
-#include "stru279.h"
-stru279 stru_51076C;
-
-
-int achievedAwardsIndex[1000];
-
 #include "stru123.h"
 stru123 stru_5E4C90;
 
 #include "stru298.h"
 stru298 stru_50FE08; // weak
 
-#include "stru287.h"
-stru287 stru_5E4C50;
-
 #include "Autonotes.h"
 Autonote pAutonoteTxt[195]; // weak
 
 #include "Awards.h"
 Award pAwards[104];
+AwardType achieved_awards[1000];
+int num_achieved_awards;
+int num_achieved_awards_2;
 
 #include "stru159.h"
 
@@ -280,16 +272,15 @@
 
 #include "MM7.h"
 
-stru289 stru_6BE158;
 int paperdoll_Weapon[4][16][2] = {//4E4C30
-  0x80, 0xCD,  0x1E, 0x90,  0x58, 0x55,  0, 0,  0, 0,  0, 0,  0x11, 0x68,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,
-  0x83, 0xC9,  0x26, 0x9E,  0x62, 0x57,  0, 0,  0, 0,  0, 0,  0x15, 0x64,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,
-  0x83, 0xD8,  0x1D, 0xBA,  0x58, 0x77,  0, 0,  0, 0,  0, 0,  0, 0,        0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,
-  0x7B, 0xD8,  0x23, 0xB8,  0x62, 0x77,  0, 0,  0, 0,  0, 0,  0, 0,        0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,  0, 0,
+  {{128, 205},  {30, 144},  {88,  85},  {0, 0},  {0, 0},  {0, 0},  {17, 104},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0}},
+  {{131, 201},  {38, 158},  {98,  87},  {0, 0},  {0, 0},  {0, 0},  {21, 100},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0}},
+  {{131, 216},  {29, 186},  {88, 119},  {0, 0},  {0, 0},  {0, 0},  {  0,  0},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0}},
+  {{123, 216},  {35, 184},  {98, 119},  {0, 0},  {0, 0},  {0, 0},  {  0,  0},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0},  {0, 0}},
 };
-int paperdoll_helm_texture[2][16];
-int paperdoll_belt_texture[2][7];
-stat_coord stat_string_coord[26] = //0x4E2940
+int paperdoll_helm_texture[2][16]; //511698
+int paperdoll_belt_texture[2][7];  //511718
+stat_coord stat_string_coord[26] = //4E2940
 {
   {0x1A, 0x39, 0xDC, 0x12},
   {0x1A, 0x4A, 0xDC, 0x12},
@@ -318,7 +309,6 @@
   {0x111, 0x129, 0xBA, 0x12},
   {0x13E, 0x12, 0x89, 0x12},
 };
-stru348 stru_4E1890[13];
 
 
 
@@ -521,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];
@@ -539,37 +528,7 @@
 };
 unsigned char hourglass_icon_idx = 12; // weak
 
-char aSS[777]; // idb
-char ascii_4E2C54[6];
-char ascii_4E2C5C[7];
-char ascii_4E2C68[8];
-char ascii_4E2C70[9];
-char ascii_4E2C7C[8];
-char ascii_4E2C84[11];
-char ascii_4E2C90[12];
-char ascii_4E2C9C[8];
-char ascii_4E2CA4[7];
-char ascii_4E2CB0[12];
-char ascii_4E2CBC[12];
-char ascii_4E2CC8[12];
-char ascii_4E2CD4[6];
-char ascii_4E2CDC[11];
-char ascii_4E2CE8[8];
-char ascii_4E2CF0[12];
-char ascii_4E2CFC[6];
-char ascii_4E2D04[8];
-char ascii_4E2D0C[8];
-char ascii_4E2D14[6];
-char ascii_4E2D1C[12];
-char ascii_4E2D28[8];
-char ascii_4E2D30[7];
-char ascii_4E2D38[5];
-char ascii_4E2D40[8];// = {0xC2, 0xCF, 0xD0, 0xC0, 0xC2, 0xCE, 0};//russian text in keyboard options
-char ascii_4E2D48[6];// = {0xC2, 0xCB, 0xC5, 0xC2, 0xCE, 0};
-char ascii_4E2D50[6];// = {0xCD, 0xC0, 0xC7, 0xC0, 0xC4, 0};
-char ascii_4E2D5C[7];// = {0xC2, 0xCF, 0xC5, 0xD0, 0xC5, 0xC4, 0};
-char aMakingItemNumb[777]; // idb
-char aNpc03d[777]; // idb
+
 const char *format_4E2D80 = "\f%05d%s\f00000\n";
 char format_4E2D90[8];
 char aS03d03dS000_0[777]; // idb
@@ -689,9 +648,9 @@
 char aInvalidDevic_0[777]; // idb
 char aEWorkMsdevMm_3[777]; // idb
 char aErrorNoMouseFo[22]; // weak
-int pPaperdoll_BodyX = 481;
-int pPaperdoll_BodyY = 0;
-int paperdoll_Armor[4][17][2] = //0x4E4E30
+int pPaperdoll_BodyX = 481; // 004E4C28
+int pPaperdoll_BodyY = 0;   // 004E4C2C
+int paperdoll_Armor[4][17][2] = //4E4E30
 {
 // X     Y
   0x2C, 0x67,  0x30, 0x69,  0x2D, 0x67,  0x2C, 0x64,  0x14, 0x66,  0x22, 0x67,  0x20, 0x66,  0x25, 0x66,  0x12, 0x66,//Human
@@ -706,7 +665,7 @@
   0x33, 0x90,  0x32, 0x90,  0x34, 0x91,  0x32, 0x8E,  0x21, 0x8B,  0x31, 0x8B,  0x33, 0x8E,  0x2F, 0x8F,  0x16, 0x8D,
   0x18, 0x8C,  0x19, 0x8C,  0x1B, 0x8E,  0x0C, 0x8C,  0x21, 0x8B,  0x0C, 0x8C,  0x18, 0x8C,  0x2F, 0x8F,
 };
-int paperdoll_shoulder[4][17][2] = 
+int paperdoll_shoulder[4][17][2] = //4E5050
 {
   0x64, 0x67,  0x61, 0x67,  0x65, 0x68,  0x6E, 0x74,  0x6C, 0x68,  0x61, 0x67,  0x66, 0x68,  0x6C, 0x6A,  0x6E, 0x6D,
   0x67, 0x69,  0x70, 0x67,  0x6E, 0x6D,  0x6C, 0x6F,  0x6C, 0x68,  0x6C, 0x6F,  0x67, 0x69,  0x6C, 0x6A,
@@ -734,14 +693,14 @@
   0x1D, 0x121,   0x1C, 0x11F,   0x1B, 0x11B,   0x1C, 0x117,  0x16, 0x116,  0x1B, 0x137,  0x1B, 0x11B,
   0x1F, 0x127,   0x1F, 0x122,   0x1B, 0x11B,   0x1D, 0x117,  0x1D, 0x116,  0x1D, 0x137,  0x1B, 0x11F,
 };
-int paperdoll_Cloak[4][10][2] = //0x4E5570
+int paperdoll_Cloak[4][10][2] = //4E5570
 {
   0x11, 0x68,  0xF, 0x68,  0x14, 0x71,  0x19, 0x6B,  0x21, 0x6F,  0x5, 0x68,  0x5, 0x68,  0x14, 0x71,  0x3, 0x6B,  0xF, 0x6F,
   0x15, 0x64,  0xB, 0x6B,  0xE, 0x67,   0x15, 0x6B,  0x1B, 0x6F,  0x3, 0x6B,  0, 0x6B,    0xE, 0x67,   0, 0x6B,    0x3, 0x6F,
   0x10, 0x8A,  0x9, 0x8B,  0x18, 0x98,  0x25, 0x91,  0x29, 0x90,  0x8, 0x8A,  0x9, 0x8B,  0x18, 0x98,  0x3, 0x91,  0x3, 0x90,
   0x14, 0x92,  0x10, 0x92, 0x15, 0x98,  0x1F, 0x91,  0x22, 0x90,  0x8, 0x92,  0xC, 0x92,  0x15, 0x98,  0x3, 0x91,  0x3, 0x90,
 };
-int paperdoll_CloakCollar[4][10][2] = //0x4E56B0
+int paperdoll_CloakCollar[4][10][2] = //4E56B0
 {
   0x11, 0x68,  0x34, 0x64,  0x21, 0x69,  0x1D, 0x67,  0x20, 0x67,  0x21, 0x68,  0x34, 0x64,  0x21, 0x69,  0x1D, 0x67,  0x1F, 0x67,
   0x13, 0x64,  0x35, 0x66,  0x29, 0x68,  0x1F, 0x68,  0x1F, 0x6A,  0x21, 0x6A,  0x2B, 0x66,  0x26, 0x68,  0x1F, 0x68,  0x1F, 0x6A,
@@ -749,48 +708,46 @@
   0, 0,        0x38, 0x8A,  0x24, 0x8B,  0x1D, 0x8B,  0x21, 0x8C,  0x27, 0x8A,  0x34, 0x8A,  0x24, 0x8B,  0x25, 0x8B,  0x21, 0x8C,
 };
 //int dword_4E56B4; // weak
-int paperdoll_Belt[4][7][2] = //0x4E57F0
+int paperdoll_Belt[4][7][2] = //4E57F0
 {
   0x3A, 0xB6,  0x37, 0xB2,  0x34, 0xB9,  0x3A, 0xB9,  0x37, 0xB7,  0x38, 0xAC,  0x37, 0xB7,
   0x3E, 0xAD,  0x3A, 0xAC,  0x37, 0xB0,  0x3A, 0xB1,  0x39, 0xB0,  0x3C, 0xA5,  0x39, 0xB0,
   0x3B, 0xD5,  0x37, 0xD2,  0x31, 0xD5,  0x39, 0xD6,  0x37, 0xD8,  0x37, 0xD1,  0x37, 0xD8,
   0x42, 0xD2,  0x3F, 0xD0,  0x3B, 0xD7,  0x3C, 0xD5,  0x3B, 0xD6,  0x3E, 0xCF,  0x36, 0xD6,
 };
-int paperdoll_Helm[4][16][2] = //0x4E58D0
+int paperdoll_Helm[4][16][2] = //4E58D0
 {
   0x3E, 0x1F,  0x41, 0x2C,  0x37, 0x2F,  0x31, 0x32,  0x37, 0x2A,  0x39, 0x28,  0x36, 0x34,  0x41, 0x38,  0x40, 0x31,  0x40, 0x21,  0x40, 0x31,  0x3C, 0x33,  0x3D, 0x24,  0x3A, 0x1A,  0x37, 0x2A,  0x41, 0x48,
   0x41, 0x1E,  0x42, 0x2B,  0x37, 0x2F,  0x34, 0x30,  0x39, 0x29,  0x3A, 0x26,  0x36, 0x34,  0x41, 0x37,  0x42, 0x32,  0x40, 0x21,  0x40, 0x31,  0x40, 0x2F,  0x3E, 0x22,  0x3B, 0x1A,  0x39, 0x29,  0x42, 0x47,
   0x3F, 0x47,  0x41, 0x56,  0x37, 0x59,  0x32, 0x5E,  0x37, 0x58,  0x39, 0x54,  0x34, 0x61,  0x40, 0x61,  0x41, 0x5D,  0x3E, 0x4F,  0x3E, 0x5B,  0x3D, 0x5B,  0x3F, 0x4C,  0x3B, 0x45,  0x37, 0x58,  0x41, 0x74,
   0x45, 0x45,  0x46, 0x54,  0x3A, 0x55,  0x38, 0x58,  0x3C, 0x54,  0x3F, 0x52,  0x39, 0x5B,  0x45, 0x5C,  0x47, 0x5C,  0x44, 0x4B,  0x44, 0x57,  0x43, 0x55,  0x44, 0x4A,  0x3E, 0x45,  0x3C, 0x54,  0x47, 0x70,
 };
-//int dword_4E58D4[777]; // HelmY 31
-int pPaperdoll_Beards[4] = //0x4E5AD0
+int pPaperdoll_Beards[4] = //4E5AD0
 {
  52, 130, 56, 136,
 };
-int dword_4E5AD4[777]; // weak
-int pPaperdoll_LeftHand[4][2] =
+int pPaperdoll_LeftHand[4][2] = //4E5AE0
 {
   0x67, 0x6A,
   0x65, 0x6C,
   0x74, 0x8D,
   0x74, 0x93,
 };
-int pPaperdoll_SecondLeftHand[4][2] =
+int pPaperdoll_SecondLeftHand[4][2] = //4E5B00
 {
   0x1A, 0x6B,
   0x28, 0x6D,
   0x19, 0x8D,
   0x20, 0x92,
 };
-int pPaperdoll_RightHand[4][2] = //fist
+int pPaperdoll_RightHand[4][2] = //4E5B20
 {
   0x1E, 0x90,
   0x22, 0x9E,
   0x19, 0xBA,
   0x1F, 0xB8,
 };
-int pPaperdollLeftEmptyHand[4][2] = //0x4E5B40
+int pPaperdollLeftEmptyHand[4][2] = //4E5B40
 {
   0x80, 0xCD,
   0x83, 0xC9,
@@ -801,10 +758,6 @@
 int pPaperdollRingsY[6] = {0x0CA, 0x0CA, 0x0CA, 0x0FA, 0x0FA, 0x0FA};
 char aItem092v3[777]; // idb
 char aIbCd5D[777]; // idb
-char aAr_dn_dn[777]; // idb
-char aAr_dn_up[777]; // idb
-char aAr_up_dn[777]; // idb
-char aAr_up_up[777]; // idb
 char aItem281pc02d[777]; // idb
 char aPc02dbrd[777]; // idb
 char aPc23vDlhu[777]; // idb
@@ -1537,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
@@ -2010,7 +1961,6 @@
 struct Texture *pTexture_PlayerFaceEradicated;
 struct Texture *pTexture_PlayerFaceDead;
 struct Texture *pTextures_PlayerFaces[4][56];
-int dword_A75070; // weak
 struct Player *pPlayers[5];
 __int64 qword_A750D8; // weak
 __int16 word_A750E0; // weak
--- a/mm7_data.h	Thu May 02 11:02:48 2013 +0600
+++ b/mm7_data.h	Thu May 02 11:03:26 2013 +0600
@@ -342,6 +342,7 @@
 extern char aPending[]; // idb
 extern char aCanTFindS[]; // idb
 extern char pDayMoonPhase[28];
+extern int paperdoll_Weapon[4][16][2];
 extern char *spellbook_texture_filename_suffices[]; // weak
 extern __int16 word_4E1D3A[]; // weak
 extern __int16 pTownPortalBook_xs[6];
@@ -441,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];
@@ -449,44 +449,10 @@
 extern char monster_popup_y_offsets[]; // weak
 extern unsigned char hourglass_icon_idx; // weak
 
-extern char aSS[]; // idb
-extern char ascii_4E2C54[6];
-extern char ascii_4E2C5C[7];
-extern char ascii_4E2C68[8];
-extern char ascii_4E2C70[9];
-extern char ascii_4E2C7C[8];
-extern char ascii_4E2C84[11];
-extern char ascii_4E2C90[12];
-extern char ascii_4E2C9C[8];
-extern char ascii_4E2CA4[7];
-extern char ascii_4E2CB0[12];
-extern char ascii_4E2CBC[12];
-extern char ascii_4E2CC8[12];
-extern char ascii_4E2CD4[6];
-extern char ascii_4E2CDC[11];
-extern char ascii_4E2CE8[8];
-extern char ascii_4E2CF0[12];
-extern char ascii_4E2CFC[6];
-extern char ascii_4E2D04[8];
-extern char ascii_4E2D0C[8];
-extern char ascii_4E2D14[6];
-extern char ascii_4E2D1C[12];
-extern char ascii_4E2D28[8];
-extern char ascii_4E2D30[7];
-extern char ascii_4E2D38[5];
-extern char ascii_4E2D40[8];
-extern char ascii_4E2D48[6];
-extern char ascii_4E2D50[6];
-extern char ascii_4E2D5C[7];
-extern char aMakingItemNumb[]; // idb
-extern char aNpc03d[]; // idb
+
 extern const char *format_4E2D80;
 extern char format_4E2D90[8];
-extern char aS03d03dS000_0[]; // idb
-extern char aS03d03dS000[]; // idb
 //extern const char *format_4E2DC8;
-extern char aS[]; // idb
-extern char aLuSLuS[]; // idb
 extern const char *format_4E2DE8; // idb
 extern char asc_4E2DFC[3]; // idb
 extern const char *format_4E2E00; // idb
@@ -603,16 +569,15 @@
 extern int pPaperdoll_BodyY; // weak
 extern int paperdoll_Armor[4][17][2];
 extern int paperdoll_shoulder[4][17][2];
+extern int paperdoll_helm_texture[2][16];
+extern int paperdoll_belt_texture[2][7];
 extern int dword_4E5270[4][2];
 extern int paperdoll_Boot[4][7][2];
 extern int paperdoll_Cloak[4][10][2];
 extern int paperdoll_CloakCollar[4][10][2];
-//extern int dword_4E56B4; // weak
 extern int paperdoll_Belt[4][7][2];
 extern int paperdoll_Helm[4][16][2];
-//extern int dword_4E58D4[]; // weak
 extern int pPaperdoll_Beards[4]; // weak
-extern int dword_4E5AD4[]; // weak
 extern int pPaperdoll_LeftHand[4][2];
 extern int pPaperdoll_SecondLeftHand[4][2];
 extern int pPaperdoll_RightHand[4][2];
@@ -621,10 +586,6 @@
 extern int pPaperdollRingsY[6];
 extern char aItem092v3[]; // idb
 extern char aIbCd5D[]; // idb
-extern char aAr_dn_dn[]; // idb
-extern char aAr_dn_up[]; // idb
-extern char aAr_up_dn[]; // idb
-extern char aAr_up_up[]; // idb
 extern char aItem281pc02d[]; // idb
 extern char aPc02dbrd[]; // idb
 extern char aPc23vDlhu[]; // idb
@@ -957,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
@@ -1213,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
 
@@ -1538,8 +1496,6 @@
 unsigned int __fastcall SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID);
 unsigned int __fastcall SearchActorByGroup(unsigned int *pTotalActors, unsigned int uGroup);
 unsigned int __fastcall SearchActorByID(unsigned int *pTotalActors, unsigned int a2);
-// char __usercall am_408BB4<al>(int a1<ecx>, int a2<ebp>);
-void __cdecl sub_409BE8();
 void __cdecl PrepareArcomage();
 char __cdecl am_409FE9();
 char __cdecl am_40A198();
@@ -1584,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
@@ -1606,34 +1562,34 @@
 void __cdecl InitializeBookFonts();
 void __fastcall LoadThumbnailLloydTexture(unsigned int uSlot, unsigned int uPlayer);
 void  sub_412AF9();
-void __cdecl DrawSpellBookContent();
-char __cdecl DrawBook_History();
-void __cdecl DrawBook_Quests();
-void __cdecl DrawBook_Autonotes();
+void DrawSpellBookContent();
+char DrawBook_History();
+void DrawBook_Quests();
+void DrawBook_Autonotes();
 void DrawBook_Maps();
-void __thiscall SellectDrawBook(unsigned int uBook); // idb
-char *__cdecl GetDayPart();
-char __cdecl DrawBook_Calendar();
-void __cdecl SetAttributeNames();
-void __cdecl uGameUIFontMain_initialize();
-void __cdecl uGameUIFontShadow_initialize();
-void __cdecl sub_41420D_press_esc();
-void __cdecl sub_41426F();
-char __cdecl GameMenuUI_DrawKeyBindings();
+void DrawCurrentBook(unsigned int uBook); // idb
+char *GetDayPart();
+char DrawBook_Calendar();
+void SetAttributeNames();
+void uGameUIFontMain_initialize();
+void uGameUIFontShadow_initialize();
+void sub_41420D_press_esc();
+void sub_41426F();
+char GameMenuUI_DrawKeyBindings();
 unsigned int __thiscall sub_414D24(int _this);
-void __cdecl GameMenuUI_DrawVideoOptions();
-void __cdecl DrawGameOptions();
+void GameMenuUI_DrawVideoOptions();
+void DrawGameOptions();
 void __fastcall DrawPopupWindow(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight); // idb
 void DrawCopyrightWindow();
 void LoadFonts_and_DrawCopyrightWindow();
-void __cdecl GUI_UpdateWindows();
-void __cdecl identify_item();
+void GUI_UpdateWindows();
+void identify_item();
 void __thiscall sub_416B01(void *_this);
 void __thiscall sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(struct Vec2_int_ *_this);
 void UI_OnMouseLeftClick(int *pXY); // idb
 void __thiscall sub_417871(int *pXY);
-void __cdecl sub_4178C4();
-void __cdecl sub_4178E1();
+void sub_4178C4();
+void sub_4178E1();
 unsigned int __fastcall UI_GetHealthManaStringColor(signed int a1, signed int a2);
 signed int __thiscall GetConditionDrawColor(unsigned int uConditionIdx); // idb
 char __fastcall sub_4179BC_draw_tooltip(const char *a1, const char *a2); // idb
--- a/stru272.h	Thu May 02 11:02:48 2013 +0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-#pragma once
-
-
-
-/*  270 */
-#pragma pack(push, 1)
-struct stru272_stru0         // ARCOMAGE stuff
-{
-  int _40DFFE();
-  int _40E01A(int a2);
-  int _40E0F5(char a2, char a3);
-  int _40E133();
-  int _40E2A7();
-
-  int field_0;
-  int field_4;
-  int field_8;
-  int field_C;
-  int field_10;
-  int field_14;
-  int field_18;
-  int field_1C;
-  int field_20;
-  int field_24;
-  float field_28;
-  float field_2C;
-  float field_30;
-  int field_34;
-  int field_38;
-  int field_3C;
-  int field_40;
-  int field_44;
-  int field_48;
-  int field_4C;
-  int field_50;
-  int field_54;
-  char field_58;
-  char field_59;
-  char field_5A;
-  char field_5B;
-};
-#pragma pack(pop)
-
-
-/*  266 */
-#pragma pack(push, 1)
-struct stru272
-{
-  void _40DFD1();
-
-  struct stru272_stru0 *ptr_0;
-  char field_4[4264];
-};
-#pragma pack(pop)
-
-
-extern stru272 array_4FAC10[10];
\ No newline at end of file
--- a/stru277.h	Thu May 02 11:02:48 2013 +0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-#pragma once
-
-
-
-/*  271 */
-#pragma pack(push, 1)
-struct stru277
-{
-  //----- (00426987) --------------------------------------------------------
-  inline stru277()
-  {
-    field_8 = 0;
-    spellnum = 0;
-    field_6 = 0;
-    uPlayerID_2 = 0;
-    uPlayerID = 0;
-    sound_id = 0;
-  }
-
-  void _427D48(unsigned int uPlayerID);
-  unsigned int PushStru277(__int16 a2, __int16 uPlayerID, __int16 skill_level, __int16 a5, int sound_id);
-  struct GUIWindow *sub_4219BE();
-  void _427E01_cast_spell();
-
-  __int16 spellnum;
-  unsigned __int16 uPlayerID;
-  __int16 uPlayerID_2;
-  __int16 field_6;
-  __int16 field_8;
-  __int16 forced_spell_skill_level;
-  int spell_target_pid;
-  int sound_id;
-};
-#pragma pack(pop)
-
-
-extern stru277 pStru277[10];
-extern stru277 stru_50CDB4; // idb
--- a/stru279.h	Thu May 02 11:02:48 2013 +0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-#pragma once
-
-
-/*  273 */
-#pragma pack(push, 1)
-struct stru279
-{
-  //----- (0043B506) --------------------------------------------------------
-  stru279()
-  {
-    this->field_4 = 0;
-    this->field_8 = 0;
-    this->field_C = 0;
-    this->field_10 = 0;
-    this->field_14 = 0;
-    this->registry_debug_flags = 0;
-  }
-
-
-  int registry_debug_flags;
-  int field_4;
-  int field_8;
-  int field_C;
-  int field_10;
-  int field_14;
-};
-#pragma pack(pop)
-extern stru279 stru_51076C;
\ No newline at end of file
--- a/stru287.h	Thu May 02 11:02:48 2013 +0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-#pragma once
-
-
-
-/*  281 */
-#pragma pack(push, 1)
-struct stru287
-{
-  char field_0[24];
-};
-#pragma pack(pop)
-extern stru287 stru_5E4C50;
\ No newline at end of file
--- a/stru351.h	Thu May 02 11:02:48 2013 +0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-#pragma once
-
-
-/*  391 */
-#pragma pack(push, 1)
-struct stru351_summoned_item
-{
-  int field_0_expire_second;
-  int field_4_expire_minute;
-  int field_8_expire_hour;
-  int field_C_expire_day;
-  int field_10_expire_week;
-  int field_14_exprie_month;
-  int field_18_expire_year;
-};
-#pragma pack(pop)
\ No newline at end of file
--- a/texts.cpp	Thu May 02 11:02:48 2013 +0600
+++ b/texts.cpp	Thu May 02 11:03:26 2013 +0600
@@ -1,7 +1,6 @@
 
 #include <string.h>
 #include "Allocator.h"
-#include "stru287.h"
 #include "LOD.h"
 #include "mm7_data.h"
 #include "texts.h"
@@ -31,7 +30,7 @@
 
 //----- (00452B95) --------------------------------------------------------
 void __cdecl SetSomeItemsNames()
-	{
+{
 	pSomeItemsNames[0] = pGlobalTXT_LocalizationStrings[568];
 	pSomeItemsNames[1] = pGlobalTXT_LocalizationStrings[271];
 	pSomeItemsNames[2] = pGlobalTXT_LocalizationStrings[272];
@@ -46,8 +45,7 @@
 	pSomeItemsNames[11] = pGlobalTXT_LocalizationStrings[281];
 	pSomeItemsNames[12] = pGlobalTXT_LocalizationStrings[282];
 	pSomeItemsNames[13] = pGlobalTXT_LocalizationStrings[143];
-	memset(&stru_5E4C50, 0, sizeof(stru_5E4C50));
-	}
+}
 
 //----- (00452C30) --------------------------------------------------------
 char *RemoveQuotes(char *pStr)