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: deconstructing terrain into t_null creates roofs or open air automatically, don't spawn deconstruction results in midair #6164

Merged
merged 5 commits into from
Mar 12, 2025

Conversation

chaosvolt
Copy link
Member

@chaosvolt chaosvolt commented Mar 8, 2025

Purpose of change (The Why)

This is an alternative put together to fix behavior wherein deconstructing stairs creates patches of nothingness. Now with a fix for it dumping the wood down into the hole.

Closes #6141

Fixes #5991

Describe the solution (The How)

  1. In construction.cpp, set construct::done_deconstruct to bother checking whether deconstruct placed t_null and if so, it looks for a potential roof assigned to the terrain on the z-level below it to use instead via get_roof, which in the case of stairs should create open air if there is a matching bottom stair below it.
  2. Additionally set it so that construct::done_deconstruct checks whether the tile it would normally dump deconstruction items into would be valid (i.e. can hold items and isn't empty space), and if it isn't valid it'll pick a random valid space next to it in the same way construction byproducts are placed. Idea here is this stops it from spawning the deconstruct results directly over the hole that removing the stairs creates, which would promptly fall through and impact the bottom.
  3. In map.h, moved get_roof from private to public because it wouldn't let me use the hidden gloryhole "access private member" in a different file without making it public.

Describe alternatives you've considered

  1. Rigging t_null to automatically convert itself to the underlying roof anytime some flavor of fuckery causes it to accidentally spawn.
  2. Making Coolthulhu cry by removing the bit in the code that makes the game complain if you explicitly try to set a deconstruct to create open air, which is what's blocking Ari's fix.

Testing

  1. Compiled and load-tested.
  2. Spawned in some wooden stairs across two z-levels.
  3. Deconstructed the upper stairs, it now correctly turns into open air instead of void. Deconstruct results also no longer drop down the hole and cause a ruckus due to landing on the stairs below, instead being spawned under a random adjacent space.
  4. Repeated test with the bottom stairs replaced with a solid wall, deconstructing the upper stairs instead correctly leaves behind a roof tile. Confirmed that items also still spawn on the usual tile since it creates normal floor to dump it on.
  5. Deconstructed some furniture to confirm nothing weird happens, also works sanely if deconstructing furniture embedded in a wall.
  6. Checked affected files for astyle.

Additional context

Checklist

Mandatory

@github-actions github-actions bot added the src changes related to source code. label Mar 8, 2025
@chaosvolt chaosvolt changed the title fix: deconstructing terrain into t_null creates roofs or open air automatically fix: deconstructing terrain into t_null creates roofs or open air automatically, don't spawn deconstruction results in midair Mar 8, 2025
Copy link
Collaborator

@RobbieNeko RobbieNeko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Looked over the code, don't see anything that looks off
  2. Compiled
  3. Ran the stair tests described in PR, confirmed they worked just fine for me too

Looks good to me!

@scarf005 scarf005 merged commit 487c607 into cataclysmbnteam:main Mar 12, 2025
16 checks passed
@chaosvolt chaosvolt deleted the I-consume-the-void branch March 12, 2025 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deconstructing stairs creates "nothing"
3 participants