changeset 26:93bf1d5f6a6d

Game loading.
author Nomad
date Tue, 16 Oct 2012 00:05:53 +0200
parents 2bbf33898c6b
children be2066176d89 7022d20db19f
files Actor.cpp Allocator.cpp Arcomage.cpp GUIWindow.cpp Game.cpp NPC.h Overlays.cpp Party.cpp Party.h Player.cpp SaveLoad.cpp Texture.cpp Time.h mm7_1.cpp mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp mm7_data.cpp mm7_data.h
diffstat 20 files changed, 946 insertions(+), 1026 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Mon Oct 15 18:45:11 2012 +0200
+++ b/Actor.cpp	Tue Oct 16 00:05:53 2012 +0200
@@ -2268,7 +2268,7 @@
       if ( pParty->uFine )
       {
         if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)(*ppPlayers)->field_152, 1) )
-          _449B7E_toggle_bit((*ppPlayers)->field_152, 1, 1u);
+          _449B7E_toggle_bit((unsigned char *)(*ppPlayers)->field_152, 1, 1u);
       }
       ++ppPlayers;
     }
--- a/Allocator.cpp	Mon Oct 15 18:45:11 2012 +0200
+++ b/Allocator.cpp	Tue Oct 16 00:05:53 2012 +0200
@@ -21,7 +21,7 @@
 //----- (00426755) --------------------------------------------------------
 void *Allocator::AllocNamedChunk(const void *pPrevPtrValue, unsigned int uSize, const char *pName)
 {
-  Allocator *v4; // esi@1
+  //Allocator *v4; // esi@1
   unsigned int v5; // eax@7
   void *result; // eax@8
   unsigned int *pNumBuffersUsed; // ebx@12
@@ -32,10 +32,10 @@
   void *v12; // eax@22
   unsigned int Size; // [sp+14h] [bp+Ch]@16
 
-  v4 = this;
+  //v4 = this;
   if ( pPrevPtrValue && !aborting_app )
     AbortWithError();
-  if ( !v4->bBigBufferAllocated && !aborting_app )
+  if ( !bBigBufferAllocated && !aborting_app )
     AbortWithError();
   v5 = uSize;
   if ( uSize )
@@ -45,23 +45,23 @@
       AbortWithError();
       v5 = uSize;
     }
-    pNumBuffersUsed = &v4->uNumBuffersUsed;
-    if ( v4->uNumBuffersUsed == 6000 && !aborting_app )
+    pNumBuffersUsed = &uNumBuffersUsed;
+    if (uNumBuffersUsed == 6000 && !aborting_app)
     {
       AbortWithError();
       v5 = uSize;
     }
     v8 = *pNumBuffersUsed;
-    v9 = v4->bUseBigBuffer == 0;
+    v9 = bUseBigBuffer == 0;
     ++*pNumBuffersUsed;
     if ( v9 )
     {
       v12 = malloc(v5);
-      v11 = (void **)((char *)v4 + 4 * v8);
+      v11 = &pMemoryBuffers[v8];
       *v11 = v12;
       if ( v12 )
       {
-        v4->uMemoryBuffersSizes[v8] = uSize;
+        uMemoryBuffersSizes[v8] = uSize;
       }
       else
       {
@@ -74,19 +74,19 @@
       LOBYTE(v5) = v5 & 0xFC;
       v10 = v5 + 4;
       Size = v10;
-      if ( v10 + v4->uNextFreeOffsetInBigBuffer > v4->uBigBufferSizeAligned )
+      if ( v10 + uNextFreeOffsetInBigBuffer > uBigBufferSizeAligned )
       {
         printf("Id: %s  Size: %i\n", pName, v10);
         CreateFileDump("Memory");
         if ( !aborting_app )
           AbortWithError();
       }
-      v11 = (void **)((char *)v4 + 4 * v8);
-      *v11 = (char *)v4->pBigMemoryBuffer + v4->uNextFreeOffsetInBigBuffer;
-      v4->uMemoryBuffersSizes[v8] = Size;
-      if ( pName )
-        strncpy((char *)v4 + 4 * (3 * v8 + 12000), pName, 11u);
-      v4->uNextFreeOffsetInBigBuffer += Size;
+      v11 = &pMemoryBuffers[v8];
+      *v11 = (char *)pBigMemoryBuffer + uNextFreeOffsetInBigBuffer;
+      uMemoryBuffersSizes[v8] = Size;
+      if (pName)
+        strncpy(pMemoryBuffersNames[v8], pName, 11);
+      uNextFreeOffsetInBigBuffer += Size;
     }
     result = *v11;
   }
--- a/Arcomage.cpp	Mon Oct 15 18:45:11 2012 +0200
+++ b/Arcomage.cpp	Tue Oct 16 00:05:53 2012 +0200
@@ -5667,12 +5667,12 @@
     }
     while ( v10 <= 120 );
     if ( v10 == 121 )
-      _449B7E_toggle_bit((char *)pParty->_award_bits, 238, 1u);
+      _449B7E_toggle_bit(pParty->_award_bits, 238, 1u);
     v11 = pParty->pPlayers[0].field_152;
     do
     {
       if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v11, 1) )
-        _449B7E_toggle_bit(v11, 103, 1u);
+        _449B7E_toggle_bit((unsigned char *)v11, 103, 1u);
       v11 += 6972;
     }
     while ( (signed int)v11 < (signed int)((char *)&pParty->field_777C[36] + 2) );
@@ -5686,7 +5686,7 @@
     do
     {
       if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v12, 1) )
-        _449B7E_toggle_bit(v12, 104, 1u);
+        _449B7E_toggle_bit((unsigned char *)v12, 104, 1u);
       v12 += 6972;
     }
     while ( (signed int)v12 < (signed int)((char *)&pParty->field_777C[36] + 2) );
--- a/GUIWindow.cpp	Mon Oct 15 18:45:11 2012 +0200
+++ b/GUIWindow.cpp	Tue Oct 16 00:05:53 2012 +0200
@@ -822,7 +822,7 @@
               v25 = (&dword_723718_autonote_related)[8 * (signed __int16)v10];
               if ( (short)v10 )
               {
-                if ( (unsigned __int16)_449B57_test_bit((unsigned __int8 *)pParty->_autonote_related_stuff, v10) && v25 )
+                if ( (unsigned __int16)_449B57_test_bit(pParty->_autonote_bits, v10) && v25 )
                 {
                   v11 = dword_506520++;
                   pStru179->field_0[v11] = (signed __int16)v10;
--- a/Game.cpp	Mon Oct 15 18:45:11 2012 +0200
+++ b/Game.cpp	Tue Oct 16 00:05:53 2012 +0200
@@ -196,8 +196,8 @@
 //----- (00463149) --------------------------------------------------------
 void Game::Loop()
 {
-  signed int v0; // ebp@3
-  signed int v1; // esi@4
+  //signed int v0; // ebp@3
+  //signed int v1; // esi@4
   Render *v2; // edi@7
   signed int v3; // esi@7
   signed int v4; // ecx@58
@@ -219,27 +219,21 @@
 
   bLoading = uCurrentMenuID == MENU_LOAD;
   SetCurrentMenuID((MENU_STATE)-1);
-  if ( bLoading )
+  if (bLoading)
   {
     pParty->Reset();
     dword_6BE340 = 0;
     uGameState = 0;
     LoadGame(uLoadGameUI_SelectedSlot);
   }
-  v0 = 1;
-  do
-  {
-    v1 = 1;
-    do
+
+  for (uint i = 1; i < 5; ++i)
+    for (uint j = 1; j < 6; ++j)
     {
-      sprintfex(pTmpBuf, "data\\lloyd%d%d.pcx", v0, v1);
+      sprintf(pTmpBuf, "data\\lloyd%d%d.pcx", i, j);
       remove(pTmpBuf);
-      ++v1;
     }
-    while ( v1 < 6 );
-    ++v0;
-  }
-  while ( v0 < 5 );
+
   LoadPlayerPortraintsAndVoices();
   pIcons_LOD->dword_11B84 = pIcons_LOD->uNumLoadedFiles;
   pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0));
--- a/NPC.h	Mon Oct 15 18:45:11 2012 +0200
+++ b/NPC.h	Tue Oct 16 00:05:53 2012 +0200
@@ -79,7 +79,9 @@
 {
   inline NPCStats():
     pNPCTextTXT_Raw(nullptr), pNPCTopicTXT_Raw(nullptr), pNPCDistTXT_Raw(nullptr)
-  {}
+  {
+    uNumNPCNames[0] = uNumNPCNames[1] = 0;
+  }
 
   void Initialize2();
   void Initialize1();
--- a/Overlays.cpp	Mon Oct 15 18:45:11 2012 +0200
+++ b/Overlays.cpp	Tue Oct 16 00:05:53 2012 +0200
@@ -17,8 +17,8 @@
 
 
 
-struct OtherOverlayList *pOtherOverlayList; // idb
-struct OverlayList *pOverlayList;
+struct OtherOverlayList *pOtherOverlayList = new OtherOverlayList; // idb
+struct OverlayList *pOverlayList = new OverlayList;
 
 
 
--- a/Party.cpp	Mon Oct 15 18:45:11 2012 +0200
+++ b/Party.cpp	Tue Oct 16 00:05:53 2012 +0200
@@ -518,16 +518,10 @@
   PLAYER_SEX v7; // al@6
   PLAYER_SEX v8; // al@9
   PLAYER_SEX v9; // cl@12
-  Player **v10; // ebx@15
-  signed int v11; // eax@16
-  Player *v12; // edx@17
-  signed int v13; // edi@18
+  //Player *v12; // edx@17
+  //signed int v13; // edi@18
   SpellBuff *v14; // ebx@21
   signed int v15; // edi@21
-  char *v16; // esi@23
-  Player **v17; // esi@23
-  int v18; // edx@24
-  Player *v19; // eax@24
 
   field_708 = 15;
   sEyelevel = 160;
@@ -718,58 +712,39 @@
   pPlayers[3].uSex = v9;
   pPlayers[3].RandomizeName();
   strcpy(pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]);
-  v10 = &::pPlayers[1];
-  do
+
+
+
+  for (uint i = 0; i < 4; ++i)
   {
-    (*v10)->uTimeToRecovery = 0;
-    v11 = 0;
-    do
-    {
-      v12 = *v10;
-      LODWORD((*v10)->pConditions[v11]) = 0;
-      ++v11;
-      *(int *)((char *)v12 + v11 * 8 - 4) = 0;
-    }
-    while ( v11 < 20 );
-    v13 = 6048;
-    do
-    {
-      ((SpellBuff *)((char *)*v10 + v13))->Reset();
-      v13 += 16;
-    }
-    while ( v13 < 6432 );
-    ++v10;
+    pPlayers[i].uTimeToRecovery = 0;
+    for (uint j = 0; j < 20; ++j)
+      pPlayers[i].pConditions[j] = 0;
+
+    for (uint j = 0; j < 24; ++j)
+      pPlayers[i].pPlayerBuffs[j].Reset();
+
+    pPlayers[i].uExpressionID = 1;
+    pPlayers[i].uExpressionTimePassed = 0;
+    pPlayers[i].uExpressionTimeLength = rand() % 256 + 128;
   }
-  while ( (signed int)v10 <= (signed int)&pPlayers[4] );
-  v14 = &pPartyBuffs[1];
-  v15 = 19;
-  do
-  {
-    v14->Reset();
-    ++v14;
-    --v15;
-  }
-  while ( v15 );
+
+  for (uint i = 1; i < 20; ++i)
+    pPartyBuffs[i].Reset();
+
+
   pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 100;
   uFlags = 0;
-  v16 = (char *)_award_bits;
-  _449B7E_toggle_bit(v16, 1, 1u);
-  _449B7E_toggle_bit(v16, 2, 1u);
-  _449B7E_toggle_bit(v16, 3, 1u);
-  _449B7E_toggle_bit(v16, 4, 1u);
-  _449B7E_toggle_bit(v16, 5, 1u);
-  _449B7E_toggle_bit(v16, 6, 1u);
-  v17 = &::pPlayers[1];
-  do
-  {
-    (*v17)->uExpressionID = 1;
-    (*v17)->uExpressionTimePassed = 0;
-    v18 = rand() % 256;
-    v19 = *v17;
-    ++v17;
-    v19->uExpressionTimeLength = v18 + 128;
-  }
-  while ( (signed int)v17 <= (signed int)&pPlayers[4] );
+
+  memset(_award_bits, 0, 64);
+  _449B7E_toggle_bit(_award_bits, 1, 1);
+  _449B7E_toggle_bit(_award_bits, 2, 1);
+  _449B7E_toggle_bit(_award_bits, 3, 1);
+  _449B7E_toggle_bit(_award_bits, 4, 1);
+  _449B7E_toggle_bit(_award_bits, 5, 1);
+  _449B7E_toggle_bit(_award_bits, 6, 1);
+
+
   memcpy(pNPCStats->pNewNPCData, &pNPCStats, 0x94BCu);
   memcpy(pNPCStats->pGroups_copy, pNPCStats->pGroups, 0x66u);
   pNPCStats->pNewNPCData[3].uFlags |= 0x80u;
--- a/Party.h	Mon Oct 15 18:45:11 2012 +0200
+++ b/Party.h	Tue Oct 16 00:05:53 2012 +0200
@@ -116,7 +116,18 @@
 {
   Party():
     uTimePlayed(0)
-  {}
+  {
+    uCurrentYear = 0;
+    uCurrentMonth = 0;
+    uCurrentMonthWeek = 0;
+    uDaysPlayed = 0;
+    uCurrentHour = 0;
+    uCurrentMinute = 0;
+    uCurrentTimeSecond = 0;
+
+    field_6FC = 0;
+    field_764 = 0;
+  }
 
   void _4909F4();
   void RestAndHeal();
@@ -179,7 +190,7 @@
   unsigned int uDaysPlayed;
   unsigned int uCurrentHour;
   unsigned int uCurrentMinute;
-  int uCurrentTimeSecond;
+  unsigned int uCurrentTimeSecond;
   unsigned int uNumFoodRations;
   int field_72C;
   int field_730;
@@ -192,7 +203,7 @@
   int field_74C;
   __int16 field_750[5];
   __int16 field_75A[5];
-  char field_764;
+  char field_764; // num hours resting or some sort of.
   unsigned __int8 _award_bits[64];
   unsigned __int8 pArcomageWins[16];
   char field_7B5_in_arena_quest;
@@ -202,7 +213,7 @@
   char uNumArenaLordWins;
   char field_7BA[12];
   char pArtifactsFound[56];
-  char _autonote_related_stuff[12];
+  unsigned char _autonote_bits[12];
   char field_80A[74];
   char field_854[32];
   int field_874;
--- a/Player.cpp	Mon Oct 15 18:45:11 2012 +0200
+++ b/Player.cpp	Tue Oct 16 00:05:53 2012 +0200
@@ -2297,6 +2297,17 @@
 
   memset(field_1988, 0, 49 * sizeof(int));
   memset(field_1A50, 0, 64 * sizeof(char));
+
+  field_E0 = 0;
+  field_E4 = 0;
+  field_E8 = 0;
+  field_EC = 0;
+  field_F0 = 0;
+  field_F4 = 0;
+  field_F8 = 0;
+  field_FC = 0;
+  field_100 = 0;
+  field_104 = 0;
 }
 
 //----- (0048C6F6) --------------------------------------------------------
@@ -7979,7 +7990,7 @@
   if ( var == VAR_AutoNotes )
   {
     v13 = 0x80u >> ((signed __int16)(a1 - 1) - 1) % 8;
-    v14 = pParty->_autonote_related_stuff[((signed __int16)(a1 - 1) - 1) >> 3];
+    v14 = pParty->_autonote_bits[((signed __int16)(a1 - 1) - 1) >> 3];
 LABEL_108:
     if ( !((unsigned __int8)v13 & v14) )
       goto _cmp_against_arg;
@@ -8360,7 +8371,7 @@
           switch ( var )
           {
             case VAR_MonthEquals|VAR_CurrentSP:
-              _449B7E_toggle_bit(this->field_1A50, a3, 1u);
+              _449B7E_toggle_bit((unsigned char *)field_1A50, a3, 1u);
               break;
             case VAR_NPCs2:
               pParty->field_709 = 0;
@@ -8451,7 +8462,7 @@
   }
   if ( var == VAR_AutoNotes )
   {
-    if ( !((unsigned __int8)(0x80u >> ((signed __int16)a3 - 1) % 8) & pParty->_autonote_related_stuff[((signed __int16)a3 - 1) >> 3])
+    if ( !((unsigned __int8)(0x80u >> ((signed __int16)a3 - 1) % 8) & pParty->_autonote_bits[((signed __int16)a3 - 1) >> 3])
       && (&dword_723718_autonote_related)[8 * a3] )
     {
       v20 = pPlayers[v3 + 1];
@@ -8461,7 +8472,7 @@
       bFlashAutonotesBook = 1;
       dword_506568 = v21;
     }
-    _449B7E_toggle_bit(pParty->_autonote_related_stuff, a3, 1u);
+    _449B7E_toggle_bit(pParty->_autonote_bits, a3, 1u);
     v31 = 1;
     goto LABEL_168;
   }
@@ -8545,7 +8556,7 @@
           }
           v13 = (char *)pParty->_award_bits;
 LABEL_51:
-          _449B7E_toggle_bit(v13, a3, 1u);
+          _449B7E_toggle_bit((unsigned char *)v13, a3, 1u);
           goto LABEL_168;
         case VAR_PlayerItemInHands:
           item.Reset();
@@ -8976,7 +8987,7 @@
               }
               v15 = (char *)pParty->_award_bits;
 LABEL_44:
-              _449B7E_toggle_bit(v15, val, 1u);
+              _449B7E_toggle_bit((unsigned char *)v15, val, 1u);
               goto LABEL_173;
             case VAR_PlayerItemInHands:
               item.Reset();
@@ -9229,7 +9240,7 @@
         return;
       goto _play_sound;
     }
-    if ( !((unsigned __int8)(0x80u >> ((signed __int16)val - 1) % 8) & pParty->_autonote_related_stuff[((signed __int16)val - 1) >> 3])
+    if ( !((unsigned __int8)(0x80u >> ((signed __int16)val - 1) % 8) & pParty->_autonote_bits[((signed __int16)val - 1) >> 3])
       && (&dword_723718_autonote_related)[8 * val] )
     {
       v23 = pPlayers[uPlayerIdx + 1];
@@ -9239,7 +9250,7 @@
       bFlashAutonotesBook = 1;
       dword_506568 = v24;
     }
-    _449B7E_toggle_bit(pParty->_autonote_related_stuff, val, 1u);
+    _449B7E_toggle_bit(pParty->_autonote_bits, val, 1u);
     v3 = 1;
 LABEL_173:
     if ( v34 != 1 )
@@ -9294,7 +9305,7 @@
         switch ( var )
         {
           case VAR_MonthEquals|VAR_CurrentSP:
-            _449B7E_toggle_bit(Dst->field_1A50, val, 1u);
+            _449B7E_toggle_bit((unsigned char *)Dst->field_1A50, val, 1u);
             break;
           case VAR_NPCs2:
             pParty->field_709 = 0;
@@ -9410,7 +9421,7 @@
       }
       if ( var == 223 )
       {
-        v11 = pParty->_autonote_related_stuff;
+        v11 = (char *)pParty->_autonote_bits;
         v22 = (short)a3 - 1;
       }
       else
@@ -9493,7 +9504,7 @@
 LABEL_112:
         v22 = (signed __int16)a3;
       }
-      _449B7E_toggle_bit(v11, v22, 0);
+      _449B7E_toggle_bit((unsigned char *)v11, v22, 0);
       return;
     }
     switch ( var )
@@ -9581,7 +9592,7 @@
           *((int *)v12 + 1) -= v14 + HIDWORD(v13);
           goto LABEL_17;
         case VAR_QBits_QuestsDone:
-          _449B7E_toggle_bit((char *)pParty->_award_bits, (__int16)a3, 0);
+          _449B7E_toggle_bit(pParty->_award_bits, (__int16)a3, 0);
           pPlayers[v4 + 1]->PlaySound(96, 0);
           return;
         case VAR_PlayerItemInHands:
--- a/SaveLoad.cpp	Mon Oct 15 18:45:11 2012 +0200
+++ b/SaveLoad.cpp	Tue Oct 16 00:05:53 2012 +0200
@@ -2,6 +2,21 @@
 #include <direct.h>
 
 #include "SaveLoad.h"
+#include "NPC.h"
+#include "Party.h"
+#include "LOD.h"
+#include "Outdoor.h"
+#include "AudioPlayer.h"
+#include "Actor.h"
+#include "Chest.h"
+#include "Time.h"
+#include "GUIWindow.h"
+#include "GUIFont.h"
+#include "Overlays.h"
+#include "LayingItem.h"
+#include "Viewport.h"
+#include "stru123.h"
+#include "Log.h"
 
 #include "mm7_data.h"
 
@@ -17,6 +32,713 @@
 
 
 
+
+
+
+
+
+
+
+//----- (0045EE8A) --------------------------------------------------------
+void __fastcall LoadGame(unsigned int uSlot)
+{
+  //unsigned int v1; // ebx@1
+  //char v2; // zf@1
+  //signed int v3; // esi@3
+  //signed int v4; // esi@8
+  //char *v5; // eax@9
+  //unsigned int v6; // eax@12
+  //unsigned int v7; // esi@13
+  //char *v8; // ecx@14
+  //FILE *v9; // eax@22
+  //FILE *v10; // eax@26
+  //FILE *v11; // eax@29
+  //FILE *v12; // eax@32
+  //FILE *v13; // eax@35
+  //FILE *v14; // eax@38
+  //unsigned int v15; // edi@41
+  //Player *v16; // esi@41
+  //int *v17; // esi@46
+  //int v18; // edi@46
+  //int v19; // ebx@46
+  //int v20; // ecx@49
+  //int v21; // eax@51
+  //int v22; // ecx@56
+  //bool v23; // edx@56
+  //AudioPlayer *v24; // ebx@60
+  bool v25; // esi@62
+  bool v26; // eax@62
+  //signed int v27; // esi@66
+  //RGBTexture *v28; // edi@67
+  std::string v29; // [sp-18h] [bp-108h]@25
+  int v30; // [sp-Ch] [bp-FCh]@65
+  int v31; // [sp-8h] [bp-F8h]@4
+  //signed int v32; // [sp-4h] [bp-F4h]@4
+  char DstBuf[100]; // [sp+Ch] [bp-E4h]@23
+  //char pContainer; // [sp+20h] [bp-D0h]@62
+  char Str[123]; // [sp+70h] [bp-80h]@25
+  //char a3[5]; // [sp+EBh] [bp-5h]@2
+
+  //v1 = uSlot;
+  //v2 = pSavegameUsedSlots[uSlot] == 0;
+  dword_5B65C8 = 0;
+  if (!pSavegameUsedSlots[uSlot])
+  {
+    pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
+    Log::Warning(L"LoadGame: slot %u is empty", uSlot);
+    return;
+  }
+
+  for (uint i = 1; i < 5; ++i)
+    for (uint j = 1; j < 6; ++j)
+    {
+      sprintf(pTmpBuf, "data\\lloyd%d%d.pcx", i, j);
+      remove(pTmpBuf);
+    }
+
+
+  if (byte_4ED498)
+    for (uint i = 0; i < 4; ++i)
+    {
+      for (uint j = 0; j < pSoundList->uNumSounds; ++j)
+        if (pSoundList->pSounds[j].uSoundID == 2 * (byte_4ED498 + 50 * pParty->pPlayers[i].uVoiceID) + 4998)
+        {
+          pSoundList->_4A9DCD(j, 1);
+          break;
+        }
+
+        for (uint j = 0; j < pSoundList->uNumSounds; ++j)
+        if (pSoundList->pSounds[j].uSoundID == 2 * (byte_4ED498 + 50 * pParty->pPlayers[i].uVoiceID) + 4999)
+        {
+          pSoundList->_4A9DCD(j, 1);
+          break;
+        }
+    }
+
+  sprintf(pTmpBuf, "saves\\%s", pSavegameList->pSavesNames[uSlot]);
+
+  pNew_LOD->CloseWriteFile();
+  if (!CopyFileA(pTmpBuf, "data\\new.lod", 0))
+    int e = GetLastError();
+
+  pNew_LOD->LoadFile("data\\new.lod", 0);
+  auto *f = pNew_LOD->FindContainer("header.bin", 1);
+  if (!f)
+  {
+    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 100);
+    Log::Warning(L"%S", Str);
+    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:549", 0);
+  }
+  fread(&DstBuf, 0x64u, 1u, f);
+
+  f = pNew_LOD->FindContainer("party.bin", 1);
+  if (!f)
+  {
+    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 101);
+    Log::Warning(L"%S", Str);
+    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:559", 0);
+  }
+  if (sizeof(Party) != 0x16238)
+    Log::Warning(L"class Party: deserialization warning");
+  fread(pParty, 0x16238u, 1, f);
+
+
+  f = pNew_LOD->FindContainer("clock.bin", 1);
+  if (!f)
+  {
+    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 102);
+    Log::Warning(L"%S", Str);
+    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:569", 0);
+  }
+  if (sizeof(Timer) != 0x28)
+    Log::Warning(L"class Timer: deserialization warning");
+  fread(pEventTimer, 0x28u, 1u, f);
+
+  f = pNew_LOD->FindContainer("overlay.bin", 1);
+  if (!f)
+  {
+    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 103);
+    Log::Warning(L"%S", Str);
+    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:579", 0);
+  }
+  if (sizeof(OtherOverlayList) != 0x3F0)
+    Log::Warning(L"class OtherOverlayList: deserialization warning");
+  fread(pOtherOverlayList, 0x3F0, 1, f);
+
+  f = pNew_LOD->FindContainer("npcdata.bin", 0);
+  if (!f)
+  {
+    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 104);
+    Log::Warning(L"%S", Str);
+    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:590", 0);
+  }
+  if (sizeof(pNPCStats->pNewNPCData) != 0x94BC)
+    Log::Warning(L"NPCStats: deserialization warning");
+  fread(pNPCStats->pNewNPCData, 0x94BC, 1, f);
+  pNPCStats->_476C60();
+
+  f = pNew_LOD->FindContainer("npcgroup.bin", 0);
+  if (!f)
+  {
+    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 105);
+    Log::Warning(L"%S", Str);
+    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:600", 0);
+  }
+  if (sizeof(pNPCStats->pGroups_copy) != 0x66)
+    Log::Warning(L"NPCStats: deserialization warning");
+  fread(pNPCStats->pGroups_copy, 0x66, 1, f);
+
+
+  uActiveCharacter = 0;
+  for (uint i = 0; i < 4; ++i)
+    if (pParty->pPlayers[i].CanAct())
+    {
+      uActiveCharacter = i + 1;
+      break;
+    }
+
+  for (uint i = 0; i < 4; ++i)
+  {
+    auto uQuickspell = pParty->pPlayers[i].uQuickSpell;
+    if (uQuickspell)
+      stru_AA1058[i]._494836(uQuickspell, i + 9 - 8);
+
+    for (uint j = 0; j < 2; ++j)
+    {
+      uint uEquipIdx = pParty->pPlayers[i].pEquipment.pIndices[j];
+      if (uEquipIdx)
+      {
+        auto uItemID = pParty->pPlayers[i].pInventoryItems[uEquipIdx - 1].uItemID;
+        if (pItemsTable->pItems[uItemID].uEquipType == 12)
+        {
+          __debugbreak();
+          v31 = *((int *)&pSpellDatas[66].field_8 + uItemID);
+          stru_A750F8[i]._494836(v31, i + 9);
+        }
+      }
+    }
+  }
+
+
+  pGUIWindow_CurrentMenu->Release();
+  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+
+  viewparams->bRedrawGameUI = true;
+
+  SetUserInterface(pParty->uAlignment, true);
+
+  pEventTimer->Resume();
+  pEventTimer->StopGameTime();
+
+  v25 = pGames_LOD->DoesContainerExist(&DstBuf[20]);
+  sprintf(pTmpBuf, "levels\\%s", &DstBuf[20]);
+  v26 = _access(pTmpBuf, 4) != -1;
+  if ( !v25 && !v26 )
+  {
+    sprintf(pTmpBuf, "Unable to find: %s!", &DstBuf[20]);
+    Abortf(pTmpBuf);
+  }
+
+  strcpy(pCurrentMapName, &DstBuf[20]);
+  dword_6BE364_game_settings_1 |= 0x2001;
+
+  for (uint i = 0; i < uNumSavegameFiles; ++i)
+    pSavegameThumbnails[i].Release();
+
+  pIcons_LOD->_4114F2();
+  pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0);
+  pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0);
+  if (uTurnSpeed)
+    pParty->sRotationY = uTurnSpeed * pParty->sRotationY / (signed int)uTurnSpeed;
+  MM7Initialization();
+  bFlashQuestBook = 0;
+  viewparams->bRedrawGameUI = 1;
+}
+
+
+//----- (0045F469) --------------------------------------------------------
+int __fastcall SaveGame(int a1, __int16 *a2)
+{
+  int result; // eax@1
+  void *v3; // edi@5
+  int v4; // eax@6
+  int v5; // eax@6
+  int v6; // eax@6
+  const char *v7; // edi@8
+  FILE *v8; // edi@24
+  int v9; // edi@30
+  void *v10; // esi@31
+  void *v11; // esi@31
+  void *v12; // esi@37
+  void *v13; // esi@37
+  void *v14; // esi@37
+  void *v15; // esi@37
+  void *v16; // esi@37
+  int v17; // esi@37
+  unsigned int v18; // ecx@38
+  unsigned int v19; // esi@39
+  char *v20; // edx@39
+  void *v21; // esi@41
+  void *v22; // esi@41
+  BSPModel *v23; // eax@42
+  signed int v24; // edi@42
+  unsigned __int8 v25; // zf@43
+  unsigned __int8 v26; // sf@43
+  signed int v27; // edi@47
+  void *v28; // esi@50
+  void *v29; // esi@50
+  void *v30; // esi@50
+  void *v31; // esi@50
+  int v32; // esi@51
+  int v33; // eax@51
+  DWORD v34; // eax@59
+  std::string v35; // [sp-18h] [bp-288h]@8
+  const char *v36; // [sp-10h] [bp-280h]@6
+  const char *v37; // [sp-Ch] [bp-27Ch]@6
+  const char *v38; // [sp-8h] [bp-278h]@8
+  int v39; // [sp-4h] [bp-274h]@8
+  CHAR Buffer; // [sp+Ch] [bp-264h]@59
+  char Dir; // [sp+8Ch] [bp-1E4h]@51
+  char Drive; // [sp+ACh] [bp-1C4h]@51
+  int v43; // [sp+CCh] [bp-1A4h]@10
+  char Dest[20]; // [sp+E0h] [bp-190h]@10
+  unsigned __int64 v45; // [sp+F4h] [bp-17Ch]@10
+  char Filename; // [sp+130h] [bp-140h]@51
+  char Ext; // [sp+150h] [bp-120h]@51
+  char v48; // [sp+151h] [bp-11Fh]@51
+  char Source[32]; // [sp+170h] [bp-100h]@51
+  char Str[120]; // [sp+190h] [bp-E0h]@8
+  int v51; // [sp+208h] [bp-68h]@2
+  int v52; // [sp+20Ch] [bp-64h]@2
+  int v53; // [sp+210h] [bp-60h]@2
+  int v54; // [sp+214h] [bp-5Ch]@2
+  int Src; // [sp+218h] [bp-58h]@30
+  char v56; // [sp+21Ch] [bp-54h]@30
+  char v57; // [sp+21Dh] [bp-53h]@30
+  char v58; // [sp+21Eh] [bp-52h]@30
+  char v59; // [sp+21Fh] [bp-51h]@30
+  int v60; // [sp+220h] [bp-50h]@30
+  int v61; // [sp+224h] [bp-4Ch]@30
+  int v62; // [sp+228h] [bp-48h]@2
+  LOD::Directory pDir; // [sp+22Ch] [bp-44h]@2
+  std::string *v64; // [sp+24Ch] [bp-24h]@1
+  size_t Size; // [sp+250h] [bp-20h]@26
+  __int16 *v66; // [sp+254h] [bp-1Ch]@1
+  void *DstBuf; // [sp+258h] [bp-18h]@2
+  __int16 *v68; // [sp+25Ch] [bp-14h]@32
+  unsigned int v69; // [sp+260h] [bp-10h]@23
+  int v70; // [sp+264h] [bp-Ch]@22
+  std::string *v71; // [sp+268h] [bp-8h]@8
+  int a3; // [sp+26Fh] [bp-1h]@8
+
+  v66 = a2;
+  v64 = (std::string *)a1;
+  strcpy(byte_6BE3B0, pCurrentMapName);
+  result = _strcmpi(pCurrentMapName, "d05.blv");
+  if ( result )
+  {
+    DstBuf = operator new(0xF4240u);
+    pDir.Reset();
+    v52 = pParty->vPosition.x;
+    v51 = pParty->vPosition.z;
+    v62 = pParty->vPosition.y;
+    v53 = pParty->sRotationY;
+    v54 = pParty->sRotationX;
+    pParty->vPosition.x = pParty->vPrevPosition.x;
+    pParty->vPosition.z = pParty->vPrevPosition.z;
+    pParty->vPosition.y = pParty->vPrevPosition.y;
+    pParty->uFallStartY = pParty->vPrevPosition.y;
+    pParty->sRotationY = pParty->sPrevRotationY;
+    pParty->sRotationX = pParty->sPrevRotationX;
+    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+      pIndoor->uLastVisitDay = pParty->uTimePlayed;
+    else
+      pOutdoor->uLastVisitDay = pParty->uTimePlayed;
+    v3 = MakeScreenshot(150, 112);
+    strcpy((char *)&pDir, "image.pcx");
+    pRenderer->_49F5A2((int)v3, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize);
+    free(v3);
+    if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 11 )
+    {
+      pRenderer->DrawTextureIndexed(
+        8u,
+        8u,
+        (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
+      pRenderer->DrawTextureIndexed(
+        0x12u,
+        0x8Du,
+        (Texture *)(uTextureID_save_up != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_save_up] : 0));
+      v36 = pGlobalTXT_LocalizationStrings[190];
+      v4 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[190]);
+      pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v4 + 25, 219, 0, v36, 0, 0, 0);
+      v37 = (const char *)(&pSavegameHeader + uLoadGameUI_SelectedSlot);
+      v5 = pFontSmallnum->AlignText_Center(0xBAu,
+             (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot);
+      pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v5 + 25, 0x103u, 0, v37, 185, 0);
+      v36 = pGlobalTXT_LocalizationStrings[165];
+      v6 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[165]);
+      pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v6 + 25, 299, 0, v36, 0, 0, 0);
+      pRenderer->Present();
+    }
+    if ( pNew_LOD->Write(&pDir, DstBuf, 0) )
+    {
+      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 200);
+    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
+    }
+    else
+    {
+      v7 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp";
+    }
+    strcpy(Dest, pCurrentMapName);
+    v45 = pParty->uTimePlayed;
+    strcpy((char *)&pDir, "header.bin");
+    pDir.uDataSize = 100;
+    if ( pNew_LOD->Write(&pDir, &v43, 0) )
+    {
+      v39 = 201;
+      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 201);
+    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0);
+    }
+    strcpy((char *)&pDir, "party.bin");
+    pDir.uDataSize = 90680;
+    if ( pNew_LOD->Write(&pDir, &pParty, 0) )
+    {
+      v39 = 202;
+      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 202);
+    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0);
+    }
+    strcpy((char *)&pDir, "Timer.bin");
+    pDir.uDataSize = 40;
+    if ( pNew_LOD->Write(&pDir, &pEventTimer, 0) )
+    {
+      v39 = 203;
+      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 203);
+          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0);
+    }
+    strcpy((char *)&pDir, "overlay.bin");
+    pDir.uDataSize = 1008;
+    if ( pNew_LOD->Write(&pDir, &pOtherOverlayList, 0) )
+    {
+      v39 = 204;
+      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 204);
+          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0);
+    }
+    strcpy((char *)&pDir, "npcdata.bin");
+    pDir.uDataSize = 38076;
+    if ( pNew_LOD->Write(&pDir, pNPCStats->pNewNPCData, 0) )
+    {
+      v39 = 205;
+      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 205);
+          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0);
+    }
+    strcpy((char *)&pDir, "npcgroup.bin");
+    pDir.uDataSize = 102;
+    if ( pNew_LOD->Write(&pDir, pNPCStats->pGroups_copy, 0) )
+    {
+      v39 = 206;
+      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 206);
+          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0);
+    }
+    v70 = 1;
+    do
+    {
+      v69 = 1;
+      do
+      {
+        v39 = v69;
+        v38 = (const char *)v70;
+        sprintfex(Str, "data\\lloyd%d%d.pcx", v70, v69);
+        v8 = fopen(Str, "rb");
+        if ( v8 )
+        {
+          v39 = v69;
+          v38 = (const char *)v70;
+          sprintfex(Str, "lloyd%d%d.pcx", v70, v69);
+          fseek(v8, 0, 2);
+          pDir.uDataSize = ftell(v8);
+          rewind(v8);
+          fread(DstBuf, pDir.uDataSize, 1u, v8);
+          strcpy((char *)&pDir, Str);
+          fclose(v8);
+          remove(Str);
+          if ( pNew_LOD->Write(&pDir, DstBuf, 0) )
+          {
+            v39 = 207;
+            sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 207);
+          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0);
+            Size = 5080748;
+          }
+        }
+        ++v69;
+      }
+      while ( (signed int)v69 <= 5 );
+      ++v70;
+    }
+    while ( v70 <= 4 );
+    if ( !v66 )
+    {
+      sub_42FA22_mess_with_laying_item_list();
+      v9 = (int)malloc(0xF4240u);
+      v71 = (std::string *)v9;
+      Src = 91969;
+      v56 = 109;
+      v57 = 118;
+      v58 = 105;
+      v59 = 105;
+      v60 = 0;
+      v61 = 0;
+      memcpy((void *)v9, &Src, 0x10u);
+      if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+      {
+        v10 = DstBuf;
+        pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces;
+        pIndoor->dlv.uNumBModels = 0;
+        pIndoor->dlv.uNumDecorations = uNumLevelDecorations;
+        memcpy(DstBuf, &pIndoor->dlv, 0x28u);
+        v10 = (char *)v10 + 40;
+        memcpy(v10, pIndoor->_visible_outlines, 0x36Bu);
+        v11 = (char *)v10 + 875;
+        v70 = 0;
+        if ( (signed int)pIndoor->uNumFaces > 0 )
+        {
+          v68 = 0;
+          do
+          {
+            v38 = (char *)v68 + (unsigned int)pIndoor->pFaces + 44;
+            memcpy(v11, v38, 4u);
+            v68 += 48;
+            v11 = (char *)v11 + 4;
+            ++v70;
+          }
+          while ( v70 < (signed int)pIndoor->uNumFaces );
+        }
+        v70 = 0;
+        if ( (signed int)uNumLevelDecorations > 0 )
+        {
+          v68 = &pLevelDecorations[0].field_2;
+          do
+          {
+            memcpy(v11, v68, 2u);
+            v68 += 16;
+            v11 = (char *)v11 + 2;
+            ++v70;
+          }
+          while ( v70 < (signed int)uNumLevelDecorations );
+        }
+        memcpy(v11, &uNumActors, 4u);
+        v12 = (char *)v11 + 4;
+        memcpy(v12, pActors, 836 * uNumActors);
+        v13 = (char *)v12 + 836 * uNumActors;
+        memcpy(v13, &uNumLayingItems, 4u);
+        v13 = (char *)v13 + 4;
+        memcpy(v13, pLayingItems, 112 * uNumLayingItems);
+        v14 = (char *)v13 + 112 * uNumLayingItems;
+        memcpy(v14, &uNumChests, 4u);
+        v14 = (char *)v14 + 4;
+        memcpy(v14, pChests, 5324 * uNumChests);
+        v15 = (char *)v14 + 5324 * uNumChests;
+        memcpy(v15, pIndoor->pDoors, 0x3E80u);
+        v15 = (char *)v15 + 16000;
+        memcpy(v15, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size);
+        v16 = (char *)v15 + pIndoor->blv.uDoors_ddata_Size;
+        memcpy(v16, &stru_5E4C90, 0xC8u);
+        v17 = (int)((char *)v16 + 200);
+        memcpy((void *)v17, &pIndoor->uLastVisitDay, 0x38u);
+      }
+      else
+      {
+        v18 = 0;
+        pOutdoor->ddm.uNumFacesInBModels = 0;
+        if ( (signed int)pOutdoor->uNumBModels > 0 )
+        {
+          v19 = pOutdoor->uNumBModels;
+          v20 = (char *)&pOutdoor->pBModels->uNumFaces;
+          do
+          {
+            v18 += *(int *)v20;
+            v20 += 188;
+            --v19;
+            pOutdoor->ddm.uNumFacesInBModels = v18;
+          }
+          while ( v19 );
+        }
+        v21 = DstBuf;
+        pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels;
+        pOutdoor->ddm.uNumDecorations = uNumLevelDecorations;
+        memcpy(DstBuf, &pOutdoor->ddm, 0x28u);
+        v21 = (char *)v21 + 40;
+        memcpy(v21, pOutdoor->array_528, 0x3C8u);
+        v21 = (char *)v21 + 968;
+        memcpy(v21, pOutdoor->array_8F0, 0x3C8u);
+        v22 = (char *)v21 + 968;
+        v70 = 0;
+        if ( (signed int)pOutdoor->uNumBModels > 0 )
+        {
+          v23 = pOutdoor->pBModels;
+          v24 = 76;
+          do
+          {
+            v25 = *(int *)&v23->pModelName[v24] == 0;
+            v26 = *(int *)&v23->pModelName[v24] < 0;
+            v66 = 0;
+            if ( !(v26 | v25) )
+            {
+              v68 = 0;
+              do
+              {
+                v38 = (char *)v68 + *(int *)&v23->pModelName[v24 + 8] + 28;
+                memcpy(v22, v38, 4u);
+                v23 = pOutdoor->pBModels;
+                v68 += 154;
+                v22 = (char *)v22 + 4;
+                v66 = (__int16 *)((char *)v66 + 1);
+              }
+              while ( (signed int)v66 < *(int *)&pOutdoor->pBModels->pModelName[v24] );
+            }
+            ++v70;
+            v24 += 188;
+          }
+          while ( v70 < (signed int)pOutdoor->uNumBModels );
+        }
+        v27 = 0;
+        if ( (signed int)uNumLevelDecorations > 0 )
+        {
+          v66 = &pLevelDecorations[0].field_2;
+          do
+          {
+            memcpy(v22, v66, 2u);
+            v66 += 16;
+            v22 = (char *)v22 + 2;
+            ++v27;
+          }
+          while ( v27 < (signed int)uNumLevelDecorations );
+        }
+        memcpy(v22, &uNumActors, 4u);
+        v28 = (char *)v22 + 4;
+        memcpy(v28, pActors, 836 * uNumActors);
+        v29 = (char *)v28 + 836 * uNumActors;
+        memcpy(v29, &uNumLayingItems, 4u);
+        v29 = (char *)v29 + 4;
+        memcpy(v29, pLayingItems, 112 * uNumLayingItems);
+        v30 = (char *)v29 + 112 * uNumLayingItems;
+        memcpy(v30, &uNumChests, 4u);
+        v30 = (char *)v30 + 4;
+        memcpy(v30, pChests, 5324 * uNumChests);
+        v31 = (char *)v30 + 5324 * uNumChests;
+        memcpy(v31, &stru_5E4C90, 0xC8u);
+        v17 = (int)((char *)v31 + 200);
+        memcpy((void *)v17, &pOutdoor->uLastVisitDay, 0x38u);
+        v9 = (int)v71;
+      }
+      v32 = v17 + 56;
+      strcpy(Source, pCurrentMapName);
+      _splitpath(Source, &Drive, &Dir, &Filename, &Ext);
+      v48 = 100;
+      Size = v32 - (int)DstBuf;
+      v69 = 999984;
+      LOBYTE(v33) = zlib::MemZip((char *)v9 + 16, (unsigned int *)&v69, DstBuf, v32 - (int)DstBuf);
+      if ( v33 || (signed int)v69 > (signed int)Size )
+      {
+        memcpy((void *)(v9 + 16), DstBuf, Size);
+        v69 = Size;
+      }
+      v69 += 16;
+      memcpy((void *)(v9 + 8), &v69, 4u);
+      memcpy((void *)(v9 + 12), &Size, 4u);
+      sprintfex(Source, "%s%s", &Filename, &Ext);
+      strcpy((char *)&pDir, Source);
+      pDir.uDataSize = v69;
+      if ( pNew_LOD->Write(&pDir, (const void *)v9, 0) )
+      {
+        v39 = 208;
+        sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 208);
+          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0);
+      }
+      free((void *)v9);
+    }
+    free(DstBuf);
+    if ( v64 )
+    {
+      if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) )
+      {
+        v34 = GetLastError();
+        FormatMessageA(0x1000u, 0, v34, 0x400u, &Buffer, 0x80u, 0);
+        v39 = 300;
+        sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 300);
+          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0);
+      }
+    }
+    pParty->vPosition.x = v52;
+    pParty->vPosition.z = v51;
+    pParty->vPosition.y = v62;
+    pParty->uFallStartY = v62;
+    pParty->sRotationY = v53;
+    result = v54;
+    pParty->sRotationX = v54;
+  }
+  return result;
+}
+
+
+//----- (00460078) --------------------------------------------------------
+void __fastcall DoSavegame(unsigned int uSlot)
+{
+  unsigned int v1; // esi@1
+  int v2; // esi@2
+  RGBTexture *v3; // ebx@3
+  int bNotArena; // [sp+2Ch] [bp-8h]@1
+  unsigned int v6; // [sp+30h] [bp-4h]@1
+
+  v1 = uSlot;
+  v6 = uSlot;
+  bNotArena = _strcmpi(pCurrentMapName, "d05.blv");
+  if ( bNotArena )
+  {
+    LOD::Directory pDir; // [sp+Ch] [bp-28h]@2
+    SaveGame(0, 0);
+    v2 = 100 * v1;
+    strcpy(&pSavegameHeader->pLocationName[v2], pCurrentMapName);
+    *(int *)((char *)&pSavegameHeader->uWordTime + v2) = LODWORD(pParty->uTimePlayed);
+    *(int *)((char *)&pSavegameHeader->uWordTime + v2 + 4) = HIDWORD(pParty->uTimePlayed);
+    strcpy((char *)&pDir, "header.bin");
+    pDir.uDataSize = 100;
+    pNew_LOD->Write(&pDir, (char *)&pSavegameHeader + v2, 0);
+    sprintfex(pTmpBuf, "saves\\save%03d.mm7", v6);
+    pNew_LOD->CloseWriteFile();
+    CopyFileA("data\\new.lod", pTmpBuf, 0);
+  }
+  GUI_UpdateWindows();
+  pGUIWindow_CurrentMenu->Release();
+  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+  v3 = pSavegameThumbnails;
+  viewparams->bRedrawGameUI = 1;
+  do
+  {
+    v3->Release();
+    ++v3;
+  }
+  while ( (signed int)v3 < (signed int)&unk_6A0758 );
+  if ( bNotArena )
+    pNew_LOD->_4621A7();
+  else
+    ShowStatusBarString(pGlobalTXT_LocalizationStrings[583], 2u);// "No saving in the Arena"
+  pIcons_LOD->_4355F7();
+  pEventTimer->Resume();
+  ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2u);// "Game Saved!"
+  viewparams->bRedrawGameUI = 1;
+}
+// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+
+
+
+
+
+
+
+
+
+
+
 //----- (0045E297) --------------------------------------------------------
 void SavegameList::Initialize(unsigned int bHideEmptySlots)
 {
--- a/Texture.cpp	Mon Oct 15 18:45:11 2012 +0200
+++ b/Texture.cpp	Tue Oct 16 00:05:53 2012 +0200
@@ -1326,9 +1326,9 @@
                       do
                       {
                         ++v14;
-                        *v15 = LOWORD(pRenderer->uTargetRMask) & (v16 << (LOBYTE(pRenderer->uTargetGBits)
-                                                                       + LOBYTE(pRenderer->uTargetRBits)
-                                                                       + LOBYTE(pRenderer->uTargetBBits)
+                        *v15 = LOWORD(pRenderer->uTargetRMask) & (v16 << (pRenderer->uTargetGBits
+                                                                       + pRenderer->uTargetRBits
+                                                                       + pRenderer->uTargetBBits
                                                                        - 8));
                         ++v15;
                         ++v27;
@@ -1339,9 +1339,9 @@
                   else
                   {
                     ++v14;
-                    *v15 = LOWORD(pRenderer->uTargetRMask) & (BYTE3(mode) << (LOBYTE(pRenderer->uTargetGBits)
-                                                                           + LOBYTE(pRenderer->uTargetRBits)
-                                                                           + LOBYTE(pRenderer->uTargetBBits)
+                    *v15 = LOWORD(pRenderer->uTargetRMask) & (BYTE3(mode) << (pRenderer->uTargetGBits
+                                                                           + pRenderer->uTargetRBits
+                                                                           + pRenderer->uTargetBBits
                                                                            - 8));
                     ++v15;
                   }
@@ -1362,8 +1362,8 @@
                   {
                     do
                     {
-                      *v17 |= pRenderer->uTargetGMask & (unsigned __int16)(v18 << (LOBYTE(pRenderer->uTargetGBits)
-                                                                                + LOBYTE(pRenderer->uTargetBBits)
+                      *v17 |= pRenderer->uTargetGMask & (unsigned __int16)(v18 << (pRenderer->uTargetGBits
+                                                                                + pRenderer->uTargetBBits
                                                                                 - 8));
                       ++v14;
                       ++v17;
@@ -1374,8 +1374,8 @@
                 }
                 else
                 {
-                  *v17 |= pRenderer->uTargetGMask & (unsigned __int16)(BYTE3(mode) << (LOBYTE(pRenderer->uTargetGBits)
-                                                                                    + LOBYTE(pRenderer->uTargetBBits)
+                  *v17 |= pRenderer->uTargetGMask & (unsigned __int16)(BYTE3(mode) << (pRenderer->uTargetGBits
+                                                                                    + pRenderer->uTargetBBits
                                                                                     - 8));
                   ++v14;
                   ++v17;
@@ -1395,7 +1395,7 @@
                   {
                     do
                     {
-                      *v19 |= v20 >> (8 - LOBYTE(pRenderer->uTargetBBits));
+                      *v19 |= v20 >> (8 - pRenderer->uTargetBBits);
                       ++v14;
                       ++v19;
                       ++v27;
@@ -1405,7 +1405,7 @@
                 }
                 else
                 {
-                  *v19 |= BYTE3(mode) >> (8 - LOBYTE(pRenderer->uTargetBBits));
+                  *v19 |= BYTE3(mode) >> (8 - pRenderer->uTargetBBits);
                   ++v14;
                   ++v19;
                 }
@@ -1788,13 +1788,13 @@
 //----- (0040D73D) --------------------------------------------------------
 RGBTexture::RGBTexture()
 {
-  this->pName[0] = 0;
-  this->pPixels = 0;
-  this->uNumPixels = 0;
-  this->uHeight = 0;
-  this->uWidth = 0;
-  this->field_1A = 0;
-  this->field_18 = 0;
-  this->field_20 = 0;
-  this->field_22 = 0;
+  pName[0] = 0;
+  pPixels = 0;
+  uNumPixels = 0;
+  uHeight = 0;
+  uWidth = 0;
+  field_1A = 0;
+  field_18 = 0;
+  field_20 = 0;
+  field_22 = 0;
 }
\ No newline at end of file
--- a/Time.h	Mon Oct 15 18:45:11 2012 +0200
+++ b/Time.h	Tue Oct 16 00:05:53 2012 +0200
@@ -9,7 +9,16 @@
 
   Timer():
     bReady(false), bPaused(false)
-  {}
+  {
+    bTackGameTime = 0;
+    uStartTime = 0;
+    uStopTime = 0;
+    uGameTimeStart = 0;
+    field_18 = 0;
+    uTimeElapsed = 0;
+    dt_in_some_format = 0;
+    uTotalGameTimeElapsed = 0;
+  }
 
   void Initialize();
   unsigned __int64 Time();
--- a/mm7_1.cpp	Mon Oct 15 18:45:11 2012 +0200
+++ b/mm7_1.cpp	Tue Oct 16 00:05:53 2012 +0200
@@ -64,10 +64,11 @@
 
 
 
-void __cdecl crt_deconstruct_ptr_6A0118()
+void __cdecl FreeSavegameThumbnails()
 {
   for (int i = 0; i < 40; ++i)
-    pAllocator->FreeChunk(pSavegameThumbnails[i].pPixels);
+    //pAllocator->FreeChunk(pSavegameThumbnails[i].pPixels);
+    pSavegameThumbnails[i].Release();
 }
 
 
@@ -5855,9 +5856,9 @@
         sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v23].pUnidentifiedName);
         ShowStatusBarString(pTmpBuf2, 2u);
         if ( v22->uItemID == 506 )
-          _449B7E_toggle_bit((char *)pParty->_award_bits, 184, 1u);
+          _449B7E_toggle_bit(pParty->_award_bits, 184, 1u);
         if ( v22->uItemID == 455 )
-          _449B7E_toggle_bit((char *)pParty->_award_bits, 185, 1u);
+          _449B7E_toggle_bit(pParty->_award_bits, 185, 1u);
         if ( !pParty->AddItem(v22) )
           pParty->SetHoldingItem(v22);
       }
--- a/mm7_2.cpp	Mon Oct 15 18:45:11 2012 +0200
+++ b/mm7_2.cpp	Tue Oct 16 00:05:53 2012 +0200
@@ -11446,760 +11446,6 @@
 
 
 
-
-//----- (0045EE8A) --------------------------------------------------------
-void __fastcall LoadGame(unsigned int uSlot)
-{
-  unsigned int v1; // ebx@1
-  char v2; // zf@1
-  signed int v3; // esi@3
-  signed int v4; // esi@8
-  char *v5; // eax@9
-  unsigned int v6; // eax@12
-  unsigned int v7; // esi@13
-  char *v8; // ecx@14
-  FILE *v9; // eax@22
-  FILE *v10; // eax@26
-  FILE *v11; // eax@29
-  FILE *v12; // eax@32
-  FILE *v13; // eax@35
-  FILE *v14; // eax@38
-  unsigned int v15; // edi@41
-  Player *v16; // esi@41
-  int *v17; // esi@46
-  int v18; // edi@46
-  int v19; // ebx@46
-  int v20; // ecx@49
-  int v21; // eax@51
-  int v22; // ecx@56
-  bool v23; // edx@56
-  AudioPlayer *v24; // ebx@60
-  bool v25; // esi@62
-  bool v26; // eax@62
-  signed int v27; // esi@66
-  RGBTexture *v28; // edi@67
-  std::string v29; // [sp-18h] [bp-108h]@25
-  int v30; // [sp-Ch] [bp-FCh]@65
-  int v31; // [sp-8h] [bp-F8h]@4
-  signed int v32; // [sp-4h] [bp-F4h]@4
-  char DstBuf; // [sp+Ch] [bp-E4h]@23
-  char pContainer; // [sp+20h] [bp-D0h]@62
-  char Str[123]; // [sp+70h] [bp-80h]@25
-  char a3[5]; // [sp+EBh] [bp-5h]@2
-
-  v1 = uSlot;
-  v2 = pSavegameUsedSlots[uSlot] == 0;
-  dword_5B65C8 = 0;
-  if ( v2 )
-  {
-    v24 = pAudioPlayer;
-    pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
-  }
-  else
-  {
-    *(int *)&a3[1] = 1;
-    do
-    {
-      v3 = 1;
-      do
-      {
-        v32 = v3;
-        v31 = *(int *)&a3[1];
-        sprintfex(pTmpBuf, "data\\lloyd%d%d.pcx", *(int *)&a3[1], v3);
-        remove(pTmpBuf);
-        ++v3;
-      }
-      while ( v3 < 6 );
-      ++*(int *)&a3[1];
-    }
-    while ( *(int *)&a3[1] < 5 );
-    *(int *)&a3[1] = (int)(char *)&pParty + 2508;
-    do
-    {
-      if ( byte_4ED498 )
-      {
-        v4 = 0;
-        if ( (signed int)pSoundList->uNumSounds <= 0 )
-        {
-LABEL_12:
-          v6 = 0;
-        }
-        else
-        {
-          v5 = (char *)&pSoundList->pSounds->uSoundID;
-          while ( *(int *)v5 != 2 * ((unsigned __int8)byte_4ED498 + 50 * *(int *)(*(int *)&a3[1] + 6432))
-                                 + 4998 )
-          {
-            ++v4;
-            v5 += 120;
-            if ( v4 >= (signed int)pSoundList->uNumSounds )
-              goto LABEL_12;
-          }
-          v6 = v4;
-        }
-        pSoundList->_4A9DCD(v6, 1);
-        v7 = 0;
-        if ( (signed int)pSoundList->uNumSounds <= 0 )
-        {
-LABEL_17:
-          v7 = 0;
-        }
-        else
-        {
-          v8 = (char *)&pSoundList->pSounds->uSoundID;
-          while ( *(int *)v8 != 2 * ((unsigned __int8)byte_4ED498 + 50 * *(int *)(*(int *)&a3[1] + 6432))
-                                 + 4999 )
-          {
-            ++v7;
-            v8 += 120;
-            if ( (signed int)v7 >= (signed int)pSoundList->uNumSounds )
-              goto LABEL_17;
-          }
-        }
-        pSoundList->_4A9DCD(v7, 1);
-      }
-      *(int *)&a3[1] += 6972;
-    }
-    while ( *(int *)&a3[1] < (signed int)pParty->pHirelings );
-    sprintfex(pTmpBuf, "saves\\%s", pSavegameList->pSavesNames[v1]);
-    pNew_LOD->CloseWriteFile();
-    if ( !CopyFileA(pTmpBuf, "data\\new.lod", 0) )
-      GetLastError();
-    pNew_LOD->LoadFile("data\\new.lod", 0);
-    v9 = pNew_LOD->FindContainer("header.bin", 1);
-    if ( v9 )
-    {
-      fread(&DstBuf, 0x64u, 1u, v9);
-    }
-    else
-    {
-      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 100);
-      MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:549", 0);
-    }
-    v10 = pNew_LOD->FindContainer("party.bin", 1);
-    if ( v10 )
-    {
-      fread(&pParty, 0x16238u, 1u, v10);
-    }
-    else
-    {
-      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 101);
-      MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:559", 0);
-    }
-    v11 = pNew_LOD->FindContainer("Timer.bin", 1);
-    if ( v11 )
-    {
-      fread(&pEventTimer, 0x28u, 1u, v11);
-    }
-    else
-    {
-      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 102);
-      MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:569", 0);
-    }
-    v12 = pNew_LOD->FindContainer("overlay.bin", 1);
-    if ( v12 )
-    {
-      fread(&pOtherOverlayList, 0x3F0u, 1u, v12);
-    }
-    else
-    {
-      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 103);
-      MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:579", 0);
-    }
-    v13 = pNew_LOD->FindContainer("npcdata.bin", 0);
-    if ( v13 )
-    {
-      fread(pNPCStats->pNewNPCData, 0x94BCu, 1u, v13);
-      pNPCStats->_476C60();
-    }
-    else
-    {
-      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 104);
-      MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:590", 0);
-    }
-    v14 = pNew_LOD->FindContainer("npcgroup.bin", 0);
-    if ( v14 )
-    {
-      fread(pNPCStats->pGroups_copy, 0x66u, 1u, v14);
-    }
-    else
-    {
-      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 105);
-      MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:600", 0);
-    }
-    v15 = 0;
-    v16 = pParty->pPlayers;
-    while ( 1 )
-    {
-      ++v15;
-      if ( v16->CanAct() )
-        break;
-      ++v16;
-      if ( (signed int)v16 >= (signed int)pParty->pHirelings )
-        goto LABEL_46;
-    }
-    uActiveCharacter = v15;
-LABEL_46:
-    v17 = (int *)&pParty->pPlayers[0].uQuickSpell;
-    v18 = 9;
-    v19 = 0;
-    do
-    {
-      if ( *(char *)v17 )
-        stru_AA1058[v19]._494836(*(char *)v17, v18 - 8);
-      *(int *)&a3[1] = 0;
-      v20 = (int)((char *)v17 - 263);
-      while ( 1 )
-      {
-        if ( *(int *)v20 )
-        {
-          v21 = *(int *)((char *)&v17[9 * *(int *)v20 - 1559] - 3);
-          if ( pItemsTable->pItems[v21].uEquipType == 12 )
-            break;
-        }
-        ++*(int *)&a3[1];
-        v20 += 4;
-        if ( *(int *)&a3[1] > 1 )
-          goto LABEL_55;
-      }
-      v32 = v18;
-      v31 = *((int *)&pSpellDatas[66].field_8 + v21);
-      stru_A750F8[v19]._494836(v31, v18);
-LABEL_55:
-      v17 += 1743;
-      ++v18;
-      ++v19;
-    }
-    while ( v18 - 9 < 4 );
-    pGUIWindow_CurrentMenu->Release();
-    uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
-    v22 = 1;
-    viewparams->bRedrawGameUI = 1;
-    LOBYTE(v23) = 1;
-    if ( pParty->uAlignment )
-    {
-      if ( pParty->uAlignment == 2 )
-        v22 = 2;
-    }
-    else
-    {
-      v22 = 0;
-    }
-    SetUserInterface(v22, v23);
-    pEventTimer->Resume();
-    pEventTimer->StopGameTime();
-    v24 = pAudioPlayer;
-  }
-  v25 = pGames_LOD->DoesContainerExist((const char *)&pContainer);
-  v32 = (signed int)&pContainer;
-  sprintfex(pTmpBuf, "levels\\%s", &pContainer);
-  v26 = _access(pTmpBuf, 4) != -1;
-  if ( !v25 && !v26 )
-  {
-    v32 = (signed int)&pContainer;
-    sprintfex(pTmpBuf, "Unable to find: %s!", &pContainer);
-    Abortf(pTmpBuf, v30, v31, v32);
-  }
-  strcpy(pCurrentMapName, &pContainer);
-  dword_6BE364_game_settings_1 |= 0x2001;
-  v27 = 0;
-  if ( (signed int)uNumSavegameFiles > 0 )
-  {
-    v28 = pSavegameThumbnails;
-    do
-    {
-      v28->Release();
-      ++v27;
-      ++v28;
-    }
-    while ( v27 < (signed int)uNumSavegameFiles );
-  }
-  pIcons_LOD->_4114F2();
-  v32 = (signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0);
-  v24->SetMusicVolume(v32);
-  v32 = (signed __int64)(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0);
-  v24->SetMasterVolume(v32);
-  if ( uTurnSpeed )
-    pParty->sRotationY = uTurnSpeed * pParty->sRotationY / (signed int)uTurnSpeed;
-  MM7Initialization();
-  bFlashQuestBook = 0;
-  viewparams->bRedrawGameUI = 1;
-}
-
-
-//----- (0045F469) --------------------------------------------------------
-int __fastcall SaveGame(int a1, __int16 *a2)
-{
-  int result; // eax@1
-  void *v3; // edi@5
-  int v4; // eax@6
-  int v5; // eax@6
-  int v6; // eax@6
-  const char *v7; // edi@8
-  FILE *v8; // edi@24
-  int v9; // edi@30
-  void *v10; // esi@31
-  void *v11; // esi@31
-  void *v12; // esi@37
-  void *v13; // esi@37
-  void *v14; // esi@37
-  void *v15; // esi@37
-  void *v16; // esi@37
-  int v17; // esi@37
-  unsigned int v18; // ecx@38
-  unsigned int v19; // esi@39
-  char *v20; // edx@39
-  void *v21; // esi@41
-  void *v22; // esi@41
-  BSPModel *v23; // eax@42
-  signed int v24; // edi@42
-  unsigned __int8 v25; // zf@43
-  unsigned __int8 v26; // sf@43
-  signed int v27; // edi@47
-  void *v28; // esi@50
-  void *v29; // esi@50
-  void *v30; // esi@50
-  void *v31; // esi@50
-  int v32; // esi@51
-  int v33; // eax@51
-  DWORD v34; // eax@59
-  std::string v35; // [sp-18h] [bp-288h]@8
-  const char *v36; // [sp-10h] [bp-280h]@6
-  const char *v37; // [sp-Ch] [bp-27Ch]@6
-  const char *v38; // [sp-8h] [bp-278h]@8
-  int v39; // [sp-4h] [bp-274h]@8
-  CHAR Buffer; // [sp+Ch] [bp-264h]@59
-  char Dir; // [sp+8Ch] [bp-1E4h]@51
-  char Drive; // [sp+ACh] [bp-1C4h]@51
-  int v43; // [sp+CCh] [bp-1A4h]@10
-  char Dest[20]; // [sp+E0h] [bp-190h]@10
-  unsigned __int64 v45; // [sp+F4h] [bp-17Ch]@10
-  char Filename; // [sp+130h] [bp-140h]@51
-  char Ext; // [sp+150h] [bp-120h]@51
-  char v48; // [sp+151h] [bp-11Fh]@51
-  char Source[32]; // [sp+170h] [bp-100h]@51
-  char Str[120]; // [sp+190h] [bp-E0h]@8
-  int v51; // [sp+208h] [bp-68h]@2
-  int v52; // [sp+20Ch] [bp-64h]@2
-  int v53; // [sp+210h] [bp-60h]@2
-  int v54; // [sp+214h] [bp-5Ch]@2
-  int Src; // [sp+218h] [bp-58h]@30
-  char v56; // [sp+21Ch] [bp-54h]@30
-  char v57; // [sp+21Dh] [bp-53h]@30
-  char v58; // [sp+21Eh] [bp-52h]@30
-  char v59; // [sp+21Fh] [bp-51h]@30
-  int v60; // [sp+220h] [bp-50h]@30
-  int v61; // [sp+224h] [bp-4Ch]@30
-  int v62; // [sp+228h] [bp-48h]@2
-  LOD::Directory pDir; // [sp+22Ch] [bp-44h]@2
-  std::string *v64; // [sp+24Ch] [bp-24h]@1
-  size_t Size; // [sp+250h] [bp-20h]@26
-  __int16 *v66; // [sp+254h] [bp-1Ch]@1
-  void *DstBuf; // [sp+258h] [bp-18h]@2
-  __int16 *v68; // [sp+25Ch] [bp-14h]@32
-  unsigned int v69; // [sp+260h] [bp-10h]@23
-  int v70; // [sp+264h] [bp-Ch]@22
-  std::string *v71; // [sp+268h] [bp-8h]@8
-  int a3; // [sp+26Fh] [bp-1h]@8
-
-  v66 = a2;
-  v64 = (std::string *)a1;
-  strcpy(byte_6BE3B0, pCurrentMapName);
-  result = _strcmpi(pCurrentMapName, "d05.blv");
-  if ( result )
-  {
-    DstBuf = operator new(0xF4240u);
-    pDir.Reset();
-    v52 = pParty->vPosition.x;
-    v51 = pParty->vPosition.z;
-    v62 = pParty->vPosition.y;
-    v53 = pParty->sRotationY;
-    v54 = pParty->sRotationX;
-    pParty->vPosition.x = pParty->vPrevPosition.x;
-    pParty->vPosition.z = pParty->vPrevPosition.z;
-    pParty->vPosition.y = pParty->vPrevPosition.y;
-    pParty->uFallStartY = pParty->vPrevPosition.y;
-    pParty->sRotationY = pParty->sPrevRotationY;
-    pParty->sRotationX = pParty->sPrevRotationX;
-    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-      pIndoor->uLastVisitDay = pParty->uTimePlayed;
-    else
-      pOutdoor->uLastVisitDay = pParty->uTimePlayed;
-    v3 = MakeScreenshot(150, 112);
-    strcpy((char *)&pDir, "image.pcx");
-    pRenderer->_49F5A2((int)v3, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize);
-    free(v3);
-    if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 11 )
-    {
-      pRenderer->DrawTextureIndexed(
-        8u,
-        8u,
-        (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
-      pRenderer->DrawTextureIndexed(
-        0x12u,
-        0x8Du,
-        (Texture *)(uTextureID_save_up != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_save_up] : 0));
-      v36 = pGlobalTXT_LocalizationStrings[190];
-      v4 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[190]);
-      pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v4 + 25, 219, 0, v36, 0, 0, 0);
-      v37 = (const char *)(&pSavegameHeader + uLoadGameUI_SelectedSlot);
-      v5 = pFontSmallnum->AlignText_Center(0xBAu,
-             (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot);
-      pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v5 + 25, 0x103u, 0, v37, 185, 0);
-      v36 = pGlobalTXT_LocalizationStrings[165];
-      v6 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[165]);
-      pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v6 + 25, 299, 0, v36, 0, 0, 0);
-      pRenderer->Present();
-    }
-    if ( pNew_LOD->Write(&pDir, DstBuf, 0) )
-    {
-      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 200);
-    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
-    }
-    else
-    {
-      v7 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp";
-    }
-    strcpy(Dest, pCurrentMapName);
-    v45 = pParty->uTimePlayed;
-    strcpy((char *)&pDir, "header.bin");
-    pDir.uDataSize = 100;
-    if ( pNew_LOD->Write(&pDir, &v43, 0) )
-    {
-      v39 = 201;
-      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 201);
-    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0);
-    }
-    strcpy((char *)&pDir, "party.bin");
-    pDir.uDataSize = 90680;
-    if ( pNew_LOD->Write(&pDir, &pParty, 0) )
-    {
-      v39 = 202;
-      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 202);
-    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0);
-    }
-    strcpy((char *)&pDir, "Timer.bin");
-    pDir.uDataSize = 40;
-    if ( pNew_LOD->Write(&pDir, &pEventTimer, 0) )
-    {
-      v39 = 203;
-      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 203);
-          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0);
-    }
-    strcpy((char *)&pDir, "overlay.bin");
-    pDir.uDataSize = 1008;
-    if ( pNew_LOD->Write(&pDir, &pOtherOverlayList, 0) )
-    {
-      v39 = 204;
-      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 204);
-          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0);
-    }
-    strcpy((char *)&pDir, "npcdata.bin");
-    pDir.uDataSize = 38076;
-    if ( pNew_LOD->Write(&pDir, pNPCStats->pNewNPCData, 0) )
-    {
-      v39 = 205;
-      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 205);
-          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0);
-    }
-    strcpy((char *)&pDir, "npcgroup.bin");
-    pDir.uDataSize = 102;
-    if ( pNew_LOD->Write(&pDir, pNPCStats->pGroups_copy, 0) )
-    {
-      v39 = 206;
-      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 206);
-          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0);
-    }
-    v70 = 1;
-    do
-    {
-      v69 = 1;
-      do
-      {
-        v39 = v69;
-        v38 = (const char *)v70;
-        sprintfex(Str, "data\\lloyd%d%d.pcx", v70, v69);
-        v8 = fopen(Str, "rb");
-        if ( v8 )
-        {
-          v39 = v69;
-          v38 = (const char *)v70;
-          sprintfex(Str, "lloyd%d%d.pcx", v70, v69);
-          fseek(v8, 0, 2);
-          pDir.uDataSize = ftell(v8);
-          rewind(v8);
-          fread(DstBuf, pDir.uDataSize, 1u, v8);
-          strcpy((char *)&pDir, Str);
-          fclose(v8);
-          remove(Str);
-          if ( pNew_LOD->Write(&pDir, DstBuf, 0) )
-          {
-            v39 = 207;
-            sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 207);
-          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0);
-            Size = 5080748;
-          }
-        }
-        ++v69;
-      }
-      while ( (signed int)v69 <= 5 );
-      ++v70;
-    }
-    while ( v70 <= 4 );
-    if ( !v66 )
-    {
-      sub_42FA22_mess_with_laying_item_list();
-      v9 = (int)malloc(0xF4240u);
-      v71 = (std::string *)v9;
-      Src = 91969;
-      v56 = 109;
-      v57 = 118;
-      v58 = 105;
-      v59 = 105;
-      v60 = 0;
-      v61 = 0;
-      memcpy((void *)v9, &Src, 0x10u);
-      if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-      {
-        v10 = DstBuf;
-        pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces;
-        pIndoor->dlv.uNumBModels = 0;
-        pIndoor->dlv.uNumDecorations = uNumLevelDecorations;
-        memcpy(DstBuf, &pIndoor->dlv, 0x28u);
-        v10 = (char *)v10 + 40;
-        memcpy(v10, pIndoor->_visible_outlines, 0x36Bu);
-        v11 = (char *)v10 + 875;
-        v70 = 0;
-        if ( (signed int)pIndoor->uNumFaces > 0 )
-        {
-          v68 = 0;
-          do
-          {
-            v38 = (char *)v68 + (unsigned int)pIndoor->pFaces + 44;
-            memcpy(v11, v38, 4u);
-            v68 += 48;
-            v11 = (char *)v11 + 4;
-            ++v70;
-          }
-          while ( v70 < (signed int)pIndoor->uNumFaces );
-        }
-        v70 = 0;
-        if ( (signed int)uNumLevelDecorations > 0 )
-        {
-          v68 = &pLevelDecorations[0].field_2;
-          do
-          {
-            memcpy(v11, v68, 2u);
-            v68 += 16;
-            v11 = (char *)v11 + 2;
-            ++v70;
-          }
-          while ( v70 < (signed int)uNumLevelDecorations );
-        }
-        memcpy(v11, &uNumActors, 4u);
-        v12 = (char *)v11 + 4;
-        memcpy(v12, pActors, 836 * uNumActors);
-        v13 = (char *)v12 + 836 * uNumActors;
-        memcpy(v13, &uNumLayingItems, 4u);
-        v13 = (char *)v13 + 4;
-        memcpy(v13, pLayingItems, 112 * uNumLayingItems);
-        v14 = (char *)v13 + 112 * uNumLayingItems;
-        memcpy(v14, &uNumChests, 4u);
-        v14 = (char *)v14 + 4;
-        memcpy(v14, pChests, 5324 * uNumChests);
-        v15 = (char *)v14 + 5324 * uNumChests;
-        memcpy(v15, pIndoor->pDoors, 0x3E80u);
-        v15 = (char *)v15 + 16000;
-        memcpy(v15, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size);
-        v16 = (char *)v15 + pIndoor->blv.uDoors_ddata_Size;
-        memcpy(v16, &stru_5E4C90, 0xC8u);
-        v17 = (int)((char *)v16 + 200);
-        memcpy((void *)v17, &pIndoor->uLastVisitDay, 0x38u);
-      }
-      else
-      {
-        v18 = 0;
-        pOutdoor->ddm.uNumFacesInBModels = 0;
-        if ( (signed int)pOutdoor->uNumBModels > 0 )
-        {
-          v19 = pOutdoor->uNumBModels;
-          v20 = (char *)&pOutdoor->pBModels->uNumFaces;
-          do
-          {
-            v18 += *(int *)v20;
-            v20 += 188;
-            --v19;
-            pOutdoor->ddm.uNumFacesInBModels = v18;
-          }
-          while ( v19 );
-        }
-        v21 = DstBuf;
-        pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels;
-        pOutdoor->ddm.uNumDecorations = uNumLevelDecorations;
-        memcpy(DstBuf, &pOutdoor->ddm, 0x28u);
-        v21 = (char *)v21 + 40;
-        memcpy(v21, pOutdoor->array_528, 0x3C8u);
-        v21 = (char *)v21 + 968;
-        memcpy(v21, pOutdoor->array_8F0, 0x3C8u);
-        v22 = (char *)v21 + 968;
-        v70 = 0;
-        if ( (signed int)pOutdoor->uNumBModels > 0 )
-        {
-          v23 = pOutdoor->pBModels;
-          v24 = 76;
-          do
-          {
-            v25 = *(int *)&v23->pModelName[v24] == 0;
-            v26 = *(int *)&v23->pModelName[v24] < 0;
-            v66 = 0;
-            if ( !(v26 | v25) )
-            {
-              v68 = 0;
-              do
-              {
-                v38 = (char *)v68 + *(int *)&v23->pModelName[v24 + 8] + 28;
-                memcpy(v22, v38, 4u);
-                v23 = pOutdoor->pBModels;
-                v68 += 154;
-                v22 = (char *)v22 + 4;
-                v66 = (__int16 *)((char *)v66 + 1);
-              }
-              while ( (signed int)v66 < *(int *)&pOutdoor->pBModels->pModelName[v24] );
-            }
-            ++v70;
-            v24 += 188;
-          }
-          while ( v70 < (signed int)pOutdoor->uNumBModels );
-        }
-        v27 = 0;
-        if ( (signed int)uNumLevelDecorations > 0 )
-        {
-          v66 = &pLevelDecorations[0].field_2;
-          do
-          {
-            memcpy(v22, v66, 2u);
-            v66 += 16;
-            v22 = (char *)v22 + 2;
-            ++v27;
-          }
-          while ( v27 < (signed int)uNumLevelDecorations );
-        }
-        memcpy(v22, &uNumActors, 4u);
-        v28 = (char *)v22 + 4;
-        memcpy(v28, pActors, 836 * uNumActors);
-        v29 = (char *)v28 + 836 * uNumActors;
-        memcpy(v29, &uNumLayingItems, 4u);
-        v29 = (char *)v29 + 4;
-        memcpy(v29, pLayingItems, 112 * uNumLayingItems);
-        v30 = (char *)v29 + 112 * uNumLayingItems;
-        memcpy(v30, &uNumChests, 4u);
-        v30 = (char *)v30 + 4;
-        memcpy(v30, pChests, 5324 * uNumChests);
-        v31 = (char *)v30 + 5324 * uNumChests;
-        memcpy(v31, &stru_5E4C90, 0xC8u);
-        v17 = (int)((char *)v31 + 200);
-        memcpy((void *)v17, &pOutdoor->uLastVisitDay, 0x38u);
-        v9 = (int)v71;
-      }
-      v32 = v17 + 56;
-      strcpy(Source, pCurrentMapName);
-      _splitpath(Source, &Drive, &Dir, &Filename, &Ext);
-      v48 = 100;
-      Size = v32 - (int)DstBuf;
-      v69 = 999984;
-      LOBYTE(v33) = zlib::MemZip((char *)v9 + 16, (unsigned int *)&v69, DstBuf, v32 - (int)DstBuf);
-      if ( v33 || (signed int)v69 > (signed int)Size )
-      {
-        memcpy((void *)(v9 + 16), DstBuf, Size);
-        v69 = Size;
-      }
-      v69 += 16;
-      memcpy((void *)(v9 + 8), &v69, 4u);
-      memcpy((void *)(v9 + 12), &Size, 4u);
-      sprintfex(Source, "%s%s", &Filename, &Ext);
-      strcpy((char *)&pDir, Source);
-      pDir.uDataSize = v69;
-      if ( pNew_LOD->Write(&pDir, (const void *)v9, 0) )
-      {
-        v39 = 208;
-        sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 208);
-          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0);
-      }
-      free((void *)v9);
-    }
-    free(DstBuf);
-    if ( v64 )
-    {
-      if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) )
-      {
-        v34 = GetLastError();
-        FormatMessageA(0x1000u, 0, v34, 0x400u, &Buffer, 0x80u, 0);
-        v39 = 300;
-        sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 300);
-          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0);
-      }
-    }
-    pParty->vPosition.x = v52;
-    pParty->vPosition.z = v51;
-    pParty->vPosition.y = v62;
-    pParty->uFallStartY = v62;
-    pParty->sRotationY = v53;
-    result = v54;
-    pParty->sRotationX = v54;
-  }
-  return result;
-}
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
-
-//----- (00460078) --------------------------------------------------------
-void __fastcall DoSavegame(unsigned int uSlot)
-{
-  unsigned int v1; // esi@1
-  int v2; // esi@2
-  RGBTexture *v3; // ebx@3
-  int bNotArena; // [sp+2Ch] [bp-8h]@1
-  unsigned int v6; // [sp+30h] [bp-4h]@1
-
-  v1 = uSlot;
-  v6 = uSlot;
-  bNotArena = _strcmpi(pCurrentMapName, "d05.blv");
-  if ( bNotArena )
-  {
-    LOD::Directory pDir; // [sp+Ch] [bp-28h]@2
-    SaveGame(0, 0);
-    v2 = 100 * v1;
-    strcpy(&pSavegameHeader->pLocationName[v2], pCurrentMapName);
-    *(int *)((char *)&pSavegameHeader->uWordTime + v2) = LODWORD(pParty->uTimePlayed);
-    *(int *)((char *)&pSavegameHeader->uWordTime + v2 + 4) = HIDWORD(pParty->uTimePlayed);
-    strcpy((char *)&pDir, "header.bin");
-    pDir.uDataSize = 100;
-    pNew_LOD->Write(&pDir, (char *)&pSavegameHeader + v2, 0);
-    sprintfex(pTmpBuf, "saves\\save%03d.mm7", v6);
-    pNew_LOD->CloseWriteFile();
-    CopyFileA("data\\new.lod", pTmpBuf, 0);
-  }
-  GUI_UpdateWindows();
-  pGUIWindow_CurrentMenu->Release();
-  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
-  v3 = pSavegameThumbnails;
-  viewparams->bRedrawGameUI = 1;
-  do
-  {
-    v3->Release();
-    ++v3;
-  }
-  while ( (signed int)v3 < (signed int)&unk_6A0758 );
-  if ( bNotArena )
-    pNew_LOD->_4621A7();
-  else
-    ShowStatusBarString(pGlobalTXT_LocalizationStrings[583], 2u);// "No saving in the Arena"
-  pIcons_LOD->_4355F7();
-  pEventTimer->Resume();
-  ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2u);// "Game Saved!"
-  viewparams->bRedrawGameUI = 1;
-}
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
-
 //----- (004601B7) --------------------------------------------------------
 void GameUI_MainMenu_DoDrawLoad(int a1)
 {
@@ -13305,7 +12551,7 @@
   stru_506F20.Load("title.pcx", 0);
   SetCurrentMenuID(MENU_MAIN);
   SetForegroundWindow(hWnd);
-  SendMessageA(hWnd, WM_ACTIVATEAPP, 1, 0);
+  SendMessageW(hWnd, WM_ACTIVATEAPP, 1, 0);
   while (GetCurrentMenuID() == MENU_MAIN ||
          GetCurrentMenuID() == MENU_SAVELOAD)
   {
@@ -13355,7 +12601,6 @@
         if (GetCurrentMenuID() == MENU_LOAD)
         {
           pIcons_LOD->_4114F2();
-          crt_deconstruct_ptr_6A0118();
           pGUIWindow_CurrentMenu->Release();
           pGUIWindow_CurrentMenu = 0;
           uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
@@ -15598,7 +14843,6 @@
   viewparams->uSomeZ = viewparams->uScreenZ;
   viewparams->uSomeW = viewparams->uScreenW;
 
-  pViewport = new Viewport;
   pViewport->SetScreen(viewparams->uScreenX, viewparams->uScreenY, viewparams->uScreenZ, viewparams->uScreenW);
   if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
     pOutdoorCamera->_485F64();
@@ -17000,9 +16244,9 @@
         sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], v24);
         ShowStatusBarString(pTmpBuf2, 2u);
         if ( v19->uItemID == 506 )
-          _449B7E_toggle_bit((char *)pParty->_award_bits, 184, 1u);
+          _449B7E_toggle_bit(pParty->_award_bits, 184, 1u);
         if ( v19->uItemID == 455 )
-          _449B7E_toggle_bit((char *)pParty->_award_bits, 185, 1u);
+          _449B7E_toggle_bit(pParty->_award_bits, 185, 1u);
         if ( !pParty->AddItem(v19) )
           pParty->SetHoldingItem(v19);
         v21 = v26;
--- a/mm7_3.cpp	Mon Oct 15 18:45:11 2012 +0200
+++ b/mm7_3.cpp	Tue Oct 16 00:05:53 2012 +0200
@@ -6303,27 +6303,12 @@
 //----- (00476C60) --------------------------------------------------------
 void NPCStats::_476C60()
 {
-  signed int v1; // esi@1
-  NPCData *v2; // edx@2
-  char **v3; // eax@2
-
-  v1 = 1;
-  if ( (signed int)this->uNumNewNPCs > 1 )
-  {
-    v2 = &this->pNewNPCData[1];
-    v3 = this->pNPCNames2;
-    do
-    {
-      ++v1;
-      v2->pName = *v3;
-      ++v3;
-      ++v2;
-    }
-    while ( v1 < (signed int)this->uNumNewNPCs );
-  }
-  if ( pParty->pHirelings[0].pName )
+  for (uint i = 1; i < uNumNewNPCs; ++i)
+    pNewNPCData[i].pName = pNPCNames2[i - 1];
+
+  if (pParty->pHirelings[0].pName)
     pParty->pHirelings[0].pName = pParty->pHireling1Name;
-  if ( pParty->pHirelings[1].pName )
+  if (pParty->pHirelings[1].pName)
     pParty->pHirelings[1].pName = pParty->pHireling2Name;
 }
 
@@ -20508,19 +20493,19 @@
 }
 
 //----- (00449B7E) --------------------------------------------------------
-char *__fastcall _449B7E_toggle_bit(char *pArray, __int16 a2, unsigned __int16 bToggle)
+unsigned char *_449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle)
 {
   signed int v3; // esi@1
-  char *result; // eax@1
+  unsigned char *result; // eax@1
   unsigned int v5; // edx@1
 
   v3 = a2 - 1;
-  result = &pArray[(signed __int16)(v3 >> 3)];
-  v5 = 0x80u >> v3 % 8;
+  result = &pArray[v3 / 8];
+  v5 = 0x80 >> v3 % 8;
   if ( bToggle )
     *result |= v5;
   else
-    *result &= ~(char)v5;
+    *result &= ~(unsigned char)v5;
   return result;
 }
 
--- a/mm7_4.cpp	Mon Oct 15 18:45:11 2012 +0200
+++ b/mm7_4.cpp	Tue Oct 16 00:05:53 2012 +0200
@@ -3811,7 +3811,6 @@
   }
   return result;
 }
-// 493938: using guessed type char var_22C[400];
 
 
 
@@ -3853,12 +3852,12 @@
   signed __int64 v2; // ST38_8@1
   unsigned __int64 v3; // qax@1
   unsigned int v4; // edi@1
-  signed int v5; // eax@4
-  char *v6; // ecx@5
-  Player *v7; // esi@8
-  char *v8; // ecx@12
+  //signed int v5; // eax@4
+  //char *v6; // ecx@5
+  //Player *v7; // esi@8
+  //char *v8; // ecx@12
   Player *pPlayer; // esi@15
-  void *v10; // esi@25
+  //void *v10; // esi@25
   unsigned int v11; // ecx@27
   signed int v12; // edi@29
   Player *v13; // ecx@30
@@ -3892,13 +3891,13 @@
   int v41; // eax@95
   int v42; // ecx@96
   bool v43; // ebx@102
-  SpellBuff *v44; // edi@104
-  signed int v45; // ebp@104
+  //SpellBuff *v44; // edi@104
+  //signed int v45; // ebp@104
   bool v46; // edi@111
-  SpellBuff *v47; // esi@113
-  Player **v48; // esi@119
-  signed int v49; // edi@121
-  char *v50; // esi@122
+  //SpellBuff *v47; // esi@113
+  //Player **v48; // esi@119
+  //signed int v49; // edi@121
+  //char *v50; // esi@122
   signed int v51; // edx@128
   signed int v52; // ecx@130
   int v53; // eax@131
@@ -3923,54 +3922,37 @@
   v1 = v0;
   v0 /= 60i64;
   v2 = v0;
-  v3 = (unsigned int)v0 / 0x18;
+  v3 = (unsigned int)v0 / 24;
   v4 = (unsigned int)(v3 / 7) >> 2;
   pParty->uCurrentTimeSecond = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) % 60;
   pParty->uCurrentMinute = v1 % 60;
   pParty->uCurrentMonthWeek = v3 / 7 & 3;
   pParty->uCurrentHour = v2 % 24;
-  pParty->uDaysPlayed = (unsigned int)v3 % 0x1C;
-  pParty->uCurrentMonth = v4 % 0xC;
+  pParty->uDaysPlayed = (unsigned int)v3 % 28;
+  pParty->uCurrentMonth = v4 % 12;
   pParty->uCurrentYear = v4 / 0xC + 1168;
-  if ( pParty->uCurrentHour >= 3 && ((signed int)a2 < 3 || (unsigned int)v3 % 0x1C > v61) )
-  {
-    v5 = 0;
-    pParty->pHirelings[0].bHasUsedTheAbility = 0;
-    pParty->pHirelings[1].bHasUsedTheAbility = 0;
-    if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
-    {
-      v6 = (char *)&pNPCStats->pNewNPCData[0].bHasUsedTheAbility;
-      do
-      {
-        *(int *)v6 = 0;
-        ++v5;
-        v6 += 76;
-      }
-      while ( v5 < (signed int)pNPCStats->uNumNewNPCs );
-    }
+  if ( pParty->uCurrentHour >= 3 && ((signed int)a2 < 3 || (unsigned int)v3 % 28 > v61) )
+  {
+    pParty->pHirelings[0].bHasUsedTheAbility = false;
+    pParty->pHirelings[1].bHasUsedTheAbility = false;
+
+    for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i)
+      pNPCStats->pNewNPCData[i].bHasUsedTheAbility = false;
+
     ++pParty->field_764;
     if ( pParty->field_764 > 1u )
     {
-      v7 = pParty->pPlayers;
-      do
-      {
-        v7->SetCondition(1u, 0);
-        ++v7;
-      }
-      while ( (signed int)v7 < (signed int)pParty->pHirelings );
+      for (uint i = 0; i < 4; ++i)
+        pParty->pPlayers[i].SetCondition(1, 0);
+
       if ( pParty->uNumFoodRations )
       {
         Party::TakeFood(1u);
       }
       else
       {
-        v8 = (char *)&pParty->pPlayers[0].sHealth;
-        do
-        {
-          *(int *)v8 = *(int *)v8 / ((unsigned __int8)pParty->field_764 + 1) + 1;
-          v8 += 6972;
-        }
-        while ( (signed int)v8 < (signed int)&pParty->field_871C[567] );
+        for (uint i = 0; i < 4; ++i)
+          pParty->pPlayers[i].sHealth = pParty->pPlayers[i].sHealth / ((unsigned __int8)pParty->field_764 + 1) + 1;
       }
       if ( pParty->field_764 > 3u )
       {
@@ -4003,13 +3985,9 @@
     }
     if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
       pOutdoor->SetFog();
-    v10 = &pParty->pPlayers[0].uNumDivineInterventionCastsThisDay;
-    do
-    {
-      memset(v10, 0, 4u);
-      v10 = (char *)v10 + 6972;
-    }
-    while ( (signed int)v10 < (signed int)&pParty->field_871C[694] );
+
+    for (uint i = 0; i < 4; ++i)
+      pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0;
   }
   v11 = LODWORD(pParty->uTimePlayed);
   if ( pParty->uFlags & 4 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed )
@@ -4247,58 +4225,46 @@
     if ( v21->pConditions[2] | v21->pConditions[12] | v21->pConditions[13] | v21->pConditions[14] | v21->pConditions[15] | v21->pConditions[16] )
       --v65;
     v43 = (signed __int64)v21->pPlayerBuffs[7].uExpireTime > 0;
-    v44 = v21->pPlayerBuffs;
-    v45 = 24;
-    do
-    {
-      v44->_4585CA(pParty->uTimePlayed);
-      ++v44;
-      --v45;
-    }
-    while ( v45 );
+
+    for (uint k = 0; k < 24; ++k)
+      v21->pPlayerBuffs[k]._4585CA(pParty->uTimePlayed);
+
     if ( v43 && (signed __int64)v21->pPlayerBuffs[7].uExpireTime <= 0 )
       v21->SetCondition(1u, 0);
     ++v62;
   }
   while ( (signed int)v62 <= (signed int)&pPlayers[4] );
   v46 = (signed __int64)pParty->pPartyBuffs[8].uExpireTime > 0;
-  v47 = pParty->pPartyBuffs;
-  do
-  {
-    if ( v47->_4585CA(pParty->uTimePlayed) == 1 )
+
+  for (uint i = 0; i < 20; ++i)
+  {
+    if (pParty->pPartyBuffs[i]._4585CA(pParty->uTimePlayed) == 1)
       viewparams->bRedrawGameUI = 1;
-    ++v47;
-  }
-  while ( (signed int)v47 < (signed int)pParty->pPlayers );
+  }
+
   if ( v46 && (signed __int64)pParty->pPartyBuffs[8].uExpireTime <= 0 )
   {
-    v48 = &pPlayers[1];
-    do
-    {
-      (*v48)->SetCondition(1u, 0);
-      ++v48;
-    }
-    while ( (signed int)v48 <= (signed int)&pPlayers[4] );
-  }
-  v49 = (signed int)dword_4EE07C;
-  do
-  {
-    v50 = (char *)&pParty->pPartyBuffs[*(int *)v49];
-    if ( *(_QWORD *)v50 > 0i64 )
-    {
-      if ( !(v50[15] & 1) )
-      {
-        if ( !pPlayers[(unsigned __int8)v50[14]]->CanAct() )
-        {
-          ((SpellBuff *)v50)->Reset();
-          if ( *(int *)v49 == 7 )
-            pParty->bFlying = 0;
-        }
-      }
-    }
-    v49 += 4;
-  }
-  while ( v49 < (signed int)&unk_4EE084 );
+    for (uint i = 0; i < 4; ++i)
+      pParty->pPlayers[i].SetCondition(1, 0);
+  }
+
+  for (uint i = 0; i < 2; ++i)
+  {
+    auto pBuf = &pParty->pPartyBuffs[dword_4EE07C[i]];
+    if (pBuf->uExpireTime == 0)
+      continue;
+
+    if ( !(pBuf->uFlags & 1) )
+    {
+      if (!pPlayers[pBuf->uCaster]->CanAct())
+      {
+        pBuf->Reset();
+        if (dword_4EE07C[i] == 7 )
+          pParty->bFlying = false;
+      }
+    }
+  }
+
   v51 = v65;
   if ( v65 )
     goto LABEL_135;
@@ -9737,7 +9703,7 @@
       v10 = result->field_152;
       result = (Player *)_449B57_test_bit((unsigned __int8 *)result->field_152, 1);
       if ( !(short)result )
-        result = (Player *)_449B7E_toggle_bit(v10, 1, 1u);
+        result = (Player *)_449B7E_toggle_bit((unsigned char *)v10, 1, 1u);
     }
     ++v8;
   }
--- a/mm7_5.cpp	Mon Oct 15 18:45:11 2012 +0200
+++ b/mm7_5.cpp	Tue Oct 16 00:05:53 2012 +0200
@@ -1320,14 +1320,14 @@
                       goto LABEL_322;
                     case 3:
                       ptr_507BE0->Release();
-                      crt_deconstruct_ptr_6A0118();
+                      //crt_deconstruct_ptr_6A0118();
                       ptr_507BE0 = 0;
                       pEventTimer->Resume();
                       goto LABEL_322;
                     case 11:
                     case 12:
                       pIcons_LOD->_4114F2();
-                      crt_deconstruct_ptr_6A0118();
+                      //crt_deconstruct_ptr_6A0118();
                       goto LABEL_291;
                     case 15:
                       uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 10;
@@ -2146,7 +2146,7 @@
               *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
               ++pMessageQueue_50CBD0->uNumMessages;
             }
-            crt_deconstruct_ptr_6A0118();
+            //crt_deconstruct_ptr_6A0118();
             ptr_507BE0->Release();
             pGUIWindow_CurrentMenu->Release();
             ptr_507BE0 = 0;
@@ -3696,7 +3696,7 @@
           if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 12 )
           {
             pIcons_LOD->_4114F2();
-            crt_deconstruct_ptr_6A0118();
+            //crt_deconstruct_ptr_6A0118();
             stru_506F20.Release();
             stru_506F20.Load("title.pcx", 0);
             SetCurrentMenuID(MENU_MAIN);
@@ -13834,7 +13834,7 @@
         v32 = (&dword_723718_autonote_related)[8 * (signed __int16)v8];
         if ( (short)v8 )
         {
-          if ( (unsigned __int16)_449B57_test_bit((unsigned __int8 *)pParty->_autonote_related_stuff, v8) && v32 )
+          if ( (unsigned __int16)_449B57_test_bit(pParty->_autonote_bits, v8) && v32 )
           {
             v9 = dword_506520++;
             pStru179->field_0[v9] = (signed __int16)v8;
--- a/mm7_data.cpp	Mon Oct 15 18:45:11 2012 +0200
+++ b/mm7_data.cpp	Tue Oct 16 00:05:53 2012 +0200
@@ -37,8 +37,8 @@
 stru277 stru_50CDB4; // idb
 
 #include "Viewport.h"
-struct Viewport *pViewport;
-struct ViewingParams *viewparams;
+struct Viewport *pViewport = new Viewport;
+struct ViewingParams *viewparams = new ViewingParams;
 
 #include "stru272.h"
 stru272 array_4FAC10[10];
@@ -1933,7 +1933,7 @@
 const char *dlh_texnames_by_face[25];
 const char *dlhu_texnames_by_face[25];
 _UNKNOWN unk_4ED3D8; // weak
-char byte_4ED498; // weak
+unsigned char byte_4ED498 = 15; // weak
 __int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing__negindex[777]; // weak
 __int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[4];
 char byte_4ED970_skill_learn_ability_by_class_table[32][37];
--- a/mm7_data.h	Mon Oct 15 18:45:11 2012 +0200
+++ b/mm7_data.h	Tue Oct 16 00:05:53 2012 +0200
@@ -1921,7 +1921,7 @@
 extern const char *dlh_texnames_by_face[25];
 extern const char *dlhu_texnames_by_face[25];
 extern _UNKNOWN unk_4ED3D8; // weak
-extern char byte_4ED498; // weak
+extern unsigned char byte_4ED498; // weak
 extern __int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing__negindex[]; // weak
 extern __int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[4];
 extern char byte_4ED970_skill_learn_ability_by_class_table[32][37];
@@ -3181,7 +3181,7 @@
 void __thiscall TeleportToStartingPoint(unsigned int uPointType); // idb
 __int16 __fastcall sub_449A49_door_switch_animation(unsigned int uDoorID, int a2); // idb
 unsigned int __fastcall _449B57_test_bit(unsigned __int8 *a1, __int16 a2);
-char *__fastcall _449B7E_toggle_bit(char *pArray, __int16 a2, unsigned __int16 bToggle); // idb
+unsigned char *_449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle); // idb
 void __cdecl sub_44A56A();
 void __fastcall ShowStatusBarString(const char *pString, unsigned int uNumSeconds);
 void __cdecl ShowNothingHereStatus();
@@ -3271,7 +3271,7 @@
 void __cdecl MM7Initialization();
 int __cdecl AbortWithError();
 void Abortf(const char *Format, ...);
-void __cdecl crt_deconstruct_ptr_6A0118();
+void FreeSavegameThumbnails();
 void SetCurrentMenuID(enum MENU_STATE); // idb
 enum MENU_STATE GetCurrentMenuID();
 void *__thiscall output_debug_string(void *_this, std::string a2, const char *a3, int a4);