Browse Source

Some additional sprintf and std::string cleanup

Michael Hansen 11 years ago
parent
commit
abe3d465b3
  1. 6
      Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp
  2. 38
      Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp
  3. 2
      Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h
  4. 62
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp
  5. 4
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.h
  6. 23
      Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp
  7. 4
      Sources/Plasma/PubUtilLib/plPipeline/DX/plDXEnumerate.cpp
  8. 1
      Sources/Tools/MaxComponent/CMakeLists.txt
  9. 41
      Sources/Tools/MaxComponent/WavFileStructs.h
  10. 2
      Sources/Tools/MaxPlasmaMtls/Materials/plClothingMtlPBDec.h

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

@ -256,12 +256,12 @@ plAGAnimInstance * plAnimStage::Attach(plArmatureMod *armature, plArmatureBrain
fAnimInstance->SetCurrentTime(fLocalTime); fAnimInstance->SetCurrentTime(fLocalTime);
#ifdef DEBUG_MULTISTAGE #ifdef DEBUG_MULTISTAGE
char sbuf[256]; char sbuf[256];
snprintf(sbuf, sizeof(sbuf), "AnimStage::Attach - attaching stage %s", fAnimName.c_str()); snprintf(sbuf, arrsize(sbuf), "AnimStage::Attach - attaching stage %s", fAnimName.c_str());
plAvatarMgr::GetInstance()->GetLog()->AddLine(sbuf); plAvatarMgr::GetInstance()->GetLog()->AddLine(sbuf);
#endif #endif
} else { } else {
char buf[256]; char buf[256];
snprintf(buf, sizeof(buf), "Can't find animation <%s> for animation stage. Anything could happen.", fAnimName.c_str()); snprintf(buf, arrsize(buf), "Can't find animation <%s> for animation stage. Anything could happen.", fAnimName.c_str());
hsAssert(false, buf); hsAssert(false, buf);
#ifdef DEBUG_MULTISTAGE #ifdef DEBUG_MULTISTAGE
plAvatarMgr::GetInstance()->GetLog()->AddLine(buf); plAvatarMgr::GetInstance()->GetLog()->AddLine(buf);
@ -328,7 +328,7 @@ bool plAnimStage::Detach(plArmatureMod *armature)
#ifdef DEBUG_MULTISTAGE #ifdef DEBUG_MULTISTAGE
char sbuf[256]; char sbuf[256];
snprintf(sbuf, sizeof(sbuf), "AnimStage::Detach - detaching stage %s", fAnimName.c_str()); snprintf(sbuf, arrsize(sbuf), "AnimStage::Detach - detaching stage %s", fAnimName.c_str());
plAvatarMgr::GetInstance()->GetLog()->AddLine(sbuf); plAvatarMgr::GetInstance()->GetLog()->AddLine(sbuf);
#endif #endif
// hsStatusMessageF("Detaching plAnimStage <%s>", fAnimName.c_str()); // hsStatusMessageF("Detaching plAnimStage <%s>", fAnimName.c_str());

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

@ -2800,41 +2800,41 @@ void plAvBoneMap::AddBoneMapping(uint32_t boneID, const plSceneObject *SO)
void plArmatureMod::DebugDumpMoveKeys(int &x, int &y, int lineHeight, plDebugText &debugTxt) void plArmatureMod::DebugDumpMoveKeys(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{ {
char buff[256]; debugTxt.DrawString(x, y, plString::Format("Mouse Input Map: %s",
snprintf(buff, sizeof(buff), "Mouse Input Map: %s", plAvatarInputInterface::GetInstance()->GetInputMapName()); plAvatarInputInterface::GetInstance()->GetInputMapName()));
debugTxt.DrawString(x, y, buff);
y += lineHeight; y += lineHeight;
snprintf(buff, sizeof(buff), "Turn strength: %.2f (key: %.2f, analog: %.2f)", debugTxt.DrawString(x, y, plString::Format("Turn strength: %.2f (key: %.2f, analog: %.2f)",
GetTurnStrength(), GetKeyTurnStrength(), GetAnalogTurnStrength()); GetTurnStrength(), GetKeyTurnStrength(), GetAnalogTurnStrength()));
debugTxt.DrawString(x, y, buff);
y += lineHeight; y += lineHeight;
GetMoveKeyString(buff); debugTxt.DrawString(x, y, GetMoveKeyString());
debugTxt.DrawString(x, y, buff);
y += lineHeight; y += lineHeight;
} }
void plArmatureMod::GetMoveKeyString(char *buff) plString plArmatureMod::GetMoveKeyString() const
{ {
sprintf(buff, "Move keys: "); plStringStream keys;
keys << "Move keys: ";
if(FastKeyDown()) if(FastKeyDown())
strcat(buff, "FAST "); keys << "FAST ";
if(StrafeKeyDown()) if(StrafeKeyDown())
strcat(buff, "STRAFE "); keys << "STRAFE ";
if(ForwardKeyDown()) if(ForwardKeyDown())
strcat(buff, "FORWARD "); keys << "FORWARD ";
if(BackwardKeyDown()) if(BackwardKeyDown())
strcat(buff, "BACKWARD "); keys << "BACKWARD ";
if(TurnLeftKeyDown()) if(TurnLeftKeyDown())
strcat(buff, "TURNLEFT "); keys << "TURNLEFT ";
if(TurnRightKeyDown()) if(TurnRightKeyDown())
strcat(buff, "TURNRIGHT "); keys << "TURNRIGHT ";
if(StrafeLeftKeyDown()) if(StrafeLeftKeyDown())
strcat(buff, "STRAFELEFT "); keys << "STRAFELEFT ";
if(StrafeRightKeyDown()) if(StrafeRightKeyDown())
strcat(buff, "STRAFERIGHT "); keys << "STRAFERIGHT ";
if(JumpKeyDown()) if(JumpKeyDown())
strcat(buff, "JUMP "); keys << "JUMP ";
return keys.GetString();
} }

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

@ -279,7 +279,7 @@ public:
void SetTurnRightKeyDown(bool status = true); void SetTurnRightKeyDown(bool status = true);
void SetJumpKeyDown(); void SetJumpKeyDown();
void DebugDumpMoveKeys(int &x, int &y, int lineHeight, plDebugText &debugTxt); void DebugDumpMoveKeys(int &x, int &y, int lineHeight, plDebugText &debugTxt);
void GetMoveKeyString(char *buff); plString GetMoveKeyString() const;
void SynchIfLocal(double timeNow, int force); // Just physical state void SynchIfLocal(double timeNow, int force); // Just physical state
void SynchInputState(uint32_t rcvID = kInvalidPlayerID); void SynchInputState(uint32_t rcvID = kInvalidPlayerID);

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

@ -922,23 +922,23 @@ void plAvBrainClimb::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugT
// -------------------- // --------------------
void plAvBrainClimb::IDumpClimbDirections(int &x, int &y, int lineHeight, plDebugText &debugTxt) void plAvBrainClimb::IDumpClimbDirections(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{ {
const char * prolog = "Allowed directions: "; static const char prolog[] = "Allowed directions: ";
std::string str; plStringStream str;
str = prolog; str << prolog;
if(fAllowedDirections & plClimbMsg::kUp) if(fAllowedDirections & plClimbMsg::kUp)
str = str + "UP "; str << "UP ";
if(fAllowedDirections & plClimbMsg::kDown) if(fAllowedDirections & plClimbMsg::kDown)
str = str + "DOWN "; str << "DOWN ";
if(fAllowedDirections & plClimbMsg::kLeft) if(fAllowedDirections & plClimbMsg::kLeft)
str = str + "LEFT "; str << "LEFT ";
if(fAllowedDirections & plClimbMsg::kRight) if(fAllowedDirections & plClimbMsg::kRight)
str = str + "RIGHT "; str << "RIGHT ";
if(str.size() == strlen(prolog)) if(str.GetLength() == strlen(prolog))
str = str + "- NONE -"; str << "- NONE -";
debugTxt.DrawString(x, y, str.c_str()); debugTxt.DrawString(x, y, str.GetString());
y += lineHeight; y += lineHeight;
} }
@ -946,49 +946,49 @@ void plAvBrainClimb::IDumpClimbDirections(int &x, int &y, int lineHeight, plDebu
// ----------------------- // -----------------------
void plAvBrainClimb::IDumpDismountDirections(int &x, int &y, int lineHeight, plDebugText &debugTxt) void plAvBrainClimb::IDumpDismountDirections(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{ {
const char * prolog = "Enabled dismounts: "; static const char prolog[] = "Enabled dismounts: ";
std::string str; plStringStream str;
str = prolog; str << prolog;
if(fAllowedDismounts & plClimbMsg::kUp) if(fAllowedDismounts & plClimbMsg::kUp)
str = str + "UP "; str << "UP ";
if(fAllowedDismounts & plClimbMsg::kDown) if(fAllowedDismounts & plClimbMsg::kDown)
str = str + "DOWN "; str << "DOWN ";
if(fAllowedDismounts & plClimbMsg::kLeft) if(fAllowedDismounts & plClimbMsg::kLeft)
str = str + "LEFT "; str << "LEFT ";
if(fAllowedDismounts & plClimbMsg::kRight) if(fAllowedDismounts & plClimbMsg::kRight)
str = str + "RIGHT "; str << "RIGHT ";
if(str.size() == strlen(prolog)) if(str.GetLength() == strlen(prolog))
str = str + "- NONE -"; str << "- NONE -";
debugTxt.DrawString(x, y, str.c_str()); debugTxt.DrawString(x, y, str.GetString());
y += lineHeight; y += lineHeight;
} }
void plAvBrainClimb::IDumpBlockedDirections(int &x, int &y, int lineHeight, plDebugText &debugTxt) void plAvBrainClimb::IDumpBlockedDirections(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{ {
const char * prolog = "Physically blocked: "; static const char prolog[] = "Physically blocked: ";
std::string str; plStringStream str;
str = prolog; str << prolog;
if(fOldPhysicallyBlockedDirections & plClimbMsg::kUp) if(fOldPhysicallyBlockedDirections & plClimbMsg::kUp)
str = str + "UP "; str << "UP ";
if(fOldPhysicallyBlockedDirections & plClimbMsg::kDown) if(fOldPhysicallyBlockedDirections & plClimbMsg::kDown)
str = str + "DOWN "; str << "DOWN ";
if(fOldPhysicallyBlockedDirections & plClimbMsg::kLeft) if(fOldPhysicallyBlockedDirections & plClimbMsg::kLeft)
str = str + "LEFT "; str << "LEFT ";
if(fOldPhysicallyBlockedDirections & plClimbMsg::kRight) if(fOldPhysicallyBlockedDirections & plClimbMsg::kRight)
str = str + "RIGHT "; str << "RIGHT ";
if(str.size() == strlen(prolog)) if(str.GetLength() == strlen(prolog))
str = str + "- NONE -"; str << "- NONE -";
debugTxt.DrawString(x, y, str.c_str()); debugTxt.DrawString(x, y, str.GetString());
y += lineHeight; y += lineHeight;
} }
const char * plAvBrainClimb::WorldDirStr(plClimbMsg::Direction dir) const char *plAvBrainClimb::WorldDirStr(plClimbMsg::Direction dir)
{ {
switch(dir) switch(dir)
{ {

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

@ -104,8 +104,8 @@ public:
virtual void LoadFromSDL(const plStateDataRecord *sdl); virtual void LoadFromSDL(const plStateDataRecord *sdl);
void DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt); void DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt);
const char * WorldDirStr(plClimbMsg::Direction dir); static const char *WorldDirStr(plClimbMsg::Direction dir);
const char *ModeStr(Mode mode); static const char *ModeStr(Mode mode);
// plasma protocol // plasma protocol
virtual bool MsgReceive(plMessage *msg); virtual bool MsgReceive(plMessage *msg);

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

@ -576,22 +576,21 @@ void plAvTaskSeek::DumpDebug(const char *name, int &x, int&y, int lineHeight, pl
void plAvTaskSeek::DumpToAvatarLog(plArmatureMod *avatar) void plAvTaskSeek::DumpToAvatarLog(plArmatureMod *avatar)
{ {
plStatusLog *log = plAvatarMgr::GetInstance()->GetLog(); plStatusLog *log = plAvatarMgr::GetInstance()->GetLog();
char strBuf[256]; log->AddLine(avatar->GetMoveKeyString().c_str());
avatar->GetMoveKeyString(strBuf);
log->AddLine(strBuf);
sprintf(strBuf, " duration: %.2f pos: (%.3f, %.3f, %.3f) goalPos: (%.3f, %.3f, %.3f) ", log->AddLine(plString::Format(" duration: %.2f pos: (%.3f, %.3f, %.3f) goalPos: (%.3f, %.3f, %.3f) ",
hsTimer::GetSysSeconds() - fStartTime, hsTimer::GetSysSeconds() - fStartTime,
fPosition.fX, fPosition.fY, fPosition.fZ, fSeekPos.fX, fSeekPos.fY, fSeekPos.fZ); fPosition.fX, fPosition.fY, fPosition.fZ,
log->AddLine(strBuf); fSeekPos.fX, fSeekPos.fY, fSeekPos.fZ).c_str());
sprintf(strBuf, " positioning: %d rotating %d goalVec: (%.3f, %.3f, %.3f) dist: %.3f angFwd: %.3f angRt: %.3f", log->AddLine(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); fStillPositioning, fStillRotating,
log->AddLine(strBuf); fGoalVec.fX, fGoalVec.fY, fGoalVec.fZ,
fDistance, fAngForward, fAngRight).c_str());
sprintf(strBuf, " distFwd: %.3f distRt: %.3f shufRange: %.3f sidAngle: %.3f sidRange: %.3f, fMinWalk: %.3f", log->AddLine(plString::Format(" distFwd: %.3f distRt: %.3f shufRange: %.3f sidAngle: %.3f sidRange: %.3f, fMinWalk: %.3f",
fDistForward, fDistRight, fShuffleRange, fMaxSidleAngle, fMaxSidleRange, fMinFwdAngle); fDistForward, fDistRight, fShuffleRange,
log->AddLine(strBuf); fMaxSidleAngle, fMaxSidleRange, fMinFwdAngle).c_str());
} }
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////

4
Sources/Plasma/PubUtilLib/plPipeline/DX/plDXEnumerate.cpp

@ -84,9 +84,7 @@ HRESULT hsGDirect3DTnLEnumerate::SelectFromDevMode(const hsG3DDeviceRecord* devR
} }
} }
} }
char errStr[256]; plString errStr = plString::Format("Can't find requested device - %s:%s:%s:%s:%s",
sprintf(errStr, "Can't find requested device - %s:%s:%s:%s:%s",
devRec->GetG3DDeviceTypeName(), devRec->GetG3DDeviceTypeName(),
devRec->GetDriverDesc().c_str(), devRec->GetDriverDesc().c_str(),
devRec->GetDriverName().c_str(), devRec->GetDriverName().c_str(),

1
Sources/Tools/MaxComponent/CMakeLists.txt

@ -89,7 +89,6 @@ set(MaxComponent_HEADERS
plVolumeGadgetComponent.h plVolumeGadgetComponent.h
plWaterComponent.h plWaterComponent.h
plXImposter.h plXImposter.h
WavFileStructs.h
) )
set(MaxComponent_RESOURCES set(MaxComponent_RESOURCES

41
Sources/Tools/MaxComponent/WavFileStructs.h

@ -1,41 +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==*/

2
Sources/Tools/MaxPlasmaMtls/Materials/plClothingMtlPBDec.h

@ -196,7 +196,7 @@ public:
plClothingElement *element = tileset->fElements.Get(i); plClothingElement *element = tileset->fElements.Get(i);
SendMessage(GetDlgItem(hWnd, plClothingMtl::TextConstants[2 * i]), SendMessage(GetDlgItem(hWnd, plClothingMtl::TextConstants[2 * i]),
WM_SETTEXT, NULL, (LPARAM)element->fName.c_str()); WM_SETTEXT, NULL, (LPARAM)element->fName.c_str());
sprintf(buff, "(%d, %d)", element->fWidth, element->fHeight); snprintf(buff, arrsize(buff), "(%d, %d)", element->fWidth, element->fHeight);
SendMessage(GetDlgItem(hWnd, plClothingMtl::TextConstants[2 * i + 1]), SendMessage(GetDlgItem(hWnd, plClothingMtl::TextConstants[2 * i + 1]),
WM_SETTEXT, NULL, (LPARAM)buff); WM_SETTEXT, NULL, (LPARAM)buff);

Loading…
Cancel
Save