annotate SaveLoad.cpp @ 2430:cb66a1082fcf

* ITrack, IMovie now properly propogate destructors * VideoPlayer correctly deallocates memory after playing a movie
author a.parshin
date Wed, 23 Jul 2014 20:28:28 +0300
parents f4af3b203f65
children 90349b8048a5
rev   line source
2415
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2394
diff changeset
1 #define _CRTDBG_MAP_ALLOC
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2394
diff changeset
2 #include <stdlib.h>
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2394
diff changeset
3 #include <crtdbg.h>
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2394
diff changeset
4
2253
aff7a7b072b7 adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents: 2224
diff changeset
5 #define _CRT_SECURE_NO_WARNINGS
0
Ritor1
parents:
diff changeset
6 #include <io.h>
Ritor1
parents:
diff changeset
7 #include <direct.h>
2336
d6887ee81068 header file include cleanup
Grumpy7
parents: 2334
diff changeset
8 #include "mm7_unsorted_subs.h"
d6887ee81068 header file include cleanup
Grumpy7
parents: 2334
diff changeset
9 #include "ErrorHandling.h"
2352
8a49cf25fb88 Moving zlib wrappers to separate headers
Grumpy7
parents: 2336
diff changeset
10 #include "ZlibWrapper.h"
0
Ritor1
parents:
diff changeset
11
Ritor1
parents:
diff changeset
12 #include "SaveLoad.h"
1016
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 982
diff changeset
13 #include "BSPModel.h"
0
Ritor1
parents:
diff changeset
14 #include "Party.h"
Ritor1
parents:
diff changeset
15 #include "LOD.h"
Ritor1
parents:
diff changeset
16 #include "Outdoor.h"
Ritor1
parents:
diff changeset
17 #include "AudioPlayer.h"
Ritor1
parents:
diff changeset
18 #include "Actor.h"
Ritor1
parents:
diff changeset
19 #include "Chest.h"
2044
28cb79ae2f6f Time.h rename
Ritor1
parents: 1980
diff changeset
20 #include "Timer.h"
0
Ritor1
parents:
diff changeset
21 #include "GUIWindow.h"
Ritor1
parents:
diff changeset
22 #include "GUIFont.h"
Ritor1
parents:
diff changeset
23 #include "Overlays.h"
515
cb0ad52d6a26 LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents: 488
diff changeset
24 #include "SpriteObject.h"
0
Ritor1
parents:
diff changeset
25 #include "Viewport.h"
Ritor1
parents:
diff changeset
26 #include "stru123.h"
189
038a4d09406f new texts file, fix text rendender error
Gloval
parents: 165
diff changeset
27 #include "texts.h"
0
Ritor1
parents:
diff changeset
28 #include "Log.h"
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
29 #include "VideoPlayer.h"
1828
35c1e4ff6ba7 party_finds_gold to Party::PartyFindsGold, cleaned up, moved Level/Decoration.h reference out of Indoor.h
Grumpy7
parents: 1754
diff changeset
30 #include "Level/Decoration.h"
2127
400f3db2e4e5 Screenshot continue
Ritor1
parents: 2124
diff changeset
31 #include "Render.h"
0
Ritor1
parents:
diff changeset
32
Ritor1
parents:
diff changeset
33 #include "mm7_data.h"
Ritor1
parents:
diff changeset
34
Ritor1
parents:
diff changeset
35
Ritor1
parents:
diff changeset
36 struct SavegameList *pSavegameList = new SavegameList;
Ritor1
parents:
diff changeset
37 unsigned int uNumSavegameFiles;
1206
ab6560001f5b arrays to std::arrays phase 2 - some more arrays converted
Grumpy7
parents: 1205
diff changeset
38 std::array<unsigned int, 45> pSavegameUsedSlots;
ab6560001f5b arrays to std::arrays phase 2 - some more arrays converted
Grumpy7
parents: 1205
diff changeset
39 std::array<struct RGBTexture, 45> pSavegameThumbnails;
ab6560001f5b arrays to std::arrays phase 2 - some more arrays converted
Grumpy7
parents: 1205
diff changeset
40 std::array<SavegameHeader, 45> pSavegameHeader;
0
Ritor1
parents:
diff changeset
41
Ritor1
parents:
diff changeset
42 //----- (0045EE8A) --------------------------------------------------------
Ritor1
parents:
diff changeset
43 void __fastcall LoadGame(unsigned int uSlot)
Ritor1
parents:
diff changeset
44 {
Ritor1
parents:
diff changeset
45 bool v25; // esi@62
Ritor1
parents:
diff changeset
46 bool v26; // eax@62
Ritor1
parents:
diff changeset
47 SavegameHeader header; // [sp+Ch] [bp-E4h]@23
Ritor1
parents:
diff changeset
48 char Str[123]; // [sp+70h] [bp-80h]@25
Ritor1
parents:
diff changeset
49
2386
41c36ecc9f32 MapsLongTimer.h
Ritor1
parents: 2364
diff changeset
50 MapsLongTimers_count = 0;
0
Ritor1
parents:
diff changeset
51 if (!pSavegameUsedSlots[uSlot])
Ritor1
parents:
diff changeset
52 {
1754
421c29d4ab3e UITransition.cpp cleaning(continue)
Ritor1
parents: 1736
diff changeset
53 pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0);
0
Ritor1
parents:
diff changeset
54 Log::Warning(L"LoadGame: slot %u is empty", uSlot);
Ritor1
parents:
diff changeset
55 return;
Ritor1
parents:
diff changeset
56 }
Ritor1
parents:
diff changeset
57
Ritor1
parents:
diff changeset
58 for (uint i = 1; i < 5; ++i)
Ritor1
parents:
diff changeset
59 for (uint j = 1; j < 6; ++j)
Ritor1
parents:
diff changeset
60 {
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
61 sprintf(pTmpBuf.data(), "data\\lloyd%d%d.pcx", i, j);
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
62 remove(pTmpBuf.data());
0
Ritor1
parents:
diff changeset
63 }
Ritor1
parents:
diff changeset
64
203
0c64754c7fd4 Voices work (at least in party creation screen)
Nomad
parents: 189
diff changeset
65 if (SoundSetAction[24][0])
0
Ritor1
parents:
diff changeset
66 for (uint i = 0; i < 4; ++i)
Ritor1
parents:
diff changeset
67 {
764
90bcfb56c8f9 sound cleaning
Gloval
parents: 752
diff changeset
68 for (uint j = 0; j < pSoundList->sNumSounds; ++j)
2113
a94c5bee0225 SoundVolume options
Ritor1
parents: 2103
diff changeset
69 if (pSoundList->pSL_Sounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4998)
0
Ritor1
parents:
diff changeset
70 {
764
90bcfb56c8f9 sound cleaning
Gloval
parents: 752
diff changeset
71 pSoundList->UnloadSound(j, 1);
0
Ritor1
parents:
diff changeset
72 break;
Ritor1
parents:
diff changeset
73 }
Ritor1
parents:
diff changeset
74
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
75 for (uint j = 0; j < pSoundList->sNumSounds; ++j)
2113
a94c5bee0225 SoundVolume options
Ritor1
parents: 2103
diff changeset
76 if (pSoundList->pSL_Sounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4999)
0
Ritor1
parents:
diff changeset
77 {
764
90bcfb56c8f9 sound cleaning
Gloval
parents: 752
diff changeset
78 pSoundList->UnloadSound(j, 1);
0
Ritor1
parents:
diff changeset
79 break;
Ritor1
parents:
diff changeset
80 }
Ritor1
parents:
diff changeset
81 }
Ritor1
parents:
diff changeset
82
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
83 sprintf(pTmpBuf.data(), "saves\\%s", pSavegameList->pFileList[uSlot].pSaveFileName);
0
Ritor1
parents:
diff changeset
84
Ritor1
parents:
diff changeset
85 pNew_LOD->CloseWriteFile();
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
86 if (!CopyFileA(pTmpBuf.data(), "data\\new.lod", 0))
0
Ritor1
parents:
diff changeset
87 int e = GetLastError();
Ritor1
parents:
diff changeset
88
Ritor1
parents:
diff changeset
89 pNew_LOD->LoadFile("data\\new.lod", 0);
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
90 FILE *file = pNew_LOD->FindContainer("header.bin", 1);
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
91 if (!file)
0
Ritor1
parents:
diff changeset
92 {
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
93 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 100);//Сохраненная игра повреждена! Code=%d
0
Ritor1
parents:
diff changeset
94 Log::Warning(L"%S", Str);
Ritor1
parents:
diff changeset
95 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:549", 0);
Ritor1
parents:
diff changeset
96 }
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1489
diff changeset
97 Assert(sizeof(SavegameHeader) == 100);
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
98 fread(&header, sizeof(SavegameHeader), 1, file);
0
Ritor1
parents:
diff changeset
99
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
100 file = pNew_LOD->FindContainer("party.bin", 1);
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
101 if (!file)
0
Ritor1
parents:
diff changeset
102 {
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
103 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 101);//Сохраненная игра повреждена! Code=%d
0
Ritor1
parents:
diff changeset
104 Log::Warning(L"%S", Str);
Ritor1
parents:
diff changeset
105 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:559", 0);
Ritor1
parents:
diff changeset
106 }
Ritor1
parents:
diff changeset
107 if (sizeof(Party) != 0x16238)
Ritor1
parents:
diff changeset
108 Log::Warning(L"class Party: deserialization warning");
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
109 fread(pParty, sizeof(Party), 1, file);
0
Ritor1
parents:
diff changeset
110
Ritor1
parents:
diff changeset
111
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
112 file = pNew_LOD->FindContainer("clock.bin", 1);
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
113 if (!file)
0
Ritor1
parents:
diff changeset
114 {
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
115 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 102);//Сохраненная игра повреждена! Code=%d
0
Ritor1
parents:
diff changeset
116 Log::Warning(L"%S", Str);
Ritor1
parents:
diff changeset
117 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:569", 0);
Ritor1
parents:
diff changeset
118 }
Ritor1
parents:
diff changeset
119 if (sizeof(Timer) != 0x28)
Ritor1
parents:
diff changeset
120 Log::Warning(L"class Timer: deserialization warning");
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
121 fread(pEventTimer, sizeof(Timer), 1, file);
0
Ritor1
parents:
diff changeset
122
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
123 file = pNew_LOD->FindContainer("overlay.bin", 1);
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
124 if (!file)
0
Ritor1
parents:
diff changeset
125 {
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
126 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 103);//Сохраненная игра повреждена! Code=%d
0
Ritor1
parents:
diff changeset
127 Log::Warning(L"%S", Str);
Ritor1
parents:
diff changeset
128 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:579", 0);
Ritor1
parents:
diff changeset
129 }
Ritor1
parents:
diff changeset
130 if (sizeof(OtherOverlayList) != 0x3F0)
Ritor1
parents:
diff changeset
131 Log::Warning(L"class OtherOverlayList: deserialization warning");
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
132 fread(pOtherOverlayList, sizeof(OtherOverlayList), 1, file);
0
Ritor1
parents:
diff changeset
133
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
134 file = pNew_LOD->FindContainer("npcdata.bin", 0);
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
135 if (!file)
0
Ritor1
parents:
diff changeset
136 {
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
137 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 104);//Сохраненная игра повреждена! Code=%d
0
Ritor1
parents:
diff changeset
138 Log::Warning(L"%S", Str);
Ritor1
parents:
diff changeset
139 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:590", 0);
Ritor1
parents:
diff changeset
140 }
Ritor1
parents:
diff changeset
141 if (sizeof(pNPCStats->pNewNPCData) != 0x94BC)
Ritor1
parents:
diff changeset
142 Log::Warning(L"NPCStats: deserialization warning");
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
143 fread(pNPCStats->pNewNPCData, sizeof(pNPCStats->pNewNPCData), 1, file);
0
Ritor1
parents:
diff changeset
144 pNPCStats->_476C60();
Ritor1
parents:
diff changeset
145
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
146 file = pNew_LOD->FindContainer("npcgroup.bin", 0);
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
147 if (!file)
0
Ritor1
parents:
diff changeset
148 {
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
149 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 105);//Сохраненная игра повреждена! Code=%d
0
Ritor1
parents:
diff changeset
150 Log::Warning(L"%S", Str);
Ritor1
parents:
diff changeset
151 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:600", 0);
Ritor1
parents:
diff changeset
152 }
Ritor1
parents:
diff changeset
153 if (sizeof(pNPCStats->pGroups_copy) != 0x66)
Ritor1
parents:
diff changeset
154 Log::Warning(L"NPCStats: deserialization warning");
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
155 fread(pNPCStats->pGroups_copy, sizeof(pNPCStats->pGroups_copy), 1, file);
0
Ritor1
parents:
diff changeset
156
Ritor1
parents:
diff changeset
157 uActiveCharacter = 0;
Ritor1
parents:
diff changeset
158 for (uint i = 0; i < 4; ++i)
Ritor1
parents:
diff changeset
159 if (pParty->pPlayers[i].CanAct())
Ritor1
parents:
diff changeset
160 {
Ritor1
parents:
diff changeset
161 uActiveCharacter = i + 1;
Ritor1
parents:
diff changeset
162 break;
Ritor1
parents:
diff changeset
163 }
Ritor1
parents:
diff changeset
164
Ritor1
parents:
diff changeset
165 for (uint i = 0; i < 4; ++i)
Ritor1
parents:
diff changeset
166 {
2184
e0863f5beee0 SPELL_WATER_RECHARGE_ITEM
Ritor1
parents: 2181
diff changeset
167 if ( pParty->pPlayers[i].uQuickSpell )
e0863f5beee0 SPELL_WATER_RECHARGE_ITEM
Ritor1
parents: 2181
diff changeset
168 AA1058_PartyQuickSpellSound[i].AddPartySpellSound(pParty->pPlayers[i].uQuickSpell, i + 1);
0
Ritor1
parents:
diff changeset
169
Ritor1
parents:
diff changeset
170 for (uint j = 0; j < 2; ++j)
Ritor1
parents:
diff changeset
171 {
Ritor1
parents:
diff changeset
172 uint uEquipIdx = pParty->pPlayers[i].pEquipment.pIndices[j];
Ritor1
parents:
diff changeset
173 if (uEquipIdx)
Ritor1
parents:
diff changeset
174 {
2184
e0863f5beee0 SPELL_WATER_RECHARGE_ITEM
Ritor1
parents: 2181
diff changeset
175 int pItemID = pParty->pPlayers[i].pInventoryItemList[uEquipIdx - 1].uItemID;
e0863f5beee0 SPELL_WATER_RECHARGE_ITEM
Ritor1
parents: 2181
diff changeset
176 if (pItemsTable->pItems[pItemID].uEquipType == EQUIP_WAND && pItemID )//жезл
0
Ritor1
parents:
diff changeset
177 {
2184
e0863f5beee0 SPELL_WATER_RECHARGE_ITEM
Ritor1
parents: 2181
diff changeset
178 __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5
e0863f5beee0 SPELL_WATER_RECHARGE_ITEM
Ritor1
parents: 2181
diff changeset
179 stru_A750F8[i].AddPartySpellSound(wand_spell_ids[pItemID - ITEM_WAND_FIRE], i + 9);
0
Ritor1
parents:
diff changeset
180 }
Ritor1
parents:
diff changeset
181 }
Ritor1
parents:
diff changeset
182 }
Ritor1
parents:
diff changeset
183 }
Ritor1
parents:
diff changeset
184
Ritor1
parents:
diff changeset
185 pGUIWindow_CurrentMenu->Release();
151
9abdd40a107b pCurrentScreen
Ritor1
parents: 79
diff changeset
186 pCurrentScreen = SCREEN_GAME;
0
Ritor1
parents:
diff changeset
187
Ritor1
parents:
diff changeset
188 viewparams->bRedrawGameUI = true;
Ritor1
parents:
diff changeset
189
373
edd2d8b7e3c4 Interface reloading fix & party alignment enum
Nomad
parents: 336
diff changeset
190 SetUserInterface(pParty->alignment, true);
0
Ritor1
parents:
diff changeset
191
Ritor1
parents:
diff changeset
192 pEventTimer->Resume();
Ritor1
parents:
diff changeset
193 pEventTimer->StopGameTime();
Ritor1
parents:
diff changeset
194
Ritor1
parents:
diff changeset
195 v25 = pGames_LOD->DoesContainerExist(header.pLocationName);
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
196 sprintf(pTmpBuf.data(), "levels\\%s", header.pLocationName);
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
197 v26 = _access(pTmpBuf.data(), 4) != -1;
0
Ritor1
parents:
diff changeset
198 if ( !v25 && !v26 )
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1489
diff changeset
199 Error("Unable to find: %s!", header.pLocationName);
0
Ritor1
parents:
diff changeset
200
1477
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
201 strcpy(pCurrentMapName, header.pLocationName);
2061
b2a434d65344 GAME_SETTINGS_* defines introduced
Nomad
parents: 2044
diff changeset
202 dword_6BE364_game_settings_1 |= GAME_SETTINGS_2000 | GAME_SETTINGS_0001;
0
Ritor1
parents:
diff changeset
203
Ritor1
parents:
diff changeset
204 for (uint i = 0; i < uNumSavegameFiles; ++i)
Ritor1
parents:
diff changeset
205 pSavegameThumbnails[i].Release();
Ritor1
parents:
diff changeset
206
1405
c0b273d33338 RemoveTexturesPackFromTextureList and RemoveTexturesFromTextureList
Ritor1
parents: 1404
diff changeset
207 pIcons_LOD->RemoveTexturesPackFromTextureList();
328
8e23edf57e27 little fix
Ritor1
parents: 203
diff changeset
208 pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
8e23edf57e27 little fix
Ritor1
parents: 203
diff changeset
209 pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f);
0
Ritor1
parents:
diff changeset
210 if (uTurnSpeed)
Ritor1
parents:
diff changeset
211 pParty->sRotationY = uTurnSpeed * pParty->sRotationY / (signed int)uTurnSpeed;
Ritor1
parents:
diff changeset
212 MM7Initialization();
Ritor1
parents:
diff changeset
213 bFlashQuestBook = false;
Ritor1
parents:
diff changeset
214 viewparams->bRedrawGameUI = true;
Ritor1
parents:
diff changeset
215 }
Ritor1
parents:
diff changeset
216
Ritor1
parents:
diff changeset
217 //----- (0045F469) --------------------------------------------------------
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
218 void SaveGame( bool IsAutoSAve, bool NotSaveWorld )
982
08fd1436ef35 enums & lod
Nomad
parents: 847
diff changeset
219 {
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
220 int text_pos; // eax@6
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
221 FILE *pLLoidFile; // edi@24
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
222 char* compressed_buf; // edi@30
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
223 char *data_write_pos; // esi@41
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
224 CHAR Buffer[128]; // [sp+Ch] [bp-264h]@59
79
6ad816231528 structure fixes, death crash fix
zipi
parents: 4
diff changeset
225 char Dir[255]; // [sp+8Ch] [bp-1E4h]@51
6ad816231528 structure fixes, death crash fix
zipi
parents: 4
diff changeset
226 char Drive[255]; // [sp+ACh] [bp-1C4h]@51
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
227 SavegameHeader save_header; // [sp+CCh] [bp-1A4h]@10
79
6ad816231528 structure fixes, death crash fix
zipi
parents: 4
diff changeset
228 char Filename[255]; // [sp+130h] [bp-140h]@51
6ad816231528 structure fixes, death crash fix
zipi
parents: 4
diff changeset
229 char Ext[255]; // [sp+150h] [bp-120h]@51
0
Ritor1
parents:
diff changeset
230 char Source[32]; // [sp+170h] [bp-100h]@51
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
231 char work_string[120]; // [sp+190h] [bp-E0h]@8
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
232 int pPositionY; // [sp+208h] [bp-68h]@2
0
Ritor1
parents:
diff changeset
233 int pPositionX; // [sp+20Ch] [bp-64h]@2
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
234 int sPRotationY; // [sp+210h] [bp-60h]@2
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
235 int sPRotationX; // [sp+214h] [bp-5Ch]@2
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
236 ODMHeader odm_data; // [sp+218h] [bp-58h]@30
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
237 int res; // [sp+224h] [bp-4Ch]@30
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
238 int pPositionZ; // [sp+228h] [bp-48h]@2
0
Ritor1
parents:
diff changeset
239 size_t Size; // [sp+250h] [bp-20h]@26
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
240 char *uncompressed_buff; // [sp+258h] [bp-18h]@2
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
241 unsigned int compressed_block_size; // [sp+260h] [bp-10h]@23
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
242
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
243 //v66 = a2;
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
244 strcpy(byte_6BE3B0.data(), pCurrentMapName);//byte_6BE3B0 - save_map_name
1477
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
245 if (!_stricmp(pCurrentMapName, "d05.blv")) // arena
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
246 return;
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
247
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
248 uncompressed_buff = (char*)malloc(1000000);
982
08fd1436ef35 enums & lod
Nomad
parents: 847
diff changeset
249
08fd1436ef35 enums & lod
Nomad
parents: 847
diff changeset
250 LOD::Directory pLodDirectory; // [sp+22Ch] [bp-44h]@2
0
Ritor1
parents:
diff changeset
251 pPositionX = pParty->vPosition.x;
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
252 pPositionY = pParty->vPosition.y;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
253 pPositionZ = pParty->vPosition.z;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
254 sPRotationY = pParty->sRotationY;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
255 sPRotationX = pParty->sRotationX;
0
Ritor1
parents:
diff changeset
256 pParty->vPosition.x = pParty->vPrevPosition.x;
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
257 pParty->vPosition.z = pParty->vPrevPosition.z;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
258 pParty->vPosition.y = pParty->vPrevPosition.y;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
259
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
260 pParty->uFallStartY = pParty->vPrevPosition.z;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
261
0
Ritor1
parents:
diff changeset
262 pParty->sRotationY = pParty->sPrevRotationY;
Ritor1
parents:
diff changeset
263 pParty->sRotationX = pParty->sPrevRotationX;
Ritor1
parents:
diff changeset
264 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
Ritor1
parents:
diff changeset
265 pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed;
Ritor1
parents:
diff changeset
266 else
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
267 pOutdoor->loc_time.uLastVisitDay = pParty->uTimePlayed;
2154
9bd7522cdbbb Render decoupling.
Nomad
parents: 2153
diff changeset
268
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
269 pRenderer->PackScreenshot(150, 112, uncompressed_buff, 1000000, &pLodDirectory.uDataSize);//создание скриншота
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
270 strcpy(pLodDirectory.pFilename, "image.pcx");
2154
9bd7522cdbbb Render decoupling.
Nomad
parents: 2153
diff changeset
271
151
9abdd40a107b pCurrentScreen
Ritor1
parents: 79
diff changeset
272 if (pCurrentScreen == SCREEN_SAVEGAME)
0
Ritor1
parents:
diff changeset
273 {
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
274 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave));
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
275 pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_save_up));
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
276 text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[190]);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
277 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Сохранение
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
278 text_pos = pFontSmallnum->AlignText_Center(186, pSavegameHeader[uLoadGameUI_SelectedSlot].pName);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
279 pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, text_pos + 25, 259, 0, pSavegameHeader[uLoadGameUI_SelectedSlot].pName, 185, 0);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
280 text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[165]);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
281 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Пожалуйста, подождите
0
Ritor1
parents:
diff changeset
282 pRenderer->Present();
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
283 }
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
284
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
285 if (pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0))
0
Ritor1
parents:
diff changeset
286 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
287 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 200); //Сохраненная игра повреждена! Code=%d
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
288 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
0
Ritor1
parents:
diff changeset
289 }
Ritor1
parents:
diff changeset
290
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1489
diff changeset
291 Assert(sizeof(SavegameHeader) == 100);
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
292 memset(save_header.pName, 0, 20);
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
293 memset(save_header.pLocationName, 0, 20);
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
294 memset(save_header.field_30, 0, 52);
1477
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
295 strcpy(save_header.pLocationName, pCurrentMapName);
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
296 save_header.uWordTime = pParty->uTimePlayed;
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
297 strcpy(pLodDirectory.pFilename, "header.bin");
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
298 pLodDirectory.uDataSize = sizeof(SavegameHeader);
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
299 if (pNew_LOD->Write(&pLodDirectory, &save_header, 0))
0
Ritor1
parents:
diff changeset
300 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
301 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 201);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
302 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0);
0
Ritor1
parents:
diff changeset
303 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
304 strcpy(pLodDirectory.pFilename, "party.bin");
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
305 pLodDirectory.uDataSize = sizeof(Party); //90680;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
306 if ( pNew_LOD->Write(&pLodDirectory, pParty, 0) )
0
Ritor1
parents:
diff changeset
307 {
2127
400f3db2e4e5 Screenshot continue
Ritor1
parents: 2124
diff changeset
308 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 202);//Save game corrupted! Code=%d
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
309 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0);
0
Ritor1
parents:
diff changeset
310 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
311 strcpy(pLodDirectory.pFilename, "clock.bin");
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
312 pLodDirectory.uDataSize =sizeof(Timer);// 40;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
313 if ( pNew_LOD->Write(&pLodDirectory, pEventTimer, 0) )
0
Ritor1
parents:
diff changeset
314 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
315 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 203);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
316 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0);
0
Ritor1
parents:
diff changeset
317 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
318 strcpy(pLodDirectory.pFilename, "overlay.bin");
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
319 pLodDirectory.uDataSize =sizeof(OtherOverlayList);// 1008;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
320 if ( pNew_LOD->Write(&pLodDirectory, pOtherOverlayList, 0) )
0
Ritor1
parents:
diff changeset
321 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
322 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 204);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
323 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0);
0
Ritor1
parents:
diff changeset
324 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
325 strcpy(pLodDirectory.pFilename, "npcdata.bin");
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
326 pLodDirectory.uDataSize = 501 * sizeof(NPCData);
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1489
diff changeset
327 Assert(pLodDirectory.uDataSize == 38076);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
328 if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pNewNPCData, 0) )
0
Ritor1
parents:
diff changeset
329 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
330 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 205);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
331 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0);
0
Ritor1
parents:
diff changeset
332 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
333 strcpy(pLodDirectory.pFilename, "npcgroup.bin");
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
334 pLodDirectory.uDataSize = 102;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
335 if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pGroups_copy, 0) )
0
Ritor1
parents:
diff changeset
336 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
337 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 206);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
338 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0);
0
Ritor1
parents:
diff changeset
339 }
Ritor1
parents:
diff changeset
340 for (int i = 1; i <= 4; ++i) // 4 - players
Ritor1
parents:
diff changeset
341 {
Ritor1
parents:
diff changeset
342 for (int j = 1; j <= 5; ++j) // 5 - images
Ritor1
parents:
diff changeset
343 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
344 sprintf(work_string, "data\\lloyd%d%d.pcx", i, j);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
345 pLLoidFile = fopen(work_string, "rb");
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
346 if ( pLLoidFile )
0
Ritor1
parents:
diff changeset
347 {
Ritor1
parents:
diff changeset
348 __debugbreak();
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
349 sprintf(work_string, "lloyd%d%d.pcx", i, j);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
350 fseek(pLLoidFile, 0, SEEK_END);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
351 pLodDirectory.uDataSize = ftell(pLLoidFile);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
352 rewind(pLLoidFile);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
353 fread(uncompressed_buff, pLodDirectory.uDataSize, 1, pLLoidFile);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
354 strcpy(pLodDirectory.pFilename, work_string);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
355 fclose(pLLoidFile);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
356 remove(work_string);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
357 if ( pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0) )
0
Ritor1
parents:
diff changeset
358 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
359 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 207);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
360 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0);
0
Ritor1
parents:
diff changeset
361 Size = 5080748;
Ritor1
parents:
diff changeset
362 }
Ritor1
parents:
diff changeset
363 }
Ritor1
parents:
diff changeset
364 }
Ritor1
parents:
diff changeset
365 }
2124
7f403ebf619f GAME_STATE_CHANGE_LOCATION
Ritor1
parents: 2113
diff changeset
366 if ( !NotSaveWorld )//autosave for change location
0
Ritor1
parents:
diff changeset
367 {
79
6ad816231528 structure fixes, death crash fix
zipi
parents: 4
diff changeset
368 //__debugbreak();
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
369 CompactLayingItemsList();
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
370 compressed_buf = (char*)malloc(1000000);
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
371 odm_data.uVersion = 91969;
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
372 odm_data.pMagic[0] = 'm';
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
373 odm_data.pMagic[1] = 'v';
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
374 odm_data.pMagic[2] = 'i';
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
375 odm_data.pMagic[3] = 'i';
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
376 odm_data.uCompressedSize = 0;
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
377 odm_data.uDecompressedSize = 0;
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
378 data_write_pos = uncompressed_buff;
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
379 memcpy((void *)compressed_buf, &odm_data, 0x10);
0
Ritor1
parents:
diff changeset
380 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
Ritor1
parents:
diff changeset
381 {
Ritor1
parents:
diff changeset
382 pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces;
Ritor1
parents:
diff changeset
383 pIndoor->dlv.uNumBModels = 0;
Ritor1
parents:
diff changeset
384 pIndoor->dlv.uNumDecorations = uNumLevelDecorations;
837
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
385 memcpy(data_write_pos, &pIndoor->dlv,sizeof(DDM_DLV_Header) );//0x28
bebc19f3d2af Save/load work with some problems
Gloval
parents: 817
diff changeset
386 data_write_pos += sizeof(DDM_DLV_Header);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
387 memcpy(data_write_pos, pIndoor->_visible_outlines, 0x36B);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
388 data_write_pos += 875;
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
389 for (int i = 0; i <(signed int)pIndoor->uNumFaces; ++i)
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
390 {
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
391 memcpy(data_write_pos, &pIndoor->pFaces[i].uAttributes, 4);
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
392 data_write_pos += 4;
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
393 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
394
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
395 for (int i = 0; i <(signed int)uNumLevelDecorations; ++i)
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
396 {
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
397 memcpy(data_write_pos, &pLevelDecorations[i].uFlags, 2);
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
398 data_write_pos += 2;
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
399 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
400 memcpy(data_write_pos, &uNumActors, 4);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
401 data_write_pos += 4;
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
402 memcpy(data_write_pos, &pActors, uNumActors * sizeof(Actor));
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
403 data_write_pos += uNumActors * sizeof(Actor);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
404 memcpy(data_write_pos, &uNumSpriteObjects, 4);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
405 data_write_pos += 4;
1207
96a81634669e arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents: 1206
diff changeset
406 memcpy(data_write_pos, pSpriteObjects.data(), 112 * uNumSpriteObjects);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
407 data_write_pos += 112 * uNumSpriteObjects;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
408 memcpy(data_write_pos, &uNumChests, 4);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
409 data_write_pos += 4;
1202
0dbf6c4dd029 arrays to std::arrays phase 1
Grumpy7
parents: 1165
diff changeset
410 memcpy(data_write_pos, pChests.data(), sizeof(Chest)*uNumChests);//5324 *
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
411 data_write_pos += sizeof(Chest)* uNumChests;
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
412 memcpy(data_write_pos, pIndoor->pDoors, 0x3E80);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
413 data_write_pos += 16000;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
414 memcpy(data_write_pos, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
415 data_write_pos += pIndoor->blv.uDoors_ddata_Size;
1736
c6fe09a06712 Player::CompareVariable finished, renamed stru_5E4C90 to stru_5E4C90_MapPersistVars, party::field_4A0 to party::CounterEventValues
Grumpy7
parents: 1583
diff changeset
416 memcpy(data_write_pos, &stru_5E4C90_MapPersistVars, 0xC8);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
417 data_write_pos += 200;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
418 memcpy(data_write_pos, &pIndoor->stru1, 0x38);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
419 data_write_pos += 56;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
420
0
Ritor1
parents:
diff changeset
421 }
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
422 else//for Outdoor
0
Ritor1
parents:
diff changeset
423 {
Ritor1
parents:
diff changeset
424 pOutdoor->ddm.uNumFacesInBModels = 0;
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
425 for ( int i = 0; i < pOutdoor->uNumBModels; ++i )
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
426 pOutdoor->ddm.uNumFacesInBModels += pOutdoor->pBModels[i].uNumFaces;
0
Ritor1
parents:
diff changeset
427 pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels;
Ritor1
parents:
diff changeset
428 pOutdoor->ddm.uNumDecorations = uNumLevelDecorations;
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
429 memcpy(data_write_pos, &pOutdoor->ddm, sizeof(DDM_DLV_Header));//0x28
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
430 data_write_pos += sizeof(DDM_DLV_Header);
2364
94e5a9740727 OutdoorLocation::UpdateDiscoveredArea cleaned up
Grumpy7
parents: 2358
diff changeset
431 memcpy(data_write_pos, pOutdoor->uFullyRevealedCellOnMap, 0x3C8);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
432 data_write_pos += 968;
2364
94e5a9740727 OutdoorLocation::UpdateDiscoveredArea cleaned up
Grumpy7
parents: 2358
diff changeset
433 memcpy(data_write_pos, pOutdoor->uPartiallyRevealedCellOnMap, 0x3C8);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
434 data_write_pos += 968;
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
435 for (int i = 0; i < pOutdoor->uNumBModels ; ++i)
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
436 for (int j = 0; j < pOutdoor->pBModels[i].uNumFaces;++j)//*(int *)&pOutdoor->pBModels->pModelName[v24]; ++j)
0
Ritor1
parents:
diff changeset
437 {
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
438 memcpy(data_write_pos, &(pOutdoor->pBModels[i].pFaces[j].uAttributes), 4);
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
439 data_write_pos += 4;
0
Ritor1
parents:
diff changeset
440 }
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
441
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
442 for (int i = 0; i < (signed int)uNumLevelDecorations; ++i)
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
443 {
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
444 memcpy(data_write_pos, &pLevelDecorations[i].uFlags, 2);
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
445 data_write_pos += 2;
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
446 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
447 memcpy(data_write_pos, &uNumActors, 4);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
448 data_write_pos += 4;
2178
43175acce099 savegame fix
Ritor1
parents: 2177
diff changeset
449 memcpy(data_write_pos, &pActors, uNumActors * sizeof(Actor));
43175acce099 savegame fix
Ritor1
parents: 2177
diff changeset
450 data_write_pos += uNumActors * sizeof(Actor);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
451 memcpy(data_write_pos, &uNumSpriteObjects, 4);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
452 data_write_pos += 4;
2178
43175acce099 savegame fix
Ritor1
parents: 2177
diff changeset
453 memcpy(data_write_pos, &pSpriteObjects, uNumSpriteObjects * sizeof(SpriteObject));
43175acce099 savegame fix
Ritor1
parents: 2177
diff changeset
454 data_write_pos += uNumSpriteObjects * sizeof(SpriteObject);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
455 memcpy(data_write_pos, &uNumChests, 4);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
456 data_write_pos += 4;
1202
0dbf6c4dd029 arrays to std::arrays phase 1
Grumpy7
parents: 1165
diff changeset
457 memcpy(data_write_pos, pChests.data(), sizeof(Chest)* uNumChests);
2178
43175acce099 savegame fix
Ritor1
parents: 2177
diff changeset
458 data_write_pos += sizeof(Chest) * uNumChests;
1736
c6fe09a06712 Player::CompareVariable finished, renamed stru_5E4C90 to stru_5E4C90_MapPersistVars, party::field_4A0 to party::CounterEventValues
Grumpy7
parents: 1583
diff changeset
459 memcpy(data_write_pos, &stru_5E4C90_MapPersistVars, 0xC8);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
460 data_write_pos += 200;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
461 memcpy(data_write_pos, &pOutdoor->loc_time, 0x38);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
462 data_write_pos += 56;
0
Ritor1
parents:
diff changeset
463 }
1477
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
464 strcpy(Source, pCurrentMapName);
79
6ad816231528 structure fixes, death crash fix
zipi
parents: 4
diff changeset
465 _splitpath(Source, Drive, Dir, Filename, Ext);
2178
43175acce099 savegame fix
Ritor1
parents: 2177
diff changeset
466 Ext[1] = 'd';
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
467
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
468 Size = (int)data_write_pos - (int)uncompressed_buff;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
469 compressed_block_size = 999984;
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
470 res = zlib::MemZip((char *)compressed_buf + 16, (unsigned int *)&compressed_block_size, uncompressed_buff,Size);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
471 if (res || (signed int)compressed_block_size > (signed int)Size )
0
Ritor1
parents:
diff changeset
472 {
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
473 memcpy((void *)(compressed_buf + 16), uncompressed_buff, Size);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
474 compressed_block_size = Size;
0
Ritor1
parents:
diff changeset
475 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
476 compressed_block_size += 16;
814
35122475edd7 struct correction
Gloval
parents: 810
diff changeset
477 memcpy(&((ODMHeader *)compressed_buf)->uCompressedSize, &compressed_block_size, 4);
35122475edd7 struct correction
Gloval
parents: 810
diff changeset
478 memcpy(&((ODMHeader *)compressed_buf)->uDecompressedSize, &Size, 4);
2224
c2eeeb991a87 some more pvs warning fixes
Grumpy7
parents: 2184
diff changeset
479 sprintf(Source, "%s%s", Filename, Ext);
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
480 strcpy(pLodDirectory.pFilename, Source);
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
481 pLodDirectory.uDataSize = compressed_block_size;
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
482 if ( pNew_LOD->Write(&pLodDirectory, (const void *)compressed_buf, 0) )
0
Ritor1
parents:
diff changeset
483 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
484 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 208);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
485 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0);
0
Ritor1
parents:
diff changeset
486 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
487 free((void *)compressed_buf);
0
Ritor1
parents:
diff changeset
488 }
810
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
489 free(uncompressed_buff);
f5156b8c61ad savegame refactoring
Gloval
parents: 764
diff changeset
490 if ( IsAutoSAve )
0
Ritor1
parents:
diff changeset
491 {
Ritor1
parents:
diff changeset
492 if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) )
Ritor1
parents:
diff changeset
493 {
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
494 FormatMessageA(0x1000, 0, GetLastError(), 0x400, Buffer, 0x80, 0);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
495 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 300);
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
496 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0);
0
Ritor1
parents:
diff changeset
497 }
Ritor1
parents:
diff changeset
498 }
Ritor1
parents:
diff changeset
499 pParty->vPosition.x = pPositionX;
847
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
500 pParty->vPosition.y = pPositionY;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
501 pParty->vPosition.z = pPositionZ;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
502 pParty->uFallStartY = pPositionZ;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
503 pParty->sRotationY = sPRotationY;
e398541aee60 fixed party save position
Gloval
parents: 837
diff changeset
504 pParty->sRotationX = sPRotationX;
0
Ritor1
parents:
diff changeset
505 }
Ritor1
parents:
diff changeset
506
Ritor1
parents:
diff changeset
507 //----- (00460078) --------------------------------------------------------
Ritor1
parents:
diff changeset
508 void __fastcall DoSavegame(unsigned int uSlot)
Ritor1
parents:
diff changeset
509 {
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
510 if ( _stricmp(pCurrentMapName, "d05.blv") )//Not Arena(не Арена)
0
Ritor1
parents:
diff changeset
511 {
Ritor1
parents:
diff changeset
512 LOD::Directory pDir; // [sp+Ch] [bp-28h]@2
Ritor1
parents:
diff changeset
513 SaveGame(0, 0);
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
514 strcpy(pSavegameHeader[uSlot].pLocationName, pCurrentMapName);//дать название карты
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
515 pSavegameHeader[uSlot].uWordTime = pParty->uTimePlayed;//текущее время
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
516 strcpy(pDir.pFilename, "header.bin");
0
Ritor1
parents:
diff changeset
517 pDir.uDataSize = 100;
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
518 pNew_LOD->Write(&pDir, &pSavegameHeader[uSlot], 0);
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
519 sprintf(pTmpBuf.data(), "saves\\save%03d.mm7", uSlot);
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
520 pNew_LOD->CloseWriteFile();//закрыть
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
521 CopyFileA("data\\new.lod", pTmpBuf.data(), 0);//сохранение файла в директорию saves
0
Ritor1
parents:
diff changeset
522 }
Ritor1
parents:
diff changeset
523 GUI_UpdateWindows();
Ritor1
parents:
diff changeset
524 pGUIWindow_CurrentMenu->Release();
151
9abdd40a107b pCurrentScreen
Ritor1
parents: 79
diff changeset
525 pCurrentScreen = SCREEN_GAME;
557
604d70894002 Saving works partly
zipi
parents: 515
diff changeset
526 //v3 = pSavegameThumbnails;
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
527 viewparams->bRedrawGameUI = true;
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
528 for (uint i = 0; i < 45; i++)
557
604d70894002 Saving works partly
zipi
parents: 515
diff changeset
529 pSavegameThumbnails[i].Release();
2154
9bd7522cdbbb Render decoupling.
Nomad
parents: 2153
diff changeset
530
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
531 if ( _stricmp(pCurrentMapName, "d05.blv") )
0
Ritor1
parents:
diff changeset
532 pNew_LOD->_4621A7();
Ritor1
parents:
diff changeset
533 else
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
534 ShowStatusBarString(pGlobalTXT_LocalizationStrings[583], 2);// "No saving in the Arena"
1405
c0b273d33338 RemoveTexturesPackFromTextureList and RemoveTexturesFromTextureList
Ritor1
parents: 1404
diff changeset
535 pIcons_LOD->RemoveTexturesFromTextureList();
0
Ritor1
parents:
diff changeset
536 pEventTimer->Resume();
2173
daa61976637d savegame and loadgame continue
Ritor1
parents: 2154
diff changeset
537 ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2);// "Game Saved!"
568
6f7d936edc9b SaveGame/LoadGame sorta works
Nomad
parents: 557
diff changeset
538 viewparams->bRedrawGameUI = true;
0
Ritor1
parents:
diff changeset
539 }
Ritor1
parents:
diff changeset
540 // 4E28F8: using guessed type int pCurrentScreen;
Ritor1
parents:
diff changeset
541
Ritor1
parents:
diff changeset
542 //----- (0045E297) --------------------------------------------------------
Ritor1
parents:
diff changeset
543 void SavegameList::Initialize(unsigned int bHideEmptySlots)
Ritor1
parents:
diff changeset
544 {
2181
17b3e40daedc _427E01_cast_spell continue
Ritor1
parents: 2180
diff changeset
545 //memset(pSavegameList, 0, sizeof(pSavegameList));//Ritor1: вызывает затирание
2180
147ee4591b76 pSavegameList->Reset()
Ritor1
parents: 2179
diff changeset
546 pSavegameList->Reset();
147ee4591b76 pSavegameList->Reset()
Ritor1
parents: 2179
diff changeset
547 uNumSavegameFiles = 0;
0
Ritor1
parents:
diff changeset
548
Ritor1
parents:
diff changeset
549 _chdir("saves");
Ritor1
parents:
diff changeset
550 {
4
8e33efd39355 15.01.13(work)
Ritor1
parents: 0
diff changeset
551 if (!bHideEmptySlots && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 ) // AutoSave.MM7
382
a4a5996fea5b Fixed savelist problem
Gloval
parents: 373
diff changeset
552 strcpy(pSavegameList->pFileList[uNumSavegameFiles++].pSaveFileName, pGlobalTXT_LocalizationStrings[613]);
0
Ritor1
parents:
diff changeset
553
Ritor1
parents:
diff changeset
554 for (uint i = 0; i < 40; ++i)
Ritor1
parents:
diff changeset
555 {
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
556 sprintf(pTmpBuf.data(), "save%03d.mm7", i);
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
557 if (_access(pTmpBuf.data(), 0) == -1)
0
Ritor1
parents:
diff changeset
558 continue;
Ritor1
parents:
diff changeset
559
Ritor1
parents:
diff changeset
560 uint idx = i;
Ritor1
parents:
diff changeset
561 if (!bHideEmptySlots)
Ritor1
parents:
diff changeset
562 idx = uNumSavegameFiles;
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
563 strcpy(pSavegameList->pFileList[idx].pSaveFileName, pTmpBuf.data());
0
Ritor1
parents:
diff changeset
564
Ritor1
parents:
diff changeset
565 ++uNumSavegameFiles;
Ritor1
parents:
diff changeset
566 }
Ritor1
parents:
diff changeset
567 }
Ritor1
parents:
diff changeset
568 _chdir("..");
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
569 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
570 //----- (0046086A) --------------------------------------------------------
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
571 void SaveNewGame()
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
572 {
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
573 FILE *file; // eax@7
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
574 void *pSave; // [sp+170h] [bp-8h]@3
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
575
2394
2fe8feb3dcd1 pMovie renamed to pMovie_Track and other
Ritor1
parents: 2386
diff changeset
576 if ( pMovie_Track )
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
577 pVideoPlayer->Unload();
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
578 pSave = malloc(1000000);
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
579 pNew_LOD->CloseWriteFile();
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
580 remove("data\\new.lod");//удалить new.lod
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
581
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
582 LOD::FileHeader header; // [sp+Ch] [bp-16Ch]@3 заголовок
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
583 strcpy(header.LodVersion, "MMVII");
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
584 strcpy(header.LodDescription, "newmaps for MMVII");
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
585 header.LODSize = 100;
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
586 header.dword_0000A8 = 0;
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
587
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
588 LOD::Directory a3; // [sp+14Ch] [bp-2Ch]@3
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
589 a3.dword_000018 = 0;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
590 a3.word_00001E = 0;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
591 strcpy(a3.pFilename, "current");
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
592 pNew_LOD->CreateNewLod(&header, &a3, "data\\new.lod");//создаётся new.lod в дирректории
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
593 if (pNew_LOD->LoadFile("data\\new.lod", false))//загрузить файл new.lod(isFileOpened = true)
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
594 {
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
595 pNew_LOD->CreateTempFile();//создаётся временный файл OutputFileHandle
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
596 pNew_LOD->uNumSubDirs = 0;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
597
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
598 LOD::Directory pDir; // [sp+10Ch] [bp-6Ch]@4
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
599 for (int i = pGames_LOD->uNumSubDirs / 2; i < pGames_LOD->uNumSubDirs; ++i)//копирование файлов с 76 по 151
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
600 {
2174
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
601 memcpy(&pDir, &pGames_LOD->pSubIndices[i], sizeof(pDir));//копирование текущего файла в pDir
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
602 file = pGames_LOD->FindContainer(pGames_LOD->pSubIndices[i].pFilename, 1);
5ca3251ea543 autosave continue
Ritor1
parents: 2173
diff changeset
603 fread(pSave, pGames_LOD->pSubIndices[i].uDataSize, 1, file);
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
604 pNew_LOD->AppendDirectory(&pDir, pSave);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
605 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
606
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
607 LOD::Directory save_game_dir; // [sp+12Ch] [bp-4Ch]@9
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
608 strcpy(pSavegameHeader[0].pLocationName, "out01.odm");
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
609 strcpy(save_game_dir.pFilename, "header.bin");
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
610 save_game_dir.uDataSize = sizeof(SavegameHeader);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
611 pNew_LOD->AppendDirectory(&save_game_dir, &pSavegameHeader[0]);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
612
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
613 pNew_LOD->FixDirectoryOffsets();
2177
e1199b655710 pParty->vPrevPosition.y = 1816; and pParty->vPrevPosition.z = 0;
Ritor1
parents: 2174
diff changeset
614
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
615 pParty->vPrevPosition.x = 12552;
2177
e1199b655710 pParty->vPrevPosition.y = 1816; and pParty->vPrevPosition.z = 0;
Ritor1
parents: 2174
diff changeset
616 pParty->vPrevPosition.y = 1816;
e1199b655710 pParty->vPrevPosition.y = 1816; and pParty->vPrevPosition.z = 0;
Ritor1
parents: 2174
diff changeset
617 pParty->vPrevPosition.z = 0;
e1199b655710 pParty->vPrevPosition.y = 1816; and pParty->vPrevPosition.z = 0;
Ritor1
parents: 2174
diff changeset
618
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
619 pParty->vPosition.x = 12552;
2177
e1199b655710 pParty->vPrevPosition.y = 1816; and pParty->vPrevPosition.z = 0;
Ritor1
parents: 2174
diff changeset
620 pParty->vPosition.y = 1816;
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
621 pParty->vPosition.z = 0;
2177
e1199b655710 pParty->vPrevPosition.y = 1816; and pParty->vPrevPosition.z = 0;
Ritor1
parents: 2174
diff changeset
622
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
623 pParty->uFallStartY = 0;
2177
e1199b655710 pParty->vPrevPosition.y = 1816; and pParty->vPrevPosition.z = 0;
Ritor1
parents: 2174
diff changeset
624
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
625 pParty->sPrevRotationX = 0;
2177
e1199b655710 pParty->vPrevPosition.y = 1816; and pParty->vPrevPosition.z = 0;
Ritor1
parents: 2174
diff changeset
626 pParty->sPrevRotationY = 512;
e1199b655710 pParty->vPrevPosition.y = 1816; and pParty->vPrevPosition.z = 0;
Ritor1
parents: 2174
diff changeset
627
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
628 pParty->sRotationX = 0;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
629 pParty->sRotationY = 512;
2177
e1199b655710 pParty->vPrevPosition.y = 1816; and pParty->vPrevPosition.z = 0;
Ritor1
parents: 2174
diff changeset
630
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
631 SaveGame(1, 1);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
632 }
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
633 free(pSave);
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
634 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1207
diff changeset
635