mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-22 20:06:49 +01:00
Portals - Fix invalid room hint when reconverting room graph
In situations where rooms are converted multiple times, the previous room hint ID can reference a room number that is out of range of the new number of rooms. This fixes the bug by checking the room hint ID is within range.
This commit is contained in:
parent
cedf68bf7f
commit
50d5be10f8
@ -102,6 +102,7 @@ int PortalRoomsBSP::find_room_within(const PortalRenderer &p_portal_renderer, co
|
|||||||
|
|
||||||
// first try previous room
|
// first try previous room
|
||||||
if (p_previous_room_id != -1) {
|
if (p_previous_room_id != -1) {
|
||||||
|
if (p_previous_room_id < p_portal_renderer.get_num_rooms()) {
|
||||||
const VSRoom &prev_room = p_portal_renderer.get_room(p_previous_room_id);
|
const VSRoom &prev_room = p_portal_renderer.get_room(p_previous_room_id);
|
||||||
|
|
||||||
// we can only use this shortcut if the room doesn't include internal rooms.
|
// we can only use this shortcut if the room doesn't include internal rooms.
|
||||||
@ -117,6 +118,10 @@ int PortalRoomsBSP::find_room_within(const PortalRenderer &p_portal_renderer, co
|
|||||||
// don't mark it as checked later, as we haven't done it because it contains internal rooms
|
// don't mark it as checked later, as we haven't done it because it contains internal rooms
|
||||||
p_previous_room_id = -1;
|
p_previous_room_id = -1;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// previous room was out of range (perhaps due to reconverting room system and the number of rooms decreasing)
|
||||||
|
p_previous_room_id = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int num_bsp_rooms = 0;
|
int num_bsp_rooms = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user