Mercurial > mm7
comparison 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 |
comparison
equal
deleted
inserted
replaced
821:5e3f4bf3b8e6 | 837:bebc19f3d2af |
---|---|
6488 pGames_LOD = new LODWriteableFile; | 6488 pGames_LOD = new LODWriteableFile; |
6489 pGames_LOD->AllocSubIndicesAndIO(300, 0); | 6489 pGames_LOD->AllocSubIndicesAndIO(300, 0); |
6490 if (pGames_LOD->LoadFile("data\\games.lod", 1)) | 6490 if (pGames_LOD->LoadFile("data\\games.lod", 1)) |
6491 { | 6491 { |
6492 pNew_LOD = new LODWriteableFile; | 6492 pNew_LOD = new LODWriteableFile; |
6493 pNew_LOD->AllocSubIndicesAndIO(300, 0x186A0u); | 6493 pNew_LOD->AllocSubIndicesAndIO(300, 100000); |
6494 return true; | 6494 return true; |
6495 } | 6495 } |
6496 return false; | 6496 return false; |
6497 } | 6497 } |
6498 | 6498 |
6499 //----- (0046086A) -------------------------------------------------------- | 6499 //----- (0046086A) -------------------------------------------------------- |
6500 void Autosave() | 6500 void SaveNewGame() |
6501 { | 6501 { |
6502 FILE *v3; // eax@7 | 6502 FILE *v3; // eax@7 |
6503 LOD::FileHeader this_; // [sp+Ch] [bp-16Ch]@3 | 6503 LOD::FileHeader this_; // [sp+Ch] [bp-16Ch]@3 |
6504 LOD::Directory pDir; // [sp+10Ch] [bp-6Ch]@4 | 6504 LOD::Directory pDir; // [sp+10Ch] [bp-6Ch]@4 |
6505 LOD::Directory v7; // [sp+12Ch] [bp-4Ch]@9 | 6505 LOD::Directory save_game_dir; // [sp+12Ch] [bp-4Ch]@9 |
6506 LOD::Directory a3; // [sp+14Ch] [bp-2Ch]@3 | 6506 LOD::Directory a3; // [sp+14Ch] [bp-2Ch]@3 |
6507 void *pSave; // [sp+170h] [bp-8h]@3 | 6507 void *pSave; // [sp+170h] [bp-8h]@3 |
6508 | 6508 |
6509 if ( pVideoPlayer->AnyMovieLoaded() ) | 6509 if ( pVideoPlayer->AnyMovieLoaded() ) |
6510 pVideoPlayer->Unload(); | 6510 pVideoPlayer->Unload(); |
6511 pSave = pAllocator->AllocNamedChunk(0, 0xF4240, 0); | 6511 pSave = pAllocator->AllocNamedChunk(0, 1000000, 0); |
6512 pNew_LOD->CloseWriteFile(); | 6512 pNew_LOD->CloseWriteFile(); |
6513 remove("data\\new.lod"); | 6513 remove("data\\new.lod"); |
6514 this_.Reset(); | 6514 this_.Reset(); |
6515 strcpy(this_.LodVersion, "MMVII"); | 6515 strcpy(this_.LodVersion, "MMVII"); |
6516 strcpy(this_.LodDescription, "newmaps for MMVII"); | 6516 strcpy(this_.LodDescription, "newmaps for MMVII"); |
6517 this_.LODSize = 100; | 6517 this_.LODSize = 100; |
6518 this_.dword_0000A8 = 0; | 6518 this_.dword_0000A8 = 0; |
6519 a3.dword_000018 = 0; | 6519 a3.dword_000018 = 0; |
6520 a3.word_00001E = 0; | 6520 a3.word_00001E = 0; |
6521 strcpy(a3.pFilename, "current"); | 6521 strcpy(a3.pFilename, "current"); |
6522 pNew_LOD->_461492(&this_, &a3, "data\\new.lod"); | 6522 pNew_LOD->CreateNewLod(&this_, &a3, "data\\new.lod"); |
6523 if ( pNew_LOD->LoadFile("data\\new.lod", 0) ) | 6523 if ( pNew_LOD->LoadFile("data\\new.lod", 0) ) |
6524 { | 6524 { |
6525 pNew_LOD->CreateTempFile(); | 6525 pNew_LOD->CreateTempFile(); |
6526 pNew_LOD->uNumSubIndices = 0; | 6526 pNew_LOD->uNumSubDirs = 0; |
6527 pDir.Reset(); | 6527 pDir.Reset(); |
6528 | 6528 |
6529 for (int i = pGames_LOD->uNumSubIndices / 2; i < pGames_LOD->uNumSubIndices; ++i) | 6529 for (int i = pGames_LOD->uNumSubDirs / 2; i < pGames_LOD->uNumSubDirs; ++i) |
6530 { | 6530 { |
6531 memcpy(&pDir, &pGames_LOD->pSubIndices[i], sizeof(pDir)); | 6531 memcpy(&pDir, &pGames_LOD->pSubIndices[i], sizeof(pDir)); |
6532 v3 = pGames_LOD->FindContainer(pGames_LOD->pSubIndices[i].pFilename, 1); | 6532 v3 = pGames_LOD->FindContainer(pGames_LOD->pSubIndices[i].pFilename, 1); |
6533 fread(pSave, pGames_LOD->pSubIndices[i].uDataSize, 1, v3); | 6533 fread(pSave, pGames_LOD->pSubIndices[i].uDataSize, 1, v3); |
6534 pNew_LOD->AppendDirectory(&pDir, pSave); | 6534 pNew_LOD->AppendDirectory(&pDir, pSave); |
6535 } | 6535 } |
6536 v7.Reset(); | 6536 save_game_dir.Reset(); |
6537 strcpy(pSavegameHeader->pLocationName, "out01.odm"); | 6537 strcpy(pSavegameHeader[0].pLocationName, "out01.odm"); |
6538 strcpy(v7.pFilename, "header.bin"); | 6538 strcpy(save_game_dir.pFilename, "header.bin"); |
6539 v7.uDataSize = 100; | 6539 save_game_dir.uDataSize = 100; |
6540 pNew_LOD->AppendDirectory(&v7, &pSavegameHeader); | 6540 pNew_LOD->AppendDirectory(&save_game_dir, &pSavegameHeader[0]); |
6541 pNew_LOD->Save(); | 6541 pNew_LOD->FixDirectoryOffsets(); |
6542 pParty->vPrevPosition.y = 0; | 6542 pParty->vPrevPosition.y = 0; |
6543 pParty->vPrevPosition.x = 12552; | 6543 pParty->vPrevPosition.x = 12552; |
6544 pParty->vPosition.x = 12552; | 6544 pParty->vPosition.x = 12552; |
6545 pParty->vPosition.z = 0; | 6545 pParty->vPosition.z = 0; |
6546 pParty->uFallStartY = 0; | 6546 pParty->uFallStartY = 0; |
9054 break; | 9054 break; |
9055 } | 9055 } |
9056 DeleteCCharFont(); | 9056 DeleteCCharFont(); |
9057 bFlashQuestBook = true; | 9057 bFlashQuestBook = true; |
9058 pGame->pCShow->PlayMovie(MOVIE_Emerald, 0); | 9058 pGame->pCShow->PlayMovie(MOVIE_Emerald, 0); |
9059 Autosave(); | 9059 SaveNewGame(); |
9060 pGame->Loop(); | 9060 pGame->Loop(); |
9061 if ( uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU ) | 9061 if ( uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU ) |
9062 { | 9062 { |
9063 SetCurrentMenuID(MENU_NEWGAME); | 9063 SetCurrentMenuID(MENU_NEWGAME); |
9064 uGameState = 0; | 9064 uGameState = 0; |