Server: Perform extra count check for Spawn_SelectRandom() to avoid recursion.
This commit is contained in:
parent
e827c51e4b
commit
350fc0d359
1 changed files with 8 additions and 0 deletions
|
@ -92,11 +92,19 @@ entity Spawn_SelectRandom(string cname)
|
||||||
|
|
||||||
float max = 0;
|
float max = 0;
|
||||||
|
|
||||||
|
/* check if _any_ entity of this type exists */
|
||||||
|
entity testcase = find(world, ::classname, cname);
|
||||||
|
|
||||||
/* count our max count */
|
/* count our max count */
|
||||||
for (entity e = world;(e = find(e, ::classname, cname));) {
|
for (entity e = world;(e = find(e, ::classname, cname));) {
|
||||||
max++;
|
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--) {
|
for (int i = random(1, max); i > 0; i--) {
|
||||||
spot = find(spot, classname, cname);
|
spot = find(spot, classname, cname);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue