fixes a crash when using optimized

Obj_CrossCheckpoints and LinOnDemand
This commit is contained in:
Ashnal 2025-05-19 18:46:28 -04:00
parent 3399f446a8
commit b332b84ed9

View file

@ -579,15 +579,18 @@ void Obj_CrossCheckpoints(player_t* player, fixed_t old_x, fixed_t old_y)
return false; return false;
} }
LineOnDemand* gate;
const srb2::Vector<line_t*>* lines = g_checkpoints.lines_for(chk); const srb2::Vector<line_t*>* lines = g_checkpoints.lines_for(chk);
INT32 side;
INT32 oldside;
if (!lines || lines->empty()) if (!lines || lines->empty())
{ {
LineOnDemand dyngate = chk->crossing_line(); LineOnDemand dyngate = chk->crossing_line();
if (!ray.overlaps(dyngate)) if (!ray.overlaps(dyngate))
return false; return false;
gate = &dyngate;
side = P_PointOnLineSide(player->mo->x, player->mo->y, &dyngate);
oldside = P_PointOnLineSide(old_x, old_y, &dyngate);
} }
else else
{ {
@ -606,7 +609,8 @@ void Obj_CrossCheckpoints(player_t* player, fixed_t old_x, fixed_t old_y)
} }
line_t* line = *it; line_t* line = *it;
gate = static_cast<LineOnDemand*>(line); side = P_PointOnLineSide(player->mo->x, player->mo->y, line);
oldside = P_PointOnLineSide(old_x, old_y, line);
} }
// Check if the bounding boxes of the two lines // Check if the bounding boxes of the two lines
@ -615,9 +619,6 @@ void Obj_CrossCheckpoints(player_t* player, fixed_t old_x, fixed_t old_y)
// but thankfully that doesn't seem to happen, under // but thankfully that doesn't seem to happen, under
// normal circumstances. // normal circumstances.
INT32 side = P_PointOnLineSide(player->mo->x, player->mo->y, gate);
INT32 oldside = P_PointOnLineSide(old_x, old_y, gate);
if (side == oldside) if (side == oldside)
{ {
// Did not cross. // Did not cross.