//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// AVP_Platform_Profile_LoadAndSave.cpp
// Thomas Young / Callum Hope - 9,1,09
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//
// File functionality to deal with saving data to file on PC Platform
// No actual profile functionality, just profile reading saving, loading, and writing of data used in profiles. 
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

// I N C L U D E S ///////////////////////////////////////////////////////////

#include "Core/Asura.h"

#if defined(AVP_SUPPORT_PROFILE_LOADANDSAVE)

// personal header
#include "LoadAndSave/AVP_Profile_LoadAndSave.h"
#include "shlobj.h"

// asura headers
#include "ChunkSystem/Asura_Chunk_Stream_WindowsFile.h"
#include "FileAccess/Asura_FileAccess.h"
#include "Interface/Asura_CommandConsole.h"
#include "LoadAndSave/Asura_LoadAndSave.h"
#include "Debugging/Asura_Assert.h"

// Project headers
#include "Core/AVP_GameStatus.h"

// F U N C T I O N   D E F I N I T I O N S ///////////////////////////////////
// MKC - Saving in the same directory as the profiles at the moment
// This may need to be saved into the users documents instead.
static char* g_szCheckpointSavePath = "/Checkpoints/Checkpoint";

////////////////////////////////////////////////////////////////////////////////
// Function     : AVP_Profile_LoadAndSave::Platform_Initialise
// Scope		: Private Static
// Author       : Callum Hope
// Date         : 9/1/09
//
// Desc			: For the PC there is no load or save "system" so just load the last save file, if its not there make a new one. 
////////////////////////////////////////////////////////////////////////////////

void AVP_Profile_LoadAndSave::Platform_Initialise( )
{
	if ( s_pxProfile->Load() != AVP_Profile::PROFILE_FILE_OK )
	{
		s_pxProfile->SetToDefaults();
		s_pxProfile->Save();
	}

	// Open all checkpoints and fetch the displayname for them, if they don't exists, set the display name to Empty Slot
	Asura_StringBuffer<128> xFilename;
	char* szSlot;
	for( int i = 0; i < NUM_CPOINT_SAVESLOTS; ++i )
	{
		Platform_GetCurrentProfileFileName( xFilename, 2 );
		xFilename += g_szCheckpointSavePath;
		szSlot = static_cast<char*>(Asura_Allocate(2*sizeof(char)));
		Asura_PrintfToBfr( szSlot, "%i", 2, true, i );
		xFilename += szSlot;
		xFilename += ".prf";
		Asura_Deallocate( szSlot );
		if( Asura_FileAccess::FileExists( xFilename.GetString() ) )
		{
			HANDLE xFile = CreateFile(	xFilename.GetString(),
										GENERIC_READ,
										0,
										0,
										OPEN_EXISTING,
										FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
										NULL );

			bool bFailure = ( xFile == INVALID_HANDLE_VALUE );

			if( !bFailure )
			{
				Asura_Chunk_Memory_Stream xStream;
				DWORD uBytesRead = 0;
				u_int uSize = 0;

				bFailure = ( ReadFile( xFile, xStream.GetAddress(), 132, &uBytesRead, NULL ) == FALSE );
				if( !bFailure )
				{
					bFailure = ( uBytesRead != 132 );
					if( bFailure )
					{
						Asura_Assertf( false, ("Read the wrong amount of bytes when trying to open Checkpoint %i\n\tRead %d bytes instead of %d bytes\nAny Error: (%d)", i, uBytesRead, uSize, GetLastError() ));
						CloseHandle(xFile);
						return;
					}
					else
					{
						xStream >> uSize;
						xStream >> s_xCheckpointDisplayName[i];
						CloseHandle(xFile);
					}
				}
				else
				{
					Asura_Assertf( false, ("Couldn't read the file data in Checkpoint %i!", i ));
					CloseHandle(xFile);
				}
			}
			else
			{
				Asura_Assertf( false, ("Couldn't open the file for Checkpoint %i!\nError: (%d)", i, GetLastError()));
			}
		}
		else
		{
			s_xCheckpointDisplayName[i] = "Empty Slot";
		}
		xFilename.MakeBlank();
	}
	return;
}

////////////////////////////////////////////////////////////////////////////////
// Function     : AVP_Profile_LoadAndSave::
// Scope		: Private Static
// Author       : Mårten Carlzon
// Date         : 4/1/09	
//
// Desc			: Needed to keep as much code independeble as possible
////////////////////////////////////////////////////////////////////////////////

void AVP_Profile_LoadAndSave::Platform_Update( )
{
	switch( s_eLoadingState )
	{
		case AVP_LOAD_SAVE_STATES_PROFILELOADREQUESTED:
		{
			Platform_LoadProfileData();
			ReadFromChunkStream();
			delete s_pxProfileStream;
			s_pxProfileStream = NULL;

			s_eLoadingState = AVP_LOAD_SAVE_STATES_IDLE;
			break;
		}
		case AVP_LOAD_SAVE_STATES_PROFILESAVEREQUESTED:
		{
			s_pxProfile->WriteToChunkStream( *(s_pxProfileStream) );
			Platform_SaveProfileData();
			delete s_pxProfileStream;
			s_pxProfileStream = NULL;

			s_eLoadingState = AVP_LOAD_SAVE_STATES_IDLE;
			break;
		}
		case AVP_LOAD_SAVE_STATES_CHECKPOINTLOADREQUESTED:
		{
			if( s_xCheckpointDisplayName[s_uSlot] == "Empty Slot" ||
				s_uSlot >= NUM_CPOINT_SAVESLOTS )
			{
				Asura_Assert( false, "Trying to load an empty or invalid slot!");
				s_eLoadingState = AVP_LOAD_SAVE_STATES_IDLE;
				delete s_pxCheckpointStream;
				s_pxCheckpointStream = NULL;
			}
			else
			{
				Platform_LoadCheckpoint( );
				s_eLoadingState = AVP_LOAD_SAVE_STATES_IDLE;
			}
			break;
		}
		case AVP_LOAD_SAVE_STATES_CHECKPOINTSAVEREQUESTED:
		{
			Platform_SaveCheckpoint( );
			s_eLoadingState = AVP_LOAD_SAVE_STATES_IDLE;
			break;
		}
		case AVP_LOAD_SAVE_STATES_IDLE:
		{
			if( s_bRequestPending )
			{
				s_bRequestPending = false;

				switch( s_ePendingLoadingState )
				{
					case AVP_LOAD_SAVE_STATES_PROFILELOADREQUESTED:
					{
						LoadProfileData();
						break;
					}
					case AVP_LOAD_SAVE_STATES_PROFILESAVEREQUESTED:
					{
						SaveProfileData();
						break;
					}
				}
			}
			break;
		}
		default:
		{
			//Shouldnt get here, but setting the s_eLoadingState to IDLE to be able to contine
			Asura_Assert( false, "s_eLoadingState != LOADREQUEST, SAVEREQUEST or IDLE");
			s_eLoadingState = AVP_LOAD_SAVE_STATES_IDLE;
			break;
		}
	}
}

////////////////////////////////////////////////////////////////////////////////
// Function     : AVP_Profile_LoadAndSave::
// Scope		: Private Static
// Author       : Callum Hope
// Date         : 9/1/09	
//
// Desc			: Nothing needed for the PC to do anything on shutdown
////////////////////////////////////////////////////////////////////////////////

void AVP_Profile_LoadAndSave::Platform_Shutdown( )
{
	return;
}

////////////////////////////////////////////////////////////////////////////////
// Function     : AVP_Profile_LoadAndSave::
// Scope		: Privaet Static
// Author       : Callum Hope
// Date         : 9/1/09
//
// Desc			: Nothing needed for PC on this, this is very much a 360 based function to set the porfile name etc. 
////////////////////////////////////////////////////////////////////////////////

void AVP_Profile_LoadAndSave::Platform_BeginProfileFlow( )
{
	return;
}

////////////////////////////////////////////////////////////////////////////////
// Function     : AVP_Profile_LoadAndSave::Platform_SaveProfileData
// Scope		: Private Static
// Author       : Mårten Carlzon
// Date         : 4/1/09
//
// Desc			: Saves the stream to an existing file or create a file and saves it there.
////////////////////////////////////////////////////////////////////////////////

void AVP_Profile_LoadAndSave::Platform_SaveProfileData()
{
	Asura_StringBuffer<128> xFilename;
	u_int iDepthCount = 0;
	u_int iForCount;

	Platform_GetCurrentProfileFileName( xFilename, 0 );

	if( xFilename.IsBlank() )
	{
		Asura_Assert( false, "AVP_Profile_LoadAndSave::Platform_SaveProfileData\n Data not saved because a file name could not be retrieved" );
		return;
	}

	// if the file exists we dont need to create the directory path for it. 
	if( ! Asura_FileAccess::FileExists( xFilename.GetString() ) )
	{
		Asura_StringBuffer<128> xPath;

		iDepthCount = 2;
		for( iForCount = 1; iForCount <= iDepthCount; iForCount ++ )
		{
			// for each directoy in the path create it individually.
			Platform_GetCurrentProfileFileName( xPath, iForCount );
			
			//Se if the existing folder already exists, if not create it
			if( GetFileAttributes( xPath.GetString() ) == ((DWORD)-1))
			{
				if( CreateDirectory( xPath.GetString(), NULL ) == 0 )
				{
					Asura_Assertf( false, ( "AVP_Profile_LoadAndSave::Platform_SaveProfileData\n Create Directory failed when trying to create:\n %s", xFilename.GetString() ) );
					return;
				}
			}
		}
	}

	HANDLE xFile = CreateFile(	xFilename.GetString(),
								GENERIC_WRITE,
								0,
								0,
								CREATE_ALWAYS,
								FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
								NULL );

	bool bFailure = ( xFile == INVALID_HANDLE_VALUE );

	if ( !bFailure )
	{
		s_pxProfile->WriteToChunkStream( *(s_pxProfileStream) );
	
		DWORD uDataBytesWritten = 0;
		bFailure = ( WriteFile( xFile, s_pxProfileStream->GetStartAddress(), s_uProfileSaveSize, &uDataBytesWritten, NULL) == FALSE );
		if( !bFailure )
		{
			bFailure = ( uDataBytesWritten != s_uProfileSaveSize );
			if( bFailure )
			{
				Asura_Assert( false, "Wrote the wrong amount of data when saving the profile!");
			}
		}
		else
		{
			Asura_Assert( false, "Couldn't write to the file when saving the profile!");
		}
		CloseHandle( xFile );
	}
	else
	{
		Asura_Assert( false, "xFile == INVALID_HANDLE_VALUE");
	}
}

////////////////////////////////////////////////////////////////////////////////
// Function     : AVP_Profile_LoadAndSave::Platform_LoadProfileData
// Scope		: Private Static
// Author       : Mårten Carlzon
// Date         : 1/4/09
//
// Desc			: Loads profile data from file if it exists. 
//				  This function finds the file name and opens the file, then passes the file stream to s_xStream
////////////////////////////////////////////////////////////////////////////////

void AVP_Profile_LoadAndSave::Platform_LoadProfileData()
{
	Asura_StringBuffer<128> xFilename;

	Platform_GetCurrentProfileFileName( xFilename );
	
	HANDLE xFile = CreateFile(	xFilename.GetString(),
								GENERIC_READ,
								0,
								0,
								OPEN_EXISTING,
								FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
								NULL );

	bool bFailure = ( xFile == INVALID_HANDLE_VALUE );

	if( !bFailure )
	{
		DWORD uBytesRead = 0;
		s_pxProfileStream->SetPosition(0);
		bFailure = ( ReadFile( xFile, s_pxProfileStream->GetAddress(), s_uProfileSaveSize , &uBytesRead, NULL) == FALSE);
	
		if( !bFailure )
		{
			bFailure = ( uBytesRead != s_uProfileSaveSize );
			if( bFailure )
			{
				Asura_Assertf( false, ("Read the wrong amount of bytes\n\tRead %f bytes instead of %f bytes", uBytesRead, s_uProfileSaveSize ));
				return;
			}
		}
		else
		{
			Asura_Assertf( false, ("Couldnt read from the file: %s", xFilename.GetString() ));
			return;
		}

		CloseHandle(xFile);
	}
	else
	{
		Asura_Assert( false, "Failed to open/find the file to load the profile!");
	}
}

////////////////////////////////////////////////////////////////////////////////
// Function     : AVP_Profile_LoadAndSave::
// Scope		: Private Static
// Author       : Callum Hope
// Date         : 9/1/09
//
// Desc			: Takes the name of the current profile and create a path and file name from it to save to
//				  uDepthToReturn defines how much of the path is wanted in terms of directories, 0 indicates the full name. 
// Return		: A string buffer holding the path and file name;
////////////////////////////////////////////////////////////////////////////////

void AVP_Profile_LoadAndSave::Platform_GetCurrentProfileFileName( Asura_StringBuffer<128>& xFileNameAndPath, u_int uDepthToReturn /* = 0 */ )
{
	char* pszPath = static_cast<char*>(Asura_Allocate(128*sizeof(char)));
	SHGetFolderPath( NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_DEFAULT, pszPath );

	xFileNameAndPath.MakeBlank();
	
	xFileNameAndPath += pszPath;
	xFileNameAndPath.ReplaceAllChars( '\\', '/' );
	Asura_Deallocate( pszPath );
	
	xFileNameAndPath += "/";
	xFileNameAndPath += "AvP3";
	if( uDepthToReturn == 1 )
	{
		return;
	}
	
	xFileNameAndPath += "/";
	xFileNameAndPath += s_pxProfile->GetName().GetString();
	if( uDepthToReturn == 2 )
	{
		return;
	}

	xFileNameAndPath += "/";
	xFileNameAndPath += s_pxProfile->GetName().GetString();
	xFileNameAndPath += ".prf";
}

////////////////////////////////////////////////////////////////////////////////
// Function     : AVP_Profile_LoadAndSave::Platform_SaveCheckpoint
// Scope		: Private Static
// Author       : Mårten Carlzon
// Date         : 3/4/09
//
// Desc			: Saves the checkpointblock to a specific file
////////////////////////////////////////////////////////////////////////////////

void AVP_Profile_LoadAndSave::Platform_SaveCheckpoint()
{
	Asura_StringBuffer<128> xFilename;
	Platform_GetCurrentProfileFileName( xFilename, 2 );

	if( s_uSlot < NUM_CPOINT_SAVESLOTS )
	{
		char *szSlot;
		szSlot = static_cast<char*>(Asura_Allocate(2*sizeof(char)));
		Asura_PrintfToBfr( szSlot, "%i", 2, true, s_uSlot );

		xFilename += g_szCheckpointSavePath;
		xFilename += szSlot;
		xFilename += ".prf";
		Asura_Deallocate( szSlot );
	}
	else
	{
		Asura_Assert( false, "Invalid slot for saving in Platform_SaveCheckpoint!\nCansel the save" );
		return;
	}
	

	// if the file exists we dont need to create the directory path for it. 
	if( ! Asura_FileAccess::FileExists( xFilename.GetString() ) )
	{
		Asura_StringBuffer<128> xPath;

		// for each directoy in the path create it individually.
		Platform_GetCurrentProfileFileName( xPath, 2 );
			
		//Se if the existing folder already exists, if not create it
		if( GetFileAttributes( xPath.GetString() ) == ((DWORD)-1))
		{
			if( CreateDirectory( xPath.GetString(), NULL ) == 0 )
			{
				Asura_Assertf( false, ( "AVP_Profile_LoadAndSave::Platform_SaveProfileData\n Create Directory failed when trying to create:\n %s", xFilename.GetString() ) );
				return;
			}
		}
		xPath += "/Checkpoints";

		//Se if the existing folder already exists, if not create it
		if( GetFileAttributes( xPath.GetString() ) == ((DWORD)-1))
		{
			if( CreateDirectory( xPath.GetString(), NULL ) == 0 )
			{
				Asura_Assertf( false, ( "AVP_Profile_LoadAndSave::Platform_SaveProfileData\n Create Directory failed when trying to create:\n %s", xFilename.GetString() ) );
				return;
			}
		}
	}

	HANDLE xFile = CreateFile(	xFilename.GetString(),
								GENERIC_WRITE,
								0,
								0,
								CREATE_ALWAYS,
								FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
								NULL );

	bool bFailure = ( xFile == INVALID_HANDLE_VALUE );

	if ( !bFailure )
	{
		DWORD uDataBytesWritten = 0;
		u_int uCheckpointSize = AVP_Game_Core::GetCheckpointBlock()->GetSize();
		Asura_Chunk_Memory_Stream xStream( 4 + 128 + 128 + uCheckpointSize );
		Asura_StringBuffer<128> xLevelName;
		Asura_StringBuffer<128> xDisplayName;
		xLevelName += AVP_Settings::GetLevelName();
		xDisplayName += AVP_Settings::GetSpeciesName( AVP_Settings::GetPlayerSpecies() );
		xDisplayName += " - ";
		xDisplayName += AVP_Settings::GetLevelName();
		s_xCheckpointDisplayName[s_uSlot] = xDisplayName;
		//Asura_PrintfToBfr( 


		xStream.Write( 4, &uCheckpointSize );
		xStream.Write( 128, &xDisplayName );
		xStream.Write( 128, &xLevelName );
		xStream.Write( uCheckpointSize, AVP_Game_Core::GetCheckpointBlock()->GetStartPtr() );

		bFailure = ( WriteFile( xFile, xStream.GetStartAddress(), (4 + 128 + 128 + uCheckpointSize), &uDataBytesWritten, NULL) == FALSE );
		
		if( !bFailure )
		{
			bFailure = ( uDataBytesWritten != (4 + 128 + 128 + uCheckpointSize) );
			if( bFailure )
			{
				Asura_Assertf( false, ("Wrote the wrong amount of data when saving the profile!\nWrote %d bytes instead of %d\n", uDataBytesWritten, uCheckpointSize));
			}
		}
		else
		{
			Asura_Assertf( false, ("Couldn't write to the file when saving the profile!\nError: (%d)", GetLastError()));
		}
		CloseHandle( xFile );
	}
	else
	{
		Asura_Assert( false, "xFile == INVALID_HANDLE_VALUE");
	}
}

////////////////////////////////////////////////////////////////////////////////
// Function     : AVP_Profile_LoadAndSave::Platform_LoadCheckpoint
// Scope		: 
// Author       : 
// Date         : 
//
// Desc			: 
////////////////////////////////////////////////////////////////////////////////

void AVP_Profile_LoadAndSave::Platform_LoadCheckpoint( )
{
	Asura_StringBuffer<128> xFilename;
	Asura_StringBuffer<128> xLevelname;

	Platform_GetCurrentProfileFileName( xFilename, 2 );
	if( s_uSlot < NUM_CPOINT_SAVESLOTS )
	{
		char* szSlot;
		szSlot = static_cast<char*>(Asura_Allocate(2*sizeof(char)));
		Asura_PrintfToBfr( szSlot, "%i", 2, true, s_uSlot );

		xFilename += g_szCheckpointSavePath;
		xFilename += szSlot;
		xFilename += ".prf";
		Asura_Deallocate( szSlot );
	}
	else
	{
		Asura_Assertf( false, ("Invalid slot for loading in Platform_LoadCheckpoint! %i isnt between -1 and %i\nCansel the load", s_uSlot, NUM_CPOINT_SAVESLOTS ) );
		return;
	}
		
	HANDLE xFile = CreateFile(	xFilename.GetString(),
								GENERIC_READ,
								0,
								0,
								OPEN_EXISTING,
								FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
								NULL );

	bool bFailure = ( xFile == INVALID_HANDLE_VALUE );

	if( !bFailure )
	{
		Asura_Chunk_Memory_Stream xStream;
		DWORD uBytesRead = 0;
			
		bFailure = ( ReadFile( xFile, xStream.GetAddress(), 260, &uBytesRead, NULL ) == FALSE );
		if( !bFailure )
		{
			bFailure = ( uBytesRead != 260 );
			if( bFailure )
			{
				Asura_Assertf( false, ("Read the wrong amount of bytes\n\tRead %d bytes instead of %d bytes\nAny Error: (%d)", uBytesRead, 260, GetLastError() ));
				CloseHandle(xFile);
				return;
			}
			else
			{
				xStream >> s_uCheckpointSize;
				xStream.Read( 128 , &s_xCheckpointDisplayName[s_uSlot] );
				xStream.Read( 128, &xLevelname );

				uBytesRead = 0;
			}
		}
		else
		{
			Asura_Assertf( false, ("Couldnt read from the file: %s\nError: (%d)\n", xFilename.GetString(), GetLastError() ));
			CloseHandle(xFile);
			return;
		}
		
		if( !s_pxCheckpointStream == NULL )
		{
			Asura_Assert( false, "s_pxCheckpointStream != NULL when loading checkpoint, possible memory leak!" );
			delete s_pxCheckpointStream;
		}
		s_pxCheckpointStream = new Asura_Chunk_Memory_Stream( s_uCheckpointSize );
		
		bFailure = ( ReadFile( xFile, s_pxCheckpointStream->GetAddress(), s_uCheckpointSize, &uBytesRead, NULL ) == FALSE );
		
		if( !bFailure )
		{
			bFailure = ( uBytesRead != ( s_uCheckpointSize ));
			if( bFailure )
			{
				Asura_Assertf( false, ("Read the wrong amount of bytes\n\tRead %d bytes instead of %d bytes\nAny Error: (%d)", uBytesRead, s_uCheckpointSize, GetLastError() ));
				CloseHandle(xFile);
				return;
			}
			else
			{
				Asura_StaticSaveBlock* pxSaveBlock = AVP_Game_Core::GetCheckpointBlock();
				pxSaveBlock->Clear( false );
				pxSaveBlock->AddData( s_pxCheckpointStream->GetStartAddress(), s_uCheckpointSize );
			}
		}
		else
		{
			Asura_Assertf( false, ("Couldnt read from the file: %s\nError: (%d)\n", xFilename.GetString(), GetLastError() ));
			CloseHandle(xFile);
			return;
		}
		delete s_pxCheckpointStream;
		s_pxCheckpointStream = NULL;
	}
	else
	{
		Asura_Assert( false, "Failed to open/find the file to load the checkpoint!");
	}
	CloseHandle(xFile);

	u_int uLevelId = GetLevelId( &xLevelname );
	Asura_UnicodeChar* pszArguments;

	pszArguments = static_cast<Asura_UnicodeChar*>(Asura_Allocate(7*sizeof(Asura_UnicodeChar)));

	Asura_PrintfToBfr( pszArguments, L"%i 0 0", 7, true, uLevelId );
	if( !Asura_CommandConsole_CmdList::Exec( L"FrontEnd.TestLevelSelect", pszArguments, false, 0 ) )
	{
		Asura_Assert( false, "Coulndt execute FrontEnd.TestLevelSelect....!" );
	}
	
	Asura_Deallocate(pszArguments);
	AVP_GameStatus::SetLoadCheckpoint( true );
}

////////////////////////////////////////////////////////////////////////////////
// Function     : AVP_Profile_LoadAndSave::Platform_GetState
// Scope		: 
// Author       : 
// Date         : 
//
// Desc			: 
////////////////////////////////////////////////////////////////////////////////

AVP_Profile_State AVP_Profile_LoadAndSave::Platform_GetState( )
{
	return AVP_PROFILE_STATE_IDLE;
}

////////////////////////////////////////////////////////////////////////////////
// Function     : AVP_Profile_LoadAndSave::Platform_GetLastError
// Scope		: 
// Author       : 
// Date         : 
//
// Desc			: 
////////////////////////////////////////////////////////////////////////////////

//AVP_Profile_Error AVP_Profile_LoadAndSave::Platform_GetLastError( )
//{
//	return AVP_PROFILE_ERROR_NONE;
//}

////////////////////////////////////////////////////////////////////////////////
// Function     : AVP_Profile_LoadAndSave::Platform_GetSlotDisplayText
// Scope		: Private Static
// Author       : Callum Hope
// Date         : 9/1/09
//
// Desc			: PC does not use slots so this is irrelevant. 
////////////////////////////////////////////////////////////////////////////////

const void AVP_Profile_LoadAndSave::Platform_GetSlotDisplayText ( const int iSlot )
{
	if( -1 < iSlot && iSlot < NUM_CPOINT_SAVESLOTS )
	{
		Asura_CommandConsole::Printf( s_xCheckpointDisplayName[iSlot].GetString() );
	}
	else
	{
		Asura_Assert( false, "Invalid iSlot number in Profile_GetSlotDisplayText");
	}
}

////////////////////////////////////////////////////////////////////////////////

#endif	//defined(AVP_SUPPORT_PROFILE_LOADANDSAVE)


/// End of file. ///
