Server: Perform extra count check for Spawn_SelectRandom() to avoid recursion.

This commit is contained in:
Marco Cawthorne 2022-04-08 22:52:37 -07:00
parent e827c51e4b
commit 350fc0d359
Signed by: eukara
GPG key ID: C196CD8BA993248A

View file

@ -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);
}