comparison SaveLoad.cpp @ 568:6f7d936edc9b

SaveGame/LoadGame sorta works
author Nomad
date Tue, 05 Mar 2013 04:30:20 +0200
parents 604d70894002
children 353ff9ea11e6
comparison
equal deleted inserted replaced
567:f51373466911 568:6f7d936edc9b
299 unsigned int v69; // [sp+260h] [bp-10h]@23 299 unsigned int v69; // [sp+260h] [bp-10h]@23
300 int v70; // [sp+264h] [bp-Ch]@22 300 int v70; // [sp+264h] [bp-Ch]@22
301 std::string *v71; // [sp+268h] [bp-8h]@8 301 std::string *v71; // [sp+268h] [bp-8h]@8
302 int a3; // [sp+26Fh] [bp-1h]@8 302 int a3; // [sp+26Fh] [bp-1h]@8
303 303
304 v66 = a2; 304 //v66 = a2;
305 strcpy(byte_6BE3B0, pCurrentMapName); 305 strcpy(byte_6BE3B0, pCurrentMapName);
306 if (!_strcmpi(pCurrentMapName, "d05.blv")) 306 if (!_strcmpi(pCurrentMapName, "d05.blv")) // arena
307 return false; 307 return false;
308
308 DstBuf = malloc(0xF4240); 309 DstBuf = malloc(0xF4240);
309 pDir.Reset(); 310 pDir.Reset();
310 pPositionX = pParty->vPosition.x; 311 pPositionX = pParty->vPosition.x;
311 v51 = pParty->vPosition.y; 312 v51 = pParty->vPosition.y;
312 v62 = pParty->vPosition.z; 313 v62 = pParty->vPosition.z;
326 strcpy(pDir.pFilename, "image.pcx"); 327 strcpy(pDir.pFilename, "image.pcx");
327 pRenderer->_49F5A2((int)pScreenshot, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize); 328 pRenderer->_49F5A2((int)pScreenshot, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize);
328 free(pScreenshot); 329 free(pScreenshot);
329 if (pCurrentScreen == SCREEN_SAVEGAME) 330 if (pCurrentScreen == SCREEN_SAVEGAME)
330 { 331 {
331 pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); 332 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave));
332 pRenderer->DrawTextureIndexed(0x12, 0x8D, (Texture *)(uTextureID_save_up != -1 ? &pIcons_LOD->pTextures[uTextureID_save_up] : 0)); 333 pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_save_up));
333 v4 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[190]); 334 v4 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[190]);
334 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v4 + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Сохранение 335 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v4 + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Сохранение
335 v5 = pFontSmallnum->AlignText_Center(0xBA, (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot); 336 v5 = pFontSmallnum->AlignText_Center(0xBA, pSavegameHeader[uLoadGameUI_SelectedSlot].pName);
336 pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v5 + 25, 0x103u, 0, (const char *)(&pSavegameHeader + uLoadGameUI_SelectedSlot), 185, 0); 337 pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v5 + 25, 0x103u, 0, pSavegameHeader[uLoadGameUI_SelectedSlot].pName, 185, 0);
337 v6 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[165]); 338 v6 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[165]);
338 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v6 + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Пожалуйста, подождите 339 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v6 + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Пожалуйста, подождите
339 pRenderer->Present(); 340 pRenderer->Present();
340 } 341 }
342
341 if (pNew_LOD->Write(&pDir, DstBuf, 0)) 343 if (pNew_LOD->Write(&pDir, DstBuf, 0))
342 { 344 {
343 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200); //Сохраненная игра повреждена! Code=%d 345 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200); //Сохраненная игра повреждена! Code=%d
344 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0); 346 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
345 } 347 }
377 { 379 {
378 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 204); 380 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 204);
379 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0); 381 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0);
380 } 382 }
381 strcpy(pDir.pFilename, "npcdata.bin"); 383 strcpy(pDir.pFilename, "npcdata.bin");
382 pDir.uDataSize = 38076; 384 pDir.uDataSize = 501 * sizeof(NPCData);
385 assert(pDir.uDataSize == 38076);
383 if ( pNew_LOD->Write(&pDir, pNPCStats->pNewNPCData, 0) ) 386 if ( pNew_LOD->Write(&pDir, pNPCStats->pNewNPCData, 0) )
384 { 387 {
385 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205); 388 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205);
386 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0); 389 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0);
387 } 390 }
533 } 536 }
534 } 537 }
535 if ( (signed int)uNumLevelDecorations > 0 ) 538 if ( (signed int)uNumLevelDecorations > 0 )
536 { 539 {
537 v66 = &pLevelDecorations[0].field_2; 540 v66 = &pLevelDecorations[0].field_2;
538 for (int i = 0; i <= (signed int)uNumLevelDecorations; ++i) 541 for (int i = 0; i <= (signed int)uNumLevelDecorations; ++i)
539 { 542 {
540 memcpy(v22, v66, 2); 543 memcpy(v22, v66, 2);
541 v66 += 16; 544 v66 += 16;
542 v22 = (char *)v22 + 2; 545 v22 = (char *)v22 + 2;
543 } 546 }
607 610
608 611
609 //----- (00460078) -------------------------------------------------------- 612 //----- (00460078) --------------------------------------------------------
610 void __fastcall DoSavegame(unsigned int uSlot) 613 void __fastcall DoSavegame(unsigned int uSlot)
611 { 614 {
612 unsigned int v1; // esi@1 615 //unsigned int v1; // esi@1
613 int v2; // esi@2 616 //int v2; // esi@2
614 //RGBTexture *v3; // ebx@3 617 //RGBTexture *v3; // ebx@3
615 int bNotArena; // [sp+2Ch] [bp-8h]@1 618 int bNotArena; // [sp+2Ch] [bp-8h]@1
616 unsigned int v6; // [sp+30h] [bp-4h]@1 619 //unsigned int v6; // [sp+30h] [bp-4h]@1
617 620
618 //__debugbreak(); 621 //__debugbreak();
619 622
620 v1 = uSlot; 623 //v1 = uSlot;
621 v6 = uSlot; 624 //v6 = uSlot;
622 bNotArena = _strcmpi(pCurrentMapName, "d05.blv"); 625 bNotArena = _strcmpi(pCurrentMapName, "d05.blv");
623 if ( bNotArena ) 626 if ( bNotArena )
624 { 627 {
625 LOD::Directory pDir; // [sp+Ch] [bp-28h]@2 628 LOD::Directory pDir; // [sp+Ch] [bp-28h]@2
626 SaveGame(0, 0); 629 SaveGame(0, 0);
627 v2 = 100 * v1; 630 //v2 = 100 * v1;
628 strcpy(&pSavegameHeader->pLocationName[v2], pCurrentMapName); 631 strcpy(pSavegameHeader[uSlot].pLocationName, pCurrentMapName);
629 *(int *)((char *)&pSavegameHeader->uWordTime + v2) = LODWORD(pParty->uTimePlayed); 632 pSavegameHeader[uSlot].uWordTime = pParty->uTimePlayed;
630 *(int *)((char *)&pSavegameHeader->uWordTime + v2 + 4) = HIDWORD(pParty->uTimePlayed); 633 strcpy(pDir.pFilename, "header.bin");
631 strcpy((char *)&pDir, "header.bin");
632 pDir.uDataSize = 100; 634 pDir.uDataSize = 100;
633 pNew_LOD->Write(&pDir, (char *)&pSavegameHeader + v2, 0); 635 pNew_LOD->Write(&pDir, &pSavegameHeader[uSlot], 0);
634 sprintf(pTmpBuf, "saves\\save%03d.mm7", v6); 636 sprintf(pTmpBuf, "saves\\save%03d.mm7", uSlot);
635 pNew_LOD->CloseWriteFile(); 637 pNew_LOD->CloseWriteFile();
636 CopyFileA("data\\new.lod", pTmpBuf, 0); 638 CopyFileA("data\\new.lod", pTmpBuf, 0);
637 } 639 }
638 GUI_UpdateWindows(); 640 GUI_UpdateWindows();
639 pGUIWindow_CurrentMenu->Release(); 641 pGUIWindow_CurrentMenu->Release();
640 pCurrentScreen = SCREEN_GAME; 642 pCurrentScreen = SCREEN_GAME;
641 //v3 = pSavegameThumbnails; 643 //v3 = pSavegameThumbnails;
642 viewparams->bRedrawGameUI = 1; 644 viewparams->bRedrawGameUI = 1;
643 for(int i=0;i<45;i++) 645 for (uint i = 0; i < 45; i++)
644 {
645 pSavegameThumbnails[i].Release(); 646 pSavegameThumbnails[i].Release();
646 }
647 //while ( (signed int)v3 < (signed int)&unk_6A0758 ); 647 //while ( (signed int)v3 < (signed int)&unk_6A0758 );
648 if ( bNotArena ) 648 if ( bNotArena )
649 pNew_LOD->_4621A7(); 649 pNew_LOD->_4621A7();
650 else 650 else
651 ShowStatusBarString(pGlobalTXT_LocalizationStrings[583], 2u);// "No saving in the Arena" 651 ShowStatusBarString(pGlobalTXT_LocalizationStrings[583], 2u);// "No saving in the Arena"
652 pIcons_LOD->_4355F7(); 652 pIcons_LOD->_4355F7();
653 pEventTimer->Resume(); 653 pEventTimer->Resume();
654 ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2u);// "Game Saved!" 654 ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2u);// "Game Saved!"
655 viewparams->bRedrawGameUI = 1; 655 viewparams->bRedrawGameUI = true;
656 } 656 }
657 // 4E28F8: using guessed type int pCurrentScreen; 657 // 4E28F8: using guessed type int pCurrentScreen;
658 658
659 659
660 660