summaryrefslogtreecommitdiff
path: root/utils/xbox/MakeGameData/MakeParticles.cpp
blob: 7e6a5f1f6758f0a4999f12a92793cc8b997cac3d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: .360 file creation of PCF files
//
//=====================================================================================//

#include "MakeGameData.h"

bool CreateTargetFile_PCF( const char *pSourceName, const char *pTargetName, bool bWriteToZip )
{	
	DmxHeader_t header;
	CDmElement *pRoot;
	if ( g_pDataModel->RestoreFromFile( pSourceName, NULL, NULL, &pRoot, CR_DELETE_NEW, &header ) == DMFILEID_INVALID )
	{
		Msg( "CreateTargetFile_PCF: Error reading file \"%s\"!\n", pSourceName );
		return false;
	}

	const char *pOutFormat = header.formatName;
	if ( !g_pDataModel->FindFormatUpdater( pOutFormat ) )
	{
		pOutFormat = "dmx";
	}

	CUtlBuffer binaryBuffer;
	if ( !g_pDataModel->Serialize( binaryBuffer, "binary", pOutFormat, pRoot->GetHandle() ) )
	{
		Msg( "CreateTargetFile_PCF: Error writing buffer\n" );
		return false;
	}

	g_pDataModel->RemoveFileId( pRoot->GetFileId() );

	WriteBufferToFile( pTargetName, binaryBuffer, bWriteToZip, g_WriteModeForConversions );

	return true;
}