Mercurial > mm7
annotate SaveLoad.cpp @ 1076:9b6e252658e8
more DecalBuilder
author | zipi |
---|---|
date | Sat, 25 May 2013 14:43:27 +0100 |
parents | c45d51b3f4f4 |
children | 5a59b5b2699f |
rev | line source |
---|---|
0 | 1 #include <io.h> |
2 #include <direct.h> | |
3 #include <assert.h> | |
4 | |
5 #include "SaveLoad.h" | |
1016 | 6 #include "BSPModel.h" |
0 | 7 #include "Party.h" |
8 #include "LOD.h" | |
9 #include "Outdoor.h" | |
10 #include "AudioPlayer.h" | |
11 #include "Actor.h" | |
12 #include "Chest.h" | |
13 #include "Time.h" | |
14 #include "GUIWindow.h" | |
15 #include "GUIFont.h" | |
16 #include "Overlays.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
17 #include "SpriteObject.h" |
0 | 18 #include "Viewport.h" |
19 #include "stru123.h" | |
189 | 20 #include "texts.h" |
0 | 21 #include "Log.h" |
22 | |
23 #include "mm7_data.h" | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 struct SavegameList *pSavegameList = new SavegameList; | |
30 unsigned int uNumSavegameFiles; | |
31 unsigned int pSavegameUsedSlots[45]; | |
32 struct RGBTexture pSavegameThumbnails[45]; | |
33 SavegameHeader pSavegameHeader[45]; | |
34 | |
35 | |
36 | |
37 | |
38 | |
39 | |
40 | |
41 | |
42 | |
43 | |
44 //----- (0045EE8A) -------------------------------------------------------- | |
45 void __fastcall LoadGame(unsigned int uSlot) | |
46 { | |
47 bool v25; // esi@62 | |
48 bool v26; // eax@62 | |
49 int v30; // [sp-Ch] [bp-FCh]@65 | |
50 int v31; // [sp-8h] [bp-F8h]@4 | |
51 SavegameHeader header; // [sp+Ch] [bp-E4h]@23 | |
52 char Str[123]; // [sp+70h] [bp-80h]@25 | |
53 | |
336 | 54 dword_5B65C8_timers_count = 0; |
0 | 55 if (!pSavegameUsedSlots[uSlot]) |
56 { | |
57 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); | |
58 Log::Warning(L"LoadGame: slot %u is empty", uSlot); | |
59 return; | |
60 } | |
61 | |
62 for (uint i = 1; i < 5; ++i) | |
63 for (uint j = 1; j < 6; ++j) | |
64 { | |
65 sprintf(pTmpBuf, "data\\lloyd%d%d.pcx", i, j); | |
66 remove(pTmpBuf); | |
67 } | |
68 | |
69 | |
203 | 70 if (SoundSetAction[24][0]) |
0 | 71 for (uint i = 0; i < 4; ++i) |
72 { | |
764 | 73 for (uint j = 0; j < pSoundList->sNumSounds; ++j) |
203 | 74 if (pSoundList->pSounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4998) |
0 | 75 { |
764 | 76 pSoundList->UnloadSound(j, 1); |
0 | 77 break; |
78 } | |
79 | |
764 | 80 for (uint j = 0; j < pSoundList->sNumSounds; ++j) |
203 | 81 if (pSoundList->pSounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4999) |
0 | 82 { |
764 | 83 pSoundList->UnloadSound(j, 1); |
0 | 84 break; |
85 } | |
86 } | |
87 | |
382 | 88 sprintf(pTmpBuf, "saves\\%s", pSavegameList->pFileList[uSlot].pSaveFileName); |
0 | 89 |
90 pNew_LOD->CloseWriteFile(); | |
91 if (!CopyFileA(pTmpBuf, "data\\new.lod", 0)) | |
92 int e = GetLastError(); | |
93 | |
94 pNew_LOD->LoadFile("data\\new.lod", 0); | |
95 auto *f = pNew_LOD->FindContainer("header.bin", 1); | |
96 if (!f) | |
97 { | |
98 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 100); | |
99 Log::Warning(L"%S", Str); | |
100 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:549", 0); | |
101 } | |
102 assert(sizeof(SavegameHeader) == 100); | |
103 fread(&header, sizeof(SavegameHeader), 1, f); | |
104 | |
105 f = pNew_LOD->FindContainer("party.bin", 1); | |
106 if (!f) | |
107 { | |
108 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 101); | |
109 Log::Warning(L"%S", Str); | |
110 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:559", 0); | |
111 } | |
112 if (sizeof(Party) != 0x16238) | |
113 Log::Warning(L"class Party: deserialization warning"); | |
114 fread(pParty, 0x16238u, 1, f); | |
115 | |
116 | |
117 f = pNew_LOD->FindContainer("clock.bin", 1); | |
118 if (!f) | |
119 { | |
120 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 102); | |
121 Log::Warning(L"%S", Str); | |
122 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:569", 0); | |
123 } | |
124 if (sizeof(Timer) != 0x28) | |
125 Log::Warning(L"class Timer: deserialization warning"); | |
126 fread(pEventTimer, 0x28u, 1u, f); | |
127 | |
128 f = pNew_LOD->FindContainer("overlay.bin", 1); | |
129 if (!f) | |
130 { | |
131 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 103); | |
132 Log::Warning(L"%S", Str); | |
133 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:579", 0); | |
134 } | |
135 if (sizeof(OtherOverlayList) != 0x3F0) | |
136 Log::Warning(L"class OtherOverlayList: deserialization warning"); | |
137 fread(pOtherOverlayList, 0x3F0, 1, f); | |
138 | |
139 f = pNew_LOD->FindContainer("npcdata.bin", 0); | |
140 if (!f) | |
141 { | |
142 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 104); | |
143 Log::Warning(L"%S", Str); | |
144 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:590", 0); | |
145 } | |
146 if (sizeof(pNPCStats->pNewNPCData) != 0x94BC) | |
147 Log::Warning(L"NPCStats: deserialization warning"); | |
148 fread(pNPCStats->pNewNPCData, 0x94BC, 1, f); | |
149 pNPCStats->_476C60(); | |
150 | |
151 f = pNew_LOD->FindContainer("npcgroup.bin", 0); | |
152 if (!f) | |
153 { | |
154 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 105); | |
155 Log::Warning(L"%S", Str); | |
156 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:600", 0); | |
157 } | |
158 if (sizeof(pNPCStats->pGroups_copy) != 0x66) | |
159 Log::Warning(L"NPCStats: deserialization warning"); | |
160 fread(pNPCStats->pGroups_copy, 0x66, 1, f); | |
161 | |
162 | |
163 uActiveCharacter = 0; | |
164 for (uint i = 0; i < 4; ++i) | |
165 if (pParty->pPlayers[i].CanAct()) | |
166 { | |
167 uActiveCharacter = i + 1; | |
168 break; | |
169 } | |
170 | |
171 for (uint i = 0; i < 4; ++i) | |
172 { | |
173 auto uQuickspell = pParty->pPlayers[i].uQuickSpell; | |
174 if (uQuickspell) | |
175 stru_AA1058[i]._494836(uQuickspell, i + 9 - 8); | |
176 | |
177 for (uint j = 0; j < 2; ++j) | |
178 { | |
179 uint uEquipIdx = pParty->pPlayers[i].pEquipment.pIndices[j]; | |
180 if (uEquipIdx) | |
181 { | |
182 auto uItemID = pParty->pPlayers[i].pInventoryItems[uEquipIdx - 1].uItemID; | |
183 if (pItemsTable->pItems[uItemID].uEquipType == 12) | |
184 { | |
816 | 185 __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 |
488 | 186 v31 = *((int *)&pSpellDatas[66].uNormalLevelRecovery + uItemID); |
0 | 187 stru_A750F8[i]._494836(v31, i + 9); |
188 } | |
189 } | |
190 } | |
191 } | |
192 | |
193 | |
194 pGUIWindow_CurrentMenu->Release(); | |
151 | 195 pCurrentScreen = SCREEN_GAME; |
0 | 196 |
197 viewparams->bRedrawGameUI = true; | |
198 | |
373 | 199 SetUserInterface(pParty->alignment, true); |
0 | 200 |
201 pEventTimer->Resume(); | |
202 pEventTimer->StopGameTime(); | |
203 | |
204 v25 = pGames_LOD->DoesContainerExist(header.pLocationName); | |
205 sprintf(pTmpBuf, "levels\\%s", header.pLocationName); | |
206 v26 = _access(pTmpBuf, 4) != -1; | |
207 if ( !v25 && !v26 ) | |
208 { | |
209 sprintf(pTmpBuf, "Unable to find: %s!", header.pLocationName); | |
210 Abortf(pTmpBuf); | |
211 } | |
212 | |
213 strcpy(pCurrentMapName, header.pLocationName); | |
214 dword_6BE364_game_settings_1 |= 0x2001; | |
215 | |
216 for (uint i = 0; i < uNumSavegameFiles; ++i) | |
217 pSavegameThumbnails[i].Release(); | |
218 | |
219 pIcons_LOD->_4114F2(); | |
328 | 220 pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); |
221 pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f); | |
0 | 222 if (uTurnSpeed) |
223 pParty->sRotationY = uTurnSpeed * pParty->sRotationY / (signed int)uTurnSpeed; | |
224 MM7Initialization(); | |
225 bFlashQuestBook = false; | |
226 viewparams->bRedrawGameUI = true; | |
227 } | |
228 | |
229 | |
230 //----- (0045F469) -------------------------------------------------------- | |
810 | 231 void SaveGame( bool IsAutoSAve, bool NotSaveWorld ) |
982 | 232 { |
810 | 233 unsigned short *pScreenshot; // edi@5 |
234 int text_pos; // eax@6 | |
847 | 235 FILE *pLLoidFile; // edi@24 |
810 | 236 char* compressed_buf; // edi@30 |
237 char *data_write_pos; // esi@41 | |
847 | 238 CHAR Buffer[128]; // [sp+Ch] [bp-264h]@59 |
79 | 239 char Dir[255]; // [sp+8Ch] [bp-1E4h]@51 |
240 char Drive[255]; // [sp+ACh] [bp-1C4h]@51 | |
837 | 241 SavegameHeader save_header; // [sp+CCh] [bp-1A4h]@10 |
79 | 242 char Filename[255]; // [sp+130h] [bp-140h]@51 |
243 char Ext[255]; // [sp+150h] [bp-120h]@51 | |
0 | 244 char Source[32]; // [sp+170h] [bp-100h]@51 |
847 | 245 char work_string[120]; // [sp+190h] [bp-E0h]@8 |
246 int pPositionY; // [sp+208h] [bp-68h]@2 | |
0 | 247 int pPositionX; // [sp+20Ch] [bp-64h]@2 |
847 | 248 int sPRotationY; // [sp+210h] [bp-60h]@2 |
249 int sPRotationX; // [sp+214h] [bp-5Ch]@2 | |
837 | 250 ODMHeader odm_data; // [sp+218h] [bp-58h]@30 |
847 | 251 int res; // [sp+224h] [bp-4Ch]@30 |
252 int pPositionZ; // [sp+228h] [bp-48h]@2 | |
0 | 253 size_t Size; // [sp+250h] [bp-20h]@26 |
810 | 254 char *uncompressed_buff; // [sp+258h] [bp-18h]@2 |
255 unsigned int compressed_block_size; // [sp+260h] [bp-10h]@23 | |
847 | 256 |
568 | 257 //v66 = a2; |
0 | 258 strcpy(byte_6BE3B0, pCurrentMapName); |
568 | 259 if (!_strcmpi(pCurrentMapName, "d05.blv")) // arena |
810 | 260 return; |
568 | 261 |
810 | 262 uncompressed_buff = (char*)malloc(1000000); |
982 | 263 |
264 LOD::Directory pLodDirectory; // [sp+22Ch] [bp-44h]@2 | |
0 | 265 pPositionX = pParty->vPosition.x; |
847 | 266 pPositionY = pParty->vPosition.y; |
267 pPositionZ = pParty->vPosition.z; | |
268 sPRotationY = pParty->sRotationY; | |
269 sPRotationX = pParty->sRotationX; | |
0 | 270 pParty->vPosition.x = pParty->vPrevPosition.x; |
847 | 271 pParty->vPosition.z = pParty->vPrevPosition.z; |
272 pParty->vPosition.y = pParty->vPrevPosition.y; | |
273 | |
274 pParty->uFallStartY = pParty->vPrevPosition.z; | |
275 | |
0 | 276 pParty->sRotationY = pParty->sPrevRotationY; |
277 pParty->sRotationX = pParty->sPrevRotationX; | |
278 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
279 pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed; | |
280 else | |
810 | 281 pOutdoor->loc_time.uLastVisitDay = pParty->uTimePlayed; |
0 | 282 pScreenshot = MakeScreenshot(150, 112); |
810 | 283 strcpy(pLodDirectory.pFilename, "image.pcx"); |
284 pRenderer->PackPCXpicture(pScreenshot, 150, 112, uncompressed_buff, 1000000, &pLodDirectory.uDataSize); | |
0 | 285 free(pScreenshot); |
151 | 286 if (pCurrentScreen == SCREEN_SAVEGAME) |
0 | 287 { |
568 | 288 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave)); |
289 pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_save_up)); | |
810 | 290 text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[190]); |
291 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Ñîõðàíåíèå | |
292 text_pos = pFontSmallnum->AlignText_Center(186, pSavegameHeader[uLoadGameUI_SelectedSlot].pName); | |
293 pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, text_pos + 25, 259, 0, pSavegameHeader[uLoadGameUI_SelectedSlot].pName, 185, 0); | |
294 text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[165]); | |
295 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Ïîæàëóéñòà, ïîäîæäèòå | |
0 | 296 pRenderer->Present(); |
568 | 297 } |
298 | |
810 | 299 if (pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0)) |
0 | 300 { |
847 | 301 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 200); //Ñîõðàíåííàÿ èãðà ïîâðåæäåíà! Code=%d |
302 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0); | |
0 | 303 } |
304 | |
305 assert(sizeof(SavegameHeader) == 100); | |
837 | 306 memset(save_header.pName, 0, 20); |
307 memset(save_header.pLocationName, 0, 20); | |
308 memset(save_header.field_30, 0, 52); | |
309 strcpy(save_header.pLocationName, pCurrentMapName); | |
310 save_header.uWordTime = pParty->uTimePlayed; | |
810 | 311 strcpy(pLodDirectory.pFilename, "header.bin"); |
312 pLodDirectory.uDataSize = sizeof(SavegameHeader); | |
837 | 313 if (pNew_LOD->Write(&pLodDirectory, &save_header, 0)) |
0 | 314 { |
847 | 315 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 201); |
316 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0); | |
0 | 317 } |
810 | 318 strcpy(pLodDirectory.pFilename, "party.bin"); |
319 pLodDirectory.uDataSize = sizeof(Party); //90680; | |
320 if ( pNew_LOD->Write(&pLodDirectory, pParty, 0) ) | |
0 | 321 { |
847 | 322 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 202); |
323 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0); | |
0 | 324 } |
810 | 325 strcpy(pLodDirectory.pFilename, "clock.bin"); |
326 pLodDirectory.uDataSize =sizeof(Timer);// 40; | |
327 if ( pNew_LOD->Write(&pLodDirectory, pEventTimer, 0) ) | |
0 | 328 { |
847 | 329 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 203); |
330 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0); | |
0 | 331 } |
810 | 332 strcpy(pLodDirectory.pFilename, "overlay.bin"); |
333 pLodDirectory.uDataSize =sizeof(OtherOverlayList);// 1008; | |
334 if ( pNew_LOD->Write(&pLodDirectory, pOtherOverlayList, 0) ) | |
0 | 335 { |
847 | 336 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 204); |
337 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0); | |
0 | 338 } |
810 | 339 strcpy(pLodDirectory.pFilename, "npcdata.bin"); |
340 pLodDirectory.uDataSize = 501 * sizeof(NPCData); | |
341 assert(pLodDirectory.uDataSize == 38076); | |
342 if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pNewNPCData, 0) ) | |
0 | 343 { |
847 | 344 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 205); |
345 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0); | |
0 | 346 } |
810 | 347 strcpy(pLodDirectory.pFilename, "npcgroup.bin"); |
348 pLodDirectory.uDataSize = 102; | |
349 if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pGroups_copy, 0) ) | |
0 | 350 { |
847 | 351 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 206); |
352 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0); | |
0 | 353 } |
354 for (int i = 1; i <= 4; ++i) // 4 - players | |
355 { | |
356 for (int j = 1; j <= 5; ++j) // 5 - images | |
357 { | |
847 | 358 sprintf(work_string, "data\\lloyd%d%d.pcx", i, j); |
359 pLLoidFile = fopen(work_string, "rb"); | |
360 if ( pLLoidFile ) | |
0 | 361 { |
362 __debugbreak(); | |
847 | 363 sprintf(work_string, "lloyd%d%d.pcx", i, j); |
364 fseek(pLLoidFile, 0, SEEK_END); | |
365 pLodDirectory.uDataSize = ftell(pLLoidFile); | |
366 rewind(pLLoidFile); | |
367 fread(uncompressed_buff, pLodDirectory.uDataSize, 1, pLLoidFile); | |
368 strcpy(pLodDirectory.pFilename, work_string); | |
369 fclose(pLLoidFile); | |
370 remove(work_string); | |
810 | 371 if ( pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0) ) |
0 | 372 { |
847 | 373 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 207); |
374 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0); | |
0 | 375 Size = 5080748; |
376 } | |
377 } | |
378 } | |
379 } | |
810 | 380 if ( !NotSaveWorld ) |
0 | 381 { |
79 | 382 //__debugbreak(); |
810 | 383 CompactLayingItemsList(); |
384 compressed_buf = (char*)malloc(1000000); | |
837 | 385 odm_data.uVersion = 91969; |
386 odm_data.pMagic[0] = 'm'; | |
387 odm_data.pMagic[1] = 'v'; | |
388 odm_data.pMagic[2] = 'i'; | |
389 odm_data.pMagic[3] = 'i'; | |
390 odm_data.uCompressedSize = 0; | |
391 odm_data.uDecompressedSize = 0; | |
810 | 392 data_write_pos = uncompressed_buff; |
837 | 393 memcpy((void *)compressed_buf, &odm_data, 0x10); |
0 | 394 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) |
395 { | |
396 pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces; | |
397 pIndoor->dlv.uNumBModels = 0; | |
398 pIndoor->dlv.uNumDecorations = uNumLevelDecorations; | |
837 | 399 memcpy(data_write_pos, &pIndoor->dlv,sizeof(DDM_DLV_Header) );//0x28 |
400 data_write_pos += sizeof(DDM_DLV_Header); | |
810 | 401 memcpy(data_write_pos, pIndoor->_visible_outlines, 0x36B); |
402 data_write_pos += 875; | |
403 | |
404 for (int i = 0; i <(signed int)pIndoor->uNumFaces; ++i) | |
0 | 405 { |
810 | 406 memcpy(data_write_pos, &pIndoor->pFaces[i].uAttributes, 4); |
407 data_write_pos += 4; | |
0 | 408 } |
810 | 409 |
410 for (int i = 0; i <(signed int)uNumLevelDecorations; ++i) | |
0 | 411 { |
810 | 412 memcpy(data_write_pos, &pLevelDecorations[i].field_2, 2); |
413 | |
414 data_write_pos+= 2; | |
0 | 415 } |
810 | 416 memcpy(data_write_pos, &uNumActors, 4); |
417 data_write_pos += 4; | |
418 memcpy(data_write_pos, pActors, 836 * uNumActors); | |
419 data_write_pos += 836 * uNumActors; | |
420 memcpy(data_write_pos, &uNumSpriteObjects, 4); | |
421 data_write_pos += 4; | |
422 memcpy(data_write_pos, pSpriteObjects, 112 * uNumSpriteObjects); | |
423 data_write_pos += 112 * uNumSpriteObjects; | |
424 memcpy(data_write_pos, &uNumChests, 4); | |
425 data_write_pos += 4; | |
847 | 426 memcpy(data_write_pos, pChests, sizeof(Chest)*uNumChests);//5324 * |
427 data_write_pos += sizeof(Chest)* uNumChests; | |
810 | 428 memcpy(data_write_pos, pIndoor->pDoors, 0x3E80); |
429 data_write_pos += 16000; | |
430 memcpy(data_write_pos, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size); | |
431 data_write_pos += pIndoor->blv.uDoors_ddata_Size; | |
432 memcpy(data_write_pos, &stru_5E4C90, 0xC8); | |
433 data_write_pos += 200; | |
434 memcpy(data_write_pos, &pIndoor->stru1, 0x38); | |
435 data_write_pos += 56; | |
436 | |
0 | 437 } |
438 else | |
439 { | |
440 pOutdoor->ddm.uNumFacesInBModels = 0; | |
810 | 441 for (int i=0; i<pOutdoor->uNumBModels;++i) |
442 { | |
837 | 443 pOutdoor->ddm.uNumFacesInBModels +=pOutdoor->pBModels[i].uNumFaces; |
810 | 444 } |
0 | 445 pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels; |
446 pOutdoor->ddm.uNumDecorations = uNumLevelDecorations; | |
810 | 447 memcpy(data_write_pos, &pOutdoor->ddm, sizeof(DDM_DLV_Header));//0x28 |
448 data_write_pos += sizeof(DDM_DLV_Header); | |
449 memcpy(data_write_pos, pOutdoor->uUndiscoveredArea, 0x3C8); | |
450 data_write_pos += 968; | |
451 memcpy(data_write_pos, pOutdoor->uDicovered_area, 0x3C8); | |
452 data_write_pos += 968; | |
837 | 453 for (int i = 0; i < pOutdoor->uNumBModels ; ++i) |
79 | 454 for (int j = 0; j < pOutdoor->pBModels[i].uNumFaces;++j)//*(int *)&pOutdoor->pBModels->pModelName[v24]; ++j) |
837 | 455 { |
456 memcpy(data_write_pos, &(pOutdoor->pBModels[i].pFaces[j].uAttributes), 4); | |
810 | 457 data_write_pos += 4; |
0 | 458 } |
837 | 459 |
568 | 460 for (int i = 0; i <= (signed int)uNumLevelDecorations; ++i) |
0 | 461 { |
837 | 462 memcpy(data_write_pos, &pLevelDecorations[i].field_2, 2); |
810 | 463 data_write_pos += 2; |
0 | 464 } |
810 | 465 memcpy(data_write_pos, &uNumActors, 4); |
466 data_write_pos += 4; | |
467 memcpy(data_write_pos, pActors, 836 * uNumActors); | |
468 data_write_pos += 836 * uNumActors; | |
469 memcpy(data_write_pos, &uNumSpriteObjects, 4); | |
470 data_write_pos += 4; | |
471 memcpy(data_write_pos, pSpriteObjects, 112 * uNumSpriteObjects); | |
472 data_write_pos += 112 * uNumSpriteObjects; | |
473 memcpy(data_write_pos, &uNumChests, 4); | |
474 data_write_pos += 4; | |
847 | 475 memcpy(data_write_pos, pChests, sizeof(Chest)* uNumChests); |
476 data_write_pos += sizeof(Chest)* uNumChests; | |
810 | 477 memcpy(data_write_pos, &stru_5E4C90, 0xC8); |
478 data_write_pos += 200; | |
479 memcpy(data_write_pos, &pOutdoor->loc_time, 0x38); | |
480 data_write_pos += 56; | |
0 | 481 } |
482 strcpy(Source, pCurrentMapName); | |
79 | 483 _splitpath(Source, Drive, Dir, Filename, Ext); |
847 | 484 |
810 | 485 Size = (int)data_write_pos - (int)uncompressed_buff; |
486 compressed_block_size = 999984; | |
847 | 487 res = zlib::MemZip((char *)compressed_buf + 16, (unsigned int *)&compressed_block_size, uncompressed_buff,Size); |
488 if (res || (signed int)compressed_block_size > (signed int)Size ) | |
0 | 489 { |
810 | 490 memcpy((void *)(compressed_buf + 16), uncompressed_buff, Size); |
491 compressed_block_size = Size; | |
0 | 492 } |
810 | 493 compressed_block_size += 16; |
814 | 494 memcpy(&((ODMHeader *)compressed_buf)->uCompressedSize, &compressed_block_size, 4); |
495 memcpy(&((ODMHeader *)compressed_buf)->uDecompressedSize, &Size, 4); | |
0 | 496 sprintf(Source, "%s%s", &Filename, &Ext); |
847 | 497 strcpy(pLodDirectory.pFilename, Source); |
810 | 498 pLodDirectory.uDataSize = compressed_block_size; |
499 if ( pNew_LOD->Write(&pLodDirectory, (const void *)compressed_buf, 0) ) | |
0 | 500 { |
847 | 501 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 208); |
502 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0); | |
0 | 503 } |
810 | 504 free((void *)compressed_buf); |
0 | 505 } |
810 | 506 free(uncompressed_buff); |
507 if ( IsAutoSAve ) | |
0 | 508 { |
509 if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) ) | |
510 { | |
847 | 511 FormatMessageA(0x1000, 0, GetLastError(), 0x400, Buffer, 0x80, 0); |
512 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 300); | |
513 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0); | |
0 | 514 } |
515 } | |
516 pParty->vPosition.x = pPositionX; | |
847 | 517 pParty->vPosition.y = pPositionY; |
518 pParty->vPosition.z = pPositionZ; | |
519 pParty->uFallStartY = pPositionZ; | |
520 pParty->sRotationY = sPRotationY; | |
521 pParty->sRotationX = sPRotationX; | |
0 | 522 } |
523 | |
524 | |
525 //----- (00460078) -------------------------------------------------------- | |
526 void __fastcall DoSavegame(unsigned int uSlot) | |
527 { | |
568 | 528 //unsigned int v1; // esi@1 |
529 //int v2; // esi@2 | |
557 | 530 //RGBTexture *v3; // ebx@3 |
0 | 531 int bNotArena; // [sp+2Ch] [bp-8h]@1 |
568 | 532 //unsigned int v6; // [sp+30h] [bp-4h]@1 |
0 | 533 |
165 | 534 //__debugbreak(); |
0 | 535 |
568 | 536 //v1 = uSlot; |
537 //v6 = uSlot; | |
0 | 538 bNotArena = _strcmpi(pCurrentMapName, "d05.blv"); |
539 if ( bNotArena ) | |
540 { | |
541 LOD::Directory pDir; // [sp+Ch] [bp-28h]@2 | |
542 SaveGame(0, 0); | |
568 | 543 //v2 = 100 * v1; |
544 strcpy(pSavegameHeader[uSlot].pLocationName, pCurrentMapName); | |
545 pSavegameHeader[uSlot].uWordTime = pParty->uTimePlayed; | |
546 strcpy(pDir.pFilename, "header.bin"); | |
0 | 547 pDir.uDataSize = 100; |
568 | 548 pNew_LOD->Write(&pDir, &pSavegameHeader[uSlot], 0); |
549 sprintf(pTmpBuf, "saves\\save%03d.mm7", uSlot); | |
0 | 550 pNew_LOD->CloseWriteFile(); |
551 CopyFileA("data\\new.lod", pTmpBuf, 0); | |
552 } | |
553 GUI_UpdateWindows(); | |
554 pGUIWindow_CurrentMenu->Release(); | |
151 | 555 pCurrentScreen = SCREEN_GAME; |
557 | 556 //v3 = pSavegameThumbnails; |
0 | 557 viewparams->bRedrawGameUI = 1; |
568 | 558 for (uint i = 0; i < 45; i++) |
557 | 559 pSavegameThumbnails[i].Release(); |
560 //while ( (signed int)v3 < (signed int)&unk_6A0758 ); | |
0 | 561 if ( bNotArena ) |
562 pNew_LOD->_4621A7(); | |
563 else | |
564 ShowStatusBarString(pGlobalTXT_LocalizationStrings[583], 2u);// "No saving in the Arena" | |
565 pIcons_LOD->_4355F7(); | |
566 pEventTimer->Resume(); | |
567 ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2u);// "Game Saved!" | |
568 | 568 viewparams->bRedrawGameUI = true; |
0 | 569 } |
570 // 4E28F8: using guessed type int pCurrentScreen; | |
571 | |
572 | |
573 | |
574 | |
575 | |
576 | |
577 | |
578 | |
579 | |
580 | |
581 | |
582 //----- (0045E297) -------------------------------------------------------- | |
583 void SavegameList::Initialize(unsigned int bHideEmptySlots) | |
584 { | |
382 | 585 memset(pSavegameList, 0, 0x3138); |
586 // Reset(); | |
4 | 587 uNumSavegameFiles = 0; |
0 | 588 |
589 _chdir("saves"); | |
590 { | |
4 | 591 if (!bHideEmptySlots && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 ) // AutoSave.MM7 |
382 | 592 strcpy(pSavegameList->pFileList[uNumSavegameFiles++].pSaveFileName, pGlobalTXT_LocalizationStrings[613]); |
0 | 593 |
594 for (uint i = 0; i < 40; ++i) | |
595 { | |
596 sprintf(pTmpBuf, "save%03d.mm7", i); | |
597 if (_access(pTmpBuf, 0) == -1) | |
598 continue; | |
599 | |
600 uint idx = i; | |
601 if (!bHideEmptySlots) | |
602 idx = uNumSavegameFiles; | |
382 | 603 strcpy(pSavegameList->pFileList[idx].pSaveFileName, pTmpBuf); |
0 | 604 |
605 ++uNumSavegameFiles; | |
606 } | |
607 } | |
608 _chdir(".."); | |
609 } |