comparison SaveLoad.cpp @ 117:a64b244da76c

some things lod
author Nomad
date Tue, 13 Nov 2012 17:29:38 +0200
parents e5d6903a077a
children 062e8a8e09bc
comparison
equal deleted inserted replaced
116:918dca162239 117:a64b244da76c
1 #include <io.h> 1 #include <io.h>
2 #include <direct.h> 2 #include <direct.h>
3 #include <assert.h>
3 4
4 #include "SaveLoad.h" 5 #include "SaveLoad.h"
5 #include "NPC.h" 6 #include "NPC.h"
6 #include "Party.h" 7 #include "Party.h"
7 #include "LOD.h" 8 #include "LOD.h"
44 { 45 {
45 bool v25; // esi@62 46 bool v25; // esi@62
46 bool v26; // eax@62 47 bool v26; // eax@62
47 int v30; // [sp-Ch] [bp-FCh]@65 48 int v30; // [sp-Ch] [bp-FCh]@65
48 int v31; // [sp-8h] [bp-F8h]@4 49 int v31; // [sp-8h] [bp-F8h]@4
49 char DstBuf[100]; // [sp+Ch] [bp-E4h]@23 50 SavegameHeader header; // [sp+Ch] [bp-E4h]@23
50 char Str[123]; // [sp+70h] [bp-80h]@25 51 char Str[123]; // [sp+70h] [bp-80h]@25
51 52
52 dword_5B65C8 = 0; 53 dword_5B65C8 = 0;
53 if (!pSavegameUsedSlots[uSlot]) 54 if (!pSavegameUsedSlots[uSlot])
54 { 55 {
95 { 96 {
96 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 100); 97 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 100);
97 Log::Warning(L"%S", Str); 98 Log::Warning(L"%S", Str);
98 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:549", 0); 99 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:549", 0);
99 } 100 }
100 fread(&DstBuf, 0x64u, 1u, f); 101 assert(sizeof(SavegameHeader) == 100);
102 fread(&header, sizeof(SavegameHeader), 1, f);
101 103
102 f = pNew_LOD->FindContainer("party.bin", 1); 104 f = pNew_LOD->FindContainer("party.bin", 1);
103 if (!f) 105 if (!f)
104 { 106 {
105 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 101); 107 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 101);
196 SetUserInterface(pParty->uAlignment, true); 198 SetUserInterface(pParty->uAlignment, true);
197 199
198 pEventTimer->Resume(); 200 pEventTimer->Resume();
199 pEventTimer->StopGameTime(); 201 pEventTimer->StopGameTime();
200 202
201 v25 = pGames_LOD->DoesContainerExist(&DstBuf[20]); 203 v25 = pGames_LOD->DoesContainerExist(header.pLocationName);
202 sprintf(pTmpBuf, "levels\\%s", &DstBuf[20]); 204 sprintf(pTmpBuf, "levels\\%s", header.pLocationName);
203 v26 = _access(pTmpBuf, 4) != -1; 205 v26 = _access(pTmpBuf, 4) != -1;
204 if ( !v25 && !v26 ) 206 if ( !v25 && !v26 )
205 { 207 {
206 sprintf(pTmpBuf, "Unable to find: %s!", &DstBuf[20]); 208 sprintf(pTmpBuf, "Unable to find: %s!", header.pLocationName);
207 Abortf(pTmpBuf); 209 Abortf(pTmpBuf);
208 } 210 }
209 211
210 strcpy(pCurrentMapName, &DstBuf[20]); 212 strcpy(pCurrentMapName, header.pLocationName);
211 dword_6BE364_game_settings_1 |= 0x2001; 213 dword_6BE364_game_settings_1 |= 0x2001;
212 214
213 for (uint i = 0; i < uNumSavegameFiles; ++i) 215 for (uint i = 0; i < uNumSavegameFiles; ++i)
214 pSavegameThumbnails[i].Release(); 216 pSavegameThumbnails[i].Release();
215 217
258 void *v30; // esi@50 260 void *v30; // esi@50
259 void *v31; // esi@50 261 void *v31; // esi@50
260 int v32; // esi@51 262 int v32; // esi@51
261 int v33; // eax@51 263 int v33; // eax@51
262 DWORD v34; // eax@59 264 DWORD v34; // eax@59
263 std::string v35; // [sp-18h] [bp-288h]@8 265 //std::string v35; // [sp-18h] [bp-288h]@8
264 const char *v36; // [sp-10h] [bp-280h]@6 266 const char *v36; // [sp-10h] [bp-280h]@6
265 const char *v37; // [sp-Ch] [bp-27Ch]@6 267 const char *v37; // [sp-Ch] [bp-27Ch]@6
266 const char *v38; // [sp-8h] [bp-278h]@8 268 const char *v38; // [sp-8h] [bp-278h]@8
267 CHAR Buffer; // [sp+Ch] [bp-264h]@59 269 CHAR Buffer; // [sp+Ch] [bp-264h]@59
268 char Dir; // [sp+8Ch] [bp-1E4h]@51 270 char Dir; // [sp+8Ch] [bp-1E4h]@51
269 char Drive; // [sp+ACh] [bp-1C4h]@51 271 char Drive; // [sp+ACh] [bp-1C4h]@51
270 int v43; // [sp+CCh] [bp-1A4h]@10 272 SavegameHeader header; // [sp+CCh] [bp-1A4h]@10
271 char Dest[20]; // [sp+E0h] [bp-190h]@10 273 //int v43; // [sp+CCh] [bp-1A4h]@10
272 unsigned __int64 pTimePlayed; // [sp+F4h] [bp-17Ch]@10 274 //char Dest[20]; // [sp+E0h] [bp-190h]@10
275 //unsigned __int64 pTimePlayed; // [sp+F4h] [bp-17Ch]@10
273 char Filename; // [sp+130h] [bp-140h]@51 276 char Filename; // [sp+130h] [bp-140h]@51
274 char Ext; // [sp+150h] [bp-120h]@51 277 char Ext; // [sp+150h] [bp-120h]@51
275 char v48; // [sp+151h] [bp-11Fh]@51 278 char v48; // [sp+151h] [bp-11Fh]@51
276 char Source[32]; // [sp+170h] [bp-100h]@51 279 char Source[32]; // [sp+170h] [bp-100h]@51
277 char Str[120]; // [sp+190h] [bp-E0h]@8 280 char Str[120]; // [sp+190h] [bp-E0h]@8
320 pOutdoor->uLastVisitDay = pParty->uTimePlayed; 323 pOutdoor->uLastVisitDay = pParty->uTimePlayed;
321 pScreenshot = MakeScreenshot(150, 112); 324 pScreenshot = MakeScreenshot(150, 112);
322 strcpy(pDir.pFilename, "image.pcx"); 325 strcpy(pDir.pFilename, "image.pcx");
323 pRenderer->_49F5A2((int)pScreenshot, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize); 326 pRenderer->_49F5A2((int)pScreenshot, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize);
324 free(pScreenshot); 327 free(pScreenshot);
325 if ( pCurrentScreen == 11 )//SaveScreen 328 if (pCurrentScreen == 11) //SaveScreen
326 { 329 {
327 pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); 330 pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
328 pRenderer->DrawTextureIndexed(0x12, 0x8D, (Texture *)(uTextureID_save_up != -1 ? &pIcons_LOD->pTextures[uTextureID_save_up] : 0)); 331 pRenderer->DrawTextureIndexed(0x12, 0x8D, (Texture *)(uTextureID_save_up != -1 ? &pIcons_LOD->pTextures[uTextureID_save_up] : 0));
329 v4 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[190]); 332 v4 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[190]);
330 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v4 + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Сохранение 333 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v4 + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Сохранение
332 pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v5 + 25, 0x103u, 0, (const char *)(&pSavegameHeader + uLoadGameUI_SelectedSlot), 185, 0); 335 pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v5 + 25, 0x103u, 0, (const char *)(&pSavegameHeader + uLoadGameUI_SelectedSlot), 185, 0);
333 v6 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[165]); 336 v6 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[165]);
334 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v6 + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Пожалуйста, подождите 337 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v6 + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Пожалуйста, подождите
335 pRenderer->Present(); 338 pRenderer->Present();
336 } 339 }
337 if ( pNew_LOD->Write(&pDir, DstBuf, 0) ) 340 if (pNew_LOD->Write(&pDir, DstBuf, 0))
338 { 341 {
339 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200); //Сохраненная игра повреждена! Code=%d 342 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200); //Сохраненная игра повреждена! Code=%d
340 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0); 343 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
341 } 344 }
342 strcpy(Dest, pCurrentMapName); 345
343 pTimePlayed = pParty->uTimePlayed; 346 assert(sizeof(SavegameHeader) == 100);
344 strcpy((char *)&pDir, "header.bin"); 347 strcpy(header.pLocationName, pCurrentMapName);
345 pDir.uDataSize = 100; 348 header.uWordTime = pParty->uTimePlayed;
346 if ( pNew_LOD->Write(&pDir, &v43, 0) ) 349 strcpy(pDir.pFilename, "header.bin");
350 pDir.uDataSize = sizeof(SavegameHeader);
351 if (pNew_LOD->Write(&pDir, &header, 0))
347 { 352 {
348 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 201); 353 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 201);
349 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0); 354 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0);
350 } 355 }
351 strcpy((char *)&pDir, "party.bin"); 356 strcpy(pDir.pFilename, "party.bin");
352 pDir.uDataSize = 90680; 357 pDir.uDataSize = 90680;
353 if ( pNew_LOD->Write(&pDir, &pParty, 0) ) 358 if ( pNew_LOD->Write(&pDir, pParty, 0) )
354 { 359 {
355 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 202); 360 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 202);
356 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0); 361 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0);
357 } 362 }
358 strcpy((char *)&pDir, "clock.bin"); 363 strcpy(pDir.pFilename, "clock.bin");
359 pDir.uDataSize = 40; 364 pDir.uDataSize = 40;
360 if ( pNew_LOD->Write(&pDir, &pEventTimer, 0) ) 365 if ( pNew_LOD->Write(&pDir, pEventTimer, 0) )
361 { 366 {
362 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 203); 367 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 203);
363 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0); 368 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0);
364 } 369 }
365 strcpy((char *)&pDir, "overlay.bin"); 370 strcpy(pDir.pFilename, "overlay.bin");
366 pDir.uDataSize = 1008; 371 pDir.uDataSize = 1008;
367 if ( pNew_LOD->Write(&pDir, &pOtherOverlayList, 0) ) 372 if ( pNew_LOD->Write(&pDir, pOtherOverlayList, 0) )
368 { 373 {
369 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 204); 374 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 204);
370 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0); 375 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0);
371 } 376 }
372 strcpy((char *)&pDir, "npcdata.bin"); 377 strcpy(pDir.pFilename, "npcdata.bin");
373 pDir.uDataSize = 38076; 378 pDir.uDataSize = 38076;
374 if ( pNew_LOD->Write(&pDir, pNPCStats->pNewNPCData, 0) ) 379 if ( pNew_LOD->Write(&pDir, pNPCStats->pNewNPCData, 0) )
375 { 380 {
376 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205); 381 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205);
377 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0); 382 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0);
378 } 383 }
379 strcpy((char *)&pDir, "npcgroup.bin"); 384 strcpy(pDir.pFilename, "npcgroup.bin");
380 pDir.uDataSize = 102; 385 pDir.uDataSize = 102;
381 if ( pNew_LOD->Write(&pDir, pNPCStats->pGroups_copy, 0) ) 386 if ( pNew_LOD->Write(&pDir, pNPCStats->pGroups_copy, 0) )
382 { 387 {
383 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 206); 388 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 206);
384 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0); 389 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0);
389 { 394 {
390 sprintf(Str, "data\\lloyd%d%d.pcx", i, j); 395 sprintf(Str, "data\\lloyd%d%d.pcx", i, j);
391 v8 = fopen(Str, "rb"); 396 v8 = fopen(Str, "rb");
392 if ( v8 ) 397 if ( v8 )
393 { 398 {
399 __debugbreak();
394 sprintf(Str, "lloyd%d%d.pcx", i, j); 400 sprintf(Str, "lloyd%d%d.pcx", i, j);
395 fseek(v8, 0, 2); 401 fseek(v8, 0, 2);
396 pDir.uDataSize = ftell(v8); 402 pDir.uDataSize = ftell(v8);
397 rewind(v8); 403 rewind(v8);
398 fread(DstBuf, pDir.uDataSize, 1, v8); 404 fread(DstBuf, pDir.uDataSize, 1, v8);
408 } 414 }
409 } 415 }
410 } 416 }
411 if ( !a2 ) 417 if ( !a2 )
412 { 418 {
419 __debugbreak();
413 sub_42FA22_mess_with_laying_item_list(); 420 sub_42FA22_mess_with_laying_item_list();
414 v9 = (int)malloc(0xF4240); 421 v9 = (int)malloc(0xF4240);
415 v71 = (std::string *)v9; 422 v71 = (std::string *)v9;
416 Src = 91969; 423 Src = 91969;
417 v56 = 109; 424 v56 = 109;
421 v60 = 0; 428 v60 = 0;
422 v61 = 0; 429 v61 = 0;
423 memcpy((void *)v9, &Src, 0x10); 430 memcpy((void *)v9, &Src, 0x10);
424 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) 431 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
425 { 432 {
433 __debugbreak();
426 pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces; 434 pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces;
427 pIndoor->dlv.uNumBModels = 0; 435 pIndoor->dlv.uNumBModels = 0;
428 pIndoor->dlv.uNumDecorations = uNumLevelDecorations; 436 pIndoor->dlv.uNumDecorations = uNumLevelDecorations;
429 memcpy(DstBuf, &pIndoor->dlv, 0x28); 437 memcpy(DstBuf, &pIndoor->dlv, 0x28);
430 v10 = (char *)DstBuf + 40; 438 v10 = (char *)DstBuf + 40;
601 int v2; // esi@2 609 int v2; // esi@2
602 RGBTexture *v3; // ebx@3 610 RGBTexture *v3; // ebx@3
603 int bNotArena; // [sp+2Ch] [bp-8h]@1 611 int bNotArena; // [sp+2Ch] [bp-8h]@1
604 unsigned int v6; // [sp+30h] [bp-4h]@1 612 unsigned int v6; // [sp+30h] [bp-4h]@1
605 613
614 __debugbreak();
615
606 v1 = uSlot; 616 v1 = uSlot;
607 v6 = uSlot; 617 v6 = uSlot;
608 bNotArena = _strcmpi(pCurrentMapName, "d05.blv"); 618 bNotArena = _strcmpi(pCurrentMapName, "d05.blv");
609 if ( bNotArena ) 619 if ( bNotArena )
610 { 620 {