Fixes error in SafeRemoveEntity/SafeRemoveEntityDelayed under certain circumstances #769

Merged
merged 2 commits into from Jul 31, 2014

Projects

None yet

2 participants

@Acecool
Contributor
Acecool commented Jul 22, 2014

Fixes issue when using SafeRemoveEntity/SafeRemoveEntityDelayed giving error on "[ERROR] lua/uncludes/util.lua:184/195: attempt to call method 'IsValid' (a nil value)" under certain circumstances when an entity is removed ( either several times using SafeRemoveEntity / Remove combo, or when trying to remove a swep that has been removed / was in the process of being removed or when trying to remove a swep that was just holstered ).

Adjusted SafeRemoveEntityDelayed spacing to match SafeRemoveEntity.

@Acecool Acecool Fixes issue when using SafeRemoveEntity/SafeRemoveEntityDelayed givin…
…g error on "[ERROR] lua/uncludes/util.lua:184/195: attempt to call method 'IsValid' (a nil value)" under certain circumstances when an entity is removed ( either several times using SafeRemoveEntity / Remove combo, or when trying to remove a swep that has been removed / was in the process of being removed or when trying to remove a swep that was just holstered ).
13121b8
@robotboy655
Collaborator

Replace the whole

!ent || ( ent.IsValid && !ent:IsValid() )

with

!IsValid( ent )
@Acecool Acecool Per Robot, altered "Replace the whole
!ent || ( ent.IsValid && !ent:IsValid() )
with
!IsValid( ent )"

Additionally, SafeRemoveEntityDelayed calls SafeRemoveEntity so ent:IsPlayer( ) isn't needed, but to prevent an extra timer from being created for an entity we won't remove anyway, I added that check.
cf37632
@Acecool
Contributor
Acecool commented Jul 23, 2014

Done, I wasn't paying attention to that for the first pull. I also changed the SafeRemoveEntityDelayed to also test to see if the entity IsPlayer so we aren't creating a timer for an entity that won't be removed anyway.

@robotboy655 robotboy655 merged commit 7eaa3cb into garrynewman:master Jul 31, 2014
@Acecool Acecool deleted the unknown repository branch Jul 31, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment