mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
- consolidated the check for "is actor an owned inventory item" into a subfunction.
This check occured 9 times in the source, better have it only once.
This commit is contained in:
parent
ee08412e49
commit
319f8743db
8 changed files with 20 additions and 32 deletions
|
@ -1271,6 +1271,7 @@ public:
|
|||
void UnlinkFromWorld(FLinkContext *ctx);
|
||||
void AdjustFloorClip ();
|
||||
bool InStateSequence(FState * newstate, FState * basestate);
|
||||
bool IsMapActor();
|
||||
int GetTics(FState * newstate);
|
||||
bool SetState (FState *newstate, bool nofunction=false);
|
||||
virtual void SplashCheck();
|
||||
|
|
|
@ -914,10 +914,7 @@ static bool IsActorACountItem(AActor *mo)
|
|||
// [SP] for all actors
|
||||
static bool IsActor(AActor *mo)
|
||||
{
|
||||
if (mo->IsKindOf(RUNTIME_CLASS(AInventory)))
|
||||
return static_cast<AInventory *>(mo)->Owner == NULL; // [SP] Exclude inventory-owned items
|
||||
else
|
||||
return true;
|
||||
return mo->IsMapActor();
|
||||
}
|
||||
|
||||
// [SP] modified - now allows showing count only, new arg must be passed. Also now still counts regardless, if lists are printed.
|
||||
|
|
|
@ -2100,7 +2100,7 @@ static int RemoveClass(const PClass *cls)
|
|||
continue;
|
||||
}
|
||||
// [SP] Don't remove owned inventory objects.
|
||||
if (actor->IsKindOf(RUNTIME_CLASS(AInventory)) && static_cast<AInventory *>(actor)->Owner != NULL)
|
||||
if (!actor->IsMapActor())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -3134,16 +3134,7 @@ void FParser::SF_MapThingNumExist()
|
|||
}
|
||||
else
|
||||
{
|
||||
// Inventory items in the player's inventory have to be considered non-present.
|
||||
if (SpawnedThings[intval]->IsKindOf(RUNTIME_CLASS(AInventory)) &&
|
||||
barrier_cast<AInventory*>(SpawnedThings[intval])->Owner != NULL)
|
||||
{
|
||||
t_return.value.i = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
t_return.value.i = 1;
|
||||
}
|
||||
t_return.value.i = SpawnedThings[intval]->IsMapActor();
|
||||
t_return.type = svt_int;
|
||||
}
|
||||
}
|
||||
|
@ -3673,8 +3664,7 @@ again:
|
|||
{
|
||||
if (mo->IsA(pClass))
|
||||
{
|
||||
if (!mo->IsKindOf (RUNTIME_CLASS(AInventory)) ||
|
||||
static_cast<AInventory *>(mo)->Owner == NULL)
|
||||
if (mo->IsMapActor())
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
|
|
@ -129,9 +129,7 @@ AActor* actorvalue(const svalue_t &svalue)
|
|||
if(svalue.type == svt_mobj)
|
||||
{
|
||||
// Inventory items in the player's inventory have to be considered non-present.
|
||||
if (svalue.value.mobj != NULL &&
|
||||
svalue.value.mobj->IsKindOf(RUNTIME_CLASS(AInventory)) &&
|
||||
static_cast<AInventory*>(svalue.value.mobj)->Owner != NULL)
|
||||
if (svalue.value.mobj == NULL || !svalue.value.mobj->IsMapActor())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -150,9 +148,7 @@ AActor* actorvalue(const svalue_t &svalue)
|
|||
return NULL;
|
||||
}
|
||||
// Inventory items in the player's inventory have to be considered non-present.
|
||||
if (SpawnedThings[intval] != NULL &&
|
||||
SpawnedThings[intval]->IsKindOf(RUNTIME_CLASS(AInventory)) &&
|
||||
barrier_cast<AInventory*>(SpawnedThings[intval])->Owner != NULL)
|
||||
if (svalue.value.mobj == NULL || !svalue.value.mobj->IsMapActor())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -3697,8 +3697,7 @@ do_count:
|
|||
if (tag == -1 || tagManager.SectorHasTag(actor->Sector, tag))
|
||||
{
|
||||
// Don't count items in somebody's inventory
|
||||
if (!actor->IsKindOf (RUNTIME_CLASS(AInventory)) ||
|
||||
static_cast<AInventory *>(actor)->Owner == NULL)
|
||||
if (actor->IsMapActor())
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
@ -3717,8 +3716,7 @@ do_count:
|
|||
if (tag == -1 || tagManager.SectorHasTag(actor->Sector, tag))
|
||||
{
|
||||
// Don't count items in somebody's inventory
|
||||
if (!actor->IsKindOf (RUNTIME_CLASS(AInventory)) ||
|
||||
static_cast<AInventory *>(actor)->Owner == NULL)
|
||||
if (actor->IsMapActor())
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
|
|
@ -620,6 +620,14 @@ DEFINE_ACTION_FUNCTION(AActor, InStateSequence)
|
|||
PARAM_POINTER(basestate, FState);
|
||||
ACTION_RETURN_BOOL(self->InStateSequence(newstate, basestate));
|
||||
}
|
||||
|
||||
|
||||
bool AActor::IsMapActor()
|
||||
{
|
||||
// [SP] Don't remove owned inventory objects.
|
||||
return (!IsKindOf(RUNTIME_CLASS(AInventory)) || static_cast<AInventory *>(this)->Owner == nullptr);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// AActor::GetTics
|
||||
|
|
|
@ -423,7 +423,7 @@ void P_RemoveThing(AActor * actor)
|
|||
if (actor->player == NULL || actor != actor->player->mo)
|
||||
{
|
||||
// Don't also remove owned inventory items
|
||||
if (actor->IsKindOf(RUNTIME_CLASS(AInventory)) && static_cast<AInventory*>(actor)->Owner != NULL) return;
|
||||
if (!actor->IsMapActor())
|
||||
|
||||
// be friendly to the level statistics. ;)
|
||||
actor->ClearCounters();
|
||||
|
@ -774,13 +774,11 @@ int P_Thing_CheckProximity(AActor *self, PClass *classname, double distance, int
|
|||
else if (classname != mo->GetClass())
|
||||
continue;
|
||||
|
||||
if (mo->IsKindOf(RUNTIME_CLASS(AInventory)))
|
||||
if (!mo->IsMapActor())
|
||||
{
|
||||
// Skip owned item because its position could remain unchanged since attachment to owner
|
||||
// Most likely it is the last location of this item in the world before pick up
|
||||
AInventory *const inventory = static_cast<AInventory*>(mo);
|
||||
if (inventory != nullptr && inventory->Owner != nullptr)
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
// [MC]Make sure it's in range and respect the desire for Z or not. The function forces it to use
|
||||
|
|
Loading…
Reference in a new issue