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
|
|
|
|
|
|
|
#define SAVEGAME_PROFILE_FILENAME "profile.bin"
|
|
|
|
|
|
|
|
idCVar profile_verbose( "profile_verbose", "0", CVAR_BOOL, "Turns on debug spam for profiles" );
|
|
|
|
|
|
|
|
/*
|
|
|
|
================================================
|
|
|
|
idProfileMgr
|
|
|
|
================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idProfileMgr
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
idProfileMgr::idProfileMgr() :
|
|
|
|
profileSaveProcessor( new( TAG_SAVEGAMES ) idSaveGameProcessorSaveProfile ),
|
|
|
|
profileLoadProcessor( new( TAG_SAVEGAMES ) idSaveGameProcessorLoadProfile ),
|
2012-11-26 18:58:24 +00:00
|
|
|
profile( NULL ),
|
2012-11-28 15:47:07 +00:00
|
|
|
handle( 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
================================================
|
|
|
|
~idProfileMgr
|
|
|
|
================================================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
idProfileMgr::~idProfileMgr()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idProfileMgr::Init
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idProfileMgr::Init( idLocalUser* user_ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
user = user_;
|
|
|
|
handle = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idProfileMgr::Pump
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idProfileMgr::Pump()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// profile can be NULL if we forced the user to register as in the case of map-ing into a level from the press start screen
|
2012-11-28 15:47:07 +00:00
|
|
|
if( profile == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// See if we are done with saving/loading the profile
|
|
|
|
bool saving = profile->GetState() == idPlayerProfile::SAVING;
|
|
|
|
bool loading = profile->GetState() == idPlayerProfile::LOADING;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( ( saving || loading ) && session->IsSaveGameCompletedFromHandle( handle ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
profile->SetState( idPlayerProfile::IDLE );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( saving )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// Done saving
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( loading )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// Done loading
|
2012-11-28 15:47:07 +00:00
|
|
|
const idSaveLoadParms& parms = profileLoadProcessor->GetParms();
|
|
|
|
if( parms.GetError() == SAVEGAME_E_FOLDER_NOT_FOUND || parms.GetError() == SAVEGAME_E_FILE_NOT_FOUND )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
profile->SaveSettings( true );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( parms.GetError() == SAVEGAME_E_CORRUPTED )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "Profile corrupt, creating a new one..." );
|
|
|
|
common->Dialog().AddDialog( GDM_CORRUPT_PROFILE, DIALOG_CONTINUE, NULL, NULL, false );
|
|
|
|
profile->SetDefaults();
|
|
|
|
profile->SaveSettings( true );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( parms.GetError() != SAVEGAME_E_NONE )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
profile->SetState( idPlayerProfile::ERR );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
session->OnLocalUserProfileLoaded( user );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( saving || loading )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// See if we need to save/load the profile
|
2012-11-28 15:47:07 +00:00
|
|
|
if( profile->GetRequestedState() == idPlayerProfile::SAVE_REQUESTED && profile->IsDirty() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
profile->MarkDirty( false );
|
|
|
|
SaveSettingsAsync();
|
|
|
|
// Syncs the steam data
|
|
|
|
//session->StoreStats();
|
|
|
|
profile->SetRequestedState( idPlayerProfile::IDLE );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( profile->GetRequestedState() == idPlayerProfile::LOAD_REQUESTED )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
LoadSettingsAsync();
|
|
|
|
profile->SetRequestedState( idPlayerProfile::IDLE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idProfileMgr::GetProfile
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
idPlayerProfile* idProfileMgr::GetProfile()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
assert( user != NULL );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( profile == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// Lazy instantiation
|
|
|
|
// Create a new profile
|
|
|
|
profile = idPlayerProfile::CreatePlayerProfile( user->GetInputDevice() );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( profile == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
bool loading = ( profile->GetState() == idPlayerProfile::LOADING ) || ( profile->GetRequestedState() == idPlayerProfile::LOAD_REQUESTED );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( loading )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return profile;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idProfileMgr::SaveSettingsAsync
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idProfileMgr::SaveSettingsAsync()
|
|
|
|
{
|
|
|
|
if( !saveGame_enable.GetBool() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "Skipping profile save because saveGame_enable = 0" );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( GetProfile() != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// Issue the async save...
|
2012-11-28 15:47:07 +00:00
|
|
|
if( profileSaveProcessor->InitSaveProfile( profile, "" ) )
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
profileSaveProcessor->AddCompletedCallback( MakeCallback( this, &idProfileMgr::OnSaveSettingsCompleted, &profileSaveProcessor->GetParmsNonConst() ) );
|
|
|
|
handle = session->GetSaveGameManager().ExecuteProcessor( profileSaveProcessor.get() );
|
|
|
|
profile->SetState( idPlayerProfile::SAVING );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "Not saving profile, profile is NULL." );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idProfileMgr::LoadSettingsAsync
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idProfileMgr::LoadSettingsAsync()
|
|
|
|
{
|
|
|
|
if( profile != NULL && saveGame_enable.GetBool() )
|
|
|
|
{
|
|
|
|
if( profileLoadProcessor->InitLoadProfile( profile, "" ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// Skip the not found error because this might be the first time to play the game!
|
|
|
|
profileLoadProcessor->SetSkipSystemErrorDialogMask( SAVEGAME_E_FOLDER_NOT_FOUND | SAVEGAME_E_FILE_NOT_FOUND );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
profileLoadProcessor->AddCompletedCallback( MakeCallback( this, &idProfileMgr::OnLoadSettingsCompleted, &profileLoadProcessor->GetParmsNonConst() ) );
|
|
|
|
handle = session->GetSaveGameManager().ExecuteProcessor( profileLoadProcessor.get() );
|
|
|
|
profile->SetState( idPlayerProfile::LOADING );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// If not able to save the profile, just change the state and leave
|
2012-11-28 15:47:07 +00:00
|
|
|
if( profile == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "Not loading profile, profile is NULL." );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( !saveGame_enable.GetBool() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "Skipping profile load because saveGame_enable = 0" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idProfileMgr::OnLoadSettingsCompleted
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idProfileMgr::OnLoadSettingsCompleted( idSaveLoadParms* parms )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Don't process if error already detected
|
2012-11-28 15:47:07 +00:00
|
|
|
if( parms->errorCode != SAVEGAME_E_NONE )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// Serialize the loaded profile
|
2012-11-28 15:47:07 +00:00
|
|
|
idFile_SaveGame** profileFileContainer = FindFromGenericPtr( parms->files, SAVEGAME_PROFILE_FILENAME );
|
|
|
|
idFile_SaveGame* profileFile = profileFileContainer == NULL ? NULL : *profileFileContainer;
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
bool foundProfile = profileFile != NULL && profileFile->Length() > 0;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( foundProfile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idTempArray< byte > buffer( MAX_PROFILE_SIZE );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// Serialize settings from this buffer
|
|
|
|
profileFile->MakeReadOnly();
|
|
|
|
unsigned int originalChecksum;
|
|
|
|
profileFile->ReadBig( originalChecksum );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
int dataLength = profileFile->Length() - ( int )sizeof( originalChecksum );
|
2012-11-26 18:58:24 +00:00
|
|
|
profileFile->ReadBigArray( buffer.Ptr(), dataLength );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// Validate the checksum before we let the game serialize the settings
|
|
|
|
unsigned int checksum = MD5_BlockChecksum( buffer.Ptr(), dataLength );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( originalChecksum != checksum )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "Checksum: 0x%08x, originalChecksum: 0x%08x, size = %d", checksum, originalChecksum, dataLength );
|
|
|
|
parms->errorCode = SAVEGAME_E_CORRUPTED;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idBitMsg msg;
|
2012-11-28 15:47:07 +00:00
|
|
|
msg.InitRead( buffer.Ptr(), ( int )buffer.Size() );
|
2012-11-26 18:58:24 +00:00
|
|
|
idSerializer ser( msg, false );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( !profile->Serialize( ser ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
parms->errorCode = SAVEGAME_E_CORRUPTED;
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
parms->errorCode = SAVEGAME_E_FILE_NOT_FOUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idProfileMgr::OnSaveSettingsCompleted
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idProfileMgr::OnSaveSettingsCompleted( 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
|
|
|
common->Dialog().AddDialog( GDM_PROFILE_SAVE_ERROR, DIALOG_CONTINUE, NULL, NULL, false );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( game )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
game->Shell_UpdateSavedGames();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================================================
|
|
|
|
idSaveGameProcessorSaveProfile
|
|
|
|
================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idSaveGameProcessorSaveProfile::idSaveGameProcessorSaveProfile
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
idSaveGameProcessorSaveProfile::idSaveGameProcessorSaveProfile()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
profileFile = NULL;
|
|
|
|
profile = NULL;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idSaveGameProcessorSaveProfile::InitSaveProfile
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool idSaveGameProcessorSaveProfile::InitSaveProfile( idPlayerProfile* profile_, const char* folder )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// Serialize the profile and pass a file to the processor
|
2012-11-28 15:47:07 +00:00
|
|
|
profileFile = new( TAG_SAVEGAMES ) idFile_SaveGame( SAVEGAME_PROFILE_FILENAME, SAVEGAMEFILE_BINARY | SAVEGAMEFILE_AUTO_DELETE );
|
2012-11-26 18:58:24 +00:00
|
|
|
profileFile->MakeWritable();
|
|
|
|
profileFile->SetMaxLength( MAX_PROFILE_SIZE );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// Create a serialization object and let the game serialize the settings into the buffer
|
|
|
|
const int serializeSize = MAX_PROFILE_SIZE - 8; // -8 for checksum (all platforms) and length (on 360)
|
|
|
|
idTempArray< byte > buffer( serializeSize );
|
|
|
|
idBitMsg msg;
|
|
|
|
msg.InitWrite( buffer.Ptr(), serializeSize );
|
|
|
|
idSerializer ser( msg, true );
|
|
|
|
profile_->Serialize( ser );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// Get and write the checksum & length first
|
|
|
|
unsigned int checksum = MD5_BlockChecksum( msg.GetReadData(), msg.GetSize() );
|
|
|
|
profileFile->WriteBig( checksum );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::PrintfIf( profile_verbose.GetBool(), "checksum: 0x%08x, length: %d\n", checksum, msg.GetSize() );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// Add data to the file and prepare for save
|
|
|
|
profileFile->Write( msg.GetReadData(), msg.GetSize() );
|
|
|
|
profileFile->MakeReadOnly();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
saveFileEntryList_t files;
|
|
|
|
files.Append( profileFile );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
idSaveGameDetails description;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( !idSaveGameProcessorSaveFiles::InitSave( folder, files, description, idSaveGameManager::PACKAGE_PROFILE ) )
|
|
|
|
{
|
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
|
|
|
profile = profile_;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idSaveGameProcessorSaveProfile::Process
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool idSaveGameProcessorSaveProfile::Process()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Files already setup for save, just execute as normal files
|
|
|
|
return idSaveGameProcessorSaveFiles::Process();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
================================================
|
|
|
|
idSaveGameProcessorLoadProfile
|
|
|
|
================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idSaveGameProcessorLoadProfile::idSaveGameProcessorLoadProfile
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
idSaveGameProcessorLoadProfile::idSaveGameProcessorLoadProfile()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
profileFile = NULL;
|
|
|
|
profile = NULL;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idSaveGameProcessorLoadProfile::~idSaveGameProcessorLoadProfile
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
idSaveGameProcessorLoadProfile::~idSaveGameProcessorLoadProfile()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idSaveGameProcessorLoadProfile::InitLoadFiles
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool idSaveGameProcessorLoadProfile::InitLoadProfile( idPlayerProfile* profile_, const char* folder_ )
|
|
|
|
{
|
|
|
|
if( !idSaveGameProcessor::Init() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
parms.directory = AddSaveFolderPrefix( folder_, idSaveGameManager::PACKAGE_PROFILE );
|
|
|
|
parms.description.slotName = folder_;
|
|
|
|
parms.mode = SAVEGAME_MBF_LOAD;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
profileFile = new( TAG_SAVEGAMES ) idFile_SaveGame( SAVEGAME_PROFILE_FILENAME, SAVEGAMEFILE_BINARY | SAVEGAMEFILE_AUTO_DELETE );
|
2012-11-26 18:58:24 +00:00
|
|
|
parms.files.Append( profileFile );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
profile = profile_;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idSaveGameProcessorLoadProfile::Process
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool idSaveGameProcessorLoadProfile::Process()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
return idSaveGameProcessorLoadFiles::Process();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
Sys_SaveGameProfileCheck
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool Sys_SaveGameProfileCheck()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
bool exists = false;
|
2012-11-28 15:47:07 +00:00
|
|
|
const char* saveFolder = "savegame";
|
|
|
|
|
|
|
|
if( fileSystem->IsFolder( saveFolder, "fs_savePath" ) == FOLDER_YES )
|
|
|
|
{
|
|
|
|
idFileList* files = fileSystem->ListFiles( saveFolder, SAVEGAME_PROFILE_FILENAME );
|
|
|
|
const idStrList& fileList = files->GetList();
|
|
|
|
|
|
|
|
for( int i = 0; i < fileList.Num(); i++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idStr filename = fileList[i];
|
2012-11-28 15:47:07 +00:00
|
|
|
if( filename == SAVEGAME_PROFILE_FILENAME )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
exists = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
fileSystem->FreeFileList( files );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return exists;
|
|
|
|
}
|