From 6c6360e50af3a99bbbf36629fb067e482f84d4cb Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Wed, 3 Jan 2024 00:06:10 -0500 Subject: [PATCH] Avoid calling `DirtyEntity()` when repeatedly dirtying the same component. (#4797) --- Robust.Shared/GameObjects/EntityManager.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Robust.Shared/GameObjects/EntityManager.cs b/Robust.Shared/GameObjects/EntityManager.cs index 49380916a..2bb03819f 100644 --- a/Robust.Shared/GameObjects/EntityManager.cs +++ b/Robust.Shared/GameObjects/EntityManager.cs @@ -369,6 +369,9 @@ namespace Robust.Shared.GameObjects if (component.LifeStage >= ComponentLifeStage.Removing || !component.NetSyncEnabled) return; + if (component.LastModifiedTick == CurrentTick) + return; + DirtyEntity(uid, meta); component.LastModifiedTick = CurrentTick; } @@ -382,6 +385,9 @@ namespace Robust.Shared.GameObjects if (ent.Comp.LifeStage >= ComponentLifeStage.Removing || !ent.Comp.NetSyncEnabled) return; + if (ent.Comp.LastModifiedTick == CurrentTick) + return; + DirtyEntity(ent, meta); ent.Comp.LastModifiedTick = CurrentTick; }