Fix openable_door_on_near_path for side WLEFT

openable_door_on_near_path should return 0 for no door and any non-zero
value for door-found.  Commit 9fdf6005df changed the logic to return 0
for no door, and the side number value for door-found.  This is wrong,
since WLEFT has integer value 0, so the caller will interpret a return
of door-found, side=WLEFT as no-door-found.

Fixes: 9fdf6005df ("Convert ai_static::GOALSIDE to sidenum_t")
This commit is contained in:
Kp 2022-02-27 14:23:53 +00:00
parent 9e58992296
commit b3f250f3b6

View file

@ -3098,8 +3098,8 @@ static int openable_door_on_near_path(fvcsegptr &vcsegptr, fvcwallptr &vcwallptr
const auto path_length = aip.path_length;
if (path_length < 1)
return 0;
if (const auto r = openable_doors_in_segment(vcwallptr, vcsegptr(obj.segnum)); r.has_value())
return *r;
if (const auto r = openable_doors_in_segment(vcwallptr, vcsegptr(obj.segnum)).has_value())
return r;
if (path_length < 2)
return 0;
size_t idx;
@ -3110,16 +3110,16 @@ static int openable_door_on_near_path(fvcsegptr &vcsegptr, fvcwallptr &vcwallptr
*/
if (idx < Point_segs.size() && Point_segs[idx].segnum != segment_none)
{
if (const auto r = openable_doors_in_segment(vcwallptr, vcsegptr(Point_segs[idx].segnum)); r.has_value())
return *r;
if (const auto r = openable_doors_in_segment(vcwallptr, vcsegptr(Point_segs[idx].segnum)).has_value())
return r;
}
if (path_length < 3)
return 0;
idx = aip.hide_index + aip.cur_path_index + 2*aip.PATH_DIR;
if (idx < Point_segs.size() && Point_segs[idx].segnum != segment_none)
{
if (const auto r = openable_doors_in_segment(vcwallptr, vcsegptr(Point_segs[idx].segnum)); r.has_value())
return *r;
if (const auto r = openable_doors_in_segment(vcwallptr, vcsegptr(Point_segs[idx].segnum)).has_value())
return r;
}
return 0;
}