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

[Crash] Ruins of Talos II: Phantom Point Crashes on load #443

Open
DatMaxNub opened this issue Aug 26, 2024 · 4 comments
Open

[Crash] Ruins of Talos II: Phantom Point Crashes on load #443

DatMaxNub opened this issue Aug 26, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@DatMaxNub
Copy link

Version: 1.10

Game: Dark Forces

Mod: https://df-21.net/downloads/missions.php?viewid=2086487251

Level crashes TFE at the load screen.

crashdump.dmp

@mlauss2
Copy link
Contributor

mlauss2 commented Aug 26, 2024

This patch fixes it for me, but I have absolutely no idea whether it's the right thing to do.
The level loads, but I haven't played it to completion yet.

index 855739e2..57738f3d 100644
--- a/TheForceEngine/TFE_Jedi/Level/level.cpp
+++ b/TheForceEngine/TFE_Jedi/Level/level.cpp
@@ -103,7 +103,7 @@ namespace TFE_Jedi
                        for (s32 w = 0; w < sector->wallCount; w++, wall++)
                        {
                                RSector* nextSector = wall->nextSector;
-                               if (nextSector)
+                               if (nextSector && nextSector->walls && wall->mirror != -1 && nextSector->wallCount > wall->mirror)
                                {
                                        RWall* mirror = &nextSector->walls[wall->mirror];
                                        wall->mirrorWall = mirror;
@@ -111,6 +111,12 @@ namespace TFE_Jedi
                                        wall->flags3 |= (mirror->flags3 & 0x0f);
                                        mirror->flags3 |= (wall->flags3 & 0x0f);
                                }
+                               else
+                               {
+                                       // disable invalid/nonsensical mirror
+                                       wall->nextSector = nullptr;
+                                       wall->mirror = -1;
+                               }
                        }
                        sector_setupWallDrawFlags(sector);
                        sector_adjustHeights(sector, 0, 0, 0);

EDIT: I was able to complete the level with this patch applied. There's a wall in the underground mining shaft one has to step through, shortly before the big wampa outside behind a bush blocking the way, is that intentional? The automap revealed the way forward, so it wasn't an issue.

here:
image

@luciusDXL
Copy link
Owner

Thanks for the report, I will look at the data. But if the above fixes it, it is probably an issue with the level data (another case where it should crash in DOS but doesn't for some reason).

@luciusDXL
Copy link
Owner

luciusDXL commented Aug 26, 2024

@DatMaxNub So I looked at the level in the editor - there is an area with a waterfall with some really wonky adjoins - I'm surprised it works in vanilla, honestly.

tfe_screenshot_Mon-Aug-26-11_09_21-2024_1

For example, see that highlight adjoin - you have 3 adjoins in that spot, if it were correctly setup, the adjoin would only extend along the length of the step.

Here you can see the sector in question is degenerate, part of the reason the adjoins are so wonky:
tfe_screenshot_Mon-Aug-26-11_09_21-2024_2

Anyway, the only real fix (other than fixing the level itself) is something like what @mlauss2 has. I will add something here for the next release. The original code did not have this check, but it doesn't crash in DOS even though it probably should.

After playing to that point in the level, I can see it looks glitchy even in software. I implemented a fix for the crash, which will be fixed in the next release (I will close the issue once the next release is published).

@DatMaxNub
Copy link
Author

DatMaxNub commented Sep 2, 2024

This patch fixes it for me, but I have absolutely no idea whether it's the right thing to do. The level loads, but I haven't played it to completion yet.

index 855739e2..57738f3d 100644
--- a/TheForceEngine/TFE_Jedi/Level/level.cpp
+++ b/TheForceEngine/TFE_Jedi/Level/level.cpp
@@ -103,7 +103,7 @@ namespace TFE_Jedi
                        for (s32 w = 0; w < sector->wallCount; w++, wall++)
                        {
                                RSector* nextSector = wall->nextSector;
-                               if (nextSector)
+                               if (nextSector && nextSector->walls && wall->mirror != -1 && nextSector->wallCount > wall->mirror)
                                {
                                        RWall* mirror = &nextSector->walls[wall->mirror];
                                        wall->mirrorWall = mirror;
@@ -111,6 +111,12 @@ namespace TFE_Jedi
                                        wall->flags3 |= (mirror->flags3 & 0x0f);
                                        mirror->flags3 |= (wall->flags3 & 0x0f);
                                }
+                               else
+                               {
+                                       // disable invalid/nonsensical mirror
+                                       wall->nextSector = nullptr;
+                                       wall->mirror = -1;
+                               }
                        }
                        sector_setupWallDrawFlags(sector);
                        sector_adjustHeights(sector, 0, 0, 0);

EDIT: I was able to complete the level with this patch applied. There's a wall in the underground mining shaft one has to step through, shortly before the big wampa outside behind a bush blocking the way, is that intentional? The automap revealed the way forward, so it wasn't an issue.

here: image

Yes cutting the brush was intentional. It's meant to loop you back to cabin with a red key hidden behind the fireplace

https://www.youtube.com/watch?v=bnpGiYPpWbY

10:30 mark and from there

@luciusDXL luciusDXL self-assigned this Sep 9, 2024
@luciusDXL luciusDXL added the bug Something isn't working label Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants
@luciusDXL @DatMaxNub @mlauss2 and others