From 7d90117fb9bf11f13d7df82c85df713566ed2624 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 20 Feb 2013 02:47:01 +0000 Subject: [PATCH] - Fixed: RandomSpawner should observe the nomonsters flags when deciding what to spawn. SVN r4153 (trunk) --- src/g_shared/a_randomspawner.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/g_shared/a_randomspawner.cpp b/src/g_shared/a_randomspawner.cpp index 5633c7b79a..549c957a5c 100644 --- a/src/g_shared/a_randomspawner.cpp +++ b/src/g_shared/a_randomspawner.cpp @@ -31,6 +31,7 @@ class ARandomSpawner : public AActor FDropItem *di; // di will be our drop item list iterator FDropItem *drop; // while drop stays as the reference point. int n=0; + bool nomonsters = (dmflags & DF_NO_MONSTERS) || (level.flags2 & LEVEL2_NOMONSTERS); Super::BeginPlay(); drop = di = GetDropItems(); @@ -40,11 +41,19 @@ class ARandomSpawner : public AActor { if (di->Name != NAME_None) { - if (di->amount < 0) di->amount = 1; // default value is -1, we need a positive value. - n += di->amount; // this is how we can weight the list. + if (!nomonsters || !(GetDefaultByType(PClass::FindClass(di->Name))->flags3 & MF3_ISMONSTER)) + { + if (di->amount < 0) di->amount = 1; // default value is -1, we need a positive value. + n += di->amount; // this is how we can weight the list. + } di = di->Next; } } + if (n == 0) + { // Nothing left to spawn. They must have all been monsters, and monsters are disabled. + Destroy(); + return; + } // Then we reset the iterator to the start position... di = drop; // Take a random number... @@ -54,15 +63,22 @@ class ARandomSpawner : public AActor { if (di->Name != NAME_None) { - n -= di->amount; - if ((di->Next != NULL) && (n > -1)) di = di->Next; else n = -1; + 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; + } } } // So now we can spawn the dropped item. if (bouncecount >= MAX_RANDOMSPAWNERS_RECURSION) // Prevents infinite recursions { Spawn("Unknown", x, y, z, NO_REPLACE); // Show that there's a problem. - Destroy(); return; + Destroy(); + return; } else if (pr_randomspawn() <= di->probability) // prob 255 = always spawn, prob 0 = never spawn. { @@ -167,8 +183,10 @@ class ARandomSpawner : public AActor if (rep && ((rep->flags4 & MF4_BOSSDEATH) || (rep->flags2 & MF2_BOSS))) boss = true; } - if (boss) this->tracer = newmobj; - else Destroy(); // "else" because a boss-replacing spawner must wait until it can call A_BossDeath. + if (boss) + this->tracer = newmobj; + else // "else" because a boss-replacing spawner must wait until it can call A_BossDeath. + Destroy(); } void Tick() // This function is needed for handling boss replacers