annotate Engine/SaveLoad.cpp @ 2546:4087cbc62706

GameMenu logic moved to GUIWindow_GameMenu the same for game menu options
author a.parshin
date Mon, 11 May 2015 17:45:02 +0200
parents a902abdfc7f2
children ac16f4a3a91e
rev   line source
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1 #define _CRTDBG_MAP_ALLOC
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2 #include <stdlib.h>
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
3 #include <crtdbg.h>
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
4
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
5 #define _CRT_SECURE_NO_WARNINGS
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
6 #include <io.h>
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
7 #include <direct.h>
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
8
2541
a902abdfc7f2 1. Renamed class Game to class Engine.
a.parshin
parents: 2508
diff changeset
9 #include "Engine/Engine.h"
a902abdfc7f2 1. Renamed class Game to class Engine.
a.parshin
parents: 2508
diff changeset
10
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
11 #include "ZlibWrapper.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
12 #include "SaveLoad.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
13 #include "Party.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
14 #include "LOD.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
15 #include "Engine/Graphics/Outdoor.h"
2502
a77c34acdbc9 Media folder
Ritor1
parents: 2499
diff changeset
16 #include "Media/Audio/AudioPlayer.h"
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
17 #include "Engine/Objects/Actor.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
18 #include "Engine/Objects/Chest.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
19 #include "Timer.h"
2502
a77c34acdbc9 Media folder
Ritor1
parents: 2499
diff changeset
20 #include "GUI/GUIWindow.h"
a77c34acdbc9 Media folder
Ritor1
parents: 2499
diff changeset
21 #include "GUI/GUIFont.h"
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
22 #include "Engine/Graphics/Overlays.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
23 #include "Engine/Objects/SpriteObject.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
24 #include "Engine/Graphics/Viewport.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
25 #include "stru123.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
26 #include "texts.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
27 #include "Engine/Graphics/Level/Decoration.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
28
2508
491f0babd563 use_music_folder
Ritor1
parents: 2502
diff changeset
29 #include "MMT.h"
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
30
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
31
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
32
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
33 struct SavegameList *pSavegameList = new SavegameList;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
34 unsigned int uNumSavegameFiles;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
35 std::array<unsigned int, 45> pSavegameUsedSlots;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
36 std::array<struct RGBTexture, 45> pSavegameThumbnails;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
37 std::array<SavegameHeader, 45> pSavegameHeader;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
38
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
39 //----- (0045EE8A) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
40 void __fastcall LoadGame(unsigned int uSlot)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
41 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
42 bool v25; // esi@62
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
43 bool v26; // eax@62
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
44 SavegameHeader header; // [sp+Ch] [bp-E4h]@23
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
45 char Str[123]; // [sp+70h] [bp-80h]@25
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
46
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
47 MapsLongTimers_count = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
48 if (!pSavegameUsedSlots[uSlot])
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
49 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
50 pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
51 Log::Warning(L"LoadGame: slot %u is empty", uSlot);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
52 return;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
53 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
54
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
55 for (uint i = 1; i < 5; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
56 for (uint j = 1; j < 6; ++j)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
57 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
58 sprintf(pTmpBuf.data(), "data\\lloyd%d%d.pcx", i, j);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
59 remove(pTmpBuf.data());
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
60 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
61
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
62 if (SoundSetAction[24][0])
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
63 for (uint i = 0; i < 4; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
64 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
65 for (uint j = 0; j < pSoundList->sNumSounds; ++j)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
66 if (pSoundList->pSL_Sounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4998)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
67 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
68 pSoundList->UnloadSound(j, 1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
69 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
70 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
71
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
72 for (uint j = 0; j < pSoundList->sNumSounds; ++j)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
73 if (pSoundList->pSL_Sounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4999)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
74 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
75 pSoundList->UnloadSound(j, 1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
76 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
77 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
78 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
79
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
80 sprintf(pTmpBuf.data(), "saves\\%s", pSavegameList->pFileList[uSlot].pSaveFileName);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
81
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
82 pNew_LOD->CloseWriteFile();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
83 if (!CopyFileA(pTmpBuf.data(), "data\\new.lod", 0))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
84 int e = GetLastError();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
85
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
86 pNew_LOD->LoadFile("data\\new.lod", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
87 FILE *file = pNew_LOD->FindContainer("header.bin", 1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
88 if (!file)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
89 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
90 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 100);//Сохраненная игра повреждена! Code=%d
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
91 Log::Warning(L"%S", Str);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
92 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:549", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
93 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
94 Assert(sizeof(SavegameHeader) == 100);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
95 fread(&header, sizeof(SavegameHeader), 1, file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
96
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
97 file = pNew_LOD->FindContainer("party.bin", 1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
98 if (!file)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
99 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
100 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 101);//Сохраненная игра повреждена! Code=%d
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
101 Log::Warning(L"%S", Str);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
102 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:559", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
103 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
104 if (sizeof(Party) != 0x16238)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
105 Log::Warning(L"class Party: deserialization warning");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
106 fread(pParty, sizeof(Party), 1, file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
107
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
108
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
109 file = pNew_LOD->FindContainer("clock.bin", 1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
110 if (!file)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
111 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
112 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 102);//Сохраненная игра повреждена! Code=%d
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
113 Log::Warning(L"%S", Str);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
114 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:569", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
115 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
116 if (sizeof(Timer) != 0x28)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
117 Log::Warning(L"class Timer: deserialization warning");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
118 fread(pEventTimer, sizeof(Timer), 1, file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
119
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
120 file = pNew_LOD->FindContainer("overlay.bin", 1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
121 if (!file)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
122 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
123 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 103);//Сохраненная игра повреждена! Code=%d
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
124 Log::Warning(L"%S", Str);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
125 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:579", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
126 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
127 if (sizeof(OtherOverlayList) != 0x3F0)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
128 Log::Warning(L"class OtherOverlayList: deserialization warning");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
129 fread(pOtherOverlayList, sizeof(OtherOverlayList), 1, file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
130
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
131 file = pNew_LOD->FindContainer("npcdata.bin", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
132 if (!file)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
133 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
134 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 104);//Сохраненная игра повреждена! Code=%d
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
135 Log::Warning(L"%S", Str);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
136 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:590", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
137 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
138 if (sizeof(pNPCStats->pNewNPCData) != 0x94BC)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
139 Log::Warning(L"NPCStats: deserialization warning");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
140 fread(pNPCStats->pNewNPCData, sizeof(pNPCStats->pNewNPCData), 1, file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
141 pNPCStats->_476C60();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
142
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
143 file = pNew_LOD->FindContainer("npcgroup.bin", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
144 if (!file)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
145 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
146 sprintf(Str, pGlobalTXT_LocalizationStrings[612], 105);//Сохраненная игра повреждена! Code=%d
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
147 Log::Warning(L"%S", Str);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
148 MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:600", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
149 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
150 if (sizeof(pNPCStats->pGroups_copy) != 0x66)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
151 Log::Warning(L"NPCStats: deserialization warning");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
152 fread(pNPCStats->pGroups_copy, sizeof(pNPCStats->pGroups_copy), 1, file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
153
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
154 uActiveCharacter = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
155 for (uint i = 0; i < 4; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
156 if (pParty->pPlayers[i].CanAct())
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
157 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
158 uActiveCharacter = i + 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
159 break;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
160 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
161
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
162 for (uint i = 0; i < 4; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
163 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
164 if ( pParty->pPlayers[i].uQuickSpell )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
165 AA1058_PartyQuickSpellSound[i].AddPartySpellSound(pParty->pPlayers[i].uQuickSpell, i + 1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
166
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
167 for (uint j = 0; j < 2; ++j)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
168 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
169 uint uEquipIdx = pParty->pPlayers[i].pEquipment.pIndices[j];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
170 if (uEquipIdx)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
171 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
172 int pItemID = pParty->pPlayers[i].pInventoryItemList[uEquipIdx - 1].uItemID;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
173 if (pItemsTable->pItems[pItemID].uEquipType == EQUIP_WAND && pItemID )//жезл
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
174 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
175 __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
176 stru_A750F8[i].AddPartySpellSound(wand_spell_ids[pItemID - ITEM_WAND_FIRE], i + 9);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
177 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
178 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
179 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
180 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
181
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
182 pGUIWindow_CurrentMenu->Release();
2541
a902abdfc7f2 1. Renamed class Game to class Engine.
a.parshin
parents: 2508
diff changeset
183 current_screen_type = SCREEN_GAME;
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
184
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
185 viewparams->bRedrawGameUI = true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
186
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
187 SetUserInterface(pParty->alignment, true);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
188
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
189 pEventTimer->Resume();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
190 pEventTimer->StopGameTime();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
191
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
192 v25 = pGames_LOD->DoesContainerExist(header.pLocationName);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
193 sprintf(pTmpBuf.data(), "levels\\%s", header.pLocationName);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
194 v26 = _access(pTmpBuf.data(), 4) != -1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
195 if ( !v25 && !v26 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
196 Error("Unable to find: %s!", header.pLocationName);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
197
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
198 strcpy(pCurrentMapName, header.pLocationName);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
199 dword_6BE364_game_settings_1 |= GAME_SETTINGS_2000 | GAME_SETTINGS_0001;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
200
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
201 for (uint i = 0; i < uNumSavegameFiles; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
202 pSavegameThumbnails[i].Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
203
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
204 pIcons_LOD->RemoveTexturesPackFromTextureList();
2508
491f0babd563 use_music_folder
Ritor1
parents: 2502
diff changeset
205 if ( use_music_folder )
491f0babd563 use_music_folder
Ritor1
parents: 2502
diff changeset
206 alSourcef (mSourceID, AL_GAIN, pSoundVolumeLevels[uMusicVolimeMultiplier]);
491f0babd563 use_music_folder
Ritor1
parents: 2502
diff changeset
207 else
491f0babd563 use_music_folder
Ritor1
parents: 2502
diff changeset
208 pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
209 pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
210 if (uTurnSpeed)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
211 pParty->sRotationY = uTurnSpeed * pParty->sRotationY / (signed int)uTurnSpeed;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
212 MM7Initialization();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
213 bFlashQuestBook = false;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
214 viewparams->bRedrawGameUI = true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
215 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
216
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
217 //----- (0045F469) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
218 void SaveGame( bool IsAutoSAve, bool NotSaveWorld )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
219 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
220 int text_pos; // eax@6
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
221 FILE *pLLoidFile; // edi@24
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
222 char* compressed_buf; // edi@30
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
223 char *data_write_pos; // esi@41
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
224 CHAR Buffer[128]; // [sp+Ch] [bp-264h]@59
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
225 char Dir[255]; // [sp+8Ch] [bp-1E4h]@51
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
226 char Drive[255]; // [sp+ACh] [bp-1C4h]@51
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
227 SavegameHeader save_header; // [sp+CCh] [bp-1A4h]@10
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
228 char Filename[255]; // [sp+130h] [bp-140h]@51
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
229 char Ext[255]; // [sp+150h] [bp-120h]@51
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
230 char Source[32]; // [sp+170h] [bp-100h]@51
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
231 char work_string[120]; // [sp+190h] [bp-E0h]@8
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
232 int pPositionY; // [sp+208h] [bp-68h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
233 int pPositionX; // [sp+20Ch] [bp-64h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
234 int sPRotationY; // [sp+210h] [bp-60h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
235 int sPRotationX; // [sp+214h] [bp-5Ch]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
236 ODMHeader odm_data; // [sp+218h] [bp-58h]@30
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
237 int res; // [sp+224h] [bp-4Ch]@30
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
238 int pPositionZ; // [sp+228h] [bp-48h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
239 size_t Size; // [sp+250h] [bp-20h]@26
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
240 char *uncompressed_buff; // [sp+258h] [bp-18h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
241 unsigned int compressed_block_size; // [sp+260h] [bp-10h]@23
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
242
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
243 //v66 = a2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
244 strcpy(byte_6BE3B0.data(), pCurrentMapName);//byte_6BE3B0 - save_map_name
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
245 if (!_stricmp(pCurrentMapName, "d05.blv")) // arena
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
246 return;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
247
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
248 uncompressed_buff = (char*)malloc(1000000);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
249
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
250 LOD::Directory pLodDirectory; // [sp+22Ch] [bp-44h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
251 pPositionX = pParty->vPosition.x;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
252 pPositionY = pParty->vPosition.y;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
253 pPositionZ = pParty->vPosition.z;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
254 sPRotationY = pParty->sRotationY;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
255 sPRotationX = pParty->sRotationX;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
256 pParty->vPosition.x = pParty->vPrevPosition.x;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
257 pParty->vPosition.z = pParty->vPrevPosition.z;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
258 pParty->vPosition.y = pParty->vPrevPosition.y;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
259
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
260 pParty->uFallStartY = pParty->vPrevPosition.z;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
261
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
262 pParty->sRotationY = pParty->sPrevRotationY;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
263 pParty->sRotationX = pParty->sPrevRotationX;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
264 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
265 pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
266 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
267 pOutdoor->loc_time.uLastVisitDay = pParty->uTimePlayed;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
268
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
269 pRenderer->PackScreenshot(150, 112, uncompressed_buff, 1000000, &pLodDirectory.uDataSize);//создание скриншота
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
270 strcpy(pLodDirectory.pFilename, "image.pcx");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
271
2541
a902abdfc7f2 1. Renamed class Game to class Engine.
a.parshin
parents: 2508
diff changeset
272 if (current_screen_type == SCREEN_SAVEGAME)
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
273 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
274 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
275 pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_save_up));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
276 text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[190]);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
277 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Сохранение
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
278 text_pos = pFontSmallnum->AlignText_Center(186, pSavegameHeader[uLoadGameUI_SelectedSlot].pName);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
279 pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, text_pos + 25, 259, 0, pSavegameHeader[uLoadGameUI_SelectedSlot].pName, 185, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
280 text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[165]);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
281 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Пожалуйста, подождите
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
282 pRenderer->Present();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
283 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
284
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
285 if (pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
286 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
287 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 200); //Сохраненная игра повреждена! Code=%d
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
288 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
289 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
290
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
291 Assert(sizeof(SavegameHeader) == 100);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
292 memset(save_header.pName, 0, 20);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
293 memset(save_header.pLocationName, 0, 20);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
294 memset(save_header.field_30, 0, 52);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
295 strcpy(save_header.pLocationName, pCurrentMapName);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
296 save_header.uWordTime = pParty->uTimePlayed;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
297 strcpy(pLodDirectory.pFilename, "header.bin");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
298 pLodDirectory.uDataSize = sizeof(SavegameHeader);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
299 if (pNew_LOD->Write(&pLodDirectory, &save_header, 0))
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
300 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
301 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 201);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
302 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
303 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
304 strcpy(pLodDirectory.pFilename, "party.bin");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
305 pLodDirectory.uDataSize = sizeof(Party); //90680;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
306 if ( pNew_LOD->Write(&pLodDirectory, pParty, 0) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
307 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
308 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 202);//Save game corrupted! Code=%d
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
309 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
310 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
311 strcpy(pLodDirectory.pFilename, "clock.bin");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
312 pLodDirectory.uDataSize =sizeof(Timer);// 40;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
313 if ( pNew_LOD->Write(&pLodDirectory, pEventTimer, 0) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
314 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
315 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 203);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
316 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
317 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
318 strcpy(pLodDirectory.pFilename, "overlay.bin");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
319 pLodDirectory.uDataSize =sizeof(OtherOverlayList);// 1008;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
320 if ( pNew_LOD->Write(&pLodDirectory, pOtherOverlayList, 0) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
321 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
322 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 204);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
323 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
324 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
325 strcpy(pLodDirectory.pFilename, "npcdata.bin");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
326 pLodDirectory.uDataSize = 501 * sizeof(NPCData);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
327 Assert(pLodDirectory.uDataSize == 38076);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
328 if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pNewNPCData, 0) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
329 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
330 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 205);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
331 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
332 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
333 strcpy(pLodDirectory.pFilename, "npcgroup.bin");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
334 pLodDirectory.uDataSize = 102;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
335 if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pGroups_copy, 0) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
336 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
337 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 206);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
338 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
339 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
340 for (int i = 1; i <= 4; ++i) // 4 - players
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
341 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
342 for (int j = 1; j <= 5; ++j) // 5 - images
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
343 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
344 sprintf(work_string, "data\\lloyd%d%d.pcx", i, j);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
345 pLLoidFile = fopen(work_string, "rb");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
346 if ( pLLoidFile )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
347 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
348 __debugbreak();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
349 sprintf(work_string, "lloyd%d%d.pcx", i, j);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
350 fseek(pLLoidFile, 0, SEEK_END);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
351 pLodDirectory.uDataSize = ftell(pLLoidFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
352 rewind(pLLoidFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
353 fread(uncompressed_buff, pLodDirectory.uDataSize, 1, pLLoidFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
354 strcpy(pLodDirectory.pFilename, work_string);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
355 fclose(pLLoidFile);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
356 remove(work_string);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
357 if ( pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
358 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
359 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 207);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
360 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
361 Size = 5080748;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
362 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
363 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
364 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
365 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
366 if ( !NotSaveWorld )//autosave for change location
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
367 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
368 //__debugbreak();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
369 CompactLayingItemsList();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
370 compressed_buf = (char*)malloc(1000000);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
371 odm_data.uVersion = 91969;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
372 odm_data.pMagic[0] = 'm';
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
373 odm_data.pMagic[1] = 'v';
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
374 odm_data.pMagic[2] = 'i';
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
375 odm_data.pMagic[3] = 'i';
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
376 odm_data.uCompressedSize = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
377 odm_data.uDecompressedSize = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
378 data_write_pos = uncompressed_buff;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
379 memcpy((void *)compressed_buf, &odm_data, 0x10);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
380 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
381 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
382 pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
383 pIndoor->dlv.uNumBModels = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
384 pIndoor->dlv.uNumDecorations = uNumLevelDecorations;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
385 memcpy(data_write_pos, &pIndoor->dlv,sizeof(DDM_DLV_Header) );//0x28
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
386 data_write_pos += sizeof(DDM_DLV_Header);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
387 memcpy(data_write_pos, pIndoor->_visible_outlines, 0x36B);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
388 data_write_pos += 875;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
389 for (int i = 0; i <(signed int)pIndoor->uNumFaces; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
390 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
391 memcpy(data_write_pos, &pIndoor->pFaces[i].uAttributes, 4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
392 data_write_pos += 4;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
393 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
394
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
395 for (int i = 0; i <(signed int)uNumLevelDecorations; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
396 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
397 memcpy(data_write_pos, &pLevelDecorations[i].uFlags, 2);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
398 data_write_pos += 2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
399 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
400 memcpy(data_write_pos, &uNumActors, 4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
401 data_write_pos += 4;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
402 memcpy(data_write_pos, &pActors, uNumActors * sizeof(Actor));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
403 data_write_pos += uNumActors * sizeof(Actor);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
404 memcpy(data_write_pos, &uNumSpriteObjects, 4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
405 data_write_pos += 4;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
406 memcpy(data_write_pos, pSpriteObjects.data(), 112 * uNumSpriteObjects);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
407 data_write_pos += 112 * uNumSpriteObjects;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
408 memcpy(data_write_pos, &uNumChests, 4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
409 data_write_pos += 4;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
410 memcpy(data_write_pos, pChests.data(), sizeof(Chest)*uNumChests);//5324 *
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
411 data_write_pos += sizeof(Chest)* uNumChests;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
412 memcpy(data_write_pos, pIndoor->pDoors, 0x3E80);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
413 data_write_pos += 16000;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
414 memcpy(data_write_pos, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
415 data_write_pos += pIndoor->blv.uDoors_ddata_Size;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
416 memcpy(data_write_pos, &stru_5E4C90_MapPersistVars, 0xC8);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
417 data_write_pos += 200;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
418 memcpy(data_write_pos, &pIndoor->stru1, 0x38);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
419 data_write_pos += 56;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
420
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
421 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
422 else//for Outdoor
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
423 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
424 pOutdoor->ddm.uNumFacesInBModels = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
425 for ( int i = 0; i < pOutdoor->uNumBModels; ++i )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
426 pOutdoor->ddm.uNumFacesInBModels += pOutdoor->pBModels[i].uNumFaces;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
427 pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
428 pOutdoor->ddm.uNumDecorations = uNumLevelDecorations;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
429 memcpy(data_write_pos, &pOutdoor->ddm, sizeof(DDM_DLV_Header));//0x28
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
430 data_write_pos += sizeof(DDM_DLV_Header);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
431 memcpy(data_write_pos, pOutdoor->uFullyRevealedCellOnMap, 0x3C8);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
432 data_write_pos += 968;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
433 memcpy(data_write_pos, pOutdoor->uPartiallyRevealedCellOnMap, 0x3C8);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
434 data_write_pos += 968;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
435 for (int i = 0; i < pOutdoor->uNumBModels ; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
436 for (int j = 0; j < pOutdoor->pBModels[i].uNumFaces;++j)//*(int *)&pOutdoor->pBModels->pModelName[v24]; ++j)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
437 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
438 memcpy(data_write_pos, &(pOutdoor->pBModels[i].pFaces[j].uAttributes), 4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
439 data_write_pos += 4;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
440 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
441
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
442 for (int i = 0; i < (signed int)uNumLevelDecorations; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
443 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
444 memcpy(data_write_pos, &pLevelDecorations[i].uFlags, 2);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
445 data_write_pos += 2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
446 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
447 memcpy(data_write_pos, &uNumActors, 4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
448 data_write_pos += 4;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
449 memcpy(data_write_pos, &pActors, uNumActors * sizeof(Actor));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
450 data_write_pos += uNumActors * sizeof(Actor);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
451 memcpy(data_write_pos, &uNumSpriteObjects, 4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
452 data_write_pos += 4;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
453 memcpy(data_write_pos, &pSpriteObjects, uNumSpriteObjects * sizeof(SpriteObject));
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
454 data_write_pos += uNumSpriteObjects * sizeof(SpriteObject);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
455 memcpy(data_write_pos, &uNumChests, 4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
456 data_write_pos += 4;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
457 memcpy(data_write_pos, pChests.data(), sizeof(Chest)* uNumChests);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
458 data_write_pos += sizeof(Chest) * uNumChests;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
459 memcpy(data_write_pos, &stru_5E4C90_MapPersistVars, 0xC8);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
460 data_write_pos += 200;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
461 memcpy(data_write_pos, &pOutdoor->loc_time, 0x38);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
462 data_write_pos += 56;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
463 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
464 strcpy(Source, pCurrentMapName);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
465 _splitpath(Source, Drive, Dir, Filename, Ext);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
466 Ext[1] = 'd';
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
467
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
468 Size = (int)data_write_pos - (int)uncompressed_buff;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
469 compressed_block_size = 999984;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
470 res = zlib::MemZip((char *)compressed_buf + 16, (unsigned int *)&compressed_block_size, uncompressed_buff,Size);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
471 if (res || (signed int)compressed_block_size > (signed int)Size )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
472 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
473 memcpy((void *)(compressed_buf + 16), uncompressed_buff, Size);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
474 compressed_block_size = Size;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
475 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
476 compressed_block_size += 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
477 memcpy(&((ODMHeader *)compressed_buf)->uCompressedSize, &compressed_block_size, 4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
478 memcpy(&((ODMHeader *)compressed_buf)->uDecompressedSize, &Size, 4);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
479 sprintf(Source, "%s%s", Filename, Ext);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
480 strcpy(pLodDirectory.pFilename, Source);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
481 pLodDirectory.uDataSize = compressed_block_size;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
482 if ( pNew_LOD->Write(&pLodDirectory, (const void *)compressed_buf, 0) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
483 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
484 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 208);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
485 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
486 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
487 free((void *)compressed_buf);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
488 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
489 free(uncompressed_buff);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
490 if ( IsAutoSAve )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
491 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
492 if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
493 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
494 FormatMessageA(0x1000, 0, GetLastError(), 0x400, Buffer, 0x80, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
495 sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 300);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
496 MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
497 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
498 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
499 pParty->vPosition.x = pPositionX;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
500 pParty->vPosition.y = pPositionY;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
501 pParty->vPosition.z = pPositionZ;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
502 pParty->uFallStartY = pPositionZ;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
503 pParty->sRotationY = sPRotationY;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
504 pParty->sRotationX = sPRotationX;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
505 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
506
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
507 //----- (00460078) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
508 void __fastcall DoSavegame(unsigned int uSlot)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
509 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
510 if ( _stricmp(pCurrentMapName, "d05.blv") )//Not Arena(не Арена)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
511 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
512 LOD::Directory pDir; // [sp+Ch] [bp-28h]@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
513 SaveGame(0, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
514 strcpy(pSavegameHeader[uSlot].pLocationName, pCurrentMapName);//дать название карты
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
515 pSavegameHeader[uSlot].uWordTime = pParty->uTimePlayed;//текущее время
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
516 strcpy(pDir.pFilename, "header.bin");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
517 pDir.uDataSize = 100;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
518 pNew_LOD->Write(&pDir, &pSavegameHeader[uSlot], 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
519 sprintf(pTmpBuf.data(), "saves\\save%03d.mm7", uSlot);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
520 pNew_LOD->CloseWriteFile();//закрыть
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
521 CopyFileA("data\\new.lod", pTmpBuf.data(), 0);//сохранение файла в директорию saves
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
522 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
523 GUI_UpdateWindows();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
524 pGUIWindow_CurrentMenu->Release();
2541
a902abdfc7f2 1. Renamed class Game to class Engine.
a.parshin
parents: 2508
diff changeset
525 current_screen_type = SCREEN_GAME;
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
526 //v3 = pSavegameThumbnails;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
527 viewparams->bRedrawGameUI = true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
528 for (uint i = 0; i < 45; i++)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
529 pSavegameThumbnails[i].Release();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
530
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
531 if ( _stricmp(pCurrentMapName, "d05.blv") )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
532 pNew_LOD->_4621A7();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
533 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
534 ShowStatusBarString(pGlobalTXT_LocalizationStrings[583], 2);// "No saving in the Arena"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
535 pIcons_LOD->RemoveTexturesFromTextureList();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
536 pEventTimer->Resume();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
537 ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2);// "Game Saved!"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
538 viewparams->bRedrawGameUI = true;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
539 }
2541
a902abdfc7f2 1. Renamed class Game to class Engine.
a.parshin
parents: 2508
diff changeset
540 // 4E28F8: using guessed type int current_screen_type;
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
541
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
542 //----- (0045E297) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
543 void SavegameList::Initialize(unsigned int bHideEmptySlots)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
544 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
545 //memset(pSavegameList, 0, sizeof(pSavegameList));//Ritor1: вызывает затирание
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
546 pSavegameList->Reset();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
547 uNumSavegameFiles = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
548
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
549 _chdir("saves");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
550 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
551 if (!bHideEmptySlots && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 ) // AutoSave.MM7
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
552 strcpy(pSavegameList->pFileList[uNumSavegameFiles++].pSaveFileName, pGlobalTXT_LocalizationStrings[613]);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
553
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
554 for (uint i = 0; i < 40; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
555 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
556 sprintf(pTmpBuf.data(), "save%03d.mm7", i);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
557 if (_access(pTmpBuf.data(), 0) == -1)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
558 continue;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
559
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
560 uint idx = i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
561 if (!bHideEmptySlots)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
562 idx = uNumSavegameFiles;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
563 strcpy(pSavegameList->pFileList[idx].pSaveFileName, pTmpBuf.data());
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
564
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
565 ++uNumSavegameFiles;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
566 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
567 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
568 _chdir("..");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
569 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
570 //----- (0046086A) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
571 void SaveNewGame()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
572 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
573 FILE *file; // eax@7
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
574 void *pSave; // [sp+170h] [bp-8h]@3
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
575
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
576 if ( pMovie_Track )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
577 pMediaPlayer->Unload();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
578 pSave = malloc(1000000);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
579 pNew_LOD->CloseWriteFile();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
580 remove("data\\new.lod");//удалить new.lod
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
581
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
582 LOD::FileHeader header; // [sp+Ch] [bp-16Ch]@3 заголовок
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
583 strcpy(header.LodVersion, "MMVII");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
584 strcpy(header.LodDescription, "newmaps for MMVII");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
585 header.LODSize = 100;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
586 header.dword_0000A8 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
587
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
588 LOD::Directory a3; // [sp+14Ch] [bp-2Ch]@3
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
589 a3.dword_000018 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
590 a3.word_00001E = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
591 strcpy(a3.pFilename, "current");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
592 pNew_LOD->CreateNewLod(&header, &a3, "data\\new.lod");//создаётся new.lod в дирректории
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
593 if (pNew_LOD->LoadFile("data\\new.lod", false))//загрузить файл new.lod(isFileOpened = true)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
594 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
595 pNew_LOD->CreateTempFile();//создаётся временный файл OutputFileHandle
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
596 pNew_LOD->uNumSubDirs = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
597
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
598 LOD::Directory pDir; // [sp+10Ch] [bp-6Ch]@4
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
599 for (int i = pGames_LOD->uNumSubDirs / 2; i < pGames_LOD->uNumSubDirs; ++i)//копирование файлов с 76 по 151
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
600 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
601 memcpy(&pDir, &pGames_LOD->pSubIndices[i], sizeof(pDir));//копирование текущего файла в pDir
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
602 file = pGames_LOD->FindContainer(pGames_LOD->pSubIndices[i].pFilename, 1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
603 fread(pSave, pGames_LOD->pSubIndices[i].uDataSize, 1, file);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
604 pNew_LOD->AppendDirectory(&pDir, pSave);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
605 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
606
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
607 LOD::Directory save_game_dir; // [sp+12Ch] [bp-4Ch]@9
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
608 strcpy(pSavegameHeader[0].pLocationName, "out01.odm");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
609 strcpy(save_game_dir.pFilename, "header.bin");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
610 save_game_dir.uDataSize = sizeof(SavegameHeader);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
611 pNew_LOD->AppendDirectory(&save_game_dir, &pSavegameHeader[0]);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
612
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
613 pNew_LOD->FixDirectoryOffsets();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
614
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
615 pParty->vPrevPosition.x = 12552;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
616 pParty->vPrevPosition.y = 1816;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
617 pParty->vPrevPosition.z = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
618
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
619 pParty->vPosition.x = 12552;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
620 pParty->vPosition.y = 1816;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
621 pParty->vPosition.z = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
622
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
623 pParty->uFallStartY = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
624
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
625 pParty->sPrevRotationX = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
626 pParty->sPrevRotationY = 512;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
627
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
628 pParty->sRotationX = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
629 pParty->sRotationY = 512;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
630
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
631 SaveGame(1, 1);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
632 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
633 free(pSave);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
634 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
635