diff mm7_2.cpp @ 837:bebc19f3d2af

Save/load work with some problems
author Gloval
date Thu, 28 Mar 2013 00:37:27 +0400
parents 5e3f4bf3b8e6
children d061180f2b42
line wrap: on
line diff
--- a/mm7_2.cpp	Tue Mar 26 15:21:03 2013 +0000
+++ b/mm7_2.cpp	Thu Mar 28 00:37:27 2013 +0400
@@ -6490,25 +6490,25 @@
   if (pGames_LOD->LoadFile("data\\games.lod", 1))
   {
     pNew_LOD = new LODWriteableFile;
-    pNew_LOD->AllocSubIndicesAndIO(300, 0x186A0u);
+    pNew_LOD->AllocSubIndicesAndIO(300, 100000);
     return true;
   }
   return false;
 }
 
 //----- (0046086A) --------------------------------------------------------
-void Autosave()
+void SaveNewGame()
 {
   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 save_game_dir; // [sp+12Ch] [bp-4Ch]@9
   LOD::Directory a3; // [sp+14Ch] [bp-2Ch]@3
   void *pSave; // [sp+170h] [bp-8h]@3
 
   if ( pVideoPlayer->AnyMovieLoaded() )
     pVideoPlayer->Unload();
-  pSave = pAllocator->AllocNamedChunk(0, 0xF4240, 0);
+  pSave = pAllocator->AllocNamedChunk(0, 1000000, 0);
   pNew_LOD->CloseWriteFile();
   remove("data\\new.lod");
   this_.Reset();
@@ -6519,26 +6519,26 @@
   a3.dword_000018 = 0;
   a3.word_00001E = 0;
   strcpy(a3.pFilename, "current");
-  pNew_LOD->_461492(&this_, &a3, "data\\new.lod");
+  pNew_LOD->CreateNewLod(&this_, &a3, "data\\new.lod");
   if ( pNew_LOD->LoadFile("data\\new.lod", 0) )
   {
     pNew_LOD->CreateTempFile();
-    pNew_LOD->uNumSubIndices = 0;
+    pNew_LOD->uNumSubDirs = 0;
     pDir.Reset();
 
-    for (int i = pGames_LOD->uNumSubIndices / 2; i < pGames_LOD->uNumSubIndices; ++i)
+    for (int i = pGames_LOD->uNumSubDirs / 2; i < pGames_LOD->uNumSubDirs; ++i)
     {
       memcpy(&pDir, &pGames_LOD->pSubIndices[i], sizeof(pDir));
       v3 = pGames_LOD->FindContainer(pGames_LOD->pSubIndices[i].pFilename, 1);
       fread(pSave, pGames_LOD->pSubIndices[i].uDataSize, 1, v3);
       pNew_LOD->AppendDirectory(&pDir, pSave);
     }
-    v7.Reset();
-    strcpy(pSavegameHeader->pLocationName, "out01.odm");
-    strcpy(v7.pFilename, "header.bin");
-    v7.uDataSize = 100;
-    pNew_LOD->AppendDirectory(&v7, &pSavegameHeader);
-    pNew_LOD->Save();
+    save_game_dir.Reset();
+    strcpy(pSavegameHeader[0].pLocationName, "out01.odm");
+    strcpy(save_game_dir.pFilename, "header.bin");
+    save_game_dir.uDataSize = 100;
+    pNew_LOD->AppendDirectory(&save_game_dir, &pSavegameHeader[0]);
+    pNew_LOD->FixDirectoryOffsets();
     pParty->vPrevPosition.y = 0;
     pParty->vPrevPosition.x = 12552;
     pParty->vPosition.x = 12552;
@@ -9056,7 +9056,7 @@
           DeleteCCharFont();
           bFlashQuestBook = true;
           pGame->pCShow->PlayMovie(MOVIE_Emerald, 0);
-          Autosave();
+          SaveNewGame();
           pGame->Loop();
           if ( uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU )
           {