changeset 1433:a6d966e85611

Merge
author Nomad
date Fri, 02 Aug 2013 19:28:59 +0200
parents 2489c8aeac90 (current diff) 4d13549db029 (diff)
children 6de9c1316852
files Player.cpp
diffstat 8 files changed, 577 insertions(+), 727 deletions(-) [+]
line wrap: on
line diff
--- a/CastSpellInfo.cpp	Fri Aug 02 19:28:36 2013 +0200
+++ b/CastSpellInfo.cpp	Fri Aug 02 19:28:59 2013 +0200
@@ -4088,7 +4088,7 @@
   return -1;
 }
 //----- (00427D48) --------------------------------------------------------
-void CastSpellInfo::_427D48(unsigned int uPlayerID)
+void CastSpellInfo::_427D48(unsigned int uPlayerID)//Press S
 {
   CastSpellInfo *v2; // esi@1
   signed int v3; // ebx@1
--- a/GUIWindow.cpp	Fri Aug 02 19:28:36 2013 +0200
+++ b/GUIWindow.cpp	Fri Aug 02 19:28:59 2013 +0200
@@ -460,9 +460,9 @@
           max_beacons = 3;
 
       
-      __debugbreak(); // warning C4700: uninitialized local variable 'v19' used
+      //__debugbreak(); // warning C4700: uninitialized local variable 'v19' used
       for (int i =0; i< max_beacons; ++i)
-            CreateButton(pLloydsBeaconsPreviewXs[v19], pLloydsBeaconsPreviewYs[v19],
+            CreateButton(pLloydsBeaconsPreviewXs[i], pLloydsBeaconsPreviewYs[i],
                            92, 68, 1, 180, UIMSG_InstallBeacon, i, 0, "", 0);
 
       for (int i =0; i< 5; ++i)
--- a/Player.cpp	Fri Aug 02 19:28:36 2013 +0200
+++ b/Player.cpp	Fri Aug 02 19:28:59 2013 +0200
@@ -8628,7 +8628,7 @@
     }
   }
 
-  assert(false);
+  //assert(false);
   return false;
 }
 // 5B65C4: using guessed type int dword_5B65C4;
--- a/Player.h	Fri Aug 02 19:28:36 2013 +0200
+++ b/Player.h	Fri Aug 02 19:28:59 2013 +0200
@@ -294,11 +294,12 @@
 struct LloydBeacon
 {
   unsigned __int64 uBeaconTime;
-  int field_8;
-  int field_C;
-  int field_10;
-  int field_14;
-  int field_18;
+  int PartyPos_X;
+  int PartyPos_Y;
+  int PartyPos_Z;
+  __int16 PartyRot_X;
+  __int16 PartyRot_Y;
+  int SaveFileID;
 };
 #pragma pack(pop)
 
--- a/Render.cpp	Fri Aug 02 19:28:36 2013 +0200
+++ b/Render.cpp	Fri Aug 02 19:28:59 2013 +0200
@@ -2753,7 +2753,7 @@
 //----- (0049F8B5) --------------------------------------------------------
 FILE *Render::SavePCXImage(const char *Filename, char *a3, int a4, int a5)
 {
-  Render *v5; // esi@1
+  //Render *v5; // esi@1
   FILE *result; // eax@1
   FILE *v7; // edi@4
   int v8; // ecx@5
@@ -2775,7 +2775,6 @@
   int v24; // [sp+9Ch] [bp-8h]@2
   char *i; // [sp+A0h] [bp-4h]@8
 
-  v5 = this;
   result = fopen(Filename, "wb");
   Filename = (const char *)result;
   if ( result )
@@ -2836,16 +2835,16 @@
           i = (char *)ptr + 2 * v24;
           do
           {
-            *((char *)ptr + v10) = (signed int)(v5->uTargetRMask & *(short *)a5) >> (LOBYTE(v5->uTargetGBits)
-                                                                                    + LOBYTE(v5->uTargetBBits)
-                                                                                    + v5->uTargetRBits
+            *((char *)ptr + v10) = (signed int)(this->uTargetRMask & *(short *)a5) >> (LOBYTE(this->uTargetGBits)
+                                                                                    + LOBYTE(this->uTargetBBits)
+                                                                                    + this->uTargetRBits
                                                                                     - 8);
-            a3[v10] = (signed int)(v5->uTargetGMask & *(short *)a5) >> (LOBYTE(v5->uTargetBBits)
-                                                                      + LOBYTE(v5->uTargetGBits)
+            a3[v10] = (signed int)(this->uTargetGMask & *(short *)a5) >> (LOBYTE(this->uTargetBBits)
+                                                                      + LOBYTE(this->uTargetGBits)
                                                                       - 8);
             v11 = a5;
             a5 += 2;
-            i[v10++] = (v5->uTargetBMask & *(char *)v11) << (8 - LOBYTE(v5->uTargetBBits));
+            i[v10++] = (this->uTargetBMask & *(char *)v11) << (8 - LOBYTE(this->uTargetBBits));
           }
           while ( v10 < a4 );
         }
--- a/SaveLoad.cpp	Fri Aug 02 19:28:36 2013 +0200
+++ b/SaveLoad.cpp	Fri Aug 02 19:28:59 2013 +0200
@@ -795,34 +795,27 @@
     v26 = pRenderer->uTargetSurfacePitch;
     if ( pRenderer->pTargetSurface )
     {
-      v29 = 0;
       if ( height > 0 )
       {
-        do
+        for ( v29 = 0; v29 < height; ++v29 )
         {
-          v28 = 0;
           if ( width > 0 )
           {
             v15 = v26 * (unsigned __int64)(signed __int64)((double)v29 * v25 + 8.0);
-            do
+            for ( v28 = 0; v28 < width; v28++ )
             {
-              v16 = (signed __int64)((double)v28++ * v23 + 8.0);
-              *v3 = _this[v15 + (int)v16];
+              *v3 = _this[v15 + (int)(signed __int64)((double)v28 * v23 + 8.0)];
               ++v3;
             }
-            while ( v28 < width );
           }
-          ++v29;
         }
-        while ( v29 < height );
       }
     }
     else
     {
       if ( height > 0 )
       {
-        v17 = height;
-        do
+        for ( v17 = height; v17; --v17 )
         {
           if ( width > 0 )
           {
@@ -835,9 +828,7 @@
             }
             v3 += width;
           }
-          --v17;
         }
-        while ( v17 );
       }
     }
     pRenderer->EndScene();
@@ -847,11 +838,9 @@
 //----- (0045E26C) --------------------------------------------------------
 void __thiscall SaveScreenshot(const char *pFilename)
 {
-  const char *v1; // edi@1
   unsigned __int16 *v2; // esi@1
 
-  v1 = pFilename;
   v2 = MakeScreenshot(92, 68);
-  pRenderer->SavePCXImage(v1, (char *)v2, 92, 68);
+  pRenderer->SavePCXImage(pFilename, (char *)v2, 92, 68);
   free(v2);
 }
\ No newline at end of file
--- a/UI/Books/UIMapBook.cpp	Fri Aug 02 19:28:36 2013 +0200
+++ b/UI/Books/UIMapBook.cpp	Fri Aug 02 19:28:59 2013 +0200
@@ -88,34 +88,34 @@
 unsigned int __cdecl DrawLloydBeaconsScreen()
 {
   Player *pPlayer; // esi@1
-  char *v1; // eax@1
-  unsigned __int16 v2; // ax@6
-  unsigned int result; // eax@11
-  unsigned int v4; // esi@13
-  unsigned int v5; // ecx@13
-  char v6; // zf@13
-  LloydBeacon *v7; // esi@14
-  int v8; // eax@14
-  unsigned __int64 v9; // kr08_8@14
-  unsigned int v10; // esi@14
-  unsigned int v11; // eax@14
-  char *v12; // eax@19
-  char *v13; // ecx@22
-  int v14; // eax@27
+  char *pText; // eax@1
+  //unsigned __int16 v2; // ax@6
+  //unsigned int result; // eax@11
+  //unsigned int v4; // esi@13
+  //unsigned int v5; // ecx@13
+  //char v6; // zf@13
+  //LloydBeacon *v7; // esi@14
+  int pTextHeight; // eax@14
+  int RemainingTime; // kr08_8@14
+  unsigned int pHours; // esi@14
+  unsigned int pDays; // eax@14
+  char *pSelectionText; // eax@19
+  //char *v13; // ecx@22
+  //int v14; // eax@27
   Texture *v19; // [sp-4h] [bp-8Ch]@4
   GUIWindow pWindow; // [sp+Ch] [bp-7Ch]@1
-  unsigned int v23; // [sp+64h] [bp-24h]@14
-  __int64 v24; // [sp+68h] [bp-20h]@14
-  unsigned int v25; // [sp+70h] [bp-18h]@13
+  //unsigned int v23; // [sp+64h] [bp-24h]@14
+  //__int64 v24; // [sp+68h] [bp-20h]@14
+  //unsigned int v25; // [sp+70h] [bp-18h]@13
   char *Str; // [sp+74h] [bp-14h]@14
-  int v27; // [sp+78h] [bp-10h]@11
-  LloydBeacon *v28; // [sp+7Ch] [bp-Ch]@12
-  RGBTexture *v29; // [sp+80h] [bp-8h]@12
+  int BeaconID; // [sp+78h] [bp-10h]@11
+  //LloydBeacon *v28; // [sp+7Ch] [bp-Ch]@12
+  //RGBTexture *v29; // [sp+80h] [bp-8h]@12
   int uNumMaxBeacons; // [sp+84h] [bp-4h]@6
 
   pPlayer = &pParty->pPlayers[_506348_current_lloyd_playerid];
-  pRenderer->DrawTextureIndexed(8u, 8u, pTexture_LloydBeacons[(unsigned __int8)bRecallingBeacon]);
-  v1 = pGlobalTXT_LocalizationStrings[523];     // Recall Beacon
+  pRenderer->DrawTextureIndexed(8, 8, pTexture_LloydBeacons[(unsigned __int8)bRecallingBeacon]);
+  pText = pGlobalTXT_LocalizationStrings[523];     // Recall Beacon
   pWindow.uFrameX = game_viewport_x;
   pWindow.uFrameY = game_viewport_y;
   pWindow.uFrameWidth = 428;
@@ -123,9 +123,9 @@
   pWindow.uFrameZ = 435;
   pWindow.uFrameW = game_viewport_w;
   if ( !bRecallingBeacon )
-    v1 = pGlobalTXT_LocalizationStrings[375];   // Set Beacon
-  sprintf(pTmpBuf.data(), "%s", v1);
-  pWindow.DrawTitleText(pBook2Font, 0, 22u, 0, pTmpBuf.data(), 3u);
+    pText = pGlobalTXT_LocalizationStrings[375];   // Set Beacon
+  sprintf(pTmpBuf.data(), "%s", pText);
+  pWindow.DrawTitleText(pBook2Font, 0, 22u, 0, pTmpBuf.data(), 3);
   if ( bRecallingBeacon )
   {
     pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6b__zoom_on);
@@ -137,649 +137,531 @@
     v19 = pTex_tab_an_6b__zoom_on;
   }
   pRenderer->DrawTextureTransparent(pBtn_Book_2->uX, pBtn_Book_2->uY, v19);
-  v2 = pPlayer->pActiveSkills[14];
   uNumMaxBeacons = 1;
-  if ( HIBYTE(v2) & 1 || (v2 & 0x80u) != 0 )
+  if ( HIBYTE(pPlayer->pActiveSkills[14]) & 1 || (pPlayer->pActiveSkills[14] & 0x80u) != 0 )
   {
     uNumMaxBeacons = 5;
   }
   else
   {
-    if ( v2 & 0x40 )
+    if ( pPlayer->pActiveSkills[14] & 0x40 )
       uNumMaxBeacons = 3;
   }
-  result = 0;
-  v27 = 0;
   if ( uNumMaxBeacons > 0 )
   {
-    v29 = pSavegameThumbnails.data();
-    v28 = pPlayer->pInstalledBeacons;
-    while ( 1 )
+    for ( BeaconID = 0; BeaconID < uNumMaxBeacons; BeaconID++ )
     {
       pWindow.uFrameWidth = 92;
-      v4 = result;
       pWindow.uFrameHeight = 68;
-      v5 = pLloydsBeaconsPreviewXs[result];
-      pWindow.uFrameY = pLloydsBeaconsPreviewYs[result];
-      v25 = pWindow.uFrameY;
-      pWindow.uFrameX = v5;
+      pWindow.uFrameY = pLloydsBeaconsPreviewYs[BeaconID];
+      pWindow.uFrameX = pLloydsBeaconsPreviewXs[BeaconID];
       pWindow.uFrameW = pWindow.uFrameY + 67;
-      v6 = v29->pPixels == 0;
-      pWindow.uFrameZ = v5 + 91;
-      if ( !v6 )
-        break;
+      pWindow.uFrameZ = pLloydsBeaconsPreviewXs[BeaconID] + 91;
+      //if ( pSavegameThumbnails[BeaconID].pPixels != 0 )
+      if ( pPlayer->pInstalledBeacons[BeaconID].SaveFileID != 0 )
+      {
+        pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[BeaconID], pLloydsBeacons_SomeYs[BeaconID], pTexture_CurrentBook);
+        pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[BeaconID], pLloydsBeaconsPreviewYs[BeaconID], &pSavegameThumbnails[BeaconID]);
+        Str = pMapStats->pInfos[sub_410D99_get_map_index(pPlayer->pInstalledBeacons[BeaconID].SaveFileID)].pName;
+        pTextHeight = pSpellFont->CalcTextHeight(Str, &pWindow, 0, 0);
+        pWindow.uFrameY += -6 - pTextHeight;
+        pWindow.DrawTitleText(pSpellFont, 0, 0, 1, Str, 3);
+        RemainingTime = pPlayer->pInstalledBeacons[BeaconID].uBeaconTime - pParty->uTimePlayed;
+        pHours = (signed __int64)((double)RemainingTime * 0.234375) / 60 / 60;
+        pDays = pHours / 24;
+        if ( pDays )
+        {
+          sprintf(pTmpBuf.data(), "%lu %s", pDays + 1, pGlobalTXT_LocalizationStrings[57]);//days
+          pWindow.uFrameY = pWindow.uFrameY + pWindow.uFrameHeight + 4;
+          pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
+          continue;
+        }
+        else
+        {
+          if ( pHours + 1 <= 23 )
+          {
+            if ( pHours < 1 )
+              pSelectionText = pGlobalTXT_LocalizationStrings[109];// Hour
+            else
+              pSelectionText = pGlobalTXT_LocalizationStrings[110];// Hours
+            sprintf(pTmpBuf.data(), "%lu %s", pHours + 1, pSelectionText);
+            pWindow.uFrameY = pWindow.uFrameY + pWindow.uFrameHeight + 4;
+            pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
+            continue;
+          }
+        }
+        sprintf(pTmpBuf.data(), "%lu %s", pDays + 1, pGlobalTXT_LocalizationStrings[56]);//Day
+        pWindow.uFrameY = pWindow.uFrameY + pWindow.uFrameHeight + 4;
+        pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
+        continue;
+      }
       if ( !bRecallingBeacon )
       {
-        pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[v4], pLloydsBeacons_SomeYs[v4], pTexture_CurrentBook);
-        v14 = pSpellFont->CalcTextHeight(pGlobalTXT_LocalizationStrings[19], &pWindow, 0, 0);
-        pWindow.DrawTitleText(pSpellFont, 0, (signed int)pWindow.uFrameHeight / 2 - v14 / 2, 1, pGlobalTXT_LocalizationStrings[19], 3);
-      }
-LABEL_29:
-      ++v29;
-      ++v28;
-      result = v27++ + 1;
-      if ( v27 >= uNumMaxBeacons )
-        goto LABEL_30;
-    }
-    pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[v4], pLloydsBeacons_SomeYs[v4], pTexture_CurrentBook);
-    pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[v4], pLloydsBeaconsPreviewYs[v4], v29);
-    v7 = v28;
-    Str = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(v28->field_18))].pName;
-    v8 = pSpellFont->CalcTextHeight(Str, &pWindow, 0, 0);
-    pWindow.uFrameY += -6 - v8;
-    pWindow.DrawTitleText(pSpellFont, 0, 0, 1u, Str, 3u);
-    v9 = v7->uBeaconTime - pParty->uTimePlayed;
-    LODWORD(v24) = LODWORD(v7->uBeaconTime) - LODWORD(pParty->uTimePlayed);
-    HIDWORD(v24) = HIDWORD(v9);
-    v23 = (unsigned __int64)((signed __int64)((double)v24 * 0.234375) / 60 / 60) >> 32;
-    v10 = (signed __int64)((double)v24 * 0.234375) / 60 / 60;
-    v11 = v10 / 0x18;
-    if ( (unsigned int)((signed __int64)((double)v24 * 0.234375) / 60 / 60) / 0x18 )
-    {
-      v13 = pGlobalTXT_LocalizationStrings[57]; // Days
-      if ( v11 > 1 )
-      {
-        sprintf(pTmpBuf.data(), "%lu %s", v11 + 1, v13);
-        pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4;
-        pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
-        goto LABEL_29;
+        pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[BeaconID], pLloydsBeacons_SomeYs[BeaconID], pTexture_CurrentBook);
+        pTextHeight = pSpellFont->CalcTextHeight(pGlobalTXT_LocalizationStrings[19], &pWindow, 0, 0);
+        pWindow.DrawTitleText(pSpellFont, 0, (signed int)pWindow.uFrameHeight / 2 - pTextHeight / 2, 1, pGlobalTXT_LocalizationStrings[19], 3);//Доступно
       }
     }
-    else
-    {
-      if ( (signed __int64)(__PAIR__(v23, v10) + 1) <= 23 )
-      {
-        if ( (v23 & 0x80000000u) != 0 || (signed int)v23 <= 0 && v10 <= 1 )
-          v12 = pGlobalTXT_LocalizationStrings[109];// Hour
-        else
-          v12 = pGlobalTXT_LocalizationStrings[110];// Hours
-        sprintf(pTmpBuf.data(), "%lu %s", v10 + 1, v12);
-        pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4;
-        pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
-        goto LABEL_29;
-      }
-    }
-    v13 = pGlobalTXT_LocalizationStrings[56];   // Day
-    sprintf(pTmpBuf.data(), "%lu %s", v11 + 1, v13);
-    pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4;
-    pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
-    goto LABEL_29;
   }
-LABEL_30:
   if ( byte_506360 )
-  {
-    /*result = pMessageQueue_50CBD0->uNumMessages;
-    if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-    {
-      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_CloseAfterInstallBeacon;
-      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
-      result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
-      *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
-      ++pMessageQueue_50CBD0->uNumMessages;
-    }*/
     pMessageQueue_50CBD0->AddMessage(UIMSG_CloseAfterInstallBeacon, 0, 0);
-  }
-  return result;
+  return BeaconID;
 }
 
-
 //----- (00413980) --------------------------------------------------------
 void BookUI_Map_Draw()
-    { 
-    int v6; // eax@31
-    unsigned int map_id; // eax@35
-    Texture *buttnTxtr; // [sp-4h] [bp-DCh]@3
-    char party_coord[120]; // [sp+Ch] [bp-CCh]@37
-    GUIWindow map_window; // [sp+84h] [bp-54h]@35
-    unsigned int textrX, textrY;
+{
+  unsigned int map_id; // eax@35
+  Texture *buttnTxtr; // [sp-4h] [bp-DCh]@3
+  char party_coord[120]; // [sp+Ch] [bp-CCh]@37
+  GUIWindow map_window; // [sp+84h] [bp-54h]@35
+  unsigned int textrX, textrY;
 
-    pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_12);
-    if ( BtnUp_flag || viewparams->field_2C / 128 >= 12 )
-        {
-        buttnTxtr = pTex_tab_an_6a__zoom_off;
-        textrY = pViewport->uViewportTL_Y + 2;
-        textrX = pViewport->uViewportTL_X + 408;
-        }
-    else
-        {
-        buttnTxtr = pTex_tab_an_6b__zoom_on;
-        textrY = pViewport->uViewportTL_Y + 1;
-        textrX = pViewport->uViewportTL_X + 398;
-        }
-    pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
-    if ( BtnDown_flag || viewparams->field_2C / 128 <= 3 )
-        {
-        buttnTxtr = pTex_tab_an_7a__zoot_off;
-        textrY = pViewport->uViewportTL_Y + 38;
-        textrX = pViewport->uViewportTL_X + 408;
-        }
-    else
-        {
-        buttnTxtr = pTex_tab_an_7b__zoot_on;
-        textrY = pViewport->uViewportTL_Y + 38;
-        textrX = pViewport->uViewportTL_X + 398;
-        }
-    pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
-    if ( Book_PageBtn3_flag )
-        {
-        buttnTxtr = pTexture_506390;
-        textrY = pViewport->uViewportTL_Y + 113;
-        textrX = pViewport->uViewportTL_X + 408;
-        }
-    else
-        {
-        buttnTxtr = pTexture_506394;
-        textrY = pViewport->uViewportTL_Y + 113;
-        textrX = pViewport->uViewportTL_X + 398;
-        }
-    pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
-    if ( Book_PageBtn4_flag )
-        {
-        buttnTxtr = pTexture_506388;
-        textrY = pViewport->uViewportTL_X + 150;
-        textrX = pViewport->uViewportTL_Y + 408;
-        }
-    else
-        {
-        buttnTxtr = pTexture_50638C;
-        textrY = pViewport->uViewportTL_X + 150;
-        textrX = pViewport->uViewportTL_Y + 399;
-        }
-    pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
-    if ( Book_PageBtn5_flag )
-        {
-        buttnTxtr = pTexture_506380;
-        textrY = pViewport->uViewportTL_Y + 188;
-        textrX = pViewport->uViewportTL_X + 408;
-        }
-    else
-        {
-        buttnTxtr = pTexture_506384;
-        textrY = pViewport->uViewportTL_Y + 188;
-        textrX = pViewport->uViewportTL_X + 397;
-        }
-    pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
-    if ( Book_PageBtn6_flag )
-        {
-        buttnTxtr = pTexture_506378;
-        textrY = pViewport->uViewportTL_Y + 226;
-        textrX = pViewport->uViewportTL_X + 408;
-        }
-    else
-        {
-        buttnTxtr = pTexture_50637C;
-        textrY = pViewport->uViewportTL_Y + 226;
-        textrX = pViewport->uViewportTL_X + 397;
-        }
-    pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
-    if ( BtnDown_flag )
-        viewparams->CenterOnParty2();
-    if ( BtnUp_flag )
-        viewparams->CenterOnParty();
-    if ( Book_PageBtn3_flag )
-        viewparams->_443219();
-    if ( Book_PageBtn4_flag )
-        viewparams->_443231();
-    if ( Book_PageBtn5_flag )
-        viewparams->_44323D();
-    if ( Book_PageBtn6_flag )
-        viewparams->_443225();
+  pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_12);
+  if ( BtnUp_flag || viewparams->field_2C / 128 >= 12 )
+  {
+    buttnTxtr = pTex_tab_an_6a__zoom_off;
+    textrY = pViewport->uViewportTL_Y + 2;
+    textrX = pViewport->uViewportTL_X + 408;
+  }
+  else
+  {
+    buttnTxtr = pTex_tab_an_6b__zoom_on;
+    textrY = pViewport->uViewportTL_Y + 1;
+    textrX = pViewport->uViewportTL_X + 398;
+  }
+  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
+  if ( BtnDown_flag || viewparams->field_2C / 128 <= 3 )
+  {
+    buttnTxtr = pTex_tab_an_7a__zoot_off;
+    textrY = pViewport->uViewportTL_Y + 38;
+    textrX = pViewport->uViewportTL_X + 408;
+  }
+  else
+  {
+    buttnTxtr = pTex_tab_an_7b__zoot_on;
+    textrY = pViewport->uViewportTL_Y + 38;
+    textrX = pViewport->uViewportTL_X + 398;
+  }
+  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
+  if ( Book_PageBtn3_flag )
+  {
+    buttnTxtr = pTexture_506390;
+    textrY = pViewport->uViewportTL_Y + 113;
+    textrX = pViewport->uViewportTL_X + 408;
+  }
+  else
+  {
+    buttnTxtr = pTexture_506394;
+    textrY = pViewport->uViewportTL_Y + 113;
+    textrX = pViewport->uViewportTL_X + 398;
+  }
+  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
+  if ( Book_PageBtn4_flag )
+  {
+    buttnTxtr = pTexture_506388;
+    textrY = pViewport->uViewportTL_X + 150;
+    textrX = pViewport->uViewportTL_Y + 408;
+  }
+  else
+  {
+    buttnTxtr = pTexture_50638C;
+    textrY = pViewport->uViewportTL_X + 150;
+    textrX = pViewport->uViewportTL_Y + 399;
+  }
+  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
+  if ( Book_PageBtn5_flag )
+  {
+    buttnTxtr = pTexture_506380;
+    textrY = pViewport->uViewportTL_Y + 188;
+    textrX = pViewport->uViewportTL_X + 408;
+  }
+  else
+  {
+    buttnTxtr = pTexture_506384;
+    textrY = pViewport->uViewportTL_Y + 188;
+    textrX = pViewport->uViewportTL_X + 397;
+  }
+  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
+  if ( Book_PageBtn6_flag )
+  {
+    buttnTxtr = pTexture_506378;
+    textrY = pViewport->uViewportTL_Y + 226;
+    textrX = pViewport->uViewportTL_X + 408;
+  }
+  else
+  {
+    buttnTxtr = pTexture_50637C;
+    textrY = pViewport->uViewportTL_Y + 226;
+    textrX = pViewport->uViewportTL_X + 397;
+  }
+  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
+  if ( BtnDown_flag )
+    viewparams->CenterOnParty2();
+  if ( BtnUp_flag )
+    viewparams->CenterOnParty();
+  if ( Book_PageBtn3_flag )
+    viewparams->_443219();
+  if ( Book_PageBtn4_flag )
+    viewparams->_443231();
+  if ( Book_PageBtn5_flag )
+    viewparams->_44323D();
+  if ( Book_PageBtn6_flag )
+    viewparams->_443225();
 
-    if ( BtnUp_flag | BtnDown_flag | Book_PageBtn3_flag | Book_PageBtn4_flag | Book_PageBtn5_flag | Book_PageBtn6_flag )
-        pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
-    BtnUp_flag = 0;
-    BtnDown_flag = 0;
-    Book_PageBtn6_flag = 0;
-    Book_PageBtn5_flag = 0;
-    Book_PageBtn4_flag = 0;
-    Book_PageBtn3_flag = 0;
-    DrawBook_Map_sub(97, 49, 361, 313, 0);
-    pRenderer->DrawTextureTransparent(75, 22, pTexture_mapbordr);
-    map_window.uFrameWidth = game_viewport_width;
-    map_window.uFrameHeight = game_viewport_height;
-    map_window.uFrameX = game_viewport_x;
-    map_window.uFrameY = game_viewport_y;
-    map_window.uFrameZ = game_viewport_z;
-    map_window.uFrameW = game_viewport_w;
-    map_id = pMapStats->GetMapInfo(pCurrentMapName.data());
-    if ( map_id )
-        map_window.DrawTitleText(pBook2Font, -14, 12, ui_book_map_title_color, pMapStats->pInfos[map_id].pName, 3);
+  if ( BtnUp_flag | BtnDown_flag | Book_PageBtn3_flag | Book_PageBtn4_flag | Book_PageBtn5_flag | Book_PageBtn6_flag )
+    pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
+  BtnUp_flag = 0;
+  BtnDown_flag = 0;
+  Book_PageBtn6_flag = 0;
+  Book_PageBtn5_flag = 0;
+  Book_PageBtn4_flag = 0;
+  Book_PageBtn3_flag = 0;
+  DrawBook_Map_sub(97, 49, 361, 313, 0);
+  pRenderer->DrawTextureTransparent(75, 22, pTexture_mapbordr);
+  map_window.uFrameWidth = game_viewport_width;
+  map_window.uFrameHeight = game_viewport_height;
+  map_window.uFrameX = game_viewport_x;
+  map_window.uFrameY = game_viewport_y;
+  map_window.uFrameZ = game_viewport_z;
+  map_window.uFrameW = game_viewport_w;
+  map_id = pMapStats->GetMapInfo(pCurrentMapName.data());
+  if ( map_id )
+    map_window.DrawTitleText(pBook2Font, -14, 12, ui_book_map_title_color, pMapStats->pInfos[map_id].pName, 3);
 
-    map_window.uFrameX = 0;
-    sprintf(party_coord, pGlobalTXT_LocalizationStrings[659], pParty->vPosition.x, pParty->vPosition.y); //"x: %d  y: %d"
-    map_window.DrawTitleText(pFontComic, 0, 320, ui_book_map_coordinates_color, party_coord, 0);
-    }
+  map_window.uFrameX = 0;
+  sprintf(party_coord, pGlobalTXT_LocalizationStrings[659], pParty->vPosition.x, pParty->vPosition.y); //"x: %d  y: %d"
+  map_window.DrawTitleText(pFontComic, 0, 320, ui_book_map_coordinates_color, party_coord, 0);
+}
 
 //----- (00442955) --------------------------------------------------------
 void DrawBook_Map_sub( unsigned int tl_x, unsigned int tl_y, unsigned int br_x, int br_y, int _48074 )
+{
+  //unsigned int v11; // edx@11
+  //__int16 v12; // cx@12
+  //signed int v13; // eax@15
+  //int v14; // eax@16
+  int v20; // eax@16
+  signed int v21; // esi@18
+  int v22; // ecx@21
+  BLVMapOutline *v23; // ecx@21
+  Vec3_short_ *v24; // edx@21
+  Vec3_short_ *v25; // eax@21
+  int v26; // ecx@21
+  unsigned __int16 *v27; // edi@21
+  int v28; // edx@21
+  int v29; // eax@21
+  double v30; // st7@23
+  signed __int64 v31; // qax@23
+  unsigned short *v32; // edx@23
+  int textr_width; // esi@23
+  signed int v34; // eax@23
+  signed int v35; // ecx@23
+  int v36; // esi@27
+  int v37; // ecx@27
+  int v38; // edx@31
+  unsigned int v39; // eax@33
+  short *v40; // esi@33
+  short *v41; // edi@33
+  unsigned __int8 v42; // cf@33
+  unsigned int v43; // ecx@33
+  short *v44; // edi@33
+  short *v45; // esi@33
+  int v46; // ecx@33
+  signed int v47; // esi@38
+  signed int v48; // ecx@38
+  int v49; // eax@38
+  signed int v50; // edx@55
+  unsigned int v51; // ecx@55
+  int result; // eax@72
+  int v53; // eax@75
+  int v54; // esi@75
+  int v55; // eax@75
+  __int16 v56; // si@85
+  double v57; // st7@85
+  int v58; // ebx@85
+  signed __int64 v59; // qax@85
+  signed int v60; // edi@85
+  signed __int64 v61; // qax@85
+  signed int v62; // ebx@85
+  signed int v63; // esi@85
+  int v64; // eax@87
+  unsigned int v65; // ebx@95
+  unsigned short *v66; // edx@95
+  unsigned __int16 *v67; // esi@96
+  int v68; // edi@98
+  unsigned __int16 v69; // cx@99
+  unsigned int v70; // [sp-10h] [bp-48074h]@80
+  unsigned int v71; // [sp-Ch] [bp-48070h]@80
+  unsigned int v72; // [sp-8h] [bp-4806Ch]@80
+  signed int v73; // [sp-4h] [bp-48068h]@59
+  unsigned __int16 v74; // [sp-4h] [bp-48068h]@79
+  unsigned short map_texture_16[147456]; // [sp+Ch] [bp-48058h]@23
+  int v76; // [sp+4800Ch] [bp-58h]@23
+  unsigned __int16 *v77; // [sp+48010h] [bp-54h]@27
+  unsigned __int16 *pPalette_16; // [sp+48014h] [bp-50h]@23
+  int v81; // [sp+48020h] [bp-44h]@23
+  unsigned __int16* render16_data;
+  unsigned char* texture8_data;
+  unsigned char* curr_line;
+  int scale_increment;
+  int scaled_posX;
+  int scaled_posY;
+  int stepX_r;
+  int stepY_r;
+  unsigned int teal; // [sp+48028h] [bp-3Ch]@8
+  int pCenterY; // [sp+4802Ch] [bp-38h]@1
+  int screenCenter_X; // [sp+48030h] [bp-34h]@1
+  int pCenterX; // [sp+48034h] [bp-30h]@1
+  int v87; // [sp+48038h] [bp-2Ch]@16
+  unsigned int v88; // [sp+4803Ch] [bp-28h]@16
+  int black; // [sp+48040h] [bp-24h]@8
+  int screenCenterY; // [sp+48044h] [bp-20h]@1
+  unsigned int i; // [sp+48048h] [bp-1Ch]@9
+  unsigned int screenHeight; // [sp+4804Ch] [bp-18h]@16
+  unsigned __int16 *v93; // [sp+48050h] [bp-14h]@16
+  signed int screenWidth; // [sp+48054h] [bp-10h]@8
+  unsigned int v95; // [sp+48058h] [bp-Ch]@16
+  int v96; // [sp+4805Ch] [bp-8h]@10
+  const void *v97; // [sp+48060h] [bp-4h]@16
+  unsigned short *a4a; // [sp+4806Ch] [bp+8h]@85
+  int a5a; // [sp+48070h] [bp+Ch]@86
+
+  screenCenter_X = (signed int)(tl_x + br_x) / 2;
+  screenCenterY = (signed int)(tl_y + br_y) / 2;
+  pRenderer->SetRasterClipRect(tl_x, tl_y, br_x, br_y);
+  pCenterX = viewparams->sViewCenterX;
+  pCenterY = viewparams->sViewCenterY;
+  if ( viewparams->field_2C != 384 )
+  {
+    if ( viewparams->field_2C == 768 )
     {
-    int v5; // ebx@1
-    int v6; // edi@1
-    BLVMapOutlines *v7; // eax@8
-    unsigned __int8 v8; // zf@8
-    unsigned __int8 v9; // sf@8
-    int v10; // esi@10
-    unsigned int v11; // edx@11
-    __int16 v12; // cx@12
-    signed int v13; // eax@15
-    int v14; // eax@16
-    Vec3_short_ *v15; // ecx@16
-    int v16; // edx@16
-    int v17; // ecx@16
-    Vec3_short_ *v18; // eax@16
-    int v19; // ecx@16
-    int v20; // eax@16
-    signed int v21; // esi@18
-    int v22; // ecx@21
-    BLVMapOutline *v23; // ecx@21
-    Vec3_short_ *v24; // edx@21
-    Vec3_short_ *v25; // eax@21
-    int v26; // ecx@21
-    unsigned __int16 *v27; // edi@21
-    int v28; // edx@21
-    int v29; // eax@21
-    double v30; // st7@23
-    signed __int64 v31; // qax@23
-    unsigned short *v32; // edx@23
-    int textr_width; // esi@23
-    signed int v34; // eax@23
-    signed int v35; // ecx@23
-    int v36; // esi@27
-    int v37; // ecx@27
-    int v38; // edx@31
-    unsigned int v39; // eax@33
-    short *v40; // esi@33
-    short *v41; // edi@33
-    unsigned __int8 v42; // cf@33
-    unsigned int v43; // ecx@33
-    short *v44; // edi@33
-    short *v45; // esi@33
-    int v46; // ecx@33
-    signed int v47; // esi@38
-    signed int v48; // ecx@38
-    int v49; // eax@38
-    signed int v50; // edx@55
-    unsigned int v51; // ecx@55
-    int result; // eax@72
-    int v53; // eax@75
-    int v54; // esi@75
-    int v55; // eax@75
-    __int16 v56; // si@85
-    double v57; // st7@85
-    int v58; // ebx@85
-    signed __int64 v59; // qax@85
-    signed int v60; // edi@85
-    signed __int64 v61; // qax@85
-    signed int v62; // ebx@85
-    signed int v63; // esi@85
-    int v64; // eax@87
-    unsigned int v65; // ebx@95
-    unsigned short *v66; // edx@95
-    unsigned __int16 *v67; // esi@96
-    int v68; // edi@98
-    unsigned __int16 v69; // cx@99
-    unsigned int v70; // [sp-10h] [bp-48074h]@80
-    unsigned int v71; // [sp-Ch] [bp-48070h]@80
-    unsigned int v72; // [sp-8h] [bp-4806Ch]@80
-    signed int v73; // [sp-4h] [bp-48068h]@59
-    unsigned __int16 v74; // [sp-4h] [bp-48068h]@79
-    unsigned short map_texture_16[147456]; // [sp+Ch] [bp-48058h]@23
-    int v76; // [sp+4800Ch] [bp-58h]@23
-    unsigned __int16 *v77; // [sp+48010h] [bp-54h]@27
-    unsigned __int16 *pPalette_16; // [sp+48014h] [bp-50h]@23
-    unsigned int surfPitch; // [sp+48018h] [bp-4Ch]@1
+      if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
+        viewparams->field_2C = 680;
+    }
+  }
+  else
+  {
+    viewparams->sViewCenterX = viewparams->indoor_center_x;
+    pCenterX = viewparams->indoor_center_x;
+    pCenterY = viewparams->indoor_center_y;
+    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
+      viewparams->field_2C = viewparams->field_2C - 34;
+  }
+  if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
+  {
+    screenWidth = br_x - tl_x + 1;
+    screenHeight = br_y - tl_y + 1;
+    render16_data = &pRenderer->pTargetSurface[tl_x + tl_y * pRenderer->uTargetSurfacePitch];
+    texture8_data = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0_prolly_alpha_mask;
+    pPalette_16 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
+    scale_increment = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / viewparams->field_2C;
 
-    int v81; // [sp+48020h] [bp-44h]@23
-    unsigned __int16* render16_data;
-    unsigned char* texture8_data;
-    unsigned char* curr_line;
-    int scale_increment;
-    int scaled_posX;
-    int scaled_posY;
-    int stepX_r;
-    int stepY_r;
+    v30 = (double)(1 << (16 - pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2));
+
+    teal = (unsigned int)(signed __int64)((double)(viewparams->sViewCenterX - 22528 / (viewparams->field_2C / 384) + 32768) / v30) << 16;
+    //  v97 = (const void *)((unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16);
 
+    //   v32 = map_texture_16;
+    textr_width = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
+    stepY_r =            (int)(signed __int64)((double)(- pCenterY - 22528 / (viewparams->field_2C / 384)+ 32768) / v30) << 16;
+    //   v81 =   (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30);
+    black = (signed __int16)(signed __int64)((double)(viewparams->sViewCenterX - 22528 / (viewparams->field_2C / 384) + 32768) / v30);
 
-    unsigned int teal; // [sp+48028h] [bp-3Ch]@8
-    int v84; // [sp+4802Ch] [bp-38h]@1
-    int screenCenter_X; // [sp+48030h] [bp-34h]@1
-    int v86; // [sp+48034h] [bp-30h]@1
-    int v87; // [sp+48038h] [bp-2Ch]@16
-    unsigned int v88; // [sp+4803Ch] [bp-28h]@16
-    int black; // [sp+48040h] [bp-24h]@8
-    int screenCenterY; // [sp+48044h] [bp-20h]@1
-    unsigned int i; // [sp+48048h] [bp-1Ch]@9
-    unsigned int screenHeight; // [sp+4804Ch] [bp-18h]@16
-    unsigned __int16 *v93; // [sp+48050h] [bp-14h]@16
-    signed int screenWidth; // [sp+48054h] [bp-10h]@8
-    unsigned int v95; // [sp+48058h] [bp-Ch]@16
-    int v96; // [sp+4805Ch] [bp-8h]@10
-    const void *v97; // [sp+48060h] [bp-4h]@16
-    unsigned short *a4a; // [sp+4806Ch] [bp+8h]@85
-    int a5a; // [sp+48070h] [bp+Ch]@86
-
-    tl_x = tl_x;
-    tl_y = tl_y;
-    screenCenter_X = (signed int)(tl_x + br_x) >> 1;
-    screenCenterY = (signed int)(tl_y + br_y) >> 1;
-    surfPitch = pRenderer->uTargetSurfacePitch;
-    pRenderer->SetRasterClipRect(tl_x, tl_y, br_x, br_y);
-    v5 = viewparams->field_2C;
-    v6 = viewparams->sViewCenterX;
-    v86 = viewparams->sViewCenterX;
-    v84 = viewparams->sViewCenterY;
-    if ( viewparams->field_2C != 384 )
+    //  v76 = textr_width;
+    scaled_posY = stepY_r >> 16;
+    //nearest neiborhood scaling
+    if ( texture8_data)  
+    {
+      for( uint i = 0; i < screenHeight; ++i )
+      {
+        curr_line=&texture8_data[scaled_posY*textr_width];
+        stepX_r=teal;
+        for( uint j = 0; j < screenWidth; ++j )
         {
-        if ( viewparams->field_2C == 768 )
-            {
-            if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
-                v5 = 680;
-            }
+          scaled_posX=stepX_r>>16;
+          map_texture_16[i*screenWidth+j]=pPalette_16[*(curr_line+scaled_posX)];
+          stepX_r+=scale_increment;      
         }
-    else
-        {
-        v6 = viewparams->indoor_center_x;
-        v86 = viewparams->indoor_center_x;
-        v84 = viewparams->indoor_center_y;
-        if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
-            v5 = viewparams->field_2C - 34;
-        }
-    if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
+        stepY_r+=scale_increment;
+        scaled_posY=stepY_r>>16;
+      }
+    }
+    //move visible square to render
+    for( uint i = 0; i < screenHeight; ++i )
+    {
+      if ( screenWidth > 0 )
+        memcpy((void*)&render16_data[pRenderer->uTargetSurfacePitch * i],(void*)&map_texture_16[i*screenWidth], screenWidth*2);
+    }
+  }
+  else
+  {
+    black = TargetColor(0, 0, 0);
+    teal = TargetColor(0, 0xFFu, 0xFFu);
+    uNumBlueFacesInBLVMinimap = 0;
+    if ( pIndoor->pMapOutlines->uNumOutlines )
+    {
+     for ( uint i = 0; i < pIndoor->pMapOutlines->uNumOutlines; ++i )
+      {
+        if ( !(BYTE1(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace1ID].uAttributes) & 0x20 
+           || (BYTE1(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace2ID].uAttributes) & 0x20) ))
         {
-        screenWidth = br_x - tl_x + 1;
-        screenHeight = br_y - tl_y + 1;
-        render16_data = &pRenderer->pTargetSurface[tl_x + tl_y * surfPitch];
-        texture8_data = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0_prolly_alpha_mask;
-        pPalette_16 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
-        scale_increment = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / v5;
-
-        v30 = (double)(1 << (16 - pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2));
-
-
-        teal =               (unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16;
-        //  v97 = (const void *)((unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16);
-
-        //   v32 = map_texture_16;
-        textr_width = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
-        stepY_r =            (int)(signed __int64)((double)(- v84 - 22528 / (v5 / 384)+ 32768) / v30) << 16;
-        //   v81 =   (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30);
-        black = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30);
-
-        //  v76 = textr_width;
-        scaled_posY = stepY_r >> 16;
-        //nearest neiborhood scaling
-        if ( texture8_data)  
+          if ( !(pIndoor->pMapOutlines->pOutlines[i].uFlags & 1) )
+          {
+            if ( !(!(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace1ID].uAttributes & 0x80)
+                && !(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace2ID].uAttributes & 0x80u) ))
             {
-            for(uint i=0; i<screenHeight;++i)
-                {
-                curr_line=&texture8_data[scaled_posY*textr_width];
-                stepX_r=teal;
-                for(uint j=0; j<screenWidth;++j)
-                    {
-                    scaled_posX=stepX_r>>16;
-                    map_texture_16[i*screenWidth+j]=pPalette_16[*(curr_line+scaled_posX)];
-                    stepX_r+=scale_increment;      
-                    }
-                stepY_r+=scale_increment;
-                scaled_posY=stepY_r>>16;
-                }
+              pIndoor->pMapOutlines->pOutlines[i].uFlags = pIndoor->pMapOutlines->pOutlines[i].uFlags | 1;
+              pIndoor->_visible_outlines[i >> 3] |= 1 << (7 - i % 8);
             }
-        //move visible square to render
-        for(uint i=0; i<screenHeight;++i)
-            {
-            if ( screenWidth > 0 )
-                {
-                memcpy((void*)&render16_data[surfPitch*i],(void*)&map_texture_16[i*screenWidth], screenWidth*2);
-                }
-            }
+          }
+          if ( (!(pIndoor->pMapOutlines->pOutlines[i].uFlags & 1) 
+            && !(!(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace1ID].uAttributes & 0x80)
+            && !(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace2ID].uAttributes & 0x80u) ))
+            || pIndoor->pMapOutlines->pOutlines[i].uFlags & 1)
+          {
+            v93 = (unsigned __int16 *)(pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex1ID].x - viewparams->sViewCenterX);
+            screenHeight = pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex1ID].y - pCenterY;
+            v20 = pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex2ID].y - pCenterY;
+            v95 = pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex2ID].x - viewparams->sViewCenterX;
+            v97 = (const void *)v20;
+            v88 = (unsigned __int64)((pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex1ID].x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16;
+            v87 = (unsigned __int64)((signed int)screenHeight * (signed __int64)viewparams->field_2C) >> 16;
+            v93 = (unsigned __int16 *)((unsigned __int64)((pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex2ID].x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16);
+            screenHeight = (unsigned __int64)(v20 * (signed __int64)viewparams->field_2C) >> 16;
+            pRenderer->RasterLine2D(screenCenter_X + v88, screenCenterY - v87,
+            screenCenter_X + ((unsigned __int64)((pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex2ID].x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16), screenCenterY - screenHeight, black);
+          }
         }
-    else
-        {
-        black = TargetColor(0, 0, 0);
-        teal = TargetColor(0, 0xFFu, 0xFFu);
-        v7 = pIndoor->pMapOutlines;
-        uNumBlueFacesInBLVMinimap = 0;
-        v8 = pIndoor->pMapOutlines->uNumOutlines == 0;
-        v9 = pIndoor->pMapOutlines->uNumOutlines < 0;
-        screenWidth = 0;
-        if ( !(v9 | v8) )
-            {
-            i = 0;
-            do
+      }
+    }
+    v21 = 0;
+    if ( (signed int)uNumBlueFacesInBLVMinimap > 0 )
+    {
+      while ( 1 )
+      {
+        v22 = pBlueFacesInBLVMinimapIDs[v21];
+        v87 = viewparams->field_2C;
+        v23 = &pIndoor->pMapOutlines->pOutlines[v22];
+        v24 = &pIndoor->pVertices[v23->uVertex1ID];
+        v25 = &pIndoor->pVertices[v23->uVertex2ID];
+        v26 = v25->x;
+        v27 = (unsigned __int16 *)(v24->x - pCenterX);
+        v28 = v24->y - pCenterY;
+        v29 = v25->y - pCenterY;
+        v93 = v27;
+        screenHeight = v28;
+        v97 = (const void *)v29;
+        v87 = (unsigned __int64)((signed int)v27 * (signed __int64)viewparams->field_2C) >> 16;
+        v88 = (unsigned __int64)(v28 * (signed __int64)viewparams->field_2C) >> 16;
+        uint i = (unsigned __int64)((v26 - pCenterX) * (signed __int64)viewparams->field_2C) >> 16;
+        v95 = (unsigned __int64)(v29 * (signed __int64)viewparams->field_2C) >> 16;
+        pRenderer->RasterLine2D(screenCenter_X + ((unsigned __int64)((signed int)v27 * (signed __int64)viewparams->field_2C) >> 16),
+        screenCenterY - v88, screenCenter_X + ((unsigned __int64)((v26 - pCenterX) * (signed __int64)viewparams->field_2C) >> 16), screenCenterY - v95, teal);
+        ++v21;
+        if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap )
+          break;
+      }
+      viewparams->sViewCenterX = pCenterX;
+    }
+  }
+  v47 = ((unsigned __int64)((pParty->vPosition.x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X - 3;
+  v81 = pParty->vPosition.y - pCenterY;
+  v97 = (const void *)((unsigned __int64)((pParty->vPosition.y - pCenterY) * (signed __int64)viewparams->field_2C) >> 16);
+  v48 = 1;
+  v49 = screenCenterY - (int)v97 - 3;
+  if ( v47 >= (signed int)tl_x )
+  {
+    if ( v47 > (signed int)br_x )
+    {
+      if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X - 6) > (signed int)br_x )
+        v48 = 0;
+      v47 = br_x;
+    }
+  }
+  else
+  {
+    if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X) < (signed int)tl_x )
+      v48 = 0;
+    v47 = tl_x;
+  }
+  if ( v49 >= (signed int)tl_y )
+  {
+    if ( v49 > br_y )
+    {
+      if ( screenCenterY - (signed int)v97 - 6 > br_y )
+        v48 = 0;
+      v49 = br_y;
+    }
+  }
+  else
+  {
+    if ( screenCenterY - (signed int)v97 < (signed int)tl_y )
+      v48 = 0;
+    v49 = tl_y;
+  }
+  if ( v48 == 1 )
+  {
+    v51 = pParty->sRotationY & stru_5C6E00->uDoublePiMask;
+    if ( (signed int)v51 <= 1920 )
+      v50 = 7;
+    if ( (signed int)v51 < 1664 )
+      v50 = 6;
+    if ( (signed int)v51 <= 1408 )
+      v50 = 5;
+    if ( (signed int)v51 < 1152 )
+      v50 = 4;
+    if ( (signed int)v51 <= 896 )
+      v50 = 3;
+    if ( (signed int)v51 < 640 )
+      v50 = 2;
+    if ( (signed int)v51 <= 384 )
+      v50 = 1;
+    if ( (signed int)v51 < 128 )
+      v50 = 0;
+    pRenderer->DrawTransparentRedShade(v47, v49, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[v50]));
+  }
+  result = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  v95 = 0;
+  pCenterX = result;
+  if ( (signed int)uNumLevelDecorations > 0 )
+  {
+    screenWidth = (unsigned int)&pLevelDecorations[0].vPosition;
+    do
+    {
+      if ( *(char *)(screenWidth - 2) & 8 )
+      {
+        v53 = *(int *)(screenWidth + 4) - pCenterY;
+        v93 = (unsigned __int16 *)(*(int *)screenWidth - viewparams->sViewCenterX);
+              screenHeight = v53;
+              v54 = ((unsigned __int64)((signed int)v93 * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X;
+              v97 = (const void *)((unsigned __int64)(v53 * (signed __int64)viewparams->field_2C) >> 16);
+              v55 = screenCenterY - (int)v97;
+              if ( v54 >= pRenderer->raster_clip_x )
+              {
+                if ( v54 <= pRenderer->raster_clip_z && v55 >= pRenderer->raster_clip_y && v55 <= pRenderer->raster_clip_w )
                 {
-                v10 = (int)((char *)v7 + i + 4);
-                v96 = pIndoor->pFaces[*(short *)((char *)v7 + i + 8)].uAttributes;
-                if ( !(BYTE1(v96) & 0x20 || (v11 = pIndoor->pFaces[*(short *)((char *)v7 + i + 10)].uAttributes, BYTE1(v11) & 0x20) ))
-                    {
-                    v12 = *(short *)((char *)v7 + i + 14);
-                    if ( !(v12 & 1) )
-                        {
-                        if ( !(!(v96 & 0x80) && (v11 & 0x80u) == 0 ))
-                            {
-                            v96 = (signed int)screenWidth >> 3;
-                            v13 = screenWidth;
-                            *(short *)(v10 + 10) = v12 | 1;
-                            pIndoor->_visible_outlines[v96] |= 1 << (7 - v13 % 8);
-                            }
-                        }
-                    if ( (!(v12 & 1) && !(!(v96 & 0x80) && (v11 & 0x80u) == 0 )) || v12 & 1)
-                        {
-                        v14 = *(short *)v10;
-                        v88 = v5;
-                        v15 = &pIndoor->pVertices[v14];
-                        v16 = v15->x;
-                        v17 = v15->y - v84;
-                        v93 = (unsigned __int16 *)(v16 - v6);
-                        screenHeight = v17;
-                        v18 = &pIndoor->pVertices[*(short *)(v10 + 2)];
-                        v19 = v18->x;
-                        v20 = v18->y - v84;
-                        v95 = v19 - v6;
-                        v97 = (const void *)v20;
-                        v88 = (unsigned __int64)((v16 - v6) * (signed __int64)v5) >> 16;
-                        v87 = (unsigned __int64)((signed int)screenHeight * (signed __int64)v5) >> 16;
-                        v93 = (unsigned __int16 *)((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16);
-                        screenHeight = (unsigned __int64)(v20 * (signed __int64)v5) >> 16;
-                        pRenderer->RasterLine2D(
-                            screenCenter_X + v88,
-                            screenCenterY - v87,
-                            screenCenter_X + ((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16),
-                            screenCenterY - screenHeight,
-                            black);
-                        v7 = pIndoor->pMapOutlines;
-                        }
-                    }
-                ++screenWidth;
-                i += 12;
+                  if ( viewparams->field_2C > 512 )
+                  {
+                    v96 = v55 + 1;
+                    black = v55 - 1;
+                    pRenderer->RasterLine2D(v54 - 1, v55 - 1, v54 - 1, v55 + 1, pCenterX);
+                    pRenderer->RasterLine2D(v54, black, v54, v96, pCenterX);
+                    ++v54;
+                    v72 = v96;
+                    v71 = v54;
+                    v70 = black;
+                  }
+                  else
+                  {
+                    v72 = screenCenterY - (int)v97;
+                    v71 = ((unsigned __int64)((signed int)v93 * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X;
+                    v70 = screenCenterY - (int)v97;
+                  }
+                  pRenderer->RasterLine2D(v54, v70, v71, v72, pCenterX);
                 }
-                while ( screenWidth < (signed int)v7->uNumOutlines );
-            }
-        v21 = 0;
-        if ( (signed int)uNumBlueFacesInBLVMinimap > 0 )
-            {
-            while ( 1 )
-                {
-                v22 = pBlueFacesInBLVMinimapIDs[v21];
-                v87 = v5;
-                v23 = &v7->pOutlines[v22];
-                v24 = &pIndoor->pVertices[v23->uVertex1ID];
-                v25 = &pIndoor->pVertices[v23->uVertex2ID];
-                v26 = v25->x;
-                v27 = (unsigned __int16 *)(v24->x - v86);
-                v28 = v24->y - v84;
-                v29 = v25->y - v84;
-                v93 = v27;
-                screenHeight = v28;
-                v97 = (const void *)v29;
-                v87 = (unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16;
-                v88 = (unsigned __int64)(v28 * (signed __int64)v5) >> 16;
-                i = (unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16;
-                v95 = (unsigned __int64)(v29 * (signed __int64)v5) >> 16;
-                pRenderer->RasterLine2D(
-                    screenCenter_X + ((unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16),
-                    screenCenterY - v88,
-                    screenCenter_X + ((unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16),
-                    screenCenterY - v95,
-                    teal);
-                ++v21;
-                if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap )
-                    break;
-                v7 = pIndoor->pMapOutlines;
-                }
-            v6 = v86;
-            }
-        }
-    v47 = ((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X - 3;
-    v81 = pParty->vPosition.y - v84;
-    v97 = (const void *)((unsigned __int64)((pParty->vPosition.y - v84) * (signed __int64)v5) >> 16);
-    v48 = 1;
-    v49 = screenCenterY - (int)v97 - 3;
-    if ( v47 >= (signed int)tl_x )
-        {
-        if ( v47 > (signed int)br_x )
-            {
-            if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X - 6) > (signed int)br_x )
-                v48 = 0;
-            v47 = br_x;
+              }
             }
-        }
-    else
-        {
-        if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X) < (signed int)tl_x )
-            v48 = 0;
-        v47 = tl_x;
-        }
-    if ( v49 >= (signed int)tl_y )
-        {
-        if ( v49 > br_y )
-            {
-            if ( screenCenterY - (signed int)v97 - 6 > br_y )
-                v48 = 0;
-            v49 = br_y;
-            }
-        }
-    else
-        {
-        if ( screenCenterY - (signed int)v97 < (signed int)tl_y )
-            v48 = 0;
-        v49 = tl_y;
-        }
-    if ( v48 == 1 )
-        {
-        v50 = 0;
-        v51 = pParty->sRotationY & stru_5C6E00->uDoublePiMask;
-        if ( (signed int)(pParty->sRotationY & stru_5C6E00->uDoublePiMask) >= 128 )
-            {
-            if ( (signed int)v51 > 384 )
-                {
-                if ( (signed int)v51 >= 640 )
-                    {
-                    if ( (signed int)v51 > 896 )
-                        {
-                        if ( (signed int)v51 >= 1152 )
-                            {
-                            if ( (signed int)v51 > 1408 )
-                                {
-                                if ( (signed int)v51 >= 1664 )
-                                    {
-                                    if ( (signed int)v51 <= 1920 )
-                                        v73 = 7;
-                                    }
-                                else
-                                    {
-                                    v73 = 6;
-                                    }
-                                }
-                            else
-                                {
-                                v73 = 5;
-                                }
-                            }
-                        else
-                            {
-                            v73 = 4;
-                            }
-                        }
-                    else
-                        {
-                        v73 = 3;
-                        }
-                    }
-                else
-                    {
-                    v73 = 2;
-                    }
-                if( (signed int)v51 <=1920)
-                    v50 = v73;
-                }
-            else
-                v50 = 1;
-            }
-        pRenderer->DrawTransparentRedShade(v47, v49, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[v50]));
-        }
-    result = TargetColor(0xFFu, 0xFFu, 0xFFu);
-    v95 = 0;
-    v86 = result;
-    if ( (signed int)uNumLevelDecorations > 0 )
-        {
-        screenWidth = (unsigned int)&pLevelDecorations[0].vPosition;
-        do
-            {
-            if ( *(char *)(screenWidth - 2) & 8 )
-                {
-                v53 = *(int *)(screenWidth + 4) - v84;
-                v93 = (unsigned __int16 *)(*(int *)screenWidth - v6);
-                screenHeight = v53;
-                v54 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + screenCenter_X;
-                v97 = (const void *)((unsigned __int64)(v53 * (signed __int64)v5) >> 16);
-                v55 = screenCenterY - (int)v97;
-                if ( v54 >= pRenderer->raster_clip_x )
-                    {
-                    if ( v54 <= pRenderer->raster_clip_z && v55 >= pRenderer->raster_clip_y && v55 <= pRenderer->raster_clip_w )
-                        {
-                        v74 = v86;
-                        if ( v5 > 512 )
-                            {
-                            v96 = v55 + 1;
-                            black = v55 - 1;
-                            pRenderer->RasterLine2D(v54 - 1, v55 - 1, v54 - 1, v55 + 1, v86);
-                            pRenderer->RasterLine2D(v54, black, v54, v96, v86);
-                            ++v54;
-                            v74 = v86;
-                            v72 = v96;
-                            v71 = v54;
-                            v70 = black;
-                            }
-                        else
-                            {
-                            v72 = screenCenterY - (int)v97;
-                            v71 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + screenCenter_X;
-                            v70 = screenCenterY - (int)v97;
-                            }
-                        pRenderer->RasterLine2D(v54, v70, v71, v72, v74);
-                        }
-                    }
-                }
             ++v95;
             result = v95;
             screenWidth += 32;
@@ -790,15 +672,15 @@
         {
         screenCenterY = br_x - tl_x + 1;
         v95 = br_y - tl_y + 1;
-        v77 = &pRenderer->pTargetSurface[tl_x + tl_y * surfPitch];
+        v77 = &pRenderer->pTargetSurface[tl_x + tl_y * pRenderer->uTargetSurfacePitch];
         v56 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2;
-        black = (1 << (v56 + 16)) / v5;
+        black = (1 << (v56 + 16)) / viewparams->field_2C;
         v57 = (double)(1 << (16 - v56));
-        v58 = 22528 / (v5 / 384);
-        v59 = (signed __int64)((double)(v6 - v58 + 32768) / v57);
+        v58 = 22528 / (viewparams->field_2C / 384);
+        v59 = (signed __int64)((double)(viewparams->sViewCenterX - v58 + 32768) / v57);
         v60 = (int)v59 << 16;
         v97 = (const void *)((int)v59 << 16);
-        v61 = (signed __int64)((double)(32768 - v58 - v84) / v57);
+        v61 = (signed __int64)((double)(32768 - v58 - pCenterY) / v57);
         pPalette_16 = (unsigned __int16 *)(v60 >> 16);
         v62 = (int)v61 << 16;
         teal = v60 >> 16;
@@ -847,7 +729,7 @@
         if ( (signed int)v95 > 0 )
             {
             v67 = v77;
-            result = 2 * (surfPitch - screenCenterY);
+            result = 2 * (pRenderer->uTargetSurfacePitch - screenCenterY);
             do
                 {
                 if ( screenCenterY > 0 )
@@ -871,5 +753,3 @@
             }
         }
     }
-
-
--- a/mm7_5.cpp	Fri Aug 02 19:28:36 2013 +0200
+++ b/mm7_5.cpp	Fri Aug 02 19:28:59 2013 +0200
@@ -112,10 +112,10 @@
   int v56; // edx@432
   int v57; // eax@432
   Player *pPlayer; // edx@442
-  unsigned int v59; // eax@445
+  unsigned int pMapNum; // eax@445
   signed int v60; // ST64_4@459
-  NPCData *pNPCData2; // eax@467
-  unsigned __int64 v62; // kr00_8@467
+  //NPCData *pNPCData2; // eax@467
+  //unsigned __int64 v62; // kr00_8@467
   __int16 v63; // dx@479
   unsigned int v64; // eax@486
   int v65; // ecx@486
@@ -205,7 +205,7 @@
   int v155; // [sp-4h] [bp-600h]@165
   int v156; // [sp-4h] [bp-600h]@204
   //const char *v157; // [sp-4h] [bp-600h]@444
-  unsigned int v158; // [sp-4h] [bp-600h]@449
+  //unsigned int v158; // [sp-4h] [bp-600h]@449
   //__int16 v159; // [sp-4h] [bp-600h]@550
   int v160; // [sp-4h] [bp-600h]@599
   const char *v161; // [sp-4h] [bp-600h]@637
@@ -232,7 +232,7 @@
   signed int thisb; // [sp+14h] [bp-5E8h]@272
   Player *pPlayer7; // [sp+14h] [bp-5E8h]@373
   Player *pPlayer8; // [sp+14h] [bp-5E8h]@377
-  char *thise; // [sp+14h] [bp-5E8h]@445
+  char *pMapName; // [sp+14h] [bp-5E8h]@445
   Player *pPlayer9; // [sp+14h] [bp-5E8h]@455
   int thisg; // [sp+14h] [bp-5E8h]@467
   int thish; // [sp+14h] [bp-5E8h]@528
@@ -259,7 +259,7 @@
   POINT v209; // [sp+78h] [bp-584h]@777
   POINT v210; // [sp+80h] [bp-57Ch]@397
   POINT v211; // [sp+88h] [bp-574h]@704
-  __int64 v212; // [sp+90h] [bp-56Ch]@467
+  //__int64 v212; // [sp+90h] [bp-56Ch]@467
   int v213; // [sp+98h] [bp-564h]@385
   char pLevelName[32]; // [sp+9Ch] [bp-560h]@380
   char pOut[32]; // [sp+BCh] [bp-540h]@370
@@ -1666,7 +1666,7 @@
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           dword_50CDC8 = 1;
           sub_42FBDD();
-          pNPCData4 = (NPCData *)GetTravelTime();
+          //pNPCData4 = (NPCData *)GetTravelTime();
           strcpy(pOutdoor->pLevelFilename, pCurrentMapName.data());
           if ( bUnderwater != 1 && pParty->bFlying
             || pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pOut, 20) != 1 )
@@ -1695,11 +1695,11 @@
             ++pGameLoadingUI_ProgressBar->uProgressMax;
             SaveGame(1, 0);
             pGameLoadingUI_ProgressBar->Progress();
-            RestAndHeal(1440 * (signed int)pNPCData4);
+            RestAndHeal(1440 * (signed int)GetTravelTime());
             if ( pParty->uNumFoodRations )
             {
               pParty->RestAndHeal();
-              if ( ((pParty->uNumFoodRations - (signed int)pNPCData4) & 0x80000000u) != 0 )
+              if ( ((pParty->uNumFoodRations - (signed int)GetTravelTime()) & 0x80000000u) != 0 )
               {
                 pPlayer7 = pParty->pPlayers;
                 do
@@ -1710,7 +1710,7 @@
                 while ( (signed int)pPlayer7 < (signed int)pParty->pHirelings );
                 ++pParty->days_played_without_rest;
               }
-              Party::TakeFood((unsigned int)pNPCData4);
+              Party::TakeFood((unsigned int)GetTravelTime());
             }
             else
             {
@@ -1964,26 +1964,25 @@
           uNumSeconds = (unsigned int)&pPlayer->pInstalledBeacons[uMessageParam];
           if ( bRecallingBeacon )
           {
-            if ( !*((int *)&pSavegameThumbnails.data()->pPixels + 10 * uMessageParam) )
+            if ( !*((int *)&pSavegameThumbnails[10 * uMessageParam].pPixels ) )
               continue;
-            v173 = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(pPlayer->pInstalledBeacons[uMessageParam].field_18))].pName;
+            v173 = pMapStats->pInfos[sub_410D99_get_map_index(pPlayer->pInstalledBeacons[uMessageParam].SaveFileID)].pName;
             sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[474], v173);// "Recall to %s"
             GameUI_SetFooterString(pTmpBuf.data());
             continue;
           }
-          v59 = pMapStats->GetMapInfo(pCurrentMapName.data());
-          thise = "Not in Map Stats";
-          if ( v59 )
-            thise = pMapStats->pInfos[v59].pName;
-          if ( !*((int *)&pSavegameThumbnails.data()->pPixels + 10 * uMessageParam) || !v59 )
+          pMapNum = pMapStats->GetMapInfo(pCurrentMapName.data());
+          pMapName = "Not in Map Stats";
+          if ( pMapNum )
+            pMapName = pMapStats->pInfos[pMapNum].pName;
+          if ( !*((int *)&pSavegameThumbnails[10 * uMessageParam].pPixels ) || !pMapNum )
           {
-            sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[476], thise);// "Set to %s"
+            sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[476], pMapName);// "Set to %s"
             GameUI_SetFooterString(pTmpBuf.data());
             continue;
           }
           v174 = pMapStats->pInfos[sub_410D99_get_map_index(*(short *)(uNumSeconds + 26))].pName;
-          v158 = (unsigned int)thise;
-          sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[475], v158, v174);// "Set %s over %s"
+          sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[475], (unsigned int)pMapName, v174);// "Set %s over %s"
           GameUI_SetFooterString(pTmpBuf.data());
           continue;
         case UIMSG_CloseAfterInstallBeacon:
@@ -1998,8 +1997,7 @@
           continue;
         case UIMSG_InstallBeacon:
           pPlayer9 = pPlayers[_506348_current_lloyd_playerid + 1];
-          pNPCData4 = (NPCData *)&pPlayer9->pInstalledBeacons[uMessageParam];
-          if ( !*(_QWORD *)&pNPCData4->pName && bRecallingBeacon )
+          if ( !pPlayer9->pInstalledBeacons[uMessageParam].uBeaconTime && bRecallingBeacon )
             continue;
           byte_506360 = 1;
           pPlayer9->CanCastSpell(uRequiredMana);
@@ -2017,38 +2015,30 @@
           pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[dword_506338], 0, 0, -1, 0, dword_50633C, 0, 0);
           if ( bRecallingBeacon )
           {
-            if ( _stricmp(pCurrentMapName.data(), (const char *)&pGames_LOD->pSubIndices[HIWORD(pNPCData4->uProfession)]) )
+            if ( _stricmp(pCurrentMapName.data(), (const char *)&pGames_LOD->pSubIndices[pPlayer9->pInstalledBeacons[uMessageParam].SaveFileID]) )
             {
               SaveGame(1, 0);
               OnMapLeave();
-              strcpy(pCurrentMapName.data(), (const char *)&pGames_LOD->pSubIndices[HIWORD(pNPCData4->uProfession)]);
+              strcpy(pCurrentMapName.data(), (const char *)&pGames_LOD->pSubIndices[pPlayer9->pInstalledBeacons[uMessageParam].SaveFileID]);
               dword_6BE364_game_settings_1 |= 1;
               uGameState = GAME_STATE_2;
-              _5B65A8_npcdata_uflags_or_other = pNPCData4->uFlags;
-              _5B65AC_npcdata_fame_or_other = pNPCData4->fame;
-              _5B65B0_npcdata_rep_or_other = pNPCData4->rep;
-              _5B65B4_npcdata_loword_house_or_other = LOWORD(pNPCData4->Location2D);
-              _5B65B8_npcdata_hiword_house_or_other = HIWORD(pNPCData4->Location2D);
+              _5B65A8_npcdata_uflags_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X;
+              _5B65AC_npcdata_fame_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Y;
+              _5B65B0_npcdata_rep_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Z;
+              _5B65B4_npcdata_loword_house_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X;
+              _5B65B8_npcdata_hiword_house_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y;
               dword_5B65C0 = 1;
             }
             else
             {
-              pParty->vPosition.x = pNPCData4->uFlags;
-              pParty->vPosition.y = pNPCData4->fame;
-              pParty->vPosition.z = pNPCData4->rep;
+              pParty->vPosition.x = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X;
+              pParty->vPosition.y = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Y;
+              pParty->vPosition.z = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Z;
               pParty->uFallStartY = pParty->vPosition.z;
-              pParty->sRotationY = LOWORD(pNPCData4->Location2D);
-              pParty->sRotationX = HIWORD(pNPCData4->Location2D);
+              pParty->sRotationY = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X;
+              pParty->sRotationX = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y;
             }
             pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-            /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-            {
-              pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
-              pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0;
-              *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-              ++pMessageQueue_50CBD0->uNumMessages;
-            }*/
-            //crt_deconstruct_ptr_6A0118();
             pBooksWindow->Release();
             pGUIWindow_CurrentMenu->Release();
             pBooksWindow = 0;
@@ -2059,28 +2049,19 @@
             sprintf(a1, "data\\lloyd%d%d.pcx", _506348_current_lloyd_playerid + 1, uMessageParam + 1);
             SaveScreenshot(a1);
             LoadThumbnailLloydTexture(uMessageParam, _506348_current_lloyd_playerid + 1);
-            v212 = qword_506350 << 7;
-            pNPCData2 = pNPCData4;
-            thisg = 0;
-            v62 = pParty->uTimePlayed + (signed __int64)((double)(qword_506350 << 7) * 0.033333335);
-            pNPCData4->pName = (char *)v62;
-            pNPCData2->uPortraitID = HIDWORD(v62);
-            pNPCData2->uFlags = pParty->vPosition.x;
-            pNPCData2->fame = pParty->vPosition.y;
-            pNPCData2->rep = pParty->vPosition.z;
-            LOWORD(pNPCData2->Location2D) = LOWORD(pParty->sRotationY);
-            HIWORD(pNPCData2->Location2D) = LOWORD(pParty->sRotationX);
+            pPlayer9->pInstalledBeacons[uMessageParam].uBeaconTime = pParty->uTimePlayed + (signed __int64)((double)(qword_506350 << 7) * 0.033333335);
+            pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X = pParty->vPosition.x;
+            pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Y = pParty->vPosition.y;
+            pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Z = pParty->vPosition.z;
+            pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X = LOWORD(pParty->sRotationY);
+            pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y = LOWORD(pParty->sRotationX);
             if ( (signed int)pGames_LOD->uNumSubDirs / 2 <= 0 )
               continue;
-            uAction = 0;
-            while ( _stricmp((const char *)pGames_LOD->pSubIndices + uAction, pCurrentMapName.data()) )
+            for ( thisg = 0; thisg < (signed int)pGames_LOD->uNumSubDirs / 2; ++thisg )
             {
-              ++thisg;
-              uAction += 32;
-              if ( thisg >= (signed int)pGames_LOD->uNumSubDirs / 2 )
-                continue;
+              if ( !_stricmp((const char *)pGames_LOD->pSubIndices[thisg].pFilename, pCurrentMapName.data()) )
+                pPlayer9->pInstalledBeacons[uMessageParam].SaveFileID = thisg;
             }
-            HIWORD(pNPCData4->uProfession) = thisg;
           }
           continue;
         case UIMSG_ClickTownInTP:
@@ -3017,8 +2998,8 @@
           continue;
         case UIMSG_ShowStatus_Funds:
           v174 = (char *)pParty->uNumGoldInBank;
-          v158 = pParty->uNumGold + pParty->uNumGoldInBank;
-          sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[489], v158, v174);// "You have %d total gold, %d in the Bank"
+          //v158 = pParty->uNumGold + pParty->uNumGoldInBank;
+          sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[489], pParty->uNumGold + pParty->uNumGoldInBank, v174);// "You have %d total gold, %d in the Bank"
           GameUI_SetFooterString(pTmpBuf.data());
           continue;
         case UIMSG_ShowStatus_DateTime: