File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -5208,7 +5208,8 @@ void CC_Ent_SetName( const CCommand& args )
5208
5208
{
5209
5209
CBaseEntity *pEntity = NULL ;
5210
5210
5211
- if ( args.ArgC () < 1 )
5211
+ // dimhotepus: Should be at least 1 argument.
5212
+ if ( args.ArgC () < 2 )
5212
5213
{
5213
5214
CBasePlayer *pPlayer = ToBasePlayer ( UTIL_GetCommandClient () );
5214
5215
if (!pPlayer)
@@ -5229,14 +5230,22 @@ void CC_Ent_SetName( const CCommand& args )
5229
5230
CBaseEntity *ent = NULL ;
5230
5231
while ( (ent = gEntList .NextEnt (ent)) != NULL )
5231
5232
{
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 ())))
5235
5237
{
5236
5238
pEntity = ent;
5237
5239
break ;
5238
5240
}
5239
5241
}
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
+ }
5240
5249
}
5241
5250
5242
5251
// Found one?
You can’t perform that action at this time.
0 commit comments