Merge pull request #51392 from lawnjelly/portals_autolink_internal
Portals - fix autolinking to internal rooms
This commit is contained in:
commit
52b3891b59
1 changed files with 31 additions and 16 deletions
|
@ -966,6 +966,9 @@ void RoomManager::_autolink_portals(Spatial *p_roomlist, LocalVector<Portal *> &
|
|||
|
||||
Vector3 test_pos = portal->_pt_center_world + (dist * portal->_plane.normal);
|
||||
|
||||
int best_priority = -1000;
|
||||
int best_room = -1;
|
||||
|
||||
for (int r = 0; r < _rooms.size(); r++) {
|
||||
Room *room = _rooms[r];
|
||||
if (room->_room_ID == portal->_linkedroom_ID[0]) {
|
||||
|
@ -988,9 +991,23 @@ void RoomManager::_autolink_portals(Spatial *p_roomlist, LocalVector<Portal *> &
|
|||
} // for through planes
|
||||
|
||||
if (!outside) {
|
||||
// we found a suitable room, but we want the highest priority in
|
||||
// case there are internal rooms...
|
||||
if (room->_room_priority > best_priority) {
|
||||
best_priority = room->_room_priority;
|
||||
best_room = r;
|
||||
}
|
||||
}
|
||||
|
||||
} // for through rooms
|
||||
|
||||
// found a suitable link room
|
||||
if (best_room != -1) {
|
||||
Room *room = _rooms[best_room];
|
||||
|
||||
// great, we found a linked room!
|
||||
convert_log("\t\tAUTOLINK OK from " + source_room->get_name() + " to " + room->get_name(), 1);
|
||||
portal->_linkedroom_ID[1] = r;
|
||||
portal->_linkedroom_ID[1] = best_room;
|
||||
|
||||
// add the portal to the portals list for the receiving room
|
||||
room->_portals.push_back(n);
|
||||
|
@ -1006,8 +1023,6 @@ void RoomManager::_autolink_portals(Spatial *p_roomlist, LocalVector<Portal *> &
|
|||
break;
|
||||
}
|
||||
|
||||
} // for through rooms
|
||||
|
||||
} // for attempt
|
||||
|
||||
// error condition
|
||||
|
|
Loading…
Reference in a new issue