FakeFishGames / Barotrauma

A 2D online multiplayer game taking place in a submarine travelling through the icy depths of Jupiter's moon Europa.
http://www.barotraumagame.com/
1.74k stars 404 forks source link

Memory component inconsistencies #12987

Closed DarthPointer closed 10 months ago

DarthPointer commented 11 months ago

Disclaimers

What happened?

Memory component behaviour seems to be volatile to installation order or other irrelevant-context things. Edge cases may involve the circuit boxes changing their behaviour after removing the component and placing it back in the editor test run.

I was trying to setup logics for an airlock, but the components did not behave as I expected them to. In the process I have found 2 issues.

Reproduction steps

Delayed memory update:

Glitched memory component:

Note that in the editor the mem component in question is set to always accept new values. Attaching a display to its output gives a pulse reading according to button hits, even prior to the replacement. Copy-pasting the related buttons and circuit boxes into a new submarine makes the replacement not fix the issue completely, which may or may not be an issue on the side CB schematics.

Just in case, the undervoltage event that happens a few seconds with this boat in simulation is not connected with the issue.

Bug prevalence

Happens every time I play

Single player or multiplayer?

Other

-

Sub editor tests (not tested it outside the editor)

Version

v1.1.19.3 (Treacherous Tides Hotfix 2)

-

No response

Which operating system did you encounter this bug on?

Windows

Relevant error messages and crash reports

No response

Regalis11 commented 11 months ago

Thank you for the report!

This sounds like the known issue of the order of signals sometimes affecting circuit behavior. Since this seems to come up periodically, I decided to make a kind of "general ticket" explaining why this happens.

In this case, I'm not entirely sure what the expected behavior would be. In the first circuit for example, you're locking the memory component at the same time as setting the value. Which one should take precedence? In my opinion, it's arguably correct that the behavior of the circuit is unpredictable.

DarthPointer commented 11 months ago

@Regalis11 Regarding the first circuit - there is no direct control over the signal order provided by the ingame tools, thus the components should behave connection-order-invariant. Otherwise the components would be impossible to use reliably without the routine overhead of timing management, that will just bloat the schemes and make the entire signals system too frustrating to deal with.

The second case likely is another symptom of signal orders, and it doubles down on lack of tools to view and control the timings.

Regalis11 commented 11 months ago

I get where you're coming from, but the way I see it, this circuit is doing something that doesn't make much sense: it's telling the memory component to store a value and to not store a value (= lock the state) at the same time. What would the expected behavior be here?

But anyway, I agree that even if there wasn't a "correct" answer to how it should behave, it could make sense to add some kind of a rule that makes the behavior consistent. But we would need to figure out what that rule would be, what takes precedence when multiple signals are interfering with each other?

Regalis11 commented 10 months ago

Closing as a duplicate of https://github.com/Regalis11/Barotrauma/issues/12993, I think the discussion can be continued there