changeset 578:fdea951756f9

Слияние
author Ritor1
date Tue, 05 Mar 2013 10:45:40 +0600
parents 7e8f5124056c (current diff) 6f7d936edc9b (diff)
children a295c9f956d1
files mm7_3.cpp
diffstat 22 files changed, 2051 insertions(+), 2382 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Tue Mar 05 10:45:29 2013 +0600
+++ b/Actor.cpp	Tue Mar 05 10:45:40 2013 +0600
@@ -3882,6 +3882,9 @@
         uCurrentActionAnimation = ANIM_Dead;
     break;
 
+    case Removed:
+      return;
+
     default:
       assert(false);
   }
--- a/GUIWindow.cpp	Tue Mar 05 10:45:29 2013 +0600
+++ b/GUIWindow.cpp	Tue Mar 05 10:45:40 2013 +0600
@@ -203,10 +203,7 @@
         uFramesetID = 1;
       if ( pPlayer->expression == CHARACTER_EXPRESSION_21)
       {
-        v15 = pPlayerFrameTable->GetFrameBy_y(
-                &pPlayer->field_1AA8,
-                &pPlayer->field_1AA4,
-                pMiscTimer->uTimeElapsed);
+        v15 = pPlayerFrameTable->GetFrameBy_y(&pPlayer->_expression21_frameset, &pPlayer->_expression21_animtime, pMiscTimer->uTimeElapsed);
       }
       else
       {
@@ -1581,7 +1578,7 @@
     }
     while ( (signed int)Str1a < (signed int)pNumLen );
   }
-  pTmpBuf[Str1a + 1999] = 0;
+  pTmpBuf2[Str1a - 1] = 0;
   pNumLen = strlen(pTmpBuf2);
   v28 = pFont->GetLineWidth(pTmpBuf2);
   if ( a8 )
--- a/GUIWindow.h	Tue Mar 05 10:45:29 2013 +0600
+++ b/GUIWindow.h	Tue Mar 05 10:45:40 2013 +0600
@@ -408,4 +408,11 @@
 
 extern int pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[]; // idb
 extern struct GUIWindow *pWindow_MainMenu;
-extern struct GUIWindow pWindowList[20];
\ No newline at end of file
+extern struct GUIWindow pWindowList[20];
+
+
+
+
+
+
+void QuickRefDraw();
\ No newline at end of file
--- a/GameUIs.cpp	Tue Mar 05 10:45:29 2013 +0600
+++ b/GameUIs.cpp	Tue Mar 05 10:45:40 2013 +0600
@@ -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/Indoor.cpp	Tue Mar 05 10:45:29 2013 +0600
+++ b/Indoor.cpp	Tue Mar 05 10:45:40 2013 +0600
@@ -2679,28 +2679,28 @@
     j += pSector->uNumFloors;
 
     pSector->pWalls = ptr_0002B0_sector_rdata + j;
-    j += pSector->field_C;
+    j += pSector->uNumWalls;
 
     pSector->pCeilings = ptr_0002B0_sector_rdata + j;
-    j += pSector->field_14;
+    j += pSector->uNumCeilings;
 
     pSector->pFluids = ptr_0002B0_sector_rdata + j;
-    j += pSector->field_1C;
+    j += pSector->uNumFluids;
 
     pSector->pPortals = ptr_0002B0_sector_rdata + j;
     j += pSector->uNumPortals;
 
     pSector->pFaceIDs = ptr_0002B0_sector_rdata + j;
-    j += pSector->field_2C;
+    j += pSector->uNumFaces;
 
     pSector->pCogs = ptr_0002B0_sector_rdata + j;
-    j += pSector->field_3C;
+    j += pSector->uNumCogs;
 
     pSector->pDecorationIDs = ptr_0002B0_sector_rdata + j;
     j += pSector->uNumDecorations;
 
     pSector->pMarkers = ptr_0002B0_sector_rdata + j;
-    j += pSector->field_4C;
+    j += pSector->uNumMarkers;
 
 
     //do
@@ -2758,8 +2758,8 @@
 
   for (uint i = 0, j = 0; i < uNumSectors; ++i)
   {
-    pSectors->pLights = (unsigned __int16 *)(ptr_0002B8_sector_lrdata + j);
-    j += pSectors->uNumLights;
+    pSectors[i].pLights = ptr_0002B8_sector_lrdata + j;
+    j += pSectors[i].uNumLights;
   }
 
   pGameLoadingUI_ProgressBar->Progress();
@@ -3712,8 +3712,7 @@
             v25 = abs(v15->pFacePlane_old.vNormal.z);
             //v26 = v87;
             if ( v24 > v25 )
-              Abortf(
-                "Door Error\ndoor id: %i\nfacet no: %i\n\nOverflow dividing facet->d [%i] by facet->nz [%i]",
+              Abortf("Door Error\ndoor id: %i\nfacet no: %i\n\nOverflow dividing facet->d [%i] by facet->nz [%i]",
                 door->uDoorID,
                 door->pFaceIDs[v88],
                 v15->pFacePlane_old.dist,
@@ -3837,8 +3836,7 @@
             {
               v52 = v15->uBitmapID;
               if ( v52 != -1 )
-                v28->sTextureDeltaV -= v82
-                                     + *(short *)((signed __int16)v52 != -1 ? 72 * (signed __int16)v52 + 7278780 + 0x1A : 26);
+                v28->sTextureDeltaV -= v82 + (v52 != -1 ? pBitmaps_LOD->pTextures[v52].uTextureHeight : 26);
             }
           }
           if ( BYTE2(v15->uAttributes) & 4 )
@@ -3886,7 +3884,9 @@
           }
           //v2 = v87;
         }
-        LOWORD(v39) = v84 + ((signed __int16)v39 != -1 ? pBitmaps_LOD->pTextures[(signed __int16)v39].uTextureWidth : 24);
+        LOWORD(v39) = v84;
+        if (v15->uBitmapID != -1)
+          LOWORD(v39) += pBitmaps_LOD->pTextures[v15->uBitmapID].uTextureWidth;
 LABEL_50:
         v28->sTextureDeltaU -= v39;
         goto LABEL_51;
--- a/Indoor.h	Tue Mar 05 10:45:29 2013 +0600
+++ b/Indoor.h	Tue Mar 05 10:45:40 2013 +0600
@@ -347,34 +347,34 @@
   unsigned __int16 uNumFloors;
   __int16 field_6;
   unsigned __int16 *pFloors;
-  __int16 field_C;
+  unsigned __int16 uNumWalls;
   __int16 field_E;
   unsigned __int16 *pWalls;
-  __int16 field_14;
+  unsigned __int16 uNumCeilings;
   __int16 field_16;
   unsigned __int16 *pCeilings;
-  __int16 field_1C;
+  unsigned __int16 uNumFluids;
   __int16 field_1E;
   unsigned __int16 *pFluids;
   __int16 uNumPortals;
   __int16 field_26;
   unsigned __int16 *pPortals;
-  __int16 field_2C;
-  __int16 uNumNonBSPFaces;
+  unsigned __int16 uNumFaces;
+  unsigned __int16 uNumNonBSPFaces;
   unsigned __int16 *pFaceIDs;
-  __int16 uNumCylinderFaces;
+  unsigned __int16 uNumCylinderFaces;
   __int16 field_36;
   int pCylinderFaces;
-  __int16 field_3C;
+  unsigned __int16 uNumCogs;
   __int16 field_3E;
   unsigned __int16 *pCogs;
   unsigned __int16 uNumDecorations;
   __int16 field_46;
   unsigned __int16 *pDecorationIDs;
-  __int16 field_4C;
+  unsigned __int16 uNumMarkers;
   __int16 field_4E;
   unsigned __int16 *pMarkers;
-  __int16 uNumLights;
+  unsigned __int16 uNumLights;
   __int16 field_56;
   unsigned __int16 *pLights;
   __int16 uWaterLevel;
--- a/Items.cpp	Tue Mar 05 10:45:29 2013 +0600
+++ b/Items.cpp	Tue Mar 05 10:45:40 2013 +0600
@@ -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 10:45:29 2013 +0600
+++ b/Items.h	Tue Mar 05 10:45:40 2013 +0600
@@ -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/LOD.cpp	Tue Mar 05 10:45:29 2013 +0600
+++ b/LOD.cpp	Tue Mar 05 10:45:40 2013 +0600
@@ -1691,7 +1691,7 @@
   if ( !this->pIOBuffer || !this->uIOBufferSize )
     return 3;
   v7 = this->uNumSubIndices == 0;
-  v8 = this->uNumSubIndices != 0; // v8 = (this->uNumSubIndices & 0x80000000u) != 0;
+  v8 = false;//this->uNumSubIndices != 0; // v8 = (this->uNumSubIndices & 0x80000000u) != 0;
   v36 = 0;
   v34 = 0;
   if ( v8 | v7 )
@@ -1703,7 +1703,7 @@
   while ( 1 )
   {
     v9 = pDir;
-    v10 = _strcmpi((const char *)v4->pSubIndices + v35, (const char *)pDir);
+    v10 = _strcmpi(v4->pSubIndices[v5].pFilename + v35, pDir->pFilename);
     if ( v10 )
     {
       if ( v10 > 0 )
@@ -1722,7 +1722,8 @@
     v11 = v5 >= v4->uNumSubIndices;
     v8 = (v5 - v4->uNumSubIndices) != 0;//v8 = ((v5 - v4->uNumSubIndices) & 0x80000000u) != 0;
     v34 = v5;
-    if ( !(v8 ^ v11) )
+    //if ( !(v8 ^ v11) )
+    if (v5 >= v4->uNumSubIndices)
       goto LABEL_22;
   }
   v12 = pDir->uNumSubIndices;
--- a/Party.cpp	Tue Mar 05 10:45:29 2013 +0600
+++ b/Party.cpp	Tue Mar 05 10:45:40 2013 +0600
@@ -256,21 +256,10 @@
 //----- (0049135E) --------------------------------------------------------
 unsigned int Party::GetPartyFame()
 {
-  signed int v1; // eax@1
-  Player *v2; // ecx@1
-  signed int v3; // edx@1
-
-  v1 = 0;
-  v2 = this->pPlayers;//[0].uExperience;
-  v3 = 4;                                       // (E exp) / 1000
-  do
-  {
-	v1 += (int)v2->uExperience; // needs review
-    ++v2;
-    --v3;
-  }
-  while ( v3 );
-  return v1 / 1000;
+  unsigned __int64 total_exp = 0;
+  for (uint i = 0; i < 4; ++i)
+    total_exp += pPlayers[i].uExperience;
+  return total_exp / 1000;
 }
 
 //----- (0049137D) --------------------------------------------------------
--- a/Player.cpp	Tue Mar 05 10:45:29 2013 +0600
+++ b/Player.cpp	Tue Mar 05 10:45:40 2013 +0600
@@ -2298,6 +2298,9 @@
   field_100 = 0;
   field_104 = 0;
 
+  _expression21_animtime = 0;
+  _expression21_frameset = 0;
+
   lastOpenedSpellbookPage = 0;
 }
 
--- a/Player.h	Tue Mar 05 10:45:29 2013 +0600
+++ b/Player.h	Tue Mar 05 10:45:40 2013 +0600
@@ -717,8 +717,8 @@
   unsigned __int16 uExpressionTimePassed;
   unsigned __int16 uExpressionTimeLength;
   __int16 field_1AA2;
-  int field_1AA4;
-  int field_1AA8;
+  int _expression21_animtime;
+  int _expression21_frameset;
   LloydBeacon pInstalledBeacons[5];
   char uNumDivineInterventionCastsThisDay;
   char uNumArmageddonCasts;
--- a/SaveLoad.cpp	Tue Mar 05 10:45:29 2013 +0600
+++ b/SaveLoad.cpp	Tue Mar 05 10:45:40 2013 +0600
@@ -301,10 +301,11 @@
   std::string *v71; // [sp+268h] [bp-8h]@8
   int a3; // [sp+26Fh] [bp-1h]@8
   
-  v66 = a2;
+  //v66 = a2;
   strcpy(byte_6BE3B0, pCurrentMapName);
-  if (!_strcmpi(pCurrentMapName, "d05.blv"))
+  if (!_strcmpi(pCurrentMapName, "d05.blv")) // arena
     return false;
+
   DstBuf = malloc(0xF4240);
   pDir.Reset();
   pPositionX = pParty->vPosition.x;
@@ -328,16 +329,17 @@
   free(pScreenshot);
   if (pCurrentScreen == SCREEN_SAVEGAME)
   {
-    pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
-    pRenderer->DrawTextureIndexed(0x12, 0x8D, (Texture *)(uTextureID_save_up != -1 ? &pIcons_LOD->pTextures[uTextureID_save_up] : 0));
+    pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave));
+    pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_save_up));
     v4 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[190]);
     pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v4 + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //
-    v5 = pFontSmallnum->AlignText_Center(0xBA, (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot);
-    pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v5 + 25, 0x103u, 0, (const char *)(&pSavegameHeader + uLoadGameUI_SelectedSlot), 185, 0);
+    v5 = pFontSmallnum->AlignText_Center(0xBA, pSavegameHeader[uLoadGameUI_SelectedSlot].pName);
+    pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v5 + 25, 0x103u, 0, pSavegameHeader[uLoadGameUI_SelectedSlot].pName, 185, 0);
     v6 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[165]);
     pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v6 + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //, 
     pRenderer->Present();
-   }
+  }
+
   if (pNew_LOD->Write(&pDir, DstBuf, 0))
   {
     sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200); //  ! Code=%d
@@ -379,7 +381,8 @@
     MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0);
   }
   strcpy(pDir.pFilename, "npcdata.bin");
-  pDir.uDataSize = 38076;
+  pDir.uDataSize = 501 * sizeof(NPCData);
+  assert(pDir.uDataSize == 38076);
   if ( pNew_LOD->Write(&pDir, pNPCStats->pNewNPCData, 0) )
   {
     sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205);
@@ -535,7 +538,7 @@
       if ( (signed int)uNumLevelDecorations > 0 )
       {
         v66 = &pLevelDecorations[0].field_2;
-        for (int i =  0; i <= (signed int)uNumLevelDecorations; ++i)
+        for (int i = 0; i <= (signed int)uNumLevelDecorations; ++i)
         {
           memcpy(v22, v66, 2);
           v66 += 16;
@@ -609,43 +612,39 @@
 //----- (00460078) --------------------------------------------------------
 void __fastcall DoSavegame(unsigned int uSlot)
 {
-  unsigned int v1; // esi@1
-  int v2; // esi@2
-  RGBTexture *v3; // ebx@3
+  //unsigned int v1; // esi@1
+  //int v2; // esi@2
+  //RGBTexture *v3; // ebx@3
   int bNotArena; // [sp+2Ch] [bp-8h]@1
-  unsigned int v6; // [sp+30h] [bp-4h]@1
+  //unsigned int v6; // [sp+30h] [bp-4h]@1
 
   //__debugbreak();
 
-  v1 = uSlot;
-  v6 = uSlot;
+  //v1 = uSlot;
+  //v6 = uSlot;
   bNotArena = _strcmpi(pCurrentMapName, "d05.blv");
   if ( bNotArena )
   {
     LOD::Directory pDir; // [sp+Ch] [bp-28h]@2
     SaveGame(0, 0);
-    v2 = 100 * v1;
-    strcpy(&pSavegameHeader->pLocationName[v2], pCurrentMapName);
-    *(int *)((char *)&pSavegameHeader->uWordTime + v2) = LODWORD(pParty->uTimePlayed);
-    *(int *)((char *)&pSavegameHeader->uWordTime + v2 + 4) = HIDWORD(pParty->uTimePlayed);
-    strcpy((char *)&pDir, "header.bin");
+    //v2 = 100 * v1;
+    strcpy(pSavegameHeader[uSlot].pLocationName, pCurrentMapName);
+    pSavegameHeader[uSlot].uWordTime = pParty->uTimePlayed;
+    strcpy(pDir.pFilename, "header.bin");
     pDir.uDataSize = 100;
-    pNew_LOD->Write(&pDir, (char *)&pSavegameHeader + v2, 0);
-    sprintf(pTmpBuf, "saves\\save%03d.mm7", v6);
+    pNew_LOD->Write(&pDir, &pSavegameHeader[uSlot], 0);
+    sprintf(pTmpBuf, "saves\\save%03d.mm7", uSlot);
     pNew_LOD->CloseWriteFile();
     CopyFileA("data\\new.lod", pTmpBuf, 0);
   }
   GUI_UpdateWindows();
   pGUIWindow_CurrentMenu->Release();
   pCurrentScreen = SCREEN_GAME;
-  v3 = pSavegameThumbnails;
+  //v3 = pSavegameThumbnails;
   viewparams->bRedrawGameUI = 1;
-  do
-  {
-    v3->Release();
-    ++v3;
-  }
-  while ( (signed int)v3 < (signed int)&unk_6A0758 );
+  for (uint i = 0; i < 45; i++)
+    pSavegameThumbnails[i].Release();
+  //while ( (signed int)v3 < (signed int)&unk_6A0758 );
   if ( bNotArena )
     pNew_LOD->_4621A7();
   else
@@ -653,7 +652,7 @@
   pIcons_LOD->_4355F7();
   pEventTimer->Resume();
   ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2u);// "Game Saved!"
-  viewparams->bRedrawGameUI = 1;
+  viewparams->bRedrawGameUI = true;
 }
 // 4E28F8: using guessed type int pCurrentScreen;
 
--- a/mm7_1.cpp	Tue Mar 05 10:45:29 2013 +0600
+++ b/mm7_1.cpp	Tue Mar 05 10:45:40 2013 +0600
@@ -985,24 +985,18 @@
   }
   while ( uCellID < 126 );
 }
-// 4E28F8: using guessed type int pCurrentScreen;
-// 507958: using guessed type int uTextureID_507958;
-// 50C9A8: using guessed type int dword_50C9A8;
 
 //----- (0041A556) --------------------------------------------------------
 void __cdecl draw_leather()
 {
-  pRenderer->DrawTextureIndexed(
-    8u,
-    8u,
-    (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0));
+  pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_Leather));
 }
 
 //----- (0041A57E) --------------------------------------------------------
-char __cdecl QuickRefDraw()
+void QuickRefDraw()
 {
   unsigned int v0; // ebx@1
-  unsigned int v1; // eax@1
+  //unsigned int v1; // eax@1
   Player *pPlayer; // ebp@2
   int v3; // eax@6
   int v4; // edi@6
@@ -1049,14 +1043,14 @@
   unsigned int v46; // [sp+1Ch] [bp-10h]@1
   unsigned int v47; // [sp+20h] [bp-Ch]@1
   unsigned int v48; // [sp+24h] [bp-8h]@33
-  unsigned int v49; // [sp+28h] [bp-4h]@1
+  //unsigned int v49; // [sp+28h] [bp-4h]@1
 
   v0 = 0;
   v47 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-  v49 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
+  //v49 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
   v46 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
-  v1 = pIcons_LOD->LoadTexture("quikref", TEXTURE_16BIT_PALETTE);
-  pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v1 != -1 ? &pIcons_LOD->pTextures[v1] : 0));
+  //v1 = pIcons_LOD->LoadTexture("quikref", TEXTURE_16BIT_PALETTE);
+  pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->LoadTexturePtr("quikref", TEXTURE_16BIT_PALETTE));
   v43 = 0;
   v45 = LOBYTE(pFontArrus->uFontHeight) + 1;
   do
@@ -1167,23 +1161,24 @@
     ++v43;
   }
   while ( v43 < 4 );
+
   v38 = GetPartyReputation();
   if ( v38 >= 0 )
   {
-    v39 = v49;
     if ( v38 <= 5 )
-      v39 = 65535;
+      v39 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0xFF);
+    else
+    v39 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0, 0);
   }
   else
-  {
     v39 = v46;
-  }
+
   v40 = GetReputationString(v38);
-  sprintf(pTmpBuf, "%s: ", pGlobalTXT_LocalizationStrings[180], v39, v40);//Reputation
+  sprintf(pTmpBuf, "%s: \xC" "%05d%s\xC" "00000", pGlobalTXT_LocalizationStrings[180], v39, v40);//Reputation
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 22, 323, 0, pTmpBuf, 0, 0, 0);
   v41 = pParty->GetPartyFame();
   sprintf(pTmpBuf, "\r261%s: %d", pGlobalTXT_LocalizationStrings[84], v41);// Fame 
-  return pGUIWindow_CurrentMenu->DrawText(pFontArrus, 0, 323, 0, pTmpBuf, 0, 0, 0);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 0, 323, 0, pTmpBuf, 0, 0, 0);
 }
 
 //----- (0041ABFD) --------------------------------------------------------
@@ -2233,8 +2228,8 @@
 
 
 //----- (0041D895) --------------------------------------------------------
-void GameUI_DrawItemInfo(ItemGen *ecx0)
-{
+void GameUI_DrawItemInfo( struct ItemGen* inspect_item )
+    {
   ItemGen *v1; // esi@1
   unsigned int v2; // eax@3
   //char *v3; // edi@5
@@ -2242,7 +2237,6 @@
   //unsigned int v5; // esi@5
   signed int v6; // eax@5
   int v7; // edx@5
-  ItemGen *v8; // ecx@10
   //unsigned int v9; // eax@12
   char v10; // zf@16
   ItemGen *v11; // eax@16
@@ -2264,7 +2258,7 @@
   int v27; // eax@67
   const char *v28; // edi@69
   int v29; // eax@70
-  char *v30; // edi@78
+  char v30; // edi@78
   const char *v31; // eax@78
   int v32; // ecx@81
   unsigned int v33; // eax@81
@@ -2296,7 +2290,7 @@
   int v59; // [sp-8h] [bp-280h]@56
   int v60; // [sp-8h] [bp-280h]@58
   unsigned int v61; // [sp-8h] [bp-280h]@110
-  char a1[300]; // [sp+8h] [bp-270h]@40
+  char out_text[300]; // [sp+8h] [bp-270h]@40
   //char Dest[100]; // [sp+6Ch] [bp-20Ch]@40
   //char v64[100]; // [sp+D0h] [bp-1A8h]@40
   char v65[120]; // [sp+134h] [bp-144h]@92
@@ -2314,31 +2308,30 @@
   //char *v76; // [sp+1FCh] [bp-7Ch]@5
   int v77; // [sp+200h] [bp-78h]@12
   int v78; // [sp+204h] [bp-74h]@5
-  GUIWindow v79; // [sp+208h] [bp-70h]@2
+  GUIWindow wHintWindow; // [sp+208h] [bp-70h]@2
   POINT a2; // [sp+25Ch] [bp-1Ch]@2
   int v81; // [sp+264h] [bp-14h]@5
-  GUIFont *v82; // [sp+268h] [bp-10h]@1
-  char *v83; // [sp+26Ch] [bp-Ch]@18
+ // GUIFont *pFontComic; // [sp+268h] [bp-10h]@1
+  PlayerSpeech v83; // [sp+26Ch] [bp-Ch]@18
+  char* v84;
+  int v85;
   char *Str; // [sp+270h] [bp-8h]@65
-  ItemGen *_this; // [sp+274h] [bp-4h]@1
-
-  v1 = ecx0;
-  _this = ecx0;
+
+  v1 = inspect_item;
   var88 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-  v82 = pFontComic;
-  if (!v1->uItemID)
+  if (!inspect_item->uItemID)
     return;
 
-    v79.Hint = 0;
-    v79.uFrameWidth = 384;
-    v79.uFrameHeight = 180;
-    v79.uFrameY = 40;
+    wHintWindow.Hint = 0;
+    wHintWindow.uFrameWidth = 384;
+    wHintWindow.uFrameHeight = 180;
+    wHintWindow.uFrameY = 40;
     if ( pMouse->GetCursorPos(&a2)->x <= 320 )
       v2 = pMouse->GetCursorPos(&a2)->x + 30;
     else
-      v2 = pMouse->GetCursorPos(&a2)->x - v79.uFrameWidth - 30;
-    v79.uFrameX = v2;
-    auto item_desc = &pItemsTable->pItems[_this->uItemID];
+      v2 = pMouse->GetCursorPos(&a2)->x - wHintWindow.uFrameWidth - 30;
+    wHintWindow.uFrameX = v2;
+    auto item_desc = &pItemsTable->pItems[inspect_item->uItemID];
     //v3 = (char *)&pItemsTable->pItems[_this->uItemID].pIconName;
     //v76 = v3;
     //v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[_this->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
@@ -2357,33 +2350,32 @@
       v81 = 0;
     else
       v81 >>= 1;
-    v8 = _this;
     if ( !item_desc->uItemID_Rep_St )
-      _this->SetIdentified();
+      inspect_item->SetIdentified();
     //v9 = v8->uAttributes;
     v77 = 0;
     //a2.y = v8->uAttributes & 2;
-    if (pItemsTable->pItems[v8->uItemID].uEquipType == EQUIP_GOLD)
-      v77 = v8->uSpecEnchantmentType;
+    if (pItemsTable->pItems[inspect_item->uItemID].uEquipType == EQUIP_GOLD)
+      v77 = inspect_item->uSpecEnchantmentType;
     if ( uActiveCharacter )
     {
-      if (!v8->Identified())
+     //try to identify
+      if (!inspect_item->Identified())
       {
-        v10 = pPlayers[uActiveCharacter]->CanIdentify(_this) == 1;
-        v11 = _this;
-        if ( v10 )
-          _this->SetIdentified();
-        v10 = !v11->Identified();
-        v83 = (char *)9;
-        if ( v10 )
+
+        v11 = inspect_item;
+        if ( pPlayers[uActiveCharacter]->CanIdentify(inspect_item) == 1 )
+          inspect_item->SetIdentified();
+        v83 = SPEECH_9;
+        if ( !inspect_item->Identified() )
         {
-          ShowStatusBarString(pGlobalTXT_LocalizationStrings[446], 2u);
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[446], 2u);//"Identify Failed"
         }
         else
         {
-          v83 = (char *)SPEECH_8;
-          if ( _this->GetValue() < 100 * (pPlayers[uActiveCharacter]->uLevel + 5) )
-            v83 = (char *)SPEECH_7;
+          v83 = SPEECH_8;
+          if ( inspect_item->GetValue() < 100 * (pPlayers[uActiveCharacter]->uLevel + 5) )
+            v83 = SPEECH_7;
         }
         if ( dword_4E455C )
         {
@@ -2391,96 +2383,95 @@
           dword_4E455C = 0;
         }
       }
-      _this->UpdateTempBonus(pParty->uTimePlayed);
-      if (v8->Broken())
+      inspect_item->UpdateTempBonus(pParty->uTimePlayed);
+      if (inspect_item->Broken())
       {
-        v10 = pPlayers[uActiveCharacter]->CanRepair(_this) == 1;
-        v12 = _this;
-        if ( v10 )
-          _this->uAttributes = _this->uAttributes & 0xFFFFFFFD | 1;
-        v10 = !v12->Broken();
-        v83 = (char *)SPEECH_11;
-        if ( v10 )
-          v83 = (char *)SPEECH_10;
+        if ( pPlayers[uActiveCharacter]->CanRepair(inspect_item) == 1 )
+          inspect_item->uAttributes = inspect_item->uAttributes & 0xFFFFFFFD | 1;
+        v83 = SPEECH_11;
+        if ( !inspect_item->Broken() )
+          v83 = SPEECH_10;
         else
-          ShowStatusBarString(pGlobalTXT_LocalizationStrings[448], 2u);
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[448], 2u);//"Repair Failed"
         if ( dword_4E455C )
         {
-          pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)(int)v83, 0);
+          pPlayers[uActiveCharacter]->PlaySound(v83, 0);
           dword_4E455C = 0;
         }
       }
     }
     //v13 = _this->uAttributes;
     //v14 = _this->Identified();
-    a2.y = _this->Identified();
-    if (_this->Broken())
+    //a2.y = inspect_item->Identified();
+    if (inspect_item->Broken())
     {
-      v79.DrawMessageBox(0);
+      wHintWindow.DrawMessageBox(0);
       //v15 = &;
-      pRenderer->Clip(v79.uFrameX + 12,                   v79.uFrameY + 12,
-                      v79.uFrameX + v79.uFrameWidth - 12, v79.uFrameY + v79.uFrameHeight - 12);
-      v79.uFrameWidth -= 24;
-      v79.uFrameHeight -= 12;
-      v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
-      v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
-      pRenderer->DrawTransparentRedShade(v79.uFrameX + v78, v81 + v79.uFrameY + 30, v73);
-      if ( a2.y )
-        v16 = _this->GetIdentifiedName();
+      pRenderer->Clip(wHintWindow.uFrameX + 12, wHintWindow.uFrameY + 12,
+                      wHintWindow.uFrameX + wHintWindow.uFrameWidth - 12, 
+                      wHintWindow.uFrameY + wHintWindow.uFrameHeight - 12);
+      wHintWindow.uFrameWidth -= 24;
+      wHintWindow.uFrameHeight -= 12;
+      wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1;
+      wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1;
+      pRenderer->DrawTransparentRedShade(wHintWindow.uFrameX + v78, v81 + wHintWindow.uFrameY + 30, v73);
+      if ( inspect_item->Identified())
+        v16 = inspect_item->GetIdentifiedName();
       else
         v16 = item_desc->pUnidentifiedName;
-      v79.DrawTitleText(pFontArrus, 0, 0xCu, var88, v16, 3u);
-      v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[32], &v79, 0, 0);
-      v57 = 3;
-      v52 = pGlobalTXT_LocalizationStrings[32];
-      goto LABEL_37;
-    }
-    if (!_this->Identified())
-    {
-      v79.DrawMessageBox(0);
-      //v15 = pRenderer;
-      pRenderer->Clip(v79.uFrameX + 12,                   v79.uFrameY + 12,
-                      v79.uFrameX + v79.uFrameWidth - 12, v79.uFrameY + v79.uFrameHeight - 12);
-      v79.uFrameWidth -= 24;
-      v79.uFrameHeight -= 12;
-      v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
-      v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
-      pRenderer->DrawTextureTransparent(v79.uFrameX + v78, v81 + v79.uFrameY + 30, v73);
-      v79.DrawTitleText(pFontArrus, 0, 0xCu, var88, item_desc->pUnidentifiedName, 3u);
-      v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[232], &v79, 0, 0);
-      v57 = 3;
-      v52 = pGlobalTXT_LocalizationStrings[232];
-LABEL_37:
+      wHintWindow.DrawTitleText(pFontArrus, 0, 0xCu, var88, v16, 3u);
+      v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[32], &wHintWindow, 0, 0); //"Broken Item"
       v18 = v17 >> 1;
       v19 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x19u, 0x19u);
-      v79.DrawTitleText(pFontArrus, 0x64u, ((signed int)v79.uFrameHeight >> 1) - v18, v19, v52, v57);
+      wHintWindow.DrawTitleText(pFontArrus, 0x64u, ((signed int)wHintWindow.uFrameHeight >> 1) - v18, v19, pGlobalTXT_LocalizationStrings[32], 3); //"Broken Item"
+       goto LABEL_116;
+    }
+    if (!inspect_item->Identified())
+    {
+      wHintWindow.DrawMessageBox(0);
+      pRenderer->Clip(wHintWindow.uFrameX + 12,  wHintWindow.uFrameY + 12,
+                      wHintWindow.uFrameX + wHintWindow.uFrameWidth - 12, 
+                      wHintWindow.uFrameY + wHintWindow.uFrameHeight - 12);
+      wHintWindow.uFrameWidth -= 24;
+      wHintWindow.uFrameHeight -= 12;
+      wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1;
+      wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1;
+      pRenderer->DrawTextureTransparent(wHintWindow.uFrameX + v78, v81 + wHintWindow.uFrameY + 30, v73);
+      wHintWindow.DrawTitleText(pFontArrus, 0, 0xCu, var88, item_desc->pUnidentifiedName, 3u);
+      v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[232], &wHintWindow, 0, 0); ///"Not Identified"
+      v18 = v17 >> 1;
+      v19 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x19u, 0x19u);
+      wHintWindow.DrawTitleText(pFontArrus, 0x64u, ((signed int)wHintWindow.uFrameHeight >> 1) - v18, v19, pGlobalTXT_LocalizationStrings[232], 3);
       goto LABEL_116;
     }
 
-    sprintfex(a1, pGlobalTXT_LocalizationStrings[463], item_desc->pUnidentifiedName);
-    a1[100] = 0;
-    a1[200] = 0;
+    sprintfex(out_text, pGlobalTXT_LocalizationStrings[463], item_desc->pUnidentifiedName); //"Type: %s"
+    out_text[100] = 0;
+    out_text[200] = 0;
     //v20 = item_desc->uEquipType;
     switch (item_desc->uEquipType)
     {
       case EQUIP_ONE_OR_TWO_HANDS:
       case EQUIP_TWO_HANDED:
-        sprintfex(a1 + 100, "%s: +%d   %s: %dd%d", pGlobalTXT_LocalizationStrings[18], (int)item_desc->uDamageMod, pGlobalTXT_LocalizationStrings[53], (int)item_desc->uDamageDice, (int)item_desc->uDamageRoll);
+        sprintfex(out_text + 100, "%s: +%d   %s: %dd%d", pGlobalTXT_LocalizationStrings[LOCSTR_ATTACK],
+            (int)item_desc->uDamageMod, pGlobalTXT_LocalizationStrings[53], (int)item_desc->uDamageDice, (int)item_desc->uDamageRoll); //"Damage"
         if (item_desc->uDamageMod)
         {
           char mod[16];
           sprintf(mod, "+%d", (int)item_desc->uDamageMod);
-          strcat(a1 + 100, mod);
+          strcat(out_text + 100, mod);
         }
       break;
 
       case EQUIP_BOW:
-        sprintfex(a1 + 100, "%s: +%d   %s: %dd%d", pGlobalTXT_LocalizationStrings[203], (int)item_desc->uDamageMod, pGlobalTXT_LocalizationStrings[53], (int)item_desc->uDamageDice, (int)item_desc->uDamageRoll);
+        sprintfex(out_text + 100, "%s: +%d   %s: %dd%d", pGlobalTXT_LocalizationStrings[203], //"Shoot"
+            (int)item_desc->uDamageMod, pGlobalTXT_LocalizationStrings[53], //"Damage"
+            (int)item_desc->uDamageDice, (int)item_desc->uDamageRoll);
         if (item_desc->uDamageMod)
         {
           char mod[16];
           sprintf(mod, "+%d", (int)item_desc->uDamageMod);
-          strcat(a1 + 100, mod);
+          strcat(out_text + 100, mod);
         }
       break;
 
@@ -2493,215 +2484,201 @@
       case EQUIP_BOOTS:
       case EQUIP_RING:
       case EQUIP_AMULET:
-        if (item_desc->uDamageDice)
-          sprintfex(a1 + 100, "%s: +%d", pGlobalTXT_LocalizationStrings[11], item_desc->uDamageDice + item_desc->uDamageMod);
+        if (item_desc->uDamageDice) //"Armor"	
+          sprintfex(out_text + 100, "%s: +%d", pGlobalTXT_LocalizationStrings[11], item_desc->uDamageDice + item_desc->uDamageMod);
       break;
+      case EQUIP_POTION:
+          if ( inspect_item->uEncantmentType )
+              sprintf(out_text + 200,  "%s: %d",pGlobalTXT_LocalizationStrings[449] , inspect_item->uEncantmentType); //"Power"
+          break;
+      case EQUIP_REAGENT:
+         sprintf(out_text + 200, "%s: %d", pGlobalTXT_LocalizationStrings[449], pItemsTable->pItems[inspect_item->uItemID].uDamageDice); //"Power"
+         break;
     }
 
     if ( v77 )
       goto LABEL_65;
     //v23 = item_desc->uEquipType;
-    if (item_desc->uEquipType == 14)
-    {
-      v24 = _this->uEncantmentType;
-      if ( v24 )
-        goto LABEL_56;
-LABEL_65:
-      v79.uFrameWidth -= 12;
-      a2.y = 3;
-      v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
-      v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
-      Str = (char *)(3 * (LOBYTE(pFontArrus->uFontHeight) + 8));
-      v83 = a1;
-      do
-      {
-        if ( *v83 )
-        {
-          v27 = v82->CalcTextHeight(v83, &v79, 100, 0);
-          Str += v27 + 3;
-        }
-        v83 += 100;
-        --a2.y;
-      }
-      while ( a2.y );
-      v28 = item_desc->pDescription;
-      if ( *v28 )
-      {
-        v29 = pFontSmallnum->CalcTextHeight(v28, &v79, 100, 0);
-        Str += v29;
-      }
-      v79.uFrameHeight = v73->uTextureHeight + v81 + 54;
-      if ( (signed int)Str > (signed int)v79.uFrameHeight )
-        v79.uFrameHeight = (unsigned int)Str;
-      if ( _this->uAttributes & 8 && (_this->uSpecEnchantmentType || _this->uEncantmentType) )
-        v79.uFrameHeight += LOBYTE(v82->uFontHeight);
-      v83 = 0;
-      if ( LOBYTE(pFontArrus->uFontHeight) )
-      {
-        v79.uFrameWidth -= 24;
-        v30 = (char *)LOBYTE(pFontArrus->uFontHeight);
-        v31 = _this->GetIdentifiedName();
-        if ( pFontArrus->CalcTextHeight(v31, &v79, 0, 0) / (signed int)v30 )
-          v83 = v30;
-        v79.uFrameWidth += 24;
-      }
-      v79.uFrameWidth += 12;
-      v79.uFrameHeight += (unsigned int)v83;
-      v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
-      v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
-      v79.DrawMessageBox(0);
-      //v15 = pRenderer;
-      pRenderer->Clip(v79.uFrameX + 12,                   v79.uFrameY + 12,
-                      v79.uFrameX + v79.uFrameWidth - 12, v79.uFrameY + v79.uFrameHeight - 12);
-      v79.uFrameWidth -= 12;
-      v32 = v73->uTextureHeight;
-      v33 = v79.uFrameHeight;
-      v79.uFrameHeight -= 12;
-      v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
-      v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
-      pRenderer->DrawTextureTransparent(
-        v79.uFrameX + v78,
-        v79.uFrameY + (signed int)(v33 - v32) / 2,
-        v73);
-      a2.y = 3;
-      v34 = (int)(v83 + 35);
-      Str = a1;
-      do
-      {
-        if ( *Str )
-        {
-          v79.DrawText(v82, 100, v34, 0, Str, 0, 0, 0);
-          v34 += v82->CalcTextHeight(Str, &v79, 100, 0) + 3;
-        }
-        Str += 100;
-        --a2.y;
-      }
-      while ( a2.y );
-      v35 = item_desc->pDescription;
-      if ( *v35 )
-        v79.DrawText(pFontSmallnum, 100, v34, 0, v35, 0, 0, 0);
-      v79.uFrameX += 12;
-      v79.uFrameWidth -= 24;
-      v36 = _this->GetIdentifiedName();
-      v79.DrawTitleText(pFontArrus, 0, 0xCu, var88, v36, 3u);
-      v79.uFrameWidth += 24;
-      v79.uFrameX -= 12;
-      if ( v77 )
-      {
-        sprintf(pTmpBuf, "%s: %lu", pGlobalTXT_LocalizationStrings[465], v77);
-        v40 = v82;
-        v61 = 0;
-        v56 = 0;
-        v51 = 0;
-        v47 = pTmpBuf;
-        v44 = 0;
-        v42 = v79.uFrameHeight - LOBYTE(v82->uFontHeight);
-        v41 = 100;
+    
+
+    if ( inspect_item->uEncantmentType )
+     {
+        sprintf(out_text + 200, "%s: %s +%d", pGlobalTXT_LocalizationStrings[210],
+             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].pBonusStatement, inspect_item->_bonus_strength);
       }
-      else
-      {
-        if ( _this->uAttributes & 8 && (_this->uSpecEnchantmentType || _this->uEncantmentType) )
+    
+    else if ( inspect_item->uNumCharges )
         {
-          sub_493F79(&v67, _this->uExpireTime - pParty->uTimePlayed);
-          strcpy(pTmpBuf, "Duration:");
-          Str = (char *)(v67.field_18_expire_year - game_starting_year);
-          if (v67.field_18_expire_year != 1168 )
-          {
-            sprintf(v65, " %d:yr", v67.field_18_expire_year - game_starting_year);
-            strcat(pTmpBuf, v65);
-          }
-          if ( (((v67.field_14_exprie_month || Str) && ((sprintf(v65, " %d:mo", v67.field_14_exprie_month), strcat(pTmpBuf, v65), v67.field_14_exprie_month) || Str) || v67.field_C_expire_day)
-             && ((sprintf(v65, " %d:dy", v67.field_C_expire_day), strcat(pTmpBuf, v65), v67.field_14_exprie_month) || Str || v67.field_C_expire_day)
-             || v67.field_8_expire_hour)
-            && ((sprintf(v65, " %d:hr", v67.field_8_expire_hour), strcat(pTmpBuf, v65), v67.field_14_exprie_month) || Str || v67.field_C_expire_day || v67.field_8_expire_hour)
-            || v67.field_4_expire_minute )
-          {
-            sprintf(v65, " %d:mn", v67.field_4_expire_minute);
-            strcat(pTmpBuf, v65);
-          }
-          v79.DrawText(v82, 100, v79.uFrameHeight - 2 * LOBYTE(v82->uFontHeight), 0, pTmpBuf, 0, 0, 0);
+        sprintf(out_text + 200, "%s: %lu", pGlobalTXT_LocalizationStrings[464], inspect_item->uNumCharges); //"Charges"
+
         }
-        v37 = _this->GetValue();
-        sprintf(pTmpBuf, "%s: %lu", pGlobalTXT_LocalizationStrings[465], v37);
-        v79.DrawText(v82, 100, v79.uFrameHeight - LOBYTE(v82->uFontHeight), 0, pTmpBuf, 0, 0, 0);
-        v38 = _this->uAttributes;
-        if ( BYTE1(v38) & 1 )
+
+LABEL_65:
+    wHintWindow.uFrameWidth -= 12;
+    v85 = 3;
+    wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1;
+    wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1;
+    Str = (char *)(3 * (LOBYTE(pFontArrus->uFontHeight) + 8));
+    v84 = &out_text[0];
+    do
         {
-          v61 = 0;
-          v56 = 0;
-          v51 = 0;
-          v47 = pGlobalTXT_LocalizationStrings[187];
-        }
-        else
-        {
-          if ( !(BYTE1(v38) & 2) )
-            goto LABEL_116;
-          v61 = 0;
-          v56 = 0;
-          v51 = 0;
-          v47 = pGlobalTXT_LocalizationStrings[651];
+        if ( *v84 )
+            {
+            v27 = pFontComic->CalcTextHeight(v84, &wHintWindow, 100, 0);
+            Str += v27 + 3;
+            }
+        v84 += 100;
+        --v85;
         }
-        LOWORD(v38) = LOWORD(pRenderer->uTargetRMask);
-        v44 = v38;
-        v42 = v79.uFrameHeight - LOBYTE(v82->uFontHeight);
-        v39 = v82->GetLineWidth(pTmpBuf);
-        v40 = v82;
-        v41 = v39 + 132;
-      }
-      v79.DrawText(v40, v41, v42, v44, v47, v51, v56, v61);
+        while ( v85 );
+        v28 = item_desc->pDescription;
+        if ( *v28 )
+            {
+            v29 = pFontSmallnum->CalcTextHeight(v28, &wHintWindow, 100, 0);
+            Str += v29;
+            }
+        wHintWindow.uFrameHeight = v73->uTextureHeight + v81 + 54;
+        if ( (signed int)Str > (signed int)wHintWindow.uFrameHeight )
+            wHintWindow.uFrameHeight = (unsigned int)Str;
+        if ( inspect_item->uAttributes & 8 && (inspect_item->uSpecEnchantmentType || inspect_item->uEncantmentType) )
+            wHintWindow.uFrameHeight += LOBYTE(pFontComic->uFontHeight);
+        v85 = 0;
+        if ( pFontArrus->uFontHeight )
+            {
+            wHintWindow.uFrameWidth -= 24;
+            v30 = pFontArrus->uFontHeight;
+            v31 = inspect_item->GetIdentifiedName();
+            if ( pFontArrus->CalcTextHeight(v31, &wHintWindow, 0, 0) / (signed int)v30 )
+                v85 = v30;
+            wHintWindow.uFrameWidth += 24;
+            }
+        wHintWindow.uFrameWidth += 12;
+        wHintWindow.uFrameHeight += (unsigned int)v85;
+        wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1;
+        wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1;
+        wHintWindow.DrawMessageBox(0);
+        //v15 = pRenderer;
+        pRenderer->Clip(wHintWindow.uFrameX + 12,                   wHintWindow.uFrameY + 12,
+            wHintWindow.uFrameX + wHintWindow.uFrameWidth - 12, wHintWindow.uFrameY + wHintWindow.uFrameHeight - 12);
+        wHintWindow.uFrameWidth -= 12;
+        v32 = v73->uTextureHeight;
+        v33 = wHintWindow.uFrameHeight;
+        wHintWindow.uFrameHeight -= 12;
+        wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1;
+        wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1;
+        pRenderer->DrawTextureTransparent(
+            wHintWindow.uFrameX + v78,
+            wHintWindow.uFrameY + (signed int)(v33 - v32) / 2,
+            v73);
+        
+        v34 = (int)(v85 + 35);
+         v85 = 3;
+        Str = out_text;
+        do
+            {
+            if ( *Str )
+                {
+                wHintWindow.DrawText(pFontComic, 100, v34, 0, Str, 0, 0, 0);
+                v34 += pFontComic->CalcTextHeight(Str, &wHintWindow, 100, 0) + 3;
+                }
+            Str += 100;
+            --v85;
+            }
+            while (v85 );
+            v35 = item_desc->pDescription;
+            if ( *v35 )
+                wHintWindow.DrawText(pFontSmallnum, 100, v34, 0, v35, 0, 0, 0);
+            wHintWindow.uFrameX += 12;
+            wHintWindow.uFrameWidth -= 24;
+            v36 = inspect_item->GetIdentifiedName();
+            wHintWindow.DrawTitleText(pFontArrus, 0, 0xCu, var88, v36, 3u);
+            wHintWindow.uFrameWidth += 24;
+            wHintWindow.uFrameX -= 12;
+            if ( v77 )
+                {
+                sprintf(pTmpBuf, "%s: %lu", pGlobalTXT_LocalizationStrings[465], v77);//"Value"
+                v40 = pFontComic;
+                v61 = 0;
+                v56 = 0;
+                v51 = 0;
+                v47 = pTmpBuf;
+                v44 = 0;
+                v42 = wHintWindow.uFrameHeight - LOBYTE(pFontComic->uFontHeight);
+                v41 = 100;
+                }
+            else
+                {
+                if ( (inspect_item->uAttributes & 8) && (inspect_item->uSpecEnchantmentType || inspect_item->uEncantmentType) )
+                    {
+                    sub_493F79(&v67, inspect_item->uExpireTime - pParty->uTimePlayed);
+                    strcpy(pTmpBuf, "Duration:");
+                    Str = (char *)(v67.field_18_expire_year - game_starting_year);
+                    if (v67.field_18_expire_year != 1168 )
+                        {
+                        sprintf(v65, " %d:yr", v67.field_18_expire_year - game_starting_year);
+                        strcat(pTmpBuf, v65);
+                        }
+                    if ( (((v67.field_14_exprie_month || Str) && 
+                        ((sprintf(v65, " %d:mo", v67.field_14_exprie_month), strcat(pTmpBuf, v65), v67.field_14_exprie_month) || Str) 
+                        || v67.field_C_expire_day)
+                        && ((sprintf(v65, " %d:dy", v67.field_C_expire_day), strcat(pTmpBuf, v65), v67.field_14_exprie_month) || Str || 
+                        v67.field_C_expire_day)
+                        || v67.field_8_expire_hour)
+                        && ((sprintf(v65, " %d:hr", v67.field_8_expire_hour), strcat(pTmpBuf, v65), v67.field_14_exprie_month) || Str || 
+                        v67.field_C_expire_day || v67.field_8_expire_hour)
+                        || v67.field_4_expire_minute )
+                        {
+                        sprintf(v65, " %d:mn", v67.field_4_expire_minute);
+                        strcat(pTmpBuf, v65);
+                        }
+                    wHintWindow.DrawText(pFontComic, 100, wHintWindow.uFrameHeight - 2 * LOBYTE(pFontComic->uFontHeight), 0, pTmpBuf, 0, 0, 0);
+                    }
+                v37 = inspect_item->GetValue();
+                sprintf(pTmpBuf, "%s: %lu", pGlobalTXT_LocalizationStrings[465], v37);
+                wHintWindow.DrawText(pFontComic, 100, wHintWindow.uFrameHeight - LOBYTE(pFontComic->uFontHeight), 0, pTmpBuf, 0, 0, 0);
+                v38 = inspect_item->uAttributes;
+                if ( BYTE1(v38) & 1 )
+                    {
+                    v61 = 0;
+                    v56 = 0;
+                    v51 = 0;
+                    v47 = pGlobalTXT_LocalizationStrings[187]; //"Stolen"
+                    }
+                else
+                    {
+                    if ( !(BYTE1(v38) & 2) )
+                        goto LABEL_116;
+                    v61 = 0;
+                    v56 = 0;
+                    v51 = 0;
+                    v47 = pGlobalTXT_LocalizationStrings[651]; //"Hardened"
+                    }
+                LOWORD(v38) = LOWORD(pRenderer->uTargetRMask);
+                v44 = v38;
+                v42 = wHintWindow.uFrameHeight - LOBYTE(pFontComic->uFontHeight);
+                v39 = pFontComic->GetLineWidth(pTmpBuf);
+                v40 = pFontComic;
+                v41 = v39 + 132;
+                }
+            wHintWindow.DrawText(v40, v41, v42, v44, v47, v51, v56, v61);
 LABEL_116:
-      pRenderer->ResetClip();
-      if ( !areWeLoadingTexture )
-      {
-        v73->Release();
-        pIcons_LOD->_40F9C5();
-      }
-      return;
-    }
-    if (item_desc->uEquipType == 13)
-    {
-      v24 = pItemsTable->pItems[_this->uItemID].uDamageDice;
-LABEL_56:
-      v59 = v24;
-      v54 = pGlobalTXT_LocalizationStrings[449];
-      v49 = "%s: %d";
-LABEL_64:
-      sprintf(a1 + 200, v49, v54, v59);
-      goto LABEL_65;
-    }
-    v25 = _this->uEncantmentType;
-    if ( v25 )
-    {
-      v60 = _this->_bonus_strength;
-      v55 = *((int *)&pItemsTable->pItems[799].uDamageMod + 5 * v25);
-      v50 = pGlobalTXT_LocalizationStrings[210];
-      v46 = "%s: %s +%d";
-    }
-    else
-    {
-      v26 = _this->uSpecEnchantmentType;
-      if ( !v26 )
-      {
-        if ( _this->uNumCharges )
-        {
-          v59 = _this->uNumCharges;
-          v54 = pGlobalTXT_LocalizationStrings[464];
-          v49 = "%s: %lu";
-          goto LABEL_64;
-        }
-        goto LABEL_65;
-      }
-      v60 = _this->_bonus_strength;
-      v55 = *((int *)&pItemsTable->pEnchantments[23].pBonusStat + 7 * v26);
-      v50 = pGlobalTXT_LocalizationStrings[210];
-      v46 = "%s: %s";
-    }
-    sprintf(a1 + 200, v46, v50, v55, v60);
-    goto LABEL_65;
+            pRenderer->ResetClip();
+            if ( !areWeLoadingTexture )
+                {
+                v73->Release();
+                pIcons_LOD->_40F9C5();
+                }
+            return;
 }
 // 4E455C: using guessed type int dword_4E455C;
 // 506128: using guessed type int areWeLoadingTexture;
 
+
 //----- (0041E360) --------------------------------------------------------
 char *__fastcall MonsterPopup_Draw(unsigned int uActorID, GUIWindow *edx0)
 {
@@ -5818,9 +5795,9 @@
   _50B924_view_transformed_xs[v1->uNumVertices] = _50B924_view_transformed_xs[0];
   _50B834_view_transformed_zs[v1->uNumVertices] = _50B834_view_transformed_zs[0];
   _50B744_view_transformed_ys[v1->uNumVertices] = _50B744_view_transformed_ys[0];
-  thisa = _50B924_view_transformed_xs[0] >= 0x80000u;
+  thisa = _50B924_view_transformed_xs[0] >= (signed int)0x80000u;
   //int i = 1;
-  for (uint i = 1; i < v1->uNumVertices; ++i)
+  for (uint i = 1; i <= v1->uNumVertices; ++i)
   {
       v10 = _50B924_view_transformed_xs[i];
       v81 = v10 >= (signed int)0x80000u;
@@ -5862,11 +5839,11 @@
       //++i;
       thisa = v81;
   }
-  ia = 0;
   v21 = v79;
   dword_50B918[v79] = dword_50B918[0];
   dword_50B828[v79] = dword_50B828[0];
-  for ( dword_50B738[v79] = dword_50B738[0]; ia < v79; dword_50BA08[v22] = pBLVRenderParams->uViewportCenterY - v35 )
+  dword_50B738[v79] = dword_50B738[0];
+  for (ia = 0; ia < v79; ++ia)
   {
     v22 = ia;
     thisc = abs(dword_50B918[ia]);
@@ -5895,7 +5872,7 @@
       }
     }
     v29 = dword_50B738[v22];
-    dword_50BAF4_xs[v22 + 1] = v26;
+    dword_50BAF8_xs[v22] = v26;
     if ( abs(v29) >> 13 <= thisc )
     {
       v33 = dword_50B738[v22];
@@ -5918,18 +5895,18 @@
         v32 = (v31 & 0x800000) - 0x400000;
       }
     }
-    dword_50BA08[v22] = v32;
-    dword_50BAF4_xs[v22 + 1] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BAF4_xs[v22 + 1]) >> 16;
-    v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BA08[v22]) >> 16;
-    dword_50BAF4_xs[v22 + 1] = pBLVRenderParams->uViewportCenterX - dword_50BAF4_xs[v22 + 1];
-    ++ia;
+    dword_50BA08_ys[v22] = v32;
+    dword_50BAF8_xs[v22] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BAF8_xs[v22]) >> 16;
+    v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BA08_ys[v22]) >> 16;
+    dword_50BAF8_xs[v22] = pBLVRenderParams->uViewportCenterX - dword_50BAF8_xs[v22];
+    dword_50BA08_ys[v22] = pBLVRenderParams->uViewportCenterY - v35;
   }
   v36 = 0;
-  dword_50BAF4_xs[v21 + 1] = dword_50BAF4_xs[1];
-  dword_50BA08[v21] = dword_50BA08[0];
+  dword_50BAF8_xs[v21] = dword_50BAF8_xs[0];
+  dword_50BA08_ys[v21] = dword_50BA08_ys[0];
   v37 = pBLVRenderParams->uViewportX;
-  v38 = dword_50BAF4_xs[1] < (signed int)pBLVRenderParams->uViewportX;
-  LOBYTE(v38) = dword_50BAF4_xs[1] >= (signed int)pBLVRenderParams->uViewportX;
+  v38 = dword_50BAF8_xs[0] < (signed int)pBLVRenderParams->uViewportX;
+  LOBYTE(v38) = dword_50BAF8_xs[0] >= (signed int)pBLVRenderParams->uViewportX;
   v39 = 1;
   ib = 1;
   if ( v79 < 1 )
@@ -5937,30 +5914,31 @@
   do
   {
     v40 = v39;
-    v41 = dword_50BAF4_xs[v40 + 1];
+    v41 = dword_50BAF8_xs[v40];
     v82 = v41 >= (signed int)v37;
     if ( v38 ^ v82 )
     {
       if ( v41 >= (signed int)v37 )
       {
-        v67 = (signed int)(v37 - dword_50BAF4_xs[v40]) * (signed __int64)(dword_50BA08[v40] - dword_50B9F8[v40 + 3]) / (v41 - dword_50BAF4_xs[v40]);
-        v42 = dword_50B9F8[v40 + 3];
+        v67 = (signed int)(v37 - dword_50BAF8_xs[v40 - 1]) * (signed __int64)(dword_50BA08_ys[v40] - dword_50BA08_ys[v40 - 1]) / (v41 - dword_50BAF8_xs[v40 - 1]);
+        v42 = dword_50BA08_ys[v40 - 1];
       }
       else
       {
-        v67 = (signed int)(v37 - v41) * (signed __int64)(dword_50B9F8[v40 + 3] - dword_50BA08[v40]) / (dword_50BAF4_xs[v40] - v41);
-        v42 = dword_50BA08[v40];
+        v67 = (signed int)(v37 - v41) * (signed __int64)(dword_50BA08_ys[v40 - 1] - dword_50BA08_ys[v40]) / (dword_50BAF8_xs[v40 - 1] - v41);
+        v42 = dword_50BA08_ys[v40];
       }
+      dword_50B9FC_ys[v36] = v67 + v42;
+      v37 = pBLVRenderParams->uViewportX;
+      dword_50BAEC_xs[v36] = pBLVRenderParams->uViewportX;
       ++v36;
-      dword_50B9F8[v36] = v67 + v42;
-      v37 = pBLVRenderParams->uViewportX;
-      dword_50BAE8_xs[v36] = pBLVRenderParams->uViewportX;
     }
     v38 = v82;
     if ( v82 )
     {
-      dword_50BAE8_xs[v36 + 1] = dword_50BAF4_xs[v40 + 1];
-      dword_50B9F8[v36++ + 1] = dword_50BA08[v40];
+      dword_50BAEC_xs[v36] = dword_50BAF8_xs[v40];
+      dword_50B9FC_ys[v36] = dword_50BA08_ys[v40];
+      ++v36;
     }
     v39 = ib++ + 1;
   }
@@ -5970,38 +5948,38 @@
     return 0;
 
   v43 = 0;
-  dword_50BAE8_xs[v36 + 1] = dword_50BAE8_xs[1];
-  dword_50B9F8[v36 + 1] = dword_50B9F8[1];
+  dword_50BAEC_xs[v36] = dword_50BAEC_xs[0];
+  dword_50B9FC_ys[v36] = dword_50B9FC_ys[0];
   v44 = pBLVRenderParams->uViewportZ;
-  thisd = dword_50BAE8_xs[1] <= (signed int)pBLVRenderParams->uViewportZ;
+  thisd = dword_50BAEC_xs[0] <= (signed int)pBLVRenderParams->uViewportZ;
   ic = 1;
 
   do
   {
     v45 = ic;
-    v46 = dword_50BAE8_xs[ic + 1];
+    v46 = dword_50BAEC_xs[ic];
     v83 = v46 <= (signed int)v44;
     if ( thisd ^ v83 )
     {
       if ( v46 <= (signed int)v44 )
       {
-        v68 = (signed int)(v44 - dword_50BAE8_xs[v45]) * (signed __int64)(dword_50B9F8[v45 + 1] - dword_50B9F8[v45]) / (v46 - dword_50BAE8_xs[v45]);
-        v47 = dword_50B9F8[v45];
+        v68 = (signed int)(v44 - dword_50BAEC_xs[v45 - 1]) * (signed __int64)(dword_50B9FC_ys[v45] - dword_50B9FC_ys[v45 - 1]) / (v46 - dword_50BAEC_xs[v45 - 1]);
+        v47 = dword_50B9FC_ys[v45 - 1];
       }
       else
       {
-        v68 = (signed int)(v44 - v46) * (signed __int64)(dword_50B9F8[v45] - dword_50B9F8[v45 + 1]) / (dword_50BAE8_xs[v45] - v46);
-        v47 = dword_50B9F8[v45 + 1];
+        v68 = (signed int)(v44 - v46) * (signed __int64)(dword_50B9FC_ys[v45 - 1] - dword_50B9FC_ys[v45]) / (dword_50BAEC_xs[v45 - 1] - v46);
+        v47 = dword_50B9FC_ys[v45];
       }
+      dword_50B9F0[v43] = v68 + v47;
+      v44 = pBLVRenderParams->uViewportZ;
+      dword_50BAE0[v43] = pBLVRenderParams->uViewportZ;
       ++v43;
-      dword_50B9EC[v43] = v68 + v47;
-      v44 = pBLVRenderParams->uViewportZ;
-      dword_50BADC_xs[v43] = pBLVRenderParams->uViewportZ;
     }
     if ( v83 )
     {
-      dword_50BAE0[v43] = dword_50BAE8_xs[v45 + 1];
-      dword_50B9F0[v43++] = dword_50B9F8[v45 + 1];
+      dword_50BAE0[v43] = dword_50BAEC_xs[v45];
+      dword_50B9F0[v43++] = dword_50B9FC_ys[v45];
     }
     ++ic;
     thisd = v83;
@@ -6028,24 +6006,24 @@
     {
       if ( v53 >= (signed int)v49 )
       {
-        v69 = (signed int)(v49 - dword_50B9EC[v52]) * (signed __int64)(dword_50BAE0[v52] - dword_50BADC_xs[v52]) / (v53 - dword_50B9EC[v52]);
-        v54 = dword_50BADC_xs[v52];
+        v69 = (signed int)(v49 - dword_50B9F0[v52 - 1]) * (signed __int64)(dword_50BAE0[v52] - dword_50BAE0[v52 - 1]) / (v53 - dword_50B9F0[v52 - 1]);
+        v54 = dword_50BAE0[v52 - 1];
       }
       else
       {
-        v69 = (signed int)(v49 - v53) * (signed __int64)(dword_50BADC_xs[v52] - dword_50BAE0[v52]) / (dword_50B9EC[v52] - v53);
+        v69 = (signed int)(v49 - v53) * (signed __int64)(dword_50BAE0[v52 - 1] - dword_50BAE0[v52]) / (dword_50B9F0[v52 - 1] - v53);
         v54 = dword_50BAE0[v52];
       }
+      dword_50BAD4[v48] = v69 + v54;
+      v49 = pBLVRenderParams->uViewportY;
+      dword_50B9E4[v48] = pBLVRenderParams->uViewportY;
       ++v48;
-      dword_50BAD0[v48] = v69 + v54;
-      v49 = pBLVRenderParams->uViewportY;
-      dword_50B9E0_ys[v48] = pBLVRenderParams->uViewportY;
     }
     v50 = v84;
     if ( v84 )
     {
       dword_50BAD4[v48] = dword_50BAE0[v52];
-      dword_50B9E0_ys[v48++ + 1] = dword_50B9F0[v52];
+      dword_50B9E4[v48++] = dword_50B9F0[v52];
     }
     v51 = id++ + 1;
   }
@@ -6056,36 +6034,36 @@
 
   v55 = 0;
   dword_50BAD4[v48] = dword_50BAD4[0];
-  dword_50B9E0_ys[v48 + 1] = dword_50B9E0_ys[1];
+  dword_50B9E4[v48] = dword_50B9E4[0];
   v56 = pBLVRenderParams->uViewportW;
-  thise = dword_50B9E0_ys[1] <= (signed int)pBLVRenderParams->uViewportW;
+  thise = dword_50B9E4[0] <= (signed int)pBLVRenderParams->uViewportW;
   ie = 1;
   do
   {
     v57 = ie;
-    v58 = dword_50B9E0_ys[ie + 1];
+    v58 = dword_50B9E4[ie];
     v85 = v58 <= (signed int)v56;
     if ( thise ^ v85 )
     {
       if ( v58 <= (signed int)v56 )
       {
-        v70 = (signed int)(v56 - dword_50B9E0_ys[v57]) * (signed __int64)(dword_50BAD4[v57] - dword_50BAD0[v57]) / (v58 - dword_50B9E0_ys[v57]);
-        v59 = dword_50BAD0[v57];
+        v70 = (signed int)(v56 - dword_50B9E4[v57 - 1]) * (signed __int64)(dword_50BAD4[v57] - dword_50BAD4[v57 - 1]) / (v58 - dword_50B9E4[v57 - 1]);
+        v59 = dword_50BAD4[v57 - 1];
       }
       else
       {
-        v70 = (signed int)(v56 - v58) * (signed __int64)(dword_50BAD0[v57] - dword_50BAD4[v57]) / (dword_50B9E0_ys[v57] - v58);
+        v70 = (signed int)(v56 - v58) * (signed __int64)(dword_50BAD4[v57 - 1] - dword_50BAD4[v57]) / (dword_50B9E4[v57 - 1] - v58);
         v59 = dword_50BAD4[v57];
       }
+      dword_50BAC8[v55] = v70 + v59;
+      v56 = pBLVRenderParams->uViewportW;
+      dword_50B9D8_ys[v55] = pBLVRenderParams->uViewportW;
       ++v55;
-      dword_50BAC4[v55] = v70 + v59;
-      v56 = pBLVRenderParams->uViewportW;
-      unk_50B9D4[v55] = pBLVRenderParams->uViewportW;
     }
     if ( v85 )
     {
       dword_50BAC8[v55] = dword_50BAD4[v57];
-      dword_50B9D8_ys[v55++] = dword_50B9E0_ys[v57 + 1];
+      dword_50B9D8_ys[v55++] = dword_50B9E4[v57];
     }
     ++ie;
     thise = v85;
--- a/mm7_2.cpp	Tue Mar 05 10:45:29 2013 +0600
+++ b/mm7_2.cpp	Tue Mar 05 10:45:40 2013 +0600
@@ -1098,65 +1098,62 @@
   v101.uFrameZ = 334;
   v105 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
   v104 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
-  if ( dword_F8B19C > 5 )
-  {
-    if ( dword_F8B19C == 94 )
-    {
-      draw_leather();
-      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
-      pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];
-      pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];
-      pShopOptions[2] = pGlobalTXT_LocalizationStrings[179];
-      v65 = 0;
-      v66 = pShopOptions;
-      do
-      {
-        v67 = pFontArrus->CalcTextHeight(*v66, &v101, 0, 0);
-        ++v66;
-        v65 += v67;
-      }
-      while ( (signed int)v66 < (signed int)&pShopOptions[3] );
-      v68 = pDialogueWindow;
-      v109 = (const char **)((174 - v65) / 3);
-      result = (char *)pDialogueWindow->pStartingPosActiveItem;
-      v69 = (int)&result[pDialogueWindow->pNumPresenceButton];
-      v70 = (3 * (58 - (signed int)v109) - v65) / 2 - (174 - v65) / 3 / 2 + 138;
-      v20 = -pDialogueWindow->pNumPresenceButton < 0;
-      v106.y = pDialogueWindow->pStartingPosActiveItem;
-      if ( v20 ^ __OFSUB__((int)result, (int)v69) )
-      {
-        _this = (Player *)2;
-        v108 = (int)pShopOptions;
-        do
-        {
-          v71 = v68->GetControl(v106.y);
-          v72 = (const char **)v108;
-          v71->uY = (unsigned int)((char *)v109 + v70);
-          v73 = pFontArrus->CalcTextHeight(*v72, &v101, 0, 0);
-          v74 = v71->uY;
-          v75 = _this;
-          v71->uHeight = v73;
-          v70 = v73 + v74 - 1;
-          v71->uW = v70;
-          v76 = v104;
-          if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v75 )
-            v76 = v105;
-          v101.DrawTitleText(pFontArrus, 0, v74, v76, *(const char **)v108, 3u);
-          v68 = pDialogueWindow;
-          _this = (Player *)((char *)_this + 1);
-          v108 += 4;
-          ++v106.y;
-          result = (char *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
-        }
-        while ( v106.y < (signed int)result );
-      }
-      return result;
-    }
-    if ( dword_F8B19C != 95 )
-    {
-      result = (char *)(dword_F8B19C - 96);
-      if ( dword_F8B19C == 96 )
-      {
+  switch(dword_F8B19C)
+  {
+	case 94:
+		{
+		draw_leather();
+		CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+		pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];
+		pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];
+		pShopOptions[2] = pGlobalTXT_LocalizationStrings[179];
+		v65 = 0;
+		v66 = pShopOptions;
+		do
+		{
+			v67 = pFontArrus->CalcTextHeight(*v66, &v101, 0, 0);
+			++v66;
+			v65 += v67;
+		}
+		while ( (signed int)v66 < (signed int)&pShopOptions[3] );
+		v68 = pDialogueWindow;
+		v109 = (const char **)((174 - v65) / 3);
+		result = (char *)pDialogueWindow->pStartingPosActiveItem;
+		v69 = (int)&result[pDialogueWindow->pNumPresenceButton];
+		v70 = (3 * (58 - (signed int)v109) - v65) / 2 - (174 - v65) / 3 / 2 + 138;
+		v20 = -pDialogueWindow->pNumPresenceButton < 0;
+		v106.y = pDialogueWindow->pStartingPosActiveItem;
+		if ( v20 ^ __OFSUB__((int)result, (int)v69) )
+		{
+			_this = (Player *)2;
+			v108 = (int)pShopOptions;
+			do
+			{
+				v71 = v68->GetControl(v106.y);
+				v72 = (const char **)v108;
+				v71->uY = (unsigned int)((char *)v109 + v70);
+				v73 = pFontArrus->CalcTextHeight(*v72, &v101, 0, 0);
+				v74 = v71->uY;
+				v75 = _this;
+				v71->uHeight = v73;
+				v70 = v73 + v74 - 1;
+				v71->uW = v70;
+				v76 = v104;
+				if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v75 )
+				v76 = v105;
+				v101.DrawTitleText(pFontArrus, 0, v74, v76, *(const char **)v108, 3u);
+				v68 = pDialogueWindow;
+				_this = (Player *)((char *)_this + 1);
+				v108 += 4;
+				++v106.y;
+				result = (char *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
+			}
+			while ( v106.y < (signed int)result );
+		}
+		break;	
+		}
+	case 96:
+		{
         result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
         if ( result )
         {
@@ -1173,7 +1170,20 @@
           v34 = v33 + v30->pNumPresenceButton;
           v109 = 0;
           if ( (signed int)v33 >= v34 )
-            goto LABEL_105;
+		  {
+		    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], _this->pName, pClassNames[_this->classType]);
+            strcat(pTmpBuf, "\n \n");
+            strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
+            v7 = pTmpBuf;
+            v86 = 3;
+            v84 = pTmpBuf;
+            v82 = v104;
+            v80 = 0;
+            v78 = 0;
+            v77 = &v101;
+            v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
+            return v101.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
+          }
           do
           {
             v35 = v30->GetControl(v33)->uControlParam - 36;
@@ -1188,7 +1198,7 @@
           while ( (signed int)v33 < v30->pNumPresenceButton + v30->pStartingPosActiveItem );
           if ( !v109 )
           {
-LABEL_105:
+//LABEL_105:
             sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], _this->pName, pClassNames[_this->classType]);
             strcat(pTmpBuf, "\n \n");
             strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
@@ -1199,7 +1209,8 @@
             v80 = 0;
             v78 = 0;
             v77 = &v101;
-            goto LABEL_15;
+            v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
+            return v101.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
           }
           sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v108);
           v101.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
@@ -1249,115 +1260,232 @@
             while ( v106.y < (signed int)result );
           }
         }
-      }
-      return result;
-    }
-  }
-  else
-  {
-    if ( dword_F8B19C == 5 )
-    {
-      draw_leather();
-      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
-      DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0);
-      result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-      if ( result )
-      {
-        v27 = pMouse->GetCursorPos(&v99)->x - 14;
-        v106.x = (v27 >> 5) + 14 * ((pMouse->GetCursorPos(&v97)->y - 17) >> 5);
-        result = (char *)pMouse->GetCursorPos(&v95);
-        if ( *(int *)result > 13 )
-        {
-          result = (char *)pMouse->GetCursorPos(&v93);
-          if ( *(int *)result < 462 )
-          {
-            result = (char *)v0->GetItemIDAtInventoryIndex((int *)&v106.x);
-            v3 = 0;
-            if ( result )
-            {
-              result = (char *)(9 * (int)result);
-              if ( _this->field_1F5[4 * (int)result + 15] & 2 )
-              {
-                v85 = 0;
-                v83 = 5;
-                v81 = window_SpeakInHouse->ptr_1C;
-                v79 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * (int)result + 5];
-                v28 = (int)window_SpeakInHouse->ptr_1C;
-                v110 = uActiveCharacter - 1;
-                v29 = _this->_490EEE(
-                        (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * (int)result + 5],
-                        1,
-                        v28,
-                        5);
-                v6 = v110;
-                v5 = (char *)pMerchantsRepairPhrases[v29];
-                goto LABEL_14;
-              }
-            }
-          }
-        }
-      }
-      return result;
-    }
-    if ( dword_F8B19C == 1 )
-    {
-      result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-      if ( result )
-      {
-        pShopOptions[0] = pGlobalTXT_LocalizationStrings[134];
-        pShopOptions[1] = pGlobalTXT_LocalizationStrings[152];
-        pShopOptions[2] = pGlobalTXT_LocalizationStrings[159];
-        v14 = 0;
-        pShopOptions[3] = pGlobalTXT_LocalizationStrings[160];
-        v15 = pShopOptions;
-        do
-        {
-          v16 = pFontArrus->CalcTextHeight(*v15, &v101, 0, 0);
-          ++v15;
-          v14 += v16;
-        }
-        while ( (signed int)v15 < (signed int)&unk_F8B1C8 );
-        v17 = pDialogueWindow;
-        v103 = (174 - v14) / 4;
-        result = (char *)pDialogueWindow->pStartingPosActiveItem;
-        v18 = (int)&result[pDialogueWindow->pNumPresenceButton];
-        v19 = (174 - 4 * (174 - v14) / 4 - v14) / 2 - (174 - v14) / 4 / 2 + 138;
-        v20 = -pDialogueWindow->pNumPresenceButton < 0;
-        _this = (Player *)pDialogueWindow->pStartingPosActiveItem;
-        if ( v20 ^ __OFSUB__((int)result, v18) )
-        {
-          v108 = 2;
-          v109 = (const char **)pShopOptions;
-          do
-          {
-            v21 = v17->GetControl((unsigned int)_this);
-            v22 = v109;
-            v21->uY = v103 + v19;
-            v23 = pFontArrus->CalcTextHeight(*v22, &v101, 0, 0);
-            v24 = v21->uY;
-            v25 = v108;
-            v21->uHeight = v23;
-            v19 = v24 + v23 - 1;
-            v21->uW = v19;
-            v26 = v104;
-            if ( pDialogueWindow->pCurrentPosActiveItem != v25 )
-              v26 = v105;
-            v101.DrawTitleText(pFontArrus, 0, v24, v26, *v109, 3u);
-            v17 = pDialogueWindow;
-            ++v108;
-            ++v109;
-            _this = (Player *)((char *)_this + 1);
-            result = (char *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
-          }
-          while ( (signed int)_this < (signed int)result );
-        }
-      }
-      return result;
-    }
-    if ( dword_F8B19C != 2 )
-    {
-      if ( dword_F8B19C == 3 )
-      {
+		break;
+		}
+	case 95:
+		{
+		pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
+		v3 = 0;
+		v109 = 0;
+		v108 = 0;
+		do
+		{
+		  //   if ( pParty->field_C59C[9 * (int)&v109[3 * (unsigned int)window_SpeakInHouse->ptr_1C] + 724] )
+		  if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v109].uItemID)
+		  {
+			v52 = word_F8B158[(signed int)v109] + 30;
+			v53 = ItemsInShopTexture[(signed int)v109];
+			v54 = 60 - ((signed int)v53->uTextureWidth >> 1);
+			pRenderer->DrawTextureTransparent(v54 + v108, word_F8B158[(signed int)v109] + 30, v53);
+			sub_40F92A(
+			  &pRenderer->pActiveZBuffer[v54 + v108 + 640 * v52],
+			  ItemsInShopTexture[(signed int)v109],
+			  (int)((char *)v109 + 1));
+		  }
+		  v109 = (const char **)((char *)v109 + 1);
+		  v108 += 70;
+		}
+		while ( (signed int)v109 < 6 );
+		result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
+		if ( result )
+		{
+			v55 = 0;
+			v106.x = 0;
+			do
+			{
+			// if ( pParty->field_C59C[9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+			if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID)
+				++v106.x;
+			++v55;
+			}
+			while ( v55 < 6 );
+			v56 = GetAsyncKeyState(17);
+			v57 = _this->CanSteal();
+			Str = (char *)v57;
+			if ( v56 && v57 )
+			{
+			  v58 = pGlobalTXT_LocalizationStrings[185];
+			}
+			else
+			{
+			  v58 = pGlobalTXT_LocalizationStrings[195];
+			  if ( dword_F8B19C != 2 )
+				v58 = pGlobalTXT_LocalizationStrings[196];
+			}
+			DrawTextAtStatusBar(v58, 0);
+			if ( v106.x )
+			{
+			  v59 = pMouse->GetCursorPos(&v91);
+			  result = (char *)(v59->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v89)->y]);
+			  if ( pRenderer->pActiveZBuffer[(int)result] & 0xFFFF )
+			  {
+				v60 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1;
+				v106.x = v60;
+				v61 = (int)window_SpeakInHouse->ptr_1C;
+			  //  v62 = 9 * (v60 + 12 * v61);
+				v63 = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60];
+				if ( dword_F8B19C != 2 )
+				  v63 = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724];
+				if ( !v56 || !Str )
+				{
+				  v85 = 0;
+				  v83 = 2;
+				  v81 = window_SpeakInHouse->ptr_1C;
+				  v79 = v63;
+				  v110 = uActiveCharacter - 1;
+				  v64 = _this->_490EEE(v63, 1, v61, 2);
+				  v6 = v110;
+				  v5 = (char *)pMerchantsBuyPhrases[v64];
+				  v7 = BuilDialogueString(v5, v6, v79, (char *)v81, v83, v85);
+				  v86 = 3;
+				  v84 = v7;
+				  v82 = v105;
+				  v80 = v3;
+				  v78 = v3;
+				  v77 = &v101;
+	  			  v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
+				  return v101.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
+				}
+				v5 = pGlobalTXT_LocalizationStrings[181];
+				v85 = 0;
+				v83 = 2;
+				v81 = window_SpeakInHouse->ptr_1C;
+				v79 = v63;
+				v6 = uActiveCharacter - 1;
+				v7 = BuilDialogueString(v5, v6, v79, (char *)v81, v83, v85);
+				v86 = 3;
+				v84 = v7;
+				v82 = v105;
+				v80 = v3;
+				v78 = v3;
+				v77 = &v101;
+				v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
+				return v101.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
+			  }
+			}
+			else
+			{
+			  v101.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C]  - pParty->uTimePlayed);
+			  result =0; //added
+			}
+		}
+		break;
+		}
+	case 2:
+		{
+		pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
+		v3 = 0;
+		v48 = 0;
+		v108 = 0;
+		v109 = 0;
+		do
+		{
+		//  if ( pParty->field_777C[9 * (int)&v48[3 * (unsigned int)window_SpeakInHouse->ptr_1C]] )
+		if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(int)v48].uItemID);
+			{
+			v49 = word_F8B158[(signed int)v48];
+			v50 = ItemsInShopTexture[(signed int)v48];
+			v49 += 30;
+			v51 = 60 - ((signed int)v50->uTextureWidth >> 1);
+			pRenderer->DrawTextureTransparent(v51 + v108, v49, v50);
+			sub_40F92A(
+				&pRenderer->pActiveZBuffer[v51 + v108 + 640 * v49],
+				ItemsInShopTexture[(signed int)v109],
+				(int)((char *)v109 + 1));
+			v48 = v109;
+			}
+			v108 += 70;
+			v48 = (const char **)((char *)v48 + 1);
+			v109 = v48;
+		}
+		while ( (signed int)v48 < 6 );
+		  result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
+		if ( result )
+		{
+			v55 = 0;
+			v106.x = 0;
+			v106.x = 0;
+			do
+			{
+			if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID);//9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
+				++v106.x;
+			++v55;
+			}
+			while ( v55 < 6 );
+			v56 = GetAsyncKeyState(17);
+			v57 = _this->CanSteal();
+			Str = (char *)v57;
+			if ( v56 && v57 )
+			{
+				v58 = pGlobalTXT_LocalizationStrings[185];
+			}
+			else
+			{
+				v58 = pGlobalTXT_LocalizationStrings[195];
+				if ( dword_F8B19C != 2 )
+				v58 = pGlobalTXT_LocalizationStrings[196];
+			}
+			DrawTextAtStatusBar(v58, 0);
+			if ( v106.x )
+			{
+				v59 = pMouse->GetCursorPos(&v91);
+				result = (char *)(v59->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v89)->y]);
+				if ( pRenderer->pActiveZBuffer[(int)result] & 0xFFFF )
+				{
+					v60 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1;
+					v106.x = v60;
+					v61 = (int)window_SpeakInHouse->ptr_1C;
+					//  v62 = 9 * (v60 + 12 * v61);
+					v63 = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60];
+					if ( dword_F8B19C != 2 )
+						v63 = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724];
+					if ( !v56 || !Str )
+					{
+						v85 = 0;
+						v83 = 2;
+						v81 = window_SpeakInHouse->ptr_1C;
+						v79 = v63;
+						v110 = uActiveCharacter - 1;
+						v64 = _this->_490EEE(v63, 1, v61, 2);
+						v6 = v110;
+						v5 = (char *)pMerchantsBuyPhrases[v64];
+						v7 = BuilDialogueString(v5, v6, v79, (char *)v81, v83, v85);
+						v86 = 3;
+						v84 = v7;
+						v82 = v105;
+						v80 = v3;
+						v78 = v3;
+						v77 = &v101;
+	  					v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
+						return v101.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
+					}
+					v5 = pGlobalTXT_LocalizationStrings[181];
+					v85 = 0;
+					v83 = 2;
+					v81 = window_SpeakInHouse->ptr_1C;
+					v79 = v63;
+					v6 = uActiveCharacter - 1;
+					v7 = BuilDialogueString(v5, v6, v79, (char *)v81, v83, v85);
+					v86 = 3;
+					v84 = v7;
+					v82 = v105;
+					v80 = v3;
+					v78 = v3;
+					v77 = &v101;
+					v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
+					return v101.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
+				}
+			}
+			else
+			{
+				v101.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C]  - pParty->uTimePlayed);
+				result =0; //added
+			}
+		}
+		break;
+		}
+	case 3:
+		{
         draw_leather();
         CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
         DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);
@@ -1385,205 +1513,148 @@
                 v13 = _this->_490EEE(v79, 1, v12, 3);
                 v6 = v110;
                 v5 = (char *)pMerchantsSellPhrases[v13];
-                goto LABEL_14;
-              }
-            }
-          }
-        }
-      }
-      else
-      {
-        result = (char *)(dword_F8B19C - 4);
-        if ( dword_F8B19C == 4 )
-        {
-          draw_leather();
-          CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
-          DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);
-          result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-          if ( result )
-          {
-            v2 = pMouse->GetCursorPos(&a2)->x - 14;
-            v106.x = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v87)->y - 17) >> 5);
-            result = (char *)pMouse->GetCursorPos(&v100);
-            if ( *(int *)result > 13 )
-            {
-              result = (char *)pMouse->GetCursorPos(&v92);
-              if ( *(int *)result < 462 )
-              {
-                result = (char *)v0->GetItemIDAtInventoryIndex((int *)&v106.x);
-                v3 = 0;
-                if ( result )
-                {
-                  v85 = 0;
-                  v83 = 4;
-                  v4 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * (int)result + 5];
-                  if (!v4->Identified())
-                  {
-                    v81 = window_SpeakInHouse->ptr_1C;
-                    v79 = v4;
-                    v9 = (int)window_SpeakInHouse->ptr_1C;
-                    v110 = uActiveCharacter - 1;
-                    v10 = _this->_490EEE(v4, 1, v9, 4);
-                    v6 = v110;
-                    v5 = (char *)pMerchantsIdentifyPhrases[v10];
-                    goto LABEL_14;
-                  }
-                  v81 = window_SpeakInHouse->ptr_1C;
-                  v5 = "%24";
-                  v79 = v4;
-LABEL_13:
-                  v6 = uActiveCharacter - 1;
-LABEL_14:
-                  v7 = BuilDialogueString(v5, v6, v79, (char *)v81, v83, v85);
-                  v86 = 3;
-                  v84 = v7;
-                  v82 = v105;
-                  v80 = v3;
-                  v78 = v3;
-                  v77 = &v101;
-LABEL_15:
-                  v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
-                  return v101.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
-                }
+                v7 = BuilDialogueString(v5, v6, v79, (char *)v81, v83, v85);
+                v86 = 3;
+                v84 = v7;
+                v82 = v105;
+                v80 = v3;
+                v78 = v3;
+                v77 = &v101;
+				v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
+                return v101.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
               }
             }
           }
         }
-      }
-      return result;
-    }
-  }
-  pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
-  v3 = 0;
-  if ( dword_F8B19C == 2 )
-  {
-    v48 = 0;
-    v108 = 0;
-    v109 = 0;
-    do
-    {
-    //  if ( pParty->field_777C[9 * (int)&v48[3 * (unsigned int)window_SpeakInHouse->ptr_1C]] )
-	if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(int)v48].uItemID);
-      {
-        v49 = word_F8B158[(signed int)v48];
-        v50 = ItemsInShopTexture[(signed int)v48];
-        v49 += 30;
-        v51 = 60 - ((signed int)v50->uTextureWidth >> 1);
-        pRenderer->DrawTextureTransparent(v51 + v108, v49, v50);
-        sub_40F92A(
-          &pRenderer->pActiveZBuffer[v51 + v108 + 640 * v49],
-          ItemsInShopTexture[(signed int)v109],
-          (int)((char *)v109 + 1));
-        v48 = v109;
-      }
-      v108 += 70;
-      v48 = (const char **)((char *)v48 + 1);
-      v109 = v48;
-    }
-    while ( (signed int)v48 < 6 );
-  }
-  else
-  {
-    v109 = 0;
-    v108 = 0;
-    do
-    {
-   //   if ( pParty->field_C59C[9 * (int)&v109[3 * (unsigned int)window_SpeakInHouse->ptr_1C] + 724] )
-	if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v109].uItemID)
-      {
-        v52 = word_F8B158[(signed int)v109] + 30;
-        v53 = ItemsInShopTexture[(signed int)v109];
-        v54 = 60 - ((signed int)v53->uTextureWidth >> 1);
-        pRenderer->DrawTextureTransparent(v54 + v108, word_F8B158[(signed int)v109] + 30, v53);
-        sub_40F92A(
-          &pRenderer->pActiveZBuffer[v54 + v108 + 640 * v52],
-          ItemsInShopTexture[(signed int)v109],
-          (int)((char *)v109 + 1));
-      }
-      v109 = (const char **)((char *)v109 + 1);
-      v108 += 70;
-    }
-    while ( (signed int)v109 < 6 );
-  }
-  result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-  if ( result )
-  {
-    v55 = 0;
-    v106.x = 0;
-    if ( dword_F8B19C == 2 )
-    {
-      v106.x = 0;
-      do
-      {
-        if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID);//9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
-          ++v106.x;
-        ++v55;
-      }
-      while ( v55 < 6 );
-    }
-    else
-    {
-      do
-      {
-       // if ( pParty->field_C59C[9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
-	  if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID)
-          ++v106.x;
-        ++v55;
-      }
-      while ( v55 < 6 );
-    }
-    v56 = GetAsyncKeyState(17);
-    v57 = _this->CanSteal();
-    Str = (char *)v57;
-    if ( v56 && v57 )
-    {
-      v58 = pGlobalTXT_LocalizationStrings[185];
-    }
-    else
-    {
-      v58 = pGlobalTXT_LocalizationStrings[195];
-      if ( dword_F8B19C != 2 )
-        v58 = pGlobalTXT_LocalizationStrings[196];
-    }
-    DrawTextAtStatusBar(v58, 0);
-    if ( v106.x )
-    {
-      v59 = pMouse->GetCursorPos(&v91);
-      result = (char *)(v59->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v89)->y]);
-      if ( pRenderer->pActiveZBuffer[(int)result] & 0xFFFF )
-      {
-        v60 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1;
-        v106.x = v60;
-        v61 = (int)window_SpeakInHouse->ptr_1C;
-      //  v62 = 9 * (v60 + 12 * v61);
-        v63 = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60];
-        if ( dword_F8B19C != 2 )
-          v63 = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724];
-        if ( !v56 || !Str )
-        {
-          v85 = 0;
-          v83 = 2;
-          v81 = window_SpeakInHouse->ptr_1C;
-          v79 = v63;
-          v110 = uActiveCharacter - 1;
-          v64 = _this->_490EEE(v63, 1, v61, 2);
-          v6 = v110;
-          v5 = (char *)pMerchantsBuyPhrases[v64];
-          goto LABEL_14;
-        }
-        v5 = pGlobalTXT_LocalizationStrings[181];
-        v85 = 0;
-        v83 = 2;
-        v81 = window_SpeakInHouse->ptr_1C;
-        v79 = v63;
-        goto LABEL_13;
-      }
-    }
-    else
-    {
-      v101.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C]  - pParty->uTimePlayed);
-	  result =0; //added
-    }
+		break;
+		}
+	case 4:
+		{
+		draw_leather();
+		CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+		DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);
+		result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
+		if ( result )
+		{
+			v2 = pMouse->GetCursorPos(&a2)->x - 14;
+			v106.x = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v87)->y - 17) >> 5);
+			result = (char *)pMouse->GetCursorPos(&v100);
+			if ( *(int *)result > 13 )
+			{
+				result = (char *)pMouse->GetCursorPos(&v92);
+				if ( *(int *)result < 462 )
+				{
+					result = (char *)v0->GetItemIDAtInventoryIndex((int *)&v106.x);
+					v3 = 0;
+					if ( result )
+					{
+						v85 = 0;
+						v83 = 4;
+						v4 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * (int)result + 5];
+						if (!v4->Identified())
+						{
+							v81 = window_SpeakInHouse->ptr_1C;
+							v79 = v4;
+							v9 = (int)window_SpeakInHouse->ptr_1C;
+							v110 = uActiveCharacter - 1;
+							v10 = _this->_490EEE(v4, 1, v9, 4);
+							v6 = v110;
+							v5 = (char *)pMerchantsIdentifyPhrases[v10];
+							v7 = BuilDialogueString(v5, v6, v79, (char *)v81, v83, v85);
+							v86 = 3;
+							v84 = v7;
+							v82 = v105;
+							v80 = v3;
+							v78 = v3;
+							v77 = &v101;
+							v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
+							return v101.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
+						}
+						v81 = window_SpeakInHouse->ptr_1C;
+						v5 = "%24";
+						v79 = v4;
+				//LABEL_13:
+						v6 = uActiveCharacter - 1;
+				//LABEL_14:
+						v7 = BuilDialogueString(v5, v6, v79, (char *)v81, v83, v85);
+						v86 = 3;
+						v84 = v7;
+						v82 = v105;
+						v80 = v3;
+						v78 = v3;
+						v77 = &v101;
+				//LABEL_15:
+						v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
+						return v101.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
+					}
+				}
+			}
+		}
+		break;
+		}
+	case 1:
+		{
+		result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
+		if ( result )
+		{
+			pShopOptions[0] = pGlobalTXT_LocalizationStrings[134];
+			pShopOptions[1] = pGlobalTXT_LocalizationStrings[152];
+			pShopOptions[2] = pGlobalTXT_LocalizationStrings[159];
+			v14 = 0;
+			pShopOptions[3] = pGlobalTXT_LocalizationStrings[160];
+			v15 = pShopOptions;
+			do
+			{
+				v16 = pFontArrus->CalcTextHeight(*v15, &v101, 0, 0);
+				++v15;
+				v14 += v16;
+			}
+			while ( (signed int)v15 < (signed int)&unk_F8B1C8 );
+			v17 = pDialogueWindow;
+			v103 = (174 - v14) / 4;
+			result = (char *)pDialogueWindow->pStartingPosActiveItem;
+			v18 = (int)&result[pDialogueWindow->pNumPresenceButton];
+			v19 = (174 - 4 * (174 - v14) / 4 - v14) / 2 - (174 - v14) / 4 / 2 + 138;
+			v20 = -pDialogueWindow->pNumPresenceButton < 0;
+			_this = (Player *)pDialogueWindow->pStartingPosActiveItem;
+			if ( v20 ^ __OFSUB__((int)result, v18) )
+			{
+				v108 = 2;
+				v109 = (const char **)pShopOptions;
+				do
+				{
+					v21 = v17->GetControl((unsigned int)_this);
+					v22 = v109;
+					v21->uY = v103 + v19;
+					v23 = pFontArrus->CalcTextHeight(*v22, &v101, 0, 0);
+					v24 = v21->uY;
+					v25 = v108;
+					v21->uHeight = v23;
+					v19 = v24 + v23 - 1;
+					v21->uW = v19;
+					v26 = v104;
+					if ( pDialogueWindow->pCurrentPosActiveItem != v25 )
+						v26 = v105;
+					v101.DrawTitleText(pFontArrus, 0, v24, v26, *v109, 3u);
+					v17 = pDialogueWindow;
+					++v108;
+					++v109;
+					_this = (Player *)((char *)_this + 1);
+					result = (char *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
+				}
+				while ( (signed int)_this < (signed int)result );
+			}
+		}
+		break;
+		}
+	default:
+		{
+		if( dword_F8B19C > 5 )
+			result = (char *)(dword_F8B19C - 96);
+		else
+			result = (char *)(dword_F8B19C - 4);
+		break;
+		}
   }
   return result;
 }
@@ -13349,7 +13420,7 @@
   assert(sizeof(GUIProgressBar) == 0x1B8);
   assert(sizeof(GUIFont) == 0x1020);
   assert(sizeof(stru262_TurnBased) == 0x40);
-  assert(sizeof(ArcomageGame) == 0xFA);
+  assert(sizeof(ArcomageGame) == 0xFB);
   assert(sizeof(stru277) == 0x14);
   assert(sizeof(ArcomageCard) == 0x6C);
   assert(sizeof(stru320) == 0x3FC);
--- a/mm7_3.cpp	Tue Mar 05 10:45:29 2013 +0600
+++ b/mm7_3.cpp	Tue Mar 05 10:45:40 2013 +0600
@@ -125,7 +125,7 @@
     {
       v9 = &pIndoor->pSectors[v33[result]];
       v10 = 0;
-      v32 = v9->uNumFloors + v9->field_C + v9->field_14;
+      v32 = v9->uNumFloors + v9->uNumWalls + v9->uNumCeilings;
       v26 = 0;
       if ( v32 > 0 )
         break;
@@ -1526,7 +1526,6 @@
   int v7; // [sp+10h] [bp-8h]@1
   signed int v8; // [sp+14h] [bp-4h]@1
 
-  __debugbreak();
   v5 = x - 2;
   v7 = x;
   v8 = y;
@@ -1650,10 +1649,10 @@
   v80 = _46ED1B_collide_against_floor(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID);
   if ( pParty->bFlying )
   {
-    pParty->bFlying = 0;
-    __debugbreak();
+    pParty->bFlying = false;
     if (pParty->FlyActive())
-      stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u;// 005E4D58 pOtherOverlayList [negindexing]
+      pOtherOverlayList->pOverlays[pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID - 1].field_E |= 1;
+      //stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] |= 1u;// 005E4D58 pOtherOverlayList [negindexing]
   }
   if ( v80 == -30000 )
   {
--- a/mm7_4.cpp	Tue Mar 05 10:45:29 2013 +0600
+++ b/mm7_4.cpp	Tue Mar 05 10:45:40 2013 +0600
@@ -3210,7 +3210,7 @@
     if ( v7 == 0 )
       v7 = 1;
     if (pPlayer->expression == CHARACTER_EXPRESSION_21)
-      pFrame = pPlayerFrameTable->GetFrameBy_y(&pPlayer->field_1AA8, &pPlayer->field_1AA4, pMiscTimer->uTimeElapsed);
+      pFrame = pPlayerFrameTable->GetFrameBy_y(&pPlayer->_expression21_frameset, &pPlayer->_expression21_animtime, pMiscTimer->uTimeElapsed);
     else
       pFrame = pPlayerFrameTable->GetFrameBy_x(v7, pPlayer->uExpressionTimePassed);
     if (pPlayer->field_1AA2 != pFrame->uTextureID - 1 || v22 )
@@ -4335,25 +4335,25 @@
 }
 
 //----- (00494B5E) --------------------------------------------------------
-PlayerFrame *PlayerFrameTable::GetFrameBy_y(int *a2, int *a3, int a4)
+PlayerFrame *PlayerFrameTable::GetFrameBy_y(int *pFramesetID, int *pAnimTime, int a4)
 {
   PlayerFrameTable *v4; // edi@1
   int v5; // esi@1
   int v6; // eax@2
 
   v4 = this;
-  v5 = a4 + *a3;
-  if ( v5 < 8 * this->pFrames[*a2].uAnimTime )
-  {
-    *a3 = v5;
+  v5 = a4 + *pAnimTime;
+  if ( v5 < 8 * this->pFrames[*pFramesetID].uAnimTime )
+  {
+    *pAnimTime = v5;
   }
   else
   {
     v6 = rand() % 4 + 21;
-    *a2 = v6;
-    *a3 = 8 * v5 % v4->pFrames[v6].uAnimTime;
-  }
-  return &v4->pFrames[*a2];
+    *pFramesetID = v6;
+    *pAnimTime = 8 * v5 % v4->pFrames[v6].uAnimTime;
+  }
+  return &v4->pFrames[*pFramesetID];
 }
 
 //----- (00494BC3) --------------------------------------------------------
@@ -4806,33 +4806,16 @@
 //----- (00495430) --------------------------------------------------------
 char *__fastcall GetReputationString(signed int a1)
 {
-  char *result; // eax@2
-
-  if ( a1 < 25 )
-  {
-    if ( a1 < 6 )
-    {
-      if ( a1 < -5 )
-      {
-        result = pGlobalTXT_LocalizationStrings[402];
-        if ( a1 < -24 )
-          result = pGlobalTXT_LocalizationStrings[434];
-      }
-      else
-      {
-        result = pGlobalTXT_LocalizationStrings[399];
-      }
-    }
-    else
-    {
-      result = pGlobalTXT_LocalizationStrings[392];
-    }
-  }
+  if (a1 >= 25)
+    return pGlobalTXT_LocalizationStrings[379]; // Hated
+  else if (a1 >= 6)
+    return pGlobalTXT_LocalizationStrings[392]; // Unfriendly
+  else if (a1 >= -5)
+    return pGlobalTXT_LocalizationStrings[399]; // Neutral;
+  else if (a1 >= -24)
+    return pGlobalTXT_LocalizationStrings[402]; // Friendly
   else
-  {
-    result = pGlobalTXT_LocalizationStrings[379];
-  }
-  return result;
+    return pGlobalTXT_LocalizationStrings[434]; // Respected;
 }
 
 //----- (00495461) --------------------------------------------------------
--- a/mm7_5.cpp	Tue Mar 05 10:45:29 2013 +0600
+++ b/mm7_5.cpp	Tue Mar 05 10:45:40 2013 +0600
@@ -11561,7 +11561,7 @@
       v61 = 116 * v59;
       sDepthb = 0;
       for ( i = 116 * v59;
-            sDepthb < *(__int16 *)((char *)&pIndoor->pSectors->field_C + v61)
+            sDepthb < *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v61)
                     + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v61);
             ++sDepthb )
       {
@@ -11715,7 +11715,7 @@
       v89 = 116 * v87;
       v162 = 0;
       v112 = v89;
-      if ( *(__int16 *)((char *)&pIndoor->pSectors->field_C + v89)
+      if ( *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89)
          + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) > 0 )
         break;
 LABEL_148:
@@ -11795,7 +11795,7 @@
 LABEL_145:
       v88 = pIndoor->pSectors;
       ++v162;
-      if ( v162 >= *(__int16 *)((char *)&pIndoor->pSectors->field_C + v89)
+      if ( v162 >= *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89)
                  + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) )
         goto LABEL_148;
     }
@@ -15063,542 +15063,241 @@
     pWindowType = pWindow->eWindowType;
     switch (pWindow->eWindowType)
     {
-      case WINDOW_MainMenu_Load:
-        GameUI_MainMenu_DrawLoad();
-        continue;
-      case WINDOW_5E: // window that initiates savegame loading
-      {
-        if (pWindow->Hint != (char *)1)
-          pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
-        auto pGUIButton3 = (GUIButton *)pWindow->ptr_1C;
-        pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pGUIButton3->pTextures[0]);
-        pHint = pWindow->Hint;
-        viewparams->bRedrawGameUI = 1;
-        if ( pHint && pHint != (char *)1 )
-          pGUIButton3->DrawLabel(pHint, pFontCreate, 0, 0);
-        pWindow->Release();
-        if (pCurrentScreen == SCREEN_SAVEGAME)
-          pMessageQueue_50CBD0->AddMessage(UIMSG_SaveGame, 0, 0);
-        else
-          pMessageQueue_50CBD0->AddMessage(UIMSG_LoadGame, 0, 0);
-      }
-      continue;
-    }
-    if ( (signed int)pWindowType > 70 )
-    {
-      if ( (signed int)pWindowType > 95 )
-      {
-        v33 = pWindowType - 96;
-        if ( pWindowType == WINDOW_60 )//96
-        {
-          if ( pWindow->Hint != (char *)1 )
-            pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
-          pGUIButton = (GUIButton *)pWindow->ptr_1C;
-          pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pGUIButton->pTextures[0]);
-          pHint = pWindow->Hint;
-          viewparams->bRedrawGameUI = 1;
-          if ( pHint && pHint != (char *)1 )
-            pGUIButton->DrawLabel(pHint, pFontCreate, 0, 0);
-          pWindow->Release();
-          /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
-            continue;
-          pNumMessages = pMessageQueue_50CBD0->uNumMessages;
-//LABEL_151:
-          pMessageQueue_50CBD0->pMessages[pNumMessages].eType = (UIMessageType)113;
-//LABEL_152:
-          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
-          *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-          ++pMessageQueue_50CBD0->uNumMessages;*/
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-          continue;
-        }
-        v34 = v33 - 1;
-        if ( v34 )//pWindowType > 97
-        {
-          v35 = v34 - 1;
-          if ( v35 )//pWindowType > 98
-          {
-            v36 = v35 - 1;
-            if ( v36 )//pWindowType > 99
-            {
-              v37 = v36 - 4;
-              if ( v37 )//pWindowType > 103
-              {
-                v38 = v37 - 2;
-                if ( v38 )//pWindowType > 105
-                {
-                  if ( pWindowType == WINDOW_VideoOptions )
-                    GameMenuUI_DrawVideoOptions();
-                }
-                else if ( pWindowType == WINDOW_KeyMappingOptions )
-                {
-                  GameMenuUI_DrawKeyBindings();
-                }
-              }
-              else//pWindowType == WINDOW_67
-              {
-                pWindow->DrawMessageBox(0);
-                pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
-                pWindow->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
-                if ( !pKeyActionMap->field_204 )
-                {
-                  ItemGen2.Reset();
-                  pWindow->Release();
-                  pEventTimer->Resume();
-                  pCurrentScreen = SCREEN_GAME;
-                  viewparams->bRedrawGameUI = 1;
-                  v39 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
-                  if ( v39 > 0 )
-                  {
-                    if ( v39 < 800 )
-                      SpawnActor(v39);
-                  }
-                }
-              }
-              continue;
-            }
-            pTexture = (Texture *)*((_DWORD *)pWindow->ptr_1C + 15);//pWindowType == 99 (0x63) WINDOW_63
+		case WINDOW_MainMenu_Load:
+			{
+			GameUI_MainMenu_DrawLoad();
+			break;
+			}
+		case WINDOW_5E: // window that initiates savegame loading
+			{
+			if (pWindow->Hint != (char *)1)
+				pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
+			auto pGUIButton3 = (GUIButton *)pWindow->ptr_1C;
+			pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pGUIButton3->pTextures[0]);
+			pHint = pWindow->Hint;
+			viewparams->bRedrawGameUI = 1;
+			if ( pHint && pHint != (char *)1 )
+				pGUIButton3->DrawLabel(pHint, pFontCreate, 0, 0);
+			pWindow->Release();
+			if (pCurrentScreen == SCREEN_SAVEGAME)
+				pMessageQueue_50CBD0->AddMessage(UIMSG_SaveGame, 0, 0);
+			else
+				pMessageQueue_50CBD0->AddMessage(UIMSG_LoadGame, 0, 0);
+			break;
+			}
+		case WINDOW_3:
+			{
+			pTexture = (Texture *)(uTextureID_Options != -1 ? &pIcons_LOD->pTextures[uTextureID_Options] : 0);//pWindowType == 3 (0x3)
+			pY = pViewport->uViewportY;
+			pX = pViewport->uViewportX;
+			pRenderer->DrawTextureIndexed(pX, pY, pTexture);
+			viewparams->bRedrawGameUI = 1;
+			break;
+			}
+		case WINDOW_CharacterRecord:
+			{
+			CharacterUI_CharacterScreen_Draw(uActiveCharacter);
+			break;
+			}
+		case WINDOW_Options:
+			{
+			DrawGameOptions();
+			break;
+			}
+		case WINDOW_Book:
+			{
+			SellectDrawBook((unsigned int)pWindow->ptr_1C);
+			break;
+			}
+		case WINDOW_QuickReference:
+			{
+            QuickRefDraw();
+			break;
+			}
+		case WINDOW_Rest:
+			{
+			RestUI_Draw();
+			break;
+			}
+		case WINDOW_Dialogue:
+			{
+			DrawDialogueUI();
+			break;
+			}
+		case WINDOW_ChangeLocation:
+			{
+            TravelUI_Draw();
+			break;
+			}
+		case WINDOW_SpellBook:
+			{
+			DrawSpellBookContent();
+			break;
+			}
+		case WINDOW_GreetingNPC:
+			{
+			DrawBranchlessDialogueUI();
+			break;
+			}
+		case WINDOW_Transition:
+			{
+			TransitionUI_Draw();
+			break;
+			}
+		case WINDOW_Scroll:
+			{
+			CreateScrollWindow();
+			break;
+			}
+		case WINDOW_FinalWindow:
+			{
+			sub_41420D_press_esc();
+			break;
+			}
+		case WINDOW_VideoOptions:
+			{
+			GameMenuUI_DrawVideoOptions();
+			break;
+			}
+		case WINDOW_KeyMappingOptions:
+			{
+			GameMenuUI_DrawKeyBindings();
+			break;
+			}
+		case WINDOW_17:
+			{
+			sub_4606FE();
+			break;
+			}
+		case WINDOW_1F:
+			{
+            pRenderer->ClearZBuffer(0, 479);
+            draw_leather();
+            CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+            CharacterUI_DrawPaperdoll(uActiveCharacter);
+            pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY,
+                (Texture *)(uTextureID_x_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_x_u] : 0));
+			break;
+			}
+		case WINDOW_RestWindow:
+			{	
+			memset(&GUIButton2, 0, 0xBCu);//pWindowType == 98 (0x62) WINDOW_RestWindow
+			GUIButton2.uZ = 197;
+			GUIButton2.uW = 197;
+			GUIButton2.uX = 27;
+			GUIButton2.uY = 161;
+			GUIButton2.uWidth = 171;
+			GUIButton2.uHeight = 37;
+			GUIButton2.pParent = pButton_RestUI_WaitUntilDawn->pParent;
+			pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
+			pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)pWindow->ptr_1C + 15));
+			viewparams->bRedrawGameUI = 1;
+			GUIButton2.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, 0, 0);//   8 
+			GUIButton2.pParent = 0;
+			pGUIWindow2 = pWindow;
+			pGUIWindow2->Release();
+			break;
+			}
+		case WINDOW_60:
+			{
+			if ( pWindow->Hint != (char *)1 )
+				pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
+			pGUIButton = (GUIButton *)pWindow->ptr_1C;
+			pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pGUIButton->pTextures[0]);
+			pHint = pWindow->Hint;
+			viewparams->bRedrawGameUI = 1;
+			if ( pHint && pHint != (char *)1 )
+				pGUIButton->DrawLabel(pHint, pFontCreate, 0, 0);
+			pWindow->Release();
+			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+			break;
+			}
+		case WINDOW_61:
+			{
+			if ( pWindow->Hint != (char *)1 )//pWindowType == WINDOW_61
+				pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
+			v32 = pWindow->ptr_1C;
+			pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)v32 + 16));
+			pHint = pWindow->Hint;
+			viewparams->bRedrawGameUI = 1;
+			if ( pHint && pHint != (char *)1 )
+				((GUIButton *)v32)->DrawLabel(pHint, pFontCreate, 0, 0);
+			pWindow->Release();
+			pNumMessages = pMessageQueue_50CBD0->uNumMessages;
+			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+			break;
+			}
+		case WINDOW_63:
+			{
+			pTexture = (Texture *)*((_DWORD *)pWindow->ptr_1C + 15);//pWindowType == 99 (0x63) WINDOW_63
             pY = pWindow->uFrameY;
             pX = pWindow->uFrameX;
-//LABEL_18:
             pRenderer->DrawTextureIndexed(pX, pY, pTexture);
-//LABEL_114:
             viewparams->bRedrawGameUI = 1;
-            continue;
-          }
-          memset(&GUIButton2, 0, 0xBCu);//pWindowType == 98 (0x62) WINDOW_RestWindow
-          GUIButton2.uZ = 197;
-          GUIButton2.uW = 197;
-          GUIButton2.uX = 27;
-          GUIButton2.uY = 161;
-          GUIButton2.uWidth = 171;
-          GUIButton2.uHeight = 37;
-          GUIButton2.pParent = pButton_RestUI_WaitUntilDawn->pParent;
-          pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
-          pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)pWindow->ptr_1C + 15));
-          viewparams->bRedrawGameUI = 1;
-          GUIButton2.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, 0, 0);//   8 
-          GUIButton2.pParent = 0;
-          //goto LABEL_134;
-          pGUIWindow2 = pWindow;
-          //goto LABEL_110;
-          pGUIWindow2->Release();
-          continue;
-        }
-        if ( pWindow->Hint != (char *)1 )//pWindowType == WINDOW_61
-          pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
-        v32 = pWindow->ptr_1C;
-        pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)v32 + 16));
-        //goto LABEL_138;
-        pHint = pWindow->Hint;
-        viewparams->bRedrawGameUI = 1;
-        if ( pHint && pHint != (char *)1 )
-          ((GUIButton *)v32)->DrawLabel(pHint, pFontCreate, 0, 0);
-        pWindow->Release();
-        pNumMessages = pMessageQueue_50CBD0->uNumMessages;
-        /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-        {
-         pMessageQueue_50CBD0->pMessages[pNumMessages].eType = (UIMessageType)113;
-         pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
-         *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-         ++pMessageQueue_50CBD0->uNumMessages;
-         continue;
-        }*/
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-        continue;
-      }
-
-      if ( pWindowType == WINDOW_5F )
-      {
-        if ( pWindow->Hint != (char *)1 )
-          pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
-        v32 = pWindow->ptr_1C;
-        pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)v32 + 15));
-//LABEL_138:
-        pHint = pWindow->Hint;
-        viewparams->bRedrawGameUI = 1;
-        if ( pHint && pHint != (char *)1 )
-          ((GUIButton *)v32)->DrawLabel(pHint, pFontCreate, 0, 0);
-        pWindow->Release();
-//LABEL_142:
-        pNumMessages = pMessageQueue_50CBD0->uNumMessages;
-        /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-          //goto LABEL_151;
-        {
-         pMessageQueue_50CBD0->pMessages[pNumMessages].eType = (UIMessageType)113; //0x71
-         pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
-         *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-         ++pMessageQueue_50CBD0->uNumMessages;
-         continue;
-        }*/
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-        continue;
-      }
-      v14 = pWindowType - 80;
-      if ( v14 )//pWindowType > 80
-      {
-        v15 = v14 - 9;
-        if ( pWindowType == WINDOW_59)
-        {
-          pWindow->DrawMessageBox(0);
-          pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
-          pWindow->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
-          if ( !pKeyActionMap->field_204 )
-          {
-            pItemGen.Reset();
-            pWindow->Release();
-            pEventTimer->Resume();
-            pCurrentScreen = SCREEN_GAME;
-            viewparams->bRedrawGameUI = 1;
-            v26 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
-            if ( v26 > 0 )
-            {
-              if ( v26 < 800 )
-              {
-                pItemGen.SetIdentified();
-                pItemGen.uItemID = v26;
-                if ( pItemsTable->pItems[v26].uEquipType == 12 )
+            break;
+			}
+		case WINDOW_CharacterWindow_Inventory:
+			{
+            pWindow->DrawMessageBox(0);
+            pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
+            pWindow->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
+            if ( !pKeyActionMap->field_204 )
+            {
+                ItemGen2.Reset();
+                pWindow->Release();
+                pEventTimer->Resume();
+                pCurrentScreen = SCREEN_GAME;
+                viewparams->bRedrawGameUI = 1;
+                v39 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
+                if ( v39 > 0 )
                 {
-                  pItemGen.uNumCharges = rand() % 6 + pItemsTable->pItems[pItemGen.uItemID].uDamageMod + 1;
-                  pItemGen.uMaxCharges = LOBYTE(pItemGen.uNumCharges);
-                }
-                else
-                {
-                  if ( v26 >= 221 && v26 < 271 )
-                    pItemGen.uEncantmentType = rand() % 10 + 1;
-                }
-                pItemsTable->SetSpecialBonus(&pItemGen);
-                pParty->SetHoldingItem(&pItemGen);
-              }
-            }
-          }
-          continue;
-        }
-        v16 = v15 - 1;
-        if ( pWindowType == WINDOW_5A ) // Press buttons in title menu and in game, and escape in game
-        {
-          if ( pWindow->Hint != (char *)1 )
-            pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
-          pButtonPtr_1C = (GUIButton *)pWindow->ptr_1C;
-          if ( pButtonPtr_1C->uX >= 0 )//if ( (pButtonPtr_1C->uX & 0x80000000u) == 0 )
-          {
-            if ( (signed int)pButtonPtr_1C->uX <= 640 )
-            {
-              //v25 = pButtonPtr_1C->uY;
-              if ( pButtonPtr_1C->uY >= 0 ) //if ( (pButtonPtr_1C->uY & 0x80000000u) == 0 )
-              {
-                if ( (signed int)pButtonPtr_1C->uY <= 480 )
-                {
-                  pTexture2 = pButtonPtr_1C->pTextures[0];
-                  //goto LABEL_94;
-                 pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pTexture2);
-                 pHint1 = pWindow->Hint;
-                 viewparams->bRedrawGameUI = 1;
-                if ( pHint1 )
-                {
-                  v24 = pHint1 == (char *)1;
-                  if ( !v24 )
-                    pButtonPtr_1C->DrawLabel(pHint1, pFontCreate, 0, 0);
-                }
-                pGUIWindow2 = pWindow;
-                pGUIWindow2->Release();
-                continue;
+                if ( v39 < 800 )
+                    SpawnActor(v39);
                 }
-              }
-            }
-          }
-          pHint1 = pWindow->Hint;
-          viewparams->bRedrawGameUI = 1;
-          if ( pHint1 )
-          {
-            v24 = pHint1 == (char *)1;
-            //goto LABEL_82;
-            if ( !v24 )
-              pButtonPtr_1C->DrawLabel(pHint1, pFontCreate, 0, 0);
-            pGUIWindow2 = pWindow;
-            pGUIWindow2->Release();
-            continue;
-          }
-//LABEL_134:
-          pGUIWindow2 = pWindow;
-          //goto LABEL_110;
-          pGUIWindow2->Release();
-          continue;
-        }
-        v17 = v16 - 1;
-        if ( pWindowType == WINDOW_5B )//Change button in Character window
-        {
-          if ( pWindow->Hint != (char *)1 )
-            pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
-          pButtonPtr_1C = (GUIButton *)pWindow->ptr_1C;
-          pTexture2 = pButtonPtr_1C->pTextures[1];
-//LABEL_94:
-          pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pTexture2);
-//LABEL_80:
-          pHint1 = pWindow->Hint;
-          viewparams->bRedrawGameUI = 1;
-          if ( pHint1 )
-          {
-            v24 = pHint1 == (char *)1;
-//LABEL_82:
-            if ( !v24 )
-              pButtonPtr_1C->DrawLabel(pHint1, pFontCreate, 0, 0);
-          }
-          //goto LABEL_134;
-          pGUIWindow2 = pWindow;
-          //goto LABEL_110;
-          pGUIWindow2->Release();
-          continue;
-        }
-        v18 = v17 - 1;
-        if ( pWindowType == WINDOW_VoiceSwitcherButton ) // Change page in AutonotesBook
-        {
-          if ( pWindow->Hint != (char *)1 )
-            pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
-          pButtonPtr_1C = (GUIButton *)pWindow->ptr_1C;
-          pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, pButtonPtr_1C->pTextures[0]);
-          //goto LABEL_80;
-          pHint1 = pWindow->Hint;
-          viewparams->bRedrawGameUI = 1;
-          if ( pHint1 )
-          {
-            v24 = pHint1 == (char *)1;
-            if ( !v24 )
-              pButtonPtr_1C->DrawLabel(pHint1, pFontCreate, 0, 0);
-          }
-          pGUIWindow2 = pWindow;
-          pGUIWindow2->Release();
-          continue;
-        }
-        v19 = v18 - 1;
-        if ( pWindowType == WINDOW_5D )
-        {
-          if ( pWindow->Hint != (char *)1 )
-            pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
-          pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)pWindow->ptr_1C + 16));
-          viewparams->bRedrawGameUI = 1;
-          //goto LABEL_134;
-          pGUIWindow2 = pWindow;
-          //goto LABEL_110;
-          pGUIWindow2->Release();
-          continue;
-        }
-      }
-      else if ( pWindowType == WINDOW_50 )
-      {
-        v27 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-        if ( ptr_507BD0->field_40 == 1 )
-        {
-          ptr_507BD0->DrawMessageBox(0);
-          ptr_507BD0->DrawText(pFontCreate, 30, 40, v27, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
-          pGUIFont = pFontCreate;
-          v31 = pFontCreate->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
-          ptr_507BD0->DrawFlashingInputCursor(v31 + 30, 40, pGUIFont);
-          continue;
-        }
-        if ( ptr_507BD0->field_40 == 2 )
-        {
-          v29 = pMessageQueue_50CBD0->uNumMessages;
-          pWindow->field_40 = 0;
-          /*if ( (signed int)v29 < 40 )
-          {
-            pMessageQueue_50CBD0->pMessages[v29].eType = (UIMessageType)(int)ptr_507BD0->ptr_1C;
-            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
-            *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-            ++pMessageQueue_50CBD0->uNumMessages;
-          }*/
-          pMessageQueue_50CBD0->AddMessage((UIMessageType)(int)ptr_507BD0->ptr_1C, 0, 0);
-          pEventTimer->Resume();
-          ptr_507BD0->Release();
-          pCurrentScreen = SCREEN_GAME;
-          //goto LABEL_114;
-          viewparams->bRedrawGameUI = 1;
-          continue;
-        }
-        if ( ptr_507BD0->field_40 == 3 )
-        {
-          pWindow->field_40 = 0;
-          pEventTimer->Resume();
-          pGUIWindow2 = ptr_507BD0;
-//LABEL_110:
-          pGUIWindow2->Release();
-          continue;
-        }
-      }
-    }
-    else
-    {
-      if ( pWindowType == WINDOW_FinalWindow )
-      {
-        sub_41420D_press_esc();
-        continue;
-      }
-      if ( (signed int)pWindowType > 18 )
-      {
-        if ( (signed int)pWindowType > 25 )
-        {
-          v12 = pWindowType - 26;
-          if ( v12 )// pWindowType > 26
-          {
-            v13 = v12 - 4;
-            if ( v13 )//pWindowType > 30
-            {
-              if ( pWindowType == WINDOW_1F)
-              {
-                pRenderer->ClearZBuffer(0, 479);
-                draw_leather();
-                CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
-                CharacterUI_DrawPaperdoll(uActiveCharacter);
-                pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY,
-                  (Texture *)(uTextureID_x_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_x_u] : 0));
-              }
-            }
-            else if( pWindowType == WINDOW_Scroll)
-            {
-              CreateScrollWindow();
-            }
-          }
-          else if ( pWindowType == WINDOW_Transition )
-          {
-            TransitionUI_Draw();
-          }
-          continue;
-        }
-        if ( pWindowType != 25 )
-        {
-          v7 = pWindowType - 19;
-          if ( v7 )// pWindowType > 19
-          {
-            v8 = v7 - 1;
-            if ( v8 )// pWindowType > 20
-            {
-              v9 = v8 - 3;
-              if ( v9 )//pWindowType > 23
-              {
-                //if ( v9 == 1 ) //pWindowType == 24 (0x18) WINDOW_MainMenu_Load
-                //  sub_4606F7();
-              }
-              else if ( pWindowType == WINDOW_17 )
-              {
-                sub_4606FE();
-              }
-            }
-            else if ( pWindowType == WINDOW_Chest )
-            {
-              if ( pCurrentScreen == SCREEN_CHEST )
-              {
-                Chest::DrawChestUI((unsigned int)pWindow->ptr_1C);
-              }
-              else
-              {
-                if ( pCurrentScreen == SCREEN_F )
-                {
-                  pRenderer->ClearZBuffer(0, 479);
-                  draw_leather();
-                  CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
-                  pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY,
-                    (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0));
-                }
-              }
-            }
-          }
-          else if (pWindowType == WINDOW_GreetingNPC )
-          {
-            DrawBranchlessDialogueUI();
-          }
-          continue;
-        }
-        pWindowList[pVisibleWindowsIdxs[i] - 1].HouseDialogManager();
-        if ( !window_SpeakInHouse )
-          continue;
-        v10 = window_SpeakInHouse->ptr_1C;
-        if ( (signed int)v10 >= 53 )
-          continue;
-        if ( pParty->field_3C._shop_ban_times[(signed int)v10] <=pParty->uTimePlayed )
-        {
-          if ( (signed int)v10 < 53 )
-          {
-              pParty->field_3C._shop_ban_times[(signed int)v10] = 0;
-          }
-          continue;
-        }
-        //goto LABEL_142;
-        pNumMessages = pMessageQueue_50CBD0->uNumMessages;
-        /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-        {
-         pMessageQueue_50CBD0->pMessages[pNumMessages].eType = (UIMessageType)113;
-         pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
-         *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-         ++pMessageQueue_50CBD0->uNumMessages;
-         continue;
-        }*/
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-        continue;
-      }
-      if ( pWindowType == WINDOW_SpellBook )
-      {
-        DrawSpellBookContent();
-      }
-      else
-      {
-        if ( (signed int)pWindowType > 10 )
-        {
-          v5 = pWindowType - 12;
-          if ( v5 )//pWindowType >12
-          {
-            v6 = v5 - 4;
-            if ( v6 )//pWindowType > 16
-            {
-              if ( pWindowType == WINDOW_ChangeLocation )
-                TravelUI_Draw();
-            }
-            else if ( pWindowType == WINDOW_Rest )
-            {
-              RestUI_Draw();
-            }
-          }
-          else if (pWindowType == WINDOW_QuickReference )
-          {
-            QuickRefDraw();
-          }
-          continue;
-        }
-        if ( pWindowType != 10 ) //pWindowType == 10
-        {
-          v2 = pWindowType - 3;
-          if ( v2 )//pWindowType > 3
-          {
-            v3 = v2 - 1;
-            if ( v3 )// pWindowType > 4
-            {
-              v4 = v3 - 2;
-              if ( v4 )//pWindowType > 6
-              {
-                if ( pWindowType == WINDOW_Book )
-                  SellectDrawBook((unsigned int)pWindow->ptr_1C);
-              }
-              else if (pWindowType == WINDOW_Options)
-              {
-                DrawGameOptions();
-              }
-            }
-            else if (pWindowType == WINDOW_CharacterRecord)
-            {
-              CharacterUI_CharacterScreen_Draw(uActiveCharacter);
-            }
-            continue;
-          }
-          pTexture = (Texture *)(uTextureID_Options != -1 ? &pIcons_LOD->pTextures[uTextureID_Options] : 0);//pWindowType == 3 (0x3)
-          pY = pViewport->uViewportY;
-          pX = pViewport->uViewportX;
-          //goto LABEL_18;
-          pRenderer->DrawTextureIndexed(pX, pY, pTexture);
-          viewparams->bRedrawGameUI = 1;
-          continue;
-        }
-        DrawDialogueUI();
-      }
-    }
+            }
+			break;
+			}
+		case WINDOW_Chest:
+			{
+            if ( pCurrentScreen == SCREEN_CHEST )
+            {
+	            Chest::DrawChestUI((unsigned int)pWindow->ptr_1C);
+            }
+            else if ( pCurrentScreen == SCREEN_F )
+			{
+				pRenderer->ClearZBuffer(0, 479);
+				draw_leather();
+				CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+				pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY,
+				(Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0));
+			}
+			break;
+			}
+		case WINDOW_HouseInterior:
+			{
+	        pWindowList[pVisibleWindowsIdxs[i] - 1].HouseDialogManager();
+			if ( !window_SpeakInHouse )
+			  continue;
+			v10 = window_SpeakInHouse->ptr_1C;
+			if ( (signed int)v10 >= 53 )
+			  continue;
+			if ( pParty->field_3C._shop_ban_times[(signed int)v10] <=pParty->uTimePlayed )
+			{
+			  if ( (signed int)v10 < 53 )
+			  {
+				  pParty->field_3C._shop_ban_times[(signed int)v10] = 0;
+			  }
+			  continue;
+			}
+			pNumMessages = pMessageQueue_50CBD0->uNumMessages;
+			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+			break;
+			}
+		default:
+			{
+			break;
+			}
+	}
   }
   if ( GetCurrentMenuID() == -1 )
     GameUI_DrawFoodAndGold();
@@ -16248,79 +15947,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 +16111,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;
 }
--- a/mm7_data.cpp	Tue Mar 05 10:45:29 2013 +0600
+++ b/mm7_data.cpp	Tue Mar 05 10:45:40 2013 +0600
@@ -1895,30 +1895,32 @@
 int dword_50B638[777]; // weak
 int dword_50B700; // weak
 int dword_50B738[777]; // idb
-int _50B744_view_transformed_ys[43];
+int _50B744_view_transformed_ys[45];
 int dword_50B828[777];
-int _50B834_view_transformed_zs[43];
+int _50B834_view_transformed_zs[45];
 int dword_50B918[777];
-int _50B924_view_transformed_xs[43];
-int unk_50B9D4[777]; // idb
+int _50B924_view_transformed_xs[45];
+//int unk_50B9D4[777]; // idb
 int dword_50B9D8_ys[777];
-int dword_50B9E0_ys[777]; // idb
-int dword_50B9EC[777]; // idb
+int dword_50B9E4[777];
+//int dword_50B9E0_ys[777]; // idb
+//int dword_50B9EC[777]; // idb
 int dword_50B9F0[2]; // idb
-int dword_50BAE8_xs[777];
-int dword_50BAF4_xs[777];
-int dword_50B9F8[777]; // idb
-int dword_50BA08[777]; // idb
-int dword_50BAC4[777]; // weak
+//int dword_50BAE8_xs[777];
+//int dword_50BAF4_xs[777];
+//int dword_50B9F8[777]; // idb
+int dword_50B9FC_ys[3 + 45];
+int dword_50BA08_ys[48]; // idb
+//int dword_50BAC4[777]; // weak
 int dword_50BAC8[777]; // idb
-int dword_50BAD0[777]; // weak
+//int dword_50BAD0[777]; // weak
 int dword_50BAD4[777]; // weak
-int dword_50BADC_xs[777]; // weak
+//int dword_50BADC_xs[777]; // weak
 int dword_50BAE0[777]; // weak
 int dword_50BAE8[777]; // weak
-int dword_50BAEC_xs[777]; // weak
-int dword_50BAF4[777]; // weak
-int dword_50BAF8_xs[777]; // weak
+int dword_50BAEC_xs[3 + 45]; // weak
+//int dword_50BAF4[777]; // weak
+int dword_50BAF8_xs[48]; // weak
 int dword_50BC10[777]; // weak
 int dword_50BDA0[777]; // weak
 int dword_50BF30[777]; // weak
--- a/mm7_data.h	Tue Mar 05 10:45:29 2013 +0600
+++ b/mm7_data.h	Tue Mar 05 10:45:40 2013 +0600
@@ -1225,29 +1225,31 @@
 extern int dword_50B638[]; // weak
 extern int dword_50B700; // weak
 extern int dword_50B738[]; // idb
-extern int _50B744_view_transformed_ys[43];
+extern int _50B744_view_transformed_ys[];
 extern int dword_50B828[];
-extern int _50B834_view_transformed_zs[43];
+extern int _50B834_view_transformed_zs[];
 extern int dword_50B918[];
-extern int _50B924_view_transformed_xs[43];
-extern int unk_50B9D4[]; // idb
+extern int _50B924_view_transformed_xs[];
+//extern int unk_50B9D4[]; // idb
 extern int dword_50B9D8_ys[];
-extern int dword_50B9E0_ys[]; // idb
-extern int dword_50B9EC[]; // idb
-extern int dword_50B9F0[2]; // idb
-extern int dword_50BAE8_xs[];
-extern int dword_50BAF4_xs[];
-extern int dword_50B9F8[]; // idb
-extern int dword_50BA08[]; // idb
-extern int dword_50BAC4[]; // weak
+extern int dword_50B9E4[];
+//extern int dword_50B9E0_ys[]; // idb
+//extern int dword_50B9EC[]; // idb
+extern int dword_50B9F0[]; // idb
+//extern int dword_50BAE8_xs[];
+//extern int dword_50BAF4_xs[];
+//extern int dword_50B9F8_xs[]; // idb
+extern int dword_50B9FC_ys[];
+extern int dword_50BA08_ys[]; // idb
+//extern int dword_50BAC4[]; // weak
 extern int dword_50BAC8[]; // idb
-extern int dword_50BAD0[]; // weak
+//extern int dword_50BAD0[]; // weak
 extern int dword_50BAD4[]; // weak
-extern int dword_50BADC_xs[]; // weak
+//extern int dword_50BADC_xs[]; // weak
 extern int dword_50BAE0[]; // weak
 extern int dword_50BAE8[]; // weak
 extern int dword_50BAEC_xs[]; // weak
-extern int dword_50BAF4[]; // weak
+//extern int dword_50BAF4[]; // weak
 extern int dword_50BAF8_xs[]; // weak
 extern int dword_50BC10[]; // weak
 extern int dword_50BDA0[]; // weak
@@ -1877,7 +1879,6 @@
 unsigned int __fastcall GetSizeInInventorySlots(unsigned int uNumPixels);
 void __fastcall CharacterUI_InventoryTab_Draw(unsigned int uPlayerID, char a2);
 void __cdecl draw_leather();
-char __cdecl QuickRefDraw();
 void __thiscall CharacterUI_CharacterScreen_Draw(unsigned int uPlayerIdx); // idb
 void __cdecl GameUI_DrawRightPanelItems();
 void __cdecl GameUI_DrawFoodAndGold();
@@ -1893,7 +1894,7 @@
 void __cdecl GameUI_DrawStatusBar();
 bool __thiscall sub_41CD4F(unsigned int _this);
 char __fastcall sub_41D20D_buff_remaining_time_string(int ecx0, struct GUIWindow *edx0, __int64 a3, struct GUIFont *a2);
-void GameUI_DrawItemInfo(struct ItemGen *_this); // idb
+void GameUI_DrawItemInfo(struct ItemGen* inspect_item); // idb
 char *__fastcall MonsterPopup_Draw(unsigned int uActorID, struct GUIWindow *edx0);
 void __cdecl nullsub_3(); // idb
 void __cdecl LoadActualSkyFrame();
--- a/stru123.h	Tue Mar 05 10:45:29 2013 +0600
+++ b/stru123.h	Tue Mar 05 10:45:40 2013 +0600
@@ -6,7 +6,7 @@
 struct stru123
 {
   char field_0[75];
-  char _decor_events[125];
+  unsigned char _decor_events[125];
 };
 #pragma pack(pop)
 extern stru123 stru_5E4C90;
\ No newline at end of file
--- a/stru6.cpp	Tue Mar 05 10:45:29 2013 +0600
+++ b/stru6.cpp	Tue Mar 05 10:45:40 2013 +0600
@@ -741,11 +741,11 @@
 //----- (004A81CA) --------------------------------------------------------
 bool stru6::_4A81CA(SpriteObject *a2)
 {
-  stru6 *v2; // ebx@1
+  //stru6 *v2; // ebx@1
   int result; // eax@1
   int v4; // eax@27
-  unsigned int diffuse; // esi@41
-  int v6; // ecx@49
+  //unsigned int diffuse; // esi@41
+  //int v6; // ecx@49
   int v7; // eax@54
   int v8; // eax@55
   char v9; // zf@56
@@ -760,97 +760,172 @@
   int v18; // eax@140
   int v19; // eax@141
   int v20; // eax@151
-  unsigned int v21; // [sp-8h] [bp-20h]@66
-  SpriteObject *v22; // [sp-8h] [bp-20h]@81
-  unsigned int v23; // [sp-4h] [bp-1Ch]@4
-  unsigned int v24; // [sp-4h] [bp-1Ch]@5
+  //unsigned int v21; // [sp-8h] [bp-20h]@66
+  //SpriteObject *v22; // [sp-8h] [bp-20h]@81
+  //unsigned int v23; // [sp-4h] [bp-1Ch]@4
+  //unsigned int v24; // [sp-4h] [bp-1Ch]@5
   unsigned int v25; // [sp-4h] [bp-1Ch]@30
-  unsigned int v26; // [sp-4h] [bp-1Ch]@57
-  unsigned int v27; // [sp-4h] [bp-1Ch]@66
-  int v28; // [sp-4h] [bp-1Ch]@81
-  unsigned int v29; // [sp+0h] [bp-18h]@4
-  unsigned int v30; // [sp+0h] [bp-18h]@5
-  int v31; // [sp+0h] [bp-18h]@30
-  unsigned int v32; // [sp+0h] [bp-18h]@45
-  float v33; // [sp+0h] [bp-18h]@57
-  float v34; // [sp+0h] [bp-18h]@66
-  signed int v35; // [sp+0h] [bp-18h]@81
+  //unsigned int v26; // [sp-4h] [bp-1Ch]@57
+  //unsigned int v27; // [sp-4h] [bp-1Ch]@66
+  //int v28; // [sp-4h] [bp-1Ch]@81
+  //unsigned int v29; // [sp+0h] [bp-18h]@4
+  //unsigned int v30; // [sp+0h] [bp-18h]@5
+  //int v31; // [sp+0h] [bp-18h]@30
+  //unsigned int v32; // [sp+0h] [bp-18h]@45
+  //float v33; // [sp+0h] [bp-18h]@57
+  //float v34; // [sp+0h] [bp-18h]@66
+  //signed int v35; // [sp+0h] [bp-18h]@81
   char pContainer[7]; // [sp+10h] [bp-8h]@81
 
-  __debugbreak(); // need to refactor carefully & collect data
-  v2 = this;
+  //__debugbreak(); // need to refactor carefully & collect data
+  //v2 = this;
   result = a2->uType;
-  if ( result <= 545 )
+
+  switch (a2->uType)
   {
-    if ( result != 545 )
+    case 545:
+    case 550:
+    case 555: return true;
+
+    case 556:
+      AddMobileLight(a2, 0xFF0000, 256);
+    return false;
+
+    case 600:
+      AddMobileLight(a2, 0xFF3C1E, 256);
+    return true;
+
+    case 1010: // Fire Bolt
+    {
+      _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(a2, 0xFF3C1E, uTextureID_effpar1);
+      AddMobileLight(a2, 0xFF3C1E, 256);
+    }
+    return false;
+
+    case 1011: // Fire Bolt impact
+    {
+      _4A75CC_single_spell_collision_particle(a2, 0xFF3C1E, uTextureID_effpar1);
+      AddMobileLight(a2, 0xFF3C1E, 256);
+    }
+    return false;
+
+    case 1050: // Fireball
+    {
+      _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(a2, 0xFF3C1E, uTextureID_effpar1);
+      AddMobileLight(a2, 0xFF3C1E, 256);
+    }
+    return false;
+
+    case 1051: // Fireball hit
     {
+      AddMobileLight(a2, 0xFF3C1E, 256);
+      if (pRenderer->pRenderD3D)
+      {
+        result = a2->field_58_pid & 7;
+        if ((a2->field_58_pid & 7) != OBJECT_Actor &&
+            (a2->field_58_pid & 7) != OBJECT_Item)
+        {
+          if (field_204 != 4)
+          {
+            field_204++;
+            _4A7688_fireball_collision_particle(a2);
+          }
+          return false;
+        }
+      }
+    }
+    return true;
+
+    case 1081:
+    {
+      _4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(a2, 0xFF3C1E, uTextureID_effpar1, 300.0);
+      _4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(a2, 0xFF3C1E, uTextureID_effpar1, 250.0);
+      _4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(a2, 0xFF3C1E, uTextureID_effpar1, 200.0);
+      AddMobileLight(a2, 0xFF3C1E, 256);
+    }
+    return false;
+
+    case 2101:
+    {
+      _4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(a2, 0xC8C814, uTextureID_effpar1, 200.0);
+      AddMobileLight(a2, 0xC8C814, 256);
+    }
+    return false;
+
+    case 3060: // Acid Burst
+      _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(a2, 0x0AB450, uTextureID_effpar1);
+      AddMobileLight(a2, 0x0AB450, 256);
+    return false;
+
+    case 9000: return true;
+  }
+
+  if ( result < 545 )
+  {
+    __debugbreak(); // find out what kind of spells are these
+
       result -= 500;
       switch ( result )
       {
         case 0:
         case 30:
-          v29 = this->uTextureID_effpar1;
-          v23 = 0xAAAFFu;
-          goto LABEL_8;
+          _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(a2, 0xAAAFF, uTextureID_effpar1);
+          return false;
         case 1:
         case 31:
-          v30 = this->uTextureID_effpar1;
-          v24 = 0xAAAFFu;
-          goto LABEL_32;
+          _4A75CC_single_spell_collision_particle(a2, 0xAAAFF, uTextureID_effpar1);
+          return true;
         case 5:
-          v29 = this->uTextureID_effpar1;
-          v23 = 0x5C310Eu;
-          goto LABEL_8;
+          _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(a2, 0x5C310E, uTextureID_effpar1);
+          return false;
         case 10:
-          v29 = this->uTextureID_effpar1;
-          v23 = 0xFF3C1Eu;
-          goto LABEL_8;
+          _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(a2, 0xFF3C1E, uTextureID_effpar1);
+          return false;
         case 15:
-          v29 = this->uTextureID_effpar1;
-          v23 = 0x62D0u;
-          goto LABEL_8;
+          _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(a2, 0x0062D0, uTextureID_effpar1);
+          return false;
         case 16:
-          v30 = this->uTextureID_effpar1;
-          v24 = 0x62D0u;
-          goto LABEL_32;
+          _4A75CC_single_spell_collision_particle(a2, 0x0062D0, uTextureID_effpar1);
+          return false;
         case 20:
-          v29 = this->uTextureID_effpar1;
-          v23 = 0xAB450u;
-          goto LABEL_8;
+          _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(a2, 0x0AB450, uTextureID_effpar1);
+          return false;
         case 21:
-          v30 = this->uTextureID_effpar1;
-          v24 = 0xAB450u;
-          goto LABEL_32;
+          _4A75CC_single_spell_collision_particle(a2, 0x0AB450, uTextureID_effpar1);
+          return false;
         case 25:
-          v29 = this->uTextureID_effpar1;
-          v23 = 0xC8C805u;
-          goto LABEL_8;
+          _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(a2, 0xC8C805, uTextureID_effpar1);
+          return false;
         case 26:
-          v30 = this->uTextureID_effpar1;
-          v24 = 0xC8C805u;
-          goto LABEL_32;
+          _4A75CC_single_spell_collision_particle(a2, 0xC8C805, uTextureID_effpar1);
+          return false;
         case 35:
-          v29 = this->uTextureID_effpar1;
-          v23 = 0xFFFFFFu;
-          goto LABEL_8;
+          _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(a2, 0xFFFFFF, uTextureID_effpar1);
+          return false;
         case 36:
-          v30 = this->uTextureID_effpar1;
-          goto LABEL_154;
+          _4A75CC_single_spell_collision_particle(a2, 0xFFFFFF, uTextureID_effpar1);
+        return false;
+
         case 40:
-          goto LABEL_17;
+        _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(a2, 0x7E7E7E, uTextureID_effpar1);
+        return false;
+
         case 11:
-          goto LABEL_31;
+          _4A75CC_single_spell_collision_particle(a2, 0xFF3C1E, uTextureID_effpar1);
+          return false;
         case 6:
-          goto LABEL_115;
+          _4A75CC_single_spell_collision_particle(a2, 0x5C310E, uTextureID_effpar1);
+          return false;
+
         case 41:
-          goto LABEL_164;
+          _4A75CC_single_spell_collision_particle(a2, 0x7E7E7E, uTextureID_effpar1);
+          return false;
         default:
-          goto LABEL_168;
+          return false;
       }
-      goto LABEL_168;
-    }
-    goto LABEL_34;
+      return false;
   }
+
   if ( result <= 4051 )
   {
     if ( result != 4051 )
@@ -859,398 +934,285 @@
       {
         if ( result != 2031 )
         {
-          if ( result <= 1051 )
+          if ( result < 1051 )
           {
-            if ( result == 1051 )
-            {
-              result = AddMobileLight(a2, 0xFF3C1Eu, 256);// fireball hit
-              if ( pRenderer->pRenderD3D )
-              {
-                result = a2->field_58_pid & 7;
-                if ( result != 3 )
-                {
-                  if ( result != 2 )
-                  {
-                    result = (bool)&v2->field_204;
-                    v6 = v2->field_204;
-                    if ( v6 != 4 )
-                    {
-                      *(int *)result = v6 + 1;
-                      _4A7688_fireball_collision_particle(a2);
-                    }
-                    goto LABEL_168;
-                  }
-                }
-              }
-              goto LABEL_34;
-            }
-            if ( result <= 600 )
+            if ( result < 600 )
             {
-              if ( result == 600 )
-              {
-                result = AddMobileLight(a2, 0xFF3C1Eu, 256);
-                goto LABEL_34;
-              }
-              result -= 550;
-              if ( !result )
-              {
-LABEL_34:
-                LOBYTE(result) = 1;
-                return result;
-              }
-              v4 = result - 1;
-              if ( v4 )
-              {
-                result = v4 - 4;
-                if ( !result )
-                  goto LABEL_34;
-                --result;
-                if ( !result )
-                {
-                  v31 = 256;
-                  v25 = 0xFF0000u;
-LABEL_144:
-                  result = AddMobileLight(a2, v25, v31);
-                  goto LABEL_168;
-                }
-                goto LABEL_168;
-              }
-              goto LABEL_31;
+              _4A75CC_single_spell_collision_particle(a2, 0xFF3C1E, uTextureID_effpar1);
+              return false;
             }
             if ( result < 811 )
-              goto LABEL_168;
+              return false;
             if ( result <= 814 )
-              goto LABEL_34;
-            if ( result == 1010 )
-              goto LABEL_41;                    // fire strike
-            if ( result != 1011 )
-            {
-              if ( result != 1050 )
-                goto LABEL_168;
-LABEL_41:
-              diffuse = 0xFF3C1Eu;
-LABEL_42:
-              _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(
-                a2,
-                diffuse,
-                this->uTextureID_effpar1);
-LABEL_43:
-              v31 = 256;
-LABEL_44:
-              v25 = diffuse;
-              goto LABEL_144;
-            }
-            v32 = this->uTextureID_effpar1;
-            diffuse = 0xFF3C1Eu;
-LABEL_146:
-            _4A75CC_single_spell_collision_particle(a2, diffuse, v32);
-            goto LABEL_43;
+              return true;
+            return false;
+
           }
           if ( result <= 1081 )
           {
-            if ( result == 1081 )
-            {
-              diffuse = 0xFF3C1Eu;
-              _4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(
-                a2,
-                0xFF3C1Eu,
-                this->uTextureID_effpar1,
-                300.0);
-              _4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(
-                a2,
-                0xFF3C1Eu,
-                v2->uTextureID_effpar1,
-                250.0);
-              v33 = 200.0;
-              v26 = v2->uTextureID_effpar1;
-            }
-            else
+            if (result != 1081)
             {
               result -= 1060;
               if ( !result )
-                goto LABEL_34;
+                return true;
               v7 = result - 1;
               if ( v7 )
               {
                 v8 = v7 - 9;
                 if ( !v8 )
                 {
-LABEL_31:
-                  v30 = this->uTextureID_effpar1;
-                  v24 = 0xFF3C1Eu;
-                  goto LABEL_32;
+                  _4A75CC_single_spell_collision_particle(a2, 0xFF3C1E, uTextureID_effpar1);
+                  return false;
                 }
                 result = v8 - 10;
                 v9 = result == 0;
-LABEL_129:
+//LABEL_129:
                 if ( v9 )
-                  goto LABEL_34;
-                goto LABEL_168;
+                  return true;
+                return false;
               }
-              diffuse = 0xFF3C1Eu;
-              v33 = 250.0;
-              v26 = this->uTextureID_effpar1;
+              _4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(a2, 0xFF3C1E, uTextureID_effpar1, 250.0);
+              AddMobileLight(a2, 0xFF3C1E, 256);
+              return false;
             }
-LABEL_84:
-            _4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(a2, diffuse, v26, v33);
-            goto LABEL_43;
+//LABEL_84:
+//            _4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(a2, diffuse, v26, v33);
+            //goto LABEL_43;
+            return false;
           }
           v10 = result - 1090;
           if ( v10 )
           {
             result = v10 - 10;
             if ( !result )
-              goto LABEL_34;
+              return true;
             v11 = result - 1;
             if ( !v11 )
             {
-              diffuse = 0xFF3C1Eu;
-              _4A75CC_single_spell_collision_particle(a2, 0xFF3C1Eu, this->uTextureID_effpar1);
-              v32 = v2->uTextureID_effpar1;
-              goto LABEL_146;
+              //diffuse = 0xFF3C1E;
+              _4A75CC_single_spell_collision_particle(a2, 0xFF3C1E, uTextureID_effpar1);
+              //v32 = v2->uTextureID_effpar1;
+              _4A75CC_single_spell_collision_particle(a2, 0xFF3C1E, uTextureID_effpar1);
+              //goto LABEL_43;
+              AddMobileLight(a2, 0xFF3C1E, 256);
+              return false;
             }
             result = v11 - 929;
             if ( result )
-              goto LABEL_168;
-LABEL_63:
+              return false;
+//LABEL_63:
             if ( !pRenderer->pRenderD3D )
-              goto LABEL_34;
+              return true;
             _4A78AE_sparks_spell(a2);
-            v31 = 128;
-            v25 = 0x64640Fu;
-            goto LABEL_144;
+            AddMobileLight(a2, 0x64640F, 128);
+            return false;
           }
-          v34 = 250.0;
-          v27 = this->uTextureID_effpar1;
-          v21 = 0xFF3C1Eu;
-LABEL_117:
-          _4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(a2, v21, v27, v34);
-          goto LABEL_168;
+
+          _4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(a2, 0xFF3C1Eu, uTextureID_effpar1, 250.0);
+          return false;
         }
-        goto LABEL_67;
+        //goto LABEL_67;
       }
-      if ( result <= 3060 )
+      if ( result < 3060 )
       {
-        if ( result == 3060 )
-          goto LABEL_171;                       // acid burst
-        if ( result <= 2101 )
+        if ( result < 2101 )
         {
-          if ( result == 2101 )
-          {
-            v33 = 200.0;
-            v26 = this->uTextureID_effpar1;
-            goto LABEL_83;
-          }
           if ( result != 2060 )
           {
             if ( result != 2061 )
             {
               if ( result <= 2079 )
-                goto LABEL_168;
+                return false;
               if ( result <= 2081 )
               {
                 if ( pRenderer->pRenderD3D )
                   _4A77FD_some_stuff_d3d(a2);
                 else
                   _4A80DC_some_stuff_sw(a2);
-                goto LABEL_168;
+                return false;
               }
               v9 = result == 2100;
-              goto LABEL_129;
+                if ( v9 )
+                  return true;
+                return false;
             }
-LABEL_67:
-            v33 = 200.0;
-            v26 = this->uTextureID_effpar2;
-LABEL_83:
-            diffuse = (unsigned int)&pDecalBuilder->std__vector_pDecals[557].pVertices[57].vWorldViewPosition.y;
-            goto LABEL_84;
+            _4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(a2, 0xC8C814, uTextureID_effpar2, 200.0);
+            AddMobileLight(a2, 0xC8C814, 256);
+            return false;
           }
           if ( !pRenderer->pRenderD3D )
-            goto LABEL_34;
+            return true;
           memcpy(pContainer, "sp18h1", 7);
           pRnd->SetRange(1, 6);
           pContainer[5] = pRnd->GetInRange() + '0';
-          v35 = pBitmaps_LOD->LoadTexture(pContainer, TEXTURE_DEFAULT);
-          v28 = 100;
-          v22 = a2;
-LABEL_157:
-          AddProjectile(v22, v28, v35);
-          goto LABEL_168;
+          AddProjectile(a2, 100, pBitmaps_LOD->LoadTexture(pContainer));
+          return false;
         }
         v12 = result - 3010;
         if ( !v12 )
         {
-LABEL_171:
-          diffuse = 0xAB450u;
-          goto LABEL_42;
+          _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(a2, 0xAB450, uTextureID_effpar1);
+          AddMobileLight(a2, 0xAB450, 256);
+          return false;
         }
         v13 = v12 - 1;
         if ( !v13 )
         {
-          v32 = this->uTextureID_effpar1;
-          diffuse = 0xAB450u;
-          goto LABEL_146;
+          _4A75CC_single_spell_collision_particle(a2, 0xAB450, uTextureID_effpar1);
+          AddMobileLight(a2, 0xAB450, 256);
+          return false;
         }
         result = v13 - 19;
         if ( !result )
-          goto LABEL_34;
+          return true;
         --result;
         if ( result )
-          goto LABEL_168;
-LABEL_89:
-        v32 = this->uTextureID_effpar1;
-        diffuse = 0x9EB9F1u;
-        goto LABEL_146;
+          return false;
+
+        _4A75CC_single_spell_collision_particle(a2, 0x9EB9F1, uTextureID_effpar1);
+        AddMobileLight(a2, 0x9EB9F1, 256);
+        return false;
       }
       if ( result > 4000 )
       {
         result -= 4030;
         if ( !result || (--result, !result) )
-          goto LABEL_34;
+          return true;
         result -= 19;
         v9 = result == 0;
-        goto LABEL_129;
+                if ( v9 )
+                  return true;
+                return false;
       }
       if ( result == 4000 )
       {
         if ( !pRenderer->pRenderD3D )
-          goto LABEL_34;
+          return true;
         _4A7C07(a2);
-        goto LABEL_168;
+        return false;
       }
       result -= 3061;
       if ( !result || (result -= 29) == 0 )
-        goto LABEL_34;
+        return true;
       v14 = result - 1;
       if ( !v14 )
-        goto LABEL_89;
+      {
+        _4A75CC_single_spell_collision_particle(a2, 0x9EB9F1, uTextureID_effpar1);
+        AddMobileLight(a2, 0x9EB9F1, 256);
+        return false;
+      }
       result = v14 - 1;
       if ( result )
-        goto LABEL_168;
-      v29 = this->uTextureID_effpar1;
-      v23 = 0x9EB9F1u;
-LABEL_8:
-      _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(a2, v23, v29);
-      goto LABEL_168;
+        return false;
+      _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(a2, 0x9EB9F1, uTextureID_effpar1);
+      return false;
     }
-    goto LABEL_122;
+    _4A7948_mind_blast_after_effect(a2);
+    return false;
   }
   if ( result <= 7090 )
   {
     if ( result == 7090 )
-      goto LABEL_34;
+      return true;
     if ( result > 6030 )
     {
       if ( result > 6091 )
       {
         result -= 6100;
         if ( !result )
-          goto LABEL_34;
+          return true;
         result -= 930;
         if ( result )
         {
           --result;
-          if ( result )
-            goto LABEL_168;
-          v30 = this->uTextureID_effpar1;
-          v24 = 0xF00000u;
-          goto LABEL_32;
+          if (!result)
+            _4A75CC_single_spell_collision_particle(a2, 0xF00000, uTextureID_effpar1);
+          return false;
         }
-        goto LABEL_63;
+            if ( !pRenderer->pRenderD3D )
+              return true;
+            _4A78AE_sparks_spell(a2);
+            AddMobileLight(a2, 0x64640F, 128);
+            return false;
       }
       if ( result != 6091 )
       {
         result -= 6040;
         if ( !result || (result -= 20) == 0 || (result -= 10) == 0 )
-          goto LABEL_34;
+          return true;
         result -= 20;
         v9 = result == 0;
-        goto LABEL_129;
+                if ( v9 )
+                  return true;
+                return false;
       }
     }
     else
     {
       if ( result == 6030 )
-        goto LABEL_34;
+        return true;
       if ( result <= 4091 )
       {
         if ( result != 4091 )
         {
           result -= 4070;
           if ( !result )
-            goto LABEL_34;
+            return true;
           v15 = result - 1;
           if ( v15 )
           {
             result = v15 - 9;
             if ( !result )
-              goto LABEL_34;
+              return true;
             result -= 10;
             if ( !result )
             {
-              _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(
-                a2,
-                0x7E7E7Eu,
-                this->uTextureID_effpar1);
-              goto LABEL_34;
+              _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(a2, 0x7E7E7E, uTextureID_effpar1);
+              return true;
             }
-            goto LABEL_168;
+            return false;
           }
-LABEL_115:
-          v30 = this->uTextureID_effpar1;
-          v24 = 0x5C310Eu;
-LABEL_32:
-          _4A75CC_single_spell_collision_particle(a2, v24, v30);
-          goto LABEL_168;
+          _4A75CC_single_spell_collision_particle(a2, 0x5C310E, uTextureID_effpar1);
+          return false;
         }
-        v34 = 200.0;
-        v27 = this->uTextureID_effpar1;
-        v21 = 0x7E7E7Eu;
-        goto LABEL_117;
+        _4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(a2, 0x7E7E7E, uTextureID_effpar1, 200.0);
+        return false;
       }
       v16 = result - 4092;
       if ( !v16 )
       {
-LABEL_17:
-        v29 = this->uTextureID_effpar1;
-        v23 = 0x7E7E7Eu;
-        goto LABEL_8;
+        _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(a2, 0x7E7E7E, uTextureID_effpar1);
+        return false;
       }
       result = v16 - 8;
       if ( !result )
-        goto LABEL_168;
+        return false;
       result -= 1910;
       if ( !result )
-        goto LABEL_34;
+        return true;
       --result;
       if ( result )
-        goto LABEL_168;
+        return false;
     }
-LABEL_122:
+//LABEL_122:
     _4A7948_mind_blast_after_effect(a2);
-    goto LABEL_168;
+    return false;
   }
   if ( result <= 9000 )
   {
-    if ( result == 9000 )
-      goto LABEL_34;
     if ( result <= 8030 )
     {
       if ( result == 8030 )
-        goto LABEL_34;
+        return true;
       v17 = result - 7091;
       if ( v17 )
       {
         v18 = v17 - 909;
         if ( !v18 )
         {
-          diffuse = 0xFFFFFFu;
-          _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(
-            a2,
-            0xFFFFFFu,
-            this->uTextureID_effpar3);
-          v31 = 128;
-          goto LABEL_44;
+          _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(a2, 0xFFFFFF, uTextureID_effpar3);
+          AddMobileLight(a2, 0xFFFFFF, 128);
+          return false;
         }
         v19 = v18 - 1;
         if ( v19 )
@@ -1258,64 +1220,59 @@
           result = v19 - 9;
           if ( !result )
           {
-            v31 = 64;
-            v25 = 0xFFFFFFu;
-            goto LABEL_144;
+            AddMobileLight(a2, 0xFFFFFF, 64);
+            return false;
           }
-          goto LABEL_168;
+          return false;
         }
-        v32 = this->uTextureID_effpar2;
-        diffuse = 0xFFFFFFu;
+        _4A75CC_single_spell_collision_particle(a2, 0xFFFFFF, uTextureID_effpar2);
+        AddMobileLight(a2, 0xFFFFFF, 256);
+        return false;
       }
       else
       {
-        v32 = this->uTextureID_effpar1;
-        diffuse = 0xF00000u;
+        _4A75CC_single_spell_collision_particle(a2, 0xF00000, uTextureID_effpar1);
+        AddMobileLight(a2, 0xF00000, 256);
+        return false;
       }
-      goto LABEL_146;
     }
     result -= 8040;
     if ( !result || (result -= 20) == 0 )
-      goto LABEL_34;
+      return true;
     v20 = result - 30;
     if ( v20 )
     {
       result = v20 - 1;
       if ( result )
-        goto LABEL_168;
-      v30 = this->uTextureID_effpar3;
-LABEL_154:
-      v24 = 16777215;
-      goto LABEL_32;
+        return false;
+
+      _4A75CC_single_spell_collision_particle(a2, 0xFFFFFF, uTextureID_effpar3);
+      return false;
     }
-    result = AddMobileLight(a2, 0xFFFFFFu, 128);
+    AddMobileLight(a2, 0xFFFFFFu, 128);
     if ( !pRenderer->pRenderD3D )
-      goto LABEL_34;
-    v35 = -1;
-    v28 = 100;
-    v22 = a2;
-    goto LABEL_157;
+      return true;
+    AddProjectile(a2, 100, -1);
+    return false;
   }
   if ( result > 9050 )
   {
     result -= 9070;
     if ( !result || (result -= 10) == 0 || (--result, !result) )
-      goto LABEL_34;
-    goto LABEL_168;
+      return true;
+    return false;
   }
   if ( result == 9050 || (result -= 9010) == 0 || (result -= 20) == 0 || (result -= 10) == 0 )
-    goto LABEL_34;
+    return true;
   --result;
   if ( !result )
   {
-LABEL_164:
-    v30 = this->uTextureID_effpar1;
-    v24 = 0x7E7E7Eu;
-    goto LABEL_32;
+//LABEL_164:
+    _4A75CC_single_spell_collision_particle(a2, 0x7E7E7E, uTextureID_effpar1);
+    return false;
   }
-LABEL_168:
-  LOBYTE(result) = 0;
-  return result;
+//LABEL_168:
+  return false;
 }
 
 //----- (004A89BD) --------------------------------------------------------