changeset 726:9d13d2ec35a6

Слияние
author Ritor1
date Fri, 22 Mar 2013 01:29:46 +0600
parents 7037f22cd716 (current diff) e7c86528a2b3 (diff)
children 9f596a163257 7378398c34e4
files Indoor.cpp Outdoor.cpp Player.cpp Render.cpp Render.h mm7_1.cpp mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp mm7_6.cpp mm7_data.cpp mm7_data.h
diffstat 31 files changed, 558 insertions(+), 486 deletions(-) [+]
line wrap: on
line diff
--- a/BSPModel.h	Fri Mar 22 01:29:25 2013 +0600
+++ b/BSPModel.h	Fri Mar 22 01:29:46 2013 +0600
@@ -3,7 +3,7 @@
 
 
 #pragma pack(push, 1)
-struct BSPNode
+struct BSPNode //8
 {
   __int16 uFront;
   __int16 uBack;
--- a/GUIProgressBar.cpp	Fri Mar 22 01:29:25 2013 +0600
+++ b/GUIProgressBar.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -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	Fri Mar 22 01:29:25 2013 +0600
+++ b/GUIWindow.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -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	Fri Mar 22 01:29:25 2013 +0600
+++ b/GUIWindow.h	Fri Mar 22 01:29:46 2013 +0600
@@ -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	Fri Mar 22 01:29:25 2013 +0600
+++ b/GameUIs.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -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	Fri Mar 22 01:29:25 2013 +0600
+++ b/Indoor.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -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;
@@ -1720,69 +1720,32 @@
 }
 
 //----- (00498C45) --------------------------------------------------------
-int IndoorLocation::Alloc()
-{
-  IndoorLocation *v1; // esi@1
-  void *v2; // eax@1
-  const void *v3; // ST3C_4@1
-  void *v4; // eax@1
-  const void *v5; // ST3C_4@1
-  void *v6; // eax@1
-  const void *v7; // ST3C_4@1
-  void *v8; // eax@1
-  const void *v9; // ST3C_4@1
-  void *v10; // eax@1
-  const void *v11; // ST3C_4@1
-  void *v12; // eax@1
-  const void *v13; // ST3C_4@1
-  void *v14; // eax@1
-  const void *v15; // ST3C_4@1
-  void *v16; // eax@1
-  void *v17; // ecx@1
-  signed int result; // eax@9
-
-  v1 = this;
-  v2 = pAllocator->AllocNamedChunk(this->pVertices, 0x15F90u, "L.V");
-  v3 = v1->pFaces;
-  v1->pVertices = (Vec3_short_ *)v2;
-  v4 = pAllocator->AllocNamedChunk(v3, 0xEA600u, "L.F");
-  v5 = v1->pFaceExtras;
-  v1->pFaces = (BLVFace *)v4;
-  v6 = pAllocator->AllocNamedChunk(v5, 0x2BF20u, "L.FX");
-  v7 = v1->pSectors;
-  v1->pFaceExtras = (BLVFaceExtra *)v6;
-  v8 = pAllocator->AllocNamedChunk(v7, 0xE800u, "L.R");
-  v9 = v1->pLights;
-  v1->pSectors = (BLVSector *)v8;
-  v10 = pAllocator->AllocNamedChunk(v9, 0x1900u, "L.L");
-  v11 = v1->pDoors;
-  v1->pLights = (BLVLightMM7 *)v10;
-  v12 = pAllocator->AllocNamedChunk(v11, 0x3E80u, "L.D");
-  v13 = v1->pNodes;
-  v1->pDoors = (BLVDoor *)v12;
-  v14 = pAllocator->AllocNamedChunk(v13, 0x9C40u, "L.BSP");
-  v15 = v1->pMapOutlines;
-  v1->pNodes = (BSPNode *)v14;
-  v16 = pAllocator->AllocNamedChunk(v15, 0x14824u, "L.Map");
-  v17 = v1->pVertices;
-  v1->pMapOutlines = (BLVMapOutlines *)v16;
-  if ( v17 && v1->pFaces && v1->pFaceExtras && v1->pSectors && v1->pLights && v1->pDoors && v1->pNodes && v16 )
+bool IndoorLocation::Alloc()
+    {
+  pVertices   = (Vec3_short_ *)   pAllocator->AllocNamedChunk(pVertices, 15000*sizeof(Vec3_short_),  "L.V");//0x15F90u
+  pFaces      = (BLVFace *)       pAllocator->AllocNamedChunk(pFaces,    10000*sizeof(BLVFace),      "L.F");//0xEA600u
+  pFaceExtras = (BLVFaceExtra *)  pAllocator->AllocNamedChunk(pFaceExtras,5000*sizeof(BLVFaceExtra), "L.FX"); //0x2BF20u
+  pSectors =    (BLVSector *)     pAllocator->AllocNamedChunk(pSectors,    512*sizeof(BLVSector),     "L.R");//0xE800u
+  pLights =     (BLVLightMM7 *)   pAllocator->AllocNamedChunk(pLights,     400*sizeof(BLVLightMM7),   "L.L");//0x1900u
+  pDoors =      (BLVDoor *)       pAllocator->AllocNamedChunk(pDoors,      200*sizeof(BLVDoor),       "L.D");//0x3E80u
+  pNodes =      (BSPNode *)       pAllocator->AllocNamedChunk(pNodes,     5000*sizeof(BSPNode),       "L.BSP");//0x9C40u
+  pMapOutlines =(BLVMapOutlines *)pAllocator->AllocNamedChunk(pMapOutlines,   sizeof(BLVMapOutlines), "L.Map");//0x14824u
+  if (pVertices && pFaces && pFaceExtras && pSectors && pLights && pDoors && pNodes && pMapOutlines )
   {
-    memset(v17, 90000, 0);
-    memset(v1->pFaces, 960000, 0);
-    memset(v1->pFaceExtras, 180000, 0);
-    memset(v1->pSectors, 59392, 0);
-    memset(v1->pLights, 6400, 0);
-    memset(v1->pDoors, 16000, 0);
-    memset(v1->pNodes, 40000, 0);
-    memset(v1->pMapOutlines, 84004, 0);
-    result = 1;
+    memset(pVertices,  0, 15000*sizeof(Vec3_short_));
+    memset(pFaces,     0, 10000*sizeof(BLVFace));
+    memset(pFaceExtras,0,  5000*sizeof(BLVFaceExtra));
+    memset(pSectors,   0,   512*sizeof(BLVSector));
+    memset(pLights,    0,   400*sizeof(BLVLightMM7));
+    memset(pDoors,     0,   200*sizeof(BLVDoor));
+    memset(pNodes,     0,  5000*sizeof(BSPNode));
+    memset(pMapOutlines,0,  sizeof(BLVMapOutlines));
+    return true;
   }
   else
   {
-    result = 0;
+    return false;
   }
-  return result;
 }
 
 
@@ -1802,13 +1765,13 @@
 
 
 //----- (004488F7) --------------------------------------------------------
-void IndoorLocation::ToggleLight(unsigned int uLightID, unsigned int bToggle)
+void IndoorLocation::ToggleLight(signed int sLightID, unsigned int bToggle)
 {
   char *v2; // eax@4
 
-  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && (signed int)uLightID <= pIndoor->uNumLights - 1 && (uLightID & 0x80000000u) == 0 )
+  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && (sLightID <= pIndoor->uNumLights - 1) && (sLightID >= 0) )
   {
-    v2 = (char *)&pIndoor->pLights[uLightID].uAtributes;
+    v2 = (char *)&pIndoor->pLights[sLightID].uAtributes;
     if ( bToggle )
       *v2 &= 0xF7u;
     else
--- a/Indoor.h	Fri Mar 22 01:29:25 2013 +0600
+++ b/Indoor.h	Fri Mar 22 01:29:46 2013 +0600
@@ -177,7 +177,7 @@
 
 /*   98 */
 #pragma pack(push, 1)
-struct BLVLightMM7
+struct BLVLightMM7 //10h
 {
   struct Vec3_short_ vPosition;
   __int16 uRadius;
@@ -202,7 +202,7 @@
 
 /*  100 */
 #pragma pack(push, 1)
-struct BLVDoor
+struct BLVDoor //50h
 {
   enum State: unsigned __int16
   {
@@ -238,7 +238,7 @@
 
 /*  101 */
 #pragma pack(push, 1)
-struct BLVMapOutline
+struct BLVMapOutline //0C
 {
   unsigned __int16 uVertex1ID;
   unsigned __int16 uVertex2ID;
@@ -264,7 +264,7 @@
 
 /*   93 */
 #pragma pack(push, 1)
-struct BLVFace
+struct BLVFace  //60h
 {
   //----- (0046ED02) --------------------------------------------------------
   inline BLVFace()
@@ -315,7 +315,7 @@
 
 /*   94 */
 #pragma pack(push, 1)
-struct BLVFaceExtra
+struct BLVFaceExtra  //24h
 {
 bool HasEventint();
 
@@ -342,7 +342,7 @@
 
 /*   95 */
 #pragma pack(push, 1)
-struct BLVSector
+struct BLVSector //0x74
 {
   int field_0;
   unsigned __int16 uNumFloors;
@@ -392,8 +392,8 @@
 #pragma pack(push, 1)
 struct BLVMapOutlines
 {
-  uint          uNumOutlines;
-  BLVMapOutline pOutlines[1];
+  int          uNumOutlines;
+  BLVMapOutline pOutlines[7000];
 };
 #pragma pack(pop)
 
@@ -435,10 +435,10 @@
 
   int GetSector(int sX, int sY, int sZ);
   void Release();
-  int Alloc();
+  bool Alloc();
   bool Load(char *pFilename, int a3, size_t i, char *pDest);
   void Draw();
-  void ToggleLight(unsigned int uLightID, unsigned int bToggle);
+  void ToggleLight(signed int uLightID, unsigned int bToggle);
 
   static unsigned int GetLocationIndex(const char *Str1);
   static void ExecDraw(bool bD3D);
@@ -503,10 +503,10 @@
   unsigned __int16 *pRenderTarget;
   unsigned int uTargetWidth;
   unsigned int uTargetHeight;
-  unsigned int uViewportX;
-  unsigned int uViewportY;
-  unsigned int uViewportZ;
-  unsigned int uViewportW;
+  signed int uViewportX;
+  signed int uViewportY;
+  signed int uViewportZ;
+  signed int uViewportW;
   int field_3C;
   int *pTargetZ;
 };
--- a/LOD.cpp	Fri Mar 22 01:29:25 2013 +0600
+++ b/LOD.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -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/Monsters.h	Fri Mar 22 01:29:25 2013 +0600
+++ b/Monsters.h	Fri Mar 22 01:29:46 2013 +0600
@@ -142,7 +142,7 @@
   unsigned int uAC;
   unsigned int uExp;
   unsigned int uBaseSpeed;
-  unsigned int uRecoveryTime;
+  signed int uRecoveryTime;
   unsigned int uAttackPreference;
 };
 #pragma pack(pop)
--- a/Mouse.cpp	Fri Mar 22 01:29:25 2013 +0600
+++ b/Mouse.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -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	Fri Mar 22 01:29:25 2013 +0600
+++ b/Outdoor.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -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	Fri Mar 22 01:29:25 2013 +0600
+++ b/Party.h	Fri Mar 22 01:29:46 2013 +0600
@@ -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	Fri Mar 22 01:29:25 2013 +0600
+++ b/Player.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -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	Fri Mar 22 01:29:25 2013 +0600
+++ b/Render.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -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);
@@ -9664,7 +9664,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;
@@ -10133,7 +10133,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 )
@@ -10243,7 +10243,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 )
@@ -10346,7 +10346,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;
@@ -10464,7 +10464,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;
@@ -10520,7 +10520,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 )
@@ -10583,7 +10583,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 )
@@ -10660,7 +10660,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
@@ -10690,7 +10690,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;
@@ -10879,7 +10879,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	Fri Mar 22 01:29:25 2013 +0600
+++ b/Render.h	Fri Mar 22 01:29:46 2013 +0600
@@ -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	Fri Mar 22 01:29:25 2013 +0600
+++ b/Texture.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -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
@@ -267,28 +267,26 @@
   if ( !v2 )
     Abortf("Unable to save dtft.bin!");
   fwrite(v1, 4u, 1u, v2);
-  fwrite(v1->pTextures, 0x14u, v1->uNumTextures, v3);
+  fwrite(v1->pTextures, 0x14u, v1->sNumTextures, v3);
   fclose(v3);
 }
 
 //----- (0044E0A0) --------------------------------------------------------
 void TextureFrameTable::FromFile(void *pSerialized)
 {
-  uNumTextures = *(int *)pSerialized;
-  pTextures = (TextureFrame *)pAllocator->AllocNamedChunk(pTextures, 20 * uNumTextures, "Txt Frames");
-  memcpy(pTextures, (char *)pSerialized + 4, 20 * uNumTextures);
+  sNumTextures = *(int *)pSerialized;
+  pTextures = (TextureFrame *)pAllocator->AllocNamedChunk(pTextures, 20 * sNumTextures, "Txt Frames");
+  memcpy(pTextures, (char *)pSerialized + 4, 20 * sNumTextures);
 }
 
 //----- (0044E0ED) --------------------------------------------------------
-unsigned int TextureFrameTable::LoadAnimationSequenceAndPalettes(unsigned int uIconID)
-{
-  unsigned int result; // eax@1
+void TextureFrameTable::LoadAnimationSequenceAndPalettes( signed int uIconID )
+    {
   TextureFrameTable *v3; // ebx@1
   unsigned int i; // edi@3
 
-  result = uIconID;
   v3 = this;
-  if ( (signed int)uIconID <= (signed int)this->uNumTextures && (uIconID & 0x80000000u) == 0 )
+  if ( (uIconID <= this->sNumTextures) && uIconID >= 0 )
   {
     for ( i = uIconID; ; ++i )
     {
@@ -296,12 +294,13 @@
       auto pTex = (v3->pTextures[i].uTextureID != -1 ? &pBitmaps_LOD->pTextures[v3->pTextures[i].uTextureID] : 0);
       if (pTex)
         pTex->palette_id2 = pPaletteManager->LoadPalette(pTex->palette_id1);
-      result = (unsigned int)v3->pTextures;
-      if ( !(*(char *)(result + i * 20 + 18) & 1) )
+      //result = (unsigned int)v3->pTextures;
+      //if ( !(*(char *)(result + i * 20 + 18) & 1) )
+      if( v3->pTextures[i].uFlags&1)
         break;
     }
   }
-  return result;
+  return;
 }
 
 //----- (0044E163) --------------------------------------------------------
@@ -315,7 +314,7 @@
   v2 = this;
   v3 = 0;
   uID = 0;
-  if ( (signed int)this->uNumTextures <= 0 )
+  if ( (signed int)this->sNumTextures <= 0 )
   {
 LABEL_4:
     result = -1;
@@ -326,7 +325,7 @@
     {
       ++uID;
       ++v3;
-      if ( (signed int)uID >= (signed int)v2->uNumTextures )
+      if ( (signed int)uID >= (signed int)v2->sNumTextures )
         goto LABEL_4;
     }
     result = uID;
@@ -384,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;
 }
 
@@ -397,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;
@@ -504,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	Fri Mar 22 01:29:25 2013 +0600
+++ b/Texture.h	Fri Mar 22 01:29:46 2013 +0600
@@ -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;
@@ -105,17 +105,17 @@
   inline TextureFrameTable()
   {
     pTextures = 0;
-    uNumTextures = 0;
+    sNumTextures = 0;
   }
   int FromFileTxt(const char *Args);
   void ToFile();
   void FromFile(void *pSerialized);
-  unsigned int LoadAnimationSequenceAndPalettes(unsigned int uIconID);
+  void LoadAnimationSequenceAndPalettes(signed int uIconID);
   unsigned int GetFrameTexture(int uFrameID, signed int a3);
   unsigned int FindTextureByName(const char *Str2);
 
 
-  unsigned int uNumTextures;
+  signed int sNumTextures;
   struct TextureFrame *pTextures;
 };
 #pragma pack(pop)
@@ -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	Fri Mar 22 01:29:25 2013 +0600
+++ b/UIBooks.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -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;
@@ -1146,9 +1146,9 @@
         }
     else
         {
-        v6 = viewparams->field_38;
-        v86 = viewparams->field_38;
-        v84 = viewparams->field_3A;
+        v6 = viewparams->indoor_center_x;
+        v86 = viewparams->indoor_center_x;
+        v84 = viewparams->indoor_center_y;
         if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
             v5 = viewparams->field_2C - 34;
         }
@@ -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	Fri Mar 22 01:29:25 2013 +0600
+++ b/UICharacter.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -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/UIHouses.h	Fri Mar 22 01:29:25 2013 +0600
+++ b/UIHouses.h	Fri Mar 22 01:29:46 2013 +0600
@@ -37,7 +37,7 @@
 char *__cdecl JailDialog();
 void  MagicShopDialog();
 void  GuildDialog();
-int __cdecl sub_4B6478();
+void  sub_4B6478();
 bool __fastcall sub_4B68EA(int a1);
 void __cdecl TravelByTransport();
 void TempleDialog();
--- a/UiGame.cpp	Fri Mar 22 01:29:25 2013 +0600
+++ b/UiGame.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -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/Viewport.cpp	Fri Mar 22 01:29:25 2013 +0600
+++ b/Viewport.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -14,7 +14,6 @@
     unsigned int br_x; // esi@1
     unsigned int tl_y; // edi@3
     unsigned int br_y; // eax@3
-    int v10; // eax@7
 
     tl_x = sTL_X;
     br_x = sBR_X;
@@ -25,7 +24,7 @@
         }
     tl_y = sTL_Y;
     br_y = sBR_Y;
-    if ( (signed int)sTL_Y > (signed int)sBR_Y )
+    if ( sTL_Y > sBR_Y )
         {
         br_y = sBR_Y ^ sTL_Y ^ sBR_Y;                           // swap y's 
         tl_y = br_y ^ sBR_Y ^ sTL_Y;
@@ -150,13 +149,13 @@
 
 
     v1 = this;
-    v2 = this->field_3A;
+    v2 = this->indoor_center_y;
     v3 = 88 >> this->field_2C / 384;
     v4 = (44 - v3) << 9;
     if ( v1->sViewCenterY > v2 + v4 )
         v1->sViewCenterY = v2 + v4;
 
-    v5 = v1->field_38;
+    v5 = v1->indoor_center_x;
     v6 = (v3 - 44) << 9;
     if ( v1->sViewCenterX < v5 + v6 )
         v1->sViewCenterX = v5 + v6;
@@ -179,80 +178,60 @@
 //----- (00443365) --------------------------------------------------------
 void ViewingParams::_443365()
     {
-    ViewingParams *v1; // esi@1
-    __int16 *v2; // edi@3
+  
     Vec3_short_ *v3; // eax@4
-    unsigned int v4; // edx@4
-    signed int v5; // eax@8
     Vec3_short_ *v6; // eax@12
-    signed int v7; // edi@12
-    signed int v8; // eax@16
-    char v9; // zf@20
-    int result; // eax@21
-    unsigned int v11; // [sp+4h] [bp-1Ch]@3
-    unsigned int *v12; // [sp+8h] [bp-18h]@3
-    unsigned int v13; // [sp+Ch] [bp-14h]@8
-    unsigned int v14; // [sp+10h] [bp-10h]@2
-    unsigned int v15; // [sp+14h] [bp-Ch]@2
-    unsigned int v16; // [sp+18h] [bp-8h]@2
-    unsigned int v17; // [sp+1Ch] [bp-4h]@2
+    int minimum_y; // [sp+10h] [bp-10h]@2
+    int maximum_y; // [sp+14h] [bp-Ch]@2
+    int minimum_x; // [sp+18h] [bp-8h]@2
+     int maximum_x; // [sp+1Ch] [bp-4h]@2
 
-    v1 = this;
+ 
     InitGrayPalette();
     if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
         {
-        v16 = 0x40000000u;
-        v14 = 0x40000000u;
-        v17 = 0xC0000000u;
-        v15 = 0xC0000000u;
-        if ( (signed int)pIndoor->pMapOutlines->uNumOutlines > 0 )
+        minimum_x = 0x40000000;
+        minimum_y = 0x40000000;
+
+        maximum_x = -0x40000000;
+        maximum_y = -0x40000000;
+        for (int i=0; i<pIndoor->pMapOutlines->uNumOutlines; ++i)
             {
-            v2 = (__int16 *)(pIndoor->pMapOutlines->pOutlines);
-            v11 = pIndoor->pMapOutlines->uNumOutlines;
-            v12 = (uint *)pIndoor->pMapOutlines->pOutlines;
-            do
-                {
-                v3 = &pIndoor->pVertices[*v2];
-                v4 = v3->x;
-                if ( (signed int)v4 < (signed int)v16 )
-                    v16 = v3->x;
-                if ( (signed int)v4 > (signed int)v17 )
-                    v17 = v3->x;
-                v5 = v3->y;
-                v13 = v5;
-                if ( v5 < (signed int)v14 )
-                    v14 = v4;
-                if ( v5 > (signed int)v15 )
-                    v15 = v4;
-                v6 = &pIndoor->pVertices[v2[1]];
-                v7 = v6->x;
-                if ( v7 < (signed int)v16 )
-                    v16 = v4;
-                if ( v7 > (signed int)v17 )
-                    v17 = v4;
-                v8 = v6->y;
-                if ( v8 < (signed int)v14 )
-                    v14 = v13;
-                if ( v8 > (signed int)v15 )
-                    v15 = v13;
-                v2 = (__int16 *)(v12 + 3);
-                v9 = v11-- == 1;
-                v12 += 3;
-                }
-                while ( !v9 );
+            v3 = &pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uFace1ID];
+
+            if ( v3->x < minimum_x )
+                minimum_x = v3->x;
+            if ( v3->x > maximum_x )
+                maximum_x = v3->x;
+            if ( v3->y < minimum_y )
+                minimum_y = v3->x;
+            if ( v3->y > maximum_y )
+                maximum_y = v3->x;
+
+            v6 = &pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uFace2ID];
+
+            if ( v6->x < minimum_x )
+                minimum_x = v3->x;
+            if ( v6->x > maximum_x )
+                maximum_x = v3->x;
+ 
+            if ( v6->y < minimum_y )
+                minimum_y = v3->y;
+            if ( v6->y > maximum_y )
+                maximum_y = v3->y;
             }
-        v1->uMinimapZoom = 1024;
-        v1->field_38 = (signed int)(v16 + v17) / 2;
-        v1->field_28 = 10;
-        result = (signed int)(v14 + v15) / 2;
-        v1->field_3A = result;
+
+        uMinimapZoom = 1024;
+        indoor_center_x = (signed int)(minimum_x + maximum_x) / 2;
+        field_28 = 10;
+        indoor_center_y = (signed int)(minimum_y + maximum_y) / 2;
         }
     else
         {
-        v1->field_38 = 0;
-        v1->field_3A = 0;
-        v1->uMinimapZoom = dword_576E2C;
-        v1->field_28 = dword_576E28;
+        indoor_center_x = 0;
+        indoor_center_y = 0;
+        uMinimapZoom = dword_576E2C;
+        field_28 = dword_576E28;
         }
-    v1->field_2C = 384;
+    field_2C = 384;
     }
\ No newline at end of file
--- a/Viewport.h	Fri Mar 22 01:29:25 2013 +0600
+++ b/Viewport.h	Fri Mar 22 01:29:46 2013 +0600
@@ -67,8 +67,8 @@
   int field_2C;
   int sViewCenterX;
   int sViewCenterY;
-  __int16 field_38;
-  __int16 field_3A;
+  __int16 indoor_center_x;
+  __int16 indoor_center_y;
   int field_3C;
   unsigned int uTextureID_LocationMap;
   int bRedrawGameUI;
--- a/mm7_1.cpp	Fri Mar 22 01:29:25 2013 +0600
+++ b/mm7_1.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -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	Fri Mar 22 01:29:25 2013 +0600
+++ b/mm7_2.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -4777,13 +4777,13 @@
     v4 = v24;
   }
   v5 = v2->pTextures;
-  v2->uNumTextures = v4;
+  v2->sNumTextures = v4;
   v6 = pAllocator->AllocNamedChunk(v5, 20 * v4, "Txt Frames");
   v2->pTextures = (TextureFrame *)v6;
   if ( !v6 )
     Abortf("CTextureFrameTable::load - Out of Memory!");
   v7 = File;
-  v2->uNumTextures = 0;
+  v2->sNumTextures = 0;
   fseek(v7, 0, 0);
   for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
   {
@@ -4791,23 +4791,23 @@
     memcpy(&v21, txt_file_frametable_parser(&Buf, &v20), 0x7Cu);
     if ( v21 && *Str1 != 47 )
     {
-      strcpy(v2->pTextures[v2->uNumTextures].pTextureName, Str1);
-      v2->pTextures[v2->uNumTextures].uAnimTime = atoi(Str);
+      strcpy(v2->pTextures[v2->sNumTextures].pTextureName, Str1);
+      v2->pTextures[v2->sNumTextures].uAnimTime = atoi(Str);
       v9 = 2;
-      for ( v2->pTextures[v2->uNumTextures].uFlags = 0; v9 < v21; ++v9 )
+      for ( v2->pTextures[v2->sNumTextures].uFlags = 0; v9 < v21; ++v9 )
       {
         if ( !_strcmpi((&Str1)[4 * v9], "New") )
         {
-          v10 = (int)&v2->pTextures[v2->uNumTextures].uFlags;
+          v10 = (int)&v2->pTextures[v2->sNumTextures].uFlags;
           *(char *)v10 |= 2u;
         }
       }
-      ++v2->uNumTextures;
+      ++v2->sNumTextures;
     }
   }
   fclose(File);
   v11 = 0;
-  if ( (signed int)(v2->uNumTextures - 1) > 0 )
+  if ( (signed int)(v2->sNumTextures - 1) > 0 )
   {
     v12 = 0;
     do
@@ -4818,9 +4818,9 @@
       ++v11;
       ++v12;
     }
-    while ( v11 < (signed int)(v2->uNumTextures - 1) );
-  }
-  for ( j = 0; j < (signed int)v2->uNumTextures; *(short *)(Argsa + 16) = v16 )
+    while ( v11 < (signed int)(v2->sNumTextures - 1) );
+  }
+  for ( j = 0; j < (signed int)v2->sNumTextures; *(short *)(Argsa + 16) = v16 )
   {
     v15 = v2->pTextures;
     Argsa = (int)&v15[j];
@@ -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	Fri Mar 22 01:29:25 2013 +0600
+++ b/mm7_3.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -8220,7 +8220,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;
@@ -8424,7 +8424,7 @@
   {
     v19 = v3->pTexture;
     v84 = 0;
-    v18 = (unsigned __int16 *)v19->pLevelOfDetail0;
+    v18 = (unsigned __int16 *)v19->pLevelOfDetail0_prolly_alpha_mask;
   }
   a1.pTextureLOD = v18;
 LABEL_16:
@@ -8880,7 +8880,7 @@
   {
     v22 = v5->pTexture;
     v75 = 0;
-    v21 = (unsigned __int16 *)v22->pLevelOfDetail0;
+    v21 = (unsigned __int16 *)v22->pLevelOfDetail0_prolly_alpha_mask;
   }
   a1.pTextureLOD = v21;
 LABEL_12:
@@ -9137,7 +9137,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;
@@ -9313,7 +9313,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;
@@ -9538,7 +9538,7 @@
   else
   {
     v16 = 0;
-    v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail0;
+    v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail0_prolly_alpha_mask;
   }
   sr.pTextureLOD = v17;
 LABEL_14:
@@ -9888,7 +9888,7 @@
   {
     v21 = v5->pTexture;
     v49 = 0;
-    pLOD = v21->pLevelOfDetail0;
+    pLOD = v21->pLevelOfDetail0_prolly_alpha_mask;
   }
   a1a.pTextureLOD = (unsigned __int16 *)pLOD;
 LABEL_12:
@@ -12328,8 +12328,8 @@
   v19 = (double)viewparams->field_2C * 0.000015258789;
   if ( viewparams->field_2C == 384 )
   {
-    v20 = viewparams->field_38;
-    v21 = viewparams->field_3A;
+    v20 = viewparams->indoor_center_x;
+    v21 = viewparams->indoor_center_y;
   }
   v17 = 0;
   v16 = pOutdoor->uNumBModels;
@@ -12478,7 +12478,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;
 }
@@ -12643,7 +12643,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);
@@ -13213,7 +13213,7 @@
   }
   if ( npcid >= 5000 )
     goto LABEL_7;
-  if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
+  if ( sDialogue_SpeakingActorNPC_ID >= 0 )
   {
     *(int *)a2 = 0;
     result = 0;
@@ -15758,7 +15758,7 @@
       v21->uCurrentActionTime += pMiscTimer->uTimeElapsed;
       if ( (signed int)v28 > 0 )
         v21->pMonsterInfo.uRecoveryTime = v28 - v27;
-      if ( (v21->pMonsterInfo.uRecoveryTime & 0x80000000u) != 0 )
+      if ( v21->pMonsterInfo.uRecoveryTime< 0 )
         v21->pMonsterInfo.uRecoveryTime = 0;
       v29 = v21->uAttributes;
       if ( !(v29 & 0x8000) )
--- a/mm7_4.cpp	Fri Mar 22 01:29:25 2013 +0600
+++ b/mm7_4.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -5758,10 +5758,10 @@
 
 
 //----- (004AD504) --------------------------------------------------------
-int __fastcall sub_4AD504(unsigned int uFaceID)
+int __fastcall sub_4AD504(signed int sFaceID)
 {
   int result; // eax@1
-  unsigned int v2; // ebx@1
+  signed int v2; // ebx@1
   BLVFace *v3; // esi@3
   Texture *v4; // edi@6
   int v5; // eax@7
@@ -5885,17 +5885,17 @@
   unsigned int v123; // [sp+A0h] [bp-4h]@13
 
   result = pRenderer->uTargetSurfacePitch;
-  v2 = uFaceID;
+  v2 = sFaceID;
   v95 = pRenderer->uTargetSurfacePitch;
-  if ( (uFaceID & 0x80000000u) == 0 )
-  {
-    if ( (signed int)uFaceID < (signed int)pIndoor->uNumFaces )
-    {
-      v3 = &pIndoor->pFaces[uFaceID];
-      v91 = &pIndoor->pFaces[uFaceID];
+  if ( sFaceID >= 0 )
+  {
+    if ( sFaceID < (signed int)pIndoor->uNumFaces )
+    {
+      v3 = &pIndoor->pFaces[sFaceID];
+      v91 = &pIndoor->pFaces[sFaceID];
       if ( !pRenderer->pRenderD3D )
       {
-        result = sub_423B5D(uFaceID);
+        result = sub_423B5D(sFaceID);
         if ( result )
         {
           result = sub_424829(result, &stru_F8A590, pBLVRenderParams->field_7C, v2);
@@ -5926,7 +5926,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;
@@ -6408,7 +6408,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;
@@ -9458,7 +9458,7 @@
 
 			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
 
-			if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
+			if ( sDialogue_SpeakingActorNPC_ID >= 0 )
 				pDialogue_SpeakingActor->uAIState = Removed;
 			if ( uActiveCharacter )
 				pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0);
@@ -9679,8 +9679,8 @@
 
 
 //----- (004B6478) --------------------------------------------------------
-int __cdecl sub_4B6478()
-{
+void sub_4B6478()
+    {
   GUIWindow *v0; // ebx@1
   Player *v1; // edi@1
   unsigned int v2; // eax@1
@@ -9787,7 +9787,7 @@
       ++pMessageQueue_50CBD0->uNumMessages;
     }*/
     pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v5);
-    return result; // void func
+    return; // void func
   }
   if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v1->_guilds_member_bits, word_4F0754[2 * (unsigned int)window_SpeakInHouse->ptr_1C]) )
   {
@@ -9795,13 +9795,12 @@
     v25 = v31;
     v26 = pFontArrus->CalcTextHeight(pNPCTopics[171].pText, &v28, 0, 0);
     v28.DrawTitleText(pFontArrus, 0, (212 - v26) / 2 + 101, v25, v24, 3u);
-    result = (int)pDialogueWindow;
     pDialogueWindow->pNumPresenceButton = 0;
-    return result;
-  }
-  result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-  if ( !result )
-    return result;
+    return ;
+  }
+
+  if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
+    return;
   v8 = pDialogueWindow;
   v33 = 0;
   v34 = 0;
@@ -9832,17 +9831,18 @@
     strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
     v22 = v31;
     v23 = pFontArrus->CalcTextHeight(pTmpBuf, &v28, 0, 0);
-    return (int)v28.DrawTitleText(pFontArrus, 0, (174 - v23) / 2 + 138, v22, pTmpBuf, 3u);
+    v28.DrawTitleText(pFontArrus, 0, (174 - v23) / 2 + 138, v22, pTmpBuf, 3u);
+    return; 
   }
   sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v32);
   v28.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
   v32 = (149 - v33) / v34;
   if ( (149 - v33) / v34 > 32 )
     v32 = 32;
-  result = v8->pStartingPosActiveItem;
-  v35 = result;
+
+  v35 = v8->pStartingPosActiveItem;
   v34 = (149 - v34 * v32 - v33) / 2 - v32 / 2 + 162;
-  if ( result < result + v8->pNumPresenceButton )
+  if ( v8->pStartingPosActiveItem < v8->pStartingPosActiveItem+ v8->pNumPresenceButton )
   {
     v33 = 2;
     do
@@ -9880,11 +9880,10 @@
       v8 = v29;
       ++v35;
       ++v33;
-      result = v29->pNumPresenceButton + v29->pStartingPosActiveItem;
-    }
-    while ( v35 < result );
-  }
-  return result;
+    }
+    while ( v35 <v29->pNumPresenceButton + v29->pStartingPosActiveItem );
+  }
+  return;
 }
 
 
@@ -10831,7 +10830,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	Fri Mar 22 01:29:25 2013 +0600
+++ b/mm7_5.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -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;
@@ -6631,7 +6625,7 @@
 
   v1 = uPlayerID - 1;
   v8 = uPlayerID;
-  if ( ((uPlayerID - 1) & 0x80000000u) == 0 )
+  if ( (uPlayerID - 1) >= 0 )
   {
     v2 = &pPlayers[uPlayerID];
     v3 = (*v2)->GetRace();
@@ -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	Fri Mar 22 01:29:25 2013 +0600
+++ b/mm7_6.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -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	Fri Mar 22 01:29:25 2013 +0600
+++ b/mm7_data.cpp	Fri Mar 22 01:29:46 2013 +0600
@@ -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	Fri Mar 22 01:29:25 2013 +0600
+++ b/mm7_data.h	Fri Mar 22 01:29:46 2013 +0600
@@ -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();
@@ -2276,7 +2276,7 @@
 struct Vec4_int_ *__thiscall sub_4AC277(unsigned int _this, Vec4_int_ *a2);
 struct Vec4_int_ *__thiscall sub_4AC33A_get_cpu_clocks_QPC(int _this, Vec4_int_ *a1);
 struct Vec4_int_ *__thiscall sub_4AC4FD_get_cpu_clocks_rdtsc(int _this, Vec4_int_ *a1);
-int __fastcall sub_4AD504(unsigned int uFaceID);
+int __fastcall sub_4AD504(signed int uFaceID);
 void __fastcall sub_4ADD1D(int uFaceID);
 int __fastcall sub_4AE1E7(int a1, int a2, int a3);
 int __fastcall sub_4AE313(int viewport_space_x, int viewport_space_y, struct stru337_stru0 *p);