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

Use archived gas mixture in gas exchange comparison #32088

Merged
merged 7 commits into from
Sep 30, 2024

Conversation

drakewill-CRL
Copy link
Contributor

@drakewill-CRL drakewill-CRL commented Sep 11, 2024

About the PR

CompareExchange() now allows using archives gases instead of current ones.

Why / Balance

Fixes #32053

Technical details

A flag was added to CompareExchange to let it pick the current air or the archived air value for comparisons. The 2 calls to it were updated to match the new function signature. The function's 2 main arguments were also changed to the parent of both the current and archived air values.

Media

No visible changes

Requirements

Breaking changes

  • In TileAtmosphere, TemperatureArchived and MolesArchived have been rolled into AirArchived. Use AirArchived.Temperature and AirArchived.Moles to access these fields, respectively.

Changelog

🆑

  • fix: Fix error in gas exchange processing order.

@drakewill-CRL drakewill-CRL marked this pull request as ready for review September 11, 2024 20:48
@github-actions github-actions bot added the Status: Needs Review This PR requires new reviews before it can be merged. label Sep 11, 2024
@ScarKy0
Copy link
Contributor

ScarKy0 commented Sep 11, 2024

it was DIRECTIONAL??

@mirrorcult
Copy link
Contributor

comment on the function should change since it takes tileatmosphere instead of gasmixture now

@lzk228
Copy link
Contributor

lzk228 commented Sep 11, 2024

your cl is broken, should have 🆑 symbol

@Partmedia
Copy link
Contributor

Thanks for the investigation and fix. From a code perspective, I think it would be cleaner, easier to understand, and more testable if you left the old CompareExchange as-is and wrapped a new function around it. It could even overload CompareExchange but with TileAtmosphere arguments (though I think overloading makes it harder for humans to understand).

That would permit you to remove the bool useArchived = false optional parameter, since the only two callers have been modified to set that to true.

@Partmedia
Copy link
Contributor

Do you happen to have a minimal map that demonstrates the issue and how the changes fix it?

@Ilya246
Copy link
Contributor

Ilya246 commented Sep 29, 2024

Do you happen to have a minimal map that demonstrates the issue and how the changes fix it?

i'm pretty sure this bug causes burns in closed room to just completely break and have one tile hitting tempcap and an adjacent tile being at like 100C, this is not exaggerated, this probably wasn't reported yet because i am lazy and because nobody else does closed burns of the required kind

@deltanedas
Copy link
Contributor

i reported it ages ago

@Partmedia
Copy link
Contributor

i reported it ages ago

Mind giving me a minimum reproducible map file for me to test this fix?

@deltanedas
Copy link
Contributor

it doesnt need a map just fill a 3x3 or larger chamber with burn mix, ignite the center and watch the center burn and sides stay at 20C until the reaction ends via fuel or tempcap (needs diffusing more fuel from adjacent tiles)

@Partmedia
Copy link
Contributor

I tested this and this patch does not appear to fix @deltanedas 's problem. I would be curious what problem this patch actually fixes and if there's a minimal map that demonstrates this patch fixing that issue.

image

@Partmedia
Copy link
Contributor

I'd like to add that this patch nevertheless seems correct and we should probably merge it with the suggested changes. I just want to make sure we all understand what is actually being fixed and have a way to validate that.

@Partmedia
Copy link
Contributor

The reason I had suggested this change was to prevent unnecessary code duplication between the two methods. Now I see why this is: TileAtmosphere has a GasMixture but MolesArchived does not. I wonder if there's a way to clean this up.

@Partmedia
Copy link
Contributor

It seems to me that the most reasonable way to handle this would be to replace TileAtmosphere.TemperatureArchived and TileAtmosphere.MolesArchived with TileAtmosphere.AirArchived which would be a GasMixture like TileAtmosphere.Air.

@Partmedia
Copy link
Contributor

Would you mind taking a look at the updated diff and double checking that this still fixes the linked bug?

@drakewill-CRL
Copy link
Contributor Author

Yes, you're passing in and handling the archived data, so that diff should resolve the issue.

@Partmedia Partmedia changed the title fix atmos being directional Use archived gas mixture in gas exchange comparison Sep 30, 2024
@Partmedia Partmedia merged commit 7cf04dc into space-wizards:master Sep 30, 2024
11 checks passed
@Partmedia
Copy link
Contributor

Thanks!

@LemonInTheDark
Copy link

it was DIRECTIONAL??

Assume we have a turf surrounded by 4 mixes that differ from it by idk 10%
Because we compare and then share with each in a loop, using non archived moles means each successive compare will see a smaller and smaller delta. At some point this hits 0, when in reality the numbers we would SHARE against (the archive) are still at that 10% number.
This leads to a failed share for 1 tick, often then becoming possible next iteration due to other gas moving.

On /tg/ this biased gas flow to the north east, because that's the order we fill out atmos_adjacent_turfs as a list.
Note: this was only a problem on the initial turf interaction, once a turf becomes active it will always share with its neighbors, compare exists just as a way to gate small deltas spreading out forever.

@Ilya246
Copy link
Contributor

Ilya246 commented Sep 30, 2024

what delta described can also happen the other way, chamber center stays 800C but sides go tempcap

Ilya246 pushed a commit to Ilya246/space-station-14 that referenced this pull request Oct 7, 2024
)

The comparison for doing gas exchange used current and not archived
moles. This could lead to update order-dependent gas spreading effects.

To fix this, convert TileAtmosphere's MolesArchived and
TemperatureArchived to a AirArchived, and use that in the comparison
method.

---------

Co-authored-by: PraxisMapper <[email protected]>
Co-authored-by: Kevin Zheng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Atmos Status: Needs Review This PR requires new reviews before it can be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Your implementation of LINDA has a broken comparison check
9 participants