convert line ends
[canaan.git] / prj / cam / src / ai / aidbgcmp.cpp
blob38399947ad19f478f7712bd8a0bb1d9b9ebade1d
1 /*
2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
4 */
6 ///////////////////////////////////////////////////////////////////////////////
7 // $Header: r:/t2repos/thief2/src/ai/aidbgcmp.cpp,v 1.11 2000/02/19 12:17:29 toml Exp $
8 //
9 //
12 // #define PROFILE_ON 1
14 #include <lg.h>
15 #include <mprintf.h>
16 #include <str.h>
18 #include <label.h>
19 #include <speech.h>
20 #include <tagdbin.h>
22 #include <aiapiabl.h>
23 #include <aiapiact.h>
24 #include <aidbgcmp.h>
25 #include <aidebug.h>
26 #include <aibasctm.h>
27 #include <aigoal.h>
28 #include <memall.h>
29 #include <dbmem.h> // must be last header!
31 ///////////////////////////////////////////////////////////////////////////////
33 // CLASS: cAIFlowDebugger
36 STDMETHODIMP_(const char *) cAIFlowDebugger::GetName()
38 return "Flow debugging component";
41 ///////////////////////////////////////
43 STDMETHODIMP_(void) cAIFlowDebugger::Init()
45 SetNotifications(kAICN_ActionProgress | kAICN_GoalProgress | kAICN_ModeChange | kAICN_GoalChange | kAICN_ActionChange);
48 ///////////////////////////////////////
50 STDMETHODIMP_(void) cAIFlowDebugger::OnActionProgress(IAIAction * pAction)
52 #ifndef SHIP
53 // mprintf("***** %d\n", pAction->GetResult());
54 if (AIIsWatched(Flow, GetID()))
56 if (!pAction->InProgress())
58 cStr desc;
59 pAction->Describe(&desc);
60 AIWatch2(Flow,
61 GetID(),
62 "%s action \"%s\"",
63 (pAction->GetResult() == kAIR_Success) ? "completed" : "failed to complete",
64 desc.operator const char *());
67 #endif
70 ///////////////////////////////////////
72 STDMETHODIMP_(void) cAIFlowDebugger::OnGoalProgress(const cAIGoal * pGoal)
74 #ifndef SHIP
75 if (AIIsWatched(Flow, GetID()))
77 if (!pGoal->InProgress())
79 cStr desc;
80 pGoal->Describe(&desc);
81 AIWatch2(Flow,
82 GetID(),
83 "%s goal \"%s\"",
84 (pGoal->result == kAIR_Success) ? "satisfied" : "failed to satisfy",
85 desc.operator const char *());
88 #endif
91 ///////////////////////////////////////
93 STDMETHODIMP_(void) cAIFlowDebugger::OnModeChange(eAIMode previous, eAIMode mode)
95 AIWatch1(Flow,
96 GetID(),
97 "changed to mode \"%s\"",
98 AIGetModeName(mode));
101 ///////////////////////////////////////
103 STDMETHODIMP_(void) cAIFlowDebugger::OnGoalChange(const cAIGoal * pPrevious, const cAIGoal * pGoal)
105 // @TBD (toml 06-12-98): this whole class has to be ifndef ship
106 #ifndef SHIP
107 if (AIIsWatched(Flow, GetID()))
109 cStr desc;
110 const char * pszAbilityName;
111 if (pGoal)
113 pGoal->Describe(&desc);
114 pszAbilityName = pGoal->pOwner->GetName();
116 else
118 desc = "(No goal)";
119 pszAbilityName = "(none)";
122 AIWatch2(Flow, GetID(),
123 "changed goal to \"%s\", ability \"%s\"", desc.operator const char *(), pszAbilityName);
125 #endif
128 ///////////////////////////////////////
130 STDMETHODIMP_(void) cAIFlowDebugger::OnActionChange(IAIAction * pPrevious, IAIAction * pAction)
132 #ifndef SHIP
133 if (AIIsWatched(Flow, GetID()))
135 cStr desc;
136 const char * pszAbilityName;
137 if (pAction)
139 pAction->Describe(&desc);
140 pszAbilityName = pAction->Access()->pOwner->GetName();
142 else
144 desc = "(No action)";
145 pszAbilityName = "(none)";
148 AIWatch2(Flow, GetID(),
149 "changed action to \"%s\" from ability \"%s\"", desc.operator const char *(), pszAbilityName);
151 #endif
154 ///////////////////////////////////////////////////////////////////////////////