changeset 770:02bfc82f429c

Слияние
author Ritor1
date Sat, 23 Mar 2013 09:26:07 +0600
parents 2f40f4b35ce0 (current diff) 3523c3b581e5 (diff)
children fbae3100f991
files mm7_3.cpp mm7_data.cpp
diffstat 20 files changed, 564 insertions(+), 1537 deletions(-) [+]
line wrap: on
line diff
--- a/Events.cpp	Sat Mar 23 09:25:31 2013 +0600
+++ b/Events.cpp	Sat Mar 23 09:26:07 2013 +0600
@@ -1353,7 +1353,7 @@
 						if ( uGameState == 2 )
 							{
 							pAudioPlayer->StopChannels(-1, -1);
-							dialog_menu_id = 0;
+							dialog_menu_id = HOUSE_DIALOGUE_NULL;
 							while ( sub_4BD8B5() )
 								;
 							pVideoPlayer->Unload();
@@ -1365,7 +1365,7 @@
 							viewparams->bRedrawGameUI = 1;
 							pDialogueNPCCount = 0;
 							pDialogueWindow->Release();
-							dialog_menu_id = 0;
+							dialog_menu_id = HOUSE_DIALOGUE_NULL;
 							pDialogueWindow = 0;
 							pIcons_LOD->_40F9C5();
 							}
--- a/Items.h	Sat Mar 23 09:25:31 2013 +0600
+++ b/Items.h	Sat Mar 23 09:26:07 2013 +0600
@@ -128,6 +128,7 @@
   inline bool Identified()    {return uAttributes & ITEM_IDENTIFIED;}
   inline void SetIdentified() {uAttributes |= ITEM_IDENTIFIED;}
   inline bool Stolen()        {return uAttributes & ITEM_STOLEN;}
+  inline void SetStolen()     {uAttributes |= ITEM_STOLEN;}
 
   bool GenerateArtifact();
   unsigned int GetValue();
--- a/Monsters.cpp	Sat Mar 23 09:25:31 2013 +0600
+++ b/Monsters.cpp	Sat Mar 23 09:26:07 2013 +0600
@@ -478,40 +478,14 @@
 
 
 //----- (004563FF) --------------------------------------------------------
-signed int MonsterStats::FindMonsterByName(const char *Str2)
+signed int MonsterStats::FindMonsterByTextureName(const char *monster_textr_name)
 {
-  MonsterStats *v2; // esi@1
-  signed int v3; // ebx@1
-  MonsterInfo *v4; // edi@2
-  signed int result; // eax@6
-/*
-  for (int i=1; i<=uNumMonsters; ++i)
+  for (int i=1; i<uNumMonsters; ++i)
       {
-        if()
+        if((pInfos[i].pName )&& (!_strcmpi(pInfos[i].pPictureName, monster_textr_name)))
             return i;
       }
   return -1;
-  */
-  v2 = this;
-  v3 = 1;
-  if ( (signed int)this->uNumMonsters <= 1 )
-  {
-LABEL_6:
-    result = -1;
-  }
-  else
-  {
-    v4 = &this->pInfos[1];
-    while ( !v4->pName || _strcmpi(v4->pPictureName, Str2) )
-    {
-      ++v3;
-      ++v4;
-      if ( v3 >= (signed int)v2->uNumMonsters )
-        goto LABEL_6;
-    }
-    result = v3;
-  }
-  return result;
 }
 
 
@@ -566,110 +540,6 @@
 //----- (0045501E) --------------------------------------------------------
 void MonsterStats::Initialize()
     {
-    MonsterStats *v1; // ebx@1
-    int v2; // ebx@4
-    char v3; // cl@5
-    int v4; // eax@5
-    size_t v5; // eax@19
-    signed int v6; // edi@19
-    MonsterStats *v7; // ecx@23
-    int v8; // eax@23
-    unsigned int *pHP; // esi@23
-    size_t v10; // eax@29
-    signed int v11; // edi@29
-    MonsterStats *v12; // ecx@33
-    int v13; // eax@33
-    unsigned int *pExp; // esi@33
-    signed int v15; // edi@36
-    size_t v16; // esi@36
-    int v17; // eax@37
-    MonsterInfo *v18; // esi@45
-    size_t v19; // edi@50
-    int v20; // eax@51
-    unsigned __int8 v21; // al@55
-    size_t v22; // edi@59
-    char v23; // cl@63
-    const char *v24; // edi@63
-    unsigned __int16 *v25; // esi@114
-    int v26; // eax@118
-    size_t v27; // eax@136
-    int v28; // edi@137
-    MonsterStats *v29; // esi@137
-    int v30; // eax@138
-    int v31; // eax@142
-    int v32; // eax@143
-    int v33; // eax@144
-    int v34; // eax@151
-    int v35; // eax@152
-    int v36; // eax@153
-    int v37; // eax@162
-    int v38; // eax@163
-    int v39; // eax@164
-    int v40; // eax@171
-    int v41; // eax@172
-    size_t v42; // eax@180
-    int v43; // edi@180
-    MonsterInfo *v44; // esi@180
-    int v45; // edi@184
-    MonsterInfo *v46; // eax@232
-    char *v47; // edx@232
-    char *v48; // ecx@232
-    MonsterInfo *v49; // eax@236
-    FrameTableTxtLine *v50; // esi@240
-    int v51; // eax@240
-    int v52; // eax@241
-    int v53; // esi@242
-    int v54; // edi@242
-    char v55; // al@242
-    char *v56; // edi@242
-    FrameTableTxtLine *v57; // esi@249
-    int v58; // eax@249
-    MonsterInfo *v59; // eax@250
-    MonsterInfo *v60; // esi@251
-    int v61; // edi@251
-    char v62; // al@251
-    char *v63; // edi@251
-    char v64; // al@258
-    char v65; // al@262
-    char v66; // al@266
-    char v67; // al@270
-    char v68; // al@274
-    char v69; // al@278
-    char v70; // al@282
-    char v71; // al@286
-    char v72; // al@290
-    unsigned __int8 v73; // al@294
-    int v74; // edi@298
-    MonsterInfo *v75; // esi@300
-    MonsterInfo *v76; // esi@302
-    char **v77; // edi@306
-    __int16 v78; // ax@316
-    MonsterInfo *v79; // esi@323
-    const char *v80; // ecx@323
-    std::string v81; // [sp-14h] [bp-46Ch]@317
-    const char *v82; // [sp-8h] [bp-460h]@306
-    char *v83; // [sp-4h] [bp-45Ch]@23
-    char *v84; // [sp+0h] [bp-458h]@37
-    FrameTableTxtLine v85; // [sp+10h] [bp-448h]@297
-    FrameTableTxtLine v86; // [sp+8Ch] [bp-3CCh]@249
-    FrameTableTxtLine v87; // [sp+108h] [bp-350h]@240
-    char Src[120]; // [sp+184h] [bp-2D4h]@317
-    FrameTableTxtLine v89; // [sp+1FCh] [bp-25Ch]@249
-    FrameTableTxtLine v90; // [sp+278h] [bp-1E0h]@240
-   
-    char Dest[64]; // [sp+334h] [bp-124h]@249
-    char v93[64]; // [sp+374h] [bp-E4h]@297
-    FrameTableTxtLine v94; // [sp+3B4h] [bp-A4h]@297
-    int v95; // [sp+430h] [bp-28h]@317
-    int v96; // [sp+434h] [bp-24h]@9
-    int v97; // [sp+438h] [bp-20h]@4
-    char a3[5]; // [sp+43Fh] [bp-19h]@4
-    int a2; // [sp+444h] [bp-14h]@36
-    int v100; // [sp+448h] [bp-10h]@36
-    size_t v101; // [sp+44Ch] [bp-Ch]@19
-    MonsterStats *v102; // [sp+450h] [bp-8h]@1
-    int v103; // [sp+454h] [bp-4h]@3
-
     int i,j;
     char* test_string;
     unsigned char c;
@@ -680,9 +550,9 @@
     int item_counter;
     int curr_rec_num;
     char parse_str[64]; 
+    char Src[120];
+    FrameTableTxtLine parsed_field;
 
-    v1 = this;
-    v102 = this;
     if ( pMonstersTXT_Raw )
         pAllocator->FreeChunk(pMonstersTXT_Raw);
     pMonstersTXT_Raw = NULL;
@@ -1054,13 +924,13 @@
                     strcpy(parse_str,test_string);
                     parse_str[0]=' ';
                     parse_str[strlen(parse_str)-1]=' ';
-                    frame_table_txt_parser(parse_str,&v85);
-                    if (v85.uPropCount>2)
+                    frame_table_txt_parser(parse_str,&parsed_field);
+                    if (parsed_field.uPropCount>2)
                         {
                         param_num=1;
-                        pInfos[curr_rec_num].uSpell1ID=ParseSpellType(&v85,&param_num);
-                        type_flag=*v85.pProperties[param_num];
-                        pInfos[curr_rec_num].uSpellSkillAndMastery1=atoi(v85.pProperties[param_num+1])&0x003F;
+                        pInfos[curr_rec_num].uSpell1ID=ParseSpellType(&parsed_field,&param_num);
+                        type_flag=*parsed_field.pProperties[param_num];
+                        pInfos[curr_rec_num].uSpellSkillAndMastery1=atoi(parsed_field.pProperties[param_num+1])&0x003F;
                         switch(type_flag)
                             {
                         case 'E': pInfos[curr_rec_num].uSpellSkillAndMastery1|=0x0040; break;
@@ -1086,13 +956,13 @@
                     strcpy(parse_str,test_string);
                     parse_str[0]=' ';
                     parse_str[strlen(parse_str)-1]=' ';
-                    frame_table_txt_parser(parse_str,&v85);
-                    if (v85.uPropCount>2)
+                    frame_table_txt_parser(parse_str,&parsed_field);
+                    if (parsed_field.uPropCount>2)
                         {
                         param_num=1;
-                        pInfos[curr_rec_num].uSpell2ID=ParseSpellType(&v85,&param_num);
-                        type_flag=*v85.pProperties[param_num];
-                        pInfos[curr_rec_num].uSpellSkillAndMastery2=atoi(v85.pProperties[param_num+1])&0x003F;
+                        pInfos[curr_rec_num].uSpell2ID=ParseSpellType(&parsed_field,&param_num);
+                        type_flag=*parsed_field.pProperties[param_num];
+                        pInfos[curr_rec_num].uSpellSkillAndMastery2=atoi(parsed_field.pProperties[param_num+1])&0x003F;
                         switch(type_flag)
                             {
                         case 'E': pInfos[curr_rec_num].uSpellSkillAndMastery2|=0x0040; break;
@@ -1189,7 +1059,88 @@
                     break;
                     case 38:
                     {
-
+                    int param_num;
+                    char type_flag;
+                    pInfos[curr_rec_num].uSpecialAbilityType=0;
+                    pInfos[curr_rec_num].uSpecialAbilityDamageDiceBonus=0;
+                    strcpy(parse_str,test_string);
+                    parse_str[0]=' ';
+                    parse_str[strlen(parse_str)-1]=' ';
+                    frame_table_txt_parser(parse_str,&parsed_field);
+                    if ( parsed_field.uPropCount )
+                        {
+                  //      v74 = v94.field_0;
+                        if ( parsed_field.uPropCount < 10 )
+                            {
+                            if (! _strcmpi(parsed_field.pProperties[0], "shot") )
+                                {
+                                pInfos[curr_rec_num].uSpecialAbilityType=1;
+                                pInfos[curr_rec_num].uSpecialAbilityDamageDiceBonus=atoi((char *)(parsed_field.pProperties[1] + 1));
+                                }
+                            else  if (!_strcmpi(parsed_field.pProperties[0], "summon") )
+                            {
+                            pInfos[curr_rec_num].uSpecialAbilityType=2;
+                            if ( parsed_field.uPropCount  > 1 )
+                                {
+                                pTmpBuf[0] = 0;
+                                strcpy(pTmpBuf, parsed_field.pProperties[2]);
+                                if ( parsed_field.uPropCount  > 2 )
+                                    {
+                                    int prop_cnt = 3;
+                                    if ( parsed_field.uPropCount  > 3 )
+                                        {
+                                        do
+                                            {
+                                            strcat(pTmpBuf, " ");
+                                            char test_char = parsed_field.pProperties[prop_cnt][0];
+                                            strcat(pTmpBuf, parsed_field.pProperties[prop_cnt]);
+                                            if ( prop_cnt == (parsed_field.uPropCount - 1) )
+                                                {
+                                                switch (tolower(test_char))
+                                                {
+                                                case 'a': pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 1; break;
+                                                case 'b': pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 2; break;
+                                                case 'c': pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 3; break;
+                                                default:
+                                                    pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 0;
+                                                }
+                                                
+                                                }
+                                            ++prop_cnt;
+                                            }
+                                        while ( prop_cnt < parsed_field.uPropCount );
+                                        }
+                                    }
+                                else
+                                    {
+                                    pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 0;
+                                    }
+                                if ( pMonsterList->uNumMonsters )
+                                    {
+                                    pInfos[curr_rec_num].field_3C_some_special_attack = pMonsterList->GetMonsterIDByName(pTmpBuf) + 1;
+                                    if ( pInfos[curr_rec_num].field_3C_some_special_attack == -1 )
+                                        {
+                                        sprintf(Src, "Can't create random monster: '%s' See MapStats!", pTmpBuf);
+                                        MessageBoxA(nullptr, Src, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Itemdata.cpp:2239", 0);
+                                        }
+                                    }
+                                pInfos[curr_rec_num].uSpecialAbilityDamageDiceSides = 0;
+                                if ( !_strcmpi(parsed_field.pProperties[1], "ground") )
+                                    pInfos[curr_rec_num].uSpecialAbilityDamageDiceSides = 1;
+                                if ( pInfos[curr_rec_num].field_3C_some_special_attack == -1 )
+                                    pInfos[curr_rec_num].uSpecialAbilityType = 0;
+                                }
+                            }
+                            else  if (!_strcmpi(parsed_field.pProperties[0], "explode") )
+                                {
+                                pInfos[curr_rec_num].uSpecialAbilityType = 3;
+                                ParseDamage((char*)parsed_field.pProperties[1], &pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls,
+                                    &pInfos[curr_rec_num].uSpecialAbilityDamageDiceSides,
+                                    &pInfos[curr_rec_num].uSpecialAbilityDamageDiceBonus);
+                                pInfos[curr_rec_num].field_3C_some_special_attack = ParseAttackType(test_string);
+                                }
+                            }
+                        }
                     }
                     break;     
                     }
@@ -1203,1122 +1154,17 @@
             } while ((decode_step<39)&&!break_loop);
         }
     uNumMonsters = i;
-
-/*
-  v103 = 0;
-  v1->uNumMonsters = 265;
-  do
-  {
-    v2 = (int)(strtok(NULL, "\r") + 1);
-    *(_DWORD *)&a3[1] = 0;
-    v97 = 0;
-    do
-    {
-      v3 = *(_BYTE *)v2;
-      v4 = 0;
-      while ( v3 != 9 && v3 )
-      {
-        ++v4;
-        v3 = *(_BYTE *)(v4 + v2);
-      }
-      v96 = v4 + v2;
-      if ( !*(_BYTE *)(v4 + v2) )
-        v97 = 1;
-      *(_BYTE *)(v4 + v2) = 0;
-      if ( v4 )
-      {
-        switch ( *(_DWORD *)&a3[1] )
-        {
-       /*   case 0:
-            v103 = atoi((const char *)v2);
-            v102->pInfos[v103].uID = v103;
-            goto LABEL_325;
-          case 2:
-            v102->pInfos[v103].pPictureName = RemoveQuotes((char *)v2);
-            goto LABEL_325;
-          case 1:
-            v102->pInfos[v103].pName = RemoveQuotes((char *)v2);
-            goto LABEL_325;
-          case 3:
-            v102->pInfos[v103].uLevel = atoi((const char *)v2);
-            goto LABEL_325;
-          case 4:
-            if ( *(_BYTE *)v2 == 34 )
-              *(_BYTE *)v2 = 32;
-            v5 = strlen((const char *)v2);
-            v6 = 0;
-            v101 = v5;
-            if ( (signed int)v5 <= 0 )
-              goto LABEL_24;
-            while ( *(_BYTE *)(v6 + v2) != 44 )
-            {
-              ++v6;
-              if ( v6 >= (signed int)v5 )
-                goto LABEL_24;
-            }
-            v7 = v102;
-            v8 = v103;
-            *(_BYTE *)(v6 + v2) = 0;
-            pHP = &v7->pInfos[v8].uHP;
-            *pHP = 1000 * atoi((const char *)v2);
-            v83 = (char *)(v6 + v2 + 1);
-            *(_BYTE *)(v6 + v2) = 44;
-            *pHP += atoi(v83);
-LABEL_24:
-            if ( v6 == v101 )
-              v102->pInfos[v103].uHP = atoi((const char *)v2);
-            goto LABEL_325;
-          case 5:
-            v102->pInfos[v103].uAC = atoi((const char *)v2);
-            goto LABEL_325;
-          case 6:
-            if ( *(_BYTE *)v2 == 34 )
-              *(_BYTE *)v2 = 32;
-            v10 = strlen((const char *)v2);
-            v11 = 0;
-            v101 = v10;
-            if ( (signed int)v10 <= 0 )
-              goto LABEL_34;
-            while ( *(_BYTE *)(v11 + v2) != 44 )
-            {
-              ++v11;
-              if ( v11 >= (signed int)v10 )
-                goto LABEL_34;
-            }
-            v12 = v102;
-            v13 = v103;
-            *(_BYTE *)(v11 + v2) = 0;
-            pExp = &v12->pInfos[v13].uExp;
-            *pExp = 1000 * atoi((const char *)v2);
-            v83 = (char *)(v11 + v2 + 1);
-            *(_BYTE *)(v11 + v2) = 44;
-            *pExp += atoi(v83);
-LABEL_34:
-            if ( v11 == v101 )
-              v102->pInfos[v103].uExp = atoi((const char *)v2);
-            goto LABEL_325;
-          case 7:
-            v15 = 0;
-            a2 = 0;
-            v100 = 0;
-            v16 = 0;
-            v101 = strlen((const char *)v2);
-            if ( (signed int)v101 <= 0 )
-              goto LABEL_325;
-            do
-            {
-              v84 = (char *)*(_BYTE *)(v16 + v2);
-              v17 = tolower((int)v84);
-              switch ( v17 )
-              {
-                case 37:
-                  v15 = 1;
-                  break;
-                case 100:
-                  v100 = 1;
-                  break;
-                case 108:
-                  a2 = 1;
-                  break;
-              }
-              ++v16;
-            }
-            while ( (signed int)v16 < (signed int)v101 );
-            if ( v15 )
-            {
-              v18 = &v102->pInfos[v103];
-              v18->uTreasureDropChance = atoi((const char *)v2);
-            }
-            else
-            {
-              if ( !v100 && !a2 )
-                goto LABEL_325;
-              v18 = &v102->pInfos[v103];
-              v18->uTreasureDropChance = 100;
-            }
-            if ( v100 )
-            {
-              v19 = 0;
-              v100 = 0;
-              do
-              {
-                v84 = (char *)*(_BYTE *)(v19 + v2);
-                v20 = tolower((int)v84);
-                if ( v20 == 37 )
-                {
-                  v84 = (char *)(v19 + v2 + 1);
-                  v18->uTreasureDiceRolls = atoi(v84);
-                  v100 = 1;
-                }
-                else
-                {
-                  if ( v20 == 100 )
-                  {
-                    if ( !v100 )
-                      v18->uTreasureDiceRolls = atoi((const char *)v2);
-                    v84 = (char *)(v19 + v2 + 1);
-                    v21 = atoi(v84);
-                    v19 = v101;
-                    v18->uTreasureDiceSides = v21;
-                  }
-                }
-                ++v19;
-              }
-              while ( (signed int)v19 < (signed int)v101 );
-            }
-            if ( a2 )
-            {
-              v22 = 0;
-              while ( 1 )
-              {
-                v84 = (char *)*(_BYTE *)(v22 + v2);
-                if ( tolower((int)v84) == 108 )
-                  break;
-                ++v22;
-                if ( (signed int)v22 >= (signed int)v101 )
-                  goto LABEL_325;
-              }
-              v23 = *(_BYTE *)(v22 + v2 + 1);
-              v24 = (const char *)(v22 + v2 + 2);
-              v18->uTreasureLevel = v23 - 48;
-              if ( *v24 )
-              {
-                if ( _strcmpi(v24, "WEAPON") )
-                {
-                  if ( _strcmpi(v24, "ARMOR") )
-                  {
-                    if ( _strcmpi(v24, "MISC") )
-                    {
-                      if ( _strcmpi(v24, "SWORD") )
-                      {
-                        if ( _strcmpi(v24, "DAGGER") )
-                        {
-                          if ( _strcmpi(v24, "AXE") )
-                          {
-                            if ( _strcmpi(v24, "SPEAR") )
-                            {
-                              if ( _strcmpi(v24, "BOW") )
-                              {
-                                if ( _strcmpi(v24, "MACE") )
-                                {
-                                  if ( _strcmpi(v24, "CLUB") )
-                                  {
-                                    if ( _strcmpi(v24, "STAFF") )
-                                    {
-                                      if ( _strcmpi(v24, "LEATHER") )
-                                      {
-                                        if ( _strcmpi(v24, "CHAIN") )
-                                        {
-                                          if ( _strcmpi(v24, "PLATE") )
-                                          {
-                                            if ( _strcmpi(v24, "SHIELD") )
-                                            {
-                                              if ( _strcmpi(v24, "HELM") )
-                                              {
-                                                if ( _strcmpi(v24, "BELT") )
-                                                {
-                                                  if ( _strcmpi(v24, "CAPE") )
-                                                  {
-                                                    if ( _strcmpi(v24, "GAUNTLETS") )
-                                                    {
-                                                      if ( _strcmpi(v24, "BOOTS") )
-                                                      {
-                                                        if ( _strcmpi(v24, "RING") )
-                                                        {
-                                                          if ( _strcmpi(v24, "AMULET") )
-                                                          {
-                                                            if ( _strcmpi(v24, "WAND") )
-                                                            {
-                                                              if ( _strcmpi(v24, "SCROLL") )
-                                                              {
-                                                                if ( !_strcmpi(v24, "GEM") )
-                                                                  v18->uTreasureType = 46;
-                                                              }
-                                                              else
-                                                              {
-                                                                v18->uTreasureType = 43;
-                                                              }
-                                                            }
-                                                            else
-                                                            {
-                                                              v18->uTreasureType = 42;
-                                                            }
-                                                          }
-                                                          else
-                                                          {
-                                                            v18->uTreasureType = 41;
-                                                          }
-                                                        }
-                                                        else
-                                                        {
-                                                          v18->uTreasureType = 40;
-                                                        }
-                                                      }
-                                                      else
-                                                      {
-                                                        v18->uTreasureType = 39;
-                                                      }
-                                                    }
-                                                    else
-                                                    {
-                                                      v18->uTreasureType = 38;
-                                                    }
-                                                  }
-                                                  else
-                                                  {
-                                                    v18->uTreasureType = 37;
-                                                  }
-                                                }
-                                                else
-                                                {
-                                                  v18->uTreasureType = 36;
-                                                }
-                                              }
-                                              else
-                                              {
-                                                v18->uTreasureType = 35;
-                                              }
-                                            }
-                                            else
-                                            {
-                                              v18->uTreasureType = 34;
-                                            }
-                                          }
-                                          else
-                                          {
-                                            v18->uTreasureType = 33;
-                                          }
-                                        }
-                                        else
-                                        {
-                                          v18->uTreasureType = 32;
-                                        }
-                                      }
-                                      else
-                                      {
-                                        v18->uTreasureType = 31;
-                                      }
-                                    }
-                                    else
-                                    {
-                                      v18->uTreasureType = 30;
-                                    }
-                                  }
-                                  else
-                                  {
-                                    v18->uTreasureType = 29;
-                                  }
-                                }
-                                else
-                                {
-                                  v18->uTreasureType = 28;
-                                }
-                              }
-                              else
-                              {
-                                v18->uTreasureType = 27;
-                              }
-                            }
-                            else
-                            {
-                              v18->uTreasureType = 26;
-                            }
-                          }
-                          else
-                          {
-                            v18->uTreasureType = 25;
-                          }
-                        }
-                        else
-                        {
-                          v18->uTreasureType = 24;
-                        }
-                      }
-                      else
-                      {
-                        v18->uTreasureType = 23;
-                      }
-                    }
-                    else
-                    {
-                      v18->uTreasureType = 22;
-                    }
-                  }
-                  else
-                  {
-                    v18->uTreasureType = 21;
-                  }
-                }
-                else
-                {
-                  v18->uTreasureType = 20;
-                }
-              }
-            }
-            goto LABEL_325;
-          case 8:
-            v84 = (char *)v2;
-            v25 = &v102->pInfos[v103].bQuestMonster;
-            *v25 = 0;
-            if ( atoi(v84) )
-              *(_BYTE *)v25 |= 1u;
-            goto LABEL_325;
-          case 9:
-            v102->pInfos[v103].uFlying = _strnicmp((const char *)v2, "n", 1u);
-            goto LABEL_325;
-          case 0xA:
-            v84 = (char *)*(_BYTE *)v2;
-            v101 = 4;
-            if ( tolower((int)v84) == 's' )
-            {
-              v84 = (char *)*(_BYTE *)(v2 + 1);
-              v26 = tolower((int)v84) != 'h' ? 5 : 0;
-            }
-            else
-            {
-              v84 = (char *)*(_BYTE *)v2;
-              if ( tolower((int)v84) == 'm' )
-              {
-                v101 = 1;
-              }
-              else
-              {
-                v84 = (char *)*(_BYTE *)v2;
-                if ( tolower((int)v84) == 'l' )
-                {
-                  v101 = 2;
-                }
-                else
-                {
-                  v84 = (char *)*(_BYTE *)v2;
-                  if ( tolower((int)v84) == 'g' )
-                    v101 = 3;
-                }
-              }
-              LOBYTE(v26) = v101;
-            }
-            v102->pInfos[v103].uMovementType = v26;
-            goto LABEL_325;
-          case 0xB:
-            v84 = (char *)*(_BYTE *)v2;
-            v101 = 3;
-            if ( tolower((int)v84) == 's' )
-            {
-              v101 = 0;
-            }
-            else
-            {
-              v84 = (char *)*(_BYTE *)v2;
-              if ( tolower((int)v84) == 'w' )
-              {
-                v101 = 1;
-              }
-              else
-              {
-                v84 = (char *)*(_BYTE *)v2;
-                if ( tolower((int)v84) == 'n' )
-                  v101 = 2;
-              }
-            }
-            v102->pInfos[v103].uAIType = v101;
-            goto LABEL_325;
-          case 0xC:
-            v102->pInfos[v103].uHostilityType = (MonsterInfo::HostilityRadius)atoi((const char *)v2);
-            goto LABEL_325;
-          case 0xD:
-            v102->pInfos[v103].uBaseSpeed = atoi((const char *)v2);
-            goto LABEL_325;
-          case 0xF:
-            v27 = strlen((const char *)v2);
-            v100 = 0;
-            v101 = v27;
-            if ( (signed int)v27 > 0 )
-            {
-              v28 = v103;
-              v29 = v102;
-              do
-              {
-                v84 = (char *)*(_BYTE *)(v100 + v2);
-                v30 = tolower((int)v84);
-                if ( v30 > 107 )
-                {
-                  if ( v30 > 115 )
-                  {
-                    v40 = v30 - 116;
-                    if ( v40 )
-                    {
-                      v41 = v40 - 3;
-                      if ( v41 )
-                      {
-                        if ( v41 == 1 )
-                          BYTE1(v29->pInfos[v28].uAttackPreference) |= 2u;
-                      }
-                      else
-                      {
-                        BYTE1(v29->pInfos[v28].uAttackPreference) |= 0x20u;
-                      }
-                    }
-                    else
-                    {
-                      LOBYTE(v29->pInfos[v28].uAttackPreference) |= 0x80u;
-                    }
-                  }
-                  else
-                  {
-                    if ( v30 == 115 )
-                    {
-                      v29->pInfos[v28].uAttackPreference |= 0x20u;
-                    }
-                    else
-                    {
-                      v37 = v30 - 109;
-                      if ( v37 )
-                      {
-                        v38 = v37 - 2;
-                        if ( v38 )
-                        {
-                          v39 = v38 - 1;
-                          if ( v39 )
-                          {
-                            if ( v39 == 2 )
-                              v29->pInfos[v28].uAttackPreference |= 0x40u;
-                          }
-                          else
-                          {
-                            v29->pInfos[v28].uAttackPreference |= 2u;
-                          }
-                        }
-                        else
-                        {
-                          BYTE1(v29->pInfos[v28].uAttackPreference) |= 4u;
-                        }
-                      }
-                      else
-                      {
-                        BYTE1(v29->pInfos[v28].uAttackPreference) |= 1u;
-                      }
-                    }
-                  }
-                }
-                else
-                {
-                  if ( v30 == 107 )
-                  {
-                    v29->pInfos[v28].uAttackPreference |= 1u;
-                  }
-                  else
-                  {
-                    if ( v30 > 99 )
-                    {
-                      v34 = v30 - 100;
-                      if ( v34 )
-                      {
-                        v35 = v34 - 1;
-                        if ( v35 )
-                        {
-                          v36 = v35 - 2;
-                          if ( v36 )
-                          {
-                            if ( v36 == 1 )
-                              BYTE1(v29->pInfos[v28].uAttackPreference) |= 8u;
-                          }
-                          else
-                          {
-                            BYTE1(v29->pInfos[v28].uAttackPreference) |= 0x40u;
-                          }
-                        }
-                        else
-                        {
-                          BYTE1(v29->pInfos[v28].uAttackPreference) |= 0x10u;
-                        }
-                      }
-                      else
-                      {
-                        v29->pInfos[v28].uAttackPreference |= 8u;
-                      }
-                    }
-                    else
-                    {
-                      if ( v30 == 99 )
-                      {
-                        v29->pInfos[v28].uAttackPreference |= 0x10u;
-                      }
-                      else
-                      {
-                        v31 = v30 - 50;
-                        if ( v31 )
-                        {
-                          v32 = v31 - 1;
-                          if ( v32 )
-                          {
-                            v33 = v32 - 1;
-                            if ( v33 )
-                            {
-                              if ( v33 == 45 )
-                                v29->pInfos[v28].uAttackPreference |= 4u;
-                            }
-                            else
-                            {
-                              v29->pInfos[v28].uNumCharactersAttackedPerSpecialAbility = 4;
-                            }
-                          }
-                          else
-                          {
-                            v29->pInfos[v28].uNumCharactersAttackedPerSpecialAbility = 3;
-                          }
-                        }
-                        else
-                        {
-                          v29->pInfos[v28].uNumCharactersAttackedPerSpecialAbility = 2;
-                        }
-                      }
-                    }
-                  }
-                }
-                ++v100;
-              }
-              while ( v100 < (signed int)v101 );
-            }
-            goto LABEL_325;
-          case 0xE:
-            v102->pInfos[v103].uRecoveryTime = atoi((const char *)v2);
-            goto LABEL_325;
-          case 0x10:
-            v42 = strlen((const char *)v2);
-            v43 = 0;
-            v44 = &v102->pInfos[v103];
-            v100 = v42;
-            v44->uSpecialAttackType = 1;
-            if ( (signed int)v42 <= 0 )
-              goto LABEL_185;
-            break;
-          case 0x11:
-            v102->pInfos[v103].uAttack1Type = ParseAttackType((unsigned __int8 *)v2);
-            goto LABEL_325;
-          case 0x12:
-            v46 = &v102->pInfos[v103];
-            v47 = (char *)&v46->uAttack1DamageDiceRolls;
-            v84 = (char *)&v46->uAttack1DamageBonus;
-            v48 = (char *)&v46->uAttack1DamageDiceSides;
-            goto LABEL_237;
-          case 0x13:
-            v102->pInfos[v103].uMissleAttack1Type = ParseMissleAttackType((const char *)v2);
-            goto LABEL_325;
-          case 0x14:
-            v102->pInfos[v103].uAttack2Chance = atoi((const char *)v2);
-            goto LABEL_325;
-          case 0x15:
-            v102->pInfos[v103].uAttack2Type = ParseAttackType((unsigned __int8 *)v2);
-            goto LABEL_325;
-          case 0x16:
-            v49 = &v102->pInfos[v103];
-            v47 = (char *)&v49->uAttack2DamageDiceRolls;
-            v84 = (char *)&v49->uAttack2DamageBonus;
-            v48 = (char *)&v49->uAttack2DamageDiceSides;
-LABEL_237:
-            ParseDamage((const char *)v2, (int)v47, (int)v48, (int)v84);
-            goto LABEL_325;
-          case 0x17:
-            v102->pInfos[v103].uMissleAttack2Type = ParseMissleAttackType((const char *)v2);
-            goto LABEL_325;
-          case 0x18:
-            v102->pInfos[v103].uSpell1UseChance = atoi((const char *)v2);
-            goto LABEL_325;
-          case 0x19:
-            strcpy(Str, (const char *)v2);
-            Str[0] = ' ';
-            Str[strlen(Str) - 1] = ' ';
-            v50 = texture_frame_table_txt_parser(Str, &v87);
-            v51 = 88 * v103;
-            memcpy(&v90, v50, sizeof(v90));
-            if ( v90.field_0 >= 3 )
-            {
-              v53 = (int)((char *)v102 + v51);
-              a2 = 1;
-              v102->pInfos[v51 / 0x58u].uSpell1ID = ParseSpellType(&v90, (int)&a2);
-              v54 = a2;
-              v84 = (char *)v90.pProperties[a2 + 1];
-              v55 = atoi(v84);
-              v56 = (char *)v90.pProperties[v54];
-              v84 = "E";
-              v83 = v56;
-              *(_WORD *)(v53 + 56) = v55 & 0x3F;
-              if ( _strcmpi(v83, v84) )
-              {
-                if ( _strcmpi(v56, "M") )
-                {
-                  if ( !_strcmpi(v56, "G") )
-                    *(_BYTE *)(v53 + 57) |= 1u;
-                }
-                else
-                {
-                  *(_BYTE *)(v53 + 56) |= 0x80u;
-                }
-              }
-              else
-              {
-                *(_BYTE *)(v53 + 56) |= 0x40u;
-              }
-            }
-            else
-            {
-              v52 = (int)((char *)v102 + v51);
-              *(_BYTE *)(v52 + 33) = 0;
-              *(_WORD *)(v52 + 56) = 0;
-            }
-            goto LABEL_325;
-          case 0x1A:
-            v102->pInfos[v103].uSpell2UseChance = atoi((const char *)v2);
-            goto LABEL_325;
-
-          case 0x1B:
-            strcpy(Dest, (const char *)v2);
-            Dest[0] = ' ';
-            Dest[strlen(Dest) - 1] = ' ';
-            v57 = texture_frame_table_txt_parser(Dest, &v86);
-            v58 = v103;
-            memcpy(&v89, v57, sizeof(v89));
-            if ( v89.field_0 >= 3 )
-            {
-              v60 = &v102->pInfos[v58];
-              a2 = 1;
-              v102->pInfos[v58].uSpell2ID = ParseSpellType(&v89, (int)&a2);
-              v61 = a2;
-              v84 = (char *)v89.pProperties[a2 + 1];
-              v62 = atoi(v84);
-              v63 = (char *)v89.pProperties[v61];
-              v84 = "E";
-              v83 = v63;
-              v60->uSpellSkillAndMastery2 = v62 & 0x3F;
-              if ( _strcmpi(v83, v84) )
-              {
-                if ( _strcmpi(v63, "M") )
-                {
-                  if ( !_strcmpi(v63, "G") )
-                    HIBYTE(v60->uSpellSkillAndMastery2) |= 1u;
-                }
-                else
-                {
-                  LOBYTE(v60->uSpellSkillAndMastery2) |= 0x80u;
-                }
-              }
-              else
-              {
-                LOBYTE(v60->uSpellSkillAndMastery2) |= 0x40u;
-              }
-            }
-            else
-            {
-              v59 = &v102->pInfos[v58];
-              v59->uSpell2ID = 0;
-              v59->uSpellSkillAndMastery2 = 0;
-            }
-            goto LABEL_325;
-          case 0x1C:
-            v84 = (char *)*(_BYTE *)v2;
-            if ( tolower((int)v84) == 'i' )
-              v64 = 200;
-            else
-              v64 = atoi((const char *)v2);
-            v102->pInfos[v103].uResFire = v64;
-            goto LABEL_325;
-          case 0x1D:
-            v84 = (char *)*(_BYTE *)v2;
-            if ( tolower((int)v84) == 'i' )
-              v65 = 200;
-            else
-              v65 = atoi((const char *)v2);
-            v102->pInfos[v103].uResAir = v65;
-            goto LABEL_325;
-          case 0x1E:
-            v84 = (char *)*(_BYTE *)v2;
-            if ( tolower((int)v84) == 'i' )
-              v66 = 200;
-            else
-              v66 = atoi((const char *)v2);
-            v102->pInfos[v103].uResWater = v66;
-            goto LABEL_325;
-          case 0x1F:
-            v84 = (char *)*(_BYTE *)v2;
-            if ( tolower((int)v84) == 'i' )
-              v67 = 200;
-            else
-              v67 = atoi((const char *)v2);
-            v102->pInfos[v103].uResEarth = v67;
-            goto LABEL_325;
-          case 0x20:
-            v84 = (char *)*(_BYTE *)v2;
-            if ( tolower((int)v84) == 'i' )
-              v68 = 200;
-            else
-              v68 = atoi((const char *)v2);
-            v102->pInfos[v103].uResMind = v68;
-            goto LABEL_325;
-          case 0x21:
-            v84 = (char *)*(_BYTE *)v2;
-            if ( tolower((int)v84) == 'i' )
-              v69 = 200;
-            else
-              v69 = atoi((const char *)v2);
-            v102->pInfos[v103].uResSpirit = v69;
-            goto LABEL_325;
-          case 0x22:
-            v84 = (char *)*(_BYTE *)v2;
-            if ( tolower((int)v84) == 'i' )
-              v70 = 200;
-            else
-              v70 = atoi((const char *)v2);
-            v102->pInfos[v103].uResBody = v70;
-            goto LABEL_325;
-          case 0x23:
-            v84 = (char *)*(_BYTE *)v2;
-            if ( tolower((int)v84) == 'i' )
-              v71 = 200;
-            else
-              v71 = atoi((const char *)v2);
-            v102->pInfos[v103].uResLight = v71;
-            goto LABEL_325;
-          case 0x24:
-            v84 = (char *)*(_BYTE *)v2;
-            if ( tolower((int)v84) == 'i' )
-              v72 = 200;
-            else
-              v72 = atoi((const char *)v2);
-            v102->pInfos[v103].uResDark = v72;
-            goto LABEL_325;
-          case 0x25:
-            v84 = (char *)*(_BYTE *)v2;
-            if ( tolower((int)v84) == 'i' )
-              v73 = 200;
-            else
-              v73 = atoi((const char *)v2);
-            v102->pInfos[v103].uResPhysical = v73;
-            goto LABEL_325;
-          case 0x26:
-            strcpy(v93, (const char *)v2);
-            v93[0] = ' ';
-            v93[strlen(v93) - 1] = ' ';
-            memcpy(&v94, texture_frame_table_txt_parser(v93, &v85), sizeof(v94));
-            if ( v94.field_0 )
-            {
-              v74 = v94.field_0;
-              if ( v94.field_0 < 10 )
-              {
-                if ( _strcmpi(v94.pProperties[0], "shot") )
-                {
-                  if ( _strcmpi(v94.pProperties[0], "summon") )
-                  {
-                    if ( !_strcmpi(v94.pProperties[0], "explode") )
-                    {
-                      v79 = &v102->pInfos[v103];
-                      v80 = v94.pProperties[1];
-                      v84 = (char *)&v79->uSpecialAbilityDamageDiceBonus;
-                      v83 = (char *)&v79->uSpecialAbilityDamageDiceSides;
-                      v79->uSpecialAbilityType = 3;
-                      ParseDamage(v80, (int)&v79->uSpecialAbilityDamageDiceRolls, (int)v83, (int)v84);
-                      v79->field_3C_some_special_attack = ParseAttackType((unsigned __int8 *)v2);
-                    }
-                  }
-                  else
-                  {
-                    v76 = &v102->pInfos[v103];
-                    v76->uSpecialAbilityType = 2;
-                    if ( v74 > 1 )
-                    {
-                      pTmpBuf[0] = 0;
-                      strcpy(pTmpBuf, v94.pProperties[2]);
-                      if ( v74 > 2 )
-                      {
-                        v100 = 3;
-                        if ( v74 > 3 )
-                        {
-                          do
-                          {
-                            strcat(pTmpBuf, " ");
-                            v77 = (char **)v94.pProperties[v100];
-                            v82 = v94.pProperties[v100];
-                            strcat(pTmpBuf, v82);
-                            if ( v100 == v94.field_0 - 1 )
-                            {
-                              v84 = (char *)*(_BYTE *)v77;
-                              if ( tolower((int)v84) == 'a' )
-                              {
-                                v76->uSpecialAbilityDamageDiceRolls = 1;
-                              }
-                              else
-                              {
-                                v84 = (char *)*(_BYTE *)v77;
-                                if ( tolower((int)v84) == 'b' )
-                                {
-                                  v76->uSpecialAbilityDamageDiceRolls = 2;
-                                }
-                                else
-                                {
-                                  v84 = (char *)*(_BYTE *)v77;
-                                  if ( tolower((int)v84) == 'c' )
-                                    v76->uSpecialAbilityDamageDiceRolls = 3;
-                                  else
-                                    v76->uSpecialAbilityDamageDiceRolls = 0;
-                                }
-                              }
-                            }
-                            ++v100;
-                          }
-                          while ( v100 < v94.field_0 );
-                        }
-                      }
-                      else
-                      {
-                        v76->uSpecialAbilityDamageDiceRolls = 0;
-                      }
-                      if ( pMonsterList->uNumMonsters )
-                      {
-                        v78 = pMonsterList->GetMonsterByName(pTmpBuf) + 1;
-                        v76->field_3C_some_special_attack = v78;
-                        if ( v78 == -1 )
-                        {
-                          sprintf(Src, "Can't create random monster: '%s' See MapStats!", Src);
-                          MessageBoxA(nullptr, Src, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Itemdata.cpp:2239", 0);
-                        }
-                      }
-                      v76->uSpecialAbilityDamageDiceSides = 0;
-                      if ( !_strcmpi(v94.pProperties[1], "ground") )
-                        v76->uSpecialAbilityDamageDiceSides = 1;
-                      if ( v76->field_3C_some_special_attack == -1 )
-                        v76->uSpecialAbilityType = 0;
-                    }
-                  }
-                }
-                else
-                {
-                  v75 = &v102->pInfos[v103];
-                  v84 = (char *)(v94.pProperties[1] + 1);
-                  v75->uSpecialAbilityType = 1;
-                  v75->uSpecialAbilityDamageDiceBonus = atoi(v84);
-                }
-              }
-            }
-            goto LABEL_325;
-          default:
-            goto LABEL_325;
-        }
-        while ( 1 )
-        {
-          v84 = (char *)*(_BYTE *)(v43 + v2);
-          if ( tolower((int)v84) == 'x' )
-            break;
-          ++v43;
-          if ( v43 >= v100 )
-            goto LABEL_185;
-        }
-        v45 = v2 + v43;
-        *(_BYTE *)v45 = 0;
-        v44->uSpecialAttackType = atoi((const char *)(v45 + 1));
-        *(_BYTE *)v45 = 100;
-LABEL_185:
-        _strlwr((char *)v2);
-        if ( strstr((const char *)v2, "curse") )
-        {
-          v44->uSpecialAttack = 1;
-        }
-        else
-        {
-          if ( strstr((const char *)v2, "weak") )
-          {
-            v44->uSpecialAttack = 2;
-          }
-          else
-          {
-            if ( strstr((const char *)v2, "asleep") )
-            {
-              v44->uSpecialAttack = 3;
-            }
-            else
-            {
-              if ( strstr((const char *)v2, "afraid") )
-              {
-                v44->uSpecialAttack = 23;
-              }
-              else
-              {
-                if ( strstr((const char *)v2, "drunk") )
-                {
-                  v44->uSpecialAttack = 4;
-                }
-                else
-                {
-                  if ( strstr((const char *)v2, "insane") )
-                  {
-                    v44->uSpecialAttack = 5;
-                  }
-                  else
-                  {
-                    if ( strstr((const char *)v2, "poison1") )
-                    {
-                      v44->uSpecialAttack = 6;
-                    }
-                    else
-                    {
-                      if ( strstr((const char *)v2, "poison2") )
-                      {
-                        v44->uSpecialAttack = 7;
-                      }
-                      else
-                      {
-                        if ( strstr((const char *)v2, "poison3") )
-                        {
-                          v44->uSpecialAttack = 8;
-                        }
-                        else
-                        {
-                          if ( strstr((const char *)v2, "disease1") )
-                          {
-                            v44->uSpecialAttack = 9;
-                          }
-                          else
-                          {
-                            if ( strstr((const char *)v2, "disease2") )
-                            {
-                              v44->uSpecialAttack = 10;
-                            }
-                            else
-                            {
-                              if ( strstr((const char *)v2, "disease3") )
-                              {
-                                v44->uSpecialAttack = 11;
-                              }
-                              else
-                              {
-                                if ( strstr((const char *)v2, "paralyze") )
-                                {
-                                  v44->uSpecialAttack = 12;
-                                }
-                                else
-                                {
-                                  if ( strstr((const char *)v2, "uncon") )
-                                  {
-                                    v44->uSpecialAttack = 13;
-                                  }
-                                  else
-                                  {
-                                    if ( strstr((const char *)v2, "dead") )
-                                    {
-                                      v44->uSpecialAttack = 14;
-                                    }
-                                    else
-                                    {
-                                      if ( strstr((const char *)v2, "stone") )
-                                      {
-                                        v44->uSpecialAttack = 15;
-                                      }
-                                      else
-                                      {
-                                        if ( strstr((const char *)v2, "errad") )
-                                        {
-                                          v44->uSpecialAttack = 16;
-                                        }
-                                        else
-                                        {
-                                          if ( strstr((const char *)v2, "brkitem") )
-                                          {
-                                            v44->uSpecialAttack = 17;
-                                          }
-                                          else
-                                          {
-                                            if ( strstr((const char *)v2, "brkarmor") )
-                                            {
-                                              v44->uSpecialAttack = 18;
-                                            }
-                                            else
-                                            {
-                                              if ( strstr((const char *)v2, "brkweapon") )
-                                              {
-                                                v44->uSpecialAttack = 19;
-                                              }
-                                              else
-                                              {
-                                                if ( strstr((const char *)v2, "steal") )
-                                                {
-                                                  v44->uSpecialAttack = 20;
-                                                }
-                                                else
-                                                {
-                                                  if ( strstr((const char *)v2, "age") )
-                                                  {
-                                                    v44->uSpecialAttack = 21;
-                                                  }
-                                                  else
-                                                  {
-                                                    if ( strstr((const char *)v2, "drainsp") )
-                                                      v44->uSpecialAttack = 22;
-                                                  }
-                                                }
-                                              }
-                                            }
-                                          }
-                                        }
-                                      }
-                                    }
-                                  }
-                                }
-                              }
-                            }
-                          }
-                        }
-                      }
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-      else
-      {
-        v97 = 1;
-      }
-LABEL_325:
-      ++*(_DWORD *)&a3[1];
-      v2 = v96 + 1;
-    }
-    while ( *(_DWORD *)&a3[1] - 1 <= (signed int)v102->uNumMonsters && !v97 );
-    ++v103;
-  }
-  while ( v103 < 265 );
-  v102->uNumMonsters = v103;
-  */
 }
 
 
-
-
 //----- (0044FA08) --------------------------------------------------------
-unsigned __int16 MonsterList::GetMonsterByName(const char *pMonsterName)
-{
-  signed int v2; // ebx@1
-  MonsterList *v3; // esi@1
-  int v4; // edi@3
-  unsigned __int16 result; // ax@6
-
-  v2 = 0;
-  v3 = this;
-  if ( pMonsterName && (signed int)this->uNumMonsters > 0 )
-  {
-    v4 = 0;
-    while ( _strcmpi(pMonsterName, v3->pMonsters[v4].pMonsterName) )
+signed __int16 MonsterList::GetMonsterIDByName( const char *pMonsterName )
     {
-      ++v2;
-      ++v4;
-      if ( v2 >= (signed int)v3->uNumMonsters )
-        goto LABEL_6;
+    if (!pMonsterName)
+        return -1;
+    for (signed __int16 i=1; i<=uNumMonsters; ++i)
+        {
+        if( (!_strcmpi(pMonsters[i].pMonsterName, pMonsterName)))
+            return i;
+        }
     }
-    result = v2;
-  }
-  else
-  {
-LABEL_6:
-    result = -1;
-  }
-  return result;
-}
--- a/Monsters.h	Sat Mar 23 09:25:31 2013 +0600
+++ b/Monsters.h	Sat Mar 23 09:26:07 2013 +0600
@@ -158,7 +158,7 @@
 {
   void Initialize();
   void InitializePlacements();
-  signed int FindMonsterByName(const char *Str2);
+  signed int FindMonsterByTextureName(const char *Str2);
 
   static bool BelongsToSupertype(unsigned int uMonsterInfoID, enum MONSTER_SUPERTYPE eSupertype);
 
@@ -193,12 +193,12 @@
   inline MonsterList():  //----- (00458429)
     uNumMonsters(0), pMonsters(nullptr)
   {}
-  unsigned __int16 GetMonsterByName(const char *pMonsterName);
+    signed __int16 GetMonsterIDByName(const char *pMonsterName);
   void ToFile();
   void FromFile(void *pSerialized);
   bool FromFileTxt(const char *Args);
 
-  unsigned int uNumMonsters;
+  signed int uNumMonsters;
   struct MonsterDesc *pMonsters;
 };
 #pragma pack(pop)
--- a/Outdoor.cpp	Sat Mar 23 09:25:31 2013 +0600
+++ b/Outdoor.cpp	Sat Mar 23 09:26:07 2013 +0600
@@ -121,7 +121,7 @@
   {
     v4 = WorldPosToGridCellZ(pParty->vPosition.y);
     v5 = WorldPosToGridCellX(pParty->vPosition.x);
-    pOutdoor->_47EF60(v5, v4, 1);
+    pOutdoor->UpdateDiscoveredArea(v5, v4, 1);
   }
   pGame->uFlags2 &= 0xFFFFFFFEu;
   if (pRenderer->pRenderD3D && pRenderer->bUsingSpecular)
@@ -171,7 +171,7 @@
   {
     if ( pParty->uCurrentHour < 0x14 )
     {
-      pWeather->field_FA0 = 0;
+      pWeather->bNight = 0;
       v2 = 0.0;
       return v2 * 0.016666668;
     }
@@ -183,13 +183,13 @@
     }
 LABEL_9:
     v2 = 60.0;
-    pWeather->field_FA0 = 1;
+    pWeather->bNight = 1;
     return v2 * 0.016666668;
   }
   v1 = 0;
   v2 = 60.0 - (double)(60 * pParty->uCurrentHour + pParty->uCurrentMinute - 300);
 LABEL_4:
-  pWeather->field_FA0 = v1;
+  pWeather->bNight = v1;
   return v2 * 0.016666668;
 }
 
@@ -2115,9 +2115,9 @@
   //v108 = (int)".odm";
   //v83 = strlen(pContainer);
   //strcpy((char *)v141 + v83, (const char *)v108);
-  memcpy(array_528, pSrc, 0x3C8);
+  memcpy(uUndiscoveredArea, pSrc, 0x3C8);
   //v84 = (const void *)(v74 + 968);
-  memcpy(array_8F0, pSrc + 0x3C8, 0x3C8);
+  memcpy(uDicovered_area, pSrc + 0x3C8, 0x3C8);
   pSrc += 2 * 0x3C8;
   //v85 = (char *)v84 + 968;
 
@@ -2125,8 +2125,8 @@
 
   if ( *(int *)thisa )
   {
-    memcpy(array_528, Dst, 0x3C8u);
-    memcpy(array_8F0, Src, 0x3C8u);
+    memcpy(uUndiscoveredArea, Dst, 0x3C8u);
+    memcpy(uDicovered_area, Src, 0x3C8u);
   }
 
   //v25 = uNumBModels == 0;
@@ -2594,7 +2594,7 @@
 }
 
 //----- (0047EF60) --------------------------------------------------------
-int OutdoorLocation::_47EF60(int a2, int a3, int a4)
+int OutdoorLocation::UpdateDiscoveredArea(int X_grid_pos, int Y_grid_poa, int a4)
 {
   int v4; // ecx@1
   int v5; // edx@2
@@ -2614,14 +2614,14 @@
   int i; // [sp+24h] [bp+Ch]@5
 
   v18 = this;
-  v4 = a3 - 10;
-  if ( a3 - 10 < a3 + 10 )
+  v4 = Y_grid_poa - 10;
+  if ( Y_grid_poa - 10 < Y_grid_poa + 10 )
   {
-    v5 = v4 - a3;
-    v6 = 88 * (a3 - 30);
-    v7 = a2;
-    v19 = v4 - a3;
-    v17 = a3 + 10 - v4;
+    v5 = v4 - Y_grid_poa;
+    v6 = (Y_grid_poa - 30);
+    v7 = X_grid_pos;
+    v19 = v4 - Y_grid_poa;
+    v17 = Y_grid_poa + 10 - v4;
     while ( 1 )
     {
       v8 = abs(v5);
@@ -2634,14 +2634,13 @@
         {
           v11 = abs(v10);
           v15 = v11 * v11 + v16;
-          if ( v15 <= 100 && v9 >= 20 && v9 <= 107 && v6 >= 0 && v6 <= 7656 )
+          if ( v15 <= 100 && v9 >= 20 && v9 <= 107 && v6 >= 0 && v6 <= 87 )
           {
-            v12 = (v6 + v9 - 20) >> 3;
-            v13 = 1 << (8 - (v6 + v9 - 20) % 8 - 1);
-            v18->array_8F0[v12] |= v13;
+            v13 = 1 << (7 - (v9 - 20) % 8);
+            v18->uDicovered_area[v6][(v9 - 20)/8] |= v13;
             if ( v15 <= 49 )
-              v18->array_528[v12] |= v13;
-            v7 = a2;
+              v18->uUndiscoveredArea[v6][(v9 - 20)/8] |= v13;
+            v7 = X_grid_pos;
           }
           ++v9;
           ++i;
@@ -2649,7 +2648,7 @@
             break;
         }
       }
-      v6 += 88;
+      ++v6 ;
       ++v19;
       --v17;
       if ( !v17 )
@@ -2661,26 +2660,26 @@
 }
 
 //----- (0047F04C) --------------------------------------------------------
-bool OutdoorLocation::_47F04C(signed int a2, signed int a3)
+bool OutdoorLocation::_47F04C(signed int x_pos, signed int y_pos)
 {
   bool result; // eax@5
 
-  if ( a2 < 0 || a2 >= 88 || a3 < 0 || a3 >= 88 )
+  if ( x_pos < 0 || x_pos >= 88 || y_pos < 0 || y_pos >= 88 )
     result = 0;
   else
-    result = (this->array_528[(a2 + 88 * a3) / 8] & (unsigned __int8)(1 << (7 - (a2 + 88 * a3) % 8))) != 0;
+    result = (uUndiscoveredArea[y_pos][x_pos/8] & (unsigned __int8)(1 << (7 - (x_pos) % 8))) != 0;
   return result;
 }
 
 //----- (0047F097) --------------------------------------------------------
-bool OutdoorLocation::_47F097(signed int a2, signed int a3)
+bool OutdoorLocation::_47F097(signed int x_pos, signed int y_pos)
 {
   bool result; // eax@5
 
-  if ( a2 < 0 || a2 >= 88 || a3 < 0 || a3 >= 88 )
+  if ( x_pos < 0 || x_pos >= 88 || y_pos < 0 || y_pos >= 88 )
     result = 0;
   else
-    result = (this->array_8F0[(a2 + 88 * a3) / 8] & (unsigned __int8)(1 << (7 - (a2 + 88 * a3) % 8))) != 0;
+    result = (uDicovered_area[y_pos][x_pos/8] & (unsigned __int8)(1 << (7 - (x_pos) % 8))) != 0;
   return result;
 }
 
--- a/Outdoor.h	Sat Mar 23 09:25:31 2013 +0600
+++ b/Outdoor.h	Sat Mar 23 09:26:07 2013 +0600
@@ -154,7 +154,7 @@
   int ActuallyGetSomeOtherTileInfo(unsigned int uX, unsigned int uY);
   int DoGetHeightOnTerrain(unsigned int uX, unsigned int uZ);
   int _47EE49(signed int a2, signed int a3, int a4);
-  int _47EF60(int a2, int a3, int a4);
+  int UpdateDiscoveredArea(int a2, int a3, int a4);
   bool _47F04C(signed int a2, signed int a3);
   bool _47F097(signed int a2, signed int a3);
   bool _47F0E2();
@@ -206,8 +206,8 @@
   int day_fogrange_1;
   int day_fogrange_2;
   char field_510[24];
-  char array_528[968];
-  char array_8F0[968];
+  unsigned char uUndiscoveredArea[88][11];//968
+  unsigned char uDicovered_area[88][11];//[968]
   int field_CB8;
   int max_terrain_dimming_level;
   int field_CC0;
--- a/Outdoor_stuff.h	Sat Mar 23 09:25:31 2013 +0600
+++ b/Outdoor_stuff.h	Sat Mar 23 09:26:07 2013 +0600
@@ -68,8 +68,8 @@
   int _48653D(int a2, int a3, int a4, int a5, int a6, int a7);
   int _48694B();
 
-  int field_0;
-  int field_4;
+  int field_0_party_dir_x;
+  int field_4_party_dir_y;
   int field_8;
   int field_C;
   int field_10;
--- a/Player.cpp	Sat Mar 23 09:25:31 2013 +0600
+++ b/Player.cpp	Sat Mar 23 09:26:07 2013 +0600
@@ -336,16 +336,14 @@
 }
 
 //----- (004B8142) --------------------------------------------------------
-int Player::_4B8142(int a2, float a3)
-{
-  int result; // eax@1
-
-  result = (int)((100 - GetMerchant()) * (unsigned __int64)(signed __int64)((double)a2 * a3)) / 100;
-  if ( result < a2 )
-    result = a2;
-  if ( result < 1 )
-    result = 1;
-  return result;
+int Player::GetBuyingPrice(unsigned int uRealValue, float price_multiplier)
+{
+  uint price = ((100 - GetMerchant()) * (uRealValue * price_multiplier)) / 100;
+  assert (price > 0);
+
+  if (price < uRealValue)
+    price = uRealValue;
+  return price;
 }
 
 //----- (004B8179) --------------------------------------------------------
@@ -1858,7 +1856,7 @@
   v14 = &p2DEvents[a4 - 1].fPriceMultiplier;
   v15 = *v14;
   v16 = pItem->GetValue();
-  v17 = _4B8142(v16, v15);
+  v17 = GetBuyingPrice(v16, v15);
   if ( a5 == 3 )
   {
     v23 = *v14;
--- a/Player.h	Sat Mar 23 09:25:31 2013 +0600
+++ b/Player.h	Sat Mar 23 09:26:07 2013 +0600
@@ -560,7 +560,7 @@
   int _4B8213(int a2, float a3);
   int _4B81C3(int a2, float a3);
   int _4B8179(float a2);
-  int _4B8142(int a2, float a3);
+  int GetBuyingPrice(unsigned int uRealValue, float price_multiplier);
   int _4B8102(int a2, float a3);
   int _4B807C(float a2);
   int _4B8040_condition_time(unsigned int uCondition);
--- a/SaveLoad.cpp	Sat Mar 23 09:25:31 2013 +0600
+++ b/SaveLoad.cpp	Sat Mar 23 09:26:07 2013 +0600
@@ -507,9 +507,9 @@
       pOutdoor->ddm.uNumDecorations = uNumLevelDecorations;
       memcpy(DstBuf, &pOutdoor->ddm, 0x28);
       v21 = (char *)v21 + 40;
-      memcpy(v21, pOutdoor->array_528, 0x3C8);
+      memcpy(v21, pOutdoor->uUndiscoveredArea, 0x3C8);
       v21 = (char *)v21 + 968;
-      memcpy(v21, pOutdoor->array_8F0, 0x3C8);
+      memcpy(v21, pOutdoor->uDicovered_area, 0x3C8);
       v22 = (char *)v21 + 968;
       if ( (signed int)pOutdoor->uNumBModels > 0 )
       {
--- a/UIHouses.cpp	Sat Mar 23 09:25:31 2013 +0600
+++ b/UIHouses.cpp	Sat Mar 23 09:26:07 2013 +0600
@@ -30,6 +30,9 @@
 
 int dword_591080; // weak
 
+int in_current_building_type; // 00F8B198
+HOUSE_DIALOGUE_MENU dialog_menu_id; // 00F8B19C
+
 const stru159 pAnimatedRooms[196] = //0x4E5F70
     {
         {"",                            0x4, 0x1F4, 0, 0, 0},
@@ -624,7 +627,7 @@
   _this.DrawTitleText(pFontArrus, 0, 0x104u, v30, pTmpBuf, 3u);
   switch(dialog_menu_id)
   {
-	case 1:
+	case HOUSE_DIALOGUE_MAIN:
 		{
 		v11 = 1;
 		pOutString = 0;
@@ -675,7 +678,8 @@
 		}
 		break;
 		}
-	case 99:
+
+	case HOUSE_DIALOGUE_TOWNHALL_99:
 		{
 		v5 = &pMonsterStats->pInfos[word_F8B1A0];
 		v6 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
@@ -702,7 +706,7 @@
 		a1.DrawText(pOutString, 13, 354 - v9, 0, v10, 0, 0, 0);
 		break;
 		}
-	case 100:
+	case HOUSE_DIALOGUE_TOWNHALL_100:
 		{
 		v0 = window_SpeakInHouse;
 		if ( window_SpeakInHouse->field_40 == 1 )
@@ -793,7 +797,7 @@
   _this.DrawTitleText(pFontArrus, 0, 0xDCu, v14[0], pTmpBuf, 3u);
   switch(dialog_menu_id)
   {
-	case 1:
+	case HOUSE_DIALOGUE_MAIN:
 		{
 		v8 = v14[0];
 		if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
@@ -805,7 +809,7 @@
 		_this.DrawTitleText(pFontArrus, 0, 0xB0u, v9, pGlobalTXT_LocalizationStrings[244], 3u);
 		break;
 		}
-	case 7:
+	case HOUSE_DIALOGUE_BANK_7:
 		{
 		v0 = window_SpeakInHouse;
 		if ( window_SpeakInHouse->field_40 != 1 )
@@ -862,7 +866,7 @@
 		break;
 		}
 
-	case 8:
+	case HOUSE_DIALOGUE_BANK_8:
 		{
 		v0 = window_SpeakInHouse;
 		if ( window_SpeakInHouse->field_40 != 1 )
@@ -1036,9 +1040,10 @@
     v7 = 1;
     v83 = 1;
   }
+
   switch(dialog_menu_id)
   {
-    case DIALOG_SHOP_MAIN:
+    case HOUSE_DIALOGUE_MAIN:
     {
       if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
           return;
@@ -1126,9 +1131,10 @@
       }
       break;
     }
-    case DIALOG_SHOP_ARCOMAGE_102:
+
+    case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_102:
     {
-      __debugbreak;
+      __debugbreak();
       pOutString = pFontArrus;
       strcpy(pTmpBuf, pNPCTopics[354].pText);
       dialog_window.uFrameWidth = 460;
@@ -1146,9 +1152,9 @@
       window_SpeakInHouse->DrawText(pOutString, 12, 354 - pTextHeight, 0, v63, 0, 0, 0);
       break;
     }
-    case DIALOG_SHOP_ARCOMAGE_103:
+    case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_103:
     {
-      __debugbreak;
+      __debugbreak();
       strcpy(pTmpBuf, pNPCTopics[(uint)window_SpeakInHouse->ptr_1C + 247].pText);
       dialog_window.uFrameWidth = 460;
       dialog_window.uFrameZ = 452;
@@ -1161,7 +1167,7 @@
       window_SpeakInHouse->DrawText(pFontArrus, 12, 354 - pTextHeight, 0, v63, 0, 0, 0);
       break;
     }
-    case DIALOG_SHOP_ARCOMAGE_RESULT:
+    case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RESULT:
     {
       if ( pArcomageGame->bGameInProgress == 1 )
         return;
@@ -1181,14 +1187,15 @@
       dialog_window.DrawTitleText(pFontArrus, 0, v66, pColorYellow, pTmpBuf, 3);
       break;
     }
-    case DIALOG_SHOP_REST:
+
+    case HOUSE_DIALOGUE_TAVERN_REST:
     {
       if ( pParty->uNumGold >= (unsigned int)pOutString )
       {
         Party::TakeGold((unsigned int)pOutString);
         v27 = (int)window_SpeakInHouse->ptr_1C;
         PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney);
-        dialog_menu_id = 0;
+        dialog_menu_id = HOUSE_DIALOGUE_NULL;
         sub_4BD8B5();
         sub_4B1D27();
         pVideoPlayer->Unload();
@@ -1207,7 +1214,8 @@
       pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0);
       break;
     }
-    case DIALOG_SHOP_SKILLS:
+
+    case HOUSE_DIALOGUE_LEARN_SKILLS:
     {
       if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
         return;
@@ -1280,7 +1288,8 @@
       dialog_window.DrawTitleText(pFontArrus, 0, pTextHeight, pColorYellow, pTmpBuf, 3);
       return;
     }
-    case DIALOG_SHOP_BYE_FOOD:
+
+    case HOUSE_DIALOGUE_TAVERN_BUY_FOOD:
     {
       *(_QWORD *)Str = pParty->uNumFoodRations;
       //if ( (double)pParty->uNumFoodRations >= p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C] )
@@ -1306,7 +1315,8 @@
       pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0);
       break;
     }
-    case DIALOG_SHOP_ARCOMAGE_MAIN:
+
+    case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN:
     {
       if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
       {
@@ -1466,9 +1476,10 @@
   dialog_window.uFrameZ = 334;
   pColorWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
   pColorYellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
+
   switch(dialog_menu_id)
   {
-    case DIALOG_SHOP_MAIN:
+    case HOUSE_DIALOGUE_MAIN:
     {
       pNumActiveItem = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
       if ( pNumActiveItem )
@@ -1509,7 +1520,8 @@
       }
       break;
     }
-    case DIALOG_SHOP_BUY_STANDART:
+
+    case HOUSE_DIALOGUE_SHOP_BUY_STANDARD:
     {
       pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
       v48 = 0;
@@ -1556,7 +1568,7 @@
         else
         {
           v58 = pGlobalTXT_LocalizationStrings[195];
-          if ( dialog_menu_id != 2 )
+          if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
             v58 = pGlobalTXT_LocalizationStrings[196];
         }
         DrawTextAtStatusBar(v58, 0);
@@ -1571,7 +1583,7 @@
             v61 = (int)window_SpeakInHouse->ptr_1C;
             //  v62 = 9 * (v60 + 12 * v61);
             v63 = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60];
-            if ( dialog_menu_id != 2 )
+            if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
               v63 = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724];
             if ( !v56 || !Str )
             {
@@ -1596,7 +1608,8 @@
       }
       break;
     }
-    case DIALOG_SHOP_SELL:
+
+    case HOUSE_DIALOGUE_SHOP_SELL:
     {
       draw_leather();
       CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
@@ -1614,7 +1627,8 @@
       dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
       break;
     }
-    case DIALOG_SHOP_IDENTIFY:
+
+    case HOUSE_DIALOGUE_SHOP_IDENTIFY:
     {
       draw_leather();
       CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
@@ -1641,7 +1655,8 @@
       }
       break;
     }
-    case DIALOG_SHOP_REPAIR:
+
+    case HOUSE_DIALOGUE_SHOP_REPAIR:
     {
       draw_leather();
       CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
@@ -1661,7 +1676,8 @@
       return;
     }
     break;
-    case DIALOG_SHOP_DISPLAY_EQUIPMENT:
+
+    case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT:
     {
       draw_leather();
       CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
@@ -1699,7 +1715,8 @@
       }
       break;
     }
-    case DIALOG_SHOP_BUY_SPECIAL:
+
+    case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL:
     {
       pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
       v109 = 0;
@@ -1742,7 +1759,7 @@
         else
         {
           v58 = pGlobalTXT_LocalizationStrings[195];
-          if ( dialog_menu_id != 2 )
+          if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
             v58 = pGlobalTXT_LocalizationStrings[196];
         }
         DrawTextAtStatusBar(v58, 0);
@@ -1757,7 +1774,7 @@
             v61 = (int)window_SpeakInHouse->ptr_1C;
             //  v62 = 9 * (v60 + 12 * v61);
             v63 = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60];
-            if ( dialog_menu_id != 2 )
+            if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
               v63 = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724];
             if ( !v56 || !Str )
             {
@@ -1782,7 +1799,8 @@
       }
       break;
     }
-    case DIALOG_SHOP_SKILLS:
+
+    case HOUSE_DIALOGUE_LEARN_SKILLS:
     {
       if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
         return;
@@ -1864,7 +1882,7 @@
     }
     default:
     {
-      if( dialog_menu_id > 5 )
+      if( dialog_menu_id > HOUSE_DIALOGUE_SHOP_REPAIR)
         pNumActiveItem = dialog_menu_id - 96;
       else
         pNumActiveItem = dialog_menu_id - 4;
@@ -1991,7 +2009,7 @@
   pColorYellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
   switch(dialog_menu_id)
   {
-    case DIALOG_SHOP_MAIN:
+    case HOUSE_DIALOGUE_MAIN:
     {
       if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
       {
@@ -2032,7 +2050,7 @@
       }
       return;
     }
-    case DIALOG_SHOP_BUY_STANDART:
+    case HOUSE_DIALOGUE_SHOP_BUY_STANDARD:
     {
       pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
       v114 = 0;
@@ -2110,7 +2128,7 @@
         {
           v65 = pGlobalTXT_LocalizationStrings[185];
         }
-        else if ( dialog_menu_id == 2 )
+        else if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
         {
           v65 = pGlobalTXT_LocalizationStrings[195];
         }
@@ -2130,7 +2148,7 @@
         {
           v67 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1;
           v70 = (ItemGen *)&pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v67];
-          if ( dialog_menu_id != 2 )
+          if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
             v70 = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724];
           if ( !v63 || !Str )
           {
@@ -2149,7 +2167,7 @@
       }
       return;
     }
-    case DIALOG_SHOP_SELL:
+    case HOUSE_DIALOGUE_SHOP_SELL:
     {
       draw_leather();
       CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
@@ -2167,7 +2185,7 @@
       dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v21, 3);
       return; 
     }
-    case DIALOG_SHOP_IDENTIFY:
+    case HOUSE_DIALOGUE_SHOP_IDENTIFY:
     {
       draw_leather();
       CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
@@ -2193,7 +2211,7 @@
       dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3);
       return;
     }
-    case DIALOG_SHOP_DISPLAY_EQUIPMENT:
+    case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT:
     {
       draw_leather();
       CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
@@ -2231,7 +2249,7 @@
       }
       return;
     }
-    case DIALOG_SHOP_BUY_SPECIAL:
+    case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL:
     {
       pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
       v114 = 0;
@@ -2315,7 +2333,7 @@
         else
         {
           v65 = pGlobalTXT_LocalizationStrings[195];
-          if ( dialog_menu_id != 2 )
+          if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
             v65 = pGlobalTXT_LocalizationStrings[196];
         }
         DrawTextAtStatusBar(v65, 0);
@@ -2333,7 +2351,7 @@
           v68 = (int)window_SpeakInHouse->ptr_1C;
           //  v69 = 9 * (v67 + 12 * v68);
           v70 = (ItemGen *)&pParty->StandartItemsInShops[v68][v67];
-          if ( dialog_menu_id != 2 )
+          if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
             v70 = &pParty->SpecialItemsInShops[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724];
           if ( !v63 || !Str )
           {
@@ -2352,7 +2370,7 @@
       }
       return;
     }
-    case DIALOG_SHOP_SKILLS:
+    case HOUSE_DIALOGUE_LEARN_SKILLS:
     {
       if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
         return;
@@ -2611,7 +2629,7 @@
     hilight_color = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
     switch (dialog_menu_id)
     {
-    case DIALOG_SHOP_MAIN:
+    case HOUSE_DIALOGUE_MAIN:
         {
         if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
             return;
@@ -2648,14 +2666,14 @@
             }
         }
         break;
-    case DIALOG_SHOP_BUY_STANDART:
+    case HOUSE_DIALOGUE_SHOP_BUY_STANDARD:
         {
         pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
         textureW = 0;
         v153 = 0;
         for(int i=0; i<8; ++i)
             {
-            if ( pParty->StandartItemsInShops[window_SpeakInHouse->par1C][i].uItemID);
+            if ( pParty->StandartItemsInShops[window_SpeakInHouse->par1C][i].uItemID)
                 {
                 textureW = ItemsInShopTexture[i]->uTextureWidth;
                 textureH = ItemsInShopTexture[i]->uTextureHeight;
@@ -2728,7 +2746,7 @@
         return;
         }
         break;
-    case DIALOG_SHOP_SELL:
+    case HOUSE_DIALOGUE_SHOP_SELL:
     {
       draw_leather();
       CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
@@ -2750,7 +2768,7 @@
       return;
     }
     break;
-    case DIALOG_SHOP_IDENTIFY:
+    case HOUSE_DIALOGUE_SHOP_IDENTIFY:
         {
         draw_leather();
         CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
@@ -2794,7 +2812,7 @@
             }
         }
         break;
-    case DIALOG_SHOP_REPAIR:
+    case HOUSE_DIALOGUE_SHOP_REPAIR:
         {
         draw_leather();
         CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
@@ -2824,7 +2842,7 @@
         return;
         }
         break;
-    case 6: //buy standart
+    case HOUSE_DIALOGUE_SHOP_6: //buy standart
         {
         pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
         DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[195], 0); //"Select the Item to Buy"
@@ -2890,7 +2908,7 @@
         return;
         }
         break;
-    case DIALOG_SHOP_DISPLAY_EQUIPMENT:
+    case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT:
         {
         draw_leather();
         CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
@@ -2937,7 +2955,7 @@
         return;
         }
         break;
-    case DIALOG_SHOP_BUY_SPECIAL:
+    case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL:
         {
         pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
         v11 = 0;
@@ -3027,7 +3045,7 @@
                 return;
         }
         break;
-    case DIALOG_SHOP_SKILLS:
+    case HOUSE_DIALOGUE_LEARN_SKILLS:
         {
         if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
             return;
@@ -3206,9 +3224,9 @@
         strcpy(v47, "");
         strcpy(v48, "");
         strcpy(v49, "");
-        if ( dialog_menu_id != 1 )
+        if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN )
             {
-            if ( dialog_menu_id != 18 ) //buy skill
+            if ( dialog_menu_id != HOUSE_DIALOGUE_GULD_BUY_BOOKS ) //buy skill
                 {
                 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
                     {
@@ -3292,7 +3310,7 @@
 
                             GetAsyncKeyState(17);
                             statusbar_string = pGlobalTXT_LocalizationStrings[195]; //"Select the Item to Buy"
-                            if ( dialog_menu_id != 2 )
+                            if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
                                 statusbar_string = pGlobalTXT_LocalizationStrings[196]; //"Select the Special Item to Buy"	
                             DrawTextAtStatusBar(statusbar_string, 0);
                             if ( !v8 )
@@ -3533,14 +3551,14 @@
     //v2 = pPlayers[uActiveCharacter]->_4B807C(p2DEvents_minus1__20[13 * (unsigned int)v0->ptr_1C]);
     v2 = pPlayers[uActiveCharacter]->_4B807C(p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier);
     HIDWORD(v60) = v2;
-    if ( dialog_menu_id != 1 )
+    if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN )
         {
-        if ( dialog_menu_id != 10 )
+        if ( dialog_menu_id != HOUSE_DIALOGUE_TEMPLE_HEAL )
             {
-            if ( dialog_menu_id != 11 )
+            if ( dialog_menu_id != HOUSE_DIALOGUE_TEMPLE_DONATE )
                 {
 
-                if ( dialog_menu_id == 96 )
+                if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS )
                     {
                     if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
                         {
@@ -3940,12 +3958,12 @@
   result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
   if ( result )
   {
-    if ( dialog_menu_id != 1 )
+    if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN )
     {
-      if ( dialog_menu_id != 17 )
+      if ( dialog_menu_id != HOUSE_DIALOGUE_TRAININGHALL_17 )
       {
         result = dialog_menu_id - 96;
-        if ( dialog_menu_id == 96 )
+        if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS )
         {
           result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
           if ( result )
@@ -4363,9 +4381,9 @@
   dialog_window.uFrameZ = 334;
   m_text_color = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
   hilight_color = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
-  if ( dialog_menu_id > 5 )
+  if ( dialog_menu_id > HOUSE_DIALOGUE_SHOP_REPAIR )
   {
-    if ( dialog_menu_id == 94 )
+    if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT )
     {
       draw_leather();
       CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
@@ -4417,10 +4435,10 @@
       }
       return;
     }
-    if ( dialog_menu_id != 95 )
+    if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_SPECIAL )
     {
-      result = dialog_menu_id - 96;
-      if ( dialog_menu_id == 96 )
+      result = dialog_menu_id - HOUSE_DIALOGUE_LEARN_SKILLS;
+      if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS )
       {
         result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
         if ( result )
@@ -4521,7 +4539,7 @@
   }
   else
   {
-    if ( dialog_menu_id == 5 )
+    if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_REPAIR)
     {
       draw_leather();
       CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
@@ -4547,7 +4565,7 @@
       v10 = (char *)pMerchantsRepairPhrases[v29];
       goto LABEL_35;
     }
-    if ( dialog_menu_id == 1 )
+    if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN)
     {
      /* result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
       if ( result )
@@ -4637,12 +4655,12 @@
 
       return;
     }
-    if ( dialog_menu_id != 2 )
+    if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
     {
-      if ( dialog_menu_id != 3 )
+      if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_SELL)
       {
-        result = dialog_menu_id - 4;
-        if ( dialog_menu_id == 4 )
+        result = dialog_menu_id - HOUSE_DIALOGUE_SHOP_IDENTIFY;
+        if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_IDENTIFY)
         {
           draw_leather();
           CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
@@ -4730,7 +4748,7 @@
   v3 = 0;
   v49 = 0;
   v122 = 0;
-  if ( dialog_menu_id == 2 )
+  if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
   {
     do
     {
@@ -4865,7 +4883,7 @@
   {
     v66 = 0;
     v117 = 0;
-    if ( dialog_menu_id == 2 )
+    if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
     {
       do
       {
@@ -4896,7 +4914,7 @@
     else
     {
       v69 = pGlobalTXT_LocalizationStrings[195];// "Select the Item to Buy"
-      if ( dialog_menu_id != 2 )
+      if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
         v69 = pGlobalTXT_LocalizationStrings[196];// "Select the Special Item to Buy"
     }
     DrawTextAtStatusBar(v69, 0);
@@ -4914,7 +4932,7 @@
       v72 = (int)window_SpeakInHouse->ptr_1C;
      // v73 = 9 * (v71 + 12 * v72);
       v74 = (ItemGen *)&pParty->StandartItemsInShops[v72][v71];
-      if ( dialog_menu_id != 2 )
+      if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
        // v74 = (ItemGen *)&pParty->field_C59C[v73 + 724];
 	      v74 =&pParty->SpecialItemsInShops[v72][v71];
       if ( v67 && Str )
--- a/UIHouses.h	Sat Mar 23 09:25:31 2013 +0600
+++ b/UIHouses.h	Sat Mar 23 09:26:07 2013 +0600
@@ -2,23 +2,46 @@
 
 #include "stru159.h"
 
-enum DIALOG_MENU
-    {
-    DIALOG_SHOP_MAIN = 1,
-    DIALOG_SHOP_BUY_STANDART = 2,
-    DIALOG_SHOP_SELL = 3,
-    DIALOG_SHOP_IDENTIFY = 4,
-    DIALOG_SHOP_REPAIR = 5,
-    DIALOG_SHOP_REST = 15,
-    DIALOG_SHOP_BYE_FOOD = 16,
-    DIALOG_SHOP_DISPLAY_EQUIPMENT = 94,
-    DIALOG_SHOP_BUY_SPECIAL = 95,
-    DIALOG_SHOP_SKILLS = 96,
-    DIALOG_SHOP_ARCOMAGE_MAIN = 101,
-    DIALOG_SHOP_ARCOMAGE_102 = 102,
-    DIALOG_SHOP_ARCOMAGE_103 = 103,
-    DIALOG_SHOP_ARCOMAGE_RESULT = 104,
-    };
+enum HOUSE_DIALOGUE_MENU: unsigned __int32
+{
+  HOUSE_DIALOGUE_NULL = 0,
+  HOUSE_DIALOGUE_MAIN = 1,
+  HOUSE_DIALOGUE_SHOP_BUY_STANDARD = 2,
+  HOUSE_DIALOGUE_SHOP_SELL = 3,
+  HOUSE_DIALOGUE_SHOP_IDENTIFY = 4,
+  HOUSE_DIALOGUE_SHOP_REPAIR = 5,
+  HOUSE_DIALOGUE_SHOP_6 = 6,
+  HOUSE_DIALOGUE_BANK_7 = 7,
+  HOUSE_DIALOGUE_BANK_8 = 8,
+  HOUSE_DIALOGUE_9 = 9,
+  HOUSE_DIALOGUE_TEMPLE_HEAL = 10,
+  HOUSE_DIALOGUE_TEMPLE_DONATE = 11,
+  HOUSE_DIALOGUE_12 = 12,
+  HOUSE_DIALOGUE_13 = 13,
+  HOUSE_DIALOGUE_14 = 14,
+  HOUSE_DIALOGUE_TAVERN_REST = 15,
+  HOUSE_DIALOGUE_TAVERN_BUY_FOOD = 16,
+  HOUSE_DIALOGUE_TRAININGHALL_17 = 17,
+  HOUSE_DIALOGUE_GULD_BUY_BOOKS = 18,
+  //...
+  HOUSE_DIALOGUE_GUILD_LEARN_SKILL = 72,
+  //...
+  HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT = 94,
+  HOUSE_DIALOGUE_SHOP_BUY_SPECIAL = 95,
+  HOUSE_DIALOGUE_LEARN_SKILLS = 96,
+  HOUSE_DIALOGUE_97 = 97,
+  HOUSE_DIALOGUE_98 = 98,
+  HOUSE_DIALOGUE_TOWNHALL_99 = 99,
+  HOUSE_DIALOGUE_TOWNHALL_100 = 100,
+  HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN = 101,
+  HOUSE_DIALOGUE_TAVERN_ARCOMAGE_102 = 102,
+  HOUSE_DIALOGUE_TAVERN_ARCOMAGE_103 = 103,
+  HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RESULT = 104,
+
+  HOUSE_DIALOGUE_108 = 108,
+
+  HOUSE_DIALOGUE_OTHER = -1
+};
 
 /*  349 */
 enum HOUSE_ID
@@ -83,4 +106,6 @@
 
 extern int uHouse_ExitPic; // weak
 extern int dword_591080; // weak
- extern  const stru159 pAnimatedRooms[196];
+extern  const stru159 pAnimatedRooms[196];
+extern int in_current_building_type; // 00F8B198
+extern HOUSE_DIALOGUE_MENU dialog_menu_id; // 00F8B19C
\ No newline at end of file
--- a/UiGame.cpp	Sat Mar 23 09:25:31 2013 +0600
+++ b/UiGame.cpp	Sat Mar 23 09:26:07 2013 +0600
@@ -45,6 +45,7 @@
 #include "Events2D.h"
 #include "texts.h"
 #include "stru351.h"
+#include "UIHouses.h"
 
 #include "mm7_data.h"
 
@@ -974,7 +975,7 @@
     }
     if ( pCurrentScreen == SCREEN_HOUSE )
     {
-      if ( dialog_menu_id != 2
+      if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD
         || (v16 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]], v16 == 0)
         || v16 == -65536 )
         //goto _return;
--- a/Weather.h	Sat Mar 23 09:25:31 2013 +0600
+++ b/Weather.h	Sat Mar 23 09:26:07 2013 +0600
@@ -17,7 +17,7 @@
 
 
   __int16 field_0[2000];
-  int field_FA0;
+  int bNight;
   int bRenderSnow;
 };
 #pragma pack(pop)
--- a/mm7_1.cpp	Sat Mar 23 09:25:31 2013 +0600
+++ b/mm7_1.cpp	Sat Mar 23 09:26:07 2013 +0600
@@ -51,6 +51,7 @@
 #include "Events2D.h"
 #include "texts.h"
 #include "stru351.h"
+#include "UIHouses.h"
 
 #include "mm7_data.h"
 
@@ -968,8 +969,9 @@
     //goto LABEL_28;
     uActiveCharacter = uPlayerID;
     return;
-  if ( dialog_menu_id == 2 || dialog_menu_id == 6 )
+  if (dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD || dialog_menu_id == HOUSE_DIALOGUE_SHOP_6)
   {
+    __debugbreak(); // fix indexing
     pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
     v5 = 14;
     //goto LABEL_22;
--- a/mm7_2.cpp	Sat Mar 23 09:25:31 2013 +0600
+++ b/mm7_2.cpp	Sat Mar 23 09:26:07 2013 +0600
@@ -301,7 +301,7 @@
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
   pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, 0, 0x53u, 0, "", 0);
   pDialogueWindow->_41D08F(1, 1, 0, 2);
-  dialog_menu_id = -1;
+  dialog_menu_id = HOUSE_DIALOGUE_OTHER;
   v0 = (int)((char *)window_SpeakInHouse->ptr_1C - 102);
   if ( (signed __int64)__PAIR__(pParty->field_3C.field_0[2 * v0 + 1], pParty->field_3C.field_0[2 * v0]) < (signed __int64)pParty->uTimePlayed )
   {
@@ -889,12 +889,12 @@
     return;
   pRenderer->ClearZBuffer(0, 479);
   //v3 = dword_F8B198;
-  if ( dialog_menu_id != 1 )
+  if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN)
   {
 	v8 = window_SpeakInHouse;
   }
   //else
-  if ( dialog_menu_id == 1 )
+  if (dialog_menu_id == HOUSE_DIALOGUE_MAIN)
   {
 	  if ( in_current_building_type == BildingType_Training )
 	  {
@@ -949,7 +949,7 @@
 		  }
 	  }
 	//LABEL_11:
-	  dialog_menu_id = uMessageParam;
+	  dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam;
 	  if ( in_current_building_type < BildingType_19 )
 	  {
 		v9 = pIcons_LOD->LoadTexture(off_4F03B8[in_current_building_type], TEXTURE_16BIT_PALETTE);
@@ -1524,7 +1524,7 @@
     case 102:
     case 103:
 		{
-        dialog_menu_id = uMessageParam;
+        dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam;
         break;
 		}
     case 104:
@@ -1537,7 +1537,7 @@
           ++pMessageQueue_50CBD0->uNumMessages;
         }*/
         pMessageQueue_50CBD0->AddMessage(UIMSG_PlayArcomage, 0, 0);
-        dialog_menu_id = 104;
+        dialog_menu_id = HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RESULT;
         break;
 		}
 	case 2:
@@ -1655,7 +1655,7 @@
 	case 4:
 	case 5:
 		{
-		dialog_menu_id = uMessageParam;
+		dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam;
 		sub_421B2C_PlaceInInventory_or_DropPickedItem();
 		break;
 		}
@@ -1918,11 +1918,11 @@
   if ( pDialogueNPCCount )
   {
     v0 = dialog_menu_id;
-    if ( dialog_menu_id != 2
-      && dialog_menu_id != 3
-      && dialog_menu_id != 97
-      && dialog_menu_id != 5
-      && dialog_menu_id != 4
+    if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD
+      && dialog_menu_id != HOUSE_DIALOGUE_SHOP_SELL
+      && dialog_menu_id != HOUSE_DIALOGUE_97
+      && dialog_menu_id != HOUSE_DIALOGUE_SHOP_REPAIR
+      && dialog_menu_id != HOUSE_DIALOGUE_SHOP_IDENTIFY
       && ShopTexture )
     {
       ShopTexture->Release();
@@ -1943,7 +1943,7 @@
         if ( v0 == 3 || v0 == 5 || v0 == 4 )
         {
           UI_CreateEndConversationButton();
-          dialog_menu_id = 94;
+          dialog_menu_id = HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT;
           sub_4B3AD4(in_current_building_type);
         }
         else
@@ -1952,26 +1952,26 @@
           {
             pVideoPlayer->_4BF5B2();
 //LABEL_28:
-            dialog_menu_id = 1;
+            dialog_menu_id = HOUSE_DIALOGUE_MAIN;
             sub_4B3B42(in_current_building_type);
             return 1;
           }
           pVideoPlayer->_4BF5B2();
           UI_CreateEndConversationButton();
-          dialog_menu_id = 101;
+          dialog_menu_id = HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN;
           sub_4B3A72(in_current_building_type);
         }
         return 1;
       }
       pVideoPlayer->_4BF5B2();
       UI_CreateEndConversationButton();
-	  dialog_menu_id = 1;
+	  dialog_menu_id = HOUSE_DIALOGUE_MAIN;
 	  sub_4B3B42(in_current_building_type);
 	  return 1;
     }
     pDialogueNPCCount = 0;
     pDialogueWindow->Release();
-    dialog_menu_id = 0;
+    dialog_menu_id = HOUSE_DIALOGUE_NULL;
     pDialogueWindow = 0;
     pIcons_LOD->_40F9C5();
     v1 = uNumDialogueNPCPortraits;
@@ -2039,14 +2039,14 @@
   void *v30; // eax@50
   int v31; // ecx@50
   ItemGen *v32; // esi@51
-  float v33; // ST1C_4@53
-  signed int v34; // eax@53
-  int v35; // eax@53
-  bool v36; // eax@53
+  //float v33; // ST1C_4@53
+  //signed int v34; // eax@53
+  //int v35; // eax@53
+  //bool v36; // eax@53
   unsigned int v37; // eax@53
   int v38; // eax@55
   int v39; // eax@63
-  int v40; // eax@64
+  //int v40; // eax@64
   int v41; // edx@66
   int v42; // esi@74
   signed int v43; // ebx@74
@@ -2063,7 +2063,7 @@
   unsigned int v54; // [sp+0h] [bp-B4h]@25
   int v55; // [sp+0h] [bp-B4h]@26
   int v56; // [sp+0h] [bp-B4h]@36
-  POINT v57; // [sp+10h] [bp-A4h]@49
+  //POINT v57; // [sp+10h] [bp-A4h]@49
   //POINT v58; // [sp+18h] [bp-9Ch]@18
   POINT v59; // [sp+20h] [bp-94h]@49
   POINT v60; // [sp+28h] [bp-8Ch]@9
@@ -2079,7 +2079,7 @@
   POINT v70; // [sp+78h] [bp-3Ch]@9
   POINT v71; // [sp+80h] [bp-34h]@31
   POINT v72; // [sp+88h] [bp-2Ch]@10
-  bool v73; // [sp+90h] [bp-24h]@53
+  //bool v73; // [sp+90h] [bp-24h]@53
   int v74; // [sp+94h] [bp-20h]@53
   int a6; // [sp+98h] [bp-1Ch]@57
   int a3; // [sp+9Ch] [bp-18h]@53
@@ -2108,15 +2108,16 @@
     pAudioPlayer->PlaySound(SOUND_27, v46, v47, v48, v49, v50, v52, v56);
     return;
   }
+
   switch(dialog_menu_id)
   {
-	case 94:
+	case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT:
 		{
 			pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
 			sub_421EA6_OnInventoryLeftClick();
 			break;
 		}
-	case 18:
+	case HOUSE_DIALOGUE_GULD_BUY_BOOKS:
 		{
 		v17 = pMouse->GetCursorPos(&v63);
 		v18 = pRenderer->pActiveZBuffer[v17->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v61)->y]] & 0xFFFF;
@@ -2128,7 +2129,7 @@
 		v21 = p2DEvents[(signed int)v19 - 1].fPriceMultiplier;
 		_this = v20;
 		v22 = v20->GetValue();
-		v23 = v0->_4B8142(v22, v21);
+		v23 = v0->GetBuyingPrice(v22, v21);
 		v80 = v23;
 		GetAsyncKeyState(VK_CONTROL);
 		if ( pParty->uNumGold < v23 )
@@ -2165,7 +2166,8 @@
 		ShowStatusBarString(v9, v54);
 		break;
 		}
-	case 3:
+
+	case HOUSE_DIALOGUE_SHOP_SELL:
 		{
 		v14 = pMouse->GetCursorPos(&v71)->x - 14;
 		v79 = (v14 >> 5) + 14 * ((pMouse->GetCursorPos(&v69)->y - 17) >> 5);
@@ -2199,7 +2201,7 @@
 		break;
 		}
 
-	case 4:
+	case HOUSE_DIALOGUE_SHOP_IDENTIFY:
     {
       pMouse->GetCursorPos(&v62);
 		v10 = v62.x - 14;
@@ -2250,7 +2252,9 @@
 		}
 		break;
 		}
-	case 5:
+
+
+	case HOUSE_DIALOGUE_SHOP_REPAIR:
 		{
 		v1 = pMouse->GetCursorPos(&a2)->x - 14;
 		v79 = (v1 >> 5) + 14 * ((pMouse->GetCursorPos(&v70)->y - 17) >> 5);
@@ -2317,20 +2321,21 @@
 		}
 		break;
 		}
-	case 2:
-	case 95:
+
+	case HOUSE_DIALOGUE_SHOP_BUY_STANDARD:
+	case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL:
 		{
 	//LABEL_49:
 		v28 = pMouse->GetCursorPos(&v59);
-		v29 = pRenderer->pActiveZBuffer[v28->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v57)->y]] & 0xFFFF;
+		v29 = pRenderer->pActiveZBuffer[v28->x + pSRZBufferLineOffsets[v28->y]] & 0xFFFF;
 		if ( !v29 )
 			return;
 		v30 = window_SpeakInHouse->ptr_1C;
 		// v31 = 9 * (v29 - 1 + 12 * (int)v30);
-		if ( dialog_menu_id == 2 )
+		if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
 		{
-			v32 = (ItemGen *)&pParty->StandartItemsInShops[(int)v30][v29-1];
-			_this = (ItemGen *)&pParty->StandartItemsInShops[(int)v30][v29-1];
+			v32 = (ItemGen *)&pParty->StandartItemsInShops[(int)v30][v29 - 1];
+			_this = (ItemGen *)&pParty->StandartItemsInShops[(int)v30][v29 - 1];
 		}
 		else
 		{
@@ -2338,23 +2343,23 @@
 			v32 = &pParty->SpecialItemsInShops[(int)v30][v29-1];//(ItemGen *)&pParty->field_C59C[v31 + 724];
 		}
 		//v33 = p2DEvents_minus1__20[13 * (signed int)v30];
-		v33 = p2DEvents[(signed int)v30 - 1].fPriceMultiplier;
-		v34 = v32->GetValue();
-		v80 = v0->_4B8142(v34, v33);
-		LOWORD(v35) = GetAsyncKeyState(VK_CONTROL);
-		v74 = v35;
-		v36 = v0->CanSteal();
+		//v33 = p2DEvents[(signed int)v30 - 1].fPriceMultiplier;
+		//v34 = v32->GetValue();
+		v80 = v0->GetBuyingPrice(v32->GetValue(), p2DEvents[(unsigned int)v30 - 1].fPriceMultiplier);
+		//LOWORD(v35) = GetAsyncKeyState(VK_CONTROL);
+		v74 = GetAsyncKeyState(VK_CONTROL);
+		//v36 = v0->CanSteal();
 		uNumSeconds = 0;
 		a3 = 0;
-		v73 = v36;
+		//v73 = v0->CanSteal();
 		v37 = pMapStats->GetMapInfo(pCurrentMapName);
 		if ( v37 )
 			a3 = pMapStats->pInfos[v37]._steal_perm;
 		v38 = GetPartyReputation();
 		v26 = 1;
-		if ( v73 == 1 )
+		if (v0->CanSteal())
 		{
-			if ( (short)v74 )
+			if ( v74 )
 			{
 			uNumSeconds = v0->StealFromShop(v32, a3, v38, 0, &a6);
 			if ( !uNumSeconds )
@@ -2372,7 +2377,7 @@
 				if ( uNumSeconds != 1 )
 				{
 					PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v24);
-					v9 = pGlobalTXT_LocalizationStrings[155];
+					v9 = pGlobalTXT_LocalizationStrings[155]; // "You don't have enough gold"
 					v54 = 2;
 					ShowStatusBarString(v9, v54);
 					return;
@@ -2383,17 +2388,19 @@
 		if ( v39 )
 		{
 			v32->SetIdentified();
-			v7 = v73 == 1;
-			v40 = (int)((char *)v0 + 36 * v39);
-			memcpy((void *)(v40 + 496), v32, 0x24u);
+			v7 = v0->CanSteal();
+			//v40 = (int)((char *)v0 + 36 * v39);
+            //memcpy((void *)(v40 + 496), v32, 0x24u);
+            memcpy(&v0->pInventoryItems[v39 - 1], v32, sizeof(ItemGen));
 			if ( v7 )
 			{
-				if ( (short)v74 )
+				if ( v74 )
 				{
 					v41 = uNumSeconds;
 					if ( uNumSeconds == 1 || uNumSeconds == 2 )
 					{
-						*(char *)(v40 + 517) |= 1u;
+						//*(char *)(v40 + 517) |= 1u;
+                        v0->pInventoryItems[v39 - 1].SetStolen();
 						sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, v41, a6);
 						viewparams->bRedrawGameUI = v26;
 						_this->Reset();
@@ -2429,6 +2436,7 @@
 
 	default:
 		{
+          __debugbreak(); // please do record these dialogue ids to the HOUSE_DIALOGUE_MENU  enum
 		if( dialog_menu_id >= 36 && dialog_menu_id <= 72 )
 		{
 			v42 = dialog_menu_id - 36;
@@ -5053,17 +5061,16 @@
         }
         sprintf(Str2, v44, pTexture);
       }
-      v26 = pMonsterList->GetMonsterByName(Str2);
-      v50 = (signed __int16)v26;
+      v50 = pMonsterList->GetMonsterIDByName(Str2);
       pTexture = Str2;
-      if ( (signed __int16)v26 == -1 )
+      if ( (signed __int16)v50 == -1 )
       {
         sprintf(Str, "Can't create random monster: '%s'! See MapStats.txt and Monsters.txt!", pTexture);
         MessageBoxA(nullptr, Str, nullptr, 0);
         ExitProcess(0);
       }
-      v27 = &pMonsterList->pMonsters[(signed __int16)v26];
-      v28 = pMonsterStats->FindMonsterByName(pTexture);
+      v27 = &pMonsterList->pMonsters[(signed __int16)v50];
+      v28 = pMonsterStats->FindMonsterByTextureName(pTexture);
       if ( !v28 )
         v28 = 1;
       Src = &pMonsterStats->pInfos[v28];
@@ -5168,7 +5175,7 @@
     else
       v15 = "Elemental Light A";
   }
-  v23 = (signed __int16)pMonsterList->GetMonsterByName(v15);
+  v23 = pMonsterList->GetMonsterIDByName(v15);
   v3 = 0;
   v20 = uNumActors;
   if ( (signed int)uNumActors > 0 )
@@ -9440,11 +9447,11 @@
   uint uWinCenteredPosY = (uDesktopHeight - uTotalWinHeight) / 2;
 
   uWindowX = ReadWindowsRegistryInt("window X", uWinCenteredPosX);
-  uWindowX = 0;
+  uWindowX = uDesktopWidth / 2 - 640 / 2;
   WriteWindowsRegistryInt("window X", uWindowX);
 
   uWindowY = ReadWindowsRegistryInt("window Y", uWinCenteredPosY);
-  uWindowY = 0;
+  uWindowY = uDesktopHeight / 2 - 480 / 2;
   WriteWindowsRegistryInt("window Y", uWindowY);
 
   hWnd = CreateWindowExW(0, wcxw.lpszClassName, L"Might and Magic VII",
@@ -9458,7 +9465,144 @@
   SetWindowTextW(hWnd, L"Might and Magic VII");
 
   HMENU menu = CreateMenu();
-  AppendMenuW(menu, MF_ENABLED | MF_STRING, 0x101, L"Open level...");
+  {
+    HMENU file = CreatePopupMenu();
+    AppendMenuW(menu, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)file, L"&File");
+    {
+      AppendMenuW(file, MF_ENABLED | MF_STRING, 40001, L"Exit");
+    }
+
+    HMENU debug = CreatePopupMenu();
+    AppendMenuW(menu, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug, L"&Debug");
+    {
+      HMENU debug_party = CreatePopupMenu();
+      AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_party, L"&Party");
+      {
+        AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40007, L"Give Gold (10 000)");
+        AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40008, L"Give Exp (20 000)");
+        AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40059, L"Give Skills (50 each)");
+        AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40013, L"Remove Gold");
+
+        HMENU debug_party_setconditions = CreatePopupMenu();
+        AppendMenuW(debug_party, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_party_setconditions, L"Set Condition");
+        {
+          AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40044, L"Afraid");
+          AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40043, L"Asleep");
+          AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40037, L"Curse");
+          AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40036, L"Disease1");
+          AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40035, L"Disease2");
+          AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40034, L"Disease3");
+          AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40041, L"Dead");
+          AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40039, L"Drunk");
+          AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40042, L"Eradicated");
+          AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40038, L"Insane");
+          AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40045, L"Paralyzed");
+          AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40033, L"Poison1");
+          AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40032, L"Poison2");
+          AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40031, L"Poison3");
+          AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40029, L"&Stone");
+          AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40040, L"Unconscious");
+          AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40030, L"Weak");
+          AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40073, L"Zombie");
+        }
+
+        AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40006, L"Set Food (20)");
+
+        HMENU debug_party_alignment = CreatePopupMenu();
+        AppendMenuW(debug_party, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_party_alignment, L"Alignment");
+        {
+          AppendMenuW(debug_party_alignment, MF_ENABLED | MF_STRING, 40062, L"Good");
+          AppendMenuW(debug_party_alignment, MF_ENABLED | MF_STRING | MF_CHECKED, 40063, L"Neutral");
+          AppendMenuW(debug_party_alignment, MF_ENABLED | MF_STRING, 40064, L"Evil");
+        }
+      }
+
+      HMENU debug_time = CreatePopupMenu();
+      AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_time, L"&Time");
+      {
+        AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40009, L"Add 1 Day");
+        AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40010, L"Add 1 Week");
+        AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40011, L"Add 1 Month");
+        AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40012, L"Add 1 Year");
+      }
+
+      HMENU debug_items = CreatePopupMenu();
+      AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_items, L"&Items");
+      {
+        AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40015, L"Generate level &1 item");
+        AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40016, L"Generate level &2 item");
+        AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40017, L"Generate level &3 item");
+        AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40018, L"Generate level &4 item");
+        AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40019, L"Generate level &5 item");
+        AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40020, L"Generate level &6 item");
+        AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40061, L"Generate special item");
+      }
+
+      HMENU debug_graphics = CreatePopupMenu();
+      AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_graphics, L"&Graphics");
+      {
+        AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40023, L"Lighting Mode");
+        AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40024, L"Lighting Geometry");
+        AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING | MF_GRAYED, 40104, L"Lights Off");
+        AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40105, L"Colored Lights");
+        AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40025, L"Debug Lights");
+        AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40101, L"Debug Decals");
+        AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40027, L"HWID Portals");
+        AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40047, L"SWID Portals");
+        AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40051, L"OD Frustum");
+        AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40054, L"SWOD Constant Redraw");
+        AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40055, L"SWOD Lit Rasterizer");
+        AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40056, L"Party Light off");
+        AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40060, L"SWOD Nice Lighting off");
+        AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40067, L"HWOD Additive Fog Lights");
+        AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40072, L"HWID Nice Lighting");
+        AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40048, L"Wireframe");
+        AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40049, L"Fog");
+      }
+
+      HMENU debug_misc = CreatePopupMenu();
+      AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_misc, L"&Misc");
+      {
+        AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40066, L"Object Viewcone Culling");
+        AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40068, L"Red Tint");
+        AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40071, L"Display Secrets");
+        AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40102, L"Massive Bloodsplat");
+        AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40103, L"Underwater Gravity");
+      }
+      
+      HMENU debug_eax = CreatePopupMenu();
+      AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_eax, L"EAX Environs");
+      {
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40074, L"NONE");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40075, L"GENERIC");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40076, L"PADDEDCELL");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40077, L"ROOM");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40078, L"BATHROOM");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40079, L"LIVINGROOM");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40080, L"STONEROOM");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40081, L"AUDITORIUM");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40082, L"CONCERTHALL");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40083, L"CAVE");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40084, L"ARENA");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40085, L"HANGAR");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40086, L"CARPETEDHALLWAY");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40087, L"HALLWAY");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40088, L"STONECORRIDOR");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40089, L"ALLEY");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40090, L"FOREST");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40091, L"CITY");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40092, L"MOUNTAINS");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40093, L"QUARRY");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40094, L"PLAIN");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40095, L"PARKINGLOT");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40096, L"SEWERPIPE");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40097, L"UNDERWATER");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40098, L"DRUGGED");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40099, L"DIZZY");
+        AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40100, L"PSICHOTIC");
+      }
+    }
+  }
   SetMenu(hWnd, menu);
   
   SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
--- a/mm7_3.cpp	Sat Mar 23 09:25:31 2013 +0600
+++ b/mm7_3.cpp	Sat Mar 23 09:26:07 2013 +0600
@@ -6824,7 +6824,7 @@
   v18 = a2;
   if ( pParty->armageddon_timer )
     return PaletteManager::Get(a2);
-  if ( !pWeather->field_FA0 )
+  if ( !pWeather->bNight )
   {
     if ( day_attrib & 1 )
     {
@@ -6873,7 +6873,7 @@
     return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1);
   }
   v6 = 0;
-  if ( pWeather->field_FA0 == 1 )
+  if (pWeather->bNight)
   {
     v8 = 67108864;
     if ( (signed __int64)pParty->pPartyBuffs[16].uExpireTime > 0 )
@@ -6954,7 +6954,7 @@
     v26 = v8->field_34 << 16;
     v9 = v8->field_34 << 16;
   }
-  v10 = pWeather->field_FA0;
+  v10 = pWeather->bNight;
   if ( bUnderwater == 1 )
     v10 = 0;
   if ( !v10 )
@@ -7240,9 +7240,10 @@
   {
     if ( day_attrib & 1 )
     {
-      if ( pWeather->field_FA0 )
-      {
-        v2 = -(pWeather->field_FA0 != 1);
+      if ( pWeather->bNight )
+      {
+        __debugbreak(); // decompilation can be inaccurate, please  send savegame to Nomad
+        v2 = -(pWeather->bNight != 1);
         result = (v2 & 0xE0E0E1) - 0xE0E0E1;
       }
       else
@@ -7274,15 +7275,13 @@
   float v11; // ST14_4@17
   double v12; // ST08_8@17
 
-  v3 = pWeather->field_FA0;
+  v3 = pWeather->bNight;
   if ( bUnderwater == 1 )
     v3 = 0;
   if ( pParty->armageddon_timer || !(day_attrib & 1) && !bUnderwater )
     return 0xFF000000;
   if ( v3 )
   {
-    if ( v3 != 1 )
-      return 0;
     v5 = (double)day_fogrange_1;
     v6 = 216;
     if ( a3 < v5 )
@@ -7337,7 +7336,7 @@
   //signed int result; // eax@2
   int v8; // eax@3
   double v9; // st7@12
-  double v10; // ST0C_8@18
+  //double v10; // ST0C_8@18
   int v11; // ecx@28
   //signed int v12; // edi@28
   //double v13; // ST0C_8@33
@@ -7352,7 +7351,7 @@
   //float a3b; // [sp+1Ch] [bp+8h]@34
   float a3c; // [sp+1Ch] [bp+8h]@44
   //float a3d; // [sp+1Ch] [bp+8h]@44
-  float a4b; // [sp+20h] [bp+Ch]@18
+  //float a4b; // [sp+20h] [bp+Ch]@18
   //int a4a; // [sp+20h] [bp+Ch]@33
   //float a4c; // [sp+20h] [bp+Ch]@44
   //float a4d; // [sp+20h] [bp+Ch]@44
@@ -7367,14 +7366,11 @@
   if (pParty->armageddon_timer)
     return 0xFFFF0000;
 
-  v8 = pWeather->field_FA0;
+  v8 = pWeather->bNight;
   if (bUnderwater)
     v8 = 0;
   if ( v8 )
   {
-    //__debugbreak(); // doubt that weather-related stuff will ever trigger, but if it suddenly does - find out what it is
-    if ( v8 != 1 )
-      return 0;
     v20 = 1;
     if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 )
       v20 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower;
@@ -7385,10 +7381,11 @@
     {
       if ( distance > 0.0 )
       {
-        a4b = distance * 216.0 / v9;
-        v10 = a4b + 6.7553994e15;
-        v6 = LODWORD(v10);
-        if ( SLODWORD(v10) > 216 )
+        //a4b = distance * 216.0 / v9;
+        //v10 = a4b + 6.7553994e15;
+        //v6 = LODWORD(v10);
+        v6 = floorf(0.5f + distance * 216.0 / v9);
+        if (v6 > 216 )
           goto LABEL_19;
       }
     }
@@ -10650,20 +10647,20 @@
   {
     v14 = v10 + pOutdoorCamera->camera_rotation_y_int_sine * -pIndoorCamera->pos.y;
     v15 = pOutdoorCamera->camera_rotation_y_int_cosine * v8 - pOutdoorCamera->camera_rotation_y_int_sine * v24;
-    this->field_0 = ((unsigned __int64)(v11 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16)
+    this->field_0_party_dir_x = ((unsigned __int64)(v11 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16)
                   + ((unsigned __int64)(-65536
                                       * pIndoorCamera->pos.z
                                       * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16);
-    this->field_4 = v15;
+    this->field_4_party_dir_y = v15;
     v12 = v25;
     v13 = ((unsigned __int64)((v26 << 16) * (signed __int64)v25) >> 16)
         - ((unsigned __int64)(v14 * (signed __int64)v27) >> 16);
   }
   else
   {
-    this->field_4 = pOutdoorCamera->camera_rotation_y_int_cosine * v8 - pOutdoorCamera->camera_rotation_y_int_sine * v24;
+    this->field_4_party_dir_y = pOutdoorCamera->camera_rotation_y_int_cosine * v8 - pOutdoorCamera->camera_rotation_y_int_sine * v24;
     v12 = v25;
-    this->field_0 = v11;
+    this->field_0_party_dir_x = v11;
     v13 = v26 << 16;
   }
   this->field_8 = v13;
@@ -10707,14 +10704,14 @@
   this->field_20 = v18;
   v20 = this->field_C;
   this->field_20 = -this->field_20;
-  v21 = ((unsigned __int64)(v20 * (signed __int64)this->field_0) >> 16)
-      + ((unsigned __int64)(this->field_10 * (signed __int64)this->field_4) >> 16)
+  v21 = ((unsigned __int64)(v20 * (signed __int64)this->field_0_party_dir_x) >> 16)
+      + ((unsigned __int64)(this->field_10 * (signed __int64)this->field_4_party_dir_y) >> 16)
       + ((unsigned __int64)(this->field_14 * (signed __int64)this->field_8) >> 16);
   v28 = this->field_18;
-  v22 = this->field_0;
+  v22 = this->field_0_party_dir_x;
   this->field_24 = v21;
   v29 = (unsigned __int64)(v28 * (signed __int64)v22) >> 16;
-  result = (unsigned __int64)(this->field_1C * (signed __int64)this->field_4) >> 16;
+  result = (unsigned __int64)(this->field_1C * (signed __int64)this->field_4_party_dir_y) >> 16;
   this->field_28 = v29 + result + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16);
   return result;
 }
@@ -10725,8 +10722,8 @@
   stru149 *v7; // esi@1
   int v8; // edi@1
   int v9; // eax@1
-  int v10; // edx@1
-  int v11; // ecx@1
+  //int v10; // edx@1
+  //int v11; // ecx@1
   int v12; // eax@1
   int v13; // ebx@2
   int v14; // ecx@2
@@ -10741,7 +10738,7 @@
   int v23; // ecx@10
   int v24; // eax@10
   int result; // eax@10
-  int v26; // [sp+14h] [bp-14h]@1
+  //int v26; // [sp+14h] [bp-14h]@1
   int v27; // [sp+18h] [bp-10h]@1
   int v28; // [sp+1Ch] [bp-Ch]@1
   int v29; // [sp+24h] [bp-4h]@1
@@ -10753,8 +10750,8 @@
   v29 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotY);
   v28 = stru_5C6E00->Cos(pBLVRenderParams->sPartyRotX);
   v9 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotX);
-  v11 = -pBLVRenderParams->vPartyPos.y;
-  v26 = -pBLVRenderParams->vPartyPos.x;
+  //v11 = -pBLVRenderParams->vPartyPos.y;
+  //v26 = -pBLVRenderParams->vPartyPos.x;
   v27 = v9;
   v12 = -pBLVRenderParams->vPartyPos.z;
   if ( pBLVRenderParams->sPartyRotX )
@@ -10762,17 +10759,17 @@
     v16 = v8 * -pBLVRenderParams->vPartyPos.x + v29 * -pBLVRenderParams->vPartyPos.y;
     v13 = v28;
     v17 = -65536 * pBLVRenderParams->vPartyPos.z;
-    v7->field_0 = ((unsigned __int64)(v16 * (signed __int64)v28) >> 16)
+    v7->field_0_party_dir_x = ((unsigned __int64)(v16 * (signed __int64)v28) >> 16)
                 + ((unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)v27) >> 16);
-    v7->field_4 = v8 * v11 - v29 * v26;
+    v7->field_4_party_dir_y = v8 * -pBLVRenderParams->vPartyPos.y - v29 * -pBLVRenderParams->vPartyPos.x;
     v14 = v27;
     v15 = ((unsigned __int64)(v17 * (signed __int64)v28) >> 16) - ((unsigned __int64)(v16 * (signed __int64)v27) >> 16);
   }
   else
   {
-    v7->field_0 = v10 + v29 * -pBLVRenderParams->vPartyPos.y;
+    v7->field_0_party_dir_x = v8 * -pBLVRenderParams->vPartyPos.x + v29 * -pBLVRenderParams->vPartyPos.y;
     v13 = v28;
-    v7->field_4 = v8 * v11 - v29 * v26;
+    v7->field_4_party_dir_y = v8 * -pBLVRenderParams->vPartyPos.y - v29 * -pBLVRenderParams->vPartyPos.x;
     v14 = v27;
     v15 = v12 << 16;
   }
@@ -10817,14 +10814,14 @@
   v7->field_20 = v20;
   v22 = v7->field_C;
   v7->field_20 = -v7->field_20;
-  v23 = ((unsigned __int64)(v22 * (signed __int64)v7->field_0) >> 16)
-      + ((unsigned __int64)(v7->field_10 * (signed __int64)v7->field_4) >> 16)
+  v23 = ((unsigned __int64)(v22 * (signed __int64)v7->field_0_party_dir_x) >> 16)
+      + ((unsigned __int64)(v7->field_10 * (signed __int64)v7->field_4_party_dir_y) >> 16)
       + ((unsigned __int64)(v7->field_14 * (signed __int64)v7->field_8) >> 16);
   v30 = v7->field_18;
-  v24 = v7->field_0;
+  v24 = v7->field_0_party_dir_x;
   v7->field_24 = v23;
   v31 = (unsigned __int64)(v30 * (signed __int64)v24) >> 16;
-  result = (unsigned __int64)(v7->field_1C * (signed __int64)v7->field_4) >> 16;
+  result = (unsigned __int64)(v7->field_1C * (signed __int64)v7->field_4_party_dir_y) >> 16;
   v7->field_28 = v31 + result + ((unsigned __int64)(v7->field_20 * (signed __int64)v7->field_8) >> 16);
   return result;
 }
@@ -10843,14 +10840,14 @@
   this->field_18 = -this->field_18;
   this->field_1C = -this->field_1C;
   this->field_20 = -this->field_20;
-  v2 = (unsigned __int64)(v1 * (signed __int64)this->field_0) >> 16;
+  v2 = (unsigned __int64)(v1 * (signed __int64)this->field_0_party_dir_x) >> 16;
   v3 = this->field_18;
-  v4 = this->field_0;
+  v4 = this->field_0_party_dir_x;
   this->field_24 = v2
-                 + ((unsigned __int64)(this->field_10 * (signed __int64)this->field_4) >> 16)
+                 + ((unsigned __int64)(this->field_10 * (signed __int64)this->field_4_party_dir_y) >> 16)
                  + ((unsigned __int64)(this->field_14 * (signed __int64)this->field_8) >> 16);
   v5 = (unsigned __int64)(v3 * (signed __int64)v4) >> 16;
-  result = (unsigned __int64)(this->field_1C * (signed __int64)this->field_4) >> 16;
+  result = (unsigned __int64)(this->field_1C * (signed __int64)this->field_4_party_dir_y) >> 16;
   this->field_28 = v5 + result + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16);
   return result;
 }
--- a/mm7_4.cpp	Sat Mar 23 09:25:31 2013 +0600
+++ b/mm7_4.cpp	Sat Mar 23 09:26:07 2013 +0600
@@ -4666,7 +4666,7 @@
                     v26 = &p2DEvents[(signed int)a4 - 1].fPriceMultiplier;
         v27 = *v26;
         v28 = a3->GetValue();
-        v29 = pPlayer->_4B8142(v28, v27);
+        v29 = pPlayer->GetBuyingPrice(v28, v27);
         if ( a5 == 3 )
         {
           v35 = *v26;
@@ -7246,11 +7246,11 @@
     return;
   if ( in_current_building_type <= BildingType_AlchemistShop )
   {
-    if ( dialog_menu_id != 2 )
-    {
-      if ( dialog_menu_id <= 2 )
+    if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
+    {
+      if ( dialog_menu_id <= HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
         return;
-      if ( dialog_menu_id <= 5 || dialog_menu_id == 94 )
+      if ( dialog_menu_id <= HOUSE_DIALOGUE_SHOP_REPAIR || dialog_menu_id == HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT )
       {
         v8 = pMouse->GetCursorPos(&v15)->x - 14;
         v18 = (v8 >> 5) + 14 * ((pMouse->GetCursorPos(&v14)->y - 17) >> 5);
@@ -7263,7 +7263,7 @@
         GameUI_DrawItemInfo(v7);
         return;
       }
-      if ( dialog_menu_id != 95 )
+      if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_SPECIAL )
         return;
     }
     v4 = pMouse->GetCursorPos(&v11);
@@ -7273,12 +7273,12 @@
       return;
     v6 = 9 * (v5 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C);
     v7 = (ItemGen *)((char *)&pParty->pPickedItem + 4 * v6 + 4);
-    if ( dialog_menu_id != 2 )
+    if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
    //   v7 = (ItemGen *)&pParty->field_C59C[v6 + 715];
 		v7 =&pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v5];
     goto LABEL_15;
   }
-  if ( in_current_building_type <= BildingType_16 && dialog_menu_id == BildingType_18 )
+  if ( in_current_building_type <= BildingType_16 && dialog_menu_id == HOUSE_DIALOGUE_GULD_BUY_BOOKS )
   {
     v1 = pMouse->GetCursorPos(&a2);
     v2 = v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v16)->y];
@@ -7786,7 +7786,7 @@
   pParty->field_709 = 0;
   Party__CountHirelings();
   PrepareHouse((HOUSE_ID)(int)window_SpeakInHouse->ptr_1C);
-  dialog_menu_id = 1;
+  dialog_menu_id = HOUSE_DIALOGUE_MAIN;
 
   pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
   /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
@@ -8772,7 +8772,7 @@
 
 //----- (004B3EF0) --------------------------------------------------------
 void DrawJoinGuildWindow( int pEventCode )
-	{
+{
   uDialogueType = 81;//enum JoinGuildDialog
   ptr_F8B1E8 = (char *)pNPCTopics[pEventCode + 99].pText;
   ContractSelectText(pEventCode);
@@ -8783,7 +8783,7 @@
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
   pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0xAFu, 0x52u, 0, pGlobalTXT_LocalizationStrings[122], 0);
   pDialogueWindow->_41D08F(1, 1, 0, 2);
-  dialog_menu_id = -1;
+  dialog_menu_id = HOUSE_DIALOGUE_OTHER;
 }
 // F8B19C: using guessed type int dword_F8B19C;
 
@@ -8809,7 +8809,7 @@
     v2 = pGlobalTXT_LocalizationStrings[535];
   pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0xAFu, 0x4Fu, 0, v2, 0);
   pDialogueWindow->_41D08F(1, 1, 0, 2);
-  dialog_menu_id = -1;
+  dialog_menu_id = HOUSE_DIALOGUE_OTHER;
 }
 // F8B19C: using guessed type int dword_F8B19C;
 // F8B1A8: using guessed type int dword_F8B1A8;
@@ -8838,7 +8838,7 @@
   pDialogueWindow->CreateButton(  0x1E0u,  30 * v0 + 160,  0x8Cu,  0x1Eu,  1,  0,  0xAFu,  0x4Cu,  0,
     pGlobalTXT_LocalizationStrings[406],  0); //"Hire"
   pDialogueWindow->_41D08F(v0 + 1, 1, 0, 2);
-  dialog_menu_id = -1;
+  dialog_menu_id = HOUSE_DIALOGUE_OTHER;
 }
 
 
@@ -8875,7 +8875,7 @@
   else
   {
     v17 = HouseNPCData[_this + 1 - ((dword_591080 != 0) + 1)];
-    if ( dialog_menu_id == -1 )
+    if ( dialog_menu_id == HOUSE_DIALOGUE_OTHER )
     {
       pDialogueWindow->Release();
     }
@@ -8958,7 +8958,7 @@
       pDialogueWindow->_41D08F(num_menu_buttons, 1, 0, 2);
       dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
     }
-    dialog_menu_id = 1;
+    dialog_menu_id = HOUSE_DIALOGUE_MAIN;
   }
  
 }
@@ -9381,7 +9381,7 @@
     v4 = v3 / 3;
     v32 = v3 / 3;
   }
-  if ( dialog_menu_id != 1 )
+  if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN)
   {
     if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
     {
@@ -9393,7 +9393,7 @@
       //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass][v23 - 36]
       // or
       //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass - 1][v23 + 1]
-
+      __debugbreak(); // whacky condition - fix
       if (false
       //if ( !*(&byte_4ED94C[37 * v1->uClass / 3] + dword_F8B19C)
         || (v6 = (int)(&v1->uIntelligence + dialog_menu_id), *(short *)v6) )
@@ -9620,7 +9620,7 @@
   s1 = v4 * (100 - v1->GetMerchant()) / 100;
   if ( (signed int)s1 < v4 / 3 )
     s1 = v4 / 3;
-  if ( dialog_menu_id == 1 )
+  if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN)
   {
     if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
     {
@@ -9744,7 +9744,7 @@
   }
   else
   {
-    if ( dialog_menu_id > 104 && dialog_menu_id <= 108 )
+    if ( dialog_menu_id > HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RESULT && dialog_menu_id <= HOUSE_DIALOGUE_108 )
     {
       if ( pParty->uNumGold < s1 )
       {
@@ -9843,7 +9843,7 @@
       }
       else
       {
-        dialog_menu_id = 1;
+        dialog_menu_id = HOUSE_DIALOGUE_MAIN;
         pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
       }
     }
--- a/mm7_data.cpp	Sat Mar 23 09:25:31 2013 +0600
+++ b/mm7_data.cpp	Sat Mar 23 09:26:07 2013 +0600
@@ -2251,8 +2251,6 @@
 __int16 word_F8B158[777]; // weak
 struct Texture *ShopTexture; // idb
 struct Texture *ItemsInShopTexture[12];
-int in_current_building_type; // 0xF8B198
-int dialog_menu_id; // weak
 __int16 word_F8B1A0; // weak
 const char *dword_F8B1A4; // idb
 int contract_approved; // weak
--- a/mm7_data.h	Sat Mar 23 09:25:31 2013 +0600
+++ b/mm7_data.h	Sat Mar 23 09:26:07 2013 +0600
@@ -1683,8 +1683,6 @@
 extern __int16 word_F8B158[]; // weak
 extern struct Texture *ShopTexture; // idb
 extern struct Texture *ItemsInShopTexture[12];
-extern int in_current_building_type; // weak
-extern int dialog_menu_id; // weak
 extern __int16 word_F8B1A0; // weak
 extern const char *dword_F8B1A4; // idb
 extern int contract_approved; // weak