changeset 1138:f947bedb2859

Слияние
author Ritor1
date Sat, 01 Jun 2013 10:32:31 +0600
parents 62c759bc49f7 (current diff) d98415be04ca (diff)
children a3ad3f38a7da
files Arcomage.cpp Vis.cpp Vis.h mm7_2.cpp
diffstat 70 files changed, 2445 insertions(+), 3457 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/Actor.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -230,29 +230,25 @@
 //----- (0040894B) --------------------------------------------------------
 bool Actor::CanAct()
 {
-  signed int v1; // esi@1
-  bool v2; // edi@2
+  bool isparalyzed; // esi@1
+  bool isstoned; // edi@2
   unsigned __int16 v3; // ax@6
 
-  v1 = 0;
-  v2 = (signed __int64)this->pActorBuffs[5].uExpireTime > 0;// stoned
-  if ( (signed __int64)this->pActorBuffs[6].uExpireTime > 0 )// paralyzed
-    v1 = 1;
+  isstoned = (signed __int64)this->pActorBuffs[5].uExpireTime > 0;// stoned
+  isparalyzed = (signed __int64)this->pActorBuffs[6].uExpireTime > 0;// paralyzed
   v3 = this->uAIState;
-  return (v2 | v1 | v3 == Dying | v3 == Dead | v3 == Removed | v3 == Summoned | v3 == Disabled) == 0;
+  return !(isstoned || isparalyzed || v3 == Dying || v3 == Dead || v3 == Removed || v3 == Summoned || v3 == Disabled);
 }
 
 //----- (004089C7) --------------------------------------------------------
 bool Actor::IsNotAlive()
 {
-  signed int v1; // esi@1
+  bool isstoned; // esi@1
   //unsigned __int16 v2; // ax@3
 
-  v1 = 0;
-  if (pActorBuffs[5].uExpireTime)
-    v1 = 1;
+  isstoned = (signed __int64)this->pActorBuffs[5].uExpireTime > 0;// stoned
   //v2 = this->uAIState;
-  return (v1 | (uAIState == Dying) | (uAIState == Dead) | (uAIState == Removed) | (uAIState == Summoned) | (uAIState == Disabled)) != 0;
+  return (isstoned || (uAIState == Dying) || (uAIState == Dead) || (uAIState == Removed) || (uAIState == Summoned) || (uAIState == Disabled));
 }
 
 //----- (004086E9) --------------------------------------------------------
@@ -875,9 +871,7 @@
               v6 + 5,
               0,
               0);
-            pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(
-              v5,
-              (unsigned int)((char *)&pDecalBuilder->std__vector_pDecals[557].pVertices[57].vWorldPosition.x + 1));
+            pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u);
             v106 = 0;
             v104 = 0;
             v103 = 0;
@@ -914,9 +908,7 @@
               v6 + 5,
               0,
               0);
-            pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(
-              v5,
-              (unsigned int)((char *)&pLevelEVT_Index[4335].uEventID + 2));
+            pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0x5C310Eu);
             v106 = 0;
             v104 = 0;
             v103 = 0;
@@ -956,9 +948,7 @@
         LOWORD(v48) = 2 * (3 * v6 + 60);
 LABEL_114:
         v5->pActorBuffs[11].Apply(pParty->uTimePlayed + 1280, v7, v48, 0, 0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(
-          v5,
-          (unsigned int)((char *)&pDecalBuilder->std__vector_pDecals[557].pVertices[57].vWorldPosition.x + 1));
+        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u);
 LABEL_127:
         v106 = v47;
         v104 = v47;
@@ -1092,9 +1082,7 @@
           v6 + 5,
           0,
           0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(
-          v5,
-          (unsigned int)((char *)&pDecalBuilder->std__vector_pDecals[557].pVertices[57].vWorldPosition.x + 1));
+        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u);
         v106 = 0;
         v104 = 0;
         v103 = 0;
@@ -1226,9 +1214,7 @@
           0,
           0,
           0);
-        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(
-          v5,
-          (unsigned int)((char *)&array_77EC08[1607].v_18.z + 2));
+        pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0x7E7E7Eu);
         v106 = 0;
         v104 = 0;
         v103 = 0;
@@ -1793,7 +1779,7 @@
   v20 = v6;
   v21 = PID_TYPE(v6);
   v22 = PID_ID(v20);
-  switch(v6)
+  switch(v21)
   {
 	case OBJECT_Item:
 		{
--- a/Allocator.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/Allocator.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -22,6 +22,10 @@
 void *Allocator::AllocNamedChunk(const void *pPrevPtrValue, unsigned int uSize, const char *pName)
 {
 
+  if ( pPrevPtrValue && !aborting_app )
+	  AbortWithError();
+  if (!uSize)
+	  return 0;
   return malloc(uSize);
 /*
   //Allocator *v4; // esi@1
--- a/Arcomage.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/Arcomage.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -736,7 +736,7 @@
     {
       result = dword_4DF3A4 - 2;
       if ( dword_4DF3A4 != 2 )
-        return result;
+        return result != 0;
       v64 = a1;
       v145 = &stru_505708[a1];
       v130 = a1;
@@ -1008,7 +1008,7 @@
           {
             --v123;
             if ( v123 < 0 )
-              return am_40BCFB(v64, v137);
+              return am_40BCFB(v64, v137) != 0;
           }
           v137 = dword_4FA9B0[2 * v123];
         }
@@ -1033,12 +1033,12 @@
           {
             ++v124;
             if ( v124 >= v136 )
-              return am_40BCFB(v64, v137);
+              return am_40BCFB(v64, v137) != 0;
           }
-          return am_40BE0E(v64, dword_4FA9B0[2 * v124]);
+          return am_40BE0E(v64, dword_4FA9B0[2 * v124]) != 0;
         }
       }
-      return am_40BCFB(v64, v137);
+      return am_40BCFB(v64, v137) != 0;
     }
     v9 = a1;
     v144 = &stru_505708[a1];
@@ -1300,7 +1300,7 @@
         {
           --v62;
           if ( v62 < 0 )
-            return am_40BCFB(v9, v137);
+            return am_40BCFB(v9, v137) != 0;
         }
         v137 = dword_4FA9B0[2 * v62];
       }
@@ -1325,12 +1325,12 @@
         {
           ++v63;
           if ( v63 >= v135 )
-            return am_40BCFB(v9, v137);
+            return am_40BCFB(v9, v137) != 0;
         }
-        return am_40BE0E(v9, dword_4FA9B0[2 * v63]);
+        return am_40BE0E(v9, dword_4FA9B0[2 * v63]) != 0;
       }
     }
-    return am_40BCFB(v9, v137);
+    return am_40BCFB(v9, v137) != 0;
   }
   v3 = 0;
   v4 = a1;
@@ -1355,7 +1355,7 @@
     }
     result = am_40BE0E(v4, v6);
   }
-  return result;
+  return result != 0;
 }
 // 408BB4: could not find valid save-restore pair for ebp
 // 4DF3A4: using guessed type int dword_4DF3A4;
--- a/AudioPlayer.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/AudioPlayer.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -267,7 +267,7 @@
         return 0;
     }
     v12 = 0;
-    while ( _strcmpi(pAudioPlayer->pSoundHeaders[v12].pSoundName, v11->pSoundName) )
+    while ( _stricmp(pAudioPlayer->pSoundHeaders[v12].pSoundName, v11->pSoundName) )
     {
       ++v7;
       ++v12;
@@ -488,11 +488,11 @@
       v9 = atoi(v19.pProperties[1]);
       v10 = v19.pProperties[2];
       v2->pSounds[v2->sNumSounds].uSoundID = v9;
-      if ( _strcmpi(v10, "system") )
+      if ( _stricmp(v10, "system") )
       {
-        if ( _strcmpi(v19.pProperties[2], "swap") )
+        if ( _stricmp(v19.pProperties[2], "swap") )
         {
-          v11 = _strcmpi(v19.pProperties[2], "lock");
+          v11 = _stricmp(v19.pProperties[2], "lock");
           v12 = v2->pSounds;
           v13 = v11 == 0;
           v14 = v2->sNumSounds;
@@ -510,7 +510,7 @@
       {
         v2->pSounds[v2->sNumSounds].eType = SOUND_DESC_SYSTEM;
       }
-      if ( v19.uPropCount >= 4 && !_strcmpi(v19.pProperties[3], "3D") )
+      if ( v19.uPropCount >= 4 && !_stricmp(v19.pProperties[3], "3D") )
       {
         v15 = (int)&v2->pSounds[v2->sNumSounds].uFlags;
         *(int *)v15 |= SOUND_DESC_SWAP;
@@ -2576,7 +2576,7 @@
     result = &pAudioPlayer->pSoundHeaders[v6 / 2 + v4];
     if ( !result )
       return result;
-    result = (SoundHeader *)_strcmpi(pName, result->pSoundName);
+    result = (SoundHeader *)_stricmp(pName, result->pSoundName);
     if ( !result )
       uFindSound_BinSearch_ResultID = v6 / 2 + v4;
     if ( v4 == v10 )
@@ -2591,7 +2591,7 @@
         v9 = v4;
         do
         {
-          result = (SoundHeader *)_strcmpi(pName, pAudioPlayer->pSoundHeaders[v9].pSoundName);
+          result = (SoundHeader *)_stricmp(pName, pAudioPlayer->pSoundHeaders[v9].pSoundName);
           if ( !result )
             goto LABEL_24;
           ++v7;
@@ -2618,7 +2618,7 @@
   v8 = v4;
   while ( 1 )
   {
-    result = (SoundHeader *)_strcmpi(pName, pAudioPlayer->pSoundHeaders[v8].pSoundName);
+    result = (SoundHeader *)_stricmp(pName, pAudioPlayer->pSoundHeaders[v8].pSoundName);
     if ( !result )
       break;
     ++v7;
--- a/AudioPlayer.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/AudioPlayer.h	Sat Jun 01 10:32:31 2013 +0600
@@ -241,7 +241,7 @@
 
 struct SoundDesc
 {
-  inline bool Is3D()  {return uFlags & SOUND_DESC_3D;}
+  inline bool Is3D()  {return (uFlags & SOUND_DESC_3D) != 0;}
 
   char pSoundName[32];
   unsigned int uSoundID;
--- a/Awards.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/Awards.h	Sat Jun 01 10:32:31 2013 +0600
@@ -9,7 +9,7 @@
   unsigned int  uPriority;
 };
 #pragma pack(pop)
-extern Award pAwards[104];
+extern Award pAwards[105];
 
 
 
--- a/CShow.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/CShow.h	Sat Jun 01 10:32:31 2013 +0600
@@ -17,8 +17,9 @@
 
 
 #pragma pack(push, 1)
-struct CShow
+class CShow
 {
+public:
   //----- (004A9507) --------------------------------------------------------
   CShow() {}
 
--- a/Chest.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/Chest.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -340,7 +340,7 @@
     v6 = item_texture->uTextureWidth;
     if ( v6 < 14 )
         v6 = 14;
-    texture_cell_width = (v6 - 14 >> 5) + 1;
+    texture_cell_width = ((v6 - 14) >> 5) + 1;
     v8 = item_texture->uTextureHeight;
     if ( v8 < 14 )
         v8 = 14;
--- a/Chest.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/Chest.h	Sat Jun 01 10:32:31 2013 +0600
@@ -48,9 +48,9 @@
 #pragma pack(push, 1)
 struct Chest //0x14cc
 {
-  inline bool Initialized() const    {return uFlags & CHEST_ITEMS_PLACED;}
+  inline bool Initialized() const    {return (uFlags & CHEST_ITEMS_PLACED) != 0;}
   inline void SetInitialized(bool b) {if (b) uFlags |= CHEST_ITEMS_PLACED; else uFlags &= ~CHEST_ITEMS_PLACED;}
-  inline bool Trapped() const        {return uFlags & CHEST_TRAPPED;}
+  inline bool Trapped() const        {return (uFlags & CHEST_TRAPPED) != 0;}
 
   static bool CanPlaceItemAt(signed int a1, int a2, signed int uChestID);
   static int CountChestItems(signed int uChestID);
--- a/DecalBuilder.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/DecalBuilder.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -128,11 +128,11 @@
   double v26; // st7@21
   int v27; // edi@21
   double v28; // st7@21
-  int v29; // ST10_4@21
+  float v29; // ST10_4@21
   int v30; // ST08_4@21
   //DecalBuilder *v31; // esi@21
   int v32; // [sp+4h] [bp-44h]@18
-  RenderVertexSoft *v33; // [sp+8h] [bp-40h]@21
+  float v33; // [sp+8h] [bp-40h]@21
   stru314 *v34; // [sp+Ch] [bp-3Ch]@21
   float v35; // [sp+10h] [bp-38h]@21
   float v36; // [sp+14h] [bp-34h]@17
@@ -145,6 +145,9 @@
   int v43; // [sp+3Ch] [bp-Ch]@21
   //DecalBuilder *thisa; // [sp+40h] [bp-8h]@1
   //RenderVertexSoft *a11; // [sp+44h] [bp-4h]@8
+  int a6a;
+  int *a6b;
+
 
 //  __debugbreak();
 
@@ -177,22 +180,11 @@
   //a11 = a6;
   if ( a7 )
   {
-    if ( a5 > 0 )
-    {
-      v11 = static_AE4F90;
-      v12 = (char *)a6 - (char *)static_AE4F90;
-      a6 = (RenderVertexSoft *)a5;
-      do
+	  for(int i=0; i < a5;i++)
       {
-        v13 = (RenderVertexSoft *)((char *)v11 + v12);
-        v14 = v11;
-        ++v11;
-        v15 = a6 == (RenderVertexSoft *)1;
-        a6 = (RenderVertexSoft *)((char *)a6 - 1);
-        memcpy(v14, v13, 0x30u);
+        memcpy(&static_AE4F90[i], a6, 0x30u);
+		++a6;
       }
-      while ( !v15 );
-    }
     v16 = a4;
     if ( pGame->pIndoorCameraD3D->_437376(a4, static_AE4F90, (unsigned int *)&a5) == 1 )
     {
@@ -221,14 +213,11 @@
   int _a7 = 0;
   if ( this->uNumDecals > 0 )
   {
-    a6 = (RenderVertexSoft *)this->std__vector_30B00C;
+    a6b = this->std__vector_30B00C;
     do
     {
-      v21 = &pBloodsplatContainer->std__vector_pBloodsplats[LODWORD(a6->vWorldPosition.x)];
-      *(float *)&v37 = v21->z;
-      v36 = v21->y;
-      v35 = v21->x;
-      v22 = _43F5C8_get_point_light_level_with_respect_to_lights(light_level, uSectorID, v35, v36, *(float *)&v37);
+      v21 = &pBloodsplatContainer->std__vector_pBloodsplats[*a6b];
+      v22 = _43F5C8_get_point_light_level_with_respect_to_lights(light_level, uSectorID, v21->x, v21->y, v21->z);
       v23 = v21->b;
       v24 = v21->x;
       v42 = v22;
@@ -242,22 +231,22 @@
       v37 = a8;
       v40 = (signed __int64)v26;
       v28 = v21->dot_dist;
-      LODWORD(v36) = (uint32)a6;
+      //LODWORD(v36) = (uint32)a6;
       a5a = v25;
       v39 = v27;
       LODWORD(v35) = a5;
       v34 = &static_AE4F60;
-      *(float *)&v33 = v28;
+      v33 = v28;
       v32 = v23 | (v22 << 8);
-      *(float *)&v29 = v21->radius;
-      v30 = (int)v21;
+      v29 = v21->radius;
+      //v30 = (int)v21;
       //v31 = thisa;
-      if ( !this->_49B790_build_decal_geometry(v42, a3, v30, (int)&a5a, v29, v43, v33, &static_AE4F60, a5, a6, a8) )
+      if ( !this->_49B790_build_decal_geometry(v42, a3, (DecalBuilder_stru0 *)v21, (int)&a5a, SLODWORD(v29), v43, v33, &static_AE4F60, a5, a6, a8) )
       {
       MessageBoxW(nullptr, L"Error: Failed to build decal geometry", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:114", 0);
       }
       ++_a7;
-      a6 = (RenderVertexSoft *)((char *)a6 + 4);
+      ++a6b;
     }
     while ( _a7 < this->uNumDecals );
   }
@@ -265,11 +254,11 @@
 }
 
 //----- (0049B790) --------------------------------------------------------
-char DecalBuilder::_49B790_build_decal_geometry(int a2, char a3, int a4, int a5, int a6, unsigned int uColorMultiplier, RenderVertexSoft *a8, stru314 *a9, signed int a10, RenderVertexSoft *a11, char uClipFlags)
+char DecalBuilder::_49B790_build_decal_geometry(int a2, char a3, DecalBuilder_stru0 *a4, int a5, float a6, unsigned int uColorMultiplier, float a8, stru314 *a9, signed int a10, RenderVertexSoft *a11, char uClipFlags)
 {
   DecalBuilder *v12; // esi@1
   Decal *v13; // edi@2
-  char *v14; // eax@2
+  int *v14; // eax@2
   double v15; // st7@4
   double v16; // st7@4
   int v17; // eax@4
@@ -295,30 +284,34 @@
   std::string v37; // [sp-4h] [bp-24h]@15
   float v38; // [sp+8h] [bp-18h]@6
   RenderVertexSoft *v39; // [sp+Ch] [bp-14h]@6
-  unsigned int *v40; // [sp+10h] [bp-10h]@6
+  unsigned int v40; // [sp+10h] [bp-10h]@6
+
+  int a6a;
+  RenderVertexSoft *a8a;
+  unsigned int a8b = 0;
 
   v12 = this;
-  if ( *(float *)&a6 == 0.0 )
-    goto LABEL_24;
+  if ( a6 == 0.0 )
+    return 1;
   v13 = &this->std__vector_pDecals[this->field_308008];
-  v14 = (char *)&this->std__vector_pDecals[this->field_308008].field_C1C;
-  this->std__vector_pDecals[this->field_308008].field_C18 = (DecalBuilder_stru0 *)a4;
-  *(int *)v14 = 0;
+  v14 = &this->std__vector_pDecals[this->field_308008].field_C1C;
+  this->std__vector_pDecals[this->field_308008].field_C18 = a4;
+  *v14 = 0;
   if ( a3 & 2 )
-    *(int *)v14 = 1;
-  v15 = *(float *)&a6 - *(float *)&a8;
-  *(float *)&this->field_30C028 = v15;
-  v16 = sqrt((*(float *)&a6 + *(float *)&a6 - v15) * v15);
-  *(float *)&v12->field_30C02C = v16;
+    *v14 = 1;
+  v15 = a6 - a8;
+  this->field_30C028 = v15;
+  v16 = sqrt((a6 + a6 - v15) * v15);
+  v12->field_30C02C = v16;
   v17 = a5;
   v18 = a9;
-  v12->flt_30C030 = 1.0 - (*(float *)&a6 - v16) / *(float *)&a6;
-  v13->field_C08 = (signed __int64)((double)*(signed int *)v17 - *(float *)&a8 * v18->field_4.x);
-  v13->field_C0A = (signed __int64)((double)*(signed int *)(a5 + 4) - *(float *)&a8 * v18->field_4.y);
-  v19 = *(float *)&a6;
-  v13->field_C0C = (signed __int64)((double)*(signed int *)(a5 + 8) - *(float *)&a8 * v18->field_4.z);
+  v12->flt_30C030 = 1.0 - (a6 - v16) / a6;
+  v13->field_C08 = (signed __int64)((double)*(signed int *)v17 - a8 * v18->field_4.x);
+  v13->field_C0A = (signed __int64)((double)*(signed int *)(a5 + 4) - a8 * v18->field_4.y);
+  v19 = a6;
+  v13->field_C0C = (signed __int64)((double)*(signed int *)(a5 + 8) - a8 * v18->field_4.z);
   v20 = v19 * v12->flt_30C030;
-  a8 = v13->pVertices;
+  a8a = v13->pVertices;
   v12->field_30C034 = v20;
   v12->field_30C010 = v20 * v18->field_10.x;
   v12->field_30C014 = v20 * v18->field_10.y;
@@ -326,19 +319,19 @@
   v12->field_30C01C = v20 * v18->field_1C.x;
   v12->field_30C020 = v20 * v18->field_1C.y;
   v12->field_30C024 = v20 * v18->field_1C.z;
-  a6 = v13->field_C08;
-  v21 = (double)a6;
+  a6a = v13->field_C08;
+  v21 = (double)a6a;
   v22 = v21 - v12->field_30C01C;
-  a6 = v13->field_C0A;
+  a6a = v13->field_C0A;
   v13->pVertices[0].vWorldPosition.x = v22 + v12->field_30C010;
-  v23 = (double)a6;
+  v23 = (double)a6a;
   v24 = v23 - v12->field_30C020 + v12->field_30C014;
   v25 = (char *)&v13->pVertices[0].vWorldPosition.y;
   a6 = v13->field_C0C;
   v26 = 4;
   v13->pVertices[0].vWorldPosition.y = v24;
-  v27 = (double)a6;
-  *(float *)&a6 = v27;
+  v27 = (double)a6a;
+  a6 = v27;
   v13->pVertices[0].vWorldPosition.z = v27 - v12->field_30C024 + v12->field_30C018;
   v13->pVertices[0].u = 0.0;
   v13->pVertices[0].v = 0.0;
@@ -354,7 +347,7 @@
   v13->pVertices[2].v = 1.0;
   v13->pVertices[3].vWorldPosition.x = v21 + v12->field_30C01C + v12->field_30C010;
   v13->pVertices[3].vWorldPosition.y = v23 + v12->field_30C020 + v12->field_30C014;
-  v13->pVertices[3].vWorldPosition.z = *(float *)&a6 + v12->field_30C024 + v12->field_30C018;
+  v13->pVertices[3].vWorldPosition.z = a6 + v12->field_30C024 + v12->field_30C018;
   v13->pVertices[3].u = 1.0;
   v13->pVertices[3].v = 0.0;
   do
@@ -371,28 +364,27 @@
   }
   while ( v26 );
   v13->uColorMultiplier = uColorMultiplier;
-  v40 = (unsigned int *)&v13->uNumVertices;
+  //v40 = (unsigned int *)&v13->uNumVertices;
   v39 = v13->pVertices;
   v13->uNumVertices = 4;
   v13->field_C14 = a2;
   v29 = v18->field_4.z;
-  a6 = (int)&v13->uNumVertices;
+  //a6a = (unsigned int *)&v13->uNumVertices;
   v38 = v29;
-  result = pGame->pStru9Instance->_4980B9(a11, a10, v18->field_4.x, v18->field_4.y, v38, v39, v40);
+  result = pGame->pStru9Instance->_4980B9(a11, a10, v18->field_4.x, v18->field_4.y, v38, v39, (unsigned int*)&v13->uNumVertices);
   if ( result )
   {
-    v31 = (unsigned int *)a6;
-    if ( !*(int *)a6 )
-      goto LABEL_24;
-    v32 = a8;
-    v40 = *(unsigned int **)a6;
-    v39 = a8;
-    pGame->pIndoorCameraD3D->ViewTransform(a8, (unsigned int)v40);
+    //v31 = a6a;
+    if ( !v13->uNumVertices )
+      return 1;
+    v32 = a8a;
+    //v40 = *a6a;
+    v39 = a8a;
+    pGame->pIndoorCameraD3D->ViewTransform(a8a, (unsigned int)v13->uNumVertices);
     v40 = 0;
-    pGame->pIndoorCameraD3D->Project(v32, *v31, 0);
+    pGame->pIndoorCameraD3D->Project(v32, v13->uNumVertices, 0);
     if ( !(uClipFlags & 1) )
     {
-LABEL_19:
       ++v12->field_308008;
       v34 = 1024;
       if ( v12->field_308008 == 1024 )
@@ -400,41 +392,52 @@
       if ( (signed int)(v12->std__vector_pDecals_size + 1) <= 1024 )
         v34 = v12->std__vector_pDecals_size + 1;
       v12->std__vector_pDecals_size = v34;
-      goto LABEL_24;
+      return 1;
     }
     if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
     {
       if ( uClipFlags & 2 )
       {
-        v40 = (unsigned int *)&a8;
+        v40 = (int)&a8;
         v39 = v12->pVertices;
-        pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v32, *v31, v12->pVertices, (unsigned int *)&a8);
-LABEL_14:
-        v40 = v31;
+        pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v32, *v31, v12->pVertices, &a8b);
+        v40 = (int)v31;
         v39 = v12->pVertices;
-        pGame->pIndoorCameraD3D->_437143((unsigned int)a8, v32, v12->pVertices, v31);
-        goto LABEL_18;
+        pGame->pIndoorCameraD3D->_437143(a8b, v32, v12->pVertices, v31);
       }
-      if ( uClipFlags & 4 )
+      else if ( uClipFlags & 4 )
       {
-        v40 = (unsigned int *)&a8;
+        v40 = (int)&a8;
+        v39 = v12->pVertices;
+        pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v32, *v31, v12->pVertices, &a8b);
+        v40 = (int)v31;
         v39 = v12->pVertices;
-        pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v32, *v31, v12->pVertices, (unsigned int *)&a8);
-        goto LABEL_14;
+        pGame->pIndoorCameraD3D->_437143(a8b, v32, v12->pVertices, v31);
       }
-      v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:258";
-      v35 = "Undefined clip flag specified";
+	  else
+	  {
+        v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:258";
+        v35 = "Undefined clip flag specified";
+	    MessageBoxA(nullptr, v35, (const char *)v39, 0);
+	  }
     }
     else
     {
       v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:263";
       v35 = "Lightpoly builder native indoor clipping not implemented";
+	  MessageBoxA(nullptr, v35, (const char *)v39, 0);
     }
-      MessageBoxA(nullptr, v35, (const char *)v39, 0);
-LABEL_18:
-    if ( *(float *)&a8 != 0.0 )
-      goto LABEL_19;
-LABEL_24:
+    if ( a8b != 0 )
+	{
+      ++v12->field_308008;
+      v34 = 1024;
+      if ( v12->field_308008 == 1024 )
+        v12->field_308008 = 0;
+      if ( (signed int)(v12->std__vector_pDecals_size + 1) <= 1024 )
+        v34 = v12->std__vector_pDecals_size + 1;
+      v12->std__vector_pDecals_size = v34;
+      return 1;
+	}
     result = 1;
   }
   return result;
@@ -445,6 +448,7 @@
 {
   double v7; // st7@12
 
+  uNumDecals = 0;  
   if (!pBloodsplatContainer->std__vector_pBloodsplats_size)
     return true;
   
@@ -454,7 +458,6 @@
     return true;
   if (pFace->Fluid())
     return true;
-
   for (uint i = 0; i < pBloodsplatContainer->std__vector_pBloodsplats_size; ++i)
   {
     auto pBloodsplat = pBloodsplatContainer->std__vector_pBloodsplats + i;
@@ -483,80 +486,52 @@
 //----- (0049BCEB) --------------------------------------------------------
 char DecalBuilder::ApplyDecals_OutdoorFace(ODMFace *pFace)
 {
-  int v2; // edi@1
-  unsigned int v3; // eax@2
-  char *v4; // edx@5
-  double v5; // ST1C_8@12
-  double v6; // ST14_8@12
-  double v7; // ST0C_8@12
-  double v8; // st7@12
-  unsigned int v10; // [sp+20h] [bp-1Ch]@1
+	double v8; // st7@12
+	unsigned int v10; // [sp+20h] [bp-1Ch]@1
+
+	Bloodsplat *pBloodsplat;
 
-  v2 = 0;
-  this->uNumDecals = 0;
-  v10 = pBloodsplatContainer->std__vector_pBloodsplats_size;
-  if ( pBloodsplatContainer->std__vector_pBloodsplats_size )
-  {
-    v3 = pFace->uAttributes;
-    if ( !(v3 & 0x400000) )
-    {
-      if ( !(v3 & 0x10) && (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 )
-      {
-        v4 = (char *)&pBloodsplatContainer->std__vector_pBloodsplats[0].y;
-        do
-        {
-          if ( (double)pFace->pBoundingBox.x1 - *((float *)v4 + 2) < *((float *)v4 - 1) )
-          {
-            if ( (double)pFace->pBoundingBox.x2 + *((float *)v4 + 2) > *((float *)v4 - 1) )
-            {
-              if ( (double)pFace->pBoundingBox.y1 - *((float *)v4 + 2) < *(float *)v4 )
-              {
-                if ( (double)pFace->pBoundingBox.y2 + *((float *)v4 + 2) > *(float *)v4 )
-                {
-                  if ( (double)pFace->pBoundingBox.z1 - *((float *)v4 + 2) < *((float *)v4 + 1) )
-                  {
-                    if ( (double)pFace->pBoundingBox.z2 + *((float *)v4 + 2) > *((float *)v4 + 1) )
-                    {
-                      v5 = *((float *)v4 - 1) + 6.7553994e15;
-                      v6 = *(float *)v4 + 6.7553994e15;
-                      v7 = *((float *)v4 + 1) + 6.7553994e15;
-                      v8 = (double)((pFace->pFacePlane.dist
-                                   + LODWORD(v5) * pFace->pFacePlane.vNormal.x
-                                   + LODWORD(v6) * pFace->pFacePlane.vNormal.y
-                                   + LODWORD(v7) * pFace->pFacePlane.vNormal.z) >> 16);
-                      if ( v8 <= *((float *)v4 + 2) )
-                      {
-                        *((float *)v4 + 3) = v8;
-                        this->std__vector_30B00C[this->uNumDecals++] = v2;
-                      }
-                    }
-                  }
-                }
-              }
-            }
-          }
-          ++v2;
-          v4 += 40;
-        }
-        while ( v2 < (signed int)v10 );
-      }
-    }
-  }
-  return 1;
+	this->uNumDecals = 0;
+	v10 = pBloodsplatContainer->std__vector_pBloodsplats_size;
+	if ( !(pFace->uAttributes & 0x400000) && !(pFace->uAttributes & 0x10) )
+	{
+		for(int i = 0; i < pBloodsplatContainer->std__vector_pBloodsplats_size; i++ )
+		{
+			pBloodsplat = &pBloodsplatContainer->std__vector_pBloodsplats[i];
+			if ( (double)pFace->pBoundingBox.x1 - pBloodsplat->radius < pBloodsplat->x &&
+				(double)pFace->pBoundingBox.x2 + pBloodsplat->radius > pBloodsplat->x &&
+				(double)pFace->pBoundingBox.y1 - pBloodsplat->radius < pBloodsplat->y &&
+				(double)pFace->pBoundingBox.y2 + pBloodsplat->radius > pBloodsplat->y &&
+				(double)pFace->pBoundingBox.z1 - pBloodsplat->radius < pBloodsplat->z &&
+				(double)pFace->pBoundingBox.z2 + pBloodsplat->radius > pBloodsplat->z )
+			{
+				v8 = (double)((pFace->pFacePlane.dist
+							+ round(pBloodsplat->x) * pFace->pFacePlane.vNormal.x
+							+ round(pBloodsplat->y) * pFace->pFacePlane.vNormal.y
+							+ round(pBloodsplat->z) * pFace->pFacePlane.vNormal.z) >> 16);
+				if ( v8 <= pBloodsplat->radius )
+				{
+					pBloodsplat->dot_dist = v8;
+					this->std__vector_30B00C[this->uNumDecals++] = i;
+				}
+			}
+		}
+	}
+	return 1;
 }
 
 //----- (0049BE8A) --------------------------------------------------------
-bool DecalBuilder::_49BE8A(struct stru148 *a2, float a3, int a4, RenderVertexSoft *a5, unsigned int uStripType, char a7)
+bool DecalBuilder::_49BE8A(struct stru148 *a2, Vec3_float_ *_a3, float *a4, RenderVertexSoft *a5, unsigned int uStripType, char a7)
 {
   bool result; // eax@1
   RenderVertexSoft *v8; // edi@3
-  float v9; // ebx@3
-  char *v10; // esi@3
+  Vec3_float_ *v9; // ebx@3
+  Bloodsplat *v10; // esi@3
   float v11; // eax@5
   float v12; // eax@6
   double v13; // st7@13
   double v14; // st7@19
-  int v15; // eax@20
+  short v15; // eax@20
   int v16; // eax@22
   int v17; // edx@24
   DecalBuilder *v18; // eax@24
@@ -574,9 +549,10 @@
   float v30; // [sp+30h] [bp-Ch]@6
   float v31; // [sp+34h] [bp-8h]@6
   bool v32; // [sp+38h] [bp-4h]@2
+  float a3;
 
   this->uNumDecals = 0;
-  result = pBloodsplatContainer->std__vector_pBloodsplats_size;
+  result = pBloodsplatContainer->std__vector_pBloodsplats_size != 0;
   v24 = this;
   v23 = pBloodsplatContainer->std__vector_pBloodsplats_size;
   if ( pBloodsplatContainer->std__vector_pBloodsplats_size )
@@ -585,11 +561,20 @@
     if ( (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 )
     {
       v8 = a5;
-      v9 = a3;
-      v10 = (char *)&pBloodsplatContainer->std__vector_pBloodsplats[0].y;
-      while ( uStripType != 4 )
+      v9 = _a3;
+	  v10 = pBloodsplatContainer->std__vector_pBloodsplats;
+      while ( v32 < (signed int)v23)
       {
-        if ( uStripType == 3 )
+		if ( uStripType == 4 )
+		{
+		  a3 = v8->vWorldPosition.x;
+		  v11 = v8[3].vWorldPosition.x;
+		  v31 = v11;
+		  v30 = v8[1].vWorldPosition.y;
+		  v12 = v8->vWorldPosition.y;
+		  v29 = v12;
+		}
+		else if ( uStripType == 3 )
         {
           if ( a7 )
           {
@@ -597,83 +582,67 @@
             v31 = v8[2].vWorldPosition.x;
             v30 = v8[1].vWorldPosition.y;
             v12 = v8[2].vWorldPosition.y;
-            goto LABEL_7;
+            v29 = v12;
           }
-          a3 = v8[1].vWorldPosition.x;
-          v11 = v8[2].vWorldPosition.x;
-LABEL_6:
-          v31 = v11;
-          v30 = v8[1].vWorldPosition.y;
-          v12 = v8->vWorldPosition.y;
-LABEL_7:
-          v29 = v12;
-          goto LABEL_13;
+		  else
+		  {
+			  a3 = v8[1].vWorldPosition.x;
+			  v11 = v8[2].vWorldPosition.x;
+			  v31 = v11;
+			  v30 = v8[1].vWorldPosition.y;
+			  v12 = v8->vWorldPosition.y;
+			  v29 = v12;
+		  }
         }
-      MessageBoxW(nullptr, L"Uknown strip type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:434", 0);
-LABEL_13:
+		else
+			MessageBoxW(nullptr, L"Uknown strip type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:434", 0);
         v21 = uStripType;
         v13 = pGame->pIndoorCameraD3D->GetPolygonMinZ(v8, uStripType);
         v21 = uStripType;
         v28 = v13;
         v26 = pGame->pIndoorCameraD3D->GetPolygonMaxZ(v8, uStripType);
-        if ( a3 - *((float *)v10 + 2) < *((float *)v10 - 1) )
+		if ( a3 - v10->radius < v10->x &&
+			v31 + v10->radius > v10->x &&
+			v30 - v10->radius < v10->y &&
+            v29 + v10->radius > v10->y &&
+            v28 - v10->radius < v10->z &&
+            v26 + v10->radius > v10->z )
         {
-          if ( v31 + *((float *)v10 + 2) > *((float *)v10 - 1) )
-          {
-            if ( v30 - *((float *)v10 + 2) < *(float *)v10 )
-            {
-              if ( v29 + *((float *)v10 + 2) > *(float *)v10 )
-              {
-                if ( v28 - *((float *)v10 + 2) < *((float *)v10 + 1) )
-                {
-                  if ( v26 + *((float *)v10 + 2) > *((float *)v10 + 1) )
-                  {
-                    Vec3_float_::NegDot(&v8->vWorldPosition, (Vec3_float_ *)LODWORD(v9), (float *)a4);
-                    v26 = *(float *)(LODWORD(v9) + 4) * *(float *)v10
-                        + *(float *)(LODWORD(v9) + 8) * *((float *)v10 + 1)
-                        + *(unsigned int *)LODWORD(v9) * *((float *)v10 - 1)
-                        + *(float *)a4;
-                    v22 = v26 + 6.7553994e15;
-                    v25 = LODWORD(v22);
-                    v14 = (double)SLODWORD(v22);
-                    v28 = v14;
-                    if ( v14 <= *((float *)v10 + 2) )
-                    {
-                      v15 = *(int *)&a2->flags;
-                      if ( v15 & 2 || BYTE1(v15) & 1 )
-                      {
-                        v16 = *((int *)v10 + 5);
-                        if ( !(v16 & 1) )
-                        {
-                          LOBYTE(v16) = v16 | 1;
-                          *((int *)v10 + 5) = v16;
-                          *((_QWORD *)v10 + 3) = pEventTimer->Time();
-                        }
-                      }
-                      v17 = v32;
-                      *((int *)v10 + 3) = LODWORD(v28);
-                      v18 = v24;
-                      v24->std__vector_30B00C[v24->uNumDecals] = v17;
-                      ++v18->uNumDecals;
-                    }
-                  }
-                }
-              }
-            }
-          }
+			Vec3_float_::NegDot(&v8->vWorldPosition, v9, a4);
+			v26 = v9->y * v10->y
+				+ v9->z * v10->z
+				+ v9->x * v10->x
+				+ *a4;
+			v22 = v26 + 6.7553994e15;
+			v25 = LODWORD(v22);
+			v14 = (double)SLODWORD(v22);
+			v28 = v14;
+			if ( v14 <= v10->radius )
+			{
+				v15 = a2->flags;
+				if ( v15 & 2 || BYTE1(v15) & 1 )
+				{
+					v16 = v10->field_1C;
+					if ( !(v16 & 1) )
+					{
+						LOBYTE(v16) = v16 | 1;
+						v10->field_1C = v16;
+						v10->field_20 = pEventTimer->Time();
+					}
+				}
+				v17 = v32;
+				v10->dot_dist = LODWORD(v28);
+				v18 = v24;
+				v24->std__vector_30B00C[v24->uNumDecals] = v17;
+				++v18->uNumDecals;
+			}
         }
         ++v32;
-        v10 += 40;
+        ++v10;
         result = v32;
-        if ( v32 >= (signed int)v23 )
-          goto LABEL_26;
       }
-      a3 = v8->vWorldPosition.x;
-      v11 = v8[3].vWorldPosition.x;
-      goto LABEL_6;
     }
   }
-LABEL_26:
   LOBYTE(result) = 1;
   return result;
 }
@@ -787,23 +756,8 @@
 //----- (0049C550) --------------------------------------------------------
 void DecalBuilder::DrawDecalDebugOutlines()
 {
-  DecalBuilder *v1; // esi@1
-  signed int v2; // ebx@1
-  RenderVertexSoft *v3; // edi@2
-
-  v1 = this;
-  v2 = 0;
-  if ( (signed int)this->std__vector_pDecals_size > 0 )
-  {
-    v3 = this->std__vector_pDecals[0].pVertices;
-    do
-    {
-      pGame->pIndoorCameraD3D->debug_outline_sw(v3, *((int *)v3 - 1), 0xC86400u, 0.0);
-      ++v2;
-      v3 = (RenderVertexSoft *)((char *)v3 + 3104);
-    }
-    while ( v2 < (signed int)v1->std__vector_pDecals_size );
-  }
+  for(int i = 0; i < std__vector_pDecals_size; i++)
+	pGame->pIndoorCameraD3D->debug_outline_sw(std__vector_pDecals[i].pVertices, std__vector_pDecals[i].uNumVertices, 0xC86400u, 0.0);
 }
 
 //----- (0040E4C2) --------------------------------------------------------
--- a/DecalBuilder.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/DecalBuilder.h	Sat Jun 01 10:32:31 2013 +0600
@@ -1,6 +1,79 @@
 #pragma once
 #include "Render.h"
 
+/*  158 */
+#pragma pack(push, 1)
+struct Bloodsplat
+{
+  //----- (0043B538) --------------------------------------------------------
+  inline Bloodsplat()
+  {
+    this->field_1C = 0;
+    this->field_20 = 0;
+    //this->field_24 = 0;
+    //this->vdestructor_ptr = &Bloodsplat_pvdtor;
+  }
+
+  //----- (0043B54C) --------------------------------------------------------
+  //void __thiscall Bloodsplat::vdtor(Bloodsplat *this, char a2)
+
+  //----- (0043B569) --------------------------------------------------------
+  virtual ~Bloodsplat()
+  {
+  }
+
+  //void (__thiscall ***vdestructor_ptr)(Bloodsplat *, bool);
+  float x;
+  float y;
+  float z;
+  float radius;
+  float dot_dist;
+  char r;
+  char g;
+  char b;
+  char field_1B;
+  int field_1C;
+  unsigned long long field_20;
+  //int field_24;
+};
+#pragma pack(pop)
+
+/*  159 */
+#pragma pack(push, 1)
+struct BloodsplatContainer
+{
+  //----- (0043B688) --------------------------------------------------------
+  inline BloodsplatContainer()
+  {
+  /*_eh_vector_constructor_iterator_(
+    this->std__vector_pBloodsplats,
+    40,
+    64,
+    (void (__thiscall *)(void *))Bloodsplat::Bloodsplat,
+    (void (__thiscall *)(void *))Bloodsplat::dtor);
+  v1->std__vector_pBloodsplats_size = 0;*/
+    uNumBloodsplats = 0;
+  }
+  //----- (0043B6D6) --------------------------------------------------------
+  virtual ~BloodsplatContainer()
+  {
+    //this->vdestructor_ptr = &BloodsplatContainer_pvdtor;
+    //_eh_vector_destructor_iterator_(this->std__vector_pBloodsplats, 40, 64, Bloodsplat::dtor);
+  }
+
+
+  bool AddBloodsplat(float x, float y, float z, float r, float g, float b, float radius, int a8, int a9);
+  bool AddBloodsplat(float x, float y, float z, float radius, char r, char g, char b);
+
+
+  //void (__thiscall ***vdestructor_ptr)(BloodsplatContainer *, bool);
+  Bloodsplat std__vector_pBloodsplats[64];
+  unsigned int std__vector_pBloodsplats_size;
+  int uNumBloodsplats;
+};
+#pragma pack(pop)
+
+extern struct BloodsplatContainer *pBloodsplatContainer; // idb
 
 #pragma pack(push, 1)
 struct DecalBuilder_stru0
@@ -92,10 +165,10 @@
   bool AddBloodsplat(float x, float y, float z, float r, float g, float b, float radius, int a8, int a9);
   void Reset(unsigned int bPreserveBloodsplats);
   char ApplyDecals(int light_level, char a3, struct stru154 *a4, int a5, struct RenderVertexSoft *a6, struct IndoorCameraD3D_Vec4 *a7, char a8, unsigned int uSectorID);
-  char _49B790_build_decal_geometry(int a2, char a3, int a4, int a5, int a6, unsigned int uColorMultiplier, struct RenderVertexSoft *a8, struct stru314 *a9, signed int a10, struct RenderVertexSoft *a11, char uClipFlags);
+  char _49B790_build_decal_geometry(int a2, char a3, DecalBuilder_stru0 *a4, int a5, float a6, unsigned int uColorMultiplier, float a8, struct stru314 *a9, signed int a10, struct RenderVertexSoft *a11, char uClipFlags);
   bool ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID);
   char ApplyDecals_OutdoorFace(ODMFace *pFace);
-  bool _49BE8A(struct stru148 *a2, float a3, int a4, struct RenderVertexSoft *a5, unsigned int uStripType, char a7);
+  bool _49BE8A(struct stru148 *a2, Vec3_float_ *a3, float *a4, struct RenderVertexSoft *a5, unsigned int uStripType, char a7);
   void DrawDecal(Decal *pDecal, float z_bias);
   void DrawDecals(float z_bias);
   void DrawBloodsplats();
@@ -116,8 +189,8 @@
   float field_30C01C;
   float field_30C020;
   float field_30C024;
-  int field_30C028;
-  int field_30C02C;
+  float field_30C028;
+  float field_30C02C;
   float flt_30C030;
   float field_30C034;
 };
@@ -129,78 +202,3 @@
 
 
 
-/*  158 */
-#pragma pack(push, 1)
-struct Bloodsplat
-{
-  //----- (0043B538) --------------------------------------------------------
-  inline Bloodsplat()
-  {
-    this->field_1C = 0;
-    this->field_20 = 0;
-    this->field_24 = 0;
-    //this->vdestructor_ptr = &Bloodsplat_pvdtor;
-  }
-
-  //----- (0043B54C) --------------------------------------------------------
-  //void __thiscall Bloodsplat::vdtor(Bloodsplat *this, char a2)
-
-  //----- (0043B569) --------------------------------------------------------
-  virtual ~Bloodsplat()
-  {
-  }
-
-  //void (__thiscall ***vdestructor_ptr)(Bloodsplat *, bool);
-  float x;
-  float y;
-  float z;
-  float radius;
-  float dot_dist;
-  char r;
-  char g;
-  char b;
-  char field_1B;
-  int field_1C;
-  int field_20;
-  int field_24;
-};
-#pragma pack(pop)
-
-/*  159 */
-#pragma pack(push, 1)
-struct BloodsplatContainer
-{
-  //----- (0043B688) --------------------------------------------------------
-  inline BloodsplatContainer()
-  {
-  /*_eh_vector_constructor_iterator_(
-    this->std__vector_pBloodsplats,
-    40,
-    64,
-    (void (__thiscall *)(void *))Bloodsplat::Bloodsplat,
-    (void (__thiscall *)(void *))Bloodsplat::dtor);
-  v1->std__vector_pBloodsplats_size = 0;*/
-    uNumBloodsplats = 0;
-  }
-  //----- (0043B6D6) --------------------------------------------------------
-  virtual ~BloodsplatContainer()
-  {
-    //this->vdestructor_ptr = &BloodsplatContainer_pvdtor;
-    //_eh_vector_destructor_iterator_(this->std__vector_pBloodsplats, 40, 64, Bloodsplat::dtor);
-  }
-
-
-  bool AddBloodsplat(float x, float y, float z, float r, float g, float b, float radius, int a8, int a9);
-  bool AddBloodsplat(float x, float y, float z, float radius, char r, char g, char b);
-
-
-  //void (__thiscall ***vdestructor_ptr)(BloodsplatContainer *, bool);
-  Bloodsplat std__vector_pBloodsplats[64];
-  unsigned int std__vector_pBloodsplats_size;
-  int uNumBloodsplats;
-};
-#pragma pack(pop)
-
-
-
-extern struct BloodsplatContainer *pBloodsplatContainer; // idb
\ No newline at end of file
--- a/DecorationList.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/DecorationList.h	Sat Jun 01 10:32:31 2013 +0600
@@ -25,10 +25,10 @@
 #pragma pack(push, 1)
 struct DecorationDesc
 {
-  inline bool CanMoveThrough() {return uFlags & DECORATION_MOVE_THROUGH;}
-  inline bool DontDraw()       {return uFlags & DECORATION_DONT_DRAW;} 
-  inline bool SoundOnDawn()    {return uFlags & DECORATION_SOUND_ON_DAWN;}
-  inline bool SoundOnDusk()    {return uFlags & DECORATION_SOUND_ON_DUSK;}
+  inline bool CanMoveThrough() {return (uFlags & DECORATION_MOVE_THROUGH) != 0;}
+  inline bool DontDraw()       {return (uFlags & DECORATION_DONT_DRAW) != 0;} 
+  inline bool SoundOnDawn()    {return (uFlags & DECORATION_SOUND_ON_DAWN) != 0;}
+  inline bool SoundOnDusk()    {return (uFlags & DECORATION_SOUND_ON_DUSK) != 0;}
 
   char pName[32];
   char field_20[32];
--- a/Events.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/Events.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -497,7 +497,7 @@
 				strcpy(Str, Source);
 				v16 = RemoveQuotes(Str);
 				VideoPlayer::MovieLoop(v16, 0, v14, 1);
-				if ( !_strcmpi(v16, "arbiter good") )
+				if ( !_stricmp(v16, "arbiter good") )
                 {
                   pParty->alignment = PartyAlignment_Good;
 					v18 = 0;
@@ -519,7 +519,7 @@
 					//v7 = "";
 					break;
 					}
-				if ( !_strcmpi(v16, "arbiter evil") )
+				if ( !_stricmp(v16, "arbiter evil") )
 					{
 					v18 = 2;
 					pParty->alignment = PartyAlignment_Evil;
@@ -541,7 +541,7 @@
 
 					break;
 					}
-				if ( !_strcmpi(v16, "pcout01") )    // moving to harmondale from emerald isle
+				if ( !_stricmp(v16, "pcout01") )    // moving to harmondale from emerald isle
                 {
 					Rest(0x2760u);
 					pParty->RestAndHeal();
@@ -1115,8 +1115,8 @@
 					return;
 					}
 				v84 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8);
-				if ( !_strcmpi(GameUI_Footer_TimedString, &pLevelStr[pLevelStrOffsets[_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8)]])
-					|| !_strcmpi(GameUI_Footer_TimedString, &pLevelStr[pLevelStrOffsets[v84]]) )
+				if ( !_stricmp(GameUI_Footer_TimedString, &pLevelStr[pLevelStrOffsets[_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8)]])
+					|| !_stricmp(GameUI_Footer_TimedString, &pLevelStr[pLevelStrOffsets[v84]]) )
 					{
 					v11 = _evt->v17;
 LABEL_130:
--- a/Events.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/Events.h	Sat Jun 01 10:32:31 2013 +0600
@@ -58,7 +58,7 @@
   unsigned char v32;
   unsigned char tail[128];
 };
-#pragma pop()
+#pragma pack(pop)
 
 
 
--- a/GUIWindow.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/GUIWindow.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -175,7 +175,7 @@
           return result;
         }
       }
-      if ( v4->uFrameX || v4->uFrameY || !(v4->uFrameWidth == 640 & v4->uFrameHeight == 480) )
+      if ( v4->uFrameX || v4->uFrameY || !(v4->uFrameWidth == 640 && v4->uFrameHeight == 480) )
       {
         --v2;
         if ( v2 >= 0 )
@@ -905,7 +905,7 @@
   }
   //while ( (signed int)v3 < 11 );
 
-  CreateButton(0, 0, 0, 0, 1, 0, UIMSG_33, 0, '\t', "", 0);
+  CreateButton(0, 0, 0, 0, 1, 0, UIMSG_SpellBook_PressTab, 0, '\t', "", 0);
   if ( a2 )
     _41D08F_set_keyboard_control_group(a2, 0, 0, 0);
 
--- a/GUIWindow.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/GUIWindow.h	Sat Jun 01 10:32:31 2013 +0600
@@ -30,7 +30,7 @@
 
   UIMSG_31 = 49,
   UIMSG_32 = 50,
-  UIMSG_33 = 51,
+  UIMSG_SpellBook_PressTab = 51,
   UIMSG_34 = 52,
   UIMSG_35 = 53,
   UIMSG_MainMenu_ShowPartyCreationWnd = 54,
@@ -152,7 +152,7 @@
   UIMSG_BD = 189,
   UIMSG_CastSpell_BE = 190,
   UIMSG_BF = 191,
-  UIMSG_C0 = 192,
+  UIMSG_ClickAwardScrollBar = 192,
   UIMSG_C1 = 192,
   UIMSG_C2 = 192,
 
--- a/Game.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/Game.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -91,8 +91,8 @@
   }
   else
   {
-    if ( pParty->vPosition.x != pParty->vPrevPosition.x | pParty->sRotationY != pParty->sPrevRotationY | pParty->vPosition.y != pParty->vPrevPosition.y 
-       | pParty->sRotationX != pParty->sPrevRotationX | pParty->vPosition.z != pParty->vPrevPosition.z | pParty->sEyelevel != pParty->sPrevEyelevel )
+    if ( pParty->vPosition.x != pParty->vPrevPosition.x || pParty->sRotationY != pParty->sPrevRotationY || pParty->vPosition.y != pParty->vPrevPosition.y 
+       || pParty->sRotationX != pParty->sPrevRotationX || pParty->vPosition.z != pParty->vPrevPosition.z || pParty->sEyelevel != pParty->sPrevEyelevel )
       pParty->uFlags |= 2u;
     pParty->vPrevPosition.x = pParty->vPosition.x;
     pParty->vPrevPosition.y = pParty->vPosition.y;
@@ -510,7 +510,7 @@
       pParty->uFallSpeed = 0;
       pParty->field_6E4 = 0;
       pParty->field_6E0 = 0;
-      if ( _strcmpi(Source, pCurrentMapName) )
+      if ( _stricmp(Source, pCurrentMapName) )
       {
         strcpy(pCurrentMapName, Source);
         _5B65A8_npcdata_uflags_or_other = pParty->vPosition.x;
@@ -582,30 +582,21 @@
 //----- (0044F120) --------------------------------------------------------
 void Game::PushStationaryLights(int a2)
 {
-  signed int v3; // ebx@1
-  char *v4; // esi@2
-
-  auto v2 = this;
-  v3 = 0;
-  if ( (signed int)this->uNumStationaryLights > 0 )
-  {
-    v4 = (char *)&this->pStationaryLights[0].vRGBColor.y;
-    do
-    {
-      pStationaryLightsStack->AddLight(
-        (signed __int64)*((float *)v4 - 4),
-        (signed __int64)*((float *)v4 - 3),
-        (signed __int64)*((float *)v4 - 2),
-        (signed __int64)*((float *)v4 + 2),
-        (signed __int64)*((float *)v4 - 1),
-        (signed __int64)*(float *)v4,
-        (signed __int64)*((float *)v4 + 1),
-        byte_4E94D0);
-      ++v3;
-      v4 += 28;
-    }
-    while ( v3 < (signed int)v2->uNumStationaryLights );
-  }
+  Game__StationaryLight* pLight;
+ 
+  for( int i=0; i<uNumStationaryLights; ++i ) 
+      {
+       pLight=&pStationaryLights[i];
+       pStationaryLightsStack->AddLight(
+           pLight->vPosition.x, 
+           pLight->vPosition.y,
+           pLight->vPosition.z,
+           pLight->flt_18,
+           pLight->vRGBColor.x,
+           pLight->vRGBColor.y,
+           pLight->vRGBColor.z,
+           byte_4E94D0);
+      }
 }
 // 4E94D0: using guessed type char byte_4E94D0;
 
@@ -769,6 +760,7 @@
   if (pMouse)
     pMouse->Deactivate();
 
+  delete pRenderer;
   pAudioPlayer->Release();//error
   pNew_LOD->FreeSubIndexAndIO();
   pGames_LOD->FreeSubIndexAndIO();
--- a/GammaControl.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/GammaControl.h	Sat Jun 01 10:32:31 2013 +0600
@@ -2,8 +2,9 @@
 #include "lib\legacy_dx\d3d.h"
 
 #pragma pack(push, 1)
-struct GammaController
+class GammaController
 {
+public:
   GammaController();
   inline ~GammaController() {} //----- (0044F22E)
   
--- a/Indoor.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/Indoor.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -5,6 +5,7 @@
 #include "ParticleEngine.h"
 #include "stru9.h"
 #include "stru10.h"
+#include "stru367.h"
 
 #include "BSPModel.h"
 #include "Outdoor.h"
@@ -315,12 +316,13 @@
 void __fastcall sub_440BED(IndoorLocation_drawstru *_this)
 {
   unsigned __int16 *v1; // edi@7
-  char *v2; // esi@8
+  BspRenderer_stru0 *v2; // esi@8
   int v3; // ecx@9
   unsigned int v4; // edx@9
-  char *v5; // eax@10
+  short *v5; // eax@10
   signed int v6; // [sp+8h] [bp-8h]@7
   int v7; // [sp+Ch] [bp-4h]@8
+  short *v8;
 
   PrepareDrawLists_BLV(_this);
   if (pBLVRenderParams->uPartySectorID)
@@ -334,34 +336,28 @@
     if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES)
     {
       v1 = pBLVRenderParams->pRenderTarget;
-      v6 = 0;
-      if ( (signed int)pBspRenderer->num_nodes > 0 )
-      {
-        v7 = 0;
-        v2 = (char *)&pBspRenderer->nodes[0].field_C._viewport_space_w;
-        do
-        {
-          v3 = *((int *)v2 - 1);
-          v4 = pRenderer->uTargetSurfacePitch * *((int *)v2 - 1);
-          if ( v3 <= *(int *)v2 )
-          {
-            v5 = (char *)&pBspRenderer->nodes[0].field_C.array_3D8[v3 + v7];
-            do
-            {
-              v1[v4 + *((short *)v5 - 480)] = 255;
-              ++v3;
-              v1[v4 + *(short *)v5] = 255;
-              v4 += pRenderer->uTargetSurfacePitch;
-              v5 += 2;
-            }
-            while ( v3 <= *(int *)v2 );
-          }
-          ++v6;
-          v7 += 1126;
-          v2 += 2252;
-        }
-        while ( v6 < (signed int)pBspRenderer->num_nodes );
-      }
+	  v7 = 0;
+	  for(int i=0; i < pBspRenderer->num_nodes; i++)
+	  {		 
+		  BspRenderer_stru0 *pNode = &pBspRenderer->nodes[i];
+		  v4 = pRenderer->uTargetSurfacePitch * pNode->field_C._viewport_space_y;
+		  if ( pNode->field_C._viewport_space_y <= pNode->field_C._viewport_space_w )
+		  {
+			//v5 = (char *)&pBspRenderer->nodes[0].field_C.array_3D8[pNode->field_C._viewport_space_y + v7];
+			v5 = &pNode->field_C.array_3D8[pNode->field_C._viewport_space_y];
+			v8 = &pNode->field_C.array_18[pNode->field_C._viewport_space_y];
+			do
+			{
+				v1[v4 + *v8] = 255;
+				++pNode->field_C._viewport_space_y;
+				v1[v4 + *v5] = 255;
+				v4 += pRenderer->uTargetSurfacePitch;
+				++v5;
+				++v8;
+			}
+			while ( pNode->field_C._viewport_space_y <= pNode->field_C._viewport_space_w );
+		  }
+	  }
     }
   }
 }
@@ -1361,21 +1357,21 @@
     if (num_vertices < 2)
       return;
 
-    auto face_min_screenspace_x = _50BAC8_screen_space_x[0],
-         face_max_screenspace_x = _50BAC8_screen_space_x[0];
-    auto face_min_screenspace_y = _50B9D8_screen_space_y[0],
-         face_max_screenspace_y = _50B9D8_screen_space_y[0];
+    auto face_min_screenspace_x = stru_50B700._screen_space_x[0],
+         face_max_screenspace_x = stru_50B700._screen_space_x[0];
+    auto face_min_screenspace_y = stru_50B700._screen_space_y[0],
+         face_max_screenspace_y = stru_50B700._screen_space_y[0];
     for (uint i = 1; i < num_vertices; ++i)
     {
-      if (face_min_screenspace_x > _50BAC8_screen_space_x[i])
-        face_min_screenspace_x = _50BAC8_screen_space_x[i];
-      if (face_max_screenspace_x < _50BAC8_screen_space_x[i])
-        face_max_screenspace_x = _50BAC8_screen_space_x[i];
-
-      if (face_min_screenspace_y > _50B9D8_screen_space_y[i])
-        face_min_screenspace_y = _50B9D8_screen_space_y[i];
-      if (face_max_screenspace_y < _50B9D8_screen_space_y[i])
-        face_max_screenspace_y = _50B9D8_screen_space_y[i];
+      if (face_min_screenspace_x > stru_50B700._screen_space_x[i])
+        face_min_screenspace_x = stru_50B700._screen_space_x[i];
+      if (face_max_screenspace_x < stru_50B700._screen_space_x[i])
+        face_max_screenspace_x = stru_50B700._screen_space_x[i];
+
+      if (face_min_screenspace_y > stru_50B700._screen_space_y[i])
+        face_min_screenspace_y = stru_50B700._screen_space_y[i];
+      if (face_max_screenspace_y < stru_50B700._screen_space_y[i])
+        face_max_screenspace_y = stru_50B700._screen_space_y[i];
     }
 
       if (face_max_screenspace_x >= p->uViewportX &&
@@ -1516,25 +1512,25 @@
       v19 = v10;
       if ( v10 )
       {
-        v11 = _50BAC8_screen_space_x[0];
-        v12 = _50B9D8_screen_space_y[0];
-        v23 = _50BAC8_screen_space_x[0];
+        v11 = stru_50B700._screen_space_x[0];
+        v12 = stru_50B700._screen_space_y[0];
+        v23 = stru_50B700._screen_space_x[0];
         v13 = 1;
-        v22 = _50B9D8_screen_space_y[0];
+        v22 = stru_50B700._screen_space_y[0];
         if ( v10 > 1 )
         {
           do
           {
-            v14 = _50BAC8_screen_space_x[v13];
+            v14 = stru_50B700._screen_space_x[v13];
             if ( v14 < v23 )
-              v23 = _50BAC8_screen_space_x[v13];
+              v23 = stru_50B700._screen_space_x[v13];
             if ( v14 > v11 )
-              v11 = _50BAC8_screen_space_x[v13];
-            v15 = _50B9D8_screen_space_y[v13];
+              v11 = stru_50B700._screen_space_x[v13];
+            v15 = stru_50B700._screen_space_y[v13];
             if ( v15 < v22 )
-              v22 = _50B9D8_screen_space_y[v13];
+              v22 = stru_50B700._screen_space_y[v13];
             if ( v15 > v12 )
-              v12 = _50B9D8_screen_space_y[v13];
+              v12 = stru_50B700._screen_space_y[v13];
             v10 = v19;
             ++v13;
           }
@@ -3264,7 +3260,7 @@
         return pSectorID;
     }
   }
-  //return pSectorID;
+  return pSectorID;
 }
 // 49AC17: using guessed type int var_108[50];
 
@@ -4320,7 +4316,7 @@
     bUnderwater = 1;
     pGame->uFlags2 |= 8u;
   }
-  if ( !_strcmpi(pCurrentMapName, "out15.odm") || !_strcmpi(pCurrentMapName, "d23.blv") )
+  if ( !_stricmp(pCurrentMapName, "out15.odm") || !_stricmp(pCurrentMapName, "d23.blv") )
     bNoNPCHiring = 1;
   pPaletteManager->pPalette_tintColor[0] = 0;
   pPaletteManager->pPalette_tintColor[1] = 0;
--- a/Indoor.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/Indoor.h	Sat Jun 01 10:32:31 2013 +0600
@@ -23,7 +23,7 @@
 {
   LevelDecoration();
   int GetGlobalEvent();
-  int IsInteractive();
+  bool IsInteractive();
   bool _47A825();
 
 
@@ -286,11 +286,11 @@
   struct Texture *GetTexture();
   void FromODM(struct ODMFace *face);
 
-  inline bool Invisible() const {return uAttributes & FACE_INVISIBLE;}
+  inline bool Invisible() const {return (uAttributes & FACE_INVISIBLE) != 0;}
   inline bool Visible() const   {return !Invisible();}
-  inline bool Portal() const    {return uAttributes & FACE_PORTAL;}
-  inline bool Fluid() const     {return uAttributes & FACE_FLUID;}
-  inline bool Clickable() const {return uAttributes & FACE_CLICKABLE;}
+  inline bool Portal() const    {return (uAttributes & FACE_PORTAL) != 0;}
+  inline bool Fluid() const     {return (uAttributes & FACE_FLUID) != 0;}
+  inline bool Clickable() const {return (uAttributes & FACE_CLICKABLE) != 0;}
 
 
   struct Plane_float_ pFacePlane;
--- a/Items.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/Items.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -306,6 +306,7 @@
   pItemsTXT_Raw = NULL;
 }
 
+
 //----- (00456D84) --------------------------------------------------------
 void ItemsTable::Initialize()
 	{
@@ -543,107 +544,107 @@
 					break;
 				case 4: //Equip Stat
 					{
-					if ( !_strcmpi(test_string, "weapon") )
+					if ( !_stricmp(test_string, "weapon") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_OFF_HAND;
 						break;
 						}
-					if ( !_strcmpi(test_string, "weapon2") )
+					if ( !_stricmp(test_string, "weapon2") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_MAIN_HAND;
 						break;
 						}
-					if ( !_strcmpi(test_string, "weapon1or2") )
+					if ( !_stricmp(test_string, "weapon1or2") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_OFF_HAND;
 						break;
 						}
-					if ( !(_strcmpi(test_string, "missile")&&_strcmpi(test_string, "bow")))
+					if ( !(_stricmp(test_string, "missile")&&_stricmp(test_string, "bow")))
 						{
 						pItems[item_counter].uEquipType = EQUIP_BOW;
 						break;
 						}
-					if ( !_strcmpi(test_string, "armor") )
+					if ( !_stricmp(test_string, "armor") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_ARMOUR;
 						break;
 						}
-					if ( !_strcmpi(test_string, "shield") )
+					if ( !_stricmp(test_string, "shield") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_SHIELD;
 						break;
 						}
-					if ( !_strcmpi(test_string, "helm") )
+					if ( !_stricmp(test_string, "helm") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_HELMET;
 						break;
 						}
-					if ( !_strcmpi(test_string, "belt") )
+					if ( !_stricmp(test_string, "belt") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_BELT;
 						break;
 						}
-					if ( !_strcmpi(test_string, "cloak") )
+					if ( !_stricmp(test_string, "cloak") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_CLOAK;
 						break;
 						}
-					if ( !_strcmpi(test_string, "gauntlets") )
+					if ( !_stricmp(test_string, "gauntlets") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_GAUNTLETS;
 						break;
 						}
-					if ( !_strcmpi(test_string, "boots") )
+					if ( !_stricmp(test_string, "boots") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_BOOTS;
 						break;
 						}
-					if ( !_strcmpi(test_string, "ring") )
+					if ( !_stricmp(test_string, "ring") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_RING;
 						break;
 						}
-					if ( !_strcmpi(test_string, "amulet") )
+					if ( !_stricmp(test_string, "amulet") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_AMULET;
 						break;
 						}
-					if ( !_strcmpi(test_string, "weaponw") )
+					if ( !_stricmp(test_string, "weaponw") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_WAND;
 						break;
 						}
-					if ( !(_strcmpi(test_string, "herb")&&_strcmpi(test_string, "reagent")))
+					if ( !(_stricmp(test_string, "herb")&&_stricmp(test_string, "reagent")))
 						{
 						pItems[item_counter].uEquipType = EQUIP_REAGENT;
 						break;
 						}
-					if ( !_strcmpi(test_string, "bottle") )
+					if ( !_stricmp(test_string, "bottle") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_POTION;
 						break;
 						}
-					if ( !_strcmpi(test_string, "sscroll") )
+					if ( !_stricmp(test_string, "sscroll") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_SPELL_SCROLL;
 						break;
 						}
-					if ( !_strcmpi(test_string, "book") )
+					if ( !_stricmp(test_string, "book") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_BOOK;
 						break;
 						}
-					if ( !_strcmpi(test_string, "mscroll") )
+					if ( !_stricmp(test_string, "mscroll") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_MESSAGE_SCROLL;
 						break;
 						}
-					if ( !_strcmpi(test_string, "gold") )
+					if ( !_stricmp(test_string, "gold") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_GOLD;
 						break;
 						}
-					if ( !_strcmpi(test_string, "gem") )
+					if ( !_stricmp(test_string, "gem") )
 						{
 						pItems[item_counter].uEquipType = EQUIP_GEM;
 						break;
@@ -653,67 +654,67 @@
 					}
 				case 5: //Skill Group
 					{
-					if ( !_strcmpi(test_string, "staff") )
+					if ( !_stricmp(test_string, "staff") )
 						{
 						pItems[item_counter].uSkillType = PLAYER_SKILL_STAFF;
 						break;
 						}
-					if ( !_strcmpi(test_string, "sword") )
+					if ( !_stricmp(test_string, "sword") )
 						{
 						pItems[item_counter].uSkillType = PLAYER_SKILL_SWORD;
 						break;
 						}
-					if ( !_strcmpi(test_string, "dagger") )
+					if ( !_stricmp(test_string, "dagger") )
 						{
 						pItems[item_counter].uSkillType = PLAYER_SKILL_DAGGER;
 						break;
 						}
-					if ( !_strcmpi(test_string, "axe") )
+					if ( !_stricmp(test_string, "axe") )
 						{
 						pItems[item_counter].uSkillType = PLAYER_SKILL_AXE;
 						break;
 						}
-					if ( !_strcmpi(test_string, "spear") )
+					if ( !_stricmp(test_string, "spear") )
 						{
 						pItems[item_counter].uSkillType = PLAYER_SKILL_SPEAR;
 						break;
 						}
-					if ( !_strcmpi(test_string, "bow") )
+					if ( !_stricmp(test_string, "bow") )
 						{
 						pItems[item_counter].uSkillType = PLAYER_SKILL_BOW;
 						break;
 						}
-					if ( !_strcmpi(test_string, "mace") )
+					if ( !_stricmp(test_string, "mace") )
 						{
 						pItems[item_counter].uSkillType = PLAYER_SKILL_MACE;
 						break;
 						}
-					if ( !_strcmpi(test_string, "blaster") )
+					if ( !_stricmp(test_string, "blaster") )
 						{
 						pItems[item_counter].uSkillType = PLAYER_SKILL_BLASTER;
 						break;
 						}
-					if ( !_strcmpi(test_string, "shield") )
+					if ( !_stricmp(test_string, "shield") )
 						{
 						pItems[item_counter].uSkillType = PLAYER_SKILL_SHIELD;
 						break;
 						}
-					if ( !_strcmpi(test_string, "leather") )
+					if ( !_stricmp(test_string, "leather") )
 						{
 						pItems[item_counter].uSkillType = PLAYER_SKILL_LEATHER;
 						break;
 						}
-					if ( !_strcmpi(test_string, "chain") )
+					if ( !_stricmp(test_string, "chain") )
 						{
 						pItems[item_counter].uSkillType = PLAYER_SKILL_CHAIN;
 						break;
 						}
-					if ( !_strcmpi(test_string, "plate") )
+					if ( !_stricmp(test_string, "plate") )
 						{
 						pItems[item_counter].uSkillType = PLAYER_SKILL_PLATE;
 						break;
 						}
-					if ( !_strcmpi(test_string, "club") )
+					if ( !_stricmp(test_string, "club") )
 						{
 						pItems[item_counter].uSkillType = PLAYER_SKILL_CLUB;
 						break;
@@ -755,17 +756,17 @@
 					break;
 				case 8: //material
 					{
-					if ( !_strcmpi(test_string, "artifact") )
+					if ( !_stricmp(test_string, "artifact") )
 						{
 						pItems[item_counter].uMaterial = MATERIAL_ARTEFACT;
 						break;
 						}
-					if ( !_strcmpi(test_string, "relic") )
+					if ( !_stricmp(test_string, "relic") )
 						{
 						pItems[item_counter].uMaterial = MATERIAL_RELIC;
 						break;
 						}
-					if ( !_strcmpi(test_string, "special") )
+					if ( !_stricmp(test_string, "special") )
 						{
 						pItems[item_counter].uMaterial = MATERIAL_SPECIAL;
 						break;
--- a/Items.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/Items.h	Sat Jun 01 10:32:31 2013 +0600
@@ -82,8 +82,11 @@
   ITEM_ARTICACT_GOVERNONS_ARMOR = 504,//1F8
   ITEM_ARTIFACT_YORUBA = 505,//1F9
   ITEM_ARTIFACT_SPLITTER = 506,//1FA
+  ITEM_ARTIFACT_GHOULSBANE = 507,//1FA
+  ITEM_ARTEFACT_ULLYSES =510, 
   ITEM_ARTIFACT_LEAGUE_BOOTS = 512,//200
   ITEM_RELIC_HARECS_LEATHER = 516,//204
+  ITEM_RELIC_KELEBRIM = 520,//208
   ITEM_RELIC_TALEDONS_HELM = 521,//209
   ITEM_RELIC_SCHOLARS_CAP = 522,//20A
   ITEM_RELIC_PHYNAXIAN_CROWN = 523,//20B
@@ -115,7 +118,7 @@
   EQUIP_BELT           = 6,
   EQUIP_CLOAK          = 7,
   EQUIP_GAUNTLETS      = 8,
-  EQUIP_BOOTS          = 9,
+  EQUIP_BOOTS          = 9, 
   EQUIP_RING           = 10,
   EQUIP_AMULET         = 11,
   EQUIP_WAND           = 12,
@@ -123,6 +126,7 @@
   EQUIP_POTION         = 14,
   EQUIP_SPELL_SCROLL   = 15,
   EQUIP_BOOK           = 16,
+  EQIUP_ANY            = 16,
   EQUIP_MESSAGE_SCROLL = 17,
   EQUIP_GOLD           = 18,
   EQUIP_GEM            = 19,
@@ -141,10 +145,10 @@
  //   Reset();
  // }
 
-  inline bool Broken()        {return uAttributes & ITEM_BROKEN;}
-  inline bool Identified()    {return uAttributes & ITEM_IDENTIFIED;}
+  inline bool Broken()        {return (uAttributes & ITEM_BROKEN) != 0;}
+  inline bool Identified()    {return (uAttributes & ITEM_IDENTIFIED) != 0;}
   inline void SetIdentified() {uAttributes |= ITEM_IDENTIFIED;}
-  inline bool Stolen()        {return uAttributes & ITEM_STOLEN;}
+  inline bool Stolen()        {return (uAttributes & ITEM_STOLEN) != 0;}
   inline void SetStolen()     {uAttributes |= ITEM_STOLEN;}
 
   bool GenerateArtifact();
--- a/Keyboard.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/Keyboard.h	Sat Jun 01 10:32:31 2013 +0600
@@ -77,8 +77,9 @@
 #pragma pack(pop)
 
 #pragma pack(push, 1)
-struct Keyboard
+class Keyboard
 {
+public:
   Keyboard();
   bool WasKeyPressed(int vKey);
   bool IsKeyBeingHeld(int vKey);
--- a/LOD.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/LOD.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -279,7 +279,7 @@
         {
         for (i=0; i<uNumLoadedSprites;++i)
             {
-            if (!(_strcmpi(pHardwareSprites[i].pName, pContainerName)))
+            if (!(_stricmp(pHardwareSprites[i].pName, pContainerName)))
                 return i;
             } 
         }
@@ -287,7 +287,7 @@
         {
         for (i=0; i<uNumLoadedSprites;++i)
             {
-            if (!(_strcmpi(pSpriteHeaders[i].pName, pContainerName)))
+            if (!(_stricmp(pSpriteHeaders[i].pName, pContainerName)))
                 return i;
             } 
         }
@@ -340,7 +340,7 @@
                 {
                 for (i=0; i<uNumLoadedSprites;++i)
                     {
-                    if (!(_strcmpi(pSpriteHeaders[i].pName, "pending")))
+                    if (!(_stricmp(pSpriteHeaders[i].pName, "pending")))
                         return i;
                     } 
                 }
@@ -1223,7 +1223,7 @@
   else
   {
     v4 = this->pTextures;
-    while ( _strcmpi(v4->pName, pName) )
+    while ( _stricmp(v4->pName, pName) )
     {
       ++v3;
       ++v4;
@@ -1899,7 +1899,7 @@
     while ( 1 )
     {
       v5 = maxIndex - v4;
-      result = _strcmpi((const char *)pContainerName, (const char *)(&v10->pSubIndices[(maxIndex - v4) / 2] + v4));
+      result = _stricmp((const char *)pContainerName, (const char *)(&v10->pSubIndices[(maxIndex - v4) / 2] + v4));
       if ( !result )
         _6A0CA4_lod_binary_search = (maxIndex - v4) / 2 + v4;
       if ( v4 == maxIndex )
@@ -1914,7 +1914,7 @@
           v9 = v4;
           do
           {
-            result = _strcmpi((const char *)pContainerName, (const char *)&v10->pSubIndices[v9]);
+            result = _stricmp((const char *)pContainerName, (const char *)&v10->pSubIndices[v9]);
             if ( !result )
               goto LABEL_21;
             ++v7;
@@ -1938,7 +1938,7 @@
   v8 = v4;
   while ( 1 )
   {
-    result = _strcmpi((const char *)pContainerName, (const char *)&v10->pSubIndices[v8]);
+    result = _stricmp((const char *)pContainerName, (const char *)&v10->pSubIndices[v8]);
     if ( !result )
       break;
     ++v7;
@@ -1971,7 +1971,7 @@
   }
   else
   {
-    while ( _strcmpi((const char *)pContainer, (const char *)&this_dup->pSubIndices[i]) )
+    while ( _stricmp((const char *)pContainer, (const char *)&this_dup->pSubIndices[i]) )
     {
       ++i_dup;
       ++i;
@@ -2917,7 +2917,7 @@
       if (uNumLoadedFiles > 0)
       {
         Sourcea = (const char *)pTextures;
-        while ( _strcmpi(Sourcea, "pending") )
+        while ( _stricmp(Sourcea, "pending") )
         {
           Sourcea += 72;
           ++v6;
@@ -2934,7 +2934,7 @@
     return uNumLoadedFiles - 1;
 //  }
 //  v5 = pTextures;
-//  while ( _strcmpi(v5->pName, pContainer) )
+//  while ( _stricmp(v5->pName, pContainer) )
 //  {
 //    ++v4;
 //    ++v5;
--- a/LOD.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/LOD.h	Sat Jun 01 10:32:31 2013 +0600
@@ -5,6 +5,7 @@
 
 #include "Texture.h"
 
+class Sprite;
 
 /*  354 */
 enum TEXTURE_TYPE
@@ -283,7 +284,7 @@
   int field_ECA4;
   int field_ECA8;
   int field_ECAC;
-  struct Sprite *pHardwareSprites;
+  Sprite *pHardwareSprites;
   int field_ECB4;
 };
 #pragma pack(pop)
--- a/LightmapBuilder.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/LightmapBuilder.h	Sat Jun 01 10:32:31 2013 +0600
@@ -27,8 +27,9 @@
 
 /*  114 */
 #pragma pack(push, 1)
-struct LightmapBuilder
+class LightmapBuilder
 {
+public:
   LightmapBuilder();
   virtual ~LightmapBuilder() //----- (0045BBAA)
   {}
--- a/Math.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/Math.h	Sat Jun 01 10:32:31 2013 +0600
@@ -29,5 +29,84 @@
 int fixpoint_mul(int, int);
 int fixpoint_from_float(float value);
 
+#ifndef ROUNDING_EPSILON
+#define ROUNDING_EPSILON 0.0000001
+#endif
 
+#include <cmath>
+#include <cstdlib>
+#include <ciso646>
+
+namespace rounding
+{
+
+  //--------------------------------------------------------------------------
+  // round down
+  // Bias: -Infinity
+  using std::floor;
+
+  //--------------------------------------------------------------------------
+  // round up
+  // Bias: +Infinity
+  using std::ceil;
+
+  //--------------------------------------------------------------------------
+  // symmetric round up
+  // Bias: away from zero
+  template <typename FloatType>
+  FloatType ceil0( const FloatType& value )
+  {
+    FloatType result = std::ceil( std::fabs( value ) );
+    return (value < 0.0) ? -result : result;
+  }
+
+  //--------------------------------------------------------------------------
+  // Common rounding: round half up
+  // Bias: +Infinity
+  template <typename FloatType>
+  FloatType roundhalfup( const FloatType& value )
+  {
+    return std::floor( value +0.5 );
+  }
+
+  //--------------------------------------------------------------------------
+  // symmetric round half up
+  // Bias: away from zero
+  template <typename FloatType>
+  FloatType roundhalfup0( const FloatType& value )
+  {
+    FloatType result = roundhalfup( std::fabs( value ) );
+    return (value < 0.0) ? -result : result;
+  }
+
+  //--------------------------------------------------------------------------
+  // round half even (banker's rounding)
+  // Bias: none
+  template <typename FloatType>
+  FloatType bankersRounding(
+    const FloatType& value,
+    const FloatType& epsilon = ROUNDING_EPSILON
+    ) {
+      if (value < 0.0) return -bankersRounding <FloatType> ( -value, epsilon );
+
+      FloatType ipart;
+      std::modf( value, &ipart );
+
+      // If 'value' is exctly halfway between two integers
+      if (abs((value -(ipart +0.5))) < epsilon)
+      {
+        // If 'ipart' is even then return 'ipart'
+        if (std::fmod( ipart, 2.0 ) < epsilon)
+          return ipart;
+
+        // Else return the nearest even integer
+        return ceil0( ipart +0.5 );
+      }
+
+      // Otherwise use the usual round to closest
+      // (Either symmetric half-up or half-down will do0
+      return roundhalfup0( value );
+  }
+
+}
 extern struct stru193_math *stru_5C6E00;
\ No newline at end of file
--- a/Monsters.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/Monsters.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -32,135 +32,135 @@
         ++*next_token;
         return 0;
         }
-    if ( !_strcmpi(tbl->pProperties[0], "Dispel") )  //dispel magic
+    if ( !_stricmp(tbl->pProperties[0], "Dispel") )  //dispel magic
         {
         ++*next_token;
         return 80;
         }
-    else  if ( !_strcmpi(tbl->pProperties[0], "Day") )  //day of protection
+    else  if ( !_stricmp(tbl->pProperties[0], "Day") )  //day of protection
         {
         *next_token+=2;;
         return 85;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "Hour") )  //hour  of power
+    else if ( !_stricmp(tbl->pProperties[0], "Hour") )  //hour  of power
         {
         *next_token+=2;;
         return 86;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "Shield") )
+    else if ( !_stricmp(tbl->pProperties[0], "Shield") )
         return  17;
-    else if ( !_strcmpi(tbl->pProperties[0], "Spirit") )
+    else if ( !_stricmp(tbl->pProperties[0], "Spirit") )
         {
         ++*next_token;
         return 52;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "Power") )  //power cure
+    else if ( !_stricmp(tbl->pProperties[0], "Power") )  //power cure
         {
         ++*next_token;
         return 77;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "Meteor") )  //meteot shower
+    else if ( !_stricmp(tbl->pProperties[0], "Meteor") )  //meteot shower
         {
         ++*next_token;
         return 9;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "Lightning") ) //Lightning bolt
+    else if ( !_stricmp(tbl->pProperties[0], "Lightning") ) //Lightning bolt
         {
         ++*next_token;
         return 18;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "Implosion") )
+    else if ( !_stricmp(tbl->pProperties[0], "Implosion") )
         return  20;
-    else if ( !_strcmpi(tbl->pProperties[0], "Stone") )
+    else if ( !_stricmp(tbl->pProperties[0], "Stone") )
         {
         ++*next_token;
         return 38;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "Haste") )
+    else if ( !_stricmp(tbl->pProperties[0], "Haste") )
         return   5;
-    else if ( !_strcmpi(tbl->pProperties[0], "Heroism") )
+    else if ( !_stricmp(tbl->pProperties[0], "Heroism") )
         return   51;
-    else if ( !_strcmpi(tbl->pProperties[0], "Pain") ) //pain reflection
+    else if ( !_stricmp(tbl->pProperties[0], "Pain") ) //pain reflection
         {
         ++*next_token;
         return 95;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "Sparks") )
+    else if ( !_stricmp(tbl->pProperties[0], "Sparks") )
         return 15;
-    else if ( !_strcmpi(tbl->pProperties[0], "Light") )
+    else if ( !_stricmp(tbl->pProperties[0], "Light") )
         {
         ++*next_token;
         return 78;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "Toxic") ) //toxic cloud
+    else if ( !_stricmp(tbl->pProperties[0], "Toxic") ) //toxic cloud
         {
         ++*next_token;
         return 90;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "ShrapMetal") )
+    else if ( !_stricmp(tbl->pProperties[0], "ShrapMetal") )
         return 93;
-    else if ( !_strcmpi(tbl->pProperties[0], "Paralyze") )
+    else if ( !_stricmp(tbl->pProperties[0], "Paralyze") )
         return 81;
-    else if ( !_strcmpi(tbl->pProperties[0], "Fireball") )
+    else if ( !_stricmp(tbl->pProperties[0], "Fireball") )
         return 6;
-    else if ( !_strcmpi(tbl->pProperties[0], "Incinerate") )
+    else if ( !_stricmp(tbl->pProperties[0], "Incinerate") )
         return 11;
-    else if ( !_strcmpi(tbl->pProperties[0], "Fire") )
+    else if ( !_stricmp(tbl->pProperties[0], "Fire") )
         {
         ++*next_token;
         return 2;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "Rock") )
+    else if ( !_stricmp(tbl->pProperties[0], "Rock") )
         {
         ++*next_token;
         return 41;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "Mass") )
+    else if ( !_stricmp(tbl->pProperties[0], "Mass") )
         {
         ++*next_token;
         return 44;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "Ice") )
+    else if ( !_stricmp(tbl->pProperties[0], "Ice") )
         {
         ++*next_token;
         return 26;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "Acid") )
+    else if ( !_stricmp(tbl->pProperties[0], "Acid") )
         {
         ++*next_token;
         return 29;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "Bless") )
+    else if ( !_stricmp(tbl->pProperties[0], "Bless") )
         return 46;
-    else if ( !_strcmpi(tbl->pProperties[0], "Dragon") )
+    else if ( !_stricmp(tbl->pProperties[0], "Dragon") )
         {
         ++*next_token;
         return 97;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "Reanimate") )
+    else if ( !_stricmp(tbl->pProperties[0], "Reanimate") )
         return 89;
-    else if ( !_strcmpi(tbl->pProperties[0], "Summon") )
+    else if ( !_stricmp(tbl->pProperties[0], "Summon") )
         {
         ++*next_token;
         return 82;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "Fate") )
+    else if ( !_stricmp(tbl->pProperties[0], "Fate") )
         return 47;
-    else if ( !_strcmpi(tbl->pProperties[0], "Harm") )
+    else if ( !_stricmp(tbl->pProperties[0], "Harm") )
         return 70;
-    else if ( !_strcmpi(tbl->pProperties[0], "Mind") )
+    else if ( !_stricmp(tbl->pProperties[0], "Mind") )
         {
         ++*next_token;
         return 57;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "Blades") )
+    else if ( !_stricmp(tbl->pProperties[0], "Blades") )
         return 39;
-    else if ( !_strcmpi(tbl->pProperties[0], "Psychic") )
+    else if ( !_stricmp(tbl->pProperties[0], "Psychic") )
         {
         ++*next_token;
         return 65;
         }
-    else if ( !_strcmpi(tbl->pProperties[0], "Hammerhands") )
+    else if ( !_stricmp(tbl->pProperties[0], "Hammerhands") )
         return 73;
     else
         {
@@ -233,29 +233,29 @@
 //----- (00454E3A) --------------------------------------------------------
 int  ParseMissleAttackType(const char *missle_attack_str)
     {
-    if ( !_strcmpi(missle_attack_str, "ARROW") )
+    if ( !_stricmp(missle_attack_str, "ARROW") )
         return 1;
-    else if ( !_strcmpi(missle_attack_str, "ARROWF") )
+    else if ( !_stricmp(missle_attack_str, "ARROWF") )
         return 2;
-    else if ( !_strcmpi(missle_attack_str, "FIRE") )
+    else if ( !_stricmp(missle_attack_str, "FIRE") )
         return 3;
-    else if ( !_strcmpi(missle_attack_str, "AIR") )       
+    else if ( !_stricmp(missle_attack_str, "AIR") )       
         return 4;
-    else if ( !_strcmpi(missle_attack_str, "WATER") )
+    else if ( !_stricmp(missle_attack_str, "WATER") )
         return 5;
-    else if ( !_strcmpi(missle_attack_str, "EARTH") )
+    else if ( !_stricmp(missle_attack_str, "EARTH") )
         return 6;
-    else if ( !_strcmpi(missle_attack_str, "SPIRIT") )       
+    else if ( !_stricmp(missle_attack_str, "SPIRIT") )       
         return 7;
-    else if ( !_strcmpi(missle_attack_str, "MIND") )
+    else if ( !_stricmp(missle_attack_str, "MIND") )
         return 8;
-    else if ( !_strcmpi(missle_attack_str, "BODY") )
+    else if ( !_stricmp(missle_attack_str, "BODY") )
         return 9;
-    else if ( !_strcmpi(missle_attack_str, "LIGHT") )       
+    else if ( !_stricmp(missle_attack_str, "LIGHT") )       
         return 10;
-    else if ( !_strcmpi(missle_attack_str, "DARK") )
+    else if ( !_stricmp(missle_attack_str, "DARK") )
         return 11;
-    else if ( !_strcmpi(missle_attack_str, "ENER") )       
+    else if ( !_stricmp(missle_attack_str, "ENER") )       
         return 13;
     else return 0;
     }
@@ -482,7 +482,7 @@
 {
   for (int i=1; i<uNumMonsters; ++i)
       {
-        if((pInfos[i].pName )&& (!_strcmpi(pInfos[i].pPictureName, monster_textr_name)))
+        if((pInfos[i].pName )&& (!_stricmp(pInfos[i].pPictureName, monster_textr_name)))
             return i;
       }
   return -1;
@@ -723,55 +723,55 @@
                                 item_name=&test_string[str_pos+2];
                                 if (*item_name)
                                     {
-                                    if ( !_strcmpi(item_name, "WEAPON"))
+                                    if ( !_stricmp(item_name, "WEAPON"))
                                         pInfos[curr_rec_num].uTreasureType= 20;
-                                    else if ( !_strcmpi(item_name, "ARMOR"))
+                                    else if ( !_stricmp(item_name, "ARMOR"))
                                         pInfos[curr_rec_num].uTreasureType= 21;
-                                    else if ( !_strcmpi(item_name, "MISC"))
+                                    else if ( !_stricmp(item_name, "MISC"))
                                         pInfos[curr_rec_num].uTreasureType= 22;
-                                    else if ( !_strcmpi(item_name, "SWORD"))
+                                    else if ( !_stricmp(item_name, "SWORD"))
                                         pInfos[curr_rec_num].uTreasureType= 23;
-                                    else if ( !_strcmpi(item_name, "DAGGER"))
+                                    else if ( !_stricmp(item_name, "DAGGER"))
                                         pInfos[curr_rec_num].uTreasureType= 24;
-                                    else if ( !_strcmpi(item_name, "AXE"))
+                                    else if ( !_stricmp(item_name, "AXE"))
                                         pInfos[curr_rec_num].uTreasureType= 25;
-                                    else if ( !_strcmpi(item_name, "SPEAR"))
+                                    else if ( !_stricmp(item_name, "SPEAR"))
                                         pInfos[curr_rec_num].uTreasureType= 26;
-                                    else if ( !_strcmpi(item_name, "BOW"))
+                                    else if ( !_stricmp(item_name, "BOW"))
                                         pInfos[curr_rec_num].uTreasureType= 27;
-                                    else if ( !_strcmpi(item_name, "MACE"))
+                                    else if ( !_stricmp(item_name, "MACE"))
                                         pInfos[curr_rec_num].uTreasureType= 28;
-                                    else if ( !_strcmpi(item_name, "CLUB"))
+                                    else if ( !_stricmp(item_name, "CLUB"))
                                         pInfos[curr_rec_num].uTreasureType= 29;
-                                    else if ( !_strcmpi(item_name, "STAFF"))
+                                    else if ( !_stricmp(item_name, "STAFF"))
                                         pInfos[curr_rec_num].uTreasureType= 30;
-                                    else if ( !_strcmpi(item_name, "LEATHER"))
+                                    else if ( !_stricmp(item_name, "LEATHER"))
                                         pInfos[curr_rec_num].uTreasureType= 31;
-                                    else if ( !_strcmpi(item_name, "CHAIN"))
+                                    else if ( !_stricmp(item_name, "CHAIN"))
                                         pInfos[curr_rec_num].uTreasureType= 32;
-                                    else if ( !_strcmpi(item_name, "PLATE"))
+                                    else if ( !_stricmp(item_name, "PLATE"))
                                         pInfos[curr_rec_num].uTreasureType= 33;
-                                    else if ( !_strcmpi(item_name, "SHIELD"))
+                                    else if ( !_stricmp(item_name, "SHIELD"))
                                         pInfos[curr_rec_num].uTreasureType= 34;
-                                    else if ( !_strcmpi(item_name, "HELM"))
+                                    else if ( !_stricmp(item_name, "HELM"))
                                         pInfos[curr_rec_num].uTreasureType= 35;
-                                    else if ( !_strcmpi(item_name, "BELT"))
+                                    else if ( !_stricmp(item_name, "BELT"))
                                         pInfos[curr_rec_num].uTreasureType= 36;
-                                    else if ( !_strcmpi(item_name, "CAPE"))
+                                    else if ( !_stricmp(item_name, "CAPE"))
                                         pInfos[curr_rec_num].uTreasureType= 37;
-                                    else if ( !_strcmpi(item_name, "GAUNTLETS"))
+                                    else if ( !_stricmp(item_name, "GAUNTLETS"))
                                         pInfos[curr_rec_num].uTreasureType= 38;
-                                    else if ( !_strcmpi(item_name, "BOOTS"))
+                                    else if ( !_stricmp(item_name, "BOOTS"))
                                         pInfos[curr_rec_num].uTreasureType= 39;
-                                    else if ( !_strcmpi(item_name, "RING"))
+                                    else if ( !_stricmp(item_name, "RING"))
                                         pInfos[curr_rec_num].uTreasureType= 40;
-                                    else if ( !_strcmpi(item_name, "AMULET"))
+                                    else if ( !_stricmp(item_name, "AMULET"))
                                         pInfos[curr_rec_num].uTreasureType= 41;
-                                    else if ( !_strcmpi(item_name, "WAND"))
+                                    else if ( !_stricmp(item_name, "WAND"))
                                         pInfos[curr_rec_num].uTreasureType= 42;
-                                    else if ( !_strcmpi(item_name, "SCROLL"))
+                                    else if ( !_stricmp(item_name, "SCROLL"))
                                         pInfos[curr_rec_num].uTreasureType= 43;
-                                    else if ( !_strcmpi(item_name, "GEM"))
+                                    else if ( !_stricmp(item_name, "GEM"))
                                         pInfos[curr_rec_num].uTreasureType= 46;
                                     }
                             }
@@ -1072,12 +1072,12 @@
                   //      v74 = v94.field_0;
                         if ( parsed_field.uPropCount < 10 )
                             {
-                            if (! _strcmpi(parsed_field.pProperties[0], "shot") )
+                            if (! _stricmp(parsed_field.pProperties[0], "shot") )
                                 {
                                 pInfos[curr_rec_num].uSpecialAbilityType=1;
                                 pInfos[curr_rec_num].uSpecialAbilityDamageDiceBonus=atoi((char *)(parsed_field.pProperties[1] + 1));
                                 }
-                            else  if (!_strcmpi(parsed_field.pProperties[0], "summon") )
+                            else  if (!_stricmp(parsed_field.pProperties[0], "summon") )
                             {
                             pInfos[curr_rec_num].uSpecialAbilityType=2;
                             if ( parsed_field.uPropCount  > 1 )
@@ -1125,13 +1125,13 @@
                                         }
                                     }
                                 pInfos[curr_rec_num].uSpecialAbilityDamageDiceSides = 0;
-                                if ( !_strcmpi(parsed_field.pProperties[1], "ground") )
+                                if ( !_stricmp(parsed_field.pProperties[1], "ground") )
                                     pInfos[curr_rec_num].uSpecialAbilityDamageDiceSides = 1;
                                 if ( pInfos[curr_rec_num].field_3C_some_special_attack == -1 )
                                     pInfos[curr_rec_num].uSpecialAbilityType = 0;
                                 }
                             }
-                            else  if (!_strcmpi(parsed_field.pProperties[0], "explode") )
+                            else  if (!_stricmp(parsed_field.pProperties[0], "explode") )
                                 {
                                 pInfos[curr_rec_num].uSpecialAbilityType = 3;
                                 ParseDamage((char*)parsed_field.pProperties[1], &pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls,
@@ -1164,7 +1164,8 @@
         return -1;
     for (signed __int16 i=1; i<=uNumMonsters; ++i)
         {
-        if( (!_strcmpi(pMonsters[i].pMonsterName, pMonsterName)))
+        if( (!_stricmp(pMonsters[i].pMonsterName, pMonsterName)))
             return i;
-        }
     }
+    assert(false && "Monster not found!");
+}
--- a/Mouse.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/Mouse.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -64,11 +64,11 @@
   v2 = this;
   if ( !this->bInitialized || !pName )
     return;
-  if ( _strcmpi("MICON2", pName) )
+  if ( _stricmp("MICON2", pName) )
     pGame->uFlags2 &= 0xFFFFFFEFu;
   else
     pGame->uFlags2 |= 0x10u;
-  if ( _strcmpi(v2->pCurrentCursorName, pName) )
+  if ( _stricmp(v2->pCurrentCursorName, pName) )
     strcpy(v2->pCurrentCursorName, pName);
   ClearCursor();
   if ( _strnicmp(pName, "MICON1", 5u) )
--- a/Mouse.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/Mouse.h	Sat Jun 01 10:32:31 2013 +0600
@@ -7,8 +7,9 @@
 
 /*  107 */
 #pragma pack(push, 1)
-struct ThreadWard
+class ThreadWard
 {
+public:
   //----- (00438B0B) --------------------------------------------------------
   inline ThreadWard()
   {
@@ -41,8 +42,9 @@
 
 /*  106 */
 #pragma pack(push, 1)
-struct Mouse
+class Mouse
 {
+public:
   //----- (00467E4E) --------------------------------------------------------
   inline Mouse(ThreadWard *pWard)
   {
--- a/NPC.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/NPC.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -155,98 +155,74 @@
     else
       result = &pParty->pHirelings[v9];
   }
+  return result;
 }
 
 //----- (00445B2C) --------------------------------------------------------
-NPCData *__fastcall GetNewNPCData(signed int npcid, int a2)
-{
-  signed int v2; // esi@1
-  int v3; // edi@1
+struct NPCData * GetNewNPCData( signed int npcid, int* npc_indx )
+    {
+
+  int* v3; // edi@1
   NPCData *result; // eax@5
   int v5; // esi@9
   int v6; // ecx@9
-  int v7; // edx@9
-  NPCData *v8; // eax@9
-  NPCData *v9; // edi@14
-  int v10; // ecx@20
   char v11; // al@23
-  std::string v12; // [sp-18h] [bp-34h]@4
-  const char *v13; // [sp-8h] [bp-24h]@4
-  int v14; // [sp-4h] [bp-20h]@4
-  std::string *v15; // [sp+Ch] [bp-10h]@1
-  char *v16; // [sp+10h] [bp-Ch]@14
-  int v17; // [sp+14h] [bp-8h]@13
-  int a3; // [sp+1Bh] [bp-1h]@4
 
-  v2 = npcid;
-  v3 = a2;
-  v15 = (std::string *)a2;
+  v3 = npc_indx;
   if ( npcid >= 0 )
   {
     if ( npcid < 5000 )
     {
       if ( npcid >= 501 )
       {
-    MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:2040", 0);
+        MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:2040", 0);
       }
-      *(int *)v3 = v2;
-      return &pNPCStats->pNewNPCData[v2];
+      *v3 = npcid;
+      return &pNPCStats->pNewNPCData[npcid];
     }
-LABEL_7:
-    *(int *)a2 = npcid - 5000;
+    *npc_indx = npcid - 5000;
     return &pNPCStats->pAdditionalNPC[npcid - 5000];
   }
   if ( npcid >= 5000 )
-    goto LABEL_7;
+      {
+      *npc_indx = npcid - 5000;
+      return &pNPCStats->pAdditionalNPC[npcid - 5000];
+      }
   if ( sDialogue_SpeakingActorNPC_ID >= 0 )
   {
-    *(int *)a2 = 0;
-    result = 0;
+    *npc_indx = 0;
+    result = NULL;
   }
   else
   {
-    v5 = abs((int)sDialogue_SpeakingActorNPC_ID) - 1;
+    v5 = abs(sDialogue_SpeakingActorNPC_ID) - 1;
     v6 = 0;
-    v7 = 0;
-    v8 = pParty->pHirelings;
-    do
-    {
-      if ( v8->pName )
-        pTmpBuf[v6++] = v7;
-      ++v8;
-      ++v7;
-    }
-    while ( (signed int)v8 < (signed int)&pParty->pPickedItem );
-    v17 = 0;
-    if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
+    for (int i=0; i<2; ++i)
     {
-      v9 = pNPCStats->pNewNPCData;
-      v16 = &pTmpBuf[v6];
-      do
-      {
-        if ( v9->Hired()
-          && (!pParty->pHirelings[0].pName || strcmp(v9->pName, pParty->pHirelings[0].pName))
-          && (!pParty->pHirelings[1].pName || strcmp(v9->pName, pParty->pHirelings[1].pName)) )
+      if ( pParty->pHirelings[i].pName )
+        pTmpBuf[v6++] = i;
+     
+    }     
+    for (int i=0; i< pNPCStats->uNumNewNPCs; ++i)
         {
-          v10 = (int)v16++;
-          *(char *)v10 = v17 + 2;
+        if ( pNPCStats->pNewNPCData[i].Hired()
+            && (!pParty->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[0].pName))
+            && (!pParty->pHirelings[1].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[1].pName)) )
+            {
+                pTmpBuf[v6++]=i+2;
+            }
         }
-        ++v17;
-        ++v9;
-      }
-      while ( v17 < (signed int)pNPCStats->uNumNewNPCs );
-      v3 = (int)v15;
-    }
     v11 = pTmpBuf[v5];
-    if ( (unsigned __int8)v11 >= 2u )
+
+    if ( v11 >= 2u )
     {
-      *(int *)v3 = (unsigned __int8)v11 - 2;
-      result = &pNPCStats->pNPCData[(unsigned __int8)pTmpBuf[v5] + 499];
+      *v3 = v11 - 2;
+      result = &pNPCStats->pNewNPCData[v11 - 2];
     }
     else
     {
-      *(int *)v3 = (unsigned __int8)v11;
-      result = &pParty->pHirelings[(unsigned __int8)pTmpBuf[v5]];
+      *v3 = v11;
+      result = &pParty->pHirelings[v11];
     }
   }
   return result;
@@ -920,39 +896,24 @@
 //----- (00476395) --------------------------------------------------------
 //0x26 Wizard eye at skill level 2
 bool __thiscall CheckHiredNPCSpeciality(unsigned int uProfession)
-{
-	bool result; // eax@2
-	signed int v2; // esi@3
-	char *v3; // eax@4
+    {
+
+    if ( bNoNPCHiring == 1 )
+        return 0;
 
-	if ( bNoNPCHiring == 1 )
-		return 0;
-	v2 = 0;
-	if ( (signed int)pNPCStats->uNumNewNPCs <= 0 )
-		{
-LABEL_8:
-		result = 0;
-		if ( pParty->pHirelings[0].uProfession != uProfession )
-			{
-			LOBYTE(result) = pParty->pHirelings[1].uProfession == uProfession;
-			return result;
-			}
-		}
-	else
-		{
-		v3 = (char *)&pNPCStats->pNewNPCData[0].uFlags;
-		while ( *((int *)v3 + 4) != uProfession || !(*v3 & 0x80) )
-			{
-			++v2;
-			v3 += 76;
-			if ( v2 >= (signed int)pNPCStats->uNumNewNPCs )
-				goto LABEL_8;
-			}
-		result = 0;
-		}
-	++result;
-	return result;
-	}
+    for (int i=0; i<pNPCStats->uNumNewNPCs; ++i )
+        {
+        if ( pNPCStats->pNewNPCData[i].uProfession == uProfession && 
+            (pNPCStats->pNewNPCData[i].uFlags & 0x80) )
+            return true;
+        }
+    if ( pParty->pHirelings[0].uProfession == uProfession ||
+         pParty->pHirelings[1].uProfession == uProfession)
+        return true;
+    else
+        return false;
+
+    }
 // 6BE3C5: using guessed type char bNoNPCHiring;
 
 //----- (004763E0) --------------------------------------------------------
@@ -1216,27 +1177,27 @@
 					break;
 				case  2:
 					{
-					if ( !_strcmpi(test_string, "potion"))
+					if ( !_stricmp(test_string, "potion"))
 						{
 						pAutonoteTxt[i].eType = AUTONOTE_POTION_RECEPIE;
 						break;
 						}
-					if ( !_strcmpi(test_string, "stat") )
+					if ( !_stricmp(test_string, "stat") )
 						{
 						pAutonoteTxt[i].eType = AUTONOTE_STAT_HINT;
 						break;
 						}
-					if ( !_strcmpi(test_string, "seer") )
+					if ( !_stricmp(test_string, "seer") )
 						{
 						pAutonoteTxt[i].eType = AUTONOTE_SEER;
 						break;
 						}
-					if ( !_strcmpi(test_string, "obelisk") )
+					if ( !_stricmp(test_string, "obelisk") )
 						{
 						pAutonoteTxt[i].eType = AUTONOTE_OBELISK;
 						break;
 						}
-					if ( !_strcmpi(test_string, "teacher") )
+					if ( !_stricmp(test_string, "teacher") )
 						{
 						pAutonoteTxt[i].eType = AUTONOTE_TEACHER;
 						break;
--- a/NPC.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/NPC.h	Sat Jun 01 10:32:31 2013 +0600
@@ -77,7 +77,7 @@
 #pragma pack(push, 1)
 struct NPCData  //4Ch
 {
-  inline bool Hired() {return uFlags & 0x80;}
+  inline bool Hired() {return (uFlags & 0x80) != 0;}
 
   char *pName;  //0
   unsigned int uPortraitID;  //4
--- a/Outdoor.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/Outdoor.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -2701,7 +2701,7 @@
 
   v1 = 0;
   v8 = 0;
-  if ( !_strcmpi(pCurrentMapName, "out09.odm") )
+  if ( !_stricmp(pCurrentMapName, "out09.odm") )
     v8 = 1;
 
   for (uint i = 0; i < uNumLevelDecorations; ++i)
--- a/Outdoor.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/Outdoor.h	Sat Jun 01 10:32:31 2013 +0600
@@ -85,11 +85,11 @@
   
   static bool IsBackfaceCulled(struct ODMFace *a1, struct RenderVertexSoft *a2, struct stru148 *a3);
   
-  inline bool Invisible() const {return uAttributes & FACE_INVISIBLE;}
+  inline bool Invisible() const {return (uAttributes & FACE_INVISIBLE) != 0;}
   inline bool Visible() const   {return !Invisible();}
-  inline bool Portal() const    {return uAttributes & FACE_PORTAL;}
-  inline bool Fluid() const     {return uAttributes & FACE_FLUID;}
-  inline bool Clickable() const {return uAttributes & FACE_CLICKABLE;}
+  inline bool Portal() const    {return (uAttributes & FACE_PORTAL) != 0;}
+  inline bool Fluid() const     {return (uAttributes & FACE_FLUID) != 0;}
+  inline bool Clickable() const {return (uAttributes & FACE_CLICKABLE) != 0;}
 
   struct Plane_int_ pFacePlane;
   int zCalc1;
--- a/Overlays.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/Overlays.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -252,9 +252,9 @@
       v10 = atoi(v19.pProperties[0]);
       v11 = v19.pProperties[1];
       v2->pOverlays[v2->uNumOverlays].uOverlayID = v10;
-      if ( _strcmpi(v11, "center") )
+      if ( _stricmp(v11, "center") )
       {
-        v12 = _strcmpi(v19.pProperties[1], "transparent");
+        v12 = _stricmp(v19.pProperties[1], "transparent");
         v13 = v2->pOverlays;
         v14 = v12 == 0;
         v15 = v2->uNumOverlays;
--- a/ParticleEngine.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/ParticleEngine.h	Sat Jun 01 10:32:31 2013 +0600
@@ -105,8 +105,9 @@
 
 /*  110 */
 #pragma pack(push, 1)
-struct ParticleEngine
+class ParticleEngine
 {
+public:
   ParticleEngine();
 
   void ResetParticles();
--- a/Party.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/Party.h	Sat Jun 01 10:32:31 2013 +0600
@@ -186,13 +186,13 @@
   inline bool FlyActive()            {return pPartyBuffs[PARTY_BUFF_FLY].uExpireTime > 0;}
   inline bool WaterWalkActive()      {return pPartyBuffs[PARTY_BUFF_WATER_WALK].uExpireTime > 0;}
   inline bool ImmolationActive()     {return pPartyBuffs[PARTY_BUFF_IMMOLATION].uExpireTime > 0;}
-  inline bool ImmolationSkillLevel() {return pPartyBuffs[PARTY_BUFF_IMMOLATION].uSkill;}
+  inline int ImmolationSkillLevel() {return pPartyBuffs[PARTY_BUFF_IMMOLATION].uSkill;}
   inline bool FeatherFallActive()    {return pPartyBuffs[PARTY_BUFF_FEATHER_FALL].uExpireTime > 0;}
   inline bool Invisible()            {return pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0;}
 
-  inline bool GetRedAlert()    {return uFlags & PARTY_FLAGS_1_ALERT_RED;}
+  inline bool GetRedAlert()    {return (uFlags & PARTY_FLAGS_1_ALERT_RED) != 0;}
   inline void SetRedAlert()    {uFlags |= PARTY_FLAGS_1_ALERT_RED;}
-  inline bool GetYellowAlert() {return uFlags & PARTY_FLAGS_1_ALERT_YELLOW;}
+  inline bool GetYellowAlert() {return (uFlags & PARTY_FLAGS_1_ALERT_YELLOW) != 0;}
   inline void SetYellowAlert() {uFlags |= PARTY_FLAGS_1_ALERT_YELLOW;}
 
 
--- a/Player.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/Player.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -1085,7 +1085,8 @@
         PlaySound((PlayerSpeech)25, 0);
         break;
     case Condition_Sleep:
-        if ( a3 == 1 &&(HasEnchantedItemEquipped(22)||WearsItem(505, 3))) 
+        if ( a3 == 1 &&(HasEnchantedItemEquipped(22)||
+            WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR))) 
             return 0;
         break;
 
@@ -1098,7 +1099,9 @@
 
     case Condition_Insane:
         if ( a3 == 1
-            && (HasEnchantedItemEquipped(19) || WearsItem(505, 3) || WearsItem(530, 6)) )
+            && (HasEnchantedItemEquipped(19) || 
+            WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) || 
+                          WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK)) )
             return 0;
 
         PlaySound((PlayerSpeech)29, 0);
@@ -1115,8 +1118,8 @@
                     pParty->pPartyBuffs[13].Reset();
                 }
             if ( HasEnchantedItemEquipped(21)
-                || WearsItem(505, 3)
-                || WearsItem(530, 6) )
+                || WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR)
+                || WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK) )
                 //goto LABEL_76;
                 return 0;
             }
@@ -1138,7 +1141,9 @@
                 return 0;
                 }
 
-            if ( HasEnchantedItemEquipped(18) ||WearsItem(505, 3) || WearsItem(530, 6) )
+            if ( HasEnchantedItemEquipped(18) ||
+                WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) || 
+                WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK) )
                 return 0;
             }
         PlaySound((PlayerSpeech)28, 0);
@@ -1154,7 +1159,10 @@
                 return 0;
                 }
 
-            if ( HasEnchantedItemEquipped(20)|| WearsItem(505, 3)|| WearsItem(507, 16)||WearsItem(530, 6))
+            if ( HasEnchantedItemEquipped(20)|| 
+                WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR)|| 
+                WearsItem(ITEM_ARTIFACT_GHOULSBANE, EQIUP_ANY)||
+                WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK))
                 return 0;
             }
         break;
@@ -1180,7 +1188,10 @@
     case Condition_Pertified:
         if ( a3 == 1
             &&((pParty->pPartyBuffs[13].uExpireTime > 0i64)
-            || HasEnchantedItemEquipped(23)|| WearsItem(520, 16) || WearsItem(505, 3) || WearsItem(530, 6)) )
+            || HasEnchantedItemEquipped(23)|| 
+            WearsItem(ITEM_RELIC_KELEBRIM, EQIUP_ANY) || 
+            WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) || 
+            WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK)) )
 
             return 0;
         PlaySound((PlayerSpeech)34, 0);
@@ -3240,8 +3251,8 @@
 //----- (0048D676) --------------------------------------------------------
 bool Player::IsUnarmed()
 {
-  return HasItemEquipped(EQUIP_MAIN_HAND) != EQUIP_MAIN_HAND &&
-        !(HasItemEquipped(EQUIP_OFF_HAND) == EQUIP_MAIN_HAND && GetEquippedItemEquipType(EQUIP_OFF_HAND) != EQUIP_SHIELD);
+  return HasItemEquipped(EQUIP_MAIN_HAND) != 0 &&
+        !(HasItemEquipped(EQUIP_OFF_HAND) == 0 && GetEquippedItemEquipType(EQUIP_OFF_HAND) != EQUIP_SHIELD);
 }
 
 //----- (0048D6AA) --------------------------------------------------------
@@ -3249,7 +3260,7 @@
 {
   auto i = pEquipment.pIndices[uEquipIndex];
   if (i)
-    return ~(pInventoryItems[i - 1].uAttributes & ITEM_BROKEN);
+    return ~(pOwnItems[i - 1].uAttributes & ITEM_BROKEN);
   else 
     return false;
 }
@@ -3260,7 +3271,7 @@
   for (uint i = 0; i < 16; ++i)
   {
     if (HasItemEquipped((ITEM_EQUIP_TYPE)i) &&
-      pInventoryItems[i].uSpecEnchantmentType == uEnchantment)
+      pOwnItems[pEquipment.pIndices[i]-1].uSpecEnchantmentType == uEnchantment)
       //  *(int *)&this->field_1F6[36 * pEquipment[i] + 6] != uEnchantment)
       return true;
   }
@@ -3268,16 +3279,16 @@
 }
 
 //----- (0048D709) --------------------------------------------------------
-bool Player::WearsItem(int a1, signed int a2)
-{
+bool Player::WearsItem( int item_id, ITEM_EQUIP_TYPE equip_type )
+    {
 
   int v6; // esi@5
 
-  if ( a2 >= 16 )
+  if ( equip_type >= 16 )
   {
     v6 = 0;
     while ( !HasItemEquipped((ITEM_EQUIP_TYPE)v6)
-         || *(int *)&this->pInventoryItems[pEquipment.pIndices[v6] - 1].uItemID != a1 )
+         || pInventoryItems[pEquipment.pIndices[v6] - 1].uItemID != item_id )
     {
       ++v6;
       if ( (signed int)v6 >= 16 )
@@ -3285,7 +3296,7 @@
     }
     return 1;
   }
-  if ( HasItemEquipped((ITEM_EQUIP_TYPE)a2) && pInventoryItems[pEquipment.pIndices[a2 - 1]].uItemID == a1 )
+  if ( HasItemEquipped(equip_type) && pInventoryItems[pEquipment.pIndices[equip_type - 1]].uItemID == item_id )
     return 1;
   return 0;
 }
@@ -3929,7 +3940,7 @@
 //----- (0048E1A3) --------------------------------------------------------
 unsigned int Player::GetSpellSchool(unsigned int uSpellID)
 {
-  return LOBYTE(pSpellStats->pInfos[uSpellID].uSchool);
+  return pSpellStats->pInfos[uSpellID].uSchool;
 }
 
 //----- (0048E1B5) --------------------------------------------------------
@@ -4120,65 +4131,60 @@
   int v8; // esi@6
   int v9; // esi@6
   int result; // eax@7
-
+  
   switch (classType)
   {
-    case 5u:
-    case 6u:
-    case 7u:
-    case 0x10u:
-    case 0x11u:
-    case 0x12u:
-    case 0x13u:
-    case 0x20u:
-    case 0x21u:
-    case 0x22u:
-    case 0x23u:
+    case PLAYER_CLASS_ROGUE:
+    case PLAYER_CLASS_SPY:
+    case PLAYER_CLASS_ASSASSIN:
+    case PLAYER_CLASS_ARCHER:
+    case PLAYER_CLASS_WARRIOR_MAGE:
+    case PLAYER_CLASS_MASTER_ARCHER:
+    case PLAYER_CLASS_SNIPER:
+    case PLAYER_CLASS_SORCERER:
+    case PLAYER_CLASS_WIZARD:
+    case PLAYER_CLASS_ARCHMAGE:
+    case PLAYER_CLASS_LICH:
       v2 = GetActualIntelligence();
       v3 = GetParameterBonus(v2);
-      goto LABEL_6;
-    case 9u:
-    case 0xAu:
-    case 0xBu:
-    case 0xCu:
-    case 0xDu:
-    case 0xEu:
-    case 0xFu:
-    case 0x18u:
-    case 0x19u:
-    case 0x1Au:
-    case 0x1Bu:
+      break;
+    case PLAYER_CLASS_INITIATE:
+    case PLAYER_CLASS_MASTER:
+    case PLAYER_CLASS_NINJA:
+    case PLAYER_CLASS_PALADIN:
+    case PLAYER_CLASS_CRUSADER:
+    case PLAYER_CLASS_HERO:
+    case PLAYER_CLASS_VILLIAN:
+    case PLAYER_CLASS_CLERIC:
+    case PLAYER_CLASS_PRIEST:
+    case PLAYER_CLASS_PRIEST_OF_SUN:
+    case PLAYER_CLASS_PRIEST_OF_MOON:
       v2 = GetActualWillpower();
       v3 = GetParameterBonus(v2);
-      goto LABEL_6;
-    case 0x15u:
-    case 0x16u:
-    case 0x17u:
-    case 0x1Cu:
-    case 0x1Du:
-    case 0x1Eu:
-    case 0x1Fu:
+      break;
+    case PLAYER_CLASS_HUNTER:
+    case PLAYER_CLASS_RANGER_LORD:
+    case PLAYER_CLASS_BOUNTY_HUNTER:
+    case PLAYER_CLASS_DRUID:
+    case PLAYER_CLASS_GREAT_DRUID:
+    case PLAYER_CLASS_ARCH_DRUID:
+    case PLAYER_CLASS_WARLOCK:
       v4 = GetActualWillpower();
       v5 = GetParameterBonus(v4);
       v6 = GetActualIntelligence();
       v3 = GetParameterBonus(v6) + v5;
-LABEL_6:
-      v7 = pBaseManaPerLevelByClass[classType] * (GetActualLevel() + v3);
-      v8 = GetItemsBonus(CHARACTER_ATTRIBUTE_MANA, 0) + v7;
-      v9 = uFullManaBonus
-         + pBaseManaByClass[classType / 4]
-         + GetSkillBonus(CHARACTER_ATTRIBUTE_MANA)
-         + v8;
-      if ( v9 < 1 )
-        goto LABEL_7;
-      result = v9;
       break;
     default:
-LABEL_7:
-      result = 0;
+      return 0;
       break;
   }
-  return result;
+  v7 = pBaseManaPerLevelByClass[classType] * (GetActualLevel() + v3);
+  v8 = GetItemsBonus(CHARACTER_ATTRIBUTE_MANA, 0) + v7;
+  v9 = uFullManaBonus
+      + pBaseManaByClass[classType / 4]
+  + GetSkillBonus(CHARACTER_ATTRIBUTE_MANA)
+      + v8;
+  return max(0,v9);
 }
 
 //----- (0048E656) --------------------------------------------------------
@@ -4467,7 +4473,7 @@
       inv_indx = pEquipment.pIndices[i]  - 1;
       if (a2==17)
           {
-          if ((pInventoryItems[inv_indx].uSpecEnchantmentType==17)||(pInventoryItems[inv_indx].uItemID=533)) //Elven Chainmail+Increases rate of Recovery
+          if ((pInventoryItems[inv_indx].uSpecEnchantmentType==17)||(pInventoryItems[inv_indx].uItemID==533)) //Elven Chainmail+Increases rate of Recovery
               return 50;
           }
       if (a2==24)
@@ -5690,7 +5696,7 @@
   int v67; // [sp+18h] [bp-14h]@104
   int v68; // [sp+1Ch] [bp-10h]@69
   PlayerEquipment *v69; // [sp+20h] [bp-Ch]@1
-  int v70; // [sp+24h] [bp-8h]@1
+  int skill_bonus; // [sp+24h] [bp-8h]@1
   ITEM_EQUIP_TYPE v71; // [sp+28h] [bp-4h]@1
   int a1; // [sp+34h] [bp+8h]@21
   int a1a; // [sp+34h] [bp+8h]@74
@@ -5700,7 +5706,7 @@
   int lvl_avl[4];
 
   v2 = this;
-  v70 = 0;
+  skill_bonus = 0;
   v69 = 0;
   multiplier =0;
   arm_bonus =0;
@@ -5809,7 +5815,7 @@
                for ( i = 0; i < (signed int)v52; ++i )
                    {
                    if ( lvl_avl[i] )
-                       v70 += v53;
+                       skill_bonus += v53;
                    }
 
                }
@@ -5829,24 +5835,105 @@
           for ( j = 0; j < (signed int)v57; ++j )
               {
               if ( lvl_avl[j] )
-                  v70 += v58;
+                  skill_bonus += v58;
               }
           }
-      return v70;
+      return skill_bonus;
 
     
       }
 
+  if (a2 == CHARACTER_ATTRIBUTE_ATTACK)
+  {
+
+  if ( v2->IsUnarmed() == 1 )
+      {
+      v33 = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
+      v34 = v33;
+      if ( !v33 )
+          return skill_bonus;
+      if ( SkillToMastery(v33) >= 3 )
+          multiplier = 2;
+      else 
+          multiplier=1;
+      v30 = multiplier * (v34 & 0x3F);
+      return arm_bonus + v30;
+      }
+  v35 = (ITEM_EQUIP_TYPE)0;
+  v68 = 0;
+  for (i=0; i<16 ; ++i)
+      {
+      if ( v2->HasItemEquipped((ITEM_EQUIP_TYPE)i) )
+          {
+          v37 = v2->pEquipment.pIndices[i]-1;
+          if ( pItemsTable->pItems[v37].uEquipType <= EQUIP_MAIN_HAND)
+              break;
+          }
+      }
+  if ( i >= 16 )
+      return skill_bonus;
+  
+  v38 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v37].uSkillType;
+  a1a = v2->GetActualSkillLevel(v38);
+  v39=  SkillToMastery(a1a);
+  v71 = (ITEM_EQUIP_TYPE)0;
+  switch (v38)
+      {
+  case PLAYER_SKILL_STAFF:
+      v71 = (ITEM_EQUIP_TYPE)1;
+      if ( v39 == 4 )
+          {
+          v40 = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
+          v41 = v40;
+
+          if ( v40 )
+              {
+              if ( SkillToMastery(v40) >= 3 )
+                  multiplier = 2;
+              else 
+                  multiplier=1;
+              v68 = multiplier * (v41 & 0x3F);
+              }
+          }
+      break;
+  case PLAYER_SKILL_SWORD:
+  case PLAYER_SKILL_DAGGER:
+  case PLAYER_SKILL_AXE:
+  case PLAYER_SKILL_SPEAR:
+  case PLAYER_SKILL_MACE:
+            v71 = (ITEM_EQUIP_TYPE)1;
+        break;
+  case PLAYER_SKILL_BLASTER:
+
+      switch (v39)
+          {
+      case 0: multiplier=1; break;
+      case 1: multiplier=3; break;
+      case 3: multiplier=3; break;
+      case 4: multiplier=5; break;
+          }
+      v5 = multiplier;
+      return v5 * (a1a & 0x3F);
+      break;
+      }
+
+
+  
+  v30 = v68 + v71 * (a1a & 0x3F);
+  return (int)((char *)v69 + v30);
+
+  }
+
+
   if ( a2 != 9 )
   {
-    if ( a2 != CHARACTER_ATTRIBUTE_ATTACK )
-    {
+   
       if ( a2 <= CHARACTER_ATTRIBUTE_ATTACK )
-        return v70;
+        return skill_bonus;
       if ( a2 > CHARACTER_ATTRIBUTE_MELEE_DMG_MAX )
       {
         if ( a2 != CHARACTER_ATTRIBUTE_RANGED_ATTACK )
-          return v70;
+          return skill_bonus;
         v71 = (ITEM_EQUIP_TYPE)0;
         v9 = &v2->pEquipment;
         while ( 1 )
@@ -5866,7 +5953,7 @@
           v71 = (ITEM_EQUIP_TYPE)((int)v71 + 1);
           v9 = (PlayerEquipment *)((char *)v9 + 4);
           if ( (signed int)v71 >= 16 )
-            return v70;
+            return skill_bonus;
         }
         v14 = a1;
         v15 = 1;
@@ -5889,7 +5976,7 @@
         LOBYTE(v18) = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
         v14 = v18;
         if ( !v18 )
-          return v70;
+          return skill_bonus;
         v15 = 0;
         v19 = SkillToMastery(v18);
         if ( (signed int)v19 < 3 )
@@ -5917,7 +6004,7 @@
         }
         v20 = (ITEM_EQUIP_TYPE)((int)v20 + 1);
         if ( (signed int)v20 >= 16 )
-          return v70;
+          return skill_bonus;
       }
       v71 = (ITEM_EQUIP_TYPE)0;
       v23 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v22].uSkillType;
@@ -5979,90 +6066,9 @@
         v71 = (ITEM_EQUIP_TYPE)1;
       goto LABEL_55;
     }
-    if ( v2->IsUnarmed() == 1 )
-    {
-      LOBYTE(v33) = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
-      v34 = v33;
-      if ( !v33 )
-        return v70;
-      if ( (signed int)SkillToMastery(v33) >= 3 )
-        v5 = 2;
-      v30 = v5 * (v34 & 0x3F);
-      return (int)((char *)v69 + v30);
-    }
-    v35 = (ITEM_EQUIP_TYPE)0;
-    v68 = 0;
-    while ( 1 )
-    {
-      if ( v2->HasItemEquipped(v35) )
-      {
-        v37 = v2->pInventoryItems[v35].uItemID;
-        if ( pItemsTable->pItems[v37].uEquipType <= 1u )
-          break;
-      }
-      v35 = (ITEM_EQUIP_TYPE)((int)v35 + 1);
-      if ( (signed int)v35 >= 16 )
-        return v70;
-    }
-    v38 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v37].uSkillType;
-    LOBYTE(v39) = v2->GetActualSkillLevel(v38);
-    a1a = v39;
-    SkillToMastery(v39);
-    v71 = (ITEM_EQUIP_TYPE)0;
-    if ( v38 )
-    {
-      if ( (signed int)v38 > 0 )
-      {
-        if ( (signed int)v38 <= 4 || v38 == 6 )
-        {
-          v71 = (ITEM_EQUIP_TYPE)1;
-        }
-        else
-        {
-          if ( v38 == 7 )
-          {
-            if ( (signed int)SkillToMastery(a1a) < 4 )
-            {
-              if ( (signed int)SkillToMastery(a1a) < 3 )
-              {
-                if ( (signed int)SkillToMastery(a1a) < 2 )
-                  return v5 * (a1a & 0x3F);
-                v63 = 2;
-              }
-              else
-              {
-                v63 = 3;
-              }
-            }
-            else
-            {
-              v63 = 5;
-            }
-            v5 = v63;
-            return v5 * (a1a & 0x3F);
-          }
-        }
-      }
-    }
-    else
-    {
-      v71 = (ITEM_EQUIP_TYPE)1;
-      if ( (signed int)SkillToMastery(a1a) >= 4 )
-      {
-        LOBYTE(v40) = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
-        v41 = v40;
-        if ( v40 )
-        {
-          if ( (signed int)SkillToMastery(v40) >= 3 )
-            v5 = 2;
-          v68 = v5 * (v41 & 0x3F);
-        }
-      }
-    }
-    v30 = v68 + v71 * (a1a & 0x3F);
-    return (int)((char *)v69 + v30);
-  }
+    
   
+    assert(false && "Unknown attribute!");
 }
 
 //----- (00490109) --------------------------------------------------------
@@ -7853,7 +7859,7 @@
     v4 = pValue;
     return v4 >= pValue;
   }
-  return *((int *)this + 2 * VarNum - 210);
+  return &LODWORD(this->pConditions[VarNum]);// *((int *)this + 2 * VarNum - 210);
 }
 
 
@@ -8988,7 +8994,7 @@
           {
             case 232:
               VarNum = (VariableType)0;
-              GetNewNPCData(sDialogue_SpeakingActorNPC_ID, (int)&VarNum);
+              GetNewNPCData(sDialogue_SpeakingActorNPC_ID, (int*)&VarNum);
               result = (bool) pValue;
 			  dword_5B65CC = 0;
               if ( (int)VarNum == pValue )
@@ -9030,11 +9036,11 @@
               break;
             case 243:
               v17 = (char *)&this->uSkillPoints;
-			  result = *v17;
+			  result = *v17 != NULL;
               if ( (unsigned int)pValue <= *(int *)v17 )
               {
 					*(int *)v17 -= (int)pValue;
-					result = v17;
+					result = (v17 != NULL);
 			  }
               else
                 *(int *)v17 = 0;
@@ -9094,6 +9100,7 @@
         pParty->uNumArenaLordWins -= (char)pValue;
         break;
     }
+    assert(false && "Function not returning any value!");
   }
   else
   {
--- a/Player.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/Player.h	Sat Jun 01 10:32:31 2013 +0600
@@ -201,7 +201,7 @@
 };
 
 /*  328 */
-enum PLAYER_SKILL_TYPE: unsigned __int8
+enum PLAYER_SKILL_TYPE: __int8
 {
   PLAYER_SKILL_STAFF = 0,
   PLAYER_SKILL_SWORD = 1,
@@ -511,7 +511,7 @@
   bool IsUnarmed();
   bool HasItemEquipped(ITEM_EQUIP_TYPE uEquipIndex);
   bool HasEnchantedItemEquipped(int uEnchantment);
-  bool WearsItem(int a1, signed int a2);
+  bool WearsItem(int item_id, ITEM_EQUIP_TYPE equip_type);
   bool StealFromShop(struct ItemGen *a2, int a3, int a4, int a5, int *a6);
   int StealFromActor(unsigned int uActorID, int _steal_perm, int reputation);
   void Heal(int amount);
--- a/Render.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/Render.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -1624,14 +1624,14 @@
         {
           //v93 = v116;
           //v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 64) << 9;
-          ptr_801A08[v86].vWorldPosition.x = terrain_76DBC8[v86] - 64 << 9;
+          ptr_801A08[v86].vWorldPosition.x = (terrain_76DBC8[v86] - 64) << 9;
           //*(float *)&pHeight = (double)pHeight;
           ptr_801A08[v86].vWorldPosition.y = v92;
           //v106 = ;
           //v97 = v116;
           ptr_801A08[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86], v116);
           //v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 63) << 9;
-          ptr_801A04[v86].vWorldPosition.x = terrain_76DBC8[v86] - 63 << 9;
+          ptr_801A04[v86].vWorldPosition.x = (terrain_76DBC8[v86] - 63) << 9;
           ptr_801A04[v86].vWorldPosition.y = v92;
           //pHeight = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86) + 1, v97);
           ptr_801A04[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86] + 1, v116);
@@ -1929,13 +1929,13 @@
   int v77; // [sp-Ch] [bp-DCh]@61
   IDirect3DTexture2 *v78; // [sp-8h] [bp-D8h]@61
   //int v79; // [sp-4h] [bp-D4h]@61
-  int v80; // [sp+0h] [bp-D0h]@59
-  int v81; // [sp+0h] [bp-D0h]@109
+  bool v80; // [sp+0h] [bp-D0h]@59
+  bool v81; // [sp+0h] [bp-D0h]@109
   int v82; // [sp+54h] [bp-7Ch]@1
   int v83; // [sp+60h] [bp-70h]@1
   int v84; // [sp+6Ch] [bp-64h]@1
   int v85; // [sp+70h] [bp-60h]@63
-  int a4; // [sp+74h] [bp-5Ch]@73
+  float a4; // [sp+74h] [bp-5Ch]@73
   float v87; // [sp+78h] [bp-58h]@122
   int v88; // [sp+7Ch] [bp-54h]@1
   int v89; // [sp+80h] [bp-50h]@6
@@ -2096,7 +2096,7 @@
           v32 = (struct8 *)array_50AC10;
           v97 = (int)pGame->pLightmapBuilder;
           pGame->pLightmapBuilder->StackLights_TerrainFace(v23, &v95, array_50AC10, 4, 1);
-          pDecalBuilder->_49BE8A(v16, *(float *)&v23, (int)&v95, array_50AC10, 4, 1);
+          pDecalBuilder->_49BE8A(v16, v23, &v95, array_50AC10, 4, 1);
           a5 = 4;
           if ( byte_4D864C && pGame->uFlags & 0x80 )
           {
@@ -2238,7 +2238,7 @@
       }*/
       v96 = pGame->pLightmapBuilder;
       pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0);
-      pDecalBuilder->_49BE8A(v40, *(float *)&v48, (int)&a4, array_50AC10, 3, 0);
+      pDecalBuilder->_49BE8A(v40, v48, &a4, array_50AC10, 3, 0);
       uNumVertices = 3;
       if ( byte_4D864C && pGame->uFlags & 0x80 )
       {
@@ -2298,13 +2298,13 @@
       {
         if ( v57 & 2 && v40->uTileBitmapID == pRenderer->hd_water_tile_id )
         {
-          v81 = 0;
+          v81 = false;
           v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame];
         }
         else
         {
           v58 = v40->uTileBitmapID;
-          v81 = 1;
+          v81 = true;
         }
         pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81);
       }
@@ -2361,7 +2361,7 @@
       }*/
       v96 = pGame->pLightmapBuilder;
       pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1);
-      pDecalBuilder->_49BE8A(v40, *(float *)&v63, (int)&v87, array_50AC10, 3, 1);
+      pDecalBuilder->_49BE8A(v40, v63, &v87, array_50AC10, 3, 1);
       v100 = 3;
       if ( byte_4D864C && pGame->uFlags & 0x80 )
       {
@@ -4468,40 +4468,28 @@
           ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
           ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
         }
-        if ( (signed int)uNumVertices > 0 )
-        {
-          v45 = (char *)&array_50AC10[0].vWorldViewPosition;
-          v57 = (int)&d3d_vertex_buffer[0].pos.y;
-          v55 = uNumVertices;
-          do
+		for (uint i = 0; i < uNumVertices; ++i)
+		{
+		
+		  d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX;
+		  d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY;
+		  d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist);
+		  d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001);
+		  d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0);
+          pGame->AlterGamma_ODM(a4, &d3d_vertex_buffer[i].diffuse);
+
+		  if ( this->bUsingSpecular )
           {
-            a2 = ::GetActorTintColor(a3->dimming_level, 0, *(float *)v45, 0, 0);
-            pGame->AlterGamma_ODM(a4, &a2);
-            v46 = v57;
-            v47 = *(float *)v45 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist;
-            *(int *)(v57 - 4) = *((int *)v45 + 3);
-            *(int *)v57 = *((int *)v45 + 4);
-            *(int *)(v57 + 12) = a2;
-            *(float *)(v57 + 4) = 1.0 - 1.0 / v47;
-            *(float *)(v57 + 8) = 1.0 / (*(float *)v45 + 0.0000001);
-            if ( v5->bUsingSpecular )
-            {
-              v48 = sub_47C3D7_get_fog_related_stuff(0, 0, *(float *)v45);
-              v46 = v57;
-            }
-            else
-            {
-              v48 = 0;
-            }
-            *(int *)(v46 + 16) = v48;
-            *(int *)(v46 + 20) = *((int *)v45 + 6);
-            *(int *)(v46 + 24) = *((int *)v45 + 7);
-            v45 += 48;
-            v18 = v55-- == 1;
-            v57 = v46 + 32;
+            d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x);
           }
-          while ( !v18 );
-        }
+          else
+          {
+            d3d_vertex_buffer[i].specular = 0;
+		  }
+		  d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u;
+		  d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v;
+		  
+		}
 
         if (a4->uAttributes & FACE_OUTLINED)
         {
@@ -4523,45 +4511,27 @@
       }
       else
       {
-        if ( (signed int)uNumVertices > 0 )
-        {
-          v9 = (ODMFace *)&d3d_vertex_buffer[0].pos.y;
-          v10 = (char *)&array_50AC10[0].vWorldViewPosition;
-          a4 = (ODMFace *)&d3d_vertex_buffer[0].pos.y;
-          v56 = uNumVertices;
-          while ( 1 )
+		for (uint i = 0; i < uNumVertices; ++i)
+		{
+		
+		  d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX;
+		  d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY;
+		  d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist);
+		  d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001);
+		  d3d_vertex_buffer[i].diffuse = GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0);
+          if ( this->bUsingSpecular )
           {
-            v11 = *(float *)v10 * 1000.0;
-            *((int *)v9 - 1) = *((int *)v10 + 3);
-            v12 = v11 / (double)pOutdoorCamera->shading_dist_mist;
-            v9->pFacePlane.vNormal.x = *((int *)v10 + 4);
-            *(float *)&v9->pFacePlane.vNormal.y = 1.0 - 1.0 / v12;
-            *(float *)&v9->pFacePlane.vNormal.z = 1.0 / (*(float *)v10 + 0.0000001);
-            v13 = GetActorTintColor(a3->dimming_level, 0, *(float *)v10, 0, 0);
-            v14 = a4;
-            v15 = *(float *)v10;
-            a4->pFacePlane.dist = v13;
-            if ( v5->bUsingSpecular )
-            {
-              v16 = v15;
-              v17 = sub_47C3D7_get_fog_related_stuff(0, 0, v16);
-              v14 = a4;
-            }
-            else
-            {
-              v17 = 0;
-            }
-            v14->zCalc1 = v17;
-            v14->zCalc2 = *((int *)v10 + 6);
-            v14->zCalc3 = *((int *)v10 + 7);
-            v10 += 48;
-            v18 = v56-- == 1;
-            a4 = (ODMFace *)((char *)v14 + 32);
-            if ( v18 )
-              break;
-            v9 = a4;
+            d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x);
           }
-        }
+          else
+          {
+            d3d_vertex_buffer[i].specular = 0;
+		  }
+		  d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u;
+		  d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v;
+		  
+		}
+	  
         ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
         ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
         if (bUsingSpecular)
@@ -4577,18 +4547,10 @@
         ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
         //(*(void (**)(void))(*(int *)v50 + 88))();
         v53->_45D74F_MessWithLight(-1, 0);
-        v23 = uNumVertices;
-        if ( (signed int)uNumVertices > 0 )
-        {
-          v24 = (char *)&d3d_vertex_buffer[0].diffuse;
-          do
-          {
-            *(int *)v24 = a2;
-            v24 += 32;
-            --v23;
-          }
-          while ( v23 );
-        }
+	    for (uint i = 0; i < uNumVertices; ++i)
+		{
+		  d3d_vertex_buffer[i].diffuse = a2;
+		}
         ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture));
         ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
         if ( !pRenderer->bUsingSpecular )
@@ -4606,20 +4568,12 @@
         {
           ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
 
-          v33 = uNumVertices;
-          if ( (signed int)uNumVertices > 0 )
-          {
-            v34 = (char *)&d3d_vertex_buffer[0].specular;
-            do
-            {
-              v35 = *(int *)v34;
-              *(int *)v34 = 0;
-              v34 += 32;
-              --v33;
-              *((int *)v34 - 9) = pRenderer->uFogColor | v35 & 0xFF000000;
-            }
-            while ( v33 );
-          }
+		  for (uint i = 0; i < uNumVertices; ++i)
+		  {
+		    d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000;
+		    d3d_vertex_buffer[i].specular = 0;
+		  }
+
           ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
           ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA));
           ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA));
@@ -5966,7 +5920,7 @@
   pParty->uFlags |= 2u;
   LODWORD(flt_6BE3A0) = 0x3F0CCCCDu;
   pViewport->_4C02F8(36044);
-  return v15;
+  return v15 != 0;
 }
 // 6BE3A0: using guessed type float flt_6BE3A0;
 
@@ -7208,7 +7162,7 @@
 //----- (004A2031) --------------------------------------------------------
 unsigned int Render::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6)
 {
-  __debugbreak(); // should not fire outside decal builder
+//  __debugbreak(); // should not fire outside decal builder
   return ::GetActorTintColor(tint, a4, a2, a5, a6);
 }
 
@@ -7436,46 +7390,28 @@
             this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
           }
         }
-        if (uNumVertices > 0)
-        {
-          v51 = (int)&d3d_vertex_buffer[0].pos.y;
-          v52 = (char *)&array_50AC10[0].vWorldViewPosition;
-          a7 = (int)&d3d_vertex_buffer[0].pos.y;
-          v66 = uNumVertices;
-          while ( 1 )
+
+		for (uint i = 0; i < uNumVertices; ++i)
+		{
+		
+		  d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX;
+		  d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY;
+		  d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist);
+		  d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001);
+		  d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0);
+          if ( this->bUsingSpecular )
           {
-            v53 = *(float *)v52 * 1000.0;
-            *(int *)(v51 - 4) = *((int *)v52 + 3);
-            v54 = v53 / (double)pOutdoorCamera->shading_dist_mist;
-            *(int *)v51 = *((int *)v52 + 4);
-            *(float *)(v51 + 4) = 1.0 - 1.0 / v54;
-            *(float *)(v51 + 8) = 1.0 / (*(float *)v52 + 0.0000001);
-            v55 = ::GetActorTintColor(a4->dimming_level, 0, *(float *)v52, 0, 0);
-            v56 = a7;
-            v57 = *(float *)v52;
-            *(int *)(a7 + 12) = v55;
-            if ( this->bUsingSpecular )
-            {
-              v58 = v57;
-              v59 = sub_47C3D7_get_fog_related_stuff(0, 0, v58);
-              v56 = a7;
-            }
-            else
-            {
-              v59 = 0;
-            }
-            *(int *)(v56 + 16) = v59;
-            *(int *)(v56 + 20) = *((int *)v52 + 6);
-            *(int *)(v56 + 24) = *((int *)v52 + 7);
-            v52 += 48;
-            v21 = v66-- == 1;
-            a7 = v56 + 32;
-            if ( v21 )
-              break;
-            v51 = a7;
+            d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x);
           }
-        }
-        this->pRenderD3D->pDevice->SetTexture(0, a5);
+          else
+          {
+            d3d_vertex_buffer[i].specular = 0;
+		  }
+		  d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u;
+		  d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v;
+		}
+
+		this->pRenderD3D->pDevice->SetTexture(0, a5);
         this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16);
         if (transparent)
         {
@@ -7486,45 +7422,26 @@
       }
       else
       {
-        if ( (signed int)uNumVertices > 0 )
-        {
-          v12 = (int)&d3d_vertex_buffer[0].pos.y;
-          v13 = (char *)&array_50AC10[0].vWorldViewPosition;
-          a7 = (int)&d3d_vertex_buffer[0].pos.y;
-          a6a = uNumVertices;
-          while ( 1 )
+		for (uint i = 0; i < uNumVertices; ++i)
+		{
+		
+		  d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX;
+		  d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY;
+		  d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist);
+		  d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001);
+		  d3d_vertex_buffer[i].diffuse = GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0);
+          if ( this->bUsingSpecular )
           {
-            v14 = *(float *)v13 * 1000.0;
-            *(int *)(v12 - 4) = *((int *)v13 + 3);
-            v15 = v14 / (double)pOutdoorCamera->shading_dist_mist;
-            *(int *)v12 = *((int *)v13 + 4);
-            *(float *)(v12 + 4) = 1.0 - 1.0 / v15;
-            *(float *)(v12 + 8) = 1.0 / (*(float *)v13 + 0.0000001);
-            v16 = GetActorTintColor(a4->dimming_level, 0, *(float *)v13, 0, 0);
-            v17 = a7;
-            v18 = *(float *)v13;
-            *(int *)(a7 + 12) = v16;
-            if ( this->bUsingSpecular )
-            {
-              v19 = v18;
-              v20 = sub_47C3D7_get_fog_related_stuff(0, 0, v19);
-              v17 = a7;
-            }
-            else
-            {
-              v20 = 0;
-            }
-            *(int *)(v17 + 16) = v20;
-            *(int *)(v17 + 20) = *((int *)v13 + 6);
-            *(int *)(v17 + 24) = *((int *)v13 + 7);
-            v13 += 48;
-            v21 = a6a-- == 1;
-            a7 = v17 + 32;
-            if ( v21 )
-              break;
-            v12 = a7;
+            d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x);
           }
-        }
+          else
+          {
+            d3d_vertex_buffer[i].specular = 0;
+		  }
+		  d3d_vertex_buffer[i].specular = v20;
+		  d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u;
+		  d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v;
+		}
         ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
         ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
         if (pRenderer->bUsingSpecular)
@@ -7540,18 +7457,10 @@
         ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
         //(*(void (**)(void))(*(int *)v63 + 88))();
         pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0);
-        v26 = uNumVertices;
-        if ( (signed int)uNumVertices > 0 )
-        {
-          v27 = (char *)&d3d_vertex_buffer[0].diffuse;
-          do
-          {
-            *(int *)v27 = -1;
-            v27 += 32;
-            --v26;
-          }
-          while ( v26 );
-        }
+	    for (uint i = 0; i < uNumVertices; ++i)
+	    {
+		  d3d_vertex_buffer[i].diffuse = -1;
+	    }
         ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5));
         ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
         if ( !pRenderer->bUsingSpecular )
@@ -7570,20 +7479,12 @@
         {
           ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
           ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));
-          v37 = uNumVertices;
-          if ( (signed int)uNumVertices > 0 )
-          {
-            v38 = (char *)&d3d_vertex_buffer[0].specular;
-            do
-            {
-              v39 = *(int *)v38;
-              *(int *)v38 = 0;
-              v38 += 32;
-              --v37;
-              *((int *)v38 - 9) = pRenderer->uFogColor | v39 & 0xFF000000;
-            }
-            while ( v37 );
-          }
+		  for (uint i = 0; i < uNumVertices; ++i)
+		  {
+			d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000;
+			d3d_vertex_buffer[i].specular = 0;
+		  }
+
           ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem
           ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA));
           ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA));
@@ -7659,11 +7560,11 @@
   signed int v4; // edi@2
   int v5; // eax@3
   int v6; // edx@5
-  char *v7; // eax@6
-  char *v8; // ecx@6
-  double v9; // st6@7
-  int v10; // ebx@7
-  int v11; // ebx@7
+  RenderVertexD3D3 *v7; // eax@6
+  RenderVertexSoft *v8; // ecx@6
+  //double v9; // st6@7
+  //int v10; // ebx@7
+  //int v11; // ebx@7
 
   if ( this->uNumD3DSceneBegins )
   {
@@ -7675,29 +7576,18 @@
       if ( v5 < pOutdoor->max_terrain_dimming_level )
         v5 = pOutdoor->max_terrain_dimming_level;
       v6 = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8);
-      if ( a2 > 0 )
-      {
-        v7 = (char *)&d3d_vertex_buffer[0].pos.y;
-        v8 = (char *)&array_507D30[0].vWorldViewProjY;
-        do
-        {
-          v9 = *((float *)v8 - 4) * 0.061758894;
-          v10 = *((int *)v8 - 1);
-          *((int *)v7 + 4) = 0;
-          *((int *)v7 - 1) = v10;
-          *(int *)v7 = *(int *)v8;
-          *((int *)v7 + 2) = *((int *)v8 + 1);
-          *((int *)v7 + 5) = *((int *)v8 + 2);
-          v11 = *((int *)v8 + 3);
-          *((int *)v7 + 3) = v6;
-          *((int *)v7 + 6) = v11;
-          v8 += 48;
-          v7 += 32;
-          --v4;
-          *((float *)v7 - 7) = 1.0 - 1.0 / v9;
-        }
-        while ( v4 );
-      }
+	  for (uint i = 0; i < a2; ++i)
+	  {
+		d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX;
+		d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY;
+		d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / array_507D30[i].vWorldViewPosition.y;
+		d3d_vertex_buffer[i].rhw = array_507D30[i]._rhw;
+		d3d_vertex_buffer[i].diffuse = v6;
+		d3d_vertex_buffer[i].specular = 0;
+		d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u;
+		d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v;
+	  }
+
       ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex));
       ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
         D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
@@ -7713,8 +7603,8 @@
 {
   //Render *v8; // edi@1
   //unsigned int v9; // esi@3
-  char *v12; // ecx@9
-  char *v13; // eax@9
+  RenderVertexSoft *v12; // ecx@9
+  RenderVertexD3D3 *v13; // eax@9
   double v14; // st6@10
   int v15; // edx@10
   Texture *v16; // edx@10
@@ -7772,35 +7662,18 @@
       __debugbreak();
       ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false));
       ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
-      if ( (signed int)uNumVertices > 0 )
-      {
-        v12 = (char *)&array_507D30[0].vWorldViewPosition;
-        v13 = (char *)&d3d_vertex_buffer[0].pos.y;
-        auto a7 = uNumVertices;
-        uint v18;
-        do
-        {
-          v14 = *(float *)v12 * 0.061758894;
-          v15 = *((int *)v12 + 3);
-          *((int *)v13 + 4) = 0;
-          *((int *)v13 - 1) = v15;
-          *(int *)v13 = *((int *)v12 + 4);
-          *((int *)v13 + 3) = uCorrectedColor;
-          v16 = pTex;
-          v13 += 32;
-          *((float *)v13 - 7) = 1.0 - 1.0 / v14;
-          v17 = 1.0 / *(float *)v12;
-          v12 += 48;
-          v18 = a7-- == 1;
-          *((float *)v13 - 6) = v17;
-          pHwTex = (IDirect3DTexture2 *)v16->uTextureWidth;
-          v19 = pTex;
-          *((float *)v13 - 3) = *((float *)v12 - 6) / (double)(signed int)pHwTex;
-          pHwTex = (IDirect3DTexture2 *)v19->uTextureHeight;
-          *((float *)v13 - 2) = *((float *)v12 - 5) / (double)(signed int)pHwTex;
-        }
-        while ( !v18 );
-      }
+	  for (uint i = 0; i < uNumVertices; ++i)
+	  {
+		d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX;
+		d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY;
+		d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894);
+		d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x;
+		d3d_vertex_buffer[i].diffuse = uCorrectedColor;
+		d3d_vertex_buffer[i].specular = 0;
+		d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth;
+		d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight;
+	  }
+
       ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
       ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
       ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
@@ -10778,7 +10651,7 @@
 void Render::ChangeBetweenWinFullscreenModes()
 {
   float v0; // ST14_4@17
-  int v1; // edx@24
+  bool v1; // edx@24
   signed int v2; // ecx@24
   int v3; // esi@25
   int v4; // edx@26
@@ -10860,9 +10733,8 @@
         ++v3;
         *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR;
         LOBYTE(v4) = v5->uParticleTrailColorG;
-        v1 = v5->uParticleTrailColorB | (v4 << 8);
+        v5->uParticleTrailColor = v5->uParticleTrailColorB | (v4 << 8);
         ++v2;
-        v5->uParticleTrailColor = v1;
       }
       while ( v2 < (signed int)pObjectList->uNumObjects );
     }
@@ -11146,7 +11018,7 @@
       while ( v2 < (signed int)v1->uNumItems );
     }
   }
-  return 1;
+  return true;
 }
 
 //----- (00452347) --------------------------------------------------------
--- a/SaveLoad.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/SaveLoad.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -256,7 +256,7 @@
  
   //v66 = a2;
   strcpy(byte_6BE3B0, pCurrentMapName);
-  if (!_strcmpi(pCurrentMapName, "d05.blv")) // arena
+  if (!_stricmp(pCurrentMapName, "d05.blv")) // arena
     return;
 
   uncompressed_buff = (char*)malloc(1000000);
@@ -457,7 +457,7 @@
               data_write_pos += 4;
             }
       
-        for (int i = 0; i <= (signed int)uNumLevelDecorations; ++i)
+        for (int i = 0; i < (signed int)uNumLevelDecorations; ++i)
         {
           memcpy(data_write_pos, &pLevelDecorations[i].field_2, 2);
           data_write_pos += 2;
@@ -535,7 +535,7 @@
 
   //v1 = uSlot;
   //v6 = uSlot;
-  bNotArena = _strcmpi(pCurrentMapName, "d05.blv");
+  bNotArena = _stricmp(pCurrentMapName, "d05.blv");
   if ( bNotArena )
   {
     LOD::Directory pDir; // [sp+Ch] [bp-28h]@2
--- a/Spells.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/Spells.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -24,7 +24,7 @@
 struct SpellStats *pSpellStats;
 
 
-stru324_spell stru_4E3ACC[100] =
+stru324_spell stru_4E3ACC[103] =
 {
   {10, 0},
   {1000, 0}, {1010, 0}, {1020, 0}, {1030, 0}, {1040, 0}, {1050, 0}, {1060, 0}, {1070, 0}, {1080, 0}, {1090, 0}, {1100, 0},
@@ -35,10 +35,10 @@
   {6000, 0}, {6010, 0}, {6020, 0}, {6030, 0}, {6040, 0}, {6050, 0}, {6060, 0}, {6070, 0}, {6080, 0}, {6090, 0}, {6100, 0},
   {7000, 0}, {7010, 0}, {7020, 0}, {7030, 0}, {7040, 0}, {7050, 0}, {7060, 0}, {7070, 0}, {7080, 0}, {7090, 0}, {7100, 0},
   {8000, 0}, {8010, 0}, {8020, 0}, {8030, 0}, {8040, 0}, {8050, 0}, {8060, 0}, {8070, 0}, {8080, 0}, {8090, 0}, {8100, 0},
-  {9000, 0}, {9010, 0}, {9020, 0}, {9030, 0}, {9040, 0}, {9050, 0}, {9060, 0}, {9070, 0}, {9080, 0}, {9090, 0}, {9100, 0}
-  //{545, 0},
-  //{545, 0},
-  //{555, 0}
+  {9000, 0}, {9010, 0}, {9020, 0}, {9030, 0}, {9040, 0}, {9050, 0}, {9060, 0}, {9070, 0}, {9080, 0}, {9090, 0}, {9100, 0},
+  {545, 0},
+  {545, 0},
+  {555, 0}
 };
  //9 spellbook pages  11 spells per page 9*11 =99 +1 zero struct at 0. It counted from 1!
 SpellData pSpellDatas[100]={
@@ -323,53 +323,53 @@
 					break;
 				case 3:
 					pInfos[i].uSchool = SPELL_SCHOOL_NONE;
-					if (!_strcmpi("fire", test_string) )
+					if (!_stricmp("fire", test_string) )
 						{
 						pInfos[i].uSchool =SPELL_SCHOOL_FIRE;
 						break;
 						}
-					if ( !_strcmpi("air", test_string) )	
+					if ( !_stricmp("air", test_string) )	
 						{
 						pInfos[i].uSchool = SPELL_SCHOOL_AIR;
 						break;
 						}
-					if ( !_strcmpi("water", test_string))	
+					if ( !_stricmp("water", test_string))	
 						{
 						pInfos[i].uSchool = SPELL_SCHOOL_WATER;
 						break;
 						}	
-					if ( !_strcmpi("earth", test_string))	
+					if ( !_stricmp("earth", test_string))	
 						{
 						pInfos[i].uSchool = SPELL_SCHOOL_EARTH;
 						break;
 						}	
-					if ( !_strcmpi("spirit", test_string))	
+					if ( !_stricmp("spirit", test_string))	
 						{
 						pInfos[i].uSchool = SPELL_SCHOOL_SPIRIT;
 						break;
 						}
-					if ( !_strcmpi("mind", test_string))	
+					if ( !_stricmp("mind", test_string))	
 						{
 						pInfos[i].uSchool = SPELL_SCHOOL_MIND;
 						break;
 						}
-					if ( !_strcmpi("body", test_string) )	
+					if ( !_stricmp("body", test_string) )	
 						{
 						pInfos[i].uSchool = SPELL_SCHOOL_BODY;
 						break;
 						}			
-					if ( !_strcmpi("light", test_string) )	
+					if ( !_stricmp("light", test_string) )	
 						{
 						pInfos[i].uSchool =  SPELL_SCHOOL_LIGHT;
 						break;
 						}					
-					if ( !_strcmpi("dark", test_string))	
+					if ( !_stricmp("dark", test_string))	
 						{
 						pInfos[i].uSchool = SPELL_SCHOOL_DARK;
 						break;
 						}					
 
-					if ( !_strcmpi("magic", test_string))	
+					if ( !_stricmp("magic", test_string))	
 						{
 						pInfos[i].uSchool = SPELL_SCHOOL_MAGIC;
 						break;
--- a/SpriteObject.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/SpriteObject.h	Sat Jun 01 10:32:31 2013 +0600
@@ -12,11 +12,11 @@
 #pragma pack(push, 1)
 struct SpriteObject
 {
-  inline bool AttachedToActor() const {return uAttributes & OBJECT_ATTACHED_TO_ACTOR;}
+  inline bool AttachedToActor() const {return (uAttributes & OBJECT_ATTACHED_TO_ACTOR) != 0;}
 
   SpriteObject();
   int Create(int yaw, int pitch, int a4, int a5);
-  void _46BEF1_apply_spells();
+  void _46BEF1_apply_spells_aoe();
   void _438E35();
 
   static void UpdateObject_fn0_BLV(unsigned int uLayingItemID);
--- a/Sprites.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/Sprites.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -475,18 +475,18 @@
         v16 = (int)&v2->pSpriteSFrames[v2->uNumSpriteFrames];
         if ( *(short *)(v16 + 48) )
           *(int *)(v16 + 44) |= 2u;
-        if ( !_strcmpi(v43.pProperties[2], "new") )
+        if ( !_stricmp(v43.pProperties[2], "new") )
         {
           v17 = (int)&v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags;
           *(int *)v17 |= 4u;
           v2->pSpritePFrames[v2->uNumEFrames] = &v2->pSpriteSFrames[v2->uNumSpriteFrames];
           v2->pSpriteEFrames[v2->uNumEFrames++] = LOWORD(v2->uNumSpriteFrames);
         }
-        if ( !_strcmpi(v43.pProperties[10], "1") )
+        if ( !_stricmp(v43.pProperties[10], "1") )
           BYTE2(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 4u;
-        if ( !_strcmpi(v43.pProperties[11], "1") )
+        if ( !_stricmp(v43.pProperties[11], "1") )
           BYTE2(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 2u;
-        if ( !_strcmpi(v43.pProperties[12], "1") )
+        if ( !_stricmp(v43.pProperties[12], "1") )
         {
           v18 = (int)&v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags;
           *(int *)v18 |= 0x20u;
@@ -514,23 +514,23 @@
         for ( j = 13; j < v43.uPropCount; ++j )
         {
           v24 = v43.pProperties[j];
-          if ( _strcmpi(v43.pProperties[j], "Luminous") )
+          if ( _stricmp(v43.pProperties[j], "Luminous") )
           {
-            if ( _strcmpi(v24, "Mirror0") )
+            if ( _stricmp(v24, "Mirror0") )
             {
-              if ( _strcmpi(v24, "Mirror1") )
+              if ( _stricmp(v24, "Mirror1") )
               {
-                if ( _strcmpi(v24, "Mirror2") )
+                if ( _stricmp(v24, "Mirror2") )
                 {
-                  if ( _strcmpi(v24, "Mirror3") )
+                  if ( _stricmp(v24, "Mirror3") )
                   {
-                    if ( _strcmpi(v24, "Mirror4") )
+                    if ( _stricmp(v24, "Mirror4") )
                     {
-                      if ( _strcmpi(v24, "Mirror5") )
+                      if ( _stricmp(v24, "Mirror5") )
                       {
-                        if ( _strcmpi(v24, "Mirror6") )
+                        if ( _stricmp(v24, "Mirror6") )
                         {
-                          if ( !_strcmpi(v24, "Mirror7") )
+                          if ( !_stricmp(v24, "Mirror7") )
                             BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 0x80u;
                         }
                         else
@@ -622,7 +622,7 @@
         {
           do
           {
-            if ( _strcmpi(v2->pSpritePFrames[(int)Argsc]->pIconName, v2->pSpritePFrames[v35]->pIconName) < 0 )
+            if ( _stricmp(v2->pSpritePFrames[(int)Argsc]->pIconName, v2->pSpritePFrames[v35]->pIconName) < 0 )
             {
               v36 = v2->pSpritePFrames;
               v37 = (int)&v36[(int)Argsc];
--- a/Sprites.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/Sprites.h	Sat Jun 01 10:32:31 2013 +0600
@@ -3,8 +3,9 @@
 
 /*   18 */
 #pragma pack(push, 1)
-struct Sprite  //28h
+class Sprite  //28h
 {
+public:
     void Release();
 
     const char *pName;  //0
@@ -23,8 +24,9 @@
 
 /*   42 */
 #pragma pack(push, 1)
-struct SpriteFrame
+class SpriteFrame
 {
+public:
     char pIconName[12]; 
     char pTextureName[12]; //c
     __int16 pHwSpriteIDs[8]; //18h
@@ -65,8 +67,8 @@
     signed int uNumSpriteFrames;
     unsigned int uNumEFrames;//field_4;
     int unused_field;          //field_8
-    struct SpriteFrame *pSpriteSFrames;  //0c
-    struct SpriteFrame **pSpritePFrames; //10h
+    SpriteFrame *pSpriteSFrames;  //0c
+    SpriteFrame **pSpritePFrames; //10h
     __int16 *pSpriteEFrames; //14h
 };
 #pragma pack(pop)
--- a/Texture.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/Texture.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -52,7 +52,7 @@
 Texture *pTextures_tabs[9][2];
 Texture *pTexture_mapbordr; // idb
 Texture *pTexture_pagemask; // idb
-Texture *pSpellBookPagesTextr[8];
+Texture *pSpellBookPagesTextr[9];
 Texture *pSpellBookPagesTextr_9;
 Texture *pSpellBookPagesTextr_10;
 Texture *pSpellBookPagesTextr_11;
@@ -278,7 +278,7 @@
     {
       v3->pTextures[i].uTextureID = pBitmaps_LOD->LoadTexture(v3->pTextures[i].pTextureName, TEXTURE_DEFAULT);
 
-      if (v3->pTextures[i].uTextureID != -1);
+      if (v3->pTextures[i].uTextureID != -1)
         pBitmaps_LOD->pTextures[v3->pTextures[i].uTextureID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v3->pTextures[i].uTextureID].palette_id1);
       //result = (unsigned int)v3->pTextures;
       //if ( !(*(char *)(result + i * 20 + 18) & 1) )
@@ -307,7 +307,7 @@
   }
   else
   {
-    while ( _strcmpi(v2->pTextures[v3].pTextureName, Str2) )
+    while ( _stricmp(v2->pTextures[v3].pTextureName, Str2) )
     {
       ++uID;
       ++v3;
@@ -363,6 +363,7 @@
 void *Texture::UnzipPalette()
 {
   Texture *v1; // esi@1
+
   void *v2; // edi@1
   Texture *pSource; // [sp+0h] [bp-4h]@1
 
@@ -382,10 +383,13 @@
 
     if (pBits & 0x0400)
     {
-      pAllocator->FreeChunk(pLevelOfDetail0_prolly_alpha_mask);
+		__debugbreak();
+	}
+	
+	  pAllocator->FreeChunk(pLevelOfDetail0_prolly_alpha_mask);
       pAllocator->FreeChunk(pPalette16);
       pAllocator->FreeChunk(pPalette24);
-    }
+    
 
     pLevelOfDetail0_prolly_alpha_mask = nullptr;
     pLevelOfDetail1 = nullptr;
--- a/Texture.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/Texture.h	Sat Jun 01 10:32:31 2013 +0600
@@ -155,7 +155,7 @@
 extern Texture *pTextures_tabs[9][2];
 extern Texture *pTexture_mapbordr; // idb
 extern Texture *pTexture_pagemask; // idb
-extern Texture *pSpellBookPagesTextr[8];
+extern Texture *pSpellBookPagesTextr[9];
 extern Texture *pSpellBookPagesTextr_9;
 extern Texture *pSpellBookPagesTextr_10;
 extern Texture *pSpellBookPagesTextr_11;
--- a/TileTable.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/TileTable.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -254,59 +254,59 @@
     v9 = v84.pProperties[3];
     v2->pTiles[v2->sNumTiles].uBitmapID = v8;
     v2->pTiles[v2->sNumTiles].tileset = Tileset_Grass;
-    if ( _strcmpi(v9, "TTtype_NULL") )
+    if ( _stricmp(v9, "TTtype_NULL") )
     {
-      if ( _strcmpi(v9, "TTtype_Start") )
+      if ( _stricmp(v9, "TTtype_Start") )
       {
-        if ( _strcmpi(v9, "TTtype_Grass") )
+        if ( _stricmp(v9, "TTtype_Grass") )
         {
-          if ( _strcmpi(v9, "TTtype_Cracked") )
+          if ( _stricmp(v9, "TTtype_Cracked") )
           {
-            if ( _strcmpi(v9, "TTtype_Snow") )
+            if ( _stricmp(v9, "TTtype_Snow") )
             {
-              if ( _strcmpi(v9, "TTtype_Sand") )
+              if ( _stricmp(v9, "TTtype_Sand") )
               {
-                if ( _strcmpi(v9, "TTtype_Volcano") )
+                if ( _stricmp(v9, "TTtype_Volcano") )
                 {
-                  if ( _strcmpi(v9, "TTtype_Dirt") )
+                  if ( _stricmp(v9, "TTtype_Dirt") )
                   {
-                    if ( _strcmpi(v9, "TTtype_Water") )
+                    if ( _stricmp(v9, "TTtype_Water") )
                     {
-                      if ( _strcmpi(v9, "TTtype_Tropical") )
+                      if ( _stricmp(v9, "TTtype_Tropical") )
                       {
-                        if ( _strcmpi(v9, "TTtype_Swamp") )
+                        if ( _stricmp(v9, "TTtype_Swamp") )
                         {
-                          if ( _strcmpi(v9, "TTtype_City") )
+                          if ( _stricmp(v9, "TTtype_City") )
                           {
-                            if ( _strcmpi(v9, "TTtype_RoadGrassCobble") )
+                            if ( _stricmp(v9, "TTtype_RoadGrassCobble") )
                             {
-                              if ( _strcmpi(v9, "TTtype_RoadGrassDirt") )
+                              if ( _stricmp(v9, "TTtype_RoadGrassDirt") )
                               {
-                                if ( _strcmpi(v9, "TTtype_RoadCrackedCobble") )
+                                if ( _stricmp(v9, "TTtype_RoadCrackedCobble") )
                                 {
-                                  if ( _strcmpi(v9, "TTtype_RoadCrackedDirt") )
+                                  if ( _stricmp(v9, "TTtype_RoadCrackedDirt") )
                                   {
-                                    if ( _strcmpi(v9, "TTtype_RoadSandCobble") )
+                                    if ( _stricmp(v9, "TTtype_RoadSandCobble") )
                                     {
-                                      if ( _strcmpi(v9, "TTtype_RoadSandDirt") )
+                                      if ( _stricmp(v9, "TTtype_RoadSandDirt") )
                                       {
-                                        if ( _strcmpi(v9, "TTtype_RoadVolcanoCobble") )
+                                        if ( _stricmp(v9, "TTtype_RoadVolcanoCobble") )
                                         {
-                                          if ( _strcmpi(v9, "TTtype_RoadVolcanoDirt") )
+                                          if ( _stricmp(v9, "TTtype_RoadVolcanoDirt") )
                                           {
-                                            if ( _strcmpi(v9, "TTtype_RoadSwampCobble") )
+                                            if ( _stricmp(v9, "TTtype_RoadSwampCobble") )
                                             {
-                                              if ( _strcmpi(v9, "TTtype_RoadSwampDirt") )
+                                              if ( _stricmp(v9, "TTtype_RoadSwampDirt") )
                                               {
-                                                if ( _strcmpi(v9, "TTtype_RoadTropicalCobble") )
+                                                if ( _stricmp(v9, "TTtype_RoadTropicalCobble") )
                                                 {
-                                                  if ( _strcmpi(v9, "TTtype_RoadTropicalDirt") )
+                                                  if ( _stricmp(v9, "TTtype_RoadTropicalDirt") )
                                                   {
-                                                    if ( _strcmpi(v9, "TTtype_RoadSnowCobble") )
+                                                    if ( _stricmp(v9, "TTtype_RoadSnowCobble") )
                                                     {
-                                                      if ( _strcmpi(v9, "TTtype_RoadSnowDirt") )
+                                                      if ( _stricmp(v9, "TTtype_RoadSnowDirt") )
                                                       {
-                                                        if ( !_strcmpi(v9, "TTtype_RoadCityStone") )
+                                                        if ( !_stricmp(v9, "TTtype_RoadCityStone") )
                                                         {
                                                           v34 = (int)&v2->pTiles[v2->sNumTiles].tileset;
                                                           *(char *)v34 |= 0x1Cu;
@@ -464,30 +464,30 @@
     v35 = v84.pProperties[4];
     v2->pTiles[v2->sNumTiles].uSection = 0;
     v2->pTiles[v2->sNumTiles].uAttributes = 0;
-    if ( !_strcmpi(v35, "TTsect_NULL") )
+    if ( !_stricmp(v35, "TTsect_NULL") )
     {
       LOBYTE(v2->pTiles[v2->sNumTiles].uSection) = -1;
 LABEL_152:
       for ( j = 5; j < v84.uPropCount; ++j )
       {
         v72 = v84.pProperties[j];
-        if ( _strcmpi(v84.pProperties[j], "TTattr_Burn") )
+        if ( _stricmp(v84.pProperties[j], "TTattr_Burn") )
         {
-          if ( _strcmpi(v72, "TTattr_Water") )
+          if ( _stricmp(v72, "TTattr_Water") )
           {
-            if ( _strcmpi(v72, "TTattr_Water2") )
+            if ( _stricmp(v72, "TTattr_Water2") )
             {
-              if ( _strcmpi(v72, "TTattr_Block") )
+              if ( _stricmp(v72, "TTattr_Block") )
               {
-                if ( _strcmpi(v72, "TTattr_Repulse") )
+                if ( _stricmp(v72, "TTattr_Repulse") )
                 {
-                  if ( _strcmpi(v72, "TTattr_Flat") )
+                  if ( _stricmp(v72, "TTattr_Flat") )
                   {
-                    if ( _strcmpi(v72, "TTattr_Wave") )
+                    if ( _stricmp(v72, "TTattr_Wave") )
                     {
-                      if ( _strcmpi(v72, "TTattr_NoDraw") )
+                      if ( _stricmp(v72, "TTattr_NoDraw") )
                       {
-                        if ( !_strcmpi(v72, "TTattr_Transition") )
+                        if ( !_stricmp(v72, "TTattr_Transition") )
                         {
                           v80 = (int)&v2->pTiles[v2->sNumTiles].uAttributes;
                           *(short *)v80 |= 0x200u;
@@ -543,245 +543,245 @@
       ++v2->sNumTiles;
       goto LABEL_173;
     }
-    if ( !_strcmpi(v35, "TTsect_Start") )
+    if ( !_stricmp(v35, "TTsect_Start") )
     {
       v36 = (int)&v2->pTiles[v2->sNumTiles].uSection;
       *(char *)v36 |= 0xFEu;
       goto LABEL_152;
     }
-    if ( !_strcmpi(v35, "TTsect_Base1") )
+    if ( !_stricmp(v35, "TTsect_Base1") )
       goto LABEL_152;
-    if ( !_strcmpi(v35, "TTsect_Base2") )
+    if ( !_stricmp(v35, "TTsect_Base2") )
     {
       v37 = (int)&v2->pTiles[v2->sNumTiles].uSection;
       *(char *)v37 |= 1u;
       goto LABEL_152;
     }
-    if ( !_strcmpi(v35, "TTsect_Base3") )
+    if ( !_stricmp(v35, "TTsect_Base3") )
     {
       v38 = (int)&v2->pTiles[v2->sNumTiles].uSection;
       *(char *)v38 |= 2u;
       goto LABEL_152;
     }
-    if ( !_strcmpi(v35, "TTsect_Base4") )
+    if ( !_stricmp(v35, "TTsect_Base4") )
     {
       v39 = (int)&v2->pTiles[v2->sNumTiles].uSection;
       *(char *)v39 |= 3u;
       goto LABEL_152;
     }
-    if ( !_strcmpi(v35, "TTsect_Special1") )
+    if ( !_stricmp(v35, "TTsect_Special1") )
     {
       v40 = (int)&v2->pTiles[v2->sNumTiles].uSection;
       *(char *)v40 |= 4u;
       goto LABEL_152;
     }
-    if ( !_strcmpi(v35, "TTsect_Special2") )
+    if ( !_stricmp(v35, "TTsect_Special2") )
     {
       v41 = (int)&v2->pTiles[v2->sNumTiles].uSection;
       *(char *)v41 |= 5u;
       goto LABEL_152;
     }
-    if ( !_strcmpi(v35, "TTsect_Special3") )
+    if ( !_stricmp(v35, "TTsect_Special3") )
     {
       v42 = (int)&v2->pTiles[v2->sNumTiles].uSection;
       *(char *)v42 |= 6u;
       goto LABEL_152;
     }
-    if ( !_strcmpi(v35, "TTsect_Special4") )
+    if ( !_stricmp(v35, "TTsect_Special4") )
     {
       v43 = (int)&v2->pTiles[v2->sNumTiles].uSection;
       *(char *)v43 |= 7u;
       goto LABEL_152;
     }
-    if ( !_strcmpi(v35, "TTsect_Special5") )
+    if ( !_stricmp(v35, "TTsect_Special5") )
     {
       v44 = (int)&v2->pTiles[v2->sNumTiles].uSection;
       *(char *)v44 |= 8u;
       goto LABEL_152;
     }
-    if ( !_strcmpi(v35, "TTsect_Special6") )
+    if ( !_stricmp(v35, "TTsect_Special6") )
     {
       v45 = (int)&v2->pTiles[v2->sNumTiles].uSection;
       *(char *)v45 |= 9u;
       goto LABEL_152;
     }
-    if ( !_strcmpi(v35, "TTsect_Special7") )
+    if ( !_stricmp(v35, "TTsect_Special7") )
     {
       v46 = (int)&v2->pTiles[v2->sNumTiles].uSection;
       *(char *)v46 |= 0xAu;
       goto LABEL_152;
     }
-    if ( !_strcmpi(v35, "TTsect_Special8") )
+    if ( !_stricmp(v35, "TTsect_Special8") )
     {
       v47 = (int)&v2->pTiles[v2->sNumTiles].uSection;
       *(char *)v47 |= 0xBu;
       goto LABEL_152;
     }
-    if ( !_strcmpi(v35, "TTsect_NE1") )
+    if ( !_stricmp(v35, "TTsect_NE1") )
       goto LABEL_130;
-    if ( !_strcmpi(v35, "TTsect_NW1") )
+    if ( !_stricmp(v35, "TTsect_NW1") )
       goto LABEL_134;
-    if ( !_strcmpi(v35, "TTsect_SE1") )
+    if ( !_stricmp(v35, "TTsect_SE1") )
       goto LABEL_130;
-    if ( !_strcmpi(v35, "TTsect_SW1") )
+    if ( !_stricmp(v35, "TTsect_SW1") )
       goto LABEL_134;
-    if ( !_strcmpi(v35, "TTsect_E1") )
+    if ( !_stricmp(v35, "TTsect_E1") )
       goto LABEL_138;
-    if ( !_strcmpi(v35, "TTsect_W1") )
+    if ( !_stricmp(v35, "TTsect_W1") )
       goto LABEL_140;
-    if ( !_strcmpi(v35, "TTsect_N1") )
+    if ( !_stricmp(v35, "TTsect_N1") )
       goto LABEL_142;
-    if ( !_strcmpi(v35, "TTsect_S1") )
+    if ( !_stricmp(v35, "TTsect_S1") )
       goto LABEL_144;
-    if ( !_strcmpi(v35, "TTsect_XNE1") )
+    if ( !_stricmp(v35, "TTsect_XNE1") )
       goto LABEL_146;
-    if ( _strcmpi(v35, "TTsect_XNW1") )
+    if ( _stricmp(v35, "TTsect_XNW1") )
     {
-      if ( !_strcmpi(v35, "TTsect_XSE1") )
+      if ( !_stricmp(v35, "TTsect_XSE1") )
         goto LABEL_146;
-      if ( _strcmpi(v35, "TTsect_XSW1") )
+      if ( _stricmp(v35, "TTsect_XSW1") )
       {
-        if ( !_strcmpi(v35, "TTsect_CROS") )
+        if ( !_stricmp(v35, "TTsect_CROS") )
         {
 LABEL_151:
           v70 = (int)&v2->pTiles[v2->sNumTiles].uAttributes;
           *(short *)v70 |= 0x200u;
           goto LABEL_152;
         }
-        if ( !_strcmpi(v35, "TTsect_NS") )
+        if ( !_stricmp(v35, "TTsect_NS") )
         {
           v48 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v48 |= 1u;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_EW") )
+        if ( !_stricmp(v35, "TTsect_EW") )
         {
           v49 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v49 |= 2u;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_N_E") )
+        if ( !_stricmp(v35, "TTsect_N_E") )
         {
           v50 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v50 |= 3u;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_N_W") )
+        if ( !_stricmp(v35, "TTsect_N_W") )
         {
           v51 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v51 |= 4u;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_S_E") )
+        if ( !_stricmp(v35, "TTsect_S_E") )
         {
           v52 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v52 |= 5u;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_S_W") )
+        if ( !_stricmp(v35, "TTsect_S_W") )
         {
           v53 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v53 |= 6u;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_NS_E") )
+        if ( !_stricmp(v35, "TTsect_NS_E") )
         {
           v54 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v54 |= 7u;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_NS_W") )
+        if ( !_stricmp(v35, "TTsect_NS_W") )
         {
           v55 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v55 |= 8u;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_EW_N") )
+        if ( !_stricmp(v35, "TTsect_EW_N") )
         {
           v56 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v56 |= 9u;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_EW_S") )
+        if ( !_stricmp(v35, "TTsect_EW_S") )
         {
           v57 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v57 |= 0xAu;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_NCAP") )
+        if ( !_stricmp(v35, "TTsect_NCAP") )
         {
           v58 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v58 |= 0xBu;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_ECAP") )
+        if ( !_stricmp(v35, "TTsect_ECAP") )
         {
 LABEL_130:
           v59 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v59 |= 0xCu;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_SCAP") )
+        if ( !_stricmp(v35, "TTsect_SCAP") )
         {
           v60 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v60 |= 0xDu;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_WCAP") )
+        if ( !_stricmp(v35, "TTsect_WCAP") )
         {
 LABEL_134:
           v61 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v61 |= 0xEu;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_DN") )
+        if ( !_stricmp(v35, "TTsect_DN") )
         {
           v62 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v62 |= 0xFu;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_DS") )
+        if ( !_stricmp(v35, "TTsect_DS") )
         {
 LABEL_138:
           v63 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v63 |= 0x10u;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_DW") )
+        if ( !_stricmp(v35, "TTsect_DW") )
         {
 LABEL_140:
           v64 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v64 |= 0x11u;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_DE") )
+        if ( !_stricmp(v35, "TTsect_DE") )
         {
 LABEL_142:
           v65 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v65 |= 0x12u;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_DSW") )
+        if ( !_stricmp(v35, "TTsect_DSW") )
         {
 LABEL_144:
           v66 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v66 |= 0x13u;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_DNE") )
+        if ( !_stricmp(v35, "TTsect_DNE") )
         {
 LABEL_146:
           v67 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v67 |= 0x14u;
           goto LABEL_151;
         }
-        if ( !_strcmpi(v35, "TTsect_DSE") )
+        if ( !_stricmp(v35, "TTsect_DSE") )
         {
           v68 = (int)&v2->pTiles[v2->sNumTiles].uSection;
           *(char *)v68 |= 0x15u;
           goto LABEL_151;
         }
-        if ( _strcmpi(v35, "TTsect_DNW") )
+        if ( _stricmp(v35, "TTsect_DNW") )
           goto LABEL_152;
       }
     }
--- a/UIBooks.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/UIBooks.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -320,11 +320,11 @@
   static const char *texNames[9] = // 004E24EC
   {
     "SBFB00", "SBAB00", "SBWB00", "SBEB00",
-    "SBSB00", "SBMB00", "SBBB00", "SBLB00",
+    "SBSB00", "SBMB00", "SBBB00", "SBLB00", "SBDB00"
   };
 
   pTexture_506444 = pIcons_LOD->LoadTexturePtr("ib-m6-d",TEXTURE_16BIT_PALETTE);
-  for (uint i = 0; i < 8; ++i)
+  for (uint i = 0; i < 9; ++i)
   {
     pSpellBookPagesTextr[i] = pIcons_LOD->LoadTexturePtr(texNames[i], TEXTURE_16BIT_PALETTE);
 
@@ -432,7 +432,7 @@
   pTexture_pagemask->Release();
   pTexture_506448->Release();
   pTexture_50643C->Release();
-  for (uint i = 0; i < 8; ++i)
+  for (uint i = 0; i < 9; ++i)
       {
       pSpellBookPagesTextr[i]->Release();
       pTextures_tabs[i][0]->Release();
@@ -1662,6 +1662,12 @@
   POINT v24;
   int v25;
 
+  static unsigned int texture_tab_coord1[9][2]=
+      {{406, 9}, {406, 46}, {406, 84}, {406,121}, {407,158}, {405, 196}, {405, 234}, {405, 272}, {405,309} };
+
+  static unsigned int texture_tab_coord0[9][2]=
+      {{415, 10}, {415, 46}, {415, 83}, {415,121}, {415,158}, {416, 196}, {416, 234}, {416, 271}, {416,307} };
+
   BookUI_Spellbook_DrawCurrentSchoolBackground();
 
   //v0 = pPlayers[uActiveCharacter];
@@ -1706,7 +1712,7 @@
       }
       ++v4;
     }
-    while ( v4 + v1 - 1 < v1 + 11 );
+    while ( v4 - 1 < 11 );
   }
 
 
@@ -1740,90 +1746,14 @@
       if ( player->lastOpenedSpellbookPage == v13 )
       {
         pPageTexture = pTextures_tabs[v13][1];
-        switch ( v13 )
-        {
-          case 0:
-            v14 = 406;
-            v22 = 9;
-            goto LABEL_27;
-          case 1:
-            v14 = 406;
-            goto LABEL_38;
-          case 2:
-            v14 = 406;
-            v22 = 84;
-            goto LABEL_27;
-          case 3:
-            v14 = 406;
-            goto LABEL_26;
-          case 4:
-            v14 = 407;
-            goto LABEL_29;
-          case 5:
-            v15 = 196;
-            goto LABEL_34;
-          case 6:
-            v15 = 234;
-            goto LABEL_34;
-          case 7:
-            v15 = 272;
-            goto LABEL_34;
-          case 8:
-            v15 = 309;
-LABEL_34:
-            v14 = 405;
-            break;
-          default:
-            break;
-        }
+       v14=texture_tab_coord1[v13][0];
+       v15=texture_tab_coord1[v13][1];
       }
       else
       {
         pPageTexture = pTextures_tabs[v13][0];
-        switch ( v13 )
-        {
-          case 0:
-            v14 = 415;
-            v22 = 10;
-            goto LABEL_27;
-          case 1:
-            v14 = 415;
-LABEL_38:
-            v22 = 46;
-            goto LABEL_27;
-          case 2:
-            v14 = 415;
-            v22 = 83;
-            goto LABEL_27;
-          case 3:
-            v14 = 415;
-LABEL_26:
-            v22 = 121;
-LABEL_27:
-            v15 = v22;
-            break;
-          case 4:
-            v14 = 415;
-LABEL_29:
-            v15 = 158;
-            break;
-          case 5:
-            v15 = 196;
-            goto LABEL_46;
-          case 6:
-            v15 = 234;
-            goto LABEL_46;
-          case 7:
-            v15 = 271;
-            goto LABEL_46;
-          case 8:
-            v15 = 307;
-LABEL_46:
-            v14 = 416;
-            break;
-          default:
-            break;
-        }
+        v14=texture_tab_coord0[v13][0];
+        v15=texture_tab_coord0[v13][1];
       }
       pRenderer->DrawTextureTransparent(v14, v15, pPageTexture);
       v13 = v25;
--- a/UICharacter.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/UICharacter.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -1,5 +1,7 @@
 #include <assert.h>
 
+#include <algorithm> 
+
 #include "MM7.h"
 
 #include "MapInfo.h"
@@ -71,6 +73,201 @@
 unsigned int ui_book_journal_text_color;
 unsigned int ui_book_journal_text_shadow;
 
+unsigned int papredoll_dbrds[16];
+unsigned int papredoll_drhs[4];
+unsigned int papredoll_dlhus[4];
+unsigned int papredoll_dlhs[4];
+unsigned int papredoll_dbods[5];
+int paperdoll_armor_texture[4][17][3];
+//int paperdoll_array_51132C[165];
+unsigned int papredoll_dlaus[5];
+unsigned int papredoll_dlads[4];
+int papredoll_flying_feet[777]; // idb
+int paperdoll_boots_texture[4][6];//0x511638
+int paperdoll_cloak_collar_texture[4][10]; // weak
+int paperdoll_cloak_texture[4][10];
+int paperdoll_helm_texture[2][16]; //511698
+int paperdoll_belt_texture[2][7];  //511718
+
+
+const int paperdoll_Weapon[4][16][2] = {//4E4C30
+    {{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}},
+    };
+
+
+
+const int paperdoll_Boot[4][7][2] = //4E5490
+    {
+    0xE, 0x11D,    0xD, 0x11D,    0xC, 0x10A,    0xA, 0xFF,    0xD, 0xF9,    0xD, 0x137,   0xC, 0x10E,
+    0x14, 0x125,   0x13, 0x122,   0x15, 0x120,   0x15, 0x114,  0x13, 0x10A,  0x11, 0x13E,  0x11, 0x116,
+    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,
+    };
+const 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,
+    };
+const 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,
+    0, 0,        0x30, 0x87,  0x1E, 0x86,  0x1B, 0x86,  0x1C, 0x8A,  0x21, 0x87,  0x30, 0x87,  0x1E, 0x86,  0x1B, 0x86,  0x1C, 0x8A,
+    0, 0,        0x38, 0x8A,  0x24, 0x8B,  0x1D, 0x8B,  0x21, 0x8C,  0x27, 0x8A,  0x34, 0x8A,  0x24, 0x8B,  0x25, 0x8B,  0x21, 0x8C,
+    };
+//int dword_4E56B4; // weak
+const 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,
+    };
+const 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,
+    };
+const int pPaperdoll_Beards[4] = //4E5AD0
+    {
+    52, 130, 56, 136,
+    };
+const int pPaperdoll_LeftHand[4][2] = //4E5AE0
+    {
+    0x67, 0x6A,
+    0x65, 0x6C,
+    0x74, 0x8D,
+    0x74, 0x93,
+    };
+const int pPaperdoll_SecondLeftHand[4][2] = //4E5B00
+    {
+    0x1A, 0x6B,
+    0x28, 0x6D,
+    0x19, 0x8D,
+    0x20, 0x92,
+    };
+const int pPaperdoll_RightHand[4][2] = //4E5B20
+    {
+    0x1E, 0x90,
+    0x22, 0x9E,
+    0x19, 0xBA,
+    0x1F, 0xB8,
+    };
+const int pPaperdollLeftEmptyHand[4][2] = //4E5B40
+    {
+    0x80, 0xCD,
+    0x83, 0xC9,
+    0x83, 0xD8,
+    0x7B, 0xD8,
+    };
+
+int pPaperdoll_BodyX = 481; // 004E4C28
+int pPaperdoll_BodyY = 0;   // 004E4C2C
+const 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
+    0x0A, 0x66,  0x13, 0x64,  0x0E, 0x64,  0x0A, 0x63,  0x14, 0x66,  0x0A, 0x63,  0x0A, 0x66,  0x25, 0x66,
+
+    0x32, 0x68,  0x32, 0x69,  0x35, 0x69,  0x33, 0x68,  0x24, 0x67,  0x30, 0x69,  0x33, 0x68,  0x31, 0x69,  0x19, 0x69,
+    0x19, 0x6A,  0x16, 0x66,  0x16, 0x65,  0x0F, 0x6B,  0x24, 0x67,  0x0F, 0x6B,  0x19, 0x6A,  0x31, 0x69,
+
+    0x2A, 0x8C,  0x29, 0x8C,  0x2A, 0x89,  0x29, 0x86,  0x12, 0x87,  0x2D, 0x89,  0x2A, 0x88,  0x25, 0x87,  0x12, 0x8B,
+    0x12, 0x8B,  0x11, 0x8A,  0x15, 0x87,  0x09, 0x89,  0x12, 0x87,  0x09, 0x89,  0x12, 0x8B,  0x25, 0x87,
+
+    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,
+    };
+const 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,
+
+    0x60, 0x6B,  0x60, 0x6C,  0x60, 0x6B,  0x61, 0x6A,  0x60, 0x69,  0x60, 0x6A,  0x60, 0x6A,  0x61, 0x69,  0x63, 0x6A,
+    0x64, 0x6A,  0x61, 0x66,  0x66, 0x67,  0x64, 0x6C,  0x60, 0x69,  0x64, 0x6C,  0x64, 0x6A,  0x61, 0x69,
+
+    0x6D, 0x8C,  0x75, 0x8C,  0, 0,        0x72, 0x8D,  0x6A, 0x89,  0, 0,        0x73, 0x8C,  0x69, 0x8C,  0x6E, 0x8D,
+    0x71, 0x8D,  0x70, 0x8D,  0x72, 0x8D,  0x74, 0x8E,  0x6A, 0x89,  0x74, 0x8E,  0x71, 0x8D,  0x69, 0x8C,
+
+    0x72, 0x91,  0x72, 0x91,  0, 0,        0x6E, 0x92,  0x6F, 0x91,  0, 0,        0, 0,        0x6E, 0x91,  0x71, 0x90,
+    0x72, 0x8D,  0x72, 0x90,  0x73, 0x93,  0x73, 0x90,  0x6F, 0x91,  0x73, 0x90,  0x72, 0x8D,  0x6E, 0x91,
+    };
+const int dword_4E5270[4][2] = 
+    {
+    0, 0,
+    0x61, 0x67,
+    0, 0,
+    0x64, 0x69,
+    };
+
+const char *dlad_texnames_by_face[25] =
+    {
+    "pc01lad", "pc02lad", "pc03lad", "pc04lad", "pc05lad", "pc06lad",
+    "pc07lad", "pc08lad", "pc09lad", "pc10lad", "pc11lad", "pc12lad",
+    "pc13lad", "pc14lad", "pc15lad", "pc16lad", "pc17lad", "pc18lad",
+    "pc19lad", "pc20lad", "pc21lad", "pc22lad", "pc23lad", "pc24lad",
+    "pc25lad"
+    };
+const char *dlau_texnames_by_face[25] =
+    {
+    "pc01lau", "pc02lau", "pc03lau", "pc04lau", "pc05lau", "pc06lau",
+    "pc07lau", "pc08lau", "pc09lau", "pc10lau", "pc11lau", "pc12lau",
+    "pc13lau", "pc14lau", "pc15lau", "pc16lau", "pc17lau", "pc18lau",
+    "pc19lau", "pc20lau", "pc21lau", "pc22lau", "pc23lau", "pc24lau",
+    "pc25lau"
+    };
+const char *dbod_texnames_by_face[25] =
+    {
+    "pc01bod", "pc02bod", "pc03bod", "pc04bod", "pc05bod", "pc06bod",
+    "pc07bod", "pc08bod", "pc09bod", "pc10bod", "pc11bod", "pc12bod",
+    "pc13bod", "pc14bod", "pc15bod", "pc16bod", "pc17bod", "pc18bod",
+    "pc19bod", "pc20bod", "pc21bod", "pc22bod", "pc23bod", "pc24bod",
+    "pc25bod"
+    };
+const char *drh_texnames_by_face[25] =
+    {
+
+    "pc01rh", "pc02rh", "pc03rh", "pc04rh", "pc05rh", "pc06rh",
+    "pc07rh", "pc08rh", "pc09rh", "pc10rh", "pc11rh", "pc12rh",
+    "pc13rh", "pc14rh", "pc15rh", "pc16rh", "pc17rh", "pc18rh",
+    "pc19rh", "pc20rh", "pc21rh", "pc22rh", "pc23rh", "pc24rh",
+    "pc25rh"
+    };
+const char *dlh_texnames_by_face[25] =
+    {
+    "pc01lh", "pc02lh", "pc03lh", "pc04lh", "pc05lh", "pc06lh",
+    "pc07lh", "pc08lh", "pc09lh", "pc10lh", "pc11lh", "pc12lh",
+    "pc13lh", "pc14lh", "pc15lh", "pc16lh", "pc17lh", "pc18lh",
+    "pc19lh", "pc20lh", "pc21lh", "pc22lh", "pc23lh", "pc24lh",
+    "pc25lh"
+    };
+const char *dlhu_texnames_by_face[25] =
+    {
+    "pc01lhu", "pc02lhu", "pc03lhu", "pc04lhu", "pc05lhu", "pc06lhu",
+    "pc07lhu", "pc08lhu", "pc09lhu", "pc10lhu", "pc11lhu", "pc12lhu",
+    "pc13lhu", "pc14lhu", "pc15lhu", "pc16lhu", "pc17lhu", "pc18lhu",
+    "pc19lhu", "pc20lhu", "pc21lhu", "pc22lhu", "pc23lhu", "pc24lhu",
+    "pc25lhu"
+    };
+
+const  int pArmorSkills[5]  = {PLAYER_SKILL_LEATHER, PLAYER_SKILL_CHAIN,      PLAYER_SKILL_PLATE,        PLAYER_SKILL_SHIELD,  PLAYER_SKILL_DODGE};
+const int pWeaponSkills[9] = {PLAYER_SKILL_AXE,     PLAYER_SKILL_BOW,        PLAYER_SKILL_DAGGER,       PLAYER_SKILL_MACE,    PLAYER_SKILL_SPEAR,      
+    PLAYER_SKILL_STAFF,    PLAYER_SKILL_SWORD,       PLAYER_SKILL_UNARMED,    PLAYER_SKILL_BLASTER};
+const  int pMiscSkills[12]  = {PLAYER_SKILL_ALCHEMY, PLAYER_SKILL_ARMSMASTER, PLAYER_SKILL_BODYBUILDING, PLAYER_SKILL_ITEM_ID, PLAYER_SKILL_MONSTER_ID, 
+    PLAYER_SKILL_LEARNING, PLAYER_SKILL_TRAP_DISARM, PLAYER_SKILL_MEDITATION, PLAYER_SKILL_MERCHANT, PLAYER_SKILL_PERCEPTION,
+    PLAYER_SKILL_REPAIR, PLAYER_SKILL_STEALING};
+const  int pMagicSkills[9]  = {PLAYER_SKILL_FIRE,    PLAYER_SKILL_AIR,        PLAYER_SKILL_WATER,        PLAYER_SKILL_EARTH,   PLAYER_SKILL_SPIRIT,    
+    PLAYER_SKILL_MIND,     PLAYER_SKILL_BODY,        PLAYER_SKILL_LIGHT,      PLAYER_SKILL_DARK};
+
+
+
 
 void set_default_ui_skin()
 {
@@ -244,7 +441,7 @@
 
 
 
-static int CharacterUI_SkillsTab_Draw__DrawSkillTable(Player *player, int x, int y, int *skill_list, int skill_list_size, int right_margin, const char *skill_group_name)
+static int CharacterUI_SkillsTab_Draw__DrawSkillTable(Player *player, int x, int y, const int *skill_list, int skill_list_size, int right_margin, const char *skill_group_name)
 {
   int y_offset = y;
   
@@ -295,20 +492,19 @@
       }
       else
       {
-        const char *v46 = nullptr;
+        const char *skill_level_str = nullptr;
 
         switch (SkillToMastery(skill_value))
         {
-          case 4: v46 = pGlobalTXT_LocalizationStrings[96];  break; // "Grand"
-          case 3: v46 = pGlobalTXT_LocalizationStrings[432]; break; // Master
-          case 2: v46 = pGlobalTXT_LocalizationStrings[433]; break; // Expert
+          case 4: skill_level_str = pGlobalTXT_LocalizationStrings[96];  break; // "Grand"
+          case 3: skill_level_str = pGlobalTXT_LocalizationStrings[432]; break; // Master
+          case 2: skill_level_str = pGlobalTXT_LocalizationStrings[433]; break; // Expert
         }
 
         if (!skill_mastery_color)
           skill_mastery_color = ui_character_header_text_color;
 
-        
-        sprintfex(pTmpBuf, "%s \f%05d%s\f%05d\r%03d%2d", pSkillNames[skill], skill_mastery_color, v46, skill_color, right_margin, skill_level);
+        sprintfex(pTmpBuf, "%s \f%05d%s\f%05d\r%03d%2d", pSkillNames[skill], skill_mastery_color, skill_level_str, skill_color, right_margin, skill_level);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, x, v8->uY, skill_color, pTmpBuf, 0, 0, 0);
       }
     }
@@ -507,7 +703,7 @@
     break;
 
     case WINDOW_CharacterWindow_Skills:                                // skills
-      if (dword_507CC0 != uActiveCharacter)
+      if (dword_507CC0_activ_ch != uActiveCharacter)
       {
         CharacterUI_ReleaseButtons();
         CharacterUI_SkillsTab_CreateButtons();
@@ -834,19 +1030,19 @@
       item_Cloak = &pPlayers[uPlayerID]->pInventoryItems[pCloakNum - 1];
       switch ( item_Cloak->uItemID )
       {
-        case 525:
+        case ITEM_RELIC_TWILIGHT:
           v33 = 5;
           break;
-        case 530:
+        case ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP:
           v33 = 6;
           break;
-        case 547:
+        case ITEM_RARE_SUN_CLOAK:
           v33 = 7;
           break;
-        case 548:
+        case ITEM_RARE_MOON_CLOAK:
           v33 = 8;
           break;
-        case 550:
+        case ITEM_RARE_VAMPIRES_CAPE:
           v33 = 9;
           break;
         default:
@@ -902,13 +1098,13 @@
         case 504:
           v45 = 15;
           break;
-        case 505:
+        case ITEM_ARTIFACT_YORUBA:
           v45 = 14;
           break;
-        case 516:
+        case ITEM_RELIC_HARECS_LEATHER:
           v45 = 13;
           break;
-        case 533:
+        case ITEM_ELVEN_CHAINMAIL:
           v45 = 16;
           break;
         default:
@@ -992,13 +1188,13 @@
             {
               if ( item_Armor->uAttributes & 0xF0 )
               {
-                if ( (item_Armor->uAttributes & 0xF0) == 16 )
+                if ( (item_Armor->uAttributes & 0xF0) == ITEM_AURA_EFFECT_RED )
                   v173 = "sptext01";
-                if ( (item_Armor->uAttributes & 0xF0) == 32 )
+                if ( (item_Armor->uAttributes & 0xF0) == ITEM_AURA_EFFECT_BLUE )
                   v173 = "sp28a";
-                if ( ( item_Armor->uAttributes & 0xF0) == 64 )
+                if ( ( item_Armor->uAttributes & 0xF0) == ITEM_AURA_EFFECT_GREEN )
                   v173 = "sp30a";
-                if ( (item_Armor->uAttributes & 0xF0) == 128 )
+                if ( (item_Armor->uAttributes & 0xF0) == ITEM_AURA_EFFECT_PURPLE )
                   v173 = "sp91a";
                 v96 = (char *)pIcons_LOD->LoadTexturePtr(v173, TEXTURE_16BIT_PALETTE);
                 _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
@@ -1136,10 +1332,10 @@
           item_Belt = &pPlayers[uPlayerID]->pInventoryItems[pBeltNum - 1];
         switch ( item_Belt->uItemID )
         {
-          case 524:
+          case ITEM_RILIC_TITANS_BELT:
             v73 = 5;
             break;
-          case 535:
+          case ITEM_ARTIFACT_HEROS_BELT:
             v73 = 6;
             break;
           default:
@@ -1919,121 +2115,94 @@
 
 //----- (00419401) --------------------------------------------------------
 void CharacterUI_SkillsTab_CreateButtons()
-{
-    unsigned int v0; // ecx@3
+    {
+    // unsigned int v0; // ecx@3
     GUIButton *pButton; // eax@3
-    GUIFont *v2; // eax@8
-    unsigned int v3; // esi@8
-    int v4; // eax@10
-    unsigned int v5; // esi@14
-    int v6; // eax@17
-    unsigned int v7; // esi@19
-    int v8; // eax@21
-    unsigned int v9; // esi@25
-    int v10; // eax@27
-    int a2; // [sp+10h] [bp-14h]@1
-    int v12; // [sp+14h] [bp-10h]@8
-    int v13; // [sp+14h] [bp-10h]@19
-    int *v14; // [sp+18h] [bp-Ch]@8
-    int *v15; // [sp+18h] [bp-Ch]@14
-    int *v16; // [sp+18h] [bp-Ch]@19
-    int *v17; // [sp+18h] [bp-Ch]@25
-    Player *v18; // [sp+1Ch] [bp-8h]@8
-    int a5; // [sp+20h] [bp-4h]@8
+    unsigned int current_Y; // esi@8
+    int buttons_count; // [sp+10h] [bp-14h]@1
+    int first_rows; // [sp+14h] [bp-10h]@19
+    int skill_id; // [sp+18h] [bp-Ch]@8
+    Player *curr_player; // [sp+1Ch] [bp-8h]@8
+    int i;
+    int uCurrFontHeght;
 
-    a2 = 0;
-    if ( dword_507CC0 )
+    buttons_count = 0;
+    if ( dword_507CC0_activ_ch )
         CharacterUI_ReleaseButtons();
-    v0 = uActiveCharacter;
-    dword_507CC0 = uActiveCharacter;
+    dword_507CC0_activ_ch = uActiveCharacter;
     for ( pButton = pGUIWindow_CurrentMenu->pControlsHead; pButton; pButton = pButton->pNext )
-    {
+        {
         if ( pButton->msg == UIMSG_InventoryLeftClick )
-        {
-            dword_50698C = pButton->uX;
-            dword_506988 = pButton->uY;
-            dword_506984 = pButton->uZ;
-            dword_506980 = pButton->uW;
+            {
+            dword_50698C_uX = pButton->uX;
+            dword_506988_uY = pButton->uY;
+            dword_506984_uZ = pButton->uZ;
+            dword_506980_uW = pButton->uW;
             pButton->uW = 0;
             pButton->uZ = 0;
             pButton->uY = 0;
             pButton->uX = 0;
-            v0 = uActiveCharacter;
+            }
+        }
+    first_rows = 0;
+    //  a5 = pGUIWindow_CurrentMenu->uNumControls;
+    curr_player = &pParty->pPlayers[uActiveCharacter-1];
+
+    uCurrFontHeght=pFontLucida->uFontHeight;
+    current_Y = 2 *uCurrFontHeght  + 13;
+    for(i=0; i<9;++i)
+        {
+        skill_id = pWeaponSkills[i];
+        if ( curr_player->pActiveSkills[skill_id] & 0x3F )
+            {
+            current_Y += uCurrFontHeght - 3;
+            ++buttons_count;
+            ++first_rows;
+            pGUIWindow_CurrentMenu->CreateButton(24, current_Y, 204, uCurrFontHeght - 3, 3, skill_id | 0x8000, UIMSG_SkillUp, skill_id, 0, "", 0, 0);
             }
         }
-    v12 = 0;
-    a5 = pGUIWindow_CurrentMenu->uNumControls;
-    v18 = &pParty->pPlayers[v0-1];
-    v2 = pFontLucida;
-    v14 = pWeaponSkills;
-    v3 = 2 * LOBYTE(pFontLucida->uFontHeight) + 13;
-    do
+    if ( !first_rows )
+        current_Y += uCurrFontHeght - 3;        
+    current_Y += 2 * uCurrFontHeght - 6;
+    for(i=0; i<9;++i)       
         {
-        if ( v18->pActiveSkills[*v14] & 0x3F )//crash
+        skill_id = pMagicSkills[i];
+        if ( curr_player->pActiveSkills[skill_id] & 0x3F && buttons_count < 15 )
             {
-            v4 = LOBYTE(v2->uFontHeight);
-            v3 = v3 + v4 - 3;
-            ++a2;
-            ++v12;
-            pGUIWindow_CurrentMenu->CreateButton(0x18u, v3, 0xCCu, v4 - 3, 3, *v14 | 0x8000, UIMSG_SkillUp, *v14, 0, "", 0, 0);
-            v2 = pFontLucida;
-            }
-        ++v14;
-        }
-        while ( v14 <= &pWeaponSkills[8] );
-        if ( !v12 )
-            v3 = v3 + LOBYTE(v2->uFontHeight) - 3;
-        v15 = pMagicSkills;
-        v5 = v3 + 2 * LOBYTE(v2->uFontHeight) - 6;
-        do
-            {
-            if ( v18->pActiveSkills[*v15] & 0x3F && a2 < 15 )
-                {
-                v6 = LOBYTE(v2->uFontHeight);
-                v5 = v5 + v6 - 3;
-                ++a2;
-                pGUIWindow_CurrentMenu->CreateButton(0x18u, v5, 0xCCu, v6 - 3, 3, *v15 | 0x8000, UIMSG_SkillUp, *v15, 0, "", 0, 0);
-                v2 = pFontLucida;
-                }
-            ++v15;
+            current_Y += uCurrFontHeght - 3;
+            ++buttons_count;
+            pGUIWindow_CurrentMenu->CreateButton(24, current_Y, 204, uCurrFontHeght - 3, 3, skill_id | 0x8000, UIMSG_SkillUp, skill_id, 0, "", 0, 0);
             }
-            while ( v15 <= &pMagicSkills[8] );
-            v13 = 0;
-            v16 = pArmorSkills;
-            v7 = 2 * LOBYTE(v2->uFontHeight) + 13;
-            do
-                {
-                if ( v18->pActiveSkills[*v16] & 0x3F )
-                    {
-                    v8 = LOBYTE(v2->uFontHeight);
-                    v7 = v7 + v8 - 3;
-                    ++a2;
-                    ++v13;
-                    pGUIWindow_CurrentMenu->CreateButton(0xF6u, v7, 0xCCu, v8 - 3, 3, *v16 | 0x8000, UIMSG_SkillUp, *v16, 0, "", 0, 0);
-                    v2 = pFontLucida;
-                    }
-                ++v16;
-                }
-                while ( v16 <= &pArmorSkills[4] );
-                if ( !v13 )
-                    v7 = v7 + LOBYTE(v2->uFontHeight) - 3;
-                v17 = pMiscSkills;
-                v9 = v7 + 2 * LOBYTE(v2->uFontHeight) - 6;
-                do
-                    {
-                    if ( v18->pActiveSkills[*v17] & 0x3F )
-                        {
-                        v10 = LOBYTE(v2->uFontHeight);
-                        v9 = v9 + v10 - 3;
-                        ++a2;
-                        pGUIWindow_CurrentMenu->CreateButton(0xF6u, v9, 0xCCu, v10 - 3, 3, *v17 | 0x8000, UIMSG_SkillUp, *v17, 0, "", 0, 0);
-                        v2 = pFontLucida;
-                        }
-                    ++v17;
-                    }
-                    while ( v17 <= &pMiscSkills[11] );
-                    if ( a2 )
-                        pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(a2, 1, 0, a5);
+        }
+    first_rows = 0;      
+    current_Y = 2 * uCurrFontHeght + 13;
+    for(i=0; i<5;++i) 
+        {
+        skill_id = pArmorSkills[i];
+        if ( curr_player->pActiveSkills[skill_id] & 0x3F )
+            {
+            current_Y+= uCurrFontHeght - 3;
+            ++buttons_count;
+            ++first_rows;
+            pGUIWindow_CurrentMenu->CreateButton(246, current_Y, 204, uCurrFontHeght - 3, 3, skill_id | 0x8000, UIMSG_SkillUp, skill_id, 0, "", 0, 0);
+            }
+        }
+    if ( !first_rows )
+        current_Y += uCurrFontHeght - 3;           
+    current_Y += 2 * uCurrFontHeght - 6;
+    for(i=0; i<12; ++i)
+        {
+        skill_id = pMiscSkills[i];
+        if ( curr_player->pActiveSkills[skill_id] & 0x3F )
+            {
+            current_Y += uCurrFontHeght - 3;
+            ++buttons_count;
+            pGUIWindow_CurrentMenu->CreateButton(246, current_Y, 204, uCurrFontHeght - 3, 3, skill_id | 0x8000, UIMSG_SkillUp, skill_id, 0, "", 0, 0);
+            }
+        }
+
+    if ( buttons_count )
+        pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(buttons_count, 1, 0, pGUIWindow_CurrentMenu->uNumControls);
     }
 
 
@@ -2336,6 +2505,59 @@
         pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
 }
 
+//Award sort stuff. Should be removed after changing the award container to something other than array
+template<class Cont>
+typename Cont::iterator begin(Cont& c){
+    return c.begin();
+}
+
+template<class Cont>
+typename Cont::iterator end(Cont& c){
+    return c.end();
+}
+
+// overloads for C style arrays
+template<class T, std::size_t N>
+T* begin(T (&arr)[N]){
+    return &arr[0];
+}
+
+template<class T, std::size_t N>
+T* end(T (&arr)[N]){
+    return arr + N;
+}
+
+bool awardSort (int i,int j) { 
+    if (pAwards[i].uPriority == 0)  //none
+    {
+        return false;
+    }
+    else if (pAwards[j].uPriority == 0)
+    {
+        return true;
+    }
+    else if(pAwards[i].uPriority == 1)  //fines,arena stuff,etc
+    {
+        return false;
+    }
+    else if(pAwards[j].uPriority == 1)
+    {
+        return true;
+    }
+    else if(pAwards[i].uPriority == 5) //joined guilds
+    {
+        return false;
+    }
+    else if(pAwards[j].uPriority == 5)
+    {
+        return true;
+    }
+    else
+    {
+        return (pAwards[i].uPriority<pAwards[j].uPriority);
+    }
+}
+
 //----- (00419100) --------------------------------------------------------
 void FillAwardsData()
 {
@@ -2352,7 +2574,9 @@
         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;
@@ -2360,20 +2584,69 @@
         //sort awards index 
         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);
+            std::stable_sort(begin(achieved_awards), end(achieved_awards), awardSort);
+        }
+    }
+
 
-            for(int i=1; i<num_achieved_awards_2-1; ++i)
-                {
-                for (int j = i; j < num_achieved_awards_2-1; ++j )
-                    {
-                    auto tmp=achieved_awards[j];
-                    if (pAwards[j].uPriority < pAwards[i].uPriority)
-                        {
-                        achieved_awards[j] = achieved_awards[i];
-                        achieved_awards[i] = tmp;
-                        }
-                    }
-                }
+//----- (0043EF2B) --------------------------------------------------------
+void WetsuitOn( unsigned int uPlayerID )
+    { 
+    CHARACTER_RACE player_race; // edi@2
+    signed int player_sex; // eax@2
+    int texture_num; // ecx@5
+    char pContainer[20]; // [sp+4h] [bp-1Ch]@7
+ 
+    if ( uPlayerID> 0 )
+        {
+        player_race = pPlayers[uPlayerID]->GetRace();
+        player_sex = pPlayers[uPlayerID]->GetSexByVoice();
+        if ( player_race == CHARACTER_RACE_DWARF  )
+            texture_num = (player_sex != 0) + 3;
+        else 
+            texture_num = (player_sex != 0) + 1;
+        wsprintfA(pContainer, "pc23v%dBod", texture_num);
+        papredoll_dbods[uPlayerID - 1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+        wsprintfA(pContainer, "pc23v%dlad", texture_num);
+        papredoll_dlads[uPlayerID - 1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+        wsprintfA(pContainer, "pc23v%dlau", texture_num);
+        papredoll_dlaus[uPlayerID - 1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+        wsprintfA(pContainer, "pc23v%drh", texture_num);
+        papredoll_drhs[uPlayerID - 1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+        wsprintfA(pContainer, "pc23v%dlh", texture_num);
+        papredoll_dlhs[uPlayerID - 1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+        wsprintfA(pContainer, "pc23v%dlhu", texture_num);
+        papredoll_dlhus[uPlayerID - 1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+
+        if ( pPlayers[uPlayerID]->uCurrentFace == 12 || pPlayers[uPlayerID]->uCurrentFace == 13 )
+            papredoll_dbrds[pPlayers[uPlayerID]->uCurrentFace] = 0;
+
+        papredoll_flying_feet[pPlayers[uPlayerID]->uCurrentFace] = 0;
+        IsPlayerWearingWatersuit[uPlayerID] = 1;
+        }
+    }
+
+//----- (0043F0BD) --------------------------------------------------------
+void WetsuitOff( unsigned int uPlayerID )
+    {
+    char pContainer[20]; // [sp+0h] [bp-18h]@4
+
+    if (uPlayerID > 0 )
+        {
+        papredoll_dbods[uPlayerID - 1] = pIcons_LOD->LoadTexture(dbod_texnames_by_face[pPlayers[uPlayerID]->uCurrentFace], TEXTURE_16BIT_PALETTE);
+        papredoll_dlads[uPlayerID - 1] = pIcons_LOD->LoadTexture(dlad_texnames_by_face[pPlayers[uPlayerID]->uCurrentFace], TEXTURE_16BIT_PALETTE);
+        papredoll_dlaus[uPlayerID - 1] = pIcons_LOD->LoadTexture(dlau_texnames_by_face[pPlayers[uPlayerID]->uCurrentFace], TEXTURE_16BIT_PALETTE);
+        papredoll_drhs [uPlayerID - 1] = pIcons_LOD->LoadTexture(drh_texnames_by_face [pPlayers[uPlayerID]->uCurrentFace], TEXTURE_16BIT_PALETTE);
+        papredoll_dlhs [uPlayerID - 1] = pIcons_LOD->LoadTexture(dlh_texnames_by_face [pPlayers[uPlayerID]->uCurrentFace], TEXTURE_16BIT_PALETTE);
+        papredoll_dlhus[uPlayerID - 1] = pIcons_LOD->LoadTexture(dlhu_texnames_by_face[pPlayers[uPlayerID]->uCurrentFace], TEXTURE_16BIT_PALETTE);
+
+        if ( pPlayers[uPlayerID]->uCurrentFace == 12 || pPlayers[uPlayerID]->uCurrentFace == 13 )
+            {
+            wsprintfA(pContainer, "pc%02dbrd", pPlayers[uPlayerID]->uCurrentFace + 1);
+            papredoll_dbrds[pPlayers[uPlayerID]->uCurrentFace] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
             }
+        wsprintfA(pContainer, "item281pc%02d", pPlayers[uPlayerID]->uCurrentFace + 1);
+        papredoll_flying_feet[pPlayers[uPlayerID]->uCurrentFace] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+        IsPlayerWearingWatersuit[uPlayerID] = 0;
         }
+    }
--- a/UIHouses.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/UIHouses.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -1893,7 +1893,7 @@
       v5 = &transport_schedule[transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][dialog_menu_id - HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1]];
       if ( v5->pSchedule[pParty->uDaysPlayed % 7] )
       {
-        if ( _strcmpi(pCurrentMapName, pMapStats->pInfos[v5->uMapInfoID].pFilename) )
+        if ( _stricmp(pCurrentMapName, pMapStats->pInfos[v5->uMapInfoID].pFilename) )
         {
           SaveGame(1, 0);
           strcpy(pCurrentMapName, pMapStats->pInfos[v5->uMapInfoID].pFilename);
@@ -2471,7 +2471,7 @@
       pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
       v36 = LOBYTE(pFontArrus->uFontHeight) - 3;
       v37 = -pDialogueWindow->pNumPresenceButton < 0;
-      if ( !(v37 ^ pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton) )
+      if ( !(v37 ^ (pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton)) )
       {
         do
         {
@@ -2883,7 +2883,7 @@
         pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
         v19 = (174 - 4 * (174 - all_text_height) / 4 - all_text_height) / 2 - (174 - all_text_height) / 4 / 2 + 138;
         v20 = -pDialogueWindow->pNumPresenceButton < 0;
-        if ( v20 ^ pNumActiveItem > pNumActiveItem + pDialogueWindow->pNumPresenceButton )
+        if ( v20 ^ (pNumActiveItem > pNumActiveItem + pDialogueWindow->pNumPresenceButton ))
         {
           pItemNum = 2;
           pNumString = 0;
@@ -3079,7 +3079,7 @@
       pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
       v70 = (3 * (58 - (signed int)v103) - all_text_height) / 2 - ((174 - all_text_height) / 3) / 2 + 138;
       v20 = -pDialogueWindow->pNumPresenceButton < 0;
-      if ( v20 ^ pNumActiveItem > pNumActiveItem + pDialogueWindow->pNumPresenceButton )
+      if ( v20 ^ (pNumActiveItem > pNumActiveItem + pDialogueWindow->pNumPresenceButton ))
       {
         pItemNum = 2;
         pNumString = 0;
@@ -3413,7 +3413,7 @@
         v76 = pNumActiveItem + pDialogueWindow->pNumPresenceButton;
         v77 = (174 - 4 * (174 - all_text_height) / 4 - all_text_height) / 2 - (174 - all_text_height) / 4 / 2 + 138;
         v28 = -pDialogueWindow->pNumPresenceButton < 0;
-        if ( v28 ^ pNumActiveItem > v76 )
+        if ( v28 ^ (pNumActiveItem > v76) )
         {
           pItemNum = 2;
           pNumString = 0;
@@ -3613,7 +3613,7 @@
       v26 = pNumActiveItem + pDialogueWindow->pNumPresenceButton;
       v27 = (2 * (87 - (174 - all_text_height) / 2) - all_text_height) / 2 - (174 - all_text_height) / 2 / 2 + 138;
       v28 = -pDialogueWindow->pNumPresenceButton < 0;
-      if ( v28 ^ pNumActiveItem > v26 )
+      if ( v28 ^ (pNumActiveItem > v26) )
       {
         pItemNum = 2;
         pNumString = 0;
@@ -4167,7 +4167,7 @@
       v86 = (3 * (58 - v152) - all_text_height) / 2 - v152 / 2 + 138;
       v24 = -pDialogueWindow->pNumPresenceButton < 0;
       pActiveButton = pDialogueWindow->pStartingPosActiveItem;
-      if ( v24 ^ pDialogueWindow->pStartingPosActiveItem > pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton )
+      if ( v24 ^ (pDialogueWindow->pStartingPosActiveItem > pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton) )
       {
         pNumString = 0;
         do
@@ -5897,7 +5897,7 @@
     v81 = (3 * (58 - (signed int)_this) - all_text_height) / 2 - (174 - all_text_height) / 3 / 2 + 138;
     v20 = -pDialogueWindow->pNumPresenceButton < 0;
     v118 = pDialogueWindow->pStartingPosActiveItem;
-    if ( v20 ^ pDialogueWindow->pStartingPosActiveItem > pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton )
+    if ( v20 ^ (pDialogueWindow->pStartingPosActiveItem > pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton) )
     {
       v122 = 2;
       pSrtingNum = 0;
--- a/UIPopup.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/UIPopup.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -1996,6 +1996,7 @@
                             {
                             pAudioPlayer->StopChannels(-1, -1);
                             v3 = (void *)1;
+                            GameUI_DrawNPCPopup(v3);
                             }
                         }
                     else
--- a/UIRest.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/UIRest.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -87,7 +87,7 @@
         --uRestUI_FoodRequiredToRest;
     if ( uRestUI_FoodRequiredToRest < 1 )
         uRestUI_FoodRequiredToRest = 1;
-    if ( !_strcmpi(pCurrentMapName, "d29.blv") && _449B57_test_bit(pParty->_quest_bits, 98) )
+    if ( !_stricmp(pCurrentMapName, "d29.blv") && _449B57_test_bit(pParty->_quest_bits, 98) )
         uRestUI_FoodRequiredToRest = 0;
 
     ++pIcons_LOD->uTexturePacksCount;
--- a/UISaveLoad.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/UISaveLoad.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -330,7 +330,7 @@
         v4 = pLODFile.FindContainer("header.bin", true);
         if ( v4 )
             fread(&pSavegameHeader[i], 0x64, 1, v4);
-        if ( !_strcmpi(pSavegameList->pFileList[i].pSaveFileName, pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7"
+        if ( !_stricmp(pSavegameList->pFileList[i].pSaveFileName, pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7"
             strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[16]);// "Autosave"
         v5 = pLODFile.FindContainer("image.pcx", true);
         if ( !v5 )
--- a/UiGame.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/UiGame.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -262,7 +262,7 @@
     if ( (signed int)((char *)v17 + (unsigned __int8)pParty->field_709) < v1 )
     {
       sDialogue_SpeakingActorNPC_ID = -1 - (unsigned __int8)pParty->field_709 - (int)v17;
-      v5 = GetNewNPCData(sDialogue_SpeakingActorNPC_ID, (int)&a2);
+      v5 = GetNewNPCData(sDialogue_SpeakingActorNPC_ID, &a2);
       v6 = v5;
       if ( v5 )
       {
@@ -925,7 +925,7 @@
                 v15 = v14;
                 if ( v14 )
                 {
-                  if ( _strcmpi(v14, "") )
+                  if ( _stricmp(v14, "") )
                     v21 = (char *)v15;
                 }
               }
@@ -2557,7 +2557,7 @@
         v11 = pOutline->uFlags;
         if ( v11 & 1 )
           goto LABEL_15;
-        if (pFace1->uAttributes & 0x80 || pFace2->uAttributes & 0x80u != 0 )
+        if (pFace1->uAttributes & 0x80 || pFace2->uAttributes & 0x80)
           goto LABEL_ABC;
 
       }
@@ -2904,7 +2904,7 @@
           else
           {
             v20 = 0;
-            while ( _strcmpi("spell96", pIconsFrameTable->pIcons[v20 / 0x20].pAnimationName) )
+            while ( _stricmp("spell96", pIconsFrameTable->pIcons[v20 / 0x20].pAnimationName) )
             {
               ++v21;
               v20 += 32;
--- a/VideoPlayer.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/VideoPlayer.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -908,7 +908,7 @@
   {
 	for ( v3 = 0; v3 < (signed int)pVideoPlayer->uNumMightVideoHeaders; ++v3)
     {
-      v4 = _strcmpi(pVideoPlayer->pMightVideoHeaders[v3].pVideoName, pFilename);
+      v4 = _stricmp(pVideoPlayer->pMightVideoHeaders[v3].pVideoName, pFilename);
 	  if ( !v4 )
 	  {
 	    SetFilePointer(pVideoPlayer->hMightVid, pVideoPlayer->pMightVideoHeaders[v3].uFileOffset, 0, 0);
@@ -919,7 +919,7 @@
   v5 = 0;
   if ( (signed int)pVideoPlayer->uNumMagicVideoHeaders > 0 )
   {
-    while ( _strcmpi(pVideoPlayer->pMagicVideoHeaders[v5].pVideoName, pFilename) )
+    while ( _stricmp(pVideoPlayer->pMagicVideoHeaders[v5].pVideoName, pFilename) )
     {
       ++v5;
       if ( v5 >= (signed int)pVideoPlayer->uNumMagicVideoHeaders )
--- a/Vis.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/Vis.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -486,7 +486,7 @@
   Vis *thisa; // [sp+68h] [bp-8h]@1
   RenderVertexSoft *v15; // [sp+6Ch] [bp-4h]@2
 
-  result = a4;
+  result = a4 != 0;
   thisa = this;
   if ( a4 > a3 )
   {
@@ -636,7 +636,7 @@
   {
     if ( v16 >= 2 )
       break;
-    if ( v6 ^ intersect_face_vertex_coords_list_b[i + 1] >= b )
+    if ( v6 ^ (intersect_face_vertex_coords_list_b[i + 1] >= b) )
     {
       if ( intersect_face_vertex_coords_list_a[i + 1] >= a )
         v10 = 0;
--- a/Vis.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/Vis.h	Sat Jun 01 10:32:31 2013 +0600
@@ -81,8 +81,9 @@
 
 /*  116 */
 #pragma pack(push, 1)
-struct Vis
+class Vis
 {
+public:
   Vis();
   //----- (004C05A2) --------------------------------------------------------
   //virtual ~Vis() {}
--- a/mm7_1.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/mm7_1.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -35,6 +35,7 @@
 #include "texts.h"
 #include "UIHouses.h"
 #include "mm7_data.h"
+#include "stru367.h"
 
 int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam);
 int __stdcall InsertMM7CDDialogFunc(HWND hDlg, int a2, __int16 a3, int a4);
@@ -66,9 +67,9 @@
   GUIButton *i; // esi@2
   GUIButton *j; // esi@7
 
-  if ( dword_507CC0 )
+  if ( dword_507CC0_activ_ch )
   {
-    dword_507CC0 = 0;
+    dword_507CC0_activ_ch = 0;
     for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = j )
     {
 	  j=i->pNext;
@@ -82,10 +83,10 @@
     {
       if ( j->msg == UIMSG_InventoryLeftClick)
       {
-        j->uX = dword_50698C;
-        j->uY = dword_506988;
-        j->uZ = dword_506984;
-        j->uW = dword_506980;
+        j->uX = dword_50698C_uX;
+        j->uY = dword_506988_uY;
+        j->uZ = dword_506984_uZ;
+        j->uW = dword_506980_uW;
         pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(1, 0, 0, 0);
       }
     }
@@ -295,49 +296,49 @@
         return true;
       }
       case VK_NEXT:
-      {
-        if ( pWindowList[v3].field_30 != 0 )
-        {
-          pMouse->GetClickPos(&uClickX, &uClickY);
-          v4 = pWindowList[v3].pStartingPosActiveItem;
-          v29 = v4 + pWindowList[v3].pNumPresenceButton;
-          if ( v4 < v4 + pWindowList[v3].pNumPresenceButton )
-          {
-            while ( 1 )
-            {
-              pButton = pWindowList[v3].pControlsHead;
-              if ( v4 > 0 )
-              {
-                v15 = v4;
-                do
-                {
-                  pButton = pButton->pNext;
-                  --v15;
-                }
-                while ( v15 );
-              }
-              if ( (signed int)uClickX >= (signed int)pButton->uX
-                && (signed int)uClickX <= (signed int)pButton->uZ
-                && (signed int)uClickY >= (signed int)pButton->uY
-                && (signed int)uClickY <= (signed int)pButton->uW )
-              {
-                pWindowList[v3].pCurrentPosActiveItem = v4;
-                return true;
-              }
-              ++v4;
-              if ( v4 >= v29 )
-              {
-                //v1 = 0;
-                //v2 = pMessageQueue_50CBD0->uNumMessages;
-                break;
-              }
-            }
-          }
-          else
-          {
-            //v2 = pMessageQueue_50CBD0->uNumMessages;
-          }
-        }
+      {  
+        //if ( pWindowList[v3].field_30 != 0 )   //crashed at skill draw
+        //{
+        //  pMouse->GetClickPos(&uClickX, &uClickY);
+        //  v4 = pWindowList[v3].pStartingPosActiveItem;
+        //  v29 = v4 + pWindowList[v3].pNumPresenceButton; //num buttons more than buttons 
+        //  if ( v4 < v29 )
+        //  {
+        //    while ( 1 )
+        //    {
+        //      pButton = pWindowList[v3].pControlsHead;
+        //      if ( v4 > 0 )
+        //      {
+        //        v15 = v4;
+        //        do
+        //        {
+        //          pButton = pButton->pNext;
+        //          --v15;
+        //        }
+        //        while ( v15 );
+        //      }
+        //      if ( (signed int)uClickX >= (signed int)pButton->uX
+        //        && (signed int)uClickX <= (signed int)pButton->uZ
+        //        && (signed int)uClickY >= (signed int)pButton->uY
+        //        && (signed int)uClickY <= (signed int)pButton->uW )
+        //      {
+        //        pWindowList[v3].pCurrentPosActiveItem = v4;
+        //        return true;
+        //      }
+        //      ++v4;
+        //      if ( v4 >= v29 )
+        //      {
+        //        //v1 = 0;
+        //        //v2 = pMessageQueue_50CBD0->uNumMessages;
+        //        break;
+        //      }
+        //    }
+        //  }
+        //  else
+        //  {
+        //    //v2 = pMessageQueue_50CBD0->uNumMessages;
+        //  }
+        //}
         break;
       }
       default:
@@ -384,7 +385,7 @@
     v10 = pGlobalTXT_LocalizationStrings[57];   // Days
     if ( v19 <= 1 )
       v10 = pGlobalTXT_LocalizationStrings[56]; // Day
-    sprintfex(pTmpBuf2, "%d %s ", v19, v10);
+    sprintfex(pTmpBuf2, "%d %s ", (int)v19, v10);
     strcat(pTmpBuf, pTmpBuf2);
   }
   if ( v9 )
@@ -393,7 +394,7 @@
       v11 = pGlobalTXT_LocalizationStrings[109];// Hour
     else
       v11 = pGlobalTXT_LocalizationStrings[110];// Hours
-    sprintfex(pTmpBuf2, "%d %s ", v9, v11);
+    sprintfex(pTmpBuf2, "%d %s ", (int)v9, v11);
     strcat(pTmpBuf, pTmpBuf2);
   }
   if ( v17 && !v19 )
@@ -402,7 +403,7 @@
       v12 = pGlobalTXT_LocalizationStrings[437];// Minute
     else
       v12 = pGlobalTXT_LocalizationStrings[436];// Minutes
-    sprintfex(pTmpBuf2, "%d %s ", v17, v12);
+    sprintfex(pTmpBuf2, "%d %s ", (int)v17, v12);
     strcat(pTmpBuf, pTmpBuf2);
   }
   if ( v18 && !v9 )
@@ -411,7 +412,7 @@
       v13 = pGlobalTXT_LocalizationStrings[439];// Second
     else
       v13 = pGlobalTXT_LocalizationStrings[438];// Seconds
-    sprintfex(pTmpBuf2, "%d %s ", v18, v13);
+    sprintfex(pTmpBuf2, "%d %s ", (int)v18, v13);
     strcat(pTmpBuf, pTmpBuf2);
   }
   a1->DrawText(a2, 32, uY, 0, pTmpBuf, 0, 0, 0);
@@ -894,11 +895,11 @@
   //POINT v25; // [sp+7Ch] [bp-10h]@3
   POINT a2; // [sp+84h] [bp-8h]@3
 
+  v1 = pMouse->GetCursorPos(&a2);
   if ( pRenderer->pRenderD3D )
     v0 = pGame->pVisInstance->get_picked_object_zbuf_val();
   else
   {
-    v1 = pMouse->GetCursorPos(&a2);
     v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[v1->y]];
   }
 
@@ -1582,11 +1583,11 @@
      + v1->pFacePlane_old.vNormal.y * (v2->y - pBLVRenderParams->vPartyPos.y)
      + v1->pFacePlane_old.vNormal.z * (v2->z - pBLVRenderParams->vPartyPos.z) < 0 )
   {
-    dword_50B700 = 1;
+    stru_50B700.field_0 = 1;
   }
   else
   {
-    dword_50B700 = 0;
+    stru_50B700.field_0 = 0;
     if ( !v1->Portal() )
       return 0;
   }
@@ -1598,9 +1599,9 @@
         v6->x,
         v6->y,
         v6->z,
-        &_50B924_view_transformed_xs[i],
-        &_50B834_view_transformed_zs[i],
-        &_50B744_view_transformed_ys[i],
+        &stru_50B700._view_transformed_xs[i],
+        &stru_50B700._view_transformed_zs[i],
+        &stru_50B700._view_transformed_ys[i],
         0);
   }
 
@@ -1611,7 +1612,7 @@
 
   bool bFound = false;
   for (uint i = 0; i < v1->uNumVertices; ++i)
-    if (_50B924_view_transformed_xs[i] >= 0x80000u)
+    if (stru_50B700._view_transformed_xs[i] >= 0x80000u)
     {
       bFound = true;
       break;
@@ -1620,27 +1621,27 @@
     return 0;
 
   v79 = 0;
-  _50B924_view_transformed_xs[v1->uNumVertices] = _50B924_view_transformed_xs[0];
-  _50B834_view_transformed_zs[v1->uNumVertices] = _50B834_view_transformed_zs[0];
-  _50B744_view_transformed_ys[v1->uNumVertices] = _50B744_view_transformed_ys[0];
-  thisa = _50B924_view_transformed_xs[0] >= (signed int)0x80000u;
+  stru_50B700._view_transformed_xs[v1->uNumVertices] = stru_50B700._view_transformed_xs[0];
+  stru_50B700._view_transformed_zs[v1->uNumVertices] = stru_50B700._view_transformed_zs[0];
+  stru_50B700._view_transformed_ys[v1->uNumVertices] = stru_50B700._view_transformed_ys[0];
+  thisa = stru_50B700._view_transformed_xs[0] >= (signed int)0x80000u;
   //int i = 1;
   for (uint i = 1; i <= v1->uNumVertices; ++i)
   {
-      v10 = _50B924_view_transformed_xs[i];
+      v10 = stru_50B700._view_transformed_xs[i];
       v81 = v10 >= (signed int)0x80000u;
       if ( thisa ^ v81 )
       {
-        v11 = _50B924_view_transformed_xs[i - 1];
+        v11 = stru_50B700._view_transformed_xs[i - 1];
         if ( v10 >= (signed int)0x80000u )
         {
           v12 = v10 - v11;
           v13 = 0x80000 - v11;
           LODWORD(v14) = v13 << 16;
           HIDWORD(v14) = v13 >> 16;
-          v15 = &_50B744_view_transformed_ys[i - 1];
-          dword_50B828[v79] = ((unsigned __int64)((_50B834_view_transformed_zs[i] - _50B834_view_transformed_zs[i - 1]) * v14 / v12) >> 16) + _50B834_view_transformed_zs[i - 1];
-          thisb = (unsigned __int64)((_50B744_view_transformed_ys[i] - _50B744_view_transformed_ys[i - 1]) * v14 / v12) >> 16;
+          v15 = &stru_50B700._view_transformed_ys[i - 1];
+          stru_50B700.field_128[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i] - stru_50B700._view_transformed_zs[i - 1]) * v14 / v12) >> 16) + stru_50B700._view_transformed_zs[i - 1];
+          thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[i] - stru_50B700._view_transformed_ys[i - 1]) * v14 / v12) >> 16;
         }
         else
         {
@@ -1648,93 +1649,93 @@
           v17 = 0x80000 - v10;
           LODWORD(v18) = v17 << 16;
           HIDWORD(v18) = v17 >> 16;
-          v15 = &_50B744_view_transformed_ys[i];
-          dword_50B828[v79] = ((unsigned __int64)((_50B834_view_transformed_zs[i - 1] - _50B834_view_transformed_zs[i]) * v18 / v16) >> 16) + _50B834_view_transformed_zs[i];
-          thisb = (unsigned __int64)((_50B744_view_transformed_ys[i - 1] - _50B744_view_transformed_ys[i]) * v18 / v16) >> 16;
+          v15 = &stru_50B700._view_transformed_ys[i];
+          stru_50B700.field_128[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i - 1] - stru_50B700._view_transformed_zs[i]) * v18 / v16) >> 16) + stru_50B700._view_transformed_zs[i];
+          thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[i - 1] - stru_50B700._view_transformed_ys[i]) * v18 / v16) >> 16;
         }
         v19 = v79++;
         //v7 = v66;
-        dword_50B738[v19] = thisb + *v15;
-        dword_50B918[v19] = 0x80000u;
+        stru_50B700.field_38[v19] = thisb + *v15;
+        stru_50B700.field_218[v19] = 0x80000u;
       }
       if ( v81 )
       {
         v20 = v79++;
-        dword_50B918[v20] = _50B924_view_transformed_xs[i];
-        dword_50B828[v20] = _50B834_view_transformed_zs[i];
-        dword_50B738[v20] = _50B744_view_transformed_ys[i];
+        stru_50B700.field_218[v20] = stru_50B700._view_transformed_xs[i];
+        stru_50B700.field_128[v20] = stru_50B700._view_transformed_zs[i];
+        stru_50B700.field_38[v20] = stru_50B700._view_transformed_ys[i];
       }
       //++i;
       thisa = v81;
   }
   v21 = v79;
-  dword_50B918[v79] = dword_50B918[0];
-  dword_50B828[v79] = dword_50B828[0];
-  dword_50B738[v79] = dword_50B738[0];
+  stru_50B700.field_218[v79] = stru_50B700.field_218[0];
+  stru_50B700.field_128[v79] = stru_50B700.field_128[0];
+  stru_50B700.field_38[v79] = stru_50B700.field_38[0];
   for (ia = 0; ia < v79; ++ia)
   {
     v22 = ia;
-    thisc = abs(dword_50B918[ia]);
-    if ( abs(dword_50B828[ia]) >> 13 <= thisc )
+    thisc = abs(stru_50B700.field_218[ia]);
+    if ( abs(stru_50B700.field_128[ia]) >> 13 <= thisc )
     {
-      v27 = dword_50B828[v22];
+      v27 = stru_50B700.field_128[v22];
       LODWORD(v28) = v27 << 16;
       HIDWORD(v28) = v27 >> 16;
-      v26 = v28 / dword_50B918[v22];
+      v26 = v28 / stru_50B700.field_218[v22];
       v23 = 0;
     }
     else
     {
       v23 = 0;
       v24 = 0;
-      if ( dword_50B828[v22] >= 0 )
+      if ( stru_50B700.field_128[v22] >= 0 )
       {
-        LOBYTE(v24) = dword_50B918[v22] >= 0;
+        LOBYTE(v24) = stru_50B700.field_218[v22] >= 0;
         v26 = ((v24 - 1) & 0xFF800000) + 0x400000;
       }
       else
       {
-        LOBYTE(v24) = dword_50B918[v22] >= 0;
+        LOBYTE(v24) = stru_50B700.field_218[v22] >= 0;
         v25 = v24 - 1;
         v26 = (v25 & 0x800000) - 0x400000;
       }
     }
-    v29 = dword_50B738[v22];
-    dword_50BAF8_xs[v22] = v26;
+    v29 = stru_50B700.field_38[v22];
+    stru_50B700._xs3[v22] = v26;
     if ( abs(v29) >> 13 <= thisc )
     {
-      v33 = dword_50B738[v22];
+      v33 = stru_50B700.field_38[v22];
       LODWORD(v34) = v33 << 16;
       HIDWORD(v34) = v33 >> 16;
-      v32 = v34 / dword_50B918[v22];
+      v32 = v34 / stru_50B700.field_218[v22];
     }
     else
     {
       v30 = 0;
-      if ( dword_50B738[v22] >= v23 )
+      if ( stru_50B700.field_38[v22] >= v23 )
       {
-        LOBYTE(v30) = dword_50B918[v22] >= v23;
+        LOBYTE(v30) = stru_50B700.field_218[v22] >= v23;
         v32 = ((v30 - 1) & 0xFF800000) + 0x400000;
       }
       else
       {
-        LOBYTE(v30) = dword_50B918[v22] >= v23;
+        LOBYTE(v30) = stru_50B700.field_218[v22] >= v23;
         v31 = v30 - 1;
         v32 = (v31 & 0x800000) - 0x400000;
       }
     }
-    dword_50BA08_ys[v22] = v32;
-    dword_50BAF8_xs[v22] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BAF8_xs[v22]) >> 16;
-    v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BA08_ys[v22]) >> 16;
-    dword_50BAF8_xs[v22] = pBLVRenderParams->uViewportCenterX - dword_50BAF8_xs[v22];
-    dword_50BA08_ys[v22] = pBLVRenderParams->uViewportCenterY - v35;
+    stru_50B700._ys2[v22] = v32;
+    stru_50B700._xs3[v22] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)stru_50B700._xs3[v22]) >> 16;
+    v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)stru_50B700._ys2[v22]) >> 16;
+    stru_50B700._xs3[v22] = pBLVRenderParams->uViewportCenterX - stru_50B700._xs3[v22];
+    stru_50B700._ys2[v22] = pBLVRenderParams->uViewportCenterY - v35;
   }
   v36 = 0;
-  dword_50BAF8_xs[v21] = dword_50BAF8_xs[0];
-  dword_50BA08_ys[v21] = dword_50BA08_ys[0];
+  stru_50B700._xs3[v21] = stru_50B700._xs3[0];
+  stru_50B700._ys2[v21] = stru_50B700._ys2[0];
   v37 = pBLVRenderParams->uViewportX;
-  v38 = dword_50BAF8_xs[0] < (signed int)pBLVRenderParams->uViewportX;
-  LOBYTE(v38) = dword_50BAF8_xs[0] >= (signed int)pBLVRenderParams->uViewportX;
+  v38 = stru_50B700._xs3[0] < (signed int)pBLVRenderParams->uViewportX;
+  LOBYTE(v38) = stru_50B700._xs3[0] >= (signed int)pBLVRenderParams->uViewportX;
   v39 = 1;
   ib = 1;
   if ( v79 < 1 )
@@ -1742,30 +1743,30 @@
   do
   {
     v40 = v39;
-    v41 = dword_50BAF8_xs[v40];
+    v41 = stru_50B700._xs3[v40];
     v82 = v41 >= (signed int)v37;
     if ( v38 ^ v82 )
     {
       if ( v41 >= (signed int)v37 )
       {
-        v67 = (signed int)(v37 - dword_50BAF8_xs[v40 - 1]) * (signed __int64)(dword_50BA08_ys[v40] - dword_50BA08_ys[v40 - 1]) / (v41 - dword_50BAF8_xs[v40 - 1]);
-        v42 = dword_50BA08_ys[v40 - 1];
+        v67 = (signed int)(v37 - stru_50B700._xs3[v40 - 1]) * (signed __int64)(stru_50B700._ys2[v40] - stru_50B700._ys2[v40 - 1]) / (v41 - stru_50B700._xs3[v40 - 1]);
+        v42 = stru_50B700._ys2[v40 - 1];
       }
       else
       {
-        v67 = (signed int)(v37 - v41) * (signed __int64)(dword_50BA08_ys[v40 - 1] - dword_50BA08_ys[v40]) / (dword_50BAF8_xs[v40 - 1] - v41);
-        v42 = dword_50BA08_ys[v40];
+        v67 = (signed int)(v37 - v41) * (signed __int64)(stru_50B700._ys2[v40 - 1] - stru_50B700._ys2[v40]) / (stru_50B700._xs3[v40 - 1] - v41);
+        v42 = stru_50B700._ys2[v40];
       }
-      dword_50B9FC_ys[v36] = v67 + v42;
+      stru_50B700._ys[v36] = v67 + v42;
       v37 = pBLVRenderParams->uViewportX;
-      dword_50BAEC_xs[v36] = pBLVRenderParams->uViewportX;
+      stru_50B700._xs2[v36] = pBLVRenderParams->uViewportX;
       ++v36;
     }
     v38 = v82;
     if ( v82 )
     {
-      dword_50BAEC_xs[v36] = dword_50BAF8_xs[v40];
-      dword_50B9FC_ys[v36] = dword_50BA08_ys[v40];
+      stru_50B700._xs2[v36] = stru_50B700._xs3[v40];
+      stru_50B700._ys[v36] = stru_50B700._ys2[v40];
       ++v36;
     }
     v39 = ib++ + 1;
@@ -1776,38 +1777,38 @@
     return 0;
 
   v43 = 0;
-  dword_50BAEC_xs[v36] = dword_50BAEC_xs[0];
-  dword_50B9FC_ys[v36] = dword_50B9FC_ys[0];
+  stru_50B700._xs2[v36] = stru_50B700._xs2[0];
+  stru_50B700._ys[v36] = stru_50B700._ys[0];
   v44 = pBLVRenderParams->uViewportZ;
-  thisd = dword_50BAEC_xs[0] <= (signed int)pBLVRenderParams->uViewportZ;
+  thisd = stru_50B700._xs2[0] <= (signed int)pBLVRenderParams->uViewportZ;
   ic = 1;
 
   do
   {
     v45 = ic;
-    v46 = dword_50BAEC_xs[ic];
+    v46 = stru_50B700._xs2[ic];
     v83 = v46 <= (signed int)v44;
     if ( thisd ^ v83 )
     {
       if ( v46 <= (signed int)v44 )
       {
-        v68 = (signed int)(v44 - dword_50BAEC_xs[v45 - 1]) * (signed __int64)(dword_50B9FC_ys[v45] - dword_50B9FC_ys[v45 - 1]) / (v46 - dword_50BAEC_xs[v45 - 1]);
-        v47 = dword_50B9FC_ys[v45 - 1];
+        v68 = (signed int)(v44 - stru_50B700._xs2[v45 - 1]) * (signed __int64)(stru_50B700._ys[v45] - stru_50B700._ys[v45 - 1]) / (v46 - stru_50B700._xs2[v45 - 1]);
+        v47 = stru_50B700._ys[v45 - 1];
       }
       else
       {
-        v68 = (signed int)(v44 - v46) * (signed __int64)(dword_50B9FC_ys[v45 - 1] - dword_50B9FC_ys[v45]) / (dword_50BAEC_xs[v45 - 1] - v46);
-        v47 = dword_50B9FC_ys[v45];
+        v68 = (signed int)(v44 - v46) * (signed __int64)(stru_50B700._ys[v45 - 1] - stru_50B700._ys[v45]) / (stru_50B700._xs2[v45 - 1] - v46);
+        v47 = stru_50B700._ys[v45];
       }
-      dword_50B9F0[v43] = v68 + v47;
+      stru_50B700.field_2F0[v43] = v68 + v47;
       v44 = pBLVRenderParams->uViewportZ;
-      dword_50BAE0[v43] = pBLVRenderParams->uViewportZ;
+      stru_50B700._xs[v43] = pBLVRenderParams->uViewportZ;
       ++v43;
     }
     if ( v83 )
     {
-      dword_50BAE0[v43] = dword_50BAEC_xs[v45];
-      dword_50B9F0[v43++] = dword_50B9FC_ys[v45];
+      stru_50B700._xs[v43] = stru_50B700._xs2[v45];
+      stru_50B700.field_2F0[v43++] = stru_50B700._ys[v45];
     }
     ++ic;
     thisd = v83;
@@ -1818,40 +1819,41 @@
     return 0;
 
   v48 = 0;
-  dword_50BAE0[v43] = dword_50BAE0[0];
-  dword_50B9F0[v43] = dword_50B9F0[0];
+  stru_50B700._xs[v43] = stru_50B700._xs[0];
+  stru_50B700.field_2F0[v43] = stru_50B700.field_2F0[0];
   v49 = pBLVRenderParams->uViewportY;
-  v50 = dword_50B9F0[0] < (signed int)pBLVRenderParams->uViewportY;
-  LOBYTE(v50) = dword_50B9F0[0] >= (signed int)pBLVRenderParams->uViewportY;
+  v50 = stru_50B700.field_2F0[0] < (signed int)pBLVRenderParams->uViewportY;
+  LOBYTE(v50) = stru_50B700.field_2F0[0] >= (signed int)pBLVRenderParams->uViewportY;
   v51 = 1;
   id = 1;
   do
   {
     v52 = v51;
-    v53 = dword_50B9F0[v52];
+    v53 = stru_50B700.field_2F0[v52];
     v84 = v53 >= (signed int)v49;
     if ( v50 ^ v84 )
     {
       if ( v53 >= (signed int)v49 )
       {
-        v69 = (signed int)(v49 - dword_50B9F0[v52 - 1]) * (signed __int64)(dword_50BAE0[v52] - dword_50BAE0[v52 - 1]) / (v53 - dword_50B9F0[v52 - 1]);
-        v54 = dword_50BAE0[v52 - 1];
+        v69 = (signed int)(v49 - stru_50B700.field_2F0[v52 - 1]) * (signed __int64)(stru_50B700._xs[v52] - stru_50B700._xs[v52 - 1]) / (v53 - stru_50B700.field_2F0[v52 - 1]);
+        v54 = stru_50B700._xs[v52 - 1];
       }
       else
       {
-        v69 = (signed int)(v49 - v53) * (signed __int64)(dword_50BAE0[v52 - 1] - dword_50BAE0[v52]) / (dword_50B9F0[v52 - 1] - v53);
-        v54 = dword_50BAE0[v52];
+        v69 = (signed int)(v49 - v53) * (signed __int64)(stru_50B700._xs[v52 - 1] - stru_50B700._xs[v52]) / (stru_50B700.field_2F0[v52 - 1] - v53);
+        v54 = stru_50B700._xs[v52];
       }
-      dword_50BAD4[v48] = v69 + v54;
+      stru_50B700.field_3D4[v48] = v69 + v54;
       v49 = pBLVRenderParams->uViewportY;
-      dword_50B9E4[v48] = pBLVRenderParams->uViewportY;
+      stru_50B700._xs[v48+1] = pBLVRenderParams->uViewportY;
       ++v48;
     }
     v50 = v84;
     if ( v84 )
     {
-      dword_50BAD4[v48] = dword_50BAE0[v52];
-      dword_50B9E4[v48++] = dword_50B9F0[v52];
+      stru_50B700.field_3D4[v48] = stru_50B700._xs[v52];
+      stru_50B700._xs[v48+1] = stru_50B700.field_2F0[v52];
+	  v48++;
     }
     v51 = id++ + 1;
   }
@@ -1861,37 +1863,37 @@
     return 0;
 
   v55 = 0;
-  dword_50BAD4[v48] = dword_50BAD4[0];
-  dword_50B9E4[v48] = dword_50B9E4[0];
+  stru_50B700.field_3D4[v48] = stru_50B700.field_3D4[0];
+  stru_50B700._xs[v48+1] = stru_50B700._xs[1];
   v56 = pBLVRenderParams->uViewportW;
-  thise = dword_50B9E4[0] <= (signed int)pBLVRenderParams->uViewportW;
+  thise = stru_50B700._xs[1] <= (signed int)pBLVRenderParams->uViewportW;
   ie = 1;
   do
   {
     v57 = ie;
-    v58 = dword_50B9E4[ie];
+    v58 = stru_50B700._xs[ie+1];
     v85 = v58 <= (signed int)v56;
     if ( thise ^ v85 )
     {
       if ( v58 <= (signed int)v56 )
       {
-        v70 = (signed int)(v56 - dword_50B9E4[v57 - 1]) * (signed __int64)(dword_50BAD4[v57] - dword_50BAD4[v57 - 1]) / (v58 - dword_50B9E4[v57 - 1]);
-        v59 = dword_50BAD4[v57 - 1];
+        v70 = (signed int)(v56 - stru_50B700._xs[v57]) * (signed __int64)(stru_50B700.field_3D4[v57] - stru_50B700.field_3D4[v57 - 1]) / (v58 - stru_50B700._xs[v57]);
+        v59 = stru_50B700.field_3D4[v57 - 1];
       }
       else
       {
-        v70 = (signed int)(v56 - v58) * (signed __int64)(dword_50BAD4[v57 - 1] - dword_50BAD4[v57]) / (dword_50B9E4[v57 - 1] - v58);
-        v59 = dword_50BAD4[v57];
+        v70 = (signed int)(v56 - v58) * (signed __int64)(stru_50B700.field_3D4[v57 - 1] - stru_50B700.field_3D4[v57]) / (stru_50B700._xs[v57] - v58);
+        v59 = stru_50B700.field_3D4[v57];
       }
-      _50BAC8_screen_space_x[v55] = v70 + v59;
+      stru_50B700._screen_space_x[v55] = v70 + v59;
       v56 = pBLVRenderParams->uViewportW;
-      _50B9D8_screen_space_y[v55] = pBLVRenderParams->uViewportW;
+      stru_50B700._screen_space_y[v55] = pBLVRenderParams->uViewportW;
       ++v55;
     }
     if ( v85 )
     {
-      _50BAC8_screen_space_x[v55] = dword_50BAD4[v57];
-      _50B9D8_screen_space_y[v55++] = dword_50B9E4[v57];
+      stru_50B700._screen_space_x[v55] = stru_50B700.field_3D4[v57];
+      stru_50B700._screen_space_y[v55++] = stru_50B700._xs[v57+1];
     }
     ++ie;
     thise = v85;
@@ -1901,13 +1903,13 @@
   if ( !v55 )
     return 0;
   v61 = pRenderer->pRenderD3D == 0;
-  _50BAC8_screen_space_x[v55] = _50BAC8_screen_space_x[0];
-  _50B9D8_screen_space_y[v55] = _50B9D8_screen_space_y[0];
+  stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0];
+  stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0];
   if ( v61 && v55 > 3 )
   {
-    _50BAC8_screen_space_x[v55 + 1] = _50BAC8_screen_space_x[1];
-    _50B9D8_screen_space_y[v55 + 1] = _50B9D8_screen_space_y[1];
-    thisf = 2 * (dword_50B700 != 0) - 1;
+    stru_50B700._screen_space_x[v55 + 1] = stru_50B700._screen_space_x[1];
+    stru_50B700._screen_space_y[v55 + 1] = stru_50B700._screen_space_y[1];
+    thisf = 2 * (stru_50B700.field_0 != 0) - 1;
     if ( v55 > 0 )
     {
       v62 = 1;
@@ -1924,8 +1926,8 @@
         if ( v64 >= v55 )
           v64 -= v55;
         if ( thisf
-           * ((_50B9D8_screen_space_y[v64] - _50B9D8_screen_space_y[v63]) * (_50BAC8_screen_space_x[v62] - _50BAC8_screen_space_x[v63])
-            - (_50B9D8_screen_space_y[v62] - _50B9D8_screen_space_y[v63]) * (_50BAC8_screen_space_x[v64] - _50BAC8_screen_space_x[v63])) < 0 )
+           * ((stru_50B700._screen_space_y[v64] - stru_50B700._screen_space_y[v63]) * (stru_50B700._screen_space_x[v62] - stru_50B700._screen_space_x[v63])
+            - (stru_50B700._screen_space_y[v62] - stru_50B700._screen_space_y[v63]) * (stru_50B700._screen_space_x[v64] - stru_50B700._screen_space_x[v63])) < 0 )
         {
           v62 = v80;
           v71 = v80;
@@ -1936,16 +1938,16 @@
           v65 = v71;
           if ( v71 < v55 || (v65 = v71 - v55, v71 - v55 < v55) )
           {
-            memcpy(&_50B9D8_screen_space_y[v65], &_50B9D8_screen_space_y[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
-            memcpy(&_50BAC8_screen_space_x[v65], &_50BAC8_screen_space_x[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
+            memcpy(&stru_50B700._screen_space_y[v65], &stru_50B700._screen_space_y[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
+            memcpy(&stru_50B700._screen_space_x[v65], &stru_50B700._screen_space_x[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
           }
           --v55;
         }
       }
       while ( v62 - 1 < v55 );
     }
-    _50BAC8_screen_space_x[v55] = _50BAC8_screen_space_x[0];
-    _50B9D8_screen_space_y[v55] = _50B9D8_screen_space_y[0];
+    stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0];
+    stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0];
   }
   return v55;
 }
@@ -1983,11 +1985,11 @@
      + v2->pFacePlane_old.vNormal.y * ((signed __int16)(*(int *)&v4->x >> 16) - pBLVRenderParams->vPartyPos.y)
      + v2->pFacePlane_old.vNormal.z * (v4->z - pBLVRenderParams->vPartyPos.z) < 0 )
   {
-    dword_50B700 = 1;
+    stru_50B700.field_0 = 1;
   }
   else
   {
-    dword_50B700 = 0;
+    stru_50B700.field_0 = 0;
     if ( !(v2->uAttributes & 1) )
       return 0;
   }
@@ -2303,24 +2305,24 @@
   v74 = a1;
   v60 = a2;
   if ( !a1
-    || (!dword_50B700 ? (v64 = -1, v6 = 1, v63 = 1) : (v6 = 1, v63 = -1, v64 = 1),
-        v7 = _50B9D8_screen_space_y[0],
+    || (!stru_50B700.field_0 ? (v64 = -1, v6 = 1, v63 = 1) : (v6 = 1, v63 = -1, v64 = 1),
+        v7 = stru_50B700._screen_space_y[0],
         v65 = 0,
-        v8 = _50B9D8_screen_space_y[0],
+        v8 = stru_50B700._screen_space_y[0],
         a1 <= v6) )
     return 0;
   do
   {
-    v9 = _50B9D8_screen_space_y[v6];
+    v9 = stru_50B700._screen_space_y[v6];
     if ( v9 >= v7 )
     {
       if ( v9 > v8 )
-        v8 = _50B9D8_screen_space_y[v6];
+        v8 = stru_50B700._screen_space_y[v6];
     }
     else
     {
       v65 = v6;
-      v7 = _50B9D8_screen_space_y[v6];
+      v7 = stru_50B700._screen_space_y[v6];
     }
     ++v6;
   }
@@ -2348,8 +2350,8 @@
       {
         v10 -= v74;
       }
-      v12 = _50B9D8_screen_space_y[v10];
-      if ( v12 <= _50B9D8_screen_space_y[v11] )
+      v12 = stru_50B700._screen_space_y[v10];
+      if ( v12 <= stru_50B700._screen_space_y[v11] )
       {
         v55 = v10;
         v11 = v10;
@@ -2374,12 +2376,12 @@
   }
   v67 = v13;
 LABEL_27:
-  if ( _50B9D8_screen_space_y[v13] != _50B9D8_screen_space_y[v55] )
+  if ( stru_50B700._screen_space_y[v13] != stru_50B700._screen_space_y[v55] )
   {
-    v14 = _50BAC8_screen_space_x[v55];
+    v14 = stru_50B700._screen_space_x[v55];
     v62 = v14 << 16;
-    v54 = ((_50BAC8_screen_space_x[v13] - v14) << 16) / (_50B9D8_screen_space_y[v13] - _50B9D8_screen_space_y[v55]);
-    v5->array_18[v7] = LOWORD(_50BAC8_screen_space_x[v55]);
+    v54 = ((stru_50B700._screen_space_x[v13] - v14) << 16) / (stru_50B700._screen_space_y[v13] - stru_50B700._screen_space_y[v55]);
+    v5->array_18[v7] = LOWORD(stru_50B700._screen_space_x[v55]);
   }
   v15 = v65;
   v69 = 0;
@@ -2399,8 +2401,8 @@
       {
         v15 -= v74;
       }
-      v17 = _50B9D8_screen_space_y[v15];
-      if ( v17 <= _50B9D8_screen_space_y[v16] )
+      v17 = stru_50B700._screen_space_y[v15];
+      if ( v17 <= stru_50B700._screen_space_y[v16] )
       {
         v61 = v15;
         v16 = v15;
@@ -2427,14 +2429,14 @@
 LABEL_44:
   v19 = v18;
   v20 = v61;
-  v53 = _50B9D8_screen_space_y[v19] - _50B9D8_screen_space_y[v61];
-  if ( _50B9D8_screen_space_y[v19] != _50B9D8_screen_space_y[v61] )
+  v53 = stru_50B700._screen_space_y[v19] - stru_50B700._screen_space_y[v61];
+  if ( stru_50B700._screen_space_y[v19] != stru_50B700._screen_space_y[v61] )
   {
-    v21 = _50BAC8_screen_space_x[v20];
+    v21 = stru_50B700._screen_space_x[v20];
     v5 = v60;
     v61 = v21 << 16;
-    v53 = ((_50BAC8_screen_space_x[v19] - v21) << 16) / v53;
-    v60->array_3D8[v73] = LOWORD(_50BAC8_screen_space_x[v20]);
+    v53 = ((stru_50B700._screen_space_x[v19] - v21) << 16) / v53;
+    v60->array_3D8[v73] = LOWORD(stru_50B700._screen_space_x[v20]);
   }
   v22 = v7;
   v70 = v7;
@@ -2445,7 +2447,7 @@
     do
     {
       v24 = v67;
-      if ( v22 < _50B9D8_screen_space_y[v67] || v22 == v73 )
+      if ( v22 < stru_50B700._screen_space_y[v67] || v22 == v73 )
         goto LABEL_57;
       v25 = v64 + v67;
       v67 = v25;
@@ -2462,16 +2464,16 @@
       v67 = v25;
 LABEL_55:
       v26 = v25;
-      v27 = _50B9D8_screen_space_y[v26] - _50B9D8_screen_space_y[v24];
-      if ( _50B9D8_screen_space_y[v26] - _50B9D8_screen_space_y[v24] > 0 )
+      v27 = stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24];
+      if ( stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24] > 0 )
       {
-        v28 = _50BAC8_screen_space_x[v24];
-        v54 = ((_50BAC8_screen_space_x[v26] - v28) << 16) / v27;
+        v28 = stru_50B700._screen_space_x[v24];
+        v54 = ((stru_50B700._screen_space_x[v26] - v28) << 16) / v27;
         v62 = v28 << 16;
       }
 LABEL_57:
       v29 = v66;
-      if ( v70 >= _50B9D8_screen_space_y[v66] && v70 != v73 )
+      if ( v70 >= stru_50B700._screen_space_y[v66] && v70 != v73 )
       {
         v30 = v63 + v66;
         v66 += v63;
@@ -2487,11 +2489,11 @@
           v66 = v30;
         }
         v31 = v30;
-        v32 = _50B9D8_screen_space_y[v31] - _50B9D8_screen_space_y[v29];
-        if ( _50B9D8_screen_space_y[v31] - _50B9D8_screen_space_y[v29] > 0 )
+        v32 = stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29];
+        if ( stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29] > 0 )
         {
-          v33 = _50BAC8_screen_space_x[v29];
-          v53 = ((_50BAC8_screen_space_x[v31] - v33) << 16) / v32;
+          v33 = stru_50B700._screen_space_x[v29];
+          v53 = ((stru_50B700._screen_space_x[v31] - v33) << 16) / v32;
           v61 = v33 << 16;
         }
       }
@@ -2611,7 +2613,7 @@
   }
   return 1;
 }
-// 50B700: using guessed type int dword_50B700;
+// 50B700: using guessed type int stru_50B700.field_0;
 
 //----- (00424CD7) --------------------------------------------------------
 signed int __fastcall sr_424CD7(unsigned int uVertexID)
--- a/mm7_2.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/mm7_2.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -2167,110 +2167,22 @@
                                             unsigned short *pDst, int dstWidth, int dstHeight, int dstPitch,
                                             int a10, int a11)
 {
-  int v11; // esi@1
   int result; // eax@1
-  int v13; // edi@8
   int v14; // ecx@10
-  double v15; // st7@11
-  double v16; // st6@11
   float v17; // ST3C_4@12
   float v18; // ST38_4@12
   unsigned int v19; // esi@12
-  int v20; // eax@16
   int v21; // eax@18
   unsigned int v22; // ecx@25
   unsigned int v23; // eax@29
-  unsigned __int16 *v24; // ecx@29
-  int v25; // edi@33
-  int v26; // ecx@35
-  double v27; // st7@36
-  double v28; // st6@36
-  float v29; // ST34_4@37
-  float v30; // ST30_4@37
-  unsigned int v31; // esi@37
-  int v32; // eax@41
-  int v33; // eax@43
-  unsigned int v34; // ecx@50
-  unsigned __int16 v35; // ax@54
-  unsigned __int16 *v36; // ecx@54
-  int v37; // edi@58
-  int v38; // ecx@60
-  double v39; // st7@61
-  double v40; // st6@61
-  float v41; // ST34_4@62
-  float v42; // ST30_4@62
-  unsigned int v43; // esi@62
-  int v44; // eax@66
-  int v45; // eax@68
-  unsigned int v46; // ecx@75
-  char v47; // al@79
-  unsigned __int16 *v48; // ecx@79
-  int v49; // edi@86
   int v50; // ecx@88
-  double v51; // st7@89
-  double v52; // st6@89
   float v53; // ST34_4@90
   float v54; // ST30_4@90
   unsigned int v55; // esi@90
-  int v56; // eax@94
   int v57; // eax@96
   unsigned int v58; // ecx@103
   unsigned int v59; // eax@107
-  unsigned __int16 *v60; // ecx@107
-  int v61; // edi@111
-  int v62; // ecx@113
-  double v63; // st7@114
-  double v64; // st6@114
-  float v65; // ST34_4@115
-  float v66; // ST30_4@115
-  unsigned int v67; // esi@115
-  int v68; // eax@119
-  int v69; // eax@121
-  unsigned int v70; // ecx@128
-  unsigned __int16 v71; // ax@132
-  unsigned __int16 *v72; // ecx@132
-  int v73; // edi@136
-  int v74; // ecx@138
-  double v75; // st7@139
-  double v76; // st6@139
-  float v77; // ST34_4@140
-  float v78; // ST30_4@140
-  unsigned int v79; // esi@140
-  int v80; // eax@144
-  int v81; // eax@146
-  unsigned int v82; // ecx@153
-  char v83; // al@157
-  unsigned __int16 *v84; // ecx@157
-  int v85; // edi@164
-  int v86; // ecx@166
-  double v87; // st7@167
-  double v88; // st6@167
-  float v89; // ST34_4@168
-  float v90; // ST30_4@168
-  unsigned int v91; // esi@168
-  signed int v92; // eax@170
-  int v93; // eax@171
-  int v94; // eax@173
-  unsigned int v95; // ecx@181
-  unsigned int v96; // eax@185
-  unsigned __int16 *v97; // ecx@185
-  int v98; // edi@189
-  int v99; // ecx@191
-  double v100; // st7@192
-  double v101; // st6@192
-  float v102; // ST34_4@193
-  float v103; // ST30_4@193
-  unsigned int v104; // esi@193
-  signed int v105; // eax@195
-  int v106; // eax@196
-  int v107; // eax@198
-  unsigned int v108; // ecx@206
-  unsigned __int16 v109; // ax@210
-  unsigned __int16 *v110; // ecx@210
-  int v111; // edi@214
   int v112; // ecx@216
-  double v113; // st7@217
-  double v114; // st6@217
   float v115; // ST34_4@218
   float v116; // ST30_4@218
   unsigned int v117; // esi@218
@@ -2279,855 +2191,275 @@
   int v120; // eax@223
   unsigned int v121; // ecx@231
   char v122; // al@235
-  unsigned __int16 *v123; // ecx@235
   double v124; // [sp+Ch] [bp-7Ch]@12
-  double v125; // [sp+Ch] [bp-7Ch]@37
-  double v126; // [sp+Ch] [bp-7Ch]@62
-  double v127; // [sp+Ch] [bp-7Ch]@90
-  //double v128; // [sp+Ch] [bp-7Ch]@115
-  uint _v128;
-  double v129; // [sp+Ch] [bp-7Ch]@140
-  double v130; // [sp+Ch] [bp-7Ch]@168
-  double v131; // [sp+Ch] [bp-7Ch]@193
+  unsigned int v127; // [sp+Ch] [bp-7Ch]@90
   double v132; // [sp+Ch] [bp-7Ch]@218
   double v133; // [sp+14h] [bp-74h]@12
-  double v134; // [sp+14h] [bp-74h]@37
-  double v135; // [sp+14h] [bp-74h]@62
-  double v136; // [sp+14h] [bp-74h]@90
-  //double v137; // [sp+14h] [bp-74h]@115
-  uint _v137;
-  double v138; // [sp+14h] [bp-74h]@140
-  double v139; // [sp+14h] [bp-74h]@168
-  double v140; // [sp+14h] [bp-74h]@193
+  unsigned int v136; // [sp+14h] [bp-74h]@90
   double v141; // [sp+14h] [bp-74h]@218
   double v142; // [sp+1Ch] [bp-6Ch]@12
-  double v143; // [sp+1Ch] [bp-6Ch]@37
-  double v144; // [sp+1Ch] [bp-6Ch]@62
-  double v145; // [sp+1Ch] [bp-6Ch]@90
-  //double v146; // [sp+1Ch] [bp-6Ch]@115
-  uint _v146;
-  double v147; // [sp+1Ch] [bp-6Ch]@140
-  double v148; // [sp+1Ch] [bp-6Ch]@168
-  double v149; // [sp+1Ch] [bp-6Ch]@193
+  unsigned int v145; // [sp+1Ch] [bp-6Ch]@90
   double v150; // [sp+1Ch] [bp-6Ch]@218
   double v151; // [sp+24h] [bp-64h]@12
-  double v152; // [sp+24h] [bp-64h]@37
-  double v153; // [sp+24h] [bp-64h]@62
-  double v154; // [sp+24h] [bp-64h]@90
-  //double v155; // [sp+24h] [bp-64h]@115
-  uint _v155;
-  double v156; // [sp+24h] [bp-64h]@140
-  double v157; // [sp+24h] [bp-64h]@168
-  double v158; // [sp+24h] [bp-64h]@193
+  unsigned int v154; // [sp+24h] [bp-64h]@90
   double v159; // [sp+24h] [bp-64h]@218
   int v160; // [sp+3Ch] [bp-4Ch]@13
   int v161; // [sp+40h] [bp-48h]@15
-  int v162; // [sp+44h] [bp-44h]@40
-  int v163; // [sp+44h] [bp-44h]@65
   int v164; // [sp+44h] [bp-44h]@93
-  int v165; // [sp+44h] [bp-44h]@118
-  int v166; // [sp+44h] [bp-44h]@143
-  int v167; // [sp+44h] [bp-44h]@169
-  int v168; // [sp+44h] [bp-44h]@194
   int v169; // [sp+44h] [bp-44h]@219
-  int v170; // [sp+48h] [bp-40h]@38
-  int v171; // [sp+48h] [bp-40h]@63
   int v172; // [sp+48h] [bp-40h]@91
-  int v173; // [sp+48h] [bp-40h]@116
-  int v174; // [sp+48h] [bp-40h]@141
   unsigned __int16 *v175; // [sp+4Ch] [bp-3Ch]@13
   int *v176; // [sp+50h] [bp-38h]@15
-  int *v177; // [sp+50h] [bp-38h]@40
-  int *v178; // [sp+50h] [bp-38h]@65
   int *v179; // [sp+50h] [bp-38h]@93
-  int *v180; // [sp+50h] [bp-38h]@118
-  int *v181; // [sp+50h] [bp-38h]@143
-  char *v182; // [sp+50h] [bp-38h]@169
-  char *v183; // [sp+50h] [bp-38h]@194
   char *v184; // [sp+50h] [bp-38h]@219
-  unsigned __int16 *v185; // [sp+54h] [bp-34h]@38
-  unsigned __int16 *v186; // [sp+54h] [bp-34h]@63
   unsigned __int16 *v187; // [sp+54h] [bp-34h]@91
-  unsigned __int16 *v188; // [sp+54h] [bp-34h]@116
-  unsigned __int16 *v189; // [sp+54h] [bp-34h]@141
-  signed int v190; // [sp+54h] [bp-34h]@170
-  signed int v191; // [sp+54h] [bp-34h]@195
-  signed int v192; // [sp+54h] [bp-34h]@220
   unsigned __int16 *v193; // [sp+5Ch] [bp-2Ch]@7
-  unsigned __int16 *v194; // [sp+5Ch] [bp-2Ch]@32
-  unsigned __int16 *v195; // [sp+5Ch] [bp-2Ch]@57
   unsigned __int16 *v196; // [sp+5Ch] [bp-2Ch]@85
-  unsigned __int16 *v197; // [sp+5Ch] [bp-2Ch]@110
-  unsigned __int16 *v198; // [sp+5Ch] [bp-2Ch]@135
-  unsigned __int16 *v199; // [sp+5Ch] [bp-2Ch]@163
-  unsigned __int16 *v200; // [sp+5Ch] [bp-2Ch]@188
   unsigned __int16 *v201; // [sp+5Ch] [bp-2Ch]@213
-  //stru350 *v202; // [sp+60h] [bp-28h]@1
-  int v203; // [sp+64h] [bp-24h]@12
-  int v204; // [sp+64h] [bp-24h]@37
-  int v205; // [sp+64h] [bp-24h]@62
-  int v206; // [sp+64h] [bp-24h]@90
-  int v207; // [sp+64h] [bp-24h]@115
-  int v208; // [sp+64h] [bp-24h]@140
-  int v209; // [sp+64h] [bp-24h]@168
-  int v210; // [sp+64h] [bp-24h]@193
-  int v211; // [sp+64h] [bp-24h]@218
-  float v212; // [sp+6Ch] [bp-1Ch]@11
-  float v213; // [sp+6Ch] [bp-1Ch]@36
-  float v214; // [sp+6Ch] [bp-1Ch]@61
-  float v215; // [sp+6Ch] [bp-1Ch]@89
-  float v216; // [sp+6Ch] [bp-1Ch]@114
-  float v217; // [sp+6Ch] [bp-1Ch]@139
-  float v218; // [sp+6Ch] [bp-1Ch]@167
-  float v219; // [sp+6Ch] [bp-1Ch]@192
-  float v220; // [sp+6Ch] [bp-1Ch]@217
-  float v221; // [sp+70h] [bp-18h]@11
-  float v222; // [sp+70h] [bp-18h]@36
-  float v223; // [sp+70h] [bp-18h]@61
-  float v224; // [sp+70h] [bp-18h]@89
-  float v225; // [sp+70h] [bp-18h]@114
-  float v226; // [sp+70h] [bp-18h]@139
-  float v227; // [sp+70h] [bp-18h]@167
-  float v228; // [sp+70h] [bp-18h]@192
-  float v229; // [sp+70h] [bp-18h]@217
-  signed int v230; // [sp+74h] [bp-14h]@1
   signed int v231; // [sp+78h] [bp-10h]@7
-  signed int v232; // [sp+78h] [bp-10h]@32
-  signed int v233; // [sp+78h] [bp-10h]@57
   signed int v234; // [sp+78h] [bp-10h]@85
-  signed int v235; // [sp+78h] [bp-10h]@110
-  signed int v236; // [sp+78h] [bp-10h]@135
-  signed int v237; // [sp+78h] [bp-10h]@163
-  signed int v238; // [sp+78h] [bp-10h]@188
   signed int v239; // [sp+78h] [bp-10h]@213
   __int64 v240; // [sp+7Ch] [bp-Ch]@12
-  __int64 v241; // [sp+7Ch] [bp-Ch]@37
-  __int64 v242; // [sp+7Ch] [bp-Ch]@62
   __int64 v243; // [sp+7Ch] [bp-Ch]@90
-  __int64 v244; // [sp+7Ch] [bp-Ch]@115
-  __int64 v245; // [sp+7Ch] [bp-Ch]@140
-  unsigned int v246; // [sp+7Ch] [bp-Ch]@168
-  unsigned int v247; // [sp+7Ch] [bp-Ch]@193
   unsigned int v248; // [sp+7Ch] [bp-Ch]@218
-  unsigned int v249; // [sp+80h] [bp-8h]@168
-  unsigned int v250; // [sp+80h] [bp-8h]@193
   unsigned int v251; // [sp+80h] [bp-8h]@218
   unsigned int v252; // [sp+84h] [bp-4h]@12
-  unsigned int v253; // [sp+84h] [bp-4h]@37
-  unsigned int v254; // [sp+84h] [bp-4h]@62
   unsigned int v255; // [sp+84h] [bp-4h]@90
-  unsigned int v256; // [sp+84h] [bp-4h]@115
-  unsigned int v257; // [sp+84h] [bp-4h]@140
-  unsigned int v258; // [sp+84h] [bp-4h]@168
-  unsigned int v259; // [sp+84h] [bp-4h]@193
   unsigned int v260; // [sp+84h] [bp-4h]@218
-  signed int a6a; // [sp+A0h] [bp+18h]@10
   float a6s; // [sp+A0h] [bp+18h]@12
   float a6t; // [sp+A0h] [bp+18h]@12
   unsigned int a6b; // [sp+A0h] [bp+18h]@12
-  signed int a6c; // [sp+A0h] [bp+18h]@35
-  float a6u; // [sp+A0h] [bp+18h]@37
-  float a6v; // [sp+A0h] [bp+18h]@37
-  unsigned int a6d; // [sp+A0h] [bp+18h]@37
-  signed int a6e; // [sp+A0h] [bp+18h]@60
-  float a6w; // [sp+A0h] [bp+18h]@62
-  float a6x; // [sp+A0h] [bp+18h]@62
-  unsigned int a6f; // [sp+A0h] [bp+18h]@62
-  signed int a6g; // [sp+A0h] [bp+18h]@88
   float a6y; // [sp+A0h] [bp+18h]@90
   float a6z; // [sp+A0h] [bp+18h]@90
   unsigned int a6h; // [sp+A0h] [bp+18h]@90
-  signed int a6i; // [sp+A0h] [bp+18h]@113
-  float a6ba; // [sp+A0h] [bp+18h]@115
-  float a6bb; // [sp+A0h] [bp+18h]@115
-  unsigned int a6j; // [sp+A0h] [bp+18h]@115
-  signed int a6k; // [sp+A0h] [bp+18h]@138
-  float a6bc; // [sp+A0h] [bp+18h]@140
-  float a6bd; // [sp+A0h] [bp+18h]@140
-  unsigned int a6l; // [sp+A0h] [bp+18h]@140
-  signed int a6m; // [sp+A0h] [bp+18h]@166
-  float a6be; // [sp+A0h] [bp+18h]@168
-  float a6bf; // [sp+A0h] [bp+18h]@168
-  unsigned int a6n; // [sp+A0h] [bp+18h]@168
-  signed int a6o; // [sp+A0h] [bp+18h]@191
-  float a6bg; // [sp+A0h] [bp+18h]@193
-  float a6bh; // [sp+A0h] [bp+18h]@193
-  unsigned int a6p; // [sp+A0h] [bp+18h]@193
-  signed int a6q; // [sp+A0h] [bp+18h]@216
   float a6bi; // [sp+A0h] [bp+18h]@218
   float a6bj; // [sp+A0h] [bp+18h]@218
   unsigned int a6r; // [sp+A0h] [bp+18h]@218
-  int a9a; // [sp+ACh] [bp+24h]@8
-  int a9b; // [sp+ACh] [bp+24h]@33
-  int a9c; // [sp+ACh] [bp+24h]@86
-  int a9d; // [sp+ACh] [bp+24h]@111
-  int a9e; // [sp+ACh] [bp+24h]@164
-  int a9f; // [sp+ACh] [bp+24h]@189
-
-  v11 = 0;
+  int dstdiffmult;
+
+  using namespace rounding;
+
+  int probablyBitDepth = this->field_20.field_C;
+  switch(probablyBitDepth)
+  {
+  case 8: dstdiffmult = dstPitch - dstWidth;
+    break;
+  case 16: dstdiffmult = 2 * (dstPitch - dstWidth);
+    break;
+  case 32: dstdiffmult = 4 * (dstPitch - dstWidth);
+    break;
+  default:
+    return probablyBitDepth;
+  }
+
+
+
   result = this->field_0.field_C;
-  //v202 = this;
-  v230 = 0;
-  if ( result != 8 )
-  {
-    if ( result != 16 )
-    {
-      if ( result != 32 )
-        return result;
-      result = this->field_20.field_C;
-      if ( result != 8 )
-      {
-        if ( result != 16 )
-        {
-          if ( result != 32 || (result = (int)pDst, v193 = pDst, v231 = 0, dstHeight <= 0) )
-            return result;
-          v13 = dstWidth;
-          a9a = 4 * (dstPitch - dstWidth);
-          while ( 1 )
-          {
-            v14 = 0;
-            a6a = 0;
-            if ( dstWidth > v11 )
-              break;
-LABEL_30:
-            v193 = (unsigned __int16 *)((char *)v193 + a9a);
-            ++v231;
-            result = v231;
-            if ( v231 >= dstHeight )
-              return result;
-            v11 = 0;
-          }
-          v221 = (double)dstWidth;
-          v212 = (double)srcWidth;
-          v15 = (double)dstHeight;
-          v16 = (double)srcHeight;
-          while ( 1 )
-          {
-            a6s = (double)a6a / v221 * v212;
-            v151 = floorf(a6s + 0.5f);//a6s + 6.7553994e15;
-            v203 = v14 + 1;
-            a6t = (double)(v14 + 1) / v221 * v212;
-            v142 = floorf(a6t + 0.5f);//a6t + 6.7553994e15;
-            v17 = (double)v231 / v15 * v16;
-            v133 = floorf(v17 + 0.5f);//v17 + 6.7553994e15;
-            v18 = (double)(v231 + 1) / v15 * v16;
-            v124 = floorf(v18 + 0.5f);//v18 + 6.7553994e15;
-            v19 = (LODWORD(v124) - LODWORD(v133)) * (LODWORD(v142) - LODWORD(v151));
-            v252 = 0;
-            a6b = 0;
-            v240 = 0i64;
-            if ( SLODWORD(v133) < SLODWORD(v124) )
-              break;
-LABEL_25:
-            v22 = (unsigned int)v240 / ((LODWORD(v124) - LODWORD(v133)) * (LODWORD(v142) - LODWORD(v151)));
-            if ( v19 )
-            {
-              a6b /= v19;
-              v252 /= v19;
-              HIDWORD(v240) /= v19;
-            }
-            if ( v22 != 255 )
-              v22 &= 0x7FFFFFFFu;
-            v23 = _450F55(HIDWORD(v240) | ((v252 | ((a6b | (v22 << 8)) << 8)) << 8));
-            v24 = v193;
-            v193 += 2;
-            *(_DWORD *)v24 = v23;
-            v14 = v203;
-            a6a = v203;
-            if ( v203 >= dstWidth )
-              goto LABEL_30;
-          }
-          v160 = LODWORD(v124) - LODWORD(v133);
-          v175 = &pSrc[2 * (LODWORD(v151) + srcPitch * LODWORD(v133))];
-          while ( SLODWORD(v151) >= SLODWORD(v142) )
-          {
-LABEL_24:
-            v175 += 2 * srcPitch;
-            --v160;
-            if ( !v160 )
-              goto LABEL_25;
-          }
-          v176 = (int *)v175;
-          v161 = LODWORD(v142) - LODWORD(v151);
-          while ( 1 )
-          {
-            v20 = *v176;
-            if ( a10 )
-            {
-              v230 = 1;
-              v13 = v20 != a11 ? 0xFF : 0;
-            }
-            v21 = _450FB1(v20);
-            if ( !v230 )
-              break;
-            LODWORD(v240) = v13 + v240;
-            v230 = 0;
-            if ( v13 )
-              goto LABEL_22;
-            --v19;
-LABEL_23:
-            ++v176;
-            --v161;
-            if ( !v161 )
-              goto LABEL_24;
-          }
-          LODWORD(v240) = ((unsigned int)v21 >> 24) + v240;
-LABEL_22:
-          a6b += BYTE2(v21);
-          v252 += BYTE1(v21);
-          HIDWORD(v240) += (unsigned __int8)v21;
-          goto LABEL_23;
-        }
-        result = (int)pDst;
-        v194 = pDst;
-        v232 = 0;
-        if ( dstHeight <= 0 )
-          return result;
-        v25 = dstWidth;
-        a9b = 2 * (dstPitch - dstWidth);
-        while ( 1 )
-        {
-          v26 = 0;
-          a6c = 0;
-          if ( dstWidth > v11 )
-            break;
-LABEL_55:
-          v194 = (unsigned __int16 *)((char *)v194 + a9b);
-          ++v232;
-          result = v232;
-          if ( v232 >= dstHeight )
-            return result;
-          v11 = 0;
-        }
-        v222 = (double)dstWidth;
-        v213 = (double)srcWidth;
-        v27 = (double)dstHeight;
-        v28 = (double)srcHeight;
-        while ( 1 )
-        {
-          a6u = (double)a6c / v222 * v213;
-          v125 = a6u + 6.7553994e15;
-          v204 = v26 + 1;
-          a6v = (double)(v26 + 1) / v222 * v213;
-          v134 = a6v + 6.7553994e15;
-          v29 = (double)v232 / v27 * v28;
-          v143 = v29 + 6.7553994e15;
-          v30 = (double)(v232 + 1) / v27 * v28;
-          v152 = v30 + 6.7553994e15;
-          v31 = (LODWORD(v152) - LODWORD(v143)) * (LODWORD(v134) - LODWORD(v125));
-          v253 = 0;
-          a6d = 0;
-          v241 = 0i64;
-          if ( SLODWORD(v143) < SLODWORD(v152) )
-            break;
-LABEL_50:
-          v34 = (unsigned int)v241 / ((LODWORD(v152) - LODWORD(v143)) * (LODWORD(v134) - LODWORD(v125)));
-          if ( v31 )
-          {
-            a6d /= v31;
-            v253 /= v31;
-            HIDWORD(v241) /= v31;
-          }
-          if ( v34 != 255 )
-            v34 &= 0x7FFFFFFFu;
-          v35 = _450F55(HIDWORD(v241) | ((v253 | ((a6d | (v34 << 8)) << 8)) << 8));
-          v36 = v194;
-          ++v194;
-          *v36 = v35;
-          v26 = v204;
-          a6c = v204;
-          if ( v204 >= dstWidth )
-            goto LABEL_55;
-        }
-        v170 = LODWORD(v152) - LODWORD(v143);
-        v185 = &pSrc[2 * (LODWORD(v125) + srcPitch * LODWORD(v143))];
-        while ( SLODWORD(v125) >= SLODWORD(v134) )
-        {
-LABEL_49:
-          v185 += 2 * srcPitch;
-          --v170;
-          if ( !v170 )
-            goto LABEL_50;
-        }
-        v177 = (int *)v185;
-        v162 = LODWORD(v134) - LODWORD(v125);
-        while ( 1 )
-        {
-          v32 = *v177;
-          if ( a10 )
-          {
-            v230 = 1;
-            v25 = v32 != a11 ? 0xFF : 0;
-          }
-          v33 = _450FB1(v32);
-          if ( !v230 )
-            break;
-          LODWORD(v241) = v25 + v241;
-          v230 = 0;
-          if ( v25 )
-            goto LABEL_47;
-          --v31;
-LABEL_48:
-          ++v177;
-          --v162;
-          if ( !v162 )
-            goto LABEL_49;
-        }
-        LODWORD(v241) = ((unsigned int)v33 >> 24) + v241;
-LABEL_47:
-        a6d += BYTE2(v33);
-        v253 += BYTE1(v33);
-        HIDWORD(v241) += (unsigned __int8)v33;
-        goto LABEL_48;
-      }
-      result = (int)pDst;
-      v195 = pDst;
-      v233 = 0;
-      if ( dstHeight <= 0 )
-        return result;
-      v37 = dstWidth;
-      while ( 1 )
-      {
-        v38 = 0;
-        a6e = 0;
-        if ( dstWidth > v11 )
-          break;
-LABEL_80:
-        v195 = (unsigned __int16 *)((char *)v195 + dstPitch - dstWidth);
-        ++v233;
-        result = v233;
-        if ( v233 >= dstHeight )
-          return result;
-        v11 = 0;
-      }
-      v223 = (double)dstWidth;
-      v214 = (double)srcWidth;
-      v39 = (double)dstHeight;
-      v40 = (double)srcHeight;
-      while ( 1 )
-      {
-        a6w = (double)a6e / v223 * v214;
-        v126 = a6w + 6.7553994e15;
-        v205 = v38 + 1;
-        a6x = (double)(v38 + 1) / v223 * v214;
-        v135 = a6x + 6.7553994e15;
-        v41 = (double)v233 / v39 * v40;
-        v144 = v41 + 6.7553994e15;
-        v42 = (double)(v233 + 1) / v39 * v40;
-        v153 = v42 + 6.7553994e15;
-        v43 = (LODWORD(v153) - LODWORD(v144)) * (LODWORD(v135) - LODWORD(v126));
-        v254 = 0;
-        a6f = 0;
-        v242 = 0i64;
-        if ( SLODWORD(v144) < SLODWORD(v153) )
-          break;
-LABEL_75:
-        v46 = (unsigned int)v242 / ((LODWORD(v153) - LODWORD(v144)) * (LODWORD(v135) - LODWORD(v126)));
-        if ( v43 )
-        {
-          a6f /= v43;
-          v254 /= v43;
-          HIDWORD(v242) /= v43;
-        }
-        if ( v46 != 255 )
-          v46 &= 0x7FFFFFFFu;
-        v47 = _450F55(HIDWORD(v242) | ((v254 | ((a6f | (v46 << 8)) << 8)) << 8));
-        v48 = v195;
-        v195 = (unsigned __int16 *)((char *)v195 + 1);
-        *(_BYTE *)v48 = v47;
-        v38 = v205;
-        a6e = v205;
-        if ( v205 >= dstWidth )
-          goto LABEL_80;
-      }
-      v171 = LODWORD(v153) - LODWORD(v144);
-      v186 = &pSrc[2 * (LODWORD(v126) + srcPitch * LODWORD(v144))];
-      while ( SLODWORD(v126) >= SLODWORD(v135) )
-      {
-LABEL_74:
-        v186 += 2 * srcPitch;
-        --v171;
-        if ( !v171 )
-          goto LABEL_75;
-      }
-      v178 = (int *)v186;
-      v163 = LODWORD(v135) - LODWORD(v126);
-      while ( 1 )
-      {
-        v44 = *v178;
-        if ( a10 )
-        {
-          v230 = 1;
-          v37 = v44 != a11 ? 0xFF : 0;
-        }
-        v45 = _450FB1(v44);
-        if ( !v230 )
-          break;
-        LODWORD(v242) = v37 + v242;
-        v230 = 0;
-        if ( v37 )
-          goto LABEL_72;
-        --v43;
-LABEL_73:
-        ++v178;
-        --v163;
-        if ( !v163 )
-          goto LABEL_74;
-      }
-      LODWORD(v242) = ((unsigned int)v45 >> 24) + v242;
-LABEL_72:
-      a6f += BYTE2(v45);
-      v254 += BYTE1(v45);
-      HIDWORD(v242) += (unsigned __int8)v45;
-      goto LABEL_73;
-    }
-    result = this->field_20.field_C;
-    if ( result != 8 )
-    {
-      if ( result != 16 )
-      {
-        if ( result != 32 || (result = (int)pDst, v196 = pDst, v234 = 0, dstHeight <= 0) )
-          return result;
-        v49 = dstWidth;
-        a9c = 4 * (dstPitch - dstWidth);
-        while ( 1 )
-        {
-          v50 = 0;
-          a6g = 0;
-          if ( dstWidth > v11 )
-            break;
-LABEL_108:
-          v196 = (unsigned __int16 *)((char *)v196 + a9c);
-          ++v234;
-          result = v234;
-          if ( v234 >= dstHeight )
-            return result;
-          v11 = 0;
-        }
-        v224 = (double)dstWidth;
-        v215 = (double)srcWidth;
-        v51 = (double)dstHeight;
-        v52 = (double)srcHeight;
-        while ( 1 )
-        {
-          a6y = (double)a6g / v224 * v215;
-          v127 = a6y + 6.7553994e15;
-          v206 = v50 + 1;
-          a6z = (double)(v50 + 1) / v224 * v215;
-          v136 = a6z + 6.7553994e15;
-          v53 = (double)v234 / v51 * v52;
-          v145 = v53 + 6.7553994e15;
-          v54 = (double)(v234 + 1) / v51 * v52;
-          v154 = v54 + 6.7553994e15;
-          v55 = (LODWORD(v154) - LODWORD(v145)) * (LODWORD(v136) - LODWORD(v127));
-          v255 = 0;
-          a6h = 0;
-          v243 = 0i64;
-          if ( SLODWORD(v145) < SLODWORD(v154) )
-            break;
-LABEL_103:
-          v58 = (unsigned int)v243 / ((LODWORD(v154) - LODWORD(v145)) * (LODWORD(v136) - LODWORD(v127)));
-          if ( v55 )
-          {
-            a6h /= v55;
-            v255 /= v55;
-            HIDWORD(v243) /= v55;
-          }
-          if ( v58 != 255 )
-            v58 &= 0x7FFFFFFFu;
-          v59 = _450F55(HIDWORD(v243) | ((v255 | ((a6h | (v58 << 8)) << 8)) << 8));
-          v60 = v196;
-          v196 += 2;
-          *(_DWORD *)v60 = v59;
-          v50 = v206;
-          a6g = v206;
-          if ( v206 >= dstWidth )
-            goto LABEL_108;
-        }
-        v172 = LODWORD(v154) - LODWORD(v145);
-        v187 = &pSrc[LODWORD(v127) + srcPitch * LODWORD(v145)];
-        while ( SLODWORD(v127) >= SLODWORD(v136) )
-        {
-LABEL_102:
-          v187 += srcPitch;
-          --v172;
-          if ( !v172 )
-            goto LABEL_103;
-        }
-        v179 = (int *)v187;
-        v164 = LODWORD(v136) - LODWORD(v127);
-        while ( 1 )
-        {
-          v56 = *(_WORD *)v179;
-          if ( a10 )
-          {
-            v230 = 1;
-            v49 = v56 != a11 ? 0xFF : 0;
-          }
-          v57 = _450FB1(v56);
-          if ( !v230 )
-            break;
-          LODWORD(v243) = v49 + v243;
-          v230 = 0;
-          if ( v49 )
-            goto LABEL_100;
-          --v55;
-LABEL_101:
-          v179 = (int *)((char *)v179 + 2);
-          --v164;
-          if ( !v164 )
-            goto LABEL_102;
-        }
-        LODWORD(v243) = ((unsigned int)v57 >> 24) + v243;
-LABEL_100:
-        a6h += BYTE2(v57);
-        v255 += BYTE1(v57);
-        HIDWORD(v243) += (unsigned __int8)v57;
-        goto LABEL_101;
-      }
-      result = (int)pDst;
-      v197 = pDst;
-      v235 = 0;
-      if ( dstHeight <= 0 )
-        return result;
-      v61 = dstWidth;
-      a9d = 2 * (dstPitch - dstWidth);
-      while ( 1 )
-      {
-        v62 = 0;
-        a6i = 0;
-        if ( dstWidth > v11 )
-          break;
-LABEL_133:
-        v197 = (unsigned __int16 *)((char *)v197 + a9d);
-        ++v235;
-        result = v235;
-        if ( v235 >= dstHeight )
-          return result;
-        v11 = 0;
-      }
-      v225 = (double)dstWidth;
-      v216 = (double)srcWidth;
-      v63 = (double)dstHeight;
-      v64 = (double)srcHeight;
-      while ( 1 )
-      {
-        a6ba = (double)a6i / v225 * v216;
-        _v128 = floorf(a6ba + 0.5f);
-        //v128 = a6ba + 6.7553994e15;
-        v207 = v62 + 1;
-        a6bb = (double)(v62 + 1) / v225 * v216;
-        //v137 = a6bb + 6.7553994e15;
-        _v137 = floorf(a6bb + 0.5f);
-        v65 = (double)v235 / v63 * v64;
-        //v146 = v65 + 6.7553994e15;
-        _v146 = floorf(v65 + 0.5f);
-        v66 = (double)(v235 + 1) / v63 * v64;
-        //v155 = v66 + 6.7553994e15;
-        _v155 = floorf(v66 + 0.5f);
-        //v67 = (LODWORD(v155) - LODWORD(v146)) * (LODWORD(v137) - LODWORD(v128));
-        v67 = (_v155 - _v146) * (_v137 - _v128);
-        v256 = 0;
-        a6j = 0;
-        v244 = 0i64;
-        //if ( SLODWORD(v146) < SLODWORD(v155) )
-        if (_v146 < _v155)
-          break;
-LABEL_128:
-        //v70 = (unsigned int)v244 / ((LODWORD(v155) - LODWORD(v146)) * (LODWORD(v137) - LODWORD(v128)));
-        v70 = (unsigned int)v244 / ((_v155 - _v146) * (_v137 - _v128));
-        if ( v67 )
-        {
-          a6j /= v67;
-          v256 /= v67;
-          HIDWORD(v244) /= v67;
-        }
-        if ( v70 != 255 )
-          v70 &= 0x7FFFFFFFu;
-        v71 = _450F55(HIDWORD(v244) | ((v256 | ((a6j | (v70 << 8)) << 8)) << 8));
-        v72 = v197;
-        ++v197;
-        *v72 = v71;
-        v62 = v207;
-        a6i = v207;
-        if ( v207 >= dstWidth )
-          goto LABEL_133;
-      }
-      //v173 = LODWORD(v155) - LODWORD(v146);
-      v173 = _v155 - _v146;
-      //v188 = &pSrc[LODWORD(v128) + srcPitch * LODWORD(v146)];
-      v188 = &pSrc[_v128 + srcPitch * _v146];
-      //while ( SLODWORD(v128) >= SLODWORD(v137) )
-      while (_v128 >= _v137)
-      {
-LABEL_127:
-        v188 += srcPitch;
-        --v173;
-        if ( !v173 )
-          goto LABEL_128;
-      }
-      v180 = (int *)v188;
-      //v165 = LODWORD(v137) - LODWORD(v128);
-      v165 = _v137 - _v128;
-      while ( 1 )
-      {
-        v68 = *(_WORD *)v180;
-        if ( a10 )
-        {
-          v230 = 1;
-          v61 = v68 != a11 ? 0xFF : 0;
-        }
-        v69 = _450FB1(v68);
-        if ( !v230 )
-          break;
-        LODWORD(v244) = v61 + v244;
-        v230 = 0;
-        if ( v61 )
-          goto LABEL_125;
-        --v67;
-LABEL_126:
-        v180 = (int *)((char *)v180 + 2);
-        --v165;
-        if ( !v165 )
-          goto LABEL_127;
-      }
-      LODWORD(v244) = ((unsigned int)v69 >> 24) + v244;
-LABEL_125:
-      a6j += BYTE2(v69);
-      v256 += BYTE1(v69);
-      HIDWORD(v244) += (unsigned __int8)v69;
-      goto LABEL_126;
-    }
+  if ( result == 32 )
+  {
     result = (int)pDst;
-    v198 = pDst;
-    v236 = 0;
+    v193 = pDst;
+    v231 = 0;
     if ( dstHeight <= 0 )
       return result;
-    v73 = dstWidth;
     while ( 1 )
     {
-      v74 = 0;
-      a6k = 0;
-      if ( dstWidth > v11 )
+      v14 = 0;
+      if ( dstWidth > 0 )
         break;
-LABEL_158:
-      v198 = (unsigned __int16 *)((char *)v198 + dstPitch - dstWidth);
-      ++v236;
-      result = v236;
-      if ( v236 >= dstHeight )
+LABEL_30:
+      v193 = (unsigned __int16 *)((char *)v193 + dstdiffmult);
+      ++v231;
+      result = v231;
+      if ( v231 >= dstHeight )
         return result;
-      v11 = 0;
-    }
-    v226 = (double)dstWidth;
-    v217 = (double)srcWidth;
-    v75 = (double)dstHeight;
-    v76 = (double)srcHeight;
+    }
     while ( 1 )
     {
-      a6bc = (double)a6k / v226 * v217;
-      v129 = a6bc + 6.7553994e15;
-      v208 = v74 + 1;
-      a6bd = (double)(v74 + 1) / v226 * v217;
-      v138 = a6bd + 6.7553994e15;
-      v77 = (double)v236 / v75 * v76;
-      v147 = v77 + 6.7553994e15;
-      v78 = (double)(v236 + 1) / v75 * v76;
-      v156 = v78 + 6.7553994e15;
-      v257 = 0;
-      v79 = (LODWORD(v156) - LODWORD(v147)) * (LODWORD(v138) - LODWORD(v129));
-      a6l = 0;
-      v245 = 0i64;
-      if ( SLODWORD(v147) < SLODWORD(v156) )
+      a6s = (double)v14 / (double)dstWidth * (double)srcWidth;
+      v151 = bankersRounding(a6s);//a6s + 6.7553994e15;
+      a6t = (double)(v14 + 1) / (double)dstWidth * (double)srcWidth;
+      v142 = bankersRounding(a6t);//a6t + 6.7553994e15;
+      v17 = (double)v231 / (double)dstHeight * (double)srcHeight;
+      v133 = bankersRounding(v17);//v17 + 6.7553994e15;
+      v18 = (double)(v231 + 1) / (double)dstHeight * (double)srcHeight;
+      v124 = bankersRounding(v18);//v18 + 6.7553994e15;
+      v19 = (LODWORD(v124) - LODWORD(v133)) * (LODWORD(v142) - LODWORD(v151));
+      v252 = 0;
+      a6b = 0;
+      v240 = 0i64;
+      if ( SLODWORD(v133) < SLODWORD(v124) )
+        break;
+LABEL_25:
+      v22 = (unsigned int)v240 / ((LODWORD(v124) - LODWORD(v133)) * (LODWORD(v142) - LODWORD(v151)));
+      if ( v19 )
+      {
+        a6b /= v19;
+        v252 /= v19;
+        HIDWORD(v240) /= v19;
+      }
+      if ( v22 != 255 )
+        v22 &= 0x7FFFFFFFu;
+      v23 = _450F55(HIDWORD(v240) | ((v252 | ((a6b | (v22 << 8)) << 8)) << 8));
+      *(_DWORD *)v193 = v23;
+      switch(probablyBitDepth)
+      {
+      case 8: v193 = (unsigned __int16 *)((char *)v193 + 1);
+        break;
+      case 16: ++v193;
+        break;
+      case 32: v193 += 2;
         break;
-LABEL_153:
-      v82 = (unsigned int)v245 / ((LODWORD(v156) - LODWORD(v147)) * (LODWORD(v138) - LODWORD(v129)));
-      if ( v79 )
-      {
-        a6l /= v79;
-        v257 /= v79;
-        HIDWORD(v245) /= v79;
-      }
-      if ( v82 != 255 )
-        v82 &= 0x7FFFFFFFu;
-      v83 = _450F55(HIDWORD(v245) | ((v257 | ((a6l | (v82 << 8)) << 8)) << 8));
-      v84 = v198;
-      v198 = (unsigned __int16 *)((char *)v198 + 1);
-      *(_BYTE *)v84 = v83;
-      v74 = v208;
-      a6k = v208;
-      if ( v208 >= dstWidth )
-        goto LABEL_158;
-    }
-    v174 = LODWORD(v156) - LODWORD(v147);
-    v189 = &pSrc[LODWORD(v129) + srcPitch * LODWORD(v147)];
-    while ( SLODWORD(v129) >= SLODWORD(v138) )
-    {
-LABEL_152:
-      v189 += srcPitch;
-      --v174;
-      if ( !v174 )
-        goto LABEL_153;
-    }
-    v166 = LODWORD(v138) - LODWORD(v129);
-    v181 = (int *)v189;
+      default:
+        assert(false);
+        return result;
+      }
+      ++v14;
+      if ( v14 >= dstWidth )
+        goto LABEL_30;
+    }
+    v160 = LODWORD(v124) - LODWORD(v133);
+    v175 = &pSrc[2 * (LODWORD(v151) + srcPitch * LODWORD(v133))];
+    while ( SLODWORD(v151) >= SLODWORD(v142) )
+    {
+LABEL_24:
+      v175 += 2 * srcPitch;
+      --v160;
+      if ( !v160 )
+        goto LABEL_25;
+    }
+    v176 = (int *)v175;
+    v161 = LODWORD(v142) - LODWORD(v151);
+    while ( 1 )
+    {
+      v21 = _450FB1(*v176);
+      break;
+LABEL_23:
+      ++v176;
+      --v161;
+      if ( !v161 )
+        goto LABEL_24;
+    }
+    LODWORD(v240) = ((unsigned int)v21 >> 24) + v240;
+    a6b += BYTE2(v21);
+    v252 += BYTE1(v21);
+    HIDWORD(v240) += (unsigned __int8)v21;
+    goto LABEL_23;
+  }
+
+  else if ( result == 16 )
+  {
+    result = (int)pDst;
+    v196 = pDst;
+    v234 = 0;
+    if ( dstHeight <= 0 )
+      return result; 
+    while ( 1 )
+    {
+      v50 = 0;
+      if ( dstWidth > 0 )
+        break;
+  LABEL_108:
+      v196 = (unsigned __int16 *)((char *)v196 + dstdiffmult);
+      ++v234;
+      result = v234;
+      if ( v234 >= dstHeight )
+        return result;
+    }
     while ( 1 )
     {
-      v80 = *(_WORD *)v181;
-      if ( a10 )
-      {
-        v230 = 1;
-        v73 = v80 != a11 ? 0xFF : 0;
-      }
-      v81 = _450FB1(v80);
-      if ( !v230 )
+      a6y = (double)v50 / (double)dstWidth * (double)srcWidth;
+      v127 = ceilf(a6y - 0.5f);//a6y + 6.7553994e15;
+      a6z = (double)(v50 + 1) / (double)dstWidth * (double)srcWidth;
+      v136 = ceilf(a6z - 0.5f);//a6z + 6.7553994e15;
+      v53 = (double)v234 / (double)dstHeight * (double)srcHeight;
+      v145 = ceilf(v53 - 0.5f);//v53 + 6.7553994e15;
+      v54 = (double)(v234 + 1) / (double)dstHeight * (double)srcHeight;
+      v154 = ceilf(v54 - 0.5f);//v54 + 6.7553994e15;
+      v55 = (v154 - v145) * (v136 - v127);
+      v255 = 0;
+      a6h = 0;
+      v243 = 0i64;
+      if ( v145 < v154 )
+        break;
+  LABEL_103:
+      v58 = (unsigned int)v243 / ((v154 - v145) * (v136 - v127));
+      if ( v55 )
+      {
+        a6h /= v55;
+        v255 /= v55;
+        HIDWORD(v243) /= v55;
+      }
+      if ( v58 != 255 )
+        v58 &= 0x7FFFFFFFu;
+      v59 = _450F55(HIDWORD(v243) | ((v255 | ((a6h | (v58 << 8)) << 8)) << 8));
+      *(_DWORD *)v196 = v59;
+      switch(probablyBitDepth)
+      {
+      case 8: v196 = (unsigned __int16 *)((char *)v196 + 1);
+        break;
+      case 16: ++v196;
+        break;
+      case 32: v196 += 2;
         break;
-      LODWORD(v245) = v73 + v245;
-      v230 = 0;
-      if ( v73 )
-        goto LABEL_150;
-      --v79;
-LABEL_151:
-      v181 = (int *)((char *)v181 + 2);
-      --v166;
-      if ( !v166 )
-        goto LABEL_152;
-    }
-    LODWORD(v245) = ((unsigned int)v81 >> 24) + v245;
-LABEL_150:
-    a6l += BYTE2(v81);
-    v257 += BYTE1(v81);
-    HIDWORD(v245) += (unsigned __int8)v81;
-    goto LABEL_151;
-  }
-  result = this->field_20.field_C;
-  if ( result == 8 )
+      default:
+        assert(false);
+        return result;
+      }
+      ++v50;
+      if ( v50 >= dstWidth )
+        goto LABEL_108;
+    }
+    v172 = v154 - v145;
+    v187 = &pSrc[v127 + srcPitch * v145];
+    while ( v127 >= v136 )
+    {
+  LABEL_102:
+      v187 += srcPitch;
+      --v172;
+      if ( !v172 )
+        goto LABEL_103;
+    }
+    v179 = (int *)v187;
+    v164 = LODWORD(v136) - LODWORD(v127);
+    while ( 1 )
+    {
+      v57 = _450FB1(*(_WORD *)v179);
+      break;
+  LABEL_101:
+      v179 = (int *)((char *)v179 + 2);
+      --v164;
+      if ( !v164 )
+        goto LABEL_102;
+    }
+    LODWORD(v243) = ((unsigned int)v57 >> 24) + v243;
+    a6h += BYTE2(v57);
+    v255 += BYTE1(v57);
+    HIDWORD(v243) += (unsigned __int8)v57;
+    goto LABEL_101;
+  }
+
+  else if ( result == 8 )
   {
     result = (int)pDst;
     v201 = pDst;
     v239 = 0;
     if ( dstHeight <= 0 )
       return result;
-    v111 = dstWidth;
     while ( 1 )
     {
       v112 = 0;
-      a6q = 0;
-      if ( dstWidth <= v11 )
+      if ( dstWidth <= 0 )
         goto LABEL_236;
-      v229 = (double)dstWidth;
-      v220 = (double)srcWidth;
-      v113 = (double)dstHeight;
-      v114 = (double)srcHeight;
       do
       {
-        a6bi = (double)a6q / v229 * v220;
+        a6bi = (double)v112 / (double)dstWidth * (double)srcWidth;
         v132 = a6bi + 6.7553994e15;
-        v211 = v112 + 1;
-        a6bj = (double)(v112 + 1) / v229 * v220;
+        a6bj = (double)(v112 + 1) / (double)dstWidth * (double)srcWidth;
         v141 = a6bj + 6.7553994e15;
-        v115 = (double)v239 / v113 * v114;
+        v115 = (double)v239 / (double)dstHeight * (double)srcHeight;
         v150 = v115 + 6.7553994e15;
-        v116 = (double)(v239 + 1) / v113 * v114;
+        v116 = (double)(v239 + 1) / (double)dstHeight * (double)srcHeight;
         v159 = v116 + 6.7553994e15;
         v251 = 0;
         v117 = (LODWORD(v159) - LODWORD(v150)) * (LODWORD(v141) - LODWORD(v132));
@@ -3141,36 +2473,15 @@
         do
         {
           v118 = LODWORD(v132);
-          v192 = LODWORD(v132);
           while ( v118 < SLODWORD(v141) )
           {
-            v119 = (unsigned __int8)v184[v192];
-            if ( a10 )
-            {
-              v230 = 1;
-              v111 = v119 != a11 ? 0xFF : 0;
-            }
+            v119 = (unsigned __int8)v184[v118];
             v120 = _450FB1(v119);
-            if ( v230 )
-            {
-              v248 += v111;
-              v230 = 0;
-              if ( !v111 )
-              {
-                --v117;
-                goto LABEL_228;
-              }
-            }
-            else
-            {
-              v248 += (unsigned int)v120 >> 24;
-            }
+            v248 += (unsigned int)v120 >> 24;
             a6r += BYTE2(v120);
             v260 += BYTE1(v120);
             v251 += (unsigned __int8)v120;
-LABEL_228:
-            ++v192;
-            v118 = v192;
+            ++v118;
           }
           v184 += srcPitch;
           --v169;
@@ -3187,225 +2498,32 @@
         if ( v121 != 255 )
           v121 &= 0x7FFFFFFFu;
         v122 = _450F55(v251 | ((v260 | ((a6r | (v121 << 8)) << 8)) << 8));
-        v123 = v201;
-        v201 = (unsigned __int16 *)((char *)v201 + 1);
-        *(_BYTE *)v123 = v122;
-        v112 = v211;
-        a6q = v211;
-      }
-      while ( v211 < dstWidth );
+        *v201 = v122;
+        switch(probablyBitDepth)
+        {
+        case 8: v201 = (unsigned __int16 *)((char *)v201 + 1);
+          break;
+        case 16: ++v201;
+          break;
+        case 32: v201 += 2;
+          break;
+        default:
+          assert(false);
+          return result;
+        }
+        ++v112;
+      }
+      while ( v112 < dstWidth );
 LABEL_236:
-      v201 = (unsigned __int16 *)((char *)v201 + dstPitch - dstWidth);
+      v201 = (unsigned __int16 *)((char *)v201 + dstdiffmult);
       ++v239;
       result = v239;
       if ( v239 >= dstHeight )
         return result;
-      v11 = 0;
-    }
-  }
-  if ( result == 16 )
-  {
-    result = (int)pDst;
-    v200 = pDst;
-    v238 = 0;
-    if ( dstHeight <= 0 )
-      return result;
-    v98 = dstWidth;
-    a9f = 2 * (dstPitch - dstWidth);
-    while ( 1 )
-    {
-      v99 = 0;
-      a6o = 0;
-      if ( dstWidth <= v11 )
-        goto LABEL_211;
-      v228 = (double)dstWidth;
-      v219 = (double)srcWidth;
-      v100 = (double)dstHeight;
-      v101 = (double)srcHeight;
-      do
-      {
-        a6bg = (double)a6o / v228 * v219;
-        v131 = a6bg + 6.7553994e15;
-        v210 = v99 + 1;
-        a6bh = (double)(v99 + 1) / v228 * v219;
-        v140 = a6bh + 6.7553994e15;
-        v102 = (double)v238 / v100 * v101;
-        v149 = v102 + 6.7553994e15;
-        v103 = (double)(v238 + 1) / v100 * v101;
-        v158 = v103 + 6.7553994e15;
-        v250 = 0;
-        v104 = (LODWORD(v158) - LODWORD(v149)) * (LODWORD(v140) - LODWORD(v131));
-        v259 = 0;
-        a6p = 0;
-        v247 = 0;
-        if ( SLODWORD(v149) >= SLODWORD(v158) )
-          goto LABEL_206;
-        v168 = LODWORD(v158) - LODWORD(v149);
-        v183 = (char *)pSrc + srcPitch * LODWORD(v149);
-        do
-        {
-          v105 = LODWORD(v131);
-          v191 = LODWORD(v131);
-          while ( v105 < SLODWORD(v140) )
-          {
-            v106 = (unsigned __int8)v183[v191];
-            if ( a10 )
-            {
-              v230 = 1;
-              v98 = v106 != a11 ? 0xFF : 0;
-            }
-            v107 = _450FB1(v106);
-            if ( v230 )
-            {
-              v247 += v98;
-              v230 = 0;
-              if ( !v98 )
-              {
-                --v104;
-                goto LABEL_203;
-              }
-            }
-            else
-            {
-              v247 += (unsigned int)v107 >> 24;
-            }
-            a6p += BYTE2(v107);
-            v259 += BYTE1(v107);
-            v250 += (unsigned __int8)v107;
-LABEL_203:
-            ++v191;
-            v105 = v191;
-          }
-          v183 += srcPitch;
-          --v168;
-        }
-        while ( v168 );
-LABEL_206:
-        v108 = v247 / ((LODWORD(v158) - LODWORD(v149)) * (LODWORD(v140) - LODWORD(v131)));
-        if ( v104 )
-        {
-          a6p /= v104;
-          v259 /= v104;
-          v250 /= v104;
-        }
-        if ( v108 != 255 )
-          v108 &= 0x7FFFFFFFu;
-        v109 = _450F55(v250 | ((v259 | ((a6p | (v108 << 8)) << 8)) << 8));
-        v110 = v200;
-        ++v200;
-        *v110 = v109;
-        v99 = v210;
-        a6o = v210;
-      }
-      while ( v210 < dstWidth );
-LABEL_211:
-      v200 = (unsigned __int16 *)((char *)v200 + a9f);
-      ++v238;
-      result = v238;
-      if ( v238 >= dstHeight )
-        return result;
-      v11 = 0;
-    }
-  }
-  if ( result != 32 || (result = (int)pDst, v199 = pDst, v237 = 0, dstHeight <= 0) )
-    return result;
-  v85 = dstWidth;
-  a9e = 4 * (dstPitch - dstWidth);
-  while ( 2 )
-  {
-    v86 = 0;
-    a6m = 0;
-    if ( dstWidth <= v11 )
-      goto LABEL_186;
-    v227 = (double)dstWidth;
-    v218 = (double)srcWidth;
-    v87 = (double)dstHeight;
-    v88 = (double)srcHeight;
-    do
-    {
-      a6be = (double)a6m / v227 * v218;
-      v130 = a6be + 6.7553994e15;
-      v209 = v86 + 1;
-      a6bf = (double)(v86 + 1) / v227 * v218;
-      v139 = a6bf + 6.7553994e15;
-      v89 = (double)v237 / v87 * v88;
-      v148 = v89 + 6.7553994e15;
-      v90 = (double)(v237 + 1) / v87 * v88;
-      v157 = v90 + 6.7553994e15;
-      v249 = 0;
-      v91 = (LODWORD(v157) - LODWORD(v148)) * (LODWORD(v139) - LODWORD(v130));
-      v258 = 0;
-      a6n = 0;
-      v246 = 0;
-      if ( SLODWORD(v148) >= SLODWORD(v157) )
-        goto LABEL_181;
-      v167 = LODWORD(v157) - LODWORD(v148);
-      v182 = (char *)pSrc + srcPitch * LODWORD(v148);
-      do
-      {
-        v92 = LODWORD(v130);
-        v190 = LODWORD(v130);
-        while ( v92 < SLODWORD(v139) )
-        {
-          v93 = (unsigned __int8)v182[v190];
-          if ( a10 )
-          {
-            v230 = 1;
-            v85 = v93 != a11 ? 0xFF : 0;
-          }
-          v94 = _450FB1(v93);
-          if ( v230 )
-          {
-            v246 += v85;
-            v230 = 0;
-            if ( !v85 )
-            {
-              --v91;
-              goto LABEL_178;
-            }
-          }
-          else
-          {
-            v246 += (unsigned int)v94 >> 24;
-          }
-          a6n += BYTE2(v94);
-          v258 += BYTE1(v94);
-          v249 += (unsigned __int8)v94;
-LABEL_178:
-          ++v190;
-          v92 = v190;
-        }
-        v182 += srcPitch;
-        --v167;
-      }
-      while ( v167 );
-LABEL_181:
-      v95 = v246 / ((LODWORD(v157) - LODWORD(v148)) * (LODWORD(v139) - LODWORD(v130)));
-      if ( v91 )
-      {
-        a6n /= v91;
-        v258 /= v91;
-        v249 /= v91;
-      }
-      if ( v95 != 255 )
-        v95 &= 0x7FFFFFFFu;
-      v96 = _450F55(v249 | ((v258 | ((a6n | (v95 << 8)) << 8)) << 8));
-      v97 = v199;
-      v199 += 2;
-      *(_DWORD *)v97 = v96;
-      v86 = v209;
-      a6m = v209;
-    }
-    while ( v209 < dstWidth );
-LABEL_186:
-    v199 = (unsigned __int16 *)((char *)v199 + a9e);
-    ++v237;
-    result = v237;
-    if ( v237 < dstHeight )
-    {
-      v11 = 0;
-      continue;
-    }
+    }
+  }
+  else //( result != 8 && result != 16 && result != 32 )
+  {
     return result;
   }
 }
@@ -3484,7 +2602,7 @@
       v9 = 2;
       for ( v2->pTextures[v2->sNumTextures].uFlags = 0; v9 < v21; ++v9 )
       {
-        if ( !_strcmpi((&Str1)[4 * v9], "New") )
+        if ( !_stricmp((&Str1)[4 * v9], "New") )
         {
           v10 = (int)&v2->pTextures[v2->sNumTextures].uFlags;
           *(char *)v10 |= 2u;
@@ -5736,25 +4854,25 @@
         for ( j = 0; j < v41.uPropCount; ++j )
         {
           v27 = v41.pProperties[j];
-          if ( _strcmpi(v41.pProperties[j], "NBM") )
-          {
-            if ( _strcmpi(v27, "Invisible") )
+          if ( _stricmp(v41.pProperties[j], "NBM") )
+          {
+            if ( _stricmp(v27, "Invisible") )
             {
-              if ( _strcmpi(v27, "FS") )
+              if ( _stricmp(v27, "FS") )
               {
-                if ( _strcmpi(v27, "FM") )
+                if ( _stricmp(v27, "FM") )
                 {
-                  if ( _strcmpi(v27, "FF") )
+                  if ( _stricmp(v27, "FF") )
                   {
-                    if ( _strcmpi(v27, "Marker") )
+                    if ( _stricmp(v27, "Marker") )
                     {
-                      if ( _strcmpi(v27, "LoopSlow") )
+                      if ( _stricmp(v27, "LoopSlow") )
                       {
-                        if ( _strcmpi(v27, "EmitFire") )
+                        if ( _stricmp(v27, "EmitFire") )
                         {
-                          if ( _strcmpi(v27, "Dawn") )
+                          if ( _stricmp(v27, "Dawn") )
                           {
-                            if ( !_strcmpi(v27, "Dusk") )
+                            if ( !_stricmp(v27, "Dusk") )
                               HIBYTE(v2->pDecorations[v2->uNumDecorations].uFlags) |= 2u;
                           }
                           else
@@ -5966,17 +5084,17 @@
         {
           v21 = Argsb;
           v22 = v44.pProperties[Argsb];
-          if ( !_strcmpi(v44.pProperties[Argsb], "NoDraw") )
+          if ( !_stricmp(v44.pProperties[Argsb], "NoDraw") )
           {
             v23 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
             *(char *)v23 |= 1u;
           }
-          if ( !_strcmpi(v22, "Lifetime") )
+          if ( !_stricmp(v22, "Lifetime") )
           {
             v24 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
             *(char *)v24 |= 4u;
           }
-          if ( !_strcmpi(v22, "FTLifetime") )
+          if ( !_stricmp(v22, "FTLifetime") )
           {
             v25 = (int)&v2->pObjects[v2->uNumObjects];
             *(short *)(v25 + 42) = 8 * pSpriteFrameTable->pSpriteSFrames[*(short *)(v25 + 40)].uAnimLength;
@@ -5985,32 +5103,32 @@
             v27 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
             *(char *)v27 |= 4u;
           }
-          if ( !_strcmpi(v22, "NoPickup") )
+          if ( !_stricmp(v22, "NoPickup") )
           {
             v28 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
             *(char *)v28 |= 0x10u;
           }
-          if ( !_strcmpi(v22, "NoGravity") )
+          if ( !_stricmp(v22, "NoGravity") )
           {
             v29 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
             *(char *)v29 |= 0x20u;
           }
-          if ( !_strcmpi(v22, "FlagOnIntercept") )
+          if ( !_stricmp(v22, "FlagOnIntercept") )
           {
             v30 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
             *(char *)v30 |= 0x40u;
           }
-          if ( !_strcmpi(v22, "Bounce") )
+          if ( !_stricmp(v22, "Bounce") )
           {
             v31 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
             *(char *)v31 |= 0x80u;
           }
           v32 = v45.pProperties[v21];
-          if ( !_strcmpi(v45.pProperties[v21], "Fire") )
+          if ( !_stricmp(v45.pProperties[v21], "Fire") )
             HIBYTE(v2->pObjects[v2->uNumObjects].uFlags) |= 2u;
-          if ( !_strcmpi(v32, "Lines") )
+          if ( !_stricmp(v32, "Lines") )
             HIBYTE(v2->pObjects[v2->uNumObjects].uFlags) |= 4u;
-          if ( !_strcmpi(v44.pProperties[v21], "bits") )
+          if ( !_stricmp(v44.pProperties[v21], "bits") )
           {
             v33 = v44.pProperties[v21 + 1];
             v34 = (int)&v2->pObjects[v2->uNumObjects].uFlags;
@@ -7053,7 +6171,7 @@
         v29 = 0;
         //goto LABEL_262;
         v30 = 1;
-        ArcomageGame::OnMouseClick(v30, v29);
+        ArcomageGame::OnMouseClick(v30, v29 != 0);
         return DefWindowProcA(hWnd, Msg, wParam, lParam);
 
       case WM_LBUTTONDBLCLK:
@@ -7129,7 +6247,7 @@
           ArcomageGame::OnMouseMove((POINT *)pXY);
           ArcomageGame::OnMouseClick(0, wParam & 1);
           v29 = (wParam >> 1) & 1;
-          ArcomageGame::OnMouseClick(1, v29);
+          ArcomageGame::OnMouseClick(1, v29 != 0);
         }
         else
         {
@@ -7967,7 +7085,7 @@
 //----- (00464839) --------------------------------------------------------
 char __cdecl Is_out15odm_underwater()
 {
-  return _strcmpi(pCurrentMapName, "out15.odm") == 0;
+  return _stricmp(pCurrentMapName, "out15.odm") == 0;
 }
 
 //----- (00464851) --------------------------------------------------------
@@ -8011,19 +7129,19 @@
   bUnderwater = 0;
   uLevelMapStatsID = v5;
   pGame->uFlags2 &= 0xFFFFFFF7u;
-  if ( !_strcmpi(pCurrentMapName, "out15.odm") )
+  if ( !_stricmp(pCurrentMapName, "out15.odm") )
   {
     bUnderwater = 1;
     pGame->uFlags2 |= 8u;
   }
   pParty->floor_face_pid = 0;
-  if ( _strcmpi(Str1, "blv") )
+  if ( _stricmp(Str1, "blv") )
     PrepareToLoadODM(v9, 0);
   else
     PrepareToLoadBLV(v9);
   pAudioPlayer->SetMapEAX();
   sub_461103();
-  if ( !_strcmpi(pCurrentMapName, "d11.blv") || !_strcmpi(pCurrentMapName, "d10.blv") )
+  if ( !_stricmp(pCurrentMapName, "d11.blv") || !_stricmp(pCurrentMapName, "d10.blv") )
   {
     //spawning grounds & good analogue - no loot & exp from monsters
 
@@ -11068,7 +10186,7 @@
 }
 
 //----- (0046BEF1) --------------------------------------------------------
-void SpriteObject::_46BEF1_apply_spells()
+void SpriteObject::_46BEF1_apply_spells_aoe()
 {
   SpriteObject *v1; // edi@1
   Actor *v2; // esi@2
@@ -11077,6 +10195,8 @@
   unsigned __int8 v5; // c3@4
   signed int v6; // [sp+8h] [bp-4h]@1
 
+  int v7,v8,v9,v10,v11;
+
   v6 = 0;
   v1 = this;
   if ( (signed int)uNumActors > 0 )
@@ -11087,7 +10207,79 @@
       if ( v2->CanAct() )
       {
         //UNDEF(v3);
-        if ( !(v4 | v5) )
+		//.text:0046BF26                 movsx   eax, word ptr [esi-2]
+		//.text:0046BF2A                 sub     eax, [edi+4]
+		//.text:0046BF31                 mov     [ebp+var_8], eax
+		//.text:0046BF37                 fild    [ebp+var_8]
+		// v7 pushed to stack
+		v7 = v2->vPosition.x - this->vPosition.x;
+
+		//.text:0046BF2D                 movsx   ecx, word ptr [esi+2]
+		v8 = v2->vPosition.z;
+
+		//.text:0046BF34                 movsx   eax, word ptr [esi]
+		//.text:0046BF3A                 sub     eax, [edi+8]
+		//.text:0046BF3D                 mov     [ebp+var_8], eax
+		//.text:0046BF44                 fild    [ebp+var_8]
+		// v9 pushed to stack
+		v9 = v2->vPosition.y - this->vPosition.y;
+
+		//.text:0046BF40                 movsx   eax, word ptr [esi-6]
+		//.text:0046BF47                 sar     eax, 1
+		//.text:0046BF49                 add     eax, ecx
+		//.text:0046BF4B                 sub     eax, [edi+0Ch]
+		//.text:0046BF4E                 mov     [ebp+var_8], eax
+		//.text:0046BF51                 fild    [ebp+var_8]
+		//.text:0046BF58                 fld     st
+		// v10 pushed to stack, two times
+		v10 = v2->uActorHeight / 2 + v8 - this->vVelocity.y;
+
+		//.text:0046BF54                 movsx   eax, word ptr [esi-8]
+		//.text:0046BF5A                 add     eax, 100h
+		//.text:0046BF63                 mov     ecx, eax
+		v11 = this->vVelocity.x;
+
+		//.text:0046BF5F                 fmul    st, st(1)
+		// stack: v10*v10, v10, v9, v7
+		//.text:0046BF61                 fld     st(2)
+		// stack: v7, v10*v10, v10, v9, v7
+		
+
+		//.text:0046BF65                 fmul    st, st(3)
+		// stack: v7*v9, v10*v10, v10, v9, v7
+		
+		//.text:0046BF67                 imul    ecx, eax
+		v11 = v11 * v11;
+
+		//.text:0046BF6A                 faddp   st(1), st
+		// stack: v10*v10+v7*v9, v10, v9, v7
+		//.text:0046BF6C                 fld     st(3)
+		// stack: v7, v10*v10+v7*v9, v10, v9, v7
+		//.text:0046BF6E                 fmul    st, st(4)
+		// stack: v7*v7, v10*v10+v7*v9, v10, v9, v7
+		//.text:0046BF70                 faddp   st(1), st
+		// stack: v10*v10+v7*v9+v7*v7, v10, v9, v7
+		
+		//.text:0046BF72                 mov     [ebp+var_8], ecx
+		//.text:0046BF75                 fild    [ebp+var_8]
+		// v11 pushed to stack
+
+		//.text:0046BF78                 fcompp
+		// if ( v11 > v10*v10+v7*v9+v7*v7 )
+		// stack: v10, v9, v7
+
+		//.text:0046BF7A                 fstp    st
+		// stack: v9, v7
+
+		//.text:0046BF7C                 fnstsw  ax
+		//.text:0046BF7E                 fstp    st
+		// stack: v7
+
+		//.text:0046BF80                 test    ah, 41h
+		//.text:0046BF83                 fstp    st
+		//.text:0046BF85                 jnz     short loc_46BFDD
+
+		if ( v11 >= v10*v10+v7*v9+v7*v7 )
         {
           if ( stru_50C198.GetMagicalResistance(v2, 0xAu) )
           {
@@ -11348,7 +10540,7 @@
         {
           if ( v6 != 9030 || v2->spell_skill != 4 )
             goto LABEL_246;
-          v2->_46BEF1_apply_spells();
+          v2->_46BEF1_apply_spells_aoe();
 LABEL_233:
           if ( !v138 )
           {
@@ -11457,7 +10649,7 @@
               }
               else
               {
-                v2->_46BEF1_apply_spells();
+                v2->_46BEF1_apply_spells_aoe();
               }
               v2->spell_level = 0;
               v2->spell_skill = 0;
--- a/mm7_3.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/mm7_3.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -1334,7 +1334,7 @@
 {
   unsigned int v0; // ebx@0
   //unsigned int v1; // edi@1
-  char *v2; // esi@2
+  //char *v2; // esi@2
   //__int16 v3; // dx@5
   ObjectDesc *v4; // eax@5
   int v5; // ecx@6
@@ -1359,7 +1359,7 @@
   for (uint i = 0; i < uNumSpriteObjects; ++i)
   {
     auto item = pSpriteObjects + i;
-    v2 = (char *)&item->uSpriteFrameID;
+    //v2 = (char *)&item->uSpriteFrameID;
     //do
     //{
       //LOWORD(v0) = item->uAttributes;
@@ -1372,20 +1372,22 @@
       if (item->AttachedToActor())
       {
           v5 = PID_ID(item->spell_target_pid);
-          *(int *)(v2 - 26) = pActors[v5].vPosition.x;
-          *(int *)(v2 - 22) = pActors[v5].vPosition.y;
-          *(int *)(v2 - 18) = pActors[v5].vPosition.z + pActors[v5].uActorHeight;
-          if ( !item->uObjectDescID || (v6 = LOWORD(pEventTimer->uTimeElapsed) + *(short *)v2, *(short *)v2 = v6, !(v4->uFlags & 4)) )
-            goto LABEL_36;
+		  item->vPosition.x = pActors[v5].vPosition.x;
+          item->vPosition.y = pActors[v5].vPosition.y;
+          item->vPosition.z = pActors[v5].vPosition.z + pActors[v5].uActorHeight;
+		  if ( !item->uObjectDescID || (v6 = LOWORD(pEventTimer->uTimeElapsed) + item->uSpriteFrameID, item->uSpriteFrameID = v6, !(v4->uFlags & 4)) )
+            continue;
           if ( v6 >= 0 )
           {
             v7 = v4->uLifetime;
             if (item->uAttributes & 2)
-              v7 = *((short *)v2 + 1);
+              v7 = item->field_20;
             if ( v6 < v7 )
-              goto LABEL_36;
-          }
-          goto LABEL_34;
+              continue;
+          }
+            v10 = i;
+            SpriteObject::OnInteraction(v10);
+            continue;
       }
 
         if ( item->uObjectDescID )
@@ -1393,30 +1395,29 @@
           v8 = LOWORD(pEventTimer->uTimeElapsed) + item->uSpriteFrameID;
           item->uSpriteFrameID = v8;
           v9 = v4->uFlags;
-          if ( !(v9 & 4) )
-            goto LABEL_22;
-          if ( v8 < 0 )
-          {
-            v10 = i;
-LABEL_35:
-            SpriteObject::OnInteraction(v10);
-            goto LABEL_36;
-          }
-          v11 = v4->uLifetime;
-          if (item->uAttributes & 2)
-            v11 = *((short *)v2 + 1);
-          if ( v8 < v11 )
-          {
-LABEL_22:
+          if ( v9 & 4 )
+		  {    
+			  if ( v8 < 0 )
+			  {
+				v10 = i;
+				SpriteObject::OnInteraction(v10);
+				continue;
+			  }
+			  v11 = v4->uLifetime;
+			  if (item->uAttributes & 2)
+				v11 = item->field_20;
+		  }
+		  if ( !(v9 & 4) || v8 < v11 )
+          {
             if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
               SpriteObject::UpdateObject_fn0_BLV(i);
             else
               SpriteObject::UpdateObject_fn0_ODM(i);
-            if ( pParty->bTurnBasedModeOn != 1 || !(*(v2 - 4) & 4) )
-              goto LABEL_36;
-            v12 = abs(pParty->vPosition.x - *(int *)(v2 - 26));
-            v18 = abs(pParty->vPosition.y - *(int *)(v2 - 22));
-            v19 = abs(pParty->vPosition.z - *(int *)(v2 - 18));
+			if ( pParty->bTurnBasedModeOn != 1 || !(item->uSectorID & 4) )
+              continue;
+			v12 = abs(pParty->vPosition.x - item->vPosition.x);
+			v18 = abs(pParty->vPosition.y - item->vPosition.y);
+			v19 = abs(pParty->vPosition.z - item->vPosition.z);
             v13 = v12;
             v14 = v18;
             v15 = v19;
@@ -1439,19 +1440,20 @@
             }
             v0 = (unsigned int)(11 * v14) >> 5;
             if ( (signed int)(v0 + (v15 >> 2) + v13) <= 5120 )
-              goto LABEL_36;
-LABEL_34:
+              continue;
             v10 = i;
-            goto LABEL_35;
+            SpriteObject::OnInteraction(v10);
+            continue;
           }
           v10 = i;
           if ( !(v9 & 0x40) )
-            goto LABEL_35;
+		  {
+            SpriteObject::OnInteraction(v10);
+            continue;
+		  }
           _46BFFA_check_object_intercept(i, PID(OBJECT_Item,i));
         }
     }
-LABEL_36:
-    ;
       //v2 += 112;
       //v1 = v20++ + 1;
     //}
@@ -1632,10 +1634,10 @@
   if (!pParty->FeatherFallActive())
   {
     bFeatherFall = false;
-    if (!pParty->pPlayers[0].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, 16) &&  // grants feather fall
-        !pParty->pPlayers[1].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, 16) &&
-        !pParty->pPlayers[2].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, 16) &&
-        !pParty->pPlayers[3].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, 16))
+    if (!pParty->pPlayers[0].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY) &&  // grants feather fall
+        !pParty->pPlayers[1].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY) &&
+        !pParty->pPlayers[2].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY) &&
+        !pParty->pPlayers[3].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY))
     {
       fall_start = pParty->uFallStartY;
     }
@@ -1656,7 +1658,7 @@
     else for (uint i = 0; i < 4; ++i)
     {                                      // receive falling damage
       auto player = pParty->pPlayers + i;
-      if (!player->HasEnchantedItemEquipped(72) && !player->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, 8))
+      if (!player->HasEnchantedItemEquipped(72) && !player->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS))
       {
         player->ReceiveDamage((pParty->uFallStartY - party_z) * (0.1f * player->GetMaxHealth()) / 256, DMGT_PHISYCAL);
         v10 = (double)(20 - player->GetParameterBonus(player->GetActualEndurance())) * flt_6BE3A4_debug_recmod1 * 2.133333333333333;
@@ -1829,7 +1831,7 @@
       v41 = &pPlayers[1];
       do
       {
-        if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, 8) )
+        if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 
           (*v41)->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0);
         ++v41;
       }
@@ -2257,7 +2259,7 @@
         goto LABEL_9;
     }*/
     for (int i = 0; i < 4; ++i)
-      if (pParty->pPlayers[i].WearsItem(536, 16))  // seems like flying boots
+      if (pParty->pPlayers[i].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY))  // seems like flying boots
       {
         bFeatherFall = 1;
         break;
@@ -2295,7 +2297,7 @@
     {
       auto player = pParty->pPlayers + _i;
 
-      if ( !player->HasEnchantedItemEquipped(72) && !player->WearsItem(529, 8) )
+      if ( !player->HasEnchantedItemEquipped(72) && !player->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) )
       {
         player->ReceiveDamage(
             (signed int)((pParty->uFallStartY - pZ) * (unsigned __int64)(player->GetMaxHealth() / 10)) / 256,
@@ -2733,7 +2735,7 @@
 		  for (int i = 0; i < 4; ++i)
 		  {
 			auto player = pParty->pPlayers + i;
-			if (!player->HasEnchantedItemEquipped(72) && !player->WearsItem(529, 8) && player->CanAct())
+			if (!player->HasEnchantedItemEquipped(72) && !player->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) && player->CanAct())
 			  player->PlaySound(SPEECH_66, 0);
 		  }
 		}
@@ -3544,14 +3546,14 @@
       break;
     v17 = v25;
     v18 = word_720B40_intercepts_zs[v25 + 1];
-    if ( v16 ^ v18 >= v27 )
+    if ( v16 ^ (v18 >= v27) )
     {
       v19 = word_720C10_intercepts_xs[v17 + 1];
       if ( v19 >= v26 )
         v20 = 0;
       else
         v20 = 2;
-      v21 = v20 | word_720C10_intercepts_xs[v17] < v26;
+      v21 = v20 | (word_720C10_intercepts_xs[v17] < v26);
       if ( v21 != 3 )
       {
         if ( !v21
@@ -3682,14 +3684,14 @@
       break;
     v13 = v21;
     v14 = word_7209A0_intercepts_ys_plus_ys[v21 + 1];
-    if ( v12 ^ v14 >= v24 )
+    if ( v12 ^ (v14 >= v24) )
     {
       v15 = word_720A70_intercepts_xs_plus_xs[v13 + 1];
       if ( v15 >= v23 )
         v16 = 0;
       else
         v16 = 2;
-      v17 = v16 | word_720A70_intercepts_xs_plus_xs[v13] < v23;
+      v17 = v16 | (word_720A70_intercepts_xs_plus_xs[v13] < v23);
       if ( v17 != 3 )
       {
         if ( !v17
@@ -4284,7 +4286,8 @@
       v33 = (double)v16 * 0.0000152587890625;
       //UNDEF(v17);
       v20 = *((float *)v15 - 1) - (double)pIndoorCamera->pos.x;
-      if ( v19 | v18 )
+      //if ( v19 | v18 )
+	  if(pIndoorCamera->pos.x == 0)
       {
         v27 = v20;
         LODWORD(v35) = *((int *)v15 + 1);
@@ -4381,96 +4384,60 @@
 //----- (0047802A) --------------------------------------------------------
 int stru6_stru1_indoor_sw_billboard::sub_47802A()
 {
-  int v1; // edx@1
-  stru6_stru1_indoor_sw_billboard *v2; // edi@1
-  int v3; // ebx@2
-  char *v4; // esi@3
-  float v5; // eax@4
   double v6; // st7@4
-  double v7; // ST30_8@5
-  double v8; // st6@6
-  double v9; // st5@6
-  char *v10; // ecx@15
-  float v11; // eax@16
   double v12; // st7@16
-  double v13; // st6@16
-  double v14; // st5@16
   signed int v16; // [sp+38h] [bp-Ch]@1
   int a6; // [sp+3Ch] [bp-8h]@5
   int a5; // [sp+40h] [bp-4h]@5
 
   auto a1 = this;
 
-  v1 = 0;
-  v2 = a1;
   v16 = 0;
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
   {
-    v3 = 0;
-    if ( a1->field_10 > 0 )
-    {
-      v4 = (char *)&a1->field_14[42];
-      do
-      {
-        LODWORD(v5) = *((int *)v4 - 2);
-        v6 = (double)pBLVRenderParams->field_40 * 0.000015258789 / *((float *)v4 - 2);
-        if ( pRenderer->pRenderD3D )
-        {
-          v7 = v5 + 6.7553994e15;
-          pGame->pIndoorCameraD3D->Project(
-            COERCE_UNSIGNED_INT64(v5 + 6.7553994e15),
-            COERCE_UNSIGNED_INT64(*((float *)v4 - 1) + 6.7553994e15),
-            COERCE_UNSIGNED_INT64(*(float *)v4 + 6.7553994e15),
-            &a5,
-            &a6);
-          *((float *)v4 + 18) = (double)a5;
-          *((float *)v4 + 19) = (double)a6;
-          *((float *)v4 + 20) = (double)SLODWORD(v7);
-        }
-        else
-        {
-          *((float *)v4 + 18) = (double)pBLVRenderParams->uViewportCenterX - v6 * *((float *)v4 - 1);
-          v8 = (double)pBLVRenderParams->uViewportCenterY;
-          v9 = v6 * *(float *)v4;
-          *((int *)v4 + 20) = LODWORD(v5);
-          *((float *)v4 + 19) = v8 - v9;
-        }
-        *((int *)v4 + 21) = *((int *)v4 + 1);
-        if ( (double)(signed int)pViewport->uViewportTL_X <= *((float *)v4 + 18)
-          && (double)(signed int)pViewport->uViewportBR_X > *((float *)v4 + 18)
-          && (double)(signed int)pViewport->uViewportTL_Y <= *((float *)v4 + 19)
-          && (double)(signed int)pViewport->uViewportBR_Y > *((float *)v4 + 19) )
-          v16 = 1;
-        ++v3;
-        v4 += 16;
-      }
-      while ( v3 < v2->field_10 );
-    }
-  }
-  else
-  {
-    if ( a1->field_10 > 0 )
-    {
-      v10 = (char *)&a1->field_14[40];
-      do
-      {
-        LODWORD(v11) = *(int *)v10;
-        v12 = (double)pOutdoorCamera->int_fov_rad / *(float *)v10;
-        *((float *)v10 + 20) = (double)pViewport->uScreenCenterX - v12 * *((float *)v10 + 1);
-        v13 = (double)pViewport->uScreenCenterY;
-        v14 = v12 * *((float *)v10 + 2);
-        *((int *)v10 + 22) = LODWORD(v11);
-        *((int *)v10 + 23) = *((int *)v10 + 3);
-        *((float *)v10 + 21) = v13 - v14;
-        if ( (double)(signed int)pViewport->uViewportTL_X <= *((float *)v10 + 20)
-          && (double)(signed int)pViewport->uViewportBR_X > *((float *)v10 + 20)
-          && (double)(signed int)pViewport->uViewportTL_Y <= *((float *)v10 + 21)
-          && (double)(signed int)pViewport->uViewportBR_Y > *((float *)v10 + 21) )
-          v16 = 1;
-        ++v1;
-        v10 += 16;
-      }
-      while ( v1 < v2->field_10 );
+	for(int i = 0; i < a1->field_10; i++)
+    {
+		v6 = (double)pBLVRenderParams->field_40 * 0.000015258789 / a1->field_B4[i*4];
+		if ( pRenderer->pRenderD3D )
+		{
+			pGame->pIndoorCameraD3D->Project(
+				round(a1->field_B4[i*4]),
+				round(a1->field_B4[i*4+1]),
+				round(a1->field_B4[i*4+2]),
+				&a5,
+				&a6);
+			a1->field_B4[i*4+16] = (double)a5;
+			a1->field_B4[i*4+17] = (double)a6;
+			a1->field_B4[i*4+18] = round(a1->field_B4[i*4]);
+		}
+		else
+		{
+			a1->field_B4[i*4+16] = (double)pBLVRenderParams->uViewportCenterX - v6 * a1->field_B4[i*4+1];
+			a1->field_B4[i*4+17] = (double)pBLVRenderParams->uViewportCenterY - v6 * a1->field_B4[i*4+2];
+			a1->field_B4[i*4+18] = a1->field_B4[i*4];
+		}
+		a1->field_B4[i*4+19] = a1->field_B4[i*4+3];
+		if ( (double)(signed int)pViewport->uViewportTL_X <= a1->field_B4[i*4+16]
+			&& (double)(signed int)pViewport->uViewportBR_X > a1->field_B4[i*4+16]
+			&& (double)(signed int)pViewport->uViewportTL_Y <= a1->field_B4[i*4+17]
+			&& (double)(signed int)pViewport->uViewportBR_Y > a1->field_B4[i*4+17] )
+			v16 = 1;
+    }
+  }
+  else
+  {
+	for(int i = 0; i < a1->field_10; i++)
+    {
+		v12 = (double)pOutdoorCamera->int_fov_rad / a1->field_B4[i*4];
+		a1->field_B4[i*4+20] = (double)pViewport->uScreenCenterX - v12 * a1->field_B4[i*4+1];
+		a1->field_B4[i*4+21] = (double)pViewport->uScreenCenterY - v12 * a1->field_B4[i*4+2];
+		*((int *)&a1->field_B4[i*4+22]) = (int)a1->field_B4[i*4];
+		*((int *)&a1->field_B4[i*4+23]) = a1->field_B4[i*4+3];
+		if ( (double)(signed int)pViewport->uViewportTL_X <= a1->field_B4[i*4+20]
+			&& (double)(signed int)pViewport->uViewportBR_X > a1->field_B4[i*4+20]
+			&& (double)(signed int)pViewport->uViewportTL_Y <= a1->field_B4[i*4+21]
+			&& (double)(signed int)pViewport->uViewportBR_Y > a1->field_B4[i*4+21] )
+			v16 = 1;
     }
   }
   return v16;
@@ -5014,7 +4981,7 @@
       {
 		v1->field_40 |= 1u;
         v2 = v1->uNumFaces;
-        v3 = (ODMFace *)v1->pFaces;
+        v3 = v1->pFaces;
         v74 = 0;
         v76 = v3;
         v68 = v2;
@@ -5084,16 +5051,16 @@
         *(int *)&v12->flags = 0;
         if ( v82 == v7 )
           *(int *)&v12->flags = 65536;
-        v12->pODMFace = (ODMFace *)v3;
+        v12->pODMFace = v3;
         v12->uNumVertices = v7;
         v12->field_59 = 5;
-        v84 = *(int *)v3;
+        v84 = v3->pFacePlane.vNormal.x;
         v83 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.x) >> 16;
         v82 = -pOutdoor->vSunlight.y;
-        v84 = *(int *)(v3 + 4);
+        v84 = v3->pFacePlane.vNormal.y;
         v82 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.y) >> 16;
         v81 = (unsigned __int16 *)-pOutdoor->vSunlight.z;
-        v84 = *(int *)(v3 + 8);
+        v84 = v3->pFacePlane.vNormal.z;
         v81 = (unsigned __int16 *)((unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16);
         v84 = v83 + v82 + ((unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16);
         v13 = (double)v84 * 0.000015258789;
@@ -5108,8 +5075,8 @@
           *(char *)v15 = 0;
         if ( *(char *)v15 > 31 )
           *(char *)v15 = 31;
-        v16 = *(short *)(v3 + 272);
-        if ( *(char *)(v3 + 29) & 0x40 )
+        v16 = v3->uTextureID;
+        if ( BYTE1(v3->uAttributes) & 0x40 )
           v16 = pTextureFrameTable->GetFrameTexture(v16, pEventTimer->uTotalGameTimeElapsed);
         v17 = v16;
         result = (BSPModel *)&pBitmaps_LOD->pTextures[v16];
@@ -5120,7 +5087,7 @@
           return result;
         ++pOutdoorCamera->numStru148s;
         ++pOutdoorCamera->field_44;
-        if ( !ODMFace::IsBackfaceCulled((ODMFace *)v3, array_73D150, v12) )
+        if ( !ODMFace::IsBackfaceCulled(v3, array_73D150, v12) )
         {
 LABEL_71:
           --pOutdoorCamera->numStru148s;
@@ -5129,18 +5096,18 @@
         }
         LOBYTE(v20) = v79;
         v21 = a1;
-        *(char *)(v3 + 305) = 1;
+        v3->bVisible = 1;
         v12->uBModelFaceID = v20;
         LOWORD(v20) = (unsigned __int8)v20;
         v12->uBModelID = v21;
         v22 = 8 * (v20 | (v21 << 6));
         LOBYTE(v22) = v22 | 6;
         v12->field_50 = v22;
-        if ( *(char *)(v3 + 28) & 0x10 )
+        if ( v3->uAttributes & 0x10 )
           *(int *)&v12->flags |= 2u;
-        if ( *(char *)(v3 + 30) & 0x40 )
+        if ( BYTE2(v3->uAttributes) & 0x40 )
           HIBYTE(v12->flags) |= 4u;
-        v23 = *(int *)(v3 + 28);
+        v23 = v3->uAttributes;
         if ( v23 & 4 )
         {
           HIBYTE(v12->flags) |= 4u;
@@ -5150,7 +5117,7 @@
           if ( v23 & 0x20 )
             HIBYTE(v12->flags) |= 8u;
         }
-        v24 = *(int *)(v3 + 28);
+        v24 = v3->uAttributes;
         if ( BYTE1(v24) & 8 )
         {
           HIBYTE(v12->flags) |= 0x20u;
@@ -5277,9 +5244,9 @@
             if ( !v50 )
               goto LABEL_71;
             sr_sub_4829B9(
-              &array_73D150[*(char *)(v3 + 298)],
-              &array_73D150[*(char *)(v3 + 299)],
-              &array_73D150[*(char *)(v3 + 300)],
+              &array_73D150[v3->uGradientVertex1],
+              &array_73D150[v3->uGradientVertex2],
+              &array_73D150[v3->uGradientVertex3],
               v12,
               0);
             v51 = 0;
@@ -5307,7 +5274,7 @@
 LABEL_72:
       ++v79;
       v1 = v78;
-      v3 += 308;
+      ++v3;
       v76 = v3;
       if ( v79 >= v68 )
         goto LABEL_73;
@@ -11567,7 +11534,7 @@
   int v2; // ebx@1
   char *v3; // esi@1
   int v4; // edi@4
-  int v5; // ecx@4
+  bool v5; // ecx@4
   SpriteFrame *v6; // eax@6
   SpriteFrame *v7; // edi@6
   int v8; // eax@6
@@ -11599,10 +11566,11 @@
       {
         //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 + 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 == v2 + 310 || v5 )
         {
           if ( !pOtherOverlayList->pOverlays[i].field_0 )
           {
@@ -12173,7 +12141,7 @@
                 v14 = v13;
                 if ( v13 )
                 {
-                  if ( _strcmpi(v13, "") )
+                  if ( _stricmp(v13, "") )
                     v17 = v14;
                 }
               }
@@ -12667,7 +12635,7 @@
     {
       if ( *((_WORD *)v4 + 9) == v6 )
       {
-        if ( pFileName && _strcmpi(pFileName, "0") )
+        if ( pFileName && _stricmp(pFileName, "0") )
         {
           v5 = pDecorationList->GetDecorIdByName(pFileName);
           *((_WORD *)v4 - 1) = v5;
@@ -12698,7 +12666,7 @@
   if ( pName && (uID = 1, (signed int)this->uNumDecorations > 1) )
   {
     v4 = 1;
-    while ( _strcmpi(pName, v2->pDecorations[v4].pName) )
+    while ( _stricmp(pName, v2->pDecorations[v4].pName) )
     {
       ++uID;
       ++v4;
@@ -13719,7 +13687,7 @@
   v2 = pMapName;
   pAudioPlayer->StopChannels(-1, -1);
   pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_None);
-  if ( _strcmpi(pCurrentMapName, v2) )
+  if ( _stricmp(pCurrentMapName, v2) )
     SaveGame(1, 0);
 
   uGameState = GAME_STATE_2;
@@ -13907,7 +13875,7 @@
 //----- (00449B57) --------------------------------------------------------
 bool _449B57_test_bit( unsigned __int8 *a1, __int16 a2 )
 {
-  return a1[(a2 - 1) >> 3] & (0x80u >> (a2 - 1) % 8);
+  return (a1[(a2 - 1) >> 3] & (0x80u >> (a2 - 1) % 8)) != 0;
 }
 
 //----- (00449B7E) --------------------------------------------------------
@@ -13957,7 +13925,7 @@
 {
   bool result; // eax@1
 
-  result = _strcmpi("nwc.blv", pCurrentMapName);
+  result = _stricmp("nwc.blv", pCurrentMapName);
   if ( result )
   {
     _5B65A8_npcdata_uflags_or_other = 0;
@@ -13976,7 +13944,7 @@
 }
 
 //----- (0044C2F4) --------------------------------------------------------
-int LevelDecoration::IsInteractive()
+bool LevelDecoration::IsInteractive()
 {
   switch (uDecorationDescID)
   {
@@ -14590,8 +14558,6 @@
 							}
 						}
 					}
-					++v84;
-					++v5;
 				}
 				for(int i = 1; i <= 4; i++)
 				{
@@ -15430,7 +15396,7 @@
         if ( pActors[v37].CanAct() )
         {
           v7 = pActor->uAttributes;
-          if ( v7 & 0x8000 < 0 )
+          if ( v7 & 0x8000 )
           {
             v8 = ai_near_actors_targets_pid[v5];
             LOBYTE(v7) = v7 | 0x80;
--- a/mm7_4.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/mm7_4.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -284,7 +284,7 @@
             continue;
 
             v14 = word_721460_xs[j + 1] >= x ? 0 : 2;
-            v15 = v14 | word_721460_xs[j] < x;
+            v15 = v14 | (word_721460_xs[j] < x);
 
           if (v15 == 3)
             continue;
@@ -516,7 +516,7 @@
                 if ( v43 != v44 )
                 {
                   v18 = word_721040[i + 1] >= X ? 0 : 2;
-                  v19 = v18 | word_721040[i] < X;
+                  v19 = v18 | (word_721040[i] < X);
                   if ( v19 != 3 )
                   {
                     if ( !v19 )
@@ -722,7 +722,7 @@
                         if ( v34 != v35 )
                         {
                           v13 = word_720DB0_xs[v12 + 1] >= v31 ? 0 : 2;
-                          v14 = v13 | word_720DB0_xs[v12] < v31;
+                          v14 = v13 | (word_720DB0_xs[v12] < v31);
                           if ( v14 != 3 )
                           {
                             if ( !v14
@@ -2382,7 +2382,7 @@
     viewparams->bRedrawGameUI = 1;
     while ( 1 )
     {
-      if ( pPlayers[v12]->WearsItem(516, 3)
+      if ( pPlayers[v12]->WearsItem(ITEM_RELIC_HARECS_LEATHER, EQUIP_ARMOUR)
         || pPlayers[v12]->HasEnchantedItemEquipped(71)
         || pPlayers[v12]->pPlayerBuffs[23].uExpireTime > 0 )
       {
@@ -2936,7 +2936,7 @@
       v2->pFrames[v2->uNumFrames].uFlags = 0;
       for ( j = 3; j < v24.uPropCount; ++j )
       {
-        if ( !_strcmpi(v24.pProperties[j], "New") )
+        if ( !_stricmp(v24.pProperties[j], "New") )
         {
           v13 = (int)&v2->pFrames[v2->uNumFrames].uFlags;
           *(char *)v13 |= 4u;
@@ -2998,7 +2998,7 @@
   }
   else
   {
-    while ( _strcmpi(pIconName, v2->pIcons[v3].pAnimationName) )
+    while ( _stricmp(pIconName, v2->pIcons[v3].pAnimationName) )
     {
       ++uID;
       ++v3;
@@ -3166,7 +3166,7 @@
         strcpy(v2->pIcons[v2->uNumIcons].pTextureName, v20.pProperties[1]);
         v8 = v20.pProperties[2];
         v2->pIcons[v2->uNumIcons].uFlags = 0;
-        if ( !_strcmpi(v8, "new") )
+        if ( !_stricmp(v8, "new") )
         {
           v9 = (int)&v2->pIcons[v2->uNumIcons].uFlags;
           *(char *)v9 |= 4u;
@@ -3826,7 +3826,7 @@
       v9 = &pVertices->pVertices[pFace->pVertexIDs[i]];
       v12 = &pVertices->pVertices[pFace->pVertexIDs[i + 1]];
       v17 = &pVertices->pVertices[pFace->pVertexIDs[i + 2]];
-
+	  i++;
       v1.x = v12->x - v9->x;
       v26 = v17->x - v12->x;
       v1.y = v12->y - v9->y;
@@ -7968,12 +7968,12 @@
 				if( v8 < (signed int)pNPCStats->uNumNewNPCs )
 					v6[8] &= 0x7Fu;
 			}
-			if ( pParty->pHirelings[0].pName && !_strcmpi(pParty->pHirelings[0].pName, speakingNPC->pName) )
+			if ( pParty->pHirelings[0].pName && !_stricmp(pParty->pHirelings[0].pName, speakingNPC->pName) )
 			{
 				v11 = pParty->pHirelings;
 				memset(v11, 0, sizeof(NPCData));
 			}
-			else if ( pParty->pHirelings[1].pName && !_strcmpi(pParty->pHirelings[1].pName, speakingNPC->pName) )
+			else if ( pParty->pHirelings[1].pName && !_stricmp(pParty->pHirelings[1].pName, speakingNPC->pName) )
 			{
 				v11 = &pParty->pHirelings[1];
 				memset(v11, 0, sizeof(NPCData));
@@ -8079,12 +8079,12 @@
 				if ( v5 < (signed int)pNPCStats->uNumNewNPCs )
 					v6[8] &= 0x7Fu;
 			}
-			if ( pParty->pHirelings[0].pName && !_strcmpi(pParty->pHirelings[0].pName, speakingNPC->pName) )
+			if ( pParty->pHirelings[0].pName && !_stricmp(pParty->pHirelings[0].pName, speakingNPC->pName) )
 			{
 				v11 = pParty->pHirelings;
 				memset(v11, 0, sizeof(NPCData));
 			}
-			else if ( pParty->pHirelings[1].pName && !_strcmpi(pParty->pHirelings[1].pName, speakingNPC->pName) )
+			else if ( pParty->pHirelings[1].pName && !_stricmp(pParty->pHirelings[1].pName, speakingNPC->pName) )
 			{
 				v11 = &pParty->pHirelings[1];
 				memset(v11, 0, sizeof(NPCData));
--- a/mm7_5.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/mm7_5.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -1640,7 +1640,7 @@
           {
             EventProcessor(dword_5C3418, 0, 1, dword_5C341C);
           }
-          if ( !_strcmpi(byte_6BE3B0, "d05.blv") )
+          if ( !_stricmp(byte_6BE3B0, "d05.blv") )
             pParty->uTimePlayed += 1474560i64;
           continue;
         case UIMSG_TransitionWindowCloseBtn:
@@ -1734,7 +1734,7 @@
               bUnderwater = 1;
               pGame->uFlags2 |= 8u;
             }
-            if ( !_strcmpi(pCurrentMapName, "out15.odm") || !_strcmpi(pCurrentMapName, "d47.blv") )
+            if ( !_stricmp(pCurrentMapName, "out15.odm") || !_stricmp(pCurrentMapName, "d47.blv") )
               bNoNPCHiring = 1;
             PrepareToLoadODM(1u, (OutdoorCamera *)1);
             pAudioPlayer->SetMapEAX();
@@ -2013,7 +2013,7 @@
           pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[dword_506338], 0, 0, -1, 0, dword_50633C, 0, 0);
           if ( bRecallingBeacon )
           {
-            if ( _strcmpi(pCurrentMapName, (const char *)&pGames_LOD->pSubIndices[HIWORD(pNPCData4->uProfession)]) )
+            if ( _stricmp(pCurrentMapName, (const char *)&pGames_LOD->pSubIndices[HIWORD(pNPCData4->uProfession)]) )
             {
               SaveGame(1, 0);
               OnMapLeave();
@@ -2069,7 +2069,7 @@
             if ( (signed int)pGames_LOD->uNumSubDirs / 2 <= 0 )
               continue;
             uAction = 0;
-            while ( _strcmpi((const char *)pGames_LOD->pSubIndices + uAction, pCurrentMapName) )
+            while ( _stricmp((const char *)pGames_LOD->pSubIndices + uAction, pCurrentMapName) )
             {
               ++thisg;
               uAction += 32;
@@ -2288,7 +2288,7 @@
               thish = 0;
               do
               {
-                if ( !_strcmpi((const char *)&pGames_LOD->pSubIndices[thish], Str2) )
+                if ( !_stricmp((const char *)&pGames_LOD->pSubIndices[thish], Str2) )
                   break;
                 ++thish;
                 pNPCData3 = (NPCData *)((char *)pNPCData3 + 1);
@@ -2667,8 +2667,8 @@
             pPlayer10->PlaySound(SPEECH_12, 0);
           byte_506550 = 0;
           continue;
-        case UIMSG_33:
-			__debugbreak();
+        case UIMSG_SpellBook_PressTab:
+			//__debugbreak();
           if ( !uActiveCharacter )
             continue;
           pPlayer3 = pPlayers[uActiveCharacter];
@@ -2856,8 +2856,7 @@
           ++pMessageQueue_50CBD0->uNumMessages;*/
           pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
           continue;
-        case UIMSG_C0:
-			__debugbreak();
+        case UIMSG_ClickAwardScrollBar:
           dword_50651C = 1;
           if ( pMouse->GetCursorPos(&v211)->y > 178 )
             dword_50651C = -1;
@@ -4446,7 +4445,7 @@
         case PLAYER_SKILL_STAFF:
           if (main_hand_mastery >= 3)
           {
-            if (rand() % 100 < player->GetActualSkillLevel(PLAYER_SKILL_STAFF) & 0x3F)  // stun chance when mastery >= 3
+            if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_STAFF) & 0x3F))  // stun chance when mastery >= 3
               hit_will_stun = true;
           }
         break;
@@ -4454,12 +4453,12 @@
         case PLAYER_SKILL_MACE:
           if (main_hand_mastery >= 3)
           {
-            if (rand() % 100 < player->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F)
+            if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F))
               hit_will_stun = true;
           }
           if (main_hand_mastery >= 4)
           {
-            if (rand() % 100 < player->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F)
+            if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F))
               hit_will_paralyze = true;
           }
         break;
@@ -5938,89 +5937,6 @@
 }
 // A750D8: using guessed type __int64 qword_A750D8;
 
-//----- (0043EF2B) --------------------------------------------------------
-void __fastcall WetsuitOn(unsigned int uPlayerID)
-{
-  unsigned int v1; // ebx@1
-  Player **v2; // esi@2
-  enum CHARACTER_RACE v3; // edi@2
-  signed int v4; // eax@2
-  int v5; // ecx@5
-  unsigned __int8 v6; // al@7
-  char pContainer[20]; // [sp+4h] [bp-1Ch]@7
-  unsigned int v8; // [sp+18h] [bp-8h]@1
-  int v9; // [sp+1Ch] [bp-4h]@7
-
-  v1 = uPlayerID - 1;
-  v8 = uPlayerID;
-  if ( (uPlayerID - 1) >= 0 )
-  {
-    v2 = &pPlayers[uPlayerID];
-    v3 = (*v2)->GetRace();
-    v4 = (*v2)->GetSexByVoice();
-    if ( v3 && v3 != 1 && v3 != 2 )
-      v5 = (v4 != 0) + 3;
-    else
-      v5 = (v4 != 0) + 1;
-    v9 = v5;
-    wsprintfA(pContainer, "pc23v%dBod", v5);
-    papredoll_dbods[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-    wsprintfA(pContainer, "pc23v%dlad", v9);
-    papredoll_dlads[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-    wsprintfA(pContainer, "pc23v%dlau", v9);
-    papredoll_dlaus[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-    wsprintfA(pContainer, "pc23v%drh", v9);
-    papredoll_drhs[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-    wsprintfA(pContainer, "pc23v%dlh", v9);
-    papredoll_dlhs[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-    wsprintfA(pContainer, "pc23v%dlhu", v9);
-    papredoll_dlhus[v1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-    v6 = pPlayers[v1 + 1]->uCurrentFace;
-    if ( v6 == 12 || v6 == 13 )
-      papredoll_dbrds[pPlayers[v8]->uCurrentFace] = 0;
-    papredoll_flying_feet[pPlayers[v8]->uCurrentFace] = 0;
-    IsPlayerWearingWatersuit[v8] = 1;
-  }
-}
-
-//----- (0043F0BD) --------------------------------------------------------
-unsigned int __fastcall WetsuitOff(unsigned int uPlayerID)
-{
-  unsigned int result; // eax@1
-  Player **v2; // edi@2
-  unsigned int v3; // ebx@2
-  int v4; // ebx@2
-  char v5; // al@2
-  char pContainer[20]; // [sp+0h] [bp-18h]@4
-  unsigned int v7; // [sp+14h] [bp-4h]@1
-
-  result = uPlayerID - 1;
-  v7 = uPlayerID;
-  if ( ((uPlayerID - 1) & 0x80000000u) == 0 )
-  {
-    v2 = &pPlayers[uPlayerID];
-    v3 = uPlayerID - 1;
-    papredoll_dbods[v3] = pIcons_LOD->LoadTexture(dbod_texnames_by_face[(*v2)->uCurrentFace], TEXTURE_16BIT_PALETTE);
-    papredoll_dlads[v3] = pIcons_LOD->LoadTexture(dlad_texnames_by_face[(*v2)->uCurrentFace], TEXTURE_16BIT_PALETTE);
-    papredoll_dlaus[v3] = pIcons_LOD->LoadTexture(dlau_texnames_by_face[(*v2)->uCurrentFace], TEXTURE_16BIT_PALETTE);
-    papredoll_drhs[v3] = pIcons_LOD->LoadTexture(drh_texnames_by_face[(*v2)->uCurrentFace], TEXTURE_16BIT_PALETTE);
-    papredoll_dlhs[v3] = pIcons_LOD->LoadTexture(dlh_texnames_by_face[(*v2)->uCurrentFace], TEXTURE_16BIT_PALETTE);
-    papredoll_dlhus[v3] = pIcons_LOD->LoadTexture(dlhu_texnames_by_face[(*v2)->uCurrentFace], TEXTURE_16BIT_PALETTE);
-    v4 = (int)&(*v2)->uCurrentFace;
-    v5 = *(char *)v4;
-    if ( *(char *)v4 == 12 || v5 == 13 )
-    {
-      wsprintfA(pContainer, "pc%02dbrd", v5 + 1);
-      v4 = (int)&(*v2)->uCurrentFace;
-      papredoll_dbrds[*(char *)v4] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-    }
-    wsprintfA(pContainer, "item281pc%02d", *(char *)v4 + 1);
-    papredoll_flying_feet[(*v2)->uCurrentFace] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-    result = v7;
-    IsPlayerWearingWatersuit[v7] = 0;
-  }
-  return result;
-}
 
 //----- (0043F333) --------------------------------------------------------
 void BspRenderer::MakeVisibleSectorList()
@@ -7203,7 +7119,7 @@
         if ( SHIDWORD(v6->pActorBuffs[6].uExpireTime) >= result
           && (SHIDWORD(v6->pActorBuffs[6].uExpireTime) > result || LODWORD(v6->pActorBuffs[6].uExpireTime) > result) )
           result = 1;
-        if ( !(v13 | result | v6->uAIState == 5 | v6->uAIState == 11 | v6->uAIState == 19) )
+        if ( !(v13 != 0 || result || v6->uAIState == 5 || v6->uAIState == 11 || v6->uAIState == 19) )
         {
           v13 = ai_near_actors_targets_pid[v5];
           memcpy(&v9, Actor::GetDirectionInfo(a1, v13, &a3, 0), sizeof(v9));
@@ -7924,14 +7840,14 @@
       break;
     v20 = v19;
     v21 = dword_4F5CC4_ys[v20 + 2];
-    if ( v18 ^ v21 >= v8 )
+    if ( v18 ^ (v21 >= v8) )
     {
       v22 = dword_4F5D98_xs[v20 + 1];
       if ( v22 >= a4a )
         v23 = 0;
       else
         v23 = 2;
-      v24 = v23 | dword_4F5D98_xs[v20] < a4a;
+      v24 = v23 | (dword_4F5D98_xs[v20] < a4a);
       if ( v24 != 3 )
       {
         if ( !v24
@@ -8059,14 +7975,14 @@
       break;
     v17 = v25;
     v18 = dword_4F5B24_ys[v25 + 2];
-    if ( v16 ^ v18 >= a3 )
+    if ( v16 ^ (v18 >= a3) )
     {
       v19 = dword_4F5BF4_xs[v17 + 2];
       if ( v19 >= a4a )
         v20 = 0;
       else
         v20 = 2;
-      v21 = v20 | dword_4F5BF4_xs[v17 + 1] < a4a;
+      v21 = v20 | (dword_4F5BF4_xs[v17 + 1] < a4a);
       if ( v21 != 3 )
       {
         if ( !v21
@@ -8866,9 +8782,9 @@
   v6 = 0;
   v7 = 0;
   v5 = 0;
-  if ( !_strcmpi(pCurrentMapName, "d25.blv") )
+  if ( !_stricmp(pCurrentMapName, "d25.blv") )
     v8 = 1;
-  if ( !_strcmpi(pCurrentMapName, "d26.blv") )
+  if ( !_stricmp(pCurrentMapName, "d26.blv") )
     v6 = 1;
   if (_449B57_test_bit(pParty->_quest_bits, 99))
     v7 = 1;
@@ -9557,7 +9473,7 @@
 
   v1 = a1;
   v2 = 1;
-  if ( _strcmpi(pMapStats->pInfos[1].pFilename, (const char *)&pGames_LOD->pSubIndices[a1]) )
+  if ( _stricmp(pMapStats->pInfos[1].pFilename, (const char *)&pGames_LOD->pSubIndices[a1]) )
   {
     v3 = (const char **)&pMapStats->pInfos[1].pFilename;
     v4 = (char *)&pMapStats->pInfos[1].pFilename;
@@ -9569,7 +9485,7 @@
       ++v2;
       v4 = (char *)v3;
     }
-    while ( _strcmpi(*v3, (const char *)&pGames_LOD->pSubIndices[v1]) );
+    while ( _stricmp(*v3, (const char *)&pGames_LOD->pSubIndices[v1]) );
   }
   return v2;
 }
@@ -11044,10 +10960,10 @@
     {
       if ( i->msg == UIMSG_InventoryLeftClick )
       {
-        dword_50698C = i->uX;
-        dword_506988 = i->uY;
-        dword_506984 = i->uZ;
-        dword_506980 = i->uW;
+        dword_50698C_uX = i->uX;
+        dword_506988_uY = i->uY;
+        dword_506984_uZ = i->uZ;
+        dword_506980_uW = i->uW;
         i->uW = 0;
         i->uZ = 0;
         i->uY = 0;
@@ -11066,7 +10982,7 @@
                    1, 0, UIMSG_ClickAwardsDownBtn, 0, 0, "",
                    pIcons_LOD->GetTexture(uTextureID_ar_dn_up),
                    pIcons_LOD->GetTexture(uTextureID_ar_dn_dn), 0);
-    ptr_507BA4 = pGUIWindow_CurrentMenu->CreateButton(440, 62, 16, 232, 1, 0, UIMSG_C0, 0, 0, "", 0);
+    ptr_507BA4 = pGUIWindow_CurrentMenu->CreateButton(440, 62, 16, 232, 1, 0, UIMSG_ClickAwardScrollBar, 0, 0, "", 0);
   }
 }
 
@@ -11089,10 +11005,10 @@
     {
       if ( pButton->msg == UIMSG_InventoryLeftClick )
       {
-        pButton->uX = dword_50698C;
-        pButton->uY = dword_506988;
-        pButton->uZ = dword_506984;
-        pButton->uW = dword_506980;
+        pButton->uX = dword_50698C_uX;
+        pButton->uY = dword_506988_uY;
+        pButton->uZ = dword_506984_uZ;
+        pButton->uW = dword_506980_uW;
         pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(1, 0, 0, 0);
       }
     }
--- a/mm7_6.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/mm7_6.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -2148,7 +2148,7 @@
             a5 |= 0x0002;
             break;
           }
-          else if ((player->pActiveSkills[PLAYER_SKILL_SPIRIT] & 0x1C0) == 0);
+          else if ((player->pActiveSkills[PLAYER_SKILL_SPIRIT] & 0x1C0) == 0)
             //goto LABEL_25;
           {
             a5 |= 0x0002;
@@ -2560,7 +2560,7 @@
   int v505; // eax@943
   int v507; // edi@944
   signed int v509; // eax@944
-  signed int v510; // edi@944
+  //signed int v510; // edi@944
   Actor *v518; // edx@957
   __int16 v519; // cx@958
   int v531; // eax@982
@@ -2599,7 +2599,7 @@
   AwardType *v607; // ecx@1100
   __int16 v608; // ax@1102
   signed int v609; // eax@1104
-  int v610; // edi@1106
+  //int v610; // edi@1106
   unsigned int v611; // eax@1106
   Player *v612; // edi@1106
   DDM_DLV_Header *v613; // eax@1108
@@ -2647,7 +2647,7 @@
   Vec3_int_ v701; // [sp+D68h] [bp-11Ch]@286
   Vec3_int_ v704; // [sp+D74h] [bp-110h]@132
   Vec3_int_ v707; // [sp+D80h] [bp-104h]@1127
-  char v710; // [sp+D8Ch] [bp-F8h]@1156
+  int v710; // [sp+D8Ch] [bp-F8h]@1156
   __int64 v712; // [sp+D94h] [bp-F0h]@991
   int v713; // [sp+D9Ch] [bp-E8h]@324
   int n; // [sp+DA0h] [bp-E4h]@1
@@ -2829,7 +2829,7 @@
 			pSpellSprite.spell_id = pCastSpell->spellnum;
 			pSpellSprite.spell_skill = v731;
 			pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType);
-			if ( pPlayer->WearsItem(510, 2) )
+			if ( pPlayer->WearsItem(ITEM_ARTEFACT_ULLYSES, EQUIP_BOW) )
 				pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(0xBD6u);
 			pSpellSprite.vPosition.x = pParty->vPosition.x;
 			pSpellSprite.vPosition.y = pParty->vPosition.y;
@@ -2842,7 +2842,7 @@
 			pSpellSprite.uFacing = LOWORD(v715.uYawAngle);
 			pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 			pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID];
-			memcpy(&pSpellSprite.stru_24, &pPlayer[pPlayer->pEquipment.uBow], sizeof(pSpellSprite.stru_24));
+			memcpy(&pSpellSprite.stru_24, &pPlayer->pInventoryItems[pPlayer->pEquipment.uBow-1], sizeof(pSpellSprite.stru_24));
 			pSpellSprite.uAttributes = 256;
 			if ( pParty->bTurnBasedModeOn == 1 )
 				pSpellSprite.uAttributes = 260;
@@ -3041,7 +3041,7 @@
 			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);
+			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), &v704);
 			LODWORD(v727) = 1;
@@ -3490,7 +3490,7 @@
 				LODWORD(v727) = 1;
 				do
 				{
-					if ( v92->pConditions )
+					if ( v92->pConditions[1] )
 						LODWORD(v727) = 0;
 					++v92;
 				}
@@ -3757,7 +3757,7 @@
 					pSpellSprite.vPosition.x = uRequiredMana;
 					pSpellSprite.vPosition.y = LODWORD(v727);
 					pSpellSprite.uSectorID = 0;
-					pSpellSprite.vPosition.z = a2 + v713;
+					pSpellSprite.vPosition.z = a2 + v154;
 					pSpellSprite.uSpriteFrameID = 0;
 					pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
 					pSpellSprite.spell_target_pid = v730;
@@ -3915,7 +3915,7 @@
 						pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed,
 						pCastSpell->uPlayerID + 1) != -1
 						&& pParty->bTurnBasedModeOn == 1 )
-				+	+pTurnEngine->field_1C;
+				    ++pTurnEngine->field_1C;
 				v188 += _v726 / (amount - 1);
 			}
 			LODWORD(v727) = 1;
@@ -4195,7 +4195,7 @@
 				pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 				if ( pParty->bTurnBasedModeOn == 1 )
 					LOBYTE(pSpellSprite.uAttributes) |= 4u;
-				v227 = SHIDWORD(v733) / -2;
+				v227 = _v733 / -2;
 				signed int _y = _v733 / 2;
 				if ( _v733 / -2 <= _v733 / 2 )
 				{
@@ -4494,7 +4494,7 @@
 		case SPELL_WATER_LLOYDS_BEACON:
 		{
 			LODWORD(v733) = 604800 * v2;
-			if ( !_strcmpi(pCurrentMapName, "d05.blv") )
+			if ( !_stricmp(pCurrentMapName, "d05.blv") )
 			{
 				ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
 				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
@@ -5627,7 +5627,7 @@
 			pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xAFF0Au, 0xC0u);
 			v505 = sub_46A6AC((int)dword_50BF30, 100, 4096);
 			++pSpellSprite.uType;
-			signed int _v733 = v505;
+			//signed int _v733 = v505;
 			v688.x = 0;
 			v688.y = 0;
 			v688.z = 0;
@@ -5644,23 +5644,17 @@
 			pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID);
 			pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 			a2 = 0;
-			if ( _v733 > 0 )
-			{
-				do
-				{
-					v507 = dword_50BF30[a2];
-					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], &v688);
-					a2 = v510 + 1;
-				}
-				while ( v510 + 1 < _v733 );
-			}
-			for ( a2 = 0; a2 < _v733; ++a2 )
+			for ( a2 = 0; a2 < v505; ++a2 )
+			{
+				v507 = dword_50BF30[a2];
+				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);
+				DamageMonsterFromParty(PID(OBJECT_Item, v509), dword_50BF30[a2], &v688);
+			}
+			for ( a2 = 0; a2 < v505; ++a2 )
 			{
 				pActor = &pActors[dword_50BF30[a2]];
 				pSpellSprite.vPosition.x = pActor->vPosition.x;
@@ -6194,7 +6188,7 @@
 			if ( (signed int)pNPCStats->uNumNewNPCs > 0)
 			{
 				pNPCData = pNPCStats->pNewNPCData;
-				__debugbreak(); // data offset
+				//__debugbreak(); // data offset
 				AwardType *_v734 = &achieved_awards[_v733];
 				do
 				{
@@ -6213,7 +6207,8 @@
 			}
 			v608 = pCastSpell->uPlayerID_2;
 			if ( v608 != 4 && v608 != 5
-				|| (v609 = (signed int)*(&pFontCChar + v608 + (unsigned __int8)pParty->field_709), v609 <= 0)
+				//|| (v609 = (signed int)*(&pFontCChar + v608 + (unsigned __int8)pParty->field_709), v609 <= 0)
+				|| (v609 = achieved_awards[v608 + (unsigned __int8)pParty->field_709 - 4], v609 <= 0)
 				|| v609 >= 3 )
 			{
 				ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
@@ -6221,13 +6216,14 @@
 				pCastSpell->spellnum = 0;
 				continue;
 			}
-			v610 = 76 * v609;
-			*((int *)&pParty->pPlayers[3].pInstalledBeacons[4].uBeaconTime + 19 * v609) = 0;
+			//v610 = 76 * v609;
+			//*((int *)&pParty->pPlayers[3].pInstalledBeacons[4].uBeaconTime + 19 * v609) = 0;
+			pParty->pHirelings[v609-1].evt_B = 0;
 			v611 = pIconsFrameTable->FindIcon("spell96");
 			//*(int *)((char *)&pParty->pPlayers[3].pInstalledBeacons[4].uBeaconTime + v610 + 4) = pIconsFrameTable->GetIconAnimLength(v611);
-			pParty->pHirelings[v609-1].evt_B = pIconsFrameTable->GetIconAnimLength(v611);
+			pParty->pHirelings[v609-1].evt_C = pIconsFrameTable->GetIconAnimLength(v611);
 			//*(int *)((char *)&pParty->pPlayers[3].pInstalledBeacons[3].field_18 + v610) = 1;
-			pParty->pHirelings[v609-1].field_24 = 1;
+			pParty->pHirelings[v609-1].evt_A = 1;
 
 			v612 = pParty->pPlayers;
 			do
@@ -6400,7 +6396,7 @@
 				v643 = rand();
 				v721 = v642 + pParty->vPosition.x;
 				y = (char *)(pParty->vPosition.y + v643 % 4096 - 2048);
-				v732 = GetTerrainHeightsAroundParty2(v642 + pParty->vPosition.x, (int)y, (int *)&v710, 0);
+				v732 = GetTerrainHeightsAroundParty2(v642 + pParty->vPosition.x, (int)y, &v710, 0);
 				v644 = rand();
 				sub_42F7EB_DropItemAt(0xFE6u, v721, (int)y, v732 + 16, v644 % 500 + 500, 1, 0, 0, 0);
 				--_v726;
@@ -6750,7 +6746,7 @@
     Vec3_int_::Normalize(&a3.x, &a3.y, &a3.z);
 
     DamageMonsterFromParty(PID(OBJECT_Player, uActiveCharacter - 1), target_id, &a3);
-    if (player->WearsItem(ITEM_ARTIFACT_SPLITTER, 1) || player->WearsItem(ITEM_ARTIFACT_SPLITTER, 0))
+    if (player->WearsItem(ITEM_ARTIFACT_SPLITTER, EQUIP_MAIN_HAND) || player->WearsItem(ITEM_ARTIFACT_SPLITTER, EQUIP_OFF_HAND))
           _42FA66_do_explosive_impact(
             actor->vPosition.x,
             actor->vPosition.y,
--- a/mm7_data.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/mm7_data.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -52,7 +52,7 @@
 Autonote pAutonoteTxt[195]; // weak
 
 #include "Awards.h"
-Award pAwards[104];
+Award pAwards[105];
 AwardType achieved_awards[1000];
 int num_achieved_awards;
 int num_achieved_awards_2;
@@ -270,14 +270,7 @@
 
 #include "MM7.h"
 
-int paperdoll_Weapon[4][16][2] = {//4E4C30
-  {{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]; //511698
-int paperdoll_belt_texture[2][7];  //511718
+
 stat_coord stat_string_coord[26] = //4E2940
 {
   {0x1A, 0x39, 0xDC, 0x12},
@@ -330,7 +323,7 @@
 };
 
 #include "stru314.h"
-
+#include "stru367.h"
 
 
 
@@ -397,8 +390,8 @@
 char aIcons[777]; // idb
 char aPending[777]; // idb
 char aCanTFindS[777]; // idb
-char *spellbook_texture_filename_suffices[8] = {"f", "a", "w", "e", "s", "m", "b", "l"}; // weak
-__int16 word_4E1D3A[777]; // weak
+char *spellbook_texture_filename_suffices[9] = {"f", "a", "w", "e", "s", "m", "b", "l", "d"}; // weak
+//__int16 word_4E1D3A[777]; // weak
 __int16 pTownPortalBook_xs[6] = {260, 324, 147, 385, 390,  19};
 __int16 pTownPortalBook_ys[6] = {206,  84, 182, 239,  17, 283};
 __int16 pTownPortalBook_ws[6] = { 80,  66,  68,  72,  67,  74};
@@ -495,10 +488,7 @@
 __int16 RightClickPortraitXmin[4]={0x14, 0x83, 0xF2, 0x165};
 __int16 RightClickPortraitXmax[4]={0x53, 0xC6, 0x138, 0x1A7};
 void *off_4E2A12; // stat_string_control_button_count
-int pArmorSkills[5]  = {PLAYER_SKILL_LEATHER, PLAYER_SKILL_CHAIN,      PLAYER_SKILL_PLATE,        PLAYER_SKILL_SHIELD,  PLAYER_SKILL_DODGE};
-int pWeaponSkills[9] = {PLAYER_SKILL_AXE,     PLAYER_SKILL_BOW,        PLAYER_SKILL_DAGGER,       PLAYER_SKILL_MACE,    PLAYER_SKILL_SPEAR,      PLAYER_SKILL_STAFF,    PLAYER_SKILL_SWORD,       PLAYER_SKILL_UNARMED,    PLAYER_SKILL_BLASTER};
-int pMiscSkills[12]  = {PLAYER_SKILL_ALCHEMY, PLAYER_SKILL_ARMSMASTER, PLAYER_SKILL_BODYBUILDING, PLAYER_SKILL_ITEM_ID, PLAYER_SKILL_MONSTER_ID, PLAYER_SKILL_LEARNING, PLAYER_SKILL_TRAP_DISARM, PLAYER_SKILL_MEDITATION, PLAYER_SKILL_MERCHANT, PLAYER_SKILL_PERCEPTION, PLAYER_SKILL_REPAIR, PLAYER_SKILL_STEALING};
-int pMagicSkills[9]  = {PLAYER_SKILL_FIRE,    PLAYER_SKILL_AIR,        PLAYER_SKILL_WATER,        PLAYER_SKILL_EARTH,   PLAYER_SKILL_SPIRIT,     PLAYER_SKILL_MIND,     PLAYER_SKILL_BODY,        PLAYER_SKILL_LIGHT,      PLAYER_SKILL_DARK};
+
 unsigned int pHealthBarPos[4] = {22, 137, 251, 366};
 unsigned int pManaBarPos[4] = {102, 217, 331, 447};
 char _4E2B21_buff_spell_tooltip_colors[80];
@@ -533,112 +523,7 @@
 int dword_4E4A40[777]; // weak
 int dword_4E4A44[777]; // weak
 float flt_4E4A80[10];
-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
-  0x0A, 0x66,  0x13, 0x64,  0x0E, 0x64,  0x0A, 0x63,  0x14, 0x66,  0x0A, 0x63,  0x0A, 0x66,  0x25, 0x66,
 
-  0x32, 0x68,  0x32, 0x69,  0x35, 0x69,  0x33, 0x68,  0x24, 0x67,  0x30, 0x69,  0x33, 0x68,  0x31, 0x69,  0x19, 0x69,
-  0x19, 0x6A,  0x16, 0x66,  0x16, 0x65,  0x0F, 0x6B,  0x24, 0x67,  0x0F, 0x6B,  0x19, 0x6A,  0x31, 0x69,
-
-  0x2A, 0x8C,  0x29, 0x8C,  0x2A, 0x89,  0x29, 0x86,  0x12, 0x87,  0x2D, 0x89,  0x2A, 0x88,  0x25, 0x87,  0x12, 0x8B,
-  0x12, 0x8B,  0x11, 0x8A,  0x15, 0x87,  0x09, 0x89,  0x12, 0x87,  0x09, 0x89,  0x12, 0x8B,  0x25, 0x87,
-
-  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] = //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,
-
-  0x60, 0x6B,  0x60, 0x6C,  0x60, 0x6B,  0x61, 0x6A,  0x60, 0x69,  0x60, 0x6A,  0x60, 0x6A,  0x61, 0x69,  0x63, 0x6A,
-  0x64, 0x6A,  0x61, 0x66,  0x66, 0x67,  0x64, 0x6C,  0x60, 0x69,  0x64, 0x6C,  0x64, 0x6A,  0x61, 0x69,
-
-  0x6D, 0x8C,  0x75, 0x8C,  0, 0,        0x72, 0x8D,  0x6A, 0x89,  0, 0,        0x73, 0x8C,  0x69, 0x8C,  0x6E, 0x8D,
-  0x71, 0x8D,  0x70, 0x8D,  0x72, 0x8D,  0x74, 0x8E,  0x6A, 0x89,  0x74, 0x8E,  0x71, 0x8D,  0x69, 0x8C,
-
-  0x72, 0x91,  0x72, 0x91,  0, 0,        0x6E, 0x92,  0x6F, 0x91,  0, 0,        0, 0,        0x6E, 0x91,  0x71, 0x90,
-  0x72, 0x8D,  0x72, 0x90,  0x73, 0x93,  0x73, 0x90,  0x6F, 0x91,  0x73, 0x90,  0x72, 0x8D,  0x6E, 0x91,
-};
-int dword_4E5270[4][2] = 
-{
-  0, 0,
-  0x61, 0x67,
-  0, 0,
-  0x64, 0x69,
-};
-int paperdoll_Boot[4][7][2] = //4E5490
-{
-  0xE, 0x11D,    0xD, 0x11D,    0xC, 0x10A,    0xA, 0xFF,    0xD, 0xF9,    0xD, 0x137,   0xC, 0x10E,
-  0x14, 0x125,   0x13, 0x122,   0x15, 0x120,   0x15, 0x114,  0x13, 0x10A,  0x11, 0x13E,  0x11, 0x116,
-  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] = //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] = //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,
-  0, 0,        0x30, 0x87,  0x1E, 0x86,  0x1B, 0x86,  0x1C, 0x8A,  0x21, 0x87,  0x30, 0x87,  0x1E, 0x86,  0x1B, 0x86,  0x1C, 0x8A,
-  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] = //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] = //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 pPaperdoll_Beards[4] = //4E5AD0
-{
- 52, 130, 56, 136,
-};
-int pPaperdoll_LeftHand[4][2] = //4E5AE0
-{
-  0x67, 0x6A,
-  0x65, 0x6C,
-  0x74, 0x8D,
-  0x74, 0x93,
-};
-int pPaperdoll_SecondLeftHand[4][2] = //4E5B00
-{
-  0x1A, 0x6B,
-  0x28, 0x6D,
-  0x19, 0x8D,
-  0x20, 0x92,
-};
-int pPaperdoll_RightHand[4][2] = //4E5B20
-{
-  0x1E, 0x90,
-  0x22, 0x9E,
-  0x19, 0xBA,
-  0x1F, 0xB8,
-};
-int pPaperdollLeftEmptyHand[4][2] = //4E5B40
-{
-  0x80, 0xCD,
-  0x83, 0xC9,
-  0x83, 0xD8,
-  0x7B, 0xD8,
-};
 
 int pPartySpellbuffsUI_XYs[14][2] =
 {
@@ -710,55 +595,7 @@
   "pc21-", "pc22-", "pc23", "pc24-", "pc25-"
 };
 
-const char *dlad_texnames_by_face[25] =
-{
-  "pc01lad", "pc02lad", "pc03lad", "pc04lad", "pc05lad", "pc06lad",
-  "pc07lad", "pc08lad", "pc09lad", "pc10lad", "pc11lad", "pc12lad",
-  "pc13lad", "pc14lad", "pc15lad", "pc16lad", "pc17lad", "pc18lad",
-  "pc19lad", "pc20lad", "pc21lad", "pc22lad", "pc23lad", "pc24lad",
-  "pc25lad"
-};
-const char *dlau_texnames_by_face[25] =
-{
-  "pc01lau", "pc02lau", "pc03lau", "pc04lau", "pc05lau", "pc06lau",
-  "pc07lau", "pc08lau", "pc09lau", "pc10lau", "pc11lau", "pc12lau",
-  "pc13lau", "pc14lau", "pc15lau", "pc16lau", "pc17lau", "pc18lau",
-  "pc19lau", "pc20lau", "pc21lau", "pc22lau", "pc23lau", "pc24lau",
-  "pc25lau"
-};
-const char *dbod_texnames_by_face[25] =
-{
-  "pc01bod", "pc02bod", "pc03bod", "pc04bod", "pc05bod", "pc06bod",
-  "pc07bod", "pc08bod", "pc09bod", "pc10bod", "pc11bod", "pc12bod",
-  "pc13bod", "pc14bod", "pc15bod", "pc16bod", "pc17bod", "pc18bod",
-  "pc19bod", "pc20bod", "pc21bod", "pc22bod", "pc23bod", "pc24bod",
-  "pc25bod"
-};
-const char *drh_texnames_by_face[25] =
-{
 
-  "pc01rh", "pc02rh", "pc03rh", "pc04rh", "pc05rh", "pc06rh",
-  "pc07rh", "pc08rh", "pc09rh", "pc10rh", "pc11rh", "pc12rh",
-  "pc13rh", "pc14rh", "pc15rh", "pc16rh", "pc17rh", "pc18rh",
-  "pc19rh", "pc20rh", "pc21rh", "pc22rh", "pc23rh", "pc24rh",
-  "pc25rh"
-};
-const char *dlh_texnames_by_face[25] =
-{
-  "pc01lh", "pc02lh", "pc03lh", "pc04lh", "pc05lh", "pc06lh",
-  "pc07lh", "pc08lh", "pc09lh", "pc10lh", "pc11lh", "pc12lh",
-  "pc13lh", "pc14lh", "pc15lh", "pc16lh", "pc17lh", "pc18lh",
-  "pc19lh", "pc20lh", "pc21lh", "pc22lh", "pc23lh", "pc24lh",
-  "pc25lh"
-};
-const char *dlhu_texnames_by_face[25] =
-{
-  "pc01lhu", "pc02lhu", "pc03lhu", "pc04lhu", "pc05lhu", "pc06lhu",
-  "pc07lhu", "pc08lhu", "pc09lhu", "pc10lhu", "pc11lhu", "pc12lhu",
-  "pc13lhu", "pc14lhu", "pc15lhu", "pc16lhu", "pc17lhu", "pc18lhu",
-  "pc19lhu", "pc20lhu", "pc21lhu", "pc22lhu", "pc23lhu", "pc24lhu",
-  "pc25lhu"
-};
 
 unsigned char byte_4ECF08[48][25] =      // 4ECF08
 {
@@ -1160,10 +997,10 @@
 //unsigned __int8 bMonsterInfoUI_bDollInitialized;
 char *aSpellNames[44];
 int pMainScreenNum; // weak
-int dword_506980; // weak
-int dword_506984; // weak
-int dword_506988; // weak
-int dword_50698C; // weak
+int dword_506980_uW; // weak
+int dword_506984_uZ; // weak
+int dword_506988_uY; // weak
+int dword_50698C_uX; // weak
 int uGameMenuUI_CurentlySelectedKeyIdx; // 506E68
 unsigned int pPrevVirtualCidesMapping[27];
 int KeyboardPageNum; // weak
@@ -1201,33 +1038,34 @@
 unsigned int uActiveCharacter;
 int dword_507BF0_is_there_popup_onscreen; // weak
 int dword_507CBC; // weak
-int dword_507CC0; // weak
+int dword_507CC0_activ_ch; // weak
 __int64 GameUI_RightPanel_BookFlashTimer; // weak
 int _507CD4_RestUI_hourglass_anim_controller; // weak
 int dword_507CD8; // weak
-int dword_50B570[777]; // weak
-int dword_50B638[777]; // weak
-int dword_50B700; // weak
-int dword_50B738[777]; // idb
-int _50B744_view_transformed_ys[45];
-int dword_50B828[777];
-int _50B834_view_transformed_zs[45];
-int dword_50B918[777];
-int _50B924_view_transformed_xs[45];
-int _50B9D8_screen_space_y[777];
-int dword_50B9E4[777];
-int dword_50B9F0[2]; // idb
-int dword_50B9FC_ys[3 + 45];
-int dword_50BA08_ys[48]; // idb
-int _50BAC8_screen_space_x[777]; // idb
-int dword_50BAD4[777]; // weak
-int dword_50BAE0[777]; // weak
+int dword_50B570[50]; // weak
+int dword_50B638[50]; // weak
+stru367 stru_50B700;
+/*int stru_50B700.field_0; // weak
+int stru_50B700.field_38[777]; // idb
+int stru_50B700._view_transformed_ys[45];
+int stru_50B700.field_128[777];
+int stru_50B700._view_transformed_zs[45];
+int stru_50B700.field_218[777];
+int stru_50B700._view_transformed_xs[45];
+int stru_50B700._screen_space_y[777];
+int stru_50B700.field_3E4[777];
+int stru_50B700.field_2F0[2]; // idb
+int stru_50B700._ys[3 + 45];
+int stru_50B700._ys2[48]; // idb
+int stru_50B700._screen_space_x[777]; // idb
+int stru_50B700.field_3D4[777]; // weak
+int stru_50B700._xs[777]; // weak
 int dword_50BAE8[777]; // weak
-int dword_50BAEC_xs[3 + 45]; // weak
-int dword_50BAF8_xs[48]; // weak
-int dword_50BC10[777]; // weak
-int dword_50BDA0[777]; // weak
-int dword_50BF30[777]; // weak
+int stru_50B700._xs2[3 + 45]; // weak
+int stru_50B700._xs3[48]; // weak*/
+int dword_50BC10[100]; // weak
+int dword_50BDA0[100]; // weak
+int dword_50BF30[100]; // weak
 char town_portal_caster_id; // weak
 int some_active_character; // weak
 //_UNKNOWN unk_50C190; // weak
@@ -1258,19 +1096,7 @@
 unsigned __int8 IsPlayerWearingWatersuit[5];
 char party_has_equipment[54];
 char byte_5111F6[16];
-unsigned int papredoll_dbrds[16];
-unsigned int papredoll_drhs[4];
-unsigned int papredoll_dlhus[4];
-unsigned int papredoll_dlhs[4];
-unsigned int papredoll_dbods[5];
-int paperdoll_armor_texture[4][17][3];
-//int paperdoll_array_51132C[165];
-unsigned int papredoll_dlaus[5];
-unsigned int papredoll_dlads[4];
-int papredoll_flying_feet[777]; // idb
-int paperdoll_boots_texture[4][6];//0x511638
-int paperdoll_cloak_collar_texture[4][10]; // weak
-int paperdoll_cloak_texture[4][10];
+
 int _unused000; // weak
 
 unsigned __int16 pOdmMinimap[117][137];
@@ -1288,7 +1114,7 @@
 int dword_591084; // weak
 struct Actor *pDialogue_SpeakingActor;
 unsigned int uDialogueType;
-signed int sDialogue_SpeakingActorNPC_ID;
+int sDialogue_SpeakingActorNPC_ID;
 struct LevelDecoration *_591094_decoration;
 char sHouseName[200]; // idb
 int uCurrentHouse_Animation; // weak
--- a/mm7_data.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/mm7_data.h	Sat Jun 01 10:32:31 2013 +0600
@@ -332,7 +332,6 @@
 extern char aIcons[]; // idb
 extern char aPending[]; // idb
 extern char aCanTFindS[]; // idb
-extern int paperdoll_Weapon[4][16][2];
 extern char *spellbook_texture_filename_suffices[]; // weak
 extern __int16 word_4E1D3A[]; // weak
 extern __int16 pTownPortalBook_xs[6];
@@ -427,10 +426,10 @@
 extern __int16 RightClickPortraitXmin[4];
 extern __int16 RightClickPortraitXmax[4];
 extern void *off_4E2A12; // weak
-extern int pArmorSkills[5];
-extern int pWeaponSkills[9];
-extern int pMiscSkills[12];
-extern int pMagicSkills[9];
+//extern int pArmorSkills[5];
+//extern int pWeaponSkills[9];
+//extern int pMiscSkills[12];
+//extern int pMagicSkills[9];
 extern unsigned int pHealthBarPos[4];
 extern unsigned int pManaBarPos[4];
 extern char _4E2B21_buff_spell_tooltip_colors[80];
@@ -455,23 +454,7 @@
 extern int dword_4E4A40[]; // weak
 extern int dword_4E4A44[]; // weak
 extern float flt_4E4A80[10];
-extern int pPaperdoll_BodyX; // weak
-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 paperdoll_Belt[4][7][2];
-extern int paperdoll_Helm[4][16][2];
-extern int pPaperdoll_Beards[4]; // weak
-extern int pPaperdoll_LeftHand[4][2];
-extern int pPaperdoll_SecondLeftHand[4][2];
-extern int pPaperdoll_RightHand[4][2];
-extern int pPaperdollLeftEmptyHand[4][2];
+
 extern int pPartySpellbuffsUI_XYs[14][2];
 extern unsigned char byte_4E5DD8[]; // weak
 extern unsigned __int8 pPartySpellbuffsUI_smthns[14];
@@ -499,12 +482,7 @@
 extern int dword_4EC2A8; // weak
 extern int dword_4EC2AC; // weak
 extern const char *pPlayerPortraitsNames[25];
-extern const char *dlad_texnames_by_face[25];
-extern const char *dlau_texnames_by_face[25];
-extern const char *dbod_texnames_by_face[25];
-extern const char *drh_texnames_by_face[25];
-extern const char *dlh_texnames_by_face[25];
-extern const char *dlhu_texnames_by_face[25];
+
 extern unsigned char byte_4ECF08[48][25];
 extern unsigned char SoundSetAction[110][8]; // weak
 extern __int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[4];
@@ -651,10 +629,10 @@
 //extern unsigned __int8 bMonsterInfoUI_bDollInitialized;
 extern char *aSpellNames[44];
 extern int pMainScreenNum; // weak
-extern int dword_506980; // weak
-extern int dword_506984; // weak
-extern int dword_506988; // weak
-extern int dword_50698C; // weak
+extern int dword_506980_uW; // weak
+extern int dword_506984_uZ; // weak
+extern int dword_506988_uY; // weak
+extern int dword_50698C_uX; // weak
 extern int uGameMenuUI_CurentlySelectedKeyIdx; // 506E68
 extern bool GameMenuUI_InvaligKeyBindingsFlags[28]; // 506E6C
 extern unsigned int pPrevVirtualCidesMapping[27];
@@ -693,30 +671,31 @@
 extern unsigned int uActiveCharacter;
 extern int dword_507BF0_is_there_popup_onscreen; // weak
 extern int dword_507CBC; // weak
-extern int dword_507CC0; // weak
+extern int dword_507CC0_activ_ch; // weak
 extern __int64 GameUI_RightPanel_BookFlashTimer; // weak
 extern int _507CD4_RestUI_hourglass_anim_controller; // weak
 extern int dword_507CD8; // weak
 extern int dword_50B570[]; // weak
 extern int dword_50B638[]; // weak
-extern int dword_50B700; // weak
-extern int dword_50B738[]; // idb
-extern int _50B744_view_transformed_ys[];
-extern int dword_50B828[];
-extern int _50B834_view_transformed_zs[];
-extern int dword_50B918[];
-extern int _50B924_view_transformed_xs[];
-extern int _50B9D8_screen_space_y[];
-extern int dword_50B9E4[];
-extern int dword_50B9F0[]; // idb
-extern int dword_50B9FC_ys[];
-extern int dword_50BA08_ys[]; // idb
-extern int _50BAC8_screen_space_x[]; // idb
-extern int dword_50BAD4[]; // weak
-extern int dword_50BAE0[]; // weak
+extern struct stru367 stru_50B700;
+/*extern int stru_50B700.field_0; // weak
+extern int stru_50B700.field_38[]; // idb
+extern int stru_50B700._view_transformed_ys[];
+extern int stru_50B700.field_128[];
+extern int stru_50B700._view_transformed_zs[];
+extern int stru_50B700.field_218[];
+extern int stru_50B700._view_transformed_xs[];
+extern int stru_50B700._screen_space_y[];
+extern int stru_50B700.field_3E4[];
+extern int stru_50B700.field_2F0[]; // idb
+extern int stru_50B700._ys[];
+extern int stru_50B700._ys2[]; // idb
+extern int stru_50B700._screen_space_x[]; // idb
+extern int stru_50B700.field_3D4[]; // weak
+extern int stru_50B700._xs[]; // weak
 extern int dword_50BAE8[]; // weak
-extern int dword_50BAEC_xs[]; // weak
-extern int dword_50BAF8_xs[]; // weak
+extern int stru_50B700._xs2[]; // weak
+extern int stru_50B700._xs3[]; // weak*/
 extern int dword_50BC10[]; // weak
 extern int dword_50BDA0[]; // weak
 extern int dword_50BF30[]; // weak
@@ -751,18 +730,7 @@
 extern char party_has_equipment[54];
 extern char byte_5111F6[];
 extern unsigned int papredoll_dbrds[16];
-extern unsigned int papredoll_drhs[4];
-extern unsigned int papredoll_dlhus[4];
-extern unsigned int papredoll_dlhs[4];
-extern unsigned int papredoll_dbods[5];
-extern int paperdoll_armor_texture[4][17][3];//0x511290
-//extern int paperdoll_array_51132C[165];
-extern unsigned int papredoll_dlaus[5];
-extern unsigned int papredoll_dlads[4];
-extern int papredoll_flying_feet[]; // idb
-extern int paperdoll_boots_texture[4][6];
-extern int paperdoll_cloak_collar_texture[4][10]; // weak
-extern int paperdoll_cloak_texture[4][10];
+
 extern int bRingsShownInCharScreen; // weak
 extern int _unused000; // weak
 
@@ -1054,7 +1022,7 @@
 extern int terrain_76DFC8[128];
 extern int terrain_76E1C8[128];
 extern int terrain_76E3C8[128];
-extern struct unk_F7B60C
+struct unk_F7B60C
 {
  int   some_data_ptr;  // dword @ 000000
  float flt_000004;
@@ -1342,8 +1310,8 @@
 bool __thiscall sub_43EDB9_get_some_race_sex_relation_2(unsigned int _this);
 bool __fastcall Player_has_item(unsigned int uItemID, struct Player *pPlayer, char a3);
 bool __fastcall sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(signed int a1);
-void __fastcall WetsuitOn(unsigned int uPlayerID); // idb
-unsigned int __fastcall WetsuitOff(unsigned int uPlayerID);
+void  WetsuitOn(unsigned int uPlayerID); // idb
+void  WetsuitOff(unsigned int uPlayerID);
 void __fastcall PrepareDrawLists_BLV(struct IndoorLocation_drawstru *_this);
 int /*__usercall*/ sr_sub_4D6FB0/*<eax>*/(struct stru315 *a1/*<ebp>*/);
 int /*__usercall*/ sr_sub_4D705A/*<eax>*/(struct stru315 *a1/*<ebp>*/);
@@ -1374,7 +1342,7 @@
 void __cdecl sub_4452BB();
 const char *GetProfessionActionText(int a1);
 struct NPCData *__fastcall GetNPCData(signed int npcid);
-struct NPCData *__fastcall GetNewNPCData(signed int npcid, int a2);
+struct NPCData * GetNewNPCData(signed int npcid, int* npc_indx);
 int __fastcall GetGreetType(signed int SpeakingNPC_ID);
 void __cdecl DialogueEnding();
 void PrepareHouse(enum HOUSE_ID house); // idb
@@ -1414,6 +1382,7 @@
 int __fastcall MakeColorMaskFromBitDepth(int a1);
 void __fastcall fill_pixels_fast(unsigned int a1, unsigned __int16 *pPixels, unsigned int uNumPixels);
 int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides); // idb
+inline int round(float x) { return (floor(x + 0.5)); }
 inline void __fastcall memset32(void *ptr, unsigned __int32 value, int count)
 {
   auto p = (unsigned __int32 *)ptr;
--- a/stru10.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/stru10.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -775,7 +775,7 @@
   //if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS)
  //   pGame->pIndoorCameraD3D->debug_outline_sw(pLimits, 4, 0xFF1E1E, 0.000099999997);
   if (CalcFaceBounding(pFace, pLimits, 4, pOutBounding))
-    return _49C720(pOutBounding, a3);
+    return _49C720(pOutBounding, a3) != 0;
   return false;
 }
 // 4D864C: using guessed type char byte_4D864C;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stru367.h	Sat Jun 01 10:32:31 2013 +0600
@@ -0,0 +1,42 @@
+#pragma once
+
+
+
+/*  152 */
+#pragma pack(push, 1)
+struct stru367
+{
+	int field_0;
+	int field_4[13];
+	int field_38[2];
+	int _view_transformed_ys_minus1;
+	int _view_transformed_ys[57];
+	int field_128[2];
+	int _view_transformed_zs_minus1;
+	int _view_transformed_zs[57];
+	int field_218[2];
+	int _view_transformed_xs_minus1;
+	int _view_transformed_xs[45];
+	int _screen_space_y[2];
+	int field_2E0;
+	int field_2E4[2];
+	int field_2EC;
+	int field_2F0[2];
+	int field_2F8;
+	int _ys[3];
+	int _ys2[48];
+	int _screen_space_x[2];
+	int field_3D0;
+	int field_3D4[2];
+	int field_3DC;
+	//int field_3E0;
+	int _xs[54];
+	int field_3E4;
+	int field_3E8;
+	int _xs2[3];
+	int _xs3[48];
+};
+#pragma pack(pop)
+
+
+//extern  const stru367 stru_367;
\ No newline at end of file
--- a/stru6.cpp	Sat Jun 01 10:32:08 2013 +0600
+++ b/stru6.cpp	Sat Jun 01 10:32:31 2013 +0600
@@ -27,6 +27,18 @@
 
 
 
+//----- (004775C4) --------------------------------------------------------
+stru6_stru1_indoor_sw_billboard::~stru6_stru1_indoor_sw_billboard()
+{
+    if (pArray1)
+        delete [] pArray1;
+    pArray1 = nullptr;
+
+    if (pArray2)
+        delete [] pArray2;
+    pArray2 = nullptr;
+}
+
 
 //----- (00478211) --------------------------------------------------------
 void stru6_stru1_indoor_sw_billboard::Initialize(int a2)
@@ -878,6 +890,7 @@
   if ( result < 545 )
   {
     __debugbreak(); // find out what kind of spells are these
+					// when summoned light elemental attacks
 
       result -= 500;
       switch ( result )
--- a/stru6.h	Sat Jun 01 10:32:08 2013 +0600
+++ b/stru6.h	Sat Jun 01 10:32:31 2013 +0600
@@ -17,16 +17,7 @@
   }
 
   //----- (004775C4) --------------------------------------------------------
-  virtual ~stru6_stru1_indoor_sw_billboard()
-  {
-    if (pArray1)
-      delete [] pArray1;
-    pArray1 = nullptr;
-
-    if (pArray2)
-      delete [] pArray2;
-    pArray2 = nullptr;
-  }
+  virtual ~stru6_stru1_indoor_sw_billboard();
 
   int _4775ED(float a2);
   int _477927(float a2);
@@ -42,7 +33,8 @@
   unsigned int uNumVec3sInArray2;
   struct stru160 *pArray2;
   int field_10;
-  int field_14[80];
+  int field_14[40];
+  float field_B4[40];
 };
 #pragma pack(pop)