diff --git a/src/k_kart.c b/src/k_kart.c index 1248714eb..91d73c254 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7929,6 +7929,12 @@ static waypoint_t *K_GetPlayerNextWaypoint(player_t *player) if (angledelta < nextbestdelta || momdelta < nextbestmomdelta) { + if (P_TraceBlockingLines(player->mo, waypoint->nextwaypoints[i]->mobj) == false) + { + // Save sight checks when all of the other checks pass, so we only do it if we have to + continue; + } + bestwaypoint = waypoint->nextwaypoints[i]; if (angledelta < nextbestdelta) @@ -7975,6 +7981,12 @@ static waypoint_t *K_GetPlayerNextWaypoint(player_t *player) if (angledelta < nextbestdelta && momdelta < nextbestmomdelta) { + if (P_TraceBlockingLines(player->mo, waypoint->prevwaypoints[i]->mobj) == false) + { + // Save sight checks when all of the other checks pass, so we only do it if we have to + continue; + } + bestwaypoint = waypoint->prevwaypoints[i]; nextbestdelta = angledelta; diff --git a/src/k_waypoint.c b/src/k_waypoint.c index 06d0a1a84..357731bd9 100644 --- a/src/k_waypoint.c +++ b/src/k_waypoint.c @@ -361,6 +361,12 @@ waypoint_t *K_GetBestWaypointForMobj(mobj_t *const mobj) // remember: huge radius if (closestdist <= rad && checkdist <= rad && finishline != NULL) { + if (!P_TraceBlockingLines(mobj, checkwaypoint->mobj)) + { + // Save sight checks when all of the other checks pass, so we only do it if we have to + continue; + } + // If the mobj is touching multiple waypoints at once, // then solve ties by taking the one closest to the finish line. // Prevents position from flickering wildly when taking turns. @@ -375,7 +381,7 @@ waypoint_t *K_GetBestWaypointForMobj(mobj_t *const mobj) { if (!P_TraceBlockingLines(mobj, checkwaypoint->mobj)) { - // Save sight checks for the end, so we only do it if we have to + // Save sight checks when all of the other checks pass, so we only do it if we have to continue; } diff --git a/src/p_sight.c b/src/p_sight.c index ca2ba77cd..4faffcf32 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -578,6 +578,15 @@ static boolean P_CrossBlockingSubsector(size_t num, register traceblocking_t *tb // This line will always block us return false; } + + if (tb->compareThing->player != NULL) + { + if (P_IsLineTripWire(line) == true && K_TripwirePass(tb->compareThing->player) == false) + { + // Can't go through trip wire. + return false; + } + } } // passed the subsector ok @@ -728,6 +737,15 @@ static boolean P_CrossBotTraversalSubsector(size_t num, register traceblocking_t return false; } + if (tb->compareThing->player != NULL) + { + if (P_IsLineTripWire(line) == true && K_TripwirePass(tb->compareThing->player) == false) + { + // Can't go through trip wire. + return false; + } + } + // set openrange, opentop, openbottom tmx = tb->compareThing->x; tmy = tb->compareThing->y; @@ -742,10 +760,13 @@ static boolean P_CrossBotTraversalSubsector(size_t num, register traceblocking_t return false; } - // Treat damage sectors like walls if (tb->compareThing->player != NULL) { - boolean alreadyHates = K_BotHatesThisSector(tb->compareThing->player, tb->compareThing->subsector->sector, tb->compareThing->x, tb->compareThing->y); + // Treat damage sectors like walls + boolean alreadyHates = K_BotHatesThisSector( + tb->compareThing->player, tb->compareThing->subsector->sector, + tb->compareThing->x, tb->compareThing->y + ); if (alreadyHates == false) { @@ -755,18 +776,16 @@ static boolean P_CrossBotTraversalSubsector(size_t num, register traceblocking_t P_ClosestPointOnLine(tb->compareThing->x, tb->compareThing->y, line, &pos); lineside = P_PointOnLineSide(tb->compareThing->x, tb->compareThing->y, line); - if (K_BotHatesThisSector(tb->compareThing->player, ((lineside == 1) ? line->frontsector : line->backsector), pos.x, pos.y)) + if (K_BotHatesThisSector( + tb->compareThing->player, + ((lineside == 1) ? line->frontsector : line->backsector), + pos.x, pos.y + )) { // This line does not block us, but we don't want to be in it. return false; } } - - if (P_IsLineTripWire(line) == true && K_TripwirePass(tb->compareThing->player) == false) - { - // Can't go through trip wire. - return false; - } } }