diff SaveLoad.cpp @ 117:a64b244da76c

some things lod
author Nomad
date Tue, 13 Nov 2012 17:29:38 +0200
parents e5d6903a077a
children 062e8a8e09bc
line wrap: on
line diff
--- a/SaveLoad.cpp	Thu Nov 08 04:57:39 2012 +0200
+++ b/SaveLoad.cpp	Tue Nov 13 17:29:38 2012 +0200
@@ -1,5 +1,6 @@
 #include <io.h>
 #include <direct.h>
+#include <assert.h>
 
 #include "SaveLoad.h"
 #include "NPC.h"
@@ -46,7 +47,7 @@
   bool v26; // eax@62
   int v30; // [sp-Ch] [bp-FCh]@65
   int v31; // [sp-8h] [bp-F8h]@4
-  char DstBuf[100]; // [sp+Ch] [bp-E4h]@23
+  SavegameHeader header; // [sp+Ch] [bp-E4h]@23
   char Str[123]; // [sp+70h] [bp-80h]@25
 
   dword_5B65C8 = 0;
@@ -97,7 +98,8 @@
     Log::Warning(L"%S", Str);
     MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:549", 0);
   }
-  fread(&DstBuf, 0x64u, 1u, f);
+  assert(sizeof(SavegameHeader) == 100);
+  fread(&header, sizeof(SavegameHeader), 1, f);
 
   f = pNew_LOD->FindContainer("party.bin", 1);
   if (!f)
@@ -198,16 +200,16 @@
   pEventTimer->Resume();
   pEventTimer->StopGameTime();
 
-  v25 = pGames_LOD->DoesContainerExist(&DstBuf[20]);
-  sprintf(pTmpBuf, "levels\\%s", &DstBuf[20]);
+  v25 = pGames_LOD->DoesContainerExist(header.pLocationName);
+  sprintf(pTmpBuf, "levels\\%s", header.pLocationName);
   v26 = _access(pTmpBuf, 4) != -1;
   if ( !v25 && !v26 )
   {
-    sprintf(pTmpBuf, "Unable to find: %s!", &DstBuf[20]);
+    sprintf(pTmpBuf, "Unable to find: %s!", header.pLocationName);
     Abortf(pTmpBuf);
   }
 
-  strcpy(pCurrentMapName, &DstBuf[20]);
+  strcpy(pCurrentMapName, header.pLocationName);
   dword_6BE364_game_settings_1 |= 0x2001;
 
   for (uint i = 0; i < uNumSavegameFiles; ++i)
@@ -260,16 +262,17 @@
   int v32; // esi@51
   int v33; // eax@51
   DWORD v34; // eax@59
-  std::string v35; // [sp-18h] [bp-288h]@8
+  //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
   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 pTimePlayed; // [sp+F4h] [bp-17Ch]@10
+  SavegameHeader header; // [sp+CCh] [bp-1A4h]@10
+  //int v43; // [sp+CCh] [bp-1A4h]@10
+  //char Dest[20]; // [sp+E0h] [bp-190h]@10
+  //unsigned __int64 pTimePlayed; // [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
@@ -322,7 +325,7 @@
   strcpy(pDir.pFilename, "image.pcx");
   pRenderer->_49F5A2((int)pScreenshot, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize);
   free(pScreenshot);
-  if ( pCurrentScreen == 11 )//SaveScreen
+  if (pCurrentScreen == 11) //SaveScreen
   {
     pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
     pRenderer->DrawTextureIndexed(0x12, 0x8D, (Texture *)(uTextureID_save_up != -1 ? &pIcons_LOD->pTextures[uTextureID_save_up] : 0));
@@ -334,49 +337,51 @@
     pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v6 + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Пожалуйста, подождите
     pRenderer->Present();
    }
-  if ( pNew_LOD->Write(&pDir, DstBuf, 0) )
+  if (pNew_LOD->Write(&pDir, DstBuf, 0))
   {
     sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200); //Сохраненная игра повреждена! Code=%d
     MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
   }
-  strcpy(Dest, pCurrentMapName);
-  pTimePlayed = pParty->uTimePlayed;
-  strcpy((char *)&pDir, "header.bin");
-  pDir.uDataSize = 100;
-  if ( pNew_LOD->Write(&pDir, &v43, 0) )
+
+  assert(sizeof(SavegameHeader) == 100);
+  strcpy(header.pLocationName, pCurrentMapName);
+  header.uWordTime = pParty->uTimePlayed;
+  strcpy(pDir.pFilename, "header.bin");
+  pDir.uDataSize = sizeof(SavegameHeader);
+  if (pNew_LOD->Write(&pDir, &header, 0))
   {
     sprintf(Str, pGlobalTXT_LocalizationStrings[612], 201);
     MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0);
   }
-  strcpy((char *)&pDir, "party.bin");
+  strcpy(pDir.pFilename, "party.bin");
   pDir.uDataSize = 90680;
-  if ( pNew_LOD->Write(&pDir, &pParty, 0) )
+  if ( pNew_LOD->Write(&pDir, pParty, 0) )
   {
     sprintf(Str, pGlobalTXT_LocalizationStrings[612], 202);
     MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0);
   }
-  strcpy((char *)&pDir, "clock.bin");
+  strcpy(pDir.pFilename, "clock.bin");
   pDir.uDataSize = 40;
-  if ( pNew_LOD->Write(&pDir, &pEventTimer, 0) )
+  if ( pNew_LOD->Write(&pDir, pEventTimer, 0) )
   {
     sprintf(Str, pGlobalTXT_LocalizationStrings[612], 203);
     MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0);
   }
-  strcpy((char *)&pDir, "overlay.bin");
+  strcpy(pDir.pFilename, "overlay.bin");
   pDir.uDataSize = 1008;
-  if ( pNew_LOD->Write(&pDir, &pOtherOverlayList, 0) )
+  if ( pNew_LOD->Write(&pDir, pOtherOverlayList, 0) )
   {
     sprintf(Str, pGlobalTXT_LocalizationStrings[612], 204);
     MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0);
   }
-  strcpy((char *)&pDir, "npcdata.bin");
+  strcpy(pDir.pFilename, "npcdata.bin");
   pDir.uDataSize = 38076;
   if ( pNew_LOD->Write(&pDir, pNPCStats->pNewNPCData, 0) )
   {
     sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205);
     MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0);
   }
-  strcpy((char *)&pDir, "npcgroup.bin");
+  strcpy(pDir.pFilename, "npcgroup.bin");
   pDir.uDataSize = 102;
   if ( pNew_LOD->Write(&pDir, pNPCStats->pGroups_copy, 0) )
   {
@@ -391,6 +396,7 @@
       v8 = fopen(Str, "rb");
       if ( v8 )
       {
+        __debugbreak();
         sprintf(Str, "lloyd%d%d.pcx", i, j);
         fseek(v8, 0, 2);
         pDir.uDataSize = ftell(v8);
@@ -410,6 +416,7 @@
   }
   if ( !a2 )
   {
+    __debugbreak();
     sub_42FA22_mess_with_laying_item_list();
     v9 = (int)malloc(0xF4240);
     v71 = (std::string *)v9;
@@ -423,6 +430,7 @@
     memcpy((void *)v9, &Src, 0x10);
     if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
     {
+      __debugbreak();
       pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces;
       pIndoor->dlv.uNumBModels = 0;
       pIndoor->dlv.uNumDecorations = uNumLevelDecorations;
@@ -603,6 +611,8 @@
   int bNotArena; // [sp+2Ch] [bp-8h]@1
   unsigned int v6; // [sp+30h] [bp-4h]@1
 
+  __debugbreak();
+
   v1 = uSlot;
   v6 = uSlot;
   bNotArena = _strcmpi(pCurrentMapName, "d05.blv");