]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/d3xp/gamesys/SaveGame.h
hello world
[icculus/iodoom3.git] / neo / d3xp / gamesys / SaveGame.h
1 /*
2 ===========================================================================
3
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. 
6
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).  
8
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code.  If not, see <http://www.gnu.org/licenses/>.
21
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code.  If not, please request a copy in writing from id Software at the address below.
23
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25
26 ===========================================================================
27 */
28
29 #ifndef __SAVEGAME_H__
30 #define __SAVEGAME_H__
31
32 /*
33
34 Save game related helper classes.
35
36 */
37
38 const int INITIAL_RELEASE_BUILD_NUMBER = 1262;
39
40 class idSaveGame {
41 public:
42                                                         idSaveGame( idFile *savefile );
43                                                         ~idSaveGame();
44
45         void                                    Close( void );
46
47         void                                    AddObject( const idClass *obj );
48         void                                    WriteObjectList( void );
49
50         void                                    Write( const void *buffer, int len );
51         void                                    WriteInt( const int value );
52         void                                    WriteJoint( const jointHandle_t value );
53         void                                    WriteShort( const short value );
54         void                                    WriteByte( const byte value );
55         void                                    WriteSignedChar( const signed char value );
56         void                                    WriteFloat( const float value );
57         void                                    WriteBool( const bool value );
58         void                                    WriteString( const char *string );
59         void                                    WriteVec2( const idVec2 &vec );
60         void                                    WriteVec3( const idVec3 &vec );
61         void                                    WriteVec4( const idVec4 &vec );
62         void                                    WriteVec6( const idVec6 &vec );
63         void                                    WriteWinding( const idWinding &winding );
64         void                                    WriteBounds( const idBounds &bounds );
65         void                                    WriteMat3( const idMat3 &mat );
66         void                                    WriteAngles( const idAngles &angles );
67         void                                    WriteObject( const idClass *obj );
68         void                                    WriteStaticObject( const idClass &obj );
69         void                                    WriteDict( const idDict *dict );
70         void                                    WriteMaterial( const idMaterial *material );
71         void                                    WriteSkin( const idDeclSkin *skin );
72         void                                    WriteParticle( const idDeclParticle *particle );
73         void                                    WriteFX( const idDeclFX *fx );
74         void                                    WriteSoundShader( const idSoundShader *shader );
75         void                                    WriteModelDef( const class idDeclModelDef *modelDef );
76         void                                    WriteModel( const idRenderModel *model );
77         void                                    WriteUserInterface( const idUserInterface *ui, bool unique );
78         void                                    WriteRenderEntity( const renderEntity_t &renderEntity );
79         void                                    WriteRenderLight( const renderLight_t &renderLight );
80         void                                    WriteRefSound( const refSound_t &refSound );
81         void                                    WriteRenderView( const renderView_t &view );
82         void                                    WriteUsercmd( const usercmd_t &usercmd );
83         void                                    WriteContactInfo( const contactInfo_t &contactInfo );
84         void                                    WriteTrace( const trace_t &trace );
85         void                                    WriteTraceModel( const idTraceModel &trace );
86         void                                    WriteClipModel( const class idClipModel *clipModel );
87         void                                    WriteSoundCommands( void );
88
89         void                                    WriteBuildNumber( const int value );
90
91 private:
92         idFile *                                file;
93
94         idList<const idClass *> objects;
95
96         void                                    CallSave_r( const idTypeInfo *cls, const idClass *obj );
97 };
98
99 class idRestoreGame {
100 public:
101                                                         idRestoreGame( idFile *savefile );
102                                                         ~idRestoreGame();
103
104         void                                    CreateObjects( void );
105         void                                    RestoreObjects( void );
106         void                                    DeleteObjects( void );
107
108         void                                    Error( const char *fmt, ... ) id_attribute((format(printf,2,3)));
109
110         void                                    Read( void *buffer, int len );
111         void                                    ReadInt( int &value );
112         void                                    ReadJoint( jointHandle_t &value );
113         void                                    ReadShort( short &value );
114         void                                    ReadByte( byte &value );
115         void                                    ReadSignedChar( signed char &value );
116         void                                    ReadFloat( float &value );
117         void                                    ReadBool( bool &value );
118         void                                    ReadString( idStr &string );
119         void                                    ReadVec2( idVec2 &vec );
120         void                                    ReadVec3( idVec3 &vec );
121         void                                    ReadVec4( idVec4 &vec );
122         void                                    ReadVec6( idVec6 &vec );
123         void                                    ReadWinding( idWinding &winding );
124         void                                    ReadBounds( idBounds &bounds );
125         void                                    ReadMat3( idMat3 &mat );
126         void                                    ReadAngles( idAngles &angles );
127         void                                    ReadObject( idClass *&obj );
128         void                                    ReadStaticObject( idClass &obj );
129         void                                    ReadDict( idDict *dict );
130         void                                    ReadMaterial( const idMaterial *&material );
131         void                                    ReadSkin( const idDeclSkin *&skin );
132         void                                    ReadParticle( const idDeclParticle *&particle );
133         void                                    ReadFX( const idDeclFX *&fx );
134         void                                    ReadSoundShader( const idSoundShader *&shader );
135         void                                    ReadModelDef( const idDeclModelDef *&modelDef );
136         void                                    ReadModel( idRenderModel *&model );
137         void                                    ReadUserInterface( idUserInterface *&ui );
138         void                                    ReadRenderEntity( renderEntity_t &renderEntity );
139         void                                    ReadRenderLight( renderLight_t &renderLight );
140         void                                    ReadRefSound( refSound_t &refSound );
141         void                                    ReadRenderView( renderView_t &view );
142         void                                    ReadUsercmd( usercmd_t &usercmd );
143         void                                    ReadContactInfo( contactInfo_t &contactInfo );
144         void                                    ReadTrace( trace_t &trace );
145         void                                    ReadTraceModel( idTraceModel &trace );
146         void                                    ReadClipModel( idClipModel *&clipModel );
147         void                                    ReadSoundCommands( void );
148
149         void                                    ReadBuildNumber( void );
150
151         //                                              Used to retrieve the saved game buildNumber from within class Restore methods
152         int                                             GetBuildNumber( void );
153
154 private:
155         int                                             buildNumber;
156
157         idFile *                                file;
158
159         idList<idClass *>               objects;
160
161         void                                    CallRestore_r( const idTypeInfo *cls, idClass *obj );
162 };
163
164 #endif /* !__SAVEGAME_H__*/