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