Debian Codegraph @

Descent3/gamesave.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/main/gamesave.cpp $
21 * $Revision: 75 $
22 * $Date: 9/05/01 12:26p $
23 * $Author: Matt $
24 *
25 *
26 *
27 * $Log: /DescentIII/main/gamesave.cpp $
28 *
29 * 75 9/05/01 12:26p Matt
30 * Flush low-level mouse click queue before bringing up buddy, save, and
31 * load menus since these menus would otherwise get clicks that occurred
32 * before they existed.
33 *
34 * 74 4/19/00 5:14p Matt
35 * From Duane for 1.4
36 * Mac-only change: ensure dialog is cleared after saving screenshot.
37 *
38 * 73 10/22/99 10:57a Matt
39 * Mac merge
40 *
41 * 72 7/22/99 11:46a Chris
42 *
43 * 71 7/21/99 7:17p Chris
44 * Fixed an attach related crash in the load/save game code
45 *
46 * 70 5/24/99 7:23p Samir
47 * pass current string length to DoEditDialog. crash otherwise for long
48 * savegames.
49 *
50 * 69 5/21/99 11:14p Samir
51 * savegames save hud timer and special text states. restore too.
52 *
53 * 68 5/20/99 2:48a Matt
54 * Auto-waypoints now stored & used per player. Manual waypoints will all
55 * players, once Jason makes it work.
56 *
57 * 67 5/12/99 6:01p Jeff
58 * flip order of saving/loading objects and players
59 *
60 * 66 5/12/99 12:25p Kevin
61 * save & restore Current_mission.game_state_flags
62 *
63 * 65 5/06/99 6:11p Kevin
64 * fixes for save/load game syste. Also require CD again and added some
65 * heat.net stuff
66 *
67 * 64 5/02/99 7:18p Samir
68 * changed titles on messageboxes and don't put up loadgame dialog if
69 * there are no savegames.
70 *
71 * 63 4/30/99 3:05p Kevin
72 * doh
73 *
74 * 62 4/30/99 3:03p Kevin
75 * improved times restored count
76 *
77 * 61 4/29/99 11:25a Kevin
78 * Added room damage to save game
79 *
80 * 60 4/28/99 2:14a Samir
81 * save and load Game messages in savegame.
82 *
83 * 59 4/26/99 4:33p Samir
84 * made stringtable change.
85 *
86 * 58 4/23/99 10:28p Kevin
87 * fixed problems with minimal install and demo/savegames
88 *
89 * 57 4/23/99 8:28p Kevin
90 * trying to get doors working in save/load games
91 *
92 * 56 4/23/99 7:33p Kevin
93 * save weather effects and reset the HUD to show the correct ship
94 *
95 * 55 4/22/99 4:13p Matt
96 * Deleted sounds array from the object struct, since it was never used.
97 *
98 * 54 4/20/99 11:45a Samir
99 * added autosave
100 *
101 * 53 4/16/99 12:39a Matt
102 * Disable Soar on non-Windows systems.
103 *
104 * 52 4/15/99 5:40p Samir
105 * save current music region and restore it.
106 *
107 * 51 4/15/99 1:39a Jeff
108 * changes for linux compile
109 *
110 * 50 4/14/99 2:50a Jeff
111 * fixed some case mismatched #includes
112 *
113 * 49 4/06/99 10:44p Samir
114 * Fixed residue from changes to UID_OK and UID_CANCEL.
115 *
116 * 48 4/05/99 10:54a Matt
117 * Added auto-waypoint system
118 *
119 * 47 3/23/99 6:09p Kevin
120 * Marker text saved
121 *
122 * 46 3/23/99 10:24a Samir
123 * check valid bitmap handle in LoadGame.
124 *
125 * 45 3/22/99 5:12p Samir
126 * added snapshot to savegame.
127 *
128 * 44 3/11/99 9:09p Jeff
129 * fixed remaining known bugs in demo system (DemoWriteObjCreate being
130 * called twice and </<= problems with
131 * Highest_room_index/Highest_object_index).
132 *
133 * 43 3/10/99 6:20p Jeff
134 * many fixes to demo system. Fixed IGC so cameras move...fixed osiris to
135 * be restored correctly, and it handles errors on restore
136 *
137 * 42 3/10/99 2:25p Kevin
138 * Save/Load and Demo file fixes
139 *
140 * 41 3/08/99 10:52a Jason
141 * save/load texture changes on room faces
142 *
143 * 40 3/04/99 6:30p Jeff
144 * saves out current waypoint and matcens
145 *
146 * 39 3/04/99 6:19p Kevin
147 * was using the wrong string
148 *
149 * 38 3/03/99 7:20p Jeff
150 * save/restore some ai path information
151 *
152 * 37 3/03/99 12:56a Kevin
153 * Added some HUD messages. Needs to be localized.
154 *
155 * 36 3/02/99 6:39p Jeff
156 * level goals working in save/load game
157 *
158 * 35 3/02/99 4:41p Jeff
159 * Fixed inventory save/load
160 *
161 * 34 3/02/99 2:49p Samir
162 * will not allow savegames with no names.
163 *
164 * 33 3/02/99 1:48p Kevin
165 * Fixed collision with external rooms
166 *
167 * 32 3/01/99 9:03p Kevin
168 * OEM Beta 4
169 *
170 * 31 3/01/99 4:38p Samir
171 * made done button cancel in gamesave menus.
172 *
173 * 30 3/01/99 11:41a Kevin
174 * More progress...
175 *
176 * 29 3/01/99 4:59a Samir
177 * redid load and save game menus.
178 *
179 * 28 2/28/99 10:50p Kevin
180 *
181 * 26 2/27/99 4:41p Kevin
182 * Fixed(?) some load/save bugs
183 *
184 * 25 2/26/99 6:48p Kevin
185 * Fixes to load/save game, and change minor version for OEM beta 3
186 *
187 * 24 2/24/99 9:57a Kevin
188 * Added error messages if you try to save a game while in multi
189 *
190 * 23 2/23/99 9:58p Kevin
191 * trying to get attach working
192 *
193 * 22 2/23/99 5:13p Kevin
194 * Fixed it so objects with lightmaps will retain their lightmaps when a
195 * game is saved & loaded.
196 *
197 * 21 2/22/99 2:04p Jason
198 * added different damages for players and generics
199 *
200 * 20 2/07/99 1:17a Jeff
201 * peppered UI dialogs that were missing NEWUIRES_FORCEQUIT to handle it
202 *
203 * 19 2/02/99 12:43p Kevin
204 * Fixes to the Save/Load game system, and the demo system to work with
205 * the new OSIRIS
206 *
207 * 18 1/29/99 12:47p Matt
208 * Rewrote the doorway system
209 *
210 * 17 1/23/99 10:10p Kevin
211 * Added the start of osiris support into the demo system
212 *
213 * 16 1/22/99 8:53p Jeff
214 * added custom-default script overrides
215 *
216 * 15 1/18/99 2:46p Matt
217 * Combined flags & flags2 fields in object struct
218 *
219 * 14 1/13/99 6:37a Jeff
220 * fixed object.h. There were numerous struct declarations that were the
221 * same name as the instance of the struct (gcc doesn't like this).
222 * Changed the struct name. Also added some #ifdef's for linux build,
223 * along with fixing case-sensitive includes
224 *
225 * 13 1/08/99 2:55p Samir
226 * Ripped out OSIRIS1.
227 *
228 * 12 11/11/98 2:46p Kevin
229 * Demo recording system work
230 *
231 * 11 10/06/98 5:45p Kevin
232 * Added new configuration for demo
233 *
234 * 10 9/22/98 3:56p Samir
235 * special demo code doesn't allow pilot and mission stuff.
236 *
237 * 9 8/25/98 3:44p Samir
238 * make sure and return false if no save games.
239 *
240 * 8 8/20/98 6:45p Samir
241 * new interfaces for load-save.
242 *
243 * 7 8/20/98 10:52a Samir
244 * fixed some ui probs
245 *
246 * 6 8/19/98 5:35p Samir
247 * saved triggers, spew, viseffects, weapons, room data xcept texture per
248 * face changes, one real strange bug where robots in the same room as you
249 * don't appear but fire at you.
250 *
251 * 5 8/18/98 3:50p Matt
252 * Maybe fixed bug
253 *
254 * 4 8/18/98 3:05p Samir
255 * save game with no weapons or fireballs.
256 *
257 * 3 8/18/98 11:17a Samir
258 * for the sake of the team.
259 *
260 * 2 8/18/98 1:12a Samir
261 * rudimentary savegame. pretty damn buggy when loading.
262 *
263 * $NoKeywords: $
264 */
265
266 #include <cstring>
267 #include <filesystem>
268
269 #include "gamesave.h"cxx . . $ `<file>/Descent3/gamesave.h`/
270 #include "descent.h"cxx . . $ `<file>/Descent3/descent.h`/
271 #include "newui.h"cxx . . $ `<file>/Descent3/newui.h`/
272 #include "cfile.h"cxx . . $ `<file>/cfile/cfile.h`/
273 #include "Mission.h"cxx . . $ `<file>/Descent3/Mission.h`/
274 #include "gamesequence.h"cxx . . $ `<file>/Descent3/gamesequence.h`/
275 #include "gameevent.h"cxx . . $ `<file>/Descent3/gameevent.h`/
276 #include "gameloop.h"cxx . . $ `<file>/Descent3/gameloop.h`/
277 #include "game.h"cxx . . $ `<file>/Descent3/game.h`/
278 #include "stringtable.h"cxx . . $ `<file>/Descent3/stringtable.h`/
279 #include "object.h"cxx . . $ `<file>/Descent3/object.h`/
280 #include "objinfo.h"cxx . . $ `<file>/Descent3/objinfo.h`/
281 #include "gametexture.h"cxx . . $ `<file>/Descent3/gametexture.h`/
282 #include "bitmap.h"cxx . . $ `<file>/lib/bitmap.h`/
283 #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/
284 #include "door.h"cxx . . $ `<file>/Descent3/door.h`/
285 #include "doorway.h"cxx . . $ `<file>/Descent3/doorway.h`/
286 #include "ship.h"cxx . . $ `<file>/Descent3/ship.h`/
287 #include "soar.h"cxx . . $ `<file>/Descent3/soar.h`/
288 #include "hud.h"cxx . . $ `<file>/Descent3/hud.h`/
289 #include "weapon.h"cxx . . $ `<file>/Descent3/weapon.h`/
290 #include "viseffect.h"cxx . . $ `<file>/Descent3/viseffect.h`/
291 #include "room.h"cxx . . $ `<file>/Descent3/room.h`/
292 #include "trigger.h"cxx . . $ `<file>/Descent3/trigger.h`/
293 #include "spew.h"cxx . . $ `<file>/Descent3/spew.h`/
294 #include "osiris_dll.h"cxx . . $ `<file>/Descent3/osiris_dll.h`/
295 #include "levelgoal.h"cxx . . $ `<file>/Descent3/levelgoal.h`/
296 #include "aistruct.h"cxx . . $ `<file>/Descent3/aistruct.h`/
297 #include "matcen.h"cxx . . $ `<file>/Descent3/matcen.h`/
298 #include "hud.h"cxx . . $ `<file>/Descent3/hud.h`/
299 #include "marker.h"cxx . . $ `<file>/Descent3/marker.h`/
300 #include "d3music.h"cxx . . $ `<file>/Descent3/d3music.h`/
301 #include "weather.h"cxx . . $ `<file>/Descent3/weather.h`/
302
303 // function prototypes.
304
305 void SGSSnapshotcxx . . $ SGSSnapshot(3639e799710acb68).(CFILEcxx . . $ CFILE# *fp);
306
307 #define SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`! 0x1000
308 #define N_SAVE_SLOTScxx . . $ `Descent3/gamesave.cpp:308:9`! 8
309 #define GAMESAVE_WND_Wcxx . . $ `Descent3/gamesave.cpp:309:9`! 448
310 #define GAMESAVE_WND_Hcxx . . $ `Descent3/gamesave.cpp:310:9`! 384
311 #define GAMESAVE_SLOT_Wcxx . . $ `Descent3/gamesave.cpp:311:9`! 336
312 #define GAMESAVE_SLOT_Hcxx . . $ `Descent3/gamesave.cpp:312:9`! 18
313 #define GAMESAVE_SLOT_H2cxx . . $ `Descent3/gamesave.cpp:313:9`! 22
314 #define GAMESAVE_HELP_Ycxx . . $ `Descent3/gamesave.cpp:314:9`! 2
315 #define GAMESAVE_HELP_Xcxx . . $ `Descent3/gamesave.cpp:315:9`! 12
316 #define GAMESAVE_SLOT_Ycxx . . $ `Descent3/gamesave.cpp:316:9`! 140
317 #define GAMESAVE_SLOT_Y2cxx . . $ `Descent3/gamesave.cpp:317:9`! 110
318 #define GAMESAVE_SLOT_Xcxx . . $ `Descent3/gamesave.cpp:318:9`! 12
319
320 // we need this directory to load the savegame from
321 static char LGS_Pathcxx . . $ LGS_Path.[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
322
323 extern int Times_game_restoredcxx . . $ Times_game_restored.;
324 // available for all.
325 int Quicksave_game_slotcxx . . $ Quicksave_game_slot. = -1;
326
327 void QuickSaveGamecxx . . $ QuickSaveGame(49f6e7a06ebc5aa8).() {
328 if (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) {
329 DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).(TXT_ERRORcxx . . $ `Descent3/stringtable.h:165:9`!, TXT_CANT_SAVE_MULTIcxx . . $ `Descent3/stringtable.h:95:9`!, MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!);
330 return;
331 }
332
333 #ifdef _DEBUGcxx . . $ `<built-in>:482:9`!
334 if (GetFunctionModecxx . . $ GetFunctionMode(4270339a2fa9f0f5).() == EDITOR_GAME_MODEcxx . . $ EDITOR_GAME_MODE. || !Current_missioncxx . . $ Current_mission..filenamecxx . . $ tMission#filename.) {
335 DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).(TXT_ERRORcxx . . $ `Descent3/stringtable.h:165:9`!, "You need to be playing a mission.", MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!);
336 return;
337 }
338 #endif
339
340 if (Quicksave_game_slotcxx . . $ Quicksave_game_slot. == -1) {
341 SaveGameDialogcxx . . $ SaveGameDialog(49f6e7a06ebc5aa8).();
342 } else {
343 // verify savegame still exists in the appropriate slot, if not just run dialog, if so then save
344 char filename[PSFILENAME_LENcxx . . $ `lib/pstypes.h:31:9`! + 1];
345 char pathname[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
346 char desc[GAMESAVE_DESCLENcxx . . $ `Descent3/gamesave.h:102:9`! + 1];
347 FILEcxx . . $ FILE# *fp;
348 int i;
349
350 i = Quicksave_game_slotcxx . . $ Quicksave_game_slot.;
351
352 snprintf(filename, sizeof(filename), "saveg00%d", i);
353 ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(pathname, Base_directory_writecxx . . $ Base_directory_write., "savegame", filename, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
354
355 fp = fopen(pathname, "rb");
356 if (fp) {
357 // slot valid, save here.
358 fclose(fp);
359 if (GetGameStateInfocxx . . $ GetGameStateInfo(3bcbb53201fcdcb8).(pathname, desc)) {
360 if (SaveGameStatecxx . . $ SaveGameState(b7a7aa4a824b7595).(pathname, desc)) {
361 AddHUDMessagecxx . . $ AddHUDMessage(f90d95ab21fd6d97).(TXT_QUICKSAVEcxx . . $ `Descent3/stringtable.h:833:9`!);
362 return; // we're okay. game saved. put up hud message?
363 }
364 DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).(TXT_ERRORcxx . . $ `Descent3/stringtable.h:165:9`!, TXT_SAVEGAMEFAILEDcxx . . $ `Descent3/stringtable.h:365:9`!, MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!);
365 }
366 }
367 Quicksave_game_slotcxx . . $ Quicksave_game_slot. = -1;
368 SaveGameDialogcxx . . $ SaveGameDialog(49f6e7a06ebc5aa8).();
369 }
370 }
371
372 void SaveGameDialogcxx . . $ SaveGameDialog(49f6e7a06ebc5aa8).() {
373 newuiTiledWindowcxx . . $ newuiTiledWindow# wndcxx . . $ newuiTiledWindow#newuiTiledWindow(49f6e7a06ebc5aa8).;
374 newuiSheetcxx . . $ newuiSheet# *sheet;
375 int i, res;
376
377 char savegame_dir[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
378 char pathname[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
379 char filename[PSFILENAME_LENcxx . . $ `lib/pstypes.h:31:9`! + 1];
380 char desc[GAMESAVE_DESCLENcxx . . $ `Descent3/gamesave.h:102:9`! + 1];
381 bool occupied_slot[N_SAVE_SLOTScxx . . $ `Descent3/gamesave.cpp:308:9`!];
382
383 if (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) {
384 DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).(TXT_ERRORcxx . . $ `Descent3/stringtable.h:165:9`!, TXT_CANT_SAVE_MULTIcxx . . $ `Descent3/stringtable.h:95:9`!, MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!);
385 return;
386 }
387
388 #ifdef _DEBUGcxx . . $ `<built-in>:482:9`!
389 if (!Current_missioncxx . . $ Current_mission..filenamecxx . . $ tMission#filename.) {
390 DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).(TXT_ERRORcxx . . $ `Descent3/stringtable.h:165:9`!, "You need to be playing a mission.", MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!);
391 return;
392 }
393 #endif
394
395 // setup paths.
396 ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(savegame_dir, Base_directory_writecxx . . $ Base_directory_write., "savegame", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
397 // ddio_MakePath(pathname, savegame_dir, "*.sav", NULL); -unused
398
399 // create savegame directory if it didn't exist before.
400 stdcxx . . $ std/::error_codecxx . . $ std/error_code# eccxx . . $ std/error_code#error_code(ced63f7c635d850d).;
401 if (!stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::create_directoriescxx . . $ std/filesystem/create_directories(d743b8a22d0b5f99).(savegame_dircxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., ec)) {
402 if (ec) {
403 DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).(TXT_ERRORcxx . . $ `Descent3/stringtable.h:165:9`!, TXT_ERRCREATEDIRcxx . . $ `Descent3/stringtable.h:368:9`!, MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!);
404 return;
405 }
406 }
407
408 // open window
409 wnd.Createcxx . . $ newuiTiledWindow#Create(9860cac3d762132).(TXT_SAVEGAMEcxx . . $ `Descent3/stringtable.h:372:9`!, 0, 0, GAMESAVE_WND_Wcxx . . $ `Descent3/gamesave.cpp:309:9`!, GAMESAVE_WND_Hcxx . . $ `Descent3/gamesave.cpp:310:9`!);
410 wnd.Opencxx . . $ UIWindow#Open(49f6e7a06ebc5aa8).();
411 sheet = wnd.GetSheetcxx . . $ newuiTiledWindow#GetSheet(661381a276e5b628).();
412
413 sheet->NewGroupcxx . . $ newuiSheet#NewGroup(465b27e37ce794b1).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, GAMESAVE_HELP_Xcxx . . $ `Descent3/gamesave.cpp:315:9`!, GAMESAVE_HELP_Ycxx . . $ `Descent3/gamesave.cpp:314:9`!);
414 sheet->AddTextcxx . . $ newuiSheet#AddText(326aeb464d16410c).(TXT_SAVEGAMEHELPcxx . . $ `Descent3/stringtable.h:771:9`!);
415
416 sheet->NewGroupcxx . . $ newuiSheet#NewGroup(465b27e37ce794b1).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, GAMESAVE_SLOT_Xcxx . . $ `Descent3/gamesave.cpp:318:9`!, GAMESAVE_SLOT_Y2cxx . . $ `Descent3/gamesave.cpp:317:9`!);
417 // generate save slots.
418 for (i = 0; i < N_SAVE_SLOTScxx . . $ `Descent3/gamesave.cpp:308:9`!; i++) {
419 FILEcxx . . $ FILE# *fp;
420 bool ingroup = (i == 0 || i == (N_SAVE_SLOTScxx . . $ `Descent3/gamesave.cpp:308:9`! - 1)) ? true : false;
421
422 snprintf(filename, sizeof(filename), "saveg00%d", i);
423 ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(pathname, savegame_dir, filename, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
424
425 occupied_slot[i] = false;
426
427 fp = fopen(pathname, "rb");
428 if (fp) {
429 fclose(fp);
430
431 if (GetGameStateInfocxx . . $ GetGameStateInfo(3bcbb53201fcdcb8).(pathname, desc)) {
432 sheet->AddHotspotcxx . . $ newuiSheet#AddHotspot(9900cc9f47e11d13).(desc, GAMESAVE_SLOT_Wcxx . . $ `Descent3/gamesave.cpp:311:9`!, GAMESAVE_SLOT_H2cxx . . $ `Descent3/gamesave.cpp:313:9`!, SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`! + i, ingroup);
433 occupied_slot[i] = true;
434 } else {
435 sheet->AddHotspotcxx . . $ newuiSheet#AddHotspot(9900cc9f47e11d13).(TXT_ILLEGALSAVEGAMEcxx . . $ `Descent3/stringtable.h:364:9`!, GAMESAVE_SLOT_Wcxx . . $ `Descent3/gamesave.cpp:311:9`!, GAMESAVE_SLOT_H2cxx . . $ `Descent3/gamesave.cpp:313:9`!, SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`! + i, ingroup);
436 }
437 } else {
438 sheet->AddHotspotcxx . . $ newuiSheet#AddHotspot(9900cc9f47e11d13).(TXT_EMPTYcxx . . $ `Descent3/stringtable.h:367:9`!, GAMESAVE_SLOT_Wcxx . . $ `Descent3/gamesave.cpp:311:9`!, GAMESAVE_SLOT_H2cxx . . $ `Descent3/gamesave.cpp:313:9`!, SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`! + i, ingroup);
439 }
440 }
441
442 sheet->NewGroupcxx . . $ newuiSheet#NewGroup(465b27e37ce794b1).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, GAMESAVE_WND_Wcxx . . $ `Descent3/gamesave.cpp:309:9`! - 148, GAMESAVE_WND_Hcxx . . $ `Descent3/gamesave.cpp:310:9`! - 100);
443 sheet->AddButtoncxx . . $ newuiSheet#AddButton(680bf41633375800).(TXT_CANCELcxx . . $ `Descent3/stringtable.h:35:9`!, UID_CANCELcxx . . $ `ui/ui.h:369:9`!);
444
445 // Mouse clicks from gameplay will be read by the dialog without this flush
446 ddio_MouseQueueFlushcxx . . $ ddio_MouseQueueFlush(49f6e7a06ebc5aa8).();
447
448 // do ui.
449 do {
450 res = wnd.DoUIcxx . . $ newuiTiledWindow#DoUI(b126dc7c1de90089).();
451 if (res == NEWUIRES_FORCEQUITcxx . . $ `Descent3/newui_core.h:131:9`!) {
452 break;
453 } else if (res >= SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`! && res < (SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`! + N_SAVE_SLOTScxx . . $ `Descent3/gamesave.cpp:308:9`!)) {
454 newuiHotspotcxx . . $ newuiHotspot# *hot;
455 const char *hot_desc;
456 int slot = res - SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`!;
457 bool do_save = false;
458
459 // fill edit box with current description.
460 hot = (newuiHotspotcxx . . $ newuiHotspot# *)sheet->GetGadgetcxx . . $ newuiSheet#GetGadget(d6ee160b69f32e15).(res);
461 ASSERTcxx . . $ `misc/pserror.h:246:9`!(hot);
462 hot_desc = hot->GetTitlecxx . . $ newuiHotspot#GetTitle(a9f41ea0e82d88cf).();
463
464 if (occupied_slot[slot]) {
465 strcpy(desc, hot_desc);
466 } else {
467 desc[0] = 0;
468 }
469
470 reenter_save:
471 if (DoEditDialogcxx . . $ DoEditDialog(79e5ffcc21f8a1c7).(TXT_DESCRIPTIONcxx . . $ `Descent3/stringtable.h:373:9`!, desc, sizeof(desc) - 1)) {
472 // perform check for duplicate names
473 // do not allow for empty or space only descriptions
474 if (strlen(desc) == 0) {
475 DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).("", TXT_SAVEGAMENAMEcxx . . $ `Descent3/stringtable.h:70:9`!, MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!);
476 goto reenter_save;
477 }
478 for (i = 0; i < N_SAVE_SLOTScxx . . $ `Descent3/gamesave.cpp:308:9`!; i++) {
479 hot = (newuiHotspotcxx . . $ newuiHotspot# *)sheet->GetGadgetcxx . . $ newuiSheet#GetGadget(d6ee160b69f32e15).(SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`! + i);
480 hot_desc = hot->GetTitlecxx . . $ newuiHotspot#GetTitle(a9f41ea0e82d88cf).();
481
482 if (occupied_slot[i] && stricmpcxx . . $ `linux/linux_fix.h:43:9`!(hot_desc, desc) == 0 && slot != i) {
483 DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).("", TXT_SAVEGAMEDUPcxx . . $ `Descent3/stringtable.h:773:9`!, MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!);
484 goto reenter_save;
485 }
486 }
487
488 do_save =
489 occupied_slot[slot] ? (DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).(TXT_WARNINGcxx . . $ `Descent3/stringtable.h:707:9`!, TXT_OVERWRITESAVEcxx . . $ `Descent3/stringtable.h:774:9`!, MSGBOX_YESNOcxx . . $ `Descent3/newui_core.h:80:9`!) ? true : false) : true;
490
491 if (do_save) {
492 snprintf(filename, sizeof(filename), "saveg00%d", slot);
493 ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(pathname, savegame_dir, filename, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
494 if (!SaveGameStatecxx . . $ SaveGameState(b7a7aa4a824b7595).(pathname, desc)) {
495 DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).("", TXT_SAVEGAMEFAILEDcxx . . $ `Descent3/stringtable.h:365:9`!, MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!);
496 } else {
497 AddHUDMessagecxx . . $ AddHUDMessage(f90d95ab21fd6d97).(TXT_QUICKSAVEcxx . . $ `Descent3/stringtable.h:833:9`!);
498 res = UID_CANCELcxx . . $ `ui/ui.h:369:9`!;
499 Quicksave_game_slotcxx . . $ Quicksave_game_slot. = slot;
500 }
501 }
502 }
503 }
504 } while (res != UID_CANCELcxx . . $ `ui/ui.h:369:9`!);
505
506 wnd.Closecxx . . $ UIWindow#Close(49f6e7a06ebc5aa8).();
507 wnd.Destroycxx . . $ UIWindow#Destroy(49f6e7a06ebc5aa8).();
508 }
509
510 ////////////////////////////////////////////////////////////////////////////////////////
511 struct tLoadGameDialogDatacxx . . $ tLoadGameDialogData# {
512 int cur_slotcxx . . $ tLoadGameDialogData#cur_slot.;
513 chunked_bitmapcxx . . $ chunked_bitmap# chunkcxx . . $ tLoadGameDialogData#chunk.;
514 };
515
516 #if defined(POSIXcxx . . $ `<built-in>:480:9`!)
517 void LoadGameDialogCBcxx . . $ LoadGameDialogCB(ea6308bbb4c73cea).(newuiTiledWindowcxx . . $ newuiTiledWindow# *wnd, void *data)
518 #else
519 void __cdecl LoadGameDialogCB(newuiTiledWindow *wnd, void *data)
520 #endif
521 {
522 tLoadGameDialogDatacxx . . $ tLoadGameDialogData# *cb_data = (tLoadGameDialogDatacxx . . $ tLoadGameDialogData# *)data;
523 UIGadgetcxx . . $ UIGadget# *cur_gadget;
524 int id;
525
526 cur_gadget = wnd->GetFocuscxx . . $ UIWindow#GetFocus(42baa2535cd0f5f7).();
527
528 for (id = SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`!; id < (SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`! + N_SAVE_SLOTScxx . . $ `Descent3/gamesave.cpp:308:9`!); id++) {
529 if (cur_gadget->GetIDcxx . . $ UIGadget#GetID(455f465bc33b4cdf).() == id) {
530 break;
531 }
532 }
533
534 if (id < (SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`! + N_SAVE_SLOTScxx . . $ `Descent3/gamesave.cpp:308:9`!) && id != cb_data->cur_slotcxx . . $ tLoadGameDialogData#cur_slot.) {
535 // new bitmap to be displayed!
536 char filename[PSFILENAME_LENcxx . . $ `lib/pstypes.h:31:9`! + 1];
537 char pathname[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
538 char savegame_dir[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
539 char desc[GAMESAVE_DESCLENcxx . . $ `Descent3/gamesave.h:102:9`! + 1];
540 int bm_handle;
541
542 if (cb_data->chunkcxx . . $ tLoadGameDialogData#chunk..bm_arraycxx . . $ chunked_bitmap#bm_array.) {
543 bm_DestroyChunkedBitmapcxx . . $ bm_DestroyChunkedBitmap(1635f60f4d3c1317).(&cb_data->chunkcxx . . $ tLoadGameDialogData#chunk.);
544 }
545
546 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "savegame slot=%d\n", id - SAVE_HOTSPOT_ID);
547
548 ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(savegame_dir, Base_directory_writecxx . . $ Base_directory_write., "savegame", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
549 snprintf(filename, sizeof(filename), "saveg00%d", (id - SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`!));
550 ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(pathname, savegame_dir, filename, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
551
552 if (GetGameStateInfocxx . . $ GetGameStateInfo(3bcbb53201fcdcb8).(pathname, desc, &bm_handle)) {
553 if (bm_handle > 0) {
554 bm_CreateChunkedBitmapcxx . . $ bm_CreateChunkedBitmap(b9fa1b176cbdfaf1).(bm_handle, &cb_data->chunkcxx . . $ tLoadGameDialogData#chunk.);
555 bm_FreeBitmapcxx . . $ bm_FreeBitmap(d4f767463ce0a6b3).(bm_handle);
556 }
557 }
558 cb_data->cur_slotcxx . . $ tLoadGameDialogData#cur_slot. = id;
559 }
560
561 // draw bitmap if there is one
562 if (cb_data->chunkcxx . . $ tLoadGameDialogData#chunk..bm_arraycxx . . $ chunked_bitmap#bm_array.) {
563 UIBitmapItemcxx . . $ UIBitmapItem# bm_itemcxx . . $ UIBitmapItem#UIBitmapItem(49f6e7a06ebc5aa8).;
564 int x, y;
565 bm_item.set_chunked_bitmapcxx . . $ UIBitmapItem#set_chunked_bitmap(1635f60f4d3c1317).(&cb_data->chunkcxx . . $ tLoadGameDialogData#chunk.);
566 x = (wnd->Wcxx . . $ UIObject#W(455f465bc33b4cdf).() - bm_item.widthcxx . . $ UIBitmapItem#width(b126dc7c1de90089).()) / 2;
567 y = (wnd->Hcxx . . $ UIObject#H(455f465bc33b4cdf).() - bm_item.heightcxx . . $ UIBitmapItem#height(b126dc7c1de90089).()) / 4;
568 bm_item.drawcxx . . $ UIBitmapItem#draw(84329bcd07240ccf).(x, y);
569 }
570 }
571
572 bool LoadGameDialogcxx . . $ LoadGameDialog(c9857a73d68e59ba).() {
573 tLoadGameDialogDatacxx . . $ tLoadGameDialogData# lgd_data;
574 newuiTiledWindowcxx . . $ newuiTiledWindow# wndcxx . . $ newuiTiledWindow#newuiTiledWindow(49f6e7a06ebc5aa8).;
575 newuiSheetcxx . . $ newuiSheet# *sheet;
576 int i, res;
577 bool retval = true;
578
579 char savegame_dir[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
580 char pathname[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
581 char filename[PSFILENAME_LENcxx . . $ `lib/pstypes.h:31:9`! + 1];
582 char desc[GAMESAVE_DESCLENcxx . . $ `Descent3/gamesave.h:102:9`! + 1];
583 bool occupied_slot[N_SAVE_SLOTScxx . . $ `Descent3/gamesave.cpp:308:9`!], loadgames_avail = false;
584
585 if (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) {
586 DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).(TXT_ERRORcxx . . $ `Descent3/stringtable.h:165:9`!, TXT_CANT_LOAD_MULTIcxx . . $ `Descent3/stringtable.h:90:9`!, MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!);
587 return false;
588 }
589
590 // setup paths.
591 ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(savegame_dir, Base_directory_writecxx . . $ Base_directory_write., "savegame", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
592 ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(pathname, savegame_dir, "*.sav", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
593
594 // create savegame directory if it didn't exist before.
595 if (!stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::is_directorycxx . . $ std/filesystem/is_directory(c53a6ef3278968b1).(savegame_dircxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).)) {
596 DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).(TXT_ERRORcxx . . $ `Descent3/stringtable.h:165:9`!, TXT_ERRNOSAVEGAMEScxx . . $ `Descent3/stringtable.h:369:9`!, MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!);
597 return false;
598 }
599
600 // open window
601 wnd.Createcxx . . $ newuiTiledWindow#Create(9860cac3d762132).(TXT_LOADGAMEcxx . . $ `Descent3/stringtable.h:371:9`!, 0, 0, GAMESAVE_WND_Wcxx . . $ `Descent3/gamesave.cpp:309:9`!, GAMESAVE_WND_Hcxx . . $ `Descent3/gamesave.cpp:310:9`!);
602 wnd.Opencxx . . $ UIWindow#Open(49f6e7a06ebc5aa8).();
603 sheet = wnd.GetSheetcxx . . $ newuiTiledWindow#GetSheet(661381a276e5b628).();
604
605 sheet->NewGroupcxx . . $ newuiSheet#NewGroup(465b27e37ce794b1).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, GAMESAVE_HELP_Xcxx . . $ `Descent3/gamesave.cpp:315:9`!, GAMESAVE_HELP_Ycxx . . $ `Descent3/gamesave.cpp:314:9`!);
606 sheet->AddTextcxx . . $ newuiSheet#AddText(326aeb464d16410c).(TXT_LOADGAMEHELPcxx . . $ `Descent3/stringtable.h:772:9`!);
607
608 sheet->NewGroupcxx . . $ newuiSheet#NewGroup(465b27e37ce794b1).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, GAMESAVE_SLOT_Xcxx . . $ `Descent3/gamesave.cpp:318:9`!, GAMESAVE_SLOT_Ycxx . . $ `Descent3/gamesave.cpp:316:9`!);
609
610 // generate save slots.
611 lgd_data.cur_slotcxx . . $ tLoadGameDialogData#cur_slot. = SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`!;
612 lgd_data.chunkcxx . . $ tLoadGameDialogData#chunk..bm_arraycxx . . $ chunked_bitmap#bm_array. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
613
614 for (i = 0; i < N_SAVE_SLOTScxx . . $ `Descent3/gamesave.cpp:308:9`!; i++) {
615 FILEcxx . . $ FILE# *fp;
616 bool ingroup = (i == 0 || i == (N_SAVE_SLOTScxx . . $ `Descent3/gamesave.cpp:308:9`! - 1)) ? true : false;
617
618 snprintf(filename, sizeof(filename), "saveg00%d", i);
619 ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(pathname, savegame_dir, filename, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
620
621 occupied_slot[i] = false;
622
623 fp = fopen(pathname, "rb");
624 if (fp) {
625 int bm_handle = -1;
626 int *pbm_handle;
627 fclose(fp);
628
629 if (lgd_data.cur_slotcxx . . $ tLoadGameDialogData#cur_slot. == (SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`! + i)) {
630 pbm_handle = &bm_handle;
631 } else {
632 pbm_handle = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
633 }
634
635 if (GetGameStateInfocxx . . $ GetGameStateInfo(3bcbb53201fcdcb8).(pathname, desc, pbm_handle)) {
636 sheet->AddHotspotcxx . . $ newuiSheet#AddHotspot(9900cc9f47e11d13).(desc, GAMESAVE_SLOT_Wcxx . . $ `Descent3/gamesave.cpp:311:9`!, GAMESAVE_SLOT_Hcxx . . $ `Descent3/gamesave.cpp:312:9`!, SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`! + i, ingroup);
637 occupied_slot[i] = true;
638 loadgames_avail = true;
639
640 // create chunk
641 if (pbm_handle && bm_handle > 0) {
642 if (lgd_data.chunkcxx . . $ tLoadGameDialogData#chunk..bm_arraycxx . . $ chunked_bitmap#bm_array.) {
643 bm_DestroyChunkedBitmapcxx . . $ bm_DestroyChunkedBitmap(1635f60f4d3c1317).(&lgd_data.chunkcxx . . $ tLoadGameDialogData#chunk.);
644 }
645 bm_CreateChunkedBitmapcxx . . $ bm_CreateChunkedBitmap(b9fa1b176cbdfaf1).(bm_handle, &lgd_data.chunkcxx . . $ tLoadGameDialogData#chunk.);
646 bm_FreeBitmapcxx . . $ bm_FreeBitmap(d4f767463ce0a6b3).(bm_handle);
647 }
648 } else {
649 sheet->AddHotspotcxx . . $ newuiSheet#AddHotspot(9900cc9f47e11d13).(TXT_ILLEGALSAVEGAMEcxx . . $ `Descent3/stringtable.h:364:9`!, GAMESAVE_SLOT_Wcxx . . $ `Descent3/gamesave.cpp:311:9`!, GAMESAVE_SLOT_Hcxx . . $ `Descent3/gamesave.cpp:312:9`!, SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`! + i, ingroup);
650 }
651 } else {
652 sheet->AddHotspotcxx . . $ newuiSheet#AddHotspot(9900cc9f47e11d13).(TXT_EMPTYcxx . . $ `Descent3/stringtable.h:367:9`!, GAMESAVE_SLOT_Wcxx . . $ `Descent3/gamesave.cpp:311:9`!, GAMESAVE_SLOT_Hcxx . . $ `Descent3/gamesave.cpp:312:9`!, SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`! + i, ingroup);
653 }
654 }
655
656 if (!loadgames_avail) {
657 wnd.Closecxx . . $ UIWindow#Close(49f6e7a06ebc5aa8).();
658 DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).("", TXT_ERRNOSAVEGAMEScxx . . $ `Descent3/stringtable.h:369:9`!, MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!);
659 wnd.Opencxx . . $ UIWindow#Open(49f6e7a06ebc5aa8).();
660 retval = false;
661 goto loadgame_fail;
662 }
663
664 sheet->NewGroupcxx . . $ newuiSheet#NewGroup(465b27e37ce794b1).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, GAMESAVE_WND_Wcxx . . $ `Descent3/gamesave.cpp:309:9`! - 148, GAMESAVE_WND_Hcxx . . $ `Descent3/gamesave.cpp:310:9`! - 100);
665 sheet->AddButtoncxx . . $ newuiSheet#AddButton(680bf41633375800).(TXT_CANCELcxx . . $ `Descent3/stringtable.h:35:9`!, UID_CANCELcxx . . $ `ui/ui.h:369:9`!);
666
667 wnd.SetDatacxx . . $ newuiTiledWindow#SetData(5d22bdacc48458e8).(&lgd_data);
668 wnd.SetOnDrawCBcxx . . $ newuiTiledWindow#SetOnDrawCB(af93e79073e6e663).(LoadGameDialogCBcxx . . $ LoadGameDialogCB(ea6308bbb4c73cea).);
669
670 // Mouse clicks from gameplay will be read by the dialog without this flush
671 ddio_MouseQueueFlushcxx . . $ ddio_MouseQueueFlush(49f6e7a06ebc5aa8).();
672
673 // do ui.
674 do {
675 res = wnd.DoUIcxx . . $ newuiTiledWindow#DoUI(b126dc7c1de90089).();
676 if (res == NEWUIRES_FORCEQUITcxx . . $ `Descent3/newui_core.h:131:9`!) {
677 retval = false;
678 break;
679 } else if (res >= SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`! && res < (SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`! + N_SAVE_SLOTScxx . . $ `Descent3/gamesave.cpp:308:9`!)) {
680 int slot = res - SAVE_HOTSPOT_IDcxx . . $ `Descent3/gamesave.cpp:307:9`!;
681
682 if (occupied_slot[slot]) {
683 snprintf(filename, sizeof(filename), "saveg00%d", slot);
684 ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(pathname, savegame_dir, filename, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
685 strcpy(LGS_Pathcxx . . $ LGS_Path., pathname);
686 SetGameStatecxx . . $ SetGameState(35729c5b0b4aef73).(GAMESTATE_LOADGAMEcxx . . $ GAMESTATE_LOADGAME.);
687 res = UID_CANCELcxx . . $ `ui/ui.h:369:9`!;
688 }
689 } else if (res == UID_CANCELcxx . . $ `ui/ui.h:369:9`!) {
690 retval = false;
691 }
692 } while (res != UID_CANCELcxx . . $ `ui/ui.h:369:9`!);
693
694 loadgame_fail:
695 if (lgd_data.chunkcxx . . $ tLoadGameDialogData#chunk..bm_arraycxx . . $ chunked_bitmap#bm_array.) {
696 bm_DestroyChunkedBitmapcxx . . $ bm_DestroyChunkedBitmap(1635f60f4d3c1317).(&lgd_data.chunkcxx . . $ tLoadGameDialogData#chunk.);
697 }
698
699 wnd.Closecxx . . $ UIWindow#Close(49f6e7a06ebc5aa8).();
700 wnd.Destroycxx . . $ UIWindow#Destroy(49f6e7a06ebc5aa8).();
701
702 return retval;
703 }
704
705 //////////////////////////////////////////////////////////////////////////////
706
707 // loads savegame as specified from LoadGameDialog.
708 bool LoadCurrentSaveGamecxx . . $ LoadCurrentSaveGame(c9857a73d68e59ba).() {
709 int retval = LoadGameStatecxx . . $ LoadGameState(5c4306d8553b3696).(LGS_Pathcxx . . $ LGS_Path.);
710 if (retval != LGS_OKcxx . . $ `Descent3/gamesave.h:136:9`!) {
711 Int3cxx . . $ `misc/pserror.h:247:9`!();
712 DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).(TXT_ERRORcxx . . $ `Descent3/stringtable.h:165:9`!, TXT_LOADGAMEFAILEDcxx . . $ `Descent3/stringtable.h:366:9`!, MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!);
713 return false;
714 }
715 AddHUDMessagecxx . . $ AddHUDMessage(f90d95ab21fd6d97).(TXT_GAMERESTOREDcxx . . $ `Descent3/stringtable.h:866:9`!);
716 return true;
717 }
718
719 //////////////////////////////////////////////////////////////////////////////
720
721 // give a description and slot number (0 to GAMESAVE_SLOTS-1)
722 bool SaveGameStatecxx . . $ SaveGameState(b7a7aa4a824b7595).(const char *pathname, const char *description) {
723 CFILEcxx . . $ CFILE# *fp;
724 char buf[GAMESAVE_DESCLENcxx . . $ `Descent3/gamesave.h:102:9`! + 1];
725 int16_t pending_music_region;
726
727 fp = cfopencxx . . $ cfopen(7c7b94e455f1ae56).(pathnamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., "wb");
728 if (!fp)
729 return false;
730
731 // Delete the old games restored count.
732 char countpath[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`! * 2];
733 strcpy(countpath, pathname);
734 strcat(countpath, ".cnt");
735 CFILEcxx . . $ CFILE# *countfp;
736 countfp = cfopencxx . . $ cfopen(7c7b94e455f1ae56).(countpathcxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., "wb");
737 if (countfp) {
738 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(countfp, Times_game_restoredcxx . . $ Times_game_restored.);
739 cfclosecxx . . $ cfclose(3639e799710acb68).(countfp);
740 }
741
742 // save out header
743 START_VERIFY_SAVEFILEcxx . . $ `Descent3/gamesave.h:167:9`!(fp);
744 ASSERTcxx . . $ `misc/pserror.h:246:9`!(strlen(description) < sizeof(buf));
745 strcpy(buf, description);
746 cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)buf, sizeof(buf), fp);
747 cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fp, GAMESAVE_VERSIONcxx . . $ `Descent3/gamesave.h:122:9`!);
748
749 SGSSnapshotcxx . . $ SGSSnapshot(3639e799710acb68).(fp); // Save snapshot? MUST KEEP THIS HERE.
750
751 // write out translation tables
752 SGSXlateTablescxx . . $ SGSXlateTables(3639e799710acb68).(fp);
753
754 // write out gamemode information
755
756 // write out mission level information
757 cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fp, (int16_t)Current_missioncxx . . $ Current_mission..cur_levelcxx . . $ tMission#cur_level.);
758
759 if (Current_missioncxx . . $ Current_mission..filenamecxx . . $ tMission#filename. && (stricmpcxx . . $ `linux/linux_fix.h:43:9`!("d3_2.mn3", Current_mission.filename) == 0)) {
760 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(fp, "d3.mn3");
761 } else {
762 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(fp, Current_missioncxx . . $ Current_mission..filenamecxx . . $ tMission#filename. ? Current_missioncxx . . $ Current_mission..filenamecxx . . $ tMission#filename. : "");
763 }
764
765 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, Current_missioncxx . . $ Current_mission..game_state_flagscxx . . $ tMission#game_state_flags.);
766
767 cf_WriteFloatcxx . . $ cf_WriteFloat(c51c6cf5f6d5270c).(fp, Gametimecxx . . $ Gametime.);
768 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, FrameCountcxx . . $ FrameCount.);
769 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, Current_waypointcxx . . $ Current_waypoint.);
770
771 pending_music_region = D3MusicGetPendingRegioncxx . . $ D3MusicGetPendingRegion(4c3706f7850cf040).();
772 if (pending_music_region < 0) {
773 pending_music_region = D3MusicGetRegioncxx . . $ D3MusicGetRegion(4c3706f7850cf040).();
774 }
775 cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fp, pending_music_region);
776
777 // cf_WriteInt(fp,Times_game_restored);
778 // Save weather
779 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, sizeof(Weathercxx . . $ Weather.));
780 cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)&Weathercxx . . $ Weather., sizeof(Weathercxx . . $ Weather.), fp);
781
782 // Save active doorways
783 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, MAX_ACTIVE_DOORWAYScxx . . $ `Descent3/doorway.h:120:9`!);
784 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, Num_active_doorwayscxx . . $ Num_active_doorways.);
785
786 for (int d = 0; d < MAX_ACTIVE_DOORWAYScxx . . $ `Descent3/doorway.h:120:9`!; d++) {
787 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, Active_doorwayscxx . . $ Active_doorways.[d]);
788 }
789
790 // save out room information.
791 SGSRoomscxx . . $ SGSRooms(3639e799710acb68).(fp);
792
793 // save out triggers
794 SGSTriggerscxx . . $ SGSTriggers(3639e799710acb68).(fp);
795
796 // save out object information.
797 SGSObjectscxx . . $ SGSObjects(3639e799710acb68).(fp);
798
799 // players
800 SGSPlayerscxx . . $ SGSPlayers(3639e799710acb68).(fp);
801
802 // save out matcens
803 SGSMatcenscxx . . $ SGSMatcens(3639e799710acb68).(fp);
804
805 // save out viseffects
806 SGSVisEffectscxx . . $ SGSVisEffects(3639e799710acb68).(fp);
807
808 // save out spew
809 SGSSpewcxx . . $ SGSSpew(3639e799710acb68).(fp);
810
811 // Save OSIRIS stuff
812 Osiris_SaveSystemStatecxx . . $ Osiris_SaveSystemState(3639e799710acb68).(fp);
813
814 // Save Level goal info
815 Level_goalscxx . . $ Level_goals..SaveLevelGoalInfocxx . . $ levelgoals#SaveLevelGoalInfo(254217fab7598d49).(fp);
816
817 // save out game messages from console. (must occur AFTER players are written out!!!)
818 SGSGameMessagescxx . . $ SGSGameMessages(3639e799710acb68).(fp);
819
820 // save out special hud item states.
821 SGSHudStatecxx . . $ SGSHudState(3639e799710acb68).(fp);
822
823 // end
824 END_VERIFY_SAVEFILEcxx . . $ `Descent3/gamesave.h:168:9`!(fp, "Total save");
825 cfclosecxx . . $ cfclose(3639e799710acb68).(fp);
826
827 return true;
828 }
829
830 //////////////////////////////////////////////////////////////////////////////
831
832 #define SAVE_DATA_TABLEcxx . . $ `Descent3/gamesave.cpp:832:9`!(_nitems, _array) \
833 do { \
834 highest_index = -1; \
835 for (i = 0; i < (_nitems); i++) \
836 if (_array[i].used) \
837 highest_index = i; \
838 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, highest_index + 1); \
839 for (i = 0; i <= highest_index; i++) \
840 cf_WriteString(fp, _array[i].used ? _array[i].name : ""); \
841 } while (0)
842
843 // writes out translation tables.
844 void SGSXlateTablescxx . . $ SGSXlateTables(3639e799710acb68).(CFILEcxx . . $ CFILE# *fp) {
845 START_VERIFY_SAVEFILEcxx . . $ `Descent3/gamesave.h:167:9`!(fp);
846 // create object info translation table
847 int16_t i, highest_index = -1;
848
849 for (i = 0; i < MAX_OBJECT_IDScxx . . $ `Descent3/objinfo.h:327:9`!; i++)
850 if (Object_infocxx . . $ Object_info.[i].typecxx . . $ object_info#type. != OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!)
851 highest_index = i;
852
853 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, highest_index + 1);
854
855 for (i = 0; i <= highest_index; i++)
856 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(fp, (Object_infocxx . . $ Object_info.[i].typecxx . . $ object_info#type. != OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!) ? Object_infocxx . . $ Object_info.[i].namecxx . . $ object_info#name. : "");
857
858 // write out polymodel list.
859 SAVE_DATA_TABLEcxx . . $ `Descent3/gamesave.cpp:832:9`!(MAX_POLY_MODELScxx . . $ `lib/polymodel_external.h:66:9`!, Poly_models);
860
861 // save out door list
862 SAVE_DATA_TABLEcxx . . $ `Descent3/gamesave.cpp:832:9`!(MAX_DOORScxx . . $ `Descent3/door.h:143:9`!, Doors);
863
864 // save out ship list
865 SAVE_DATA_TABLEcxx . . $ `Descent3/gamesave.cpp:832:9`!(MAX_SHIPScxx . . $ `Descent3/ship.h:122:9`!, Ships);
866
867 // save out weapons list
868 SAVE_DATA_TABLEcxx . . $ `Descent3/gamesave.cpp:832:9`!(MAX_WEAPONScxx . . $ `Descent3/weapon.h:208:9`!, Weapons);
869
870 // save out textures list
871 SAVE_DATA_TABLEcxx . . $ `Descent3/gamesave.cpp:832:9`!(MAX_TEXTUREScxx . . $ `Descent3/gametexture.h:244:9`!, GameTextures);
872
873 // write out bitmap handle list. look at all Objects that are fireballs and
874 // save their handles-names.
875 for (i = 0; i <= Highest_object_indexcxx . . $ Highest_object_index.; i++)
876 if (Objectscxx . . $ Objects.[i].typecxx . . $ object#type. == OBJ_FIREBALLcxx . . $ `Descent3/object_external.h:161:9`!) {
877 if (Objectscxx . . $ Objects.[i].ctypecxx . . $ object#ctype..blast_infocxx . . $ object#$anonymous_type_9#blast_info..bm_handlecxx . . $ blast_info_s#bm_handle. > -1) {
878 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, Objects[i].ctype.blast_info.bm_handle);
879 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(fp, GameBitmapscxx . . $ GameBitmaps.[Objectscxx . . $ Objects.[i].ctypecxx . . $ object#ctype..blast_infocxx . . $ object#$anonymous_type_9#blast_info..bm_handlecxx . . $ blast_info_s#bm_handle.].namecxx . . $ bms_bitmap#name.);
880 }
881 }
882 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, -1); // terminate bitmap list
883 cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(fp, "");
884 END_VERIFY_SAVEFILEcxx . . $ `Descent3/gamesave.h:168:9`!(fp, "Xlate save");
885 }
886
887 extern uint8_tcxx . . $ uint8_t# AutomapVisMapcxx . . $ AutomapVisMap.[MAX_ROOMScxx . . $ `Descent3/room.h:377:9`!];
888 // initializes rooms
889 void SGSRoomscxx . . $ SGSRooms(3639e799710acb68).(CFILEcxx . . $ CFILE# *fp) {
890 int i, f, p;
891
892 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, (int16_t)Highest_room_index);
893
894 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, MAX_ROOMScxx . . $ `Descent3/room.h:377:9`!);
895
896 for (i = 0; i < MAX_ROOMScxx . . $ `Descent3/room.h:377:9`!; i++) {
897 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, AutomapVisMap[i]);
898 }
899
900 for (i = 0; i <= Highest_room_indexcxx . . $ Highest_room_index.; i++) {
901 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, Rooms[i].used);
902 if (Roomscxx . . $ Rooms.[i].usedcxx . . $ room#used.) {
903 // we need to save some room info out.
904 gs_WriteIntcxx . . $ `Descent3/gamesave.h:163:9`!(fp, Rooms[i].flags);
905 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, Rooms[i].pulse_time);
906 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, Rooms[i].pulse_offset);
907 gs_WriteVectorcxx . . $ `Descent3/gamesave.h:148:9`!(fp, Rooms[i].wind);
908 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, Rooms[i].last_render_time);
909 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, Rooms[i].fog_depth);
910 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, Rooms[i].fog_r);
911 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, Rooms[i].fog_g);
912 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, Rooms[i].fog_b);
913 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, Rooms[i].damage);
914
915 //?? gs_WriteFloat(fp, Rooms[i].ambient_sound); // need to save an index of sounds.
916
917 // save additional face information here.
918 // save texture changes
919 int num_changed = 0;
920 for (f = 0; f < Roomscxx . . $ Rooms.[i].num_facescxx . . $ room#num_faces.; f++) {
921 if (Roomscxx . . $ Rooms.[i].facescxx . . $ room#faces.[f].flagscxx . . $ face#flags. & FF_TEXTURE_CHANGEDcxx . . $ `Descent3/room_external.h:115:9`!)
922 num_changed++;
923 }
924 cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fp, num_changed);
925 for (f = 0; f < Roomscxx . . $ Rooms.[i].num_facescxx . . $ room#num_faces.; f++) {
926 if (Roomscxx . . $ Rooms.[i].facescxx . . $ room#faces.[f].flagscxx . . $ face#flags. & FF_TEXTURE_CHANGEDcxx . . $ `Descent3/room_external.h:115:9`!) {
927 cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fp, f);
928 cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fp, Roomscxx . . $ Rooms.[i].facescxx . . $ room#faces.[f].tmapcxx . . $ face#tmap.);
929 }
930 }
931
932 for (p = 0; p < Roomscxx . . $ Rooms.[i].num_portalscxx . . $ room#num_portals.; p++) {
933 gs_WriteIntcxx . . $ `Descent3/gamesave.h:163:9`!(fp, Rooms[i].portals[p].flags);
934 }
935
936 // save doorway info
937 if (Roomscxx . . $ Rooms.[i].flagscxx . . $ room#flags. & RF_DOORcxx . . $ `Descent3/room_external.h:176:9`!) {
938 doorwaycxx . . $ doorway# *dp = Roomscxx . . $ Rooms.[i].doorway_datacxx . . $ room#doorway_data.;
939 ASSERTcxx . . $ `misc/pserror.h:246:9`!(dp != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
940 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, dp->state);
941 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, dp->flags);
942 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, dp->keys_needed);
943 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, dp->position);
944 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, dp->dest_pos);
945 gs_WriteIntcxx . . $ `Descent3/gamesave.h:163:9`!(fp, dp->sound_handle);
946 gs_WriteIntcxx . . $ `Descent3/gamesave.h:163:9`!(fp, dp->activenum);
947 gs_WriteIntcxx . . $ `Descent3/gamesave.h:163:9`!(fp, dp->doornum);
948 }
949 }
950 }
951 }
952
953 // saves out events
954 void SGSEventscxx . . $ SGSEvents(3639e799710acb68).(CFILEcxx . . $ CFILE# *fp) {}
955
956 // saves out triggers
957 void SGSTriggerscxx . . $ SGSTriggers(3639e799710acb68).(CFILEcxx . . $ CFILE# *fp) {
958 int i;
959
960 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, (int16_t)Num_triggers);
961
962 for (i = 0; i < Num_triggerscxx . . $ Num_triggers.; i++) {
963 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, Triggers[i].flags);
964 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, Triggers[i].activator);
965
966 // write script info
967 //@@ SGSScript(fp, &Triggers[i].script);
968 }
969 }
970
971 // players
972 void SGSPlayerscxx . . $ SGSPlayers(3639e799710acb68).(CFILEcxx . . $ CFILE# *fp) {
973 // player struct needs savin
974 playercxx . . $ player# *plr = &Playerscxx . . $ Players.[0];
975
976 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, sizeof(player));
977 cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)plr, sizeof(playercxx . . $ player#), fp);
978 if (plr->guided_objcxx . . $ player#guided_obj.)
979 gs_WriteIntcxx . . $ `Descent3/gamesave.h:163:9`!(fp, plr->guided_obj->handle);
980
981 // save inventory and countermeasures
982 plr->inventorycxx . . $ player#inventory..SaveInventorycxx . . $ Inventory#SaveInventory(413716a422df0036).(fp);
983 plr->counter_measurescxx . . $ player#counter_measures..SaveInventorycxx . . $ Inventory#SaveInventory(413716a422df0036).(fp);
984 }
985
986 // save viseffects
987 void SGSVisEffectscxx . . $ SGSVisEffects(3639e799710acb68).(CFILEcxx . . $ CFILE# *fp) {
988 int i, count = 0;
989
990 // count up all viseffects to write out.
991 for (i = 0; i <= Highest_vis_effect_indexcxx . . $ Highest_vis_effect_index.; i++)
992 if (VisEffectscxx . . $ VisEffects.[i].typecxx . . $ vis_effect#type. != VIS_NONEcxx . . $ `Descent3/viseffect_external.h:60:9`!)
993 count++;
994
995 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, (int16_t)count);
996
997 for (i = 0; i <= Highest_vis_effect_indexcxx . . $ Highest_vis_effect_index.; i++) {
998 if (VisEffectscxx . . $ VisEffects.[i].typecxx . . $ vis_effect#type. != VIS_NONEcxx . . $ `Descent3/viseffect_external.h:60:9`!)
999 cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)&VisEffectscxx . . $ VisEffects.[i], sizeof(vis_effectcxx . . $ vis_effect#), fp);
1000 }
1001 }
1002
1003 extern int Physics_NumLinkedcxx . . $ Physics_NumLinked.;
1004 extern int PhysicsLinkListcxx . . $ PhysicsLinkList.[MAX_OBJECTScxx . . $ `lib/object_external_struct.h:107:9`!];
1005 extern char MarkerMessagescxx . . $ MarkerMessages.[MAX_PLAYERScxx . . $ `Descent3/player_external_struct.h:86:9`! * 2][MAX_MARKER_MESSAGE_LENGTHcxx . . $ `Descent3/marker.h:24:9`!];
1006 extern int Marker_messagecxx . . $ Marker_message.;
1007 void InsureSaveGamecxx . . $ InsureSaveGame(3639e799710acb68).(CFILEcxx . . $ CFILE# *fp) { cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, 0xF00D4B0B); }
1008
1009 #define INSURE_SAVEFILEcxx . . $ `Descent3/gamesave.cpp:1009:9`!
1010 // InsureSaveGame(fp)
1011
1012 // saves out objects
1013 void SGSObjectscxx . . $ SGSObjects(3639e799710acb68).(CFILEcxx . . $ CFILE# *fp) {
1014 int i, j;
1015
1016 START_VERIFY_SAVEFILEcxx . . $ `Descent3/gamesave.h:167:9`!(fp);
1017
1018 // Save marker info (text)
1019 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, Marker_messagecxx . . $ Marker_message.);
1020 cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fp, (int16_t)MAX_PLAYERScxx . . $ `Descent3/player_external_struct.h:86:9`! * 2);
1021 for (i = 0; i < MAX_PLAYERScxx . . $ `Descent3/player_external_struct.h:86:9`! * 2; i++) {
1022 cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fp, strlen(MarkerMessagescxx . . $ MarkerMessages.[i]) + 1);
1023 cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)MarkerMessagescxx . . $ MarkerMessages.[i], strlen(MarkerMessagescxx . . $ MarkerMessages.[i]) + 1, fp);
1024 }
1025
1026 // this method should maintain the object list as it currently stands in the level
1027 cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fp, (int16_t)Highest_object_indexcxx . . $ Highest_object_index.);
1028
1029 // save what objects are stuck to each other
1030 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, MAX_OBJECTScxx . . $ `lib/object_external_struct.h:107:9`!);
1031 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, Physics_NumLinkedcxx . . $ Physics_NumLinked.);
1032 for (i = 0; i < MAX_OBJECTScxx . . $ `lib/object_external_struct.h:107:9`!; i++) {
1033 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, PhysicsLinkListcxx . . $ PhysicsLinkList.[i]);
1034 }
1035
1036 // save AI information
1037 //////////////////////////////////
1038 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, MAX_DYNAMIC_PATHScxx . . $ `Descent3/aistruct.h:858:9`!);
1039 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, MAX_NODEScxx . . $ `Descent3/aistruct.h:859:9`!);
1040
1041 int s;
1042 for (i = 0; i < MAX_DYNAMIC_PATHScxx . . $ `Descent3/aistruct.h:858:9`!; i++) {
1043 cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fp, AIDynamicPathcxx . . $ AIDynamicPath.[i].num_nodescxx . . $ ai_dynamic_path#num_nodes.);
1044 cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fp, AIDynamicPathcxx . . $ AIDynamicPath.[i].use_countcxx . . $ ai_dynamic_path#use_count.);
1045 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, AIDynamicPathcxx . . $ AIDynamicPath.[i].owner_handlecxx . . $ ai_dynamic_path#owner_handle.);
1046
1047 for (s = 0; s < MAX_NODEScxx . . $ `Descent3/aistruct.h:859:9`!; s++) {
1048 cf_WriteFloatcxx . . $ cf_WriteFloat(c51c6cf5f6d5270c).(fp, AIDynamicPathcxx . . $ AIDynamicPath.[i].poscxx . . $ ai_dynamic_path#pos.[s].xcxx . . $ vector#x.);
1049 cf_WriteFloatcxx . . $ cf_WriteFloat(c51c6cf5f6d5270c).(fp, AIDynamicPathcxx . . $ AIDynamicPath.[i].poscxx . . $ ai_dynamic_path#pos.[s].ycxx . . $ vector#y.);
1050 cf_WriteFloatcxx . . $ cf_WriteFloat(c51c6cf5f6d5270c).(fp, AIDynamicPathcxx . . $ AIDynamicPath.[i].poscxx . . $ ai_dynamic_path#pos.[s].zcxx . . $ vector#z.);
1051 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, AIDynamicPathcxx . . $ AIDynamicPath.[i].roomnumcxx . . $ ai_dynamic_path#roomnum.[s]);
1052 }
1053 }
1054
1055 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, MAX_ROOMScxx . . $ `Descent3/room.h:377:9`!);
1056 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, AIAltPathNumNodescxx . . $ AIAltPathNumNodes.);
1057
1058 for (i = 0; i < MAX_ROOMScxx . . $ `Descent3/room.h:377:9`!; i++) {
1059 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, AIAltPathcxx . . $ AIAltPath.[i]);
1060 }
1061
1062 ///////////////////////////////////
1063
1064 for (i = 0; i <= Highest_object_indexcxx . . $ Highest_object_index.; i++) {
1065 objectcxx . . $ object# *op = &Objectscxx . . $ Objects.[i];
1066 poly_modelcxx . . $ poly_model# *pm = &Poly_modelscxx . . $ Poly_models.[op->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num.];
1067
1068 gs_WriteIntcxx . . $ `Descent3/gamesave.h:163:9`!(fp, 0xBADB0B);
1069 // we don't save deleted objects or room objects since they're reconstructed on loadlevel
1070 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, (int8_t)op->type);
1071
1072 if (op->typecxx . . $ object#type. == OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!)
1073 continue;
1074 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, (int8_t)op->lighting_render_type);
1075
1076 // Store whether or not we have a pointer to lighting_info
1077 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, op->lighting_info ? 1 : 0);
1078 if (op->lighting_infocxx . . $ object#lighting_info.) {
1079 cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)op->lighting_infocxx . . $ object#lighting_info., sizeof(*op->lighting_infocxx . . $ object#lighting_info.), fp);
1080 }
1081
1082 // these objects FOR NOW won't be saved
1083 gs_WriteIntcxx . . $ `Descent3/gamesave.h:163:9`!(fp, op->handle);
1084 ASSERTcxx . . $ `misc/pserror.h:246:9`!((op->handle & HANDLE_OBJNUM_MASKcxx . . $ `Descent3/object.h:642:9`!) == i);
1085
1086 // type and handle info.
1087 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, (int8_t)op->dummy_type);
1088 // positional information
1089 gs_WriteIntcxx . . $ `Descent3/gamesave.h:163:9`!(fp, op->roomnum);
1090 gs_WriteVectorcxx . . $ `Descent3/gamesave.h:148:9`!(fp, op->pos);
1091 gs_WriteVectorcxx . . $ `Descent3/gamesave.h:148:9`!(fp, op->last_pos);
1092 gs_WriteMatrixcxx . . $ `Descent3/gamesave.h:154:9`!(fp, op->orient);
1093
1094 // write out object name
1095 int ii;
1096 ii = (op->namecxx . . $ object#name.) ? strlen(op->namecxx . . $ object#name.) : 0;
1097 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, ii);
1098 if (ii > 0)
1099 cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)op->namecxx . . $ object#name., ii, fp);
1100
1101 // data universal to all objects that need to be saved.
1102 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, (int16_t)op->id);
1103 gs_WriteIntcxx . . $ `Descent3/gamesave.h:163:9`!(fp, static_cast<int32_t>(op->flags));
1104 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, (int8_t)op->control_type);
1105 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, (int8_t)op->movement_type);
1106 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, (int8_t)op->render_type);
1107
1108 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, (int16_t)op->renderframe);
1109 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, op->size);
1110 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, op->shields);
1111 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, op->contains_type);
1112 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, op->contains_id);
1113 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, op->contains_count);
1114 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, op->creation_time);
1115 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, op->lifeleft);
1116 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, op->lifetime);
1117 gs_WriteIntcxx . . $ `Descent3/gamesave.h:163:9`!(fp, op->parent_handle);
1118
1119 // attachment info.
1120 gs_WriteIntcxx . . $ `Descent3/gamesave.h:163:9`!(fp, op->attach_ultimate_handle);
1121 gs_WriteIntcxx . . $ `Descent3/gamesave.h:163:9`!(fp, op->attach_parent_handle);
1122 if ((op->attach_ultimate_handlecxx . . $ object#attach_ultimate_handle.) && (OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`! != op->attach_ultimate_handlecxx . . $ object#attach_ultimate_handle.)) {
1123 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Object %d has an ultimate parent of %d (%d)\n", i, OBJNUM(ObjGet(op->attach_ultimate_handle)),
1124 op->attach_parent_handle);
1125 }
1126 if ((op->attach_ultimate_handlecxx . . $ object#attach_ultimate_handle.) && (OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`! != op->attach_parent_handlecxx . . $ object#attach_parent_handle.)) {
1127 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Object %d has a parent of %d (%d)\n", i, OBJNUM(ObjGet(op->attach_parent_handle)),
1128 op->attach_parent_handle);
1129 }
1130
1131 gs_WriteIntcxx . . $ `Descent3/gamesave.h:163:9`!(fp, pm->n_attach);
1132 if (pm->n_attachcxx . . $ poly_model#n_attach.) {
1133 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Object %d has %d attach points.\n", i, pm->n_attach);
1134
1135 if (op->attach_childrencxx . . $ object#attach_children.) {
1136 gs_WriteIntcxx . . $ `Descent3/gamesave.h:163:9`!(fp, 1);
1137
1138 for (j = 0; j < pm->n_attachcxx . . $ poly_model#n_attach.; j++)
1139 gs_WriteIntcxx . . $ `Descent3/gamesave.h:163:9`!(fp, op->attach_children[j]);
1140 } else {
1141 gs_WriteIntcxx . . $ `Descent3/gamesave.h:163:9`!(fp, 0);
1142 }
1143 }
1144
1145 INSURE_SAVEFILEcxx . . $ `Descent3/gamesave.cpp:1009:9`!;
1146
1147 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, op->attach_type);
1148 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, op->attach_index);
1149 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, op->attach_dist);
1150 gs_WriteVectorcxx . . $ `Descent3/gamesave.h:148:9`!(fp, op->min_xyz);
1151 gs_WriteVectorcxx . . $ `Descent3/gamesave.h:148:9`!(fp, op->max_xyz);
1152 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, op->impact_size);
1153 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, op->impact_time);
1154 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, op->impact_player_damage);
1155 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, op->impact_generic_damage);
1156 gs_WriteFloatcxx . . $ `Descent3/gamesave.h:164:9`!(fp, op->impact_force);
1157
1158 // write out custom default script info
1159 ii = (op->custom_default_script_namecxx . . $ object#custom_default_script_name.) ? strlen(op->custom_default_script_namecxx . . $ object#custom_default_script_name.) : 0;
1160 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, ii);
1161 if (ii > 0)
1162 cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)op->custom_default_script_namecxx . . $ object#custom_default_script_name., ii, fp);
1163
1164 ii = (op->custom_default_module_namecxx . . $ object#custom_default_module_name.) ? strlen(op->custom_default_module_namecxx . . $ object#custom_default_module_name.) : 0;
1165 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, ii);
1166 if (ii > 0)
1167 cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)op->custom_default_module_namecxx . . $ object#custom_default_module_name., ii, fp);
1168
1169 INSURE_SAVEFILEcxx . . $ `Descent3/gamesave.cpp:1009:9`!;
1170
1171 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, (int16_t)op->position_counter);
1172
1173 INSURE_SAVEFILEcxx . . $ `Descent3/gamesave.cpp:1009:9`!;
1174
1175 // write out all structures here.
1176 // movement info.
1177 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, sizeof(op->mtype));
1178 cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)&op->mtypecxx . . $ object#mtype., sizeof(op->mtypecxx . . $ object#mtype.), fp);
1179
1180 INSURE_SAVEFILEcxx . . $ `Descent3/gamesave.cpp:1009:9`!;
1181
1182 // Control info, determined by CONTROL_TYPE
1183 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, sizeof(op->ctype));
1184 cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)&op->ctypecxx . . $ object#ctype., sizeof(op->ctypecxx . . $ object#ctype.), fp);
1185
1186 INSURE_SAVEFILEcxx . . $ `Descent3/gamesave.cpp:1009:9`!;
1187
1188 // save ai information.
1189 SGSObjAIcxx . . $ SGSObjAI(c32be398de915cb1).(fp, op->ai_infocxx . . $ object#ai_info.);
1190
1191 INSURE_SAVEFILEcxx . . $ `Descent3/gamesave.cpp:1009:9`!;
1192 // save out rendering information
1193 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, sizeof(op->rtype));
1194 cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)&op->rtypecxx . . $ object#rtype., sizeof(op->rtypecxx . . $ object#rtype.), fp);
1195
1196 cf_WriteFloatcxx . . $ cf_WriteFloat(c51c6cf5f6d5270c).(fp, op->sizecxx . . $ object#size.);
1197 if (op->render_typecxx . . $ object#render_type. == RT_POLYOBJcxx . . $ `Descent3/object_external.h:258:9`!) {
1198 // Do Animation stuff
1199 custom_animcxx . . $ custom_anim# multi_anim_info;
1200 ObjGetAnimUpdatecxx . . $ ObjGetAnimUpdate(6db95621231b744d).(i, &multi_anim_info);
1201 cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)&multi_anim_info, sizeof(multi_anim_info), fp);
1202 }
1203
1204 INSURE_SAVEFILEcxx . . $ `Descent3/gamesave.cpp:1009:9`!;
1205
1206 // dynamic weapon battery info!!
1207 SGSObjWBcxx . . $ SGSObjWB(12961102d09f19c6).(fp, op, (op->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) ? MAX_WBS_PER_OBJcxx . . $ `lib/robotfirestruct.h:32:9`! : pm->num_wbscxx . . $ poly_model#num_wbs.);
1208
1209 INSURE_SAVEFILEcxx . . $ `Descent3/gamesave.cpp:1009:9`!;
1210
1211 // save effect info!
1212 SGSObjEffectscxx . . $ SGSObjEffects(b160c87ac8ed4668).(fp, op);
1213
1214 INSURE_SAVEFILEcxx . . $ `Descent3/gamesave.cpp:1009:9`!;
1215
1216 // save script stuff.
1217 //@@ SGSScript(fp, &op->script);
1218
1219 // special things local to object
1220 SGSObjSpecialcxx . . $ SGSObjSpecial(b160c87ac8ed4668).(fp, op);
1221 }
1222 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "highest obj index = %d, ", Highest_object_index);
1223 END_VERIFY_SAVEFILEcxx . . $ `Descent3/gamesave.h:168:9`!(fp, "Objects save");
1224 }
1225
1226 // saves ai
1227 void SGSObjAIcxx . . $ SGSObjAI(c32be398de915cb1).(CFILEcxx . . $ CFILE# *fp, const ai_framecxx . . $ ai_frame# *ai) {
1228 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, (ai ? 1 : 0));
1229 if (!ai)
1230 return;
1231
1232 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, sizeof(ai_frame));
1233 cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)ai, sizeof(ai_framecxx . . $ ai_frame#), fp);
1234 }
1235
1236 // saves script
1237 //@@void SGSScript(CFILE *fp, const script_info *script)
1238 //@@{
1239 //@@ int i,j;
1240 //@@
1241 //@@// ugh, write out script info.
1242 //@@ gs_WriteByte(fp, (script->thread ? 1 : 0));
1243 //@@
1244 //@@ if (script->name)
1245 //@@ cf_WriteString(fp, script->name);
1246 //@@ else
1247 //@@ cf_WriteString(fp, "");
1248 //@@
1249 //@@ gs_WriteShort(fp, script->num_parms);
1250 //@@ gs_WriteShort(fp, script->is_custom);
1251 //@@ for (i = 0; i < script->num_parms; i++)
1252 //@@ {
1253 //@@ gs_WriteByte(fp, script->parms[i].type);
1254 //@@ gs_WriteFloat(fp, script->parms[i].val.x);
1255 //@@ gs_WriteFloat(fp, script->parms[i].val.y);
1256 //@@ gs_WriteFloat(fp, script->parms[i].val.z);
1257 //@@ }
1258 //@@
1259 //@@// write out thread data if necessary
1260 //@@ if (script->thread) {
1261 //@@ const vector *mem = D3XGetThreadMem(script->thread->mem_handle);
1262 //@@ uint16_t mem_size = script->thread->prog->map[script->thread->prog_idx].mem;
1263 //@@
1264 //@@ gs_WriteShort(fp, mem_size);
1265 //@@ if (mem) {
1266 //@@ for (j = 0; j < mem_size; j++)
1267 //@@ gs_WriteVector(fp, mem[j]);
1268 //@@ }
1269 //@@ }
1270 //@@}
1271
1272 // saves fx
1273 void SGSObjEffectscxx . . $ SGSObjEffects(b160c87ac8ed4668).(CFILEcxx . . $ CFILE# *fp, const objectcxx . . $ object# *op) {
1274 effect_info_scxx . . $ effect_info_s# *ei = op->effect_infocxx . . $ object#effect_info.;
1275
1276 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, (ei ? 1 : 0));
1277 if (ei) {
1278 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, sizeof(effect_info_s));
1279 cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)ei, sizeof(effect_info_scxx . . $ effect_info_s#), fp);
1280 }
1281 }
1282
1283 // saves wb
1284 void SGSObjWBcxx . . $ SGSObjWB(12961102d09f19c6).(CFILEcxx . . $ CFILE# *fp, objectcxx . . $ object# *op, int num_wbs) {
1285 int i;
1286
1287 if (op->dynamic_wbcxx . . $ object#dynamic_wb.) {
1288 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, (int8_t)num_wbs);
1289 for (i = 0; i < num_wbs; i++) {
1290 dynamic_wb_infocxx . . $ dynamic_wb_info# *dwb = &op->dynamic_wbcxx . . $ object#dynamic_wb.[i];
1291 cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)dwb, sizeof(dynamic_wb_infocxx . . $ dynamic_wb_info#), fp);
1292 }
1293 } else {
1294 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, 0);
1295 }
1296 }
1297
1298 // saves special object info
1299 void SGSObjSpecialcxx . . $ SGSObjSpecial(b160c87ac8ed4668).(CFILEcxx . . $ CFILE# *fp, const objectcxx . . $ object# *op) {}
1300
1301 // load spew
1302 void SGSSpewcxx . . $ SGSSpew(3639e799710acb68).(CFILEcxx . . $ CFILE# *fp) {
1303 int i;
1304
1305 gs_WriteShortcxx . . $ `Descent3/gamesave.h:162:9`!(fp, (int16_t)spew_count);
1306 for (i = 0; i < MAX_SPEW_EFFECTScxx . . $ `Descent3/spew.h:131:9`!; i++) {
1307 gs_WriteBytecxx . . $ `Descent3/gamesave.h:161:9`!(fp, SpewEffects[i].inuse ? true : false);
1308 if (SpewEffectscxx . . $ SpewEffects.[i].inusecxx . . $ spewinfo#inuse.)
1309 cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)&SpewEffectscxx . . $ SpewEffects.[i], sizeof(spewinfocxx . . $ spewinfo#), fp);
1310 }
1311 }
1312
1313 // save matcens
1314 void SGSMatcenscxx . . $ SGSMatcens(3639e799710acb68).(CFILEcxx . . $ CFILE# *fp) {
1315 cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fp, Num_matcenscxx . . $ Num_matcens.);
1316
1317 for (int i = 0; i < Num_matcenscxx . . $ Num_matcens.; i++) {
1318 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Matcen[i]);
1319
1320 Matcencxx . . $ Matcen.[i]->SaveDatacxx . . $ matcen#SaveData(3639e799710acb68).(fp);
1321 }
1322 }
1323
1324 #define HUD_RENDER_ZOOMcxx . . $ `Descent3/gamesave.cpp:1324:9`! 0.56f
1325 void SGSSnapshotcxx . . $ SGSSnapshot(3639e799710acb68).(CFILEcxx . . $ CFILE# *fp) {
1326 extern void ResetFacingscxx . . $ ResetFacings(49f6e7a06ebc5aa8).(); // render.cpp
1327
1328 const int SGSSNAP_WIDTH = 160, SGSSNAP_HEIGHT = 120;
1329 int oldfilepos, bm_handle;
1330
1331 oldfilepos = cftellcxx . . $ cftell(65b457210a6528a1).(fp);
1332
1333 // Set up for rendering
1334 StartFramecxx . . $ StartFrame(3285c9bef785d51c).(0, 0, Max_window_wcxx . . $ Max_window_w., Max_window_hcxx . . $ Max_window_h.);
1335 g3_StartFramecxx . . $ g3_StartFrame(e35d136ceab5c8a2).(&Viewer_objectcxx . . $ Viewer_object.->poscxx . . $ object#pos., &Viewer_objectcxx . . $ Viewer_object.->orientcxx . . $ object#orient., HUD_RENDER_ZOOMcxx . . $ `Descent3/gamesave.cpp:1324:9`!);
1336
1337 // Reset facings for mine stuff
1338 ResetFacingscxx . . $ ResetFacings(49f6e7a06ebc5aa8).();
1339
1340 // Render the world
1341 GameRenderWorldcxx . . $ GameRenderWorld(68d409d91ffdd12f).(Viewer_objectcxx . . $ Viewer_object., &Viewer_objectcxx . . $ Viewer_object.->poscxx . . $ object#pos., Viewer_objectcxx . . $ Viewer_object.->roomnumcxx . . $ object#roomnum., &Viewer_objectcxx . . $ Viewer_object.->orientcxx . . $ object#orient., Render_zoomcxx . . $ Render_zoom.,
1342 false);
1343
1344 // Done rendering
1345 g3_EndFramecxx . . $ g3_EndFrame(49f6e7a06ebc5aa8).();
1346 EndFramecxx . . $ EndFrame(49f6e7a06ebc5aa8).();
1347 rend_Flipcxx . . $ rend_Flip(49f6e7a06ebc5aa8).();
1348 bm_handle = bm_AllocBitmapcxx . . $ bm_AllocBitmap(2326284602b0bb2d).(Max_window_wcxx . . $ Max_window_w., Max_window_hcxx . . $ Max_window_h., 0);
1349
1350 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(fp, (bm_handle > 0) ? 1 : 0);
1351
1352 if (bm_handle > 0) {
1353 // Tell our renderer lib to take a screen shot
1354 rend_Screenshotcxx . . $ rend_Screenshot(d4f767463ce0a6b3).(bm_handle);
1355 bm_ChangeSizecxx . . $ bm_ChangeSize(b1146eedae1e1d0b).(bm_handle, SGSSNAP_WIDTH, SGSSNAP_HEIGHT);
1356
1357 try {
1358 if (bm_SaveBitmapcxx . . $ bm_SaveBitmap(3041dee38160abc0).(fp, bm_handle) < 0) {
1359 cfseekcxx . . $ cfseek(f9992d249f032805).(fp, oldfilepos, SEEK_SETcxx . . $ `<external>/14710646456994434043/fcntl.h:137:10`!);
1360 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(fp, 0);
1361 }
1362 } catch (cfile_errorcxx . . $ cfile_error#) {
1363 cfseekcxx . . $ cfseek(f9992d249f032805).(fp, oldfilepos, SEEK_SETcxx . . $ `<external>/14710646456994434043/fcntl.h:137:10`!);
1364 cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(fp, 0);
1365 }
1366
1367 bm_FreeBitmapcxx . . $ bm_FreeBitmap(d4f767463ce0a6b3).(bm_handle);
1368 }
1369 }
1370
1371 //@@ switch (op->control_type)
1372 //@@ {
1373 //@@ case CT_NONE:
1374 //@@ case CT_AI:
1375 //@@ case CT_FLYING: //the player is flying
1376 //@@ case CT_FLYTHROUGH: //the flythrough system
1377 //@@ case CT_SLEW: //slewing
1378 //@@ case CT_PARTICLE: //Particle
1379 //@@ break;
1380 //@@ case CT_EXPLOSION: //explosion sequencer
1381 //@@ gs_WriteFloat(fp, op_expl->spawn_time);
1382 //@@ gs_WriteFloat(fp, op_expl->delete_time);
1383 //@@ gs_WriteShort(fp, op_expl->delete_objnum);
1384 //@@ gs_WriteShort(fp, op_expl->attach_parent);
1385 //@@ gs_WriteShort(fp, op_expl->prev_attach);
1386 //@@ gs_WriteShort(fp, op_expl->next_attach);
1387 //@@ break;
1388 //@@ case CT_DEBRIS: //this is a piece of debris
1389 //@@ gs_WriteFloat(fp, op->ctype.dying_info.delay_time);
1390 //@@ gs_WriteBool(fp, op->ctype.dying_info.f_death_anim);
1391 //@@ break;
1392 //@@ case CT_POWERUP: //animating powerup blob
1393 //@@ gs_WriteInt(fp, op->ctype.powerup_info.count);
1394 //@@ gs_WriteInt(fp, op->ctype.powerup_info.flags);
1395 //@@ break;
1396 //@@ case CT_SPLINTER: //Splinter
1397 //@@ gs_WriteByte(fp, (int8_t)op_splint->subobj_num);
1398 //@@ gs_WriteShort(fp, op_splint->facenum);
1399 //@@ for (j = 0; j < MAX_VERTS_PER_SPLINTER; j++)
1400 //@@ gs_WriteVector(fp, op_splint->verts[j]);
1401 //@@ gs_WriteVector(fp, op_splint->center);
1402 //@@ break;
1403 //@@ case CT_WEAPON: //laser, etc.
1404 //@@ gs_WriteShort(fp, op_wpn->parent_type);
1405 //@@ gs_WriteShort(fp, op_wpn->src_gun_num);
1406 //@@ gs_WriteInt(fp, op_wpn->last_hit_handle);
1407 //@@ gs_WriteInt(fp, op_wpn->track_handle);
1408 //@@ gs_WriteInt(fp, op_wpn->hit_status);
1409 //@@ gs_WriteVector(fp, op_wpn->hit_pnt);
1410 //@@ gs_WriteVector(fp, op_wpn->hit_wall_pnt);
1411 //@@ gs_WriteVector(fp, op_wpn->hit_wall_normal);
1412 //@@ gs_WriteInt(fp, op_wpn->hit_room);
1413 //@@ gs_WriteInt(fp, op_wpn->hit_pnt_room);
1414 //@@ gs_WriteShort(fp, op_wpn->hit_face);
1415 //@@ gs_WriteFloat(fp, op_wpn->multiplier);
1416 //@@ gs_WriteFloat(fp, op_wpn->thrust_left);
1417 //@@ gs_WriteFloat(fp, op_wpn->last_drop_time);
1418 //@@ break;
1419 //@@
1420 //@@ default:
1421 //@@ Int3();
1422 //@@ }
1423
1424 //@@ if (op->type == OBJ_FIREBALL) {
1425 //@@ gs_WriteFloat(fp, op->ctype.blast_info.max_size);
1426 //@@ gs_WriteInt(fp, op->ctype.blast_info.bm_handle);
1427 //@@ }
1428
1429 //@@ const int N_SHARD_VERTS = 3;
1430 //@@ switch (op->render_type)
1431 //@@ {
1432 //@@ case RT_NONE:
1433 //@@ case RT_EDITOR_SPHERE:
1434 //@@ case RT_FIREBALL:
1435 //@@ case RT_LINE:
1436 //@@ case RT_PARTICLE:
1437 //@@ case RT_SPLINTER:
1438 //@@ case RT_ROOM:
1439 //@@ break;
1440 //@@ case RT_WEAPON:
1441 //@@ if (!(op->flags & OF_POLYGON_OBJECT))
1442 //@@ break;
1443 //@@ case RT_POLYOBJ:
1444 //@@ gs_WriteShort(fp, pobji->model_num);
1445 //@@ gs_WriteShort(fp, pobji->dying_model_num);
1446 //@@ gs_WriteFloat(fp, pobji->anim_start_frame);
1447 //@@ gs_WriteFloat(fp, pobji->anim_frame);
1448 //@@ gs_WriteFloat(fp, pobji->anim_end_frame);
1449 //@@ gs_WriteFloat(fp, pobji->anim_time);
1450 //@@ gs_WriteInt(fp, (int)pobji->anim_flags);
1451 //@@ gs_WriteFloat(fp, pobji->max_speed);
1452 //@@ gs_WriteInt(fp, (int)pobji->subobj_flags);
1453 //@@ gs_WriteInt(fp, pobji->tmap_override);
1454 //@@ //!! multi_anim_save here
1455 //@@ break;
1456 //@@
1457 //@@ case RT_SHARD:
1458 //@@ for (j = 0; j < N_SHARD_VERTS; j++)
1459 //@@ gs_WriteVector(fp, op->rtype.shard_info.points[j]);
1460 //@@ for (j = 0; j < N_SHARD_VERTS; j++)
1461 //@@ gs_WriteFloat(fp, op->rtype.shard_info.u[j]);
1462 //@@ for (j = 0; j < N_SHARD_VERTS; j++)
1463 //@@ gs_WriteFloat(fp, op->rtype.shard_info.v[j]);
1464 //@@ gs_WriteVector(fp, op->rtype.shard_info.normal);
1465 //@@ gs_WriteShort(fp, op->rtype.shard_info.tmap);
1466 //@@ break;
1467 //@@
1468 //@@ default:
1469 //@@ Int3();
1470 //@@ }
1471
1472 // AI WRITES
1473 //@@// the FUN begins.
1474 //@@ gs_WriteByte(fp, ai->ai_class);
1475 //@@ gs_WriteByte(fp, ai->ai_type);
1476 //@@
1477 //@@// write path info
1478 //@@ const ai_path_info *path = &ai->path;
1479 //@@ gs_WriteInt(fp, path->flags);
1480 //@@ gs_WriteShort(fp, path->cur_path);
1481 //@@ gs_WriteShort(fp, path->cur_node);
1482 //@@ gs_WriteShort(fp, path->num_paths);
1483 //@@ gs_WriteShort(fp, path->goal_index);
1484 //@@
1485 //@@ for (i = 0; i < MAX_JOINED_PATHS; i++)
1486 //@@ {
1487 //@@ gs_WriteByte(fp, path->path_id[i]);
1488 //@@ gs_WriteByte(fp, path->path_type[i]);
1489 //@@ gs_WriteShort(fp, path->path_start_node[i]);
1490 //@@ gs_WriteShort(fp, path->path_end_node[i]);
1491 //@@ gs_WriteShort(fp, path->path_flags[i]);
1492 //@@ }
1493 //@@
1494 //@@// continue
1495 //@@ gs_WriteFloat(fp, ai->max_velocity);
1496 //@@ gs_WriteFloat(fp, ai->max_delta_velocity);
1497 //@@ gs_WriteFloat(fp, ai->max_turn_rate);
1498 //@@ gs_WriteFloat(fp, ai->max_delta_turn_rate);
1499 //@@ gs_WriteFloat(fp, ai->attack_vel_percent);
1500 //@@ gs_WriteFloat(fp, ai->flee_vel_percent);
1501 //@@ gs_WriteFloat(fp, ai->dodge_vel_percent);
1502 //@@ gs_WriteFloat(fp, ai->circle_distance);
1503 //@@ gs_WriteFloat(fp, ai->dodge_percent);
1504 //@@
1505 //@@ for (i = 0; i < 2; i++)
1506 //@@ {
1507 //@@ gs_WriteFloat(fp, ai->melee_damage[i]);
1508 //@@ gs_WriteFloat(fp, ai->melee_latency[i]);
1509 //@@ }
1510 //@@
1511 //@@ for (i = 0; i < MAX_AI_SOUNDS; i++)
1512 //@@ {
1513 //@@ gs_WriteInt(fp, ai->sound[i]);
1514 //@@ gs_WriteFloat(fp, ai->last_sound_time[i]);
1515 //@@ }
1516 //@@ gs_WriteShort(fp, ai->last_played_sound_index);
1517 //@@
1518 //@@ gs_WriteByte(fp, ai->movement_type);
1519 //@@ gs_WriteByte(fp, ai->movement_subtype);
1520 //@@ gs_WriteByte(fp, ai->animation_type);
1521 //@@ gs_WriteByte(fp, ai->next_animation_type);
1522 //@@ gs_WriteByte(fp, ai->next_movement);
1523 //@@ gs_WriteByte(fp, ai->current_wb_firing);
1524 //@@ gs_WriteByte(fp, ai->last_wb_firing);
1525 //@@
1526 //@@// goals
1527 //@@ for (i = 0;i < MAX_GOALS; i++)
1528 //@@ SGSObjAIGoal(fp, &ai->goals[i]);
1529 //@@
1530 //@@// continue
1531 //@@ gs_WriteInt(fp, ai->target_handle);
1532 //@@ gs_WriteFloat(fp, ai->next_target_update_time);
1533 //@@ gs_WriteFloat(fp, ai->dist_to_target);
1534 //@@ gs_WriteVector(fp, ai->vec_to_target);
1535 //@@ gs_WriteFloat(fp, ai->last_check_see_target_time);
1536 //@@ gs_WriteVector(fp, ai->last_see_target_pos);
1537 //@@ gs_WriteFloat(fp, ai->last_see_target_time);
1538 //@@ gs_WriteFloat(fp, ai->weapon_speed);
1539 //@@ gs_WriteFloat(fp, ai->next_melee_time);
1540 //@@ gs_WriteFloat(fp, ai->last_render_time);
1541 //@@ gs_WriteFloat(fp, ai->next_flinch_time);
1542 //@@ gs_WriteInt(fp, ai->status_reg);
1543 //@@ gs_WriteInt(fp, ai->flags);
1544 //@@ gs_WriteInt(fp, ai->notify_flags);
1545 //@@
1546 //@@// notify events (MUST BE WRITTEN OUT AT A LATER DATE)
1547 //@@
1548 //@@// Normalized movement and facing information
1549 //@@ gs_WriteVector(fp, ai->movement_dir);
1550 //@@ gs_WriteVector(fp, ai->rot_thrust_vector);
1551 //@@ gs_WriteFloat(fp, ai->fov);
1552 //@@ gs_WriteInt(fp, ai->anim_sound_handle);
1553 //@@ gs_WriteFloat(fp, ai->frustration);
1554 //@@ gs_WriteFloat(fp, ai->curiousity);
1555 //@@ gs_WriteFloat(fp, ai->fire_spread);
1556 //@@ gs_WriteFloat(fp, ai->agression);
1557 //@@ gs_WriteFloat(fp, ai->night_vision);
1558 //@@ gs_WriteFloat(fp, ai->fog_vision);
1559 //@@ gs_WriteFloat(fp, ai->lead_accuracy);
1560 //@@ gs_WriteFloat(fp, ai->lead_varience);
1561 //@@ gs_WriteFloat(fp, ai->fight_team);
1562 //@@ gs_WriteFloat(fp, ai->fight_same);
1563 //@@ gs_WriteFloat(fp, ai->hearing);
1564 //@@ gs_WriteFloat(fp, ai->roaming);
1565 //@@ gs_WriteFloat(fp, ai->life_preservation);
1566 //@@
1567 //@@ gs_WriteShort(fp, ai->awareness);
1568
1569 //@@void SGSObjAIGoal(CFILE *fp, const goal *g)
1570 //@@{
1571 //@@ int i;
1572 //@@
1573 //@@ gs_WriteByte(fp, (g->used ? 1 : 0));
1574 //@@ if (!g->used)
1575 //@@ return;
1576 //@@
1577 //@@ gs_WriteInt(fp, g->type);
1578 //@@ gs_WriteByte(fp, g->activation_level);
1579 //@@ gs_WriteShort(fp, g->influence);
1580 //@@
1581 //@@// write goal info
1582 //@@ switch (g->type)
1583 //@@ {
1584 //@@ case AIG_HIDE_FROM_OBJ:
1585 //@@ gs_WriteInt(fp, g->g_info.handle);
1586 //@@ gs_WriteFloat(fp, g->g_info.time);
1587 //@@ break;
1588 //@@
1589 //@@ case AIG_WANDER_AROUND:
1590 //@@ gs_WriteInt(fp, g->g_info.roomnum);
1591 //@@ break;
1592 //@@
1593 //@@ case AIG_DODGE_OBJ:
1594 //@@ case AIG_MOVE_RELATIVE_OBJ:
1595 //@@ gs_WriteInt(fp, g->g_info.handle);
1596 //@@ break;
1597 //@@
1598 //@@ case AIG_MOVE_RELATIVE_OBJ_VEC:
1599 //@@ gs_WriteInt(fp, g->g_info.handle);
1600 //@@ gs_WriteInt(fp, g->g_info.subtype);
1601 //@@ break;
1602 //@@
1603 //@@ case AIG_GUARD_AREA:
1604 //@@ gs_WriteVector(fp, g->g_info.pos);
1605 //@@ break;
1606 //@@
1607 //@@ case AIG_GET_TO_OBJ:
1608 //@@ gs_WriteInt(fp, g->g_info.handle);
1609 //@@ gs_WriteVector(fp, g->g_info.pos);
1610 //@@ break;
1611 //@@
1612 //@@ case AIG_GET_TO_POS:
1613 //@@ gs_WriteInt(fp, g->g_info.roomnum);
1614 //@@ gs_WriteVector(fp, g->g_info.pos);
1615 //@@ break;
1616 //@@
1617 //@@ case AIG_FOLLOW_PATH: // This must be fixed -- chrishack
1618 //@@ gs_WriteInt(fp, g->g_info.id);
1619 //@@ break;
1620 //@@ }
1621 //@@
1622 //@@// write goal enabler
1623 //@@ gs_WriteByte(fp, g->num_enablers);
1624 //@@ for (i = 0; i < g->num_enablers; i++)
1625 //@@ {
1626 //@@ gs_WriteByte(fp, g->enabler[i].enabler_type);
1627 //@@
1628 //@@ switch (g->enabler[i].enabler_type)
1629 //@@ {
1630 //@@ case AIE_AI_STATUS_FLAG:
1631 //@@ gs_WriteInt(fp, g->enabler[i].flags);
1632 //@@ break;
1633 //@@ }
1634 //@@
1635 //@@ gs_WriteFloat(fp, g->enabler[i].percent_enable);
1636 //@@ gs_WriteFloat(fp, g->enabler[i].check_interval);
1637 //@@ gs_WriteFloat(fp, g->enabler[i].last_check_time);
1638 //@@ gs_WriteByte(fp, g->enabler[i].bool_next_enabler_op);
1639 //@@ }
1640 //@@
1641 //@@// continue
1642 //@@ gs_WriteFloat(fp, g->circle_distance);
1643 //@@ gs_WriteInt(fp, g->status_reg);
1644 //@@ gs_WriteFloat(fp, g->start_time);
1645 //@@ gs_WriteFloat(fp, g->next_path_time);
1646 //@@ gs_WriteFloat(fp, g->dist_to_goal);
1647 //@@ gs_WriteVector(fp, g->vec_to_target);
1648 //@@ gs_WriteFloat(fp, g->last_check_see_target_time);
1649 //@@ gs_WriteVector(fp, g->last_see_target_pos);
1650 //@@ gs_WriteFloat(fp, g->last_see_target_time);
1651 //@@ gs_WriteFloat(fp, g->next_target_update_time);
1652 //@@ gs_WriteShort(fp, g->flags);
1653 //@@}
1654 //@@
1655
1656 // EFFECTS INFO STRUCTURE
1657 //@@ gs_WriteInt(fp, ei->type_flags);
1658 //@@ gs_WriteFloat(fp, ei->alpha);
1659 //@@
1660 //@@// if (op->type == OBJ_POWERUP) {
1661 //@@ gs_WriteFloat(fp, ei->last_object_hit_time);
1662 //@@ gs_WriteInt(fp, ei->last_object_hit);
1663 //@@// }
1664 //@@// if (ei->type_flags & EF_DEFORM) {
1665 //@@ gs_WriteFloat(fp, ei->deform_range);
1666 //@@ gs_WriteFloat(fp, ei->deform_time);
1667 //@@// }
1668 //@@// if (ei->type_flags & EF_VOLUME_CHANGING) {
1669 //@@ gs_WriteFloat(fp, ei->volume_change_time);
1670 //@@ gs_WriteVector(fp, ei->volume_old_pos);
1671 //@@ gs_WriteFloat(fp, ei->volume_old_room);
1672 //@@// }
1673 //@@// if (ei->type_flags & EF_VOLUME_LIT) {
1674 //@@ gs_WriteByte(fp, (int8_t)ei->dynamic_this_frame);
1675 //@@ gs_WriteFloat(fp, ei->dynamic_red);
1676 //@@ gs_WriteFloat(fp, ei->dynamic_green);
1677 //@@ gs_WriteFloat(fp, ei->dynamic_blue);
1678 //@@// }
1679 //@@// if (ei->type_flags & EF_CLOAKED) {
1680 //@@ gs_WriteFloat(fp, ei->cloak_time);
1681 //@@// }
1682 //@@// if (ei->type_flags & EF_COLORED) {
1683 //@@ gs_WriteFloat(fp, ei->color_time);
1684 //@@ gs_WriteFloat(fp, ei->r);
1685 //@@ gs_WriteFloat(fp, ei->g);
1686 //@@ gs_WriteFloat(fp, ei->b);
1687 //@@// }
1688 //@@// if (ei->type_flags & EF_NAPALMED) {
1689 //@@ gs_WriteFloat(fp, ei->damage_time);
1690 //@@ gs_WriteFloat(fp, ei->damage_per_second);
1691 //@@ gs_WriteFloat(fp, ei->last_damage_time);
1692 //@@ gs_WriteInt(fp, ei->damage_handle);
1693 //@@// }
1694 //@@// if (ei->type_flags & EF_FREEZE) {
1695 //@@ gs_WriteFloat(fp, ei->freeze_scalar);
1696 //@@// }
1697 //@@// if (ei->type_flags & EF_LINE_ATTACH) {
1698 //@@ gs_WriteInt(fp, ei->attach_line_handle);
1699 //@@// }
1700
1701 // Weapon Battery Info
1702 //@@ gs_WriteFloat(fp, dwb->last_fire_time);
1703 //@@ gs_WriteByte(fp, dwb->cur_firing_mask);
1704 //@@
1705 //@@ for (j = 0; j < MAX_WB_TURRETS; j++)
1706 //@@ {
1707 //@@ gs_WriteFloat(fp, dwb->norm_turret_angle[j]);
1708 //@@ gs_WriteFloat(fp, dwb->turret_next_think_time[j]);
1709 //@@ gs_WriteByte(fp, dwb->turret_direction[j]);
1710 //@@ }
1711 //@@
1712 //@@ gs_WriteByte(fp, dwb->wb_anim_mask);
1713 //@@ gs_WriteFloat(fp, dwb->wb_anim_frame);
1714 //@@ gs_WriteVector(fp, dwb->cur_target);
1715 //@@ gs_WriteByte(fp, dwb->upgrade_level);
1716 //@@ gs_WriteInt(fp, dwb->flags);