implement course radar value caching

This commit is contained in:
Glenn Maynard
2005-03-07 22:30:39 +00:00
parent 021e36535c
commit 776060e913
7 changed files with 187 additions and 18 deletions
+31
View File
@@ -58,6 +58,37 @@ void RadarValues::LoadFromNode( const XNode* pNode )
pNode->GetChildValue( RadarCategoryToString(rc), m_fValues[rc] );
}
/* iMaxValues is only used for writing compatibility fields in non-cache
* SM files; they're never actually read. */
CString RadarValues::ToString( int iMaxValues ) const
{
if( iMaxValues == -1 )
iMaxValues = NUM_RADAR_CATEGORIES;
iMaxValues = min( iMaxValues, (int)NUM_RADAR_CATEGORIES );
CStringArray asRadarValues;
for( int r=0; r < iMaxValues; r++ )
asRadarValues.push_back( ssprintf("%.3f", m_fValues[r]) );
return join( ",",asRadarValues );
}
void RadarValues::FromString( CString sRadarValues )
{
CStringArray saValues;
split( sRadarValues, ",", saValues, true );
if( saValues.size() != NUM_RADAR_CATEGORIES )
{
MakeUnknown();
return;
}
FOREACH_RadarCategory(rc)
m_fValues[rc] = strtof( saValues[rc], NULL );
}
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.