From e0db52629d9e27d55e8ee386854bb64dd5764ae3 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 22 Feb 2013 01:34:16 +0000 Subject: [PATCH] - Fixed: RandomSpawner could hang on lists with monsters when nomonsters is enabled or with 'None' items. SVN r4155 (trunk) --- src/g_shared/a_randomspawner.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/g_shared/a_randomspawner.cpp b/src/g_shared/a_randomspawner.cpp index 549c957a5..fc7ca8cf9 100644 --- a/src/g_shared/a_randomspawner.cpp +++ b/src/g_shared/a_randomspawner.cpp @@ -59,22 +59,24 @@ class ARandomSpawner : public AActor // Take a random number... n = pr_randomspawn(n); // And iterate in the array up to the random number chosen. - while (n > -1) + while (n > -1 && di != NULL) { - if (di->Name != NAME_None) + if (di->Name != NAME_None && + (!nomonsters || !(GetDefaultByType(PClass::FindClass(di->Name))->flags3 & MF3_ISMONSTER))) { - if (!nomonsters || !(GetDefaultByType(PClass::FindClass(di->Name))->flags3 & MF3_ISMONSTER)) - { - n -= di->amount; - if ((di->Next != NULL) && (n > -1)) - di = di->Next; - else - n = -1; - } + n -= di->amount; + if ((di->Next != NULL) && (n > -1)) + di = di->Next; + else + n = -1; + } + else + { + di = di->Next; } } // So now we can spawn the dropped item. - if (bouncecount >= MAX_RANDOMSPAWNERS_RECURSION) // Prevents infinite recursions + if (di == NULL || bouncecount >= MAX_RANDOMSPAWNERS_RECURSION) // Prevents infinite recursions { Spawn("Unknown", x, y, z, NO_REPLACE); // Show that there's a problem. Destroy();