diff --git a/Sources/Plasma/Apps/plClient/winmain.cpp b/Sources/Plasma/Apps/plClient/winmain.cpp index ae195734..32318fa8 100644 --- a/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/Sources/Plasma/Apps/plClient/winmain.cpp @@ -964,13 +964,12 @@ BOOL CALLBACK UruTOSDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l if (stream.Open("TOS.txt", "rt")) { uint32_t dataLen = stream.GetSizeLeft(); - char* eulaData = new char[dataLen + 1]; + plStringBuffer eula; + char* eulaData = eula.CreateWritableBuffer(dataLen); memset(eulaData, 0, dataLen + 1); stream.Read(dataLen, eulaData); - plString str = plString::FromUtf8(eulaData); - delete [] eulaData; - SetDlgItemTextW(hwndDlg, IDC_URULOGIN_EULATEXT, str.ToWchar()); + SetDlgItemTextW(hwndDlg, IDC_URULOGIN_EULATEXT, plString(eula).ToWchar()); } else // no TOS found, go ahead EndDialog(hwndDlg, true); diff --git a/Sources/Plasma/CoreLib/HeadSpin.h b/Sources/Plasma/CoreLib/HeadSpin.h index 9a51bf29..08dc423e 100644 --- a/Sources/Plasma/CoreLib/HeadSpin.h +++ b/Sources/Plasma/CoreLib/HeadSpin.h @@ -366,7 +366,7 @@ char * hsFormatStr(const char * fmt, ...); // You are responsible for returned char * hsFormatStrV(const char * fmt, va_list args); // You are responsible for returned memory. // Use "correct" stricmp based on the selected compiler / library -#if HS_BUILD_FOR_WIN32 +#if _MSC_VER # define stricmp _stricmp # define strnicmp _strnicmp # define wcsicmp _wcsicmp diff --git a/Sources/Plasma/CoreLib/plString.cpp b/Sources/Plasma/CoreLib/plString.cpp index e67bf8a3..c60440c9 100644 --- a/Sources/Plasma/CoreLib/plString.cpp +++ b/Sources/Plasma/CoreLib/plString.cpp @@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include #include +#include const plString plString::Null; @@ -93,10 +94,17 @@ void plString::IConvertFromUtf8(const char *utf8, size_t size) if ((int32_t)size < 0) size = strnlen(utf8, -(int32_t)size); + operator=(plStringBuffer(utf8, size)); +} + +plString &plString::operator=(const plStringBuffer &init) +{ + fUtf8Buffer = init; + #ifdef _DEBUG // Check to make sure the string is actually valid UTF-8 - const char *sp = utf8; - while (sp < utf8 + size) { + const char *sp = fUtf8Buffer.GetData(); + while (sp < fUtf8Buffer.GetData() + fUtf8Buffer.GetSize()) { unsigned char unichar = *sp++; if ((unichar & 0xF8) == 0xF0) { // Four bytes @@ -118,7 +126,7 @@ void plString::IConvertFromUtf8(const char *utf8, size_t size) } #endif - fUtf8Buffer = plStringBuffer(utf8, size); + return *this; } void plString::IConvertFromUtf16(const uint16_t *utf16, size_t size) diff --git a/Sources/Plasma/CoreLib/plString.h b/Sources/Plasma/CoreLib/plString.h index ed0dbd84..c29a4a12 100644 --- a/Sources/Plasma/CoreLib/plString.h +++ b/Sources/Plasma/CoreLib/plString.h @@ -45,7 +45,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "HeadSpin.h" #include -#include /* NOTE & TODO: * These macros are intentionally annoyingly named, to mark what code @@ -177,10 +176,12 @@ public: //plString(const char *utf8) { IConvertFromUtf8(utf8, kSizeAuto, false); } //plString(const wchar_t *wstr) { IConvertFromWchar(wstr, kSizeAuto); } plString(const plString ©) : fUtf8Buffer(copy.fUtf8Buffer) { } + plString(const plStringBuffer &init) { operator=(init); } //plString &operator=(const char *utf8) { IConvertFromUtf8(utf8, kSizeAuto, false); return *this; } //plString &operator=(const wchar_t *wstr) { IConvertFromWchar(wstr, kSizeAuto); return *this; } plString &operator=(const plString ©) { fUtf8Buffer = copy.fUtf8Buffer; return *this; } + plString &operator=(const plStringBuffer &init); plString &operator+=(const plString &str) { return operator=(*this + str); } diff --git a/Sources/Plasma/FeatureLib/pfAnimation/plRandomCommandMod.cpp b/Sources/Plasma/FeatureLib/pfAnimation/plRandomCommandMod.cpp index ec0f4a36..cc555c37 100644 --- a/Sources/Plasma/FeatureLib/pfAnimation/plRandomCommandMod.cpp +++ b/Sources/Plasma/FeatureLib/pfAnimation/plRandomCommandMod.cpp @@ -41,6 +41,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com *==LICENSE==*/ #include +#include #include "HeadSpin.h" #include "plRandomCommandMod.h" diff --git a/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h b/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h index d950233b..aebfbfc5 100644 --- a/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h +++ b/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h @@ -46,6 +46,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnKeyedObject/hsKeyedObject.h" #include "hsMatrix44.h" #include "hsBitVector.h" +#include class plPipeline; class plCameraModifier1; diff --git a/Sources/Plasma/FeatureLib/pfPython/plPythonParameter.h b/Sources/Plasma/FeatureLib/pfPython/plPythonParameter.h index 50101e71..a089b1ad 100644 --- a/Sources/Plasma/FeatureLib/pfPython/plPythonParameter.h +++ b/Sources/Plasma/FeatureLib/pfPython/plPythonParameter.h @@ -376,11 +376,11 @@ public: count = stream->ReadLE32(); if ( count != 0 ) { - char *buffer = new char[count]; + plStringBuffer str; + char *buffer = str.CreateWritableBuffer(count-1); stream->ReadLE(count, buffer); buffer[count-1] = 0; - fString = plString::FromUtf8(buffer, count); - delete [] buffer; + fString = str; } else fString = plString::Null; diff --git a/Sources/Plasma/FeatureLib/pfPython/pyGUIControlTextBox.h b/Sources/Plasma/FeatureLib/pfPython/pyGUIControlTextBox.h index 9f8f5b00..bd7b49a9 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyGUIControlTextBox.h +++ b/Sources/Plasma/FeatureLib/pfPython/pyGUIControlTextBox.h @@ -51,6 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pyGUIControl.h" #include "pyGlueHelpers.h" +#include class pyColor; class pfGUIColorScheme; diff --git a/Sources/Plasma/FeatureLib/pfPython/pyGUIPopUpMenu.h b/Sources/Plasma/FeatureLib/pfPython/pyGUIPopUpMenu.h index 20d8c184..7298e925 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyGUIPopUpMenu.h +++ b/Sources/Plasma/FeatureLib/pfPython/pyGUIPopUpMenu.h @@ -52,6 +52,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnKeyedObject/plKey.h" #include "pyGlueHelpers.h" #include "pnKeyedObject/plUoid.h" +#include class pfGUIPopUpMenu; class pyColor; diff --git a/Sources/Plasma/FeatureLib/pfPython/pyJournalBook.h b/Sources/Plasma/FeatureLib/pfPython/pyJournalBook.h index 3df7246c..df5aa774 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyJournalBook.h +++ b/Sources/Plasma/FeatureLib/pfPython/pyJournalBook.h @@ -49,7 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com ////////////////////////////////////////////////////////////////////// #include "pyGlueHelpers.h" -#include +#include class cyAnimation; class pyImage; diff --git a/Sources/Plasma/FeatureLib/pfPython/pyPlayer.h b/Sources/Plasma/FeatureLib/pfPython/pyPlayer.h index 45e67865..7babf5f5 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyPlayer.h +++ b/Sources/Plasma/FeatureLib/pfPython/pyPlayer.h @@ -51,6 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pyGlueHelpers.h" #include "pnKeyedObject/plKey.h" +#include class pyPlayer { diff --git a/Sources/Plasma/FeatureLib/pfPython/pySceneObject.h b/Sources/Plasma/FeatureLib/pfPython/pySceneObject.h index da952e35..9a257736 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pySceneObject.h +++ b/Sources/Plasma/FeatureLib/pfPython/pySceneObject.h @@ -52,6 +52,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pyGlueHelpers.h" #include "pnKeyedObject/plKey.h" #include "hsTemplates.h" +#include class pyMatrix44; diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp index 12272d9a..1b2b999a 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp @@ -645,7 +645,7 @@ void plNetClientMgr::ICheckPendingStateLoad(double secs) #ifdef HS_DEBUGGING if (plNetObjectDebugger::GetInstance()->IsDebugObject(so)) { - hsLogEntry( DebugMsg( "Delivering SDL state %s:%s", pl->fKey->GetName(), pl->fSDRec->GetDescriptor()->GetName() ) ); + hsLogEntry( DebugMsg( "Delivering SDL state %s:%s", pl->fKey->GetName().c_str(), pl->fSDRec->GetDescriptor()->GetName() ) ); // hsLogEntry(plNetObjectDebugger::GetInstance()->LogMsg(xtl::format("Dispatching SDL state, type %s to object:%s, locallyOwned=%d, st=%.3f rt=%.3f", // pl->fSDRec->GetDescriptor()->GetName(), pl->fKey->GetName(), // so->IsLocallyOwned()==plSynchedObject::kYes, secs, hsTimer::GetSeconds()).c_str()));