//
// Asura_Chunk_ResourceFile_PSP.cpp
//
// Created by KJFL - Wednesday, February 04, 2004
//
// Copyright (C) 2004 Rebellion, All Rights Reserved.
//

#include "Core/Asura.h"

// This file's header.
#include "ChunkSystem/Asura_Chunk_ResourceFile_PSP.h"

#include "Debugging/Asura_Assert.h"
#include "ChunkSystem/Asura_Chunk_ResourceFile.h"
#include "Core/Asura_Handle.h"
#include "FileAccess/Asura_FileAccess.h"

#include "ChunkSystem/Asura_Chunk_ResourceFile_PSP_Botanicals.h"
#include "ChunkSystem/Asura_Chunk_ResourceFile_PSP_Character.h"
#include "ChunkSystem/Asura_Chunk_ResourceFile_PSP_Environment.h"
#include "ChunkSystem/Asura_Chunk_ResourceFile_PSP_Object.h"
#include "ChunkSystem/Asura_Chunk_ResourceFile_PSP_ObjectHierarchy.h"
#include "ChunkSystem/Asura_Chunk_ResourceFile_PSP_SoundData.h"
#include "ChunkSystem/Asura_Chunk_ResourceFile_PSP_StreamedSounds.h"

// C L A S S   I M P L E M E N T A T I O N S /////////////////////////////////

bool Asura_Chunk_ResourceFile::Platform_Process( Asura_Handle hFile, const char* szOriginalFileName )
{
    bool bProcessedEntireChunk;

	// (MP - 16.09.2002) Note that I've omitted the semi-colon at the end of
	// this macro; this stops Lint complaining.
    #define PROCESS( type, class_for_type ) \
        case type: \
            bProcessedEntireChunk = (reinterpret_cast<class_for_type*>(this))->Process( hFile ); \
            break
    #define PROCESS_VOID( type, class_for_type ) \
        case type: \
            (reinterpret_cast<class_for_type*>(this))->Process( hFile ); \
			bProcessedEntireChunk = true; \
            break

	switch( this->SubType )
	{
		// Process known subtypes.
		PROCESS_VOID( ASURA_RESOURCEFILE_TYPE_PSP_ENVIRONMENT, Asura_Chunk_ResourceFile_PSP_Environment);
		PROCESS_VOID( ASURA_RESOURCEFILE_TYPE_PSP_CHARACTER, Asura_Chunk_ResourceFile_PSP_Character);
		PROCESS_VOID( ASURA_RESOURCEFILE_TYPE_PSP_OBJECTHIERARCHY, Asura_Chunk_ResourceFile_PSP_ObjectHierarchy);
		PROCESS_VOID( ASURA_RESOURCEFILE_TYPE_PSP_OBJECT, Asura_Chunk_ResourceFile_PSP_Object);
		PROCESS( ASURA_RESOURCEFILE_TYPE_PSP_SOUNDDATA, Asura_Chunk_ResourceFile_PSP_SoundData);
		PROCESS( ASURA_RESOURCEFILE_TYPE_PSP_STREAMINGSOUNDS, Asura_Chunk_ResourceFile_PSP_StreamedSounds);

#if defined ASURA_USE_BOTANICALS
		PROCESS_VOID( ASURA_RESOURCEFILE_TYPE_PSP_BOTANICALS, Asura_Chunk_ResourceFile_PSP_Botanicals);
#endif // #if defined ASURA_USE_BOTANICALS

	default:
		{
            Asura_Assert( false, "Unrecognised PSP resource file subtype." );
			
			// skip the data to keep things happy
			Asura_FileAccess::SkipData( hFile, this->FileSize );
			bProcessedEntireChunk = true;
			break;
		}
    }

	#undef PROCESS
	#undef PROCESS_VOID

	return bProcessedEntireChunk;
}


