/
p_saveio.h
118 lines (91 loc) · 2.91 KB
/
p_saveio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/** @file p_saveio.h Game save file IO.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2005-2013 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/
#ifndef LIBCOMMON_SAVESTATE_INPUT_OUTPUT_H
#define LIBCOMMON_SAVESTATE_INPUT_OUTPUT_H
#include "api_materialarchive.h"
#include "p_savedef.h"
#include <de/Path>
#include "lzss.h"
typedef enum savestatesegment_e {
ASEG_MAP_HEADER = 102, // Hexen only
ASEG_MAP_ELEMENTS,
ASEG_POLYOBJS, // Hexen only
ASEG_MOBJS, // Hexen < ver 4 only
ASEG_THINKERS,
ASEG_SCRIPTS, // Hexen only
ASEG_PLAYERS,
ASEG_SOUNDS, // Hexen only
ASEG_MISC, // Hexen only
ASEG_END, // = 111
ASEG_MATERIAL_ARCHIVE,
ASEG_MAP_HEADER2,
ASEG_PLAYER_HEADER,
ASEG_WORLDSCRIPTDATA // Hexen only
} savestatesegment_t;
#if __JHEXEN__
typedef union saveptr_u {
byte *b;
short *w;
int *l;
float *f;
} saveptr_t;
#endif
void SV_InitIO();
void SV_ShutdownIO();
/**
* Create the saved game directories.
*/
void SV_SetupSaveDirectory(de::Path);
de::Path SV_SavePath();
#if !__JHEXEN__
de::Path SV_ClientSavePath();
#endif
/*
* File management
*/
bool SV_ExistingFile(de::Path filePath);
int SV_RemoveFile(de::Path filePath);
void SV_CopyFile(de::Path srcFilePath, de::Path destFilePath);
bool SV_OpenFile(de::Path filePath, bool write);
void SV_CloseFile();
#if __JHEXEN__
saveptr_t *SV_HxSavePtr();
void SV_HxSetSaveEndPtr(void *endPtr);
size_t SV_HxBytesLeft();
void SV_HxReleaseSaveBuffer();
#endif // __JHEXEN__
/**
* Exit with a fatal error if the value at the current location in the
* game-save file does not match that associated with the segment id.
*
* @param segmentId Identifier of the segment to check alignment of.
*/
void SV_AssertSegment(int segmentId);
void SV_BeginSegment(int segmentId);
void SV_EndSegment();
void SV_WriteConsistencyBytes();
void SV_ReadConsistencyBytes();
/**
* Seek forward @a offset bytes in the save file.
*/
void SV_Seek(uint offset);
Writer *SV_NewWriter();
Reader *SV_NewReader();
#endif // LIBCOMMON_SAVESTATE_INPUT_OUTPUT_H