mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-21 12:49:10 +00:00
Some cleanup and a vararg plString usage fix
This commit is contained in:
@ -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<char> 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);
|
||||
|
@ -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
|
||||
|
@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <wchar.h>
|
||||
#include <memory>
|
||||
|
||||
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<char>(utf8, size));
|
||||
}
|
||||
|
||||
plString &plString::operator=(const plStringBuffer<char> &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<char>(utf8, size);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void plString::IConvertFromUtf16(const uint16_t *utf16, size_t size)
|
||||
|
@ -45,7 +45,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include "HeadSpin.h"
|
||||
#include <stddef.h>
|
||||
#include <vector>
|
||||
|
||||
/* 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<char> &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<char> &init);
|
||||
|
||||
plString &operator+=(const plString &str) { return operator=(*this + str); }
|
||||
|
||||
|
@ -41,6 +41,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
*==LICENSE==*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cmath>
|
||||
|
||||
#include "HeadSpin.h"
|
||||
#include "plRandomCommandMod.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 <vector>
|
||||
|
||||
class plPipeline;
|
||||
class plCameraModifier1;
|
||||
|
@ -376,11 +376,11 @@ public:
|
||||
count = stream->ReadLE32();
|
||||
if ( count != 0 )
|
||||
{
|
||||
char *buffer = new char[count];
|
||||
plStringBuffer<char> 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;
|
||||
|
@ -51,6 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include "pyGUIControl.h"
|
||||
#include "pyGlueHelpers.h"
|
||||
#include <string>
|
||||
|
||||
class pyColor;
|
||||
class pfGUIColorScheme;
|
||||
|
@ -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 <string>
|
||||
|
||||
class pfGUIPopUpMenu;
|
||||
class pyColor;
|
||||
|
@ -49,7 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pyGlueHelpers.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class cyAnimation;
|
||||
class pyImage;
|
||||
|
@ -51,6 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include "pyGlueHelpers.h"
|
||||
#include "pnKeyedObject/plKey.h"
|
||||
#include <string>
|
||||
|
||||
class pyPlayer
|
||||
{
|
||||
|
@ -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 <vector>
|
||||
|
||||
class pyMatrix44;
|
||||
|
||||
|
@ -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()));
|
||||
|
Reference in New Issue
Block a user