changeset 562:b23f19fc0d1b

Merge
author Nomad
date Tue, 05 Mar 2013 00:25:08 +0200
parents 8b9cbf1f87fb (current diff) 4f14053d6105 (diff)
children 5eb2c6286c49 8b77231088d8
files mm7_1.cpp
diffstat 6 files changed, 636 insertions(+), 659 deletions(-) [+]
line wrap: on
line diff
--- a/GameUIs.cpp	Tue Mar 05 00:24:28 2013 +0200
+++ b/GameUIs.cpp	Tue Mar 05 00:25:08 2013 +0200
@@ -189,7 +189,7 @@
   for (uint i = 0; i < 40; ++i)
 	  {
     v3 = pSavegameList->pFileList[i].pSaveFileName;
-    if ( !pSavegameList->pFileList[i].pSaveFileName )
+    if ( !*pSavegameList->pFileList[i].pSaveFileName )
       v3 = "1.mm7";
     sprintf(pTmpBuf, "saves\\%s", v3);
     if ( _access(pTmpBuf, 0) || _access(pTmpBuf, 6) )
--- a/Items.cpp	Tue Mar 05 00:24:28 2013 +0200
+++ b/Items.cpp	Tue Mar 05 00:25:08 2013 +0200
@@ -746,9 +746,9 @@
 						++test_char;
 						}
 					test_char=test_string;
-					if ((ii==tst_len)&&(tolower(*test_char)=='s'))
+					if ((ii==tst_len)&&(tolower(*test_char)!='s'))
 						{
-						pItems[item_counter].uDamageDice=atoi(test_char+1);
+						pItems[item_counter].uDamageDice=atoi(test_char);
 						pItems[item_counter].uDamageRoll=1;
 						}
 					break;
@@ -1534,391 +1534,357 @@
 
 //----- (00456620) --------------------------------------------------------
 void ItemsTable::GenerateItem(int treasure_level, unsigned int uTreasureType, ItemGen *out_item)
-{
-  
-ItemGen *v4; // esi@1
-  ItemsTable *v5; // edi@1
-  int v6; // ebx@3
-  int *v7; // ecx@33
-  //int v8; // eax@34
-  //int v9; // eax@39
-  int v10; // ebx@43
-  int v11; // ecx@47
-  unsigned int *v12; // edx@48
-  unsigned int v13; // eax@49
-  signed int v14; // ebx@52
-  int v15; // eax@53
-  signed int v16; // eax@55
-  int v17; // ebx@57
-  int v18; // edx@62
-  signed int v19; // ebx@70
-  unsigned __int8 v20; // al@81
-  int v21; // eax@84
-  int v22; // ebx@85
-  int v23; // eax@86
-  int v24; // ebx@86
-  int v25; // edx@86
-  int v26; // edx@89
-  unsigned int v27; // eax@89
-  int i; // ebx@89
-  unsigned int v29; // ecx@90
-  int v30; // ebx@91
-  int v31; // eax@91
-  int v32; // ecx@91
-  int v33; // eax@91
-  int v34; // eax@97
-  unsigned __int8 v35; // sf@97
-  unsigned __int8 v36; // of@97
-  int v37; // ebx@98
-  int v38; // edx@99
-  signed int v39; // ebx@101
-  int v40; // ecx@102
-  char v41; // zf@107
-  char v42; // al@108
-  char v43; // al@111
-  int *v44; // edx@118
-  int v45; // eax@120
-  int v46; // edx@120
-  int *j; // eax@121
-  unsigned int v48; // ecx@123
-  int v49; // eax@123
-  int v50; // eax@123
-  int Dst[800]; // [sp+Ch] [bp-C88h]@33
-  int v52; // [sp+C8Ch] [bp-8h]@33
-  int v53; // [sp+C90h] [bp-4h]@1
-  int v54; // [sp+C9Ch] [bp+8h]@3
-  //int v55; // [sp+CA0h] [bp+Ch]@34
-  signed int v56; // [sp+CA0h] [bp+Ch]@55
-  int v57; // [sp+CA0h] [bp+Ch]@62
-  int *v58; // [sp+CA0h] [bp+Ch]@102
-  int v59; // [sp+CA0h] [bp+Ch]@123
-  //signed int a2a; // [sp+CA4h] [bp+10h]@33
-  int a2b; // [sp+CA4h] [bp+10h]@101
-  int a2c; // [sp+CA4h] [bp+10h]@120
+    {
 
-  v53 = -1;
-  v5 = this;
-  if (!out_item)
-    out_item = (ItemGen *)pAllocator->AllocNamedChunk(out_item, sizeof(*out_item), "newItemGen");
-  memset(out_item, 0, sizeof(*out_item));
+    ItemsTable *v5; // edi@1
+    int v6; // ebx@3
+    int *v7; // ecx@33
+    //int v8; // eax@34
+    //int v9; // eax@39
+    int current_chance; // ebx@43
+    int tmp_chance; // ecx@47
+    unsigned int *v12; // edx@48
+    unsigned int v13; // eax@49
+    signed int v14; // ebx@52
+    int v15; // eax@53
+    signed int v16; // eax@55
+    int v17; // ebx@57
+    int v18; // edx@62
+    signed int v19; // ebx@70
+    unsigned __int8 v20; // al@81
+    int v21; // eax@84
+    int v22; // ebx@85
+    int v23; // eax@86
+    int v24; // ebx@86
+    int special_chance; // edx@86
+    int v26; // edx@89
+    unsigned int v27; // eax@89
+    int i; // ebx@89
+    unsigned int v29; // ecx@90
+    int v30; // ebx@91
+    int v31; // eax@91
+    int v32; // ecx@91
+    int v33; // eax@91
+    int v34; // eax@97
+    unsigned __int8 v35; // sf@97
+    unsigned __int8 v36; // of@97
+    int v37; // ebx@98
+    int v38; // edx@99
+    signed int v39; // ebx@101
+    int v40; // ecx@102
+    char v41; // zf@107
+    char v42; // al@108
+    char v43; // al@111
+    int *v44; // edx@118
+    int v45; // eax@120
+    int v46; // edx@120
+    int j; // eax@121
+    unsigned int v48; // ecx@123
+    int v49; // eax@123
+    int v50; // eax@123
+    int val_list[800]; // [sp+Ch] [bp-C88h]@33
+    int total_chance; // [sp+C8Ch] [bp-8h]@33
+    int v53; // [sp+C90h] [bp-4h]@1
+    int v54; // [sp+C9Ch] [bp+8h]@3
+    //int v55; // [sp+CA0h] [bp+Ch]@34
+    signed int v56; // [sp+CA0h] [bp+Ch]@55
+    int v57; // [sp+CA0h] [bp+Ch]@62
+    int *v58; // [sp+CA0h] [bp+Ch]@102
+    int v59; // [sp+CA0h] [bp+Ch]@123
+    //signed int a2a; // [sp+CA4h] [bp+10h]@33
+    int a2b; // [sp+CA4h] [bp+10h]@101
+    int a2c; // [sp+CA4h] [bp+10h]@120
+
+    v5 = this;
+    if (!out_item)
+        out_item = (ItemGen *)pAllocator->AllocNamedChunk(out_item, sizeof(*out_item), "newItemGen");
+    memset(out_item, 0, sizeof(*out_item));
+
 
-  v4 = out_item;
-  v6 = treasure_level - 1;
-  v54 = treasure_level - 1;
-  if ( uTreasureType ) //generate known treasure type
-  {
-    ITEM_EQUIP_TYPE   requested_equip;
-    PLAYER_SKILL_TYPE requested_skill = PLAYER_SKILL_INVALID;
-    switch (uTreasureType)
-     {
-      case 20: requested_equip = EQUIP_ONE_OR_TWO_HANDS; break;
-      case 21: requested_equip = EQUIP_ARMOUR; break;
-      case 22: requested_skill = PLAYER_SKILL_MISC; break;
-      case 23: requested_skill = PLAYER_SKILL_SWORD; break;
-      case 24: requested_skill = PLAYER_SKILL_DAGGER; break;
-      case 25: requested_skill = PLAYER_SKILL_AXE; break;
-      case 26: requested_skill = PLAYER_SKILL_SPEAR; break;
-      case 27: requested_skill = PLAYER_SKILL_BOW; break;
-      case 28: requested_skill = PLAYER_SKILL_MACE; break;
-      case 29: requested_skill = PLAYER_SKILL_CLUB; break;
-      case 30: requested_skill = PLAYER_SKILL_STAFF; break;
-      case 31: requested_skill = PLAYER_SKILL_LEATHER; break;
-      case 32: requested_skill = PLAYER_SKILL_CHAIN; break;
-      case 33: requested_skill = PLAYER_SKILL_PLATE; break;
-      case 34: requested_equip = EQUIP_SHIELD; break;
-      case 35: requested_equip = EQUIP_HELMET; break;
-      case 36: requested_equip = EQUIP_BELT; break;
-      case 37: requested_equip = EQUIP_CLOAK; break;
-      case 38: requested_equip = EQUIP_GAUNTLETS; break;
-      case 39: requested_equip = EQUIP_BOOTS; break;
-      case 40: requested_equip = EQUIP_RING; break;
-      case 41: requested_equip = EQUIP_AMULET; break;
-      case 42: requested_equip = EQUIP_WAND; break;
-	  case 43: requested_equip = EQUIP_SPELL_SCROLL; break;
-      case 44: requested_equip = EQUIP_POTION; break;
-      case 45: requested_equip = EQUIP_REAGENT; break;
-      case 46: requested_equip = EQUIP_GEM; break;
-      default:
-        __debugbreak(); // check this condition
-        requested_equip = (ITEM_EQUIP_TYPE)(uTreasureType - 1);
-      break;
-    }
-    memset(Dst, 0, sizeof(Dst));
-    v52 = 0;
-    v7 = Dst;
-    //a2a = 1;
-    if (requested_skill == PLAYER_SKILL_INVALID)  // no skill for this item needed
-    {
-      for (uint i = 1; i < 500; ++i)
-      {
-        if (pItems[i].uEquipType == requested_equip)
+    v6 = treasure_level - 1;
+    v54 = treasure_level - 1;
+    if ( uTreasureType ) //generate known treasure type
         {
-          *v7++ = i;
-          v52 += pItems[i].uChanceByTreasureLvl[v6];
+        ITEM_EQUIP_TYPE   requested_equip;
+        PLAYER_SKILL_TYPE requested_skill = PLAYER_SKILL_INVALID;
+        switch (uTreasureType)
+            {
+        case 20: requested_equip = EQUIP_ONE_OR_TWO_HANDS; break;
+        case 21: requested_equip = EQUIP_ARMOUR; break;
+        case 22: requested_skill = PLAYER_SKILL_MISC; break;
+        case 23: requested_skill = PLAYER_SKILL_SWORD; break;
+        case 24: requested_skill = PLAYER_SKILL_DAGGER; break;
+        case 25: requested_skill = PLAYER_SKILL_AXE; break;
+        case 26: requested_skill = PLAYER_SKILL_SPEAR; break;
+        case 27: requested_skill = PLAYER_SKILL_BOW; break;
+        case 28: requested_skill = PLAYER_SKILL_MACE; break;
+        case 29: requested_skill = PLAYER_SKILL_CLUB; break;
+        case 30: requested_skill = PLAYER_SKILL_STAFF; break;
+        case 31: requested_skill = PLAYER_SKILL_LEATHER; break;
+        case 32: requested_skill = PLAYER_SKILL_CHAIN; break;
+        case 33: requested_skill = PLAYER_SKILL_PLATE; break;
+        case 34: requested_equip = EQUIP_SHIELD; break;
+        case 35: requested_equip = EQUIP_HELMET; break;
+        case 36: requested_equip = EQUIP_BELT; break;
+        case 37: requested_equip = EQUIP_CLOAK; break;
+        case 38: requested_equip = EQUIP_GAUNTLETS; break;
+        case 39: requested_equip = EQUIP_BOOTS; break;
+        case 40: requested_equip = EQUIP_RING; break;
+        case 41: requested_equip = EQUIP_AMULET; break;
+        case 42: requested_equip = EQUIP_WAND; break;
+        case 43: requested_equip = EQUIP_SPELL_SCROLL; break;
+        case 44: requested_equip = EQUIP_POTION; break;
+        case 45: requested_equip = EQUIP_REAGENT; break;
+        case 46: requested_equip = EQUIP_GEM; break;
+        default:
+            __debugbreak(); // check this condition
+            requested_equip = (ITEM_EQUIP_TYPE)(uTreasureType - 1);
+            break;
+            }
+        memset(val_list, 0, sizeof(val_list));
+        total_chance = 0;
+        j=0;
+        //a2a = 1;
+        if (requested_skill == PLAYER_SKILL_INVALID)  // no skill for this item needed
+            {
+            for (uint i = 1; i < 500; ++i)
+                {
+                if (pItems[i].uEquipType == requested_equip)
+                    {
+                    val_list[j] = i;
+                    ++j;
+                    total_chance += pItems[i].uChanceByTreasureLvl[treasure_level - 1];
+                    }
+                }
+            }
+        else  //have needed skill
+            {
+            for (uint i = 1; i < 500; ++i)
+                {
+                if (pItems[i].uSkillType == requested_skill)
+                    {
+                    val_list[j] = i;
+                    ++j;
+                    total_chance += pItems[i].uChanceByTreasureLvl[treasure_level - 1];
+                    }
+                }
+            }
+
+        current_chance = 0;
+        if ( total_chance )
+            current_chance = rand() % total_chance;
+
+        out_item->uItemID = val_list[0];
+        if (!out_item->uItemID)
+            out_item->uItemID = 1;
+
+        if ( pItems[out_item->uItemID].uChanceByTreasureLvl[treasure_level - 1] < current_chance )
+            {
+            j=0;
+            tmp_chance=pItems[out_item->uItemID].uChanceByTreasureLvl[treasure_level - 1];
+            do
+                {
+                ++j;
+                out_item->uItemID = val_list[j];
+                tmp_chance += pItems[val_list[j]].uChanceByTreasureLvl[treasure_level - 1];
+                }
+                while ( tmp_chance < current_chance );
+            }
+
+        if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE )
+            {// if it potion set potion spec
+            out_item->uEncantmentType = 0;
+            for (int i=0; i<2; ++i)
+                out_item->uEncantmentType += rand() % 4 + 1;
+            out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; 
+            }
         }
-      }
-    }
-    else  //have needed skill
-    {
-      for (uint i = 1; i < 500; ++i)
-      {
-        if (pItems[i].uSkillType == requested_skill)
+    else
         {
-          *v7++ = i;
-          v52 += pItems[i].uChanceByTreasureLvl[v6];
-        }
-      }
-    }
-
-    v10 = 0;
-    if ( v52 )
-      v10 = rand() % v52;
-
-    out_item->uItemID = *Dst;
-    if (!out_item->uItemID)
-      out_item->uItemID = 1;
+   //artifact
+        v56 = 0;
+        for(int i=0; i<29; ++i) 
+            v56 += pParty->pIsArtifactFound[i];
 
-    v11 = pItems[out_item->uItemID].uChanceByTreasureLvl[v6];
-    if ( v11 < v10 )
-    {
-      v12 = (uint *)Dst;
-      do
-      {
-        ++v12;
-        v13 = *v12;
-        out_item->uItemID = *v12;
-        v11 += pItems[v13].uChanceByTreasureLvl[v6];
-      }
-      while ( v11 < v10 );
-    }
-	
-    if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE )
-    {// if it potion set potion spec
-      out_item->uEncantmentType = 0;
-     for (int i=0; i<2; ++i)
-        out_item->uEncantmentType += rand() % 4 + 1;
-      out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; 
-    }
-  }
-  else
-  {
-    v16 = 0;
-    v56 = 0;
-    do
-      v56 += pParty->pIsArtifactFound[v16++];
-    while ( v16 < 29 );
-    v17 = rand() % 29;
-
-    if ( v6 == 5 && rand() % 100 < 5 && !pParty->pIsArtifactFound[v17] && v56 < 13 )
-    {
-      pParty->pIsArtifactFound[v17] = 1;
-      out_item->uAttributes = 0;
-      out_item->uItemID = v17 + 500;
-      SetSpecialBonus(out_item);
-      return;
-    }
+        v17 = rand() % 29;
 
-    v57 = 0;
-    v18 = rand() % v5->uChanceByTreasureLvlSumm[v54];// v5->field_11684[v54];
-    out_item->uItemID = 0;
-    if ( v18 > 0 )
-    {
-      do
-        v57 += pItems[out_item->uItemID++ + 1].uChanceByTreasureLvl[v6];
-      while ( v57 < v18 );
-    }
+        if ( v6 == 5 && (rand() % 100 < 5) && !pParty->pIsArtifactFound[v17] && v56 < 13 )
+            {
+            pParty->pIsArtifactFound[v17] = 1;
+            out_item->uAttributes = 0;
+            out_item->uItemID = v17 + 500;
+            SetSpecialBonus(out_item);
+            return;
+            }
+
+        v57 = 0;
+        v18 = rand() % v5->uChanceByTreasureLvlSumm[treasure_level - 1];
+        out_item->uItemID = 0;
+        if ( v18 > 0 )
+            {
+            do
+            v57 += pItems[out_item->uItemID++ + 1].uChanceByTreasureLvl[v6];
+            while ( v57 < v18 );
+            }
+
+        if ( !v18 )
+            out_item->uItemID = 1;
+        if ( !out_item->uItemID )
+            out_item->uItemID = 1;
+        if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE )
+            {// if it potion set potion spec
+            out_item->uEncantmentType = 0;
+            for (int i=0; i<2; ++i)
+                out_item->uEncantmentType += rand() % 4 + 1;
+            out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; 
+            }
+        out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; 
+        }
+
+    if ( out_item->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION
+        && !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 239) )
+        out_item->uItemID = ITEM_SPELLBOOK_LIGHT_SUN_BURST;
+    if ( pItemsTable->pItems[out_item->uItemID + 1].uItemID_Rep_St )
+        out_item->uAttributes = 0;
+    else
+        out_item->uAttributes = 1;
 
-    if ( !v18 )
-      out_item->uItemID = 1;
-    if ( !out_item->uItemID )
-      out_item->uItemID = 1;
-	if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE )
-		{// if it potion set potion spec
-		out_item->uEncantmentType = 0;
-		for (int i=0; i<2; ++i)
-			out_item->uEncantmentType += rand() % 4 + 1;
-		out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; 
-		}
-	out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; 
-  }
-  if ( v4->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION
-    && !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 239) )
-    v4->uItemID = ITEM_SPELLBOOK_LIGHT_SUN_BURST;
-  if ( pItemsTable->pItems[v4->uItemID + 1].uItemID_Rep_St )
-    v4->uAttributes = 0;
-  else
-    v4->uAttributes = 1;
-  if ( pItems[out_item->uItemID].uEquipType != EQUIP_POTION )
-  {
-    out_item->uSpecEnchantmentType = 0;
-    out_item->uEncantmentType = 0;
-  }
-  v20 = pItems[out_item->uItemID].uEquipType;
-  if ( v20 <= EQUIP_BOW )
-  {
-    v37 = v5->uBonusChanceWpSpecial[v54];
-    if ( !v37 )
-      return;
-    v38 = rand() % 100;
-    v36 = __OFSUB__(v38, v37);
-    v35 = v38 - v37 < 0;
-  }
-  else
-  {
-    if ( v20 > EQUIP_AMULET )
-    {
-      if ( v20 == EQUIP_WAND )
-      {
-        v21 = rand() % 6 + pItemsTable->pItems[v4->uItemID].uDamageMod + 1;
-        out_item->uNumCharges = v21;
-        out_item->uMaxCharges = v21;
-      }
-      return;
-    }
-    v22 = uBonusChanceStandart[v6];
-    if ( !v22 )
-      return;
-    v24 = v22;
-    v25 = rand() % 100;
-    if ( !uBonusChanceSpecial[v6] && !(v25 < v24))
+    if ( pItems[out_item->uItemID].uEquipType != EQUIP_POTION )
+        {
+        out_item->uSpecEnchantmentType = 0;
+        out_item->uEncantmentType = 0;
+        }
+    //try get special enhansment
+    switch (pItems[out_item->uItemID].uEquipType)
+        {
+    case EQUIP_ONE_OR_TWO_HANDS:
+    case EQUIP_TWO_HANDED :   
+    case EQUIP_BOW :    
+        if ( !uBonusChanceWpSpecial[v6] )
+            return;
+        if ((rand() % 100)>=uBonusChanceWpSpecial[v6])
+            return;
+        break;
+    case      EQUIP_ARMOUR :        
+    case      EQUIP_SHIELD :         
+    case      EQUIP_HELMET  :       
+    case      EQUIP_BELT   :          
+    case      EQUIP_CLOAK  :        
+    case      EQUIP_GAUNTLETS :      
+    case      EQUIP_BOOTS  :        
+    case      EQUIP_RING   : 
+        v22 = uBonusChanceStandart[v6];
+        if ( !uBonusChanceStandart[v6] )
+            return;
+        v24 = v22;
+        special_chance = rand() % 100;
+        if ( !uBonusChanceSpecial[v6] && !(special_chance < uBonusChanceStandart[v6]))
+            return;
+        if ( special_chance < uBonusChanceStandart[v6])
+            {
+            v26 = rand() % v5->uBonusChanceWpSpecial[v5->pItems[out_item->uItemID].uEquipType + 3];
+            v27 = out_item->uItemID;
+            out_item->uEncantmentType = 0;
+            for ( i = pEnchantments[0].to_item[pItems[v27].uEquipType + 1];
+                i < v26;
+                i += pEnchantments[out_item->uEncantmentType].to_item[pItems[v29].uEquipType + 1] )
+                {
+                v29 = out_item->uItemID;
+                ++out_item->uEncantmentType;
+                }
+            ++out_item->uEncantmentType;
+            v30 = bonus_ranges[v6].minR;
+            v32 = out_item->uEncantmentType - 1;
+            v33 = rand() % (bonus_ranges[v6].maxR - v30 + 1) + v30;
+            out_item->_bonus_strength = v33;
+            if ( v32 == 21 || v32 == 22 || v32 == 23 )
+                out_item->_bonus_strength = v33 >> 1;
+            if ( out_item->_bonus_strength <= 0 )
+                out_item->_bonus_strength = 1;
+            return;
+            
+            }
+        v34 = uBonusChanceStandart[v6] + uBonusChanceSpecial[v6];
+        if ( special_chance<v34 )
+            return;
+        break;
+    case EQUIP_WAND:
+        out_item->uNumCharges = rand() % 6 + pItemsTable->pItems[out_item->uItemID].uDamageMod + 1;
+        out_item->uMaxCharges = out_item->uNumCharges;
+    default:
         return;
-    if ( v25 < v24 || v25 < v24)
-    {
-      v26 = rand() % v5->uBonusChanceWpSpecial[v5->pItems[v4->uItemID].uEquipType + 3];
-      v27 = v4->uItemID;
-      v4->uEncantmentType = 0;
-      for ( i = pEnchantments[0].to_item[pItems[v27].uEquipType + 1];
-            i < v26;
-            i += pEnchantments[v4->uEncantmentType].to_item[pItems[v29].uEquipType + 1] )
-      {
-        v29 = v4->uItemID;
-        ++v4->uEncantmentType;
-      }
-      ++v4->uEncantmentType;
-      v30 = 10;// v5->field_116D8[2 * v54 + 12];
-      v31 = rand();
-      v32 = v4->uEncantmentType - 1;
-      v33 = v31 % 10;//(v5->field_116D8[2 * v54 + 13] - v30 + 1) + v30;
-      v4->_bonus_strength = v33;
-      if ( v32 == 21 || v32 == 22 || v32 == 23 )
-        v4->_bonus_strength = v33 >> 1;
-      if ( v4->_bonus_strength <= 0 )
-        v4->_bonus_strength = 1;
-      return;
-    }
-    v34 = v24 + 10;//*(unsigned int *)&v5->field_1169C[4 * v54 + 24];
-    v36 = __OFSUB__(v25, v34);
-    v35 = v25 - v34 < 0;
-  }
-  if ( !(v35 ^ v36) )
-    return;
-  memset(&Dst, 0, 0xC80u);
-  v39 = 0;
-  a2b = 0;
-  if ( pSpecialEnchantments_count > 0 )
-  {
-    v52 = -16 - (uint)this;
-    v58 = (int *)&Dst;
-    v40 = (int)&pSpecialEnchantments[1];
-    do
-    {
-      switch ( v6 )
-      {
+        }
+
+    j=0;
+    int spc_sum=0;
+    int spc;
+    memset(&val_list, 0, 3200);
+    for (int i=0; i<pSpecialEnchantments_count;++i)
+        {
+        int tr_lv= pSpecialEnchantments[i].iTreasureLevel;
+        switch ( treasure_level - 1 )
+            {
         case 2:
-          if ( !*(unsigned char *)v40 )
-          {
-            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;
+            if ((tr_lv==1)||(tr_lv==0))
+                {
+                spc=pSpecialEnchantments[i].to_item_apply[pItems[out_item->uItemID].uEquipType];
+                spc_sum+=spc;
+                if(spc)
+                    {
+                    val_list[j++]=i;  
+                    }
+                }
+            break;
         case 3:
-          v43 = *(unsigned char *)v40;
-          if ( !*(unsigned char *)v40 || v43 == 1 )
-          {
-            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;
+            if ((tr_lv==2)||(tr_lv==1)||(tr_lv==0))
+                {
+                spc=pSpecialEnchantments[i].to_item_apply[pItems[out_item->uItemID].uEquipType];
+                spc_sum+=spc;
+                if(spc)
+                    {
+                    val_list[j++]=i;  
+                    }
+                }
+            break;
+        case 4:
+            if ((tr_lv==3)||(tr_lv==2)||(tr_lv==1))
+                {
+                spc=pSpecialEnchantments[i].to_item_apply[pItems[out_item->uItemID].uEquipType];
+                spc_sum+=spc;
+                if(spc)
+                    {
+                    val_list[j++]=i;  
+                    }
+                }
+            break;
+        case 5:
+            if (tr_lv==3)
+                {
+                spc=pSpecialEnchantments[i].to_item_apply[pItems[out_item->uItemID].uEquipType];
+                spc_sum+=spc;     
+                if(spc)
+                    {
+                    val_list[j++]=i;  
+                    }
+                }
+            break;
             }
-            ++a2b;
-			v40 += 28;
-			continue;
-          }
-          v41 = v43 == 2;
-          break;
-        case 4:
-          v42 = *(unsigned char *)v40;
-          if ( *(unsigned char *)v40 == 1 || v42 == 2 )
-          {
-            v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType);
-            if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) )
+        }
+
+    v46 = rand()%spc_sum+1;
+    j=0;
+    out_item->uSpecEnchantmentType =val_list[j];
+    v45=pSpecialEnchantments[val_list[j]].to_item_apply[pItems[out_item->uItemID].uEquipType];
+    if (v45<v46)
+        {
+        do 
             {
-              v44 = v58;
-              ++v58;
-              *v44 = a2b;
-            }
-            ++a2b;
-			v40 += 28;
-			continue;
-          }
-          v41 = v42 == 3;
-          break;
-        default:
-          if ( v6 != 5 )
-		  {
-            ++a2b;
-			v40 += 28;
-			continue;
-		  }
-          v41 = *(unsigned char *)v40 == 3;
-          break;
-      }
-      if ( v41 )
-      {
-		v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType);
-		if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) )
-		{
-			v44 = v58;
-			++v58;
-			*v44 = a2b;
-		}
-	  }
-LABEL_119:
-      ++a2b;
-      v40 += 28;
-    }
-    while ( a2b < pSpecialEnchantments_count );
-  }
-  v45 = rand();
-  v4->uSpecEnchantmentType = *(uint *)Dst;
-  v46 = v45 % v39 + 1;
-  a2c = *((unsigned char *)&uAllItemsCount + 28 * (*(uint *)Dst + 1389) + pItems[v4->uItemID].uEquipType);
-  if ( a2c < v46 )
-  {
-    for ( j = (int *)&Dst; ; j = (int *)v59 )
-    {
-      v48 = v4->uItemID;
-      v49 = (int)(j + 1);
-      v59 = v49;
-      v50 = *(unsigned int *)v49;
-      v4->uSpecEnchantmentType = v50;
-      a2c += *((unsigned char *)&uAllItemsCount + 28 * (v50 + 1389) + pItems[v48].uEquipType);
-      if ( a2c >= v46 )
-        break;
-    }
-  }
-  ++v4->uSpecEnchantmentType;
+            ++j;
+            out_item->uSpecEnchantmentType=val_list[j];
+            v45+=pSpecialEnchantments[val_list[j]].to_item_apply[pItems[out_item->uItemID].uEquipType];
+            } while (v45<v46);
+        }
+    ++out_item->uSpecEnchantmentType;
 }
 
 //----- (004505CC) --------------------------------------------------------
--- a/Items.h	Tue Mar 05 00:24:28 2013 +0200
+++ b/Items.h	Tue Mar 05 00:25:08 2013 +0200
@@ -157,7 +157,7 @@
 
 /*  175 */
 #pragma pack(push, 1)
-struct ItemDesc
+struct ItemDesc //30h
 	{ //Item # |Pic File|Name|Value|Equip Stat|Skill Group|Mod1|Mod2|material|	
 	///ID/Rep/St|Not identified name|Sprite Index|VarA|VarB|Equip X|Equip Y|Notes
 	char *pIconName;  //0 4
@@ -225,14 +225,14 @@
 
 /*  178 */
 #pragma pack(push, 1)
-struct ItemSpecialEnchantment
+struct ItemSpecialEnchantment //1Ch
 { //Bonus Stat|Name Add|W1|W2|Miss|Arm|Shld|Helm|Belt|Cape|Gaunt|Boot|Ring|Amul|Value|Lvl|Description fo special Bonuses and values			
 
-  char *pBonusStatement;
-  char *pNameAdd;
-  char to_item_apply[12];
-  int iValue;
-  int iTreasureLevel;
+  char *pBonusStatement;  //0
+  char *pNameAdd;    //4
+  char to_item_apply[12]; //8
+  int iValue;  //14
+  int iTreasureLevel; //18
 };
 #pragma pack(pop)
 
--- a/SaveLoad.cpp	Tue Mar 05 00:24:28 2013 +0200
+++ b/SaveLoad.cpp	Tue Mar 05 00:25:08 2013 +0200
@@ -611,7 +611,7 @@
 {
   unsigned int v1; // esi@1
   int v2; // esi@2
-  RGBTexture *v3; // ebx@3
+  //RGBTexture *v3; // ebx@3
   int bNotArena; // [sp+2Ch] [bp-8h]@1
   unsigned int v6; // [sp+30h] [bp-4h]@1
 
@@ -638,14 +638,13 @@
   GUI_UpdateWindows();
   pGUIWindow_CurrentMenu->Release();
   pCurrentScreen = SCREEN_GAME;
-  v3 = pSavegameThumbnails;
+  //v3 = pSavegameThumbnails;
   viewparams->bRedrawGameUI = 1;
-  do
+  for(int i=0;i<45;i++)
   {
-    v3->Release();
-    ++v3;
+    pSavegameThumbnails[i].Release();
   }
-  while ( (signed int)v3 < (signed int)&unk_6A0758 );
+  //while ( (signed int)v3 < (signed int)&unk_6A0758 );
   if ( bNotArena )
     pNew_LOD->_4621A7();
   else
--- a/mm7_1.cpp	Tue Mar 05 00:24:28 2013 +0200
+++ b/mm7_1.cpp	Tue Mar 05 00:25:08 2013 +0200
@@ -2509,14 +2509,12 @@
     if ( inspect_item->uEncantmentType )
      {
         sprintf(out_text + 200, "%s: %s +%d", pGlobalTXT_LocalizationStrings[210],
-             pItemsTable->pEnchantments[inspect_item->uEncantmentType-1].pOfName, inspect_item->_bonus_strength); //"Special"
+             pItemsTable->pEnchantments[inspect_item->uEncantmentType-1].pBonusStat, inspect_item->_bonus_strength); //"Special"
     }
     else  if ( inspect_item->uSpecEnchantmentType )
-      {
-      
-          
+      {      
         sprintf(out_text + 200, "%s: %s", pGlobalTXT_LocalizationStrings[210], 
-            pItemsTable->pSpecialEnchantments[inspect_item->uSpecEnchantmentType-1].pNameAdd, inspect_item->_bonus_strength);
+            pItemsTable->pSpecialEnchantments[inspect_item->uSpecEnchantmentType-1].pBonusStatement, inspect_item->_bonus_strength);
       }
     
     else if ( inspect_item->uNumCharges )
--- a/mm7_5.cpp	Tue Mar 05 00:24:28 2013 +0200
+++ b/mm7_5.cpp	Tue Mar 05 00:25:08 2013 +0200
@@ -16248,79 +16248,161 @@
   }
 
   pEventTimer->Pause();
-  if ( pCurrentScreen <= SCREEN_CHEST )
-  {
-    if ( pCurrentScreen == SCREEN_CHEST )
-    {
-    //  __debugbreak();
-      if ( !pPlayers[uActiveCharacter]->CanAct() )
-      {
-        sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[427],//%s не в состоянии %s
-          pPlayers[uActiveCharacter]->pName, pGlobalTXT_LocalizationStrings[541]);//Опознать предметы
-        pWindow.Hint = pTmpBuf;
-        pWindow.uFrameWidth = 384;
-        pWindow.uFrameHeight = 180;
-        pWindow.uFrameY = 40;
-        if ( (signed int)pX <= 320 )
-          v10 = pX + 30;
-        else
-          v10 = pX - 414;
-        pWindow.uFrameX = v10;
-		pWindow.DrawMessageBox(0);
-        goto LABEL_132;
-      }
-      v9 = pX + pSRZBufferLineOffsets[pY];
-      if ( !(pRenderer->pActiveZBuffer[v9] & 0xFFFF) )
-        goto LABEL_132;
-      v8 = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + 18* *((short *)&pChests[0].igChestItems[139].uExpireTime
-                       + (pRenderer->pActiveZBuffer[v9] & 0xFFFF) + 2662 * (unsigned int)pChestWindow->ptr_1C + 3));
-    }
-    else
-    {
-      if ( pCurrentScreen )
-      {
-        if ( pCurrentScreen != SCREEN_BOOKS )
-        {
-          if ( pCurrentScreen != SCREEN_CHARACTERS )
-          {
-            if ( pCurrentScreen == SCREEN_SPELL_BOOK )
-            {
-              if ( dword_507B00_spell_info_to_draw_in_popup )
-                DrawSpellDescriptionPopup(dword_507B00_spell_info_to_draw_in_popup - 1);
-            }
-            goto LABEL_132;
-          }
-LABEL_119:
-          if ( (signed int)pX > 467 && pCurrentScreen != SCREEN_E )
-          {
-            identify_item();
-            goto LABEL_132;
-          }
-          if ( (signed int)pY >= 345 )
-            goto LABEL_132;
-          if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 100 )//2DEvent - CharacerScreenStats
-          {
-            CharacterUI_StatsTab_ShowHint();
-            goto LABEL_132;
-          }
-          if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 101 )//2DEvent - CharacerScreenSkills
-          {
-            CharacterUI_SkillsTab_ShowHint();
-            goto LABEL_132;
-          }
-          v11 = pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103;//2DEvent - CharacerScreenInventory
-          if ( !v11 )
-            goto LABEL_132;
- 		  identify_item();
-          goto LABEL_132;
-        }
+
+  switch(pCurrentScreen)
+  {
+    case SCREEN_CASTING:
+		{
+		identify_item();
+		break;
+		}
+
+    case SCREEN_CHEST:
+		{
+        if ( !pPlayers[uActiveCharacter]->CanAct() )
+		{
+			sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[427],//%s не в состоянии %s
+				pPlayers[uActiveCharacter]->pName, pGlobalTXT_LocalizationStrings[541]);//Опознать предметы
+			pWindow.Hint = pTmpBuf;
+			pWindow.uFrameWidth = 384;
+			pWindow.uFrameHeight = 180;
+			pWindow.uFrameY = 40;
+			if ( (signed int)pX <= 320 )
+				v10 = pX + 30;
+			else
+				v10 = pX - 414;
+			pWindow.uFrameX = v10;
+			pWindow.DrawMessageBox(0);
+		}
+		else
+		{
+			v9 = pX + pSRZBufferLineOffsets[pY];
+			if ( pRenderer->pActiveZBuffer[v9] & 0xFFFF )
+			{
+				v8 = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + 18* *((short *)&pChests[0].igChestItems[139].uExpireTime
+								+ (pRenderer->pActiveZBuffer[v9] & 0xFFFF) + 2662 * (unsigned int)pChestWindow->ptr_1C + 3));
+				GameUI_DrawItemInfo(v8);
+			}
+		}
+		break;
+		}
+    case SCREEN_GAME:
+		{
+		if (GetCurrentMenuID() > 0)
+			break;
+
+		if ( (signed int)pY > (signed int)pViewport->uViewportW )
+		{
+			pWindow.ptr_1C = (void *)((signed int)pX / 118);
+			if ( (signed int)pX / 118 < 4 )
+			{
+				pWindow.Hint = 0;
+				pWindow.uFrameWidth = 400;
+				pWindow.uFrameHeight = 200;
+				pWindow.uFrameX = 38;
+				pWindow.uFrameY = 60;
+				pAudioPlayer->StopChannels(-1, -1);
+				pWindow.DrawQuickCharRecord();
+			}
+		}
+		else if ( (signed int)pX > (signed int)pViewport->uViewportZ )
+		{
+			if ( (signed int)pY >= 130 )
+			{
+				if ( (signed int)pX >= 476 && (signed int)pX <= 636 && (signed int)pY >= 240 && (signed int)pY <= 300 )
+				{
+					pWindow.Hint = 0;
+					pWindow.uFrameWidth = 400;
+					pWindow.uFrameHeight = 200;
+					pWindow.uFrameX = 38;
+					pWindow.uFrameY = 60;
+					pAudioPlayer->StopChannels(-1, -1);
+					pWindow._41D73D_draw_buff_tooltip();
+				}
+				else if ( (signed int)pX < 485 || (signed int)pX > 548 || (signed int)pY < 156 || (signed int)pY > 229 )
+				{
+					if (!( (signed int)pX < 566 || (signed int)pX > 629 || (signed int)pY < 156 || (signed int)pY > 229 ))
+					{
+						pAudioPlayer->StopChannels(-1, -1);
+						v3 = (void *)1;
+					}
+					else
+					{
+						sub_416B01(v3);
+					}
+				}
+				else
+				{
+					pAudioPlayer->StopChannels(-1, -1);
+					v3 = 0;
+					sub_416B01(v3);
+				}
+			}
+			else
+			{
+				pWindow.Hint = _4443D5_GetMinimapRightClickText();
+				pWindow.uFrameWidth = 256;
+				pWindow.uFrameX = 130;
+				pWindow.uFrameY = 140;
+				pWindow.uFrameHeight = 64;
+				pAudioPlayer->StopChannels(-1, -1);
+				pWindow.DrawMessageBox(0);
+			}
+		}
+		else
+		{
+			pWindow.Hint = 0;
+			pWindow.uFrameWidth = 320;
+			pWindow.uFrameHeight = 320;
+			v4 = pX - 350;
+			if ( (signed int)pX <= 320 )
+				v4 = pX + 30;
+			pWindow.uFrameX = v4;
+			pWindow.uFrameY = 40;
+			if ( pRenderer->pRenderD3D )
+				LOWORD(v5) = pGame->pVisInstance->get_picked_object_zbuf_val();
+			else
+				v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];
+			v6 = (unsigned __int16)v5;
+			if ( (v6 & 7) != OBJECT_Item)
+			{
+				if ( (v6 & 7) == OBJECT_Actor)
+				{
+					if ( pRenderer->uNumSceneBegins )
+					{
+					pWindow.DrawMessageBox(1);
+					MonsterPopup_Draw(v6 >> 3, &pWindow);
+					}
+					else
+					{
+					pRenderer->BeginScene();
+					pWindow.DrawMessageBox(1);
+					MonsterPopup_Draw(v6 >> 3, &pWindow);
+					pRenderer->EndScene();
+					}
+				}
+			}
+			else
+			{
+				v7 = v6 >> 3;
+				if ( ! (pObjectList->pObjects[pSpriteObjects[v7].uObjectDescID].uFlags & 0x10 ) )
+				{
+					v8 = &pSpriteObjects[v7].stru_24;
+					GameUI_DrawItemInfo(v8);
+				}
+			}
+		}
+		break;
+		}
+    case SCREEN_BOOKS:
+		{
         if ( !dword_506364
           || (signed int)pX < (signed int)pViewport->uViewportX
           || (signed int)pX > (signed int)pViewport->uViewportZ
           || (signed int)pY < (signed int)pViewport->uViewportY
           || (signed int)pY > (signed int)pViewport->uViewportW
           || (v2 = (char *)sub_444564(), (pWindow.Hint = v2) == 0) )
-          goto LABEL_132;
+          break;
         v30 = (double)(pFontArrus->GetLineWidth(v2) + 32);
         v27 = v30 + 6.7553994e15;
         v29 = (char *)LODWORD(v27);
@@ -16330,205 +16412,137 @@
 		pWindow.uFrameHeight = 64;
         pAudioPlayer->StopChannels(-1, -1);
         pWindow.DrawMessageBox(0);
-        goto LABEL_132;
-      }
-      if (GetCurrentMenuID() > 0)
-        goto LABEL_132;
-
-      if ( (signed int)pY > (signed int)pViewport->uViewportW )
-      {
-        pWindow.ptr_1C = (void *)((signed int)pX / 118);
-        if ( (signed int)pX / 118 < 4 )
-        {
-          pWindow.Hint = 0;
-          pWindow.uFrameWidth = 400;
-          pWindow.uFrameHeight = 200;
-          pWindow.uFrameX = 38;
-          pWindow.uFrameY = 60;
-          pAudioPlayer->StopChannels(-1, -1);
-          pWindow.DrawQuickCharRecord();
-        }
-        goto LABEL_132;
-      }
-      if ( (signed int)pX > (signed int)pViewport->uViewportZ )
-      {
-        if ( (signed int)pY >= 130 )
-        {
-          if ( (signed int)pX >= 476 && (signed int)pX <= 636 && (signed int)pY >= 240 && (signed int)pY <= 300 )
-          {
-            pWindow.Hint = 0;
-            pWindow.uFrameWidth = 400;
-            pWindow.uFrameHeight = 200;
-            pWindow.uFrameX = 38;
-            pWindow.uFrameY = 60;
-            pAudioPlayer->StopChannels(-1, -1);
-            pWindow._41D73D_draw_buff_tooltip();
-            goto LABEL_132;
-          }
-          if ( (signed int)pX < 485 || (signed int)pX > 548 || (signed int)pY < 156 || (signed int)pY > 229 )
-          {
-            if ( (signed int)pX < 566 || (signed int)pX > 629 || (signed int)pY < 156 || (signed int)pY > 229 )
-              goto LABEL_132;
-            pAudioPlayer->StopChannels(-1, -1);
-            v3 = (void *)1;
-          }
-          else
-          {
-            pAudioPlayer->StopChannels(-1, -1);
-            v3 = 0;
-          }
-          sub_416B01(v3);
-          goto LABEL_132;
-        }
-        pWindow.Hint = _4443D5_GetMinimapRightClickText();
-        pWindow.uFrameWidth = 256;
-        pWindow.uFrameX = 130;
-        pWindow.uFrameY = 140;
-        pWindow.uFrameHeight = 64;
-        pAudioPlayer->StopChannels(-1, -1);
-        pWindow.DrawMessageBox(0);
-        goto LABEL_132;
-      }
-      pWindow.Hint = 0;
-      pWindow.uFrameWidth = 320;
-      pWindow.uFrameHeight = 320;
-      v4 = pX - 350;
-      if ( (signed int)pX <= 320 )
-        v4 = pX + 30;
-      pWindow.uFrameX = v4;
-      pWindow.uFrameY = 40;
-      if ( pRenderer->pRenderD3D )
-        LOWORD(v5) = pGame->pVisInstance->get_picked_object_zbuf_val();
-      else
-        v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];
-      v6 = (unsigned __int16)v5;
-      if ( (v6 & 7) != OBJECT_Item)
-      {
-        if ( (v6 & 7) == OBJECT_Actor)
-        {
-          if ( pRenderer->uNumSceneBegins )
-          {
-            pWindow.DrawMessageBox(1);
-            MonsterPopup_Draw(v6 >> 3, &pWindow);
-          }
-          else
-          {
-            pRenderer->BeginScene();
-            pWindow.DrawMessageBox(1);
-            MonsterPopup_Draw(v6 >> 3, &pWindow);
-            pRenderer->EndScene();
-          }
-        }
-        goto LABEL_132;
-      }
-      v7 = v6 >> 3;
-      if ( pObjectList->pObjects[pSpriteObjects[v7].uObjectDescID].uFlags & 0x10 )
-        goto LABEL_132;
-      v8 = &pSpriteObjects[v7].stru_24;
-    }
-    GameUI_DrawItemInfo(v8);
-    goto LABEL_132;
-  }
-  if ( pCurrentScreen == SCREEN_HOUSE )
-  {
-    if ( (signed int)pY < 345 && (signed int)pX < 469 )
-      sub_4B1A2D();//identify item in inventory
-    goto LABEL_132;
-  }
-  if ( pCurrentScreen <= SCREEN_HOUSE )
-    goto LABEL_132;
-  if ( pCurrentScreen <= SCREEN_F )
-    goto LABEL_119;
-  if ( pCurrentScreen != SCREEN_PARTY_CREATION )
-  {
-    v11 = pCurrentScreen == SCREEN_CASTING;
-    if ( !v11 )
-      goto LABEL_132;
-    identify_item();
-    goto LABEL_132;
-  }
-  pWindow.Hint = 0;
-  pStr = 0;
-  for ( pButton = pGUIWindow_CurrentMenu->pControlsHead; pButton; pButton = pButton->pNext)
-  {
-    if ( pButton->uButtonType == 1 && pButton->uButtonType != 3 && (signed int)pX > (signed int)pButton->uX && (signed int)pX < (signed int)pButton->uZ
-      && (signed int)pY > (signed int)pButton->uY && (signed int)pY < (signed int)pButton->uW )
-    {
-     pControlID = pButton->uControlID;
-     switch ( pControlID )
-	 {
-	 case 0: //stats info
-      pWindow.Hint = pAttributeDescriptions[(signed int)pButton->uControlParam % 7];
-      pStr = aAttributeNames[(signed int)pButton->uControlParam % 7];
-      break;
-	 case 62: //Plus button info 
-      pStr = pGlobalTXT_LocalizationStrings[670];//Добавить
-      pWindow.Hint = pGlobalTXT_LocalizationStrings[671];//"Добавляет очко к выделенному навыку, забирая его из накопителя очков"
-	  break;
-	 case 63: //Minus button info
-      pStr = pGlobalTXT_LocalizationStrings[668];//Вычесть
-      pWindow.Hint = pGlobalTXT_LocalizationStrings[669];//"Вычитает очко из выделенного навыка, возвращая его в накопитель очков"
-	  break;
-	 case 64: //Available skill button info
-      v18 = pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(pButton->uControlParam + 4);
-      pStr = pSkillNames[v18];
-      pWindow.Hint = pSkillDesc[v18];
-	  break;
-	 case 65: //Available Class Info
-      pWindow.Hint = pClassDescriptions[pButton->uControlParam];
-      pStr = pClassNames[pButton->uControlParam];
-	  break;
-     case 66: //OK Info
-      pWindow.Hint = pGlobalTXT_LocalizationStrings[664];//Щелкните здесь для утверждения состава отряда и продолжения игры.
-      pStr = pGlobalTXT_LocalizationStrings[665];//Кнопка ОК
-	  break;
-	 case 67: //Clear info
-      pWindow.Hint = pGlobalTXT_LocalizationStrings[666];//Сбрасывает все параметры и навыки отряда.
-      pStr = pGlobalTXT_LocalizationStrings[667];//Кнопка Очистить
-      break;
-	 case 118: // Character info
-      pStr = pParty->pPlayers[pButton->uControlParam].pName;
-      pWindow.Hint = pClassDescriptions[pParty->pPlayers[pButton->uControlParam].classType];
-      break;
-     }
-     if ( pControlID > 68 && pControlID <= 75 ) //Sellected skills info
-     {
-      pSkillId = pParty->pPlayers[pButton->uControlParam].GetSkillIdxByOrder(pControlID - 72);
-      pY = 0;
-      if ( (signed int)pSkillId < 37 )
-      {
-	   pSkillInfo = CharacterUI_GetSkillDescText(pButton->uControlParam, (enum PLAYER_SKILL_TYPE)pSkillId);
-       strcpy(pTmpBuf2, pSkillInfo);
-       pWindow.Hint = pTmpBuf2;
-       pStr = pSkillNames[pSkillId];
-	  }
-     }
-	}
-  }
-  if ( pWindow.Hint )
-  {
-    pHint = pWindow.Hint;
-    pWindow.Hint = 0;
-    pWindow.uFrameWidth = 384;
-    pWindow.uFrameHeight = 256;
-    pWindow.uFrameX = 128;
-    pWindow.uFrameY = 40;
-    pWindow.uFrameHeight = pFontSmallnum->CalcTextHeight(pHint, &pWindow, 24, 0) + 2 * LOBYTE(pFontLucida->uFontHeight) + 24;
-    pWindow.uFrameZ = pWindow.uFrameX + pWindow.uFrameWidth - 1;
-    pWindow.uFrameW = pWindow.uFrameY + pWindow.uFrameHeight - 1;
-    pWindow.DrawMessageBox(0);
-    pWindow.uFrameX += 12;
-    pWindow.uFrameWidth -= 24;
-    pWindow.uFrameY += 12;
-    pWindow.uFrameHeight -= 12;
-    pWindow.uFrameZ = pWindow.uFrameX + pWindow.uFrameWidth - 1;
-    pWindow.uFrameW = pWindow.uFrameY + pWindow.uFrameHeight - 1;
-    pColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0x9B);
-    sprintf(pTmpBuf, format_4E2D80, pColor, pStr);//"\f%05d%s\f00000\n"
-    pWindow.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf, 3);
-    pWindow.DrawText(pFontSmallnum, 1, pFontLucida->uFontHeight, 0, pHint, 0, 0, 0);
-  }
-LABEL_132:
+		break;
+		}
+	case SCREEN_CHARACTERS:
+	case SCREEN_E:
+	case SCREEN_F:
+		{
+		if ( (signed int)pX > 467 && pCurrentScreen != SCREEN_E )
+		{
+			identify_item();
+		}
+		else if ( (signed int)pY >= 345 )
+			break;
+		else if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 100 )//2DEvent - CharacerScreenStats
+		{
+			CharacterUI_StatsTab_ShowHint();
+		}
+		else if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 101 )//2DEvent - CharacerScreenSkills
+		{
+			CharacterUI_SkillsTab_ShowHint();
+		}
+		else
+		{
+			v11 = pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103;//2DEvent - CharacerScreenInventory
+			if ( v11 )
+	 			identify_item();
+		}
+		break;
+		}
+	case SCREEN_SPELL_BOOK:
+		{
+		if ( dword_507B00_spell_info_to_draw_in_popup )
+			DrawSpellDescriptionPopup(dword_507B00_spell_info_to_draw_in_popup - 1);
+		break;
+		}
+	case SCREEN_HOUSE:
+		{
+		if ( (signed int)pY < 345 && (signed int)pX < 469 )
+			sub_4B1A2D();//identify item in inventory
+		break;
+		}
+
+	case SCREEN_PARTY_CREATION:
+		{
+		pWindow.Hint = 0;
+		pStr = 0;
+		for ( pButton = pGUIWindow_CurrentMenu->pControlsHead; pButton; pButton = pButton->pNext)
+		{
+			if ( pButton->uButtonType == 1 && pButton->uButtonType != 3 && (signed int)pX > (signed int)pButton->uX && (signed int)pX < (signed int)pButton->uZ
+				&& (signed int)pY > (signed int)pButton->uY && (signed int)pY < (signed int)pButton->uW )
+			{
+				pControlID = pButton->uControlID;
+				switch ( pControlID )
+				{
+					case 0: //stats info
+					pWindow.Hint = pAttributeDescriptions[(signed int)pButton->uControlParam % 7];
+					pStr = aAttributeNames[(signed int)pButton->uControlParam % 7];
+					break;
+					case 62: //Plus button info 
+					pStr = pGlobalTXT_LocalizationStrings[670];//Добавить
+					pWindow.Hint = pGlobalTXT_LocalizationStrings[671];//"Добавляет очко к выделенному навыку, забирая его из накопителя очков"
+					break;
+					case 63: //Minus button info
+					pStr = pGlobalTXT_LocalizationStrings[668];//Вычесть
+					pWindow.Hint = pGlobalTXT_LocalizationStrings[669];//"Вычитает очко из выделенного навыка, возвращая его в накопитель очков"
+					break;
+					case 64: //Available skill button info
+					v18 = pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(pButton->uControlParam + 4);
+					pStr = pSkillNames[v18];
+					pWindow.Hint = pSkillDesc[v18];
+					break;
+					case 65: //Available Class Info
+					pWindow.Hint = pClassDescriptions[pButton->uControlParam];
+					pStr = pClassNames[pButton->uControlParam];
+					break;
+					case 66: //OK Info
+					pWindow.Hint = pGlobalTXT_LocalizationStrings[664];//Щелкните здесь для утверждения состава отряда и продолжения игры.
+					pStr = pGlobalTXT_LocalizationStrings[665];//Кнопка ОК
+					break;
+					case 67: //Clear info
+					pWindow.Hint = pGlobalTXT_LocalizationStrings[666];//Сбрасывает все параметры и навыки отряда.
+					pStr = pGlobalTXT_LocalizationStrings[667];//Кнопка Очистить
+					break;
+					case 118: // Character info
+					pStr = pParty->pPlayers[pButton->uControlParam].pName;
+					pWindow.Hint = pClassDescriptions[pParty->pPlayers[pButton->uControlParam].classType];
+					break;
+				}
+				if ( pControlID > 68 && pControlID <= 75 ) //Sellected skills info
+				{
+					pSkillId = pParty->pPlayers[pButton->uControlParam].GetSkillIdxByOrder(pControlID - 72);
+					pY = 0;
+					if ( (signed int)pSkillId < 37 )
+					{
+						pSkillInfo = CharacterUI_GetSkillDescText(pButton->uControlParam, (enum PLAYER_SKILL_TYPE)pSkillId);
+						strcpy(pTmpBuf2, pSkillInfo);
+						pWindow.Hint = pTmpBuf2;
+						pStr = pSkillNames[pSkillId];
+					}
+				}
+			}
+		}
+		if ( pWindow.Hint )
+		{
+			pHint = pWindow.Hint;
+			pWindow.Hint = 0;
+			pWindow.uFrameWidth = 384;
+			pWindow.uFrameHeight = 256;
+			pWindow.uFrameX = 128;
+			pWindow.uFrameY = 40;
+			pWindow.uFrameHeight = pFontSmallnum->CalcTextHeight(pHint, &pWindow, 24, 0) + 2 * LOBYTE(pFontLucida->uFontHeight) + 24;
+			pWindow.uFrameZ = pWindow.uFrameX + pWindow.uFrameWidth - 1;
+			pWindow.uFrameW = pWindow.uFrameY + pWindow.uFrameHeight - 1;
+			pWindow.DrawMessageBox(0);
+			pWindow.uFrameX += 12;
+			pWindow.uFrameWidth -= 24;
+			pWindow.uFrameY += 12;
+			pWindow.uFrameHeight -= 12;
+			pWindow.uFrameZ = pWindow.uFrameX + pWindow.uFrameWidth - 1;
+			pWindow.uFrameW = pWindow.uFrameY + pWindow.uFrameHeight - 1;
+			pColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0x9B);
+			sprintf(pTmpBuf, format_4E2D80, pColor, pStr);//"\f%05d%s\f00000\n"
+			pWindow.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf, 3);
+			pWindow.DrawText(pFontSmallnum, 1, pFontLucida->uFontHeight, 0, pHint, 0, 0, 0);
+		}
+		break;
+		}
+	default:
+		{
+		break;
+		}
+  }
   dword_507BF0_is_there_popup_onscreen = 1;
   viewparams->bRedrawGameUI = 1;
 }