doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SaveGame.h
Go to the documentation of this file.
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 
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:
93 
95 
96  void CallSave_r( const idTypeInfo *cls, const idClass *obj );
97 };
98 
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:
156 
158 
160 
161  void CallRestore_r( const idTypeInfo *cls, idClass *obj );
162 };
163 
164 #endif /* !__SAVEGAME_H__*/
void ReadContactInfo(contactInfo_t &contactInfo)
Definition: SaveGame.cpp:1452
void WriteBuildNumber(const int value)
Definition: SaveGame.cpp:767
jointHandle_t
Definition: Model.h:156
void ReadSignedChar(signed char &value)
Definition: SaveGame.cpp:958
void WriteTrace(const trace_t &trace)
Definition: SaveGame.cpp:694
GLsizei const GLfloat * value
Definition: glext.h:3614
void WriteString(const char *string)
Definition: SaveGame.cpp:231
void ReadSoundCommands(void)
Definition: SaveGame.cpp:1536
void ReadSoundShader(const idSoundShader *&shader)
Definition: SaveGame.cpp:1196
void CreateObjects(void)
Definition: SaveGame.cpp:799
void ReadParticle(const idDeclParticle *&particle)
Definition: SaveGame.cpp:1164
void ReadVec2(idVec2 &vec)
Definition: SaveGame.cpp:1002
void ReadMaterial(const idMaterial *&material)
Definition: SaveGame.cpp:1132
void WriteObject(const idClass *obj)
Definition: SaveGame.cpp:329
idList< const idClass * > objects
Definition: SaveGame.h:94
GLenum GLsizei GLenum format
Definition: glext.h:2846
idFile * file
Definition: SaveGame.h:157
void ReadDict(idDict *dict)
Definition: SaveGame.cpp:1107
void WriteSkin(const idDeclSkin *skin)
Definition: SaveGame.cpp:393
void WriteModel(const idRenderModel *model)
Definition: SaveGame.cpp:461
void Write(const void *buffer, int len)
Definition: SaveGame.cpp:159
void WriteVec4(const idVec4 &vec)
Definition: SaveGame.cpp:262
void ReadWinding(idWinding &winding)
Definition: SaveGame.cpp:1048
void ReadFX(const idDeclFX *&fx)
Definition: SaveGame.cpp:1180
Definition: Vector.h:316
void ReadJoint(jointHandle_t &value)
Definition: SaveGame.cpp:931
void ReadBool(bool &value)
Definition: SaveGame.cpp:976
void Close(void)
Definition: SaveGame.cpp:93
void WriteStaticObject(const idClass &obj)
Definition: SaveGame.cpp:348
idFile * file
Definition: SaveGame.h:92
void ReadTraceModel(idTraceModel &trace)
Definition: SaveGame.cpp:1482
void ReadBuildNumber(void)
Definition: SaveGame.cpp:1546
GLenum GLsizei len
Definition: glext.h:3472
GLhandleARB obj
Definition: glext.h:3602
void WriteClipModel(const class idClipModel *clipModel)
Definition: SaveGame.cpp:744
void ReadUsercmd(usercmd_t &usercmd)
Definition: SaveGame.cpp:1429
void ReadModel(idRenderModel *&model)
Definition: SaveGame.cpp:1228
void WriteVec3(const idVec3 &vec)
Definition: SaveGame.cpp:253
void ReadRenderEntity(renderEntity_t &renderEntity)
Definition: SaveGame.cpp:1269
void ReadVec6(idVec6 &vec)
Definition: SaveGame.cpp:1029
void WriteSoundShader(const idSoundShader *shader)
Definition: SaveGame.cpp:445
void WriteMaterial(const idMaterial *material)
Definition: SaveGame.cpp:380
Definition: Class.h:174
void CallSave_r(const idTypeInfo *cls, const idClass *obj)
Definition: SaveGame.cpp:133
void WriteJoint(const jointHandle_t value)
Definition: SaveGame.cpp:177
void WriteBool(const bool value)
Definition: SaveGame.cpp:222
void WriteUsercmd(const usercmd_t &usercmd)
Definition: SaveGame.cpp:653
void WriteSignedChar(const signed char value)
Definition: SaveGame.cpp:204
Definition: File.h:50
void ReadTrace(trace_t &trace)
Definition: SaveGame.cpp:1470
void WriteShort(const short value)
Definition: SaveGame.cpp:186
const int INITIAL_RELEASE_BUILD_NUMBER
Definition: SaveGame.h:38
Definition: Vector.h:52
void WriteWinding(const idWinding &winding)
Definition: SaveGame.cpp:291
void ReadFloat(float &value)
Definition: SaveGame.cpp:967
Definition: Vector.h:808
void ReadRenderLight(renderLight_t &renderLight)
Definition: SaveGame.cpp:1333
void void Read(void *buffer, int len)
Definition: SaveGame.cpp:913
void WriteFloat(const float value)
Definition: SaveGame.cpp:213
Definition: Dict.h:65
void ReadModelDef(const idDeclModelDef *&modelDef)
Definition: SaveGame.cpp:1212
GLuint buffer
Definition: glext.h:3108
void WriteVec6(const idVec6 &vec)
Definition: SaveGame.cpp:271
void ReadVec4(idVec4 &vec)
Definition: SaveGame.cpp:1020
void ReadUserInterface(idUserInterface *&ui)
Definition: SaveGame.cpp:1244
void CallRestore_r(const idTypeInfo *cls, idClass *obj)
Definition: SaveGame.cpp:896
void WriteObjectList(void)
Definition: SaveGame.cpp:119
void ReadRefSound(refSound_t &refSound)
Definition: SaveGame.cpp:1377
void WriteRenderEntity(const renderEntity_t &renderEntity)
Definition: SaveGame.cpp:497
int GetBuildNumber(void)
Definition: SaveGame.cpp:1555
void Error(const char *fmt,...) id_attribute((format(printf
Definition: SaveGame.cpp:878
void ReadBounds(idBounds &bounds)
Definition: SaveGame.cpp:1038
idSaveGame(idFile *savefile)
Definition: SaveGame.cpp:68
void WriteInt(const int value)
Definition: SaveGame.cpp:168
void WriteRenderView(const renderView_t &view)
Definition: SaveGame.cpp:625
void WriteMat3(const idMat3 &mat)
Definition: SaveGame.cpp:309
void ReadMat3(idMat3 &mat)
Definition: SaveGame.cpp:1064
void WriteDict(const idDict *dict)
Definition: SaveGame.cpp:357
int buildNumber
Definition: SaveGame.h:155
void ReadStaticObject(idClass &obj)
Definition: SaveGame.cpp:1098
void ReadClipModel(idClipModel *&clipModel)
Definition: SaveGame.cpp:1519
Definition: Matrix.h:333
#define id_attribute(x)
Definition: sys_public.h:139
void WriteAngles(const idAngles &angles)
Definition: SaveGame.cpp:318
idList< idClass * > objects
Definition: SaveGame.h:159
unsigned char byte
Definition: Lib.h:75
void ReadShort(short &value)
Definition: SaveGame.cpp:940
void WriteRefSound(const refSound_t &refSound)
Definition: SaveGame.cpp:600
void WriteFX(const idDeclFX *fx)
Definition: SaveGame.cpp:419
Definition: Str.h:116
void WriteTraceModel(const idTraceModel &trace)
Definition: SaveGame.cpp:706
void ReadRenderView(renderView_t &view)
Definition: SaveGame.cpp:1401
void WriteVec2(const idVec2 &vec)
Definition: SaveGame.cpp:244
void WriteByte(const byte value)
Definition: SaveGame.cpp:195
void ReadVec3(idVec3 &vec)
Definition: SaveGame.cpp:1011
void WriteContactInfo(const contactInfo_t &contactInfo)
Definition: SaveGame.cpp:676
void RestoreObjects(void)
Definition: SaveGame.cpp:829
void ReadAngles(idAngles &angles)
Definition: SaveGame.cpp:1073
void WriteBounds(const idBounds &bounds)
Definition: SaveGame.cpp:280
void AddObject(const idClass *obj)
Definition: SaveGame.cpp:150
void WriteSoundCommands(void)
Definition: SaveGame.cpp:758
void WriteModelDef(const class idDeclModelDef *modelDef)
Definition: SaveGame.cpp:432
idRestoreGame(idFile *savefile)
Definition: SaveGame.cpp:782
void WriteParticle(const idDeclParticle *particle)
Definition: SaveGame.cpp:406
void ReadString(idStr &string)
Definition: SaveGame.cpp:985
void WriteRenderLight(const renderLight_t &renderLight)
Definition: SaveGame.cpp:555
void ReadInt(int &value)
Definition: SaveGame.cpp:922
void WriteUserInterface(const idUserInterface *ui, bool unique)
Definition: SaveGame.cpp:477
void ReadSkin(const idDeclSkin *&skin)
Definition: SaveGame.cpp:1148
void ReadByte(byte &value)
Definition: SaveGame.cpp:949
void ReadObject(idClass *&obj)
Definition: SaveGame.cpp:1083
void DeleteObjects(void)
Definition: SaveGame.cpp:865