Mercurial > might-and-magic-trilogy
comparison mm7_2.cpp @ 26:93bf1d5f6a6d
Game loading.
author | Nomad |
---|---|
date | Tue, 16 Oct 2012 00:05:53 +0200 |
parents | 509744251c8e |
children | be2066176d89 |
comparison
equal
deleted
inserted
replaced
25:2bbf33898c6b | 26:93bf1d5f6a6d |
---|---|
11444 } | 11444 } |
11445 | 11445 |
11446 | 11446 |
11447 | 11447 |
11448 | 11448 |
11449 | |
11450 //----- (0045EE8A) -------------------------------------------------------- | |
11451 void __fastcall LoadGame(unsigned int uSlot) | |
11452 { | |
11453 unsigned int v1; // ebx@1 | |
11454 char v2; // zf@1 | |
11455 signed int v3; // esi@3 | |
11456 signed int v4; // esi@8 | |
11457 char *v5; // eax@9 | |
11458 unsigned int v6; // eax@12 | |
11459 unsigned int v7; // esi@13 | |
11460 char *v8; // ecx@14 | |
11461 FILE *v9; // eax@22 | |
11462 FILE *v10; // eax@26 | |
11463 FILE *v11; // eax@29 | |
11464 FILE *v12; // eax@32 | |
11465 FILE *v13; // eax@35 | |
11466 FILE *v14; // eax@38 | |
11467 unsigned int v15; // edi@41 | |
11468 Player *v16; // esi@41 | |
11469 int *v17; // esi@46 | |
11470 int v18; // edi@46 | |
11471 int v19; // ebx@46 | |
11472 int v20; // ecx@49 | |
11473 int v21; // eax@51 | |
11474 int v22; // ecx@56 | |
11475 bool v23; // edx@56 | |
11476 AudioPlayer *v24; // ebx@60 | |
11477 bool v25; // esi@62 | |
11478 bool v26; // eax@62 | |
11479 signed int v27; // esi@66 | |
11480 RGBTexture *v28; // edi@67 | |
11481 std::string v29; // [sp-18h] [bp-108h]@25 | |
11482 int v30; // [sp-Ch] [bp-FCh]@65 | |
11483 int v31; // [sp-8h] [bp-F8h]@4 | |
11484 signed int v32; // [sp-4h] [bp-F4h]@4 | |
11485 char DstBuf; // [sp+Ch] [bp-E4h]@23 | |
11486 char pContainer; // [sp+20h] [bp-D0h]@62 | |
11487 char Str[123]; // [sp+70h] [bp-80h]@25 | |
11488 char a3[5]; // [sp+EBh] [bp-5h]@2 | |
11489 | |
11490 v1 = uSlot; | |
11491 v2 = pSavegameUsedSlots[uSlot] == 0; | |
11492 dword_5B65C8 = 0; | |
11493 if ( v2 ) | |
11494 { | |
11495 v24 = pAudioPlayer; | |
11496 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); | |
11497 } | |
11498 else | |
11499 { | |
11500 *(int *)&a3[1] = 1; | |
11501 do | |
11502 { | |
11503 v3 = 1; | |
11504 do | |
11505 { | |
11506 v32 = v3; | |
11507 v31 = *(int *)&a3[1]; | |
11508 sprintfex(pTmpBuf, "data\\lloyd%d%d.pcx", *(int *)&a3[1], v3); | |
11509 remove(pTmpBuf); | |
11510 ++v3; | |
11511 } | |
11512 while ( v3 < 6 ); | |
11513 ++*(int *)&a3[1]; | |
11514 } | |
11515 while ( *(int *)&a3[1] < 5 ); | |
11516 *(int *)&a3[1] = (int)(char *)&pParty + 2508; | |
11517 do | |
11518 { | |
11519 if ( byte_4ED498 ) | |
11520 { | |
11521 v4 = 0; | |
11522 if ( (signed int)pSoundList->uNumSounds <= 0 ) | |
11523 { | |
11524 LABEL_12: | |
11525 v6 = 0; | |
11526 } | |
11527 else | |
11528 { | |
11529 v5 = (char *)&pSoundList->pSounds->uSoundID; | |
11530 while ( *(int *)v5 != 2 * ((unsigned __int8)byte_4ED498 + 50 * *(int *)(*(int *)&a3[1] + 6432)) | |
11531 + 4998 ) | |
11532 { | |
11533 ++v4; | |
11534 v5 += 120; | |
11535 if ( v4 >= (signed int)pSoundList->uNumSounds ) | |
11536 goto LABEL_12; | |
11537 } | |
11538 v6 = v4; | |
11539 } | |
11540 pSoundList->_4A9DCD(v6, 1); | |
11541 v7 = 0; | |
11542 if ( (signed int)pSoundList->uNumSounds <= 0 ) | |
11543 { | |
11544 LABEL_17: | |
11545 v7 = 0; | |
11546 } | |
11547 else | |
11548 { | |
11549 v8 = (char *)&pSoundList->pSounds->uSoundID; | |
11550 while ( *(int *)v8 != 2 * ((unsigned __int8)byte_4ED498 + 50 * *(int *)(*(int *)&a3[1] + 6432)) | |
11551 + 4999 ) | |
11552 { | |
11553 ++v7; | |
11554 v8 += 120; | |
11555 if ( (signed int)v7 >= (signed int)pSoundList->uNumSounds ) | |
11556 goto LABEL_17; | |
11557 } | |
11558 } | |
11559 pSoundList->_4A9DCD(v7, 1); | |
11560 } | |
11561 *(int *)&a3[1] += 6972; | |
11562 } | |
11563 while ( *(int *)&a3[1] < (signed int)pParty->pHirelings ); | |
11564 sprintfex(pTmpBuf, "saves\\%s", pSavegameList->pSavesNames[v1]); | |
11565 pNew_LOD->CloseWriteFile(); | |
11566 if ( !CopyFileA(pTmpBuf, "data\\new.lod", 0) ) | |
11567 GetLastError(); | |
11568 pNew_LOD->LoadFile("data\\new.lod", 0); | |
11569 v9 = pNew_LOD->FindContainer("header.bin", 1); | |
11570 if ( v9 ) | |
11571 { | |
11572 fread(&DstBuf, 0x64u, 1u, v9); | |
11573 } | |
11574 else | |
11575 { | |
11576 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 100); | |
11577 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:549", 0); | |
11578 } | |
11579 v10 = pNew_LOD->FindContainer("party.bin", 1); | |
11580 if ( v10 ) | |
11581 { | |
11582 fread(&pParty, 0x16238u, 1u, v10); | |
11583 } | |
11584 else | |
11585 { | |
11586 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 101); | |
11587 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:559", 0); | |
11588 } | |
11589 v11 = pNew_LOD->FindContainer("Timer.bin", 1); | |
11590 if ( v11 ) | |
11591 { | |
11592 fread(&pEventTimer, 0x28u, 1u, v11); | |
11593 } | |
11594 else | |
11595 { | |
11596 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 102); | |
11597 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:569", 0); | |
11598 } | |
11599 v12 = pNew_LOD->FindContainer("overlay.bin", 1); | |
11600 if ( v12 ) | |
11601 { | |
11602 fread(&pOtherOverlayList, 0x3F0u, 1u, v12); | |
11603 } | |
11604 else | |
11605 { | |
11606 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 103); | |
11607 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:579", 0); | |
11608 } | |
11609 v13 = pNew_LOD->FindContainer("npcdata.bin", 0); | |
11610 if ( v13 ) | |
11611 { | |
11612 fread(pNPCStats->pNewNPCData, 0x94BCu, 1u, v13); | |
11613 pNPCStats->_476C60(); | |
11614 } | |
11615 else | |
11616 { | |
11617 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 104); | |
11618 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:590", 0); | |
11619 } | |
11620 v14 = pNew_LOD->FindContainer("npcgroup.bin", 0); | |
11621 if ( v14 ) | |
11622 { | |
11623 fread(pNPCStats->pGroups_copy, 0x66u, 1u, v14); | |
11624 } | |
11625 else | |
11626 { | |
11627 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 105); | |
11628 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:600", 0); | |
11629 } | |
11630 v15 = 0; | |
11631 v16 = pParty->pPlayers; | |
11632 while ( 1 ) | |
11633 { | |
11634 ++v15; | |
11635 if ( v16->CanAct() ) | |
11636 break; | |
11637 ++v16; | |
11638 if ( (signed int)v16 >= (signed int)pParty->pHirelings ) | |
11639 goto LABEL_46; | |
11640 } | |
11641 uActiveCharacter = v15; | |
11642 LABEL_46: | |
11643 v17 = (int *)&pParty->pPlayers[0].uQuickSpell; | |
11644 v18 = 9; | |
11645 v19 = 0; | |
11646 do | |
11647 { | |
11648 if ( *(char *)v17 ) | |
11649 stru_AA1058[v19]._494836(*(char *)v17, v18 - 8); | |
11650 *(int *)&a3[1] = 0; | |
11651 v20 = (int)((char *)v17 - 263); | |
11652 while ( 1 ) | |
11653 { | |
11654 if ( *(int *)v20 ) | |
11655 { | |
11656 v21 = *(int *)((char *)&v17[9 * *(int *)v20 - 1559] - 3); | |
11657 if ( pItemsTable->pItems[v21].uEquipType == 12 ) | |
11658 break; | |
11659 } | |
11660 ++*(int *)&a3[1]; | |
11661 v20 += 4; | |
11662 if ( *(int *)&a3[1] > 1 ) | |
11663 goto LABEL_55; | |
11664 } | |
11665 v32 = v18; | |
11666 v31 = *((int *)&pSpellDatas[66].field_8 + v21); | |
11667 stru_A750F8[v19]._494836(v31, v18); | |
11668 LABEL_55: | |
11669 v17 += 1743; | |
11670 ++v18; | |
11671 ++v19; | |
11672 } | |
11673 while ( v18 - 9 < 4 ); | |
11674 pGUIWindow_CurrentMenu->Release(); | |
11675 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0; | |
11676 v22 = 1; | |
11677 viewparams->bRedrawGameUI = 1; | |
11678 LOBYTE(v23) = 1; | |
11679 if ( pParty->uAlignment ) | |
11680 { | |
11681 if ( pParty->uAlignment == 2 ) | |
11682 v22 = 2; | |
11683 } | |
11684 else | |
11685 { | |
11686 v22 = 0; | |
11687 } | |
11688 SetUserInterface(v22, v23); | |
11689 pEventTimer->Resume(); | |
11690 pEventTimer->StopGameTime(); | |
11691 v24 = pAudioPlayer; | |
11692 } | |
11693 v25 = pGames_LOD->DoesContainerExist((const char *)&pContainer); | |
11694 v32 = (signed int)&pContainer; | |
11695 sprintfex(pTmpBuf, "levels\\%s", &pContainer); | |
11696 v26 = _access(pTmpBuf, 4) != -1; | |
11697 if ( !v25 && !v26 ) | |
11698 { | |
11699 v32 = (signed int)&pContainer; | |
11700 sprintfex(pTmpBuf, "Unable to find: %s!", &pContainer); | |
11701 Abortf(pTmpBuf, v30, v31, v32); | |
11702 } | |
11703 strcpy(pCurrentMapName, &pContainer); | |
11704 dword_6BE364_game_settings_1 |= 0x2001; | |
11705 v27 = 0; | |
11706 if ( (signed int)uNumSavegameFiles > 0 ) | |
11707 { | |
11708 v28 = pSavegameThumbnails; | |
11709 do | |
11710 { | |
11711 v28->Release(); | |
11712 ++v27; | |
11713 ++v28; | |
11714 } | |
11715 while ( v27 < (signed int)uNumSavegameFiles ); | |
11716 } | |
11717 pIcons_LOD->_4114F2(); | |
11718 v32 = (signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0); | |
11719 v24->SetMusicVolume(v32); | |
11720 v32 = (signed __int64)(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0); | |
11721 v24->SetMasterVolume(v32); | |
11722 if ( uTurnSpeed ) | |
11723 pParty->sRotationY = uTurnSpeed * pParty->sRotationY / (signed int)uTurnSpeed; | |
11724 MM7Initialization(); | |
11725 bFlashQuestBook = 0; | |
11726 viewparams->bRedrawGameUI = 1; | |
11727 } | |
11728 | |
11729 | |
11730 //----- (0045F469) -------------------------------------------------------- | |
11731 int __fastcall SaveGame(int a1, __int16 *a2) | |
11732 { | |
11733 int result; // eax@1 | |
11734 void *v3; // edi@5 | |
11735 int v4; // eax@6 | |
11736 int v5; // eax@6 | |
11737 int v6; // eax@6 | |
11738 const char *v7; // edi@8 | |
11739 FILE *v8; // edi@24 | |
11740 int v9; // edi@30 | |
11741 void *v10; // esi@31 | |
11742 void *v11; // esi@31 | |
11743 void *v12; // esi@37 | |
11744 void *v13; // esi@37 | |
11745 void *v14; // esi@37 | |
11746 void *v15; // esi@37 | |
11747 void *v16; // esi@37 | |
11748 int v17; // esi@37 | |
11749 unsigned int v18; // ecx@38 | |
11750 unsigned int v19; // esi@39 | |
11751 char *v20; // edx@39 | |
11752 void *v21; // esi@41 | |
11753 void *v22; // esi@41 | |
11754 BSPModel *v23; // eax@42 | |
11755 signed int v24; // edi@42 | |
11756 unsigned __int8 v25; // zf@43 | |
11757 unsigned __int8 v26; // sf@43 | |
11758 signed int v27; // edi@47 | |
11759 void *v28; // esi@50 | |
11760 void *v29; // esi@50 | |
11761 void *v30; // esi@50 | |
11762 void *v31; // esi@50 | |
11763 int v32; // esi@51 | |
11764 int v33; // eax@51 | |
11765 DWORD v34; // eax@59 | |
11766 std::string v35; // [sp-18h] [bp-288h]@8 | |
11767 const char *v36; // [sp-10h] [bp-280h]@6 | |
11768 const char *v37; // [sp-Ch] [bp-27Ch]@6 | |
11769 const char *v38; // [sp-8h] [bp-278h]@8 | |
11770 int v39; // [sp-4h] [bp-274h]@8 | |
11771 CHAR Buffer; // [sp+Ch] [bp-264h]@59 | |
11772 char Dir; // [sp+8Ch] [bp-1E4h]@51 | |
11773 char Drive; // [sp+ACh] [bp-1C4h]@51 | |
11774 int v43; // [sp+CCh] [bp-1A4h]@10 | |
11775 char Dest[20]; // [sp+E0h] [bp-190h]@10 | |
11776 unsigned __int64 v45; // [sp+F4h] [bp-17Ch]@10 | |
11777 char Filename; // [sp+130h] [bp-140h]@51 | |
11778 char Ext; // [sp+150h] [bp-120h]@51 | |
11779 char v48; // [sp+151h] [bp-11Fh]@51 | |
11780 char Source[32]; // [sp+170h] [bp-100h]@51 | |
11781 char Str[120]; // [sp+190h] [bp-E0h]@8 | |
11782 int v51; // [sp+208h] [bp-68h]@2 | |
11783 int v52; // [sp+20Ch] [bp-64h]@2 | |
11784 int v53; // [sp+210h] [bp-60h]@2 | |
11785 int v54; // [sp+214h] [bp-5Ch]@2 | |
11786 int Src; // [sp+218h] [bp-58h]@30 | |
11787 char v56; // [sp+21Ch] [bp-54h]@30 | |
11788 char v57; // [sp+21Dh] [bp-53h]@30 | |
11789 char v58; // [sp+21Eh] [bp-52h]@30 | |
11790 char v59; // [sp+21Fh] [bp-51h]@30 | |
11791 int v60; // [sp+220h] [bp-50h]@30 | |
11792 int v61; // [sp+224h] [bp-4Ch]@30 | |
11793 int v62; // [sp+228h] [bp-48h]@2 | |
11794 LOD::Directory pDir; // [sp+22Ch] [bp-44h]@2 | |
11795 std::string *v64; // [sp+24Ch] [bp-24h]@1 | |
11796 size_t Size; // [sp+250h] [bp-20h]@26 | |
11797 __int16 *v66; // [sp+254h] [bp-1Ch]@1 | |
11798 void *DstBuf; // [sp+258h] [bp-18h]@2 | |
11799 __int16 *v68; // [sp+25Ch] [bp-14h]@32 | |
11800 unsigned int v69; // [sp+260h] [bp-10h]@23 | |
11801 int v70; // [sp+264h] [bp-Ch]@22 | |
11802 std::string *v71; // [sp+268h] [bp-8h]@8 | |
11803 int a3; // [sp+26Fh] [bp-1h]@8 | |
11804 | |
11805 v66 = a2; | |
11806 v64 = (std::string *)a1; | |
11807 strcpy(byte_6BE3B0, pCurrentMapName); | |
11808 result = _strcmpi(pCurrentMapName, "d05.blv"); | |
11809 if ( result ) | |
11810 { | |
11811 DstBuf = operator new(0xF4240u); | |
11812 pDir.Reset(); | |
11813 v52 = pParty->vPosition.x; | |
11814 v51 = pParty->vPosition.z; | |
11815 v62 = pParty->vPosition.y; | |
11816 v53 = pParty->sRotationY; | |
11817 v54 = pParty->sRotationX; | |
11818 pParty->vPosition.x = pParty->vPrevPosition.x; | |
11819 pParty->vPosition.z = pParty->vPrevPosition.z; | |
11820 pParty->vPosition.y = pParty->vPrevPosition.y; | |
11821 pParty->uFallStartY = pParty->vPrevPosition.y; | |
11822 pParty->sRotationY = pParty->sPrevRotationY; | |
11823 pParty->sRotationX = pParty->sPrevRotationX; | |
11824 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
11825 pIndoor->uLastVisitDay = pParty->uTimePlayed; | |
11826 else | |
11827 pOutdoor->uLastVisitDay = pParty->uTimePlayed; | |
11828 v3 = MakeScreenshot(150, 112); | |
11829 strcpy((char *)&pDir, "image.pcx"); | |
11830 pRenderer->_49F5A2((int)v3, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize); | |
11831 free(v3); | |
11832 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 11 ) | |
11833 { | |
11834 pRenderer->DrawTextureIndexed( | |
11835 8u, | |
11836 8u, | |
11837 (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); | |
11838 pRenderer->DrawTextureIndexed( | |
11839 0x12u, | |
11840 0x8Du, | |
11841 (Texture *)(uTextureID_save_up != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_save_up] : 0)); | |
11842 v36 = pGlobalTXT_LocalizationStrings[190]; | |
11843 v4 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[190]); | |
11844 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v4 + 25, 219, 0, v36, 0, 0, 0); | |
11845 v37 = (const char *)(&pSavegameHeader + uLoadGameUI_SelectedSlot); | |
11846 v5 = pFontSmallnum->AlignText_Center(0xBAu, | |
11847 (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot); | |
11848 pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v5 + 25, 0x103u, 0, v37, 185, 0); | |
11849 v36 = pGlobalTXT_LocalizationStrings[165]; | |
11850 v6 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[165]); | |
11851 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v6 + 25, 299, 0, v36, 0, 0, 0); | |
11852 pRenderer->Present(); | |
11853 } | |
11854 if ( pNew_LOD->Write(&pDir, DstBuf, 0) ) | |
11855 { | |
11856 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 200); | |
11857 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0); | |
11858 } | |
11859 else | |
11860 { | |
11861 v7 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp"; | |
11862 } | |
11863 strcpy(Dest, pCurrentMapName); | |
11864 v45 = pParty->uTimePlayed; | |
11865 strcpy((char *)&pDir, "header.bin"); | |
11866 pDir.uDataSize = 100; | |
11867 if ( pNew_LOD->Write(&pDir, &v43, 0) ) | |
11868 { | |
11869 v39 = 201; | |
11870 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 201); | |
11871 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0); | |
11872 } | |
11873 strcpy((char *)&pDir, "party.bin"); | |
11874 pDir.uDataSize = 90680; | |
11875 if ( pNew_LOD->Write(&pDir, &pParty, 0) ) | |
11876 { | |
11877 v39 = 202; | |
11878 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 202); | |
11879 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0); | |
11880 } | |
11881 strcpy((char *)&pDir, "Timer.bin"); | |
11882 pDir.uDataSize = 40; | |
11883 if ( pNew_LOD->Write(&pDir, &pEventTimer, 0) ) | |
11884 { | |
11885 v39 = 203; | |
11886 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 203); | |
11887 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0); | |
11888 } | |
11889 strcpy((char *)&pDir, "overlay.bin"); | |
11890 pDir.uDataSize = 1008; | |
11891 if ( pNew_LOD->Write(&pDir, &pOtherOverlayList, 0) ) | |
11892 { | |
11893 v39 = 204; | |
11894 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 204); | |
11895 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0); | |
11896 } | |
11897 strcpy((char *)&pDir, "npcdata.bin"); | |
11898 pDir.uDataSize = 38076; | |
11899 if ( pNew_LOD->Write(&pDir, pNPCStats->pNewNPCData, 0) ) | |
11900 { | |
11901 v39 = 205; | |
11902 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 205); | |
11903 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0); | |
11904 } | |
11905 strcpy((char *)&pDir, "npcgroup.bin"); | |
11906 pDir.uDataSize = 102; | |
11907 if ( pNew_LOD->Write(&pDir, pNPCStats->pGroups_copy, 0) ) | |
11908 { | |
11909 v39 = 206; | |
11910 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 206); | |
11911 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0); | |
11912 } | |
11913 v70 = 1; | |
11914 do | |
11915 { | |
11916 v69 = 1; | |
11917 do | |
11918 { | |
11919 v39 = v69; | |
11920 v38 = (const char *)v70; | |
11921 sprintfex(Str, "data\\lloyd%d%d.pcx", v70, v69); | |
11922 v8 = fopen(Str, "rb"); | |
11923 if ( v8 ) | |
11924 { | |
11925 v39 = v69; | |
11926 v38 = (const char *)v70; | |
11927 sprintfex(Str, "lloyd%d%d.pcx", v70, v69); | |
11928 fseek(v8, 0, 2); | |
11929 pDir.uDataSize = ftell(v8); | |
11930 rewind(v8); | |
11931 fread(DstBuf, pDir.uDataSize, 1u, v8); | |
11932 strcpy((char *)&pDir, Str); | |
11933 fclose(v8); | |
11934 remove(Str); | |
11935 if ( pNew_LOD->Write(&pDir, DstBuf, 0) ) | |
11936 { | |
11937 v39 = 207; | |
11938 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 207); | |
11939 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0); | |
11940 Size = 5080748; | |
11941 } | |
11942 } | |
11943 ++v69; | |
11944 } | |
11945 while ( (signed int)v69 <= 5 ); | |
11946 ++v70; | |
11947 } | |
11948 while ( v70 <= 4 ); | |
11949 if ( !v66 ) | |
11950 { | |
11951 sub_42FA22_mess_with_laying_item_list(); | |
11952 v9 = (int)malloc(0xF4240u); | |
11953 v71 = (std::string *)v9; | |
11954 Src = 91969; | |
11955 v56 = 109; | |
11956 v57 = 118; | |
11957 v58 = 105; | |
11958 v59 = 105; | |
11959 v60 = 0; | |
11960 v61 = 0; | |
11961 memcpy((void *)v9, &Src, 0x10u); | |
11962 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
11963 { | |
11964 v10 = DstBuf; | |
11965 pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces; | |
11966 pIndoor->dlv.uNumBModels = 0; | |
11967 pIndoor->dlv.uNumDecorations = uNumLevelDecorations; | |
11968 memcpy(DstBuf, &pIndoor->dlv, 0x28u); | |
11969 v10 = (char *)v10 + 40; | |
11970 memcpy(v10, pIndoor->_visible_outlines, 0x36Bu); | |
11971 v11 = (char *)v10 + 875; | |
11972 v70 = 0; | |
11973 if ( (signed int)pIndoor->uNumFaces > 0 ) | |
11974 { | |
11975 v68 = 0; | |
11976 do | |
11977 { | |
11978 v38 = (char *)v68 + (unsigned int)pIndoor->pFaces + 44; | |
11979 memcpy(v11, v38, 4u); | |
11980 v68 += 48; | |
11981 v11 = (char *)v11 + 4; | |
11982 ++v70; | |
11983 } | |
11984 while ( v70 < (signed int)pIndoor->uNumFaces ); | |
11985 } | |
11986 v70 = 0; | |
11987 if ( (signed int)uNumLevelDecorations > 0 ) | |
11988 { | |
11989 v68 = &pLevelDecorations[0].field_2; | |
11990 do | |
11991 { | |
11992 memcpy(v11, v68, 2u); | |
11993 v68 += 16; | |
11994 v11 = (char *)v11 + 2; | |
11995 ++v70; | |
11996 } | |
11997 while ( v70 < (signed int)uNumLevelDecorations ); | |
11998 } | |
11999 memcpy(v11, &uNumActors, 4u); | |
12000 v12 = (char *)v11 + 4; | |
12001 memcpy(v12, pActors, 836 * uNumActors); | |
12002 v13 = (char *)v12 + 836 * uNumActors; | |
12003 memcpy(v13, &uNumLayingItems, 4u); | |
12004 v13 = (char *)v13 + 4; | |
12005 memcpy(v13, pLayingItems, 112 * uNumLayingItems); | |
12006 v14 = (char *)v13 + 112 * uNumLayingItems; | |
12007 memcpy(v14, &uNumChests, 4u); | |
12008 v14 = (char *)v14 + 4; | |
12009 memcpy(v14, pChests, 5324 * uNumChests); | |
12010 v15 = (char *)v14 + 5324 * uNumChests; | |
12011 memcpy(v15, pIndoor->pDoors, 0x3E80u); | |
12012 v15 = (char *)v15 + 16000; | |
12013 memcpy(v15, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size); | |
12014 v16 = (char *)v15 + pIndoor->blv.uDoors_ddata_Size; | |
12015 memcpy(v16, &stru_5E4C90, 0xC8u); | |
12016 v17 = (int)((char *)v16 + 200); | |
12017 memcpy((void *)v17, &pIndoor->uLastVisitDay, 0x38u); | |
12018 } | |
12019 else | |
12020 { | |
12021 v18 = 0; | |
12022 pOutdoor->ddm.uNumFacesInBModels = 0; | |
12023 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
12024 { | |
12025 v19 = pOutdoor->uNumBModels; | |
12026 v20 = (char *)&pOutdoor->pBModels->uNumFaces; | |
12027 do | |
12028 { | |
12029 v18 += *(int *)v20; | |
12030 v20 += 188; | |
12031 --v19; | |
12032 pOutdoor->ddm.uNumFacesInBModels = v18; | |
12033 } | |
12034 while ( v19 ); | |
12035 } | |
12036 v21 = DstBuf; | |
12037 pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels; | |
12038 pOutdoor->ddm.uNumDecorations = uNumLevelDecorations; | |
12039 memcpy(DstBuf, &pOutdoor->ddm, 0x28u); | |
12040 v21 = (char *)v21 + 40; | |
12041 memcpy(v21, pOutdoor->array_528, 0x3C8u); | |
12042 v21 = (char *)v21 + 968; | |
12043 memcpy(v21, pOutdoor->array_8F0, 0x3C8u); | |
12044 v22 = (char *)v21 + 968; | |
12045 v70 = 0; | |
12046 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
12047 { | |
12048 v23 = pOutdoor->pBModels; | |
12049 v24 = 76; | |
12050 do | |
12051 { | |
12052 v25 = *(int *)&v23->pModelName[v24] == 0; | |
12053 v26 = *(int *)&v23->pModelName[v24] < 0; | |
12054 v66 = 0; | |
12055 if ( !(v26 | v25) ) | |
12056 { | |
12057 v68 = 0; | |
12058 do | |
12059 { | |
12060 v38 = (char *)v68 + *(int *)&v23->pModelName[v24 + 8] + 28; | |
12061 memcpy(v22, v38, 4u); | |
12062 v23 = pOutdoor->pBModels; | |
12063 v68 += 154; | |
12064 v22 = (char *)v22 + 4; | |
12065 v66 = (__int16 *)((char *)v66 + 1); | |
12066 } | |
12067 while ( (signed int)v66 < *(int *)&pOutdoor->pBModels->pModelName[v24] ); | |
12068 } | |
12069 ++v70; | |
12070 v24 += 188; | |
12071 } | |
12072 while ( v70 < (signed int)pOutdoor->uNumBModels ); | |
12073 } | |
12074 v27 = 0; | |
12075 if ( (signed int)uNumLevelDecorations > 0 ) | |
12076 { | |
12077 v66 = &pLevelDecorations[0].field_2; | |
12078 do | |
12079 { | |
12080 memcpy(v22, v66, 2u); | |
12081 v66 += 16; | |
12082 v22 = (char *)v22 + 2; | |
12083 ++v27; | |
12084 } | |
12085 while ( v27 < (signed int)uNumLevelDecorations ); | |
12086 } | |
12087 memcpy(v22, &uNumActors, 4u); | |
12088 v28 = (char *)v22 + 4; | |
12089 memcpy(v28, pActors, 836 * uNumActors); | |
12090 v29 = (char *)v28 + 836 * uNumActors; | |
12091 memcpy(v29, &uNumLayingItems, 4u); | |
12092 v29 = (char *)v29 + 4; | |
12093 memcpy(v29, pLayingItems, 112 * uNumLayingItems); | |
12094 v30 = (char *)v29 + 112 * uNumLayingItems; | |
12095 memcpy(v30, &uNumChests, 4u); | |
12096 v30 = (char *)v30 + 4; | |
12097 memcpy(v30, pChests, 5324 * uNumChests); | |
12098 v31 = (char *)v30 + 5324 * uNumChests; | |
12099 memcpy(v31, &stru_5E4C90, 0xC8u); | |
12100 v17 = (int)((char *)v31 + 200); | |
12101 memcpy((void *)v17, &pOutdoor->uLastVisitDay, 0x38u); | |
12102 v9 = (int)v71; | |
12103 } | |
12104 v32 = v17 + 56; | |
12105 strcpy(Source, pCurrentMapName); | |
12106 _splitpath(Source, &Drive, &Dir, &Filename, &Ext); | |
12107 v48 = 100; | |
12108 Size = v32 - (int)DstBuf; | |
12109 v69 = 999984; | |
12110 LOBYTE(v33) = zlib::MemZip((char *)v9 + 16, (unsigned int *)&v69, DstBuf, v32 - (int)DstBuf); | |
12111 if ( v33 || (signed int)v69 > (signed int)Size ) | |
12112 { | |
12113 memcpy((void *)(v9 + 16), DstBuf, Size); | |
12114 v69 = Size; | |
12115 } | |
12116 v69 += 16; | |
12117 memcpy((void *)(v9 + 8), &v69, 4u); | |
12118 memcpy((void *)(v9 + 12), &Size, 4u); | |
12119 sprintfex(Source, "%s%s", &Filename, &Ext); | |
12120 strcpy((char *)&pDir, Source); | |
12121 pDir.uDataSize = v69; | |
12122 if ( pNew_LOD->Write(&pDir, (const void *)v9, 0) ) | |
12123 { | |
12124 v39 = 208; | |
12125 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 208); | |
12126 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0); | |
12127 } | |
12128 free((void *)v9); | |
12129 } | |
12130 free(DstBuf); | |
12131 if ( v64 ) | |
12132 { | |
12133 if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) ) | |
12134 { | |
12135 v34 = GetLastError(); | |
12136 FormatMessageA(0x1000u, 0, v34, 0x400u, &Buffer, 0x80u, 0); | |
12137 v39 = 300; | |
12138 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 300); | |
12139 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0); | |
12140 } | |
12141 } | |
12142 pParty->vPosition.x = v52; | |
12143 pParty->vPosition.z = v51; | |
12144 pParty->vPosition.y = v62; | |
12145 pParty->uFallStartY = v62; | |
12146 pParty->sRotationY = v53; | |
12147 result = v54; | |
12148 pParty->sRotationX = v54; | |
12149 } | |
12150 return result; | |
12151 } | |
12152 // 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions; | |
12153 | |
12154 //----- (00460078) -------------------------------------------------------- | |
12155 void __fastcall DoSavegame(unsigned int uSlot) | |
12156 { | |
12157 unsigned int v1; // esi@1 | |
12158 int v2; // esi@2 | |
12159 RGBTexture *v3; // ebx@3 | |
12160 int bNotArena; // [sp+2Ch] [bp-8h]@1 | |
12161 unsigned int v6; // [sp+30h] [bp-4h]@1 | |
12162 | |
12163 v1 = uSlot; | |
12164 v6 = uSlot; | |
12165 bNotArena = _strcmpi(pCurrentMapName, "d05.blv"); | |
12166 if ( bNotArena ) | |
12167 { | |
12168 LOD::Directory pDir; // [sp+Ch] [bp-28h]@2 | |
12169 SaveGame(0, 0); | |
12170 v2 = 100 * v1; | |
12171 strcpy(&pSavegameHeader->pLocationName[v2], pCurrentMapName); | |
12172 *(int *)((char *)&pSavegameHeader->uWordTime + v2) = LODWORD(pParty->uTimePlayed); | |
12173 *(int *)((char *)&pSavegameHeader->uWordTime + v2 + 4) = HIDWORD(pParty->uTimePlayed); | |
12174 strcpy((char *)&pDir, "header.bin"); | |
12175 pDir.uDataSize = 100; | |
12176 pNew_LOD->Write(&pDir, (char *)&pSavegameHeader + v2, 0); | |
12177 sprintfex(pTmpBuf, "saves\\save%03d.mm7", v6); | |
12178 pNew_LOD->CloseWriteFile(); | |
12179 CopyFileA("data\\new.lod", pTmpBuf, 0); | |
12180 } | |
12181 GUI_UpdateWindows(); | |
12182 pGUIWindow_CurrentMenu->Release(); | |
12183 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0; | |
12184 v3 = pSavegameThumbnails; | |
12185 viewparams->bRedrawGameUI = 1; | |
12186 do | |
12187 { | |
12188 v3->Release(); | |
12189 ++v3; | |
12190 } | |
12191 while ( (signed int)v3 < (signed int)&unk_6A0758 ); | |
12192 if ( bNotArena ) | |
12193 pNew_LOD->_4621A7(); | |
12194 else | |
12195 ShowStatusBarString(pGlobalTXT_LocalizationStrings[583], 2u);// "No saving in the Arena" | |
12196 pIcons_LOD->_4355F7(); | |
12197 pEventTimer->Resume(); | |
12198 ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2u);// "Game Saved!" | |
12199 viewparams->bRedrawGameUI = 1; | |
12200 } | |
12201 // 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions; | |
12202 | |
12203 //----- (004601B7) -------------------------------------------------------- | 11449 //----- (004601B7) -------------------------------------------------------- |
12204 void GameUI_MainMenu_DoDrawLoad(int a1) | 11450 void GameUI_MainMenu_DoDrawLoad(int a1) |
12205 { | 11451 { |
12206 unsigned __int16 v1; // bx@1 | 11452 unsigned __int16 v1; // bx@1 |
12207 unsigned int v2; // edi@4 | 11453 unsigned int v2; // edi@4 |
13303 | 12549 |
13304 stru_506F20.Release(); | 12550 stru_506F20.Release(); |
13305 stru_506F20.Load("title.pcx", 0); | 12551 stru_506F20.Load("title.pcx", 0); |
13306 SetCurrentMenuID(MENU_MAIN); | 12552 SetCurrentMenuID(MENU_MAIN); |
13307 SetForegroundWindow(hWnd); | 12553 SetForegroundWindow(hWnd); |
13308 SendMessageA(hWnd, WM_ACTIVATEAPP, 1, 0); | 12554 SendMessageW(hWnd, WM_ACTIVATEAPP, 1, 0); |
13309 while (GetCurrentMenuID() == MENU_MAIN || | 12555 while (GetCurrentMenuID() == MENU_MAIN || |
13310 GetCurrentMenuID() == MENU_SAVELOAD) | 12556 GetCurrentMenuID() == MENU_SAVELOAD) |
13311 { | 12557 { |
13312 POINT pt; | 12558 POINT pt; |
13313 pMouse->GetCursorPos(&pt); | 12559 pMouse->GetCursorPos(&pt); |
13353 { | 12599 { |
13354 LABEL_45: | 12600 LABEL_45: |
13355 if (GetCurrentMenuID() == MENU_LOAD) | 12601 if (GetCurrentMenuID() == MENU_LOAD) |
13356 { | 12602 { |
13357 pIcons_LOD->_4114F2(); | 12603 pIcons_LOD->_4114F2(); |
13358 crt_deconstruct_ptr_6A0118(); | |
13359 pGUIWindow_CurrentMenu->Release(); | 12604 pGUIWindow_CurrentMenu->Release(); |
13360 pGUIWindow_CurrentMenu = 0; | 12605 pGUIWindow_CurrentMenu = 0; |
13361 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0; | 12606 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0; |
13362 viewparams->bRedrawGameUI = 1; | 12607 viewparams->bRedrawGameUI = 1; |
13363 } | 12608 } |
15596 viewparams->uSomeY = viewparams->uScreenY; | 14841 viewparams->uSomeY = viewparams->uScreenY; |
15597 viewparams->uSomeX = viewparams->uScreenX; | 14842 viewparams->uSomeX = viewparams->uScreenX; |
15598 viewparams->uSomeZ = viewparams->uScreenZ; | 14843 viewparams->uSomeZ = viewparams->uScreenZ; |
15599 viewparams->uSomeW = viewparams->uScreenW; | 14844 viewparams->uSomeW = viewparams->uScreenW; |
15600 | 14845 |
15601 pViewport = new Viewport; | |
15602 pViewport->SetScreen(viewparams->uScreenX, viewparams->uScreenY, viewparams->uScreenZ, viewparams->uScreenW); | 14846 pViewport->SetScreen(viewparams->uScreenX, viewparams->uScreenY, viewparams->uScreenZ, viewparams->uScreenW); |
15603 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | 14847 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) |
15604 pOutdoorCamera->_485F64(); | 14848 pOutdoorCamera->_485F64(); |
15605 } | 14849 } |
15606 | 14850 |
16998 return 1; | 16242 return 1; |
16999 v24 = (int)pItemsTable->pItems[v20].pUnidentifiedName; | 16243 v24 = (int)pItemsTable->pItems[v20].pUnidentifiedName; |
17000 sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], v24); | 16244 sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], v24); |
17001 ShowStatusBarString(pTmpBuf2, 2u); | 16245 ShowStatusBarString(pTmpBuf2, 2u); |
17002 if ( v19->uItemID == 506 ) | 16246 if ( v19->uItemID == 506 ) |
17003 _449B7E_toggle_bit((char *)pParty->_award_bits, 184, 1u); | 16247 _449B7E_toggle_bit(pParty->_award_bits, 184, 1u); |
17004 if ( v19->uItemID == 455 ) | 16248 if ( v19->uItemID == 455 ) |
17005 _449B7E_toggle_bit((char *)pParty->_award_bits, 185, 1u); | 16249 _449B7E_toggle_bit(pParty->_award_bits, 185, 1u); |
17006 if ( !pParty->AddItem(v19) ) | 16250 if ( !pParty->AddItem(v19) ) |
17007 pParty->SetHoldingItem(v19); | 16251 pParty->SetHoldingItem(v19); |
17008 v21 = v26; | 16252 v21 = v26; |
17009 } | 16253 } |
17010 LayingItem::_42F933(v21); | 16254 LayingItem::_42F933(v21); |