Browse Source

Some cleanup and a vararg plString usage fix

Michael Hansen 12 years ago
parent
commit
075c535e2c
  1. 7
      Sources/Plasma/Apps/plClient/winmain.cpp
  2. 2
      Sources/Plasma/CoreLib/HeadSpin.h
  3. 14
      Sources/Plasma/CoreLib/plString.cpp
  4. 3
      Sources/Plasma/CoreLib/plString.h
  5. 1
      Sources/Plasma/FeatureLib/pfAnimation/plRandomCommandMod.cpp
  6. 1
      Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h
  7. 6
      Sources/Plasma/FeatureLib/pfPython/plPythonParameter.h
  8. 1
      Sources/Plasma/FeatureLib/pfPython/pyGUIControlTextBox.h
  9. 1
      Sources/Plasma/FeatureLib/pfPython/pyGUIPopUpMenu.h
  10. 2
      Sources/Plasma/FeatureLib/pfPython/pyJournalBook.h
  11. 1
      Sources/Plasma/FeatureLib/pfPython/pyPlayer.h
  12. 1
      Sources/Plasma/FeatureLib/pfPython/pySceneObject.h
  13. 2
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp

7
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")) if (stream.Open("TOS.txt", "rt"))
{ {
uint32_t dataLen = stream.GetSizeLeft(); uint32_t dataLen = stream.GetSizeLeft();
char* eulaData = new char[dataLen + 1]; plStringBuffer<char> eula;
char* eulaData = eula.CreateWritableBuffer(dataLen);
memset(eulaData, 0, dataLen + 1); memset(eulaData, 0, dataLen + 1);
stream.Read(dataLen, eulaData); stream.Read(dataLen, eulaData);
plString str = plString::FromUtf8(eulaData); SetDlgItemTextW(hwndDlg, IDC_URULOGIN_EULATEXT, plString(eula).ToWchar());
delete [] eulaData;
SetDlgItemTextW(hwndDlg, IDC_URULOGIN_EULATEXT, str.ToWchar());
} }
else // no TOS found, go ahead else // no TOS found, go ahead
EndDialog(hwndDlg, true); EndDialog(hwndDlg, true);

2
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. char * hsFormatStrV(const char * fmt, va_list args); // You are responsible for returned memory.
// Use "correct" stricmp based on the selected compiler / library // Use "correct" stricmp based on the selected compiler / library
#if HS_BUILD_FOR_WIN32 #if _MSC_VER
# define stricmp _stricmp # define stricmp _stricmp
# define strnicmp _strnicmp # define strnicmp _strnicmp
# define wcsicmp _wcsicmp # define wcsicmp _wcsicmp

14
Sources/Plasma/CoreLib/plString.cpp

@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <cstring> #include <cstring>
#include <cstdlib> #include <cstdlib>
#include <wchar.h> #include <wchar.h>
#include <memory>
const plString plString::Null; const plString plString::Null;
@ -93,10 +94,17 @@ void plString::IConvertFromUtf8(const char *utf8, size_t size)
if ((int32_t)size < 0) if ((int32_t)size < 0)
size = strnlen(utf8, -(int32_t)size); size = strnlen(utf8, -(int32_t)size);
operator=(plStringBuffer<char>(utf8, size));
}
plString &plString::operator=(const plStringBuffer<char> &init)
{
fUtf8Buffer = init;
#ifdef _DEBUG #ifdef _DEBUG
// Check to make sure the string is actually valid UTF-8 // Check to make sure the string is actually valid UTF-8
const char *sp = utf8; const char *sp = fUtf8Buffer.GetData();
while (sp < utf8 + size) { while (sp < fUtf8Buffer.GetData() + fUtf8Buffer.GetSize()) {
unsigned char unichar = *sp++; unsigned char unichar = *sp++;
if ((unichar & 0xF8) == 0xF0) { if ((unichar & 0xF8) == 0xF0) {
// Four bytes // Four bytes
@ -118,7 +126,7 @@ void plString::IConvertFromUtf8(const char *utf8, size_t size)
} }
#endif #endif
fUtf8Buffer = plStringBuffer<char>(utf8, size); return *this;
} }
void plString::IConvertFromUtf16(const uint16_t *utf16, size_t size) void plString::IConvertFromUtf16(const uint16_t *utf16, size_t size)

3
Sources/Plasma/CoreLib/plString.h

@ -45,7 +45,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include <stddef.h> #include <stddef.h>
#include <vector>
/* NOTE & TODO: /* NOTE & TODO:
* These macros are intentionally annoyingly named, to mark what code * 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 char *utf8) { IConvertFromUtf8(utf8, kSizeAuto, false); }
//plString(const wchar_t *wstr) { IConvertFromWchar(wstr, kSizeAuto); } //plString(const wchar_t *wstr) { IConvertFromWchar(wstr, kSizeAuto); }
plString(const plString &copy) : fUtf8Buffer(copy.fUtf8Buffer) { } plString(const plString &copy) : fUtf8Buffer(copy.fUtf8Buffer) { }
plString(const plStringBuffer<char> &init) { operator=(init); }
//plString &operator=(const char *utf8) { IConvertFromUtf8(utf8, kSizeAuto, false); return *this; } //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 wchar_t *wstr) { IConvertFromWchar(wstr, kSizeAuto); return *this; }
plString &operator=(const plString &copy) { fUtf8Buffer = copy.fUtf8Buffer; return *this; } plString &operator=(const plString &copy) { fUtf8Buffer = copy.fUtf8Buffer; return *this; }
plString &operator=(const plStringBuffer<char> &init);
plString &operator+=(const plString &str) { return operator=(*this + str); } plString &operator+=(const plString &str) { return operator=(*this + str); }

1
Sources/Plasma/FeatureLib/pfAnimation/plRandomCommandMod.cpp

@ -41,6 +41,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include <stdlib.h> #include <stdlib.h>
#include <cmath>
#include "HeadSpin.h" #include "HeadSpin.h"
#include "plRandomCommandMod.h" #include "plRandomCommandMod.h"

1
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 "pnKeyedObject/hsKeyedObject.h"
#include "hsMatrix44.h" #include "hsMatrix44.h"
#include "hsBitVector.h" #include "hsBitVector.h"
#include <vector>
class plPipeline; class plPipeline;
class plCameraModifier1; class plCameraModifier1;

6
Sources/Plasma/FeatureLib/pfPython/plPythonParameter.h

@ -376,11 +376,11 @@ public:
count = stream->ReadLE32(); count = stream->ReadLE32();
if ( count != 0 ) if ( count != 0 )
{ {
char *buffer = new char[count]; plStringBuffer<char> str;
char *buffer = str.CreateWritableBuffer(count-1);
stream->ReadLE(count, buffer); stream->ReadLE(count, buffer);
buffer[count-1] = 0; buffer[count-1] = 0;
fString = plString::FromUtf8(buffer, count); fString = str;
delete [] buffer;
} }
else else
fString = plString::Null; fString = plString::Null;

1
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 "pyGUIControl.h"
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
#include <string>
class pyColor; class pyColor;
class pfGUIColorScheme; class pfGUIColorScheme;

1
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 "pnKeyedObject/plKey.h"
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
#include "pnKeyedObject/plUoid.h" #include "pnKeyedObject/plUoid.h"
#include <string>
class pfGUIPopUpMenu; class pfGUIPopUpMenu;
class pyColor; class pyColor;

2
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 "pyGlueHelpers.h"
#include <string> #include <vector>
class cyAnimation; class cyAnimation;
class pyImage; class pyImage;

1
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 "pyGlueHelpers.h"
#include "pnKeyedObject/plKey.h" #include "pnKeyedObject/plKey.h"
#include <string>
class pyPlayer class pyPlayer
{ {

1
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 "pyGlueHelpers.h"
#include "pnKeyedObject/plKey.h" #include "pnKeyedObject/plKey.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include <vector>
class pyMatrix44; class pyMatrix44;

2
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp

@ -645,7 +645,7 @@ void plNetClientMgr::ICheckPendingStateLoad(double secs)
#ifdef HS_DEBUGGING #ifdef HS_DEBUGGING
if (plNetObjectDebugger::GetInstance()->IsDebugObject(so)) 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", // 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(), // pl->fSDRec->GetDescriptor()->GetName(), pl->fKey->GetName(),
// so->IsLocallyOwned()==plSynchedObject::kYes, secs, hsTimer::GetSeconds()).c_str())); // so->IsLocallyOwned()==plSynchedObject::kYes, secs, hsTimer::GetSeconds()).c_str()));

Loading…
Cancel
Save