CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.26k stars 4.12k forks source link

Can not Build "Shingle Flat Roof" on Roof of a Building #74942

Closed Alm999 closed 2 months ago

Alm999 commented 2 months ago

Describe the bug

It would appear the construction of (at least) a shingle roof is broken. As it stands, one can not build a shingle flat roof on a roof of a building (building a shingle roof indoors is permitted, but what's the point of that?) roof_troubles_01 The issue is that the construction recipe fails the "supported" check. Either removing the "check_support" from the data/json/construction/roofs.json or adding the "SUPPORTS_ROOF" flag to the "t_shingle_flat_roof" in the data/json/furniture_and_terrain/terrain-roofs.json makes the construction valid. roof_troubles_02 But I'm not convinced these hacks are a way to go. It seems that while the game checks for support on at least two sides of a tile on the same Z-level, it forgets to check a tile directly below even though there is a "t_floor" tile below in our case, which is stated explicitly that it supports a roof and does have the "SUPPORTS_ROOF" flag in the data/json/furniture_and_terrain/terrain-floors-indoor.json roof_troubles_03

Attach save file

Skyforest-trimmed.tar.gz

Steps to reproduce

  1. Load the save;
  2. Try to "Build Shingle Flat Roof" via construction menu;
  3. Verify that the game does not allow this despite the materials, tools and skills all being present.

Expected behavior

We should be able to shingle the roof of our (maybe custom-built) houses.

Screenshots

No response

Versions and configuration

Additional context

No response

PatrikLundell commented 2 months ago

The check for directly below is for the case when there's a WALL directly below, so there's actually something to hold the roof up. Otherwise it would allow for the levitation of a roof about a single floor tile. If that wasn't there you'd never be able to build a roof from scratch, since you'd never fulfill the requirement of support on two sides (because those would require that you'd already, somehow, managed to build a roof there).

The problem is that there is nothing to indicate whether a piece of terrain propagates support from the walls. This could be done either by introducing a new flag, e.g. PROPAGATES_SUPPORT on all terrain that should contributing to holding up a roof beside it that would be checked, or deciding an adjacent tile provides support if the tile isn't open space and the tile below it supports a roof or is a wall.

Instead of a flag tiles may have a value indicating how much support they provide, and you'd have to have enough support all the way to the walls to be allowed to add a new roof tile. That would be rather complex though, in particular when trying to use it in reverse to determine whether something caves in or not. It would get even more complicated if you were to take weight into consideration (imaging adding a wall onto a floor 3 floors above, causing the floor to collapse because too much weight was carried by a pillar with no support from directly below). On the other hand a support concept would allow for logic to build overhangs, which you can't do with the rule requiring support from two sides (it can only be produced by world gen and faction buildings that aren't subject to these checks).

The short term solution would probably be to change the side check to be for not being open space and have "support" from below.

Alm999 commented 2 months ago

Well, PatrikLundell, you are obviously far more qualified in how terrain mechanic works than I am. Considering your work on roofs I can safely bet there is very little you don't know about roofs. I just want my shingles on my roof :)

Current building system leaves a lot to be desired. I could not find a way to remove a door frame (other than smashing it with a war flail, but that produced a hole in my roof in the first place!), to dig tunnels in soil (other than with jackhammer, but that also has a risk of cave-in), to repair/reconstruct a lower z-level of a staircase (courtesy of a zombie hulk) when the upper part of it, still hangs on a z-level above or to construct a staircase leading to upper floor from inside a building (the floor above prevents it)… But these are probably topics for another Issues.

PatrikLundell commented 2 months ago

I plan to get to this tomorrow.

The construction system is indeed clunky. You have to specify a "recipe" for every transformation you want to support (smashing has to be supported in the tile definition). It doesn't help that the UI consists of a single unorganized list of entries, rather than something with a bit of organized structure (like the crafting menu).

Digging horizontally requires some kind of pickaxe (like a jackhammer, but the manually operated pickaxe will do, and I'm not sure it makes a difference if it's powered: it could if there are two separate recipes, but we don't have any logic to allow tool selection affect the recipe such as speed, effort, or quality, and there's no support for reinforcing tunnels. I dig my (sub) basements two levels down to avoid cave-ins and have yet to experience one.

The reason you can't repair a staircase is that it requires a recipe that doesn't built the top part and thus doesn't check that this space is free (which it isn't when the top half remain). It's probably possible to add such a construction entry, but I guess nobody has done so, and there's also a potential issue if both a normal staircase with a top part and one only consisting of the bottom one match the criteria, so maybe a bottom half only recipe should check there's a top half in place to be legal (and the opposite for the top half only case).