diff --git a/Sources/Plasma/Apps/plClient/plClient.cpp b/Sources/Plasma/Apps/plClient/plClient.cpp index c39c3b68..283feaed 100644 --- a/Sources/Plasma/Apps/plClient/plClient.cpp +++ b/Sources/Plasma/Apps/plClient/plClient.cpp @@ -632,7 +632,7 @@ hsBool plClient::MsgReceive(plMessage* msg) { case plClientRefMsg::kLoadRoom : #ifndef PLASMA_EXTERNAL_RELEASE - plStatusLog::AddLineS( "pageouts.log", ".. ClientRefMsg received for room %s", pRefMsg->GetRef() != nil ? pRefMsg->GetRef()->GetKey()->GetUoid().GetObjectName() : "nilref" ); + plStatusLog::AddLineS( "pageouts.log", ".. ClientRefMsg received for room %s", pRefMsg->GetRef() != nil ? pRefMsg->GetRef()->GetKey()->GetUoid().GetObjectName().c_str() : "nilref" ); #endif // was it that the room was loaded? @@ -782,11 +782,10 @@ hsBool plClient::MsgReceive(plMessage* msg) plEventCallbackMsg* callback = plEventCallbackMsg::ConvertNoRef(msg); if( callback ) { - char str[256]; - sprintf(str, "Callback event from %s\n", callback->GetSender() - ? callback->GetSender()->GetName() - : "Unknown"); - hsStatusMessage(str); + plString str = plString::Format("Callback event from %s\n", callback->GetSender() + ? callback->GetSender()->GetName().c_str() + : "Unknown"); + hsStatusMessage(str.c_str()); static int gotten = 0; if( ++gotten > 5 ) { @@ -1282,7 +1281,7 @@ void plClient::IRoomUnloaded(plSceneNode* node) void plClient::IReadKeyedObjCallback(plKey key) { - fInstance->IIncProgress(1, key->GetName()); + fInstance->IIncProgress(1, _TEMP_CONVERT_TO_CONST_CHAR(key->GetName())); } //============================================================================ diff --git a/Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp b/Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp index 77ea680f..219a2d88 100644 --- a/Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp +++ b/Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp @@ -230,7 +230,7 @@ public: { plKeyImp* imp = (plKey)key; - fStream.WriteString(imp->GetName()); + fStream.WriteString_TEMP(imp->GetName()); fStream.WriteString(","); fStream.WriteString(plFactory::GetNameOfClass(imp->GetUoid().GetClassType())); diff --git a/Sources/Plasma/CoreLib/hsStream.cpp b/Sources/Plasma/CoreLib/hsStream.cpp index 8593ca4b..5bac2757 100644 --- a/Sources/Plasma/CoreLib/hsStream.cpp +++ b/Sources/Plasma/CoreLib/hsStream.cpp @@ -322,6 +322,33 @@ wchar_t *hsStream::ReadSafeWString() return retVal; } +UInt32 hsStream::WriteSafeString_TEMP(const plString &string) +{ + return WriteSafeString(string.c_str()); +} + +UInt32 hsStream::WriteSafeWString_TEMP(const plString &string) +{ + plStringBuffer wbuffer = string.ToWchar(); + return WriteSafeWString(wbuffer.GetData()); +} + +plString hsStream::ReadSafeString_TEMP() +{ + char *buffer = ReadSafeString(); + plString result = plString::FromIso8859_1(buffer); + delete [] buffer; + return result; +} + +plString hsStream::ReadSafeWString_TEMP() +{ + wchar_t *wbuffer = ReadSafeWString(); + plString result = plString::FromWchar(wbuffer); + delete [] wbuffer; + return result; +} + hsBool hsStream::Read4Bytes(void *pv) // Virtual, faster version in sub classes { int knt = this->Read(sizeof(UInt32), pv); diff --git a/Sources/Plasma/CoreLib/hsStream.h b/Sources/Plasma/CoreLib/hsStream.h index 32b390d6..1ed46bd7 100644 --- a/Sources/Plasma/CoreLib/hsStream.h +++ b/Sources/Plasma/CoreLib/hsStream.h @@ -59,7 +59,8 @@ struct FileEntry; #ifndef STREAM_LOGGER #define hsReadOnlyLoggingStream hsReadOnlyStream #define LogRead(byteCount, buffer, desc) Read(byteCount, buffer) -#define LogReadSafeString() ReadSafeString(); +#define LogReadSafeString() ReadSafeString() +#define LogReadSafeString_TEMP() ReadSafeString_TEMP() #define LogReadSafeStringLong() ReadSafeStringLong(); #define LogSkip(deltaByteCount, desc) Skip(deltaByteCount) #define LogReadLE(value, desc) ReadLE(value) @@ -130,6 +131,7 @@ public: virtual hsBool IsCompressed() { return false; } UInt32 WriteString(const char cstring[]); + UInt32 WriteString_TEMP(const plString & string) { return WriteString(string.c_str()); } UInt32 WriteFmt(const char * fmt, ...); UInt32 WriteFmtV(const char * fmt, va_list av); @@ -143,6 +145,11 @@ public: char * ReadSafeString(); wchar_t * ReadSafeWString(); + UInt32 WriteSafeString_TEMP(const plString &string); // uses 2 bytes for length + UInt32 WriteSafeWString_TEMP(const plString &string); + plString ReadSafeString_TEMP(); + plString ReadSafeWString_TEMP(); + hsBool GetToken(char *s, UInt32 maxLen=UInt32(-1), const char beginComment=kComment, const char endComment=kEolnCode); hsBool ReadLn(char* s, UInt32 maxLen=UInt32(-1), const char beginComment=kComment, const char endComment=kEolnCode); diff --git a/Sources/Plasma/CoreLib/plString.cpp b/Sources/Plasma/CoreLib/plString.cpp index 9db20ea8..6bbadc99 100644 --- a/Sources/Plasma/CoreLib/plString.cpp +++ b/Sources/Plasma/CoreLib/plString.cpp @@ -490,7 +490,7 @@ plString plString::Format(const char *fmt, ...) return str; } -int plString::Find(char ch, CaseSense sense) const +int plString::Find(char ch, CaseSensitivity sense) const { if (sense == kCaseSensitive) { const char *cp = strchr(s_str(), ch); @@ -506,7 +506,7 @@ int plString::Find(char ch, CaseSense sense) const } } -int plString::FindReverse(char ch, CaseSense sense) const +int plString::FindLast(char ch, CaseSensitivity sense) const { if (IsEmpty()) return -1; @@ -526,6 +526,26 @@ int plString::FindReverse(char ch, CaseSense sense) const } } +int plString::Find(const char *str, CaseSensitivity sense) const +{ + if (!str || !str[0]) + return -1; + + if (sense == kCaseSensitive) { + const char *cp = strstr(s_str(), str); + return cp ? (cp - c_str()) : -1; + } else { + // The easy way + size_t len = strlen(str); + const char *cp = c_str(); + while (*cp) { + if (strnicmp(cp, str, len) == 0) + return cp - c_str(); + ++cp; + } + } +} + static bool in_set(char key, const char *charset) { for (const char *cs = charset; *cs; ++cs) { diff --git a/Sources/Plasma/CoreLib/plString.h b/Sources/Plasma/CoreLib/plString.h index 7537bc07..fc821c5c 100644 --- a/Sources/Plasma/CoreLib/plString.h +++ b/Sources/Plasma/CoreLib/plString.h @@ -126,10 +126,6 @@ class plString }; #pragma warning(pop) - enum CaseSense { - kCaseSensitive, kCaseInsensitive - }; - public: static const plString Null; @@ -212,23 +208,50 @@ public: return str; } - int Compare(const plString &str, CaseSense sense = kCaseSensitive) const + enum CaseSensitivity { + kCaseSensitive, kCaseInsensitive + }; + + int Compare(const plString &str, CaseSensitivity sense = kCaseSensitive) const { + if (c_str() == str.c_str()) + return 0; + return (sense == kCaseSensitive) ? strcmp(s_str(), str.s_str()) : stricmp(s_str(), str.s_str()); } - int Compare(const char *str, CaseSense sense = kCaseSensitive) const + int Compare(const char *str, CaseSensitivity sense = kCaseSensitive) const { return (sense == kCaseSensitive) ? strcmp(s_str(), str) : stricmp(s_str(), str); } + int CompareN(const plString &str, size_t count, CaseSensitivity sense = kCaseSensitive) const + { + if (c_str() == str.c_str()) + return 0; + + return (sense == kCaseSensitive) ? strncmp(s_str(), str.s_str(), count) + : strnicmp(s_str(), str.s_str(), count); + } + + int CompareN(const char *str, size_t count, CaseSensitivity sense = kCaseSensitive) const + { + return (sense == kCaseSensitive) ? strncmp(s_str(), str, count) + : strnicmp(s_str(), str, count); + } + + bool operator<(const plString &other) const { return Compare(other) < 0; } bool operator==(const plString &other) const { return Compare(other) == 0; } bool operator!=(const plString &other) const { return Compare(other) != 0; } - int Find(char ch, CaseSense sense = kCaseSensitive) const; - int FindReverse(char ch, CaseSense sense = kCaseSensitive) const; + int Find(char ch, CaseSensitivity sense = kCaseSensitive) const; + int FindLast(char ch, CaseSensitivity sense = kCaseSensitive) const; + + int Find(const char *str, CaseSensitivity sense = kCaseSensitive) const; + int Find(const plString &str, CaseSensitivity sense = kCaseSensitive) const + { return Find(str.c_str(), sense); } plString TrimLeft(const char *charset = " \t\n\r") const; plString TrimRight(const char *charset = " \t\n\r") const; diff --git a/Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.cpp b/Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.cpp index 671153df..0e51d048 100644 --- a/Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.cpp +++ b/Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.cpp @@ -53,7 +53,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plResMgr/plKeyFinder.h" #include "plPipeline/plDebugText.h" -void plAnimDebugList::AddObjects(char *subString) +void plAnimDebugList::AddObjects(const plString &subString) { std::vector keys; std::vector::iterator i; @@ -79,18 +79,18 @@ void plAnimDebugList::AddObjects(char *subString) } } -void plAnimDebugList::RemoveObjects(char *subString) +void plAnimDebugList::RemoveObjects(const plString &subString) { int i; for (i = fMaterialKeys.GetCount() - 1; i >= 0; i--) { - if (strstr(fMaterialKeys[i]->GetName(), subString)) + if (fMaterialKeys[i]->GetName().Find(subString) >= 0) fMaterialKeys.Remove(i); } for (i = fSOKeys.GetCount() - 1; i >= 0; i--) { - if (strstr(fSOKeys[i]->GetName(), subString)) + if (fSOKeys[i]->GetName().Find(subString) >= 0) fSOKeys.Remove(i); } } diff --git a/Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.h b/Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.h index 5c9a02bd..5cd5cc9b 100644 --- a/Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.h +++ b/Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.h @@ -55,8 +55,8 @@ public: plAnimDebugList() : fEnabled(false) {} ~plAnimDebugList() {} - void AddObjects(char *subString); - void RemoveObjects(char *subString); + void AddObjects(const plString &subString); + void RemoveObjects(const plString &subString); void ShowReport(); }; diff --git a/Sources/Plasma/FeatureLib/pfAnimation/plFollowMod.cpp b/Sources/Plasma/FeatureLib/pfAnimation/plFollowMod.cpp index 0ca112bb..c0b627cd 100644 --- a/Sources/Plasma/FeatureLib/pfAnimation/plFollowMod.cpp +++ b/Sources/Plasma/FeatureLib/pfAnimation/plFollowMod.cpp @@ -69,11 +69,11 @@ hsBool plFollowMod::MsgReceive(plMessage* msg) plRenderMsg* rend = plRenderMsg::ConvertNoRef(msg); if( rend ) { - plProfile_BeginLap(FollowMod, this->GetKey()->GetUoid().GetObjectName()); + plProfile_BeginLap(FollowMod, this->GetKey()->GetUoid().GetObjectName().c_str()); fLeaderL2W = rend->Pipeline()->GetCameraToWorld(); fLeaderW2L = rend->Pipeline()->GetWorldToCamera(); fLeaderSet = true; - plProfile_EndLap(FollowMod, this->GetKey()->GetUoid().GetObjectName()); + plProfile_EndLap(FollowMod, this->GetKey()->GetUoid().GetObjectName().c_str()); return true; } plListenerMsg* list = plListenerMsg::ConvertNoRef(msg); diff --git a/Sources/Plasma/FeatureLib/pfAnimation/plLineFollowMod.cpp b/Sources/Plasma/FeatureLib/pfAnimation/plLineFollowMod.cpp index dd0c8f23..7bb48ac4 100644 --- a/Sources/Plasma/FeatureLib/pfAnimation/plLineFollowMod.cpp +++ b/Sources/Plasma/FeatureLib/pfAnimation/plLineFollowMod.cpp @@ -257,11 +257,11 @@ hsBool plLineFollowMod::MsgReceive(plMessage* msg) plRenderMsg* rend = plRenderMsg::ConvertNoRef(msg); if( rend ) { - plProfile_BeginLap(LineFollow, this->GetKey()->GetUoid().GetObjectName()); + plProfile_BeginLap(LineFollow, this->GetKey()->GetUoid().GetObjectName().c_str()); hsPoint3 oldPos = fSearchPos; fSearchPos = rend->Pipeline()->GetViewPositionWorld(); ICheckForPop(oldPos, fSearchPos); - plProfile_EndLap(LineFollow, this->GetKey()->GetUoid().GetObjectName()); + plProfile_EndLap(LineFollow, this->GetKey()->GetUoid().GetObjectName().c_str()); return true; } plListenerMsg* list = plListenerMsg::ConvertNoRef(msg); diff --git a/Sources/Plasma/FeatureLib/pfAnimation/plViewFaceModifier.cpp b/Sources/Plasma/FeatureLib/pfAnimation/plViewFaceModifier.cpp index 39a43aba..c96a543a 100644 --- a/Sources/Plasma/FeatureLib/pfAnimation/plViewFaceModifier.cpp +++ b/Sources/Plasma/FeatureLib/pfAnimation/plViewFaceModifier.cpp @@ -278,7 +278,7 @@ hsBool plViewFaceModifier::MsgReceive(plMessage* msg) if( rend ) { - plProfile_BeginLap(ViewFace, this->GetKey()->GetUoid().GetObjectName()); + plProfile_BeginLap(ViewFace, this->GetKey()->GetUoid().GetObjectName().c_str()); if( HasFlag(kFaceCam) ) { @@ -314,7 +314,7 @@ hsBool plViewFaceModifier::MsgReceive(plMessage* msg) IFacePoint(rend->Pipeline(), fFacePoint); - plProfile_EndLap(ViewFace, this->GetKey()->GetUoid().GetObjectName()); + plProfile_EndLap(ViewFace, this->GetKey()->GetUoid().GetObjectName().c_str()); return true; } plArmatureUpdateMsg* armMsg = plArmatureUpdateMsg::ConvertNoRef(msg); diff --git a/Sources/Plasma/FeatureLib/pfAudio/plListener.cpp b/Sources/Plasma/FeatureLib/pfAudio/plListener.cpp index d098520a..bd6de81b 100644 --- a/Sources/Plasma/FeatureLib/pfAudio/plListener.cpp +++ b/Sources/Plasma/FeatureLib/pfAudio/plListener.cpp @@ -182,21 +182,21 @@ hsBool plListener::IEval(double secs, hsScalar del, UInt32 dirty) if( fPrintDbgInfo ) { - char str[ 256 ]; - sprintf( str, "Direction: (%3.2f,%3.2f,%3.2f) from %s", dir.fX, dir.fY, dir.fZ, ( facingType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName() : "VCam" ); - plDebugText::Instance().DrawString( x, y, str, (UInt32)0xffffffff ); + plString str; + str = plString::Format( "Direction: (%3.2f,%3.2f,%3.2f) from %s", dir.fX, dir.fY, dir.fZ, ( facingType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName().c_str() : "VCam" ); + plDebugText::Instance().DrawString( x, y, str.c_str(), (UInt32)0xffffffff ); y += 12; - sprintf( str, "Up: (%3.2f,%3.2f,%3.2f) from %s", up.fX, up.fY, up.fZ, ( facingType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName() : "VCam" ); - plDebugText::Instance().DrawString( x, y, str, (UInt32)0xffffffff ); + str = plString::Format( "Up: (%3.2f,%3.2f,%3.2f) from %s", up.fX, up.fY, up.fZ, ( facingType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName().c_str() : "VCam" ); + plDebugText::Instance().DrawString( x, y, str.c_str(), (UInt32)0xffffffff ); y += 12; - sprintf( str, "Position: (%3.2f,%3.2f,%3.2f) from %s", position.fX, position.fY, position.fZ, ( posType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName() : "VCam" ); - plDebugText::Instance().DrawString( x, y, str, (UInt32)0xffffffff ); + str = plString::Format( "Position: (%3.2f,%3.2f,%3.2f) from %s", position.fX, position.fY, position.fZ, ( posType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName().c_str() : "VCam" ); + plDebugText::Instance().DrawString( x, y, str.c_str(), (UInt32)0xffffffff ); y += 12; - sprintf( str, "Velocity: (%3.2f,%3.2f,%3.2f) from %s", velocity.fX, velocity.fY, velocity.fZ, ( velType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName() : "VCam" ); - plDebugText::Instance().DrawString( x, y, str, (UInt32)0xffffffff ); + str = plString::Format( "Velocity: (%3.2f,%3.2f,%3.2f) from %s", velocity.fX, velocity.fY, velocity.fZ, ( velType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName().c_str() : "VCam" ); + plDebugText::Instance().DrawString( x, y, str.c_str(), (UInt32)0xffffffff ); y += 12; } plgDispatch::MsgSend( msg ); diff --git a/Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp b/Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp index 50cf05f4..4fcc277f 100644 --- a/Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp +++ b/Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp @@ -1318,8 +1318,8 @@ hsBool plCameraBrain1_FirstPerson::MsgReceive(plMessage* msg) plSceneObject* child = (plSceneObject*)ci->GetChild(i)->GetOwner(); if (child) { - const char* name = child->GetKeyName(); - if (stricmp(name, "FPCameraOrigin") == 0) + const plString& name = child->GetKeyName(); + if (name.Compare("FPCameraOrigin", plString::kCaseInsensitive) == 0) { fPosNode = child; SetOffset(hsVector3(0,0,0)); diff --git a/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp b/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp index 4028d296..5dc81326 100644 --- a/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp +++ b/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp @@ -533,11 +533,11 @@ void plVirtualCam1::SetRender(hsBool render) } // hack, hack, hack -hsBool plVirtualCam1::RestoreFromName(const char* name) +hsBool plVirtualCam1::RestoreFromName(const plString& name) { for(int i = 0; i < fCamerasLoaded.Count(); i++) { - if (strcmp(name, fCamerasLoaded[i]->GetKeyName()) == 0) + if (name.Compare(fCamerasLoaded[i]->GetKeyName()) == 0) { RebuildStack(fCamerasLoaded[i]->GetKey()); return true; diff --git a/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h b/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h index b615b902..12b08b69 100644 --- a/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h +++ b/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h @@ -170,7 +170,7 @@ public: void ClearStack(); void AddCameraLoaded(plSceneObject* pCam) { fCamerasLoaded.Append(pCam); } - hsBool RestoreFromName(const char* name); + hsBool RestoreFromName(const plString& name); void StartUnPan(); // these are for console access static hsBool fUseAccelOverride, freeze, alwaysCutForColin, WalkPan3rdPerson,StayInFirstPersonForever; diff --git a/Sources/Plasma/FeatureLib/pfCharacter/pfMarkerInfo.cpp b/Sources/Plasma/FeatureLib/pfCharacter/pfMarkerInfo.cpp index 270c96b0..28b27400 100644 --- a/Sources/Plasma/FeatureLib/pfCharacter/pfMarkerInfo.cpp +++ b/Sources/Plasma/FeatureLib/pfCharacter/pfMarkerInfo.cpp @@ -77,7 +77,7 @@ void pfMarkerInfo::Init() plLocation markerLoc = plKeyFinder::Instance().FindLocation("GlobalMarkers", "Markers"); if (markerLoc.IsValid()) - fMarkerUoid = plUoid(markerLoc, plSceneObject::Index(), "MarkerRoot"); + fMarkerUoid = plUoid(markerLoc, plSceneObject::Index(), _TEMP_CONVERT_FROM_LITERAL("MarkerRoot")); else fMarkerUoid.Invalidate(); } @@ -101,7 +101,7 @@ void pfMarkerInfo::Spawn(MarkerType type) plLocation markerLoc = plKeyFinder::Instance().FindLocation("GlobalMarkers", "Markers"); if (markerLoc.IsValid()) - fMarkerUoid = plUoid(markerLoc, plSceneObject::Index(), "MarkerRoot"); + fMarkerUoid = plUoid(markerLoc, plSceneObject::Index(), _TEMP_CONVERT_FROM_LITERAL("MarkerRoot")); else { hsAssert(false, "Unable to spawn markers because the marker age was not loaded or found"); diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp index 0de829d5..6a502831 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp @@ -112,9 +112,9 @@ PF_CONSOLE_FILE_DUMMY(Avatar) // ///////////////////////////////////////////////////////////////// -plKey FindSceneObjectByName(const char* name, const char* ageName, char* statusStr, bool subString=false); -plKey FindObjectByName(const char* name, int type, const char* ageName, char* statusStr, bool subString=false); -plKey FindObjectByNameAndType(const char* name, const char* typeName, const char* ageName, +plKey FindSceneObjectByName(const plString& name, const char* ageName, char* statusStr, bool subString=false); +plKey FindObjectByName(const plString& name, int type, const char* ageName, char* statusStr, bool subString=false); +plKey FindObjectByNameAndType(const plString& name, const char* typeName, const char* ageName, char* statusStr, bool subString=false); void PrintStringF(void pfun(const char *),const char * fmt, ...); @@ -353,7 +353,7 @@ PF_CONSOLE_CMD( Avatar_Turn, SetMouseTurnSensitivity, "float sensitivity", "Set PF_CONSOLE_CMD( Avatar_Multistage, Trigger, "string multiComp", "Triggers the named Multistage Animation component") { char str[256]; - plKey key = FindObjectByNameAndType((const char*)params[0], "plMultistageBehMod", nil, str, true); + plKey key = FindObjectByNameAndType(plString::FromUtf8(params[0]), "plMultistageBehMod", nil, str, true); PrintString(str); if (key) @@ -464,8 +464,8 @@ PF_CONSOLE_CMD( Avatar, "Mark whether avatars in regionA want updates on those on regionB" ) { plRelevanceMgr *mgr = plRelevanceMgr::Instance(); - char *regA = params[0]; - char *regB = params[1]; + plString regA = plString::FromUtf8(params[0]); + plString regB = plString::FromUtf8(params[1]); mgr->MarkRegion(mgr->GetIndex(regA), mgr->GetIndex(regB), params[2]); } @@ -484,7 +484,7 @@ PF_CONSOLE_CMD( Avatar, PF_CONSOLE_CMD( Avatar, SeekPoint, "string seekpoint", "Move to the given seekpoint.") { - char *spName = params[0]; + plString spName = plString::FromUtf8(params[0]); plArmatureMod *avatar = plAvatarMgr::GetInstance()->GetLocalAvatar(); @@ -586,7 +586,7 @@ PF_CONSOLE_CMD( Avatar, ClickToTurn, "bool b", "Set click-to-turn functionality. PF_CONSOLE_CMD( Avatar, FakeLinkToObj, "string objName", "Pseudo-Link the avatar to the specified object's location") { - char *spName = params[0]; + plString spName = plString::FromUtf8(params[0]); char buff[256]; plKey seekKey = FindSceneObjectByName(spName, nil, buff); if (!seekKey) diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp index b7093521..be242d4c 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp @@ -267,9 +267,9 @@ PF_CONSOLE_FILE_DUMMY(Main) // utility functions // ////////////////////////////////////////////////////////////////////////////// -plKey FindSceneObjectByName(const char* name, const char* ageName, char* statusStr, bool subString=false); -plKey FindObjectByName(const char* name, int type, const char* ageName, char* statusStr, bool subString=false); -plKey FindObjectByNameAndType(const char* name, const char* typeName, const char* ageName, +plKey FindSceneObjectByName(const plString& name, const char* ageName, char* statusStr, bool subString=false); +plKey FindObjectByName(const plString& name, int type, const char* ageName, char* statusStr, bool subString=false); +plKey FindObjectByNameAndType(const plString& name, const char* typeName, const char* ageName, char* statusStr, bool subString=false); void PrintStringF(void pfun(const char *),const char * fmt, ...); @@ -277,9 +277,9 @@ void PrintStringF(void pfun(const char *),const char * fmt, ...); // Find an object from name, type (int), and optionally age. // Name can be an alias specified by saying $foo // -plKey FindObjectByName(const char* name, int type, const char* ageName, char* statusStr, bool subString) +plKey FindObjectByName(const plString& name, int type, const char* ageName, char* statusStr, bool subString) { - if (!name) + if (name.IsNull()) { if (statusStr) sprintf(statusStr, "Object name is nil"); @@ -338,10 +338,10 @@ plKey FindObjectByName(const char* name, int type, const char* ageName, char* st // Name can be an alias specified by saying $foo. // Will load the object if necessary. // -plKey FindSceneObjectByName(const char* name, const char* ageName, char* statusStr, bool subString) +plKey FindSceneObjectByName(const plString& name, const char* ageName, char* statusStr, bool subString) { plKey key=FindObjectByName(name, plSceneObject::Index(), ageName, statusStr, subString); - + if (!plSceneObject::ConvertNoRef(key ? key->ObjectIsLoaded() : nil)) { if (statusStr) @@ -356,7 +356,7 @@ plKey FindSceneObjectByName(const char* name, const char* ageName, char* statusS // Find an object from name, type (string) and optionally age. // Name can be an alias specified by saying $foo // -plKey FindObjectByNameAndType(const char* name, const char* typeName, const char* ageName, +plKey FindObjectByNameAndType(const plString& name, const char* typeName, const char* ageName, char* statusStr, bool subString) { if (!typeName) @@ -1628,7 +1628,7 @@ PF_CONSOLE_CMD( Graphics_Renderer, GrabCubeMap, "Take cubemap from sceneObject's position and name it prefix_XX.jpg") { char str[512]; - const char* objName = params[0]; + plString objName = plString::FromUtf8(params[0]); plKey key = FindSceneObjectByName(objName, nil, str); PrintString( str ); if( !key ) @@ -1892,7 +1892,7 @@ PF_CONSOLE_CMD( Graphics_Show, SingleSound, const char *ageName = plAgeLoader::GetInstance()->GetCurrAgeDesc().GetAgeName(); - plKey key = FindSceneObjectByName( params[ 0 ], ageName, str, true ); + plKey key = FindSceneObjectByName( plString::FromUtf8( params[ 0 ] ), ageName, str, true ); plSceneObject *obj = ( key != nil ) ? plSceneObject::ConvertNoRef( key->GetObjectPtr() ) : nil; if( !obj ) { @@ -2224,7 +2224,7 @@ PF_CONSOLE_CMD( App, { char str[256]; - plKey key = FindSceneObjectByName(params[0], nil, str); + plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str); plSceneObject* obj = plSceneObject::ConvertNoRef(key->GetObjectPtr()); if( !obj ) { @@ -2301,7 +2301,7 @@ PF_CONSOLE_CMD( App, { char str[256]; - plKey key = FindSceneObjectByName(params[0], nil, str); + plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str); plSceneObject* obj = plSceneObject::ConvertNoRef(key->GetObjectPtr()); if( !obj ) { @@ -2355,18 +2355,18 @@ PF_CONSOLE_CMD( App, "Enable/Disable/Toggle display of named CamView object" ) { char str[256]; - char* name = params[0]; + plString name = plString::FromUtf8(params[0]); plKey key = FindSceneObjectByName(name, nil, str); if( !key ) { - sprintf(str, "%s - Not Found!", name); + sprintf(str, "%s - Not Found!", name.c_str()); PrintString(str); return; } plSceneObject* obj = plSceneObject::ConvertNoRef(key->GetObjectPtr()); if( !obj ) { - sprintf(str, "%s - Not Found!", name); + sprintf(str, "%s - Not Found!", name.c_str()); PrintString(str); return; } @@ -2379,11 +2379,11 @@ PF_CONSOLE_CMD( App, } if( i >= obj->GetNumModifiers() ) { - sprintf(str, "%s - No CamView Modifier found!", name); + sprintf(str, "%s - No CamView Modifier found!", name.c_str()); PrintString(str); return; } - strcpy(str, name); + strcpy(str, name.c_str()); plAnimCmdMsg* cmd = TRACKED_NEW plAnimCmdMsg(nil, obj->GetModifier(i)->GetKey(), nil); @@ -2818,7 +2818,7 @@ PF_CONSOLE_CMD( Registry, ListRefs, "string keyType, string keyName", "For the g "the objects who currently have active refs on it." ) { char result[ 256 ]; - plKey obj = FindObjectByNameAndType( params[ 1 ], params[ 0 ], nil, result); + plKey obj = FindObjectByNameAndType( plString::FromUtf8( params[ 1 ] ), params[ 0 ], nil, result); if( obj == nil ) { PrintString( result ); @@ -2994,8 +2994,7 @@ PF_CONSOLE_CMD( Camera, // groupName PF_CONSOLE_CMD( Camera, SwitchTo, "string cameraName", "Switch to the named camera") { char str[256]; - char foo[256]; - sprintf(foo, "%s_", (const char*)params[0]); + plString foo = plString::Format("%s_", plString::FromUtf8(params[0])); plKey key = FindObjectByNameAndType(foo, "plCameraModifier1", nil, str, true); PrintString(str); @@ -3119,7 +3118,7 @@ PF_CONSOLE_CMD( Camera, // groupName PF_CONSOLE_GROUP( Logic ) -static plLogicModBase *FindLogicMod(const char *name) +static plLogicModBase *FindLogicMod(const plString &name) { char str[256]; plKey key = FindObjectByNameAndType(name, "plLogicModifier", nil, str, true); @@ -3133,7 +3132,7 @@ static plLogicModBase *FindLogicMod(const char *name) PF_CONSOLE_CMD( Logic, TriggerDetectorNum, "int detectorNum", "Triggers the detector with this number (from ListDetectors)") { - std::vector activatorNames; + std::vector activatorNames; plKeyFinder::Instance().GetActivatorNames(activatorNames); int activatorNum = params[0]; @@ -3143,21 +3142,21 @@ PF_CONSOLE_CMD( Logic, TriggerDetectorNum, "int detectorNum", "Triggers the dete return; } - plLogicModBase *mod = FindLogicMod(activatorNames[activatorNum-1].c_str()); + plLogicModBase *mod = FindLogicMod(activatorNames[activatorNum-1]); if (mod) mod->ConsoleTrigger(plNetClientMgr::GetInstance()->GetLocalPlayerKey()); } PF_CONSOLE_CMD( Logic, TriggerDetector, "string detectorComp", "Triggers the named detector component") { - plLogicModBase *mod = FindLogicMod((const char*)params[0]); + plLogicModBase *mod = FindLogicMod(plString::FromUtf8(params[0])); if (mod) mod->ConsoleTrigger(plNetClientMgr::GetInstance()->GetLocalPlayerKey()); } PF_CONSOLE_CMD(Logic, EnableDetector, "string detectorComp, bool enable", "Enables/disables the named detector component") { - plLogicModBase *mod = FindLogicMod((const char*)params[0]); + plLogicModBase *mod = FindLogicMod(plString::FromUtf8(params[0])); if (mod) { plEnableMsg* enableMsg = TRACKED_NEW plEnableMsg; @@ -3202,7 +3201,7 @@ PF_CONSOLE_CMD( Logic, TriggerResponderNum, "int responderNum, ...", "Triggers t return; } - std::vector responderNames; + std::vector responderNames; plKeyFinder::Instance().GetResponderNames(responderNames); int responderNum = params[0]; @@ -3219,7 +3218,7 @@ PF_CONSOLE_CMD( Logic, TriggerResponderNum, "int responderNum, ...", "Triggers t } char str[256]; - plKey key = FindObjectByNameAndType(responderNames[responderNum-1].c_str(), "plResponderModifier", nil, str, true); + plKey key = FindObjectByNameAndType(responderNames[responderNum-1], "plResponderModifier", nil, str, true); PrintString(str); if (key) @@ -3235,7 +3234,7 @@ PF_CONSOLE_CMD( Logic, TriggerResponder, "string responderComp, ...", "Triggers } char str[256]; - plKey key = FindObjectByNameAndType(params[0], "plResponderModifier", nil, str, true); + plKey key = FindObjectByNameAndType(plString::FromUtf8(params[0]), "plResponderModifier", nil, str, true); PrintString(str); int responderState = -1; @@ -3257,7 +3256,7 @@ PF_CONSOLE_CMD( Logic, FastForwardResponder, "string responderComp, ...", "Fastf } char str[256]; - plKey key = FindObjectByNameAndType(params[0], "plResponderModifier", nil, str, true); + plKey key = FindObjectByNameAndType(plString::FromUtf8(params[0]), "plResponderModifier", nil, str, true); PrintString(str); int responderState = -1; @@ -3272,7 +3271,7 @@ PF_CONSOLE_CMD( Logic, FastForwardResponder, "string responderComp, ...", "Fastf PF_CONSOLE_CMD(Logic, ListDetectors, "", "Prints the names of the loaded detectors to the console") { - std::vector activatorNames; + std::vector activatorNames; plKeyFinder::Instance().GetActivatorNames(activatorNames); for (int i = 0; i < activatorNames.size(); i++) @@ -3285,7 +3284,7 @@ PF_CONSOLE_CMD(Logic, ListDetectors, "", "Prints the names of the loaded detecto PF_CONSOLE_CMD(Logic, ListResponders, "", "Prints the names of the loaded responders to the console") { - std::vector responderNames; + std::vector responderNames; plKeyFinder::Instance().GetResponderNames(responderNames); for (int i = 0; i < responderNames.size(); i++) @@ -3568,7 +3567,7 @@ PF_CONSOLE_CMD( Audio, SetVolume, "string obj, float vol", "Sets the volume on a given object. 1 is max volume, 0 is silence" ) { char str[ 256 ]; - plKey key = FindSceneObjectByName(params[ 0 ], nil, str); + plKey key = FindSceneObjectByName(plString::FromUtf8(params[ 0 ]), nil, str); if( key == nil ) return; @@ -3597,7 +3596,7 @@ PF_CONSOLE_CMD( Audio, IsolateSound, plKey key; plAudioSysMsg *asMsg; - key = FindSceneObjectByName( params[ 0 ], nil, str ); + key = FindSceneObjectByName( plString::FromUtf8( params[ 0 ] ), nil, str ); if( key == nil ) { sprintf( str, "Cannot find sound %s", (char *)params[ 0 ] ); @@ -4020,7 +4019,7 @@ PF_CONSOLE_CMD( Nav, UnloadPlayer, // Group name, Function name "unloads a named player" ) // Help string { char str[256]; - plKey key = FindSceneObjectByName(params[0], nil, str); + plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str); PrintString("UnloadPlayer (console version) is currently broken. Hassle Matt."); // plNetClientMgr::UnloadPlayer(key); } @@ -4038,12 +4037,12 @@ PF_CONSOLE_CMD( Nav, MovePlayer, // Group name, Function name "moves a player from one paging unit to another" ) // Help string { char str[256]; - plKey playerKey = FindSceneObjectByName(params[0], nil, str); + plKey playerKey = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str); PrintString(str); if( !playerKey ) return; - plKey nodeKey = FindObjectByName(params[1], plSceneNode::Index(), nil, str); + plKey nodeKey = FindObjectByName(plString::FromUtf8(params[1]), plSceneNode::Index(), nil, str); PrintString(str); if( !nodeKey ) return; @@ -4348,9 +4347,8 @@ PF_CONSOLE_CMD( Access, "Set the weight for a morphMod" ) { char str[256]; - char name[256]; char* preFix = params[0]; - sprintf(name, "%s_plMorphSequence_0", preFix); + plString name = plString::Format("%s_plMorphSequence_0", preFix); plKey key = FindObjectByName(name, plMorphSequence::Index(), nil, str); PrintString(str); if (!key) @@ -4374,9 +4372,8 @@ PF_CONSOLE_CMD( Access, "Activate a morphMod" ) { char str[256]; - char name[256]; char* preFix = params[0]; - sprintf(name, "%s_plMorphSequence_2", preFix); + plString name = plString::Format("%s_plMorphSequence_2", preFix); plKey key = FindObjectByName(name, plMorphSequence::Index(), nil, str); PrintString(str); if (!key) @@ -4396,9 +4393,8 @@ PF_CONSOLE_CMD( Access, "Activate a morphMod" ) { char str[256]; - char name[256]; char* preFix = params[0]; - sprintf(name, "%s_plMorphSequence_2", preFix); + plString name = plString::Format("%s_plMorphSequence_2", preFix); plKey key = FindObjectByName(name, plMorphSequence::Index(), nil, str); PrintString(str); if (!key) @@ -4623,7 +4619,7 @@ PF_CONSOLE_CMD( Access, "Test fading on visibility" ) { char str[256]; - plKey key = FindSceneObjectByName(params[0], nil, str); + plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str); PrintString(str); if( !key ) return; @@ -4655,7 +4651,7 @@ PF_CONSOLE_CMD( Access, "Set the los test marker" ) { char str[256]; - plKey key = FindSceneObjectByName(params[0], nil, str); + plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str); PrintString(str); if( !key ) return; @@ -4669,7 +4665,7 @@ PF_CONSOLE_CMD( Access, "Set the Los hack marker" ) { char str[256]; - plKey key = FindSceneObjectByName(params[0], nil, str); + plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str); PrintString(str); plSceneObject* so = nil; @@ -4744,7 +4740,7 @@ PF_CONSOLE_CMD( Access, "Fire shot along gun's z-axis, creating decal of radius , with optional max-range (def 1000)" ) { char str[256]; - plKey key = FindSceneObjectByName(params[0], nil, str); + plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str); PrintString(str); if( !key ) return; @@ -4825,7 +4821,7 @@ PF_CONSOLE_CMD( Access, "Add particle system to bulletMgr ") { char str[256]; - plKey bullKey = FindObjectByName(params[0], plDynaBulletMgr::Index(), nil, str, false); + plKey bullKey = FindObjectByName(plString::FromUtf8(params[0]), plDynaBulletMgr::Index(), nil, str, false); PrintString(str); if( !(bullKey && bullKey->GetObjectPtr()) ) { @@ -4833,7 +4829,7 @@ PF_CONSOLE_CMD( Access, return; } - plKey sysKey = FindSceneObjectByName(params[1], nil, str); + plKey sysKey = FindSceneObjectByName(plString::FromUtf8(params[1]), nil, str); if( !(sysKey && sysKey->GetObjectPtr()) ) { PrintString("Psys not found"); @@ -5030,7 +5026,7 @@ static void IDisplayWaveVal(PrintFunk PrintString, plWaveSet7* wave, plWaveCmd:: PrintString(buff); } -static plWaveSet7* IGetWaveSet(PrintFunk PrintString, const char* name) +static plWaveSet7* IGetWaveSet(PrintFunk PrintString, const plString& name) { char str[256]; plKey waveKey = FindObjectByName(name, plWaveSet7::Index(), nil, str, false); @@ -5046,7 +5042,7 @@ static plWaveSet7* IGetWaveSet(PrintFunk PrintString, const char* name) return waveSet; } -static plWaveSet7* ICheckWaveParams(PrintFunk PrintString, const char* name, int numParams, int n, plWaveCmd::Cmd cmd) +static plWaveSet7* ICheckWaveParams(PrintFunk PrintString, const plString& name, int numParams, int n, plWaveCmd::Cmd cmd) { if( !numParams ) { @@ -5083,7 +5079,7 @@ static hsScalar LimitVal(hsScalar val, hsScalar lo, hsScalar hi, PrintFunk Print static bool ISendWaveCmd1f(PrintFunk PrintString, pfConsoleCmdParam* params, int numParams, plWaveCmd::Cmd cmd) { - plWaveSet7* wave = ICheckWaveParams(PrintString, params[0], numParams, 2, cmd); + plWaveSet7* wave = ICheckWaveParams(PrintString, plString::FromUtf8(params[0]), numParams, 2, cmd); if( !wave ) return false; @@ -5162,7 +5158,7 @@ static bool ISendWaveCmd1f(PrintFunk PrintString, pfConsoleCmdParam* params, int static bool ISendWaveCmd2f(PrintFunk PrintString, pfConsoleCmdParam* params, int numParams, plWaveCmd::Cmd cmd) { - plWaveSet7* wave = ICheckWaveParams(PrintString, params[0], numParams, 3, cmd); + plWaveSet7* wave = ICheckWaveParams(PrintString, plString::FromUtf8(params[0]), numParams, 3, cmd); if( !wave ) return false; @@ -5205,7 +5201,7 @@ static bool ISendWaveCmd2f(PrintFunk PrintString, pfConsoleCmdParam* params, int static bool ISendWaveCmd3f(PrintFunk PrintString, pfConsoleCmdParam* params, int numParams, plWaveCmd::Cmd cmd) { - plWaveSet7* wave = ICheckWaveParams(PrintString, params[0], numParams, 4, cmd); + plWaveSet7* wave = ICheckWaveParams(PrintString, plString::FromUtf8(params[0]), numParams, 4, cmd); if( !wave ) return false; @@ -5243,7 +5239,7 @@ static bool ISendWaveCmd3f(PrintFunk PrintString, pfConsoleCmdParam* params, int static bool ISendWaveCmd4c(PrintFunk PrintString, pfConsoleCmdParam* params, int numParams, plWaveCmd::Cmd cmd) { - plWaveSet7* wave = ICheckWaveParams(PrintString, params[0], numParams, 4, cmd); + plWaveSet7* wave = ICheckWaveParams(PrintString, plString::FromUtf8(params[0]), numParams, 4, cmd); if( !wave ) return false; @@ -5279,7 +5275,7 @@ PF_CONSOLE_CMD( Wave, Log, // Group name, Function name "string waveSet", // Params none "Toggle logging for waves" ) // Help string { - const char* name = params[0]; + plString name = plString::FromUtf8(params[0]); plWaveSet7* waveSet = IGetWaveSet(PrintString, name); if( waveSet ) { @@ -5290,7 +5286,7 @@ PF_CONSOLE_CMD( Wave, Log, // Group name, Function name waveSet->StopLog(); char buff[256]; - sprintf(buff, "Logging for %s now %s", name, logging ? "on" : "off"); + sprintf(buff, "Logging for %s now %s", name.c_str(), logging ? "on" : "off"); PrintString(buff); } } @@ -5299,7 +5295,7 @@ PF_CONSOLE_CMD( Wave, Graph, // Group name, Function name "string waveSet", // Params none "Toggle graphing lens for waves" ) // Help string { - const char* name = params[0]; + plString name = plString::FromUtf8(params[0]); plWaveSet7* waveSet = IGetWaveSet(PrintString, name); if( waveSet ) { @@ -5310,7 +5306,7 @@ PF_CONSOLE_CMD( Wave, Graph, // Group name, Function name waveSet->StopGraph(); char buff[256]; - sprintf(buff, "Graphing for %s now %s", name, graphing ? "on" : "off"); + sprintf(buff, "Graphing for %s now %s", name.c_str(), graphing ? "on" : "off"); PrintString(buff); } } @@ -5514,7 +5510,7 @@ PF_CONSOLE_CMD( SceneObject_SetEnable, Drawable, // Group name, Function name "Enable or disable drawing of a sceneobject" ) // Help string { char str[256]; - plKey key = FindSceneObjectByName(params[0], nil, str); + plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str); PrintString(str); if (!key) return; @@ -5533,7 +5529,7 @@ PF_CONSOLE_CMD( SceneObject_SetEnable, Physical, // Group name, Function name "Enable or disable the physical of a sceneobject" ) // Help string { char str[256]; - plKey key = FindSceneObjectByName(params[0], nil, str); + plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str); PrintString(str); if (!key) return; @@ -5575,7 +5571,7 @@ PF_CONSOLE_CMD( SceneObject_SetEnable, Audible, // Group name, Function name "Enable or disable the audible of a sceneobject" ) // Help string { char str[256]; - plKey key = FindSceneObjectByName(params[0], nil, str); + plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str); PrintString(str); if (!key) return; @@ -5594,7 +5590,7 @@ PF_CONSOLE_CMD( SceneObject_SetEnable, All, // Group name, Function name "Enable or disable all fxns of a sceneobject" ) // Help string { char str[256]; - plKey key = FindSceneObjectByName(params[0], nil, str); + plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str); PrintString(str); if (!key) return; @@ -5614,8 +5610,8 @@ PF_CONSOLE_CMD( SceneObject, Attach, // Group name, Function name { char str[256]; - const char* childName = params[0]; - const char* parentName = params[1]; + plString childName = plString::FromUtf8(params[0]); + plString parentName = plString::FromUtf8(params[1]); plKey childKey = FindSceneObjectByName(childName, nil, str); if( !childKey ) @@ -5641,7 +5637,7 @@ PF_CONSOLE_CMD( SceneObject, Attach, // Group name, Function name plAttachMsg* attMsg = TRACKED_NEW plAttachMsg(parentKey, child, plRefMsg::kOnRequest, nil); plgDispatch::MsgSend(attMsg); - sprintf(str, "%s now child of %s", childName, parentName); + sprintf(str, "%s now child of %s", childName.c_str(), parentName.c_str()); PrintString(str); } @@ -5652,7 +5648,7 @@ PF_CONSOLE_CMD( SceneObject, Detach, // Group name, Function name { char str[256]; - const char* childName = params[0]; + plString childName = plString::FromUtf8(params[0]); plKey childKey = FindSceneObjectByName(childName, nil, str); if( !childKey ) @@ -5677,13 +5673,13 @@ PF_CONSOLE_CMD( SceneObject, Detach, // Group name, Function name plAttachMsg* attMsg = TRACKED_NEW plAttachMsg(parentKey, child, plRefMsg::kOnRemove, nil); plgDispatch::MsgSend(attMsg); - sprintf(str, "%s detached from %s", childName, parentKey->GetName()); + sprintf(str, "%s detached from %s", childName.c_str(), parentKey->GetName().c_str()); PrintString(str); return; } else { - sprintf(str, "%s not attached to anything", childName); + sprintf(str, "%s not attached to anything", childName.c_str()); PrintString(str); return; } @@ -6238,7 +6234,7 @@ PF_CONSOLE_CMD( Age, SetSDLBool, "string varName, bool value, int index", "Set t PF_CONSOLE_GROUP( ParticleSystem ) // Defines a main command group -void UpdateParticleParam(char *objName, Int32 paramID, hsScalar value, void (*PrintString)(const char *)) +void UpdateParticleParam(const plString &objName, Int32 paramID, hsScalar value, void (*PrintString)(const char *)) { char str[256]; plKey key = FindSceneObjectByName(objName, nil, str); @@ -6267,7 +6263,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name "string objName, float value", // Params "Set the particles-per-second generated" ) // Help string { - UpdateParticleParam(params[0], plParticleUpdateMsg::kParamParticlesPerSecond, params[1], PrintString); + UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamParticlesPerSecond, params[1], PrintString); } PF_CONSOLE_CMD( ParticleSystem, // Group name @@ -6275,7 +6271,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name "string objName, float value", // Params "Set the initial range of pitch of generated particles" ) // Help string { - UpdateParticleParam(params[0], plParticleUpdateMsg::kParamInitPitchRange, params[1], PrintString); + UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamInitPitchRange, params[1], PrintString); } PF_CONSOLE_CMD( ParticleSystem, // Group name @@ -6283,7 +6279,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name "string objName, float value", // Params "Set the initial range of yaw of generated particles" ) // Help string { - UpdateParticleParam(params[0], plParticleUpdateMsg::kParamInitYawRange, params[1], PrintString); + UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamInitYawRange, params[1], PrintString); } PF_CONSOLE_CMD( ParticleSystem, // Group name @@ -6291,7 +6287,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name "string objName, float value", // Params "Set the minimum initial velocity of generated particles" ) // Help string { - UpdateParticleParam(params[0], plParticleUpdateMsg::kParamVelMin, params[1], PrintString); + UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamVelMin, params[1], PrintString); } PF_CONSOLE_CMD( ParticleSystem, // Group name @@ -6299,7 +6295,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name "string objName, float value", // Params "Set the maximum initial velocity of generated particles" ) // Help string { - UpdateParticleParam(params[0], plParticleUpdateMsg::kParamVelMax, params[1], PrintString); + UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamVelMax, params[1], PrintString); } PF_CONSOLE_CMD( ParticleSystem, // Group name @@ -6307,7 +6303,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name "string objName, float value", // Params "Set the width of generated particles" ) // Help string { - UpdateParticleParam(params[0], plParticleUpdateMsg::kParamXSize, params[1], PrintString); + UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamXSize, params[1], PrintString); } PF_CONSOLE_CMD( ParticleSystem, // Group name @@ -6315,7 +6311,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name "string objName, float value", // Params "Set the height of generated particles" ) // Help string { - UpdateParticleParam(params[0], plParticleUpdateMsg::kParamYSize, params[1], PrintString); + UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamYSize, params[1], PrintString); } PF_CONSOLE_CMD( ParticleSystem, // Group name @@ -6323,7 +6319,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name "string objName, float value", // Params "Set the minimum width/height scaling of generated particles" ) // Help string { - UpdateParticleParam(params[0], plParticleUpdateMsg::kParamScaleMin, params[1], PrintString); + UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamScaleMin, params[1], PrintString); } PF_CONSOLE_CMD( ParticleSystem, // Group name @@ -6331,7 +6327,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name "string objName, float value", // Params "Set the maximum width/height scaling of generated particles" ) // Help string { - UpdateParticleParam(params[0], plParticleUpdateMsg::kParamScaleMax, params[1], PrintString); + UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamScaleMax, params[1], PrintString); } PF_CONSOLE_CMD( ParticleSystem, // Group name @@ -6339,7 +6335,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name "string objName, float value", // Params "Set the remaining life of the particle generator" ) // Help string { - UpdateParticleParam(params[0], plParticleUpdateMsg::kParamGenLife, params[1], PrintString); + UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamGenLife, params[1], PrintString); } PF_CONSOLE_CMD( ParticleSystem, // Group name @@ -6347,7 +6343,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name "string objName, float value", // Params "Set the minimum lifespan of generated particles (negative values make them immortal)" ) // Help string { - UpdateParticleParam(params[0], plParticleUpdateMsg::kParamPartLifeMin, params[1], PrintString); + UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamPartLifeMin, params[1], PrintString); } PF_CONSOLE_CMD( ParticleSystem, // Group name @@ -6355,7 +6351,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name "string objName, float value", // Params "Set the max lifespan of generated particles" ) // Help string { - UpdateParticleParam(params[0], plParticleUpdateMsg::kParamPartLifeMax, params[1], PrintString); + UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamPartLifeMax, params[1], PrintString); } PF_CONSOLE_CMD( ParticleSystem, @@ -6364,7 +6360,7 @@ PF_CONSOLE_CMD( ParticleSystem, "Creates a system (if necessary) on the avatar, and transfers particles" ) { char str[256]; - plKey key = FindSceneObjectByName(params[0], nil, str); + plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str); if (key == nil) return; @@ -6383,7 +6379,7 @@ PF_CONSOLE_CMD( ParticleSystem, "Flag some particles for death." ) { char str[256]; - plKey key = FindSceneObjectByName(params[0], nil, str); + plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str); if (key == nil) return; @@ -6402,7 +6398,7 @@ PF_CONSOLE_CMD( ParticleSystem, PF_CONSOLE_SUBGROUP( ParticleSystem, Flock ) -static plParticleFlockEffect *FindFlock(char *objName) +static plParticleFlockEffect *FindFlock(const plString &objName) { char str[256]; plKey key = FindSceneObjectByName(objName, nil, str); @@ -6430,7 +6426,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock, "string objName, float x, float y, float z", "Set the flock's goal to be an offset from its sceneObject") { - plParticleEffect *flock = FindFlock(params[0]); + plParticleEffect *flock = FindFlock(plString::FromUtf8(params[0])); if (flock) { (TRACKED_NEW plParticleFlockMsg(nil, flock->GetKey(), 0, plParticleFlockMsg::kFlockCmdSetOffset, params[1], params[2], params[3]))->Send(); @@ -6442,7 +6438,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock, "string objName, float x, float y, float z", "Set the goal for particles that leave the flock") { - plParticleEffect *flock = FindFlock(params[0]); + plParticleEffect *flock = FindFlock(plString::FromUtf8(params[0])); if (flock) { (TRACKED_NEW plParticleFlockMsg(nil, flock->GetKey(), 0, plParticleFlockMsg::kFlockCmdSetDissentPoint, params[1], params[2], params[3]))->Send(); @@ -6454,7 +6450,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock, "string objName, float value", "") { - plParticleFlockEffect *flock = FindFlock(params[0]); + plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0])); if (flock) flock->SetInfluenceAvgRadius(params[1]); else @@ -6466,7 +6462,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock, "string objName, float value", "") { - plParticleFlockEffect *flock = FindFlock(params[0]); + plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0])); if (flock) flock->SetInfluenceRepelRadius(params[1]); else @@ -6478,7 +6474,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock, "string objName, float value", "") { - plParticleFlockEffect *flock = FindFlock(params[0]); + plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0])); if (flock) flock->SetGoalRadius(params[1]); else @@ -6490,7 +6486,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock, "string objName, float value", "") { - plParticleFlockEffect *flock = FindFlock(params[0]); + plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0])); if (flock) flock->SetFullChaseRadius(params[1]); else @@ -6502,7 +6498,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock, "string objName, float value", "") { - plParticleFlockEffect *flock = FindFlock(params[0]); + plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0])); if (flock) flock->SetConformStr(params[1]); else @@ -6514,7 +6510,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock, "string objName, float value", "") { - plParticleFlockEffect *flock = FindFlock(params[0]); + plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0])); if (flock) flock->SetRepelStr(params[1]); else @@ -6526,7 +6522,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock, "string objName, float value", "") { - plParticleFlockEffect *flock = FindFlock(params[0]); + plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0])); if (flock) flock->SetGoalOrbitStr(params[1]); else @@ -6538,7 +6534,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock, "string objName, float value", "") { - plParticleFlockEffect *flock = FindFlock(params[0]); + plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0])); if (flock) flock->SetGoalChaseStr(params[1]); else @@ -6550,7 +6546,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock, "string objName, float value", "") { - plParticleFlockEffect *flock = FindFlock(params[0]); + plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0])); if (flock) flock->SetMaxOrbitSpeed(params[1]); else @@ -6562,7 +6558,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock, "string objName, float value", "") { - plParticleFlockEffect *flock = FindFlock(params[0]); + plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0])); if (flock) flock->SetMaxChaseSpeed(params[1]); else @@ -6580,7 +6576,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock, PF_CONSOLE_GROUP( Animation ) // Defines a main command group -void SendAnimCmdMsg(char *objName, plMessage *msg) +void SendAnimCmdMsg(const plString &objName, plMessage *msg) { char str[256]; plKey key = FindSceneObjectByName(objName, nil, str); @@ -6603,7 +6599,7 @@ PF_CONSOLE_CMD( Animation, // Group name msg->SetCmd(plAnimCmdMsg::kContinue); msg->SetAnimName(nil); msg->SetBCastFlag(plMessage::kPropagateToModifiers); - SendAnimCmdMsg(params[0], msg); + SendAnimCmdMsg(plString::FromUtf8(params[0]), msg); } PF_CONSOLE_CMD( Animation, // Group name @@ -6615,7 +6611,7 @@ PF_CONSOLE_CMD( Animation, // Group name msg->SetCmd(plAnimCmdMsg::kStop); msg->SetAnimName(nil); msg->SetBCastFlag(plMessage::kPropagateToModifiers); - SendAnimCmdMsg(params[0], msg); + SendAnimCmdMsg(plString::FromUtf8(params[0]), msg); } PF_CONSOLE_CMD( Animation, // Group name @@ -6629,7 +6625,7 @@ PF_CONSOLE_CMD( Animation, // Group name msg->fBlendRate = params[3]; msg->SetAnimName(params[1]); msg->SetBCastFlag(plMessage::kPropagateToModifiers); - SendAnimCmdMsg(params[0], msg); + SendAnimCmdMsg(plString::FromUtf8(params[0]), msg); } PF_CONSOLE_CMD( Animation, // Group name @@ -6643,7 +6639,7 @@ PF_CONSOLE_CMD( Animation, // Group name msg->fAmpRate = params[3]; msg->SetAnimName(params[1]); msg->SetBCastFlag(plMessage::kPropagateToModifiers); - SendAnimCmdMsg(params[0], msg); + SendAnimCmdMsg(plString::FromUtf8(params[0]), msg); } PF_CONSOLE_CMD( Animation, // Group name @@ -6657,7 +6653,7 @@ PF_CONSOLE_CMD( Animation, // Group name msg->fSpeedChangeRate = params[3]; msg->SetAnimName(params[1]); msg->SetBCastFlag(plMessage::kPropagateToModifiers); - SendAnimCmdMsg(params[0], msg); + SendAnimCmdMsg(plString::FromUtf8(params[0]), msg); } PF_CONSOLE_CMD( Animation, @@ -6667,7 +6663,7 @@ PF_CONSOLE_CMD( Animation, { plAnimDebugList *adl = plClient::GetInstance()->fAnimDebugList; if (adl) - adl->AddObjects(params[0]); + adl->AddObjects(plString::FromUtf8(params[0])); } PF_CONSOLE_CMD( Animation, @@ -6677,7 +6673,7 @@ PF_CONSOLE_CMD( Animation, { plAnimDebugList *adl = plClient::GetInstance()->fAnimDebugList; if (adl) - adl->RemoveObjects(params[0]); + adl->RemoveObjects(plString::FromUtf8(params[0])); } PF_CONSOLE_CMD( Animation, diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp index 4268604a..27f2ea12 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp @@ -196,9 +196,9 @@ PF_CONSOLE_FILE_DUMMY(Net) // utility functions // ////////////////////////////////////////////////////////////////////////////// -plKey FindSceneObjectByName(const char* name, const char* ageName, char* statusStr, bool subString=false); -plKey FindObjectByName(const char* name, int type, const char* ageName, char* statusStr, bool subString=false); -plKey FindObjectByNameAndType(const char* name, const char* typeName, const char* ageName, +plKey FindSceneObjectByName(const plString& name, const char* ageName, char* statusStr, bool subString=false); +plKey FindObjectByName(const plString& name, int type, const char* ageName, char* statusStr, bool subString=false); +plKey FindObjectByNameAndType(const plString& name, const char* typeName, const char* ageName, char* statusStr, bool subString=false); void PrintStringF(void pfun(const char *),const char * fmt, ...); @@ -508,7 +508,7 @@ PF_CONSOLE_CMD( Net, // groupName "Instructs the server to only send me updates about this object periodically" ) // helpString { char str[256]; - plKey key = FindSceneObjectByName(params[0], nil, str); + plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str); PrintString(str); if (!key) return; diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp index 7abc9027..9761f828 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp @@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnMessage/plMessage.h" #include "pnKeyedObject/plKey.h" #include "hsWindows.h" +#include "plString.h" static bool DumpSpecificMsgInfo(plMessage* msg, std::string& info); @@ -137,9 +138,9 @@ void plDispatchLog::DumpMsg(plMessage* msg, int numReceivers, int sendTimeMs, In fLog->AddLineF("%sDispatched (%d) %d ms: time=%d CName=%s, sndr=%s, rcvr(%d)=%s, flags=0x%lx, tstamp=%f\n", indentStr, numReceivers, sendTimeMs, - int(sendTime), msg->ClassName(), msg->fSender?msg->fSender->GetName():"nil", + int(sendTime), msg->ClassName(), msg->fSender?msg->fSender->GetName().c_str():"nil", msg->GetNumReceivers(), msg->GetNumReceivers() && msg->GetReceiver(0) - ? msg->GetReceiver(0)->GetName():"nil", + ? msg->GetReceiver(0)->GetName().c_str():"nil", msg->fBCastFlags, msg->fTimeStamp); lastTime=curTime; diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIControlMod.cpp b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIControlMod.cpp index 7fc3ebda..3b4ace00 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIControlMod.cpp +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIControlMod.cpp @@ -587,11 +587,11 @@ hsBool pfGUIControlMod::MsgReceive( plMessage *msg ) if( rend ) { - plProfile_BeginLap(GUITime, this->GetKey()->GetUoid().GetObjectName()); + plProfile_BeginLap(GUITime, this->GetKey()->GetUoid().GetObjectName().c_str()); // Only need it once if( ISetUpDynTextMap( rend->Pipeline() ) ) plgDispatch::Dispatch()->UnRegisterForExactType( plRenderMsg::Index(), GetKey() ); - plProfile_EndLap(GUITime, this->GetKey()->GetUoid().GetObjectName()); + plProfile_EndLap(GUITime, this->GetKey()->GetUoid().GetObjectName().c_str()); return true; } diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICtrlGenerator.cpp b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICtrlGenerator.cpp index 78aba3a6..58aff8dd 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICtrlGenerator.cpp +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICtrlGenerator.cpp @@ -122,22 +122,20 @@ pfGUICtrlGenerator &pfGUICtrlGenerator::Instance( void ) //// IGetNextKeyName ///////////////////////////////////////////////////////// -void pfGUICtrlGenerator::IGetNextKeyName( char *name, const char *prefix ) +plString pfGUICtrlGenerator::IGetNextKeyName( const char *prefix ) { static UInt32 keyCount = 0; - - sprintf( name, "%s%d", prefix, keyCount++ ); + return plString::Format( "%s%d", prefix, keyCount++ ); } //// IAddKey ///////////////////////////////////////////////////////////////// plKey pfGUICtrlGenerator::IAddKey( hsKeyedObject *ko, const char *prefix ) { - char keyName[ 128 ]; - + plString keyName; - IGetNextKeyName( keyName, prefix ); + keyName = IGetNextKeyName( prefix ); return hsgResMgr::ResMgr()->NewKey( keyName, ko, plLocation::kGlobalFixedLoc ); } diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICtrlGenerator.h b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICtrlGenerator.h index 123d12d6..628b5da6 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICtrlGenerator.h +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICtrlGenerator.h @@ -85,7 +85,7 @@ class pfGUICtrlGenerator plKey IAddKey( hsKeyedObject *ko, const char *prefix ); - void IGetNextKeyName( char *name, const char *prefix ); + plString IGetNextKeyName( const char *prefix ); hsGMaterial *ICreateSolidMaterial( hsColorRGBA &color ); diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListElement.cpp b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListElement.cpp index 1376c87a..1a97d260 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListElement.cpp +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListElement.cpp @@ -221,8 +221,7 @@ pfGUIListPicture::pfGUIListPicture( plKey mipKey, hsBool respectAlpha ) : pfGUIL { // Gotta make and grab an uncompressed one plMipmap *uncompBuffer = hsCodecManager::Instance().CreateUncompressedMipmap( mip, hsCodecManager::k32BitDepth ); - char str[ 512 ]; - sprintf( str, "%s_uncomp", mip->GetKeyName() ); + plString str = plString::Format( "%s_uncomp", mip->GetKeyName() ); fMipmapKey = hsgResMgr::ResMgr()->NewKey( str, uncompBuffer, fMipmapKey->GetUoid().GetLocation() ); fMipmapKey->RefObject(); } diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIPopUpMenu.cpp b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIPopUpMenu.cpp index 777066eb..7efd73c6 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIPopUpMenu.cpp +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIPopUpMenu.cpp @@ -97,8 +97,7 @@ class pfPopUpKeyGenerator plKey CreateKey( hsKeyedObject *ko ) { - char name[ 256 ]; - sprintf( name, "%s-%d", fPrefix, fKeyCount++ ); + plString name = plString::Format( "%s-%d", fPrefix, fKeyCount++ ); return hsgResMgr::ResMgr()->NewKey( name, ko, fLoc ); } diff --git a/Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp b/Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp index 91a40e62..de0fae63 100644 --- a/Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp +++ b/Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp @@ -446,7 +446,7 @@ public: //// Book data class ///////////////////////////////////////////////////////// -pfBookData::pfBookData(const char *guiName /* = nil */) +pfBookData::pfBookData(const plString &guiName /* = nil */) { fCurrBook = nil; fDialog = nil; @@ -470,10 +470,10 @@ pfBookData::pfBookData(const char *guiName /* = nil */) fEditable = false; fAdjustCursorTo = -1; - if (guiName) + if (!guiName.IsEmpty()) fGUIName = guiName; else - fGUIName = "BkBook"; + fGUIName = _TEMP_CONVERT_FROM_LITERAL("BkBook"); } pfBookData::~pfBookData() @@ -1137,18 +1137,18 @@ void pfBookData::EnableEditGUI(hsBool enable/* =true */) //// Our Singleton Stuff ///////////////////////////////////////////////////// //pfJournalBook *pfJournalBook::fInstance = nil; -std::map pfJournalBook::fBookGUIs; +std::map pfJournalBook::fBookGUIs; void pfJournalBook::SingletonInit( void ) { - fBookGUIs["BkBook"] = TRACKED_NEW pfBookData(); // load the default book data object - hsgResMgr::ResMgr()->NewKey("BkBook",fBookGUIs["BkBook"],pfGameGUIMgr::GetInstance()->GetKey()->GetUoid().GetLocation()); - fBookGUIs["BkBook"]->LoadGUI(); + fBookGUIs[_TEMP_CONVERT_FROM_LITERAL("BkBook")] = TRACKED_NEW pfBookData(); // load the default book data object + hsgResMgr::ResMgr()->NewKey(_TEMP_CONVERT_FROM_LITERAL("BkBook"),fBookGUIs[_TEMP_CONVERT_FROM_LITERAL("BkBook")],pfGameGUIMgr::GetInstance()->GetKey()->GetUoid().GetLocation()); + fBookGUIs[_TEMP_CONVERT_FROM_LITERAL("BkBook")]->LoadGUI(); } void pfJournalBook::SingletonShutdown( void ) { - std::map::iterator i = fBookGUIs.begin(); + std::map::iterator i = fBookGUIs.begin(); while (i != fBookGUIs.end()) { pfBookData *bookData = i->second; @@ -1159,7 +1159,7 @@ void pfJournalBook::SingletonShutdown( void ) fBookGUIs.clear(); } -void pfJournalBook::LoadGUI( const char *guiName ) +void pfJournalBook::LoadGUI( const plString &guiName ) { if (fBookGUIs.find(guiName) == fBookGUIs.end()) // is it already loaded? { // nope, load it @@ -1169,11 +1169,11 @@ void pfJournalBook::LoadGUI( const char *guiName ) } } -void pfJournalBook::UnloadGUI( const char *guiName ) +void pfJournalBook::UnloadGUI( const plString &guiName ) { - if (strcmp(guiName,"BkBook")==0) + if (guiName.Compare("BkBook")==0) return; // do not allow people to unload the default book gui - std::map::iterator loc = fBookGUIs.find(guiName); + std::map::iterator loc = fBookGUIs.find(guiName); if (loc != fBookGUIs.end()) // make sure it's loaded { fBookGUIs[guiName]->GetKey()->UnRefObject(); @@ -1184,17 +1184,17 @@ void pfJournalBook::UnloadGUI( const char *guiName ) void pfJournalBook::UnloadAllGUIs() { - std::map::iterator i = fBookGUIs.begin(); - std::vector names; + std::map::iterator i = fBookGUIs.begin(); + std::vector names; while (i != fBookGUIs.end()) { - std::string name = i->first; + plString name = i->first; names.push_back(name); // store a list of keys i++; } int idx; for (idx = 0; idx < names.size(); idx++) - UnloadGUI(names[idx].c_str()); // UnloadGUI won't unload BkBook + UnloadGUI(names[idx]); // UnloadGUI won't unload BkBook } //// Constructor ///////////////////////////////////////////////////////////// @@ -1203,16 +1203,16 @@ void pfJournalBook::UnloadAllGUIs() // key is the keyed object to send event messages to (see tag). pfJournalBook::pfJournalBook( const char *esHTMLSource, plKey coverImageKey, plKey callbackKey /*= nil*/, - const plLocation &hintLoc /* = plLocation::kGlobalFixedLoc */, const char *guiName /* = nil */ ) + const plLocation &hintLoc /* = plLocation::kGlobalFixedLoc */, const plString &guiName /* = nil */ ) { - if (guiName && (strcmp(guiName,"") != 0)) + if (!guiName.IsEmpty()) fCurBookGUI = guiName; else - fCurBookGUI = "BkBook"; + fCurBookGUI = _TEMP_CONVERT_FROM_LITERAL("BkBook"); if (fBookGUIs.find(fCurBookGUI) == fBookGUIs.end()) { - fBookGUIs[fCurBookGUI] = TRACKED_NEW pfBookData(fCurBookGUI.c_str()); - hsgResMgr::ResMgr()->NewKey(fCurBookGUI.c_str(),fBookGUIs[fCurBookGUI],pfGameGUIMgr::GetInstance()->GetKey()->GetUoid().GetLocation()); + fBookGUIs[fCurBookGUI] = TRACKED_NEW pfBookData(fCurBookGUI); + hsgResMgr::ResMgr()->NewKey(fCurBookGUI,fBookGUIs[fCurBookGUI],pfGameGUIMgr::GetInstance()->GetKey()->GetUoid().GetLocation()); fBookGUIs[fCurBookGUI]->LoadGUI(); } @@ -1239,16 +1239,16 @@ pfJournalBook::pfJournalBook( const char *esHTMLSource, plKey coverImageKey, plK } pfJournalBook::pfJournalBook( const wchar_t *esHTMLSource, plKey coverImageKey, plKey callbackKey /*= nil*/, - const plLocation &hintLoc /* = plLocation::kGlobalFixedLoc */, const char *guiName /* = nil */ ) + const plLocation &hintLoc /* = plLocation::kGlobalFixedLoc */, const plString &guiName /* = nil */ ) { - if (guiName && (strcmp(guiName,"") != 0)) + if (!guiName.IsEmpty()) fCurBookGUI = guiName; else - fCurBookGUI = "BkBook"; + fCurBookGUI = _TEMP_CONVERT_FROM_LITERAL("BkBook"); if (fBookGUIs.find(fCurBookGUI) == fBookGUIs.end()) { - fBookGUIs[fCurBookGUI] = TRACKED_NEW pfBookData(fCurBookGUI.c_str()); - hsgResMgr::ResMgr()->NewKey(fCurBookGUI.c_str(),fBookGUIs[fCurBookGUI],pfGameGUIMgr::GetInstance()->GetKey()->GetUoid().GetLocation()); + fBookGUIs[fCurBookGUI] = TRACKED_NEW pfBookData(fCurBookGUI); + hsgResMgr::ResMgr()->NewKey(fCurBookGUI,fBookGUIs[fCurBookGUI],pfGameGUIMgr::GetInstance()->GetKey()->GetUoid().GetLocation()); fBookGUIs[fCurBookGUI]->LoadGUI(); } @@ -1288,12 +1288,12 @@ hsBool pfJournalBook::MsgReceive( plMessage *pMsg ) return hsKeyedObject::MsgReceive( pMsg ); } -void pfJournalBook::SetGUI( const char *guiName ) +void pfJournalBook::SetGUI( const plString &guiName ) { - if (guiName && (strcmp(guiName,"") != 0)) + if (!guiName.IsEmpty()) fCurBookGUI = guiName; if (fBookGUIs.find(fCurBookGUI) == fBookGUIs.end()) - fCurBookGUI = "BkBook"; // requested GUI isn't loaded, so use default GUI + fCurBookGUI = _TEMP_CONVERT_FROM_LITERAL("BkBook"); // requested GUI isn't loaded, so use default GUI SetEditable(fWantEditing); // make sure that if we want editing, to set it ICompileSource(fUncompiledSource.c_str(), fDefLoc); // recompile the source to be safe } @@ -2501,20 +2501,19 @@ void pfJournalBook::IFreeSource( void ) plKey pfJournalBook::IGetMipmapKey( const wchar_t *name, const plLocation &loc ) { - char *cName = hsWStringToString(name); + plString cName = plString::FromWchar(name); #ifndef PLASMA_EXTERNAL_RELEASE - if( strchr( cName, '/' ) != nil || strchr( cName, '\\' ) != nil ) + if( cName.Find( '/' ) >= 0 || cName.Find( '\\' ) >= 0 ) { // For internal use only--allow local path names of PNG and JPEG images, to // facilitate fast prototyping plMipmap *mip; - if( strstr( cName, ".png" ) != nil ) - mip = plPNG::Instance().ReadFromFile( cName ); + if( cName.Find( ".png" ) >= 0 ) + mip = plPNG::Instance().ReadFromFile( _TEMP_CONVERT_TO_CONST_CHAR( cName ) ); else - mip = plJPEG::Instance().ReadFromFile( cName ); + mip = plJPEG::Instance().ReadFromFile( _TEMP_CONVERT_TO_CONST_CHAR( cName ) ); hsgResMgr::ResMgr()->NewKey( cName, mip, loc ); - delete [] cName; return mip->GetKey(); } #endif @@ -2524,7 +2523,6 @@ plKey pfJournalBook::IGetMipmapKey( const wchar_t *name, const plLocation &loc plKey key = hsgResMgr::ResMgr()->FindKey( myUoid ); if( key != nil ) { - delete [] cName; return key; } @@ -2535,7 +2533,6 @@ plKey pfJournalBook::IGetMipmapKey( const wchar_t *name, const plLocation &loc key = hsgResMgr::ResMgr()->FindKey( myUoid ); if( key != nil ) { - delete [] cName; return key; } @@ -2548,13 +2545,11 @@ plKey pfJournalBook::IGetMipmapKey( const wchar_t *name, const plLocation &loc key = plKeyFinder::Instance().StupidSearch( thisAge, nil, plMipmap::Index(), cName, true ); if( key != nil ) { - delete [] cName; return key; } } } - delete [] cName; return nil; } @@ -3043,13 +3038,13 @@ plLayerBink *pfJournalBook::IMakeMovieLayer(pfEsHTMLChunk *chunk, UInt16 x, UInt // We'll need a unique name. This is a hack, but an effective hack. static int uniqueSuffix = 0; - char buff[256]; + plString buff; - sprintf(buff, "%s_%d_ml", GetKey()->GetName(), uniqueSuffix); + buff = plString::Format("%s_%d_ml", GetKey()->GetName().c_str(), uniqueSuffix); layer = TRACKED_NEW plLayer; hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation()); - sprintf(buff, "%s_%d_m", GetKey()->GetName(), uniqueSuffix++); + buff = plString::Format("%s_%d_m", GetKey()->GetName().c_str(), uniqueSuffix++); movieLayer = TRACKED_NEW plLayerBink; hsgResMgr::ResMgr()->NewKey(buff, movieLayer, GetKey()->GetUoid().GetLocation()); movieLayer->GetKey()->RefObject(); // we want to own a ref so we can nuke it at will @@ -3192,8 +3187,7 @@ plLayerInterface *pfJournalBook::IMakeBaseLayer(plMipmap *image) // We'll need a unique name. This is a hack, but an effective hack. static int uniqueSuffix = 0; - char buff[256]; - sprintf(buff, "%s_%d", GetKey()->GetName(), uniqueSuffix++); + plString buff = plString::Format("%s_%d", GetKey()->GetName().c_str(), uniqueSuffix++); plLayer* layer = TRACKED_NEW plLayer; hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation()); @@ -3247,8 +3241,7 @@ plLayerInterface *pfJournalBook::IMakeDecalLayer(pfEsHTMLChunk *decalChunk, plMi // We'll need a unique name. This is a hack, but an effective hack. static int uniqueSuffix = 0; - char buff[256]; - sprintf(buff, "%s_%d_d", GetKey()->GetName(), uniqueSuffix++); + plString buff = plString::Format("%s_%d_d", GetKey()->GetName().c_str(), uniqueSuffix++); plLayer* layer = TRACKED_NEW plLayer; hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation()); diff --git a/Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.h b/Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.h index 6be8fc27..affa289a 100644 --- a/Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.h +++ b/Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.h @@ -211,7 +211,7 @@ public: kTurnBackPage }; - pfBookData(const char *guiName = nil); + pfBookData(const plString &guiName = plString::Null); virtual ~pfBookData(); void LoadGUI(); // need this seperate because the plKey isn't setup until the constructor is done @@ -284,7 +284,7 @@ protected: kRefDefaultCover }; - std::string fGUIName; + plString fGUIName; // The pointer to our dialog pfGUIDialogMod *fDialog; @@ -362,8 +362,8 @@ class pfJournalBook : public hsKeyedObject // The constructor takes in the esHTML source for the journal, along with // the name of the mipmap to use as the cover of the book. The callback // key is the keyed object to send event messages to (see tag). - pfJournalBook( const char *esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, const plLocation &hintLoc = plLocation::kGlobalFixedLoc, const char *guiName = nil ); - pfJournalBook( const wchar_t *esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, const plLocation &hintLoc = plLocation::kGlobalFixedLoc, const char *guiName = nil ); + pfJournalBook( const char *esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, const plLocation &hintLoc = plLocation::kGlobalFixedLoc, const plString &guiName = plString::Null ); + pfJournalBook( const wchar_t *esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, const plLocation &hintLoc = plLocation::kGlobalFixedLoc, const plString &guiName = plString::Null ); virtual ~pfJournalBook(); @@ -380,15 +380,15 @@ class pfJournalBook : public hsKeyedObject static void SingletonShutdown( void ); // loads a gui - static void LoadGUI( const char *guiName ); + static void LoadGUI( const plString &guiName ); // unloads a gui if we don't need it any more and want to free up memory - static void UnloadGUI( const char *guiName ); + static void UnloadGUI( const plString &guiName ); // unloads all GUIs except for the default static void UnloadAllGUIs(); - void SetGUI( const char *guiName ); + void SetGUI( const plString &guiName ); // Shows the book, optionally starting open or closed void Show( hsBool startOpened = false ); @@ -505,8 +505,8 @@ class pfJournalBook : public hsKeyedObject // Current list of linkable image chunks we have visible on the screen, for quick hit testing hsTArray fVisibleLinks; - static std::map fBookGUIs; - std::string fCurBookGUI; + static std::map fBookGUIs; + plString fCurBookGUI; enum Refs { diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp b/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp index 27d33639..a48ce09e 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp @@ -194,12 +194,12 @@ void cyMisc::ConsoleNet(const char* command, hsBool netForce) // PURPOSE : Execute a console command from a python script, // optionally propagate over the net // -PyObject* cyMisc::FindSceneObject(const char* name, const char* ageName) +PyObject* cyMisc::FindSceneObject(const plString& name, const char* ageName) { // assume that we won't find the sceneobject (key is equal to nil) plKey key=nil; - if ( name || name[0] != 0) + if ( !name.IsEmpty() ) { const char* theAge = ageName; if ( ageName[0] == 0 ) @@ -209,18 +209,17 @@ PyObject* cyMisc::FindSceneObject(const char* name, const char* ageName) if ( key == nil ) { - char errmsg[256]; - sprintf(errmsg,"Sceneobject %s not found",name); - PyErr_SetString(PyExc_NameError, errmsg); + plString errmsg = plString::Format("Sceneobject %s not found",name.c_str()); + PyErr_SetString(PyExc_NameError, errmsg.c_str()); return nil; // return nil cause we errored } return pySceneObject::New(key); } -PyObject* cyMisc::FindActivator(const char* name) +PyObject* cyMisc::FindActivator(const plString& name) { plKey key = nil; - if (name && strlen(name) > 0) + if (!name.IsEmpty()) { std::vector keylist; plKeyFinder::Instance().ReallyStupidActivatorSearch(name, keylist); @@ -453,9 +452,9 @@ hsBool cyMisc::WasLocallyNotified(pyKey &selfkey) // PURPOSE : Return the net client (account) name of the player whose avatar // key is provided. // -const char* cyMisc::GetClientName(pyKey &avKey) +plString cyMisc::GetClientName(pyKey &avKey) { - return plNetClientMgr::GetInstance()->GetPlayerName(avKey.getKey()).s_str(); + return plNetClientMgr::GetInstance()->GetPlayerName(avKey.getKey()); } PyObject* cyMisc::GetAvatarKeyFromClientID(int clientID) @@ -546,9 +545,9 @@ hsBool cyMisc::ValidateKey(pyKey& key) // // PURPOSE : Return the local net client (account) name // -const char* cyMisc::GetLocalClientName() +plString cyMisc::GetLocalClientName() { - return plNetClientMgr::GetInstance()->GetPlayerName().c_str(); + return plNetClientMgr::GetInstance()->GetPlayerName(); } @@ -1910,7 +1909,7 @@ int cyMisc::GetNumParticles(pyKey& host) } -void cyMisc::SetLightColorValue(pyKey& light, std::string lightName, hsScalar r, hsScalar g, hsScalar b, hsScalar a) +void cyMisc::SetLightColorValue(pyKey& light, const plString& lightName, hsScalar r, hsScalar g, hsScalar b, hsScalar a) { // lightName is the name of the light object attached to the light that we want to talk to // for the bug lights, this would be "RTOmni-BugLightTest" @@ -1958,7 +1957,7 @@ void cyMisc::SetLightColorValue(pyKey& light, std::string lightName, hsScalar r, } #include "pnMessage/plEnableMsg.h" -void cyMisc::SetLightAnimationOn(pyKey& light, std::string lightName, hsBool start) +void cyMisc::SetLightAnimationOn(pyKey& light, const plString& lightName, hsBool start) { // lightName is the name of the light object attached to the light that we want to talk to // for the bug lights, this would be "RTOmni-BugLightTest" @@ -2449,28 +2448,26 @@ const char* cyMisc::GetCameraNumber(int number) plCameraModifier1* pCam = plVirtualCam1::Instance()->GetCameraNumber(number-1); if (pCam->GetTarget()) { - const char* ret = pCam->GetTarget()->GetKeyName(); + const char* ret = pCam->GetTarget()->GetKeyName().c_str(); (ret==nil) ? "empty" : ret; - char str[256]; - sprintf(str, "saving camera named %s to chronicle\n",ret); - plVirtualCam1::Instance()->AddMsgToLog(str); + plString str = plString::Format("saving camera named %s to chronicle\n",ret); + plVirtualCam1::Instance()->AddMsgToLog(str.c_str()); return ret; } plVirtualCam1::Instance()->AddMsgToLog("sending empty to camera chronicle\n"); return "empty"; } -void cyMisc::RebuildCameraStack(const char* name, const char* ageName) +void cyMisc::RebuildCameraStack(const plString& name, const char* ageName) { plKey key=nil; - char str[256]; - sprintf(str, "attempting to restore camera named %s from chronicle\n",name); - plVirtualCam1::Instance()->AddMsgToLog(str); - - if (strcmp(name, "empty") == 0) + plString str = plString::Format("attempting to restore camera named %s from chronicle\n",name.c_str()); + plVirtualCam1::Instance()->AddMsgToLog(str.c_str()); + + if (name.Compare("empty") == 0) return; - if ( name || name[0] != 0) + if ( !name.IsEmpty() ) { key=plKeyFinder::Instance().StupidSearch(nil,nil,plSceneObject::Index(), name, false); } @@ -2481,9 +2478,8 @@ void cyMisc::RebuildCameraStack(const char* name, const char* ageName) { // give up and force built in 3rd person plVirtualCam1::Instance()->PushThirdPerson(); - char errmsg[256]; - sprintf(errmsg,"Sceneobject %s not found",name); - PyErr_SetString(PyExc_NameError, errmsg); + plString errmsg = plString::Format("Sceneobject %s not found",name.c_str()); + PyErr_SetString(PyExc_NameError, errmsg.c_str()); } } else @@ -2506,9 +2502,8 @@ void cyMisc::RebuildCameraStack(const char* name, const char* ageName) } } plVirtualCam1::Instance()->PushThirdPerson(); - char errmsg[256]; - sprintf(errmsg,"Sceneobject %s has no camera modifier",name); - PyErr_SetString(PyExc_NameError, errmsg); + plString errmsg = plString::Format("Sceneobject %s has no camera modifier",name.c_str()); + PyErr_SetString(PyExc_NameError, errmsg.c_str()); } } @@ -2670,10 +2665,10 @@ void cyMisc::FakeLinkToObject(pyKey& avatar, pyKey& object) plgDispatch::MsgSend(msg); } -void cyMisc::FakeLinkToObjectNamed(const char* name) +void cyMisc::FakeLinkToObjectNamed(const plString& name) { plKey key = nil; - if ( name || name[0] != 0) + if ( !name.IsEmpty() ) { key = plKeyFinder::Instance().StupidSearch(nil,nil,plSceneObject::Index(), name, false); } diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMisc.h b/Sources/Plasma/FeatureLib/pfPython/cyMisc.h index d2afdd0a..706a70a6 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMisc.h +++ b/Sources/Plasma/FeatureLib/pfPython/cyMisc.h @@ -142,8 +142,8 @@ public: // PURPOSE : Execute a console command from a python script, // optionally propagate over the net // - static PyObject* FindSceneObject(const char* name, const char* ageName); // returns pySceneObject - static PyObject* FindActivator(const char* name); // returns pyKey + static PyObject* FindSceneObject(const plString& name, const char* ageName); // returns pySceneObject + static PyObject* FindActivator(const plString& name); // returns pyKey ///////////////////////////////////////////////////////////////////////////// // @@ -252,7 +252,7 @@ public: // PURPOSE : Return the net client (account) name of the player whose avatar // key is provided. // - static const char* GetClientName(pyKey &avKey); + static plString GetClientName(pyKey &avKey); static PyObject* GetAvatarKeyFromClientID(int clientID); // returns pyKey static int GetLocalClientID(); @@ -268,7 +268,7 @@ public: // // PURPOSE : Return the local net client (account) name // - static const char* GetLocalClientName(); + static plString GetLocalClientName(); // @@ -697,8 +697,8 @@ public: static void SetParticleOffset(float x, float y, float z, pyKey& particles); static void KillParticles(float time, float pct, pyKey& particles); static int GetNumParticles(pyKey& host); - static void SetLightColorValue(pyKey& light, std::string lightName, hsScalar r, hsScalar g, hsScalar b, hsScalar a); - static void SetLightAnimationOn(pyKey& light, std::string lightName, hsBool start); + static void SetLightColorValue(pyKey& light, const plString& lightName, hsScalar r, hsScalar g, hsScalar b, hsScalar a); + static void SetLightAnimationOn(pyKey& light, const plString& lightName, hsBool start); ////////////////////////////////////////////////////////////////////////////// // // Function : RegisterForControlEventMessages @@ -799,7 +799,7 @@ public: static int GetNumCameras(); static const char* GetCameraNumber(int number); - static void RebuildCameraStack(const char* name, const char* ageName); + static void RebuildCameraStack(const plString& name, const char* ageName); static void PyClearCameraStack(); static void RecenterCamera(); static bool IsFirstPerson(); @@ -877,8 +877,8 @@ public: // PURPOSE : takes an avatar key and an object key and fake-links the avatar // to that object's position. appears to be a link to other players // - static void FakeLinkToObject(pyKey& avatar, pyKey& object); - static void FakeLinkToObjectNamed(const char* name); + static void FakeLinkToObject(pyKey& avatar, pyKey& object); + static void FakeLinkToObjectNamed(const plString& name); ////////////////////////////////////////////////////////////////////////////// // diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp index b63e276f..2ff81a00 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp @@ -112,10 +112,10 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtGetClientName, args, "Params: avatarKey=None\n PYTHON_RETURN_ERROR; } pyKey* key = pyKey::ConvertFrom(keyObj); - return PyString_FromString(cyMisc::GetClientName(*key)); + return PyString_FromString(cyMisc::GetClientName(*key).s_str()); } else - return PyString_FromString(cyMisc::GetLocalClientName()); + return PyString_FromString(cyMisc::GetLocalClientName().c_str()); } PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetLocalAvatar, "This will return a ptSceneobject of the local avatar\n" diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue3.cpp b/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue3.cpp index c6e3b396..1cf5b4bd 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue3.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue3.cpp @@ -183,7 +183,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtFindSceneobject, args, "Params: name,ageName\n PyErr_SetString(PyExc_TypeError, "PtFindSceneobject expects two strings"); PYTHON_RETURN_ERROR; } - return cyMisc::FindSceneObject(name, ageName); + return cyMisc::FindSceneObject(plString::FromUtf8(name), ageName); } PYTHON_GLOBAL_METHOD_DEFINITION(PtFindActivator, args, "Params: name\nThis will try to find an activator based on its name\n" @@ -197,7 +197,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtFindActivator, args, "Params: name\nThis will PYTHON_RETURN_ERROR; } - return cyMisc::FindActivator(name); + return cyMisc::FindActivator(plString::FromUtf8(name)); } PYTHON_BASIC_GLOBAL_METHOD_DEFINITION(PtClearCameraStack, cyMisc::ClearCameraStack, "Clears the camera stack") diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue4.cpp b/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue4.cpp index b049face..3897bc3e 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue4.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue4.cpp @@ -141,23 +141,17 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtSetLightValue, args, "Params: key,name,r,g,b,a PYTHON_RETURN_ERROR; } pyKey* key = pyKey::ConvertFrom(keyObj); - std::string name = ""; + plString name; if (PyUnicode_Check(nameObj)) { - int strLen = PyUnicode_GetSize(nameObj); - wchar_t* text = TRACKED_NEW wchar_t[strLen + 1]; - PyUnicode_AsWideChar((PyUnicodeObject*)nameObj, text, strLen); - text[strLen] = L'\0'; - char* cText = hsWStringToString(text); - name = cText; - delete [] cText; - delete [] text; + PyObject* utf8 = PyUnicode_AsUTF8String(nameObj); + name = plString::FromUtf8(PyString_AsString(utf8)); + Py_DECREF(utf8); } else if (PyString_Check(nameObj)) { // we'll allow this, just in case something goes weird - char* text = PyString_AsString(nameObj); - name = text; + name = plString::FromUtf8(PyString_AsString(nameObj)); } else { @@ -184,23 +178,17 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtSetLightAnimStart, args, "Params: key,name,sta PYTHON_RETURN_ERROR; } pyKey* key = pyKey::ConvertFrom(keyObj); - std::string name = ""; + plString name; if (PyUnicode_Check(nameObj)) { - int strLen = PyUnicode_GetSize(nameObj); - wchar_t* text = TRACKED_NEW wchar_t[strLen + 1]; - PyUnicode_AsWideChar((PyUnicodeObject*)nameObj, text, strLen); - text[strLen] = L'\0'; - char* cText = hsWStringToString(text); - name = cText; - delete [] cText; - delete [] text; + PyObject* utf8 = PyUnicode_AsUTF8String(nameObj); + name = plString::FromUtf8(PyString_AsString(utf8)); + Py_DECREF(utf8); } else if (PyString_Check(nameObj)) { // we'll allow this, just in case something goes weird - char* text = PyString_AsString(nameObj); - name = text; + name = plString::FromUtf8(PyString_AsString(nameObj)); } else { @@ -363,7 +351,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtRebuildCameraStack, args, "Params: name,ageNam PyErr_SetString(PyExc_TypeError, "PtRebuildCameraStack expects two strings"); PYTHON_RETURN_ERROR; } - cyMisc::RebuildCameraStack(name, ageName); + cyMisc::RebuildCameraStack(plString::FromUtf8(name), ageName); PYTHON_RETURN_NONE; } diff --git a/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp b/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp index 9b0df979..360e05f6 100644 --- a/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp @@ -331,7 +331,6 @@ hsBool plPythonFileMod::fAtConvertTime = false; plPythonFileMod::plPythonFileMod() { fPythonFile = nil; - fModuleName = nil; fModule = nil; fLocalNotify= true; fIsFirstTimeEval = true; @@ -404,15 +403,15 @@ plPythonFileMod::~plPythonFileMod() } // then get rid of this module // NOTE: fModule shouldn't be made in the plugin, only at runtime - if ( fModuleName && fModule ) + if ( !fModuleName.IsNull() && fModule ) { //_PyModule_Clear(fModule); PyObject *m; PyObject *modules = PyImport_GetModuleDict(); - if( modules && (m = PyDict_GetItemString(modules, fModuleName)) && PyModule_Check(m)) + if( modules && (m = PyDict_GetItemString(modules, fModuleName.c_str())) && PyModule_Check(m)) { hsStatusMessageF("Module %s removed from python dictionary",fModuleName); - PyDict_DelItemString(modules, fModuleName); + PyDict_DelItemString(modules, fModuleName.c_str()); } else { @@ -422,8 +421,7 @@ plPythonFileMod::~plPythonFileMod() // we need to set our pointer to nil to make sure we don't try to use it fModule = nil; } - delete [] fModuleName; - fModuleName = nil; + fModuleName = plString::Null; } #include "plPythonPack.h" @@ -510,11 +508,8 @@ void plPythonFileMod::AddTarget(plSceneObject* sobj) { plKey pkey = sobj->GetKey(); // nope, must be the first object. Then use it as the basis for the module - char modulename[256]; - IMakeModuleName(modulename,sobj); - delete [] fModuleName; - fModuleName = StrDup(modulename); - fModule = PythonInterface::CreateModule(modulename); + fModuleName = IMakeModuleName(sobj); + fModule = PythonInterface::CreateModule(fModuleName.c_str()); // if we can't create the instance then there is nothing to do here if (!ILoadPythonCode()) @@ -634,17 +629,16 @@ void plPythonFileMod::AddTarget(plSceneObject* sobj) NamedComponent comp; comp.isActivator = (isNamedAttr == 1); comp.id = parameter.fID; - comp.name = TRACKED_NEW char[strlen(parameter.datarecord.fString) + 1]; - strcpy(comp.name, parameter.datarecord.fString); + comp.name = plString::FromUtf8(parameter.datarecord.fString); fNamedCompQueue.Append(comp); } else { if (isNamedAttr == 1) - IFindActivatorAndAdd(parameter.datarecord.fString, parameter.fID); + IFindActivatorAndAdd(plString::FromUtf8(parameter.datarecord.fString), parameter.fID); else - IFindResponderAndAdd(parameter.datarecord.fString, parameter.fID); + IFindResponderAndAdd(plString::FromUtf8(parameter.datarecord.fString), parameter.fID); } } } @@ -951,7 +945,7 @@ void plPythonFileMod::HandleDiscardedKey( plKeyEventMsg *msg ) // // NOTE: This modifier wasn't intended to have multiple targets // -void plPythonFileMod::IMakeModuleName(char* modulename,plSceneObject* sobj) +plString plPythonFileMod::IMakeModuleName(plSceneObject* sobj) { // Forgive my general crapulance... // This strips underscores out of module names @@ -960,13 +954,14 @@ void plPythonFileMod::IMakeModuleName(char* modulename,plSceneObject* sobj) plKey pKey = GetKey(); plKey sKey = sobj->GetKey(); - const char* pKeyName = pKey->GetName(); - const char* pSobjName = sKey->GetName(); + const char* pKeyName = pKey->GetName().c_str(); + const char* pSobjName = sKey->GetName().c_str(); - UInt16 len = hsStrlen(pKeyName); - UInt16 slen = hsStrlen(pSobjName); + UInt16 len = pKey->GetName().GetSize(); + UInt16 slen = sKey->GetName().GetSize(); hsAssert(len+slen < 256, "Warning: String length exceeds 256 characters."); + char modulename[256]; int i, k = 0; for(i = 0; i < slen; i++) @@ -983,6 +978,7 @@ void plPythonFileMod::IMakeModuleName(char* modulename,plSceneObject* sobj) } modulename[k] = '\0'; + plString name = plString::FromUtf8(modulename); // check to see if we are attaching to a clone? plKeyImp* pKeyImp = (plKeyImp*)(sKey); @@ -992,7 +988,7 @@ void plPythonFileMod::IMakeModuleName(char* modulename,plSceneObject* sobj) // add the cloneID to the end of the module name // and set the fIAmAClone flag UInt32 cloneID = pKeyImp->GetUoid().GetCloneID(); - sprintf(modulename,"%s%d",modulename,cloneID); + name += plString::Format("%d", cloneID); fAmIAttachedToClone = true; } @@ -1001,8 +997,10 @@ void plPythonFileMod::IMakeModuleName(char* modulename,plSceneObject* sobj) { // if not unique then add the sequence number to the end of the modulename UInt32 seqID = pKeyImp->GetUoid().GetLocation().GetSequenceNumber(); - sprintf(modulename,"%s%d",modulename,seqID); + name += plString::Format("%d", seqID); } + + return name; } ///////////////////////////////////////////////////////////////////////////// @@ -1047,9 +1045,9 @@ void plPythonFileMod::ISetKeyValue(const plKey& key, Int32 id) // PURPOSE : find a responder by name in all age and page locations // : and add to the Parameter list // -void plPythonFileMod::IFindResponderAndAdd(const char *responderName, Int32 id) +void plPythonFileMod::IFindResponderAndAdd(const plString &responderName, Int32 id) { - if ( responderName != nil ) + if ( !responderName.IsNull() ) { std::vector keylist; const plLocation &loc = GetKey()->GetUoid().GetLocation(); @@ -1075,9 +1073,9 @@ void plPythonFileMod::IFindResponderAndAdd(const char *responderName, Int32 id) // PURPOSE : find a responder by name in all age and page locations // : and add to the Parameter list // -void plPythonFileMod::IFindActivatorAndAdd(const char *activatorName, Int32 id) +void plPythonFileMod::IFindActivatorAndAdd(const plString &activatorName, Int32 id) { - if ( activatorName != nil ) + if ( !activatorName.IsNull() ) { std::vector keylist; const plLocation &loc = GetKey()->GetUoid().GetLocation(); @@ -1236,8 +1234,6 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg) IFindActivatorAndAdd(comp.name, comp.id); else IFindResponderAndAdd(comp.name, comp.id); - - delete [] comp.name; } fNamedCompQueue.Reset(); @@ -1756,9 +1752,9 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg) { // yes... // call it - char* roomname = ""; + const char* roomname = ""; if ( pRLNMsg->GetRoom() != nil ) - roomname = (char*)pRLNMsg->GetRoom()->GetName(); + roomname = pRLNMsg->GetRoom()->GetName().c_str(); plProfile_BeginTiming(PythonUpdate); PyObject* retVal = PyObject_CallMethod( @@ -2837,11 +2833,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg) // void plPythonFileMod::ReportError() { - char objectName[128]; - StrCopy(objectName, this->GetKeyName(), arrsize(objectName)); - StrPack(objectName, " - ", arrsize(objectName)); + plString objectName = this->GetKeyName(); + objectName += _TEMP_CONVERT_FROM_LITERAL(" - "); - PythonInterface::WriteToStdErr(objectName); + PythonInterface::WriteToStdErr(objectName.c_str()); PyErr_Print(); // make sure the error is printed PyErr_Clear(); // clear the error @@ -2984,4 +2979,4 @@ void plPythonFileMod::Write(hsStream* stream, hsResMgr* mgr) //// kGlobalNameKonstant ///////////////////////////////////////////////// // My continued attempt to spread the CORRECT way to spell konstant. -mcn -char plPythonFileMod::kGlobalNameKonstant[] = "VeryVerySpecialPythonFileMod"; +plString plPythonFileMod::kGlobalNameKonstant = _TEMP_CONVERT_FROM_LITERAL("VeryVerySpecialPythonFileMod"); diff --git a/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.h b/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.h index e4ee6fa9..7a0a36a5 100644 --- a/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.h +++ b/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.h @@ -74,10 +74,10 @@ protected: hsBool IEval(double secs, hsScalar del, UInt32 dirty); - void IMakeModuleName(char* modulename,plSceneObject* sobj); + plString IMakeModuleName(plSceneObject* sobj); char* fPythonFile; - char* fModuleName; + plString fModuleName; // the list of receivers that want to be notified hsTArray fReceivers; @@ -104,15 +104,15 @@ protected: struct NamedComponent { - char* name; - Int32 id; - bool isActivator; + plString name; + Int32 id; + bool isActivator; }; hsTArray fNamedCompQueue; - virtual void IFindResponderAndAdd(const char *responderName, Int32 id); - virtual void IFindActivatorAndAdd(const char *activatorName, Int32 id); + virtual void IFindResponderAndAdd(const plString &responderName, Int32 id); + virtual void IFindActivatorAndAdd(const plString &activatorName, Int32 id); void ISetKeyValue(const plKey& key, Int32 id); bool ILoadPythonCode(); @@ -210,7 +210,7 @@ public: static const char* fFunctionNames[]; // The konstant hard-coded name to be used for all global pythonFileMods - static char kGlobalNameKonstant[]; + static plString kGlobalNameKonstant; // API for processing discarded keys as the deafult key catcher void HandleDiscardedKey( plKeyEventMsg *msg ); diff --git a/Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp b/Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp index f6a7ed07..d814b0c8 100644 --- a/Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp @@ -605,7 +605,7 @@ const plPythonSDLModifier* plPythonSDLModifier::FindAgeSDL() return sdlMod; plNetClientApp::StaticErrorMsg("pfmod %s has a nil python SDL modifier for age sdl %s", - pfmod->GetKeyName() ? pfmod->GetKeyName() : "?", ageName); + pfmod->GetKeyName().s_str("?"), ageName); } else { @@ -614,11 +614,11 @@ const plPythonSDLModifier* plPythonSDLModifier::FindAgeSDL() else if (!key->ObjectIsLoaded()) plNetClientApp::StaticErrorMsg("key %s not loaded for age sdl %s", - key->GetName() ? key->GetName() : "?", ageName); + key->GetName().s_str("?"), ageName); else if (!plPythonFileMod::ConvertNoRef(key->ObjectIsLoaded())) plNetClientApp::StaticErrorMsg("key %s is not a python file mod for age sdl %s", - key->GetName() ? key->GetName() : "?", ageName); + key->GetName().s_str("?"), ageName); } } else diff --git a/Sources/Plasma/FeatureLib/pfPython/pyImage.cpp b/Sources/Plasma/FeatureLib/pfPython/pyImage.cpp index 762f7d24..e78dab5d 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyImage.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyImage.cpp @@ -200,7 +200,7 @@ PyObject* pyImage::LoadJPEGFromDisk(const wchar* filename, UInt16 width, UInt16 } // let's create a nice name for this thing based on the filename - std::string name = "PtImageFromDisk_"; + plString name = _TEMP_CONVERT_FROM_LITERAL("PtImageFromDisk_"); const wchar* i = filename; int charsChecked = 0; @@ -219,10 +219,9 @@ PyObject* pyImage::LoadJPEGFromDisk(const wchar* filename, UInt16 width, UInt16 i++; } - char* cName = hsWStringToString(i); - name = name + cName; + name += plString::FromWchar(i); - hsgResMgr::ResMgr()->NewKey(name.c_str(), theMipmap, plLocation::kGlobalFixedLoc); + hsgResMgr::ResMgr()->NewKey(name, theMipmap, plLocation::kGlobalFixedLoc); return pyImage::New( theMipmap ); } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyJournalBook.cpp b/Sources/Plasma/FeatureLib/pfPython/pyJournalBook.cpp index 874e6e6e..d526ba6b 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyJournalBook.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyJournalBook.cpp @@ -58,8 +58,7 @@ UInt32 pyJournalBook::fNextKeyID = 0; void pyJournalBook::IMakeNewKey( void ) { - char name[ 128 ]; - sprintf( name, "pyJournalBook-%d", fNextKeyID++ ); + plString name = plString::Format( "pyJournalBook-%d", fNextKeyID++ ); hsgResMgr::ResMgr()->NewKey( name, fBook, plLocation::kGlobalFixedLoc ); fBook->GetKey()->RefObject(); @@ -96,14 +95,14 @@ pyJournalBook::pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, py IMakeNewKey(); } -pyJournalBook::pyJournalBook( const char *esHTMLSource, pyImage &coverImage, pyKey callbackKey, const char *guiName ) +pyJournalBook::pyJournalBook( const char *esHTMLSource, pyImage &coverImage, pyKey callbackKey, const plString &guiName ) { fBook = TRACKED_NEW pfJournalBook( esHTMLSource, coverImage.GetKey(), callbackKey.getKey(), callbackKey.getKey() != nil ? callbackKey.getKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc, guiName ); IMakeNewKey(); } -pyJournalBook::pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, pyKey callbackKey, const char *guiName ) +pyJournalBook::pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, pyKey callbackKey, const plString &guiName ) { fBook = TRACKED_NEW pfJournalBook( esHTMLSource.c_str(), coverImage.GetKey(), callbackKey.getKey(), callbackKey.getKey() != nil ? callbackKey.getKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc, guiName ); @@ -135,7 +134,7 @@ pyJournalBook::~pyJournalBook() } } -void pyJournalBook::MakeBook(std::string esHTMLSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, std::string guiName /* = "" */) +void pyJournalBook::MakeBook(std::string esHTMLSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, plString guiName /* = "" */) { if (fBook) fBook->GetKey()->UnRefObject(); @@ -144,11 +143,11 @@ void pyJournalBook::MakeBook(std::string esHTMLSource, plKey coverImageKey /* = if (callbackKey != nil) loc = callbackKey->GetUoid().GetLocation(); - fBook = TRACKED_NEW pfJournalBook(esHTMLSource.c_str(), coverImageKey, callbackKey, loc, guiName.c_str()); + fBook = TRACKED_NEW pfJournalBook(esHTMLSource.c_str(), coverImageKey, callbackKey, loc, guiName); IMakeNewKey(); } -void pyJournalBook::MakeBook(std::wstring esHTMLSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, std::string guiName /* = "" */) +void pyJournalBook::MakeBook(std::wstring esHTMLSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, plString guiName /* = "" */) { if (fBook) fBook->GetKey()->UnRefObject(); @@ -157,7 +156,7 @@ void pyJournalBook::MakeBook(std::wstring esHTMLSource, plKey coverImageKey /* = if (callbackKey != nil) loc = callbackKey->GetUoid().GetLocation(); - fBook = TRACKED_NEW pfJournalBook(esHTMLSource.c_str(), coverImageKey, callbackKey, loc, guiName.c_str()); + fBook = TRACKED_NEW pfJournalBook(esHTMLSource.c_str(), coverImageKey, callbackKey, loc, guiName); IMakeNewKey(); } @@ -235,18 +234,18 @@ void pyJournalBook::AllowPageTurning( bool allow ) fBook->AllowPageTurning(allow); } -void pyJournalBook::SetGUI( const char *guiName ) +void pyJournalBook::SetGUI( const plString &guiName ) { if (fBook != nil) fBook->SetGUI(guiName); } -void pyJournalBook::LoadGUI( const char *guiName ) +void pyJournalBook::LoadGUI( const plString &guiName ) { pfJournalBook::LoadGUI(guiName); } -void pyJournalBook::UnloadGUI( const char *guiName ) +void pyJournalBook::UnloadGUI( const plString &guiName ) { pfJournalBook::UnloadGUI(guiName); } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyJournalBook.h b/Sources/Plasma/FeatureLib/pfPython/pyJournalBook.h index ec764873..0ae43332 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyJournalBook.h +++ b/Sources/Plasma/FeatureLib/pfPython/pyJournalBook.h @@ -78,8 +78,8 @@ protected: pyJournalBook( std::wstring esHTMLSource, pyKey callbackKey ); pyJournalBook( const char *esHTMLSource, pyImage &coverImage, pyKey callbackKey ); pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, pyKey callbackKey ); - pyJournalBook( const char *esHTMLSource, pyImage &coverImage, pyKey callbackKey, const char *guiName ); - pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, pyKey callbackKey, const char *guiName ); + pyJournalBook( const char *esHTMLSource, pyImage &coverImage, pyKey callbackKey, const plString &guiName ); + pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, pyKey callbackKey, const plString &guiName ); public: virtual ~pyJournalBook(); @@ -88,8 +88,8 @@ public: // required functions for PyObject interoperability PYTHON_CLASS_NEW_FRIEND(ptBook); - static PyObject *New(std::string htmlSource, plKey coverImageKey = nil, plKey callbackKey = nil, std::string guiName = ""); - static PyObject *New(std::wstring htmlSource, plKey coverImageKey = nil, plKey callbackKey = nil, std::string guiName = ""); + static PyObject *New(std::string htmlSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = _TEMP_CONVERT_FROM_LITERAL("")); + static PyObject *New(std::wstring htmlSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = _TEMP_CONVERT_FROM_LITERAL("")); PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyJournalBook object PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyJournalBook); // converts a PyObject to a pyJournalBook (throws error if not correct type) @@ -98,8 +98,8 @@ public: static void AddPlasmaConstantsClasses(PyObject *m); // Deletes the existing book and re-creates it, for use by the python glue - void MakeBook(std::string esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, std::string guiName = ""); - void MakeBook(std::wstring esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, std::string guiName = ""); + void MakeBook(std::string esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = _TEMP_CONVERT_FROM_LITERAL("")); + void MakeBook(std::wstring esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = _TEMP_CONVERT_FROM_LITERAL("")); // Interface functions per book virtual void Show( hsBool startOpened ); @@ -117,10 +117,10 @@ public: virtual void SetSize( hsScalar width, hsScalar height ); - virtual void SetGUI( const char *guiName ); + virtual void SetGUI( const plString &guiName ); - static void LoadGUI( const char *guiName ); - static void UnloadGUI( const char *guiName ); + static void LoadGUI( const plString &guiName ); + static void UnloadGUI( const plString &guiName ); static void UnloadAllGUIs(); virtual PyObject *GetMovie( UInt8 index ); // returns cyAnimation diff --git a/Sources/Plasma/FeatureLib/pfPython/pyJournalBookGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyJournalBookGlue.cpp index f778c203..03c058cd 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyJournalBookGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyJournalBookGlue.cpp @@ -101,9 +101,9 @@ PYTHON_INIT_DEFINITION(ptBook, args, keywords) callbackKey = pyKey::ConvertFrom(callbackObj)->getKey(); } - std::string guiNameStr = ""; + plString guiNameStr; if (guiName) - guiNameStr = guiName; + guiNameStr = plString::FromUtf8(guiName); // convert the sourcecode object if (PyUnicode_Check(sourceObj)) @@ -225,7 +225,7 @@ PYTHON_METHOD_DEFINITION(ptBook, setGUI, args) PyErr_SetString(PyExc_TypeError, "setGUI expects a string"); PYTHON_RETURN_ERROR; } - self->fThis->SetGUI(guiName); + self->fThis->SetGUI(plString::FromUtf8(guiName)); PYTHON_RETURN_NONE; } @@ -293,14 +293,14 @@ PYTHON_END_METHODS_TABLE; PLASMA_DEFAULT_TYPE(ptBook, "Params: esHTMLSource,coverImage=None,callbackKey=None,guiName=''\nCreates a new book"); // required functions for PyObject interoperability -PyObject *pyJournalBook::New(std::string htmlSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, std::string guiName /* = "" */) +PyObject *pyJournalBook::New(std::string htmlSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, plString guiName /* = "" */) { ptBook *newObj = (ptBook*)ptBook_type.tp_new(&ptBook_type, NULL, NULL); newObj->fThis->MakeBook(htmlSource, coverImageKey, callbackKey, guiName); return (PyObject*)newObj; } -PyObject *pyJournalBook::New(std::wstring htmlSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, std::string guiName /* = "" */) +PyObject *pyJournalBook::New(std::wstring htmlSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, plString guiName /* = "" */) { ptBook *newObj = (ptBook*)ptBook_type.tp_new(&ptBook_type, NULL, NULL); newObj->fThis->MakeBook(htmlSource, coverImageKey, callbackKey, guiName); @@ -329,7 +329,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtLoadBookGUI, args, "Params: guiName\nLoads the PyErr_SetString(PyExc_TypeError, "PtLoadBookGUI expects a string"); PYTHON_RETURN_ERROR; } - pyJournalBook::LoadGUI(guiName); + pyJournalBook::LoadGUI(plString::FromUtf8(guiName)); PYTHON_RETURN_NONE; } @@ -341,7 +341,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtUnloadBookGUI, args, "Params: guiName\nUnloads PyErr_SetString(PyExc_TypeError, "PtUnloadBookGUI expects a string"); PYTHON_RETURN_ERROR; } - pyJournalBook::UnloadGUI(guiName); + pyJournalBook::UnloadGUI(plString::FromUtf8(guiName)); PYTHON_RETURN_NONE; } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyKey.h b/Sources/Plasma/FeatureLib/pfPython/pyKey.h index 1dc05e89..3e84e7e4 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyKey.h +++ b/Sources/Plasma/FeatureLib/pfPython/pyKey.h @@ -52,6 +52,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include "pyGlueHelpers.h" +#include "plString.h" class plPythonFileMod; class pySceneObject; @@ -98,7 +99,7 @@ public: // getter and setters virtual plKey getKey() { return fKey; } virtual void setKey(plKey key) { fKey=key; } - virtual const char* getName() const { return fKey ? fKey->GetName() : "nil"; } + virtual const char* getName() const { return fKey ? fKey->GetName().c_str() : "nil"; } #ifndef BUILDING_PYPLASMA PyObject* GetPySceneObject(); diff --git a/Sources/Plasma/FeatureLib/pfPython/pySceneObject.cpp b/Sources/Plasma/FeatureLib/pfPython/pySceneObject.cpp index 9035ac64..7f3acac9 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pySceneObject.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pySceneObject.cpp @@ -210,21 +210,21 @@ void pySceneObject::SetNetForce(hsBool state) } -const char* pySceneObject::GetName() +plString pySceneObject::GetName() { if ( fSceneObjects.Count() > 0 ) return fSceneObjects[0]->GetName(); - return ""; + return _TEMP_CONVERT_FROM_LITERAL(""); } -PyObject* pySceneObject::findObj(const char* name) +PyObject* pySceneObject::findObj(const plString& name) { PyObject* pSobj = nil; // search through the plKeys that we have looking for this name int i; for ( i=0; iGetName()) ) + if ( name == fSceneObjects[i]->GetName() ) { pSobj = pySceneObject::New(fSceneObjects[i],fPyMod); break; @@ -235,7 +235,7 @@ PyObject* pySceneObject::findObj(const char* name) if ( pSobj == nil ) { // throw a Python error, so the coder knows it didn't work - PyErr_SetString(PyExc_KeyError, name); + PyErr_SetString(PyExc_KeyError, name.c_str()); } return pSobj; diff --git a/Sources/Plasma/FeatureLib/pfPython/pySceneObject.h b/Sources/Plasma/FeatureLib/pfPython/pySceneObject.h index 84da856f..8bbe0760 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pySceneObject.h +++ b/Sources/Plasma/FeatureLib/pfPython/pySceneObject.h @@ -114,9 +114,9 @@ public: virtual void SetNetForce(hsBool state); - virtual PyObject* findObj(const char* name); // pySceneObject + virtual PyObject* findObj(const plString& name); // pySceneObject - virtual const char* GetName(); + virtual plString GetName(); virtual std::vector GetResponders(); // pyKey list virtual std::vector GetPythonMods(); // pyKey list // diff --git a/Sources/Plasma/FeatureLib/pfPython/pySceneObjectGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pySceneObjectGlue.cpp index df699948..61a9fab4 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pySceneObjectGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pySceneObjectGlue.cpp @@ -151,12 +151,12 @@ PYTHON_METHOD_DEFINITION(ptSceneobject, findObject, args) PyErr_SetString(PyExc_TypeError, "findObject expects a string"); PYTHON_RETURN_ERROR; } - return self->fThis->findObj(name); + return self->fThis->findObj(plString::FromUtf8(name)); } PYTHON_METHOD_DEFINITION_NOARGS(ptSceneobject, getName) { - return PyString_FromString(self->fThis->GetName()); + return PyString_FromString(self->fThis->GetName().c_str()); } PYTHON_METHOD_DEFINITION_NOARGS(ptSceneobject, getResponders) diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultImageNode.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultImageNode.cpp index a7c9e325..44a5cb44 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultImageNode.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultImageNode.cpp @@ -64,8 +64,7 @@ static unsigned s_keyseq; //============================================================================ static plKey CreateAndRefImageKey (unsigned nodeId, plMipmap * mipmap) { - char keyName[MAX_PATH]; - StrPrintf(keyName, arrsize(keyName), "VaultImg_%u_%u", nodeId, s_keyseq++); + plString keyName = plString::Format("VaultImg_%u_%u", nodeId, s_keyseq++); plKey key = hsgResMgr::ResMgr()->NewKey(keyName, mipmap, plLocation::kGlobalFixedLoc); diff --git a/Sources/Plasma/FeatureLib/pfSurface/plLayerMovie.cpp b/Sources/Plasma/FeatureLib/pfSurface/plLayerMovie.cpp index 05af21f2..9f88a822 100644 --- a/Sources/Plasma/FeatureLib/pfSurface/plLayerMovie.cpp +++ b/Sources/Plasma/FeatureLib/pfSurface/plLayerMovie.cpp @@ -115,8 +115,7 @@ hsBool plLayerMovie::ISetupBitmap() memset(b->GetImage(), 0x10, b->GetHeight() * b->GetRowBytes() ); b->SetFlags( b->GetFlags() | plMipmap::kDontThrowAwayImage ); - char name[ 256 ]; - sprintf( name, "%s_BMap", fMovieName ); + plString name = plString::Format( "%s_BMap", fMovieName ); hsgResMgr::ResMgr()->NewKey( name, b, plLocation::kGlobalFixedLoc ); *fTexture = (plBitmap *)b; diff --git a/Sources/Plasma/NucleusLib/inc/hsResMgr.h b/Sources/Plasma/NucleusLib/inc/hsResMgr.h index 5bf3cd38..9df9dfc4 100644 --- a/Sources/Plasma/NucleusLib/inc/hsResMgr.h +++ b/Sources/Plasma/NucleusLib/inc/hsResMgr.h @@ -105,7 +105,7 @@ public: //--------------------------- // Registry Modification Functions //--------------------------- - virtual plKey NewKey(const char* name, hsKeyedObject* object, const plLocation& loc, const plLoadMask& m = plLoadMask::kAlways)=0; + virtual plKey NewKey(const plString& name, hsKeyedObject* object, const plLocation& loc, const plLoadMask& m = plLoadMask::kAlways)=0; virtual plKey NewKey(plUoid& newUoid, hsKeyedObject* object)=0; virtual plDispatchBase* Dispatch()=0; @@ -118,7 +118,7 @@ protected: friend class plKeyImp; friend class plArmatureMod; // Temp hack until a findkey/clone issue is fixed. -Bob - virtual plKey ReRegister(const char *nm, const plUoid& oid)=0; + virtual plKey ReRegister(const plString& nm, const plUoid& oid)=0; virtual hsBool ReadObject(plKeyImp* key)=0; // plKeys call this when needed // Sets a key as used or unused in the registry. When all keys in a page of a diff --git a/Sources/Plasma/NucleusLib/pnDispatch/plDispatch.cpp b/Sources/Plasma/NucleusLib/pnDispatch/plDispatch.cpp index 78814c0d..d064d850 100644 --- a/Sources/Plasma/NucleusLib/pnDispatch/plDispatch.cpp +++ b/Sources/Plasma/NucleusLib/pnDispatch/plDispatch.cpp @@ -341,7 +341,7 @@ void plDispatch::IMsgDispatch() UInt32 rcvTicks = hsTimer::GetPrecTickCount(); // Object could be deleted by this message, so we need to log this stuff now - const char* keyname = "(unknown)"; + plString keyname = _TEMP_CONVERT_FROM_LITERAL("(unknown)"); const char* className = "(unknown)"; UInt32 clonePlayerID = 0; if (plDispatchLogBase::IsLoggingLong()) @@ -373,7 +373,7 @@ void plDispatch::IMsgDispatch() float rcvTime = (float)(hsTimer::PrecTicksToSecs(rcvTicks) * 1000.f); // If the receiver takes more than 5 ms to process its message, log it if (rcvTime > 5.f) - plDispatchLogBase::GetInstance()->LogLongReceive(keyname, className, clonePlayerID, msg, rcvTime); + plDispatchLogBase::GetInstance()->LogLongReceive(keyname.c_str(), className, clonePlayerID, msg, rcvTime); } #endif // PLASMA_EXTERNAL_RELEASE diff --git a/Sources/Plasma/NucleusLib/pnKeyedObject/hsKeyedObject.cpp b/Sources/Plasma/NucleusLib/pnKeyedObject/hsKeyedObject.cpp index 233baa92..3c7b10d3 100644 --- a/Sources/Plasma/NucleusLib/pnKeyedObject/hsKeyedObject.cpp +++ b/Sources/Plasma/NucleusLib/pnKeyedObject/hsKeyedObject.cpp @@ -65,12 +65,12 @@ hsBool hsKeyedObject::SendRef(plRefMsg* refMsg, plRefFlags::Type flags) return hsgResMgr::SendRef(key, refMsg, flags); } -const char* hsKeyedObject::GetKeyName() const +plString hsKeyedObject::GetKeyName() const { if (fpKey) return fpKey->GetName(); else - return "(unknown)"; + return _TEMP_CONVERT_FROM_LITERAL("(unknown)"); } hsKeyedObject::~hsKeyedObject() @@ -123,7 +123,7 @@ void hsKeyedObject::UnRegisterAs(plFixedKeyId fixedKey) UnRegisterAsManual(uoid); } -plKey hsKeyedObject::RegisterAsManual(plUoid& meUoid, const char* p) +plKey hsKeyedObject::RegisterAsManual(plUoid& meUoid, const plString& p) { hsAssert(meUoid.GetClassType() == ClassIndex(),"Registering as wrong type!"); // Really should be a NewKey() call just for fixed keys, so change this once player rooms behave diff --git a/Sources/Plasma/NucleusLib/pnKeyedObject/hsKeyedObject.h b/Sources/Plasma/NucleusLib/pnKeyedObject/hsKeyedObject.h index b6e04440..2efd15b5 100644 --- a/Sources/Plasma/NucleusLib/pnKeyedObject/hsKeyedObject.h +++ b/Sources/Plasma/NucleusLib/pnKeyedObject/hsKeyedObject.h @@ -62,7 +62,7 @@ public: GETINTERFACE_ANY(hsKeyedObject, plReceiver); const plKey& GetKey() const { return fpKey; } - const char* GetKeyName() const; + plString GetKeyName() const; virtual void Validate(); virtual hsBool IsFinal() { return true; }; // experimental; currently "is ready to process Loads" @@ -85,7 +85,7 @@ public: void UnRegisterAs(plFixedKeyId fixedKey); // used when manually loading the player room - plKey RegisterAsManual(plUoid& uoid, const char* p); + plKey RegisterAsManual(plUoid& uoid, const plString& p); void UnRegisterAsManual(plUoid& uoid); // If you want clone keys to share a type of object, override this function for it. diff --git a/Sources/Plasma/NucleusLib/pnKeyedObject/plFixedKey.cpp b/Sources/Plasma/NucleusLib/pnKeyedObject/plFixedKey.cpp index ab4c1b42..4866da6f 100644 --- a/Sources/Plasma/NucleusLib/pnKeyedObject/plFixedKey.cpp +++ b/Sources/Plasma/NucleusLib/pnKeyedObject/plFixedKey.cpp @@ -64,11 +64,11 @@ struct plKeySeed // NOTE: The following fields are broken out to make adding to the fixed key list easier. // However, what they really are, are just the fields of plUoid (including plLocation) UInt16 fType; - const char *fObj; + plString fObj; hsBool Match( plKeySeed *p ) { - if( ( fType == p->fType ) && stricmp( p->fObj, fObj ) == 0 ) + if( ( fType == p->fType ) && p->fObj.Compare( fObj, plString::kCaseInsensitive ) == 0 ) { return true; } @@ -82,48 +82,50 @@ struct plKeySeed // 2) Be sure your ClassIndex CLASS_INDEX(plSceneObject) matches the type of object you want to have the fixedKey // 3) Make sure the Obj is unique for this location/Type Combo... (validated at runtime) +#define _TCFL _TEMP_CONVERT_FROM_LITERAL plKeySeed SeedList[] = { // Key Enum Type Obj - { kFirst_Fixed_KEY, CLASS_INDEX_SCOPED( plSceneObject ), "kFirst_Fixed_KEY" }, - - { kLOSObject_KEY, CLASS_INDEX_SCOPED( plLOSDispatch ), "kLOSObject_KEY", }, - { kTimerCallbackManager_KEY, CLASS_INDEX_SCOPED( plTimerCallbackManager ), "kTimerCallbackManager_KEY", }, - { kConsoleObject_KEY, CLASS_INDEX_SCOPED( pfConsole ), "kConsoleObject_KEY", }, - { kAudioSystem_KEY, CLASS_INDEX_SCOPED( plAudioSystem ), "kAudioSystem_KEY", }, - { kInput_KEY, CLASS_INDEX_SCOPED( plInputManager ), "kInput_KEY", }, - { kClient_KEY, CLASS_INDEX_SCOPED( plClient ), "kClient_KEY", }, - { kNetClientMgr_KEY, CLASS_INDEX_SCOPED( plNetClientMgr ), "kNetClientMgr_KEY", }, - { kListenerMod_KEY, CLASS_INDEX_SCOPED( plListener ), "kListenerMod_KEY", }, - { kTransitionMgr_KEY, CLASS_INDEX_SCOPED( plTransitionMgr ), "kTransitionMgr_KEY", }, - { kLinkEffectsMgr_KEY, CLASS_INDEX_SCOPED( plLinkEffectsMgr ), "kLinkEffectsMgr_KEY", }, - { kGameGUIMgr_KEY, CLASS_INDEX_SCOPED( pfGameGUIMgr ), "kGameGUIMgr_KEY", }, - { kGameGUIDynamicDlg_KEY, CLASS_INDEX_SCOPED( plSceneNode ), "kGameGUIDynamicDlg_KEY", }, - { kVirtualCamera1_KEY, CLASS_INDEX_SCOPED( plVirtualCam1 ), "kVirtualCamera_KEY", }, - { kDefaultCameraMod1_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), "kDefaultCameraMod1_KEY", }, - { kKIGUIGlue_KEY, CLASS_INDEX_SCOPED( pfKI ), "kKIGUIGlue_KEY", }, - { kClothingMgr_KEY, CLASS_INDEX_SCOPED( plClothingMgr ), "kClothingMgr_KEY", }, - { kInputInterfaceMgr_KEY, CLASS_INDEX_SCOPED( plInputInterfaceMgr ), "kInputInterfaceMgr_KEY", }, - { kAVIWriter_KEY, CLASS_INDEX_SCOPED( plAVIWriter ), "kAVIWriter_KEY", }, - { kResManagerHelper_KEY, CLASS_INDEX_SCOPED( plResManagerHelper ), "kResManagerHelper_KEY", }, - { kAvatarMgr_KEY, CLASS_INDEX_SCOPED( plAvatarMgr ), "kAvatarMgr_KEY", }, - { kSimulationMgr_KEY, CLASS_INDEX_SCOPED( plSimulationMgr ), "kSimulationMgr_KEY", }, - { kTransitionCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), "kTransitionCamera_KEY", }, - { kCCRMgr_KEY, CLASS_INDEX_SCOPED( plCCRMgr ), "kCCRMgr_KEY", }, - { kNetClientCloneRoom_KEY, CLASS_INDEX_SCOPED( plSceneNode ), "kNetClientCloneRoom_KEY", }, - { kMarkerMgr_KEY, CLASS_INDEX_SCOPED( pfMarkerMgr ), "kMarkerMgr_KEY", }, - { kAutoProfile_KEY, CLASS_INDEX_SCOPED( plAutoProfile ), "kAutoProfile_KEY", }, - { kGlobalVisMgr_KEY, CLASS_INDEX_SCOPED( plVisMgr ), "kGlobalVisMgr_KEY", }, - { kFontCache_KEY, CLASS_INDEX_SCOPED( plFontCache ), "kFontCache_KEY", }, - { kRelevanceMgr_KEY, CLASS_INDEX_SCOPED( plRelevanceMgr ), "kRelevanceMgr_KEY", }, - { kJournalBookMgr_KEY, CLASS_INDEX_SCOPED( pfJournalBook ), "kJournalBookMgr_KEY" }, - { kAgeLoader_KEY, CLASS_INDEX_SCOPED( plAgeLoader), "kAgeLoader_KEY" }, - { kBuiltIn3rdPersonCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), "kBuiltIn3rdPersonCamera_KEY", }, - { kSecurePreloader_KEY, CLASS_INDEX_SCOPED( pfSecurePreloader ), "kSecurePreloader_KEY", }, + { kFirst_Fixed_KEY, CLASS_INDEX_SCOPED( plSceneObject ), _TCFL("kFirst_Fixed_KEY") }, + + { kLOSObject_KEY, CLASS_INDEX_SCOPED( plLOSDispatch ), _TCFL("kLOSObject_KEY"), }, + { kTimerCallbackManager_KEY, CLASS_INDEX_SCOPED( plTimerCallbackManager ), _TCFL("kTimerCallbackManager_KEY"), }, + { kConsoleObject_KEY, CLASS_INDEX_SCOPED( pfConsole ), _TCFL("kConsoleObject_KEY"), }, + { kAudioSystem_KEY, CLASS_INDEX_SCOPED( plAudioSystem ), _TCFL("kAudioSystem_KEY"), }, + { kInput_KEY, CLASS_INDEX_SCOPED( plInputManager ), _TCFL("kInput_KEY"), }, + { kClient_KEY, CLASS_INDEX_SCOPED( plClient ), _TCFL("kClient_KEY"), }, + { kNetClientMgr_KEY, CLASS_INDEX_SCOPED( plNetClientMgr ), _TCFL("kNetClientMgr_KEY"), }, + { kListenerMod_KEY, CLASS_INDEX_SCOPED( plListener ), _TCFL("kListenerMod_KEY"), }, + { kTransitionMgr_KEY, CLASS_INDEX_SCOPED( plTransitionMgr ), _TCFL("kTransitionMgr_KEY"), }, + { kLinkEffectsMgr_KEY, CLASS_INDEX_SCOPED( plLinkEffectsMgr ), _TCFL("kLinkEffectsMgr_KEY"), }, + { kGameGUIMgr_KEY, CLASS_INDEX_SCOPED( pfGameGUIMgr ), _TCFL("kGameGUIMgr_KEY"), }, + { kGameGUIDynamicDlg_KEY, CLASS_INDEX_SCOPED( plSceneNode ), _TCFL("kGameGUIDynamicDlg_KEY"), }, + { kVirtualCamera1_KEY, CLASS_INDEX_SCOPED( plVirtualCam1 ), _TCFL("kVirtualCamera_KEY"), }, + { kDefaultCameraMod1_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), _TCFL("kDefaultCameraMod1_KEY"), }, + { kKIGUIGlue_KEY, CLASS_INDEX_SCOPED( pfKI ), _TCFL("kKIGUIGlue_KEY"), }, + { kClothingMgr_KEY, CLASS_INDEX_SCOPED( plClothingMgr ), _TCFL("kClothingMgr_KEY"), }, + { kInputInterfaceMgr_KEY, CLASS_INDEX_SCOPED( plInputInterfaceMgr ), _TCFL("kInputInterfaceMgr_KEY"), }, + { kAVIWriter_KEY, CLASS_INDEX_SCOPED( plAVIWriter ), _TCFL("kAVIWriter_KEY"), }, + { kResManagerHelper_KEY, CLASS_INDEX_SCOPED( plResManagerHelper ), _TCFL("kResManagerHelper_KEY"), }, + { kAvatarMgr_KEY, CLASS_INDEX_SCOPED( plAvatarMgr ), _TCFL("kAvatarMgr_KEY"), }, + { kSimulationMgr_KEY, CLASS_INDEX_SCOPED( plSimulationMgr ), _TCFL("kSimulationMgr_KEY"), }, + { kTransitionCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), _TCFL("kTransitionCamera_KEY"), }, + { kCCRMgr_KEY, CLASS_INDEX_SCOPED( plCCRMgr ), _TCFL("kCCRMgr_KEY"), }, + { kNetClientCloneRoom_KEY, CLASS_INDEX_SCOPED( plSceneNode ), _TCFL("kNetClientCloneRoom_KEY"), }, + { kMarkerMgr_KEY, CLASS_INDEX_SCOPED( pfMarkerMgr ), _TCFL("kMarkerMgr_KEY"), }, + { kAutoProfile_KEY, CLASS_INDEX_SCOPED( plAutoProfile ), _TCFL("kAutoProfile_KEY"), }, + { kGlobalVisMgr_KEY, CLASS_INDEX_SCOPED( plVisMgr ), _TCFL("kGlobalVisMgr_KEY"), }, + { kFontCache_KEY, CLASS_INDEX_SCOPED( plFontCache ), _TCFL("kFontCache_KEY"), }, + { kRelevanceMgr_KEY, CLASS_INDEX_SCOPED( plRelevanceMgr ), _TCFL("kRelevanceMgr_KEY"), }, + { kJournalBookMgr_KEY, CLASS_INDEX_SCOPED( pfJournalBook ), _TCFL("kJournalBookMgr_KEY") }, + { kAgeLoader_KEY, CLASS_INDEX_SCOPED( plAgeLoader), _TCFL("kAgeLoader_KEY") }, + { kBuiltIn3rdPersonCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), _TCFL("kBuiltIn3rdPersonCamera_KEY"), }, + { kSecurePreloader_KEY, CLASS_INDEX_SCOPED( pfSecurePreloader ), _TCFL("kSecurePreloader_KEY"), }, - { kLast_Fixed_KEY, CLASS_INDEX_SCOPED( plSceneObject ), "kLast_Fixed_KEY", } + { kLast_Fixed_KEY, CLASS_INDEX_SCOPED( plSceneObject ), _TCFL("kLast_Fixed_KEY"), } }; +#undef _TCFL //// plFixedKeyValidator ///////////////////////////////////////////////////// @@ -166,14 +168,13 @@ plUoid::plUoid(plFixedKeyId fixedkey) { hsAssert(fixedkey < kLast_Fixed_KEY, "Request for Fixed key is out of Range"); - fObjectName = nil; Invalidate(); plKeySeed* p= &SeedList[fixedkey]; fLocation = plLocation::kGlobalFixedLoc; fClassType = p->fType; - fObjectName = hsStrcpy(p->fObj); + fObjectName = p->fObj; fObjectID = 0; fCloneID = 0; fClonePlayerID = 0; diff --git a/Sources/Plasma/NucleusLib/pnKeyedObject/plKey.h b/Sources/Plasma/NucleusLib/pnKeyedObject/plKey.h index 9207e0e2..f740db09 100644 --- a/Sources/Plasma/NucleusLib/pnKeyedObject/plKey.h +++ b/Sources/Plasma/NucleusLib/pnKeyedObject/plKey.h @@ -55,6 +55,7 @@ class hsBitVector; class plKeyData; class plKeyImp; +class plString; class plKey { @@ -96,7 +97,7 @@ class plKeyData { public: virtual const plUoid& GetUoid() const=0; - virtual const char* GetName() const=0; + virtual const plString& GetName() const=0; virtual hsKeyedObject* GetObjectPtr()=0; virtual hsKeyedObject* ObjectIsLoaded() const=0; diff --git a/Sources/Plasma/NucleusLib/pnKeyedObject/plKeyImp.cpp b/Sources/Plasma/NucleusLib/pnKeyedObject/plKeyImp.cpp index 40b0bf14..80bc6555 100644 --- a/Sources/Plasma/NucleusLib/pnKeyedObject/plKeyImp.cpp +++ b/Sources/Plasma/NucleusLib/pnKeyedObject/plKeyImp.cpp @@ -55,8 +55,8 @@ plProfile_CreateMemCounter("Keys", "Memory", KeyMem); static UInt32 CalcKeySize(plKeyImp* key) { UInt32 nameLen = 0; - if (key->GetUoid().GetObjectName()) - nameLen = strlen(key->GetUoid().GetObjectName()) + 1; + if (!key->GetUoid().GetObjectName().IsNull()) + nameLen = key->GetUoid().GetObjectName().GetSize() + 1; return sizeof(plKeyImp) + nameLen; } @@ -143,7 +143,7 @@ void plKeyImp::SetUoid(const plUoid& uoid) #endif } -const char* plKeyImp::GetName() const +const plString& plKeyImp::GetName() const { return fUoid.GetObjectName(); } diff --git a/Sources/Plasma/NucleusLib/pnKeyedObject/plKeyImp.h b/Sources/Plasma/NucleusLib/pnKeyedObject/plKeyImp.h index a054990b..222c80df 100644 --- a/Sources/Plasma/NucleusLib/pnKeyedObject/plKeyImp.h +++ b/Sources/Plasma/NucleusLib/pnKeyedObject/plKeyImp.h @@ -59,7 +59,7 @@ public: virtual ~plKeyImp(); virtual const plUoid& GetUoid() const { return fUoid; } - virtual const char* GetName() const; + virtual const plString& GetName() const; virtual hsKeyedObject* GetObjectPtr(); virtual hsKeyedObject* ObjectIsLoaded() const; diff --git a/Sources/Plasma/NucleusLib/pnKeyedObject/plMsgForwarder.cpp b/Sources/Plasma/NucleusLib/pnKeyedObject/plMsgForwarder.cpp index 089fdd2c..b8d9a7ed 100644 --- a/Sources/Plasma/NucleusLib/pnKeyedObject/plMsgForwarder.cpp +++ b/Sources/Plasma/NucleusLib/pnKeyedObject/plMsgForwarder.cpp @@ -167,7 +167,7 @@ hsBool plMsgForwarder::IForwardCallbackMsg(plMessage *msg) if (--fc->fNumCallbacks == 0) { hsStatusMessageF("plEventCallbackMsg received, erasing, sender=%s, remoteMsg=%d\n", - msg->GetSender() ? msg->GetSender()->GetName() : "nil", msg->HasBCastFlag(plMessage::kNetNonLocal)); + msg->GetSender() ? msg->GetSender()->GetName().c_str() : "nil", msg->HasBCastFlag(plMessage::kNetNonLocal)); fCallbacks.erase(eventMsg); @@ -190,7 +190,7 @@ hsBool plMsgForwarder::IForwardCallbackMsg(plMessage *msg) else { hsStatusMessageF("! Unknown plEventCallbackMsg received, sender=%s, remoteMsg=%d\n", - msg->GetSender() ? msg->GetSender()->GetName() : "nil", msg->HasBCastFlag(plMessage::kNetNonLocal)); + msg->GetSender() ? msg->GetSender()->GetName().c_str() : "nil", msg->HasBCastFlag(plMessage::kNetNonLocal)); hsAssert(0, "Unknown plEventCallbackMsg received"); } return true; diff --git a/Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp b/Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp index f70d4a49..555633d4 100644 --- a/Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp +++ b/Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp @@ -135,21 +135,19 @@ plLocation plLocation::MakeNormal(UInt32 number) //// plUoid ////////////////////////////////////////////////////////////////// -plUoid::plUoid(const plLocation& location, UInt16 classType, const char* objectName, const plLoadMask& m) +plUoid::plUoid(const plLocation& location, UInt16 classType, const plString& objectName, const plLoadMask& m) { - fObjectName = nil; Invalidate(); fLocation = location; fClassType = classType; - fObjectName = hsStrcpy(objectName); + fObjectName = objectName; fLoadMask = m; fClonePlayerID = 0; } plUoid::plUoid(const plUoid& src) { - fObjectName = nil; Invalidate(); *this = src; } @@ -177,7 +175,7 @@ void plUoid::Read(hsStream* s) s->LogReadLE(&fClassType, "ClassType"); s->LogReadLE(&fObjectID, "ObjectID"); s->LogSubStreamPushDesc("ObjectName"); - fObjectName = s->LogReadSafeString(); + fObjectName = s->LogReadSafeString_TEMP(); // conditional cloneIDs read if (contents & kHasCloneIDs) @@ -210,7 +208,7 @@ void plUoid::Write(hsStream* s) const s->WriteLE( fClassType ); s->WriteLE( fObjectID ); - s->WriteSafeString( fObjectName ); + s->WriteSafeString_TEMP( fObjectName ); // conditional cloneIDs write if (contents & kHasCloneIDs) @@ -228,9 +226,7 @@ void plUoid::Invalidate() fCloneID = 0; fClonePlayerID = 0; fClassType = 0; - if (fObjectName) - delete [] fObjectName; - fObjectName = nil; + fObjectName = plString::Null; fLocation.Invalidate(); fLoadMask = plLoadMask::kAlways; @@ -238,7 +234,7 @@ void plUoid::Invalidate() hsBool plUoid::IsValid() const { - if (!fLocation.IsValid() || fObjectName == nil) + if (!fLocation.IsValid() || fObjectName.IsNull()) return false; return true; @@ -249,7 +245,7 @@ hsBool plUoid::operator==(const plUoid& u) const return fLocation == u.fLocation && fLoadMask == u.fLoadMask && fClassType == u.fClassType - && hsStrEQ(fObjectName, u.fObjectName) + && fObjectName == u.fObjectName && fObjectID == u.fObjectID && fCloneID == u.fCloneID && fClonePlayerID == u.fClonePlayerID; @@ -261,9 +257,7 @@ plUoid& plUoid::operator=(const plUoid& rhs) fCloneID = rhs.fCloneID; fClonePlayerID = rhs.fClonePlayerID; fClassType = rhs.fClassType; - if (fObjectName) - delete [] fObjectName; - fObjectName = hsStrcpy(rhs.fObjectName); + fObjectName = rhs.fObjectName; fLocation = rhs.fLocation; fLoadMask = rhs.fLoadMask; @@ -276,7 +270,7 @@ plString plUoid::StringIze() const // Format to displayable string return plString::Format("(0x%x:0x%x:%s:C:[%u,%u])", fLocation.GetSequenceNumber(), int(fLocation.GetFlags()), - fObjectName, + fObjectName.c_str(), GetClonePlayerID(), GetCloneID()); } diff --git a/Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.h b/Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.h index fa11c0f8..c5458f00 100644 --- a/Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.h +++ b/Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.h @@ -57,9 +57,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "hsTypes.h" #include "plFixedKey.h" #include "plLoadMask.h" +#include "plString.h" class hsStream; -class plString; //// plLocation ////////////////////////////////////////////////////////////// @@ -144,15 +144,15 @@ public: class plUoid { public: - plUoid() { fObjectName = nil; Invalidate(); } - plUoid(const plLocation& location, UInt16 classType, const char* objectName, const plLoadMask& m=plLoadMask::kAlways); + plUoid() { Invalidate(); } + plUoid(const plLocation& location, UInt16 classType, const plString& objectName, const plLoadMask& m=plLoadMask::kAlways); plUoid(plFixedKeyId fixedKey); plUoid(const plUoid& src); ~plUoid(); const plLocation& GetLocation() const { return fLocation; } UInt16 GetClassType() const { return fClassType; } - const char* GetObjectName() const { return fObjectName; } + const plString& GetObjectName() const { return fObjectName; } const plLoadMask& GetLoadMask() const { return fLoadMask; } void Read(hsStream* s); @@ -188,7 +188,7 @@ protected: UInt32 fClonePlayerID; // The ID of the player who made this clone UInt16 fCloneID; // The ID of this clone (unique per client) UInt16 fClassType; - char* fObjectName; + plString fObjectName; plLocation fLocation; plLoadMask fLoadMask; }; diff --git a/Sources/Plasma/NucleusLib/pnMessage/plMessage.cpp b/Sources/Plasma/NucleusLib/pnMessage/plMessage.cpp index 86b7abff..2eef2b1c 100644 --- a/Sources/Plasma/NucleusLib/pnMessage/plMessage.cpp +++ b/Sources/Plasma/NucleusLib/pnMessage/plMessage.cpp @@ -313,7 +313,7 @@ int plMsgStdStringHelper::PeekBig(std::string & stringref, hsStream* stream, co return stream->GetPosition(); } -int plMsgStdStringHelper::Peek(plString & stringref, hsStream* stream, const UInt32 peekOptions) +int plMsgStdStringHelper::Peek(plString & stringref, hsStream* stream, const UInt32 peekOptions) { std::string temp; int pos = Peek(temp, stream, peekOptions); @@ -321,7 +321,7 @@ int plMsgStdStringHelper::Peek(plString & stringref, hsStream* stream, const UI return pos; } -int plMsgStdStringHelper::PeekBig(plString & stringref, hsStream* stream, const UInt32 peekOptions) +int plMsgStdStringHelper::PeekBig(plString & stringref, hsStream* stream, const UInt32 peekOptions) { std::string temp; int pos = PeekBig(temp, stream, peekOptions); @@ -399,6 +399,20 @@ int plMsgCStringHelper::Peek(char *& str, hsStream* stream, const UInt32 peekOpt return stream->GetPosition(); } +int plMsgCStringHelper::Poke(const plString & str, hsStream* stream, const UInt32 peekOptions) +{ + return Poke(str.c_str(), stream, peekOptions); +} + +int plMsgCStringHelper::Peek(plString & str, hsStream* stream, const UInt32 peekOptions) +{ + char * temp = nil; + int pos = Peek(temp, stream, peekOptions); + str = plString::FromIso8859_1(temp); + delete [] temp; + return pos; +} + ///////////////////////////////////////////////////////////////// diff --git a/Sources/Plasma/NucleusLib/pnMessage/plMessage.h b/Sources/Plasma/NucleusLib/pnMessage/plMessage.h index 6a53a8d0..0c602acb 100644 --- a/Sources/Plasma/NucleusLib/pnMessage/plMessage.h +++ b/Sources/Plasma/NucleusLib/pnMessage/plMessage.h @@ -190,13 +190,16 @@ struct plMsgXtlStringHelper }; ///////////////////////////////////////////////////////////////// -// reads/writes your char * field +// reads/writes your char * field (deprecated) struct plMsgCStringHelper { static int Poke(const char * str, hsStream* stream, const UInt32 peekOptions=0); // deletes str and reallocates. you must delete [] str; static int Peek(char *& str, hsStream* stream, const UInt32 peekOptions=0); + + static int Poke(const plString & str, hsStream* stream, const UInt32 peekOptions=0); + static int Peek(plString & str, hsStream* stream, const UInt32 peekOptions=0); }; ///////////////////////////////////////////////////////////////// diff --git a/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoaderPaging.cpp b/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoaderPaging.cpp index 8a882667..fc4ed194 100644 --- a/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoaderPaging.cpp +++ b/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoaderPaging.cpp @@ -69,10 +69,10 @@ bool ReportRoomToServer(const plKey &key) plLocation keyLoc=key->GetUoid().GetLocation(); bool skip=(keyLoc.IsReserved() || keyLoc.IsVirtual() || // HACK ALERT - replace with new uoid type flags - (key->GetName() && - (!strnicmp(key->GetName(), "global", 6) || - strstr(key->GetName(), "_Male") || - strstr(key->GetName(), "_Female") + (!key->GetName().IsNull() && + (!key->GetName().CompareN("global", 6, plString::kCaseInsensitive) || + key->GetName().Find("_Male") >= 0 || + key->GetName().Find("_Female") >= 0 ) ) ); diff --git a/Sources/Plasma/PubUtilLib/plAudible/plWinAudible.cpp b/Sources/Plasma/PubUtilLib/plAudible/plWinAudible.cpp index 72ec8bcc..a9a655f4 100644 --- a/Sources/Plasma/PubUtilLib/plAudible/plWinAudible.cpp +++ b/Sources/Plasma/PubUtilLib/plAudible/plWinAudible.cpp @@ -473,9 +473,7 @@ void plWinAudible::Read(hsStream* s, hsResMgr* mgr) void plWinAudible::IAssignSoundKey( plSound *sound, const char *name, UInt32 i ) { - char keyName[ 256 ]; - - sprintf( keyName, "%s_%d", name, i ); + plString keyName = plString::Format( "%s_%d", name, i ); hsgResMgr::ResMgr()->NewKey( keyName, sound, GetKey() ? GetKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc ); } @@ -607,7 +605,7 @@ int plWinAudible::GetSoundIndex(const char *keyname) const for( int i = 0; i < fSoundObjs.Count(); i++) { if(!fSoundObjs[i]) continue; - if(!strcmp(fSoundObjs[i]->GetKeyName(), keyname )) + if(!fSoundObjs[i]->GetKeyName().Compare( keyname )) { return i; } diff --git a/Sources/Plasma/PubUtilLib/plAudio/plAudioSystem.cpp b/Sources/Plasma/PubUtilLib/plAudio/plAudioSystem.cpp index dd4aa736..bd80bcde 100644 --- a/Sources/Plasma/PubUtilLib/plAudio/plAudioSystem.cpp +++ b/Sources/Plasma/PubUtilLib/plAudio/plAudioSystem.cpp @@ -934,7 +934,7 @@ hsBool plAudioSystem::MsgReceive(plMessage* msg) { //if( fListener ) { - plProfile_BeginLap(AudioUpdate, this->GetKey()->GetUoid().GetObjectName()); + plProfile_BeginLap(AudioUpdate, this->GetKey()->GetUoid().GetObjectName().c_str()); if(hsTimer::GetMilliSeconds() - fLastUpdateTimeMs > UPDATE_TIME_MS) { IUpdateSoftSounds( fCurrListenerPos ); @@ -947,7 +947,7 @@ hsBool plAudioSystem::MsgReceive(plMessage* msg) } //fCommittedListenerPos = fCurrListenerPos; } - plProfile_EndLap(AudioUpdate, this->GetKey()->GetUoid().GetObjectName()); + plProfile_EndLap(AudioUpdate, this->GetKey()->GetUoid().GetObjectName().c_str()); } return true; diff --git a/Sources/Plasma/PubUtilLib/plAudio/plSound.cpp b/Sources/Plasma/PubUtilLib/plAudio/plSound.cpp index bbc8e58a..e63f29d8 100644 --- a/Sources/Plasma/PubUtilLib/plAudio/plSound.cpp +++ b/Sources/Plasma/PubUtilLib/plAudio/plSound.cpp @@ -141,10 +141,10 @@ void plSound::IPrintDbgMessage( const char *msg, hsBool isError ) if( isError ) // ourLog->AddLineF( plStatusLog::kRed, "ERROR: %s (%s)", msg, GetKey() ? GetKeyName() : "unkeyed" ); - ourLog->AddLineS( "audio.log", plStatusLog::kRed, "ERROR: %s (%s)", msg, GetKey() ? GetKeyName() : "unkeyed" ); + ourLog->AddLineS( "audio.log", plStatusLog::kRed, "ERROR: %s (%s)", msg, GetKey() ? GetKeyName().c_str() : "unkeyed" ); else // ourLog->AddLineF( "%s (%s)", msg, GetKey() ? GetKeyName() : "unkeyed" ); - ourLog->AddLineS( "audio.log", "%s (%s)", msg, GetKey() ? GetKeyName() : "unkeyed" ); + ourLog->AddLineS( "audio.log", "%s (%s)", msg, GetKey() ? GetKeyName().c_str() : "unkeyed" ); } /////////////////////////////////////////////////////////// @@ -163,7 +163,7 @@ void plSound::IUpdateDebugPlate( void ) fDebugPlate->SetPosition( -0.5, 0 ); fDebugPlate->SetDataRange( 0, 100, 100 ); fDebugPlate->SetColors( 0x80202000 ); - fDebugPlate->SetTitle( (char *)GetKeyName() ); // Bleah + fDebugPlate->SetTitle( _TEMP_CONVERT_TO_CONST_CHAR( GetKeyName() ) ); // Bleah fDebugPlate->SetLabelText( "Desired", "Curr", "Soft", "Dist" ); } @@ -190,7 +190,7 @@ void plSound::SetCurrDebugPlate( const plKey soundKey ) { fDebugPlate->ClearData(); fDebugPlate->SetVisible( true ); - fDebugPlate->SetTitle( (char *)fCurrDebugPlateSound->GetKeyName() ); // Bleah + fDebugPlate->SetTitle( _TEMP_CONVERT_TO_CONST_CHAR( fCurrDebugPlateSound->GetKeyName() ) ); // Bleah } } } diff --git a/Sources/Plasma/PubUtilLib/plAudio/plVoiceChat.cpp b/Sources/Plasma/PubUtilLib/plAudio/plVoiceChat.cpp index 5321bcec..4a806811 100644 --- a/Sources/Plasma/PubUtilLib/plAudio/plVoiceChat.cpp +++ b/Sources/Plasma/PubUtilLib/plAudio/plVoiceChat.cpp @@ -410,8 +410,7 @@ plVoiceSound::plVoiceSound() fEAXSettings.SetRoomParams(-1200, -100, 0, 0); fLastUpdate = 0; - char keyName[32]; - snprintf(keyName, arrsize(keyName), "VoiceSound_%d", fCount); + plString keyName = plString::Format("VoiceSound_%d", fCount); fCount++; hsgResMgr::ResMgr()->NewKey(keyName, this, plLocation::kGlobalFixedLoc); } diff --git a/Sources/Plasma/PubUtilLib/plAudio/plWin32GroupedSound.cpp b/Sources/Plasma/PubUtilLib/plAudio/plWin32GroupedSound.cpp index 08a5bc45..b24e8a2e 100644 --- a/Sources/Plasma/PubUtilLib/plAudio/plWin32GroupedSound.cpp +++ b/Sources/Plasma/PubUtilLib/plAudio/plWin32GroupedSound.cpp @@ -160,9 +160,8 @@ hsBool plWin32GroupedSound::LoadSound( hsBool is3D ) // We need it to be resident to read in if( retVal == plSoundBuffer::kError) { - char str[ 256 ]; - sprintf( str, "Unable to open .wav file %s", fDataBufferKey ? fDataBufferKey->GetName() : "nil"); - IPrintDbgMessage( str, true ); + plString str = plString::Format("Unable to open .wav file %s", fDataBufferKey ? fDataBufferKey->GetName().c_str() : "nil"); + IPrintDbgMessage( str.c_str(), true ); fFailed = true; return false; } @@ -229,9 +228,8 @@ hsBool plWin32GroupedSound::LoadSound( hsBool is3D ) IFillCurrentSound( 0 ); // Logging - char str[ 256 ]; - sprintf( str, " Grouped %s %s allocated (%d msec).", buffer->GetFileName() != nil ? "file" : "buffer", - buffer->GetFileName() != nil ? buffer->GetFileName() : buffer->GetKey()->GetUoid().GetObjectName(), + plString str = plString::Format(" Grouped %s %s allocated (%d msec).", buffer->GetFileName() != nil ? "file" : "buffer", + buffer->GetFileName() != nil ? buffer->GetFileName() : buffer->GetKey()->GetUoid().GetObjectName().c_str(), //fDSoundBuffer->IsHardwareAccelerated() ? "hardware" : "software", //fDSoundBuffer->IsStaticVoice() ? "static" : "dynamic", #ifdef PL_PROFILE_ENABLED @@ -239,11 +237,11 @@ hsBool plWin32GroupedSound::LoadSound( hsBool is3D ) #else 0 ); #endif - IPrintDbgMessage( str ); - if( GetKey() != nil && GetKeyName() != nil && strstr( GetKeyName(), "Footstep" ) != nil ) + IPrintDbgMessage( str.c_str() ); + if( GetKey() != nil && GetKeyName().Find( "Footstep" ) >= 0 ) ; else - plStatusLog::AddLineS( "audioTimes.log", "%s (%s)", str, GetKey() ? GetKeyName() : "unkeyed" ); + plStatusLog::AddLineS( "audioTimes.log", "%s (%s)", str, GetKey() ? GetKeyName().c_str() : "unkeyed" ); fTotalBytes = bufferSize; diff --git a/Sources/Plasma/PubUtilLib/plAudio/plWin32Sound.cpp b/Sources/Plasma/PubUtilLib/plAudio/plWin32Sound.cpp index cd61403f..e64aaf31 100644 --- a/Sources/Plasma/PubUtilLib/plAudio/plWin32Sound.cpp +++ b/Sources/Plasma/PubUtilLib/plAudio/plWin32Sound.cpp @@ -168,7 +168,7 @@ void plWin32Sound::IActuallyStop() { if( fDSoundBuffer != nil && fDSoundBuffer->IsPlaying() ) { - plStatusLog::AddLineS( "audio.log", 0xffff0000, "WARNING: BUFFER FLAGGED AS STOPPED BUT NOT STOPPED - %s", GetKey() ? GetKeyName() : nil ); + plStatusLog::AddLineS( "audio.log", 0xffff0000, "WARNING: BUFFER FLAGGED AS STOPPED BUT NOT STOPPED - %s", GetKey() ? GetKeyName().c_str() : nil ); fDSoundBuffer->Stop(); } } diff --git a/Sources/Plasma/PubUtilLib/plAudio/plWin32StaticSound.cpp b/Sources/Plasma/PubUtilLib/plAudio/plWin32StaticSound.cpp index 46a1ba15..77c4d7a9 100644 --- a/Sources/Plasma/PubUtilLib/plAudio/plWin32StaticSound.cpp +++ b/Sources/Plasma/PubUtilLib/plAudio/plWin32StaticSound.cpp @@ -115,9 +115,8 @@ hsBool plWin32StaticSound::LoadSound( hsBool is3D ) if( retVal == plSoundBuffer::kError ) { - char str[ 256 ]; - sprintf( str, "Unable to open .wav file %s", fDataBufferKey ? fDataBufferKey->GetName() : "nil"); - IPrintDbgMessage( str, true ); + plString str = plString::Format( "Unable to open .wav file %s", fDataBufferKey ? fDataBufferKey->GetName().c_str() : "nil"); + IPrintDbgMessage( str.c_str(), true ); fFailed = true; return false; } diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp index 75dfb149..b1148b8a 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp @@ -241,7 +241,7 @@ hsBool plAGMasterMod::IEval(double secs, hsScalar del, UInt32 dirty) // APPLYANIMATIONS void plAGMasterMod::ApplyAnimations(double time, hsScalar elapsed) { - plProfile_BeginLap(ApplyAnimation, this->GetKey()->GetUoid().GetObjectName()); + plProfile_BeginLap(ApplyAnimation, this->GetKey()->GetUoid().GetObjectName().c_str()); // update any fades for (int i = 0; i < fAnimInstances.size(); i++) @@ -251,7 +251,7 @@ void plAGMasterMod::ApplyAnimations(double time, hsScalar elapsed) AdvanceAnimsToTime(time); - plProfile_EndLap(ApplyAnimation,this->GetKey()->GetUoid().GetObjectName()); + plProfile_EndLap(ApplyAnimation,this->GetKey()->GetUoid().GetObjectName().c_str()); } void plAGMasterMod::AdvanceAnimsToTime(double time) diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterSDLModifier.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterSDLModifier.cpp index 461ebd70..3779e5d3 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterSDLModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAGMasterSDLModifier.cpp @@ -57,10 +57,10 @@ char plAGMasterSDLModifier::AGMasterVarNames::kStrBlends[]="blends"; UInt32 plAGMasterSDLModifier::IApplyModFlags(UInt32 sendFlags) { // ugly hack so bug light animation state isn't stored on the server - if (stricmp(GetTarget()->GetKeyName(), "RTOmni-BugLightTest") == 0) + if (GetTarget()->GetKeyName().Compare("RTOmni-BugLightTest", plString::kCaseInsensitive) == 0) return (sendFlags | plSynchedObject::kDontPersistOnServer | plSynchedObject::kIsAvatarState); // ditto for the KI light - if (stricmp(GetTarget()->GetKeyName(), "RTOmniKILight") == 0) + if (GetTarget()->GetKeyName().Compare("RTOmniKILight", plString::kCaseInsensitive) == 0) return (sendFlags | plSynchedObject::kDontPersistOnServer | plSynchedObject::kIsAvatarState); return sendFlags; diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp index 0b750b84..d10d43e4 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp @@ -809,11 +809,8 @@ int plArmatureMod::IFindSpawnOverride( void ) plAvatarMgr *mgr = plAvatarMgr::GetInstance(); for( i = 0; i < mgr->NumSpawnPoints(); i++ ) { - char str2[ 256 ]; - strcpy(str2, mgr->GetSpawnPoint( i )->GetTarget(0)->GetKeyName()); - strlwr(str2); - - if (strstr(str2, fSpawnPointOverride) != nil) + const plString &name = mgr->GetSpawnPoint( i )->GetTarget(0)->GetKeyName(); + if (name.Find(fSpawnPointOverride, plString::kCaseInsensitive) >= 0) return i; // Found it! } return -1; @@ -1792,33 +1789,33 @@ void plArmatureMod::Read(hsStream * stream, hsResMgr *mgr) if (gLoc.IsValid()) { const plUoid &myUoid = GetKey()->GetUoid(); - plUoid SOUoid(gLoc, plSceneObject::Index(), "FootstepSoundObject"); + plUoid SOUoid(gLoc, plSceneObject::Index(), _TEMP_CONVERT_FROM_LITERAL("FootstepSoundObject")); fFootSoundSOKey = mgr->FindKey(SOUoid); if (fFootSoundSOKey) { // So it exists... but FindKey won't properly create our clone. So we do. SOUoid.SetClone(myUoid.GetClonePlayerID(), myUoid.GetCloneID()); - fFootSoundSOKey = mgr->ReRegister(nil, SOUoid); + fFootSoundSOKey = mgr->ReRegister(plString::Null, SOUoid); } // Add the effect to our effects manager - plUoid effectUoid(gLoc, plArmatureEffectFootSound::Index(), "FootstepSounds" ); + plUoid effectUoid(gLoc, plArmatureEffectFootSound::Index(), _TEMP_CONVERT_FROM_LITERAL("FootstepSounds") ); plKey effectKey = mgr->FindKey(effectUoid); if (effectKey) { effectUoid.SetClone(myUoid.GetClonePlayerID(), myUoid.GetCloneID()); - effectKey = mgr->ReRegister(nil, effectUoid); + effectKey = mgr->ReRegister(plString::Null, effectUoid); } if (effectKey != nil) mgr->AddViaNotify(effectKey, TRACKED_NEW plGenRefMsg(effectMgrKey, plRefMsg::kOnCreate, -1, -1), plRefFlags::kActiveRef); // Get the linking sound - plUoid LinkUoid(gLoc, plSceneObject::Index(), "LinkSoundSource"); + plUoid LinkUoid(gLoc, plSceneObject::Index(), _TEMP_CONVERT_FROM_LITERAL("LinkSoundSource")); fLinkSoundSOKey = mgr->FindKey(LinkUoid); if (fLinkSoundSOKey) { LinkUoid.SetClone(myUoid.GetClonePlayerID(), myUoid.GetCloneID()); - fLinkSoundSOKey = mgr->ReRegister(nil, LinkUoid); + fLinkSoundSOKey = mgr->ReRegister(plString::Null, LinkUoid); } } } @@ -2060,7 +2057,7 @@ hsBool plArmatureMod::ValidateMesh() hsgResMgr::ResMgr()->SendRef(meshObj->GetKey(), refMsg, plRefFlags::kPassiveRef); } } - if (!strcmp(GetTarget(0)->GetKeyName(), "Yeesha")) + if (!GetTarget(0)->GetKeyName().Compare("Yeesha")) ISetTransparentDrawOrder(true); else ISetTransparentDrawOrder(false); @@ -2704,7 +2701,7 @@ void plArmatureMod::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *str plKey world = nil; if (fController) world = fController->GetSubworld(); - sprintf(strBuf, "In world: %s Frozen: %s", world ? world->GetName() : "nil", frozen); + sprintf(strBuf, "In world: %s Frozen: %s", world ? world->GetName().c_str() : "nil", frozen); debugTxt.DrawString(x,y, strBuf); y+= lineHeight; diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp index 6689bdc7..1435a233 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp @@ -276,13 +276,12 @@ void plClothingItem::Write(hsStream *s, hsResMgr *mgr) plKey accessoryKey = nil; if (fAccessoryName) { - char strBuf[512]; - sprintf(strBuf, "CItm_%s", fAccessoryName); + plString strBuf = plString::Format("CItm_%s", fAccessoryName); accessoryKey = plKeyFinder::Instance().StupidSearch("GlobalClothing", nil, plClothingItem::Index(), strBuf); if (accessoryKey == nil) { - sprintf(strBuf, "Couldn't find accessory \"%s\". It won't show at runtime.", fAccessoryName); - hsMessageBox(strBuf, GetKeyName(), hsMessageBoxNormal); + strBuf = plString::Format("Couldn't find accessory \"%s\". It won't show at runtime.", fAccessoryName); + hsMessageBox(strBuf.c_str(), GetKeyName().c_str(), hsMessageBoxNormal); } } mgr->WriteKey(s, accessoryKey); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp index 6c0f168b..3c3655b1 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp @@ -134,10 +134,6 @@ void plAvatarMgr::IReset() { fSeekPoints.clear(); - // Oneshots have copies of strings in their maps. I'm assuming the others should be the same, but until - // I hear otherwise... - for( plOneShotMap::iterator it = fOneShots.begin(); it != fOneShots.end(); it++ ) - delete [] (char *)it->first; fOneShots.clear(); fAvatars.clear(); fSpawnPoints.clear(); @@ -203,9 +199,9 @@ plKey plAvatarMgr::LoadAvatar(const char *name, const char *accountName, bool is const plLocation& loc = (globalLoc.IsValid() ? globalLoc : custLoc.IsValid() ? custLoc : maleLoc); #endif - const char* theName = name; + plString theName = _TEMP_CONVERT_FROM_LITERAL(name); if ( loc == maleLoc ) - theName = "Male"; + theName = _TEMP_CONVERT_FROM_LITERAL("Male"); if (loc.IsValid()) { @@ -561,15 +557,14 @@ void plAvatarMgr::AddSeekPoint(plSeekPointMod *seekPoint) { if(seekPoint) { - const char *name = seekPoint->GetTarget(0)->GetKey()->GetName(); - char *ourName = hsStrcpy(name); + plString name = seekPoint->GetTarget(0)->GetKey()->GetName(); plSeekPointMod *alreadyThere = FindSeekPoint(name); - + /// hsAssert( ! alreadyThere, "Tried to add a seek point with duplicate name. Ignoring second seek point."); if ( ! alreadyThere) { - fSeekPoints[ourName] = seekPoint; + fSeekPoints[name] = seekPoint; } } } @@ -579,21 +574,19 @@ void plAvatarMgr::RemoveSeekPoint(plSeekPointMod *seekPoint) { if(seekPoint) { - const char *name = seekPoint->GetTarget(0)->GetKey()->GetName(); + plString name = seekPoint->GetTarget(0)->GetKey()->GetName(); plSeekPointMap::iterator found = fSeekPoints.find(name); if(found != fSeekPoints.end()) { - const char *oldName = (*found).first; fSeekPoints.erase(found); - delete[] const_cast(oldName); // retarded language, this is... } } } // FINDSEEKPOINT -plSeekPointMod * plAvatarMgr::FindSeekPoint(const char *name) +plSeekPointMod * plAvatarMgr::FindSeekPoint(const plString &name) { plSeekPointMap::iterator found = fSeekPoints.find(name); @@ -610,8 +603,7 @@ void plAvatarMgr::AddOneShot(plOneShotMod *oneshot) { if(oneshot) { - // allocate a copy of the target name to use as a key - char * name = hsStrcpy(oneshot->GetTarget(0)->GetKey()->GetName()); + plString name = oneshot->GetTarget(0)->GetKey()->GetName(); plOneShotMod *alreadyThere = FindOneShot(name); @@ -619,8 +611,6 @@ void plAvatarMgr::AddOneShot(plOneShotMod *oneshot) { fOneShots[name] = oneshot; } - else - delete [] name; } } @@ -631,14 +621,12 @@ void plAvatarMgr::RemoveOneShot(plOneShotMod *oneshot) while (i != fOneShots.end()) { - char * name = (*i).first; + plString name = (*i).first; plOneShotMod *thisOneshot = (*i).second; if(oneshot == thisOneshot) { i = fOneShots.erase(i); - // destroy our copy of the target name - delete[] name; } else { i++; } @@ -646,7 +634,7 @@ void plAvatarMgr::RemoveOneShot(plOneShotMod *oneshot) } // FINDONESHOT -plOneShotMod *plAvatarMgr::FindOneShot(char *name) +plOneShotMod *plAvatarMgr::FindOneShot(const plString &name) { plOneShotMap::iterator found = fOneShots.find(name); @@ -756,7 +744,7 @@ plArmatureMod *plAvatarMgr::FindAvatarByModelName(char *name) for (it = fAvatars.begin(); it != fAvatars.end(); ++it) { plArmatureMod* armature = plArmatureMod::ConvertNoRef((*it)->ObjectIsLoaded()); - if (armature && (!strcmp(armature->GetTarget(0)->GetKeyName(), name))) + if (armature && (!armature->GetTarget(0)->GetKeyName().Compare(name))) return armature; } @@ -769,7 +757,7 @@ void plAvatarMgr::FindAllAvatarsByModelName(const char* name, plArmatureModPtrVe for (it = fAvatars.begin(); it != fAvatars.end(); ++it) { plArmatureMod* armature = plArmatureMod::ConvertNoRef((*it)->ObjectIsLoaded()); - if (armature && (!strcmp(armature->GetTarget(0)->GetKeyName(), name))) + if (armature && (!armature->GetTarget(0)->GetKeyName().Compare(name))) outVec.push_back(armature); } } @@ -807,8 +795,8 @@ int plAvatarMgr::FindSpawnPoint( const char *name ) const for( i = 0; i < fSpawnPoints.size(); i++ ) { if( fSpawnPoints[ i ] != nil && - (strstr( fSpawnPoints[ i ]->GetKey()->GetUoid().GetObjectName(), name ) != nil || - strstr( fSpawnPoints[i]->GetTarget(0)->GetKeyName(), name) != nil)) + ( fSpawnPoints[ i ]->GetKey()->GetUoid().GetObjectName().Find( name ) >= 0 || + fSpawnPoints[ i ]->GetTarget(0)->GetKeyName().Find( name ) >= 0 )) return i; } diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.h b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.h index 26fa62f1..8d2cb8a7 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.h @@ -101,7 +101,7 @@ public: do away with this bookeeping entirely. */ void AddSeekPoint(plSeekPointMod *seekpoint); void RemoveSeekPoint(plSeekPointMod *seekpoint); - plSeekPointMod *FindSeekPoint(const char *name); + plSeekPointMod *FindSeekPoint(const plString &name); // \} // \{ @@ -109,7 +109,7 @@ public: scripting only. */ void AddOneShot(plOneShotMod *oneshot); void RemoveOneShot(plOneShotMod *oneshot); - plOneShotMod *FindOneShot(char *name); + plOneShotMod *FindOneShot(const plString &name); // \} plKey LoadPlayer(const char* name, const char *account); @@ -200,10 +200,10 @@ protected: static plAvatarMgr* fInstance; // the single instance of the avatar manager - typedef std::map plSeekPointMap; + typedef std::map plSeekPointMap; plSeekPointMap fSeekPoints; - typedef std::map plOneShotMap; + typedef std::map plOneShotMap; plOneShotMap fOneShots; typedef std::map DeferredInits; diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp index 45119c8c..f737ba04 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp @@ -111,22 +111,14 @@ plCoopCoordinator::plCoopCoordinator(plKey host, plKey guest, fGuestAccepted(false), fGuestLinked(false) { - const char * hostName = host->GetName(); - const char * guestName = guest->GetName(); static int serial = 0; - int len = strlen(hostName) + strlen(guestName) + 3 /* serial num */ + 1; - - char *newName = TRACKED_NEW char[len]; - serial = serial % 999; - sprintf(newName, "%s%s%3i\x000", hostName, guestName, serial++); + plString newName = plString::Format("%s%s%3i\x000", host->GetName().c_str(), guest->GetName().c_str(), serial++); plKey newKey = hsgResMgr::ResMgr()->NewKey(newName, this, host->GetUoid().GetLocation()); - delete[] newName; - fSynchBone = hsStrcpy(synchBone); plKey avMgrKey = plAvatarMgr::GetInstance()->GetKey(); diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plDrawableGenerator.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plDrawableGenerator.cpp index 4a8465ee..fb170bc2 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plDrawableGenerator.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plDrawableGenerator.cpp @@ -259,8 +259,7 @@ plDrawableSpans *plDrawableGenerator::GenerateDrawable( UInt32 vertCount, hsPoin } static int nameIdx = 0; - char buff[256]; - sprintf(buff, "%s_%d", "GenDrawable", nameIdx++); + plString buff = plString::Format( "GenDrawable_%d", nameIdx++ ); hsgResMgr::ResMgr()->NewKey( buff, newDraw, plLocation::kGlobalFixedLoc ); } diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpans.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpans.cpp index adb532b6..60ce5b17 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpans.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpans.cpp @@ -1320,7 +1320,7 @@ hsBool plDrawableSpans::MsgReceive( plMessage* msg ) } else if( plRenderMsg::ConvertNoRef( msg ) ) { - plProfile_BeginLap(PalletteHack, this->GetKey()->GetUoid().GetObjectName()); + plProfile_BeginLap(PalletteHack, this->GetKey()->GetUoid().GetObjectName().c_str()); IUpdateMatrixPaletteBoundsHack(); @@ -1331,7 +1331,7 @@ hsBool plDrawableSpans::MsgReceive( plMessage* msg ) // The pipeline will then clear out those bits as it blends them, and then we simply // re-set them here, since plRenderMsg is sent once before all the rendering is done :) fFakeBlendingSpanVector = fBlendingSpanVector; - plProfile_EndLap(PalletteHack, this->GetKey()->GetUoid().GetObjectName()); + plProfile_EndLap(PalletteHack, this->GetKey()->GetUoid().GetObjectName().c_str()); return true; } diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpansExport.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpansExport.cpp index 444233df..bd5866e5 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpansExport.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpansExport.cpp @@ -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 ? geo->fMaxOwner : "", - geo->fMaterial ? geo->fMaterial->GetKey()->GetName() : "", + geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "", geo->GetVertexSize(geo->fFormat) * geo->fNumVerts + sizeof(UInt16) * 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 ? geo->fMaxOwner : "", - geo->fMaterial ? geo->fMaterial->GetKey()->GetName() : "", + geo->fMaterial ? geo->fMaterial->GetKey()->GetName().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 ? geo->fMaxOwner : "", - geo->fMaterial ? geo->fMaterial->GetKey()->GetName() : "", + geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "", geo->GetVertexSize(geo->fFormat) * geo->fNumVerts + sizeof(UInt16) * 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 ? geo->fMaxOwner : "", - geo->fMaterial ? geo->fMaterial->GetKey()->GetName() : "", + geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "", span->fGroupIdx, span->fVBufferIdx, span->fCellIdx, @@ -755,18 +755,18 @@ short plDrawableSpans::ICompareSpans( plGeometrySpan *span1, plGeometrySpan *s else if( t1 == nil && t2 == nil ) break; // Textures equal up to here--keep going with rest of tests - if( t1->GetKeyName() != nil && t2->GetKeyName() != nil ) + if( !t1->GetKeyName().IsNull() && !t2->GetKeyName().IsNull() ) { - j = stricmp( t1->GetKeyName(), t2->GetKeyName() ); + j = t1->GetKeyName().Compare( t2->GetKeyName(), plString::kCaseInsensitive ); if( j != 0 ) return (short)j; } } // Finally, by material itself. - if( span1->fMaterial->GetKeyName() != nil && span2->fMaterial->GetKeyName() != nil ) + if( !span1->fMaterial->GetKeyName().IsNull() && !span2->fMaterial->GetKeyName().IsNull() ) { - j = stricmp( span1->fMaterial->GetKeyName(), span2->fMaterial->GetKeyName() ); + j = span1->fMaterial->GetKeyName().Compare( span2->fMaterial->GetKeyName(), plString::kCaseInsensitive ); if( j != 0 ) return (short)j; } diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plDynaDecalMgr.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plDynaDecalMgr.cpp index 69f00005..c26edde4 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plDynaDecalMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plDynaDecalMgr.cpp @@ -1578,21 +1578,20 @@ hsGMaterial* plDynaDecalMgr::IConvertToEnvMap(hsGMaterial* mat, plBitmap* envMap oldMip->SetCurrLevel(0); hsGMaterial* newMat = TRACKED_NEW hsGMaterial; - char buff[256]; - sprintf(buff, "%s_%s", GetKey()->GetName(), "EnvMat"); + plString buff = plString::Format("%s_EnvMat", GetKey()->GetName().c_str()); hsgResMgr::ResMgr()->NewKey(buff, newMat, GetKey()->GetUoid().GetLocation()); static plTweak kSmooth(1.f); plMipmap* bumpMap = plBumpMapGen::QikNormalMap(nil, oldMip, 0xffffffff, plBumpMapGen::kBubbleTest, kSmooth); // plMipmap* bumpMap = plBumpMapGen::QikNormalMap(nil, oldMip, 0xffffffff, plBumpMapGen::kNormalize, kSmooth); // plMipmap* bumpMap = plBumpMapGen::QikNormalMap(nil, oldMip, 0xffffffff, 0, 0); - sprintf(buff, "%s_%s", GetKey()->GetName(), "BumpMap"); + buff = plString::Format("%s_BumpMap", GetKey()->GetName().c_str()); hsgResMgr::ResMgr()->NewKey(buff, bumpMap, GetKey()->GetUoid().GetLocation()); bumpMap->SetFlags(bumpMap->GetFlags() | plMipmap::kBumpEnvMap | plMipmap::kForceNonCompressed); plLayer* bumpLay = TRACKED_NEW plLayer; - sprintf(buff, "%s_%s_%d", GetKey()->GetName(), "BumpMap", 0); + buff = plString::Format("%s_BumpMap_0", GetKey()->GetName().c_str()); hsgResMgr::ResMgr()->NewKey(buff, bumpLay, GetKey()->GetUoid().GetLocation()); bumpLay->SetState(oldLay->GetState()); @@ -1614,7 +1613,7 @@ hsGMaterial* plDynaDecalMgr::IConvertToEnvMap(hsGMaterial* mat, plBitmap* envMap newMat->AddLayerViaNotify(bumpLay); plLayer* envLay = TRACKED_NEW plLayer; - sprintf(buff, "%s_%s_%d", GetKey()->GetName(), "EnvMap", 0); + buff = plString::Format("%s_EnvMap_0", GetKey()->GetName().c_str()); hsgResMgr::ResMgr()->NewKey(buff, envLay, GetKey()->GetUoid().GetLocation()); envLay->SetBlendFlags(hsGMatState::kBlendMult); diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plProxyGen.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plProxyGen.cpp index 7ee07026..09ba523d 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plProxyGen.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plProxyGen.cpp @@ -80,16 +80,16 @@ void plProxyGen::Init(const hsKeyedObject* owner) { if( !GetKey() ) { - char buff[256]; + plString buff; plLocation loc; if( owner->GetKey() ) { - sprintf(buff, "%s_%s_%d_%d", owner->GetKey()->GetName(), "ProxyGen", owner->GetKey()->GetUoid().GetClonePlayerID(), fProxyKeyCounter++); + buff = plString::Format("%s_ProxyGen_%d_%d", owner->GetKey()->GetName().c_str(), owner->GetKey()->GetUoid().GetClonePlayerID(), fProxyKeyCounter++); loc = owner->GetKey()->GetUoid().GetLocation(); } else { - sprintf( buff, "ProxyGen%d", fProxyKeyCounter++ ); + buff = plString::Format( "ProxyGen%d", fProxyKeyCounter++ ); loc = plLocation::kGlobalFixedLoc; } @@ -157,11 +157,11 @@ hsGMaterial* plProxyGen::IMakeProxyMaterial() const hsGMaterial* retVal = TRACKED_NEW hsGMaterial(); - char buff[256]; - if( GetKey()->GetName() ) - sprintf(buff, "%s_%s", GetKey()->GetName(), "Material"); + plString buff; + if( !GetKey()->GetName().IsNull() ) + buff = plString::Format("%s_Material", GetKey()->GetName().c_str()); else - strcpy(buff, "ProxyMaterial"); + buff = _TEMP_CONVERT_FROM_LITERAL("ProxyMaterial"); hsgResMgr::ResMgr()->NewKey( buff, retVal, GetKey() ? GetKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc ); plLayer *lay = retVal->MakeBaseLayer(); @@ -232,11 +232,11 @@ void plProxyGen::IGenerateProxy() if( fProxyDrawables[idx] && !fProxyDrawables[idx]->GetKey() ) { - char buff[256]; - if( GetKey()->GetName() ) - sprintf(buff, "%s_%s", GetKey()->GetName(), "ProxyDrawable"); + plString buff; + if( !GetKey()->GetName().IsNull() ) + buff = plString::Format("%s_ProxyDrawable", GetKey()->GetName().c_str()); else - strcpy(buff, "ProxyDrawable"); + buff = _TEMP_CONVERT_FROM_LITERAL("ProxyDrawable"); hsgResMgr::ResMgr()->NewKey( buff, fProxyDrawables[ idx ], GetKey() ? GetKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc ); } diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plWaveSet7.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plWaveSet7.cpp index 895f4767..3928916b 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plWaveSet7.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plWaveSet7.cpp @@ -1617,8 +1617,7 @@ plMipmap* plWaveSet7::ICreateBiasNoiseMap() plMipmap::kUncompressed, plMipmap::UncompressedInfo::kRGB8888); - char buff[256]; - sprintf(buff, "%s_%s", GetKey()->GetName(), "BiasBitPS"); + plString buff = plString::Format("%s_BiasBitPS", GetKey()->GetName().c_str()); hsgResMgr::ResMgr()->NewKey(buff, mipMap, GetKey()->GetUoid().GetLocation()); int i; @@ -1663,8 +1662,7 @@ plMipmap* plWaveSet7::ICreateBumpMipmapPS() plMipmap::kUncompressed, plMipmap::UncompressedInfo::kRGB8888); - char buff[256]; - sprintf(buff, "%s_%s", GetKey()->GetName(), "BumpBitPS"); + plString buff = plString::Format("%s_BumpBitPS", GetKey()->GetName().c_str()); hsgResMgr::ResMgr()->NewKey(buff, mipMap, GetKey()->GetUoid().GetLocation()); hsgResMgr::ResMgr()->SendRef(mipMap->GetKey(), TRACKED_NEW plGenRefMsg(GetKey(), plRefMsg::kOnRequest, 0, kRefCosineLUT), plRefFlags::kActiveRef); @@ -1716,8 +1714,7 @@ void plWaveSet7::IAddBumpBiasLayer(hsGMaterial* mat) for( i = 0; i < 2; i++ ) { plLayer* layer = TRACKED_NEW plLayer; - char buff[256]; - sprintf(buff, "%s_%s_%d", GetKey()->GetName(), "Bias", i); + plString buff = plString::Format("%s_Bias_%d", GetKey()->GetName().c_str(), i); hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation()); layer->SetBlendFlags(hsGMatState::kBlendAdd); @@ -1752,8 +1749,7 @@ void plWaveSet7::IAddBumpBiasLayer(hsGMaterial* mat) plLayer* plWaveSet7::ICreateBumpLayerPS(plMipmap* mipMap, hsGMaterial* bumpMat, int which) { plLayer* layer = TRACKED_NEW plLayer; - char buff[256]; - sprintf(buff, "%s_%s_%d", GetKey()->GetName(), "BumpLayerPS", which); + plString buff = plString::Format("%s_BumpLayerPS_%d", GetKey()->GetName().c_str(), which); hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation()); layer->SetBlendFlags(which ? hsGMatState::kBlendAdd : 0); @@ -1810,8 +1806,7 @@ hsGMaterial* plWaveSet7::ICreateBumpLayersPS() // Create a blank material hsGMaterial* bumpMat = TRACKED_NEW hsGMaterial; - char buff[256]; - sprintf(buff, "%s_%s", GetKey()->GetName(), "BumpMatPS"); + plString buff = plString::Format("%s_BumpMatPS", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, bumpMat, GetKey()->GetUoid().GetLocation()); plMipmap* mipMap = ICreateBumpMipmapPS(); @@ -1852,8 +1847,7 @@ void plWaveSet7::IAddBumpBiasShaders(plLayer* layer) { plShader* vShader = TRACKED_NEW plShader; - char buff[256]; - sprintf(buff, "%s_BiasVS", GetKey()->GetName()); + plString buff = plString::Format("%s_BiasVS", GetKey()->GetName().c_str()); hsgResMgr::ResMgr()->NewKey(buff, vShader, GetKey()->GetUoid().GetLocation()); vShader->SetIsPixelShader(false); @@ -1916,8 +1910,7 @@ void plWaveSet7::IAddBumpBiasShaders(plLayer* layer) { plShader* pShader = TRACKED_NEW plShader; - char buff[256]; - sprintf(buff, "%s_BiasPS", GetKey()->GetName()); + plString buff = plString::Format("%s_BiasPS", GetKey()->GetName().c_str()); hsgResMgr::ResMgr()->NewKey(buff, pShader, GetKey()->GetUoid().GetLocation()); pShader->SetIsPixelShader(true); @@ -1950,8 +1943,7 @@ void plWaveSet7::IAddBumpVertexShader(hsGMaterial* mat, int iShader, int iFirst, int iShader = iBase / kBumpPerPass; plShader* vShader = TRACKED_NEW plShader; - char buff[256]; - sprintf(buff, "%s_BumpVS_%d", GetKey()->GetName(), iShader); + plString buff = plString::Format("%s_BumpVS_%d", GetKey()->GetName().c_str(), iShader); hsgResMgr::ResMgr()->NewKey(buff, vShader, GetKey()->GetUoid().GetLocation()); vShader->SetIsPixelShader(false); @@ -1996,8 +1988,7 @@ void plWaveSet7::IAddBumpPixelShader(hsGMaterial* mat, int iShader, int iFirst, int iShader = iBase / kBumpPerPass; plShader* pShader = TRACKED_NEW plShader; - char buff[256]; - sprintf(buff, "%s_BumpPS_%d", GetKey()->GetName(), iShader); + plString buff = plString::Format("%s_BumpPS_%d", GetKey()->GetName().c_str(), iShader); hsgResMgr::ResMgr()->NewKey(buff, pShader, GetKey()->GetUoid().GetLocation()); pShader->SetIsPixelShader(true); @@ -2039,8 +2030,7 @@ void plWaveSet7::IAddBumpPixelShader(hsGMaterial* mat, int iShader, int iFirst, plDrawableSpans* plWaveSet7::ICreateBumpDrawable() { fBumpDraw = TRACKED_NEW plDrawableSpans; - char buff[256]; - sprintf(buff, "%s_BumpDraw", GetKey()->GetName()); + plString buff = plString::Format("%s_BumpDraw", GetKey()->GetName().c_str()); hsgResMgr::ResMgr()->NewKey(buff, fBumpDraw, GetKey()->GetUoid().GetLocation()); ICreateClearDrawable(fBumpDraw, fBumpMat); @@ -2155,8 +2145,7 @@ plRenderTarget* plWaveSet7::ICreateTransferRenderTarget(const char* name, int si plRenderTarget* rt = TRACKED_NEW plRenderTarget(flags, size, size, bitDepth, zDepth, stencilDepth); - char buff[256]; - sprintf(buff, "%s_%s", GetKey()->GetName(), name); + plString buff = plString::Format("%s_%s", GetKey()->GetName().c_str(), name); hsgResMgr::ResMgr()->NewKey(buff, rt, GetKey()->GetUoid().GetLocation()); return rt; @@ -2168,8 +2157,7 @@ plLayer* plWaveSet7::ICreateTotalLayer(plBitmap* bm, hsGMaterial* mat, int which if( !layer ) { layer = TRACKED_NEW plLayer; - char buff[256]; - sprintf(buff, "%s_%sLayerPS_%d", GetKey()->GetName(), suff, which); + plString buff = plString::Format("%s_%sLayerPS_%d", GetKey()->GetName().c_str(), suff, which); hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation()); layer->SetAmbientColor(hsColorRGBA().Set(0.f, 0.f, 0.f, 1.f)); @@ -2203,8 +2191,7 @@ plLayer* plWaveSet7::ICreateTotalLayer(plBitmap* bm, hsGMaterial* mat, int which plLayer* plWaveSet7::ICreateTotalEnvLayer(plBitmap* envMap, hsGMaterial* mat, int which, const char* pref) { plLayer* layer = TRACKED_NEW plLayer; - char buff[256]; - sprintf(buff, "%s_%s_%s_%d", GetKey()->GetName(), pref, "EnvLayerPS", which); + plString buff = plString::Format("%s_%s_EnvLayerPS_%d", GetKey()->GetName().c_str(), pref, which); hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation()); layer->SetBlendFlags(which ? hsGMatState::kBlendAddSigned : 0); @@ -2304,8 +2291,7 @@ void plWaveSet7::IAddShoreVertexShader(hsGMaterial* mat) plShader* vShader = TRACKED_NEW plShader; - char buff[256]; - sprintf(buff, "%s_ShoreVS", GetKey()->GetName()); + plString buff = plString::Format("%s_ShoreVS", GetKey()->GetName().c_str()); hsgResMgr::ResMgr()->NewKey(buff, vShader, GetKey()->GetUoid().GetLocation()); vShader->SetIsPixelShader(false); @@ -2358,8 +2344,7 @@ void plWaveSet7::IAddShorePixelShader(hsGMaterial* mat) { plShader* pShader = TRACKED_NEW plShader; - char buff[256]; - sprintf(buff, "%s_ShorePS", GetKey()->GetName()); + plString buff = plString::Format("%s_ShorePS", GetKey()->GetName().c_str()); hsgResMgr::ResMgr()->NewKey(buff, pShader, GetKey()->GetUoid().GetLocation()); pShader->SetIsPixelShader(true); @@ -2382,8 +2367,7 @@ void plWaveSet7::IAddFixedVertexShader(hsGMaterial* mat, const int numUVWs) plShader* vShader = TRACKED_NEW plShader; - char buff[256]; - sprintf(buff, "%s_FixedVS", GetKey()->GetName()); + plString buff = plString::Format("%s_FixedVS", GetKey()->GetName().c_str()); hsgResMgr::ResMgr()->NewKey(buff, vShader, GetKey()->GetUoid().GetLocation()); vShader->SetIsPixelShader(false); @@ -2452,8 +2436,7 @@ void plWaveSet7::IAddFixedPixelShader(hsGMaterial* mat) if( !fFixedPShader ) { plShader* pShader = TRACKED_NEW plShader; - char buff[256]; - sprintf(buff, "%s_FixedPS", GetKey()->GetName()); + plString buff = plString::Format("%s_FixedPS", GetKey()->GetName().c_str()); hsgResMgr::ResMgr()->NewKey(buff, pShader, GetKey()->GetUoid().GetLocation()); pShader->SetIsPixelShader(true); @@ -2481,8 +2464,7 @@ void plWaveSet7::IAddRipVertexShader(hsGMaterial* mat, const plRipVSConsts& ripC if( !fRipVShader ) { plShader* vShader = TRACKED_NEW plShader; - char buff[256]; - sprintf(buff, "%s_RipVS", GetKey()->GetName()); + plString buff = plString::Format("%s_RipVS", GetKey()->GetName().c_str()); hsgResMgr::ResMgr()->NewKey(buff, vShader, GetKey()->GetUoid().GetLocation()); vShader->SetIsPixelShader(false); @@ -2567,8 +2549,7 @@ void plWaveSet7::IAddRipPixelShader(hsGMaterial* mat, const plRipVSConsts& ripCo if( !fRipPShader ) { plShader* pShader = TRACKED_NEW plShader; - char buff[256]; - sprintf(buff, "%s_RipPS", GetKey()->GetName()); + plString buff = plString::Format("%s_RipPS", GetKey()->GetName().c_str()); hsgResMgr::ResMgr()->NewKey(buff, pShader, GetKey()->GetUoid().GetLocation()); pShader->SetIsPixelShader(true); @@ -2627,8 +2608,7 @@ plShader* plWaveSet7::ICreateDecalVShader(DecalVType t) plShader* vShader = TRACKED_NEW plShader; - char buff[256]; - sprintf(buff, "%s_%s", GetKey()->GetName(), fname[t]); + plString buff = plString::Format("%s_%s", GetKey()->GetName().c_str(), fname[t]); hsgResMgr::ResMgr()->NewKey(buff, vShader, GetKey()->GetUoid().GetLocation()); vShader->SetIsPixelShader(false); @@ -2756,8 +2736,7 @@ plShader* plWaveSet7::ICreateDecalPShader(DecalPType t) plShader* pShader = TRACKED_NEW plShader; - char buff[256]; - sprintf(buff, "%s_%s", GetKey()->GetName(), fname[t]); + plString buff = plString::Format("%s_%s", GetKey()->GetName().c_str(), fname[t]); hsgResMgr::ResMgr()->NewKey(buff, pShader, GetKey()->GetUoid().GetLocation()); pShader->SetIsPixelShader(true); @@ -3698,8 +3677,7 @@ plDrawableSpans* plWaveSet7::ICreateGraphDrawable(plDrawableSpans* drawable, hsG plDrawableSpans* plWaveSet7::ICreateEmptyGraphDrawable(const char* name, UInt32 ref, int which) { plDrawableSpans* drawable = TRACKED_NEW plDrawableSpans; - char buff[256]; - sprintf(buff, "%s_%s_%d", GetKey()->GetName(), name, which); + plString buff = plString::Format("%s_%s_%d", GetKey()->GetName().c_str(), name, which); hsgResMgr::ResMgr()->NewKey(buff, drawable, GetKey()->GetUoid().GetLocation()); hsgResMgr::ResMgr()->SendRef(drawable->GetKey(), TRACKED_NEW plGenRefMsg(GetKey(), plRefMsg::kOnRequest, which, (Int8)ref), plRefFlags::kActiveRef); @@ -3711,8 +3689,7 @@ hsGMaterial* plWaveSet7::ICreateEmptyMaterial(const char* name, UInt32 ref, int { hsGMaterial* mat = TRACKED_NEW hsGMaterial; - char buff[256]; - sprintf(buff, "%s_%s_%d", GetKey()->GetName(), name, which); + plString buff = plString::Format("%s_%s_%d", GetKey()->GetName().c_str(), name, which); hsgResMgr::ResMgr()->NewKey(buff, mat, GetKey()->GetUoid().GetLocation()); hsgResMgr::ResMgr()->SendRef(mat->GetKey(), TRACKED_NEW plGenRefMsg(GetKey(), plRefMsg::kOnRequest, which, (Int8)ref), plRefFlags::kActiveRef); @@ -3723,8 +3700,7 @@ hsGMaterial* plWaveSet7::ICreateEmptyMaterial(const char* name, UInt32 ref, int plLayer* plWaveSet7::ICreateBlankLayer(const char* name, int suff) { plLayer* lay = TRACKED_NEW plLayer; - char buff[256]; - sprintf(buff, "%s_%s_%d", GetKey()->GetName(), name, suff); + plString buff = plString::Format("%s_%s_%d", GetKey()->GetName().c_str(), name, suff); hsgResMgr::ResMgr()->NewKey(buff, lay, GetKey()->GetUoid().GetLocation()); return lay; @@ -3739,8 +3715,7 @@ plMipmap* plWaveSet7::ICreateBlankTex(const char* name, int width, int height, U plMipmap::kUncompressed, plMipmap::UncompressedInfo::kRGB8888); - char buff[256]; - sprintf(buff, "%s_%s", GetKey()->GetName(), name); + plString buff = plString::Format("%s_%s", GetKey()->GetName().c_str(), name); hsgResMgr::ResMgr()->NewKey(buff, mipMap, GetKey()->GetUoid().GetLocation()); hsgResMgr::ResMgr()->SendRef(mipMap->GetKey(), TRACKED_NEW plGenRefMsg(GetKey(), plRefMsg::kOnRequest, 0, (Int8)ref), plRefFlags::kActiveRef); @@ -4146,8 +4121,7 @@ void plWaveSet7::IAddGraphVShader(hsGMaterial* mat, int iPass) if( !fGraphVShader[iPass] ) { plShader* vShader = TRACKED_NEW plShader; - char buff[256]; - sprintf(buff, "%s_GraphVS_%d", GetKey()->GetName(), iPass); + plString buff = plString::Format("%s_GraphVS_%d", GetKey()->GetName().c_str(), iPass); hsgResMgr::ResMgr()->NewKey(buff, vShader, GetKey()->GetUoid().GetLocation()); vShader->SetIsPixelShader(false); @@ -4181,8 +4155,7 @@ void plWaveSet7::IAddGraphPShader(hsGMaterial* mat, int iPass) if( !fGraphPShader[iPass] ) { plShader* pShader = TRACKED_NEW plShader; - char buff[256]; - sprintf(buff, "%s_GraphPS_%d", GetKey()->GetName(), iPass); + plString buff = plString::Format("%s_GraphPS_%d", GetKey()->GetName().c_str(), iPass); hsgResMgr::ResMgr()->NewKey(buff, pShader, GetKey()->GetUoid().GetLocation()); pShader->SetIsPixelShader(true); @@ -4252,11 +4225,11 @@ void plWaveSet7::ISetupGraphShore(hsGMaterial* mat) void plWaveSet7::IMakeShoreLayer(hsGMaterial* mat, int which) { - char name[512]; + plString name; if( which >= mat->GetNumLayers() ) { plLayer* lay = TRACKED_NEW plLayer; - sprintf(name, "%s_lay_%d", mat->GetKey()->GetName(), which); + name = plString::Format("%s_lay_%d", mat->GetKey()->GetName().c_str(), which); hsgResMgr::ResMgr()->NewKey(name, lay, GetKey()->GetUoid().GetLocation()); lay->SetAmbientColor(hsColorRGBA().Set(0.f, 0.f, 0.f, 1.f)); diff --git a/Sources/Plasma/PubUtilLib/plGImage/plFontCache.cpp b/Sources/Plasma/PubUtilLib/plGImage/plFontCache.cpp index f18149e0..4cf08662 100644 --- a/Sources/Plasma/PubUtilLib/plGImage/plFontCache.cpp +++ b/Sources/Plasma/PubUtilLib/plGImage/plFontCache.cpp @@ -179,10 +179,10 @@ void plFontCache::ILoadCustomFonts( void ) delete font; else { - char keyName[ 512 ]; + plString keyName; if( font->GetKey() == nil ) { - sprintf( keyName, "%s-%d", font->GetFace(), font->GetSize() ); + keyName = plString::Format( "%s-%d", font->GetFace(), font->GetSize() ); hsgResMgr::ResMgr()->NewKey( keyName, font, plLocation::kGlobalFixedLoc ); } diff --git a/Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp b/Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp index e2a3b8ff..03896355 100644 --- a/Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp +++ b/Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp @@ -373,7 +373,7 @@ hsBool plLightInfo::MsgReceive(plMessage* msg) plRenderMsg* rendMsg = plRenderMsg::ConvertNoRef(msg); if( rendMsg ) { - plProfile_BeginLap(LightInfo, this->GetKey()->GetUoid().GetObjectName()); + plProfile_BeginLap(LightInfo, this->GetKey()->GetUoid().GetObjectName().c_str()); if( !fDeviceRef && !GetProperty(kLPShadowOnly) ) { @@ -382,7 +382,7 @@ hsBool plLightInfo::MsgReceive(plMessage* msg) ICheckMaxStrength(); - plProfile_EndLap(LightInfo, this->GetKey()->GetUoid().GetObjectName()); + plProfile_EndLap(LightInfo, this->GetKey()->GetUoid().GetObjectName().c_str()); return true; } plGenRefMsg* refMsg = plGenRefMsg::ConvertNoRef(msg); @@ -395,7 +395,7 @@ hsBool plLightInfo::MsgReceive(plMessage* msg) case kProjection: fProjection = plLayerInterface::ConvertNoRef(refMsg->GetRef()); { - if( GetKey() && GetKey()->GetName() && !strncmp(GetKey()->GetName(), "RTPatternLight", strlen("RTPatternLight")) ) + if( GetKey() && !GetKey()->GetName().CompareN("RTPatternLight", strlen("RTPatternLight")) ) SetProperty(kLPForceProj, true); } break; diff --git a/Sources/Plasma/PubUtilLib/plGLight/plShadowCaster.cpp b/Sources/Plasma/PubUtilLib/plGLight/plShadowCaster.cpp index 2c89532b..28cc7f5b 100644 --- a/Sources/Plasma/PubUtilLib/plGLight/plShadowCaster.cpp +++ b/Sources/Plasma/PubUtilLib/plGLight/plShadowCaster.cpp @@ -214,9 +214,9 @@ hsBool plShadowCaster::MsgReceive(plMessage* msg) plRenderMsg* rendMsg = plRenderMsg::ConvertNoRef(msg); if( rendMsg ) { - plProfile_BeginLap(ShadowCaster, this->GetKey()->GetUoid().GetObjectName()); + plProfile_BeginLap(ShadowCaster, this->GetKey()->GetUoid().GetObjectName().c_str()); IOnRenderMsg(rendMsg); - plProfile_EndLap(ShadowCaster, this->GetKey()->GetUoid().GetObjectName()); + plProfile_EndLap(ShadowCaster, this->GetKey()->GetUoid().GetObjectName().c_str()); return true; } diff --git a/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp b/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp index c6b68fa3..098d9f10 100644 --- a/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp +++ b/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp @@ -180,9 +180,9 @@ hsBool plShadowMaster::MsgReceive(plMessage* msg) plRenderMsg* rendMsg = plRenderMsg::ConvertNoRef(msg); if( rendMsg ) { - plProfile_BeginLap(ShadowMaster, this->GetKey()->GetUoid().GetObjectName()); + plProfile_BeginLap(ShadowMaster, this->GetKey()->GetUoid().GetObjectName().c_str()); IBeginRender(); - plProfile_EndLap(ShadowMaster, this->GetKey()->GetUoid().GetObjectName()); + plProfile_EndLap(ShadowMaster, this->GetKey()->GetUoid().GetObjectName().c_str()); return true; } diff --git a/Sources/Plasma/PubUtilLib/plModifier/plCloneSpawnModifier.cpp b/Sources/Plasma/PubUtilLib/plModifier/plCloneSpawnModifier.cpp index c75c616b..88e36511 100644 --- a/Sources/Plasma/PubUtilLib/plModifier/plCloneSpawnModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plModifier/plCloneSpawnModifier.cpp @@ -106,7 +106,7 @@ plKey plCloneSpawnModifier::SpawnClone(const char* cloneName, const char* cloneA const plLocation& loc = plKeyFinder::Instance().FindLocation(cloneAge, "BuiltIn"); // Find the clone template key - plUoid objUoid(loc, plSceneObject::Index(), cloneName); + plUoid objUoid(loc, plSceneObject::Index(), _TEMP_CONVERT_FROM_LITERAL(cloneName)); plKey key = resMgr->FindKey(objUoid); if (key) diff --git a/Sources/Plasma/PubUtilLib/plModifier/plResponderModifier.cpp b/Sources/Plasma/PubUtilLib/plModifier/plResponderModifier.cpp index a27c8cdd..d0e62679 100644 --- a/Sources/Plasma/PubUtilLib/plModifier/plResponderModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plModifier/plResponderModifier.cpp @@ -775,7 +775,7 @@ void plResponderModifier::ILog(UInt32 color, const char* format, ...) if (!format || *format == '\0') return; - const char* keyName = GetKeyName(); + const char* keyName = _TEMP_CONVERT_TO_CONST_CHAR(GetKeyName()); // Make sure this key isn't in our list of keys to deny for (int i = 0; i < gNoLogStrings.size(); i++) diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp index f5955522..73941f36 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp @@ -181,7 +181,7 @@ void plNCAgeJoiner::IDispatchMsgReceiveCallback () { void plNCAgeJoiner::IResMgrProgressBarCallback (plKey key) { #ifndef PLASMA_EXTERNAL_RELEASE if (s_instance) - s_instance->progressBar->SetStatusText(key->GetName()); + s_instance->progressBar->SetStatusText(_TEMP_CONVERT_TO_CONST_CHAR(key->GetName())); #endif } diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp index 5bed98b7..6c374809 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp @@ -1480,7 +1480,7 @@ void plNetClientMgr::AddPendingLoad(PendingLoad *pl) pl->fKey = hsgResMgr::ResMgr()->FindKey(pl->fUoid); // check for age SDL state - if (pl->fUoid.GetObjectName() && !strcmp(pl->fUoid.GetObjectName(), plSDL::kAgeSDLObjectName)) + if (!pl->fUoid.GetObjectName().IsNull() && !pl->fUoid.GetObjectName().Compare(plSDL::kAgeSDLObjectName)) { DebugMsg("Recv SDL state for age hook object, uoid=%s", pl->fUoid.StringIze().c_str()); if (!pl->fKey) diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetObjectDebugger.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetObjectDebugger.cpp index 1350adac..2eb22fef 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetObjectDebugger.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetObjectDebugger.cpp @@ -130,7 +130,7 @@ bool plNetObjectDebugger::DebugObject::ObjectMatches(const hsKeyedObject* obj) if ((fFlags & kPageMatch)==0) { // match based on object name only - return StringMatches(obj->GetKeyName()); + return StringMatches(_TEMP_CONVERT_TO_CONST_CHAR(obj->GetKeyName())); } return (obj->GetKey()->GetUoid().GetLocation()==fLoc); diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetVoiceList.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetVoiceList.cpp index 833facbf..edcc33af 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetVoiceList.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetVoiceList.cpp @@ -88,7 +88,7 @@ void plNetTalkList::AddMember(plNetTransportMember* e) { if (FindMember(e)==-1) { - plStatusLog::AddLineS("voice.log", "Adding %s to talk list", e->AsStdString().c_str()); + plStatusLog::AddLineS("voice.log", "Adding %s to talk list", e->AsString().c_str()); fMembers.push_back(e); } fFlags |= kDirty; @@ -99,7 +99,7 @@ void plNetTalkList::RemoveMember(plNetTransportMember* e) int idx=FindMember(e); if (idx!=-1) { - plStatusLog::AddLineS("voice.log", "Removing %s from talklist", e->AsStdString().c_str()); + plStatusLog::AddLineS("voice.log", "Removing %s from talklist", e->AsString().c_str()); fMembers.erase(fMembers.begin()+idx); } fFlags |= kDirty; @@ -122,7 +122,7 @@ void plNetListenList::AddMember(plNetTransportMember* e) { if (FindMember(e)==-1) { - plStatusLog::AddLineS("voice.log", "Adding %s to listen list ", e->AsStdString().c_str()); + plStatusLog::AddLineS("voice.log", "Adding %s to listen list ", e->AsString().c_str()); fMembers.push_back(e); #if 0 @@ -146,7 +146,7 @@ void plNetListenList::RemoveMember(plNetTransportMember* e) if (idx!=-1) { fMembers.erase(fMembers.begin()+idx); - plStatusLog::AddLineS("voice.log", "Removing %s from listen list", e->AsStdString().c_str()); + plStatusLog::AddLineS("voice.log", "Removing %s from listen list", e->AsString().c_str()); #if 0 // call the new member's win audible and set talk icon parameters diff --git a/Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgScreener.cpp b/Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgScreener.cpp index e1e93b19..6d2a6d51 100644 --- a/Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgScreener.cpp +++ b/Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgScreener.cpp @@ -76,8 +76,8 @@ void plNetMsgScreener::IRejectLogMsg(Int16 classIndex, const char* desc, const p // void plNetMsgScreener::IRejectLogMsg(const plMessage* msg, const char* desc, const plNetGameMember* gm) const { - const char* senderName = msg->GetSender() ? msg->GetSender()->GetUoid().GetObjectName() : "?"; - const char* rcvrName = msg->GetNumReceivers() && msg->GetReceiver(0) ? msg->GetReceiver(0)->GetUoid().GetObjectName() : "?"; + const char* senderName = msg->GetSender() ? msg->GetSender()->GetUoid().GetObjectName().c_str() : "?"; + const char* rcvrName = msg->GetNumReceivers() && msg->GetReceiver(0) ? msg->GetReceiver(0)->GetUoid().GetObjectName().c_str() : "?"; DebugMsg("Message %s was rejected, reason:%s, age:%s, client:%s, msgSndr:%s, msgRcvr:%s", msg->ClassName(), desc, IGetAgeName(), IGetSenderName(gm), diff --git a/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.cpp b/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.cpp index 13f08f47..49d7248d 100644 --- a/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.cpp +++ b/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.cpp @@ -828,13 +828,6 @@ void plNetMsgSDLStateBCast::WriteVersion(hsStream* s, hsResMgr* mgr) //////////////////////////////////////////////////////// // plNetMsgRoomsList //////////////////////////////////////////////////////// -plNetMsgRoomsList::~plNetMsgRoomsList() -{ - int i; - for(i=0;iLogSubStreamPushDesc("RoomList"); plMsgCStringHelper::Peek(fRoomNames[i],stream,peekOptions); } @@ -884,13 +876,13 @@ int plNetMsgRoomsList::IPeekBuffer(hsStream* stream, UInt32 peekOptions) void plNetMsgRoomsList::AddRoom(plKey rmKey) { fRooms.push_back(rmKey->GetUoid().GetLocation()); - fRoomNames.push_back(hsStrcpy(rmKey->GetName())); + fRoomNames.push_back(rmKey->GetName()); } -void plNetMsgRoomsList::AddRoomLocation(plLocation loc, const char* rmName) +void plNetMsgRoomsList::AddRoomLocation(plLocation loc, const plString& rmName) { fRooms.push_back(loc); - fRoomNames.push_back(rmName ? hsStrcpy(rmName) : nil); + fRoomNames.push_back(rmName); } int plNetMsgRoomsList::FindRoomLocation(plLocation loc) diff --git a/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.h b/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.h index e02a3b4b..d815c2ba 100644 --- a/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.h +++ b/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.h @@ -451,24 +451,24 @@ class plNetMsgRoomsList : public plNetMessage { protected: std::vector fRooms; - std::vector fRoomNames; // for debug usage only + std::vector fRoomNames; // for debug usage only int IPokeBuffer(hsStream* stream, UInt32 peekOptions=0); int IPeekBuffer(hsStream* stream, UInt32 peekOptions=0); public: plNetMsgRoomsList() {} - ~plNetMsgRoomsList(); + ~plNetMsgRoomsList() {}; CLASSNAME_REGISTER( plNetMsgRoomsList ); GETINTERFACE_ANY( plNetMsgRoomsList, plNetMessage ); void AddRoom(plKey rmKey); - void AddRoomLocation(plLocation loc, const char* rmName); + void AddRoomLocation(plLocation loc, const plString& rmName); int FindRoomLocation(plLocation loc); int GetNumRooms() const { return fRooms.size(); } plLocation GetRoomLoc(int i) const { return fRooms[i]; } - const char* GetRoomName(int i) const { return fRoomNames[i]; } // debug + plString GetRoomName(int i) const { return fRoomNames[i]; } // debug }; // diff --git a/Sources/Plasma/PubUtilLib/plNetMessage/plNetMsgHelpers.cpp b/Sources/Plasma/PubUtilLib/plNetMessage/plNetMsgHelpers.cpp index ec2a5ce8..ca8b0b2b 100644 --- a/Sources/Plasma/PubUtilLib/plNetMessage/plNetMsgHelpers.cpp +++ b/Sources/Plasma/PubUtilLib/plNetMessage/plNetMsgHelpers.cpp @@ -364,7 +364,7 @@ int plNetMsgObjectHelper::Peek(hsStream* stream, const UInt32 peekOptions) hsBool plNetMsgObjectHelper::SetFromKey(const plKey &key) { - if (!key || !key->GetName()) + if (!key || key->GetName().IsNull()) return false; fUoid = key->GetUoid(); diff --git a/Sources/Plasma/PubUtilLib/plNetMessage/plNetMsgHelpers.h b/Sources/Plasma/PubUtilLib/plNetMessage/plNetMsgHelpers.h index 0707936f..2d1aa53d 100644 --- a/Sources/Plasma/PubUtilLib/plNetMessage/plNetMsgHelpers.h +++ b/Sources/Plasma/PubUtilLib/plNetMessage/plNetMsgHelpers.h @@ -213,7 +213,7 @@ public: void SetUoid(const plUoid &u) { fUoid=u; } // getters - const char* GetObjectName() const { return fUoid.GetObjectName(); } + const plString& GetObjectName() const { return fUoid.GetObjectName(); } UInt32 GetPageID() const { return fUoid.GetLocation().GetSequenceNumber(); } const plUoid& GetUoid() const { return fUoid; } diff --git a/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEmitter.cpp b/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEmitter.cpp index fe865742..ae200e97 100644 --- a/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEmitter.cpp +++ b/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEmitter.cpp @@ -324,7 +324,7 @@ void plParticleEmitter::IUpdateParticles(hsScalar delta) if ((fGenerator != nil) && (fTimeToLive >= 0)) { - plProfile_BeginLap(ParticleGenerate, fSystem->GetKeyName()); + plProfile_BeginLap(ParticleGenerate, fSystem->GetKeyName().c_str()); if (!fGenerator->AddAutoParticles(this, delta)) { delete fGenerator; @@ -332,7 +332,7 @@ void plParticleEmitter::IUpdateParticles(hsScalar delta) } if( (fTimeToLive > 0) && ((fTimeToLive -= delta) <= 0) ) fTimeToLive = -1.f; - plProfile_EndLap(ParticleGenerate, fSystem->GetKeyName()); + plProfile_EndLap(ParticleGenerate, fSystem->GetKeyName().c_str()); } fTargetInfo.fContext = fSystem->fContext; diff --git a/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleSystem.cpp b/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleSystem.cpp index c07c9492..96c88d73 100644 --- a/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleSystem.cpp +++ b/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleSystem.cpp @@ -486,9 +486,9 @@ hsBool plParticleSystem::MsgReceive(plMessage* msg) if ((rend = plRenderMsg::ConvertNoRef(msg))) { - plProfile_BeginLap(ParticleSys, this->GetKey()->GetUoid().GetObjectName()); + plProfile_BeginLap(ParticleSys, this->GetKey()->GetUoid().GetObjectName().c_str()); IHandleRenderMsg(rend->Pipeline()); - plProfile_EndLap(ParticleSys, this->GetKey()->GetUoid().GetObjectName()); + plProfile_EndLap(ParticleSys, this->GetKey()->GetUoid().GetObjectName().c_str()); return true; } else if ((refMsg = plGenRefMsg::ConvertNoRef(msg))) diff --git a/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp b/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp index 99a210df..c46a8b05 100644 --- a/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp +++ b/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp @@ -493,7 +493,7 @@ hsBool plPXPhysical::Init(PhysRecipe& recipe) } actorDesc.userData = this; - actorDesc.name = GetKeyName(); + actorDesc.name = GetKeyName().c_str(); // Put the dynamics into actor group 1. The actor groups are only used for // deciding who we get contact reports for. @@ -617,7 +617,7 @@ hsBool plPXPhysical::HandleRefMsg(plGenRefMsg* refMsg) plKey ourKey = GetKey(); PhysRefType refType = PhysRefType(refMsg->fType); - const char* refKeyName = refKey ? refKey->GetName() : "MISSING"; + plString refKeyName = refKey ? refKey->GetName() : _TEMP_CONVERT_FROM_LITERAL("MISSING"); if (refType == kPhysRefWorld) { @@ -695,11 +695,11 @@ plPhysical& plPXPhysical::SetProperty(int prop, hsBool status) case plSimulationInterface::kNoSynchronize: propName = "kNoSynchronize"; break; } - const char* name = "(unknown)"; + plString name = _TEMP_CONVERT_FROM_LITERAL("(unknown)"); if (GetKey()) name = GetKeyName(); if (plSimulationMgr::fExtraProfile) - plSimulationMgr::Log("Warning: Redundant physical property set (property %s, value %s) on %s", propName, status ? "true" : "false", name); + plSimulationMgr::Log("Warning: Redundant physical property set (property %s, value %s) on %s", propName, status ? "true" : "false", name.c_str()); } switch (prop) @@ -786,7 +786,7 @@ void plPXPhysical::SendNewLocation(hsBool synchTransform, hsBool isSynchUpdate) if (!CompareMatrices(curl2w, fCachedLocal2World, .0001f)) { plProfile_Inc(LocationsSent); - plProfile_BeginLap(PhysicsUpdates, GetKeyName()); + plProfile_BeginLap(PhysicsUpdates, GetKeyName().c_str()); // quick peek at the translation...last time it was corrupted because we applied a non-unit quaternion // hsAssert(real_finite(fCachedLocal2World.fMap[0][3]) && @@ -808,7 +808,7 @@ void plPXPhysical::SendNewLocation(hsBool synchTransform, hsBool isSynchUpdate) pCorrMsg->Send(); if (fProxyGen) fProxyGen->SetTransform(fCachedLocal2World, w2l); - plProfile_EndLap(PhysicsUpdates, GetKeyName()); + plProfile_EndLap(PhysicsUpdates, GetKeyName().c_str()); } } } diff --git a/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp b/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp index 52d5320e..df15e972 100644 --- a/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp @@ -208,7 +208,7 @@ class SensorReport : public NxUserTriggerReport void SendCollisionMsg(plKey receiver, plKey hitter, hsBool entering) { DetectorLogYellow("Collision: %s was triggered by %s. Sending an %s msg", receiver->GetName(), - hitter ? hitter->GetName() : "(nil)" , entering ? "'enter'" : "'exit'"); + hitter ? hitter->GetName().c_str() : "(nil)" , entering ? "'enter'" : "'exit'"); plCollideMsg* msg = TRACKED_NEW plCollideMsg; msg->fOtherKey = hitter; msg->fEntering = entering; @@ -537,8 +537,8 @@ void plSimulationMgr::ReleaseScene(plKey world) void plSimulationMgr::ISendCollisionMsg(plKey receiver, plKey hitter, hsBool entering) { - DetectorLogYellow("Collision: %s is inside %s. Sending an %s msg", hitter ? hitter->GetName() : "(nil)", - receiver->GetName(), entering ? "'enter'" : "'exit'"); + DetectorLogYellow("Collision: %s is inside %s. Sending an %s msg", hitter ? hitter->GetName().c_str() : "(nil)", + receiver->GetName().c_str(), entering ? "'enter'" : "'exit'"); plCollideMsg* msg = TRACKED_NEW plCollideMsg; msg->fOtherKey = hitter; msg->fEntering = entering; @@ -740,10 +740,10 @@ void plSimulationMgr::ISendUpdates() const plKey physKey = physical->GetKey(); if (physKey) { - const char *physName = physical->GetKeyName(); - if (physName) + const plString &physName = physical->GetKeyName(); + if (!physName.IsNull()) { - plSimulationMgr::Log("Removing physical <%s> because of missing scene node.\n", physName); + plSimulationMgr::Log("Removing physical <%s> because of missing scene node.\n", physName.c_str()); } } // Remove(physical); diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plCaptureRender.cpp b/Sources/Plasma/PubUtilLib/plPipeline/plCaptureRender.cpp index c0a2284a..5f5abe5a 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plCaptureRender.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/plCaptureRender.cpp @@ -138,8 +138,7 @@ hsBool plCaptureRender::Capture(const plKey& ack, UInt16 width, UInt16 height) plRenderTarget* rt = TRACKED_NEW plRenderTarget(flags, width, height, bitDepth, zDepth, stencilDepth); static int idx=0; - char buff[32]; - sprintf(buff, "tRT%d", idx++); + plString buff = plString::Format("tRT%d", idx++); hsgResMgr::ResMgr()->NewKey(buff, rt, ack->GetUoid().GetLocation()); @@ -181,8 +180,7 @@ hsBool plCaptureRender::IProcess(plPipeline* pipe, const plKey& ack, plRenderTar static int currentCapIndex = 0; // Mipmap isn't created with a key so let's give it one now - char buff[512]; - sprintf(buff, "CaptureRender_%d", currentCapIndex++); + plString buff = plString::Format("CaptureRender_%d", currentCapIndex++); hsgResMgr::ResMgr()->NewKey(buff, mipMap, plLocation::kGlobalFixedLoc); mipMap->Ref(); diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plDXDeviceRefs.cpp b/Sources/Plasma/PubUtilLib/plPipeline/plDXDeviceRefs.cpp index c589e264..db79af42 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plDXDeviceRefs.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/plDXDeviceRefs.cpp @@ -235,7 +235,7 @@ void plDXTextureRef::Release( void ) { plProfile_DelMem(MemTexture, fDataSize + sizeof(plDXTextureRef)); plProfile_Extern(ManagedMem); - PROFILE_POOL_MEM(D3DPOOL_MANAGED, fDataSize, false, (fOwner ? fOwner->GetKey() ? fOwner->GetKey()->GetUoid().GetObjectName() : "(UnknownTexture)" : "(UnknownTexture)")); + PROFILE_POOL_MEM(D3DPOOL_MANAGED, fDataSize, false, (fOwner ? fOwner->GetKey() ? fOwner->GetKey()->GetUoid().GetObjectName().c_str() : "(UnknownTexture)" : "(UnknownTexture)")); plDXPipeline::FreeManagedTexture(fDataSize); fDataSize = 0; diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp b/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp index 347c0fad..7a8fb12c 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp @@ -1333,10 +1333,10 @@ hsBool plDXPipeline::ICreateDeviceObjects() /// Ok, we're done now #if MCN_BOUNDS_SPANS fBoundsSpans = TRACKED_NEW plDrawableSpans(); - hsgResMgr::ResMgr()->NewKey( "BoundsSpans", fBoundsSpans, plLocation::kGlobalFixedLoc ); + hsgResMgr::ResMgr()->NewKey( _TEMP_CONVERT_FROM_LITERAL("BoundsSpans"), fBoundsSpans, plLocation::kGlobalFixedLoc ); fBoundsSpans->SetNativeProperty( plDrawable::kPropVolatile, true ); fBoundsMat = TRACKED_NEW hsGMaterial(); - hsgResMgr::ResMgr()->NewKey( "BoundsMaterial", fBoundsMat, plLocation::kGlobalFixedLoc ); + hsgResMgr::ResMgr()->NewKey( _TEMP_CONVERT_FROM_LITERAL("BoundsMaterial"), fBoundsMat, plLocation::kGlobalFixedLoc ); plLayer *lay = fBoundsMat->MakeBaseLayer(); lay->SetMiscFlags( hsGMatState::kMiscWireFrame | hsGMatState::kMiscTwoSided ); lay->SetShadeFlags( lay->GetShadeFlags() | hsGMatState::kShadeWhite ); @@ -8304,11 +8304,11 @@ IDirect3DTexture9 *plDXPipeline::IMakeD3DTexture( plDXTextureRef *ref, D3DFORM IGetD3DError(); plStatusLog::AddLineS( "pipeline.log", 0xffff0000, "Unable to create texture (%s) Owner: %s " "Size: %d x %d NumLvls: %d Flags: %x", - fSettings.fErrorStr, ref->fOwner ? ref->fOwner->GetKey() ? ref->fOwner->GetKey()->GetUoid().GetObjectName() : "" : "", + fSettings.fErrorStr, ref->fOwner ? ref->fOwner->GetKey() ? ref->fOwner->GetKey()->GetUoid().GetObjectName().c_str() : "" : "", ref->fMaxWidth, ref->fMaxHeight, ref->fMMLvs, ref->GetFlags() ); return nil; } - PROFILE_POOL_MEM(poolType, ref->fDataSize, true, (ref->fOwner ? ref->fOwner->GetKey() ? ref->fOwner->GetKey()->GetUoid().GetObjectName() : "(UnknownTexture)" : "(UnknownTexture)")); + PROFILE_POOL_MEM(poolType, ref->fDataSize, true, (ref->fOwner ? ref->fOwner->GetKey() ? ref->fOwner->GetKey()->GetUoid().GetObjectName().c_str() : "(UnknownTexture)" : "(UnknownTexture)")); fTexManaged += ref->fDataSize; return texPtr; @@ -8326,7 +8326,7 @@ void plDXPipeline::IFillD3DTexture( plDXTextureRef *ref ) if( pTexDat == nil ) { plStatusLog::AddLineS( "pipeline.log", 0xffff0000, "Unable to fill texture ref (data is nil) Owner: %s", - ref->fOwner ? ref->fOwner->GetKey() ? ref->fOwner->GetKey()->GetUoid().GetObjectName() : "" : "" ); + ref->fOwner ? ref->fOwner->GetKey() ? ref->fOwner->GetKey()->GetUoid().GetObjectName().c_str() : "" : "" ); return; } @@ -8341,7 +8341,7 @@ void plDXPipeline::IFillD3DTexture( plDXTextureRef *ref ) IGetD3DError(); plStatusLog::AddLineS( "pipeline.log", 0xffff0000, "Unable to lock texture level %d for filling (%s) Owner: %s " "Size: %d x %d NumLvls: %d Flags: %x", - i, fSettings.fErrorStr, ref->fOwner ? ref->fOwner->GetKey() ? ref->fOwner->GetKey()->GetUoid().GetObjectName() : "" : "", + i, fSettings.fErrorStr, ref->fOwner ? ref->fOwner->GetKey() ? ref->fOwner->GetKey()->GetUoid().GetObjectName().c_str() : "" : "", ref->fMaxWidth, ref->fMaxHeight, ref->fMMLvs, ref->GetFlags() ); return; } @@ -8361,7 +8361,7 @@ IDirect3DCubeTexture9 *plDXPipeline::IMakeD3DCubeTexture( plDXTextureRef *ref, IDirect3DCubeTexture9 *texPtr = nil; fManagedAlloced = true; WEAK_ERROR_CHECK(fD3DDevice->CreateCubeTexture( ref->fMaxWidth, ref->fMMLvs, 0, formatType, poolType, &texPtr, NULL)); - PROFILE_POOL_MEM(poolType, ref->fDataSize, true, (ref->fOwner ? ref->fOwner->GetKey() ? ref->fOwner->GetKey()->GetUoid().GetObjectName() : "(UnknownTexture)" : "(UnknownTexture)")); + PROFILE_POOL_MEM(poolType, ref->fDataSize, true, (ref->fOwner ? ref->fOwner->GetKey() ? ref->fOwner->GetKey()->GetUoid().GetObjectName().c_str() : "(UnknownTexture)" : "(UnknownTexture)")); fTexManaged += ref->fDataSize; return texPtr; } @@ -9367,7 +9367,7 @@ void plDXPipeline::IMakeOcclusionSnap() ident.Reset(); hsGMaterial* mat = TRACKED_NEW hsGMaterial; - hsgResMgr::ResMgr()->NewKey( "OcclusionSnapMat", mat, plLocation::kGlobalFixedLoc ); + hsgResMgr::ResMgr()->NewKey( _TEMP_CONVERT_FROM_LITERAL("OcclusionSnapMat"), mat, plLocation::kGlobalFixedLoc ); plLayer *lay = mat->MakeBaseLayer(); lay->SetZFlags(hsGMatState::kZNoZWrite); lay->SetPreshadeColor(hsColorRGBA().Set(1.f, 0.5f, 0.5f, 1.f)); diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plDynamicEnvMap.cpp b/Sources/Plasma/PubUtilLib/plPipeline/plDynamicEnvMap.cpp index 3d4489dd..4982d066 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plDynamicEnvMap.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/plDynamicEnvMap.cpp @@ -439,9 +439,7 @@ void plDynamicEnvMap::Read(hsStream* s, hsResMgr* mgr) nVis = s->ReadLE32(); for( i = 0; i < nVis; i++) { - char *name = s->ReadSafeString(); - plKey key = plKeyFinder::Instance().StupidSearch(nil, nil, plVisRegion::Index(), name); - delete[] name; + plKey key = plKeyFinder::Instance().StupidSearch(nil, nil, plVisRegion::Index(), s->ReadSafeString_TEMP()); if (key) hsgResMgr::ResMgr()->AddViaNotify(key, TRACKED_NEW plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, kRefVisSet), plRefFlags::kActiveRef); } @@ -910,9 +908,7 @@ void plDynamicCamMap::Read(hsStream* s, hsResMgr* mgr) nVis = s->ReadLE32(); for( i = 0; i < nVis; i++) { - char *name = s->ReadSafeString(); - plKey key = plKeyFinder::Instance().StupidSearch(nil, nil, plVisRegion::Index(), name); - delete[] name; + plKey key = plKeyFinder::Instance().StupidSearch(nil, nil, plVisRegion::Index(), s->ReadSafeString_TEMP()); if (key) hsgResMgr::ResMgr()->AddViaNotify(key, TRACKED_NEW plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, kRefVisSet), plRefFlags::kActiveRef); } diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp b/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp index 119742e4..46e30bcf 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/plPlates.cpp @@ -164,10 +164,10 @@ void plPlate::SetTexture(plBitmap *texture) { plLayer *layer; hsGMaterial *material; - char keyName[ 128 ]; + plString keyName; material = TRACKED_NEW hsGMaterial(); - sprintf( keyName, "PlateBlank#%d", fMagicUniqueKeyInt++ ); + keyName = plString::Format( "PlateBlank#%d", fMagicUniqueKeyInt++ ); hsgResMgr::ResMgr()->NewKey( keyName, material, plLocation::kGlobalFixedLoc ); layer = material->MakeBaseLayer(); layer->SetShadeFlags( layer->GetShadeFlags() | hsGMatState::kShadeNoShade | hsGMatState::kShadeWhite | hsGMatState::kShadeReallyNoFog ); @@ -202,7 +202,7 @@ plMipmap *plPlate::CreateMaterial( UInt32 width, UInt32 height, hsBool withAl { plLayer *layer; hsGMaterial *material; - char keyName[ 128 ]; + plString keyName; if (texture) @@ -214,14 +214,14 @@ plMipmap *plPlate::CreateMaterial( UInt32 width, UInt32 height, hsBool withAl /// Create a new bitmap fMipmap = TRACKED_NEW plMipmap( width, height, withAlpha ? plMipmap::kARGB32Config : plMipmap::kRGB32Config, 1 ); memset( fMipmap->GetImage(), 0xff, height * fMipmap->GetRowBytes() ); - sprintf( keyName, "PlateBitmap#%d", fMagicUniqueKeyInt++ ); + keyName = plString::Format( "PlateBitmap#%d", fMagicUniqueKeyInt++ ); hsgResMgr::ResMgr()->NewKey( keyName, fMipmap, plLocation::kGlobalFixedLoc ); fMipmap->SetFlags( fMipmap->GetFlags() | plMipmap::kDontThrowAwayImage ); } /// NOW create a layer wrapper and a material for that layer material = TRACKED_NEW hsGMaterial(); - sprintf( keyName, "PlateBlank#%d", fMagicUniqueKeyInt++ ); + keyName = plString::Format( "PlateBlank#%d", fMagicUniqueKeyInt++ ); hsgResMgr::ResMgr()->NewKey( keyName, material, plLocation::kGlobalFixedLoc ); layer = material->MakeBaseLayer(); layer->SetShadeFlags( layer->GetShadeFlags() | hsGMatState::kShadeNoShade | hsGMatState::kShadeWhite | hsGMatState::kShadeReallyNoFog ); @@ -252,8 +252,7 @@ void plPlate::CreateFromResource(const char *resName) plMipmap* resTexture = TRACKED_NEW plMipmap; resTexture->CopyFrom(plClientResMgr::Instance().getResource(resName)); - char keyName[128]; - sprintf( keyName, "PlateResource#%d", fMagicUniqueKeyInt++ ); + plString keyName = plString::Format( "PlateResource#%d", fMagicUniqueKeyInt++ ); hsgResMgr::ResMgr()->NewKey(keyName, resTexture, plLocation::kGlobalFixedLoc); CreateMaterial(resTexture->GetWidth(), resTexture->GetHeight(), true, resTexture); } diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp index 45476472..6d559308 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp @@ -109,12 +109,7 @@ hsBool NameMatches(const char* obName, const char* pKName, hsBool subString) } else { - char oCopy[256], pCopy[256]; - strcpy(oCopy, o); - strcpy(pCopy, p); - hsStrLower(oCopy); - hsStrLower(pCopy); - if (strstr(pCopy, oCopy)) + if (plString(_TEMP_CONVERT_FROM_LITERAL(p)).Find(p, plString::kCaseInsensitive) >= 0) return true; } @@ -122,7 +117,7 @@ hsBool NameMatches(const char* obName, const char* pKName, hsBool subString) } plKey plKeyFinder::StupidSearch(const char * age, const char * rm, - const char *className, const char *obName, hsBool subString) + const char *className, const plString &obName, hsBool subString) { UInt16 ty = plFactory::FindClassIndex(className); return StupidSearch(age, rm, ty, obName, subString); @@ -132,7 +127,7 @@ class plKeyFinderIter : public plRegistryKeyIterator, public plRegistryPageItera { protected: UInt16 fClassType; - const char *fObjName; + plString fObjName; hsBool fSubstr; plKey fFoundKey; const char *fAgeName; @@ -140,17 +135,17 @@ protected: public: plKey GetFoundKey( void ) const { return fFoundKey; } - plKeyFinderIter( UInt16 classType, const char *obName, hsBool substr ) + plKeyFinderIter( UInt16 classType, const plString &obName, hsBool substr ) : fFoundKey( nil ), fClassType( classType ), fObjName( obName ), fSubstr( substr ) { } - plKeyFinderIter( UInt16 classType, const char *obName, hsBool substr, const char *ageName ) + plKeyFinderIter( UInt16 classType, const plString &obName, hsBool substr, const char *ageName ) : fFoundKey( nil ), fClassType( classType ), fObjName( obName ), fSubstr( substr ), fAgeName( ageName ) {} virtual hsBool EatKey( const plKey& key ) { if( key->GetUoid().GetClassType() == fClassType && - NameMatches( fObjName, key->GetUoid().GetObjectName(), fSubstr ) ) + NameMatches( fObjName.c_str(), key->GetUoid().GetObjectName().c_str(), fSubstr ) ) { fFoundKey = key; return false; @@ -187,9 +182,9 @@ public: }; plKey plKeyFinder::StupidSearch(const char * age, const char * rm, - UInt16 classType, const char *obName, hsBool subString) + UInt16 classType, const plString &obName, hsBool subString) { - if (!obName) + if (obName.IsNull()) return nil; plUoid newOid; @@ -239,12 +234,12 @@ plKey plKeyFinder::StupidSearch(const char * age, const char * rm, return nil; } -void plKeyFinder::ReallyStupidResponderSearch(const char *name, std::vector& foundKeys, const plLocation &hintLocation ) +void plKeyFinder::ReallyStupidResponderSearch(const plString &name, std::vector& foundKeys, const plLocation &hintLocation ) { ReallyStupidSubstringSearch(name, CLASS_INDEX_SCOPED(plResponderModifier), foundKeys, hintLocation); } -void plKeyFinder::ReallyStupidActivatorSearch(const char *name, std::vector& foundKeys, const plLocation &hintLocation) +void plKeyFinder::ReallyStupidActivatorSearch(const plString &name, std::vector& foundKeys, const plLocation &hintLocation) { // use the createable macro so we don't have to pull in all of Python ReallyStupidSubstringSearch(name, CLASS_INDEX_SCOPED(plLogicModifier), foundKeys, hintLocation); @@ -252,7 +247,7 @@ void plKeyFinder::ReallyStupidActivatorSearch(const char *name, std::vector& names, const char* searchName, int index) +void plKeyFinder::IGetNames(std::vector& names, const plString& searchName, int index) { // Not really searching for any particular key, just need all the logic mods std::vector keys; @@ -267,14 +262,14 @@ void plKeyFinder::IGetNames(std::vector& names, const char* searchN } } -void plKeyFinder::GetResponderNames(std::vector& names) +void plKeyFinder::GetResponderNames(std::vector& names) { - IGetNames(names, "", CLASS_INDEX_SCOPED(plResponderModifier)); + IGetNames(names, _TEMP_CONVERT_FROM_LITERAL(""), CLASS_INDEX_SCOPED(plResponderModifier)); } -void plKeyFinder::GetActivatorNames(std::vector& names) +void plKeyFinder::GetActivatorNames(std::vector& names) { - IGetNames(names, "", CLASS_INDEX_SCOPED(plLogicModifier)); + IGetNames(names, _TEMP_CONVERT_FROM_LITERAL(""), CLASS_INDEX_SCOPED(plLogicModifier)); } class plKeyFinderIterator : public plRegistryKeyIterator, public plRegistryPageIterator @@ -282,19 +277,19 @@ class plKeyFinderIterator : public plRegistryKeyIterator, public plRegistryPageI protected: UInt16 fClassType; - const char *fObjName; + plString fObjName; std::vector &fFoundKeys; public: - plKeyFinderIterator( UInt16 classType, const char *obName, std::vector& foundKeys ) + plKeyFinderIterator( UInt16 classType, const plString &obName, std::vector& foundKeys ) : fClassType( classType ), fObjName( obName ), fFoundKeys( foundKeys ) { } virtual hsBool EatKey( const plKey& key ) { if( key->GetUoid().IsValid() && key->GetUoid().GetClassType() == fClassType && - strstr( key->GetUoid().GetObjectName(), fObjName ) ) + key->GetUoid().GetObjectName().Find( fObjName ) >= 0 ) { fFoundKeys.push_back( key ); } @@ -309,9 +304,9 @@ class plKeyFinderIterator : public plRegistryKeyIterator, public plRegistryPageI } }; -void plKeyFinder::ReallyStupidSubstringSearch(const char *name, UInt16 objType, std::vector& foundKeys, const plLocation &hintLocation ) +void plKeyFinder::ReallyStupidSubstringSearch(const plString &name, UInt16 objType, std::vector& foundKeys, const plLocation &hintLocation ) { - if (!name) + if (name.IsNull()) return; plKeyFinderIterator collector( objType, name, foundKeys ); diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.h b/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.h index 858bc108..b11048e0 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.h +++ b/Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.h @@ -89,19 +89,19 @@ public: static plKeyFinder& Instance(); // These are Stupid search because they just do string searchs on the objects. - plKey StupidSearch(const char * age, const char * rm, const char *className, const char *obName, hsBool subString=false); - plKey StupidSearch(const char * age, const char * rm, UInt16 objType, const char *obName, hsBool subString=false); + plKey StupidSearch(const char * age, const char * rm, const char *className, const plString &obName, hsBool subString=false); + plKey StupidSearch(const char * age, const char * rm, UInt16 objType, const plString &obName, hsBool subString=false); eErrCodes GetLastErrorCode() { return fLastError; } const char* GetLastErrorString(); // For Console display - void ReallyStupidResponderSearch(const char* name, std::vector& foundKeys, const plLocation& hintLocation = plLocation::kInvalidLoc); - void ReallyStupidActivatorSearch(const char* name, std::vector& foundKeys, const plLocation& hintLocation = plLocation::kInvalidLoc); + void ReallyStupidResponderSearch(const plString& name, std::vector& foundKeys, const plLocation& hintLocation = plLocation::kInvalidLoc); + void ReallyStupidActivatorSearch(const plString& name, std::vector& foundKeys, const plLocation& hintLocation = plLocation::kInvalidLoc); - void ReallyStupidSubstringSearch(const char* name, UInt16 objType, std::vector& foundKeys, const plLocation& hintLocation = plLocation::kInvalidLoc); + void ReallyStupidSubstringSearch(const plString& name, UInt16 objType, std::vector& foundKeys, const plLocation& hintLocation = plLocation::kInvalidLoc); - void GetActivatorNames(std::vector& names); - void GetResponderNames(std::vector& names); + void GetActivatorNames(std::vector& names); + void GetResponderNames(std::vector& names); plKey FindSceneNodeKey(const char* pageOrFullLocName) const; plKey FindSceneNodeKey(const char* ageName, const char* pageName) const; @@ -113,7 +113,7 @@ public: protected: plKeyFinder() {} - void IGetNames(std::vector& names, const char* name, int index); + void IGetNames(std::vector& names, const plString& name, int index); plKey IFindSceneNodeKey(plRegistryPageNode* page) const; eErrCodes fLastError; diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp index eaf3c840..88cd3a70 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp @@ -69,11 +69,11 @@ plRegistryKeyList::~plRegistryKeyList() class plSearchKeyImp : public plKeyImp { public: - const char* fSearchKeyName; - const char* GetName() const { return fSearchKeyName; } + plString fSearchKeyName; + const plString& GetName() const { return fSearchKeyName; } }; -plKeyImp* plRegistryKeyList::FindKey(const char* keyName) +plKeyImp* plRegistryKeyList::FindKey(const plString& keyName) { static plSearchKeyImp searchKey; searchKey.fSearchKeyName = keyName; @@ -86,7 +86,7 @@ plKeyImp* plRegistryKeyList::FindKey(const char* keyName) for (int i = 0; i < fStaticKeys.size(); i++) { plKeyImp* curKey = fStaticKeys[i]; - if (curKey && hsStrCaseEQ(keyName, curKey->GetName())) + if (curKey && !keyName.Compare(curKey->GetName(), plString::kCaseInsensitive)) return curKey; } } @@ -94,7 +94,7 @@ plKeyImp* plRegistryKeyList::FindKey(const char* keyName) { // We're sorted, do a fast lookup StaticVec::const_iterator it = std::lower_bound(fStaticKeys.begin(), fStaticKeys.end(), &searchKey, KeySorter()); - if (it != fStaticKeys.end() && hsStrCaseEQ(keyName, (*it)->GetName())) + if (it != fStaticKeys.end() && !keyName.Compare((*it)->GetName(), plString::kCaseInsensitive)) return *it; } @@ -124,7 +124,7 @@ plKeyImp* plRegistryKeyList::FindKey(const plUoid& uoid) // because of local data. Verify that we have the right key by // name, and if it's wrong, do the slower find-by-name. plKeyImp *keyImp = fStaticKeys[objectID-1]; - if (!hsStrCaseEQ(keyImp->GetName(), uoid.GetObjectName())) + if (keyImp->GetName().Compare(uoid.GetObjectName(), plString::kCaseInsensitive) != 0) return FindKey(uoid.GetObjectName()); else return keyImp; diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.h b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.h index b1176246..bdad2d71 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.h +++ b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.h @@ -55,7 +55,7 @@ public: bool operator() (plKeyImp* k1, plKeyImp* k2) const { hsAssert(k1 && k2, "Should have valid keys here"); - return stricmp(k1->GetName(), k2->GetName()) < 0; + return k1->GetName().Compare(k2->GetName(), plString::kCaseInsensitive) < 0; } }; @@ -100,7 +100,7 @@ public: UInt16 GetClassType() const { return fClassType; } // Find a key by name (case-insensitive) - plKeyImp* FindKey(const char* keyName); + plKeyImp* FindKey(const plString& keyName); // Find a key by uoid index. plKeyImp* FindKey(const plUoid& uoid); diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp index 060df37a..08b1b0d4 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp @@ -309,7 +309,7 @@ hsBool plRegistryPageNode::IterateKeys(plRegistryKeyIterator* iterator, UInt16 c return true; } -plKeyImp* plRegistryPageNode::FindKey(UInt16 classType, const char* name) const +plKeyImp* plRegistryPageNode::FindKey(UInt16 classType, const plString& name) const { plRegistryKeyList* keys = IGetKeyList(classType); if (keys == nil) @@ -350,8 +350,7 @@ void plRegistryPageNode::AddKey(plKeyImp* key) // Attempt recovery for (int i = 0; i < 500; i++) { - char tempName[512]; - sprintf(tempName, "%s%d", key->GetUoid().GetObjectName(), i); + plString tempName = plString::Format("%s%d", key->GetUoid().GetObjectName().c_str(), i); if (keys->FindKey(tempName) == nil) { plUoid uoid(key->GetUoid().GetLocation(), key->GetUoid().GetClassType(), tempName, key->GetUoid().GetLoadMask()); diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.h b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.h index c914d97b..e053ef51 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.h +++ b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.h @@ -118,7 +118,7 @@ public: void UnloadKeys(); // Frees all our keys // Find a key by type and name - plKeyImp* FindKey(UInt16 classType, const char* name) const; + plKeyImp* FindKey(UInt16 classType, const plString& name) const; // Find a key by direct uoid lookup (or fallback to name lookup if that doesn't work) plKeyImp* FindKey(const plUoid& uoid) const; diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp index 4d828293..e30c2c30 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp @@ -528,15 +528,15 @@ void plResManager::IPageOutSceneNodes(hsBool forceAll) inline plKeyImp* IFindKeyLocalized(const plUoid& uoid, plRegistryPageNode* page) { - const char* objectName = uoid.GetObjectName(); + const plString& objectName = uoid.GetObjectName(); // If we're running localized, try to find a localized version first - if ((objectName != nil) && plLocalization::IsLocalized()) + if ((!objectName.IsNull()) && plLocalization::IsLocalized()) { char localName[256]; - if (plLocalization::GetLocalized(objectName, localName)) + if (plLocalization::GetLocalized(_TEMP_CONVERT_TO_CONST_CHAR(objectName), localName)) { - plKeyImp* localKey = page->FindKey(uoid.GetClassType(), localName); + plKeyImp* localKey = page->FindKey(uoid.GetClassType(), _TEMP_CONVERT_FROM_LITERAL(localName)); if (localKey != nil) return localKey; } @@ -743,9 +743,9 @@ plKey plResManager::ReadKeyNotifyMe(hsStream* stream, plRefMsg* msg, plRefFlags: // Creates a new key and assigns it to the given keyed object, also placing // it into the registry. -plKey plResManager::NewKey(const char* name, hsKeyedObject* object, const plLocation& loc, const plLoadMask& m ) +plKey plResManager::NewKey(const plString& name, hsKeyedObject* object, const plLocation& loc, const plLoadMask& m ) { - hsAssert(name && name[0] != '\0', "No name for new key"); + hsAssert(!name.IsEmpty(), "No name for new key"); plUoid newUoid(loc, object->ClassIndex(), name, m); return NewKey(newUoid, object); } @@ -764,7 +764,7 @@ plKey plResManager::NewKey(plUoid& newUoid, hsKeyedObject* object) return keyPtr; } -plKey plResManager::ReRegister(const char* nm, const plUoid& oid) +plKey plResManager::ReRegister(const plString& nm, const plUoid& oid) { hsAssert(fInited, "Attempting to reregister a key before we're inited!"); @@ -919,7 +919,7 @@ plKey plResManager::ICloneKey(const plUoid& objUoid, UInt32 playerID, UInt32 clo fCurCloneID = cloneID; fCurClonePlayerID = playerID; - plKey cloneKey = ReRegister("", objUoid); + plKey cloneKey = ReRegister(_TEMP_CONVERT_FROM_LITERAL(""), objUoid); fCurClonePlayerID = 0; fCurCloneID = 0; @@ -1270,7 +1270,7 @@ public: { if (stricmp(page->GetPageInfo().GetAge(), fAgeName) == 0) { - plUoid uoid(page->GetPageInfo().GetLocation(), 0, ""); + plUoid uoid(page->GetPageInfo().GetLocation(), 0, _TEMP_CONVERT_FROM_LITERAL("")); fLocations.push_back(uoid.GetLocation()); } return true; diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plResManager.h b/Sources/Plasma/PubUtilLib/plResMgr/plResManager.h index bf587aa2..c632235a 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plResManager.h +++ b/Sources/Plasma/PubUtilLib/plResMgr/plResManager.h @@ -123,7 +123,7 @@ public: //--------------------------- // Registry Modification Functions //--------------------------- - virtual plKey NewKey(const char* name, hsKeyedObject* object, const plLocation& loc, const plLoadMask& m = plLoadMask::kAlways); + virtual plKey NewKey(const plString& name, hsKeyedObject* object, const plLocation& loc, const plLoadMask& m = plLoadMask::kAlways); virtual plKey NewKey(plUoid& newUoid, hsKeyedObject* object); virtual plDispatchBase* Dispatch(); @@ -174,7 +174,7 @@ protected: friend class plKeyImp; friend class plResManagerHelper; - virtual plKey ReRegister(const char* nm, const plUoid& uoid); + virtual plKey ReRegister(const plString& nm, const plUoid& uoid); virtual hsBool ReadObject(plKeyImp* key); // plKeys call this when needed virtual hsBool IReadObject(plKeyImp* pKey, hsStream *stream); diff --git a/Sources/Plasma/PubUtilLib/plSDL/plSDL.h b/Sources/Plasma/PubUtilLib/plSDL/plSDL.h index 4daeba0e..3e469a46 100644 --- a/Sources/Plasma/PubUtilLib/plSDL/plSDL.h +++ b/Sources/Plasma/PubUtilLib/plSDL/plSDL.h @@ -99,7 +99,7 @@ namespace plSDL kDisallowTimeStamping = 0x1, }; - extern const char* kAgeSDLObjectName; + extern const plString kAgeSDLObjectName; void VariableLengthRead(hsStream* s, int size, int* val); void VariableLengthWrite(hsStream* s, int size, int val); }; @@ -304,7 +304,7 @@ public: const plUnifiedTime& GetTimeStamp() const { return fTimeStamp; } // Special backdoor so the KI Manager can get the key name without having a ResMgr - const char* GetKeyName(int idx=0) const; + plString GetKeyName(int idx=0) const; int GetCount() const { return fVar.GetCount(); } // helper plVarDescriptor* GetVarDescriptor() { return &fVar; } diff --git a/Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp b/Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp index a597207e..c8777ba2 100644 --- a/Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp +++ b/Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp @@ -49,7 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plNetMessage/plNetMessage.h" #include "pnNetCommon/plNetApp.h" -const char* plSDL::kAgeSDLObjectName = {"AgeSDLHook"}; +const plString plSDL::kAgeSDLObjectName = _TEMP_CONVERT_FROM_LITERAL("AgeSDLHook"); // static const UInt8 plStateDataRecord::kIOVersion=6; @@ -734,19 +734,19 @@ void plStateDataRecord::DumpToObjectDebugger(const char* msg, bool dirtyOnly, in if (!dbg) return; - std::string pad; + plString pad; int i; for(i=0;iLogMsg(xtl::format("%s", fAssocObject.IsValid() ? fAssocObject.GetObjectName() : " ").c_str()); + dbg->LogMsg(plString::Format("%s", fAssocObject.IsValid() ? fAssocObject.GetObjectName().c_str() : " ").c_str()); if (msg) - dbg->LogMsg(xtl::format("%s%s", pad.c_str(),msg).c_str()); + dbg->LogMsg(plString::Format("%s%s", pad.c_str(),msg).c_str()); - dbg->LogMsg(xtl::format("%sSDR(%p), desc=%s, showDirty=%d, numVars=%d, vol=%d", + dbg->LogMsg(plString::Format("%sSDR(%p), desc=%s, showDirty=%d, numVars=%d, vol=%d", pad.c_str(), this, fDescriptor->GetName(), dirtyOnly, numVars+numSDVars, fFlags&kVolatile).c_str()); // dump simple vars @@ -778,17 +778,17 @@ void plStateDataRecord::DumpToStream(hsStream* stream, const char* msg, bool dir int numVars = dirtyOnly ? GetNumDirtyVars() : GetNumUsedVars(); int numSDVars = dirtyOnly ? GetNumDirtySDVars() : GetNumUsedSDVars(); - std::string logStr = xtl::format("%s", fAssocObject.IsValid() ? fAssocObject.GetObjectName() : " "); + plString logStr = plString::Format("%s", fAssocObject.IsValid() ? fAssocObject.GetObjectName().c_str() : " "); - stream->Write(logStr.length(), logStr.c_str()); + stream->Write(logStr.GetSize(), logStr.c_str()); if (msg) { - logStr = xtl::format("%s%s", pad.c_str(),msg); - stream->Write(logStr.length(), logStr.c_str()); + logStr = plString::Format("%s%s", pad.c_str(),msg); + stream->Write(logStr.GetSize(), logStr.c_str()); } - logStr = xtl::format("%sSDR(%p), desc=%s, showDirty=%d, numVars=%d, vol=%d", pad.c_str(), this, fDescriptor->GetName(), dirtyOnly, numVars+numSDVars, fFlags&kVolatile); - stream->Write(logStr.length(), logStr.c_str()); + logStr = plString::Format("%sSDR(%p), desc=%s, showDirty=%d, numVars=%d, vol=%d", pad.c_str(), this, fDescriptor->GetName(), dirtyOnly, numVars+numSDVars, fFlags&kVolatile); + stream->Write(logStr.GetSize(), logStr.c_str()); // dump simple vars for(i=0;iWrite(logStr.length(), logStr.c_str()); + logStr = _TEMP_CONVERT_FROM_LITERAL("\n"); + stream->Write(logStr.GetSize(), logStr.c_str()); } void plStateDataRecord::SetFromDefaults(bool timeStampNow) diff --git a/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp b/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp index 89b4485a..63469006 100644 --- a/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp +++ b/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp @@ -1719,7 +1719,7 @@ bool plSimpleStateVariable::Get(plKey* value, int idx) const if (*value) { const plUoid& newUoid = (*value)->GetUoid(); - if (stricmp(newUoid.GetObjectName(), fU[idx].GetObjectName()) != 0) + if (newUoid.GetObjectName().Compare(fU[idx].GetObjectName(), plString::kCaseInsensitive) != 0) { // uoid names don't match... chances are the key changed in the local data after the key was written to the sdl // do a search by name, which takes longer, to get the correct key @@ -1780,7 +1780,7 @@ bool plSimpleStateVariable::Get(plCreatable** value, int idx) const ///////////////////////////////////////////////////////////// -const char* plSimpleStateVariable::GetKeyName(int idx) const +plString plSimpleStateVariable::GetKeyName(int idx) const { if (fVar.GetAtomicType()==plVarDescriptor::kKey) { @@ -1790,7 +1790,7 @@ const char* plSimpleStateVariable::GetKeyName(int idx) const } } hsAssert(false, "passing wrong value type to SDL variable"); - return "(nil)"; + return _TEMP_CONVERT_FROM_LITERAL("(nil)"); } #pragma optimize( "g", off ) // disable float optimizations diff --git a/Sources/Plasma/PubUtilLib/plScene/plPageTreeMgr.cpp b/Sources/Plasma/PubUtilLib/plScene/plPageTreeMgr.cpp index 9ef6a94c..bc46e908 100644 --- a/Sources/Plasma/PubUtilLib/plScene/plPageTreeMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plScene/plPageTreeMgr.cpp @@ -211,7 +211,7 @@ int plPageTreeMgr::IRenderVisList(plPipeline* pipe, hsTArray& lev plDrawable* p = sortedDrawList[i].fDrawable; - plProfile_BeginLap(DrawableTime, p->GetKey()->GetUoid().GetObjectName()); + plProfile_BeginLap(DrawableTime, p->GetKey()->GetUoid().GetObjectName().c_str()); if( sortedDrawList[i].fDrawable->GetNativeProperty(plDrawable::kPropSortSpans) ) { @@ -229,7 +229,7 @@ int plPageTreeMgr::IRenderVisList(plPipeline* pipe, hsTArray& lev } - plProfile_EndLap(DrawableTime, p->GetKey()->GetUoid().GetObjectName()); + plProfile_EndLap(DrawableTime, p->GetKey()->GetUoid().GetObjectName().c_str()); } return numDrawn; diff --git a/Sources/Plasma/PubUtilLib/plScene/plPostEffectMod.cpp b/Sources/Plasma/PubUtilLib/plScene/plPostEffectMod.cpp index 3614ee09..b9e4b911 100644 --- a/Sources/Plasma/PubUtilLib/plScene/plPostEffectMod.cpp +++ b/Sources/Plasma/PubUtilLib/plScene/plPostEffectMod.cpp @@ -245,9 +245,9 @@ hsBool plPostEffectMod::MsgReceive(plMessage* msg) plRenderMsg* rend = plRenderMsg::ConvertNoRef(msg); if( rend && IIsEnabled() ) { - plProfile_BeginLap(PostEffect, this->GetKey()->GetUoid().GetObjectName()); + plProfile_BeginLap(PostEffect, this->GetKey()->GetUoid().GetObjectName().c_str()); ISubmitRequest(); - plProfile_EndLap(PostEffect, this->GetKey()->GetUoid().GetObjectName()); + plProfile_EndLap(PostEffect, this->GetKey()->GetUoid().GetObjectName().c_str()); return true; } diff --git a/Sources/Plasma/PubUtilLib/plScene/plRelevanceMgr.cpp b/Sources/Plasma/PubUtilLib/plScene/plRelevanceMgr.cpp index 1b91dd6c..50e6946f 100644 --- a/Sources/Plasma/PubUtilLib/plScene/plRelevanceMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plScene/plRelevanceMgr.cpp @@ -149,12 +149,12 @@ hsBool plRelevanceMgr::MsgReceive(plMessage* msg) return hsKeyedObject::MsgReceive(msg); } -UInt32 plRelevanceMgr::GetIndex(char *regionName) +UInt32 plRelevanceMgr::GetIndex(const plString ®ionName) { int i; for (i = 0; i < fRegions.GetCount(); i++) { - if (fRegions[i] && !stricmp(regionName, fRegions[i]->GetKeyName())) + if (fRegions[i] && !regionName.Compare(fRegions[i]->GetKeyName(), plString::kCaseInsensitive)) return i + 1; } @@ -222,7 +222,7 @@ void plRelevanceMgr::ParseCsvInput(hsStream *s) plRegionInfo *info = TRACKED_NEW plRegionInfo; regions.Append(info); info->fName = hsStrcpy(buff); - info->fIndex = GetIndex(buff); + info->fIndex = GetIndex(_TEMP_CONVERT_FROM_LITERAL(buff)); } } else // parsing actual settings. @@ -231,7 +231,7 @@ void plRelevanceMgr::ParseCsvInput(hsStream *s) if (!toke.Next(buff, kBufSize)) continue; - int rowIndex = GetIndex(buff); + int rowIndex = GetIndex(_TEMP_CONVERT_FROM_LITERAL(buff)); int column = 0; while (toke.Next(buff, kBufSize) && column < regions.GetCount()) { @@ -248,24 +248,24 @@ void plRelevanceMgr::ParseCsvInput(hsStream *s) delete regions[i]; } -std::string plRelevanceMgr::GetRegionNames(hsBitVector regions) +plString plRelevanceMgr::GetRegionNames(hsBitVector regions) { - std::string retVal = ""; + plString retVal; if (regions.IsBitSet(0)) - retVal = "-Nowhere (0)-"; + retVal = _TEMP_CONVERT_FROM_LITERAL("-Nowhere (0)-"); for (int i = 0; i < fRegions.GetCount(); ++i) { if (regions.IsBitSet(i + 1)) { - if (retVal.length() != 0) - retVal += ", "; + if (!retVal.IsEmpty()) + retVal += _TEMP_CONVERT_FROM_LITERAL(", "); if (fRegions[i]) retVal += fRegions[i]->GetKeyName(); } } - if (retVal.length() == 0) - retVal = ""; + if (retVal.IsEmpty()) + retVal = _TEMP_CONVERT_FROM_LITERAL(""); return retVal; -} \ No newline at end of file +} diff --git a/Sources/Plasma/PubUtilLib/plScene/plRelevanceMgr.h b/Sources/Plasma/PubUtilLib/plScene/plRelevanceMgr.h index 24b545b8..c11b2ce2 100644 --- a/Sources/Plasma/PubUtilLib/plScene/plRelevanceMgr.h +++ b/Sources/Plasma/PubUtilLib/plScene/plRelevanceMgr.h @@ -80,13 +80,13 @@ public: hsBool GetEnabled() { return fEnabled; } void SetEnabled(hsBool val) { fEnabled = val; } - UInt32 GetIndex(char *regionName); + UInt32 GetIndex(const plString ®ionName); void MarkRegion(UInt32 localIdx, UInt32 remoteIdx, hsBool doICare); void SetRegionVectors(const hsPoint3 &pos, hsBitVector ®ionsImIn, hsBitVector ®ionsICareAbout); UInt32 GetNumRegions() const; // includes the secret 0 region in its count void ParseCsvInput(hsStream *s); - std::string GetRegionNames(hsBitVector regions); + plString GetRegionNames(hsBitVector regions); }; #endif // plRelevanceMgr_inc diff --git a/Sources/Plasma/PubUtilLib/plStatGather/plAutoProfile.cpp b/Sources/Plasma/PubUtilLib/plStatGather/plAutoProfile.cpp index 75adcc44..dbe53715 100644 --- a/Sources/Plasma/PubUtilLib/plStatGather/plAutoProfile.cpp +++ b/Sources/Plasma/PubUtilLib/plStatGather/plAutoProfile.cpp @@ -81,7 +81,7 @@ protected: plStringList fAges; int fNextAge; int fNextSpawnPoint; - const char* fLastSpawnPointName; + plString fLastSpawnPointName; // For profiling a single age std::string fAgeName; bool fLinkedToSingleAge; @@ -89,7 +89,7 @@ protected: UInt64 fLinkTime; - std::string fStatusMessage; + plString fStatusMessage; void INextProfile(); bool INextAge(); @@ -115,7 +115,7 @@ plAutoProfile* plAutoProfile::Instance() //////////////////////////////////////////////////////////////////////////////// -plAutoProfileImp::plAutoProfileImp() : fNextAge(0), fNextSpawnPoint(0), fLastSpawnPointName(nil), fLinkedToSingleAge(false), fJustLinkToAges(false) +plAutoProfileImp::plAutoProfileImp() : fNextAge(0), fNextSpawnPoint(0), fLinkedToSingleAge(false), fJustLinkToAges(false) { } @@ -216,10 +216,10 @@ void plAutoProfileImp::INextProfile() else { // Log the stats for this spawn point - if (fLastSpawnPointName) + if (!fLastSpawnPointName.IsNull()) { const char * ageName = NetCommGetAge()->ageDatasetName; - plProfileManagerFull::Instance().LogStats(ageName, fLastSpawnPointName); + plProfileManagerFull::Instance().LogStats(ageName, _TEMP_CONVERT_TO_CONST_CHAR(fLastSpawnPointName)); plMipmap mipmap; if (plClient::GetInstance()->GetPipeline()->CaptureScreen(&mipmap)) @@ -233,7 +233,7 @@ void plAutoProfileImp::INextProfile() plJPEG::Instance().WriteToFile(fileName, &mipmap); } - fLastSpawnPointName = nil; + fLastSpawnPointName = plString::Null; } // Try to go to the next spawn point @@ -277,8 +277,8 @@ bool plAutoProfileImp::INextAge() link.SetLinkingRules(plNetCommon::LinkingRules::kBasicLink); plNetLinkingMgr::GetInstance()->LinkToAge(&link); - fStatusMessage = "Linking to age "; - fStatusMessage += ageName; + fStatusMessage = _TEMP_CONVERT_FROM_LITERAL("Linking to age "); + fStatusMessage += _TEMP_CONVERT_FROM_LITERAL(ageName); return true; } @@ -298,9 +298,9 @@ bool plAutoProfileImp::INextSpawnPoint() const plSpawnModifier* spawnMod = plAvatarMgr::GetInstance()->GetSpawnPoint(fNextSpawnPoint); fLastSpawnPointName = spawnMod->GetKeyName(); - if (strncmp(fLastSpawnPointName, kPerfSpawnPrefix, kPerfSpawnLen) == 0) + if (fLastSpawnPointName.CompareN(kPerfSpawnPrefix, kPerfSpawnLen) == 0) { - fStatusMessage = "Profiling spawn point "; + fStatusMessage = _TEMP_CONVERT_FROM_LITERAL("Profiling spawn point "); fStatusMessage += fLastSpawnPointName; foundGood = true; @@ -312,8 +312,8 @@ bool plAutoProfileImp::INextSpawnPoint() if (!foundGood) { - fLastSpawnPointName = nil; - fStatusMessage = "No profile spawn point found"; + fLastSpawnPointName = plString::Null; + fStatusMessage = _TEMP_CONVERT_FROM_LITERAL("No profile spawn point found"); return false; } @@ -337,7 +337,7 @@ hsBool plAutoProfileImp::MsgReceive(plMessage* msg) plEvalMsg* evalMsg = plEvalMsg::ConvertNoRef(msg); if (evalMsg) { - if (fStatusMessage.length() > 0) + if (fStatusMessage.GetSize() > 0) plDebugText::Instance().DrawString(10, 10, fStatusMessage.c_str()); } @@ -369,7 +369,7 @@ hsBool plAutoProfileImp::MsgReceive(plMessage* msg) ms); } - fStatusMessage = "Age loaded. Preparing to profile."; + fStatusMessage = _TEMP_CONVERT_FROM_LITERAL("Age loaded. Preparing to profile."); // Age is loaded, start profiling in 5 seconds (to make sure the avatar is linked in all the way) plTimerCallbackMsg* timerMsg = TRACKED_NEW plTimerCallbackMsg(GetKey()); diff --git a/Sources/Plasma/PubUtilLib/plSurface/hsGMaterial.cpp b/Sources/Plasma/PubUtilLib/plSurface/hsGMaterial.cpp index fc738d65..ff9b8f45 100644 --- a/Sources/Plasma/PubUtilLib/plSurface/hsGMaterial.cpp +++ b/Sources/Plasma/PubUtilLib/plSurface/hsGMaterial.cpp @@ -132,11 +132,11 @@ plLayer* hsGMaterial::MakeBaseLayer() hsAssert(GetKey(), "All materials need a key (or temp key)"); - char buff[256]; - if( GetKey()->GetName() ) - sprintf(buff, "%s_%s", GetKey()->GetName(), "Layer"); + plString buff; + if( !GetKey()->GetName().IsNull() ) + buff = plString::Format("%s_Layer", GetKey()->GetName().c_str()); else - strcpy(buff, "Layer"); + buff = _TEMP_CONVERT_FROM_LITERAL("Layer"); hsgResMgr::ResMgr()->NewKey( buff, newLay, GetKey() != nil ? GetKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc ); // Add layer so we have it now. @@ -278,7 +278,7 @@ void hsGMaterial::Read(hsStream *stream, hsResMgr *group) void hsGMaterial::Eval(double secs, UInt32 frame) { - plProfile_BeginLap(MaterialAnims, GetKeyName()); + plProfile_BeginLap(MaterialAnims, GetKeyName().c_str()); int i; for( i = 0; i < GetNumLayers(); i++ ) @@ -292,7 +292,7 @@ void hsGMaterial::Eval(double secs, UInt32 frame) fPiggyBacks[i]->Eval(secs, frame, 0); } - plProfile_EndLap(MaterialAnims, GetKeyName()); + plProfile_EndLap(MaterialAnims, GetKeyName().c_str()); } void hsGMaterial::Reset() diff --git a/Sources/Plasma/PubUtilLib/plSurface/plGrassShaderMod.cpp b/Sources/Plasma/PubUtilLib/plSurface/plGrassShaderMod.cpp index 0f3f3c5f..01ec71e9 100644 --- a/Sources/Plasma/PubUtilLib/plSurface/plGrassShaderMod.cpp +++ b/Sources/Plasma/PubUtilLib/plSurface/plGrassShaderMod.cpp @@ -226,8 +226,7 @@ void plGrassShaderMod::ISetupShaders() if (!fVShader) { plShader* vShader = TRACKED_NEW plShader; - char buff[256]; - sprintf(buff, "%s_GrassVS", GetKey()->GetName()); + plString buff = plString::Format("%s_GrassVS", GetKey()->GetName().c_str()); hsgResMgr::ResMgr()->NewKey(buff, vShader, GetKey()->GetUoid().GetLocation()); vShader->SetIsPixelShader(false); vShader->SetInputFormat(1); @@ -250,8 +249,7 @@ void plGrassShaderMod::ISetupShaders() if (!fPShader) { plShader* pShader = TRACKED_NEW plShader; - char buff[256]; - sprintf(buff, "%s_GrassPS", GetKey()->GetName()); + plString buff = plString::Format("%s_GrassPS", GetKey()->GetName().c_str()); hsgResMgr::ResMgr()->NewKey(buff, pShader, GetKey()->GetUoid().GetLocation()); pShader->SetIsPixelShader(true); pShader->SetNumConsts(0); diff --git a/Sources/Tools/plResBrowser/plResTreeView.cpp b/Sources/Tools/plResBrowser/plResTreeView.cpp index b7838971..c0900700 100644 --- a/Sources/Tools/plResBrowser/plResTreeView.cpp +++ b/Sources/Tools/plResBrowser/plResTreeView.cpp @@ -164,7 +164,7 @@ class plResDlgLoader : public plRegistryPageIterator, public plRegistryKeyIterat } if( !fFilter ) - AddLeaf( fTree, fCurrTypeItem, key->GetUoid().GetObjectName(), new plKeyInfo( key, fCurrPage ) ); + AddLeaf( fTree, fCurrTypeItem, key->GetUoid().GetObjectName().c_str(), new plKeyInfo( key, fCurrPage ) ); return true; } }; @@ -236,7 +236,7 @@ void plResTreeView::IFindNextObject( HWND tree ) plKeyInfo *keyInfo = (plKeyInfo *)itemInfo.lParam; if( keyInfo != nil && keyInfo->fKey != nil ) { - if( StrStrI( keyInfo->fKey->GetUoid().GetObjectName(), gSearchString ) != nil ) + if( keyInfo->fKey->GetUoid().GetObjectName().Compare( gSearchString, plString::kCaseInsensitive ) >= 0 ) { /// FOUND TreeView_SelectItem( tree, fFoundItem ); @@ -415,7 +415,7 @@ void plResTreeView::UpdateInfoDlg( HWND treeCtrl ) char str[ 128 ]; - SetDlgItemText( fInfoDlg, IDC_NAME, info->fKey->GetUoid().GetObjectName() ); + SetDlgItemText( fInfoDlg, IDC_NAME, info->fKey->GetUoid().GetObjectName().c_str() ); const char *name = plFactory::GetNameOfClass( info->fKey->GetUoid().GetClassType() ); sprintf( str, "%s (%d)", name != nil ? name : "", info->fKey->GetUoid().GetClassType() );