Browse Source

Manual merge of Pull Request #232 from zrax/plString

Conflicts:
	Sources/Plasma/CoreLib/HeadSpin.h
Adam Johnson 12 years ago
parent
commit
75793e5182
  1. 7
      CMakeLists.txt
  2. 4
      Sources/Plasma/Apps/plClient/CMakeLists.txt
  3. 4
      Sources/Plasma/Apps/plClient/winmain.cpp
  4. 4
      Sources/Plasma/Apps/plClientPatcher/CMakeLists.txt
  5. 24
      Sources/Plasma/Apps/plClientPatcher/UruPlayer.cpp
  6. 6
      Sources/Plasma/Apps/plCrashHandler/CMakeLists.txt
  7. 4
      Sources/Plasma/Apps/plFileEncrypt/CMakeLists.txt
  8. 4
      Sources/Plasma/Apps/plFileSecure/CMakeLists.txt
  9. 4
      Sources/Plasma/Apps/plMD5/CMakeLists.txt
  10. 4
      Sources/Plasma/Apps/plPageInfo/CMakeLists.txt
  11. 4
      Sources/Plasma/Apps/plPythonPack/CMakeLists.txt
  12. 4
      Sources/Plasma/Apps/plSHA/CMakeLists.txt
  13. 4
      Sources/Plasma/Apps/plUruLauncher/CMakeLists.txt
  14. 7
      Sources/Plasma/Apps/plUruLauncher/Main.cpp
  15. 6
      Sources/Plasma/CoreLib/HeadSpin.h
  16. 154
      Sources/Plasma/CoreLib/hsStream.cpp
  17. 7
      Sources/Plasma/CoreLib/hsStream.h
  18. 5
      Sources/Plasma/CoreLib/hsThread_Win.cpp
  19. 78
      Sources/Plasma/CoreLib/plString.cpp
  20. 27
      Sources/Plasma/CoreLib/plString.h
  21. 22
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp
  22. 4
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp
  23. 3
      Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp
  24. 8
      Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp
  25. 57
      Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp
  26. 28
      Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.h
  27. 2
      Sources/Plasma/FeatureLib/pfPython/pyGlueHelpers.h
  28. 29
      Sources/Plasma/FeatureLib/pfPython/pySDL.cpp
  29. 13
      Sources/Plasma/FeatureLib/pfPython/pySDL.h
  30. 10
      Sources/Plasma/FeatureLib/pfPython/pySDLGlue.cpp
  31. 12
      Sources/Plasma/FeatureLib/pfPython/pySpawnPointInfo.h
  32. 12
      Sources/Plasma/FeatureLib/pfPython/pySpawnPointInfoGlue.cpp
  33. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNode.cpp
  34. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNode.h
  35. 5
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceThread.cpp
  36. 6
      Sources/Plasma/NucleusLib/pnMessage/plSDLModifierMsg.cpp
  37. 8
      Sources/Plasma/NucleusLib/pnMessage/plSDLModifierMsg.h
  38. 4
      Sources/Plasma/NucleusLib/pnMessage/plSDLNotificationMsg.h
  39. 7
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp
  40. 4
      Sources/Plasma/PubUtilLib/plAvatar/plClothingSDLModifier.cpp
  41. 2
      Sources/Plasma/PubUtilLib/plDrawable/plMorphSequenceSDLMod.cpp
  42. 4
      Sources/Plasma/PubUtilLib/plModifier/plSDLModifier.cpp
  43. 2
      Sources/Plasma/PubUtilLib/plModifier/plSDLModifier.h
  44. 6
      Sources/Plasma/PubUtilLib/plNetClient/plLinkEffectsMgr.cpp
  45. 4
      Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp
  46. 13
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp
  47. 8
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgHandler.cpp
  48. 2
      Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp
  49. 3
      Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp
  50. 9
      Sources/Plasma/PubUtilLib/plNetClientRecorder/plNetClientStatsRecorder.cpp
  51. 9
      Sources/Plasma/PubUtilLib/plNetClientRecorder/plNetClientStreamRecorder.cpp
  52. 10
      Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.cpp
  53. 10
      Sources/Plasma/PubUtilLib/plNetCommon/plSpawnPointInfo.cpp
  54. 23
      Sources/Plasma/PubUtilLib/plNetCommon/plSpawnPointInfo.h
  55. 4
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp
  56. 40
      Sources/Plasma/PubUtilLib/plSDL/plSDL.h
  57. 61
      Sources/Plasma/PubUtilLib/plSDL/plSDLDescriptor.h
  58. 6
      Sources/Plasma/PubUtilLib/plSDL/plSDLMgr.cpp
  59. 58
      Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp
  60. 2
      Sources/Plasma/PubUtilLib/plSDL/plStateChangeNotifier.cpp
  61. 66
      Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp
  62. 8
      Sources/Plasma/PubUtilLib/plSDL/plStateDescriptor.cpp
  63. 130
      Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp
  64. 120
      Sources/Plasma/PubUtilLib/plSDL/plVarDescriptor.cpp
  65. 8
      Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp
  66. 48
      Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp
  67. 4
      Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.h
  68. 2
      Sources/Tools/MaxComponent/plAnimComponent.cpp
  69. 4
      Sources/Tools/MaxMain/CMakeLists.txt
  70. 4
      Sources/Tools/MaxPlasmaLights/CMakeLists.txt
  71. 4
      Sources/Tools/plFontConverter/CMakeLists.txt
  72. 4
      Sources/Tools/plLocalizationEditor/CMakeLists.txt
  73. 8
      Sources/Tools/plResBrowser/CMakeLists.txt
  74. 23
      cmake/FindVLD.cmake

7
CMakeLists.txt

@ -76,6 +76,13 @@ if(PLASMA_TARGETS STREQUAL "Ethereal")
add_definitions(-DSTREAM_LOGGER)
endif(PLASMA_TARGETS STREQUAL "Ethereal")
option(USE_VLD "Build and link with Visual Leak Detector (MSVC only)" OFF)
if(USE_VLD)
add_definitions(-DUSE_VLD)
find_package(VLD REQUIRED)
include_directories(${VLD_INCLUDE_DIR})
endif(USE_VLD)
include(TestBigEndian)
test_big_endian(BIG_ENDIAN)
if(BIG_ENDIAN)

4
Sources/Plasma/Apps/plClient/CMakeLists.txt

@ -178,6 +178,10 @@ if(Bink_SDK_AVAILABLE)
target_link_libraries(plClient ${Bink_LIBRARIES})
endif()
if(USE_VLD)
target_link_libraries(plClient ${VLD_LIBRARY})
endif()
if (WIN32)
target_link_libraries(plClient Rpcrt4)
target_link_libraries(plClient Version)

4
Sources/Plasma/Apps/plClient/winmain.cpp

@ -945,6 +945,10 @@ static size_t CurlCallback(void *buffer, size_t size, size_t nmemb, void *param)
void StatusCallback(void *param)
{
#ifdef USE_VLD
VLDEnable();
#endif
HWND hwnd = (HWND)param;
const char *statusUrl = GetServerStatusUrl();

4
Sources/Plasma/Apps/plClientPatcher/CMakeLists.txt

@ -20,5 +20,9 @@ set(plClientPatcher_SOURCES
add_library(plClientPatcher STATIC ${plClientPatcher_HEADERS} ${plClientPatcher_SOURCES})
target_link_libraries(plClientPatcher CoreLib plAudioCore plStatusLog)
if(USE_VLD)
target_link_libraries(plClientPatcher ${VLD_LIBRARY})
endif()
source_group("Header Files" FILES ${plClientPatcher_HEADERS})
source_group("Source Files" FILES ${plClientPatcher_SOURCES})

24
Sources/Plasma/Apps/plClientPatcher/UruPlayer.cpp

@ -264,6 +264,10 @@ static void NetErrorHandler (ENetProtocol protocol, ENetError error) {
/*
//============================================================================
static void WaitUruExitProc (void * param) {
#ifdef USE_VLD
VLDEnable();
#endif
plLauncherInfo *info = (plLauncherInfo *) param;
WaitForSingleObject(s_pi.hProcess, INFINITE);
DWORD exitcode;
@ -539,6 +543,10 @@ static void ProcessManifestEntry (void * param, ENetError error) {
//============================================================================
static void ProcessManifest (void * param) {
#ifdef USE_VLD
VLDEnable();
#endif
wchar_t basePath[MAX_PATH];
char path[MAX_PATH];
AtomicAdd(&s_perf[kPerfThreadTaskCount], 1);
@ -885,6 +893,10 @@ void ShutdownAsyncCore () {
//============================================================================
// param = URU_PreparationRequest
void UruPrepProc (void * param) {
#ifdef USE_VLD
VLDEnable();
#endif
s_running = true;
plLauncherInfo *info = (plLauncherInfo *) param;
@ -952,6 +964,10 @@ void UruPrepProc (void * param) {
//============================================================================
void PlayerStopProc (void * param) {
#ifdef USE_VLD
VLDEnable();
#endif
s_running = false;
plLauncherInfo *info = (plLauncherInfo *) param;
//TerminateProcess(s_pi.hProcess, kExitCodeTerminated);
@ -960,6 +976,10 @@ void PlayerStopProc (void * param) {
//============================================================================
void PlayerTerminateProc (void * param) {
#ifdef USE_VLD
VLDEnable();
#endif
s_running = false;
plLauncherInfo *info = (plLauncherInfo *) param;
ShutdownAsyncCore();
@ -968,6 +988,10 @@ void PlayerTerminateProc (void * param) {
//============================================================================
void UruStartProc (void * param) {
#ifdef USE_VLD
VLDEnable();
#endif
if(!s_running)
return;

6
Sources/Plasma/Apps/plCrashHandler/CMakeLists.txt

@ -15,7 +15,11 @@ target_link_libraries(plCrashHandler pfCrashHandler)
target_link_libraries(plCrashHandler plFile)
target_link_libraries(plCrashHandler pnProduct)
if(USE_VLD)
target_link_libraries(plCrashHandler ${VLD_LIBRARY})
endif()
# Platform specific libs
if(WIN32)
target_link_libraries(plCrashHandler Dbghelp)
target_link_libraries(plCrashHandler Dbghelp)
endif(WIN32)

4
Sources/Plasma/Apps/plFileEncrypt/CMakeLists.txt

@ -14,4 +14,8 @@ set(plFileEncrypt_SOURCES
add_executable(plFileEncrypt ${plFileEncrypt_SOURCES})
target_link_libraries(plFileEncrypt CoreLib pnProduct plFile)
if(USE_VLD)
target_link_libraries(plFileEncrypt ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plFileEncrypt_SOURCES})

4
Sources/Plasma/Apps/plFileSecure/CMakeLists.txt

@ -14,4 +14,8 @@ set(plFileSecure_SOURCES
add_executable(plFileSecure ${plFileSecure_SOURCES})
target_link_libraries(plFileSecure CoreLib pnProduct plFile)
if(USE_VLD)
target_link_libraries(plFileSecure ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plFileSecure_SOURCES})

4
Sources/Plasma/Apps/plMD5/CMakeLists.txt

@ -16,4 +16,8 @@ add_executable(plMD5 ${plMD5_SOURCES})
target_link_libraries(plMD5 CoreLib pnUtils pnProduct pnEncryption)
target_link_libraries(plMD5 ${OPENSSL_LIBRARIES})
if(USE_VLD)
target_link_libraries(plMD5 ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plMD5_SOURCES})

4
Sources/Plasma/Apps/plPageInfo/CMakeLists.txt

@ -15,4 +15,8 @@ set(plPageInfo_SOURCES
add_executable(plPageInfo ${plPageInfo_SOURCES})
target_link_libraries(plPageInfo CoreLib pnProduct plResMgr plAudioCore)
if(USE_VLD)
target_link_libraries(plPageInfo ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plPageInfo_SOURCES})

4
Sources/Plasma/Apps/plPythonPack/CMakeLists.txt

@ -22,5 +22,9 @@ else()
target_link_libraries(plPythonPack ${PYTHON_LIBRARY})
endif()
if(USE_VLD)
target_link_libraries(plPythonPack ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plPythonPack_SOURCES})
source_group("Header Files" FILES ${plPythonPack_HEADERS})

4
Sources/Plasma/Apps/plSHA/CMakeLists.txt

@ -16,4 +16,8 @@ add_executable(plSHA ${plSHA_SOURCES})
target_link_libraries(plSHA CoreLib pnUtils pnProduct pnEncryption)
target_link_libraries(plSHA ${OPENSSL_LIBRARIES})
if(USE_VLD)
target_link_libraries(plSHA ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plSHA_SOURCES})

4
Sources/Plasma/Apps/plUruLauncher/CMakeLists.txt

@ -65,6 +65,10 @@ target_link_libraries(plUruLauncher ws2_32)
target_link_libraries(plUruLauncher rpcrt4)
target_link_libraries(plUruLauncher comctl32)
if(USE_VLD)
target_link_libraries(plUruLauncher ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plUruLauncher_SOURCES})
source_group("Header Files" FILES ${plUruLauncher_HEADERS})
source_group("Resource Files" FILES ${plUruLauncher_RESOURCES})

7
Sources/Plasma/Apps/plUruLauncher/Main.cpp

@ -431,6 +431,9 @@ BOOL CALLBACK SplashDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
//============================================================================
static void WindowThreadProc(void *) {
#ifdef USE_VLD
VLDEnable();
#endif
InitCommonControls();
s_event = CreateEvent(
@ -476,6 +479,10 @@ static size_t CurlCallback(void *buffer, size_t size, size_t nmemb, void *)
//============================================================================
static void StatusCallback(void *)
{
#ifdef USE_VLD
VLDEnable();
#endif
const char *serverUrl = GetServerStatusUrl();
CURL * hCurl = curl_easy_init();

6
Sources/Plasma/CoreLib/HeadSpin.h

@ -80,8 +80,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
# define NOMINMAX // Needed to prevent NxMath conflicts
# endif
# include <Windows.h>
#endif
// This needs to be after #include <windows.h>, since it also includes windows.h
# ifdef USE_VLD
# include <vld.h>
# endif
#endif // HS_BUILD_FOR_WIN32
//======================================
// We don't want the Windows.h min/max!

154
Sources/Plasma/CoreLib/hsStream.cpp

@ -112,17 +112,6 @@ void hsStream::CopyToMem(void* mem)
//////////////////////////////////////////////////////////////////////////////////
hsStream::~hsStream()
{
}
uint32_t hsStream::WriteString(const char cstring[])
{
if (cstring)
return Write(strlen(cstring), cstring);
return 0;
}
uint32_t hsStream::WriteFmt(const char * fmt, ...)
{
va_list av;
@ -159,64 +148,81 @@ uint32_t hsStream::WriteSafeStringLong(const plString &string)
uint32_t hsStream::WriteSafeWStringLong(const plString &string)
{
plStringBuffer<wchar_t> wbuff = string.ToWchar();
plStringBuffer<uint16_t> wbuff = string.ToUtf16();
uint32_t len = wbuff.GetSize();
WriteLE32(len);
if (len > 0)
{
const wchar_t *buffp = wbuff.GetData();
const uint16_t *buffp = wbuff.GetData();
for (uint32_t i=0; i<len; i++)
{
WriteLE16((uint16_t)~buffp[i]);
WriteLE16(~buffp[i]);
}
WriteLE16((uint16_t)L'\0');
WriteLE16(static_cast<uint16_t>(0));
}
return 0;
}
char *hsStream::ReadSafeStringLong()
plString hsStream::ReadSafeStringLong_TEMP()
{
char *name = nil;
plStringBuffer<char> name;
uint32_t numChars = ReadLE32();
if (numChars > 0 && numChars <= GetSizeLeft())
{
name = new char[numChars+1];
Read(numChars, name);
name[numChars] = '\0';
char *buff = name.CreateWritableBuffer(numChars);
Read(numChars, buff);
buff[numChars] = 0;
// if the high bit is set, flip the bits. Otherwise it's a normal string, do nothing.
if (name[0] & 0x80)
if (buff[0] & 0x80)
{
int i;
for (i = 0; i < numChars; i++)
name[i] = ~name[i];
for (int i = 0; i < numChars; i++)
buff[i] = ~buff[i];
}
}
return name;
}
wchar_t *hsStream::ReadSafeWStringLong()
char *hsStream::ReadSafeStringLong()
{
wchar_t *retVal = nil;
plString name = ReadSafeStringLong_TEMP();
char *buff = new char[name.GetSize() + 1];
memcpy(buff, name.c_str(), name.GetSize() + 1);
return buff;
}
plString hsStream::ReadSafeWStringLong_TEMP()
{
plStringBuffer<uint16_t> retVal;
uint32_t numChars = ReadLE32();
if (numChars > 0 && numChars <= (GetSizeLeft()/2)) // divide by two because each char is two bytes
{
retVal = new wchar_t[numChars+1];
int i;
for (i=0; i<numChars; i++)
retVal[i] = (wchar_t)ReadLE16();
retVal[numChars] = (wchar_t)ReadLE16(); // we wrote the null out, read it back in
uint16_t *buff = retVal.CreateWritableBuffer(numChars);
for (int i=0; i<numChars; i++)
buff[i] = ReadLE16();
ReadLE16(); // we wrote the null out, read it back in
buff[numChars] = 0; // But terminate it safely anyway
if (retVal[0]* 0x80)
if (buff[0]* 0x80)
{
int i;
for (i=0; i<numChars; i++)
retVal[i] = ~retVal[i];
for (int i=0; i<numChars; i++)
buff[i] = ~buff[i];
}
}
return retVal;
return plString::FromUtf16(retVal);
}
wchar_t *hsStream::ReadSafeWStringLong()
{
// Horribly inefficient (convert to UTF-8 and then back to UTF-16), which
// is why this should go away completely after plString has taken over
// the world^H^H^H^H^HPlasma
plStringBuffer<wchar_t> retVal = ReadSafeWStringLong_TEMP().ToWchar();
wchar_t *buff = new wchar_t[retVal.GetSize() + 1];
memcpy(buff, retVal.GetData(), retVal.GetSize() + 1);
return buff;
}
uint32_t hsStream::WriteSafeString(const plString &string)
@ -242,27 +248,27 @@ uint32_t hsStream::WriteSafeString(const plString &string)
uint32_t hsStream::WriteSafeWString(const plString &string)
{
plStringBuffer<wchar_t> wbuff = string.ToWchar();
plStringBuffer<uint16_t> wbuff = string.ToUtf16();
uint32_t len = wbuff.GetSize();
hsAssert(len<0xf000, xtl::format("string len of %d is too long for WriteSafeWString, use WriteSafeWStringLong",
hsAssert(len<0xf000, plString::Format("string len of %d is too long for WriteSafeWString, use WriteSafeWStringLong",
len).c_str() );
WriteLE16(len | 0xf000);
if (len > 0)
{
const wchar_t *buffp = wbuff.GetData();
const uint16_t *buffp = wbuff.GetData();
for (uint32_t i=0; i<len; i++)
{
WriteLE16((uint16_t)~buffp[i]);
WriteLE16(~buffp[i]);
}
WriteLE16((uint16_t)L'\0');
WriteLE16(static_cast<uint16_t>(0));
}
return 0;
}
char *hsStream::ReadSafeString()
plString hsStream::ReadSafeString_TEMP()
{
char *name = nil;
plStringBuffer<char> name;
uint16_t numChars = ReadLE16();
#ifndef REMOVE_ME_SOON
@ -276,62 +282,64 @@ char *hsStream::ReadSafeString()
hsAssert(numChars <= GetSizeLeft(), "Bad string");
if (numChars > 0 && numChars <= GetSizeLeft())
{
name = new char[numChars+1];
Read(numChars, name);
name[numChars] = '\0';
char *buff = name.CreateWritableBuffer(numChars);
Read(numChars, buff);
buff[numChars] = 0;
// if the high bit is set, flip the bits. Otherwise it's a normal string, do nothing.
if (name[0] & 0x80)
if (buff[0] & 0x80)
{
int i;
for (i = 0; i < numChars; i++)
name[i] = ~name[i];
buff[i] = ~buff[i];
}
}
return name;
}
wchar_t *hsStream::ReadSafeWString()
char *hsStream::ReadSafeString()
{
wchar_t *retVal = nil;
plString name = ReadSafeString_TEMP();
char *buff = new char[name.GetSize() + 1];
memcpy(buff, name.c_str(), name.GetSize() + 1);
return buff;
}
plString hsStream::ReadSafeWString_TEMP()
{
plStringBuffer<uint16_t> retVal;
uint32_t numChars = ReadLE16();
numChars &= ~0xf000;
hsAssert(numChars <= GetSizeLeft()/2, "Bad string");
if (numChars > 0 && numChars <= (GetSizeLeft()/2)) // divide by two because each char is two bytes
{
retVal = new wchar_t[numChars+1];
int i;
for (i=0; i<numChars; i++)
retVal[i] = (wchar_t)ReadLE16();
retVal[numChars] = (wchar_t)ReadLE16(); // we wrote the null out, read it back in
uint16_t *buff = retVal.CreateWritableBuffer(numChars);
for (int i=0; i<numChars; i++)
buff[i] = ReadLE16();
ReadLE16(); // we wrote the null out, read it back in
buff[numChars] = 0; // But terminate it safely anyway
if (retVal[0]* 0x80)
if (buff[0]* 0x80)
{
int i;
for (i=0; i<numChars; i++)
retVal[i] = ~retVal[i];
for (int i=0; i<numChars; i++)
buff[i] = ~buff[i];
}
}
return retVal;
}
plString hsStream::ReadSafeString_TEMP()
{
char *buffer = ReadSafeString();
plString result = plString::FromIso8859_1(buffer);
delete [] buffer;
return result;
return plString::FromUtf16(retVal);
}
plString hsStream::ReadSafeWString_TEMP()
wchar_t *hsStream::ReadSafeWString()
{
wchar_t *wbuffer = ReadSafeWString();
plString result = plString::FromWchar(wbuffer);
delete [] wbuffer;
return result;
// Horribly inefficient (convert to UTF-8 and then back to UTF-16), which
// is why this should go away completely after plString has taken over
// the world^H^H^H^H^HPlasma
plStringBuffer<wchar_t> retVal = ReadSafeWString_TEMP().ToWchar();
wchar_t *buff = new wchar_t[retVal.GetSize() + 1];
memcpy(buff, retVal.GetData(), retVal.GetSize() + 1);
return buff;
}
bool hsStream::Read4Bytes(void *pv) // Virtual, faster version in sub classes

7
Sources/Plasma/CoreLib/hsStream.h

@ -81,7 +81,7 @@ protected:
bool IsTokenSeparator(char c);
public:
hsStream() : fBytesRead(0), fPosition(0) {}
virtual ~hsStream();
virtual ~hsStream() { }
virtual bool Open(const char *, const char * = "rb")=0;
virtual bool Open(const wchar_t *, const wchar_t * = L"rb")=0;
@ -123,8 +123,7 @@ public:
virtual void CopyToMem(void* mem);
virtual bool IsCompressed() { return false; }
uint32_t WriteString(const char cstring[]);
uint32_t WriteString(const plString & string) { return WriteString(string.c_str()); }
uint32_t WriteString(const plString & string) { return Write(string.GetSize(), string.c_str()); }
uint32_t WriteFmt(const char * fmt, ...);
uint32_t WriteFmtV(const char * fmt, va_list av);
@ -138,6 +137,8 @@ public:
char * ReadSafeString();
wchar_t * ReadSafeWString();
plString ReadSafeStringLong_TEMP();
plString ReadSafeWStringLong_TEMP();
plString ReadSafeString_TEMP();
plString ReadSafeWString_TEMP();

5
Sources/Plasma/CoreLib/hsThread_Win.cpp

@ -58,6 +58,11 @@ struct WinThreadParam
static unsigned int __stdcall gEntryPointBT(void* param)
{
#ifdef USE_VLD
// Needs to be enabled for each thread except the WinMain
VLDEnable();
#endif
WinThreadParam* wtp = (WinThreadParam*)param;
unsigned int result = wtp->fThread->Run();
::ReleaseSemaphore(wtp->fQuitSemaH, 1, nil); // signal that we've quit

78
Sources/Plasma/CoreLib/plString.cpp

@ -700,6 +700,60 @@ plString plString::ToLower() const
return str;
}
static bool ch_in_set(char ch, const char *set)
{
for (const char *s = set; *s; ++s) {
if (ch == *s)
return true;
}
return false;
}
std::vector<plString> plString::Tokenize(const char *delims) const
{
std::vector<plString> result;
const char *next = c_str();
const char *end = next + GetSize(); // So binary strings work
while (next != end) {
const char *cur = next;
while (cur != end && !ch_in_set(*cur, delims))
++cur;
// Found a delimiter
if (cur != next)
result.push_back(plString::FromUtf8(next, cur - next));
next = cur;
while (next != end && ch_in_set(*next, delims))
++next;
}
return result;
}
//TODO: Not binary safe
std::vector<plString> plString::Split(const char *split, size_t maxSplits) const
{
std::vector<plString> result;
const char *next = c_str();
size_t splitlen = strlen(split);
while (maxSplits > 0) {
const char *sp = strstr(next, split);
if (!sp)
break;
result.push_back(plString::FromUtf8(next, sp - next));
next = sp + splitlen;
--maxSplits;
}
result.push_back(plString::FromUtf8(next));
return result;
}
plString operator+(const plString &left, const plString &right)
{
plString cat;
@ -711,6 +765,30 @@ plString operator+(const plString &left, const plString &right)
return cat;
}
plString operator+(const plString &left, const char *right)
{
plString cat;
size_t rsize = strlen(right);
char *catstr = cat.fUtf8Buffer.CreateWritableBuffer(left.GetSize() + rsize);
memcpy(catstr, left.c_str(), left.GetSize());
memcpy(catstr + left.GetSize(), right, rsize);
catstr[cat.fUtf8Buffer.GetSize()] = 0;
return cat;
}
plString operator+(const char *left, const plString &right)
{
plString cat;
size_t lsize = strlen(left);
char *catstr = cat.fUtf8Buffer.CreateWritableBuffer(lsize + right.GetSize());
memcpy(catstr, left, lsize);
memcpy(catstr + lsize, right.c_str(), right.GetSize());
catstr[cat.fUtf8Buffer.GetSize()] = 0;
return cat;
}
plStringStream &plStringStream::append(const char *data, size_t length)
{
if (fLength + length > fBufSize) {

27
Sources/Plasma/CoreLib/plString.h

@ -44,7 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plString_Defined
#include "HeadSpin.h"
#include <stddef.h>
#include <vector>
typedef unsigned int UniChar;
@ -163,18 +163,15 @@ private:
public:
plString() { }
#ifndef PLSTRING_POLLUTE_ASCII_CAST
plString(const char *cstr) { IConvertFromUtf8(cstr, kSizeAuto); }
#endif
plString(const plString &copy) : fUtf8Buffer(copy.fUtf8Buffer) { }
plString(const plStringBuffer<char> &init) { operator=(init); }
#ifndef PLSTRING_POLLUTE_ASCII_CAST
plString &operator=(const char *cstr) { IConvertFromUtf8(cstr, kSizeAuto); return *this; }
#endif
plString &operator=(const plString &copy) { fUtf8Buffer = copy.fUtf8Buffer; return *this; }
plString &operator=(const plStringBuffer<char> &init);
plString &operator+=(const char *cstr) { return operator=(*this + cstr); }
plString &operator+=(const plString &str) { return operator=(*this + str); }
static inline plString FromUtf8(const char *utf8, size_t size = kSizeAuto)
@ -205,10 +202,8 @@ public:
return str;
}
#ifndef PLSTRING_POLLUTE_C_STR
const char *c_str(const char *substitute = "") const
{ return IsEmpty() ? substitute : fUtf8Buffer.GetData(); }
#endif
char CharAt(size_t position) const { return c_str()[position]; }
@ -263,8 +258,15 @@ public:
: strnicmp(c_str(), str, count);
}
int CompareI(const plString &str) const { return Compare(str, kCaseInsensitive); }
int CompareI(const char *str) const { return Compare(str, kCaseInsensitive); }
int CompareNI(const plString &str, size_t count) const { return CompareN(str, count, kCaseInsensitive); }
int CompareNI(const char *str, size_t count) const { return CompareN(str, count, kCaseInsensitive); }
bool operator<(const plString &other) const { return Compare(other) < 0; }
bool operator==(const char *other) const { return Compare(other) == 0; }
bool operator==(const plString &other) const { return Compare(other) == 0; }
bool operator!=(const char *other) const { return Compare(other) != 0; }
bool operator!=(const plString &other) const { return Compare(other) != 0; }
int Find(char ch, CaseSensitivity sense = kCaseSensitive) const;
@ -287,6 +289,13 @@ public:
plString ToUpper() const;
plString ToLower() const;
// Should replace other tokenization methods. The difference between Split
// and Tokenize is that Tokenize never returns a blank string (it strips
// all delimiters and only returns the pieces left between them), whereas
// Split will split on a full string, returning whatever is left between.
std::vector<plString> Split(const char *split, size_t maxSplits = kSizeAuto) const;
std::vector<plString> Tokenize(const char *delims = " \t\r\n\f\v") const;
public:
struct less
{
@ -416,9 +425,13 @@ public:
private:
friend plString operator+(const plString &left, const plString &right);
friend plString operator+(const plString &left, const char *right);
friend plString operator+(const char *left, const plString &right);
};
plString operator+(const plString &left, const plString &right);
plString operator+(const plString &left, const char *right);
plString operator+(const char *left, const plString &right);
class plStringStream

22
Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp

@ -6044,22 +6044,18 @@ PF_CONSOLE_CMD(Age, ShowSDL, "", "Prints the age SDL values")
return;
}
char line[2048];
plStatusLog::AddLineS("ShowSDL.log", "-----------------------------------");
for (unsigned i = 0; i < rec->GetNumVars(); ++i) {
plStateVariable * var = rec->GetVar(i);
if (plSimpleStateVariable * simple = var->GetAsSimpleStateVar()) {
const char * name = var->GetName();
StrPrintf(line, arrsize(line), "%s=", name);
plString line = var->GetName();
line += "=";
for (unsigned j = 0; j < simple->GetCount(); ++j) {
char * str = simple->GetAsString(j);
StrPack(line, str, arrsize(line));
StrPack(line, ",", arrsize(line));
free(str);
line += simple->GetAsString(j);
line += ",";
}
PrintString(line);
plStatusLog::AddLineS("ShowSDL.log", "%s", line);
PrintString(line.c_str());
plStatusLog::AddLineS("ShowSDL.log", "%s", line.c_str());
}
}
@ -6117,7 +6113,7 @@ PF_CONSOLE_CMD( Age, SetSDLFloat, "string varName, float value, int index", "Set
if (!sdlMod)
return;
plSimpleStateVariable *var = sdlMod->GetStateCache()->FindVar(params[0]);
plSimpleStateVariable *var = sdlMod->GetStateCache()->FindVar((const char *)params[0]);
if (!var)
return;
@ -6141,7 +6137,7 @@ PF_CONSOLE_CMD( Age, SetSDLInt, "string varName, int value, int index", "Set the
if (!sdlMod)
return;
plSimpleStateVariable *var = sdlMod->GetStateCache()->FindVar(params[0]);
plSimpleStateVariable *var = sdlMod->GetStateCache()->FindVar((const char *)params[0]);
if (!var)
return;
@ -6164,7 +6160,7 @@ PF_CONSOLE_CMD( Age, SetSDLBool, "string varName, bool value, int index", "Set t
if (!sdlMod)
return;
plSimpleStateVariable *var = sdlMod->GetStateCache()->FindVar(params[0]);
plSimpleStateVariable *var = sdlMod->GetStateCache()->FindVar((const char*)params[0]);
if (!var)
return;

4
Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp

@ -356,7 +356,7 @@ PF_CONSOLE_CMD( Net, // groupName
link.GetAgeInfo()->SetAgeFilename( params[0] );
//link.GetAgeInfo()->SetAgeInstanceName( params[0] );
//link.GetAgeInfo()->SetAgeUserDefinedName( params[0] );
plUUID guid(params[1]);
plUUID guid( (const char *)params[1] );
link.GetAgeInfo()->SetAgeInstanceGuid( &guid );
link.SetLinkingRules( plNetCommon::LinkingRules::kBasicLink );
plNetLinkingMgr::GetInstance()->LinkToAge( &link );
@ -379,7 +379,7 @@ PF_CONSOLE_CMD( Net,
{
plAgeLinkStruct link;
link.GetAgeInfo()->SetAgeFilename( params[0] );
link.SpawnPoint() = plSpawnPointInfo( params[1], params[1] );
link.SpawnPoint() = plSpawnPointInfo( (const char *)params[1], (const char *)params[1] );
link.SetLinkingRules( plNetCommon::LinkingRules::kOriginalBook );
plNetLinkingMgr::GetInstance()->LinkToAge( &link );
PrintString("Linking to age with original book...");

3
Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp

@ -395,8 +395,7 @@ pfConsoleCmd::~pfConsoleCmd()
for( i = 0; i < fSigLabels.GetCount(); i++ )
{
if( fSigLabels[ i ] != nil )
delete [] fSigLabels[ i ];
delete [] fSigLabels[ i ];
}
Unregister();

8
Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp

@ -2300,16 +2300,14 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
plSDLNotificationMsg* sn = plSDLNotificationMsg::ConvertNoRef(msg);
if (sn)
{
const char* tag = sn->fHintString.c_str();
if (tag == nil)
tag = "";
plString tag = sn->fHintString;
// yes... then call it
plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_SDLNotify],
(char*)fFunctionNames[kfunc_SDLNotify],
"ssls", sn->fVar->GetName(), sn->fSDLName.c_str(),
sn->fPlayerID, tag);
"ssls", sn->fVar->GetName().c_str(), sn->fSDLName.c_str(),
sn->fPlayerID, tag.c_str());
if ( retVal == nil )
{
#ifndef PLASMA_EXTERNAL_RELEASE

57
Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp

@ -81,7 +81,7 @@ plPythonSDLModifier::plPythonSDLModifier(plPythonFileMod* owner) : fOwner(owner)
{
plVarDescriptor* var = desc->GetVar(i);
const char* name = var->GetName();
plString name = var->GetName();
int count = var->GetCount();
fMap[name] = SDLObj(nil, count, false);
@ -99,15 +99,14 @@ plPythonSDLModifier::~plPythonSDLModifier()
}
}
PyObject* plPythonSDLModifier::GetItem(const char* key)
PyObject* plPythonSDLModifier::GetItem(const plString& key)
{
SDLMap::iterator it = fMap.find(key);
if (it == fMap.end())
{
char errmsg[256];
sprintf(errmsg,"SDL key %s not found",key);
PyErr_SetString(PyExc_KeyError, errmsg);
plString errmsg = plString::Format("SDL key %s not found", key.c_str());
PyErr_SetString(PyExc_KeyError, errmsg.c_str());
PYTHON_RETURN_ERROR;
}
@ -119,7 +118,7 @@ PyObject* plPythonSDLModifier::GetItem(const char* key)
return val;
}
void plPythonSDLModifier::ISetItem(const char* key, PyObject* value)
void plPythonSDLModifier::ISetItem(const plString& key, PyObject* value)
{
if (!value || !PyTuple_Check(value))
{
@ -149,19 +148,19 @@ void plPythonSDLModifier::ISetItem(const char* key, PyObject* value)
oldObj.obj = value;
}
void plPythonSDLModifier::SendToClients(const char* key)
void plPythonSDLModifier::SendToClients(const plString& key)
{
SDLMap::iterator it = fMap.find(key);
if (it != fMap.end())
it->second.sendToClients = true;
}
void plPythonSDLModifier::SetNotify(pyKey& selfkey, const char* key, float tolerance)
void plPythonSDLModifier::SetNotify(pyKey& selfkey, const plString& key, float tolerance)
{
AddNotifyForVar(selfkey.getKey(), key, tolerance);
}
void plPythonSDLModifier::SetItem(const char* key, PyObject* value)
void plPythonSDLModifier::SetItem(const plString& key, PyObject* value)
{
ISetItem(key, value);
IDirtySynchState(key);
@ -169,7 +168,7 @@ void plPythonSDLModifier::SetItem(const char* key, PyObject* value)
void plPythonSDLModifier::SetItemFromSDLVar(plSimpleStateVariable* var)
{
const char* name = var->GetName();
plString name = var->GetName();
// Get the SDL value in Python format
PyObject* pyVar = ISDLVarToPython(var);
@ -180,12 +179,12 @@ void plPythonSDLModifier::SetItemFromSDLVar(plSimpleStateVariable* var)
}
void plPythonSDLModifier::SetDefault(const char* key, PyObject* value)
void plPythonSDLModifier::SetDefault(const plString& key, PyObject* value)
{
ISetItem(key, value);
}
void plPythonSDLModifier::SetItemIdx(const char* key, int idx, PyObject* value, bool sendImmediate)
void plPythonSDLModifier::SetItemIdx(const plString& key, int idx, PyObject* value, bool sendImmediate)
{
if (!value)
{
@ -269,7 +268,7 @@ const char* plPythonSDLModifier::GetSDLName() const
return fOwner->fPythonFile;
}
void plPythonSDLModifier::SetFlags(const char* name, bool sendImmediate, bool skipOwnershipCheck)
void plPythonSDLModifier::SetFlags(const plString& name, bool sendImmediate, bool skipOwnershipCheck)
{
SDLMap::iterator it = fMap.find(name);
if (it != fMap.end())
@ -279,7 +278,7 @@ void plPythonSDLModifier::SetFlags(const char* name, bool sendImmediate, bool sk
}
}
void plPythonSDLModifier::SetTagString(const char* name, const char* tag)
void plPythonSDLModifier::SetTagString(const plString& name, const plString& tag)
{
SDLMap::iterator it = fMap.find(name);
if (it != fMap.end())
@ -297,7 +296,7 @@ void plPythonSDLModifier::ISetCurrentStateFrom(const plStateDataRecord* srcState
{
plSimpleStateVariable* var = vars[i];
const char* name = var->GetName();
plString name = var->GetName();
// Get the SDL value in Python format
PyObject* pyVar = ISDLVarToPython(var);
@ -334,11 +333,11 @@ void plPythonSDLModifier::IPutCurrentStateIn(plStateDataRecord* dstState)
SDLMap::iterator it = fMap.begin();
for (; it != fMap.end(); it++)
{
IPythonVarToSDL(dstState, it->first.c_str());
IPythonVarToSDL(dstState, it->first);
}
}
void plPythonSDLModifier::IDirtySynchState(const char* name, bool sendImmediate)
void plPythonSDLModifier::IDirtySynchState(const plString& name, bool sendImmediate)
{
SDLMap::iterator it = fMap.find(name);
if (it != fMap.end())
@ -358,7 +357,7 @@ void plPythonSDLModifier::IDirtySynchState(const char* name, bool sendImmediate)
}
bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int varIdx, int type, PyObject* pyVar,
const char* hintstring)
const plString& hintstring)
{
switch (type)
{
@ -370,7 +369,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{
int v = PyInt_AsLong(pyVar);
var->Set(v, varIdx);
if (hintstring)
if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring);
return true;
}
@ -378,7 +377,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{
int v = (int)PyLong_AsLong(pyVar);
var->Set(v, varIdx);
if (hintstring)
if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring);
return true;
}
@ -387,7 +386,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{
int v = (int)PyFloat_AsDouble(pyVar);
var->Set(v, varIdx);
if (hintstring)
if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring);
return true;
}
@ -398,7 +397,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{
float v = (float)PyFloat_AsDouble(pyVar);
var->Set(v, varIdx);
if (hintstring)
if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring);
return true;
}
@ -407,7 +406,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{
float v = (float)PyInt_AsLong(pyVar);
var->Set(v, varIdx);
if (hintstring)
if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring);
return true;
}
@ -418,7 +417,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{
char* v = PyString_AsString(pyVar);
var->Set(v, varIdx);
if (hintstring)
if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring);
}
break;
@ -428,7 +427,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
pyKey* key = PythonInterface::GetpyKeyFromPython(pyVar);
if ( key )
var->Set(key->getKey(),varIdx);
if (hintstring)
if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring);
}
break;
@ -438,7 +437,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{
double v = PyFloat_AsDouble(pyVar);
var->Set(v, varIdx);
if (hintstring)
if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring);
return true;
}
@ -446,7 +445,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{
double v = (double)PyInt_AsLong(pyVar);
var->Set(v, varIdx);
if (hintstring)
if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring);
return true;
}
@ -462,7 +461,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
return false;
}
void plPythonSDLModifier::IPythonVarToSDL(plStateDataRecord* state, const char* name)
void plPythonSDLModifier::IPythonVarToSDL(plStateDataRecord* state, const plString& name)
{
plSimpleStateVariable* var = state->FindVar(name);
PyObject* pyVar = nil;
@ -482,7 +481,7 @@ void plPythonSDLModifier::IPythonVarToSDL(plStateDataRecord* state, const char*
{
PyObject* pyVarItem = PyTuple_GetItem(pyVar, i);
if (pyVarItem)
IPythonVarIdxToSDL(var, i, type, pyVarItem,it->second.hintString.c_str());
IPythonVarIdxToSDL(var, i, type, pyVarItem,it->second.hintString);
}
}
}

28
Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.h

@ -70,11 +70,11 @@ protected:
bool sendToClients;
bool skipLocalCheck;
bool sendImmediate;
std::string hintString;
plString hintString;
SDLObj() : obj(nil), size(-1), sendToClients(false) {}
SDLObj(PyObject* obj, int size, bool sendToClients) : obj(obj), size(size), sendToClients(sendToClients) {}
};
typedef std::map<std::string, SDLObj> SDLMap;
typedef std::map<plString, SDLObj> SDLMap;
SDLMap fMap;
plPythonFileMod* fOwner;
@ -83,11 +83,11 @@ protected:
PyObject* ISDLVarToPython(plSimpleStateVariable* var);
PyObject* ISDLVarIdxToPython(plSimpleStateVariable* var, int type, int idx);
void IPythonVarToSDL(plStateDataRecord* state, const char* name);
bool IPythonVarIdxToSDL(plSimpleStateVariable* var, int varIdx, int type, PyObject* pyVar, const char* hintstring);
void IPythonVarToSDL(plStateDataRecord* state, const plString& name);
bool IPythonVarIdxToSDL(plSimpleStateVariable* var, int varIdx, int type, PyObject* pyVar, const plString& hintstring);
void ISetItem(const char* key, PyObject* value);
void IDirtySynchState(const char* name, bool sendImmediate = false);
void ISetItem(const plString& key, PyObject* value);
void IDirtySynchState(const plString& name, bool sendImmediate = false);
void IPutCurrentStateIn(plStateDataRecord* dstState);
void ISetCurrentStateFrom(const plStateDataRecord* srcState);
@ -106,15 +106,15 @@ public:
static const plPythonSDLModifier* FindAgeSDL();
static plKey FindAgeSDLTarget();
void SetDefault(const char* key, PyObject* value);
void SendToClients(const char* key);
void SetNotify(pyKey& selfkey, const char* key, float tolerance);
void SetDefault(const plString& key, PyObject* value);
void SendToClients(const plString& key);
void SetNotify(pyKey& selfkey, const plString& key, float tolerance);
PyObject* GetItem(const char* key);
void SetItem(const char* key, PyObject* value);
void SetItemIdx(const char* key, int idx, PyObject* value, bool sendImmediate = false);
void SetFlags(const char* name, bool sendImmediate, bool skipOwnershipCheck);
void SetTagString(const char* name, const char* tag);
PyObject* GetItem(const plString& key);
void SetItem(const plString& key, PyObject* value);
void SetItemIdx(const plString& key, int idx, PyObject* value, bool sendImmediate = false);
void SetFlags(const plString& name, bool sendImmediate, bool skipOwnershipCheck);
void SetTagString(const plString& name, const plString& tag);
};
// A wrapper for plPythonSDLModifier that Python uses

2
Sources/Plasma/FeatureLib/pfPython/pyGlueHelpers.h

@ -53,6 +53,8 @@ plString PyString_AsStringEx(PyObject* obj);
bool PyString_CheckEx(PyObject* obj);
PyObject* PyUnicode_FromStringEx(const plString& str);
#define PyString_FromPlString(x) PyString_FromString((x).c_str())
// A set of macros to take at least some of the tediousness out of creating straight python glue code
/////////////////////////////////////////////////////////////////////

29
Sources/Plasma/FeatureLib/pfPython/pySDL.cpp

@ -67,7 +67,7 @@ plStateDataRecord * pySDLStateDataRecord::GetRec() const
return fRec;
}
PyObject * pySDLStateDataRecord::FindVar( const char * name ) const
PyObject * pySDLStateDataRecord::FindVar( const plString & name ) const
{
if ( !fRec )
PYTHON_RETURN_NONE;
@ -79,17 +79,17 @@ PyObject * pySDLStateDataRecord::FindVar( const char * name ) const
return pySimpleStateVariable::New( var );
}
const char *pySDLStateDataRecord::GetName() const
plString pySDLStateDataRecord::GetName() const
{
if (!fRec)
return nil;
return "";
const plStateDescriptor *stateDesc = fRec->GetDescriptor();
return stateDesc->GetName();
}
std::vector<std::string> pySDLStateDataRecord::GetVarList()
std::vector<plString> pySDLStateDataRecord::GetVarList()
{
std::vector<std::string> retVal;
std::vector<plString> retVal;
if (!fRec)
return retVal;
const plStateDescriptor *stateDesc = fRec->GetDescriptor();
@ -225,16 +225,15 @@ bool pySimpleStateVariable::GetBool( int idx ) const
return v;
}
const char * pySimpleStateVariable::GetString( int idx ) const
plString pySimpleStateVariable::GetString( int idx ) const
{
fString = "";
if ( fVar )
{
char v[256];
if ( fVar->Get( v, idx ) )
fString = v;
return plString::FromUtf8(v);
}
return fString.c_str();
return "";
}
plKey pySimpleStateVariable::GetKey( int idx ) const
@ -253,18 +252,18 @@ int pySimpleStateVariable::GetType() const
return varDesc->GetType();
}
const char *pySimpleStateVariable::GetDisplayOptions() const
plString pySimpleStateVariable::GetDisplayOptions() const
{
if (!fVar)
return nil;
return "";
plVarDescriptor *varDesc = fVar->GetVarDescriptor();
return varDesc->GetDisplayOptions();
}
const char *pySimpleStateVariable::GetDefault() const
plString pySimpleStateVariable::GetDefault() const
{
if (!fVar)
return nil;
return "";
plVarDescriptor *varDesc = fVar->GetVarDescriptor();
return varDesc->GetDefault();
}
@ -272,7 +271,7 @@ const char *pySimpleStateVariable::GetDefault() const
bool pySimpleStateVariable::IsInternal() const
{
if (!fVar)
return nil;
return false;
plVarDescriptor *varDesc = fVar->GetVarDescriptor();
return varDesc->IsInternal();
}
@ -280,7 +279,7 @@ bool pySimpleStateVariable::IsInternal() const
bool pySimpleStateVariable::IsAlwaysNew() const
{
if (!fVar)
return nil;
return false;
plVarDescriptor *varDesc = fVar->GetVarDescriptor();
return varDesc->IsAlwaysNew();
}

13
Sources/Plasma/FeatureLib/pfPython/pySDL.h

@ -90,9 +90,9 @@ public:
plStateDataRecord * GetRec() const;
/////////////////////
PyObject * FindVar( const char * name ) const; // returns pySimpleStateVariable
const char *GetName() const;
std::vector<std::string> GetVarList();
PyObject * FindVar( const plString & name ) const; // returns pySimpleStateVariable
plString GetName() const;
std::vector<plString> GetVarList();
void SetFromDefaults(bool timeStampNow);
};
@ -101,7 +101,6 @@ class pySimpleStateVariable
{
private:
plSimpleStateVariable * fVar;
mutable std::string fString; // for GetString()
protected:
pySimpleStateVariable();
@ -133,12 +132,12 @@ public:
float GetFloat( int idx=0 ) const;
double GetDouble( int idx=0 ) const;
bool GetBool( int idx=0 ) const;
const char * GetString( int idx=0 ) const;
plString GetString( int idx=0 ) const;
plKey GetKey( int idx=0 ) const;
int GetType() const;
const char *GetDisplayOptions() const;
const char *GetDefault() const;
plString GetDisplayOptions() const;
plString GetDefault() const;
bool IsAlwaysNew() const;
bool IsInternal() const;

10
Sources/Plasma/FeatureLib/pfPython/pySDLGlue.cpp

@ -104,12 +104,12 @@ PYTHON_METHOD_DEFINITION(ptSDLStateDataRecord, findVar, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptSDLStateDataRecord, getName)
{
return PyString_FromString(self->fThis->GetName());
return PyString_FromString(self->fThis->GetName().c_str());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptSDLStateDataRecord, getVarList)
{
std::vector<std::string> vars = self->fThis->GetVarList();
std::vector<plString> vars = self->fThis->GetVarList();
PyObject* varList = PyList_New(vars.size());
for (int i = 0; i < vars.size(); i++)
PyList_SetItem(varList, i, PyString_FromString(vars[i].c_str()));
@ -224,7 +224,7 @@ STATEVAR_GET(getShort, GetShort, PyInt_FromLong)
STATEVAR_GET(getInt, GetInt, PyInt_FromLong)
STATEVAR_GET(getFloat, GetFloat, PyFloat_FromDouble)
STATEVAR_GET(getDouble, GetDouble, PyFloat_FromDouble)
STATEVAR_GET(getString, GetString, PyString_FromString)
STATEVAR_GET(getString, GetString, PyString_FromPlString)
STATEVAR_GET(getKey, GetKey, pyKey::New)
// getBool is special cause of the way python represents booleans
@ -246,12 +246,12 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptSimpleStateVariable, getType)
PYTHON_METHOD_DEFINITION_NOARGS(ptSimpleStateVariable, getDisplayOptions)
{
return PyString_FromString(self->fThis->GetDisplayOptions());
return PyString_FromString(self->fThis->GetDisplayOptions().c_str());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptSimpleStateVariable, getDefault)
{
return PyString_FromString(self->fThis->GetDefault());
return PyString_FromString(self->fThis->GetDefault().c_str());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptSimpleStateVariable, isAlwaysNew)

12
Sources/Plasma/FeatureLib/pfPython/pySpawnPointInfo.h

@ -74,11 +74,11 @@ public:
plSpawnPointInfo & SpawnPoint() { return fInfo; }
void SetTitle( const char * v ) { fInfo.SetTitle( v ); }
const char * GetTitle() const { return fInfo.GetTitle(); }
plString GetTitle() const { return fInfo.GetTitle(); }
void SetName( const char * v ) { fInfo.SetName( v ); }
const char * GetName() const { return fInfo.GetName(); }
plString GetName() const { return fInfo.GetName(); }
void SetCameraStack(const char * v ) { fInfo.SetCameraStack( v ); }
const char * GetCameraStack() const { return fInfo.GetCameraStack(); }
plString GetCameraStack() const { return fInfo.GetCameraStack(); }
static PyObject* GetDefaultSpawnPoint();
};
@ -105,11 +105,11 @@ public:
plSpawnPointInfo & SpawnPoint() { return fInfo; }
void SetTitle( const char * v ) { fInfo.SetTitle( v ); }
const char * GetTitle() const { return fInfo.GetTitle(); }
plString GetTitle() const { return fInfo.GetTitle(); }
void SetName( const char * v ) { fInfo.SetName( v ); }
const char * GetName() const { return fInfo.GetName(); }
plString GetName() const { return fInfo.GetName(); }
void SetCameraStack(const char * v ) { fInfo.SetCameraStack( v ); }
const char * GetCameraStack() const { return fInfo.GetCameraStack(); }
plString GetCameraStack() const { return fInfo.GetCameraStack(); }
};
#endif // pySpawnPointInfo_h_inc

12
Sources/Plasma/FeatureLib/pfPython/pySpawnPointInfoGlue.cpp

@ -78,7 +78,7 @@ PYTHON_INIT_DEFINITION(ptSpawnPointInfo, args, keywords)
PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfo, getTitle)
{
return PyString_FromString(self->fThis->GetTitle());
return PyString_FromString(self->fThis->GetTitle().c_str());
}
PYTHON_METHOD_DEFINITION(ptSpawnPointInfo, setTitle, args)
@ -95,7 +95,7 @@ PYTHON_METHOD_DEFINITION(ptSpawnPointInfo, setTitle, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfo, getName)
{
return PyString_FromString(self->fThis->GetName());
return PyString_FromString(self->fThis->GetName().c_str());
}
PYTHON_METHOD_DEFINITION(ptSpawnPointInfo, setName, args)
@ -112,7 +112,7 @@ PYTHON_METHOD_DEFINITION(ptSpawnPointInfo, setName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfo, getCameraStack)
{
return PyString_FromString(self->fThis->GetCameraStack());
return PyString_FromString(self->fThis->GetCameraStack().c_str());
}
PYTHON_METHOD_DEFINITION(ptSpawnPointInfo, setCameraStack, args)
@ -191,7 +191,7 @@ PYTHON_NO_INIT_DEFINITION(ptSpawnPointInfoRef)
PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfoRef, getTitle)
{
return PyString_FromString(self->fThis->GetTitle());
return PyString_FromString(self->fThis->GetTitle().c_str());
}
PYTHON_METHOD_DEFINITION(ptSpawnPointInfoRef, setTitle, args)
@ -208,7 +208,7 @@ PYTHON_METHOD_DEFINITION(ptSpawnPointInfoRef, setTitle, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfoRef, getName)
{
return PyString_FromString(self->fThis->GetName());
return PyString_FromString(self->fThis->GetName().c_str());
}
PYTHON_METHOD_DEFINITION(ptSpawnPointInfoRef, setName, args)
@ -225,7 +225,7 @@ PYTHON_METHOD_DEFINITION(ptSpawnPointInfoRef, setName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfoRef, getCameraStack)
{
return PyString_FromString(self->fThis->GetCameraStack());
return PyString_FromString(self->fThis->GetCameraStack().c_str());
}
PYTHON_METHOD_DEFINITION(ptSpawnPointInfoRef, setCameraStack, args)

4
Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNode.cpp

@ -166,7 +166,7 @@ void pyVaultAgeLinkNode::RemoveSpawnPointRef( pySpawnPointInfoRef & point )
access.RemoveSpawnPoint(point.GetName());
}
void pyVaultAgeLinkNode::RemoveSpawnPointByName( const char * spawnPtName )
void pyVaultAgeLinkNode::RemoveSpawnPointByName( const plString & spawnPtName )
{
if (!fNode)
return;
@ -175,7 +175,7 @@ void pyVaultAgeLinkNode::RemoveSpawnPointByName( const char * spawnPtName )
access.RemoveSpawnPoint(spawnPtName);
}
bool pyVaultAgeLinkNode::HasSpawnPoint( const char * spawnPtName ) const
bool pyVaultAgeLinkNode::HasSpawnPoint( const plString & spawnPtName ) const
{
if (!fNode)
return false;

4
Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNode.h

@ -100,8 +100,8 @@ public:
void AddSpawnPointRef( pySpawnPointInfoRef & point ); // will only add if not there already.
void RemoveSpawnPoint( pySpawnPointInfo & point );
void RemoveSpawnPointRef( pySpawnPointInfoRef & point );
void RemoveSpawnPointByName( const char * spawnPtName );
bool HasSpawnPoint( const char * spawnPtName ) const;
void RemoveSpawnPointByName( const plString & spawnPtName );
bool HasSpawnPoint( const plString & spawnPtName ) const;
PyObject * GetSpawnPoints() const; // returns list of pySpawnPointInfo
PyObject * AsAgeLinkStruct() const; // returns pyAgeLinkStruct

5
Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceThread.cpp

@ -65,6 +65,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//===========================================================================
static unsigned CALLBACK CreateThreadProc (LPVOID param) {
#ifdef USE_VLD
VLDEnable();
#endif
PerfAddCounter(kAsyncPerfThreadsTotal, 1);
PerfAddCounter(kAsyncPerfThreadsCurr, 1);

6
Sources/Plasma/NucleusLib/pnMessage/plSDLModifierMsg.cpp

@ -42,15 +42,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plSDLModifierMsg.h"
#include "plSDL/plSDL.h" // ugh.
plSDLModifierMsg::plSDLModifierMsg(const char* sdlName, Action a) :
fSDLName(nil),
plSDLModifierMsg::plSDLModifierMsg(const plString& sdlName, Action a) :
fSDLName(sdlName),
fAction(a),
fState(nil),
fPlayerID(0),
fManageStateMem(false),
fFlags(0)
{
SetSDLName(sdlName);
SetBCastFlag(plMessage::kPropagateToModifiers);
}
@ -58,5 +57,4 @@ plSDLModifierMsg::~plSDLModifierMsg()
{
if ( fManageStateMem )
delete fState;
delete [] fSDLName;
}

8
Sources/Plasma/NucleusLib/pnMessage/plSDLModifierMsg.h

@ -63,7 +63,7 @@ public:
};
protected:
char* fSDLName; // the state descriptor name (ie. "physical")
plString fSDLName; // the state descriptor name (ie. "physical")
Action fAction;
plStateDataRecord* fState; // for recving state
bool fManageStateMem; // delete fState?
@ -71,7 +71,7 @@ protected:
uint32_t fFlags;
public:
plSDLModifierMsg(const char* sdlName=nil, Action a=kActionNone);
plSDLModifierMsg(const plString& sdlName="", Action a=kActionNone);
~plSDLModifierMsg();
CLASSNAME_REGISTER( plSDLModifierMsg );
@ -86,8 +86,8 @@ public:
plStateDataRecord* GetState(bool unManageState=false) { if ( unManageState ) fManageStateMem=false; return fState; }
void SetState(plStateDataRecord* s, bool manageState) { fState=s; fManageStateMem=manageState; }
const char* GetSDLName() const { return fSDLName; }
void SetSDLName(const char* s) { delete [] fSDLName; fSDLName=hsStrcpy(s); }
plString GetSDLName() const { return fSDLName; }
void SetSDLName(const plString& s) { fSDLName=s; }
uint32_t GetPlayerID() const { return fPlayerID; }
void SetPlayerID(uint32_t p) { fPlayerID=p; }

4
Sources/Plasma/NucleusLib/pnMessage/plSDLNotificationMsg.h

@ -50,9 +50,9 @@ class plSDLNotificationMsg : public plMessage
public:
float fDelta; // change threshold
const plSimpleStateVariable* fVar;
std::string fSDLName; // name of state descriptor
plString fSDLName; // name of state descriptor
int fPlayerID; // pid of the player who changed the data
std::string fHintString; // hint from the player who changed the data
plString fHintString; // hint from the player who changed the data
plSDLNotificationMsg() : fDelta(0), fVar(nil), fPlayerID(0) {}
~plSDLNotificationMsg() { }

7
Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp

@ -821,21 +821,20 @@ void plClothingOutfit::ReadFromVault()
ram.Write(sdl.sdlDataLen, sdl.sdlData);
ram.Rewind();
char * sdlRecName = nil;
int sdlRecVersion;
plString sdlRecName;
int sdlRecVersion;
plStateDataRecord::ReadStreamHeader(&ram, &sdlRecName, &sdlRecVersion);
plStateDescriptor * desc = plSDLMgr::GetInstance()->FindDescriptor(sdlRecName, sdlRecVersion);
if (desc) {
plStateDataRecord * sdlDataRec = new plStateDataRecord(desc);
if (sdlDataRec->Read(&ram, 0)) {
if (!strcmp(sdlRecName, kSDLMorphSequence))
if (sdlRecName == kSDLMorphSequence)
IHandleMorphSDR(sdlDataRec);
else
plClothingSDLModifier::HandleSingleSDR(sdlDataRec, this);
}
delete sdlDataRec;
}
delete [] sdlRecName;
}
nodes[i]->DecRef();
}

4
Sources/Plasma/PubUtilLib/plAvatar/plClothingSDLModifier.cpp

@ -231,7 +231,7 @@ void plClothingSDLModifier::HandleSingleSDR(const plStateDataRecord *sdr, plClot
int i;
uint8_t tint[3];
float tintScalar[3];
if (!strcmp(sdr->GetDescriptor()->GetName(), kStrClothingDescName))
if (sdr->GetDescriptor()->GetName() == kStrClothingDescName)
{
// get item from clothesItem
plSimpleStateVariable* itemVar = sdr->FindVar(kStrItem);
@ -284,7 +284,7 @@ void plClothingSDLModifier::HandleSingleSDR(const plStateDataRecord *sdr, plClot
}
}
}
else if (!strcmp(sdr->GetDescriptor()->GetName(), kStrAppearanceDescName))
else if (sdr->GetDescriptor()->GetName() == kStrAppearanceDescName)
{
// skin tints
plSimpleStateVariable* skinVar = sdr->FindVar(kStrSkinTint);

2
Sources/Plasma/PubUtilLib/plDrawable/plMorphSequenceSDLMod.cpp

@ -134,7 +134,7 @@ void plMorphSequenceSDLMod::ISetCurrentStateFrom(const plStateDataRecord* srcSta
plSceneObject* sobj=GetTarget();
hsAssert(sobj, "plMorphSequenceSDLMod, nil target");
if (strcmp(srcState->GetDescriptor()->GetName(), kSDLMorphSequence))
if (srcState->GetDescriptor()->GetName() != kSDLMorphSequence)
{
hsAssert(false, "Wrong type of state data record passed into plMorphSequenceSDLMod.");
return;

4
Sources/Plasma/PubUtilLib/plModifier/plSDLModifier.cpp

@ -110,7 +110,7 @@ void plSDLModifier::ISendNetMsg(plStateDataRecord*& state, plKey senderKey, uint
bool plSDLModifier::MsgReceive(plMessage* msg)
{
plSDLModifierMsg* sdlMsg = plSDLModifierMsg::ConvertNoRef(msg);
if (sdlMsg && !stricmp(sdlMsg->GetSDLName(),GetSDLName()))
if (sdlMsg && !sdlMsg->GetSDLName().CompareI(GetSDLName()))
{
uint32_t sendFlags = IApplyModFlags(sdlMsg->GetFlags());
@ -229,7 +229,7 @@ void plSDLModifier::ReceiveState(const plStateDataRecord* srcState)
plNetObjectDebugger::GetInstance()->SetDebugging(false);
}
void plSDLModifier::AddNotifyForVar(plKey key, const char* varName, float tolerance) const
void plSDLModifier::AddNotifyForVar(plKey key, const plString& varName, float tolerance) const
{
// create a SDL notifier object
plStateChangeNotifier notifier(tolerance, key);

2
Sources/Plasma/PubUtilLib/plModifier/plSDLModifier.h

@ -80,7 +80,7 @@ public:
plStateDataRecord* GetStateCache() const { return fStateCache; }
virtual void AddTarget(plSceneObject* so);
void AddNotifyForVar(plKey key, const char* varName, float tolerance) const;
void AddNotifyForVar(plKey key, const plString& varName, float tolerance) const;
};
#endif // plSDLModifier_inc

6
Sources/Plasma/PubUtilLib/plNetClient/plLinkEffectsMgr.cpp

@ -386,12 +386,10 @@ bool plLinkEffectsMgr::MsgReceive(plMessage *msg)
bool linkToFissureDrop = lm &&
lm->GetAgeLink()->HasSpawnPt() &&
lm->GetAgeLink()->SpawnPoint().GetName() &&
!stricmp(lm->GetAgeLink()->SpawnPoint().GetName(), kCleftAgeLinkInPointFissureDrop);
!lm->GetAgeLink()->SpawnPoint().GetName().CompareI(kCleftAgeLinkInPointFissureDrop);
bool linkToDsntFromShell = lm &&
lm->GetAgeLink()->HasSpawnPt() &&
lm->GetAgeLink()->SpawnPoint().GetTitle() &&
!stricmp(lm->GetAgeLink()->SpawnPoint().GetTitle(), kDescentLinkFromShell);
!lm->GetAgeLink()->SpawnPoint().GetTitle().CompareI(kDescentLinkFromShell);
if ( linkToACA || linkFromACA || linkToStartup || linkFromStartup || linkToFissureDrop || linkToDsntFromShell)
{
BCMsg->SetLinkFlag(plLinkEffectBCMsg::kMute);

4
Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp

@ -270,8 +270,8 @@ void plNCAgeJoiner::ExecNextOp () {
avatarName = "Male";
else
avatarName = NetCommGetPlayer()->avatarDatasetName;
const char * linkInName = plNetLinkingMgr::GetInstance()->GetAgeLink()->SpawnPoint().GetName();
am->LoadPlayer( avatarName, nil, linkInName );
plString linkInName = plNetLinkingMgr::GetInstance()->GetAgeLink()->SpawnPoint().GetName();
am->LoadPlayer( avatarName, nil, linkInName.c_str() );
}
else {
LogMsg(kLogPerf, L"AgeJoiner: Next:kPropagatePlayer");

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

@ -624,7 +624,7 @@ void plNetClientMgr::ICheckPendingStateLoad(double secs)
// discard the state if object not found in dataset.
hsLogEntry( DebugMsg( "Failed to find object %s in dataset. Discarding pending state '%s'",
tmpUoid.StringIze().c_str(),
pl->fSDRec->GetDescriptor()->GetName() ) );
pl->fSDRec->GetDescriptor()->GetName().c_str() ) );
delete pl;
it = fPendingLoads.erase(it);
continue;
@ -645,9 +645,10 @@ void plNetClientMgr::ICheckPendingStateLoad(double secs)
#ifdef HS_DEBUGGING
if (plNetObjectDebugger::GetInstance()->IsDebugObject(so))
{
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(),
hsLogEntry( DebugMsg( "Delivering SDL state %s:%s", pl->fKey->GetName().c_str(),
pl->fSDRec->GetDescriptor()->GetName().c_str() ) );
// hsLogEntry(plNetObjectDebugger::GetInstance()->LogMsg(plString::Format("Dispatching SDL state, type %s to object:%s, locallyOwned=%d, st=%.3f rt=%.3f",
// pl->fSDRec->GetDescriptor()->GetName().c_str(), pl->fKey->GetName().c_str(),
// so->IsLocallyOwned()==plSynchedObject::kYes, secs, hsTimer::GetSeconds()).c_str()));
// hsLogEntry( pl->fSDRec->DumpToObjectDebugger( "Delivering SDL state", false, 0 ) );
}
@ -671,7 +672,7 @@ void plNetClientMgr::ICheckPendingStateLoad(double secs)
// for around 5 minutes and its time to go
WarningMsg( "Pending state '%s' for object [uoid:%s,key:%s] has been queued for about %f secs. Removing...",
pl->fSDRec && pl->fSDRec->GetDescriptor() ? pl->fSDRec->GetDescriptor()->GetName() : "?",
pl->fSDRec && pl->fSDRec->GetDescriptor() ? pl->fSDRec->GetDescriptor()->GetName().c_str() : "?",
pl->fUoid.StringIze().c_str(), pl->fKey ? pl->fKey->GetUoid().StringIze().c_str() : "?",
( rawSecs - pl->fQueuedTime ) * pl->fQueueTimeResets);
@ -681,7 +682,7 @@ void plNetClientMgr::ICheckPendingStateLoad(double secs)
}
WarningMsg( "Pending state '%s' for object [uoid:%s,key:%s] has been queued for about %f secs. %s",
pl->fSDRec && pl->fSDRec->GetDescriptor() ? pl->fSDRec->GetDescriptor()->GetName() : "?",
pl->fSDRec && pl->fSDRec->GetDescriptor() ? pl->fSDRec->GetDescriptor()->GetName().c_str() : "?",
pl->fUoid.StringIze().c_str(), pl->fKey ? pl->fKey->GetUoid().StringIze().c_str() : "?",
( rawSecs - pl->fQueuedTime ) * pl->fQueueTimeResets,
so ? "(not loaded)" : "(not final)" );

8
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgHandler.cpp

@ -236,12 +236,12 @@ MSG_HANDLER_DEFN(plNetClientMsgHandler,plNetMsgSDLState)
// extract stateDataRecord from msg
hsReadOnlyStream stream(m->StreamInfo()->GetStreamLen(), m->StreamInfo()->GetStreamBuf());
char* descName = nil;
plString descName;
int ver;
plStateDataRecord::ReadStreamHeader(&stream, &descName, &ver);
plStateDescriptor* des = plSDLMgr::GetInstance()->FindDescriptor(descName, ver);
if (stricmp(descName, kSDLAvatarPhysical) == 0)
if (descName.CompareI(kSDLAvatarPhysical) == 0)
rwFlags |= plSDL::kKeepDirty;
//
@ -287,13 +287,11 @@ MSG_HANDLER_DEFN(plNetClientMsgHandler,plNetMsgSDLState)
// queue up state
nc->fPendingLoads.push_back(pl);
hsLogEntry( nc->DebugMsg( "Added pending SDL delivery for %s:%s",
m->ObjectInfo()->GetObjectName().c_str(), des->GetName() ) );
m->ObjectInfo()->GetObjectName().c_str(), des->GetName().c_str() ) );
}
else
delete sdRec;
delete [] descName; // We've only used descName for a lookup (via SDR, and some error strings. Must delete now.
return hsOK;
}

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

@ -427,7 +427,7 @@ void plNetLinkingMgr::IDoLink(plLinkToAgeMsg* msg)
);
StrCopy(
joinAgeOp->age.spawnPtName,
GetAgeLink()->SpawnPoint().GetName(),
GetAgeLink()->SpawnPoint().GetName().c_str(),
arrsize(joinAgeOp->age.spawnPtName)
);
QueueOp(joinAgeOp);

3
Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp

@ -598,11 +598,10 @@ static void INetCliAuthAgeRequestCallback (
s_age.ageVaultId = ageVaultId;
wchar_t ageInstIdStr[64];
plString gameAddrStr = gameAddr.GetHostString();
LogMsg(
kLogPerf,
L"Connecting to game server %s, ageInstId %s",
gameAddrStr.c_str(),
gameAddr.GetHostString().ToWchar().GetData(),
GuidToString(ageInstId, ageInstIdStr, arrsize(ageInstIdStr))
);
NetCliGameDisconnect();

9
Sources/Plasma/PubUtilLib/plNetClientRecorder/plNetClientStatsRecorder.cpp

@ -129,11 +129,11 @@ void plNetClientStatsRecorder::ILogMsg(plNetMessage* msg, const char* preText)
else if (plNetMsgSDLState* sdlMsg = plNetMsgSDLState::ConvertNoRef(msg))
{
hsReadOnlyStream stream(sdlMsg->StreamInfo()->GetStreamLen(), sdlMsg->StreamInfo()->GetStreamBuf());
char* descName=nil;
plString descName;
int ver;
if (plStateDataRecord::ReadStreamHeader(&stream, &descName, &ver))
{
fLog->AddLineF("%s%s(%s)", preText, msg->ClassName(), descName);
fLog->AddLineF("%s%s(%s)", preText, msg->ClassName(), descName.c_str());
int i;
@ -143,17 +143,16 @@ void plNetClientStatsRecorder::ILogMsg(plNetMessage* msg, const char* preText)
sdRec.GetDirtyVars(&vars);
for (i = 0; i < vars.size(); i++)
{
fLog->AddLineF("\t%s", vars[i]->GetVarDescriptor()->GetName());
fLog->AddLineF("\t%s", vars[i]->GetVarDescriptor()->GetName().c_str());
}
plStateDataRecord::SDVarsList sdVars;
sdRec.GetDirtySDVars(&sdVars);
for (i = 0; i < sdVars.size(); i++)
{
fLog->AddLineF("\t%s", sdVars[i]->GetSDVarDescriptor()->GetName());
fLog->AddLineF("\t%s", sdVars[i]->GetSDVarDescriptor()->GetName().c_str());
}
}
delete [] descName;
}
else
fLog->AddLineF("%s%s", preText, msg->ClassName());

9
Sources/Plasma/PubUtilLib/plNetClientRecorder/plNetClientStreamRecorder.cpp

@ -334,11 +334,11 @@ void plNetClientStreamRecorder::ILogMsg(plNetMessage* msg, const char* preText)
else if (plNetMsgSDLState* sdlMsg = plNetMsgSDLState::ConvertNoRef(msg))
{
hsReadOnlyStream stream(sdlMsg->StreamInfo()->GetStreamLen(), sdlMsg->StreamInfo()->GetStreamBuf());
char* descName=nil;
plString descName;
int ver;
if (plStateDataRecord::ReadStreamHeader(&stream, &descName, &ver))
{
fLog->AddLineF("%s%s(%s)", preText, msg->ClassName(), descName);
fLog->AddLineF("%s%s(%s)", preText, msg->ClassName(), descName.c_str());
int i;
@ -348,17 +348,16 @@ void plNetClientStreamRecorder::ILogMsg(plNetMessage* msg, const char* preText)
sdRec.GetDirtyVars(&vars);
for (i = 0; i < vars.size(); i++)
{
fLog->AddLineF("\t%s", vars[i]->GetVarDescriptor()->GetName());
fLog->AddLineF("\t%s", vars[i]->GetVarDescriptor()->GetName().c_str());
}
plStateDataRecord::SDVarsList sdVars;
sdRec.GetDirtySDVars(&sdVars);
for (i = 0; i < sdVars.size(); i++)
{
fLog->AddLineF("\t%s", sdVars[i]->GetSDVarDescriptor()->GetName());
fLog->AddLineF("\t%s", sdVars[i]->GetSDVarDescriptor()->GetName().c_str());
}
}
delete [] descName;
}
else
fLog->AddLineF("%s%s", preText, msg->ClassName());

10
Sources/Plasma/PubUtilLib/plNetCommon/plNetServerSessionInfo.cpp

@ -387,14 +387,14 @@ void plAgeLinkStruct::Read( hsStream * s, hsResMgr* m)
s->LogReadLE( &fLinkingRules ,"LinkingRules");
if ( IsFlagSet( kHasSpawnPt_DEAD ) )
{
std::string str;
plString str;
s->LogSubStreamPushDesc("SpawnPt_DEAD");
plMsgStdStringHelper::Peek(str,s);
fSpawnPoint.SetName( str.c_str() );
if ( strcmp( fSpawnPoint.GetName(), kDefaultSpawnPtName )==0 )
fSpawnPoint.SetName( str );
if ( fSpawnPoint.GetName() == kDefaultSpawnPtName )
fSpawnPoint.SetTitle( kDefaultSpawnPtTitle );
else
fSpawnPoint.SetTitle( str.c_str() );
fSpawnPoint.SetTitle( str );
ClearFlag( kHasSpawnPt_DEAD );
SetFlag( kHasSpawnPt );
}
@ -520,7 +520,7 @@ plString plAgeLinkStruct::AsString() const
{
ss << spacer
<< "Spwn:"
<< fSpawnPoint.AsStdString().c_str();
<< fSpawnPoint.AsString();
spacer = kComma;
}
if (HasAmCCR())

10
Sources/Plasma/PubUtilLib/plNetCommon/plSpawnPointInfo.cpp

@ -120,10 +120,10 @@ void plSpawnPointInfo::Reset()
(*this)=kDefaultSpawnPoint;
}
std::string plSpawnPointInfo::AsStdString() const
plString plSpawnPointInfo::AsString() const
{
return xtl::format( "t:%s,n:%s,c:%s",
fTitle.size()?fTitle.c_str():"(nil)",
fSpawnPt.size()?fSpawnPt.c_str():"(nil)",
fCameraStack.size()?fCameraStack.c_str():"(nil)" );
return plString::Format( "t:%s,n:%s,c:%s",
fTitle.c_str("(nil)"),
fSpawnPt.c_str("(nil)"),
fCameraStack.c_str("(nil)") );
}

23
Sources/Plasma/PubUtilLib/plNetCommon/plSpawnPointInfo.h

@ -43,6 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plSpawnPointInfo_h_inc
#include "hsStlUtils.h"
#include "plString.h"
///////////////////////////////////////////////////////////////////
@ -55,24 +56,24 @@ class hsStream;
struct plSpawnPointInfo
{
std::string fTitle; // friendly title for GUIs
std::string fSpawnPt; // name of spawn point in dataset
std::string fCameraStack;
plString fTitle; // friendly title for GUIs
plString fSpawnPt; // name of spawn point in dataset
plString fCameraStack;
plSpawnPointInfo(){}
plSpawnPointInfo( const plSpawnPointInfo & other ) { (*this)=other; }
plSpawnPointInfo( const char * title, const char * spawnPt )
plSpawnPointInfo( const plString & title, const plString & spawnPt )
: fTitle( title ), fSpawnPt( spawnPt ) {}
const char * GetTitle() const { return fTitle.c_str(); }
void SetTitle( const char * v ) { fTitle=v; }
const char * GetName() const { return fSpawnPt.c_str(); }
void SetName( const char * v ) { fSpawnPt = v; }
const char * GetCameraStack() const { return fCameraStack.c_str(); }
void SetCameraStack( const char * v ) { fCameraStack=v; }
plString GetTitle() const { return fTitle; }
void SetTitle( const plString & v ) { fTitle=v; }
plString GetName() const { return fSpawnPt; }
void SetName( const plString & v ) { fSpawnPt = v; }
plString GetCameraStack() const { return fCameraStack; }
void SetCameraStack( const plString & v ) { fCameraStack=v; }
void Reset();
void Read( hsStream * s );
void ReadOld( hsStream * s );
void Write( hsStream * s ) const;
std::string AsStdString() const;
plString AsString() const;
};
typedef std::vector<plSpawnPointInfo> plSpawnPointVec;

4
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp

@ -2196,9 +2196,7 @@ static bool Recv_ServerAddr (
s_active->token = msg.token;
s_active->addr.SetHost(msg.srvAddr);
plString logmsg = "SrvAuth addr: ";
logmsg += s_active->addr.GetHostString();
LogMsg(kLogPerf, L"SrvAuth addr: %s", logmsg.c_str());
LogMsg(kLogPerf, "SrvAuth addr: %s", s_active->addr.GetHostString().c_str());
}
}
s_critsect.Leave();

40
Sources/Plasma/PubUtilLib/plSDL/plSDL.h

@ -107,10 +107,10 @@ namespace plSDL
class plStateVarNotificationInfo
{
private:
std::string fHintString;
plString fHintString;
public:
void SetHintString(const char* c) { fHintString=c; }
const char* GetHintString() const { return fHintString.c_str(); }
void SetHintString(const plString& c) { fHintString=c; }
plString GetHintString() const { return fHintString; }
void Read(hsStream* s, uint32_t readOptions);
void Write(hsStream* s, uint32_t writeOptions) const;
@ -137,8 +137,8 @@ public:
plStateVariable() : fFlags(0) {}
virtual ~plStateVariable() {}
const char* GetName() const { return GetVarDescriptor()->GetName(); }
bool IsNamed(const char* n) const { return (n && !stricmp(GetName(), n)); }
plString GetName() const { return GetVarDescriptor()->GetName(); }
bool IsNamed(const char* n) const { return (n && !GetName().CompareI(n)); }
virtual int GetCount() const = 0;
// conversion ops
@ -193,7 +193,7 @@ public:
int RemoveNotificationKey(plKey k); // returns number of keys left after removal
int RemoveNotificationKeys(KeyList keys); // returns number of keys left after removal
void SendNotificationMsg(const plSimpleStateVariable* srcVar, const plSimpleStateVariable* dstVar, const char* sdlName);
void SendNotificationMsg(const plSimpleStateVariable* srcVar, const plSimpleStateVariable* dstVar, const plString& sdlName);
bool GetValue(float* i) const;
bool SetValue(float i);
@ -266,10 +266,10 @@ public:
void TimeStamp( const plUnifiedTime & ut=plUnifiedTime::GetCurrentTime() );
void CopyFrom(plVarDescriptor* v);
void CopyData(const plSimpleStateVariable* other, uint32_t writeOptions=0);
bool SetFromString(const char* value, int idx, bool timeStampNow); // set value from string, type. return false on err
char* GetAsString(int idx) const;
bool SetFromString(const plString& value, int idx, bool timeStampNow); // set value from string, type. return false on err
plString GetAsString(int idx) const;
bool ConvertTo(plSimpleVarDescriptor* toVar, bool force=false); // return false on err
void Alloc(int cnt=-1 /* -1 means don't change count */); // alloc memory after setting type
void Alloc(int cnt=-1 /* -1 means don't change count */); // alloc memory after setting type
void Reset();
// setters
@ -293,7 +293,7 @@ public:
// getters
bool Get(int* value, int idx=0) const;
bool Get(short* value, int idx=0) const;
bool Get(uint8_t* value, int idx=0) const; // returns uint8_t or uint8_tVector
bool Get(uint8_t* value, int idx=0) const; // returns uint8_t or uint8_tVector
bool Get(float* value, int idx=0) const; // returns float or floatVector
bool Get(double* value, int idx=0) const; // returns double or doubleVector
bool Get(bool* value, int idx=0) const;
@ -315,7 +315,7 @@ public:
void AddStateChangeNotification(plStateChangeNotifier& n);
void RemoveStateChangeNotification(plKey notificationObj); // remove all with this key
void RemoveStateChangeNotification(plStateChangeNotifier n); // remove ones which match
void NotifyStateChange(const plSimpleStateVariable* other, const char* sdlName); // send notification msg if necessary, internal use
void NotifyStateChange(const plSimpleStateVariable* other, const plString& sdlName); // send notification msg if necessary, internal use
void DumpToObjectDebugger(bool dirtyOnly, int level) const;
void DumpToStream(hsStream* stream, bool dirtyOnly, int level) const;
@ -407,18 +407,18 @@ protected:
plUoid fAssocObject; // optional
VarsList fVarsList; // list of variables
VarsList fSDVarsList; // list of nested data records
uint32_t fFlags;
uint32_t fFlags;
static const uint8_t kIOVersion; // I/O Version
void IDeleteVarsList(VarsList& vars);
void IInitDescriptor(const char* name, int version); // or plSDL::kLatestVersion
void IInitDescriptor(const plString& name, int version); // or plSDL::kLatestVersion
void IInitDescriptor(const plStateDescriptor* sd);
void IReadHeader(hsStream* s);
void IWriteHeader(hsStream* s) const;
bool IConvertVar(plSimpleStateVariable* fromVar, plSimpleStateVariable* toVar, bool force);
plStateVariable* IFindVar(const VarsList& vars, const char* name) const;
plStateVariable* IFindVar(const VarsList& vars, const plString& name) const;
int IGetNumUsedVars(const VarsList& vars) const;
int IGetUsedVars(const VarsList& varsOut, VarsList *varsIn) const; // build a list of vars that have data
bool IHasUsedVars(const VarsList& vars) const;
@ -430,7 +430,7 @@ public:
CLASSNAME_REGISTER( plStateDataRecord );
GETINTERFACE_ANY( plStateDataRecord, plCreatable);
plStateDataRecord(const char* sdName, int version=plSDL::kLatestVersion);
plStateDataRecord(const plString& sdName, int version=plSDL::kLatestVersion);
plStateDataRecord(plStateDescriptor* sd);
plStateDataRecord(const plStateDataRecord &other, uint32_t writeOptions=0 ):fFlags(0) { CopyFrom(other, writeOptions); }
plStateDataRecord():fFlags(0) {}
@ -442,8 +442,8 @@ public:
uint32_t GetFlags() const { return fFlags; }
void SetFlags(uint32_t f) { fFlags =f; }
plSimpleStateVariable* FindVar(const char* name) const { return (plSimpleStateVariable*)IFindVar(fVarsList, name); }
plSDStateVariable* FindSDVar(const char* name) const { return (plSDStateVariable*)IFindVar(fSDVarsList, name); }
plSimpleStateVariable* FindVar(const plString& name) const { return (plSimpleStateVariable*)IFindVar(fVarsList, name); }
plSDStateVariable* FindSDVar(const plString& name) const { return (plSDStateVariable*)IFindVar(fSDVarsList, name); }
plStateDataRecord& operator=(const plStateDataRecord& other) { CopyFrom(other); return *this; }
void CopyFrom(const plStateDataRecord& other, uint32_t writeOptions=0);
@ -479,7 +479,7 @@ public:
bool HasDirtySDVars() const { return IHasDirtyVars(fSDVarsList); }
const plStateDescriptor* GetDescriptor() const { return fDescriptor; }
void SetDescriptor(const char* sdName, int version);
void SetDescriptor(const plString& sdName, int version);
plNetMsgSDLState* PrepNetMsg(float timeConvert, uint32_t writeOptions) const; // create/prep a net msg with this data
@ -498,7 +498,7 @@ public:
bool Read(hsStream* s, float timeConvert, uint32_t readOptions=0);
void Write(hsStream* s, float timeConvert, uint32_t writeOptions=0) const;
static bool ReadStreamHeader(hsStream* s, char** name, int* version, plUoid* objUoid=nil);
static bool ReadStreamHeader(hsStream* s, plString* name, int* version, plUoid* objUoid=nil);
void WriteStreamHeader(hsStream* s, plUoid* objUoid=nil) const;
};
@ -543,7 +543,7 @@ public:
~plSDLMgr();
static plSDLMgr* GetInstance();
plStateDescriptor* FindDescriptor(const char* name, int version, const plSDL::DescriptorList * dl=nil) const; // version or kLatestVersion
plStateDescriptor* FindDescriptor(const plString& name, int version, const plSDL::DescriptorList * dl=nil) const; // version or kLatestVersion
const plSDL::DescriptorList * GetDescriptors( void ) const { return &fDescriptors;}

61
Sources/Plasma/PubUtilLib/plSDL/plSDLDescriptor.h

@ -50,6 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "hsStlUtils.h"
#include "plString.h"
//
// Describes a variable in a state descriptor.
@ -98,17 +99,17 @@ public:
kVariableLength = 0x4 // Var is defined as int foo[], so it's length is variable, starting at 0
};
protected:
static const uint8_t kVersion; // for Read/Write format
char* fDefault; // set by .sdl
char* fName; // set by .sdl
int fCount; // set by .sdl
Type fType; // set by .sdl
char* fTypeString; // string version of fType
uint32_t fFlags;
std::string fDisplayOptions; // set by .sdl
static const uint8_t kVersion; // for Read/Write format
plString fDefault; // set by .sdl
plString fName; // set by .sdl
int fCount; // set by .sdl
Type fType; // set by .sdl
plString fTypeString; // string version of fType
uint32_t fFlags;
plString fDisplayOptions; // set by .sdl
public:
plVarDescriptor();
virtual ~plVarDescriptor();
plVarDescriptor() : fCount(1), fType(kNone), fFlags(0) { }
virtual ~plVarDescriptor() { }
virtual void CopyFrom(const plVarDescriptor* v);
@ -119,26 +120,26 @@ public:
virtual const plSDVarDescriptor* GetAsSDVarDescriptor() const = 0;
// getters
const char* GetDefault() const { return fDefault; }
const char* GetName() const { return fName; }
Type GetType() const { return fType; }
const char* GetTypeString() const { return fTypeString; }
int GetCount() const { return fCount; }
bool IsInternal() const { return (fFlags & kInternal) != 0; }
bool IsAlwaysNew() const { return (fFlags & kAlwaysNew) != 0; }
bool IsVariableLength() const { return (fFlags & kVariableLength) != 0; }
const char* GetDisplayOptions() const { return fDisplayOptions.c_str(); }
plString GetDefault() const { return fDefault; }
plString GetName() const { return fName; }
Type GetType() const { return fType; }
plString GetTypeString() const { return fTypeString; }
int GetCount() const { return fCount; }
bool IsInternal() const { return (fFlags & kInternal) != 0; }
bool IsAlwaysNew() const { return (fFlags & kAlwaysNew) != 0; }
bool IsVariableLength() const { return (fFlags & kVariableLength) != 0; }
plString GetDisplayOptions() const { return fDisplayOptions; }
// setters
void SetDefault(const char* n) { delete [] fDefault; fDefault= hsStrcpy(n); }
void SetName(const char* n) { delete [] fName; fName = hsStrcpy(n); }
void SetDefault(const plString& n) { fDefault = n; }
void SetName(const plString& n) { fName = n; }
void SetCount(int c) { fCount=c; }
virtual bool SetType(const char* type);
void SetType(Type t) { fType=t; }
virtual bool SetType(const plString& type);
void SetType(Type t) { fType=t; }
void SetInternal(bool d) { if (d) fFlags |= kInternal; else fFlags &= ~kInternal; }
void SetAlwaysNew(bool d) { if (d) fFlags |= kAlwaysNew; else fFlags &= ~kAlwaysNew; }
void SetVariableLength(bool d) { if (d) fFlags |= kVariableLength; else fFlags &= ~kVariableLength; }
void SetDisplayOptions(const char* s) { fDisplayOptions=s; }
void SetDisplayOptions(const plString& s) { fDisplayOptions=s; }
// IO
virtual bool Read(hsStream* s);
@ -173,7 +174,7 @@ public:
int GetAtomicCount() const { return fAtomicCount; }
// setters
bool SetType(const char* type);
bool SetType(const plString& type);
void SetType(Type t) { plVarDescriptor::SetType(t); } // for lame compiler
void SetAtomicType(Type t) { fAtomicType=t; }
@ -225,16 +226,16 @@ private:
typedef std::vector<plVarDescriptor*> VarsList;
VarsList fVarsList;
int fVersion;
char* fName;
plString fName;
std::string fFilename; // the filename this descriptor was read from
void IDeInit();
public:
plStateDescriptor() : fVersion(-1),fName(nil) {}
plStateDescriptor() : fVersion(-1) {}
~plStateDescriptor();
// getters
const char* GetName() const { return fName; }
plString GetName() const { return fName; }
int GetNumVars() const { return fVarsList.size(); }
plVarDescriptor* GetVar(int i) const { return fVarsList[i]; }
int GetVersion() const { return fVersion; }
@ -242,11 +243,11 @@ public:
// setters
void SetVersion(int v) { fVersion=v; }
void SetName(const char* n) { delete [] fName; fName=hsStrcpy(n); }
void SetName(const plString& n) { fName=n; }
void AddVar(plVarDescriptor* v) { fVarsList.push_back(v); }
void SetFilename( const char * n ) { fFilename=n;}
plVarDescriptor* FindVar(const char* name, int* idx=nil) const;
plVarDescriptor* FindVar(const plString& name, int* idx=nil) const;
// IO
bool Read(hsStream* s);

6
Sources/Plasma/PubUtilLib/plSDL/plSDLMgr.cpp

@ -101,9 +101,9 @@ plSDLMgr* plSDLMgr::GetInstance()
// search latest and legacy descriptors for one that matches.
// if version is -1, search for latest descriptor with matching name
//
plStateDescriptor* plSDLMgr::FindDescriptor(const char* name, int version, const plSDL::DescriptorList * dl) const
plStateDescriptor* plSDLMgr::FindDescriptor(const plString& name, int version, const plSDL::DescriptorList * dl) const
{
if (!name)
if (name.IsNull())
return nil;
if ( !dl )
@ -116,7 +116,7 @@ plStateDescriptor* plSDLMgr::FindDescriptor(const char* name, int version, const
int highestFound = -1;
for(it=(*dl).begin(); it!= (*dl).end(); it++)
{
if (!stricmp((*it)->GetName(), name) )
if (!(*it)->GetName().CompareI(name) )
{
if ( (*it)->GetVersion()==version )
{

58
Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp

@ -162,12 +162,12 @@ bool plSDLParser::IParseStateDesc(const char* fileName, hsStream* stream, char t
bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char token[], plStateDescriptor*& curDesc,
plVarDescriptor*& curVar) const
{
hsAssert(curDesc, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
hsAssert(curDesc, plString::Format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
if ( !curDesc )
return false;
bool skipNext=false;
std::string dbgStr;
plString dbgStr;
static char seps[] = "( ,)[]";
// read type, name, cnt, [default]
@ -180,7 +180,7 @@ bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char tok
// nested sdls
char* sdlName = token+1;
plStateDescriptor* stateDesc = plSDLMgr::GetInstance()->FindDescriptor(sdlName, plSDL::kLatestVersion);
hsAssert(stateDesc, xtl::format("can't find nested state desc reference %s, fileName=%s",
hsAssert(stateDesc, plString::Format("can't find nested state desc reference %s, fileName=%s",
sdlName, fileName).c_str());
curVar = new plSDVarDescriptor(stateDesc);
}
@ -189,19 +189,19 @@ bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char tok
curDesc->AddVar(curVar);
bool ok=curVar->SetType(token);
hsAssert(ok, xtl::format("Variable 'type' syntax problem with .sdl file, type=%s, fileName=%s", token, fileName).c_str());
dbgStr = xtl::format("\tVAR Type=%s ", token).c_str();
hsAssert(ok, plString::Format("Variable 'type' syntax problem with .sdl file, type=%s, fileName=%s", token, fileName).c_str());
dbgStr = plString::Format("\tVAR Type=%s ", token);
//
// NAME (foo[1])
//
if (stream->GetToken(token, kTokenLen))
{
hsAssert(strstr(token, "[") && strstr(token, "]"), xtl::format("invalid var syntax, missing [x], fileName=%s",
hsAssert(strstr(token, "[") && strstr(token, "]"), plString::Format("invalid var syntax, missing [x], fileName=%s",
fileName).c_str());
char* ptr = strtok( token, seps ); // skip [
hsAssert(curVar, xtl::format("Missing current var. Syntax problem with .sdl file, fileName=%s", fileName).c_str());
hsAssert(curVar, plString::Format("Missing current var. Syntax problem with .sdl file, fileName=%s", fileName).c_str());
curVar->SetName(token);
//
// COUNT
@ -211,7 +211,7 @@ bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char tok
curVar->SetCount(cnt);
if (cnt==0)
curVar->SetVariableLength(true);
dbgStr += xtl::format("Name=%s[%d]", curVar->GetName(), cnt).c_str();
dbgStr += plString::Format("Name=%s[%d]", curVar->GetName().c_str(), cnt);
}
//
@ -221,10 +221,10 @@ bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char tok
{
if (!strcmp(token, "DEFAULT"))
{
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
// read state var type
std::string defaultStr;
plString defaultStr;
plSimpleVarDescriptor* sVar=(plSimpleVarDescriptor*)curVar;
if (sVar)
{
@ -239,51 +239,51 @@ bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char tok
}
}
}
if (defaultStr.size())
if (!defaultStr.IsEmpty())
{
curVar->SetDefault(defaultStr.c_str());
dbgStr += std::string(" DEFAULT=") + defaultStr;
curVar->SetDefault(defaultStr);
dbgStr += " DEFAULT=" + defaultStr;
}
}
else
if (!strcmp(token, "DISPLAYOPTION"))
{
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
dbgStr += std::string(" ") + token;
hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
dbgStr += plString(" ") + token;
bool read=stream->GetToken(token, kTokenLen);
if (read)
{
std::string oldOptions=curVar->GetDisplayOptions();
if (oldOptions.size())
oldOptions += std::string(",");
plString oldOptions=curVar->GetDisplayOptions();
if (!oldOptions.IsEmpty())
oldOptions += ",";
oldOptions += token;
curVar->SetDisplayOptions(oldOptions.c_str());
dbgStr += std::string("=") + token;
curVar->SetDisplayOptions(oldOptions);
dbgStr += plString("=") + token;
if (!stricmp(token, "hidden"))
curVar->SetInternal(true);
}
else
{
hsAssert(false, xtl::format("missing displayOption string, fileName=%s", fileName).c_str());
hsAssert(false, plString::Format("missing displayOption string, fileName=%s", fileName).c_str());
}
}
else
if (!strcmp(token, "DEFAULTOPTION"))
{
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
dbgStr += std::string(" ") + token;
hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
dbgStr += plString(" ") + token;
bool read=stream->GetToken(token, kTokenLen);
if (read)
{
dbgStr += std::string("=") + token;
dbgStr += plString("=") + token;
if (!stricmp(token, "vault"))
curVar->SetAlwaysNew(true);
}
else
{
hsAssert(false, xtl::format("missing defaultOption string, fileName=%s", fileName).c_str());
hsAssert(false, plString::Format("missing defaultOption string, fileName=%s", fileName).c_str());
}
}
@ -291,16 +291,16 @@ bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char tok
else
if (!strcmp(token, "INTERNAL"))
{
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
curVar->SetInternal(true);
dbgStr += std::string(" ") + token;
dbgStr += plString(" ") + token;
}
else
if (!strcmp(token, "PHASED"))
{
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
curVar->SetAlwaysNew(true);
dbgStr += std::string(" ") + token;
dbgStr += plString(" ") + token;
}
#endif
else

2
Sources/Plasma/PubUtilLib/plSDL/plStateChangeNotifier.cpp

@ -121,7 +121,7 @@ bool plStateChangeNotifier::operator==(const plStateChangeNotifier &other) const
// send notification msg to all registered recipients
//
void plStateChangeNotifier::SendNotificationMsg(const plSimpleStateVariable* srcVar, const plSimpleStateVariable* dstVar,
const char* sdlName)
const plString& sdlName)
{
plSDLNotificationMsg* m = new plSDLNotificationMsg;

66
Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp

@ -95,7 +95,7 @@ void plSDL::VariableLengthWrite(hsStream* s, int size, int val)
/////////////////////////////////////////////////////////////////////////////////
// State Data
/////////////////////////////////////////////////////////////////////////////////
plStateDataRecord::plStateDataRecord(const char* name, int version) : fFlags(0)
plStateDataRecord::plStateDataRecord(const plString& name, int version) : fFlags(0)
, fDescriptor( nil )
{
SetDescriptor(name, version);
@ -113,7 +113,7 @@ plStateDataRecord::~plStateDataRecord()
IDeleteVarsList(fSDVarsList);
}
void plStateDataRecord::SetDescriptor(const char* name, int version)
void plStateDataRecord::SetDescriptor(const plString& name, int version)
{
IInitDescriptor(name, version);
}
@ -125,10 +125,10 @@ void plStateDataRecord::IDeleteVarsList(VarsList& vars)
vars.clear();
}
void plStateDataRecord::IInitDescriptor(const char* name, int version)
void plStateDataRecord::IInitDescriptor(const plString& name, int version)
{
plStateDescriptor* sd = plSDLMgr::GetInstance()->FindDescriptor(name, version);
//hsAssert( sd, xtl::format("Failed to find sdl descriptor: %s,%d. Missing legacy descriptor?", name, version ).c_str() );
//hsAssert( sd, plString::Format("Failed to find sdl descriptor: %s,%d. Missing legacy descriptor?", name.c_str(), version ).c_str() );
if (sd)
IInitDescriptor(sd);
}
@ -268,7 +268,7 @@ bool plStateDataRecord::Read(hsStream* s, float timeConvert, uint32_t readOption
{
if (plSDLMgr::GetInstance()->GetNetApp())
plSDLMgr::GetInstance()->GetNetApp()->ErrorMsg("Failed reading SDL, desc %s",
fDescriptor && fDescriptor->GetName() ? fDescriptor->GetName() : "?");
fDescriptor ? fDescriptor->GetName().c_str("?") : "?");
return false;
}
}
@ -276,8 +276,8 @@ bool plStateDataRecord::Read(hsStream* s, float timeConvert, uint32_t readOption
catch(...)
{
hsAssert( false,
xtl::format("Something bad happened while reading simple var data, desc:%s",
fDescriptor && fDescriptor->GetName() ? fDescriptor->GetName() : "?").c_str());
plString::Format("Something bad happened while reading simple var data, desc:%s",
fDescriptor ? fDescriptor->GetName().c_str("?") : "?").c_str());
return false;
}
@ -302,7 +302,7 @@ bool plStateDataRecord::Read(hsStream* s, float timeConvert, uint32_t readOption
{
if (plSDLMgr::GetInstance()->GetNetApp())
plSDLMgr::GetInstance()->GetNetApp()->ErrorMsg("Failed reading nested SDL, desc %s",
fDescriptor && fDescriptor->GetName() ? fDescriptor->GetName() : "?");
fDescriptor ? fDescriptor->GetName().c_str("?") : "?");
return false;
}
}
@ -310,15 +310,15 @@ bool plStateDataRecord::Read(hsStream* s, float timeConvert, uint32_t readOption
catch(...)
{
hsAssert( false,
xtl::format("Something bad happened while reading nested var data, desc:%s",
fDescriptor && fDescriptor->GetName() ? fDescriptor->GetName() : "?").c_str());
plString::Format("Something bad happened while reading nested var data, desc:%s",
fDescriptor ? fDescriptor->GetName().c_str("?") : "?").c_str());
return false;
}
// convert to latest descriptor
// Only really need to do this the first time this descriptor is read...
plStateDescriptor* latestDesc=plSDLMgr::GetInstance()->FindDescriptor(fDescriptor->GetName(), plSDL::kLatestVersion);
hsAssert( latestDesc, xtl::format("Failed to find latest sdl descriptor for: %s", fDescriptor->GetName() ).c_str() );
hsAssert( latestDesc, plString::Format("Failed to find latest sdl descriptor for: %s", fDescriptor->GetName().c_str() ).c_str() );
bool forceConvert = (readOptions&plSDL::kForceConvert)!=0;
if ( latestDesc && ( forceConvert || ( fDescriptor->GetVersion()!=latestDesc->GetVersion() ) ) )
{
@ -392,17 +392,17 @@ void plStateDataRecord::Write(hsStream* s, float timeConvert, uint32_t writeOpti
//
// STATIC - read prefix header. returns true on success
//
bool plStateDataRecord::ReadStreamHeader(hsStream* s, char** name, int* version, plUoid* objUoid)
bool plStateDataRecord::ReadStreamHeader(hsStream* s, plString* name, int* version, plUoid* objUoid)
{
uint16_t savFlags;
s->ReadLE(&savFlags);
if (!(savFlags & plSDL::kAddedVarLengthIO)) // using to establish a new version in the header, can delete in 8/03
{
*name = nil;
*name = "";
return false; // bad version
}
*name = s->ReadSafeString();
*name = s->ReadSafeString_TEMP();
*version = s->ReadLE16();
if (objUoid)
@ -492,13 +492,14 @@ void plStateDataRecord::UpdateFrom(const plStateDataRecord& other, uint32_t writ
if ( GetDescriptor()->GetVersion()!=other.GetDescriptor()->GetVersion() )
{
plStateDescriptor* sd=plSDLMgr::GetInstance()->FindDescriptor( other.GetDescriptor()->GetName(), other.GetDescriptor()->GetVersion() );
hsAssert( sd, xtl::format( "Failed to find sdl descriptor %s,%d. Missing legacy descriptor?", other.GetDescriptor()->GetName(), other.GetDescriptor()->GetVersion() ).c_str() );
hsAssert( sd, plString::Format( "Failed to find sdl descriptor %s,%d. Missing legacy descriptor?",
other.GetDescriptor()->GetName().c_str(), other.GetDescriptor()->GetVersion() ).c_str() );
ConvertTo( sd );
}
hsAssert(other.GetDescriptor()==fDescriptor,
xtl::format("descriptor mismatch in UpdateFromDirty, SDL=%s,%s version %d %d",
GetDescriptor()->GetName(), other.GetDescriptor()->GetName(),
plString::Format("descriptor mismatch in UpdateFromDirty, SDL=%s,%s version %d %d",
GetDescriptor()->GetName().c_str(), other.GetDescriptor()->GetName().c_str(),
GetDescriptor()->GetVersion(), other.GetDescriptor()->GetVersion()).c_str());
bool dirtyOnly = (writeOptions & plSDL::kDirtyOnly);
@ -543,9 +544,9 @@ void plStateDataRecord::FlagDifferentState(const plStateDataRecord& other)
}
else
{
hsAssert(false, xtl::format("descriptor mismatch in FlagDifferentState, mine %s %d, other %s %d",
fDescriptor->GetName(), fDescriptor->GetVersion(),
other.GetDescriptor()->GetName(), other.GetDescriptor()->GetVersion()).c_str());
hsAssert(false, plString::Format("descriptor mismatch in FlagDifferentState, mine %s %d, other %s %d",
fDescriptor->GetName().c_str(), fDescriptor->GetVersion(),
other.GetDescriptor()->GetName().c_str(), other.GetDescriptor()->GetVersion()).c_str());
}
}
@ -597,9 +598,9 @@ void plStateDataRecord::FlagNewerState(const plStateDataRecord& other, bool resp
}
else
{
hsAssert(false, xtl::format("descriptor mismatch in FlagNewerState, mine %s %d, other %s %d",
fDescriptor->GetName(), fDescriptor->GetVersion(),
other.GetDescriptor()->GetName(), other.GetDescriptor()->GetVersion()).c_str());
hsAssert(false, plString::Format("descriptor mismatch in FlagNewerState, mine %s %d, other %s %d",
fDescriptor->GetName().c_str(), fDescriptor->GetVersion(),
other.GetDescriptor()->GetName().c_str(), other.GetDescriptor()->GetVersion()).c_str());
}
}
@ -651,16 +652,16 @@ bool plStateDataRecord::IConvertVar(plSimpleStateVariable* fromVar, plSimpleStat
return true; // ok
}
plStateVariable* plStateDataRecord::IFindVar(const VarsList& vars, const char* name) const
plStateVariable* plStateDataRecord::IFindVar(const VarsList& vars, const plString& name) const
{
for (int i = 0; i < vars.size(); i++)
{
if (!stricmp(vars[i]->GetVarDescriptor()->GetName(), name))
if (!vars[i]->GetVarDescriptor()->GetName().CompareI(name))
return vars[i];
}
if (plSDLMgr::GetInstance()->GetNetApp())
plSDLMgr::GetInstance()->GetNetApp()->ErrorMsg("Failed to find SDL var %s", name);
plSDLMgr::GetInstance()->GetNetApp()->ErrorMsg("Failed to find SDL var %s", name.c_str());
return nil;
}
@ -674,7 +675,7 @@ bool plStateDataRecord::ConvertTo( plStateDescriptor* other, bool force )
if (!other && !force)
return false; // err
hsAssert(!stricmp(fDescriptor->GetName(), other->GetName()), "descriptor mismatch");
hsAssert(!fDescriptor->GetName().CompareI(other->GetName()), "descriptor mismatch");
if ( !force && (other == fDescriptor || other->GetVersion()==fDescriptor->GetVersion()))
return true; // ok, nothing to do
@ -682,7 +683,7 @@ bool plStateDataRecord::ConvertTo( plStateDescriptor* other, bool force )
hsAssert(other->GetVersion()>=fDescriptor->GetVersion(), "converting to an older state descriptor version?");
hsLogEntry( plNetApp::StaticDebugMsg( "SDR(%p) converting sdl record %s from version %d to %d (force:%d)",
this, fDescriptor->GetName(), fDescriptor->GetVersion(), other->GetVersion(), force ) );
this, fDescriptor->GetName().c_str(), fDescriptor->GetVersion(), other->GetVersion(), force ) );
// make other StateData to represent other descriptor,
// this will be the destination for the convert operation
@ -696,7 +697,7 @@ bool plStateDataRecord::ConvertTo( plStateDescriptor* other, bool force )
{
// get other var info
plSimpleStateVariable* otherVar = otherStateData.GetVar(i);
const char* otherVarName = otherVar->GetVarDescriptor()->GetName();
plString otherVarName = otherVar->GetVarDescriptor()->GetName();
// find corresponding var in my data
plSimpleStateVariable* myVar=FindVar(otherVarName);
@ -708,7 +709,7 @@ bool plStateDataRecord::ConvertTo( plStateDescriptor* other, bool force )
for(i=0;i<otherStateData.GetNumSDVars(); i++)
{
plSDStateVariable* otherSDVar = otherStateData.GetSDVar(i);
const char* otherSDVarName = otherSDVar->GetVarDescriptor()->GetName();
plString otherSDVarName = otherSDVar->GetVarDescriptor()->GetName();
// find corresponding var in my data
plSDStateVariable* mySDVar=FindSDVar(otherSDVarName);
@ -747,7 +748,7 @@ void plStateDataRecord::DumpToObjectDebugger(const char* msg, bool dirtyOnly, in
dbg->LogMsg(plString::Format("%s%s", pad.c_str(),msg).c_str());
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());
pad.c_str(), this, fDescriptor->GetName().c_str(), dirtyOnly, numVars+numSDVars, fFlags&kVolatile).c_str());
// dump simple vars
for(i=0;i<fVarsList.size(); i++)
@ -787,7 +788,8 @@ void plStateDataRecord::DumpToStream(hsStream* stream, const char* msg, bool dir
stream->Write(logStr.GetSize(), 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);
logStr = plString::Format("%sSDR(%p), desc=%s, showDirty=%d, numVars=%d, vol=%d",
pad.c_str(), this, fDescriptor->GetName().c_str(), dirtyOnly, numVars+numSDVars, fFlags&kVolatile);
stream->Write(logStr.GetSize(), logStr.c_str());
// dump simple vars

8
Sources/Plasma/PubUtilLib/plSDL/plStateDescriptor.cpp

@ -56,19 +56,18 @@ plStateDescriptor::~plStateDescriptor()
void plStateDescriptor::IDeInit()
{
delete [] fName;
int i;
for(i=0;i<fVarsList.size();i++)
delete fVarsList[i];
fVarsList.clear();
}
plVarDescriptor* plStateDescriptor::FindVar(const char* name, int* idx) const
plVarDescriptor* plStateDescriptor::FindVar(const plString& name, int* idx) const
{
VarsList::const_iterator it;
for(it=fVarsList.begin(); it != fVarsList.end(); it++)
{
if (!stricmp((*it)->GetName(), name))
if (!(*it)->GetName().CompareI(name))
{
if (idx)
*idx = it-fVarsList.begin();
@ -95,8 +94,7 @@ bool plStateDescriptor::Read(hsStream* s)
IDeInit();
delete [] fName;
fName = s->ReadSafeString();
fName = s->ReadSafeString_TEMP();
uint16_t version=s->ReadLE16();
fVersion=version;

130
Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp

@ -108,11 +108,9 @@ public:
void plStateVarNotificationInfo::Read(hsStream* s, uint32_t readOptions)
{
uint8_t saveFlags=s->ReadByte(); // unused
char* hint=s->ReadSafeString();
if (hint && !(readOptions & plSDL::kSkipNotificationInfo))
fHintString = (const char*)hint;
// we're done with it...
delete[] hint;
plString hint=s->ReadSafeString_TEMP();
if (!hint.IsNull() && !(readOptions & plSDL::kSkipNotificationInfo))
fHintString = hint;
}
void plStateVarNotificationInfo::Write(hsStream* s, uint32_t writeOptions) const
@ -212,8 +210,8 @@ void plSimpleStateVariable::IDeAlloc()
}
break;
default:
hsAssert(false, xtl::format("undefined atomic type:%d var:%s cnt:%d",
type, GetName() ? GetName() : "?", GetCount()).c_str());
hsAssert(false, plString::Format("undefined atomic type:%d var:%s cnt:%d",
type, GetName().c_str("?"), GetCount()).c_str());
break;
};
@ -328,12 +326,11 @@ void plSimpleStateVariable::TimeStamp( const plUnifiedTime & ut/*=plUnifiedTime:
//
// Set value from string. Used to set default values which are specified as strings.
//
bool plSimpleStateVariable::SetFromString(const char* valueConst, int idx, bool timeStampNow)
bool plSimpleStateVariable::SetFromString(const plString& value, int idx, bool timeStampNow)
{
if (!valueConst)
if (value.IsNull())
return false;
std::string value = valueConst;
plVarDescriptor::Type type=fVar.GetAtomicType();
switch(type)
{
@ -346,54 +343,47 @@ bool plSimpleStateVariable::SetFromString(const char* valueConst, int idx, bool
case plVarDescriptor::kByte:
{
// handles value in the form "(i,j,k)" for vectors
static char seps[] = "( ,)";
char* ptr = strtok( (char*)value.c_str(), seps );
std::vector<plString> bits = value.Tokenize("( ,)");
int i=idx*fVar.GetAtomicCount();
while (ptr)
for (std::vector<plString>::iterator ptr = bits.begin(); ptr != bits.end(); ++ptr)
{
if ((type==plVarDescriptor::kInt) && fI)
fI[i++] = atoi(ptr);
fI[i++] = ptr->ToInt();
else if (type==plVarDescriptor::kShort && fS)
fS[i++] = (short)atoi(ptr);
fS[i++] = static_cast<short>(ptr->ToInt());
else if (type==plVarDescriptor::kByte && fBy)
fBy[i++] = (uint8_t)atoi(ptr);
fBy[i++] = static_cast<uint8_t>(ptr->ToInt());
else if ( (type==plVarDescriptor::kFloat || type==plVarDescriptor::kAgeTimeOfDay) && fF)
fF[i++] = (float)atof(ptr);
fF[i++] = static_cast<float>(ptr->ToFloat());
else if ( (type==plVarDescriptor::kDouble || type==plVarDescriptor::kTime) && fD)
fD[i++] = atof(ptr);
ptr = strtok(nil, seps);
fD[i++] = ptr->ToDouble();
}
}
break;
case plVarDescriptor::kBool:
{
// handles value in the form "(i,j,k)" for things like vectors
static char seps[] = "( ,)";
char* ptr = strtok( (char*)value.c_str(), seps );
std::vector<plString> bits = value.Tokenize("( ,)");
int i=idx*fVar.GetAtomicCount();
while (ptr)
for (std::vector<plString>::iterator ptr = bits.begin(); ptr != bits.end(); ++ptr)
{
if (!stricmp(ptr, "true"))
if (!ptr->CompareI("true"))
fB[i++]=true;
else
if (!stricmp(ptr, "false"))
else if (!ptr->CompareI("false"))
fB[i++]=false;
else
fB[i++] = (atoi(ptr) != 0);
ptr = strtok(nil, seps);
fB[i++] = (ptr->ToInt() != 0);
}
}
break;
case plVarDescriptor::kString32:
{
// handles value in the form "(i,j,k)" for things like vectors
static char seps[] = "( ,)";
char* ptr = strtok( (char*)value.c_str(), seps );
std::vector<plString> bits = value.Tokenize("( ,)");
int i=idx*fVar.GetAtomicCount();
while (ptr)
for (std::vector<plString>::iterator ptr = bits.begin(); ptr != bits.end(); ++ptr)
{
hsStrncpy(fS32[i++], ptr, 32);
ptr = strtok(nil, seps);
hsStrncpy(fS32[i++], ptr->c_str(), 32);
}
}
break;
@ -419,12 +409,12 @@ void plSimpleStateVariable::IVarSet(bool timeStampNow/*=true*/)
//
// Get value as string.
//
char* plSimpleStateVariable::GetAsString(int idx) const
plString plSimpleStateVariable::GetAsString(int idx) const
{
int j;
std::string str;
plString str;
if (fVar.GetAtomicCount()>1)
str = str + "(";
str += "(";
plVarDescriptor::Type type=fVar.GetAtomicType();
switch(type)
@ -442,20 +432,20 @@ char* plSimpleStateVariable::GetAsString(int idx) const
for(j=0;j<fVar.GetAtomicCount();j++)
{
if (type==plVarDescriptor::kInt)
str.append( xtl::format( "%d", fI[i++]) );
str += plString::Format( "%d", fI[i++]);
else if (type==plVarDescriptor::kShort)
str.append( xtl::format( "%d", fS[i++]) );
str += plString::Format( "%d", fS[i++]);
else if (type==plVarDescriptor::kByte)
str.append( xtl::format( "%d", fBy[i++]) );
str += plString::Format( "%d", fBy[i++]);
else if (type==plVarDescriptor::kFloat || type==plVarDescriptor::kAgeTimeOfDay)
str.append( xtl::format( "%.3f", fF[i++]) );
str += plString::Format( "%.3f", fF[i++]);
else if (type==plVarDescriptor::kDouble)
str.append( xtl::format( "%.3f", fD[i++]) );
str += plString::Format( "%.3f", fD[i++]);
else if (type==plVarDescriptor::kTime)
{
double tmp;
Get(&tmp, i++);
str.append( xtl::format( "%.3f", tmp) );
str += plString::Format( "%.3f", tmp);
}
if (j==fVar.GetAtomicCount()-1)
@ -474,7 +464,7 @@ char* plSimpleStateVariable::GetAsString(int idx) const
int i=idx*fVar.GetAtomicCount();
for(j=0;j<fVar.GetAtomicCount();j++)
{
str.append( xtl::format( "%s", fB[i++] ? "true" : "false") );
str += plString::Format( "%s", fB[i++] ? "true" : "false");
if (j==fVar.GetAtomicCount()-1)
{
@ -492,7 +482,7 @@ char* plSimpleStateVariable::GetAsString(int idx) const
int i=idx*fVar.GetAtomicCount();
for(j=0;j<fVar.GetAtomicCount();j++)
{
str.append( xtl::format( "%s", fS32[i++]) );
str += plString::Format( "%s", fS32[i++]);
if (j==fVar.GetAtomicCount()-1)
{
@ -510,7 +500,7 @@ char* plSimpleStateVariable::GetAsString(int idx) const
int i=idx*fVar.GetAtomicCount();
for(j=0;j<fVar.GetAtomicCount();j++)
{
str.append( xtl::format( "%s", "other") );
str += "other";
if (j==fVar.GetAtomicCount()-1)
{
@ -524,7 +514,7 @@ char* plSimpleStateVariable::GetAsString(int idx) const
break;
}
return hsStrcpy(str.c_str());
return str;
}
//
@ -2131,7 +2121,7 @@ case type: \
} \
break;
void plSimpleStateVariable::NotifyStateChange(const plSimpleStateVariable* other, const char* sdlName)
void plSimpleStateVariable::NotifyStateChange(const plSimpleStateVariable* other, const plString& sdlName)
{
if (fChangeNotifiers.size()==0)
return;
@ -2174,8 +2164,8 @@ void plSimpleStateVariable::NotifyStateChange(const plSimpleStateVariable* other
if (plNetObjectDebuggerBase::GetInstance() && plNetObjectDebuggerBase::GetInstance()->GetDebugging())
{
plNetObjectDebuggerBase::GetInstance()->LogMsg(
xtl::format("Var %s did %s send notification difference. Has %d notifiers with %d recipients.",
GetName(), !notify ? "NOT" : "", fChangeNotifiers.size(), numNotifiers).c_str());
plString::Format("Var %s did %s send notification difference. Has %d notifiers with %d recipients.",
GetName().c_str(), !notify ? "NOT" : "", fChangeNotifiers.size(), numNotifiers).c_str());
}
}
@ -2290,12 +2280,12 @@ void plSimpleStateVariable::DumpToObjectDebugger(bool dirtyOnly, int level) cons
if (!dbg)
return;
std::string pad;
plString pad;
int i;
for(i=0;i<level; i++)
pad += " ";
std::string logMsg = xtl::format( "%sSimpleVar, name:%s[%d]", pad.c_str(), GetName(), GetCount());
plString logMsg = plString::Format( "%sSimpleVar, name:%s[%d]", pad.c_str(), GetName().c_str(), GetCount());
if (GetCount()>1)
{
dbg->LogMsg(logMsg.c_str()); // it's going to be a long msg, so print it on its own line
@ -2305,22 +2295,21 @@ void plSimpleStateVariable::DumpToObjectDebugger(bool dirtyOnly, int level) cons
pad += "\t";
for(i=0;i<GetCount(); i++)
{
char* s=GetAsString(i);
plString s=GetAsString(i);
if (fVar.GetAtomicType() == plVarDescriptor::kTime)
{
const char* p=fT[i].PrintWMillis();
logMsg += xtl::format( "%sVar:%d gameTime:%s pst:%s ts:%s",
pad.c_str(), i, s ? s : "?", p, fTimeStamp.Format("%c").c_str() );
logMsg += plString::Format( "%sVar:%d gameTime:%s pst:%s ts:%s",
pad.c_str(), i, s.c_str("?"), p, fTimeStamp.Format("%c").c_str() );
}
else
{
logMsg +=xtl::format( "%sVar:%d value:%s ts:%s",
pad.c_str(), i, s ? s : "?", fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c").c_str() );
logMsg += plString::Format( "%sVar:%d value:%s ts:%s",
pad.c_str(), i, s.c_str("?"), fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c").c_str() );
}
delete [] s;
if ( !dirtyOnly )
logMsg += xtl::format( " dirty:%d", IsDirty() );
logMsg += plString::Format( " dirty:%d", IsDirty() );
dbg->LogMsg(logMsg.c_str());
logMsg = "";
@ -2329,12 +2318,12 @@ void plSimpleStateVariable::DumpToObjectDebugger(bool dirtyOnly, int level) cons
void plSimpleStateVariable::DumpToStream(hsStream* stream, bool dirtyOnly, int level) const
{
std::string pad;
plString pad;
int i;
for(i=0;i<level; i++)
pad += " ";
std::string logMsg = xtl::format( "%sSimpleVar, name:%s[%d]", pad.c_str(), GetName(), GetCount());
plString logMsg = plString::Format( "%sSimpleVar, name:%s[%d]", pad.c_str(), GetName().c_str(), GetCount());
if (GetCount()>1)
{
stream->WriteString(logMsg.c_str()); // it's going to be a long msg, so print it on its own line
@ -2344,22 +2333,21 @@ void plSimpleStateVariable::DumpToStream(hsStream* stream, bool dirtyOnly, int l
pad += "\t";
for(i=0;i<GetCount(); i++)
{
char* s=GetAsString(i);
plString s=GetAsString(i);
if (fVar.GetAtomicType() == plVarDescriptor::kTime)
{
const char* p=fT[i].PrintWMillis();
logMsg += xtl::format( "%sVar:%d gameTime:%s pst:%s ts:%s",
pad.c_str(), i, s ? s : "?", p, fTimeStamp.Format("%c").c_str() );
logMsg += plString::Format( "%sVar:%d gameTime:%s pst:%s ts:%s",
pad.c_str(), i, s.c_str("?"), p, fTimeStamp.Format("%c").c_str() );
}
else
{
logMsg +=xtl::format( "%sVar:%d value:%s ts:%s",
pad.c_str(), i, s ? s : "?", fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c").c_str() );
logMsg += plString::Format( "%sVar:%d value:%s ts:%s",
pad.c_str(), i, s.c_str("?"), fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c").c_str() );
}
delete [] s;
if ( !dirtyOnly )
logMsg += xtl::format( " dirty:%d", IsDirty() );
logMsg += plString::Format( " dirty:%d", IsDirty() );
stream->WriteString(logMsg.c_str());
logMsg = "";
@ -2497,9 +2485,9 @@ void plSDStateVariable::CopyFrom(plSDStateVariable* other, uint32_t writeOptions
//
void plSDStateVariable::UpdateFrom(plSDStateVariable* other, uint32_t writeOptions/*=0*/)
{
hsAssert(!stricmp(other->GetSDVarDescriptor()->GetName(), fVarDescriptor->GetName()),
xtl::format("var descriptor mismatch in UpdateFrom, name %s,%s ver %d,%d",
GetName(), other->GetName()).c_str());
hsAssert(!other->GetSDVarDescriptor()->GetName().CompareI(fVarDescriptor->GetName()),
plString::Format("var descriptor mismatch in UpdateFrom, name %s,%s ver %d,%d",
GetName().c_str(), other->GetName().c_str()).c_str());
Resize(other->GetCount()); // make sure sizes match
bool dirtyOnly = (writeOptions & plSDL::kDirtyOnly);
@ -2521,8 +2509,8 @@ void plSDStateVariable::ConvertTo(plSDStateVariable* otherSDVar, bool force )
plStateDescriptor* otherSD=otherSDVar->GetSDVarDescriptor()->GetStateDescriptor();
hsLogEntry( plNetApp::StaticDebugMsg( "SDSV(%p) converting %s from %s to %s (force:%d)",
this, fVarDescriptor->GetName(), fVarDescriptor->GetTypeString(),
otherSDVar->GetSDVarDescriptor()->GetTypeString(), force ) );
this, fVarDescriptor->GetName().c_str(), fVarDescriptor->GetTypeString().c_str(),
otherSDVar->GetSDVarDescriptor()->GetTypeString().c_str(), force ) );
int j;
for(j=0;j<GetCount(); j++)

120
Sources/Plasma/PubUtilLib/plSDL/plVarDescriptor.cpp

@ -55,96 +55,77 @@ const uint8_t plVarDescriptor::kVersion=3; // for Read/Write format
// State Var
/////////////////////////////////////////////////////////////////////////////////
plVarDescriptor::plVarDescriptor() :
fName(nil),
fCount(1),
fType(kNone),
fTypeString(nil),
fDefault(nil),
fFlags(0)
{
}
plVarDescriptor::~plVarDescriptor()
{
delete [] fName;
delete [] fDefault;
delete [] fTypeString;
}
//
// Set type from a string. Return false on err.
//
bool plVarDescriptor::SetType(const char* type)
bool plVarDescriptor::SetType(const plString& type)
{
if (!type)
if (type.IsNull())
return false;
if (!stricmp(type, "vector3"))
if (!type.CompareI("vector3"))
fType=kVector3;
else
if (!stricmp(type, "point3"))
if (!type.CompareI("point3"))
fType=kPoint3;
else
if (!stricmp(type, "rgb"))
if (!type.CompareI("rgb"))
fType=kRGB;
else
if (!stricmp(type, "rgba"))
if (!type.CompareI("rgba"))
fType=kRGBA;
else
if (!stricmp(type, "rgb8"))
if (!type.CompareI("rgb8"))
fType=kRGB8;
else
if (!stricmp(type, "rgba8"))
if (!type.CompareI("rgba8"))
fType=kRGBA8;
else
if (!strnicmp(type, "quat",4))
if (!type.CompareNI("quat", 4))
fType=kQuaternion;
else
if (!stricmp(type, "rgba"))
if (!type.CompareI("rgba"))
fType=kRGBA;
else
if (!stricmp(type, "int"))
if (!type.CompareI("int"))
fType=kInt;
else
if (!stricmp(type, "byte"))
if (!type.CompareI("byte"))
fType=kByte;
else
if (!stricmp(type, "short"))
if (!type.CompareI("short"))
fType=kShort;
else
if (!stricmp(type, "float"))
if (!type.CompareI("float"))
fType=kFloat;
else
if (!stricmp(type, "double"))
if (!type.CompareI("double"))
fType=kDouble;
else
if (!stricmp(type, "time"))
if (!type.CompareI("time"))
fType=kTime;
else
if (!stricmp(type, "ageTimeOfDay"))
if (!type.CompareI("ageTimeOfDay"))
fType=kAgeTimeOfDay;
else
if (!stricmp(type, "bool"))
if (!type.CompareI("bool"))
fType=kBool;
else
if (!stricmp(type, "string32"))
if (!type.CompareI("string32"))
fType=kString32;
else
if (!stricmp(type, "plKey"))
if (!type.CompareI("plKey"))
fType=kKey;
else
if (!stricmp(type, "message") || !stricmp(type, "creatable") )
if (!type.CompareI("message") || !type.CompareI("creatable") )
fType=kCreatable;
else
if (*type=='$')
if (type.CharAt(0)=='$')
fType=kStateDescriptor;
else
return false; // err
delete [] fTypeString;
fTypeString = hsStrcpy(type);
fTypeString = type;
return true; // ok
}
@ -156,8 +137,7 @@ void plVarDescriptor::CopyFrom(const plVarDescriptor* other)
SetCount(other->GetCount());
SetDisplayOptions(other->GetDisplayOptions());
delete [] fTypeString;
fTypeString=hsStrcpy(other->GetTypeString());
fTypeString=other->GetTypeString();
fType = other->GetType();
fFlags = other->fFlags;
@ -178,8 +158,7 @@ bool plVarDescriptor::Read(hsStream* s)
return false;
}
delete [] fName;
fName=s->ReadSafeString();
fName=s->ReadSafeString_TEMP();
plMsgStdStringHelper::Peek(fDisplayOptions, s);
@ -187,8 +166,7 @@ bool plVarDescriptor::Read(hsStream* s)
fType=(Type)s->ReadByte();
delete [] fDefault;
fDefault = s->ReadSafeString();
fDefault = s->ReadSafeString_TEMP();
fFlags = s->ReadLE32();
return true;
@ -259,87 +237,84 @@ int plSimpleVarDescriptor::GetSize() const
// Set type from a string. Return false on err.
// Sets atomicCount and atomicType
//
bool plSimpleVarDescriptor::SetType(const char* type)
bool plSimpleVarDescriptor::SetType(const plString& type)
{
if (!type)
return false;
if (!plVarDescriptor::SetType(type))
return false;
if (!stricmp(type, "vector3"))
if (!type.CompareI("vector3"))
{
fAtomicCount = 3;
fAtomicType=kFloat;
}
else
if (!stricmp(type, "point3"))
if (!type.CompareI("point3"))
{
fAtomicCount = 3;
fAtomicType=kFloat;
}
else
if (!stricmp(type, "rgb"))
if (!type.CompareI("rgb"))
{
fAtomicCount = 3;
fAtomicType=kFloat;
}
else
if (!stricmp(type, "rgba"))
if (!type.CompareI("rgba"))
{
fAtomicCount = 4;
fAtomicType=kFloat;
}
else
if (!stricmp(type, "rgb8"))
if (!type.CompareI("rgb8"))
{
fAtomicCount = 3;
fAtomicType=kByte;
}
else
if (!stricmp(type, "rgba8"))
if (!type.CompareI("rgba8"))
{
fAtomicCount = 4;
fAtomicType=kByte;
}
else
if (!strnicmp(type, "quat",4))
if (!type.CompareNI("quat", 4))
{
fAtomicCount = 4;
fAtomicType=kFloat;
}
else
if (!stricmp(type, "int"))
if (!type.CompareI("int"))
fAtomicType=kInt;
else
if (!stricmp(type, "byte"))
if (!type.CompareI("byte"))
fAtomicType=kByte;
else
if (!stricmp(type, "short"))
if (!type.CompareI("short"))
fAtomicType=kShort;
else
if (!stricmp(type, "float"))
if (!type.CompareI("float"))
fAtomicType=kFloat;
else
if (!stricmp(type, "double"))
if (!type.CompareI("double"))
fAtomicType=kDouble;
else
if (!stricmp(type, "time"))
if (!type.CompareI("time"))
fAtomicType=kTime;
else
if (!stricmp(type, "ageTimeOfDay"))
if (!type.CompareI("ageTimeOfDay"))
fAtomicType=kAgeTimeOfDay;
else
if (!stricmp(type, "bool"))
if (!type.CompareI("bool"))
fAtomicType=kBool;
else
if (!stricmp(type, "string32"))
if (!type.CompareI("string32"))
fAtomicType=kString32;
else
if (!stricmp(type, "plKey"))
if (!type.CompareI("plKey"))
fAtomicType=kKey;
else
if (!stricmp(type, "message") || !stricmp(type, "creatable"))
if (!type.CompareI("message") || !type.CompareI("creatable"))
fAtomicType=kCreatable;
else
return false; // err
@ -398,12 +373,11 @@ bool plSDVarDescriptor::Read(hsStream* s)
if (!plVarDescriptor::Read(s))
return false;
char* sdName=s->ReadSafeString();
plString sdName=s->ReadSafeString_TEMP();
uint16_t version = s->ReadLE16();
plStateDescriptor* sd=plSDLMgr::GetInstance()->FindDescriptor(sdName, version);
hsAssert( sd, xtl::format("Failed to find sdl descriptor: %s,%d. Missing legacy descriptor?", sdName, version ).c_str() );
hsAssert( sd, plString::Format("Failed to find sdl descriptor: %s,%d. Missing legacy descriptor?", sdName.c_str(), version ).c_str() );
SetStateDesc(sd);
delete [] sdName;
return true;
}

8
Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp

@ -2424,13 +2424,9 @@ bool VaultAddOwnedAgeSpawnPoint (const Uuid & ageInstId, const plSpawnPointInfo
RelVaultNode * link = nil;
for (;;) {
if (!spawnPt.GetName())
if (spawnPt.GetName().IsEmpty())
break;
if (!spawnPt.GetTitle())
break;
if (!StrLen(spawnPt.GetName()))
break;
if (!StrLen(spawnPt.GetTitle()))
if (spawnPt.GetTitle().IsEmpty())
break;
fldr = VaultGetAgesIOwnFolderIncRef();

48
Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp

@ -534,13 +534,12 @@ bool VaultSDLNode::GetStateDataRecord (plStateDataRecord * rec, unsigned readOpt
ram.Write(sdlDataLen, sdlData);
ram.Rewind();
char * sdlRecName = nil;
int sdlRecVersion;
plString sdlRecName;
int sdlRecVersion;
if (!plStateDataRecord::ReadStreamHeader(&ram, &sdlRecName, &sdlRecVersion))
return false;
rec->SetDescriptor(sdlRecName, sdlRecVersion);
free(sdlRecName);
// Note: Setting from default here results in a bug causing age SDL to
// be incorrectly shown when immediately linking back to an age you linked
@ -698,14 +697,14 @@ bool VaultImageNode::ExtractImage (plMipmap ** dst) {
#ifdef CLIENT
struct MatchesSpawnPointTitle
{
std::string fTitle;
MatchesSpawnPointTitle( const char * title ):fTitle( title ){}
plString fTitle;
MatchesSpawnPointTitle( const plString & title ):fTitle( title ){}
bool operator ()( const plSpawnPointInfo & p ) const { return ( p.fTitle==fTitle ); }
};
struct MatchesSpawnPointName
{
std::string fName;
MatchesSpawnPointName( const char * name ):fName( name ){}
plString fName;
MatchesSpawnPointName( const plString & name ):fName( name ){}
bool operator ()( const plSpawnPointInfo & p ) const { return ( p.fSpawnPt==fName ); }
};
#endif
@ -768,7 +767,7 @@ void VaultAgeLinkNode::AddSpawnPoint (const plSpawnPointInfo & point) {
//============================================================================
#ifdef CLIENT
void VaultAgeLinkNode::RemoveSpawnPoint (const char spawnPtName[]) {
void VaultAgeLinkNode::RemoveSpawnPoint (const plString & spawnPtName) {
plSpawnPointVec points;
GetSpawnPoints( &points );
@ -784,7 +783,7 @@ void VaultAgeLinkNode::RemoveSpawnPoint (const char spawnPtName[]) {
//============================================================================
#ifdef CLIENT
bool VaultAgeLinkNode::HasSpawnPoint (const char spawnPtName[]) const {
bool VaultAgeLinkNode::HasSpawnPoint (const plString & spawnPtName) const {
plSpawnPointVec points;
GetSpawnPoints( &points );
@ -804,23 +803,18 @@ bool VaultAgeLinkNode::HasSpawnPoint (const plSpawnPointInfo & point) const {
#ifdef CLIENT
void VaultAgeLinkNode::GetSpawnPoints (plSpawnPointVec * out) const {
char str[2048];
memset(&str, 0, sizeof(str));
memcpy(str, spawnPoints, min(spawnPointsLen, arrsize(str) - 1));
char token1[ 1024 ];
hsStringTokenizer izer1( str, ";" );
while ( izer1.Next( token1, sizeof( token1 ) ) )
plString str = plString::FromUtf8(reinterpret_cast<const char*>(spawnPoints), spawnPointsLen);
std::vector<plString> izer = str.Tokenize(";");
for (auto token1 = izer.begin(); token1 != izer.end(); ++token1)
{
plSpawnPointInfo point;
char token2[ 1024 ];
hsStringTokenizer izer2( token1, ":" );
if ( izer2.Next( token2, sizeof( token2 ) ) )
point.fTitle = token2;
if ( izer2.Next( token2, sizeof( token2 ) ) )
point.fSpawnPt = token2;
if ( izer2.Next( token2, sizeof( token2 ) ) )
point.fCameraStack = token2;
std::vector<plString> izer2 = token1->Tokenize(":");
if ( izer2.size() > 0)
point.fTitle = izer2[0];
if ( izer2.size() > 1)
point.fSpawnPt = izer2[1];
if ( izer2.size() > 2)
point.fSpawnPt = izer2[2];
out->push_back(point);
}
@ -831,7 +825,7 @@ void VaultAgeLinkNode::GetSpawnPoints (plSpawnPointVec * out) const {
#ifdef CLIENT
void VaultAgeLinkNode::SetSpawnPoints (const plSpawnPointVec & in) {
std::stringstream ss;
plStringStream ss;
for ( unsigned i=0; i<in.size(); i++ ) {
ss
<< in[i].fTitle << ":"
@ -843,8 +837,8 @@ void VaultAgeLinkNode::SetSpawnPoints (const plSpawnPointVec & in) {
base,
&spawnPoints,
&spawnPointsLen,
(const uint8_t *)ss.str().c_str(),
ss.str().size()
(const uint8_t *)ss.GetString().c_str(),
ss.GetLength()
);
}
#endif

4
Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.h

@ -277,8 +277,8 @@ struct VaultAgeLinkNode : NetVaultNodeAccess {
#ifdef CLIENT
bool CopyTo (plAgeLinkStruct * link);
void AddSpawnPoint (const plSpawnPointInfo & point); // will only add if not there already.
void RemoveSpawnPoint (const char spawnPtName[]);
bool HasSpawnPoint (const char spawnPtName[]) const;
void RemoveSpawnPoint (const plString & spawnPtName);
bool HasSpawnPoint (const plString & spawnPtName) const;
bool HasSpawnPoint (const plSpawnPointInfo & point) const; // compares spawn name only, not title.
void GetSpawnPoints (plSpawnPointVec * out) const;
void SetSpawnPoints (const plSpawnPointVec & in);

2
Sources/Tools/MaxComponent/plAnimComponent.cpp

@ -178,7 +178,7 @@ void plAnimComponentProc::FillAgeGlobalComboBox(HWND box, const char *varName)
var->GetType() == plVarDescriptor::kTime ||
var->GetType() == plVarDescriptor::kAgeTimeOfDay)
{
ComboBox_AddString(box, var->GetName());
ComboBox_AddString(box, var->GetName().c_str());
}
}
}

4
Sources/Tools/MaxMain/CMakeLists.txt

@ -202,6 +202,10 @@ if (WIN32)
target_link_libraries(MaxMain winmm)
endif(WIN32)
if(USE_VLD)
target_link_libraries(MaxMain ${VLD_LIBRARY})
endif()
source_group("Header Files" FILES ${MaxMain_HEADERS})
source_group("Resource Files" FILES ${MaxMain_RESOURCES})
source_group("Source Files" FILES ${MaxMain_SOURCES})

4
Sources/Tools/MaxPlasmaLights/CMakeLists.txt

@ -130,6 +130,10 @@ if (WIN32)
target_link_libraries(MaxPlasmaLights Ws2_32)
endif(WIN32)
if(USE_VLD)
target_link_libraries(MaxPlasmaLights ${VLD_LIBRARY})
endif()
source_group("Header Files" FILES ${MaxPlasmaLights_HEADERS})
source_group("Resource Files" FILES ${MaxPlasmaLights_RESOURCES})
source_group("Source Files" FILES ${MaxPlasmaLights_SOURCES})

4
Sources/Tools/plFontConverter/CMakeLists.txt

@ -45,6 +45,10 @@ if (WIN32)
target_link_libraries(plFontConverter shlwapi)
endif(WIN32)
if(USE_VLD)
target_link_libraries(plFontConverter ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plFontConverter_SOURCES})
source_group("Header Files" FILES ${plFontConverter_HEADERS})
source_group("Resource Files" FILES ${plFontConverter_RESOURCES})

4
Sources/Tools/plLocalizationEditor/CMakeLists.txt

@ -35,6 +35,10 @@ target_link_libraries(plLocalizationEditor pfLocalizationMgr)
target_link_libraries(plLocalizationEditor ${EXPAT_LIBRARY})
target_link_libraries(plLocalizationEditor comctl32)
if(USE_VLD)
target_link_libraries(plLocalizationEditor ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plLocalizationEditor_SOURCES})
source_group("Header Files" FILES ${plLocalizationEditor_HEADERS})
source_group("Resource Files" FILES ${plLocalizationEditor_RESOURCES})

8
Sources/Tools/plResBrowser/CMakeLists.txt

@ -58,10 +58,14 @@ if (WIN32)
target_link_libraries(plResBrowser Ws2_32)
target_link_libraries(plResBrowser winmm)
target_link_libraries(plResBrowser strmiids)
target_link_libraries(plResBrowser comctl32)
target_link_libraries(plResBrowser shlwapi)
target_link_libraries(plResBrowser comctl32)
target_link_libraries(plResBrowser shlwapi)
endif(WIN32)
if(USE_VLD)
target_link_libraries(plResBrowser ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plResBrowser_SOURCES})
source_group("Header Files" FILES ${plResBrowser_HEADERS})
source_group("Resource Files" FILES ${plResBrowser_RESOURCES})

23
cmake/FindVLD.cmake

@ -0,0 +1,23 @@
if(VLD_INCLUDE_DIR AND VLD_LIBRARY)
set(VLD_FIND_QUIETLY TRUE)
endif()
find_path(VLD_INCLUDE_DIR vld.h)
find_library(VLD_LIBRARY NAMES vld)
set(VLD_LIBRARIES ${VLD_LIBRARY})
if(VLD_INCLUDE_DIR AND VLD_LIBRARY)
set(VLD_FOUND TRUE)
endif()
if (VLD_FOUND)
if(NOT VLD_FIND_QUIETLY)
message(STATUS "Found Visual Leak Detector: ${VLD_INCLUDE_DIR}")
endif()
else()
if(VLD_FIND_REQUIRED)
message(FATAL_ERROR "Could not find Visual Leak Detector")
endif()
endif()
Loading…
Cancel
Save