mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2025-02-21 19:00:56 +00:00
Fixed crash in RandomSpawner with -nomonsters
See http://forum.zdoom.org/viewtopic.php?f=2&t=49520
This commit is contained in:
parent
e9a3f7f5fc
commit
49519db257
1 changed files with 14 additions and 2 deletions
|
@ -19,6 +19,18 @@
|
||||||
#define MAX_RANDOMSPAWNERS_RECURSION 32 // Should be largely more than enough, honestly.
|
#define MAX_RANDOMSPAWNERS_RECURSION 32 // Should be largely more than enough, honestly.
|
||||||
static FRandom pr_randomspawn("RandomSpawn");
|
static FRandom pr_randomspawn("RandomSpawn");
|
||||||
|
|
||||||
|
static bool IsMonster(const FDropItem *di)
|
||||||
|
{
|
||||||
|
const PClass *pclass = PClass::FindClass(di->Name);
|
||||||
|
|
||||||
|
if (NULL == pclass)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetDefaultByType(pclass)->flags3 & MF3_ISMONSTER;
|
||||||
|
}
|
||||||
|
|
||||||
class ARandomSpawner : public AActor
|
class ARandomSpawner : public AActor
|
||||||
{
|
{
|
||||||
DECLARE_CLASS (ARandomSpawner, AActor)
|
DECLARE_CLASS (ARandomSpawner, AActor)
|
||||||
|
@ -41,7 +53,7 @@ class ARandomSpawner : public AActor
|
||||||
{
|
{
|
||||||
if (di->Name != NAME_None)
|
if (di->Name != NAME_None)
|
||||||
{
|
{
|
||||||
if (!nomonsters || !(GetDefaultByType(PClass::FindClass(di->Name))->flags3 & MF3_ISMONSTER))
|
if (!nomonsters || !IsMonster(di))
|
||||||
{
|
{
|
||||||
if (di->amount < 0) di->amount = 1; // default value is -1, we need a positive value.
|
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.
|
n += di->amount; // this is how we can weight the list.
|
||||||
|
@ -62,7 +74,7 @@ class ARandomSpawner : public AActor
|
||||||
while (n > -1 && di != NULL)
|
while (n > -1 && di != NULL)
|
||||||
{
|
{
|
||||||
if (di->Name != NAME_None &&
|
if (di->Name != NAME_None &&
|
||||||
(!nomonsters || !(GetDefaultByType(PClass::FindClass(di->Name))->flags3 & MF3_ISMONSTER)))
|
(!nomonsters || !IsMonster(di)))
|
||||||
{
|
{
|
||||||
n -= di->amount;
|
n -= di->amount;
|
||||||
if ((di->Next != NULL) && (n > -1))
|
if ((di->Next != NULL) && (n > -1))
|
||||||
|
|
Loading…
Reference in a new issue