From 350fc0d35956bdc91f19e5b83bf45b6d72455e5f Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Fri, 8 Apr 2022 22:52:37 -0700 Subject: [PATCH] Server: Perform extra count check for Spawn_SelectRandom() to avoid recursion. --- src/server/spawn.qc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/server/spawn.qc b/src/server/spawn.qc index 563672f2..6feacbea 100644 --- a/src/server/spawn.qc +++ b/src/server/spawn.qc @@ -92,11 +92,19 @@ entity Spawn_SelectRandom(string cname) float max = 0; + /* check if _any_ entity of this type exists */ + entity testcase = find(world, ::classname, cname); + /* count our max count */ for (entity e = world;(e = find(e, ::classname, cname));) { max++; } + if (max <= 0) { + print(sprintf("^1Error: %s is not present on this map.\n", cname)); + return __NULL__; + } + for (int i = random(1, max); i > 0; i--) { spot = find(spot, classname, cname); }