Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup: Dirty(Comp) #26238

Merged
merged 5 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Content.Client/Weather/WeatherSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ protected override void Run(EntityUid uid, WeatherData weather, WeatherPrototype
comp.Occlusion = occlusion;
}

protected override bool SetState(WeatherState state, WeatherComponent comp, WeatherData weather, WeatherPrototype weatherProto)
protected override bool SetState(EntityUid uid, WeatherState state, WeatherComponent comp, WeatherData weather, WeatherPrototype weatherProto)
{
if (!base.SetState(state, comp, weather, weatherProto))
if (!base.SetState(uid, state, comp, weather, weatherProto))
return false;

if (!Timing.IsFirstTimePredicted)
Expand Down Expand Up @@ -164,7 +164,7 @@ private void OnWeatherHandleState(EntityUid uid, WeatherComponent component, ref
continue;

// New weather
StartWeather(component, ProtoMan.Index<WeatherPrototype>(proto), weather.EndTime);
StartWeather(uid, component, ProtoMan.Index<WeatherPrototype>(proto), weather.EndTime);
}
}
}
26 changes: 13 additions & 13 deletions Content.IntegrationTests/Tests/Tag/TagTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ await server.WaitAssertion(() =>
Assert.Multiple(() =>
{
// Cannot add the starting tag again
Assert.That(tagSystem.AddTag(sTagComponent, StartingTag), Is.False);
Assert.That(tagSystem.AddTags(sTagComponent, StartingTag, StartingTag), Is.False);
Assert.That(tagSystem.AddTags(sTagComponent, new List<string> { StartingTag, StartingTag }), Is.False);
Assert.That(tagSystem.AddTag(sTagDummy, sTagComponent, StartingTag), Is.False);
Assert.That(tagSystem.AddTags(sTagDummy, sTagComponent, StartingTag, StartingTag), Is.False);
Assert.That(tagSystem.AddTags(sTagDummy, sTagComponent, new List<string> { StartingTag, StartingTag }), Is.False);

// Has the starting tag
Assert.That(tagSystem.HasTag(sTagComponent, StartingTag), Is.True);
Expand All @@ -157,22 +157,22 @@ await server.WaitAssertion(() =>
Assert.That(tagSystem.HasAllTags(sTagComponent, new List<string> { StartingTag, AddedTag }), Is.False);

// Cannot remove a tag that does not exist
Assert.That(tagSystem.RemoveTag(sTagComponent, AddedTag), Is.False);
Assert.That(tagSystem.RemoveTags(sTagComponent, AddedTag, AddedTag), Is.False);
Assert.That(tagSystem.RemoveTags(sTagComponent, new List<string> { AddedTag, AddedTag }), Is.False);
Assert.That(tagSystem.RemoveTag(sTagDummy, sTagComponent, AddedTag), Is.False);
Assert.That(tagSystem.RemoveTags(sTagDummy, sTagComponent, AddedTag, AddedTag), Is.False);
Assert.That(tagSystem.RemoveTags(sTagDummy, sTagComponent, new List<string> { AddedTag, AddedTag }), Is.False);
});

// Can add the new tag
Assert.That(tagSystem.AddTag(sTagComponent, AddedTag), Is.True);
Assert.That(tagSystem.AddTag(sTagDummy, sTagComponent, AddedTag), Is.True);

Assert.Multiple(() =>
{
// Cannot add it twice
Assert.That(tagSystem.AddTag(sTagComponent, AddedTag), Is.False);
Assert.That(tagSystem.AddTag(sTagDummy, sTagComponent, AddedTag), Is.False);

// Cannot add existing tags
Assert.That(tagSystem.AddTags(sTagComponent, StartingTag, AddedTag), Is.False);
Assert.That(tagSystem.AddTags(sTagComponent, new List<string> { StartingTag, AddedTag }), Is.False);
Assert.That(tagSystem.AddTags(sTagDummy, sTagComponent, StartingTag, AddedTag), Is.False);
Assert.That(tagSystem.AddTags(sTagDummy, sTagComponent, new List<string> { StartingTag, AddedTag }), Is.False);

// Now has two tags
Assert.That(sTagComponent.Tags, Has.Count.EqualTo(2));
Expand All @@ -191,16 +191,16 @@ await server.WaitAssertion(() =>
Assert.Multiple(() =>
{
// Remove the existing starting tag
Assert.That(tagSystem.RemoveTag(sTagComponent, StartingTag), Is.True);
Assert.That(tagSystem.RemoveTag(sTagDummy, sTagComponent, StartingTag), Is.True);

// Remove the existing added tag
Assert.That(tagSystem.RemoveTags(sTagComponent, AddedTag, AddedTag), Is.True);
Assert.That(tagSystem.RemoveTags(sTagDummy, sTagComponent, AddedTag, AddedTag), Is.True);
});

Assert.Multiple(() =>
{
// No tags left to remove
Assert.That(tagSystem.RemoveTags(sTagComponent, new List<string> { StartingTag, AddedTag }), Is.False);
Assert.That(tagSystem.RemoveTags(sTagDummy, sTagComponent, new List<string> { StartingTag, AddedTag }), Is.False);

// No tags left in the component
Assert.That(sTagComponent.Tags, Is.Empty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,13 +638,13 @@ private void AddSmiteVerbs(GetVerbsEvent<Verb> args)
{
Text = "Remove gravity",
Category = VerbCategory.Smite,
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Structures/Machines/gravity_generator.rsi"), "off"),
Icon = new SpriteSpecifier.Rsi(new("/Textures/Structures/Machines/gravity_generator.rsi"), "off"),
Act = () =>
{
var grav = EnsureComp<MovementIgnoreGravityComponent>(args.Target);
grav.Weightless = true;

Dirty(grav);
Dirty(args.Target, grav);
},
Impact = LogImpact.Extreme,
Message = Loc.GetString("admin-smite-remove-gravity-description"),
Expand Down Expand Up @@ -741,7 +741,7 @@ private void AddSmiteVerbs(GetVerbsEvent<Verb> args)
var movementSpeed = EnsureComp<MovementSpeedModifierComponent>(args.Target);
(movementSpeed.BaseSprintSpeed, movementSpeed.BaseWalkSpeed) = (movementSpeed.BaseWalkSpeed, movementSpeed.BaseSprintSpeed);

Dirty(movementSpeed);
Dirty(args.Target, movementSpeed);

_popupSystem.PopupEntity(Loc.GetString("admin-smite-run-walk-swap-prompt"), args.Target,
args.Target, PopupType.LargeCaution);
Expand Down
6 changes: 3 additions & 3 deletions Content.Server/Atmos/EntitySystems/AtmosphereSystem.Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void SetMapAtmosphere(EntityUid uid, bool space, GasMixture mixture, MapA

component.Space = space;
component.Mixture = mixture;
Dirty(component);
Dirty(uid, component);
}

public void SetMapGasMixture(EntityUid uid, GasMixture? mixture, MapAtmosphereComponent? component = null)
Expand All @@ -67,7 +67,7 @@ public void SetMapGasMixture(EntityUid uid, GasMixture? mixture, MapAtmosphereCo
return;

component.Mixture = mixture;
Dirty(component);
Dirty(uid, component);
}

public void SetMapSpace(EntityUid uid, bool space, MapAtmosphereComponent? component = null)
Expand All @@ -76,6 +76,6 @@ public void SetMapSpace(EntityUid uid, bool space, MapAtmosphereComponent? compo
return;

component.Space = space;
Dirty(component);
Dirty(uid, component);
}
}
8 changes: 4 additions & 4 deletions Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ private void ActivateAnalyzer(EntityUid uid, GasAnalyzerComponent component, Ent
else
component.LastPosition = null;
component.Enabled = true;
Dirty(component);
Dirty(uid, component);
UpdateAppearance(uid, component);
if(!HasComp<ActiveGasAnalyzerComponent>(uid))
if (!HasComp<ActiveGasAnalyzerComponent>(uid))
AddComp<ActiveGasAnalyzerComponent>(uid);
UpdateAnalyzer(uid, component);
}
Expand All @@ -105,7 +105,7 @@ private void ActivateAnalyzer(EntityUid uid, GasAnalyzerComponent component, Ent
/// </summary>
private void OnDropped(EntityUid uid, GasAnalyzerComponent component, DroppedEvent args)
{
if(args.User is var userId && component.Enabled)
if (args.User is var userId && component.Enabled)
_popup.PopupEntity(Loc.GetString("gas-analyzer-shutoff"), userId, userId);
DisableAnalyzer(uid, component, args.User);
}
Expand All @@ -122,7 +122,7 @@ private void DisableAnalyzer(EntityUid uid, GasAnalyzerComponent? component = nu
_userInterface.TryClose(uid, GasAnalyzerUiKey.Key, actor.PlayerSession);

component.Enabled = false;
Dirty(component);
Dirty(uid, component);
UpdateAppearance(uid, component);
RemCompDeferred<ActiveGasAnalyzerComponent>(uid);
}
Expand Down
12 changes: 7 additions & 5 deletions Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ private void OnPvsToggle(bool value)
}

// PVS was turned off, ensure data gets sent to all clients.
foreach (var (grid, meta) in EntityQuery<GasTileOverlayComponent, MetaDataComponent>(true))
var query = EntityQueryEnumerator<GasTileOverlayComponent, MetaDataComponent>();
while (query.MoveNext(out var uid, out var grid, out var meta))
{
grid.ForceTick = _gameTiming.CurTick;
Dirty(grid, meta);
Dirty(uid, grid, meta);
}
}

Expand Down Expand Up @@ -264,9 +265,10 @@ private bool UpdateChunkTile(GridAtmosphereComponent gridAtmosphere, GasOverlayC
private void UpdateOverlayData(GameTick curTick)
{
// TODO parallelize?
foreach (var (overlay, gam, meta) in EntityQuery<GasTileOverlayComponent, GridAtmosphereComponent, MetaDataComponent>(true))
var query = EntityQueryEnumerator<GasTileOverlayComponent, GridAtmosphereComponent, MetaDataComponent>();
while (query.MoveNext(out var uid, out var overlay, out var gam, out var meta))
{
bool changed = false;
var changed = false;
foreach (var index in overlay.InvalidTiles)
{
var chunkIndex = GetGasChunkIndices(index);
Expand All @@ -278,7 +280,7 @@ private void UpdateOverlayData(GameTick curTick)
}

if (changed)
Dirty(overlay, meta);
Dirty(uid, overlay, meta);

overlay.InvalidTiles.Clear();
}
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/BarSign/Systems/BarSignSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private void OnMapInit(EntityUid uid, BarSignComponent component, MapInitEvent a
_metaData.SetEntityDescription(uid, Loc.GetString(newPrototype.Description), meta);

component.Current = newPrototype.ID;
Dirty(component);
Dirty(uid, component);
}
}
}
4 changes: 2 additions & 2 deletions Content.Server/Clothing/Systems/ChameleonClothingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private void OnVerb(EntityUid uid, ChameleonClothingComponent component, GetVerb
args.Verbs.Add(new InteractionVerb()
{
Text = Loc.GetString("chameleon-component-verb-text"),
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/settings.svg.192dpi.png")),
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/settings.svg.192dpi.png")),
Act = () => TryOpenUi(uid, args.User, component)
});
}
Expand Down Expand Up @@ -91,7 +91,7 @@ public void SetSelectedPrototype(EntityUid uid, string? protoId, bool forceUpdat
UpdateIdentityBlocker(uid, component, proto);
UpdateVisuals(uid, component);
UpdateUi(uid, component);
Dirty(component);
Dirty(uid, component);
}

private void UpdateIdentityBlocker(EntityUid uid, ChameleonClothingComponent component, EntityPrototype proto)
Expand Down
5 changes: 3 additions & 2 deletions Content.Server/Decals/DecalSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ private void OnPvsToggle(bool value)
playerData.Clear();
}

foreach (var (grid, meta) in EntityQuery<DecalGridComponent, MetaDataComponent>(true))
var query = EntityQueryEnumerator<DecalGridComponent, MetaDataComponent>();
while (query.MoveNext(out var uid, out var grid, out var meta))
{
grid.ForceTick = _timing.CurTick;
Dirty(grid, meta);
Dirty(uid, grid, meta);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ private void SetMode(EntityUid configuratorUid, NetworkConfiguratorComponent con
/// </summary>
private void UpdateModeAppearance(EntityUid userUid, EntityUid configuratorUid, NetworkConfiguratorComponent configurator)
{
Dirty(configurator);
Dirty(configuratorUid, configurator);
_appearanceSystem.SetData(configuratorUid, NetworkConfiguratorVisuals.Mode, configurator.LinkModeActive);

var pitch = configurator.LinkModeActive ? 1 : 0.8f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ private void OnPowerChange(EntityUid uid, SharedDisposalUnitComponent component,
if (!args.Powered)
{
component.NextFlush = null;
Dirty(component);
Dirty(uid, component);
return;
}

Expand Down Expand Up @@ -396,7 +396,7 @@ private void UpdateState(EntityUid uid, DisposalsPressureState state, SharedDisp
component.State = state;
UpdateVisualState(uid, component);
UpdateInterface(uid, component, component.Powered);
Dirty(component, metadata);
Dirty(uid, component, metadata);

if (state == DisposalsPressureState.Ready)
{
Expand Down Expand Up @@ -477,7 +477,7 @@ private void Update(EntityUid uid, SharedDisposalUnitComponent component, MetaDa
}

if (count != component.RecentlyEjected.Count)
Dirty(component, metadata);
Dirty(uid, component, metadata);
}

public bool TryInsert(EntityUid unitId, EntityUid toInsertId, EntityUid? userId, DisposalUnitComponent? unit = null)
Expand Down Expand Up @@ -783,7 +783,7 @@ public void QueueAutomaticEngage(EntityUid uid, SharedDisposalUnitComponent comp
var flushTime = TimeSpan.FromSeconds(Math.Min((component.NextFlush ?? TimeSpan.MaxValue).TotalSeconds, automaticTime.TotalSeconds));

component.NextFlush = flushTime;
Dirty(component);
Dirty(uid, component);
}

public void AfterInsert(EntityUid uid, SharedDisposalUnitComponent component, EntityUid inserted, EntityUid? user = null, bool doInsert = false)
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Dragon/DragonRiftSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public override void Update(float frameTime)
if (comp.State < DragonRiftState.AlmostFinished && comp.Accumulator > comp.MaxAccumulator / 2f)
{
comp.State = DragonRiftState.AlmostFinished;
Dirty(comp);
Dirty(uid, comp);

var location = xform.LocalPosition;
_chat.DispatchGlobalAnnouncement(Loc.GetString("carp-rift-warning", ("location", location)), playSound: false, colorOverride: Color.Red);
Expand Down
6 changes: 3 additions & 3 deletions Content.Server/Ensnaring/EnsnareableSystem.Ensnaring.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void TryEnsnare(EntityUid target, EntityUid ensnare, EnsnaringComponent c
component.Ensnared = target;
_container.Insert(ensnare, ensnareable.Container);
ensnareable.IsEnsnared = true;
Dirty(ensnareable);
Dirty(target, ensnareable);

UpdateAlert(target, ensnareable);
var ev = new EnsnareEvent(component.WalkSpeed, component.SprintSpeed);
Expand All @@ -107,7 +107,7 @@ public void TryEnsnare(EntityUid target, EntityUid ensnare, EnsnaringComponent c
/// <param name="user">The entity that is freeing the target</param>
/// <param name="ensnare">The entity used to ensnare</param>
/// <param name="component">The ensnaring component</param>
public void TryFree(EntityUid target, EntityUid user, EntityUid ensnare, EnsnaringComponent component)
public void TryFree(EntityUid target, EntityUid user, EntityUid ensnare, EnsnaringComponent component)
{
//Don't do anything if they don't have the ensnareable component.
if (!HasComp<EnsnareableComponent>(target))
Expand Down Expand Up @@ -148,7 +148,7 @@ public void ForceFree(EntityUid ensnare, EnsnaringComponent component)

_container.Remove(ensnare, ensnareable.Container, force: true);
ensnareable.IsEnsnared = ensnareable.Container.ContainedEntities.Count > 0;
Dirty(ensnareable);
Dirty(component.Ensnared.Value, ensnareable);
component.Ensnared = null;

UpdateAlert(target, ensnareable);
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Ensnaring/EnsnareableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void OnDoAfter(EntityUid uid, EnsnareableComponent component, DoAfterEve
}

component.IsEnsnared = component.Container.ContainedEntities.Count > 0;
Dirty(component);
Dirty(uid, component);
ensnaring.Ensnared = null;

_hands.PickupOrDrop(args.Args.User, args.Args.Used.Value);
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Gravity/GravitySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void RefreshGravity(EntityUid uid, GravityComponent? gravity = null)
gravity.Enabled = enabled;
var ev = new GravityChangedEvent(uid, enabled);
RaiseLocalEvent(uid, ref ev, true);
Dirty(gravity);
Dirty(uid, gravity);

if (HasComp<MapGridComponent>(uid))
{
Expand Down Expand Up @@ -71,7 +71,7 @@ public void EnableGravity(EntityUid uid, GravityComponent? gravity = null)
gravity.Enabled = true;
var ev = new GravityChangedEvent(uid, true);
RaiseLocalEvent(uid, ref ev, true);
Dirty(gravity);
Dirty(uid, gravity);

if (HasComp<MapGridComponent>(uid))
{
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/HotPotato/HotPotatoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void OnActiveTimer(EntityUid uid, HotPotatoComponent comp, ref ActiveTim
comp.CanTransfer = false;
_ambientSound.SetAmbience(uid, true);
_damageOnHolding.SetEnabled(uid, true);
Dirty(comp);
Dirty(uid, comp);
}

private void OnMeleeHit(EntityUid uid, HotPotatoComponent comp, MeleeHitEvent args)
Expand All @@ -56,6 +56,6 @@ private void OnMeleeHit(EntityUid uid, HotPotatoComponent comp, MeleeHitEvent ar
break;
}
comp.CanTransfer = false;
Dirty(comp);
Dirty(uid, comp);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void OnVerbsRequest(EntityUid uid, HumanoidAppearanceComponent component
{
Text = "Modify markings",
Category = VerbCategory.Tricks,
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Mobs/Customization/reptilian_parts.rsi"), "tail_smooth"),
Icon = new SpriteSpecifier.Rsi(new("/Textures/Mobs/Customization/reptilian_parts.rsi"), "tail_smooth"),
Act = () =>
{
_uiSystem.TryOpen(uid, HumanoidMarkingModifierKey.Key, actor.PlayerSession);
Expand Down Expand Up @@ -63,7 +63,7 @@ private void OnBaseLayersSet(EntityUid uid, HumanoidAppearanceComponent componen
component.CustomBaseLayers[message.Layer] = message.Info.Value;
}

Dirty(component);
Dirty(uid, component);

if (message.ResendState)
{
Expand All @@ -88,7 +88,7 @@ private void OnMarkingsSet(EntityUid uid, HumanoidAppearanceComponent component,
}

component.MarkingSet = message.MarkingSet;
Dirty(component);
Dirty(uid, component);

if (message.ResendState)
{
Expand Down
Loading
Loading