From 2da868656eeba7197f1a371a5f097dae42a5c66c Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Wed, 27 Jan 2016 15:22:05 -0600 Subject: [PATCH] Finalize loop and prioritize missile searching. --- src/thingdef/thingdef_codeptr.cpp | 39 ++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index d0eb6baf09..4f674955cc 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -4977,6 +4977,19 @@ enum RadiusGiveFlags static bool DoRadiusGive(AActor *self, AActor *thing, const PClass *item, int amount, fixed_t distance, int flags, const PClass *filter, FName species, fixed_t mindist) { + // [MC] We only want to make an exception for missiles here. Nothing else. + bool missilePass = !!((flags & RGF_MISSILES) && thing->isMissile()); + if (thing == self) + { + if (!(flags & RGF_GIVESELF)) + return false; + } + else if (thing->isMissile()) + { + if (!missilePass) + return false; + } + //[MC] Check for a filter, species, and the related exfilter/expecies/either flag(s). bool filterpass = DoCheckClass(thing, filter, !!(flags & RGF_EXFILTER)), speciespass = DoCheckSpecies(thing, species, !!(flags & RGF_EXSPECIES)); @@ -4987,12 +5000,6 @@ static bool DoRadiusGive(AActor *self, AActor *thing, const PClass *item, int am return false; } - if (thing == self) - { - if (!(flags & RGF_GIVESELF)) - return false; - } - //Check for target, master, and tracer flagging. bool targetPass = true; bool masterPass = true; @@ -5039,7 +5046,6 @@ static bool DoRadiusGive(AActor *self, AActor *thing, const PClass *item, int am } bool itemPass = !!((flags & RGF_ITEMS) && thing->IsKindOf(RUNTIME_CLASS(AInventory))); - bool missilePass = !!((flags & RGF_MISSILES) && thing->flags & MF_MISSILE); if (selfPass || monsterPass || corpsePass || killedPass || itemPass || objectPass || missilePass || playerPass || voodooPass) { @@ -5120,7 +5126,24 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusGive) } AActor *thing; bool given = false; - + if (flags & RGF_MISSILES) + { + TThinkerIterator it; + while ((thing = it.Next())) + { + bool giving = !!(DoRadiusGive(self, thing, item, amount, distance, flags, filter, species, mindist)); + if (giving) given = true; + } + } + else + { + FBlockThingsIterator it(FBoundingBox(self->X(), self->Y(), distance)); + while ((thing = it.Next())) + { + bool giving = !!(DoRadiusGive(self, thing, item, amount, distance, flags, filter, species, mindist)); + if (giving) given = true; + } + } ACTION_SET_RESULT(given); }