comparison SaveLoad.cpp @ 87:c0cf9393af64

Слияние
author Ritor1
date Mon, 29 Oct 2012 09:28:08 +0600
parents a84fb3752681
children 6c42178c226e 51a5b0dc3f30
comparison
equal deleted inserted replaced
86:c83d06692295 87:c0cf9393af64
40 40
41 41
42 //----- (0045EE8A) -------------------------------------------------------- 42 //----- (0045EE8A) --------------------------------------------------------
43 void __fastcall LoadGame(unsigned int uSlot) 43 void __fastcall LoadGame(unsigned int uSlot)
44 { 44 {
45 //unsigned int v1; // ebx@1
46 //char v2; // zf@1
47 //signed int v3; // esi@3
48 //signed int v4; // esi@8
49 //char *v5; // eax@9
50 //unsigned int v6; // eax@12
51 //unsigned int v7; // esi@13
52 //char *v8; // ecx@14
53 //FILE *v9; // eax@22
54 //FILE *v10; // eax@26
55 //FILE *v11; // eax@29
56 //FILE *v12; // eax@32
57 //FILE *v13; // eax@35
58 //FILE *v14; // eax@38
59 //unsigned int v15; // edi@41
60 //Player *v16; // esi@41
61 //int *v17; // esi@46
62 //int v18; // edi@46
63 //int v19; // ebx@46
64 //int v20; // ecx@49
65 //int v21; // eax@51
66 //int v22; // ecx@56
67 //bool v23; // edx@56
68 //AudioPlayer *v24; // ebx@60
69 bool v25; // esi@62 45 bool v25; // esi@62
70 bool v26; // eax@62 46 bool v26; // eax@62
71 //signed int v27; // esi@66
72 //RGBTexture *v28; // edi@67
73 std::string v29; // [sp-18h] [bp-108h]@25
74 int v30; // [sp-Ch] [bp-FCh]@65 47 int v30; // [sp-Ch] [bp-FCh]@65
75 int v31; // [sp-8h] [bp-F8h]@4 48 int v31; // [sp-8h] [bp-F8h]@4
76 //signed int v32; // [sp-4h] [bp-F4h]@4
77 char DstBuf[100]; // [sp+Ch] [bp-E4h]@23 49 char DstBuf[100]; // [sp+Ch] [bp-E4h]@23
78 //char pContainer; // [sp+20h] [bp-D0h]@62
79 char Str[123]; // [sp+70h] [bp-80h]@25 50 char Str[123]; // [sp+70h] [bp-80h]@25
80 //char a3[5]; // [sp+EBh] [bp-5h]@2 51
81
82 //v1 = uSlot;
83 //v2 = pSavegameUsedSlots[uSlot] == 0;
84 dword_5B65C8 = 0; 52 dword_5B65C8 = 0;
85 if (!pSavegameUsedSlots[uSlot]) 53 if (!pSavegameUsedSlots[uSlot])
86 { 54 {
87 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); 55 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
88 Log::Warning(L"LoadGame: slot %u is empty", uSlot); 56 Log::Warning(L"LoadGame: slot %u is empty", uSlot);
219 } 187 }
220 } 188 }
221 189
222 190
223 pGUIWindow_CurrentMenu->Release(); 191 pGUIWindow_CurrentMenu->Release();
224 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0; 192 pCurrentScreen = 0;
225 193
226 viewparams->bRedrawGameUI = true; 194 viewparams->bRedrawGameUI = true;
227 195
228 SetUserInterface(pParty->uAlignment, true); 196 SetUserInterface(pParty->uAlignment, true);
229 197
319 char v59; // [sp+21Fh] [bp-51h]@30 287 char v59; // [sp+21Fh] [bp-51h]@30
320 int v60; // [sp+220h] [bp-50h]@30 288 int v60; // [sp+220h] [bp-50h]@30
321 int v61; // [sp+224h] [bp-4Ch]@30 289 int v61; // [sp+224h] [bp-4Ch]@30
322 int v62; // [sp+228h] [bp-48h]@2 290 int v62; // [sp+228h] [bp-48h]@2
323 LOD::Directory pDir; // [sp+22Ch] [bp-44h]@2 291 LOD::Directory pDir; // [sp+22Ch] [bp-44h]@2
324 std::string *v64; // [sp+24Ch] [bp-24h]@1 292 //std::string *v64; // [sp+24Ch] [bp-24h]@1
325 size_t Size; // [sp+250h] [bp-20h]@26 293 size_t Size; // [sp+250h] [bp-20h]@26
326 __int16 *v66; // [sp+254h] [bp-1Ch]@1 294 __int16 *v66; // [sp+254h] [bp-1Ch]@1
327 void *DstBuf; // [sp+258h] [bp-18h]@2 295 void *DstBuf; // [sp+258h] [bp-18h]@2
328 __int16 *v68; // [sp+25Ch] [bp-14h]@32 296 __int16 *v68; // [sp+25Ch] [bp-14h]@32
329 unsigned int v69; // [sp+260h] [bp-10h]@23 297 unsigned int v69; // [sp+260h] [bp-10h]@23
330 int v70; // [sp+264h] [bp-Ch]@22 298 int v70; // [sp+264h] [bp-Ch]@22
331 std::string *v71; // [sp+268h] [bp-8h]@8 299 std::string *v71; // [sp+268h] [bp-8h]@8
332 int a3; // [sp+26Fh] [bp-1h]@8 300 int a3; // [sp+26Fh] [bp-1h]@8
333 301
334 v66 = a2; 302 v66 = a2;
335 v64 = (std::string *)a1; 303 //v64 = (std::string *)a1;
304
336 strcpy(byte_6BE3B0, pCurrentMapName); 305 strcpy(byte_6BE3B0, pCurrentMapName);
337 result = _strcmpi(pCurrentMapName, "d05.blv"); 306 if (!_strcmpi(pCurrentMapName, "d05.blv"))
338 if ( result ) 307 return false;
339 { 308
340 DstBuf = operator new(0xF4240u); 309 DstBuf = malloc(0xF4240u);
341 pDir.Reset(); 310 pDir.Reset();
342 v52 = pParty->vPosition.x; 311 v52 = pParty->vPosition.x;
343 v51 = pParty->vPosition.z; 312 v51 = pParty->vPosition.y;
344 v62 = pParty->vPosition.y; 313 v62 = pParty->vPosition.z;
345 v53 = pParty->sRotationY; 314 v53 = pParty->sRotationY;
346 v54 = pParty->sRotationX; 315 v54 = pParty->sRotationX;
347 pParty->vPosition.x = pParty->vPrevPosition.x; 316 pParty->vPosition.x = pParty->vPrevPosition.x;
348 pParty->vPosition.z = pParty->vPrevPosition.z; 317 pParty->vPosition.y = pParty->vPrevPosition.z;
349 pParty->vPosition.y = pParty->vPrevPosition.y; 318 pParty->vPosition.z = pParty->vPrevPosition.y;
350 pParty->uFallStartY = pParty->vPrevPosition.y; 319 pParty->uFallStartY = pParty->vPrevPosition.y;
351 pParty->sRotationY = pParty->sPrevRotationY; 320 pParty->sRotationY = pParty->sPrevRotationY;
352 pParty->sRotationX = pParty->sPrevRotationX; 321 pParty->sRotationX = pParty->sPrevRotationX;
353 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) 322
354 pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed; 323 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
355 else 324 pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed;
356 pOutdoor->uLastVisitDay = pParty->uTimePlayed; 325 else
357 v3 = MakeScreenshot(150, 112); 326 pOutdoor->uLastVisitDay = pParty->uTimePlayed;
358 strcpy((char *)&pDir, "image.pcx"); 327
328 v3 = MakeScreenshot(150, 112);
329 {
330 strcpy(pDir.pFilename, "image.pcx");
331
359 pRenderer->_49F5A2((int)v3, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize); 332 pRenderer->_49F5A2((int)v3, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize);
360 free(v3); 333 }
361 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 11 ) 334 free(v3);
335
336 if ( pCurrentScreen == 11 )
362 { 337 {
363 pRenderer->DrawTextureIndexed( 338 pRenderer->DrawTextureIndexed(
364 8u, 339 8u,
365 8u, 340 8u,
366 (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); 341 (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
367 pRenderer->DrawTextureIndexed( 342 pRenderer->DrawTextureIndexed(
368 0x12u, 343 0x12u,
369 0x8Du, 344 0x8Du,
370 (Texture *)(uTextureID_save_up != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_save_up] : 0)); 345 (Texture *)(uTextureID_save_up != -1 ? &pIcons_LOD->pTextures[uTextureID_save_up] : 0));
371 v36 = pGlobalTXT_LocalizationStrings[190]; 346 v36 = pGlobalTXT_LocalizationStrings[190];
372 v4 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[190]); 347 v4 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[190]);
373 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v4 + 25, 219, 0, v36, 0, 0, 0); 348 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v4 + 25, 219, 0, v36, 0, 0, 0);
374 v37 = (const char *)(&pSavegameHeader + uLoadGameUI_SelectedSlot); 349 v37 = (const char *)(&pSavegameHeader + uLoadGameUI_SelectedSlot);
375 v5 = pFontSmallnum->AlignText_Center(0xBAu, 350 v5 = pFontSmallnum->AlignText_Center(0xBAu,
445 v69 = 1; 420 v69 = 1;
446 do 421 do
447 { 422 {
448 v39 = v69; 423 v39 = v69;
449 v38 = (const char *)v70; 424 v38 = (const char *)v70;
450 sprintfex(Str, "data\\lloyd%d%d.pcx", v70, v69); 425 sprintf(Str, "data\\lloyd%d%d.pcx", v70, v69);
451 v8 = fopen(Str, "rb"); 426 v8 = fopen(Str, "rb");
452 if ( v8 ) 427 if ( v8 )
453 { 428 {
454 v39 = v69; 429 v39 = v69;
455 v38 = (const char *)v70; 430 v38 = (const char *)v70;
456 sprintfex(Str, "lloyd%d%d.pcx", v70, v69); 431 sprintf(Str, "lloyd%d%d.pcx", v70, v69);
457 fseek(v8, 0, 2); 432 fseek(v8, 0, 2);
458 pDir.uDataSize = ftell(v8); 433 pDir.uDataSize = ftell(v8);
459 rewind(v8); 434 rewind(v8);
460 fread(DstBuf, pDir.uDataSize, 1u, v8); 435 fread(DstBuf, pDir.uDataSize, 1u, v8);
461 strcpy((char *)&pDir, Str); 436 strcpy((char *)&pDir, Str);
462 fclose(v8); 437 fclose(v8);
463 remove(Str); 438 remove(Str);
464 if ( pNew_LOD->Write(&pDir, DstBuf, 0) ) 439 if ( pNew_LOD->Write(&pDir, DstBuf, 0) )
465 { 440 {
466 v39 = 207; 441 v39 = 207;
467 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 207); 442 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 207);
468 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0); 443 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0);
469 Size = 5080748; 444 Size = 5080748;
470 } 445 }
471 } 446 }
472 ++v69; 447 ++v69;
473 } 448 }
474 while ( (signed int)v69 <= 5 ); 449 while ( (signed int)v69 <= 5 );
475 ++v70; 450 ++v70;
476 } 451 }
477 while ( v70 <= 4 ); 452 while ( v70 <= 4 );
478 if ( !v66 ) 453 if ( !a2 )
479 { 454 {
480 sub_42FA22_mess_with_laying_item_list(); 455 sub_42FA22_mess_with_laying_item_list();
481 v9 = (int)malloc(0xF4240u); 456 v9 = (int)malloc(0xF4240u);
482 v71 = (std::string *)v9; 457 v71 = (std::string *)v9;
483 Src = 91969; 458 Src = 91969;
655 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0); 630 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0);
656 } 631 }
657 free((void *)v9); 632 free((void *)v9);
658 } 633 }
659 free(DstBuf); 634 free(DstBuf);
660 if ( v64 ) 635 if ( a1 )
661 { 636 {
662 if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) ) 637 if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) )
663 { 638 {
664 v34 = GetLastError(); 639 v34 = GetLastError();
665 FormatMessageA(0x1000u, 0, v34, 0x400u, &Buffer, 0x80u, 0); 640 FormatMessageA(0x1000u, 0, v34, 0x400u, &Buffer, 0x80u, 0);
667 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 300); 642 sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 300);
668 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0); 643 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0);
669 } 644 }
670 } 645 }
671 pParty->vPosition.x = v52; 646 pParty->vPosition.x = v52;
672 pParty->vPosition.z = v51; 647 pParty->vPosition.y = v51;
673 pParty->vPosition.y = v62; 648 pParty->vPosition.z = v62;
674 pParty->uFallStartY = v62; 649 pParty->uFallStartY = v62;
675 pParty->sRotationY = v53; 650 pParty->sRotationY = v53;
676 result = v54; 651 result = v54;
677 pParty->sRotationX = v54; 652 pParty->sRotationX = v54;
678 } 653
679 return result; 654 return result;
680 } 655 }
681 656
682 657
683 //----- (00460078) -------------------------------------------------------- 658 //----- (00460078) --------------------------------------------------------
707 pNew_LOD->CloseWriteFile(); 682 pNew_LOD->CloseWriteFile();
708 CopyFileA("data\\new.lod", pTmpBuf, 0); 683 CopyFileA("data\\new.lod", pTmpBuf, 0);
709 } 684 }
710 GUI_UpdateWindows(); 685 GUI_UpdateWindows();
711 pGUIWindow_CurrentMenu->Release(); 686 pGUIWindow_CurrentMenu->Release();
712 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0; 687 pCurrentScreen = 0;
713 v3 = pSavegameThumbnails; 688 v3 = pSavegameThumbnails;
714 viewparams->bRedrawGameUI = 1; 689 viewparams->bRedrawGameUI = 1;
715 do 690 do
716 { 691 {
717 v3->Release(); 692 v3->Release();
725 pIcons_LOD->_4355F7(); 700 pIcons_LOD->_4355F7();
726 pEventTimer->Resume(); 701 pEventTimer->Resume();
727 ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2u);// "Game Saved!" 702 ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2u);// "Game Saved!"
728 viewparams->bRedrawGameUI = 1; 703 viewparams->bRedrawGameUI = 1;
729 } 704 }
730 // 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; 705 // 4E28F8: using guessed type int pCurrentScreen;
731 706
732 707
733 708
734 709
735 710