1) swap out the pattern of

CODE: SELECT ALL
#if defined (WIN32) || defined (LINUX)
  char    buf[4096], *p = buf;
  sprintf(buf, "Some debug message showing  variables %i and %i\n", variableA, variableB);
  OutputDebugString(buf);
#endif


new paradigm:
CODE: SELECT ALL
DebugTrace("Some debug message showing variables " << variableA <<" and " << variableB);


No more dealing with formatting sprintf crap, just stream out variables. Also, DebugTrace washes out in release automatically. (TODO, need to sweep through the rest of the app to apply the changes to all the cases where OutputDebugString() is being called)

2) added two traces to follow adding/resolving things on the stack;

3) changed the uninformative "stack object" string that was the default for base class interrupts to use typeinfo(*this).name() so that you can actually see the derived class in the trace output. Here's a sample of what my trace output looks like now:
Action added to stack: Devoted Hero
Resolving Action on stack: Devoted Hero
Action added to stack: class NextGamePhase
Resolving Action on stack: class NextGamePhase
Action added to stack: class NextGamePhase
Resolving Action on stack: class NextGamePhase
Action added to stack: class StackAbility
Resolving Action on stack: class StackAbility
Action added to stack: class DrawAction
Resolving Action on stack: class DrawAction

4) replaced some hardcoded 0 / -1 values with their proper enums.
This commit is contained in:
wrenczes@gmail.com
2010-10-06 09:28:45 +00:00
parent 9c982475fe
commit 291a0d0312
3 changed files with 54 additions and 32 deletions
+29
View File
@@ -0,0 +1,29 @@
#ifndef DEBUGROUTINES_H
#define DEBUGROUTINES_H
// dirty, but I get OS header includes this way
#include "JGE.h"
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#if defined (WIN32) || defined (LINUX)
#ifdef _DEBUG
#define DebugTrace(inString) \
{ \
std::ostringstream stream; \
stream << inString << std::endl; \
OutputDebugString(stream.str().c_str()); \
}
#endif //#ifdef _DEBUG
#endif // Win32, Linux
#ifndef DebugTrace
#define DebugTrace(inString) (void (0))
#endif
#endif // DEBUGROUTINES_H