changeset 712:e7c86528a2b3

Merge
author Gloval
date Thu, 21 Mar 2013 23:11:54 +0400
parents a5e587c8e30e (current diff) 735dab8d3c9a (diff)
children 9d13d2ec35a6
files Indoor.cpp Texture.cpp Texture.h UIBooks.cpp mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp mm7_data.h
diffstat 25 files changed, 404 insertions(+), 272 deletions(-) [+]
line wrap: on
line diff
--- a/GUIProgressBar.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/GUIProgressBar.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -158,20 +158,20 @@
       Progress();
     }
     free(v1->pLoadingBg.pPixels);
-    v3 = (int)&v1->pLoadingProgress.pLevelOfDetail0;
-    free(v1->pLoadingProgress.pLevelOfDetail0);
+    v3 = (int)&v1->pLoadingProgress.pLevelOfDetail0_prolly_alpha_mask;
+    free(v1->pLoadingProgress.pLevelOfDetail0_prolly_alpha_mask);
     free(v1->pLoadingProgress.pPalette16);
     v1->pLoadingProgress.pPalette16 = 0;
     v1->pLoadingBg.pPixels = 0;
   }
   else
   {
-    if ( !v1->pBardata.pLevelOfDetail0 )
+    if ( !v1->pBardata.pLevelOfDetail0_prolly_alpha_mask )
       return;
-    free(v1->pBardata.pLevelOfDetail0);
+    free(v1->pBardata.pLevelOfDetail0_prolly_alpha_mask);
     v3 = (int)&v1->pBardata.pPalette16;
     free(v1->pBardata.pPalette16);
-    v1->pBardata.pLevelOfDetail0 = 0;
+    v1->pBardata.pLevelOfDetail0_prolly_alpha_mask = 0;
   }
   *(int *)v3 = 0;
 }
@@ -186,7 +186,7 @@
   pRenderer->BeginScene();
   if (uType != TYPE_Fullscreen)
   {
-    if (pBardata.pLevelOfDetail0)
+    if (pBardata.pLevelOfDetail0_prolly_alpha_mask)
     {
       if (pRenderer->pRenderD3D)
       {
--- a/GUIWindow.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/GUIWindow.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -447,7 +447,7 @@
   int i; // esi@28
   char *v14; // ebp@29
   int v15; // eax@31
-  unsigned int v16; // esi@35
+  //unsigned int v16; // esi@35
   Player *v17; // esi@38
   unsigned __int16 v18; // ax@38
   unsigned int v19; // edi@43
@@ -460,7 +460,7 @@
   v1 = this;
   pAudioPlayer->StopChannels(-1, -1);
   InitializeBookFonts();
-  v1->CreateButton(0x1DBu, 0x1BDu, 0x9Eu, 0x22u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], 0);
+  v1->CreateButton(0x1DBu, 0x1BDu, 0x9Eu, 0x22u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], 0); // Close
   pCurrentScreen = SCREEN_BOOKS;
   awards_count2 = 0;
   dword_506528 = 0;
@@ -468,7 +468,7 @@
   awards_count = 0; 
   switch (v1->par1C)
       {
-  case 177:{
+  case WINDOW_Lloyd:{
       byte_506360 = 0;
       pTexture_CurrentBook = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("lb_bordr", TEXTURE_16BIT_PALETTE)];
       pTexture_LloydBeacons[0] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbmap", TEXTURE_16BIT_PALETTE)];
@@ -513,25 +513,31 @@
           while ( (signed int)v20 < 5 );
       }
       break;
-  case 195:
-      {
+
+    case WINDOW_TownPortal:
+    {
       pTexture_CurrentBook = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("townport", TEXTURE_16BIT_PALETTE)];
-      pTexture_TownPortalHarmn = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tpharmndy", TEXTURE_16BIT_PALETTE)];
-      pTexture_TownPortalElf = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tpelf", TEXTURE_16BIT_PALETTE)];
-      pTexture_TownPortalWarlock = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tpwarlock", TEXTURE_16BIT_PALETTE)];
-      pTexture_TownPortalIsland = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tpisland", TEXTURE_16BIT_PALETTE)];
-      pTexture_TownPortalHeaven = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tpheaven", TEXTURE_16BIT_PALETTE)];
-      v16 = 0;
-      pTexture_TownPortalHell = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture( "tphell", TEXTURE_16BIT_PALETTE)];
+
+      pTexture_TownPortalIcons[0] = pIcons_LOD->LoadTexturePtr("tpharmndy", TEXTURE_16BIT_PALETTE);
+      pTexture_TownPortalIcons[1] = pIcons_LOD->LoadTexturePtr("tpelf", TEXTURE_16BIT_PALETTE);
+      pTexture_TownPortalIcons[2] = pIcons_LOD->LoadTexturePtr("tpwarlock", TEXTURE_16BIT_PALETTE);
+      pTexture_TownPortalIcons[3] = pIcons_LOD->LoadTexturePtr("tpisland", TEXTURE_16BIT_PALETTE);
+      pTexture_TownPortalIcons[4] = pIcons_LOD->LoadTexturePtr("tpheaven", TEXTURE_16BIT_PALETTE);
+      pTexture_TownPortalIcons[5] = pIcons_LOD->LoadTexturePtr( "tphell", TEXTURE_16BIT_PALETTE);
+
+      for (uint i = 0; i < 6; ++i)
+        v1->CreateButton(pTownPortalBook_xs[i], pTownPortalBook_ys[i], pTownPortalBook_ws[i], pTownPortalBook_hs[i], 1, 182, 183, i, 0, "", nullptr);
+      /*v16 = 0;
       do
           {
           v1->CreateButton(pTownPortalBook_xs[v16], pTownPortalBook_ys[v16], pTownPortalBook_ws[v16], pTownPortalBook_hs[v16], 1, 182, 0xB7u, v16, 0, "", 0);
           ++v16;
           }
-          while ( (signed int)v16 < 6 );
-      }
-      break;
-  case 200:
+          while ( (signed int)v16 < 6 );*/
+    }
+    break;
+
+  case WINDOW_QuestBook:
       {
       pTexture_CurrentBook = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture( "sbquiknot", TEXTURE_16BIT_PALETTE)];
       pSpellBookPagesTextr_10 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture( "divbar", TEXTURE_16BIT_PALETTE)];
@@ -561,7 +567,7 @@
       awards_count2 = v12;
       }
       break;
-  case 201:
+  case WINDOW_AutonotesBook:
       {
       pTexture_AutonotesBook   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbautnot", TEXTURE_16BIT_PALETTE)];
       pSpellBookPagesTextr_10     = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("divbar", TEXTURE_16BIT_PALETTE)];
@@ -619,7 +625,7 @@
           }
       }
       break;
-  case 202:
+  case WINDOW_MapsBook:
       {
       dword_506364 = 1;
       pSpellBookPagesTextr_12 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbmap", TEXTURE_16BIT_PALETTE)];
@@ -649,7 +655,7 @@
           pGlobalTXT_LocalizationStrings[572], (Texture *)"", 0);// "Scroll Left"
       }
       break;
-  case 203: {
+  case WINDOW_CalendarBook: {
       pSpellBookPagesTextr_13 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbdate-time", TEXTURE_16BIT_PALETTE)];
       pTex_moon_new = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_new", TEXTURE_16BIT_PALETTE)];
       pTex_moon_4   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_4", TEXTURE_16BIT_PALETTE)];
@@ -658,7 +664,7 @@
       pTex_moon_ful = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_ful", TEXTURE_16BIT_PALETTE)];
       }
       break;
-  case 224:
+  case WINDOW_HistoryBook:
       {
       pSpellBookPagesTextr_11 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbplayrnot", TEXTURE_16BIT_PALETTE)];
       pTex_tab_an_6b__zoom_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
--- a/GUIWindow.h	Thu Mar 21 23:10:57 2013 +0400
+++ b/GUIWindow.h	Thu Mar 21 23:11:54 2013 +0400
@@ -54,43 +54,45 @@
   WINDOW_3 = 0x3,
   WINDOW_CharacterRecord = 0x4,
   WINDOW_Options = 0x6,
+  WINDOW_8 = 8,
   WINDOW_Book = 0x9,
   WINDOW_Dialogue = 0xA,
-  WINDOW_QuickReference = 0xC,
+  WINDOW_QuickReference = 12,
   WINDOW_Rest = 0x10,
-  WINDOW_ChangeLocation = 0x11,
+  WINDOW_ChangeLocation = 17,
   WINDOW_SpellBook = 0x12,
-  WINDOW_GreetingNPC = 0x13,
+  WINDOW_GreetingNPC = 19,
   WINDOW_Chest = 0x14,
-  WINDOW_17 = 0x17,
+  WINDOW_17 = 23,
   WINDOW_MainMenu_Load = 0x18,
   WINDOW_HouseInterior = 0x19,
-  WINDOW_Transition = 0x1A,
+  WINDOW_Transition = 26,
   WINDOW_1B = 0x1B,
   WINDOW_Scroll = 0x1E,
-  WINDOW_1F = 0x1F,
+  WINDOW_1F = 31,
   WINDOW_FinalWindow = 0x46,
   WINDOW_50 = 0x50,
   WINDOW_59 = 0x59,
-  WINDOW_5A = 0x5A,
-  WINDOW_5B = 0x5B,
+  WINDOW_5A = 90,
+  WINDOW_5B = 91,
   WINDOW_VoiceSwitcherButton = 0x5C,
   WINDOW_5D = 0x5D,
-  WINDOW_5E = 0x5E,
+  WINDOW_5E = 94,
   WINDOW_5F = 0x5F,
-  WINDOW_60 = 0x60,
+  WINDOW_60 = 96,
   WINDOW_61 = 0x61,
   WINDOW_RestWindow = 0x62,
-  WINDOW_63 = 0x63,
+  WINDOW_63 = 99,
   WINDOW_CharacterWindow_Stats = 0x64,
   WINDOW_CharacterWindow_Skills = 0x65,
   WINDOW_CharacterWindow_Awards = 0x66,
   WINDOW_CharacterWindow_Inventory = 0x67,
+  WINDOW_68 = 104,
   WINDOW_KeyMappingOptions = 0x69,
   WINDOW_VideoOptions = 0x6A,
   WINDOW_Lloyd = 0xB1,
-  WINDOW_TownPortal = 0xC3,
-  WINDOW_QuestBook = 0xC8,
+  WINDOW_TownPortal = 195,
+  WINDOW_QuestBook = 200,
   WINDOW_AutonotesBook = 0xC9,
   WINDOW_MapsBook = 0xCA,
   WINDOW_CalendarBook = 0xCB,
@@ -281,7 +283,7 @@
   UIMSG_C0 = 0xC0,
   UIMSG_C1 = 0xC1,
   UIMSG_C2 = 0xC2,
-  UIMSG_C3 = 0xC3,
+  UIMSG_OnCastTownPortal = 0xC3,
   UIMSG_C4 = 0xC4,
   UIMSG_ShowFinalWindow = 0xC5,
   UIMSG_C6 = 0xC6,
--- a/GameUIs.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/GameUIs.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -222,7 +222,7 @@
   uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE);
   uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
   uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
-  pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_Chest|WINDOW_MainMenu|0x2), 0, 0);
+  pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_17, 0, 0);
   pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 0xBFu, 0x12u, 1, 0, 0xA5u, 0, 0, "", 0);
   pGUIWindow_CurrentMenu->CreateButton(21u, 218u, 0xBFu, 0x12u, 1, 0, 0xA5u, 1u, 0, "", 0);
   pGUIWindow_CurrentMenu->CreateButton(21u, 238u, 0xBFu, 0x12u, 1, 0, 0xA5u, 2u, 0, "", 0);
--- a/Indoor.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/Indoor.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -846,7 +846,7 @@
                 v21 = stru_F8A590._viewport_space_y;
                 a2 = stru_F8A590._viewport_space_y;
                 v110 = v111 * stru_F8A590._viewport_space_y;
-                v97 = v5->pLevelOfDetail0;
+                v97 = v5->pLevelOfDetail0_prolly_alpha_mask;
                 v98 = v5->pLevelOfDetail1;
                 v99 = v5->pLevelOfDetail2;
                 v22 = v5->pLevelOfDetail3;
--- a/LOD.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/LOD.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -2370,15 +2370,15 @@
   strcpy(v5->pName, pContainer);
   pDst = (Texture *)v5->uTextureSize;
   v6 = v5->uDecompressedSize;
-  v5->pLevelOfDetail0 = 0;
+  v5->pLevelOfDetail0_prolly_alpha_mask = 0;
   if ( v6 )
   {
     v7 = operator new(v6);
     v8 = v5->uTextureSize;
-    v5->pLevelOfDetail0 = (unsigned __int8 *)v7;
+    v5->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)v7;
     pContainer = (const char *)operator new(v8);
     fread((void *)pContainer, 1u, (size_t)pDst, File);
-    zlib::MemUnzip(v5->pLevelOfDetail0, &v5->uDecompressedSize, pContainer, v5->uTextureSize);
+    zlib::MemUnzip(v5->pLevelOfDetail0_prolly_alpha_mask, &v5->uDecompressedSize, pContainer, v5->uTextureSize);
     v9 = (void *)pContainer;
     v5->uTextureSize = v5->uDecompressedSize;
     free(v9);
@@ -2387,7 +2387,7 @@
   {
     v10 = (unsigned __int8 *)operator new(0);
     v11 = File;
-    v5->pLevelOfDetail0 = v10;
+    v5->pLevelOfDetail0_prolly_alpha_mask = v10;
     fread(v10, 1u, (size_t)pDst, v11);
   }
   v5->pPalette24 = 0;
@@ -2423,7 +2423,7 @@
   if ( v5->pBits & 2 )
   {
     v14 = v5->uSizeOfMaxLevelOfDetail;
-    v15 = (int)&v5->pLevelOfDetail0[v14];
+    v15 = (int)&v5->pLevelOfDetail0_prolly_alpha_mask[v14];
     v5->pLevelOfDetail1 = (unsigned __int8 *)v15;
     v16 = (v14 >> 2) + v15;
     v5->pLevelOfDetail2 = (unsigned __int8 *)v16;
@@ -2701,7 +2701,7 @@
   v5 = FindContainer(pContainer, 0);
   File = v5;
   if ( v5
-    && (v6 = pDst, pDst->pLevelOfDetail0)
+    && (v6 = pDst, pDst->pLevelOfDetail0_prolly_alpha_mask)
     && mode == 2
     && pDst->pPalette16
     && !pDst->pPalette24
@@ -2715,7 +2715,7 @@
     v10 = &pDst->uDecompressedSize;
     if ( !pDst->uDecompressedSize || v4->dword_011BA4 )
     {
-      fread(pDst->pLevelOfDetail0, 1u, v8, File);
+      fread(pDst->pLevelOfDetail0_prolly_alpha_mask, 1u, v8, File);
     }
     else
     {
@@ -2725,7 +2725,7 @@
       zlib::MemUnzip(Sourcea, &v6->uDecompressedSize, DstBufa, v6->uTextureSize);
       v6->uTextureSize = *v10;
       free(DstBufa);
-      memcpy(v6->pLevelOfDetail0, Sourcea, *v10);
+      memcpy(v6->pLevelOfDetail0_prolly_alpha_mask, Sourcea, *v10);
       free(Sourcea);
     }
     v11 = 0;
@@ -2851,8 +2851,8 @@
   if ( !v8->uDecompressedSize || dword_011BA4 )
   {
     v20 = pAllocator;
-    v32 = pAllocator->AllocNamedChunk(v8->pLevelOfDetail0, v15, v8->pName);
-    v8->pLevelOfDetail0 = (unsigned __int8 *)v32;
+    v32 = pAllocator->AllocNamedChunk(v8->pLevelOfDetail0_prolly_alpha_mask, v15, v8->pName);
+    v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)v32;
     fread(v32, 1u, (size_t)pOutTex, pFile);
   }
   else
@@ -2871,10 +2871,10 @@
       pOutTex = (Texture *)(((signed int)v8->uSizeOfMaxLevelOfDetail >> 2)
                           + ((signed int)v8->uSizeOfMaxLevelOfDetail >> 4)
                           + ((signed int)v8->uSizeOfMaxLevelOfDetail >> 6));
-      v21 = pAllocator->AllocNamedChunk(v8->pLevelOfDetail0, (unsigned int)pOutTex, v8->pName);
+      v21 = pAllocator->AllocNamedChunk(v8->pLevelOfDetail0_prolly_alpha_mask, (unsigned int)pOutTex, v8->pName);
       v22 = (size_t)pOutTex;
       v23 = &pContainer[v8->uTextureWidth * v8->uTextureHeight];
-      v8->pLevelOfDetail0 = (unsigned __int8 *)v21;
+      v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)v21;
       memcpy(v21, v23, v22);
       v8->uTextureWidth = (signed __int16)v8->uTextureWidth >> 1;
       v24 = v8->uTextureWidth;
@@ -2894,9 +2894,9 @@
     {
       v29 = *v16;
       v20 = pAllocator;
-      v30 = pAllocator->AllocNamedChunk(v8->pLevelOfDetail0, v29, v8->pName);
+      v30 = pAllocator->AllocNamedChunk(v8->pLevelOfDetail0_prolly_alpha_mask, v29, v8->pName);
       v31 = v8->uDecompressedSize;
-      v8->pLevelOfDetail0 = (unsigned __int8 *)v30;
+      v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)v30;
       memcpy(v30, pContainer, v31);
     }
     free((void *)pContainer);
@@ -2937,7 +2937,7 @@
   if ( v8->pBits & 2 )
   {
     v34 = v8->uSizeOfMaxLevelOfDetail;
-    v35 = &v8->pLevelOfDetail0[v34];
+    v35 = &v8->pLevelOfDetail0_prolly_alpha_mask[v34];
     v8->pLevelOfDetail1 = v35;
     v36 = &v35[v34 >> 2];
     v8->pLevelOfDetail2 = v36;
--- a/Mouse.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/Mouse.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -929,7 +929,7 @@
   if ( result )
   {
     v5 = a1->pPalette16;
-    v6 = a1->pLevelOfDetail0;
+    v6 = a1->pLevelOfDetail0_prolly_alpha_mask;
     v7 = a1->uTextureWidth;
     v8 = a1->uTextureHeight;
     v9 = Dst.lpSurface;
--- a/Outdoor.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/Outdoor.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -2699,7 +2699,7 @@
     do
     {
       if ( v1 != -1 ? (int)v3 : 0 )
-        v3->uDecompressedSize = v2->pTerrain._47CB57((int)v3->pLevelOfDetail0,
+        v3->uDecompressedSize = v2->pTerrain._47CB57((int)v3->pLevelOfDetail0_prolly_alpha_mask,
                                                       v3->palette_id2,
                                                       v3->uTextureWidth * v3->uTextureHeight);
       ++v1;
--- a/Party.h	Thu Mar 21 23:10:57 2013 +0400
+++ b/Party.h	Thu Mar 21 23:11:54 2013 +0400
@@ -8,7 +8,15 @@
 
 
 
-
+enum PARTY_QUEST_BITS: unsigned __int32
+{
+  PARTY_QUEST_FOUNTAIN_HARMONDALE = 206,
+  PARTY_QUEST_FOUNTAIN_NIGHON = 207,
+  PARTY_QUEST_FOUNTAIN_PIERPONT = 208,
+  PARTY_QUEST_FOUNTAIN_CELESTIA = 209,
+  PARTY_QUEST_FOUNTAIN_THE_PIT = 210,
+  PARTY_QUEST_FOUNTAIN_EVENMORN_ISLE = 211
+};
 
 
 
--- a/Player.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/Player.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -6515,6 +6515,9 @@
           spellbook.pWaterSpellbook.bIsSpellAvailable[3] = true;
           spellbook.pWaterSpellbook.bIsSpellAvailable[4] = true;
           spellbook.pWaterSpellbook.bIsSpellAvailable[5] = true;
+          spellbook.pWaterSpellbook.bIsSpellAvailable[6] = true;
+          spellbook.pWaterSpellbook.bIsSpellAvailable[7] = true;
+          spellbook.pWaterSpellbook.bIsSpellAvailable[8] = true;
         break;
       case PLAYER_SKILL_AIR:    spellbook.pAirSpellbook.bIsSpellAvailable[0] = true;    break;
       case PLAYER_SKILL_WATER:  spellbook.pWaterSpellbook.bIsSpellAvailable[0] = true;  break;
--- a/Render.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/Render.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -841,7 +841,7 @@
     v16 = v42 + ((unsigned __int64)(v3->ptr_38->field_10 * (signed __int64)v10) >> 16);
     v17 = v40 + ((unsigned __int64)(v3->ptr_38->field_1C * (signed __int64)v10) >> 16);
     v18 = v15 / v52;
-    v43 = v3->pTexture->pLevelOfDetail0;
+    v43 = v3->pTexture->pLevelOfDetail0_prolly_alpha_mask;
     v19 = v3->sTextureDeltaU + ((signed int)((unsigned __int64)(v16 * v15 / v52) >> 16) >> 3);
     v56 = v15 / v52;
     v20 = v3->sTextureDeltaV + ((signed int)((unsigned __int64)(v17 * v15 / v52) >> 16) >> 3);
@@ -9662,7 +9662,7 @@
   if ( this->uNumSceneBegins && a4 && a4->pPalette16 )
   {
     v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
-    v20 = a4->pLevelOfDetail0;
+    v20 = a4->pLevelOfDetail0_prolly_alpha_mask;
     v5 = a4->uTextureWidth;
     v6 = a4->uTextureHeight;
     v19 = a4->uTextureWidth;
@@ -10131,7 +10131,7 @@
       {
         v5 = pTexture->uTextureHeight;
         v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
-        v19 = pTexture->pLevelOfDetail0;
+        v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask;
         v20 = pTexture->uTextureWidth;
         v18 = pTexture->uTextureWidth;
         if ( this->bClip )
@@ -10241,7 +10241,7 @@
       {
         v5 = a4->uTextureHeight;
         v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
-        v19 = a4->pLevelOfDetail0;
+        v19 = a4->pLevelOfDetail0_prolly_alpha_mask;
         v20 = a4->uTextureWidth;
         v18 = a4->uTextureWidth;
         if ( this->bClip )
@@ -10344,7 +10344,7 @@
   if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 )
   {
     v8 = &this->pTargetSurface[x + y * this->uTargetSurfacePitch];
-    v24 = a4->pLevelOfDetail0;
+    v24 = a4->pLevelOfDetail0_prolly_alpha_mask;
     v27 = a4->uTextureWidth;
     v9 = a4->uTextureHeight;
     v22 = a4->uTextureWidth;
@@ -10462,7 +10462,7 @@
           if ( a5->pPalette16 )
           {
             v10 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
-            v28 = a4->pLevelOfDetail0;
+            v28 = a4->pLevelOfDetail0_prolly_alpha_mask;
             v25 = v8->uTextureWidth;
             v24 = v8->uTextureHeight;
             v22 = v8->uTextureWidth;
@@ -10518,7 +10518,7 @@
                 {
                   if ( *v28 )
                   {
-                    v20 = *(&v9->pLevelOfDetail0[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1));
+                    v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1));
                     if ( v20 >= a7 )
                     {
                       if ( v20 <= a8 )
@@ -10581,7 +10581,7 @@
       {
         uHeight = pTexture->uTextureHeight;
         v6 = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch];
-        v19 = pTexture->pLevelOfDetail0;
+        v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask;
         uWidth = pTexture->uTextureWidth;
         v18 = pTexture->uTextureWidth;
         if ( this->bClip )
@@ -10658,7 +10658,7 @@
 
 
 //----- (004A612A) --------------------------------------------------------
-void Render::_4A612A(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal)
+void Render::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal)
 {
   Texture *v5; // eax@2
   unsigned int v6; // edx@3
@@ -10688,7 +10688,7 @@
       v6 = uOutY;
       v7 = pTexture->uTextureHeight;
       pZBuffer = &this->pActiveZBuffer[uOutX + 640 * uOutY];
-      uOutYa = v5->pLevelOfDetail0;
+      uOutYa = v5->pLevelOfDetail0_prolly_alpha_mask;
       v8 = v5->uTextureWidth;
       v20 = v5->uTextureWidth;
       v19 = v5->uTextureWidth;
@@ -10877,7 +10877,7 @@
       {
         v5 = a4->uTextureHeight;
         pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch];
-        v19 = a4->pLevelOfDetail0;
+        v19 = a4->pLevelOfDetail0_prolly_alpha_mask;
         v20 = a4->uTextureWidth;
         v18 = a4->uTextureWidth;
         if ( this->bClip )
--- a/Render.h	Thu Mar 21 23:10:57 2013 +0400
+++ b/Render.h	Thu Mar 21 23:11:54 2013 +0400
@@ -344,7 +344,7 @@
   void _4A5D33(unsigned int a2, unsigned int a3, int a4, int a5, RGBTexture *pTexture);
   void DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4);
   void _4A601E(signed int a2, signed int a3, Texture *pTexture, int a5);
-  void _4A612A(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal);
+  void DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal);
   void DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture);
   void _4A63E6(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8);
   void _4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8);
--- a/Texture.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/Texture.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -42,12 +42,12 @@
 Texture *pTex_tab_an_6a__zoom_off;
 Texture *pTex_tab_an_7b__zoot_on;
 Texture *pTex_tab_an_6b__zoom_on;
-Texture *pTexture_TownPortalHarmn;
-Texture *pTexture_TownPortalElf;
-Texture *pTexture_TownPortalWarlock;
-Texture *pTexture_TownPortalIsland;
-Texture *pTexture_TownPortalHeaven;
-Texture *pTexture_TownPortalHell;
+Texture *pTexture_TownPortalIcons[6]; // [0]Harmonale, [1]Pierpont, [2]Nighon, [3]Evenmorn Island, [4]Celestia, [5]The Pit
+//Texture *pTexture_TownPortalElf;
+//Texture *pTexture_TownPortalWarlock;
+//Texture *pTexture_TownPortalIsland;
+//Texture *pTexture_TownPortalHeaven;
+//Texture *pTexture_TownPortalHell;
 Texture *dword_5063D8[12];
 Texture *dword_506408[12];
 Texture *pTexture_50643C; // idb
@@ -383,7 +383,7 @@
   pSource = this;
   v1 = this;
   v2 = malloc(this->uDecompressedSize);
-  zlib::MemUnzip(v2, (unsigned int *)&pSource, v1->pLevelOfDetail0, v1->uTextureSize);
+  zlib::MemUnzip(v2, (unsigned int *)&pSource, v1->pLevelOfDetail0_prolly_alpha_mask, v1->uTextureSize);
   return v2;
 }
 
@@ -396,12 +396,12 @@
 
     if (pBits & 0x0400)
     {
-      pAllocator->FreeChunk(pLevelOfDetail0);
+      pAllocator->FreeChunk(pLevelOfDetail0_prolly_alpha_mask);
       pAllocator->FreeChunk(pPalette16);
       pAllocator->FreeChunk(pPalette24);
     }
 
-    pLevelOfDetail0 = nullptr;
+    pLevelOfDetail0_prolly_alpha_mask = nullptr;
     pLevelOfDetail1 = nullptr;
     pLevelOfDetail2 = nullptr;
     pLevelOfDetail3 = nullptr;
@@ -503,7 +503,7 @@
   uWidthLn2 = 0;
   palette_id1 = 0;
   palette_id2 = 0;
-  pLevelOfDetail0 = 0;
+  pLevelOfDetail0_prolly_alpha_mask = 0;
   pLevelOfDetail3 = 0;
   pLevelOfDetail2 = 0;
   pLevelOfDetail1 = 0;
--- a/Texture.h	Thu Mar 21 23:10:57 2013 +0400
+++ b/Texture.h	Thu Mar 21 23:11:54 2013 +0400
@@ -51,7 +51,7 @@
   short palette_id2;
   unsigned int uDecompressedSize;
   int pBits;
-  unsigned __int8 *pLevelOfDetail0;
+  unsigned __int8 *pLevelOfDetail0_prolly_alpha_mask;
   unsigned __int8 *pLevelOfDetail1;
   unsigned __int8 *pLevelOfDetail2;
   unsigned __int8 *pLevelOfDetail3;
@@ -144,12 +144,12 @@
 extern Texture *pTex_tab_an_6a__zoom_off;
 extern Texture *pTex_tab_an_7b__zoot_on;
 extern Texture *pTex_tab_an_6b__zoom_on;
-extern Texture *pTexture_TownPortalHarmn;
-extern Texture *pTexture_TownPortalElf;
-extern Texture *pTexture_TownPortalWarlock;
-extern Texture *pTexture_TownPortalIsland;
-extern Texture *pTexture_TownPortalHeaven;
-extern Texture *pTexture_TownPortalHell;
+extern Texture *pTexture_TownPortalIcons[]; // [0]Harmonale, [1]Pierpont, [2]Nighon, [3]Evenmorn Island, [4]Celestia, [5]The Pit
+//extern Texture *pTexture_TownPortalElf;
+//extern Texture *pTexture_TownPortalWarlock;
+//extern Texture *pTexture_TownPortalIsland;
+//extern Texture *pTexture_TownPortalHeaven;
+//extern Texture *pTexture_TownPortalHell;
 extern Texture *dword_5063D8[];
 extern Texture *dword_506408[];
 extern Texture *pTexture_50643C; // idb
--- a/UIBooks.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/UIBooks.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -234,7 +234,7 @@
             v23 = dword_506408[v4];
             v6 = v5;
           }
-          if ( v6->pLevelOfDetail0 )
+          if ( v6->pLevelOfDetail0_prolly_alpha_mask )
           {
 			v7 = v0->lastOpenedSpellbookPage;
            // v7 =  (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v4]);
@@ -244,7 +244,7 @@
               pRenderer->DrawTextureTransparent(v17, v19, v6);
             else
               pRenderer->DrawTextureIndexed(v17, v19, v6);
-            pRenderer->_4A612A(pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Xpos,
+            pRenderer->DrawMaskToZBuffer(pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Xpos,
 				               pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Ypos, v23, v4);
           }
         }
@@ -258,7 +258,7 @@
   if ( v10 )
   {
     v11 = dword_5063D8[v10];
-    if ( v11->pLevelOfDetail0 )
+    if ( v11->pLevelOfDetail0_prolly_alpha_mask )
     {
       v21 = dword_5063D8[v10];
 	  v12 = v0->lastOpenedSpellbookPage;
@@ -1157,7 +1157,7 @@
         screenWidth = br_x - tl_x + 1;
         screenHeight = br_y - tl_y + 1;
         render16_data = &pRenderer->pTargetSurface[tl_x + tl_y * surfPitch];
-        texture8_data = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0;
+        texture8_data = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0_prolly_alpha_mask;
         pPalette_16 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
         scale_increment = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / v5;
 
--- a/UICharacter.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/UICharacter.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -1491,7 +1491,7 @@
                     }
 LABEL_57:
                 if ( !bRingsShownInCharScreen )
-                    pRenderer->_4A612A(v24, a3b, v27, v230);
+                    pRenderer->DrawMaskToZBuffer(v24, a3b, v27, v230);
 LABEL_59:
                 v31 = pPlayer->pEquipment.uCloak;// ïîòîì ïëàù
                 if ( !v31 )
@@ -1540,7 +1540,7 @@
                                     pRenderer->DrawTextureTransparent(a2c, v36, v42);
                                     }
                                 if ( !bRingsShownInCharScreen )
-                                    pRenderer->_4A612A(a2c, a3c, v42, v231);
+                                    pRenderer->DrawMaskToZBuffer(a2c, a3c, v42, v231);
 LABEL_93:
                                 v240 = 4 * uPlayerID_ - 4;
                                 pRenderer->DrawTextureTransparent(pPaperdoll_BodyX, pPaperdoll_BodyY,
@@ -1602,7 +1602,7 @@
                                                             }
                                                         }
                                                     if ( !bRingsShownInCharScreen )
-                                                        pRenderer->_4A612A(a2d, a3d, v54, v232);
+                                                        pRenderer->DrawMaskToZBuffer(a2d, a3d, v54, v232);
 LABEL_127:
                                                     v56 = pPlayer->pEquipment.field_20;
                                                     if ( !v56 )
@@ -1667,7 +1667,7 @@
                                                                 }
                                                             }
                                                         if ( !bRingsShownInCharScreen )
-                                                            pRenderer->_4A612A(a2e, a3e, v67, v233);
+                                                            pRenderer->DrawMaskToZBuffer(a2e, a3e, v67, v233);
 LABEL_155:
                                                         v69 = pPlayer->pEquipment.uMainHand;
                                                         uPlayerID_a = 2 * pBodyComplection;
@@ -1729,7 +1729,7 @@
                                                                             }
                                                                         }
                                                                     if ( !bRingsShownInCharScreen )
-                                                                        pRenderer->_4A612A(a2f, a3f, v81, v234);
+                                                                        pRenderer->DrawMaskToZBuffer(a2f, a3f, v81, v234);
                                                                     goto LABEL_192;
                                                                     }
                                                                 if ( (*(int *)&pPlayer->field_1F5[36 * v71 + 15] & 0xF0) != 16 )
@@ -2000,7 +2000,7 @@
                                                                                                         }
                                                                                                     }
                                                                                                 if ( !bRingsShownInCharScreen )
-                                                                                                    pRenderer->_4A612A(a2j, a3i, v133, v237);
+                                                                                                    pRenderer->DrawMaskToZBuffer(a2j, a3i, v133, v237);
 LABEL_335:
                                                                                                 v134 = pPlayer->pEquipment.uMainHand;
                                                                                                 if ( !v134 )
@@ -2041,7 +2041,7 @@
                                                                                                             }
                                                                                                         }
                                                                                                     if ( !bRingsShownInCharScreen )
-                                                                                                        pRenderer->_4A612A(a2k, a3j, v144, v238);
+                                                                                                        pRenderer->DrawMaskToZBuffer(a2k, a3j, v144, v238);
 LABEL_358:
                                                                                                     v145 = pPlayer->pEquipment.uOffHand;
                                                                                                     v249 = pPlayer->pEquipment.uOffHand;
@@ -2102,7 +2102,7 @@
                                                                                                                         }
                                                                                                                     }
                                                                                                                 if ( !bRingsShownInCharScreen )
-                                                                                                                    pRenderer->_4A612A(v150, a3k, v159, v249);
+                                                                                                                    pRenderer->DrawMaskToZBuffer(v150, a3k, v159, v249);
                                                                                                                 if ( v245 )
                                                                                                                     pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdollLeftEmptyHand[uPlayerID_a],
                                                                                                                     pPaperdoll_BodyY + pPaperdollLeftEmptyHand[uPlayerID_a + 1],
@@ -2296,7 +2296,7 @@
                                                                                                 pRenderer->DrawTextureTransparent(a2h, a3h, v121);
                                                                                                 }
                                                                                             if ( !bRingsShownInCharScreen )
-                                                                                                pRenderer->_4A612A(a2h, a3h, v121, v236);
+                                                                                                pRenderer->DrawMaskToZBuffer(a2h, a3h, v121, v236);
                                                                                             goto LABEL_292;
                                                                                             }
                                                                                         if ( (*(int *)(v225 + 20) & 0xF0) != 16 )
@@ -2484,7 +2484,7 @@
                                                                                 v163 = a2g;
                                                                                 v100->DrawTransparentRedShade(v163, v175, v188);
                                                                                 if ( !bRingsShownInCharScreen )
-                                                                                    pRenderer->_4A612A(a2g, a3g, v101, v235);
+                                                                                    pRenderer->DrawMaskToZBuffer(a2g, a3g, v101, v235);
                                                                                 goto LABEL_259;
                                                                                 }
                                                                             if ( *(char *)(v242 + 516) & 1 )
@@ -2495,7 +2495,7 @@
                                                                                 v164 = a2g;
                                                                                 pRenderer->DrawTextureTransparent(v164, v176, v189);
                                                                                 if ( !bRingsShownInCharScreen )
-                                                                                    pRenderer->_4A612A(a2g, a3g, v101, v235);
+                                                                                    pRenderer->DrawMaskToZBuffer(a2g, a3g, v101, v235);
                                                                                 goto LABEL_259;
                                                                                 }
                                                                             v101 = (Texture *)(v98 != 0 ? (int)v99 : 0);
@@ -2504,7 +2504,7 @@
                                                                             v165 = a2g;
                                                                             pRenderer->DrawTransparentGreenShade(v165, v177, v190);
                                                                             if ( !bRingsShownInCharScreen )
-                                                                                pRenderer->_4A612A(a2g, a3g, v101, v235);
+                                                                                pRenderer->DrawMaskToZBuffer(a2g, a3g, v101, v235);
                                                                             goto LABEL_259;
                                                                             }
                                                                         v102 = 17 * pBodyComplection + v90;
@@ -2530,7 +2530,7 @@
                                                                                 v100 = pRenderer;
                                                                                 v100->DrawTransparentRedShade(v163, v175, v188);
                                                                                 if ( !bRingsShownInCharScreen )
-                                                                                    pRenderer->_4A612A(a2g, a3g, v101, v235);
+                                                                                    pRenderer->DrawMaskToZBuffer(a2g, a3g, v101, v235);
                                                                                 goto LABEL_259;
                                                                                 }
                                                                             if ( v224 & 1 )
@@ -2542,7 +2542,7 @@
                                                                                 v100 = pRenderer;
                                                                                 pRenderer->DrawTextureTransparent(v164, v176, v189);
                                                                                 if ( !bRingsShownInCharScreen )
-                                                                                    pRenderer->_4A612A(a2g, a3g, v101, v235);
+                                                                                    pRenderer->DrawMaskToZBuffer(a2g, a3g, v101, v235);
                                                                                 goto LABEL_259;
                                                                                 }
                                                                             v101 = (Texture *)(v109 != 0 ? (int)v110 : 0);
@@ -2552,7 +2552,7 @@
                                                                             v100 = pRenderer;
                                                                             pRenderer->DrawTransparentGreenShade(v165, v177, v190);
                                                                             if ( !bRingsShownInCharScreen )
-                                                                                pRenderer->_4A612A(a2g, a3g, v101, v235);
+                                                                                pRenderer->DrawMaskToZBuffer(a2g, a3g, v101, v235);
                                                                             goto LABEL_259;
                                                                             }
                                                                         v106 = v105 - 16;
@@ -2953,7 +2953,7 @@
         pRenderer->DrawTextureTransparent(pPaperdoll_BodyX, pPaperdoll_BodyY,
             (Texture *)(*(unsigned int *)((char *)papredoll_dbods + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dbods + v240)] : 0));
         if ( !bRingsShownInCharScreen )
-            pRenderer->_4A612A(a2, a3,
+            pRenderer->DrawMaskToZBuffer(a2, a3,
             (Texture *)(*(unsigned int *)((char *)papredoll_dbods + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dbods + v240)] : 0),
             pPlayer->pEquipment.uBody);
         uPlayerID_a = 2 * pBodyComplection;
@@ -3069,7 +3069,7 @@
                     }
                 }
             if ( !bRingsShownInCharScreen )
-                pRenderer->_4A612A(a2a, a3a, v20, v229);
+                pRenderer->DrawMaskToZBuffer(a2a, a3a, v20, v229);
             }
 LABEL_393:
         pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_RightHand[uPlayerID_a],
--- a/UiGame.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/UiGame.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -1586,7 +1586,7 @@
   if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
   {
     v17 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2;
-    auto pMapLod0 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0;
+    auto pMapLod0 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0_prolly_alpha_mask;
     auto pPal = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
     v73 = (1 << (v17 + 16)) / (signed int)uZoom;
     v18 = (double)(1 << (16 - v17));
--- a/mm7_1.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/mm7_1.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -738,7 +738,7 @@
   bRingsShownInCharScreen = 0;
   CharacterUI_LoadPaperdollTextures();
   pCurrentScreen = SCREEN_CASTING;
-  v2 = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|WINDOW_Options), v1, 0);
+  v2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_1F, v1, 0);
   pCharacterScreen_ExitBtn = v2->CreateButton(
                  394u,
                  318u,
@@ -749,7 +749,7 @@
                  0xA8u,
                  0,
                  0,
-                 pGlobalTXT_LocalizationStrings[79],
+                 pGlobalTXT_LocalizationStrings[79], // Close
                  (Texture *)(papredoll_dbrds[2] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[2]] : 0),
                  papredoll_dbrds[1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[1]] : 0,
                  0);
--- a/mm7_2.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/mm7_2.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -11102,7 +11102,7 @@
     if ( a1 <= 782 )
     {
       uTextureID_720980 = pIcons_LOD->LoadTexture("leather", TEXTURE_16BIT_PALETTE);
-      pGUIWindow_ScrollWindow = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)30, v1 - 700, 0);
+      pGUIWindow_ScrollWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Scroll, v1 - 700, 0);
     }
   }
 }
--- a/mm7_3.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/mm7_3.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -8254,7 +8254,7 @@
   }
   else
   {
-    v19 = (unsigned __int16 *)v18->pLevelOfDetail0;
+    v19 = (unsigned __int16 *)v18->pLevelOfDetail0_prolly_alpha_mask;
   }
   a1.pTextureLOD = v19;
   X = (unsigned __int64)(v36 * (signed __int64)v38) >> 16;
@@ -8458,7 +8458,7 @@
   {
     v19 = v3->pTexture;
     v84 = 0;
-    v18 = (unsigned __int16 *)v19->pLevelOfDetail0;
+    v18 = (unsigned __int16 *)v19->pLevelOfDetail0_prolly_alpha_mask;
   }
   a1.pTextureLOD = v18;
 LABEL_16:
@@ -8914,7 +8914,7 @@
   {
     v22 = v5->pTexture;
     v75 = 0;
-    v21 = (unsigned __int16 *)v22->pLevelOfDetail0;
+    v21 = (unsigned __int16 *)v22->pLevelOfDetail0_prolly_alpha_mask;
   }
   a1.pTextureLOD = v21;
 LABEL_12:
@@ -9171,7 +9171,7 @@
   {
     v20 = v3->pTexture;
     v44 = 0;
-    v21 = (unsigned __int16 *)v20->pLevelOfDetail0;
+    v21 = (unsigned __int16 *)v20->pLevelOfDetail0_prolly_alpha_mask;
 LABEL_11:
     a1.pTextureLOD = v21;
     goto LABEL_12;
@@ -9347,7 +9347,7 @@
   if ( v17 < mipmapping_terrain_mm1 << 16 )
   {
     v20 = 0;
-    v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail0;
+    v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail0_prolly_alpha_mask;
 LABEL_11:
     v35.pTextureLOD = v21;
     goto LABEL_12;
@@ -9572,7 +9572,7 @@
   else
   {
     v16 = 0;
-    v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail0;
+    v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail0_prolly_alpha_mask;
   }
   sr.pTextureLOD = v17;
 LABEL_14:
@@ -9922,7 +9922,7 @@
   {
     v21 = v5->pTexture;
     v49 = 0;
-    pLOD = v21->pLevelOfDetail0;
+    pLOD = v21->pLevelOfDetail0_prolly_alpha_mask;
   }
   a1a.pTextureLOD = (unsigned __int16 *)pLOD;
 LABEL_12:
@@ -12512,7 +12512,7 @@
     sprintf(sHouseName, pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v1].pName);// "Leave %s"
   else
     strcpy(sHouseName, pGlobalTXT_LocalizationStrings[79]);// "Exit"
-  result = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)17, 0, (int)sHouseName);
+  result = GUIWindow::Create(0, 0, 640, 480, WINDOW_ChangeLocation, 0, (int)sHouseName);
   pDialogueWindow = result;
   return result;
 }
@@ -12677,7 +12677,7 @@
     dword_5C3418 = v4;
     dword_5C341C = v3;
     _591094_decoration = activeLevelDecoration;
-    pGUIWindow2 = GUIWindow::Create(0, 0, 640u, 480u, (enum WindowType)19, a4, 0);
+    pGUIWindow2 = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_GreetingNPC, a4, 0);
     pGUIWindow2->CreateButton(61u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
     pGUIWindow2->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
     pGUIWindow2->CreateButton(292u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
--- a/mm7_4.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/mm7_4.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -6089,7 +6089,7 @@
               a2 = stru_F8A590._viewport_space_y;
               v11 = stru_F8A590._viewport_space_y * pRenderer->uTargetSurfacePitch;
               v99 = 640 * stru_F8A590._viewport_space_y;
-              v86 = v4->pLevelOfDetail0;
+              v86 = v4->pLevelOfDetail0_prolly_alpha_mask;
               v87 = v4->pLevelOfDetail1;
               v88 = v4->pLevelOfDetail2;
               v89 = v4->pLevelOfDetail3;
@@ -6571,7 +6571,7 @@
           v49 = v4->uWidthMinus1;
           v47 = v4->uHeightMinus1 << 16;
           v9 = 16 - v4->uWidthLn2;
-          v10 = v4->pLevelOfDetail0;
+          v10 = v4->pLevelOfDetail0_prolly_alpha_mask;
           LOBYTE(v2->uAttributes) |= 0x80u;
           v48 = v9;
           v50 = v10;
@@ -10997,7 +10997,7 @@
 LABEL_19:
   strcpy(sHouseName, v21);
 LABEL_20:
-  pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)26, 0, (int)sHouseName);
+  pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Transition, 0, (int)sHouseName);
   //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * v9]].field_C) )
   if ( pAnimatedRooms[p2DEvents[v9 - 1].uAnimationID].uRoomSoundId )
     HousePlaySomeSound(v9, 1);
--- a/mm7_5.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/mm7_5.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -214,7 +214,7 @@
   enum WindowType pWindowType2; // [sp-8h] [bp-604h]@121
   const char *v146; // [sp-8h] [bp-604h]@449
   unsigned int v147; // [sp-8h] [bp-604h]@550
-  int v148; // [sp-4h] [bp-600h]@56
+  //int v148; // [sp-4h] [bp-600h]@56
   GUIButton *pButton2; // [sp-4h] [bp-600h]@59
   const char *v150; // [sp-4h] [bp-600h]@86
   unsigned int v151; // [sp-4h] [bp-600h]@107
@@ -228,7 +228,7 @@
   __int16 v159; // [sp-4h] [bp-600h]@550
   int v160; // [sp-4h] [bp-600h]@599
   const char *v161; // [sp-4h] [bp-600h]@637
-  int v162; // [sp+0h] [bp-5FCh]@56
+  //int v162; // [sp+0h] [bp-5FCh]@56
   int v163; // [sp+0h] [bp-5FCh]@59
   Texture *pTexture; // [sp+0h] [bp-5FCh]@86
   int v165; // [sp+0h] [bp-5FCh]@107
@@ -461,25 +461,25 @@
           pIcons_LOD->_4114F2();
           pGUIWindow_CurrentMenu->Release();
           pCurrentScreen = SCREEN_OPTIONS;
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (WindowType)8, 0, 0);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_8, 0, 0);
           continue;
         case UIMSG_ArrowUp:
           --pSaveListPosition;
           if ( pSaveListPosition < 0 )
             pSaveListPosition = 0;
-          GUIWindow::Create(215, 199, 17, 17, (WindowType)90, (int)pBtnArrowUp, 0);
+          GUIWindow::Create(215, 199, 17, 17, WINDOW_5A, (int)pBtnArrowUp, 0);
           continue;
         case UIMSG_DownArrow:
           ++pSaveListPosition;
           if ( pSaveListPosition >= uMessageParam )
             pSaveListPosition = uMessageParam - 1;
-          GUIWindow::Create(215, 323, 17, 17, (WindowType)90, (int)pBtnDownArrow, 0);
+          GUIWindow::Create(215, 323, 17, 17, WINDOW_5A, (int)pBtnDownArrow, 0);
           continue;
         case UIMSG_Cancel:
-          GUIWindow::Create(350, 302, 106, 42, (WindowType)96, (int)pBtnCancel, 0);
+          GUIWindow::Create(350, 302, 106, 42, WINDOW_60, (int)pBtnCancel, 0);
           continue;
         case UIMSG_LoadSlot:
-          GUIWindow::Create(241, 302, 106, 42, (WindowType)94, (int)pBtnLoadSlot, 0);
+          GUIWindow::Create(241, 302, 106, 42, WINDOW_5E, (int)pBtnLoadSlot, 0);
           continue;
         case UIMSG_SelectLoadSlot:
           if ( pGUIWindow_CurrentMenu->field_40 == v0 )
@@ -763,7 +763,7 @@
             }
             v19 = (double)(signed int)uGammaPos * 0.1 + 0.6;
             pGame->pGammaController->Initialize(v19);
-            GUIWindow::Create(21, 161, 0, 0, (WindowType)90, (int)pBtn_SliderLeft, v0);
+            GUIWindow::Create(21, 161, 0, 0, WINDOW_5A, (int)pBtn_SliderLeft, v0);
             pAudioPlayer->PlaySound((SoundID)21, 0, 0, -1, 0, 0, 0, 0);
             continue;
           }
@@ -774,7 +774,7 @@
             {
               v21 = (double)(signed int)uGammaPos * 0.1 + 0.6;
               pGame->pGammaController->Initialize(v21);
-              GUIWindow::Create(213, 161, 0, 0, (WindowType)90, (int)pBtn_SliderRight, v0);
+              GUIWindow::Create(213, 161, 0, 0, WINDOW_5A, (int)pBtn_SliderRight, v0);
               pAudioPlayer->PlaySound((SoundID)21, 0, 0, -1, 0, 0, 0, 0);
               continue;
             }
@@ -803,7 +803,7 @@
             --uMusicVolimeMultiplier;
             if ( (char)uMusicVolimeMultiplier < 1 )
               uMusicVolimeMultiplier = 0;
-            GUIWindow::Create(243, 0xD8u, 0, 0, (enum WindowType)90, (int)pBtn_SliderLeft, v0);
+            GUIWindow::Create(243, 0xD8u, 0, 0, WINDOW_5A, (int)pBtn_SliderLeft, v0);
             if ( uMusicVolimeMultiplier )
               pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0, pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0f, 0);
             pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0f);
@@ -814,7 +814,7 @@
             ++uMusicVolimeMultiplier;
             if ( (char)uMusicVolimeMultiplier > 9 )
               uMusicVolimeMultiplier = 9;
-            GUIWindow::Create(435, 0xD8u, 0, 0, (enum WindowType)90, (int)pBtn_SliderRight, v0);
+            GUIWindow::Create(435, 0xD8u, 0, 0, WINDOW_5A, (int)pBtn_SliderRight, v0);
             if ( uMusicVolimeMultiplier )
               pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0, pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0f, 0);
             pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0f);
@@ -833,7 +833,7 @@
             --uSoundVolumeMultiplier;
             if ( (char)uSoundVolumeMultiplier < 1 )
               uSoundVolumeMultiplier = 0;
-            GUIWindow::Create(243, 162, 0, 0, (enum WindowType)90, (int)pBtn_SliderLeft, v0);
+            GUIWindow::Create(243, 162, 0, 0, WINDOW_5A, (int)pBtn_SliderLeft, v0);
             pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f);
             pAudioPlayer->PlaySound((SoundID)218, -1, 0, -1, 0, 0, 0, 0);
             continue;
@@ -846,7 +846,7 @@
             v168 = v0;
             v24 = 435;
             v154 = (int)pBtn_SliderRight;
-            GUIWindow::Create(v24, 0xA2u, 0, 0, (enum WindowType)90, v154, v168);
+            GUIWindow::Create(v24, 0xA2u, 0, 0, WINDOW_5A, v154, v168);
             pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f);
             pAudioPlayer->PlaySound((SoundID)218, -1, 0, -1, 0, 0, 0, 0);
             continue;
@@ -875,7 +875,7 @@
             --uVoicesVolumeMultiplier;
             if ( (char)uVoicesVolumeMultiplier < 1 )
               uVoicesVolumeMultiplier = 0;
-            GUIWindow::Create(243, 270, 0, 0, (enum WindowType)90, (int)pBtn_SliderLeft, v0);
+            GUIWindow::Create(243, 270, 0, 0, WINDOW_5A, (int)pBtn_SliderLeft, v0);
             if ( !uVoicesVolumeMultiplier )
               continue;
             pAudioPlayer->PlaySound((SoundID)5788, -1, 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0);
@@ -886,7 +886,7 @@
             ++uVoicesVolumeMultiplier;
             if ( (char)uVoicesVolumeMultiplier > 8 )
               uVoicesVolumeMultiplier = 9;
-            GUIWindow::Create(435, 270, 0, 0, (enum WindowType)90, (int)pBtn_SliderRight, v0);
+            GUIWindow::Create(435, 270, 0, 0, WINDOW_5A, (int)pBtn_SliderRight, v0);
             if ( !uVoicesVolumeMultiplier )
               continue;
             pAudioPlayer->PlaySound((SoundID)5788, -1, 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0);
@@ -943,7 +943,7 @@
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
-          pBooksWindow = GUIWindow::Create(493u, 355u, 0, 0, (enum WindowType)99, (int)pBtn_Quests, 0);
+          pBooksWindow = GUIWindow::Create(493u, 355u, 0, 0, WINDOW_63, (int)pBtn_Quests, 0);
           bFlashQuestBook = 0;
           continue;
         case UIMSG_OpenAutonotes:
@@ -954,7 +954,7 @@
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
-          pBooksWindow = GUIWindow::Create(527u, 353u, 0, 0, (enum WindowType)99, (int)pBtn_Autonotes, 0);
+          pBooksWindow = GUIWindow::Create(527u, 353u, 0, 0, WINDOW_63, (int)pBtn_Autonotes, 0);
           bFlashAutonotesBook = 0;
           continue;
         case UIMSG_OpenMapBook:
@@ -977,7 +977,7 @@
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, uMessage, 0);
-          pBooksWindow = GUIWindow::Create(570, 354, 0, 0, (enum WindowType)99, (int)pBtn_Calendar, 0);
+          pBooksWindow = GUIWindow::Create(570, 354, 0, 0, WINDOW_63, (int)pBtn_Calendar, 0);
           continue;
         case UIMSG_OpenHistoryBook:
           if ( pMessageQueue_50CBD0->uNumMessages )
@@ -987,7 +987,7 @@
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, uMessage, 0);
-          pBooksWindow = GUIWindow::Create(0x258u, 0x169u, 0, 0, (enum WindowType)99, (int)pBtn_History, 0);
+          pBooksWindow = GUIWindow::Create(0x258u, 0x169u, 0, 0, WINDOW_63, (int)pBtn_History, 0);
           bFlashHistoryBook = 0;
           continue;
         case UIMSG_Escape:// íàæàòèå Escape and return to game
@@ -1496,14 +1496,14 @@
             if ( !pGUIWindow_Settings )//Draw Menu
             {
               dword_6BE138 = -1;
-              GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, (enum WindowType)90, (int)pBtn_GameSettings, v0);
+              GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, WINDOW_5A, (int)pBtn_GameSettings, v0);
               pEventTimer->Pause();
               pAudioPlayer->StopChannels(-1, -1);
               ++pIcons_LOD->uTexturePacksCount;
               pCurrentScreen = v0;
               if ( !pIcons_LOD->uNumPrevLoadedFiles )
                 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
-              pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)3, 0, 0);
+              pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_3, 0, 0);
               uTextureID_Options = pIcons_LOD->LoadTexture("options", TEXTURE_16BIT_PALETTE);
               uTextureID_New1 = pIcons_LOD->LoadTexture("new1", TEXTURE_16BIT_PALETTE);
               uTextureID_Load1 = pIcons_LOD->LoadTexture("load1", TEXTURE_16BIT_PALETTE);
@@ -1513,22 +1513,22 @@
               uTextureID_Quit1 = pIcons_LOD->LoadTexture("quit1", TEXTURE_16BIT_PALETTE);
               pBtn_NewGame = pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x9Bu, 0xD6u, 0x28u, v0, 0, 0x7Cu, 0, 0x4Eu,
                              pGlobalTXT_LocalizationStrings[614],// "New Game"
-                             (Texture *)(uTextureID_New1 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_New1] : 0), 0);
+                             pIcons_LOD->GetTexture(uTextureID_New1), 0);
               pBtn_SaveGame = pGUIWindow_CurrentMenu->CreateButton(0x13u, 0xD1u, 0xD6u, 0x28u, v0, 0, 0x7Eu, 0, 0x53u,
                              pGlobalTXT_LocalizationStrings[615],// "Save Game"
-                             (Texture *)(uTextureID_Save1 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Save1] : 0), 0);
+                             pIcons_LOD->GetTexture(uTextureID_Save1), 0);
               pBtn_LoadGame = pGUIWindow_CurrentMenu->CreateButton(19, 263, 0xD6u, 0x28u, v0, 0, 0x7Du, 0, 0x4Cu,
                              pGlobalTXT_LocalizationStrings[616],// "Load Game"
-                             (Texture *)(uTextureID_Load1 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Load1] : 0), 0);
+                             pIcons_LOD->GetTexture(uTextureID_Load1), 0);
               pBtn_GameControls = pGUIWindow_CurrentMenu->CreateButton(241, 155, 214, 40, v0, 0, 0x7Fu, 0, 0x43u,
                              pGlobalTXT_LocalizationStrings[617],// ""Sound, Keyboard, Game Options:""
-                             (Texture *)(uTextureID_Controls1 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Controls1] : 0), 0);
+                             pIcons_LOD->GetTexture(uTextureID_Controls1), 0);
               pBtn_QuitGame = pGUIWindow_CurrentMenu->CreateButton(241, 209, 214, 40, v0, 0, 0x84u, 0, 0x51u,
                              pGlobalTXT_LocalizationStrings[618],// "Quit"
-                             (Texture *)(uTextureID_Quit1 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Quit1] : 0), 0);
+                             pIcons_LOD->GetTexture(uTextureID_Quit1), 0);
               pBtn_Resume = pGUIWindow_CurrentMenu->CreateButton(241, 263, 214, 40, v0, 0, 0x7Bu, 0, 0x52u,
                              pGlobalTXT_LocalizationStrings[619],// "Return to Game"
-                             (Texture *)(uTextureID_Resume1 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Resume1] : 0), 0);
+                             pIcons_LOD->GetTexture(uTextureID_Resume1), 0);
               pGUIWindow_CurrentMenu->_41D08F(6, v0, 0, 0);
               viewparams->field_48 = v0;
               stru_506E40.Release();
@@ -1551,7 +1551,7 @@
         case UIMSG_ScrollNPCPanel://Right and Left button for NPCPanel
           if ( uMessageParam )
           {
-            GUIWindow::Create(626, 179, 0, 0, (enum WindowType)90, (int)pBtn_NPCRight, 0);
+            GUIWindow::Create(626, 179, 0, 0, WINDOW_5A, (int)pBtn_NPCRight, 0);
             v37 = (pParty->pHirelings[0].pName != 0) + (pParty->pHirelings[1].pName != 0) + (unsigned __int8)pParty->field_70A - 2;
             if ( (unsigned __int8)pParty->field_709 < v37 )
             {
@@ -1562,7 +1562,7 @@
           }
           else
           {
-            GUIWindow::Create(469, 179, 0, 0, (enum WindowType)90, (int)pBtn_NPCLeft, 0);
+            GUIWindow::Create(469, 179, 0, 0, WINDOW_5A, (int)pBtn_NPCLeft, 0);
             if ( pParty->field_709 )
             {
               --pParty->field_709;
@@ -1929,23 +1929,17 @@
           }*/
           pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v0, 0);
           continue;
-        case UIMSG_C3:
+
+        case UIMSG_OnCastTownPortal:
           pAudioPlayer->StopChannels(-1, -1);
-          v162 = uMessageParam;
-          v148 = 195;
-          //goto LABEL_438;
-          pWindowType = (WindowType)9;
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, pWindowType, v148, v162);
-          continue;
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, WINDOW_TownPortal, uMessageParam);
+        continue;
+
         case UIMSG_B1:
           pAudioPlayer->StopChannels(-1, -1);
-          v162 = 0;
-          v148 = 177;
-//LABEL_438:
-          pWindowType = (WindowType)9;
-//LABEL_439:
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, pWindowType, v148, v162);
-          continue;
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, 117, 0);
+        continue;
+
         case UIMSG_B2:
           v165 = 0;
           v151 = 0;
@@ -2138,7 +2132,7 @@
                   if ( v67 )
                     *((int *)v67 + 17) = v0;
                   else
-                    pParty->pPlayers[(unsigned __int8)byte_50C0C0].CanCastSpell(0x14u);
+                    pParty->pPlayers[(unsigned __int8)town_portal_caster_id].CanCastSpell(0x14u);
 //LABEL_434:
                   /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
                   {
@@ -2458,7 +2452,7 @@
             v0 = 1;
             continue;
           }
-          ptr_507BC8 = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)104, uMessageParam, 0);
+          ptr_507BC8 = GUIWindow::Create(0, 0, 640, 480, WINDOW_68, uMessageParam, 0);
           pCurrentScreen = SCREEN_19;
           pEventTimer->Pause();
           continue;
@@ -2543,7 +2537,7 @@
             pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
             continue;
           }
-          GUIWindow::Create(pButton_RestUI_Wait5Minutes->uX, pButton_RestUI_Wait5Minutes->uY, 0, 0, (enum WindowType)90,
+          GUIWindow::Create(pButton_RestUI_Wait5Minutes->uX, pButton_RestUI_Wait5Minutes->uY, 0, 0, WINDOW_5A,
             (int)pButton_RestUI_Wait5Minutes, (int)pGlobalTXT_LocalizationStrings[238]);// "Wait 5 Minutes"
           dword_506F14 = v0;
           _506F18_num_hours_to_sleep = 5;
@@ -2557,7 +2551,7 @@
             pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
             continue;
           }
-          GUIWindow::Create(pButton_RestUI_Wait1Hour->uX, pButton_RestUI_Wait1Hour->uY, 0, 0, (enum WindowType)90,
+          GUIWindow::Create(pButton_RestUI_Wait1Hour->uX, pButton_RestUI_Wait1Hour->uY, 0, 0, WINDOW_5A,
             (int)pButton_RestUI_Wait1Hour, (int)pGlobalTXT_LocalizationStrings[239]);// "Wait 1 Hour"
           dword_506F14 = v0;
           _506F18_num_hours_to_sleep = 60;
@@ -2735,7 +2729,7 @@
             pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
             continue;
           }
-          GUIWindow::Create(pButton_RestUI_WaitUntilDawn->uX, pButton_RestUI_WaitUntilDawn->uY, 0, 0, (enum WindowType)90,
+          GUIWindow::Create(pButton_RestUI_WaitUntilDawn->uX, pButton_RestUI_WaitUntilDawn->uY, 0, 0, WINDOW_5A,
             (int)pButton_RestUI_WaitUntilDawn, (int)pGlobalTXT_LocalizationStrings[237]);// "Wait until Dawn"
           v97 = sub_494820(pParty->uCurrentHour);
           dword_506F14 = v0;
@@ -2783,7 +2777,7 @@
           v0 = 1;
           continue;
         case UIMSG_58:
-          GUIWindow::Create(pBtn_InstallRemoveSpell->uX, pBtn_InstallRemoveSpell->uY, 0, 0, (enum WindowType)90, (int)pBtn_InstallRemoveSpell, 0);
+          GUIWindow::Create(pBtn_InstallRemoveSpell->uX, pBtn_InstallRemoveSpell->uY, 0, 0, WINDOW_5A, (int)pBtn_InstallRemoveSpell, 0);
           if ( !uActiveCharacter )
             continue;
           pPlayer10 = pPlayers[uActiveCharacter];
@@ -2962,10 +2956,10 @@
               if ( !pCurrentScreen )
                 //goto LABEL_693;
               {
-                GUIWindow::Create(0x1DCu, 0x1C2u, 0, 0, (enum WindowType)90, (int)pBtn_CastSpell, 0);
+                GUIWindow::Create(0x1DCu, 0x1C2u, 0, 0, WINDOW_5A, (int)pBtn_CastSpell, 0);
                 pCurrentScreen = SCREEN_SPELL_BOOK;
                 pEventTimer->Pause();
-                pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)18, 0, 0);
+                pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_SpellBook, 0, 0);
                 pAudioPlayer->PlaySound((SoundID)48, 0, 0, -1, 0, 0, 0, 0);
                 viewparams->field_48 = v0;
                 continue;
@@ -2977,10 +2971,10 @@
               {
                 pGUIWindow_CurrentMenu->Release();
 //LABEL_693:
-                GUIWindow::Create(0x1DCu, 0x1C2u, 0, 0, (enum WindowType)90, (int)pBtn_CastSpell, 0);
+                GUIWindow::Create(0x1DCu, 0x1C2u, 0, 0, WINDOW_5A, (int)pBtn_CastSpell, 0);
                 pCurrentScreen = SCREEN_SPELL_BOOK;
                 pEventTimer->Pause();
-                pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)18, 0, 0);
+                pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_SpellBook, 0, 0);
                 pAudioPlayer->PlaySound((SoundID)48, 0, 0, -1, 0, 0, 0, 0);
                 viewparams->field_48 = v0;
                 continue;
@@ -3001,7 +2995,7 @@
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
           pCurrentScreen = SCREEN_QUICK_REFERENCE;
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)12, 5, 0);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_QuickReference, 5, 0);
           papredoll_dbrds[2] = pIcons_LOD->LoadTexture("BUTTEXI1", TEXTURE_16BIT_PALETTE);
           pBtn_ExitCancel = pGUIWindow_CurrentMenu->CreateButton(0x187u, 0x13Cu, 0x4Bu, 0x21u, v0, 0, 0x71u, 0, 0,
                          pGlobalTXT_LocalizationStrings[79],// "Exit"
@@ -3038,12 +3032,12 @@
             dword_50651C = -1;
           continue;
         case UIMSG_A9:
-          GUIWindow::Create(pBtn_Up->uX, pBtn_Up->uY, 0, 0, (WindowType)(WINDOW_HouseInterior|0x42), (int)pBtn_Up, 0);
+          GUIWindow::Create(pBtn_Up->uX, pBtn_Up->uY, 0, 0, WINDOW_5B, (int)pBtn_Up, 0);
 //LABEL_707:
           dword_506548 = v0;
           continue;
         case UIMSG_AA:
-          GUIWindow::Create(pBtn_Down->uX, pBtn_Down->uY, 0, 0, (WindowType)(WINDOW_HouseInterior|0x42), (int)pBtn_Down, 0);
+          GUIWindow::Create(pBtn_Down->uX, pBtn_Down->uY, 0, 0, WINDOW_5B, (int)pBtn_Down, 0);
 //LABEL_709:
           dword_506544 = v0;
           continue;
@@ -10179,7 +10173,7 @@
   if ( pIcons_LOD->dword_011BA4 && pTex->uDecompressedSize )
     v3 = pTex->UnzipPalette();
   else
-    v3 = pTex->pLevelOfDetail0;
+    v3 = pTex->pLevelOfDetail0_prolly_alpha_mask;
   v12 = v3;
   v4 = v3;
   v5 = v9;
@@ -10227,7 +10221,7 @@
   if ( pIcons_LOD->dword_011BA4 && a2->uDecompressedSize )
     v4 = a2->UnzipPalette();
   else
-    v4 = a2->pLevelOfDetail0;
+    v4 = a2->pLevelOfDetail0_prolly_alpha_mask;
   v5 = v7;
   do
   {
@@ -10482,30 +10476,44 @@
 
 
 //----- (00411150) --------------------------------------------------------
-char *__cdecl DrawTownPortalScreen()
-{
-  signed int v0; // edi@1
-  __int16 v1; // dx@8
-  POINT *v2; // edi@17
+void DrawTownPortalScreen()
+{
+  //signed int v0; // edi@1
+  //__int16 v1; // dx@8
+  //POINT *v2; // edi@17
   int v3; // edi@17
-  __int16 v4; // dx@24
+  //__int16 v4; // dx@24
   GUIWindow v6; // [sp+Ch] [bp-64h]@1
-  POINT v7; // [sp+60h] [bp-10h]@17
+  //POINT v7; // [sp+60h] [bp-10h]@17
   POINT a2; // [sp+68h] [bp-8h]@17
 
   pRenderer->ClearZBuffer(0, 479);
-  pRenderer->DrawTextureTransparent(8u, 8u, pTexture_CurrentBook);
-  pRenderer->DrawTextureTransparent(
-    0x1D7u,
-    0x1BDu,
-    (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0));
+  pRenderer->DrawTextureTransparent(8, 8, pTexture_CurrentBook);
+  pRenderer->DrawTextureTransparent(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId));
+
   v6.uFrameX = 8;
   v6.uFrameY = 8;
   v6.uFrameWidth = 460;
   v6.uFrameHeight = 344;
   v6.uFrameZ = 467;
   v6.uFrameW = 351;
-  v0 = 0;
+  
+  const uint fountain_bits_lut[] = {PARTY_QUEST_FOUNTAIN_HARMONDALE,
+                                    PARTY_QUEST_FOUNTAIN_PIERPONT,
+                                    PARTY_QUEST_FOUNTAIN_NIGHON,
+                                    PARTY_QUEST_FOUNTAIN_EVENMORN_ISLE,
+                                    PARTY_QUEST_FOUNTAIN_CELESTIA,
+                                    PARTY_QUEST_FOUNTAIN_THE_PIT};
+  for (uint i = 0; i < 6; ++i)
+  {
+
+    if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[i]))
+      pRenderer->DrawMaskToZBuffer(pTownPortalBook_xs[i],
+                                   pTownPortalBook_ys[i],
+                                   pTexture_TownPortalIcons[i], i + 1);
+  }
+
+/*  v0 = 0;
   do
   {
     if ( !v0 )
@@ -10542,7 +10550,7 @@
       goto LABEL_14;
     }
 LABEL_15:
-    pRenderer->_4A612A(
+    pRenderer->DrawMaskToZBuffer(
       pTownPortalBook_xs[v0],
       pTownPortalBook_ys[v0],
       *(&pTexture_TownPortalHarmn + v0),
@@ -10550,18 +10558,33 @@
 LABEL_16:
     ++v0;
   }
-  while ( v0 < 6 );
-  v2 = pMouse->GetCursorPos(&a2);
-  v3 = pRenderer->pActiveZBuffer[v2->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v7)->y]] & 0xFFFF;
-  if ( !v3 )                                    // Town Portal
-    return v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);
+  while ( v0 < 6 );*/
+
+  pMouse->GetCursorPos(&a2);
+  //v2 = pMouse->GetCursorPos(&a2);
+  v3 = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF;
+
+  if (v3)
+  {
+    if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[v3 - 1]))
+      pRenderer->DrawTextureIndexed(pTownPortalBook_xs[v3 - 1], pTownPortalBook_ys[v3 - 1], pTexture_TownPortalIcons[v3 - 1]);
+  }
+  v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);
+
+
+/*  if ( !v3 )                                    // Town Portal
+  {
+    v6.DrawTitleText(pBook2Font, 0, 22, 0, pGlobalTXT_LocalizationStrings[10], 3);  // "Town Portal"
+    return;
+  }
   if ( v3 == 1 )
   {
     v4 = 206;
 LABEL_30:
     if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v4) )
       goto LABEL_31;
-    return v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);
+    v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);  // "Town Portal"
+    return;
   }
   if ( v3 == 2 )
   {
@@ -10590,7 +10613,7 @@
   }
 LABEL_31:
   pRenderer->DrawTextureIndexed(word_4E1D3A[v3], pTownPortalBook_xs[v3 + 5], *(&pTex_tab_an_6b__zoom_on + v3));
-  return v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);
+  v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);*/
 }
 // 4E1D3A: using guessed type __int16 word_4E1D3A[];
 
--- a/mm7_6.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/mm7_6.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -2166,6 +2166,7 @@
 {
   bool result; // eax@2
 
+  __debugbreak(); // refactor
   if ( *(&pSpellDatas[0].field_12 + 20 * uSpellID) & 0xC )
     result = 1;
   else
@@ -2616,8 +2617,8 @@
   int v63; // ecx@187
   int v64; // ecx@188
   int v65; // ecx@189
-  const char *v66; // ecx@200
-  unsigned int v67; // edx@201
+  //const char *v66; // ecx@200
+  //unsigned int v67; // edx@201
   char v68; // al@207
   ItemGen *v69; // esi@211
   int v70; // ecx@214
@@ -2740,7 +2741,7 @@
   int v187; // eax@367
   int v188; // esi@369
   int v189; // edi@369
-  const char *v190; // ecx@377
+  //const char *v190; // ecx@377
   signed int v191; // edi@379
   int v192; // ecx@382
   int v193; // ecx@383
@@ -3613,7 +3614,11 @@
           while ( v730 );*/
         }
         if ( SHIDWORD(v733) > amount )
-          goto LABEL_200;
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
+        }
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           goto play_sound_and_continue;
 
@@ -3644,11 +3649,16 @@
         v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
         v35 = pParty->sRotationX + 10;
         goto LABEL_124;
+
       case 20:
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           goto play_sound_and_continue;
         if (!a2)
-          goto LABEL_200;
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
+        }
         if ( (a2 & 7) != OBJECT_Actor)
           goto LABEL_1056;
         v699 = 0;
@@ -3753,7 +3763,11 @@
         a1.uSoundID = v49;
         v726 = (Player *)a1.Create(0, 0, 0, 0);
         if ( !MonsterStats::BelongsToSupertype(*(short *)(HIDWORD(v733) + 96), MONSTER_SUPERTYPE_UNDEAD) )
-          goto LABEL_200;
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
+        }
         v47 = v730;
         v670 = (Vec3_int_ *)&v691;
         v42 = (signed int)v726;
@@ -3820,7 +3834,11 @@
       case 87:
         if ( uCurrentlyLoadedLevelType == LEVEL_Indoor
           || uCurrentlyLoadedLevelType == LEVEL_Outdoor && (pParty->uCurrentHour < 5 || pParty->uCurrentHour >= 0x15) )
-          goto LABEL_200;
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
+        }
         if ( pPlayer->CanCastSpell(uRequiredMana) )
           goto LABEL_152;
         goto play_sound_and_continue;
@@ -4056,16 +4074,12 @@
             }
           }
         }
-LABEL_199:
+
         dword_50C9D0 = 113;
         dword_50C9D4 = 0;
         dword_50C9D8 = 1;
-LABEL_200:
-        v66 = pGlobalTXT_LocalizationStrings[428];
-LABEL_201:
-        v67 = 2;
-LABEL_202:
-        ShowStatusBarString(v66, v67);
+
+        ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
         pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
         goto LABEL_203;
 
@@ -4443,8 +4457,9 @@
         }
         if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
         {
-          v66 = pGlobalTXT_LocalizationStrings[491];
-          goto LABEL_201;
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[491], 2);  // Can't cast Meteor Shower indoors!
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
         }
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           goto play_sound_and_continue;
@@ -4533,11 +4548,12 @@
         }
         goto LABEL_1056;
       case 10:
-        v67 = 2;
+        //v67 = 2;
         if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
         {
-          v66 = pGlobalTXT_LocalizationStrings[492];
-          goto LABEL_202;
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[492], 2); // Can't cast Inferno outdoors!
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
         }
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           goto play_sound_and_continue;
@@ -4708,8 +4724,9 @@
       case 16:
         if ( pParty->uFlags & PARTY_FLAGS_1_FALLING)
         {
-          v190 = pGlobalTXT_LocalizationStrings[493]; // Can't cast Jump while airborne!
-          goto LABEL_462;
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[493], 2);  // Can't cast Jump while airborne!
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto play_sound_and_continue;
         }
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           goto play_sound_and_continue;
@@ -4751,10 +4768,11 @@
 LABEL_392:
         LODWORD(v733) = v195;
 LABEL_393:
-        if ( pParty->uFlags & 0x30 )
-        {
-          v66 = pGlobalTXT_LocalizationStrings[638];
-          goto LABEL_201;
+        if (pParty->uFlags & (PARTY_FLAGS_1_ALERT_RED | PARTY_FLAGS_1_ALERT_YELLOW))
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[638], 2);  // There are hostile creatures nearby!
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
         }
         if ( pPlayer->CanCastSpell(uRequiredMana) )
         {
@@ -4769,20 +4787,19 @@
           LODWORD(v727) = v83;
         }
         goto play_sound_and_continue;
+
       case 21:
         if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
         {
-          v190 = pGlobalTXT_LocalizationStrings[494]; // Can not cast Fly indoors!
-LABEL_462:
-          ShowStatusBarString(v190, 2u);
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2);  // Can not cast Fly indoors!
           pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
           goto play_sound_and_continue;
         }
         if ( !pPlayers[v3->uPlayerID + 1]->GetMaxMana() )
         {
-LABEL_461:
-          v190 = pGlobalTXT_LocalizationStrings[428];
-          goto LABEL_462;
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);  // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto play_sound_and_continue;
         }
         LODWORD(v733) = 3600 * v2;
         if ( v731 == 2 || v731 == 3 || (amount = 0, v731 != 4) )
@@ -4803,11 +4820,12 @@
         goto LABEL_1056;
 
       case 22:
-        v67 = 2;
+        //v67 = 2;
         if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
         {
-          v66 = pGlobalTXT_LocalizationStrings[495];
-          goto LABEL_202;
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[495], 2);  // Can't cast Starburst indoors!
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
         }
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           goto play_sound_and_continue;
@@ -5034,7 +5052,11 @@
         goto LABEL_1056;
       case 27:
         if ( !pPlayers[v3->uPlayerID + 1]->GetMaxMana() )
-          goto LABEL_461;
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);  // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto play_sound_and_continue;
+        }
         if ( v731 == 2 || v731 != 3 && v731 != 4 )
           v229 = 600 * v2;
         else
@@ -5059,13 +5081,22 @@
           pParty->pPartyBuffs[18].uFlags = 1;
         LODWORD(v727) = 1;
         goto play_sound_and_continue;
+
       case 28:
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           goto play_sound_and_continue;
         v240 = (char *)&pParty->pPlayers[v3->uPlayerID_2].pInventoryItems[a2];
         y = v240;
         if ( pItemsTable->pItems[*(int *)v240].uEquipType != 12 || v240[20] & 2 )
-          goto LABEL_199;
+        {
+          dword_50C9D0 = 113;
+          dword_50C9D4 = 0;
+          dword_50C9D8 = 1;
+
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);  // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
+        }
         if ( v731 == 1 || v731 == 2 )
         {
           v241 = (double)v723 * 0.0099999998 + 0.5;
@@ -5428,13 +5459,28 @@
         if ( rand() % 100 >= SHIDWORD(v733) )
           uRequiredMana = 1;
         if ( uRequiredMana != 0 )
-          goto LABEL_199;
+        {
+          dword_50C9D0 = 113;
+          dword_50C9D4 = 0;
+          dword_50C9D8 = 1;
+
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
+        }
         v292 = *(char *)(LODWORD(v725) + 28);
         if ( !(v292 == 3 | v292 == 4 | v292 == 5 | v292 == 6 | v292 == 7 | v292 == 8 | v292 == 9 | v292 == 10 | v292 == 11) )
         {
           v2 = v723;
           //v1 = 0;
-          goto LABEL_199;
+
+          dword_50C9D0 = 113;
+          dword_50C9D4 = 0;
+          dword_50C9D8 = 1;
+
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
         }
         if ( rand() % 100 >= 80 )
         {
@@ -5506,19 +5552,27 @@
         }
         v294->uAttributes |= 0x20u;
         goto LABEL_1055;
-      case 31:
+      case SPELL_WATER_TOWN_PORTAL:
         amount = 10 * v2;
         if ( pPlayer->sMana < (signed int)uRequiredMana )
           goto play_sound_and_continue;
-        if ( pParty->uFlags & 0x30 && v12 != 4 || rand() % 100 >= amount && v731 != 4 )
-          goto LABEL_200;
-        byte_50C0C0 = LOBYTE(v3->uPlayerID);
-        pMessageQueue_50CBD0->AddMessage(UIMSG_C3, 0, 0);
+        if ( pParty->uFlags & (PARTY_FLAGS_1_ALERT_RED | PARTY_FLAGS_1_ALERT_YELLOW) && v12 != 4 || rand() % 100 >= amount && v731 != 4 )
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
+        }
+        town_portal_caster_id = LOBYTE(v3->uPlayerID);
+        pMessageQueue_50CBD0->AddMessage(UIMSG_OnCastTownPortal, 0, 0);
         goto LABEL_1056;
       case 33:
         LODWORD(v733) = 604800 * v2;
         if ( !_strcmpi(pCurrentMapName, "d05.blv") )
-          goto LABEL_200;
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
+        }
         v319 = uRequiredMana;
         if ( pPlayer->sMana >= (signed int)uRequiredMana )
         {
@@ -5595,7 +5649,11 @@
         goto LABEL_125;
       case 43:
         if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
-          goto LABEL_200;
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
+        }
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           goto play_sound_and_continue;
         a1.uType = 4090;
@@ -6741,8 +6799,9 @@
         }
         if ( SHIDWORD(v733) >= amount )
         {
-          v66 = pGlobalTXT_LocalizationStrings[648];
-          goto LABEL_201;
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[648], 2);  // This character can't summon any more monsters!
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
         }
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           goto play_sound_and_continue;
@@ -6790,11 +6849,12 @@
         goto play_sound_and_continue;
 
       case 84:
-        v67 = 2;
+        //v67 = 2;
         if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
         {
-          v66 = pGlobalTXT_LocalizationStrings[497];
-          goto LABEL_202;
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[497], 2);  // Can't cast Prismatic Light outdoors!
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
         }
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           goto play_sound_and_continue;
@@ -6940,7 +7000,11 @@
       case 88:
         amount = 3;
         if ( pPlayer->uNumDivineInterventionCastsThisDay >= 3u )
-          goto LABEL_200;
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
+        }
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           goto play_sound_and_continue;
         a2 = 0;
@@ -7017,13 +7081,18 @@
         v726 = v577;
         if ( v577 == (Player *)-1 )
         {
-          v66 = pGlobalTXT_LocalizationStrings[496];
-          goto LABEL_201;
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[496], 2);  // No valid target exists!
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
         }
         v578 = (int)&pActors[(int)v577];
         v721 = v578;
         if ( *(short *)(v578 + 40) > 0 || (v579 = *(short *)(v578 + 176), v579 != 5) && v579 != 4 )
-          goto LABEL_200;
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
+        }
         ++a1.uType;
         a1.stru_24.Reset();
         a1.field_48 = v3->spellnum;
@@ -7090,7 +7159,15 @@
           || *(int *)(HIDWORD(v733) + 4) != 0
           || (v591 = *(char *)(v732 + 28)) != 0 && v591 != 1 && v591 != 2
           || pItemsTable->IsMaterialNonCommon((ItemGen *)HIDWORD(v733)) )
-          goto LABEL_199;
+        {
+          dword_50C9D0 = 113;
+          dword_50C9D4 = 0;
+          dword_50C9D8 = 1;
+
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
+        }
         v592 = HIDWORD(v733);
         v14 = v731 == 4;
         *(int *)(HIDWORD(v733) + 12) = 16;
@@ -7191,7 +7268,11 @@
         if ( !MonsterStats::BelongsToSupertype(pActors[v599].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
           goto play_sound_and_continue;
         if ( !stru_50C198.GetMagicalResistance(&pActors[v599], 0xAu) )
-          goto LABEL_200;
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
+        }
         pActors[v599].pActorBuffs[9].Reset();
         pActors[v599].pActorBuffs[1].Reset();
         v732 = (int)v733 << 7;
@@ -7273,7 +7354,11 @@
         if ( v608 != 4 && v608 != 5
           || (v609 = (signed int)*(&pFontCChar + v608 + (unsigned __int8)pParty->field_709), v609 <= 0)
           || v609 >= 3 )
-          goto LABEL_200;
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
+        }
         v610 = 76 * v609;
         *((int *)&pParty->pPlayers[3].pInstalledBeacons[4].uBeaconTime + 19 * v609) = 0;
         v611 = pIconsFrameTable->FindIcon("spell96");
@@ -7425,14 +7510,19 @@
       case 98:
         if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
         {
-          v66 = pGlobalTXT_LocalizationStrings[499];
-          goto LABEL_201;
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[499], 2);  // Can't cast Armageddon indoors!
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
         }
         v640 = v12 - 2;
         if ( !v640 || (v641 = v640 - 1) == 0 || (amount = 4, v641 != 1) )
           amount = 3;
         if ( pPlayer->uNumArmageddonCasts >= amount || pParty->armageddon_timer > 0 )
-          goto LABEL_200;
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          goto LABEL_203;
+        }
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           goto play_sound_and_continue;
         pParty->armageddon_timer = 256;
--- a/mm7_data.cpp	Thu Mar 21 23:10:57 2013 +0400
+++ b/mm7_data.cpp	Thu Mar 21 23:11:54 2013 +0400
@@ -380,10 +380,10 @@
 char pDayMoonPhase[28];
 char *spellbook_texture_filename_suffices[8] = {"f", "a", "w", "e", "s", "m", "b", "l"}; // weak
 __int16 word_4E1D3A[777]; // weak
-__int16 pTownPortalBook_xs[6];
-__int16 pTownPortalBook_ys[6];
-__int16 pTownPortalBook_ws[6];
-__int16 pTownPortalBook_hs[6];
+__int16 pTownPortalBook_xs[6] = {260, 324, 147, 385, 390,  19};
+__int16 pTownPortalBook_ys[6] = {206,  84, 182, 239,  17, 283};
+__int16 pTownPortalBook_ws[6] = { 80,  66,  68,  72,  67,  74};
+__int16 pTownPortalBook_hs[6] = { 55,  56,  65,  67,  67,  59};
 
 
 unsigned int pLloydsBeaconsPreviewXs[5] = {61, 281,  61, 281, 171}; // 004E249C
@@ -1741,7 +1741,7 @@
 int dword_50BC10[777]; // weak
 int dword_50BDA0[777]; // weak
 int dword_50BF30[777]; // weak
-char byte_50C0C0; // weak
+char town_portal_caster_id; // weak
 int some_active_character; // weak
 _UNKNOWN unk_50C190; // weak
 int dword_50C968; // weak
--- a/mm7_data.h	Thu Mar 21 23:10:57 2013 +0400
+++ b/mm7_data.h	Thu Mar 21 23:11:54 2013 +0400
@@ -1255,7 +1255,7 @@
 extern int dword_50BC10[]; // weak
 extern int dword_50BDA0[]; // weak
 extern int dword_50BF30[]; // weak
-extern char byte_50C0C0; // weak
+extern char town_portal_caster_id; // weak
 extern int some_active_character; // weak
 extern _UNKNOWN unk_50C190; // weak
 extern int dword_50C968; // weak
@@ -1824,7 +1824,7 @@
 void DrawSpellDescriptionPopup(int spell_index);
 signed int __fastcall sub_410D99_get_map_index(int a1);
 unsigned int __cdecl DrawLloydBeaconsScreen();
-char *__cdecl DrawTownPortalScreen();
+void DrawTownPortalScreen();
 void LoadSpellbook(unsigned int uID); // idb
 struct GUIWindow *__cdecl sub_41140B();
 void __cdecl sub_411473();