From 2af0a7f56ea5e8b32473108a147bc58ce3403c45 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Sat, 5 Jan 2013 21:48:03 -0800 Subject: [PATCH] Get rid of clang warnings in plAvatar. --- .../PubUtilLib/plAvatar/plAGMasterMod.cpp | 37 ++++++++++--------- .../PubUtilLib/plAvatar/plArmatureMod.cpp | 4 +- .../PubUtilLib/plAvatar/plArmatureMod.h | 4 +- .../PubUtilLib/plAvatar/plAvBrainClimb.cpp | 19 ++++++---- .../PubUtilLib/plAvatar/plAvBrainGeneric.cpp | 13 +++---- .../PubUtilLib/plAvatar/plAvBrainHuman.cpp | 6 +++ .../PubUtilLib/plAvatar/plAvBrainSwim.cpp | 4 ++ .../plAvatar/plAvLadderModifier.cpp | 2 +- .../PubUtilLib/plAvatar/plAvTaskSeek.cpp | 4 +- .../Plasma/PubUtilLib/plAvatar/plAvTaskSeek.h | 6 +-- .../PubUtilLib/plAvatar/plAvatarClothing.cpp | 7 ++-- .../PubUtilLib/plAvatar/plAvatarClothing.h | 2 +- .../PubUtilLib/plAvatar/plAvatarTasks.cpp | 18 ++++----- .../PubUtilLib/plAvatar/plAvatarTasks.h | 4 +- .../PubUtilLib/plAvatar/plClothingLayout.h | 2 +- .../PubUtilLib/plAvatar/plCoopCoordinator.cpp | 3 +- .../plAvatar/plMultistageBehMod.cpp | 12 +++--- .../PubUtilLib/plAvatar/plSittingModifier.cpp | 16 +++++--- .../PubUtilLib/plAvatar/plSittingModifier.h | 2 +- .../PubUtilLib/plMessage/plAvatarMsg.cpp | 4 +- .../Plasma/PubUtilLib/plMessage/plAvatarMsg.h | 5 +-- 21 files changed, 95 insertions(+), 79 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp index 42ff1d66..7fb747d9 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp @@ -614,10 +614,6 @@ void plAGMasterMod::DumpCurrentAnims(const char *header) // receive trigger messages bool plAGMasterMod::MsgReceive(plMessage* msg) { - plAnimCmdMsg* cmdMsg; - plAGCmdMsg* agMsg; - int i; - plSDLNotificationMsg* nMsg = plSDLNotificationMsg::ConvertNoRef(msg); if (nMsg) { @@ -626,7 +622,8 @@ bool plAGMasterMod::MsgReceive(plMessage* msg) return true; } - if (cmdMsg = plAnimCmdMsg::ConvertNoRef(msg)) + plAnimCmdMsg* cmdMsg = plAnimCmdMsg::ConvertNoRef(msg); + if (cmdMsg) { plString targetName = cmdMsg->GetAnimName(); @@ -638,7 +635,7 @@ bool plAGMasterMod::MsgReceive(plMessage* msg) { if (cmdMsg->CmdChangesAnimTime()) { - for (i = 0; i < GetNumAnimations(); i++) + for (int i = 0; i < GetNumAnimations(); i++) { plAGAnimInstance *currInst = GetAnimInstance(i); if (currInst != inst && currInst->GetAnimation()->SharesPinsWith(inst->GetAnimation())) @@ -653,7 +650,8 @@ bool plAGMasterMod::MsgReceive(plMessage* msg) return true; } - if (agMsg = plAGCmdMsg::ConvertNoRef(msg)) + plAGCmdMsg* agMsg = plAGCmdMsg::ConvertNoRef(msg); + if (agMsg) { if (agMsg->Cmd(plAGCmdMsg::kSetAnimTime)) { @@ -678,7 +676,7 @@ bool plAGMasterMod::MsgReceive(plMessage* msg) } plAGInstanceCallbackMsg *agicMsg = plAGInstanceCallbackMsg::ConvertNoRef(msg); - if (agicMsg != nil) + if (agicMsg) { if (agicMsg->fEvent == kStart) { @@ -697,16 +695,16 @@ bool plAGMasterMod::MsgReceive(plMessage* msg) } plAGDetachCallbackMsg *detachMsg = plAGDetachCallbackMsg::ConvertNoRef(msg); - if (detachMsg != nil) + if (detachMsg) { DetachAnimation(detachMsg->GetAnimName()); } - plGenRefMsg *genRefMsg; - if (genRefMsg = plGenRefMsg::ConvertNoRef(msg)) + plGenRefMsg *genRefMsg = plGenRefMsg::ConvertNoRef(msg); + if (genRefMsg) { - plAGAnim *anim; - if (anim = plAGAnim::ConvertNoRef(genRefMsg->GetRef())) + plAGAnim *anim = plAGAnim::ConvertNoRef(genRefMsg->GetRef()); + if (anim) { if (genRefMsg->GetContext() & (plRefMsg::kOnCreate|plRefMsg::kOnRequest)) { @@ -733,8 +731,9 @@ bool plAGMasterMod::MsgReceive(plMessage* msg) return true; } - plAGModifier *agmod; - if (agmod = plAGModifier::ConvertNoRef(genRefMsg->GetRef())) + + plAGModifier *agmod = plAGModifier::ConvertNoRef(genRefMsg->GetRef()); + if (agmod) { if (genRefMsg->GetContext() & (plRefMsg::kOnCreate|plRefMsg::kOnRequest)) fChannelMods[agmod->GetChannelName()] = agmod; @@ -743,8 +742,9 @@ bool plAGMasterMod::MsgReceive(plMessage* msg) return true; } - plMsgForwarder *msgfwd; - if (msgfwd = plMsgForwarder::ConvertNoRef(genRefMsg->GetRef())) + + plMsgForwarder *msgfwd = plMsgForwarder::ConvertNoRef(genRefMsg->GetRef()); + if (msgfwd) { if (genRefMsg->GetContext() & (plRefMsg::kOnCreate|plRefMsg::kOnRequest)) fMsgForwarder = msgfwd; @@ -754,8 +754,9 @@ bool plAGMasterMod::MsgReceive(plMessage* msg) return true; } } + plRefMsg* refMsg = plRefMsg::ConvertNoRef(msg); - if( refMsg ) + if (refMsg) { if( refMsg->GetContext() & (plRefMsg::kOnCreate|plRefMsg::kOnRequest|plRefMsg::kOnReplace) ) AddTarget(plSceneObject::ConvertNoRef(refMsg->GetRef())); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp index 655e4a76..f22bc9ff 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp @@ -2380,7 +2380,7 @@ bool plArmatureMod::FindMatchingGenericBrain(const char *names[], int count) return false; } -plString plArmatureMod::MakeAnimationName(const char *baseName) const +plString plArmatureMod::MakeAnimationName(const plString& baseName) const { return fAnimationPrefix + baseName; } @@ -2395,7 +2395,7 @@ void plArmatureMod::SetRootName(const plString &name) fRootName = name; } -plAGAnim *plArmatureMod::FindCustomAnim(const char *baseName) const +plAGAnim *plArmatureMod::FindCustomAnim(const plString& baseName) const { plString customName = MakeAnimationName(baseName); plAGAnim *result = plAGAnim::FindAnim(customName); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h index 4f2a69c4..1a35be23 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h @@ -226,7 +226,7 @@ public: 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(); - plAGAnim *FindCustomAnim(const char *baseName) const; + plAGAnim *FindCustomAnim(const plString& baseName) const; virtual void Spawn(double timeNow); virtual void SpawnAt(int which, double timeNow); @@ -305,7 +305,7 @@ public: int GetBodyType(int type) { return fBodyType; } int GetCurrentGenericType(); bool FindMatchingGenericBrain(const char *names[], int count); - plString MakeAnimationName(const char * baseName) const; + plString MakeAnimationName(const plString& baseName) const; plString GetRootName(); void SetRootName(const plString &name); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp index 5bf9747c..026c1a02 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp @@ -244,18 +244,19 @@ bool plAvBrainClimb::Apply(double time, float elapsed) // MSGRECEIVE bool plAvBrainClimb::MsgReceive(plMessage *msg) { - plClimbMsg *climbMsg; - plLOSHitMsg *losMsg; - - if(climbMsg = plClimbMsg::ConvertNoRef(msg)) + plClimbMsg* climbMsg = plClimbMsg::ConvertNoRef(msg); + if (climbMsg) { return IHandleClimbMsg(climbMsg); - } else if(losMsg = plLOSHitMsg::ConvertNoRef(msg)) + } + + plLOSHitMsg *losMsg = plLOSHitMsg::ConvertNoRef(msg); + if (losMsg) { return IHandleLOSMsg(losMsg); - } else { - return plArmatureBrain::MsgReceive(msg); } + + return plArmatureBrain::MsgReceive(msg); } // IHANDLECLIMBMSG @@ -296,6 +297,8 @@ bool plAvBrainClimb::IHandleClimbMsg(plClimbMsg *msg) break; } + default: + break; } return true; } @@ -1047,6 +1050,6 @@ const char *plAvBrainClimb::ModeStr(Mode mode) case kFallingOff: return "FallingOff"; default: - return "WTF???!!!"; + return "WTF?!"; } } diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainGeneric.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainGeneric.cpp index a014e977..ec0eab50 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainGeneric.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainGeneric.cpp @@ -259,6 +259,8 @@ bool plAvBrainGeneric::Apply(double time, float elapsed) case kNormal: result = IProcessNormal(time, elapsed); break; + default: + break; } plArmatureBrain::Apply(time, elapsed); return result; @@ -653,15 +655,15 @@ bool plAvBrainGeneric::IHandleGenBrainMsg(const plAvBrainGenericMsg *msg) } } break; -#ifdef DEBUG_MULTISTAGE default: +#ifdef DEBUG_MULTISTAGE { char sbuf[256]; sprintf(sbuf,"GenericMsg - Unknown command %d ",msg->fType); plAvatarMgr::GetInstance()->GetLog()->AddLine(sbuf); } - break; #endif + break; } return true; } @@ -731,24 +733,21 @@ bool plAvBrainGeneric::IBrainIsCompatible(plAvBrainGeneric *otherBrain) { case plAGAnim::kBodyUnknown: return false; - break; case plAGAnim::kBodyFull: return false; - break; case plAGAnim::kBodyUpper: if(otherUsage == plAGAnim::kBodyLower) return true; else return false; - break; case plAGAnim::kBodyLower: if(otherUsage == plAGAnim::kBodyUpper) return true; else return false; - break; + default: + return false; } - return false; } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp index 98c6ffad..20fc9cc7 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp @@ -389,6 +389,8 @@ bool plAvBrainHuman::IHandleControlMsg(plControlEventMsg* msg) IChatOn(); return true; break; + default: + break; } } else { switch(moveCode) @@ -398,6 +400,8 @@ bool plAvBrainHuman::IHandleControlMsg(plControlEventMsg* msg) IChatOff(); return true; break; + default: + break; } } return false; @@ -515,6 +519,8 @@ bool plAvBrainHuman::IHandleClimbMsg(plClimbMsg *msg) case plClimbMsg::kRight: startMode = plAvBrainClimb::kMountingRight; break; + default: + break; } plAvBrainClimb *brain = new plAvBrainClimb(startMode); plAvTaskBrain *brainTask = new plAvTaskBrain(brain); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp index 2805de77..4adf219b 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp @@ -586,6 +586,8 @@ bool plAvBrainSwim::IHandleControlMsg(plControlEventMsg* msg) return true; } break; + default: + break; } } return false; @@ -611,6 +613,8 @@ void plAvBrainSwim::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *str case kAbort: sprintf(strBuf, "Mode: Abort (you should never see this)"); break; + default: + break; } debugTxt.DrawString(x, y, strBuf); y += lineHeight; diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvLadderModifier.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvLadderModifier.cpp index b1fc2478..ba8ec78a 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvLadderModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvLadderModifier.cpp @@ -255,7 +255,7 @@ void plAvLadderMod::EmitCommand(const plKey receiver) plSceneObject *seekObj = GetTarget(); plKey seekKey = seekObj->GetKey(); // this modifier's target is the seek object - char *mountName, *dismountName, *traverseName; + const char *mountName, *dismountName, *traverseName; if(fGoingUp) { diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp index f834ddb1..0704eef0 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp @@ -104,7 +104,7 @@ void plAvTaskSeek::IInitDefaults() fSeekObject = nil; fMovingTarget = false; fAlign = kAlignHandle; - fAnimName = nil; + fAnimName = ""; fPosGoalHit = false; fRotGoalHit = false; fStillPositioning = true; @@ -171,7 +171,7 @@ plAvTaskSeek::plAvTaskSeek(plKey target) // plAvTaskSeek ------------------------------------------------------------------------------------------- // ------------- -plAvTaskSeek::plAvTaskSeek(plKey target, plAvAlignment align, const char *animName, bool moving) +plAvTaskSeek::plAvTaskSeek(plKey target, plAvAlignment align, const plString& animName, bool moving) { IInitDefaults(); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.h b/Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.h index 5a0012da..7640ec01 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.h @@ -75,7 +75,7 @@ public: plAvTaskSeek(); plAvTaskSeek(plKey target); plAvTaskSeek(plAvSeekMsg *msg); - plAvTaskSeek(plKey target, plAvAlignment align, const char *animName, bool moving); + plAvTaskSeek(plKey target, plAvAlignment align, const plString& animName, bool moving); void SetTarget(plKey target); void SetTarget(hsPoint3 &pos, hsPoint3 &lookAt); @@ -153,7 +153,7 @@ protected: // for example, you can say "find a good start point so that you can play this animation // and have your handle wind up here" i.e: aligntype = "kAlignHandleAnimEnd" plAvAlignment fAlign; // how to line up with the seek point - const char * fAnimName; // an (optional) anim to use to line up our target + plString fAnimName; // an (optional) anim to use to line up our target // so you can say "seek to a place where your hand // will be here after you play animation foo" @@ -187,4 +187,4 @@ protected: plKey fNotifyFinishedKey; // Send a message to this key when we're done. }; -#endif \ No newline at end of file +#endif diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp index 8dc7df66..b1001043 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp @@ -632,10 +632,11 @@ void plClothingOutfit::IAddItem(plClothingItem *item) for (i = 0; i < num; i++) { - if (soundEffect = plArmatureEffectFootSound::ConvertNoRef(mgr->GetEffect(i))) + soundEffect = plArmatureEffectFootSound::ConvertNoRef(mgr->GetEffect(i)); + if (soundEffect) break; } - + if (soundEffect) { if (!strcmp(item->fName, "03_MLFoot04_01") || !strcmp(item->fName, "03_FLFoot04_01")) @@ -1533,7 +1534,7 @@ plClothingLayout *plClothingMgr::GetLayout(char *name) return nil; } -plClothingElement *plClothingMgr::FindElementByName(char *name) +plClothingElement *plClothingMgr::FindElementByName(const char *name) { int i; for (i = 0; i < fElements.GetCount(); i++) diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.h b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.h index 46ab2588..94c22927 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.h @@ -259,7 +259,7 @@ public: GETINTERFACE_ANY( plClothingMgr, hsKeyedObject ); plClothingLayout *GetLayout(char *name); - plClothingElement *FindElementByName(char *name); + plClothingElement *FindElementByName(const char *name); // Functions that just relate to the clothing you have permission to wear (closet) diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp index 14ed7926..9d809231 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp @@ -169,7 +169,7 @@ plAvSeekTask::plAvSeekTask() } // CTOR target, align, animName -plAvSeekTask::plAvSeekTask(plKey target, plAvAlignment align, const char *animName) +plAvSeekTask::plAvSeekTask(plKey target, plAvAlignment align, const plString& animName) : fAlign(align), fDuration(0.25), fTarget(target), @@ -178,19 +178,17 @@ plAvSeekTask::plAvSeekTask(plKey target, plAvAlignment align, const char *animNa fPhysicalAtStart(false), fCleanup(false) { - fAnimName = hsStrcpy(animName); } // CTOR target plAvSeekTask::plAvSeekTask(plKey target) -: fAnimName(nil), -fAlign(kAlignHandle), -fDuration(0.25), -fTarget(target), -fAnimInstance(nil), -fTargetTime(0), -fPhysicalAtStart(false), -fCleanup(false) +: fAlign(kAlignHandle), + fDuration(0.25), + fTarget(target), + fAnimInstance(nil), + fTargetTime(0), + fPhysicalAtStart(false), + fCleanup(false) { } diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.h b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.h index 1cc0846e..db0c96d5 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.h @@ -132,7 +132,7 @@ public: plAvSeekTask(plKey target); /** Constructor form for calculated seek points: uses aligment type and (optionally) animation The animation is used if we're trying to align some future pose with a seek target. */ - plAvSeekTask(plKey target, plAvAlignment alignType, const char *animName); + plAvSeekTask(plKey target, plAvAlignment alignType, const plString& animName); // task protocol virtual bool Start(plArmatureMod *avatar, plArmatureBrain *brain, double time, float elapsed); @@ -146,7 +146,7 @@ public: // *** implement reader and writer if needed for network propagation protected: // -- specification members -- - char * fAnimName; // the animation we're using, if any; + plString fAnimName; // the animation we're using, if any; plAvAlignment fAlign; // how to line up with the seek point double fDuration; // the time we want the task to take plKey fTarget; // the thing we're seeking towards diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plClothingLayout.h b/Sources/Plasma/PubUtilLib/plAvatar/plClothingLayout.h index b1a9bf24..bc477bb2 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plClothingLayout.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plClothingLayout.h @@ -127,7 +127,7 @@ public: class plClothingLayout { public: - plClothingLayout(char *name, uint32_t origWidth) { fName = hsStrcpy(name); fOrigWidth = origWidth; } + plClothingLayout(const char *name, uint32_t origWidth) { fName = hsStrcpy(name); fOrigWidth = origWidth; } ~plClothingLayout() { delete [] fName; } char *fName; diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp index 46a31e4e..73c46b7c 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp @@ -227,7 +227,8 @@ bool plCoopCoordinator::MsgReceive(plMessage *msg) fGuestLinked = true; IAdvanceParticipant(true); // advance the host break; - + default: + break; } } diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plMultistageBehMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plMultistageBehMod.cpp index c54cdc30..22178ffa 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plMultistageBehMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plMultistageBehMod.cpp @@ -120,7 +120,6 @@ void plMultistageBehMod::IDeleteStageVec() bool plMultistageBehMod::MsgReceive(plMessage* msg) { - plMultistageModMsg *multiMsg = nil; plNotifyMsg* notifyMsg = plNotifyMsg::ConvertNoRef(msg); if (notifyMsg) { @@ -187,8 +186,10 @@ bool plMultistageBehMod::MsgReceive(plMessage* msg) } return true; - } - else if (multiMsg = plMultistageModMsg::ConvertNoRef(msg)) + } + + plMultistageModMsg *multiMsg = plMultistageModMsg::ConvertNoRef(msg); + if (multiMsg) { if (multiMsg->GetCommand(plMultistageModMsg::kSetLoopCount)) { @@ -196,9 +197,8 @@ bool plMultistageBehMod::MsgReceive(plMessage* msg) } return true; } - else { - return plSingleModifier::MsgReceive(msg); - } + + return plSingleModifier::MsgReceive(msg); } void plMultistageBehMod::Read(hsStream *stream, hsResMgr *mgr) diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.cpp index 8fd488f9..870cf867 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.cpp @@ -220,8 +220,8 @@ void plSittingModifier::Trigger(const plArmatureMod *avMod, plNotifyMsg *enterNo // send the SEEK message - char *animName = nil; // this will be the name of our sit animation, which we - // need to know so we can seek properly. + const char *animName = nil; // this will be the name of our sit animation, which we + // need to know so we can seek properly. plAvBrainGeneric *brain = IBuildSitBrain(avModKey, seekKey, &animName, enterNotify, exitNotify); if(brain) @@ -298,7 +298,7 @@ bool IIsClosestAnim(const char *animName, hsMatrix44 &sitGoal, float &closestDis // IBuildSitBrain --------------------------------------------------------------------- // ---------------- plAvBrainGeneric *plSittingModifier::IBuildSitBrain(plKey avModKey, plKey seekKey, - char **pAnimName, plNotifyMsg *enterNotify, plNotifyMsg *exitNotify) + const char **pAnimName, plNotifyMsg *enterNotify, plNotifyMsg *exitNotify) { plArmatureMod *avatar = plArmatureMod::ConvertNoRef(avModKey->ObjectIsLoaded()); plSceneObject *seekObj = plSceneObject::ConvertNoRef(seekKey->ObjectIsLoaded()); @@ -308,8 +308,8 @@ plAvBrainGeneric *plSittingModifier::IBuildSitBrain(plKey avModKey, plKey seekKe float closestDist = 0.0f; uint8_t closestApproach = 0; hsPoint3 curPosition = avatar->GetTarget(0)->GetLocalToWorld().GetTranslate(); - char * sitAnimName = nil; - char * standAnimName = "StandUpFront"; // always prefer to stand facing front + const char* sitAnimName = nil; + const char* standAnimName = "StandUpFront"; // always prefer to stand facing front bool frontClear = fMiscFlags & kApproachFront; plAvBrainGeneric *brain = nil; @@ -353,7 +353,11 @@ plAvBrainGeneric *plSittingModifier::IBuildSitBrain(plKey avModKey, plKey seekKe brain->AddStage(sitStage); brain->AddStage(idleStage); brain->AddStage(standStage); - *pAnimName = sitAnimName; +#if HS_BUILD_FOR_WIN32 + *pAnimName = _strdup(sitAnimName); +#else + *pAnimName = strdup(sitAnimName); +#endif brain->SetType(plAvBrainGeneric::kSit); brain->SetRecipient(GetKey()); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.h b/Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.h index df67b42b..4d45cae3 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.h @@ -110,7 +110,7 @@ protected: /** Figure out which approach we should use to the sit target, and add the relevant stages to the brain. */ - plAvBrainGeneric * IBuildSitBrain(plKey avModKey, plKey seekKey,char **pAnimName, plNotifyMsg *enterNotify, plNotifyMsg *exitNotify); + plAvBrainGeneric * IBuildSitBrain(plKey avModKey, plKey seekKey, const char **pAnimName, plNotifyMsg *enterNotify, plNotifyMsg *exitNotify); /** Unused. */ virtual bool IEval(double secs, float del, uint32_t dirty) { return true; } diff --git a/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.cpp b/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.cpp index dcf558ac..1b8879f1 100644 --- a/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.cpp +++ b/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.cpp @@ -249,7 +249,7 @@ plAvSeekMsg::plAvSeekMsg() // CTOR(sender, receiver, seekKey, time) plAvSeekMsg::plAvSeekMsg(const plKey& sender, const plKey& receiver, const plKey &seekKey, float duration, bool smartSeek, - plAvAlignment alignType, char *animName, bool noSeek, + plAvAlignment alignType, const plString& animName, bool noSeek, uint8_t flags, plKey finishKey) : plAvTaskMsg(sender, receiver), fSeekPoint(seekKey), @@ -359,7 +359,7 @@ plAvOneShotMsg::plAvOneShotMsg() plAvOneShotMsg::plAvOneShotMsg(const plKey &sender, const plKey& receiver, const plKey& seekKey, float duration, bool smartSeek, const plString &animName, bool drivable, bool reversible) -: plAvSeekMsg(sender, receiver, seekKey, duration, smartSeek), fAnimName(animName), +: plAvSeekMsg(sender, receiver, seekKey, duration, smartSeek, kAlignHandle, animName), fDrivable(drivable), fReversible(reversible), fCallbacks(nil) { } diff --git a/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.h b/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.h index fe5017db..ffa9f8dd 100644 --- a/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.h +++ b/Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.h @@ -189,7 +189,7 @@ public: // tors plAvSeekMsg(); plAvSeekMsg(const plKey& sender, const plKey& receiver, const plKey &seekKey, float duration, bool smartSeek, - plAvAlignment align = kAlignHandle, char *animName = nil, bool noSeek = false, + plAvAlignment align = kAlignHandle, const plString& animName = "", bool noSeek = false, uint8_t flags = kSeekFlagForce3rdPersonOnStart, plKey finishKey = nil); // plasma protocol @@ -212,7 +212,7 @@ public: float fDuration; // take this much time to do the move (only if smartSeek is false) bool fSmartSeek; // seek by walking rather than floating bool fNoSeek; - char *fAnimName; + plString fAnimName; plAvAlignment fAlignType; uint8_t fFlags; plKey fFinishKey; @@ -257,7 +257,6 @@ public: virtual void Write(hsStream *stream, hsResMgr *mgr); // public members - plString fAnimName; // the name of the animation we're going to use bool fDrivable; // are we animated by time or by mouse movement? bool fReversible; // can we play backwards? plOneShotCallbacks *fCallbacks; // Callbacks given to us by a one-shot modifier