-
Notifications
You must be signed in to change notification settings - Fork 37
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
tr2/room: refactor floor data handling #1896
tr2/room: refactor floor data handling #1896
Conversation
244613a
to
f7d8927
Compare
Download the built assets for this pull request: |
An issue I found that is currently confined to this PR - the |
Thanks, now addressed. The global item count wasn't being set to 0 for the title level. It wasn't an issue before because we were skipping |
This prepares for additional loading activities we will need to perform, such as FD parsing. This is akin to TR1.
This creates a shell floor data master parser to (later) allow setting all relevant properties for sectors once, thus reducing FD iteration and complexity throughout the codebase.
This creates a tilt property for each sector, which is populated via floor data parsing. Calls related to GetHeight for floor and ceiling have been updated to use this property.
This creates a wall portal room property for each sector, which is initialised to NO_ROOM and populated via floor data parsing. Room_GetDoor is now redundant. This also moves sky and pit portals, together with wall, into a struct in the sector for readability.
Adds functions to get absolute pit and sky sectors, given another sector and X/Z values, to eliminate repeated looping logic where feasible.
Adds a death property to SECTOR. This contains a temporary check in Room_TestTriggers until we can later eliminate g_TriggerIndex.
Adds a more explicit ladder property and makes the ladder test less cryptic as a result.
ad3b40b
to
7b5e265
Compare
TT_COMBAT = 7, | ||
TT_DUMMY = 8, | ||
TT_ANTITRIGGER = 9, | ||
} TRIGGER_TYPE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this file is autogenerated, we also need to mark these types as // decompiled
in progress.txt
, otherwise just tr2-auto
will bring them back here.
Triggers are also now directly in sectors, and their list of commands. Most duplicated FD iterations are now removed. All callers to Room_TestTriggers updated, and an additional change was needed when Lara pulls the dagger from the dragon (as she is not heavy).
TR1 and TR2 are now equivalent, bar the ladder property for TR2.
g_FloorData is now redundant, but retained as legacy until decomp completed.
This marks g_TriggerIndex as legacy.
7b5e265
to
60d20a3
Compare
Resolves #1883.
Checklist
Description
This follows a similar approach as we did for TR1 in #941. Best viewed commit-by-commit to see the iterative changes.
As well as the main FD overhaul, there were a few snagging points that have been addressed here.
Item_Initialise
was previously called duringM_LoadItems
inlevel.c
but this had to be shifted because there are floor data dependencies there. We now take a similar approach to TR1, so load the level data, then perform a "CompleteSetup"; this can be expanded later for things like injection processing.g_LevelItemCount
wasn't being set to 0 here - not an issue originally becauseItem_Initialise
(where the crash would occur) would have been skipped in that case.The dragon may need some extra checks based on where it lands e.g. if partially in the wall. I may change this to behave like the Torso in TR1, where it checks a range of surrounding sectors.
For testing, attached is a level with various trigger types, basic geometry, ladders, and death tiles. I didn't include a dragon for testing, that can be done in OG easily enough. For ceiling geometry, it's best to fly against it and hold down to see that Lara follows the structure properly.
WALL.zip
There is a lot of scope now for sharing FD handling with TR1, but that can be tackled in the future. I may follow this up with some minor changes, like moving all FD macros to libtrx and renaming some enums, but I didn't want to touch TR1 at all in this PR.