From da52e557902c6aaea14e6f19ec4ef87f878c4103 Mon Sep 17 00:00:00 2001 From: march <106459595+marchc1@users.noreply.github.com> Date: Fri, 16 Oct 2026 13:52:37 -0700 Subject: [PATCH] Fix ClientEntityList not having OnRemoveEntity override --- Game.Client/ClientEntityList.cs | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Game.Client/ClientEntityList.cs b/Game.Client/ClientEntityList.cs index 32360004e..3c063110a 100644 --- a/Game.Client/ClientEntityList.cs +++ b/Game.Client/ClientEntityList.cs @@ -170,6 +170,41 @@ protected override void OnAddEntity(IHandleEntity? ent, BaseHandle handle) { cache.LinkedListNode = null; } + protected override void OnRemoveEntity(IHandleEntity? ent, BaseHandle handle) { + int entnum = handle.GetEntryIndex(); + + if (entnum < 0 || entnum >= Constants.NUM_ENT_ENTRIES) + return; + + ref EntityCacheInfo_t cache = ref EntityCacheInfo[entnum]; + + if (entnum < Constants.MAX_EDICTS) { + cache.Networkable = null!; + NumServerEnts--; + + if (entnum >= MaxUsedServerIndex) { + while (MaxUsedServerIndex >= 0 && EntityCacheInfo[MaxUsedServerIndex].Networkable == null) + MaxUsedServerIndex--; + } + } + + IClientUnknown? unknown = (IClientUnknown?)ent; + RemovePVSNotifier(unknown); + + C_BaseEntity? baseEntity = unknown.GetBaseEntity(); + if (baseEntity != null) { + if ((baseEntity.ObjectCaps() & EntityCapabilities.SaveNonNetworkable) != 0) + NumClientNonNetworkable--; + + for (int i = EntityListeners.Count() - 1; i >= 0; i--) + EntityListeners[i].OnEntityDeleted(baseEntity); + } + + if (cache.LinkedListNode?.List != null) + BaseEntities.Remove(cache.LinkedListNode); + cache.LinkedListNode = null; + } + int NumServerEnts; int MaxServerEnts; int NumClientNonNetworkable;