Skip to content

Commit ae3973f

Browse files
committed
ecs: fix cleaning up player on exception on disconnect
1 parent 219531a commit ae3973f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/SampSharp.Entities/SAMP/Middleware/PlayerDisconnectMiddleware.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,15 @@ public object Invoke(EventContext context, IEntityManager entityManager)
3333

3434
context.Arguments[0] = entity;
3535

36-
var result = _next(context);
37-
38-
entityManager.Destroy(entity);
39-
40-
return result;
36+
try
37+
{
38+
var result = _next(context);
39+
40+
return result;
41+
}
42+
finally
43+
{
44+
entityManager.Destroy(entity);
45+
}
4146
}
4247
}

0 commit comments

Comments
 (0)