Cataclysm-DDA icon indicating copy to clipboard operation
Cataclysm-DDA copied to clipboard

Flat roof on Buildings / chain link fence and locked wire gate

Open ZweiFedern opened this issue 1 year ago • 12 comments

Is your feature request related to a problem? Please describe.

if i go on roof tops of buildings, that have a water heater, water purifier, standing tank, a chain link fence and a locked wire gate, and i smahed the fence an the gate, for parts all droped down. because there is no flat roof under the fence.

Bildschirmfoto vom 2024-09-12 10-46-55

Solution you would like.

Is it possible to get a "ground" under the fence and gate? like concrete if the rest of the roof top is all make of concrete.

Describe alternatives you have considered.

No response

Additional context

No response

ZweiFedern avatar Sep 12 '24 09:09 ZweiFedern

The problem is that a chain link fence is "terrain", and the underlying system doesn't support "terrain" on top of a base "terrain". It's the same issue with trees (which are also "terrain"). A smashed chain link fence results in the terrain turning into chain fence posts, and smashing those turns the terrain into "t_null", which I would guess means it turns into whatever the base terrain of that overmap tile is (open air above ground, such as on a roof, soil at the ground level, and rock below ground, basically). For this to work properly, the system would have to support more than one layer of "terrain". I've suggested a split between a "terrain" layer and a "construction/vegetation" layer. It would not be trivial to implement, however (and a lot of work to convert things to work with it).

PatrikLundell avatar Sep 12 '24 09:09 PatrikLundell

ok look here, i just found this. building - grocery store roof, with chain link fence. i smash the first "chain link fence" and get pips and no hole in the celling. ("flat roof" was under the fence). Bildschirmfoto vom 2024-09-13 16-26-11 i smash the second "chain link fence" and the pips drop down in a hole. ("open air") Bildschirmfoto vom 2024-09-13 16-52-28

under one fence is flat roof - now i have the question: why does it work there and not with the other tiles? Bildschirmfoto vom 2024-09-13 17-05-19

i see on cdda-guide.nornagon.net - chain link fence there are 2x maybe is there the "wrong" build in?

ghost avatar Sep 13 '24 15:09 ghost

First you smash chain link fence into chain link posts, and then you smash chain link posts into open air. There is only one version in the JSON files, although it also has two additional alias names.

The above is what happened when I tried it. If you're using an old version you may be subjected to roof autmagic repair, although that should only happen on a save/load cycle.

PatrikLundell avatar Sep 13 '24 15:09 PatrikLundell

As a workaround in /data/json/furniture_and_terrain in:

{
    "type": "terrain",
    "id": "t_chainfence_posts",
    ...
   "bash": {
      "ter_set": "t_null",
    }
},

Value of bash -> ter_set can be changed to something like:

"ter_set": "t_thconc_floor"

Syler1984 avatar Sep 25 '24 02:09 Syler1984

ok look here, i just found this. building - grocery store roof, with chain link fence. i smash the first "chain link fence" and get pips and no hole in the celling.

I can confirm that on fresh experimental. Gunstore roof (data/json/mapgen/store/s_gunstore.json):

Screenshot_3

Screenshot_2

As you can see, smashing fence and gate north and south of the character did result in proper roof tiles generating. In this case it happens because there is a wall under these two tiles, which generates roof above them.

Syler1984 avatar Sep 25 '24 02:09 Syler1984

As a workaround in /data/json/furniture_and_terrain in: ... Value of bash -> ter_set can be changed to something like:

"ter_set": "t_thconc_floor"

To follow up on that: Similar changes needed to be made for t_chaingate_l, t_chaingate_c and t_chaingate_o (lokced, unlocked and open chain link gates).

Also, all related terrain leaves t_dirt when hacksawed or torched instead of t_null: Screenshot_4

Some other terrain like railings seem to function in similar way, leaving some sort of solid floor instead of nothing when bashed.

Syler1984 avatar Sep 25 '24 02:09 Syler1984

Value of bash -> ter_set can be changed to something like: "ter_set": "t_thconc_floor"

This will lead to concrete floor generating even if fence is located somewhere in open field.

Night-Pryanik avatar Sep 25 '24 02:09 Night-Pryanik

Value of bash -> ter_set can be changed to something like: "ter_set": "t_thconc_floor"

This will lead to concrete floor generating even if fence is located somewhere in open field.

Like i said "workaround". It probably less exploity to have concrete floor in the field than hole in the roof of a gunstore. But it could be anything else but t_null. Wooden floor, dirt, anything.

Syler1984 avatar Sep 25 '24 02:09 Syler1984

This is actually interesting:

ok look here, i just found this. building - grocery store roof, with chain link fence. i smash the first "chain link fence" and get pips and no hole in the celling.

I can confirm that on fresh experimental. Gunstore roof (data/json/mapgen/store/s_gunstore.json):

As you can see, smashing fence and gate north and south of the character did result in proper roof tiles generating. In this case it happens because there is a wall under these two tiles, which generates roof above them.

As far as I can tell, whenever terrain is destroyed, the game checks terrain one level below for presence of a "WALL" flag. If the flag is present, it generates terrain from "roof" property. Which, in case of a regular wall is set to "roof": "t_flat_roof". So regular roof tile is generated.

It might be possible to extend this logic to some new tag, like "GENERATE_ROOF" or something. And then check, if destroyed terrain already equal to "roof", then just ignore that logic to avoid indestructible roofs. This should fix this issue and many similar ones by generating proper terrain instead of open air.

I'll look for a place in the code which handles that logic.

Syler1984 avatar Sep 25 '24 03:09 Syler1984

And then check, if destroyed terrain already equal to "roof", then just ignore that logic to avoid indestructible roofs.

This logic exists in the game code already. I don't see any other effect of "WALL" tag other than generating roof tile above it (unless it is already the "roof"). It does not influence pathfinding, it does not make terrain impassible.

Basically, just adding "WALL" flag to every floor in the game already fixes the issue (despite being a misnomer). It does add extra "layer" to bashing normal floors down if floor does not match "roof" terrain of a floor below it.

I still haven't looked at the code though.

Syler1984 avatar Sep 25 '24 03:09 Syler1984

The WALL flag affects support, and thus collapse effects. If you'd add it to a floor it would allow a roof to levitate over it. It may also affect visuals and similar things that tries to join up walls with each others.

PatrikLundell avatar Sep 25 '24 07:09 PatrikLundell

Value of bash -> ter_set can be changed to something like: "ter_set": "t_thconc_floor"

This will lead to concrete floor generating even if fence is located somewhere in open field.

Are there any metal chain link fences in fields though? Metal fence posts are usually set in concrete in the end after all. It wouldn't be too far-fetched to have a concrete pad base tile under metal fences even if it was surrounded dirt, if that's a thing that exists on any maps currently.

How are the fences currently rendered as a tile? Since there isn't any information about the terrain under it available for transparency I'm assuming the floor/base is just baked in, and it's not dirt...

oosyrag avatar Dec 03 '24 17:12 oosyrag

This bug is so annoying so I wanted to know, what caused it, and I tested lots of releases And the problem is in this release Cataclysm-DDA experimental build 2024-07-18-0452 Caused by this pr #75038

Because no bug appeared in release before Cataclysm-DDA experimental build 2024-07-18-0220

@ShnitzelX2 can you check pls? If you need screenshots/saves to reproduce this bug - tell me or use info and save file from my bug report #78309

KHeket avatar Jan 04 '25 11:01 KHeket

Thanks for the mention, I would also assume my PR caused this issue. The floor/roof bash code is tough, so it doesn't surprise me that I missed an edge case.

Also thanks for for the save, I will do my best to fix this soon.

ShnitzelX2 avatar Jan 07 '25 21:01 ShnitzelX2