Browse Source

Cleanup: Don't pass a writable scratch buffer off to dozens of virtual

functions -- that's just silly!
Michael Hansen 11 years ago
parent
commit
8323758d33
  1. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp
  2. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.h
  3. 62
      Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp
  4. 4
      Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h
  5. 11
      Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp
  6. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.h
  7. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrain.h
  8. 46
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp
  9. 8
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.h
  10. 14
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.cpp
  11. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.h
  12. 4
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainGeneric.cpp
  13. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainGeneric.h
  14. 25
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp
  15. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.h
  16. 147
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainStaticNPC.cpp
  17. 22
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp
  18. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.h
  19. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvTask.h
  20. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvTaskBrain.cpp
  21. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvTaskBrain.h
  22. 20
      Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp
  23. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.h
  24. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp

2
Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp

@ -716,7 +716,7 @@ int plAnimStage::GetPrevStage(int curStage)
}
// DUMPDEBUG
void plAnimStage::DumpDebug(bool active, int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt)
void plAnimStage::DumpDebug(bool active, int &x, int &y, int lineHeight, plDebugText &debugTxt)
{
plStringStream str;

2
Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.h

@ -231,7 +231,7 @@ public:
plAGAnimInstance *GetAnimInstance() const { return fAnimInstance; };
bool GetReverseOnIdle() { return fReverseOnIdle; }
void SetReverseOnIdle(bool onOff) { fReverseOnIdle = onOff; }
void DumpDebug(bool active, int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt);
void DumpDebug(bool active, int &x, int &y, int lineHeight, plDebugText &debugTxt);
// STANDARD PLASMA PROTOCOL
virtual void Read(hsStream *stream, hsResMgr *mgr);

62
Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp

@ -2649,7 +2649,6 @@ void plArmatureLODMod::Write(hsStream *stream, hsResMgr *mgr)
int plArmatureMod::RefreshDebugDisplay()
{
plDebugText &debugTxt = plDebugText::Instance();
char strBuf[ 2048 ];
int lineHeight = debugTxt.GetFontSize() + 4;
uint32_t scrnWidth, scrnHeight;
@ -2657,14 +2656,13 @@ int plArmatureMod::RefreshDebugDisplay()
int y = 10;
int x = 10;
DumpToDebugDisplay(x, y, lineHeight, strBuf, debugTxt);
DumpToDebugDisplay(x, y, lineHeight, debugTxt);
return y;
}
void plArmatureMod::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt)
void plArmatureMod::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{
sprintf(strBuf, "Armature <%s>:", fRootName.c_str());
debugTxt.DrawString(x, y, strBuf, 255, 128, 128);
debugTxt.DrawString(x, y, plString::Format("Armature <%s>:", fRootName.c_str()), 255, 128, 128);
y += lineHeight;
plSceneObject * SO = GetTarget(0);
@ -2675,9 +2673,8 @@ void plArmatureMod::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *str
hsPoint3 worldPos = l2w.GetTranslate();
const char *opaque = IsOpaque() ? "yes" : "no";
sprintf(strBuf, "position(world): %.2f, %.2f, %.2f Opaque: %3s",
worldPos.fX, worldPos.fY, worldPos.fZ, opaque);
debugTxt.DrawString(x, y, strBuf);
debugTxt.DrawString(x, y, plString::Format("position(world): %.2f, %.2f, %.2f Opaque: %3s",
worldPos.fX, worldPos.fY, worldPos.fZ, opaque));
y += lineHeight;
const char* frozen = "n.a.";
@ -2688,32 +2685,34 @@ void plArmatureMod::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *str
plKey world = nil;
if (fController)
world = fController->GetSubworld();
sprintf(strBuf, "In world: %s Frozen: %s", world ? world->GetName().c_str() : "nil", frozen);
debugTxt.DrawString(x,y, strBuf);
debugTxt.DrawString(x, y, plString::Format("In world: %s Frozen: %s",
world ? world->GetName().c_str() : "nil", frozen));
y+= lineHeight;
plString details;
if (fController)
{
hsPoint3 physPos;
GetPositionAndRotationSim(&physPos, nil);
const hsVector3& vel = fController->GetLinearVelocity();
sprintf(strBuf, "position(physical): <%.2f, %.2f, %.2f> velocity: <%5.2f, %5.2f, %5.2f>", physPos.fX, physPos.fY, physPos.fZ, vel.fX, vel.fY, vel.fZ);
details = plString::Format("position(physical): <%.2f, %.2f, %.2f> velocity: <%5.2f, %5.2f, %5.2f>",
physPos.fX, physPos.fY, physPos.fZ, vel.fX, vel.fY, vel.fZ);
}
else
{
sprintf(strBuf, "position(physical): no controller");
details = "position(physical): no controller";
}
debugTxt.DrawString(x, y, strBuf);
debugTxt.DrawString(x, y, details);
y += lineHeight;
}
DebugDumpMoveKeys(x, y, lineHeight, strBuf, debugTxt);
DebugDumpMoveKeys(x, y, lineHeight, debugTxt);
int i;
for(i = 0; i < fBrains.size(); i++)
{
plArmatureBrain *brain = fBrains[i];
brain->DumpToDebugDisplay(x, y, lineHeight, strBuf, debugTxt);
brain->DumpToDebugDisplay(x, y, lineHeight, debugTxt);
}
if (fClothingOutfit)
@ -2722,30 +2721,30 @@ void plArmatureMod::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *str
debugTxt.DrawString(x, y, "ItemsWorn:");
y += lineHeight;
strBuf[0] = '\0';
plStringStream outfit;
int itemCount = 0;
for (i = 0; i < fClothingOutfit->fItems.GetCount(); i++)
{
if (itemCount == 0)
strcat(strBuf, " ");
outfit << " ";
strcat(strBuf, fClothingOutfit->fItems[i]->fName);
outfit << fClothingOutfit->fItems[i]->fName;
itemCount++;
if (itemCount == 4)
{
debugTxt.DrawString(x, y, strBuf);
debugTxt.DrawString(x, y, outfit.GetString());
itemCount = 0;
strBuf[0] = '\0';
outfit.Truncate();
y += lineHeight;
}
if (itemCount > 0)
strcat(strBuf, ", ");
outfit << ", ";
}
if (itemCount > 0)
{
debugTxt.DrawString(x, y, strBuf);
debugTxt.DrawString(x, y, outfit.GetString());
y += lineHeight;
}
}
@ -2756,11 +2755,11 @@ void plArmatureMod::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *str
debugTxt.DrawString(x, y, "Relevance Regions:");
y += lineHeight;
sprintf(strBuf, " In: %s", plRelevanceMgr::Instance()->GetRegionNames(fRegionsImIn).c_str());
debugTxt.DrawString(x, y, strBuf);
debugTxt.DrawString(x, y, plString::Format(" In: %s",
plRelevanceMgr::Instance()->GetRegionNames(fRegionsImIn).c_str()));
y += lineHeight;
sprintf(strBuf, " Care about: %s", plRelevanceMgr::Instance()->GetRegionNames(fRegionsICareAbout).c_str());
debugTxt.DrawString(x, y, strBuf);
debugTxt.DrawString(x, y, plString::Format(" Care about: %s",
plRelevanceMgr::Instance()->GetRegionNames(fRegionsICareAbout).c_str()));
y += lineHeight;
}
}
@ -2799,17 +2798,18 @@ void plAvBoneMap::AddBoneMapping(uint32_t boneID, const plSceneObject *SO)
(fImp->fMap)[boneID] = SO;
}
void plArmatureMod::DebugDumpMoveKeys(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt)
void plArmatureMod::DebugDumpMoveKeys(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{
char buff[256];
sprintf(buff, "Mouse Input Map: %s", plAvatarInputInterface::GetInstance()->GetInputMapName());
snprintf(buff, sizeof(buff), "Mouse Input Map: %s", plAvatarInputInterface::GetInstance()->GetInputMapName());
debugTxt.DrawString(x, y, buff);
y += lineHeight;
sprintf(buff, "Turn strength: %.2f (key: %.2f, analog: %.2f)", GetTurnStrength(), GetKeyTurnStrength(), GetAnalogTurnStrength());
snprintf(buff, sizeof(buff), "Turn strength: %.2f (key: %.2f, analog: %.2f)",
GetTurnStrength(), GetKeyTurnStrength(), GetAnalogTurnStrength());
debugTxt.DrawString(x, y, buff);
y += lineHeight;
GetMoveKeyString(buff);
debugTxt.DrawString(x, y, buff);
y += lineHeight;

4
Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h

@ -278,7 +278,7 @@ public:
void SetTurnLeftKeyDown(bool status = true);
void SetTurnRightKeyDown(bool status = true);
void SetJumpKeyDown();
void DebugDumpMoveKeys(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt);
void DebugDumpMoveKeys(int &x, int &y, int lineHeight, plDebugText &debugTxt);
void GetMoveKeyString(char *buff);
void SynchIfLocal(double timeNow, int force); // Just physical state
@ -310,7 +310,7 @@ public:
void SetRootName(const plString &name);
int RefreshDebugDisplay();
void DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt);
void DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt);
void SetDebugState(bool state) { fDebugOn = (state != 0); }
bool GetDebugState() { return fDebugOn; }

11
Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp

@ -101,7 +101,7 @@ void plArmatureBehavior::Rewind()
fAnim->SetCurrentTime(0.0f, true);
}
void plArmatureBehavior::DumpDebug(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt)
void plArmatureBehavior::DumpDebug(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{
float strength = GetStrength();
const char *onOff = strength > 0 ? "on" : "off";
@ -109,16 +109,17 @@ void plArmatureBehavior::DumpDebug(int &x, int &y, int lineHeight, char *strBuf,
int bars = (int)min(10 * strength, 10);
blendBar[bars] = '\0';
plString details;
if (fAnim)
{
plString animName = fAnim->GetName();
float time = fAnim->GetTimeConvert()->CurrentAnimTime();
sprintf(strBuf, "%20s %3s time: %5.2f %s", animName.c_str(), onOff, time, blendBar);
float time = fAnim->GetTimeConvert()->CurrentAnimTime();
details = plString::Format("%20s %3s time: %5.2f %s", animName.c_str(), onOff, time, blendBar);
}
else
sprintf(strBuf, " Behavior %2d %3s %s", fIndex, onOff, blendBar);
details = plString::Format(" Behavior %2d %3s %s", fIndex, onOff, blendBar);
debugTxt.DrawString(x, y, strBuf);
debugTxt.DrawString(x, y, details);
y += lineHeight;
}

2
Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.h

@ -65,7 +65,7 @@ public:
virtual void SetStrength(float val, float rate = 0.f); // default instant change
virtual float GetStrength();
virtual void Rewind();
void DumpDebug(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt);
void DumpDebug(int &x, int &y, int lineHeight, plDebugText &debugTxt);
enum
{

2
Sources/Plasma/PubUtilLib/plAvatar/plAvBrain.h

@ -81,7 +81,7 @@ public:
virtual bool LeaveAge();
virtual bool IsRunningTask() const;
virtual void QueueTask(plAvTask *task);
virtual void DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt) {}
virtual void DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt) {}
virtual void Write(hsStream *stream, hsResMgr *mgr);
virtual void Read(hsStream *stream, hsResMgr *mgr);

46
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp

@ -884,7 +884,7 @@ void plAvBrainClimb::LoadFromSDL(const plStateDataRecord *sdl)
// DumpToDebugDisplay --------------------------------------------------------------------------------------
// ------------------
void plAvBrainClimb::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt)
void plAvBrainClimb::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{
debugTxt.DrawString(x, y, "Brain type: Climb");
y += lineHeight;
@ -896,31 +896,31 @@ void plAvBrainClimb::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *st
debugTxt.DrawString(x,y, buffy);
y += lineHeight;
IDumpClimbDirections(x, y, lineHeight, strBuf, debugTxt);
IDumpDismountDirections(x, y, lineHeight, strBuf, debugTxt);
IDumpBlockedDirections(x, y, lineHeight, strBuf, debugTxt);
fUp->DumpDebug(fUp == fCurStage, x, y, lineHeight, strBuf, debugTxt);
fDown->DumpDebug(fDown == fCurStage, x, y, lineHeight, strBuf, debugTxt);
fLeft->DumpDebug(fLeft == fCurStage, x, y, lineHeight, strBuf, debugTxt);
fRight->DumpDebug(fRight == fCurStage, x, y, lineHeight, strBuf, debugTxt);
fMountUp->DumpDebug(fMountUp == fCurStage, x, y, lineHeight, strBuf, debugTxt);
fMountDown->DumpDebug(fMountDown == fCurStage, x, y, lineHeight, strBuf, debugTxt);
fMountLeft->DumpDebug(fMountLeft == fCurStage, x, y, lineHeight, strBuf, debugTxt);
fMountRight->DumpDebug(fMountRight == fCurStage, x, y, lineHeight, strBuf, debugTxt);
fDismountUp->DumpDebug(fDismountUp == fCurStage, x, y, lineHeight, strBuf, debugTxt);
fDismountDown->DumpDebug(fDismountDown == fCurStage, x, y, lineHeight, strBuf, debugTxt);
fDismountLeft->DumpDebug(fDismountLeft == fCurStage, x, y, lineHeight, strBuf, debugTxt);
fDismountRight->DumpDebug(fDismountRight == fCurStage, x, y, lineHeight, strBuf, debugTxt);
fIdle->DumpDebug(fIdle == fCurStage, x, y, lineHeight, strBuf, debugTxt);
fRelease->DumpDebug(fRelease == fCurStage, x, y, lineHeight, strBuf, debugTxt);
fFallOff->DumpDebug(fFallOff == fCurStage, x, y, lineHeight, strBuf, debugTxt);
IDumpClimbDirections(x, y, lineHeight, debugTxt);
IDumpDismountDirections(x, y, lineHeight, debugTxt);
IDumpBlockedDirections(x, y, lineHeight, debugTxt);
fUp->DumpDebug(fUp == fCurStage, x, y, lineHeight, debugTxt);
fDown->DumpDebug(fDown == fCurStage, x, y, lineHeight, debugTxt);
fLeft->DumpDebug(fLeft == fCurStage, x, y, lineHeight, debugTxt);
fRight->DumpDebug(fRight == fCurStage, x, y, lineHeight, debugTxt);
fMountUp->DumpDebug(fMountUp == fCurStage, x, y, lineHeight, debugTxt);
fMountDown->DumpDebug(fMountDown == fCurStage, x, y, lineHeight, debugTxt);
fMountLeft->DumpDebug(fMountLeft == fCurStage, x, y, lineHeight, debugTxt);
fMountRight->DumpDebug(fMountRight == fCurStage, x, y, lineHeight, debugTxt);
fDismountUp->DumpDebug(fDismountUp == fCurStage, x, y, lineHeight, debugTxt);
fDismountDown->DumpDebug(fDismountDown == fCurStage, x, y, lineHeight, debugTxt);
fDismountLeft->DumpDebug(fDismountLeft == fCurStage, x, y, lineHeight, debugTxt);
fDismountRight->DumpDebug(fDismountRight == fCurStage, x, y, lineHeight, debugTxt);
fIdle->DumpDebug(fIdle == fCurStage, x, y, lineHeight, debugTxt);
fRelease->DumpDebug(fRelease == fCurStage, x, y, lineHeight, debugTxt);
fFallOff->DumpDebug(fFallOff == fCurStage, x, y, lineHeight, debugTxt);
}
// IDumpClimbDirections --------------------------------------------------------------------------------------
// --------------------
void plAvBrainClimb::IDumpClimbDirections(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt)
void plAvBrainClimb::IDumpClimbDirections(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{
const char * prolog = "Allowed directions: ";
std::string str;
@ -944,7 +944,7 @@ void plAvBrainClimb::IDumpClimbDirections(int &x, int &y, int lineHeight, char *
// IDumpDismountDirections --------------------------------------------------------------------------------------
// -----------------------
void plAvBrainClimb::IDumpDismountDirections(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt)
void plAvBrainClimb::IDumpDismountDirections(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{
const char * prolog = "Enabled dismounts: ";
std::string str;
@ -966,7 +966,7 @@ void plAvBrainClimb::IDumpDismountDirections(int &x, int &y, int lineHeight, cha
y += lineHeight;
}
void plAvBrainClimb::IDumpBlockedDirections(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt)
void plAvBrainClimb::IDumpBlockedDirections(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{
const char * prolog = "Physically blocked: ";
std::string str;

8
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.h

@ -103,7 +103,7 @@ public:
virtual void SaveToSDL(plStateDataRecord *sdl);
virtual void LoadFromSDL(const plStateDataRecord *sdl);
void DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt);
void DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt);
const char * WorldDirStr(plClimbMsg::Direction dir);
const char *ModeStr(Mode mode);
@ -173,9 +173,9 @@ private:
*/
bool IProcessExitStage(double time, float elapsed);
void IDumpClimbDirections(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt);
void IDumpDismountDirections(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt);
void IDumpBlockedDirections(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt);
void IDumpClimbDirections(int &x, int &y, int lineHeight, plDebugText &debugTxt);
void IDumpDismountDirections(int &x, int &y, int lineHeight, plDebugText &debugTxt);
void IDumpBlockedDirections(int &x, int &y, int lineHeight, plDebugText &debugTxt);
////////////////////////////
//

14
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.cpp

@ -435,23 +435,21 @@ void plAvBrainCritter::RemoveReceiver(const plKey key)
return; // not found, do nothing
}
void plAvBrainCritter::DumpToDebugDisplay(int& x, int& y, int lineHeight, char* strBuf, plDebugText& debugTxt)
void plAvBrainCritter::DumpToDebugDisplay(int& x, int& y, int lineHeight, plDebugText& debugTxt)
{
sprintf(strBuf, "Brain type: Critter");
debugTxt.DrawString(x, y, strBuf, 0, 255, 255);
debugTxt.DrawString(x, y, "Brain type: Critter", 0, 255, 255);
y += lineHeight;
// extract the name from the behavior running
plString mode = "Mode: Unknown";
if (fBehaviors[fCurMode])
sprintf(strBuf, "Mode: %s", ((CritterBehavior*)(fBehaviors[fCurMode]))->Name().c_str());
else
sprintf(strBuf, "Mode: Unknown");
mode = plString::Format("Mode: %s", ((CritterBehavior*)(fBehaviors[fCurMode]))->Name().c_str());
// draw it
debugTxt.DrawString(x, y, strBuf);
debugTxt.DrawString(x, y, mode);
y += lineHeight;
for (int i = 0; i < fBehaviors.GetCount(); ++i)
fBehaviors[i]->DumpDebug(x, y, lineHeight, strBuf, debugTxt);
fBehaviors[i]->DumpDebug(x, y, lineHeight, debugTxt);
}
///////////////////////////////////////////////////////////////////////////////

2
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.h

@ -133,7 +133,7 @@ public:
void AddReceiver(const plKey key);
void RemoveReceiver(const plKey key);
virtual void DumpToDebugDisplay(int& x, int& y, int lineHeight, char* strBuf, plDebugText& debugTxt);
virtual void DumpToDebugDisplay(int& x, int& y, int lineHeight, plDebugText& debugTxt);
// For the console
static bool fDrawDebug;

4
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainGeneric.cpp

@ -946,7 +946,7 @@ void plAvBrainGeneric::SetBodyUsage(plAGAnim::BodyUsage bodyUsage)
// DumpToDebugDisplay ----------------------------------------------------------------------------------------
// -------------------
void plAvBrainGeneric::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt)
void plAvBrainGeneric::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{
debugTxt.DrawString(x, y, "Brain type: Generic AKA Multistage");
y += lineHeight;
@ -955,7 +955,7 @@ void plAvBrainGeneric::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *
for(int i = 0; i < stageCount; i++)
{
plAnimStage *stage = (*fStages)[i];
stage->DumpDebug(i == fCurStage, x, y, lineHeight, strBuf, debugTxt);
stage->DumpDebug(i == fCurStage, x, y, lineHeight, debugTxt);
}
}

2
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainGeneric.h

@ -252,7 +252,7 @@ public:
MoveMode GetMoveMode() { return fMoveMode; }
/** Output the brain's status to the avatar debug screen. */
virtual void DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt);
virtual void DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt);
// plasma protocol
bool MsgReceive(plMessage *msg);

25
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp

@ -896,28 +896,19 @@ bool plAvBrainHuman::LeaveAge()
return false;
}
void plAvBrainHuman::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt)
void plAvBrainHuman::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{
sprintf(strBuf, "Brain type: Human");
debugTxt.DrawString(x, y, strBuf);
debugTxt.DrawString(x, y, "Brain type: Human");
y += lineHeight;
const char *grounded = fWalkingStrategy->IsOnGround() ? "yes" : "no";
const char *pushing = (fWalkingStrategy->GetPushingPhysical() ? (fWalkingStrategy->GetFacingPushingPhysical() ? "facing" : "behind") : "none");
sprintf(strBuf, "Ground: %3s, AirTime: %5.2f (Peak: %5.2f), PushingPhys: %6s",
grounded, fWalkingStrategy->GetAirTime(), fWalkingStrategy->GetImpactTime(), pushing);
debugTxt.DrawString(x, y, strBuf);
debugTxt.DrawString(x, y, plString::Format("Ground: %3s, AirTime: %5.2f (Peak: %5.2f), PushingPhys: %6s",
grounded, fWalkingStrategy->GetAirTime(), fWalkingStrategy->GetImpactTime(), pushing));
y += lineHeight;
int i;
//strBuf[0] = '\0';
//for (i = 0; i < 32; i++)
// strcat(strBuf, fPreconditions & (0x1 << i) ? "1" : "0");
//debugTxt.DrawString(x, y, strBuf);
//y += lineHeight;
for (i = 0; i < fBehaviors.GetCount(); i++)
fBehaviors[i]->DumpDebug(x, y, lineHeight, strBuf, debugTxt);
for (int i = 0; i < fBehaviors.GetCount(); i++)
fBehaviors[i]->DumpDebug(x, y, lineHeight, debugTxt);
debugTxt.DrawString(x, y, "Tasks:");
y += lineHeight;
@ -928,7 +919,7 @@ void plAvBrainHuman::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *st
y += lineHeight;
int indentedX = x + 4;
fCurTask->DumpDebug("-", indentedX, y, lineHeight, strBuf, debugTxt);
fCurTask->DumpDebug("-", indentedX, y, lineHeight, debugTxt);
}
int tasks = fTaskQueue.size();
if(tasks > 0)
@ -941,7 +932,7 @@ void plAvBrainHuman::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *st
for (int i = 0; i < tasks; i++)
{
plAvTask *each = fTaskQueue[i];
each->DumpDebug("-", indentedX, y, lineHeight, strBuf, debugTxt);
each->DumpDebug("-", indentedX, y, lineHeight, debugTxt);
}
}
}

2
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.h

@ -97,7 +97,7 @@ public:
virtual void Write(hsStream *stream, hsResMgr *mgr);
virtual void Read(hsStream *stream, hsResMgr *mgr);
virtual bool MsgReceive(plMessage *msg);
virtual void DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt);
virtual void DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt);
// Hardwired Identifiers for all the canonical bones.
enum HumanBoneID {

147
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainStaticNPC.cpp

@ -1,147 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//class plAvBrainStaticNPC : public plAvBrain
//{
//
//};
//
///** \class plAvBrain
// Virtual base class for the modular avatar & creature brains.
// A brain is a modular object which can be installed into a plArmatureMod
// to drive it around in the scene. Some brains are for creature ai;
// others intepret user input. The most interesting brain for reference is
// probably plAvBrainHuman, which implements the control system for the
// user's avatar.
// /sa plAvBrainHuman, plArmatureMod
//*/
//class plAvBrainStaticNPC : public plAvBrainStaticNPC
//{
//public:
// /** Default constructor - constructs the brain but does not attach it.
// Brains are always constructed before being Pushed onto the armature
// they seek to control. */
// plAvBrain();
//
// /** Destructor. Automatically called on a brain when it is popped from the armature. */
// virtual ~plAvBrain();
//
// // BRAIN PROTOCOL
// /** This brain has just been freshly pushed onto an armature and is now
// in primary control. Note that brains beneath it on the stack may
// still have effect on the armature; any messages which the top
// brain doesn't handle will propagate down to the next brain in line.
// */
// virtual bool Activate(plArmatureMod *avMod);
//
// /** Has the brain resolved all its load-time dependencies? This is a mechanism
// to allow newly loading creatures to reach a known state before they
// are asked to load secondary state or to interact with the environment.
// */
// virtual bool IsReady();
//
// /** This brain has just been removed from its armature and is about to be destructed. */
// virtual bool Deactivate();
//
// /** This is the top brain and it's time for it to evaluate. Called during eval
// time for the armature modifier. Only the topmost brain gets an apply
// call; others must do any necessary background work during MsgReceive. */
// virtual bool Apply(double timeNow, hsScalar elapsed);
//
// /** Another brain has been pushed atop this brain. Drop into the background.
// We'll still receive any messages that the upper brain doesn't eat. */
// virtual bool Suspend();
//
// /** We were suspended, but now we're on top of the brain stack again. */
// virtual bool Resume();
//
// // \name Spawning \{
// /** Do any necessary custom action upon spawning afresh in a new age.
// For the human brain, this simply consists of noting that we have
// spawned and we can stop trying to do so. */
// virtual void Spawn(double timeNow) {};
//
// /** Custom behavior for entering an age. Binding the camera, audio source, etc. */
// virtual void EnterAge(bool reSpawn) {};
//
// /** Custom behavior for leaving an age. Free any attachments to camera, audio, etc. */
// virtual void LeaveAge() {};
//
// // TASKS
// // tasks are operations that must be done in sequence.
// /** Push a new task onto the end of our FIFO task queue. Will not
// run until all the tasks ahead of it have run.
// \sa plAvTask
// */
// virtual void QueueTask(plAvTask *task);
//
//
// virtual void DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt);
//
//
// // PLASMOTICS
// CLASSNAME_REGISTER( plAvBrain );
// GETINTERFACE_ANY( plAvBrain, plCreatable );
//
// virtual void Write(hsStream *stream, hsResMgr *mgr);
// virtual void Read(hsStream *stream, hsResMgr *mgr);
//
// virtual void SaveAux(hsStream *stream, hsResMgr *mgr);
// virtual void LoadAux(hsStream *stream, hsResMgr *mgr, double time);
//
// virtual bool MsgReceive(plMessage *msg);
//
//
//protected:
// plArmatureMod *fAvMod; // the avatar we're controlling
//
// // TASKS
// // -- variables
// typedef std::deque<plAvTask *> plAvTaskQueue;
// plAvTaskQueue fTaskQueue; // FIFO queue of tasks we're working on
// plAvTask *fCurTask; // the task we're working on right now
// // -- methods
// virtual bool IHandleTaskMsg(plAvTaskMsg *msg); // respond to a task scheduling message
// void IProcessTasks(double time, hsScalar elapsed); // process current task and start new one if necessary
//
// bool fSuspended;
//};
//

22
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp

@ -594,42 +594,38 @@ bool plAvBrainSwim::IHandleControlMsg(plControlEventMsg* msg)
}
void plAvBrainSwim::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt)
void plAvBrainSwim::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{
sprintf(strBuf, "Brain type: Swim");
debugTxt.DrawString(x, y, strBuf, 0, 255, 255);
debugTxt.DrawString(x, y, "Brain type: Swim", 0, 255, 255);
y += lineHeight;
switch(fMode) {
case kWading:
sprintf(strBuf, "Mode: Wading");
debugTxt.DrawString(x, y, "Mode: Wading");
break;
case kSwimming2D:
sprintf(strBuf, "Mode: Swimming2D");
debugTxt.DrawString(x, y, "Mode: Swimming2D");
break;
case kSwimming3D:
sprintf(strBuf, "Mode: Swimming3D");
debugTxt.DrawString(x, y, "Mode: Swimming3D");
break;
case kAbort:
sprintf(strBuf, "Mode: Abort (you should never see this)");
debugTxt.DrawString(x, y, "Mode: Abort (you should never see this)");
break;
default:
break;
}
debugTxt.DrawString(x, y, strBuf);
y += lineHeight;
float buoy = fSwimStrategy ? fSwimStrategy->GetBuoyancy() : 0.0f;
sprintf(strBuf, "Distance to surface: %f Buoyancy: %f", fSurfaceDistance, buoy);
debugTxt.DrawString(x, y, strBuf);
debugTxt.DrawString(x, y, plString::Format("Distance to surface: %f Buoyancy: %f", fSurfaceDistance, buoy));
y += lineHeight;
hsVector3 linV = fAvMod->GetController()->GetAchievedLinearVelocity();
sprintf(strBuf, "Linear Velocity: (%5.2f, %5.2f, %5.2f)", linV.fX, linV.fY, linV.fZ);
debugTxt.DrawString(x, y, strBuf);
debugTxt.DrawString(x, y, plString::Format("Linear Velocity: (%5.2f, %5.2f, %5.2f)", linV.fX, linV.fY, linV.fZ));
y += lineHeight;
int i;
for (i = 0; i < fBehaviors.GetCount(); i++)
fBehaviors[i]->DumpDebug(x, y, lineHeight, strBuf, debugTxt);
fBehaviors[i]->DumpDebug(x, y, lineHeight, debugTxt);
}

2
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.h

@ -66,7 +66,7 @@ public:
virtual void Deactivate();
virtual void Suspend();
virtual void Resume();
virtual void DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt);
virtual void DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt);
bool MsgReceive(plMessage *msg);
bool IsWalking();
bool IsWading();

2
Sources/Plasma/PubUtilLib/plAvatar/plAvTask.h

@ -94,7 +94,7 @@ public:
virtual void LeaveAge(plArmatureMod *avatar) {}
/** dump descriptive stuff to the given debug text */
virtual void DumpDebug(const char *name, int &x, int&y, int lineHeight, char *strBuf, plDebugText &debugTxt);
virtual void DumpDebug(const char *name, int &x, int&y, int lineHeight, plDebugText &debugTxt);
// plasma protocol
CLASSNAME_REGISTER( plAvTask );

2
Sources/Plasma/PubUtilLib/plAvatar/plAvTaskBrain.cpp

@ -94,7 +94,7 @@ void plAvTaskBrain::Finish(plArmatureMod *avatar, plArmatureBrain *brain, double
// DumpDebug ------------------------------------------------------------------------------------------------------
// ----------
void plAvTaskBrain::DumpDebug(const char *name, int &x, int&y, int lineHeight, char *strBuf, plDebugText &debugTxt)
void plAvTaskBrain::DumpDebug(const char *name, int &x, int&y, int lineHeight, plDebugText &debugTxt)
{
if(fBrain)
{

2
Sources/Plasma/PubUtilLib/plAvatar/plAvTaskBrain.h

@ -75,7 +75,7 @@ public:
virtual void Finish(plArmatureMod *avatar, plArmatureBrain *brain, double time, float elapsed);
/** dump descriptive stuff to the given debug text */
virtual void DumpDebug(const char *name, int &x, int&y, int lineHeight, char *strBuf, plDebugText &debugTxt);
virtual void DumpDebug(const char *name, int &x, int&y, int lineHeight, plDebugText &debugTxt);
plArmatureBrain *GetBrain();

20
Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp

@ -556,22 +556,20 @@ bool plAvTaskSeek::IUpdateObjective(plArmatureMod *avatar)
// DumpDebug -----------------------------------------------------------------------------------------------------
// ----------
void plAvTaskSeek::DumpDebug(const char *name, int &x, int&y, int lineHeight, char *strBuf, plDebugText &debugTxt)
void plAvTaskSeek::DumpDebug(const char *name, int &x, int&y, int lineHeight, plDebugText &debugTxt)
{
sprintf(strBuf, "duration: %.2f pos: (%.3f, %.3f, %.3f) goalPos: (%.3f, %.3f, %.3f) ",
debugTxt.DrawString(x, y, plString::Format("duration: %.2f pos: (%.3f, %.3f, %.3f) goalPos: (%.3f, %.3f, %.3f) ",
hsTimer::GetSysSeconds() - fStartTime,
fPosition.fX, fPosition.fY, fPosition.fZ, fSeekPos.fX, fSeekPos.fY, fSeekPos.fZ);
debugTxt.DrawString(x, y, strBuf);
fPosition.fX, fPosition.fY, fPosition.fZ, fSeekPos.fX, fSeekPos.fY, fSeekPos.fZ));
y += lineHeight;
sprintf(strBuf, "positioning: %d rotating %d goalVec: (%.3f, %.3f, %.3f) dist: %.3f angFwd: %.3f angRt: %.3f",
fStillPositioning, fStillRotating, fGoalVec.fX, fGoalVec.fY, fGoalVec.fZ, fDistance, fAngForward, fAngRight);
debugTxt.DrawString(x, y, strBuf);
debugTxt.DrawString(x, y, plString::Format("positioning: %d rotating %d goalVec: (%.3f, %.3f, %.3f) dist: %.3f angFwd: %.3f angRt: %.3f",
fStillPositioning, fStillRotating, fGoalVec.fX, fGoalVec.fY, fGoalVec.fZ,
fDistance, fAngForward, fAngRight));
y += lineHeight;
sprintf(strBuf, " distFwd: %.3f distRt: %.3f shufRange: %.3f sidAngle: %.3f sidRange: %.3f, fMinWalk: %.3f",
fDistForward, fDistRight, fShuffleRange, fMaxSidleAngle, fMaxSidleRange, fMinFwdAngle);
debugTxt.DrawString(x, y, strBuf);
debugTxt.DrawString(x, y, plString::Format(" distFwd: %.3f distRt: %.3f shufRange: %.3f sidAngle: %.3f sidRange: %.3f, fMinWalk: %.3f",
fDistForward, fDistRight, fShuffleRange, fMaxSidleAngle, fMaxSidleRange, fMinFwdAngle));
y += lineHeight;
}

2
Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.h

@ -96,7 +96,7 @@ public:
virtual void LeaveAge(plArmatureMod *avatar);
/** Spew "useful" information to the game screen. Used when Avatar.Debug is active. */
virtual void DumpDebug(const char *name, int &x, int&y, int lineHeight, char *strBuf, plDebugText &debugTxt);
virtual void DumpDebug(const char *name, int &x, int&y, int lineHeight, plDebugText &debugTxt);
void DumpToAvatarLog(plArmatureMod *avatar);

2
Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp

@ -107,7 +107,7 @@ void plAvTask::Finish(plArmatureMod *avatar, plArmatureBrain *brain, double time
// DUMPDEBUG
void plAvTask::DumpDebug(const char *name, int &x, int&y, int lineHeight, char *strBuf, plDebugText &debugTxt)
void plAvTask::DumpDebug(const char *name, int &x, int&y, int lineHeight, plDebugText &debugTxt)
{
debugTxt.DrawString(x, y, "<anonymous task>");
y += lineHeight;

Loading…
Cancel
Save