Added the following ccmds:

actorlist, actornum, monsternum, itemsnum, countitemsnum
Modified the following ccmds:
 monster, items, countitems

All commands with "num" at the end simply print a count of their respective filters, all other listed commands now print a list and a count.
This commit is contained in:
raa-eruanna 2016-09-15 15:09:36 -04:00
parent 0d27996a64
commit ac70f77e44

View file

@ -923,10 +923,18 @@ 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)
// [SP] for all actors
static bool IsActor(AActor *mo)
{
return true;
}
// [SP] modified - now allows showing count only, new arg must be passed. Also now still counts regardless, if lists are printed.
static void PrintFilteredActorList(const ActorTypeChecker IsActorType, const char *FilterName, bool countOnly)
{
AActor *mo;
const PClass *FilterClass = NULL;
int counter = 0;
if (FilterName != NULL)
{
@ -943,10 +951,32 @@ static void PrintFilteredActorList(const ActorTypeChecker IsActorType, const cha
{
if ((FilterClass == NULL || mo->IsA(FilterClass)) && IsActorType(mo))
{
Printf ("%s at (%f,%f,%f)\n",
mo->GetClass()->TypeName.GetChars(), mo->X(), mo->Y(), mo->Z());
counter++;
if (!countOnly)
Printf ("%s at (%f,%f,%f)\n",
mo->GetClass()->TypeName.GetChars(), mo->X(), mo->Y(), mo->Z());
}
}
Printf("%i match(s) found.\n", counter);
}
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
CCMD(actorlist) // [SP] print all actors (this can get quite big?)
{
if (CheckCheatmode ()) return;
PrintFilteredActorList(IsActor, argv.argc() > 1 ? argv[1] : NULL, false);
}
CCMD(actornum) // [SP] count all actors
{
if (CheckCheatmode ()) return;
PrintFilteredActorList(IsActor, argv.argc() > 1 ? argv[1] : NULL, true);
}
//-----------------------------------------------------------------------------
@ -958,7 +988,14 @@ CCMD(monster)
{
if (CheckCheatmode ()) return;
PrintFilteredActorList(IsActorAMonster, argv.argc() > 1 ? argv[1] : NULL);
PrintFilteredActorList(IsActorAMonster, argv.argc() > 1 ? argv[1] : NULL, false);
}
CCMD(monsternum) // [SP] count monsters
{
if (CheckCheatmode ()) return;
PrintFilteredActorList(IsActorAMonster, argv.argc() > 1 ? argv[1] : NULL, true);
}
//-----------------------------------------------------------------------------
@ -970,7 +1007,14 @@ CCMD(items)
{
if (CheckCheatmode ()) return;
PrintFilteredActorList(IsActorAnItem, argv.argc() > 1 ? argv[1] : NULL);
PrintFilteredActorList(IsActorAnItem, argv.argc() > 1 ? argv[1] : NULL, false);
}
CCMD(itemsnum) // [SP] # of any items
{
if (CheckCheatmode ()) return;
PrintFilteredActorList(IsActorAnItem, argv.argc() > 1 ? argv[1] : NULL, true);
}
//-----------------------------------------------------------------------------
@ -982,7 +1026,14 @@ CCMD(countitems)
{
if (CheckCheatmode ()) return;
PrintFilteredActorList(IsActorACountItem, argv.argc() > 1 ? argv[1] : NULL);
PrintFilteredActorList(IsActorACountItem, argv.argc() > 1 ? argv[1] : NULL, false);
}
CCMD(countitemsnum) // [SP] # of counted items
{
if (CheckCheatmode ()) return;
PrintFilteredActorList(IsActorACountItem, argv.argc() > 1 ? argv[1] : NULL, true);
}
//-----------------------------------------------------------------------------