mirror of
https://github.com/dhewm/dhewm3-sdk.git
synced 2025-01-22 00:41:21 +00:00
Add information about dhewm3 build to savegames
like the dhewm3 version and the OS and architecture of the dhewm3 version that created the savegame. Also added an internalSavegameVersion so be independent of BUILD_NUMBER fixes #344
This commit is contained in:
parent
ad2bb56fed
commit
70f01e6c9f
8 changed files with 112 additions and 6 deletions
|
@ -26,6 +26,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "sys/Stub_SDL_endian.h"
|
||||
#include "sys/platform.h"
|
||||
#include "idlib/LangDict.h"
|
||||
#include "idlib/Timer.h"
|
||||
|
@ -33,6 +34,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "framework/BuildVersion.h"
|
||||
#include "framework/DeclEntityDef.h"
|
||||
#include "framework/FileSystem.h"
|
||||
#include "framework/Licensee.h"
|
||||
#include "renderer/ModelManager.h"
|
||||
|
||||
#include "gamesys/SysCvar.h"
|
||||
|
@ -503,6 +505,15 @@ void idGameLocal::SaveGame( idFile *f ) {
|
|||
|
||||
savegame.WriteBuildNumber( BUILD_NUMBER );
|
||||
|
||||
// DG: add some more information to savegame to make future quirks easier
|
||||
savegame.WriteInt( INTERNAL_SAVEGAME_VERSION ); // to be independent of BUILD_NUMBER
|
||||
savegame.WriteString( D3_OSTYPE ); // operating system - from CMake
|
||||
savegame.WriteString( D3_ARCH ); // CPU architecture (e.g. "x86" or "x86_64") - from CMake
|
||||
savegame.WriteString( ENGINE_VERSION );
|
||||
savegame.WriteShort( (short)sizeof(void*) ); // tells us if it's from a 32bit (4) or 64bit system (8)
|
||||
savegame.WriteShort( SDL_BYTEORDER ) ; // SDL_LIL_ENDIAN or SDL_BIG_ENDIAN
|
||||
// DG end
|
||||
|
||||
// go through all entities and threads and add them to the object list
|
||||
for( i = 0; i < MAX_GENTITIES; i++ ) {
|
||||
ent = entities[i];
|
||||
|
@ -1358,6 +1369,36 @@ bool idGameLocal::InitFromSaveGame( const char *mapName, idRenderWorld *renderWo
|
|||
|
||||
savegame.ReadBuildNumber();
|
||||
|
||||
// DG: I enhanced the information in savegames a bit for dhewm3 1.5.1
|
||||
// for which I bumped th BUILD_NUMBER to 1305
|
||||
if( savegame.GetBuildNumber() >= 1305 )
|
||||
{
|
||||
savegame.ReadInternalSavegameVersion();
|
||||
if( savegame.GetInternalSavegameVersion() > INTERNAL_SAVEGAME_VERSION ) {
|
||||
Warning( "Savegame from newer dhewm3 version, don't know how to load! (its version is %d, only up to %d supported)",
|
||||
savegame.GetInternalSavegameVersion(), INTERNAL_SAVEGAME_VERSION );
|
||||
return false;
|
||||
}
|
||||
idStr osType;
|
||||
idStr cpuArch;
|
||||
idStr engineVersion;
|
||||
short ptrSize = 0;
|
||||
short byteorder = 0;
|
||||
savegame.ReadString( osType ); // operating system the savegame was crated on (written from D3_OSTYPE)
|
||||
savegame.ReadString( cpuArch ); // written from D3_ARCH (which is set in CMake), like "x86" or "x86_64"
|
||||
savegame.ReadString( engineVersion ); // written from ENGINE_VERSION
|
||||
savegame.ReadShort( ptrSize ); // sizeof(void*) of system that created the savegame, 4 on 32bit systems, 8 on 64bit systems
|
||||
savegame.ReadShort( byteorder ); // SDL_LIL_ENDIAN or SDL_BIG_ENDIAN
|
||||
|
||||
Printf( "Savegame was created by %s on %s %s. BuildNumber was %d, savegameversion %d\n",
|
||||
engineVersion.c_str(), osType.c_str(), cpuArch.c_str(), savegame.GetBuildNumber(),
|
||||
savegame.GetInternalSavegameVersion() );
|
||||
|
||||
// right now I have no further use for this information, but in the future
|
||||
// it can be used for quirks for (then-) old savegames
|
||||
}
|
||||
// DG end
|
||||
|
||||
// Create the list of all objects in the game
|
||||
savegame.CreateObjects();
|
||||
|
||||
|
|
|
@ -512,6 +512,7 @@ public:
|
|||
|
||||
private:
|
||||
const static int INITIAL_SPAWN_COUNT = 1;
|
||||
const static int INTERNAL_SAVEGAME_VERSION = 1; // DG: added this for >= 1305 savegames
|
||||
|
||||
idStr mapFileName; // name of the map, empty string if no map loaded
|
||||
idMapFile * mapFile; // will be NULL during the game unless in-game editing is used
|
||||
|
|
|
@ -786,6 +786,7 @@ idRestoreGame::RestoreGame
|
|||
*/
|
||||
idRestoreGame::idRestoreGame( idFile *savefile ) {
|
||||
file = savefile;
|
||||
internalSavegameVersion = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -158,8 +158,23 @@ public:
|
|||
// Used to retrieve the saved game buildNumber from within class Restore methods
|
||||
int GetBuildNumber( void );
|
||||
|
||||
// DG: added these methods, internalSavegameVersion makes us independent of the global BUILD_NUMBER
|
||||
void ReadInternalSavegameVersion( void )
|
||||
{
|
||||
ReadInt( internalSavegameVersion );
|
||||
}
|
||||
|
||||
// if it's 0, this is from a GetBuildNumber() < 1305 savegame
|
||||
// otherwise, compare it to idGameLocal::INTERNAL_SAVEGAME_VERSION
|
||||
int GetInternalSavegameVersion( void ) const
|
||||
{
|
||||
return internalSavegameVersion;
|
||||
}
|
||||
// DG end
|
||||
|
||||
private:
|
||||
int buildNumber;
|
||||
int internalSavegameVersion; // DG added this
|
||||
|
||||
idFile * file;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "sys/Stub_SDL_endian.h"
|
||||
#include "sys/platform.h"
|
||||
#include "idlib/LangDict.h"
|
||||
#include "idlib/Timer.h"
|
||||
|
@ -33,6 +34,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "framework/BuildVersion.h"
|
||||
#include "framework/DeclEntityDef.h"
|
||||
#include "framework/FileSystem.h"
|
||||
#include "framework/Licensee.h"
|
||||
#include "renderer/ModelManager.h"
|
||||
|
||||
#include "gamesys/SysCvar.h"
|
||||
|
@ -447,9 +449,14 @@ void idGameLocal::SaveGame( idFile *f ) {
|
|||
|
||||
savegame.WriteBuildNumber( BUILD_NUMBER );
|
||||
|
||||
// DG: TODO: write other things (maybe internal savegame version so I don't have to bump BUILD_NUMBER AGAIN)
|
||||
// and OS, architecture etc, see #344
|
||||
// TODO: adjust InitFromSavegame() accordingly!
|
||||
// DG: add some more information to savegame to make future quirks easier
|
||||
savegame.WriteInt( INTERNAL_SAVEGAME_VERSION ); // to be independent of BUILD_NUMBER
|
||||
savegame.WriteString( D3_OSTYPE ); // operating system - from CMake
|
||||
savegame.WriteString( D3_ARCH ); // CPU architecture (e.g. "x86" or "x86_64") - from CMake
|
||||
savegame.WriteString( ENGINE_VERSION );
|
||||
savegame.WriteShort( (short)sizeof(void*) ); // tells us if it's from a 32bit (4) or 64bit system (8)
|
||||
savegame.WriteShort( SDL_BYTEORDER ) ; // SDL_LIL_ENDIAN or SDL_BIG_ENDIAN
|
||||
// DG end
|
||||
|
||||
// go through all entities and threads and add them to the object list
|
||||
for( i = 0; i < MAX_GENTITIES; i++ ) {
|
||||
|
@ -1262,11 +1269,35 @@ bool idGameLocal::InitFromSaveGame( const char *mapName, idRenderWorld *renderWo
|
|||
|
||||
savegame.ReadBuildNumber();
|
||||
|
||||
|
||||
if(savegame.GetBuildNumber() >= 1305)
|
||||
// DG: I enhanced the information in savegames a bit for dhewm3 1.5.1
|
||||
// for which I bumped th BUILD_NUMBER to 1305
|
||||
if( savegame.GetBuildNumber() >= 1305 )
|
||||
{
|
||||
// TODO: read stuff additionally written in SaveGame()
|
||||
savegame.ReadInternalSavegameVersion();
|
||||
if( savegame.GetInternalSavegameVersion() > INTERNAL_SAVEGAME_VERSION ) {
|
||||
Warning( "Savegame from newer dhewm3 version, don't know how to load! (its version is %d, only up to %d supported)",
|
||||
savegame.GetInternalSavegameVersion(), INTERNAL_SAVEGAME_VERSION );
|
||||
return false;
|
||||
}
|
||||
idStr osType;
|
||||
idStr cpuArch;
|
||||
idStr engineVersion;
|
||||
short ptrSize = 0;
|
||||
short byteorder = 0;
|
||||
savegame.ReadString( osType ); // operating system the savegame was crated on (written from D3_OSTYPE)
|
||||
savegame.ReadString( cpuArch ); // written from D3_ARCH (which is set in CMake), like "x86" or "x86_64"
|
||||
savegame.ReadString( engineVersion ); // written from ENGINE_VERSION
|
||||
savegame.ReadShort( ptrSize ); // sizeof(void*) of system that created the savegame, 4 on 32bit systems, 8 on 64bit systems
|
||||
savegame.ReadShort( byteorder ); // SDL_LIL_ENDIAN or SDL_BIG_ENDIAN
|
||||
|
||||
Printf( "Savegame was created by %s on %s %s. BuildNumber was %d, savegameversion %d\n",
|
||||
engineVersion.c_str(), osType.c_str(), cpuArch.c_str(), savegame.GetBuildNumber(),
|
||||
savegame.GetInternalSavegameVersion() );
|
||||
|
||||
// right now I have no further use for this information, but in the future
|
||||
// it can be used for quirks for (then-) old savegames
|
||||
}
|
||||
// DG end
|
||||
|
||||
// Create the list of all objects in the game
|
||||
savegame.CreateObjects();
|
||||
|
|
|
@ -463,6 +463,7 @@ public:
|
|||
|
||||
private:
|
||||
const static int INITIAL_SPAWN_COUNT = 1;
|
||||
const static int INTERNAL_SAVEGAME_VERSION = 1; // DG: added this for >= 1305 savegames
|
||||
|
||||
idStr mapFileName; // name of the map, empty string if no map loaded
|
||||
idMapFile * mapFile; // will be NULL during the game unless in-game editing is used
|
||||
|
|
|
@ -781,6 +781,7 @@ idRestoreGame::RestoreGame
|
|||
*/
|
||||
idRestoreGame::idRestoreGame( idFile *savefile ) {
|
||||
file = savefile;
|
||||
internalSavegameVersion = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -158,8 +158,23 @@ public:
|
|||
// Used to retrieve the saved game buildNumber from within class Restore methods
|
||||
int GetBuildNumber( void );
|
||||
|
||||
// DG: added these methods, internalSavegameVersion makes us independent of the global BUILD_NUMBER
|
||||
void ReadInternalSavegameVersion( void )
|
||||
{
|
||||
ReadInt( internalSavegameVersion );
|
||||
}
|
||||
|
||||
// if it's 0, this is from a GetBuildNumber() < 1305 savegame
|
||||
// otherwise, compare it to idGameLocal::INTERNAL_SAVEGAME_VERSION
|
||||
int GetInternalSavegameVersion( void ) const
|
||||
{
|
||||
return internalSavegameVersion;
|
||||
}
|
||||
// DG end
|
||||
|
||||
private:
|
||||
int buildNumber;
|
||||
int internalSavegameVersion; // DG added this
|
||||
|
||||
idFile * file;
|
||||
|
||||
|
|
Loading…
Reference in a new issue