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

d3: fix game crash in Retribution level 12's big matcen room #648

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

jengelh
Copy link
Contributor

@jengelh jengelh commented Nov 6, 2024

When activating switches in the room with 6 matcens, this happens after a short while:

Assertion failure at TERRAIN_REGION (Descent3/terrain.h:218), triggered 1 time:
  'x != -1 && "invalid/unset room number (-1)!"'

f0  TERRAIN_REGION (x=-1) at Descent3/terrain.h:222
f1  AIPathAllocPath (obj=0x3d304b0 <Objects+150000>, ai_info=0x520000444080, goal_ptr=0x520000444250, start_room=0x3d304cc <Objects+150028>, start_pos=0x3d304d0 <Objects+150032>, end_room=0x7fb115dbe830, end_pos=0x52000044427c, rad=0, flags=0, handle=28822, ignore_obj=-1) at Descent3/aipath.cpp:1066
f2  GoalDoFrame (obj=0x3d304b0 <Objects+150000>) at Descent3/AIGoal.cpp:823
f3  AIDoFrame (obj=0x3d304b0 <Objects+150000>) at Descent3/AImain.cpp:6214
f4  ObjDoFrame (obj=0x3d304b0 <Objects+150000>) at Descent3/object.cpp:2674
f5  ObjDoFrameAll () at Descent3/object.cpp:2988
f6  GameFrame () at Descent3/GameLoop.cpp:2981
f7  GameSequencer () at Descent3/gamesequence.cpp:1221
f8  PlayGame () at Descent3/game.cpp:834
f9  MainLoop () at Descent3/descent.cpp:550
f10 Descent3 () at Descent3/descent.cpp:508
f11 oeD3LnxApp::run (this=0x7fb115a0db50) at Descent3/sdlmain.cpp:151

(gdb) up
    start_room=0x3d304cc <Objects+150028>, start_pos=0x3d304d0 <Objects+150032>, end_room=0x7fb115dbe830, end_pos=0x52000044427c, rad=0, flags=0,
    handle=28822, ignore_obj=-1) at Descent3/aipath.cpp:1066
1066          } else if (BOA_Array[BOA_INDEX(*start_room)][BOA_INDEX(*end_room)] & BOAF_TOO_SMALL_FOR_ROBOT) {
(gdb) p *start_room
$2 = 171
(gdb) p *end_room
$3 = -1

The return type of BOA_GetNextPath is int; but inside the function, false is returned, which does not fit the scheme. Judging from callsites, BOA_NO_PATH is expected instead.

In some functions related to AI pathfinding, add handling or assertions for invalid room numbers.

Pull Request Type

  • Runtime changes
    • Other changes

Checklist

  • I have tested my changes locally and verified that they work as intended.
  • I have reviewed the changes to ensure they do not introduce any unnecessary complexity or duplicate code.
  • I understand that by submitting this pull request, I am agreeing to license my contributions under the project's license.

When activating switches in the room with 6 matcens,
this happens after a short while:

```
Assertion failure at TERRAIN_REGION (Descent3/terrain.h:218), triggered 1 time:
  'x != -1 && "invalid/unset room number (-1)!"'

f0  TERRAIN_REGION (x=-1) at Descent3/terrain.h:222
f1  AIPathAllocPath (obj=0x3d304b0 <Objects+150000>, ai_info=0x520000444080, goal_ptr=0x520000444250, start_room=0x3d304cc <Objects+150028>, start_pos=0x3d304d0 <Objects+150032>, end_room=0x7fb115dbe830, end_pos=0x52000044427c, rad=0, flags=0, handle=28822, ignore_obj=-1) at Descent3/aipath.cpp:1066
f2  GoalDoFrame (obj=0x3d304b0 <Objects+150000>) at Descent3/AIGoal.cpp:823
f3  AIDoFrame (obj=0x3d304b0 <Objects+150000>) at Descent3/AImain.cpp:6214
f4  ObjDoFrame (obj=0x3d304b0 <Objects+150000>) at Descent3/object.cpp:2674
f5  ObjDoFrameAll () at Descent3/object.cpp:2988
f6  GameFrame () at Descent3/GameLoop.cpp:2981
f7  GameSequencer () at Descent3/gamesequence.cpp:1221
f8  PlayGame () at Descent3/game.cpp:834
f9  MainLoop () at Descent3/descent.cpp:550
f10 Descent3 () at Descent3/descent.cpp:508
f11 oeD3LnxApp::run (this=0x7fb115a0db50) at Descent3/sdlmain.cpp:151

(gdb) up
    start_room=0x3d304cc <Objects+150028>, start_pos=0x3d304d0 <Objects+150032>, end_room=0x7fb115dbe830, end_pos=0x52000044427c, rad=0, flags=0,
    handle=28822, ignore_obj=-1) at Descent3/aipath.cpp:1066
1066          } else if (BOA_Array[BOA_INDEX(*start_room)][BOA_INDEX(*end_room)] & BOAF_TOO_SMALL_FOR_ROBOT) {
(gdb) p *start_room
$2 = 171
(gdb) p *end_room
$3 = -1
```

The return type of ``BOA_GetNextPath`` is int; but inside the
function, ``false`` is returned, which does not fit the scheme.
Judging from callsites, ``BOA_NO_PATH`` is expected instead.

In some functions related to AI pathfinding, add handling or
assertions for invalid room numbers.
Copy link
Member

@Lgt2x Lgt2x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BOA_NO_PATH looks indeed like the right value to return here.

@Lgt2x Lgt2x merged commit f7efa4b into DescentDevelopers:main Nov 25, 2024
10 checks passed
@jengelh jengelh deleted the lv12 branch November 26, 2024 22:44
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.

2 participants