From 317259a459ac3e7b050070a78b2a42746228851e Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Sat, 8 Jul 2017 11:41:20 +0100 Subject: [PATCH] Two fixes to playersforexit changes. * Crash prevention if total somehow becomes zero. * Don't waste time multiplying and demultiplying the HUD check if it's just gonna net you the same number. --- src/p_user.c | 2 +- src/st_stuff.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 9ede28f96..052018c1e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9435,7 +9435,7 @@ void P_PlayerThink(player_t *player) exiting++; } - if (((4*exiting)/total) >= cv_playersforexit.value) + if (!total || ((4*exiting)/total) >= cv_playersforexit.value) { if (server) SendNetXCmd(XD_EXITLEVEL, NULL, 0); diff --git a/src/st_stuff.c b/src/st_stuff.c index 7a49b0402..33192eedb 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2013,9 +2013,12 @@ static void ST_overlayDrawer(void) exiting++; } - total *= cv_playersforexit.value; - if (total % 4) total += 4; // round up - total /= 4; + if (cv_playersforexit.value != 4) + { + total *= cv_playersforexit.value; + if (total % 4) total += 4; // round up + total /= 4; + } if (exiting >= total) ;