- Improvements to some of the actor debug CCMDs.

- 'monster' and 'items' can now filter the list if an argument is passed (like with 'kill');
- added 'countitems', which will show only the 'count items' in the current map, with the same filter parameter as 'monster' and 'items'.
- reorganize the code to reduce the duplication.
This commit is contained in:
Edoardo Prezioso 2015-03-25 22:25:00 +01:00
parent 21314fe867
commit 66b090cd44

View file

@ -889,6 +889,50 @@ CCMD(info)
"the NOBLOCKMAP flag or have height/radius of 0.\n"); "the NOBLOCKMAP flag or have height/radius of 0.\n");
} }
typedef bool (*ActorTypeChecker) (AActor *);
static bool IsActorAMonster(AActor *mo)
{
return mo->flags3&MF3_ISMONSTER && !(mo->flags&MF_CORPSE) && !(mo->flags&MF_FRIENDLY);
}
static bool IsActorAnItem(AActor *mo)
{
return mo->IsKindOf(RUNTIME_CLASS(AInventory)) && mo->flags&MF_SPECIAL;
}
static bool IsActorACountItem(AActor *mo)
{
return mo->IsKindOf(RUNTIME_CLASS(AInventory)) && mo->flags&MF_SPECIAL && mo->flags&MF_COUNTITEM;
}
static void PrintFilteredActorList(const ActorTypeChecker IsActorType, const char *FilterName)
{
AActor *mo;
const PClass *FilterClass = NULL;
if (FilterName != NULL)
{
FilterClass = PClass::FindClass(FilterName);
if (FilterClass == NULL || FilterClass->ActorInfo == NULL)
{
Printf("%s is not an actor class.\n", FilterName);
return;
}
}
TThinkerIterator<AActor> it;
while ( (mo = it.Next()) )
{
if ((FilterClass == NULL || mo->IsA(FilterClass)) && IsActorType(mo))
{
Printf ("%s at (%d,%d,%d)\n",
mo->GetClass()->TypeName.GetChars(),
mo->x >> FRACBITS, mo->y >> FRACBITS, mo->z >> FRACBITS);
}
}
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// //
// //
@ -896,20 +940,9 @@ CCMD(info)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
CCMD(monster) CCMD(monster)
{ {
AActor * mo;
if (CheckCheatmode ()) return; if (CheckCheatmode ()) return;
TThinkerIterator<AActor> it;
while ( (mo = it.Next()) ) PrintFilteredActorList(IsActorAMonster, argv.argc() > 1 ? argv[1] : NULL);
{
if (mo->flags3&MF3_ISMONSTER && !(mo->flags&MF_CORPSE) && !(mo->flags&MF_FRIENDLY))
{
Printf ("%s at (%d,%d,%d)\n",
mo->GetClass()->TypeName.GetChars(),
mo->x >> FRACBITS, mo->y >> FRACBITS, mo->z >> FRACBITS);
}
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -919,20 +952,21 @@ CCMD(monster)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
CCMD(items) CCMD(items)
{ {
AActor * mo;
if (CheckCheatmode ()) return; if (CheckCheatmode ()) return;
TThinkerIterator<AActor> it;
while ( (mo = it.Next()) ) PrintFilteredActorList(IsActorAnItem, argv.argc() > 1 ? argv[1] : NULL);
{
if (mo->IsKindOf(RUNTIME_CLASS(AInventory)) && mo->flags&MF_SPECIAL)
{
Printf ("%s at (%d,%d,%d)\n",
mo->GetClass()->TypeName.GetChars(),
mo->x >> FRACBITS, mo->y >> FRACBITS, mo->z >> FRACBITS);
}
} }
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
CCMD(countitems)
{
if (CheckCheatmode ()) return;
PrintFilteredActorList(IsActorACountItem, argv.argc() > 1 ? argv[1] : NULL);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------