Skip to content

Commit

Permalink
Simplify CBreakableGibShooter::GetRandomTemplateModelIndex
Browse files Browse the repository at this point in the history
MapEntity_ExtractValue(), as opposed to CEntityMapData, does not require
a mutable string.
  • Loading branch information
z33ky committed Apr 26, 2021
1 parent de31b7a commit 8186644
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions sp/src/game/server/effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down

0 comments on commit 8186644

Please sign in to comment.