diff --git a/src/p_inter.c b/src/p_inter.c index bce0f6261..a37015029 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -830,6 +830,8 @@ void P_CheckTimeLimit(void) thinker_t *th; mobj_t *center = NULL; + fixed_t rx, ry; + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { mobj_t *thismo; @@ -861,7 +863,24 @@ void P_CheckTimeLimit(void) battleovertime.z = center->z; } - battleovertime.initial_radius = 4096 * mapobjectscale; + // Get largest radius from center point to minimap edges + + rx = max( + abs(battleovertime.x - (minimapinfo.min_x * FRACUNIT)), + abs(battleovertime.x - (minimapinfo.max_x * FRACUNIT)) + ); + + ry = max( + abs(battleovertime.y - (minimapinfo.min_y * FRACUNIT)), + abs(battleovertime.y - (minimapinfo.max_y * FRACUNIT)) + ); + + battleovertime.initial_radius = min( + max(max(rx, ry), 4096 * mapobjectscale), + // Prevent overflow in K_RunBattleOvertime + FixedDiv(INT32_MAX, M_PI_FIXED) / 2 + ); + battleovertime.radius = battleovertime.initial_radius; battleovertime.enabled = 1;