changeset 110:430786d916d6

6.11.12 SaveLoad
author Ritor1
date Tue, 06 Nov 2012 17:30:24 +0600
parents 62772029b56d
children e5d6903a077a
files LOD.cpp LOD.h SaveLoad.cpp mm7_2.cpp
diffstat 4 files changed, 39 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/LOD.cpp	Tue Nov 06 10:07:35 2012 +0600
+++ b/LOD.cpp	Tue Nov 06 17:30:24 2012 +0600
@@ -1019,8 +1019,8 @@
   v4->pFile = v6;
   if ( !v6 )
     return 3;
-  fwrite(pHeader, 0x100u, 1u, v6);
-  fwrite(pDir, 0x20u, 1u, v4->pFile);
+  fwrite(pHeader, 0x100, 1, v6);
+  fwrite(pDir, 0x20, 1, v4->pFile);
   fclose(v4->pFile);
   v4->pFile = 0;
   return 0;
@@ -1518,7 +1518,7 @@
   v13 = v12;
   if ( v12 )
   {
-    fwrite(&v1->header, 0x100u, 1, v12);
+    fwrite(&v1->header, 0x100, 1, v12);
 
     LOD::Directory v0; // [sp+20Ch] [bp-28h]@11
     //LOD::Directory::LOD::Directory(&v0);
@@ -1531,7 +1531,7 @@
     v0.uDataSize = v21;
     v0.uNumSubIndices = LOWORD(v1->uNumSubIndices);
     fwrite(&v0, 0x20, 1, v13);
-    fwrite(v1->pSubIndices, 0x20u, v1->uNumSubIndices, v13);
+    fwrite(v1->pSubIndices, 0x20, v1->uNumSubIndices, v13);
     v16 = v1->pOutputFileHandle;
     v22 = v2;
     fseek(v16, 0, 0);
@@ -1542,8 +1542,8 @@
         v17 = v1->uIOBufferSize;
         if ( v22 <= (signed int)v17 )
           v17 = v22;
-        fread(v1->pIOBuffer, 1u, v17, v1->pOutputFileHandle);
-        fwrite(v1->pIOBuffer, 1u, v17, v13);
+        fread(v1->pIOBuffer, 1, v17, v1->pOutputFileHandle);
+        fwrite(v1->pIOBuffer, 1, v17, v13);
         v22 -= v17;
       }
       while ( v22 > 0 );
--- a/LOD.h	Tue Nov 06 10:07:35 2012 +0600
+++ b/LOD.h	Tue Nov 06 17:30:24 2012 +0600
@@ -1,7 +1,7 @@
 #pragma once
 #include <stdio.h>
 #include "Texture.h"
-
+#include <memory.h>
 
 
 /*  354 */
--- a/SaveLoad.cpp	Tue Nov 06 10:07:35 2012 +0600
+++ b/SaveLoad.cpp	Tue Nov 06 17:30:24 2012 +0600
@@ -298,14 +298,12 @@
   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);
   if (!_strcmpi(pCurrentMapName, "d05.blv"))
     return false;
-
   DstBuf = malloc(0xF4240u);
   pDir.Reset();
     v52 = pParty->vPosition.x;
@@ -319,48 +317,32 @@
   pParty->uFallStartY = pParty->vPrevPosition.y;
   pParty->sRotationY = pParty->sPrevRotationY;
   pParty->sRotationX = pParty->sPrevRotationX;
-
   if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
     pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed;
   else
     pOutdoor->uLastVisitDay = pParty->uTimePlayed;
-
   v3 = MakeScreenshot(150, 112);
-  {
-    strcpy(pDir.pFilename, "image.pcx");
-
-    pRenderer->_49F5A2((int)v3, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize);
-  }
+  strcpy(pDir.pFilename, "image.pcx");
+  pRenderer->_49F5A2((int)v3, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize);
   free(v3);
-
-    if ( pCurrentScreen == 11 )
+  if ( pCurrentScreen == 11 )//Save
     {
-      pRenderer->DrawTextureIndexed(
-        8u,
-        8u,
-        (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
-      pRenderer->DrawTextureIndexed(
-        0x12u,
-        0x8Du,
-        (Texture *)(uTextureID_save_up != -1 ? &pIcons_LOD->pTextures[uTextureID_save_up] : 0));
-      v36 = pGlobalTXT_LocalizationStrings[190];
+      pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
+      pRenderer->DrawTextureIndexed(0x12u, 0x8Du, (Texture *)(uTextureID_save_up != -1 ? &pIcons_LOD->pTextures[uTextureID_save_up] : 0));
       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];
+      pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v4 + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Сохранение
+      v5 = pFontSmallnum->AlignText_Center(0xBAu, (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot);
+      pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v5 + 25, 0x103u, 0, (const char *)(&pSavegameHeader + uLoadGameUI_SelectedSlot), 185, 0);
       v6 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[165]);
-      pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v6 + 25, 299, 0, v36, 0, 0, 0);
+      pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v6 + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Пожалуйста, подождите
       pRenderer->Present();
     }
     if ( pNew_LOD->Write(&pDir, DstBuf, 0) )
     {
-      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200);
-    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
+      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200); //Сохраненная игра повреждена! Code=%d
+      MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
     }
-    else
+  else
     {
       v7 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp";
     }
@@ -382,7 +364,7 @@
       sprintf(Str, pGlobalTXT_LocalizationStrings[612], 202);
     MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0);
     }
-    strcpy((char *)&pDir, "Timer.bin");
+    strcpy((char *)&pDir, "clock.bin");
     pDir.uDataSize = 40;
     if ( pNew_LOD->Write(&pDir, &pEventTimer, 0) )
     {
@@ -650,7 +632,6 @@
     pParty->sRotationY = v53;
     result = v54;
     pParty->sRotationX = v54;
-
   return result;
 }
 
--- a/mm7_2.cpp	Tue Nov 06 10:07:35 2012 +0600
+++ b/mm7_2.cpp	Tue Nov 06 17:30:24 2012 +0600
@@ -11726,27 +11726,23 @@
 //----- (0046086A) --------------------------------------------------------
 bool Autosave()
 {
-  int v0; // esi@3
-  int v1; // eax@4
-  int v2; // edx@5
+  int flag; // esi@3
   FILE *v3; // eax@7
   LOD::FileHeader this_; // [sp+Ch] [bp-16Ch]@3
   LOD::Directory pDir; // [sp+10Ch] [bp-6Ch]@4
   LOD::Directory v7; // [sp+12Ch] [bp-4Ch]@9
   LOD::Directory a3; // [sp+14Ch] [bp-2Ch]@3
-  unsigned int v9; // [sp+16Ch] [bp-Ch]@5
   void *pSave; // [sp+170h] [bp-8h]@3
-  unsigned int v11; // [sp+174h] [bp-4h]@5
 
   if ( pVideoPlayer->AnyMovieLoaded() )
     pVideoPlayer->Unload();
-  v0 = 0;
+  flag = 0;
   pSave = pAllocator->AllocNamedChunk(0, 0xF4240, 0);
   pNew_LOD->CloseWriteFile();
   remove("data\\new.lod");
   this_.Reset();
-  strcpy(this_.array_000004, "MMVII");
-  strcpy(this_.array_000054, "newmaps for MMVII");
+  strcpy(this_.LodVersion, "MMVII");
+  strcpy(this_.LodDescription, "newmaps for MMVII");
   this_.dword_0000A4 = 100;
   this_.dword_0000A8 = 0;
   a3.dword_000018 = 0;
@@ -11758,48 +11754,35 @@
     pNew_LOD->CreateTempFile();
     pNew_LOD->uNumSubIndices = 0;
     pDir.Reset();
-    v1 = (signed int)pGames_LOD->uNumSubIndices / 2;
-    if ( (signed int)pGames_LOD->uNumSubIndices / 2 < (signed int)pGames_LOD->uNumSubIndices )
-    {
-      v2 = 32 * v1;
-      v11 = 32 * v1;
-      v9 = pGames_LOD->uNumSubIndices - v1;
-      while ( 1 )
-      {
-        memcpy(&pDir, (char *)pGames_LOD->pSubIndices + v2, sizeof(pDir));
-        v3 = pGames_LOD->FindContainer((const char *)pGames_LOD->pSubIndices + v2, 1);
-        fread(pSave, pGames_LOD->pSubIndices[v11 / 0x20].uDataSize, 1u, v3);
-        pNew_LOD->AppendDirectory(&pDir, pSave);
-        v11 += 32;
-        --v9;
-        if ( !v9 )
-          break;
-        v2 = v11;
-      }
-      v0 = 0;
-    }
+	for (int i =  pGames_LOD->uNumSubIndices / 2; i < pGames_LOD->uNumSubIndices; ++i)
+   {
+    memcpy(&pDir, (char *)&pGames_LOD->pSubIndices[i], sizeof(pDir));
+    v3 = pGames_LOD->FindContainer((const char *)&pGames_LOD->pSubIndices[i], 1);
+    fread(pSave, pGames_LOD->pSubIndices[i].uDataSize, 1, v3);
+    pNew_LOD->AppendDirectory(&pDir, pSave);
+   }
     v7.Reset();
     strcpy(pSavegameHeader->pLocationName, "out01.odm");
     strcpy((char *)&v7, "header.bin");
     v7.uDataSize = 100;
     pNew_LOD->AppendDirectory(&v7, &pSavegameHeader);
     pNew_LOD->Save();
-    pParty->vPrevPosition.y = v0;
+    pParty->vPrevPosition.y = 0;
     pParty->vPrevPosition.x = 12552;
     pParty->vPosition.x = 12552;
-    pParty->vPosition.z = v0;
-    pParty->uFallStartY = v0;
-    pParty->sPrevRotationX = v0;
-    pParty->sRotationX = v0;
+    pParty->vPosition.z = 0;
+    pParty->uFallStartY = 0;
+    pParty->sPrevRotationX = 0;
+    pParty->sRotationX = 0;
     pParty->vPrevPosition.z = 1816;
     pParty->vPosition.y = 1816;
-    v0 = 1;
+    flag = 1;
     pParty->sPrevRotationY = 512;
     pParty->sRotationY = 512;
     SaveGame(1, (__int16 *)1);
   }
   pAllocator->FreeChunk(pSave);
-  return v0;
+  return flag;
 }