changeset 259:92a551e4dbeb

Слияние
author Ritor1
date Mon, 18 Feb 2013 09:44:59 +0600
parents 6764ce3cb9bb (current diff) fb8a876f41e1 (diff)
children b89ee5d926dd
files mm7_3.cpp stru157.h
diffstat 59 files changed, 8794 insertions(+), 6880 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/Actor.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -155,9 +155,9 @@
   int v10; // eax@11
   GUIWindow *v11; // ecx@19
   signed int v12; // eax@21
-  int v13; // [sp-8h] [bp-44h]@34
+  //int v13; // [sp-8h] [bp-44h]@34
   const char *v14; // [sp-4h] [bp-40h]@4
-  int v15; // [sp-4h] [bp-40h]@34
+  //int v15; // [sp-4h] [bp-40h]@34
   signed int v16; // [sp-4h] [bp-40h]@35
   int v17; // [sp+10h] [bp-2Ch]@1
   char pContainer[32]; // [sp+14h] [bp-28h]@3
@@ -184,16 +184,13 @@
   if ( !pParty->uAlignment )
   {
     v14 = "-b";
-LABEL_7:
     strcat(pContainer, v14);
-    goto LABEL_8;
   }
-  if ( pParty->uAlignment == 2 )
+  else if ( pParty->uAlignment == 2 )
   {
     v14 = "-c";
-    goto LABEL_7;
+    strcat(pContainer, v14);
   }
-LABEL_8:
   v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
   array_5913D8[6] = 0;
   uNumDialogueNPCPortraits = 1;
@@ -208,33 +205,38 @@
     if ( (signed int)pParty->GetPartyFame() <= v5->fame
       || (v10 = v5->uFlags & 0xFFFFFF7F, (v5->uFlags & 0xFFFFFF7F & 0x80000000u) != 0) )
     {
-LABEL_16:
       v9 = 1;
-      goto LABEL_17;
     }
-    if ( v10 > 1 )
-    {
-      if ( v10 == 2 )
-      {
-        v16 = 3;
-        goto LABEL_36;
-      }
-      if ( v10 != 3 )
-      {
-        if ( v10 == 4 )
-          goto LABEL_17;
-        goto LABEL_16;
-      }
-LABEL_35:
-      v16 = 2;
-LABEL_36:
-      v9 = v16;
-      goto LABEL_17;
-    }
-    if ( v5->rep )
-      goto LABEL_35;
+	else
+	{
+		if ( v10 > 1 )
+		{
+		  if ( v10 == 2 )
+		  {
+			v16 = 3;
+			v9 = v16;
+		  }
+		  else
+		  {
+			  if ( v10 != 3 )
+			  {
+				if ( v10 != 4 )
+				  v9 = 1;
+			  }
+			  else
+			  {
+				v16 = 2;
+				v9 = v16;
+			  }
+		  }
+		}
+		else if ( v5->rep )
+		{
+		  v16 = 2;
+		  v9 = v16;
+		}
+	}
   }
-LABEL_17:
   if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) != 0 )
     v9 = 4;
   v11 = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)10, v9, 0);
@@ -271,21 +273,14 @@
   pDialogueWindow->CreateButton(407u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
   if ( v17 && uActiveCharacter && !(v5->uFlags & 0x80) )
   {
-    if ( pParty->uCurrentHour < 5 || pParty->uCurrentHour > 0x15 )
-    {
-      v15 = 0;
-      v13 = 23;
-    }
+    if (pParty->uCurrentHour < 5 || pParty->uCurrentHour > 21)
+      pPlayers[uActiveCharacter]->PlaySound(SPEECH_GoodEvening, 0);
     else
-    {
-      v15 = 0;
-      v13 = 22;
-    }
-    pPlayers[uActiveCharacter]->PlaySound(v13, v15);
+      pPlayers[uActiveCharacter]->PlaySound(SPEECH_GoodDay, 0);
   }
 }
 
-
+  
 //----- (0040894B) --------------------------------------------------------
 bool Actor::CanAct()
 {
@@ -2489,7 +2484,7 @@
 
   v1 = uActiveCharacter;
   v7 = uActorID;
-  pPlayer = &pParty->pPlayers[uActiveCharacter-1];//(Player *)&stru_AA1058[3].pSounds[6972 * uActiveCharacter + 40552];
+  pPlayer = &pParty->pPlayers[uActiveCharacter-1];
   result = pPlayer->CanAct();
   if ( result )
   {
@@ -2984,7 +2979,6 @@
   {
     v13 = &v14;
     v12 = 256;
-LABEL_16:
     Actor::_403EB6(uActorID, v16, v12, v13);
     return;
   }
@@ -3001,7 +2995,8 @@
   {
     v13 = &v14;
     v12 = 256;
-    goto LABEL_16;
+    Actor::_403EB6(uActorID, v16, v12, v13);
+    return;
   }
   v11 = v5->uMovementSpeed;
   v5->uYawAngle = v10;
@@ -3252,18 +3247,83 @@
   if ( v8 > MONSTER_HARPY_3 )
   {
     if ( v8 < MONSTER_OOZE_1 )
-      goto LABEL_21;
+	{
+      if ( !_this.uItemID )
+	  {
+		if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+			Actor::Explode(v11);
+		return;
+	  }
+      if ( rand() % 100 < 20 )
+	  {
+		v9 = rand();
+		sub_42F7EB_DropItemAt(
+		  pItemsTable->pItems[_this.uItemID].uSpriteID,
+		  v1->vPosition.x,
+		  v1->vPosition.y,
+		  v1->vPosition.z + 16,
+		  v9 % 200 + 200,
+		  1,
+		  1,
+		  0,
+		  &_this);
+	  }
+	  if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+		Actor::Explode(v11);
+	  return;
+	}
     if ( v8 <= MONSTER_OOZE_3 )
     {
       _this.uItemID = ITEM_OOZE_ECTOPLASM_BOTTLE;
-      goto LABEL_21;
+      if ( !_this.uItemID )
+	  {
+		if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+			Actor::Explode(v11);
+		return;
+	  }
+      if ( rand() % 100 < 20 )
+	  {
+		v9 = rand();
+		sub_42F7EB_DropItemAt(
+		  pItemsTable->pItems[_this.uItemID].uSpriteID,
+		  v1->vPosition.x,
+		  v1->vPosition.y,
+		  v1->vPosition.z + 16,
+		  v9 % 200 + 200,
+		  1,
+		  1,
+		  0,
+		  &_this);
+	  }
+	  if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+		Actor::Explode(v11);
+	  return;
     }
     if ( v8 <= MONSTER_PEASANT_GOBLIN_MALE_3_3 || v8 > MONSTER_TROLL_3 )
     {
-LABEL_21:
       if ( !_this.uItemID )
-        goto LABEL_24;
-      goto LABEL_22;
+	  {
+		if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+			Actor::Explode(v11);
+		return;
+	  }
+      if ( rand() % 100 < 20 )
+	  {
+		v9 = rand();
+		sub_42F7EB_DropItemAt(
+		  pItemsTable->pItems[_this.uItemID].uSpriteID,
+		  v1->vPosition.x,
+		  v1->vPosition.y,
+		  v1->vPosition.z + 16,
+		  v9 % 200 + 200,
+		  1,
+		  1,
+		  0,
+		  &_this);
+	  }
+	  if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+		Actor::Explode(v11);
+	  return;
     }
     _this.uItemID = ITEM_TROLL_BLOOD;
   }
@@ -3276,20 +3336,81 @@
     else
     {
       if ( v8 < MONSTER_DEVIL_1 )
-        goto LABEL_21;
+	  {
+		  if ( !_this.uItemID )
+		  {
+			if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+				Actor::Explode(v11);
+			return;
+		  }
+		  if ( rand() % 100 < 20 )
+		  {
+			v9 = rand();
+			sub_42F7EB_DropItemAt(
+			  pItemsTable->pItems[_this.uItemID].uSpriteID,
+			  v1->vPosition.x,
+			  v1->vPosition.y,
+			  v1->vPosition.z + 16,
+			  v9 % 200 + 200,
+			  1,
+			  1,
+			  0,
+			  &_this);
+		  }
+		  if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+			Actor::Explode(v11);
+		  return;
+	  }
       if ( v8 > MONSTER_DEVIL_3 )
       {
         if ( v8 <= MONSTER_DRAGON_3 )
         {
           _this.uItemID = ITEM_DRAGON_EYE;
-          goto LABEL_22;
+          if ( rand() % 100 < 20 )
+		  {
+			v9 = rand();
+			sub_42F7EB_DropItemAt(
+				pItemsTable->pItems[_this.uItemID].uSpriteID,
+				v1->vPosition.x,
+				v1->vPosition.y,
+				v1->vPosition.z + 16,
+				v9 % 200 + 200,
+				1,
+				1,
+				0,
+				&_this);
+		  }
+		  if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+		    Actor::Explode(v11);
+		  return;
         }
-        goto LABEL_21;
+		if ( !_this.uItemID )
+		{
+			if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+				Actor::Explode(v11);
+			return;
+		}
+		if ( rand() % 100 < 20 )
+		{
+			v9 = rand();
+			sub_42F7EB_DropItemAt(
+			  pItemsTable->pItems[_this.uItemID].uSpriteID,
+			  v1->vPosition.x,
+			  v1->vPosition.y,
+			  v1->vPosition.z + 16,
+			  v9 % 200 + 200,
+			  1,
+			  1,
+			  0,
+			  &_this);
+		}
+		if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+			Actor::Explode(v11);
+		return;
       }
       _this.uItemID = ITEM_DEVIL_ICHOR;
     }
   }
-LABEL_22:
   if ( rand() % 100 < 20 )
   {
     v9 = rand();
@@ -3304,7 +3425,6 @@
       0,
       &_this);
   }
-LABEL_24:
   if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
     Actor::Explode(v11);
 }
@@ -3726,60 +3846,79 @@
   v21 = 0;
   v24 = v6;
   v26 = 0;
-  if ( (signed int)uNumActors <= 0 )
-    goto LABEL_26;
-  v7 = pActors;
-  do
+  if ( (signed int)uNumActors > 0 )
   {
-	v8 = v7->uAIState;
-	if ( v7->uAIState == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 )
-      goto LABEL_23;
-    if ( v24 == v4 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, v24 != v9) )
-      goto LABEL_13;
-    if ( v7->IsAlive() == 1 )
-    {
-      v24 = v4;
-      v3->uLastCharacterIDToHit = v4;
-LABEL_13:
-      v10 = v3->GetActorsRelation(v7);
-      if ( v10 == v4 )
-        goto LABEL_23;
-      goto LABEL_14;
-    }
-	v18 = v7->uGroup;
-    if ( (v18 != v4 || v3->uGroup != v4) && v18 == v3->uGroup )
-      goto LABEL_23;
-    v10 = 4;
-LABEL_14:
-    if ( v3->pMonsterInfo.uHostilityType )
-      v10 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uHostilityType;
-    v11 = dword_4DF380[v10];
-	v23 = abs(v3->vPosition.x - v7->vPosition.x);
-	v27 = abs(v3->vPosition.y - v7->vPosition.y);
-	v12 = abs(v3->vPosition.z - v7->vPosition.z);
-    v19 = v12;
-    if ( v23 <= v11
-      && v27 <= v11
-      && v12 <= v11
-      && sub_4070EF_prolly_collide_objects(8 * v26 | 3, 8 * v22 | 3)
-      && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 )
-    {
-      v25 = v23 * v23 + v27 * v27 + v19 * v19;
-      v21 = v26;
-    }
-    v4 = 0;
-LABEL_23:
-    ++v7;
-    v5 = v26++ + 1;
+	  v7 = pActors;
+	  do
+	  {
+		v8 = v7->uAIState;
+		if ( v7->uAIState == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 )
+		{
+			++v7;
+			v5 = v26++ + 1;
+			continue;
+		}
+		if ( v24 == v4 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, v24 != v9) )
+		{
+		  v10 = v3->GetActorsRelation(v7);
+		  if ( v10 == v4 )
+		  {
+			++v7;
+			v5 = v26++ + 1;
+			continue;
+		  }
+		}
+		else if ( v7->IsAlive() == 1 )
+		{
+		  v24 = v4;
+		  v3->uLastCharacterIDToHit = v4;
+		  v10 = v3->GetActorsRelation(v7);
+		  if ( v10 == v4 )
+		  {
+			++v7;
+			v5 = v26++ + 1;
+			continue;
+		  }
+		}
+		else
+		{
+			v18 = v7->uGroup;
+			if ( (v18 != v4 || v3->uGroup != v4) && v18 == v3->uGroup )
+			{
+				++v7;
+				v5 = v26++ + 1;
+				continue;
+			}
+			v10 = 4;
+		}
+		if ( v3->pMonsterInfo.uHostilityType )
+		  v10 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uHostilityType;
+		v11 = dword_4DF380[v10];
+		v23 = abs(v3->vPosition.x - v7->vPosition.x);
+		v27 = abs(v3->vPosition.y - v7->vPosition.y);
+		v12 = abs(v3->vPosition.z - v7->vPosition.z);
+		v19 = v12;
+		if ( v23 <= v11
+		  && v27 <= v11
+		  && v12 <= v11
+		  && sub_4070EF_prolly_collide_objects(8 * v26 | 3, 8 * v22 | 3)
+		  && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 )
+		{
+		  v25 = v23 * v23 + v27 * v27 + v19 * v19;
+		  v21 = v26;
+		}
+		v4 = 0;
+		++v7;
+		v5 = v26++ + 1;
+	  }
+	  while ( v26 < (signed int)uNumActors );
+	  if ( v25 != -1 )
+	  {
+		v13 = 8 * v21;
+		LOBYTE(v13) = 8 * v21 | 3;
+		*v20 = v13;
+	  }
   }
-  while ( v26 < (signed int)uNumActors );
-  if ( v25 != -1 )
-  {
-    v13 = 8 * v21;
-    LOBYTE(v13) = 8 * v21 | 3;
-    *v20 = v13;
-  }
-LABEL_26:
   if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= (signed int)v4
     && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > (signed int)v4 || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > v4) )
     a3 = v4;
@@ -3877,45 +4016,33 @@
   if ( a1 )
   {
     v9 = a1->uAlly;
-    if ( (signed int)v9 <= 0 )
-    {
-      if ( v9 != 9999 )
-        goto LABEL_30;
-    }
-    else
+    if ( (signed int)v9 > 0 )
     {
       if ( v9 != 9999 )
       {
         v7 = a1->uAlly;
-        goto LABEL_30;
       }
     }
-    v7 = 0;
-LABEL_30:
+	if(v9==9999)
+      v7 = 0;
     if ( (signed __int64)a1->pActorBuffs[12].uExpireTime > 0 )
       v7 = 0;
   }
-  if ( !v2 )
-    goto LABEL_40;
-  v10 = v2->uAlly;
-  if ( (signed int)v10 <= 0 )
-  {
-    if ( v10 != 9999 )
-      goto LABEL_38;
-  }
-  else
+  if ( v2 )
   {
-    if ( v10 != 9999 )
-    {
-      v8 = v2->uAlly;
-      goto LABEL_38;
-    }
+	  v10 = v2->uAlly;
+	  if ( (signed int)v10 > 0 )
+	  {
+		if ( v10 != 9999 )
+		{
+		  v8 = v2->uAlly;
+		}
+	  }
+	  if(v10==9999)
+	    v8 = 0;
+	  if ( (signed __int64)v2->pActorBuffs[12].uExpireTime > 0 )
+		v8 = 0;
   }
-  v8 = 0;
-LABEL_38:
-  if ( (signed __int64)v2->pActorBuffs[12].uExpireTime > 0 )
-    v8 = 0;
-LABEL_40:
   if ( a1 && (signed __int64)a1->pActorBuffs[1].uExpireTime > 0 && !v8
     || v2 && (signed __int64)v2->pActorBuffs[1].uExpireTime > 0 && !v7 )
     return 0;
@@ -3924,7 +4051,15 @@
   if ( v2 && a1 && (signed __int64)a1->pActorBuffs[12].uExpireTime <= 0 && v2->uAttributes & 0x80000 )
   {
     if ( v7 )
-      goto LABEL_55;
+	{
+		if ( (signed int)v7 < 89 )
+		{
+		  if ( v8 < 89 )
+			return pFactionTable->relations[v7][v8];
+		  return 0;
+		}
+		return 0;
+	}
     return 4;
   }
   if ( !v7 )
@@ -3932,16 +4067,18 @@
     if ( (!v2 || (signed __int64)v2->pActorBuffs[12].uExpireTime > 0 || !(v2->uAttributes & 0x80000))
       && !pFactionTable->relations[v8][0]) 
     {
-LABEL_56:
       if ( v8 < 89 )
         return pFactionTable->relations[v7][v8];
       return 0;
     }
     return 4;
   }
-LABEL_55:
   if ( (signed int)v7 < 89 )
-    goto LABEL_56;
+  {
+    if ( v8 < 89 )
+      return pFactionTable->relations[v7][v8];
+    return 0;
+  }
   return 0;
 }
 
--- a/Actor.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/Actor.h	Mon Feb 18 09:44:59 2013 +0600
@@ -51,7 +51,7 @@
 /*  295 */
 enum ObjectType
 {
-  OBJECT_unk0 = 0x0,
+  OBJECT_Any = 0x0,
   OBJECT_BLVDoor = 0x1,
   OBJECT_Item = 0x2,
   OBJECT_Actor = 0x3,
--- a/Arcomage.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/Arcomage.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -13,7 +13,7 @@
 #include "Events2D.h"
 #include "stru272.h"
 #include "VectorTypes.h"
-
+#include "texts.h"
 #include "mm7_data.h"
 
 
--- a/AudioPlayer.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/AudioPlayer.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -737,7 +737,6 @@
   int v102; // [sp+90h] [bp+1Ch]@60
   int v103; // [sp+90h] [bp+1Ch]@68
 
-  uVolume = 120; //Ritor1:It's temporary
   pAudioPlayer = this;
   v35 = this->bPlayerReady == 0;
   //pAudioPlayer = this;
@@ -2066,7 +2065,7 @@
   int Data; // [sp+Ch] [bp-8h]@1
   HKEY hKey; // [sp+10h] [bp-4h]@1
   char v6; // [sp+1Ch] [bp+8h]@0
-
+  v6=0; //to fix
   hKey = 0;
   cbData = 4;
   Data = 0;
--- a/AudioPlayer.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/AudioPlayer.h	Mon Feb 18 09:44:59 2013 +0600
@@ -77,6 +77,7 @@
   SOUND_EnteringAHouse = 0x6,
   SOUND_8 = 0x8,
   SOUND_27 = 0x1B,
+  SOUND_Button = 66,
   SOUND_Arcomage_LoseResources = 0x78,
   SOUND_Arcomage_AddResources = 0x79,
   SOUND_Arcomage_TowerWallDamage = 0x7A,
--- a/CShow.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/CShow.h	Mon Feb 18 09:44:59 2013 +0600
@@ -36,7 +36,7 @@
   //std::string v5; // [sp-18h] [bp-24h]@4
   //signed int v6; // [sp-Ch] [bp-18h]@10
   int ScreenSizeFlag; // [sp-8h] [bp-14h]@4
-  int v8; // [sp-4h] [bp-10h]@4
+  //int v8; // [sp-4h] [bp-10h]@4
   //char v9; // [sp+0h] [bp-Ch]@14
   //char v10; // [sp+4h] [bp-8h]@4
   //int a3; // [sp+Bh] [bp-1h]@14
@@ -49,53 +49,46 @@
       MessageBoxW(nullptr, L"No movie", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Show.cpp:40", 0);
       break;
     case MOVIE_3DOLogo:
-      v8 = 1;
       ScreenSizeFlag = 0;
       v3 = 0;
       Name = "3dologo";
-      VideoPlayer::MovieLoop(Name, v3, ScreenSizeFlag, v8);
+      VideoPlayer::MovieLoop(Name, v3, ScreenSizeFlag, 1);
       break;
     case MOVIE_NWCLogo:
-      v8 = 1;
       ScreenSizeFlag = 1;
       v3 = 0;
       Name = "new world logo";
-      VideoPlayer::MovieLoop(Name, v3, ScreenSizeFlag, v8);
+      VideoPlayer::MovieLoop(Name, v3, ScreenSizeFlag, 1);
       break;
     case MOVIE_JVC:
-      v8 = 1;
       ScreenSizeFlag = 1;
       v3 = 0;
       Name = "jvc";
-      VideoPlayer::MovieLoop(Name, v3, ScreenSizeFlag, v8);
+      VideoPlayer::MovieLoop(Name, v3, ScreenSizeFlag, 1);
       break;
     case MOVIE_Intro:
-      v8 = 1;
       ScreenSizeFlag = 1;
       v3 = 0;
       Name = "Intro";
-      VideoPlayer::MovieLoop(Name, v3, ScreenSizeFlag, v8);
+      VideoPlayer::MovieLoop(Name, v3, ScreenSizeFlag, 1);
       break;
     case MOVIE_Emerald:
-      v8 = 1;
       ScreenSizeFlag = 1;
       v3 = 0;
       Name = "Intro Post";
-      VideoPlayer::MovieLoop(Name, v3, ScreenSizeFlag, v8);
+      VideoPlayer::MovieLoop(Name, v3, ScreenSizeFlag, 1);
       break;
     case MOVIE_Death:
-      v8 = 1;
       ScreenSizeFlag = 1;
       v3 = 2;
       Name = "losegame";
-      VideoPlayer::MovieLoop(Name, v3, ScreenSizeFlag, v8);
+      VideoPlayer::MovieLoop(Name, v3, ScreenSizeFlag, 1);
       break;
     case MOVIE_Outro:
-      v8 = 1;
       ScreenSizeFlag = 1;
       v3 = 20;
       Name = "end_seq1";
-      VideoPlayer::MovieLoop(Name, v3, ScreenSizeFlag, v8);
+      VideoPlayer::MovieLoop(Name, v3, ScreenSizeFlag, 1);
       break;
     default:
       MessageBoxW(nullptr, L"Invalid movie requested in CShow::Run()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Show.cpp:72", 0);
--- a/DecalBuilder.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/DecalBuilder.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -774,28 +774,28 @@
     return;
 
   if (pRenderer->bUsingSpecular)
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3));
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
 
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
 
   auto pTex = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04");
   ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTex));
  
   DrawDecals(0.00039999999);
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
 
   if (pRenderer->bUsingSpecular)
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
 }
 
 //----- (0049C550) --------------------------------------------------------
--- a/GUIFont.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/GUIFont.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -1,4 +1,6 @@
 #include <string>
+#include <assert.h>
+
 #include "LOD.h"
 #include "GUIFont.h"
 #include "GUIWindow.h"
@@ -21,9 +23,13 @@
 struct GUIFont *pFontComic;
 struct GUIFont *pFontSmallnum;
 
+char temp_string[2048];
+
+char pTmpBuf3[10000];
+
 //----- (0044C448) --------------------------------------------------------
 GUIFont *LoadFont(const char *pFontFile, const char *pFontPalette, ...)
-	{
+{
 	
 	int pallete_index; // eax@3
 	GUIFont *pFont;
@@ -344,6 +350,8 @@
   v8 = strlen(pString);
   v9 = v8;
   v39 = v8;
+
+  assert(strlen(v6) < sizeof(pTmpBuf3));
   strcpy(pTmpBuf3, v6);
   v10 = a5;
   v11 = v35;
@@ -605,10 +613,10 @@
 //----- (0044C59D) --------------------------------------------------------
 int GUIFont::CalcTextHeight(const char *pString, GUIWindow *pWindow, int uXOffset, int a5)
 	{ 
-	int uAllHeght; // esi@3
-	unsigned int uStringLen; // eax@3
-	char c; // cl@4
-	char *test_string; // [sp+14h] [bp+Ch]@3
+	int uAllHeght; 
+	unsigned int uStringLen; 
+	char c; 
+	char *test_string; 
 
 	if (!pString)
 		return 0;
@@ -694,147 +702,97 @@
 //----- (0044C768) --------------------------------------------------------
 char * FitTextInAWindow(const char *pInString, GUIFont *pFont, GUIWindow *pWindow, unsigned int uX, int a5)
 	{
-	const char *v5; // edi@1
-	GUIFont *v6; // esi@1
-	unsigned int v8; // eax@3
-	int v9; // edi@3
-	unsigned __int8 v10; // cl@4
-	int v11; // edx@10
-	GUICharMetric *v12; // ecx@10
-	int v13; // edx@11
-	int v14; // edx@12
-	int v15; // edx@13
-	unsigned int v16; // esi@15
-	unsigned int v17; // edx@15
-	unsigned int v18; // ecx@15
-	int v19; // ebx@16
-	unsigned __int8 v20; // zf@16
-	char v21; // sf@16
-	unsigned __int8 v22; // of@16
-	int v23; // edi@16
-	unsigned __int8 v24; // dl@17
-	int v25; // edi@39
-	int v26; // eax@42
-	std::string v27; // [sp-18h] [bp-40h]@2
-	const char *v28; // [sp-8h] [bp-30h]@2
-	int v29; // [sp-4h] [bp-2Ch]@2
-	const char *v30; // [sp+Ch] [bp-1Ch]@1
-	char Str[3]; // [sp+10h] [bp-18h]@42
-	char v32; // [sp+13h] [bp-15h]@42
-	size_t v33; // [sp+14h] [bp-14h]@3
-	unsigned int v34; // [sp+18h] [bp-10h]@3
-	GUIFont *v35; // [sp+1Ch] [bp-Ch]@1
-	int v36; // [sp+20h] [bp-8h]@3
-	int v37; // [sp+24h] [bp-4h]@3
+	unsigned char c;
+	unsigned int uInStrLen;
+	char digits[4];
+	int possible_transition_point;
+	int string_pixel_Width;
+	int start_pixel_offset;
 
-	v5 = pInString;
-	v6 = pFont;
-	v30 = pInString;
-	v35 = pFont;
-	if ( !pInString )
+	if (!pInString)
 		{
 		MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0);
 		return 0;
 		}
-	v33 = strlen(pInString);
-	strcpy(pTmpBuf3, v5);
-	v8 = uX;
-	v9 = 0;
-	v36 = 0;
-	v34 = uX;
-	v37 = 0;
-	if ( (signed int)v33 > 0 )
+	uInStrLen = strlen(pInString);
+	strcpy(&temp_string[0], pInString);
+	if (uInStrLen==0)
+		return &temp_string[0];
+
+	start_pixel_offset=string_pixel_Width=uX;
+	possible_transition_point=0;
+	for(int i=0; i<uInStrLen; ++i) 
 		{
-		while ( 1 )
+		c=temp_string[i];
+		if (pFont->IsCharValid(c))
 			{
-			v10 = pTmpBuf3[v9];
-			if ((v10 < v6->cFirstChar || v10 > v6->cLastChar)
-				&& v10 != '\f' && v10 != '\r' && v10 != '\t' && v10 != '\n' )
-				goto LABEL_34;
-			v11 = v10 - 9;
-			v12 = &v6->pMetrics[v10];
-			if ( !v11 )
+			switch (c)
+				{
+			case '\t':	// Horizontal tab 09
+				{
+				strncpy(digits, &temp_string[i+1],3);
+				digits[3]=0;
+				string_pixel_Width= atoi(digits)+uX;
+				i+=3;
+				break;
+				}
+			case  '\n':	//Line Feed 0A 10
+				{
+				string_pixel_Width=start_pixel_offset;
+				possible_transition_point=i;
+				break;
+				}
+			case  '\f':   //Form Feed, page eject  0C 12
 				{
-				strncpy(Str, &pTmpBuf3[v9 + 1], 3u);
-				v32 = 0;
-				v26 = atoi(Str);
-				v8 = uX + v26;
-				v25 = v9 + 3;
-				v34 = v8;
-				goto LABEL_43;
+				i+=5;  
+				break;
 				}
-			v13 = v11 - 1;
-			if ( !v13 )
+			case  '\r':   //Carriage Return 0D 13
+				{
+				if (!a5)
+					return (char*)pInString;
 				break;
-			v14 = v13 - 2;
-			if ( !v14 )
+				}
+			case ' ' :
 				{
-				v25 = v9 + 5;
-LABEL_43:
-				v37 = v25;
-				goto LABEL_34;
+				string_pixel_Width+=pFont->pMetrics[c].uWidth;
+				possible_transition_point=i;
+				break;
 				}
-			v15 = v14 - 1;
-			if ( v15 )
-				{
-				if ( v15 != 19 )
+			default:
+
+				if ((string_pixel_Width+pFont->pMetrics[c].uWidth+ pFont->pMetrics[c].uLeftSpacing+
+					pFont->pMetrics[c].uRightSpacing)<pWindow->uFrameWidth)
 					{
-					v16 = v12->uRightSpacing;
-					v17 = v12->uWidth;
-					v18 = v12->uLeftSpacing;
-					if ( v8 + v16 + v18 + v17 < pWindow->uFrameWidth )
+					if(i>possible_transition_point)
+						string_pixel_Width+=pFont->pMetrics[c].uLeftSpacing;
+					string_pixel_Width+=pFont->pMetrics[c].uWidth;
+					if (i<uInStrLen)
+						string_pixel_Width+=pFont->pMetrics[c].uRightSpacing;
+					}
+				else
+					{
+					temp_string[possible_transition_point]='\n';
+					string_pixel_Width=start_pixel_offset;
+					if (i>possible_transition_point)
 						{
-						if ( v37 > v36 )
-							v8 += v18;
-						v8 += v17;
-						if ( v37 < (signed int)v33 )
-							v8 += v16;
-						v6 = v35;
-						}
-					else
-						{
-						v19 = v36;
-						v8 = v34;
-						v22 = v36 > v37;
-						v20 = v36 == v37;
-						v21 = v36 - v37 < 0;
-						v6 = v35;
-						pTmpBuf3[v36] = 10;
-						v23 = v19;
-						if ( (unsigned __int8)(v21 ^ v22) | v20 )
+						for(int j=possible_transition_point;j<i; ++j ) 
 							{
-							do
+							c=temp_string[j];
+							if (pFont->IsCharValid(c))
 								{
-								v24 = pTmpBuf3[v23];
-								if ( v24 >= v6->cFirstChar && v24 <= v6->cLastChar || v24 == 12 || v24 == 13 || v24 == 9 || v24 == 10 )
-									{
-									if ( v23 > v19 )
-										v8 += v6->pMetrics[v24].uLeftSpacing;
-									v8 += *((int *)&v6->cFirstChar + 3 * v24 + 9);
-									if ( v23 < v37 )
-										v8 += v6->pMetrics[v24].uRightSpacing;
-									}
-								++v23;
+								if(j>possible_transition_point)
+									string_pixel_Width+=pFont->pMetrics[c].uLeftSpacing;
+								string_pixel_Width+=pFont->pMetrics[c].uWidth;
+								if (j<i)
+									string_pixel_Width+=pFont->pMetrics[c].uRightSpacing;
+
 								}
-								while ( v23 <= v37 );
-							}
+							}  
 						}
-					goto LABEL_34;
 					}
-				v8 += v12->uWidth;
-				goto LABEL_41;
 				}
-			if ( !a5 )
-				return (char *)v30;
-LABEL_34:
-			v9 = v37++ + 1;
-			if ( v37 >= (signed int)v33 )
-				return pTmpBuf3;
 			}
-		v8 = v34;
-LABEL_41:
-		v36 = v9;
-		goto LABEL_34;
 		}
-	return pTmpBuf3;
+	return &temp_string[0];
 	}
--- a/GUIFont.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/GUIFont.h	Mon Feb 18 09:44:59 2013 +0600
@@ -17,7 +17,7 @@
 {
 	
 //----- (0044C4DE) --------------------------------------------------------
-  bool IsCharValid(char c) {	return (c >= cFirstChar) && (c <= cLastChar) || (c == '\f') || (c == '\r') || (c == '\t') || (c == '\n');}
+  bool IsCharValid(unsigned char c) {	return (c >= cFirstChar) && (c <= cLastChar) || (c == '\f') || (c == '\r') || (c == '\t') || (c == '\n');}
   int AlignText_Center(unsigned int uCenterX, const char *pString);
   int GetLineWidth(const char *pString);
   int CalcTextHeight(const char *pString, struct GUIWindow *pWindow, int a4, int a5);
--- a/GUIWindow.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/GUIWindow.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -20,6 +20,7 @@
 #include "FactionTable.h"
 #include "StorylineTextTable.h"
 #include "Events2D.h"
+#include "texts.h"
 #include "Autonotes.h"
 
 
@@ -240,8 +241,8 @@
     v29 = pSpellStats->pInfos[v28].pShortName;
   else
     v29 = pGlobalTXT_LocalizationStrings[153];
-  sprintf(pTmpBuf2, "%s: %s", pGlobalTXT_LocalizationStrings[172], v29);
-  strcat(pTmpBuf, pTmpBuf2);
+  sprintf((char*)pTmpBuf2, "%s: %s", (char*)pGlobalTXT_LocalizationStrings[172], v29);
+  strcat((char*)pTmpBuf, (char*)pTmpBuf2);
   DrawText(pFontArrus, 120, 22, 0, pTmpBuf, 0, 0, 0);
 
   uFramesetIDa = 0;
@@ -720,7 +721,7 @@
           {
             v3 = (__int64 *)&pParty->field_3C.field_4F0[2 * dword_506528];
             v24 = dword_506528 + 1;
-            v22 = (char *)&pStorylineText->field_4[3 * dword_506528 + 2];
+            v22 = (char *)&pStorylineText->StoreLine[dword_506528].pPageTitle;//guess //field_4[3 * dword_506528 + 2];
             do
             {
               v4 = *(char **)v22;
@@ -961,66 +962,64 @@
 
 
 //----- (00411621) --------------------------------------------------------
-GUIButton *GUIWindow::OpenSpellBook()
+void GUIWindow::OpenSpellBook()
 {
   Player *pPlayer; // edi@1
-  GUIWindow *pWindow; // esi@1
-  unsigned int v3; // ebp@1
+  //GUIWindow *pWindow; // esi@1
+  //unsigned int v3; // ebp@1
   int v4; // eax@3
-  GUIButton *result; // eax@25
+  ///GUIButton *result; // eax@25
   int a2; // [sp+10h] [bp-8h]@1
-  int v7; // [sp+14h] [bp-4h]@1
-
-  //__debugbreak();
+  //int v7; // [sp+14h] [bp-4h]@1
 
   pPlayer = pPlayers[uActiveCharacter];
-  pWindow = this;
-  LoadSpellbook(pPlayer->pNumSpellBookPage);
-  v3 = 0;
+  //pWindow = this;
+  LoadSpellbook(pPlayer->lastOpenedSpellbookPage);
+  //v3 = 0;
   a2 = 0;
-  v7 = (int)&pPlayer->spellbook.pChapters[pPlayer->pNumSpellBookPage];
-  do
+
+  auto chapter = &pPlayer->spellbook.pChapters[pPlayer->lastOpenedSpellbookPage];
+  for (uint i = 0; i < 11; ++i)
   {
-    if ( *(char *)(v7 + v3) )
-    {
-      v4 = 2 * (12 * pPlayer->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2431[12 * pPlayer->pNumSpellBookPage] + v3));
-      pWindow->CreateButton(pViewport->uViewportX + dword_4E20D0[v4],
-        pViewport->uViewportY + dword_4E20D0[v4 + 1],
-        dword_506408[v3 + 1]->uTextureWidth,
-        dword_506408[v3 + 1]->uTextureHeight,
-        1, 79, 0x56u, v3, 0, "", 0);
+    if (!chapter->bIsSpellAvailable[i])
+      continue;
+
+      v4 = 2 * (12 * pPlayer->lastOpenedSpellbookPage + pSpellbookSpellIndices[pPlayer->lastOpenedSpellbookPage][i + 1]);
+      CreateButton(pViewport->uViewportX + dword_4E20D0[v4],
+                   pViewport->uViewportY + dword_4E20D0[v4 + 1],
+                   dword_506408[i + 1]->uTextureWidth,
+                   dword_506408[i + 1]->uTextureHeight,
+                   1, 79, 0x56u, i, 0, "", 0);
       ++a2;
-    }
-    ++v3;
+    //++v3;
   }
-  while ( (signed int)v3 < 11 );
-  pWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x33u, 0, 9u, "", 0);
+  //while ( (signed int)v3 < 11 );
+
+  CreateButton(0, 0, 0, 0, 1, 0, 0x33u, 0, 9u, "", 0);
   if ( a2 )
-    pWindow->_41D08F(a2, 0, 0, 0);
-  if ( pPlayer->pActiveSkills[12] )
-    pWindow->CreateButton(0x18Fu, 0xAu, 0x32u, 0x24u, 1, 0, 0x57u, 0, 0, aSpellSchoolNames[0], 0);
-  if ( pPlayer->pActiveSkills[13] )
-    pWindow->CreateButton(0x18Fu, 0x2Eu, 0x32u, 0x24u, 1, 0, 0x57u, 1u, 0, aSpellSchoolNames[1], 0);
-  if ( pPlayer->pActiveSkills[14] )
-    pWindow->CreateButton(0x18Fu, 0x53u, 0x32u, 0x24u, 1, 0, 0x57u, 2u, 0, aSpellSchoolNames[2], 0);
-  if ( pPlayer->pActiveSkills[15] )
-    pWindow->CreateButton(0x18Fu, 0x79u, 0x32u, 0x24u, 1, 0, 0x57u, 3u, 0, aSpellSchoolNames[3], 0);
-  if ( pPlayer->pActiveSkills[16] )
-    pWindow->CreateButton(0x18Fu, 0x9Eu, 0x32u, 0x24u, 1, 0, 0x57u, 4u, 0, aSpellSchoolNames[4], 0);
-  if ( pPlayer->pActiveSkills[17] )
-    pWindow->CreateButton(0x190u, 0xC4u, 0x32u, 0x24u, 1, 0, 0x57u, 5u, 0, aSpellSchoolNames[5], 0);
-  if ( pPlayer->pActiveSkills[18] )
-    pWindow->CreateButton(0x190u, 0xEAu, 0x32u, 0x24u, 1, 0, 0x57u, 6u, 0, aSpellSchoolNames[6], 0);
-  if ( pPlayer->pActiveSkills[19] )
-    pWindow->CreateButton(0x190u, 0x10Fu, 0x32u, 0x24u, 1, 0, 0x57u, 7u, 0, aSpellSchoolNames[7], 0);
-  if ( pPlayer->pActiveSkills[20] )
-    pWindow->CreateButton(0x190u, 0x133u, 0x32u, 0x24u, 1, 0, 0x57u, 8u, 0, aSpellSchoolNames[8], 0);
-  pWindow->CreateButton(0x1DCu, 0x1C2u, pTexture_506444->uTextureWidth, pTexture_506444->uTextureHeight, 1, 78, 0x58u, 0, 0, "", 0);
-  pBtn_InstallRemoveSpell = pWindow->CreateButton(0x1DCu, 0x1C2u, 0x30u, 0x20u, 1, 78, 0x58u, 0, 0, "", pTexture_506444, 0);
-  pWindow->CreateButton(0x231u, 0x1C2u, ptr_506440->uTextureWidth, ptr_506440->uTextureHeight, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], 0);
-  pBtn_CloseBook = pWindow->CreateButton(0x231u, 0x1C2u, 0x30u, 0x20u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], ptr_506440, 0);
-  result = pBtn_CloseBook;
-  return result;
+    _41D08F(a2, 0, 0, 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_FIRE])
+    CreateButton(0x18Fu, 0xAu, 0x32u, 0x24u, 1, 0, 0x57u, 0, 0, aSpellSchoolNames[0], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_AIR])
+    CreateButton(0x18Fu, 0x2Eu, 0x32u, 0x24u, 1, 0, 0x57u, 1u, 0, aSpellSchoolNames[1], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_WATER])
+    CreateButton(0x18Fu, 0x53u, 0x32u, 0x24u, 1, 0, 0x57u, 2u, 0, aSpellSchoolNames[2], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_EARTH])
+    CreateButton(0x18Fu, 0x79u, 0x32u, 0x24u, 1, 0, 0x57u, 3u, 0, aSpellSchoolNames[3], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_SPIRIT])
+    CreateButton(0x18Fu, 0x9Eu, 0x32u, 0x24u, 1, 0, 0x57u, 4u, 0, aSpellSchoolNames[4], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_MIND])
+    CreateButton(0x190u, 0xC4u, 0x32u, 0x24u, 1, 0, 0x57u, 5u, 0, aSpellSchoolNames[5], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_BODY])
+    CreateButton(0x190u, 0xEAu, 0x32u, 0x24u, 1, 0, 0x57u, 6u, 0, aSpellSchoolNames[6], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_LIGHT])
+    CreateButton(0x190u, 0x10Fu, 0x32u, 0x24u, 1, 0, 0x57u, 7u, 0, aSpellSchoolNames[7], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_DARK])
+    CreateButton(0x190u, 0x133u, 0x32u, 0x24u, 1, 0, 0x57u, 8u, 0, aSpellSchoolNames[8], 0);
+  CreateButton(0x1DCu, 0x1C2u, pTexture_506444->uTextureWidth, pTexture_506444->uTextureHeight, 1, 78, 0x58u, 0, 0, "", 0);
+  pBtn_InstallRemoveSpell = CreateButton(0x1DCu, 0x1C2u, 0x30u, 0x20u, 1, 78, 0x58u, 0, 0, "", pTexture_506444, 0);
+  CreateButton(0x231u, 0x1C2u, ptr_506440->uTextureWidth, ptr_506440->uTextureHeight, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], 0);
+  pBtn_CloseBook = CreateButton(0x231u, 0x1C2u, 0x30u, 0x20u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], ptr_506440, 0);
 }
 // 50640C: using guessed type int dword_50640C[];
 
@@ -1321,7 +1320,8 @@
 
 
 //----- (0044D406) --------------------------------------------------------
-char *GUIWindow::DrawTitleText(GUIFont *a2, unsigned int uHorizontalMargin, unsigned int uVerticalMargin, unsigned __int16 uDefaultColor, const char *pInString, unsigned int uLineSpacing)
+char *GUIWindow::DrawTitleText(GUIFont *a2, unsigned int uHorizontalMargin, unsigned int uVerticalMargin, 
+	        unsigned __int16 uDefaultColor, const char *pInString, unsigned int uLineSpacing)
 {
   GUIWindow *pWindow; // esi@1
   unsigned int v8; // ebx@1
@@ -1698,18 +1698,20 @@
 }
 
 //----- (0041D12F) --------------------------------------------------------
-GUIButton *GUIWindow::CreateButton(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, int a6, int a7, unsigned int uControlID, unsigned int uControlParam, unsigned __int8 uHotkey, const char *pName, Texture *pTextures, ...)
+GUIButton *GUIWindow::CreateButton(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, 
+	int a6, int a7, unsigned int uControlID, unsigned int uControlParam, unsigned __int8 uHotkey, const char *pName, Texture *pTextures, ...)
 {
   GUIButton *pButton; // esi@1
   unsigned int v13; // eax@1
   unsigned int v14; // ebx@4
   unsigned int v15; // eax@4
-  unsigned int pTextureNum; // ebx@4
+  unsigned int TextureNum=0; // ebx@4
   unsigned int v17; // eax@4
   Texture *v18; // eax@4
   Texture **v19; // ecx@5
   Texture **v20; // edx@5
   GUIButton *v21; // eax@7
+  va_list texturs_ptr;
 
   pButton = (GUIButton *)pAllocator->AllocNamedChunk(0, 0xBCu, "BUTTON");
   pButton->pParent = this;
@@ -1723,7 +1725,6 @@
   v14 = pButton->uX;
   pButton->uButtonType = a6;
   v15 = v14 + uWidth - 1;
-  pTextureNum = 0;
   pButton->uZ = v15;
   v17 = pButton->uY;
   pButton->field_2C = 0;
@@ -1734,25 +1735,16 @@
   pButton->uHotkey = uHotkey;
   strlen(pName);
   strcpy(pButton->pButtonName, pName);
-  v18 = pTextures;
-  if ( pTextures )
+  va_start(texturs_ptr, pName);
+  while  (NULL!=(pTextures=va_arg(texturs_ptr, Texture *)))
   {
-    v19 = &pTextures;
-    v20 = pButton->pTextures;
-    do
-    {
-      ++v19;
-      *v20 = v18;
-      ++pTextureNum;
-      ++v20;
-      v18 = *v19;
-    }
-    while ( *v19 );
+	pButton->pTextures[TextureNum]=pTextures;
+	++TextureNum;	
   }
-  pButton->uNumTextures = pTextureNum;
-  v21 = this->pControlsTail;
-  if ( v21 )
-    v21->pNext = pButton;
+  va_end(texturs_ptr);
+  pButton->uNumTextures = TextureNum;
+  if ( this->pControlsTail )
+    this->pControlsTail->pNext = pButton;
   else
     this->pControlsHead = pButton;
   pButton->pPrev = this->pControlsTail;
@@ -1774,7 +1766,6 @@
     DrawText(a2, v4, a4, 0, "_", 0, 0, 0);
 }
 
-
 //----- (0041C432) --------------------------------------------------------
 GUIWindow *GUIWindow::Create(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, WindowType eWindowType, int pButton, int a5)
 {
@@ -1804,7 +1795,6 @@
   int uWidtha; // [sp+14h] [bp+4h]@66
   int a4a; // [sp+20h] [bp+10h]@15
 
-  uNextFreeWindowID = 0;
   for (uNextFreeWindowID = 0; uNextFreeWindowID < 20; ++uNextFreeWindowID)
   {
     if (pWindowList[uNextFreeWindowID].eWindowType == WINDOW_null)
@@ -1979,7 +1969,7 @@
         if ( v26 + 1 == v25 && uHouse_ExitPic )
         {
           v30 = pMapStats->pInfos[uHouse_ExitPic].pName;
-          v29 = pGlobalTXT_LocalizationStrings[411];//  ^Pv[%s]
+          v29 = (char*)pGlobalTXT_LocalizationStrings[411];//  ^Pv[%s]
         }
         else
         {
@@ -1989,7 +1979,7 @@
             //v27 = (char *)p2DEvents_minus1_::08[13 * a4];
             v27 = (char *)p2DEvents[pButton - 1].pProprieterName;
           v30 = v27;
-          v29 = pGlobalTXT_LocalizationStrings[435];//  ^Pt[%s]
+          v29 = (char*)pGlobalTXT_LocalizationStrings[435];//  ^Pt[%s]
         }
         sprintf(&byte_591180[100 * v26], v29, v30);
         array_5913D8[v26 + 7] = (NPCData *)pWindow->CreateButton(*(&pNPCPortraits_x + v26 + 6 * uNumDialogueNPCPortraits - 6),
--- a/GUIWindow.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/GUIWindow.h	Mon Feb 18 09:44:59 2013 +0600
@@ -67,7 +67,7 @@
   WINDOW_59 = 0x59,
   WINDOW_5A = 0x5A,
   WINDOW_5B = 0x5B,
-  WINDOW_5C = 0x5C,
+  WINDOW_VoiceSwitcherButton = 0x5C,
   WINDOW_5D = 0x5D,
   WINDOW_5E = 0x5E,
   WINDOW_5F = 0x5F,
@@ -94,14 +94,22 @@
 #pragma pack(push, 1)
 struct GUIWindow
 {
-  GUIButton *CreateButton(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, int a6, int a7, unsigned int uControlID, unsigned int uControlParam, unsigned __int8 uHotkey, const char *pName, Texture *pTextures, ...);
+  inline GUIWindow()
+  {
+    pControlsHead = pControlsTail = nullptr;
+    eWindowType = WINDOW_null;
+  }
+
+  GUIButton *CreateButton(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, int a6, int a7, 
+	         unsigned int uControlID, unsigned int uControlParam, unsigned __int8 uHotkey, const char *pName, Texture *pTextures, ...);
   void DrawFlashingInputCursor(signed int a3, int a4, struct GUIFont *a2);
   int DrawTextInRect(GUIFont *a2, unsigned int uX, unsigned int uY, unsigned int uColor, const char *Str1, int Source, int a8);
   char DrawText(GUIFont *a2, signed int uX, int uY, unsigned int uFontColor, const char *Str, int a7, int a8, unsigned int uFontShadowColor);
-  char *DrawTitleText(GUIFont *a2, unsigned int uHorizontalMargin, unsigned int uVerticalMargin, unsigned __int16 uDefaultColor, const char *pInString, unsigned int uLineSpacing);
+  char *DrawTitleText(GUIFont *a2, unsigned int uHorizontalMargin, unsigned int uVerticalMargin, 
+	            unsigned __int16 uDefaultColor, const char *pInString, unsigned int uLineSpacing);
   char *_4B1854(__int64 a2);
   void _4B3157();
-  GUIButton *OpenSpellBook();
+  void OpenSpellBook();
   void InitializeBookView();
   void DrawMessageBox(int arg0);
   GUIButton *GetControl(unsigned int uID);
@@ -207,7 +215,7 @@
   UIMSG_73 = 0x73,
   UIMSG_74 = 0x74,
   UIMSG_75 = 0x75,
-  UIMSG_PlayerCreationSelectQuality = 0x76,
+  UIMSG_PlayerCreation_SelectAttribute = 0x76,
   UIMSG_InventoryLeftClick = 0x78,
   UIMSG_SkillUp = 0x79,
   UIMSG_7A = 0x7A,
@@ -220,15 +228,15 @@
   UIMSG_SetGraphicsMode = 0x83,
   UIMSG_Quit = 0x84,
   UIMSG_85 = 0x85,
-  UIMSG_86 = 0x86,
-  UIMSG_87 = 0x87,
+  UIMSG_StartHireling1Dialogue = 0x86,
+  UIMSG_StartHireling2Dialogue = 0x87,
   UIMSG_88 = 0x88,
   UIMSG_8C = 0x8C,
   UIMSG_8D = 0x8D,
   UIMSG_8E = 0x8E,
   UIMSG_8F = 0x8F,
-  UIMSG_PlayerCreationVoiceBack = 0x90,
-  UIMSG_PlayerCreationVoiceForward = 0x91,
+  UIMSG_PlayerCreation_VoicePrev = 0x90,
+  UIMSG_PlayerCreation_VoiceNext = 0x91,
   UIMSG_92 = 0x92,
   UIMSG_StartNPCDialogue = 0xA1,
   UIMSG_ArrowUp = 0xA2,
@@ -240,8 +248,8 @@
   UIMSG_A8 = 0xA8,
   UIMSG_A9 = 0xA9,
   UIMSG_AA = 0xAA,
-  UIMSG_SelectFacePlayerBack = 0xAB,
-  UIMSG_SelectFacePlayerForward = 0xAC,
+  UIMSG_PlayerCreation_FacePrev = 0xAB,
+  UIMSG_PlayerCreation_FaceNext = 0xAC,
   UIMSG_AD = 0xAD,
   UIMSG_AE = 0xAE,
   UIMSG_AF = 0xAF,
@@ -290,7 +298,7 @@
   UIMSG_ToggleFlipOnExit = 0xE2,
   UIMSG_16F = 0x16F,
   UIMSG_170 = 0x170,
-  UIMSG_194 = 0x194,
+  UIMSG_Game_Action = 0x194,
   UIMSG_195 = 0x195,
   UIMSG_OpenRestUI = 0x199,
   UIMSG_19A = 0x19A,
--- a/Game.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/Game.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -16,11 +16,13 @@
 #include "GUIWindow.h"
 #include "Party.h"
 #include "TurnEngine.h"
-#include "stru157.h"
 #include "VideoPlayer.h"
 #include "Bink_Smacker.h"
 #include "Events.h"
 #include "Arcomage.h"
+#include "texts.h"
+#include "Actor.h"
+#include "Log.h"
 
 //#include "MM7.h"
 
@@ -470,7 +472,7 @@
       if ( v11 )
       {
         v12 = rand();
-        pPlayers[v17[v12 % v11]]->PlaySound(99, 0);
+        pPlayers[v17[v12 % v11]]->PlaySound(SPEECH_99, 0);
       }
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[524], 2u);// "Once again you've cheated death!.." "   ! "
       uGameState = 0;
@@ -582,69 +584,54 @@
 bool Game::_44EEA7()
 {
   //Game *v1; // esi@1
-  double v2; // st7@2
+  //double v2; // st7@2
   float depth; // ST00_4@9
-  bool result; // eax@9
+  //bool result; // eax@9
   unsigned int v5; // eax@14
   __int64 v6; // kr00_8@21
   unsigned int y; // [sp+4h] [bp-24h]@2
   unsigned int x; // [sp+8h] [bp-20h]@2
-  bool v9; // [sp+Ch] [bp-1Ch]@2
-  stru157 *v10; // [sp+10h] [bp-18h]@2
-  stru157 *v11; // [sp+14h] [bp-14h]@2
+  Vis_SelectionFilter *v10; // [sp+10h] [bp-18h]@2
+  Vis_SelectionFilter *v11; // [sp+14h] [bp-14h]@2
   POINT a2; // [sp+20h] [bp-8h]@1
 
   //v1 = this;
   ++qword_5C6DF0;
   pParticleEngine->UpdateParticles();
   pMouseInstance->GetCursorPos(&a2);
+
+  x = a2.y;
+  y = a2.x;
   if ( sub_4637E0_is_there_popup_onscreen() )
   {
-    v11 = &a5;
-    v10 = &stru_F93E30;
-    v9 = 0;
-    x = a2.y;
-    y = a2.x;
-    v2 = GetPickDepth();
+    v11 = &vis_face_filter;
+    v10 = &vis_sprite_filter_2;
+    depth = GetPickDepth();
   }
   else
   {
     if ( uFlags2 & 0x10 )
     {
-      v11 = &a5;
-      v10 = &stru_F93E1C;
+      v11 = &vis_face_filter;
+      v10 = &vis_sprite_filter_1;
     }
     else
     {
-      static bool __init_flag = false;
-      static stru157 static_sub_44EEA7_stru157;
-      if (!__init_flag)
-      {
-        __init_flag = true;
-        static_sub_44EEA7_stru157.field_8 = -1;
-        static_sub_44EEA7_stru157.field_0 = 0;
-        static_sub_44EEA7_stru157.field_4 = 2;
-        static_sub_44EEA7_stru157.field_C = 0;
-        static_sub_44EEA7_stru157.field_10 = 0;
-      }
-      v11 = &a5;
-      v10 = &static_sub_44EEA7_stru157;
+      v11 = &vis_face_filter;
+      v10 = &vis_sprite_filter_4;
     }
-    v2 = 5120.0;
-    v9 = 0;
-    x = a2.y;
-    y = a2.x;
+    depth = 5120.0;
   }
-  depth = v2;
+  //depth = v2;
 
-  PickMouse(depth, y, x, v9, v10, v11);
+  PickMouse(depth, y, x, true, v10, v11);
   pLightmapBuilder->std__vector_000004_size = 0;
   pLightmapBuilder->std__vector_183808_size = 0;
   pDecalBuilder->std__vector_pDecals_size = 0;
   pDecalBuilder->field_308008 = 0;
-  result = _44F07B();
-  if ( result )
-  {
+  if (!_44F07B())
+    return false;
+
     if ( uFlags & 8 )
       LOBYTE(pStru10Instance->field_4) = 0;
     if ( pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor)
@@ -668,9 +655,7 @@
       uNumStationaryLights_in_pStationaryLightsStack = pStationaryLightsStack->uNumLightsActive;
     }
     _44E904();
-    LOBYTE(result) = 1;
-  }
-  return result;
+    return true;
 }
 
 
@@ -1037,51 +1022,38 @@
 }
 
 //----- (0044EA5E) --------------------------------------------------------
-char Game::PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, stru157 *a5, stru157 *a6)
+bool Game::PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter)
 {
-  char result; // al@3
-  std::string v10; // [sp-4h] [bp-24h]@5
-  float v11; // [sp+4h] [bp-1Ch]@10
-  float v12; // [sp+8h] [bp-18h]@10
-  const char *v13; // [sp+Ch] [bp-14h]@5
-  int v14; // [sp+10h] [bp-10h]@5
-  std::string *v15; // [sp+18h] [bp-8h]@5
-  int a3; // [sp+1Fh] [bp-1h]@5
+  if (pCurrentScreen != SCREEN_GAME|| !pRenderer->pRenderD3D)
+    return false;
 
-  auto v7 = this;
-  if (!pCurrentScreen && pRenderer->pRenderD3D)
+  if (!pVisInstance)
   {
-    if (!pVisInstance)
-    {
-      MessageBoxW(nullptr, L"The 'Vis' object pointer has not been instatiated, but CGame::Pick() is trying to call through it.", nullptr, 0);
-      ExitProcess(0);
-    }
+    MessageBoxW(nullptr, L"The 'Vis' object pointer has not been instatiated, but CGame::Pick() is trying to call through it.", nullptr, 0);
+    return false;
+  }
 
-    if ( (signed int)uMouseX >= (signed int)pViewport->uScreenX
-      && (signed int)uMouseX <= (signed int)pViewport->uScreenZ
-      && (signed int)uMouseY >= (signed int)pViewport->uScreenY
-      && (signed int)uMouseY <= (signed int)pViewport->uScreenW )
-    {
-      v14 = (int)a6;
-      v12 = (double)(signed int)uMouseY;
-      v11 = (double)(signed int)uMouseX;
-      pVisInstance->PickMouse(fPickDepth, v11, v12, a5, a6);
+  if (uMouseX >= (signed int)pViewport->uScreenX &&
+      uMouseX <= (signed int)pViewport->uScreenZ &&
+      uMouseY >= (signed int)pViewport->uScreenY &&
+      uMouseY <= (signed int)pViewport->uScreenW)
+  {
+    pVisInstance->PickMouse(fPickDepth, uMouseX, uMouseY, sprite_filter, face_filter);
 
-      if (bOutline)
-        OutlineSelection();
-    }
-    return true;
+    if (bOutline)
+      OutlineSelection();
   }
-  return false;
+
+  return true;
 }
 // 4E28F8: using guessed type int pCurrentScreen;
 
 //----- (0044EB12) --------------------------------------------------------
-bool Game::_44EB12(bool bOutline, stru157 *a3, stru157 *a4)
+bool Game::PickKeyboard(bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter)
 {
   if ( !pCurrentScreen && pVisInstance && pRenderer->pRenderD3D )
   {
-    bool r = pVisInstance->PickKeyboard(&pVisInstance->stru1, a3, a4);
+    bool r = pVisInstance->PickKeyboard(&pVisInstance->default_list, sprite_filter, face_filter);
 
     if (bOutline)
       OutlineSelection();
@@ -1106,58 +1078,47 @@
 //----- (0044EB5A) --------------------------------------------------------
 void Game::OutlineSelection()
 {
-  Vis *v1; // eax@1
-  Vis_stru1_stru0 *v2; // eax@3
-  void *v3; // edx@9
-  int v4; // eax@10
-  int v5; // eax@11
-  int v6; // eax@14
-  int v7; // eax@15
-  const char *v9; // [sp-8h] [bp-14h]@8
-  int v10; // [sp-4h] [bp-10h]@8
-  char v11; // [sp+0h] [bp-Ch]@18
-  int a3; // [sp+Ah] [bp-2h]@8
+  if (!pVisInstance)
+    return;
+
+  if (!pVisInstance->default_list.uNumPointers)
+    return;
 
-  v1 = this->pVisInstance;
-  if ( v1 )
-  {
-    v2 = (Vis_stru1_stru0 *)((signed int)v1->stru1.uNumPointers <= 0 ? 0 : v1->stru1.array_1804[0]);
-    if ( v2 )
+  auto object_info = pVisInstance->default_list.object_pointers[0];
+  if (object_info)
+    switch (object_info->object_type)
     {
-      if ( v2->uObjectType == 1 )
+      case VisObjectType_Sprite:
       {
-        MessageBoxW(nullptr, L"Sprite outline currently Unsupported", nullptr, 0);
-        ExitProcess(0);
+        Log::Warning(L"Sprite outline currently unsupported");
+        return;
       }
 
-        if ( v2->uObjectType == 2 )
+      case VisObjectType_Face:
+      {
+        if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
         {
-          v3 = v2->pObjectInfo;                 // TODO  2 objects for indoor/outdoor
-                                                // some clues in header for Vis_stru1_stru0
-          if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
-          {
-            v4 = *((int *)v3 + 11);
-            if ( v4 & 0x10000 )
-              v5 = v4 & 0xFFFEFFFF;
-            else
-              v5 = v4 | 0x10000;
-            *((int *)v3 + 11) = v5;
-          }
+          auto face = (ODMFace *)object_info->object;
+          if (face->uAttributes & FACE_OUTLINED)
+            face->uAttributes &= ~FACE_OUTLINED;
           else
-          {
-            v6 = *((int *)v3 + 7);
-            if ( v6 & 0x10000 )
-              v7 = v6 & 0xFFFEFFFF;
-            else
-              v7 = v6 | 0x10000;
-            *((int *)v3 + 7) = v7;
-          }
+            face->uAttributes |= FACE_OUTLINED;
+        }
+        else if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
+        {
+          auto face = (BLVFace *)object_info->object;
+          if (face->uAttributes & FACE_OUTLINED)
+            face->uAttributes &= ~FACE_OUTLINED;
+          else
+            face->uAttributes |= FACE_OUTLINED;
         }
-        else
-        {
-          MessageBoxW(nullptr, L"Undefined CObjectInfo type requested in CGame::outline_selection()", nullptr, 0);
-          ExitProcess(0);
-        }
+        else assert(false);
+      }
+
+      default:
+      {
+        MessageBoxW(nullptr, L"Undefined CObjectInfo type requested in CGame::outline_selection()", nullptr, 0);
+        ExitProcess(0);
+      }
     }
-  }
 }
\ No newline at end of file
--- a/Game.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/Game.h	Mon Feb 18 09:44:59 2013 +0600
@@ -87,8 +87,8 @@
 public:
   void _44E904();
   bool InitializeGammaController();
-  char PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, struct stru157 *a5, struct stru157 *a6);
-  bool _44EB12(bool bOutline, struct stru157 *a3, struct stru157 *a4);
+  bool PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, struct Vis_SelectionFilter *sprite_filter, struct Vis_SelectionFilter *face_filter);
+  bool PickKeyboard(bool bOutline, struct Vis_SelectionFilter *sprite_filter, struct Vis_SelectionFilter *face_filter);
   void OutlineSelection();
   signed int _44EC23(struct stru148 *a2, int *a3, signed int a4);
   signed int _44ED0A(struct BLVFace *a2, int *a3, signed int a4);
--- a/GameUIs.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/GameUIs.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -7,6 +7,7 @@
 #include "LOD.h"
 #include "SaveLoad.h"
 #include "Render.h"
+#include "texts.h"
 
 #include "mm7_data.h"
 
--- a/Indoor.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/Indoor.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -22,6 +22,7 @@
 #include "TurnEngine.h"
 #include "PaletteManager.h"
 #include "MapInfo.h"
+#include "IndoorCamera.h"
 
 #include "mm7_data.h"
 
@@ -359,18 +360,18 @@
 //----- (00441BD4) --------------------------------------------------------
 void IndoorLocation::Draw()
 {
-  int v0; // eax@1
+  //int v0; // eax@1
   IndoorLocation_drawstru _this; // [sp+0h] [bp-4Ch]@5
   int v2; // [sp+44h] [bp-8h]@5
   int v3; // [sp+48h] [bp-4h]@5
 
-  v0 = 0;
-  if ( viewparams->field_50_draw_debug_outlines )
-    v0 = 1;
-  if ( viewparams->field_54 )
-    LOBYTE(v0) = v0 | 2;
+  _this.uFlags = 0;
+  if (viewparams->draw_sw_outlines)
+    _this.uFlags |= INDOOR_CAMERA_DRAW_SW_OUTLINES;
+  if (viewparams->draw_d3d_outlines)
+    _this.uFlags |= INDOOR_CAMERA_DRAW_D3D_OUTLINES;
+
   _this.field_0_timer = pEventTimer->uTotalGameTimeElapsed;
-  _this.uFlags = v0;
   _this.vPosition.x = pParty->vPosition.x
                    - ((unsigned __int64)(stru_5C6E00->SinCos(pParty->sRotationY)
                                        * (signed __int64)pParty->y_rotation_granularity) >> 16);
@@ -1256,8 +1257,6 @@
   return result;
 }
 
-
-
 //----- (004B0EA8) --------------------------------------------------------
 void BspRenderer::PrepareFaceRenderList_d3d(int a2, unsigned int uFaceID)
 {
--- a/Indoor.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/Indoor.h	Mon Feb 18 09:44:59 2013 +0600
@@ -255,6 +255,7 @@
 #define FACE_TEXTURE_ANIMATED 0x00000010 // like wavy water
 #define FACE_INVISIBLE        0x00002000
 #define FACE_TEXTURE_FRAME    0x00004000 // Texture ID is a frameset from TextureFrameTable, otherwise BitmapID
+#define FACE_OUTLINED         0x00010000 // outline face edges
 #define FACE_TEXTURE_FLOW     0x00040000 // The texture moves slowly. For horizontal facets only.
 #define FACE_CLICKABLE        0x02000000 // Event can be triggered by clicking on the facet.
 #define FACE_PRESSURE_PLATE   0x04000000 // Event can be triggered by stepping on the facet.
@@ -493,7 +494,7 @@
 struct IndoorLocation_drawstru
 {
   int field_0_timer;
-  int uFlags;
+  int uFlags;              // & INDOOR_CAMERA_DRAW_D3D_OUTLINES:  render d3d outlines
   Vec3_int_ vPosition;
   int sRotationY;
   int sRotationX;
@@ -528,7 +529,7 @@
   int Reset(struct IndoorLocation_drawstru *a2);
 
   int field_0_timer_;
-  int uFlags;
+  int uFlags;              // & INDOOR_CAMERA_DRAW_D3D_OUTLINES:  render d3d outlines
   Vec3_int_ vPartyPos;
   int sPartyRotY;
   int sPartyRotX;
--- a/IndoorCamera.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/IndoorCamera.h	Mon Feb 18 09:44:59 2013 +0600
@@ -1,6 +1,9 @@
 #pragma once
 #include "VectorTypes.h"
 
+
+#define INDOOR_CAMERA_DRAW_SW_OUTLINES 1
+#define INDOOR_CAMERA_DRAW_D3D_OUTLINES 2
 /*  157 */
 #pragma pack(push, 1)
 struct IndoorCamera
@@ -13,7 +16,7 @@
     flt_1C_fov = 2000.0f;
     flt_20_inv_1C = 32.768002f;
 
-    field_4C = 0;
+    flags = 0;
   }
   void Initialize(int degFov, unsigned int uViewportWidth, unsigned int uViewportHeight);
   void Initialize2();
@@ -37,7 +40,7 @@
   int _int_cosine;
   int _int_sine_2;
   int _int_cosine_2;
-  int field_4C;
+  int flags;  // & INDOOR_CAMERA_DRAW_D3D_OUTLINES:  render terrain outlines in d3d
 };
 #pragma pack(pop)
 
--- a/Items.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/Items.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -1,4 +1,5 @@
 #include <stdlib.h>
+#include <assert.h>
 
 #include "Items.h"
 #include "MapInfo.h"
@@ -9,7 +10,7 @@
 #include "Party.h"
 #include "FactionTable.h"
 #include "StorylineTextTable.h"
-
+#include "texts.h"
 #include "mm7_data.h"
 
 
@@ -52,7 +53,6 @@
   UpdateTempBonus(pParty->uTimePlayed);
   if ( v4->uItemID == 501 )
   {
-LABEL_45:
     *v3 = 1;
     v10 = rand();
     v17 = 10;
@@ -72,13 +72,17 @@
     return v9 + 9;
   }
   if ( v4->uItemID == 517 )
-    goto LABEL_36;
+  {
+    v5 = 8;
+    *v3 = v5;
+    return v5;
+  }
   v8 = v4->uAdditionalValue;
   if ( v8 > 46 )
   {
-LABEL_42:
     v5 = 0;
-    goto LABEL_37;
+    *v3 = v5;
+    return v5;
   }
   if ( v8 == 46 )
   {
@@ -112,14 +116,14 @@
           *a3 = 1;
           return v5;
         }
-        goto LABEL_42;
+		v5 = 0;
+		*v3 = v5;
+		return v5;
       }
       *v3 = 2;
       return 12;
     }
-LABEL_36:
     v5 = 8;
-LABEL_37:
     *v3 = v5;
     return v5;
   }
@@ -159,9 +163,18 @@
     return rand() % 7 + 4;
   }
   if ( v8 == 9 )
-    goto LABEL_45;
+  {
+    *v3 = 1;
+    v10 = rand();
+    v17 = 10;
+    return v10 % v17 + 6;
+  }
   if ( v8 != 10 )
-    goto LABEL_42;
+  {
+        v5 = 0;
+    *v3 = v5;
+    return v5;
+  }
   *v3 = 0;
   v7 = 1;
   return GetDiceResult(v7, 6u);
@@ -241,1223 +254,942 @@
 
 //----- (00456D84) --------------------------------------------------------
 void ItemsTable::Initialize()
-{
-  //ItemsTable *v1; // edi@1
-  char *v2; // eax@1
-  char *v3; // eax@2
-  char v4; // cl@3
-  int v5; // esi@3
-  char *v6; // esi@21
-  char *v7; // eax@21
-  char *v8; // ecx@22
-  char *v9; // eax@26
-  char v10; // dl@27
-  int v11; // ecx@27
-  int v12; // esi@31
-  char *v13; // eax@39
-  int v14; // esi@40
-  char v15; // cl@41
-  int v16; // eax@41
-  char v17; // zf@53
-  int v18; // eax@57
-  int *v19; // esi@66
-  char *v20; // edx@66
-  int v21; // eax@66
-  char *v22; // ecx@68
-  char *v23; // eax@71
-  int v24; // esi@71
-  char *v25; // ebx@72
-  char v26; // cl@73
-  int v27; // eax@73
-  char *v28; // ST3C_4@160
-  char *v29; // ST3C_4@163
-  char *v30; // eax@175
-  char *v31; // eax@188
-  char v32; // al@190
-  char *v33; // eax@199
-  const char *v34; // ebx@199
-  int v35; // esi@199
-  char *v36; // eax@200
-  char v37; // dl@201
-  int v38; // ecx@201
-  char *v39; // esi@229
-  char *v40; // eax@229
-  char *v41; // ecx@230
-  char *v42; // esi@233
-  char *v43; // eax@234
-  char v44; // dl@235
-  int v45; // ecx@235
-  signed int v46; // edi@287
-  char *v47; // ecx@288
-  char v48; // dl@289
-  int v49; // eax@289
-  int v50; // esi@293
-  signed int v51; // edi@312
-  char *v52; // ecx@312
-  char v53; // dl@313
-  int v54; // eax@313
-  int v55; // esi@317
-  signed int v56; // edi@348
-  char *v57; // eax@348
-  char v58; // dl@349
-  int v59; // ecx@349
-  int v60; // esi@353
-  char *Str; // [sp+Ch] [bp-18h]@1
-  signed int Stra; // [sp+Ch] [bp-18h]@22
-  signed int Strb; // [sp+Ch] [bp-18h]@25
-  signed int Strc; // [sp+Ch] [bp-18h]@39
-  signed int Strd; // [sp+Ch] [bp-18h]@66
-  signed int Stre; // [sp+Ch] [bp-18h]@156
-  const char **Strf; // [sp+Ch] [bp-18h]@176
-  const char **Strg; // [sp+Ch] [bp-18h]@182
-  signed int Strh; // [sp+Ch] [bp-18h]@230
-  signed int Stri; // [sp+Ch] [bp-18h]@311
-  char **Strj; // [sp+Ch] [bp-18h]@347
-  int v72; // [sp+10h] [bp-14h]@7
-  signed int v73; // [sp+10h] [bp-14h]@21
-  int v74; // [sp+10h] [bp-14h]@45
-  int v75; // [sp+10h] [bp-14h]@77
-  int v76; // [sp+10h] [bp-14h]@205
-  signed int v77; // [sp+10h] [bp-14h]@229
-  int v78; // [sp+10h] [bp-14h]@239
-  signed int v79; // [sp+14h] [bp-10h]@1
-  char *v80; // [sp+14h] [bp-10h]@39
-  char *v81; // [sp+14h] [bp-10h]@175
-  char *v82; // [sp+14h] [bp-10h]@188
-  int v83; // [sp+18h] [bp-Ch]@67
-  size_t v84; // [sp+18h] [bp-Ch]@156
-  signed int v85; // [sp+18h] [bp-Ch]@176
-  signed int v86; // [sp+18h] [bp-Ch]@182
-  signed int v87; // [sp+18h] [bp-Ch]@233
-  signed int v88; // [sp+1Ch] [bp-8h]@2
-  signed int v89; // [sp+1Ch] [bp-8h]@26
-  signed int v90; // [sp+1Ch] [bp-8h]@40
-  signed int v91; // [sp+1Ch] [bp-8h]@72
-  signed int v92; // [sp+1Ch] [bp-8h]@200
-  signed int v93; // [sp+1Ch] [bp-8h]@234
-  signed int v94; // [sp+1Ch] [bp-8h]@288
-  signed int v95; // [sp+1Ch] [bp-8h]@312
-  signed int v96; // [sp+1Ch] [bp-8h]@348
-  signed int v97; // [sp+20h] [bp-4h]@2
-  signed int v98; // [sp+20h] [bp-4h]@26
-  signed int v99; // [sp+20h] [bp-4h]@40
-  signed int v100; // [sp+20h] [bp-4h]@72
-  signed int v101; // [sp+20h] [bp-4h]@200
-  signed int v102; // [sp+20h] [bp-4h]@234
-  signed int v103; // [sp+20h] [bp-4h]@288
+	{
+	int i,j;
+	char* test_string;
+	unsigned char c;
+	bool break_loop;
+	unsigned int temp_str_len;
+	char* tmp_pos;
+	int decode_step;
+	int item_counter;
+
+	pMapStats = new MapStats;
+	pMapStats->Initialize();
+
+	pMonsterStats = new MonsterStats;
+	pMonsterStats->Initialize();
+	pMonsterStats->InitializePlacements();
+
+	pSpellStats = new SpellStats;
+	pSpellStats->Initialize();
+
+	LoadPotions();
+	LoadPotionNotes();
+
+	pFactionTable = new FactionTable;
+	pFactionTable->Initialize();
+
+	pStorylineText = new StorylineText;
+	pStorylineText->Initialize();
+
+	pStdItemsTXT_Raw = NULL;
+	pStdItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stditems.txt", 0);
+	strtok(pStdItemsTXT_Raw, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	//Standard Bonuses by Group	
+	for (i=0;i<24;++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				switch (decode_step)
+					{
+				case 0: 
+					pEnchantments[i].pBonusStat=RemoveQuotes(test_string);
+					break;
+				case 1:
+					pEnchantments[i].pOfName= RemoveQuotes(test_string);
+					break;
+				default:
+					pEnchantments[i].to_item[decode_step-2]=atoi(test_string);
+					}
+				}
+			else
+				{ 
+				if (!decode_step)
+					break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<11)&&!break_loop);
+		}
+
+	memset(&pEnchantmentsSumm, 0, 36);
+	for(i=0;i<9;++i)
+		{
+		for (j=0;j<24;++j)
+			pEnchantmentsSumm[i]+=pEnchantments[j].to_item[i];
+		}
 
-  //v1 = this;
+	//Bonus range for Standard by Level
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	for(i=0;i<6;++i) //counted from 1
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if  (decode_step==2)
+				bonus_ranges[i].minR = atoi(test_string);
+			else if (decode_step==3)
+				bonus_ranges[i].maxR =atoi(test_string);
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<4)&&!break_loop);
+		}
 
-  pMapStats = new MapStats;
-  pMapStats->Initialize();
-
-  pMonsterStats = new MonsterStats;
-  pMonsterStats->Initialize();
-  pMonsterStats->InitializePlacements();
 
-  pSpellStats = new SpellStats;
-  pSpellStats->Initialize();
-
-  LoadPotions();
-  LoadPotionNotes();
+	pSpcItemsTXT_Raw = 0;
+	pSpcItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spcitems.txt", 0);
+	strtok(pSpcItemsTXT_Raw, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	for (i=0;i<72;++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				switch (decode_step)
+					{
+				case 0: 
+					pSpecialEnchantments[i].pBonusStatement=RemoveQuotes(test_string);
+					break;
+				case 1:
+					pSpecialEnchantments[i].pNameAdd= RemoveQuotes(test_string);
+					break;
+				case 14:
+					int res;
+					res=atoi(test_string);
+					if(!res)
+						{
+						++test_string; 
+						while (*test_string==' ')//fix X 2 case
+							++test_string; 
+						res=atoi(test_string);
+						}				
+					pSpecialEnchantments[i].iValue=res;
+					break;
+				case 15:
+					pSpecialEnchantments[i].iTreasureLevel=  tolower(*test_string) - 97;;
+					break;
+				default:
+					pSpecialEnchantments[i].to_item_apply[decode_step-2]=atoi(test_string);
+					}
+				}
+			else
+				{ 
+				if (!decode_step)
+					break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<16)&&!break_loop);
+		}
 
-  pFactionTable = new FactionTable;
-  pFactionTable->Initialize();
+	pSpecialEnchantments_count = 71;
+	memset(&pSpecialEnchantmentsSumm, 0, 96);
+	for(i=0;i<12;++i)
+		{
+		for (j=0;j<pSpecialEnchantments_count;++j)
+			pSpecialEnchantmentsSumm[i]+=pSpecialEnchantments[j].to_item_apply[i];
+		}
 
-  pStorylineText = new StorylineText;
-  pStorylineText->Initialize();
+
+
+	Initialize2DA();
 
-  pStdItemsTXT_Raw = 0;
-  v2 = (char *)pEvents_LOD->LoadRaw("stditems.txt", 0);
-  pStdItemsTXT_Raw = v2;
-  strtok(v2, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
-  Str = (char *)&pEnchantments[0].pParam;
-  v79 = 24;
-  do
-  {
-    v3 = strtok(0, "\r") + 1;
-    v97 = 0;
-    v88 = 0;
-    do
-    {
-      v4 = *v3;
-      v5 = 0;
-      while ( v4 != 9 && v4 )
-      {
-        ++v5;
-        v4 = v3[v5];
-      }
-      v72 = (int)&v3[v5];
-      if ( !v3[v5] )
-        v88 = 1;
-      v3[v5] = 0;
-      if ( v5 )
-      {
-        if ( v97 )
-        {
-          if ( v97 == 1 )
-          {
-            *(unsigned int *)Str = (int)RemoveQuotes(v3);
-          }
-          else
-          {
-            if ( v97 > 1 )
-              Str[v97 + 6] = atoi(v3);
-          }
-        }
-        else
-        {
-          *((char **)Str + 1) = RemoveQuotes(v3);
-        }
-      }
-      else
-      {
-        if ( !v97 )
-          v88 = 1;
-      }
-      ++v97;
-      v3 = (char *)(v72 + 1);
-    }
-    while ( v97 <= 10 && !v88 );
-    Str += 20;
-    --v79;
-  }
-  while ( v79 );
-  v6 = (char *)&field_116D8[3];
-  memset(&field_116D8[3], 0, 0x24u);
-  v7 = &pEnchantments[0].field_8[4];
-  v73 = 9;
-  do
-  {
-    v8 = v7;
-    Stra = 24;
-    do
-    {
-      *(unsigned int *)v6 += (unsigned __int8)*v8;
-      v8 += 20;
-      --Stra;
-    }
-    while ( Stra );
-    v6 += 4;
-    ++v7;
-    --v73;
-  }
-  while ( v73 );
-  strtok(0, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
-  Strb = 17856;
-  do
-  {
-    v9 = strtok(0, "\r") + 1;
-    v98 = 0;
-    v89 = 0;
-    do
-    {
-      v10 = *v9;
-      v11 = 0;
-      while ( v10 != 9 && v10 )
-      {
-        ++v11;
-        v10 = v9[v11];
-      }
-      v12 = (int)&v9[v11];
-      if ( !v9[v11] )
-        v89 = 1;
-      *(unsigned char *)v12 = 0;
-      if ( v11 && v98 > 1 )
-        *(&pItems[0].uItemID + v98 + Strb) = atoi(v9);
-      ++v98;
-      v9 = (char *)(v12 + 1);
-    }
-    while ( v98 < 4 && !v89 );
-    Strb += 2;
-  }
-  while ( Strb < 17868 );
-  pSpcItemsTXT_Raw = 0;
-  v13 = (char *)pEvents_LOD->LoadRaw("spcitems.txt", 0);
-  pSpcItemsTXT_Raw = v13;
-  strtok(v13, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
-  v80 = (char *)&pSpecialEnchantments[0].pParam;
-  Strc = 72;
-  do
-  {
-    v99 = 0;
-    v14 = (int)(strtok(0, "\r") + 1);
-    v90 = 0;
-    do
-    {
-      v15 = *(unsigned char *)v14;
-      v16 = 0;
-      while ( v15 != 9 && v15 )
-      {
-        ++v16;
-        v15 = *(unsigned char *)(v16 + v14);
-      }
-      v74 = v16 + v14;
-      if ( !*(unsigned char *)(v16 + v14) )
-        v90 = 1;
-      *(unsigned char *)(v16 + v14) = 0;
-      if ( v16 )
-      {
-        if ( v99 )
-        {
-          if ( v99 == 1 )
-          {
-            *(char **)v80 = RemoveQuotes((char *)v14);
-          }
-          else
-          {
-            if ( v99 <= 1 )
-            {
-              v17 = v99 == 14;
-            }
-            else
-            {
-              v17 = v99 == 14;
-              if ( v99 < 14 )
-              {
-                v80[v99 + 6] = atoi((const char *)v14);
-                goto LABEL_63;
-              }
-            }
-            if ( v17 )
-            {
-              v18 = atoi((const char *)v14);
-              *((unsigned int *)v80 + 5) = v18;
-              if ( !v18 )
-                *((unsigned int *)v80 + 5) = atoi((const char *)(v14 + 1));
-            }
-            else
-            {
-              if ( v99 == 15 )
-                v80[24] = tolower(*(unsigned char *)v14) - 97;
-            }
-          }
-        }
-        else
-        {
-          *((char **)v80 + 1) = RemoveQuotes((char *)v14);
-        }
-      }
-      else
-      {
-        if ( !v99 )
-          v90 = 1;
-      }
-LABEL_63:
-      ++v99;
-      v14 = v74 + 1;
-    }
-    while ( v99 <= 15 && !v90 );
-    v80 += 28;
-    --Strc;
-  }
-  while ( Strc );
-  v19 = field_11738;
-  memset(field_11738, 0, 0x60u);
-  v20 = &pSpecialEnchantments[0].field_8[4];
-  Strd = 12;
-  v21 = 71;
-  field_11798 = 71;
-  do
-  {
-    v83 = 0;
-    if ( v21 > 0 )
-    {
-      v22 = v20;
-      do
-      {
-        *v19 += (unsigned __int8)*v22;
-        ++v83;
-        v21 = field_11798;
-        v22 += 28;
-      }
-      while ( v83 < v21 );
-    }
-    ++v19;
-    ++v20;
-    --Strd;
-  }
-  while ( Strd );
-  Initialize2DA();
-  pItemsTXT_Raw = 0;
-  v23 = (char *)pEvents_LOD->LoadRaw("items.txt", 0);
-  pItemsTXT_Raw = v23;
-  strtok(v23, "\r");
-  v24 = 0;
-  strtok(0, "\r");
-  pItems[0].uItemID = 0;
-  while ( 2 )
-  {
-    v100 = 0;
-    v25 = strtok(0, "\r") + 1;
-    v91 = 0;
-    while ( 2 )
-    {
-      v26 = *v25;
-      v27 = 0;
-      while ( v26 != 9 && v26 )
-      {
-        ++v27;
-        v26 = v25[v27];
-      }
-      v75 = (int)&v25[v27];
-      if ( !v25[v27] )
-        v91 = 1;
-      v25[v27] = 0;
-      if ( v27 )
-      {
-        switch ( v100 )
-        {
-          case 0:
-            v24 = atoi(v25);
-            break;
-          case 1:
-            pItems[v24].pIconName = (char *)RemoveQuotes(v25);
-            break;
-          case 2:
-            pItems[v24].pName = (char *)RemoveQuotes(v25);
-            break;
-          case 3:
-            pItems[v24].uValue = atoi(v25);
-            break;
-          case 4:
-            if ( !_strcmpi(v25, "weapon") )
-              goto LABEL_89;
-            if ( _strcmpi(v25, "weapon2") )
-            {
-              if ( _strcmpi(v25, "weapon1or2") )
-              {
-                if ( _strcmpi(v25, "missile") && _strcmpi(v25, "bow") )
-                {
-                  if ( _strcmpi(v25, "armor") )
-                  {
-                    if ( _strcmpi(v25, "shield") )
-                    {
-                      if ( _strcmpi(v25, "helm") )
-                      {
-                        if ( _strcmpi(v25, "belt") )
-                        {
-                          if ( _strcmpi(v25, "cloak") )
-                          {
-                            if ( _strcmpi(v25, "gauntlets") )
-                            {
-                              if ( _strcmpi(v25, "boots") )
-                              {
-                                if ( _strcmpi(v25, "ring") )
-                                {
-                                  if ( _strcmpi(v25, "amulet") )
-                                  {
-                                    if ( _strcmpi(v25, "weaponw") )
-                                    {
-                                      if ( _strcmpi(v25, "herb") && _strcmpi(v25, "reagent") )
-                                      {
-                                        if ( _strcmpi(v25, "bottle") )
-                                        {
-                                          if ( _strcmpi(v25, "sscroll") )
-                                          {
-                                            if ( _strcmpi(v25, "book") )
-                                            {
-                                              if ( _strcmpi(v25, "mscroll") )
-                                              {
-                                                if ( _strcmpi(v25, "gold") )
-                                                {
-                                                  if ( _strcmpi(v25, "gem") )
-                                                    pItems[v24].uEquipType = 20;
-                                                  else
-                                                    pItems[v24].uEquipType = 19;
-                                                }
-                                                else
-                                                {
-                                                  pItems[v24].uEquipType = 18;
-                                                }
-                                              }
-                                              else
-                                              {
-                                                pItems[v24].uEquipType = 17;
-                                              }
-                                            }
-                                            else
-                                            {
-                                              pItems[v24].uEquipType = 16;
-                                            }
-                                          }
-                                          else
-                                          {
-                                            pItems[v24].uEquipType = 15;
-                                          }
-                                        }
-                                        else
-                                        {
-                                          pItems[v24].uEquipType = 14;
-                                        }
-                                      }
-                                      else
-                                      {
-                                        pItems[v24].uEquipType = 13;
-                                      }
-                                    }
-                                    else
-                                    {
-                                      pItems[v24].uEquipType = 12;
-                                    }
-                                  }
-                                  else
-                                  {
-                                    pItems[v24].uEquipType = 11;
-                                  }
-                                }
-                                else
-                                {
-                                  pItems[v24].uEquipType = 10;
-                                }
-                              }
-                              else
-                              {
-                                pItems[v24].uEquipType = 9;
-                              }
-                            }
-                            else
-                            {
-                              pItems[v24].uEquipType = 8;
-                            }
-                          }
-                          else
-                          {
-                            pItems[v24].uEquipType = 7;
-                          }
-                        }
-                        else
-                        {
-                          pItems[v24].uEquipType = 6;
-                        }
-                      }
-                      else
-                      {
-                        pItems[v24].uEquipType = 5;
-                      }
-                    }
-                    else
-                    {
-                      pItems[v24].uEquipType = 4;
-                    }
-                  }
-                  else
-                  {
-                    pItems[v24].uEquipType = 3;
-                  }
-                }
-                else
-                {
-                  pItems[v24].uEquipType = 2;
-                }
-              }
-              else
-              {
-LABEL_89:
-                pItems[v24].uEquipType = 0;
-              }
-            }
-            else
-            {
-              pItems[v24].uEquipType = 1;
-            }
-            break;
-          case 5:
-            if ( _strcmpi(v25, "staff") )
-            {
-              if ( _strcmpi(v25, "sword") )
-              {
-                if ( _strcmpi(v25, "dagger") )
-                {
-                  if ( _strcmpi(v25, "axe") )
-                  {
-                    if ( _strcmpi(v25, "spear") )
-                    {
-                      if ( _strcmpi(v25, "bow") )
-                      {
-                        if ( _strcmpi(v25, "mace") )
-                        {
-                          if ( _strcmpi(v25, "blaster") )
-                          {
-                            if ( _strcmpi(v25, "shield") )
-                            {
-                              if ( _strcmpi(v25, "leather") )
-                              {
-                                if ( _strcmpi(v25, "chain") )
-                                {
-                                  if ( _strcmpi(v25, "plate") )
-                                  {
-                                    if ( _strcmpi(v25, "club") )
-                                      pItems[v24].uSkillType = 38;
-                                    else
-                                      pItems[v24].uSkillType = 37;
-                                  }
-                                  else
-                                  {
-                                    pItems[v24].uSkillType = 11;
-                                  }
-                                }
-                                else
-                                {
-                                  pItems[v24].uSkillType = 10;
-                                }
-                              }
-                              else
-                              {
-                                pItems[v24].uSkillType = 9;
-                              }
-                            }
-                            else
-                            {
-                              pItems[v24].uSkillType = 8;
-                            }
-                          }
-                          else
-                          {
-                            pItems[v24].uSkillType = 7;
-                          }
-                        }
-                        else
-                        {
-                          pItems[v24].uSkillType = 6;
-                        }
-                      }
-                      else
-                      {
-                        pItems[v24].uSkillType = 5;
-                      }
-                    }
-                    else
-                    {
-                      pItems[v24].uSkillType = 4;
-                    }
-                  }
-                  else
-                  {
-                    pItems[v24].uSkillType = 3;
-                  }
-                }
-                else
-                {
-                  pItems[v24].uSkillType = 2;
-                }
-              }
-              else
-              {
-                pItems[v24].uSkillType = 1;
-              }
-            }
-            else
-            {
-              pItems[v24].uSkillType = 0;
-            }
-            break;
-          case 6:
-            Stre = 0;
-            v84 = strlen(v25);
-            if ( (signed int)v84 > 0 )
-            {
-              while ( tolower((unsigned __int8)v25[Stre]) != 'd' )
-              {
-                ++Stre;
-                if ( Stre >= (signed int)v84 )
-                  goto LABEL_161;
-              }
-              v25[Stre] = 0;
-              v28 = (char *)&pItems[v24];
-              v28[34] = atoi(v25);
-              v28[35] = atoi(&v25[Stre + 1]);
-              v25[Stre] = 'd';
-            }
-LABEL_161:
-            if ( Stre == v84 && tolower((unsigned __int8)*v25) != 115 )
-            {
-              v29 = (char *)&pItems[v24];
-              v29[34] = atoi(v25);
-              v29[35] = 1;
-            }
-            break;
-          case 7:
-            pItems[v24].uDamageMod = atoi(v25);
-            break;
-          case 8:
-            if ( _strcmpi(v25, "artifact") )
-            {
-              if ( _strcmpi(v25, "relic") )
-              {
-                if ( _strcmpi(v25, "special") )
-                  pItems[v24].uMaterial = 0;
-                else
-                  pItems[v24].uMaterial = 3;
-              }
-              else
-              {
-                pItems[v24].uMaterial = 2;
-              }
-            }
-            else
-            {
-              pItems[v24].uMaterial = 1;
-            }
-            break;
-          case 9:
-            BYTE2(pItems[v24 + 1].uItemID) = atoi(v25);
-            break;
-          case 10:
-            pItems[v24].pUnidentifiedName = (char *)RemoveQuotes(v25);
-            break;
-          case 11:
-            pItems[v24].uSpriteID = atoi(v25);
-            break;
-          case 12:
-            v30 = (char *)&pItems[v24];
-            v81 = v30;
-            if ( v30[37] == 3 )
-            {
-              v85 = 0;
-              Strf = (const char **)&pEnchantments[0].pParam;
-              while ( _strcmpi(*Strf, v25) )
-              {
-                ++v85;
-                Strf += 5;
-                if ( v85 >= 24 )
-                  goto LABEL_181;
-              }
-              v81[39] = v85 + 1;
-LABEL_181:
-              if ( !v81[39] )
-              {
-                v86 = 0;
-                Strg = (const char **)&pSpecialEnchantments[0].pParam;
-                while ( _strcmpi(*Strg, v25) )
-                {
-                  ++v86;
-                  Strg += 7;
-                  if ( v86 >= 72 )
-                    goto LABEL_196;
-                }
-                v81[38] = v86 + 1;
-              }
-            }
-            else
-            {
-              v30[38] = 0;
-              v30[39] = 0;
-            }
-            break;
-          case 13:
-            v31 = (char *)&pItems[v24];
-            v82 = v31;
-            if ( v31[37] == 3 && v31[39] )
-            {
-              v32 = atoi(v25);
-              v82[40] = v32;
-              if ( !v32 )
-                v82[40] = 1;
-            }
-            else
-            {
-              v31[40] = 0;
-            }
-            break;
-          case 14:
-            pItems[v24].uEquipX = atoi(v25);
-            break;
-          case 15:
-            pItems[v24].uEquipY = atoi(v25);
-            break;
-          case 16:
-            pItems[v24].pDescription = (char *)RemoveQuotes(v25);
-            break;
-          default:
-            break;
-        }
-      }
-LABEL_196:
-      ++v100;
-      v25 = (char *)(v75 + 1);
-      if ( v100 <= 16 && !v91 )
-        continue;
-      break;
-    }
-    ++v24;
-    if ( v24 < 800 )
-      continue;
-    break;
-  }
-  pRndItemsTXT_Raw = 0;
-  pItems[0].uItemID = v24;
-  v33 = (char *)pEvents_LOD->LoadRaw("rnditems.txt", 0);
-  v34 = "\r";
-  pRndItemsTXT_Raw = v33;
-  strtok(v33, "\r");
-  v35 = 0;
-  strtok(0, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
-  do
-  {
-    v101 = 0;
-    v36 = strtok(0, "\r") + 1;
-    v92 = 0;
-    do
-    {
-      v37 = *v36;
-      v38 = 0;
-      while ( v37 != 9 && v37 )
-      {
-        ++v38;
-        v37 = v36[v38];
-      }
-      v76 = (int)&v36[v38];
-      if ( !v36[v38] )
-        v92 = 1;
-      *(unsigned char *)v76 = 0;
-      if ( v38 )
-      {
-        if ( v101 )
-        {
-          switch ( v101 )
-          {
-            case 2:
-              pItems[v35].field_2C = atoi(v36);
-              break;
-            case 3:
-              pItems[v35].field_2D = atoi(v36);
-              break;
-            case 4:
-              pItems[v35].field_2E = atoi(v36);
-              break;
-            case 5:
-              pItems[v35].field_2F = atoi(v36);
-              break;
-            case 6:
-              *((unsigned char *)&pItems[0].uItemID + 16 * (3 * v35 + 3)) = atoi(v36);
-              break;
-            case 7:
-              BYTE1(pItems[v35 + 1].uItemID) = atoi(v36);
-              break;
-          }
-        }
-        else
-        {
-          v35 = atoi(v36);
-        }
-      }
-      else
-      {
-        if ( !v101 )
-          v92 = 1;
-      }
-      ++v101;
-      v36 = (char *)(v76 + 1);
-    }
-    while ( v101 <= 7 && !v92 );
-    ++v35;
-  }
-  while ( v35 < 619 );
-  if ( pRndItemsTXT_Raw )
-  {
-    pAllocator->FreeChunk(pRndItemsTXT_Raw);
-    pRndItemsTXT_Raw = 0;
-  }
-  v39 = (char *)field_11684;
-  memset(field_11684, 0, 0x18u);
-  v40 = &pItems[0].field_2C;
-  v77 = 6;
-  do
-  {
-    v41 = v40;
-    Strh = 800;
-    do
-    {
-      *(unsigned int *)v39 += (unsigned __int8)*v41;
-      v41 += 48;
-      --Strh;
-    }
-    while ( Strh );
-    v39 += 4;
-    ++v40;
-    --v77;
-  }
-  while ( v77 );
-  v42 = 0;
-  strtok(0, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
-  v87 = 0;
-  do
-  {
-    v43 = strtok(v42, "\r") + 1;
-    v102 = (signed int)v42;
-    v93 = (signed int)v42;
-    do
-    {
-      v44 = *v43;
-      v45 = 0;
-      while ( v44 != 9 && v44 )
-      {
-        ++v45;
-        v44 = v43[v45];
-      }
-      v78 = (int)&v43[v45];
-      if ( !v43[v45] )
-        v93 = 1;
-      v42 = 0;
-      *(unsigned char *)v78 = 0;
-      if ( v45 )
-      {
-        switch ( v102 )
-        {
-          case 2:
-            if ( v87 )
-            {
-              if ( v87 == 1 )
-              {
-                *(unsigned int *)&field_1169C[24] = atoi(v43);
-              }
-              else
-              {
-                if ( v87 == 2 )
-                  *(unsigned int *)&field_1169C[48] = atoi(v43);
-              }
-            }
-            else
-            {
-              *(unsigned int *)&field_1169C[0] = atoi(v43);
-            }
-            break;
-          case 3:
-            if ( v87 )
-            {
-              if ( v87 == 1 )
-              {
-                *(unsigned int *)&field_1169C[28] = atoi(v43);
-              }
-              else
-              {
-                if ( v87 == 2 )
-                  *(unsigned int *)&field_1169C[52] = atoi(v43);
-              }
-            }
-            else
-            {
-              *(unsigned int *)&field_1169C[4] = atoi(v43);
-            }
-            break;
-          case 4:
-            if ( v87 )
-            {
-              if ( v87 == 1 )
-              {
-                *(unsigned int *)&field_1169C[32] = atoi(v43);
-              }
-              else
-              {
-                if ( v87 == 2 )
-                  *(unsigned int *)&field_1169C[56] = atoi(v43);
-              }
-            }
-            else
-            {
-              *(unsigned int *)&field_1169C[8] = atoi(v43);
-            }
-            break;
-          case 5:
-            if ( v87 )
-            {
-              if ( v87 == 1 )
-              {
-                *(unsigned int *)&field_1169C[36] = atoi(v43);
-              }
-              else
-              {
-                if ( v87 == 2 )
-                  field_116D8[0] = atoi(v43);
-              }
-            }
-            else
-            {
-              *(unsigned int *)&field_1169C[12] = atoi(v43);
-            }
-            break;
-          case 6:
-            if ( v87 )
-            {
-              if ( v87 == 1 )
-              {
-                *(unsigned int *)&field_1169C[40] = atoi(v43);
-              }
-              else
-              {
-                if ( v87 == 2 )
-                  field_116D8[1] = atoi(v43);
-              }
-            }
-            else
-            {
-              *(unsigned int *)&field_1169C[16] = atoi(v43);
-            }
-            break;
-          case 7:
-            if ( v87 )
-            {
-              if ( v87 == 1 )
-              {
-                *(unsigned int *)&field_1169C[44] = atoi(v43);
-              }
-              else
-              {
-                if ( v87 == 2 )
-                  field_116D8[2] = atoi(v43);
-              }
-            }
-            else
-            {
-              *(unsigned int *)&field_1169C[20] = atoi(v43);
-            }
-            break;
-        }
-      }
-      ++v102;
-      v43 = (char *)(v78 + 1);
-    }
-    while ( v102 <= 7 && !v93 );
-    ++v87;
-  }
-  while ( v87 < 3 );
-  pSkillDescTXT_Raw = 0;
-  pSkillDescTXT_Raw = (char *)pEvents_LOD->LoadRaw("skilldes.txt", 0);
-  strtok(pSkillDescTXT_Raw, "\r");
-  v46 = 0;
-  do
-  {
-    v103 = 0;
-    v94 = 0;
-    v47 = strtok(0, "\r") + 1;
-    do
-    {
-      v48 = *v47;
-      v49 = 0;
-      while ( v48 != 9 && v48 )
-      {
-        ++v49;
-        v48 = v47[v49];
-      }
-      v50 = (int)&v47[v49];
-      if ( !v47[v49] )
-        v94 = 1;
-      *(unsigned char *)v50 = 0;
-      if ( v49 )
-      {
-        switch ( v103 )
-        {
-          case 1:
-            pSkillDesc[v46] = (char *)RemoveQuotes(v47);
-            break;
-          case 2:
-            pNormalSkillDesc[v46] = (char *)RemoveQuotes(v47);
-            break;
-          case 3:
-            pExpertSkillDesc[v46] = (char *)RemoveQuotes(v47);
-            break;
-          case 4:
-            pMasterSkillDesc[v46] = (char *)RemoveQuotes(v47);
-            break;
-          case 5:
-            pGrandSkillDesc[v46] = (char *)RemoveQuotes(v47);
-            break;
-        }
-      }
-      else
-      {
-        if ( !v103 )
-          v94 = 1;
-      }
-      ++v103;
-      v47 = (char *)(v50 + 1);
-    }
-    while ( v103 <= 5 && !v94 );
-    ++v46;
-  }
-  while ( v46 < 37 );
-  pStatsTXT_Raw = 0;
-  pStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stats.txt", 0);
-  strtok(pStatsTXT_Raw, "\r");
-  Stri = 0;
-  do
-  {
-    v51 = 0;
-    v95 = 0;
-    v52 = strtok(0, v34) + 1;
-    do
-    {
-      v53 = *v52;
-      v54 = 0;
-      if ( *v52 != 9 )
-      {
-        do
-        {
-          if ( !v53 )
-            break;
-          ++v54;
-          v53 = v52[v54];
-        }
-        while ( v53 != 9 );
-        v34 = "\r";
-      }
-      v55 = (int)&v52[v54];
-      if ( !v52[v54] )
-        v95 = 1;
-      *(unsigned char *)v55 = 0;
-      if ( v54 )
-      {
-        if ( v51 )
-        {
-          switch ( Stri )
-          {
-            case 0:
-            case 1:
-            case 2:
-            case 3:
-            case 4:
-            case 5:
-            case 6:
-              pAttributeDescriptions[Stri] = (char *)RemoveQuotes(v52);
-              break;
-            case 7:
-              pHealthPointsAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 8:
-              pArmourClassAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 9:
-              pSpellPointsAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 10:
-              pPlayerConditionAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 11:
-              pFastSpellAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 12:
-              pPlayerAgeAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 13:
-              pPlayerLevelAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 14:
-              pPlayerExperienceAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 15:
-              pAttackBonusAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 16:
-              pAttackDamageAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 17:
-              pMissleBonusAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 18:
-              pMissleDamageAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 19:
-              pFireResistanceAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 20:
-              pAirResistanceAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 21:
-              pWaterResistanceAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 22:
-              pEarthResistanceAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 23:
-              pMindResistanceAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 24:
-              pBodyResistanceAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 25:
-              pSkillPointsAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            default:
-              break;
-          }
-        }
-      }
-      else
-      {
-        if ( !v51 )
-          v95 = 1;
-      }
-      ++v51;
-      v52 = (char *)(v55 + 1);
-    }
-    while ( v51 < 2 && !v95 );
-    ++Stri;
-  }
-  while ( Stri < 26 );
-  pClassTXT_Raw = 0;
-  pClassTXT_Raw = (char *)pEvents_LOD->LoadRaw("class.txt", 0);
-  strtok(pClassTXT_Raw, v34);
-  Strj = pClassDescriptions;
-  do
-  {
-    v56 = 0;
-    v57 = strtok(0, v34) + 1;
-    v96 = 0;
-    do
-    {
-      v58 = *v57;
-      v59 = 0;
-      if ( *v57 != 9 )
-      {
-        do
-        {
-          if ( !v58 )
-            break;
-          ++v59;
-          v58 = v57[v59];
-        }
-        while ( v58 != 9 );
-        v34 = "\r";
-      }
-      v60 = (int)&v57[v59];
-      if ( !v57[v59] )
-        v96 = 1;
-      *(unsigned char *)v60 = 0;
-      if ( v59 )
-      {
-        if ( v56 )
-          *Strj = (char *)RemoveQuotes(v57);
-      }
-      else
-      {
-        if ( !v56 )
-          v96 = 1;
-      }
-      ++v56;
-      v57 = (char *)(v60 + 1);
-    }
-    while ( v56 < 2 && !v96 );
-    ++Strj;
-  }
-  while ( (signed int)Strj <= (signed int)&pClassDescriptions[35] );
-}
+	pItemsTXT_Raw = NULL;
+	pItemsTXT_Raw = (char*) pEvents_LOD->LoadRaw("items.txt", 0);
+	strtok(pItemsTXT_Raw, "\r");
+	strtok(NULL, "\r");
+	uAllItemsCount = 0;
+	item_counter = 0;
+	while (true)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				switch (decode_step)
+					{
+				case 0: //Item #
+					item_counter=atoi(test_string);
+					uAllItemsCount=item_counter;
+					break;
+				case 1: //Pic File
+					pItems[item_counter].pIconName = RemoveQuotes(test_string);
+					break;
+				case 2: //Name
+					pItems[item_counter].pName = RemoveQuotes(test_string);
+					break;
+				case 3: //Value
+					pItems[item_counter].uValue=atoi(test_string);
+					break;
+				case 4: //Equip Stat
+					{
+					if ( !_strcmpi(test_string, "weapon") )
+						{
+						pItems[item_counter].uEquipType = 0;
+						break;
+						}
+					if ( !_strcmpi(test_string, "weapon2") )
+						{
+						pItems[item_counter].uEquipType = 1;
+						break;
+						}
+					if ( !_strcmpi(test_string, "weapon1or2") )
+						{
+						pItems[item_counter].uEquipType = 0;
+						break;
+						}
+					if ( !(_strcmpi(test_string, "missile")&&_strcmpi(test_string, "bow")))
+						{
+						pItems[item_counter].uEquipType = 2;
+						break;
+						}
+					if ( !_strcmpi(test_string, "armor") )
+						{
+						pItems[item_counter].uEquipType = 3;
+						break;
+						}
+					if ( !_strcmpi(test_string, "shield") )
+						{
+						pItems[item_counter].uEquipType = 4;
+						break;
+						}
+					if ( !_strcmpi(test_string, "helm") )
+						{
+						pItems[item_counter].uEquipType = 5;
+						break;
+						}
+					if ( !_strcmpi(test_string, "belt") )
+						{
+						pItems[item_counter].uEquipType = 6;
+						break;
+						}
+					if ( !_strcmpi(test_string, "cloak") )
+						{
+						pItems[item_counter].uEquipType = 7;
+						break;
+						}
+					if ( !_strcmpi(test_string, "gauntlets") )
+						{
+						pItems[item_counter].uEquipType = 8;
+						break;
+						}
+					if ( !_strcmpi(test_string, "boots") )
+						{
+						pItems[item_counter].uEquipType = 9;
+						break;
+						}
+					if ( !_strcmpi(test_string, "ring") )
+						{
+						pItems[item_counter].uEquipType = 10;
+						break;
+						}
+					if ( !_strcmpi(test_string, "amulet") )
+						{
+						pItems[item_counter].uEquipType = 11;
+						break;
+						}
+					if ( !_strcmpi(test_string, "weaponw") )
+						{
+						pItems[item_counter].uEquipType = 12;
+						break;
+						}
+					if ( !(_strcmpi(test_string, "herb")&&_strcmpi(test_string, "reagent")))
+						{
+						pItems[item_counter].uEquipType = 13;
+						break;
+						}
+					if ( !_strcmpi(test_string, "bottle") )
+						{
+						pItems[item_counter].uEquipType = 14;
+						break;
+						}
+					if ( !_strcmpi(test_string, "sscroll") )
+						{
+						pItems[item_counter].uEquipType = 15;
+						break;
+						}
+					if ( !_strcmpi(test_string, "book") )
+						{
+						pItems[item_counter].uEquipType = 16;
+						break;
+						}
+					if ( !_strcmpi(test_string, "mscroll") )
+						{
+						pItems[item_counter].uEquipType = 17;
+						break;
+						}
+					if ( !_strcmpi(test_string, "gold") )
+						{
+						pItems[item_counter].uEquipType = 18;
+						break;
+						}
+					if ( !_strcmpi(test_string, "gem") )
+						{
+						pItems[item_counter].uEquipType = 19;
+						break;
+						}
+					pItems[item_counter].uEquipType = 20;
+					break;
+					}
+				case 5: //Skill Group
+					{
+					if ( !_strcmpi(test_string, "staff") )
+						{
+						pItems[item_counter].uSkillType = 0;
+						break;
+						}
+					if ( !_strcmpi(test_string, "sword") )
+						{
+						pItems[item_counter].uSkillType = 1;
+						break;
+						}
+					if ( !_strcmpi(test_string, "dagger") )
+						{
+						pItems[item_counter].uSkillType = 2;
+						break;
+						}
+					if ( !_strcmpi(test_string, "axe") )
+						{
+						pItems[item_counter].uSkillType = 3;
+						break;
+						}
+					if ( !_strcmpi(test_string, "spear") )
+						{
+						pItems[item_counter].uSkillType = 4;
+						break;
+						}
+					if ( !_strcmpi(test_string, "bow") )
+						{
+						pItems[item_counter].uSkillType = 5;
+						break;
+						}
+					if ( !_strcmpi(test_string, "mace") )
+						{
+						pItems[item_counter].uSkillType = 6;
+						break;
+						}
+					if ( !_strcmpi(test_string, "blaster") )
+						{
+						pItems[item_counter].uSkillType = 7;
+						break;
+						}
+					if ( !_strcmpi(test_string, "shield") )
+						{
+						pItems[item_counter].uSkillType = 8;
+						break;
+						}
+					if ( !_strcmpi(test_string, "leather") )
+						{
+						pItems[item_counter].uSkillType = 9;
+						break;
+						}
+					if ( !_strcmpi(test_string, "chain") )
+						{
+						pItems[item_counter].uSkillType = 10;
+						break;
+						}
+					if ( !_strcmpi(test_string, "plate") )
+						{
+						pItems[item_counter].uSkillType = 11;
+						break;
+						}
+					if ( !_strcmpi(test_string, "club") )
+						{
+						pItems[item_counter].uSkillType = 37;
+						break;
+						}
+					pItems[item_counter].uSkillType = 38;
+					break;
+					}
+				case 6: //Mod1
+					{
+					int ii;
+					char* test_char;
+					int tst_len;
+					tst_len=strlen(test_string);
+					pItems[item_counter].uDamageDice=0;
+					pItems[item_counter].uDamageRoll=0;
+					test_char=test_string;
+					for (ii=0; ii<tst_len; ++ii)
+						{
+						if (tolower(*test_char)=='d')
+							{
+							*test_char=0;
+							pItems[item_counter].uDamageDice=atoi(test_string);
+							pItems[item_counter].uDamageRoll=atoi(test_char+1);
+							*test_char='d';
+							break;
+							}
+						++test_char;
+						}
+					test_char=test_string;
+					if ((ii==tst_len)&&(tolower(*test_char)=='s'))
+						{
+						pItems[item_counter].uDamageDice=atoi(test_char+1);
+						pItems[item_counter].uDamageRoll=1;
+						}
+					break;
+					}
+				case 7: //Mod2
+					pItems[item_counter].uDamageMod=atoi(test_string);
+					break;
+				case 8: //material
+					{
+					if ( !_strcmpi(test_string, "artifact") )
+						{
+						pItems[item_counter].uMaterial = 1;
+						break;
+						}
+					if ( !_strcmpi(test_string, "relic") )
+						{
+						pItems[item_counter].uMaterial = 2;
+						break;
+						}
+					if ( !_strcmpi(test_string, "special") )
+						{
+						pItems[item_counter].uMaterial = 3;
+						break;
+						}
+					pItems[item_counter].uMaterial = 0;
+					break;}
+				case 9:  //ID/Rep/St
+					pItems[item_counter].uItemID_Rep_St=atoi(test_string);
+					break;
+				case 10: //Not identified name
+					pItems[item_counter].pUnidentifiedName = RemoveQuotes(test_string);
+					break;
+				case 11: //Sprite Index
+					pItems[item_counter].uSpriteID=atoi(test_string);
+					break;
+				case 12: //VarA
+					{
+					pItems[item_counter]._additional_value=0;
+					pItems[item_counter]._bonus_type=0;
+					if (pItems[item_counter].uMaterial==3)
+						{
+						for(int ii=0; ii<24; ++ii)
+							{
+							if (stricmp(test_string,pEnchantments[ii].pBonusStat))
+								{
+								pItems[item_counter]._bonus_type=ii+1;
+								break;
+								}
+							}
+						if (!pItems[item_counter]._bonus_type)
+							{
+							for(int ii=0; ii<72; ++ii)
+								{
+								if (stricmp(test_string,pSpecialEnchantments[ii].pBonusStatement))
+									{
+									pItems[item_counter]._additional_value=ii+1;
+									}
+								}
+							}
+						}
+
+					break;
+					}
+				case 13: //VarB
+					if ((pItems[item_counter].uMaterial==3)&&(pItems[item_counter]._bonus_type))
+						{
+						char b_s=atoi(test_string);
+						if (b_s)
+							pItems[item_counter]._bonus_strength=b_s;
+						else
+							pItems[item_counter]._bonus_strength=1;
+						}
+					else
+						pItems[item_counter]._bonus_strength=0;
+					break;
+				case 14: //Equip X
+					pItems[item_counter].uEquipX=atoi(test_string);
+					break;
+				case 15: //Equip Y
+					pItems[item_counter].uEquipY=atoi(test_string);
+					break;
+				case 16: //Notes
+					pItems[item_counter].pDescription = RemoveQuotes(test_string);
+					break;
+
+					}
+				}
+			else
+				{ 
+				if (!decode_step)
+					break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<17)&&!break_loop);
+			++item_counter;
+			if (item_counter>799)
+				break;
+		}
+
+
+	pRndItemsTXT_Raw = NULL;
+	uAllItemsCount = item_counter;
+	pRndItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("rnditems.txt", 0);
+	strtok(pRndItemsTXT_Raw, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	item_counter = 0;
+	while (true)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				switch (decode_step)
+					{
+				case 0: 
+					item_counter=atoi(test_string);
+					break;
+				case 2:
+					pItems[item_counter].uChanceByTreasureLvl1=atoi(test_string);
+					break;
+				case 3:
+					pItems[item_counter].uChanceByTreasureLvl2=atoi(test_string);
+					break;
+				case 4:
+					pItems[item_counter].uChanceByTreasureLvl3=atoi(test_string);
+					break;
+				case 5:
+					pItems[item_counter].uChanceByTreasureLvl4=atoi(test_string);
+					break;
+				case 6:
+					pItems[item_counter].uChanceByTreasureLvl5=atoi(test_string);
+					break;
+				case 7:
+					pItems[item_counter].uChanceByTreasureLvl6=atoi(test_string);
+					break;
+					}
+				}
+			else
+				{ 
+				if (!decode_step)
+					break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<8)&&!break_loop);
+			++item_counter;
+			if (item_counter>618)
+				break;
+		}
+
+	if ( pRndItemsTXT_Raw )
+		{
+		pAllocator->FreeChunk(pRndItemsTXT_Raw);
+		pRndItemsTXT_Raw = NULL;
+		}
+	//ChanceByTreasureLvl Summ - anti cheating?
+	memset(&uChanceByTreasureLvlSumm, 0, 24);
+	for(i=0;i<6;++i)
+		{
+		for (j=0;j<800;++j)
+			uChanceByTreasureLvlSumm[i]+=pItems[j].uChanceByTreasureLvl[i];
+		}
+
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	for (i=0;i<3;++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				switch (decode_step)
+					{
+				case 2: 
+					switch (i)
+						{
+					case 0:
+						uBonusChanceStandart[0]=atoi(test_string);
+						break;
+					case 1:
+						uBonusChanceSpecial[0]=atoi(test_string);
+						break;
+					case 2:
+						uBonusChanceWpSpecial[0]=atoi(test_string);
+						break;
+						}
+					break;
+				case 3:
+					switch (i)
+						{
+					case 0:
+						uBonusChanceStandart[1]=atoi(test_string);
+						break;
+					case 1:
+						uBonusChanceSpecial[1]=atoi(test_string);
+						break;
+					case 2:
+						uBonusChanceWpSpecial[1]=atoi(test_string);
+						break;
+						}
+					break;
+				case 4: 
+					switch (i)
+						{
+					case 0:
+						uBonusChanceStandart[2]=atoi(test_string);
+						break;
+					case 1:
+						uBonusChanceSpecial[2]=atoi(test_string);
+						break;
+					case 2:
+						uBonusChanceWpSpecial[2]=atoi(test_string);
+						break;
+						}
+					break;
+				case 5:
+					switch (i)
+						{
+					case 0:
+						uBonusChanceStandart[3]=atoi(test_string);
+						break;
+					case 1:
+						uBonusChanceSpecial[3]=atoi(test_string);
+						break;
+					case 2:
+						uBonusChanceWpSpecial[3]=atoi(test_string);
+						break;
+						}
+					break;
+				case 6: 
+					switch (i)
+						{
+					case 0:
+						uBonusChanceStandart[4]=atoi(test_string);
+						break;
+					case 1:
+						uBonusChanceSpecial[4]=atoi(test_string);
+						break;
+					case 2:
+						uBonusChanceWpSpecial[4]=atoi(test_string);
+						break;
+						}
+					break;
+				case 7:
+					switch (i)
+						{
+					case 0:
+						uBonusChanceStandart[5]=atoi(test_string);
+						break;
+					case 1:
+						uBonusChanceSpecial[5]=atoi(test_string);
+						break;
+					case 2:
+						uBonusChanceWpSpecial[5]=atoi(test_string);
+						break;
+						}
+					break;
+					}
+				}
+			else
+				{ 
+				if (!decode_step)
+					break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<8)&&!break_loop);
+		}
+
+	pSkillDescTXT_Raw = NULL;
+	pSkillDescTXT_Raw = (char *)pEvents_LOD->LoadRaw("skilldes.txt", 0);
+	strtok(pSkillDescTXT_Raw, "\r");
+	for (i=0; i<37; ++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				switch (decode_step)
+					{
+				case 1:
+					pSkillDesc[i] = RemoveQuotes(test_string);
+					break;
+				case 2:
+					pNormalSkillDesc[i] = RemoveQuotes(test_string);
+					break;
+				case 3:
+					pExpertSkillDesc[i] = RemoveQuotes(test_string);
+					break;
+				case 4:
+					pMasterSkillDesc[i] = RemoveQuotes(test_string);
+					break;
+				case 5:
+					pGrandSkillDesc[i] = RemoveQuotes(test_string);
+					break;	  
+					}
+				}
+			else
+				{ 
+				if (!decode_step)
+					break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<6)&&!break_loop);
+		}
+
+	pStatsTXT_Raw = 0;
+	pStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stats.txt", 0);
+	strtok(pStatsTXT_Raw, "\r");
+	for (i=0; i<26; ++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				switch (i)
+					{
+				case 0:
+				case 1:
+				case 2:
+				case 3:
+				case 4:
+				case 5:
+				case 6:
+					pAttributeDescriptions[i] = RemoveQuotes(test_string);
+					break;
+				case 7:
+					pHealthPointsAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 8:
+					pArmourClassAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 9:
+					pSpellPointsAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 10:
+					pPlayerConditionAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 11:
+					pFastSpellAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 12:
+					pPlayerAgeAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 13:
+					pPlayerLevelAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 14:
+					pPlayerExperienceAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 15:
+					pAttackBonusAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 16:
+					pAttackDamageAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 17:
+					pMissleBonusAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 18:
+					pMissleDamageAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 19:
+					pFireResistanceAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 20:
+					pAirResistanceAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 21:
+					pWaterResistanceAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 22:
+					pEarthResistanceAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 23:
+					pMindResistanceAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 24:
+					pBodyResistanceAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 25:
+					pSkillPointsAttributeDescription = RemoveQuotes(test_string);
+					break;  
+					}
+				}
+			else
+				{ 
+				if (!decode_step)
+					break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<2)&&!break_loop);
+		}
+
+
+	pClassTXT_Raw = 0;
+	pClassTXT_Raw = (char *)pEvents_LOD->LoadRaw("class.txt", 0);
+	strtok(pClassTXT_Raw, "\r");
+	for (i=0; i<36; ++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				//if(i) 
+					pClassDescriptions[i]=RemoveQuotes(test_string);
+				}
+			else
+				{ 
+				if (!decode_step)
+					break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<2)&&!break_loop);
+		}
+
+	}
 
 //----- (00456D17) --------------------------------------------------------
 void ItemsTable::SetSpecialBonus(ItemGen *pItem)
@@ -1491,196 +1223,162 @@
 
 //----- (00453B3C) --------------------------------------------------------
 void ItemsTable::LoadPotions()
-{
-  char *i; // eax@3
-  signed int v2; // esi@11
-  char *v3; // eax@16
-  char *v4; // edi@16
-  __int16 v5; // ax@17
-  char *v6; // esi@17
-  CHAR Text; // [sp+Ch] [bp-6Ch]@26
-  ItemsTable *v8; // [sp+68h] [bp-10h]@1
-  int v9; // [sp+6Ch] [bp-Ch]@10
-  int v10; // [sp+70h] [bp-8h]@10
-  char *v11; // [sp+74h] [bp-4h]@4
+	{
+
+	CHAR Text[90]; // [sp+Ch] [bp-6Ch]@26
+	char* test_string;
+	unsigned int uRow;
+	unsigned int uColumn;
+	unsigned __int8 potion_value;
+
+	if ( pPotionsTXT_Raw )
+		pAllocator->FreeChunk(pPotionsTXT_Raw);
+	pPotionsTXT_Raw = NULL;
+	pPotionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("potion.txt", 0);
+	test_string = strtok(pPotionsTXT_Raw,"\t\r\n");
+	while ( 1 )
+		{
+		if ( !test_string )
+			{
+			MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE);
+			return;
+			}
+		if ( !strcmp(test_string, "222") )
+			break;
+
+		test_string = strtok(NULL, "\t\r\n");
+		}
+	while ( 1 )
+		{
+		test_string = strtok(NULL, "\t\r\n");
+
+		if ( !test_string )
+			{
+			MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE);
+			return;
+			}
+		if ( !strcmp(test_string, "222") )
+			break;
+		}
 
-  v8 = this;
-  if ( pPotionsTXT_Raw )
-    pAllocator->FreeChunk(pPotionsTXT_Raw);
-  pPotionsTXT_Raw = 0;
-  pPotionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("potion.txt", 0);
-  for ( i = strtok(pPotionsTXT_Raw, "\t\r\n"); ; i = strtok(0, "\t\r\n") )
-  {
-    v11 = i;
-    if ( !strcmp(i, "222") )
-      break;
-    if ( !v11 )
-    {
-LABEL_20:
-      MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", 0x10u);
-      return;
-    }
-  }
-  while ( 1 )
-  {
-    v11 = strtok(0, "\t\r\n");
-    if ( !strcmp(v11, "222") )
-      break;
-    if ( !v11 )
-      goto LABEL_20;
-  }
-  v9 = 0;
-  v10 = 30642;
-  do
-  {
-    v11 = 0;
-    v2 = 0;
-    do
-    {
-      if ( !strtok(0, "\r\t\n") )
-        break;
-      ++v2;
-    }
-    while ( v2 < 6 );
-    if ( v2 != 6 )
-      break;
-    v11 = 0;
-    do
-    {
-      v3 = strtok(0, "\r\t\n");
-      v4 = v3;
-      if ( !v3 )
-        break;
-      v5 = atoi(v3);
-      v6 = (char *)v8 + 2 * (uint)&v11[v10];
-      *(_WORD *)v6 = v5;
-      if ( !v5 )
-      {
-        if ( tolower((unsigned __int8)*v4) == 101 )
-          *(_WORD *)v6 = atoi(v4 + 1);
-        else
-          *(_WORD *)v6 = 0;
-      }
-      ++v11;
-    }
-    while ( (signed int)v11 < 50 );
-    if ( v11 != (char *)50 )
-      break;
-    strtok(0, "\r\t\n");
-    v10 += 50;
-    ++v9;
-  }
-  while ( v10 < 33142 );
-  if ( v9 != 50 )
-  {
-    wsprintfA(&Text, "Error Parsing Potion Table at Row: %d Column: %d", v9, v11);
-    MessageBoxA(0, &Text, "Parsing Error", 0x10u);
-  }
-  if ( pPotionsTXT_Raw )
-  {
-    pAllocator->FreeChunk(pPotionsTXT_Raw);
-    pPotionsTXT_Raw = 0;
-  }
-}
+	for (uRow = 0;uRow < 50; ++uRow)
+		{
+		int skip_count;
+		for (skip_count = 0;skip_count < 6; ++skip_count)
+			{
+			if ( !strtok(NULL, "\r\t\n") )
+				break;
+			}
+		if ( skip_count != 6 )
+			break;
+		for (uColumn = 0; uColumn < 50; ++uColumn)
+			{
+			test_string = strtok(NULL, "\r\t\n");   
+			if ( !test_string )
+				break;
+			potion_value = atoi(test_string);
+			unsigned char c=*test_string;
+			if ( !potion_value )
+				{
+				if ( tolower(c) == 'e' )
+					potion_value = atoi(test_string + 1);
+				else
+					potion_value = 0;
+				}
+			this->potion_data[uRow][uColumn]=potion_value;
+			}
+		if ( uColumn != 50 )
+			break;
+		strtok(NULL, "\r\t\n");
+		}
+
+	if ( uRow != 50 )
+		{
+		wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, uColumn);
+		MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE);
+		}
+	if ( pPotionsTXT_Raw )
+		{
+		pAllocator->FreeChunk(pPotionsTXT_Raw);
+		pPotionsTXT_Raw = 0;
+		}
+	}
 
 //----- (00453CE5) --------------------------------------------------------
 void ItemsTable::LoadPotionNotes()
-{
-  char *i; // eax@3
-  signed int v2; // esi@11
-  char *v3; // eax@16
-  char *v4; // edi@16
-  __int16 v5; // ax@17
-  char *v6; // esi@17
-  CHAR *v7; // [sp-Ch] [bp-84h]@20
-  const CHAR *v8; // [sp-8h] [bp-80h]@20
-  UINT v9; // [sp-4h] [bp-7Ch]@20
-  CHAR Text; // [sp+Ch] [bp-6Ch]@26
-  ItemsTable *v11; // [sp+68h] [bp-10h]@1
-  int v12; // [sp+6Ch] [bp-Ch]@10
-  int v13; // [sp+70h] [bp-8h]@10
-  char *v14; // [sp+74h] [bp-4h]@4
+	{
+
+	CHAR Text[90]; 
+	char* test_string;
+	unsigned int uRow;
+	unsigned int uColumn;
+	unsigned __int8 potion_note;
+
+	if ( pPotionNotesTXT_Raw )
+		pAllocator->FreeChunk(pPotionNotesTXT_Raw);
+	pPotionNotesTXT_Raw = NULL;
+	pPotionNotesTXT_Raw = (char *)pEvents_LOD->LoadRaw("potnotes.txt", 0);
+	test_string = strtok(pPotionNotesTXT_Raw ,"\t\r\n");
+	while ( 1 )
+		{
+		if ( !test_string )
+			{
+			MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE);
+			return;
+			}	
+		if ( !strcmp(test_string, "222") )
+			break;
+		test_string = strtok(NULL, "\t\r\n");
+		}
+	while ( 1 )
+		{
+		test_string = strtok(NULL, "\t\r\n");
+
+		if ( !test_string )
+			{
+			MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE);
+			return;
+			}
+		if ( !strcmp(test_string, "222") )
+			break;
+		}
 
-  v11 = this;
-  if ( pPotionNotesTXT_Raw )
-    pAllocator->FreeChunk(pPotionNotesTXT_Raw);
-  pPotionNotesTXT_Raw = 0;
-  pPotionNotesTXT_Raw = (char *)pEvents_LOD->LoadRaw("potnotes.txt", 0);
-  for ( i = strtok(pPotionNotesTXT_Raw, "\t\r\n"); ; i = strtok(0, "\t\r\n") )
-  {
-    v14 = i;
-    if ( !strcmp(i, "222") )
-      break;
-    if ( !v14 )
-    {
-LABEL_20:
-      v9 = 16;
-      v8 = "Load Error";
-      v7 = "Error Pre-Parsing Potion Table";
-LABEL_27:
-      MessageBoxA(0, v7, v8, v9);
-      return;
-    }
-  }
-  while ( 1 )
-  {
-    v14 = strtok(0, "\t\r\n");
-    if ( !strcmp(v14, "222") )
-      break;
-    if ( !v14 )
-      goto LABEL_20;
-  }
-  v12 = 0;
-  v13 = 33142;
-  do
-  {
-    v14 = 0;
-    v2 = 0;
-    do
-    {
-      if ( !strtok(0, "\r\t\n") )
-        break;
-      ++v2;
-    }
-    while ( v2 < 6 );
-    if ( v2 != 6 )
-      break;
-    v14 = 0;
-    do
-    {
-      v3 = strtok(0, "\r\t\n");
-      v4 = v3;
-      if ( !v3 )
-        break;
-      v5 = atoi(v3);
-      v6 = (char *)v11 + 2 * (unsigned int)&v14[v13];
-      *(unsigned short *)v6 = v5;
-      if ( !v5 )
-      {
-        if ( tolower((unsigned __int8)*v4) == 101 )
-          *(unsigned short *)v6 = atoi(v4 + 1);
-        else
-          *(unsigned short *)v6 = 0;
-      }
-      ++v14;
-    }
-    while ( (signed int)v14 < 50 );
-    if ( v14 != (char *)50 )
-      break;
-    strtok(0, "\r\t\n");
-    v13 += 50;
-    ++v12;
-  }
-  while ( v13 < 35642 );
-  if ( v12 != 50 )
-  {
-    wsprintfA(&Text, "Error Parsing Potion Autonote Table at Row: %d Column: %d", v12, v14);
-    v9 = 16;
-    v8 = "Parsing Error";
-    v7 = &Text;
-    goto LABEL_27;
-  }
-}
+	for (uRow = 0;uRow < 50; ++uRow)
+		{
+		int skip_count;
+		for (skip_count = 0;skip_count < 6; ++skip_count)
+			{
+			if ( !strtok(NULL, "\r\t\n") )
+				break;
+			}
+		if ( skip_count != 6 )
+			break;
+		for (uColumn = 0; uColumn < 50; ++uColumn)
+			{
+			test_string = strtok(NULL, "\r\t\n");   
+			if ( !test_string )
+				break;
+			potion_note = atoi(test_string);
+			unsigned char c=*test_string;
+			if ( !potion_note )
+				{
+				if ( tolower(c) == 'e' )
+					potion_note = atoi(test_string + 1);
+				else
+					potion_note = 0;
+				}
+			this->potion_note[uRow][uColumn]=potion_note;
+			}
+		if ( uColumn != 50 )
+			break;
+		strtok(NULL, "\r\t\n");
+		}
+	if ( uRow != 50 )
+		{
+		wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, uColumn);
+		MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE);
+		}
+	}
 
 
 //----- (00456442) --------------------------------------------------------
@@ -1695,7 +1393,7 @@
   v1 = this;
   uBaseValue = pItemsTable->pItems[this->uItemID].uValue;
   if ( this->uAttributes & ITEM_TEMP_BONUS || pItemsTable->_456D5E_is_some_material(this) )
-    goto LABEL_12;
+    return uBaseValue;
   if ( v1->_bonus_type )
   {
     v3 = 100 * v1->_bonus_strength;
@@ -1704,12 +1402,11 @@
   v4 = v1->uAdditionalValue;
   if ( !v4 )
   {
-LABEL_12:
     result = uBaseValue;
   }
   else
   {
-    v3 = *(unsigned int *)&pItemsTable->pEnchantments[23].field_8[28 * v4 + 8];
+	v3 = pItemsTable->pSpecialEnchantments[v4].iTreasureLevel;
     if ( (unsigned int)v3 > 0xA )
       return uBaseValue + v3;
     result = uBaseValue * v3;
@@ -1751,7 +1448,6 @@
     v11 = pItemsTable->pItems[v2].pName;
     v4 = item__getname_buffer;
     v10 = "%s";
-LABEL_10:
     sprintf(v4, v10, v11);
     return v4;
   }
@@ -1771,7 +1467,8 @@
           v10 = pGlobalTXT_LocalizationStrings[655];
         else
           v10 = pGlobalTXT_LocalizationStrings[654];
-        goto LABEL_10;
+		sprintf(v4, v10, v11);
+		return v4;
       }
     }
   }
@@ -1805,12 +1502,12 @@
         sprintf(
           item__getname_buffer,
           "%s %s",
-          *(unsigned int *)&pItemsTable->pEnchantments[22].field_8[28 * v7 + 8],
+		  pItemsTable->pSpecialEnchantments[v7].pBonusStatement,
           pItemsTable->pItems[v1->uItemID].pName);
         return v4;
       }
       strcat(item__getname_buffer, " ");
-      v9 = *(const char **)&pItemsTable->pEnchantments[22].field_8[28 * v1->uAdditionalValue + 8];
+	  v9 = pItemsTable->pSpecialEnchantments[v1->uAdditionalValue].pBonusStatement;
     }
     strcat(item__getname_buffer, v9);
   }
@@ -1819,14 +1516,14 @@
 
 
 //----- (00456620) --------------------------------------------------------
-void ItemsTable::GenerateItem(int a2, int a3, ItemGen *pItem)
+void ItemsTable::GenerateItem(int treasure_level, int a3, ItemGen *out_item)
 {
-  ItemGen *v4; // esi@1
-  ItemsTable *v5; // edi@1
+  //ItemGen *v4; // esi@1
+  //ItemsTable *v5; // edi@1
   int v6; // ebx@3
   int *v7; // ecx@33
-  int v8; // eax@34
-  int v9; // eax@39
+  //int v8; // eax@34
+  //int v9; // eax@39
   int v10; // ebx@43
   int v11; // ecx@47
   unsigned int *v12; // edx@48
@@ -1868,163 +1565,103 @@
   unsigned int v48; // ecx@123
   int v49; // eax@123
   int v50; // eax@123
-  unsigned char Dst[0xC80]; // [sp+Ch] [bp-C88h]@33
+  int Dst[800]; // [sp+Ch] [bp-C88h]@33
   int v52; // [sp+C8Ch] [bp-8h]@33
-  int v53; // [sp+C90h] [bp-4h]@1
-  int v54; // [sp+C9Ch] [bp+8h]@3
-  int v55; // [sp+CA0h] [bp+Ch]@34
+  //int v53; // [sp+C90h] [bp-4h]@1
+  //int v54; // [sp+C9Ch] [bp+8h]@3
+  //int v55; // [sp+CA0h] [bp+Ch]@34
   signed int v56; // [sp+CA0h] [bp+Ch]@55
   int v57; // [sp+CA0h] [bp+Ch]@62
   int *v58; // [sp+CA0h] [bp+Ch]@102
   int v59; // [sp+CA0h] [bp+Ch]@123
-  signed int a2a; // [sp+CA4h] [bp+10h]@33
+  //signed int a2a; // [sp+CA4h] [bp+10h]@33
   int a2b; // [sp+CA4h] [bp+10h]@101
   int a2c; // [sp+CA4h] [bp+10h]@120
 
-  v53 = -1;
-  v4 = pItem;
-  v5 = this;
-  if ( !pItem )
-    v4 = (ItemGen *)pAllocator->AllocNamedChunk(pItem, 0x24u, "newItemGen");
-  memset(v4, 0, 0x24u);
-  v6 = a2 - 1;
-  v54 = a2 - 1;
+  //v53 = -1;
+  //v4 = pItem;
+  //v5 = this;
+  if (!out_item)
+    out_item = (ItemGen *)pAllocator->AllocNamedChunk(out_item, sizeof(*out_item), "newItemGen");
+  memset(out_item, 0, sizeof(*out_item));
+
+  auto v4 = out_item;
+  v6 = treasure_level - 1;
+  //v54 = treasure_level - 1;
   if ( a3 )
   {
-    switch ( a3 )
+    ITEM_EQUIP_TYPE   requested_equip;
+    PLAYER_SKILL_TYPE requested_skill = PLAYER_SKILL_INVALID;
+    switch (a3)
+     {
+      case 20: requested_equip = EQUIP_ONE_OR_TWO_HANDS; break;
+      case 21: requested_equip = EQUIP_ARMOUR; break;
+      case 22: requested_skill = (PLAYER_SKILL_TYPE)38; __debugbreak();/*check this skill*/ break;
+      case 23: requested_skill = PLAYER_SKILL_SWORD; break;
+      case 24: requested_skill = PLAYER_SKILL_DAGGER; break;
+      case 25: requested_skill = PLAYER_SKILL_AXE; break;
+      case 26: requested_skill = PLAYER_SKILL_SPEAR; break;
+      case 27: requested_skill = PLAYER_SKILL_BOW; break;
+      case 28: requested_skill = PLAYER_SKILL_MACE; break;
+      case 29: requested_skill = (PLAYER_SKILL_TYPE)37; __debugbreak();/*check this skill*/break;
+      case 30: requested_skill = PLAYER_SKILL_STAFF; break;
+      case 31: requested_skill = PLAYER_SKILL_LEATHER; break;
+      case 32: requested_skill = PLAYER_SKILL_CHAIN; break;
+      case 33: requested_skill = PLAYER_SKILL_PLATE; break;
+      case 34: requested_equip = EQUIP_SHIELD; break;
+      case 35: requested_equip = EQUIP_HELMET; break;
+      case 36: requested_equip = EQUIP_BELT; break;
+      case 37: requested_equip = EQUIP_CLOAK; break;
+      case 38: requested_equip = EQUIP_GAUNTLETS; break;
+      case 39: requested_equip = EQUIP_BOOTS; break;
+      case 40: requested_equip = EQUIP_RING; break;
+      case 41: requested_equip = EQUIP_AMULET; break;
+      case 42: requested_equip = EQUIP_C; break;
+      case 43: requested_equip = EQUIP_F; break;
+      case 44: requested_equip = EQUIP_POTION; break;
+      case 45: requested_equip = EQUIP_REAGENT; break;
+      case 46: requested_equip = EQUIP_GEM; break;
+      default:
+        __debugbreak(); // check this condition
+        requested_equip = (ITEM_EQUIP_TYPE)(a3 - 1);
+      break;
+    }
+    memset(Dst, 0, sizeof(Dst));
+    v52 = 0;
+    v7 = Dst;
+    //a2a = 1;
+    if (requested_skill == PLAYER_SKILL_INVALID)
     {
-      case 20:
-        a3 = EQUIP_ONE_OR_TWO_HANDS;
-        break;
-      case 21:
-        a3 = 3;
-        break;
-      case 22:
-        v53 = 38;
-        break;
-      case 23:
-        v53 = 1;
-        break;
-      case 24:
-        v53 = 2;
-        break;
-      case 25:
-        v53 = 3;
-        break;
-      case 26:
-        v53 = 4;
-        break;
-      case 27:
-        v53 = 5;
-        break;
-      case 28:
-        v53 = 6;
-        break;
-      case 30:
-        v53 = 0;
-        break;
-      case 31:
-        v53 = 9;
-        break;
-      case 32:
-        v53 = 10;
-        break;
-      case 33:
-        v53 = 0xBu;
-        break;
-      case 34:
-        a3 = 4;
-        break;
-      case 35:
-        a3 = 5;
-        break;
-      case 36:
-        a3 = 6;
-        break;
-      case 37:
-        a3 = 7;
-        break;
-      case 38:
-        a3 = 8;
-        break;
-      case 39:
-        a3 = EQUIP_BOOTS;
-        break;
-      case 40:
-        a3 = EQUIP_RING;
-        break;
-      case 41:
-        a3 = 0xBu;
-        break;
-      case 42:
-        a3 = EQUIP_C;
-        break;
-      case 43:
-        a3 = EQUIP_F;
-        break;
-      case 44:
-        a3 = EQUIP_POTION;
-        break;
-      case 45:
-        a3 = EQUIP_REAGENT;
-        break;
-      case 46:
-        a3 = EQUIP_GEM;
-        break;
-      case 29:
-        v53 = 37;
-        break;
-      default:
-        --a3;
-        break;
-    }
-    memset(&Dst, 0, 0xC80u);
-    v52 = 0;
-    v7 = (int *)&Dst;
-    a2a = 1;
-    if ( v53 == -1 )
-    {
-      v53 = (int)&v5->pItems[1].uEquipType;
-      v9 = (int)(&v5->pItems[1].field_2C + v6);
-      do
+      for (uint i = 1; i < 500; ++i)
       {
-        if ( *(unsigned char *)v53 == a3 )
+        if (pItems[i].uEquipType == requested_equip)
         {
-          *v7 = a2a;
-          ++v7;
-          v52 += *(unsigned char *)v9;
+          *v7++ = i;
+          v52 += pItems[i].uChanceByTreasureLvl[v6];
         }
-        ++a2a;
-        v53 += 48;
-        v9 += 48;
       }
-      while ( a2a < 500 );
     }
     else
     {
-      v55 = (int)&v5->pItems[1].uSkillType;
-      v8 = (int)(&v5->pItems[1].field_2C + v6);
-      do
+      for (uint i = 1; i < 500; ++i)
       {
-        if ( *(unsigned char *)v55 == v53 )
+        if (pItems[i].uSkillType == requested_skill)
         {
-          *v7 = a2a;
-          ++v7;
-          v52 += *(unsigned char *)v8;
+          *v7++ = i;
+          v52 += pItems[i].uChanceByTreasureLvl[v6];
         }
-        ++a2a;
-        v55 += 48;
-        v8 += 48;
       }
-      while ( a2a < 500 );
     }
+
     v10 = 0;
     if ( v52 )
       v10 = rand() % v52;
-    v4->uItemID = *(uint *)Dst;
-    if ( !Dst )
+
+    v4->uItemID = *Dst;
+    if (!v4->uItemID)
       v4->uItemID = 1;
-    v11 = *(&v5->pItems[v4->uItemID].field_2C + v54);
+
+    v11 = pItems[v4->uItemID].uChanceByTreasureLvl[v6];
     if ( v11 < v10 )
     {
       v12 = (uint *)Dst;
@@ -2033,11 +1670,11 @@
         ++v12;
         v13 = *v12;
         v4->uItemID = *v12;
-        v11 += *(&v5->pItems[v13].field_2C + v54);
+        v11 += pItems[v13].uChanceByTreasureLvl[v6];
       }
       while ( v11 < v10 );
     }
-    if ( v5->pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE )
+    if (pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE )
     {
       v4->_bonus_type = 0;
       v14 = 2;
@@ -2048,9 +1685,7 @@
         --v14;
       }
       while ( v14 );
-LABEL_72:
-      v4->_bonus_type = v15 * (v54 + 1);
-      goto LABEL_73;
+      v4->_bonus_type = v15 * treasure_level;
     }
   }
   else
@@ -2061,28 +1696,28 @@
       v56 += pParty->field_7BA[v16++];
     while ( v16 < 29 );
     v17 = rand() % 29;
-    if ( v54 == 5 && rand() % 100 < 5 && !pParty->field_7BA[v17] && v56 < 13 )
+    if ( v6 == 5 && rand() % 100 < 5 && !pParty->field_7BA[v17] && v56 < 13 )
     {
       pParty->field_7BA[v17] = 1;
       v4->uAttributes = 0;
       v4->uItemID = v17 + 500;
-      v5->SetSpecialBonus(v4);
+      SetSpecialBonus(v4);
       return;
     }
     v57 = 0;
-    v18 = rand() % v5->field_11684[v54];
+    v18 = rand() % 10;// v5->field_11684[v54];
     v4->uItemID = 0;
     if ( v18 > 0 )
     {
       do
-        v57 += *(&v5->pItems[v4->uItemID++ + 1].field_2C + v54);
+        v57 += pItems[v4->uItemID++ + 1].uChanceByTreasureLvl[v6];
       while ( v57 < v18 );
     }
     if ( !v18 )
       v4->uItemID = 1;
     if ( !v4->uItemID )
       v4->uItemID = 1;
-    if ( v5->pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE )
+    if (pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE)
     {
       v4->_bonus_type = 0;
       v19 = 2;
@@ -2093,26 +1728,25 @@
         --v19;
       }
       while ( v19 );
-      goto LABEL_72;
+      v4->_bonus_type = v15 * treasure_level;
     }
   }
-LABEL_73:
   if ( v4->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION
     && !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, 239) )
     v4->uItemID = ITEM_SPELLBOOK_LIGHT_SUN_BURST;
-  if ( BYTE2(pItemsTable->pItems[v4->uItemID + 1].uItemID) )
+  if ( pItemsTable->pItems[v4->uItemID + 1].uItemID_Rep_St )
     v4->uAttributes = 0;
   else
     v4->uAttributes = 1;
-  if ( v5->pItems[v4->uItemID].uEquipType != EQUIP_POTION )
+  if ( pItems[v4->uItemID].uEquipType != EQUIP_POTION )
   {
     v4->uAdditionalValue = 0;
     v4->_bonus_type = 0;
   }
-  v20 = v5->pItems[v4->uItemID].uEquipType;
+  v20 = pItems[v4->uItemID].uEquipType;
   if ( v20 <= EQUIP_BOW )
   {
-    v37 = (int)&v5->field_1169C[4 * v54 + 48];
+    v37 = 10;//(int)&v5->field_1169C[4 * v54 + 48];
     if ( !*(unsigned int *)v37 )
       return;
     v38 = rand() % 100;
@@ -2131,34 +1765,31 @@
       }
       return;
     }
-    v22 = (int)&v5->field_1169C[4 * v54];
+    v22 = (int)&uBonusChanceStandart[v6];
     if ( !*(unsigned int *)v22 )
       return;
     v23 = rand();
     v24 = *(unsigned int *)v22;
     v25 = v23 % 100;
-    if ( v23 % 100 < v24 )
-      goto LABEL_127;
-    if ( !*(unsigned int *)&v5->field_1169C[4 * v54 + 24] )
-      return;
-    if ( v25 < v24 )
+    if ( !uBonusChanceSpecial[v6] && !(v23 % 100 < v24))
+        return;
+    if ( v25 < v24 || v23 % 100 < v24)
     {
-LABEL_127:
-      v26 = rand() % v5->field_116D8[v5->pItems[v4->uItemID].uEquipType];
+      v26 = rand() % 10;//v5->field_116D8[v5->pItems[v4->uItemID].uEquipType];
       v27 = v4->uItemID;
       v4->_bonus_type = 0;
-      for ( i = v5->pEnchantments[0].field_8[v5->pItems[v27].uEquipType + 1];
+      for ( i = pEnchantments[0].to_item[pItems[v27].uEquipType + 1];
             i < v26;
-            i += v5->pEnchantments[v4->_bonus_type].field_8[v5->pItems[v29].uEquipType + 1] )
+            i += pEnchantments[v4->_bonus_type].to_item[pItems[v29].uEquipType + 1] )
       {
         v29 = v4->uItemID;
         ++v4->_bonus_type;
       }
       ++v4->_bonus_type;
-      v30 = v5->field_116D8[2 * v54 + 12];
+      v30 = 10;// v5->field_116D8[2 * v54 + 12];
       v31 = rand();
       v32 = v4->_bonus_type - 1;
-      v33 = v31 % (v5->field_116D8[2 * v54 + 13] - v30 + 1) + v30;
+      v33 = v31 % 10;//(v5->field_116D8[2 * v54 + 13] - v30 + 1) + v30;
       v4->_bonus_strength = v33;
       if ( v32 == 21 || v32 == 22 || v32 == 23 )
         v4->_bonus_strength = v33 >> 1;
@@ -2166,7 +1797,7 @@
         v4->_bonus_strength = 1;
       return;
     }
-    v34 = v24 + *(unsigned int *)&v5->field_1169C[4 * v54 + 24];
+    v34 = v24 + 10;//*(unsigned int *)&v5->field_1169C[4 * v54 + 24];
     v36 = __OFSUB__(v25, v34);
     v35 = v25 - v34 < 0;
   }
@@ -2175,60 +1806,95 @@
   memset(&Dst, 0, 0xC80u);
   v39 = 0;
   a2b = 0;
-  if ( v5->field_11798 > 0 )
+  if ( pSpecialEnchantments_count > 0 )
   {
-    v52 = -16 - (uint)v5;
+    v52 = -16 - (uint)this;
     v58 = (int *)&Dst;
-    v40 = (int)&v5->pSpecialEnchantments[1];
+    v40 = (int)&pSpecialEnchantments[1];
     do
     {
-      switch ( v54 )
+      switch ( v6 )
       {
         case 2:
           if ( !*(unsigned char *)v40 )
-            goto LABEL_117;
+          {
+            v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType);
+            if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) )
+            {
+              v44 = v58;
+              ++v58;
+              *v44 = a2b;
+            }
+            ++a2b;
+			v40 += 28;
+			continue;
+          }
           v41 = *(unsigned char *)v40 == 1;
           break;
         case 3:
           v43 = *(unsigned char *)v40;
           if ( !*(unsigned char *)v40 || v43 == 1 )
           {
-LABEL_117:
-            v39 += *((unsigned char *)&v5->pItems[0].uItemID + v40 + v52 + v5->pItems[v4->uItemID].uEquipType);
-            if ( *((unsigned char *)&v5->pItems[0].uItemID + v40 + v52 + v5->pItems[v4->uItemID].uEquipType) )
+            v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType);
+            if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) )
             {
               v44 = v58;
               ++v58;
               *v44 = a2b;
             }
-            goto LABEL_119;
+            ++a2b;
+			v40 += 28;
+			continue;
           }
           v41 = v43 == 2;
           break;
         case 4:
           v42 = *(unsigned char *)v40;
           if ( *(unsigned char *)v40 == 1 || v42 == 2 )
-            goto LABEL_117;
+          {
+            v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType);
+            if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) )
+            {
+              v44 = v58;
+              ++v58;
+              *v44 = a2b;
+            }
+            ++a2b;
+			v40 += 28;
+			continue;
+          }
           v41 = v42 == 3;
           break;
         default:
-          if ( v54 != 5 )
-            goto LABEL_119;
+          if ( v6 != 5 )
+		  {
+            ++a2b;
+			v40 += 28;
+			continue;
+		  }
           v41 = *(unsigned char *)v40 == 3;
           break;
       }
       if ( v41 )
-        goto LABEL_117;
+      {
+		v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType);
+		if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) )
+		{
+			v44 = v58;
+			++v58;
+			*v44 = a2b;
+		}
+	  }
 LABEL_119:
       ++a2b;
       v40 += 28;
     }
-    while ( a2b < v5->field_11798 );
+    while ( a2b < pSpecialEnchantments_count );
   }
   v45 = rand();
   v4->uAdditionalValue = *(uint *)Dst;
   v46 = v45 % v39 + 1;
-  a2c = *((unsigned char *)&v5->pItems[0].uItemID + 28 * (*(uint *)Dst + 1389) + v5->pItems[v4->uItemID].uEquipType);
+  a2c = *((unsigned char *)&uAllItemsCount + 28 * (*(uint *)Dst + 1389) + pItems[v4->uItemID].uEquipType);
   if ( a2c < v46 )
   {
     for ( j = (int *)&Dst; ; j = (int *)v59 )
@@ -2238,7 +1904,7 @@
       v59 = v49;
       v50 = *(unsigned int *)v49;
       v4->uAdditionalValue = v50;
-      a2c += *((unsigned char *)&v5->pItems[0].uItemID + 28 * (v50 + 1389) + v5->pItems[v48].uEquipType);
+      a2c += *((unsigned char *)&uAllItemsCount + 28 * (v50 + 1389) + pItems[v48].uEquipType);
       if ( a2c >= v46 )
         break;
     }
--- a/Items.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/Items.h	Mon Feb 18 09:44:59 2013 +0600
@@ -123,34 +123,44 @@
 /*  175 */
 #pragma pack(push, 1)
 struct ItemDesc
-{
-  unsigned int uItemID;
-  char *pIconName;
-  char *pName;
-  char *pUnidentifiedName;
-  char *pDescription;
-  unsigned int uValue;
-  unsigned __int16 uSpriteID;
-  __int16 field_1A;
-  unsigned __int16 uEquipX;
-  unsigned __int16 uEquipY;
-  unsigned __int8 uEquipType;
-  unsigned __int8 uSkillType;
-  unsigned __int8 uDamageDice;
-  unsigned __int8 uDamageRoll;
-  unsigned __int8 uDamageMod;
-  unsigned __int8 uMaterial;
-  char _additional_value;
-  char _bonus_type;
-  char _bonus_strength;
-  char field_29;
-  char field_2A;
-  char field_2B;
-  char field_2C;
-  char field_2D;
-  char field_2E;
-  char field_2F;
-};
+	{ //Item # |Pic File|Name|Value|Equip Stat|Skill Group|Mod1|Mod2|material|	
+	///ID/Rep/St|Not identified name|Sprite Index|VarA|VarB|Equip X|Equip Y|Notes
+	char *pIconName;  //0 4
+	char *pName;   //4 8
+	char *pUnidentifiedName; //8 c
+	char *pDescription;  //0c 10
+	unsigned int uValue;  //10 14
+	unsigned __int16 uSpriteID; //14 18
+	__int16 field_1A; //16 
+	unsigned __int16 uEquipX; //18  1c
+	unsigned __int16 uEquipY; //1a  1e
+	unsigned __int8 uEquipType; //1c 20
+	unsigned __int8 uSkillType; //1d 21
+	unsigned __int8 uDamageDice; //1e 22
+	unsigned __int8 uDamageRoll; //1f 23
+	unsigned __int8 uDamageMod; //20 24
+	unsigned __int8 uMaterial; //21 25
+	char _additional_value; //22 26
+	char _bonus_type; //23  27
+	char _bonus_strength; //24 28
+	char field_25;  // 25  29
+	char field_26;  //26   2A
+	char field_27; // 27   2b
+	union
+		{
+		unsigned __int8 uChanceByTreasureLvl[6];
+		struct {
+			unsigned __int8 uChanceByTreasureLvl1; // 28  2c
+			unsigned __int8 uChanceByTreasureLvl2;  // 29  2d 
+			unsigned __int8 uChanceByTreasureLvl3;  // 2A   2e
+			unsigned __int8 uChanceByTreasureLvl4;  // 2B  2f
+			unsigned __int8 uChanceByTreasureLvl5;  // 2C  30
+			unsigned __int8 uChanceByTreasureLvl6;  // 2D  32
+			};
+		};
+	unsigned char uItemID_Rep_St; //2e 32
+	char field_2f;
+	};
 #pragma pack(pop)
 
 
@@ -158,25 +168,46 @@
 /*  177 */
 #pragma pack(push, 1)
 struct ItemEnchantment
-{
-  char *pName;
-  char *pParam;
-  char field_8[12];
-};
+	{ //Bonus|Sta|Of Name|Arm|Shld|Helm|Belt|Cape|Gaunt|Boot|Ring|Amul
+	char *pBonusStat;
+	char *pOfName;
+/*	union{
+		struct {
+			unsigned char to_arm;
+			unsigned char to_shld;
+			unsigned char to_helm;
+			unsigned char to_belt;
+			unsigned char to_cape;
+			unsigned char to_gaunt;
+			unsigned char to_boot;
+			unsigned char to_ring;
+			unsigned char to_amul;
+			}; */
+			unsigned char to_item[12];
+	//	};
+	};
 #pragma pack(pop)
 
 /*  178 */
 #pragma pack(push, 1)
 struct ItemSpecialEnchantment
-{
-  char *pName;
-  char *pParam;
-  char field_8[12];
-  int field_14;
-  int field_18;
+{ //Bonus Stat|Name Add|W1|W2|Miss|Arm|Shld|Helm|Belt|Cape|Gaunt|Boot|Ring|Amul|Value|Lvl|Description fo special Bonuses and values			
+
+  char *pBonusStatement;
+  char *pNameAdd;
+  char to_item_apply[12];
+  int iValue;
+  int iTreasureLevel;
 };
 #pragma pack(pop)
 
+#pragma pack(push, 1)
+struct BonusRange
+{
+  unsigned int minR;
+  unsigned int maxR;
+};
+#pragma pack(pop)
 
 /*  176 */
 #pragma pack(push, 1)
@@ -185,32 +216,35 @@
   void Initialize();
   void LoadPotions();
   void LoadPotionNotes();
-  void GenerateItem(int a2, int a3, ItemGen *pItem);
+  void GenerateItem(int treasure_level, int a3, ItemGen *pItem);
   void SetSpecialBonus(ItemGen *pItem);
   bool _456D43_is_material_equals_3(ItemGen *pItem);
   bool _456D5E_is_some_material(ItemGen *pItem);
   char *Release();
 
-
-  ItemDesc pItems[800];
-  ItemEnchantment pEnchantments[24];
-  ItemSpecialEnchantment pSpecialEnchantments[72];
-  char field_9FC0[5000];
+  int uAllItemsCount;
+  ItemDesc pItems[800]; //4-9604h
+  ItemEnchantment pEnchantments[24]; //9604h
+  ItemSpecialEnchantment pSpecialEnchantments[72]; //97E4h -9FC4h
+  char field_9FC4[5000];
   char field_B348[5000];
   char field_C6D0[5000];
   char field_DA58[5000];
-  char field_EDE0[5000];
-  char field_10168[5000];
-  char field_114F0[388];
-  char *pItemsTXT_Raw;
+  char field_EDE0[384];
+  unsigned __int16 potion_data[50][50]; // 77B2h*2=EF64h  -102ECh
+  unsigned __int16 potion_note[50][50]; // 8176h*2=102ECh -11674h
+  char *pItemsTXT_Raw; //11674h
   char *pRndItemsTXT_Raw;
-  char *pStdItemsTXT_Raw;
-  char *pSpcItemsTXT_Raw;
-  int field_11684[6];
-  char field_1169C[60];
-  int field_116D8[24];
-  int field_11738[24];
-  int field_11798;
+  char *pStdItemsTXT_Raw; //1167Ch
+  char *pSpcItemsTXT_Raw; //11680h
+  unsigned int uChanceByTreasureLvlSumm[6]; //11684
+  unsigned int uBonusChanceStandart[6]; //1169c
+  unsigned int uBonusChanceSpecial[6]; //116B4
+  unsigned int uBonusChanceWpSpecial[6]; //116cc -116e4
+  unsigned int pEnchantmentsSumm[9]; //116E4h -11708h
+  BonusRange bonus_ranges[6]; //45C2h*4 =11708h
+  unsigned int pSpecialEnchantmentsSumm[24]; //11738h
+  unsigned int pSpecialEnchantments_count; //11798h
   char field_1179C;
 };
 #pragma pack(pop)
--- a/LayingItem.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/LayingItem.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -13,7 +13,7 @@
 
 
 //----- (00438E35) --------------------------------------------------------
-__int16 LayingItem::_438E35()
+void LayingItem::_438E35()
 {
   LayingItem *v1; // edi@1
   MapInfo *pMapInfo; // esi@1
@@ -64,14 +64,14 @@
   {
     v17 = 0;
     v11 = 5;
-    if ( pMapInfo->field_2E )
+    if ( pMapInfo->Trap_D20 )
     {
       do
       {
         ++v17;
         v11 += rand() % 20 + 1;
       }
-      while ( v17 < pMapInfo->field_2E );
+      while ( v17 < pMapInfo->Trap_D20 );
     }
     switch ( v1->uItemType )
     {
@@ -85,9 +85,9 @@
         v18 = 2;
         break;
       default:
-        LOWORD(v10) = v1->uItemType - 814;
+        //LOWORD(v10) = v1->uItemType - 814;
         if ( v1->uItemType != 814 )
-          return v10;
+          return;
         v18 = 8;
         break;
     }
@@ -95,14 +95,13 @@
     do
     {
       if ( (*v12)->CanAct() && (v13 = (*v12)->GetPerception() + 20, rand() % v13 > 20) )
-        LOWORD(v10) = (*v12)->PlaySound(6, 0);
+        (*v12)->PlaySound(SPEECH_6, 0);
       else
-        LOWORD(v10) = (*v12)->ReceiveDamage(v11, v18);
+        (*v12)->ReceiveDamage(v11, v18);
       ++v12;
     }
     while ( (signed int)v12 <= (signed int)&pPlayers[4] );
   }
-  return v10;
 }
 
 
@@ -114,7 +113,7 @@
   unsigned __int16 *pAttributes; // ecx@2
   unsigned __int16 v3; // ax@2
 
-  __debugbreak(); // find out what's going on
+  //__debugbreak(); // find out what's going on
 
   v1 = uLayingItemID;
   pLayingItems[v1].uObjectDescID = 0;
@@ -124,7 +123,7 @@
     v3 = *pAttributes;
     if ( *pAttributes & 4 )
     {
-      LOBYTE(v3) = v3 & 0xFB;
+      v3 = v3 & 0xFB;
       --pTurnEngine->field_1C;
       *pAttributes = v3;
     }
--- a/LayingItem.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/LayingItem.h	Mon Feb 18 09:44:59 2013 +0600
@@ -10,7 +10,7 @@
   LayingItem();
   int Create(int yaw, int pitch, int a4, int a5);
   void _46BEF1_apply_spells();
-  __int16 _438E35();
+  void _438E35();
 
   static void UpdateObject_fn0_BLV(unsigned int uLayingItemID);
   static void UpdateObject_fn0_ODM(unsigned int uLayingItemID);
--- a/LightmapBuilder.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/LightmapBuilder.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -1630,11 +1630,11 @@
       pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0);
     if ( !byte_4D864C || !(pGame->uFlags & 1) )
     {
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u));
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
       ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, v7));
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
       v13 = a3;
       v33 = 1.0;
       v32 = 1.0;
@@ -1681,24 +1681,24 @@
         }
       }
       v15 = pRenderer->pRenderD3D->pDevice;
-      ErrD3D(v15->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
-      ErrD3D(v15->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
-      ErrD3D(v15->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
-      ErrD3D(v15->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u));
+      ErrD3D(v15->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+      ErrD3D(v15->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
+      ErrD3D(v15->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
+      ErrD3D(v15->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
     }
     if ( pRenderer->bUsingSpecular )
     {
       //LODWORD(v30) = 1;
       //v29 = 28;
       //v28 = (Lightmap *)pRenderer->pRenderD3D->pDevice;
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1));
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
       //v30 = pRenderer->uFogColor;
       //v23 = pRenderer->pRenderD3D->pDevice;
       //v29 = 34;
       //v28 = (Lightmap *)v23;
       ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, pRenderer->uFogColor));
       //v28 = (Lightmap *)pRenderer->pRenderD3D->pDevice;
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, false));
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
     }
   }
   return 1;
@@ -1797,28 +1797,28 @@
     return;
 
   if (pRenderer->bUsingSpecular)
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
  
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
 
   auto pTex = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03");
   ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTex));
 
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
 
   DrawLightmaps2(0.00050000002);
 
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
 
   if (pRenderer->bUsingSpecular)
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
 }
\ No newline at end of file
--- a/MM7.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/MM7.h	Mon Feb 18 09:44:59 2013 +0600
@@ -225,15 +225,6 @@
 
 
 
-/*  301 */
-enum PlayerSpeech
-{
-  SPEECH_Yell = 0x41,
-};
-
-
-
-
 
 
 
--- a/MM7.vcxproj.filters	Mon Feb 18 09:44:44 2013 +0600
+++ b/MM7.vcxproj.filters	Mon Feb 18 09:44:59 2013 +0600
@@ -199,6 +199,9 @@
     </ClInclude>
     <ClInclude Include="Log.h" />
     <ClInclude Include="FrameTableInc.h" />
+    <ClInclude Include="resource.h" />
+    <ClInclude Include="stru346.h" />
+    <ClInclude Include="texts.h" />
   </ItemGroup>
   <ItemGroup>
     <Filter Include="lib">
@@ -314,5 +317,9 @@
     <ClCompile Include="FrameTableInc.cpp" />
     <ClCompile Include="mm7_6.cpp" />
     <ClCompile Include="GameUIs.cpp" />
+    <ClCompile Include="texts.cpp" />
+  </ItemGroup>
+  <ItemGroup>
+    <ResourceCompile Include="Might and Magic Trilogy.rc" />
   </ItemGroup>
 </Project>
\ No newline at end of file
--- a/MapInfo.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/MapInfo.h	Mon Feb 18 09:44:59 2013 +0600
@@ -20,20 +20,20 @@
   int _steal_perm;
   int _per;
   char field_2C;
-  char field_2D;
-  char field_2E;
-  char field_2F;
-  char field_30;
-  char field_31;
-  char field_32;
-  char field_33;
-  char field_34;
+  char LockX5;
+  char Trap_D20;
+  char Treasure_prob;
+  char Encounter_percent;
+  char EncM1percent;
+  char EncM2percent;
+  char EncM3percent;
+  char Dif_M1;
   unsigned __int8 uEncounterMonster1AtLeast;
   unsigned __int8 uEncounterMonster1AtMost;
-  char field_37;
+  char Dif_M2;
   unsigned __int8 uEncounterMonster2AtLeast;
   unsigned __int8 uEncounterMonster2AtMost;
-  char field_3A;
+  char Dif_M3;
   unsigned __int8 uEncounterMonster3AtLeast;
   unsigned __int8 uEncounterMonster3AtMost;
   char field_3D;
--- a/Monsters.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/Monsters.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -6,7 +6,7 @@
 #include "FrameTableInc.h"
 #include "Allocator.h"
 #include "LOD.h"
-
+#include "texts.h"
 #include "mm7_data.h"
 
 
@@ -215,67 +215,49 @@
 //----- (00454F4E) --------------------------------------------------------
 void MonsterStats::InitializePlacements()
 {
-  char *v1; // ebx@1
-  MonsterStats *v2; // edi@1
-  char *v3; // eax@2
-  char v4; // dl@3
-  char *v5; // ecx@3
-  int v6; // esi@7
-  signed int v7; // [sp+Ch] [bp-10h]@1
-  char **v8; // [sp+10h] [bp-Ch]@1
-  signed int v9; // [sp+14h] [bp-8h]@2
-  char *v10; // [sp+18h] [bp-4h]@2
+  int i;
+  char* test_string;
+  unsigned char c;
+  bool break_loop;
+  unsigned int temp_str_len;
+  char* tmp_pos;
+  int decode_step;
+  int item_counter;
 
-  v1 = 0;
-  v2 = this;
   pMonsterPlacementTXT_Raw = (char *)pEvents_LOD->LoadRaw("placemon.txt", 0);
   strtok(pMonsterPlacementTXT_Raw, "\r");
-  v2->uNumPlacements = 31;
-  v8 = v2->pPlacement.pSubstrings;
-  v7 = 30;
-  do
-  {
-    v3 = strtok(v1, "\r") + 1;
-    v10 = v1;
-    v9 = (signed int)v1;
-    do
-    {
-      v4 = *v3;
-      v5 = 0;
-      if ( *v3 != 9 )
-      {
-        v1 = 0;
-        do
-        {
-          if ( !v4 )
-            break;
-          ++v5;
-          v4 = v3[(unsigned int)v5];
-        }
-        while ( v4 != 9 );
-      }
-      v6 = (int)&v3[(unsigned int)v5];
-      if ( v3[(unsigned int)v5] == (unsigned char)v1 )
-        v9 = 1;
-      *(unsigned char *)v6 = (unsigned char)v1;
-      if ( v5 == v1 )
-      {
-        v9 = 1;
-      }
-      else
-      {
-        if ( v10 == (char *)1 )
-          *v8 = (char *)RemoveQuotes(v3);
-      }
-      ++v10;
-      v3 = (char *)(v6 + 1);
-    }
-    while ( (signed int)(v10 - 1) <= 31 && (char *)v9 == v1 );
-    ++v8;
-    --v7;
-  }
-  while ( v7 );
-  v2->uNumPlacements = 31;
+  for (i=1; i<31; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			   if (decode_step==1)
+				  pPlaceStrings[i]=RemoveQuotes(test_string);
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<3)&&!break_loop);
+	  }
+  uNumPlacements = 31;
 }
 
 //----- (0045501E) --------------------------------------------------------
@@ -1060,6 +1042,7 @@
           case 0x1A:
             v102->pInfos[v103].uSpell2UseChance = atoi((const char *)v2);
             goto LABEL_325;
+
           case 0x1B:
             strcpy(Dest, (const char *)v2);
             Dest[0] = ' ';
--- a/Monsters.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/Monsters.h	Mon Feb 18 09:44:59 2013 +0600
@@ -141,15 +141,8 @@
 };
 #pragma pack(pop)
 
-/*  188 */
-#pragma pack(push, 1)
-struct MonsterPlacement
-{
-  unsigned int uNumStrings;
-  char *pSubstrings[30];
-};
-#pragma pack(pop)
 
+ 
 /*  189 */
 #pragma pack(push, 1)
 struct MonsterStats
@@ -160,10 +153,10 @@
 
   static bool BelongsToSupertype(unsigned int uMonsterInfoID, enum MONSTER_SUPERTYPE eSupertype);
 
-  MonsterInfo pInfos[265];
-  MonsterPlacement pPlacement;
-  unsigned int uNumMonsters;
-  unsigned int uNumPlacements;
+  MonsterInfo pInfos[265];  //0 - 5b18h
+  char *pPlaceStrings[31];; //5B18h placement counts from 1
+  unsigned int uNumMonsters;  //5B94h
+  unsigned int uNumPlacements; //5B98h
   int field_5B9C;
 };
 #pragma pack(pop)
--- a/Mouse.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/Mouse.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -879,7 +879,7 @@
 void AsyncMouse::Suspend()
 {
   void *v1; // esi@1
-  Vis *v2; // eax@3
+  //Vis *v2; // eax@3
   std::string v3; // [sp-18h] [bp-24h]@2
   const char *v4; // [sp-8h] [bp-14h]@2
   int v5; // [sp-4h] [bp-10h]@2
@@ -889,9 +889,10 @@
   v1 = this;
   if ( *((int *)this + 33) )
   {
-    v2 = pGame->pVisInstance;
-    if ( v2 )
-      v2->stru1.uNumPointers = 0;
+    //v2 = pGame->pVisInstance;
+    if (pGame->pVisInstance)
+      pGame->pVisInstance->default_list.uNumPointers = 0;
+
     EnterCriticalSection(&pGame->pThreadWardInstance->cs3);
     SuspendThread(*((HANDLE *)v1 + 4));
     _46B0ED();
--- a/NPC.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/NPC.h	Mon Feb 18 09:44:59 2013 +0600
@@ -19,7 +19,7 @@
 {
   char *pName;
   unsigned int uPortraitID;
-  unsigned int uFlags;
+  unsigned int uFlags;         // & 0x80    no greeting on dialogue start
   int fame;
   int rep;
   int house;
@@ -57,8 +57,8 @@
 #pragma pack(push, 1)
 struct NPCStats_stru0
 {
-  int field_0;
-  char field_4[60];
+  int field_0;  //summ 
+  char field_4[60]; //prof position
 };
 #pragma pack(pop)
 
@@ -90,7 +90,7 @@
   bool InitializeAdditionalNPCs(NPCData *a2, int a3, int a4, int a5);
   void _476C60();
 
-
+  
   NPCData pNPCData[501];
   NPCData pNewNPCData[501];
   char *pNPCNames[540][2];
@@ -103,7 +103,7 @@
   NPCData array_13EF4[100];
   char *pCatchPhrases[52];
   char *pNPCNames2[500];
-  NPCStats_stru0 array_16544[77];
+  NPCStats_stru0 array_16544[77]; //16544h proffesion position in area
   int field_17884;
   int field_17888;
   NPCGreeting pNPCGreetings[205];
--- a/Outdoor.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/Outdoor.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -46,23 +46,20 @@
 //----- (0047A59E) --------------------------------------------------------
 void OutdoorLocation::ExecDraw(unsigned int bRedraw)
 {
-  int v1; // edi@1
   //unsigned int v2; // ebx@1
   int v3; // ST18_4@3
   int v4; // ST04_4@19
   int v5; // eax@19
 
-  v1 = 0;
-  //v2 = bRedraw;
-  if ( viewparams->field_54 )
-    v1 = 2;
+  pIndoorCamera->flags = 0;
+  if (viewparams->draw_d3d_outlines)
+    pIndoorCamera->flags |= INDOOR_CAMERA_DRAW_D3D_OUTLINES;
+
   pIndoorCamera->sRotationX = pParty->sRotationX;
   pIndoorCamera->sRotationY = pParty->sRotationY;
   pIndoorCamera->pos.x = pParty->vPosition.x
                       - ((unsigned __int64)(stru_5C6E00->SinCos(pParty->sRotationY)
                                           * (signed __int64)pParty->y_rotation_granularity) >> 16);
-  //v3 = stru_5C6E00->SinCos(pParty->sRotationY - stru_5C6E00->uIntegerHalfPi);
-  pIndoorCamera->field_4C = v1;
   pIndoorCamera->pos.y = pParty->vPosition.y - pParty->y_rotation_granularity * ((stru_5C6E00->SinCos(pParty->sRotationY)) >> 16);
   pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel;
   if (bRedraw || pRenderer->pRenderD3D)
@@ -2012,8 +2009,7 @@
       header.pMagic[2] != 'i' ||
       header.pMagic[3] != 'i' )
   {
-    MessageBoxW(nullptr, L"Can't load file!",
-                L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:746", 0);
+    MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:746", 0);
     Str2 = (char *)1;
   }
   //v74 = 0;
@@ -2411,28 +2407,14 @@
   int v3; // esi@5
   unsigned int result; // eax@9
 
-
-/*    v3 = *(&this->pTerrain.pTilemap[128 * uZ] + uX);
-    if ( v3 < 198 )
-    {
-      if ( v3 >= 90 )
-        v3 = v3 + this->pTileTypes[(v3 - 90) / 36].uTileID - 36 * (v3 - 90) / 36 - 90;
-    }
-    else
-    {
-      v3 = v3 + this->pTileTypes[3].uTileID - 198;
-    }
-    result = pTileTable->pTiles[v3].uBitmapID;
-  }
-  return result;*/
-   if (uX > 127 || uY > 127)
+   if ( uX < 0 || uX > 127 || uY < 0 || uY > 127)
    return 0;
 
  v3 = this->pTerrain.pTilemap[uY * 128 + uX];
  if (v3 < 198)
  {
   if (v3 >= 90)
-    v3 = v3 + this->pTileTypes[(v3 - 90) / 36].uTileID - 36 * (v3 - 90) / 36 - 90;
+    v3 = v3 + this->pTileTypes[(v3 - 90) / 36].uTileID - 36 * ((v3 - 90) / 36) - 90;
  }
  else
    v3 = v3 + this->pTileTypes[3].uTileID - 198;
@@ -2456,29 +2438,16 @@
 int OutdoorLocation::ActuallyGetSomeOtherTileInfo(unsigned int uX, unsigned int uY)
 {
   int v3; // esi@5
-  //int result; // eax@7
 
-/*  if ( (uX & 0x80000000u) != 0 || (signed int)uX > 127 || (uY & 0x80000000u) != 0 || (signed int)uY > 127 )
-  {
-    result = 0;
-  }
-  else
-  {
-    v3 = *(&this->pTerrain.pTilemap[128 * uY] + uX);
-    if ( v3 >= 90 )
-      v3 = v3 + this->pTileTypes[(v3 - 90) / 36].uTileID - 36 * (v3 - 90) / 36 - 90;
-    result = pTileTable->pTiles[v3].uAttributes;
-  }
-  return result;*/
-  if (uX > 127 || uY > 127)
+  if (uX < 0 || uX > 127 || uY < 0 || uY > 127)
     return 0;
   else
   {
     v3 = this->pTerrain.pTilemap[uY * 128 + uX];
     if ( v3 >= 90 )
-      v3 = v3 + this->pTileTypes[(v3 - 90) / 36].uTileID - 36 * (v3 - 90) / 36 - 90;
+      v3 = v3 + this->pTileTypes[(v3 - 90) / 36].uTileID - 36 * ((v3 - 90) / 36) - 90;
   return pTileTable->pTiles[v3].uAttributes;
- }
+  }
 }
 
 //----- (0047EE16) --------------------------------------------------------
--- a/Outdoor.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/Outdoor.h	Mon Feb 18 09:44:59 2013 +0600
@@ -124,6 +124,9 @@
   {
     subconstuctor();
     uLastSunlightUpdateMinute = 0;
+
+    uNumBModels = 0;
+    pBModels = nullptr;
   }
   //----- (004626CD) --------------------------------------------------------
   void subconstuctor()
--- a/Party.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/Party.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -12,6 +12,7 @@
 #include "Viewport.h"
 #include "Actor.h"
 #include "GUIWindow.h"
+#include "texts.h"
 
 #include "mm7_data.h"
 
@@ -70,12 +71,9 @@
 //----- (004936E1) --------------------------------------------------------
 void Party::SetHoldingItem(ItemGen *pItem)
 {
-  Party *v2; // esi@1
-
-  v2 = this;
   sub_421B2C_PlaceInInventory_or_DropPickedItem();
-  memcpy(&v2->pPickedItem, pItem, sizeof(v2->pPickedItem));
-  pMouse->SetCursorBitmapFromItemID(v2->pPickedItem.uItemID);
+  memcpy(&pPickedItem, pItem, sizeof(pPickedItem));
+  pMouse->SetCursorBitmapFromItemID(pPickedItem.uItemID);
 }
 
 //----- (0049370F) --------------------------------------------------------
@@ -391,7 +389,7 @@
 	    if (pPlayers[uNumPlayers].pActiveSkills[12+i])
 			++uSpellBookPageCount;
     }
-    pCharacter->pNumSpellBookPage = uSpellBookPageCount;
+    pCharacter->lastOpenedSpellbookPage = uSpellBookPageCount;
 //LABEL_10:
     pCharacter->uExpressionTimePassed = 0;
     Dst.Reset();
--- a/Player.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/Player.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -1,5 +1,6 @@
+#include <assert.h>
+
 #include "OSAPI.h"
-
 #include "Player.h"
 #include "PlayerFrameTable.h"
 #include "Texture.h"
@@ -20,6 +21,7 @@
 #include "StorylineTextTable.h"
 #include "Autonotes.h"
 #include "Awards.h"
+#include "texts.h"
 #include "mm7_data.h"
 
 
@@ -255,7 +257,7 @@
     result = v2->uOffHand;
     if ( v2->uOffHand )
     {
-      result = *(int *)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * result + 5];
+      result = *(int *)&this->pInventoryItems[result-1];
       if ( result )
       {
         if ( result != 64 && result != 65 )
@@ -569,44 +571,45 @@
 }
 
 //----- (004948B1) --------------------------------------------------------
-__int16 Player::PlaySound(int a2, int a3)
-{
-  Player *pPlayer; // edi@1
-  int v4; // eax@4
+void Player::PlaySound(PlayerSpeech speech, int a3)
+{
+  //Player *pPlayer; // edi@1
+  //int v4; // eax@4
   signed int v5; // esi@4
-  short *v6; // ebx@4
+  unsigned char *v6; // ebx@4
   signed int v7; // ecx@5
   unsigned __int8 v8; // al@6
   int v9; // eax@10
-  unsigned int pVoiceID; // ecx@10
+  //unsigned int pVoiceID; // ecx@10
   int v11; // esi@10
   signed int v12; // eax@11
   signed int v13; // esi@12
   int v14; // eax@12
-  int v15; // eax@17
+  //int v15; // eax@17
   int pExpression; // ebx@17
   signed int v17; // ecx@19
   char *pSoundID; // edi@20
   int v20[5]; // [sp+Ch] [bp-1Ch]@7
-  Player *pPlayer2; // [sp+20h] [bp-8h]@1
+  //Player *pPlayer2; // [sp+20h] [bp-8h]@1
   int pPlayerNum; // [sp+24h] [bp-4h]@1
   int pSoundId; // [sp+30h] [bp+8h]@4
 
-  pPlayer = this;
-  pPlayer2 = this;
+  //pPlayer = this;
+  //pPlayer2 = this;
+
   pPlayerNum = 1;
-  do
-  {
-    if ( this == pPlayers[pPlayerNum] )
+  for (int i = 0; i < 4; ++i)
+    if (&pParty->pPlayers[i] == this)
+    {
+      pPlayerNum = i + 1;
       break;
-    ++pPlayerNum;
-  }
-  while ( pPlayerNum <= 4 );
-  v4 = a2;//102
+    }
+
+  //v4 = a2;//102
   v5 = 0;
   pSoundId = 0;
-  v6 = &SoundSetAction[8 * v4];//byte_4ED280 &byte_4ED3D8[4 * v4] ???
-  if ( uVoicesVolumeMultiplier )
+  v6 = SoundSetAction[speech];//byte_4ED280 &byte_4ED3D8[4 * v4] ???
+  if (uVoicesVolumeMultiplier)
   {
     v7 = 0;
     do
@@ -620,19 +623,18 @@
     if ( v5 )
     {
       v9 = rand();
-      pVoiceID = pPlayer->uVoiceID;
+      //pVoiceID = uVoiceID;
       v11 = v20[v9 % v5];
-      if ( LOBYTE((&(&dlhu_texnames_by_face[19])[25 * v11 + 3])[pVoiceID]) )
-      {
-        pSoundId = rand() % SLOBYTE((&(&dlhu_texnames_by_face[19])[25 * v11 + 3])[pVoiceID])
-            + 2 * (v11 + 50 * pPlayer2->uVoiceID)
-            + 4998;
-        v12 = 8 * pPlayerNum + 312;
-        LOBYTE(v12) = v12 | 4;
+
+      if (int _v1 = byte_4ECF08[v11 - 1][uVoiceID])
+      {
+        pSoundId = rand() % _v1 + 2 * (v11 + 50 * uVoiceID) + 4998;
+        v12 = (8 * pPlayerNum + 312) | OBJECT_Player;
         pAudioPlayer->PlaySound((SoundID)pSoundId, v12, 0, -1, 0, 0, (pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0), 0);
       }
     }
   }
+
   v13 = 0;
   v14 = (int)(v6 + 3);
   do
@@ -644,9 +646,8 @@
   while ( -3 - (signed int)v6 + v14 < 5 );
   if ( v13 )
   {
-    v15 = rand();
     pPlayerNum = 0;
-    pExpression = v20[v15 % v13];
+    pExpression = v20[rand() % v13];
     if ( pExpression == 21 && pSoundId )
     {
       v17 = 0;
@@ -669,26 +670,27 @@
       if ( pSoundList->pSounds[v17].pSoundData[0] )
         pPlayerNum = (sLastTrackLengthMS << 7) / 1000;
     }
-    LOWORD(v14) = pPlayer2->PlayEmotion((CHARACTER_EXPRESSION_ID)pExpression, pPlayerNum);
-  }
-  return v14;
+    /*LOWORD(v14) = */PlayEmotion((CHARACTER_EXPRESSION_ID)pExpression, pPlayerNum);
+  }
+  //return v14;
 }
 // 4948B1: using guessed type int var_1C[5];
 
 //----- (00494A25) --------------------------------------------------------
-__int16 Player::PlayEmotion(CHARACTER_EXPRESSION_ID expr, int a3)
-{
-  signed int v3; // eax@1
-  CHARACTER_EXPRESSION_ID v4; // dx@1
+void Player::PlayEmotion(CHARACTER_EXPRESSION_ID new_expression, int a3)
+{
+  //signed int v3; // eax@1
+  //CHARACTER_EXPRESSION_ID v4; // dx@1
   signed int v5; // edi@15
   PlayerFrame *v6; // esi@17
   signed int v7; // eax@20
 
-  LOWORD(v3) = this->expression;
-  v4 = expr;
-  if ( (short)v3 != 4 && (short)v3 != 12 || expr != 58 )
-  {
-    v3 = (unsigned __int16)v3;
+  //LOWORD(v3) = this->expression;
+  //v4 = expr;
+  if (expression != CHARACTER_EXPRESSION_SLEEP &&
+      expression != CHARACTER_EXPRESSION_PERTIFIED || new_expression != CHARACTER_EXPRESSION_58)
+  {
+    int v3 = (unsigned)expression;
     if ( (signed int)(unsigned __int16)v3 >= 2 )
     {
       if ( v3 <= 7 )
@@ -697,19 +699,19 @@
       {
         if ( v3 > 11 )
         {
-          if ( v3 == 12 || v3 > 97 && v3 <= 99 )
-            return v3;
+          if ( v3 == CHARACTER_EXPRESSION_PERTIFIED || v3 > 97 && v3 <= 99 )
+            return;
           goto LABEL_15;
         }
 LABEL_12:
-        if ( expr != 34 && expr != 35 && expr != 36 )
-          return v3;
+        if (new_expression != CHARACTER_EXPRESSION_34 && new_expression != CHARACTER_EXPRESSION_35 && new_expression != CHARACTER_EXPRESSION_36)
+          return;
         goto LABEL_15;
       }
     }
   }
 LABEL_15:
-  LOWORD(v3) = a3;
+  //LOWORD(v3) = a3;
   v5 = 0;
   this->uExpressionTimeLength = a3;
   this->uExpressionTimePassed = 0;
@@ -723,7 +725,7 @@
     else
     {
       v6 = pPlayerFrameTable->pFrames;
-      while ( v6->expression != expr )
+      while ( v6->expression != new_expression )
       {
         ++v5;
         ++v6;
@@ -732,13 +734,11 @@
       }
       v7 = v5;
     }
-    v4 = expr;
-    LOWORD(v3) = 8 * pPlayerFrameTable->pFrames[v3].uAnimLength;
-    this->uExpressionTimeLength = v3;
-  }
-  this->expression = v4;
+    //v4 = expr;
+    this->uExpressionTimeLength = 8 * pPlayerFrameTable->pFrames[a3].uAnimLength;
+  }
+  expression = new_expression;
   viewparams->bRedrawGameUI = 1;
-  return v3;
 }
 
 //----- (0049327B) --------------------------------------------------------
@@ -1237,7 +1237,7 @@
           goto LABEL_76;
         goto LABEL_82;
       case 0xDu:
-        v3->PlaySound(32, 0);
+        v3->PlaySound(SPEECH_32, 0);
         v13 = (char *)&v3->sHealth;
         goto LABEL_70;
       case 0xEu:
@@ -1268,9 +1268,9 @@
           goto LABEL_76;
         }
         v28 = 0;
-        v25 = 35;
+        v25 = SPEECH_35;
 LABEL_67:
-        v3->PlaySound(v25, v28);
+        v3->PlaySound((PlayerSpeech)v25, v28);
         if ( v3->sHealth > 0 )
           v3->sHealth = 0;
         v13 = (char *)&v3->sMana;
@@ -1295,7 +1295,7 @@
         if ( v30 == 2 )
         {
           if ( v31 == 1 )
-            pPlayers[v21]->PlaySound(107, 0);
+            pPlayers[v21]->PlaySound(SPEECH_107, 0);
         }
         result = 1;
         break;
@@ -1345,11 +1345,11 @@
         }
         v26 = 0;
         v20 = (v18 != 0) + 23;
-        v23 = 99;
+        v23 = SPEECH_99;
         v3->uFace = v20;
         v3->uVoiceID = v20;
 LABEL_81:
-        v3->PlaySound(v23, v26);
+        v3->PlaySound((PlayerSpeech)v23, v26);
         goto LABEL_82;
       default:
         goto LABEL_82;
@@ -1373,7 +1373,7 @@
 
   v11 = this;
   v3 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
-  v4 = (Texture *)(v3 != -1 ? (int)&pIcons_LOD->pTextures[v3] : 0);
+  v4 = (Texture *)(v3 != -1 ? &pIcons_LOD->pTextures[v3] : 0);
   v5 = GetSizeInInventorySlots(v3 != -1 ? pIcons_LOD->pTextures[v3].uTextureWidth : 24);
   uItemIDa = GetSizeInInventorySlots(v4->uTextureHeight);
   if ( !areWeLoadingTexture )
@@ -1462,7 +1462,7 @@
   if ( v12 == -1 )
   {
     if ( uActiveCharacter )
-      pPlayers[uActiveCharacter]->PlaySound(15, 0);
+      pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0);
     result = 0;
   }
   else
@@ -1760,7 +1760,8 @@
   unsigned int uSlota; // [sp+14h] [bp+4h]@1
 
   pIndices = &this->pInventoryIndices[uSlot];
-  v3 = (ItemGen *)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *pIndices + 5];
+
+  v3 = &this->pInventoryItems[*pIndices-1];
   v4 = v3->uItemID;
   v3->Reset();
   v5 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v4].pIconName, TEXTURE_16BIT_PALETTE);
@@ -2314,6 +2315,8 @@
   field_FC = 0;
   field_100 = 0;
   field_104 = 0;
+
+  lastOpenedSpellbookPage = 0;
 }
 
 //----- (0048C6F6) --------------------------------------------------------
@@ -2332,10 +2335,10 @@
   std::string v12; // [sp-18h] [bp-40h]@9
   const char *v13; // [sp-8h] [bp-30h]@9
   int v14; // [sp-4h] [bp-2Ch]@9
-  int v15; // [sp+Ch] [bp-1Ch]@3
-  int v16; // [sp+10h] [bp-18h]@3
-  int v17; // [sp+14h] [bp-14h]@3
-  int v18; // [sp+18h] [bp-10h]@3
+  int v15[4] = {0, 1, 2, 3}; // [sp+Ch] [bp-1Ch]@3
+  //int v16; // [sp+10h] [bp-18h]@3
+  //int v17; // [sp+14h] [bp-14h]@3
+  //int v18; // [sp+18h] [bp-10h]@3
   Player *v19; // [sp+1Ch] [bp-Ch]@9
   Party *v20; // [sp+20h] [bp-8h]@1
   int v21; // [sp+24h] [bp-4h]@10
@@ -2344,19 +2347,19 @@
 
   v20 = thos;
   v2 = pItem->uItemID;
-  if ( !BYTE2(pItemsTable->pItems[v2 + 1].uItemID) )
+  if ( !pItemsTable->pItems[v2].uItemID_Rep_St )
     pItem->uAttributes |= 1u;
-  v15 = 0;
-  v16 = 1;
-  v18 = 3;
-  v17 = 2;
+  ///v15 = 0;
+  //v16 = 1;
+  //v18 = 3;
+  //v17 = 2;
   if ( uActiveCharacter )
   {
     v3 = uActiveCharacter - 1;
     v4 = 0;
     do
     {
-      *(&v15 + v4++) = v3++;
+      v15[v4++] = v3++;
       if ( (signed int)v3 >= 4 )
         v3 = 0;
     }
@@ -2366,13 +2369,13 @@
   if ( v5 )
   {
     v6 = pIcons_LOD->LoadTexture(v5, TEXTURE_16BIT_PALETTE);
-    v7 = (Texture *)(v6 != -1 ? (int)&pIcons_LOD->pTextures[v6] : 0);
+    v7 = (Texture *)(v6 != -1 ? &pIcons_LOD->pTextures[v6] : 0);
     v21 = areWeLoadingTexture;
     v8 = 0;
     while ( 1 )
     {
-      v9 = &v20->pPlayers[*(&v15 + v8)];
-      v19 = &v20->pPlayers[*(&v15 + v8)];
+      v9 = &v20->pPlayers[v15[v8]];
+      v19 = &v20->pPlayers[v15[v8]];
       v10 = v19->AddItem(0xFFFFFFFFu, pItem->uItemID);
       if ( v10 )
         break;
@@ -2387,10 +2390,10 @@
         goto LABEL_15;
       }
     }
-    memcpy(&v9->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v10 + 5], pItem, 0x24u);
+    memcpy(&v9->pInventoryItems[v10-1], pItem, 0x24u);
     pItem->Reset();
     pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0);
-    v19->PlaySound(60, 0);
+    v19->PlaySound(SPEECH_60, 0);
     if ( !v21 )
     {
       v7->Release();
@@ -2782,7 +2785,7 @@
   }
   if ( HasItemEquipped(EQUIP_TWO_HANDED) )
   {
-    v6 = (ItemGen *)&v5->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v5->pEquipment.uMainHand + 5];
+    v6 = (ItemGen *)&v5->pInventoryItems[v5->pEquipment.uMainHand-1];
     v7 = v6->uItemID;
     v8 = v6->uItemID;
     v9 = pItemsTable->pItems[v8].uDamageDice;
@@ -2854,7 +2857,7 @@
   {
     if ( v5->HasItemEquipped((ITEM_EQUIP_TYPE)0) )
     {
-      v15 = (ItemGen *)&v5->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v5->pEquipment.uOffHand + 5];
+      v15 = (ItemGen *)&v5->pInventoryItems[v5->pEquipment.uOffHand-1];
       v16 = v15->uItemID;
       v17 = v15->uItemID;
       if ( pItemsTable->pItems[v17].uEquipType != 4 )
@@ -2947,7 +2950,7 @@
   int v7; // edi@4
 
   v1 = this;
-  v2 = *(int *)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * this->pEquipment.uMainHand + 5];
+  v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1];
   if ( v2 < 64 || v2 > 65 )
   {
     v4 = GetActualAccuracy();
@@ -3037,7 +3040,7 @@
   result = HasItemEquipped(EQUIP_BOW);
   if ( !result )
     return result;
-  v4 = (ItemGen *)&v2->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2->pEquipment.uBow + 5];
+  v4 = (ItemGen *)&v2->pInventoryItems[v2->pEquipment.uBow-1];
   v5 = v4->uItemID;
   v6 = v4->uItemID;
   v15 = pItemsTable->pItems[v6].uDamageRoll;
@@ -3108,7 +3111,7 @@
   static char player__getmeleedamagestring_static_buff[40]; // idb
 
   v1 = this;
-  v2 = *(int *)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * this->pEquipment.uMainHand + 5];
+  v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1];
   if ( v2 < 64 || v2 > 65 )
   {
     v3 = GetMeleeDamageMinimal();
@@ -3134,7 +3137,7 @@
   v8 = v1->pEquipment.uMainHand;
   if ( v8 )
   {
-    v9 = *(int *)&v1->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5];
+    v9 = *(int *)&v1->pInventoryItems[v8-1];
     if ( v9 >= 135 )
     {
       if ( v9 <= 159 )
@@ -3160,7 +3163,7 @@
   static char player__getrangeddamagestring_static_buff[40]; // idb
 
   v1 = this;
-  v2 = *(int *)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * this->pEquipment.uMainHand + 5];
+  v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1];
   if ( v2 < 64 || v2 > 65 )
   {
     v3 = GetRangedDamageMin();
@@ -3194,7 +3197,7 @@
   v8 = v1->pEquipment.uMainHand;
   if ( v8 )
   {
-    v9 = *(int *)&v1->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5];
+    v9 = *(int *)&v1->pInventoryItems[v8-1];
     if ( v9 >= 135 )
     {
       if ( v9 <= 159 )
@@ -3666,13 +3669,13 @@
   unsigned int v7; // eax@8
   char *v8; // ecx@9
   int v9; // eax@9
-  signed int typea; // [sp+14h] [bp+8h]@1
+  //signed int typea; // [sp+14h] [bp+8h]@1
 
   v3 = this;
   this->pConditions[2] = 0i64;
   v4 = CalculateIncommingDamage(resistance, type);
   v3->sHealth -= v4;
-  typea = v4;
+  //typea = v4;
   v5 = v3->sHealth;
   v6 = v5 < -10;
   LOBYTE(v6) = v5 <= -10;
@@ -3705,9 +3708,9 @@
       }
     }
   }
-  if ( typea && CanAct() )
-    PlaySound(24, 0);
-  return typea;
+  if ( v4 && CanAct() )
+    PlaySound(SPEECH_24, 0);
+  return v4;
 }
 
 //----- (0048DCF6) --------------------------------------------------------
@@ -3858,7 +3861,7 @@
       {
         if ( *v20 > 0 )
         {
-          v21 = *(int *)&v5->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *v20 + 5];
+          v21 = *(int *)&v5->pInventoryItems[*v20-1];
           if ( v21 > 0 )
           {
             if ( v21 <= 134 )
@@ -4018,11 +4021,11 @@
         v26 = v48;
         if ( *(char *)(v48 + 21) & 2 )
           goto LABEL_84;
-        PlaySound(40, 0);
+        PlaySound(SPEECH_40, 0);
         *(int *)(v26 + 20) |= 2u;
         goto LABEL_79;
       case 20:
-        PlaySound(40, 0);
+        PlaySound(SPEECH_40, 0);
         v27 = pActor->array_000234;
         if ( pActor->array_000234[0].uItemID )
         {
@@ -4044,11 +4047,11 @@
         v30 = (SoundID)47;
         goto LABEL_83;
       case 21:
-        PlaySound(42, 0);
+        PlaySound(SPEECH_42, 0);
         ++v5->sAgeModifier;
         goto LABEL_82;
       case 22:
-        PlaySound(41, 0);
+        PlaySound(SPEECH_41, 0);
         v5->sMana = 0;
 LABEL_82:
         v42 = 0;
@@ -4138,7 +4141,7 @@
   {
     if ( !HasItemEquipped(EQUIP_BOW) )
       goto LABEL_17;
-    v5 = (int)&v4->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v4->pEquipment.uBow + 5];
+    v5 = (int)&v4->pInventoryItems[v4->pEquipment.uBow-1];
     v46 = v5;
     v3 = (char *)&pItemsTable->pItems[*(int *)v5].pIconName;
     v6 = (unsigned __int16)word_4EDED8[(unsigned __int8)v3[29]];
@@ -4157,7 +4160,7 @@
   }
   if ( HasItemEquipped(EQUIP_TWO_HANDED) )
   {
-    v8 = (int)&v4->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v4->pEquipment.uMainHand + 5];
+    v8 = (int)&v4->pInventoryItems[v4->pEquipment.uMainHand-1];
     v46 = v8;
     v9 = *(int *)v8;
     v3 = (char *)&pItemsTable->pItems[v9].pIconName;
@@ -4169,7 +4172,7 @@
   }
   if ( HasItemEquipped((ITEM_EQUIP_TYPE)0) )
   {
-    v12 = (int)&v4->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v4->pEquipment.uOffHand + 5];
+    v12 = (int)&v4->pInventoryItems[v4->pEquipment.uOffHand-1];
     v42 = (unsigned __int16)word_4EDED8[pItemsTable->pItems[*(int *)v12].uSkillType];
     if ( (signed int)v42 > v47 )
     {
@@ -4183,7 +4186,7 @@
 LABEL_17:
   if ( HasItemEquipped(EQUIP_ARMOUR) )
   {
-    v14 = pItemsTable->pItems[*(int *)&v4->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v4->pEquipment.uBody + 5]].uSkillType;
+    v14 = pItemsTable->pItems[*(int *)&v4->pInventoryItems[v4->pEquipment.uBody-1]].uSkillType;
     SkillToMastery(v4->pActiveSkills[9]);
     v15 = (unsigned __int16)word_4EDED8[v14];
     v35 = 1.0;
@@ -4866,14 +4869,14 @@
     if ( (signed int)attr <= 30 )
     {
       if ( HasItemEquipped(EQUIP_BOW) )
-        v5 = pItemsTable->pItems[*(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6->pEquipment.uBow + 5]].uDamageMod;
+        v5 = pItemsTable->pItems[*(int *)&v6->pInventoryItems[v6->pEquipment.uBow-1]].uDamageMod;
       return v5 + v62 + v61;
     }
     if ( attr == 31 )
     {
       if ( !HasItemEquipped(EQUIP_BOW) )
         return v5 + v62 + v61;
-      v57 = *(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6->pEquipment.uBow + 5];
+      v57 = *(int *)&v6->pInventoryItems[v6->pEquipment.uBow-1];
       v5 = pItemsTable->pItems[v57].uDamageMod;
       v56 = pItemsTable->pItems[v57].uDamageDice;
       goto LABEL_366;
@@ -4882,7 +4885,7 @@
     {
       if ( !HasItemEquipped(EQUIP_BOW) )
         return v5 + v62 + v61;
-      v20 = *(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6->pEquipment.uBow + 5];
+      v20 = *(int *)&v6->pInventoryItems[v6->pEquipment.uBow-1];
       v5 = pItemsTable->pItems[v20].uDamageDice * pItemsTable->pItems[v20].uDamageRoll;
 LABEL_365:
       v56 = pItemsTable->pItems[v20].uDamageMod;
@@ -5515,12 +5518,12 @@
       if ( v17 >= 0 )
       {
         if ( v17 <= 2 )
-          v5 = pItemsTable->pItems[*(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6->pEquipment.uMainHand + 5]].uDamageMod;
+          v5 = pItemsTable->pItems[*(int *)&v6->pInventoryItems[v6->pEquipment.uMainHand-1]].uDamageMod;
       }
     }
     if ( a3 || !v6->HasItemEquipped((ITEM_EQUIP_TYPE)0) || (v19 = v18->GetEquippedItemEquipType(0), v19 < 0) || v19 > 2 )
       return v5 + v62 + v61;
-    v20 = *(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6->pEquipment.uOffHand + 5];
+    v20 = *(int *)&v6->pInventoryItems[v6->pEquipment.uOffHand-1];
     goto LABEL_365;
   }
   if ( attr == 27 )
@@ -6407,7 +6410,7 @@
 }
 
 //----- (00490141) --------------------------------------------------------
-int Player::GetSexByVoice()
+PLAYER_SEX Player::GetSexByVoice()
 {
   signed int result; // eax@1
 
@@ -6426,8 +6429,8 @@
     case 0x11u:
     case 0x14u:
     case 0x17u:
-      result = 0;
-      break;
+      return SEX_MALE;
+
     case 4u:
     case 5u:
     case 6u:
@@ -6440,12 +6443,11 @@
     case 0x13u:
     case 0x15u:
     case 0x18u:
-      result = 1;
-      break;
+      return SEX_FEMALE;
+
     default:
-      return result;
-  }
-  return result;
+      assert(false);
+  }
 }
 
 //----- (00490188) --------------------------------------------------------
@@ -6534,15 +6536,15 @@
 
     switch (i)
     {
-      case PLAYER_SKILL_FIRE:   spellbook.pFireSpellbook.bIsSpellbookAvailable = true;   break;
-      case PLAYER_SKILL_AIR:    spellbook.pAirSpellbook.bIsSpellbookAvailable = true;    break;
-      case PLAYER_SKILL_WATER:  spellbook.pWaterSpellbook.bIsSpellbookAvailable = true;  break;
-      case PLAYER_SKILL_EARTH:  spellbook.pEarthSpellbook.bIsSpellbookAvailable = true;  break;
-      case PLAYER_SKILL_SPIRIT: spellbook.pSpiritSpellbook.bIsSpellbookAvailable = true; break;
-      case PLAYER_SKILL_MIND:   spellbook.pMindSpellbook.bIsSpellbookAvailable = 1; break;
-      case PLAYER_SKILL_BODY:   spellbook.pBodySpellbook.bIsSpellbookAvailable = 1; break;
-      case PLAYER_SKILL_LIGHT:  spellbook.pLightSpellbook.bIsSpellbookAvailable = 1; break;
-      case PLAYER_SKILL_DARK:   spellbook.pDarkSpellbook.bIsSpellbookAvailable = 1; break;
+      case PLAYER_SKILL_FIRE:   spellbook.pFireSpellbook.bIsSpellAvailable[0] = true;   break;
+      case PLAYER_SKILL_AIR:    spellbook.pAirSpellbook.bIsSpellAvailable[0] = true;    break;
+      case PLAYER_SKILL_WATER:  spellbook.pWaterSpellbook.bIsSpellAvailable[0] = true;  break;
+      case PLAYER_SKILL_EARTH:  spellbook.pEarthSpellbook.bIsSpellAvailable[0] = true;  break;
+      case PLAYER_SKILL_SPIRIT: spellbook.pSpiritSpellbook.bIsSpellAvailable[0] = true; break;
+      case PLAYER_SKILL_MIND:   spellbook.pMindSpellbook.bIsSpellAvailable[0] = true;   break;
+      case PLAYER_SKILL_BODY:   spellbook.pBodySpellbook.bIsSpellAvailable[0] = true;   break;
+      case PLAYER_SKILL_LIGHT:  spellbook.pLightSpellbook.bIsSpellAvailable[0] = true;  break;
+      case PLAYER_SKILL_DARK:   spellbook.pDarkSpellbook.bIsSpellAvailable[0] = true;   break;
     }
   }
 
@@ -6975,7 +6977,7 @@
   unsigned int thisa; // [sp+28h] [bp-4h]@22
 
   thisb = this;
-  v3 = &pParty->pPlayers[a2-1];//(Player *)&stru_AA1058[3].pSounds[6972 * a2 + 40552];
+  v3 = &pParty->pPlayers[a2-1];
   v73 = 1;
   if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 3) )
     return;
@@ -7003,10 +7005,10 @@
         }
         v69 = 2;
 LABEL_111:
-        pParty->pPlayers[a2-1].Heal(v69);//((Player *)&stru_AA1058[3].pSounds[6972 * a2 + 40552])->Heal(v69);
+        pParty->pPlayers[a2-1].Heal(v69);
       }
 LABEL_112:
-      v3->PlaySound(36, 0);
+      v3->PlaySound(SPEECH_36, 0);
       goto LABEL_173;
     }
 LABEL_172:
@@ -7176,7 +7178,7 @@
         v33 = HIDWORD(v3->pConditions[15]);
         v34 = LODWORD(v3->pConditions[16]);
         v35 = HIDWORD(v3->pConditions[16]);
-        memset(&pParty->pPlayers[a2-1],0,0xA0u);//memset(&stru_AA1058[3].pSounds[6972 * a2 + 40552], 0, 0xA0u);
+        memset(&pParty->pPlayers[a2-1],0,0xA0u);
         HIDWORD(v3->pConditions[14]) = v31;
         LODWORD(v3->pConditions[15]) = v32;
         HIDWORD(v3->pConditions[15]) = v33;
@@ -7448,7 +7450,7 @@
               ShowStatusBarString(pTmpBuf, 2u);
               pMouse->RemoveHoldingItem();
               pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, a2 - 1);
-              v3->PlaySound(93, 0);
+              v3->PlaySound(SPEECH_93, 0);
               pAudioPlayer->PlaySound((SoundID)(SOUND_Bell|0x2), 0, 0, -1, 0, 0, 0, 0);
               if ( pParty->uDaysPlayed == 6 || pParty->uDaysPlayed == 20 )
               {
@@ -7547,13 +7549,13 @@
         pMouse->RemoveHoldingItem();
         return;
       }
-      if ( pParty->pPlayers[a2-1].CanAct() )//if ( ((Player *)&stru_AA1058[3].pSounds[6972 * a2 + 40552])->CanAct() )
+      if ( pParty->pPlayers[a2-1].CanAct() )
       {
         sub_467F48(pParty->pPickedItem.uItemID);
         v65 = 0;
-        v56 = 37;
+        v56 = SPEECH_37;
 LABEL_67:
-        v3->PlaySound(v56, v65);
+        v3->PlaySound((PlayerSpeech)v56, v65);
         return;
       }
 LABEL_89:
@@ -7591,7 +7593,7 @@
       pAudioPlayer->PlaySound(v37, v39, v41, v43, v45, v48, v52, v61);
       return;
     }
-    if ( !pParty->pPlayers[a2-1].CanAct() )//if ( !((Player *)&stru_AA1058[3].pSounds[6972 * a2 + 40552])->CanAct() )
+    if ( !pParty->pPlayers[a2-1].CanAct() )
     {
       v66 = aCharacterConditionNames[v3->GetMajorConditionIdx()];
       v57 = pGlobalTXT_LocalizationStrings[382];
@@ -7623,7 +7625,7 @@
               goto LABEL_67;
             }
             *v72 = 1;
-            v3->PlaySound(21, 0);
+            v3->PlaySound(SPEECH_21, 0);
             v73 = 0;
 LABEL_173:
             v36 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType;
@@ -7703,7 +7705,7 @@
   }
   if ( pCurrentScreen == SCREEN_CASTING )
     return;
-  if ( !pParty->pPlayers[a2-1].CanAct() )//if ( !((Player *)&stru_AA1058[3].pSounds[6972 * a2 + 40552])->CanAct() )
+  if ( !pParty->pPlayers[a2-1].CanAct() )
     goto LABEL_89;
   if ( bUnderwater == 1 )
   {
@@ -8375,7 +8377,7 @@
           || var > VAR_History_28
           || (v22 = var - 276, pParty->field_3C.field_4F0[2 * v22 + 1] | pParty->field_3C.field_4F0[2 * v22])
           || (pParty->field_3C.field_4F0[2 * (var - 276)] = LODWORD(pParty->uTimePlayed),
-              v23 = *(&pStorylineText->field_0 + 3 * v22) == 0,
+              v23 = pStorylineText->StoreLine[v22].pText==0,//*(&pStorylineText->field_0 + 3 * v22) == 0,
               pParty->field_3C.field_4F0[2 * (var - 276) + 1] = HIDWORD(pParty->uTimePlayed),
               v23) )
           return;
@@ -8434,7 +8436,7 @@
     {
       v20 = pPlayers[v3 + 1];
       v30 = 1;
-      v20->PlaySound(96, 0);
+      v20->PlaySound(SPEECH_96, 0);
 	  v21 = pAutonoteTxt[a3-1].eType;// dword_72371C[2 * a3];
       bFlashAutonotesBook = 1;
       dword_506568 = v21;
@@ -8505,7 +8507,7 @@
             v12 = pPlayers[v3 + 1];
             v30 = 1;
             v31 = 1;
-            v12->PlaySound(96, 0);
+            v12->PlaySound(SPEECH_96, 0);
           }
           v13 = v4->field_152;
           goto LABEL_51;
@@ -8521,7 +8523,7 @@
             bFlashQuestBook = 1;
             v30 = 1;
             v31 = 1;
-            v14->PlaySound(93, 0);
+            v14->PlaySound(SPEECH_93, 0);
           }
           v13 = (char *)pParty->_award_bits;
 LABEL_51:
@@ -8621,11 +8623,11 @@
     this->uMightBonus = (unsigned __int8)a3;
 LABEL_111:
     v28 = 0;
-    v26 = 91;
+    v26 = SPEECH_91;
 LABEL_112:
     v19 = pPlayers[v3 + 1];
     v31 = 1;
-    v19->PlaySound(v26, v28);
+    v19->PlaySound((PlayerSpeech)v26, v28);
     goto LABEL_169;
   }
   if ( var <= VAR_FireResistanceBonus )
@@ -8934,7 +8936,7 @@
                 v14 = pPlayers[uPlayerIdx + 1];
                 v34 = 1;
                 v3 = 1;
-                v14->PlaySound(96, 0);
+                v14->PlaySound(SPEECH_96, 0);
               }
               v15 = v4->field_152;
               goto LABEL_44;
@@ -8954,7 +8956,7 @@
                 bFlashQuestBook = 1;
                 v34 = 1;
                 v3 = 1;
-                v17->PlaySound(93, 0);
+                v17->PlaySound(SPEECH_93, 0);
               }
               v15 = (char *)pParty->_award_bits;
 LABEL_44:
@@ -9105,10 +9107,10 @@
         if ( *v19 > 255 )
           *v19 = 255;
         v31 = 0;
-        v29 = 91;
+        v29 = SPEECH_91;
 LABEL_116:
         v3 = 1;
-        pPlayers[uPlayerIdx + 1]->PlaySound(v29, v31);
+        pPlayers[uPlayerIdx + 1]->PlaySound((PlayerSpeech)v29, v31);
         goto _play_anim_and_maybe_sound;
       }
       if ( var <= VAR_DisarmTrapSkill )
@@ -9217,7 +9219,7 @@
     {
       v23 = pPlayers[uPlayerIdx + 1];
       v34 = 1;
-      v23->PlaySound(96, 0);
+      v23->PlaySound(SPEECH_96, 0);
 	  v24 = pAutonoteTxt[val-1].eType;//dword_72371C[2 * val];
       bFlashAutonotesBook = 1;
       dword_506568 = v24;
@@ -9306,7 +9308,7 @@
         || var > VAR_History_28
         || (v25 = var - 276, pParty->field_3C.field_4F0[2 * v25 + 1] | pParty->field_3C.field_4F0[2 * v25])
         || (pParty->field_3C.field_4F0[2 * (var - 276)] = LODWORD(pParty->uTimePlayed),
-            v26 = *(&pStorylineText->field_0 + 3 * v25) == 0,
+            v26 = pStorylineText->StoreLine[v25].pText==0,//*(&pStorylineText->field_0 + 3 * v25) == 0,
             pParty->field_3C.field_4F0[2 * (var - 276) + 1] = HIDWORD(pParty->uTimePlayed),
             v26) )
         return;
@@ -9565,7 +9567,7 @@
           goto LABEL_17;
         case VAR_QBits_QuestsDone:
           _449B7E_toggle_bit(pParty->_award_bits, (__int16)a3, 0);
-          pPlayers[v4 + 1]->PlaySound(96, 0);
+          pPlayers[v4 + 1]->PlaySound(SPEECH_96, 0);
           return;
         case VAR_PlayerItemInHands:
           v15 = (char *)this->pInventoryIndices;
@@ -9688,9 +9690,9 @@
           this->sResMagicBonus -= (signed __int16)a3;
 LABEL_72:
           v25 = 0;
-          v23 = 91;
+          v23 = SPEECH_91;
 LABEL_73:
-          pPlayers[v4 + 1]->PlaySound(v23, v25);
+          pPlayers[v4 + 1]->PlaySound((PlayerSpeech)v23, v25);
           goto LABEL_17;
         case VAR_FixedFood:
           Party::TakeFood((unsigned int)a3);
--- a/Player.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/Player.h	Mon Feb 18 09:44:59 2013 +0600
@@ -6,6 +6,124 @@
 
 
 
+
+
+/*  301 */
+enum PlayerSpeech
+{
+  SPEECH_1 = 1,
+  SPEECH_2 = 2,
+  SPEECH_3 = 3,
+  SPEECH_4 = 4,
+  SPEECH_5 = 5,
+  SPEECH_6 = 6,
+  SPEECH_7 = 7,
+  SPEECH_8 = 8,
+  SPEECH_9 = 9,
+  SPEECH_10 = 10,
+  SPEECH_11 = 11,
+  SPEECH_12 = 12,
+  SPEECH_14 = 14,
+  SPEECH_NoRoom = 15,  // when placing to inventory
+  SPEECH_16 = 16,
+  SPEECH_17 = 17,
+  SPEECH_18 = 18,
+  SPEECH_19 = 19,
+  SPEECH_20 = 20,
+  SPEECH_21 = 21,
+  SPEECH_GoodDay = 22,     // greets on dialogue start
+  SPEECH_GoodEvening = 23,
+  SPEECH_24 = 24,
+  SPEECH_25 = 25,
+  SPEECH_26 = 26,
+  SPEECH_27 = 27,
+  SPEECH_28 = 28,
+  SPEECH_29 = 29,
+  SPEECH_30 = 30,
+  SPEECH_31 = 31,
+  SPEECH_32 = 32,
+  SPEECH_33 = 33,
+  SPEECH_34 = 34,
+  SPEECH_35 = 35,
+  SPEECH_36 = 36,
+  SPEECH_37 = 37,
+  SPEECH_38 = 38,
+  SPEECH_39 = 39,
+  SPEECH_40 = 40,
+  SPEECH_41 = 41,
+  SPEECH_42 = 42,
+  SPEECH_43 = 43,
+  SPEECH_44 = 44,
+  SPEECH_45 = 45,
+  SPEECH_46 = 46,
+  SPEECH_47 = 47,
+  SPEECH_48 = 48,
+  SPEECH_49 = 49,
+  SPEECH_50 = 50,
+  SPEECH_51 = 51,
+  SPEECH_52 = 52,
+  SPEECH_53 = 53,
+  SPEECH_54 = 54,
+  SPEECH_55 = 55,
+  SPEECH_56 = 56,
+  SPEECH_57 = 57,
+  SPEECH_58 = 58,
+  SPEECH_59 = 59,
+  SPEECH_60 = 60,
+  SPEECH_61 = 61,
+  SPEECH_62 = 62,
+  SPEECH_63 = 63,
+  SPEECH_64 = 64,
+  SPEECH_Yell = 65,
+  SPEECH_66 = 66,
+  SPEECH_67 = 67,
+  SPEECH_68 = 68,
+  SPEECH_69 = 69,
+  SPEECH_70 = 70,
+  SPEECH_71 = 71,
+  SPEECH_72 = 72,
+  SPEECH_73 = 73,
+  SPEECH_74 = 74,
+  SPEECH_75 = 75,
+  SPEECH_76 = 76,
+  SPEECH_77 = 77,
+  SPEECH_78 = 78,
+  SPEECH_79 = 79,
+  SPEECH_80 = 80,
+  SPEECH_81 = 81,
+  SPEECH_82 = 82,
+  SPEECH_83 = 83,
+  SPEECH_84 = 84,
+  SPEECH_85 = 85,
+  SPEECH_86 = 86,
+  SPEECH_87 = 87,
+  SPEECH_88 = 88,
+  SPEECH_89 = 89,
+  SPEECH_90 = 90,
+  SPEECH_91 = 91,
+  SPEECH_92 = 92,
+  SPEECH_93 = 93,
+  SPEECH_94 = 94,
+  SPEECH_95 = 95,
+  SPEECH_96 = 96,
+  SPEECH_97 = 97,
+  SPEECH_98 = 98,
+  SPEECH_99 = 99,
+  SPEECH_100 = 100,
+  SPEECH_101 = 101,
+  SPEECH_PickMe = 102,
+  SPEECH_103 = 103,
+  SPEECH_104 = 104,
+  SPEECH_105 = 105,
+  SPEECH_106 = 106,
+  SPEECH_107 = 107,
+  SPEECH_108 = 108,
+  SPEECH_109 = 109,
+  SPEECH_110 = 110,
+};
+
+
+
 /*  339 */
 enum CHARACTER_RACE
 {
@@ -77,26 +195,28 @@
   PLAYER_SKILL_WATER = 14,
   PLAYER_SKILL_EARTH = 15,
   PLAYER_SKILL_SPIRIT = 16,
-  PLAYER_SKILL_MIND = 0x11,
+  PLAYER_SKILL_MIND = 17,
   PLAYER_SKILL_BODY = 18,
-  PLAYER_SKILL_LIGHT = 0x13,
-  PLAYER_SKILL_DARK = 0x14,
-  PLAYER_SKILL_ITEM_ID = 0x15,
-  PLAYER_SKILL_MERCHANT = 0x16,
-  PLAYER_SKILL_REPAIR = 0x17,
-  PLAYER_SKILL_BODYBUILDING = 0x18,
-  PLAYER_SKILL_MEDITATION = 0x19,
-  PLAYER_SKILL_PERCEPTION = 0x1A,
-  PLAYER_SKILL_DIPLOMACY = 0x1B,
-  PLAYER_SKILL_TIEVERY = 0x1C,
+  PLAYER_SKILL_LIGHT = 19,
+  PLAYER_SKILL_DARK = 20,
+  PLAYER_SKILL_ITEM_ID = 21,
+  PLAYER_SKILL_MERCHANT = 22,
+  PLAYER_SKILL_REPAIR = 23,
+  PLAYER_SKILL_BODYBUILDING = 24,
+  PLAYER_SKILL_MEDITATION = 25,
+  PLAYER_SKILL_PERCEPTION = 26,
+  PLAYER_SKILL_DIPLOMACY = 27,
+  PLAYER_SKILL_TIEVERY = 28,
   PLAYER_SKILL_TRAP_DISARM = 29,
-  PLAYER_SKILL_DODGE = 0x1E,
-  PLAYER_SKILL_UNARMED = 0x1F,
-  PLAYER_SKILL_MONSTER_ID = 0x20,
+  PLAYER_SKILL_DODGE = 30,
+  PLAYER_SKILL_UNARMED = 31,
+  PLAYER_SKILL_MONSTER_ID = 32,
   PLAYER_SKILL_ARMSMASTER = 33,
   PLAYER_SKILL_STEALING = 34,
   PLAYER_SKILL_ALCHEMY = 35,
-  PLAYER_SKILL_LEARNING = 0x24,
+  PLAYER_SKILL_LEARNING = 36,
+
+  PLAYER_SKILL_INVALID = -1
 };
 
 /*  329 */
@@ -137,8 +257,7 @@
 #pragma pack(push, 1)
 struct PlayerSpellbookChapter
 {
-  unsigned __int8 bIsSpellbookAvailable;
-  char bIsSpellAvailable[10];
+  char bIsSpellAvailable[11];
 };
 #pragma pack(pop)
 
@@ -255,6 +374,7 @@
   CHARACTER_EXPRESSION_55 = 55,
   CHARACTER_EXPRESSION_56 = 56,
   CHARACTER_EXPRESSION_57 = 57,
+  CHARACTER_EXPRESSION_58 = 58,
 
   // ?
 
@@ -363,7 +483,7 @@
   char GetActualSkillLevel(enum PLAYER_SKILL_TYPE uSkillType);
   int GetSkillBonus(enum CHARACTER_ATTRIBUTE_TYPE a2);
   enum CHARACTER_RACE GetRace();
-  int GetSexByVoice();
+  PLAYER_SEX GetSexByVoice();
   void SetInitialStats();
   int SetSexByVoice();
   void Reset(PLAYER_CLASS_TYPE classType);
@@ -397,8 +517,8 @@
   bool CanEquip_RaceAndAlignmentCheck(unsigned int uItemID);
   int SetCondition(unsigned int uConditionIdx, int a3);
   int _49327B(unsigned int uClass, int a3);
-  __int16 PlaySound(int a2, int a3);
-  __int16 PlayEmotion(CHARACTER_EXPRESSION_ID expression, int a3);
+  void PlaySound(PlayerSpeech speech, int a3);
+  void PlayEmotion(CHARACTER_EXPRESSION_ID expression, int a3);
   char _4160CA(int a2);
   unsigned int GetItemIDAtInventoryIndex(int *a2);
   int _4B6FF9();
@@ -547,7 +667,7 @@
   int field_1988[49];
   char field_1A4C;
   char field_1A4D;
-  char pNumSpellBookPage;
+  char lastOpenedSpellbookPage;
   unsigned __int8 uQuickSpell;
   char field_1A50[64];
   char _some_attack_bonus;
--- a/Render.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/Render.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -21,6 +21,7 @@
 #include "Actor.h"
 #include "Log.h"
 #include "TileFrameTable.h"
+#include "texts.h"
 
 #include "mm7_data.h"
 
@@ -52,7 +53,7 @@
 
 RenderVertexSoft array_73D150[20];
 
-RenderVertexD3D3 arary_77E5C8[50];
+RenderVertexD3D3 d3d_vertex_buffer[50];
 
 RenderVertexSoft *ptr_801A04;
 RenderVertexSoft *ptr_801A08;
@@ -135,7 +136,7 @@
   pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface2, &pTexture2, true, false, 32u);
 
   ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture1));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
   ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2u));
   ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u));
   ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u));
@@ -143,7 +144,7 @@
   ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1u));
 
   ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture2));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, 3u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
   ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1u));
   ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7u));
   ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2u));
@@ -1743,6 +1744,11 @@
   //struct IndoorCameraD3D *pIndoorCameraD3D;
   //RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6
 
+
+  //warning: the game uses CW culling by default, ccw is incosistent
+  pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW);
+
+
   v63 = 0;
   // basic optimizations
   unsigned int uStartX, uEndX,
@@ -1782,6 +1788,7 @@
       pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0);
     }
   }
+
   for (unsigned int z = uStartZ; z < uEndZ - 1; ++z)
   {
     for (unsigned int x = uStartX; x < uEndX - 1; ++x)
@@ -1796,6 +1803,7 @@
       v8->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v8->uTileBitmapID];
       if (v8->uTileBitmapID == 0xFFFF)
         continue;
+
       v8->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z);
       v8->field_32 = 0;
       v8->field_59 = 1;
@@ -1836,6 +1844,7 @@
         array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097);
       }
 
+      bool transparent = false;
             if ( v8->flags & 2 && v8->uTileBitmapID == pRenderer->field_1036AC_bitmapid )
             {
               //v80 = false;
@@ -1844,11 +1853,23 @@
             else
             {
               v6 = v8->uTileBitmapID;
-              //v80 = true;
+              transparent = true;
             }
 
       assert(v6 < 1000); // many random crashes here
-      pRenderer->DrawTerrainPolygon(v8, pBitmaps_LOD->pHardwareTextures[v6]);
+
+      // for all shore tiles - draw a tile water under them since they're half-empty
+      if (!strnicmp(pBitmaps_LOD->pTextures[v8->uTileBitmapID].pName, "wtrdr", 5))  // all shore tile filenames are wtrdrXXX
+      {
+        pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE);  // no Z writing: the shore tile will be draw in the same place, so taking care about z-fighting
+        pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]], false, true);
+        pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE);
+        
+      }
+
+      pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[v6], transparent, true);
+
+
       --pOutdoorCamera->numStru148s;
       --pOutdoorCamera->field_44;
     }
@@ -1996,6 +2017,7 @@
       v5 = abs(X);//v5 = 13108
       v6 = abs(v83);//v6 = 13108
       --X;
+      __debugbreak(); // uncoment & refactor following large if
       v93 = (int)&stru_76E5C8[(v5 << 7) + v6];
       /*if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7),
                                                                        v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)),
@@ -2168,7 +2190,7 @@
             v77 = (int)v16;
             //v76 = v16->uNumVertices;
 //LABEL_161:
-            pRenderer->DrawTerrainPolygon(v16, pBitmaps_LOD->pHardwareTextures[v39]);//pRenderer->DrawTerrainPolygon(v16->uNumVertices, v16, pBitmaps_LOD->pHardwareTextures[v39], false, v80);
+            pRenderer->DrawTerrainPolygon(v16->uNumVertices, v16, pBitmaps_LOD->pHardwareTextures[v39], false, v80);
             goto LABEL_162;
           }
           v38 = v16;
@@ -2312,7 +2334,7 @@
           v58 = v40->uTileBitmapID;
           v81 = 1;
         }
-        pRenderer->DrawTerrainPolygon(v40, pBitmaps_LOD->pHardwareTextures[v58]);
+        pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81);
       }
 LABEL_112:
       v59 = &array_77EC08[pOutdoorCamera->numStru148s];
@@ -2433,7 +2455,7 @@
             //v77 = (int)v71;
             //v76 = v71->uNumVertices;
             //goto LABEL_161;
-            pRenderer->DrawTerrainPolygon(v71, pBitmaps_LOD->pHardwareTextures[v75]);//pRenderer->DrawTerrainPolygon(v76, (stru148 *)v71, v78, v79, v80);
+            pRenderer->DrawTerrainPolygon(v76, (stru148 *)v71, v78, v79, v80);
             goto LABEL_162;
           }
           v38 = (stru148 *)v71;
@@ -4413,18 +4435,18 @@
     {
       if ( !v54 || byte_4D864C && pGame->uFlags & 2 )
       {
-        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u));//   
+        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));//   
         ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
         if (bUsingSpecular)
         {
-          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, true));
-          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2));
-          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1));
+          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
+          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)&arary_77E5C8[0].pos.y;
+          v57 = (int)&d3d_vertex_buffer[0].pos.y;
           v55 = uNumVertices;
           do
           {
@@ -4458,7 +4480,7 @@
         pRenderD3D->pDevice->SetTexture(0, pTexture);
         pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
                                            D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
-                                           arary_77E5C8,
+                                           d3d_vertex_buffer,
                                            uNumVertices,
                                            D3DDP_DONOTLIGHT);
       }
@@ -4466,9 +4488,9 @@
       {
         if ( (signed int)uNumVertices > 0 )
         {
-          v9 = (ODMFace *)&arary_77E5C8[0].pos.y;
+          v9 = (ODMFace *)&d3d_vertex_buffer[0].pos.y;
           v10 = (char *)&array_50AC10[0].vWorldViewPosition;
-          a4 = (ODMFace *)&arary_77E5C8[0].pos.y;
+          a4 = (ODMFace *)&d3d_vertex_buffer[0].pos.y;
           v56 = uNumVertices;
           while ( 1 )
           {
@@ -4503,15 +4525,15 @@
             v9 = a4;
           }
         }
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false));
-        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u));
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
+        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
         if (bUsingSpecular)
-          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
+          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
 
         ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
         ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
                                                   D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
-                                                  arary_77E5C8,
+                                                  d3d_vertex_buffer,
                                                   uNumVertices,
                                                   D3DDP_DONOTLIGHT));
         //v50 = (const char *)v5->pRenderD3D->pDevice;
@@ -4521,7 +4543,7 @@
         v23 = uNumVertices;
         if ( (signed int)uNumVertices > 0 )
         {
-          v24 = (char *)&arary_77E5C8[0].diffuse;
+          v24 = (char *)&d3d_vertex_buffer[0].diffuse;
           do
           {
             *(int *)v24 = a2;
@@ -4531,26 +4553,26 @@
           while ( v23 );
         }
         ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture));
-        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u));
+        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
         if ( !pRenderer->bUsingSpecular )
-          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true));
-
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, true));
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 1));
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 3));
+          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
+
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO));
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR));
         ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
                                                   D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
-                                                  arary_77E5C8,
+                                                  d3d_vertex_buffer,
                                                   uNumVertices,
                                                   D3DDP_DONOTLIGHT));
         if (bUsingSpecular)
         {
-          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true));
+          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
 
           v33 = uNumVertices;
           if ( (signed int)uNumVertices > 0 )
           {
-            v34 = (char *)&arary_77E5C8[0].specular;
+            v34 = (char *)&d3d_vertex_buffer[0].specular;
             do
             {
               v35 = *(int *)v34;
@@ -4562,22 +4584,22 @@
             while ( v33 );
           }
           ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
-          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 6));
-          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 5));
+          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA));
+          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA));
           ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
                                                     D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
-                                                    arary_77E5C8,
+                                                    d3d_vertex_buffer,
                                                     uNumVertices,
                                                     D3DDP_DONOTLIGHT));
-          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, true));
+          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
           //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl;
           v41 = GetLevelFogColor();
           pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF);
           v6 = 0;
           pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0);
         }
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2));
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1));
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
         ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6));
       }
     }
@@ -7207,7 +7229,7 @@
   return ::GetActorTintColor(a3, a4, a2, a5, a6);
 }
 
-void Render::DrawTerrainPolygon(stru148 *a3, IDirect3DTexture2 *pTexture)//new function
+/*void Render::DrawTerrainPolygon_new(stru148 *a3, IDirect3DTexture2 *pTexture)//new function
 {
   int v5; // ebx@1
   int v6; // edi@1
@@ -7267,13 +7289,13 @@
 
 
  
-     this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1);
+     this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP);
      this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
      if (this->bUsingSpecular)
      {
-      this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1);
-      this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2);
-      this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1);
+      this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
+      this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
+      this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
      }
 
      pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX;
@@ -7319,12 +7341,13 @@
      this->pRenderD3D->pDevice->SetTexture(0, pTexture);
      this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT);
 
-}
+}*/
+
 //----- (004A26BC) --------------------------------------------------------
-void Render::DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, int a6, int a7)
-{
-  RenderVertexSoft *pVertices; // esi@0
-  int v7; // edi@1
+void Render::DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders)
+{
+  //RenderVertexSoft *pVertices; // esi@0
+  //int v7; // edi@1
   unsigned int v8; // ebx@1
   LightmapBuilder *v9; // esi@3
   unsigned int v10; // edx@3
@@ -7366,7 +7389,7 @@
   HRESULT v46; // eax@29
   HRESULT v47; // eax@29
   HRESULT v48; // eax@29
-  IDirect3DDevice3 *v49; // eax@35
+  //IDirect3DDevice3 *v49; // eax@35
   //IDirect3DDevice3Vtbl *v50; // ecx@35
   int v51; // eax@40
   char *v52; // esi@40
@@ -7377,23 +7400,25 @@
   double v57; // st7@42
   float v58; // ST7C_4@43
   int v59; // eax@43
-  signed int v60; // [sp+78h] [bp-14h]@31
-  RenderVertexSoft *v61; // [sp+7Ch] [bp-10h]@3
+  //signed int v60; // [sp+78h] [bp-14h]@31
+  //RenderVertexSoft *v61; // [sp+7Ch] [bp-10h]@3
   const char *v62; // [sp+80h] [bp-Ch]@0
   const char *v63; // [sp+80h] [bp-Ch]@19
   int v64; // [sp+84h] [bp-8h]@0
   LightmapBuilder *v65; // [sp+88h] [bp-4h]@3
   unsigned int v66; // [sp+88h] [bp-4h]@40
   unsigned int a6a; // [sp+A0h] [bp+14h]@11
-
-  v7 = (int)this;
+  int a7;
+
+  //v7 = (int)this;
   v8 = 0;
-  if ( !this->uNumD3DSceneBegins )
+  if (!this->uNumD3DSceneBegins)
      return;
   if ( uNumVertices < 3)
      return;
 
-  v61 = pVertices;
+  //v61 = pVertices;
+
   /*  v9 = pGame->pLightmapBuilder;
     v65 = v9;
     v10 = v9->std__vector_000004_size;*/
@@ -7404,37 +7429,35 @@
     }
     else
     {
-      if ( a6 || !pGame->pLightmapBuilder->std__vector_000004_size || 
+      if (transparent || !pGame->pLightmapBuilder->std__vector_000004_size || 
           byte_4D864C && pGame->uFlags & 2 )
       {
-        if ( (_BYTE)a7 )
-          v60 = 3;
+        if (clampAtTextureBorders)
+          this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP);
         else
-          v60 = 1;
-        this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, v60);
-        if ( a6 || this->bUsingSpecular )
-        {
-          this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1);
-          v49 = this->pRenderD3D->pDevice;
-          //v50 = v49->lpVtbl;
-          if ( a6 )
+          this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP);
+
+        if (transparent || this->bUsingSpecular)
+        {
+          this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
+          if (transparent)
           {
-            this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 5);
-            //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 6);
+            this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
+            this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
+            //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO);
+            //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
           }
           else
           {
-            this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2);
-            //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1);
-            __debugbreak;//it's error
+            this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
+            this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
           }
-
-        }
-        if ( (signed int)uNumVertices > 0 )
-        {
-          v51 = (int)&arary_77E5C8[0].pos.y;
+        }
+        if (uNumVertices > 0)
+        {
+          v51 = (int)&d3d_vertex_buffer[0].pos.y;
           v52 = (char *)&array_50AC10[0].vWorldViewPosition;
-          a7 = (int)&arary_77E5C8[0].pos.y;
+          a7 = (int)&d3d_vertex_buffer[0].pos.y;
           v66 = uNumVertices;
           while ( 1 )
           {
@@ -7470,22 +7493,21 @@
           }
         }
         this->pRenderD3D->pDevice->SetTexture(0, a5);
-        this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
-          arary_77E5C8, uNumVertices, 16);
-        if ( a6 )
-        {
-          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
-          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
-          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
+        this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16);
+        if (transparent)
+        {
+          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
+          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
         }
       }
       else
       {
         if ( (signed int)uNumVertices > 0 )
         {
-          v12 = (int)&arary_77E5C8[0].pos.y;
+          v12 = (int)&d3d_vertex_buffer[0].pos.y;
           v13 = (char *)&array_50AC10[0].vWorldViewPosition;
-          a7 = (int)&arary_77E5C8[0].pos.y;
+          a7 = (int)&d3d_vertex_buffer[0].pos.y;
           a6a = uNumVertices;
           while ( 1 )
           {
@@ -7520,26 +7542,25 @@
             v12 = a7;
           }
         }
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false));
-        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u));
-        if ( pRenderer->bUsingSpecular )
-          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
+        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
+        if (pRenderer->bUsingSpecular)
+          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
 
         ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));
-        ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
-                D3DPT_TRIANGLEFAN,
+        ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
                 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
-                arary_77E5C8,
+                d3d_vertex_buffer,
                 uNumVertices,
                 16));
         //v63 = (const char *)v7->pRenderD3D->pDevice;
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1));
+        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 *)&arary_77E5C8[0].diffuse;
+          v27 = (char *)&d3d_vertex_buffer[0].diffuse;
           do
           {
             *(int *)v27 = -1;
@@ -7549,28 +7570,27 @@
           while ( v26 );
         }
         ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5));
-        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u));
+        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
         if ( !pRenderer->bUsingSpecular )
         {
-          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
-        }
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u));
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 1u));
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 3u));
-        ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
-                D3DPT_TRIANGLEFAN,
+          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
+        }
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO));
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR));
+        ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
                 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
-                arary_77E5C8,
+                d3d_vertex_buffer,
                 uNumVertices,
                 16));
         if ( pRenderer->bUsingSpecular )
         {
-          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
+          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
           ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));
           v37 = uNumVertices;
           if ( (signed int)uNumVertices > 0 )
           {
-            v38 = (char *)&arary_77E5C8[0].specular;
+            v38 = (char *)&d3d_vertex_buffer[0].specular;
             do
             {
               v39 = *(int *)v38;
@@ -7582,28 +7602,29 @@
             while ( v37 );
           }
           ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem
-          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 6u));
-          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 5u));
-          ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
-                  D3DPT_TRIANGLEFAN,
+          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA));
+          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA));
+          ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
                   D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
-                  arary_77E5C8,
+                  d3d_vertex_buffer,
                   uNumVertices,
                   16));
-          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1));
+          ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
           //v44 = pRenderer->pRenderD3D->pDevice;
           v45 = GetLevelFogColor();
           ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF));
           v8 = 0;
           ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
         }
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2));
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
         ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8));
       }
     }
-    if ( pIndoorCamera->field_4C & 2 || pBLVRenderParams->uFlags & 2 )
-      pGame->pIndoorCameraD3D->debug_outline_d3d(arary_77E5C8, uNumVertices, 0xFFFFFFu, 0.0);
+
+    if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_D3D_OUTLINES ||
+        pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_D3D_OUTLINES )
+      pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0);
   }
 
 // 4A26BC: could not find valid save-restore pair for esi
@@ -7623,12 +7644,12 @@
 
  if (uNumVertices >= 3)
  {
-  this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1);
+  this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP);
   if (this->bUsingSpecular)
   {
-   this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1);
-   this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2);
-   this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1);
+   this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
+   this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
+   this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
   }
   
   for (i = 0; i < uNumVertices; ++i)
@@ -7666,12 +7687,12 @@
     return;
   if ( uNumVertices >= 3 )
   {
-    this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1);
+    this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP);
     if ( this->bUsingSpecular )
     {
-      this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1);
-      this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2);
-      this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1);
+      this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
+      this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
+      this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
     }
     for (i = 0; i < uNumVertices; ++i)
     {
@@ -7715,14 +7736,14 @@
     v4 = a2;
     if ( a2 >= 3 )
     {
-      ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u));
+      ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
       v5 = 31 - (a3->field_58 & 0x1F);
       if ( v5 < pOutdoor->field_CBC_terrain_triangles_shade_type )
         v5 = pOutdoor->field_CBC_terrain_triangles_shade_type;
       v6 = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8);
       if ( a2 > 0 )
       {
-        v7 = (char *)&arary_77E5C8[0].pos.y;
+        v7 = (char *)&d3d_vertex_buffer[0].pos.y;
         v8 = (char *)&array_507D30[0].vWorldViewProjY;
         do
         {
@@ -7744,10 +7765,9 @@
         while ( v4 );
       }
       ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex));
-      ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
-        D3DPT_TRIANGLEFAN,
+      ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
         D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
-        arary_77E5C8,
+        d3d_vertex_buffer,
         a2,
         28));
     }
@@ -7810,11 +7830,11 @@
   {
       __debugbreak();
       ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false));
-      ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1));
+      ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
       if ( (signed int)uNumVertices > 0 )
       {
         v12 = (char *)&array_507D30[0].vWorldViewPosition;
-        v13 = (char *)&arary_77E5C8[0].pos.y;
+        v13 = (char *)&d3d_vertex_buffer[0].pos.y;
         auto a7 = uNumVertices;
         uint v18;
         do
@@ -7840,12 +7860,12 @@
         }
         while ( !v18 );
       }
-      ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1));
+      ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
       ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
       ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
               D3DPT_TRIANGLEFAN,
               D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
-              arary_77E5C8,
+              d3d_vertex_buffer,
               uNumVertices,
               28));
       pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0);
@@ -7857,21 +7877,21 @@
     {
       for (uint i = 0; i < uNumVertices; ++i)
       {
-        arary_77E5C8[i].pos.x = array_507D30[i].vWorldViewProjX;
-        arary_77E5C8[i].pos.y = array_507D30[i].vWorldViewProjY;
-        arary_77E5C8[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894);
-        arary_77E5C8[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x;
-        arary_77E5C8[i].diffuse = uCorrectedColor;
-        arary_77E5C8[i].specular = 0;
-        arary_77E5C8[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth;
-        arary_77E5C8[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight;
-      }
-
-      ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1));
+        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, pHwTex));
       ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
                 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
-                arary_77E5C8,
+                d3d_vertex_buffer,
                 uNumVertices,
                 28));
     }
@@ -7882,7 +7902,7 @@
         {
           v23 = pTex;
           v24 = (char *)&array_507D30[0].vWorldViewPosition;
-          v25 = (char *)&arary_77E5C8[0].pos.y;
+          v25 = (char *)&d3d_vertex_buffer[0].pos.y;
           pTex = (Texture *)uNumVertices;
           uint v18;
           do
@@ -7908,12 +7928,11 @@
           while ( !v18 );
         }
         ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false));
-        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1));
+        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
         ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
-        ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
-                D3DPT_TRIANGLEFAN,
+        ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
                 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
-                arary_77E5C8,
+                d3d_vertex_buffer,
                 uNumVertices,
                 28));
         ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1));
@@ -7921,7 +7940,7 @@
         v33 = uNumVertices;
         if ( (signed int)uNumVertices > 0 )
         {
-          v34 = (char *)&arary_77E5C8[0].diffuse;
+          v34 = (char *)&d3d_vertex_buffer[0].diffuse;
           do
           {
             *(int *)v34 = uCorrectedColor;
@@ -7931,20 +7950,19 @@
           while ( v33 );
         }
         ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex));
-        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1));
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, true));
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 1));
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 3));
-        ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
-                D3DPT_TRIANGLEFAN,
+        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO));
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR));
+        ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
                 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
-                arary_77E5C8,
+                d3d_vertex_buffer,
                 uNumVertices,
                 28));
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2));
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1));
-        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, false));
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
+        ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
     }
   }
 }
@@ -8708,12 +8726,12 @@
   v29[3].pos.y = v18 + srcY;
   v29[3].texcoord.x = 0.0;
   v29[3].texcoord.y = 0.0;
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
   ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9));
   ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(
     D3DPT_TRIANGLEFAN,
@@ -8721,12 +8739,12 @@
     v29,
     4,
     24));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
 }
 
 
@@ -9186,25 +9204,25 @@
     v36[3].texcoord.x = 0.0;
     v36[3].texcoord.y = 0.0;
     ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));
-    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
-    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u));
-    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
-    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 5u));
-    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 6u));
-    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
-    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 8u));
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA));
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA));
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS));
     ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
       D3DPT_TRIANGLEFAN,
       D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
       v36,
       4,
       28));
-    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2));
-    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
-    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
-    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
-    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u));
-    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u));
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS));
   }
   else
   {
@@ -11295,9 +11313,9 @@
 //----- (004A1C1E) --------------------------------------------------------
 void DoRenderBillboards_D3D()
 {
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
   ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
   
   /*if (pRenderer->uNumBillboardsToDraw)
@@ -11348,16 +11366,16 @@
   if (pRenderer->bFogEnabled)
   {
     pRenderer->bFogEnabled = false;
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1));
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
     ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF));
     ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
   }
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
 }
 
 
@@ -11374,14 +11392,14 @@
       if (pRenderer->bFogEnabled)
       {
         pRenderer->bFogEnabled = false;
-        ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
+        ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
         ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF));
         ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
       }
 
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 5));
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 6u));
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1));
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA));
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA));
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
     }
     break;
 
@@ -11394,13 +11412,13 @@
         if (!pRenderer->bFogEnabled)
         {
           pRenderer->bFogEnabled = true;
-          ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
-        }
-      }
-
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2));
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
+          ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
+        }
+      }
+
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
     }
     break;
 
--- a/Render.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/Render.h	Mon Feb 18 09:44:59 2013 +0600
@@ -56,7 +56,15 @@
   int _screenspace_y_scaler_packedfloat;
   float fov_x;
   float fov_y;
-  int sZValue;
+  union
+  {
+    int sZValue;
+    struct
+    {
+      unsigned __int16 object_pid;
+      signed __int16 actual_z;
+    };
+  };
   int field_14_actor_id;
   unsigned __int16 uHwSpriteID;
   __int16 uPalette;
@@ -73,7 +81,7 @@
 
    inline float GetFloatZ() const
  {
-  return LOWORD(sZValue) / 65535.0f + (float)HIWORD(sZValue);
+  return (float)object_pid / 65535.0f + (float)actual_z;
  }
 };
 #pragma pack(pop)
@@ -313,9 +321,8 @@
   void DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
   unsigned int GetActorTintColor(float a2, int a3, int a4, int a5, RenderBillboard *a6);
   void DrawPolygon(unsigned int uNumVertices, stru148 *a3, ODMFace *a4, IDirect3DTexture2 *pTexture);
-  void DrawTerrainPolygon(stru148 *a3, IDirect3DTexture2 *pTexture);
-  void DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, int a6, int a7);
-  void Render::DrawStrip(unsigned int uNumVertices, struct stru148 *a3, IDirect3DTexture2 *pTexture);
+  void DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders);
+  void DrawStrip(unsigned int uNumVertices, struct stru148 *a3, IDirect3DTexture2 *pTexture);
   void DrawFan(unsigned int uNumVertices, stru148 *a3, IDirect3DTexture2 *a4);
   void _4A2ED5(signed int a2, stru148 *a3, IDirect3DTexture2 *pHwTex);
   void DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8);
@@ -513,7 +520,7 @@
 
 extern RenderVertexSoft array_73D150[20];
 
-extern RenderVertexD3D3 arary_77E5C8[50];
+extern RenderVertexD3D3 d3d_vertex_buffer[50];
 
 extern RenderVertexSoft *ptr_801A04;
 extern RenderVertexSoft *ptr_801A08;
--- a/SaveLoad.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/SaveLoad.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -17,6 +17,7 @@
 #include "LayingItem.h"
 #include "Viewport.h"
 #include "stru123.h"
+#include "texts.h"
 #include "Log.h"
 
 #include "mm7_data.h"
@@ -66,18 +67,18 @@
     }
 
 
-  if (byte_4ED498)
+  if (SoundSetAction[24][0])
     for (uint i = 0; i < 4; ++i)
     {
       for (uint j = 0; j < pSoundList->uNumSounds; ++j)
-        if (pSoundList->pSounds[j].uSoundID == 2 * (byte_4ED498 + 50 * pParty->pPlayers[i].uVoiceID) + 4998)
+        if (pSoundList->pSounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4998)
         {
           pSoundList->_4A9DCD(j, 1);
           break;
         }
 
         for (uint j = 0; j < pSoundList->uNumSounds; ++j)
-        if (pSoundList->pSounds[j].uSoundID == 2 * (byte_4ED498 + 50 * pParty->pPlayers[i].uVoiceID) + 4999)
+        if (pSoundList->pSounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4999)
         {
           pSoundList->_4A9DCD(j, 1);
           break;
--- a/Spells.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/Spells.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -5,6 +5,7 @@
 #include "Allocator.h"
 #include "LOD.h"
 #include "stru123.h"
+#include "texts.h"
 
 #include "mm7_data.h"
 
@@ -16,8 +17,109 @@
 
 
 stru324_spell stru_4E3ACC[102];
-SpellData pSpellDatas[95];
 
+SpellData pSpellDatas[100]={
+					 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},	
+					 {1, 1, 1, 1, 60, 60, 60, 40, 0, 0},
+	                 {2, 2, 2, 2, 110, 110, 100, 90, 768, 0},
+	                 {3, 3, 3, 3, 120, 120, 120, 120, 0, 0},
+	                 {4, 4, 4, 4, 120, 120, 120, 120, 0, 0},
+	                 {5, 5, 5, 5, 120, 120, 120, 120, 0, 0},
+	                 {8, 8, 8, 8, 100, 100, 90, 80, 1536, 0},
+	                 {10, 10, 10, 10, 150, 150, 150, 150, 1536, 0},
+	                 {15, 15, 15, 15, 120, 120, 120, 120, 1536, 0},
+	                 {20, 20, 20, 20, 100, 100, 100, 90, 264, 0},
+	                 {25, 25, 25, 25, 100, 100, 100, 90, 268, 0},
+	                 {30, 30, 30, 30, 90, 90, 90, 90, 3855, 0},
+	                 {1, 1, 1, 0, 60, 60, 60, 60, 0, 0},
+	                 {2, 2, 2, 2, 120, 120, 120, 100, 0, 0},
+	                 {3, 3, 3, 3, 120, 120, 120, 120, 0, 0},
+	                 {4, 4, 4, 4, 110, 100, 90, 80, 258, 0},
+	                 {5, 5, 5, 5,  90, 90,  70, 50, 0, 0},
+	                 {8, 8, 8, 8, 120, 120, 120, 120, 0, 0},
+	                 {10, 10, 10, 10, 100, 100, 90, 70, 2048, 0},
+	                 {15, 15, 15, 15, 200, 200, 200, 200, 0, 0},
+	                 {20, 20, 20, 20, 100, 100, 100, 90, 2570, 0},
+	                 {25, 25, 25, 25, 250, 250, 250, 250, 0, 0},
+	                 {30, 30, 30, 30, 90, 90, 90, 90, 276, 0},
+	                 {1, 1, 1, 1, 60, 60, 60, 20, 0, 0},
+	                 {2, 2, 2, 2, 110, 100, 90, 70, 514, 0},
+	                 {3, 3, 3, 3, 120, 120, 120, 120, 0, 0},
+	                 {4, 4, 4, 4, 110, 100, 90, 80, 1024, 0},
+	                 {5, 5, 5, 5, 150, 150, 150, 150, 0, 0},
+	                 {8, 8, 8, 8, 200, 200, 200, 200, 0, 0},
+	                 {10, 10, 10, 10, 100, 100, 90, 80, 2313, 0},
+	                 {15, 15, 15, 15, 140, 140, 140, 140, 0, 0},
+	                 {20, 20, 20, 20, 200, 200, 200, 200, 0, 0},
+	                 {25, 25, 25, 25, 80, 80, 80, 80, 780, 0},
+	                 {30, 30, 30, 30, 250, 250, 250, 250, 0, 0},
+	                 {1, 1, 1, 1, 80, 80, 80, 80, 0, 0},
+	                 {2, 2, 2, 2, 100, 100, 100, 100, 0, 0},
+	                 {3, 3, 3, 3, 120, 120, 120, 120, 0, 0},
+	                 {4, 4, 4, 4, 110, 100, 90, 80, 773, 0},
+	                 {5, 5, 5, 5, 120, 120, 120, 120, 0, 0},
+	                 {8, 8, 8, 8, 100, 100, 90, 80, 2304, 0},
+	                 {10, 10, 10, 10, 140, 140, 140, 140, 0, 0},
+	                 {15, 15, 15, 15, 90, 90, 90, 80, 2048, 0},
+	                 {20, 20, 20, 20, 150, 150, 150, 150, 0, 0},
+	                 {25, 25, 25, 25, 100, 100, 100, 90, 276, 0},
+	                 {30, 30, 30, 30, 90, 90, 90, 90, 25, 0},
+	                 {1, 1, 1, 1, 100, 100, 100, 100, 0, 0},
+	                 {2, 2, 2, 2, 100, 100, 100, 100, 0, 0},
+	                 {3, 3, 3, 3, 90, 90, 90, 90, 0, 0},
+	                 {4, 4, 4, 4, 120, 120, 120, 120, 0, 0},
+	                 {5, 5, 5, 5, 120, 120, 120, 120, 0, 0},
+	                 {8, 8, 8, 8, 120, 120, 120, 120, 0, 0},
+	                 {10, 10, 10, 10, 120, 120, 120, 120, 0, 0},
+	                 {15, 15, 15, 15, 100, 100, 100, 100, 2058, 0},
+	                 {20, 20, 20, 20, 240, 240, 240, 240, 0, 0},
+	                 {25, 25, 25, 25, 150, 150, 150, 150, 0, 0},
+	                 {30, 30, 30, 30, 1000, 1000, 1000, 1000, 0, 0},
+	                 {1, 1, 1, 1, 120, 120, 120, 120, 0, 0},
+	                 {2, 2, 2, 2, 110, 110, 110, 110, 771, 0},
+	                 {3, 3, 3, 3, 120, 120, 120, 120, 0, 0},
+	                 {4, 4, 4, 4, 110, 100, 90, 80, 0, 0},
+	                 {5, 5, 5, 5, 100, 100, 100, 100, 0, 0},
+	                 {8, 8, 8, 8, 120, 120, 120, 120, 0, 0},
+	                 {10, 10, 10, 10, 120, 120, 120, 120, 0, 0},
+	                 {15, 15, 15, 15, 80, 80, 80, 80, 0, 0},
+	                 {20, 20, 20, 20, 120, 120, 120, 120, 0, 0},
+	                 {25, 25, 25, 25, 110, 110, 110, 100, 268, 0},
+	                 {30, 30, 30, 30, 120, 120, 120, 120, 0, 0},
+	                 {1, 1, 1, 1, 120, 120, 120, 120, 0, 0},
+	                 {2, 2, 2, 2, 100, 100, 100, 100, 0, 0},
+	                 {3, 3, 3, 3, 120, 120, 120, 120, 0, 0},
+	                 {4, 4, 4, 4, 110, 100, 90, 80, 520, 0},
+	                 {5, 5, 5, 5, 110, 110, 110, 110, 0, 0},
+	                 {8, 8, 8, 8, 120, 120, 120, 120, 0, 0},
+	                 {10, 10, 10, 10, 120, 120, 120, 120, 0, 0},
+	                 {15, 15, 15, 15, 120, 120, 120, 120, 0, 0},
+	                 {20, 20, 20, 20, 120, 120, 120, 120, 0, 0},
+	                 {25, 25, 25, 25, 110, 110, 110, 100, 1310, 0},
+	                 {30, 30, 30, 30, 100, 100, 100, 100, 0, 0},
+	                 {5, 5, 5, 5, 110, 100, 90, 80, 1024, 0},
+	                 {10, 10, 10, 10, 120, 110, 100, 90, 4112, 0},
+	                 {15, 15, 15, 15, 120, 110, 100, 90, 0, 0},
+	                 {20, 20, 20, 20, 160, 140, 120, 100, 0, 0},
+	                 {25, 25, 25, 25, 140, 140, 140, 140, 0, 0},
+	                 {30, 30, 30, 30, 500, 500, 500, 500, 0, 0},
+	                 {35, 35, 35, 35, 135, 135, 120, 100, 281, 0},
+	                 {40, 40, 40, 40, 500, 500, 500, 500, 0, 0},
+	                 {45, 45, 45, 45, 250, 250, 250, 250, 0, 0},
+	                 {50, 50, 50, 50, 150, 150, 150, 135, 5140, 0},
+	                 {55, 55, 55, 55, 300, 300, 300, 300, 0, 0},
+	                 {10, 10, 10, 10, 140, 140, 140, 140, 0, 0},
+	                 {15, 15, 15, 15, 120, 110, 100, 90, 2585, 0},
+	                 {20, 20, 20, 20, 120, 100, 90, 120, 0, 0},
+	                 {25, 25, 25, 25, 120, 120, 120, 120, 0, 0},
+	                 {30, 30, 30, 30, 90, 90, 80, 70, 1542, 0},
+	                 {35, 35, 35, 35, 120, 120, 100, 80, 0, 0},
+	                 {40, 40, 40, 40, 110, 110, 110, 110, 0, 0},
+	                 {45, 45, 45, 45, 200, 200, 200, 150, 0, 0},
+	                 {50, 50, 50, 50, 120, 120, 120, 100, 6400, 0},
+	                 {55, 55, 55, 55, 250, 250, 250, 250, 306, 0},
+	                 {60, 60, 60, 60, 300, 300, 300, 300, 2073, 0}
+	};
 
 
 
@@ -26,12 +128,7 @@
 //----- (0042EB31) --------------------------------------------------------
 bool SpellBuff::NotExpired()
 {
-  bool result; // eax@1
-
-  result = 0;
-  if ( (signed __int64)this->uExpireTime > 0 )
-    result = 1;
-  return result;
+  return (signed __int64)this->uExpireTime > 0 ? true:false;
 }
 
 
@@ -41,18 +138,16 @@
   SpellBuff *v1; // esi@1
   unsigned __int16 v2; // ax@1
 
-  v1 = this;
-  v2 = this->uOverlayID;
   this->uSkill = 0;
   this->uPower = 0;
   this->uExpireTime = 0i64;
   this->uCaster = 0;
   this->uFlags = 0;
-  if ( v2 )
+  if ( this->uOverlayID )
   {
-    ((OtherOverlay *)&stru_5E4C90._decor_events[20 * v2 + 105])->Reset();
+    ((OtherOverlay *)&stru_5E4C90._decor_events[20 * this->uOverlayID + 105])->Reset();
     pOtherOverlayList->bRedraw = true;
-    v1->uOverlayID = 0;
+    this->uOverlayID = 0;
   }
 }
 
@@ -113,201 +208,152 @@
 
 //----- (0045384A) --------------------------------------------------------
 void SpellStats::Initialize()
-{
-  SpellStats *v1; // esi@1
-  const char *v2; // ebp@3
-  char *v3; // edi@3
-  signed int v4; // ebx@4
-  char *v5; // esi@4
-  char v6; // cl@5
-  int v7; // eax@5
-  size_t v8; // ebp@40
-  int v9; // eax@41
-  int v10; // eax@42
-  int v11; // eax@43
-  char *v12; // [sp+10h] [bp-10h]@3
-  signed int v13; // [sp+14h] [bp-Ch]@4
-  signed int v14; // [sp+18h] [bp-8h]@3
-  int v15; // [sp+1Ch] [bp-4h]@9
+	{
+
+	int decode_step;
+	char* test_string;
+	bool break_loop;
+	unsigned char c;
+	unsigned int temp_str_len;
+	char* tmp_pos;
+
+	if ( pSpellsTXT_Raw )
+		pAllocator->FreeChunk(pSpellsTXT_Raw);
+	pSpellsTXT_Raw = NULL;
 
-  v1 = this;
-  if ( pSpellsTXT_Raw )
-    pAllocator->FreeChunk(pSpellsTXT_Raw);
-  pSpellsTXT_Raw = 0;
-  v2 = "\r";
-  pSpellsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spells.txt", 0);
-  strtok(pSpellsTXT_Raw, "\r");
-  strtok(0, "\r");
-  v14 = 1;
-  v12 = (char *)&pSpellDatas[1].field_10;
-  v3 = (char *)&v1->pInfos[1].uSchool;
-  do
-  {
-    v4 = 0;
-    v5 = strtok(0, v2) + 1;
-    v13 = 0;
-    do
-    {
-      v6 = *v5;
-      v7 = 0;
-      while ( v6 != 9 && v6 )
-      {
-        ++v7;
-        v6 = v5[v7];
-      }
-      v15 = (int)&v5[v7];
-      if ( !v5[v7] )
-        v13 = 1;
-      v5[v7] = 0;
-      if ( v7 )
-      {
-        switch ( v4 )
-        {
-          case 2:
-            *((char **)v3 - 7) = RemoveQuotes(v5);
-            break;
-          case 3:
-            *v3 = 4;
-            if ( _strcmpi("fire", v5) )
-            {
-              if ( _strcmpi("air", v5) )
-              {
-                if ( _strcmpi("water", v5) )
-                {
-                  if ( _strcmpi("earth", v5) )
-                  {
-                    if ( _strcmpi("spirit", v5) )
-                    {
-                      if ( _strcmpi("mind", v5) )
-                      {
-                        if ( _strcmpi("body", v5) )
-                        {
-                          if ( _strcmpi("light", v5) )
-                          {
-                            if ( _strcmpi("dark", v5) )
-                            {
-                              if ( !_strcmpi("magic", v5) )
-                                *v3 = 5;
-                            }
-                            else
-                            {
-                              *v3 = 10;
-                            }
-                          }
-                          else
-                          {
-                            *v3 = 9;
-                          }
-                        }
-                        else
-                        {
-                          *v3 = 8;
-                        }
-                      }
-                      else
-                      {
-                        *v3 = 7;
-                      }
-                    }
-                    else
-                    {
-                      *v3 = 6;
-                    }
-                  }
-                  else
-                  {
-                    *v3 = 3;
-                  }
-                }
-                else
-                {
-                  *v3 = 2;
-                }
-              }
-              else
-              {
-                *v3 = 1;
-              }
-            }
-            else
-            {
-              *v3 = 0;
-            }
-            break;
-          case 4:
-            *((char **)v3 - 6) = RemoveQuotes(v5);
-            break;
-          case 5:
-            *((char **)v3 - 5) = RemoveQuotes(v5);
-            break;
-          case 6:
-            *((char **)v3 - 4) = RemoveQuotes(v5);
-            break;
-          case 7:
-            *((char **)v3 - 3) = RemoveQuotes(v5);
-            break;
-          case 8:
-            *((char **)v3 - 2) = RemoveQuotes(v5);
-            break;
-          case 9:
-            *((char **)v3 - 1) = RemoveQuotes(v5);
-            break;
-          case 10:
-            v4 = 0;
-            v8 = strlen(v5);
-            if ( (signed int)v8 > 0 )
-            {
-              do
-              {
-                v9 = tolower((unsigned __int8)v5[v4]) - 99;
-                if ( v9 )
-                {
-                  v10 = v9 - 2;
-                  if ( v10 )
-                  {
-                    v11 = v10 - 8;
-                    if ( v11 )
-                    {
-                      if ( v11 == 11 )
-                        *v12 |= 8u;
-                    }
-                    else
-                    {
-                      *v12 |= 1u;
-                    }
-                  }
-                  else
-                  {
-                    *v12 |= 2u;
-                  }
-                }
-                else
-                {
-                  *v12 |= 4u;
-                }
-                ++v4;
-              }
-              while ( v4 < (signed int)v8 );
-            }
-            v2 = "\r";
-            break;
-          default:
-            break;
-        }
-      }
-      else
-      {
-        v13 = 1;
-      }
-      ++v4;
-      v5 = (char *)(v15 + 1);
-    }
-    while ( v4 - 1 <= 10 && !v13 );
-    if ( !(v14 % 11) )
-      strtok(0, v2);
-    v12 += 20;
-    ++v14;
-    v3 += 36;
-  }
-  while ( (signed int)v12 <= (signed int)&pSpellDatas[90].field_12 );
-}
\ No newline at end of file
+	pSpellsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spells.txt", 0);
+	strtok(pSpellsTXT_Raw, "\r");
+	strtok(NULL, "\r");
+	for(int i=1; i<100; ++i) 
+		{
+		test_string=strtok(NULL, "\r")+1;
+		decode_step =0;
+		break_loop=false;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{		
+				switch (decode_step)
+					{	
+				case 2:
+					pInfos[i].pName=RemoveQuotes(test_string);
+					break;
+				case 3:
+					pInfos[i].uSchool = SPELL_SCHOOL_NONE;
+					if (!_strcmpi("fire", test_string) )
+						{
+						pInfos[i].uSchool =SPELL_SCHOOL_FIRE;
+						break;
+						}
+					if ( !_strcmpi("air", test_string) )	
+						{
+						pInfos[i].uSchool = SPELL_SCHOOL_AIR;
+						break;
+						}
+					if ( !_strcmpi("water", test_string))	
+						{
+						pInfos[i].uSchool = SPELL_SCHOOL_WATER;
+						break;
+						}	
+					if ( !_strcmpi("earth", test_string))	
+						{
+						pInfos[i].uSchool = SPELL_SCHOOL_EARTH;
+						break;
+						}	
+					if ( !_strcmpi("spirit", test_string))	
+						{
+						pInfos[i].uSchool = SPELL_SCHOOL_SPIRIT;
+						break;
+						}
+					if ( !_strcmpi("mind", test_string))	
+						{
+						pInfos[i].uSchool = SPELL_SCHOOL_MIND;
+						break;
+						}
+					if ( !_strcmpi("body", test_string) )	
+						{
+						pInfos[i].uSchool = SPELL_SCHOOL_BODY;
+						break;
+						}			
+					if ( !_strcmpi("light", test_string) )	
+						{
+						pInfos[i].uSchool =  SPELL_SCHOOL_LIGHT;
+						break;
+						}					
+					if ( !_strcmpi("dark", test_string))	
+						{
+						pInfos[i].uSchool = SPELL_SCHOOL_DARK;
+						break;
+						}					
+
+					if ( !_strcmpi("magic", test_string))	
+						{
+						pInfos[i].uSchool = SPELL_SCHOOL_MAGIC;
+						break;
+						}								
+					break;
+				case 4:
+					pInfos[i].pShortName=RemoveQuotes(test_string);
+					break;
+				case 5:
+					pInfos[i].pDescription=RemoveQuotes(test_string);
+					break;
+				case 6:
+					pInfos[i].pBasicSkillDesc=RemoveQuotes(test_string);
+					break;
+				case 7:
+					pInfos[i].pExpertSkillDesc=RemoveQuotes(test_string);
+					break;
+				case 8:
+					pInfos[i].pMasterSkillDesc=RemoveQuotes(test_string);
+					break;
+				case 9:
+					pInfos[i].pGrandmasterSkillDesc=RemoveQuotes(test_string);
+					break;
+				case 10:
+					int in_string_pos=0;
+					unsigned char test;
+					int in_str_len=strlen(test_string);
+					for (int j=0; j<in_str_len; ++j)
+						{
+							test= tolower(test_string[j]);
+							switch (test)
+							{
+							case 109:
+								pSpellDatas[i].field_12|=1;
+								break;
+							case 101:
+								pSpellDatas[i].field_12|=2;
+								break;
+							case 99:
+								pSpellDatas[i].field_12|=4;
+								break;
+							case 120:
+								pSpellDatas[i].field_12|=8;
+								break;
+							}					
+						}
+					break;
+					}
+				}
+			else
+				break_loop=true;
+			++decode_step;
+			test_string=tmp_pos+1;	
+			} while ((decode_step<11)&&!break_loop);
+			if ((i%11)==0)
+				strtok(NULL, "\r");
+		}
+
+	}
\ No newline at end of file
--- a/Spells.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/Spells.h	Mon Feb 18 09:44:59 2013 +0600
@@ -33,6 +33,21 @@
 };
 
 
+enum SPELL_SCHOOL : int
+{
+  SPELL_SCHOOL_FIRE =  0,
+  SPELL_SCHOOL_AIR  =  1,
+  SPELL_SCHOOL_WATER = 2,
+  SPELL_SCHOOL_EARTH = 3,
+  SPELL_SCHOOL_NONE =  4,
+  SPELL_SCHOOL_MAGIC =  5,
+  SPELL_SCHOOL_SPIRIT = 6,
+  SPELL_SCHOOL_MIND   = 7,
+  SPELL_SCHOOL_BODY   = 8,
+  SPELL_SCHOOL_LIGHT   = 9,
+  SPELL_SCHOOL_DARK =  10
+};
+
 
 
 /*   68 */
@@ -74,7 +89,7 @@
   char *pExpertSkillDesc;
   char *pMasterSkillDesc;
   char *pGrandmasterSkillDesc;
-  unsigned int uSchool;
+  SPELL_SCHOOL uSchool;
   int field_20;
 };
 #pragma pack(pop)
@@ -120,9 +135,10 @@
   __int16 field_C;
   __int16 field_E;
   __int16 field_10;
-  char field_12;
-  char field_13;
-  __int16 field_14;
+  __int16 field_12;
+ // char field_12;
+ // char field_13;
+ // __int16 field_14;
 };
 #pragma pack(pop)
 
@@ -133,4 +149,4 @@
 
 
 extern stru324_spell stru_4E3ACC[];
-extern SpellData pSpellDatas[95];
\ No newline at end of file
+extern SpellData pSpellDatas[100];
\ No newline at end of file
--- a/Sprites.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/Sprites.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -11,8 +11,6 @@
 
 
 
-//extern int (__cdecl *sprintfex)(char *a1, const char *a2, ...);
-
 struct SpriteFrameTable *pSpriteFrameTable;
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/StorylineTextTable.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -0,0 +1,71 @@
+#include <stdlib.h>
+#include <string.h>
+
+#include "LOD.h"
+#include "allocator.h"
+#include "texts.h"
+#include "StorylineTextTable.h"
+
+char *pHistoryTXT_Raw;
+struct StorylineText *pStorylineText;  
+
+//----- (00453E6D) --------------------------------------------------------
+void StorylineText::Initialize()
+	{
+
+	int i;
+	char* test_string;
+	unsigned char c;
+	bool break_loop;
+	unsigned int temp_str_len;
+	char* tmp_pos;
+	int decode_step;
+
+	if ( pHistoryTXT_Raw )
+		pAllocator->FreeChunk(pHistoryTXT_Raw);
+	pHistoryTXT_Raw = NULL;
+	pHistoryTXT_Raw = (char *)pEvents_LOD->LoadRaw("history.txt", 0);
+	strtok(pHistoryTXT_Raw, "\r");
+
+	for (i=0;i<29;++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				switch (decode_step)
+					{
+				case 1: 
+					StoreLine[i+1].pText=RemoveQuotes(test_string);
+					break;
+				case 2:
+					StoreLine[i+1].uTime=atoi(test_string);  //strange but in text here string not digit
+					break;
+				case 3:
+					StoreLine[i+1].pPageTitle=RemoveQuotes(test_string);
+					break;
+					}
+				}
+			else
+				{ 
+				break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<4)&&!break_loop);
+		}
+	}
\ No newline at end of file
--- a/StorylineTextTable.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/StorylineTextTable.h	Mon Feb 18 09:44:59 2013 +0600
@@ -1,15 +1,27 @@
 #pragma once
 
-
+#pragma pack(push, 1)
+struct StorylineRecord
+{
+  char* pText; //0
+  char* pPageTitle; //4
+  unsigned __int8 uTime; //8
+  char f_9;
+  char f_A;
+  char f_B;
+};
+#pragma pack(pop)
 
-
-/*  173 */
+/*  173 */  
 #pragma pack(push, 1)
 struct StorylineText
 {
   void Initialize();
-
-  int field_0;
-  int field_4[87];
+  StorylineRecord StoreLine[30];
+  //int field_0;
+ // int field_4[87];
 };
 #pragma pack(pop)
+
+extern char *pHistoryTXT_Raw;
+extern struct StorylineText *pStorylineText;
\ No newline at end of file
--- a/VideoPlayer.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/VideoPlayer.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -334,7 +334,7 @@
 
 
 //----- (004BE70E) --------------------------------------------------------
-void __fastcall VideoPlayer::MovieLoop(const char *pMovieName, int a2, int ScreenSizeFlag, int uGameState)
+void __fastcall VideoPlayer::MovieLoop(const char *pMovieName, int a2, int ScreenSizeFlag, int a4)
 {
   int v4; // ebp@1
   const char *pName; // edi@1
@@ -418,7 +418,7 @@
         }
       }
     }
-    if ( uGameState == GAME_FINISHED )
+    if (a4 == 1)
       pCurrentScreen = SCREEN_GAME;
     pVideoPlayer->bPlayingMovie = 0;
     ShowCursor(1);
--- a/Viewport.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/Viewport.h	Mon Feb 18 09:44:59 2013 +0600
@@ -43,6 +43,12 @@
 #pragma pack(push, 1)
 struct ViewingParams
 {
+  inline ViewingParams()
+  {
+    draw_sw_outlines = false;
+    draw_d3d_outlines = false;
+  }
+
   int _443291();
   unsigned int _443343();
   int _443219();
@@ -76,8 +82,8 @@
   int bRedrawGameUI;
   int field_48;
   int field_4C;
-  int field_50_draw_debug_outlines;
-  int field_54;
+  int draw_sw_outlines;
+  int draw_d3d_outlines;
   int field_58;
   int field_5C;
   int field_60;
--- a/Vis.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/Vis.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -1,45 +1,54 @@
+#include <assert.h>
+
 #include "Vis.h"
 #include "Outdoor.h"
 #include "Game.h"
 #include "Actor.h"
 #include "IndoorCamera.h"
 #include "Viewport.h"
-#include "stru157.h"
+#include "Log.h"
 
 #include "mm7_data.h"
 //#include "MM7.h"
 
 
-static Vis_stru1 Vis_static_sub_4C1944_stru_F8BDE8;
+static Vis_SelectionList Vis_static_sub_4C1944_stru_F8BDE8;
+
+Vis_SelectionFilter vis_sprite_filter_1 = {VisObjectType_Sprite, OBJECT_Decoration,  0, 0,         2}; // 00F93E1C
+Vis_SelectionFilter vis_sprite_filter_2 = {VisObjectType_Sprite, OBJECT_Decoration,  0, 0,         2}; // 00F93E30
+Vis_SelectionFilter vis_face_filter     = {VisObjectType_Face,   OBJECT_Any,        -1, 0,         0}; // 00F93E44
+Vis_SelectionFilter vis_door_filter     = {VisObjectType_Face,   OBJECT_BLVDoor,    -1, 0x100000,  0}; // 00F93E58
+Vis_SelectionFilter vis_sprite_filter_3 = {VisObjectType_Sprite, OBJECT_Decoration, -1, 0,         4}; // 00F93E6C
+Vis_SelectionFilter vis_sprite_filter_4 = {VisObjectType_Any,    OBJECT_Item,       -1, 0,         0}; // static to sub_44EEA7
 
 
 
 //----- (004C1026) --------------------------------------------------------
-Vis_stru1_stru0 *Vis::_4C1026(BLVFace *a2, unsigned int a3, float a4)
+Vis_ObjectInfo *Vis::_4C1026(BLVFace *face, unsigned int a3, float pick_depth)
 {
   char *v4; // eax@4
   signed int v5; // ecx@4
-  BLVFace *v6; // ecx@7
-  unsigned int v7; // edi@7
+  //BLVFace *v6; // ecx@7
+  //unsigned int v7; // edi@7
   Vec3_short_ *v8; // eax@9
   char *v9; // edx@9
   signed int v10; // esi@10
-  Vec3_int_ **v11; // edx@13
-  char *v12; // eax@13
-  double v13; // st7@14
-  signed int v14; // ebx@14
-  Vis *v15; // ebx@15
-  Vis_stru1_stru0 *result; // eax@21
-  Vis_stru1_stru0 *v17; // ecx@24
+  //Vec3_int_ **v11; // edx@13
+  //char *v12; // eax@13
+  //double v13; // st7@14
+  //signed int v14; // ebx@14
+  //Vis *v15; // ebx@15
+  //Vis_ObjectInfo *result; // eax@21
+  //Vis_ObjectInfo *v17; // ecx@24
   RenderVertexSoft pRay[2]; // [sp+20h] [bp-70h]@17
   int v20; // [sp+84h] [bp-Ch]@10
-  int v21; // [sp+88h] [bp-8h]@16
-  int v22; // [sp+8Ch] [bp-4h]@16
+  //int v21; // [sp+88h] [bp-8h]@16
+  //int v22; // [sp+8Ch] [bp-4h]@16
   signed int v23; // [sp+98h] [bp+8h]@7
 
-  auto ecx0 = this;
+  //auto ecx0 = this;
 
-  static Vis_stru1 static_sub_4C1026_stru_F8FE00;
+  static Vis_SelectionList static_sub_4C1026_stru_F8FE00;
   static_sub_4C1026_stru_F8FE00.uNumPointers = 0;
 
   static bool _init_flag = false;
@@ -51,138 +60,150 @@
       static_sub_4C1026_array_F8F200[i].flt_2C = 0.0f;
   }
 
-  v6 = a2;
+  //v6 = a2;
   v23 = 0;
-  v7 = v6->uNumVertices;
-  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+  //v7 = face->uNumVertices;
+  if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
   {
-    if ( (signed int)v7 > 0 )
+    __debugbreak(); // refactor for BLV picking
+    if ( (signed int)face->uNumVertices > 0 )
     {
       v8 = pIndoor->pVertices;
       v9 = (char *)&static_sub_4C1026_array_F8F200[0].vWorldPosition.y;
       do
       {
         v10 = v23++;
-        v20 = v8[v6->pVertexIDs[v10]].x;
+        v20 = v8[face->pVertexIDs[v10]].x;
         *((float *)v9 - 1) = (double)v20;
-        v20 = v8[v6->pVertexIDs[v10]].y;
+        v20 = v8[face->pVertexIDs[v10]].y;
         *(float *)v9 = (double)v20;
         v9 += 48;
-        v20 = v8[v6->pVertexIDs[v10]].z;
+        v20 = v8[face->pVertexIDs[v10]].z;
         *((float *)v9 - 11) = (double)v20;
       }
-      while ( v23 < (signed int)v7 );
+      while ( v23 < (signed int)face->uNumVertices );
+    }
+  }
+  else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+  {
+    uint bmodel_id = a3 >> 9;
+    auto v = (Vec3_int_ *)pOutdoor->pBModels[bmodel_id].pVertices.pVertices;
+    for (uint i = 0; i < face->uNumVertices; ++i)
+    {
+      static_sub_4C1026_array_F8F200[i].vWorldPosition.x = v[face->pVertexIDs[i]].x;
+      static_sub_4C1026_array_F8F200[i].vWorldPosition.y = v[face->pVertexIDs[i]].y;
+      static_sub_4C1026_array_F8F200[i].vWorldPosition.z = v[face->pVertexIDs[i]].z;
     }
   }
-  else
-  {
-    if ( (signed int)v7 > 0 )
-    {
-      v11 = &pOutdoor->pBModels[a3 >> 9].pVertices.pVertices;
-      v12 = (char *)&static_sub_4C1026_array_F8F200[0].vWorldPosition.y;
-      do
-      {
-        *((float *)v12 - 1) = (double)(*v11)[v6->pVertexIDs[v23]].x;
-        v13 = (double)(*v11)[v6->pVertexIDs[v23]].y;
-        v14 = v23++;
-        *(float *)v12 = v13;
-        v12 += 48;
-        *((float *)v12 - 11) = (double)(*v11)[v6->pVertexIDs[v14]].z;
-      }
-      while ( v23 < (signed int)v7 );
-    }
-  }
-  pGame->pIndoorCameraD3D->ViewTransform(static_sub_4C1026_array_F8F200, v7);
-  pGame->pIndoorCameraD3D->Project(static_sub_4C1026_array_F8F200, v7, 1);
-  v15 = this;
-  SortVectors_x(static_sub_4C1026_array_F8F200, 0, v7 - 1);
-  if ( static_sub_4C1026_array_F8F200[0].vWorldViewPosition.x > (double)a4
-    || (_4C1495(static_sub_4C1026_array_F8F200, v7, (float *)&v21, (float *)&v22),
-        _4C12C3_FindSomeBillboard(static_sub_4C1026_array_F8F200, v7, *(float *)&v21, *(float *)&v22))
-    || ((CastPickRay(pRay, *(float *)&v21, *(float *)&v22, a4), uCurrentlyLoadedLevelType != LEVEL_Indoor) ? PickOutdoor(a4, pRay, &static_sub_4C1026_stru_F8FE00, &a5, 1) : PickIndoor(a4, pRay, &static_sub_4C1026_stru_F8FE00, &a5),
-        (static_sub_4C1026_stru_F8FE00.create_object_pointers(0),
-         sort_object_pointers(
-           static_sub_4C1026_stru_F8FE00.array_1804,
-           0,
-           static_sub_4C1026_stru_F8FE00.uNumPointers - 1),
-         !static_sub_4C1026_stru_F8FE00.uNumPointers)
-     || (result = static_sub_4C1026_stru_F8FE00.sub_4C2551(2, a3)) == 0
-     || (signed int)static_sub_4C1026_stru_F8FE00.uNumPointers > 1
-     && ((signed int)static_sub_4C1026_stru_F8FE00.uNumPointers <= 0 ? (v17 = 0) : (v17 = static_sub_4C1026_stru_F8FE00.array_1804[0]),
-         result != v17)) )
-    result = 0;
-  return result;
+  else assert(false);
+
+  pGame->pIndoorCameraD3D->ViewTransform(static_sub_4C1026_array_F8F200, face->uNumVertices);
+  pGame->pIndoorCameraD3D->Project(static_sub_4C1026_array_F8F200, face->uNumVertices, 1);
+
+  //v15 = this;
+  SortVectors_x(static_sub_4C1026_array_F8F200, 0, face->uNumVertices - 1);
+  if (static_sub_4C1026_array_F8F200[0].vWorldViewPosition.x > pick_depth)
+    return nullptr;
+
+  float screenspace_center_x,
+        screenspace_center_y;
+  GetPolygonScreenSpaceCenter(static_sub_4C1026_array_F8F200, face->uNumVertices, &screenspace_center_x, &screenspace_center_y);
+  if (IsPolygonOccludedByBillboard(static_sub_4C1026_array_F8F200, face->uNumVertices, screenspace_center_x, screenspace_center_y))
+    return nullptr;
+
+  CastPickRay(pRay, screenspace_center_x, screenspace_center_y, pick_depth);
+
+  if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+    PickOutdoorFaces_Mouse(pick_depth, pRay, &static_sub_4C1026_stru_F8FE00, &vis_face_filter, true);
+  else if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
+    PickIndoorFaces_Mouse(pick_depth, pRay, &static_sub_4C1026_stru_F8FE00, &vis_face_filter);
+  else assert(false);
+
+  static_sub_4C1026_stru_F8FE00.create_object_pointers();
+  sort_object_pointers(static_sub_4C1026_stru_F8FE00.object_pointers, 0, static_sub_4C1026_stru_F8FE00.uNumPointers - 1);
+  if (!static_sub_4C1026_stru_F8FE00.uNumPointers)
+    return nullptr;
+
+  if (!static_sub_4C1026_stru_F8FE00.sub_4C2551(2, a3))
+    return nullptr;
+
+  if (static_sub_4C1026_stru_F8FE00.uNumPointers)
+    return static_sub_4C1026_stru_F8FE00.object_pointers[0];
+  else return nullptr;
 }
 // F91E08: using guessed type char static_sub_4C1026_byte_F91E08__init_flags;
 
 //----- (004C12C3) --------------------------------------------------------
-char Vis::_4C12C3_FindSomeBillboard(RenderVertexSoft *a1, int a2, float a3, float a4)
+bool Vis::IsPolygonOccludedByBillboard(RenderVertexSoft *vertices, int num_vertices, float x, float y)
 {
-  signed int v5; // esi@1
-  RenderBillboardD3D *v6; // edi@2
-  double v7; // st7@9
-  int v8; // edx@9
-  RenderVertexSoft *v9; // ecx@10
-  char result; // al@24
-  Vis *thisa; // [sp+10h] [bp-8h]@1
-  float thisb; // [sp+10h] [bp-8h]@9
-  signed int v13; // [sp+14h] [bp-4h]@1
-  float a3a; // [sp+28h] [bp+10h]@9
-  float a4a; // [sp+2Ch] [bp+14h]@9
+  //signed int v5; // esi@1
+  //RenderBillboardD3D *v6; // edi@2
+  //double v7; // st7@9
+  //int v8; // edx@9
+  //RenderVertexSoft *v9; // ecx@10
+  //char result; // al@24
+  //Vis *thisa; // [sp+10h] [bp-8h]@1
+  //float thisb; // [sp+10h] [bp-8h]@9
+  //signed int v13; // [sp+14h] [bp-4h]@1
+  //float a3a; // [sp+28h] [bp+10h]@9
+  //float a4a; // [sp+2Ch] [bp+14h]@9
 
-  v13 = -1;
-  v5 = 0;
-  thisa = this;
-  if ( (signed int)pRenderer->uNumBillboardsToDraw <= 0 )
-  {
-    return 0;
-  }
-  v6 = pRenderer->pBillboardRenderListD3D;
-  do
-  {
-    if ( IsPointInsideD3DBillboard(v6, a3, a4)
-      && (v13 == -1
-	  || (unsigned int)pBillboardRenderList[v6->uParentBillboardID].sZValue < pBillboardRenderList[pRenderer->pBillboardRenderListD3D[v13].uParentBillboardID].sZValue) )
-      v13 = v5;
-    ++v5;
-    ++v6;
-  }
-  while ( v5 < (signed int)pRenderer->uNumBillboardsToDraw );
-  if ( v13 == -1 )
+  int v13 = -1;
+  //v5 = 0;
+  //thisa = this;
+
+  //v6 = pRenderer->pBillboardRenderListD3D;
+  for (uint i = 0; i < pRenderer->uNumBillboardsToDraw; ++i)
   {
-    return 0;
-  }
-  v7 = 3.4028235e38;
-  v8 = a2;
-  a4a = 3.4028235e38;
-  a3a = -3.4028235e38;
-  thisb = -3.4028235e38;
-  if ( a2 > 0 )
-  {
-    v9 = a1;
-    do
+    auto billboard = pRenderer->pBillboardRenderListD3D + i;
+    if (IsPointInsideD3DBillboard(billboard, x, y))
     {
-		if ( v9->vWorldViewProjX < v7 )
-			v7 = v9->vWorldViewProjX;
-		if ( v9->vWorldViewProjX > (double)a3a )
-        a3a = v9->vWorldViewProjX;
-		if ( v9->vWorldViewProjY < (double)a4a )
-        a4a = v9->vWorldViewProjY;
-      if ( v9->vWorldViewProjY > (double)thisb )
-        thisb = v9->vWorldViewProjY;
-      ++v9;
-      --v8;
+      if (v13 == -1)
+        v13 = i;
+      else  if ((unsigned int)pBillboardRenderList[billboard->uParentBillboardID].sZValue < pBillboardRenderList[pRenderer->pBillboardRenderListD3D[v13].uParentBillboardID].sZValue)
+        v13 = i;
     }
-    while ( v8 );
   }
-  if ( v7 < pRenderer->pBillboardRenderListD3D[v13].pQuards[0].pos.x
-    || pRenderer->pBillboardRenderListD3D[v13].pQuards[0].pos.y > (double)a4a
-    || pRenderer->pBillboardRenderListD3D[v13].pQuards[3].pos.x < (double)a3a
-    || pRenderer->pBillboardRenderListD3D[v13].pQuards[1].pos.y < (double)thisb )
-    result = 0;
-  else
-    result = 1;
-  return result;
+
+  if ( v13 == -1 )
+    return false;
+  
+  //v8 = num_vertices;
+  //v7 = 3.4028235e38;
+  float min_x = FLT_MAX;
+  //a4a = 3.4028235e38;
+  float min_y = FLT_MAX;
+  //a3a = -3.4028235e38;
+  float max_x = -FLT_MAX;
+  //thisb = -3.4028235e38;
+  float max_y = -FLT_MAX;
+  for (uint i = 0; i < num_vertices; ++i)
+  {
+    //v9 = a1;
+    //do
+    //{
+    auto v = vertices + i;
+
+    if (v->vWorldViewProjX < min_x)
+      min_x = v->vWorldViewProjX;
+    if (v->vWorldViewProjX > max_x)
+      max_x = v->vWorldViewProjX;
+
+    if (v->vWorldViewProjY < min_y)
+      min_y = v->vWorldViewProjY;
+    if (v->vWorldViewProjY > max_y)
+      max_y = v->vWorldViewProjY;
+      //++v9;
+      //--v8;
+    //}
+    //while ( v8 );
+  }
+
+  if (min_x < pRenderer->pBillboardRenderListD3D[v13].pQuards[0].pos.x || pRenderer->pBillboardRenderListD3D[v13].pQuards[0].pos.y > min_y ||
+      pRenderer->pBillboardRenderListD3D[v13].pQuards[3].pos.x < max_x || pRenderer->pBillboardRenderListD3D[v13].pQuards[1].pos.y < max_y)
+    return false;
+
+  return true;
 }
 
 //----- (004C1417) --------------------------------------------------------
@@ -200,81 +221,45 @@
 }
 
 //----- (004C1495) --------------------------------------------------------
-float *Vis::_4C1495(RenderVertexSoft *Src, int a2, float *a3, float *a4)
+void Vis::GetPolygonScreenSpaceCenter(RenderVertexSoft *vertices, int num_vertices, float *out_center_x, float *out_center_y)
 {
   char *v5; // eax@2
   signed int v6; // ecx@2
   float *result; // eax@5
-  Vis *thisa; // [sp+0h] [bp-4h]@1
 
-  thisa = this;
-
-  static bool static_sub_4C1495_byte_F8E9F8__init_flags = false; // weak
   static RenderVertexSoft static_sub_4C1495_array_F8DDF8[64];
-  if ( !static_sub_4C1495_byte_F8E9F8__init_flags )
-  {
-    static_sub_4C1495_byte_F8E9F8__init_flags = true;
 
-    for (uint i = 0; i < 64; ++i)
-      static_sub_4C1495_array_F8DDF8[i].flt_2C = 0.0f;
-  }
+  memcpy(static_sub_4C1495_array_F8DDF8, vertices, 48 * num_vertices);
 
-  memcpy(static_sub_4C1495_array_F8DDF8, Src, 48 * a2);
-  sort_objects_2(static_sub_4C1495_array_F8DDF8, 0, a2 - 1);
-  *a3 = (*(float *)&Vis_static_sub_4C1944_stru_F8BDE8.array_1804[12 * a2 + 509]
-       - static_sub_4C1495_array_F8DDF8[0].vWorldViewProjX)
-      * 0.5
-      + static_sub_4C1495_array_F8DDF8[0].vWorldViewProjX;
-  sort_objects_3(static_sub_4C1495_array_F8DDF8, 0, a2 - 1);
-  result = a4;
-  *a4 = (*(float *)&Vis_static_sub_4C1944_stru_F8BDE8.array_1804[12 * a2 + 510]
-       - static_sub_4C1495_array_F8DDF8[0].vWorldViewProjY)
-      * 0.5
-      + static_sub_4C1495_array_F8DDF8[0].vWorldViewProjY;
-  return result;
+  SortByScreenSpaceX(static_sub_4C1495_array_F8DDF8, 0, num_vertices - 1);
+  *out_center_x = (static_sub_4C1495_array_F8DDF8[num_vertices - 1].vWorldViewProjX - static_sub_4C1495_array_F8DDF8[0].vWorldViewProjX) * 0.5 + static_sub_4C1495_array_F8DDF8[0].vWorldViewProjX;
+
+  SortByScreenSpaceY(static_sub_4C1495_array_F8DDF8, 0, num_vertices - 1);
+  *out_center_y = (static_sub_4C1495_array_F8DDF8[num_vertices - 1].vWorldViewProjY - static_sub_4C1495_array_F8DDF8[0].vWorldViewProjY) * 0.5 + static_sub_4C1495_array_F8DDF8[0].vWorldViewProjY;
 }
 
 //----- (004C1542) --------------------------------------------------------
-void Vis::PickBillboards(float fPickDepth, float fX, float fY, Vis_stru1 *a4, stru157 *a2)
+void Vis::PickBillboards_Mouse(float fPickDepth, float fX, float fY, Vis_SelectionList *list, Vis_SelectionFilter *filter)
 {
-  int v6; // ST1C_4@6
-  Vis_stru1_stru0 *v7; // edi@6
-  Vis *thisa; // [sp+20h] [bp-Ch]@1
-  RenderBillboardD3D *v9; // [sp+24h] [bp-8h]@2
-  unsigned int uD3DBillboardIdx; // [sp+28h] [bp-4h]@1
-
-  uD3DBillboardIdx = 0;
-  thisa = this;
-  if ( (signed int)pRenderer->uNumBillboardsToDraw > 0 )
+  for (uint i = 0; i < pRenderer->uNumBillboardsToDraw; ++i)
   {
-    v9 = pRenderer->pBillboardRenderListD3D;//[0].uParentBillboardID;
-    do
+    auto d3d_billboard = pRenderer->pBillboardRenderListD3D + i;
+    if (is_part_of_selection((void *)i, filter) && IsPointInsideD3DBillboard(d3d_billboard, fX, fY))
     {
-      if ( is_part_of_selection((BLVFace *)uD3DBillboardIdx, a2)
-        && IsPointInsideD3DBillboard((RenderBillboardD3D *)(v9 - 38), fX, fY) )
+      if (DoesRayIntersectBillboard(fPickDepth, i))
       {
-        if ( DoesRayIntersectBillboard(fPickDepth, uD3DBillboardIdx) )
-        {
-          v6 = pBillboardRenderList[v9->uParentBillboardID].sZValue;
-          v7 = &a4->array_0004[a4->uNumPointers];
-		  v7->pObjectInfo = (void *)v9->uParentBillboardID;
-          v7 = (Vis_stru1_stru0 *)((char *)v7 + 4);
-          v7->pObjectInfo = (void *)v6;
-          v7->sZValue = 1;
-          ++a4->uNumPointers;
-        }
+        auto billboard = &pBillboardRenderList[d3d_billboard->uParentBillboardID];
+
+        list->AddObject((void *)d3d_billboard->uParentBillboardID, VisObjectType_Sprite, billboard->sZValue);
       }
-      ++uD3DBillboardIdx;
-      ++v9;
     }
-    while ( (signed int)uD3DBillboardIdx < (signed int)pRenderer->uNumBillboardsToDraw );
   }
 }
 
 //----- (004C1607) --------------------------------------------------------
 bool Vis::IsPointInsideD3DBillboard(RenderBillboardD3D *a1, float x, float y)
 {
-  RenderBillboardD3D *result; // eax@1
+  //RenderBillboardD3D *result; // eax@1
   double v5; // st7@2
   float v6; // ecx@2
   float v7; // ST00_4@3
@@ -302,27 +287,28 @@
   float v29; // [sp+8h] [bp-4h]@2
   float a1a; // [sp+14h] [bp+8h]@2
 
-  result = a1;
   if ( a1->uParentBillboardID == -1 )
-    goto LABEL_14;
+    return false;
+
+  //result = a1;
   v5 = a1->pQuards[0].pos.x;
   a1a = a1->pQuards[3].pos.x;
-  v6 = result->pQuards[0].pos.y;
-  result = (RenderBillboardD3D *)LODWORD(result->pQuards[1].pos.y);
+  v6 = a1->pQuards[0].pos.y;
+  //result = (RenderBillboardD3D *)LODWORD(result->pQuards[1].pos.y);
   v29 = v6;
-  LODWORD(v28) = (int)result;
+  v28 = a1->pQuards[1].pos.y;
   if ( v5 > a1a )
   {
     v7 = v5;
-    HIWORD(result) = HIWORD(v7);
+    //HIWORD(result) = HIWORD(v7);
     v5 = a1a;
     a1a = v7;
   }
   if ( v6 > (double)v28 )
   {
-    result = (RenderBillboardD3D *)LODWORD(v28);
+    //result = (RenderBillboardD3D *)LODWORD(v28);
     v28 = v6;
-    LODWORD(v29) = (int)result;
+    v29 = v28;
   }
   v9 = x + 1.0;
   //UNDEF(v8);
@@ -330,19 +316,17 @@
   //v11 = 0;
   //v12 = v9 == v5;
   //BYTE1(result) = HIBYTE(v8);//crash
-  if ( v9 >= v5
-    && (v14 = x - 1.0, v14<=a1a)///*UNDEF(v13),*/ v15 = v14 < a1a, v16 = 0, v17 = v14 == a1a, BYTE1(result) = HIBYTE(v13), v15 | v17)
-    && (v19 = y + 1.0, v19>=v29)///*UNDEF(v18),*/ v20 = v19 < v29, v21 = 0, v22 = v19 == v29, BYTE1(result) = HIBYTE(v18), v19 >= v29)
-    && (v24 = y - 1.0, v24<=v28))///*UNDEF(v23),*/ v25 = v24 < v28, v26 = 0, v27 = v24 == v28, BYTE1(result) = HIBYTE(v23), v25 | v27) )
-    LOBYTE(result) = 1;
+  if (v9 >= v5 &&
+      (v14 = x - 1.0, v14<=a1a) &&///*UNDEF(v13),*/ v15 = v14 < a1a, v16 = 0, v17 = v14 == a1a, BYTE1(result) = HIBYTE(v13), v15 | v17)
+      (v19 = y + 1.0, v19>=v29) &&///*UNDEF(v18),*/ v20 = v19 < v29, v21 = 0, v22 = v19 == v29, BYTE1(result) = HIBYTE(v18), v19 >= v29)
+      (v24 = y - 1.0, v24<=v28))///*UNDEF(v23),*/ v25 = v24 < v28, v26 = 0, v27 = v24 == v28, BYTE1(result) = HIBYTE(v23), v25 | v27) )
+    return true;
   else
-LABEL_14:
-    LOBYTE(result) = 0;
-  return (bool)result;
+    return false;
 }
 
 //----- (004C16B4) --------------------------------------------------------
-void Vis::PickIndoor(float fDepth, RenderVertexSoft *pRay, Vis_stru1 *a4, stru157 *a5)
+void Vis::PickIndoorFaces_Mouse(float fDepth, RenderVertexSoft *pRay, Vis_SelectionList *list, Vis_SelectionFilter *filter)
 {
   int v5; // eax@1
   signed int v6; // edi@2
@@ -351,7 +335,7 @@
   int v9; // eax@7
   unsigned int *pNumPointers; // eax@7
   unsigned int v11; // ecx@7
-  Vis_stru1_stru0 *v12; // edi@7
+  Vis_ObjectInfo *v12; // edi@7
   RenderVertexSoft a1; // [sp+Ch] [bp-44h]@1
   BLVFace *v14; // [sp+3Ch] [bp-14h]@7
   void *v15; // [sp+40h] [bp-10h]@7
@@ -359,6 +343,8 @@
   int v17; // [sp+48h] [bp-8h]@1
   Vis *thisa; // [sp+4Ch] [bp-4h]@1
 
+  __debugbreak(); // refactor for BLV picking
+
   v5 = 0;
   thisa = this;
   v17 = 0;
@@ -370,7 +356,7 @@
       if ( v6 < (signed int)pIndoor->uNumFaces )
       {
         v7 = v6;
-        if ( is_part_of_selection(&pIndoor->pFaces[v6], a5) )
+        if ( is_part_of_selection(&pIndoor->pFaces[v6], filter) )
         {
           if ( !pGame->pIndoorCameraD3D->IsCulled(&pIndoor->pFaces[v7]) )
           {
@@ -380,14 +366,14 @@
               v9 = _48B561_mess_with_scaling_along_z(/*v8, */a1.vWorldViewPosition.x);
               LOWORD(v9) = 0;
               v15 = (void *)((8 * v6 | 6) + v9);
-              pNumPointers = &a4->uNumPointers;
+              pNumPointers = &list->uNumPointers;
               v16 = 2;
-              v11 = a4->uNumPointers;
+              v11 = list->uNumPointers;
               v14 = &pIndoor->pFaces[v7];
-              v12 = &a4->array_0004[v11];
-              v12->pObjectInfo = &pIndoor->pFaces[v7];
-              v12 = (Vis_stru1_stru0 *)((char *)v12 + 4);
-              v12->pObjectInfo = v15;
+              v12 = &list->object_pool[v11];
+              v12->object = &pIndoor->pFaces[v7];
+              v12 = (Vis_ObjectInfo *)((char *)v12 + 4);
+              v12->object = v15;
               v12->sZValue = v16;
               ++*pNumPointers;
             }
@@ -400,99 +386,40 @@
 }
 
 //----- (004C17CF) --------------------------------------------------------
-void Vis::PickOutdoor(float fDepth, RenderVertexSoft *pRay, Vis_stru1 *a4, stru157 *a5, char a6)
-{
-  int v6; // esi@1
-  unsigned int v7; // ecx@1
-  BSPModel *v8; // ebx@3
-  bool v9; // eax@3
-  int v10; // eax@8
-  ODMFace *v11; // esi@10
-  int v12; // ecx@12
-  int v13; // eax@12
-  unsigned int *pNumPointers; // eax@12
-  Vis_stru1_stru0 *v15; // edi@12
-  BLVFace thisa; // [sp+10h] [bp-B8h]@1
-  RenderVertexSoft a1; // [sp+70h] [bp-58h]@1
-  void *v18; // [sp+A0h] [bp-28h]@12
-  void *v19; // [sp+A4h] [bp-24h]@12
-  int v20; // [sp+A8h] [bp-20h]@12
-  int v21; // [sp+ACh] [bp-1Ch]@8
-  Vis *v22; // [sp+B0h] [bp-18h]@1
-  int v23; // [sp+B4h] [bp-14h]@9
-  int v24; // [sp+B8h] [bp-10h]@1
-  unsigned int v25; // [sp+BCh] [bp-Ch]@2
-  unsigned int v26; // [sp+C0h] [bp-8h]@1
-  int v27; // [sp+C4h] [bp-4h]@8
-
-  v22 = this;
-  v6 = 0;
-  v7 = 0;
-  v24 = 0;
-  v26 = 0;
-  a1.flt_2C = 0.0;
+void Vis::PickOutdoorFaces_Mouse(float fDepth, RenderVertexSoft *pRay, Vis_SelectionList *list, Vis_SelectionFilter *filter, bool one_sided)
+{  
   if (!pOutdoor)
     return;
-  if ( (signed int)pOutdoor->uNumBModels > 0 )
+
+  for (uint i = 0; i < pOutdoor->uNumBModels; ++i)
   {
-    v25 = 0;
-    do
+    int v24;
+    if (!IsBModelVisible(i, &v24))
+      continue;
+    if (one_sided && !v24)
+      continue;
+
+    auto bmodel = &pOutdoor->pBModels[i];
+
+    for (uint j = 0; j < bmodel->uNumFaces; ++j)
     {
-      v8 = &pOutdoor->pBModels[v25 / 0xBC];
-      v9 = IsBModelVisible(v7, &v24);
-      if ( a6 )
+      auto face = bmodel->pFaces + j;
+      if (is_part_of_selection(face, filter))
       {
-        if ( v9 && v24 != v6 )
+        BLVFace blv_face;
+        blv_face.FromODM(face);
+        
+        RenderVertexSoft intersection;
+        if (Intersect_Ray_Face(pRay, pRay + 1, &fDepth, &intersection, &blv_face, i))
         {
-LABEL_8:
-          v10 = v8->uNumFaces;
-          v27 = v6;
-          v21 = v10;
-          if ( v10 > v6 )
-          {
-            v23 = v6;
-            do
-            {
-              v11 = (ODMFace *)((char *)v8->pFaces + v23);
-              if ( is_part_of_selection((BLVFace *)((char *)v8->pFaces + v23), a5) )
-              {
-                thisa.FromODM(v11);
-                if ( Intersect_Ray_Face(pRay, pRay + 1, &fDepth, &a1, &thisa, v26) )
-                {
-                  pGame->pIndoorCameraD3D->ViewTransform(&a1, 1u);
-                  v18 = v11;
-                  v13 = _48B561_mess_with_scaling_along_z(/*v12, */a1.vWorldViewPosition.x);
-                  LOWORD(v13) = 0;
-                  v20 = 2;
-                  v19 = (void *)((8 * (v27 | (v26 << 6)) | 6) + v13);
-                  pNumPointers = &a4->uNumPointers;
-                  v15 = &a4->array_0004[a4->uNumPointers];
-                  v15->pObjectInfo = v18;
-                  v15 = (Vis_stru1_stru0 *)((char *)v15 + 4);
-                  v15->pObjectInfo = v19;
-                  v15->sZValue = v20;
-                  ++*pNumPointers;
-                }
-              }
-              ++v27;
-              v23 += 308;
-            }
-            while ( v27 < v21 );
-            v6 = 0;
-          }
-          goto LABEL_15;
+          pGame->pIndoorCameraD3D->ViewTransform(&intersection, 1u);
+          int v13 = _48B561_mess_with_scaling_along_z(/*v12, */intersection.vWorldViewPosition.x);
+          LOWORD(v13) = (8 * (j | (i << 6)) | OBJECT_BModel) + v13;
+
+          list->AddObject(face, VisObjectType_Face, v13);
         }
       }
-      else
-      {
-        if ( v9 )
-          goto LABEL_8;
-      }
-LABEL_15:
-      v25 += 188;
-      v7 = v26++ + 1;
     }
-    while ( (signed int)v26 < (signed int)pOutdoor->uNumBModels );
   }
 }
 
@@ -501,39 +428,38 @@
 //{return DoesRayIntersectBillboard(fDepth, uD3DBillboardIdx);}
 
 //----- (004C1944) --------------------------------------------------------
-int Vis::_4C1944(int a2, unsigned int a3, int a4, int a5, int a6)
+int Vis::_4C1944(int object_id, unsigned int a3, int a4, int a5, int a6)
 {
   float v6; // ST00_4@3
   int result; // eax@4
-  stru157 v8; // [sp+18h] [bp-20h]@3
+  Vis_SelectionFilter v8; // [sp+18h] [bp-20h]@3
   __int64 v9; // [sp+2Ch] [bp-Ch]@3
   Vis *v14; // [sp+34h] [bp-4h]@1
 
   v14 = this;
 
-  static Vis_stru1 Vis_static_sub_4C1944_stru_F8BDE8;
+  static Vis_SelectionList Vis_static_sub_4C1944_stru_F8BDE8;
 
-  v8.field_4 = a2;
+  v8.object_id = object_id;
   v8.field_8 = a6;
   v8.field_C = a5;
   v8.field_10 = a4;
   v9 = a3;
   Vis_static_sub_4C1944_stru_F8BDE8.uNumPointers = 0;
   v6 = (double)a3;
-  v8.field_0 = 1;
-  _4C06F8(v6, &Vis_static_sub_4C1944_stru_F8BDE8, &v8);
-  Vis_static_sub_4C1944_stru_F8BDE8.create_object_pointers(1u);
+  v8.object_type = VisObjectType_Sprite;
+  PickBillboards_Keyboard(v6, &Vis_static_sub_4C1944_stru_F8BDE8, &v8);
+  Vis_static_sub_4C1944_stru_F8BDE8.create_object_pointers(Vis_SelectionList::Unique);
   sort_object_pointers(
-    Vis_static_sub_4C1944_stru_F8BDE8.array_1804,
+    Vis_static_sub_4C1944_stru_F8BDE8.object_pointers,
     0,
     Vis_static_sub_4C1944_stru_F8BDE8.uNumPointers - 1);
   if ( (signed int)Vis_static_sub_4C1944_stru_F8BDE8.uNumPointers <= 0 )
     result = -1;
   else
-    result = Vis_static_sub_4C1944_stru_F8BDE8.array_1804[0]->sZValue;
+    result = Vis_static_sub_4C1944_stru_F8BDE8.object_pointers[0]->sZValue;
   return result;
 }
-// F8DDF0: using guessed type char Vis_static_sub_4C1944_byte_F8DDF0_init;
 
 //----- (004C1A02) --------------------------------------------------------
 void Vis::_4C1A02()
@@ -626,39 +552,27 @@
 }
 
 //----- (004C1BAA) --------------------------------------------------------
-int Vis::get_object_zbuf_val(Vis_stru1_stru0 *a2)
+int Vis::get_object_zbuf_val(Vis_ObjectInfo *info)
 {
-  unsigned int v2; // eax@1
-  int result; // eax@3
-  std::string v4; // [sp-18h] [bp-1Ch]@4
-  const char *v5; // [sp-8h] [bp-Ch]@4
-  int v6; // [sp-4h] [bp-8h]@4
-  Vis *v7; // [sp+0h] [bp-4h]@1
+  switch (info->object_type)
+  {
+    case VisObjectType_Sprite:
+    case VisObjectType_Face:
+      return info->sZValue;
 
-  v7 = this;
-  v2 = a2->uObjectType;
-  if ( (signed int)v2 <= 0 || (signed int)v2 > 2 )
-  {
-    MessageBoxW(nullptr, L"Undefined type requested for: CVis::get_object_zbuf_val()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Vis.cpp:1037", 0);
-    result = -1;
+    default:
+      MessageBoxW(nullptr, L"Undefined type requested for: CVis::get_object_zbuf_val()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Vis.cpp:1037", 0);
+      return -1;
   }
-  else
-  {
-    result = a2->sZValue;
-  }
-  return result;
 }
 
 //----- (004C1BF1) --------------------------------------------------------
 int Vis::get_picked_object_zbuf_val()
 {
-  int result; // eax@2
+  if (!default_list.uNumPointers)
+    return -1;
 
-  if ( (signed int)this->stru1.uNumPointers <= 0 )
-    result = -1;
-  else
-    result = get_object_zbuf_val(this->stru1.array_1804[0]);
-  return result;
+  return get_object_zbuf_val(default_list.object_pointers[0]);
 }
 
 //----- (004C1C0C) --------------------------------------------------------
@@ -1126,12 +1040,12 @@
 }
 
 //----- (004C2551) --------------------------------------------------------
-Vis_stru1_stru0 *Vis_stru1::sub_4C2551(int a2, int a3)
+Vis_ObjectInfo *Vis_SelectionList::sub_4C2551(int a2, int a3)
 {
   unsigned int v3; // esi@1
   signed int v4; // edx@1
   char *v5; // eax@2
-  Vis_stru1_stru0 *result; // eax@6
+  Vis_ObjectInfo *result; // eax@6
 
   v3 = this->uNumPointers;
   v4 = 0;
@@ -1142,7 +1056,7 @@
   }
   else
   {
-    v5 = (char *)&this->array_0004[0].sZValue;
+    v5 = (char *)&this->object_pool[0].sZValue;
     while ( *((int *)v5 + 1) != a2 || (*(int *)v5 & 0xFFFF) != a3 )
     {
       ++v4;
@@ -1150,92 +1064,51 @@
       if ( v4 >= (signed int)v3 )
         goto LABEL_6;
     }
-    result = &this->array_0004[v4];
+    result = &this->object_pool[v4];
   }
   return result;
 }
 
 //----- (004C2591) --------------------------------------------------------
-Vis_stru1_stru0 **Vis_stru1::create_object_pointers(unsigned int flag)
+void Vis_SelectionList::create_object_pointers(PointerCreationType type)
 {
-  Vis_stru1_stru0 **result; // eax@1
-  signed int v3; // esi@2
-  Vis_stru1_stru0 *v4; // edx@3
-  unsigned __int8 v5; // zf@7
-  unsigned __int8 v6; // sf@7
-  Vis_stru1_stru0 **v7; // ebx@8
-  Vis_stru1_stru0 *v8; // esi@8
-  signed int v9; // edi@9
-  Vis_stru1_stru0 **v10; // edx@10
-  std::string v11; // [sp-18h] [bp-28h]@19
-  const char *v12; // [sp-8h] [bp-18h]@19
-  int v13; // [sp-4h] [bp-14h]@19
-  char v14; // [sp+Ch] [bp-4h]@19
+  switch (type)
+  {
+    case All:
+    {
+      for (uint i = 0; i < uNumPointers; ++i)
+        object_pointers[i] = &object_pool[i];
+    }
+    break;
 
-  result = 0;
-  if ( flag )
-  {
-    if ( flag == 1 )
-    {
-      v5 = this->uNumPointers == 0;
-      v6 = (this->uNumPointers & 0x80000000u) != 0;
-      BYTE3(flag) = 1;
-      if ( !(v6 | v5) )
+    case Unique: // seems quite retarted; the inner if condition will never trigger, since we compare pointers, not values. pointers will always be unique
+    {            // but it may be decompilation error thou
+      bool create = true;
+ 
+      for (uint i = 0; i < uNumPointers; ++i)
       {
-        v7 = this->array_1804;
-        v8 = this->array_0004;
-        do
+        for (uint j = 0; j < i; ++j)
         {
-          v9 = 0;
-          if ( (signed int)result > 0 )
+          if (object_pointers[j] == &object_pool[i])
           {
-            v10 = this->array_1804;
-            while ( *v10 != v8 )
-            {
-              ++v9;
-              ++v10;
-              if ( v9 >= (signed int)result )
-                goto LABEL_15;
-            }
-            BYTE3(flag) = 0;
+            create = false;
+            break;
           }
-LABEL_15:
-          if ( BYTE3(flag) )
-            *v7 = v8;
-          result = (Vis_stru1_stru0 **)((char *)result + 1);
-          ++v7;
-          ++v8;
         }
-        while ( (signed int)result < (signed int)this->uNumPointers );
+
+        if (create)
+          object_pointers[i] = &object_pool[i];
       }
     }
-    else
-    {
+    break;
+
+    default:
       MessageBoxW(nullptr, L"Unknown pointer creation flag passed to ::create_object_pointers()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Vis.cpp:1358", 0);
-    }
   }
-  else
-  {
-    v3 = 0;
-    if ( (signed int)this->uNumPointers > 0 )
-    {
-      result = this->array_1804;
-      v4 = this->array_0004;
-      do
-      {
-        *result = v4;
-        ++v3;
-        ++result;
-        ++v4;
-      }
-      while ( v3 < (signed int)this->uNumPointers );
-    }
-  }
-  return result;
 }
 
 //----- (004C264A) --------------------------------------------------------
-void Vis::sort_object_pointers(Vis_stru1_stru0 **pPointers, int left, int right)
+void Vis::sort_object_pointers(Vis_ObjectInfo **pPointers, int left, int right)
 {
   int v4; // edx@1
   int v5; // ebx@1
@@ -1244,9 +1117,9 @@
   int v8; // eax@3
   int v9; // ebx@4
   int v10; // ebx@6
-  Vis_stru1_stru0 *v11; // eax@7
+  Vis_ObjectInfo *v11; // eax@7
   Vis *thisa; // [sp+4h] [bp-4h]@1
-  Vis_stru1_stru0 *a3a; // [sp+14h] [bp+Ch]@2
+  Vis_ObjectInfo *a3a; // [sp+14h] [bp+Ch]@2
 
   v4 = left;
   v5 = right;
@@ -1410,15 +1283,14 @@
     memcpy(&v12, &v5[v8], sizeof(v12));
     memcpy(&v5[v8], v15, sizeof(v5[v8]));
     memcpy(v15, &v12, 0x20u);
-    //__debugbreak();
-    SortVerticesByX(v5, uStart, v8 - 1);
-    SortVerticesByX(a2, v8 + 1, uEnd);
+    SortVerticesByY(v5, uStart, v8 - 1);
+    SortVerticesByY(a2, v8 + 1, uEnd);
   }
   return true;
 }
 
 //----- (004C288E) --------------------------------------------------------
-bool Vis::sort_objects_2(RenderVertexSoft *pArray, int sLeft, int sRight)
+bool Vis::SortByScreenSpaceX(RenderVertexSoft *pArray, int sLeft, int sRight)
 {
   bool result; // eax@1
   RenderVertexSoft *v5; // edx@2
@@ -1433,11 +1305,11 @@
   //float v13; // [sp+4Ch] [bp-24h]@4
   int v14; // [sp+64h] [bp-Ch]@7
   //Vis *thisa; // [sp+68h] [bp-8h]@1
-  void *thisa;
+  //void *thisa;
   //RenderVertexSoft *v16; // [sp+6Ch] [bp-4h]@2
   const void *v16;
 
-  thisa = this;
+  //thisa = this;
   if (sRight <= sLeft)
     return true;
   v5 = pArray;
@@ -1472,13 +1344,13 @@
   memcpy(&v11, &v5[v6], sizeof(v11));
   memcpy(&v5[v6], v16, sizeof(v5[v6]));
   memcpy((void *)v16, &v11, sizeof(0x30u));
-  sort_objects_2(v5, sLeft, v6 - 1);
-  sort_objects_2(pArray, v6 + 1, sRight);
+  SortByScreenSpaceX(v5, sLeft, v6 - 1);
+  SortByScreenSpaceX(pArray, v6 + 1, sRight);
   return true;
 }
 
 //----- (004C297E) --------------------------------------------------------
-bool Vis::sort_objects_3(RenderVertexSoft *pArray, int sLeft, int sRight)
+bool Vis::SortByScreenSpaceY(RenderVertexSoft *pArray, int sLeft, int sRight)
 {
   //bool result; // eax@1
   RenderVertexSoft *v5; // edx@2
@@ -1530,8 +1402,8 @@
   memcpy(&v11, &v5[v6], sizeof(0x30));
   memcpy(&v5[v6], v16, sizeof(v5[v6]));
   memcpy((void *)v16, &v11, sizeof(0x30));
-  sort_objects_3(v5, sLeft, v6 - 1);
-  sort_objects_3(pArray, v6 + 1, sRight);
+  SortByScreenSpaceY(v5, sLeft, v6 - 1);
+  SortByScreenSpaceY(pArray, v6 + 1, sRight);
   return true;
 }
 
@@ -1539,12 +1411,9 @@
 //----- (004C04AF) --------------------------------------------------------
 Vis::Vis()
 {
-  Vis *v1; // ebx@1
-  Vis *result; // eax@1
   RenderVertexSoft v3; // [sp+Ch] [bp-60h]@1
   RenderVertexSoft v4; // [sp+3Ch] [bp-30h]@1
 
-  v1 = this;
   v3.flt_2C = 0.0;
   v3.vWorldPosition.x = 0.0;
   v3.vWorldPosition.y = 65536.0;
@@ -1553,205 +1422,202 @@
   v4.vWorldPosition.x = 65536.0;
   v4.vWorldPosition.y = 0.0;
   v4.vWorldPosition.z = 0.0;
-  memcpy(&v1->stru_200C, &v4, sizeof(v1->stru_200C));
+  memcpy(&stru_200C, &v4, sizeof(stru_200C));
+
   v4.flt_2C = 0.0;
   v4.vWorldPosition.x = 0.0;
   v4.vWorldPosition.y = 65536.0;
   v4.vWorldPosition.z = 0.0;
-  memcpy(&v1->stru_203C, &v3, sizeof(v1->stru_203C));
+  memcpy(&stru_203C, &v3, sizeof(stru_203C));
+
   v3.flt_2C = 0.0;
   v3.vWorldPosition.x = 65536.0;
   v3.vWorldPosition.y = 0.0;
   v3.vWorldPosition.z = 0.0;
-  memcpy(&v1->stru_206C, &v3, sizeof(v1->stru_206C));
-  result = v1;
-  memcpy(&v1->stru_209C, &v4, sizeof(v1->stru_209C));
-  v1->field_20CC = 512;
+  memcpy(&stru_206C, &v3, sizeof(stru_206C));
+  memcpy(&stru_209C, &v4, sizeof(stru_209C));
+
+  keyboard_pick_depth = 512;
 }
 
 //----- (004C055C) --------------------------------------------------------
-Vis_stru1::Vis_stru1()
+Vis_SelectionList::Vis_SelectionList()
 {
   for (uint i = 0; i < 512; ++i)
   {
-    array_0004[i].pObjectInfo = 0;
-    array_0004[i].sZValue = -1;
-    array_0004[i].uObjectType = 0;
+    object_pool[i].object = nullptr;
+    object_pool[i].sZValue = -1;
+    object_pool[i].object_type = VisObjectType_Any;
   }
   uNumPointers = 0;
 }
 
-
-
-
 //----- (004C05CC) --------------------------------------------------------
-bool Vis::PickKeyboard(Vis_stru1 *a2, stru157 *a3, stru157 *a4)
+bool Vis::PickKeyboard(Vis_SelectionList *list, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter)
 {
-  Vis_stru1 *v4; // esi@1
-  Vis *v5; // ebx@1
-  char *v6; // edi@3
-  float v7; // ST00_4@3
-  bool result; // eax@6
-  float v9; // [sp+4h] [bp-14h]@3
+  if (!list)
+    list = &default_list;
+  list->uNumPointers = 0;
 
-  v4 = a2;
-  v5 = this;
-  if ( !a2 )
-    v4 = &this->stru1;
-  v4->uNumPointers = 0;
-  v6 = (char *)&this->field_20CC;
-  v7 = (double)this->field_20CC;
-  _4C06F8(v7, v4, a3);
-  v9 = (double)*(signed int *)v6;
-  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-    _4C0D32_BLV(v9, v4, a4);
+  PickBillboards_Keyboard(keyboard_pick_depth, list, sprite_filter);
+  if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
+    PickIndoorFaces_Keyboard(keyboard_pick_depth, list, face_filter);
+  else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+    PickOutdoorFaces_Keyboard(keyboard_pick_depth, list, face_filter);
   else
-    _4C0DEA_ODM(v9, v4, a4);
-  v4->create_object_pointers(1u);
-  sort_object_pointers(v4->array_1804, 0, v4->uNumPointers - 1);
+    assert(false);
+
+  list->create_object_pointers(Vis_SelectionList::Unique);
+  sort_object_pointers(list->object_pointers, 0, list->uNumPointers - 1);
+
   return true;
 }
 
 //----- (004C0646) --------------------------------------------------------
-bool Vis::PickMouse(float fDepth, float fMouseX, float fMouseY, stru157 *a5, stru157 *a6)
+bool Vis::PickMouse(float fDepth, float fMouseX, float fMouseY, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter)
 {
   RenderVertexSoft pMouseRay[2]; // [sp+1Ch] [bp-60h]@1
 
-  stru1.uNumPointers = 0;
+  default_list.uNumPointers = 0;
   CastPickRay(pMouseRay, fMouseX, fMouseY, fDepth);
-  //PickBillboards(fDepth, fMouseX, fMouseY, &stru1, a5);//Ritor1: do comment to test
+  PickBillboards_Mouse(fDepth, fMouseX, fMouseY, &default_list, sprite_filter);
   if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
-    PickIndoor(fDepth, pMouseRay, &stru1, a6);
+    PickIndoorFaces_Mouse(fDepth, pMouseRay, &default_list, face_filter);
+  else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+    PickOutdoorFaces_Mouse(fDepth, pMouseRay, &default_list, face_filter, false);
   else
-    PickOutdoor(fDepth, pMouseRay, &stru1, a6, 0);
-  stru1.create_object_pointers(0);
-  sort_object_pointers(stru1.array_1804, 0, stru1.uNumPointers - 1);
+  {
+    Log::Warning(L"Picking mouse in undefined level"); // picking in main menu is default (buggy) game behavious. should've returned false in Game::PickMouse
+    return false;
+  }
+  default_list.create_object_pointers(Vis_SelectionList::All);
+  sort_object_pointers(default_list.object_pointers, 0, default_list.uNumPointers - 1);
+
   return true;
 }
 
 //----- (004C06F8) --------------------------------------------------------
-void Vis::_4C06F8(float arg0, Vis_stru1 *a3, stru157 *a2)
+void Vis::PickBillboards_Keyboard(float pick_depth, Vis_SelectionList *list, Vis_SelectionFilter *filter)
 {
-  int v4; // ST18_4@5
-  Vis_stru1_stru0 *v5; // edi@5
-  void **v7; // [sp+24h] [bp-8h]@2
-  unsigned int uD3DBillboardIdx; // [sp+28h] [bp-4h]@1
+  for (int i = 0; i < pRenderer->uNumBillboardsToDraw; ++i)
+  {
+    auto d3d_billboard = &pRenderer->pBillboardRenderListD3D[i];
 
-  uD3DBillboardIdx = 0;
-  auto ecx0 = this;
-  if ( (signed int)pRenderer->uNumBillboardsToDraw > 0 )
-  {
-    v7 = (void **)&pRenderer->pBillboardRenderListD3D[0].uParentBillboardID;
-    do
+    if (is_part_of_selection((void *)i, filter))
     {
-      if ( is_part_of_selection((BLVFace *)uD3DBillboardIdx, a2) )
+      if (DoesRayIntersectBillboard(pick_depth, i))
       {
-        if ( DoesRayIntersectBillboard(arg0, uD3DBillboardIdx) )
-        {
-          v4 = pBillboardRenderList[(int)*v7].sZValue;
-          v5 = &a3->array_0004[a3->uNumPointers];
-          v5->pObjectInfo = *v7;
-          v5 = (Vis_stru1_stru0 *)((char *)v5 + 4);
-          v5->pObjectInfo = (void *)v4;
-          v5->sZValue = 1;
-          ++a3->uNumPointers;
-        }
+        auto billboard = &pBillboardRenderList[d3d_billboard->uParentBillboardID];
+
+        list->AddObject((void *)d3d_billboard->uParentBillboardID, VisObjectType_Sprite, billboard->sZValue);
       }
-      ++uD3DBillboardIdx;
-      v7 += 39;
     }
-    while ( (signed int)uD3DBillboardIdx < (signed int)pRenderer->uNumBillboardsToDraw );
   }
 }
 
+
+// tests the object against selection filter to determine whether it can be picked or not
 //----- (004C0791) --------------------------------------------------------
-bool Vis::is_part_of_selection(BLVFace *uD3DBillboardIdx_or_pBLVFace_or_pODMFace, stru157 *a2)
+bool Vis::is_part_of_selection(void *uD3DBillboardIdx_or_pBLVFace_or_pODMFace, Vis_SelectionFilter *filter)
 {
-  stru157 *v3; // esi@1
-  int result; // eax@1
+  //stru157 *v3; // esi@1
+  //int result; // eax@1
   int v5; // edx@2
-  int v6; // ecx@2
-  char v7; // zf@3
+  //int v6; // ecx@2
+  //char v7; // zf@3
   int v8; // esi@5
   std::string *v9; // ecx@7
   Actor *v10; // edi@18
-  char v11; // zf@26
-  const char *v12; // [sp-20h] [bp-2Ch]@7
+  //const char *v12; // [sp-20h] [bp-2Ch]@7
   int v13; // [sp-1Ch] [bp-28h]@7
-  std::string v14; // [sp-18h] [bp-24h]@7
-  const char *v15; // [sp-8h] [bp-14h]@7
+  //std::string v14; // [sp-18h] [bp-24h]@7
+  //const char *v15; // [sp-8h] [bp-14h]@7
   int v16; // [sp-4h] [bp-10h]@7
 
-  v3 = a2;
-  result = a2->field_0;
-  if ( a2->field_0 != 1 )
+  switch (filter->object_type)
   {
-    if ( result != 2
-      || (uCurrentlyLoadedLevelType != LEVEL_Indoor ? (v11 = LOWORD(uD3DBillboardIdx_or_pBLVFace_or_pODMFace[3].pFacePlane.vNormal.y) == 0,
-                                            result = uD3DBillboardIdx_or_pBLVFace_or_pODMFace->pFacePlane_old.dist) : (v11 = pIndoor->pFaceExtras[uD3DBillboardIdx_or_pBLVFace_or_pODMFace->uFaceExtraID].uEventID == 0, result = uD3DBillboardIdx_or_pBLVFace_or_pODMFace->uAttributes),
-          a2->field_4 != 1) )
-      goto LABEL_16;
-    if ( v11 || result & a2->field_C )
-      goto LABEL_33;
-    v7 = (result & a2->field_8) == 0;
-    goto LABEL_32;
-  }
-  v5 = a2->field_10;
-  result = (pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].sZValue & 0xFFFF) >> 3;
-  v6 = pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].sZValue & 7;
-  if ( v5 & 2 )
-  {
-    v7 = v6 == a2->field_4;
-    goto LABEL_32;
-  }
-  if ( v5 & 4 )
-  {
-    v8 = a2->field_4;
-    if ( v6 != v8 )
-      goto LABEL_16;
-    if ( v8 != 5 )
+    case VisObjectType_Any:
+      return true;
+
+    case VisObjectType_Sprite:
     {
-      v15 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Vis.cpp:207";
-      v12 = "Unsupported \"exclusion if no event\" type in CVis::is_part_of_selection";
-LABEL_15:
-          MessageBoxA(nullptr, v12, v15, 0);
-      return true;
+      v5 = filter->field_10;
+      int object_idx = (pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].object_pid & 0xFFFF) >> 3;
+      int object_type = pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].object_pid & 7;
+      if ( v5 & 2 )
+      {
+        if (object_type == filter->object_id)
+          return false;
+        return true;
+      }
+      if ( v5 & 4 )
+      {
+        v8 = filter->object_id;
+        if ( object_type != filter->object_id)
+          return true;
+        if (v8 != OBJECT_Decoration)
+        {
+          MessageBoxA(nullptr, "Unsupported \"exclusion if no event\" type in CVis::is_part_of_selection", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Vis.cpp:207", 0);
+          return true;
+        }
+        if (pLevelDecorations[object_idx].uCog || pLevelDecorations[object_idx].field_16_event_id)
+          return true;
+        return pLevelDecorations[object_idx].IsInteractive();
+      }
+      if (object_type == filter->object_id)
+      {
+        if (object_type != OBJECT_Actor)
+        {
+          MessageBoxA(nullptr, "Default case reached in VIS", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Vis.cpp:245", 0);
+          return true;
+        }
+
+        v10 = &pActors[object_idx];
+        int result = 1 << LOBYTE(v10->uAIState);
+        if ( result & filter->field_C
+            || !(result & filter->field_8)
+            || v5 & 8 && (result = MonsterStats::BelongsToSupertype(v10->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD)) == 0 )
+          return false;
+        if ( !(filter->field_10 & 1) )
+          return true;
+
+        result = v10->GetActorsRelation(nullptr);
+        if (result == 0)
+          return false;
+        return true;
+      }
+      return false;
     }
-    result *= 32;
-    if ( *(__int16 *)((char *)&pLevelDecorations[0].uCog + result)
-      || *(__int16 *)((char *)&pLevelDecorations[0].field_16_event_id + result) )
-      goto LABEL_16;
-    result = pLevelDecorations[result / sizeof(LevelDecoration)].IsInteractive();
-    goto LABEL_11;
-  }
-  if ( v6 == a2->field_4 )
-  {
-    if ( v6 != 3 )
+
+    case VisObjectType_Face:
     {
-      v15 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Vis.cpp:245";
-      v12 = "Default case reached in VIS";
-      goto LABEL_15;
+      uint face_attrib = 0;
+      bool no_event = true;
+      if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+      {
+        auto face = (ODMFace *)uD3DBillboardIdx_or_pBLVFace_or_pODMFace;
+        no_event = face->sCogTriggeredID == 0;
+        face_attrib = face->uAttributes;
+      }
+      else if (uCurrentlyLoadedLevelType == LEVEL_Indoor) 
+      {
+        auto face = (BLVFace *)uD3DBillboardIdx_or_pBLVFace_or_pODMFace;
+        no_event = pIndoor->pFaceExtras[face->uFaceExtraID].uEventID == 0;
+        face_attrib = face->uAttributes;
+      }
+      else
+        assert(false);
+
+      if (filter->object_id != OBJECT_BLVDoor)
+        return true;
+      if (no_event || face_attrib & filter->field_C)
+        return false;
+      return (face_attrib & filter->field_8) != 0;
     }
-    v10 = &pActors[result];
-    result = 1 << LOBYTE(v10->uAIState);
-    if ( result & a2->field_C
-      || !(result & a2->field_8)
-      || v5 & 8 && (result = MonsterStats::BelongsToSupertype(v10->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD)) == 0 )
-      goto LABEL_33;
-    if ( !(v3->field_10 & 1) )
-      goto LABEL_16;
-    result = v10->GetActorsRelation(nullptr);
-LABEL_11:
-    v7 = result == 0;
-LABEL_32:
-    if ( v7 )
-      goto LABEL_33;
-LABEL_16:
-    return true;
+
+    default:
+      assert(false);
   }
-LABEL_33:
-  LOBYTE(result) = 0;
-  return result;
 }
 
 //----- (004C091D) --------------------------------------------------------
@@ -1761,8 +1627,8 @@
   //signed int v5; // ecx@4
   //float v6; // ST04_4@6
   //float v7; // ST00_4@7
-  int v8; // eax@10
-  unsigned int v9; // eax@12
+  //int v8; // eax@10
+  //unsigned int v9; // eax@12
   int v10; // eax@17
   double v11; // st6@18
   double v12; // st7@18
@@ -1771,8 +1637,8 @@
   float v15; // ST08_4@22
   //float v16; // ST04_4@23
   //float v17; // ST00_4@24
-  signed int v18; // eax@27
-  unsigned int v19; // eax@29
+  //signed int v18; // eax@27
+  //unsigned int v19; // eax@29
   double v20; // st6@32
   double v21; // st7@32
   int v22; // eax@32
@@ -1792,13 +1658,13 @@
   float v34; // [sp+E4h] [bp-18h]@32
   int v35; // [sp+E8h] [bp-14h]@5
   int v36; // [sp+ECh] [bp-10h]@5
-  unsigned int v37; // [sp+F0h] [bp-Ch]@5
+  int v37; // [sp+F0h] [bp-Ch]@5
   float v38; // [sp+F4h] [bp-8h]@17
   //void *v39; // [sp+F8h] [bp-4h]@1
   signed int v40; // [sp+108h] [bp+Ch]@17
   float v41; // [sp+108h] [bp+Ch]@32
 
-  static Vis_stru1 Vis_static_stru_F91E10;
+  static Vis_SelectionList Vis_static_stru_F91E10;
   Vis_static_stru_F91E10.uNumPointers = 0;
   v3 = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].uParentBillboardID;
   if (v3 == -1)
@@ -1808,26 +1674,20 @@
 LABEL_49:
     return false;
   }
-  else
-  {
+
     v37 = pBillboardRenderList[v3].sZValue & 0xFFFF0000;
     GetPolygonCenter(pRenderer->pBillboardRenderListD3D[v3].pQuards, 4, (float *)&v35, (float *)&v36);
-    this->CastPickRay(pPickingRay, *(float *)&v35, *(float *)&v36, fDepth);
-    if (uCurrentlyLoadedLevelType == 1)
-      PickIndoor(fDepth, pPickingRay, &Vis_static_stru_F91E10, &a5);
+    CastPickRay(pPickingRay, *(float *)&v35, *(float *)&v36, fDepth);
+    if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
+      PickIndoorFaces_Mouse(fDepth, pPickingRay, &Vis_static_stru_F91E10, &vis_face_filter);
     else
-      PickOutdoor(fDepth, pPickingRay, &Vis_static_stru_F91E10, &a5, 0);
-    Vis_static_stru_F91E10.create_object_pointers(0);
-    sort_object_pointers(Vis_static_stru_F91E10.array_1804, 0, Vis_static_stru_F91E10.uNumPointers - 1);
+      PickOutdoorFaces_Mouse(fDepth, pPickingRay, &Vis_static_stru_F91E10, &vis_face_filter, false);
+    Vis_static_stru_F91E10.create_object_pointers();
+    sort_object_pointers(Vis_static_stru_F91E10.object_pointers, 0, Vis_static_stru_F91E10.uNumPointers - 1);
     if (Vis_static_stru_F91E10.uNumPointers)
     {
-     if (Vis_static_stru_F91E10.uNumPointers <= 0)
-       v8 = 0;
-     else v8 = (int)Vis_static_stru_F91E10.array_1804;
-     v9 = *(_DWORD *)(v8 + 4);
-     LOWORD(v9) = 0;
-     if (v9 > v37)
-       return 1;
+       if (Vis_static_stru_F91E10.object_pointers[0]->actual_z > pBillboardRenderList[v3].actual_z)
+         return 1;
     }
     else if ((double)(pViewport->uScreenX) <= *(float *)&v35 &&
              (double)pViewport->uScreenZ >= *(float *)&v35 &&
@@ -1855,18 +1715,21 @@
                 v15 = v12;
                 CastPickRay(local_80, SLODWORD(v15), v14, fDepth);
                 if ( uCurrentlyLoadedLevelType == 1 )
-                  PickIndoor(fDepth, local_80, &Vis_static_stru_F91E10, &a5);
+                  PickIndoorFaces_Mouse(fDepth, local_80, &Vis_static_stru_F91E10, &vis_face_filter);
                 else
-                  PickOutdoor(fDepth, local_80, &Vis_static_stru_F91E10, &a5, 0);
-                Vis_static_stru_F91E10.create_object_pointers(0);
-                sort_object_pointers(Vis_static_stru_F91E10.array_1804, 0, Vis_static_stru_F91E10.uNumPointers - 1);
+                  PickOutdoorFaces_Mouse(fDepth, local_80, &Vis_static_stru_F91E10, &vis_face_filter, false);
+                Vis_static_stru_F91E10.create_object_pointers();
+                sort_object_pointers(Vis_static_stru_F91E10.object_pointers, 0, Vis_static_stru_F91E10.uNumPointers - 1);
                 if ( !Vis_static_stru_F91E10.uNumPointers )
                   break;
-                v18 = Vis_static_stru_F91E10.uNumPointers <= 0 ? 0 : (int)Vis_static_stru_F91E10.array_1804;
-                v19 = *(_DWORD *)(v18 + 4);
-                LOWORD(v19) = 0;
-                if ( v19 > v37 )
+                else
+                {
+                //v18 = Vis_static_stru_F91E10.uNumPointers <= 0 ? 0 : (int);
+                //v19 = *(_DWORD *)(v18 + 4);
+                //LOWORD(v19) = 0;
+                if (Vis_static_stru_F91E10.object_pointers[0]->actual_z > pBillboardRenderList[v3].actual_z)
                   break;
+                }
               }
             }
           }
@@ -1899,12 +1762,12 @@
             || (double)pViewport->uScreenY > v41
             || (double)pViewport->uScreenW < v41
             || ((v25 = v23, CastPickRay(local_80, SLODWORD(v25), v41, fDepth), uCurrentlyLoadedLevelType != 1) ? 
-             (PickOutdoor(fDepth, local_80, &Vis_static_stru_F91E10, &a5, 0)) : 
-             (PickIndoor(fDepth, local_80, &Vis_static_stru_F91E10, &a5)),
-             (Vis_static_stru_F91E10.create_object_pointers(0),
-              sort_object_pointers(Vis_static_stru_F91E10.array_1804, 0, Vis_static_stru_F91E10.uNumPointers - 1),
+             (PickOutdoorFaces_Mouse(fDepth, local_80, &Vis_static_stru_F91E10, &vis_face_filter, false)) : 
+             (PickIndoorFaces_Mouse(fDepth, local_80, &Vis_static_stru_F91E10, &vis_face_filter)),
+             (Vis_static_stru_F91E10.create_object_pointers(),
+              sort_object_pointers(Vis_static_stru_F91E10.object_pointers, 0, Vis_static_stru_F91E10.uNumPointers - 1),
               Vis_static_stru_F91E10.uNumPointers)
-             && (Vis_static_stru_F91E10.uNumPointers <= 0 ? (v28 = 0) : (v28 = (int)Vis_static_stru_F91E10.array_1804),
+             && (Vis_static_stru_F91E10.uNumPointers <= 0 ? (v28 = 0) : (v28 = (int)Vis_static_stru_F91E10.object_pointers),
                  v29 = *(_DWORD *)(v28 + 4),
                  LOWORD(v29) = 0,
                  v29 <= v37)) )
@@ -1912,23 +1775,21 @@
           break;
         }
       }
-    result = 1;
-  }
-  return result;
+  return true;
 }
 // F93E18: using guessed type char static_byte_F93E18_init;
 
 //----- (004C0D32) --------------------------------------------------------
-int Vis::_4C0D32_BLV(float a1, Vis_stru1 *arg4, stru157 *a2)
+void Vis::PickIndoorFaces_Keyboard(float pick_depth, Vis_SelectionList *list, Vis_SelectionFilter *filter)
 {
   int result; // eax@1
   signed int v5; // esi@2
   BLVFace *v6; // edi@4
   unsigned int v7; // eax@6
-  Vis_stru1_stru0 *v8; // eax@6
-  int v9; // ST18_4@7
-  unsigned int v10; // ST1C_4@7
-  unsigned int v11; // ecx@7
+  Vis_ObjectInfo *v8; // eax@6
+  //int v9; // ST18_4@7
+  //unsigned int v10; // ST1C_4@7
+  //unsigned int v11; // ecx@7
   signed int i; // [sp+18h] [bp-8h]@1
   Vis *thisa; // [sp+1Ch] [bp-4h]@1
 
@@ -1944,108 +1805,46 @@
         v6 = &pIndoor->pFaces[v5];
         if ( !pGame->pIndoorCameraD3D->IsCulled(&pIndoor->pFaces[v5]) )
         {
-          if ( is_part_of_selection(v6, a2) )
+          if ( is_part_of_selection(v6, filter) )
           {
             v7 = 8 * v5;
-            LOBYTE(v7) = 8 * v5 | 6;
-            v8 = _4C1026(v6, v7, a1);
+            LOBYTE(v7) = 8 * v5 | OBJECT_BModel;
+            v8 = _4C1026(v6, v7, pick_depth);
             if ( v8 )
-            {
-              v9 = v8->sZValue;
-              v10 = v8->uObjectType;
-              v11 = 3 * arg4->uNumPointers;
-              arg4->array_0004[arg4->uNumPointers].pObjectInfo = v8->pObjectInfo;
-              arg4->array_0004[4 * v11 / 0xC].sZValue = v9;
-              arg4->array_0004[4 * v11 / 0xC].uObjectType = v10;
-              ++arg4->uNumPointers;
-            }
+              list->AddObject(v8->object, v8->object_type, v8->sZValue);
           }
         }
       }
     }
     result = i + 1;
   }
-  return result;
 }
 
 //----- (004C0DEA) --------------------------------------------------------
-void Vis::_4C0DEA_ODM(float arg0, Vis_stru1 *a3, stru157 *a2)
+void Vis::PickOutdoorFaces_Keyboard(float pick_depth, Vis_SelectionList *list, Vis_SelectionFilter *filter)
 {
-  int v4; // esi@1
-  BSPModel *v5; // ebx@3
-  unsigned __int8 v6; // zf@5
-  char v7; // sf@5
-  unsigned __int8 v8; // of@5
-  ODMFace *v9; // esi@7
-  unsigned int v10; // eax@8
-  Vis_stru1_stru0 *v11; // eax@8
-  unsigned int v12; // ecx@9
-  BLVFace f; // [sp+10h] [bp-84h]@1
-  void *v14; // [sp+70h] [bp-24h]@9
-  int v15; // [sp+74h] [bp-20h]@9
-  unsigned int v16; // [sp+78h] [bp-1Ch]@9
-  int v17; // [sp+7Ch] [bp-18h]@1
-  Vis *v18; // [sp+80h] [bp-14h]@1
-  int v19; // [sp+84h] [bp-10h]@6
-  unsigned int v20; // [sp+88h] [bp-Ch]@2
-  int v21; // [sp+8Ch] [bp-8h]@5
-  int a1; // [sp+90h] [bp-4h]@1
+  for (uint i = 0; i < pOutdoor->uNumBModels; ++i)
+  {
+    int v17;
+    if (!IsBModelVisible(i, &v17))
+      continue;
+    if (!v17)
+      continue;
 
-  auto ecx0 = this;
-  v18 = ecx0;
-  v4 = 0;
-  v17 = 0;
-  a1 = 0;
-  if ( (signed int)pOutdoor->uNumBModels > 0 )
-  {
-    v20 = 0;
-    do
+    auto bmodel = pOutdoor->pBModels + i;
+    for (uint j = 0; j < bmodel->uNumFaces; ++j)
     {
-      v5 = &pOutdoor->pBModels[v20 / 0xBC];
-      if ( IsBModelVisible(a1, &v17) )
+      auto face = bmodel->pFaces + j;
+
+      if (is_part_of_selection(face, filter) )
       {
-        if ( v17 != v4 )
-        {
-          v8 = __OFSUB__(v5->uNumFaces, v4);
-          v6 = v5->uNumFaces == v4;
-          v7 = ((v5->uNumFaces - v4) & 0x80000000u) != 0;
-          v21 = v4;
-          if ( !((unsigned __int8)(v7 ^ v8) | v6) )
-          {
-            v19 = v4;
-            do
-            {
-              v9 = (ODMFace *)((char *)v5->pFaces + v19);
-              if ( is_part_of_selection((BLVFace *)((char *)v5->pFaces + v19), a2) )
-              {
-                f.FromODM(v9);
-                v10 = 8 * (v21 | (a1 << 6));
-                LOBYTE(v10) = v10 | 6;
-                v11 = _4C1026(&f, v10, arg0);
-                if ( v11 )
-                {
-                  v14 = v11->pObjectInfo;
-                  v15 = v11->sZValue;
-                  v12 = a3->uNumPointers;
-                  v16 = v11->uObjectType;
-                  v12 *= 3;
-                  *((int *)&a3->array_0004[0].pObjectInfo + v12) = (int)v14;
-                  *(&a3->array_0004[0].sZValue + v12) = v15;
-                  *(&a3->array_0004[0].uObjectType + v12) = v16;
-                  ++a3->uNumPointers;
-                }
-              }
-              ++v21;
-              v19 += 308;
-            }
-            while ( v21 < (signed int)v5->uNumFaces );
-            v4 = 0;
-          }
-        }
+        BLVFace blv_face;
+        blv_face.FromODM(face);
+
+        int pid = 8 * (j | (i << 6)) | OBJECT_BModel;
+        if (auto object_info = _4C1026(&blv_face, pid, pick_depth))
+          list->AddObject(object_info->object, object_info->object_type, object_info->sZValue);
       }
-      ++a1;
-      v20 += 188;
     }
-    while ( a1 < (signed int)pOutdoor->uNumBModels );
   }
 }
\ No newline at end of file
--- a/Vis.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/Vis.h	Mon Feb 18 09:44:59 2013 +0600
@@ -3,31 +3,77 @@
 
 
 
+enum VisObjectType: unsigned __int32
+{
+  VisObjectType_Any = 0,
+  VisObjectType_Sprite = 1,
+  VisObjectType_Face = 2
+};
+
+/*  150 */
+#pragma pack(push, 1)
+struct Vis_SelectionFilter //stru157
+{
+  VisObjectType object_type;
+  int object_id;  // OBJECT_Actor, OBJECT_Player etc
+  int field_8;
+  int field_C;
+  int field_10;
+};
+#pragma pack(pop)
+extern Vis_SelectionFilter vis_sprite_filter_1; // 00F93E1C
+extern Vis_SelectionFilter vis_sprite_filter_2; // 00F93E30
+extern Vis_SelectionFilter vis_face_filter;     // 00F93E44
+extern Vis_SelectionFilter vis_door_filter;     // 00F93E58
+extern Vis_SelectionFilter vis_sprite_filter_3; // 00F93E6C
+extern Vis_SelectionFilter vis_sprite_filter_4; // static to sub_44EEA7
 
 
 
 #pragma pack(push, 1)
-struct Vis_stru1_stru0
+struct Vis_ObjectInfo
 {
-  void *pObjectInfo;
-  int sZValue;
-  unsigned int uObjectType;
+  void *object;
+  union
+  {
+    int sZValue;
+    struct
+    {
+      unsigned __int16 object_pid;
+      signed __int16 actual_z;
+    };
+  };
+  VisObjectType object_type;
 };
 #pragma pack(pop)
 
+
 #pragma pack(push, 1)
-struct Vis_stru1
+struct Vis_SelectionList
 {
-  Vis_stru1();
+  enum PointerCreationType
+  {
+    All = 0,
+    Unique = 1
+  };
+
+  Vis_SelectionList();
   //----- (004C0585) --------------------------------------------------------
-  ~Vis_stru1() {}
-  Vis_stru1_stru0 *sub_4C2551(int a2, int a3);
-  Vis_stru1_stru0 **create_object_pointers(unsigned int flag);
+  ~Vis_SelectionList() {}
+  Vis_ObjectInfo *sub_4C2551(int a2, int a3);
+  void            create_object_pointers(PointerCreationType type = All);
 
-  void (__thiscall ***vdestructor_ptr)(Vis_stru1 *, bool);
-  Vis_stru1_stru0 array_0004[512];
-  Vis_stru1_stru0 *array_1804[512];
-  unsigned int uNumPointers;
+  inline void AddObject(void *object, VisObjectType type, int packed_zval)
+  {
+    object_pool[uNumPointers].object = object;
+    object_pool[uNumPointers].object_type = type;
+    object_pool[uNumPointers++].sZValue = packed_zval;
+  }
+
+  void (__thiscall ***vdestructor_ptr)(Vis_SelectionList *, bool);
+  Vis_ObjectInfo  object_pool[512];
+  Vis_ObjectInfo *object_pointers[512];
+  unsigned int    uNumPointers;
 };
 #pragma pack(pop)
 
@@ -42,43 +88,45 @@
   //virtual ~Vis() {}
   //----- (004C05BE) --------------------------------------------------------
   ~Vis() {}
-  bool PickKeyboard(Vis_stru1 *a2, struct stru157 *a3, struct stru157 *a4);
-  bool PickMouse(float fDepth, float fMouseX, float fMouseY, struct stru157 *a5, struct stru157 *a6);
-  void _4C06F8(float arg0, Vis_stru1 *a3, struct stru157 *a2);
-  bool is_part_of_selection(struct BLVFace *uD3DBillboardIdx_or_pBLVFace_or_pODMFace, struct stru157 *a2);
+  bool PickKeyboard(Vis_SelectionList *list, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter);
+  void PickBillboards_Keyboard(float pick_depth, Vis_SelectionList *list, Vis_SelectionFilter *filter);
+  void PickIndoorFaces_Keyboard(float pick_depth, Vis_SelectionList *list, Vis_SelectionFilter *filter);
+  void PickOutdoorFaces_Keyboard(float pick_depth, Vis_SelectionList *list, Vis_SelectionFilter *filter);
+
+  bool PickMouse(float fDepth, float fMouseX, float fMouseY, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter);
+  void PickBillboards_Mouse(float fPickDepth, float fX, float fY, Vis_SelectionList *list, Vis_SelectionFilter *filter);
+  void PickIndoorFaces_Mouse(float fDepth, struct RenderVertexSoft *pRay, Vis_SelectionList *list, Vis_SelectionFilter *filter);
+  void PickOutdoorFaces_Mouse(float fDepth, struct RenderVertexSoft *pRay, Vis_SelectionList *list, Vis_SelectionFilter *filter, bool one_sided);
+
+  bool is_part_of_selection(void *uD3DBillboardIdx_or_pBLVFace_or_pODMFace, Vis_SelectionFilter *filter);
   bool DoesRayIntersectBillboard(float fDepth, unsigned int uD3DBillboardIdx);
-  int _4C0D32_BLV(float a1, Vis_stru1 *arg4, struct stru157 *a2);
-  void _4C0DEA_ODM(float arg0, Vis_stru1 *a3, struct stru157 *a2);
-  Vis_stru1_stru0 *_4C1026(struct BLVFace *a2, unsigned int a3, float a4);
-  char _4C12C3_FindSomeBillboard(struct RenderVertexSoft *a1, int a2, float a3, float a4);
+  Vis_ObjectInfo *_4C1026(struct BLVFace *face, unsigned int a3, float pick_depth);
+  bool IsPolygonOccludedByBillboard(struct RenderVertexSoft *vertices, int num_vertices, float x, float y);
   void GetPolygonCenter(struct RenderVertexD3D3 *pVertices, unsigned int uNumVertices, float *pCenterX, float *pCenterY);
-  float *_4C1495(struct RenderVertexSoft *Src, int a2, float *a3, float *a4);
-  void PickBillboards(float fPickDepth, float fX, float fY, Vis_stru1 *a4, stru157 *a2);
+  void GetPolygonScreenSpaceCenter(struct RenderVertexSoft *vertices, int num_vertices, float *out_center_x, float *out_center_y);
   bool IsPointInsideD3DBillboard(struct RenderBillboardD3D *a1, float x, float y);
-  void PickIndoor(float fDepth, struct RenderVertexSoft *pRay, Vis_stru1 *a4, stru157 *a5);
-  void PickOutdoor(float fDepth, struct RenderVertexSoft *pRay, Vis_stru1 *a4, stru157 *a5, char a6);
-  int _4C1944(int a2, unsigned int a3, int a4, int a5, int a6);
+  int _4C1944(int object_id, unsigned int a3, int a4, int a5, int a6);
   void _4C1A02();
   bool SortVectors_x(RenderVertexSoft *a2, int a3, int a4);
-  int get_object_zbuf_val(Vis_stru1_stru0 *a2);
+  int get_object_zbuf_val(Vis_ObjectInfo *info);
   int get_picked_object_zbuf_val();
   bool Intersect_Ray_Face(struct RenderVertexSoft *pRayStart, struct RenderVertexSoft *pRayEnd, float *pDepth, RenderVertexSoft *a4, BLVFace *a5, unsigned int a6);
   int _4C1D2B(BLVFace *pFace, Vec3_short_ a2, unsigned int uModelID);
   bool _4C1EE5_BLV_IntersectBModel_2(int *a1, int *a2, __int16 *a3, __int16 *a4, Vec3_short_ *a5, BLVFace *pFace);
   bool _4C2186_BLV_IntersectBModel(int *a1, int *a2, __int16 *a3, __int16 *a4, Vec3_short_ *a5, BLVFace *a6, unsigned int uModelID);
   void CastPickRay(RenderVertexSoft *pRay, float fMouseX, float fMouseY, float fPickDepth);
-  void sort_object_pointers(Vis_stru1_stru0 **pPointers, int left, int right);
+  void sort_object_pointers(Vis_ObjectInfo **pPointers, int left, int right);
   bool SortVerticesByX(struct RenderVertexD3D3 *a2, unsigned int uStart, unsigned int uEnd);
   bool SortVerticesByY(struct RenderVertexD3D3 *a2, unsigned int uStart, unsigned int uEnd);
-  bool sort_objects_2(struct RenderVertexSoft *pArray, int sLeft, int sRight);
-  bool sort_objects_3(struct RenderVertexSoft *pArray, int sLeft, int sRight);
+  bool SortByScreenSpaceX(struct RenderVertexSoft *pArray, int sLeft, int sRight);
+  bool SortByScreenSpaceY(struct RenderVertexSoft *pArray, int sLeft, int sRight);
 
   void (__thiscall ***vdestructor_ptr)(Vis *, bool);
-  Vis_stru1 stru1;
-  RenderVertexSoft stru_200C;
-  RenderVertexSoft stru_203C;
-  RenderVertexSoft stru_206C;
-  RenderVertexSoft stru_209C;
-  int field_20CC;
+  Vis_SelectionList default_list;
+  RenderVertexSoft  stru_200C;
+  RenderVertexSoft  stru_203C;
+  RenderVertexSoft  stru_206C;
+  RenderVertexSoft  stru_209C;
+  int keyboard_pick_depth;
 };
 #pragma pack(pop)
--- a/mm7_1.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/mm7_1.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -48,6 +48,7 @@
 #include "stru298.h"
 #include "StorylineTextTable.h"
 #include "Events2D.h"
+#include "texts.h"
 
 #include "mm7_data.h"
 
@@ -206,7 +207,7 @@
   v85 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem;
   v86 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
   v79 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
-  pPlayer = &pParty->pPlayers[v1-1];//(Player *)&stru_AA1058[3].pSounds[6972 * v1 + 40552];
+  pPlayer = &pParty->pPlayers[v1-1];
   v3 = pIcons_LOD->LoadTexture("fr_skill", TEXTURE_16BIT_PALETTE);
   pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v3 != -1 ? (int)&pIcons_LOD->pTextures[v3] : 0));
   v4 = v79;
@@ -640,8 +641,8 @@
   sprintf(pTmpBuf, "%s \f%05d", pGlobalTXT_LocalizationStrings[23], v2);// TODO check args
   sprintf(Source,
     pGlobalTXT_LocalizationStrings[429],
-	&pParty->pPlayers[v1-1].pName,//&stru_AA1058[3].pSounds[6972 * v1 + 40720],
-	pClassNames[pParty->pPlayers[v1-1].classType]);//&pClassNames[stru_AA1058[3].pSounds[6972 * v1 + 40737]]);
+	&pParty->pPlayers[v1-1].pName,
+	pClassNames[pParty->pPlayers[v1-1].classType]);
   strcat(pTmpBuf, Source);
   strcat(pTmpBuf, "\xC" "00000");
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, 18, 0, pTmpBuf, 0, 0, 0);
@@ -2081,7 +2082,7 @@
       pWindowList[v3].pCurrentPosActiveItem -= v12;
       if ( v8 )
       {
-        pAudioPlayer->PlaySound((SoundID)66, v1, v1, -1, v1, v1, v1, v1);
+        pAudioPlayer->PlaySound(SOUND_Button, v1, v1, -1, v1, v1, v1, v1);
         v2 = pMessageQueue_50CBD0->uNumMessages;
       }
     }
@@ -2121,7 +2122,7 @@
         pWindowList[v3].pCurrentPosActiveItem = v7;
         if ( v8 )
         {
-          pAudioPlayer->PlaySound((SoundID)66, v1, v1, -1, v1, v1, v1, v1);
+          pAudioPlayer->PlaySound(SOUND_Button, v1, v1, -1, v1, v1, v1, v1);
           v2 = pMessageQueue_50CBD0->uNumMessages;
         }
       }
@@ -2450,13 +2451,13 @@
         }
         else
         {
-          v83 = (char *)8;
+          v83 = (char *)SPEECH_8;
           if ( _this->GetValue() < 100 * (pPlayers[uActiveCharacter]->uLevel + 5) )
-            v83 = (char *)7;
+            v83 = (char *)SPEECH_7;
         }
         if ( dword_4E455C )
         {
-          pPlayers[uActiveCharacter]->PlaySound((int)v83, 0);
+          pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)(int)v83, 0);
           dword_4E455C = 0;
         }
       }
@@ -2468,14 +2469,14 @@
         if ( v10 )
           _this->uAttributes = _this->uAttributes & 0xFFFFFFFD | 1;
         v10 = (v12->uAttributes & 2) == 0;
-        v83 = (char *)11;
+        v83 = (char *)SPEECH_11;
         if ( v10 )
-          v83 = (char *)10;
+          v83 = (char *)SPEECH_10;
         else
           ShowStatusBarString(pGlobalTXT_LocalizationStrings[448], 2u);
         if ( dword_4E455C )
         {
-          pPlayers[uActiveCharacter]->PlaySound((int)v83, 0);
+          pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)(int)v83, 0);
           dword_4E455C = 0;
         }
       }
@@ -2779,7 +2780,7 @@
         goto LABEL_65;
       }
       v60 = _this->_bonus_strength;
-      v55 = *((int *)&pItemsTable->pEnchantments[23].pName + 7 * v26);
+      v55 = *((int *)&pItemsTable->pEnchantments[23].pBonusStat + 7 * v26);
       v50 = pGlobalTXT_LocalizationStrings[210];
       v46 = "%s: %s";
     }
@@ -2802,7 +2803,7 @@
   int v8; // eax@4
   unsigned __int16 v9; // dx@4
   SpriteFrame *v10; // edi@17
-  int v11; // esi@17
+  LODSprite *v11; // esi@17
   unsigned int v12; // ecx@17
   Sprite *v13; // edi@18
   int v14; // ecx@18
@@ -2852,7 +2853,6 @@
   int v58; // eax@132
   Actor *v59; // ecx@133
   unsigned __int8 v60; // dl@138
-  char *v61; // eax@145
   char *v62; // eax@147
   int v63; // eax@152
   char *result; // eax@152
@@ -2876,27 +2876,8 @@
   DDBLTFX Dst; // [sp+Ch] [bp-1E0h]@18
   DDSURFACEDESC2 pDesc; // [sp+70h] [bp-17Ch]@18
   RECT v84; // [sp+ECh] [bp-100h]@26
-  char *v85; // [sp+FCh] [bp-F0h]@145
-  char *v86; // [sp+100h] [bp-ECh]@145
-  char *v87; // [sp+104h] [bp-E8h]@145
-  char *v88; // [sp+108h] [bp-E4h]@145
-  char *v89; // [sp+10Ch] [bp-E0h]@145
-  char *v90; // [sp+110h] [bp-DCh]@145
-  char *v91; // [sp+114h] [bp-D8h]@145
-  char *v92; // [sp+118h] [bp-D4h]@145
-  char *v93; // [sp+11Ch] [bp-D0h]@145
-  char *v94; // [sp+120h] [bp-CCh]@145
-  char *v95; // [sp+124h] [bp-C8h]@127
-  char *v96; // [sp+128h] [bp-C4h]@127
-  char *v97; // [sp+12Ch] [bp-C0h]@127
-  char *v98; // [sp+130h] [bp-BCh]@127
-  char *v99; // [sp+134h] [bp-B8h]@127
-  char *v100; // [sp+138h] [bp-B4h]@127
-  char *v101; // [sp+13Ch] [bp-B0h]@127
-  char *v102; // [sp+140h] [bp-ACh]@127
-  char *v103; // [sp+144h] [bp-A8h]@127
-  char *v104; // [sp+148h] [bp-A4h]@127
-  char *v105; // [sp+14Ch] [bp-A0h]@127
+  char *v85[10]; // [sp+FCh] [bp-F0h]@145
+  char *v95[11]; // [sp+124h] [bp-C8h]@127
   RenderBillboardTransform_local0 v106; // [sp+150h] [bp-9Ch]@3
   unsigned int v107; // [sp+1A0h] [bp-4Ch]@18
   unsigned __int16 *v108; // [sp+1A4h] [bp-48h]@34
@@ -2975,7 +2956,7 @@
   v10 = pSpriteFrameTable->GetFrame(
           v3->pSpriteIDs[(signed __int16)pMonsterInfoUI_Doll.uCurrentActionAnimation],
           pMonsterInfoUI_Doll.uCurrentActionTime);
-  v11 = 40 * v10->pHwSpriteIDs[0] + 7218180;
+  v11 = pSprites_LOD[v10->pHwSpriteIDs[0]].pSpriteHeaders;//40 * v10->pHwSpriteIDs[0] + 7218180;
   v106.pTarget = pRenderer->pTargetSurface;
   v106.pTargetZ = pRenderer->pActiveZBuffer;
   v106.uTargetPitch = pRenderer->uTargetSurfacePitch;
@@ -2987,7 +2968,7 @@
   v106.uScreenSpaceX = (signed int)(v106.uViewportX + 128 + v106.uViewportX) / 2;
   v106._screenspace_x_scaler_packedfloat = 65536;
   v106._screenspace_y_scaler_packedfloat = 65536;
-  v106.uScreenSpaceY = v115 + v12 + *(short *)(v11 + 18);
+  v106.uScreenSpaceY = v115 + v12 + v11->uHeight;
   v106.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v10->uPaletteIndex, 0, 1);
   v106.sZValue = 0;
   v106.uFlags = 0;
@@ -3062,99 +3043,101 @@
     {
       memset(&pDesc, 0, 0x7Cu);
       pDesc.dwSize = 124;
-      if ( !pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)v222, &pDesc, DDLOCK_WAIT))
-        goto LABEL_51;
-      v20 = (char *)v124;
-      v110 = pDesc.lpSurface;
-      a2 = (Player *)v124;
-      if ( v124 < v119 )
-      {
-        v111 = 2 * pRenderer->uTargetSurfacePitch;
-        v21 = (int)a4;
-        v22 = &pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
-        v23 = i - v124;
-        v120 = (SpellBuff *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
-        v115 = i - v124;
-        while ( 1 )
-        {
-          v124 = v21;
-          if ( v21 < (signed int)v116 )
-          {
-            v24 = (int)&v20[v23];
-            v25 = v107 - v21;
-            v109 = v24;
-            for ( i = v107 - v21; ; v25 = i )
-            {
-              v108 = (unsigned __int16 *)((pDesc.lPitch >> 1) * pDesc.dwHeight * v109 / v13->uAreaHeight);
-              v26 = (char *)v108 + pDesc.dwWidth * (v25 + v124++) / v13->uAreaWidth;
-              *v22 = *((short *)v110 + (int)v26);
-              ++v22;
-              if ( v124 >= (signed int)v116 )
-                break;
-            }
-            v23 = v115;
-          }
-          v22 = (unsigned __int16 *)((char *)v120 + v111);
-          v20 = (char *)&a2->pConditions[0] + 1;
-          v28 = __OFSUB__((int)&a2->pConditions[0] + 1, v119);
-          v27 = (signed int)((char *)&a2->pConditions[0] + -v119 + 1) < 0;
-          a2 = (Player *)((char *)a2 + 1);
-          v120 = (SpellBuff *)((char *)v120 + v111);
-          if ( !(v27 ^ v28) )
-            break;
-          v21 = (int)a4;
-        }
-      }
-      goto LABEL_37;
-    }
-    memset(&pDesc, 0, 0x7Cu);
-    pDesc.dwSize = 124;
-    if ( pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)v222, &pDesc, DDLOCK_WAIT) )
-    {
-      v108 = (unsigned __int16 *)pDesc.lpSurface;
-      a2 = (Player *)v124;
-      if ( v124 < v119 )
-      {
-        v109 = 2 * pRenderer->uTargetSurfacePitch;
-        v29 = (int)a4;
-        v30 = (char *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
-        v31 = i - v124;
-        v120 = (SpellBuff *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
-        v115 = i - v124;
-        while ( 1 )
-        {
-          v124 = v29;
-          if ( v29 < (signed int)v116 )
-          {
-            v32 = v107 - (int)a4;
-            v111 = (unsigned int)((char *)a2 + v31);
-            for ( i = v107 - (int)a4; ; v32 = i )
-            {
-              v110 = (LPVOID)((pDesc.lPitch >> 1) * pDesc.dwHeight * v111 / v13->uAreaHeight);
-              v33 = v108[(int)((char *)v110 + pDesc.dwWidth * (v32 + v124) / v13->uAreaWidth)];
-              v34 = v33 & 0x1F | 2
-                               * (unsigned __int16)(v108[(int)((char *)v110
-                                                                + pDesc.dwWidth * (v32 + v124++) / v13->uAreaWidth)] & 0xFFE0);
-              v35 = v124;
-              *(short *)v30 = v34;
-              v30 += 2;
-              if ( v35 >= (signed int)v116 )
-                break;
-            }
-            v31 = v115;
-          }
-          a2 = (Player *)((char *)a2 + 1);
-          v30 = (char *)v120 + v109;
-          v120 = (SpellBuff *)((char *)v120 + v109);
-          if ( (signed int)a2 >= v119 )
-            break;
-          v29 = (int)a4;
-        }
-      }
-LABEL_37:
-      v222->Unlock(0);
-      goto LABEL_51;
-    }
+      if ( pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)v222, &pDesc, DDLOCK_WAIT))
+	  {
+		  v20 = (char *)v124;
+		  v110 = pDesc.lpSurface;
+		  a2 = (Player *)v124;
+		  if ( v124 < v119 )
+		  {
+			v111 = 2 * pRenderer->uTargetSurfacePitch;
+			v21 = (int)a4;
+			v22 = &pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
+			v23 = i - v124;
+			v120 = (SpellBuff *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
+			v115 = i - v124;
+			while ( 1 )
+			{
+			  v124 = v21;
+			  if ( v21 < (signed int)v116 )
+			  {
+				v24 = (int)&v20[v23];
+				v25 = v107 - v21;
+				v109 = v24;
+				for ( i = v107 - v21; ; v25 = i )
+				{
+				  v108 = (unsigned __int16 *)((pDesc.lPitch >> 1) * pDesc.dwHeight * v109 / v13->uAreaHeight);
+				  v26 = (char *)v108 + pDesc.dwWidth * (v25 + v124++) / v13->uAreaWidth;
+				  *v22 = *((short *)v110 + (int)v26);
+				  ++v22;
+				  if ( v124 >= (signed int)v116 )
+					break;
+				}
+				v23 = v115;
+			  }
+			  v22 = (unsigned __int16 *)((char *)v120 + v111);
+			  v20 = (char *)&a2->pConditions[0] + 1;
+			  v28 = __OFSUB__((int)&a2->pConditions[0] + 1, v119);
+			  v27 = (signed int)((char *)&a2->pConditions[0] + -v119 + 1) < 0;
+			  a2 = (Player *)((char *)a2 + 1);
+			  v120 = (SpellBuff *)((char *)v120 + v111);
+			  if ( !(v27 ^ v28) )
+				break;
+			  v21 = (int)a4;
+			}
+		  }
+		  v222->Unlock(0);
+	  }
+    }
+	else
+	{
+		memset(&pDesc, 0, 0x7Cu);
+		pDesc.dwSize = 124;
+		if ( pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)v222, &pDesc, DDLOCK_WAIT) )
+		{
+		  v108 = (unsigned __int16 *)pDesc.lpSurface;
+		  a2 = (Player *)v124;
+		  if ( v124 < v119 )
+		  {
+			v109 = 2 * pRenderer->uTargetSurfacePitch;
+			v29 = (int)a4;
+			v30 = (char *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
+			v31 = i - v124;
+			v120 = (SpellBuff *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
+			v115 = i - v124;
+			while ( 1 )
+			{
+			  v124 = v29;
+			  if ( v29 < (signed int)v116 )
+			  {
+				v32 = v107 - (int)a4;
+				v111 = (unsigned int)((char *)a2 + v31);
+				for ( i = v107 - (int)a4; ; v32 = i )
+				{
+				  v110 = (LPVOID)((pDesc.lPitch >> 1) * pDesc.dwHeight * v111 / v13->uAreaHeight);
+				  v33 = v108[(int)((char *)v110 + pDesc.dwWidth * (v32 + v124) / v13->uAreaWidth)];
+				  v34 = v33 & 0x1F | 2
+								   * (unsigned __int16)(v108[(int)((char *)v110
+																	+ pDesc.dwWidth * (v32 + v124++) / v13->uAreaWidth)] & 0xFFE0);
+				  v35 = v124;
+				  *(short *)v30 = v34;
+				  v30 += 2;
+				  if ( v35 >= (signed int)v116 )
+					break;
+				}
+				v31 = v115;
+			  }
+			  a2 = (Player *)((char *)a2 + 1);
+			  v30 = (char *)v120 + v109;
+			  v120 = (SpellBuff *)((char *)v120 + v109);
+			  if ( (signed int)a2 >= v119 )
+				break;
+			  v29 = (int)a4;
+			}
+		  }
+		  v222->Unlock(0);
+		}
+	}
   }
   else
   {
@@ -3168,29 +3151,30 @@
     if ( v36 >= 0 )
       pSprites_LOD->pSpriteHeaders[v36]._4ACC38(&v106, 0);
   }
-LABEL_51:
   if ( v121->uNPC_ID )
   {
     v37 = v112[6];
     if ( v37 )
     {
       sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], *v112, aNPCProfessionNames[(signed int)v37]);
-      goto LABEL_59;
-    }
-    v77 = 2000;
-    v72 = *v112;
+    }
+	else
+	{
+	  v77 = 2000;
+	  v72 = *v112;
+	}
   }
   else
   {
     v38 = v121->dword_000334_unique_name;
     v77 = 2000;
     if ( v38 )
-      v72 = (char *)*(&pMonsterStats->pPlacement.uNumStrings + v38);
+      v72 = pMonsterStats->pPlaceStrings[v38];
     else
       v72 = pMonsterStats->pInfos[v121->pMonsterInfo.uID].pName;
   }
-  strncpy(pTmpBuf, v72, v77);
-LABEL_59:
+  if(!v121->uNPC_ID || (v121->uNPC_ID && !v37))
+    strncpy(pTmpBuf, v72, v77);
   v39 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
   a1->DrawTitleText(pFontComic, 0, 0xCu, v39, pTmpBuf, 3u);
   Actor::DrawHealthBar(v121, a1);
@@ -3203,77 +3187,93 @@
   if ( !uActiveCharacter )
   {
     v45 = 1;
-    goto LABEL_84;
-  }
-  LOBYTE(v40) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID);
-  v120 = v40;
-  if ( !v40 )
-    goto LABEL_72;
-  v41 = (unsigned __int8)v40 & 0x3F;
-  v42 = SkillToMastery((unsigned __int16)v40) - 1;
-  if ( !v42 )
-  {
-    if ( v41 + 10 >= v121->pMonsterInfo.uLevel )
-    {
-      v45 = 1;
-      v119 = 1;
-      goto LABEL_73;
-    }
-    goto LABEL_72;
-  }
-  v43 = v42 - 1;
-  if ( !v43 )
-  {
-    if ( 2 * v41 + 10 >= v121->pMonsterInfo.uLevel )
-    {
-      v45 = 1;
-      v119 = 1;
-      v116 = 1;
-      goto LABEL_73;
-    }
-    goto LABEL_72;
-  }
-  v44 = v43 - 1;
-  if ( !v44 )
-  {
-    if ( 3 * v41 + 10 >= v121->pMonsterInfo.uLevel )
-    {
-      v45 = 1;
-      v119 = 1;
-      v116 = 1;
-      i = 1;
-      goto LABEL_73;
-    }
-LABEL_72:
-    v45 = 1;
-    goto LABEL_73;
-  }
-  if ( v44 != 1 )
-    goto LABEL_72;
-  v45 = 1;
-  v119 = 1;
-  v116 = 1;
-  i = 1;
-  v112 = (char **)1;
-LABEL_73:
-  v46 = v121->uAIState;
-  if ( v46 != 5 && v46 != 4 && !dword_507BF0_is_there_popup_onscreen && v120 )
-  {
-    v47 = pPlayers[uActiveCharacter];
-    if ( v119 | v116 | i | (unsigned int)v112 )
-    {
-      if ( v121->pMonsterInfo.uLevel >= v47->uLevel - 5 )
-        v73 = 105;
-      else
-        v73 = 104;
-    }
-    else
-    {
-      v73 = 106;
-    }
-    v47->PlaySound(v73, 0);
-  }
-LABEL_84:
+  }
+  else
+  {
+	  LOBYTE(v40) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID);
+	  v120 = v40;
+	  if ( !v40 )
+					v45 = 1;
+	  else
+	  {
+		  v41 = (unsigned __int8)v40 & 0x3F;
+		  v42 = SkillToMastery((unsigned __int16)v40) - 1;
+		  if ( !v42 )
+		  {
+			if ( v41 + 10 >= v121->pMonsterInfo.uLevel )
+			{
+			  v45 = 1;
+			  v119 = 1;
+			}
+			else
+						v45 = 1;
+		  }
+		  else
+		  {
+			  v43 = v42 - 1;
+			  if ( !v43 )
+			  {
+				if ( 2 * v41 + 10 >= v121->pMonsterInfo.uLevel )
+				{
+				  v45 = 1;
+				  v119 = 1;
+				  v116 = 1;
+				}
+				else
+						v45 = 1;
+			  }
+			  else
+			  {
+				  v44 = v43 - 1;
+				  if ( !v44 )
+				  {
+					if ( 3 * v41 + 10 >= v121->pMonsterInfo.uLevel )
+					{
+					  v45 = 1;
+					  v119 = 1;
+					  v116 = 1;
+					  i = 1;
+					}
+					else
+					{
+						v45 = 1;
+					}
+				  }
+				  else
+				  {
+					  if ( v44 != 1 )
+						v45 = 1;
+					  else
+					  {
+						  v45 = 1;
+						  v119 = 1;
+						  v116 = 1;
+						  i = 1;
+						  v112 = (char **)1;
+					  }
+				  }
+			  }
+		  }
+	  }
+	  //	LABEL_73:
+	  v46 = v121->uAIState;
+	  if ( v46 != 5 && v46 != 4 && !dword_507BF0_is_there_popup_onscreen && v120 )
+	  {
+		v47 = pPlayers[uActiveCharacter];
+		if ( v119 | v116 | i | (unsigned int)v112 )
+		{
+		  if ( v121->pMonsterInfo.uLevel >= v47->uLevel - 5 )
+			v73 = SPEECH_105;
+		  else
+			v73 = SPEECH_104;
+		}
+		else
+		{
+		  v73 = SPEECH_106;
+		}
+		v47->PlaySound((PlayerSpeech)v73, 0);
+	  }
+  }
   a2 = pParty->pPlayers;
   do
   {
@@ -3431,48 +3431,48 @@
   a4 = (char *)v106.uViewportY;
   if ( v119 )
   {
-    sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[108], 0, v121->pMonsterInfo.uHP);
+    sprintf(pTmpBuf, "%s\f%05u\t100%d\n", pGlobalTXT_LocalizationStrings[108], 0, v121->pMonsterInfo.uHP);
     a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
     a4 = &a4[LOBYTE(v56->uFontHeight) - 3];
     v79 = v121->pMonsterInfo.uAC;
     v75 = 0;
     v70 = pGlobalTXT_LocalizationStrings[12];
-    v67 = "%s";
+    v67 = "%s\f%05u\t100%d\n";
   }
   else
   {
-    sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[108], 0, pGlobalTXT_LocalizationStrings[630]);
+    sprintf(pTmpBuf, "%s\f%05u\t100%s\n", pGlobalTXT_LocalizationStrings[108], 0, pGlobalTXT_LocalizationStrings[630]);
     a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
     v79 = (unsigned int)pGlobalTXT_LocalizationStrings[630];
     v75 = 0;
     v70 = pGlobalTXT_LocalizationStrings[12];
     a4 = &a4[LOBYTE(v56->uFontHeight) - 3];
-    v67 = "%s";
+    v67 = "%s\f%05u\t100%s\n";
   }
   sprintf(pTmpBuf, v67, v70, v75, v79);
   a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
   a4 = &a4[LOBYTE(v56->uFontHeight) - 6] + LOBYTE(v56->uFontHeight);
-  v95 = pGlobalTXT_LocalizationStrings[87];
-  v96 = pGlobalTXT_LocalizationStrings[6];
-  v97 = pGlobalTXT_LocalizationStrings[240];
-  v98 = pGlobalTXT_LocalizationStrings[70];
-  v99 = pGlobalTXT_LocalizationStrings[624];
-  v100 = pGlobalTXT_LocalizationStrings[138];
-  v101 = pGlobalTXT_LocalizationStrings[214];
-  v102 = pGlobalTXT_LocalizationStrings[142];
-  v103 = pGlobalTXT_LocalizationStrings[29];
-  v104 = pGlobalTXT_LocalizationStrings[133];
-  v105 = pGlobalTXT_LocalizationStrings[54];
+  v95[0] = pGlobalTXT_LocalizationStrings[87];
+  v95[1] = pGlobalTXT_LocalizationStrings[6];
+  v95[2] = pGlobalTXT_LocalizationStrings[240];
+  v95[3] = pGlobalTXT_LocalizationStrings[70];
+  v95[4] = pGlobalTXT_LocalizationStrings[624];
+  v95[5] = pGlobalTXT_LocalizationStrings[138];
+  v95[6] = pGlobalTXT_LocalizationStrings[214];
+  v95[7] = pGlobalTXT_LocalizationStrings[142];
+  v95[8] = pGlobalTXT_LocalizationStrings[29];
+  v95[9] = pGlobalTXT_LocalizationStrings[133];
+  v95[10] = pGlobalTXT_LocalizationStrings[54];
   if ( v116 )
   {
-    sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[18], 0, (&v95)[4 * v121->pMonsterInfo.uAttack1Type]);
+    sprintf(pTmpBuf, "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[18], 0, v95[v121->pMonsterInfo.uAttack1Type]);
     a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
     a4 = &a4[LOBYTE(v56->uFontHeight) - 3];
     v57 = v121->pMonsterInfo.uAttack1DamageBonus;
     if ( v57 )
       sprintf(
         pTmpBuf,
-        "%s",
+        "%s\f%05u\t080%dd%d+%d\n",
         pGlobalTXT_LocalizationStrings[53],
         0,
         v121->pMonsterInfo.uAttack1DamageDiceRolls,
@@ -3481,7 +3481,7 @@
     else
       sprintf(
         pTmpBuf,
-        "%s",
+        "%s\f%05u\t080%dd%d\n",
         pGlobalTXT_LocalizationStrings[53],
         0,
         v121->pMonsterInfo.uAttack1DamageDiceRolls,
@@ -3489,10 +3489,10 @@
   }
   else
   {
-    sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[18], 0, pGlobalTXT_LocalizationStrings[630]);
+    sprintf(pTmpBuf, "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[18], 0, pGlobalTXT_LocalizationStrings[630]);
     a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
     a4 = &a4[LOBYTE(v56->uFontHeight) - 3];
-    sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[53], 0, pGlobalTXT_LocalizationStrings[630]);
+    sprintf(pTmpBuf, "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[53], 0, pGlobalTXT_LocalizationStrings[630]);
   }
   a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
   v58 = LOBYTE(v56->uFontHeight);
@@ -3502,7 +3502,7 @@
     v80 = pGlobalTXT_LocalizationStrings[630];
     v76 = 0;
     v71 = pGlobalTXT_LocalizationStrings[628];
-    v68 = "%s";
+    v68 = "%s\f%05u\t080%s\n";
     goto LABEL_144;
   }
   v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[628];
@@ -3512,7 +3512,7 @@
     v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[629];
   if ( v114 )
   {
-    sprintf(pTmpBuf, "%s", v120, 0, pSpellStats->pInfos[v114].pShortName);
+    sprintf(pTmpBuf, "%s\f%05u\t060%s\n", v120, 0, pSpellStats->pInfos[v114].pShortName);
     a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
     v58 = LOBYTE(v56->uFontHeight);
     a4 = &a4[v58 - 3];
@@ -3521,9 +3521,7 @@
   v60 = v59->pMonsterInfo.uSpell2ID;
   if ( v60 )
   {
-    __debugbreak();
-    const char *fmt = "\xC\x25\x30\x35\x75\x9\x30\x36\x30\x25\x73\n";
-    sprintf(pTmpBuf, fmt, 0, pSpellStats->pInfos[v60].pShortName);
+    sprintf(pTmpBuf, "\f%05u\t060%s\n", 0, pSpellStats->pInfos[v60].pShortName);
     a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
     v58 = LOBYTE(v56->uFontHeight);
     a4 = &a4[v58 - 3];
@@ -3534,7 +3532,7 @@
     v80 = pGlobalTXT_LocalizationStrings[153];
     v76 = 0;
     v71 = pGlobalTXT_LocalizationStrings[628];
-    v68 = "%s";
+    v68 = "%s\f%05u\t060%s\n";
 LABEL_144:
     sprintf(pTmpBuf, v68, v71, v76, v80);
     a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
@@ -3544,33 +3542,32 @@
   a4 = &a4[v58 - 3];
   a1->DrawText(v56, 150, (int)a4, a5, pGlobalTXT_LocalizationStrings[626], 0, 0, 0);
   a4 = &a4[LOBYTE(v56->uFontHeight) - 3];
-  v85 = pGlobalTXT_LocalizationStrings[87];
-  v86 = pGlobalTXT_LocalizationStrings[6];
-  v87 = pGlobalTXT_LocalizationStrings[240];
-  v88 = pGlobalTXT_LocalizationStrings[70];
-  v89 = pGlobalTXT_LocalizationStrings[142];
-  v90 = pGlobalTXT_LocalizationStrings[214];
-  v91 = pGlobalTXT_LocalizationStrings[29];
-  v92 = pGlobalTXT_LocalizationStrings[133];
-  v93 = pGlobalTXT_LocalizationStrings[54];
-  v94 = pGlobalTXT_LocalizationStrings[624];
-  v96 = (char *)v121->pMonsterInfo.uResFire;
-  v97 = (char *)v121->pMonsterInfo.uResAir;
-  v98 = (char *)v121->pMonsterInfo.uResWater;
-  v99 = (char *)v121->pMonsterInfo.uResEarth;
-  v100 = (char *)v121->pMonsterInfo.uResMind;
-  v101 = (char *)v121->pMonsterInfo.uResSpirit;
-  v102 = (char *)v121->pMonsterInfo.uResBody;
-  v103 = (char *)v121->pMonsterInfo.uResLight;
-  v61 = (char *)v121->pMonsterInfo.uResPhysical;
-  v104 = (char *)v121->pMonsterInfo.uResDark;
-  v105 = v61;
+  v85[0] = pGlobalTXT_LocalizationStrings[87];
+  v85[1] = pGlobalTXT_LocalizationStrings[6];
+  v85[2] = pGlobalTXT_LocalizationStrings[240];
+  v85[3] = pGlobalTXT_LocalizationStrings[70];
+  v85[4] = pGlobalTXT_LocalizationStrings[142];
+  v85[5] = pGlobalTXT_LocalizationStrings[214];
+  v85[6] = pGlobalTXT_LocalizationStrings[29];
+  v85[7] = pGlobalTXT_LocalizationStrings[133];
+  v85[8] = pGlobalTXT_LocalizationStrings[54];
+  v85[9] = pGlobalTXT_LocalizationStrings[624];
+  v95[1] = (char *)v121->pMonsterInfo.uResFire;
+  v95[2] = (char *)v121->pMonsterInfo.uResAir;
+  v95[3] = (char *)v121->pMonsterInfo.uResWater;
+  v95[4] = (char *)v121->pMonsterInfo.uResEarth;
+  v95[5] = (char *)v121->pMonsterInfo.uResMind;
+  v95[6] = (char *)v121->pMonsterInfo.uResSpirit;
+  v95[7] = (char *)v121->pMonsterInfo.uResBody;
+  v95[8] = (char *)v121->pMonsterInfo.uResLight;
+  v95[9] = (char *)v121->pMonsterInfo.uResPhysical;
+  v95[10] = (char *)v121->pMonsterInfo.uResDark;
   if ( v112 )
   {
     v124 = 0;
     do
     {
-      v62 = (&v96)[v124];
+      v62 = v95[v124+1];
       if ( v62 == (char *)200 )
       {
         v81 = pGlobalTXT_LocalizationStrings[625];
@@ -3582,7 +3579,7 @@
         else
           v81 = pGlobalTXT_LocalizationStrings[153];
       }
-      sprintf(pTmpBuf, "%s", (&v85)[v124], 0, v81);
+      sprintf(pTmpBuf, "%s\f%05u\t070%s\n", v85[v124], 0, v81);
       a1->DrawText(v56, 170, (int)a4, a5, pTmpBuf, 0, 0, 0);
       v63 = LOBYTE(v56->uFontHeight);
       v124 += 4;
@@ -3596,7 +3593,7 @@
     i = 0;
     do
     {
-      sprintf(pTmpBuf, "%s", (&v85)[4 * i], 0, pGlobalTXT_LocalizationStrings[630]);
+      sprintf(pTmpBuf, "%s\f%05u\t070%s\n", v85[i], 0, pGlobalTXT_LocalizationStrings[630]); // "?"
       a1->DrawText(v56, 170, (int)a4, a5, pTmpBuf, 0, 0, 0);
       v65 = LOBYTE(v56->uFontHeight);
       ++i;
@@ -4089,7 +4086,7 @@
     if ( v22 == v5 )
     {
       if ( uActiveCharacter )
-        pPlayers[uActiveCharacter]->PlaySound(15, 0);
+        pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0);
       return 0;
     }
     v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v4->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
@@ -4386,7 +4383,7 @@
   v2 = pMapStats->GetMapInfo(pCurrentMapName);
   if ( !(*v1 & 1) || !v2 )
     goto LABEL_12;
-  if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].field_2D )
+  if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].LockX5 )
   {
     v29 = 811;
     v30 = 812;
@@ -4519,7 +4516,7 @@
   if ( *(float *)&sRotY != 0.0 )
   {
     if ( !dword_507CD8 )
-      pPlayers[uActiveCharacter]->PlaySound(4, 0);
+      pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0);
   }
   dword_507CD8 = 0;
   v3 = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Chest, a4, 0);
@@ -5178,7 +5175,7 @@
       v28 = pTmpBuf;
       v29 = pActor->dword_000334_unique_name;
       if ( v29 )
-        v40 = (char *)*(&pMonsterStats->pPlacement.uNumStrings + v29);
+        v40 = pMonsterStats->pPlaceStrings[v29];
       else
         v40 = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].pName;
       strncpy(pTmpBuf, v40, 0x7D0u);
@@ -5270,7 +5267,7 @@
         uLastPointedObjectID = pMouse->uPointingObjectID;
         return;
       }
-      pItemGen = (ItemGen *)&pPlayers[uActiveCharacter]->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v14 + 5];
+      pItemGen = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v14-1];
       //goto LABEL_49;
       v17 = pItemGen->GetDisplayName();
       sub_41C0B8_set_status_string(v17);
@@ -5657,65 +5654,67 @@
   if ( uActiveCharacter
     && (v2 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID)) != 0 )
   {
-    memcpy(&pPlayers[uActiveCharacter]->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5], &pParty->pPickedItem, 0x24u);
+    memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v2-1], &pParty->pPickedItem, 0x24u);
+	pMouse->RemoveHoldingItem();
   }
   else
   {
     v12 = 0;
     v3 = pParty->pPlayers;
-    while ( 1 )
+	while ( v3 <= &pParty->pPlayers[3] )
     {
       v4 = v3->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID);
       if ( v4 )
-        break;
-      ++v12;
+	  {
+		memcpy(&pParty->pPlayers[v12].pInventoryItems[v4], &pParty->pPickedItem, 0x24u);
+		pMouse->RemoveHoldingItem();
+		break;
+	  }
+	  ++v12;
       ++v3;
-      if ( (signed int)v3 >= (signed int)pParty->pHirelings )
-        goto LABEL_10;
-    }
-    memcpy(&pParty->pPlayers[v12].spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v4 + 5], &pParty->pPickedItem, 0x24u);
-    pMouse->RemoveHoldingItem();
-LABEL_10:
-    if ( v12 != 4 )
-      goto LABEL_18;
-    v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
-    v6 = 0;
-    a1.uItemType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
-    if ( (signed int)pObjectList->uNumObjects <= 0 )
-    {
-LABEL_15:
-      LOWORD(v6) = 0;
-    }
-    else
-    {
-      v7 = (char *)&pObjectList->pObjects->uObjectID;
-      while ( v5 != *(short *)v7 )
-      {
-        ++v6;
-        v7 += 56;
-        if ( v6 >= (signed int)pObjectList->uNumObjects )
-          goto LABEL_15;
-      }
-    }
-    a1.field_58 = 4;
-    a1.uObjectDescID = v6;
-    a1.vPosition.y = pParty->vPosition.y;
-    a1.vPosition.x = pParty->vPosition.x;
-    a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
-    a1.uSoundID = 0;
-    a1.uFacing = 0;
-    a1.uAttributes = 8;
-    v8 = pIndoor->GetSector(
-           pParty->vPosition.x,
-           pParty->vPosition.y,
-           pParty->sEyelevel + pParty->vPosition.z);
-    a1.uSpriteFrameID = 0;
-    a1.uSectorID = v8;
-    memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24));
-    a1.Create(pParty->sRotationY, 184, 200, 0);
-  }
-  pMouse->RemoveHoldingItem();
-LABEL_18:
+    }
+    if ( v12 == 4 )
+	{
+		v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
+		v6 = 0;
+		a1.uItemType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
+		if ( (signed int)pObjectList->uNumObjects <= 0 )
+		{
+		  LOWORD(v6) = 0;
+		}
+		else
+		{
+		  v7 = (char *)&pObjectList->pObjects->uObjectID;
+		  while ( v5 != *(short *)v7 )
+		  {
+			++v6;
+			v7 += 56;
+			if ( v6 >= (signed int)pObjectList->uNumObjects )
+			{
+				LOWORD(v6) = 0;
+				break;
+			}
+		  }
+		}
+		a1.field_58 = 4;
+		a1.uObjectDescID = v6;
+		a1.vPosition.y = pParty->vPosition.y;
+		a1.vPosition.x = pParty->vPosition.x;
+		a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
+		a1.uSoundID = 0;
+		a1.uFacing = 0;
+		a1.uAttributes = 8;
+		v8 = pIndoor->GetSector(
+			   pParty->vPosition.x,
+			   pParty->vPosition.y,
+			   pParty->sEyelevel + pParty->vPosition.z);
+		a1.uSpriteFrameID = 0;
+		a1.uSectorID = v8;
+		memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24));
+		a1.Create(pParty->sRotationY, 184, 200, 0);
+		pMouse->RemoveHoldingItem();
+	}
+  }
   if ( !v11 )
   {
     v1->Release();
@@ -5728,46 +5727,45 @@
 //----- (00421D00) --------------------------------------------------------
 void __fastcall GameUI_OnPlayerPortraitLeftClick(unsigned int uPlayerID)
 {
-  unsigned int v1; // esi@1
-  int v2; // eax@2
-  Player *v3; // ecx@2
-  Player *v4; // ecx@5
+  //unsigned int v1; // esi@1
+  //int v2; // eax@2
+  //Player *v3; // ecx@2
+  //Player *v4; // ecx@5
   unsigned int v5; // [sp-4h] [bp-10h]@21
 
-  v1 = uPlayerID;
-  if ( pParty->pPickedItem.uItemID )
-  {
-    v2 = pPlayers[uPlayerID]->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID);
-    v3 = pPlayers[v1];
-    if ( v2 )
-    {
-      memcpy(&v3->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5], &pParty->pPickedItem, 0x24u);
-      viewparams->bRedrawGameUI = 1;
+  //v1 = uPlayerID;
+  auto player = &pParty->pPlayers[uPlayerID - 1];
+  if (pParty->pPickedItem.uItemID)
+  {
+    //v3 = player;
+    if (auto slot = player->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID))
+    {
+      memcpy(&player->pInventoryItems[slot-1], &pParty->pPickedItem, 0x24u);
+      viewparams->bRedrawGameUI = true;
       pMouse->RemoveHoldingItem();
       return;
     }
-    if ( v3->CanAct() )
-    {
-      v4 = pPlayers[v1];
-    }
-    else
-    {
-      if ( !pPlayers[uActiveCharacter]->CanAct() )
+
+    if (!player->CanAct())
+    {
+      if ( pPlayers[uActiveCharacter]->CanAct())
         goto LABEL_9;
-      v4 = pPlayers[uActiveCharacter];
-    }
-    v4->PlaySound(15, 0);
-  }
+      player = pPlayers[uActiveCharacter];
+    }
+    player->PlaySound(SPEECH_NoRoom, 0);
+  }
+
 LABEL_9:
-  if ( !pCurrentScreen )
-  {
-    viewparams->bRedrawGameUI = 1;
-    if ( uActiveCharacter != v1 )
+  if (pCurrentScreen == SCREEN_GAME)
+  {
+    viewparams->bRedrawGameUI = true;
+    if ( uActiveCharacter != uPlayerID )
       //goto LABEL_27;
     {
-      if ( pPlayers[v1]->uTimeToRecovery )
+      if ( pPlayers[uPlayerID]->uTimeToRecovery )
         return;
-      uActiveCharacter = v1;
+
+      uActiveCharacter = uPlayerID;
       return;
     }
     v5 = 7;
@@ -5780,20 +5778,20 @@
   if ( pCurrentScreen == SCREEN_CHEST )
   {
 //LABEL_23:
-    viewparams->bRedrawGameUI = 1;
-    if ( uActiveCharacter == v1 )
+    viewparams->bRedrawGameUI = true;
+    if ( uActiveCharacter == uPlayerID )
     {
       pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
       pCurrentScreen = SCREEN_F;
       //goto LABEL_28;
-      uActiveCharacter = v1;
+      uActiveCharacter = uPlayerID;
       return;
     }
 //LABEL_27:
-    if ( pPlayers[v1]->uTimeToRecovery )
+    if ( pPlayers[uPlayerID]->uTimeToRecovery )
       return;
     //goto LABEL_28;
-    uActiveCharacter = v1;
+    uActiveCharacter = uPlayerID;
     return;
   }
   if ( pCurrentScreen != SCREEN_HOUSE )
@@ -5801,40 +5799,40 @@
     if ( pCurrentScreen == SCREEN_E )
     {
 //LABEL_28:
-      uActiveCharacter = v1;
+      uActiveCharacter = uPlayerID;
       return;
     }
     if ( pCurrentScreen != SCREEN_F )
     {
-      viewparams->bRedrawGameUI = 1;
-      uActiveCharacter = v1;
+      viewparams->bRedrawGameUI = true;
+      uActiveCharacter = uPlayerID;
       if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 102 )
         sub_419100();
       return;
     }
     //goto LABEL_23;
-    viewparams->bRedrawGameUI = 1;
-    if ( uActiveCharacter == v1 )
+    viewparams->bRedrawGameUI = true;
+    if ( uActiveCharacter == uPlayerID )
     {
       pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
       pCurrentScreen = SCREEN_F;
       //goto LABEL_28;
-      uActiveCharacter = v1;
+      uActiveCharacter = uPlayerID;
       return;
     }
 //LABEL_27:
-    if ( pPlayers[v1]->uTimeToRecovery )
+    if ( pPlayers[uPlayerID]->uTimeToRecovery )
       return;
     //goto LABEL_28;
-    uActiveCharacter = v1;
+    uActiveCharacter = uPlayerID;
     return;
   }
   if ( ptr_507BC0->field_40 == 1 )
     return;
-  viewparams->bRedrawGameUI = 1;
-  if ( uActiveCharacter != v1 )
+  viewparams->bRedrawGameUI = true;
+  if ( uActiveCharacter != uPlayerID )
     //goto LABEL_28;
-    uActiveCharacter = v1;
+    uActiveCharacter = uPlayerID;
     return;
   if ( dword_F8B19C == 2 || dword_F8B19C == 6 )
   {
@@ -5895,7 +5893,7 @@
       *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1;
       *((int *)pGUIWindow_Settings->ptr_1C + 3) = v6 - 1;
       *((short *)pGUIWindow_Settings->ptr_1C + 3) = a4;
-      ptr_50C9A4 = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6 + 5];
+      ptr_50C9A4 = (ItemGen *)&v0->pInventoryItems[v6-1];
       unk_50C9A0 = 0;
       if ( pMessageQueue_50CBD0->uNumMessages )
         pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -5914,7 +5912,7 @@
   {
     if ( !v8 )
       return;
-    memcpy(&pParty->pPickedItem, &v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5], sizeof(pParty->pPickedItem));
+    memcpy(&pParty->pPickedItem, &v0->pInventoryItems[v8-1], sizeof(pParty->pPickedItem));
     v0->RemoveItemAtInventoryIndex(a4);
     v9 = pParty->pPickedItem.uItemID;
     goto LABEL_24;
@@ -5922,7 +5920,7 @@
   v13 = v8;
   if ( v8 )
   {
-    a2.y = (LONG)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5];
+    a2.y = (LONG)&v0->pInventoryItems[v8-1];
     memcpy(&this_, (const void *)a2.y, sizeof(this_));
     v0->RemoveItemAtInventoryIndex(a4);
     pX = v0->AddItem2(a4, &pParty->pPickedItem);
@@ -5946,7 +5944,7 @@
   pX = v10;
   if ( v10 || (v10 = v0->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID), (pX = v10) != 0) )
   {
-    memcpy(&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v10 + 5], &pParty->pPickedItem, 0x24u);
+    memcpy(&v0->pInventoryItems[v10-1], &pParty->pPickedItem, 0x24u);
     pMouse->RemoveHoldingItem();
   }
 }
--- a/mm7_2.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/mm7_2.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -32,7 +32,6 @@
 #include "Time.h"
 #include "IconFrameTable.h"
 #include "GUIProgressBar.h"
-#include "stru157.h"
 #include "Bink_Smacker.h"
 #include "TileFrameTable.h"
 #include "PlayerFrameTable.h"
@@ -51,6 +50,7 @@
 #include "Events2D.h"
 #include "stru159.h"
 #include "Log.h"
+#include "texts.h"
 
 #include "mm7_data.h"
 
@@ -243,7 +243,7 @@
         if ( pParty->uFine < 0 )
           pParty->uFine = 0;
         if ( uActiveCharacter )
-          pPlayers[uActiveCharacter]->PlaySound(81, 0);
+          pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0);
         v0 = ptr_507BC0;
       }
       else
@@ -347,7 +347,7 @@
             Party::TakeGold(v7);
             pParty->uNumGoldInBank += v7;
             if ( uActiveCharacter )
-              pPlayers[uActiveCharacter]->PlaySound(81, 0);
+              pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0);
           }
           v0 = ptr_507BC0;
 LABEL_16:
@@ -743,7 +743,7 @@
         {
           ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2u);
           if ( uActiveCharacter )
-            pPlayers[uActiveCharacter]->PlaySound(67, 0);
+            pPlayers[uActiveCharacter]->PlaySound(SPEECH_67, 0);
           goto LABEL_43;
         }
         if ( pParty->uNumGold >= v7 )
@@ -2869,7 +2869,7 @@
     v124 = 0;
     v122 = 3;
     v120 = ptr_507BC0->ptr_1C;
-    v116 = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v10 + 5];
+    v116 = (ItemGen *)&v0->pInventoryItems[v10-1];
     v12 = (int)ptr_507BC0->ptr_1C;
     uPlayerID = uActiveCharacter - 1;
     v13 = v0->_490EEE(v116, 2, v12, 3);
@@ -2893,7 +2893,7 @@
           v2 = v0->GetItemIDAtInventoryIndex((int *)&v149);
           if ( v2 )
           {
-            v3 = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5];
+            v3 = (ItemGen *)&v0->pInventoryItems[v2-1];
             if ( v3->uAttributes & 1 )
             {
               v118 = ptr_507BC0->ptr_1C;
@@ -4188,7 +4188,7 @@
                     Party::TakeGold(v37);
                     dword_F8B1E4 = 1;
                     *(short *)v38 = 1;
-                    v35->PlaySound(78, 0);
+                    v35->PlaySound(SPEECH_78, 0);
                   }
                 }
               }
@@ -4596,10 +4596,10 @@
     {
       v26 = 1;
       v20->uAttributes |= 1u;
-      memcpy(&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v25 + 5], v20, 0x24u);
+      memcpy(&v0->pInventoryItems[v25-1], v20, 0x24u);
       goto LABEL_42;
     }
-    v0->PlaySound(15, 0);
+    v0->PlaySound(SPEECH_NoRoom, 0);
     v54 = 5;
 LABEL_70:
     v9 = pGlobalTXT_LocalizationStrings[563];   // "Pack is Full!"
@@ -4689,12 +4689,12 @@
       pRenderer->ClearZBuffer(0, 479);
       v27 = v77;
       v53 = 0;
-      v51 = 75;
+      v51 = SPEECH_75;
 LABEL_81:
-      v27->PlaySound(v51, v53);
+      v27->PlaySound((PlayerSpeech)v51, v53);
       return;
     }
-    v0->PlaySound(15, 0);
+    v0->PlaySound(SPEECH_NoRoom, 0);
     v54 = 2;
     goto LABEL_70;
   }
@@ -4707,7 +4707,7 @@
       || (v15 = v0->GetItemIDAtInventoryIndex((int *)&v79), (v77 = (Player *)v15) == 0) )
       return;
     v16 = ptr_507BC0;
-    if ( sub_4BDAAF((ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v15 + 5], (int)ptr_507BC0->ptr_1C) )
+    if ( sub_4BDAAF((ItemGen *)&v0->pInventoryItems[v15-1], (int)ptr_507BC0->ptr_1C) )
     {
       dword_F8B1E4 = 1;
       v0->_4BE2DD(v79, (int)((char *)v77 - 1), (int)v16->ptr_1C);
@@ -4717,7 +4717,7 @@
       v51 = 77;
       goto LABEL_80;
     }
-    v0->PlaySound(79, 0);
+    v0->PlaySound(SPEECH_79, 0);
     v56 = 0;
     v52 = 0;
     v50 = 0;
@@ -4742,7 +4742,7 @@
         {
           //v80 = v0->_4B8179(p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C]);
           v80 = v0->_4B8179(p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].fPriceMultiplier);
-          v12 = (int)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v11 + 5];
+          v12 = (int)&v0->pInventoryItems[v11-1];
           if ( !(*(char *)(v12 + 20) & 1) )
           {
             _this = (ItemGen *)ptr_507BC0->ptr_1C;
@@ -4753,7 +4753,7 @@
                 dword_F8B1E4 = 1;
                 Party::TakeGold(v80);
                 *(int *)(v12 + 20) |= 1u;
-                v0->PlaySound(73, 0);
+                v0->PlaySound(SPEECH_73, 0);
                 v9 = pGlobalTXT_LocalizationStrings[569];
                 goto LABEL_25;
               }
@@ -4784,11 +4784,11 @@
           v2 = v0->GetItemIDAtInventoryIndex((int *)&v79);
           if ( v2 )
           {
-            v3 = (int)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5];
+            v3 = (int)&v0->pInventoryItems[v2-1];
             //v4 = p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C];
             v4 = p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].fPriceMultiplier;
 
-            auto _v = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5];
+            auto _v = (ItemGen *)&v0->pInventoryItems[v2-1];
             v5 = _v->GetValue();
 
             v6 = v0->_4B81C3(v5, v4);
@@ -4806,7 +4806,7 @@
                   v8 = *(int *)(v3 + 20);
                   LOBYTE(v8) = v8 & 0xFD;
                   *(int *)(v3 + 20) = v8 | 1;
-                  v0->PlaySound(74, 0);
+                  v0->PlaySound(SPEECH_74, 0);
                   v9 = pGlobalTXT_LocalizationStrings[570];
 LABEL_25:
                   v54 = 2;
@@ -4872,10 +4872,11 @@
   static_stru_F8BA58.field_0 = 0;
   if ( _this && *_this )
   {
-    v2 = (char *)&unk_F8B668;
+    int i = 0;
+    v2 = (char *)&array_F8B668;
     v3 = 1;
     v7 = 0;
-    v4 = _this - (char *)&unk_F8B668;
+    v4 = _this - (char *)&array_F8B668;
     do
     {
       v5 = v2[v4];
@@ -4920,8 +4921,9 @@
       if ( static_stru_F8BA58.field_0 >= 30 )
         break;
       ++v2;
-    }
-    while ( (unsigned int)v2 < (unsigned int)&unk_F8BA50 );
+      ++i;
+    }
+    while (i < 1000);
     *v2 = 0;
   }
   result = a2;
@@ -7563,7 +7565,7 @@
         v11 = pMapInfo->uEncounterMonster1AtMost;
         pTexture = pMapInfo->pEncounterMonster1Texture;
         v12 = v10 % (v11 - v9 + 1);
-        v13 = pMapInfo->field_34;
+        v13 = pMapInfo->Dif_M1;
         goto LABEL_20;
     case 3u:
         pTexture = pMapInfo->pEncounterMonster1Texture;
@@ -7583,7 +7585,7 @@
         v15 = pMapInfo->uEncounterMonster2AtMost;
         pTexture = pMapInfo->pEncounterMonster2Texture;
         v12 = v14 % (v15 - v9 + 1);
-        v13 = pMapInfo->field_37;
+        v13 = pMapInfo->Dif_M2;
         goto LABEL_20;
     case 6u:
         pTexture = pMapInfo->pEncounterMonster1Texture;
@@ -7603,7 +7605,7 @@
         v17 = pMapInfo->uEncounterMonster3AtMost;
         pTexture = pMapInfo->pEncounterMonster3Texture;
         v12 = v16 % (v17 - v9 + 1);
-        v13 = pMapInfo->field_3A;
+        v13 = pMapInfo->Dif_M3;
 LABEL_20:
         v57 = v13;
         v56 = v9 + v12;
@@ -7934,7 +7936,7 @@
   v4 = rand();
   v34 = 0;
   v5 = v4 % 100;
-  v6 = 2 * (v2->field_2F + 7 * v3->uIndex) - 14;
+  v6 = 2 * (v2->Treasure_prob + 7 * v3->uIndex) - 14;
   v7 = (unsigned __int8)byte_4E8168[v6 + 16];
   v8 = (unsigned __int8)byte_4E8168[v6 + 17];
   v32 = v5;
@@ -8112,8 +8114,8 @@
       if ( (v3->uItemID & 0x80000000u) == 0 )
         goto LABEL_56;
       v4 = rand() % 5 + 1;
-      v5 = (unsigned __int8)byte_4E8168[2 * (v2->field_2F + 7 * abs((int)v3->uItemID)) + 2];
-      v6 = (unsigned __int8)byte_4E8168[2 * (v2->field_2F + 7 * abs((int)v3->uItemID)) + 3];
+      v5 = (unsigned __int8)byte_4E8168[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 2];
+      v6 = (unsigned __int8)byte_4E8168[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 3];
       v7 = rand();
       v8 = v6 - v5 + 1;
       v9 = v5 + v7 % v8;
@@ -9236,804 +9238,335 @@
 }
 
 
-//----- (00452B95) --------------------------------------------------------
-void __cdecl SetSomeItemsNames()
-{
-  pSomeItemsNames[0] = pGlobalTXT_LocalizationStrings[568];
-  pSomeItemsNames[1] = pGlobalTXT_LocalizationStrings[271];
-  pSomeItemsNames[2] = pGlobalTXT_LocalizationStrings[272];
-  pSomeItemsNames[3] = pGlobalTXT_LocalizationStrings[273];
-  pSomeItemsNames[4] = pGlobalTXT_LocalizationStrings[274];
-  pSomeItemsNames[5] = pGlobalTXT_LocalizationStrings[275];
-  pSomeItemsNames[6] = pGlobalTXT_LocalizationStrings[276];
-  pSomeItemsNames[7] = pGlobalTXT_LocalizationStrings[277];
-  pSomeItemsNames[8] = pGlobalTXT_LocalizationStrings[278];
-  pSomeItemsNames[9] = pGlobalTXT_LocalizationStrings[279];
-  pSomeItemsNames[10] = pGlobalTXT_LocalizationStrings[280];
-  pSomeItemsNames[11] = pGlobalTXT_LocalizationStrings[281];
-  pSomeItemsNames[12] = pGlobalTXT_LocalizationStrings[282];
-  pSomeItemsNames[13] = pGlobalTXT_LocalizationStrings[143];
-  memset(&stru_5E4C50, 0, sizeof(stru_5E4C50));
-}
-
-//----- (00452C30) --------------------------------------------------------
-char *RemoveQuotes(char *Str)
-{
-  char *v1; // esi@1
-
-  v1 = Str;
-  if ( *Str == '"' )
-  {
-    Str[strlen(Str) - 1] = 0;
-    v1 = Str + 1;
-  }
-  return v1;
-}
-
-//----- (00452C49) --------------------------------------------------------
-void InitializeGameText()
-{
-  //char *v0; // ebx@1
-  char *v1; // eax@3
-  int v2; // ebp@4
-  char v3; // dl@5
-  char *v4; // ecx@5
-  int v5; // esi@9
-  //char **v6; // [sp+10h] [bp-8h]@3
-  signed int v7; // [sp+14h] [bp-4h]@4
-
-  //v0 = 0;
-  if (pGlobalTXT_Raw)
-    pAllocator->FreeChunk(pGlobalTXT_Raw);
-
-  pGlobalTXT_Raw = nullptr;
-  pGlobalTXT_Raw = (char *)pEvents_LOD->LoadRaw("global.txt", 0);
-
-  strtok(pGlobalTXT_Raw, "\r");
-  strtok(nullptr, "\r");
-  v1 = strtok(nullptr, "\r") + 1;
-
-  for (uint i = 0; i < 677; ++i)
-  {
-    char *p = v1;
-    while (*++p != '\t' && *p);
-
-    pGlobalTXT_LocalizationStrings[i] = RemoveQuotes(p + 1);
-
-    v1 = strtok(nullptr, "\r") + 1;
-  }
-
-  aMonthNames[0] = pGlobalTXT_LocalizationStrings[415];
-  aMonthNames[1] = pGlobalTXT_LocalizationStrings[416];
-  aMonthNames[2] = pGlobalTXT_LocalizationStrings[417];
-  pSomeItemsNames[10] = pGlobalTXT_LocalizationStrings[280];
-  aMonthNames[3] = pGlobalTXT_LocalizationStrings[418];
-  pSomeItemsNames[11] = pGlobalTXT_LocalizationStrings[281];
-  aMonthNames[4] = pGlobalTXT_LocalizationStrings[419];
-  pSomeItemsNames[12] = pGlobalTXT_LocalizationStrings[282];
-  aMonthNames[5] = pGlobalTXT_LocalizationStrings[420];
-  pSomeItemsNames[13] = pGlobalTXT_LocalizationStrings[143];
-  aMonthNames[6] = pGlobalTXT_LocalizationStrings[421];
-  aCharacterConditionNames[0] = pGlobalTXT_LocalizationStrings[52];
-  aMonthNames[7] = pGlobalTXT_LocalizationStrings[422];
-  aCharacterConditionNames[1] = pGlobalTXT_LocalizationStrings[241];
-  aMonthNames[8] = pGlobalTXT_LocalizationStrings[423];
-  aCharacterConditionNames[2] = pGlobalTXT_LocalizationStrings[14];
-  aMonthNames[9] = pGlobalTXT_LocalizationStrings[424];
-  aCharacterConditionNames[3] = pGlobalTXT_LocalizationStrings[4];
-  aMonthNames[10] = pGlobalTXT_LocalizationStrings[425];
-  aCharacterConditionNames[4] = pGlobalTXT_LocalizationStrings[69];
-  aMonthNames[11] = pGlobalTXT_LocalizationStrings[426];
-  aCharacterConditionNames[5] = pGlobalTXT_LocalizationStrings[117];
-  pSomeItemsNames[0] = pGlobalTXT_LocalizationStrings[568];
-  aCharacterConditionNames[6] = pGlobalTXT_LocalizationStrings[166];
-  aCharacterConditionNames[8] = pGlobalTXT_LocalizationStrings[166];
-  aCharacterConditionNames[10] = pGlobalTXT_LocalizationStrings[166];
-  pSomeItemsNames[5] = pGlobalTXT_LocalizationStrings[275];
-  aCharacterConditionNames[12] = pGlobalTXT_LocalizationStrings[162];
-  pSomeItemsNames[6] = pGlobalTXT_LocalizationStrings[276];
-  aCharacterConditionNames[13] = pGlobalTXT_LocalizationStrings[231];
-  pSomeItemsNames[7] = pGlobalTXT_LocalizationStrings[277];
-  aCharacterConditionNames[14] = pGlobalTXT_LocalizationStrings[58];
-  pSomeItemsNames[8] = pGlobalTXT_LocalizationStrings[278];
-  aCharacterConditionNames[15] = pGlobalTXT_LocalizationStrings[220];
-  pSomeItemsNames[1] = pGlobalTXT_LocalizationStrings[271];
-  pSomeItemsNames[2] = pGlobalTXT_LocalizationStrings[272];
-  pSomeItemsNames[3] = pGlobalTXT_LocalizationStrings[273];
-  pSomeItemsNames[4] = pGlobalTXT_LocalizationStrings[274];
-  pSomeItemsNames[9] = pGlobalTXT_LocalizationStrings[279];
-  aCharacterConditionNames[7] = pGlobalTXT_LocalizationStrings[65];
-  aCharacterConditionNames[9] = pGlobalTXT_LocalizationStrings[65];
-  aCharacterConditionNames[11] = pGlobalTXT_LocalizationStrings[65];
-  aCharacterConditionNames[16] = pGlobalTXT_LocalizationStrings[76];
-  pClassNames[9] = pGlobalTXT_LocalizationStrings[26];
-  pClassNames[10] = pGlobalTXT_LocalizationStrings[432];
-  pClassNames[11] = pGlobalTXT_LocalizationStrings[27];
-  pClassNames[12] = pGlobalTXT_LocalizationStrings[262];
-  pClassNames[13] = pGlobalTXT_LocalizationStrings[263];
-  pClassNames[14] = pGlobalTXT_LocalizationStrings[264];
-  pClassNames[15] = pGlobalTXT_LocalizationStrings[28];
-  pClassNames[16] = pGlobalTXT_LocalizationStrings[265];
-  pClassNames[17] = pGlobalTXT_LocalizationStrings[267];
-  pClassNames[18] = pGlobalTXT_LocalizationStrings[119];
-  pClassNames[19] = pGlobalTXT_LocalizationStrings[124];
-  pClassNames[20] = pGlobalTXT_LocalizationStrings[31];
-  pClassNames[21] = pGlobalTXT_LocalizationStrings[370];
-  pClassNames[22] = pGlobalTXT_LocalizationStrings[33];
-  aCharacterConditionNames[17] = pGlobalTXT_LocalizationStrings[601];
-  pClassNames[23] = pGlobalTXT_LocalizationStrings[40];
-  aCharacterConditionNames[18] = pGlobalTXT_LocalizationStrings[98];
-  pClassNames[24] = pGlobalTXT_LocalizationStrings[256];
-  pClassNames[0] = pGlobalTXT_LocalizationStrings[253];
-  pClassNames[25] = pGlobalTXT_LocalizationStrings[257];
-  pClassNames[1] = pGlobalTXT_LocalizationStrings[254];
-  pClassNames[26] = pGlobalTXT_LocalizationStrings[44];
-  pClassNames[2] = pGlobalTXT_LocalizationStrings[255];
-  pClassNames[27] = pGlobalTXT_LocalizationStrings[46];
-  pClassNames[3] = pGlobalTXT_LocalizationStrings[2];
-  pClassNames[28] = pGlobalTXT_LocalizationStrings[268];
-  pClassNames[4] = pGlobalTXT_LocalizationStrings[307];
-  pClassNames[29] = pGlobalTXT_LocalizationStrings[269];
-  pClassNames[5] = pGlobalTXT_LocalizationStrings[114];
-  pClassNames[30] = pGlobalTXT_LocalizationStrings[270];
-  pClassNames[6] = pGlobalTXT_LocalizationStrings[3];
-  pClassNames[31] = pGlobalTXT_LocalizationStrings[48];
-  pClassNames[7] = pGlobalTXT_LocalizationStrings[13];
-  pClassNames[32] = pGlobalTXT_LocalizationStrings[259];
-  pClassNames[8] = pGlobalTXT_LocalizationStrings[21];
-  pClassNames[33] = pGlobalTXT_LocalizationStrings[260];
-  pClassNames[34] = pGlobalTXT_LocalizationStrings[261];
-  pClassNames[35] = pGlobalTXT_LocalizationStrings[49];
-  pSkillNames[0] = pGlobalTXT_LocalizationStrings[271];
-  pSkillNames[1] = pGlobalTXT_LocalizationStrings[272];
-  pSkillNames[2] = pGlobalTXT_LocalizationStrings[273];
-  pSkillNames[3] = pGlobalTXT_LocalizationStrings[274];
-  pSkillNames[4] = pGlobalTXT_LocalizationStrings[275];
-  pSkillNames[5] = pGlobalTXT_LocalizationStrings[276];
-  pSkillNames[6] = pGlobalTXT_LocalizationStrings[277];
-  pSkillNames[7] = pGlobalTXT_LocalizationStrings[278];
-  pSkillNames[23] = pGlobalTXT_LocalizationStrings[294];
-  pSkillNames[9] = pGlobalTXT_LocalizationStrings[280];
-  pSkillNames[24] = pGlobalTXT_LocalizationStrings[295];
-  pSkillNames[10] = pGlobalTXT_LocalizationStrings[281];
-  pSkillNames[25] = pGlobalTXT_LocalizationStrings[296];
-  pSkillNames[11] = pGlobalTXT_LocalizationStrings[282];
-  pSkillNames[26] = pGlobalTXT_LocalizationStrings[297];
-  pSkillNames[12] = pGlobalTXT_LocalizationStrings[283];
-  pSkillNames[27] = pGlobalTXT_LocalizationStrings[298];
-  pSkillNames[13] = pGlobalTXT_LocalizationStrings[284];
-  pSkillNames[28] = pGlobalTXT_LocalizationStrings[299];
-  pSkillNames[14] = pGlobalTXT_LocalizationStrings[285];
-  pSkillNames[29] = pGlobalTXT_LocalizationStrings[300];
-  pSkillNames[15] = pGlobalTXT_LocalizationStrings[286];
-  pSkillNames[30] = pGlobalTXT_LocalizationStrings[50];
-  pSkillNames[16] = pGlobalTXT_LocalizationStrings[289];
-  pSkillNames[31] = pGlobalTXT_LocalizationStrings[77];
-  aDayNames[0] = pGlobalTXT_LocalizationStrings[145];
-  pSkillNames[17] = pGlobalTXT_LocalizationStrings[290];
-  pSkillNames[32] = pGlobalTXT_LocalizationStrings[88];
-  aDayNames[1] = pGlobalTXT_LocalizationStrings[230];
-  pSkillNames[18] = pGlobalTXT_LocalizationStrings[291];
-  pSkillNames[33] = pGlobalTXT_LocalizationStrings[89];
-  aDayNames[2] = pGlobalTXT_LocalizationStrings[243];
-  pSkillNames[19] = pGlobalTXT_LocalizationStrings[287];
-  pSkillNames[34] = pGlobalTXT_LocalizationStrings[90];
-  aDayNames[3] = pGlobalTXT_LocalizationStrings[227];
-  pSkillNames[20] = pGlobalTXT_LocalizationStrings[288];
-  pSkillNames[35] = pGlobalTXT_LocalizationStrings[95];
-  aDayNames[4] = pGlobalTXT_LocalizationStrings[91];
-  pSkillNames[21] = pGlobalTXT_LocalizationStrings[292];
-  pSkillNames[36] = pGlobalTXT_LocalizationStrings[301];
-  aDayNames[5] = pGlobalTXT_LocalizationStrings[188];
-  pSkillNames[8] = pGlobalTXT_LocalizationStrings[279];
-  pSkillNames[22] = pGlobalTXT_LocalizationStrings[293];
-  pSkillNames[37] = pGlobalTXT_LocalizationStrings[153];
-  aDayNames[6] = pGlobalTXT_LocalizationStrings[222];
-  aNPCProfessionNames[0] = pGlobalTXT_LocalizationStrings[153];
-  aNPCProfessionNames[1] = pGlobalTXT_LocalizationStrings[308];
-  aNPCProfessionNames[2] = pGlobalTXT_LocalizationStrings[309];
-  aNPCProfessionNames[3] = pGlobalTXT_LocalizationStrings[7];
-  aNPCProfessionNames[4] = pGlobalTXT_LocalizationStrings[306];
-  aNPCProfessionNames[5] = pGlobalTXT_LocalizationStrings[310];
-  aNPCProfessionNames[6] = pGlobalTXT_LocalizationStrings[311];
-  aNPCProfessionNames[7] = pGlobalTXT_LocalizationStrings[312];
-  aSpellSchoolNames[0] = pGlobalTXT_LocalizationStrings[87];
-  aNPCProfessionNames[8] = pGlobalTXT_LocalizationStrings[313];
-  aSpellSchoolNames[1] = pGlobalTXT_LocalizationStrings[6];
-  aNPCProfessionNames[9] = pGlobalTXT_LocalizationStrings[314];
-  aNPCProfessionNames[21] = pGlobalTXT_LocalizationStrings[293];
-  aNPCProfessionNames[10] = pGlobalTXT_LocalizationStrings[105];
-  aSpellSchoolNames[2] = pGlobalTXT_LocalizationStrings[240];
-  aNPCProfessionNames[11] = pGlobalTXT_LocalizationStrings[315];
-  aNPCProfessionNames[22] = pGlobalTXT_LocalizationStrings[324];
-  aNPCProfessionNames[12] = pGlobalTXT_LocalizationStrings[316];
-  aSpellSchoolNames[3] = pGlobalTXT_LocalizationStrings[70];
-  aNPCProfessionNames[13] = pGlobalTXT_LocalizationStrings[317];
-  aNPCProfessionNames[23] = pGlobalTXT_LocalizationStrings[498];
-  aSpellSchoolNames[4] = pGlobalTXT_LocalizationStrings[214];
-  aNPCProfessionNames[14] = pGlobalTXT_LocalizationStrings[115];
-  aNPCProfessionNames[24] = pGlobalTXT_LocalizationStrings[525];
-  aSpellSchoolNames[5] = pGlobalTXT_LocalizationStrings[142];
-  aNPCProfessionNames[15] = pGlobalTXT_LocalizationStrings[318];
-  aNPCProfessionNames[25] = pGlobalTXT_LocalizationStrings[327];
-  aSpellSchoolNames[6] = pGlobalTXT_LocalizationStrings[29];
-  aNPCProfessionNames[16] = pGlobalTXT_LocalizationStrings[319];
-  aNPCProfessionNames[26] = pGlobalTXT_LocalizationStrings[328];
-  aSpellSchoolNames[7] = pGlobalTXT_LocalizationStrings[133];
-  aNPCProfessionNames[17] = pGlobalTXT_LocalizationStrings[320];
-  aNPCProfessionNames[27] = pGlobalTXT_LocalizationStrings[329];
-  aSpellSchoolNames[8] = pGlobalTXT_LocalizationStrings[54];
-  aNPCProfessionNames[18] = pGlobalTXT_LocalizationStrings[321];
-  aNPCProfessionNames[28] = pGlobalTXT_LocalizationStrings[330];
-  aAMPMNames[0] = pGlobalTXT_LocalizationStrings[472];
-  aNPCProfessionNames[19] = pGlobalTXT_LocalizationStrings[322];
-  aNPCProfessionNames[29] = pGlobalTXT_LocalizationStrings[331];
-  aAMPMNames[1] = pGlobalTXT_LocalizationStrings[473];
-  aNPCProfessionNames[20] = pGlobalTXT_LocalizationStrings[323];
-  aNPCProfessionNames[30] = pGlobalTXT_LocalizationStrings[332];
-  aNPCProfessionNames[31] = pGlobalTXT_LocalizationStrings[333];
-  aNPCProfessionNames[32] = pGlobalTXT_LocalizationStrings[334];
-  aNPCProfessionNames[33] = pGlobalTXT_LocalizationStrings[335];
-  aNPCProfessionNames[34] = pGlobalTXT_LocalizationStrings[336];
-  aNPCProfessionNames[35] = pGlobalTXT_LocalizationStrings[337];
-  aNPCProfessionNames[36] = pGlobalTXT_LocalizationStrings[338];
-  aNPCProfessionNames[37] = pGlobalTXT_LocalizationStrings[339];
-  aNPCProfessionNames[38] = pGlobalTXT_LocalizationStrings[340];
-  aNPCProfessionNames[39] = pGlobalTXT_LocalizationStrings[341];
-  aNPCProfessionNames[40] = pGlobalTXT_LocalizationStrings[342];
-  aNPCProfessionNames[56] = pGlobalTXT_LocalizationStrings[21];
-  aNPCProfessionNames[41] = pGlobalTXT_LocalizationStrings[343];
-  aNPCProfessionNames[57] = pGlobalTXT_LocalizationStrings[600];
-  aNPCProfessionNames[42] = pGlobalTXT_LocalizationStrings[596];
-  aNPCProfessionNames[58] = pGlobalTXT_LocalizationStrings[370];
-  aNPCProfessionNames[43] = pGlobalTXT_LocalizationStrings[345];
-  aMoonPhaseNames[0] = pGlobalTXT_LocalizationStrings[150];
-  aNPCProfessionNames[44] = pGlobalTXT_LocalizationStrings[346];
-  aMoonPhaseNames[1] = pGlobalTXT_LocalizationStrings[171];
-  aNPCProfessionNames[45] = pGlobalTXT_LocalizationStrings[347];
-  aMoonPhaseNames[2] = pGlobalTXT_LocalizationStrings[102];
-  aNPCProfessionNames[46] = pGlobalTXT_LocalizationStrings[348];
-  aMoonPhaseNames[3] = pGlobalTXT_LocalizationStrings[169];
-  aNPCProfessionNames[47] = pGlobalTXT_LocalizationStrings[349];
-  aMoonPhaseNames[4] = pGlobalTXT_LocalizationStrings[92];
-  aNPCProfessionNames[48] = pGlobalTXT_LocalizationStrings[350];
-  aAttributeNames[0] = pGlobalTXT_LocalizationStrings[144];
-  aNPCProfessionNames[49] = pGlobalTXT_LocalizationStrings[597];
-  aAttributeNames[1] = pGlobalTXT_LocalizationStrings[116];
-  aNPCProfessionNames[50] = pGlobalTXT_LocalizationStrings[352];
-  aAttributeNames[2] = pGlobalTXT_LocalizationStrings[163];
-  aNPCProfessionNames[51] = pGlobalTXT_LocalizationStrings[353];
-  aAttributeNames[3] = pGlobalTXT_LocalizationStrings[75];
-  aNPCProfessionNames[52] = pGlobalTXT_LocalizationStrings[598];
-  aAttributeNames[4] = pGlobalTXT_LocalizationStrings[1];
-  aNPCProfessionNames[53] = pGlobalTXT_LocalizationStrings[344];
-  aAttributeNames[5] = pGlobalTXT_LocalizationStrings[211];
-  aNPCProfessionNames[54] = pGlobalTXT_LocalizationStrings[26];
-  aAttributeNames[6] = pGlobalTXT_LocalizationStrings[136];
-  aNPCProfessionNames[55] = pGlobalTXT_LocalizationStrings[599];
-  aSpellNames[14] = pGlobalTXT_LocalizationStrings[279];
-  aSpellNames[33] = pGlobalTXT_LocalizationStrings[279];
-  aSpellNames[9] = pGlobalTXT_LocalizationStrings[440];
-  aSpellNames[34] = pGlobalTXT_LocalizationStrings[442];
-  aSpellNames[0] = pGlobalTXT_LocalizationStrings[202];
-  aSpellNames[10] = pGlobalTXT_LocalizationStrings[218];
-  aSpellNames[20] = pGlobalTXT_LocalizationStrings[202];
-  aSpellNames[35] = pGlobalTXT_LocalizationStrings[235];
-  aSpellNames[11] = pGlobalTXT_LocalizationStrings[217];
-  aSpellNames[21] = pGlobalTXT_LocalizationStrings[443];
-  aSpellNames[36] = pGlobalTXT_LocalizationStrings[246];
-  aSpellNames[12] = pGlobalTXT_LocalizationStrings[213];
-  aSpellNames[24] = pGlobalTXT_LocalizationStrings[221];
-  aSpellNames[37] = pGlobalTXT_LocalizationStrings[247];
-  aSpellNames[13] = pGlobalTXT_LocalizationStrings[462];
-  aSpellNames[26] = pGlobalTXT_LocalizationStrings[228];
-  aSpellNames[38] = pGlobalTXT_LocalizationStrings[248];
-  aSpellNames[15] = pGlobalTXT_LocalizationStrings[442];
-  aSpellNames[28] = pGlobalTXT_LocalizationStrings[440];
-  aSpellNames[39] = pGlobalTXT_LocalizationStrings[674];
-  aSpellNames[16] = pGlobalTXT_LocalizationStrings[452];
-  aSpellNames[29] = pGlobalTXT_LocalizationStrings[213];
-  aSpellNames[40] = pGlobalTXT_LocalizationStrings[249];
-  aSpellNames[2] = pGlobalTXT_LocalizationStrings[219];
-  aSpellNames[17] = pGlobalTXT_LocalizationStrings[194];
-  aSpellNames[30] = pGlobalTXT_LocalizationStrings[229];
-  aSpellNames[41] = pGlobalTXT_LocalizationStrings[258];
-  aSpellNames[5] = pGlobalTXT_LocalizationStrings[454];
-  aSpellNames[3] = pGlobalTXT_LocalizationStrings[215];
-  aSpellNames[7] = pGlobalTXT_LocalizationStrings[455];
-  aSpellNames[18] = pGlobalTXT_LocalizationStrings[456];
-  aSpellNames[31] = pGlobalTXT_LocalizationStrings[233];
-  aSpellNames[42] = pGlobalTXT_LocalizationStrings[194];
-  aSpellNames[6] = pGlobalTXT_LocalizationStrings[24];
-  aSpellNames[25] = pGlobalTXT_LocalizationStrings[24];
-  aSpellNames[1] = pGlobalTXT_LocalizationStrings[204];
-  aSpellNames[4] = pGlobalTXT_LocalizationStrings[208];
-  aSpellNames[8] = pGlobalTXT_LocalizationStrings[441];
-  aSpellNames[19] = pGlobalTXT_LocalizationStrings[453];
-  aSpellNames[22] = pGlobalTXT_LocalizationStrings[204];
-  aSpellNames[23] = pGlobalTXT_LocalizationStrings[208];
-  aSpellNames[27] = pGlobalTXT_LocalizationStrings[441];
-  aSpellNames[32] = pGlobalTXT_LocalizationStrings[234];
-  aSpellNames[43] = pGlobalTXT_LocalizationStrings[657];
-}
-
-
-
-
-
-
-
-//----- (00453E6D) --------------------------------------------------------
-void StorylineText::Initialize()
-{
-  char *v1; // ebx@1
-  StorylineText *v2; // esi@1
-  char *v3; // ecx@4
-  char v4; // dl@5
-  char *v5; // eax@5
-  int v6; // esi@9
-  int v7; // [sp+Ch] [bp-10h]@3
-  int v8; // [sp+10h] [bp-Ch]@4
-  char *v9; // [sp+14h] [bp-8h]@4
-  int Str; // [sp+18h] [bp-4h]@3
-
-  v1 = 0;
-  v2 = this;
-  if ( pHistoryTXT_Raw )
-    pAllocator->FreeChunk(pHistoryTXT_Raw);
-  pHistoryTXT_Raw = 0;
-  pHistoryTXT_Raw = (char *)pEvents_LOD->LoadRaw("history.txt", 0);
-  strtok(pHistoryTXT_Raw, "\r");
-  Str = (int)&v2->field_4[4];
-  v7 = 29;
-  do
-  {
-    v9 = v1;
-    v8 = (signed int)v1;
-    v3 = strtok(v1, "\r");
-    do
-    {
-      v4 = *v3;
-      v5 = 0;
-      if ( *v3 != 9 )
-      {
-        v1 = 0;
-        do
-        {
-          if ( !v4 )
-            break;
-          ++v5;
-          v4 = v3[(int)v5];
-        }
-        while ( v4 != 9 );
-      }
-      v6 = (int)&v3[(int)v5];
-      if ( v3[(int)v5] == (char)v1 )
-        v8 = 1;
-      *(char *)v6 = (char)v1;
-      if ( v5 == v1 )
-      {
-        v8 = 1;
-      }
-      else
-      {
-        if ( v9 == (char *)1 )
-        {
-          *(char **)(Str - 8) = RemoveQuotes(v3);
-        }
-        else
-        {
-          if ( v9 == (char *)2 )
-          {
-            *(char *)Str = atoi(v3);
-          }
-          else
-          {
-            if ( v9 - 2 == (char *)1 )
-              *(char * *)(Str - 4) = RemoveQuotes(v3);
-          }
-        }
-      }
-      ++v9;
-      v3 = (char *)(v6 + 1);
-    }
-    while ( (signed int)(v9 - 1) <= 3 && (char *)v8 == v1 );
-    Str += 12;
-    --v7;
-  }
-  while ( v7 );
-}
+
+
+
 
 //----- (00453F62) --------------------------------------------------------
 void MapStats::Initialize()
 {
-  MapStats *v1; // esi@1
-  unsigned int v2; // ebx@3
-  char *v3; // eax@4
-  char *v4; // edi@4
-  char v5; // cl@5
-  int v6; // eax@5
-  size_t v7; // eax@32
-  size_t v8; // eax@35
-  size_t v9; // eax@42
-  size_t v10; // eax@45
-  size_t v11; // eax@52
-  size_t v12; // eax@55
-  char Str[32]; // [sp+Ch] [bp-34h]@30
-  char *v14; // [sp+2Ch] [bp-14h]@9
-  int v15; // [sp+30h] [bp-10h]@4
-  int v16; // [sp+34h] [bp-Ch]@4
-  unsigned int v17; // [sp+38h] [bp-8h]@30
-  MapStats *v18; // [sp+3Ch] [bp-4h]@30
-
-  v1 = this;
+  char work_str[32]; // [sp+Ch] [bp-34h]@3
+  int work_str_pos;
+  int work_str_len;
+  int i;
+  char* test_string;
+  unsigned char c;
+  bool break_loop;
+  unsigned int temp_str_len;
+  char* tmp_pos;
+  int decode_step;
+  int item_counter;
+
   if ( pMapStatsTXT_Raw )
     pAllocator->FreeChunk(pMapStatsTXT_Raw);
-  pMapStatsTXT_Raw = 0;
+  pMapStatsTXT_Raw = NULL;
   pMapStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("MapStats.txt", 0);
   strtok(pMapStatsTXT_Raw, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
-  v2 = 1;
-  v1->uNumMaps = 77;
-  do
-  {
-    v3 = strtok(0, "\r");
-    v16 = 0;
-    v15 = 0;
-    v4 = v3;
-    do
-    {
-      v5 = *v4;
-      v6 = 0;
-      while ( v5 != 9 && v5 )
-      {
-        ++v6;
-        v5 = v4[v6];
-      }
-      v14 = &v4[v6];
-      if ( !v4[v6] )
-        v15 = 1;
-      v4[v6] = 0;
-      if ( v6 )
-      {
-        switch ( v16 )
-        {
-          case 1:
-            v1->pInfos[v2].pName = (char *)RemoveQuotes(v4);
-            break;
-          case 2:
-            v1->pInfos[v2].pFilename = (char *)RemoveQuotes(v4);
-            break;
-          case 3:
-            v1->pInfos[v2].uNumResets = atoi(v4);
-            break;
-          case 4:
-            v1->pInfos[v2].uFirstVisitedAt = atoi(v4);
-            break;
-          case 5:
-            v1->pInfos[v2]._per = atoi(v4);
-            break;
-          case 6:
-            v1->pInfos[v2].uRespawnIntervalDays = atoi(v4);
-            break;
-          case 7:
-            v1->pInfos[v2]._alert_days = atoi(v4);
-            break;
-          case 8:
-            v1->pInfos[v2]._steal_perm = atoi(v4);
-            break;
-          case 9:
-            v1->pInfos[v2].field_2D = atoi(v4);
-            break;
-          case 10:
-            v1->pInfos[v2].field_2E = atoi(v4);
-            break;
-          case 11:
-            v1->pInfos[v2].field_2F = atoi(v4);
-            break;
-          case 12:
-            v1->pInfos[v2].field_30 = atoi(v4);
-            break;
-          case 13:
-            v1->pInfos[v2].field_31 = atoi(v4);
-            break;
-          case 14:
-            v1->pInfos[v2].field_32 = atoi(v4);
-            break;
-          case 15:
-            v1->pInfos[v2].field_33 = atoi(v4);
-            break;
-          case 16:
-            v1->pInfos[v2].pEncounterMonster1Texture = (char *)RemoveQuotes(v4);
-            break;
-          case 18:
-            v1->pInfos[v2].field_34 = atoi(v4);
-            break;
-          case 19:
-            v18 = (MapStats *)((char *)v1 + 68 * v2);
-            v18->pInfos[0].uEncounterMonster1AtLeast = 1;
-            strcpy(Str, v4);
-            v17 = 0;
-            if ( strlen(Str) )
-            {
-              while ( Str[v17] != 45 )
-              {
-                ++v17;
-                v7 = strlen(Str);
-                if ( v17 >= v7 )
-                  goto LABEL_35;
-              }
-              Str[v17] = 0;
-              v18->pInfos[0].uEncounterMonster1AtLeast = atoi(Str);
-            }
-LABEL_35:
-            v8 = strlen(Str);
-            if ( v17 == v8 )
-              v18->pInfos[0].uEncounterMonster1AtMost = atoi(&v4[v17 + 1]);
-            else
-              v18->pInfos[0].uEncounterMonster1AtMost = v18->pInfos[0].uEncounterMonster1AtLeast;
-            break;
-          case 20:
-            v1->pInfos[v2].pEncounterMonster2Texture = (char *)RemoveQuotes(v4);
-            break;
-          case 22:
-            v1->pInfos[v2].field_37 = atoi(v4);
-            break;
-          case 23:
-            v18 = (MapStats *)((char *)v1 + 68 * v2);
-            v18->pInfos[0].uEncounterMonster2AtLeast = 1;
-            strcpy(Str, v4);
-            v17 = 0;
-            if ( strlen(Str) )
-            {
-              while ( Str[v17] != 45 )
-              {
-                ++v17;
-                v9 = strlen(Str);
-                if ( v17 >= v9 )
-                  goto LABEL_45;
-              }
-              Str[v17] = 0;
-              v18->pInfos[0].uEncounterMonster2AtLeast = atoi(Str);
-            }
-LABEL_45:
-            v10 = strlen(Str);
-            if ( v17 == v10 )
-              v18->pInfos[0].uEncounterMonster2AtMost = atoi(&v4[v17 + 1]);
-            else
-              v18->pInfos[0].uEncounterMonster2AtMost = v18->pInfos[0].uEncounterMonster2AtLeast;
-            break;
-          case 24:
-            v1->pInfos[v2].pEncounterMonster3Texture = (char *)RemoveQuotes(v4);
-            break;
-          case 26:
-            v1->pInfos[v2].field_3A = atoi(v4);
-            break;
-          case 27:
-            v18 = (MapStats *)((char *)v1 + 68 * v2);
-            v18->pInfos[0].uEncounterMonster3AtLeast = 1;
-            strcpy(Str, v4);
-            v17 = 0;
-            if ( strlen(Str) )
-            {
-              while ( Str[v17] != 45 )
-              {
-                ++v17;
-                v11 = strlen(Str);
-                if ( v17 >= v11 )
-                  goto LABEL_55;
-              }
-              Str[v17] = 0;
-              v18->pInfos[0].uEncounterMonster3AtLeast = atoi(Str);
-            }
-LABEL_55:
-            v12 = strlen(Str);
-            if ( v17 == v12 )
-              v18->pInfos[0].uEncounterMonster3AtMost = atoi(&v4[v17 + 1]);
-            else
-              v18->pInfos[0].uEncounterMonster3AtMost = v18->pInfos[0].uEncounterMonster3AtLeast;
-            break;
-          case 28:
-            v1->pInfos[v2].uRedbookTrackID = atoi(v4);
-            break;
-          case 29:
-            if ( strcmp(v4, "GENERIC") )
-            {
-              if ( strcmp(v4, "PADDEDCELL") )
-              {
-                if ( strcmp(v4, "ROOM") )
-                {
-                  if ( strcmp(v4, "BATHROOM") )
-                  {
-                    if ( strcmp(v4, "LIVINGROOM") )
-                    {
-                      if ( strcmp(v4, "STONEROOM") )
-                      {
-                        if ( strcmp(v4, "AUDITORIUM") )
-                        {
-                          if ( strcmp(v4, "CONCERTHALL") )
-                          {
-                            if ( strcmp(v4, "CAVE") )
-                            {
-                              if ( strcmp(v4, "ARENA") )
-                              {
-                                if ( strcmp(v4, "HANGAR") )
-                                {
-                                  if ( strcmp(v4, "CARPETEDHALLWAY") )
-                                  {
-                                    if ( strcmp(v4, "HALLWAY") )
-                                    {
-                                      if ( strcmp(v4, "STONECORRIDOR") )
-                                      {
-                                        if ( strcmp(v4, "ALLEY") )
-                                        {
-                                          if ( strcmp(v4, "FOREST") )
-                                          {
-                                            if ( strcmp(v4, "CITY") )
-                                            {
-                                              if ( strcmp(v4, "MOUNTAINS") )
-                                              {
-                                                if ( strcmp(v4, "QUARRY") )
-                                                {
-                                                  if ( strcmp(v4, "PLAIN") )
-                                                  {
-                                                    if ( strcmp(v4, "PARKINGLOT") )
-                                                    {
-                                                      if ( strcmp(v4, "SEWERPIPE") )
-                                                      {
-                                                        if ( strcmp(v4, "UNDERWATER") )
-                                                        {
-                                                          if ( strcmp(v4, "DRUGGED") )
-                                                          {
-                                                            if ( strcmp(v4, "DIZZY") )
-                                                            {
-                                                              if ( strcmp(v4, "PSYCHOTIC") )
-                                                                v1->pInfos[v2].uEAXEnv = 26;
-                                                              else
-                                                                v1->pInfos[v2].uEAXEnv = 25;
-                                                            }
-                                                            else
-                                                            {
-                                                              v1->pInfos[v2].uEAXEnv = 24;
-                                                            }
-                                                          }
-                                                          else
-                                                          {
-                                                            v1->pInfos[v2].uEAXEnv = 23;
-                                                          }
-                                                        }
-                                                        else
-                                                        {
-                                                          v1->pInfos[v2].uEAXEnv = 22;
-                                                        }
-                                                      }
-                                                      else
-                                                      {
-                                                        v1->pInfos[v2].uEAXEnv = 21;
-                                                      }
-                                                    }
-                                                    else
-                                                    {
-                                                      v1->pInfos[v2].uEAXEnv = 20;
-                                                    }
-                                                  }
-                                                  else
-                                                  {
-                                                    v1->pInfos[v2].uEAXEnv = 19;
-                                                  }
-                                                }
-                                                else
-                                                {
-                                                  v1->pInfos[v2].uEAXEnv = 18;
-                                                }
-                                              }
-                                              else
-                                              {
-                                                v1->pInfos[v2].uEAXEnv = 17;
-                                              }
-                                            }
-                                            else
-                                            {
-                                              v1->pInfos[v2].uEAXEnv = 16;
-                                            }
-                                          }
-                                          else
-                                          {
-                                            v1->pInfos[v2].uEAXEnv = 15;
-                                          }
-                                        }
-                                        else
-                                        {
-                                          v1->pInfos[v2].uEAXEnv = 14;
-                                        }
-                                      }
-                                      else
-                                      {
-                                        v1->pInfos[v2].uEAXEnv = 13;
-                                      }
-                                    }
-                                    else
-                                    {
-                                      v1->pInfos[v2].uEAXEnv = 12;
-                                    }
-                                  }
-                                  else
-                                  {
-                                    v1->pInfos[v2].uEAXEnv = 11;
-                                  }
-                                }
-                                else
-                                {
-                                  v1->pInfos[v2].uEAXEnv = 10;
-                                }
-                              }
-                              else
-                              {
-                                v1->pInfos[v2].uEAXEnv = 9;
-                              }
-                            }
-                            else
-                            {
-                              v1->pInfos[v2].uEAXEnv = 8;
-                            }
-                          }
-                          else
-                          {
-                            v1->pInfos[v2].uEAXEnv = 7;
-                          }
-                        }
-                        else
-                        {
-                          v1->pInfos[v2].uEAXEnv = 6;
-                        }
-                      }
-                      else
-                      {
-                        v1->pInfos[v2].uEAXEnv = 5;
-                      }
-                    }
-                    else
-                    {
-                      v1->pInfos[v2].uEAXEnv = 4;
-                    }
-                  }
-                  else
-                  {
-                    v1->pInfos[v2].uEAXEnv = 3;
-                  }
-                }
-                else
-                {
-                  v1->pInfos[v2].uEAXEnv = 2;
-                }
-              }
-              else
-              {
-                v1->pInfos[v2].uEAXEnv = 1;
-              }
-            }
-            else
-            {
-              v1->pInfos[v2].uEAXEnv = 0;
-            }
-            break;
-          default:
-            break;
-        }
-      }
-      else
-      {
-        v15 = 1;
-      }
-      ++v16;
-      v4 = v14 + 1;
-    }
-    while ( v16 - 1 <= 29 && !v15 );
-    ++v2;
-  }
-  while ( (signed int)v2 < 77 );
-  v1->uNumMaps = v2;
+  strtok(NULL, "\r");
+  strtok(NULL, "\r");
+
+ for (i=1; i<77; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			  switch (decode_step)
+				  {
+				  case 1:
+					  pInfos[i].pName = RemoveQuotes(test_string);
+					  break;
+				  case 2:
+					  pInfos[i].pFilename = RemoveQuotes(test_string);
+					  break;
+				  case 3:
+					  pInfos[i].uNumResets = atoi(test_string);
+					  break;
+				  case 4:
+					  pInfos[i].uFirstVisitedAt = atoi(test_string);
+					  break;
+				  case 5:
+					  pInfos[i]._per = atoi(test_string);
+					  break;
+				  case 6:
+					  pInfos[i].uRespawnIntervalDays = atoi(test_string);
+					  break;
+				  case 7:
+					  pInfos[i]._alert_days = atoi(test_string);
+					  break;
+				  case 8:
+					  pInfos[i]._steal_perm = atoi(test_string);
+					  break;
+				  case 9:
+					  pInfos[i].LockX5 = atoi(test_string);
+					  break;
+				  case 10:
+					  pInfos[i].Trap_D20 = atoi(test_string);
+					  break;
+				  case 11:
+					  pInfos[i].Treasure_prob = atoi(test_string);
+					  break;
+				  case 12:
+					  pInfos[i].Encounter_percent = atoi(test_string);
+					  break;
+				  case 13:
+					  pInfos[i].EncM1percent = atoi(test_string);
+					  break;
+				  case 14:
+					  pInfos[i].EncM2percent = atoi(test_string);
+					  break;
+				  case 15:
+					  pInfos[i].EncM3percent = atoi(test_string);
+					  break;
+				  case 16:
+					  pInfos[i].pEncounterMonster1Texture = RemoveQuotes(test_string);
+					  break;
+				  case 18:
+					  pInfos[i].Dif_M1 = atoi(test_string);
+					  break;
+				  case 19:
+					  pInfos[i].uEncounterMonster1AtLeast = 1;
+					  pInfos[i].uEncounterMonster1AtMost = 1;
+					  strcpy(work_str, test_string);
+					  work_str_pos = 0;
+					  work_str_len=strlen(work_str);
+					  if (work_str_len )
+						  {
+						  while (work_str[work_str_pos] != '-' )
+							  {
+							  ++work_str_pos;
+							  if (work_str_pos >= work_str_len )
+								  break;
+							  }
+						  work_str[work_str_pos] = 0;
+						  pInfos[i].uEncounterMonster1AtLeast = atoi(work_str);
+						  if ( work_str_pos < work_str_len )
+							  pInfos[i].uEncounterMonster1AtMost = atoi(&work_str[work_str_pos + 1]);
+						  else
+							  pInfos[i].uEncounterMonster1AtMost = pInfos[i].uEncounterMonster1AtLeast;
+						  }
+					  break;
+				  case 20:
+					  pInfos[i].pEncounterMonster2Texture = RemoveQuotes(test_string);
+					  break;
+				  case 22:
+					  pInfos[i].Dif_M2 = atoi(test_string);
+					  break;
+				  case 23:
+					  pInfos[i].uEncounterMonster2AtLeast = 1;
+					  pInfos[i].uEncounterMonster2AtMost = 1;
+					  strcpy(work_str, test_string);
+					  work_str_pos = 0;
+					  work_str_len=strlen(work_str);
+					  if (work_str_len )
+						  {
+						  while (work_str[work_str_pos] != '-' )
+							  {
+							  ++work_str_pos;
+							  if (work_str_pos >= work_str_len )
+								  break;
+							  }
+						  work_str[work_str_pos] = 0;
+						  pInfos[i].uEncounterMonster2AtLeast = atoi(work_str);
+						  if ( work_str_pos < work_str_len )
+							  pInfos[i].uEncounterMonster2AtMost = atoi(&work_str[work_str_pos + 1]);
+						  else
+							  pInfos[i].uEncounterMonster2AtMost = pInfos[i].uEncounterMonster2AtLeast;
+						  }
+					  break;
+				  case 24:
+					  pInfos[i].pEncounterMonster3Texture = RemoveQuotes(test_string);
+					  break;
+				  case 26:
+					  pInfos[i].Dif_M3 = atoi(test_string);
+					  break;
+				  case 27:
+					  pInfos[i].uEncounterMonster3AtLeast = 1;
+					  pInfos[i].uEncounterMonster3AtMost = 1;
+					  strcpy(work_str, test_string);
+					  work_str_pos = 0;
+					  work_str_len=strlen(work_str);
+					  if (work_str_len )
+						  {
+						  while (work_str[work_str_pos] != '-' )
+							  {
+							  ++work_str_pos;
+							  if (work_str_pos >= work_str_len )
+								  break;
+							  }
+						  work_str[work_str_pos] = 0;
+						  pInfos[i].uEncounterMonster3AtLeast = atoi(work_str);
+						  if ( work_str_pos < work_str_len )
+							  pInfos[i].uEncounterMonster3AtMost = atoi(&work_str[work_str_pos + 1]);
+						  else
+							  pInfos[i].uEncounterMonster3AtMost = pInfos[i].uEncounterMonster3AtLeast;
+						  }
+					  break;
+				  case 28:
+					  pInfos[i].uRedbookTrackID = atoi(test_string);
+					  break;
+				  case 29:
+					  {
+					  if ( !strcmp(test_string, "CAVE") )
+						  {
+						  pInfos[i].uEAXEnv = 8;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "STONEROOM") )
+						  {
+						  pInfos[i].uEAXEnv = 5;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "MOUNTAINS") )
+						  {
+						  pInfos[i].uEAXEnv = 17;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "PLAIN") )
+						  {
+						  pInfos[i].uEAXEnv = 19;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "FOREST") )
+						  {
+						  pInfos[i].uEAXEnv = 15;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "CITY") )
+						  {
+						  pInfos[i].uEAXEnv = 16;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "UNDERWATER") )
+						  {
+						  pInfos[i].uEAXEnv = 22;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "ARENA") )
+						  {
+						  pInfos[i].uEAXEnv = 9;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "GENERIC") )
+						  {
+						  pInfos[i].uEAXEnv = 0;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "PADDEDCELL") )
+						  {
+						  pInfos[i].uEAXEnv = 1;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "ROOM") )
+						  {
+						  pInfos[i].uEAXEnv = 2;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "BATHROOM") )
+						  {
+						  pInfos[i].uEAXEnv = 3;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "LIVINGROOM") )
+						  {
+						  pInfos[i].uEAXEnv = 4;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "AUDITORIUM") )
+						  {
+						  pInfos[i].uEAXEnv = 6;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "CONCERTHALL") )
+						  {
+						  pInfos[i].uEAXEnv = 7;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "HANGAR") )
+						  {
+						  pInfos[i].uEAXEnv = 10;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "CARPETEDHALLWAY") )
+						  {
+						  pInfos[i].uEAXEnv = 11;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "HALLWAY") )
+						  {
+						  pInfos[i].uEAXEnv = 12;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "STONECORRIDOR") )
+						  {
+						  pInfos[i].uEAXEnv = 13;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "ALLEY") )
+						  {
+						  pInfos[i].uEAXEnv = 14;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "QUARRY") )
+						  {
+						  pInfos[i].uEAXEnv = 18;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "PARKINGLOT") )
+						  {
+						  pInfos[i].uEAXEnv = 20;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "SEWERPIPE") )
+						  {
+						  pInfos[i].uEAXEnv = 21;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "DRUGGED") )
+						  {
+						  pInfos[i].uEAXEnv = 23;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "DIZZY") )
+						  {
+						  pInfos[i].uEAXEnv = 24;
+						  break;
+						  }
+					  if ( !strcmp(test_string, "PSYCHOTIC") )
+						  {
+						  pInfos[i].uEAXEnv = 25;
+						  break;
+						  }
+					   pInfos[i].uEAXEnv = 26;
+					
+						  }
+					  break;
+				  }
+			  }
+		  else
+			  { 
+				  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<31)&&!break_loop);
+	  }
+ 
+  uNumMaps = 77;
 }
 // 453F62: using guessed type char Str[32];
 
@@ -10075,73 +9608,55 @@
 //----- (004547E4) --------------------------------------------------------
 void FactionTable::Initialize()
 {
-  char *v1; // ebx@1
-  char *v2; // eax@4
-  signed int v3; // edi@4
-  int v4; // ebp@4
-  char v5; // dl@5
-  char *v6; // ecx@5
-  int v7; // esi@9
-  signed int v8; // [sp+4h] [bp-Ch]@3
-  signed int v9; // [sp+8h] [bp-8h]@4
-  char *v10; // [sp+Ch] [bp-4h]@1
-
-  v1 = 0;
-  v10 = (char *)relations;
+  int i;
+  char* test_string;
+  unsigned char c;
+  bool break_loop;
+  unsigned int temp_str_len;
+  char* tmp_pos;
+  int decode_step;
+  int item_counter;
+
   if ( pHostileTXT_Raw )
     pAllocator->FreeChunk(pHostileTXT_Raw);
-  pHostileTXT_Raw = 0;
+  pHostileTXT_Raw = NULL;
   pHostileTXT_Raw = (char *)pEvents_LOD->LoadRaw("hostile.txt", 0);
   strtok(pHostileTXT_Raw, "\r");
-  v8 = 0;
-  do
-  {
-    v2 = strtok(v1, "\r") + 1;
-    v3 = 0;
-    v9 = (signed int)v1;
-    v4 = (int)&v10[v8-89];
-    do
-    {
-      v5 = *v2;
-      v6 = 0;
-      if ( *v2 != 9 )
-      {
-        v1 = 0;
-        do
-        {
-          if ( !v5 )
-            break;
-          ++v6;
-          v5 = v2[(int)v6];
-        }
-        while ( v5 != 9 );
-      }
-      v7 = (int)&v2[(int)v6];
-      if ( v2[(int)v6] == (char)v1 )
-        v9 = 1;
-      *(char *)v7 = (char)v1;
-      if ( v6 == v1 )
-      {
-        v9 = 1;
-      }
-      else
-      {
-        if ( v3 >= 1 && v3 <= 90 )
-          *(char *)v4 = atoi(v2);
-      }
-      ++v3;
-      v4 += 89;
-      v2 = (char *)(v7 + 1);
-    }
-    while ( v3 - 1 <= 90 && (char *)v9 == v1 );
-    ++v8;
-  }
-  while ( v8 < 89 );
-
-  if ( pHostileTXT_Raw != v1 )
+  for (i=0; i<89; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			  if ( decode_step >= 1 && decode_step < 90 )
+				  relations[decode_step-1][i] = atoi(test_string);
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<92)&&!break_loop);
+	  }
+  if ( pHostileTXT_Raw)
   {
     pAllocator->FreeChunk(pHostileTXT_Raw);
-    pHostileTXT_Raw = v1;
+    pHostileTXT_Raw = NULL;
   }
 }
 
@@ -12302,7 +11817,7 @@
         {
           if ( pAsyncMouse != (void *)v28 )
             goto _def_wnd_proc;
-          pGame->PickMouse(512.0, (unsigned __int16)lParam, lParam >> 16, v28, &a3, &a4);
+          pGame->PickMouse(512.0, (unsigned __int16)lParam, lParam >> 16, v28, &vis_sprite_filter_3, &vis_door_filter);
         }
         if ( pAsyncMouse == (void *)v28 )
         {
@@ -12324,7 +11839,7 @@
             if (pAsyncMouse)
               goto _def_wnd_proc;
             v33 = GetPickDepth();
-            pGame->PickMouse(v33, (unsigned __int16)lParam, lParam >> 16, v31, &stru_F93E30, &a4);
+            pGame->PickMouse(v33, (unsigned __int16)lParam, lParam >> 16, v31, &vis_sprite_filter_2, &vis_door_filter);
           }
           if (!pAsyncMouse)
           {
@@ -12343,7 +11858,7 @@
           if ( pGame && !pAsyncMouse )
           {
             v34 = GetPickDepth();
-            pGame->PickMouse(v34, (unsigned __int16)lParam, lParam >> 16, 1, &a3, &a5);
+            pGame->PickMouse(v34, (unsigned __int16)lParam, lParam >> 16, 1, &vis_sprite_filter_3, &vis_face_filter);
             return DefWindowProcA(hWnd, Msg, wParam, v4);
           }
           goto _def_wnd_proc;
@@ -13350,6 +12865,9 @@
   }
 }
 
+
+
+
 //----- (004651F4) --------------------------------------------------------
 bool MM7_Initialize()
 {
@@ -13369,20 +12887,7 @@
   }
 
 
-
   srand(GetTickCount());
-  /*GetDiskFreeSpaceA(0, &SectorsPerCluster, &BytesPerSector, &hdc, &TotalNumberOfClusters);
-  v4 = hdc * BytesPerSector * SectorsPerCluster;
-  if ( (unsigned int)v4 < 0x1E00000 )
-  {
-    sprintfex(
-      pTmpBuf,
-      "Due to Window Virtual Memory requirements Might and Magic VII\nrequires 30MB of free hard drive space to operate properly.\n\nAvailable on Current Drive = %luk",
-      (unsigned int)v4 / 1024i64);
-    v41 = 48;
-    v40 = "More Hard Drive Space Required";
-    v39 = pTmpBuf;
-*/
   
   WNDCLASSEXW wcxw;
   {
@@ -13857,19 +13362,6 @@
       sprintf(pTmpBuf, "data\\lloyd%d%d.pcx", i, j);
       remove(pTmpBuf);
     }
-  /*do
-  {
-    v11 = 1;
-    do
-    {
-      sprintfex(pTmpBuf, "data\\lloyd%d%d.pcx", v10, v11);
-      remove(pTmpBuf);
-      ++v11;
-    }
-    while ( v11 < 6 );
-    ++v10;
-  }
-  while ( v10 < 5 );*/
 
   Initialize_GamesLOD_NewLOD();
   dword_576E2C = 512;
@@ -13881,7 +13373,6 @@
 
 
 
-
 bool new_sky = false;
 
 //----- (00462C94) --------------------------------------------------------
@@ -13899,11 +13390,9 @@
   unsigned int startms; // [sp+8h] [bp-24h]@55
   RECT Rect; // [sp+Ch] [bp-20h]@15
   int a2[4]; // [sp+1Ch] [bp-10h]@15
-#ifdef MM7_TEXT_DLL
-  auto mm7text_dll = LoadLibraryW(L"mm7text.dll");
-  sprintfex = (int (__cdecl *)(char *a1, const char *a2, ...))GetProcAddress(mm7text_dll, "_sprintfex");
-#endif
-
+
+  char test[1024];
+  sprintfex(test, "^Pi[%s]: ^R[;;]", "");
 
   if (pCmdLine && *pCmdLine)
   {
@@ -15102,7 +14591,7 @@
   v2 = v0->pEquipment.uOffHand;
   v54 = v0->pEquipment.uOffHand;
   v53 = v1;
-  if ( v1 && pItemsTable->pItems[*(int *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v1 + 5]].uEquipType == 1 )
+  if ( v1 && pItemsTable->pItems[*(int *)&v0->pInventoryItems[v1-1]].uEquipType == 1 )
     v51 = v1;
   v3 = pParty->pPickedItem.uItemID;
   if ( pParty->pPickedItem.uItemID )
@@ -15118,7 +14607,7 @@
         if ( (signed int)SkillToMastery(v5) < 3 )
         {
 LABEL_8:
-          v0->PlaySound(39, 0);
+          v0->PlaySound(SPEECH_39, 0);
           return;
         }
         v3 = pParty->pPickedItem.uItemID;
@@ -15129,7 +14618,7 @@
     {
       if ( (v4 == 8 || v4 == 1 || v4 == 2)
         && v1
-        && pItemsTable->pItems[*(int *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v1 + 5]].uSkillType == 4 )
+        && pItemsTable->pItems[*(int *)&v0->pInventoryItems[v1-1]].uSkillType == 4 )
         goto LABEL_7;
     }
 LABEL_16:
@@ -15474,7 +14963,7 @@
     v35 = v0->pEquipment.uBow;
     if ( v35 )
     {
-      auto _a = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v35 + 5];
+      auto _a = (ItemGen *)&v0->pInventoryItems[v35-1];
       pParty->SetHoldingItem(_a);
       _a->Reset();
       v0->pEquipment.uBow = 0;
@@ -15528,9 +15017,9 @@
 }
 
 //----- (0046A14B) --------------------------------------------------------
-char __cdecl OnPressSpace()
-{
-  SHORT v0; // ax@2
+void OnPressSpace()
+{
+  //SHORT v0; // ax@2
   int *v1; // eax@2
   char *v2; // ebx@5
   unsigned int v3; // esi@5
@@ -15555,12 +15044,10 @@
 
   if ( pRenderer->pRenderD3D )
   {
-    v0 = GetAsyncKeyState(17);
-    pGame->_44EB12((v0 & 0x8001) != 0, &a3, &a4);
+    pGame->PickKeyboard(GetAsyncKeyState(VK_CONTROL) & 0x8001, &vis_sprite_filter_3, &vis_door_filter);
     v1 = (int *)pGame->pVisInstance->get_picked_object_zbuf_val();
     if ( v1 != (int *)-1 )
-      LOBYTE(v1) = DoInteractionWithTopmostZObject((unsigned __int16)v1, (signed int)(unsigned __int16)v1 >> 3);
-    return (char)v1;
+      DoInteractionWithTopmostZObject((unsigned __int16)v1, (signed int)(unsigned __int16)v1 >> 3);
   }
   v22 = 0;
   v1 = (int *)((signed int)(viewparams->uScreenZ + viewparams->uScreenX) >> 1);
@@ -15657,10 +15144,7 @@
     if ( !(char)v1 )
       break;
   }
-  return (char)v1;
-}
-// 72065C: using guessed type int dword_72065C[];
-// 7207EC: using guessed type int dword_7207EC[];
+}
 
 //----- (0046A334) --------------------------------------------------------
 char __fastcall DoInteractionWithTopmostZObject(int a1, int a2)
@@ -15937,7 +15421,7 @@
     {
       v3 = pRenderer->GetParentBillboardID(a1a);
       v4 = pBillboardRenderList[v3].sZValue;
-      v5 = (unsigned __int16)pBillboardRenderList[v3].sZValue;
+      v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid;
       if ( (v5 & 7) == OBJECT_Actor)
       {
         if ( v4 <= (unsigned int)(a3 << 16) )
--- a/mm7_3.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/mm7_3.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -41,6 +41,7 @@
 #include "stru176.h"
 #include "stru159.h"
 #include "stru298.h"
+#include "texts.h"
 #include "Log.h"
 
 #include "mm7_data.h"
@@ -2676,7 +2677,7 @@
         if ( !uActiveCharacter )
           goto LABEL_87;
         v65 = 0;
-        v63 = 63;
+        v63 = SPEECH_63;
         goto LABEL_76;
       case PARTY_LookDown:
         __debugbreak();
@@ -2687,9 +2688,9 @@
         if ( uActiveCharacter )
         {
           v65 = 0;
-          v63 = 64;
+          v63 = SPEECH_64;
 LABEL_76:
-          pPlayers[v35]->PlaySound(v63, v65);
+          pPlayers[v35]->PlaySound((PlayerSpeech)v63, v65);
         }
         break;
       case PARTY_CenterView:
@@ -3507,7 +3508,7 @@
         if ( _angle_x > 128 )
           _angle_x = 128;
         if (uActiveCharacter)
-          pPlayers[uActiveCharacter]->PlaySound(63, 0);
+          pPlayers[uActiveCharacter]->PlaySound(SPEECH_63, 0);
       break;
 
       case PARTY_LookDown:
@@ -3515,7 +3516,7 @@
         if ( _angle_x < -128 )
           _angle_x = -128;
         if (uActiveCharacter)
-          pPlayers[uActiveCharacter]->PlaySound(64, 0);
+          pPlayers[uActiveCharacter]->PlaySound(SPEECH_64, 0);
       break;
 
       case PARTY_Jump:
@@ -3623,7 +3624,7 @@
       {
         auto player = pParty->pPlayers + i;
         if (!player->HasEnchantedItemEquipped(72) && !player->WearsItem(529, 8) && player->CanAct())
-          player->PlaySound(66, 0);
+          player->PlaySound(SPEECH_66, 0);
       }
     }
   }
@@ -4747,432 +4748,364 @@
 // 6BE3C5: using guessed type char bNoNPCHiring;
 
 //----- (004763E0) --------------------------------------------------------
-void __cdecl InitializeAwards()
-{
-  char *v0; // ebx@1
-  char *v1; // eax@4
-  char v2; // dl@5
-  char *v3; // ecx@5
-  int v4; // esi@9
-  signed int v5; // [sp+Ch] [bp-Ch]@4
-  char *v6; // [sp+10h] [bp-8h]@4
-  Award *v7; // [sp+14h] [bp-4h]@3
-
-  v0 = 0;
+void  InitializeAwards()
+{
+  
+  int i;
+  char* test_string;
+  unsigned char c;
+  bool break_loop;
+  unsigned int temp_str_len;
+  char* tmp_pos;
+  int decode_step;
+  int item_counter;
+
   if ( pAwardsTXT_Raw )
     pAllocator->FreeChunk(pAwardsTXT_Raw);
-  pAwardsTXT_Raw = 0;
+  pAwardsTXT_Raw = NULL;
   pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0);
   strtok(pAwardsTXT_Raw, "\r");
-  v7 = pAwards;
-  for (uint i = 0; i < 104; ++i)
-  {
-    v1 = strtok(v0, "\r") + 1;
-    v6 = v0;
-    v5 = (signed int)v0;
-    do
-    {
-      v2 = *v1;
-      v3 = 0;
-      if ( *v1 != 9 )
-      {
-        v0 = 0;
-        do
-        {
-          if ( !v2 )
-            break;
-          ++v3;
-          v2 = v1[(int)v3];
-        }
-        while ( v2 != 9 );
-      }
-      v4 = (int)&v1[(int)v3];
-      if ( v1[(int)v3] == (char)v0 )
-        v5 = 1;
-      *(char *)v4 = (char)v0;
-      if ( v3 == v0 )
-      {
-        v5 = 1;
-      }
-      else
-      {
-        if ( v6 == (char *)1 )
-        {
-          v7->pText = RemoveQuotes(v1);
-        }
-        else
-        {
-          if ( v6 == (char *)2 )
-            v7->uSort = atoi(v1);
-        }
-      }
-      ++v6;
-      v1 = (char *)(v4 + 1);
-    }
-    while ( (signed int)(v6 - 1) <= 2 && (char *)v5 == v0 );
-    ++v7;
-  }
-  //while ( (signed int)v7 < (signed int)&dword_7241C8 );
+
+  for (i=1; i<104; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			   if (decode_step==1)
+				  pAwards[i].pText=RemoveQuotes(test_string);
+			   else if (decode_step==2)
+				  pAwards[i].uSort=atoi(test_string);
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<3)&&!break_loop);
+	  }
+
 }
 // 7241C8: using guessed type int dword_7241C8;
 
 //----- (004764C2) --------------------------------------------------------
-void __cdecl InitializeScrolls()
-{
-  char *v0; // ebx@1
-  char *v1; // eax@4
-  int v2; // edi@4
-  char v3; // dl@5
-  char *v4; // ecx@5
-  int v5; // esi@9
-  const char **v6; // [sp+10h] [bp-8h]@3
-  signed int v7; // [sp+14h] [bp-4h]@4
-
-  v0 = 0;
+void  InitializeScrolls()
+{
+  
+  int i;
+  char* test_string;
+  unsigned char c;
+  bool break_loop;
+  unsigned int temp_str_len;
+  char* tmp_pos;
+  int decode_step;
+  int item_counter;
+
   if ( pScrollsTXT_Raw )
     pAllocator->FreeChunk(pScrollsTXT_Raw);
-  pScrollsTXT_Raw = 0;
+  pScrollsTXT_Raw = NULL;
   pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0);
   strtok(pScrollsTXT_Raw, "\r");
-  v6 = pScrolls;
-  for (uint i = 0; i < 82; ++i)
-  {
-    v1 = strtok(v0, "\r") + 1;
-    v2 = 0;
-    v7 = (signed int)v0;
-    do
-    {
-      v3 = *v1;
-      v4 = 0;
-      if ( *v1 != 9 )
-      {
-        v0 = 0;
-        do
-        {
-          if ( !v3 )
-            break;
-          ++v4;
-          v3 = v1[(int)v4];
-        }
-        while ( v3 != 9 );
-      }
-      v5 = (int)&v1[(int)v4];
-      if ( v1[(int)v4] == (char)v0 )
-        v7 = 1;
-      *(char *)v5 = (char)v0;
-      if ( v4 == v0 )
-      {
-        v7 = 1;
-      }
-      else
-      {
-        if ( v2 == 1 )
-          *v6 = RemoveQuotes(v1);
-      }
-      ++v2;
-      v1 = (char *)(v5 + 1);
-    }
-    while ( v2 - 1 <= 1 && (char *)v7 == v0 );
-    ++v6;
-  }
-  //while ( (signed int)v6 < (signed int)dword_723E80_award_related );
+  for (i=0; i<82; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			  if ( decode_step == 1)
+				 pScrolls[i]=RemoveQuotes(test_string);
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<2)&&!break_loop);
+	  }
 }
 
 
 //----- (00476590) --------------------------------------------------------
-void __cdecl InitializeMerchants()
-{
-  char *v0; // ebx@1
-  //char **v1; // edi@3
-  char *v2; // ecx@4
-  char v3; // dl@5
-  char *v4; // eax@5
-  int v5; // esi@9
-  signed int v6; // [sp+Ch] [bp-8h]@4
-  char *v7; // [sp+10h] [bp-4h]@4
-
-  v0 = 0;
+void  InitializeMerchants()
+{
+  int i;
+  char* test_string;
+  unsigned char c;
+  bool break_loop;
+  unsigned int temp_str_len;
+  char* tmp_pos;
+  int decode_step;
+  int item_counter;
+
   if ( pMerchantsTXT_Raw )
     pAllocator->FreeChunk(pMerchantsTXT_Raw);
-  pMerchantsTXT_Raw = 0;
+  pMerchantsTXT_Raw = NULL;
   pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0);
   strtok(pMerchantsTXT_Raw, "\r");
-  //v1 = (char **)pMerchantsRepairPhrases;
-  for (uint i = 0; i < 7; ++i)
-  {
-    v7 = v0;
-    v6 = (signed int)v0;
-    v2 = strtok(v0, "\r") + 1;
-    do
-    {
-      v3 = *v2;
-      v4 = 0;
-      if ( *v2 != 9 )
-      {
-        v0 = 0;
-        do
-        {
-          if ( !v3 )
-            break;
-          ++v4;
-          v3 = v2[(int)v4];
-        }
-        while ( v3 != 9 );
-      }
-      v5 = (int)&v2[(int)v4];
-      if ( v2[(int)v4] == (char)v0 )
-        v6 = 1;
-      *(char *)v5 = (char)v0;
-      if ( v4 == v0 )
-      {
-        v6 = 1;
-      }
-      else
-      {
-        if ( v7 == (char *)1 )
-        {
-          pMerchantsBuyPhrases[i] = RemoveQuotes(v2);
-        }
-        else
-        {
-          if ( v7 == (char *)2 )
-          {
-            pMerchantsSellPhrases[i] = RemoveQuotes(v2);
-          }
-          else
-          {
-            if ( v7 == (char *)3 )
-            {
-              pMerchantsRepairPhrases[i] = RemoveQuotes(v2);
-            }
-            else
-            {
-              if ( v7 - 3 == (char *)1 )
-                pMerchantsIdentifyPhrases[i] = RemoveQuotes(v2);
-            }
-          }
-        }
-      }
-      ++v7;
-      v2 = (char *)(v5 + 1);
-    }
-    while ( (signed int)(v7 - 1) <= 4 && (char *)v6 == v0 );
-    //++v1;
-  }
-  //while ( (signed int)v1 < (signed int)pMerchantsIdentifyPhrases );
+
+  for (i=0; i<7; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+				switch (decode_step)
+					{
+					case 1:
+						pMerchantsBuyPhrases[i]=RemoveQuotes(test_string);
+						break;
+					case 2:
+						pMerchantsSellPhrases[i]=RemoveQuotes(test_string);
+						break;
+					case 3:
+						pMerchantsRepairPhrases[i]=RemoveQuotes(test_string); 
+						break;
+					case 4:
+						pMerchantsIdentifyPhrases[i]=RemoveQuotes(test_string); 
+						break;
+					}
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<5)&&!break_loop);
+	  }
+
 }
 
 //----- (00476682) --------------------------------------------------------
-void __cdecl InitializeTransitions()
-{
-  char *v0; // ebx@1
-  char *v1; // eax@4
-  int v2; // edi@4
-  char v3; // dl@5
-  char *v4; // ecx@5
-  int v5; // esi@9
-  char **v6; // [sp+10h] [bp-8h]@3
-  signed int v7; // [sp+14h] [bp-4h]@4
-
-  v0 = 0;
+void InitializeTransitions()
+{
+  int i;
+  char* test_string;
+  unsigned char c;
+  bool break_loop;
+  unsigned int temp_str_len;
+  char* tmp_pos;
+  int decode_step;
+  int item_counter;
+
   if ( pTransitionsTXT_Raw )
     pAllocator->FreeChunk(pTransitionsTXT_Raw);
-  pTransitionsTXT_Raw = 0;
+  pTransitionsTXT_Raw = NULL;
   pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0);
   strtok(pTransitionsTXT_Raw, "\r");
-  v6 = pTransitionStrings;
-  for (uint i = 0; i < 464; ++i)
-  {
-    v1 = strtok(v0, "\r") + 1;
-    v2 = 0;
-    v7 = (signed int)v0;
-    do
-    {
-      v3 = *v1;
-      v4 = 0;
-      if ( *v1 != 9 )
-      {
-        v0 = 0;
-        do
-        {
-          if ( !v3 )
-            break;
-          ++v4;
-          v3 = v1[(int)v4];
-        }
-        while ( v3 != 9 );
-      }
-      v5 = (int)&v1[(int)v4];
-      if ( v1[(int)v4] == (char)v0 )
-        v7 = 1;
-      *(char *)v5 = (char)v0;
-      if ( v4 == v0 )
-      {
-        v7 = 1;
-      }
-      else
-      {
-        if ( v2 == 1 )
-          *v6 = (char *)RemoveQuotes(v1);
-      }
-      ++v2;
-      v1 = (char *)(v5 + 1);
-    }
-    while ( v2 - 1 <= 1 && (char *)v7 == v0 );
-    ++v6;
-  }
-  //while ( (signed int)v6 < (signed int)"awards.txt" );
+
+  for (i=0; i<464; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			  if ( decode_step == 1)
+				 pTransitionStrings[i]=RemoveQuotes(test_string);
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<2)&&!break_loop);
+	  }
 }
 
 //----- (00476750) --------------------------------------------------------
 void __cdecl InitializeAutonotes()
 {
-  Autonote *v0; // ebp@3
-  int v1; // ebx@4
-  char *v2; // esi@4
-  char v3; // cl@5
-  int v4; // eax@5
-  char *v5; // edi@9
-  signed int v6; // [sp+0h] [bp-4h]@4
+  int i;
+  char* test_string;
+  unsigned char c;
+  bool break_loop;
+  unsigned int temp_str_len;
+  char* tmp_pos;
+  int decode_step;
+  int item_counter;
 
   if ( pAutonoteTXT_Raw )
     pAllocator->FreeChunk(pAutonoteTXT_Raw);
   pAutonoteTXT_Raw = 0;
   pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0);
   strtok(pAutonoteTXT_Raw, "\r");
-  v0 = pAutonoteTxt;
-  for (uint i = 0; i < 195; ++i)
-  {
-    v1 = 0;
-    v2 = strtok(0, "\r") + 1;
-    v6 = 0;
-    do
-    {
-      v3 = *v2;
-      v4 = 0;
-      while ( v3 != 9 && v3 )
-      {
-        ++v4;
-        v3 = v2[v4];
-      }
-      v5 = &v2[v4];
-      if ( !v2[v4] )
-        v6 = 1;
-      *v5 = 0;
-      if ( v4 )
-      {
-        if ( v1 == 1 )
-        {
-			v0->pText = RemoveQuotes(v2);
-        }
-        else
-        {
-          if ( v1 == 2 )
-          {
-            if ( _strcmpi(v2, "potion") )
-            {
-              if ( _strcmpi(v2, "stat") )
-              {
-                if ( _strcmpi(v2, "seer") )
-                {
-                  if ( _strcmpi(v2, "obelisk") )
-					  v0->eType = (AUTONOTE_TYPE)(5 - (_strcmpi(v2, "teacher") != 0));
-                  else
-					  v0->eType = (AUTONOTE_TYPE)2;
-                }
-                else
-                {
-                  v0->eType = (AUTONOTE_TYPE)3;
-                }
-              }
-              else
-              {
-                v0->eType = (AUTONOTE_TYPE)1;
-              }
-            }
-            else
-            {
-              v0->eType = (AUTONOTE_TYPE)0;
-            }
-          }
-        }
-      }
-      else
-      {
-        v6 = 1;
-      }
-      ++v1;
-      v2 = v5 + 1;
-    }
-    while ( v1 - 1 <= 2 && !v6 );
-    ++v0;
-  }
-  //while ( (signed int)v0 < (signed int)&pScrolls[1] );
+
+  for (i=0; i<195; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			  switch (decode_step)
+				  {
+			  case  1:
+				  pAutonoteTxt[i].pText=RemoveQuotes(test_string);
+				  break;
+			  case  2:
+				  {
+				  if ( !_strcmpi(test_string, "potion"))
+					  {
+					  pAutonoteTxt[i].eType = AUTONOTE_POTION_RECEPIE;
+					  break;
+					  }
+				  if ( !_strcmpi(test_string, "stat") )
+					  {
+					  pAutonoteTxt[i].eType = AUTONOTE_STAT_HINT;
+					  break;
+					  }
+				  if ( !_strcmpi(test_string, "seer") )
+					  {
+					  pAutonoteTxt[i].eType = AUTONOTE_SEER;
+					  break;
+					  }
+				  if ( !_strcmpi(test_string, "obelisk") )
+					  {
+					  pAutonoteTxt[i].eType = AUTONOTE_OBELISK;
+					  break;
+					  }
+				  if ( !_strcmpi(test_string, "teacher") )
+					  {
+					  pAutonoteTxt[i].eType = AUTONOTE_TEACHER;
+					  break;
+					  }
+				  pAutonoteTxt[i].eType =AUTONOTE_MISC;
+				  break;
+				  }
+				  }
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<3)&&!break_loop);
+	  }
 }
 
 
 //----- (004768A9) --------------------------------------------------------
 void __cdecl InitializeQuests()
 {
-  char *v0; // ebx@1
-  char *v1; // eax@4
-  int v2; // edi@4
-  char v3; // dl@5
-  char *v4; // ecx@5
-  int v5; // esi@9
-  //const char **v6; // [sp+10h] [bp-8h]@3
-  signed int v7; // [sp+14h] [bp-4h]@4
-
-  v0 = 0;
+   int i;
+  char* test_string;
+  unsigned char c;
+  bool break_loop;
+  unsigned int temp_str_len;
+  char* tmp_pos;
+  int decode_step;
+  int item_counter;
+
   if ( pQuestsTXT_Raw )
     pAllocator->FreeChunk(pQuestsTXT_Raw);
-  pQuestsTXT_Raw = 0;
+  pQuestsTXT_Raw = NULL;
   pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0);
   strtok(pQuestsTXT_Raw, "\r");
 
-  //v6 = pQuestTable;
-  for (uint i = 0; i < 512; ++i)
-  //do
-  {
-    v1 = strtok(v0, "\r") + 1;
-    v2 = 0;
-    v7 = (signed int)v0;
-    do
-    {
-      v3 = *v1;
-      v4 = 0;
-      if ( *v1 != '\t' )
-      {
-        v0 = 0;
-        do
-        {
-          if ( !v3 )
-            break;
-          ++v4;
-          v3 = v1[(int)v4];
-        }
-        while ( v3 != '\t' );
-      }
-      v5 = (int)&v1[(int)v4];
-      if ( v1[(int)v4] == (char)v0 )
-        v7 = 1;
-      *(char *)v5 = (char)v0;
-      if ( v4 == v0 )
-      {
-        v7 = 1;
-      }
-      else
-      {
-        if ( v2 == 1 )
-          pQuestTable[i] = RemoveQuotes(v1);
-      }
-      ++v2;
-      v1 = (char *)(v5 + 1);
-    }
-    while ( v2 - 1 <= 1 && (char *)v7 == v0 );
-    //++v6;
-  }
-  //while ( (signed int)v6 < (signed int)&unk_723714 );
+  for (i=0; i<512; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			  if ( decode_step == 1)
+				 pQuestTable[i] =RemoveQuotes(test_string);
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<2)&&!break_loop);
+	  }
 }
 
 
@@ -5180,214 +5113,150 @@
 //----- (00476977) --------------------------------------------------------
 void NPCStats::Initialize2()
 {
-  char *v4; // eax@4
-  char v5; // dl@5
-  char *v6; // ecx@5
-  int v7; // edi@9
-  char *v9; // eax@21
-  char v10; // dl@22
-  char *v11; // ecx@22
-  int v12; // edi@26
-  char *v14; // eax@39
-  char v15; // dl@40
-  int v16; // ecx@40
-  int v17; // edi@44
-  char v18; // zf@47
-  NPCStats_stru0 *v19; // eax@57
-  signed int v20; // edx@57
-  signed int v21; // ecx@58
-  char *v22; // [sp+10h] [bp-10h]@4
-  char *v23; // [sp+10h] [bp-10h]@21
-  char *v25; // [sp+14h] [bp-Ch]@4
-  char *v26; // [sp+14h] [bp-Ch]@21
-  signed int v27; // [sp+14h] [bp-Ch]@39
-  //signed int v28; // [sp+18h] [bp-8h]@3
-  //signed int v29; // [sp+18h] [bp-8h]@20
-  signed int v30; // [sp+18h] [bp-8h]@37
-  char *v31; // [sp+1Ch] [bp-4h]@37
-
-  //v1 = this;
-  //v2 = 0;
+  int i;
+  char* test_string;
+  unsigned char c;
+  bool break_loop;
+  unsigned int temp_str_len;
+  char* tmp_pos;
+  int decode_step;
+  int item_counter;
+
+
   if (pNPCTextTXT_Raw)
     pAllocator->FreeChunk(pNPCTextTXT_Raw);
-
-  //v3 = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0);
+  pNPCTextTXT_Raw =NULL;
   pNPCTextTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0);
   strtok(pNPCTextTXT_Raw, "\r");
 
-  for (uint i = 0; i < 789; ++i)
-  {
-    v4 = strtok(nullptr, "\r") + 1;
-    v22 = nullptr;
-    v25 = nullptr;
-    do
-    {
-      v5 = *v4;
-      v6 = 0;
-      if ( *v4 != 9 )
-      {
-        do
-        {
-          if ( !v5 )
-            break;
-          ++v6;
-          v5 = v4[(int)v6];
-        }
-        while ( v5 != 9 );
-        //v2 = 0;
-      }
-      v7 = (int)&v4[(int)v6];
-      if ( !v4[(int)v6] )
-        v25 = (char *)1;
-      *(char *)v7 = 0;
-      if ( v6 == nullptr )
-      {
-        v25 = (char *)1;
-      }
-      else
-      {
-        if ( v22 == (char *)1 )
-          pNPCTopics[i].pText = RemoveQuotes(v4);
-      }
-      ++v22;
-      v4 = (char *)(v7 + 1);
-    }
-    while ( (signed int)(v22 - 1) <= 1 && v25 == nullptr );
-  }
+  for (i=0; i<789; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			  if ( decode_step == 1)
+				 pNPCTopics[i].pText =RemoveQuotes(test_string);
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<2)&&!break_loop);
+	  }
 
   if (pNPCTopicTXT_Raw)
     pAllocator->FreeChunk(pNPCTopicTXT_Raw);
-
-  //v8 = (char *)pEvents_LOD->LoadRaw("npctopic.txt", (int)v2);
+  pNPCTopicTXT_Raw =NULL;
   pNPCTopicTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctopic.txt", 0);
   strtok(pNPCTopicTXT_Raw, "\r");
 
-  for (uint i = 0; i < 579; ++i)
-  {
-    v9 = strtok(nullptr, "\r") + 1;
-    v23 = nullptr;
-    v26 = nullptr;
-    do
-    {
-      v10 = *v9;
-      v11 = 0;
-      if ( *v9 != 9 )
-      {
-        do
-        {
-          if ( !v10 )
-            break;
-          ++v11;
-          v10 = v9[(int)v11];
-        }
-        while ( v10 != 9 );
-        //v2 = 0;
-      }
-      v12 = (int)&v9[(int)v11];
-      if ( !v9[(int)v11] )
-        v26 = (char *)1;
-      *(char *)v12 = 0;
-      if ( v11 == nullptr )
-      {
-        v26 = (char *)1;
-      }
-      else
-      {
-        if ( v23 == (char *)1 )
-          pNPCTopics[i].pTopic = RemoveQuotes(v9);
-      }
-      ++v23;
-      v9 = (char *)(v12 + 1);
-    }
-    while ( (signed int)(v23 - 1) <= 1 && v26 == nullptr );
-  }
+   for (i=0; i<579; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			  if ( decode_step == 1)
+				 pNPCTopics[i].pTopic = RemoveQuotes(test_string);
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<2)&&!break_loop);
+	  }
 
   if (pNPCDistTXT_Raw)
     pAllocator->FreeChunk(pNPCDistTXT_Raw);
-
-  //v13 = (char *)pEvents_LOD->LoadRaw("npcdist.txt", (int)v2);
+  pNPCDistTXT_Raw = NULL;
   pNPCDistTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdist.txt", 0);
   strtok(pNPCDistTXT_Raw, "\r");
-  strtok(nullptr, "\r");
-  v30 = 1;
-  v31 = &array_16544[0].field_4[1];
-
-  char *v2 = 0;
-  while ( 2 )
-  {
-    v14 = strtok(nullptr, "\r") + 1;
-    v27 = 0;
-    char *v24 = nullptr;
-    do
-    {
-      v15 = *v14;
-      v16 = 0;
-      if ( *v14 != 9 )
-      {
-        do
-        {
-          if ( !v15 )
-            break;
-          ++v16;
-          v15 = v14[v16];
-        }
-        while ( v15 != 9 );
-        v2 = v24;
-      }
-      v17 = (int)&v14[v16];
-      if ( !v14[v16] )
-        v27 = 1;
-      *(char *)v17 = 0;
-      if ( !v16 )
-      {
-        v27 = 1;
-        goto LABEL_54;
-      }
-      v18 = v2 == 0;
-      if ( (signed int)v2 > 0 )
-      {
-        if ( (signed int)v2 < 77 )
-        {
-          array_16544[(int)v2].field_4[v30] = atoi(v14);
-          goto LABEL_54;
-        }
-        v18 = v2 == 0;
-      }
-      if ( v18 )
-        *v31 = 10;
-LABEL_54:
-      ++v2;
-      v14 = (char *)(v17 + 1);
-      v24 = v2;
-    }
-    while ( (signed int)(v2 - 1) <= 77 && !v27 );
-    ++v30;
-    ++v31;
-    if ( v30 < 59 )
-    {
-      v2 = 0;
-      continue;
-    }
-    break;
-  }
-  v19 = array_16544;
-  v20 = 77;
-  do
-  {
-    v19->field_0 = 0;
-    v21 = 1;
-    do
-      v19->field_0 += v19->field_4[v21++];
-    while ( v21 < 59 );
-    ++v19;
-    --v20;
-  }
-  while ( v20 );
+  strtok(NULL, "\r");
+
+   for (i=1; i<59; ++i)
+	  {
+	  test_string = strtok(NULL, "\r") + 1;
+	  break_loop = false;
+	  decode_step=0;
+	  do 
+		  {
+		  c = *(unsigned char*)test_string;
+		  temp_str_len = 0;
+		  while((c!='\t')&&(c>0))
+			  {
+			  ++temp_str_len;
+			  c=test_string[temp_str_len];
+			  }		
+		  tmp_pos=test_string+temp_str_len;
+		  if (*tmp_pos == 0)
+			  break_loop = true;
+		  *tmp_pos = 0;
+		  if (temp_str_len)
+			  {
+			   if ((decode_step>0)&&(decode_step<77))
+				   {
+				   array_16544[decode_step].field_4[i]=atoi(test_string);
+				   }
+			   else if (decode_step==0)
+				   {
+				  array_16544[0].field_4[i]=10;
+				   }
+			  }
+		  else
+			  { 
+			  break_loop = true;
+			  }
+		  ++decode_step;
+		  test_string=tmp_pos+1;
+		  } while ((decode_step<78)&&!break_loop);
+	  }
+
+  for (i=0; i<78; ++i)
+	  {
+	  array_16544[i].field_0=0;
+	  for (int ii=1; ii<59; ++ii)
+		  {
+		  array_16544[i].field_0+=array_16544[i].field_4[ii];
+		  }
+	  }
 
   if (pNPCDistTXT_Raw)
   {
     pAllocator->FreeChunk(pNPCDistTXT_Raw);
-    pNPCDistTXT_Raw = nullptr;
+    pNPCDistTXT_Raw = NULL;
   }
 }
 
@@ -9664,7 +9533,7 @@
   for (uint i = 0; i < 16384; ++i)
   //do
   {
-    auto v4 = stru_76E5C8 + i;
+    auto v4 = stru_76E5C8[i];
     //band3a = 256;
     //v8 = (double)(signed int)((char *)v4 + 256 - (int)stru_76E5C8);
     for (uint j = 0; j < 128; ++j)                  // band3a: 0 -> 128
@@ -9676,17 +9545,17 @@
       if (v7 >= v10)
       {
         if (v7 >= v9)
-          v4->field_0 = ((v7 >= v3) - 1) & 2;
+          v4.field_0 = ((v7 >= v3) - 1) & 2;
         else
-          v4->field_0 = 2;
-      }
-      else
-      {
-        v4->field_0 = 1;
+          v4.field_0 = 2;
+      }
+      else
+      {
+        v4.field_0 = 1;
       }
       //band3a += 512;
-      v4->distance = v7;
-      ++v4;
+      v4.distance = v7;
+      //++v4;
     }
     //while ( band3a < 65792 );
   }
@@ -9699,6 +9568,8 @@
 //----- (004811A3) --------------------------------------------------------
 void stru148::_4811A3()
 {
+  __debugbreak();
+
   ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
   pRenderer->DrawTerrainPolygon(uNumVertices, this,
     pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]],
@@ -13433,10 +13304,14 @@
               v15->uScreenSpaceX = a5;
               v15->uScreenSpaceY = a6;
               v23 = 8 * v26;
-              LOBYTE(v23) = 8 * v26 | 5;
+              LOBYTE(v23) = 8 * v26 | OBJECT_Decoration;
               LOWORD(v22) = 0;
+
+              //v15->sZValue = v22 + v23;
+              v15->actual_z = HIWORD(x);
+              v15->object_pid = 8 * v26 | OBJECT_Decoration;
+
               v15->uTintColor = 0;
-              v15->sZValue = v22 + v23;
               v15->pSpriteFrame = v12;
             }
           }
@@ -13607,7 +13482,7 @@
               v3->uScreenSpaceY = v22;
               LOWORD(v21) = 0;
               v23 = 8 * i;
-              LOBYTE(v23) = 8 * i | 2;
+              LOBYTE(v23) = 8 * i | OBJECT_Item;
               v3->pSpriteFrame = v24;
               v12 = (p->uAttributes & 0x20) == 0;
               v3->sZValue = v21 + v23;
@@ -14512,7 +14387,7 @@
 {
   int v5; // ebx@1
   int v6; // edi@1
-  unsigned int *v7; // eax@8
+  BLVMapOutlines *v7; // eax@8
   unsigned __int8 v8; // zf@8
   unsigned __int8 v9; // sf@8
   int v10; // esi@10
@@ -14528,7 +14403,7 @@
   int v20; // eax@16
   signed int v21; // esi@18
   int v22; // ecx@21
-  int v23; // ecx@21
+  BLVMapOutline *v23; // ecx@21
   Vec3_short_ *v24; // edx@21
   Vec3_short_ *v25; // eax@21
   int v26; // ecx@21
@@ -14537,7 +14412,7 @@
   int v29; // eax@21
   double v30; // st7@23
   signed __int64 v31; // qax@23
-  char *v32; // edx@23
+  unsigned short *v32; // edx@23
   int v33; // esi@23
   signed int v34; // eax@23
   signed int v35; // ecx@23
@@ -14545,12 +14420,12 @@
   int v37; // ecx@27
   int v38; // edx@31
   unsigned int v39; // eax@33
-  const void *v40; // esi@33
-  unsigned __int16 *v41; // edi@33
+  short *v40; // esi@33
+  short *v41; // edi@33
   unsigned __int8 v42; // cf@33
   unsigned int v43; // ecx@33
-  int v44; // edi@33
-  int v45; // esi@33
+  short *v44; // edi@33
+  short *v45; // esi@33
   int v46; // ecx@33
   signed int v47; // esi@38
   signed int v48; // ecx@38
@@ -14571,7 +14446,7 @@
   signed int v63; // esi@85
   int v64; // eax@87
   unsigned int v65; // ebx@95
-  char *v66; // edx@95
+  unsigned short *v66; // edx@95
   unsigned __int16 *v67; // esi@96
   int v68; // edi@98
   unsigned __int16 v69; // cx@99
@@ -14580,7 +14455,7 @@
   unsigned int v72; // [sp-8h] [bp-4806Ch]@80
   signed int v73; // [sp-4h] [bp-48068h]@59
   unsigned __int16 v74; // [sp-4h] [bp-48068h]@79
-  char v75; // [sp+Ch] [bp-48058h]@23
+  unsigned short v75[131070]; // [sp+Ch] [bp-48058h]@23
   int v76; // [sp+4800Ch] [bp-58h]@23
   unsigned __int16 *v77; // [sp+48010h] [bp-54h]@27
   unsigned __int16 *v78; // [sp+48014h] [bp-50h]@23
@@ -14599,11 +14474,11 @@
   unsigned int i; // [sp+48048h] [bp-1Ch]@9
   unsigned int v92; // [sp+4804Ch] [bp-18h]@16
   unsigned __int16 *v93; // [sp+48050h] [bp-14h]@16
-  unsigned int v94; // [sp+48054h] [bp-10h]@8
+  signed int v94; // [sp+48054h] [bp-10h]@8
   unsigned int v95; // [sp+48058h] [bp-Ch]@16
   int v96; // [sp+4805Ch] [bp-8h]@10
   const void *v97; // [sp+48060h] [bp-4h]@16
-  char *a4a; // [sp+4806Ch] [bp+8h]@85
+  unsigned short *a4a; // [sp+4806Ch] [bp+8h]@85
   int a5a; // [sp+48070h] [bp+Ch]@86
 
   x_ = x;
@@ -14620,13 +14495,20 @@
   {
     if ( viewparams->field_2C == 768 )
     {
-      if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
-        goto LABEL_23;
-      v5 = 680;
-    }
-    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
-      goto LABEL_8;
-LABEL_23:
+      if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
+		v5 = 680;
+    }
+  }
+  else
+  {
+	  v6 = viewparams->field_38;
+	  v86 = viewparams->field_38;
+	  v84 = viewparams->field_3A;
+	  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
+	    v5 = viewparams->field_2C - 34;
+  }
+  if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
+  {
     v94 = a4 - x_ + 1;
     v92 = a5 - y_ + 1;
     v93 = &pRenderer->pTargetSurface[x_ + y_ * v79];
@@ -14639,7 +14521,7 @@
     v97 = (const void *)((unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16);
     v96 = 32768 - black - v84;
     v31 = (signed __int64)((double)v96 / v30);
-    v32 = &v75;
+    v32 = v75;
     v33 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
     v34 = (int)v31 << 16;
     v81 = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30);
@@ -14661,8 +14543,8 @@
           v77 = (unsigned __int16 *)v36;
           do
           {
-            *(short *)v32 = v78[*((char *)v77 + v37)];
-            v32 += 2;
+            *(short *)v32 = v78[*((char *)v77 + v37)];//crash
+            ++v32;
             v97 = (char *)v97 + v87;
             v37 = (signed int)v97 >> 16;
             --i;
@@ -14688,22 +14570,22 @@
         if ( (signed int)v94 > 0 )
         {
           v39 = v94;
-          v40 = v97;
-          v41 = v93;
+          v40 = (short *)v97;
+          v41 = (short *)v93;
           v42 = v94 & 1;
           v43 = v94 >> 1;
-          memcpy(v93, v97, 4 * (v94 >> 1));
-          v45 = (int)((char *)v40 + 4 * v43);
-          v44 = (int)&v41[2 * v43];
+          memcpy(v93, v97, 2 * (v94 >> 1));
+          v45 = &v40[2 * v43];
+          v44 = &v41[2 * v43];
           v46 = v42;
           v39 *= 2;
           v93 = (unsigned __int16 *)((char *)v93 + v39);
           v97 = (char *)v97 + v39;
           while ( v46 )
           {
-            *(short *)v44 = *(short *)v45;
-            v45 += 2;
-            v44 += 2;
+            *v44 = *v45;
+            ++v45;
+            ++v44;
             --v46;
           }
           v6 = v86;
@@ -14713,105 +14595,103 @@
       }
       while ( v96 );
     }
-    goto LABEL_38;
-  }
-  v6 = viewparams->field_38;
-  v86 = viewparams->field_38;
-  v84 = viewparams->field_3A;
-  if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
-    goto LABEL_23;
-  v5 = viewparams->field_2C - 34;
-LABEL_8:
-  black = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0);
-  teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu);
-  v7 = (uint *)pIndoor->pMapOutlines;
-  uNumBlueFacesInBLVMinimap = 0;
-  v8 = pIndoor->pMapOutlines->uNumOutlines == 0;
-  v9 = (pIndoor->pMapOutlines->uNumOutlines & 0x80000000u) != 0;
-  v94 = 0;
-  if ( !(v9 | v8) )
-  {
-    i = 0;
-    do
-    {
-      v10 = (int)((char *)v7 + i + 4);
-      v96 = pIndoor->pFaces[*(short *)((char *)v7 + i + 8)].uAttributes;
-      if ( BYTE1(v96) & 0x20 || (v11 = pIndoor->pFaces[*(short *)((char *)v7 + i + 10)].uAttributes, BYTE1(v11) & 0x20) )
-        goto LABEL_17;
-      v12 = *(short *)((char *)v7 + i + 14);
-      if ( !(v12 & 1) )
-      {
-        if ( !(v96 & 0x80) && (v11 & 0x80u) == 0 )
-          goto LABEL_17;
-        v96 = (signed int)v94 >> 3;
-        v13 = v94;
-        *(short *)(v10 + 10) = v12 | 1;
-        pIndoor->_visible_outlines[v96] |= 1 << (7 - v13 % 8);
-      }
-      v14 = *(short *)v10;
-      v88 = v5;
-      v15 = &pIndoor->pVertices[v14];
-      v16 = v15->x;
-      v17 = v15->y - v84;
-      v93 = (unsigned __int16 *)(v16 - v6);
-      v92 = v17;
-      v18 = &pIndoor->pVertices[*(short *)(v10 + 2)];
-      v19 = v18->x;
-      v20 = v18->y - v84;
-      v95 = v19 - v6;
-      v97 = (const void *)v20;
-      v88 = (unsigned __int64)((v16 - v6) * (signed __int64)v5) >> 16;
-      v87 = (unsigned __int64)((signed int)v92 * (signed __int64)v5) >> 16;
-      v93 = (unsigned __int16 *)((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16);
-      v92 = (unsigned __int64)(v20 * (signed __int64)v5) >> 16;
-      pRenderer->Line2D(
-        v85 + v88,
-        v90 - v87,
-        v85 + ((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16),
-        v90 - v92,
-        black);
-      v7 = (uint *)pIndoor->pMapOutlines;
-LABEL_17:
-      ++v94;
-      i += 12;
-    }
-    while ( (signed int)v94 < (signed int)*v7 );
-  }
-  v21 = 0;
-  if ( (signed int)uNumBlueFacesInBLVMinimap > 0 )
-  {
-    while ( 1 )
-    {
-      v22 = pBlueFacesInBLVMinimapIDs[v21];
-      v87 = v5;
-      v23 = (int)&v7[3 * v22 + 1];
-      v24 = &pIndoor->pVertices[*(short *)v23];
-      v25 = &pIndoor->pVertices[*(short *)(v23 + 2)];
-      v26 = v25->x;
-      v27 = (unsigned __int16 *)(v24->x - v86);
-      v28 = v24->y - v84;
-      v29 = v25->y - v84;
-      v93 = v27;
-      v92 = v28;
-      v97 = (const void *)v29;
-      v87 = (unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16;
-      v88 = (unsigned __int64)(v28 * (signed __int64)v5) >> 16;
-      i = (unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16;
-      v95 = (unsigned __int64)(v29 * (signed __int64)v5) >> 16;
-      pRenderer->Line2D(
-        v85 + ((unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16),
-        v90 - v88,
-        v85 + ((unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16),
-        v90 - v95,
-        teal);
-      ++v21;
-      if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap )
-        break;
-      v7 = (uint *)pIndoor->pMapOutlines;
-    }
-    v6 = v86;
-  }
-LABEL_38:
+  }
+  else
+  {
+	  black = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0);
+	  teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu);
+	  v7 = pIndoor->pMapOutlines;
+	  uNumBlueFacesInBLVMinimap = 0;
+	  v8 = pIndoor->pMapOutlines->uNumOutlines == 0;
+	  v9 = pIndoor->pMapOutlines->uNumOutlines < 0;
+	  v94 = 0;
+	  if ( !(v9 | v8) )
+	  {
+		i = 0;
+		do
+		{
+		  v10 = (int)((char *)v7 + i + 4);
+		  v96 = pIndoor->pFaces[*(short *)((char *)v7 + i + 8)].uAttributes;
+		  if ( !(BYTE1(v96) & 0x20 || (v11 = pIndoor->pFaces[*(short *)((char *)v7 + i + 10)].uAttributes, BYTE1(v11) & 0x20) ))
+		  {
+			  v12 = *(short *)((char *)v7 + i + 14);
+			  if ( !(v12 & 1) )
+			  {
+				if ( !(!(v96 & 0x80) && (v11 & 0x80u) == 0 ))
+				{
+					v96 = (signed int)v94 >> 3;
+					v13 = v94;
+					*(short *)(v10 + 10) = v12 | 1;
+					pIndoor->_visible_outlines[v96] |= 1 << (7 - v13 % 8);
+				}
+			  }
+			  if ( (!(v12 & 1) && !(!(v96 & 0x80) && (v11 & 0x80u) == 0 )) || v12 & 1)
+			  {
+				  v14 = *(short *)v10;
+				  v88 = v5;
+				  v15 = &pIndoor->pVertices[v14];
+				  v16 = v15->x;
+				  v17 = v15->y - v84;
+				  v93 = (unsigned __int16 *)(v16 - v6);
+				  v92 = v17;
+				  v18 = &pIndoor->pVertices[*(short *)(v10 + 2)];
+				  v19 = v18->x;
+				  v20 = v18->y - v84;
+				  v95 = v19 - v6;
+				  v97 = (const void *)v20;
+				  v88 = (unsigned __int64)((v16 - v6) * (signed __int64)v5) >> 16;
+				  v87 = (unsigned __int64)((signed int)v92 * (signed __int64)v5) >> 16;
+				  v93 = (unsigned __int16 *)((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16);
+				  v92 = (unsigned __int64)(v20 * (signed __int64)v5) >> 16;
+				  pRenderer->Line2D(
+					v85 + v88,
+					v90 - v87,
+					v85 + ((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16),
+					v90 - v92,
+					black);
+				  v7 = pIndoor->pMapOutlines;
+			  }
+		  }
+		  ++v94;
+		  i += 12;
+		}
+		while ( v94 < (signed int)v7->uNumOutlines );
+	  }
+	  v21 = 0;
+	  if ( (signed int)uNumBlueFacesInBLVMinimap > 0 )
+	  {
+		while ( 1 )
+		{
+		  v22 = pBlueFacesInBLVMinimapIDs[v21];
+		  v87 = v5;
+		  v23 = &v7->pOutlines[v22];
+		  v24 = &pIndoor->pVertices[v23->uVertex1ID];
+		  v25 = &pIndoor->pVertices[v23->uVertex2ID];
+		  v26 = v25->x;
+		  v27 = (unsigned __int16 *)(v24->x - v86);
+		  v28 = v24->y - v84;
+		  v29 = v25->y - v84;
+		  v93 = v27;
+		  v92 = v28;
+		  v97 = (const void *)v29;
+		  v87 = (unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16;
+		  v88 = (unsigned __int64)(v28 * (signed __int64)v5) >> 16;
+		  i = (unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16;
+		  v95 = (unsigned __int64)(v29 * (signed __int64)v5) >> 16;
+		  pRenderer->Line2D(
+			v85 + ((unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16),
+			v90 - v88,
+			v85 + ((unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16),
+			v90 - v95,
+			teal);
+		  ++v21;
+		  if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap )
+			break;
+		  v7 = pIndoor->pMapOutlines;
+		}
+		v6 = v86;
+	  }
+  }
   v47 = ((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + v85 - 3;
   v81 = pParty->vPosition.y - v84;
   v97 = (const void *)((unsigned __int64)((pParty->vPosition.y - v84) * (signed __int64)v5) >> 16);
@@ -14865,9 +14745,8 @@
               {
                 if ( (signed int)v51 >= 1664 )
                 {
-                  if ( (signed int)v51 > 1920 )
-                    goto LABEL_71;
-                  v73 = 7;
+                  if ( (signed int)v51 <= 1920 )
+				    v73 = 7;
                 }
                 else
                 {
@@ -14893,12 +14772,12 @@
         {
           v73 = 2;
         }
-        v50 = v73;
-        goto LABEL_71;
-      }
-      v50 = 1;
-    }
-LABEL_71:
+		if( (signed int)v51 <=1920)
+          v50 = v73;
+      }
+	  else
+        v50 = 1;
+    }
     pRenderer->_4A6776(
       v47,
       v49,
@@ -14970,7 +14849,7 @@
     v62 = (int)v61 << 16;
     teal = v60 >> 16;
     v63 = (signed __int16)v61;
-    a4a = &v75;
+    a4a = v75;
     result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xCu, 0xCu, 0xCu);
     v85 = 0;
     for ( i = result; v85 < (signed int)v95; result = v85 )
@@ -14988,14 +14867,14 @@
             if ( pOutdoor->_47F097(v81, v96) )
             {
               if ( !((a5a + v85) % 2) )
-                *(short *)a4a = i;
+                *a4a = i;
             }
             else
             {
-              *(short *)a4a = 0;
-            }
-          }
-          a4a += 2;
+              *a4a = 0;
+            }
+          }
+          ++a4a;
           v97 = (char *)v97 + black;
           v64 = (signed int)v97 >> 16;
           ++a5a;
@@ -15004,13 +14883,13 @@
       }
       v62 += black;
       v97 = (const void *)v60;
-      a4a += 2 * (v90 - a5a);
+      a4a += v90 - a5a;
       v63 = v62 >> 16;
       ++v85;
       teal = (unsigned int)v78;
     }
     v65 = v95;
-    v66 = &v75;
+    v66 = v75;
     if ( (signed int)v95 > 0 )
     {
       v67 = v77;
@@ -15025,7 +14904,7 @@
             v69 = *(short *)v66;
             if ( !*(short *)v66 || v69 == (short)i )
               *v67 = v69;
-            v66 += 2;
+            ++v66;
             ++v67;
             --v68;
           }
@@ -15236,322 +15115,259 @@
 
 
 //----- (00443801) --------------------------------------------------------
-int __cdecl Initialize2DA()
-{
-  const char *v0; // esi@3
-  _2devent *v1; // edi@3
-  char *v2; // esi@5
-  int v3; // edx@5
-  char v4; // cl@6
-  int v5; // eax@6
-  int v6; // ebx@10
-  int v7; // eax@60
-  int result; // eax@78
-  signed int v9; // [sp+10h] [bp-8h]@5
-  signed int v10; // [sp+14h] [bp-4h]@5
-
-  int it = 0;
-
-  if ( p2DEventsTXT_Raw )
-    pAllocator->FreeChunk(p2DEventsTXT_Raw);
-  p2DEventsTXT_Raw = 0;
-  v0 = "\r";
-  p2DEventsTXT_Raw = (char *)pEvents_LOD->LoadRaw("2dEvents.txt", 0);
-  strtok(p2DEventsTXT_Raw, "\r");
-  strtok(0, "\r");
-  v1 = p2DEvents;
-  while ( 1 )
-  {
-    v2 = strtok(0, v0) + 1;
-    v10 = 0;
-    v3 = -2;
-    v9 = -2;
-    do
-    {
-      v4 = *v2;
-      v5 = 0;
-      while ( v4 != 9 && v4 )
-      {
-        ++v5;
-        v4 = v2[v5];
-      }
-      v6 = (int)&v2[v5];
-      if ( !v2[v5] )
-        v10 = 1;
-      *(char *)v6 = 0;
-      if ( v5 )
-      {
-        switch ( v3 )
-        {
-          case 0:
-            if ( _strnicmp(v2, "wea", 3u) )
-            {
-              if ( _strnicmp(v2, "arm", 3u) )
-              {
-                if ( _strnicmp(v2, "mag", 3u) )
-                {
-                  if ( _strnicmp(v2, "alc", 3u) )
-                  {
-                    if ( _strnicmp(v2, "sta", 3u) )
-                    {
-                      if ( _strnicmp(v2, "boa", 3u) )
-                      {
-                        if ( _strnicmp(v2, "tem", 3u) )
-                        {
-                          if ( _strnicmp(v2, "tra", 3u) )
-                          {
-                            if ( _strnicmp(v2, "tow", 3u) )
-                            {
-                              if ( _strnicmp(v2, "tav", 3u) )
-                              {
-                                if ( _strnicmp(v2, "ban", 3u) )
-                                {
-                                  if ( _strnicmp(v2, "fir", 3u) )
-                                  {
-                                    if ( _strnicmp(v2, "air", 3u) )
-                                    {
-                                      if ( _strnicmp(v2, "wat", 3u) )
-                                      {
-                                        if ( _strnicmp(v2, "ear", 3u) )
-                                        {
-                                          if ( _strnicmp(v2, "spi", 3u) )
-                                          {
-                                            if ( _strnicmp(v2, "min", 3u) )
-                                            {
-                                              if ( _strnicmp(v2, "bod", 3u) )
-                                              {
-                                                if ( _strnicmp(v2, "lig", 3u) )
-                                                {
-                                                  if ( _strnicmp(v2, "dar", 3u) )
-                                                  {
-                                                    if ( _strnicmp(v2, "ele", 3u) )
-                                                    {
-                                                      if ( _strnicmp(v2, "sel", 3u) )
-                                                      {
-                                                        if ( _strnicmp(v2, "mir", 3u) )
-                                                        {
-                                                          v7 = -(_strnicmp(v2, "mer", 3u) != 0);
-                                                          LOBYTE(v7) = v7 & 0xEE;
-                                                          v1->uType = v7 + 18;
-                                                        }
-                                                        else
-                                                        {
-                                                          v1->uType = 16;
-                                                        }
-                                                      }
-                                                      else
-                                                      {
-                                                        v1->uType = 15;
-                                                      }
-                                                    }
-                                                    else
-                                                    {
-                                                      v1->uType = 14;
-                                                    }
-                                                  }
-                                                  else
-                                                  {
-                                                    v1->uType = 13;
-                                                  }
-                                                }
-                                                else
-                                                {
-                                                  v1->uType = 12;
-                                                }
-                                              }
-                                              else
-                                              {
-                                                v1->uType = 11;
-                                              }
-                                            }
-                                            else
-                                            {
-                                              v1->uType = 10;
-                                            }
-                                          }
-                                          else
-                                          {
-                                            v1->uType = 9;
-                                          }
-                                        }
-                                        else
-                                        {
-                                          v1->uType = 8;
-                                        }
-                                      }
-                                      else
-                                      {
-                                        v1->uType = 7;
-                                      }
-                                    }
-                                    else
-                                    {
-                                      v1->uType = 6;
-                                    }
-                                  }
-                                  else
-                                  {
-                                    v1->uType = 5;
-                                  }
-                                }
-                                else
-                                {
-                                  v1->uType = 22;
-                                }
-                              }
-                              else
-                              {
-                                v1->uType = 21;
-                              }
-                            }
-                            else
-                            {
-                              v1->uType = 17;
-                            }
-                          }
-                          else
-                          {
-                            v1->uType = 30;
-                          }
-                        }
-                        else
-                        {
-                          v1->uType = 23;
-                        }
-                      }
-                      else
-                      {
-                        v1->uType = 28;
-                      }
-                    }
-                    else
-                    {
-                      v1->uType = 27;
-                    }
-                  }
-                  else
-                  {
-                    v1->uType = 4;
-                  }
-                }
-                else
-                {
-                  v1->uType = 3;
-                }
-              }
-              else
-              {
-                v1->uType = 2;
-              }
-            }
-            else
-            {
-              v1->uType = 1;
-            }
-            break;
-          case 2:
-            v1->uAnimationID = atoi(v2);
-            break;
-          case 3:
-            v1->pName = (char *)RemoveQuotes(v2);
-            break;
-          case 4:
-            v1->pProprieterName = RemoveQuotes(v2);
-            break;
-          case 5:
-            v1->pProprieterTitle = RemoveQuotes(v2);
-            break;
-          case 6:
-            v1->field_14 = atoi(v2);
-            break;
-          case 7:
-            v1->_state = atoi(v2);
-            break;
-          case 8:
-            v1->_rep = atoi(v2);
-            break;
-          case 9:
-            v1->_per = atoi(v2);
-            break;
-          case 10:
-            v1->fPriceMultiplier = atof(v2);
-            break;
-          case 11:
-            v1->flt_24 = atof(v2);
-            break;
-          case 13:
-            v1->field_1C = atoi(v2);
-            break;
-          case 16:
-            v1->uOpenTime = atoi(v2);
-            break;
-          case 17:
-            v1->uCloseTime = atoi(v2);
-            break;
-          case 18:
-            v1->uExitPicID = atoi(v2);
-            break;
-          case 19:
-            v1->uExitMapID = atoi(v2);
-            break;
-          case 20:
-            v1->_quest_related = atoi(v2);
-            break;
-          case 21:
-            v1->pEnterText = RemoveQuotes(v2);
-            break;
-          default:
-            break;
-        }
-      }
-      v2 = (char *)(v6 + 1);
-      v3 = v9 + 1;
-      v9 = v3;
-      result = v3 + 1;
-    }
-    while ( v3 + 1 <= 23 && !v10 );
-    ++v1;
-    //if ( (signed int)v1 >= (signed int)&unk_597F10 )
-    if (++it >= 525)
-      return result;
-    v0 = "\r";
-  }
+void Initialize2DA()
+{
+ 
+  int i;
+	char* test_string;
+	unsigned char c;
+	bool break_loop;
+	unsigned int temp_str_len;
+	char* tmp_pos;
+	int decode_step;
+
+	if ( p2DEventsTXT_Raw )
+		pAllocator->FreeChunk(p2DEventsTXT_Raw);
+	p2DEventsTXT_Raw = NULL;
+	p2DEventsTXT_Raw = (char *)pEvents_LOD->LoadRaw("2dEvents.txt", 0);
+	strtok(p2DEventsTXT_Raw, "\r");
+	strtok(NULL, "\r");
+
+	for (i=0;i<525;++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				switch (decode_step)
+					{
+				case 2:
+					{
+					if ( !_strnicmp(test_string, "wea", 3) )
+						{
+						p2DEvents[i].uType = 1;
+						break;
+						}
+					if ( !_strnicmp(test_string, "arm", 3) )
+						{
+						p2DEvents[i].uType = 2;
+						break;
+						}
+					if ( !_strnicmp(test_string, "mag", 3) )
+						{
+						p2DEvents[i].uType = 3;
+						break;
+						}
+					if ( !_strnicmp(test_string, "alc", 3) )
+						{
+						p2DEvents[i].uType = 4;
+						break;
+						}
+					if ( !_strnicmp(test_string, "sta", 3) )
+						{
+						p2DEvents[i].uType = 27;
+						break;
+						}
+					if ( !_strnicmp(test_string, "boa", 3) )
+						{
+						p2DEvents[i].uType = 28;
+						break;
+						}
+					if ( !_strnicmp(test_string, "tem", 3) )
+						{
+						p2DEvents[i].uType = 23;
+						break;
+						}
+					if ( !_strnicmp(test_string, "tra", 3) )
+						{
+						p2DEvents[i].uType = 30;
+						break;
+						}
+					if ( !_strnicmp(test_string, "tow", 3) )
+						{
+						p2DEvents[i].uType = 17;
+						break;
+						}
+
+					if ( !_strnicmp(test_string, "tav", 3) )
+						{
+						p2DEvents[i].uType = 21;
+						break;
+						}
+					if ( !_strnicmp(test_string, "ban", 3) )
+						{
+						p2DEvents[i].uType = 22;
+						break;
+						}
+					if ( !_strnicmp(test_string, "fir", 3) )
+						{
+						p2DEvents[i].uType = 5;
+						break;
+						}
+					if ( !_strnicmp(test_string, "air", 3) )
+						{
+						p2DEvents[i].uType = 6;
+						break;
+						}
+					if ( !_strnicmp(test_string, "wat", 3) )
+						{
+						p2DEvents[i].uType = 7;
+						break;
+						}
+					if ( !_strnicmp(test_string, "ear", 3) )
+						{
+						p2DEvents[i].uType = 8;
+						break;
+						}
+					if ( !_strnicmp(test_string, "spi", 3) )
+						{
+						p2DEvents[i].uType = 9;
+						break;
+						}
+					if ( !_strnicmp(test_string, "min", 3) )
+						{
+						p2DEvents[i].uType = 10;
+						break;
+						}
+					if ( !_strnicmp(test_string, "bod", 3) )
+						{
+						p2DEvents[i].uType = 11;
+						break;
+						}
+					if ( !_strnicmp(test_string, "lig", 3) )
+						{
+						p2DEvents[i].uType = 12;
+						break;
+						}
+					if ( !_strnicmp(test_string, "dar", 3) )
+						{
+						p2DEvents[i].uType = 13;
+						break;
+						}
+					if ( !_strnicmp(test_string, "ele", 3) )
+						{
+						p2DEvents[i].uType = 14;
+						break;
+						}
+					if ( !_strnicmp(test_string, "sel", 3) )
+						{
+						p2DEvents[i].uType = 15;
+						break;
+						}
+					if ( !_strnicmp(test_string, "mir", 3) )
+						{
+						p2DEvents[i].uType = 16;
+						break;
+						}
+					if ( !_strnicmp(test_string, "mer", 3) )
+						{
+						p2DEvents[i].uType = 17;
+						break;
+						}
+					p2DEvents[i].uType = 18;
+					}
+					break;
+
+				case 4:
+					p2DEvents[i].uAnimationID = atoi(test_string);
+					break;
+				case 5:
+					p2DEvents[i].pName = RemoveQuotes(test_string);
+					break;
+				case 6:
+					p2DEvents[i].pProprieterName = RemoveQuotes(test_string);
+					break;
+				case 7:
+					p2DEvents[i].pProprieterTitle = RemoveQuotes(test_string);
+					break;
+				case 8:
+					p2DEvents[i].field_14 = atoi(test_string);
+					break;
+				case 9:
+					p2DEvents[i]._state = atoi(test_string);
+					break;
+				case 10:
+					p2DEvents[i]._rep = atoi(test_string);
+					break;
+				case 11:
+					p2DEvents[i]._per = atoi(test_string);
+					break;
+				case 12:
+					p2DEvents[i].fPriceMultiplier = atof(test_string);
+					break;
+				case 13:
+					p2DEvents[i].flt_24 = atof(test_string);
+					break;
+				case 15:
+					p2DEvents[i].field_1C = atoi(test_string);
+					break;
+				case 18:
+					p2DEvents[i].uOpenTime = atoi(test_string);
+					break;
+				case 19:
+					p2DEvents[i].uCloseTime = atoi(test_string);
+					break;
+				case 20:
+					p2DEvents[i].uExitPicID = atoi(test_string);
+					break;
+				case 21:
+					p2DEvents[i].uExitMapID = atoi(test_string);
+					break;
+				case 22:
+					p2DEvents[i]._quest_related = atoi(test_string);
+					break;
+				case 23:
+					p2DEvents[i].pEnterText = RemoveQuotes(test_string);
+					break;
+					}
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<24)&&!break_loop);
+		}
+
 }
 
 //----- (00443CE1) --------------------------------------------------------
-unsigned int __fastcall LoadEventsToBuffer(const char *pContainerName, char *a2, unsigned int uBufferSize)
-{
-  const char *v3; // edi@1
-  FILE *v4; // eax@1
-  unsigned int v5; // esi@3
-  char Args; // [sp+8h] [bp-B4h]@6
-  //Texture DstBuf; // [sp+6Ch] [bp-50h]@1
-  void *Dst; // [sp+B4h] [bp-8h]@1
+unsigned int LoadEventsToBuffer(const char *pContainerName, char *pBuffer, unsigned int uBufferSize)
+{
+  FILE *pLodFile; // eax@1
+  unsigned int uTextureSize; // esi@3
+  char Args[60]; // [sp+8h] [bp-B4h]@6
   void *ptr; // [sp+B8h] [bp-4h]@1
-
-  v3 = pContainerName;
-  Dst = a2;
-  ptr = pEvents_LOD->LoadRaw(pContainerName, 0);
-  
   Texture DstBuf; // [sp+6Ch] [bp-50h]@1
-  //Texture::Texture(&DstBuf);
-
-  v4 = pEvents_LOD->FindContainer(v3, 0);
-  if ( !v4 )
-    Abortf("Unable to load %s", v3);
-  fread(&DstBuf, 1u, 0x30u, v4);
-  v5 = DstBuf.uDecompressedSize;
+
+  ptr = pEvents_LOD->LoadRaw(pContainerName, 0);
+  pLodFile = pEvents_LOD->FindContainer(pContainerName, 0);
+  if ( !pLodFile )
+    Abortf("Unable to load %s", pContainerName);
+  fread(&DstBuf, 1, 48, pLodFile);
+  uTextureSize = DstBuf.uDecompressedSize;
   if ( !DstBuf.uDecompressedSize )
-    v5 = DstBuf.uTextureSize;
-  memset(&DstBuf, 0, 0x48u);
-  if ( (signed int)v5 >= (signed int)uBufferSize )
-  {
-    sprintf(&Args, "File %s Size %lu - Buffer size %lu", v3, v5, uBufferSize);
-    Abortf(&Args);
-  }
-  memcpy(Dst, ptr, v5);
+    uTextureSize = DstBuf.uTextureSize;
+  memset(&DstBuf, 0, 72);
+  if ( uTextureSize >= (signed int)uBufferSize )
+  {
+    sprintf(Args, "File %s Size %lu - Buffer size %lu", pContainerName, uTextureSize, uBufferSize);
+    Abortf(Args);
+  }
+  memcpy(pBuffer, ptr, uTextureSize);
   pAllocator->FreeChunk(ptr);
-  return v5;
+  return uTextureSize;
 }
 
 //----- (00443DA1) --------------------------------------------------------
@@ -16416,19 +16232,8 @@
   GUIButton *v14; // eax@43
   GUIButton *v15; // edi@43
   signed int v16; // eax@44
-  int v17; // eax@46
-  int v18; // eax@47
-  int v19; // eax@48
-  int v20; // eax@49
-  int v21; // eax@50
-  int v22; // eax@51
   unsigned int v23; // eax@53
   const char *v24; // eax@59
-  int v25; // eax@65
-  int v26; // eax@66
-  int v27; // eax@67
-  int v28; // eax@68
-  int v29; // eax@69
   unsigned __int16 v30; // cx@83
   int v31; // ecx@86
   int v32; // ebx@93
@@ -16456,7 +16261,7 @@
   __int16 v54[2]; // [sp+104h] [bp-10h]@2
   unsigned __int16 *v55; // [sp+108h] [bp-Ch]@82
   GUIFont *pOutString; // [sp+10Ch] [bp-8h]@39
-  char *pInString; // [sp+110h] [bp-4h]@32
+  char *pInString=NULL; // [sp+110h] [bp-4h]@32
 
   if ( !pDialogueWindow )
     return;
@@ -16483,9 +16288,9 @@
   }
   v51.DrawTitleText(pFontArrus, 483, 112, v2, pTmpBuf, 3);
   pParty->GetPartyFame();
-  if ( (signed int)uDialogueType > 89 )
-  {
-    if ( uDialogueType == 90 )
+  if ( (signed int)uDialogueType > DIALOGUE_ARENA_WELCOME )
+  {
+    if ( uDialogueType == DIALOGUE_ARENA_FIGHT_NOT_OVER_YET )
     {
       pWindow.uFrameWidth = 460;
       pWindow.uFrameZ = 452;
@@ -16501,235 +16306,231 @@
       pRenderer->DrawTextureIndexed(8, 347 - v12, pTexture_591428);
       v13 = FitTextInAWindow(pGlobalTXT_LocalizationStrings[577], pFontArrus, &pWindow, 0xDu, 0);
       pDialogueWindow->DrawText(pFontArrus, 13, 354 - v12, 0, v13, 0, 0, 0);
-      goto LABEL_42;
-    }
-    if ( uDialogueType == 91 )
+    }
+    else if ( uDialogueType == DIALOGUE_ARENA_REWARD )
     {
       sprintf(v4, pGlobalTXT_LocalizationStrings[576], dword_F8B1B4);// "Congratulations on your win: here's your stuff: %u gold."
       pInString = v4;
-      v8 = 0;
       pWindow.uFrameWidth = 460;
       pWindow.uFrameZ = 452;
       pOutString = pFontArrus;
-      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
       if ( 352 - v12 < 8 )
       {
         pOutString = pFontCreate;
-        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
       }
       pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
         (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
       pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, v8);
-      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
-      goto LABEL_42;
-    }
-    if ( uDialogueType == 92 )
-    {
-      v7 = pGlobalTXT_LocalizationStrings[582]; // "You already won this trip to the Arena:"
-      v8 = 0;
+      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+    }
+    else if ( uDialogueType == DIALOGUE_ARENA_ALREADY_WON )
+    {
+      pInString = pGlobalTXT_LocalizationStrings[582]; // "You already won this trip to the Arena:"
+      pWindow.uFrameWidth = 460;
+      pWindow.uFrameZ = 452;
+      pOutString = pFontArrus;
+      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+      if ( 352 - v12 < 8 )
+      {
+        pOutString = pFontCreate;
+        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+      }
+      pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
+        (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
+      pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
+      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+    }
+  }
+  else
+  {
+    if ( uDialogueType == DIALOGUE_ARENA_WELCOME )
+    {
+      v7 = pGlobalTXT_LocalizationStrings[574]; // "Welcome to the Arena of Life and Death.  Remember, you are only allowed one arena combat per visit.  To fight an arena battle, select the option that best describes your abilities and return to me- if you survive:"
       pInString = v7;
       pWindow.uFrameWidth = 460;
       pWindow.uFrameZ = 452;
       pOutString = pFontArrus;
-      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
       if ( 352 - v12 < 8 )
       {
         pOutString = pFontCreate;
-        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
       }
       pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
         (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
       pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, v8);
-      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
-      goto LABEL_42;
-    }
-  }
-  else
-  {
-    if ( uDialogueType == 89 )
-    {
-      v7 = pGlobalTXT_LocalizationStrings[574]; // "Welcome to the Arena of Life and Death.  Remember, you are only allowed one arena combat per visit.  To fight an arena battle, select the option that best describes your abilities and return to me- if you survive:"
-      v8 = 0;
-      pInString = v7;
-      pWindow.uFrameWidth = 460;
-      pWindow.uFrameZ = 452;
-      pOutString = pFontArrus;
-      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
-      if ( 352 - v12 < 8 )
-      {
-        pOutString = pFontCreate;
-        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
-      }
-      pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
-        (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
-      pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, v8);
-      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
-      goto LABEL_42;
-    }
-    if ( uDialogueType == 13 )
+      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+    }
+    else if ( uDialogueType == DIALOGUE_13 )
     {
       v5 = 5 * pNPC->uProfession;
       v6 = (char *)*(&pNPCStats->field_13A64 + v5);
-      v8 = 0;
       v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
       pInString = v7;
       pWindow.uFrameWidth = 460;
       pWindow.uFrameZ = 452;
       pOutString = pFontArrus;
-      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
       if ( 352 - v12 < 8 )
       {
         pOutString = pFontCreate;
-        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
       }
       pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
         (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
       pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, v8);
-      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
-      goto LABEL_42;
-    }
-    if ( (signed int)uDialogueType > 18 )
-    {
-      if ( (signed int)uDialogueType > 24 )
-      {
-        if ( uDialogueType == 77 )
-        {
+      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+    }
+    else if ( (signed int)uDialogueType > DIALOGUE_18 && !((signed int)uDialogueType > DIALOGUE_24 && uDialogueType != DIALOGUE_77 || byte_5B0938[0]) )
+    {
+      if ( (signed int)uDialogueType > DIALOGUE_24 && uDialogueType == DIALOGUE_77 )
+      {
           v5 = 5 * pNPC->uProfession;
           if ( byte_F8B1EC )
           {
             v6 = (char *)*(&pNPCStats->field_13A5C + 5 * pNPC->uProfession);
-            v8 = 0;
             v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
             pInString = v7;
             pWindow.uFrameWidth = 460;
             pWindow.uFrameZ = 452;
             pOutString = pFontArrus;
-            v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+            v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
             if ( 352 - v12 < 8 )
             {
               pOutString = pFontCreate;
-              v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+              v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
             }
             pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
                               (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
             pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-            v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, v8);
-            pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
-            goto LABEL_42;
-          }
-          if ( pNPC->uFlags & 0x80 )
+            v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+            pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+          }
+          else if ( pNPC->uFlags & 0x80 )
           {
             v6 = (char *)*(&pNPCStats->field_13A68 + 5 * pNPC->uProfession);
-            v8 = 0;
             v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
             pInString = v7;
             pWindow.uFrameWidth = 460;
             pWindow.uFrameZ = 452;
             pOutString = pFontArrus;
-            v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+            v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
             if ( 352 - v12 < 8 )
             {
               pOutString = pFontCreate;
-              v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
+              v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
             }
             pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
                                (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
             pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-            v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, v8);
-            pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
-            goto LABEL_42;
-          }
-          v6 = (char *)*(&pNPCStats->field_13A64 + v5);
-          v8 = 0;
-          v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
-          pInString = v7;
-          pWindow.uFrameWidth = 460;
-          pWindow.uFrameZ = 452;
-          pOutString = pFontArrus;
-          v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
-          if ( 352 - v12 < 8 )
-          {
-            pOutString = pFontCreate;
-            v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
-          }
-          pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
-                                     (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
-          pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-          v13 = FitTextInAWindow(pInString, pOutString,  &pWindow, 0xDu, v8);
-          pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
-          goto LABEL_42;
-        }
-        goto LABEL_24;
-      }
-      if ( byte_5B0938[0] )
-        goto LABEL_24;
-      v7 = (char *)ptr_F8B1E8;
-      v8 = 0;
-      pInString = v7;
-      pWindow.uFrameWidth = 460;
-      pWindow.uFrameZ = 452;
-      pOutString = pFontArrus;
-      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
-      if ( 352 - v12 < 8 )
-      {
-        pOutString = pFontCreate;
-        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
-      }
-      pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
-        (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
-      pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, v8);
-      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
-      goto LABEL_42;
-    }
-  }
-LABEL_24:
-  if ( *(int *)v54 == 1 )
-  {
-    v11 = pNPC->greet;
-    v8 = 0;
-    if ( v11 )
-    {
-      v10 = (char *)*(&pNPCStats->field_17884 + ((pNPC->uFlags & 3) == 2) + 2 * v11);
-      goto LABEL_32;
-    }
-  }
-  else
-  {
-    if ( *(int *)v54 == 2 )
-    {
-      v8 = 0;
-      if ( pNPC->uFlags & 0x80 )
-        v9 = (char *)*(&pNPCStats->field_13A68 + 5 * pNPC->uProfession);
-      else
-        v9 = (char *)*(&pNPCStats->field_13A64 + 5 * pNPC->uProfession); //"Invalid String Passed"
-      v10 = sub_495461(v9, uActiveCharacter - 1, 0, 0, 0, 0);
-LABEL_32:
-      pInString = v10;
-      if ( v10 == (char *)v8 )
-        goto LABEL_42;
-      pWindow.uFrameWidth = 460;
-      pWindow.uFrameZ = 452;
-      pOutString = pFontArrus;
-      v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
-      if ( 352 - v12 < 8 )
-      {
-        pOutString = pFontCreate;
-        v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, v8) + 7;
-      }
-      pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
-        (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
-      pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-      v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, v8);
-      pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8);
-      goto LABEL_42;
-    }
-  }
-LABEL_42:
+            v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+            pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+          }
+		  else
+		  {
+			v6 = (char *)*(&pNPCStats->field_13A64 + v5);
+			v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
+			pInString = v7;
+			pWindow.uFrameWidth = 460;
+			pWindow.uFrameZ = 452;
+			pOutString = pFontArrus;
+			v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+			if ( 352 - v12 < 8 )
+			{
+			pOutString = pFontCreate;
+			v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+			}
+			pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
+										(uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
+			pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
+			v13 = FitTextInAWindow(pInString, pOutString,  &pWindow, 0xDu, 0);
+			pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+		  }
+      }
+	  else
+	  {
+		  v7 = (char *)ptr_F8B1E8;
+		  pInString = v7;
+		  pWindow.uFrameWidth = 460;
+		  pWindow.uFrameZ = 452;
+		  pOutString = pFontArrus;
+		  v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+		  if ( 352 - v12 < 8 )
+		  {
+			pOutString = pFontCreate;
+			v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+		  }
+		  pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
+			(uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
+		  pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
+		  v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+		  pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+	  }
+    }
+	else
+	{    
+		if ( *(int *)v54 == 1 )
+		{
+			v11 = pNPC->greet;
+			v8 = 0;
+			if ( v11 )
+			{
+				v10 = (char *)*(&pNPCStats->field_17884 + ((pNPC->uFlags & 3) == 2) + 2 * v11);
+				if (  pInString != NULL )
+				{
+					pWindow.uFrameWidth = 460;
+					pWindow.uFrameZ = 452;
+					pOutString = pFontArrus;
+					v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+					if ( 352 - v12 < 8 )
+					{
+						pOutString = pFontCreate;
+						v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+					}
+					pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
+					(uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
+					pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
+					v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+					pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+				}
+			}
+		}
+		else
+		{
+			if ( *(int *)v54 == 2 )
+			{
+				if ( pNPC->uFlags & 0x80 )
+					v9 = (char *)pNPCStats->pProfessions[pNPC->uProfession].pDismissText;
+				else
+					v9 = (char *)pNPCStats->pProfessions[pNPC->uProfession].pJoinText; //"Invalid String Passed"
+				pInString = sub_495461(v9, uActiveCharacter - 1, 0, 0, 0, 0);
+				if (  pInString != NULL )
+				{
+					pWindow.uFrameWidth = 460;
+					pWindow.uFrameZ = 452;
+					pOutString = pFontArrus;
+					v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+					if ( 352 - v12 < 8 )
+					{
+						pOutString = pFontCreate;
+						v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+					}
+					pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
+					(uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
+					pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
+					v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+					pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+				}
+			}
+		}
+	}
+  }
   memcpy(&v52, pDialogueWindow, sizeof(v52));
   v52.uFrameX = 483;
   v52.uFrameWidth = 148;
@@ -16743,125 +16544,107 @@
     if ( !v14 )
       break;
     v16 = v14->uControlParam;
-    if ( v16 > 24 )
-    {
-      v25 = v16 - 76;
-      if ( v25 )
-      {
-        v26 = v25 - 1;
-        if ( v26 )
-        {
-          v27 = v26 - 8;
-          if ( v27 )
-          {
-            v28 = v27 - 1;
-            if ( v28 )
-            {
-              v29 = v28 - 1;
-              if ( v29 )
-              {
-                if ( v29 != 1 )
-                {
-                  v24 = "";
-                  goto LABEL_79;
-                }
-                v24 = pGlobalTXT_LocalizationStrings[581];
-              }
-              else
-              {
-                v24 = pGlobalTXT_LocalizationStrings[580];
-              }
-            }
-            else
-            {
-              v24 = pGlobalTXT_LocalizationStrings[579];
-            }
-          }
-          else
-          {
-            v24 = pGlobalTXT_LocalizationStrings[578];
-          }
-        }
-        else
-        {
-          v24 = pGlobalTXT_LocalizationStrings[407];
-        }
-      }
-      else
-      {
-        if ( pNPC->uFlags & 0x80 )
-        {
-          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], pNPC->pName);
-          v24 = pTmpBuf;
-          goto LABEL_79;
-        }
-        v24 = pGlobalTXT_LocalizationStrings[406];
-      }
-    }
-    else
-    {
-      if ( v16 == 24 )
-      {
-        v23 = pNPC->evtf;
-LABEL_63:
-        v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
-        if ( !v24 )
-        {
-          v24 = "";
-          v15->uControlParam = 0;
-        }
-        goto LABEL_79;
-      }
-      v17 = v16 - 9;
-      if ( !v17 )
-      {
-        v24 = (const char *)sub_445308(pNPC->uProfession);
-        goto LABEL_79;
-      }
-      v18 = v17 - 4;
-      if ( v18 )
-      {
-        v19 = v18 - 6;
-        if ( !v19 )
-        {
-          v23 = pNPC->bDrawSomeAnim;
-          goto LABEL_63;
-        }
-        v20 = v19 - 1;
-        if ( !v20 )
-        {
-          v23 = pNPC->_anim_current_time;
-          goto LABEL_63;
-        }
-        v21 = v20 - 1;
-        if ( !v21 )
-        {
-          v23 = pNPC->_anim_end_time;
-          goto LABEL_63;
-        }
-        v22 = v21 - 1;
-        if ( !v22 )
-        {
-          v23 = pNPC->evtd;
-          goto LABEL_63;
-        }
-        if ( v22 == 1 )
-        {
-          v23 = pNPC->evte;
-          goto LABEL_63;
-        }
+
+    if ( v16 > 88 )
+    {
         v24 = "";
-        goto LABEL_79;
-      }
-      if ( pNPC->uFlags & 0x80 )
-      {
-        sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], pNPC->pName);
-        v24 = pTmpBuf;
-        goto LABEL_79;
-      }
-      v24 = pGlobalTXT_LocalizationStrings[122];
-    }
-LABEL_79:
+    }
+	else if ( v16 == 88 )
+		v24 = pGlobalTXT_LocalizationStrings[581];
+    else if ( v16 == 87 )
+	    v24 = pGlobalTXT_LocalizationStrings[580];
+    else if ( v16 == 86 )
+	    v24 = pGlobalTXT_LocalizationStrings[579];
+    else if ( v16 == 85 )
+		v24 = pGlobalTXT_LocalizationStrings[578];
+    else if ( v16 == 77 )
+        v24 = pGlobalTXT_LocalizationStrings[407];
+    else if ( v16 == 76 )
+    {
+		if ( pNPC->uFlags & 0x80 )
+		{
+			sprintf(pTmpBuf, (const char*)pGlobalTXT_LocalizationStrings[408], pNPC->pName);
+			v24 = pTmpBuf;
+		}
+		else
+			v24 = pGlobalTXT_LocalizationStrings[406];
+    }
+	else if ( v16 == 24 )
+    {
+		v23 = pNPC->evtf;
+		v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+		if ( !v24 )
+		{
+			v24 = "";
+			v15->uControlParam = 0;
+		}
+    }
+	else if ( v16 == 9 )
+		v24 = (const char *)sub_445308(pNPC->uProfession);
+	else if ( v16 == 19 )
+	{
+		v23 = pNPC->bDrawSomeAnim;
+		v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+		if ( !v24 )
+		{
+			v24 = "";
+			v15->uControlParam = 0;
+		}
+	}
+	else if ( v16 == 20 )
+	{
+		v23 = pNPC->_anim_current_time;
+		v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+		if ( !v24 )
+		{
+			v24 = "";
+			v15->uControlParam = 0;
+		}
+	}
+	else if ( v16 == 21 )
+	{
+		v23 = pNPC->_anim_end_time;
+		v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+		if ( !v24 )
+		{
+			v24 = "";
+			v15->uControlParam = 0;
+		}
+	}
+	else if ( v16 == 22 )
+	{
+		v23 = pNPC->evtd;
+		v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+		if ( !v24 )
+		{
+			v24 = "";
+			v15->uControlParam = 0;
+		}
+	}
+	else if ( v16 == 23 )
+	{
+		v23 = pNPC->evte;
+		v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+		if ( !v24 )
+		{
+			v24 = "";
+			v15->uControlParam = 0;
+		}
+	}
+	else if ( v16 == 13 )
+	{
+		if ( pNPC->uFlags & 0x80 )
+		{
+			sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], pNPC->pName);
+			v24 = pTmpBuf;
+		}
+		else
+			v24 = pGlobalTXT_LocalizationStrings[122];
+	}
+	else
+		v24 = "";
+	
+
     if ( pParty->field_7B5_in_arena_quest && pParty->field_7B5_in_arena_quest != -1 )
     {
       pInString = 0;
@@ -16949,18 +16732,23 @@
   NPCData *result; // eax@5
   int v3; // esi@9
   int v4; // ecx@9
-  int v5; // edx@9
-  NPCData *v6; // eax@9
+  //int v5; // edx@9
+  //NPCData *v6; // eax@9
   char *v7; // ebx@14
   NPCData *v8; // edi@14
   char v9; // al@22
-  std::string v10; // [sp-18h] [bp-2Ch]@4
-  const char *v11; // [sp-8h] [bp-1Ch]@4
+  char v10;
+  //std::string v10; // [sp-18h] [bp-2Ch]@4
+  int v11;
+  //const char *v11; // [sp-8h] [bp-1Ch]@4
   int v12; // [sp-4h] [bp-18h]@4
-  std::string *v13; // [sp+Ch] [bp-8h]@4
+  int v13; 
+  char *v14;
+  //std::string *v13; // [sp+Ch] [bp-8h]@4
   int a3; // [sp+13h] [bp-1h]@4
-
-  v1 = npcid;
+  int i;
+
+  /*v1 = npcid;
   if ( (npcid & 0x80000000u) == 0 )
   {
     if ( (signed int)npcid < 5000 )
@@ -17015,7 +16803,60 @@
     else
       result = &pParty->pHirelings[(unsigned __int8)v9];
   }
-  return result;
+  return result;*/
+  v1 = npcid;
+  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:1984", 0);
+      }
+      return &pNPCStats->pNewNPCData[v1];// - 1];
+    }
+    return &pNPCStats->array_13EF4[npcid - 5000];
+  }
+
+
+  if ( npcid >= 5000 )
+    return &pNPCStats->array_13EF4[npcid - 5000];
+  if (uDialogue_SpeakingActorNPC_ID >= 0)
+  {
+    result = 0;
+  }
+  else
+  {
+    v3 = uDialogue_SpeakingActorNPC_ID - 1;
+    v4 = 0;
+
+    for (i = 0; i < 4; ++i)
+    {
+      if (pParty->pHirelings[i].pName)
+        pTmpBuf[v4++] = i;
+    }
+
+    if (pNPCStats->uNumNewNPCs > 0)
+    {
+      for (i = 0; i < pNPCStats->uNumNewNPCs; ++i)
+      {
+        if (pNPCStats->pNewNPCData[i].uFlags & 0x80)
+        {
+          if (!pParty->pHirelings[0].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[0].pName))
+          {
+            if (!pParty->pHirelings[1].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[1].pName))
+              pTmpBuf[v4++] = i + 2;
+          }
+        }
+      }
+    }
+
+    v9 = pTmpBuf[v3];
+    if ( v9 >= 2 )
+     result = &pNPCStats->pNPCData[499 + v9];
+    else
+      result = &pParty->pHirelings[v9];
+  }
 }
 
 //----- (00445B2C) --------------------------------------------------------
@@ -18080,7 +17921,7 @@
 LABEL_119:
               v56 = &pParty->pPlayers[v57];
 LABEL_120:
-              v56->PlaySound(v114, v118);
+              v56->PlaySound((PlayerSpeech)v114, v118);
               ++v122;
               //v4 = v124;
               //v5 = pSomeEVT;
@@ -18089,12 +17930,12 @@
               break;
             }
             v55 = pParty->pPlayers;
-            do
-            {
-              v55->PlaySound(_evt->v6, 0);
+            for (int iii = 0; iii < 4; ++iii)
+            {
+              v55->PlaySound((PlayerSpeech)_evt->v6, 0);
               ++v55;
             }
-            while ( (signed int)v55 < (signed int)pParty->pHirelings );
+            //while ( (signed int)v55 < (signed int)pParty->pHirelings );
             ++v122;
             //v4 = v124;
             //v5 = pSomeEVT;
--- a/mm7_4.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/mm7_4.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -1,5 +1,6 @@
 #include <io.h>
 #include <direct.h>
+#include <assert.h>
 
 #include "MapInfo.h"
 #include "Game.h"
@@ -31,7 +32,6 @@
 #include "Time.h"
 #include "IconFrameTable.h"
 #include "GUIProgressBar.h"
-#include "stru157.h"
 #include "Bink_Smacker.h"
 #include "TileFrameTable.h"
 #include "PlayerFrameTable.h"
@@ -49,6 +49,7 @@
 #include "stru351.h"
 #include "Events2D.h"
 #include "stru159.h"
+#include "texts.h"
 #include "Log.h"
 
 #include "mm7_data.h"
@@ -2888,11 +2889,11 @@
   pTexture_PlayerFaceDead = pIcons_LOD->LoadTexturePtr("DEAD", TEXTURE_16BIT_PALETTE);
   pTexture_PlayerFaceMask = pIcons_LOD->LoadTexturePtr("FACEMASK", TEXTURE_16BIT_PALETTE);
   
-  if (byte_4ED498)
+  if (SoundSetAction[24][0])
     for (uint i = 0; i < 4; ++i)
     {
-      pSoundList->LoadSound(2 * (byte_4ED498 + 50 * pParty->pPlayers[i].uVoiceID) + 4998, 0);
-      pSoundList->LoadSound(2 * (byte_4ED498 + 50 * pParty->pPlayers[i].uVoiceID) + 4999, 0);
+      pSoundList->LoadSound(2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4998, 0);
+      pSoundList->LoadSound(2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4999, 0);
     }
 }
 
@@ -2940,7 +2941,7 @@
   v0 = pParty->pPlayers;
   do
   {
-    if ( byte_4ED498 )
+    if (SoundSetAction[24][0])
     {
       v1 = 0;
       if ( (signed int)pSoundList->uNumSounds <= 0 )
@@ -2951,7 +2952,7 @@
       else
       {
         v2 = (char *)&pSoundList->pSounds->uSoundID;
-        while ( *(int *)v2 != 2 * ((unsigned __int8)byte_4ED498 + 50 * v0->uVoiceID) + 4998 )
+        while ( *(int *)v2 != 2 * (SoundSetAction[24][0] + 50 * v0->uVoiceID) + 4998 )
         {
           ++v1;
           v2 += 120;
@@ -2970,7 +2971,7 @@
       else
       {
         v5 = (char *)&pSoundList->pSounds->uSoundID;
-        while ( *(int *)v5 != 2 * ((unsigned __int8)byte_4ED498 + 50 * v0->uVoiceID) + 4999 )
+        while ( *(int *)v5 != 2 * (SoundSetAction[24][0] + 50 * v0->uVoiceID) + 4999 )
         {
           ++v4;
           v5 += 120;
@@ -3147,7 +3148,7 @@
     if ( qword_A750D8 <= 0 )
     {
       if ( pPlayers[word_A750E2]->CanAct() )
-        pPlayers[word_A750E2]->PlaySound(word_A750E0, 0);
+        pPlayers[word_A750E2]->PlaySound((PlayerSpeech)word_A750E0, 0);
       qword_A750D8 = 0i64;
     }
   }
@@ -5844,7 +5845,7 @@
 //----- (00497526) --------------------------------------------------------
 bool __cdecl PlayerCreationUI_Loop()
 {
-  RGBTexture *pTexture; // ebx@1
+  //RGBTexture *pTexture; // ebx@1
   UINT v1; // esi@1
   unsigned int v2; // ecx@3
   LONG uMouseX; // edi@6
@@ -5858,10 +5859,10 @@
   Player *v11; // esi@38
   signed int uSpellBookPageCount; // ecx@40
   int v13; // eax@40
-  signed int uSkillIdx; // eax@45
+  //signed int uSkillIdx; // eax@45
   int v15; // eax@70
   signed int v16; // ecx@70
-  unsigned int v18; // [sp-4h] [bp-84h]@48
+  //unsigned int v18; // [sp-4h] [bp-84h]@48
   ItemGen item; // [sp+Ch] [bp-74h]@37
   char v20[32]; // [sp+30h] [bp-50h]@29
   //char v21; // [sp+31h] [bp-4Fh]@29
@@ -5870,10 +5871,10 @@
   MSG Msg; // [sp+50h] [bp-30h]@17
   POINT v25; // [sp+6Ch] [bp-14h]@6
   bool v26; // [sp+74h] [bp-Ch]@1
-  POINT v24; // [sp+78h] [bp-8h]@6
-  Player *pPlayer;
-
-  pTexture = &pTexture_PCX;
+  //POINT v24; // [sp+78h] [bp-8h]@6
+  //Player *pPlayer;
+
+  //pTexture = &pTexture_PCX;
   v1 = 0;
   v26 = 0;
   pTexture_PCX.Release();
@@ -5888,7 +5889,7 @@
   {
     if ( pAsyncMouse != (void *)v1 )
       pAsyncMouse->_46B736_consume_click_lists(1);
-    uMouseX = pMouse->GetCursorPos(&v24)->x;
+    uMouseX = pMouse->GetCursorPos(&v25)->x;
     uMouseY = pMouse->GetCursorPos(&v25)->y;
     pControlsHead = pGUIWindow_CurrentMenu->pControlsHead;
     if ( pControlsHead != (GUIButton *)v1 )
@@ -5903,7 +5904,7 @@
           if ( (signed int)pNumMessage < 40 )
           {
             pMessageQueue_50CBD0->pMessages[pNumMessage].eType = (UIMessageType)pControlsHead->field_1C;
-            pTexture = &pTexture_PCX;
+            //pTexture = &pTexture_PCX;
             pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = pControlParam;
             *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
             pNumMessage = pMessageQueue_50CBD0->uNumMessages + 1;
@@ -5952,13 +5953,11 @@
       }
     }
   }
-  pTexture->Release();
+  pTexture_PCX.Release();
   pGUIWindow_CurrentMenu->Release();
   pIcons_LOD->_4114F2();
-  v20[0] = 0;
-  memset(&v20[1], 0, 0x1Cu);
-  *(_WORD*)&v20[29] = 0;
-  v20[31] = 0;
+
+  memset(v20, 0, 32);
   do
   {
     v8 = 0;
@@ -5984,142 +5983,107 @@
     v20[v9] = 1;
   }
   while ( (signed int)v1 < 32 );
+  //v10 = (char *)&pParty->pPlayers[0].sResMagicBase;
+  
   item.Reset();
-  //v10 = (char *)&pParty->pPlayers[0].sResMagicBase;
-  for ( pPlayer = &pParty->pPlayers[0];  pPlayer < &pParty->pPlayers[4]; pPlayer++)
-  {
+  //for ( pPlayer = &pParty->pPlayers[0];  pPlayer < &pParty->pPlayers[4]; pPlayer++)
+  for (uint i = 0; i < 4; ++i)
+  {
+    auto player = &pParty->pPlayers[i];
     //v11 = pPlayer;
-    if (pPlayer->classType == PLAYER_CLASS_KNIGHT)
-      pPlayer->sResMagicBase = 10;
+    if (player->classType == PLAYER_CLASS_KNIGHT)
+      player->sResMagicBase = 10;
     //*((short *)v10 + 400) = 0;
-    pPlayer->pPlayerBuffs[22].uExpireTime = 0;
+    player->pPlayerBuffs[22].uExpireTime = 0;
     uSpellBookPageCount = 0;
-    for ( int i = 0; i < 9; i++)
-    {
-      if ( pPlayer->pActiveSkills[12+i] )
+    for (uint j = 0; j < 9; j++)
+    {
+      if (player->pActiveSkills[PLAYER_SKILL_FIRE + j])
         ++uSpellBookPageCount;
     }
-    pPlayer->pNumSpellBookPage = uSpellBookPageCount;
+    player->lastOpenedSpellbookPage = uSpellBookPageCount;
     pItemsTable->GenerateItem(2, 40, &item);
-    pPlayer->AddItem2(-1, &item);
-    uSkillIdx = 0;
-    v24.y = 0;
-    do
-    {
-      if ( pPlayer->pActiveSkills[uSkillIdx] )
-      {
-        switch ( uSkillIdx )
-        {
-          case 0:
-            v18 = 61;
-            pPlayer->AddItem(-1, v18);
-            break;
-          case 1:
-            v18 = 1;
-            pPlayer->AddItem(-1, v18);
-            break;
-          case 2:
-            v18 = 15;
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 3:
-            v18 = 23;
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 4:
-            v18 = 31;
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 5:
-            v18 = 47;
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 6:
-            v18 = 50;
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 8:
-            v18 = 84;
-  			pPlayer->AddItem(-1, v18);
-            break;
-          case 9:
-            v18 = 66;
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 10:
-            v18 = 71;
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 11:
-            v18 = 76;
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 12:
-            pPlayer->AddItem(-1, 0x191);
-            pPlayer->spellbook.pFireSpellbook.bIsSpellbookAvailable = 1;
-            break;
-          case 13:
-            pPlayer->AddItem(-1, 0x19C);
-            pPlayer->spellbook.pAirSpellbook.bIsSpellbookAvailable = 1;
-            break;
-          case 14:
-            pPlayer->AddItem(-1, 0x1A7);
-			pPlayer->spellbook.pWaterSpellbook.bIsSpellbookAvailable = 1;
-            break;
-          case 15:
-            pPlayer->AddItem(-1, 0x1B2);
-			pPlayer->spellbook.pEarthSpellbook.bIsSpellbookAvailable = 1;
-            break;
-          case 16:
-            pPlayer->AddItem(-1, 0x1BD);
-			pPlayer->spellbook.pSpiritSpellbook.bIsSpellbookAvailable = 1;
-            break;
-          case 17:
-            pPlayer->AddItem(-1, 0x1C8);
-			pPlayer->spellbook.pMindSpellbook.bIsSpellbookAvailable = 1;
-            break;
-          case 18:
-            pPlayer->AddItem(-1, 0x1D3);
-			pPlayer->spellbook.pBodySpellbook.bIsSpellbookAvailable = 1;
-            break;
-          case 21:
-          case 23:
-          case 25:
-          case 26:
-          case 29:
-          case 36:
-            pPlayer->AddItem(-1, 0xDC);
-            v18 = 5 * (rand() % 3 + 40);
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 30:
-            v18 = 115;
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 31:
-            v18 = 110;
-            pPlayer->AddItem(-1, v18);
-            break;
-          default:
-            break;
-        }
-		for ( int i = 0; i < 138; i++)
-        {
-          if ( &pPlayer->pInventoryItems[i] )
-            pPlayer->pInventoryItems[i].uAttributes |= 1;
-         }
-        pPlayer->sHealth = pPlayer->GetMaxHealth();
-        pPlayer->sMana = pPlayer->GetMaxMana();
-        uSkillIdx = v24.y;
-      }
-      ++uSkillIdx;
-      v24.y = uSkillIdx;
-    }
-    while ( uSkillIdx < 37 );
-    //v10 += 6972;
-	//pPlayer++;
-  }
-  //while ( (signed int)v10 < (signed int)((char *)&pParty->field_871C[455] + 2) );
+    player->AddItem2(-1, &item);
+    //uSkillIdx = 0;
+    //v24.y = 0;
+
+    player->sHealth = player->GetMaxHealth();
+    player->sMana = player->GetMaxMana();
+    for (uint j = 0; j < 37; ++j)
+    {
+      if (!player->pActiveSkills[j])
+        continue;
+
+      switch (j)
+      {
+        case PLAYER_SKILL_STAFF:   player->AddItem(-1, 61); break;
+        case PLAYER_SKILL_SWORD:   player->AddItem(-1, 1); break;
+        case PLAYER_SKILL_DAGGER:  player->AddItem(-1, 15); break;
+        case PLAYER_SKILL_AXE:     player->AddItem(-1, 23); break;
+        case PLAYER_SKILL_SPEAR:   player->AddItem(-1, 31); break;
+        case PLAYER_SKILL_BOW:     player->AddItem(-1, 47); break;
+        case PLAYER_SKILL_MACE:    player->AddItem(-1, 50); break;
+        case PLAYER_SKILL_BLASTER: assert(false); break;
+        case PLAYER_SKILL_SHIELD:  player->AddItem(-1, 84); break;
+        case PLAYER_SKILL_LEATHER: player->AddItem(-1, 66); break;
+        case PLAYER_SKILL_CHAIN:   player->AddItem(-1, 71); break;
+        case PLAYER_SKILL_PLATE:   player->AddItem(-1, 76); break;
+        case PLAYER_SKILL_FIRE:
+          player->AddItem(-1, 0x191);
+          player->spellbook.pFireSpellbook.bIsSpellAvailable[0] = true;
+        break;
+        case PLAYER_SKILL_AIR:
+          player->AddItem(-1, 0x19C);
+          player->spellbook.pAirSpellbook.bIsSpellAvailable[0] = true;
+        break;
+        case PLAYER_SKILL_WATER:
+          player->AddItem(-1, 0x1A7);
+		  player->spellbook.pWaterSpellbook.bIsSpellAvailable[0] = true;
+        break;
+        case PLAYER_SKILL_EARTH:
+          player->AddItem(-1, 0x1B2);
+		  player->spellbook.pEarthSpellbook.bIsSpellAvailable[0] = true;
+        break;
+        case PLAYER_SKILL_SPIRIT:
+          player->AddItem(-1, 0x1BD);
+		  player->spellbook.pSpiritSpellbook.bIsSpellAvailable[0] = true;
+        break;
+        case PLAYER_SKILL_MIND:
+          player->AddItem(-1, 0x1C8);
+		  player->spellbook.pMindSpellbook.bIsSpellAvailable[0] = true;
+        break;
+        case PLAYER_SKILL_BODY:
+          player->AddItem(-1, 0x1D3);
+		  player->spellbook.pBodySpellbook.bIsSpellAvailable[0] = true;
+        break;
+        case PLAYER_SKILL_LIGHT:
+        case PLAYER_SKILL_DARK:
+        case PLAYER_SKILL_DIPLOMACY:
+          assert(false);
+        break;
+        case PLAYER_SKILL_ITEM_ID:
+        case PLAYER_SKILL_REPAIR:
+        case PLAYER_SKILL_MEDITATION:
+        case PLAYER_SKILL_PERCEPTION:
+        case PLAYER_SKILL_TRAP_DISARM:
+        case PLAYER_SKILL_LEARNING:
+          player->AddItem(-1, 0xDC);
+		  player->AddItem(-1, 5 * (rand() % 3 + 40));
+        break;
+        case PLAYER_SKILL_DODGE:   player->AddItem(-1, 115); break;
+        case PLAYER_SKILL_UNARMED: player->AddItem(-1, 110); break;
+        default:
+          break;
+      }
+
+      for (uint k = 0; k < 138; k++)
+      {
+        if (&player->pInventoryItems[k])
+          player->pInventoryItems[k].uAttributes |= 1;
+      }
+    }
+  }
+
   pAudioPlayer->StopChannels(-1, -1);
   if (pAsyncMouse)
     pAsyncMouse->Suspend();
@@ -9140,7 +9104,7 @@
           || pMouse->GetCursorPos((POINT *)&v12)->x >= 462
           || (v9 = v0->GetItemIDAtInventoryIndex(&v18)) == 0 )
           return;
-        v7 = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v9 + 5];
+        v7 = (ItemGen *)&v0->pInventoryItems[v9-1];
 LABEL_15:
         GameUI_DrawItemInfo(v7);
         return;
@@ -9565,7 +9529,7 @@
                 v13[1] |= 1u;
                 break;
             }
-            pPlayers[uActiveCharacter]->PlaySound(85, 0);
+            pPlayers[uActiveCharacter]->PlaySound(SPEECH_85, 0);
           }
           if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
           {
@@ -9635,9 +9599,9 @@
           if ( uActiveCharacter )
           {
             v25 = 0;
-            v23 = 86;
+            v23 = SPEECH_86;
 LABEL_50:
-            pPlayers[v11]->PlaySound(v23, v25);
+            pPlayers[v11]->PlaySound((PlayerSpeech)v23, v25);
             goto _return;
           }
         }
@@ -9664,7 +9628,7 @@
       ptr_F8B1E8 = (char *)*(&pNPCStats->field_13A64 + 5 * v2->uProfession);
       ptr_F8B1E8 = sub_495461((char *)ptr_F8B1E8, uActiveCharacter - 1, 0, 0, 0, 0);
       if ( uActiveCharacter )
-        pPlayers[uActiveCharacter]->PlaySound(38, 0);
+        pPlayers[uActiveCharacter]->PlaySound(SPEECH_38, 0);
       v19 = pGlobalTXT_LocalizationStrings[155];
       goto LABEL_77;
     }
@@ -11762,7 +11726,7 @@
               if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
                 pOutdoor->SetFog();
             }
-            v0->PlaySound(87, 0);
+            v0->PlaySound(SPEECH_87, 0);
             sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[430], v0->pName, v0->uLevel, v0->uLevel / 10 + 5);// 
                                                 // "%s is now Level %lu and has earned %lu Skill Points!"
             ShowStatusBarString(pTmpBuf, 2u);
@@ -12302,7 +12266,7 @@
                 {
                   v96 = 0;
                   v94 = 4;
-                  v4 = &_this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * result + 5];
+                  v4 = (char *)&_this->pInventoryItems[result-1];
                   if ( v4[20] & 1 )
                   {
                     v5 = sub_495461("%24", uActiveCharacter - 1, (ItemGen *)v4, (char *)ptr_507BC0->ptr_1C, 4, 0);
@@ -12342,7 +12306,7 @@
       v96 = 0;
       v94 = 3;
       v93 = ptr_507BC0->ptr_1C;
-      v90 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * result + 5];
+      v90 = (ItemGen *)&_this->pInventoryItems[result-1];
       v12 = (int)ptr_507BC0->ptr_1C;
       uPlayerID = uActiveCharacter - 1;
       v13 = _this->_490EEE(v90, 3, v12, 3);
@@ -12692,7 +12656,7 @@
         byte_F8B1EC = 0;
         uDialogueType = 13;
         if ( uActiveCharacter )
-          pPlayers[uActiveCharacter]->PlaySound(38, 0);
+          pPlayers[uActiveCharacter]->PlaySound(SPEECH_38, 0);
         v7 = pGlobalTXT_LocalizationStrings[155];
         goto LABEL_64;
       }
@@ -12724,7 +12688,7 @@
     if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
       pDialogue_SpeakingActor->uAIState = Removed;
     if ( uActiveCharacter )
-      pPlayers[uActiveCharacter]->PlaySound(61, 0);
+      pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0);
     goto LABEL_87;
   }
   if ( v3 == 22 )
@@ -13496,7 +13460,7 @@
           }
         }
         ++byte_F8B1EF[v29];
-        v1->PlaySound(83, 0);
+        v1->PlaySound(SPEECH_83, 0);
         ShowStatusBarString(pGlobalTXT_LocalizationStrings[527], 2u);
         goto LABEL_46;
       }
@@ -13557,7 +13521,7 @@
     HIDWORD(v1->pConditions[17]) = (int)v39;
 LABEL_63:
     pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x2), -1, 0, -1, 0, 0, 0, 0);
-    v1->PlaySound(82, 0);
+    v1->PlaySound(SPEECH_82, 0);
     pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536);
 LABEL_46:
     result = pMessageQueue_50CBD0->uNumMessages;
@@ -14220,7 +14184,7 @@
         v12 = (unsigned __int8)v5[8];
         if ( (signed int)ptr_507BC0->ptr_1C >= 63 )
         {
-          v63 = 72;
+          v63 = SPEECH_72;
           v13 = 2500;
           if ( CheckHiredNPCSpeciality(8u) )
             v12 -= 2;
@@ -14230,7 +14194,7 @@
         }
         else
         {
-          v63 = 71;
+          v63 = SPEECH_71;
           v13 = 1500;
           v47[1] = (const char *)35;
         }
@@ -14241,7 +14205,7 @@
         if ( v12 < 1 )
           v12 = 1;
         RestAndHeal(1440 * v12);
-        v61->PlaySound(v63, 0);
+        v61->PlaySound((PlayerSpeech)v63, 0);
         v14 = GetTickCount();
         v15 = v14 + v13;
         if ( v15 < v14 )
@@ -14718,9 +14682,11 @@
     v0->uScreenSpaceY = a6;
     LOWORD(v25) = 0;
     LOBYTE(v26) = v41;
-    v0->sZValue = v25 + (8 * i | 3);
-    //v27 = pMonsterList->pMonsters;
-    //v28 = p->pMonsterInfo.uID;
+
+    //v0->sZValue = v25 + (8 * i | OBJECT_Actor);
+    v0->actual_z = HIWORD(x);
+    v0->object_pid = v8 * i | OBJECT_Actor;
+
     v29 = HIDWORD(p->pActorBuffs[5].uExpireTime) == 0;
     v30 = HIDWORD(p->pActorBuffs[5].uExpireTime) < 0;
     v0->field_1E = v41;
@@ -14900,7 +14866,7 @@
   if ( BYTE1(pAnimatedRooms[p2DEvents[v9 - 1].uAnimationID].field_C) )
     HousePlaySomeSound(v9, 1);
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30 )
-    pPlayers[uActiveCharacter]->PlaySound(47, 0);
+    pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0);
   result = v23;
   if ( v23 )
     uCurrentHouse_Animation = v23;
@@ -15106,7 +15072,7 @@
       sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[414], v6, aAMPMNames[v7], v9, aAMPMNames[v8]);
       ShowStatusBarString(pTmpBuf, 2u);
       if ( uActiveCharacter )
-        pPlayers[uActiveCharacter]->PlaySound(3, 0);
+        pPlayers[uActiveCharacter]->PlaySound(SPEECH_3, 0);
       return 0;
     }
   }
--- a/mm7_5.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/mm7_5.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -41,6 +41,7 @@
 #include "stru298.h"
 #include "StorylineTextTable.h"
 #include "Events2D.h"
+#include "texts.h"
 #include "Log.h"
 
 #include "mm7_data.h"
@@ -68,9 +69,9 @@
   unsigned int v2; // edx@7
   Actor *pActor; // ecx@13
   int v4; // ecx@18
-  NPCData *pNPCData0; // eax@18
-  int v6; // edx@20
-  int v7; // ecx@29
+  //NPCData *pNPCData0; // eax@18
+  //int v6; // edx@20
+  //int v7; // ecx@29
   unsigned int v8; // edx@59
   unsigned int v9; // ecx@60
   unsigned int v10; // ecx@73
@@ -243,7 +244,7 @@
   const char *v177; // [sp+0h] [bp-5FCh]@629
   char *v178; // [sp+0h] [bp-5FCh]@637
   int v179; // [sp+4h] [bp-5F8h]@0
-  signed int _this; // [sp+14h] [bp-5E8h]@22
+  //signed int _this; // [sp+14h] [bp-5E8h]@22
   signed int thisa; // [sp+14h] [bp-5E8h]@251
   signed int thisb; // [sp+14h] [bp-5E8h]@272
   Player *pPlayer7; // [sp+14h] [bp-5E8h]@373
@@ -332,50 +333,56 @@
           //goto _actor_init_dlg;
           pActor->InitializeDialogue(v0);
           continue;
-        case UIMSG_86:
-        case UIMSG_87:
-          if ( bNoNPCHiring != 1 && !pCurrentScreen )
-          {
+        case UIMSG_StartHireling1Dialogue:
+        case UIMSG_StartHireling2Dialogue:
+        {
+          if (bNoNPCHiring || pCurrentScreen)
+            continue;
+
             if ( pMessageQueue_50CBD0->uNumMessages )
               pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
             uAction = 0;
-            uNumSeconds = uMessage - 134;
+            int hireling_idx = uMessage - UIMSG_StartHireling1Dialogue;
             v4 = 0;
-            pNPCData0 = pParty->pHirelings;
-            do
-            {
-              if ( pNPCData0->pName )
-              {
-                v6 = uAction++;
-                pTmpBuf[v6] = v4;
-              }
-              ++pNPCData0;
-              ++v4;
-            }
-            while ( (signed int)pNPCData0 < (signed int)&pParty->pPickedItem );
-            _this = 0;
-            if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
-            {
-              pNPCData4 = pNPCStats->pNewNPCData;
-              do
-              {
-                if ( pNPCData4->uFlags & 0x80
-                  && (!pParty->pHirelings[0].pName || strcmp(pNPCData4->pName, pParty->pHirelings[0].pName))
-                  && (!pParty->pHirelings[1].pName || strcmp(pNPCData4->pName, pParty->pHirelings[1].pName)) )
+
+            for (uint i = 0; i < 2; ++i)
+            //pNPCData0 = pParty->pHirelings;
+            //do
+            {
+              if (pParty->pHirelings[i].pName)
+              //{
+                //v6 = uAction++;
+                pTmpBuf[uAction++] = i;
+              //}
+              //++pNPCData0;
+              //++v4;
+            }
+            //while ( (signed int)pNPCData0 < (signed int)&pParty->pPickedItem );
+
+            //_this = 0;
+            for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i)
+            {
+              auto npc = pNPCStats->pNewNPCData + i;
+              //do
+              //{
+                if (npc->uFlags & 0x80 &&
+                    (!pParty->pHirelings[0].pName || strcmp(npc->pName, pParty->pHirelings[0].pName)) &&
+                    (!pParty->pHirelings[1].pName || strcmp(npc->pName, pParty->pHirelings[1].pName)) )
                 {
-                  v7 = uAction++;
-                  pTmpBuf[v7] = _this + 2;
+                  //v7 =;
+                  pTmpBuf[uAction++] = i + 2;
                 }
-                ++_this;
-                ++pNPCData4;
-              }
-              while ( _this < (signed int)pNPCStats->uNumNewNPCs );
-            }
-            if ( (signed int)(uNumSeconds + (unsigned __int8)pParty->field_709) < uAction )
+                //++_this;
+                //++pNPCData4;
+              //}
+              //while ( _this < (signed int)pNPCStats->uNumNewNPCs );
+            }
+
+            if ( (signed int)(hireling_idx + (unsigned __int8)pParty->field_709) < uAction )
             {
               //Actor::Actor(&actor);
               memset(&actor, 0, 0x344u);
-              actor.uNPC_ID += -1 - (unsigned __int8)pParty->field_709 - uNumSeconds;
+              actor.uNPC_ID += -1 - (unsigned __int8)pParty->field_709 - hireling_idx;
               pActor = &actor;
 //_actor_init_dlg:
               pActor->InitializeDialogue(v0);
@@ -2879,9 +2886,9 @@
             {
               v89 = uActiveCharacter;
               v176 = 0;
-              v160 = 108;
+              v160 = SPEECH_108;
 LABEL_619:
-              pPlayers[v89]->PlaySound(v160, v176);
+              pPlayers[v89]->PlaySound((PlayerSpeech)v160, v176);
             }
           }
           else
@@ -2894,13 +2901,13 @@
             if ( !v90 )
               v90 = rand() % (signed int)pMapStats->uNumMaps + 1;
             pMapInfo = &pMapStats->pInfos[v90];
-            if ( rand() % 100 + 1 <= pMapInfo->field_30 )
+            if ( rand() % 100 + 1 <= pMapInfo->Encounter_percent )
             {
               v91 = rand() % 100;
-              v92 = pMapInfo->field_31;
+              v92 = pMapInfo->EncM1percent;
               v93 = v91 + 1;
               if ( v93 > v92 )
-                pNPCData4 = (NPCData *)((v93 > v92 + pMapInfo->field_32) + 2);
+                pNPCData4 = (NPCData *)((v93 > v92 + pMapInfo->EncM2percent) + 2);
               else
                 pNPCData4 = (NPCData *)v0;
               if ( !sub_45063B(pMapInfo, (int)pNPCData4) )
@@ -2961,7 +2968,7 @@
         case UIMSG_4E:
           if ( dword_50654C && byte_506550 )
           {
-            v173 = pSpellStats->pInfos[dword_50654C + 11 * pPlayers[uActiveCharacter]->pNumSpellBookPage].pName;
+            v173 = pSpellStats->pInfos[dword_50654C + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage].pName;
             v157 = pGlobalTXT_LocalizationStrings[483];
 _sprintex_2args_draw_status_and_continue:
             sprintf(pTmpBuf, v157, v173);
@@ -3018,11 +3025,11 @@
             v127 = 203;
             goto _play_sound_and_continue;
           }
-          v99 = dword_50654C + 11 * pPlayers[uActiveCharacter]->pNumSpellBookPage;
+          v99 = dword_50654C + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage;
           pPlayers[uActiveCharacter]->uQuickSpell = v99;
           stru_A750F8[uActiveCharacter + 3]._494836(v99, uActiveCharacter);
           if ( uActiveCharacter )
-            pPlayer10->PlaySound(12, 0);
+            pPlayer10->PlaySound(SPEECH_12, 0);
           byte_506550 = 0;
           continue;
         case UIMSG_33:
@@ -3037,7 +3044,7 @@
           {
             if ( *(short *)thisl )
             {
-              if ( pPlayer3->pNumSpellBookPage == v101 )
+              if ( pPlayer3->lastOpenedSpellbookPage == v101 )
                 uAction = (int)pNPCData4;
               v102 = (int)pNPCData4;
               pNPCData4 = (NPCData *)((char *)pNPCData4 + 1);
@@ -3072,7 +3079,7 @@
               uAction = 0;
           }
           sub_41140B();
-          pPlayers[uActiveCharacter]->pNumSpellBookPage = LOBYTE(v217[uAction]);
+          pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = LOBYTE(v217[uAction]);
           pGUIWindow_CurrentMenu->OpenSpellBook();
           v165 = 0;
           v151 = 0;
@@ -3084,10 +3091,10 @@
           v127 = rand() % 2 + 204;
           goto _play_sound_and_continue;
         case UIMSG_57:
-          if ( pTurnEngine->field_4 == 3 || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->pNumSpellBookPage )
+          if ( pTurnEngine->field_4 == 3 || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->lastOpenedSpellbookPage )
             continue;
           sub_41140B();
-          pPlayers[uActiveCharacter]->pNumSpellBookPage = uMessageParam;
+          pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = uMessageParam;
           pGUIWindow_CurrentMenu->OpenSpellBook();
           v165 = 0;
           v151 = 0;
@@ -3243,7 +3250,7 @@
           pRenderer->SavePCXImage("gamma.pcx", (char *)uNumSeconds, 155, 117);
           free((void *)uNumSeconds);
           stru_506E40._40E55E("gamma.pcx", 0);
-          GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, (enum WindowType)92, (int)pBtn_GameSettings, 0);
+          GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, WINDOW_VoiceSwitcherButton, (int)pBtn_GameSettings, 0);
 //LABEL_453:
           if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
             continue;
@@ -3342,7 +3349,7 @@
             {
               *(short *)v105 = uNumSeconds + 1;
               pPlayer4->uSkillPoints -= pPlayer4->pActiveSkills[uMessageParam] & 0x3F;
-              pPlayer4->PlaySound(14, 0);
+              pPlayer4->PlaySound(SPEECH_14, 0);
               v165 = 0;
               v151 = 0;
               v144 = 0;
@@ -3472,7 +3479,7 @@
           v158 = pParty->uNumGold + pParty->uNumGoldInBank;
           v146 = pGlobalTXT_LocalizationStrings[489];// "You have %d total gold, %d in the Bank""
           //goto _sprintex_draw_status_and_continue;
-          sprintf(pTmpBuf, v146, v158, v174);
+          sprintfex(pTmpBuf, v146, v158, v174);
           sub_41C0B8_set_status_string(pTmpBuf);
           continue;
         case UIMSG_ShowStatus_DateTime:
@@ -3618,7 +3625,7 @@
 //LABEL_733:
           GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
           continue;
-        case UIMSG_194:
+        case UIMSG_Game_Action:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           OnPressSpace();
@@ -3744,11 +3751,11 @@
   enum PLAYER_SKILL_TYPE v6; // edi@37
   GUIWindow *pWindow; // eax@56
   unsigned int v8; // edx@56
-  Player *pCurrentPlayer; // edi@57
+  //Player *pCurrentPlayer; // edi@57
   signed int v10; // eax@58
   GUIButton *pButton; // eax@59
-  unsigned __int8 v12; // sf@62
-  signed int v13; // eax@64
+  //unsigned __int8 v12; // sf@62
+  //signed int v13; // eax@64
   unsigned int v14; // eax@66
   int v15; // edi@70
   char v16; // zf@73
@@ -3777,7 +3784,7 @@
   int v43; // [sp-10h] [bp-20h]@56
   int uNum; // [sp+4h] [bp-Ch]@3
   UIMessageType pUIMessageType; // [sp+8h] [bp-8h]@3
-  int pSex; // [sp+Ch] [bp-4h]@3
+  //int pSex; // [sp+Ch] [bp-4h]@3
   Player *pPlayer;
 
   if ( pMessageQueue_50CBD0->uNumMessages )
@@ -3787,7 +3794,9 @@
     pPlayer = pParty->pPlayers;
     do
     {
-      pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &uNum, &pSex);
+      int param2;
+      pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &uNum, &param2);
+
       switch (pUIMessageType) // For buttons of window MainMenu
       {
         case UIMSG_MainMenu_ShowPartyCreationWnd:
@@ -3816,6 +3825,99 @@
         continue;
       }
 
+      
+      switch (pUIMessageType) // For buttons of Party Creation Window
+      {
+        case UIMSG_PlayerCreation_SelectAttribute:
+        {
+            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
+                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
+            uPlayerCreationUI_SelectedCharacter = uNum;
+            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
+        }
+        continue;
+
+        case UIMSG_PlayerCreation_VoicePrev:
+        {
+            auto player = &pParty->pPlayers[uNum];
+            auto sex = player->GetSexByVoice();
+            do
+            {
+              if (player->uVoiceID == 0)
+                player->uVoiceID = 19;
+              else --player->uVoiceID;
+            }
+            while (player->GetSexByVoice() != sex);
+
+            pButton = pCreationUI_BtnPressLeft2[uNum];
+            GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_VoiceSwitcherButton, (int)pButton, 1);
+            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
+            player->PlaySound(SPEECH_PickMe, 0);
+        }
+        continue;
+
+        case UIMSG_PlayerCreation_VoiceNext:
+        {
+            auto player = &pParty->pPlayers[uNum];
+            auto sex = player->GetSexByVoice();
+            do
+            {
+              player->uVoiceID = (player->uVoiceID + 1) % 20;
+            }
+            while (player->GetSexByVoice() != sex);
+
+            pButton = pCreationUI_BtnPressRight2[uNum];
+            GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_VoiceSwitcherButton, (int)pButton, 1);
+            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
+            player->PlaySound(SPEECH_PickMe, 0);
+        }
+        continue;
+
+        case UIMSG_PlayerCreation_FacePrev:
+        {
+            pPlayer = &pParty->pPlayers[uNum];
+            unsigned char v12 = (char)((int)pPlayer->uFace - 1) < 0;
+            --pPlayer->uFace;
+            if ( v12 )
+              pPlayer->uFace = 19;
+            pPlayer->uVoiceID = pPlayer->uFace;
+            pPlayer->SetInitialStats();
+            pPlayer->SetSexByVoice();
+            pPlayer->RandomizeName();
+            v25 = uNum;
+            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
+                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
+            uPlayerCreationUI_SelectedCharacter = v25;
+            GUIWindow::Create(pCreationUI_BtnPressLeft[v25]->uX, pCreationUI_BtnPressLeft[v25]->uY, 0, 0, WINDOW_VoiceSwitcherButton, (int)pCreationUI_BtnPressLeft[v25], 1);
+            //v0 = pAudioPlayer;
+            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0.0, 0);
+            pPlayer->PlaySound(SPEECH_PickMe, 0);
+            //v1 = (char *)pParty->pPlayers;
+        }
+        continue;
+
+        case UIMSG_PlayerCreation_FaceNext:
+        {
+            pPlayer = &pParty->pPlayers[uNum];
+            v20 = (char)((int)pPlayer->uFace + 1) % 20;
+            pPlayer->uFace = v20;
+            pPlayer->uVoiceID = v20;
+            pPlayer->SetInitialStats();
+            pPlayer->SetSexByVoice();
+            pPlayer->RandomizeName();
+            v21 = uNum;
+            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
+                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
+            uPlayerCreationUI_SelectedCharacter = v21;
+            GUIWindow::Create(pCreationUI_BtnPressRight[v21]->uX, pCreationUI_BtnPressRight[v21]->uY, 0, 0, WINDOW_VoiceSwitcherButton, (int)pCreationUI_BtnPressRight[v21], 1);
+            //v0 = pAudioPlayer;
+            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
+            pPlayer->PlaySound(SPEECH_PickMe, 0);
+            //v1 = (char *)pParty->pPlayers;
+        }
+        continue;
+      }
+
       switch (pUIMessageType) // For buttons of window LoadGame
       {
         case UIMSG_LoadGame:
@@ -3887,50 +3989,6 @@
       {
         if ( pUIMessageType > UIMSG_DownArrow )
         {
-          if ( pUIMessageType == UIMSG_SelectFacePlayerBack )
-          {
-            pPlayer = &pParty->pPlayers[uNum];
-            v12 = (char)((int)pPlayer->uFace - 1) < 0;
-            --pPlayer->uFace;
-            if ( v12 )
-              pPlayer->uFace = 19;
-            pPlayer->uVoiceID = pPlayer->uFace;
-            pPlayer->SetInitialStats();
-            pPlayer->SetSexByVoice();
-            pPlayer->RandomizeName();
-            v25 = uNum;
-            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
-                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
-            uPlayerCreationUI_SelectedCharacter = v25;
-            GUIWindow::Create(pCreationUI_BtnPressLeft[v25]->uX, pCreationUI_BtnPressLeft[v25]->uY, 0, 0,
-              (enum WindowType)92, (int)pCreationUI_BtnPressLeft[v25], 1);
-            //v0 = pAudioPlayer;
-            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0.0, 0);
-            pPlayer->PlaySound(102, 0);
-            //v1 = (char *)pParty->pPlayers;
-            continue;
-          }
-          if ( pUIMessageType == UIMSG_SelectFacePlayerForward )
-          {
-            pPlayer = &pParty->pPlayers[uNum];
-            v20 = (char)((int)pPlayer->uFace + 1) % 20;
-            pPlayer->uFace = v20;
-            pPlayer->uVoiceID = v20;
-            pPlayer->SetInitialStats();
-            pPlayer->SetSexByVoice();
-            pPlayer->RandomizeName();
-            v21 = uNum;
-            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
-                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
-            uPlayerCreationUI_SelectedCharacter = v21;
-            GUIWindow::Create(pCreationUI_BtnPressRight[v21]->uX, pCreationUI_BtnPressRight[v21]->uY, 0, 0, (enum WindowType)92,
-            (int)pCreationUI_BtnPressRight[v21], 1);
-            //v0 = pAudioPlayer;
-            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
-            pPlayer->PlaySound(102, 0);
-            //v1 = (char *)pParty->pPlayers;
-            continue;
-          }
           if ( pUIMessageType == UIMSG_AD )//unknow
           {
             __debugbreak();
@@ -3957,7 +4015,7 @@
             pCurrentScreen = SCREEN_GAME;
             viewparams->bRedrawGameUI = 1;
           }
-          GUIWindow::Create(602, 450, 0, 0, (enum WindowType)92, (int)pBtn_GameSettings, 0);
+          GUIWindow::Create(602, 450, 0, 0, WINDOW_VoiceSwitcherButton, (int)pBtn_GameSettings, 0);
           if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
             continue;
           pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
@@ -4045,50 +4103,6 @@
             //VideoPlayer::dtor();
           }
         }
-        else
-        {
-          if ( pUIMessageType == UIMSG_PlayerCreationSelectQuality )
-          {
-            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
-                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
-            uPlayerCreationUI_SelectedCharacter = uNum;
-            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
-            continue;
-          }
-          if ( pUIMessageType == UIMSG_PlayerCreationVoiceBack )//    
-          {
-            pCurrentPlayer = &pPlayer[uNum];
-            pSex = pCurrentPlayer->GetSexByVoice();
-            do
-            {
-              v12 = (pCurrentPlayer->uVoiceID-- - 1) == 0;
-              if ( v12 )
-                pCurrentPlayer->uVoiceID = 19;
-              v13 = pCurrentPlayer->GetSexByVoice();
-            }
-            while ( v13 != pSex );
-            pButton = pCreationUI_BtnPressLeft2[uNum];
-            GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, (enum WindowType)92, (int)pButton, 1);
-            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
-            pCurrentPlayer->PlaySound(102, 0);
-            continue;
-          }
-          if ( pUIMessageType == UIMSG_PlayerCreationVoiceForward )
-          {
-            pCurrentPlayer = &pPlayer[uNum];
-            pSex = pCurrentPlayer->GetSexByVoice();
-            do
-            {
-              pCurrentPlayer->uVoiceID = (signed int)(pCurrentPlayer->uVoiceID + 1) % 20;
-            }
-            while ( pCurrentPlayer->GetSexByVoice() != pSex );
-            pButton = pCreationUI_BtnPressRight2[uNum];
-            GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, (enum WindowType)92, (int)pButton, 1);
-            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
-            pCurrentPlayer->PlaySound(102, 0);
-            continue;
-          }
-        }
       }
       else
       {
@@ -4133,7 +4147,7 @@
           if ( pUIMessageType == UIMSG_PlayerCreationSelectClass )
           {
             pPlayer[uPlayerCreationUI_SelectedCharacter].Reset((PLAYER_CLASS_TYPE)uNum);
-            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
+            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
             continue;
           }
           if ( pUIMessageType == UIMSG_PlayerCreationClickOK )
@@ -4156,7 +4170,7 @@
             {
               uPlayerCreationUI_SelectedCharacter = uNum;
               v4 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem;
-              pSex = pGUIWindow_CurrentMenu->pStartingPosActiveItem;
+              int pSex = pGUIWindow_CurrentMenu->pStartingPosActiveItem;
               v41 = 2;
               v5 = v4 % 7 + pSex + 7 * uNum;
               pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v5;
@@ -5127,7 +5141,7 @@
 // 50FE08: using guessed type stru298 stru_50FE08;
 
 //----- (00439474) --------------------------------------------------------
-bool __fastcall DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, Vec3_int_ *pVelocity)
+void DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, Vec3_int_ *pVelocity)
 {
   signed int v3; // eax@1
   LayingItem *v4; // ebx@1
@@ -5212,8 +5226,8 @@
   }
   v5 = v3 & 7;
   uPlayerID = v3 >> 3;
-  if ( v5 != 4 )
-    return uPlayerID;
+  if (v5 != OBJECT_Player)
+    return;
   pPlayer = &pParty->pPlayers[uPlayerID];
   if ( uPlayerID < 0 && uPlayerID > 3 )
   {
@@ -5222,7 +5236,7 @@
   pMonster = &pActors[uActorID_Monster_];
   uPlayerID = pMonster->IsAlive();
   if ( uPlayerID )
-    return uPlayerID;
+    return;
   BYTE1(pMonster->uAttributes) |= 0xC0u;
   if ( pMonster->uAIState == Fleeing )
     pMonster->uAttributes |= 0x20000u;
@@ -5311,7 +5325,7 @@
     if ( uPlayerID >= 2560 )
     {
       if ( v61 >= 5120 && !(BYTE1(pMonster->uAttributes) & 4) )
-        return uPlayerID;
+        return;
       v61 = 2;
     }
     else
@@ -5363,8 +5377,8 @@
       if ( !stru_50C198.PlayerHitOrMiss(pPlayer, pMonster, v61, a4) )
       {
 LABEL_68:
-        LOWORD(uPlayerID) = pPlayer->PlaySound(52, 0);
-        return uPlayerID;
+        pPlayer->PlaySound(SPEECH_52, 0);
+        return;
       }
       goto LABEL_69;
     }
@@ -5441,7 +5455,7 @@
       {
         if ( pPlayer->HasItemEquipped((ITEM_EQUIP_TYPE)v59) )
         {
-          auto _s = (ItemGen *)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v57->uOffHand + 5];
+          auto _s = (ItemGen *)&pPlayer->pInventoryItems[v57->uOffHand-1];
           a4 = _s->_439DF3_get_additional_damage(&a2, &v62);
           if ( v62 && pMonster->sCurrentHP > 0 )
           {
@@ -5515,10 +5529,10 @@
     Actor::_43AC45(uActorID_Monster_, 1);
     if ( pMonster->pMonsterInfo.uExp )
       sub_4269A2_GivePartyExp(pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].uExp);
-    v40 = 51;
+    v40 = SPEECH_51;
     if ( rand() % 100 < 20 )
       v40 = ((signed int)pMonster->pMonsterInfo.uHP >= 100) + 1;
-    pPlayer->PlaySound(v40, 0);
+    pPlayer->PlaySound((PlayerSpeech)v40, 0);
     v41 = 0;
     if ( bShowDamage )
     {
@@ -5585,7 +5599,7 @@
     pMonster->vVelocity.y = 50 * LOWORD(pVelocity->y);
     pMonster->vVelocity.z = 50 * LOWORD(pVelocity->z);
   }
-  return Actor::AddBloodsplatOnDamageOverlay(uActorID_Monster_, 1, v61);
+  Actor::AddBloodsplatOnDamageOverlay(uActorID_Monster_, 1, v61);
 }
 // 4D864C: using guessed type char byte_4D864C;
 
@@ -5832,10 +5846,10 @@
                 Actor::_43AC45(uActorID, 1);
                 if ( v7->pMonsterInfo.uExp )
                   sub_4269A2_GivePartyExp(pMonsterStats->pInfos[v7->pMonsterInfo.uID].uExp);
-                v34 = 51;
+                v34 = SPEECH_51;
                 if ( rand() % 100 < 20 )
                   v34 = ((signed int)v7->pMonsterInfo.uHP >= 100) + 1;
-                v6->PlaySound(v34, 0);
+                v6->PlaySound((PlayerSpeech)v34, 0);
               }
             }
           }
@@ -5860,7 +5874,7 @@
         if ( v6->sHealth > 0 )
         {
           if ( (double)v6->GetMaxHealth() * 0.25 >= (double)v6->sHealth )
-            v6->PlaySound(48, 0);
+            v6->PlaySound(SPEECH_48, 0);
         }
       }
     }
@@ -5892,7 +5906,7 @@
       {
 		  sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[637], v45->pName);
         ShowStatusBarString(pTmpBuf, 2u);
-        v45->PlaySound(6, 0);
+        v45->PlaySound(SPEECH_6, 0);
         return;
       }
     }
@@ -5919,7 +5933,7 @@
     if ( v45->HasEnchantedItemEquipped(69) )
       v77 >>= 1;
     if ( v45->HasItemEquipped(EQUIP_ARMOUR)
-		&& *(_DWORD *)&v45->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v45->pEquipment.uBody + 5] == 504 )
+		&& *(_DWORD *)&v45->pInventoryItems[v45->pEquipment.uBody-1] == 504 )
       v77 >>= 1;
     v75 = 0;
 	v47 = (int)&v45->pEquipment;
@@ -6018,10 +6032,10 @@
                       Actor::_43AC45(uActorID, 1);
                       if ( v44->pMonsterInfo.uExp )
                         sub_4269A2_GivePartyExp(pMonsterStats->pInfos[v44->pMonsterInfo.uID].uExp);
-                      v64 = 51;
+                      v64 = SPEECH_51;
                       if ( rand() % 100 < 20 )
                         v64 = ((signed int)v44->pMonsterInfo.uHP >= 100) + 1;
-                      v45->PlaySound(v64, 0);
+                      v45->PlaySound((PlayerSpeech)v64, 0);
                     }
                   }
                 }
@@ -7275,7 +7289,7 @@
     if ( !v21 )
       goto LABEL_59;
     v230 = pPlayer->pEquipment.uBow;
-    v22 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v21 + 5];
+    v22 = (int)&v217->pInventoryItems[v21-1];
     v23 = *(int *)v22;
     v24 = pPaperdoll_BodyX + array_4E4C30[pBodyComplection].equip_x - pItemsTable->pItems[v23].uEquipX;
     a3b = pPaperdoll_BodyY + array_4E4C30[pBodyComplection].equip_y - pItemsTable->pItems[v23].uEquipY;
@@ -7311,7 +7325,7 @@
       if ( !v31 )
         goto LABEL_93;
       v231 = v217->pEquipment.uCloak;
-      v32 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v31 + 5];
+      v32 = (int)&v217->pInventoryItems[v31-1];
       v219 = v32;
       if ( *(int *)v32 != 525 )
       {
@@ -7363,7 +7377,7 @@
                 if ( !v43 )
                   goto LABEL_127;
                 v232 = v217->pEquipment.uBody;
-                v44 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v43 + 5];
+                v44 = (int)&v217->pInventoryItems[v43-1];
                 v220 = v44;
                 if ( *(int *)v44 != 504 )
                 {
@@ -7422,7 +7436,7 @@
                           if ( !v56 )
                             goto LABEL_155;
                           v233 = v217->pEquipment.field_20;
-                          v57 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v56 + 5];
+                          v57 = (int)&v217->pInventoryItems[v56-1];
                           v221 = v57;
                           v58 = *(int *)v57;
                           if ( *(int *)v57 == 529 )
@@ -7486,7 +7500,7 @@
                             v68 = v217;
                             v69 = v217->pEquipment.uMainHand;
                             uPlayerID_a = 2 * pBodyComplection;
-                            if ( !v69 || (v70 = *(int *)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v69 + 5],
+                            if ( !v69 || (v70 = *(int *)&v217->pInventoryItems[v69-1],
                                   pItemsTable->pItems[v70].uEquipType != 1)
                               && (pItemsTable->pItems[v70].uSkillType != 4 || v217->pEquipment.uOffHand) )
                               pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[2 * pBodyComplection],
@@ -7496,7 +7510,7 @@
                             if ( v71 )
                             {
                               v234 = v217->pEquipment.uBelt;
-                              v72 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v71 + 5];
+                              v72 = (int)&v217->pInventoryItems[v71-1];
                               v222 = v72;
                               if ( *(int *)v72 == 524 )
                               {
@@ -7588,7 +7602,7 @@
                             v82 = v68->pEquipment.uMainHand;
                             if ( v82 )
                             {
-                              v83 = *(int *)&v68->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v82 + 5];
+                              v83 = *(int *)&v68->pInventoryItems[v82-1];
                               if ( pItemsTable->pItems[v83].uEquipType == 1
                                 || pItemsTable->pItems[v83].uSkillType == 4 && !v68->pEquipment.uOffHand )
                                 pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[uPlayerID_a],
@@ -7620,7 +7634,7 @@
                                       if ( !v111 )
                                         goto LABEL_293;
                                       v236 = v68->pEquipment.uCloak;
-                                      v112 = (int)&v68->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v111 + 5];
+                                      v112 = (int)&v68->pInventoryItems[v111-1];
                                       v225 = v112;
                                       v113 = *(int *)v112;
                                       if ( v113 != 525 )
@@ -7668,7 +7682,7 @@
                                                 if ( !v123 )
                                                   goto LABEL_335;
                                                 v237 = v123;
-                                                v124 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v123 + 5];
+                                                v124 = (int)&v217->pInventoryItems[v123-1];
                                                 v226 = v124;
                                                 if ( *(int *)v124 != 521 )
                                                 {
@@ -7773,7 +7787,7 @@
                                                   if ( !v134 )
                                                     goto LABEL_358;
                                                   v238 = v217->pEquipment.uMainHand;
-                                                  v135 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v134 + 5];
+                                                  v135 = (int)&v217->pInventoryItems[v134-1];
                                                   v227 = v135;
                                                   v136 = *(int *)v135;
                                                   v137 = *(int *)v135;
@@ -7818,7 +7832,7 @@
                                                     v249 = v217->pEquipment.uOffHand;
                                                     if ( !v145 )
                                                       goto LABEL_393;
-                                                    v146 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v145 + 5];
+                                                    v146 = (int)&v217->pInventoryItems[v145-1];
                                                     v228 = v146;
                                                     v147 = *(int *)v146;
                                                     v148 = *(int *)v146;
@@ -8445,7 +8459,7 @@
   uPlayerID_a = 2 * v5;
   v6 = pPlayer->pEquipment.uMainHand;
   if ( !v6
-    || (v7 = *(int *)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6 + 5], pItemsTable->pItems[v7].uEquipType != 1)
+    || (v7 = *(int *)&pPlayer->pInventoryItems[v6-1], pItemsTable->pItems[v7].uEquipType != 1)
     && (pItemsTable->pItems[v7].uSkillType != 4 || pPlayer->pEquipment.uOffHand) )
     pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[2 * v5], pPaperdoll_BodyY + pPaperdoll_LeftHand[2 * v5 + 1],
       (Texture *)(*(unsigned int *)((char *)papredoll_dlads + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dlads + v240)] : 0));
@@ -8457,7 +8471,7 @@
   if ( v8 )
   {
     v229 = pPlayer->pEquipment.uMainHand;
-    v9 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5];
+    v9 = (int)&v217->pInventoryItems[v8-1];
     v10 = v5 << 7;
     v218 = v9;
     v11 = *(int *)v9;
@@ -8547,7 +8561,7 @@
   v161 = v217->pEquipment.uMainHand;
   if ( v161 )
   {
-    v162 = *(int *)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v161 + 5];
+    v162 = *(int *)&v217->pInventoryItems[v161-1];
     if ( pItemsTable->pItems[v162].uEquipType == 1
       || pItemsTable->pItems[v162].uSkillType == 4 && !v217->pEquipment.uOffHand )
       pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[uPlayerID_a],
@@ -8572,7 +8586,7 @@
   unsigned int v1; // ebx@1
   Player *pPlayer; // edi@1
   int v3; // ecx@1
-  int v4; // edi@3
+  int *v4; // edi@3
   unsigned int v5; // ebx@3
   int v6; // eax@3
   LODFile_IconsBitmaps *v7; // ecx@7
@@ -8614,7 +8628,7 @@
   int v43; // [sp+10h] [bp-20h]@47
   unsigned int a3; // [sp+14h] [bp-1Ch]@3
   unsigned int a2; // [sp+18h] [bp-18h]@3
-  int v46; // [sp+1Ch] [bp-14h]@1
+  unsigned int *v46; // [sp+1Ch] [bp-14h]@1
   Player *v47; // [sp+20h] [bp-10h]@1
   int v48; // [sp+24h] [bp-Ch]@1
   int v49; // [sp+24h] [bp-Ch]@26
@@ -8629,17 +8643,17 @@
   pRenderer->DrawTextureIndexed(pCharacterScreen_DetalizBtn->uX, pCharacterScreen_DetalizBtn->uY,
     (Texture *)(uTextureID_5118C8 != -1 ? &pIcons_LOD->pTextures[uTextureID_5118C8] : 0));
   v3 = 0;
-  v46 = (int)&pPlayer->pEquipment.field_28;
+  v46 = &pPlayer->pEquipment.field_28;
   v48 = 0;
   do
   {
-    if ( !*(int *)v46 )
+    if ( !*v46 )
       goto LABEL_24;
-    v39 = *(int *)v46;
-    v4 = (int)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v46 + 5];
+    v39 = *v46;
+	v4 = (int *)&pPlayer->pInventoryItems[*v46-1].uItemID;
     a3 = pPaperdollRingsY[v3];
     a2 = pPaperdollRingsX[v3];
-    v5 = pIcons_LOD->LoadTexture(pItemsTable->pItems[*(int *)v4].pIconName, TEXTURE_16BIT_PALETTE);
+    v5 = pIcons_LOD->LoadTexture(pItemsTable->pItems[*v4].pIconName, TEXTURE_16BIT_PALETTE);
     v6 = *(int *)(v4 + 20);
     if ( *(int *)(v4 + 20) & 0xF0 )
     {
@@ -8720,7 +8734,7 @@
   if ( !v15 )
     goto LABEL_46;
   v41 = pPlayer->pEquipment.field_24;
-  v49 = (int)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v15 + 5];
+  v49 = (int)&pPlayer->pInventoryItems[v15-1];
   v16 = pIcons_LOD->LoadTexture(pItemsTable->pItems[*(int *)v49].pIconName, TEXTURE_16BIT_PALETTE);
   v17 = *(int *)(v49 + 20);
   if ( !(*(int *)(v49 + 20) & 0xF0) )
@@ -8802,7 +8816,7 @@
   if ( !v26 )
     return;
   v43 = pPlayer->pEquipment.field_1C;
-  v27 = (int)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v26 + 5];
+  v27 = (int)&pPlayer->pInventoryItems[v26-1];
   v28 = pIcons_LOD->LoadTexture(pItemsTable->pItems[*(int *)v27].pIconName, TEXTURE_16BIT_PALETTE);
   v29 = *(int *)(v27 + 20);
   if ( !(*(int *)(v27 + 20) & 0xF0) )
@@ -8974,7 +8988,7 @@
       if ( *v5 )
       {
         result = 9 * *v5;
-        if ( *(int *)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *v5 + 5] == uItemID )
+        if ( *(int *)&pPlayer->pInventoryItems[*v5-1] == uItemID )
           break;
       }
       ++v4;
@@ -12730,7 +12744,7 @@
 
   v1 = pPlayers[uActiveCharacter];
   v10 = _this;
-  v2 = &pSpellStats->pInfos[(signed int)((char *)_this + 11 * v1->pNumSpellBookPage) + 1];
+  v2 = &pSpellStats->pInfos[(signed int)((char *)_this + 11 * v1->lastOpenedSpellbookPage) + 1];
   if ( pMouse->GetCursorPos(&a2)->y <= 250 )
     v3 = pMouse->GetCursorPos(&a2)->y + 30;
   else
@@ -12789,14 +12803,14 @@
   a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2, 0, 0, 0);
   a1.uFrameWidth = 108;
   a1.uFrameZ = a1.uFrameX + 107;
-  a1.DrawTitleText(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[v1->pNumSpellBookPage + 12], 3u);
+  a1.DrawTitleText(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[v1->lastOpenedSpellbookPage + 12], 3u);
   sprintf(
     pTmpBuf,
     "%s\n%d",
     pGlobalTXT_LocalizationStrings[522],
-    *(&pSpellDatas[0].field_14
-    + ((unsigned int)LOBYTE(v1->pActiveSkills[v1->pNumSpellBookPage + 12]) >> 6)
-    + 10 * (int)((char *)v10 + 11 * v1->pNumSpellBookPage)));
+    *(&pSpellDatas[0].field_12 //temp_fix field_14
+    + ((unsigned int)LOBYTE(v1->pActiveSkills[v1->lastOpenedSpellbookPage + 12]) >> 6)
+    + 10 * (int)((char *)v10 + 11 * v1->lastOpenedSpellbookPage)));
   a1.DrawTitleText(pFontComic, 0xCu, a1.uFrameHeight - LOBYTE(pFontComic->uFontHeight) - 16, 0, pTmpBuf, 3u);
   dword_507B00_spell_info_to_draw_in_popup = 0;
 }
@@ -13122,56 +13136,44 @@
 // 4E1D3A: using guessed type __int16 word_4E1D3A[];
 
 //----- (00411300) --------------------------------------------------------
-Texture *__fastcall LoadSpellbook(unsigned int uID)
-{
-  unsigned int v1; // esi@1
+void LoadSpellbook(unsigned int school)
+{
+  //unsigned int v1; // esi@1
   Player *pPlayer; // ecx@1
   char v3; // al@1
-  int v4; // edi@5
-  Texture *result; // eax@6
-  char *v6; // edi@7
-  unsigned int v7; // eax@7
-  unsigned __int8 v8; // sf@8
-  unsigned __int8 v9; // of@8
+  //int v4; // edi@5
+  //Texture *result; // eax@6
+  //unsigned char *v6; // edi@7
+  //unsigned int v7; // eax@7
+  //unsigned __int8 v8; // sf@8
+  //unsigned __int8 v9; // of@8
   char pContainer[20]; // [sp+Ch] [bp-1Ch]@7
-  Texture *v11; // [sp+20h] [bp-8h]@5
-  int v12; // [sp+24h] [bp-4h]@5
+  //Texture *v11; // [sp+20h] [bp-8h]@5
+  //int v12; // [sp+24h] [bp-4h]@5
 
   byte_506550 = 0;
-  v1 = uID;
+  //v1 = uID;
   pPlayer = pPlayers[uActiveCharacter];
   v3 = pPlayer->uQuickSpell;
-  if ( v3 && (unsigned __int8)v3 / 11 == v1 )
-    dword_50654C = (unsigned __int8)v3 - 11 * v1;
+  if ( v3 && (unsigned __int8)v3 / 11 == school )
+    dword_50654C = (unsigned __int8)v3 - 11 * school;
   else
     dword_50654C = 0;
-  v4 = 1;
-  v12 = 1;
-  v11 = (Texture *)&pPlayer->field_152[11 * v1 + 63];
-  do
-  {
-    result = v11;
-    if ( v11->pName[v4] )
-    {
-      v6 = &byte_4E2430[12 * v1] + v4;
-      sprintf(pContainer, "SB%sS%02d", spellbook_texture_filename_suffices[v1], (unsigned __int8)*v6);
-      v7 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      dword_506408[v12] = &pIcons_LOD->pTextures[v7];
-      sprintf(pContainer, "SB%sC%02d", spellbook_texture_filename_suffices[v1], (unsigned __int8)*v6);
-      result = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)];
-      dword_5063D8[v12] = result;
-    }
-    v4 = v12 + 1;
-    v9 = v12++ > 12;//v9 = __OFSUB__(v12 + 1, 12);
-    v8 = v12++ - 11 < 0;
-  }
-  while ( v8 ^ v9 );
-  return result;
-}
-// 4E1D18: using guessed type char *spellbook_texture_filename_suffices[8];
-// 506408: using guessed type int dword_506408[];
-// 50654C: using guessed type int dword_50654C;
-// 506550: using guessed type char byte_506550;
+
+  char *v11 = &pPlayer->field_152[11 * school + 63];
+
+  for (uint i = 1; i < 12; ++i)
+  {
+    if (v11[i])
+    {
+      sprintf(pContainer, "SB%sS%02d", spellbook_texture_filename_suffices[school], pSpellbookSpellIndices[school][i]);
+      dword_506408[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
+
+      sprintf(pContainer, "SB%sC%02d", spellbook_texture_filename_suffices[school], pSpellbookSpellIndices[school][i]);
+      dword_5063D8[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
+    }
+  }
+}
 
 //----- (0041140B) --------------------------------------------------------
 GUIWindow *__cdecl sub_41140B()
@@ -13271,7 +13273,7 @@
 
   v0 = 0;
   if ( uActiveCharacter )
-	  v0 = pParty->pPlayers[uActiveCharacter-1].pNumSpellBookPage;//*((char *)&pParty->pPartyBuffs[5].uExpireTime + 6972 * uActiveCharacter + 2);
+	  v0 = pParty->pPlayers[uActiveCharacter-1].lastOpenedSpellbookPage;//*((char *)&pParty->pPartyBuffs[5].uExpireTime + 6972 * uActiveCharacter + 2);
   pRenderer->DrawTextureIndexed(8u, 8u, pTextures_5064A0[v0]);
   pRenderer->DrawTextureIndexed(0x1DCu, 0x1C2u, pTexture_50643C);
   pRenderer->DrawTextureIndexed(0x231u, 0x1C2u, pTexture_506448);
@@ -13310,7 +13312,7 @@
 
   sub_412AF9();
   v0 = pPlayers[uActiveCharacter];
-  v1 = 11 * v0->pNumSpellBookPage;
+  v1 = 11 * v0->lastOpenedSpellbookPage;
   v2 = pIcons_LOD->FindTextureByName("Pending");
   v3 = (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0);
   pRenderer->ClearZBuffer(0, 479);
@@ -13336,14 +13338,14 @@
           }
           if ( v6->pLevelOfDetail0 )
           {
-            v7 = 2 * (12 * v0->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2430[12 * v0->pNumSpellBookPage + v4]));
+            v7 = 2 * (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v4]);
             v19 = pViewport->uViewportY + dword_4E20D0[v7 + 1];
             v17 = pViewport->uViewportX + dword_4E20D0[v7];
             if ( BYTE1(v6->pBits) & 2 )
               pRenderer->DrawTextureTransparent(v17, v19, v6);
             else
               pRenderer->DrawTextureIndexed(v17, v19, v6);
-            v8 = 2 * (12 * v0->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2430[12 * v0->pNumSpellBookPage] + v4));
+            v8 = 2 * (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v4]);
             pRenderer->_4A612A(dword_4E20D0[v8], dword_4E20D0[v8 + 1], v23, v4);
           }
         }
@@ -13360,7 +13362,7 @@
     if ( v11->pLevelOfDetail0 )
     {
       v21 = dword_5063D8[v10];
-      v12 = 2 * (12 * v0->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2430[12 * v0->pNumSpellBookPage] + v10));
+      v12 = 2 * (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v10]);
       v20 = pViewport->uViewportY + dword_4E20D0[v12 + 1];
       v18 = pViewport->uViewportX + dword_4E20D0[v12];
       if ( BYTE1(v11->pBits) & 2 )
@@ -13378,7 +13380,7 @@
   {
     if ( *(short *)a2.x )
     {
-      if ( v0->pNumSpellBookPage == v13 )
+      if ( v0->lastOpenedSpellbookPage == v13 )
       {
         pPageTexture = pTextures_tabs[v13][1];
         switch ( v13 )
@@ -13531,7 +13533,7 @@
     a1.uFrameX = 8;
     a1.uFrameY = 8;
     a1.uFrameHeight = 344;
-    v3 = (const char *)pStorylineText->field_4[3 * v2];
+    v3 = (const char *)pStorylineText->StoreLine[v2].pText;//field_4[];
     a1.uFrameZ = 467;
     a1.uFrameW = 351;
     if ( v3 )
@@ -13567,9 +13569,9 @@
   v6 = pStru179.field_0[dword_506528];
   dword_506548 = 0;
   dword_506520 = 0;
-  v7 = *(&pStorylineText->field_0 + 3 * v6);
+  v7 = *pStorylineText->StoreLine[v6].pText;//*(&pStorylineText->field_0 + 3 * v6);
   v8 = sub_495461(
-         *((char **)&pStorylineText->field_0 + 3 * v6),
+         pStorylineText->StoreLine[v6].pText,
          uActiveCharacter - 1,
          0,
          0,
@@ -15294,7 +15296,7 @@
           continue;
         }
         v18 = v17 - 1;
-        if ( pWindowType == WINDOW_5C ) // Change page in AutonotesBook
+        if ( pWindowType == WINDOW_VoiceSwitcherButton ) // Change page in AutonotesBook
         {
           if ( pWindow->Hint != (char *)1 )
             pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
@@ -15883,14 +15885,14 @@
               v0->pInventoryItems[pOut.z]._bonus_type = (pParty->pPickedItem._bonus_type
                                                        + v0->pInventoryItems[pOut.z]._bonus_type)
                                                       / 2;
-              v0->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->field_10168[2 * v20 + 388]);
+              v0->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->potion_note[2 * v20 ]);//field_10168  + 388
 LABEL_74:
               v22 = (int)((char *)v0 + 36 * pOut.z);
-              if ( !BYTE2(pItemsTable->pItems[*(int *)(v22 + 532) + 1].uItemID) )
+              if ( !(pItemsTable->pItems[*(int *)(v22 + 532) ].uItemID_Rep_St) )
                 *(int *)(v22 + 552) |= 1u;
               if ( !dword_4E455C )
                 goto LABEL_92;
-              v0->PlaySound(16, 0);
+              v0->PlaySound(SPEECH_16, 0);
               goto LABEL_91;
             }
             if ( v45 )
@@ -15931,7 +15933,7 @@
     if ( dword_4E455C )
     {
       if ( v0->CanAct() )
-        v0->PlaySound(17, 0);
+        v0->PlaySound(SPEECH_17, 0);
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[444], 2u);
 LABEL_91:
       dword_4E455C = 0;
@@ -15979,7 +15981,7 @@
   dword_50CDCC = 1;
   if ( dword_4E455C )
   {
-    v0->PlaySound(16, 0);
+    v0->PlaySound(SPEECH_16, 0);
     dword_4E455C = 0;
   }
 }
@@ -16171,6 +16173,7 @@
       return;
     }
   }
+
   if ( pParty->pPickedItem.uItemID )//        
   {
     //v1 = 0;
@@ -16187,6 +16190,7 @@
     }
     //while ( v1 < 4 );
   }
+
   pEventTimer->Pause();
   if ( pCurrentScreen <= SCREEN_CHEST )
   {
@@ -17396,7 +17400,7 @@
   int v137; // [sp+1Ch] [bp-4h]@27
   int v138; // [sp+1Ch] [bp-4h]@33
 
-  pPlayer = &pParty->pPlayers[uPlayerID-1];//(Player *)&stru_AA1058[3].pSounds[6972 * uPlayerID + 40552];
+  pPlayer = &pParty->pPlayers[uPlayerID-1];
   v2 = pIcons_LOD->LoadTexture("fr_stats", TEXTURE_16BIT_PALETTE);
   pRenderer->DrawTextureIndexed(8, 8, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0));
   v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
@@ -17853,7 +17857,7 @@
   }
   v12 = 0;
   a5 = pGUIWindow_CurrentMenu->uNumControls;
-  v18 = &pParty->pPlayers[v0-1];	  //&stru_AA1058[3].pSounds[6972 * v0 + 40552];
+  v18 = &pParty->pPlayers[v0-1];
   v2 = pFontLucida;
   v14 = pWeaponSkills;
   v3 = 2 * LOBYTE(pFontLucida->uFontHeight) + 13;
--- a/mm7_6.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/mm7_6.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -39,6 +39,7 @@
 #include "Weather.h"
 #include "stru272.h"
 #include "stru298.h"
+#include "texts.h"
 #include "StorylineTextTable.h"
 #include "Events2D.h"
 
@@ -1415,9 +1416,9 @@
     Dst.uItemID = pActor->uCarriedItemID;
     v9 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName;
     if ( v14 )
-      sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[490], v14, v9);
+      sprintf(pTmpBuf2, (char*)pGlobalTXT_LocalizationStrings[490], v14, v9);
     else
-      sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], v9);
+      sprintf(pTmpBuf2, (char*)pGlobalTXT_LocalizationStrings[471], v9);
     ShowStatusBarString(pTmpBuf2, 2u);
     v4 = Dst.uItemID;
     v5 = Dst.uItemID;
@@ -4071,7 +4072,7 @@
                       }
                       if ( v727 != 0.0 )
                       {
-                        pPlayer->PlaySound(49, 0);
+                        pPlayer->PlaySound(SPEECH_49, 0);
                         goto LABEL_1162;
                       }
                     }
@@ -5264,12 +5265,12 @@
                             v313 = *(char *)(LODWORD(v725) + 28);
                             if ( v313 == 3 | v313 == 4 | v313 == 5 | v313 == 6 | v313 == 7 | v313 == 8 | v313 == 9 | v313 == 10 | v313 == 11 )
                             {
-                              v314 = rand() % pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType];
+                              v314 = rand() % 10;//pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType];
                               *(int *)(v245 + 4) = 0;
-                              for ( j = pItemsTable->pEnchantments[0].field_8[pItemsTable->pItems[*(int *)v245].uEquipType
+                              for ( j = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[*(int *)v245].uEquipType
                                                                            + 1];
                                     ;
-                                    j += pItemsTable->pEnchantments[*(int *)(v245 + 4)].field_8[pItemsTable->pItems[*(int *)v245].uEquipType
+                                    j += pItemsTable->pEnchantments[*(int *)(v245 + 4)].to_item[pItemsTable->pItems[*(int *)v245].uEquipType
                                                                                                 + 1] )
                               {
                                 ++*(int *)(v245 + 4);
@@ -5277,8 +5278,8 @@
                                   break;
                               }
                               v254 = rand();
-                              v255 = pItemsTable->field_116D8[17];
-                              v256 = pItemsTable->field_116D8[16];
+                              v255 = 10;//pItemsTable->field_116D8[17];
+                              v256 = 10;//pItemsTable->field_116D8[16];
 LABEL_611:
                               *(int *)(v245 + 8) = v256 + v254 % (v255 - v256 + 1);
 LABEL_612:
@@ -5312,7 +5313,7 @@
             pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, v1, v1, -1, v1, v1, v1, v1);
             v318 = v726;
             v3->spellnum = v1;
-            v318->PlaySound(43, v1);
+            v318->PlaySound(SPEECH_43, v1);
           }
           goto LABEL_83;
         }
@@ -5351,11 +5352,11 @@
               if ( rand() % 100 < 80
                 && !(*(char *)(LODWORD(v273) + 28) == 0 | *(char *)(LODWORD(v273) + 28) == 1 | *(char *)(LODWORD(v273) + 28) == 2) )
               {
-                v275 = rand() % pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType];
+                v275 = rand() % 10;//pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType];
                 *(int *)(v245 + 4) = 0;
-                for ( k = pItemsTable->pEnchantments[0].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + 1];
+                for ( k = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[*(int *)v245].uEquipType + 1];
                       ;
-                      k += pItemsTable->pEnchantments[*(int *)(v245 + 4)].field_8[pItemsTable->pItems[*(int *)v245].uEquipType
+                      k += pItemsTable->pEnchantments[*(int *)(v245 + 4)].to_item[pItemsTable->pItems[*(int *)v245].uEquipType
                                                                                   + 1] )
                 {
                   ++*(int *)(v245 + 4);
@@ -5363,23 +5364,23 @@
                     break;
                 }
                 v254 = rand();
-                v255 = pItemsTable->field_116D8[19];
-                v256 = pItemsTable->field_116D8[18];
+                v255 = 10;//pItemsTable->field_116D8[19];
+                v256 = 10;//pItemsTable->field_116D8[18];
                 goto LABEL_611;
               }
-              v277 = pItemsTable->field_11798;
+              v277 = pItemsTable->pSpecialEnchantments_count;
               v278 = 0;
               v725 = 0.0;
               HIDWORD(v733) = 0;
-              if ( pItemsTable->field_11798 > 0 )
+              if ( pItemsTable->pSpecialEnchantments_count > 0 )
               {
                 v730 = (int)&v679;
                 do
                 {
-                  v279 = LOBYTE(pItemsTable->pSpecialEnchantments[v278 + 1].pName);
+                  v279 = LOBYTE(pItemsTable->pSpecialEnchantments[v278 + 1].pBonusStatement);
                   if ( !v279 || v279 == 1 )
                   {
-                    v280 = *(&pItemsTable->pSpecialEnchantments[0].field_8[pItemsTable->pItems[*(int *)v245].uEquipType
+                    v280 = *(&pItemsTable->pSpecialEnchantments[0].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType
                                                                         + 4]
                            + v278 * 28);
                     LODWORD(v725) += v280;
@@ -5398,7 +5399,7 @@
               v282 = rand() % SLODWORD(v725);
               v283 = v679;
               *(int *)(v245 + 12) = v679;
-              v284 = pItemsTable->pSpecialEnchantments[v283].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + 4];
+              v284 = pItemsTable->pSpecialEnchantments[v283].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType + 4];
               v285 = v282 + 1;
               if ( v284 < v285 )
               {
@@ -5408,7 +5409,7 @@
                   v732 = v287;
                   v288 = *(int *)v287;
                   *(int *)(v245 + 12) = v288;
-                  v284 += pItemsTable->pSpecialEnchantments[v288].field_8[pItemsTable->pItems[*(int *)v245].uEquipType
+                  v284 += pItemsTable->pSpecialEnchantments[v288].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType
                                                                        + 4];
                   if ( v284 >= v285 )
                     break;
@@ -5449,11 +5450,11 @@
               if ( rand() % 100 < 80
                 && !(*(char *)(LODWORD(v250) + 28) == 0 | *(char *)(LODWORD(v250) + 28) == 1 | *(char *)(LODWORD(v250) + 28) == 2) )
               {
-                v252 = rand() % pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType];
+                v252 = rand() % 10;//pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType];
                 *(int *)(v245 + 4) = 0;
-                for ( m = pItemsTable->pEnchantments[0].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + 1];
+                for ( m = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[*(int *)v245].uEquipType + 1];
                       ;
-                      m += pItemsTable->pEnchantments[*(int *)(v245 + 4)].field_8[pItemsTable->pItems[*(int *)v245].uEquipType
+                      m += pItemsTable->pEnchantments[*(int *)(v245 + 4)].to_item[pItemsTable->pItems[*(int *)v245].uEquipType
                                                                                   + 1] )
                 {
                   ++*(int *)(v245 + 4);
@@ -5461,23 +5462,23 @@
                     break;
                 }
                 v254 = rand();
-                v255 = pItemsTable->field_116D8[21];
-                v256 = pItemsTable->field_116D8[20];
+                v255 = 10;// pItemsTable->field_116D8[21];
+                v256 =  10;//pItemsTable->field_116D8[20];
                 goto LABEL_611;
               }
-              v257 = pItemsTable->field_11798;
+              v257 = pItemsTable->pSpecialEnchantments_count;
               v258 = 0;
               v725 = 0.0;
               HIDWORD(v733) = 0;
-              if ( pItemsTable->field_11798 > 0 )
+              if ( pItemsTable->pSpecialEnchantments_count > 0 )
               {
                 v730 = (int)&v679;
                 do
                 {
-                  v259 = LOBYTE(pItemsTable->pSpecialEnchantments[v258 + 1].pName);
+                  v259 = LOBYTE(pItemsTable->pSpecialEnchantments[v258 + 1].pBonusStatement);
                   if ( !v259 || v259 == 1 )
                   {
-                    v260 = *(&pItemsTable->pSpecialEnchantments[0].field_8[pItemsTable->pItems[*(int *)v245].uEquipType
+                    v260 = *(&pItemsTable->pSpecialEnchantments[0].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType
                                                                         + 4]
                            + v258 * 28);
                     LODWORD(v725) += v260;
@@ -5496,7 +5497,7 @@
               v262 = rand() % SLODWORD(v725);
               v263 = v679;
               *(int *)(v245 + 12) = v679;
-              v264 = pItemsTable->pSpecialEnchantments[v263].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + 4];
+              v264 = pItemsTable->pSpecialEnchantments[v263].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType + 4];
               v265 = v262 + 1;
               if ( v264 < v265 )
               {
@@ -5506,7 +5507,7 @@
                   v732 = v267;
                   v268 = *(int *)v267;
                   *(int *)(v245 + 12) = v268;
-                  v264 += pItemsTable->pSpecialEnchantments[v268].field_8[pItemsTable->pItems[*(int *)v245].uEquipType
+                  v264 += pItemsTable->pSpecialEnchantments[v268].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType
                                                                        + 4];
                   if ( v264 >= v265 )
                     break;
@@ -5549,20 +5550,20 @@
         }
         if ( rand() % 100 >= 80 )
         {
-          v297 = pItemsTable->field_11798;
+          v297 = pItemsTable->pSpecialEnchantments_count;
           v294 = _this;
           v298 = 0;
           v725 = 0.0;
           HIDWORD(v733) = 0;
-          if ( pItemsTable->field_11798 > 0 )
+          if ( pItemsTable->pSpecialEnchantments_count > 0 )
           {
             v730 = (int)&v679;
             do
             {
-              v299 = LOBYTE(pItemsTable->pSpecialEnchantments[v298 + 1].pName);
+              v299 = LOBYTE(pItemsTable->pSpecialEnchantments[v298 + 1].pBonusStatement);
               if ( !v299 || v299 == 1 )
               {
-                v300 = *(&pItemsTable->pSpecialEnchantments[0].field_8[pItemsTable->pItems[v294->uItemID].uEquipType + 4]
+                v300 = *(&pItemsTable->pSpecialEnchantments[0].to_item_apply[pItemsTable->pItems[v294->uItemID].uEquipType + 4]
                        + v298 * 28);
                 LODWORD(v725) += v300;
                 if ( v300 )
@@ -5580,7 +5581,7 @@
           v302 = rand() % SLODWORD(v725);
           v303 = v679;
           v294->uAdditionalValue = v679;
-          v304 = pItemsTable->pSpecialEnchantments[v303].field_8[pItemsTable->pItems[v294->uItemID].uEquipType + 4];
+          v304 = pItemsTable->pSpecialEnchantments[v303].to_item_apply[pItemsTable->pItems[v294->uItemID].uEquipType + 4];
           v305 = v302 + 1;
           if ( v304 < v305 )
           {
@@ -5590,7 +5591,7 @@
               v732 = v307;
               v308 = *(int *)v307;
               v294->uAdditionalValue = v308;
-              v304 += pItemsTable->pSpecialEnchantments[v308].field_8[pItemsTable->pItems[v294->uItemID].uEquipType + 4];
+              v304 += pItemsTable->pSpecialEnchantments[v308].to_item_apply[pItemsTable->pItems[v294->uItemID].uEquipType + 4];
               if ( v304 >= v305 )
                 break;
             }
@@ -5601,19 +5602,19 @@
         {
           v293 = rand();
           v294 = _this;
-          v295 = v293 % pItemsTable->field_116D8[pItemsTable->pItems[_this->uItemID].uEquipType];
+          v295 = v293 % 10;// pItemsTable->field_116D8[pItemsTable->pItems[_this->uItemID].uEquipType];
           _this->_bonus_type = 0;
-          for ( kk = pItemsTable->pEnchantments[0].field_8[pItemsTable->pItems[v294->uItemID].uEquipType + 1];
+          for ( kk = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[v294->uItemID].uEquipType + 1];
                 ;
-                kk += pItemsTable->pEnchantments[v294->_bonus_type].field_8[pItemsTable->pItems[v294->uItemID].uEquipType
+                kk += pItemsTable->pEnchantments[v294->_bonus_type].to_item[pItemsTable->pItems[v294->uItemID].uEquipType
                                                                          + 1] )
           {
             ++v294->_bonus_type;
             if ( kk >= v295 )
               break;
           }
-          v294->_bonus_strength = pItemsTable->field_116D8[18]
-                                + rand() % (pItemsTable->field_116D8[19] - pItemsTable->field_116D8[18] + 1);
+          v294->_bonus_strength = 10//pItemsTable->field_116D8[18]
+                                + rand() % 10;//(pItemsTable->field_116D8[19] - pItemsTable->field_116D8[18] + 1);
         }
         v294->uAttributes |= 0x20u;
         goto LABEL_1055;
@@ -6089,7 +6090,7 @@
           || HIDWORD(pParty->pPlayers[v396].pConditions[14]) | LODWORD(pParty->pPlayers[v396].pConditions[14]) )
         {
           if ( !(HIDWORD(pParty->pPlayers[v396].pConditions[1]) | LODWORD(pParty->pPlayers[v396].pConditions[1])) )
-            pParty->pPlayers[v396].PlaySound(25, v1);
+            pParty->pPlayers[v396].PlaySound(SPEECH_25, v1);
           if ( v731 == 4 )
           {
             v397 = v3->uPlayerID_2;
@@ -6424,7 +6425,7 @@
         if ( HIDWORD(pParty->pPlayers[v440].pConditions[5]) | LODWORD(pParty->pPlayers[v440].pConditions[5]) )
         {
           if ( !(HIDWORD(pParty->pPlayers[v440].pConditions[1]) | LODWORD(pParty->pPlayers[v440].pConditions[1])) )
-            pParty->pPlayers[v440].PlaySound(25, v1);
+            pParty->pPlayers[v440].PlaySound(SPEECH_25, v1);
           if ( v731 == 4 )
           {
             v441 = v3->uPlayerID_2;
@@ -6475,7 +6476,7 @@
           }
           else
           {
-            sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v450].pUnidentifiedName);
+            sprintf(pTmpBuf2, (char*)pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v450].pUnidentifiedName);
             ShowStatusBarString(pTmpBuf2, 2u);
             if ( !pParty->AddItem(&pLayingItems[v445].stru_24) )
               pParty->SetHoldingItem(&pLayingItems[v445].stru_24);
@@ -7740,7 +7741,7 @@
         v222 = (char *)HIDWORD(v733);
         if ( v223 )
 LABEL_439:
-          ((Player *)v222)->PlaySound(103, v1);
+          ((Player *)v222)->PlaySound(SPEECH_103, v1);
       }
       v222 += 6972;
       HIDWORD(v733) = (int)v222;
@@ -7872,8 +7873,8 @@
 
   v0 = uActiveCharacter;
   v27 = 6972 * uActiveCharacter;
-  v1 = &pParty->pPlayers[uActiveCharacter-1];//(Player *)&stru_AA1058[3].pSounds[6972 * uActiveCharacter + 40552];
-  result = pParty->pPlayers[uActiveCharacter-1].CanAct();//((Player *)&stru_AA1058[3].pSounds[6972 * uActiveCharacter + 40552])->CanAct();
+  v1 = &pParty->pPlayers[uActiveCharacter-1];
+  result = pParty->pPlayers[uActiveCharacter-1].CanAct();
   if ( result )
   {
     pStru277->_427D48(v0);
@@ -8015,7 +8016,7 @@
         v12 = v1->pEquipment.uMainHand;
         v29 = 1;
         _42777D_CastSpell_UseWand_ShootArrow(
-          *((int *)&pSpellDatas[66].field_8 + *(int *)&v1->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v12 + 5]),
+          *((int *)&pSpellDatas[66].field_8 + *(int *)&v1->pInventoryItems[v12-1]),
           v0 - 1,
           8u,
           0,
@@ -8038,7 +8039,7 @@
           {
             v15 = v1->pEquipment.uMainHand;
             if ( v1->HasItemEquipped(EQUIP_TWO_HANDED) )
-              v34 = pItemsTable->pItems[*(int *)&v1->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v15 + 5]].uSkillType;
+              v34 = pItemsTable->pItems[*(int *)&v1->pInventoryItems[v15-1]].uSkillType;
             pTurnEngine->_40471C();
           }
           else
@@ -8049,7 +8050,7 @@
         else
         {
           v34 = 5;
-          v1->PlaySound(50, v3);
+          v1->PlaySound(SPEECH_50, v3);
         }
         switch ( v34 )
         {
@@ -8147,7 +8148,7 @@
     v6 = a3 != 0;
     if ( a4 )
       LOBYTE(v6) = v6 | 8;
-    v7 = pGame->pVisInstance->_4C1944(3, a2, v6, 657456, -1);
+    v7 = pGame->pVisInstance->_4C1944(OBJECT_Actor, a2, v6, 657456, -1);
     if ( v7 != -1 )
       return (unsigned __int16)v7;
   }
@@ -8574,14 +8575,14 @@
   if ( !(a1a.uAttributes & 0x10) )
   {
     v13 = 0;
-    if ( (signed int)pItemsTable->pItems[0].uItemID > 0 )
+    if ( (signed int)pItemsTable->uAllItemsCount > 0 )
     {
       v14 = (char *)&pItemsTable->pItems[0].uSpriteID;
       while ( *(short *)v14 != v9 )
       {
         ++v13;
         v14 += 48;
-        if ( (signed int)v13 >= (signed int)pItemsTable->pItems[0].uItemID )
+        if ( (signed int)v13 >= (signed int)pItemsTable->uAllItemsCount )
           goto LABEL_16;
       }
       a1a.stru_24.uItemID = v13;
@@ -9110,14 +9111,12 @@
             v5->Add(partyAction);
             break;
           case INPUT_Yell:
-            //__debugbreak();
-            if ( !pCurrentScreen
-              && uActiveCharacter )
+            if (!pCurrentScreen && uActiveCharacter)
             {
               pParty->Yell();
-              pPlayers[uActiveCharacter]->PlaySound(65, 0);
+              pPlayers[uActiveCharacter]->PlaySound(SPEECH_Yell, 0);
             }
-            break;
+          break;
           case INPUT_Pass:
             //__debugbreak();
             if ( pCurrentScreen )
--- a/mm7_data.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/mm7_data.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -1,7 +1,8 @@
 #include "mm7_data.h"
 
 #include "NPC.h"
-
+#include "Actor.h"
+#include "GUIWindow.h"
 
 
 
@@ -47,13 +48,6 @@
 #include "stru279.h"
 stru279 stru_51076C;
 
-#include "stru157.h"
-stru157 stru_F93E1C; // weak
-stru157 stru_F93E30; // weak
-stru157 a5; // idb
-stru157 a4; // idb
-stru157 a3; // idb
-
 #include "stru179.h"
 stru179 pStru179;
 
@@ -327,8 +321,6 @@
 //-------------------------------------------------------------------------
 // Data declarations
 
-int (__cdecl *sprintfex)(char *a1, const char *a2, ...) = nullptr;
-
 int pWindowList_at_506F50_minus1_indexing[1];
 int dword_4C9890[10]; // weak
 int dword_4C9920[16]; // weak
@@ -391,9 +383,19 @@
 __int16 pTownPortalBook_ws[6];
 __int16 pTownPortalBook_hs[6];
 int dword_4E20D0[777]; // idb
-char byte_4E2430[777]; // weak
-char byte_4E2431[777]; // weak
-unsigned int pLloydsBeaconsPreviewXs[5] = {61, 281,  61, 281, 171};
+unsigned char pSpellbookSpellIndices[9][12] = // 4E2430
+{
+   {0,  3,  1,  8, 11,  7,  4, 10,  6,  2,  5,  9},
+   {0, 11,  2,  9,  6,  8,  5, 10,  3,  7,  1,  4},
+   {0,  4,  8,  9,  1, 10,  3, 11,  7,  6,  2,  5}, 
+   {0,  7, 10,  8,  2, 11,  1,  5,  3,  6,  4,  9},
+   {0,  5, 10, 11,  7,  2,  8,  1,  4,  9,  3,  6},
+   {0,  5,  9,  8,  3,  7,  6,  4,  1, 11,  2, 10}, 
+   {0,  1,  6,  9,  3,  5,  8, 11,  7, 10,  4,  2},
+   {0,  1, 10, 11,  9,  4,  3,  6,  5,  7,  8,  2},
+   {0,  9,  3,  7,  1,  5,  2, 10, 11,  8,  6,  4}
+};
+unsigned int pLloydsBeaconsPreviewXs[5] = {61, 281,  61, 281, 171}; // 004E249C
 unsigned int pLloydsBeaconsPreviewYs[5] = {84,  84, 228, 228, 155};
 unsigned int pLloydsBeacons_SomeXs[5] = {59, 279, 59, 279, 169};
 unsigned int pLloydsBeacons_SomeYs[5] = {82, 82, 226, 226, 153};
@@ -474,7 +476,7 @@
 char aS100110D[777]; // idb
 char aS100110DS[777]; // idb
 char aS100110D02dSS[777]; // idb
-int pCurrentScreen; // weak
+int pCurrentScreen = SCREEN_VIDEO; // 004E28F8
 char byte_4E28FC; // weak
 unsigned int uGammaPos;
 int dword_4E2910[777]; // weak
@@ -542,7 +544,7 @@
 char aS100S[777]; // idb
 char aS100D[777]; // idb
 char aS180[6]; // idb
-const char *format_4E2E68 = "%s\f%05u\t180%d\f00000 / %d\d";
+const char *format_4E2E68 = "%s\f%05u\t180%d\f00000 / %d\n";
 char aS_6[2]; // idb
 char aSS_0[777]; // idb
 char aS_5[4]; // idb
@@ -1094,16 +1096,171 @@
   "pc19lhu", "pc20lhu", "pc21lhu", "pc22lhu", "pc23lhu", "pc24lhu",
   "pc25lhu"
 };
-short SoundSetAction[192]=
+
+unsigned char byte_4ECF08[48][25] =      // 4ECF08
+{
+  {2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1},//1
+  {2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2},//2
+  {2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//3
+  {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//4
+  {2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//5
+  {2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//6
+  {2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//7
+  {2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1},//8
+  {2, 1, 2, 2, 2, 2, 1, 2, 1, 2, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2},//9
+  {2, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//10
+  {2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2},//11
+  {1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2},//12
+  {2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//13
+  {1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 2},//14
+  {2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2},//15
+  {1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1},//16
+  {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//17
+  {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1},//18
+  {1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//19
+  {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//20
+  {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//21
+  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//22
+  {2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1},//23
+  {2, 2, 2, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2},//24
+  {1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 2, 2, 2, 1, 2, 1, 1},//25
+  {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//26
+  {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2},//27
+  {1, 2, 2, 1, 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//28
+  {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 1, 1},//29
+  {1, 2, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 1, 2, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1},//30
+  {1, 1, 2, 1, 2, 1, 2, 2, 2, 2, 2, 1, 2, 1, 2, 1, 2, 2, 2, 2, 2, 1, 2, 1, 1},//31
+  {1, 1, 2, 1, 1, 2, 2, 2, 2, 1, 2, 2, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2},//32
+  {1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1},//33
+  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1},//34
+  {1, 1, 1, 2, 1, 2, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2},//35
+  {1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2},//36
+  {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2},//37
+  {2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 1, 1},//38
+  {1, 1, 1, 1, 2, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1},//39
+  {1, 2, 2, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//40
+  {2, 1, 2, 1, 2, 1, 2, 2, 2, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1},//41
+  {1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 1},//42
+  {1, 2, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//43
+  {1, 2, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 2},//44
+  {2, 1, 1, 1, 2, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2},//45
+  {1, 1, 1, 2, 2, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2, 2, 2, 1, 1, 2, 1, 2, 1, 2, 2},//46
+  {1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1},//47
+  {1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1},//48
+};
+unsigned char SoundSetAction[110][8] = // 4ED3D8
 {
-	0, 0, 0, 0, 0, 0, 0, 0, 38, 0, 0, 37, 38, 45, 0, 0, 37, 0, 0, 47, 53, 0, 0, 0, 2, 0, 0, 25, 0, 0, 0, 0, 1, 0, 0, 47, 0,
-	0, 0, 0, 3, 0, 0, 41, 42, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 5, 0, 0, 21, 22, 23, 24, 45, 6, 0, 0, 47, 0, 0, 0, 0, 7, 0,
-	0, 43, 48, 0, 0, 0, 8, 0, 0, 38, 0, 0, 0, 0, 9, 0, 0, 39, 0, 0, 0, 0, 13, 0, 0, 37, 38, 0, 0, 0, 23, 0, 0, 25, 0, 0, 0,
-	0, 0, 0, 0, 37, 38, 45, 0, 0, 25, 0, 0, 25, 0, 0, 0, 0, 26, 0, 0, 38, 47, 0, 0, 0, 27, 0, 0, 41, 42, 0, 0, 0, 28, 0, 0,
-	25, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 30, 0, 0, 25, 0, 0, 0, 0, 29, 0, 0, 27, 0, 0, 0, 0, 32, 33, 0, 37, 38, 0, 0, 0,
-	34, 0, 0, 53, 0, 0, 0, 0
-}; // weak
-unsigned char byte_4ED498 = 15; // weak
+  { 0,  0,  0,  0,  0,  0,  0,  0},
+  {38,  0,  0, 37, 38, 45,  0,  0},
+  {37,  0,  0, 47, 53,  0,  0,  0},
+  { 2,  0,  0, 25,  0,  0,  0,  0},
+  { 1,  0,  0, 47,  0,  0,  0,  0},
+  { 3,  0,  0, 41, 42,  0,  0,  0},
+  { 0,  0,  0, 33,  0,  0,  0,  0},
+  { 5,  0,  0, 21, 22, 23, 24, 45},
+  { 6,  0,  0, 47,  0,  0,  0,  0},
+  { 7,  0,  0, 43, 48,  0,  0,  0},
+  { 8,  0,  0, 38,  0,  0,  0,  0},
+  { 9,  0,  0, 39,  0,  0,  0,  0},
+  {13,  0,  0, 37, 38,  0,  0,  0},
+  {23,  0,  0, 25,  0,  0,  0,  0},
+  { 0,  0,  0, 37, 38, 45,  0,  0},
+  {25,  0,  0, 25,  0,  0,  0,  0},
+  {26,  0,  0, 38, 47,  0,  0,  0},
+  {27,  0,  0, 41, 42,  0,  0,  0},
+  {28,  0,  0, 25,  0,  0,  0,  0},
+  { 0,  0,  0, 51,  0,  0,  0,  0},
+  {30,  0,  0, 25,  0,  0,  0,  0},
+  {29,  0,  0, 27,  0,  0,  0,  0},
+  {32, 33,  0, 37, 38,  0,  0,  0},
+  {34,  0,  0, 53,  0,  0,  0,  0},
+  {15,  0,  0, 34, 35, 36,  0,  0},
+  { 0,  0,  0,  3,  0,  0,  0,  0},
+  {22,  0,  0,  5,  0,  0,  0,  0},
+  {20,  0,  0,  8,  0,  0,  0,  0},
+  {20,  0,  0,  9,  0,  0,  0,  0},
+  {19,  0,  0,  7,  0,  0,  0,  0},
+  {21,  0,  0,  2,  0,  0,  0,  0},
+  {18,  0,  0,  6,  0,  0,  0,  0},
+  { 0,  0,  0, 11,  0,  0,  0,  0},
+  {17,  0,  0,  0,  0,  0,  0,  0},
+  { 0,  0,  0, 12,  0,  0,  0,  0},
+  {17,  0,  0,  0,  0,  0,  0,  0},
+  { 0,  0,  0, 37,  0,  0,  0,  0},
+  { 0,  0,  0, 49,  0,  0,  0,  0},
+  {24,  0,  0, 25,  0,  0,  0,  0},
+  {31,  0,  0, 25,  0,  0,  0,  0},
+  { 0,  0,  0, 41, 42,  0,  0,  0},
+  { 0,  0,  0, 39, 48,  0,  0,  0},
+  { 0,  0,  0, 46,  0,  0,  0,  0}, 
+  { 0,  0,  0, 39, 48,  0,  0,  0},
+  { 0,  0,  0, 41, 42,  0,  0,  0},
+  { 0,  0,  0, 39, 48,  0,  0,  0},
+  {41,  0,  0, 21,  0,  0,  0,  0},
+  {40,  0,  0, 21,  0,  0,  0,  0},
+  {16,  0,  0, 46,  0,  0,  0,  0},
+  { 0,  0,  0, 40,  0,  0,  0,  0},
+  { 0,  0,  0, 39,  0,  0,  0,  0},
+  { 0,  0,  0, 37, 38,  0,  0,  0},
+  { 0,  0,  0, 48, 49, 50,  0,  0},
+  { 0,  0,  0, 44,  0,  0,  0,  0},
+  { 0,  0,  0, 48,  0,  0,  0,  0},
+  { 0,  0,  0, 37, 38, 45,  0,  0},
+  { 0,  0,  0, 41, 42,  0,  0,  0},
+  { 0,  0,  0, 47,  0,  0,  0,  0},
+  { 0,  0,  0, 39, 48,  0,  0,  0},
+  { 0,  0,  0, 39, 48,  0,  0,  0},
+  { 0,  0,  0, 37, 38,  0,  0,  0},
+  { 0,  0,  0, 37, 38,  0,  0,  0},
+  { 0,  0,  0, 37, 38,  0,  0,  0},
+  { 0,  0,  0, 31,  0,  0,  0,  0},
+  { 0,  0,  0, 32,  0,  0,  0,  0},
+  {47,  0,  0, 46,  0,  0,  0,  0},
+  {22,  0,  0,  5,  0,  0,  0,  0},
+  { 0,  0,  0, 25,  0,  0,  0,  0},
+  { 0,  0,  0, 37,  0,  0,  0,  0},
+  { 0,  0,  0, 52,  0,  0,  0,  0},
+  { 0,  0,  0, 45,  0,  0,  0,  0},
+  { 0,  0,  0, 27,  0,  0,  0,  0},
+  { 0,  0,  0, 37, 38,  0,  0,  0},
+  { 0,  0,  0, 49,  0,  0,  0,  0},
+  { 0,  0,  0, 48,  0,  0,  0,  0},
+  { 0,  0,  0, 37, 38, 45,  0,  0},
+  { 0,  0,  0, 48,  0,  0,  0,  0},
+  { 0,  0,  0, 37, 38, 45,  0,  0},
+  { 0,  0,  0, 47,  0,  0,  0,  0},
+  { 0,  0,  0, 48,  0,  0,  0,  0},
+  {44,  0,  0, 39, 48,  0,  0,  0},
+  { 0,  0,  0, 48, 49,  0,  0,  0},
+  { 0,  0,  0, 38,  0,  0,  0,  0},
+  { 0,  0,  0, 31,  0,  0,  0,  0},
+  {32, 33,  0, 37, 38,  0,  0,  0},
+  { 0,  0,  0, 37, 38,  0,  0,  0},
+  { 0,  0,  0, 37, 38,  0,  0,  0},
+  { 0,  0,  0, 47,  0,  0,  0,  0},
+  { 0,  0,  0, 38,  0,  0,  0,  0},
+  { 0,  0,  0, 48,  0,  0,  0,  0},
+  { 0,  0,  0,  0,  0,  0,  0,  0},
+  { 0,  0,  0, 38,  0,  0,  0,  0},
+  { 0,  0,  0, 47,  0,  0,  0,  0},
+  { 0,  0,  0, 38,  0,  0,  0,  0},
+  { 0,  0,  0,  0,  0,  0,  0,  0},
+  { 0,  0,  0,  0,  0,  0,  0,  0},
+  { 0,  0,  0, 38,  0,  0,  0,  0},
+  { 0,  0,  0, 38,  0,  0,  0,  0},
+  { 0,  0,  0,  5,  0,  0,  0,  0},
+  { 0,  0,  0, 37, 38,  0,  0,  0},
+  { 0,  0,  0, 44,  0,  0,  0,  0},
+  { 0,  0,  0, 48,  0,  0,  0,  0},
+  { 4,  0,  0,  0,  0,  0,  0,  0},
+  { 0,  0,  0, 58,  0,  0,  0,  0},
+  {10,  0,  0, 45,  0,  0,  0,  0},
+  {11,  0,  0, 47,  0,  0,  0,  0},
+  {12,  0,  0, 43, 48,  0,  0,  0},
+  {39,  0,  0, 48,  0,  0,  0,  0},
+  {14,  0,  0, 48,  0,  0,  0,  0},
+  {17,  0,  0,  0,  0,  0,  0,  0}
+};
 __int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[4] = {34, 149, 264, 379};
 char byte_4ED970_skill_learn_ability_by_class_table[32][37];
 int dword_4EDEA0[777]; // weak
@@ -1530,7 +1687,7 @@
 int dword_5C35D4; // weak
 char *aAMPMNames[2];
 char byte_5C45AF[777]; // weak
-char pTmpBuf3[2048];
+
 char pFinalMessage[4096]; // idb
 char pTmpBuf[2000];
 char pTmpBuf2[2000];
@@ -1568,13 +1725,13 @@
 char *pClassTXT_Raw;
 char *pStatsTXT_Raw;
 char *pSkillDescTXT_Raw;
-struct StorylineText *pStorylineText;
+
 struct FactionTable *pFactionTable;
 char byte_5C8D1A[777]; // weak
-char *pGlobalTXT_LocalizationStrings[677];
+
 char byte_5E4C15[777]; // weak
 char *pSomeItemsNames[14];
-char *pGlobalTXT_Raw;
+
 char *pMonstersTXT_Raw;
 char *pMonsterPlacementTXT_Raw;
 char *pSpellsTXT_Raw;
@@ -1582,7 +1739,7 @@
 char *pHostileTXT_Raw;
 char *pPotionsTXT_Raw;
 char *pPotionNotesTXT_Raw;
-char *pHistoryTXT_Raw;
+
 int _6807B8_level_decorations_ids[777]; // idb
 int _6807E0_num_decorations_with_sounds_6807B8; // weak
 int _6807E8_level_decorations_ids[777]; // idb
@@ -1856,8 +2013,8 @@
 int dword_F8B1F4; // weak
 _UNKNOWN unk_F8B1F8; // weak
 _UNKNOWN unk_F8B5E0; // weak
-_UNKNOWN unk_F8B668; // weak
-_UNKNOWN unk_F8BA50; // weak
+char array_F8B668[1000]; // weak
+//_UNKNOWN unk_F8BA50; // weak
 char byte_F8BC0C; // weak
 int bGameoverLoop = 0; // weak
 __int16 word_F8BC48_displaced_face_intersect_plane_coords_a; // idb
--- a/mm7_data.h	Mon Feb 18 09:44:44 2013 +0600
+++ b/mm7_data.h	Mon Feb 18 09:44:59 2013 +0600
@@ -310,7 +310,6 @@
 
 //-------------------------------------------------------------------------
 // Data declarations
-//extern int (__cdecl *sprintfex)(char *a1, const char *a2, ...);
 
 extern int pWindowList_at_506F50_minus1_indexing[1];
 extern int dword_4C9890[10]; // weak
@@ -374,9 +373,8 @@
 extern __int16 pTownPortalBook_ws[6];
 extern __int16 pTownPortalBook_hs[6];
 extern int dword_4E20D0[]; // idb
-extern char byte_4E2430[]; // weak
-extern char byte_4E2431[]; // weak
-extern unsigned int pLloydsBeaconsPreviewXs[5];
+extern unsigned char pSpellbookSpellIndices[9][12]; // 4E2430
+extern unsigned int pLloydsBeaconsPreviewXs[5]; // 004E249C
 extern unsigned int pLloydsBeaconsPreviewYs[5];
 extern unsigned int pLloydsBeacons_SomeXs[5];
 extern unsigned int pLloydsBeacons_SomeYs[5]; // idb
@@ -457,7 +455,7 @@
 extern char aS100110D[]; // idb
 extern char aS100110DS[]; // idb
 extern char aS100110D02dSS[]; // idb
-extern int pCurrentScreen; // weak
+extern int pCurrentScreen; // 004E28F8
 extern char byte_4E28FC; // weak
 extern unsigned int uGammaPos;
 extern int dword_4E2910[]; // weak
@@ -979,8 +977,9 @@
 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 short SoundSetAction[192]; // weak
-extern unsigned char byte_4ED498; // weak
+extern unsigned char byte_4ECF08[48][25];
+extern unsigned char SoundSetAction[110][8]; // weak
+//extern unsigned char byte_4ED498; // weak
 extern __int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[4];
 extern char byte_4ED970_skill_learn_ability_by_class_table[32][37];
 extern int dword_4EDEA0[]; // weak
@@ -1154,7 +1153,6 @@
 extern __int64 qword_506350; // weak
 extern char byte_506360; // weak
 extern int dword_506364; // weak
-extern Texture *dword_506408[]; // weak
 extern Texture *dword_50640C[]; // weak
 extern unsigned int uTextureID_506438;
 extern int dword_50651C; // weak
@@ -1374,7 +1372,7 @@
 extern int dword_5C35D4; // weak
 extern char *aAMPMNames[2];
 extern char byte_5C45AF[]; // weak
-extern char pTmpBuf3[2048];
+extern char pTmpBuf3[];
 extern char pFinalMessage[4096]; // idb
 extern char pTmpBuf[2000];
 extern char pTmpBuf2[2000];
@@ -1412,13 +1410,13 @@
 extern char *pClassTXT_Raw;
 extern char *pStatsTXT_Raw;
 extern char *pSkillDescTXT_Raw;
-extern struct StorylineText *pStorylineText;
+
 extern struct FactionTable *pFactionTable;
 extern char byte_5C8D1A[]; // weak
-extern char *pGlobalTXT_LocalizationStrings[677];
+
 extern char byte_5E4C15[]; // weak
 extern char *pSomeItemsNames[14];
-extern char *pGlobalTXT_Raw;
+
 extern char *pMonstersTXT_Raw;
 extern char *pMonsterPlacementTXT_Raw;
 extern char *pSpellsTXT_Raw;
@@ -1426,7 +1424,7 @@
 extern char *pHostileTXT_Raw;
 extern char *pPotionsTXT_Raw;
 extern char *pPotionNotesTXT_Raw;
-extern char *pHistoryTXT_Raw;
+
 extern int _6807B8_level_decorations_ids[]; // idb
 extern int _6807E0_num_decorations_with_sounds_6807B8; // weak
 extern int _6807E8_level_decorations_ids[]; // idb
@@ -1711,8 +1709,8 @@
 extern _UNKNOWN unk_F8B1F8; // weak
 extern _UNKNOWN unk_F8B5E0; // weak
 extern struct FrameTableTxtLine stru_F8B5E8; // weak
-extern _UNKNOWN unk_F8B668; // weak
-extern _UNKNOWN unk_F8BA50; // weak
+extern char array_F8B668[]; // weak
+//extern _UNKNOWN unk_F8BA50; // weak
 extern char byte_F8BC0C; // weak
 extern int bGameoverLoop; // weak
 extern __int16 word_F8BC48_displaced_face_intersect_plane_coords_a; // idb
@@ -1827,7 +1825,7 @@
 signed int __fastcall sub_410D99_get_map_index(int a1);
 unsigned int __cdecl DrawLloydBeaconsScreen();
 char *__cdecl DrawTownPortalScreen();
-struct Texture *__fastcall LoadSpellbook(unsigned int uID); // idb
+void LoadSpellbook(unsigned int uID); // idb
 struct GUIWindow *__cdecl sub_41140B();
 void __cdecl sub_411473();
 void __cdecl OnCloseSpellook();
@@ -2002,8 +2000,8 @@
 __int16 __fastcall sub_441A4E(int a1);
 void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int bRedrawOdmMinimap);
 int __fastcall DrawBook_Map_sub(unsigned int x, unsigned int y, unsigned int a4, int a5, int _48074); // idb
-int __cdecl Initialize2DA();
-unsigned int __fastcall LoadEventsToBuffer(const char *pContainerName, char *a2, unsigned int uBufferSize);
+void Initialize2DA();
+unsigned int LoadEventsToBuffer(const char *pContainerName, char *pBuffer, unsigned int uBufferSize);
 void __cdecl Initialize_GlobalEVT();
 void __cdecl LoadLevel_InitializeLevelStr();
 void __cdecl LoadLevel_InitializeLevelEvt();
@@ -2078,9 +2076,7 @@
 inline void __fastcall j_memset32(int a2, void *a1, unsigned int a3) {memset32(a1, a2, a3);}
 // int __cdecl crt_452B74();
 int __cdecl j_SetSomeItemsNames();
-void __cdecl SetSomeItemsNames();
-char *RemoveQuotes(char *Str);
-void __cdecl InitializeGameText();
+
 unsigned int __fastcall ParseSpellType(struct FrameTableTxtLine *, int a2);
 int __thiscall ParseAttackType(unsigned __int8 *_this);
 char __fastcall ParseDamage(const char *Str, int a2, int a3, int a4);
@@ -2147,7 +2143,7 @@
 void __cdecl OnPaperdollLeftClick();
 int __thiscall UnprojectX(int x);
 int __thiscall UnprojectY(int _this);
-char __cdecl OnPressSpace();
+void OnPressSpace();
 char __fastcall DoInteractionWithTopmostZObject(int a1, int a2);
 int __fastcall sub_46A6AC(int a1, int a2, int a3);
 int __fastcall sub_46A7C8(int a1, int a2, signed int a3);
@@ -2386,7 +2382,7 @@
 int /*__usercall*/ sr_sub_4D72EC/*<eax>*/(int a1/*<ebp>*/);
 int /*__usercall*/ sr_sub_4D73DF/*<eax>*/(int a1/*<ebp>*/);
 signed int __fastcall SpawnRandomTreasure(struct MapInfo *a1, struct SpawnPointMM7 *a2);
-bool __fastcall DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, struct Vec3_int_ *pVelocity);
+void DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, struct Vec3_int_ *pVelocity);
 
 
 #define ErrD3D(hr) do {extern void ErrHR(HRESULT, const char *, const char *, const char *, int); ErrHR(hr, "Direct3D", __FUNCTION__, __FILE__, __LINE__);} while(0)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mm7text_ru.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -0,0 +1,1417 @@
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+
+#include "Log.h"
+
+
+struct GenderTableEntry
+{
+  const char *name;
+  int         gender;
+} gender_table_caps[] =
+{
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 2},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 2},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 2},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 2},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 2},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"-", 0},
+  {"-", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 2},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 2},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 2},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 2},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 2},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 2},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 2},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 2},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 2},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 2},
+  {"", 0},
+  {"", 0},
+  {"", 2},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 2},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 2},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 2},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 2},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 1},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 1},
+  {"", 2},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 1},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0},
+  {"", 0}
+},
+  gender_table[] =
+{
+  {"", 0},       {"", 1},    {"", 0},      {"", 1},      {"", 0}, {"", 0},   {"", 1},      {"", 1},   {"", 0}, {"", 0},  {"", 1},
+  {"", 0},     {"", 0},      {"", 1},     {"", 0},       {"", 0},   {"", 1},     {"", 1},   {"", 0},    {"", 1},  {"", 0},     {"", 0},
+  {"", 0},   {"", 0},      {"", 0},    {"", 1}, {"", 0},     {"", 0}, {"", 1},      {"", 0}, {"", 0},     {"", 1}, {"", 1},
+  {"", 0}, {"", 1},    {"", 0}, {"", 1},       {"", 0},  {"", 0},    {"", 0},        {"", 0},   {"", 0},  {"", 1},     {"", 0},
+  {"", 1}, {"", 0},    {"", 0},       {"", 0},       {"", 1},  {"", 1},   {"", 0}, {"", 0},   {"", 0},   {"", 0},    {"", 1},
+  {"", 0},   {"", 0}, {"", 0},       {"", 0},   {"", 0},     {"", 0},  {"", 0},     {"", 0},    {"", 0},   {"", 0},   {"", 0},
+  {"", 0},     {"", 2},  {"", 1},     {"", 0}
+};
+
+
+
+#include <mbstring.h>
+
+int GetGender(char *ansi_name, int name_len)
+{
+  auto name = (unsigned char *)ansi_name;
+
+  GenderTableEntry *table = nullptr;
+  unsigned int      table_size = 0;
+  if (name[0] >= (unsigned char)'' && name[0] <= (unsigned char)'')
+  {
+    table = gender_table;
+    table_size = sizeof(gender_table) / sizeof(*gender_table);
+  }
+  else if (name[0] >= (unsigned char)'' && name[0] <= (unsigned char)'')
+  {
+    table = gender_table_caps;
+    table_size = sizeof(gender_table_caps) / sizeof(*gender_table_caps);
+  }
+  else return 0;
+
+  int left = 0,
+      right = table_size - 1,
+      match = 0;
+  while (left <= right)
+  {
+    match = left + (right - left) / 2;
+    switch (_mbsncmp(name, (unsigned char *)table[match].name, name_len))
+    {
+      case -1: right = match; break;
+      case  0: return table[match].gender;
+      case  1: left = match; break;
+    }
+  }
+  assert(false);
+  return 0;
+}
+
+
+bool IsSpecialName(const char *ansi_name)
+{
+  auto name = (unsigned char *)ansi_name;
+  return !_mbsncmp(name, (unsigned char *)" ", 8)        || !_mbsncmp(name, (unsigned char *)" ", 6) ||
+         !_mbsncmp(name, (unsigned char *)"  ", 14) || !_mbsncmp(name, (unsigned char *)" ", 12);
+}
+int GetSpecialGender(const char *ansi_name)
+{
+  auto name = (unsigned char *)ansi_name;
+  if (!_mbsncmp(name, (unsigned char *)" ", 8))
+    return 1;
+  if (!_mbsncmp(name, (unsigned char *)" ", 6))
+    return 1;
+  if (!_mbsncmp(name, (unsigned char *)"  ", 14))
+    return 1;
+  if (!!_mbsncmp(name, (unsigned char *)" ", 12))
+    return 0;
+  return 0;
+}
+const char *GetSpecialCase(const char *ansi_name, char c)
+{
+  auto name = (unsigned char *)ansi_name;
+
+  if (!_mbsncmp(name, (unsigned char *)" ", 8))
+    return " ";
+  if (!_mbsncmp(name, (unsigned char *)" ", 6))
+    return " ";
+
+  if (!_mbsncmp(name, (unsigned char *)"  ", 14))
+    switch (c)
+    {
+      case 'I': case 'i': return "  ";
+      case 'R': case 'r': return "  ";
+      case 'D': case 'd': return "  ";
+      case 'V': case 'v': return "  ";
+      case 'T': case 't': return "  ";
+      case 'P': case 'p': return "  ";
+    }
+
+  if (!_mbsncmp(name, (unsigned char *)" ", 12))
+    switch (c)
+    {
+      case 'I': case 'i': return " ";
+      case 'R': case 'r': return " ";
+      case 'D': case 'd': return " ";
+      case 'V': case 'v': return " ";
+      case 'T': case 't': return " ";
+      case 'P': case 'p': return " ";
+    }
+
+  return nullptr;
+}
+
+int __cdecl sprintfex_internal(char *str)
+{
+  auto p = strstr(str, "^");
+  if (!p)
+    return strlen(str);
+
+  char buf[8192];
+  assert(strlen(str) < sizeof(buf));
+
+  bool integer_token_defined = false;
+  int integer_token = 0;
+
+  bool gender_token_defined = false;
+  int gender_token = 0;
+  
+  auto src = buf,
+       dst = p;
+  strcpy(buf, str + (p - str));
+  while (true)
+  {
+    switch (src[1])
+    {
+      case 'I':
+      {
+        if (src[2] != '[')
+          goto _invalid_token;
+        src += 3;  // ^I[
+
+        if (sscanf(src, "%d", &integer_token))
+          integer_token_defined = true;
+
+        auto int_begin = src;
+        while (*src++ != ']');
+
+        int int_len = src - int_begin - 1;
+        strncpy(dst, int_begin, int_len);
+        dst += int_len;
+      }
+      break;
+
+      case 'L':
+      {
+        if (src[2] != '[')
+          goto _invalid_token;
+        assert(integer_token_defined);
+        src += 3; // ^L[
+
+        auto ending1 = src;
+        while (*src++ != ';');
+        auto ending2 = src;
+        while (*src++ != ';');
+        auto ending3 = src;
+        while (*src++ != ']');
+
+        char *actual_ending = nullptr;
+        int   actual_ending_len = 0;
+
+        int modulo = abs(integer_token) % 10;
+        if (modulo == 1)
+        {
+          actual_ending = ending1;
+          actual_ending_len = ending2 - ending1 - 1;
+        }
+        else if (modulo >= 2 && modulo <= 4)
+        {
+          actual_ending = ending2;
+          actual_ending_len = ending3 - ending2 - 1;
+        }
+        else
+        {
+          actual_ending = ending3;
+          actual_ending_len = src - ending3 - 1;
+        }
+
+        strncpy(dst, actual_ending, actual_ending_len);
+        dst += actual_ending_len;
+      }
+      break;
+
+      case 'R':
+      {
+        if (src[2] != '[')
+          goto _invalid_token;
+        assert(gender_token_defined);
+
+        src += 3; // ^R[
+
+        auto ending1 = src;
+        while (*src++ != ';');
+        auto ending2 = src;
+        while (*src++ != ';');
+        auto ending3 = src;
+        while (*src++ != ']');
+
+        char *actual_ending = nullptr;
+        int   actual_ending_len = 0;
+
+        if (gender_token == 0)
+        {
+          actual_ending = ending1;
+          actual_ending_len = ending2 - ending1 - 1;
+        }
+        else if (gender_token == 1)
+        {
+          actual_ending = ending2;
+          actual_ending_len = ending3 - ending2 - 1;
+        }
+        else if (gender_token == 2)
+        {
+          actual_ending = ending3;
+          actual_ending_len = src - ending3 - 1;
+        }
+        else assert(false);
+
+        strncpy(dst, actual_ending, actual_ending_len);
+        dst += actual_ending_len;
+      }
+      break;
+
+      case 'P':
+      {
+        if (src[3] != '[')
+          goto _invalid_token;
+        switch (src[2])
+        {
+          case 'I': case 'i':
+          case 'R': case 'r':
+          case 'D': case 'd':
+          case 'V': case 'v':
+          case 'T': case 't':
+          case 'P': case 'p': break;
+          default:
+            goto _invalid_token;
+        }
+
+        if (IsSpecialName(src + 4))
+        {
+          __debugbreak(); // check this is ok
+          auto name = GetSpecialCase(src + 4, src[2]);
+          int name_len = strlen(name);
+
+          gender_token = GetSpecialGender(src + 4);
+          gender_token_defined = true;
+
+          strncpy(dst, name, name_len);
+          dst += name_len;
+          while (*src++ != ']');
+          break;
+        }
+        
+        auto name_begin = src + 4;
+        int name_len = 0;
+        for (int i = 0; name_begin[i] != ']'; ++i)
+          name_len++;
+        gender_token = GetGender(name_begin, name_len);
+        gender_token_defined = true;
+
+        switch (src[2])
+        {
+          case 'I': case 'i':
+          {
+            strncpy(dst, name_begin, name_len);
+            dst += name_len;
+          }
+          break;
+
+          case 'R': case 'r':
+          case 'D': case 'd':
+          case 'V': case 'v':
+          case 'T': case 't':
+          case 'P': case 'p':
+          {
+            auto token_begin = src;
+            int token_len = 0;
+            for (int i = 0; token_begin[i] != ']'; ++i)
+              token_len++;
+            strncpy(dst, token_begin, token_len);
+            dst += token_len;
+          }
+        }
+        while (*src++ != ']');
+      }
+      break;
+
+      default:
+      {
+_invalid_token:
+        auto token_begin = src;
+        while (*src++ != ']');
+
+        int token_len = src - token_begin;
+        char token[1024];
+        strncpy(token, token_begin, token_len);
+        token[token_len] = 0;
+
+        Log::Warning(L"Invalid format token: %S", token);
+        assert(false);
+      }
+      break;
+    }
+    
+    *dst = 0;
+
+    auto copy_begin = src;
+    src = strstr(src, "^");
+    if (!src)
+    {
+      strcpy(dst, copy_begin); // just copy the rest
+      break;
+    }
+
+    int copy_len = src - copy_begin;
+    strncpy(dst, copy_begin, copy_len);
+    dst += copy_len;
+  }
+
+  return dst - str;
+}
+
+
+
+
+
+
+//mm6text.non -> c structure array
+  /*FILE *f = fopen("_1.txt", "w+t");
+  FILE *in = fopen("mm6text.non", "rt");
+  fscanf(in, "%*[^\n]\n");
+
+  int idx = 0;
+  auto pairs = new NameGender[8000];
+
+  char line[1024];
+  while (fscanf(in, "%[^\n]\n", line) && !feof(in))
+  {
+    char name1[100], name2[100], name3[100];
+    int e = sscanf(line, "%s\t%s\t%s", pairs[idx].name, pairs[idx + 1].name, pairs[idx + 2].name);
+    pairs[idx].gender = 0;
+    pairs[idx+1].gender = 1;
+    pairs[idx+2].gender = 2;
+    idx += e;
+  }
+
+  for (int i = 0; i < idx; ++i)
+    for (int j = 0; j < i; ++j)
+    {
+      if (_mbsicmp(pairs[i].name, pairs[j].name) < 0)
+      {
+        char n[1024];
+        strcpy(n, (char *)pairs[j].name);
+        auto g = pairs[j].gender;
+
+        strcpy((char *)pairs[j].name, (char *)pairs[i].name);
+        pairs[j].gender = pairs[i].gender;
+
+        strcpy((char *)pairs[i].name, n);
+        pairs[i].gender = g;
+      }
+    }
+    
+  for (int i = 0; i < idx; ++i)
+  {
+    fprintf(f, "  {\"%s\", %u},\n", pairs[i].name, pairs[i].gender);
+  }
+  fclose(f);*/
\ No newline at end of file
--- a/stru157.h	Mon Feb 18 09:44:44 2013 +0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-#pragma once
-
-
-/*  150 */
-#pragma pack(push, 1)
-struct stru157
-{
-  int field_0;
-  int field_4;
-  int field_8;
-  int field_C;
-  int field_10;
-};
-#pragma pack(pop)
-extern stru157 stru_F93E1C; // weak
-extern stru157 stru_F93E30; // weak
-extern stru157 a5; // idb
-extern stru157 a4; // idb
-extern stru157 a3; // idb
\ No newline at end of file
--- a/stru6.cpp	Mon Feb 18 09:44:44 2013 +0600
+++ b/stru6.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -1553,27 +1553,25 @@
       pRenderer->pRenderD3D->pDevice->SetTexture(
         0,
         pSprites_LOD->pHardwareSprites[v11].pTexture);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 8u);
+      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE);
+      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
+      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE);
+      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
+      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
+      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE);
+      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS);
       pRenderer->pRenderD3D->pDevice->DrawPrimitive(
         D3DPT_TRIANGLEFAN,
         D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
         vd3d,
         4,
         28);
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2),
-                  "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\seffects.cpp:1348");
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1),
-                  "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\seffects.cpp:1349");
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, true);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2);
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
+      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
+      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE);
+      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE);
+      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS);
     }
     else
     {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/texts.cpp	Mon Feb 18 09:44:59 2013 +0600
@@ -0,0 +1,391 @@
+
+#include <string.h>
+#include "Allocator.h"
+#include "stru287.h"
+#include "LOD.h"
+#include "mm7_data.h"
+#include "texts.h"
+
+
+
+
+
+static char *pGlobalTXT_Raw=NULL;
+
+char *pGlobalTXT_LocalizationStrings[MAX_LOC_STRINGS];
+
+
+
+int __cdecl sprintfex(char *buf, const char *format, ...)
+{
+  va_list args_ptr;
+  va_start(args_ptr, format);
+  {
+    vsprintf(buf, format, args_ptr);
+  }
+  va_end(args_ptr);
+
+  extern int __cdecl sprintfex_internal(char *buf);
+  return sprintfex_internal(buf);
+}
+
+//----- (00452B95) --------------------------------------------------------
+void __cdecl SetSomeItemsNames()
+	{
+	pSomeItemsNames[0] = pGlobalTXT_LocalizationStrings[568];
+	pSomeItemsNames[1] = pGlobalTXT_LocalizationStrings[271];
+	pSomeItemsNames[2] = pGlobalTXT_LocalizationStrings[272];
+	pSomeItemsNames[3] = pGlobalTXT_LocalizationStrings[273];
+	pSomeItemsNames[4] = pGlobalTXT_LocalizationStrings[274];
+	pSomeItemsNames[5] = pGlobalTXT_LocalizationStrings[275];
+	pSomeItemsNames[6] = pGlobalTXT_LocalizationStrings[276];
+	pSomeItemsNames[7] = pGlobalTXT_LocalizationStrings[277];
+	pSomeItemsNames[8] = pGlobalTXT_LocalizationStrings[278];
+	pSomeItemsNames[9] = pGlobalTXT_LocalizationStrings[279];
+	pSomeItemsNames[10] = pGlobalTXT_LocalizationStrings[280];
+	pSomeItemsNames[11] = pGlobalTXT_LocalizationStrings[281];
+	pSomeItemsNames[12] = pGlobalTXT_LocalizationStrings[282];
+	pSomeItemsNames[13] = pGlobalTXT_LocalizationStrings[143];
+	memset(&stru_5E4C50, 0, sizeof(stru_5E4C50));
+	}
+
+//----- (00452C30) --------------------------------------------------------
+char *RemoveQuotes(char *pStr)
+	{
+	if ( *pStr == '"' )
+		{
+		pStr[strlen(pStr) - 1] = 0;
+		return pStr + 1;
+		}
+	return pStr;
+	}
+
+//----- (00452C49) --------------------------------------------------------
+void InitializeGameText()
+	{
+	//char *v0; // ebx@1
+	/*char *v1; // eax@3
+	int v2; // ebp@4
+	char v3; // dl@5
+	char *v4; // ecx@5
+	int v5; // esi@9
+	//char **v6; // [sp+10h] [bp-8h]@3
+	signed int v7; // [sp+14h] [bp-4h]@4*/
+	char *test_string; // eax@3
+	char *tmp_pos; // eax@3
+	int step; // ebp@4
+	unsigned char c; // dl@5
+	int temp_str_len; // ecx@5
+	bool string_end; // [sp+14h] [bp-4h]@4
+	//v0 = 0;
+	if (pGlobalTXT_Raw)
+		pAllocator->FreeChunk(pGlobalTXT_Raw);
+	pGlobalTXT_Raw = (char *)pEvents_LOD->LoadRaw("global.txt", 0);
+
+/*	strtok(pGlobalTXT_Raw, "\r");
+	strtok(nullptr, "\r");
+	v1 = strtok(nullptr, "\r") + 1;
+
+	for (uint i = 0; i < 677; ++i)
+		{
+		char *p = v1;
+		while (*++p != '\t' && *p);
+
+		pGlobalTXT_LocalizationStrings[i] = RemoveQuotes(p + 1);
+
+		v1 = strtok(nullptr, "\r") + 1;
+		}*/
+	strtok((char *)pGlobalTXT_Raw, "\r");	   //Carriage Return 0D 13
+	strtok(NULL, "\r");					   	  //Carriage Return 0D 13
+	test_string = strtok(NULL, "\r") + 1;	 //Carriage Return 0D 13
+
+	for (int i = 0; i < MAX_LOC_STRINGS; ++i)
+		{
+		step = 0;
+		string_end = false;
+		do
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			if (c!= '\t' )	// Horizontal tab 09 
+				{
+				do
+					{
+					if ( !c )
+						break; 
+					c = *(test_string+temp_str_len+1);
+					temp_str_len++;    
+					}
+				while ( c != '\t' );	// Horizontal tab 09 
+				}
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				string_end = true;
+			*tmp_pos = 0;
+			if ( temp_str_len == 0)
+				string_end = true;
+			else
+				{
+				if ( step == 1 )
+					pGlobalTXT_LocalizationStrings[i] = RemoveQuotes(test_string);
+				}
+			++step;
+			test_string=tmp_pos+1;
+			}
+		while ( step <= 2 && !string_end);  
+
+		test_string = strtok(NULL, "\r") + 1;  //Carriage Return 0D 13
+		}	
+
+	aMonthNames[0] = pGlobalTXT_LocalizationStrings[415];  aMonthNames[1] = pGlobalTXT_LocalizationStrings[416];
+	aMonthNames[2] = pGlobalTXT_LocalizationStrings[417];  aMonthNames[3] = pGlobalTXT_LocalizationStrings[418];
+	aMonthNames[4] = pGlobalTXT_LocalizationStrings[419];  aMonthNames[5] = pGlobalTXT_LocalizationStrings[420];
+	aMonthNames[6] = pGlobalTXT_LocalizationStrings[421];  aMonthNames[7] = pGlobalTXT_LocalizationStrings[422];
+	aMonthNames[8] = pGlobalTXT_LocalizationStrings[423];  aMonthNames[9] = pGlobalTXT_LocalizationStrings[424];
+	aMonthNames[10] = pGlobalTXT_LocalizationStrings[425]; aMonthNames[11] = pGlobalTXT_LocalizationStrings[426];
+
+	aDayNames[0] = pGlobalTXT_LocalizationStrings[145];  aDayNames[1] = pGlobalTXT_LocalizationStrings[230];
+	aDayNames[2] = pGlobalTXT_LocalizationStrings[243];  aDayNames[3] = pGlobalTXT_LocalizationStrings[227];
+	aDayNames[4] = pGlobalTXT_LocalizationStrings[91];   aDayNames[5] = pGlobalTXT_LocalizationStrings[188];
+	aDayNames[6] = pGlobalTXT_LocalizationStrings[222];
+
+	
+	pClassNames [0] = pGlobalTXT_LocalizationStrings[LOCSTR_KNIGHT];
+	pClassNames [1] = pGlobalTXT_LocalizationStrings[LOCSTR_CAVALIER];
+	pClassNames [2] = pGlobalTXT_LocalizationStrings[LOCSTR_CHAMPION];
+	pClassNames [3] = pGlobalTXT_LocalizationStrings[LOCSTR_BLK_KNIGHT];
+
+	pClassNames [4] = pGlobalTXT_LocalizationStrings[LOCSTR_THIEF];
+	pClassNames [5] = pGlobalTXT_LocalizationStrings[LOCSTR_ROGUE];
+	pClassNames [6] = pGlobalTXT_LocalizationStrings[LOCSTR_SPY];
+	pClassNames [7] = pGlobalTXT_LocalizationStrings[LOCSTR_ASSASIN];
+
+	pClassNames [8] = pGlobalTXT_LocalizationStrings[LOCSTR_MONK];
+	pClassNames [9] = pGlobalTXT_LocalizationStrings[26];
+	pClassNames [10] = pGlobalTXT_LocalizationStrings[432];
+	pClassNames [11] = pGlobalTXT_LocalizationStrings[27];
+
+	pClassNames [12] = pGlobalTXT_LocalizationStrings[LOCSTR_PALADIN];
+	pClassNames [13] = pGlobalTXT_LocalizationStrings[263];
+	pClassNames [14] = pGlobalTXT_LocalizationStrings[264];
+	pClassNames [15] = pGlobalTXT_LocalizationStrings[28];
+
+	pClassNames [16] = pGlobalTXT_LocalizationStrings[LOCSTR_ARCHER];
+	pClassNames [17] = pGlobalTXT_LocalizationStrings[267];
+	pClassNames [18] = pGlobalTXT_LocalizationStrings[119];
+	pClassNames [19] = pGlobalTXT_LocalizationStrings[124];
+
+	pClassNames [20] = pGlobalTXT_LocalizationStrings[LOCSTR_RANGER];
+	pClassNames [21] = pGlobalTXT_LocalizationStrings[370];
+	pClassNames [22] = pGlobalTXT_LocalizationStrings[33];
+	pClassNames [23] = pGlobalTXT_LocalizationStrings[40];
+
+	pClassNames [24] = pGlobalTXT_LocalizationStrings[LOCSTR_CLERIC];
+	pClassNames [25] = pGlobalTXT_LocalizationStrings[257];
+	pClassNames [26] = pGlobalTXT_LocalizationStrings[44];
+	pClassNames [27] = pGlobalTXT_LocalizationStrings[46];
+
+	pClassNames [28] = pGlobalTXT_LocalizationStrings[LOCSTR_DRUID];
+	pClassNames [29] = pGlobalTXT_LocalizationStrings[269];
+	pClassNames [30] = pGlobalTXT_LocalizationStrings[270];
+	pClassNames [31] = pGlobalTXT_LocalizationStrings[48];
+
+	pClassNames [32] = pGlobalTXT_LocalizationStrings[LOCSTR_SORCERER];
+	pClassNames [33] = pGlobalTXT_LocalizationStrings[260];
+	pClassNames [34] = pGlobalTXT_LocalizationStrings[261];
+	pClassNames [35] = pGlobalTXT_LocalizationStrings[49];
+
+	aCharacterConditionNames[0] = pGlobalTXT_LocalizationStrings[52];
+	aCharacterConditionNames[1] = pGlobalTXT_LocalizationStrings[241];
+	aCharacterConditionNames[2] = pGlobalTXT_LocalizationStrings[14];
+	aCharacterConditionNames[3] = pGlobalTXT_LocalizationStrings[4];
+	aCharacterConditionNames[4] = pGlobalTXT_LocalizationStrings[69];
+	aCharacterConditionNames[5] = pGlobalTXT_LocalizationStrings[117];
+	aCharacterConditionNames[6] = pGlobalTXT_LocalizationStrings[166];
+	aCharacterConditionNames[7] = pGlobalTXT_LocalizationStrings[65];
+	aCharacterConditionNames[8] = pGlobalTXT_LocalizationStrings[166];
+	aCharacterConditionNames[9] = pGlobalTXT_LocalizationStrings[65];
+	aCharacterConditionNames[10] = pGlobalTXT_LocalizationStrings[166];
+	aCharacterConditionNames[11] = pGlobalTXT_LocalizationStrings[65];
+	aCharacterConditionNames[12] = pGlobalTXT_LocalizationStrings[162];
+	aCharacterConditionNames[13] = pGlobalTXT_LocalizationStrings[231];
+	aCharacterConditionNames[14] = pGlobalTXT_LocalizationStrings[58];
+	aCharacterConditionNames[15] = pGlobalTXT_LocalizationStrings[220];
+	aCharacterConditionNames[16] = pGlobalTXT_LocalizationStrings[76];
+	aCharacterConditionNames[17] = pGlobalTXT_LocalizationStrings[601];
+	aCharacterConditionNames[18] = pGlobalTXT_LocalizationStrings[98];
+
+	pSkillNames[0] = pGlobalTXT_LocalizationStrings[271];
+	pSkillNames[1] = pGlobalTXT_LocalizationStrings[272];
+	pSkillNames[2] = pGlobalTXT_LocalizationStrings[273];
+	pSkillNames[3] = pGlobalTXT_LocalizationStrings[274];
+	pSkillNames[4] = pGlobalTXT_LocalizationStrings[275];
+	pSkillNames[5] = pGlobalTXT_LocalizationStrings[276];
+	pSkillNames[6] = pGlobalTXT_LocalizationStrings[277];
+	pSkillNames[7] = pGlobalTXT_LocalizationStrings[278];
+	pSkillNames[8] = pGlobalTXT_LocalizationStrings[279];
+	pSkillNames[9] = pGlobalTXT_LocalizationStrings[280];
+	pSkillNames[10] = pGlobalTXT_LocalizationStrings[281];
+	pSkillNames[11] = pGlobalTXT_LocalizationStrings[282];
+	pSkillNames[12] = pGlobalTXT_LocalizationStrings[283];
+	pSkillNames[13] = pGlobalTXT_LocalizationStrings[284];
+	pSkillNames[14] = pGlobalTXT_LocalizationStrings[285];
+	pSkillNames[15] = pGlobalTXT_LocalizationStrings[286];
+	pSkillNames[16] = pGlobalTXT_LocalizationStrings[289];
+	pSkillNames[17] = pGlobalTXT_LocalizationStrings[290];
+	pSkillNames[18] = pGlobalTXT_LocalizationStrings[291];
+	pSkillNames[19] = pGlobalTXT_LocalizationStrings[287];
+	pSkillNames[20] = pGlobalTXT_LocalizationStrings[288];
+	pSkillNames[21] = pGlobalTXT_LocalizationStrings[292];
+	pSkillNames[22] = pGlobalTXT_LocalizationStrings[293];
+	pSkillNames[23] = pGlobalTXT_LocalizationStrings[294];
+	pSkillNames[24] = pGlobalTXT_LocalizationStrings[295];
+	pSkillNames[25] = pGlobalTXT_LocalizationStrings[296];
+	pSkillNames[26] = pGlobalTXT_LocalizationStrings[297];
+	pSkillNames[27] = pGlobalTXT_LocalizationStrings[298];
+	pSkillNames[28] = pGlobalTXT_LocalizationStrings[299];
+	pSkillNames[29] = pGlobalTXT_LocalizationStrings[300];
+	pSkillNames[30] = pGlobalTXT_LocalizationStrings[50];
+	pSkillNames[31] = pGlobalTXT_LocalizationStrings[77];
+	pSkillNames[32] = pGlobalTXT_LocalizationStrings[88];
+	pSkillNames[33] = pGlobalTXT_LocalizationStrings[89];
+	pSkillNames[34] = pGlobalTXT_LocalizationStrings[90];
+	pSkillNames[35] = pGlobalTXT_LocalizationStrings[95];
+	pSkillNames[36] = pGlobalTXT_LocalizationStrings[301];
+	pSkillNames[37] = pGlobalTXT_LocalizationStrings[153];
+
+	aSpellSchoolNames[0] = pGlobalTXT_LocalizationStrings[87];
+	aSpellSchoolNames[1] = pGlobalTXT_LocalizationStrings[6];
+	aSpellSchoolNames[2] = pGlobalTXT_LocalizationStrings[240];
+	aSpellSchoolNames[3] = pGlobalTXT_LocalizationStrings[70];
+	aSpellSchoolNames[4] = pGlobalTXT_LocalizationStrings[214];
+	aSpellSchoolNames[5] = pGlobalTXT_LocalizationStrings[142];
+	aSpellSchoolNames[6] = pGlobalTXT_LocalizationStrings[29];
+	aSpellSchoolNames[7] = pGlobalTXT_LocalizationStrings[133];
+	aSpellSchoolNames[8] = pGlobalTXT_LocalizationStrings[54];
+
+	aAttributeNames[0] = pGlobalTXT_LocalizationStrings[144];
+	aAttributeNames[1] = pGlobalTXT_LocalizationStrings[116];
+	aAttributeNames[2] = pGlobalTXT_LocalizationStrings[163];
+	aAttributeNames[3] = pGlobalTXT_LocalizationStrings[75];
+	aAttributeNames[4] = pGlobalTXT_LocalizationStrings[1];
+	aAttributeNames[5] = pGlobalTXT_LocalizationStrings[211];
+	aAttributeNames[6] = pGlobalTXT_LocalizationStrings[136];
+
+	aAMPMNames[0] = pGlobalTXT_LocalizationStrings[472];
+	aAMPMNames[1] = pGlobalTXT_LocalizationStrings[473];
+
+	aNPCProfessionNames[0] = pGlobalTXT_LocalizationStrings[153];
+	aNPCProfessionNames[1] = pGlobalTXT_LocalizationStrings[308];
+	aNPCProfessionNames[2] = pGlobalTXT_LocalizationStrings[309];
+	aNPCProfessionNames[3] = pGlobalTXT_LocalizationStrings[7];
+	aNPCProfessionNames[4] = pGlobalTXT_LocalizationStrings[306];
+	aNPCProfessionNames[5] = pGlobalTXT_LocalizationStrings[310];
+	aNPCProfessionNames[6] = pGlobalTXT_LocalizationStrings[311];
+	aNPCProfessionNames[7] = pGlobalTXT_LocalizationStrings[312];
+	aNPCProfessionNames[8] = pGlobalTXT_LocalizationStrings[313];
+	aNPCProfessionNames[9] = pGlobalTXT_LocalizationStrings[314];
+	aNPCProfessionNames[10] = pGlobalTXT_LocalizationStrings[105];
+	aNPCProfessionNames[11] = pGlobalTXT_LocalizationStrings[315];
+	aNPCProfessionNames[12] = pGlobalTXT_LocalizationStrings[316];
+	aNPCProfessionNames[13] = pGlobalTXT_LocalizationStrings[317];
+	aNPCProfessionNames[14] = pGlobalTXT_LocalizationStrings[115];
+	aNPCProfessionNames[15] = pGlobalTXT_LocalizationStrings[318];
+	aNPCProfessionNames[16] = pGlobalTXT_LocalizationStrings[319];
+	aNPCProfessionNames[17] = pGlobalTXT_LocalizationStrings[320];
+	aNPCProfessionNames[18] = pGlobalTXT_LocalizationStrings[321];
+	aNPCProfessionNames[19] = pGlobalTXT_LocalizationStrings[322];
+	aNPCProfessionNames[20] = pGlobalTXT_LocalizationStrings[323];
+	aNPCProfessionNames[21] = pGlobalTXT_LocalizationStrings[293];
+	aNPCProfessionNames[22] = pGlobalTXT_LocalizationStrings[324];
+	aNPCProfessionNames[23] = pGlobalTXT_LocalizationStrings[498];
+	aNPCProfessionNames[24] = pGlobalTXT_LocalizationStrings[525];
+	aNPCProfessionNames[25] = pGlobalTXT_LocalizationStrings[327];
+	aNPCProfessionNames[26] = pGlobalTXT_LocalizationStrings[328];
+	aNPCProfessionNames[27] = pGlobalTXT_LocalizationStrings[329];
+	aNPCProfessionNames[28] = pGlobalTXT_LocalizationStrings[330];
+	aNPCProfessionNames[29] = pGlobalTXT_LocalizationStrings[331];
+	aNPCProfessionNames[20] = pGlobalTXT_LocalizationStrings[332];
+	aNPCProfessionNames[31] = pGlobalTXT_LocalizationStrings[333];
+	aNPCProfessionNames[32] = pGlobalTXT_LocalizationStrings[334];
+	aNPCProfessionNames[33] = pGlobalTXT_LocalizationStrings[335];
+	aNPCProfessionNames[34] = pGlobalTXT_LocalizationStrings[336];
+	aNPCProfessionNames[35] = pGlobalTXT_LocalizationStrings[337];
+	aNPCProfessionNames[36] = pGlobalTXT_LocalizationStrings[338];
+	aNPCProfessionNames[37] = pGlobalTXT_LocalizationStrings[339];
+	aNPCProfessionNames[38] = pGlobalTXT_LocalizationStrings[340];
+	aNPCProfessionNames[39] = pGlobalTXT_LocalizationStrings[341];
+	aNPCProfessionNames[40] = pGlobalTXT_LocalizationStrings[342];
+	aNPCProfessionNames[41] = pGlobalTXT_LocalizationStrings[343];
+	aNPCProfessionNames[42] = pGlobalTXT_LocalizationStrings[596];
+	aNPCProfessionNames[43] = pGlobalTXT_LocalizationStrings[345];
+	aNPCProfessionNames[44] = pGlobalTXT_LocalizationStrings[346];
+	aNPCProfessionNames[45] = pGlobalTXT_LocalizationStrings[347];
+	aNPCProfessionNames[46] = pGlobalTXT_LocalizationStrings[348];
+	aNPCProfessionNames[47] = pGlobalTXT_LocalizationStrings[349];  
+	aNPCProfessionNames[48] = pGlobalTXT_LocalizationStrings[350];
+	aNPCProfessionNames[49] = pGlobalTXT_LocalizationStrings[597];
+	aNPCProfessionNames[50] = pGlobalTXT_LocalizationStrings[352];
+	aNPCProfessionNames[51] = pGlobalTXT_LocalizationStrings[353];
+	aNPCProfessionNames[52] = pGlobalTXT_LocalizationStrings[598];
+	aNPCProfessionNames[53] = pGlobalTXT_LocalizationStrings[344];
+	aNPCProfessionNames[54] = pGlobalTXT_LocalizationStrings[26];
+	aNPCProfessionNames[55] = pGlobalTXT_LocalizationStrings[599];
+	aNPCProfessionNames[56] = pGlobalTXT_LocalizationStrings[21];
+	aNPCProfessionNames[57] = pGlobalTXT_LocalizationStrings[600];
+	aNPCProfessionNames[58] = pGlobalTXT_LocalizationStrings[370];
+
+	aMoonPhaseNames[0] = pGlobalTXT_LocalizationStrings[150];
+	aMoonPhaseNames[1] = pGlobalTXT_LocalizationStrings[171];
+	aMoonPhaseNames[2] = pGlobalTXT_LocalizationStrings[102];
+	aMoonPhaseNames[3] = pGlobalTXT_LocalizationStrings[169];
+	aMoonPhaseNames[4] = pGlobalTXT_LocalizationStrings[92];
+
+	aSpellNames[0] = pGlobalTXT_LocalizationStrings[202];
+	aSpellNames[1] = pGlobalTXT_LocalizationStrings[204];
+	aSpellNames[2] = pGlobalTXT_LocalizationStrings[219];
+	aSpellNames[3] = pGlobalTXT_LocalizationStrings[215];
+	aSpellNames[4] = pGlobalTXT_LocalizationStrings[208];
+	aSpellNames[5] = pGlobalTXT_LocalizationStrings[454];
+	aSpellNames[6] = pGlobalTXT_LocalizationStrings[24];
+	aSpellNames[7] = pGlobalTXT_LocalizationStrings[455];
+	aSpellNames[8] = pGlobalTXT_LocalizationStrings[441];
+	aSpellNames[9] = pGlobalTXT_LocalizationStrings[440];
+	aSpellNames[10] = pGlobalTXT_LocalizationStrings[218];
+	aSpellNames[11] = pGlobalTXT_LocalizationStrings[217];
+	aSpellNames[12] = pGlobalTXT_LocalizationStrings[213];
+	aSpellNames[13] = pGlobalTXT_LocalizationStrings[462];
+	aSpellNames[14] = pGlobalTXT_LocalizationStrings[279];
+	aSpellNames[15] = pGlobalTXT_LocalizationStrings[442];
+	aSpellNames[16] = pGlobalTXT_LocalizationStrings[452];
+	aSpellNames[17] = pGlobalTXT_LocalizationStrings[194];
+	aSpellNames[18] = pGlobalTXT_LocalizationStrings[456];
+	aSpellNames[19] = pGlobalTXT_LocalizationStrings[453];
+	aSpellNames[20] = pGlobalTXT_LocalizationStrings[202];
+	aSpellNames[21] = pGlobalTXT_LocalizationStrings[443];
+	aSpellNames[22] = pGlobalTXT_LocalizationStrings[204];
+	aSpellNames[23] = pGlobalTXT_LocalizationStrings[208];
+	aSpellNames[24] = pGlobalTXT_LocalizationStrings[221];
+	aSpellNames[25] = pGlobalTXT_LocalizationStrings[24];
+	aSpellNames[26] = pGlobalTXT_LocalizationStrings[228];
+	aSpellNames[27] = pGlobalTXT_LocalizationStrings[441];
+	aSpellNames[28] = pGlobalTXT_LocalizationStrings[440];
+	aSpellNames[29] = pGlobalTXT_LocalizationStrings[213];
+	aSpellNames[30] = pGlobalTXT_LocalizationStrings[229];
+	aSpellNames[31] = pGlobalTXT_LocalizationStrings[233];
+	aSpellNames[32] = pGlobalTXT_LocalizationStrings[234];
+	aSpellNames[33] = pGlobalTXT_LocalizationStrings[279];
+	aSpellNames[34] = pGlobalTXT_LocalizationStrings[442];
+	aSpellNames[35] = pGlobalTXT_LocalizationStrings[235];
+	aSpellNames[36] = pGlobalTXT_LocalizationStrings[246];
+	aSpellNames[37] = pGlobalTXT_LocalizationStrings[247];
+	aSpellNames[38] = pGlobalTXT_LocalizationStrings[248];
+	aSpellNames[39] = pGlobalTXT_LocalizationStrings[674];
+	aSpellNames[40] = pGlobalTXT_LocalizationStrings[249];
+	aSpellNames[41] = pGlobalTXT_LocalizationStrings[258];
+	aSpellNames[42] = pGlobalTXT_LocalizationStrings[194];
+	aSpellNames[43] = pGlobalTXT_LocalizationStrings[657];
+	}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/texts.h	Mon Feb 18 09:44:59 2013 +0600
@@ -0,0 +1,843 @@
+#pragma once
+
+
+
+int __cdecl sprintfex(char *buf, const char *format, ...);
+
+
+void __cdecl SetSomeItemsNames();
+char *RemoveQuotes(char *Str);
+void __cdecl InitializeGameText();
+
+
+enum GLOBAL_LOCALIZ_INDEX
+	{
+
+	LOCSTR_AC     =                             0,		//"AC"	
+	LOCSTR_ACCURACY 	=						1,		//"Accuracy"	
+	LOCSTR_BLK_KNIGHT =							2,		//"Black Knight"
+	LOCSTR_SPY  	=						    3,		// "Spy"
+
+	LOCSTR_TOWN_PORTAL		   =                 10, // "Town Portal"	
+
+	LOCSTR_ASSASIN             =        		13,	// "Assassin"
+
+	LOCSTR_AUTOSAVE            =        		16,	// "Autosave"
+
+	LOCSTR_ATTACK             =         		18, // "Attack"	
+	LOCSTR_AVAILABLE           =                19, //"Available"
+
+	LOCSTR_MONK                 =       		21, //"Monk"	
+
+	LOCSTR_AVARDS_FOR            =      		23, //"Awards for"
+
+
+	LOCSTR_RANGER		           =             31, //"Ranger"
+
+	LOCSTR_CANCEL		            =            34, //"Cancel"	
+
+
+	LOCSTR_SELECT_TGT               =   		39,	 ///"Select Target"
+
+	LOCSTR_CLASS                     =  		41,	// "Class"
+
+	LOCSTR_CONDITION                  = 		47,	//"Condition"
+
+	LOCSTR_CREATE_PARTY                =  		51,   //"C R E A T E   P A R T Y"	
+
+	LOCSTR_DAWN                       =         55, //"Dawn"	
+	LOCSTR_DAY                         = 		56,	//"Day"	
+	LOCSTR_DAYS                        =		57,	/// "Days"	
+
+	LOCSTR_PRESS_ESCAPE                =		61,	// "Press Escape"	
+
+	LOCSTR_TROUBLE_LOAD                 =		63,//"Might and Magic VII is having trouble loading files. 
+	// Please re-install to fix this problem. Note: Re-installing will not destroy your save games."	
+	LOCSTR_DETAIL_TOGGLE              = 		64,	 //"Detail Toggle"	
+
+	LOCSTR_DMG                   =   		    66,	 /// "Dmg"	
+
+	LOCSTR_EMPTY                  =     		72, // "Empty"	
+
+	LOCSTR_EXIT                    =    		79,	// "Exit"	
+	LOCSTR_EXIT_BLDNG               =   		80,   // "Exit Building"
+
+	LOCSTR_EXPIRIENCE		          =          83, //"Experience"	
+
+	LOCSTR_GRAND		               =         96,	// "Grand"
+
+	LOCSTR_HP                          =		107,	// "HP"	
+	LOCSTR_HIT_POINTS		             =       108,	// "Hit Points"	
+	LOCSTR_HOUR                         =		109,	//"Hour"	
+	LOCSTR_HOURS		                  =      110, //"Hours"	
+
+	LOCSTR_ROGUE                 =          	114,	 //"Rogue"
+
+	LOCSTR_LEVEL                =        		131,   // "Level"	
+
+	LOCSTR_LOADING               =      		135,  //"Loading"	
+
+	LOCSTR_MIGHT		           =             144,	 //"Might"
+
+	LOCSTR_NAME		            =            149,	// "Name"	
+
+	LOCSTR_YOU_TO_TRAIN             =      		147, // "You are eligible to train to %u."	
+
+	LOCSTR_STAY_IN_AREA		      =          156,  //"Stay in this Area"	
+	LOCSTR_3DO_COPYRHT			=				157,	  // "" 1999 The 3DO Company.
+
+	LOCSTR_PLEASE_WAIT          =       		165,	// "Please Wait"
+
+	LOCSTR_REPUTATION            =      		180,	 //"Reputation"
+
+	LOCSTR_REST_HEAL_8            =             183, //"Rest & Heal 8 Hours"	
+
+	LOCSTR_TIME_ERATHIA            =    		186, // "Time in Erathia"	
+
+	LOCSTR_SAVING                   =   		190,  // "Saving"	
+
+	LOCSTR_SKILL_POINTS		      =          207, /// "Skill Points"	
+
+	LOCSTR_KNIGHT                     = 		253,  //"Knight"	
+	LOCSTR_CAVALIER		            =        254,  //"Cavalier"	
+	LOCSTR_CHAMPION		             =       255,  //"Champion"	
+	LOCSTR_CLERIC		                  =      256,  //"Cleric"	
+	LOCSTR_PRIEST		                   =     257,  //"Priest"	
+
+	LOCSTR_SORCERER		                =    259,  // "Sorcerer"	
+
+	LOCSTR_PALADIN                   =  		262, // "Paladin"
+
+	LOCSTR_ARCHER		               =         265,   /// "Archer"
+
+	LOCSTR_DRUID		            =            268, // "Druid"	
+
+	LOCSTR_THIEF                    =   		307, //"Thief"
+
+	LOCSTR_SET_BEACON                =  		375, // "Set Beacon"
+
+	LOCSTR_HATED                      =  		379,// "Hated"
+
+	LOCSTR_UNFRENDLY		            =        392,	 //"Unfriendly"	
+
+	LOCSTR_NEITRAL                     =		399,  // "Neutral"	
+
+	LOCSTR_FRENDLY                     =		402, // "Friendly"	
+
+	LOCSTR_D_DAYS_TO_S                  =		404,   //"%d days to %s"	
+	LOCSTR_TRAVEL_COST                   =      405,    //"Travel Cost %d gold"	
+
+	LOCSTR_ENTER_S		                   =     411, // "Enter %s"	
+
+	LOCSTR_IS_IN_NO_COND		            =    427,	// "%s is in no condition to %s"	
+
+	LOCSTR_S_THE_S                          =   429,    //"%s the %s"
+
+	LOCSTR_NORMAL               =       		431,	//"Normal"
+	LOCSTR_MASTER		          =              432,	//"Master"	
+	LOCSTR_EXPERT		          =              433,	//"Expert"
+	LOCSTR_LIKED		          =              434, //"Liked"	
+
+	LOCSTR_ACTIVE_SPELL           =     		450,	// "Active Spells: %s"	
+
+	LOCSTR_READING                 =        	505, ///"Reading..."	
+
+	LOCSTR_NOTHING_HERE             =    		521, // "Nothing here"	
+
+	LOCSTR_SP_COST                   =   		522, //"SP Cost"
+	LOCSTR_RECALL_BEACON              = 		523, // "Recall Beacon"	
+
+	LOCSTR_TIME                        =		526,	//"Time"	
+
+	LOCSTR_NEED_MORE_EXP               =		538, //"You need %d more experience to train to level %d"	
+
+	LOCSTR_IDENT_ITEM                  =		541, // "Identify Items"
+
+	LOCSTR_DUSK                         =		566,   //"Dusk"	
+	LOCSTR_NIGHT                        =       567,  // "Night"	
+
+	LOCSTR_NO_SAVING                   	=	583,	//"No saving in the Arena"	
+
+	LOCSTR_AUTOSAVE_MM7                    =	613, // "AutoSave.MM7"
+
+	LOCSTR_BONUS                       	=	623, //"Bonus"	
+
+	LOCSTR_GAME_SAVED                  	=	656,	// "Game Saved!"
+
+	MAX_LOC_STRINGS =677
+
+	};
+
+extern  char *pGlobalTXT_LocalizationStrings[MAX_LOC_STRINGS];
+
+/*
+
++		[4]	0x04102dab "Afraid"	unsigned char *
++		[5]	0x04102db5 "Age"	unsigned char *
++		[6]	0x04102dbc "Air"	unsigned char *
++		[7]	0x04102dc3 "Alchemist"	unsigned char *
++		[8]	0x04102dd0 "Obelisk Notes"	unsigned char *
++		[9]	0x04102de1 "Congratulations!"	unsigned char *
+
++		[11]	0x04102e06 "Armor"	unsigned char *
++		[0xc]	0x04102e10 "Armor Class"	unsigned char *
+
++		[0xe]	0x04102e2d "Asleep"	unsigned char *
++		[0xf]	0x04102e38 "Assertion failed at %d in %s"	unsigned char *
+
++		[17]	0x04102e66 "Exp."	unsigned char *
+
+
++		[20]	0x04102e88 "Available Skills"	unsigned char *
+
++		[22]	0x04102ea6 "Awards"	unsigned char *
+
++		[24]	0x04102ec0 "Fire Res"	unsigned char *
++		[25]	0x04102ecd "Balance"	unsigned char *
++		[26]	0x04102ed9 "Initiate"	unsigned char *
++		[27]	0x04102ee6 "Ninja"	unsigned char *
++		[28]	0x04102ef0 "Villain"	unsigned char *
++		[29]	0x04102efc "Body"	unsigned char *
++		[30]	0x04102f05 "Bonus"	unsigned char *
+
++		[32]	0x04102f1a "Broken Item"	unsigned char *
++		[33]	0x04102f2a "Ranger Lord"	unsigned char *
++		[34]	0x04102f3a "Cancel"	unsigned char *
++		[35]	0x04102f45 "Town Portal to %s"	unsigned char *
++		[36]	0x04102f5b "%s can not be used that way"	unsigned char *
++		[37]	0x04102f7b "Total Time:"	unsigned char *
++		[38]	0x04102f8b "Cast Spell"	unsigned char *
+
++		[0x28]	0x04102fac "Bounty Hunter"	unsigned char *
+
++		[0x2a]	0x04102fc8 "Clerk"	unsigned char *
++		[0x2b]	0x04102fd2 "Cold"	unsigned char *
++		[0x2c]	0x04102fdb "Priest of Light"	unsigned char *
++		[45]	0x04102fef "Cond"	unsigned char *
++		[46]	0x04102ff8 "Priest of Dark"	unsigned char *
+
++		[48]	0x04103019 "Warlock"	unsigned char *
++		[49]	0x04103025 "Lich"	unsigned char *
++		[50]	0x0410302e "Dodging"	unsigned char *
+
++		[52]	0x04103056 "Cursed"	unsigned char *
++		[0x35]	0x04103061 "Damage"	unsigned char *
++		[0x36]	0x0410306c "Dark"	unsigned char *
+
+
+
++		[58]	0x0410308f "Dead"	unsigned char *
++		[59]	0x04103098 "Internal Error"	unsigned char *
++		[60]	0x041030ab "Deposit"	unsigned char *
+
++		[62]	0x041030c8 "Might and Magic VII requires your desktop to be in 16bit (32k or 65k) Color mode in order to operate in a window."	unsigned char *
+
+
++		[65]	0x041031e6 "Diseased"	unsigned char *
+
++		[0x43]	0x041031fb "%s does not have the skill"	unsigned char *
++		[68]	0x0410321a "Donate"	unsigned char *
++		[69]	0x04103225 "Drunk"	unsigned char *
++		[70]	0x0410322f "Earth"	unsigned char *
++		[71]	0x04103239 "Electricity"	unsigned char *
+
++		[73]	0x04103253 "Enter"	unsigned char *
++		[74]	0x0410325d "End Conversation"	unsigned char *
++		[75]	0x04103272 "Endurance"	unsigned char *
++		[0x4c]	0x04103280 "Eradicated"	unsigned char *
++		[0x4d]	0x0410328f "Unarmed"	unsigned char *
++		[0x4e]	0x0410329b "Calendar"	unsigned char *
++		[0x4f]	0x041032a8 "Exit"	unsigned char *
+
++		[81]	0x041032c3 "Exit Rest"	unsigned char *
++		[82]	0x041032d1 "Are you sure?  Click again to quit"	unsigned char *
+
++		[84]	0x04103307 "Fame"	unsigned char *
++		[85]	0x04103310 "Potion Notes"	unsigned char *
++		[86]	0x04103321 "Fill Packs to %d days for %d gold"	unsigned char *
++		[87]	0x04103347 "Fire"	unsigned char *
++		[88]	0x04103350 "Identify Monster"	unsigned char *
++		[89]	0x04103365 "Armsmaster"	unsigned char *
++		[90]	0x04103374 "Stealing"	unsigned char *
++		[91]	0x04103381 "Friday"	unsigned char *
++		[92]	0x0410338c "Full"	unsigned char *
++		[93]	0x04103395 "Game Options"	unsigned char *
++		[94]	0x041033a6 "Your score: %lu"	unsigned char *
++		[95]	0x041033ba "Alchemy"	unsigned char *
+
+
+
++		[97]	0x041033d0 "Gold"	unsigned char *
++		[98]	0x041033d9 "Good"	unsigned char *
++		[99]	0x041033e2 "Human"	unsigned char *
++		[100]	0x041033ed "Guard"	unsigned char *
++		[101]	0x041033f8 "Dwarf"	unsigned char *
++		[102]	0x04103403 "Half"	unsigned char *
++		[103]	0x0410340d "Elf"	unsigned char *
++		[104]	0x04103416 "Heal"	unsigned char *
++		[105]	0x04103420 "Healer"	unsigned char *
++		[106]	0x0410342c "Goblin"	unsigned char *
+
++		[108]	0x04103440 "Hit Points"	unsigned char *
+
++		[111]	0x04103465 "Grand"	unsigned char *
++		[112]	0x04103470 "How Much?"	unsigned char *
++		[113]	0x0410347f "Identify"	unsigned char *
+
++		[115]	0x04103498 "Instructor"	unsigned char *
++		[116]	0x041034a8 "Intellect"	unsigned char *
++		[117]	0x041034b7 "Insane"	unsigned char *
++		[118]	0x041034c3 "We hope that you've enjoyed playing Might and Magic VII as much as we did making it. We have saved this screen as MM7_WIN.PCX in your MM7 directory. You can print it out as proof of your accomplishment."	unsigned char *
++		[119]	0x04103593 "Master Archer"	unsigned char *
++		[120]	0x041035a6 "Inventory"	unsigned char *
++		[121]	0x041035b5 "Permanent"	unsigned char *
++		[122]	0x041035c4 "Join"	unsigned char *
++		[123]	0x041035ce "Miscellaneous Notes"	unsigned char *
++		[124]	0x041035e7 "Sniper"	unsigned char *
++		[125]	0x041035f3 "+2 Skill Points!"	unsigned char *
++		[126]	0x04103609 "Do you wish to leave %s?"	unsigned char *
++		[127]	0x04103627 "No Text!"	unsigned char *
++		[128]	0x04103635 "It will take %d days to travel to %s."	unsigned char *
++		[129]	0x04103660 "%s the Level %u %s"	unsigned char *
++		[130]	0x04103678 "Player"	unsigned char *
+
++		[132]	0x0410368f "Years"	unsigned char *
++		[133]	0x0410369a "Light"	unsigned char *
++		[134]	0x041036a5 "Buy Standard"	unsigned char *
+
++		[136]	0x041036c4 "Luck"	unsigned char *
++		[137]	0x041036ce "Fountain Notes"	unsigned char *
++		[138]	0x041036e2 "Magic"	unsigned char *
++		[139]	0x041036ed "Maps"	unsigned char *
++		[140]	0x041036f7 "Your packs are already full!"	unsigned char *
++		[141]	0x04103719 "Seer Notes"	unsigned char *
++		[142]	0x04103729 "Mind"	unsigned char *
++		[143]	0x04103733 "Misc"	unsigned char *
+
++		[145]	0x04103748 "Monday"	unsigned char *
++		[146]	0x04103754 "Month"	unsigned char *
+
++		[148]	0x04103785 "Months"	unsigned char *
+
++		[150]	0x0410379b "New"	unsigned char *
++		[151]	0x041037a4 "Congratulations Adventurer."	unsigned char *
++		[152]	0x041037c5 "Buy Special"	unsigned char *
++		[153]	0x041037d6 "None"	unsigned char *
++		[154]	0x041037e0 "Auto Notes"	unsigned char *
++		[155]	0x041037f0 "You don't have enough gold"	unsigned char *
+
++		[157]	0x04103827 "" 1999 The 3DO Company.  All Rights Reserved.  Might and Magic, Blood and Honor, New World Computing, 3DO, and their respective logos, are trademarks and/or service marks of The 3DO Company in the U.S. and other countries.  All other trademarks belong to their respective owners.  New World Computing is a division of The 3DO Company.""	unsigned char *
++		[158]	0x0410397d "Bootleg Bay East"	unsigned char *
++		[159]	0x04103993 "Display Inventory"	unsigned char *
++		[160]	0x041039aa "Learn Skills"	unsigned char *
++		[161]	0x041039bc "Steal"	unsigned char *
++		[162]	0x041039c7 "Paralyzed"	unsigned char *
++		[163]	0x041039d6 "Personality"	unsigned char *
++		[164]	0x041039e7 "%s hits %s for %lu damage"	unsigned char *
+
++		[166]	0x04103a17 "Poison"	unsigned char *
++		[167]	0x04103a23 "- The Might and Magic VII Development Team."	unsigned char *
++		[168]	0x04103a54 "Points"	unsigned char *
++		[169]	0x04103a60 "Three Quarter"	unsigned char *
++		[170]	0x04103a73 "QSpell"	unsigned char *
++		[171]	0x04103a7f "Quarter"	unsigned char *
++		[172]	0x04103a8c "Quick Spell"	unsigned char *
++		[173]	0x04103a9d "Quick Reference"	unsigned char *
++		[174]	0x04103ab2 "Current Quests"	unsigned char *
++		[175]	0x04103ac6 "%s inflicts %lu points killing %s"	unsigned char *
++		[176]	0x04103aed "Might and Magic VII has detected an internal error and will be forced to close.  Would you like us to autosave your game before closing?"	unsigned char *
++		[177]	0x04103b7b "Standard"	unsigned char *
++		[178]	0x04103b89 "Rent Room for %d gold"	unsigned char *
++		[179]	0x04103ba4 "Repair"	unsigned char *
+
++		[181]	0x04103bc0 "Steal %24"	unsigned char *
++		[182]	0x04103bcf "Rest"	unsigned char *
+
++		[184]	0x04103bf2 "Reinstall Necessary"	unsigned char *
++		[185]	0x04103c0b "Steal item"	unsigned char *
+
++		[187]	0x04103c30 "Stolen"	unsigned char *
++		[188]	0x04103c3c "Saturday"	unsigned char *
++		[189]	0x04103c4a "%s shoots %s for %lu points"	unsigned char *
+
++		[191]	0x04103c77 "You've been banned from this shop!"	unsigned char *
++		[192]	0x04103c9f "Scroll Up"	unsigned char *
++		[193]	0x04103cae "Scroll Down"	unsigned char *
++		[194]	0x04103cbf "Water Res"	unsigned char *
++		[195]	0x04103cce "Select the Item to Buy"	unsigned char *
++		[196]	0x04103cea "Select the Special Item to Buy"	unsigned char *
++		[197]	0x04103d0e "Select the Item to Identify"	unsigned char *
++		[198]	0x04103d2f "Select the Item to Repair"	unsigned char *
++		[199]	0x04103d4e "Select the Item to Sell"	unsigned char *
++		[200]	0x04103d6b "Sell"	unsigned char *
++		[201]	0x04103d75 "Are you sure?  Click again to start a New Game"	unsigned char *
++		[202]	0x04103da9 "Air Res"	unsigned char *
++		[203]	0x04103db6 "Shoot"	unsigned char *
++		[204]	0x04103dc1 "Body Res"	unsigned char *
++		[205]	0x04103dcf "Skills"	unsigned char *
++		[206]	0x04103ddb "Skills for"	unsigned char *
+
++		[208]	0x04103dfd "Earth Res"	unsigned char *
++		[209]	0x04103e0c "SP"	unsigned char *
++		[210]	0x04103e14 "Special"	unsigned char *
++		[211]	0x04103e21 "Speed"	unsigned char *
++		[212]	0x04103e2c "Spell Points"	unsigned char *
++		[213]	0x04103e3e "Mind Res"	unsigned char *
++		[214]	0x04103e4c "Spirit"	unsigned char *
++		[215]	0x04103e58 "Detect Life"	unsigned char *
++		[216]	0x04103e69 "Stats"	unsigned char *
++		[217]	0x04103e74 "Invisibility"	unsigned char *
++		[218]	0x04103e86 "Immolation"	unsigned char *
++		[219]	0x04103e96 "Day of the Gods"	unsigned char *
++		[220]	0x04103eab "Stoned"	unsigned char *
++		[221]	0x04103eb7 "Fate"	unsigned char *
++		[222]	0x04103ec1 "Sunday"	unsigned char *
++		[223]	0x00000000 <Bad Ptr>	unsigned char *
++		[224]	0x00000000 <Bad Ptr>	unsigned char *
++		[225]	0x04103ed9 "Grandmaster"	unsigned char *
++		[226]	0x04103eea ""Gamma controls the relative ""brightness"" of the game.  May vary depending on your monitor.""	unsigned char *
++		[227]	0x04103f4e "Thursday"	unsigned char *
++		[228]	0x04103f5c "Hammerhands"	unsigned char *
++		[229]	0x04103f6d "Pain Reflection"	unsigned char *
++		[230]	0x04103f82 "Tuesday"	unsigned char *
++		[231]	0x04103f8f "Unconscious"	unsigned char *
++		[232]	0x04103fa0 "Not Identified"	unsigned char *
++		[233]	0x04103fb4 "Preservation"	unsigned char *
++		[234]	0x04103fc6 "Regeneration"	unsigned char *
++		[235]	0x04103fd8 "Temp Accuracy"	unsigned char *
++		[236]	0x04103feb "Wait without healing"	unsigned char *
++		[237]	0x04104005 "Wait until Dawn"	unsigned char *
++		[238]	0x0410401a "Wait 5 Minutes"	unsigned char *
++		[239]	0x0410402e "Wait 1 Hour"	unsigned char *
++		[240]	0x0410403f "Water"	unsigned char *
++		[241]	0x0410404a "Weak"	unsigned char *
++		[242]	0x04104054 "Weapons"	unsigned char *
++		[243]	0x04104061 "Wednesday"	unsigned char *
++		[244]	0x04104070 "Withdraw"	unsigned char *
++		[245]	0x0410407e "Year"	unsigned char *
++		[246]	0x04104088 "Temp Endurance"	unsigned char *
++		[247]	0x0410409c "Temp Intelligence"	unsigned char *
++		[248]	0x041040b3 "Temp Luck"	unsigned char *
++		[249]	0x041040c2 "Temp Personality"	unsigned char *
++		[250]	0x041040d8 "You need %s"	unsigned char *
++		[251]	0x041040e9 "Zoom In"	unsigned char *
++		[252]	0x041040f6 "Zoom Out"	unsigned char *
+
+
++		[258]	0x04104144 "Temp Speed"	unsigned char *
+
++		[260]	0x04104162 "Wizard"	unsigned char *
++		[261]	0x0410416e "Archmage"	unsigned char *
+
++		[263]	0x04104189 "Crusader"	unsigned char *
++		[264]	0x04104197 "Hero"	unsigned char *
+
++		[266]	0x041041ad "DISCARD A CARD"	unsigned char *
++		[267]	0x041041c1 "Warrior Mage"	unsigned char *
+
++		[269]	0x041041de "Greater Druid"	unsigned char *
++		[270]	0x041041f1 "Arch Druid"	unsigned char *
++		[271]	0x04104201 "Staff"	unsigned char *
++		[272]	0x0410420c "Sword"	unsigned char *
++		[273]	0x04104217 "Dagger"	unsigned char *
++		[274]	0x04104223 "Axe"	unsigned char *
++		[275]	0x0410422c "Spear"	unsigned char *
++		[276]	0x04104237 "Bow"	unsigned char *
++		[277]	0x04104240 "Mace"	unsigned char *
++		[278]	0x0410424a "Blaster"	unsigned char *
++		[279]	0x04104257 "Shield"	unsigned char *
++		[280]	0x04104263 "Leather"	unsigned char *
++		[281]	0x04104270 "Chain"	unsigned char *
++		[282]	0x0410427b "Plate"	unsigned char *
++		[283]	0x04104286 "Fire Magic"	unsigned char *
++		[284]	0x04104296 "Air Magic"	unsigned char *
++		[285]	0x041042a5 "Water Magic"	unsigned char *
++		[286]	0x041042b6 "Earth Magic"	unsigned char *
++		[287]	0x041042c7 "Light Magic"	unsigned char *
++		[288]	0x041042d8 "Dark Magic"	unsigned char *
++		[289]	0x041042e8 "Spirit Magic"	unsigned char *
++		[290]	0x041042fa "Mind Magic"	unsigned char *
++		[291]	0x0410430a "Body Magic"	unsigned char *
++		[292]	0x0410431a "Identify Item"	unsigned char *
++		[293]	0x0410432d "Merchant"	unsigned char *
++		[294]	0x0410433b "Repair Item"	unsigned char *
++		[295]	0x0410434c "Body Building"	unsigned char *
++		[296]	0x0410435f "Meditation"	unsigned char *
++		[297]	0x0410436f "Perception"	unsigned char *
++		[298]	0x0410437f "Diplomacy"	unsigned char *
++		[299]	0x0410438e "Thievery"	unsigned char *
++		[300]	0x0410439c "Disarm Trap"	unsigned char *
++		[301]	0x041043ad "Learning"	unsigned char *
++		[302]	0x041043bb "%s stole %d gold!"	unsigned char *
++		[303]	0x041043d2 "Noble"	unsigned char *
++		[304]	0x041043dd "Official"	unsigned char *
++		[305]	0x041043eb "Peasant"	unsigned char *
++		[306]	0x041043f8 "Scholar"	unsigned char *
+
++		[308]	0x04104410 "Smith"	unsigned char *
++		[309]	0x0410441b "Armorer"	unsigned char *
++		[310]	0x04104428 "Guide"	unsigned char *
++		[311]	0x04104433 "Tracker"	unsigned char *
++		[312]	0x04104440 "Pathfinder"	unsigned char *
++		[313]	0x04104450 "Sailor"	unsigned char *
++		[314]	0x0410445c "Navigator"	unsigned char *
++		[315]	0x0410446b "Expert Healer"	unsigned char *
++		[316]	0x0410447e "Master Healer"	unsigned char *
++		[317]	0x04104491 "Teacher"	unsigned char *
++		[318]	0x0410449e "Arms Master"	unsigned char *
++		[319]	0x041044af "Weapons Master"	unsigned char *
++		[320]	0x041044c3 "Apprentice"	unsigned char *
++		[321]	0x041044d3 "Mystic"	unsigned char *
++		[322]	0x041044df "Spell Master"	unsigned char *
++		[323]	0x041044f1 "Trader"	unsigned char *
++		[324]	0x041044fd "Scout"	unsigned char *
++		[325]	0x04104508 "Counselor"	unsigned char *
++		[326]	0x04104517 "Barrister"	unsigned char *
++		[327]	0x04104526 "Tinker"	unsigned char *
++		[328]	0x04104532 "Locksmith"	unsigned char *
++		[329]	0x04104541 "Fool"	unsigned char *
++		[330]	0x0410454b "Chimney Sweep"	unsigned char *
++		[331]	0x0410455e "Porter"	unsigned char *
++		[332]	0x0410456a "Quarter Master"	unsigned char *
++		[333]	0x0410457e "Factor"	unsigned char *
++		[334]	0x0410458a "Banker"	unsigned char *
++		[335]	0x04104596 "Cook"	unsigned char *
++		[336]	0x041045a0 "Chef"	unsigned char *
++		[337]	0x041045aa "Horseman"	unsigned char *
++		[338]	0x041045b8 "Bard"	unsigned char *
++		[339]	0x041045c2 "Enchanter"	unsigned char *
++		[340]	0x041045d1 "Cartographer"	unsigned char *
++		[341]	0x041045e3 "Wind Master"	unsigned char *
++		[342]	0x041045f4 "Water Master"	unsigned char *
++		[343]	0x04104606 "Gate Master"	unsigned char *
++		[344]	0x04104617 "Acolyte"	unsigned char *
++		[345]	0x04104624 "Piper"	unsigned char *
++		[346]	0x0410462f "Explorer"	unsigned char *
++		[347]	0x0410463d "Pirate"	unsigned char *
++		[348]	0x04104649 "Squire"	unsigned char *
++		[349]	0x04104655 "Psychic"	unsigned char *
++		[350]	0x04104662 "Gypsy"	unsigned char *
++		[351]	0x0410466d "Negotiator"	unsigned char *
++		[352]	0x0410467d "Duper"	unsigned char *
++		[353]	0x04104688 "Burglar"	unsigned char *
++		[354]	0x04104695 "Serf"	unsigned char *
++		[355]	0x0410469f "Tailor"	unsigned char *
++		[356]	0x041046ab "Laborer"	unsigned char *
++		[357]	0x041046b8 "Farmer"	unsigned char *
++		[358]	0x041046c4 "Cooper"	unsigned char *
++		[359]	0x041046d0 "Potter"	unsigned char *
++		[360]	0x041046dc "Weaver"	unsigned char *
++		[361]	0x041046e8 "Cobbler"	unsigned char *
++		[362]	0x041046f5 "Ditch Digger"	unsigned char *
++		[363]	0x04104707 "Miller"	unsigned char *
++		[364]	0x04104713 "Carpenter"	unsigned char *
++		[365]	0x04104722 "Stone Cutter"	unsigned char *
++		[366]	0x04104734 "Jester"	unsigned char *
++		[367]	0x04104740 "Trapper"	unsigned char *
++		[368]	0x0410474d "Beggar"	unsigned char *
++		[369]	0x04104759 "Rustler"	unsigned char *
++		[370]	0x04104766 "Hunter"	unsigned char *
++		[371]	0x04104772 "Scribe"	unsigned char *
++		[372]	0x0410477e "Missionary"	unsigned char *
++		[373]	0x0410478e "Follower of Baa"	unsigned char *
++		[374]	0x041047a3 "Gambler"	unsigned char *
+
++		[376]	0x041047c0 "%s was caught stealing!"	unsigned char *
++		[377]	0x041047dd "%s failed to steal anything!"	unsigned char *
++		[378]	0x041047ff ""%s %d, %d""	unsigned char *
+
++		[380]	0x0410481b "You already know the %s spell"	unsigned char *
++		[381]	0x0410483e "You don't have the skill to learn %s"	unsigned char *
++		[382]	0x04104868 "That player is %s"	unsigned char *
++		[383]	0x0410487f "his"	unsigned char *
++		[384]	0x04104888 "her"	unsigned char *
++		[385]	0x04104891 "sir"	unsigned char *
++		[386]	0x0410489a "Sir"	unsigned char *
++		[387]	0x041048a3 "lady"	unsigned char *
++		[388]	0x041048ad "Lord"	unsigned char *
++		[389]	0x041048b7 "Lady"	unsigned char *
++		[390]	0x041048c1 "brother"	unsigned char *
++		[391]	0x041048ce "sister"	unsigned char *
+
++		[393]	0x041048ea "daughter"	unsigned char *
++		[394]	0x041048f8 "Unknown"	unsigned char *
++		[395]	0x04104905 "morning"	unsigned char *
++		[396]	0x04104912 "day"	unsigned char *
++		[397]	0x0410491b "evening"	unsigned char *
++		[398]	0x04104928 "Have a Drink"	unsigned char *
+
++		[400]	0x04104947 "Buy Spells"	unsigned char *
++		[401]	0x04104957 "Skill Cost: %lu"	unsigned char *
+
++		[403]	0x0410497a "You already know the %s skill"	unsigned char *
+
++		[406]	0x041049c9 "Hire"	unsigned char *
++		[407]	0x041049d3 "More Information"	unsigned char *
++		[408]	0x041049e9 "Dismiss %s"	unsigned char *
++		[409]	0x041049f9 "Do you wish to leave %s?"	unsigned char *
++		[410]	0x04104a17 "Leave %s"	unsigned char *
+
++		[412]	0x04104a33 "Create Party cannot be completed unless you have assigned all characters 2 extra skills and have spent all of your bonus points."	unsigned char *
++		[413]	0x04104ab9 "You can't spend more than 50 points."	unsigned char *
++		[414]	0x04104ae3 "This place is open from %d%s to %d%s"	unsigned char *
++		[415]	0x04104b0d "January"	unsigned char *
++		[416]	0x04104b1a "February"	unsigned char *
++		[417]	0x04104b28 "March"	unsigned char *
++		[418]	0x04104b33 "April"	unsigned char *
++		[419]	0x04104b3e "May"	unsigned char *
++		[420]	0x04104b47 "June"	unsigned char *
++		[421]	0x04104b51 "July"	unsigned char *
++		[422]	0x04104b5b "August"	unsigned char *
++		[423]	0x04104b67 "September"	unsigned char *
++		[424]	0x04104b76 "October"	unsigned char *
++		[425]	0x04104b83 "November"	unsigned char *
++		[426]	0x04104b91 "December"	unsigned char *
+
++		[428]	0x04104bc0 "Spell failed"	unsigned char *
+
++		[430]	0x04104be1 "%s is now Level %lu and has earned %lu Skill Points!"	unsigned char *
+
+
++		[435]	0x04104c4a "Converse with %s"	unsigned char *
++		[436]	0x04104c60 "Minutes"	unsigned char *
++		[437]	0x04104c6d "Minute"	unsigned char *
++		[438]	0x04104c79 "Seconds"	unsigned char *
++		[439]	0x04104c86 "Second"	unsigned char *
++		[440]	0x04104c92 "Heroism"	unsigned char *
++		[441]	0x04104c9f "Haste"	unsigned char *
++		[442]	0x04104caa "Stoneskin"	unsigned char *
++		[443]	0x04104cb9 "Bless"	unsigned char *
++		[444]	0x04104cc4 "Ooops!"	unsigned char *
++		[445]	0x04104cd0 "Lucky Day"	unsigned char *
++		[446]	0x04104cdf "Identify Failed"	unsigned char *
++		[447]	0x04104cf4 "Precision"	unsigned char *
++		[448]	0x04104d03 "Repair Failed"	unsigned char *
++		[449]	0x04104d16 "Power"	unsigned char *
++		[450]	0x04104d21 "Active Spells: %s"	unsigned char *
++		[451]	0x04104d38 "Active Party Spells"	unsigned char *
++		[452]	0x04104d51 "Torch Light"	unsigned char *
++		[453]	0x04104d62 "Wizard Eye"	unsigned char *
++		[454]	0x04104d72 "Feather Fall"	unsigned char *
++		[455]	0x04104d84 "Fly"	unsigned char *
++		[456]	0x04104d8d "Water Walk"	unsigned char *
++		[457]	0x04104d9d "Guardian"	unsigned char *
++		[458]	0x04104dab "Prot Fire"	unsigned char *
++		[459]	0x04104dba "Prot Elec"	unsigned char *
++		[460]	0x04104dc9 "Prot Cold"	unsigned char *
++		[461]	0x04104dd8 "Prot Poison"	unsigned char *
++		[462]	0x04104de9 "Prot Magic"	unsigned char *
++		[463]	0x04104df9 "Type: %s"	unsigned char *
++		[464]	0x04104e07 "Charges"	unsigned char *
++		[465]	0x04104e14 "Value"	unsigned char *
++		[466]	0x04104e1f "You found %lu gold (followers take %lu)!"	unsigned char *
++		[467]	0x04104e4d "You found %lu gold!"	unsigned char *
++		[468]	0x04104e66 "Clicking here will spend %d Skill Points"	unsigned char *
++		[469]	0x04104e94 "You need %d more Skill Points to advance here"	unsigned char *
++		[470]	0x04104ec7 "Get %s"	unsigned char *
++		[471]	0x04104ed3 "You found an item (%s)!"	unsigned char *
++		[472]	0x04104ef0 "am"	unsigned char *
++		[473]	0x04104ef8 "pm"	unsigned char *
++		[474]	0x04104f00 "Recall to %s"	unsigned char *
++		[475]	0x04104f12 "Set %s over %s"	unsigned char *
++		[476]	0x04104f26 "Set to %s"	unsigned char *
++		[477]	0x04104f35 "You are already resting!"	unsigned char *
++		[478]	0x04104f53 "You can't rest in turn-based mode!"	unsigned char *
++		[479]	0x04104f7b "You can't rest here!"	unsigned char *
++		[480]	0x04104f95 "There are hostile enemies near!"	unsigned char *
++		[481]	0x04104fba "Encounter!"	unsigned char *
++		[482]	0x04104fca "You don't have enough food to rest"	unsigned char *
++		[483]	0x04104ff2 "Set %s as the Ready Spell"	unsigned char *
++		[484]	0x04105011 "Select a spell then click here to set a QuickSpell"	unsigned char *
++		[485]	0x04105049 "Cast %s"	unsigned char *
++		[486]	0x04105056 "Select %s"	unsigned char *
++		[487]	0x04105065 "You have already mastered this skill!"	unsigned char *
++		[488]	0x04105090 "You don't have enough skill points!"	unsigned char *
++		[489]	0x041050b9 ""You have %d total gold, %d in the Bank""	unsigned char *
++		[490]	0x041050e7 "You found %d gold and an item (%s)!"	unsigned char *
++		[491]	0x04105110 "Can't cast Meteor Shower indoors!"	unsigned char *
++		[492]	0x04105137 "Can't cast Inferno outdoors!"	unsigned char *
++		[493]	0x04105159 "Can't cast Jump while airborne! "	unsigned char *
++		[494]	0x0410517f "Can not cast Fly indoors!"	unsigned char *
++		[495]	0x0410519e "Can't cast Starburst indoors!"	unsigned char *
++		[496]	0x041051c1 "No valid target exists! "	unsigned char *
++		[497]	0x041051df "Can't cast Prismatic Light outdoors!"	unsigned char *
++		[498]	0x04105209 "Herbalist"	unsigned char *
++		[499]	0x04105218 "Can't cast Armageddon indoors!"	unsigned char *
++		[500]	0x0410523c "You have %lu gold"	unsigned char *
++		[501]	0x04105253 "You have %lu food"	unsigned char *
++		[502]	0x0410526a "You find %lu food"	unsigned char *
++		[503]	0x04105281 "You lose %lu gold"	unsigned char *
++		[504]	0x04105298 "You lose %lu food"	unsigned char *
+
++		[506]	0x041052bf "Roderick"	unsigned char *
++		[507]	0x041052cd "Alexis"	unsigned char *
++		[508]	0x041052d9 "Serena"	unsigned char *
++		[509]	0x041052e5 "Zoltan"	unsigned char *
+
++		[510]	0x041052f1 "Saintly"	unsigned char *
++		[511]	0x041052fe "Angelic"	unsigned char *
++		[512]	0x0410530b "Glorious"	unsigned char *
++		[513]	0x04105319 "Honorable"	unsigned char *
++		[514]	0x04105328 "Respectable"	unsigned char *
++		[515]	0x04105339 "Average"	unsigned char *
++		[516]	0x04105346 "Bad"	unsigned char *
++		[517]	0x0410534f "Vile"	unsigned char *
++		[518]	0x04105359 "Despicable"	unsigned char *
++		[519]	0x04105369 "Monstrous"	unsigned char *
++		[520]	0x04105378 "Notorious"	unsigned char *
+
+
+
++		[524]	0x041053b9 "Once again you've cheated death! "	unsigned char *
++		[525]	0x041053e1 "Apothecary"	unsigned char *
+
++		[527]	0x041053fb "Thank You!"	unsigned char *
++		[528]	0x0410540b "I can offer you nothing further."	unsigned char *
++		[529]	0x04105431 ""Sorry, but we are unable to train you.""	unsigned char *
++		[530]	0x0410545f "Moon"	unsigned char *
++		[531]	0x04105469 "Location"	unsigned char *
++		[532]	0x04105477 "Please try back in "	unsigned char *
++		[533]	0x04105490 ""I cannot join you, you're party is full""	unsigned char *
++		[534]	0x041054bf "Become %s in %s for %lu gold"	unsigned char *
++		[535]	0x041054e1 "Learn"	unsigned char *
++		[536]	0x041054ec ""With your skills, you should be working here as a teacher.""	unsigned char *
++		[537]	0x0410552e "Train to level %d for %d gold"	unsigned char *
+
++		[539]	0x04105587 "Buy Items"	unsigned char *
++		[540]	0x04105596 "Sell Items"	unsigned char *
+
++		[542]	0x041055ba "Repair Items"	unsigned char *
++		[543]	0x041055cc "Special Items"	unsigned char *
++		[544]	0x041055df "Seek knowledge elsewhere %s the %s"	unsigned char *
++		[545]	0x04105607 "Castle Ironfist"	unsigned char *
++		[546]	0x0410561c "New Sorpigal"	unsigned char *
++		[547]	0x0410562e "Free Haven"	unsigned char *
++		[548]	0x0410563e "Arena"	unsigned char *
++		[549]	0x04105649 "Blackshire"	unsigned char *
++		[550]	0x04105659 "Kriegspire"	unsigned char *
++		[551]	0x04105669 "White Cap"	unsigned char *
++		[552]	0x04105678 "Silver Cove"	unsigned char *
++		[553]	0x04105689 "Darkmoor"	unsigned char *
++		[554]	0x04105697 "Mist"	unsigned char *
++		[555]	0x041056a1 "Bootleg Bay West"	unsigned char *
++		[556]	0x041056b7 "Volcano"	unsigned char *
++		[557]	0x041056c4 "Hermit's Isle"	unsigned char *
++		[558]	0x041056d7 "Child"	unsigned char *
++		[559]	0x041056e2 "Island North"	unsigned char *
++		[560]	0x041056f4 "Island South"	unsigned char *
++		[561]	0x04105706 ""Sorry, come back another day""	unsigned char *
++		[562]	0x0410572a "do anything"	unsigned char *
++		[563]	0x0410573b "Pack is Full!"	unsigned char *
++		[564]	0x0410574e "Hic..."	unsigned char *
++		[565]	0x0410575a "Have a Drink first..."	unsigned char *
+
++		[568]	0x0410578a "Club"	unsigned char *
++		[569]	0x04105794 "Done!"	unsigned char *
++		[570]	0x0410579f "Good as New!"	unsigned char *
++		[571]	0x041057b1 "Ready Spell: %s"	unsigned char *
++		[572]	0x041057c6 "Scroll Left"	unsigned char *
++		[573]	0x041057d7 "Scroll Right"	unsigned char *
++		[574]	0x041057e9 ""Welcome to the Arena of Life and Death.  Remember, you are only allowed one arena combat per visit.  To fight an arena battle, select the option that best describes your abilities and return to me- if you survive""	unsigned char *
++		[575]	0x041058c6 "Please wait while I summon the monsters.  Good luck."	unsigned char *
++		[576]	0x04105900 "Congratulations on your win here's your stuff %u gold."	unsigned char *
++		[577]	0x0410593e "Get back in there you wimps"	unsigned char *
++		[578]	0x04105960 "Page"	unsigned char *
++		[579]	0x0410596a "Squire"	unsigned char *
++		[580]	0x04105976 "Knight"	unsigned char *
++		[581]	0x04105982 "Lord"	unsigned char *
++		[582]	0x0410598c "You already won this trip to the Arena"	unsigned char *
+
++		[584]	0x041059d5 "Click here to remove your Quick Spell"	unsigned char *
++		[585]	0x04105a00 "Item is not of high enough quality"	unsigned char *
++		[586]	0x04105a28 "Not enough spell points"	unsigned char *
++		[587]	0x04105a45 "Attack Bonus"	unsigned char *
++		[588]	0x04105a57 "Attack Damage"	unsigned char *
++		[589]	0x04105a6a "Shoot Bonus"	unsigned char *
++		[590]	0x04105a7b "Shoot Damage"	unsigned char *
++		[591]	0x04105a8d "Charmed"	unsigned char *
++		[592]	0x04105a9a "Shrunk"	unsigned char *
++		[593]	0x04105aa6 "Slowed"	unsigned char *
++		[594]	0x04105ab2 "Feebleminded"	unsigned char *
++		[595]	0x04105ac4 "Wand"	unsigned char *
++		[596]	0x04105ace "Chaplain"	unsigned char *
++		[597]	0x04105adc "Diplomat"	unsigned char *
++		[598]	0x04105aea "Fallen Wizard"	unsigned char *
++		[599]	0x04105afd "Prelate"	unsigned char *
++		[600]	0x04105b0a "Sage"	unsigned char *
++		[601]	0x04105b14 "Zombie"	unsigned char *
++		[602]	0x04105b20 "History"	unsigned char *
++		[603]	0x04105b2d "Pay Fine"	unsigned char *
++		[604]	0x04105b3b "Bounty Hunt"	unsigned char *
++		[605]	0x04105b4c "Current Fine"	unsigned char *
++		[606]	0x04105b5e "Pay"	unsigned char *
++		[607]	0x04105b67 "Enslaved"	unsigned char *
++		[608]	0x04105b75 "Berserk"	unsigned char *
++		[609]	0x04105b82 "Hour of Power"	unsigned char *
++		[610]	0x04105b95 "Day of Protection"	unsigned char *
++		[611]	0x04105bac "Play ArcoMage"	unsigned char *
++		[612]	0x04105bbf "Save game corrupted!  Code=%d"	unsigned char *
+
++		[614]	0x04105bf4 "New Game"	unsigned char *
++		[615]	0x04105c02 "Save Game"	unsigned char *
++		[616]	0x04105c11 "Load Game"	unsigned char *
++		[617]	0x04105c20 ""Sound, Keyboard, Game Options""	unsigned char *
++		[618]	0x04105c46 "Quit"	unsigned char *
++		[619]	0x04105c50 "Return to Game"	unsigned char *
++		[620]	0x04105c64 "Rules"	unsigned char *
++		[621]	0x04105c6f "Play"	unsigned char *
++		[622]	0x04105c79 "Victory Conditions"	unsigned char *
+
++		[624]	0x04105c9c "Physical"	unsigned char *
++		[625]	0x04105caa "Immune"	unsigned char *
++		[626]	0x04105cb6 "Resistances"	unsigned char *
++		[627]	0x04105cc7 "Resistant"	unsigned char *
++		[628]	0x04105cd6 "Spell"	unsigned char *
++		[629]	0x04105ce1 "Spells"	unsigned char *
++		[630]	0x04105ced "?"	unsigned char *
++		[631]	0x04105cf4 "Effects"	unsigned char *
++		[632]	0x04105d01 "This skill level can not be learned by the %s class."	unsigned char *
++		[633]	0x04105d3b "You have to be promoted to %s to learn this skill level."	unsigned char *
++		[634]	0x04105d79 "You have to be promoted to %s or %s to learn this skill level."	unsigned char *
++		[635]	0x04105dbd "%s stuns %s"	unsigned char *
++		[636]	0x04105dce "%s paralyzes %s"	unsigned char *
++		[637]	0x04105de3 "%s evades damage"	unsigned char *
++		[638]	0x04105df9 "There are hostile creatures nearby!"	unsigned char *
++		[639]	0x04105e22 "A tie!"	unsigned char *
++		[640]	0x04105e2e "You won!"	unsigned char *
++		[641]	0x04105e3c "You lost!"	unsigned char *
++		[642]	0x04105e4b "Error"	unsigned char *
++		[643]	0x04105e56 "by a Tower Building Victory!"	unsigned char *
++		[644]	0x04105e78 "by Wall Building due to a Tower Building Tie!"	unsigned char *
++		[645]	0x04105eab "by a Tower Destruction Victory!"	unsigned char *
++		[646]	0x04105ed0 "by a Resource Victory!"	unsigned char *
++		[647]	0x04105eec "by a Resource Victory due to a Tower & Wall Building Tie!"	unsigned char *
++		[648]	0x04105f2b "This character can't summon any more monsters!"	unsigned char *
++		[649]	0x04105f5f "Summoned"	unsigned char *
++		[650]	0x04105f6d "Current Hit Points"	unsigned char *
++		[651]	0x04105f85 "Hardened"	unsigned char *
++		[652]	0x04105f93 "You can not do that while you are underwater!"	unsigned char *
++		[653]	0x04105fc6 "Food"	unsigned char *
++		[654]	0x04105fd0 "%s's Jar"	unsigned char *
++		[655]	0x04105fde "%s' Jar"	unsigned char *
+
++		[657]	0x04105ffc "Water Breathing"	unsigned char *
++		[658]	0x04106011 "Collect Prize"	unsigned char *
++		[659]	0x04106024 "x: %d  y: %d"	unsigned char *
++		[660]	0x04106036 "You are drowning!"	unsigned char *
++		[661]	0x0410604d "You are burning!"	unsigned char *
++		[662]	0x04106063 "Instructors"	unsigned char *
++		[663]	0x04106074 "It will take %d day to cross to %s."	unsigned char *
++		[664]	0x0410609d "Click here to accept this party and continue to the game."	unsigned char *
++		[665]	0x041060dc "Ok Button"	unsigned char *
++		[666]	0x041060eb "Clears all party stats and skills."	unsigned char *
++		[667]	0x04106113 "Clear Button"	unsigned char *
++		[668]	0x04106125 "Subtract"	unsigned char *
++		[669]	0x04106133 ""Subtracts a point from the highlighted skill, returning it to the bonus pool""	unsigned char *
++		[670]	0x04106187 "Add"	unsigned char *
++		[671]	0x04106190 ""Adds a point from the highlighted skill, taking it from the bonus pool""	unsigned char *
++		[672]	0x041061de ""For your numerous crimes and evil deeds, you have been sentenced to one year in prison.""	unsigned char *
++		[673]	0x0410623d "You have an outstanding fine of %lu gold.  Pay your fine now or be sentenced to jail for 1 year?"	unsigned char *
++		[674]	0x041062a3 "Temp Might"	unsigned char *
++		[675]	0x041062b3 ""Splendid job!  With the activation of the Gate, a thousand worlds lie at your feet.  Perhaps on one of them you will find the Ancients themselves, and return with the fruits their great civilization has to offer your world and your kingdom.""	unsigned char *
++		[676]	0x041063ab ""Brilliant!  The completion of the Heavenly Forge has provided enough Ancient weapons to crush all resistance to your plans.  Soon the world will bow to your every whim!  Still, you can't help but wonder what was beyond the Gate the other side was trying so hard to build.""	unsigned char *
+ */
\ No newline at end of file