From 217e34b05eff58af1261bcb857ab5f378e721ac7 Mon Sep 17 00:00:00 2001 From: MotoLegacy Date: Sun, 24 Nov 2024 18:21:55 -0800 Subject: [PATCH] SERVER: Give up after X attempts to pick random Perk-A-Cola --- source/server/entities/perk_a_cola.qc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/server/entities/perk_a_cola.qc b/source/server/entities/perk_a_cola.qc index ada2836..c0f07ab 100644 --- a/source/server/entities/perk_a_cola.qc +++ b/source/server/entities/perk_a_cola.qc @@ -643,7 +643,8 @@ void() Perk_RandomDecide = } // Choose which of the eight machines we want to become, if permitted. - while (true) { + float num_attempts; + for(num_attempts = 64; num_attempts > 0; num_attempts--) { i = random(); // Quick Revive if (i < (1/8) && (self.spawnflags & SPAWNFLAG_PERKRANDOM_QUICKREVIVE)) { @@ -694,6 +695,9 @@ void() Perk_RandomDecide = break; } } + + if (!num_attempts) + objerror("perk_random: Failed 64 times to pick a Perk-A-Cola. Bailing!\n"); }; void() Perk_RandomPrecaches =