changeset 1294:6bbd50bda571

Слияние
author Ritor1
date Mon, 17 Jun 2013 09:09:30 +0600
parents 557c0c3cc314 (current diff) d8033eb56d7e (diff)
children 86a83e12d795
files Indoor.cpp Indoor_stuff.h UIHouses.cpp UITransition.cpp mm7_1.cpp mm7_3.cpp stru367.h
diffstat 29 files changed, 911 insertions(+), 1514 deletions(-) [+]
line wrap: on
line diff
--- a/DecalBuilder.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/DecalBuilder.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -9,6 +9,7 @@
 
 #include "stru9.h"
 
+#include "Outdoor_stuff.h"
 
 
 struct DecalBuilder *pDecalBuilder = new DecalBuilder;
--- a/GUIWindow.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/GUIWindow.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -29,8 +29,36 @@
 
 #include "mm7_data.h"
 
+typedef struct _RGBColor
+    {
+    unsigned char R;
+    unsigned char B;
+    unsigned char G;
+    }RGBColor;
 
 
+std::array<RGBColor, 20> spell_tooltip_colors={{ 
+    {0x96, 0xD4, 0xFF},
+    {0xFF, 0x80, 0x00},
+    {0xFF, 0xFF, 0x9B},
+    {0xE1, 0xE1, 0xE1},
+    {0x80, 0x80, 0x80},
+    {0x96, 0xD4, 0xFF},
+    {0xFF, 0x55, 0x00},
+    {0x96, 0xD4, 0xFF},
+    {0xFF, 0x55, 0x00},
+    {0xE1, 0xE1, 0xE1},
+    {0xFF, 0x55, 0x00},
+    {0x96, 0xD4, 0xFF},
+    {0xEB, 0x0F, 0xFF},
+    {0xFF, 0x80, 0x00},
+    {0x96, 0xD4, 0xFF},
+    {0x80, 0x80, 0x80},
+    {0xFF, 0x55, 0x00},
+    {0x00, 0x80, 0xFF},
+    {0x00, 0x80, 0xFF},
+    {0x96, 0xD4, 0xFF}}};
+
 
 int pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[1]; // idb
 struct GUIWindow *pWindow_MainMenu;
@@ -46,11 +74,11 @@
 
 
 //----- (004141CA) --------------------------------------------------------
-void ModalWindow(const char *pStr, int a4)
-{
+void ModalWindow( const char *pStrHint, int a4 )
+    {
   pEventTimer->Pause();
   dword_506F0C[0] = pCurrentScreen;
-  ptr_507BDC = GUIWindow::Create(0, 0, 640, 480, WINDOW_FinalWindow, a4, (int)pStr);
+  ptr_507BDC = GUIWindow::Create(0, 0, 640, 480, WINDOW_FinalWindow, a4, pStrHint);
   pCurrentScreen = SCREEN_PRESS_ESCAPE_MESSAGE;
 }
 // 4E28F8: using guessed type int pCurrentScreen;
@@ -180,79 +208,41 @@
 //----- (0041D73D) --------------------------------------------------------
 void GUIWindow::_41D73D_draw_buff_tooltip()
     {
-  GUIFont *v1; // esi@1
-  GUIWindow *v2; // edi@1
-  SpellBuff *v3; // eax@1
-  unsigned int v4; // eax@5
-  int v5; // ecx@5
-  unsigned int v6; // eax@5
-  unsigned int v7; // ecx@5
-  char *v8; // ebx@7
-  unsigned int v9; // eax@8
-  unsigned int v10; // ecx@8
-  __int64 v11; // ST28_8@11
-  int v12; // esi@11
-  const char *v13; // ST0C_4@11
-  unsigned int v14; // eax@11
-  char **v16; // [sp+14h] [bp-10h]@7
-  GUIFont *a2; // [sp+18h] [bp-Ch]@1
-  SpellBuff *v18; // [sp+1Ch] [bp-8h]@7
-  int v19; // [sp+20h] [bp-4h]@1
-  int v20; // [sp+20h] [bp-4h]@7
+ 
+  __int64 remaing_time; // ST28_8@11
+  unsigned short text_color;
+  int Y_pos; // esi@11
+  int string_count; // [sp+20h] [bp-4h]@7
+
+
+  string_count = 0;
+  for (int i=0; i<20; ++i)
+    if ( pParty->pPartyBuffs[i].uExpireTime > 0i64 )
+      ++string_count;
 
-  v1 = pFontComic;
-  v2 = this;
-  a2 = pFontComic;
-  v19 = 0;
-  v3 = pParty->pPartyBuffs;
-  do
+  uFrameHeight = pFontArrus->uFontHeight + 72;
+  uFrameHeight += (string_count - 1) * pFontArrus->uFontHeight;
+  uFrameZ = uFrameWidth + uFrameX - 1;
+  uFrameW = uFrameY + uFrameHeight - 1;
+  DrawMessageBox(0);
+  DrawTitleText(pFontArrus, 0, 12, 0, pGlobalTXT_LocalizationStrings[451], 3u);
+  if ( !string_count )
+     DrawTitleText(pFontComic, 0, 40, 0, pGlobalTXT_LocalizationStrings[153], 3u);
+
+  GetTickCount();
+  string_count = 0;
+  for (int i=0; i<20; ++i)
   {
-    if ( (signed __int64)v3->uExpireTime > 0 )
-      ++v19;
-    ++v3;
+    if ( pParty->pPartyBuffs[i].uExpireTime>0i64 )//!!!
+    {
+      remaing_time = pParty->pPartyBuffs[i].uExpireTime- pParty->uTimePlayed;//!!!
+      Y_pos = string_count * pFontComic->uFontHeight + 40; 
+      text_color = TargetColor(spell_tooltip_colors[i].R, spell_tooltip_colors[i].G, spell_tooltip_colors[i].B);
+      DrawText(pFontComic, 52, Y_pos, text_color, aSpellNames[i], 0, 0, 0);
+      sub_41D20D_buff_remaining_time_string(Y_pos, this, remaing_time, pFontComic); 
+      ++string_count;
+        }
   }
-  while ( (signed int)v3 < (signed int)pParty->pPlayers );
-  v4 = LOBYTE(pFontArrus->uFontHeight) + 72;
-  this->uFrameHeight = v4;
-  v5 = v4 + (v19 - 1) * LOBYTE(pFontArrus->uFontHeight);
-  v6 = v2->uFrameWidth;
-  v2->uFrameHeight = v5;
-  v7 = v2->uFrameHeight;
-  v2->uFrameZ = v6 + v2->uFrameX - 1;
-  v2->uFrameW = v2->uFrameY + v7 - 1;
-  v2->DrawMessageBox(0);
-  v2->DrawTitleText(pFontArrus, 0, 0xCu, 0, pGlobalTXT_LocalizationStrings[451], 3u);
-  if ( !v19 )
-    v2->DrawTitleText(v1, 0, 0x28u, 0, pGlobalTXT_LocalizationStrings[153], 3u);
-  v20 = 0;
-  GetTickCount();
-  v8 = &_4E2B21_buff_spell_tooltip_colors[1];
-  v16 = aSpellNames.data();
-  v18 = pParty->pPartyBuffs;
-  do
-  {
-    v9 = LODWORD(v18->uExpireTime);
-    v10 = HIDWORD(v18->uExpireTime);
-    if ( (v10 & 0x80000000u) == 0 && ((signed int)v10 > 0 || v9) )//!!!
-    {
-      v11 = __PAIR__(v10, v9) - pParty->uTimePlayed;//!!!
-      v12 = v20 * LOBYTE(v1->uFontHeight) + 40;
-      v13 = *v16;
-      ++v20;
-      v14 = TargetColor(
-              (unsigned __int8)*(v8 - 1),
-              (unsigned __int8)*v8,
-              (unsigned __int8)v8[1]);
-      v2->DrawText(a2, 52, v12, v14, v13, 0, 0, 0);
-      sub_41D20D_buff_remaining_time_string(v12, v2, v11, a2);
-      v1 = a2;
-    }
-    ++v18;
-    ++v16;
-    v8 += 3;
-  }
-  while ( (signed int)v18 < (signed int)pParty->pPlayers );
-  
 }
 
 
@@ -1206,7 +1196,8 @@
 
 
 //----- (0044D406) --------------------------------------------------------
-void GUIWindow::DrawTitleText( GUIFont *a2, signed int uHorizontalMargin, unsigned int uVerticalMargin, unsigned __int16 uDefaultColor, const char *pInString, unsigned int uLineSpacing )
+void GUIWindow::DrawTitleText( GUIFont *a2, signed int uHorizontalMargin, unsigned int uVerticalMargin, unsigned __int16 uDefaultColor, 
+                               const char *pInString, unsigned int uLineSpacing )
 {
   GUIWindow *pWindow; // esi@1
   unsigned int v8; // ebx@1
@@ -1383,7 +1374,7 @@
                   pRenderer->DrawTextPalette(
                     v12,
                     v13,
-                    v17,
+                    (unsigned char*)v17,
                     v16,
                     LOBYTE(v10->uFontHeight),
                     v10->pFontPalettes[0],
@@ -1409,11 +1400,11 @@
 
 
 //----- (0044CB4F) --------------------------------------------------------
-int GUIWindow::DrawTextInRect(GUIFont *a2, unsigned int uX, unsigned int uY, unsigned int uColor, const char *Str1, int Source, int a8)
-{
-  GUIFont *pFont; // edi@1
+int GUIWindow::DrawTextInRect( GUIFont *pFont, unsigned int uX, unsigned int uY, unsigned int uColor, const char *text, int rect_width, int reverse_text )
+    {
+
   int pLineWidth; // ebx@1
-  int v11; // esi@3
+  int text_width; // esi@3
   unsigned __int8 v12; // cl@7
   signed int v13; // esi@19
   signed int v14; // ebx@19
@@ -1423,11 +1414,11 @@
   int v18; // ecx@23
   int v19; // ecx@24
   unsigned int v20; // ecx@26
-  int v21; // eax@28
+  unsigned char* v21; // eax@28
   int v22; // ebx@34
   int v23; // eax@34
   int v24; // ebx@36
-  char Str; // [sp+Ch] [bp-20h]@34
+  char Str[6]; // [sp+Ch] [bp-20h]@34
   char v26; // [sp+Fh] [bp-1Dh]@34
   char v27; // [sp+11h] [bp-1Bh]@35
   int v28; // [sp+20h] [bp-Ch]@17
@@ -1437,144 +1428,114 @@
   size_t Str1b; // [sp+40h] [bp+14h]@19
   const char *Sourcea; // [sp+44h] [bp+18h]@20
   int v34; // [sp+48h] [bp+1Ch]@26
+  int i;
 
-  pFont = a2;
+
   pWindow = this;
-  pNumLen = strlen(Str1);
-  pLineWidth = pFont->GetLineWidth(Str1);
-  if ( pLineWidth < Source )
+  pNumLen = strlen(text);
+  pLineWidth = pFont->GetLineWidth(text);
+  if ( pLineWidth < rect_width )
   {
-    pWindow->DrawText(pFont, uX, uY, uColor, Str1, 0, 0, 0);
+    pWindow->DrawText(pFont, uX, uY, uColor, text, 0, 0, 0);
     return pLineWidth;
   }
-  strcpy(pTmpBuf2.data(), Str1);
-  v11 = 0;
-  if ( a8 )
+  strcpy(pTmpBuf2.data(), text);
+  text_width = 0;
+  if ( reverse_text )
     _strrev(pTmpBuf2.data());
   Str1a = 0;
-  if ( (signed int)pNumLen > 0 )
-  {
-    do
+  for (i=0; i<pNumLen; ++i)
     {
-      if ( v11 >= Source )
+      if ( text_width >= rect_width )
         break;
-      if ( pFont->IsCharValid(v12 = pTmpBuf2[Str1a]) )
+      v12 = pTmpBuf2[i];
+      if ( pFont->IsCharValid(v12) )
       {
-        if ( v12 < 9u )
-        {
-          if ( (signed int)Str1a > 0 )
-            v11 += pFont->pMetrics[v12].uLeftSpacing;
-          v11 += *((int *)&pFont->cFirstChar + 3 * v12 + 9);
-          if ( (signed int)Str1a < (signed int)pNumLen )
-            v11 += pFont->pMetrics[v12].uRightSpacing;
-          goto LABEL_16;
-        }
-        if ( v12 > 0xAu )//10
-        {
-          if ( v12 == 12 )
+      switch (v12)
           {
-            Str1a += 5;
-          }
-          else
-          {
-            if ( v12 != 13 )
-            {
-              if ( (signed int)Str1a > 0 )
-                v11 += pFont->pMetrics[v12].uLeftSpacing;
-              v11 += *((int *)&pFont->cFirstChar + 3 * v12 + 9);
-              if ( (signed int)Str1a < (signed int)pNumLen )
-                v11 += pFont->pMetrics[v12].uRightSpacing;
-            }
-          }
-        }
+      case '\t':// Horizontal tab 09
+      case '\n': //Line Feed 0A 10
+      case '\r': //Form Feed, page eject  0C 12
+          break;
+      case '\f': //Carriage Return 0D 13
+          i += 5;	  
+          break;
+      default:
+          if ( i > 0 )
+            text_width += pFont->pMetrics[v12].uLeftSpacing;
+          text_width += pFont->pMetrics[v12].uWidth;
+          if ( i < pNumLen )
+              text_width += pFont->pMetrics[v12].uRightSpacing;
+          }       
       }
-LABEL_16:
-      ++Str1a;
     }
-    while ( (signed int)Str1a < (signed int)pNumLen );
-  }
-  pTmpBuf2[Str1a - 1] = 0;
+  pTmpBuf2[i - 1] = 0;
+
+
   pNumLen = strlen(pTmpBuf2.data());
   v28 = pFont->GetLineWidth(pTmpBuf2.data());
-  if ( a8 )
+  if ( reverse_text )
     _strrev(pTmpBuf2.data());
-  Str1b = 0;
+
   v13 = uX + pWindow->uFrameX;
   v14 = uY + pWindow->uFrameY;
-  if ( (signed int)pNumLen > 0 )
+  for (i=0; i<pNumLen; ++i)
   {
-    Sourcea = &pTmpBuf2[1];
-    do
-    {
-      if ( pFont->IsCharValid(v15 = pTmpBuf2[Str1b]) )
+      v15 = pTmpBuf2[i];
+      if ( pFont->IsCharValid(v15) )
       {
-        v16 = v15;
-        v17 = v15 - 9;
-        if ( v17 )//>0
-        {
-          v18 = v17 - 1;
-          if ( v18 )//>0
+      switch (v12)
+          {
+      case '\t':// Horizontal tab 09
+          {
+          strncpy(Str,  &pTmpBuf2[i+1], 3);
+          Str[3] = 0;
+       //   atoi(Str);
+          i += 3;
+          break;
+          }
+      case '\n': //Line Feed 0A 10
+          {
+          v24 = pFont->uFontHeight;
+          v13 = uX;
+          uY = uY + pFont->uFontHeight - 3;
+          v14 = uY+pFont->uFontHeight - 3;
+          break;
+          }
+      case '\r': //Form Feed, page eject  0C 12
           {
-            v19 = v18 - 2;
-            if ( v19 )//>0
-            {
-              if ( v19 == 1 )//v15 == 13
-              {
-                strncpy(&Str, Sourcea, 3u);
-                v26 = 0;
-                Str1b += 3;
-                Sourcea += 3;
-                v22 = atoi(&Str);
-                v23 = pFont->GetLineWidth(&pTmpBuf2[Str1b]);
-                v13 = pWindow->uFrameZ - v23 - v22;
-                v14 = uY;
-              }
-              else//v15 > 13
-              {
-                v20 = *((int *)&pFont->cFirstChar + 3 * v16 + 9);
-                v34 = *((int *)&pFont->cFirstChar + 3 * v16 + 9);
-                if ( (signed int)Str1b > 0 )
-                  v13 += pFont->pMetrics[v16].uLeftSpacing;
-                v21 = (int)((char *)&pFont[1] + pFont->font_pixels_offset[v16]);
-                if ( (short)uColor )
-                  pRenderer->DrawText(v13, v14, (unsigned __int8 *)v21, v20, LOBYTE(pFont->uFontHeight), pFont->pFontPalettes[0], uColor, 0);
-                else
-                  pRenderer->DrawTextPalette(v13, v14, v21, v20, LOBYTE(pFont->uFontHeight), pFont->pFontPalettes[0], 0);
-                v13 += v34;
-                if ( (signed int)Str1b < (signed int)pNumLen )
-                  v13 += pFont->pMetrics[(unsigned __int8)pTmpBuf2[Str1b]].uRightSpacing;
-              }
-            }
-            else//v15 == 12
-            {
-              strncpy(&Str, Sourcea, 5u);
-              v27 = 0;
-              Str1b += 5;
-              Sourcea += 5;
-              uColor = atoi(&Str);
-            }
+          strncpy(Str, &pTmpBuf2[i+1], 5);
+          Str[5] = 0;
+          i += 5;
+          uColor = atoi(Str);
+          break;
+          }
+      case '\f': //Carriage Return 0D 13
+          {
+          strncpy(Str, &pTmpBuf2[i+1], 3);
+          Str[3] = 0;
+          i += 3;
+          v23 = pFont->GetLineWidth(&pTmpBuf2[i]);
+          v13 = pWindow->uFrameZ - v23 - atoi(Str);
+          v14 = uY;
+          break;
           }
-          else//v15 == 10
-          {
-            v24 = LOBYTE(pFont->uFontHeight);
-            v13 = uX;
-            uY = uY + v24 - 3;
-            v14 = v24 + uY - 3;
-          }
-        }
-        else//v15 == 9
-        {
-          strncpy(&Str, Sourcea, 3u);
-          v26 = 0;
-          atoi(&Str);
-          Str1b += 3;
-          Sourcea += 3;
-        }
+      default:
+          v20 = pFont->pMetrics[v15].uWidth;
+          if ( i > 0 )
+              v13 += pFont->pMetrics[v15].uLeftSpacing;
+          v21 = &pFont->pFontData[pFont->font_pixels_offset[v15]];
+          if ( uColor )
+              pRenderer->DrawText(v13, v14,  v21, v20, pFont->uFontHeight, pFont->pFontPalettes[0], uColor, 0);
+          else
+              pRenderer->DrawTextPalette(v13, v14, v21, v20, pFont->uFontHeight, pFont->pFontPalettes[0], 0);
+          v13 += v20;
+          if ( i < (signed int)pNumLen )
+              v13 += pFont->pMetrics[v15].uRightSpacing;
+          }       
       }
-      ++Str1b;
-      ++Sourcea;
-    }
-    while ( (signed int)Str1b < (signed int)pNumLen );
+      
+   
   }
   return v28;
 }
@@ -1597,25 +1558,23 @@
 
   pButton = (GUIButton *)pAllocator->AllocNamedChunk(0, 0xBCu, "BUTTON");
   pButton->pParent = this;
-  pButton->uX = uX + this->uFrameX;
-  v13 = uY + this->uFrameY;
+  pButton->uWidth = uWidth;
   pButton->uHeight = uHeight;
-  pButton->uY = v13;
-  pButton->uWidth = uWidth;
+  
   if ( a6 == 2 && !uHeight )
     pButton->uHeight = uWidth;
-  v14 = pButton->uX;
+
   pButton->uButtonType = a6;
-  v15 = v14 + uWidth - 1;
-  pButton->uZ = v15;
-  v17 = pButton->uY;
+  pButton->uX = uX + this->uFrameX;
+  pButton->uY = uY + this->uFrameY;
+  pButton->uZ = pButton->uX + uWidth - 1;
+  pButton->uW = pButton->uY + uHeight - 1;
   pButton->field_2C_is_pushed = 0;
-  pButton->uW = v17 + uHeight - 1;
   pButton->field_1C = a7;
   pButton->msg = msg;
   pButton->msg_param = msg_param;
   pButton->uHotkey = uHotkey;
-  strlen(pName);
+  //strlen(pName);
   strcpy(pButton->pButtonName, pName);
   va_start(texturs_ptr, pName);
   while  (NULL!=(pTextures=va_arg(texturs_ptr, Texture *)))
@@ -1637,20 +1596,15 @@
 }
 
 //----- (00459C2B) --------------------------------------------------------
-void GUIWindow::DrawFlashingInputCursor(signed int a3, int a4, GUIFont *a2)
-{
-  signed int v4; // esi@1
-  GUIWindow *v5; // edi@1
-
-  v4 = a3;
-  v5 = this;
+void GUIWindow::DrawFlashingInputCursor( signed int uX, int uY, struct GUIFont *a2 )
+    {
   if ( GetTickCount() % 1000 > 500 )
-    DrawText(a2, v4, a4, 0, "_", 0, 0, 0);
+    DrawText(a2, uX, uY, 0, "_", 0, 0, 0);
 }
 
 //----- (0041C432) --------------------------------------------------------
-GUIWindow *GUIWindow::Create(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, WindowType eWindowType, int pButton, int a5)
-{
+GUIWindow * GUIWindow::Create( unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, enum WindowType eWindowType, int pButton, const char* hint )
+    {
   unsigned int uNextFreeWindowID; // ebp@1
   //int *v8; // eax@1
   //GUIWindow *pWindow; // esi@4
@@ -1679,15 +1633,16 @@
 
   auto pWindow = &pWindowList[uNextFreeWindowID];
   pWindow->uFrameWidth = uWidth;
+  pWindow->uFrameHeight = uHeight;
+
+  pWindow->uFrameX = uX;
+  pWindow->uFrameY = uY;
   pWindow->uFrameZ = uX + uWidth - 1;
   pWindow->uFrameW = uY + uHeight - 1;
+
   pWindow->ptr_1C = (void *)pButton;
-  pWindow->Hint = (char *)a5;
-  //v10 = uNumVisibleWindows;
-  pWindow->uFrameX = uX;
-  //++v10;
-  pWindow->uFrameY = uY;
-  pWindow->uFrameHeight = uHeight;
+  pWindow->Hint = hint;
+  
   pWindow->eWindowType = eWindowType;
   pWindow->receives_keyboard_input = false;
   ++uNumVisibleWindows;
@@ -1699,10 +1654,11 @@
     {
       switch (eWindowType)
       {
-        case WINDOW_Book:
+        case WINDOW_Book: {
           pWindow->InitializeBookView();
           break;
-        case WINDOW_Dialogue:
+          }
+        case WINDOW_Dialogue: {
           pMainScreenNum = pCurrentScreen;
           pCurrentScreen = SCREEN_NPC_DIALOGUE;
           pBtn_ExitCancel = pWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], //"Exit"
@@ -1794,8 +1750,8 @@
             pWindow->_41D08F_set_keyboard_control_group(num_menu_buttons, 1, 0, 1);
           }
           break;
-
-        case WINDOW_ChangeLocation:
+            }
+        case WINDOW_ChangeLocation: {
           pMainScreenNum = pCurrentScreen;
           pCurrentScreen = SCREEN_CHANGE_LOCATION;
           pBtn_ExitCancel = pWindow->CreateButton(                  566,                   445,  75,  33, 1, 0, UIMSG_CHANGE_LOCATION_ClickCencelBtn, 0, 'N', pGlobalTXT_LocalizationStrings[156], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);//   
@@ -1803,16 +1759,19 @@
                             pWindow->CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0],  63,  73, 1, 0, UIMSG_OnTravelByFoot, 1, ' ', pWindow->Hint, 0, 0, 0);
                             pWindow->CreateButton(                    8,                     8, 460, 344, 1, 0, UIMSG_OnTravelByFoot, 1,   0, pWindow->Hint, 0);
           break;
-
-        case WINDOW_SpellBook: //   
+            }
+        case WINDOW_SpellBook: {//   
           InitializeBookTextures();
           pWindow->OpenSpellBook();
           break;
-        case WINDOW_GreetingNPC: //   
+            }
+        case WINDOW_GreetingNPC: {//   
           pMainScreenNum = pCurrentScreen;
           pKeyActionMap->EnterText(0, 15, pWindow);
           pCurrentScreen = SCREEN_BRANCHLESS_NPC_DIALOG;
           break;
+            }
+
       }
       return pWindow;
     }
@@ -1842,7 +1801,7 @@
           if ( v26 || !dword_591080 )
             v27 = HouseNPCData[v26 +1 - (dword_591080 != 0)]->pName;
           else
-            v27 = (char *)p2DEvents[pButton - 1].pProprieterName;
+            v27 = (char*)p2DEvents[pButton - 1].pProprieterName;
           v30 = v27;
           v29 = (char*)pGlobalTXT_LocalizationStrings[435];
         }
@@ -1879,7 +1838,6 @@
       return pWindow;
     }
     if (eWindowType == WINDOW_Scroll)
-      //goto LABEL_62;
     {
       pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, '1', "", 0);
       pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, '2', "", 0);
--- a/GUIWindow.h	Mon Jun 17 09:09:03 2013 +0600
+++ b/GUIWindow.h	Mon Jun 17 09:09:30 2013 +0600
@@ -253,21 +253,21 @@
 /*  298 */
 enum WindowType: unsigned __int32
 {
-  WINDOW_null = 0,
-  WINDOW_MainMenu = 1,
-  WINDOW_OptionsButtons = 3,
+  WINDOW_null            = 0,
+  WINDOW_MainMenu        = 1,
+  WINDOW_OptionsButtons  = 3,
   WINDOW_CharacterRecord = 4,
-  WINDOW_Options = 6,
-  WINDOW_8 = 8,
-  WINDOW_Book = 9,
-  WINDOW_Dialogue = 10,
+  WINDOW_Options         = 6,
+  WINDOW_8               = 8,
+  WINDOW_Book            = 9,
+  WINDOW_Dialogue       = 10,
   WINDOW_QuickReference = 12,
-  WINDOW_F = 15,
-  WINDOW_Rest = 16,
+  WINDOW_F              = 15,
+  WINDOW_Rest           = 16,
   WINDOW_ChangeLocation = 17,
-  WINDOW_SpellBook = 0x12,
-  WINDOW_GreetingNPC = 19,
-  WINDOW_Chest = 0x14,
+  WINDOW_SpellBook      = 18,
+  WINDOW_GreetingNPC    = 19,
+  WINDOW_Chest          = 20,
   WINDOW_22 = 0x16,
   WINDOW_SaveLoadButtons = 23,
   WINDOW_MainMenu_Load = 0x18,
@@ -326,8 +326,8 @@
 
   GUIButton *CreateButton(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, int a6, int a7, 
 	                      UIMessageType msg, unsigned int msg_param, unsigned __int8 uHotkey, const char *pName, struct Texture *pTextures, ...);
-  void DrawFlashingInputCursor(signed int a3, int a4, struct GUIFont *a2);
-  int DrawTextInRect(GUIFont *a2, unsigned int uX, unsigned int uY, unsigned int uColor, const char *Str1, int Source, int a8);
+  void DrawFlashingInputCursor(signed int uX, int uY, struct GUIFont *a2);
+  int DrawTextInRect(GUIFont *pFont, unsigned int uX, unsigned int uY, unsigned int uColor, const char *text, int rect_width, int reverse_text);
   void DrawText(GUIFont *a2, signed int uX, int uY, unsigned int uFontColor, const char *Str, int a7, int a8, unsigned int uFontShadowColor);
   void DrawTitleText(GUIFont *a2, signed int uHorizontalMargin, unsigned int uVerticalMargin, unsigned __int16 uDefaultColor, const char *pInString, unsigned int uLineSpacing);
   void DrawCurrentTime(__int64 a2);
@@ -340,7 +340,7 @@
   void _41D08F_set_keyboard_control_group(int a2, int a3, int a4, int a5);
   void _41D73D_draw_buff_tooltip();
 
-  static GUIWindow *Create(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, enum WindowType eType, int a4, int a5);
+  static GUIWindow *Create(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, enum WindowType eWindowType, int pButton, const char* hint);
 
   unsigned int uFrameX;
   unsigned int uFrameY;
@@ -363,7 +363,7 @@
   int numVisibleWindows;
   int receives_keyboard_input_2; //  0  no input   1 currently typing   2 enter pressed   3 escape pressed
   int receives_keyboard_input;
-  char *Hint;
+  const char *Hint;
   GUIButton *pControlsHead;
   GUIButton *pControlsTail;
 };
@@ -464,7 +464,7 @@
 
 
 
-void ModalWindow(const char *pStr, int a4);
+void ModalWindow(const char *pStrHint, int a4);
 
 
 
--- a/Game.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/Game.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -25,6 +25,7 @@
 #include "Viewport.h"
 #include "Time.h"
 #include "Outdoor.h"
+#include "Outdoor_stuff.h"
 #include "Overlays.h"
 #include "AudioPlayer.h"
 #include "LOD.h"
--- a/Indoor.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/Indoor.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -347,7 +347,7 @@
 		  v4 = pRenderer->uTargetSurfacePitch * pNode->field_C._viewport_space_y;
 		  if ( pNode->field_C._viewport_space_y <= pNode->field_C._viewport_space_w )
 		  {
-			//v5 = (char *)&pBspRenderer->nodes[0].field_C.viewport_right_side[pNode->field_C._viewport_space_y + v7];
+			//v5 = (char *)&pBspRenderer->nodes[0].field_C.array_3D8[pNode->field_C._viewport_space_y + v7];
 			v5 = &pNode->field_C.viewport_right_side[pNode->field_C._viewport_space_y];
 			v8 = &pNode->field_C.viewport_left_side[pNode->field_C._viewport_space_y];
 			do
@@ -1259,8 +1259,8 @@
   //stru170 *v4; // ebx@1
   //BLVFace *v5; // eax@1
   //int v6; // ecx@2
-  unsigned __int16 TransitionSectorID; // ax@11
-  //Vec3_short_ *v8; // esi@15
+  unsigned __int16 v7; // ax@11
+  Vec3_short_ *v8; // esi@15
   int v9; // edx@15
   //signed int v10; // eax@18
   //signed int v11; // edi@19
@@ -1326,16 +1326,16 @@
                                           + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y
                                           + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) // we sure are standing at the portal plane
       {
-        TransitionSectorID = pFace->uSectorID;
-        if ( nodes[0].uSectorID == TransitionSectorID )  // draw back sector
-          TransitionSectorID = pFace->uBackSectorID;
-        nodes[num_nodes].uSectorID = TransitionSectorID;
+        v7 = pFace->uSectorID;
+        if ( nodes[0].uSectorID == v7 )  // draw back sector
+          v7 = pFace->uBackSectorID;
+        nodes[num_nodes].uSectorID = v7;
         nodes[num_nodes].uFaceID = uFaceID;
         nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX;
         nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ;
         nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY;
         nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW;
-        nodes[num_nodes].field_C.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY,
+        nodes[num_nodes].field_C._43F9E1(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY,
                                          pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW);
         AddBspNodeToRenderList(++num_nodes - 1);
         return;
@@ -1344,10 +1344,10 @@
       //v6 = a0;
     }
 
-    //  
-    v9 = pFace->pFacePlane_old.vNormal.x * (pIndoor->pVertices[pFace->pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x)
-       + pFace->pFacePlane_old.vNormal.y * (pIndoor->pVertices[pFace->pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y)
-       + pFace->pFacePlane_old.vNormal.z * (pIndoor->pVertices[pFace->pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z);
+    v8 = &pIndoor->pVertices[pFace->pVertexIDs[0]];
+    v9 = pFace->pFacePlane_old.vNormal.x * (v8->x - pBLVRenderParams->vPartyPos.x)
+       + pFace->pFacePlane_old.vNormal.y * (v8->y - pBLVRenderParams->vPartyPos.y)
+       + pFace->pFacePlane_old.vNormal.z * (v8->z - pBLVRenderParams->vPartyPos.z);
     if (p->uSectorID != pFace->uSectorID)
       v9 = -v9;
     if (v9 >= 0)
@@ -1491,7 +1491,7 @@
         v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ);
         v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY);
         v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW);
-        v3->nodes[v3->num_nodes++].field_C.GetViewportData(
+        v3->nodes[v3->num_nodes++].field_C._43F9E1(
           SLOWORD(pBLVRenderParams->uViewportX),
           pBLVRenderParams->uViewportY,
           SLOWORD(pBLVRenderParams->uViewportZ),
--- a/LightmapBuilder.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/LightmapBuilder.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -2,6 +2,7 @@
 #include "Game.h"
 #include "stru314.h"
 #include "Outdoor.h"
+#include "Outdoor_stuff.h"
 #include "Log.h"
 
 #include "OutdoorCamera.h"
--- a/MM7.h	Mon Jun 17 09:09:03 2013 +0600
+++ b/MM7.h	Mon Jun 17 09:09:30 2013 +0600
@@ -1,8 +1,5 @@
 #pragma once
-#include <math.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string>
+#include <array>
 
 typedef unsigned int uint;
 
@@ -15,15 +12,6 @@
 typedef unsigned __int64 _QWORD;
 
 
-#include "VectorTypes.h"
-#include "IndoorCameraD3D.h"
-
-
-
-
-
-
-
 /*  288 */
 /*#pragma pack(push, 1)
 struct CheckHRESULT_stru0
--- a/Outdoor.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/Outdoor.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -9,6 +9,7 @@
 #include "Sprites.h"
 #include "LightmapBuilder.h"
 #include "Outdoor.h"
+#include "Outdoor_stuff.h"
 #include "Party.h"
 #include "SpriteObject.h"
 #include "LOD.h"
--- a/Outdoor.h	Mon Jun 17 09:09:03 2013 +0600
+++ b/Outdoor.h	Mon Jun 17 09:09:30 2013 +0600
@@ -2,7 +2,6 @@
 
 #include "Indoor.h"
 #include "TileFrameTable.h"
-#include "Outdoor_stuff.h"
 
 #define DAY_ATTRIB_FOG  1
 
--- a/Outdoor_stuff.h	Mon Jun 17 09:09:03 2013 +0600
+++ b/Outdoor_stuff.h	Mon Jun 17 09:09:30 2013 +0600
@@ -1,6 +1,8 @@
 #pragma once
+#include "VectorTypes.h"
+#include <array>
 
-
+struct ODMFace;
 
 
 /*  141 */
--- a/Player.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/Player.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -138,75 +138,61 @@
 
 
 //----- (00490913) --------------------------------------------------------
-signed int __cdecl PlayerCreation_ComputeAttributeBonus()
+signed int __cdecl PlayerCreation_GetUnspentAttributePointCount()
 {
   signed int v0; // edi@1
-  signed int v1; // esi@1
-  int v2; // ebx@2
-  int v3; // ecx@17
+  int raceId; // ebx@2
   signed int v4; // eax@17
   int v5; // edx@18
   signed int v6; // ecx@18
-  signed int v8; // [sp+Ch] [bp-8h]@1
-  signed int v9; // [sp+10h] [bp-4h]@2
-
-  v8 = 50;
+  signed int remainingStatPoints; // [sp+Ch] [bp-8h]@1
+
+  remainingStatPoints = 50;
   v0 = 50;
-  v1 = 0;
-  do
-  {
-    v9 = 0;
-    v2 = 7 * pParty->pPlayers[v1].GetRace();
-    do
-    {
-      if ( v9 )
+  for (int playerNum = 0; playerNum < 4; playerNum++)
+  {
+    raceId = pParty->pPlayers[playerNum].GetRace();
+    for (int statNum = 0; statNum <= 6; statNum++)
+    {
+      switch ( statNum )
       {
-        switch ( v9 )
-        {
-          case 1:
-            v0 = pParty->pPlayers[v1].uIntelligence;
-            break;
-          case 2:
-            v0 = pParty->pPlayers[v1].uWillpower;
-            break;
-          case 3:
-            v0 = pParty->pPlayers[v1].uEndurance;
-            break;
-          case 4:
-            v0 = pParty->pPlayers[v1].uAccuracy;
-            break;
-          case 5:
-            v0 = pParty->pPlayers[v1].uSpeed;
-            break;
-          case 6:
-            v0 = pParty->pPlayers[v1].uLuck;
-            break;
-        }
+      case 0:
+        v0 = pParty->pPlayers[playerNum].uMight;
+        break;
+      case 1:
+        v0 = pParty->pPlayers[playerNum].uIntelligence;
+        break;
+      case 2:
+        v0 = pParty->pPlayers[playerNum].uWillpower;
+        break;
+      case 3:
+        v0 = pParty->pPlayers[playerNum].uEndurance;
+        break;
+      case 4:
+        v0 = pParty->pPlayers[playerNum].uAccuracy;
+        break;
+      case 5:
+        v0 = pParty->pPlayers[playerNum].uSpeed;
+        break;
+      case 6:
+        v0 = pParty->pPlayers[playerNum].uLuck;
+        break;
+      }
+      v4 = StatTable[raceId][statNum].uBaseValue;
+      if ( v0 >= v4 )
+      {
+        v5 = StatTable[raceId][statNum].uDroppedStep;
+        v6 = StatTable[raceId][statNum].uBaseStep;
       }
       else
       {
-        v0 = pParty->pPlayers[v1].uMight;
-      }
-      v3 = v2 + v9;
-      v4 = StatTable[0][v3].uBaseValue;
-      if ( v0 >= v4 )
-      {
-        v5 = StatTable[0][v3].uDroppedStep;
-        v6 = StatTable[0][v3].uBaseStep;
+        v5 = StatTable[raceId][statNum].uBaseStep;
+        v6 = StatTable[raceId][statNum].uDroppedStep;
       }
-      else
-      {
-        v5 = StatTable[0][v3].uBaseStep;
-        v6 = StatTable[0][v3].uDroppedStep;
-      }
-      v8 += v5 * (v4 - v0) / v6;
-      ++v9;
-    }
-    while ( v9 <= 6 );
-    ++v1;
-  }
-  while ( v1 < 4 );
-  return v8;
+      remainingStatPoints += v5 * (v4 - v0) / v6;
+    }
+  }
+  return remainingStatPoints;
 }
 
 
@@ -214,9 +200,9 @@
 //----- (00427730) --------------------------------------------------------
 bool Player::CanCastSpell(unsigned int uRequiredMana)
 {
-  if (sMana >= uRequiredMana)
-  {
-    sMana -= uRequiredMana;
+  if (sMana >= (signed int)uRequiredMana)
+  {
+    sMana -= (signed int)uRequiredMana;
     return true;
   }
 
@@ -273,56 +259,48 @@
 }
 
 //----- (004B807C) --------------------------------------------------------
-int Player::_4B807C(float a2)
-{
-  Player *v2; // edi@1
-  unsigned int v3; // eax@1
-  int v4; // esi@1
-  unsigned int v5; // ebx@7
+int Player::GetTempleHealCostModifier(float a2)
+{
+  unsigned int conditionIdx; // eax@1
+  int conditionTimeMultiplier; // esi@1
   int v6; // eax@8
-  signed __int64 v7; // qax@13
-  unsigned int v9; // [sp-4h] [bp-14h]@4
-  signed int v10; // [sp+8h] [bp-8h]@4
-  int v11; // [sp+Ch] [bp-4h]@6
-
-  v2 = this;
-  v3 = GetMajorConditionIdx();
-  v4 = 0;
-  if ( (signed int)v3 >= 14 )
-  {
-    if ( (signed int)v3 <= 15 )
-    {
-      v10 = 5;
-      v9 = v3;
-      goto LABEL_6;
-    }
-    if ( v3 == 16 )
-    {
-      v10 = 10;
-      v9 = 16;
-LABEL_6:
-      v11 = GetConditionDayOfWeek(v9);
-      goto LABEL_13;
-    }
-  }
-  v10 = 1;
-  v5 = 0;
-  do
-  {
-    v6 = GetConditionDayOfWeek(v5);
-    if ( v6 > v4 )
-      v4 = v6;
-    ++v5;
-  }
-  while ( (signed int)v5 <= 13 );
-  v11 = v4;
-  if ( !v4 )
-    v11 = 1;
-LABEL_13:
-  v7 = (signed __int64)((double)v11 * (double)v10 * a2);
-  if ( (signed int)v7 < 1 )
-    LODWORD(v7) = 1;
-  return v7;
+  signed int result; // qax@13
+  signed int baseConditionMultiplier; // [sp+8h] [bp-8h]@4
+
+  conditionIdx = GetMajorConditionIdx();
+  if ( conditionIdx >= 14 && conditionIdx <= 16)
+  {
+    if ( conditionIdx <= 15 )
+    {
+      baseConditionMultiplier = 5;
+    }
+    if ( conditionIdx == 16 )
+    {
+      baseConditionMultiplier = 10;
+    }
+    conditionTimeMultiplier = GetConditionDayOfWeek(conditionIdx);
+  }
+  else if (conditionIdx < 14)
+  {
+    baseConditionMultiplier = 1;
+    conditionTimeMultiplier = 0;
+    for (int i = 0; i <= 13; i++)
+    {
+      v6 = GetConditionDayOfWeek(i);
+      if ( v6 > conditionTimeMultiplier )
+        conditionTimeMultiplier = v6;
+    }
+    if ( !conditionTimeMultiplier )
+      conditionTimeMultiplier = 1;
+  }
+  else{
+    conditionTimeMultiplier = 1;
+    baseConditionMultiplier = 1;
+  }
+  result = (int)((double)conditionTimeMultiplier * (double)baseConditionMultiplier * a2);
+  if ( result < 1 )
+    result = 1;
+  return result;
 }
 
 //----- (004B8102) --------------------------------------------------------
@@ -331,7 +309,7 @@
   signed int v3; // esi@1
   signed int result; // eax@3
 
-  v3 = (unsigned __int64)(signed __int64)((double)uRealValue / (price_multiplier + 2.0)) + uRealValue * GetMerchant() / 100;
+  v3 = (signed int)((signed __int64)((double)uRealValue / (price_multiplier + 2.0)) + uRealValue * GetMerchant() / 100);
   if ( v3 > uRealValue )
     v3 = uRealValue;
   result = 1;
@@ -343,7 +321,7 @@
 //----- (004B8142) --------------------------------------------------------
 int Player::GetBuyingPrice(unsigned int uRealValue, float price_multiplier)
 {
-  uint price = ((100 - GetMerchant()) * (uRealValue * price_multiplier)) / 100;
+  uint price = (uint)(((100 - GetMerchant()) * (uRealValue * price_multiplier)) / 100);
   assert (price > 0);
 
   if (price < uRealValue)
@@ -358,7 +336,7 @@
   int v3; // ecx@1
   signed int result; // eax@3
 
-  v2 = (signed __int64)(a2 * 50.0);
+  v2 = (signed int)(a2 * 50.0);
   v3 = v2 * (100 - GetMerchant()) / 100;
   if ( v3 < v2 / 3 )
     v3 = v2 / 3;
@@ -375,7 +353,7 @@
   int v4; // ecx@1
   signed int result; // eax@3
 
-  v3 = (signed __int64)((double)a2 / (6.0 - a3));
+  v3 = (signed int)((double)a2 / (6.0 - a3));
   v4 = v3 * (100 - GetMerchant()) / 100;
   if ( v4 < v3 / 3 )
     v4 = v3 / 3;
@@ -386,46 +364,46 @@
 }
 
 //----- (004B8213) --------------------------------------------------------
-int Player::_4B8213(int a2, float a3)
-{
-  signed __int64 v3; // qax@1
-
-  v3 = (signed __int64)((double)a2 / (a3 + 2.0));
-  if ( (signed int)v3 < 1 )
-    LODWORD(v3) = 1;
+int Player::GetBaseSellingPrice(int a2, float a3)
+{
+  signed int v3; // qax@1
+
+  v3 = (signed int)((double)a2 / (a3 + 2.0));
+  if ( v3 < 1 )
+    v3 = 1;
   return v3;
 }
 
 //----- (004B8233) --------------------------------------------------------
-int Player::_4B8233(int a2, float a3)
-{
-  signed __int64 v3; // qax@1
-
-  v3 = (signed __int64)((double)a2 * a3);
-  if ( (signed int)v3 < 1 )
-    LODWORD(v3) = 1;
+int Player::GetBaseBuyingPrice(int a2, float a3)
+{
+  signed int v3; // qax@1
+
+  v3 = (signed int)((double)a2 * a3);
+  if ( v3 < 1 )
+    v3 = 1;
   return v3;
 }
 
 //----- (004B824B) --------------------------------------------------------
-int Player::_4B824B(float a2)
-{
-  signed __int64 v2; // qax@1
-
-  v2 = (signed __int64)(a2 * 50.0);
-  if ( (signed int)v2 < 1 )
-    LODWORD(v2) = 1;
+int Player::GetBaseIdentifyPrice(float a2)
+{
+  signed int v2; // qax@1
+
+  v2 = (signed int)(a2 * 50.0);
+  if ( v2 < 1 )
+    v2 = 1;
   return v2;
 }
 
 //----- (004B8265) --------------------------------------------------------
-int Player::_4B8265(int a2, float a3)
-{
-  signed __int64 v3; // qax@1
-
-  v3 = (signed __int64)((double)a2 / (6.0 - a3));
-  if ( (signed int)v3 < 1 )
-    LODWORD(v3) = 1;
+int Player::GetBaseRepairPrice(int a2, float a3)
+{
+  signed int v3; // qax@1
+
+  v3 = (signed int)((double)a2 / (6.0 - a3));
+  if ( v3 < 1 )
+    v3 = 1;
   return v3;
 }
 
@@ -434,30 +412,27 @@
 
 
 //----- (004B6FF9) --------------------------------------------------------
-int Player::_4B6FF9()
-{
-  Player *v1; // esi@1
+int Player::IsPlayerHealableByTemple()
+{
   signed int v2; // eax@1
-  char v3; // zf@4
-
-  v1 = this;
   v2 = (signed int)window_SpeakInHouse->ptr_1C;
-  if ( (v2 == 78 || v2 > 80) && v2 <= 82 )
-  {
-    if ( GetMajorConditionIdx() == 18 )
-      goto LABEL_6;
-    v3 = GetMajorConditionIdx() == 17;
+
+  if ( this->sHealth < GetMaxHealth() || this->sMana < GetMaxMana() )
+  {
+    return 1;
+  }
+  else if (GetMajorConditionIdx() == 18)
+  {
+    return 0;
+  }
+  else if (GetMajorConditionIdx() == 17 && (v2 == 78 || v2 > 80) && v2 <= 82)
+  {
+    return 0;
   }
   else
   {
-    v3 = GetMajorConditionIdx() == 18;
-  }
-  if ( !v3 )
     return 1;
-LABEL_6:
-  if ( v1->sHealth < GetMaxHealth() || v1->sMana < GetMaxMana() )
-    return 1;
-  return 0;
+  }
 }
 
 
@@ -6367,78 +6342,43 @@
 //----- (004903C9) --------------------------------------------------------
 PLAYER_SKILL_TYPE Player::GetSkillIdxByOrder(signed int order)
 {
-  PLAYER_SKILL_TYPE result; // eax@5
-  int v3; // edx@5
-  char *v4; // ecx@5
-  int v5; // esi@11
-  unsigned __int16 *v6; // edx@11
-  int v7; // esi@18
-  unsigned __int16 *pActiveSkill; // edx@18
-
-  if ( order >= 0 )
-  {
-    if ( order <= 1 )
-    {
-      result = (PLAYER_SKILL_TYPE)0;
-      v7 = 0;
-      pActiveSkill = this->pActiveSkills;
-      do
-      {
-        if ( *pActiveSkill && pSkillAvailabilityPerClass[classType / 4][result] == 2 )
-        {
-          if ( v7 == order )
-            return result;
-          ++v7;
-        }
-        result = (PLAYER_SKILL_TYPE)((int)result + 1);
-        ++pActiveSkill;
-      }
-      while ( (signed int)result < 37 );
-    }
-    else
-    {
-      if ( order <= 3 )
-      {
-        result = (PLAYER_SKILL_TYPE)0;
-        v5 = 0;
-        pActiveSkill = this->pActiveSkills;
-        do
-        {
-          if ( *pActiveSkill && pSkillAvailabilityPerClass[classType / 4][result] == 1 )
-          {
-            if ( v5 == order - 2 )
-              return result;
-            ++v5;
-          }
-          result = (PLAYER_SKILL_TYPE)((int)result + 1);
-          ++pActiveSkill;
-        }
-        while ( (signed int)result < 37 );
-      }
-      else
-      {
-        if ( order <= 12 )
-        {
-          result = (PLAYER_SKILL_TYPE)0;
-          v3 = 0;
-          v4 = (char *)pSkillAvailabilityPerClass[classType / 4];
-          do
-          {
-            if ( *v4 == 1 )
-            {
-              if ( v3 == order - 4 )
-                return result;
-              ++v3;
-            }
-            result = (PLAYER_SKILL_TYPE)((int)result + 1);
-            ++v4;
-          }
-          while ( (signed int)result < 37 );
-        }
-      }
-    }
-  }
-  return (PLAYER_SKILL_TYPE)37;
+  int counter; // edx@5
+  bool canBeInactive;
+  unsigned char requiredValue;
+  signed int offset;
+
+  if ( order <= 1 )
+  {
+    canBeInactive = false;
+    requiredValue = 2;  // 2 - primary skill
+    offset = 0;
+  }
+  else if ( order <= 3 )
+  {
+    canBeInactive = false;
+    requiredValue = 1;  // 1 - available
+    offset = 2;
+  }
+  else if ( order <= 12 )
+  {
+    canBeInactive = true;
+    requiredValue = 1;  // 1 - available
+    offset = 4;
+  }
+  else
+  {
+    return (PLAYER_SKILL_TYPE)37;
+  }
+  counter = 0;
+  for (int i = 0; i < 37; i++)
+  {
+    if ( (this->pActiveSkills[i] || canBeInactive) && pSkillAvailabilityPerClass[classType / 4][i] == requiredValue )
+    {
+      if ( counter == order - offset )
+        return (PLAYER_SKILL_TYPE)i;
+      ++counter;
+    }
+  }
 }
 
 
@@ -6459,157 +6399,100 @@
   pDroppedStep = StatTable[0][v2].uDroppedStep;
   uMinValue = pBaseValue - 2;
   pStep = StatTable[0][v2].uBaseStep;
-    switch ( eAttribute )
-    {
-      case CHARACTER_ATTRIBUTE_STRENGTH:
-        if ( this->uMight <= pBaseValue )
-          pStep = pDroppedStep;
-        if ( this->uMight - pStep >= uMinValue )
-         this->uMight -= pStep;
-        break;
-	  case CHARACTER_ATTRIBUTE_INTELLIGENCE:
-        if ( this->uIntelligence <= pBaseValue )
-          pStep = pDroppedStep;
-        if ( this->uIntelligence - pStep >= uMinValue )
-          this->uIntelligence -= pStep;
-        break;
-      case CHARACTER_ATTRIBUTE_WILLPOWER:
-        if ( this->uWillpower <= pBaseValue )
-          pStep = pDroppedStep;
-        if ( this->uWillpower - pStep >= uMinValue )
-          this->uWillpower -= pStep;
-        break;
-      case CHARACTER_ATTRIBUTE_ENDURANCE:
-        if ( this->uEndurance <= pBaseValue )
-          pStep = pDroppedStep;
-        if ( this->uEndurance - pStep >= uMinValue )
-          this->uEndurance -= pStep;
-        break;
-      case CHARACTER_ATTRIBUTE_ACCURACY:
-        if ( this->uAccuracy <= pBaseValue )
-          pStep = pDroppedStep;
-        if ( this->uAccuracy - pStep >= uMinValue )
-          this->uAccuracy -= pStep;
-        break;
-      case CHARACTER_ATTRIBUTE_SPEED:
-        if ( this->uSpeed <= pBaseValue )
-          pStep = pDroppedStep;
-        if ( this->uSpeed - pStep >= uMinValue )
-          this->uSpeed -= pStep;
-        break;
-      case CHARACTER_ATTRIBUTE_LUCK:
-		if ( this->uLuck <= pBaseValue )
-          pStep = pDroppedStep;
-        if ( this->uLuck - pStep >= uMinValue )
-          this->uLuck -= pStep;
-        break;
-    }
+  unsigned short* AttrToChange = nullptr;
+  switch ( eAttribute )
+  {
+    case CHARACTER_ATTRIBUTE_STRENGTH:
+      AttrToChange = &this->uMight;
+      break;
+    case CHARACTER_ATTRIBUTE_INTELLIGENCE:
+      AttrToChange = &this->uIntelligence;
+      break;
+    case CHARACTER_ATTRIBUTE_WILLPOWER:
+      AttrToChange = &this->uWillpower;
+      break;
+    case CHARACTER_ATTRIBUTE_ENDURANCE:
+      AttrToChange = &this->uEndurance;
+      break;
+    case CHARACTER_ATTRIBUTE_ACCURACY:
+      AttrToChange = &this->uAccuracy;
+      break;
+    case CHARACTER_ATTRIBUTE_SPEED:
+      AttrToChange = &this->uSpeed;
+      break;
+    case CHARACTER_ATTRIBUTE_LUCK:
+      AttrToChange = &this->uLuck;
+      break;
+  }
+  if ( *AttrToChange <= pBaseValue )
+    pStep = pDroppedStep;
+  if ( *AttrToChange - pStep >= uMinValue )
+    *AttrToChange -= pStep;
 }
 
 //----- (004905F5) --------------------------------------------------------
 //signed int __thiscall PartyCreation_BtnPlusClick(Player *this, int eAttribute)
-int Player::IncreaseAttribute(int eAttribute)
-{
-  Player *v2; // esi@1
-  int v3; // eax@1
-  int v4; // ebx@1
-  signed int v5; // edi@1
-  int v6; // eax@8
-  signed int v7; // eax@17
+void Player::IncreaseAttribute( int eAttribute )
+{
+  int raceId; // eax@1
+  int maxValue; // ebx@1
+  signed int baseStep; // edi@1
+  signed int tmp; // eax@17
   signed int result; // eax@18
-  int v9; // [sp+Ch] [bp-8h]@1
-  signed int v10; // [sp+10h] [bp-4h]@1
-
-  v2 = this;
-  v3 = eAttribute + 7 * GetRace();
-  v4 = StatTable[0][v3].uMaxValue;
-  v5 = StatTable[0][v3].uBaseStep;
-  v9 = StatTable[0][v3].uBaseValue;
-  v10 = StatTable[0][v3].uDroppedStep;
-  PlayerCreation_ComputeAttributeBonus();
-  if ( eAttribute )
-  {
-    switch ( eAttribute )
-    {
-      case 1:
-        v6 = v2->uIntelligence;
-        break;
-      case 2:
-        v6 = v2->uWillpower;
-        break;
-      case 3:
-        v6 = v2->uEndurance;
-        break;
-      case 4:
-        v6 = v2->uAccuracy;
-        break;
-      case 5:
-        v6 = v2->uSpeed;
-        break;
-      case 6:
-        v6 = v2->uLuck;
-        break;
-      default:
-        v6 = eAttribute;
-        break;
-    }
-  }
-  else
-  {
-    v6 = v2->uMight;
-  }
-  if ( v6 < v9 )
-  {
-    v7 = v5;
-    v5 = v10;
-    v10 = v7;
-  }
-  result = PlayerCreation_ComputeAttributeBonus();
-  if ( result >= v10 )
-  {
-    if ( eAttribute )
-    {
-      switch ( eAttribute )
-      {
-        case 1:
-          result = (signed int)&v2->uIntelligence;
-          break;
-        case 2:
-          result = (signed int)&v2->uWillpower;
-          break;
-        case 3:
-          result = (signed int)&v2->uEndurance;
-          break;
-        case 4:
-          result = (signed int)&v2->uAccuracy;
-          break;
-        case 5:
-          result = (signed int)&v2->uSpeed;
-          break;
-        default:
-          result = eAttribute - 6;
-          if ( eAttribute != 6 )
-            return result;
-          result = (signed int)&v2->uLuck;
-          break;
-      }
-    }
-    else
-    {
-      result = (signed int)&v2->uMight;
-    }
-    if ( v5 + *(short *)result <= v4 )
-      *(short *)result += v5;
-  }
-  return result;
+  int baseValue; // [sp+Ch] [bp-8h]@1
+  signed int droppedStep; // [sp+10h] [bp-4h]@1
+  unsigned short* statToChange;
+
+  raceId = GetRace();
+  maxValue = StatTable[raceId][eAttribute].uMaxValue;
+  baseStep = StatTable[raceId][eAttribute].uBaseStep;
+  baseValue = StatTable[raceId][eAttribute].uBaseValue;
+  droppedStep = StatTable[raceId][eAttribute].uDroppedStep;
+  PlayerCreation_GetUnspentAttributePointCount();
+  switch ( eAttribute )
+  {
+  case 0:
+    statToChange = &this->uMight;
+    break;
+  case 1:
+    statToChange = &this->uIntelligence;
+    break;
+  case 2:
+    statToChange = &this->uWillpower;
+    break;
+  case 3:
+    statToChange = &this->uEndurance;
+    break;
+  case 4:
+    statToChange = &this->uAccuracy;
+    break;
+  case 5:
+    statToChange = &this->uSpeed;
+    break;
+  case 6:
+    statToChange = &this->uLuck;
+  default:
+    assert(false);
+    return;
+    break;
+  }
+  if ( *statToChange < baseValue )
+  {
+    tmp = baseStep;
+    baseStep = droppedStep;
+    droppedStep = tmp;
+  }
+  result = PlayerCreation_GetUnspentAttributePointCount();
+  if ( result >= droppedStep )
+  {
+    if ( baseStep + *statToChange <= maxValue )
+      *statToChange += baseStep;
+  }
 }
 
 //----- (0049070F) --------------------------------------------------------
 void Player::Zero()
 {
-  Player *v1; // esi@1
-
-  v1 = this;
   this->sLevelModifier = 0;
   this->sACModifier = 0;
   this->uLuckBonus = 0;
@@ -6629,18 +6512,18 @@
   this->field_E4 = 0;
   this->field_E0 = 0;
   memset(&this->sResFireBonus, 0, 0x16u);
-  v1->field_1A97 = 0;
-  v1->_ranged_dmg_bonus = 0;
-  v1->field_1A95 = 0;
-  v1->_ranged_atk_bonus = 0;
-  v1->field_1A93 = 0;
-  v1->_melee_dmg_bonus = 0;
-  v1->field_1A91 = 0;
-  v1->_some_attack_bonus = 0;
-  v1->_mana_related = 0;
-  v1->uFullManaBonus = 0;
-  v1->_health_related = 0;
-  v1->uFullHealthBonus = 0;
+  this->field_1A97 = 0;
+  this->_ranged_dmg_bonus = 0;
+  this->field_1A95 = 0;
+  this->_ranged_atk_bonus = 0;
+  this->field_1A93 = 0;
+  this->_melee_dmg_bonus = 0;
+  this->field_1A91 = 0;
+  this->_some_attack_bonus = 0;
+  this->_mana_related = 0;
+  this->uFullManaBonus = 0;
+  this->_health_related = 0;
+  this->uFullHealthBonus = 0;
 }
 
 //----- (004907E7) --------------------------------------------------------
@@ -9558,4 +9441,84 @@
   }
 }
 // 5B65C4: using guessed type int dword_5B65C4;
-// 5B65CC: using guessed type int dword_5B65CC;
\ No newline at end of file
+// 5B65CC: using guessed type int dword_5B65CC;
+
+
+//----- (00467E7F) --------------------------------------------------------
+void Player::EquipBody(ITEM_EQUIP_TYPE uEquipType)
+{
+  //unsigned int v1; // esi@1
+  int v2; // ebx@1
+  Player *v3; // eax@1
+  int v4; // edx@1
+  int v5; // esi@2
+  //int v6; // eax@2
+  unsigned int v7; // eax@3
+  ItemGen _this; // [sp+Ch] [bp-30h]@1
+  //Player *v9; // [sp+30h] [bp-Ch]@1
+  int v10; // [sp+34h] [bp-8h]@1
+  int *v11; // [sp+38h] [bp-4h]@1
+
+  static unsigned char byte_4E8398[200] = // 4E8398
+  {
+    1, // EQUIP_OFF_HAND
+    1, // EQUIP_MAIN_HAND
+    2, // EQUIP_BOW
+    3, // EQUIP_ARMOUR
+    0, // EQUIP_SHIELD
+    4, // EQUIP_HELMET
+    5, // EQUIP_BELT
+    6, // EQUIP_CLOAK
+    7, // EQUIP_GAUNTLETS
+    8, // EQUIP_BOOTS
+    10, // EQUIP_RING
+    9, // EQUIP_AMULET
+    1, // EQUIP_WAND
+    0, // EQUIP_REAGENT
+    0, // EQUIP_POTION
+    0, // EQUIP_SPELL_SCROLL
+    0, // EQUIP_BOOK
+    0, // EQUIP_MESSAGE_SCROLL
+    0, // EQUIP_GOLD
+    0, // EQUIP_GEM
+    0, // EQUIP_NONE
+    // ???
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
+    0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0,  0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0,
+    0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0,  0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,  1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0,  0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 3, 3, 3, 3, 3, 3, 1, 1, 1,
+    1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2,  2, 0, 0, 0, 0, 0
+  };
+
+  _this.Reset();
+  v2 = byte_4E8398[uEquipType];
+  v3 = pPlayers[uActiveCharacter];
+  v11 = (int *)&v3->pEquipment.pIndices[v2];
+  v4 = *v11;
+  v10 = *v11;
+  if ( v10 )
+  {
+    memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
+    v5 = (int)((char *)v3 + 4 * (9 * v4 - 9));
+    *(char *)(v5 + 556) = 0;
+    pParty->pPickedItem.Reset();
+    pParty->SetHoldingItem((ItemGen *)(v5 + 532));
+    _this.uBodyAnchor = v2 + 1;
+    memcpy((void *)(v5 + 532), &_this, 0x24u);
+    *v11 = v10;
+  }
+  else
+  {
+    v7 = v3->FindFreeInventorySlot();
+    if (v7 >= 0)
+    {
+      pParty->pPickedItem.uBodyAnchor = v2 + 1;
+      memcpy(&v3->pInventoryItems[v7], &pParty->pPickedItem, sizeof(v3->pInventoryItems[v7]));
+      *v11 = v7 + 1;
+      pMouse->RemoveHoldingItem();
+    }
+  }
+}
\ No newline at end of file
--- a/Player.h	Mon Jun 17 09:09:03 2013 +0600
+++ b/Player.h	Mon Jun 17 09:09:30 2013 +0600
@@ -543,7 +543,7 @@
   void Reset(PLAYER_CLASS_TYPE classType);
   PLAYER_SKILL_TYPE GetSkillIdxByOrder(signed int order);
   void DecreaseAttribute(int eAttribute);
-  int IncreaseAttribute(int eAttribute);
+  void IncreaseAttribute(int eAttribute);
   void Player::Zero();
   unsigned int GetStatColor(int uStat);
   bool DiscardConditionIfLastsLongerThan(unsigned int uCondition, unsigned __int64 uTime);
@@ -575,16 +575,16 @@
   void PlayEmotion(CHARACTER_EXPRESSION_ID expression, int a3);
   void ItemsEnchant(int enchant_count);
   unsigned int GetItemIDAtInventoryIndex(int *a2);
-  int _4B6FF9();
-  int _4B824B(float a2);
-  int _4B8265(int a2, float a3);
-  int _4B8233(int a2, float a3);
-  int _4B8213(int a2, float a3);
+  int IsPlayerHealableByTemple();
+  int GetBaseIdentifyPrice(float a2);
+  int GetBaseRepairPrice(int a2, float a3);
+  int GetBaseBuyingPrice(int a2, float a3);
+  int GetBaseSellingPrice(int a2, float a3);
   int GetPriceRepair(int a2, float a3);
   int GetPriceIdentification(float a2);
   int GetBuyingPrice(unsigned int uRealValue, float price_multiplier);
   int GetPriceSell(int uRealValue, float price_multiplier);
-  int _4B807C(float a2);
+  int GetTempleHealCostModifier(float a2);
   int GetConditionDayOfWeek(unsigned int uCondition);
   bool _43EEF3();
   void SalesProcess(unsigned int inventory_idnx, int item_index, int _2devent_idx);//0x4BE2DD
@@ -592,6 +592,7 @@
   bool CanCastSpell(unsigned int uRequiredMana);
   void PlaySoundBasedOnCondition(int currPlayerId);
   void DrawPlayerBuffAnimBasedOnCondition(int currPlayerId);
+  void EquipBody(ITEM_EQUIP_TYPE uEquipType);
 
   inline bool Weak()       {return pConditions[Condition_Weak] != 0;}
   inline bool Dead()       {return pConditions[Condition_Dead] != 0;}
--- a/Render.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/Render.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -4,6 +4,7 @@
 
 #include <assert.h>
 
+#include "Outdoor_stuff.h"
 #include "VideoPlayer.h"
 #include "Sprites.h"
 #include "Mouse.h"
@@ -9566,8 +9567,8 @@
 }
 
 //----- (004A6AB1) --------------------------------------------------------
-void Render::DrawTextPalette(int x, int y, int a4, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8)
-{
+void Render::DrawTextPalette( int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8 )
+    {
   int v8; // edi@2
   unsigned int v9; // esi@2
   unsigned __int16 *v10; // eax@2
@@ -9600,14 +9601,14 @@
     v8 = a5;
     v9 = a6;
     v10 = &pTargetSurface[x + y * uTargetSurfacePitch];
-    v11 = (unsigned char *)a4;
-    v25 = a4;
+    v11 = (unsigned char *)font_pixels;
+    v25 = (int)font_pixels;
     if ( this->bClip )
     {
       v12 = this->uClipX;
       if ( a2 < (signed int)v12 )
       {
-        v25 = v12 - a2 + a4;
+        v25 = v12 - a2 + (int)font_pixels;
         v10 += v12 - a2;
         v8 = a5 + a2 - v12;
       }
--- a/Render.h	Mon Jun 17 09:09:03 2013 +0600
+++ b/Render.h	Mon Jun 17 09:09:30 2013 +0600
@@ -44,6 +44,7 @@
   unsigned int specular;
   Vec2_float_ texcoord;
 };
+#pragma pack(pop)
 
 class Sprite;
 class SpriteFrame;
@@ -349,7 +350,7 @@
   void DrawTransparentRedShade(unsigned int a2, unsigned int a3, struct Texture *a4);
   void DrawTransparentGreenShade(signed int a2, signed int a3, struct Texture *pTexture);
   void _4A6A68(unsigned int a2, unsigned int a3, struct Texture *a4, __int16 height);
-  void DrawTextPalette(int x, int y, int a4, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8);
+  void DrawTextPalette(int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8);
   void DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned __int16 *pFontPalette, unsigned __int16 uFaceColor, unsigned __int16 uShadowColor);
   void FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16);
   int _4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, struct Vec2_int_ *pBitmapXY, unsigned __int16 *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7);
--- a/UIHouses.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/UIHouses.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -710,7 +710,7 @@
 		  }
 		  else if (uActiveCharacter)
 		  {
-			if ( !pPlayers[uActiveCharacter]->_4B6FF9() )
+			if ( !pPlayers[uActiveCharacter]->IsPlayerHealableByTemple() )
 			  return;
 			v8 = window_SpeakInHouse;
 		  }
@@ -4748,7 +4748,7 @@
     HIDWORD(v59) = TargetColor(0xFFu, 0xFFu, 0x9Bu);
     v1 = pPlayers[uActiveCharacter];
     //v2 = pPlayers[uActiveCharacter]->_4B807C(p2DEvents_minus1__20[13 * (unsigned int)v0->ptr_1C]);
-    v2 = pPlayers[uActiveCharacter]->_4B807C(p2DEvents[v0->par1C - 1].fPriceMultiplier);
+    v2 = pPlayers[uActiveCharacter]->GetTempleHealCostModifier(p2DEvents[v0->par1C - 1].fPriceMultiplier);
     HIDWORD(v60) = v2;
     if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN )
     {
@@ -4920,7 +4920,7 @@
           pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25);
           return;
         }
-        if ( !v1->_4B6FF9() )
+        if ( !v1->IsPlayerHealableByTemple() )
             return;
         v25 = 0;
         if ( pParty->uNumGold < v2 )
@@ -4993,7 +4993,7 @@
     strcpy(a1, "");
     v41->uHeight = 0;
     v41->uY = 0;
-    if ( v1->_4B6FF9() )
+    if ( v1->IsPlayerHealableByTemple() )
         {
         sprintf(a1, "%s %d %s", pGlobalTXT_LocalizationStrings[104], HIDWORD(v60), pGlobalTXT_LocalizationStrings[97]);
         v63 = 0;
--- a/UIMainMenu.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/UIMainMenu.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -313,7 +313,7 @@
         pFontQuick->_44D2FD_prolly_draw_credits_entry(pFontCChar, 0, a2.uFrameHeight, (signed __int16)pTexture2.uWidth, (signed __int16)pTexture2.uHeight, pColor1, 
             pColor2, pString, pTexture2.pPixels, (signed __int16)pTexture2.uWidth);
         free(pString);
-        pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, (int)ptr);
+        pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, ptr);
         pWindow_MainMenu->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_Escape, 0, 0x1Bu, "", 0);
         pCurrentScreen = SCREEN_CREATORS;
         SetCurrentMenuID(MENU_CREDITSPROC);
--- a/UIPartyCreation.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/UIPartyCreation.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -454,7 +454,7 @@
 
   pTextCenter = pFontCreate->AlignText_Center(0x5C, pGlobalTXT_LocalizationStrings[30]);// "Bonus"
   pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 533, 394, uColor1, pGlobalTXT_LocalizationStrings[30], 0, 0, 0);
-  pBonusNum = PlayerCreation_ComputeAttributeBonus();
+  pBonusNum = PlayerCreation_GetUnspentAttributePointCount();
   sprintf(pTmpBuf.data(), "%d", pBonusNum);
   pTextCenter = pFontCreate->AlignText_Center(84, pTmpBuf.data());
   pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 530, 410, uColorWhite, pTmpBuf.data(), 0, 0, 0);
--- a/UIPopup.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/UIPopup.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -2160,7 +2160,7 @@
                 }
             if ( pWindow.Hint )
                 {
-                pHint = pWindow.Hint;
+                pHint = (char*)pWindow.Hint;
                 pWindow.Hint = 0;
                 pWindow.uFrameWidth = 384;
                 pWindow.uFrameHeight = 256;
--- a/UIRest.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/UIRest.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -192,5 +192,6 @@
             Sleep6Hours();
         }
     else
-      GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_CloseRestWindowBtn, (int)pButton_RestUI_Exit, (int)pGlobalTXT_LocalizationStrings[81]); // "Exit Rest"
+      GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_CloseRestWindowBtn, 
+      (int)pButton_RestUI_Exit, pGlobalTXT_LocalizationStrings[81]); // "Exit Rest"
     }
\ No newline at end of file
--- a/UITransition.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/UITransition.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -100,7 +100,7 @@
 LABEL_19:
   strcpy(sHouseName.data(), v21);
 LABEL_20:
-  pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Transition, 0, (int)sHouseName.data());
+  pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Transition, 0, sHouseName.data());
   //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * v9]].field_C) )
   if ( pAnimatedRooms[p2DEvents[anim_id].uAnimationID].uRoomSoundId )
     PlayHouseSound(anim_id, HouseSound_Greeting);
@@ -139,7 +139,7 @@
     sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v1].pName);// "Leave %s"
   else
     strcpy(sHouseName.data(), pGlobalTXT_LocalizationStrings[79]);// "Exit"
-  pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_ChangeLocation, 0, (int)sHouseName.data());
+  pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_ChangeLocation, 0, sHouseName.data());
 }
 
 
--- a/mm7_1.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/mm7_1.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -40,7 +40,6 @@
 #include "TurnEngine.h"
 #include "texts.h"
 #include "UIHouses.h"
-#include "mm7_data.h"
 #include "stru367.h"
 
 int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam);
@@ -1489,487 +1488,21 @@
 //----- (00423B5D) --------------------------------------------------------
 int __fastcall sub_423B5D(unsigned int uFaceID)
 {
-  BLVFace *pFace; // ebx@1
-  //Vec3_short_ *v2; // esi@1
-  //int v3; // ST28_4@1
-  //__int16 v4; // ST2C_2@1
-  //signed int v5; // esi@1
-  //Vec3_short_ *v6; // eax@4
-  //signed int v7; // edi@5
-  //signed int v8; // eax@5
-  //signed int i_; // ecx@10
-  //int v10; // eax@10
-  //int v11; // edx@11
-  //int v12; // ST28_4@12
-  //signed int v13; // edx@12
-  //signed __int64 v14; // qtt@12
-  //int *v15; // ebx@12
-  //int v16; // ST28_4@14
-  //signed int v17; // eax@14
-  //signed __int64 v18; // qtt@14
-  //signed int v19; // edx@15
-  //signed int v20; // edx@17
-  //signed int v21; // ebx@19
-  //signed int v22; // esi@20
-  //int v23; // edi@21
-  int v24; // eax@21
-  //int v25; // eax@22
-  int v26; // eax@22
-  //signed int v27; // ST30_4@24
-  //signed __int64 v28; // qtt@24
-  //int v29; // ST18_4@25
-  int v30; // eax@26
-  //int v31; // eax@27
-  int v32; // eax@27
-  //signed int v33; // ST30_4@29
-  //signed __int64 v34; // qtt@29
-  //int v35; // ST30_4@30
-  signed int for_x_num_vertices; // edi@31
-  //unsigned int v37; // eax@31
-  //bool v38; // edx@31
-  //int v39; // ecx@31
-  //int v40; // ecx@32
-  //int v41; // esi@32
-  int v42; // eax@34
-  signed int for_z_num_vertices; // ebx@41
-  //unsigned int v44; // eax@41
-  //signed int v45; // ecx@42
-  //int v46; // esi@42
-  int v47; // eax@44
-  signed int for_y_num_vertices; // edi@51
-  //unsigned int v49; // eax@51
-  bool v50; // edx@51
-  //int v51; // ecx@51
-  //int v52; // ecx@52
-  //signed int v53; // esi@52
-  int v54; // eax@54
-  int for_w_num_vertices; // ebx@61
-  //unsigned int v56; // eax@61
-  //signed int v57; // ecx@62
-  //int v58; // esi@62
-  int v59; // eax@64
-  char v61; // zf@72
-  signed int v62; // edx@75
-  int v63; // ecx@76
-  int v64; // esi@76
-  int v65; // ecx@83
-  //signed int v66; // [sp+14h] [bp-14h]@3
-  int v67; // [sp+14h] [bp-14h]@34
-  int v68; // [sp+14h] [bp-14h]@44
-  int v69; // [sp+14h] [bp-14h]@54
-  int v70; // [sp+14h] [bp-14h]@64
-  signed int v71; // [sp+14h] [bp-14h]@75
-  bool current_vertices_flag; // [sp+18h] [bp-10h]@9
-  //int thisb; // [sp+18h] [bp-10h]@12
-  //int thisc; // [sp+18h] [bp-10h]@20
-  bool thisd; // [sp+18h] [bp-10h]@41
-  bool thise; // [sp+18h] [bp-10h]@61
-  int thisf; // [sp+18h] [bp-10h]@74
-  signed int length_num_vertices; // [sp+1Ch] [bp-Ch]@9
-  int v80; // [sp+1Ch] [bp-Ch]@76
-  bool next_vertices_flag; // [sp+20h] [bp-8h]@10
-  //bool v82; // [sp+20h] [bp-8h]@32
-  bool v83; // [sp+20h] [bp-8h]@42
-  bool v84; // [sp+20h] [bp-8h]@52
-  bool v85; // [sp+20h] [bp-8h]@62
-  //signed int i; // [sp+24h] [bp-4h]@9
-  //unsigned int i; // [sp+24h] [bp-4h]@19
-  //signed int ix; // [sp+24h] [bp-4h]@31
-  //signed int iz; // [sp+24h] [bp-4h]@41
-  //signed int iy; // [sp+24h] [bp-4h]@51
-  //signed int iw; // [sp+24h] [bp-4h]@61
-
-  pFace = &pIndoor->pFaces[uFaceID];
-  memset(&stru_50B700, 0, sizeof(stru367));
-
-  if ( pFace->pFacePlane.vNormal.x * (pIndoor->pVertices[pFace->pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x)//check the angle of the vector and the plane
-     + pFace->pFacePlane.vNormal.y * (pIndoor->pVertices[pFace->pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y)
-     + pFace->pFacePlane.vNormal.z * (pIndoor->pVertices[pFace->pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z) < 0 )
-  {
-    stru_50B700.field_0 = 1;
-  }
-  else
-  {
-    stru_50B700.field_0 = 0;
-    if ( !pFace->Portal() )
-      return 0;
-  }
-  for (uint i = 0; i < pFace->uNumVertices; ++i)
-  {
-      //    ( ),          
-      pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(pIndoor->pVertices[pFace->pVertexIDs[i]].x,
-                         pIndoor->pVertices[pFace->pVertexIDs[i]].y, pIndoor->pVertices[pFace->pVertexIDs[i]].z,
-        &stru_50B700._view_transformed_xs[i], &stru_50B700._view_transformed_zs[i], &stru_50B700._view_transformed_ys[i], 0);
-  }
-
-  if (pFace->uNumVertices <= 0)
-    return 0;
-
-  bool bFound = false;
-  for (uint i = 0; i < pFace->uNumVertices; ++i)
-    if (stru_50B700._view_transformed_xs[i] >= 0x80000u)//   (cull for near clip plane)  z 
-    {
-      bFound = true;
-      break;
-    }
-  if (!bFound)
-    return 0;
-
-  int t;
-  //int new_point = 0;
-  length_num_vertices = 0;
-  stru_50B700._view_transformed_xs[pFace->uNumVertices] = stru_50B700._view_transformed_xs[0];//  
-  stru_50B700._view_transformed_zs[pFace->uNumVertices] = stru_50B700._view_transformed_zs[0];
-  stru_50B700._view_transformed_ys[pFace->uNumVertices] = stru_50B700._view_transformed_ys[0];
-
-  //maybe for near clip plane
-  current_vertices_flag = stru_50B700._view_transformed_xs[0] >= (signed int)0x80000u;//    >=  
-  //if (pFace->uNumVertices >= 24 )
-	  //__debugbreak();
-  for ( uint i = 1; i <= pFace->uNumVertices; ++i)
-  {
-    next_vertices_flag = stru_50B700._view_transformed_xs[i] >= (signed int)0x80000u;//  i-  >=  
-    if ( current_vertices_flag ^ next_vertices_flag )//    >  
-    {
-      if ( stru_50B700._view_transformed_xs[i] >= (signed int)0x80000u )//   thisa <  , a i-  >=  
-      {
-        //t = (near_clip - v0.x)/(v1.x - v0.x)
-        t = (0x80000 - stru_50B700._view_transformed_xs[i - 1]) / (stru_50B700._view_transformed_xs[i] - stru_50B700._view_transformed_xs[i - 1]);
-        //z = (v1.z - v0.z)*t + v0.z
-        stru_50B700._view_transformed_zs[length_num_vertices] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i] - stru_50B700._view_transformed_zs[i - 1])
-                * t)) + stru_50B700._view_transformed_zs[i - 1];
-        //y = (v1.y -v0.y)*(near_clip - v0.x)/(v1.x - v0.x)
-        stru_50B700._view_transformed_ys[length_num_vertices] = (unsigned __int64)((stru_50B700._view_transformed_ys[i] - stru_50B700._view_transformed_ys[i - 1])
-                * t) + stru_50B700._view_transformed_ys[i];
-        stru_50B700._view_transformed_xs[length_num_vertices] = 0x80000u;//z    = 8.0
-        //stru_50B700._view_transformed_ys[i] = stru_50B700.field_38[new_point];
-        //stru_50B700._view_transformed_zs[i] = stru_50B700.field_128[new_point];
-      }
-      else//   thisa  >=  
-      {
-        t = (0x80000 - stru_50B700._view_transformed_xs[i]) / (stru_50B700._view_transformed_xs[i - 1] - stru_50B700._view_transformed_xs[i]);
-        //z = (v0.z - v1.z)*(near_clip - v1.x)/(v0.x - v1.x) + v1.z
-        stru_50B700._view_transformed_zs[length_num_vertices + 1] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i - 1] - stru_50B700._view_transformed_zs[i])
-                 * t)) + stru_50B700._view_transformed_zs[i];
-        //y = (v0.y - v1.y)*(near_clip - v1.x)/(v0.x - v1.x)
-        stru_50B700._view_transformed_ys[length_num_vertices + 1] = (unsigned __int64)((stru_50B700._view_transformed_ys[i - 1] - stru_50B700._view_transformed_ys[i])
-                * t) + stru_50B700._view_transformed_ys[i];
-        stru_50B700._view_transformed_xs[length_num_vertices + 1] = 0x80000u;//z    = 8.0
-        //stru_50B700._view_transformed_ys[i] = stru_50B700.field_38[new_point];
-        //stru_50B700._view_transformed_zs[i] = stru_50B700.field_128[new_point];
-      }
-      //stru_50B700.field_218[new_point] 
-      //stru_50B700._view_transformed_xs[i] = 0x80000u;//z    = 8.0
-      length_num_vertices++;
-      //new_point++;
-    }
-    if ( next_vertices_flag )
-    {
-      //v20 = v79++;
-      //stru_50B700.field_38[length_num_vertices] = stru_50B700._view_transformed_ys[i];
-      //stru_50B700.field_128[length_num_vertices] = stru_50B700._view_transformed_zs[i];
-      //stru_50B700.field_218[length_num_vertices] = stru_50B700._view_transformed_xs[i];
-      length_num_vertices++;
-    }
-    /*else
-      length_num_vertices++;
-      stru_50B700.field_218[0] = stru_50B700._view_transformed_xs[i];
-      stru_50B700.field_128[0] = stru_50B700._view_transformed_zs[i];
-      stru_50B700.field_38[0] = stru_50B700._view_transformed_ys[i];*/
-    current_vertices_flag = next_vertices_flag;//i-  
-  }
-  //v21 = v79;
-  //stru_50B700.field_218[length_num_vertices] = stru_50B700.field_218[0];//  (t1, t2)  
-  //stru_50B700.field_128[length_num_vertices] = stru_50B700.field_128[0];
-  //stru_50B700.field_38[length_num_vertices] = stru_50B700.field_38[0];
-
-  //maybe for far clip plane
-  for ( uint i = 0; i < length_num_vertices; ++i )
-  {
-    if ( abs(stru_50B700._view_transformed_zs[i]) <= abs(stru_50B700._view_transformed_xs[i]) )
-    {
-      //LODWORD(v28) = stru_50B700.field_128[i] << 16;
-      //HIDWORD(v28) = stru_50B700.field_128[i] >> 16;
-      v26 = stru_50B700._view_transformed_zs[i] / stru_50B700._view_transformed_xs[i];
-      //v23 = 0;
-    }
-    else
-    {
-      //v23 = 0;
-      v24 = 0;
-      if ( stru_50B700._view_transformed_zs[i] >= 0 )
-      {
-        LOBYTE(v24) = stru_50B700._view_transformed_xs[i] >= 0;
-        v26 = ((v24 - 1) & 0xFF800000) + 0x400000;//((v24 - 1) & -127) + 64.0
-      }
-      else
-      {
-        LOBYTE(v24) = stru_50B700._view_transformed_xs[i] >= 0;
-        v26 = ((v24 - 1) & 0x800000) - 0x400000;//((v24 - 1) & 128) - 64.0
-      }
-    }
-    stru_50B700._xs3[i] = v26;//  z    
-    if ( abs(stru_50B700._view_transformed_ys[i]) <= abs(stru_50B700._view_transformed_xs[i]) )
-    {
-      //LODWORD(v34) = stru_50B700.field_38[i] << 16;
-      //HIDWORD(v34) = stru_50B700.field_38[i] >> 16;
-      v32 = stru_50B700._view_transformed_ys[i] / stru_50B700._view_transformed_xs[i];
-    }
-    else
-    {
-      v30 = 0;
-      if ( stru_50B700._view_transformed_ys[i] >= 0 )
-      {
-        LOBYTE(v30) = stru_50B700._view_transformed_xs[i] >= 0;
-        v32 = ((v30 - 1) & 0xFF800000) + 0x400000;
-      }
-      else
-      {
-        LOBYTE(v30) = stru_50B700._view_transformed_xs[i] >= 0;
-        v32 = ((v30 - 1) & 0x800000) - 0x400000;
-      }
-    }
-    //stru_50B700._ys2[i] = v32;
-    stru_50B700._xs3[i] = pBLVRenderParams->uViewportCenterX -(unsigned __int64)(SHIWORD(pBLVRenderParams->field_40)//maybe screen space x
-                          * (signed __int64)stru_50B700._xs3[i]);
-    //stru_50B700._xs3[i] = pBLVRenderParams->uViewportCenterX - stru_50B700._xs3[i];
-    stru_50B700._ys2[i] = pBLVRenderParams->uViewportCenterY - (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40)//screen space y
-                           * (signed __int64)v32);
-  }
-
-  for_x_num_vertices = 0;
-  stru_50B700._xs3[length_num_vertices] = stru_50B700._xs3[0];
-  stru_50B700._ys2[length_num_vertices] = stru_50B700._ys2[0];
-  if ( length_num_vertices < 1 )
-    return 0;
-
-  //maybe for left clip plane
-  current_vertices_flag = stru_50B700._xs3[0] >= (signed int)pBLVRenderParams->uViewportX;
-  for ( uint i = 1; i <= length_num_vertices; i++ )
-  {
-    next_vertices_flag = stru_50B700._xs3[i] >= (signed int)pBLVRenderParams->uViewportX;//    >=  
-    if ( current_vertices_flag ^ next_vertices_flag )
-    {
-      if ( stru_50B700._xs3[i] >= (signed int)pBLVRenderParams->uViewportX )
-      {
-		  //v67 = (a-b)*(c-d)/(e-f)
-        v67 = (signed int)(pBLVRenderParams->uViewportX - stru_50B700._xs3[i - 1])
-            * (signed __int64)(stru_50B700._ys2[i] - stru_50B700._ys2[i - 1]) / (stru_50B700._xs3[i] - stru_50B700._xs3[i - 1]);
-        v42 = stru_50B700._ys2[i - 1];//d
-      }
-      else
-      {
-		  //v67 = (a-e)*(d-c)/(f-e)
-        v67 = (signed int)(pBLVRenderParams->uViewportX - stru_50B700._xs3[i])
-            * (signed __int64)(stru_50B700._ys2[i - 1] - stru_50B700._ys2[i]) / (stru_50B700._xs3[i - 1] - stru_50B700._xs3[i]);
-        v42 = stru_50B700._ys2[i];//c
-      }
-      stru_50B700._ys[for_x_num_vertices] = v67 + v42;
-      stru_50B700._xs2[for_x_num_vertices] = pBLVRenderParams->uViewportX;
-      ++for_x_num_vertices;
-    }
-    current_vertices_flag = next_vertices_flag;
-    if ( next_vertices_flag )
-    {
-      stru_50B700._xs2[for_x_num_vertices] = stru_50B700._xs3[i];
-      stru_50B700._ys[for_x_num_vertices] = stru_50B700._ys2[i];
-      ++for_x_num_vertices;
-    }
-  }
-
-  if (for_x_num_vertices < 1)
-    return 0;
-
-  for_z_num_vertices = 0;
-  stru_50B700._xs2[for_x_num_vertices] = stru_50B700._xs2[0];
-  stru_50B700._ys[for_x_num_vertices] = stru_50B700._ys[0];
-
-  //maybe for right clip plane
-  thisd = stru_50B700._xs2[0] <= (signed int)pBLVRenderParams->uViewportZ;
-  for ( uint i = 1; i <= for_x_num_vertices; ++i )
-  {
-    v83 = stru_50B700._xs2[i] <= (signed int)pBLVRenderParams->uViewportZ;
-    if ( thisd ^ v83 )
-    {
-      if ( stru_50B700._xs2[i] <= (signed int)pBLVRenderParams->uViewportZ )
-      {
-		  //v68 = (a-b)*(c-d)/(e-b)
-        v68 = (signed int)(pBLVRenderParams->uViewportZ - stru_50B700._xs2[i - 1])
-            * (signed __int64)(stru_50B700._ys[i] - stru_50B700._ys[i - 1]) / (stru_50B700._xs2[i] - stru_50B700._xs2[i - 1]);
-        v47 = stru_50B700._ys[i - 1];//d
-      }
-      else
-      {
-		  //v68 = (a-e)*(d-c)/(b-e)
-        v68 = (signed int)(pBLVRenderParams->uViewportZ - stru_50B700._xs2[i])
-            * (signed __int64)(stru_50B700._ys[i - 1] - stru_50B700._ys[i]) / (stru_50B700._xs2[i - 1] - stru_50B700._xs2[i]);
-        v47 = stru_50B700._ys[i];//c
-      }
-      stru_50B700.field_2F0[for_z_num_vertices] = v68 + v47;
-      stru_50B700._xs[for_z_num_vertices] = pBLVRenderParams->uViewportZ;
-      ++for_z_num_vertices;
-    }
-    if ( v83 )
-    {
-      stru_50B700._xs[for_z_num_vertices] = stru_50B700._xs2[i];
-      stru_50B700.field_2F0[for_z_num_vertices++] = stru_50B700._ys[i];
-    }
-    thisd = v83;
-  }
-
-  if (for_z_num_vertices < 1)
-    return 0;
-
-  for_y_num_vertices = 0;
-  stru_50B700._xs[for_z_num_vertices] = stru_50B700._xs[0];
-  stru_50B700.field_2F0[for_z_num_vertices] = stru_50B700.field_2F0[0];
-  v50 = stru_50B700.field_2F0[0] < (signed int)pBLVRenderParams->uViewportY;
-
-  //maybr for top clip plane
-  LOBYTE(v50) = stru_50B700.field_2F0[0] >= (signed int)pBLVRenderParams->uViewportY;
-  for ( uint i = 1; i <= for_z_num_vertices; i++ )
-  {
-    v84 = stru_50B700.field_2F0[i] >= (signed int)pBLVRenderParams->uViewportY;
-    if ( v50 ^ v84 )
-    {
-      if ( stru_50B700.field_2F0[i] >= (signed int)pBLVRenderParams->uViewportY )
-      {
-		  //v69 = (a-b)*(c-d)/(e-b)
-        v69 = (signed int)(pBLVRenderParams->uViewportY - stru_50B700.field_2F0[i - 1])
-            * (signed __int64)(stru_50B700._xs[i] - stru_50B700._xs[i - 1]) / (stru_50B700.field_2F0[i] - stru_50B700.field_2F0[i - 1]);
-        v54 = stru_50B700._xs[i - 1];//d
-      }
-      else
-      {
-		  //v69 = (a-e)*(d-c)/(b-e)
-        v69 = (signed int)(pBLVRenderParams->uViewportY - stru_50B700.field_2F0[i])
-            * (signed __int64)(stru_50B700._xs[i - 1] - stru_50B700._xs[i]) / (stru_50B700.field_2F0[i - 1] - stru_50B700.field_2F0[i]);
-        v54 = stru_50B700._xs[i];//c
-      }
-      stru_50B700.field_3D4[for_y_num_vertices] = v69 + v54;
-      stru_50B700._xs[for_y_num_vertices + 1] = pBLVRenderParams->uViewportY;
-      ++for_y_num_vertices;
-    }
-    v50 = v84;
-    if ( v84 )
-    {
-      stru_50B700.field_3D4[for_y_num_vertices] = stru_50B700._xs[i];
-      stru_50B700._xs[for_y_num_vertices + 1] = stru_50B700.field_2F0[i];
-      for_y_num_vertices++;
-    }
-  }
-
-  if (for_y_num_vertices < 1)
-    return 0;
-
-  for_w_num_vertices = 0;
-  stru_50B700.field_3D4[for_y_num_vertices] = stru_50B700.field_3D4[0];
-  stru_50B700._xs[for_y_num_vertices + 1] = stru_50B700._xs[1];
-
-  //maybe for bottom clip plane
-  thise = stru_50B700._xs[1] <= (signed int)pBLVRenderParams->uViewportW;
-  for ( uint i = 1; i <= for_y_num_vertices; ++i )
-  {
-    v85 = stru_50B700._xs[i + 1] <= (signed int)pBLVRenderParams->uViewportW;
-    if ( thise ^ v85 )
-    {
-      if ( stru_50B700._xs[i + 1] <= (signed int)pBLVRenderParams->uViewportW )
-      {
-		  //v70 = (a-b)*(c-d)/(e-b)
-        v70 = (signed int)(pBLVRenderParams->uViewportW - stru_50B700._xs[i])
-            * (signed __int64)(stru_50B700.field_3D4[i] - stru_50B700.field_3D4[i - 1]) / (stru_50B700._xs[i + 1] - stru_50B700._xs[i]);
-        v59 = stru_50B700.field_3D4[i - 1];//d
-      }
-      else
-      {
-		  //v70 = (a-e)*(d-c)/(b-e)
-        v70 = (signed int)(pBLVRenderParams->uViewportW - stru_50B700._xs[i + 1])
-            * (signed __int64)(stru_50B700.field_3D4[i - 1] - stru_50B700.field_3D4[i]) / (stru_50B700._xs[i] - stru_50B700._xs[i + 1]);
-        v59 = stru_50B700.field_3D4[i];//c
-      }
-      stru_50B700._screen_space_x[for_w_num_vertices] = v70 + v59;
-      stru_50B700._screen_space_y[for_w_num_vertices] = pBLVRenderParams->uViewportW;
-      ++for_w_num_vertices;
-    }
-    if ( v85 )
-    {
-      stru_50B700._screen_space_x[for_w_num_vertices] = stru_50B700.field_3D4[i];
-      stru_50B700._screen_space_y[for_w_num_vertices++] = stru_50B700._xs[i + 1];
-    }
-    thise = v85;
-  }
-
-  if ( !for_w_num_vertices )
-    return 0;
-  v61 = pRenderer->pRenderD3D == 0;
-  stru_50B700._screen_space_x[for_w_num_vertices] = stru_50B700._screen_space_x[0];
-  stru_50B700._screen_space_y[for_w_num_vertices] = stru_50B700._screen_space_y[0];
-  if ( v61 && for_w_num_vertices > 3 )
-  {
-    stru_50B700._screen_space_x[for_w_num_vertices + 1] = stru_50B700._screen_space_x[1];
-    stru_50B700._screen_space_y[for_w_num_vertices + 1] = stru_50B700._screen_space_y[1];
-    thisf = 2 * (stru_50B700.field_0 != 0) - 1;
-    if ( for_w_num_vertices > 0 )
-    {
-      v62 = 1;
-      v71 = 1;
-      do
-      {
-        v63 = v62 - 1;
-        v64 = v62 + 1;
-        v80 = v62 + 1;
-        if ( v62 - 1 >= for_w_num_vertices )
-          v63 -= for_w_num_vertices;
-        if ( v62 >= for_w_num_vertices )
-          v62 -= for_w_num_vertices;
-        if ( v64 >= for_w_num_vertices )
-          v64 -= for_w_num_vertices;
-        if ( thisf * ((stru_50B700._screen_space_y[v64] - stru_50B700._screen_space_y[v63])
-                   * (stru_50B700._screen_space_x[v62] - stru_50B700._screen_space_x[v63])
-                   - (stru_50B700._screen_space_y[v62] - stru_50B700._screen_space_y[v63])
-                   * (stru_50B700._screen_space_x[v64] - stru_50B700._screen_space_x[v63])) < 0 )
-        {
-          v62 = v80;
-          v71 = v80;
-        }
-        else
-        {
-          v62 = v71;
-          v65 = v71;
-          if ( v71 < for_w_num_vertices || (v65 = v71 - for_w_num_vertices, v71 - for_w_num_vertices < for_w_num_vertices) )
-          {
-            memcpy(&stru_50B700._screen_space_y[v65], &stru_50B700._screen_space_y[v65 + 1], 4 * ((unsigned int)(4 * (for_w_num_vertices - v65)) >> 2));
-            memcpy(&stru_50B700._screen_space_x[v65], &stru_50B700._screen_space_x[v65 + 1], 4 * ((unsigned int)(4 * (for_w_num_vertices - v65)) >> 2));
-          }
-          --for_w_num_vertices;
-        }
-      }
-      while ( v62 - 1 < for_w_num_vertices );
-    }
-    stru_50B700._screen_space_x[for_w_num_vertices] = stru_50B700._screen_space_x[0];
-    stru_50B700._screen_space_y[for_w_num_vertices] = stru_50B700._screen_space_y[0];
-  }
-  return for_w_num_vertices;
-}
-
-//old function
-/*int __fastcall sub_423B5D(unsigned int uFaceID)
-{
   BLVFace *v1; // ebx@1
   Vec3_short_ *v2; // esi@1
-  //int v3; // ST28_4@1
+  int v3; // ST28_4@1
   __int16 v4; // ST2C_2@1
-  //signed int v5; // esi@1
-  //Vec3_short_ *v6; // eax@4
-  //signed int v7; // edi@5
-  //signed int v8; // eax@5
-  //signed int i_; // ecx@10
+  signed int v5; // esi@1
+  Vec3_short_ *v6; // eax@4
+  signed int v7; // edi@5
+  signed int v8; // eax@5
+  signed int v9; // ecx@10
   int v10; // eax@10
   int v11; // edx@11
   int v12; // ST28_4@12
   signed int v13; // edx@12
   signed __int64 v14; // qtt@12
-  int *v15; // ebx@12
+  char *v15; // ebx@12
   int v16; // ST28_4@14
   signed int v17; // eax@14
   signed __int64 v18; // qtt@14
@@ -2007,7 +1540,7 @@
   bool v50; // edx@51
   int v51; // ecx@51
   int v52; // ecx@52
-  signed int v53; // esi@52
+  int v53; // esi@52
   int v54; // eax@54
   int v55; // ebx@61
   unsigned int v56; // eax@61
@@ -2019,12 +1552,13 @@
   int v63; // ecx@76
   int v64; // esi@76
   int v65; // ecx@83
-  //signed int v66; // [sp+14h] [bp-14h]@3
+  signed int v66; // [sp+14h] [bp-14h]@3
   int v67; // [sp+14h] [bp-14h]@34
   int v68; // [sp+14h] [bp-14h]@44
   int v69; // [sp+14h] [bp-14h]@54
   int v70; // [sp+14h] [bp-14h]@64
   signed int v71; // [sp+14h] [bp-14h]@75
+  IndoorCameraD3D *_this; // [sp+18h] [bp-10h]@1
   bool thisa; // [sp+18h] [bp-10h]@9
   int thisb; // [sp+18h] [bp-10h]@12
   int thisc; // [sp+18h] [bp-10h]@20
@@ -2038,349 +1572,383 @@
   bool v83; // [sp+20h] [bp-8h]@42
   bool v84; // [sp+20h] [bp-8h]@52
   bool v85; // [sp+20h] [bp-8h]@62
-  //signed int i; // [sp+24h] [bp-4h]@9
-  signed int ia; // [sp+24h] [bp-4h]@19
-  signed int ib; // [sp+24h] [bp-4h]@31
-  signed int ic; // [sp+24h] [bp-4h]@41
-  signed int id; // [sp+24h] [bp-4h]@51
-  signed int ie; // [sp+24h] [bp-4h]@61
+  signed int v86; // [sp+24h] [bp-4h]@9
+  signed int v87; // [sp+24h] [bp-4h]@19
+  signed int v88; // [sp+24h] [bp-4h]@31
+  signed int v89; // [sp+24h] [bp-4h]@41
+  signed int v90; // [sp+24h] [bp-4h]@51
+  signed int v91; // [sp+24h] [bp-4h]@61
 
   v1 = &pIndoor->pFaces[uFaceID];
-  //this = pGame->pIndoorCameraD3D;
-  v2 = &pIndoor->pVertices[v1->pVertexIDs[0]];
-  //v3 = *(_DWORD *)&v2->x;
+  _this = pGame->pIndoorCameraD3D;
+  v2 = &pIndoor->pVertices[*v1->pVertexIDs];
+  v3 = *(_DWORD *)&v2->x;
   v4 = v2->z;
-  //v5 = 0;
-  if ( v1->pFacePlane_old.vNormal.x * (v2->x - pBLVRenderParams->vPartyPos.x)
-     + v1->pFacePlane_old.vNormal.y * (v2->y - pBLVRenderParams->vPartyPos.y)
-     + v1->pFacePlane_old.vNormal.z * (v2->z - pBLVRenderParams->vPartyPos.z) < 0 )
+  v5 = 0;
+  if ( v1->pFacePlane_old.vNormal.x * ((signed __int16)v3 - pBLVRenderParams->vPartyPos.x)
+     + v1->pFacePlane_old.vNormal.y * (SHIWORD(v3) - pBLVRenderParams->vPartyPos.y)
+     + v1->pFacePlane_old.vNormal.z * (v4 - pBLVRenderParams->vPartyPos.z) < 0 )
   {
-    dword_50B700 = 1;
+    stru_50B700.field_0 = 1;
   }
   else
   {
-    dword_50B700 = 0;
-    if ( !v1->Portal() )
+    stru_50B700.field_0 = 0;
+    if ( !(v1->uAttributes & 1) )
       return 0;
   }
-  //v66 = v1->uNumVertices;
-  for (uint i = 0; i < v1->uNumVertices; ++i)
+  v66 = v1->uNumVertices;
+  if ( (signed int)v1->uNumVertices > 0 )
   {
-      auto v6 = &pIndoor->pVertices[v1->pVertexIDs[i]];
+    do
+    {
+      v6 = &pIndoor->pVertices[v1->pVertexIDs[v5]];
       pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(
         v6->x,
         v6->y,
         v6->z,
-        &_50B924_view_transformed_xs[i],
-        &_50B834_view_transformed_zs[i],
-        &_50B744_view_transformed_ys[i],
+        &stru_50B700._view_transformed_xs[v5 + 3],
+        &stru_50B700._view_transformed_zs[v5 + 3],
+        &stru_50B700._view_transformed_ys[v5 + 3],
         0);
+      ++v5;
+    }
+    while ( v5 < v66 );
   }
-
-  //v7 = v1->uNumVertices;
-  //v8 = 0;
-  if (v1->uNumVertices <= 0)
+  v7 = v66;
+  v8 = 0;
+  if ( v66 <= 0 )
     return 0;
-
-  bool bFound = false;
-  for (uint i = 0; i < v1->uNumVertices; ++i)
-    if (_50B924_view_transformed_xs[i] >= 0x80000u)
+  do
+  {
+    if ( stru_50B700._view_transformed_xs[v8 + 3] >= 524288 )
+      break;
+    ++v8;
+  }
+  while ( v8 < v66 );
+  if ( v8 >= v66 )
+    return 0;
+  v79 = 0;
+  stru_50B700._view_transformed_xs[v66 + 3] = stru_50B700._view_transformed_xs[3];
+  stru_50B700._view_transformed_zs[v66 + 3] = stru_50B700._view_transformed_zs[3];
+  stru_50B700._view_transformed_ys[v66 + 3] = stru_50B700._view_transformed_ys[3];
+  thisa = stru_50B700._view_transformed_xs[3] >= 524288;
+  v86 = 1;
+  if ( v66 >= 1 )
+  {
+    do
     {
-      bFound = true;
-      break;
-    }
-  if (!bFound)
-    return 0;
-
-  v79 = 0;
-  _50B924_view_transformed_xs[v1->uNumVertices] = _50B924_view_transformed_xs[0];
-  _50B834_view_transformed_zs[v1->uNumVertices] = _50B834_view_transformed_zs[0];
-  _50B744_view_transformed_ys[v1->uNumVertices] = _50B744_view_transformed_ys[0];
-  thisa = _50B924_view_transformed_xs[0] >= (signed int)0x80000u;
-  //int i = 1;
-  for (uint i = 1; i <= v1->uNumVertices; ++i)
-  {
-      v10 = _50B924_view_transformed_xs[i];
-      v81 = v10 >= (signed int)0x80000u;
+      v9 = v86;
+      v10 = stru_50B700._view_transformed_xs[v86 + 3];
+      v81 = v10 >= 524288;
       if ( thisa ^ v81 )
       {
-        v11 = _50B924_view_transformed_xs[i - 1];
-        if ( v10 >= (signed int)0x80000u )
+        v11 = stru_50B700._view_transformed_xs[v9 + 2];
+        if ( v10 >= 524288 )
         {
           v12 = v10 - v11;
-          v13 = 0x80000 - v11;
+          v13 = 524288 - v11;
           LODWORD(v14) = v13 << 16;
           HIDWORD(v14) = v13 >> 16;
-          v15 = &_50B744_view_transformed_ys[i - 1];
-          dword_50B828[v79] = ((unsigned __int64)((_50B834_view_transformed_zs[i] - _50B834_view_transformed_zs[i - 1]) * v14 / v12) >> 16) + _50B834_view_transformed_zs[i - 1];
-          thisb = (unsigned __int64)((_50B744_view_transformed_ys[i] - _50B744_view_transformed_ys[i - 1]) * v14 / v12) >> 16;
+          v15 = (char *)&stru_50B700._view_transformed_ys[v9 + 2];
+          stru_50B700._view_transformed_zs[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[v9 + 3]
+                                                                     - stru_50B700._view_transformed_zs[v9 + 2])
+                                                                    * v14
+                                                                    / v12) >> 16)
+                                                + stru_50B700._view_transformed_zs[v9 + 2];
+          thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[v9 + 3] - stru_50B700._view_transformed_ys[v9 + 2])
+                                   * v14
+                                   / v12) >> 16;
         }
         else
         {
           v16 = v11 - v10;
-          v17 = 0x80000 - v10;
+          v17 = 524288 - v10;
           LODWORD(v18) = v17 << 16;
           HIDWORD(v18) = v17 >> 16;
-          v15 = &_50B744_view_transformed_ys[i];
-          dword_50B828[v79] = ((unsigned __int64)((_50B834_view_transformed_zs[i - 1] - _50B834_view_transformed_zs[i]) * v18 / v16) >> 16) + _50B834_view_transformed_zs[i];
-          thisb = (unsigned __int64)((_50B744_view_transformed_ys[i - 1] - _50B744_view_transformed_ys[i]) * v18 / v16) >> 16;
+          v15 = (char *)&stru_50B700._view_transformed_ys[v9 + 3];
+          stru_50B700._view_transformed_zs[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[v9 + 2]
+                                                                     - stru_50B700._view_transformed_zs[v9 + 3])
+                                                                    * v18
+                                                                    / v16) >> 16)
+                                                + stru_50B700._view_transformed_zs[v9 + 3];
+          thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[v9 + 2] - stru_50B700._view_transformed_ys[v9 + 3])
+                                   * v18
+                                   / v16) >> 16;
         }
         v19 = v79++;
-        //v7 = v66;
-        dword_50B738[v19] = thisb + *v15;
-        dword_50B918[v19] = 0x80000u;
+        v7 = v66;
+        stru_50B700._view_transformed_ys[v19] = thisb + *(_DWORD *)v15;
+        stru_50B700._view_transformed_xs[v19] = 524288;
       }
       if ( v81 )
       {
         v20 = v79++;
-        dword_50B918[v20] = _50B924_view_transformed_xs[i];
-        dword_50B828[v20] = _50B834_view_transformed_zs[i];
-        dword_50B738[v20] = _50B744_view_transformed_ys[i];
+        stru_50B700._view_transformed_xs[v20] = stru_50B700._view_transformed_xs[v9 + 3];
+        stru_50B700._view_transformed_zs[v20] = stru_50B700._view_transformed_zs[v9 + 3];
+        stru_50B700._view_transformed_ys[v20] = stru_50B700._view_transformed_ys[v9 + 3];
       }
-      //++i;
+      ++v86;
       thisa = v81;
+    }
+    while ( v86 <= v7 );
   }
+  v87 = 0;
   v21 = v79;
-  dword_50B918[v79] = dword_50B918[0];
-  dword_50B828[v79] = dword_50B828[0];
-  dword_50B738[v79] = dword_50B738[0];
-  for (ia = 0; ia < v79; ++ia)
+  stru_50B700._view_transformed_xs[v79] = stru_50B700._view_transformed_xs[0];
+  stru_50B700._view_transformed_zs[v79] = stru_50B700._view_transformed_zs[0];
+  for ( stru_50B700._view_transformed_ys[v79] = stru_50B700._view_transformed_ys[0];
+        v87 < v79;
+        stru_50B700._screen_space_y[v22 + 12] = pBLVRenderParams->uViewportCenterY - v35 )
   {
-    v22 = ia;
-    thisc = abs(dword_50B918[ia]);
-    if ( abs(dword_50B828[ia]) >> 13 <= thisc )
+    v22 = v87;
+    thisc = abs(stru_50B700._view_transformed_xs[v87]);
+    if ( abs(stru_50B700._view_transformed_zs[v87]) >> 13 <= thisc )
     {
-      v27 = dword_50B828[v22];
+      v27 = stru_50B700._view_transformed_zs[v22];
       LODWORD(v28) = v27 << 16;
       HIDWORD(v28) = v27 >> 16;
-      v26 = v28 / dword_50B918[v22];
+      v26 = v28 / stru_50B700._view_transformed_xs[v22];
       v23 = 0;
     }
     else
     {
       v23 = 0;
       v24 = 0;
-      if ( dword_50B828[v22] >= 0 )
+      if ( stru_50B700._view_transformed_zs[v22] >= 0 )
       {
-        LOBYTE(v24) = dword_50B918[v22] >= 0;
-        v26 = ((v24 - 1) & 0xFF800000) + 0x400000;
+        LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0;
+        v26 = ((v24 - 1) & 0xFF800000) + 4194304;
       }
       else
       {
-        LOBYTE(v24) = dword_50B918[v22] >= 0;
+        LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0;
         v25 = v24 - 1;
-        v26 = (v25 & 0x800000) - 0x400000;
+        v26 = (v25 & 0x800000) - 4194304;
       }
     }
-    v29 = dword_50B738[v22];
-    dword_50BAF8_xs[v22] = v26;
+    v29 = stru_50B700._view_transformed_ys[v22];
+    stru_50B700._screen_space_x[v22 + 12] = v26;
     if ( abs(v29) >> 13 <= thisc )
     {
-      v33 = dword_50B738[v22];
+      v33 = stru_50B700._view_transformed_ys[v22];
       LODWORD(v34) = v33 << 16;
       HIDWORD(v34) = v33 >> 16;
-      v32 = v34 / dword_50B918[v22];
+      v32 = v34 / stru_50B700._view_transformed_xs[v22];
     }
     else
     {
       v30 = 0;
-      if ( dword_50B738[v22] >= v23 )
+      if ( stru_50B700._view_transformed_ys[v22] >= v23 )
       {
-        LOBYTE(v30) = dword_50B918[v22] >= v23;
-        v32 = ((v30 - 1) & 0xFF800000) + 0x400000;
+        LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23;
+        v32 = ((v30 - 1) & 0xFF800000) + 4194304;
       }
       else
       {
-        LOBYTE(v30) = dword_50B918[v22] >= v23;
+        LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23;
         v31 = v30 - 1;
-        v32 = (v31 & 0x800000) - 0x400000;
+        v32 = (v31 & 0x800000) - 4194304;
       }
     }
-    dword_50BA08_ys[v22] = v32;
-    dword_50BAF8_xs[v22] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BAF8_xs[v22]) >> 16;
-    v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BA08_ys[v22]) >> 16;
-    dword_50BAF8_xs[v22] = pBLVRenderParams->uViewportCenterX - dword_50BAF8_xs[v22];
-    dword_50BA08_ys[v22] = pBLVRenderParams->uViewportCenterY - v35;
+    stru_50B700._screen_space_y[v22 + 12] = v32;
+    stru_50B700._screen_space_x[v22 + 12] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40)
+                                                             * (signed __int64)stru_50B700._screen_space_x[v22 + 12]) >> 16;
+    v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)stru_50B700._screen_space_y[v22 + 12]) >> 16;
+    stru_50B700._screen_space_x[v22 + 12] = pBLVRenderParams->uViewportCenterX - stru_50B700._screen_space_x[v22 + 12];
+    ++v87;
   }
   v36 = 0;
-  dword_50BAF8_xs[v21] = dword_50BAF8_xs[0];
-  dword_50BA08_ys[v21] = dword_50BA08_ys[0];
+  stru_50B700._screen_space_x[v21 + 12] = stru_50B700._screen_space_x[12];
+  stru_50B700._screen_space_y[v21 + 12] = stru_50B700._screen_space_y[12];
   v37 = pBLVRenderParams->uViewportX;
-  v38 = dword_50BAF8_xs[0] < (signed int)pBLVRenderParams->uViewportX;
-  LOBYTE(v38) = dword_50BAF8_xs[0] >= (signed int)pBLVRenderParams->uViewportX;
+  v38 = stru_50B700._screen_space_x[12] < (signed int)pBLVRenderParams->uViewportX;
+  LOBYTE(v38) = stru_50B700._screen_space_x[12] >= (signed int)pBLVRenderParams->uViewportX;
   v39 = 1;
-  ib = 1;
+  v88 = 1;
   if ( v79 < 1 )
     return 0;
   do
   {
     v40 = v39;
-    v41 = dword_50BAF8_xs[v40];
+    v41 = stru_50B700._screen_space_x[v40 + 12];
     v82 = v41 >= (signed int)v37;
     if ( v38 ^ v82 )
     {
       if ( v41 >= (signed int)v37 )
       {
-        v67 = (signed int)(v37 - dword_50BAF8_xs[v40 - 1]) * (signed __int64)(dword_50BA08_ys[v40] - dword_50BA08_ys[v40 - 1]) / (v41 - dword_50BAF8_xs[v40 - 1]);
-        v42 = dword_50BA08_ys[v40 - 1];
+        v67 = (signed int)(v37 - stru_50B700._screen_space_x[v40 + 11])
+            * (signed __int64)(stru_50B700._screen_space_y[v40 + 12] - stru_50B700._screen_space_y[v40 + 11])
+            / (v41 - stru_50B700._screen_space_x[v40 + 11]);
+        v42 = stru_50B700._screen_space_y[v40 + 11];
       }
       else
       {
-        v67 = (signed int)(v37 - v41) * (signed __int64)(dword_50BA08_ys[v40 - 1] - dword_50BA08_ys[v40]) / (dword_50BAF8_xs[v40 - 1] - v41);
-        v42 = dword_50BA08_ys[v40];
+        v67 = (signed int)(v37 - v41)
+            * (signed __int64)(stru_50B700._screen_space_y[v40 + 11] - stru_50B700._screen_space_y[v40 + 12])
+            / (stru_50B700._screen_space_x[v40 + 11] - v41);
+        v42 = stru_50B700._screen_space_y[v40 + 12];
       }
-      dword_50B9FC_ys[v36] = v67 + v42;
+      ++v36;
+      stru_50B700._screen_space_y[v36 + 8] = v67 + v42;
       v37 = pBLVRenderParams->uViewportX;
-      dword_50BAEC_xs[v36] = pBLVRenderParams->uViewportX;
-      ++v36;
+      stru_50B700._screen_space_x[v36 + 8] = pBLVRenderParams->uViewportX;
     }
     v38 = v82;
     if ( v82 )
     {
-      dword_50BAEC_xs[v36] = dword_50BAF8_xs[v40];
-      dword_50B9FC_ys[v36] = dword_50BA08_ys[v40];
-      ++v36;
+      stru_50B700._screen_space_x[v36 + 9] = stru_50B700._screen_space_x[v40 + 12];
+      stru_50B700._screen_space_y[v36++ + 9] = stru_50B700._screen_space_y[v40 + 12];
     }
-    v39 = ib++ + 1;
+    v39 = v88++ + 1;
   }
-  while ( ib <= v79 );
-
-  if (v36 < 1)
+  while ( v88 <= v79 );
+  if ( !v36
+    || (v43 = 0,
+        stru_50B700._screen_space_x[v36 + 9] = stru_50B700._screen_space_x[9],
+        stru_50B700._screen_space_y[v36 + 9] = stru_50B700._screen_space_y[9],
+        v44 = pBLVRenderParams->uViewportZ,
+        thisd = stru_50B700._screen_space_x[9] <= (signed int)pBLVRenderParams->uViewportZ,
+        v89 = 1,
+        v36 < 1) )
     return 0;
-
-  v43 = 0;
-  dword_50BAEC_xs[v36] = dword_50BAEC_xs[0];
-  dword_50B9FC_ys[v36] = dword_50B9FC_ys[0];
-  v44 = pBLVRenderParams->uViewportZ;
-  thisd = dword_50BAEC_xs[0] <= (signed int)pBLVRenderParams->uViewportZ;
-  ic = 1;
-
   do
   {
-    v45 = ic;
-    v46 = dword_50BAEC_xs[ic];
+    v45 = v89;
+    v46 = stru_50B700._screen_space_x[v89 + 9];
     v83 = v46 <= (signed int)v44;
     if ( thisd ^ v83 )
     {
       if ( v46 <= (signed int)v44 )
       {
-        v68 = (signed int)(v44 - dword_50BAEC_xs[v45 - 1]) * (signed __int64)(dword_50B9FC_ys[v45] - dword_50B9FC_ys[v45 - 1]) / (v46 - dword_50BAEC_xs[v45 - 1]);
-        v47 = dword_50B9FC_ys[v45 - 1];
+        v68 = (signed int)(v44 - stru_50B700._screen_space_x[v45 + 8])
+            * (signed __int64)(stru_50B700._screen_space_y[v45 + 9] - stru_50B700._screen_space_y[v45 + 8])
+            / (v46 - stru_50B700._screen_space_x[v45 + 8]);
+        v47 = stru_50B700._screen_space_y[v45 + 8];
       }
       else
       {
-        v68 = (signed int)(v44 - v46) * (signed __int64)(dword_50B9FC_ys[v45 - 1] - dword_50B9FC_ys[v45]) / (dword_50BAEC_xs[v45 - 1] - v46);
-        v47 = dword_50B9FC_ys[v45];
+        v68 = (signed int)(v44 - v46)
+            * (signed __int64)(stru_50B700._screen_space_y[v45 + 8] - stru_50B700._screen_space_y[v45 + 9])
+            / (stru_50B700._screen_space_x[v45 + 8] - v46);
+        v47 = stru_50B700._screen_space_y[v45 + 9];
       }
-      dword_50B9F0[v43] = v68 + v47;
+      ++v43;
+      stru_50B700._screen_space_y[v43 + 5] = v68 + v47;
       v44 = pBLVRenderParams->uViewportZ;
-      dword_50BAE0[v43] = pBLVRenderParams->uViewportZ;
-      ++v43;
+      stru_50B700._screen_space_x[v43 + 5] = pBLVRenderParams->uViewportZ;
     }
     if ( v83 )
     {
-      dword_50BAE0[v43] = dword_50BAEC_xs[v45];
-      dword_50B9F0[v43++] = dword_50B9FC_ys[v45];
+      stru_50B700._screen_space_x[v43 + 6] = stru_50B700._screen_space_x[v45 + 9];
+      stru_50B700._screen_space_y[v43++ + 6] = stru_50B700._screen_space_y[v45 + 9];
     }
-    ++ic;
+    ++v89;
     thisd = v83;
   }
-  while ( ic <= v36 );
-
-  if (v43 < 1)
+  while ( v89 <= v36 );
+  if ( !v43
+    || (v48 = 0,
+        stru_50B700._screen_space_x[v43 + 6] = stru_50B700._screen_space_x[6],
+        stru_50B700._screen_space_y[v43 + 6] = stru_50B700._screen_space_y[6],
+        v49 = pBLVRenderParams->uViewportY,
+        v50 = stru_50B700._screen_space_y[6] < (signed int)pBLVRenderParams->uViewportY,
+        LOBYTE(v50) = stru_50B700._screen_space_y[6] >= (signed int)pBLVRenderParams->uViewportY,
+        v51 = 1,
+        v90 = 1,
+        v43 < 1) )
     return 0;
-
-  v48 = 0;
-  dword_50BAE0[v43] = dword_50BAE0[0];
-  dword_50B9F0[v43] = dword_50B9F0[0];
-  v49 = pBLVRenderParams->uViewportY;
-  v50 = dword_50B9F0[0] < (signed int)pBLVRenderParams->uViewportY;
-  LOBYTE(v50) = dword_50B9F0[0] >= (signed int)pBLVRenderParams->uViewportY;
-  v51 = 1;
-  id = 1;
   do
   {
     v52 = v51;
-    v53 = dword_50B9F0[v52];
+    v53 = stru_50B700._screen_space_y[v52 + 6];
     v84 = v53 >= (signed int)v49;
     if ( v50 ^ v84 )
     {
       if ( v53 >= (signed int)v49 )
       {
-        v69 = (signed int)(v49 - dword_50B9F0[v52 - 1]) * (signed __int64)(dword_50BAE0[v52] - dword_50BAE0[v52 - 1]) / (v53 - dword_50B9F0[v52 - 1]);
-        v54 = dword_50BAE0[v52 - 1];
+        v69 = (signed int)(v49 - stru_50B700._screen_space_y[v52 + 5])
+            * (signed __int64)(stru_50B700._screen_space_x[v52 + 6] - stru_50B700._screen_space_x[v52 + 5])
+            / (v53 - stru_50B700._screen_space_y[v52 + 5]);
+        v54 = stru_50B700._screen_space_x[v52 + 5];
       }
       else
       {
-        v69 = (signed int)(v49 - v53) * (signed __int64)(dword_50BAE0[v52 - 1] - dword_50BAE0[v52]) / (dword_50B9F0[v52 - 1] - v53);
-        v54 = dword_50BAE0[v52];
+        v69 = (signed int)(v49 - v53)
+            * (signed __int64)(stru_50B700._screen_space_x[v52 + 5] - stru_50B700._screen_space_x[v52 + 6])
+            / (stru_50B700._screen_space_y[v52 + 5] - v53);
+        v54 = stru_50B700._screen_space_x[v52 + 6];
       }
-      dword_50BAD4[v48] = v69 + v54;
+      ++v48;
+      stru_50B700._screen_space_x[v48 + 2] = v69 + v54;
       v49 = pBLVRenderParams->uViewportY;
-      dword_50B9E4[v48] = pBLVRenderParams->uViewportY;
-      ++v48;
+      stru_50B700._screen_space_y[v48 + 2] = pBLVRenderParams->uViewportY;
     }
     v50 = v84;
     if ( v84 )
     {
-      dword_50BAD4[v48] = dword_50BAE0[v52];
-      dword_50B9E4[v48++] = dword_50B9F0[v52];
+      stru_50B700._screen_space_x[v48 + 3] = stru_50B700._screen_space_x[v52 + 6];
+      stru_50B700._screen_space_y[v48++ + 3] = stru_50B700._screen_space_y[v52 + 6];
     }
-    v51 = id++ + 1;
+    v51 = v90++ + 1;
   }
-  while ( id <= v43 );
-
-  if (v48 < 1)
+  while ( v90 <= v43 );
+  if ( !v48
+    || (v55 = 0,
+        stru_50B700._screen_space_x[v48 + 3] = stru_50B700._screen_space_x[3],
+        stru_50B700._screen_space_y[v48 + 3] = stru_50B700._screen_space_y[3],
+        v56 = pBLVRenderParams->uViewportW,
+        thise = stru_50B700._screen_space_y[3] <= (signed int)pBLVRenderParams->uViewportW,
+        v91 = 1,
+        v48 < 1) )
     return 0;
-
-  v55 = 0;
-  dword_50BAD4[v48] = dword_50BAD4[0];
-  dword_50B9E4[v48] = dword_50B9E4[0];
-  v56 = pBLVRenderParams->uViewportW;
-  thise = dword_50B9E4[0] <= (signed int)pBLVRenderParams->uViewportW;
-  ie = 1;
   do
   {
-    v57 = ie;
-    v58 = dword_50B9E4[ie];
+    v57 = v91;
+    v58 = stru_50B700._screen_space_y[v91 + 3];
     v85 = v58 <= (signed int)v56;
     if ( thise ^ v85 )
     {
       if ( v58 <= (signed int)v56 )
       {
-        v70 = (signed int)(v56 - dword_50B9E4[v57 - 1]) * (signed __int64)(dword_50BAD4[v57] - dword_50BAD4[v57 - 1]) / (v58 - dword_50B9E4[v57 - 1]);
-        v59 = dword_50BAD4[v57 - 1];
+        v70 = (signed int)(v56 - stru_50B700._screen_space_y[v57 + 2])
+            * (signed __int64)(stru_50B700._screen_space_x[v57 + 3] - stru_50B700._screen_space_x[v57 + 2])
+            / (v58 - stru_50B700._screen_space_y[v57 + 2]);
+        v59 = stru_50B700._screen_space_x[v57 + 2];
       }
       else
       {
-        v70 = (signed int)(v56 - v58) * (signed __int64)(dword_50BAD4[v57 - 1] - dword_50BAD4[v57]) / (dword_50B9E4[v57 - 1] - v58);
-        v59 = dword_50BAD4[v57];
+        v70 = (signed int)(v56 - v58)
+            * (signed __int64)(stru_50B700._screen_space_x[v57 + 2] - stru_50B700._screen_space_x[v57 + 3])
+            / (stru_50B700._screen_space_y[v57 + 2] - v58);
+        v59 = stru_50B700._screen_space_x[v57 + 3];
       }
-      _50BAC8_screen_space_x[v55] = v70 + v59;
+      ++v55;
+      //stru_50B700._screen_space_y[v55 + 59] = v70 + v59;
+	  stru_50B700._screen_space_x[v55 - 1] = v70 + v59;
       v56 = pBLVRenderParams->uViewportW;
-      _50B9D8_screen_space_y[v55] = pBLVRenderParams->uViewportW;
-      ++v55;
+      //stru_50B700._view_transformed_xs[v55 + 47] = pBLVRenderParams->uViewportW;
+	  stru_50B700._screen_space_y[v55 - 1] = pBLVRenderParams->uViewportW;
     }
     if ( v85 )
     {
-      _50BAC8_screen_space_x[v55] = dword_50BAD4[v57];
-      _50B9D8_screen_space_y[v55++] = dword_50B9E4[v57];
+      stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[v57 + 3];
+      stru_50B700._screen_space_y[v55++] = stru_50B700._screen_space_y[v57 + 3];
     }
-    ++ie;
+    ++v91;
     thise = v85;
   }
-  while ( ie <= v48 );
-
+  while ( v91 <= v48 );
   if ( !v55 )
     return 0;
   v61 = pRenderer->pRenderD3D == 0;
-  _50BAC8_screen_space_x[v55] = _50BAC8_screen_space_x[0];
-  _50B9D8_screen_space_y[v55] = _50B9D8_screen_space_y[0];
+  stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0];
+  stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0];
   if ( v61 && v55 > 3 )
   {
-    _50BAC8_screen_space_x[v55 + 1] = _50BAC8_screen_space_x[1];
-    _50B9D8_screen_space_y[v55 + 1] = _50B9D8_screen_space_y[1];
-    thisf = 2 * (dword_50B700 != 0) - 1;
+    stru_50B700._screen_space_x[v55 + 1] = stru_50B700._screen_space_x[1];
+    stru_50B700._screen_space_y[v55 + 1] = stru_50B700._screen_space_y[1];
+    thisf = 2 * (stru_50B700.field_0 != 0) - 1;
     if ( v55 > 0 )
     {
       v62 = 1;
@@ -2397,8 +1965,10 @@
         if ( v64 >= v55 )
           v64 -= v55;
         if ( thisf
-           * ((_50B9D8_screen_space_y[v64] - _50B9D8_screen_space_y[v63]) * (_50BAC8_screen_space_x[v62] - _50BAC8_screen_space_x[v63])
-            - (_50B9D8_screen_space_y[v62] - _50B9D8_screen_space_y[v63]) * (_50BAC8_screen_space_x[v64] - _50BAC8_screen_space_x[v63])) < 0 )
+           * ((stru_50B700._screen_space_y[v64] - stru_50B700._screen_space_y[v63])
+            * (stru_50B700._screen_space_x[v62] - stru_50B700._screen_space_x[v63])
+            - (stru_50B700._screen_space_y[v62] - stru_50B700._screen_space_y[v63])
+            * (stru_50B700._screen_space_x[v64] - stru_50B700._screen_space_x[v63])) < 0 )
         {
           v62 = v80;
           v71 = v80;
@@ -2409,20 +1979,25 @@
           v65 = v71;
           if ( v71 < v55 || (v65 = v71 - v55, v71 - v55 < v55) )
           {
-            memcpy(&_50B9D8_screen_space_y[v65], &_50B9D8_screen_space_y[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
-            memcpy(&_50BAC8_screen_space_x[v65], &_50BAC8_screen_space_x[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
+            memcpy(
+              &stru_50B700._screen_space_y[v65],
+              &stru_50B700._screen_space_y[v65 + 1],
+              4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
+            memcpy(
+              &stru_50B700._screen_space_x[v65],
+              &stru_50B700._screen_space_x[v65 + 1],
+              4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
           }
           --v55;
         }
       }
       while ( v62 - 1 < v55 );
     }
-    _50BAC8_screen_space_x[v55] = _50BAC8_screen_space_x[0];
-    _50B9D8_screen_space_y[v55] = _50B9D8_screen_space_y[0];
+    stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0];
+    stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0];
   }
   return v55;
-}*/
-
+}
 //----- (00424579) --------------------------------------------------------
 int __fastcall sub_424579(int uFaceID, stru320 *a2)
 {
@@ -2882,8 +2457,8 @@
   v22 = min_y;
   if ( min_y <= max_y )
   {
-    //v56 = &a2->viewport_right_side[v7];
-    //v23 = &a2->viewport_left_side[v7];
+    //v56 = &a2->array_3D8[v7];
+    //v23 = &a2->array_18[v7];
     for ( v70 = min_y; v70 <= max_y; ++v70 )
     {
       v24 = v13;
@@ -2924,8 +2499,8 @@
           v61 = stru_50B700._screen_space_x[v29] << 16;
         }
       }
-	  //v34 = (char *)a2->viewport_left_side - (char *)a2->viewport_right_side;
-	  //v35 = *(__int16 *)((char *)&a2->viewport_right_side[v70] + v34);
+	  //v34 = (char *)a2->array_18 - (char *)a2->array_3D8;
+	  //v35 = *(__int16 *)((char *)&a2->array_3D8[v70] + v34);
       //v35 = HIWORD(v62);
       a2->viewport_left_side[v70] = HIWORD(v62);
       a2->viewport_right_side[v70] = HIWORD(v61);
@@ -2958,7 +2533,7 @@
   if ( min_y <= max_y )
   {
     //a3a = (char *)a2 - (char *)a3;
-    //v42 = &a3->viewport_right_side[v7];
+    //v42 = &a3->array_3D8[v7];
     //v57 = *(__int16 *)((char *)v42 + a3a);
     for ( v71 = min_y; v71 <= max_y; ++v71 )
     {
@@ -2972,7 +2547,7 @@
   if ( max_y < min_y )
     return false;
   //a3a = (char *)a2 - (char *)a3;
-  //v43 = &a3->viewport_right_side[v8];
+  //v43 = &a3->array_3D8[v8];
   //v58 = *(__int16 *)((char *)v43 + a3a);
   for ( v72 = max_y; v72 >= min_y; --v72 )
   {
@@ -2987,7 +2562,7 @@
     return false;
   //a3b = (char *)a3 - (char *)a2;
   v59 = min_y;
-  //v45 = &a2->viewport_left_side[v7];
+  //v45 = &a2->array_18[v7];
   
   for ( v46 = max_y - min_y + 1; v46; --v46 )
   {
@@ -3009,10 +2584,10 @@
   v49 = min_y + 1;
   if ( v49 <= max_y )
   {
-    //v50 = &a2->viewport_right_side[v49];
+    //v50 = &a2->array_3D8[v49];
     for ( v49; v49 <= max_y; ++v49 )
     {
-      //v51 = a2->viewport_left_side[v49];
+      //v51 = a2->array_18[v49];
       if ( a2->viewport_left_side[v49] < a2->field_8 )
       {
         a2->field_8 = a2->viewport_left_side[v49];
--- a/mm7_2.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/mm7_2.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -7986,86 +7986,6 @@
   return uCurrentMenuID;
 }
 
-
-//----- (00467E7F) --------------------------------------------------------
-void sub_467E7F_EquipBody(ITEM_EQUIP_TYPE uEquipType)
-{
-  //unsigned int v1; // esi@1
-  int v2; // ebx@1
-  Player *v3; // eax@1
-  int v4; // edx@1
-  int v5; // esi@2
-  //int v6; // eax@2
-  unsigned int v7; // eax@3
-  ItemGen _this; // [sp+Ch] [bp-30h]@1
-  //Player *v9; // [sp+30h] [bp-Ch]@1
-  int v10; // [sp+34h] [bp-8h]@1
-  int *v11; // [sp+38h] [bp-4h]@1
-
-  static unsigned char byte_4E8398[200] = // 4E8398
-  {
-     1, // EQUIP_OFF_HAND
-     1, // EQUIP_MAIN_HAND
-     2, // EQUIP_BOW
-     3, // EQUIP_ARMOUR
-     0, // EQUIP_SHIELD
-     4, // EQUIP_HELMET
-     5, // EQUIP_BELT
-     6, // EQUIP_CLOAK
-     7, // EQUIP_GAUNTLETS
-     8, // EQUIP_BOOTS
-    10, // EQUIP_RING
-     9, // EQUIP_AMULET
-     1, // EQUIP_WAND
-     0, // EQUIP_REAGENT
-     0, // EQUIP_POTION
-     0, // EQUIP_SPELL_SCROLL
-     0, // EQUIP_BOOK
-     0, // EQUIP_MESSAGE_SCROLL
-     0, // EQUIP_GOLD
-     0, // EQUIP_GEM
-     0, // EQUIP_NONE
-  // ???
-     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
-     0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0,  0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0,
-     0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0,  0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0,
-     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,  1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-     0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0,  0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0,
-     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 3, 3, 3, 3, 3, 3, 1, 1, 1,
-     1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-     0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2,  2, 0, 0, 0, 0, 0
-};
-
-  _this.Reset();
-  v2 = byte_4E8398[uEquipType];
-  v3 = pPlayers[uActiveCharacter];
-  v11 = (int *)&v3->pEquipment.pIndices[v2];
-  v4 = *v11;
-  v10 = *v11;
-  if ( v10 )
-  {
-    memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
-    v5 = (int)((char *)v3 + 4 * (9 * v4 - 9));
-    *(char *)(v5 + 556) = 0;
-    pParty->pPickedItem.Reset();
-    pParty->SetHoldingItem((ItemGen *)(v5 + 532));
-    _this.uBodyAnchor = v2 + 1;
-    memcpy((void *)(v5 + 532), &_this, 0x24u);
-    *v11 = v10;
-  }
-  else
-  {
-    v7 = v3->FindFreeInventorySlot();
-    if (v7 >= 0)
-    {
-      pParty->pPickedItem.uBodyAnchor = v2 + 1;
-      memcpy(&v3->pInventoryItems[v7], &pParty->pPickedItem, sizeof(v3->pInventoryItems[v7]));
-      *v11 = v7 + 1;
-      pMouse->RemoveHoldingItem();
-    }
-  }
-}
-
 //----- (00467F48) --------------------------------------------------------
 void CreateMsgScrollWindow( signed int mscroll_id )
     {
@@ -8239,7 +8159,7 @@
     }
     if ( pParty->pPickedItem.uItemID == 604 )
     {
-      sub_467E7F_EquipBody((ITEM_EQUIP_TYPE)3);
+      pPlayers[uActiveCharacter]->EquipBody((ITEM_EQUIP_TYPE)3);
       WetsuitOn(uActiveCharacter);
       return;
     }
@@ -8264,7 +8184,7 @@
 			pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
 			return;
 		}
-        sub_467E7F_EquipBody((ITEM_EQUIP_TYPE)v6);
+        pPlayers[uActiveCharacter]->EquipBody((ITEM_EQUIP_TYPE)v6);
         if ( pParty->pPickedItem.uItemID == 604 )
           WetsuitOff(uActiveCharacter);
         return;
@@ -9715,7 +9635,11 @@
     }
   }
   if ( v151 == OBJECT_BModel && PID_TYPE(v2->spell_caster_pid) != OBJECT_Player)
-    BYTE2(pActors[PID_ID(v2->spell_caster_pid)].uAttributes) |= 4u;
+      {
+      if (PID_ID(v2->spell_caster_pid)<500)  //bugfix  PID_ID(v2->spell_caster_pid)==1000
+         BYTE2(pActors[PID_ID(v2->spell_caster_pid)].uAttributes) |= 4;
+      }
+
   v6 = v2->uType;
   v7 = v2->uType;
   if ( v7 > 3060 )
@@ -9996,7 +9920,7 @@
             v127 = v9;
             v126 = v124;
 LABEL_268:
-            v116 = word_4EE088_sound_ids[v2->spell_id];
+            v116 = word_4EE088_sound_ids[v2->spell_id - 1];
 LABEL_269:
             v125 = v116 + 1;
             goto LABEL_29;
--- a/mm7_3.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/mm7_3.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -25,6 +25,7 @@
 #include "Party.h"
 #include "AudioPlayer.h"
 #include "Outdoor.h"
+#include "Outdoor_stuff.h"
 #include "IndoorCamera.h"
 #include "Overlays.h"
 #include "LOD.h"
@@ -1626,9 +1627,9 @@
     auto v67 = GetTickCount() / 500;
     if (dword_720CDC != v67 )
     {
-      dword_4F8580[3 * dword_4F8580[0] + 1] = pParty->vPosition.x;
-      dword_4F8580[3 * dword_4F8580[0] + 2] = pParty->vPosition.y;
-      dword_4F8580[3 * dword_4F8580[0]++ + 3] = pParty->vPosition.z;
+      dword_4F8580[3 * dword_4F8580[1]] = pParty->vPosition.x;
+      dword_4F8580[3 * dword_4F8580[2]] = pParty->vPosition.y;
+      dword_4F8580[3 * dword_4F8580[3]] = pParty->vPosition.z;
       if ( dword_4F8580[0] > 60 )
         dword_4F8580[0] = 1;
     }
--- a/mm7_4.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/mm7_4.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -24,6 +24,7 @@
 #include "Party.h"
 #include "AudioPlayer.h"
 #include "Outdoor.h"
+#include "Outdoor_stuff.h"
 #include "IndoorCamera.h"
 #include "LOD.h"
 #include "Actor.h"
@@ -3594,26 +3595,26 @@
             v37 = &p2DEvents[(signed int)a4 - 1].fPriceMultiplier;
             v38 = *v37;
             v39 = a3->GetValue();
-            v29 = pPlayer->_4B8233(v39, v38);
+            v29 = pPlayer->GetBaseBuyingPrice(v39, v38);
           switch ( a5 )
           {
             case 3:
               v44 = *v37;
               v45 = a3->GetValue();
-              v29 = pPlayer->_4B8213(v45, v44);
+              v29 = pPlayer->GetBaseSellingPrice(v45, v44);
               break;
             case 4:
-              v29 = pPlayer->_4B824B(*v37);
+              v29 = pPlayer->GetBaseIdentifyPrice(*v37);
               break;
             case 5:
               v42 = *v37;
               v43 = a3->GetValue();
-              v29 = pPlayer->_4B8265(v43, v42);
+              v29 = pPlayer->GetBaseRepairPrice(v43, v42);
               break;
             case 6:
               v40 = *v37;
               v41 = a3->GetValue();
-              v29 = pPlayer->_4B8213(v41, v40) / 2;
+              v29 = pPlayer->GetBaseSellingPrice(v41, v40) / 2;
               break;
             }
             goto _continue_sprintf;
--- a/mm7_5.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/mm7_5.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -728,7 +728,7 @@
             }
             v19 = (double)(signed int)uGammaPos * 0.1 + 0.6;
             pGame->pGammaController->Initialize(v19);
-            GUIWindow::Create(21, 161, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, 1);
+            GUIWindow::Create(21, 161, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, (char *)1);
             pAudioPlayer->PlaySound((SoundID)21, 0, 0, -1, 0, 0, 0, 0);
             continue;
           }
@@ -739,7 +739,7 @@
             {
               v21 = (double)(signed int)uGammaPos * 0.1 + 0.6;
               pGame->pGammaController->Initialize(v21);
-              GUIWindow::Create(213, 161, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderRight, 1);
+              GUIWindow::Create(213, 161, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderRight, (char *)1);
               pAudioPlayer->PlaySound((SoundID)21, 0, 0, -1, 0, 0, 0, 0);
               continue;
             }
@@ -768,7 +768,7 @@
             --uMusicVolimeMultiplier;
             if ( (char)uMusicVolimeMultiplier < 1 )
               uMusicVolimeMultiplier = 0;
-            GUIWindow::Create(243, 0xD8u, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, 1);
+            GUIWindow::Create(243, 0xD8u, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, (char *)1);
             if ( uMusicVolimeMultiplier )
               pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0, pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0f, 0);
             pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0f);
@@ -779,7 +779,7 @@
             ++uMusicVolimeMultiplier;
             if ( (char)uMusicVolimeMultiplier > 9 )
               uMusicVolimeMultiplier = 9;
-            GUIWindow::Create(435, 0xD8u, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderRight, 1);
+            GUIWindow::Create(435, 0xD8u, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderRight, (char *)1);
             if ( uMusicVolimeMultiplier )
               pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0, pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0f, 0);
             pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0f);
@@ -798,7 +798,7 @@
             --uSoundVolumeMultiplier;
             if ( (char)uSoundVolumeMultiplier < 1 )
               uSoundVolumeMultiplier = 0;
-            GUIWindow::Create(243, 162, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, 1);
+            GUIWindow::Create(243, 162, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, (char *)1);
             pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f);
             pAudioPlayer->PlaySound((SoundID)218, -1, 0, -1, 0, 0, 0, 0);
             continue;
@@ -811,7 +811,7 @@
             //v168 = 1;
             v24 = 435;
             //v154 = (int)pBtn_SliderRight;
-            GUIWindow::Create(v24, 0xA2u, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderRight, 1);
+            GUIWindow::Create(v24, 0xA2u, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderRight, (char *)1);
             pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f);
             pAudioPlayer->PlaySound((SoundID)218, -1, 0, -1, 0, 0, 0, 0);
             continue;
@@ -840,7 +840,7 @@
             --uVoicesVolumeMultiplier;
             if ( (char)uVoicesVolumeMultiplier < 1 )
               uVoicesVolumeMultiplier = 0;
-            GUIWindow::Create(243, 270, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, 1);
+            GUIWindow::Create(243, 270, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, (char *)1);
             if ( !uVoicesVolumeMultiplier )
               continue;
             pAudioPlayer->PlaySound((SoundID)5788, -1, 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0);
@@ -851,7 +851,7 @@
             ++uVoicesVolumeMultiplier;
             if ( (char)uVoicesVolumeMultiplier > 8 )
               uVoicesVolumeMultiplier = 9;
-            GUIWindow::Create(435, 270, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderRight, 1);
+            GUIWindow::Create(435, 270, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderRight, (char *)1);
             if ( !uVoicesVolumeMultiplier )
               continue;
             pAudioPlayer->PlaySound((SoundID)5788, -1, 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0);
@@ -1514,7 +1514,7 @@
             if ( !pGUIWindow_Settings )//Draw Menu
             {
               dword_6BE138 = -1;
-              GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, WINDOW_PressedButton2, (int)pBtn_GameSettings, 1);
+              GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, WINDOW_PressedButton2, (int)pBtn_GameSettings, (char *)1);
               pEventTimer->Pause();
               pAudioPlayer->StopChannels(-1, -1);
               pCurrentScreen = SCREEN_MENU;
@@ -1948,7 +1948,7 @@
 
         case UIMSG_OnCastTownPortal:
           pAudioPlayer->StopChannels(-1, -1);
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, WINDOW_TownPortal, uMessageParam);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, WINDOW_TownPortal, (char *)uMessageParam);
         continue;
 
         case UIMSG_OnCastLloydsBeacon:
@@ -2136,7 +2136,7 @@
                     _5B65B8_npcdata_hiword_house_or_other = v66;
                     InitializeActors();
                   }
-                  v67 = pGUIWindow_CurrentMenu->Hint;
+                  v67 = (char*)pGUIWindow_CurrentMenu->Hint;
                   if ( v67 )
                     *((int *)v67 + 17) = 1;
                   else
@@ -2455,7 +2455,7 @@
             _42ECB5_PlayerAttacksActor();
           continue;
         case UIMSG_ExitRest:
-          GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_CloseRestWindowBtn, (int)pButton_RestUI_Exit, (int)pGlobalTXT_LocalizationStrings[81]);// "Exit Rest"
+          GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_CloseRestWindowBtn, (int)pButton_RestUI_Exit, pGlobalTXT_LocalizationStrings[81]);// "Exit Rest"
           continue;
         case UIMSG_Wait5Minutes:
           if ( dword_506F14 == 2 )
@@ -2465,7 +2465,7 @@
             continue;
           }
           GUIWindow::Create(pButton_RestUI_Wait5Minutes->uX, pButton_RestUI_Wait5Minutes->uY, 0, 0, WINDOW_PressedButton2,
-            (int)pButton_RestUI_Wait5Minutes, (int)pGlobalTXT_LocalizationStrings[238]);// "Wait 5 Minutes"
+            (int)pButton_RestUI_Wait5Minutes, pGlobalTXT_LocalizationStrings[238]);// "Wait 5 Minutes"
           dword_506F14 = 1;
           _506F18_num_hours_to_sleep = 5;
           continue;
@@ -2477,7 +2477,7 @@
             continue;
           }
           GUIWindow::Create(pButton_RestUI_Wait1Hour->uX, pButton_RestUI_Wait1Hour->uY, 0, 0, WINDOW_PressedButton2,
-            (int)pButton_RestUI_Wait1Hour, (int)pGlobalTXT_LocalizationStrings[239]);// "Wait 1 Hour"
+            (int)pButton_RestUI_Wait1Hour, pGlobalTXT_LocalizationStrings[239]);// "Wait 1 Hour"
           dword_506F14 = 1;
           _506F18_num_hours_to_sleep = 60;
           continue;
@@ -2615,7 +2615,7 @@
             continue;
           }
           GUIWindow::Create(pButton_RestUI_WaitUntilDawn->uX, pButton_RestUI_WaitUntilDawn->uY, 0, 0, WINDOW_PressedButton2,
-            (int)pButton_RestUI_WaitUntilDawn, (int)pGlobalTXT_LocalizationStrings[237]);// "Wait until Dawn"
+            (int)pButton_RestUI_WaitUntilDawn, pGlobalTXT_LocalizationStrings[237]);// "Wait until Dawn"
           v97 = _494820_training_time(pParty->uCurrentHour);
           dword_506F14 = 1;
           _506F18_num_hours_to_sleep = 60 * v97 - pParty->uCurrentMinute;
@@ -3011,7 +3011,7 @@
             default:
               continue;
           }
-          GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_PressedButton, (int)pButton, 1);
+          GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_PressedButton, (int)pButton, (char *)1);
           continue;
         case UIMSG_SelectCharacter:
           if ( pMessageQueue_50CBD0->uNumMessages )
@@ -3336,7 +3336,7 @@
           }
           while (player->GetSexByVoice() != pSex);
           pButton = pCreationUI_BtnPressLeft2[pParam];
-          GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_PressedButton, (int)pButton, 1);
+          GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_PressedButton, (int)pButton, (char *)1);
           pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
           player->PlaySound(SPEECH_PickMe, 0);
           break;
@@ -3348,7 +3348,7 @@
           }
           while (player->GetSexByVoice() != pSex);
           pButton = pCreationUI_BtnPressRight2[pParam];
-          GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_PressedButton, (int)pButton, 1);
+          GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_PressedButton, (int)pButton, (char *)1);
           pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
           player->PlaySound(SPEECH_PickMe, 0);
           break;
@@ -3366,7 +3366,7 @@
           pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
                                                     % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam;
           uPlayerCreationUI_SelectedCharacter = v25;
-          GUIWindow::Create(pCreationUI_BtnPressLeft[v25]->uX, pCreationUI_BtnPressLeft[v25]->uY, 0, 0, WINDOW_PressedButton, (int)pCreationUI_BtnPressLeft[v25], 1);
+          GUIWindow::Create(pCreationUI_BtnPressLeft[v25]->uX, pCreationUI_BtnPressLeft[v25]->uY, 0, 0, WINDOW_PressedButton, (int)pCreationUI_BtnPressLeft[v25], (char *)1);
           pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0.0, 0);
           pPlayer->PlaySound(SPEECH_PickMe, 0);
           break;
@@ -3382,17 +3382,17 @@
           pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
                                                     % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam;
           uPlayerCreationUI_SelectedCharacter = v21;
-          GUIWindow::Create(pCreationUI_BtnPressRight[v21]->uX, pCreationUI_BtnPressRight[v21]->uY, 0, 0, WINDOW_PressedButton, (int)pCreationUI_BtnPressRight[v21], 1);
+          GUIWindow::Create(pCreationUI_BtnPressRight[v21]->uX, pCreationUI_BtnPressRight[v21]->uY, 0, 0, WINDOW_PressedButton, (int)pCreationUI_BtnPressRight[v21], (char *)1);
           pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
           pPlayer->PlaySound(SPEECH_PickMe, 0);
           break;
         case UIMSG_PlayerCreationClickPlus:
-          GUIWindow::Create(613, 393, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnPlus, 1);
+          GUIWindow::Create(613, 393, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnPlus, (char *)1);
           pPlayer[uPlayerCreationUI_SelectedCharacter].IncreaseAttribute((pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7);
           pAudioPlayer->PlaySound((SoundID)20, 0, 0, -1, 0, 0, 0, 0);
           break;
         case UIMSG_PlayerCreationClickMinus:
-          GUIWindow::Create(523, 393, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnMinus, 1);
+          GUIWindow::Create(523, 393, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnMinus, (char *)1);
           pPlayer[uPlayerCreationUI_SelectedCharacter].DecreaseAttribute((pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7);
           pAudioPlayer->PlaySound((SoundID)23, 0, 0, -1, 0, 0, 0, 0);
           break;
@@ -3409,7 +3409,7 @@
           break;
         case UIMSG_PlayerCreationClickOK:
           GUIWindow::Create(580, 431, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnOK, 0);
-          if ( PlayerCreation_ComputeAttributeBonus() || !PlayerCreation_Chose4Skills() )
+          if ( PlayerCreation_GetUnspentAttributePointCount() || !PlayerCreation_Chose4Skills() )
             GameUI_Footer_TimeLeft = GetTickCount() + 4000;
           else
             uGameState = GAME_STATE_STARTING_NEW_GAME;
@@ -9539,7 +9539,7 @@
 {
   GUIWindow *pWindow; // esi@4
   //unsigned int pWindowType; // eax@4
-  char *pHint; // edx@66
+  const char *pHint; // edx@66
   GUIButton *pButtonPtr_1C; // ebp@79
   char *pHint1; // edx@80
   int v26; // eax@98
--- a/mm7_6.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/mm7_6.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -6,6 +6,7 @@
 
 
 
+
 #include "Sprites.h"
 #include "BSPModel.h"
 #include "OutdoorCamera.h"
@@ -20,6 +21,7 @@
 #include "Party.h"
 #include "AudioPlayer.h"
 #include "Outdoor.h"
+#include "Outdoor_stuff.h"
 #include "Overlays.h"
 #include "LOD.h"
 #include "Actor.h"
@@ -2779,8 +2781,8 @@
     if (pCastSpell->forced_spell_skill_level)
       uRequiredMana = 0;
     else 
-      uRequiredMana = pSpellDatas[pCastSpell->spellnum].mana_per_skill[v731 - 1];
-    sRecoveryTime = pSpellDatas[pCastSpell->spellnum].recovery_per_skill[v731 - 1];
+      uRequiredMana = pSpellDatas[pCastSpell->spellnum - 1].mana_per_skill[v731 - 1];
+    sRecoveryTime = pSpellDatas[pCastSpell->spellnum - 1].recovery_per_skill[v731 - 1];
 
     if (LODWORD(v725) == PLAYER_SKILL_DARK && pParty->uCurrentHour == 0 && pParty->uCurrentMinute == 0 ||
         LODWORD(v725) == PLAYER_SKILL_LIGHT && pParty->uCurrentHour == 12 && pParty->uCurrentMinute == 0)
--- a/mm7_data.cpp	Mon Jun 17 09:09:03 2013 +0600
+++ b/mm7_data.cpp	Mon Jun 17 09:09:30 2013 +0600
@@ -484,7 +484,7 @@
 
 std::array<unsigned int, 4> pHealthBarPos = {{22, 137, 251, 366}};
 std::array<unsigned int, 4> pManaBarPos = {{102, 217, 331, 447}};
-std::array<char, 80> _4E2B21_buff_spell_tooltip_colors;
+
 std::array<char, 88> monster_popup_y_offsets =
 {{
   -20,  20,   0, -40,   0,   0,   0,   0,   0,   0, -50,
@@ -887,7 +887,7 @@
 int ai_arrays_size; // weak
 std::array<int, 500> ai_near_actors_distances;
 std::array<unsigned int, 500> ai_near_actors_ids;
-std::array<int, 121> dword_4F8580; // weak
+std::array<int, 182> dword_4F8580; // weak
 
 
 
--- a/mm7_data.h	Mon Jun 17 09:09:03 2013 +0600
+++ b/mm7_data.h	Mon Jun 17 09:09:30 2013 +0600
@@ -3,7 +3,6 @@
 #include "VectorTypes.h"
 #include "OSAPI.h"
 #include <array>
-#include "Items.h"    //TODO: remove this once sub_467E7F_EquipBody if moved to a class or something
 typedef char _UNKNOWN;
 
 
@@ -432,7 +431,7 @@
 //extern int pMagicSkills[9];
 extern std::array<unsigned int, 4> pHealthBarPos;
 extern std::array<unsigned int, 4> pManaBarPos;
-extern std::array<char, 80> _4E2B21_buff_spell_tooltip_colors;
+//extern std::array<char, 80> _4E2B21_buff_spell_tooltip_colors;
 extern std::array<char, 88>  monster_popup_y_offsets; // weak
 extern unsigned char hourglass_icon_idx; // weak
 
@@ -528,7 +527,7 @@
 extern int ai_arrays_size; // weak
 extern std::array<int, 500> ai_near_actors_distances;
 extern std::array<unsigned int, 500> ai_near_actors_ids;
-extern std::array<int, 121> dword_4F8580; // weak
+extern std::array<int, 182> dword_4F8580; // weak
 extern int dword_4FA9B0[]; // weak
 extern int dword_4FA9B4[]; // weak
 
@@ -1344,7 +1343,6 @@
 enum MENU_STATE GetCurrentMenuID();
 void *__thiscall output_debug_string(void *_this, std::string a2, const char *a3, int a4);
 std::string *__fastcall _4678E2_make_error_string(std::string *a1, int line, std::string file);
-void sub_467E7F_EquipBody(ITEM_EQUIP_TYPE uEquipType); // idb
 void  CreateMsgScrollWindow(signed int mscroll_id);
 void __cdecl free_book_subwindow();
 void  CreateScrollWindow();
@@ -1448,7 +1446,7 @@
 void __fastcall RGB2HSV(float *a1, float *a2, float a3, float a4, float a5, float *a6);
 unsigned int ReplaceHSV(unsigned int uColor, float a2, float gamma, float a4);
 signed int __cdecl PlayerCreation_Chose4Skills();
-signed int __cdecl PlayerCreation_ComputeAttributeBonus();
+signed int __cdecl PlayerCreation_GetUnspentAttributePointCount();
 void LoadPlayerPortraintsAndVoices();
 int __fastcall ReloadPlayerPortraits(int, int); // weak
 void sub_491E3A();
--- a/stru367.h	Mon Jun 17 09:09:03 2013 +0600
+++ b/stru367.h	Mon Jun 17 09:09:30 2013 +0600
@@ -7,34 +7,12 @@
 struct stru367
 {
 	int field_0;
-	int field_4[13];
-	int field_38[2];//new point x for near plane
-	int _view_transformed_ys_minus1;
-	int _view_transformed_ys[57];//origin coordinates x
-	int field_128[2];//new point y for near plane
-	int _view_transformed_zs_minus1;
-	int _view_transformed_zs[57];//origin coordinates y
-	int field_218[2];//new point z for near plane
-	int _view_transformed_xs_minus1;
-	int _view_transformed_xs[45];//origin coordinates z
-	int _screen_space_y[2];
-	int field_2E0;
-	int field_2E4[2];
-	int field_2EC;
-	int field_2F0[2];//new point y for right plane
-	int field_2F8;
-	int _ys[3];//new point x for left plane
-	int _ys2[48];//
-	int _screen_space_x[2];
-	int field_3D0;
-	int field_3D4[2];//new point x for top plane
-	int field_3DC;
-	//int field_3E0;
-	int _xs[54];//
-	int field_3E4;
-	int field_3E8;
-	int _xs2[3];//new point y for left plane
-	int _xs3[48];// 
+	std::array<int, 13> field_4;
+	std::array<int, 60> _view_transformed_ys;
+	std::array<int, 60> _view_transformed_zs;
+	std::array<int, 48> _view_transformed_xs;
+	std::array<int, 60> _screen_space_y;
+	std::array<int, 60> _screen_space_x;
 };
 #pragma pack(pop)