From 7b8274566532da771721905e0928e4d9640b481e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Oct 2008 20:57:48 +0000 Subject: [PATCH] - added dumpstates CCMD for debugging. SVN r1256 (trunk) --- src/p_states.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/p_states.cpp b/src/p_states.cpp index 03762888b..3ca914b3e 100644 --- a/src/p_states.cpp +++ b/src/p_states.cpp @@ -38,6 +38,7 @@ #include "templates.h" #include "cmdlib.h" #include "i_system.h" +#include "c_dispatch.h" #include "thingdef/thingdef.h" // Each state is owned by an actor. Actors can own any number of @@ -816,3 +817,38 @@ int FStateDefinitions::FinishStates (FActorInfo *actor, AActor *defaults, TArray return count; } + +void DumpStateHelper(FStateLabels *StateList, const FString &prefix) +{ + for (int i = 0; i < StateList->NumLabels; i++) + { + if (StateList->Labels[i].State != NULL) + { + const PClass *owner = FState::StaticFindStateOwner(StateList->Labels[i].State); + if (owner == NULL) + { + Printf(PRINT_LOG, "%s%s: invalid\n", prefix.GetChars(), StateList->Labels[i].Label.GetChars()); + } + else + { + Printf(PRINT_LOG, "%s%s: %s.%d\n", prefix.GetChars(), StateList->Labels[i].Label.GetChars(), + owner->TypeName.GetChars(), StateList->Labels[i].State - owner->ActorInfo->OwnedStates); + } + } + if (StateList->Labels[i].Children != NULL) + { + DumpStateHelper(StateList->Labels[i].Children, prefix + '.' + StateList->Labels[i].Label.GetChars()); + } + } +} + +CCMD(dumpstates) +{ + for (unsigned int i = 0; i < PClass::m_RuntimeActors.Size(); ++i) + { + FActorInfo *info = PClass::m_RuntimeActors[i]->ActorInfo; + Printf(PRINT_LOG, "State labels for %s\n", info->Class->TypeName.GetChars()); + DumpStateHelper(info->StateList, ""); + Printf(PRINT_LOG, "----------------------------\n"); + } +} \ No newline at end of file