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