]> git.smokeofanarchy.ru Git - space-station-14.git/commit
Solution precision fixes (#25199)
authorPieter-Jan Briers <pieterjan.briers+git@gmail.com>
Fri, 16 Feb 2024 23:54:27 +0000 (00:54 +0100)
committerGitHub <noreply@github.com>
Fri, 16 Feb 2024 23:54:27 +0000 (16:54 -0700)
commit33611b7094ba9540326a6f0f6edd2017640e61db
tree20902864e30eebd7274ba52d5327e68cb4bfb796
parentc7870882f6f956eea07cbb4738ae45c8805c8ce6
Solution precision fixes (#25199)

* Add test for two chemistry issues

1. rounding issue with reaction processing when making chloral hydrate
2. reliable assert trip due to the ValidateSolution() heat capacity issue.

* Fix FixedPoint2 arithmetic

Fix internal floating point arithmetic in places where it could be avoided.

Fix incorrect rounding mode used in other places (it should always floor, like regular int arithmetic).

I had to add an explicit epsilon value for float -> FixedPoint2 because something like 1.05 is actually like 1.04999 and that'd cause it to be rounded down to 1.04.

This fixes reaction reagent processing in cases where the reagent inputs can't cleanly divide. Previously, when making 30u chloral hydrate by adding the chlorine in 10u increments you'd end up with 0.04 chlorine left over. This was caused by division in the reaction code rounding up in some cases. Changing division here to always round down fixes it.

* Attempt to fix heat capacity precision assert issues.

Fixes #22126

First, we just increase the tolerance of the assert. It was way too low.

Second, actually put a cap on float drift from one-off _heatCapacity changes.

* Fix float -> FixedPoint2 epsilon for negative number, fix tests.

* Fix DamageableTest

* Oh yeah I need to call CleanReturnAsync
Content.IntegrationTests/Tests/Chemistry/SolutionRoundingTest.cs [new file with mode: 0644]
Content.IntegrationTests/Tests/Damageable/DamageableTest.cs
Content.Shared/Chemistry/Components/Solution.cs
Content.Shared/FixedPoint/FixedPoint2.cs
Content.Tests/Shared/Chemistry/FixedPoint2_Tests.cs
Content.Tests/Shared/DamageTest.cs