From 3e92022db2afa8053d952349822e6582c66a8b8a Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Fri, 16 Nov 2012 17:32:33 -0800 Subject: [PATCH] Fix additional issues from review --- Sources/Plasma/CoreLib/hsStream.cpp | 16 +++++++--------- .../Plasma/NucleusLib/pnKeyedObject/plKeyImp.cpp | 7 ++++--- .../NucleusLib/pnKeyedObject/plMsgForwarder.cpp | 4 ++-- .../NucleusLib/pnModifier/plLogicModBase.cpp | 2 +- .../PubUtilLib/plAvatar/plAGAnimInstance.cpp | 6 +++--- .../PubUtilLib/plAvatar/plAGAnimInstance.h | 4 ++-- .../Plasma/PubUtilLib/plAvatar/plAGChannel.cpp | 2 +- .../PubUtilLib/plAvatar/plMultistageBehMod.cpp | 2 +- .../plDrawable/plDrawableSpansExport.cpp | 10 +++++----- .../plDrawable/plInstanceDrawInterface.cpp | 2 +- .../Plasma/PubUtilLib/plDrawable/plProxyGen.cpp | 8 ++++---- .../PubUtilLib/plInputCore/plInputDevice.cpp | 6 +++--- .../PubUtilLib/plInputCore/plInputDevice.h | 3 +-- .../PubUtilLib/plNetClient/plNetClientMgr.cpp | 4 ++-- .../plNetClient/plNetClientMgrSend.cpp | 6 +++--- .../Plasma/PubUtilLib/plSurface/hsGMaterial.cpp | 4 ++-- .../PubUtilLib/plUnifiedTime/plUnifiedTime.cpp | 1 + Sources/Tools/MaxConvert/hsConverterUtils.cpp | 2 +- Sources/Tools/MaxConvert/hsMaterialConverter.cpp | 2 +- 19 files changed, 45 insertions(+), 46 deletions(-) diff --git a/Sources/Plasma/CoreLib/hsStream.cpp b/Sources/Plasma/CoreLib/hsStream.cpp index 5cff5899..3f172469 100644 --- a/Sources/Plasma/CoreLib/hsStream.cpp +++ b/Sources/Plasma/CoreLib/hsStream.cpp @@ -146,12 +146,12 @@ uint32_t hsStream::WriteSafeStringLong(const plString &string) if (len > 0) { const char *buffp = string.c_str(); - int i; + uint32_t i; for (i = 0; i < len; i++) { WriteByte(~buffp[i]); } - return static_cast(i); + return i; } else return 0; @@ -164,9 +164,8 @@ uint32_t hsStream::WriteSafeWStringLong(const plString &string) WriteLE32(len); if (len > 0) { - int i; const wchar_t *buffp = wbuff.GetData(); - for (i=0; i 0) { - int i; + uint32_t i; const char *buffp = string.c_str(); for (i = 0; i < len; i++) { WriteByte(~buffp[i]); } - return static_cast(i); + return i; } else return 0; @@ -244,16 +243,15 @@ uint32_t hsStream::WriteSafeString(const plString &string) uint32_t hsStream::WriteSafeWString(const plString &string) { plStringBuffer wbuff = string.ToWchar(); - int len = wbuff.GetSize(); + uint32_t len = wbuff.GetSize(); hsAssert(len<0xf000, xtl::format("string len of %d is too long for WriteSafeWString, use WriteSafeWStringLong", len).c_str() ); WriteLE16(len | 0xf000); if (len > 0) { - int i; const wchar_t *buffp = wbuff.GetData(); - for (i=0; iGetName(), kObjName) == 0) && + return (key->GetName() == kObjName) && key->GetUoid().GetClassType() == kClassType && key->GetUoid().GetCloneID() == kCloneID; } @@ -348,7 +348,7 @@ void plKeyImp::AddNotifyCreated(plRefMsg* msg, plRefFlags::Type flags) #ifdef LOG_ACTIVE_REFS if (IsTrackedKey(this)) { - hsStatusMessageF("@@@ %s(%s) adding active ref to %s (%d total)", msg->GetReceiver(0)->GetName(), + hsStatusMessageF("@@@ %s(%s) adding active ref to %s (%d total)", msg->GetReceiver(0)->GetName().c_str(), plFactory::GetNameOfClass(msg->GetReceiver(0)->GetUoid().GetClassType()), kObjName, fNumActiveRefs+1); } #endif // LOG_ACTIVE_REFS @@ -635,7 +635,8 @@ void plKeyImp::IRelease(plKeyImp* iTargetKey) // it has been notified it is going away. #ifdef LOG_ACTIVE_REFS if (isActive && IsTrackedKey(iTargetKey)) - hsStatusMessageF("@@@ %s(%s) releasing active ref on %s (%d total)", GetName(), plFactory::GetNameOfClass(GetUoid().GetClassType()), kObjName, iTargetKey->fNumActiveRefs-1); + hsStatusMessageF("@@@ %s(%s) releasing active ref on %s (%d total)", GetName().c_str(), + plFactory::GetNameOfClass(GetUoid().GetClassType()), kObjName, iTargetKey->fNumActiveRefs-1); #endif // LOG_ACTIVE_REFS if (isActive && iTargetKey->GetActiveRefs() && !iTargetKey->DecActiveRefs()) diff --git a/Sources/Plasma/NucleusLib/pnKeyedObject/plMsgForwarder.cpp b/Sources/Plasma/NucleusLib/pnKeyedObject/plMsgForwarder.cpp index 76aa5a7b..48ebb56e 100644 --- a/Sources/Plasma/NucleusLib/pnKeyedObject/plMsgForwarder.cpp +++ b/Sources/Plasma/NucleusLib/pnKeyedObject/plMsgForwarder.cpp @@ -142,13 +142,13 @@ bool plMsgForwarder::IForwardCallbackMsg(plMessage *msg) #if 0 hsStatusMessageF("Adding CBMsg, eventSender=%s, eventRemoteMsg=%d\n", - event->GetSender() ? event->GetSender()->GetName() : "nil", fc->fNetPropogate); + event->GetSender() ? event->GetSender()->GetName().c_str() : "nil", fc->fNetPropogate); #endif } } #if 0 hsStatusMessageF("Fwding CBMsg, sender=%s, remoteMsg=%d", - msg->GetSender() ? msg->GetSender()->GetName() : "nil", msg->HasBCastFlag(plMessage::kNetNonLocal)); + msg->GetSender() ? msg->GetSender()->GetName().c_str() : "nil", msg->HasBCastFlag(plMessage::kNetNonLocal)); #endif IForwardMsg(callbackMsg); diff --git a/Sources/Plasma/NucleusLib/pnModifier/plLogicModBase.cpp b/Sources/Plasma/NucleusLib/pnModifier/plLogicModBase.cpp index f7285ae6..dfee7765 100644 --- a/Sources/Plasma/NucleusLib/pnModifier/plLogicModBase.cpp +++ b/Sources/Plasma/NucleusLib/pnModifier/plLogicModBase.cpp @@ -275,7 +275,7 @@ void plLogicModBase::UnTrigger() #ifdef HS_DEBUGGING char str[256]; sprintf(str, "LogicModifier %s is Un-triggering, activatorType=%d\n", - GetKeyName(), HasFlag(kTypeActivator)); + GetKeyName().c_str(), HasFlag(kTypeActivator)); plNetClientApp::GetInstance()->DebugMsg(str); #endif fNotify->SetSender(this->GetKey()); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.cpp index 950c32f3..d8fd1333 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.cpp @@ -78,8 +78,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com // ///////////////////////////////////////////////////////////////////////////////////////// #ifdef TRACK_AG_ALLOCS -extern const char *gGlobalAnimName = nil; -extern const char *gGlobalChannelName = nil; +plString gGlobalAnimName; +plString gGlobalChannelName; #endif // TRACK_AG_ALLOCS ///////////////////////////////////////////////////////////////////////////////////////// @@ -172,7 +172,7 @@ plAGAnimInstance::plAGAnimInstance(plAGAnim * anim, plAGMasterMod * master, fFadeBlend = fFadeAmp = false; #ifdef TRACK_AG_ALLOCS - gGlobalAnimName = nil; + gGlobalAnimName = ""; #endif // TRACK_AG_ALLOCS } diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.h b/Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.h index 51c2b219..edd259f7 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.h @@ -261,8 +261,8 @@ protected: //#endif #ifdef TRACK_AG_ALLOCS -extern const char *gGlobalAnimName; -extern const char *gGlobalChannelName; +extern plString gGlobalAnimName; +extern plString gGlobalChannelName; void RegisterAGAlloc(plAGChannel *object, const char *chanName, const char *animName, uint16_t classIndex); void UnRegisterAGAlloc(plAGChannel *object); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGChannel.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAGChannel.cpp index 9aa7dbda..f31602ed 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGChannel.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGChannel.cpp @@ -61,7 +61,7 @@ plAGChannel::plAGChannel() { #ifdef TRACK_AG_ALLOCS fName = gGlobalAnimName; - RegisterAGAlloc(this, gGlobalChannelName, gGlobalAnimName, this->ClassIndex()); + RegisterAGAlloc(this, gGlobalChannelName.c_str(), gGlobalAnimName.c_str(), this->ClassIndex()); #endif // TRACK_AG_ALLOCS } diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plMultistageBehMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plMultistageBehMod.cpp index 149b3bb9..c54cdc30 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plMultistageBehMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plMultistageBehMod.cpp @@ -161,7 +161,7 @@ bool plMultistageBehMod::MsgReceive(plMessage* msg) #ifdef DEBUG_MULTISTAGE char sbuf[256]; - sprintf(sbuf,"plMultistageModMsg - starting multistage from %s",sender->GetName()); + sprintf(sbuf,"plMultistageModMsg - starting multistage from %s",sender->GetName().c_str()); plAvatarMgr::GetInstance()->GetLog()->AddLine(sbuf); #endif plAvSeekMsg *seeker = new plAvSeekMsg(nil, avModKey, seekKey, 1.0f, fSmartSeek); diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpansExport.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpansExport.cpp index 0d25525b..27078fb9 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpansExport.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpansExport.cpp @@ -197,7 +197,7 @@ void plDrawableSpans::Write( hsStream* s, hsResMgr* mgr ) hsUNIXStream log; log.Open("log\\GBuf.log", "ab"); char buf[256]; - sprintf(buf, "Drawable Span: %s, GroupNum: %u\r\n", GetKeyName(), i); + sprintf(buf, "Drawable Span: %s, GroupNum: %u\r\n", GetKeyName().c_str(), i); log.WriteString(buf); log.Close(); #endif @@ -387,7 +387,7 @@ static void ILogSpan(plStatusLog* statusLog, plGeometrySpan* geo, plVertexSpan* statusLog->AddLineF("From obj <%s> mat <%s> size %d bytes grp=%d (%d offset)", geo->fMaxOwner.c_str(""), - geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "", + geo->fMaterial ? geo->fMaterial->GetKeyName().c_str() : "", geo->GetVertexSize(geo->fFormat) * geo->fNumVerts + sizeof(uint16_t) * geo->fNumIndices, span->fGroupIdx, ptr @@ -405,7 +405,7 @@ static void ILogSpan(plStatusLog* statusLog, plGeometrySpan* geo, plVertexSpan* { statusLog->AddLineF("Instanced obj <%s> mat <%s> grp=%d (%d/%d/%d/%d/%d/%d/%d/%d)", geo->fMaxOwner.c_str(""), - geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "", + geo->fMaterial ? geo->fMaterial->GetKeyName().c_str() : "", span->fGroupIdx, span->fVBufferIdx, span->fCellIdx, @@ -424,7 +424,7 @@ static void ILogSpan(plStatusLog* statusLog, plGeometrySpan* geo, plVertexSpan* { statusLog->AddLineF("From obj <%s> mat <%s> size %d bytes grp=%d (%d/%d/%d/%d/%d)", geo->fMaxOwner.c_str(""), - geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "", + geo->fMaterial ? geo->fMaterial->GetKeyName().c_str() : "", geo->GetVertexSize(geo->fFormat) * geo->fNumVerts + sizeof(uint16_t) * geo->fNumIndices, span->fGroupIdx, span->fVBufferIdx, @@ -438,7 +438,7 @@ static void ILogSpan(plStatusLog* statusLog, plGeometrySpan* geo, plVertexSpan* { statusLog->AddLineF("Instanced obj <%s> mat <%s> grp=%d (%d/%d/%d/%d/%d)", geo->fMaxOwner.c_str(""), - geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "", + geo->fMaterial ? geo->fMaterial->GetKeyName().c_str() : "", span->fGroupIdx, span->fVBufferIdx, span->fCellIdx, diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plInstanceDrawInterface.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plInstanceDrawInterface.cpp index f90e0607..c8e3e00a 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plInstanceDrawInterface.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plInstanceDrawInterface.cpp @@ -114,7 +114,7 @@ void plInstanceDrawInterface::AddSharedMesh(plSharedMesh *mesh, hsGMaterial *mat #ifdef MF_NOSHADOW_ACC // TESTHACKERY FOLLOWS - GlassesNoShadow uint32_t noShadHack = 0; - if( mesh->GetKey() && (strstr(mesh->GetKey()->GetName(), "lasses") || strstr(mesh->GetKey()->GetName(), "oggles")) ) + if( mesh->GetKey() && (mesh->GetKey()->GetName().Find("lasses") >= 0 || mesh->GetKey()->GetName().Find("oggles") >= 0) ) noShadHack = plGeometrySpan::kPropNoShadowCast; #endif // MF_NOSHADOW_ACC diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plProxyGen.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plProxyGen.cpp index b8e67cf3..53624dcf 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plProxyGen.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plProxyGen.cpp @@ -158,8 +158,8 @@ hsGMaterial* plProxyGen::IMakeProxyMaterial() const hsGMaterial* retVal = new hsGMaterial(); plString buff; - if( !GetKey()->GetName().IsNull() ) - buff = plString::Format("%s_Material", GetKey()->GetName().c_str()); + if( !GetKeyName().IsNull() ) + buff = plString::Format("%s_Material", GetKeyName().c_str()); else buff = "ProxyMaterial"; hsgResMgr::ResMgr()->NewKey( buff, retVal, GetKey() ? GetKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc ); @@ -233,8 +233,8 @@ void plProxyGen::IGenerateProxy() if( fProxyDrawables[idx] && !fProxyDrawables[idx]->GetKey() ) { plString buff; - if( !GetKey()->GetName().IsNull() ) - buff = plString::Format("%s_ProxyDrawable", GetKey()->GetName().c_str()); + if( !GetKeyName().IsNull() ) + buff = plString::Format("%s_ProxyDrawable", GetKeyName().c_str()); else buff = "ProxyDrawable"; diff --git a/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp b/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp index fe0f4d5a..b4625f63 100644 --- a/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp +++ b/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp @@ -292,12 +292,12 @@ void plMouseDevice::IUpdateCursorSize() } } -void plMouseDevice::AddNameToCursor(const char* name) +void plMouseDevice::AddNameToCursor(const plString& name) { - if (fInstance && name) + if (fInstance && !name.IsNull()) { plDebugText &txt = plDebugText::Instance(); - txt.DrawString(fInstance->fWXPos + 12 ,fInstance->fWYPos - 7,name); + txt.DrawString(fInstance->fWXPos + 12 ,fInstance->fWYPos - 7,name.c_str()); } } void plMouseDevice::AddCCRToCursor() diff --git a/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h b/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h index 42c7c120..cd373fa0 100644 --- a/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h +++ b/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h @@ -188,8 +188,7 @@ public: static void SetCursorOpacity( float opacity = 1.f ); static bool GetInverted() { return plMouseDevice::bInverted; } static void SetInverted(bool inverted) { plMouseDevice::bInverted = inverted; } - static void AddNameToCursor(const char* name); - static void AddNameToCursor(const plString& name) { AddNameToCursor(name); } + static void AddNameToCursor(const plString& name); static void AddIDNumToCursor(uint32_t idNum); static void AddCCRToCursor(); diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp index 1b2b999a..6c1a6757 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp @@ -1457,8 +1457,8 @@ bool plNetClientMgr::IFindModifier(plSynchedObject* obj, int16_t classIdx) cnt++; } - hsAssert(cnt<2, xtl::format("Object %s has multiple SDL modifiers of the same kind (%s)?", - obj->GetKeyName(), plFactory::GetNameOfClass(classIdx)).c_str()); + hsAssert(cnt<2, plString::Format("Object %s has multiple SDL modifiers of the same kind (%s)?", + obj->GetKeyName().c_str(), plFactory::GetNameOfClass(classIdx)).c_str()); return cnt==0 ? false : true; } diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrSend.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrSend.cpp index 40149d69..2fd908cb 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrSend.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrSend.cpp @@ -396,9 +396,9 @@ int plNetClientMgr::ISendGameMessage(plMessage* msg) { #if 0 hsLogEntry(plNetObjectDebugger::GetInstance()->LogMsg( - xtl::format(" object:%s, rcvr %s %s", - msg->GetSender(), - msg->GetNumReceivers() ? msg->GetReceiver(0)->GetName() : "?", + plString::Format(" object:%s, rcvr %s %s", + msg->GetSender().GetKeyName().c_str(), + msg->GetNumReceivers() ? msg->GetReceiver(0)->GetName().c_str() : "?", netMsgWrap->AsStdString().c_str()).c_str())); #endif } diff --git a/Sources/Plasma/PubUtilLib/plSurface/hsGMaterial.cpp b/Sources/Plasma/PubUtilLib/plSurface/hsGMaterial.cpp index 0134d0ca..b5ef858b 100644 --- a/Sources/Plasma/PubUtilLib/plSurface/hsGMaterial.cpp +++ b/Sources/Plasma/PubUtilLib/plSurface/hsGMaterial.cpp @@ -133,8 +133,8 @@ plLayer* hsGMaterial::MakeBaseLayer() hsAssert(GetKey(), "All materials need a key (or temp key)"); plString buff; - if( !GetKey()->GetName().IsNull() ) - buff = plString::Format("%s_Layer", GetKey()->GetName().c_str()); + if( !GetKeyName().IsNull() ) + buff = plString::Format("%s_Layer", GetKeyName().c_str()); else buff = "Layer"; hsgResMgr::ResMgr()->NewKey( buff, newLay, GetKey() != nil ? GetKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc ); diff --git a/Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.cpp b/Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.cpp index 78e913a0..0a23993f 100644 --- a/Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.cpp +++ b/Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.cpp @@ -40,6 +40,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com *==LICENSE==*/ #include +#include #include "plUnifiedTime.h" #include "hsStlUtils.h" diff --git a/Sources/Tools/MaxConvert/hsConverterUtils.cpp b/Sources/Tools/MaxConvert/hsConverterUtils.cpp index 6b31e269..2c5e8049 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().c_str()); + INode* retVal = FindINodeFromMangledName(obj->GetKeyName().c_str()); if( retVal ) return (retVal); diff --git a/Sources/Tools/MaxConvert/hsMaterialConverter.cpp b/Sources/Tools/MaxConvert/hsMaterialConverter.cpp index 69b54c29..8be1339d 100644 --- a/Sources/Tools/MaxConvert/hsMaterialConverter.cpp +++ b/Sources/Tools/MaxConvert/hsMaterialConverter.cpp @@ -4951,7 +4951,7 @@ void hsMaterialConverter::IPrintDoneMat(hsStream* stream, const char* prefix, Do stream->WriteString(buff); sprintf(buff, "\t\t\tTexture %s\n", layer->GetTexture() && layer->GetTexture()->GetKey() - ? layer->GetTexture()->GetKey()->GetName().c_str("None") + ? layer->GetTexture()->GetKeyName().c_str("None") : "None"); stream->WriteString(buff);