Skip to content

Commit

Permalink
Re-applying savegame cvars after sikkmod revert
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.thedarkmod.com/svn/darkmod_src/trunk@6344 49c82d7f-2e2a-0410-a16f-ae8f201b507f
  • Loading branch information
stevel committed Dec 6, 2014
1 parent cd87e28 commit 34cb1ab
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
46 changes: 42 additions & 4 deletions framework/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ idCVar idSessionLocal::com_aviDemoTics( "com_aviDemoTics", "2", CVAR_SYSTEM | CV
idCVar idSessionLocal::com_wipeSeconds( "com_wipeSeconds", "1", CVAR_SYSTEM, "" );
idCVar idSessionLocal::com_guid( "com_guid", "", CVAR_SYSTEM | CVAR_ARCHIVE | CVAR_ROM, "" );

//Obsttorte
idCVar idSessionLocal::saveGameName( "saveGameName", "", CVAR_GAME | CVAR_ROM, "");

idSessionLocal sessLocal;
idSession *session = &sessLocal;

Expand Down Expand Up @@ -1697,14 +1700,16 @@ void idSessionLocal::ScrubSaveGameFileName( idStr &saveFileName ) const {
idSessionLocal::SaveGame
===============
*/
bool idSessionLocal::SaveGame( const char *saveName, bool autosave ) {
bool idSessionLocal::SaveGame( const char *saveName, bool autosave, bool skipCheck ) {
#ifdef ID_DEDICATED
common->Printf( "Dedicated servers cannot save games.\n" );
return false;
#else
int i;
idStr gameFile, previewFile, descriptionFile, mapName;

gameFile = saveName; // Obsttorte: moved upwards as needed earlier

if ( !mapSpawned ) {
common->Printf( "Not playing a game.\n" );
return false;
Expand All @@ -1721,7 +1726,19 @@ bool idSessionLocal::SaveGame( const char *saveName, bool autosave ) {
common->Printf( "You must be alive to save the game\n" );
return false;
}

if (!skipCheck)
{
if (game->savegamesDisallowed())
{
common->Printf("Manual saving is disabled!\n");
return false;
}
if (game->quicksavesDisallowed() && gameFile == "Quicksave")
{
common->Printf("Quicksaves disabled!\n");
return false;
}
}
if ( Sys_GetDriveFreeSpace( cvarSystem->GetCVarString( "fs_savepath" ) ) < 25 ) {
// "Not eough space" and "Unable to save"
MessageBox( MSG_OK, common->Translate ( "#str_02014" ), common->Translate ( "#str_02013" ), true );
Expand All @@ -1735,8 +1752,8 @@ bool idSessionLocal::SaveGame( const char *saveName, bool autosave ) {
soundSystem->SetPlayingSoundWorld( NULL );
}

// setup up filenames and paths
gameFile = saveName;
// setup up paths

ScrubSaveGameFileName( gameFile );

gameFile = "savegames/" + gameFile;
Expand All @@ -1759,6 +1776,10 @@ bool idSessionLocal::SaveGame( const char *saveName, bool autosave ) {
return false;
}

// Obsttorte increment the savegame counter

game->incrementSaveCount();

// Write SaveGame Header:
// Game Name / Version / Map Name / Persistant Player Info

Expand Down Expand Up @@ -2664,6 +2685,23 @@ void idSessionLocal::RunGameTic() {
game->SetTime2Start();
loadDoneTime = 0;
}

// Obsttorte - check if we should save the game

idStr saveGameName = game->triggeredSave();
if (!saveGameName.IsEmpty())
{
if (cvarSystem->GetCVarBool("tdm_nosave"))
{
cvarSystem->SetCVarBool("tdm_nosave",false);
SaveGame(saveGameName.c_str());
cvarSystem->SetCVarBool("tdm_nosave",true);
}
else
{
SaveGame(saveGameName.c_str(), false, true);
}
}

// run the game logic every player move
int start = Sys_Milliseconds();
Expand Down
5 changes: 4 additions & 1 deletion framework/Session_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class idSessionLocal : public idSession {
idStr GetAutoSaveName( const char *mapName ) const;

bool LoadGame(const char *saveName);
bool SaveGame(const char *saveName, bool autosave = false);
bool SaveGame(const char *saveName, bool autosave = false, bool skipCheck = false);

//=====================================

Expand All @@ -153,6 +153,9 @@ class idSessionLocal : public idSession {

static idCVar gui_configServerRate;

//Obsttorte: cvar for disabling manual saves
static idCVar saveGameName;

int timeHitch;

bool menuActive;
Expand Down

0 comments on commit 34cb1ab

Please sign in to comment.