Simplify CBreakableGibShooter::GetRandomTemplateModelIndex

MapEntity_ExtractValue(), as opposed to CEntityMapData, does not require
a mutable string.
This commit is contained in:
Alexander 'z33ky' Hirsch 2021-04-26 09:44:12 +02:00
parent 036fbda906
commit d0b6998637

View File

@ -2563,15 +2563,11 @@ LINK_ENTITY_TO_CLASS( env_break_shooter, CBreakableGibShooter );
int CBreakableGibShooter::GetRandomTemplateModelIndex( CPointTemplate *pTemplate )
{
int iIndex = RandomInt( 0, pTemplate->GetNumTemplates() );
char *iszTemplate = strdup(STRING(Templates_FindByIndex(pTemplate->GetTemplateIndexForTemplate(iIndex))));
CEntityMapData entData( iszTemplate );
const char *szTemplate = STRING(Templates_FindByIndex(pTemplate->GetTemplateIndexForTemplate(iIndex)));
// This might seem a little messy, but I think it's cheaper than creating the entity.
char szModel[MAPKEY_MAXLENGTH];
bool modelExtracted = entData.ExtractValue("model", szModel);
free(iszTemplate);
bool modelExtracted = MapEntity_ExtractValue(szTemplate, "model", szModel);
return modelinfo->GetModelIndex( modelExtracted ? szModel : NULL );
}