Debian Codegraph @

prboom2/src/p_saveg.h

raw
1 /* Emacs style mode select -*- C -*-
2 *-----------------------------------------------------------------------------
3 *
4 *
5 * PrBoom: a Doom port merged with LxDoom and LSDLDoom
6 * based on BOOM, a modified and improved DOOM engine
7 * Copyright (C) 1999 by
8 * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
9 * Copyright (C) 1999-2000 by
10 * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
11 * Copyright 2005, 2006 by
12 * Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 * 02111-1307, USA.
28 *
29 * DESCRIPTION:
30 * Savegame I/O, archiving, persistence.
31 *
32 *-----------------------------------------------------------------------------*/
33
34 #ifndef __P_SAVEG__
35 #define __P_SAVEG__
36
37 #include "doomtype.h"
38
39 #define SAVEVERSION 6
40
41 /* Persistent storage/archiving.
42 * These are the load / save game routines. */
43 void P_ArchivePlayers(void);
44 void P_UnArchivePlayers(void);
45 void P_ArchiveWorld(void);
46 void P_UnArchiveWorld(void);
47 void P_ThinkerToIndex(void); /* phares 9/13/98: save soundtarget in savegame */
48 void P_IndexToThinker(void); /* phares 9/13/98: save soundtarget in savegame */
49
50 /* 1/18/98 killough: add RNG info to savegame */
51 void P_ArchiveRNG(void);
52 void P_UnArchiveRNG(void);
53
54 /* 2/21/98 killough: add automap info to savegame */
55 void P_ArchiveMap(void);
56 void P_UnArchiveMap(void);
57
58 // dsda - fix save / load synchronization
59 void P_ArchiveThinkers(void);
60 void P_UnArchiveThinkers(void);
61
62 extern byte *save_p;
63 extern byte* savebuffer;
64
65 void CheckSaveGame(size_t size);
66 void P_InitSaveBuffer(void);
67 void P_ForgetSaveBuffer(void);
68 void P_FreeSaveBuffer(void);
69
70 #define P_SAVE_X(x) { CheckSaveGame(sizeof(x)); \
71 memcpy(save_p, &x, sizeof(x)); \
72 save_p += sizeof(x); }
73
74 #define P_LOAD_X(x) { memcpy(&x, save_p, sizeof(x)); \
75 save_p += sizeof(x); }
76
77 #define P_SAVE_SIZE(x, size) { CheckSaveGame(size); \
78 memcpy(save_p, x, size); \
79 save_p += size; }
80
81 #define P_LOAD_SIZE(x, size) { memcpy(x, save_p, size); \
82 save_p += size; }
83
84 #define P_SAVE_TYPE(x, type) { CheckSaveGame(sizeof(type)); \
85 memcpy(save_p, x, sizeof(type)); \
86 save_p += sizeof(type); }
87
88 #define P_SAVE_TYPE_REF(x, ref, type) { CheckSaveGame(sizeof(type)); \
89 ref = (type *) save_p; \
90 memcpy(save_p, x, sizeof(type)); \
91 save_p += sizeof(type); }
92
93 #define P_LOAD_P(p) { memcpy(p, save_p, sizeof(*p)); \
94 save_p += sizeof(*p); }
95
96 #define P_SAVE_BYTE(x) { CheckSaveGame(1); \
97 *save_p++ = x; }
98
99 #define P_LOAD_BYTE(x) { x = *save_p++; }
100
101 #define P_SAVE_ARRAY(x) { CheckSaveGame(sizeof(x)); \
102 memcpy(save_p, x, sizeof(x)); \
103 save_p += sizeof(x); }
104
105 #define P_LOAD_ARRAY(x) { memcpy(x, save_p, sizeof(x)); \
106 save_p += sizeof(x); }
107
108 // heretic
109
110 void P_ArchiveAmbientSound(void);
111 void P_UnArchiveAmbientSound(void);
112
113 // hexen
114
115 void P_ArchiveACS(void);
116 void P_UnArchiveACS(void);
117 void P_ArchivePolyobjs(void);
118 void P_UnArchivePolyobjs(void);
119 void P_ArchiveScripts(void);
120 void P_UnArchiveScripts(void);
121 void P_ArchiveSounds(void);
122 void P_UnArchiveSounds(void);
123 void P_ArchiveMisc(void);
124 void P_UnArchiveMisc(void);
125
126 #endif