Skip to content

Commit

Permalink
Merge pull request #648 from jengelh/lv12
Browse files Browse the repository at this point in the history
d3: fix game crash in Retribution level 12's big matcen room
  • Loading branch information
Lgt2x authored Nov 25, 2024
2 parents 238aead + 0b7989b commit f7efa4b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Descent3/BOA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ int BOA_DetermineStartRoomPortal(int start_room, vector *start_pos, int end_room
bool f_making_robot_path_invalid_list, int *blocked_portal) {
int i;

if (start_room == -1 || end_room == -1)
return -1;
if (start_room > Highest_room_index && end_room > Highest_room_index)
return -1;

Expand Down Expand Up @@ -566,12 +568,12 @@ int BOA_GetNextRoom(int start_room, int end_room) {
int e_index = end_room;

if (start_room == -1 || end_room == -1) {
return false;
return BOA_NO_PATH;
}

if ((!ROOMNUM_OUTSIDE(s_index)) && s_index <= Highest_room_index) {
if (!Rooms[s_index].used) {
return false;
return BOA_NO_PATH;
}
} else if (ROOMNUM_OUTSIDE(s_index)) {
s_index = TERRAIN_REGION(start_room) + Highest_room_index + 1;
Expand All @@ -581,7 +583,7 @@ int BOA_GetNextRoom(int start_room, int end_room) {

if ((!ROOMNUM_OUTSIDE(e_index)) && e_index <= Highest_room_index) {
if (!Rooms[e_index].used) {
return false;
return BOA_NO_PATH;
}
} else if (ROOMNUM_OUTSIDE(e_index)) {
e_index = TERRAIN_REGION(end_room) + Highest_room_index + 1;
Expand Down
2 changes: 2 additions & 0 deletions Descent3/aipath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ static void AIUpdatePathInfo(q_item **node_list, int start, int end) {

// Ok to use Highest_room_index offset stuff
bool AIFindAltPath(object *obj, int i, int j, float *dist) {
if (i == -1 || j == -1)
return false;
i = BOA_INDEX(i);
j = BOA_INDEX(j);

Expand Down
5 changes: 5 additions & 0 deletions Descent3/bnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ static void BNode_UpdatePathInfo(pq_item **node_list, int start, int end) {

// Ok to use Highest_room_index offset stuff
bool BNode_FindPath(int start_room, int i, int j, float rad) {
if (start_room == -1)
return false;
bpq PQPath;
int counter;
pq_item *start_node = new pq_item(i, -1, 0.0f);
Expand Down Expand Up @@ -311,6 +313,8 @@ int BNode_FindDirLocalVisibleBNode(int roomnum, vector *pos, vector *fvec, float
}

bn_list *bnlist = BNode_GetBNListPtr(roomnum);
if (bnlist == nullptr)
return -1;

retry:

Expand Down Expand Up @@ -402,6 +406,7 @@ int BNode_FindClosestLocalVisibleBNode(int roomnum, vector *pos, float rad) {
}

bn_list *bnlist = BNode_GetBNListPtr(roomnum);
ASSERT(bnlist);

retry:

Expand Down

0 comments on commit f7efa4b

Please sign in to comment.