Skip to content

Commit 3d9a68e

Browse files
committed
game\server: ent_set_name should work with 1 or 2 args
See ValveSoftware/source-sdk-2013#1217 ValveSoftware/source-sdk-2013#1221
1 parent 1ceeef1 commit 3d9a68e

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

game/server/baseentity.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5208,7 +5208,8 @@ void CC_Ent_SetName( const CCommand& args )
52085208
{
52095209
CBaseEntity *pEntity = NULL;
52105210

5211-
if ( args.ArgC() < 1 )
5211+
// dimhotepus: Should be at least 1 argument.
5212+
if ( args.ArgC() < 2 )
52125213
{
52135214
CBasePlayer *pPlayer = ToBasePlayer( UTIL_GetCommandClient() );
52145215
if (!pPlayer)
@@ -5229,14 +5230,22 @@ void CC_Ent_SetName( const CCommand& args )
52295230
CBaseEntity *ent = NULL;
52305231
while ( (ent = gEntList.NextEnt(ent)) != NULL )
52315232
{
5232-
if ( (ent->GetEntityName() != NULL_STRING && FStrEq(args[1], STRING(ent->GetEntityName()))) ||
5233-
(ent->m_iClassname != NULL_STRING && FStrEq(args[1], STRING(ent->m_iClassname))) ||
5234-
(ent->GetClassname()!=NULL && FStrEq(args[1], ent->GetClassname())))
5233+
// dimhotepus: Honor second arg for entity name
5234+
if ( (ent->GetEntityName() != NULL_STRING && FStrEq(args[2], STRING(ent->GetEntityName()))) ||
5235+
(ent->m_iClassname != NULL_STRING && FStrEq(args[2], STRING(ent->m_iClassname))) ||
5236+
(ent->GetClassname()!=NULL && FStrEq(args[2], ent->GetClassname())))
52355237
{
52365238
pEntity = ent;
52375239
break;
52385240
}
52395241
}
5242+
5243+
if ( !pEntity )
5244+
{
5245+
// dimhotepus: Notify if we don't set the name.
5246+
Warning( "No such entity with name %s found to set new name for.\n", args[2] );
5247+
return;
5248+
}
52405249
}
52415250

52425251
// Found one?

0 commit comments

Comments
 (0)