2012-11-26 18:58:24 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Doom 3 BFG Edition GPL Source Code
2012-11-28 15:47:07 +00:00
Copyright ( C ) 1993 - 2012 id Software LLC , a ZeniMax Media company .
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
This file is part of the Doom 3 BFG Edition GPL Source Code ( " Doom 3 BFG Edition Source Code " ) .
2012-11-26 18:58:24 +00:00
Doom 3 BFG Edition Source Code is free software : you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code . If not , see < http : //www.gnu.org/licenses/>.
In addition , the Doom 3 BFG Edition 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 BFG Edition Source Code . If not , please request a copy in writing from id Software at the address below .
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 .
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
# pragma hdrstop
2012-12-22 15:18:19 +00:00
# include "precompiled.h"
2012-11-26 18:58:24 +00:00
# include "sys_savegame.h"
# include "sys_session_local.h"
# include "sys_session_savegames.h"
extern idCVar saveGame_verbose ;
idCVar savegame_error ( " savegame_error " , " 0 " , CVAR_INTEGER , " Combination of bits that will simulate and error, see 'savegamePrintErrors'. 0 = no error " ) ;
2012-11-28 15:47:07 +00:00
void OutputDetailList ( const saveGameDetailsList_t & savegameList ) ;
2012-11-26 18:58:24 +00:00
# pragma region PROCESSORS
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
idSaveGameProcessorLoadFiles
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSaveGameProcessorLoadFiles : : InitLoadFiles
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
bool idSaveGameProcessorLoadFiles : : InitLoadFiles ( const char * folder_ , const saveFileEntryList_t & files , idSaveGameManager : : packageType_t type )
{
if ( ! idSaveGameProcessor : : Init ( ) )
{
2012-11-26 18:58:24 +00:00
return false ;
}
parms . directory = AddSaveFolderPrefix ( folder_ , type ) ;
parms . description . slotName = folder_ ;
parms . mode = SAVEGAME_MBF_LOAD ;
2012-11-28 15:47:07 +00:00
for ( int i = 0 ; i < files . Num ( ) ; + + i )
{
2012-11-26 18:58:24 +00:00
parms . files . Append ( files [ i ] ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return true ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSaveGameProcessorLoadFiles : : Process
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
bool idSaveGameProcessorLoadFiles : : Process ( )
{
2012-11-26 18:58:24 +00:00
// Platform-specific impl
// This will populate an idFile_Memory with the contents of the save game
// This will not initialize the game, only load the file from the file-system
Sys_ExecuteSavegameCommandAsync ( & parms ) ;
return false ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
idSaveGameProcessorDelete
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSaveGameProcessorDelete : : Init
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
bool idSaveGameProcessorDelete : : InitDelete ( const char * folder_ , idSaveGameManager : : packageType_t type )
{
if ( ! idSaveGameProcessor : : Init ( ) )
{
2012-11-26 18:58:24 +00:00
return false ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
parms . description . slotName = folder_ ;
parms . directory = AddSaveFolderPrefix ( folder_ , type ) ;
parms . mode = SAVEGAME_MBF_DELETE_FOLDER ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return true ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSaveGameProcessorDelete : : Process
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
bool idSaveGameProcessorDelete : : Process ( )
{
2012-11-26 18:58:24 +00:00
// Platform-specific impl
// This will populate an idFile_Memory with the contents of the save game
// This will not initialize the game, only load the file from the file-system
Sys_ExecuteSavegameCommandAsync ( & parms ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return false ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
idSaveGameProcessorSaveFiles
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSaveGameProcessorSaveFiles : : InitSave
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
bool idSaveGameProcessorSaveFiles : : InitSave ( const char * folder , const saveFileEntryList_t & files , const idSaveGameDetails & descriptionForPS3 , idSaveGameManager : : packageType_t type )
{
if ( ! idSaveGameProcessor : : Init ( ) )
{
2012-11-26 18:58:24 +00:00
return false ;
}
2012-11-28 15:47:07 +00:00
if ( files . Num ( ) = = 0 )
{
2012-11-26 18:58:24 +00:00
idLib : : Warning ( " No files to save. " ) ;
return false ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Setup save system
parms . directory = AddSaveFolderPrefix ( folder , type ) ;
parms . mode = SAVEGAME_MBF_SAVE ; // do NOT delete the existing files
2012-11-28 15:47:07 +00:00
for ( int i = 0 ; i < files . Num ( ) ; + + i )
{
2012-11-26 18:58:24 +00:00
parms . files . Append ( files [ i ] ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
this - > parms . description = descriptionForPS3 ;
parms . description . slotName = folder ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return true ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
2012-11-28 15:47:07 +00:00
idSaveGameProcessorSaveFiles : : Process
2012-11-26 18:58:24 +00:00
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
bool idSaveGameProcessorSaveFiles : : Process ( )
{
2012-11-26 18:58:24 +00:00
// Platform-specific implementation
// This will start a worker thread for async operation.
// It will always signal when it's completed.
Sys_ExecuteSavegameCommandAsync ( & parms ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return false ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
idSaveGameProcessorEnumerateGames
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSaveGameProcessorEnumerateGames : : Process
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
bool idSaveGameProcessorEnumerateGames : : Process ( )
{
2012-11-26 18:58:24 +00:00
parms . mode = SAVEGAME_MBF_ENUMERATE | SAVEGAME_MBF_READ_DETAILS ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Platform-specific implementation
// This will start a worker thread for async operation.
// It will always signal when it's completed.
Sys_ExecuteSavegameCommandAsync ( & parms ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return false ;
}
2012-11-28 15:47:07 +00:00
# pragma endregion
2012-11-26 18:58:24 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSessionLocal : : SaveGameSync
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
saveGameHandle_t idSessionLocal : : SaveGameSync ( const char * name , const saveFileEntryList_t & files , const idSaveGameDetails & description )
{
2012-11-26 18:58:24 +00:00
saveGameHandle_t handle = 0 ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// serialize the description file behind their back...
saveFileEntryList_t filesWithDetails ( files ) ;
2012-11-28 15:47:07 +00:00
idFile_SaveGame * gameDetailsFile = new ( TAG_SAVEGAMES ) idFile_SaveGame ( SAVEGAME_DETAILS_FILENAME , SAVEGAMEFILE_TEXT | SAVEGAMEFILE_AUTO_DELETE ) ;
2012-11-26 18:58:24 +00:00
gameDetailsFile - > MakeWritable ( ) ;
description . descriptors . WriteToIniFile ( gameDetailsFile ) ;
filesWithDetails . Append ( gameDetailsFile ) ;
2012-11-28 15:47:07 +00:00
if ( processorSaveFiles - > InitSave ( name , filesWithDetails , description ) )
{
2012-11-26 18:58:24 +00:00
processorSaveFiles - > AddCompletedCallback ( MakeCallback ( this , & idSessionLocal : : OnSaveCompleted , & processorSaveFiles - > GetParmsNonConst ( ) ) ) ;
handle = GetSaveGameManager ( ) . ExecuteProcessorAndWait ( processorSaveFiles ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Errors within the process of saving are handled in OnSaveCompleted()
// so that asynchronous save errors are handled the same was as synchronous.
2012-11-28 15:47:07 +00:00
if ( handle = = 0 )
{
idSaveLoadParms & parms = processorSaveFiles - > GetParmsNonConst ( ) ;
2012-11-26 18:58:24 +00:00
parms . errorCode = SAVEGAME_E_UNKNOWN ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Uniform error handling
OnSaveCompleted ( & parms ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return handle ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSessionLocal : : SaveGameAsync
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
saveGameHandle_t idSessionLocal : : SaveGameAsync ( const char * name , const saveFileEntryList_t & files , const idSaveGameDetails & description )
{
2012-11-26 18:58:24 +00:00
saveGameHandle_t handle = 0 ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Done this way so we know it will be shutdown properly on early exit or exception
2012-11-28 15:47:07 +00:00
struct local_t
{
local_t ( idSaveLoadParms * localparms ) : parms ( localparms )
{
2012-11-26 18:58:24 +00:00
// Prepare background renderer
}
2012-11-28 15:47:07 +00:00
~ local_t ( )
{
2012-11-26 18:58:24 +00:00
// Shutdown background renderer
}
2012-11-28 15:47:07 +00:00
idSaveLoadParms * parms ;
2012-11-26 18:58:24 +00:00
} local ( & processorSaveFiles - > GetParmsNonConst ( ) ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// serialize the description file behind their back...
saveFileEntryList_t filesWithDetails ( files ) ;
2012-11-28 15:47:07 +00:00
idFile_SaveGame * gameDetailsFile = new ( TAG_SAVEGAMES ) idFile_SaveGame ( SAVEGAME_DETAILS_FILENAME , SAVEGAMEFILE_TEXT | SAVEGAMEFILE_AUTO_DELETE ) ;
2012-11-26 18:58:24 +00:00
gameDetailsFile - > MakeWritable ( ) ;
description . descriptors . WriteToIniFile ( gameDetailsFile ) ;
filesWithDetails . Append ( gameDetailsFile ) ;
2012-11-28 15:47:07 +00:00
if ( processorSaveFiles - > InitSave ( name , filesWithDetails , description ) )
{
2012-11-26 18:58:24 +00:00
processorSaveFiles - > AddCompletedCallback ( MakeCallback ( this , & idSessionLocal : : OnSaveCompleted , & processorSaveFiles - > GetParmsNonConst ( ) ) ) ;
handle = GetSaveGameManager ( ) . ExecuteProcessor ( processorSaveFiles ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Errors within the process of saving are handled in OnSaveCompleted()
// so that asynchronous save errors are handled the same was as synchronous.
2012-11-28 15:47:07 +00:00
if ( handle = = 0 )
{
idSaveLoadParms & parms = processorSaveFiles - > GetParmsNonConst ( ) ;
2012-11-26 18:58:24 +00:00
parms . errorCode = SAVEGAME_E_UNKNOWN ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
common - > Dialog ( ) . ShowSaveIndicator ( false ) ;
// Uniform error handling
OnSaveCompleted ( & parms ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return handle ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSessionLocal : : OnSaveCompleted
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idSessionLocal : : OnSaveCompleted ( idSaveLoadParms * parms )
{
idLocalUser * master = session - > GetSignInManager ( ) . GetMasterLocalUser ( ) ;
if ( parms - > GetError ( ) ! = SAVEGAME_E_INSUFFICIENT_ROOM )
{
2012-11-26 18:58:24 +00:00
// if savegame completeed we can clear retry info
GetSaveGameManager ( ) . ClearRetryInfo ( ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Only turn off the indicator if we're not also going to save the profile settings
2012-11-28 15:47:07 +00:00
if ( master ! = NULL & & master - > GetProfile ( ) ! = NULL & & ! master - > GetProfile ( ) - > IsDirty ( ) )
{
2012-11-26 18:58:24 +00:00
common - > Dialog ( ) . ShowSaveIndicator ( false ) ;
}
2012-11-28 15:47:07 +00:00
if ( parms - > GetError ( ) = = SAVEGAME_E_NONE )
{
2012-11-26 18:58:24 +00:00
// Save the profile any time we save the game
2012-11-28 15:47:07 +00:00
if ( master ! = NULL & & master - > GetProfile ( ) ! = NULL )
{
2012-11-26 18:58:24 +00:00
master - > GetProfile ( ) - > SaveSettings ( false ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Update the enumerated savegames
2012-11-28 15:47:07 +00:00
saveGameDetailsList_t & detailList = session - > GetSaveGameManager ( ) . GetEnumeratedSavegamesNonConst ( ) ;
idSaveGameDetails * details = detailList . Find ( parms - > description ) ;
if ( details = = NULL )
{
2012-11-26 18:58:24 +00:00
// add it
detailList . Append ( parms - > description ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
// replace it
* details = parms - > description ;
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Error handling and additional processing
common - > OnSaveCompleted ( * parms ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSessionLocal : : LoadGameSync
2012-11-28 15:47:07 +00:00
We still want to use the savegame manager because we could have file system operations in flight and need to
2012-11-26 18:58:24 +00:00
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
saveGameHandle_t idSessionLocal : : LoadGameSync ( const char * name , saveFileEntryList_t & files )
{
idSaveLoadParms & parms = processorLoadFiles - > GetParmsNonConst ( ) ;
2012-11-26 18:58:24 +00:00
saveGameHandle_t handle = 0 ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
{
2012-11-28 15:47:07 +00:00
// Put in a local block so everything will go in the global heap before the map change, but the heap is
2012-11-26 18:58:24 +00:00
// automatically popped out on early return or exception
// You cannot be in the global heap during a map change...
//idScopedGlobalHeap everythingGoesInTheGlobalHeap;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Done this way so we know it will be shutdown properly on early exit or exception
2012-11-28 15:47:07 +00:00
struct local_t
{
local_t ( idSaveLoadParms * parms_ ) : parms ( parms_ )
{
2012-11-26 18:58:24 +00:00
// Prepare background renderer or loadscreen with what you want to show
{
// with mode: SAVE_GAME_MODE_LOAD
}
}
2012-11-28 15:47:07 +00:00
~ local_t ( )
{
2012-11-26 18:58:24 +00:00
// Shutdown background renderer or loadscreen
{
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
common - > OnLoadCompleted ( * parms ) ;
}
2012-11-28 15:47:07 +00:00
idSaveLoadParms * parms ;
2012-11-26 18:58:24 +00:00
} local ( & parms ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Read the details file when loading games
saveFileEntryList_t filesWithDetails ( files ) ;
2012-11-28 15:47:07 +00:00
std : : auto_ptr < idFile_SaveGame > gameDetailsFile ( new ( TAG_SAVEGAMES ) idFile_SaveGame ( SAVEGAME_DETAILS_FILENAME , SAVEGAMEFILE_TEXT ) ) ;
2012-11-26 18:58:24 +00:00
filesWithDetails . Append ( gameDetailsFile . get ( ) ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Check the cached save details from the enumeration and make sure we don't load a save from a newer version of the game!
const saveGameDetailsList_t details = GetSaveGameManager ( ) . GetEnumeratedSavegames ( ) ;
2012-11-28 15:47:07 +00:00
for ( int i = 0 ; i < details . Num ( ) ; + + i )
{
if ( idStr : : Cmp ( name , details [ i ] . slotName ) = = 0 )
{
if ( details [ i ] . GetSaveVersion ( ) > BUILD_NUMBER )
{
2012-11-26 18:58:24 +00:00
parms . errorCode = SAVEGAME_E_INCOMPATIBLE_NEWER_VERSION ;
return 0 ;
}
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Synchronous load
2012-11-28 15:47:07 +00:00
if ( processorLoadFiles - > InitLoadFiles ( name , filesWithDetails ) )
{
2012-11-26 18:58:24 +00:00
handle = GetSaveGameManager ( ) . ExecuteProcessorAndWait ( processorLoadFiles ) ;
}
2012-11-28 15:47:07 +00:00
if ( handle = = 0 )
{
2012-11-26 18:58:24 +00:00
parms . errorCode = SAVEGAME_E_UNKNOWN ;
}
2012-11-28 15:47:07 +00:00
if ( parms . GetError ( ) ! = SAVEGAME_E_NONE )
{
2012-11-26 18:58:24 +00:00
return 0 ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Checks the description file to see if corrupted or if it's from a newer savegame
2012-11-28 15:47:07 +00:00
if ( ! LoadGameCheckDescriptionFile ( parms ) )
{
2012-11-26 18:58:24 +00:00
return 0 ;
}
// Checks to see if loaded map is from a DLC map and if that DLC is active
2012-11-28 15:47:07 +00:00
if ( ! IsDLCAvailable ( parms . description . GetMapName ( ) ) )
{
2012-11-26 18:58:24 +00:00
parms . errorCode = SAVEGAME_E_DLC_NOT_FOUND ;
return 0 ;
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
common - > OnLoadFilesCompleted ( parms ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return handle ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSessionLocal : : OnLoadCompleted
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idSessionLocal : : OnLoadCompleted ( idSaveLoadParms * parms )
{
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSessionLocal : : EnumerateSaveGamesSync
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
saveGameHandle_t idSessionLocal : : EnumerateSaveGamesSync ( )
{
2012-11-26 18:58:24 +00:00
saveGameHandle_t handle = 0 ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Done this way so we know it will be shutdown properly on early exit or exception
2012-11-28 15:47:07 +00:00
struct local_t
{
local_t ( )
{
2012-11-26 18:58:24 +00:00
// Prepare background renderer or loadscreen with what you want to show
{
// with mode: SAVE_GAME_MODE_ENUMERATE
}
}
2012-11-28 15:47:07 +00:00
~ local_t ( )
{
2012-11-26 18:58:24 +00:00
// Shutdown background renderer or loadscreen
{
}
}
} local ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// flush the old enumerated list
GetSaveGameManager ( ) . GetEnumeratedSavegamesNonConst ( ) . Clear ( ) ;
2012-11-28 15:47:07 +00:00
if ( processorEnumerate - > Init ( ) )
{
2012-11-26 18:58:24 +00:00
processorEnumerate - > AddCompletedCallback ( MakeCallback ( this , & idSessionLocal : : OnEnumerationCompleted , & processorEnumerate - > GetParmsNonConst ( ) ) ) ;
handle = GetSaveGameManager ( ) . ExecuteProcessorAndWait ( processorEnumerate ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Errors within the process of saving are handled in OnEnumerationCompleted()
// so that asynchronous save errors are handled the same was as synchronous.
2012-11-28 15:47:07 +00:00
if ( handle = = 0 )
{
idSaveLoadParms & parms = processorEnumerate - > GetParmsNonConst ( ) ;
2012-11-26 18:58:24 +00:00
parms . errorCode = SAVEGAME_E_UNKNOWN ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Uniform error handling
OnEnumerationCompleted ( & parms ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return handle ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSessionLocal : : EnumerateSaveGamesAsync
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
saveGameHandle_t idSessionLocal : : EnumerateSaveGamesAsync ( )
{
2012-11-26 18:58:24 +00:00
saveGameHandle_t handle = 0 ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// flush the old enumerated list
GetSaveGameManager ( ) . GetEnumeratedSavegamesNonConst ( ) . Clear ( ) ;
2012-11-28 15:47:07 +00:00
if ( processorEnumerate - > Init ( ) )
{
2012-11-26 18:58:24 +00:00
processorEnumerate - > AddCompletedCallback ( MakeCallback ( this , & idSessionLocal : : OnEnumerationCompleted , & processorEnumerate - > GetParmsNonConst ( ) ) ) ;
handle = GetSaveGameManager ( ) . ExecuteProcessor ( processorEnumerate ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Errors within the process of saving are handled in OnEnumerationCompleted()
// so that asynchronous save errors are handled the same was as synchronous.
2012-11-28 15:47:07 +00:00
if ( handle = = 0 )
{
idSaveLoadParms & parms = processorEnumerate - > GetParmsNonConst ( ) ;
2012-11-26 18:58:24 +00:00
parms . errorCode = SAVEGAME_E_UNKNOWN ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Uniform error handling
OnEnumerationCompleted ( & parms ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return handle ;
}
2012-11-28 15:47:07 +00:00
int idSort_EnumeratedSavegames ( const idSaveGameDetails * a , const idSaveGameDetails * b )
{
2012-11-26 18:58:24 +00:00
return b - > date - a - > date ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSessionLocal : : OnEnumerationCompleted
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idSessionLocal : : OnEnumerationCompleted ( idSaveLoadParms * parms )
{
2012-11-26 18:58:24 +00:00
// idTech4 idList::sort is just a qsort wrapper, which doesn't deal with
// idStrStatic properly!
// parms->detailList.Sort( idSort_EnumeratedSavegames );
std : : sort ( parms - > detailList . Ptr ( ) , parms - > detailList . Ptr ( ) + parms - > detailList . Num ( ) ) ;
2012-11-28 15:47:07 +00:00
if ( parms - > GetError ( ) = = SAVEGAME_E_NONE )
{
// Copy into the maintained list
saveGameDetailsList_t & detailsList = session - > GetSaveGameManager ( ) . GetEnumeratedSavegamesNonConst ( ) ;
2012-11-26 18:58:24 +00:00
//mem.PushHeap();
detailsList = parms - > detailList ; // copies new list into the savegame manager's reference
//mem.PopHeap();
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// The platform-specific implementations don't know about the prefixes
// If we don't do this here, we will end up with slots like: GAME-GAME-GAME-GAME-AUTOSAVE...
2012-11-28 15:47:07 +00:00
for ( int i = 0 ; i < detailsList . Num ( ) ; i + + )
{
idSaveGameDetails & details = detailsList [ i ] ;
2012-11-26 18:58:24 +00:00
const idStr original = details . slotName ;
const idStr stripped = RemoveSaveFolderPrefix ( original , idSaveGameManager : : PACKAGE_GAME ) ;
details . slotName = stripped ;
}
2012-11-28 15:47:07 +00:00
if ( saveGame_verbose . GetBool ( ) )
{
2012-11-26 18:58:24 +00:00
OutputDetailList ( detailsList ) ;
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
common - > OnEnumerationCompleted ( * parms ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSessionLocal : : DeleteSaveGameSync
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
saveGameHandle_t idSessionLocal : : DeleteSaveGameSync ( const char * name )
{
2012-11-26 18:58:24 +00:00
saveGameHandle_t handle = 0 ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Done this way so we know it will be shutdown properly on early exit or exception
2012-11-28 15:47:07 +00:00
struct local_t
{
local_t ( )
{
2012-11-26 18:58:24 +00:00
// Prepare background renderer or loadscreen with what you want to show
{
// with mode: SAVE_GAME_MODE_DELETE
}
}
2012-11-28 15:47:07 +00:00
~ local_t ( )
{
2012-11-26 18:58:24 +00:00
// Shutdown background renderer or loadscreen
{
}
}
} local ;
2012-11-28 15:47:07 +00:00
if ( processorDelete - > InitDelete ( name ) )
{
2012-11-26 18:58:24 +00:00
processorDelete - > AddCompletedCallback ( MakeCallback ( this , & idSessionLocal : : OnDeleteCompleted , & processorDelete - > GetParmsNonConst ( ) ) ) ;
handle = GetSaveGameManager ( ) . ExecuteProcessorAndWait ( processorDelete ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Errors within the process of saving are handled in OnDeleteCompleted()
// so that asynchronous save errors are handled the same was as synchronous.
2012-11-28 15:47:07 +00:00
if ( handle = = 0 )
{
idSaveLoadParms & parms = processorDelete - > GetParmsNonConst ( ) ;
2012-11-26 18:58:24 +00:00
parms . errorCode = SAVEGAME_E_UNKNOWN ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Uniform error handling
OnDeleteCompleted ( & parms ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return handle ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSessionLocal : : DeleteSaveGameAsync
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
saveGameHandle_t idSessionLocal : : DeleteSaveGameAsync ( const char * name )
{
2012-11-26 18:58:24 +00:00
saveGameHandle_t handle = 0 ;
2012-11-28 15:47:07 +00:00
if ( processorDelete - > InitDelete ( name ) )
{
2012-11-26 18:58:24 +00:00
processorDelete - > AddCompletedCallback ( MakeCallback ( this , & idSessionLocal : : OnDeleteCompleted , & processorDelete - > GetParmsNonConst ( ) ) ) ;
common - > Dialog ( ) . ShowSaveIndicator ( true ) ;
handle = GetSaveGameManager ( ) . ExecuteProcessor ( processorDelete ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Errors within the process of saving are handled in OnDeleteCompleted()
// so that asynchronous save errors are handled the same was as synchronous.
2012-11-28 15:47:07 +00:00
if ( handle = = 0 )
{
idSaveLoadParms & parms = processorDelete - > GetParmsNonConst ( ) ;
2012-11-26 18:58:24 +00:00
parms . errorCode = SAVEGAME_E_UNKNOWN ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Uniform error handling
OnDeleteCompleted ( & parms ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return handle ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSessionLocal : : OnDeleteCompleted
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idSessionLocal : : OnDeleteCompleted ( idSaveLoadParms * parms )
{
2012-11-26 18:58:24 +00:00
common - > Dialog ( ) . ShowSaveIndicator ( false ) ;
2012-11-28 15:47:07 +00:00
if ( parms - > GetError ( ) = = SAVEGAME_E_NONE )
{
2012-11-26 18:58:24 +00:00
// Update the enumerated list
2012-11-28 15:47:07 +00:00
saveGameDetailsList_t & details = session - > GetSaveGameManager ( ) . GetEnumeratedSavegamesNonConst ( ) ;
2012-11-26 18:58:24 +00:00
details . Remove ( parms - > description ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
common - > OnDeleteCompleted ( * parms ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSessionLocal : : IsEnumerating
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
bool idSessionLocal : : IsEnumerating ( ) const
{
2012-11-26 18:58:24 +00:00
return ! session - > IsSaveGameCompletedFromHandle ( processorEnumerate - > GetHandle ( ) ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSessionLocal : : GetEnumerationHandle
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
saveGameHandle_t idSessionLocal : : GetEnumerationHandle ( ) const
{
2012-11-26 18:58:24 +00:00
return processorEnumerate - > GetHandle ( ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSessionLocal : : IsDLCAvailable
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
bool idSessionLocal : : IsDLCAvailable ( const char * mapName )
{
2012-11-26 18:58:24 +00:00
bool hasContentPackage = true ;
return hasContentPackage ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSessionLocal : : LoadGameCheckDiscNumber
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
bool idSessionLocal : : LoadGameCheckDiscNumber ( idSaveLoadParms & parms )
{
2012-11-26 18:58:24 +00:00
#if 0
idStr mapName = parms . description . GetMapName ( ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
assert ( ! discSwapStateMgr - > IsWorking ( ) ) ;
discSwapStateMgr - > Init ( & parms . callbackSignal , idDiscSwapStateManager : : DISC_SWAP_COMMAND_LOAD ) ;
//// TODO_KC this is probably broken now...
//discSwapStateMgr->folder = folder;
//discSwapStateMgr->spawnInfo = newSpawnInfo;
//discSwapStateMgr->spawnSpot = newSpawnPoint;
//discSwapStateMgr->instanceFileName = instanceFileName;
discSwapStateMgr - > user = session - > GetSignInManager ( ) . GetMasterLocalUser ( ) ;
discSwapStateMgr - > map = mapName ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
discSwapStateMgr - > Pump ( ) ;
2012-11-28 15:47:07 +00:00
while ( discSwapStateMgr - > IsWorking ( ) )
{
2012-11-26 18:58:24 +00:00
Sys_Sleep ( 15 ) ;
// process input and render
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
discSwapStateMgr - > Pump ( ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
idDiscSwapStateManager : : discSwapStateError_t discSwapError = discSwapStateMgr - > GetError ( ) ;
2012-11-28 15:47:07 +00:00
if ( discSwapError = = idDiscSwapStateManager : : DSSE_CANCEL )
{
2012-11-26 18:58:24 +00:00
parms . errorCode = SAVEGAME_E_CANCELLED ;
2012-11-28 15:47:07 +00:00
}
else if ( discSwapError = = idDiscSwapStateManager : : DSSE_INSUFFICIENT_ROOM )
{
2012-11-26 18:58:24 +00:00
parms . errorCode = SAVEGAME_E_INSUFFICIENT_ROOM ;
parms . requiredSpaceInBytes = discSwapStateMgr - > GetRequiredStorageBytes ( ) ;
2012-11-28 15:47:07 +00:00
}
else if ( discSwapError = = idDiscSwapStateManager : : DSSE_CORRECT_DISC_ALREADY )
{
2012-11-26 18:58:24 +00:00
parms . errorCode = SAVEGAME_E_NONE ;
2012-11-28 15:47:07 +00:00
}
else if ( discSwapError ! = idDiscSwapStateManager : : DSSE_OK )
{
2012-11-26 18:58:24 +00:00
parms . errorCode = SAVEGAME_E_DISC_SWAP ;
}
2012-11-28 15:47:07 +00:00
if ( parms . errorCode = = SAVEGAME_E_UNKNOWN )
{
2012-11-26 18:58:24 +00:00
parms . errorCode = SAVEGAME_E_DISC_SWAP ;
}
# endif
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return ( parms . GetError ( ) = = SAVEGAME_E_NONE ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idSessionLocal : : LoadGameCheckDescriptionFile
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
bool idSessionLocal : : LoadGameCheckDescriptionFile ( idSaveLoadParms & parms )
{
idFile_SaveGame * * detailsFile = FindFromGenericPtr ( parms . files , SAVEGAME_DETAILS_FILENAME ) ;
if ( detailsFile = = NULL )
{
2012-11-26 18:58:24 +00:00
parms . errorCode = SAVEGAME_E_FILE_NOT_FOUND ;
return false ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
assert ( * detailsFile ! = NULL ) ;
2012-11-28 15:47:07 +00:00
( * detailsFile ) - > MakeReadOnly ( ) ;
if ( ! SavegameReadDetailsFromFile ( * detailsFile , parms . description ) )
{
2012-11-26 18:58:24 +00:00
parms . errorCode = SAVEGAME_E_CORRUPTED ;
2012-11-28 15:47:07 +00:00
}
else
{
if ( parms . description . GetSaveVersion ( ) > BUILD_NUMBER )
{
2012-11-26 18:58:24 +00:00
parms . errorCode = SAVEGAME_E_INCOMPATIBLE_NEWER_VERSION ;
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return ( parms . GetError ( ) = = SAVEGAME_E_NONE ) ;
}
# pragma region COMMANDS
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
COMMANDS
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
CONSOLE_COMMAND ( testSavegameDeleteAll , " delete all savegames without confirmation " , 0 )
{
if ( session = = NULL )
{
2012-11-26 18:58:24 +00:00
idLib : : Printf ( " Invalid session. \n " ) ;
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
idSaveLoadParms parms ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
parms . SetDefaults ( ) ;
parms . mode = SAVEGAME_MBF_DELETE_ALL_FOLDERS | SAVEGAME_MBF_NO_COMPRESS ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
Sys_ExecuteSavegameCommandAsync ( & parms ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
parms . callbackSignal . Wait ( ) ;
idLib : : Printf ( " Completed process. \n " ) ;
idLib : : Printf ( " Error = 0x%08X, %s \n " , parms . GetError ( ) , GetSaveGameErrorString ( parms . GetError ( ) ) . c_str ( ) ) ;
}
2012-11-28 15:47:07 +00:00
CONSOLE_COMMAND ( testSavegameDelete , " deletes a savegames without confirmation " , 0 )
{
if ( session = = NULL )
{
2012-11-26 18:58:24 +00:00
idLib : : Printf ( " Invalid session. \n " ) ;
return ;
}
2012-11-28 15:47:07 +00:00
if ( args . Argc ( ) ! = 2 )
{
2012-11-26 18:58:24 +00:00
idLib : : Printf ( " Usage: testSavegameDelete <folder (without 'GAMES-')> \n " ) ;
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
idStr folder = args . Argv ( 1 ) ;
idSaveGameProcessorDelete testDeleteSaveGamesProc ;
2012-11-28 15:47:07 +00:00
if ( testDeleteSaveGamesProc . InitDelete ( folder ) )
{
2012-11-26 18:58:24 +00:00
session - > GetSaveGameManager ( ) . ExecuteProcessorAndWait ( & testDeleteSaveGamesProc ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
idLib : : Printf ( " Completed process. \n " ) ;
idLib : : Printf ( " Error = 0x%08X, %s \n " , testDeleteSaveGamesProc . GetParms ( ) . GetError ( ) , GetSaveGameErrorString ( testDeleteSaveGamesProc . GetParms ( ) . GetError ( ) ) . c_str ( ) ) ;
}
2012-11-28 15:47:07 +00:00
CONSOLE_COMMAND ( testSavegameEnumerateFiles , " enumerates all the files in a folder (blank for 'current slot' folder, use 'autosave' for the autosave slot) " , 0 )
{
if ( session = = NULL )
{
2012-11-26 18:58:24 +00:00
idLib : : Printf ( " Invalid session. \n " ) ;
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
idStr folder = session - > GetCurrentSaveSlot ( ) ;
2012-11-28 15:47:07 +00:00
if ( args . Argc ( ) > 1 )
{
2012-11-26 18:58:24 +00:00
folder = args . Argv ( 1 ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
idLib : : Printf ( " Testing folder: %s \n \n " , folder . c_str ( ) ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
idSaveLoadParms parms ;
parms . SetDefaults ( ) ;
parms . mode = SAVEGAME_MBF_ENUMERATE_FILES ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Platform-specific implementation
// This will start a worker thread for async operation.
// It will always signal when it's completed.
Sys_ExecuteSavegameCommandAsync ( & parms ) ;
parms . callbackSignal . Wait ( ) ;
2012-11-28 15:47:07 +00:00
for ( int i = 0 ; i < parms . files . Num ( ) ; i + + )
{
2012-11-26 18:58:24 +00:00
idLib : : Printf ( S_COLOR_YELLOW " \t %d: %s \n " S_COLOR_DEFAULT , i , parms . files [ i ] - > GetName ( ) ) ;
}
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
OutputDetailList
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void OutputDetailList ( const saveGameDetailsList_t & savegameList )
{
for ( int i = 0 ; i < savegameList . Num ( ) ; + + i )
{
2012-11-26 18:58:24 +00:00
idLib : : Printf ( S_COLOR_YELLOW " \t %s - %s \n " S_COLOR_DEFAULT
2012-11-28 15:47:07 +00:00
" \t \t Map: %s \n "
" \t \t Time: %s \n " ,
savegameList [ i ] . slotName . c_str ( ) ,
savegameList [ i ] . damaged ? S_COLOR_RED " CORRUPT " : S_COLOR_GREEN " OK " ,
savegameList [ i ] . damaged ? " ? " : savegameList [ i ] . descriptors . GetString ( SAVEGAME_DETAIL_FIELD_MAP , " " ) ,
Sys_TimeStampToStr ( savegameList [ i ] . date )
) ;
2012-11-26 18:58:24 +00:00
}
}
2012-11-28 15:47:07 +00:00
CONSOLE_COMMAND ( testSavegameEnumerate , " enumerates the savegames available " , 0 )
{
if ( session = = NULL )
{
2012-11-26 18:58:24 +00:00
idLib : : Printf ( " Invalid session. \n " ) ;
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
saveGameHandle_t handle = session - > EnumerateSaveGamesSync ( ) ;
2012-11-28 15:47:07 +00:00
if ( handle = = 0 )
{
2012-11-26 18:58:24 +00:00
idLib : : Printf ( " Error enumerating. \n " ) ;
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
const saveGameDetailsList_t gameList = session - > GetSaveGameManager ( ) . GetEnumeratedSavegames ( ) ;
idLib : : Printf ( " Savegames found: %d \n \n " , gameList . Num ( ) ) ;
OutputDetailList ( gameList ) ;
}
2012-11-28 15:47:07 +00:00
CONSOLE_COMMAND ( testSaveGameCheck , " tests existence of savegame " , 0 )
{
2012-11-26 18:58:24 +00:00
bool exists ;
bool autosaveExists ;
Sys_SaveGameCheck ( exists , autosaveExists ) ;
idLib : : Printf ( " Savegame check: exists = %d, autosaveExists = %d \n " , exists , autosaveExists ) ;
}
2012-11-28 15:47:07 +00:00
CONSOLE_COMMAND ( testSaveGameOutputEnumeratedSavegames , " outputs the list of savegames already enumerated, this does not re-enumerate " , 0 )
{
if ( session = = NULL )
{
2012-11-26 18:58:24 +00:00
idLib : : Printf ( " Invalid session. \n " ) ;
return ;
}
2012-11-28 15:47:07 +00:00
const saveGameDetailsList_t & savegames = session - > GetSaveGameManager ( ) . GetEnumeratedSavegames ( ) ;
2012-11-26 18:58:24 +00:00
OutputDetailList ( savegames ) ;
}
2012-11-28 15:47:07 +00:00
CONSOLE_COMMAND ( testSavegameGetCurrentSlot , " returns the current slot in use " , 0 )
{
if ( session = = NULL )
{
2012-11-26 18:58:24 +00:00
idLib : : Printf ( " Invalid session. \n " ) ;
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
idLib : : Printf ( " Current slot: %s \n " , session - > GetCurrentSaveSlot ( ) ) ;
}
2012-11-28 15:47:07 +00:00
CONSOLE_COMMAND ( testSavegameSetCurrentSlot , " returns the current slot in use " , 0 )
{
if ( session = = NULL )
{
2012-11-26 18:58:24 +00:00
idLib : : Printf ( " Invalid session. \n " ) ;
return ;
}
2012-11-28 15:47:07 +00:00
if ( args . Argc ( ) ! = 2 )
{
2012-11-26 18:58:24 +00:00
idLib : : Printf ( " Usage: testSavegameSetCurrentSlot name \n " ) ;
return ;
}
2012-11-28 15:47:07 +00:00
const char * slot = args . Argv ( 1 ) ;
2012-11-26 18:58:24 +00:00
session - > SetCurrentSaveSlot ( slot ) ;
idLib : : Printf ( " Current slot: %s \n " , session - > GetCurrentSaveSlot ( ) ) ;
}
2012-11-28 15:47:07 +00:00
CONSOLE_COMMAND ( savegameSetErrorBit , " Allows you to set savegame_error by bit instead of integer value " , 0 )
{
2012-11-26 18:58:24 +00:00
int bit = atoi ( args . Argv ( 1 ) ) ;
savegame_error . SetInteger ( savegame_error . GetInteger ( ) | ( 1 < < bit ) ) ;
}
# pragma endregion