This commit is contained in:
Christoph Oelckers 2015-03-25 23:21:14 +01:00
commit d206e423b6

View file

@ -889,21 +889,42 @@ 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 *);
//
//
//
//-----------------------------------------------------------------------------
CCMD(monster)
{
AActor * mo;
if (CheckCheatmode ()) return; 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; TThinkerIterator<AActor> it;
while ( (mo = it.Next()) ) while ( (mo = it.Next()) )
{ {
if (mo->flags3&MF3_ISMONSTER && !(mo->flags&MF_CORPSE) && !(mo->flags&MF_FRIENDLY)) if ((FilterClass == NULL || mo->IsA(FilterClass)) && IsActorType(mo))
{ {
Printf ("%s at (%d,%d,%d)\n", Printf ("%s at (%d,%d,%d)\n",
mo->GetClass()->TypeName.GetChars(), mo->GetClass()->TypeName.GetChars(),
@ -912,6 +933,18 @@ CCMD(monster)
} }
} }
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
CCMD(monster)
{
if (CheckCheatmode ()) return;
PrintFilteredActorList(IsActorAMonster, argv.argc() > 1 ? argv[1] : NULL);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// //
// //
@ -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);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------