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

Tunnels displaying correctly in low walls mode #3699

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

Spatulade
Copy link
Contributor

@Spatulade Spatulade commented Nov 18, 2024

See https://discord.com/channels/480505152806191114/648319840288768000/1305891716133421127

Tunnels (i.e. columns with empty cubes inside but solid cubes above) don't display properly in low walls mode. I want to make them display correctly in low walls mode so they don't look weird and potential spoil secrets.



The aim is (for a standard 5-high column) to put the top of cube 5 onto cube 2, and display cubes 1 and 2.

image
image

I've tried to find code for low walls mode but I just can't seem to find it. Wall height seems to be video_cluedo_mode, but I can't find any code, just toggles.

The only thing that seemed to help is find_column_height, which seems to treat the height as "how many solid blocks are there connected to the floor?", so for a cave with a hole in like in the pictures, it treats the height as 1 or 0. Maybe that's why it's not working - it's reading the height of these examples as 0 or 1. I'm going to see if this works, and if not hope someone can point me in the right direction.

First I'm seeing in the wall height is calculated incorrectly
@Spatulade Spatulade changed the title Trying to see if tunnels work in low walls mode Tunnels displaying correctly in low walls mode Nov 18, 2024
@walt253

This comment was marked as off-topic.

@Loobinex Loobinex marked this pull request as draft November 19, 2024 19:27
solidmask seemed to only count the number of solid cubes from the bottom (even though it shouldn't), so instead of checking if a column is 4 or more cubes tall, this checks if cube 4 (cubes[3]) or higher exists
@Spatulade Spatulade marked this pull request as ready for review November 20, 2024 00:31
@Spatulade Spatulade marked this pull request as draft November 20, 2024 00:35
@Spatulade Spatulade marked this pull request as ready for review November 20, 2024 00:35
@Spatulade Spatulade marked this pull request as draft November 20, 2024 01:14
@Spatulade Spatulade marked this pull request as ready for review November 20, 2024 01:15
@Spatulade Spatulade marked this pull request as draft November 20, 2024 01:48
@Spatulade Spatulade self-assigned this Nov 20, 2024
@walt253 walt253 marked this pull request as ready for review November 20, 2024 02:12
@walt253 walt253 marked this pull request as draft November 20, 2024 02:12
@Spatulade Spatulade marked this pull request as ready for review November 21, 2024 23:02
@Spatulade
Copy link
Contributor Author

Spatulade commented Nov 21, 2024

I've been doing a lot of reading and some tests and I'm not sure what I'd need to fix to get this to work - the lines in question we were looking at are fill_in_points_cluedo in engine_render.c:

if ((mask_cur >= 8) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0))

The first part checks for cube[3] or higher, the second checks it's not a door or room and the third avoids ceiling mask collision issues. I tried changing the first part to checking if the cubes in any of those positions were nonempty and it made no difference. Removing the third part caused all sort of graphical issues. The second part is what worries me:

Here I've tried all column combinations up to height 5, and the only ones which are affected are the solid columns of height 4 or 5. This tells us either:

  • solidmask isn't pulling data correctly (which I doubt, it checks the ids of each cube and makes a binary representation of whether those cubes are solid or not)
  • Or more likely - it's something built into how the game works at a fundamental level, and the game works off the assumption that all columns are solid. This is why I reckon the middle part ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) exists: The team were aware that low walls weren't working for columns with gaps in them, and to avoid it looking weird for the two cases of columns with gaps in (Portals and open doors, where the solid columns would shrink and the ones with gaps wouldn't), columns of those types were excluded. Basically every column check looks at the height as the number of solid cubes from the bottom before a gap, where the top of that is the 'floor', and the first nonempty cube above that is the 'ceiling', and so maybe the game is fully coded around the assumption that every column is solid.

I'm hoping this isn't the case, and there's some other piece of code that will just magically fix this, but I don't know. My guess (if it's actually a fundamental issue) is something to do with col->bitfields and how floor and ceiling heights and block heights are stored there.

I've thrown out all sorts of ramblings on Discord about it all, but I'm really not sure what else I can do. I'm hoping someone with more experience can either identify the code that's causing the issue, or suggest ways to probe for the right info (e.g. checking the solidmask for columns or seeing what bitfields looks like for some examples and what CLF_CEILING_MASK looks like).

Edit: The only other idea for how to work with this if it really does only work for solid columns is to make some sort of "dummy air cube" which is treated as solid by some checks and empty by others, i.e. most things consider it solid but creatures can work through it, although I don't know how that would work, as I don't know exactly what causes the issue: solidmask seems to work but I haven't probed the solidmask number for some test columns to see if it gives back what we need, and most checks seem to also be used for drawing the floor etc

@Spatulade Spatulade removed their assignment Nov 22, 2024
@Loobinex Loobinex marked this pull request as draft November 25, 2024 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants