Jump to content

Buildings internal storage wrong heat calculation


Fradow
  • Branch: Live Branch Version: Windows Known Issue

This bug has also been reported for Spaced Out!

I’m reposting here because I’ve taken a bit of time observing details on it, but cannot confirm if those details are identical on DLC (99% chances they are) and the save game provided is in base game.

An exploit has been posted, that deletes or create about 1.6MDTU/s to 2MDTU/s in water temperature range. I used that exact build for reproduction and observation. Credit to @ghkbrew for finding this build.

Let's start with the bug, visualized:

SieveOutputTempExploit.thumb.gif.bf72f630f4688e400782c342a2f2b58f.gif

Here is a save file containing it, just un-pause, and the setup will automatically pause a few seconds after the bug happens. You’ll be able to see cold water being outputted from hot water.
Piped output bug sandbox.sav

At the heart of the issue is what I believe to be a race condition: 2 parts of the game tries to access and modify the same thing at the same time, resulting in both seeing the initial value, but ignoring each other's changes during calculations.

Those 2 parts are:

  • The internal storage of buildings (coded in C#, moddable)
  • The temperature calculation of elements (coded in C++, in the Sim, non-moddable)

Basically, what happens, with the Water Sieve example:

  1. The internal storage has 0kg of cold water
  2. The building converts some water, and input 5kg of hot water into the storage
  3. During the frame the water is outputted, just before it is taken out of internal storage, the temperature calculation algorithm somehow transforms those 5kg of hot water into 5kg of cold water. That’s the bug.
  4. Now you have 5kg of cold water in the internal storage
  5. That cold water is outputted to the pipe output during the same frame as temperature calculation, and you know have 0kg of cold water
  6. Rinse and repeat

What exactly is the bug?

It’s hard to say, since it comes from the Sim. The Sim could be using an invalid Mass, an invalid Temperature, both, or a corrupted cache value.

While the example exploit shows a build with a Water Sieve, it’s not limited to that, but should include every building with an internal storage and a piped output. I’ve seen this happen with the Desalinator and Oil Refinery as well.

The exploit explained shows heat deletion, but you can also create heat by doing the inverse. You could for example get 400°C Petroleum out of 90°C Crude Oil, and there are probably other ways to exploit it that the community hasn't discovered yet.

Why is it important?

Apart from exploit potential, it happens randomly to players who play the game as expected and don't understand why sometimes the water output of their Water Sieve is widely different from the input, deleting or creating heat in the process. There has been other instances of beginners being hit by this bug.

As for the exploit shown, it deletes about between 1.6MDTU/s to 2MDTU/s depending on how close to water temperature range you get. The equivalent of 20 AETN, for the low, low cost of 120W.


How to fix that bug?
A quick-fix can be done by not keeping a zero-mass object. I’ve confirmed it works, but it’s going to have a performance impact, since it was obviously kept for performance reasons. To confirm yourself, uncomment the commented patch in the provided mod to run any save with patched internal storage.
A real fix would be to fix the temperature calculation on internal storage. I suspect something is really off because the bug shows on the UI even when there is nothing being passed through.

SieveOutputBuggedStorage.thumb.gif.d0d57fcb92f8b5aad55b1e868db29041.gif

More technical details.

To acquire that many details, I used a mission-specific mod. That mod is specific to the save file included above as it uses hard-coded values to log only what’s relevant.
Here is the mod, configured in “logging” mode:
Water Temperature Observer.zip

Here is the unpolished source file for that mod, which contains, commented out, the quick-fix mentioned above, that remove the instruction to keep zero-mass elements. You need to uncomment and rebuild the mod (note: not tested on DLC/mergedown). The bug won’t trigger anymore with that patch.
Patches.cs

When we look at the log output, the bug is also very visible, and always happen the same way. Left is a sequence without the bug, and right is a sequence with the bug happening. I've annotated what happens, and circled cold temps in blue and hot temps in red.

without_bugs_log.thumb.png.1517d33712d398c75fe7a2ff6d129e6e.pngbug_log.thumb.png.3f2a97f9ec62db34514b694d87daecc0.png

 

Special thanks to the modding community for helping me build this mod!


Steps to Reproduce

Load the included save file, unpause. The automated notifier auto-pause the game when the bug is triggered.

What the build does:

  • run cold water through the Water Sieve
  • run hot polluted water through the Water Sieve
  • when the bug triggers, the output for that hot polluted water is cold water (instead of hot water)

There are other, more complicated ways to reproduce that bug.

Included is a full Player.log of that save using the aforementioned mod to have more logging about that specific bug.

 

  • Like 3



User Feedback


Update: in addition to degrading performance, the quick-fix leads to massive Steam/Water deletion in standard Steam Turbine builds.

It should not be used as-is, and will not be integrated to Stock Bug Fix.

Share this comment


Link to comment
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...