From be4b0732d54d1275742b86daa958e267ef8c98ef Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Sun, 5 Feb 2012 21:53:54 -0800 Subject: [PATCH] Fix string usage that was broken from enabling the Max plugin build --- Sources/Plasma/CoreLib/hsStream.cpp | 9 +- Sources/Plasma/CoreLib/hsStream.h | 4 +- Sources/Plasma/CoreLib/plString.cpp | 21 +++ Sources/Plasma/CoreLib/plString.h | 6 +- .../pfConsole/pfAvatarConsoleCommands.cpp | 18 +- .../pfConsole/pfConsoleCommands.cpp | 10 +- .../pfGameGUIMgr/pfGUIButtonMod.cpp | 34 +--- .../FeatureLib/pfGameGUIMgr/pfGUIButtonMod.h | 9 +- .../pfGameGUIMgr/pfGUICheckBoxCtrl.cpp | 19 +- .../pfGameGUIMgr/pfGUICheckBoxCtrl.h | 7 +- .../FeatureLib/pfGameGUIMgr/pfGUIKnobCtrl.cpp | 19 +- .../FeatureLib/pfGameGUIMgr/pfGUIKnobCtrl.h | 11 +- .../pfGameGUIMgr/pfGUIProgressCtrl.cpp | 19 +- .../pfGameGUIMgr/pfGUIProgressCtrl.h | 9 +- .../pfJournalBook/pfJournalBook.cpp | 4 +- .../Plasma/FeatureLib/pfPython/cyAvatar.cpp | 6 +- Sources/Plasma/FeatureLib/pfPython/cyAvatar.h | 4 +- .../FeatureLib/pfPython/cyAvatarGlue.cpp | 6 +- .../FeatureLib/pfPython/plPythonFileMod.cpp | 10 +- .../FeatureLib/pfPython/plPythonParameter.h | 37 ++-- .../FeatureLib/pfPython/pyCritterBrain.cpp | 8 +- .../FeatureLib/pfPython/pyCritterBrain.h | 2 +- .../NucleusLib/pnKeyedObject/plUoid.cpp | 2 +- .../NucleusLib/pnUtils/Private/pnUtSubst.cpp | 3 +- .../Plasma/PubUtilLib/plAvatar/plAGAnim.cpp | 78 ++++---- Sources/Plasma/PubUtilLib/plAvatar/plAGAnim.h | 48 ++--- .../PubUtilLib/plAvatar/plAGAnimInstance.cpp | 18 +- .../PubUtilLib/plAvatar/plAGAnimInstance.h | 8 +- .../PubUtilLib/plAvatar/plAGApplicator.cpp | 19 +- .../PubUtilLib/plAvatar/plAGApplicator.h | 15 +- .../PubUtilLib/plAvatar/plAGChannel.cpp | 4 +- .../Plasma/PubUtilLib/plAvatar/plAGChannel.h | 7 +- .../PubUtilLib/plAvatar/plAGMasterMod.cpp | 38 ++-- .../PubUtilLib/plAvatar/plAGMasterMod.h | 16 +- .../PubUtilLib/plAvatar/plAGModifier.cpp | 19 +- .../Plasma/PubUtilLib/plAvatar/plAGModifier.h | 12 +- .../PubUtilLib/plAvatar/plAnimStage.cpp | 2 +- .../PubUtilLib/plAvatar/plArmatureMod.cpp | 92 +++++----- .../PubUtilLib/plAvatar/plArmatureMod.h | 24 +-- .../PubUtilLib/plAvatar/plAvBehaviors.cpp | 4 +- .../PubUtilLib/plAvatar/plAvBrainClimb.cpp | 4 +- .../PubUtilLib/plAvatar/plAvBrainCritter.cpp | 8 +- .../PubUtilLib/plAvatar/plAvBrainCritter.h | 2 +- .../PubUtilLib/plAvatar/plAvBrainHuman.cpp | 17 +- .../PubUtilLib/plAvatar/plAvTaskSeek.cpp | 2 +- .../PubUtilLib/plAvatar/plAvatarMgr.cpp | 2 +- .../PubUtilLib/plAvatar/plAvatarTasks.cpp | 67 +++---- .../PubUtilLib/plAvatar/plAvatarTasks.h | 26 ++- .../PubUtilLib/plAvatar/plCoopCoordinator.cpp | 14 +- .../PubUtilLib/plAvatar/plCoopCoordinator.h | 5 +- .../PubUtilLib/plAvatar/plOneShotMod.cpp | 3 +- .../PubUtilLib/plAvatar/plSittingModifier.cpp | 6 +- .../plDrawable/plDrawableSpansExport.cpp | 8 +- .../PubUtilLib/plDrawable/plGeometrySpan.cpp | 2 +- .../PubUtilLib/plDrawable/plGeometrySpan.h | 36 ++-- .../PubUtilLib/plMessage/plAnimCmdMsg.cpp | 41 ++--- .../PubUtilLib/plMessage/plAnimCmdMsg.h | 38 ++-- .../PubUtilLib/plMessage/plAvatarMsg.cpp | 12 +- .../Plasma/PubUtilLib/plMessage/plAvatarMsg.h | 4 +- .../plMessage/plOneShotCallbacks.cpp | 9 +- .../PubUtilLib/plMessage/plOneShotCallbacks.h | 6 +- .../plModifier/plAxisAnimModifier.cpp | 8 +- .../plModifier/plAxisAnimModifier.h | 7 +- .../PubUtilLib/plSurface/plLayerAnimation.cpp | 4 +- .../PubUtilLib/plSurface/plLayerAnimation.h | 12 +- Sources/Tools/MaxComponent/plAGComponents.cpp | 26 +-- Sources/Tools/MaxComponent/plAnimCompProc.cpp | 7 +- .../Tools/MaxComponent/plAnimComponent.cpp | 43 ++--- Sources/Tools/MaxComponent/plAnimComponent.h | 4 +- .../MaxComponent/plAnimEventComponent.cpp | 36 ++-- .../Tools/MaxComponent/plAnimObjInterface.h | 3 +- .../Tools/MaxComponent/plAudioComponents.cpp | 44 ++--- Sources/Tools/MaxComponent/plAutoUIParams.cpp | 4 +- .../Tools/MaxComponent/plAvatarComponent.cpp | 22 +-- .../MaxComponent/plClickDragComponent.cpp | 6 +- .../Tools/MaxComponent/plComponentBase.cpp | 10 +- Sources/Tools/MaxComponent/plComponentBase.h | 2 +- .../Tools/MaxComponent/plComponentTools.cpp | 6 +- Sources/Tools/MaxComponent/plComponentTools.h | 12 +- .../MaxComponent/plFootstepComponent.cpp | 2 +- .../Tools/MaxComponent/plGUIComponents.cpp | 8 +- .../MaxComponent/plInventoryObjComponent.cpp | 3 +- Sources/Tools/MaxComponent/plMaxAnimUtils.cpp | 31 ++-- Sources/Tools/MaxComponent/plMaxAnimUtils.h | 9 +- .../Tools/MaxComponent/plNotetrackAnim.cpp | 48 ++--- Sources/Tools/MaxComponent/plNotetrackAnim.h | 22 +-- Sources/Tools/MaxComponent/plNotetrackDlg.cpp | 14 +- .../MaxComponent/plObjectFlockerComponent.cpp | 2 +- .../MaxComponent/plParticleComponents.cpp | 6 +- .../MaxComponent/plPhysicalComponents.cpp | 6 +- .../MaxComponent/plPythonFileComponent.cpp | 22 +-- .../Tools/MaxComponent/plResponderAnim.cpp | 22 +-- Sources/Tools/MaxComponent/plResponderCmd.h | 6 +- .../MaxComponent/plResponderComponent.cpp | 6 +- .../Tools/MaxComponent/plResponderLink.cpp | 2 +- Sources/Tools/MaxComponent/plResponderMtl.cpp | 46 +++-- Sources/Tools/MaxComponent/plResponderMtl.h | 6 +- .../Tools/MaxComponent/plResponderWait.cpp | 6 +- Sources/Tools/MaxComponent/plResponderWait.h | 3 +- .../MaxComponent/plSoftVolumeComponent.cpp | 8 +- .../Tools/MaxComponent/plTypesComponents.cpp | 9 +- .../MaxComponent/plVolumeGadgetComponent.cpp | 11 +- .../Tools/MaxComponent/plWaterComponent.cpp | 4 +- .../Tools/MaxConvert/hsControlConverter.cpp | 2 +- Sources/Tools/MaxConvert/hsConverterUtils.cpp | 2 +- .../Tools/MaxConvert/hsMaterialConverter.cpp | 168 +++++++++--------- .../Tools/MaxConvert/hsMaterialConverter.h | 31 ++-- Sources/Tools/MaxConvert/plBitmapCreator.cpp | 17 +- Sources/Tools/MaxConvert/plBitmapCreator.h | 2 +- Sources/Tools/MaxConvert/plClusterUtil.cpp | 3 +- Sources/Tools/MaxConvert/plLayerConverter.cpp | 45 +++-- Sources/Tools/MaxConvert/plLayerConverter.h | 11 +- Sources/Tools/MaxConvert/plLightMapGen.cpp | 15 +- Sources/Tools/MaxMain/plCommonObjLib.cpp | 4 +- Sources/Tools/MaxMain/plCommonObjLib.h | 4 +- Sources/Tools/MaxMain/plMaxNode.cpp | 75 ++++---- Sources/Tools/MaxMain/plMaxNode.h | 4 +- Sources/Tools/MaxMain/plPluginResManager.cpp | 3 +- Sources/Tools/MaxMain/plTextureExportLog.cpp | 2 +- .../MaxPlasmaMtls/Layers/plPlasmaMAXLayer.cpp | 5 +- .../Materials/plAnimStealthConvert.cpp | 29 ++- .../Materials/plAnimStealthNode.cpp | 25 ++- .../Materials/plAnimStealthNode.h | 28 +-- .../MaxPlasmaMtls/Materials/plBumpMtl.cpp | 2 +- .../MaxPlasmaMtls/Materials/plDecalMtl.cpp | 2 +- .../Materials/plPassAnimDlgProc.cpp | 2 +- .../MaxPlasmaMtls/Materials/plPassMtl.cpp | 2 +- .../MaxPlasmaMtls/Materials/plPassMtlBase.cpp | 22 +-- .../MaxPlasmaMtls/Materials/plPassMtlBase.h | 5 +- 129 files changed, 952 insertions(+), 1109 deletions(-) diff --git a/Sources/Plasma/CoreLib/hsStream.cpp b/Sources/Plasma/CoreLib/hsStream.cpp index 18071430..257511bf 100644 --- a/Sources/Plasma/CoreLib/hsStream.cpp +++ b/Sources/Plasma/CoreLib/hsStream.cpp @@ -322,15 +322,14 @@ wchar_t *hsStream::ReadSafeWString() return retVal; } -uint32_t hsStream::WriteSafeString_TEMP(const plString &string) +uint32_t hsStream::WriteSafeString(const plString &string) { - return WriteSafeString(string.c_str()); + return WriteSafeString(_TEMP_CONVERT_TO_CONST_CHAR(string)); } -uint32_t hsStream::WriteSafeWString_TEMP(const plString &string) +uint32_t hsStream::WriteSafeWString(const plString &string) { - plStringBuffer wbuffer = string.ToWchar(); - return WriteSafeWString(wbuffer.GetData()); + return WriteSafeWString(_TEMP_CONVERT_TO_WCHAR_T(string)); } plString hsStream::ReadSafeString_TEMP() diff --git a/Sources/Plasma/CoreLib/hsStream.h b/Sources/Plasma/CoreLib/hsStream.h index cf0c5599..3ae694d4 100644 --- a/Sources/Plasma/CoreLib/hsStream.h +++ b/Sources/Plasma/CoreLib/hsStream.h @@ -145,8 +145,8 @@ public: char * ReadSafeString(); wchar_t * ReadSafeWString(); - uint32_t WriteSafeString_TEMP(const plString &string); // uses 2 bytes for length - uint32_t WriteSafeWString_TEMP(const plString &string); + uint32_t WriteSafeString(const plString &string); // uses 2 bytes for length + uint32_t WriteSafeWString(const plString &string); plString ReadSafeString_TEMP(); plString ReadSafeWString_TEMP(); diff --git a/Sources/Plasma/CoreLib/plString.cpp b/Sources/Plasma/CoreLib/plString.cpp index e58e204f..c4ba50f0 100644 --- a/Sources/Plasma/CoreLib/plString.cpp +++ b/Sources/Plasma/CoreLib/plString.cpp @@ -28,6 +28,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include +#include const plString plString::Null; @@ -51,6 +52,11 @@ static inline size_t u16slen(const uint16_t *ustr, size_t max) void plString::IConvertFromUtf8(const char *utf8, size_t size, bool steal) { + if (utf8 == nil) { + fUtf8Buffer = plStringBuffer(); + return; + } + if ((long)size < 0) size = strnlen(utf8, -(long)size); @@ -85,6 +91,11 @@ void plString::IConvertFromUtf8(const char *utf8, size_t size, bool steal) void plString::IConvertFromUtf16(const uint16_t *utf16, size_t size) { + if (utf16 == nil) { + fUtf8Buffer = plStringBuffer(); + return; + } + if ((long)size < 0) size = u16slen(utf16, -(long)size); @@ -156,6 +167,11 @@ void plString::IConvertFromWchar(const wchar_t *wstr, size_t size) // We assume that if sizeof(wchar_t) == 2, the data is UTF-16 already IConvertFromUtf16((const uint16_t *)wstr, size); #else + if (wstr == nil) { + fUtf8Buffer = plStringBuffer(); + return; + } + if ((long)size < 0) size = wcsnlen(wstr, -(long)size); @@ -213,6 +229,11 @@ void plString::IConvertFromWchar(const wchar_t *wstr, size_t size) void plString::IConvertFromIso8859_1(const char *astr, size_t size) { + if (astr == nil) { + fUtf8Buffer = plStringBuffer(); + return; + } + if ((long)size < 0) size = strnlen(astr, -(long)size); diff --git a/Sources/Plasma/CoreLib/plString.h b/Sources/Plasma/CoreLib/plString.h index 212a0d5a..f2a4d4b8 100644 --- a/Sources/Plasma/CoreLib/plString.h +++ b/Sources/Plasma/CoreLib/plString.h @@ -39,8 +39,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com */ #define _TEMP_CONVERT_FROM_LITERAL(x) plString::FromUtf8((x)) #define _TEMP_CONVERT_FROM_WCHAR_T(x) plString::FromWchar((x)) -#define _TEMP_CONVERT_TO_CONST_CHAR(x) (x).c_str() -#define _TEMP_CONVERT_TO_CONST_CHAR_S(x) (x).s_str() +#define _TEMP_CONVERT_TO_CONST_CHAR(x) ((x).c_str()) +#define _TEMP_CONVERT_TO_WCHAR_T(x) ((x).ToWchar().GetData()) typedef unsigned int UniChar; @@ -70,7 +70,7 @@ private: StringRef *fData; public: - plStringBuffer() : fData(0) { } + plStringBuffer() : fData(nil) { } plStringBuffer(const plStringBuffer<_Ch> ©) { diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp index f31f4553..0069cc7a 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp @@ -632,11 +632,11 @@ PF_CONSOLE_CMD( Avatar_Physics, TogglePhysical, "", "Disable/enable physics on t PF_CONSOLE_CMD( Avatar_Anim, BlendAnim, "string Animation, float blendFactor", "Blend the given animation with the current animation.") { - char *animationName = params[0]; + plString animationName = plString::FromUtf8(params[0]); float blendFactor = params[1]; plArmatureMod *avatar = plAvatarMgr::GetInstance()->GetLocalAvatar(); - if (avatar && animationName) + if (avatar && !animationName.IsNull()) { plAGAnim * anim = plAGAnim::FindAnim(animationName); if(anim) @@ -650,12 +650,12 @@ PF_CONSOLE_CMD( Avatar_Anim, BlendAnim, "string Animation, float blendFactor", " PF_CONSOLE_CMD( Avatar_Anim, BlendAnimPri, "string Animation, float blendFactor, int priority", "Blend animation using priority.") { - char *animationName = params[0]; + plString animationName = plString::FromUtf8(params[0]); float blendFactor = params[1]; int priority = params[2]; plArmatureMod *avatar = plAvatarMgr::GetInstance()->GetLocalAvatar(); - if (avatar && animationName) + if (avatar && !animationName.IsNull()) { plAGAnim * anim = plAGAnim::FindAnim(animationName); if(anim) @@ -671,15 +671,15 @@ PF_CONSOLE_CMD( Avatar_Anim, PlaySimpleAnim, "string AvatarName, string Animatio { plArmatureMod *avatar = plAvatarMgr::GetInstance()->FindAvatarByModelName(params[0]); if (avatar) - avatar->PlaySimpleAnim(params[1]); + avatar->PlaySimpleAnim(plString::FromUtf8(params[1])); } PF_CONSOLE_CMD( Avatar_Anim, DetachAnim, "string Animation", "Remove the given animation from the avatar.") { - char *animationName = params[0]; + plString animationName = plString::FromUtf8(params[0]); plArmatureMod *avatar = plAvatarMgr::GetInstance()->GetLocalAvatar(); - if (avatar && animationName) + if (avatar && !animationName.IsNull()) { plAGAnimInstance * instance = avatar->FindAnimInstance(animationName); if(instance) @@ -691,11 +691,11 @@ PF_CONSOLE_CMD( Avatar_Anim, DetachAnim, "string Animation", "Remove the given a PF_CONSOLE_CMD( Avatar_Anim, SetBlend, "string Animation, float blend", "Set the blend of the given animation.") { - char *animationName = params[0]; + plString animationName = plString::FromUtf8(params[0]); float blend = params[1]; plArmatureMod *avatar = plAvatarMgr::GetInstance()->GetLocalAvatar(); - if (avatar && animationName) + if (avatar && !animationName.IsNull()) { plAGAnimInstance *anim = avatar->FindAnimInstance(animationName); if(anim) diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp index a53e5fd8..0499522d 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp @@ -6548,7 +6548,7 @@ PF_CONSOLE_CMD( Animation, // Group name { plAnimCmdMsg *msg = new plAnimCmdMsg(); msg->SetCmd(plAnimCmdMsg::kContinue); - msg->SetAnimName(nil); + msg->SetAnimName(plString::Null); msg->SetBCastFlag(plMessage::kPropagateToModifiers); SendAnimCmdMsg(plString::FromUtf8(params[0]), msg); } @@ -6560,7 +6560,7 @@ PF_CONSOLE_CMD( Animation, // Group name { plAnimCmdMsg *msg = new plAnimCmdMsg(); msg->SetCmd(plAnimCmdMsg::kStop); - msg->SetAnimName(nil); + msg->SetAnimName(plString::Null); msg->SetBCastFlag(plMessage::kPropagateToModifiers); SendAnimCmdMsg(plString::FromUtf8(params[0]), msg); } @@ -6574,7 +6574,7 @@ PF_CONSOLE_CMD( Animation, // Group name msg->SetCmd(plAGCmdMsg::kSetBlend); msg->fBlend = params[2]; msg->fBlendRate = params[3]; - msg->SetAnimName(params[1]); + msg->SetAnimName(plString::FromUtf8(params[1])); msg->SetBCastFlag(plMessage::kPropagateToModifiers); SendAnimCmdMsg(plString::FromUtf8(params[0]), msg); } @@ -6588,7 +6588,7 @@ PF_CONSOLE_CMD( Animation, // Group name msg->SetCmd(plAGCmdMsg::kSetAmp); msg->fAmp = params[2]; msg->fAmpRate = params[3]; - msg->SetAnimName(params[1]); + msg->SetAnimName(plString::FromUtf8(params[1])); msg->SetBCastFlag(plMessage::kPropagateToModifiers); SendAnimCmdMsg(plString::FromUtf8(params[0]), msg); } @@ -6602,7 +6602,7 @@ PF_CONSOLE_CMD( Animation, // Group name msg->SetCmd(plAnimCmdMsg::kSetSpeed); msg->fSpeed = params[2]; msg->fSpeedChangeRate = params[3]; - msg->SetAnimName(params[1]); + msg->SetAnimName(plString::FromUtf8(params[1])); msg->SetBCastFlag(plMessage::kPropagateToModifiers); SendAnimCmdMsg(plString::FromUtf8(params[0]), msg); } diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIButtonMod.cpp b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIButtonMod.cpp index 5225d19d..d31af392 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIButtonMod.cpp +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIButtonMod.cpp @@ -150,8 +150,6 @@ void pfGUIButtonMod::StartDragging( void ) pfGUIButtonMod::pfGUIButtonMod() { - fAnimName = nil; - fMouseOverAnimName = nil; fDraggable = nil; fOrigHandler = nil; @@ -161,12 +159,6 @@ pfGUIButtonMod::pfGUIButtonMod() SetFlag( kWantsInterest ); } -pfGUIButtonMod::~pfGUIButtonMod() -{ - delete [] fAnimName; - delete [] fMouseOverAnimName; -} - //// IEval /////////////////////////////////////////////////////////////////// hsBool pfGUIButtonMod::IEval( double secs, float del, uint32_t dirty ) @@ -204,13 +196,13 @@ void pfGUIButtonMod::Read( hsStream *s, hsResMgr *mgr ) uint32_t i, count = s->ReadLE32(); for( i = 0; i < count; i++ ) fAnimationKeys.Append( mgr->ReadKey( s ) ); - fAnimName = s->ReadSafeString(); + fAnimName = s->ReadSafeString_TEMP(); fMouseOverAnimKeys.Reset(); count = s->ReadLE32(); for( i = 0; i < count; i++ ) fMouseOverAnimKeys.Append( mgr->ReadKey( s ) ); - fMouseOverAnimName = s->ReadSafeString(); + fMouseOverAnimName = s->ReadSafeString_TEMP(); fNotifyType = s->ReadLE32(); mgr->ReadKeyNotifyMe( s, new plGenRefMsg( GetKey(), plRefMsg::kOnCreate, -1, kRefDraggable ), plRefFlags::kActiveRef ); @@ -366,30 +358,16 @@ void pfGUIButtonMod::SetInteresting( hsBool i ) } -void pfGUIButtonMod::SetAnimationKeys( hsTArray &keys, const char *name ) +void pfGUIButtonMod::SetAnimationKeys( hsTArray &keys, const plString &name ) { fAnimationKeys = keys; - delete [] fAnimName; - if( name != nil ) - { - fAnimName = new char[ strlen( name ) + 1 ]; - strcpy( fAnimName, name ); - } - else - fAnimName = nil; + fAnimName = name; } -void pfGUIButtonMod::SetMouseOverAnimKeys( hsTArray &keys, const char *name ) +void pfGUIButtonMod::SetMouseOverAnimKeys( hsTArray &keys, const plString &name ) { fMouseOverAnimKeys = keys; - delete [] fMouseOverAnimName; - if( name != nil ) - { - fMouseOverAnimName = new char[ strlen( name ) + 1 ]; - strcpy( fMouseOverAnimName, name ); - } - else - fMouseOverAnimName = nil; + fMouseOverAnimName = name; } diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIButtonMod.h b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIButtonMod.h index faed9a1e..b7f92c36 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIButtonMod.h +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIButtonMod.h @@ -60,10 +60,10 @@ class pfGUIButtonMod : public pfGUIControlMod protected: hsTArray fAnimationKeys; - char *fAnimName; + plString fAnimName; hsTArray fMouseOverAnimKeys; - char *fMouseOverAnimName; + plString fMouseOverAnimName; hsBool fClicking; hsBool fTriggering; @@ -83,7 +83,6 @@ class pfGUIButtonMod : public pfGUIControlMod public: pfGUIButtonMod(); - virtual ~pfGUIButtonMod(); CLASSNAME_REGISTER( pfGUIButtonMod ); GETINTERFACE_ANY( pfGUIButtonMod, pfGUIControlMod ); @@ -130,8 +129,8 @@ class pfGUIButtonMod : public pfGUIControlMod void StopDragging( hsBool cancel ); // Export only - void SetAnimationKeys( hsTArray &keys, const char *name ); - void SetMouseOverAnimKeys( hsTArray &keys, const char *name ); + void SetAnimationKeys( hsTArray &keys, const plString &name ); + void SetMouseOverAnimKeys( hsTArray &keys, const plString &name ); }; #endif // _pfGUIButtonMod_h diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICheckBoxCtrl.cpp b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICheckBoxCtrl.cpp index ac43b99b..24b853a2 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICheckBoxCtrl.cpp +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICheckBoxCtrl.cpp @@ -65,18 +65,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com pfGUICheckBoxCtrl::pfGUICheckBoxCtrl() { - fAnimName = nil; SetFlag( kWantsInterest ); fChecked = false; fClicking = false; fPlaySound = true; } -pfGUICheckBoxCtrl::~pfGUICheckBoxCtrl() -{ - delete [] fAnimName; -} - //// IEval /////////////////////////////////////////////////////////////////// hsBool pfGUICheckBoxCtrl::IEval( double secs, float del, uint32_t dirty ) @@ -102,7 +96,7 @@ void pfGUICheckBoxCtrl::Read( hsStream *s, hsResMgr *mgr ) for( i = 0; i < count; i++ ) fAnimationKeys.Append( mgr->ReadKey( s ) ); - fAnimName = s->ReadSafeString(); + fAnimName = s->ReadSafeString_TEMP(); fChecked = s->ReadBool(); } @@ -197,17 +191,10 @@ void pfGUICheckBoxCtrl::SetChecked( hsBool checked, hsBool immediate /*= fals } } -void pfGUICheckBoxCtrl::SetAnimationKeys( hsTArray &keys, const char *name ) +void pfGUICheckBoxCtrl::SetAnimationKeys( hsTArray &keys, const plString &name ) { fAnimationKeys = keys; - delete [] fAnimName; - if( name != nil ) - { - fAnimName = new char[ strlen( name ) + 1 ]; - strcpy( fAnimName, name ); - } - else - fAnimName = nil; + fAnimName = name; } //// IGetDesiredCursor /////////////////////////////////////////////////////// diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICheckBoxCtrl.h b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICheckBoxCtrl.h index c4c3e38e..912e4f1c 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICheckBoxCtrl.h +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICheckBoxCtrl.h @@ -59,7 +59,7 @@ class pfGUICheckBoxCtrl : public pfGUIControlMod protected: hsTArray fAnimationKeys; - char *fAnimName; + plString fAnimName; hsBool fClicking; hsBool fChecked; @@ -72,7 +72,6 @@ class pfGUICheckBoxCtrl : public pfGUIControlMod public: pfGUICheckBoxCtrl(); - virtual ~pfGUICheckBoxCtrl(); CLASSNAME_REGISTER( pfGUICheckBoxCtrl ); GETINTERFACE_ANY( pfGUICheckBoxCtrl, pfGUIControlMod ); @@ -94,7 +93,7 @@ class pfGUICheckBoxCtrl : public pfGUIControlMod void DontPlaySounds() { fPlaySound = false; } // should the checkbox play sounds? const hsTArray &GetAnimationKeys( void ) const { return fAnimationKeys; } - const char *GetAnimationName( void ) const { return fAnimName; } + plString GetAnimationName( void ) const { return fAnimName; } enum SoundEvents { @@ -105,7 +104,7 @@ class pfGUICheckBoxCtrl : public pfGUIControlMod }; // Export only - void SetAnimationKeys( hsTArray &keys, const char *name ); + void SetAnimationKeys( hsTArray &keys, const plString &name ); }; #endif // _pfGUICheckBoxCtrl_h diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIKnobCtrl.cpp b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIKnobCtrl.cpp index 45a2ca64..264ccd07 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIKnobCtrl.cpp +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIKnobCtrl.cpp @@ -69,7 +69,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com //// Constructor/Destructor ////////////////////////////////////////////////// pfGUIKnobCtrl::pfGUIKnobCtrl() : - fAnimName(nil), fDragStart(0.f, 0.f, 0.f), fDragging(false), fAnimStartPos(0.f, 0.f, 0.f), @@ -83,11 +82,6 @@ pfGUIKnobCtrl::pfGUIKnobCtrl() : SetFlag( kWantsInterest ); } -pfGUIKnobCtrl::~pfGUIKnobCtrl() -{ - delete [] fAnimName; -} - //// IEval /////////////////////////////////////////////////////////////////// hsBool pfGUIKnobCtrl::IEval( double secs, float del, uint32_t dirty ) @@ -112,7 +106,7 @@ void pfGUIKnobCtrl::Read( hsStream *s, hsResMgr *mgr ) uint32_t i, count = s->ReadLE32(); for( i = 0; i < count; i++ ) fAnimationKeys.Append( mgr->ReadKey( s ) ); - fAnimName = s->ReadSafeString(); + fAnimName = s->ReadSafeString_TEMP(); fAnimTimesCalced = false; @@ -262,17 +256,10 @@ void pfGUIKnobCtrl::HandleMouseDrag( hsPoint3 &mousePt, uint8_t modifiers ) //// SetAnimationKeys //////////////////////////////////////////////////////// -void pfGUIKnobCtrl::SetAnimationKeys( hsTArray &keys, const char *name ) +void pfGUIKnobCtrl::SetAnimationKeys( hsTArray &keys, const plString &name ) { fAnimationKeys = keys; - delete [] fAnimName; - if( name != nil ) - { - fAnimName = new char[ strlen( name ) + 1 ]; - strcpy( fAnimName, name ); - } - else - fAnimName = nil; + fAnimName = name; } //// ICalcAnimTimes ////////////////////////////////////////////////////////// diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIKnobCtrl.h b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIKnobCtrl.h index c58753c6..006849d9 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIKnobCtrl.h +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIKnobCtrl.h @@ -58,17 +58,17 @@ class pfGUIKnobCtrl : public pfGUIValueCtrl protected: hsTArray fAnimationKeys; - char *fAnimName; + plString fAnimName; hsPoint3 fDragStart; - float fDragValue; + float fDragValue; hsBool fDragging; hsPoint3 fAnimStartPos, fAnimEndPos; // Calculated at export time for kMapToScreenRange - float fDragRangeMin, fDragRangeMax; + float fDragRangeMin, fDragRangeMax; // Computed once, once an anim is loaded that we can compute this with - float fAnimBegin, fAnimEnd; + float fAnimBegin, fAnimEnd; hsBool fAnimTimesCalced; virtual hsBool IEval( double secs, float del, uint32_t dirty ); // called only by owner object's Eval() @@ -80,7 +80,6 @@ class pfGUIKnobCtrl : public pfGUIValueCtrl public: pfGUIKnobCtrl(); - virtual ~pfGUIKnobCtrl(); CLASSNAME_REGISTER( pfGUIKnobCtrl ); GETINTERFACE_ANY( pfGUIKnobCtrl, pfGUIValueCtrl ); @@ -109,7 +108,7 @@ class pfGUIKnobCtrl : public pfGUIValueCtrl virtual void SetCurrValue( float v ); // Export only - void SetAnimationKeys( hsTArray &keys, const char *name ); + void SetAnimationKeys( hsTArray &keys, const plString &name ); void SetScreenRange( const hsPoint3 &startPos, const hsPoint3 &endPos ) { fAnimStartPos = startPos; fAnimEndPos = endPos; } }; diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIProgressCtrl.cpp b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIProgressCtrl.cpp index dc0ac095..a8dc6ef0 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIProgressCtrl.cpp +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIProgressCtrl.cpp @@ -72,15 +72,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com pfGUIProgressCtrl::pfGUIProgressCtrl() : fStopSoundTimer(99) { fAnimTimesCalced = false; - fAnimName = nil; fPlaySound = true; } -pfGUIProgressCtrl::~pfGUIProgressCtrl() -{ - delete [] fAnimName; -} - //// IEval /////////////////////////////////////////////////////////////////// hsBool pfGUIProgressCtrl::IEval( double secs, float del, uint32_t dirty ) @@ -114,7 +108,7 @@ void pfGUIProgressCtrl::Read( hsStream *s, hsResMgr *mgr ) uint32_t i, count = s->ReadLE32(); for( i = 0; i < count; i++ ) fAnimationKeys.Append( mgr->ReadKey( s ) ); - fAnimName = s->ReadSafeString(); + fAnimName = s->ReadSafeString_TEMP(); fAnimTimesCalced = false; } @@ -141,17 +135,10 @@ void pfGUIProgressCtrl::UpdateBounds( hsMatrix44 *invXformMatrix, hsBool forc //// SetAnimationKeys //////////////////////////////////////////////////////// -void pfGUIProgressCtrl::SetAnimationKeys( hsTArray &keys, const char *name ) +void pfGUIProgressCtrl::SetAnimationKeys( hsTArray &keys, const plString &name ) { fAnimationKeys = keys; - delete [] fAnimName; - if( name != nil ) - { - fAnimName = new char[ strlen( name ) + 1 ]; - strcpy( fAnimName, name ); - } - else - fAnimName = nil; + fAnimName = name; } //// ICalcAnimTimes ////////////////////////////////////////////////////////// diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIProgressCtrl.h b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIProgressCtrl.h index 18c7c50a..9e207c21 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIProgressCtrl.h +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIProgressCtrl.h @@ -58,10 +58,10 @@ class pfGUIProgressCtrl : public pfGUIValueCtrl protected: hsTArray fAnimationKeys; - char *fAnimName; + plString fAnimName; // Computed once, once an anim is loaded that we can compute this with - float fAnimBegin, fAnimEnd; + float fAnimBegin, fAnimEnd; hsBool fAnimTimesCalced; hsBool fPlaySound; @@ -69,12 +69,11 @@ class pfGUIProgressCtrl : public pfGUIValueCtrl hsBool ICalcAnimTimes( void ); - const uint32_t fStopSoundTimer; + const uint32_t fStopSoundTimer; public: pfGUIProgressCtrl(); - virtual ~pfGUIProgressCtrl(); CLASSNAME_REGISTER( pfGUIProgressCtrl ); GETINTERFACE_ANY( pfGUIProgressCtrl, pfGUIValueCtrl ); @@ -103,7 +102,7 @@ class pfGUIProgressCtrl : public pfGUIValueCtrl void DontPlaySounds() { fPlaySound = false; } // Export only - void SetAnimationKeys( hsTArray &keys, const char *name ); + void SetAnimationKeys( hsTArray &keys, const plString &name ); }; #endif // _pfGUIProgressCtrl_h diff --git a/Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp b/Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp index 2d6a4698..10bc1176 100644 --- a/Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp +++ b/Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp @@ -867,7 +867,7 @@ void pfBookData::ITriggerPageFlip(hsBool flipBackwards, hsBool immediate) // in MAX, we just use a GUI check box to grab them for us, even though we never // actually use the functionality of the checkbox itself const hsTArray &keys = fTurnPageButton->GetAnimationKeys(); - const char *animName = fTurnPageButton->GetAnimationName(); + plString animName = fTurnPageButton->GetAnimationName(); plAnimCmdMsg *msg = new plAnimCmdMsg(); if (immediate) @@ -1474,7 +1474,7 @@ void pfJournalBook::ITriggerCloseWithNotify( hsBool closeNotOpen, hsBool imme fBookGUIs[fCurBookGUI]->CurrentlyOpen(!closeNotOpen); const hsTArray &keys = fBookGUIs[fCurBookGUI]->CoverButton()->GetAnimationKeys(); - const char *animName = fBookGUIs[fCurBookGUI]->CoverButton()->GetAnimationName(); + plString animName = fBookGUIs[fCurBookGUI]->CoverButton()->GetAnimationName(); plAnimCmdMsg *msg = new plAnimCmdMsg(); if( !immediate ) diff --git a/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp b/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp index 6751e1bd..c57afce5 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp @@ -174,7 +174,7 @@ plKey cyAvatar::IFindArmatureModKey(plKey avKey) // PURPOSE : oneShot Avatar (must already be there) // void cyAvatar::OneShot(pyKey &seekKey, float duration, hsBool usePhysics, - const char *animName, hsBool drivable, hsBool reversible) + const plString &animName, hsBool drivable, hsBool reversible) { if ( fRecvr.Count() > 0 ) { @@ -185,7 +185,7 @@ void cyAvatar::OneShot(pyKey &seekKey, float duration, hsBool usePhysics, seekKey.getKey(), // Mark D told me to do it ...paulg duration, usePhysics, - animName, // Constructor will do a copy. -mf- hsStrcpy(animName), + animName, drivable, reversible); @@ -1586,7 +1586,7 @@ void cyAvatar::ExitSubWorld() // // PURPOSE : Place the Avatar into the subworld of the sceneobject specified // -void cyAvatar::PlaySimpleAnimation(const char* animName) +void cyAvatar::PlaySimpleAnimation(const plString& animName) { // make sure that there is atleast one avatar scene object attached (should be) if ( fRecvr.Count() > 0) diff --git a/Sources/Plasma/FeatureLib/pfPython/cyAvatar.h b/Sources/Plasma/FeatureLib/pfPython/cyAvatar.h index ded3c41e..21281c0b 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyAvatar.h +++ b/Sources/Plasma/FeatureLib/pfPython/cyAvatar.h @@ -103,7 +103,7 @@ public: // oneShot Avatar (must already be there) virtual void OneShot(pyKey &seekKey, float duration, hsBool usePhysics, - const char *animName, hsBool drivable, hsBool reversible); + const plString &animName, hsBool drivable, hsBool reversible); // oneShot Avatar virtual void RunBehavior(pyKey &behKey, hsBool netForce, hsBool netProp); @@ -412,7 +412,7 @@ public: // virtual void ExitSubWorld(); - virtual void PlaySimpleAnimation(const char* animName); + virtual void PlaySimpleAnimation(const plString& animName); ///////////////////////////////////////////////////////////////////////////// // diff --git a/Sources/Plasma/FeatureLib/pfPython/cyAvatarGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/cyAvatarGlue.cpp index feb49db1..20a30ec9 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyAvatarGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyAvatarGlue.cpp @@ -89,8 +89,7 @@ PYTHON_METHOD_DEFINITION(ptAvatar, oneShot, args) } pyKey* key = pyKey::ConvertFrom(keyObj); - std::string animNameStr = animName; // convert to string (for safety) - self->fThis->OneShot(*key, duration, usePhysics != 0, animNameStr.c_str(), drivable != 0, reversable != 0); + self->fThis->OneShot(*key, duration, usePhysics != 0, plString::FromUtf8(animName), drivable != 0, reversable != 0); PYTHON_RETURN_NONE; } @@ -592,8 +591,7 @@ PYTHON_METHOD_DEFINITION(ptAvatar, playSimpleAnimation, args) PYTHON_RETURN_ERROR; } - std::string animNameStr = animName; // convert to a string (for safety) - self->fThis->PlaySimpleAnimation(animNameStr.c_str()); + self->fThis->PlaySimpleAnimation(plString::FromUtf8(animName)); PYTHON_RETURN_NONE; } diff --git a/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp b/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp index 156c6475..6d89af14 100644 --- a/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp @@ -629,23 +629,23 @@ void plPythonFileMod::AddTarget(plSceneObject* sobj) NamedComponent comp; comp.isActivator = (isNamedAttr == 1); comp.id = parameter.fID; - comp.name = plString::FromUtf8(parameter.datarecord.fString); + comp.name = parameter.fString; fNamedCompQueue.Append(comp); } else { if (isNamedAttr == 1) - IFindActivatorAndAdd(plString::FromUtf8(parameter.datarecord.fString), parameter.fID); + IFindActivatorAndAdd(parameter.fString, parameter.fID); else - IFindResponderAndAdd(plString::FromUtf8(parameter.datarecord.fString), parameter.fID); + IFindResponderAndAdd(parameter.fString, parameter.fID); } } } // if it wasn't a named string then must be normal string type if ( isNamedAttr == 0 ) - if ( parameter.datarecord.fString != nil ) - value = PyString_FromString(parameter.datarecord.fString); + if ( !parameter.fString.IsNull() ) + value = PyString_FromString(parameter.fString.c_str()); break; case plPythonParameter::kSceneObject: case plPythonParameter::kSceneObjectList: diff --git a/Sources/Plasma/FeatureLib/pfPython/plPythonParameter.h b/Sources/Plasma/FeatureLib/pfPython/plPythonParameter.h index d77db84f..e22febc8 100644 --- a/Sources/Plasma/FeatureLib/pfPython/plPythonParameter.h +++ b/Sources/Plasma/FeatureLib/pfPython/plPythonParameter.h @@ -94,17 +94,16 @@ public: // the data of the value union { - int32_t fIntNumber; + int32_t fIntNumber; - float fFloatNumber; + float fFloatNumber; hsBool fBool; - char* fString; - } datarecord; plKey fObjectKey; // the plKey of the scene object (should be part of the union, but unions don't allow complex types) + plString fString; plPythonParameter() @@ -147,7 +146,7 @@ public: SetTobool(other.datarecord.fBool); break; case kString: - SetToString(other.datarecord.fString); + SetToString(other.fString); break; case kSceneObject: SetToSceneObject(other.fObjectKey); @@ -174,7 +173,7 @@ public: SetToAnimation(other.fObjectKey); break; case kAnimationName: - SetToAnimationName(other.datarecord.fString); + SetToAnimationName(other.fString); break; case kBehavior: SetToBehavior(other.fObjectKey); @@ -214,10 +213,6 @@ public: void SetToNone() { - // remove the string if one was created - if ( fValueType == kString || fValueType == kAnimationName ) - delete [] datarecord.fString; - fValueType = kNone; } @@ -239,11 +234,11 @@ public: fValueType = kbool; datarecord.fBool = state; } - void SetToString(const char* string) + void SetToString(const plString& string) { SetToNone(); fValueType = kString; - datarecord.fString = hsStrcpy(string); + fString = string; } void SetToSceneObject(plKey key, hsBool list=false) { @@ -302,11 +297,11 @@ public: fValueType = kAnimation; fObjectKey = key; } - void SetToAnimationName(const char* string) + void SetToAnimationName(const plString& string) { SetToNone(); fValueType = kAnimationName; - datarecord.fString = hsStrcpy(string); + fString = string; } void SetToBehavior(plKey key) { @@ -380,11 +375,13 @@ public: count = stream->ReadLE32(); if ( count != 0 ) { - datarecord.fString = new char[count+1]; - stream->ReadLE(count,datarecord.fString); + char *buffer = new char[count]; + stream->ReadLE(count, buffer); + buffer[count-1] = 0; + fString = plString::Steal(buffer, count); } else - datarecord.fString = nil; + fString = plString::Null; break; case kSceneObject: @@ -430,13 +427,13 @@ public: case kString: case kAnimationName: - if ( datarecord.fString != nil ) - count = hsStrlen(datarecord.fString)+1; + if ( !fString.IsNull() ) + count = fString.GetSize()+1; else count = 0; stream->WriteLE(count); if ( count != 0 ) - stream->WriteLE(count,datarecord.fString); + stream->WriteLE(count, fString.c_str()); break; case kSceneObject: diff --git a/Sources/Plasma/FeatureLib/pfPython/pyCritterBrain.cpp b/Sources/Plasma/FeatureLib/pfPython/pyCritterBrain.cpp index b4883bdf..063778de 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyCritterBrain.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyCritterBrain.cpp @@ -109,24 +109,24 @@ std::string pyCritterBrain::BehaviorName(int behavior) const return fBrain->BehaviorName(behavior); } -std::string pyCritterBrain::AnimationName(int behavior) const +plString pyCritterBrain::AnimationName(int behavior) const { if (!fBrain) - return false; + return plString::Null; return fBrain->AnimationName(behavior); } int pyCritterBrain::CurBehavior() const { if (!fBrain) - return false; + return 0; return fBrain->CurBehavior(); } int pyCritterBrain::NextBehavior() const { if (!fBrain) - return false; + return 0; return fBrain->NextBehavior(); } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyCritterBrain.h b/Sources/Plasma/FeatureLib/pfPython/pyCritterBrain.h index 8f211ae9..28bb3eb4 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyCritterBrain.h +++ b/Sources/Plasma/FeatureLib/pfPython/pyCritterBrain.h @@ -92,7 +92,7 @@ public: bool RunningBehavior(const std::string& behaviorName) const; std::string BehaviorName(int behavior) const; - std::string AnimationName(int behavior) const; + plString AnimationName(int behavior) const; int CurBehavior() const; int NextBehavior() const; diff --git a/Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp b/Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp index c1ebce7e..6b42e130 100644 --- a/Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp +++ b/Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp @@ -208,7 +208,7 @@ void plUoid::Write(hsStream* s) const s->WriteLE( fClassType ); s->WriteLE( fObjectID ); - s->WriteSafeString_TEMP( fObjectName ); + s->WriteSafeString( fObjectName ); // conditional cloneIDs write if (contents & kHasCloneIDs) diff --git a/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtSubst.cpp b/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtSubst.cpp index 9a671032..c05a93e3 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtSubst.cpp +++ b/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtSubst.cpp @@ -157,8 +157,7 @@ bool IParseForSubst ( } // Validate variable name length - chartype varBuffer[256]; - if (varEnd - varStart >= arrsize(varBuffer)) { + if (varEnd - varStart >= 256) { result = false; src = current = varEnd + 1; continue; diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGAnim.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAGAnim.cpp index 00bb52db..5b9ccf77 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGAnim.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGAnim.cpp @@ -76,31 +76,24 @@ plAGAnim::plAnimMap plAGAnim::fAllAnims; plAGAnim::plAGAnim() : plSynchedObject() { - fName = nil; } // ctor ------------------------------------------------------ // ----- -plAGAnim::plAGAnim(const char *name, double start, double end) +plAGAnim::plAGAnim(const plString &name, double start, double end) : fStart((float)start), - fEnd((float)end) + fEnd((float)end), + fName(name) { - if (name == nil) - name = ""; - - fName = new char[strlen(name) + 1]; - strcpy(fName, name); } // dtor ------------- // ----- plAGAnim::~plAGAnim() { - if (fName) + if (!fName.IsNull()) { RemoveAnim(fName); - delete[] fName; - fName = nil; } //int numChannels = fChannels.size(); @@ -137,7 +130,7 @@ plAGChannel * plAGAnim::GetChannel(int index) const // GetChannel -------------------------------------------- // ----------- -plAGChannel * plAGAnim::GetChannel(const char *name) const +plAGChannel * plAGAnim::GetChannel(const plString &name) const { int appCount = fApps.size(); @@ -145,9 +138,9 @@ plAGChannel * plAGAnim::GetChannel(const char *name) const { plAGApplicator *app = fApps[i]; plAGChannel *channel = app->GetChannel(); - const char *channelName = app->GetChannelName(); + plString channelName = app->GetChannelName(); - if(stricmp(name, channelName) == 0) + if(name.Compare(channelName, plString::kCaseInsensitive) == 0) { return channel; } @@ -205,7 +198,7 @@ void plAGAnim::ExtendToLength(float length) // GetChannelName ------------------------------ // --------------- -const char * plAGAnim::GetChannelName(int index) +plString plAGAnim::GetChannelName(int index) { hsAssert(index < fApps.size(), "Out of range index for plAGAnim::GetChannelName()"); @@ -213,7 +206,7 @@ const char * plAGAnim::GetChannelName(int index) { return fApps[index]->GetChannel()->GetName(); } else { - return nil; + return plString::Null; } } @@ -224,7 +217,7 @@ void plAGAnim::Read(hsStream *stream, hsResMgr *mgr) plSynchedObject::Read(stream, mgr); // read in the name of the animation itself - fName = stream->ReadSafeString(); + fName = stream->ReadSafeString_TEMP(); fStart = stream->ReadLEScalar(); fEnd = stream->ReadLEScalar(); @@ -279,11 +272,11 @@ void plAGAnim::ClearAnimationRegistry() // AddAnim ---------------------------------------------- // -------- -void plAGAnim::AddAnim(const char * name, plAGAnim *anim) +void plAGAnim::AddAnim(const plString & name, plAGAnim *anim) { // Only register the animation if it's got a "real" name. Unnamed animations // all get the same standard name. - if(strcmp(name, ENTIRE_ANIMATION_NAME) != 0) + if(name.Compare(ENTIRE_ANIMATION_NAME) != 0) { hsAssert(anim, "registering nil anim"); fAllAnims[name] = anim; @@ -292,7 +285,7 @@ void plAGAnim::AddAnim(const char * name, plAGAnim *anim) // FindAnim ----------------------------------- // --------- -plAGAnim * plAGAnim::FindAnim(const char *name) +plAGAnim * plAGAnim::FindAnim(const plString &name) { plAnimMap::iterator i = fAllAnims.find(name); @@ -306,7 +299,7 @@ plAGAnim * plAGAnim::FindAnim(const char *name) // RemoveAnim ------------------------------- // ----------- -hsBool plAGAnim::RemoveAnim(const char *name) +hsBool plAGAnim::RemoveAnim(const plString &name) { plAnimMap::iterator i = fAllAnims.find(name); @@ -328,8 +321,8 @@ void plAGAnim::DumpAnimationRegistry() do { plAGAnim *anim = (*i).second; - const char *name = anim->GetName(); - hsStatusMessageF("GLOBAL ANIMS [%d]: <%s>", j++, name); + plString name = anim->GetName(); + hsStatusMessageF("GLOBAL ANIMS [%d]: <%s>", j++, name.c_str()); } while(++i != fAllAnims.end()); } @@ -342,7 +335,7 @@ hsBool plAGAnim::SharesPinsWith(const plAGAnim *anim) const { for (j = 0; j < anim->fApps.size(); j++) { - if (!strcmp(fApps[i]->GetChannelName(), anim->fApps[j]->GetChannelName()) && + if (!fApps[i]->GetChannelName().Compare(anim->fApps[j]->GetChannelName()) && fApps[i]->CanBlend(anim->fApps[j])) { return true; @@ -367,7 +360,7 @@ plATCAnim::plATCAnim() // ctor -------------------------------------------------------- // ----- -plATCAnim::plATCAnim(const char *name, double start, double end) +plATCAnim::plATCAnim(const plString &name, double start, double end) : plAGAnim(name, start, end), fInitial(-1), fAutoStart(true), @@ -389,11 +382,7 @@ plATCAnim::plATCAnim(const char *name, double start, double end) // ----- plATCAnim::~plATCAnim() { - for (MarkerMap::iterator it = fMarkers.begin(); it != fMarkers.end(); it++) - delete [] (char*)it->first; fMarkers.clear(); - for( LoopMap::iterator it2 = fLoops.begin(); it2 != fLoops.end(); it2++ ) - delete [] (char *)it2->first; fLoops.clear(); fStopPoints.clear(); } @@ -423,7 +412,7 @@ void plATCAnim::Read(hsStream *stream, hsResMgr *mgr) int numMarkers = stream->ReadLE32(); for (i = 0; i < numMarkers; i++) { - char *name = stream->ReadSafeString(); + plString name = stream->ReadSafeString_TEMP(); float time = stream->ReadLEFloat(); fMarkers[name] = time; } @@ -431,7 +420,7 @@ void plATCAnim::Read(hsStream *stream, hsResMgr *mgr) int numLoops = stream->ReadLE32(); for (i = 0; i < numLoops; i++) { - char *name = stream->ReadSafeString(); + plString name = stream->ReadSafeString_TEMP(); float begin = stream->ReadLEScalar(); float end = stream->ReadLEScalar(); fLoops[name] = std::pair(begin,end); @@ -498,15 +487,14 @@ void plATCAnim::CheckLoop() // AddLoop ------------------------------------------------------ // -------- -void plATCAnim::AddLoop(const char *name, float start, float end) +void plATCAnim::AddLoop(const plString &name, float start, float end) { - char *nameCpy = hsStrcpy(name); - fLoops[nameCpy] = std::pair(start, end); + fLoops[name] = std::pair(start, end); } // GetLoop -------------------------------------------------------------- // -------- -bool plATCAnim::GetLoop(const char *name, float &start, float &end) const +bool plATCAnim::GetLoop(const plString &name, float &start, float &end) const { LoopMap::const_iterator it = fLoops.find(name); if (it != fLoops.end()) @@ -549,15 +537,14 @@ uint32_t plATCAnim::GetNumLoops() const // AddMarker ------------------------------------------ // ---------- -void plATCAnim::AddMarker(const char *name, float time) +void plATCAnim::AddMarker(const plString &name, float time) { - char *nameCpy = hsStrcpy(name); - fMarkers[nameCpy] = time; + fMarkers[name] = time; } // GetMarker ------------------------------------- // ---------- -float plATCAnim::GetMarker(const char *name) const +float plATCAnim::GetMarker(const plString &name) const { if (fMarkers.find(name) != fMarkers.end()) return (*fMarkers.find(name)).second; @@ -566,13 +553,14 @@ float plATCAnim::GetMarker(const char *name) const // CopyMarkerNames ------------------------------------- // ---------------- -void plATCAnim::CopyMarkerNames(std::vector &out) +void plATCAnim::CopyMarkerNames(std::vector &out) { MarkerMap::iterator it = fMarkers.begin(); + out.reserve(fMarkers.size()); for (; it != fMarkers.end(); it++) { - out.push_back(hsStrcpy((*it).first)); + out.push_back((*it).first); } } @@ -613,7 +601,7 @@ plEmoteAnim::plEmoteAnim() // ctor ------------------------------------------------------------------------------ // ----- -plEmoteAnim::plEmoteAnim(const char *animName, double begin, double end, float fadeIn, +plEmoteAnim::plEmoteAnim(const plString &animName, double begin, double end, float fadeIn, float fadeOut, BodyUsage bodyUsage) : plATCAnim(animName, begin, end), fFadeIn(fadeIn), @@ -682,7 +670,7 @@ plAgeGlobalAnim::plAgeGlobalAnim() // ctor -------------------------------------------------------------------- // ----- -plAgeGlobalAnim::plAgeGlobalAnim(const char *name, double start, double end) +plAgeGlobalAnim::plAgeGlobalAnim(const plString &name, double start, double end) : plAGAnim(name, start, end), fGlobalVarName(nil) { @@ -729,7 +717,7 @@ void plAgeGlobalAnim::Write(hsStream *stream, hsResMgr *mgr) // GetStartToEndTransform ----------------------------------------------- bool GetStartToEndTransform(const plAGAnim *anim, hsMatrix44 *startToEnd, - hsMatrix44 *endToStart, const char *channelName) + hsMatrix44 *endToStart, const plString &channelName) { double start = 0.0f; // assumed double end = anim->GetEnd(); @@ -740,7 +728,7 @@ bool GetStartToEndTransform(const plAGAnim *anim, hsMatrix44 *startToEnd, // GetRelativeTransform --------------------------------------------------- bool GetRelativeTransform(const plAGAnim *anim, double timeA, double timeB, - hsMatrix44 *a2b, hsMatrix44 *b2a, const char *channelName) + hsMatrix44 *a2b, hsMatrix44 *b2a, const plString &channelName) { bool result = false; plAGChannel *maybeChannel = anim->GetChannel(channelName); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGAnim.h b/Sources/Plasma/PubUtilLib/plAvatar/plAGAnim.h index ef75eced..49eca8aa 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGAnim.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGAnim.h @@ -92,7 +92,7 @@ public: plAGAnim(); /** Construct with name, start time, and end time (within the max note track) */ - plAGAnim(const char *name, double begin, double end); + plAGAnim(const plString &name, double begin, double end); /** Destruct, freeing the underlying animation data. */ virtual ~plAGAnim(); @@ -112,12 +112,12 @@ public: /** Get the name of the channel having the given index. Useful for talking to an an animation before it is applied and finding out what channels it's going to affect. */ - virtual const char * GetChannelName(int index); + virtual plString GetChannelName(int index); /** Get channel by name. This corresponds to the name of the scene object this channel will be attached to when the animation is applied. This function is fairly slow and shouldn't be used often. */ - plAGChannel * GetChannel(const char *name) const; + plAGChannel * GetChannel(const plString &name) const; /** Return the number of applicators held by this animation. An applicator is used to attach a channel to a sceneobject. */ @@ -141,7 +141,7 @@ public: by the avatar or from script, but most of the functions which take an animation name (such as AttachAnimation on the plAGMasterMod) will also take an pointer to a plAGAnim. */ - virtual const char * GetName() const { return fName; } + virtual plString GetName() const { return fName; } /** Return the length of the animation; end - start. */ virtual float GetLength() const { return fEnd - fStart; } @@ -176,12 +176,12 @@ public: /** Add the animation by name to a global static registry. This functionality will possibly be added to the resource manager. */ - static void AddAnim(const char * name, plAGAnim *anim); + static void AddAnim(const plString & name, plAGAnim *anim); /** See if there is an animation with the given name in the global animation registry. */ - static plAGAnim *FindAnim(const char *name); + static plAGAnim *FindAnim(const plString &name); /** Remove the given animation from the registry. */ - static hsBool RemoveAnim(const char *name); + static hsBool RemoveAnim(const plString &name); /** Clear the animation cache. Used when resetting the client to a vanilla state, as when clearing the scene while exporting. */ @@ -199,17 +199,17 @@ protected: ApplicatorVec fApps; /// our animation channels float fBlend; /// requested blend factor - float fStart; /// the start time of the beginning of the animation (usually 0) - float fEnd; /// the end time of the animation + float fStart; /// the start time of the beginning of the animation (usually 0) + float fEnd; /// the end time of the animation - char *fName; /// the name of our animation + plString fName; /// the name of our animation // ??? Can this be moved to the resource manager? If it can manage an efficient // string-based namespace per class, we could get rid of this. - typedef std::map plAnimMap; // + typedef std::map plAnimMap; // static plAnimMap fAllAnims; /// map of animation names to animations - typedef std::map plEmoteMap; + typedef std::map plEmoteMap; static plEmoteMap fAllEmotes; }; @@ -230,7 +230,7 @@ public: plATCAnim(); /** Construct with name, start time, and end time (within the max note track) Default is to start automatically, not loop, with no ease curves. */ - plATCAnim(const char *name, double begin, double end); + plATCAnim(const plString &name, double begin, double end); /** Destruct, freeing the underlying animation data. */ virtual ~plATCAnim(); @@ -305,11 +305,11 @@ public: /** Animations can have multiple defined loop segments; these are selected using animation control messages. Each loop segment is named using markers in the notetrack. */ - void AddLoop(const char *name, float start, float end); + void AddLoop(const plString &name, float start, float end); /** Get the loop having the given name. \param start will return the start time of the loop. \param end will hold the end time of the loop */ - bool GetLoop(const char *name, float &start, float &end) const; + bool GetLoop(const plString &name, float &start, float &end) const; /** Lets you get a loop by index instead of name. */ bool GetLoop(uint32_t num, float &start, float &end) const; /** Returns the number of loops defined on this anim. */ @@ -318,10 +318,10 @@ public: /** Add a marker to the animation. Markers can be used for callbacks or for goto comands. A marker is a simple name/time tuple. */ - void AddMarker(const char *name, float time); + void AddMarker(const plString &name, float time); /** Returns the time value of the marker named by name. */ - float GetMarker(const char *name) const; - void CopyMarkerNames(std::vector &out); + float GetMarker(const plString &name) const; + void CopyMarkerNames(std::vector &out); /** Add a stop point to the animation. A stop point is a "detent" for playback - if the animation is stopping near a stop point and fading out, the stop point will @@ -363,10 +363,10 @@ protected: float fEaseOutMax; /// maximum (initial) value of our ease-out // a map from segment names to times - typedef std::map MarkerMap; + typedef std::map MarkerMap; MarkerMap fMarkers; - typedef std::map, stringSorter> LoopMap; + typedef std::map > LoopMap; LoopMap fLoops; typedef std::vector ScalarMap; @@ -384,7 +384,7 @@ class plEmoteAnim : public plATCAnim public: plEmoteAnim(); - plEmoteAnim(const char *animName, double begin, double end, float fadeIn, float fadeOut, BodyUsage bodyUsage); + plEmoteAnim(const plString &animName, double begin, double end, float fadeIn, float fadeOut, BodyUsage bodyUsage); BodyUsage GetBodyUsage() const; float GetFadeIn() const; @@ -417,7 +417,7 @@ public: plAgeGlobalAnim(); /** Construct with name, start time, and end time (within the max note track) */ - plAgeGlobalAnim(const char *name, double begin, double end); + plAgeGlobalAnim(const plString &name, double begin, double end); /** Destruct, freeing the underlying animation data. */ virtual ~plAgeGlobalAnim(); @@ -438,8 +438,8 @@ protected: }; // USEFUL HELPER FUNCTIONS -bool GetStartToEndTransform(const plAGAnim *anim, hsMatrix44 *startToEnd, hsMatrix44 *endToStart, const char *channelName); -bool GetRelativeTransform(const plAGAnim *anim, double timeA, double timeB, hsMatrix44 *a2b, hsMatrix44 *b2a, const char *channelName); +bool GetStartToEndTransform(const plAGAnim *anim, hsMatrix44 *startToEnd, hsMatrix44 *endToStart, const plString &channelName); +bool GetRelativeTransform(const plAGAnim *anim, double timeA, double timeB, hsMatrix44 *a2b, hsMatrix44 *b2a, const plString &channelName); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.cpp index 2ebd587e..a622cfab 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.cpp @@ -123,7 +123,7 @@ plAGAnimInstance::plAGAnimInstance(plAGAnim * anim, plAGMasterMod * master, fCleanupChannels.push_back(timeChan); #ifdef SHOW_AG_CHANGES - hsStatusMessageF("\nAbout to Attach anim <%s>", GetName()); + hsStatusMessageF("\nAbout to Attach anim <%s>", GetName().c_str()); fMaster->DumpAniGraph("bone_pelvis", false, hsTimer::GetSysSeconds()); #endif @@ -131,7 +131,7 @@ plAGAnimInstance::plAGAnimInstance(plAGAnim * anim, plAGMasterMod * master, { plAGApplicator * app = fAnimation->GetApplicator(i); plAGChannel * inChannel = app->GetChannel(); - const char * channelName = app->GetChannelName(); + plString channelName = app->GetChannelName(); plAGModifier * channelMod = master->GetChannelMod(channelName); if(channelMod) { @@ -206,7 +206,7 @@ void plAGAnimInstance::SearchForGlobals() } } -void plAGAnimInstance::IRegisterDetach(const char *channelName, plAGChannel *channel) +void plAGAnimInstance::IRegisterDetach(const plString &channelName, plAGChannel *channel) { plDetachMap::value_type newPair(channelName, channel); fManualDetachChannels.insert(newPair); @@ -243,14 +243,14 @@ void plAGAnimInstance::Detach() void plAGAnimInstance::DetachChannels() { #ifdef SHOW_AG_CHANGES - hsStatusMessageF("\nAbout to DETACH anim <%s>", GetName()); + hsStatusMessageF("\nAbout to DETACH anim <%s>", GetName().c_str()); fMaster->DumpAniGraph("bone_pelvis", false, hsTimer::GetSysSeconds()); #endif plDetachMap::iterator i = fManualDetachChannels.begin(); while(i != fManualDetachChannels.end()) { - const char *channelName = (*i).first; + plString channelName = (*i).first; plAGModifier *channelMod = fMaster->GetChannelMod(channelName, true); if(channelMod) @@ -274,7 +274,7 @@ void plAGAnimInstance::DetachChannels() fCleanupChannels.clear(); #ifdef SHOW_AG_CHANGES - hsStatusMessageF("\nFinished DETACHING anim <%s>", GetName()); + hsStatusMessageF("\nFinished DETACHING anim <%s>", GetName().c_str()); fMaster->DumpAniGraph("bone_pelvis", false, hsTimer::GetSysSeconds()); #endif } @@ -323,12 +323,12 @@ float plAGAnimInstance::GetAmplitude() // GetName ----------------------------- // -------- -const char * plAGAnimInstance::GetName() +plString plAGAnimInstance::GetName() { if(fAnimation) return fAnimation->GetName(); else - return nil; + return plString::Null; } // SetLoop ---------------------------------- @@ -409,7 +409,7 @@ void plAGAnimInstance::AttachCallbacks(plOneShotCallbacks *callbacks) eventMsg->fRepeats = 0; eventMsg->fUser = cb.fUser; - if (cb.fMarker) + if (!cb.fMarker.IsNull()) { float marker = anim->GetMarker(cb.fMarker); hsAssert(marker != -1, "Bad marker name"); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.h b/Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.h index 7c2ffd2d..b6f453f5 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.h @@ -192,7 +192,7 @@ public: hsBool IsAtEnd(); /** Get the name of the underlying animation. */ - const char * GetName(); + plString GetName(); /** Remove all channels from the master mode and remove us from our master modifier. @@ -224,14 +224,14 @@ protected: /** Set up bookkeeping for a fade. */ void ISetupFade(float goal, float rate, bool detach, uint8_t type); - void IRegisterDetach(const char *channelName, plAGChannel *channel); + void IRegisterDetach(const plString &channelName, plAGChannel *channel); const plAGAnim * fAnimation; plAGMasterMod * fMaster; - std::map fChannels; + std::map fChannels; - typedef std::multimap plDetachMap; + typedef std::multimap plDetachMap; plDetachMap fManualDetachChannels; std::vector fCleanupChannels; diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGApplicator.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAGApplicator.cpp index 01e4eb0c..f10c94bd 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGApplicator.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGApplicator.cpp @@ -48,24 +48,21 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com // ----- plAGApplicator::plAGApplicator() : fChannel(nil), - fChannelName(nil), fEnabled(true) { }; // ctor ------------------------------- // ----- -plAGApplicator::plAGApplicator(const char *channelName) +plAGApplicator::plAGApplicator(const plString &channelName) : fChannel(nil), - fEnabled(true) + fEnabled(true), + fChannelName(channelName) { - fChannelName = hsStrcpy(channelName); }; plAGApplicator::~plAGApplicator() { - if(fChannelName) - delete[] fChannelName; } void plAGApplicator::Apply(const plAGModifier *mod, double time, hsBool force) @@ -74,14 +71,14 @@ void plAGApplicator::Apply(const plAGModifier *mod, double time, hsBool force) IApply(mod, time); } -void plAGApplicator::SetChannelName(const char *name) +void plAGApplicator::SetChannelName(const plString &name) { - if(name) - fChannelName = hsStrcpy(name); + if(!name.IsNull()) + fChannelName = name; }; -const char * plAGApplicator::GetChannelName() +plString plAGApplicator::GetChannelName() { return fChannelName; }; @@ -141,7 +138,7 @@ void plAGApplicator::Read(hsStream *stream, hsResMgr *mgr) fEnabled = stream->ReadBool(); fChannel = nil; // Whatever is reading this applicator in should know what channel to assign it - fChannelName = stream->ReadSafeString(); + fChannelName = stream->ReadSafeString_TEMP(); } // IGETxI diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGApplicator.h b/Sources/Plasma/PubUtilLib/plAvatar/plAGApplicator.h index cd346c5d..5eeebc4a 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGApplicator.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGApplicator.h @@ -62,6 +62,7 @@ class plAGModifier; ///////////////////////////////////////////////////////////////////////////////////////// #include "pnFactory/plCreatable.h" #include "plAvDefs.h" +#include "plString.h" ///////////////////////////////////////////////////////////////////////////////////////// // @@ -88,7 +89,7 @@ public: // -- methods -- /** Base constructor. */ plAGApplicator(); - plAGApplicator(const char *channelName); + plAGApplicator(const plString &channelName); virtual ~plAGApplicator(); /** Return our single input channel. Applicators only ever @@ -100,8 +101,12 @@ public: /** Set our input channel. Does not free the previous input channel. */ void SetChannel(plAGChannel *channel) { fChannel = channel; } - void SetChannelName(const char *name); - const char * GetChannelName(); + void SetChannelName(const plString &name); + plString GetChannelName(); + + // TEMP plString REVISIT + // Because I'm TOO LAZY to keep converting all these calls to SetChannelName + void SetChannelName(const char *name) { SetChannelName(_TEMP_CONVERT_FROM_LITERAL(name)); } /** Optionally suppress the action of this applicator. The applicator can still be forced to apply using the force @@ -167,7 +172,7 @@ protected: // -- members -- plAGChannel *fChannel; hsBool fEnabled; - char *fChannelName; + plString fChannelName; }; -#endif \ No newline at end of file +#endif diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGChannel.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAGChannel.cpp index ef369a75..9aa7dbda 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGChannel.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGChannel.cpp @@ -62,8 +62,6 @@ plAGChannel::plAGChannel() #ifdef TRACK_AG_ALLOCS fName = gGlobalAnimName; RegisterAGAlloc(this, gGlobalChannelName, gGlobalAnimName, this->ClassIndex()); -#else // TRACK_AG_ALLOCS - fName = nil; #endif // TRACK_AG_ALLOCS } @@ -121,7 +119,7 @@ void plAGChannel::Read(hsStream *stream, hsResMgr *mgr) { plCreatable::Read(stream, mgr); - fName = stream->ReadSafeString(); + fName = stream->ReadSafeString_TEMP(); } //////////////////////////////////////////////////////////////////////////////////// diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGChannel.h b/Sources/Plasma/PubUtilLib/plAvatar/plAGChannel.h index f05752bb..3afaaac8 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGChannel.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGChannel.h @@ -101,6 +101,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com ///////////////////////////////////////////////////////////////////////////////////////// #include "pnFactory/plCreatable.h" +#include "plString.h" ///////////////////////////////////////////////////////////////////////////////////////// // @@ -177,8 +178,8 @@ public: // \{ /** The name of the channel is used to dynamically attach to sub-parts of an object. */ - virtual const char * GetName() { return fName; }; - virtual void SetName(char * name) { fName = name; }; + virtual plString GetName() { return fName; }; + virtual void SetName(const plString & name) { fName = name; }; // \} // PLASMA PROTOCOL @@ -191,7 +192,7 @@ public: virtual void Read(hsStream *s, hsResMgr *mgr); protected: - const char * fName; + plString fName; }; diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp index 8101dfac..f97c87c4 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp @@ -301,7 +301,7 @@ void plAGMasterMod::DumpAniGraph(const char *justThisChannel, bool optimized, do for(plChannelModMap::iterator j = fChannelMods.begin(); j != end; j++) { plAGModifier *mod = (*j).second; - if(!justThisChannel || stricmp(justThisChannel, mod->GetChannelName()) == 0) + if(!justThisChannel || mod->GetChannelName().Compare(justThisChannel, plString::kCaseInsensitive) == 0) { plAGApplicator *app = mod->GetApplicator(kAGPinTransform); @@ -325,10 +325,10 @@ void plAGMasterMod::DumpAniGraph(const char *justThisChannel, bool optimized, do // GETCHANNELMOD(name) // Get the modifier that controls the channel with the given name -plAGModifier * plAGMasterMod::GetChannelMod(const char * name, hsBool dontCache ) const +plAGModifier * plAGMasterMod::GetChannelMod(const plString & name, hsBool dontCache ) const { plAGModifier * result = nil; - std::map::const_iterator i = fChannelMods.find(name); + std::map::const_iterator i = fChannelMods.find(name); if (i != fChannelMods.end()) { result = (*i).second; @@ -356,7 +356,7 @@ plAGModifier * plAGMasterMod::ICacheChannelMod(plAGModifier *mod) const // IFINDAGMOD (sceneObject) // See if there's an ag modifier on this sceneobject. // Doesn't check for multiples; just returns the first one. -plAGModifier * plAGMasterMod::IFindChannelMod(const plSceneObject *SO, const char *name) const +plAGModifier * plAGMasterMod::IFindChannelMod(const plSceneObject *SO, const plString &name) const { const plCoordinateInterface * CI = SO->GetCoordinateInterface(); @@ -365,8 +365,8 @@ plAGModifier * plAGMasterMod::IFindChannelMod(const plSceneObject *SO, const cha if(mod) { - const char *modName = mod->GetChannelName(); - if(stricmp(name, modName) == 0) + plString modName = mod->GetChannelName(); + if(modName.Compare(name, plString::kCaseInsensitive) == 0) return mod; } @@ -421,7 +421,7 @@ plAGAnimInstance * plAGMasterMod::AttachAnimationBlended(plAGAnim *anim, } // ATTACHANIMATIONBLENDED(name, blend) -plAGAnimInstance * plAGMasterMod::AttachAnimationBlended(const char *name, float blendFactor /* = 0 */, uint16_t blendPriority, hsBool cache /* = false */) +plAGAnimInstance * plAGMasterMod::AttachAnimationBlended(const plString &name, float blendFactor /* = 0 */, uint16_t blendPriority, hsBool cache /* = false */) { plAGAnimInstance *instance = nil; plAGAnim *anim = plAGAnim::FindAnim(name); @@ -433,7 +433,7 @@ plAGAnimInstance * plAGMasterMod::AttachAnimationBlended(const char *name, float return instance; } -void plAGMasterMod::PlaySimpleAnim(const char *name) +void plAGMasterMod::PlaySimpleAnim(const plString &name) { plATCAnim *anim = plATCAnim::ConvertNoRef(plAGAnim::FindAnim(name)); plAGAnimInstance *instance = nil; @@ -460,18 +460,18 @@ void plAGMasterMod::PlaySimpleAnim(const char *name) // FINDANIMINSTANCE // Look for an animation instance of the given name on the modifier. // If we need this to be fast, should make it a map rather than a vector -plAGAnimInstance * plAGMasterMod::FindAnimInstance(const char *name) +plAGAnimInstance * plAGMasterMod::FindAnimInstance(const plString &name) { plAGAnimInstance *result = nil; - if (name) + if (!name.IsNull()) { for (int i = 0; i < fAnimInstances.size(); i++) { plAGAnimInstance *act = fAnimInstances[i]; - const char *eachName = act->GetName(); + plString eachName = act->GetName(); - if( stricmp(eachName, name) == 0) + if( eachName.Compare(name, plString::kCaseInsensitive) == 0) { result = act; break; @@ -482,7 +482,7 @@ plAGAnimInstance * plAGMasterMod::FindAnimInstance(const char *name) } // FINDORATTACHINSTANCE -plAGAnimInstance * plAGMasterMod::FindOrAttachInstance(const char *name, float blendFactor) +plAGAnimInstance * plAGMasterMod::FindOrAttachInstance(const plString &name, float blendFactor) { plAGAnimInstance *result = FindAnimInstance(name); if(result) @@ -587,7 +587,7 @@ void plAGMasterMod::DetachAnimation(plAGAnimInstance *anim) } // DETACHANIMATION(name) -void plAGMasterMod::DetachAnimation(const char *name) +void plAGMasterMod::DetachAnimation(const plString &name) { plAGAnimInstance *anim = FindAnimInstance(name); if(anim) { @@ -603,10 +603,10 @@ void plAGMasterMod::DumpCurrentAnims(const char *header) for(int i = nAnims - 1; i >= 0; i--) { plAGAnimInstance *inst = fAnimInstances[i]; - const char *name = inst->GetName(); + plString name = inst->GetName(); float blend = inst->GetBlend(); - hsStatusMessageF("%d: %s with blend of %f\n", i, name, blend); + hsStatusMessageF("%d: %s with blend of %f\n", i, name.c_str(), blend); } } @@ -628,10 +628,10 @@ hsBool plAGMasterMod::MsgReceive(plMessage* msg) if (cmdMsg = plAnimCmdMsg::ConvertNoRef(msg)) { - const char *targetName = cmdMsg->GetAnimName(); + plString targetName = cmdMsg->GetAnimName(); - if (!targetName) - targetName = ENTIRE_ANIMATION_NAME; + if (targetName.IsNull()) + targetName = _TEMP_CONVERT_FROM_LITERAL(ENTIRE_ANIMATION_NAME); plAGAnimInstance *inst = FindAnimInstance(targetName); if (inst != nil) diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.h b/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.h index 2ee35d87..35fdb834 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.h @@ -98,7 +98,7 @@ public: virtual ~plAGMasterMod(); /** Find an individual plAGModifier of the given name under our control. */ - plAGModifier * GetChannelMod(const char * name, hsBool dontCache = false) const; + plAGModifier * GetChannelMod(const plString & name, hsBool dontCache = false) const; /** \name Managing Animations */ // \{ @@ -112,13 +112,13 @@ public: /** Look up the given animation by name and attach it with the given blend factor. */ - plAGAnimInstance *AttachAnimationBlended(const char *name, float blendFactor = 0, + plAGAnimInstance *AttachAnimationBlended(const plString &name, float blendFactor = 0, uint16_t blendPriority = kAGMedBlendPriority, hsBool cache = false); /** Play a simple anim (one that doesn't affect root) once and auto detach. Intended for Zandi's facial animations that run seperate from the behaviors. */ - void PlaySimpleAnim(const char *name); + void PlaySimpleAnim(const plString &name); /** Detach the given animation instance. Does nothing if the instance is not managed by this master mod. */ @@ -128,7 +128,7 @@ public: /** Detach the given animation by name. Searches for any instances derived from animations with the given name and removes them. */ - void DetachAnimation(const char *name); + void DetachAnimation(const plString &name); // \} /** Print the current animation stack to the console. @@ -139,7 +139,7 @@ public: /** Find and return any animation instances with the given name on this master modifer. */ - plAGAnimInstance *FindAnimInstance(const char *name); + plAGAnimInstance *FindAnimInstance(const plString &name); /** Return the Ith animation instance, based on blend order. Of dubious utility, but, y'know. */ @@ -152,7 +152,7 @@ public: attached, it could be anywhere, including buried under a bunch of other animations. If it's important that it be on top of the stack, you may need to detach it first. */ - plAGAnimInstance *FindOrAttachInstance(const char *name, float blendFactor); + plAGAnimInstance *FindOrAttachInstance(const plString &name, float blendFactor); /** Return the number of animations available. */ int GetNumAnimations(); @@ -218,7 +218,7 @@ public: protected: // -- methods -- plAGModifier * ICacheChannelMod(plAGModifier *mod) const; - plAGModifier * IFindChannelMod(const plSceneObject *obj, const char *name) const; + plAGModifier * IFindChannelMod(const plSceneObject *obj, const plString &name) const; virtual hsBool IEval(double secs, float del, uint32_t dirty); @@ -231,7 +231,7 @@ protected: plSceneObject* fTarget; // a map from channel names to ag modifiers within our domain - typedef std::map plChannelModMap; + typedef std::map plChannelModMap; plChannelModMap fChannelMods; // instances which are currently attached to this master diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGModifier.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAGModifier.cpp index e72e96e2..d5bfacfb 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGModifier.cpp @@ -64,28 +64,21 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com plAGModifier::plAGModifier() : plSingleModifier() { - fChannelName = nil; fAutoApply = true; fEnabled = true; } // CTOR(name) -plAGModifier::plAGModifier(const char *name, hsBool autoApply) +plAGModifier::plAGModifier(const plString &name, hsBool autoApply) : plSingleModifier(), fAutoApply(autoApply) { - fChannelName = hsStrcpy(name); + fChannelName = name; fEnabled = true; } // DTOR plAGModifier::~plAGModifier() { - if(fChannelName) - { - delete[] fChannelName; - fChannelName = nil; - } - int i; for (i = 0; i < fApps.size(); i++) { @@ -94,7 +87,7 @@ plAGModifier::~plAGModifier() } // GETCHANNELNAME -const char * plAGModifier::GetChannelName() const +plString plAGModifier::GetChannelName() const { return fChannelName; } @@ -106,9 +99,9 @@ void plAGModifier::Enable(hsBool val) } // SETCHANNELNAME -void plAGModifier::SetChannelName(char * name) +void plAGModifier::SetChannelName(const plString & name) { - fChannelName = hsStrcpy(name); + fChannelName = name; } // IAPPLYCHANNELS (time) @@ -276,7 +269,7 @@ void plAGModifier::Read(hsStream *stream, hsResMgr *mgr) plSingleModifier::Read(stream, mgr); // read in the name of the modifier - fChannelName = stream->ReadSafeString(); + fChannelName = stream->ReadSafeString_TEMP(); } // WRITE diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGModifier.h b/Sources/Plasma/PubUtilLib/plAvatar/plAGModifier.h index 703ac05b..d08a3711 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGModifier.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGModifier.h @@ -89,19 +89,19 @@ public: incoming channels with this modifier. You may also supply an autoApply parameter, which indicates whether this modifier should apply itself every frame, or only when explicitly asked to. */ - plAGModifier(const char *name, hsBool autoApply = true); + plAGModifier(const plString &name, hsBool autoApply = true); /** It's a destructor. Destroys the name passed into the constructor, and a bunch of other stuff you don't need to know anything about. */ virtual ~plAGModifier(); /** Get the name of the channel controlled by this modifier. */ - const char * GetChannelName() const; + plString GetChannelName() const; /** Change the channel name of the modifier. Will delete the previous name. Will NOT remove any channels that are already attached, so you could wind up with a modifier named "Fred" and a bunch of channels attached to it that were intended for "Lamont." */ - void SetChannelName(char * name); + void SetChannelName(const plString & name); /** Attach a new applicator to our modifier. Will arbitrate with existing modifiers if necessary, based on pin type. May destruct existing applicators. */ @@ -139,9 +139,9 @@ protected: typedef std::vector plAppTable; plAppTable fApps; // the applicators (with respective channels) that we're applying to our scene object - char *fChannelName; // name used for matching animation channels to this modifier - hsBool fAutoApply; // evaluate animation automatically during IEval call - hsBool fEnabled; // if not enabled, we don't eval any of our anims + plString fChannelName; // name used for matching animation channels to this modifier + hsBool fAutoApply; // evaluate animation automatically during IEval call + hsBool fEnabled; // if not enabled, we don't eval any of our anims // APPLYING THE ANIMATION virtual hsBool IEval(double secs, float del, uint32_t dirty); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp index d4408413..37a8dc11 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp @@ -277,7 +277,7 @@ plAGAnimInstance * plAnimStage::Attach(plArmatureMod *armature, plArmatureBrain if(fAnimInstance) { fAnimInstance->Stop(); // we'll be setting the time directly. - fAnimatedHandle = (fAnimInstance->GetAnimation()->GetChannel("Handle") != nil); + fAnimatedHandle = (fAnimInstance->GetAnimation()->GetChannel(_TEMP_CONVERT_FROM_LITERAL("Handle")) != nil); fAttached = true; // this is too early to send the enter notify. we're attached, but we may not // have faded in yet. diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp index 5b480fd8..266b3de8 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp @@ -660,11 +660,11 @@ void plArmatureMod::IInitDefaults() fPhysHeight = 0.f; fPhysWidth = 0.f; fUpdateMsg = nil; - fRootName = nil; + fRootName = plString::Null; fDontPanicLink = false; fBodyAgeName = "GlobalAvatars"; fBodyFootstepSoundPage = "Audio"; - fAnimationPrefix = "Male"; + fAnimationPrefix = _TEMP_CONVERT_FROM_LITERAL("Male"); fUserStr = ""; } @@ -677,7 +677,6 @@ plArmatureMod::plArmatureMod() : plArmatureModBase() plArmatureMod::~plArmatureMod() { delete fBoneMap; - delete [] fRootName; if (fUpdateMsg) fUpdateMsg->UnRef(); @@ -746,7 +745,7 @@ void plArmatureMod::GetPositionAndRotationSim(hsPoint3* position, hsQuat* rotati } } -const plSceneObject *plArmatureMod::FindBone(const char * name) const +const plSceneObject *plArmatureMod::FindBone(const plString & name) const { plSceneObject *result = nil; @@ -1034,14 +1033,12 @@ void plArmatureMod::PanicLink(hsBool playLinkOutAnim /* = true */) { plAvOneShotLinkTask *task = new plAvOneShotLinkTask; - char *animName = MakeAnimationName("FallingLinkOut"); + plString animName = MakeAnimationName("FallingLinkOut"); task->SetAnimName(animName); - task->SetMarkerName("touch"); + task->SetMarkerName(_TEMP_CONVERT_FROM_LITERAL("touch")); plAvTaskMsg *taskMsg = new plAvTaskMsg(GetKey(), GetKey(), task); taskMsg->Send(); - - delete [] animName; } else { @@ -1059,10 +1056,9 @@ void plArmatureMod::PersonalLink() else { plAvOneShotLinkTask *task = new plAvOneShotLinkTask; - char *animName = MakeAnimationName("PersonalLink"); + plString animName = MakeAnimationName("PersonalLink"); task->SetAnimName(animName); - task->SetMarkerName("touch"); - delete [] animName; + task->SetMarkerName(_TEMP_CONVERT_FROM_LITERAL("touch")); plAvTaskMsg *taskMsg = new plAvTaskMsg(GetKey(), GetKey(), task); taskMsg->SetBCastFlag(plMessage::kNetPropagate); @@ -1758,7 +1754,7 @@ void plArmatureMod::Read(hsStream * stream, hsResMgr *mgr) fMeshKeys.push_back(mgr->ReadKey(stream)); // read the root name string - fRootName = stream->ReadSafeString(); + fRootName = stream->ReadSafeString_TEMP(); // read in the brains int nBrains = stream->ReadLE32(); @@ -1825,11 +1821,9 @@ void plArmatureMod::Read(hsStream * stream, hsResMgr *mgr) fPhysHeight = stream->ReadLEFloat(); fPhysWidth = stream->ReadLEFloat(); - char* temp = stream->ReadSafeString(); - fAnimationPrefix = temp; - delete [] temp; + fAnimationPrefix = stream->ReadSafeString_TEMP(); - temp = stream->ReadSafeString(); + char *temp = stream->ReadSafeString(); fBodyAgeName = temp; delete [] temp; @@ -1906,7 +1900,7 @@ void plArmatureMod::ICustomizeApplicator() { plArmatureModBase::ICustomizeApplicator(); - const plAGModifier *agMod = GetChannelMod("Bone_Root", true); + const plAGModifier *agMod = GetChannelMod(_TEMP_CONVERT_FROM_LITERAL("Bone_Root"), true); if (agMod) { // are there any applicators that manipulate the transform? @@ -2387,35 +2381,31 @@ bool plArmatureMod::FindMatchingGenericBrain(const char *names[], int count) return false; } -char *plArmatureMod::MakeAnimationName(const char *baseName) const +plString plArmatureMod::MakeAnimationName(const char *baseName) const { - std::string temp = fAnimationPrefix + baseName; - char *result = hsStrcpy(temp.c_str()); // why they want a new string I'll never know... but hey, too late to change it now - return result; + return fAnimationPrefix + _TEMP_CONVERT_FROM_LITERAL(baseName); } -char *plArmatureMod::GetRootName() +plString plArmatureMod::GetRootName() { return fRootName; } -void plArmatureMod::SetRootName(const char *name) +void plArmatureMod::SetRootName(const plString &name) { - delete [] fRootName; - fRootName = hsStrcpy(name); + fRootName = name; } plAGAnim *plArmatureMod::FindCustomAnim(const char *baseName) const { - char *customName = MakeAnimationName(baseName); + plString customName = MakeAnimationName(baseName); plAGAnim *result = plAGAnim::FindAnim(customName); - delete[] customName; return result; } void plArmatureMod::ISetupMarkerCallbacks(plATCAnim *anim, plAnimTimeConvert *atc) { - std::vector markers; + std::vector markers; anim->CopyMarkerNames(markers); int i; @@ -2424,12 +2414,12 @@ void plArmatureMod::ISetupMarkerCallbacks(plATCAnim *anim, plAnimTimeConvert *at float time = -1; hsBool isLeft = false; - if (strstr(markers[i], "SndLeftFootDown") == markers[i]) + if (markers[i].Find("SndLeftFootDown") == 0) { isLeft = true; time = anim->GetMarker(markers[i]); } - if (strstr(markers[i], "SndRightFootDown") == markers[i]) + if (markers[i].Find("SndRightFootDown") == 0) time = anim->GetMarker(markers[i]); if (time >= 0) @@ -2461,40 +2451,38 @@ void plArmatureMod::ISetupMarkerCallbacks(plATCAnim *anim, plAnimTimeConvert *at hsRefCnt_SafeUnRef(foot); hsRefCnt_SafeUnRef(iMsg); } - - delete [] markers[i]; // done with this string, nuke it } } -const char *plArmatureMod::GetAnimRootName(const char *name) +plString plArmatureMod::GetAnimRootName(const plString &name) { - return name + fAnimationPrefix.length(); + return name.Substr(fAnimationPrefix.GetSize()); } -int8_t plArmatureMod::AnimNameToIndex(const char *name) +int8_t plArmatureMod::AnimNameToIndex(const plString &name) { - const char *rootName = GetAnimRootName(name); + plString rootName = GetAnimRootName(name); int8_t result = -1; - if (!strcmp(rootName, "Walk") || !strcmp(rootName, "WalkBack") || - !strcmp(rootName, "LadderDown") || !strcmp(rootName, "LadderDownOn") || - !strcmp(rootName, "LadderDownOff") || !strcmp(rootName, "LadderUp") || - !strcmp(rootName, "LadderUpOn") || !strcmp(rootName, "LadderUpOff") || - !strcmp(rootName, "SwimSlow") || !strcmp(rootName, "SwimBackward") || - !strcmp(rootName, "BallPushWalk")) + if (!rootName.Compare("Walk") || !rootName.Compare("WalkBack") || + !rootName.Compare("LadderDown") || !rootName.Compare("LadderDownOn") || + !rootName.Compare("LadderDownOff") || !rootName.Compare("LadderUp") || + !rootName.Compare("LadderUpOn") || !rootName.Compare("LadderUpOff") || + !rootName.Compare("SwimSlow") || !rootName.Compare("SwimBackward") || + !rootName.Compare("BallPushWalk")) result = kWalk; - else if (!strcmp(rootName, "Run") || !strcmp(rootName, "SwimFast")) + else if (!rootName.Compare("Run") || !rootName.Compare("SwimFast")) result = kRun; - else if (!strcmp(rootName, "TurnLeft") || !strcmp(rootName, "TurnRight") || - !strcmp(rootName, "StepLeft") || !strcmp(rootName, "StepRight") || - !strcmp(rootName, "SideSwimLeft") || !strcmp(rootName, "SideSwimRight") || - !strcmp(rootName, "TreadWaterTurnLeft") || !strcmp(rootName, "TreadWaterTurnRight")) + else if (!rootName.Compare("TurnLeft") || !rootName.Compare("TurnRight") || + !rootName.Compare("StepLeft") || !rootName.Compare("StepRight") || + !rootName.Compare("SideSwimLeft") || !rootName.Compare("SideSwimRight") || + !rootName.Compare("TreadWaterTurnLeft") || !rootName.Compare("TreadWaterTurnRight")) result = kTurn; - else if (!strcmp(rootName, "GroundImpact") || !strcmp(rootName, "RunningImpact")) + else if (!rootName.Compare("GroundImpact") || !rootName.Compare("RunningImpact")) result = kImpact; - else if (strstr(rootName, "Run")) // Critters + else if (rootName.Find("Run") >= 0) // Critters result = kRun; - else if (strstr(rootName, "Idle")) // Critters + else if (rootName.Find("Idle") >= 0) // Critters result = kWalk; return result; @@ -2590,10 +2578,10 @@ plArmatureLODMod::plArmatureLODMod() } // CTOR (physical, name) -plArmatureLODMod::plArmatureLODMod(const char* root_name) +plArmatureLODMod::plArmatureLODMod(const plString& root_name) : plArmatureMod() { - fRootName = hsStrcpy(root_name); + fRootName = root_name; } plArmatureLODMod::~plArmatureLODMod() diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h index c89fa1df..a5e445d9 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h @@ -221,7 +221,7 @@ public: hsBool IsLocalAvatar(); hsBool IsLocalAI(); - virtual const plSceneObject *FindBone(const char * name) const; + virtual const plSceneObject *FindBone(const plString & name) const; virtual const plSceneObject *FindBone(uint32_t id) const; // use an id from an appropriate taxonomy, such as plAvBrainHuman::BoneID virtual void AddBoneMapping(uint32_t id, const plSceneObject *bone); plAGModifier *GetRootAGMod(); @@ -298,15 +298,15 @@ public: kSwim, }; - const char *GetAnimRootName(const char *name); - int8_t AnimNameToIndex(const char *name); + plString GetAnimRootName(const plString &name); + int8_t AnimNameToIndex(const plString &name); void SetBodyType(int type) { fBodyType = type; } int GetBodyType(int type) { return fBodyType; } int GetCurrentGenericType(); bool FindMatchingGenericBrain(const char *names[], int count); - char *MakeAnimationName(const char * baseName) const; - char *GetRootName(); - void SetRootName(const char *name); + plString MakeAnimationName(const char * baseName) const; + plString GetRootName(); + void SetRootName(const plString &name); int RefreshDebugDisplay(); void DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt); @@ -369,7 +369,7 @@ public: void SetBodyAgeName(const char* ageName) {if (ageName) fBodyAgeName = ageName; else fBodyAgeName = "";} void SetBodyFootstepSoundPage(const char* pageName) {if (pageName) fBodyFootstepSoundPage = pageName; else fBodyFootstepSoundPage = "";} - void SetAnimationPrefix(const char* prefix) {if (prefix) fAnimationPrefix = prefix; else fAnimationPrefix = "";} + void SetAnimationPrefix(const plString& prefix) { fAnimationPrefix = prefix; } const char* GetUserStr() {return fUserStr.c_str();} @@ -388,16 +388,16 @@ protected: void ISetTransparentDrawOrder(bool val); plLayerLinkAnimation *IFindLayerLinkAnim(); - char *fRootName; // the name of the player root (from the max file) + plString fRootName; // the name of the player root (from the max file) hsBitVector fMoveFlags; // which keys/buttons are currently pressed hsBitVector fMoveFlagsBackup; // a copy of fMoveFlags typedef std::vector CtrlMessageVec; CtrlMessageVec fQueuedCtrlMessages; // input messages we haven't processed - float fMouseFrameTurnStrength; // Sum turnage from mouse delta messages since last eval. + float fMouseFrameTurnStrength; // Sum turnage from mouse delta messages since last eval. plKey fFootSoundSOKey; // The Scene Object we attach to targets for footstep sounds plKey fLinkSoundSOKey; // Same thing for linking... wwwwawAWAWAwawa... plKey fLinkInAnimKey; // Set when we link out, this is the anim to play (backwards) when we link in. - static float fMouseTurnSensitivity; + static float fMouseTurnSensitivity; plArmatureUpdateMsg *fUpdateMsg; // Trying to be a good lad here and align all our bools and bytes... @@ -443,7 +443,7 @@ protected: // strings for animations, age names, footstep sounds, etc std::string fBodyAgeName; std::string fBodyFootstepSoundPage; - std::string fAnimationPrefix; + plString fAnimationPrefix; // user-defined string assigned to this avatar std::string fUserStr; @@ -457,7 +457,7 @@ class plArmatureLODMod : public plArmatureMod public: // tors plArmatureLODMod(); - plArmatureLODMod(const char * root_name); + plArmatureLODMod(const plString & root_name); virtual ~plArmatureLODMod(); CLASSNAME_REGISTER( plArmatureLODMod ); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp index cf6a7ff1..bfbcdf25 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp @@ -109,9 +109,9 @@ void plArmatureBehavior::DumpDebug(int &x, int &y, int lineHeight, char *strBuf, if (fAnim) { - const char *animName = fAnim->GetName(); + plString animName = fAnim->GetName(); float time = fAnim->GetTimeConvert()->CurrentAnimTime(); - sprintf(strBuf, "%20s %3s time: %5.2f %s", animName, onOff, time, blendBar); + sprintf(strBuf, "%20s %3s time: %5.2f %s", animName.c_str(), onOff, time, blendBar); } else sprintf(strBuf, " Behavior %2d %3s %s", fIndex, onOff, blendBar); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp index 802d5be3..46a40850 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp @@ -714,7 +714,7 @@ void plAvBrainClimb::ICalcProbeLengths() hsAssert(up, "Couldn't find ClimbUp animation."); if(up) { - GetStartToEndTransform(up, &upMove, nil, "Handle"); + GetStartToEndTransform(up, &upMove, nil, _TEMP_CONVERT_FROM_LITERAL("Handle")); fVerticalProbeLength = upMove.GetTranslate().fZ; } else fVerticalProbeLength = 4.0f; // guess @@ -722,7 +722,7 @@ void plAvBrainClimb::ICalcProbeLengths() hsAssert(left, "Couldn't find ClimbLeft animation."); if(left) { - GetStartToEndTransform(left, &leftMove, nil, "Handle"); + GetStartToEndTransform(left, &leftMove, nil, _TEMP_CONVERT_FROM_LITERAL("Handle")); fHorizontalProbeLength = leftMove.GetTranslate().fX; } else fHorizontalProbeLength = 3.0f; // guess diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.cpp index 88003c14..c0b5fb80 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.cpp @@ -95,7 +95,7 @@ public: void SetAnimTime(float time) {fAnim->SetCurrentTime(time, true);} std::string Name() const {return fName;} - std::string AnimName() const {return fAnimName;} + plString AnimName() const {return fAnimName;} bool RandomStartPoint() const {return fRandomStartPoint;} float FadeInLength() const {return fFadeInLength;} float FadeOutLength() const {return fFadeOutLength;} @@ -117,7 +117,7 @@ protected: plAvBrainCritter *fCritterBrain; std::string fName; // user-created name for this behavior, also used as the index into the brain's behavior map - std::string fAnimName; // physical animation's name, for reference + plString fAnimName; // physical animation's name, for reference bool fRandomStartPoint; // do we want this behavior to start at a random frame every time we start it? float fFadeInLength; // how long to fade in this behavior float fFadeOutLength; // how long to fade out this behavior @@ -290,10 +290,10 @@ std::string plAvBrainCritter::BehaviorName(int behavior) const return ((CritterBehavior*)fBehaviors[behavior])->Name(); } -std::string plAvBrainCritter::AnimationName(int behavior) const +plString plAvBrainCritter::AnimationName(int behavior) const { if ((behavior >= fBehaviors.Count()) || (behavior < 0)) - return ""; + return _TEMP_CONVERT_FROM_LITERAL(""); return ((CritterBehavior*)fBehaviors[behavior])->AnimName(); } diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.h b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.h index 96a0c5f0..dd89f40c 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.h @@ -92,7 +92,7 @@ public: bool LocallyControlled() const {return fLocallyControlled;} std::string BehaviorName(int behavior) const; - std::string AnimationName(int behavior) const; + plString AnimationName(int behavior) const; int CurBehavior() const {return fCurMode;} int NextBehavior() const {return fNextMode;} diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp index 0d1d292b..34581ae7 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp @@ -309,7 +309,7 @@ void plAvBrainHuman::IInitBoneMap() for(int i = 0; i < numTuples; i++) { HumanBoneID id = tupleMap[i].fID; - const char * name = tupleMap[i].fName; + plString name = _TEMP_CONVERT_FROM_LITERAL(tupleMap[i].fName); const plSceneObject * bone = this->fAvMod->FindBone(name); if( bone ) @@ -317,7 +317,7 @@ void plAvBrainHuman::IInitBoneMap() fAvMod->AddBoneMapping(id, bone); } else - hsStatusMessageF("Couldn't find standard bone %s.", name); + hsStatusMessageF("Couldn't find standard bone %s.", name.c_str()); } } @@ -346,9 +346,8 @@ void plAvBrainHuman::Suspend() // Kind of hacky... but this is a rather rare case. // If the user lets up on the PushToTalk key in another brain // we'll miss the message to take off the animation. - char *chatAnimName = fAvMod->MakeAnimationName("Talk"); + plString chatAnimName = fAvMod->MakeAnimationName("Talk"); plAGAnimInstance *anim = fAvMod->FindAnimInstance(chatAnimName); - delete [] chatAnimName; if (anim) anim->FadeAndDetach(0, 1); @@ -699,7 +698,7 @@ void plAvBrainHuman::TurnToPoint(hsPoint3 point) void plAvBrainHuman::IChatOn() { - char *chatAnimName = fAvMod->MakeAnimationName("Talk"); + plString chatAnimName = fAvMod->MakeAnimationName("Talk"); // check that we aren't adding this twice... if (!fAvMod->FindAnimInstance(chatAnimName)) @@ -713,13 +712,11 @@ void plAvBrainHuman::IChatOn() taskMsg->Send(); } } - - delete [] chatAnimName; } void plAvBrainHuman::IChatOff() { - char *chatAnimName = fAvMod->MakeAnimationName("Talk"); + plString chatAnimName = fAvMod->MakeAnimationName("Talk"); plKey avKey = fAvMod->GetKey(); plAvAnimTask *animTask = new plAvAnimTask(chatAnimName, -1.0); if (animTask) @@ -728,7 +725,6 @@ void plAvBrainHuman::IChatOff() taskMsg->SetBCastFlag(plMessage::kNetPropagate); taskMsg->Send(); } - delete[] chatAnimName; } hsBool plAvBrainHuman::IInitAnimations() @@ -1422,12 +1418,11 @@ bool PushSimpleMultiStage(plArmatureMod *avatar, const char *enterAnim, const ch bool AvatarEmote(plArmatureMod *avatar, const char *emoteName) { bool result = false; - char *fullName = avatar->MakeAnimationName(emoteName); + plString fullName = avatar->MakeAnimationName(emoteName); plAGAnim *anim = plAGAnim::FindAnim(fullName); plEmoteAnim *emote = plEmoteAnim::ConvertNoRef(anim); hsBool alreadyActive = avatar->FindAnimInstance(fullName) != nil; plAvBrainHuman *huBrain = plAvBrainHuman::ConvertNoRef(avatar->FindBrainByClass(plAvBrainHuman::Index())); - delete[] fullName; // XXX plAvBrainSwim *swimBrain = plAvBrainSwim::ConvertNoRef(avatar->GetCurrentBrain()); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp index a720ab14..ee937f5c 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp @@ -534,7 +534,7 @@ hsBool plAvTaskSeek::IUpdateObjective(plArmatureMod *avatar) plAGAnim *anim = avatar->FindCustomAnim(fAnimName); // don't need to do this every frame; the animation doesn't change. // *** cache the adjustment; - GetStartToEndTransform(anim, nil, &adjustment, "Handle"); // actually getting end-to-start + GetStartToEndTransform(anim, nil, &adjustment, _TEMP_CONVERT_FROM_LITERAL("Handle")); // actually getting end-to-start // ... but we do still need to multiply by the (potentially changed) target targL2W = targL2W * adjustment; } diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp index 557e7937..62a0eb18 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp @@ -1022,7 +1022,7 @@ void plAvatarMgr::OfferLinkingBook(plKey hostKey, plKey guestKey, plMessage *lin brainG->AddStage(guestAccept); brainG->AddStage(guestAcceptIdle); - plCoopCoordinator *coord = new plCoopCoordinator(hostKey, guestKey, brainH, brainG, "Convergence", 1, 1, linkMsg, true); + plCoopCoordinator *coord = new plCoopCoordinator(hostKey, guestKey, brainH, brainG, _TEMP_CONVERT_FROM_LITERAL("Convergence"), 1, 1, linkMsg, true); plAvCoopMsg *coMg = new plAvCoopMsg(hostKey, coord); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp index c614f849..f4be85f8 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp @@ -249,7 +249,7 @@ hsBool plAvSeekTask::Start(plArmatureMod *avatar, plArmatureBrain *brain, double { hsMatrix44 adjustment; plAGAnim *anim = avatar->FindCustomAnim(fAnimName); - GetStartToEndTransform(anim, nil, &adjustment, "Handle"); // actually getting end-to-start + GetStartToEndTransform(anim, nil, &adjustment, _TEMP_CONVERT_FROM_LITERAL("Handle")); // actually getting end-to-start targetL2W = targetL2W * adjustment; } break; @@ -334,8 +334,7 @@ void plAvSeekTask::LeaveAge(plArmatureMod *avatar) // CTOR default plAvAnimTask::plAvAnimTask() -: fAnimName(nil), - fInitialBlend(0.0f), +: fInitialBlend(0.0f), fTargetBlend(0.0f), fFadeSpeed(0.0f), fSetTime(0.0f), @@ -347,7 +346,7 @@ plAvAnimTask::plAvAnimTask() } // CTOR animName, initialBlend, targetBlend, fadeSpeed, start, loop, attach -plAvAnimTask::plAvAnimTask(const char *animName, +plAvAnimTask::plAvAnimTask(const plString &animName, float initialBlend, float targetBlend, float fadeSpeed, @@ -355,7 +354,8 @@ plAvAnimTask::plAvAnimTask(const char *animName, hsBool start, hsBool loop, hsBool attach) -: fInitialBlend(initialBlend), +: fAnimName(animName), + fInitialBlend(initialBlend), fTargetBlend(targetBlend), fFadeSpeed(fadeSpeed), fSetTime(setTime), @@ -364,13 +364,12 @@ plAvAnimTask::plAvAnimTask(const char *animName, fAttach(attach), fAnimInstance(nil) { - if(animName) - fAnimName = hsStrcpy(animName); } // CTOR animName, fadeSpeed, attach -plAvAnimTask::plAvAnimTask(const char *animName, float fadeSpeed, hsBool attach) -: fInitialBlend(0.0f), +plAvAnimTask::plAvAnimTask(const plString &animName, float fadeSpeed, hsBool attach) +: fAnimName(animName), + fInitialBlend(0.0f), fTargetBlend(0.0f), fFadeSpeed(fadeSpeed), fSetTime(0.0f), @@ -379,23 +378,11 @@ plAvAnimTask::plAvAnimTask(const char *animName, float fadeSpeed, hsBool attach) fAttach(attach), fAnimInstance(nil) { - if(animName) - fAnimName = hsStrcpy(animName); } -// DTOR -plAvAnimTask::~plAvAnimTask() -{ - if(fAnimName) - { - delete[] fAnimName; - fAnimName = nil; - } -} - // START hsBool plAvAnimTask::Start(plArmatureMod *avatar, plArmatureBrain *brain, double time, float elapsed) { @@ -420,7 +407,7 @@ hsBool plAvAnimTask::Start(plArmatureMod *avatar, plArmatureBrain *brain, double } else { - hsStatusMessageF("Couldn't find animation <%s> for plAvAnimTask: will try again", fAnimName); + hsStatusMessageF("Couldn't find animation <%s> for plAvAnimTask: will try again", fAnimName.c_str()); } } else @@ -480,7 +467,7 @@ void plAvAnimTask::LeaveAge(plArmatureMod *avatar) // READ void plAvAnimTask::Read(hsStream *stream, hsResMgr *mgr) { - fAnimName = stream->ReadSafeString(); + fAnimName = stream->ReadSafeString_TEMP(); fInitialBlend = stream->ReadLEScalar(); fTargetBlend = stream->ReadLEScalar(); fFadeSpeed = stream->ReadLEScalar(); @@ -515,7 +502,6 @@ void plAvOneShotTask::InitDefaults() fBackwards = false; fDisableLooping = false; fDisablePhysics = true; - fAnimName = nil; fMoveHandle = false; fAnimInstance = nil; fDrivable = false; @@ -537,7 +523,7 @@ plAvOneShotTask::plAvOneShotTask() // this construct is typically used when you want to create a one-shot task as part of a sequence // of tasks // it's different than the message-based constructor in that fDetachAnimation and fMoveHandle default to false -plAvOneShotTask::plAvOneShotTask(const char *animName, hsBool drivable, hsBool reversible, plOneShotCallbacks *callbacks) +plAvOneShotTask::plAvOneShotTask(const plString &animName, hsBool drivable, hsBool reversible, plOneShotCallbacks *callbacks) { InitDefaults(); @@ -547,7 +533,7 @@ plAvOneShotTask::plAvOneShotTask(const char *animName, hsBool drivable, hsBool r // we're going to use this sometime in the future, better ref it so someone else doesn't release it hsRefCnt_SafeRef(fCallbacks); - fAnimName = hsStrcpy(animName); + fAnimName = animName; } // CTOR (plAvOneShotMsg, plArmatureMod) @@ -565,14 +551,12 @@ plAvOneShotTask::plAvOneShotTask (plAvOneShotMsg *msg, plArmatureMod *avatar, pl // we're going to use this sometime in the future, better ref it so someone else doesn't release it hsRefCnt_SafeRef(fCallbacks); - fAnimName = hsStrcpy(msg->fAnimName); + fAnimName = msg->fAnimName; } // DTOR plAvOneShotTask::~plAvOneShotTask() { - if(fAnimName) - delete[] fAnimName; hsRefCnt_SafeUnRef(fCallbacks); } @@ -640,7 +624,7 @@ hsBool plAvOneShotTask::Start(plArmatureMod *avatar, plArmatureBrain *brain, dou plgDispatch::MsgSend( pMsg ); // whoosh... off it goes } - fMoveHandle = (fAnimInstance->GetAnimation()->GetChannel("Handle") != nil); + fMoveHandle = (fAnimInstance->GetAnimation()->GetChannel(_TEMP_CONVERT_FROM_LITERAL("Handle")) != nil); if(fMoveHandle) { plMatrixDifferenceApp *differ = avatar->GetRootAnimator(); @@ -654,9 +638,8 @@ hsBool plAvOneShotTask::Start(plArmatureMod *avatar, plArmatureBrain *brain, dou } else { - char buf[256]; - sprintf(buf, "Oneshot: Can't find animation <%s>; all bets are off.", fAnimName); - hsAssert(false, buf); + plString buf = plString::Format("Oneshot: Can't find animation <%s>; all bets are off.", fAnimName.c_str()); + hsAssert(false, buf.c_str()); result = true; } return result; @@ -750,10 +733,9 @@ void plAvOneShotTask::LeaveAge(plArmatureMod *avatar) fIgnore = true; } -void plAvOneShotTask::SetAnimName(char *name) +void plAvOneShotTask::SetAnimName(const plString &name) { - delete [] fAnimName; - fAnimName = hsStrcpy(name); + fAnimName = name; } ////////////////////// @@ -763,7 +745,6 @@ void plAvOneShotTask::SetAnimName(char *name) ////////////////////// plAvOneShotLinkTask::plAvOneShotLinkTask() : plAvOneShotTask(), -fMarkerName(nil), fMarkerTime(-1), fStartTime(0), fLinkFired(false) @@ -773,7 +754,6 @@ fLinkFired(false) plAvOneShotLinkTask::~plAvOneShotLinkTask() { - delete [] fMarkerName; } // task protocol @@ -782,7 +762,7 @@ hsBool plAvOneShotLinkTask::Start(plArmatureMod *avatar, plArmatureBrain *brain, hsBool result = plAvOneShotTask::Start(avatar, brain, time, elapsed); fStartTime = time; - if (fAnimInstance && fMarkerName) + if (fAnimInstance && !fMarkerName.IsNull()) { const plATCAnim *anim = plATCAnim::ConvertNoRef(fAnimInstance->GetAnimation()); if (anim) @@ -824,14 +804,13 @@ void plAvOneShotLinkTask::Write(hsStream *stream, hsResMgr *mgr) void plAvOneShotLinkTask::Read(hsStream *stream, hsResMgr *mgr) { plAvOneShotTask::Read(stream, mgr); - fAnimName = stream->ReadSafeString(); - fMarkerName = stream->ReadSafeString(); + fAnimName = stream->ReadSafeString_TEMP(); + fMarkerName = stream->ReadSafeString_TEMP(); } -void plAvOneShotLinkTask::SetMarkerName(char *name) +void plAvOneShotLinkTask::SetMarkerName(const plString &name) { - delete [] fMarkerName; - fMarkerName = hsStrcpy(name); + fMarkerName = name; } diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.h b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.h index 79b206ea..4ffb275e 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.h @@ -84,15 +84,13 @@ public: \param loop Make the animation loop? \param attach Are we attaching or detaching the animation? */ - plAvAnimTask(const char *animName, float initialBlend, float targetBlend, float fadeSpeed, + plAvAnimTask(const plString &animName, float initialBlend, float targetBlend, float fadeSpeed, float setTime, hsBool start, hsBool loop, hsBool attach); /** Canonical constructor form form for detaching \param animName The name of the animation we're detaching \param fadeSpeed How fast to fade it out. */ - plAvAnimTask(const char *animName, float fadeSpeed, hsBool attach = false); - - virtual ~plAvAnimTask(); + plAvAnimTask(const plString &animName, float fadeSpeed, hsBool attach = false); // task protocol virtual hsBool Start(plArmatureMod *avatar, plArmatureBrain *brain, double time, float elapsed); @@ -108,11 +106,11 @@ public: protected: // public members - char* fAnimName; // the animation we're operating on - float fInitialBlend; // the blend to establish (attaching only) - float fTargetBlend; // the blend to achieve eventually (attaching only) - float fFadeSpeed; // how fast to achieve the blend - float fSetTime; // set the animation to this time + plString fAnimName; // the animation we're operating on + float fInitialBlend; // the blend to establish (attaching only) + float fTargetBlend; // the blend to achieve eventually (attaching only) + float fFadeSpeed; // how fast to achieve the blend + float fSetTime; // set the animation to this time hsBool fStart; // start the animation playing? (attaching only) hsBool fLoop; // turn on looping? (attaching only) hsBool fAttach; // attach? (otherwise detach) @@ -184,7 +182,7 @@ public: \param reversable Unused. Allows the oneshot to be backed up by keyboard input \param callbacks A vector of callback messages to be sent at specific times during the animation */ - plAvOneShotTask(const char *animName, hsBool drivable, hsBool reversible, plOneShotCallbacks *callbacks); + plAvOneShotTask(const plString &animName, hsBool drivable, hsBool reversible, plOneShotCallbacks *callbacks); /** Construct from a oneshot message. \param msg The message to copy our parameters from \param brain The brain to attach the task to. @@ -197,7 +195,7 @@ public: virtual hsBool Process(plArmatureMod *avatar, plArmatureBrain *brain, double time, float elapsed); virtual void LeaveAge(plArmatureMod *avatar); - void SetAnimName(char *name); + void SetAnimName(const plString &name); static hsBool fForce3rdPerson; @@ -211,7 +209,7 @@ public: // *** implement reader and writer if needed for network propagation protected: - char *fAnimName; // the name of the one-shot animation we want to use + plString fAnimName; // the name of the one-shot animation we want to use hsBool fMoveHandle; // move the handle after the oneshot's done playing? plAGAnimInstance *fAnimInstance; // the animation instance (available only after it starts playing) hsBool fDrivable; // the user can control the animation with the mouse @@ -257,10 +255,10 @@ public: virtual void Write(hsStream *stream, hsResMgr *mgr); virtual void Read(hsStream *stream, hsResMgr *mgr); - void SetMarkerName(char *name); + void SetMarkerName(const plString &name); protected: - char *fMarkerName; + plString fMarkerName; double fStartTime; float fMarkerTime; hsBool fLinkFired; diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp index 9630e592..a408beae 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp @@ -94,7 +94,7 @@ plCoopCoordinator::plCoopCoordinator() // ------------------ plCoopCoordinator::plCoopCoordinator(plKey host, plKey guest, plAvBrainCoop *hostBrain, plAvBrainCoop *guestBrain, - const char *synchBone, + const plString &synchBone, uint32_t hostOfferStage, uint32_t guestAcceptStage, plMessage *guestAcceptMsg, bool autoStartGuest) @@ -108,6 +108,7 @@ plCoopCoordinator::plCoopCoordinator(plKey host, plKey guest, fGuestAcceptStage(guestAcceptStage), fGuestAcceptMsg(guestAcceptMsg), fAutoStartGuest(autoStartGuest), + fSynchBone(synchBone), fGuestAccepted(false), fGuestLinked(false) { @@ -119,8 +120,6 @@ plCoopCoordinator::plCoopCoordinator(plKey host, plKey guest, plKey newKey = hsgResMgr::ResMgr()->NewKey(newName, this, host->GetUoid().GetLocation()); - fSynchBone = hsStrcpy(synchBone); - plKey avMgrKey = plAvatarMgr::GetInstance()->GetKey(); guestBrain->SetRecipient(avMgrKey); @@ -136,13 +135,6 @@ plCoopCoordinator::plCoopCoordinator(plKey host, plKey guest, } } -// plCoopCoordinator ------------------ -// ------------------ -plCoopCoordinator::~plCoopCoordinator() -{ - delete[] fSynchBone; -} - ///////////////////////////////////////////////////////////////////////////////////////// // // CONSTRUCTORS @@ -405,7 +397,7 @@ void plCoopCoordinator::Read(hsStream *stream, hsResMgr *mgr) else fGuestAcceptMsg = nil; - fSynchBone = stream->ReadSafeString(); + fSynchBone = stream->ReadSafeString_TEMP(); fAutoStartGuest = stream->Readbool(); fInitiatorID = fHostBrain->GetInitiatorID(); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.h b/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.h index 6a176cc4..04e67aae 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.h @@ -79,10 +79,9 @@ public: plCoopCoordinator(); plCoopCoordinator(plKey host, plKey guest, plAvBrainCoop *hostBrain, plAvBrainCoop *guestBrain, - const char *synchBone, uint32_t hostOfferStage, uint32_t guestAcceptStage, + const plString &synchBone, uint32_t hostOfferStage, uint32_t guestAcceptStage, plMessage *guestAcceptMsg, bool autoStartGuest); - ~plCoopCoordinator(); virtual hsBool MsgReceive(plMessage *msg); @@ -124,7 +123,7 @@ protected: plMessage *fGuestAcceptMsg; // send this when the guest accepts - char *fSynchBone; + plString fSynchBone; bool fAutoStartGuest; bool fGuestAccepted; diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plOneShotMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plOneShotMod.cpp index 16a398b6..4638b5b9 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plOneShotMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plOneShotMod.cpp @@ -130,13 +130,12 @@ hsBool plOneShotMod::MsgReceive(plMessage* msg) if(avMod) { - char *animName = avMod->MakeAnimationName(fAnimName); + plString animName = avMod->MakeAnimationName(fAnimName); plAvOneShotMsg *avOSmsg = new plAvOneShotMsg(myKey, oneShotMsg->fPlayerKey, objKey, fSeekDuration, (hsBool)fSmartSeek, animName, fDrivable, fReversable); - delete [] animName; // AvOneShotMsg constructor copies. avOSmsg->fNoSeek = fNoSeek; avOSmsg->SetBCastFlag(plMessage::kPropagateToModifiers); hsRefCnt_SafeRef(oneShotMsg->fCallbacks); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.cpp index 8fa88342..76e64e9c 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.cpp @@ -279,7 +279,7 @@ bool IIsClosestAnim(const char *animName, hsMatrix44 &sitGoal, float &closestDis // The first step is to get the transform from the end to the beginning of the // animation. That's what this next line is doing. It's a bit unintuitive // until you look at the parameter definitions. - GetStartToEndTransform(anim, nil, &animEndToStart, "Handle"); + GetStartToEndTransform(anim, nil, &animEndToStart, _TEMP_CONVERT_FROM_LITERAL("Handle")); hsMatrix44 candidateGoal = sitGoal * animEndToStart; hsPoint3 distP = candidateGoal.GetTranslate() - curPosition; hsVector3 distV(distP.fX, distP.fY, distP.fZ); @@ -290,9 +290,7 @@ bool IIsClosestAnim(const char *animName, hsMatrix44 &sitGoal, float &closestDis return true; } } else { - char buffy[256]; - sprintf(buffy, "Missing sit animation: %s", animName); - hsAssert(false, buffy); + hsAssert(false, plString::Format("Missing sit animation: %s", animName).c_str()); } return false; } diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpansExport.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpansExport.cpp index 4b690152..ad3b410a 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpansExport.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpansExport.cpp @@ -386,7 +386,7 @@ static void ILogSpan(plStatusLog* statusLog, plGeometrySpan* geo, plVertexSpan* uint32_t ptr = cell->fVtxStart + span->fCellOffset * stride; statusLog->AddLineF("From obj <%s> mat <%s> size %d bytes grp=%d (%d offset)", - geo->fMaxOwner ? geo->fMaxOwner : "", + geo->fMaxOwner.s_str(""), geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "", geo->GetVertexSize(geo->fFormat) * geo->fNumVerts + sizeof(uint16_t) * geo->fNumIndices, span->fGroupIdx, @@ -404,7 +404,7 @@ static void ILogSpan(plStatusLog* statusLog, plGeometrySpan* geo, plVertexSpan* else { statusLog->AddLineF("Instanced obj <%s> mat <%s> grp=%d (%d/%d/%d/%d/%d/%d/%d/%d)", - geo->fMaxOwner ? geo->fMaxOwner : "", + geo->fMaxOwner.s_str(""), geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "", span->fGroupIdx, span->fVBufferIdx, @@ -423,7 +423,7 @@ static void ILogSpan(plStatusLog* statusLog, plGeometrySpan* geo, plVertexSpan* if( geo->fProps & plGeometrySpan::kFirstInstance ) { statusLog->AddLineF("From obj <%s> mat <%s> size %d bytes grp=%d (%d/%d/%d/%d/%d)", - geo->fMaxOwner ? geo->fMaxOwner : "", + geo->fMaxOwner.s_str(""), geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "", geo->GetVertexSize(geo->fFormat) * geo->fNumVerts + sizeof(uint16_t) * geo->fNumIndices, span->fGroupIdx, @@ -437,7 +437,7 @@ static void ILogSpan(plStatusLog* statusLog, plGeometrySpan* geo, plVertexSpan* else { statusLog->AddLineF("Instanced obj <%s> mat <%s> grp=%d (%d/%d/%d/%d/%d)", - geo->fMaxOwner ? geo->fMaxOwner : "", + geo->fMaxOwner.s_str(""), geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "", span->fGroupIdx, span->fVBufferIdx, diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plGeometrySpan.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plGeometrySpan.cpp index b321337a..eb1b5bc6 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plGeometrySpan.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plGeometrySpan.cpp @@ -115,7 +115,7 @@ void plGeometrySpan::IClearMembers( void ) fDecalLevel = 0; - fMaxOwner = nil; + fMaxOwner = plString::Null; } //// ClearBuffers //////////////////////////////////////////////////////////// diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plGeometrySpan.h b/Sources/Plasma/PubUtilLib/plDrawable/plGeometrySpan.h index f40615a8..6eb85f20 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plGeometrySpan.h +++ b/Sources/Plasma/PubUtilLib/plDrawable/plGeometrySpan.h @@ -136,20 +136,20 @@ class plGeometrySpan hsBounds3Ext fWorldBounds; plFogEnvironment *fFogEnviron; - uint32_t fBaseMatrix; - uint8_t fNumMatrices; - uint16_t fLocalUVWChans; - uint16_t fMaxBoneIdx; - uint32_t fPenBoneIdx; + uint32_t fBaseMatrix; + uint8_t fNumMatrices; + uint16_t fLocalUVWChans; + uint16_t fMaxBoneIdx; + uint32_t fPenBoneIdx; - float fMinDist; - float fMaxDist; + float fMinDist; + float fMaxDist; - float fWaterHeight; + float fWaterHeight; - uint8_t fFormat; - uint32_t fProps; - uint32_t fNumVerts, fNumIndices; + uint8_t fFormat; + uint32_t fProps; + uint32_t fNumVerts, fNumIndices; /// Current vertex format: /// float position[ 3 ]; @@ -158,22 +158,22 @@ class plGeometrySpan /// float weights[]; // 0-3 blending weights /// uint32_t weightIndices; // Only if there are >= 1 blending weights - uint8_t* fVertexData; - uint16_t* fIndexData; - uint32_t fDecalLevel; + uint8_t* fVertexData; + uint16_t* fIndexData; + uint32_t fDecalLevel; hsColorRGBA* fMultColor; hsColorRGBA* fAddColor; - uint32_t* fDiffuseRGBA; - uint32_t* fSpecularRGBA; + uint32_t* fDiffuseRGBA; + uint32_t* fSpecularRGBA; mutable hsTArray* fInstanceRefs; - mutable uint32_t fInstanceGroupID; // For writing out/reading in instance refs + mutable uint32_t fInstanceGroupID; // For writing out/reading in instance refs // The following is only used for logging during export. It is never set // at runtime. Don't even think about using it for anything. - const char* fMaxOwner; + plString fMaxOwner; // The following is ONLY used during pack; it's so we can do a reverse lookup // from the instanceRefs list to the correct span in the drawable diff --git a/Sources/Plasma/PubUtilLib/plMessage/plAnimCmdMsg.cpp b/Sources/Plasma/PubUtilLib/plMessage/plAnimCmdMsg.cpp index 6ee197c5..b3e7dd2b 100644 --- a/Sources/Plasma/PubUtilLib/plMessage/plAnimCmdMsg.cpp +++ b/Sources/Plasma/PubUtilLib/plMessage/plAnimCmdMsg.cpp @@ -47,8 +47,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com plAnimCmdMsg::~plAnimCmdMsg() { ClearCmd(); - delete [] fAnimName; - delete [] fLoopName; } @@ -58,24 +56,22 @@ void plAnimCmdMsg::ClearCmd() fCmd.Clear(); } -void plAnimCmdMsg::SetAnimName(const char *name) +void plAnimCmdMsg::SetAnimName(const plString &name) { - delete [] fAnimName; - fAnimName = hsStrcpy(name); + fAnimName = name; } -const char *plAnimCmdMsg::GetAnimName() +plString plAnimCmdMsg::GetAnimName() { return fAnimName; } -void plAnimCmdMsg::SetLoopName(const char *name) +void plAnimCmdMsg::SetLoopName(const plString &name) { - delete [] fLoopName; - fLoopName = hsStrcpy(name); + fLoopName = name; } -const char *plAnimCmdMsg::GetLoopName() +plString plAnimCmdMsg::GetLoopName() { return fLoopName; } @@ -110,8 +106,8 @@ void plAnimCmdMsg::Read(hsStream* stream, hsResMgr* mgr) stream->ReadLE(&fSpeedChangeRate); stream->ReadLE(&fTime); - fAnimName = stream->ReadSafeString(); - fLoopName = stream->ReadSafeString(); + fAnimName = stream->ReadSafeString_TEMP(); + fLoopName = stream->ReadSafeString_TEMP(); } void plAnimCmdMsg::Write(hsStream* stream, hsResMgr* mgr) @@ -136,16 +132,14 @@ void plAnimCmdMsg::Write(hsStream* stream, hsResMgr* mgr) plAGCmdMsg::~plAGCmdMsg() { ClearCmd(); - delete [] fAnimName; } -void plAGCmdMsg::SetAnimName(const char *name) +void plAGCmdMsg::SetAnimName(const plString &name) { - delete [] fAnimName; - fAnimName = hsStrcpy(name); + fAnimName = name; } -const char *plAGCmdMsg::GetAnimName() +plString plAGCmdMsg::GetAnimName() { return fAnimName; } @@ -160,7 +154,7 @@ void plAGCmdMsg::Read(hsStream* stream, hsResMgr* mgr) stream->ReadLE(&fAmp); stream->ReadLE(&fAmpRate); - fAnimName = stream->ReadSafeString(); + fAnimName = stream->ReadSafeString_TEMP(); } void plAGCmdMsg::Write(hsStream* stream, hsResMgr* mgr) @@ -178,17 +172,12 @@ void plAGCmdMsg::Write(hsStream* stream, hsResMgr* mgr) ///////////////////////////////////////////////////////////////////////////////////// -plAGDetachCallbackMsg::~plAGDetachCallbackMsg() +void plAGDetachCallbackMsg::SetAnimName(const plString &name) { - delete [] fAnimName; + fAnimName = name; } -void plAGDetachCallbackMsg::SetAnimName(const char *name) -{ - fAnimName = hsStrcpy(name); -} - -char *plAGDetachCallbackMsg::GetAnimName() +plString plAGDetachCallbackMsg::GetAnimName() { return fAnimName; } diff --git a/Sources/Plasma/PubUtilLib/plMessage/plAnimCmdMsg.h b/Sources/Plasma/PubUtilLib/plMessage/plAnimCmdMsg.h index 219da379..b1ad1a12 100644 --- a/Sources/Plasma/PubUtilLib/plMessage/plAnimCmdMsg.h +++ b/Sources/Plasma/PubUtilLib/plMessage/plAnimCmdMsg.h @@ -47,6 +47,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "hsBitVector.h" #include "hsTemplates.h" #include "hsGeometry3.h" +#include "plString.h" #include "plInterp/plAnimEaseTypes.h" #include "plInterp/plAnimTimeConvert.h" @@ -55,11 +56,11 @@ class plAGAnimInstance; class plAnimCmdMsg : public plMessageWithCallbacks { protected: - char *fAnimName; - char *fLoopName; + plString fAnimName; + plString fLoopName; private: - void IInit() { fBegin=fEnd=fLoopBegin=fLoopEnd=fSpeed=fSpeedChangeRate=fTime=0; fAnimName=fLoopName=nil;} + void IInit() { fBegin=fEnd=fLoopBegin=fLoopEnd=fSpeed=fSpeedChangeRate=fTime=0; fAnimName=fLoopName=plString::Null;} public: plAnimCmdMsg() : plMessageWithCallbacks(nil, nil, nil) { IInit(); } @@ -110,12 +111,16 @@ public: hsBool Cmd(int n) const { return fCmd.IsBitSet(n); } void SetCmd(int n) { fCmd.SetBit(n); } void ClearCmd(); - void SetAnimName(const char *name); - const char *GetAnimName(); + void SetAnimName(const plString &name); + plString GetAnimName(); hsBool CmdChangesAnimTime(); // Will this command cause an update to the current anim time? - void SetLoopName(const char *name); - const char *GetLoopName(); + // TEMP plString REVISIT + // Because I'm TOO LAZY to keep converting all these calls to SetAnimName + void SetAnimName(const char *name) { SetAnimName(_TEMP_CONVERT_FROM_LITERAL(name)); } + + void SetLoopName(const plString &name); + plString GetLoopName(); float fBegin; float fEnd; @@ -136,11 +141,11 @@ public: class plAGCmdMsg : public plMessage { protected: - char *fAnimName; + plString fAnimName; private: void IInit() { fBlend = fAmp = 0; - fAnimName=nil;} + fAnimName=plString::Null;} public: plAGCmdMsg() : plMessage(nil, nil, nil) { IInit(); } @@ -165,8 +170,8 @@ public: hsBool Cmd(int n) const { return fCmd.IsBitSet(n); } void SetCmd(int n) { fCmd.SetBit(n); } void ClearCmd() { fCmd.Clear(); } - void SetAnimName(const char *name); - const char *GetAnimName(); + void SetAnimName(const plString &name); + plString GetAnimName(); float fBlend; float fBlendRate; @@ -199,13 +204,12 @@ public: class plAGDetachCallbackMsg : public plEventCallbackMsg { protected: - char *fAnimName; + plString fAnimName; public: - plAGDetachCallbackMsg() : plEventCallbackMsg(), fAnimName(nil) {} + plAGDetachCallbackMsg() : plEventCallbackMsg() {} plAGDetachCallbackMsg(plKey receiver, CallbackEvent e, int idx=0, float t=0, int16_t repeats=-1, uint16_t user=0) : - plEventCallbackMsg(receiver, e, idx, t, repeats, user), fAnimName(nil) {} - virtual ~plAGDetachCallbackMsg(); + plEventCallbackMsg(receiver, e, idx, t, repeats, user) {} CLASSNAME_REGISTER( plAGDetachCallbackMsg ); GETINTERFACE_ANY( plAGDetachCallbackMsg, plEventCallbackMsg ); @@ -214,8 +218,8 @@ public: void Read(hsStream* stream, hsResMgr* mgr) {} void Write(hsStream* stream, hsResMgr* mgr) {} - void SetAnimName(const char *name); - char *GetAnimName(); + void SetAnimName(const plString &name); + plString GetAnimName(); }; diff --git a/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.cpp b/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.cpp index 4b4f0c29..8585249b 100644 --- a/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.cpp +++ b/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.cpp @@ -351,18 +351,17 @@ void plAvTaskSeekDoneMsg::Write(hsStream *stream, hsResMgr *mgr) // CTOR() plAvOneShotMsg::plAvOneShotMsg() -: plAvSeekMsg(), fAnimName(nil), fDrivable(false), fReversible(false), fCallbacks(nil) +: plAvSeekMsg(), fDrivable(false), fReversible(false), fCallbacks(nil) { } // CTOR(sender, receiver, seekKey, time) plAvOneShotMsg::plAvOneShotMsg(const plKey &sender, const plKey& receiver, const plKey& seekKey, float duration, hsBool smartSeek, - const char *animName, hsBool drivable, hsBool reversible) -: plAvSeekMsg(sender, receiver, seekKey, duration, smartSeek), + const plString &animName, hsBool drivable, hsBool reversible) +: plAvSeekMsg(sender, receiver, seekKey, duration, smartSeek), fAnimName(animName), fDrivable(drivable), fReversible(reversible), fCallbacks(nil) { - fAnimName = hsStrcpy(animName); } // DTOR @@ -370,8 +369,6 @@ plAvOneShotMsg::~plAvOneShotMsg() { hsRefCnt_SafeUnRef(fCallbacks); fCallbacks = nil; - - delete[] fAnimName; } // READ @@ -379,8 +376,7 @@ void plAvOneShotMsg::Read(hsStream *stream, hsResMgr *mgr) { plAvSeekMsg::Read(stream, mgr); - delete [] fAnimName; - fAnimName = stream->ReadSafeString(); + fAnimName = stream->ReadSafeString_TEMP(); fDrivable = stream->ReadBool(); fReversible = stream->ReadBool(); } diff --git a/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.h b/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.h index e4e6b451..f3966b9b 100644 --- a/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.h +++ b/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.h @@ -247,7 +247,7 @@ public: virtual ~plAvOneShotMsg(); plAvOneShotMsg(const plKey &sender, const plKey& receiver, const plKey& seekKey, float duration, hsBool fSmartSeek, - const char *animName, hsBool drivable, hsBool reversible); + const plString &animName, hsBool drivable, hsBool reversible); // plasma protocol CLASSNAME_REGISTER( plAvOneShotMsg ); @@ -257,7 +257,7 @@ public: virtual void Write(hsStream *stream, hsResMgr *mgr); // public members - char * fAnimName; // the name of the animation we're going to use + plString fAnimName; // the name of the animation we're going to use hsBool fDrivable; // are we animated by time or by mouse movement? hsBool fReversible; // can we play backwards? plOneShotCallbacks *fCallbacks; // Callbacks given to us by a one-shot modifier diff --git a/Sources/Plasma/PubUtilLib/plMessage/plOneShotCallbacks.cpp b/Sources/Plasma/PubUtilLib/plMessage/plOneShotCallbacks.cpp index bbbe597e..93b27de8 100644 --- a/Sources/Plasma/PubUtilLib/plMessage/plOneShotCallbacks.cpp +++ b/Sources/Plasma/PubUtilLib/plMessage/plOneShotCallbacks.cpp @@ -50,15 +50,12 @@ plOneShotCallbacks::plOneShotCallbacks() plOneShotCallbacks::~plOneShotCallbacks() { - int size = fCallbacks.size(); - for (int i = 0; i < size; i++) - delete [] fCallbacks[i].fMarker; fCallbacks.clear(); } -void plOneShotCallbacks::AddCallback(const char *marker, plKey &receiver, int16_t user) +void plOneShotCallbacks::AddCallback(const plString &marker, plKey &receiver, int16_t user) { - fCallbacks.push_back(plOneShotCallback(hsStrcpy(marker), receiver, user)); + fCallbacks.push_back(plOneShotCallback(marker, receiver, user)); } int plOneShotCallbacks::GetNumCallbacks() @@ -77,7 +74,7 @@ void plOneShotCallbacks::Read(hsStream* stream, hsResMgr* mgr) fCallbacks.reserve(size); for (int i = 0; i < size; i++) { - char *marker = stream->ReadSafeString(); + plString marker = stream->ReadSafeString_TEMP(); plKey receiver = mgr->ReadKey(stream); int16_t user = stream->ReadLE16(); diff --git a/Sources/Plasma/PubUtilLib/plMessage/plOneShotCallbacks.h b/Sources/Plasma/PubUtilLib/plMessage/plOneShotCallbacks.h index e419eefa..ec46c548 100644 --- a/Sources/Plasma/PubUtilLib/plMessage/plOneShotCallbacks.h +++ b/Sources/Plasma/PubUtilLib/plMessage/plOneShotCallbacks.h @@ -59,10 +59,10 @@ public: class plOneShotCallback { public: - plOneShotCallback(char *marker, plKey &receiver, int16_t user) : + plOneShotCallback(const plString &marker, plKey &receiver, int16_t user) : fMarker(marker), fReceiver(receiver) , fUser(user) {} - char *fMarker; + plString fMarker; plKey fReceiver; int16_t fUser; }; @@ -74,7 +74,7 @@ public: plOneShotCallbacks(); ~plOneShotCallbacks(); - void AddCallback(const char *marker, plKey &receiver, int16_t user=0); + void AddCallback(const plString &marker, plKey &receiver, int16_t user=0); int GetNumCallbacks(); plOneShotCallback& GetCallback(int i); diff --git a/Sources/Plasma/PubUtilLib/plModifier/plAxisAnimModifier.cpp b/Sources/Plasma/PubUtilLib/plModifier/plAxisAnimModifier.cpp index 19dfd491..c038e86d 100644 --- a/Sources/Plasma/PubUtilLib/plModifier/plAxisAnimModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plModifier/plAxisAnimModifier.cpp @@ -203,7 +203,7 @@ hsBool plAxisAnimModifier::MsgReceive(plMessage* msg) return true; plAnimCmdMsg* pMsg = new plAnimCmdMsg; pMsg->AddReceiver(fXAnim); - pMsg->SetAnimName(fAnimLabel.c_str()); + pMsg->SetAnimName(fAnimLabel); // pMsg->SetAnimName() if (fXPos < pMMsg->GetXPos()) { @@ -223,7 +223,7 @@ hsBool plAxisAnimModifier::MsgReceive(plMessage* msg) return true; plAnimCmdMsg* pMsg = new plAnimCmdMsg; pMsg->AddReceiver(fYAnim); - pMsg->SetAnimName(fAnimLabel.c_str()); + pMsg->SetAnimName(fAnimLabel); if (fYPos > pMMsg->GetYPos()) { if (fAllOrNothing) @@ -301,7 +301,7 @@ hsBool plAxisAnimModifier::MsgReceive(plMessage* msg) pMsg->SetCmd(plAnimCmdMsg::kAddCallbacks); pMsg->AddCallback(pCall1); pMsg->AddCallback(pCall2); - pMsg->SetAnimName(fAnimLabel.c_str()); + pMsg->SetAnimName(fAnimLabel); pMsg->AddReceiver( fXAnim ); hsRefCnt_SafeUnRef( pCall1 ); @@ -330,7 +330,7 @@ hsBool plAxisAnimModifier::MsgReceive(plMessage* msg) pMsg->AddCallback(pCall1); pMsg->AddCallback(pCall2); pMsg->AddReceiver( fYAnim ); - pMsg->SetAnimName(fAnimLabel.c_str()); + pMsg->SetAnimName(fAnimLabel); hsRefCnt_SafeUnRef( pCall1 ); hsRefCnt_SafeUnRef( pCall2 ); diff --git a/Sources/Plasma/PubUtilLib/plModifier/plAxisAnimModifier.h b/Sources/Plasma/PubUtilLib/plModifier/plAxisAnimModifier.h index 4bb981b8..738583bc 100644 --- a/Sources/Plasma/PubUtilLib/plModifier/plAxisAnimModifier.h +++ b/Sources/Plasma/PubUtilLib/plModifier/plAxisAnimModifier.h @@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "hsStlUtils.h" #include "pnModifier/plSingleModifier.h" +#include "plString.h" class plKey; @@ -74,7 +75,7 @@ protected: int fIface; plNotifyMsg* fNotify; - std::string fAnimLabel; + plString fAnimLabel; plAxisInputInterface *fInputIface; @@ -100,8 +101,8 @@ public: void SetNotificationKey(plKey k) { fNotificationKey = k; } plNotifyMsg* GetNotify() { return fNotify; } - const char* GetAnimLabel() const {return fAnimLabel.c_str();} - void SetAnimLabel(const char* a) {fAnimLabel = a; } + plString GetAnimLabel() const { return fAnimLabel; } + void SetAnimLabel(const plString& a) { fAnimLabel = a; } }; diff --git a/Sources/Plasma/PubUtilLib/plSurface/plLayerAnimation.cpp b/Sources/Plasma/PubUtilLib/plSurface/plLayerAnimation.cpp index 4e84ff9a..cbdba018 100644 --- a/Sources/Plasma/PubUtilLib/plSurface/plLayerAnimation.cpp +++ b/Sources/Plasma/PubUtilLib/plSurface/plLayerAnimation.cpp @@ -68,8 +68,7 @@ plLayerAnimationBase::plLayerAnimationBase() fOpacityCtl(nil), fTransformCtl(nil), fEvalTime(-1.0), - fCurrentTime(-1.f), - fSegmentID(nil) + fCurrentTime(-1.f) { } @@ -81,7 +80,6 @@ plLayerAnimationBase::~plLayerAnimationBase() delete fSpecularColorCtl; delete fOpacityCtl; delete fTransformCtl; - delete [] fSegmentID; } void plLayerAnimationBase::Read(hsStream* s, hsResMgr* mgr) diff --git a/Sources/Plasma/PubUtilLib/plSurface/plLayerAnimation.h b/Sources/Plasma/PubUtilLib/plSurface/plLayerAnimation.h index 6e30079b..f789ea5a 100644 --- a/Sources/Plasma/PubUtilLib/plSurface/plLayerAnimation.h +++ b/Sources/Plasma/PubUtilLib/plSurface/plLayerAnimation.h @@ -60,10 +60,10 @@ class plSimpleStateVariable; class plLayerAnimationBase : public plLayerInterface { protected: - char* fSegmentID; - double fEvalTime; - float fCurrentTime; - float fLength; + plString fSegmentID; + double fEvalTime; + float fCurrentTime; + float fLength; plController* fPreshadeColorCtl; plController* fRuntimeColorCtl; @@ -92,8 +92,8 @@ public: // Specialized float GetLength() const { return fLength; } - char *GetSegmentID() const { return fSegmentID; } - void SetSegmentID(char *ID) { delete fSegmentID; fSegmentID = hsStrcpy(ID); } + plString GetSegmentID() const { return fSegmentID; } + void SetSegmentID(const plString &ID) { fSegmentID = ID; } // Export construction functions follow void SetPreshadeColorCtl(plController* colCtl); diff --git a/Sources/Tools/MaxComponent/plAGComponents.cpp b/Sources/Tools/MaxComponent/plAGComponents.cpp index a58b9052..692ccbf4 100644 --- a/Sources/Tools/MaxComponent/plAGComponents.cpp +++ b/Sources/Tools/MaxComponent/plAGComponents.cpp @@ -109,11 +109,11 @@ public: virtual hsBool Convert(plMaxNode* node, plErrorMsg *pErrMsg); - virtual plATCAnim * NewAnimation(const char *name, double begin, double end); + virtual plATCAnim * NewAnimation(const plString &name, double begin, double end); hsBool ConvertNode(plMaxNode *node, plErrorMsg *pErrMsg); hsBool ConvertNodeSegmentBranch(plMaxNode *node, plAGAnim *mod, plErrorMsg *pErrMsg); - hsBool MakePersistent(plMaxNode *node, plAGAnim *anim, const char *animName, plErrorMsg *pErrMsg); + hsBool MakePersistent(plMaxNode *node, plAGAnim *anim, const plString &animName, plErrorMsg *pErrMsg); virtual void CollectNonDrawables(INodeTab& nonDrawables) { AddTargetsToList(nonDrawables); } @@ -218,15 +218,16 @@ hsBool plAnimAvatarComponent::ConvertNode(plMaxNode *node, plErrorMsg *pErrMsg) // does this node have any segments specified? if (noteAnim.HasNotetracks()) { - // for each segment we found: - while (const char *animName = noteAnim.GetNextAnimName()) + // for each segment we found: + plString animName; + while (!(animName = noteAnim.GetNextAnimName()).IsNull()) { plAnimInfo info = noteAnim.GetAnimInfo(animName); plATCAnim *anim = NewAnimation(info.GetAnimName(), info.GetAnimStart(), info.GetAnimEnd()); - const char *loopName = info.GetNextLoopName(); - if (loopName) + plString loopName = info.GetNextLoopName(); + if (!loopName.IsNull()) { anim->SetLoop(true); float loopStart = info.GetLoopStart(loopName); @@ -234,7 +235,8 @@ hsBool plAnimAvatarComponent::ConvertNode(plMaxNode *node, plErrorMsg *pErrMsg) anim->SetLoopStart(loopStart == -1 ? anim->GetStart() : loopStart); anim->SetLoopEnd(loopEnd == -1 ? anim->GetEnd() : loopEnd); } - while (const char *marker = info.GetNextMarkerName()) + plString marker; + while (!(marker = info.GetNextMarkerName()).IsNull()) anim->AddMarker(marker, info.GetMarkerTime(marker)); ConvertNodeSegmentBranch(node, anim, pErrMsg); @@ -252,7 +254,7 @@ hsBool plAnimAvatarComponent::ConvertNode(plMaxNode *node, plErrorMsg *pErrMsg) // NewAnimation ------------------------------------------------------------------------- // ------------- -plATCAnim * plAnimAvatarComponent::NewAnimation(const char *name, double begin, double end) +plATCAnim * plAnimAvatarComponent::NewAnimation(const plString &name, double begin, double end) { return new plATCAnim(name, begin, end); } @@ -268,7 +270,7 @@ hsBool plAnimAvatarComponent::ConvertNodeSegmentBranch(plMaxNode *node, plAGAnim { // Check for a suppression marker plNotetrackAnim noteAnim(node, pErrMsg); - plAnimInfo info = noteAnim.GetAnimInfo(nil); + plAnimInfo info = noteAnim.GetAnimInfo(plString::Null); hsBool suppressed = info.IsSuppressed(mod->GetName()); // Get the affine parts and the TM Controller @@ -336,7 +338,7 @@ plKey FindSceneNode(plMaxNode *node) // Perform wizardry necessary to make the object save itself. // // -hsBool plAnimAvatarComponent::MakePersistent(plMaxNode *node, plAGAnim *anim, const char *animName, plErrorMsg *pErrMsg) +hsBool plAnimAvatarComponent::MakePersistent(plMaxNode *node, plAGAnim *anim, const plString &animName, plErrorMsg *pErrMsg) { // new approach: add to the generic pool on the scene node plLocation nodeLoc = node->GetLocation(); @@ -379,7 +381,7 @@ public: plEmoteComponent(); virtual hsBool Convert(plMaxNode *node, plErrorMsg *pErrMsg); - virtual plATCAnim * NewAnimation(const char *name, double begin, double end); + virtual plATCAnim * NewAnimation(const plString &name, double begin, double end); protected: float fFadeIn; @@ -455,7 +457,7 @@ hsBool plEmoteComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) // NewAnimation ---------------------------------------------------------------------- // ------------- -plATCAnim * plEmoteComponent::NewAnimation(const char *name, double begin, double end) +plATCAnim * plEmoteComponent::NewAnimation(const plString &name, double begin, double end) { return new plEmoteAnim(name, begin, end, fFadeIn, fFadeOut, fBodyUsage); } diff --git a/Sources/Tools/MaxComponent/plAnimCompProc.cpp b/Sources/Tools/MaxComponent/plAnimCompProc.cpp index 150b524a..c1e65fdc 100644 --- a/Sources/Tools/MaxComponent/plAnimCompProc.cpp +++ b/Sources/Tools/MaxComponent/plAnimCompProc.cpp @@ -313,11 +313,12 @@ void plMtlAnimProc::ILoadAnimCombo(HWND hWnd, IParamBlock2* pb) if (mtl) { plNotetrackAnim anim(mtl, nil); - while (const char* animName = anim.GetNextAnimName()) + plString animName; + while (!(animName = anim.GetNextAnimName()).IsNull()) { - int idx = ComboBox_AddString(hAnim, animName); + int idx = ComboBox_AddString(hAnim, animName.c_str()); ComboBox_SetItemData(hAnim, idx, 1); - if (!strcmp(animName, savedName)) + if (!animName.Compare(savedName)) ComboBox_SetCurSel(hAnim, idx); } diff --git a/Sources/Tools/MaxComponent/plAnimComponent.cpp b/Sources/Tools/MaxComponent/plAnimComponent.cpp index cf5b0c31..ab44d51a 100644 --- a/Sources/Tools/MaxComponent/plAnimComponent.cpp +++ b/Sources/Tools/MaxComponent/plAnimComponent.cpp @@ -607,12 +607,12 @@ plAnimComponentBase::plAnimComponentBase() : fNeedReset(true) } -const char *plAnimComponentBase::GetAnimName() +plString plAnimComponentBase::GetAnimName() { const char *name = fCompPB->GetStr(kAnimName); if (!name || name[0] == '\0') - return nil; - return name; + return plString::Null; + return plString::FromUtf8(name); } bool IsSubworld(plMaxNode* node) @@ -697,7 +697,7 @@ hsBool plAnimComponentBase::PreConvert(plMaxNode *node, plErrorMsg *pErrMsg) { if (!node->HasAGMod()) // Need to add this before the MasterMod, if it doesn't have one already. { - node->AddModifier(new plAGModifier(node->GetName()), IGetUniqueName(node)); + node->AddModifier(new plAGModifier(plString::FromUtf8(node->GetName())), IGetUniqueName(node)); } mod = new plAGMasterMod(); @@ -717,9 +717,9 @@ hsBool plAnimComponentBase::PreConvert(plMaxNode *node, plErrorMsg *pErrMsg) // we've added all keys during convert. Some cleanup might // be necessary in this case. - const char *animName = fCompPB->GetStr(kAnimName); - if (animName == nil || !strcmp(animName, "")) - animName = ENTIRE_ANIMATION_NAME; + plString animName = plString::FromUtf8(fCompPB->GetStr(kAnimName)); + if (animName.IsEmpty()) + animName = _TEMP_CONVERT_FROM_LITERAL(ENTIRE_ANIMATION_NAME); if (fCompPB->GetInt(ParamID(kAnimUseGlobal))) { @@ -748,7 +748,7 @@ hsBool plAnimComponentBase::PreConvert(plMaxNode *node, plErrorMsg *pErrMsg) if (fCompPB->GetInt(kAnimLoop)) { ATCAnim->SetLoop(true); - const char *loopName = fCompPB->GetStr(kAnimLoopName); + plString loopName = plString::FromUtf8(fCompPB->GetStr(kAnimLoopName)); float loopStart = info.GetLoopStart(loopName); float loopEnd = info.GetLoopEnd(loopName); @@ -756,10 +756,12 @@ hsBool plAnimComponentBase::PreConvert(plMaxNode *node, plErrorMsg *pErrMsg) ATCAnim->SetLoopEnd(loopEnd == -1 ? ATCAnim->GetEnd() : loopEnd); } - while (const char *loop = info.GetNextLoopName()) + plString loop; + while (!(loop = info.GetNextLoopName()).IsNull()) ATCAnim->AddLoop(loop, info.GetLoopStart(loop), info.GetLoopEnd(loop)); - while (const char *marker = info.GetNextMarkerName()) + plString marker; + while (!(marker = info.GetNextMarkerName()).IsNull()) ATCAnim->AddMarker(marker, info.GetMarkerTime(marker)); float stopPoint = -1; @@ -790,7 +792,7 @@ hsBool plAnimComponentBase::IAddTMToAnim(plMaxNode *node, plAGAnim *anim, plErro hsAffineParts * parts = new hsAffineParts; plController* tmc; - if (!strcmp(anim->GetName(), ENTIRE_ANIMATION_NAME)) + if (!anim->GetName().Compare(ENTIRE_ANIMATION_NAME)) tmc = hsControlConverter::Instance().ConvertTMAnim(obj, node, parts); else tmc = hsControlConverter::Instance().ConvertTMAnim(obj, node, parts, anim->GetStart(), anim->GetEnd()); @@ -798,11 +800,11 @@ hsBool plAnimComponentBase::IAddTMToAnim(plMaxNode *node, plAGAnim *anim, plErro if (tmc) { plMatrixChannelApplicator *app = new plMatrixChannelApplicator(); - app->SetChannelName(node->GetName()); + app->SetChannelName(plString::FromUtf8(node->GetName())); plMatrixControllerChannel *channel = new plMatrixControllerChannel(tmc, parts); app->SetChannel(channel); anim->AddApplicator(app); - if (!strcmp(anim->GetName(), ENTIRE_ANIMATION_NAME)) + if (!anim->GetName().Compare(ENTIRE_ANIMATION_NAME)) anim->ExtendToLength(tmc->GetLength()); result = true; } @@ -861,7 +863,7 @@ hsBool plAnimComponentBase::IConvertNodeSegmentBranch(plMaxNode *node, plAGAnim // It has an animation, we're going to need a plAGMod when loading the anim if (!node->HasAGMod()) { - node->AddModifier(new plAGModifier(node->GetName()), IGetUniqueName(node)); + node->AddModifier(new plAGModifier(plString::FromUtf8(node->GetName())), IGetUniqueName(node)); } madeAnim = true; } @@ -883,8 +885,7 @@ hsBool plAnimComponentBase::IMakePersistent(plMaxNode *node, plAGAnim *anim, plE plAGMasterMod *mod = plAGMasterMod::ConvertNoRef(fMods[node]); hsAssert(mod != nil, "No MasterMod to make animation persistent!"); - char buffer[256]; - sprintf(buffer, "%s_%s_anim_%d", node->GetName(), anim->GetName(), mod->GetNumPrivateAnimations()); + plString buffer = plString::Format("%s_%s_anim_%d", node->GetName(), anim->GetName().c_str(), mod->GetNumPrivateAnimations()); plLocation nodeLoc = node->GetLocation(); plKey animKey = hsgResMgr::ResMgr()->NewKey(buffer, anim, nodeLoc); @@ -935,7 +936,7 @@ void plAnimComponentBase::SetupCtl( plAGAnim *anim, plController *ctl, plAGAppli plScalarControllerChannel *channel = new plScalarControllerChannel(ctl); app->SetChannel(channel); anim->AddApplicator(app); - if (!strcmp(anim->GetName(), ENTIRE_ANIMATION_NAME)) + if (!anim->GetName().Compare(ENTIRE_ANIMATION_NAME)) anim->ExtendToLength(ctl->GetLength()); } @@ -989,12 +990,12 @@ void plAnimComponentBase::PickTargetNode( IParamBlock2 *destPB, ParamID destP pick.DoPick(); } -const char *plAnimComponentBase::GetIfaceSegmentName( hsBool allowNil ) +plString plAnimComponentBase::GetIfaceSegmentName( hsBool allowNil ) { - const char *name = GetAnimName(); - if( allowNil || name != nil ) + plString name = GetAnimName(); + if( allowNil || !name.IsNull() ) return name; - return ENTIRE_ANIMATION_NAME; + return _TEMP_CONVERT_FROM_LITERAL( ENTIRE_ANIMATION_NAME ); } //// Hit Callback for Animations ///////////////////////////////////////////// diff --git a/Sources/Tools/MaxComponent/plAnimComponent.h b/Sources/Tools/MaxComponent/plAnimComponent.h index 5d8626c2..26f0d972 100644 --- a/Sources/Tools/MaxComponent/plAnimComponent.h +++ b/Sources/Tools/MaxComponent/plAnimComponent.h @@ -115,7 +115,7 @@ public: hsBool DeInit(plMaxNode *node, plErrorMsg *pErrMsg); virtual plKey GetModKey(plMaxNode *node)=0; - const char *GetAnimName(); + plString GetAnimName(); static hsBool IsAnimComponent(plComponentBase *comp); std::map fAnims; @@ -132,7 +132,7 @@ public: // plAnimObjInterface functions virtual void PickTargetNode( IParamBlock2 *destPB, ParamID destParamID, ParamID typeID ); virtual hsBool IsNodeRestricted( void ) { return true; } - virtual const char *GetIfaceSegmentName( hsBool allowNil ); + virtual plString GetIfaceSegmentName( hsBool allowNil ); protected: hsBool IAddTMToAnim(plMaxNode *node, plAGAnim *anim, plErrorMsg *pErrMsg); diff --git a/Sources/Tools/MaxComponent/plAnimEventComponent.cpp b/Sources/Tools/MaxComponent/plAnimEventComponent.cpp index dff4715c..13c98e86 100644 --- a/Sources/Tools/MaxComponent/plAnimEventComponent.cpp +++ b/Sources/Tools/MaxComponent/plAnimEventComponent.cpp @@ -183,7 +183,7 @@ hsBool plAnimEventComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) // Create and setup the callback message // plKey animKey = animComp->GetModKey(animNode); - const char* animName = animComp->GetAnimName(); + plString animName = animComp->GetAnimName(); plAnimCmdMsg *animMsg = new plAnimCmdMsg; animMsg->SetCmd(plAnimCmdMsg::kAddCallbacks); @@ -209,7 +209,7 @@ hsBool plAnimEventComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) int numMarkers = fCompPB->Count(kAnimMarkers); for (int i = 0; i < numMarkers; i++) { - const char* marker = fCompPB->GetStr(kAnimMarkers, 0, i); + plString marker = plString::FromUtf8(fCompPB->GetStr(kAnimMarkers, 0, i)); float time = info.GetMarkerTime(marker); plEventCallbackMsg *eventMsg = CreateCallbackMsg(animMsg, modKey); @@ -255,12 +255,12 @@ static int ListBox_AddStringData(HWND hList, const char* text, int data) return idx; } -static bool IsMarkerSelected(IParamBlock2* pb, int paramID, const char* marker, bool remove=false) +static bool IsMarkerSelected(IParamBlock2* pb, int paramID, const plString& marker, bool remove=false) { int numMarkers = pb->Count(paramID); for (int i = 0; i < numMarkers; i++) { - if (hsStrEQ(marker, pb->GetStr(paramID, 0, i))) + if (marker.Compare(pb->GetStr(paramID, 0, i)) == 0) { if (remove) pb->Delete(paramID, i, 1); @@ -279,7 +279,7 @@ static void RemoveDeadMarkers(IParamBlock2* pb, int paramID, plAnimInfo& info) int numMarkers = pb->Count(paramID); for (int i = numMarkers-1; i >= 0; i--) { - float time = info.GetMarkerTime(pb->GetStr(paramID, 0, i)); + float time = info.GetMarkerTime(plString::FromUtf8(pb->GetStr(paramID, 0, i))); if (time == -1) { pb->Delete(paramID, i, 1); @@ -328,9 +328,10 @@ void plAnimEventProc::ILoadUser(HWND hWnd, IParamBlock2* pb) RemoveDeadMarkers(pb, kAnimMarkers, info); // Get all the markers in this animation - while (const char* marker = info.GetNextMarkerName()) + plString marker; + while (!(marker = info.GetNextMarkerName()).IsNull()) { - idx = ListBox_AddStringData(hList, marker, kAnimEventMarker); + idx = ListBox_AddStringData(hList, marker.c_str(), kAnimEventMarker); if (IsMarkerSelected(pb, kAnimMarkers, marker)) ListBox_SetSel(hList, TRUE, idx); @@ -355,16 +356,17 @@ bool plAnimEventProc::IUserCommand(HWND hWnd, IParamBlock2* pb, int cmd, int res { char buf[256]; ListBox_GetText(hList, idx, buf); + plString text = plString::FromUtf8(buf); if (selected) { - if (!IsMarkerSelected(pb, kAnimMarkers, buf)) + if (!IsMarkerSelected(pb, kAnimMarkers, text)) { TCHAR* name = buf; pb->Append(kAnimMarkers, 1, &name); } } else - IsMarkerSelected(pb, kAnimMarkers, buf, true); + IsMarkerSelected(pb, kAnimMarkers, text, true); } return true; @@ -480,7 +482,7 @@ hsBool plMtlEventComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) Mtl* mtl = fCompPB->GetMtl(kMtlMtl); plMaxNodeBase* mtlNode = (plMaxNodeBase*)fCompPB->GetINode(kMtlNode); - const char* mtlAnim = fCompPB->GetStr(kMtlAnim); + plString mtlAnim = plString::FromUtf8(fCompPB->GetStr(kMtlAnim)); // // Create and setup the callback message @@ -512,7 +514,7 @@ hsBool plMtlEventComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) int numMarkers = fCompPB->Count(kMtlMarkers); for (int i = 0; i < numMarkers; i++) { - const char* marker = fCompPB->GetStr(kMtlMarkers, 0, i); + plString marker = plString::FromUtf8(fCompPB->GetStr(kMtlMarkers, 0, i)); float time = info.GetMarkerTime(marker); plEventCallbackMsg *eventMsg = CreateCallbackMsg(animMsg, modKey); @@ -576,7 +578,7 @@ void plMtlEventProc::ILoadUser(HWND hWnd, IParamBlock2* pb) if (mtl) { - const char* mtlAnim = pb->GetStr(kMtlAnim); + plString mtlAnim = plString::FromUtf8(pb->GetStr(kMtlAnim)); // Get the shared animations for all the nodes this component is applied to plNotetrackAnim anim(mtl, nil); @@ -585,9 +587,10 @@ void plMtlEventProc::ILoadUser(HWND hWnd, IParamBlock2* pb) RemoveDeadMarkers(pb, kMtlMarkers, info); // Get all the markers in this animation - while (const char* marker = info.GetNextMarkerName()) + plString marker; + while (!(marker = info.GetNextMarkerName()).IsNull()) { - idx = ListBox_AddStringData(hList, marker, kAnimEventMarker); + idx = ListBox_AddStringData(hList, marker.c_str(), kAnimEventMarker); if (IsMarkerSelected(pb, kMtlMarkers, marker)) ListBox_SetSel(hList, TRUE, idx); @@ -612,16 +615,17 @@ bool plMtlEventProc::IUserCommand(HWND hWnd, IParamBlock2* pb, int cmd, int resI { char buf[256]; ListBox_GetText(hList, idx, buf); + plString text = plString::FromUtf8(buf); if (selected) { - if (!IsMarkerSelected(pb, kMtlMarkers, buf)) + if (!IsMarkerSelected(pb, kMtlMarkers, text)) { TCHAR* name = buf; pb->Append(kMtlMarkers, 1, &name); } } else - IsMarkerSelected(pb, kMtlMarkers, buf, true); + IsMarkerSelected(pb, kMtlMarkers, text, true); } return true; diff --git a/Sources/Tools/MaxComponent/plAnimObjInterface.h b/Sources/Tools/MaxComponent/plAnimObjInterface.h index f7552761..d6d76dad 100644 --- a/Sources/Tools/MaxComponent/plAnimObjInterface.h +++ b/Sources/Tools/MaxComponent/plAnimObjInterface.h @@ -51,6 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #define _plAnimObjInterface_h #include "hsTemplates.h" +#include "plString.h" class plAnimObjInterface { @@ -79,7 +80,7 @@ class plAnimObjInterface // Return the name of the segment/animation that this interface references. Pass "false" to get the // ENTIRE_ANIMATION_NAME string for entire animations, "true" for nil. - virtual const char *GetIfaceSegmentName( hsBool allowNil ) = 0; + virtual plString GetIfaceSegmentName( hsBool allowNil ) = 0; // This animation would require (depending on the node restriction) a separate material (i.e. material anim) virtual hsBool MightRequireSeparateMaterial( void ) { return false; } diff --git a/Sources/Tools/MaxComponent/plAudioComponents.cpp b/Sources/Tools/MaxComponent/plAudioComponents.cpp index 4cc106c7..eeae85c9 100644 --- a/Sources/Tools/MaxComponent/plAudioComponents.cpp +++ b/Sources/Tools/MaxComponent/plAudioComponents.cpp @@ -614,13 +614,16 @@ plSoundBuffer *plBaseSoundEmitterComponent::GetSourceBuffer( const char *fileN plSoundBuffer *plBaseSoundEmitterComponent::IGetSourceBuffer( const char *fileName, plMaxNode *srcNode, uint32_t srcBufferFlags ) { plKey key; - char keyName[ MAX_PATH ]; + plString keyName; char fullPath[ MAX_PATH ]; - strcpy( keyName, fileName ); - ::PathStripPath( keyName ); - + // ***TEMP plString REVISIT*** + char tempPath[ MAX_PATH ]; + strncpy(tempPath, fileName, MAX_PATH); + ::PathStripPath( tempPath ); + keyName = _TEMP_CONVERT_FROM_LITERAL( tempPath ); + // TEMP HACK until we get packed sounds: // Given the source filename, we check to see if it's in our plasma game directory. If not, or if // it's out of date, we copy it over. We'll truncate the filename inside plSoundBuffer when we're ready. @@ -635,7 +638,7 @@ plSoundBuffer *plBaseSoundEmitterComponent::IGetSourceBuffer( const char *file plFileUtils::CreateDir( fullPath ); // Now finish the path... - strcat( fullPath, keyName ); + strcat( fullPath, _TEMP_CONVERT_TO_CONST_CHAR( keyName ) ); // Check filestamp WIN32_FILE_ATTRIBUTE_DATA oldFileAttrib, newFileAttrib; @@ -664,9 +667,9 @@ plSoundBuffer *plBaseSoundEmitterComponent::IGetSourceBuffer( const char *file // Additional info for the keyName--need some flag mangling, specifically for the left/right channel mangling if( srcBufferFlags & plSoundBuffer::kOnlyLeftChannel ) - strcat( keyName, ":L" ); + keyName += _TEMP_CONVERT_FROM_LITERAL( ":L" ); else if( srcBufferFlags & plSoundBuffer::kOnlyRightChannel ) - strcat( keyName, ":R" ); + keyName += _TEMP_CONVERT_FROM_LITERAL( ":R" ); key = srcNode->FindPageKey( plSoundBuffer::Index(), keyName ); if( key != nil ) @@ -890,8 +893,8 @@ void plBaseSoundEmitterComponent::ISetBaseParameters( plSound *destSound, plE { destSound->SetProperty( plSound::kPropLooping, true ); - const char *loop = fCompPB->GetStr((ParamID)kSoundLoopName); - if (loop && loop[0] != '\0') + plString loop = plString::FromUtf8( fCompPB->GetStr((ParamID)kSoundLoopName) ); + if (!loop.IsEmpty()) { SegmentMap *segMap = GetCompWaveSegmentMap( GetSoundFileName( kBaseSound ) ); if (segMap && segMap->find(loop) != segMap->end()) @@ -915,7 +918,7 @@ hsBool plBaseSoundEmitterComponent::AddToAnim( plAGAnim *anim, plMaxNode *node hsControlConverter& cc = hsControlConverter::Instance(); float start, end; - if (!strcmp(anim->GetName(), ENTIRE_ANIMATION_NAME)) + if (!anim->GetName().Compare(ENTIRE_ANIMATION_NAME)) { start = end = -1; } @@ -937,7 +940,7 @@ hsBool plBaseSoundEmitterComponent::AddToAnim( plAGAnim *anim, plMaxNode *node std::map::iterator i = fIndices.begin(); plSoundVolumeApplicator *app = new plSoundVolumeApplicator( (*i).second ); - app->SetChannelName(node->GetName()); + app->SetChannelName(plString::FromUtf8(node->GetName())); plAnimComponentBase::SetupCtl( anim, ctl, app, node ); result = true; } @@ -1817,10 +1820,10 @@ public: for (SegmentMap::iterator it = segMap->begin(); it != segMap->end(); it++) { SegmentSpec *spec = it->second; - int idx = SendMessage(hLoop, CB_ADDSTRING, 0, (LPARAM)spec->fName); + int idx = SendMessage(hLoop, CB_ADDSTRING, 0, (LPARAM)spec->fName.c_str()); SendMessage(hLoop, CB_SETITEMDATA, idx, 1); - if (!strcmp(spec->fName, loop)) + if (!spec->fName.Compare(loop)) SendMessage(hLoop, CB_SETCURSEL, idx, 0); } @@ -2185,8 +2188,7 @@ hsBool plSound3DEmitterComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) plWinAudible* pAudible = (plWinAudible*)ai->GetAudible(); - char keyName[ 256 ]; - sprintf( keyName, "%s", GetINode()->GetName()); + plString keyName = plString::FromUtf8(GetINode()->GetName()); plWin32Sound *sound = nil; @@ -2219,7 +2221,7 @@ hsBool plSound3DEmitterComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) // Converts an array of components into a single grouped sound hsBool plSound3DEmitterComponent::ConvertGrouped( plMaxNode *baseNode, hsTArray &groupArray, plErrorMsg *pErrMsg ) { - char keyName[ 256 ]; + plString keyName; if( !fValidNodes[ baseNode ] || !fCreateGrouped ) @@ -2340,7 +2342,7 @@ hsBool plSound3DEmitterComponent::ConvertGrouped( plMaxNode *baseNode, hsTArray if( fIndices.find( baseNode ) != fIndices.end() ) index = fIndices[ baseNode ]; - sprintf( keyName, "%s_MergedSound", GetINode()->GetName() ); + keyName = plString::Format( "%s_MergedSound", GetINode()->GetName() ); plKey buffKey = baseNode->FindPageKey( plSoundBuffer::Index(), keyName ); if( buffKey != nil ) @@ -2361,7 +2363,7 @@ hsBool plSound3DEmitterComponent::ConvertGrouped( plMaxNode *baseNode, hsTArray const plAudioInterface* ai = baseNode->GetSceneObject()->GetAudioInterface(); plWinAudible* pAudible = (plWinAudible*)ai->GetAudible(); - sprintf( keyName, "%s", GetINode()->GetName()); + keyName = plString::FromUtf8(GetINode()->GetName()); plWin32GroupedSound *sound = new plWin32GroupedSound; sound->SetPositionArray( startPoses.GetCount(), startPoses.AcquireArray(), volumes.AcquireArray() ); sound->SetProperty( plSound::kPropLoadOnlyOnCall, true ); @@ -2508,8 +2510,7 @@ hsBool plBackgroundMusicComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) if( srcBuffer == nil ) return false; - char keyName[ 256 ]; - sprintf( keyName, "%s_Win32BgndSnd", GetINode()->GetName() ); + plString keyName = plString::Format( "%s_Win32BgndSnd", GetINode()->GetName() ); plWin32Sound *sound = nil; if( srcBuffer->GetDataLengthInSecs() > 4.f ) @@ -2667,8 +2668,7 @@ hsBool plGUISoundComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) return false; } - char keyName[ 256 ]; - sprintf( keyName, "%s_Win32GUISound", GetINode()->GetName() ); + plString keyName = plString::Format( "%s_Win32GUISound", GetINode()->GetName() ); plWin32StaticSound *sound = new plWin32StaticSound; hsgResMgr::ResMgr()->NewKey(keyName, sound, node->GetLocation(), node->GetLoadMask()); diff --git a/Sources/Tools/MaxComponent/plAutoUIParams.cpp b/Sources/Tools/MaxComponent/plAutoUIParams.cpp index d586b7f5..963686ce 100644 --- a/Sources/Tools/MaxComponent/plAutoUIParams.cpp +++ b/Sources/Tools/MaxComponent/plAutoUIParams.cpp @@ -1605,7 +1605,7 @@ plKey plPickMaterialAnimationButtonParam::GetKey(IParamBlock2 *pb, int idx) } // this is in plResponderMtl.cpp -extern int GetMatAnimModKey(Mtl* mtl, plMaxNodeBase* node, const char* segName, hsTArray& keys);; +extern int GetMatAnimModKey(Mtl* mtl, plMaxNodeBase* node, const plString& segName, hsTArray& keys);; void plPickMaterialAnimationButtonParam::CreateKeyArray(IParamBlock2* pb) { @@ -1613,7 +1613,7 @@ void plPickMaterialAnimationButtonParam::CreateKeyArray(IParamBlock2* pb) Mtl* mtl = (Mtl*)pb->GetReferenceTarget(fID); - int bob = GetMatAnimModKey(mtl, nil, nil, fKeys); + int bob = GetMatAnimModKey(mtl, nil, plString::Null, fKeys); } void plPickMaterialAnimationButtonParam::DestroyKeyArray() diff --git a/Sources/Tools/MaxComponent/plAvatarComponent.cpp b/Sources/Tools/MaxComponent/plAvatarComponent.cpp index 09883a82..f1bfe28f 100644 --- a/Sources/Tools/MaxComponent/plAvatarComponent.cpp +++ b/Sources/Tools/MaxComponent/plAvatarComponent.cpp @@ -264,11 +264,11 @@ hsBool plArmatureComponent::Convert(plMaxNode* node, plErrorMsg *pErrMsg) { // MakeCharacterHierarchy will attach agmodifiers to all the bones in the hierarchy; // have to manually add any for non-bone objects... - agMod = new plAGModifier("Handle"); // the player root is known as the handle + agMod = new plAGModifier(_TEMP_CONVERT_FROM_LITERAL("Handle")); // the player root is known as the handle node->AddModifier(agMod, IGetUniqueName(node)); } - agMod->SetChannelName("Handle"); + agMod->SetChannelName(_TEMP_CONVERT_FROM_LITERAL("Handle")); // Get the position and radius of the head and torso physicals if (ClassID() == AVATAR_CLASS_ID || ClassID() == LOD_AVATAR_CLASS_ID) @@ -453,7 +453,7 @@ plAvatarComponent::plAvatarComponent() void plAvatarComponent::IAttachModifiers(plMaxNode *node, plErrorMsg *pErrMsg) { - const char *name = node->GetKey()->GetName(); + plString name = node->GetKey()->GetName(); plMaxNode *meshNode = (plMaxNode *)fCompPB->GetINode(plAvatarComponent::kMeshNode); plKey meshKey = meshNode->GetSceneObject()->GetKey(); @@ -476,7 +476,7 @@ void plAvatarComponent::IAttachModifiers(plMaxNode *node, plErrorMsg *pErrMsg) avMod->SetBodyAgeName(node->GetAgeName()); avMod->SetBodyFootstepSoundPage(fCompPB->GetStr(ParamID(kBodyFootstepSoundPage))); - avMod->SetAnimationPrefix(fCompPB->GetStr(ParamID(kAnimationPrefix))); + avMod->SetAnimationPrefix(plString::FromUtf8(fCompPB->GetStr(ParamID(kAnimationPrefix)))); //AddLinkSound(node, node->GetSceneObject()->GetKey(), pErrMsg ); @@ -491,7 +491,7 @@ void plAvatarComponent::IAttachModifiers(plMaxNode *node, plErrorMsg *pErrMsg) void AddClothingToMod(plMaxNode *node, plArmatureMod *mod, int group, hsGMaterial *mat, plErrorMsg *pErrMsg) { plGenRefMsg *msg; - char keyName[256]; + plString keyName; TSTR sdata; hsStringTokenizer toker; @@ -509,11 +509,11 @@ void AddClothingToMod(plMaxNode *node, plArmatureMod *mod, int group, hsGMateria } else base->SetLayoutName("BasicHuman"); - sprintf(keyName, "%s_ClothingBase", node->GetName()); + keyName = plString::Format("%s_ClothingBase", node->GetName()); hsgResMgr::ResMgr()->NewKey(keyName, base, node->GetLocation()); plClothingOutfit *outfit = new plClothingOutfit(); outfit->fGroup = group; - sprintf(keyName, "%s_outfit", mod->GetKey()->GetName()); + keyName = plString::Format("%s_outfit", mod->GetKey()->GetName().c_str()); hsgResMgr::ResMgr()->NewKey(keyName, outfit, node->GetLocation()); msg = new plGenRefMsg(outfit->GetKey(), plRefMsg::kOnCreate, -1, -1); @@ -682,10 +682,10 @@ hsBool plCompoundCtrlComponent::SetupProperties(plMaxNode *node, plErrorMsg *pEr hsBool plCompoundCtrlComponent::Convert(plMaxNode* node, plErrorMsg *pErrMsg) { - const char *name = node->GetKey()->GetName(); + plString name = node->GetKey()->GetName(); node->MakeCharacterHierarchy(pErrMsg); - node->SetupBonesAliasesRecur(name); + node->SetupBonesAliasesRecur(_TEMP_CONVERT_TO_CONST_CHAR(name)); // create and register the player modifier @@ -1052,7 +1052,7 @@ plLODAvatarComponent::plLODAvatarComponent() : fMaterial(nil) void plLODAvatarComponent::IAttachModifiers( plMaxNode *node, plErrorMsg *pErrMsg) { - const char *avatarName = node->GetKey()->GetName(); + plString avatarName = node->GetKey()->GetName(); plMaxNode *animRoot = (plMaxNode *)fCompPB->GetINode(plLODAvatarComponent::kRootNodeAddBtn); plKey animRootKey = animRoot->GetSceneObject()->GetKey(); plArmatureLODMod* avMod = new plArmatureLODMod(avatarName); @@ -1066,7 +1066,7 @@ void plLODAvatarComponent::IAttachModifiers( plMaxNode *node, plErrorMsg *pEr avMod->SetBodyAgeName(node->GetAgeName()); avMod->SetBodyFootstepSoundPage(fCompPB->GetStr(ParamID(kBodyFootstepSoundPage))); - avMod->SetAnimationPrefix(fCompPB->GetStr(ParamID(kAnimationPrefix))); + avMod->SetAnimationPrefix(plString::FromUtf8(fCompPB->GetStr(ParamID(kAnimationPrefix)))); int iLODCount = fCompPB->Count(plLODAvatarComponent::kMeshNodeTab); for (int i = 0; i < iLODCount; i++) diff --git a/Sources/Tools/MaxComponent/plClickDragComponent.cpp b/Sources/Tools/MaxComponent/plClickDragComponent.cpp index 50fa6f32..bda40ed3 100644 --- a/Sources/Tools/MaxComponent/plClickDragComponent.cpp +++ b/Sources/Tools/MaxComponent/plClickDragComponent.cpp @@ -448,12 +448,12 @@ hsBool plClickDragComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) pCall2->AddReceiver(axisKey); plAnimCmdMsg* pMsg = new plAnimCmdMsg; - const char *tempAnimName = pAnim->GetAnimName(); - if (tempAnimName == nil) + plString tempAnimName = pAnim->GetAnimName(); + if (tempAnimName.IsNull()) { //pMsg->SetAnimName(ENTIRE_ANIMATION_NAME); pMsg->SetAnimName(pAnim->GetModKey(node)->GetName()); - pAxis->SetAnimLabel(ENTIRE_ANIMATION_NAME); + pAxis->SetAnimLabel(_TEMP_CONVERT_FROM_LITERAL(ENTIRE_ANIMATION_NAME)); } else { diff --git a/Sources/Tools/MaxComponent/plComponentBase.cpp b/Sources/Tools/MaxComponent/plComponentBase.cpp index f71e8c56..b5662291 100644 --- a/Sources/Tools/MaxComponent/plComponentBase.cpp +++ b/Sources/Tools/MaxComponent/plComponentBase.cpp @@ -279,10 +279,8 @@ bool plComponentBase::IsTarget(plMaxNodeBase *node) return false; } -const char* plComponentBase::IGetUniqueName(plMaxNodeBase* target) +plString plComponentBase::IGetUniqueName(plMaxNodeBase* target) { - static char nameBuf[256]; - // Make sure we've actually got multiple *used* targets. (Some could be nil) int numUsedTargs = 0; int thisTargIdx = -1; @@ -305,11 +303,9 @@ const char* plComponentBase::IGetUniqueName(plMaxNodeBase* target) hsAssert(thisTargIdx != -1, "Bad target for IGetUniqueName"); if (numUsedTargs > 1) - _snprintf(nameBuf, sizeof(nameBuf), "%s_%d", GetINode()->GetName(), thisTargIdx); + return plString::Format("%s_%d", GetINode()->GetName(), thisTargIdx); else - strncpy(nameBuf, GetINode()->GetName(), sizeof(nameBuf)); - - return nameBuf; + return plString::FromUtf8(GetINode()->GetName()); } plMaxNodeBase *plComponentBase::GetINode() diff --git a/Sources/Tools/MaxComponent/plComponentBase.h b/Sources/Tools/MaxComponent/plComponentBase.h index 274aa485..817a51a9 100644 --- a/Sources/Tools/MaxComponent/plComponentBase.h +++ b/Sources/Tools/MaxComponent/plComponentBase.h @@ -70,7 +70,7 @@ protected: // Get a unique name based on this components name and the index of this target // Return value points to a static, so don't try to hold on to it - const char* IGetUniqueName(plMaxNodeBase* target); + plString IGetUniqueName(plMaxNodeBase* target); public: // Permanent Block ID's diff --git a/Sources/Tools/MaxComponent/plComponentTools.cpp b/Sources/Tools/MaxComponent/plComponentTools.cpp index 34181434..bc166c95 100644 --- a/Sources/Tools/MaxComponent/plComponentTools.cpp +++ b/Sources/Tools/MaxComponent/plComponentTools.cpp @@ -50,7 +50,7 @@ plKey plComponentTools::AddModifier(plMaxNodeBase *node, plModifier *mod) return fAddModFunc(node, mod); } -plKey plComponentTools::GetNewKey(const char *name, plModifier *mod, plLocation loc) +plKey plComponentTools::GetNewKey(const plString &name, plModifier *mod, plLocation loc) { return fNewKey(name, mod, loc); } @@ -70,12 +70,12 @@ plKey plComponentTools::GetAnimCompLightModKey(plComponentBase *comp, plMaxNodeB return fAnimLightKey(comp, node); } */ -const char *plComponentTools::GetAnimCompAnimName(plComponentBase *comp) +plString plComponentTools::GetAnimCompAnimName(plComponentBase *comp) { return fAnimName(comp); } -int plComponentTools::GetMaterialAnimModKey(Mtl* mtl, plMaxNodeBase* node, const char *segName, hsTArray& keys) +int plComponentTools::GetMaterialAnimModKey(Mtl* mtl, plMaxNodeBase* node, const plString &segName, hsTArray& keys) { return fMatMod(mtl, node, segName, keys); } diff --git a/Sources/Tools/MaxComponent/plComponentTools.h b/Sources/Tools/MaxComponent/plComponentTools.h index 600afe84..9e076d1b 100644 --- a/Sources/Tools/MaxComponent/plComponentTools.h +++ b/Sources/Tools/MaxComponent/plComponentTools.h @@ -55,11 +55,11 @@ class plComponentBase; class plMaxNodeBase; typedef plKey (*PAddModFunc) (plMaxNodeBase *, plModifier *); -typedef plKey (*PGetNewKeyFunc) (const char*, plModifier*, plLocation); +typedef plKey (*PGetNewKeyFunc) (const plString&, plModifier*, plLocation); typedef void (*PSetActivatorKeyFunc) (plMaxNodeBase*, plMaxNodeBase*, plMaxNodeBase*, plResponderModifier*); typedef plKey (*PGetAnimModKeyFunc) (plComponentBase*, plMaxNodeBase*); -typedef const char* (*PGetAnimNameFunc) (plComponentBase*); -typedef int (*PGetMaterialAnimModKeyFunc) (Mtl* mtl, plMaxNodeBase* node, const char *segName, hsTArray& keys); +typedef plString (*PGetAnimNameFunc) (plComponentBase*); +typedef int (*PGetMaterialAnimModKeyFunc) (Mtl* mtl, plMaxNodeBase* node, const plString &segName, hsTArray& keys); typedef int (*PGetSoundNameAndIndex) (plComponentBase*, plMaxNodeBase* node, const char*& name); // @@ -101,14 +101,14 @@ public: {} plKey AddModifier(plMaxNodeBase *node, plModifier *mod); - plKey GetNewKey(const char *name, plModifier *mod, plLocation loc); + plKey GetNewKey(const plString &name, plModifier *mod, plLocation loc); void SetActivatorKey(plMaxNodeBase *activatorNode, plMaxNodeBase *responderNode, plMaxNodeBase *convertNode, plResponderModifier *responderLogic); - const char *GetAnimCompAnimName(plComponentBase *comp); + plString GetAnimCompAnimName(plComponentBase *comp); plKey GetAnimCompModKey(plComponentBase *comp, plMaxNodeBase *node); // plKey GetAnimCompLightModKey(plComponentBase *comp, plMaxNodeBase *node); - int GetMaterialAnimModKey(Mtl* mtl, plMaxNodeBase* node, const char *segName, hsTArray& keys); + int GetMaterialAnimModKey(Mtl* mtl, plMaxNodeBase* node, const plString &segName, hsTArray& keys); int GetSoundNameAndIndex(plComponentBase* comp, plMaxNodeBase* node, const char*& name); }; diff --git a/Sources/Tools/MaxComponent/plFootstepComponent.cpp b/Sources/Tools/MaxComponent/plFootstepComponent.cpp index 4c8131b8..71ba371d 100644 --- a/Sources/Tools/MaxComponent/plFootstepComponent.cpp +++ b/Sources/Tools/MaxComponent/plFootstepComponent.cpp @@ -115,7 +115,7 @@ hsBool plFootstepSoundComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) plArmatureEffectFootSound *effect = new plArmatureEffectFootSound(); // Note: MUST be a hard-coded keyname, since we search for same name in plArmatureMod.cpp - hsgResMgr::ResMgr()->NewKey( "FootstepSounds", effect, node->GetLocation()); + hsgResMgr::ResMgr()->NewKey( _TEMP_CONVERT_FROM_LITERAL("FootstepSounds"), effect, node->GetLocation()); int i; for (i = 0; i < plArmatureEffectsMgr::kMaxSurface; i++) diff --git a/Sources/Tools/MaxComponent/plGUIComponents.cpp b/Sources/Tools/MaxComponent/plGUIComponents.cpp index 10038a33..49c764f3 100644 --- a/Sources/Tools/MaxComponent/plGUIComponents.cpp +++ b/Sources/Tools/MaxComponent/plGUIComponents.cpp @@ -1319,7 +1319,7 @@ hsBool plGUIDialogComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) // Add it to the sceneNode as a generic interface, so it gets loaded with the sceneNode plLocation nodeLoc = sceneNodeKey->GetUoid().GetLocation(); - plKey modKey = hsgResMgr::ResMgr()->NewKey( fCompPB->GetStr( kRefDialogName ), mod, nodeLoc ); + plKey modKey = hsgResMgr::ResMgr()->NewKey( plString::FromUtf8( fCompPB->GetStr( kRefDialogName ) ), mod, nodeLoc ); hsgResMgr::ResMgr()->AddViaNotify( modKey, new plNodeRefMsg( sceneNodeKey, plRefMsg::kOnCreate, -1, plNodeRefMsg::kGeneric ), plRefFlags::kActiveRef ); // Also add our dialog mod to the scene node in the same way @@ -1360,7 +1360,7 @@ hsBool plGUIDialogComponent::PreConvert(plMaxNode *node, plErrorMsg *pErrMsg) fCompPB->GetStr( kRefDialogName ), (uint32_t)-1 ); plLocation nodeLoc = sceneNodeKey->GetUoid().GetLocation(); - plKey dlgKey = hsgResMgr::ResMgr()->NewKey( fCompPB->GetStr( kRefDialogName ), fDialogMod, nodeLoc ); + plKey dlgKey = hsgResMgr::ResMgr()->NewKey( plString::FromUtf8( fCompPB->GetStr( kRefDialogName ) ), fDialogMod, nodeLoc ); fDialogMod->SetSceneNodeKey( sceneNodeKey ); @@ -2728,7 +2728,7 @@ hsBool plGUIKnobCtrlComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) plAGMasterMod *master = node->GetAGMasterMod(); hsTArray keys; keys.Append( master->GetKey() ); - ctrl->SetAnimationKeys( keys, ENTIRE_ANIMATION_NAME ); + ctrl->SetAnimationKeys( keys, _TEMP_CONVERT_FROM_LITERAL( ENTIRE_ANIMATION_NAME ) ); } if( fCompPB->GetInt( kRefOrientation ) == 1 ) @@ -4450,7 +4450,7 @@ hsBool plGUIProgressCtrlComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) plAGMasterMod *master = node->GetAGMasterMod(); hsTArray keys; keys.Append( master->GetKey() ); - ctrl->SetAnimationKeys( keys, ENTIRE_ANIMATION_NAME ); + ctrl->SetAnimationKeys( keys, _TEMP_CONVERT_FROM_LITERAL( ENTIRE_ANIMATION_NAME ) ); } const char *errMsg = ISetSoundIndex( kRefAnimateSound, kRefAnimateSoundComp, pfGUIProgressCtrl::kAnimateSound, node ); diff --git a/Sources/Tools/MaxComponent/plInventoryObjComponent.cpp b/Sources/Tools/MaxComponent/plInventoryObjComponent.cpp index 13b03360..af18367c 100644 --- a/Sources/Tools/MaxComponent/plInventoryObjComponent.cpp +++ b/Sources/Tools/MaxComponent/plInventoryObjComponent.cpp @@ -187,8 +187,7 @@ hsBool plInventoryObjComponent::PreConvert(plMaxNode *node, plErrorMsg *pErrMsg) // Create and register the ClickDrag's logic component plLogicModifier *logic = new plLogicModifier; - char tmpName[256]; - sprintf(tmpName, "%s_%s_LogicModifier", obj->GetKeyName(), GetINode()->GetName()); + plString tmpName = plString::Format("%s_%s_LogicModifier", obj->GetKeyName().c_str(), GetINode()->GetName()); plKey logicKey = hsgResMgr::ResMgr()->NewKey(tmpName, logic, node->GetLocation()); hsgResMgr::ResMgr()->AddViaNotify(logicKey, new plObjRefMsg(obj->GetKey(), plRefMsg::kOnCreate, -1, plObjRefMsg::kModifier), plRefFlags::kActiveRef); diff --git a/Sources/Tools/MaxComponent/plMaxAnimUtils.cpp b/Sources/Tools/MaxComponent/plMaxAnimUtils.cpp index e9157a3f..450863e4 100644 --- a/Sources/Tools/MaxComponent/plMaxAnimUtils.cpp +++ b/Sources/Tools/MaxComponent/plMaxAnimUtils.cpp @@ -58,11 +58,11 @@ float TimeValueToGameTime(TimeValue t) return float(t)/float(TPS); } -bool GetSegMapAnimTime(const char *animName, SegmentMap *segMap, SegmentSpec::SegType type, float& begin, float& end) +bool GetSegMapAnimTime(const plString &animName, SegmentMap *segMap, SegmentSpec::SegType type, float& begin, float& end) { if (segMap) { - if (animName && segMap->find(animName) != segMap->end()) + if (!animName.IsNull() && segMap->find(animName) != segMap->end()) { SegmentSpec *spec = (*segMap)[animName]; if (spec->fType == type) @@ -124,14 +124,13 @@ SegmentMap *GetSharedAnimSegmentMap(std::vector& anims, plErrorMsg return segMap; } -SegmentSpec::SegmentSpec(float start, float end, char * name, SegType type) : +SegmentSpec::SegmentSpec(float start, float end, const plString & name, SegType type) : fStart(start), fEnd(end), fName(name), fType(type), fInitial(-1) { } SegmentSpec::~SegmentSpec() { - delete [] fName; } // constants used for parsing the note tracks @@ -154,7 +153,6 @@ SegmentSpec::SegmentSpec() fStart = -1; fEnd = -1; fInitial = -1; - fName = nil; fType = kAnim; } @@ -211,7 +209,10 @@ void GetSegment(const char *note, float time, SegmentMap *segMap, plErrorMsg *pE char segSuffix[256]; int matchedFields = sscanf(note, " %[^@] @ %s ", segName, segSuffix); - + + plString name = _TEMP_CONVERT_FROM_LITERAL(segName); + plString suffix = _TEMP_CONVERT_FROM_LITERAL(segSuffix); + if (matchedFields == 2) { NoteType type = kNoteUnknown; @@ -249,7 +250,7 @@ void GetSegment(const char *note, float time, SegmentMap *segMap, plErrorMsg *pE } else { - SegmentMap::iterator existing = segMap->find(segName); + SegmentMap::iterator existing = segMap->find(name); SegmentSpec *existingSpec = (existing != segMap->end()) ? (*existing).second : nil; const char *kErrorTitle = "NoteTrack Anim Error"; @@ -304,37 +305,33 @@ void GetSegment(const char *note, float time, SegmentMap *segMap, plErrorMsg *pE } else { - char *nameCopy = new char[strlen(segName)+1]; - strcpy(nameCopy, segName); - switch (type) { case kNoteStartAnim: - (*segMap)[nameCopy] = new SegmentSpec(time, -1, nameCopy, SegmentSpec::kAnim); + (*segMap)[name] = new SegmentSpec(time, -1, name, SegmentSpec::kAnim); break; case kNoteStartLoop: - (*segMap)[nameCopy] = new SegmentSpec(time, -1, nameCopy, SegmentSpec::kLoop); + (*segMap)[name] = new SegmentSpec(time, -1, name, SegmentSpec::kLoop); break; case kNoteEndLoop: - (*segMap)[nameCopy] = new SegmentSpec(-1, time, nameCopy, SegmentSpec::kLoop); + (*segMap)[name] = new SegmentSpec(-1, time, name, SegmentSpec::kLoop); break; case kNoteMarker: - (*segMap)[nameCopy] = new SegmentSpec(time, -1, nameCopy, SegmentSpec::kMarker); + (*segMap)[name] = new SegmentSpec(time, -1, name, SegmentSpec::kMarker); break; case kNoteStopPoint: - (*segMap)[nameCopy] = new SegmentSpec(time, -1, nameCopy, SegmentSpec::kStopPoint); + (*segMap)[name] = new SegmentSpec(time, -1, name, SegmentSpec::kStopPoint); break; case kNoteSuppress: - (*segMap)[nameCopy] = new SegmentSpec(-1, -1, nameCopy, SegmentSpec::kSuppress); + (*segMap)[name] = new SegmentSpec(-1, -1, name, SegmentSpec::kSuppress); break; default: - delete [] nameCopy; break; } } diff --git a/Sources/Tools/MaxComponent/plMaxAnimUtils.h b/Sources/Tools/MaxComponent/plMaxAnimUtils.h index 2af1541a..8e687f04 100644 --- a/Sources/Tools/MaxComponent/plMaxAnimUtils.h +++ b/Sources/Tools/MaxComponent/plMaxAnimUtils.h @@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include #include "hsStlSortUtils.h" +#include "plString.h" class plErrorMsg; class Animatable; @@ -59,11 +60,11 @@ public: float fStart; // beginning of the segment in game time float fEnd; // end of the segment in game time float fInitial; // initial position of the animation (-1 for the start) - char * fName; // name of the segment: controls lifespan of the name + plString fName; // name of the segment: controls lifespan of the name SegType fType; SegmentSpec(); - SegmentSpec(float start, float end, char * name, SegType); + SegmentSpec(float start, float end, const plString & name, SegType); ~SegmentSpec(); bool Contains(SegmentSpec *spec); @@ -71,7 +72,7 @@ public: // a table mapping segment names to segment spec objects -typedef std::map SegmentMap; +typedef std::map SegmentMap; // You can pass in nil for pErrMsg for silent operation SegmentMap *GetAnimSegmentMap(Animatable *anim, plErrorMsg *pErrMsg); @@ -80,7 +81,7 @@ void DeleteSegmentMap(SegmentMap *segMap); SegmentMap *GetSharedAnimSegmentMap(std::vector& anims, plErrorMsg *pErrorMsg); -bool GetSegMapAnimTime(const char *animName, SegmentMap *segMap, SegmentSpec::SegType type, float& begin, float& end); +bool GetSegMapAnimTime(const plString &animName, SegmentMap *segMap, SegmentSpec::SegType type, float& begin, float& end); // For internal use void GetSegment(const char *note, float time, SegmentMap *segMap, plErrorMsg *pErrMsg); diff --git a/Sources/Tools/MaxComponent/plNotetrackAnim.cpp b/Sources/Tools/MaxComponent/plNotetrackAnim.cpp index 6555b578..6aa6159c 100644 --- a/Sources/Tools/MaxComponent/plNotetrackAnim.cpp +++ b/Sources/Tools/MaxComponent/plNotetrackAnim.cpp @@ -79,10 +79,10 @@ plNotetrackAnim::~plNotetrackAnim() DeleteSegmentMap(fSegMap); } -const char *plNotetrackAnim::GetNextAnimName() +plString plNotetrackAnim::GetNextAnimName() { if (!fSegMap) - return nil; + return plString::Null; while (fAnimIt != fSegMap->end()) { @@ -94,28 +94,28 @@ const char *plNotetrackAnim::GetNextAnimName() } fAnimIt = fSegMap->begin(); - return nil; + return plString::Null; } -plAnimInfo plNotetrackAnim::GetAnimInfo(const char *animName) +plAnimInfo plNotetrackAnim::GetAnimInfo(const plString &animName) { if (!fSegMap) return plAnimInfo(); - if (!animName || *animName == '\0' || fSegMap->find(animName) == fSegMap->end()) - return plAnimInfo(fSegMap, nil); + if (animName.IsEmpty() || fSegMap->find(animName) == fSegMap->end()) + return plAnimInfo(fSegMap, plString::Null); else - return plAnimInfo(fSegMap, animName); + return plAnimInfo(fSegMap, animName); return plAnimInfo(); } //////////////////////////////////////////////////////////////////////////////// -plAnimInfo::plAnimInfo(SegmentMap *segMap, const char *animName) +plAnimInfo::plAnimInfo(SegmentMap *segMap, const plString &animName) { fSegMap = segMap; - fAnimSpec = animName ? (*fSegMap)[animName] : nil; + fAnimSpec = !animName.IsNull() ? (*fSegMap)[animName] : nil; if (fSegMap) { @@ -125,9 +125,9 @@ plAnimInfo::plAnimInfo(SegmentMap *segMap, const char *animName) } } -const char *plAnimInfo::GetAnimName() +plString plAnimInfo::GetAnimName() { - return fAnimSpec ? fAnimSpec->fName : nil; + return fAnimSpec ? fAnimSpec->fName : plString::Null; } float plAnimInfo::GetAnimStart() @@ -145,10 +145,10 @@ float plAnimInfo::GetAnimInitial() return fAnimSpec ? fAnimSpec->fInitial : -1; } -const char *plAnimInfo::GetNextLoopName() +plString plAnimInfo::GetNextLoopName() { if (!fSegMap) - return nil; + return plString::Null; while (fLoopIt != fSegMap->end()) { @@ -161,12 +161,12 @@ const char *plAnimInfo::GetNextLoopName() } fLoopIt = fSegMap->begin(); - return nil; + return plString::Null; } -float plAnimInfo::GetLoopStart(const char *loopName) +float plAnimInfo::GetLoopStart(const plString &loopName) { - if (!fSegMap || loopName == nil) + if (!fSegMap || loopName.IsNull()) return -1; if (fSegMap->find(loopName) != fSegMap->end()) @@ -181,9 +181,9 @@ float plAnimInfo::GetLoopStart(const char *loopName) return -1; } -float plAnimInfo::GetLoopEnd(const char *loopName) +float plAnimInfo::GetLoopEnd(const plString &loopName) { - if (!fSegMap || loopName == nil) + if (!fSegMap || loopName.IsNull()) return -1; if (fSegMap->find(loopName) != fSegMap->end()) @@ -198,10 +198,10 @@ float plAnimInfo::GetLoopEnd(const char *loopName) return -1; } -const char *plAnimInfo::GetNextMarkerName() +plString plAnimInfo::GetNextMarkerName() { if (!fSegMap) - return nil; + return plString::Null; while (fMarkerIt != fSegMap->end()) { @@ -214,10 +214,10 @@ const char *plAnimInfo::GetNextMarkerName() } fMarkerIt = fSegMap->begin(); - return nil; + return plString::Null; } -float plAnimInfo::GetMarkerTime(const char *markerName) +float plAnimInfo::GetMarkerTime(const plString &markerName) { if (!fSegMap) return -1; @@ -250,9 +250,9 @@ float plAnimInfo::GetNextStopPoint() return -1; } -bool plAnimInfo::IsSuppressed(const char *animName) +bool plAnimInfo::IsSuppressed(const plString &animName) { - if (!fSegMap || animName == nil) + if (!fSegMap || animName.IsNull()) return false; if (fSegMap->find(animName) != fSegMap->end()) diff --git a/Sources/Tools/MaxComponent/plNotetrackAnim.h b/Sources/Tools/MaxComponent/plNotetrackAnim.h index 6dc51d1f..b527fb2f 100644 --- a/Sources/Tools/MaxComponent/plNotetrackAnim.h +++ b/Sources/Tools/MaxComponent/plNotetrackAnim.h @@ -56,22 +56,22 @@ protected: public: plAnimInfo() : fSegMap(NULL), fAnimSpec(NULL) {} - plAnimInfo(SegmentMap *segMap, const char *animName); + plAnimInfo(SegmentMap *segMap, const plString &animName); - const char *GetAnimName(); + plString GetAnimName(); float GetAnimStart(); float GetAnimEnd(); float GetAnimInitial(); - const char *GetNextLoopName(); - float GetLoopStart(const char *loopName); - float GetLoopEnd(const char *loopName); + plString GetNextLoopName(); + float GetLoopStart(const plString &loopName); + float GetLoopEnd(const plString &loopName); - const char *GetNextMarkerName(); - float GetMarkerTime(const char *markerName); + plString GetNextMarkerName(); + float GetMarkerTime(const plString &markerName); float GetNextStopPoint(); // Returns -1 on last stop point - bool IsSuppressed(const char *animName); + bool IsSuppressed(const plString &animName); }; class plNotetrackAnim @@ -88,8 +88,8 @@ public: bool HasNotetracks() { return (fSegMap != NULL); } - const char *GetNextAnimName(); - plAnimInfo GetAnimInfo(const char *animName); + plString GetNextAnimName(); + plAnimInfo GetAnimInfo(const plString &animName); }; -#endif //PL_NOTETRACK_ANIM \ No newline at end of file +#endif //PL_NOTETRACK_ANIM diff --git a/Sources/Tools/MaxComponent/plNotetrackDlg.cpp b/Sources/Tools/MaxComponent/plNotetrackDlg.cpp index d452ffde..2bd77f41 100644 --- a/Sources/Tools/MaxComponent/plNotetrackDlg.cpp +++ b/Sources/Tools/MaxComponent/plNotetrackDlg.cpp @@ -129,11 +129,11 @@ void plNoteTrackDlg::ILoadAnims() SegmentSpec *spec = it->second; if (spec->fType == SegmentSpec::kAnim) { - int idx = ComboBox_AddString(fhAnim, spec->fName); + int idx = ComboBox_AddString(fhAnim, spec->fName.c_str()); ComboBox_SetItemData(fhAnim, idx, kName); // If this is the saved animation name, select it - if (!strcmp(spec->fName, savedAnim)) + if (!spec->fName.Compare(savedAnim)) ComboBox_SetCurSel(fhAnim, idx); } } @@ -155,8 +155,8 @@ void plNoteTrackDlg::ILoadLoops() { // Get the animation segment (or leave it nil if we're using the entire animation) SegmentSpec *animSpec = nil; - const char *animName = fPB->GetStr(fAnimID); - if (animName && *animName != '\0' && fSegMap->find(animName) != fSegMap->end()) + plString animName = plString::FromUtf8(fPB->GetStr(fAnimID)); + if (!animName.IsEmpty() && fSegMap->find(animName) != fSegMap->end()) animSpec = (*fSegMap)[animName]; // Get the saved loop name @@ -174,10 +174,10 @@ void plNoteTrackDlg::ILoadLoops() if (!animSpec || animSpec->Contains(spec)) { // Add the name - int idx = ComboBox_AddString(fhLoop, spec->fName); + int idx = ComboBox_AddString(fhLoop, spec->fName.c_str()); ComboBox_SetItemData(fhLoop, idx, kName); - if (!strcmp(loopName, spec->fName)) + if (!spec->fName.Compare(loopName)) ComboBox_SetCurSel(fhLoop, idx); } } @@ -192,7 +192,7 @@ const char *plNoteTrackDlg::IGetSel(HWND hCombo) { char buf[256]; ComboBox_GetText(hCombo, buf, sizeof(buf)); - return (*fSegMap)[buf]->fName; + return (*fSegMap)[plString::FromUtf8(buf)]->fName.c_str(); } return ""; diff --git a/Sources/Tools/MaxComponent/plObjectFlockerComponent.cpp b/Sources/Tools/MaxComponent/plObjectFlockerComponent.cpp index e69917bc..03877df1 100644 --- a/Sources/Tools/MaxComponent/plObjectFlockerComponent.cpp +++ b/Sources/Tools/MaxComponent/plObjectFlockerComponent.cpp @@ -271,7 +271,7 @@ hsBool plObjectFlockerComponent::PreConvert(plMaxNode *node, plErrorMsg *pErrMsg hsBool plObjectFlockerComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) { - node->AddModifier(fFlocker, nil); + node->AddModifier(fFlocker, plString::Null); return true; } diff --git a/Sources/Tools/MaxComponent/plParticleComponents.cpp b/Sources/Tools/MaxComponent/plParticleComponents.cpp index fe19769c..3bee66b9 100644 --- a/Sources/Tools/MaxComponent/plParticleComponents.cpp +++ b/Sources/Tools/MaxComponent/plParticleComponents.cpp @@ -165,7 +165,7 @@ hsBool plParticleCoreComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) int32_t i, j, k; plLocation nodeLoc = node->GetKey()->GetUoid().GetLocation(); - const char *objName = node->GetKey()->GetName(); + plString objName = node->GetKey()->GetName(); plSceneObject *sObj = node->GetSceneObject(); plParticleSystem *sys = new plParticleSystem(); @@ -518,7 +518,7 @@ hsBool plParticleCoreComponent::AddToAnim(plAGAnim *anim, plMaxNode *node) hsControlConverter& cc = hsControlConverter::Instance(); float start, end; - if (!strcmp(anim->GetName(), ENTIRE_ANIMATION_NAME)) + if (!anim->GetName().Compare(ENTIRE_ANIMATION_NAME)) { start = end = -1; } @@ -1051,7 +1051,7 @@ void plParticleVolumeComponent::BuildVolume(plMaxNode *node) return; // already converted it fBound = new plBoundInterface; - hsgResMgr::ResMgr()->NewKey(node->GetName(), fBound, node->GetLocation(), node->GetLoadMask()); + hsgResMgr::ResMgr()->NewKey(plString::FromUtf8(node->GetName()), fBound, node->GetLocation(), node->GetLoadMask()); fBound->Init(plMeshConverter::Instance().CreateConvexVolume(node)); hsgResMgr::ResMgr()->AddViaNotify(fBound->GetKey(), new plObjRefMsg(node->GetKey(), plRefMsg::kOnCreate, -1, plObjRefMsg::kInterface), plRefFlags::kActiveRef); } diff --git a/Sources/Tools/MaxComponent/plPhysicalComponents.cpp b/Sources/Tools/MaxComponent/plPhysicalComponents.cpp index 7dc18d04..b2a8b7ad 100644 --- a/Sources/Tools/MaxComponent/plPhysicalComponents.cpp +++ b/Sources/Tools/MaxComponent/plPhysicalComponents.cpp @@ -1325,19 +1325,19 @@ hsBool plSwim2DComponent::PreConvert(plMaxNode *node, plErrorMsg *pErrMsg) case kCurrentSpiral: { fSwimRegions[node] = new plSwimCircularCurrentRegion(); - hsgResMgr::ResMgr()->NewKey(node->GetName(), fSwimRegions[node], node->GetLocation(), node->GetLoadMask()); + hsgResMgr::ResMgr()->NewKey(plString::FromUtf8(node->GetName()), fSwimRegions[node], node->GetLocation(), node->GetLoadMask()); break; } case kCurrentStraight: { fSwimRegions[node] = new plSwimStraightCurrentRegion(); - hsgResMgr::ResMgr()->NewKey(node->GetName(), fSwimRegions[node], node->GetLocation(), node->GetLoadMask()); + hsgResMgr::ResMgr()->NewKey(plString::FromUtf8(node->GetName()), fSwimRegions[node], node->GetLocation(), node->GetLoadMask()); break; } default: { fSwimRegions[node] = new plSwimRegionInterface(); - hsgResMgr::ResMgr()->NewKey(node->GetName(), fSwimRegions[node], node->GetLocation(), node->GetLoadMask()); + hsgResMgr::ResMgr()->NewKey(plString::FromUtf8(node->GetName()), fSwimRegions[node], node->GetLocation(), node->GetLoadMask()); break; } } diff --git a/Sources/Tools/MaxComponent/plPythonFileComponent.cpp b/Sources/Tools/MaxComponent/plPythonFileComponent.cpp index ad04ea10..f08f0457 100644 --- a/Sources/Tools/MaxComponent/plPythonFileComponent.cpp +++ b/Sources/Tools/MaxComponent/plPythonFileComponent.cpp @@ -102,7 +102,7 @@ class plCommonPythonLib : public plCommonObjLib if( objectKey->GetUoid().GetClassType() == plPythonFileMod::Index() ) return true; if( objectKey->GetUoid().GetClassType() == plSceneObject::Index() && - strcmp( objectKey->GetUoid().GetObjectName(), plSDL::kAgeSDLObjectName ) == 0 ) + objectKey->GetUoid().GetObjectName().Compare( plSDL::kAgeSDLObjectName ) == 0 ) return true; return false; } @@ -457,7 +457,7 @@ hsBool plPythonFileComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) break; case plAutoUIParam::kTypeString: - pyParam.SetToString(param->GetString(pb)); + pyParam.SetToString(_TEMP_CONVERT_FROM_LITERAL(param->GetString(pb))); mod->AddParameter(pyParam); break; @@ -805,9 +805,9 @@ hsBool plPythonFileComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) { plAnimComponentBase *animcomp = (plAnimComponentBase*)comp; // save out the animation name first - const char *tempAnimName = animcomp->GetAnimName(); - if (tempAnimName == nil) - pyParam.SetToAnimationName(ENTIRE_ANIMATION_NAME); + plString tempAnimName = animcomp->GetAnimName(); + if (tempAnimName.IsNull()) + pyParam.SetToAnimationName(_TEMP_CONVERT_FROM_LITERAL(ENTIRE_ANIMATION_NAME)); else pyParam.SetToAnimationName(tempAnimName); mod->AddParameter(pyParam); @@ -929,7 +929,7 @@ hsBool plPythonFileComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg) break; case plAutoUIParam::kTypeDropDownList: - pyParam.SetToString(param->GetString(pb)); + pyParam.SetToString(_TEMP_CONVERT_FROM_LITERAL(param->GetString(pb))); mod->AddParameter(pyParam); break; @@ -1074,13 +1074,13 @@ static BOOL CALLBACK WarnDialogProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM l switch (err.error) { - case plPythonFileComponent::Validate::kPythonBadVer: + case plPythonFileComponent::kPythonBadVer: ListView_SetItemText(hList, idx, 2, "Old Version"); break; - case plPythonFileComponent::Validate::kPythonNoVer: + case plPythonFileComponent::kPythonNoVer: ListView_SetItemText(hList, idx, 2, "No Version"); break; - case plPythonFileComponent::Validate::kPythonNoFile: + case plPythonFileComponent::kPythonNoFile: ListView_SetItemText(hList, idx, 2, "No File/Python Error"); break; } @@ -1119,10 +1119,10 @@ static void WriteBadPythonText(ErrorSet& badNodes) case plPythonFileComponent::kPythonBadVer: errorText = "Old Version"; break; - case plPythonFileComponent::Validate::kPythonNoVer: + case plPythonFileComponent::kPythonNoVer: errorText = "No Version"; break; - case plPythonFileComponent::Validate::kPythonNoFile: + case plPythonFileComponent::kPythonNoFile: errorText = "No File/Python Error"; break; } diff --git a/Sources/Tools/MaxComponent/plResponderAnim.cpp b/Sources/Tools/MaxComponent/plResponderAnim.cpp index 74305162..be20aa8e 100644 --- a/Sources/Tools/MaxComponent/plResponderAnim.cpp +++ b/Sources/Tools/MaxComponent/plResponderAnim.cpp @@ -333,7 +333,7 @@ plMessage *plResponderCmdAnim::ICreateAnimMsg(plMaxNode* node, plErrorMsg *pErrM plAnimCmdMsg *msg = new plAnimCmdMsg; msg->AddReceiver(animKey); - const char *tempAnimName = comp->GetAnimName(); + plString tempAnimName = comp->GetAnimName(); msg->SetAnimName(tempAnimName); // Create and initialize a message for the command @@ -364,7 +364,7 @@ plMessage *plResponderCmdAnim::ICreateAnimMsg(plMaxNode* node, plErrorMsg *pErrM // anims with a loop set in advance will actually work with this. -Colin // msg->SetCmd(plAnimCmdMsg::kSetLoopBegin); // msg->SetCmd(plAnimCmdMsg::kSetLoopEnd); - const char *loopName = pb->GetStr(kAnimLoop); + plString loopName = plString::FromUtf8(pb->GetStr(kAnimLoop)); msg->SetLoopName(loopName); } break; @@ -481,13 +481,14 @@ void plResponderCmdAnim::GetWaitPoints(IParamBlock2 *pb, WaitPoints& waitPoints) return; plAnimComponent *animComp = (plAnimComponent*)GetComponent(pb); - const char *animName = animComp->GetAnimName(); + plString animName = animComp->GetAnimName(); if (animComp) { plNotetrackAnim notetrackAnim(animComp, nil); plAnimInfo info = notetrackAnim.GetAnimInfo(animName); - while (const char *marker = info.GetNextMarkerName()) + plString marker; + while (!(marker = info.GetNextMarkerName()).IsNull()) waitPoints.push_back(marker); } } @@ -507,11 +508,11 @@ void plResponderCmdAnim::CreateWait(plMaxNode* node, plErrorMsg* pErrMsg, IParam eventMsg->fRepeats = 0; eventMsg->fUser = waitInfo.callbackUser; - if (waitInfo.point) + if (!waitInfo.point.IsNull()) { // FIXME COLIN - Error checking here? plAnimComponent *animComp = (plAnimComponent*)GetComponent(pb); - const char *animName = animComp->GetAnimName(); + plString animName = animComp->GetAnimName(); plNotetrackAnim notetrackAnim(animComp, nil); plAnimInfo info = notetrackAnim.GetAnimInfo(animName); @@ -752,18 +753,19 @@ void plResponderAnimProc::ILoadUser(HWND hWnd, IParamBlock2 *pb) plComponentBase *comp = plResponderCmdAnim::Instance().GetComponent(pb); if (comp && comp->ClassID() == ANIM_COMP_CID) { - const char *animName = ((plAnimComponent*)comp)->GetAnimName(); + plString animName = ((plAnimComponent*)comp)->GetAnimName(); // Get the shared animations for all the nodes this component is applied to plNotetrackAnim anim(comp, nil); plAnimInfo info = anim.GetAnimInfo(animName); // Get all the loops in this animation - while (const char *loopName = info.GetNextLoopName()) + plString loopName; + while (!(loopName = info.GetNextLoopName()).IsNull()) { - int idx = ComboBox_AddString(hLoop, loopName); + int idx = ComboBox_AddString(hLoop, loopName.c_str()); ComboBox_SetItemData(hLoop, idx, 1); - if (!strcmp(loopName, savedName)) + if (!loopName.Compare(savedName)) ComboBox_SetCurSel(hLoop, idx); } diff --git a/Sources/Tools/MaxComponent/plResponderCmd.h b/Sources/Tools/MaxComponent/plResponderCmd.h index 0a4c8706..2cf6557f 100644 --- a/Sources/Tools/MaxComponent/plResponderCmd.h +++ b/Sources/Tools/MaxComponent/plResponderCmd.h @@ -55,11 +55,11 @@ class plMaxNode; class ResponderWaitInfo { public: - const char* responderName; // For error messages + plString responderName; // For error messages plMessage *msg; // Message created by the responder command plKey receiver; // Key to send the callback message to - const char *point; // Marker name to wait on (nil for end) + plString point; // Marker name to wait on (nil for end) int callbackUser; // Value to set the callback user value to }; @@ -81,7 +81,7 @@ public: virtual void SetupProperties(plMaxNode* node, plErrorMsg* pErrMsg, IParamBlock2* pb) {} virtual plMessage *CreateMsg(plMaxNode* node, plErrorMsg* pErrMsg, IParamBlock2* pb)=0; - typedef std::vector WaitPoints; + typedef std::vector WaitPoints; // Can other commands wait on you? virtual bool IsWaitable(IParamBlock2 *pb) { return false; } // The names of the points commands can wait on (or leave empty for only 'end') diff --git a/Sources/Tools/MaxComponent/plResponderComponent.cpp b/Sources/Tools/MaxComponent/plResponderComponent.cpp index 8f6fcf18..a6cabda4 100644 --- a/Sources/Tools/MaxComponent/plResponderComponent.cpp +++ b/Sources/Tools/MaxComponent/plResponderComponent.cpp @@ -491,11 +491,11 @@ void plResponderComponent::ISetupDefaultWait(plMaxNode* node, plErrorMsg* pErrMs int convertedIdx = cmdIdxs[i]; ResponderWaitInfo waitInfo; - waitInfo.responderName = GetINode()->GetName(); + waitInfo.responderName = plString::FromUtf8(GetINode()->GetName()); waitInfo.receiver = responder->GetKey(); waitInfo.callbackUser = numCallbacks++; waitInfo.msg = cmds[convertedIdx].fMsg; - waitInfo.point = nil; + waitInfo.point = plString::Null; IParamBlock2 *pb = (IParamBlock2*)statePB->GetReferenceTarget(kStateCmdParams, 0, i); plResponderCmd *cmd = plResponderCmd::Find(pb); @@ -525,7 +525,7 @@ void plResponderComponent::IConvertCmdWaits(plMaxNode* node, plErrorMsg* pErrMsg int convertedIdx = cmdIdxs[wait]; ResponderWaitInfo waitInfo; - waitInfo.responderName = GetINode()->GetName(); + waitInfo.responderName = plString::FromUtf8(GetINode()->GetName()); waitInfo.receiver = responder->GetKey(); waitInfo.callbackUser = numCallbacks++; waitInfo.msg = cmds[convertedIdx].fMsg; diff --git a/Sources/Tools/MaxComponent/plResponderLink.cpp b/Sources/Tools/MaxComponent/plResponderLink.cpp index 6b0ea760..4ca2db98 100644 --- a/Sources/Tools/MaxComponent/plResponderLink.cpp +++ b/Sources/Tools/MaxComponent/plResponderLink.cpp @@ -1262,7 +1262,7 @@ void plResponderCmdDelay::CreateWait(plMaxNode* node, plErrorMsg* pErrMsg, IPara "However, you don't actually need two commands to wait on\n" "the same command since the first command will automatically\n" "delay any commands further down the list", - waitInfo.responderName, node->GetName()).Show(); + waitInfo.responderName.c_str(), node->GetName()).Show(); pErrMsg->Set(false); } else diff --git a/Sources/Tools/MaxComponent/plResponderMtl.cpp b/Sources/Tools/MaxComponent/plResponderMtl.cpp index 4feff3a5..494d42e2 100644 --- a/Sources/Tools/MaxComponent/plResponderMtl.cpp +++ b/Sources/Tools/MaxComponent/plResponderMtl.cpp @@ -250,12 +250,12 @@ Mtl *plResponderCmdMtl::GetMtl(IParamBlock2 *pb) return (Mtl*)pb->GetReferenceTarget(kMtlRef); } -const char *plResponderCmdMtl::GetAnim(IParamBlock2 *pb) +plString plResponderCmdMtl::GetAnim(IParamBlock2 *pb) { - return pb->GetStr(kMtlAnim); + return plString::FromUtf8(pb->GetStr(kMtlAnim)); } -void ISearchLayerRecur(plLayerInterface *layer, const char *segName, hsTArray& keys) +void ISearchLayerRecur(plLayerInterface *layer, const plString &segName, hsTArray& keys) { if (!layer) return; @@ -263,10 +263,8 @@ void ISearchLayerRecur(plLayerInterface *layer, const char *segName, hsTArrayGetSegmentID(); - if (ID == nil) - ID = ""; - if (!strcmp(ID, segName)) + plString ID = animLayer->GetSegmentID(); + if (!segName.Compare(ID)) { if( keys.kMissingIndex == keys.Find(animLayer->GetKey()) ) keys.Append(animLayer->GetKey()); @@ -276,17 +274,16 @@ void ISearchLayerRecur(plLayerInterface *layer, const char *segName, hsTArrayGetAttached(), segName, keys); } -int ISearchLayerRecur(hsGMaterial* mat, const char *segName, hsTArray& keys) +int ISearchLayerRecur(hsGMaterial* mat, const plString &segName, hsTArray& keys) { - if (segName == nil) - segName = ""; + plString name = segName.IsNull() ? _TEMP_CONVERT_FROM_LITERAL("") : segName; int i; for( i = 0; i < mat->GetNumLayers(); i++ ) - ISearchLayerRecur(mat->GetLayer(i), segName, keys); + ISearchLayerRecur(mat->GetLayer(i), name, keys); return keys.GetCount(); } -int GetMatAnimModKey(Mtl* mtl, plMaxNodeBase* node, const char* segName, hsTArray& keys) +int GetMatAnimModKey(Mtl* mtl, plMaxNodeBase* node, const plString& segName, hsTArray& keys) { int retVal = 0; @@ -336,7 +333,7 @@ plMessage *plResponderCmdMtl::CreateMsg(plMaxNode* node, plErrorMsg *pErrMsg, IP if (!maxMtl) throw "No material specified"; - const char *animName = pb->GetStr(kMtlAnim); + plString animName = plString::FromUtf8(pb->GetStr(kMtlAnim)); float begin=-1.f; float end = -1.f; @@ -357,9 +354,8 @@ plMessage *plResponderCmdMtl::CreateMsg(plMaxNode* node, plErrorMsg *pErrMsg, IP GetMatAnimModKey(maxMtl, mtlNode, animName, keys); - const char *loopName = nil; - loopName = pb->GetStr(kMtlLoop); - if (segMap && loopName) + plString loopName = plString::FromUtf8(pb->GetStr(kMtlLoop)); + if (segMap && !loopName.IsNull()) GetSegMapAnimTime(loopName, segMap, SegmentSpec::kLoop, begin, end); DeleteSegmentMap(segMap); @@ -445,13 +441,14 @@ bool plResponderCmdMtl::IsWaitable(IParamBlock2 *pb) void plResponderCmdMtl::GetWaitPoints(IParamBlock2 *pb, WaitPoints& waitPoints) { Mtl *mtl = GetMtl(pb); - const char *animName = GetAnim(pb); + plString animName = GetAnim(pb); if (mtl) { plNotetrackAnim notetrackAnim(mtl, nil); plAnimInfo info = notetrackAnim.GetAnimInfo(animName); - while (const char *marker = info.GetNextMarkerName()) + plString marker; + while (!(marker = info.GetNextMarkerName()).IsNull()) waitPoints.push_back(marker); } } @@ -468,11 +465,11 @@ void plResponderCmdMtl::CreateWait(plMaxNode* node, plErrorMsg* pErrMsg, IParamB eventMsg->fEvent = kStop; eventMsg->fUser = waitInfo.callbackUser; - if (waitInfo.point) + if (!waitInfo.point.IsNull()) { // FIXME COLIN - Error checking here? Mtl *mtl = GetMtl(pb); - const char *animName = GetAnim(pb); + plString animName = GetAnim(pb); plNotetrackAnim notetrackAnim(mtl, nil); plAnimInfo info = notetrackAnim.GetAnimInfo(animName); @@ -545,13 +542,14 @@ void plResponderMtlProc::ILoadUser(HWND hWnd, IParamBlock2 *pb) ComboBox_Enable(hLoop, TRUE); plNotetrackAnim anim(mtl, nil); - const char *animName = pb->GetStr(kMtlAnim); + plString animName = plString::FromUtf8(pb->GetStr(kMtlAnim)); plAnimInfo info = anim.GetAnimInfo(animName); - while (const char *loopName = info.GetNextLoopName()) + plString loopName; + while (!(loopName = info.GetNextLoopName()).IsNull()) { - sel = ComboBox_AddString(hLoop, loopName); - if (!strcmp(loopName, savedName)) + sel = ComboBox_AddString(hLoop, loopName.c_str()); + if (!loopName.Compare(savedName)) ComboBox_SetCurSel(hLoop, sel); } } diff --git a/Sources/Tools/MaxComponent/plResponderMtl.h b/Sources/Tools/MaxComponent/plResponderMtl.h index e0a9aa7f..a738f1a3 100644 --- a/Sources/Tools/MaxComponent/plResponderMtl.h +++ b/Sources/Tools/MaxComponent/plResponderMtl.h @@ -52,7 +52,7 @@ class Mtl; class plMaxNodeBase; template class hsTArray; -int GetMatAnimModKey(Mtl* mtl, plMaxNodeBase* node, const char *segName, hsTArray& keys); +int GetMatAnimModKey(Mtl* mtl, plMaxNodeBase* node, const plString &segName, hsTArray& keys); class plResponderCmdMtl : public plResponderCmd { @@ -74,7 +74,7 @@ public: virtual void CreateWait(plMaxNode* node, plErrorMsg* pErrMsg, IParamBlock2 *pb, ResponderWaitInfo& waitInfo); Mtl *GetMtl(IParamBlock2 *pb); - const char *GetAnim(IParamBlock2 *pb); + plString GetAnim(IParamBlock2 *pb); }; -int GetMatAnimModKey(Mtl* mtl, plMaxNodeBase* node, const char* segName, hsTArray& keys); +int GetMatAnimModKey(Mtl* mtl, plMaxNodeBase* node, const plString& segName, hsTArray& keys); diff --git a/Sources/Tools/MaxComponent/plResponderWait.cpp b/Sources/Tools/MaxComponent/plResponderWait.cpp index 1848f344..b4cb0edc 100644 --- a/Sources/Tools/MaxComponent/plResponderWait.cpp +++ b/Sources/Tools/MaxComponent/plResponderWait.cpp @@ -140,12 +140,12 @@ int ResponderWait::GetWaitingOn(IParamBlock2* waitPB) return waitPB->GetInt(kWaitWho); } -const char* ResponderWait::GetWaitPoint(IParamBlock2* waitPB) +plString ResponderWait::GetWaitPoint(IParamBlock2* waitPB) { const char* point = waitPB->GetStr(kWaitPoint); if (point && *point == '\0') - return nil; - return point; + return plString::Null; + return plString::FromUtf8(point); } ///////////////////////////////////////////////////////////////////////////// diff --git a/Sources/Tools/MaxComponent/plResponderWait.h b/Sources/Tools/MaxComponent/plResponderWait.h index 28bf797f..2af33065 100644 --- a/Sources/Tools/MaxComponent/plResponderWait.h +++ b/Sources/Tools/MaxComponent/plResponderWait.h @@ -46,6 +46,7 @@ class IParamBlock2; class plKey; class plMessage; class plResponderModifier; +class plString; namespace ResponderWait { @@ -62,5 +63,5 @@ namespace ResponderWait bool GetWaitOnMe(IParamBlock2* waitPB); int GetWaitingOn(IParamBlock2* waitPB); - const char* GetWaitPoint(IParamBlock2* waitPB); + plString GetWaitPoint(IParamBlock2* waitPB); } diff --git a/Sources/Tools/MaxComponent/plSoftVolumeComponent.cpp b/Sources/Tools/MaxComponent/plSoftVolumeComponent.cpp index 72f5725f..c741db6b 100644 --- a/Sources/Tools/MaxComponent/plSoftVolumeComponent.cpp +++ b/Sources/Tools/MaxComponent/plSoftVolumeComponent.cpp @@ -255,7 +255,7 @@ plKey plSoftVolBaseComponent::ISetVolumeKey(plSoftVolume* vol) break; } hsAssert(i < NumTargets(), "We're not attached to anything?"); - plKey key = hsgResMgr::ResMgr()->NewKey(GetINode()->GetName(), vol, GetTarget(i)->GetLocation()); + plKey key = hsgResMgr::ResMgr()->NewKey(plString::FromUtf8(GetINode()->GetName()), vol, GetTarget(i)->GetLocation()); return key; } @@ -1299,7 +1299,7 @@ void plVisRegionComponent::ICheckVisRegion(const plLocation& loc) return; fVisReg = new plVisRegion; - plKey key = hsgResMgr::ResMgr()->NewKey(GetINode()->GetName(), fVisReg, loc); + plKey key = hsgResMgr::ResMgr()->NewKey(plString::FromUtf8(GetINode()->GetName()), fVisReg, loc); hsBool excludes = fCompPB->GetInt(kExcludes); @@ -1465,7 +1465,7 @@ hsBool plRelevanceRegionComponent::Convert(plMaxNode *node, plErrorMsg *errMsg) return true; fRegion = new plRelevanceRegion; - plKey key = hsgResMgr::ResMgr()->NewKey(GetINode()->GetName(), fRegion, node->GetLocation()); + plKey key = hsgResMgr::ResMgr()->NewKey(plString::FromUtf8(GetINode()->GetName()), fRegion, node->GetLocation()); plGenRefMsg* refMsg = new plGenRefMsg(fRegion->GetKey(), plRefMsg::kOnCreate, 0, 0); hsgResMgr::ResMgr()->SendRef(softKey, refMsg, plRefFlags::kActiveRef); @@ -1561,7 +1561,7 @@ plVisRegion* plEffVisSetComponent::GetVisRegion(plMaxNode* node) if( !fVisReg ) { fVisReg = new plVisRegion; - plKey key = hsgResMgr::ResMgr()->NewKey(GetINode()->GetName(), fVisReg, node->GetLocation()); + plKey key = hsgResMgr::ResMgr()->NewKey(plString::FromUtf8(GetINode()->GetName()), fVisReg, node->GetLocation()); fVisReg->SetProperty(plVisRegion::kIsNot, false); fVisReg->SetProperty(plVisRegion::kReplaceNormal, fCompPB->GetInt(kHideNormal)); diff --git a/Sources/Tools/MaxComponent/plTypesComponents.cpp b/Sources/Tools/MaxComponent/plTypesComponents.cpp index 4d986e23..e44a5615 100644 --- a/Sources/Tools/MaxComponent/plTypesComponents.cpp +++ b/Sources/Tools/MaxComponent/plTypesComponents.cpp @@ -538,10 +538,11 @@ protected: HWND hCombo = GetDlgItem(hWnd, ctrlID); ComboBox_ResetContent(hCombo); - while (const char* animName = anim.GetNextAnimName()) + plString animName; + while (!(animName = anim.GetNextAnimName()).IsNull()) { - int sel = ComboBox_AddString(hCombo, animName); - if (hsStrEQ(animName, savedName)) + int sel = ComboBox_AddString(hCombo, animName.c_str()); + if (animName.Compare(savedName) == 0) ComboBox_SetCurSel(hCombo, sel); } } @@ -714,7 +715,7 @@ plKey plGameMarkerComponent::IGetMtlAnimKey(int paramID, plMaxNode* node) Mtl* mtl = fCompPB->GetMtl(kMarkerMtl); plMaxNode* mtlNode = (plMaxNode*)fCompPB->GetINode(kMarkerMtlNode); hsTArray keys; - const char* anim = fCompPB->GetStr(paramID); + plString anim = plString::FromUtf8(fCompPB->GetStr(paramID)); GetMatAnimModKey(mtl, mtlNode, anim, keys); hsAssert(keys.Count() == 1, "Wrong number of keys"); return keys[0]; diff --git a/Sources/Tools/MaxComponent/plVolumeGadgetComponent.cpp b/Sources/Tools/MaxComponent/plVolumeGadgetComponent.cpp index 5f0d0a34..c015e499 100644 --- a/Sources/Tools/MaxComponent/plVolumeGadgetComponent.cpp +++ b/Sources/Tools/MaxComponent/plVolumeGadgetComponent.cpp @@ -330,8 +330,7 @@ hsBool plVolumeGadgetComponent::PreConvert(plMaxNode *node, plErrorMsg *pErrMsg) if(fCompPB->GetInt(kVolumeGadgetEnter) || fCompPB->GetInt(kVolumeTriggerOnFacing)) { plLogicModifier *logic = new plLogicModifier; - char tmpName[256]; - sprintf(tmpName, "%s_Enter", IGetUniqueName(node)); + plString tmpName = plString::Format("%s_Enter", IGetUniqueName(node).c_str()); plKey logicKey = hsgResMgr::ResMgr()->NewKey(tmpName, logic, node->GetLocation()); hsgResMgr::ResMgr()->AddViaNotify(logicKey, new plObjRefMsg(obj->GetKey(), plRefMsg::kOnCreate, -1, plObjRefMsg::kModifier), plRefFlags::kActiveRef); @@ -345,8 +344,7 @@ hsBool plVolumeGadgetComponent::PreConvert(plMaxNode *node, plErrorMsg *pErrMsg) if(fCompPB->GetInt(kVolumeGadgetExit)) { plLogicModifier *logic = new plLogicModifier; - char tmpName[256]; - sprintf(tmpName, "%s_Exit", IGetUniqueName(node)); + plString tmpName = plString::Format("%s_Exit", IGetUniqueName(node).c_str()); plKey logicKey = hsgResMgr::ResMgr()->NewKey(tmpName, logic, node->GetLocation()); hsgResMgr::ResMgr()->AddViaNotify(logicKey, new plObjRefMsg(obj->GetKey(), plRefMsg::kOnCreate, -1, plObjRefMsg::kModifier), plRefFlags::kActiveRef); @@ -365,7 +363,6 @@ void plVolumeGadgetComponent::ICreateConditions(plMaxNode* node, plErrorMsg* err plLocation loc = node->GetLocation(); plSceneObject *obj = node->GetSceneObject(); - char tmpName[256]; plKey logicKey; if (enter) @@ -405,7 +402,7 @@ void plVolumeGadgetComponent::ICreateConditions(plMaxNode* node, plErrorMsg* err prefix = "Enter"; // Register the detector - sprintf(tmpName, "%s_%s", IGetUniqueName(node), prefix); + plString tmpName = plString::Format("%s_%s", IGetUniqueName(node).c_str(), prefix); plKey detectorKey = hsgResMgr::ResMgr()->NewKey(tmpName, detector, loc); hsgResMgr::ResMgr()->AddViaNotify(detectorKey, new plObjRefMsg(obj->GetKey(), plRefMsg::kOnCreate, -1, plObjRefMsg::kModifier), plRefFlags::kActiveRef); plVolumeSensorConditionalObject* boxCond=nil; @@ -417,7 +414,7 @@ void plVolumeGadgetComponent::ICreateConditions(plMaxNode* node, plErrorMsg* err { boxCond = new plVolumeSensorConditionalObjectNoArbitration; } - sprintf(tmpName, "%s_%s", IGetUniqueName(node), prefix); + tmpName = plString::Format("%s_%s", IGetUniqueName(node).c_str(), prefix); plKey boxKey = hsgResMgr::ResMgr()->NewKey(tmpName, boxCond, loc); if (enter) diff --git a/Sources/Tools/MaxComponent/plWaterComponent.cpp b/Sources/Tools/MaxComponent/plWaterComponent.cpp index a8138602..257d5654 100644 --- a/Sources/Tools/MaxComponent/plWaterComponent.cpp +++ b/Sources/Tools/MaxComponent/plWaterComponent.cpp @@ -568,7 +568,7 @@ hsBool plWaterComponent::IReadEnvObject(plMaxNode* node, plErrorMsg* pErrMsg, pl size = uint32_t(1 << i); env = new plDynamicEnvMap(size, size, 32); - hsgResMgr::ResMgr()->NewKey(ref->GetName(), env, node->GetLocation(), node->GetLoadMask()); + hsgResMgr::ResMgr()->NewKey(plString::FromUtf8(ref->GetName()), env, node->GetLocation(), node->GetLoadMask()); Point3 pos = ref->GetNodeTM(TimeValue(0)).GetTrans(); env->SetPosition(hsPoint3(pos.x, pos.y, pos.z)); @@ -1290,7 +1290,7 @@ plRenderTarget* plEnvMapComponent::IGetMap() fMap = cam = new plDynamicCamMap(size, size, 32); // Need to assign the key before we call all the setup functions. - hsgResMgr::ResMgr()->NewKey(GetINode()->GetName(), fMap, firstTarg->GetLocation(), firstTarg->GetLoadMask()); + hsgResMgr::ResMgr()->NewKey(plString::FromUtf8(GetINode()->GetName()), fMap, firstTarg->GetLocation(), firstTarg->GetLoadMask()); if (fCompPB->GetInt((ParamID(kMapType))) == kMapCubic) diff --git a/Sources/Tools/MaxConvert/hsControlConverter.cpp b/Sources/Tools/MaxConvert/hsControlConverter.cpp index d9043c28..de4ee65e 100644 --- a/Sources/Tools/MaxConvert/hsControlConverter.cpp +++ b/Sources/Tools/MaxConvert/hsControlConverter.cpp @@ -2158,7 +2158,7 @@ void hsControlConverter::IExportAnimatedCameraFOV(plMaxNode* node, hsTArray AddReceiver(pCamMod->GetKey()); pMsg->SetSender(pAnim->GetModKey(node)); pMsg->SetCmd(plAnimCmdMsg::kAddCallbacks); - pMsg->SetAnimName(ENTIRE_ANIMATION_NAME); + pMsg->SetAnimName(_TEMP_CONVERT_FROM_LITERAL(ENTIRE_ANIMATION_NAME)); pMsg->fTime = kfArray[0][i].fFrame / MAX_FRAMES_PER_SEC; pMsg->AddCallback(pCall); hsRefCnt_SafeUnRef(pCall); diff --git a/Sources/Tools/MaxConvert/hsConverterUtils.cpp b/Sources/Tools/MaxConvert/hsConverterUtils.cpp index 54249978..1e32c052 100644 --- a/Sources/Tools/MaxConvert/hsConverterUtils.cpp +++ b/Sources/Tools/MaxConvert/hsConverterUtils.cpp @@ -346,7 +346,7 @@ INode* hsConverterUtils::FindINodeFromKeyedObject(hsKeyedObject* obj) { hsGuardBegin("hsConverterUtils::FindINodeFromKeyedObject"); - INode* retVal = FindINodeFromMangledName(obj->GetKey()->GetName()); + INode* retVal = FindINodeFromMangledName(_TEMP_CONVERT_TO_CONST_CHAR(obj->GetKey()->GetName())); if( retVal ) return (retVal); diff --git a/Sources/Tools/MaxConvert/hsMaterialConverter.cpp b/Sources/Tools/MaxConvert/hsMaterialConverter.cpp index efa3f132..dd06c718 100644 --- a/Sources/Tools/MaxConvert/hsMaterialConverter.cpp +++ b/Sources/Tools/MaxConvert/hsMaterialConverter.cpp @@ -308,7 +308,7 @@ void AttachLinkMtlAnims(plMaxNode *node, hsGMaterial *mat) animLayer = new plLayerLinkAnimation; animLayer->SetLinkKey(node->GetAvatarSO()->GetKey()); //animLayer->fLeavingAge = leaving[x]; - TSTR fullAnimName = TSTR(oldLayer->GetKeyName()) + TSTR("_") + TSTR(animName) + TSTR("_") + TSTR(suff); + plString fullAnimName = plString::Format("%s_%s_%s", oldLayer->GetKeyName().c_str(), animName, suff); hsgResMgr::ResMgr()->NewKey(fullAnimName, animLayer, node->GetLocation()); animLayer->SetOpacityCtl(opaCtl); animLayer->GetTimeConvert().SetBegin(times[0]); @@ -758,11 +758,11 @@ hsMaterialConverter::CreateMaterialArray(Mtl *maxMaterial, plMaxNode *node, uint hsBool enviro = fConverterUtils.IsEnvironHolder(node); - TSTR name; + plString name; if (maxMaterial) - name = maxMaterial->GetName(); + name = plString::FromUtf8(maxMaterial->GetName()); else - name = "nil"; + name = _TEMP_CONVERT_FROM_LITERAL("nil"); /// Get the material hsBool isMultiMat = IsMultiMat( maxMaterial ); @@ -905,8 +905,7 @@ hsGMaterial* hsMaterialConverter::NonAlphaHackPrint(plMaxNode* node, Texmap* bas if( !(baseTex && node) ) return nil; - char name[256]; - sprintf(name, "%s_%s_%d", node->GetName(), baseTex->GetName(), 0); + plString name = plString::Format("%s_%s_%d", node->GetName(), baseTex->GetName(), 0); // Search done materials for it @@ -948,8 +947,7 @@ hsGMaterial* hsMaterialConverter::AlphaHackPrint(plMaxNode* node, Texmap* baseTe if( !(baseTex && node) ) return nil; - char name[256]; - sprintf(name, "%s_%s_%d_AH", node->GetName(), baseTex->GetName(), 0); + plString name = plString::Format("%s_%s_%d_AH", node->GetName(), baseTex->GetName(), 0); // Search done materials for it @@ -998,8 +996,7 @@ hsGMaterial* hsMaterialConverter::NonAlphaHackVersion(plMaxNode* node, Mtl* mtl, return nil; } - char name[256]; - sprintf(name, "%s_%s_%d", node->GetName(), mtl->GetName(), subIndex); + plString name = plString::Format("%s_%s_%d", node->GetName(), mtl->GetName(), subIndex); return ICreateMaterial(mtl, node, name, subIndex, 1, false); } @@ -1014,8 +1011,7 @@ hsGMaterial* hsMaterialConverter::AlphaHackVersion(plMaxNode* node, Mtl* mtl, in return nil; } - char name[256]; - sprintf(name, "%s_%s_%d_AH", node->GetName(), mtl->GetName(), subIndex); + plString name = plString::Format("%s_%s_%d_AH", node->GetName(), mtl->GetName(), subIndex); return ICreateMaterial(mtl, node, name, subIndex, 1, true); } @@ -1024,7 +1020,7 @@ hsGMaterial* hsMaterialConverter::AlphaHackVersion(plMaxNode* node, Mtl* mtl, in // Big kahuna converter function // (Though meshConverter should be calling CreateMaterialArray instead) // -hsGMaterial *hsMaterialConverter::ICreateMaterial(Mtl *mtl, plMaxNode *node, const char *name, int subIndex, +hsGMaterial *hsMaterialConverter::ICreateMaterial(Mtl *mtl, plMaxNode *node, const plString &name, int subIndex, int numUVChannels, hsBool makeAlphaLayer) { hsGuardBegin("hsMaterialConverter::ICreateMaterial"); @@ -1133,7 +1129,7 @@ hsGMaterial *hsMaterialConverter::ICreateMaterial(Mtl *mtl, plMaxNode *node, con // // Handle materials for normal non-light, non-particle nodes. // -hsGMaterial *hsMaterialConverter::IProcessMaterial(Mtl *mtl, plMaxNode *node, const char *name, +hsGMaterial *hsMaterialConverter::IProcessMaterial(Mtl *mtl, plMaxNode *node, const plString &name, int UVChan, int subMtlFlags /* = 0 */) { hsGuardBegin("hsMaterialConverter::IProcessMaterial"); @@ -1187,11 +1183,11 @@ hsGMaterial *hsMaterialConverter::IProcessMaterial(Mtl *mtl, plMaxNode *node, co plLayer* hLay = new plLayer; hLay->InitToDefault(); - hsgResMgr::ResMgr()->NewKey(TSTR(name) + TSTR("_DefLay"), hLay, nodeLoc); + hsgResMgr::ResMgr()->NewKey(name + _TEMP_CONVERT_FROM_LITERAL("_DefLay"), hLay, nodeLoc); IAddLayerToMaterial(hMat, hLay); } - if( node->UserPropExists("WetMe") && !strstr(hMat->GetKey()->GetName(), "Wet(*)") ) + if( node->UserPropExists("WetMe") && (hMat->GetKey()->GetName().Find("Wet(*)") < 0) ) IAppendWetLayer(node, hMat); // hsgResMgr::ResMgr()->NewKey(name, hMat,nodeLoc); } @@ -1337,11 +1333,11 @@ hsGMaterial *hsMaterialConverter::IAddDefaultMaterial(plMaxNode *node) plLocation loc = node->GetLocation(); hsGMaterial *hMat = new hsGMaterial; - hsgResMgr::ResMgr()->NewKey(TSTR(node->GetName()) + TSTR("_DefMat"), hMat, loc); + hsgResMgr::ResMgr()->NewKey(plString::Format("%s_DefMat", node->GetName()), hMat, loc); plLayer *layer = new plLayer; layer->InitToDefault(); - hsgResMgr::ResMgr()->NewKey(TSTR(hMat->GetKeyName()) + TSTR("_DefLay"), layer, loc); + hsgResMgr::ResMgr()->NewKey(hMat->GetKeyName() + _TEMP_CONVERT_FROM_LITERAL("_DefLay"), layer, loc); DWORD color = node->GetWireColor(); float r = float(GetRValue(color)) / 255.f; @@ -1357,7 +1353,8 @@ hsGMaterial *hsMaterialConverter::IAddDefaultMaterial(plMaxNode *node) plMipmap *hsMaterialConverter::IGetUVTransTexture(plMaxNode *node, hsBool useU /* = true */) { - char* texName = (useU ? "ALPHA_BLEND_FILTER_U2ALPHA_TRANS_64x4" : "ALPHA_BLEND_FILTER_V2ALPHA_TRANS_4x64" ); + plString texName = (useU ? _TEMP_CONVERT_FROM_LITERAL("ALPHA_BLEND_FILTER_U2ALPHA_TRANS_64x4") + : _TEMP_CONVERT_FROM_LITERAL("ALPHA_BLEND_FILTER_V2ALPHA_TRANS_4x64") ); int w = (useU ? 64 : 4); int h = (useU ? 4 : 64); @@ -1415,7 +1412,7 @@ void hsMaterialConverter::IInsertSingleBlendLayer(plMipmap *texture, hsGMaterial plLayer* layer = new plLayer; layer->InitToDefault(); - hsgResMgr::ResMgr()->NewKey(TSTR(underLay->GetKeyName()) + TSTR("_AlphaBlend"), layer, node->GetLocation()); + hsgResMgr::ResMgr()->NewKey(underLay->GetKeyName() + _TEMP_CONVERT_FROM_LITERAL("_AlphaBlend"), layer, node->GetLocation()); hsgResMgr::ResMgr()->AddViaNotify(texture->GetKey(), new plLayRefMsg(layer->GetKey(), plRefMsg::kOnCreate, 0, plLayRefMsg::kTexture), plRefFlags::kActiveRef); layer->SetAmbientColor(hsColorRGBA().Set(1.f, 1.f, 1.f, 1.f)); // layer->SetZFlags(hsGMatState::kZNoZWrite | hsGMatState::kZIncLayer); @@ -1570,16 +1567,14 @@ void hsMaterialConverter::IInsertCompBlendingLayers(Mtl *mtl, plMaxNode *node, h return; } -hsGMaterial *hsMaterialConverter::IProcessCompositeMtl(Mtl *mtl, plMaxNode *node, const char *name, int UVChan, int subMtlFlags) +hsGMaterial *hsMaterialConverter::IProcessCompositeMtl(Mtl *mtl, plMaxNode *node, const plString &name, int UVChan, int subMtlFlags) { if (!mtl || mtl->ClassID() != COMP_MTL_CLASS_ID) return nil; uint32_t *layerCounts = new uint32_t[mtl->NumSubMtls()]; IParamBlock2 *pb = mtl->GetParamBlockByID(plCompositeMtl::kBlkPasses); - char suff[10]; - sprintf(suff, "_%d", subMtlFlags); hsGMaterial *mat = new hsGMaterial; - hsgResMgr::ResMgr()->NewKey(TSTR(name) + TSTR(suff), mat, node->GetLocation()); + hsgResMgr::ResMgr()->NewKey(plString::Format("%s_%d", name.c_str(), subMtlFlags), mat, node->GetLocation()); int multiIndex = IFindSubIndex(node, mtl); hsBool needAlphaHack = node->AlphaHackLayersNeeded(multiIndex) > 0; @@ -1593,8 +1588,7 @@ hsGMaterial *hsMaterialConverter::IProcessCompositeMtl(Mtl *mtl, plMaxNode *node hsBool usingSubMtl = (i == 0 || pb->GetInt(kCompOn, 0, i - 1)); if ((bitMask & subMtlFlags) != 0 && usingSubMtl) { - char pref[256]; - sprintf(pref, "%s_%d", mat->GetKey()->GetName(), i); + plString pref = plString::Format("%s_%d", mat->GetKey()->GetName().c_str(), i); subMtl = mtl->GetSubMtl(i); if (subMtl != nil && subMtl->ClassID() == PASS_MTL_CLASS_ID) @@ -1673,7 +1667,7 @@ hsGMaterial *hsMaterialConverter::IProcessCompositeMtl(Mtl *mtl, plMaxNode *node return mat; } -hsGMaterial *hsMaterialConverter::IProcessMultipassMtl(Mtl *mtl, plMaxNode *node, const char *name, int UVChan) +hsGMaterial *hsMaterialConverter::IProcessMultipassMtl(Mtl *mtl, plMaxNode *node, const plString &name, int UVChan) { if (!mtl || mtl->ClassID() != MULTIMTL_CLASS_ID) return nil; @@ -1705,7 +1699,7 @@ hsGMaterial *hsMaterialConverter::IProcessMultipassMtl(Mtl *mtl, plMaxNode *node return mat; } -hsGMaterial *hsMaterialConverter::IProcessParticleMtl(Mtl *mtl, plMaxNode *node, const char *name) +hsGMaterial *hsMaterialConverter::IProcessParticleMtl(Mtl *mtl, plMaxNode *node, const plString &name) { hsGuardBegin("hsMaterialConverter::IProcessParticleMaterial"); @@ -1713,7 +1707,7 @@ hsGMaterial *hsMaterialConverter::IProcessParticleMtl(Mtl *mtl, plMaxNode *node, char* dbgNodeName = node->GetName(); hsGMaterial *mat = new hsGMaterial; - hsgResMgr::ResMgr()->NewKey(name, mat,nodeLoc); + hsgResMgr::ResMgr()->NewKey(name, mat, nodeLoc); if(!mtl) @@ -1732,10 +1726,10 @@ hsGMaterial *hsMaterialConverter::IProcessParticleMtl(Mtl *mtl, plMaxNode *node, Color dif = basicPB->GetColor(plParticleMtl::kColor); float opac = float(basicPB->GetInt(plParticleMtl::kOpacity)) / 100.0f; - fErrorMsg->Set(opac < 0.0 || opac > 1.0, dbgNodeName, "Bad opacity on mat %s", name).CheckAndAsk(); - fErrorMsg->Set(dif.r < 0.0 || dif.r > 1.0, dbgNodeName, "Bad color (r) on mat %s", name).CheckAndAsk(); - fErrorMsg->Set(dif.g < 0.0 || dif.g > 1.0, dbgNodeName, "Bad color (g) on mat %s", name).CheckAndAsk(); - fErrorMsg->Set(dif.b < 0.0 || dif.b > 1.0, dbgNodeName, "Bad color (b) on mat %s", name).CheckAndAsk(); + fErrorMsg->Set(opac < 0.0 || opac > 1.0, dbgNodeName, "Bad opacity on mat %s", name.c_str()).CheckAndAsk(); + fErrorMsg->Set(dif.r < 0.0 || dif.r > 1.0, dbgNodeName, "Bad color (r) on mat %s", name.c_str()).CheckAndAsk(); + fErrorMsg->Set(dif.g < 0.0 || dif.g > 1.0, dbgNodeName, "Bad color (g) on mat %s", name.c_str()).CheckAndAsk(); + fErrorMsg->Set(dif.b < 0.0 || dif.b > 1.0, dbgNodeName, "Bad color (b) on mat %s", name.c_str()).CheckAndAsk(); Color col = dif; @@ -1817,7 +1811,7 @@ hsGMaterial *hsMaterialConverter::IProcessParticleMtl(Mtl *mtl, plMaxNode *node, } plLayerAnimation *IConvertNoteTrackAnims(plLayerAnimation *animLayer, SegmentMap *segMap, plMaxNode *node, - const char *name) + const plString &name) { plLayerAnimation *prev = animLayer; @@ -1827,7 +1821,7 @@ plLayerAnimation *IConvertNoteTrackAnims(plLayerAnimation *animLayer, SegmentMap if (spec->fType == SegmentSpec::kAnim) { plLayerAnimation *noteAnim = new plLayerAnimation; - TSTR animName = TSTR(name) + TSTR("_anim_") + TSTR(spec->fName); + plString animName = plString::Format("%s_anim_%s", name.c_str(), spec->fName); hsgResMgr::ResMgr()->NewKey(animName, noteAnim, node->GetLocation()); if (animLayer->GetPreshadeColorCtl()) @@ -1854,8 +1848,8 @@ plLayerAnimation *IConvertNoteTrackAnims(plLayerAnimation *animLayer, SegmentMap void ISetDefaultAnim(plPassMtlBase* mtl, plAnimTimeConvert& tc, SegmentMap* segMap) { - const char *animName = mtl->GetAnimName(); - if( segMap && animName && (segMap->find(animName) != segMap->end()) ) + plString animName = _TEMP_CONVERT_FROM_LITERAL( mtl->GetAnimName() ); + if( segMap && !animName.IsNull() && (segMap->find(animName) != segMap->end()) ) { SegmentSpec *spec = (*segMap)[animName]; tc.SetBegin(spec->fStart); @@ -1874,8 +1868,8 @@ void ISetDefaultAnim(plPassMtlBase* mtl, plAnimTimeConvert& tc, SegmentMap* segM float loopEnd = tc.GetEnd(); // If there's a loop, use it - const char *loopName = mtl->GetAnimLoopName(); - if (loopName && *loopName && segMap) + plString loopName = plString::FromUtf8(mtl->GetAnimLoopName()); + if (!loopName.IsEmpty() && segMap) GetSegMapAnimTime(loopName, segMap, SegmentSpec::kLoop, loopStart, loopEnd); tc.SetLoopPoints(loopStart, loopEnd); @@ -1960,8 +1954,8 @@ static plAnimStealthNode* IGetEntireAnimation(plPassMtlBase* mtl) { plAnimStealthNode* stealth = mtl->GetStealth(i); - const char *segName = stealth->GetSegmentName(); - if( !segName || !*segName || !stricmp(segName, ENTIRE_ANIMATION_NAME) ) + plString segName = stealth->GetSegmentName(); + if( segName.IsEmpty() || !segName.Compare(ENTIRE_ANIMATION_NAME, plString::kCaseInsensitive) ) return stealth; } @@ -1998,20 +1992,20 @@ static plLayerInterface* IProcessLayerMovie(plPassMtlBase* mtl, plLayerTex* layT sprintf(movieName, "avi/%s", plFileUtils::GetFileName(fileName)); plLayerMovie* movieLayer = nil; - const char* moviePostfix = nil; + plString moviePostfix; if (isBink) { movieLayer = new plLayerBink; - moviePostfix = "_bink"; + moviePostfix = _TEMP_CONVERT_FROM_LITERAL("_bink"); } else if (isAvi) { movieLayer = new plLayerAVI; - moviePostfix = "_avi"; + moviePostfix = _TEMP_CONVERT_FROM_LITERAL("_avi"); } - TSTR movieKeyName = TSTR(layerIFace->GetKeyName()) + moviePostfix; + plString movieKeyName = layerIFace->GetKeyName() + moviePostfix; hsgResMgr::ResMgr()->NewKey(movieKeyName, movieLayer, node->GetLocation()); movieLayer->SetMovieName(movieName); @@ -2040,7 +2034,7 @@ static plLayerInterface* IProcessLayerMovie(plPassMtlBase* mtl, plLayerTex* layT } plLayerInterface* IProcessLayerAnimation(plPassMtlBase* mtl, plLayerTex* layTex, plMaxNode* node, - const char *name, plLayerInterface* layerIFace) + const plString &name, plLayerInterface* layerIFace) { hsControlConverter& cc = hsControlConverter::Instance(); @@ -2055,7 +2049,7 @@ plLayerInterface* IProcessLayerAnimation(plPassMtlBase* mtl, plLayerTex* layTex, if( mtl->GetUseGlobal() ) { plLayerSDLAnimation *SDLLayer = new plLayerSDLAnimation; - TSTR animName = TSTR(name) + TSTR("_anim_") + TSTR(mtl->GetGlobalVarName()); + plString animName = plString::Format("%s_anim_%s", name.c_str(), mtl->GetGlobalVarName()); hsgResMgr::ResMgr()->NewKey(animName, SDLLayer, node->GetLocation()); SDLLayer->SetVarName((char*)mtl->GetGlobalVarName()); @@ -2078,10 +2072,11 @@ plLayerInterface* IProcessLayerAnimation(plPassMtlBase* mtl, plLayerTex* layTex, plLayerAnimation *noteAnim = new plLayerAnimation; node->CheckSynchOptions(noteAnim); - const char *segName = stealth->GetSegmentName(); - bool isDefault = ( segName == nil || strcmp( segName, ENTIRE_ANIMATION_NAME ) == 0 ) ? true : false; + plString segName = stealth->GetSegmentName(); + bool isDefault = ( segName.IsNull() || segName.Compare( ENTIRE_ANIMATION_NAME ) == 0 ) ? true : false; - TSTR animName = TSTR( name ) + ( ( isDefault ) ? TSTR( "_LayerAnim_" ) : ( TSTR("_LayerAnim") + TSTR( segName ) ) ); + plString animName = name + ( ( isDefault ) ? _TEMP_CONVERT_FROM_LITERAL( "_LayerAnim_" ) + : ( _TEMP_CONVERT_FROM_LITERAL("_LayerAnim") + segName ) ); hsgResMgr::ResMgr()->NewKey( animName, noteAnim, node->GetLocation() ); StdUVGen *uvGen = (StdUVGen *)layTex->GetTheUVGen(); @@ -2093,7 +2088,7 @@ plLayerInterface* IProcessLayerAnimation(plPassMtlBase* mtl, plLayerTex* layTex, // Set segment name if we're not the default if( !isDefault ) - noteAnim->SetSegmentID( (char *)segName ); + noteAnim->SetSegmentID( segName ); // And attach! noteAnim->AttachViaNotify( layerIFace ); @@ -2106,7 +2101,7 @@ plLayerInterface* IProcessLayerAnimation(plPassMtlBase* mtl, plLayerTex* layTex, } -plLayerInterface* IProcessAnimation(plPassMtlBase *mtl, plMaxNode *node, const char *name, +plLayerInterface* IProcessAnimation(plPassMtlBase *mtl, plMaxNode *node, const plString &name, plLayerInterface *layerIFace) { hsControlConverter& cc = hsControlConverter::Instance(); @@ -2155,7 +2150,7 @@ plLayerInterface* IProcessAnimation(plPassMtlBase *mtl, plMaxNode *node, const c // return layerIFace; plLayerSDLAnimation *SDLLayer = new plLayerSDLAnimation; - TSTR animName = TSTR(name) + TSTR("_anim_") + TSTR(mtl->GetGlobalVarName()); + plString animName = plString::Format("%s_anim_%s", name.c_str(), mtl->GetGlobalVarName()); hsgResMgr::ResMgr()->NewKey(animName, SDLLayer, node->GetLocation()); SDLLayer->SetVarName((char*)mtl->GetGlobalVarName()); @@ -2193,10 +2188,11 @@ plLayerInterface* IProcessAnimation(plPassMtlBase *mtl, plMaxNode *node, const c plLayerAnimation *noteAnim = new plLayerAnimation; node->CheckSynchOptions(noteAnim); - const char *segName = stealth->GetSegmentName(); - bool isDefault = ( segName == nil || strcmp( segName, ENTIRE_ANIMATION_NAME ) == 0 ) ? true : false; + plString segName = stealth->GetSegmentName(); + bool isDefault = ( segName.IsNull() || segName.Compare( ENTIRE_ANIMATION_NAME ) == 0 ) ? true : false; - TSTR animName = TSTR( name ) + ( ( isDefault ) ? TSTR( "_anim" ) : ( TSTR("_anim_") + TSTR( segName ) ) ); + plString animName = name + ( ( isDefault ) ? _TEMP_CONVERT_FROM_LITERAL( "_anim" ) + : ( _TEMP_CONVERT_FROM_LITERAL("_anim_") + segName ) ); hsgResMgr::ResMgr()->NewKey( animName, noteAnim, node->GetLocation() ); plController *noteColCtl = cc.MakeColorController( maxColCtl, node ); @@ -2221,7 +2217,7 @@ plLayerInterface* IProcessAnimation(plPassMtlBase *mtl, plMaxNode *node, const c // Set segment name if we're not the default if( !isDefault ) - noteAnim->SetSegmentID( (char *)segName ); + noteAnim->SetSegmentID( segName ); // And attach! noteAnim->AttachViaNotify( layerIFace ); @@ -2274,7 +2270,7 @@ int hsMaterialConverter::IFindSubIndex(plMaxNode* node, Mtl* mtl) // // Now handles both plPassMtl and plDecalMtl which derive from plPassMtlBase -hsBool hsMaterialConverter::IProcessPlasmaMaterial(Mtl *mtl, plMaxNode *node, hsGMaterial *mat, const char* name) +hsBool hsMaterialConverter::IProcessPlasmaMaterial(Mtl *mtl, plMaxNode *node, hsGMaterial *mat, const plString& name) { hsGuardBegin("hsMaterialConverter::IProcessPlasmaMaterial"); @@ -2307,13 +2303,13 @@ hsBool hsMaterialConverter::IProcessPlasmaMaterial(Mtl *mtl, plMaxNode *node, hs float opac = float(passBase->GetOpacity()) / 100.0f; - fErrorMsg->Set(opac < 0.0 || opac > 1.0, dbgNodeName, "Bad opacity on mat %s", name).CheckAndAsk(); - fErrorMsg->Set(dif.r < 0.0 || dif.r > 1.0, dbgNodeName, "Bad color (r) on mat %s", name).CheckAndAsk(); - fErrorMsg->Set(dif.g < 0.0 || dif.g > 1.0, dbgNodeName, "Bad color (g) on mat %s", name).CheckAndAsk(); - fErrorMsg->Set(dif.b < 0.0 || dif.b > 1.0, dbgNodeName, "Bad color (b) on mat %s", name).CheckAndAsk(); - fErrorMsg->Set(runDif.r < 0.0 || runDif.r > 1.0, dbgNodeName, "Bad runtime color (r) on mat %s", name).CheckAndAsk(); - fErrorMsg->Set(runDif.g < 0.0 || runDif.g > 1.0, dbgNodeName, "Bad runtime color (g) on mat %s", name).CheckAndAsk(); - fErrorMsg->Set(runDif.b < 0.0 || runDif.b > 1.0, dbgNodeName, "Bad runtime color (b) on mat %s", name).CheckAndAsk(); + fErrorMsg->Set(opac < 0.0 || opac > 1.0, dbgNodeName, "Bad opacity on mat %s", name.c_str()).CheckAndAsk(); + fErrorMsg->Set(dif.r < 0.0 || dif.r > 1.0, dbgNodeName, "Bad color (r) on mat %s", name.c_str()).CheckAndAsk(); + fErrorMsg->Set(dif.g < 0.0 || dif.g > 1.0, dbgNodeName, "Bad color (g) on mat %s", name.c_str()).CheckAndAsk(); + fErrorMsg->Set(dif.b < 0.0 || dif.b > 1.0, dbgNodeName, "Bad color (b) on mat %s", name.c_str()).CheckAndAsk(); + fErrorMsg->Set(runDif.r < 0.0 || runDif.r > 1.0, dbgNodeName, "Bad runtime color (r) on mat %s", name.c_str()).CheckAndAsk(); + fErrorMsg->Set(runDif.g < 0.0 || runDif.g > 1.0, dbgNodeName, "Bad runtime color (g) on mat %s", name.c_str()).CheckAndAsk(); + fErrorMsg->Set(runDif.b < 0.0 || runDif.b > 1.0, dbgNodeName, "Bad runtime color (b) on mat %s", name.c_str()).CheckAndAsk(); // Color col = dif - amb; Color col = dif; @@ -2778,9 +2774,8 @@ hsGMaterial *hsMaterialConverter::IWrapTextureInMaterial(Texmap *texMap, plMaxNo texMap->GetClassName(className); // We want to keep it. Handle appropriately. - BitmapTex *bitmapTex = (BitmapTex *)texMap; - char txtFileName[256]; - strcpy(txtFileName, bitmapTex->GetMapName()); + BitmapTex *bitmapTex = (BitmapTex *)texMap; + plString txtFileName = plString::FromUtf8( bitmapTex->GetMapName() ); // hsRegistryKey* key = hsgResMgr::ResMgr()->FindKey(txtFileName, hsGMaterial::Index()); plKey key = node->FindPageKey( hsGMaterial::Index(), txtFileName ); @@ -3090,8 +3085,7 @@ void hsMaterialConverter::IAppendFunkyLayer(plMaxNode* node, Texmap* texMap, hsG plBitmap* funkRamp = IGetFunkyRamp(node, funkyType); - char name[512]; - sprintf(name, "%s_funkRamp", prevLay->GetKey()->GetName()); + plString name = plString::Format("%s_funkRamp", prevLay->GetKey()->GetName().c_str()); plLayer* layer = new plLayer; layer->InitToDefault(); @@ -3134,7 +3128,7 @@ void hsMaterialConverter::IAppendFunkyLayer(plMaxNode* node, Texmap* texMap, hsG plBitmap* hsMaterialConverter::IGetFunkyRamp(plMaxNode* node, uint32_t funkyType) { - const char* funkName = funkyType & kFunkyAdd ? "FunkyRampAdd" : "FunkyRampMult"; + plString funkName = funkyType & kFunkyAdd ? _TEMP_CONVERT_FROM_LITERAL("FunkyRampAdd") : _TEMP_CONVERT_FROM_LITERAL("FunkyRampMult"); const int kLUTWidth = 16; const int kLUTHeight = 16; @@ -3230,8 +3224,7 @@ void hsMaterialConverter::IAppendWetLayer(plMaxNode* node, hsGMaterial* mat) uvwXfm.fMap[1][2] = -1.f / (tr - op); uvwXfm.fMap[1][3] = uvwXfm.fMap[1][2] * -tr; - char name[512]; - sprintf(name, "%s_funkRamp", prevLay->GetKey()->GetName()); + plString name = plString::Format("%s_funkRamp", prevLay->GetKey()->GetName().c_str()); plLayer* layer = nil; plKey key = node->FindPageKey( plLayer::Index(), name ); @@ -3517,7 +3510,7 @@ BitmapTex* hsMaterialConverter::GetBumpLayer(plMaxNode* node, Mtl* mtl) plMipmap *hsMaterialConverter::IGetBumpLutTexture(plMaxNode *node) { - const char* texName = "BumpLutTexture"; + const plString texName = _TEMP_CONVERT_FROM_LITERAL("BumpLutTexture"); //#define FUNKYBUMP #ifndef FUNKYBUMP @@ -3697,19 +3690,19 @@ plMipmap *hsMaterialConverter::IGetBumpLutTexture(plMaxNode *node) return texture; } -plLayer* hsMaterialConverter::IMakeBumpLayer(plMaxNode* node, const char* nameBase, hsGMaterial* mat, uint32_t miscFlag) +plLayer* hsMaterialConverter::IMakeBumpLayer(plMaxNode* node, const plString& nameBase, hsGMaterial* mat, uint32_t miscFlag) { - char name[256]; + plString name; switch( miscFlag & hsGMatState::kMiscBumpChans ) { case hsGMatState::kMiscBumpDu: - sprintf(name, "%s_DU_BumpLut", nameBase); + name = plString::Format("%s_DU_BumpLut", nameBase.c_str()); break; case hsGMatState::kMiscBumpDv: - sprintf(name, "%s_DV_BumpLut", nameBase); + name = plString::Format("%s_DV_BumpLut", nameBase.c_str()); break; case hsGMatState::kMiscBumpDw: - sprintf(name, "%s_DW_BumpLut", nameBase); + name = plString::Format("%s_DW_BumpLut", nameBase.c_str()); break; default: hsAssert(false, "Bogus flag input to MakeBumpLayer"); @@ -3787,7 +3780,7 @@ void hsMaterialConverter::IInsertBumpLayers(plMaxNode* node, hsGMaterial* mat, i (bumpLay->GetBlendFlags() & ~hsGMatState::kBlendMask) | hsGMatState::kBlendDot3); - const char* name = mat->GetLayer(bumpLayerIdx)->GetKey()->GetName(); + plString name = mat->GetLayer(bumpLayerIdx)->GetKey()->GetName(); plLayer* layerDu = IMakeBumpLayer(node, name, mat, hsGMatState::kMiscBumpDu); plLayer* layerDv = IMakeBumpLayer(node, name, mat, hsGMatState::kMiscBumpDv); @@ -4532,7 +4525,7 @@ void hsMaterialConverter::CollectConvertedMaterials(Mtl *mtl, hsTArraySetName(mtl->GetName()); cloth->fSortOrder = (mtl->GetDefault() ? 0 : 1); @@ -4550,7 +4543,7 @@ plClothingItem *hsMaterialConverter::GenerateClothingItem(plClothingMtl *mtl, co cloth->fDefaultTint2[1] = tint2.g * 255; cloth->fDefaultTint2[2] = tint2.b * 255; - sprintf(clothKeyName, "CItm_%s", cloth->fName); + clothKeyName = plString::Format("CItm_%s", cloth->fName); hsgResMgr::ResMgr()->NewKey(clothKeyName, cloth, loc); plNodeRefMsg* nodeRefMsg = new plNodeRefMsg(plKeyFinder::Instance().FindSceneNodeKey(loc), @@ -4629,7 +4622,7 @@ static int ICompareBaseLayerTexture(const hsMaterialConverter::DoneMaterialData* if( !oneTex && twoTex ) return -1; - return _stricmp(oneTex->GetKey()->GetName(), twoTex->GetKey()->GetName()); + return oneTex->GetKey()->GetName().Compare(twoTex->GetKey()->GetName(), plString::kCaseInsensitive); } static int IIsAnimatedLayer(const plLayerInterface* lay) @@ -4686,7 +4679,7 @@ static int ICompareDoneLayers(const plLayerInterface* one, const plLayerInterfac if( one->GetTexture() && two->GetTexture() ) { - retVal = _stricmp(one->GetTexture()->GetKey()->GetName(), two->GetTexture()->GetKey()->GetName()); + retVal = one->GetTexture()->GetKey()->GetName().Compare(two->GetTexture()->GetKey()->GetName(), plString::kCaseInsensitive); if( retVal < 0 ) return -1; else if( retVal > 0 ) @@ -4957,8 +4950,8 @@ void hsMaterialConverter::IPrintDoneMat(hsStream* stream, const char* prefix, Do layer->GetLODBias()); stream->WriteString(buff); - sprintf(buff, "\t\t\tTexture %s\n", layer->GetTexture() && layer->GetTexture()->GetKey() && layer->GetTexture()->GetKey()->GetName() - ? layer->GetTexture()->GetKey()->GetName() + sprintf(buff, "\t\t\tTexture %s\n", layer->GetTexture() && layer->GetTexture()->GetKey() + ? layer->GetTexture()->GetKey()->GetName().s_str("None") : "None"); stream->WriteString(buff); @@ -5139,9 +5132,8 @@ hsMaterialConverter::DoneMaterialData* hsMaterialConverter::IFindDoneMaterial(Do plMipmap *hsMaterialConverter::GetStaticColorTexture(Color c, plLocation &loc) { - char texName[256]; uint32_t colorHex = MakeUInt32Color(c.r, c.g, c.b, 1.f); - sprintf(texName, "StaticColorTex_4x4_%X", colorHex); + plString texName = plString::Format("StaticColorTex_4x4_%X", colorHex); int w = 4; int h = 4; diff --git a/Sources/Tools/MaxConvert/hsMaterialConverter.h b/Sources/Tools/MaxConvert/hsMaterialConverter.h index 492d3ff5..a2dbba1c 100644 --- a/Sources/Tools/MaxConvert/hsMaterialConverter.h +++ b/Sources/Tools/MaxConvert/hsMaterialConverter.h @@ -63,6 +63,7 @@ class hsGAnimLayer; class plBitmap; class plMipmap; class plErrorMsg; +class plString; class Mtl; class Texmap; @@ -138,10 +139,10 @@ public: static int GetCoordMapping(StdUVGen *uvgen); static void GetNodesByMaterial(Mtl *mtl, hsTArray &out); - static uint32_t VertexChannelsRequestMask(plMaxNode* node, int iSubMtl, Mtl* mtl); - static uint32_t VertexChannelsRequiredMask(plMaxNode* node, int iSubMtl); + static uint32_t VertexChannelsRequestMask(plMaxNode* node, int iSubMtl, Mtl* mtl); + static uint32_t VertexChannelsRequiredMask(plMaxNode* node, int iSubMtl); static int NumVertexOpacityChannelsRequired(plMaxNode* node, int iSubMtl); - static uint32_t ColorChannelsUseMask(plMaxNode* node, int iSubMtl); + static uint32_t ColorChannelsUseMask(plMaxNode* node, int iSubMtl); static int MaxUsedUVWSrc(plMaxNode* node, Mtl* mtl); @@ -235,7 +236,7 @@ enum { hsBool fSubMultiMat; hsBool fOwnedCopy; hsBool fRuntimeLit; - uint32_t fSubMtlFlags; + uint32_t fSubMtlFlags; int fNumUVChannels; hsBool fMakeAlphaLayer; }; @@ -265,21 +266,21 @@ private: void IInsertSingleBlendLayer(plMipmap *texture, hsGMaterial *mat, plMaxNode *node, int layerIdx, int UVChan); - hsGMaterial *ICreateMaterial(Mtl *mtl, plMaxNode *node, const char *name, int subIndex, int numUVChannels, hsBool makeAlphaLayer); - hsGMaterial *IProcessMaterial(Mtl *mtl, plMaxNode *node, const char *name, int UVChan, int subMtlFlags = 0); + hsGMaterial *ICreateMaterial(Mtl *mtl, plMaxNode *node, const plString &name, int subIndex, int numUVChannels, hsBool makeAlphaLayer); + hsGMaterial *IProcessMaterial(Mtl *mtl, plMaxNode *node, const plString &name, int UVChan, int subMtlFlags = 0); // ... calls one of: - hsGMaterial *IProcessMultipassMtl(Mtl *mtl, plMaxNode *node, const char *name, int UVChan); - hsGMaterial *IProcessCompositeMtl(Mtl *mtl, plMaxNode *node, const char *name, int UVChan, int subMtlFlags); - hsGMaterial *IProcessParticleMtl(Mtl *mtl, plMaxNode *node, const char *name); - hsBool IProcessPlasmaMaterial(Mtl *mtl, plMaxNode *node, hsGMaterial *mat, const char* namePrefix); + hsGMaterial *IProcessMultipassMtl(Mtl *mtl, plMaxNode *node, const plString &name, int UVChan); + hsGMaterial *IProcessCompositeMtl(Mtl *mtl, plMaxNode *node, const plString &name, int UVChan, int subMtlFlags); + hsGMaterial *IProcessParticleMtl(Mtl *mtl, plMaxNode *node, const plString &name); + hsBool IProcessPlasmaMaterial(Mtl *mtl, plMaxNode *node, hsGMaterial *mat, const plString& namePrefix); hsGMaterial* IInsertDoneMaterial(Mtl *mtl, hsGMaterial *hMat, plMaxNode *node, hsBool isMultiMat, hsBool forceCopy, hsBool runtimeLit, uint32_t subMtlFlags, int numUVChannels, hsBool makeAlphaLayer); void IInsertBumpLayers(plMaxNode* node, hsGMaterial* mat, int bumpLayerIdx); void IInsertBumpLayers(plMaxNode* node, hsGMaterial* mat); - plLayer* IMakeBumpLayer(plMaxNode* node, const char* nameBase, hsGMaterial* mat, uint32_t miscFlag); + plLayer* IMakeBumpLayer(plMaxNode* node, const plString& nameBase, hsGMaterial* mat, uint32_t miscFlag); plMipmap* IGetBumpLutTexture(plMaxNode* node); hsBool IHasSubMtl(Mtl* base, Mtl* sub); @@ -328,19 +329,19 @@ private: static plBitmap* IGetFunkyRamp(plMaxNode* node, uint32_t funkyType); static void IAppendFunkyLayer(plMaxNode* node, Texmap* texMap, hsGMaterial* mat); static hsBool IHasFunkyOpacity(plMaxNode* node, Texmap* texMap); - static uint32_t IGetFunkyType(Texmap* texMap); - static uint32_t IGetOpacityRanges(plMaxNode* node, Texmap* texMap, float& tr0, float& op0, float& op1, float& tr1); + static uint32_t IGetFunkyType(Texmap* texMap); + static uint32_t IGetOpacityRanges(plMaxNode* node, Texmap* texMap, float& tr0, float& op0, float& op1, float& tr1); Interface *fInterface; hsConverterUtils& fConverterUtils; hsBool fSave; plErrorMsg *fErrorMsg; - int32_t fSubIndex; + int32_t fSubIndex; hsBool fChangedTimes; char *fNodeName; - uint32_t fWarned; + uint32_t fWarned; DoneMaterialData fLastMaterial; diff --git a/Sources/Tools/MaxConvert/plBitmapCreator.cpp b/Sources/Tools/MaxConvert/plBitmapCreator.cpp index 4d3afa16..5429f715 100644 --- a/Sources/Tools/MaxConvert/plBitmapCreator.cpp +++ b/Sources/Tools/MaxConvert/plBitmapCreator.cpp @@ -521,7 +521,8 @@ plBitmap *plBitmapCreator::ICreateTexture( plBitmapData *bd, const plLocation &l } // Get and mangle key name - char name[ 256 ], temp[ 256 ]; + plString name; + char temp[ 256 ]; _splitpath(bd->fileName, NULL, NULL, temp, NULL); // Somehow, sometimes, we get the same file in with different cases. So we need to force the @@ -534,21 +535,21 @@ plBitmap *plBitmapCreator::ICreateTexture( plBitmapData *bd, const plLocation &l { // Mangle of the form: name@dropStart&dropStop&max&min if( clipID != -1 ) - sprintf( name, "%s*%x#%d@%s&%3.2f&%3.2f&%3.2f&%3.2f", temp, bd->texFlags, clipID, + name = plString::Format( "%s*%x#%d@%s&%3.2f&%3.2f&%3.2f&%3.2f", temp, bd->texFlags, clipID, bd->createFlags & plMipmap::kCreateDetailAlpha ? "al" : ( bd->createFlags & plMipmap::kCreateDetailAdd ? "ad" : "mu" ), bd->detailDropoffStart, bd->detailDropoffStop, bd->detailMax, bd->detailMin ); else - sprintf( name, "%s*%x@%s&%3.2f&%3.2f&%3.2f&%3.2f", temp, bd->texFlags, + name = plString::Format( "%s*%x@%s&%3.2f&%3.2f&%3.2f&%3.2f", temp, bd->texFlags, bd->createFlags & plMipmap::kCreateDetailAlpha ? "al" : ( bd->createFlags == plMipmap::kCreateDetailAdd ? "ad" : "mu" ), bd->detailDropoffStart, bd->detailDropoffStop, bd->detailMax, bd->detailMin ); } else if( clipID != -1 ) - sprintf( name, "%s*%x#%d", temp, bd->texFlags, clipID ); + name = plString::Format( "%s*%x#%d", temp, bd->texFlags, clipID ); else - sprintf( name, "%s*%x", temp, bd->texFlags ); + name = plString::Format( "%s*%x", temp, bd->texFlags ); if( bd->invertAlpha ) - strcat( name, "_inva" ); - strcat( name, ".hsm" ); + name += _TEMP_CONVERT_FROM_LITERAL( "_inva" ); + name += _TEMP_CONVERT_FROM_LITERAL( ".hsm" ); // Has this texture been used before? @@ -672,7 +673,7 @@ void plBitmapCreator::IAddBitmap( plBitmap *bitmap, hsBool dontRef ) // of "converted" maps to clean up at the end of export. plMipmap *plBitmapCreator::CreateBlankMipmap( uint32_t width, uint32_t height, unsigned config, uint8_t numLevels, - const char *keyName, const plLocation &keyLocation ) + const plString &keyName, const plLocation &keyLocation ) { hsGuardBegin( "plBitmapCreator::CreateBlankMipmap" ); diff --git a/Sources/Tools/MaxConvert/plBitmapCreator.h b/Sources/Tools/MaxConvert/plBitmapCreator.h index 5942c3b6..9b2c2a86 100644 --- a/Sources/Tools/MaxConvert/plBitmapCreator.h +++ b/Sources/Tools/MaxConvert/plBitmapCreator.h @@ -100,7 +100,7 @@ class plBitmapCreator static plBitmapCreator &Instance(); plBitmap *CreateTexture( plBitmapData *bd, const plLocation &loc, int clipID = -1 ); - plMipmap *CreateBlankMipmap( uint32_t width, uint32_t height, unsigned config, uint8_t numLevels, const char *keyName, const plLocation &keyLocation ); + plMipmap *CreateBlankMipmap( uint32_t width, uint32_t height, unsigned config, uint8_t numLevels, const plString &keyName, const plLocation &keyLocation ); void Init( hsBool save, plErrorMsg *msg ); void DeInit( void ); diff --git a/Sources/Tools/MaxConvert/plClusterUtil.cpp b/Sources/Tools/MaxConvert/plClusterUtil.cpp index 79fdd347..08a56434 100644 --- a/Sources/Tools/MaxConvert/plClusterUtil.cpp +++ b/Sources/Tools/MaxConvert/plClusterUtil.cpp @@ -106,8 +106,7 @@ plClusterGroup* plClusterUtil::CreateGroup(plMaxNode* templNode, const char* nam { plClusterGroup* retVal = new plClusterGroup; - char buff[256]; - sprintf(buff, "%s_%s_%d", name, templNode->GetName(), fIdx++); + plString buff = plString::Format("%s_%s_%d", name, templNode->GetName(), fIdx++); hsgResMgr::ResMgr()->NewKey(buff, retVal, templNode->GetLocation(), templNode->GetLoadMask()); plKey sceneNode = templNode->GetRoomKey(); diff --git a/Sources/Tools/MaxConvert/plLayerConverter.cpp b/Sources/Tools/MaxConvert/plLayerConverter.cpp index 90dffb79..3144d2c2 100644 --- a/Sources/Tools/MaxConvert/plLayerConverter.cpp +++ b/Sources/Tools/MaxConvert/plLayerConverter.cpp @@ -295,7 +295,7 @@ plLayerInterface *plLayerConverter::IConvertLayerTex( plPlasmaMAXLayer *layer } // Get a new layer to play with - plLayer *plasmaLayer = ICreateLayer( layer->GetName(), upperLayer, loc ); + plLayer *plasmaLayer = ICreateLayer( plString::FromUtf8( layer->GetName() ), upperLayer, loc ); // We're using a texture, try and get its info PBBitmap *pbbm = nil; @@ -430,7 +430,7 @@ plLayerInterface *plLayerConverter::IConvertStaticEnvLayer( plPlasmaMAXLayer } // Get a new layer to play with - plLayer *plasmaLayer = ICreateLayer( layer->GetName(), upperLayer, loc ); + plLayer *plasmaLayer = ICreateLayer( plString::FromUtf8( layer->GetName() ), upperLayer, loc ); // Get the texture info PBBitmap *pbbm = bitmapPB->GetBitmap( plStaticEnvLayer::kBmpFrontBitmap + 0 ); @@ -540,7 +540,7 @@ plLayerInterface *plLayerConverter::IConvertDynamicEnvLayer( plPlasmaMAXLayer } // Get a new layer to play with - plLayer *plasmaLayer = ICreateLayer( layer->GetName(), upperLayer, loc ); + plLayer *plasmaLayer = ICreateLayer( plString::FromUtf8( layer->GetName() ), upperLayer, loc ); // Get the anchor node plMaxNode *anchor = (plMaxNode *)bitmapPB->GetINode( plDynamicEnvLayer::kBmpAnchorNode ); @@ -550,7 +550,7 @@ plLayerInterface *plLayerConverter::IConvertDynamicEnvLayer( plPlasmaMAXLayer if( !anchor->CanConvert() || !( anchor->GetForceLocal() || anchor->GetDrawable() ) ) { - fErrorMsg->Set( true, "Plasma Layer Error", "The dynamic envMap material %s has an invalid anchor specified. Please specify a valid Plasma scene object as an anchor.", plasmaLayer->GetKeyName() ).Show(); + fErrorMsg->Set( true, "Plasma Layer Error", "The dynamic envMap material %s has an invalid anchor specified. Please specify a valid Plasma scene object as an anchor.", plasmaLayer->GetKeyName().c_str() ).Show(); fErrorMsg->Set(); return (plLayerInterface *)plasmaLayer; } @@ -563,14 +563,14 @@ plLayerInterface *plLayerConverter::IConvertDynamicEnvLayer( plPlasmaMAXLayer plasmaLayer->SetUVWSrc( plasmaLayer->GetUVWSrc() | plLayerInterface::kUVWReflect ); // Create the texture. If it works, assign it to the layer - char texName[ 256 ]; + plString texName; if( anchor == maxNode ) { // Self-anchoring material, make sure the name is unique via the nodeName - sprintf( texName, "%s_cubicRT@%s", plasmaLayer->GetKeyName(), maxNode->GetName() ); + texName = plString::Format( "%s_cubicRT@%s", plasmaLayer->GetKeyName().c_str(), maxNode->GetName() ); } else - sprintf( texName, "%s_cubicRT", plasmaLayer->GetKeyName() ); + texName = plString::Format( "%s_cubicRT", plasmaLayer->GetKeyName().c_str() ); plBitmap *texture = (plBitmap *)IMakeCubicRenderTarget( texName, maxNode, anchor ); if( texture ) @@ -606,7 +606,7 @@ plLayerInterface *plLayerConverter::IConvertCameraLayer(plPlasmaMAXLayer *lay return nil; } - plLayer *plasmaLayer = ICreateLayer (layer->GetName(), upperLayer, loc); + plLayer *plasmaLayer = ICreateLayer (plString::FromUtf8(layer->GetName()), upperLayer, loc); plMaxNode *rootNode = (plMaxNode*)pb->GetINode(ParamID(plMAXCameraLayer::kRootNode)); plDynamicCamMap *map = plEnvMapComponent::GetCamMap(rootNode ? rootNode : maxNode); @@ -678,7 +678,7 @@ plLayerInterface *plLayerConverter::IConvertDynamicTextLayer( plPlasmaMAXLaye } // Get a new layer to play with - plLayer *plasmaLayer = ICreateLayer( maxLayer->GetName(), upperLayer, loc ); + plLayer *plasmaLayer = ICreateLayer( plString::FromUtf8( maxLayer->GetName() ), upperLayer, loc ); /// UV Gen @@ -772,8 +772,7 @@ static uint32_t MakeUInt32Color(float r, float g, float b, float a) plBitmap* plLayerConverter::IGetAttenRamp(plMaxNode *node, BOOL isAdd, int loClamp, int hiClamp) { - char funkName[512]; - sprintf(funkName, "%s_%d_%d", + plString funkName = plString::Format("%s_%d_%d", isAdd ? "AttenRampAdd" : "AttenRampMult", loClamp, hiClamp); @@ -831,7 +830,7 @@ plBitmap* plLayerConverter::IGetAttenRamp(plMaxNode *node, BOOL isAdd, int loCla } -plLayer* plLayerConverter::ICreateAttenuationLayer(const char* name, plMaxNode *node, int uvwSrc, +plLayer* plLayerConverter::ICreateAttenuationLayer(const plString& name, plMaxNode *node, int uvwSrc, float tr0, float op0, float tr1, float op1, int loClamp, int hiClamp) { @@ -917,7 +916,7 @@ plLayerInterface* plLayerConverter::IConvertAngleAttenLayer(plPlasmaMAXLayer *la int uvwSrc = aaLay->Reflect() ? plLayerInterface::kUVWReflect : plLayerInterface::kUVWNormal; - plLayer* lut = ICreateAttenuationLayer(layer->GetName(), maxNode, uvwSrc, tr0, op0, tr1, op1, loClamp, hiClamp); + plLayer* lut = ICreateAttenuationLayer(plString::FromUtf8(layer->GetName()), maxNode, uvwSrc, tr0, op0, tr1, op1, loClamp, hiClamp); return lut; @@ -925,7 +924,7 @@ plLayerInterface* plLayerConverter::IConvertAngleAttenLayer(plPlasmaMAXLayer *la } //// ICreateLayer ///////////////////////////////////////////////////////////// -plLayer *plLayerConverter::ICreateLayer( const char *name, hsBool upperLayer, plLocation &loc ) +plLayer *plLayerConverter::ICreateLayer( const plString &name, hsBool upperLayer, plLocation &loc ) { hsGuardBegin( "plPlasmaMAXLayer::ICreateLayer" ); @@ -969,11 +968,11 @@ void plLayerConverter::IProcessUVGen( plPlasmaMAXLayer *srcLayer, plLayer *de // UVW Src int32_t uvwSrc = srcLayer->GetMapChannel() - 1; - if( fErrorMsg->Set( !( fWarned & kWarnedTooManyUVs ) && - ( ( uvwSrc < 0 ) || ( uvwSrc >= plGeometrySpan::kMaxNumUVChannels ) ), - destLayer->GetKeyName(), "Only %d UVW channels (1-%d) currently supported", + if( fErrorMsg->Set( !( fWarned & kWarnedTooManyUVs ) && + ( ( uvwSrc < 0 ) || ( uvwSrc >= plGeometrySpan::kMaxNumUVChannels ) ), + destLayer->GetKeyName().c_str(), "Only %d UVW channels (1-%d) currently supported", plGeometrySpan::kMaxNumUVChannels, plGeometrySpan::kMaxNumUVChannels).CheckAskOrCancel() ) - fWarned |= kWarnedTooManyUVs; + fWarned |= kWarnedTooManyUVs; fErrorMsg->Set( false ); destLayer->SetUVWSrc( uvwSrc ); @@ -989,19 +988,18 @@ void plLayerConverter::IProcessUVGen( plPlasmaMAXLayer *srcLayer, plLayer *de //// ICreateDynTextMap //////////////////////////////////////////////////////// -plDynamicTextMap *plLayerConverter::ICreateDynTextMap( const char *layerName, uint32_t width, uint32_t height, +plDynamicTextMap *plLayerConverter::ICreateDynTextMap( const plString &layerName, uint32_t width, uint32_t height, hsBool includeAlphaChannel, plMaxNode *node ) { hsGuardBegin( "plPlasmaMAXLayer::ICreateDynTextMap" ); - char texName[ 256 ]; plKey key; plDynamicTextMap *map = nil; // Need a unique key name for every layer that uses one. We could also key // off of width and height, but layerName should be more than plenty - sprintf( texName, "%s_dynText", layerName ); + plString texName = plString::Format( "%s_dynText", layerName ); // Does it already exist? key = node->FindPageKey( plDynamicTextMap::Index(), texName ); @@ -1086,13 +1084,12 @@ plLayer *plLayerConverter::IAssignTexture( plBitmapData *bd, plMaxNode *maxNode, // Makes a plCubicRenderTarget as a texture. Also constructs the associated // modifier and attaches it to the necessary object (hacked for now) -plCubicRenderTarget *plLayerConverter::IMakeCubicRenderTarget( const char *name, plMaxNode *node, plMaxNode *anchor ) +plCubicRenderTarget *plLayerConverter::IMakeCubicRenderTarget( const plString &name, plMaxNode *node, plMaxNode *anchor ) { plDynamicEnvMap* env = plEnvMapComponent::GetEnvMap(anchor); if( env ) return env; - char modName[ 256 ]; plCubicRenderTarget *cubic = nil; @@ -1123,7 +1120,7 @@ plCubicRenderTarget *plLayerConverter::IMakeCubicRenderTarget( const char *name, /// Now make a modifier plCubicRenderTargetModifier *mod = new plCubicRenderTargetModifier(); - sprintf( modName, "%s_mod", name ); + plString modName = plString::Format( "%s_mod", name.c_str() ); hsgResMgr::ResMgr()->NewKey( modName, mod, node->GetLocation() ); hsgResMgr::ResMgr()->AddViaNotify( cubic->GetKey(), new plGenRefMsg( mod->GetKey(), plRefMsg::kOnCreate, 0, 0 ), plRefFlags::kPassiveRef ); diff --git a/Sources/Tools/MaxConvert/plLayerConverter.h b/Sources/Tools/MaxConvert/plLayerConverter.h index 7c8fbe03..1782b6d7 100644 --- a/Sources/Tools/MaxConvert/plLayerConverter.h +++ b/Sources/Tools/MaxConvert/plLayerConverter.h @@ -72,6 +72,7 @@ class plBitmap; class plCubicRenderTarget; class hsConverterUtils; class plDynamicTextLayer; +class plString; class plLayerConverter { @@ -112,12 +113,12 @@ class plLayerConverter hsTArray fConvertedLayers; - plLayer *ICreateLayer( const char *name, hsBool upperLayer, plLocation &loc ); + plLayer *ICreateLayer( const plString &name, hsBool upperLayer, plLocation &loc ); void IProcessUVGen( plPlasmaMAXLayer *srcLayer, plLayer *destLayer, plBitmapData *bitmapData, hsBool preserveUVOffset ); - plDynamicTextMap *ICreateDynTextMap( const char *layerName, uint32_t width, uint32_t height, hsBool includeAlpha, plMaxNode *node ); + plDynamicTextMap *ICreateDynTextMap( const plString &layerName, uint32_t width, uint32_t height, hsBool includeAlpha, plMaxNode *node ); plLayer *IAssignTexture( plBitmapData *bd, plMaxNode *maxNode, plLayer *destLayer, hsBool upperLayer, int clipID = -1 ); - plCubicRenderTarget *IMakeCubicRenderTarget( const char *name, plMaxNode *maxNode, plMaxNode *anchor ); + plCubicRenderTarget *IMakeCubicRenderTarget( const plString &name, plMaxNode *maxNode, plMaxNode *anchor ); // Add your function to process your layer type here plLayerInterface *IConvertLayerTex( plPlasmaMAXLayer *layer, plMaxNode *maxNode, uint32_t blendFlags, hsBool preserveUVOffset, hsBool upperLayer ); @@ -127,12 +128,12 @@ class plLayerConverter plLayerInterface *IConvertDynamicTextLayer( plPlasmaMAXLayer *layer, plMaxNode *maxNode, uint32_t blendFlags, hsBool preserveUVOffset, hsBool upperLayer ); plBitmap* IGetAttenRamp( plMaxNode *maxNode, BOOL isAdd, int loClamp, int hiClamp); - plLayer* ICreateAttenuationLayer(const char* name, plMaxNode *maxNode, int uvwSrc, float tr0, float op0, float tr1, float op1, int loClamp, int hiClamp); + plLayer* ICreateAttenuationLayer(const plString& name, plMaxNode *maxNode, int uvwSrc, float tr0, float op0, float tr1, float op1, int loClamp, int hiClamp); plLayerInterface* IConvertAngleAttenLayer(plPlasmaMAXLayer *layer, plMaxNode *maxNode, uint32_t blendFlags, hsBool preserveUVOffset, hsBool upperLayer); void IRegisterConversion( plPlasmaMAXLayer *origLayer, plLayerInterface *convertedLayer ); - uint32_t *IGetInitBitmapBuffer( plDynamicTextLayer *layer ) const; + uint32_t *IGetInitBitmapBuffer( plDynamicTextLayer *layer ) const; }; diff --git a/Sources/Tools/MaxConvert/plLightMapGen.cpp b/Sources/Tools/MaxConvert/plLightMapGen.cpp index 1760a9db..ce96089a 100644 --- a/Sources/Tools/MaxConvert/plLightMapGen.cpp +++ b/Sources/Tools/MaxConvert/plLightMapGen.cpp @@ -365,8 +365,7 @@ hsBool plLightMapGen::ICompressLightMaps() { const plLocation &textureLoc = plPluginResManager::ResMgr()->GetCommonPage(orig->GetKey()->GetUoid().GetLocation(), plAgeDescription::kTextures ); - char name[512]; - sprintf(name, "%s_DX", orig->GetKey()->GetName()); + plString name = plString::Format("%s_DX", orig->GetKey()->GetName().c_str()); plKey compKey = hsgResMgr::ResMgr()->FindKey(plUoid(textureLoc, plMipmap::Index(), name)); if( compKey ) @@ -1252,8 +1251,7 @@ plLayerInterface* plLightMapGen::IMakeLightMapLayer(plMaxNode* node, plGeometryS return mat->GetPiggyBack(i); } - char newMatName[256]; - sprintf(newMatName, "%s_%s_LIGHTMAPGEN", mat->GetKey()->GetName(), node->GetName()); + plString newMatName = plString::Format("%s_%s_LIGHTMAPGEN", mat->GetKey()->GetName().c_str(), node->GetName()); plLocation nodeLoc = node->GetLocation(); plKey matKey = hsgResMgr::ResMgr()->FindKey(plUoid(nodeLoc, hsGMaterial::Index(), newMatName)); @@ -1291,8 +1289,7 @@ plLayerInterface* plLightMapGen::IMakeLightMapLayer(plMaxNode* node, plGeometryS // Make sure layer (and mip) name are unique across pages by putting the page name in const plPageInfo* pageInfo = plKeyFinder::Instance().GetLocationInfo(node->GetLocation()); - char layName[256]; - sprintf(layName, "%s_%s_LIGHTMAPGEN", pageInfo->GetPage(), node->GetName()); + plString layName = plString::Format("%s_%s_LIGHTMAPGEN", pageInfo->GetPage(), node->GetName()); plKey layKey = node->FindPageKey(plLayer::Index(), layName); @@ -1309,8 +1306,7 @@ plLayerInterface* plLightMapGen::IMakeLightMapLayer(plMaxNode* node, plGeometryS } else { - char mipmapName[ 256 ]; - sprintf( mipmapName, "%s_mip", layName ); + plString mipmapName = plString::Format( "%s_mip", layName.c_str() ); // Deleted the NOTE here because it was incorrect in every meaningful sense of the word. - mf @@ -1320,8 +1316,7 @@ plLayerInterface* plLightMapGen::IMakeLightMapLayer(plMaxNode* node, plGeometryS if( !mipKey && !fRecalcLightMaps ) { - char compressedName[512]; - sprintf(compressedName, "%s_DX", mipmapName); + plString compressedName = plString::Format("%s_DX", mipmapName.c_str()); plKey compKey = hsgResMgr::ResMgr()->FindKey(plUoid(textureLoc, plMipmap::Index(), compressedName)); diff --git a/Sources/Tools/MaxMain/plCommonObjLib.cpp b/Sources/Tools/MaxMain/plCommonObjLib.cpp index dd6d0875..8f359bbf 100644 --- a/Sources/Tools/MaxMain/plCommonObjLib.cpp +++ b/Sources/Tools/MaxMain/plCommonObjLib.cpp @@ -219,7 +219,7 @@ hsBool plCommonObjLib::RemoveObjectAndKey( plKey &key ) // our lib. Returns nil if not found. Use to find out if you already have a // object of a given name that was previously exported. -hsKeyedObject *plCommonObjLib::FindObject( const char *name, uint16_t classType /* = -1 */ ) +hsKeyedObject *plCommonObjLib::FindObject( const plString &name, uint16_t classType /* = -1 */ ) { int i; @@ -229,7 +229,7 @@ hsKeyedObject *plCommonObjLib::FindObject( const char *name, uint16_t classTyp const plUoid &uoid = fObjects[ i ]->GetKey()->GetUoid(); - if( stricmp( uoid.GetObjectName(), name ) == 0 && + if( uoid.GetObjectName().Compare( name, plString::kCaseInsensitive ) == 0 && ( classType == (uint16_t)-1 || classType == uoid.GetClassType() ) ) { return fObjects[ i ]; diff --git a/Sources/Tools/MaxMain/plCommonObjLib.h b/Sources/Tools/MaxMain/plCommonObjLib.h index a1dfcdac..24f55cd6 100644 --- a/Sources/Tools/MaxMain/plCommonObjLib.h +++ b/Sources/Tools/MaxMain/plCommonObjLib.h @@ -67,6 +67,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "hsTemplates.h" +class plString; + //// Class Definition ///////////////////////////////////////////////////////// @@ -88,7 +90,7 @@ class plCommonObjLib void AddObject( hsKeyedObject *object ); hsBool RemoveObjectAndKey( plKey &key ); - hsKeyedObject *FindObject( const char *name, uint16_t classType = (uint16_t)-1 ); + hsKeyedObject *FindObject( const plString &name, uint16_t classType = (uint16_t)-1 ); void ClearObjectList( void ); /// THIS IS YOUR VIRTUAL HERE. Override this to define which objects you collect diff --git a/Sources/Tools/MaxMain/plMaxNode.cpp b/Sources/Tools/MaxMain/plMaxNode.cpp index 16e22a1c..644e2b67 100644 --- a/Sources/Tools/MaxMain/plMaxNode.cpp +++ b/Sources/Tools/MaxMain/plMaxNode.cpp @@ -154,23 +154,23 @@ static plKey ExternAddModifier(plMaxNodeBase *node, plModifier *mod) return nil;//((plMaxNode*)node)->AddModifier(mod); } -static plKey ExternGetNewKey(const char *name, plModifier *mod, plLocation loc) +static plKey ExternGetNewKey(const plString &name, plModifier *mod, plLocation loc) { return nil;//hsgResMgr::ResMgr()->NewKey(name, mod, loc); } // In plResponderComponent (for no apparent reason). -int GetMatAnimModKey(Mtl* mtl, plMaxNodeBase* node, const char *segName, hsTArray& keys); +int GetMatAnimModKey(Mtl* mtl, plMaxNodeBase* node, const plString &segName, hsTArray& keys); // In plAudioComponents int GetSoundNameAndIdx(plComponentBase *comp, plMaxNodeBase *node, const char*& name); #include "MaxComponent/plAnimComponent.h" -static const char *GetAnimCompAnimName(plComponentBase *comp) +static plString GetAnimCompAnimName(plComponentBase *comp) { if (comp->ClassID() == ANIM_COMP_CID || comp->ClassID() == ANIM_GROUP_COMP_CID) return ((plAnimComponentBase*)comp)->GetAnimName(); - return nil; + return plString::Null; } static plKey GetAnimCompModKey(plComponentBase *comp, plMaxNodeBase *node) @@ -258,7 +258,7 @@ void plMaxBoneMap::SortBones() /////////////////////////////////////////////////////////////////////////////////////////////////// -plKey plMaxNode::AddModifier(plModifier *pMod, const char* name) +plKey plMaxNode::AddModifier(plModifier *pMod, const plString& name) { plKey modKey = pMod->GetKey(); if (!modKey) @@ -539,7 +539,7 @@ hsBool plMaxNode::MakeSceneObject(plErrorMsg *pErrMsg, plConvertSettings *settin // Handle this as a SceneObject pso = new plSceneObject; - objKey = hsgResMgr::ResMgr()->NewKey(GetName(), pso, nodeLoc, GetLoadMask()); + objKey = hsgResMgr::ResMgr()->NewKey(plString::FromUtf8(GetName()), pso, nodeLoc, GetLoadMask()); // Remember info in MaxNodeData block for later plMaxNodeData *pDat = GetMaxNodeData(); @@ -828,7 +828,7 @@ hsBool plMaxNode::MakePhysical(plErrorMsg *pErrMsg, plConvertSettings *settings) // add the object to the resource manager, keyed to the new name plLocation nodeLoc = GetKey()->GetUoid().GetLocation(); - const char *objName = GetKey()->GetName(); + plString objName = GetKey()->GetName(); plKey physKey = hsgResMgr::ResMgr()->NewKey(objName, physical, nodeLoc, GetLoadMask()); if (!physical->Init(recipe)) @@ -917,7 +917,7 @@ hsBool plMaxNode::MakeCoordinateInterface(plErrorMsg *pErrMsg, plConvertSettings //------------------------- plKey pNodeKey = GetKey(); hsAssert(pNodeKey, "Missing key for this Object"); - const char *pName = pNodeKey->GetName(); + plString pName = pNodeKey->GetName(); plLocation nodeLoc = GetLocation(); plKey pCiKey = hsgResMgr::ResMgr()->NewKey(pName, ci,nodeLoc, GetLoadMask()); @@ -990,7 +990,7 @@ hsBool plMaxNode::MakeModifiers(plErrorMsg *pErrMsg, plConvertSettings *settings } pMod->SetScale(scale); } - AddModifier(pMod, GetName()); + AddModifier(pMod, plString::FromUtf8(GetName())); } } return true; @@ -1445,8 +1445,7 @@ hsBool plMaxNode::MakeMesh(plErrorMsg *pErrMsg, plConvertSettings *settings) for (i = 0; i < spanArray.GetCount(); i++) swapSpans->Append(spanArray.Get(i)); - char tmpName[256]; - sprintf(tmpName, "%s_SMsh", GetName()); + plString tmpName = plString::Format("%s_SMsh", GetName()); hsgResMgr::ResMgr()->NewKey(tmpName, GetSwappableGeom(), GetLocation(), GetLoadMask()); return true; @@ -2255,15 +2254,15 @@ hsBool plMaxNode::ConvertToOccluder(plErrorMsg* pErrMsg, hsBool twoSided, hsBool occ->ComputeFromPolys(); // Register it. - char tmpName[256]; - if( GetKey() && GetKey()->GetName() && *GetKey()->GetName() ) + plString tmpName; + if( GetKey() && !GetKey()->GetName().IsEmpty() ) { - sprintf(tmpName, "%s_%s", GetKey()->GetName(), "Occluder"); + tmpName = plString::Format("%s_Occluder", GetKey()->GetName().c_str()); } else { static int numOcc = 0; - sprintf(tmpName, "%s_%4.4d", "Occluder", numOcc); + tmpName = plString::Format("Occluder_%4.4d", numOcc); } plKey key = hsgResMgr::ResMgr()->NewKey( tmpName, occ, nodeLoc, GetLoadMask() ); @@ -2986,7 +2985,7 @@ void plMaxNode::GetRTLightAttenAnim(IParamBlock2* ProperPB, plAGAnim *anim) if( falloffCtl ) { plLeafController* subCtl; - if (!strcmp(anim->GetName(), ENTIRE_ANIMATION_NAME)) + if (!anim->GetName().Compare(ENTIRE_ANIMATION_NAME)) subCtl = hsControlConverter::Instance().MakeScalarController(falloffCtl, this); else subCtl = hsControlConverter::Instance().MakeScalarController(falloffCtl, this, @@ -3002,7 +3001,7 @@ void plMaxNode::GetRTLightAttenAnim(IParamBlock2* ProperPB, plAGAnim *anim) plScalarControllerChannel *chan = new plScalarControllerChannel(subCtl); app->SetChannel(chan); anim->AddApplicator(app); - if (!strcmp(anim->GetName(), ENTIRE_ANIMATION_NAME)) + if (!anim->GetName().Compare(ENTIRE_ANIMATION_NAME)) anim->ExtendToLength(subCtl->GetLength()); } else @@ -3056,7 +3055,7 @@ void plMaxNode::GetRTLightAttenAnim(IParamBlock2* ProperPB, plAGAnim *anim) plScalarControllerChannel *chan = new plScalarControllerChannel(subCtl); app->SetChannel(chan); anim->AddApplicator(app); - if (!strcmp(anim->GetName(), ENTIRE_ANIMATION_NAME)) + if (!anim->GetName().Compare(ENTIRE_ANIMATION_NAME)) anim->ExtendToLength(subCtl->GetLength()); float attenConst, attenLinear, attenQuadratic, attenCutoff; @@ -3125,7 +3124,7 @@ void plMaxNode::GetRTLightColAnim(IParamBlock2* ProperPB, plAGAnim *anim) if( ambientCtl ) { plController* ctl; - if (!strcmp(anim->GetName(), ENTIRE_ANIMATION_NAME)) + if (!anim->GetName().Compare(ENTIRE_ANIMATION_NAME)) ctl = hsControlConverter::Instance().MakeColorController(ambientCtl, this); else ctl = hsControlConverter::Instance().MakeColorController(ambientCtl, this, anim->GetStart(), anim->GetEnd()); @@ -3137,14 +3136,14 @@ void plMaxNode::GetRTLightColAnim(IParamBlock2* ProperPB, plAGAnim *anim) chan = new plPointControllerChannel(ctl); app->SetChannel(chan); anim->AddApplicator(app); - if (!strcmp(anim->GetName(), ENTIRE_ANIMATION_NAME)) + if (!anim->GetName().Compare(ENTIRE_ANIMATION_NAME)) anim->ExtendToLength(ctl->GetLength()); } } if( colorCtl ) { plController* ctl; - if (!strcmp(anim->GetName(), ENTIRE_ANIMATION_NAME)) + if (!anim->GetName().Compare(ENTIRE_ANIMATION_NAME)) ctl = hsControlConverter::Instance().MakeColorController(colorCtl, this); else ctl = hsControlConverter::Instance().MakeColorController(colorCtl, this, anim->GetStart(), anim->GetEnd()); @@ -3157,14 +3156,14 @@ void plMaxNode::GetRTLightColAnim(IParamBlock2* ProperPB, plAGAnim *anim) chan = new plPointControllerChannel(ctl); app->SetChannel(chan); anim->AddApplicator(app); - if (!strcmp(anim->GetName(), ENTIRE_ANIMATION_NAME)) + if (!anim->GetName().Compare(ENTIRE_ANIMATION_NAME)) anim->ExtendToLength(ctl->GetLength()); } } if( specCtl ) { plController* ctl; - if (!strcmp(anim->GetName(), ENTIRE_ANIMATION_NAME)) + if (!anim->GetName().Compare(ENTIRE_ANIMATION_NAME)) ctl = hsControlConverter::Instance().MakeColorController(specCtl, this); else ctl = hsControlConverter::Instance().MakeColorController(specCtl, this, anim->GetStart(), anim->GetEnd()); @@ -3176,7 +3175,7 @@ void plMaxNode::GetRTLightColAnim(IParamBlock2* ProperPB, plAGAnim *anim) chan = new plPointControllerChannel(ctl); app->SetChannel(chan); anim->AddApplicator(app); - if (!strcmp(anim->GetName(), ENTIRE_ANIMATION_NAME)) + if (!anim->GetName().Compare(ENTIRE_ANIMATION_NAME)) anim->ExtendToLength(ctl->GetLength()); } } @@ -3191,7 +3190,7 @@ void plMaxNode::GetRTConeAnim(IParamBlock2* ProperPB, plAGAnim *anim) if( innerCtl ) { plLeafController* ctl; - if (!strcmp(anim->GetName(), ENTIRE_ANIMATION_NAME)) + if (!anim->GetName().Compare(ENTIRE_ANIMATION_NAME)) ctl = hsControlConverter::Instance().MakeScalarController(innerCtl, this); else ctl = hsControlConverter::Instance().MakeScalarController(innerCtl, this, anim->GetStart(), anim->GetEnd()); @@ -3203,14 +3202,14 @@ void plMaxNode::GetRTConeAnim(IParamBlock2* ProperPB, plAGAnim *anim) chan = new plScalarControllerChannel(ctl); app->SetChannel(chan); anim->AddApplicator(app); - if (!strcmp(anim->GetName(), ENTIRE_ANIMATION_NAME)) + if (!anim->GetName().Compare(ENTIRE_ANIMATION_NAME)) anim->ExtendToLength(ctl->GetLength()); } } if( outerCtl ) { plController* ctl; - if (!strcmp(anim->GetName(), ENTIRE_ANIMATION_NAME)) + if (!anim->GetName().Compare(ENTIRE_ANIMATION_NAME)) ctl = hsControlConverter::Instance().MakeScalarController(outerCtl, this); else ctl = hsControlConverter::Instance().MakeScalarController(outerCtl, this, anim->GetStart(), anim->GetEnd()); @@ -3222,7 +3221,7 @@ void plMaxNode::GetRTConeAnim(IParamBlock2* ProperPB, plAGAnim *anim) chan = new plScalarControllerChannel(ctl); app->SetChannel(chan); anim->AddApplicator(app); - if (!strcmp(anim->GetName(), ENTIRE_ANIMATION_NAME)) + if (!anim->GetName().Compare(ENTIRE_ANIMATION_NAME)) anim->ExtendToLength(ctl->GetLength()); } } @@ -3318,7 +3317,7 @@ plDrawableSpans *plMaxNode::IGetSceneNodeSpans( plSceneNode *node, hsBool needBl { plDrawableSpans *spans; - char tmpName[ 512 ]; + plString tmpName; plLocation nodeLoc = GetLocation(); if( !needBlending ) @@ -3344,13 +3343,13 @@ plDrawableSpans *plMaxNode::IGetSceneNodeSpans( plSceneNode *node, hsBool needBl { /// Blending (deferred) spans spans->SetCriteria( crit ); - sprintf( tmpName, "%s_%8.8x_%xBlendSpans", node->GetKeyName(), crit.fLevel.fLevel, crit.fCriteria); + tmpName = plString::Format( "%s_%8.8x_%xBlendSpans", node->GetKeyName().c_str(), crit.fLevel.fLevel, crit.fCriteria); } else { /// Normal spans spans->SetCriteria( crit ); - sprintf( tmpName, "%s_%8.8x_%xSpans", node->GetKeyName(), crit.fLevel.fLevel, crit.fCriteria); + tmpName = plString::Format( "%s_%8.8x_%xSpans", node->GetKeyName().c_str(), crit.fLevel.fLevel, crit.fCriteria); } if (GetSwappableGeomTarget() != (uint32_t)-1 || GetSwappableGeom()) // We intend to swap geometry with this node... flag the drawable as volatile @@ -3650,7 +3649,7 @@ void plMaxNode::SetupBonesAliasesRecur(const char *rootName) { if(CanConvert()) { if (!HasAGMod()) { - const char *nameToUse; + plString nameToUse; // parse UserPropsBuf for entire BoneName line char localName[256]; @@ -3664,19 +3663,19 @@ void plMaxNode::SetupBonesAliasesRecur(const char *rootName) { start+=len; int i=0; - while(*start != '\n' && *start != '\0' && *start) + while(*start != '\n' && *start) { hsAssert(i<256, "localName overflow"); localName[i++]=*start++; } localName[i]=0; - nameToUse = localName; + nameToUse = plString::FromUtf8(localName); } else { - const char *nodeName = GetName(); + plString nodeName = plString::FromUtf8(GetName()); // char str[256]; // sprintf(str, "Missing 'BoneName=foo' UserProp, on object %s, using node name", nodeName ? nodeName : "?"); // hsAssert(false, str); @@ -3696,7 +3695,7 @@ void plMaxNode::SetupBonesAliasesRecur(const char *rootName) } */ plAGModifier *mod = new plAGModifier(nameToUse); - AddModifier(mod, GetName()); + AddModifier(mod, plString::FromUtf8(GetName())); } } @@ -4049,7 +4048,7 @@ plPhysicalProps *plMaxNode::GetPhysicalProps() //// FindPageKey ///////////////////////////////////////////////////////////// // Little helper function. Calls FindKey() in the resManager using the location (page) of this node -plKey plMaxNode::FindPageKey( uint16_t classIdx, const char *name ) +plKey plMaxNode::FindPageKey( uint16_t classIdx, const plString &name ) { return hsgResMgr::ResMgr()->FindKey( plUoid( GetLocation(), classIdx, name ) ); } @@ -4109,7 +4108,7 @@ hsBool plMaxNode::MakeIfaceReferences(plErrorMsg *pErrMsg, plConvertSettings *se { plInterfaceInfoModifier* pMod = new plInterfaceInfoModifier; - plKey modifierKey = hsgResMgr::ResMgr()->NewKey(GetName(), pMod, GetLocation(), GetLoadMask()); + plKey modifierKey = hsgResMgr::ResMgr()->NewKey(plString::FromUtf8(GetName()), pMod, GetLocation(), GetLoadMask()); hsgResMgr::ResMgr()->AddViaNotify(modifierKey, new plObjRefMsg(GetSceneObject()->GetKey(), plRefMsg::kOnCreate, -1, plObjRefMsg::kModifier), plRefFlags::kActiveRef); for(int i = 0; i < keys.Count(); i++) diff --git a/Sources/Tools/MaxMain/plMaxNode.h b/Sources/Tools/MaxMain/plMaxNode.h index 34cfb5e5..052e2225 100644 --- a/Sources/Tools/MaxMain/plMaxNode.h +++ b/Sources/Tools/MaxMain/plMaxNode.h @@ -130,7 +130,7 @@ public: enum { kSetupProperties, kPreConvert, kConvert }; hsBool DoComponents(int convertType, plErrorMsg *, plConvertSettings *); - plKey AddModifier(plModifier *pMod, const char* name); + plKey AddModifier(plModifier *pMod, const plString& name); hsBool ConvertToOccluder (plErrorMsg* pErrMsg, hsBool twoSided, hsBool isHole); @@ -179,7 +179,7 @@ public: plPhysicalProps *GetPhysicalProps(); // Little helper function. Calls FindKey() in the resManager using the location (page) of this node - plKey FindPageKey( uint16_t classIdx, const char *name ); + plKey FindPageKey( uint16_t classIdx, const plString &name ); const char *GetAgeName(); void CheckSynchOptions(plSynchedObject* so); diff --git a/Sources/Tools/MaxMain/plPluginResManager.cpp b/Sources/Tools/MaxMain/plPluginResManager.cpp index 4fb69433..e004920c 100644 --- a/Sources/Tools/MaxMain/plPluginResManager.cpp +++ b/Sources/Tools/MaxMain/plPluginResManager.cpp @@ -67,8 +67,7 @@ plKey plPluginResManager::NameToLoc(const char* age, const char* page, int32_t s hsAssert(pageNode != nil, "No page returned from INameToPage(), shouldn't be possible"); // Go find the sceneNode now, since we know the page exists (go through our normal channels, though) - char keyName[256]; - sprintf(keyName, "%s_%s", age, page); + plString keyName = plString::Format("%s_%s", age, page); plUoid nodeUoid(pageNode->GetPageInfo().GetLocation(), plSceneNode::Index(), keyName); diff --git a/Sources/Tools/MaxMain/plTextureExportLog.cpp b/Sources/Tools/MaxMain/plTextureExportLog.cpp index ba143b61..de5578d7 100644 --- a/Sources/Tools/MaxMain/plTextureExportLog.cpp +++ b/Sources/Tools/MaxMain/plTextureExportLog.cpp @@ -146,7 +146,7 @@ void plTextureExportLog::Write( void ) plRenderTarget* rend = plRenderTarget::ConvertNoRef( node->fBitmap ); // Name - IWriteTabbedString( stream, node->fBitmap->GetKeyName(), dynText != nil ? 8 : 4 ); + IWriteTabbedString( stream, _TEMP_CONVERT_TO_CONST_CHAR( node->fBitmap->GetKeyName() ), dynText != nil ? 8 : 4 ); // Size, formatted size = node->fBitmap->GetTotalSize(); diff --git a/Sources/Tools/MaxPlasmaMtls/Layers/plPlasmaMAXLayer.cpp b/Sources/Tools/MaxPlasmaMtls/Layers/plPlasmaMAXLayer.cpp index a60b771c..92e1a412 100644 --- a/Sources/Tools/MaxPlasmaMtls/Layers/plPlasmaMAXLayer.cpp +++ b/Sources/Tools/MaxPlasmaMtls/Layers/plPlasmaMAXLayer.cpp @@ -154,10 +154,7 @@ class plLayerTargetContainer : public hsKeyedObject plLayerTargetContainer() { - char str[ 512 ]; - - - sprintf( str, "plLayerTargetContainer-%d", fKeyCount++ ); + plString str = plString::Format( "plLayerTargetContainer-%d", fKeyCount++ ); hsgResMgr::ResMgr()->NewKey( str, this, plLocation::kGlobalFixedLoc ); } }; diff --git a/Sources/Tools/MaxPlasmaMtls/Materials/plAnimStealthConvert.cpp b/Sources/Tools/MaxPlasmaMtls/Materials/plAnimStealthConvert.cpp index 417284a9..f97ef900 100644 --- a/Sources/Tools/MaxPlasmaMtls/Materials/plAnimStealthConvert.cpp +++ b/Sources/Tools/MaxPlasmaMtls/Materials/plAnimStealthConvert.cpp @@ -62,7 +62,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com //// Helpers ///////////////////////////////////////////////////////////////// -static void ISearchLayerRecur( plLayerInterface *layer, const char *segName, hsTArray& keys ) +static void ISearchLayerRecur( plLayerInterface *layer, const plString &segName, hsTArray& keys ) { if( !layer ) return; @@ -70,10 +70,8 @@ static void ISearchLayerRecur( plLayerInterface *layer, const char *segName, hsT plLayerAnimation *animLayer = plLayerAnimation::ConvertNoRef(layer); if (animLayer) { - char *ID = animLayer->GetSegmentID(); - if (ID == nil) - ID = ""; - if (!strcmp(ID, segName)) + plString ID = animLayer->GetSegmentID(); + if (!ID.Compare(segName)) { if( keys.kMissingIndex == keys.Find(animLayer->GetKey()) ) keys.Append(animLayer->GetKey()); @@ -83,17 +81,16 @@ static void ISearchLayerRecur( plLayerInterface *layer, const char *segName, hsT ISearchLayerRecur(layer->GetAttached(), segName, keys); } -static int ISearchLayerRecur(hsGMaterial* mat, const char *segName, hsTArray& keys) +static int ISearchLayerRecur(hsGMaterial* mat, const plString &segName, hsTArray& keys) { - if (segName == nil || strcmp( segName, ENTIRE_ANIMATION_NAME ) == 0 ) - segName = ""; + plString name = (segName.IsNull() || segName.Compare( ENTIRE_ANIMATION_NAME ) == 0 ) ? _TEMP_CONVERT_FROM_LITERAL( "" ) : segName; int i; for( i = 0; i < mat->GetNumLayers(); i++ ) - ISearchLayerRecur(mat->GetLayer(i), segName, keys); + ISearchLayerRecur(mat->GetLayer(i), name, keys); return keys.GetCount(); } -static int GetMatAnimModKey(Mtl* mtl, plMaxNodeBase* node, const char* segName, hsTArray& keys) +static int GetMatAnimModKey(Mtl* mtl, plMaxNodeBase* node, const plString& segName, hsTArray& keys) { int retVal = 0; @@ -129,8 +126,8 @@ SegmentSpec *plAnimStealthNode::IGetSegmentSpec( void ) const { if( fCachedSegMap != nil ) { - const char *name = GetSegmentName(); - if( name != nil ) + plString name = GetSegmentName(); + if( !name.IsNull() ) { SegmentMap::iterator i = fCachedSegMap->find( name ); if( i != fCachedSegMap->end() ) @@ -167,8 +164,8 @@ void plAnimStealthNode::GetLoopPoints( float &start, float &end ) const start = GetSegStart(); end = GetSegEnd(); - const char *loopName = GetLoopName(); - if( loopName != nil && loopName[ 0 ] != 0 && fCachedSegMap != nil ) + plString loopName = GetLoopName(); + if( !loopName.IsEmpty() && fCachedSegMap != nil ) GetSegMapAnimTime( loopName, fCachedSegMap, SegmentSpec::kLoop, start, end ); } @@ -193,8 +190,8 @@ void plAnimStealthNode::GetAllStopPoints( hsTArray &out ) void plAnimStealthNode::StuffToTimeConvert( plAnimTimeConvert &convert, float maxLength ) { - const char *segName = GetSegmentName(); - bool isEntire = ( segName == nil || strcmp( segName, ENTIRE_ANIMATION_NAME ) == 0 ) ? true : false; + plString segName = GetSegmentName(); + bool isEntire = ( segName.IsNull() || segName.Compare( ENTIRE_ANIMATION_NAME ) == 0 ) ? true : false; if( isEntire ) { diff --git a/Sources/Tools/MaxPlasmaMtls/Materials/plAnimStealthNode.cpp b/Sources/Tools/MaxPlasmaMtls/Materials/plAnimStealthNode.cpp index db647932..9b34aca8 100644 --- a/Sources/Tools/MaxPlasmaMtls/Materials/plAnimStealthNode.cpp +++ b/Sources/Tools/MaxPlasmaMtls/Materials/plAnimStealthNode.cpp @@ -250,12 +250,12 @@ plAnimStealthNode *plAnimStealthNode::ConvertToStealth( INode *objNode ) } -const char *plAnimStealthNode::GetSegmentName( void ) const +plString plAnimStealthNode::GetSegmentName( void ) const { const char *str = fParamBlock->GetStr( (ParamID)kPBName ); if( str == nil || str[ 0 ] == 0 ) - return ENTIRE_ANIMATION_NAME; - return str; + return _TEMP_CONVERT_FROM_LITERAL( ENTIRE_ANIMATION_NAME ); + return plString::FromUtf8(str); } void plAnimStealthNode::SetSegment( const char *name ) @@ -710,8 +710,8 @@ void plStealthDlgProc::ILoadLoops(IParamBlock2 *pb) int defIdx = SendMessage( hLoops, CB_ADDSTRING, 0, (LPARAM)ENTIRE_ANIMATION_NAME ); SendMessage( hLoops, CB_SETITEMDATA, defIdx, kDefault ); - const char *segName = pb->GetStr( (ParamID)plAnimStealthNode::kPBName ); - if( segName == nil || fSegMap == nil ) + plString segName = plString::FromUtf8( pb->GetStr( (ParamID)plAnimStealthNode::kPBName ) ); + if( segName.IsNull() || fSegMap == nil ) { // Default of "entire animation", no other loop options SendMessage( hLoops, CB_SETCURSEL, defIdx, 0 ); @@ -733,7 +733,7 @@ void plStealthDlgProc::ILoadLoops(IParamBlock2 *pb) (spec->fEnd == -1 || spec->fEnd <= animSpec->fEnd) ) { // Add the name - int idx = SendMessage( hLoops, CB_ADDSTRING, 0, (LPARAM)spec->fName ); + int idx = SendMessage( hLoops, CB_ADDSTRING, 0, (LPARAM)spec->fName.c_str() ); SendMessage( hLoops, CB_SETITEMDATA, idx, kName ); } } @@ -878,11 +878,11 @@ void plAnimStealthNode::PickTargetNode( IParamBlock2 *destPB, ParamID destPar pick.DoPick(); } -const char *plAnimStealthNode::GetIfaceSegmentName( hsBool allowNil ) +plString plAnimStealthNode::GetIfaceSegmentName( hsBool allowNil ) { // When sending messages to material animations, they're already addressed for the right // layer, no need for a segment name - return nil; + return plString::Null; } //// Parameter Access Functions ////////////////////////////////////////////// @@ -893,14 +893,11 @@ bool plAnimStealthNode::GetAutoStart( void ) const { return (bool)fParamBlo void plAnimStealthNode::SetAutoStart( bool b ) { fParamBlock->SetValue( (ParamID)kPBAutoStart, 0, (int)b ); }; bool plAnimStealthNode::GetLoop( void ) const { return fParamBlock->GetInt( (ParamID)kPBLoop ); } -const char *plAnimStealthNode::GetLoopName( void ) const { return fParamBlock->GetStr( (ParamID)kPBLoopName ); } -void plAnimStealthNode::SetLoop( bool b, const char *name ) +plString plAnimStealthNode::GetLoopName( void ) const { return plString::FromUtf8( fParamBlock->GetStr( (ParamID)kPBLoopName ) ); } +void plAnimStealthNode::SetLoop( bool b, const plString &name ) { fParamBlock->SetValue( (ParamID)kPBLoop, 0, (int)b ); - if( name == nil ) - fParamBlock->SetValue( (ParamID)kPBLoopName, 0, "" ); - else - fParamBlock->SetValue( (ParamID)kPBLoopName, 0, (char *)name ); + fParamBlock->SetValue( (ParamID)kPBLoopName, 0, (char *)name.s_str() ); } uint8_t plAnimStealthNode::GetEaseInType( void ) const { return (uint8_t)fParamBlock->GetInt( (ParamID)kPBEaseInType ); } diff --git a/Sources/Tools/MaxPlasmaMtls/Materials/plAnimStealthNode.h b/Sources/Tools/MaxPlasmaMtls/Materials/plAnimStealthNode.h index f6356746..55825cde 100644 --- a/Sources/Tools/MaxPlasmaMtls/Materials/plAnimStealthNode.h +++ b/Sources/Tools/MaxPlasmaMtls/Materials/plAnimStealthNode.h @@ -142,7 +142,7 @@ public: HWND GetWinDlg( void ) const; // Interesting functions - const char *GetSegmentName( void ) const; + plString GetSegmentName( void ) const; void SetSegment( const char *name ); // nil for "entire animation" // Conversion from stealth's INode to the actual object @@ -203,32 +203,32 @@ public: void SetAutoStart( bool b ); bool GetLoop( void ) const; - const char *GetLoopName( void ) const; - void SetLoop( bool b, const char *name ); + plString GetLoopName( void ) const; + void SetLoop( bool b, const plString &name ); - uint8_t GetEaseInType( void ) const; - float GetEaseInLength( void ) const; - float GetEaseInMin( void ) const; - float GetEaseInMax( void ) const; + uint8_t GetEaseInType( void ) const; + float GetEaseInLength( void ) const; + float GetEaseInMin( void ) const; + float GetEaseInMax( void ) const; void SetEaseIn( uint8_t type, float length, float min, float max ); - uint8_t GetEaseOutType( void ) const; - float GetEaseOutLength( void ) const; - float GetEaseOutMin( void ) const; - float GetEaseOutMax( void ) const; + uint8_t GetEaseOutType( void ) const; + float GetEaseOutLength( void ) const; + float GetEaseOutMin( void ) const; + float GetEaseOutMax( void ) const; void SetEaseOut( uint8_t type, float length, float min, float max ); // Conversion stuff void GetAllStopPoints( hsTArray &out ); - float GetSegStart( void ) const; - float GetSegEnd( void ) const; + float GetSegStart( void ) const; + float GetSegEnd( void ) const; void GetLoopPoints( float &start, float &end ) const; void StuffToTimeConvert( plAnimTimeConvert &convert, float maxLength ); // plAnimObjInterface functions virtual void PickTargetNode( IParamBlock2 *destPB, ParamID destParamID, ParamID typeID ); virtual hsBool IsNodeRestricted( void ) { return true; } - virtual const char *GetIfaceSegmentName( hsBool allowNil ); + virtual plString GetIfaceSegmentName( hsBool allowNil ); virtual hsBool GetKeyList( INode *restrictedNode, hsTArray &outKeys ); virtual hsBool MightRequireSeparateMaterial( void ) { return true; } diff --git a/Sources/Tools/MaxPlasmaMtls/Materials/plBumpMtl.cpp b/Sources/Tools/MaxPlasmaMtls/Materials/plBumpMtl.cpp index 3b2b7ebb..30777b73 100644 --- a/Sources/Tools/MaxPlasmaMtls/Materials/plBumpMtl.cpp +++ b/Sources/Tools/MaxPlasmaMtls/Materials/plBumpMtl.cpp @@ -86,7 +86,7 @@ plBumpMtl::plBumpMtl(BOOL loading) : plPassMtlBase( loading ) // If we do this later (like, when the dialog loads) something blows up, // somewhere in Max. It didn't in 4, it does in 7. This seems to fix it. if (!loading) - IVerifyStealthPresent(ENTIRE_ANIMATION_NAME); + IVerifyStealthPresent(_TEMP_CONVERT_FROM_LITERAL(ENTIRE_ANIMATION_NAME)); } ParamDlg* plBumpMtl::CreateParamDlg(HWND hwMtlEdit, IMtlParams *imp) diff --git a/Sources/Tools/MaxPlasmaMtls/Materials/plDecalMtl.cpp b/Sources/Tools/MaxPlasmaMtls/Materials/plDecalMtl.cpp index 49488fa7..add1dc60 100644 --- a/Sources/Tools/MaxPlasmaMtls/Materials/plDecalMtl.cpp +++ b/Sources/Tools/MaxPlasmaMtls/Materials/plDecalMtl.cpp @@ -93,7 +93,7 @@ plDecalMtl::plDecalMtl(BOOL loading) : plPassMtlBase( loading ) // If we do this later (like, when the dialog loads) something blows up, // somewhere in Max. It didn't in 4, it does in 7. This seems to fix it. if (!loading) - IVerifyStealthPresent(ENTIRE_ANIMATION_NAME); + IVerifyStealthPresent(_TEMP_CONVERT_FROM_LITERAL(ENTIRE_ANIMATION_NAME)); } ParamDlg* plDecalMtl::CreateParamDlg(HWND hwMtlEdit, IMtlParams *imp) diff --git a/Sources/Tools/MaxPlasmaMtls/Materials/plPassAnimDlgProc.cpp b/Sources/Tools/MaxPlasmaMtls/Materials/plPassAnimDlgProc.cpp index 7c15998d..deb666c7 100644 --- a/Sources/Tools/MaxPlasmaMtls/Materials/plPassAnimDlgProc.cpp +++ b/Sources/Tools/MaxPlasmaMtls/Materials/plPassAnimDlgProc.cpp @@ -289,7 +289,7 @@ void plPassAnimDlgProc::ILoadNames(IParamBlock2 *pb ) plAnimStealthNode *stealth = mtl->IGetStealth( i, false ); if( stealth != nil ) { - int idx = SendMessage( hAnims, CB_ADDSTRING, 0, (LPARAM)stealth->GetSegmentName() ); + int idx = SendMessage( hAnims, CB_ADDSTRING, 0, (LPARAM)stealth->GetSegmentName().c_str() ); SendMessage( hAnims, CB_SETITEMDATA, idx, (LPARAM)stealth ); } } diff --git a/Sources/Tools/MaxPlasmaMtls/Materials/plPassMtl.cpp b/Sources/Tools/MaxPlasmaMtls/Materials/plPassMtl.cpp index 306b5eb6..2124c830 100644 --- a/Sources/Tools/MaxPlasmaMtls/Materials/plPassMtl.cpp +++ b/Sources/Tools/MaxPlasmaMtls/Materials/plPassMtl.cpp @@ -96,7 +96,7 @@ plPassMtl::plPassMtl(BOOL loading) : plPassMtlBase( loading ) // If we do this later (like, when the dialog loads) something blows up, // somewhere in Max. It didn't in 4, it does in 7. This seems to fix it. if (!loading) - IVerifyStealthPresent(ENTIRE_ANIMATION_NAME); + IVerifyStealthPresent(_TEMP_CONVERT_FROM_LITERAL(ENTIRE_ANIMATION_NAME)); } plPassMtl::~plPassMtl() diff --git a/Sources/Tools/MaxPlasmaMtls/Materials/plPassMtlBase.cpp b/Sources/Tools/MaxPlasmaMtls/Materials/plPassMtlBase.cpp index 146181d3..4e505df3 100644 --- a/Sources/Tools/MaxPlasmaMtls/Materials/plPassMtlBase.cpp +++ b/Sources/Tools/MaxPlasmaMtls/Materials/plPassMtlBase.cpp @@ -181,7 +181,7 @@ plAnimStealthNode *plPassMtlBase::IGetStealth( int index, hsBool update ) return (plAnimStealthNode *)fAnimPB->GetReferenceTarget( (ParamID)kPBAnimStealthNodes, 0, index ); } -plAnimStealthNode *plPassMtlBase::IFindStealth( const char *segmentName ) +plAnimStealthNode *plPassMtlBase::IFindStealth( const plString &segmentName ) { int i; @@ -189,9 +189,9 @@ plAnimStealthNode *plPassMtlBase::IFindStealth( const char *segmentName ) for( i = 0; i < fAnimPB->Count( (ParamID)kPBAnimStealthNodes ); i++ ) { plAnimStealthNode *node = (plAnimStealthNode *)fAnimPB->GetReferenceTarget( (ParamID)kPBAnimStealthNodes, 0, i ); - const char *name = node->GetSegmentName(); + plString name = node->GetSegmentName(); - if( node != nil && strcmp( name, segmentName ) == 0 ) + if( node != nil && name.Compare( segmentName ) == 0 ) { return node; } @@ -203,7 +203,7 @@ plAnimStealthNode *plPassMtlBase::IFindStealth( const char *segmentName ) //// IVerifyStealthPresent /////////////////////////////////////////////////// // Ensures that we have a stealth for the given segment. -plAnimStealthNode *plPassMtlBase::IVerifyStealthPresent( const char *animName ) +plAnimStealthNode *plPassMtlBase::IVerifyStealthPresent( const plString &animName ) { // If we're in the middle of loading, don't check if (plPostLoadHandler::IsLoading()) @@ -215,7 +215,7 @@ plAnimStealthNode *plPassMtlBase::IVerifyStealthPresent( const char *animName // New segment, add a new stealth node stealth = (plAnimStealthNode *)GetCOREInterface()->CreateInstance( HELPER_CLASS_ID, ANIMSTEALTH_CLASSID ); INode *node = GetCOREInterface()->CreateObjectNode( stealth ); - stealth->SetSegment( ( strcmp(animName, ENTIRE_ANIMATION_NAME) != 0 ) ? animName : nil ); + stealth->SetSegment( ( animName.Compare(ENTIRE_ANIMATION_NAME) != 0 ) ? _TEMP_CONVERT_TO_CONST_CHAR(animName) : nil ); stealth->SetNodeName( GetName() ); node->Freeze( true ); @@ -231,7 +231,7 @@ plAnimStealthNode *plPassMtlBase::IVerifyStealthPresent( const char *animName fAnimPB->Append( (ParamID)kPBAnimStealthNodes, 1, (ReferenceTarget **)&stealth ); - const char *realName = stealth->GetSegmentName(); + plString realName = stealth->GetSegmentName(); fStealthsChanged = true; } @@ -277,7 +277,7 @@ void plPassMtlBase::IUpdateAnimNodes( void ) fStealthsChanged = false; // Verify one for "entire animation" - plAnimStealthNode *stealth = IVerifyStealthPresent( ENTIRE_ANIMATION_NAME ); + plAnimStealthNode *stealth = IVerifyStealthPresent( _TEMP_CONVERT_FROM_LITERAL(ENTIRE_ANIMATION_NAME) ); goodNodes.Append( stealth ); // Verify segment nodes @@ -517,9 +517,9 @@ void plPassMtlBase::PostLoadAnimPBFixup( void ) for( int i = 0; i < fAnimPB->Count( (ParamID)kPBAnimStealthNodes ); i++ ) { plAnimStealthNode *node = (plAnimStealthNode *)fAnimPB->GetReferenceTarget( (ParamID)kPBAnimStealthNodes, 0, i ); - const char *name = node->GetSegmentName(); + plString name = node->GetSegmentName(); node->SetAutoStart( false ); - node->SetLoop( true, ENTIRE_ANIMATION_NAME ); + node->SetLoop( true, _TEMP_CONVERT_FROM_LITERAL( ENTIRE_ANIMATION_NAME ) ); node->SetEaseIn( plAnimEaseTypes::kNoEase, 1.f, 1.f, 1.f ); node->SetEaseOut( plAnimEaseTypes::kNoEase, 1.f, 1.f, 1.f ); } @@ -528,14 +528,14 @@ void plPassMtlBase::PostLoadAnimPBFixup( void ) const char *oldSel = (const char *)fAnimPB->GetStr( (ParamID)kPBAnimName ); if( oldSel == nil ) oldSel = ENTIRE_ANIMATION_NAME; - plAnimStealthNode *myNew = IFindStealth( oldSel ); + plAnimStealthNode *myNew = IFindStealth( plString::FromUtf8( oldSel ) ); if( myNew != nil ) { #pragma warning( push ) // Forcing value to bool true or false (go figure, i'm even explicitly casting) #pragma warning( disable:4800 ) // Forcing value to bool true or false (go figure, i'm even explicitly casting) myNew->SetAutoStart( (bool)fAnimPB->GetInt( (ParamID)kPBAnimAutoStart ) ); myNew->SetLoop( (bool)fAnimPB->GetInt( (ParamID)kPBAnimLoop ), - (char *)fAnimPB->GetStr( (ParamID)kPBAnimLoopName ) ); + plString::FromUtf8( (char *)fAnimPB->GetStr( (ParamID)kPBAnimLoopName ) ) ); myNew->SetEaseIn( (uint8_t)fAnimPB->GetInt( (ParamID)kPBAnimEaseInType ), (float)fAnimPB->GetFloat( (ParamID)kPBAnimEaseInLength ), (float)fAnimPB->GetFloat( (ParamID)kPBAnimEaseInMin ), diff --git a/Sources/Tools/MaxPlasmaMtls/Materials/plPassMtlBase.h b/Sources/Tools/MaxPlasmaMtls/Materials/plPassMtlBase.h index d8230a54..1bf3ab65 100644 --- a/Sources/Tools/MaxPlasmaMtls/Materials/plPassMtlBase.h +++ b/Sources/Tools/MaxPlasmaMtls/Materials/plPassMtlBase.h @@ -55,6 +55,7 @@ class plPassAnimDlgProc; class plStealthNodeAccessor; class plMaxNode; class plErrorMsg; +class plString; class plPassMtlBase : public Mtl { @@ -81,8 +82,8 @@ protected: hsTArray fChangeCallbacks; void IUpdateAnimNodes( void ); - plAnimStealthNode *IFindStealth( const char *animName ); - plAnimStealthNode *IVerifyStealthPresent( const char *animName ); + plAnimStealthNode *IFindStealth( const plString &animName ); + plAnimStealthNode *IVerifyStealthPresent( const plString &animName ); int IGetNumStealths( hsBool update = true ); plAnimStealthNode *IGetStealth( int index, hsBool update = true );