changeset 247:fb8a876f41e1

Merge
author Nomad
date Mon, 18 Feb 2013 03:59:31 +0200
parents 1bfe546561c4 (current diff) f070b49d40dd (diff)
children 37dcbe8f3cca 48f21f569328 92a551e4dbeb
files mm7_2.cpp mm7_5.cpp mm7_data.h
diffstat 15 files changed, 1829 insertions(+), 1964 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Mon Feb 18 03:58:08 2013 +0200
+++ b/Actor.cpp	Mon Feb 18 03:59:31 2013 +0200
@@ -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);
@@ -2482,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 )
   {
@@ -2977,7 +2979,6 @@
   {
     v13 = &v14;
     v12 = 256;
-LABEL_16:
     Actor::_403EB6(uActorID, v16, v12, v13);
     return;
   }
@@ -2994,7 +2995,8 @@
   {
     v13 = &v14;
     v12 = 256;
-    goto LABEL_16;
+    Actor::_403EB6(uActorID, v16, v12, v13);
+    return;
   }
   v11 = v5->uMovementSpeed;
   v5->uYawAngle = v10;
@@ -3245,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;
   }
@@ -3269,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();
@@ -3297,7 +3425,6 @@
       0,
       &_this);
   }
-LABEL_24:
   if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
     Actor::Explode(v11);
 }
@@ -3719,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;
@@ -3870,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;
@@ -3917,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 )
@@ -3925,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/Items.cpp	Mon Feb 18 03:58:08 2013 +0200
+++ b/Items.cpp	Mon Feb 18 03:59:31 2013 +0200
@@ -53,7 +53,6 @@
   UpdateTempBonus(pParty->uTimePlayed);
   if ( v4->uItemID == 501 )
   {
-LABEL_45:
     *v3 = 1;
     v10 = rand();
     v17 = 10;
@@ -73,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 )
   {
@@ -113,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;
   }
@@ -160,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);
@@ -1381,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;
@@ -1390,12 +1402,11 @@
   v4 = v1->uAdditionalValue;
   if ( !v4 )
   {
-LABEL_12:
     result = uBaseValue;
   }
   else
   {
-    v3 = *(unsigned int *)&pItemsTable->pEnchantments[23].to_item[28 * v4 + 8];
+	v3 = pItemsTable->pSpecialEnchantments[v4].iTreasureLevel;
     if ( (unsigned int)v3 > 0xA )
       return uBaseValue + v3;
     result = uBaseValue * v3;
@@ -1437,7 +1448,6 @@
     v11 = pItemsTable->pItems[v2].pName;
     v4 = item__getname_buffer;
     v10 = "%s";
-LABEL_10:
     sprintf(v4, v10, v11);
     return v4;
   }
@@ -1457,7 +1467,8 @@
           v10 = pGlobalTXT_LocalizationStrings[655];
         else
           v10 = pGlobalTXT_LocalizationStrings[654];
-        goto LABEL_10;
+		sprintf(v4, v10, v11);
+		return v4;
       }
     }
   }
@@ -1491,12 +1502,12 @@
         sprintf(
           item__getname_buffer,
           "%s %s",
-          *(unsigned int *)&pItemsTable->pEnchantments[22].to_item[28 * v7 + 8],
+		  pItemsTable->pSpecialEnchantments[v7].pBonusStatement,
           pItemsTable->pItems[v1->uItemID].pName);
         return v4;
       }
       strcat(item__getname_buffer, " ");
-      v9 = *(const char **)&pItemsTable->pEnchantments[22].to_item[28 * v1->uAdditionalValue + 8];
+	  v9 = pItemsTable->pSpecialEnchantments[v1->uAdditionalValue].pBonusStatement;
     }
     strcat(item__getname_buffer, v9);
   }
@@ -1674,9 +1685,7 @@
         --v14;
       }
       while ( v14 );
-LABEL_72:
       v4->_bonus_type = v15 * treasure_level;
-      goto LABEL_73;
     }
   }
   else
@@ -1719,10 +1728,9 @@
         --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;
@@ -1763,13 +1771,10 @@
     v23 = rand();
     v24 = *(unsigned int *)v22;
     v25 = v23 % 100;
-    if ( v23 % 100 < v24 )
-      goto LABEL_127;
-    if ( !uBonusChanceSpecial[v6] )
+    if ( !uBonusChanceSpecial[v6] && !(v23 % 100 < v24))
         return;
-    if ( v25 < v24 )
+    if ( v25 < v24 || v23 % 100 < v24)
     {
-LABEL_127:
       v26 = rand() % 10;//v5->field_116D8[v5->pItems[v4->uItemID].uEquipType];
       v27 = v4->uItemID;
       v4->_bonus_type = 0;
@@ -1812,14 +1817,24 @@
       {
         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 *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType);
             if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) )
             {
@@ -1827,24 +1842,49 @@
               ++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 ( v6 != 5 )
-            goto LABEL_119;
+		  {
+            ++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;
--- a/LayingItem.cpp	Mon Feb 18 03:58:08 2013 +0200
+++ b/LayingItem.cpp	Mon Feb 18 03:59:31 2013 +0200
@@ -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 )
     {
--- a/MapInfo.h	Mon Feb 18 03:58:08 2013 +0200
+++ b/MapInfo.h	Mon Feb 18 03:59:31 2013 +0200
@@ -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 03:58:08 2013 +0200
+++ b/Monsters.cpp	Mon Feb 18 03:59:31 2013 +0200
@@ -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) --------------------------------------------------------
--- a/Monsters.h	Mon Feb 18 03:58:08 2013 +0200
+++ b/Monsters.h	Mon Feb 18 03:59:31 2013 +0200
@@ -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/NPC.h	Mon Feb 18 03:58:08 2013 +0200
+++ b/NPC.h	Mon Feb 18 03:59:31 2013 +0200
@@ -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/Player.cpp	Mon Feb 18 03:58:08 2013 +0200
+++ b/Player.cpp	Mon Feb 18 03:59:31 2013 +0200
@@ -6977,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;
@@ -7005,7 +7005,7 @@
         }
         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(SPEECH_36, 0);
@@ -7178,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;
@@ -7549,7 +7549,7 @@
         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;
@@ -7593,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];
@@ -7705,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 )
   {
--- a/StorylineTextTable.cpp	Mon Feb 18 03:58:08 2013 +0200
+++ b/StorylineTextTable.cpp	Mon Feb 18 03:59:31 2013 +0200
@@ -11,33 +11,23 @@
 
 //----- (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
-  int i,j;
+	{
+
+	int i;
 	char* test_string;
 	unsigned char c;
 	bool break_loop;
 	unsigned int temp_str_len;
 	char* tmp_pos;
 	int decode_step;
-  v1 = 0;
-  v2 = this;
-  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)
+	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;
@@ -72,10 +62,10 @@
 				}
 			else
 				{ 
-					break_loop = true;
+				break_loop = true;
 				}
 			++decode_step;
 			test_string=tmp_pos+1;
 			} while ((decode_step<4)&&!break_loop);
 		}
-}
\ No newline at end of file
+	}
\ No newline at end of file
--- a/mm7_1.cpp	Mon Feb 18 03:58:08 2013 +0200
+++ b/mm7_1.cpp	Mon Feb 18 03:59:31 2013 +0200
@@ -207,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;
@@ -641,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);
@@ -2803,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
@@ -2853,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
@@ -2877,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
@@ -2976,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;
@@ -2988,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;
@@ -3063,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
   {
@@ -3169,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);
@@ -3204,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 = SPEECH_105;
-      else
-        v73 = SPEECH_104;
-    }
-    else
-    {
-      v73 = SPEECH_106;
-    }
-    v47->PlaySound((PlayerSpeech)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
   {
@@ -3432,51 +3431,48 @@
   a4 = (char *)v106.uViewportY;
   if ( v119 )
   {
-    __debugbreak(); // following format strings are decompiled incorrectly
-    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
   {
-    __debugbreak(); // following format strings are decompiled incorrectly
-    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 )
   {
-    __debugbreak(); // following format strings are decompiled incorrectly
-    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,
@@ -3485,7 +3481,7 @@
     else
       sprintf(
         pTmpBuf,
-        "%s",
+        "%s\f%05u\t080%dd%d\n",
         pGlobalTXT_LocalizationStrings[53],
         0,
         v121->pMonsterInfo.uAttack1DamageDiceRolls,
@@ -3493,11 +3489,10 @@
   }
   else
   {
-    __debugbreak(); // following format strings are decompiled incorrectly
-    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);
@@ -3507,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];
@@ -3517,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];
@@ -3526,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];
@@ -3539,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);
@@ -3549,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];
@@ -3587,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;
@@ -3601,8 +3593,7 @@
     i = 0;
     do
     {
-      __debugbreak(); // string argument is decompiled incorrectry
-      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;
@@ -4392,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;
@@ -5184,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);
@@ -5664,64 +5655,66 @@
     && (v2 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID)) != 0 )
   {
     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();
--- a/mm7_2.cpp	Mon Feb 18 03:58:08 2013 +0200
+++ b/mm7_2.cpp	Mon Feb 18 03:59:31 2013 +0200
@@ -7565,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;
@@ -7585,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;
@@ -7605,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;
@@ -7936,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;
@@ -8114,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;
@@ -9245,393 +9245,328 @@
 //----- (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];
 
@@ -9673,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;
   }
 }
 
--- a/mm7_3.cpp	Mon Feb 18 03:58:08 2013 +0200
+++ b/mm7_3.cpp	Mon Feb 18 03:59:31 2013 +0200
@@ -4748,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);
+	  }
 }
 
 
@@ -5181,214 +5113,150 @@
 //----- (00476977) --------------------------------------------------------
 void NPCStats::Initialize2()
 {
-  char *v4; // eax@4
-  char v5; // dl@5
-  int v6; // ecx@5
-  char *v7; // edi@9
-  char *v9; // eax@21
-  char v10; // dl@22
-  int v11; // ecx@22
-  char *v12; // edi@26
-  char *v14; // eax@39
-  char v15; // dl@40
-  int v16; // ecx@40
-  char *v17; // edi@44
-  char v18; // zf@47
-  NPCStats_stru0 *v19; // eax@57
-  signed int v20; // edx@57
-  signed int v21; // ecx@58
-  int v22; // [sp+10h] [bp-10h]@4
-  int v23; // [sp+10h] [bp-10h]@21
-  int v25; // [sp+14h] [bp-Ch]@4
-  int 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 = 0;
-    v25 = 0;
-    do
-    {
-      v5 = *v4;
-      v6 = 0;
-      if ( *v4 != 9 )
-      {
-        do
-        {
-          if ( !v5 )
-            break;
-          ++v6;
-          v5 = v4[v6];
-        }
-        while ( v5 != 9 );
-        //v2 = 0;
-      }
-      v7 = &v4[v6];
-      if ( !v4[v6] )
-        v25 = 1;
-      *v7 = 0;
-      if ( v6 == 0 )
-      {
-        v25 = 1;
-      }
-      else
-      {
-        if ( v22 == 1 )
-          pNPCTopics[i].pText = RemoveQuotes(v4);
-      }
-      ++v22;
-      v4 = 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 = 0;
-    v26 = 0;
-    do
-    {
-      v10 = *v9;
-      v11 = 0;
-      if ( *v9 != 9 )
-      {
-        do
-        {
-          if ( !v10 )
-            break;
-          ++v11;
-          v10 = v9[v11];
-        }
-        while ( v10 != 9 );
-        //v2 = 0;
-      }
-      v12 = &v9[v11];
-      if ( !v9[v11] )
-        v26 = 1;
-      *v12 = 0;
-      if ( v11 == 0 )
-      {
-        v26 = 1;
-      }
-      else
-      {
-        if ( v23 == 1 )
-          pNPCTopics[i].pTopic = RemoveQuotes(v9);
-      }
-      ++v23;
-      v9 = v12 + 1;
-    }
-    while ( (signed int)(v23 - 1) <= 1 && !v26 );
-  }
+   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 = &v14[v16];
-      if ( !v14[v16] )
-        v27 = 1;
-      *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 = 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;
   }
 }
 
@@ -14519,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
@@ -14535,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
@@ -14544,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
@@ -14552,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
@@ -14578,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
@@ -14587,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
@@ -14606,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;
@@ -14630,9 +14498,17 @@
       if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
 		v5 = 680;
     }
-    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
-      goto LABEL_8;
-LABEL_23:
+  }
+  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];
@@ -14645,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);
@@ -14668,7 +14544,7 @@
           do
           {
             *(short *)v32 = v78[*((char *)v77 + v37)];//crash
-            v32 += 2;
+            ++v32;
             v97 = (char *)v97 + v87;
             v37 = (signed int)v97 >> 16;
             --i;
@@ -14694,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;
@@ -14722,16 +14598,9 @@
   }
   else
   {
-	  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;
+	  v7 = pIndoor->pMapOutlines;
 	  uNumBlueFacesInBLVMinimap = 0;
 	  v8 = pIndoor->pMapOutlines->uNumOutlines == 0;
 	  v9 = pIndoor->pMapOutlines->uNumOutlines < 0;
@@ -14780,13 +14649,13 @@
 					v85 + ((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16),
 					v90 - v92,
 					black);
-				  v7 = (uint *)pIndoor->pMapOutlines;
+				  v7 = pIndoor->pMapOutlines;
 			  }
 		  }
 		  ++v94;
 		  i += 12;
 		}
-		while ( (signed int)v94 < (signed int)*v7 );
+		while ( v94 < (signed int)v7->uNumOutlines );
 	  }
 	  v21 = 0;
 	  if ( (signed int)uNumBlueFacesInBLVMinimap > 0 )
@@ -14795,9 +14664,9 @@
 		{
 		  v22 = pBlueFacesInBLVMinimapIDs[v21];
 		  v87 = v5;
-		  v23 = (int)&v7[3 * v22 + 1];
-		  v24 = &pIndoor->pVertices[*(short *)v23];
-		  v25 = &pIndoor->pVertices[*(short *)(v23 + 2)];
+		  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;
@@ -14818,7 +14687,7 @@
 		  ++v21;
 		  if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap )
 			break;
-		  v7 = (uint *)pIndoor->pMapOutlines;
+		  v7 = pIndoor->pMapOutlines;
 		}
 		v6 = v86;
 	  }
@@ -14980,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 )
@@ -14998,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;
@@ -15014,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;
@@ -15035,7 +14904,7 @@
             v69 = *(short *)v66;
             if ( !*(short *)v66 || v69 == (short)i )
               *v67 = v69;
-            v66 += 2;
+            ++v66;
             ++v67;
             --v68;
           }
@@ -15246,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) --------------------------------------------------------
--- a/mm7_5.cpp	Mon Feb 18 03:58:08 2013 +0200
+++ b/mm7_5.cpp	Mon Feb 18 03:59:31 2013 +0200
@@ -2901,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) )
@@ -8586,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
@@ -8628,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
@@ -8643,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 )
     {
@@ -17400,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);
@@ -17857,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 03:58:08 2013 +0200
+++ b/mm7_6.cpp	Mon Feb 18 03:59:31 2013 +0200
@@ -7873,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);
--- a/mm7_data.h	Mon Feb 18 03:58:08 2013 +0200
+++ b/mm7_data.h	Mon Feb 18 03:59:31 2013 +0200
@@ -2000,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();