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

Fix exception when telepad system plays beam animations #33010

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eoineoineoin
Copy link
Contributor

@eoineoineoin eoineoineoin commented Oct 26, 2024

About the PR

Fixes an exception raised when an order was sent to a cargo telepad.

Why / Balance

Less runtime errors, please.

Technical details

Content.Client.Cargo.Systems.CargoSystem.OnChangeData was reentrant, but did not handle this correctly.

When the appearancechanged event was raised, sending the component into a CargoTelepadState.Teleporting state, the code previously:

  1. Checked if TelepadBeamKey was playing, and if so, early-out
  2. Stop playing TelepadIdleKey
  3. Play TelepadBeamKey

However, inside step 2, an AnimationCompletedEvent is raised, which calls OnChangeData() again (i.e. running steps 1-3). When that completes and we attempt to execute 3, the animation is already playing, raising an exception because the early-out in step 1 was invalidated:

[DEBG] root: Switching to state Content.Client.Gameplay.GameplayState
Unhandled exception. System.ArgumentException: An item with the same key has already been added. Key: cargo-telepad-beam
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Robust.Client.GameObjects.AnimationPlayerSystem.Play(Entity`1 ent, Animation animation, String key) in /home/eoin/code/space-station-14/RobustToolbox/Robust.Client/GameObjects/EntitySystems/AnimationPlayerSystem.cs:line 154
   at Robust.Client.GameObjects.AnimationPlayerSystem.Play(EntityUid uid, AnimationPlayerComponent component, Animation animation, String key) in /home/eoin/code/space-station-14/RobustToolbox/Robust.Client/GameObjects/EntitySystems/AnimationPlayerSystem.cs:line 99
   at Content.Client.Cargo.Systems.CargoSystem.OnChangeData(EntityUid uid, SpriteComponent sprite) in /home/eoin/code/space-station-14/Content.Client/Cargo/Systems/CargoSystem.Telepad.cs:line 79
   at Content.Client.Cargo.Systems.CargoSystem.OnCargoAppChange(EntityUid uid, CargoTelepadComponent component, AppearanceChangeEvent& args) in /home/eoin/code/space-station-14/Content.Client/Cargo/Systems/CargoSystem.Telepad.cs:line 57
   at Robust.Shared.GameObjects.EntityEventBus.<>c__DisplayClass56_0`2.<SubscribeLocalEvent>g__EventHandler|0(EntityUid uid, IComponent comp, TEvent& args) in /home/eoin/code/space-station-14/RobustToolbox/Robust.Shared/GameObjects/EntityEventBus.Directed.cs:line 305

Media

Requirements

Breaking changes

Changelog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant