diff --git a/Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp b/Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp index f0e935a2..e862c6cf 100644 --- a/Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp +++ b/Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp @@ -815,8 +815,8 @@ bool plDynamicTextMap::MsgReceive( plMessage *msg ) if( textMsg->fCmd & plDynamicTextMsg::kSetTextColor ) SetTextColor( textMsg->fColor, textMsg->fBlockRGB ); - if( (textMsg->fCmd & plDynamicTextMsg::kSetFont ) && textMsg->fString) - SetFont( textMsg->fString, textMsg->fX, (uint8_t)(textMsg->fFlags) ); + if( (textMsg->fCmd & plDynamicTextMsg::kSetFont ) && !textMsg->fString.IsNull()) + SetFont( textMsg->fString.ToWchar(), textMsg->fX, (uint8_t)(textMsg->fFlags) ); if( textMsg->fCmd & plDynamicTextMsg::kSetLineSpacing ) SetLineSpacing( textMsg->fLineSpacing ); @@ -832,16 +832,16 @@ bool plDynamicTextMap::MsgReceive( plMessage *msg ) FrameRect( textMsg->fLeft, textMsg->fTop, textMsg->fRight - textMsg->fLeft + 1, textMsg->fBottom - textMsg->fTop + 1, textMsg->fColor ); - if( (textMsg->fCmd & plDynamicTextMsg::kDrawString ) && textMsg->fString) - DrawString( textMsg->fX, textMsg->fY, textMsg->fString ); + if( (textMsg->fCmd & plDynamicTextMsg::kDrawString ) && !textMsg->fString.IsNull()) + DrawString( textMsg->fX, textMsg->fY, textMsg->fString.ToWchar() ); - if( (textMsg->fCmd & plDynamicTextMsg::kDrawClippedString ) && textMsg->fString) - DrawClippedString( textMsg->fX, textMsg->fY, textMsg->fString, + if( (textMsg->fCmd & plDynamicTextMsg::kDrawClippedString ) && !textMsg->fString.IsNull()) + DrawClippedString( textMsg->fX, textMsg->fY, textMsg->fString.ToWchar(), textMsg->fLeft, textMsg->fTop, textMsg->fRight - textMsg->fLeft + 1, textMsg->fBottom - textMsg->fTop + 1 ); - if( (textMsg->fCmd & plDynamicTextMsg::kDrawWrappedString ) && textMsg->fString) - DrawWrappedString( textMsg->fX, textMsg->fY, textMsg->fString, textMsg->fRight, textMsg->fBottom ); + if( (textMsg->fCmd & plDynamicTextMsg::kDrawWrappedString ) && !textMsg->fString.IsNull()) + DrawWrappedString( textMsg->fX, textMsg->fY, textMsg->fString.ToWchar(), textMsg->fRight, textMsg->fBottom ); if( textMsg->fCmd & plDynamicTextMsg::kDrawImage ) { diff --git a/Sources/Plasma/PubUtilLib/plMessage/plDynamicTextMsg.cpp b/Sources/Plasma/PubUtilLib/plMessage/plDynamicTextMsg.cpp index 3b4861fc..ceebb8b4 100644 --- a/Sources/Plasma/PubUtilLib/plMessage/plDynamicTextMsg.cpp +++ b/Sources/Plasma/PubUtilLib/plMessage/plDynamicTextMsg.cpp @@ -65,7 +65,7 @@ void plDynamicTextMsg::SetFont( const char *face, int16_t size, bool isBold ) hsAssert( ( fCmd & ( kPosCmds | kStringCmds | kFlagCmds ) ) == 0, "Attempting to issue conflicting drawText commands" ); fCmd &= ~( kPosCmds | kStringCmds | kFlagCmds ); fCmd |= kSetFont; - fString = hsStringToWString( face ); + fString = face; fX = size; fFlags = (uint32_t)isBold; } @@ -123,9 +123,7 @@ void plDynamicTextMsg::DrawString( int16_t x, int16_t y, const wchar_t *text fCmd &= ~( kStringCmds | kPosCmds ); fCmd |= kDrawString; - fString = new wchar_t[wcslen(text)+1]; - wcscpy( fString, text ); - fString[wcslen(text)] = L'\0'; + fString = plString::FromWchar(text); fX = x; fY = y; } @@ -143,9 +141,7 @@ void plDynamicTextMsg::DrawClippedString( int16_t x, int16_t y, uint16_t clip fCmd &= ~( kStringCmds | kPosCmds | kRectCmds ); fCmd |= kDrawClippedString; - fString = new wchar_t[wcslen(text)+1]; - wcscpy( fString, text ); - fString[wcslen(text)] = L'\0'; + fString = plString::FromWchar(text); fX = x; fY = y; @@ -168,9 +164,7 @@ void plDynamicTextMsg::DrawWrappedString( int16_t x, int16_t y, uint16_t wrap fCmd &= ~( kStringCmds | kPosCmds | kRectCmds ); fCmd |= kDrawWrappedString; - fString = new wchar_t[wcslen(text)+1]; - wcscpy( fString, text ); - fString[wcslen(text)] = L'\0'; + fString = plString::FromWchar(text); fX = x; fY = y; @@ -222,7 +216,7 @@ void plDynamicTextMsg::Read( hsStream *s, hsResMgr *mgr ) fClearColor.Read( s ); fColor.Read( s ); - fString = s->ReadSafeWString(); + fString = s->ReadSafeWString_TEMP(); fImageKey = mgr->ReadKey( s ); s->ReadLE( &fFlags ); @@ -253,7 +247,8 @@ void plDynamicTextMsg::Write( hsStream *s, hsResMgr *mgr ) fClearColor.Write( s ); fColor.Write( s ); - s->WriteSafeWString( plString::FromWchar(fString) ); + s->WriteSafeWString(fString); + mgr->WriteKey( s, fImageKey ); s->WriteLE( fFlags ); @@ -306,7 +301,7 @@ void plDynamicTextMsg::ReadVersion(hsStream* s, hsResMgr* mgr) if (contentFlags.IsBitSet(kDynTextMsgColor)) fColor.Read( s ); if (contentFlags.IsBitSet(kDynTextMsgString)) - fString = s->ReadSafeWString(); + fString = s->ReadSafeWString_TEMP(); if (contentFlags.IsBitSet(kDynTextMsgImageKey)) fImageKey = mgr->ReadKey( s ); if (contentFlags.IsBitSet(kDynTextMsgFlags)) @@ -360,7 +355,7 @@ void plDynamicTextMsg::WriteVersion(hsStream* s, hsResMgr* mgr) fColor.Write( s ); // kDynTextMsgString - s->WriteSafeWString( plString::FromWchar(fString) ); + s->WriteSafeWString( fString ); // kDynTextMsgImageKey mgr->WriteKey( s, fImageKey ); diff --git a/Sources/Plasma/PubUtilLib/plMessage/plDynamicTextMsg.h b/Sources/Plasma/PubUtilLib/plMessage/plDynamicTextMsg.h index 9de28e8b..9f800450 100644 --- a/Sources/Plasma/PubUtilLib/plMessage/plDynamicTextMsg.h +++ b/Sources/Plasma/PubUtilLib/plMessage/plDynamicTextMsg.h @@ -72,7 +72,7 @@ protected: hsColorRGBA fColor; // String - wchar_t *fString; + plString fString; // Mipmap plKey fImageKey; @@ -84,8 +84,10 @@ protected: int16_t fLineSpacing; public: - plDynamicTextMsg() : plMessage( nil, nil, nil ) { fCmd = 0; fString = nil; fImageKey = nil; fFlags = 0; fBlockRGB = false; } - ~plDynamicTextMsg() { delete [] fString; } + plDynamicTextMsg() : + plMessage(nullptr, nullptr, nullptr), + fCmd(0), fImageKey(nullptr), fFlags(0), fBlockRGB(false) + { } CLASSNAME_REGISTER( plDynamicTextMsg ); GETINTERFACE_ANY( plDynamicTextMsg, plMessage ); diff --git a/Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgScreener.cpp b/Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgScreener.cpp index 4afe7e2a..a5e575a8 100644 --- a/Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgScreener.cpp +++ b/Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgScreener.cpp @@ -116,6 +116,7 @@ plNetMsgScreener::Answer plNetMsgScreener::IAllowMessageType(int16_t classIndex, case CLASS_INDEX_SCOPED(plEnableMsg): case CLASS_INDEX_SCOPED(plLinkToAgeMsg): case CLASS_INDEX_SCOPED(plSubWorldMsg): + case CLASS_INDEX_SCOPED(plDynamicTextMsg): return kYes; // conditionally yes, requires further validation of msg contents