SaveGame.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code 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. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. 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.
  17. 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.
  18. ===========================================================================
  19. */
  20. #ifndef __SAVEGAME_H__
  21. #define __SAVEGAME_H__
  22. /*
  23. Save game related helper classes.
  24. */
  25. const int INITIAL_RELEASE_BUILD_NUMBER = 1262;
  26. class idSaveGame {
  27. public:
  28. idSaveGame( idFile *savefile );
  29. ~idSaveGame();
  30. void Close( void );
  31. void AddObject( const idClass *obj );
  32. void WriteObjectList( void );
  33. void Write( const void *buffer, int len );
  34. void WriteInt( const int value );
  35. void WriteJoint( const jointHandle_t value );
  36. void WriteShort( const short value );
  37. void WriteByte( const byte value );
  38. void WriteSignedChar( const signed char value );
  39. void WriteFloat( const float value );
  40. void WriteBool( const bool value );
  41. void WriteString( const char *string );
  42. void WriteVec2( const idVec2 &vec );
  43. void WriteVec3( const idVec3 &vec );
  44. void WriteVec4( const idVec4 &vec );
  45. void WriteVec6( const idVec6 &vec );
  46. void WriteWinding( const idWinding &winding );
  47. void WriteBounds( const idBounds &bounds );
  48. void WriteMat3( const idMat3 &mat );
  49. void WriteAngles( const idAngles &angles );
  50. void WriteObject( const idClass *obj );
  51. void WriteStaticObject( const idClass &obj );
  52. void WriteDict( const idDict *dict );
  53. void WriteMaterial( const idMaterial *material );
  54. void WriteSkin( const idDeclSkin *skin );
  55. void WriteParticle( const idDeclParticle *particle );
  56. void WriteFX( const idDeclFX *fx );
  57. void WriteSoundShader( const idSoundShader *shader );
  58. void WriteModelDef( const class idDeclModelDef *modelDef );
  59. void WriteModel( const idRenderModel *model );
  60. void WriteUserInterface( const idUserInterface *ui, bool unique );
  61. void WriteRenderEntity( const renderEntity_t &renderEntity );
  62. void WriteRenderLight( const renderLight_t &renderLight );
  63. void WriteRefSound( const refSound_t &refSound );
  64. void WriteRenderView( const renderView_t &view );
  65. void WriteUsercmd( const usercmd_t &usercmd );
  66. void WriteContactInfo( const contactInfo_t &contactInfo );
  67. void WriteTrace( const trace_t &trace );
  68. void WriteTraceModel( const idTraceModel &trace );
  69. void WriteClipModel( const class idClipModel *clipModel );
  70. void WriteSoundCommands( void );
  71. void WriteBuildNumber( const int value );
  72. private:
  73. idFile * file;
  74. idList<const idClass *> objects;
  75. void CallSave_r( const idTypeInfo *cls, const idClass *obj );
  76. };
  77. class idRestoreGame {
  78. public:
  79. idRestoreGame( idFile *savefile );
  80. ~idRestoreGame();
  81. void CreateObjects( void );
  82. void RestoreObjects( void );
  83. void DeleteObjects( void );
  84. void Error( const char *fmt, ... ) id_attribute((format(printf,2,3)));
  85. void Read( void *buffer, int len );
  86. void ReadInt( int &value );
  87. void ReadJoint( jointHandle_t &value );
  88. void ReadShort( short &value );
  89. void ReadByte( byte &value );
  90. void ReadSignedChar( signed char &value );
  91. void ReadFloat( float &value );
  92. void ReadBool( bool &value );
  93. void ReadString( idStr &string );
  94. void ReadVec2( idVec2 &vec );
  95. void ReadVec3( idVec3 &vec );
  96. void ReadVec4( idVec4 &vec );
  97. void ReadVec6( idVec6 &vec );
  98. void ReadWinding( idWinding &winding );
  99. void ReadBounds( idBounds &bounds );
  100. void ReadMat3( idMat3 &mat );
  101. void ReadAngles( idAngles &angles );
  102. void ReadObject( idClass *&obj );
  103. void ReadStaticObject( idClass &obj );
  104. void ReadDict( idDict *dict );
  105. void ReadMaterial( const idMaterial *&material );
  106. void ReadSkin( const idDeclSkin *&skin );
  107. void ReadParticle( const idDeclParticle *&particle );
  108. void ReadFX( const idDeclFX *&fx );
  109. void ReadSoundShader( const idSoundShader *&shader );
  110. void ReadModelDef( const idDeclModelDef *&modelDef );
  111. void ReadModel( idRenderModel *&model );
  112. void ReadUserInterface( idUserInterface *&ui );
  113. void ReadRenderEntity( renderEntity_t &renderEntity );
  114. void ReadRenderLight( renderLight_t &renderLight );
  115. void ReadRefSound( refSound_t &refSound );
  116. void ReadRenderView( renderView_t &view );
  117. void ReadUsercmd( usercmd_t &usercmd );
  118. void ReadContactInfo( contactInfo_t &contactInfo );
  119. void ReadTrace( trace_t &trace );
  120. void ReadTraceModel( idTraceModel &trace );
  121. void ReadClipModel( idClipModel *&clipModel );
  122. void ReadSoundCommands( void );
  123. void ReadBuildNumber( void );
  124. // Used to retrieve the saved game buildNumber from within class Restore methods
  125. int GetBuildNumber( void );
  126. private:
  127. int buildNumber;
  128. idFile * file;
  129. idList<idClass *> objects;
  130. void CallRestore_r( const idTypeInfo *cls, idClass *obj );
  131. };
  132. #endif /* !__SAVEGAME_H__*/