Merge pull request #6744 from mattsc/vision_path_oos

Fix potential for OOS errors due to wrong viewing side in vision_path
This commit is contained in:
mattsc 2022-06-06 19:15:51 -07:00 committed by GitHub
commit 78079ffd79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -582,7 +582,8 @@ vision_path::vision_path(const unit& viewer, const map_location& loc,
// The three nullptr parameters indicate (in order):
// ignore units, ignore ZoC (no effect), and don't build a cost_map.
const team& viewing_team = resources::gameboard->teams()[display::get_singleton()->viewing_team()];
// The viewing team needs to be the unit's team here.
const team& viewing_team = resources::gameboard->get_team(viewer.side());
find_routes(loc, viewer.movement_type().get_vision(),
viewer.get_state(unit::STATE_SLOWED), sight_range, sight_range,
0, destinations, &edges, &viewer, nullptr, nullptr, &viewing_team, &jamming_map, nullptr, true);
@ -607,8 +608,9 @@ vision_path::vision_path(const movetype::terrain_costs & view_costs, bool slowed
{
// The three nullptr parameters indicate (in order):
// ignore units, ignore ZoC (no effect), and don't build a cost_map.
const team& viewing_team = resources::gameboard->teams()[display::get_singleton()->viewing_team()];
const unit_map::const_iterator u = resources::gameboard->units().find(loc);
// The viewing team needs to be the unit's team here.
const team& viewing_team = resources::gameboard->get_team(u->side());
find_routes(loc, view_costs, slowed, sight_range, sight_range, 0,
destinations, &edges, u.valid() ? &*u : nullptr, nullptr, nullptr, &viewing_team, &jamming_map, nullptr, true);
}