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. 10
      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. 10
      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) add_definitions(-DSTREAM_LOGGER)
endif(PLASMA_TARGETS STREQUAL "Ethereal") 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) include(TestBigEndian)
test_big_endian(BIG_ENDIAN) test_big_endian(BIG_ENDIAN)
if(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}) target_link_libraries(plClient ${Bink_LIBRARIES})
endif() endif()
if(USE_VLD)
target_link_libraries(plClient ${VLD_LIBRARY})
endif()
if (WIN32) if (WIN32)
target_link_libraries(plClient Rpcrt4) target_link_libraries(plClient Rpcrt4)
target_link_libraries(plClient Version) 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) void StatusCallback(void *param)
{ {
#ifdef USE_VLD
VLDEnable();
#endif
HWND hwnd = (HWND)param; HWND hwnd = (HWND)param;
const char *statusUrl = GetServerStatusUrl(); 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}) add_library(plClientPatcher STATIC ${plClientPatcher_HEADERS} ${plClientPatcher_SOURCES})
target_link_libraries(plClientPatcher CoreLib plAudioCore plStatusLog) 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("Header Files" FILES ${plClientPatcher_HEADERS})
source_group("Source Files" FILES ${plClientPatcher_SOURCES}) 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) { static void WaitUruExitProc (void * param) {
#ifdef USE_VLD
VLDEnable();
#endif
plLauncherInfo *info = (plLauncherInfo *) param; plLauncherInfo *info = (plLauncherInfo *) param;
WaitForSingleObject(s_pi.hProcess, INFINITE); WaitForSingleObject(s_pi.hProcess, INFINITE);
DWORD exitcode; DWORD exitcode;
@ -539,6 +543,10 @@ static void ProcessManifestEntry (void * param, ENetError error) {
//============================================================================ //============================================================================
static void ProcessManifest (void * param) { static void ProcessManifest (void * param) {
#ifdef USE_VLD
VLDEnable();
#endif
wchar_t basePath[MAX_PATH]; wchar_t basePath[MAX_PATH];
char path[MAX_PATH]; char path[MAX_PATH];
AtomicAdd(&s_perf[kPerfThreadTaskCount], 1); AtomicAdd(&s_perf[kPerfThreadTaskCount], 1);
@ -885,6 +893,10 @@ void ShutdownAsyncCore () {
//============================================================================ //============================================================================
// param = URU_PreparationRequest // param = URU_PreparationRequest
void UruPrepProc (void * param) { void UruPrepProc (void * param) {
#ifdef USE_VLD
VLDEnable();
#endif
s_running = true; s_running = true;
plLauncherInfo *info = (plLauncherInfo *) param; plLauncherInfo *info = (plLauncherInfo *) param;
@ -952,6 +964,10 @@ void UruPrepProc (void * param) {
//============================================================================ //============================================================================
void PlayerStopProc (void * param) { void PlayerStopProc (void * param) {
#ifdef USE_VLD
VLDEnable();
#endif
s_running = false; s_running = false;
plLauncherInfo *info = (plLauncherInfo *) param; plLauncherInfo *info = (plLauncherInfo *) param;
//TerminateProcess(s_pi.hProcess, kExitCodeTerminated); //TerminateProcess(s_pi.hProcess, kExitCodeTerminated);
@ -960,6 +976,10 @@ void PlayerStopProc (void * param) {
//============================================================================ //============================================================================
void PlayerTerminateProc (void * param) { void PlayerTerminateProc (void * param) {
#ifdef USE_VLD
VLDEnable();
#endif
s_running = false; s_running = false;
plLauncherInfo *info = (plLauncherInfo *) param; plLauncherInfo *info = (plLauncherInfo *) param;
ShutdownAsyncCore(); ShutdownAsyncCore();
@ -968,6 +988,10 @@ void PlayerTerminateProc (void * param) {
//============================================================================ //============================================================================
void UruStartProc (void * param) { void UruStartProc (void * param) {
#ifdef USE_VLD
VLDEnable();
#endif
if(!s_running) if(!s_running)
return; 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 plFile)
target_link_libraries(plCrashHandler pnProduct) target_link_libraries(plCrashHandler pnProduct)
if(USE_VLD)
target_link_libraries(plCrashHandler ${VLD_LIBRARY})
endif()
# Platform specific libs # Platform specific libs
if(WIN32) if(WIN32)
target_link_libraries(plCrashHandler Dbghelp) target_link_libraries(plCrashHandler Dbghelp)
endif(WIN32) endif(WIN32)

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

@ -14,4 +14,8 @@ set(plFileEncrypt_SOURCES
add_executable(plFileEncrypt ${plFileEncrypt_SOURCES}) add_executable(plFileEncrypt ${plFileEncrypt_SOURCES})
target_link_libraries(plFileEncrypt CoreLib pnProduct plFile) target_link_libraries(plFileEncrypt CoreLib pnProduct plFile)
if(USE_VLD)
target_link_libraries(plFileEncrypt ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plFileEncrypt_SOURCES}) 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}) add_executable(plFileSecure ${plFileSecure_SOURCES})
target_link_libraries(plFileSecure CoreLib pnProduct plFile) target_link_libraries(plFileSecure CoreLib pnProduct plFile)
if(USE_VLD)
target_link_libraries(plFileSecure ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plFileSecure_SOURCES}) 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 CoreLib pnUtils pnProduct pnEncryption)
target_link_libraries(plMD5 ${OPENSSL_LIBRARIES}) target_link_libraries(plMD5 ${OPENSSL_LIBRARIES})
if(USE_VLD)
target_link_libraries(plMD5 ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plMD5_SOURCES}) 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}) add_executable(plPageInfo ${plPageInfo_SOURCES})
target_link_libraries(plPageInfo CoreLib pnProduct plResMgr plAudioCore) 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}) 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}) target_link_libraries(plPythonPack ${PYTHON_LIBRARY})
endif() endif()
if(USE_VLD)
target_link_libraries(plPythonPack ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plPythonPack_SOURCES}) source_group("Source Files" FILES ${plPythonPack_SOURCES})
source_group("Header Files" FILES ${plPythonPack_HEADERS}) 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 CoreLib pnUtils pnProduct pnEncryption)
target_link_libraries(plSHA ${OPENSSL_LIBRARIES}) target_link_libraries(plSHA ${OPENSSL_LIBRARIES})
if(USE_VLD)
target_link_libraries(plSHA ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plSHA_SOURCES}) 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 rpcrt4)
target_link_libraries(plUruLauncher comctl32) target_link_libraries(plUruLauncher comctl32)
if(USE_VLD)
target_link_libraries(plUruLauncher ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plUruLauncher_SOURCES}) source_group("Source Files" FILES ${plUruLauncher_SOURCES})
source_group("Header Files" FILES ${plUruLauncher_HEADERS}) source_group("Header Files" FILES ${plUruLauncher_HEADERS})
source_group("Resource Files" FILES ${plUruLauncher_RESOURCES}) 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 *) { static void WindowThreadProc(void *) {
#ifdef USE_VLD
VLDEnable();
#endif
InitCommonControls(); InitCommonControls();
s_event = CreateEvent( s_event = CreateEvent(
@ -476,6 +479,10 @@ static size_t CurlCallback(void *buffer, size_t size, size_t nmemb, void *)
//============================================================================ //============================================================================
static void StatusCallback(void *) static void StatusCallback(void *)
{ {
#ifdef USE_VLD
VLDEnable();
#endif
const char *serverUrl = GetServerStatusUrl(); const char *serverUrl = GetServerStatusUrl();
CURL * hCurl = curl_easy_init(); 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 # define NOMINMAX // Needed to prevent NxMath conflicts
# endif # endif
# include <Windows.h> # 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! // 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, ...) uint32_t hsStream::WriteFmt(const char * fmt, ...)
{ {
va_list av; va_list av;
@ -159,64 +148,81 @@ uint32_t hsStream::WriteSafeStringLong(const plString &string)
uint32_t hsStream::WriteSafeWStringLong(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(); uint32_t len = wbuff.GetSize();
WriteLE32(len); WriteLE32(len);
if (len > 0) if (len > 0)
{ {
const wchar_t *buffp = wbuff.GetData(); const uint16_t *buffp = wbuff.GetData();
for (uint32_t i=0; i<len; i++) 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; return 0;
} }
char *hsStream::ReadSafeStringLong() plString hsStream::ReadSafeStringLong_TEMP()
{ {
char *name = nil; plStringBuffer<char> name;
uint32_t numChars = ReadLE32(); uint32_t numChars = ReadLE32();
if (numChars > 0 && numChars <= GetSizeLeft()) if (numChars > 0 && numChars <= GetSizeLeft())
{ {
name = new char[numChars+1]; char *buff = name.CreateWritableBuffer(numChars);
Read(numChars, name); Read(numChars, buff);
name[numChars] = '\0'; buff[numChars] = 0;
// if the high bit is set, flip the bits. Otherwise it's a normal string, do nothing. // 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 (int i = 0; i < numChars; i++)
for (i = 0; i < numChars; i++) buff[i] = ~buff[i];
name[i] = ~name[i];
} }
} }
return name; 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(); uint32_t numChars = ReadLE32();
if (numChars > 0 && numChars <= (GetSizeLeft()/2)) // divide by two because each char is two bytes if (numChars > 0 && numChars <= (GetSizeLeft()/2)) // divide by two because each char is two bytes
{ {
retVal = new wchar_t[numChars+1]; uint16_t *buff = retVal.CreateWritableBuffer(numChars);
int i; for (int i=0; i<numChars; i++)
for (i=0; i<numChars; i++) buff[i] = ReadLE16();
retVal[i] = (wchar_t)ReadLE16(); ReadLE16(); // we wrote the null out, read it back in
retVal[numChars] = (wchar_t)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 (int i=0; i<numChars; i++)
for (i=0; i<numChars; i++) buff[i] = ~buff[i];
retVal[i] = ~retVal[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) 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) uint32_t hsStream::WriteSafeWString(const plString &string)
{ {
plStringBuffer<wchar_t> wbuff = string.ToWchar(); plStringBuffer<uint16_t> wbuff = string.ToUtf16();
uint32_t len = wbuff.GetSize(); 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() ); len).c_str() );
WriteLE16(len | 0xf000); WriteLE16(len | 0xf000);
if (len > 0) if (len > 0)
{ {
const wchar_t *buffp = wbuff.GetData(); const uint16_t *buffp = wbuff.GetData();
for (uint32_t i=0; i<len; i++) 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; return 0;
} }
char *hsStream::ReadSafeString() plString hsStream::ReadSafeString_TEMP()
{ {
char *name = nil; plStringBuffer<char> name;
uint16_t numChars = ReadLE16(); uint16_t numChars = ReadLE16();
#ifndef REMOVE_ME_SOON #ifndef REMOVE_ME_SOON
@ -276,62 +282,64 @@ char *hsStream::ReadSafeString()
hsAssert(numChars <= GetSizeLeft(), "Bad string"); hsAssert(numChars <= GetSizeLeft(), "Bad string");
if (numChars > 0 && numChars <= GetSizeLeft()) if (numChars > 0 && numChars <= GetSizeLeft())
{ {
name = new char[numChars+1]; char *buff = name.CreateWritableBuffer(numChars);
Read(numChars, name); Read(numChars, buff);
name[numChars] = '\0'; buff[numChars] = 0;
// if the high bit is set, flip the bits. Otherwise it's a normal string, do nothing. // 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; int i;
for (i = 0; i < numChars; i++) for (i = 0; i < numChars; i++)
name[i] = ~name[i]; buff[i] = ~buff[i];
} }
} }
return name; 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(); uint32_t numChars = ReadLE16();
numChars &= ~0xf000; numChars &= ~0xf000;
hsAssert(numChars <= GetSizeLeft()/2, "Bad string"); hsAssert(numChars <= GetSizeLeft()/2, "Bad string");
if (numChars > 0 && numChars <= (GetSizeLeft()/2)) // divide by two because each char is two bytes if (numChars > 0 && numChars <= (GetSizeLeft()/2)) // divide by two because each char is two bytes
{ {
retVal = new wchar_t[numChars+1]; uint16_t *buff = retVal.CreateWritableBuffer(numChars);
int i; for (int i=0; i<numChars; i++)
for (i=0; i<numChars; i++) buff[i] = ReadLE16();
retVal[i] = (wchar_t)ReadLE16(); ReadLE16(); // we wrote the null out, read it back in
retVal[numChars] = (wchar_t)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 (int i=0; i<numChars; i++)
for (i=0; i<numChars; i++) buff[i] = ~buff[i];
retVal[i] = ~retVal[i];
} }
} }
return retVal; return plString::FromUtf16(retVal);
}
plString hsStream::ReadSafeString_TEMP()
{
char *buffer = ReadSafeString();
plString result = plString::FromIso8859_1(buffer);
delete [] buffer;
return result;
} }
plString hsStream::ReadSafeWString_TEMP() wchar_t *hsStream::ReadSafeWString()
{ {
wchar_t *wbuffer = ReadSafeWString(); // Horribly inefficient (convert to UTF-8 and then back to UTF-16), which
plString result = plString::FromWchar(wbuffer); // is why this should go away completely after plString has taken over
delete [] wbuffer; // the world^H^H^H^H^HPlasma
return result; 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 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); bool IsTokenSeparator(char c);
public: public:
hsStream() : fBytesRead(0), fPosition(0) {} hsStream() : fBytesRead(0), fPosition(0) {}
virtual ~hsStream(); virtual ~hsStream() { }
virtual bool Open(const char *, const char * = "rb")=0; virtual bool Open(const char *, const char * = "rb")=0;
virtual bool Open(const wchar_t *, const wchar_t * = L"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 void CopyToMem(void* mem);
virtual bool IsCompressed() { return false; } virtual bool IsCompressed() { return false; }
uint32_t WriteString(const char cstring[]); uint32_t WriteString(const plString & string) { return Write(string.GetSize(), string.c_str()); }
uint32_t WriteString(const plString & string) { return WriteString(string.c_str()); }
uint32_t WriteFmt(const char * fmt, ...); uint32_t WriteFmt(const char * fmt, ...);
uint32_t WriteFmtV(const char * fmt, va_list av); uint32_t WriteFmtV(const char * fmt, va_list av);
@ -138,6 +137,8 @@ public:
char * ReadSafeString(); char * ReadSafeString();
wchar_t * ReadSafeWString(); wchar_t * ReadSafeWString();
plString ReadSafeStringLong_TEMP();
plString ReadSafeWStringLong_TEMP();
plString ReadSafeString_TEMP(); plString ReadSafeString_TEMP();
plString ReadSafeWString_TEMP(); plString ReadSafeWString_TEMP();

5
Sources/Plasma/CoreLib/hsThread_Win.cpp

@ -58,6 +58,11 @@ struct WinThreadParam
static unsigned int __stdcall gEntryPointBT(void* param) 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; WinThreadParam* wtp = (WinThreadParam*)param;
unsigned int result = wtp->fThread->Run(); unsigned int result = wtp->fThread->Run();
::ReleaseSemaphore(wtp->fQuitSemaH, 1, nil); // signal that we've quit ::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; 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 operator+(const plString &left, const plString &right)
{ {
plString cat; plString cat;
@ -711,6 +765,30 @@ plString operator+(const plString &left, const plString &right)
return cat; 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) plStringStream &plStringStream::append(const char *data, size_t length)
{ {
if (fLength + length > fBufSize) { 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 #define plString_Defined
#include "HeadSpin.h" #include "HeadSpin.h"
#include <stddef.h> #include <vector>
typedef unsigned int UniChar; typedef unsigned int UniChar;
@ -163,18 +163,15 @@ private:
public: public:
plString() { } plString() { }
#ifndef PLSTRING_POLLUTE_ASCII_CAST
plString(const char *cstr) { IConvertFromUtf8(cstr, kSizeAuto); } plString(const char *cstr) { IConvertFromUtf8(cstr, kSizeAuto); }
#endif
plString(const plString &copy) : fUtf8Buffer(copy.fUtf8Buffer) { } plString(const plString &copy) : fUtf8Buffer(copy.fUtf8Buffer) { }
plString(const plStringBuffer<char> &init) { operator=(init); } plString(const plStringBuffer<char> &init) { operator=(init); }
#ifndef PLSTRING_POLLUTE_ASCII_CAST
plString &operator=(const char *cstr) { IConvertFromUtf8(cstr, kSizeAuto); return *this; } plString &operator=(const char *cstr) { IConvertFromUtf8(cstr, kSizeAuto); return *this; }
#endif
plString &operator=(const plString &copy) { fUtf8Buffer = copy.fUtf8Buffer; return *this; } plString &operator=(const plString &copy) { fUtf8Buffer = copy.fUtf8Buffer; return *this; }
plString &operator=(const plStringBuffer<char> &init); plString &operator=(const plStringBuffer<char> &init);
plString &operator+=(const char *cstr) { return operator=(*this + cstr); }
plString &operator+=(const plString &str) { return operator=(*this + str); } plString &operator+=(const plString &str) { return operator=(*this + str); }
static inline plString FromUtf8(const char *utf8, size_t size = kSizeAuto) static inline plString FromUtf8(const char *utf8, size_t size = kSizeAuto)
@ -205,10 +202,8 @@ public:
return str; return str;
} }
#ifndef PLSTRING_POLLUTE_C_STR
const char *c_str(const char *substitute = "") const const char *c_str(const char *substitute = "") const
{ return IsEmpty() ? substitute : fUtf8Buffer.GetData(); } { return IsEmpty() ? substitute : fUtf8Buffer.GetData(); }
#endif
char CharAt(size_t position) const { return c_str()[position]; } char CharAt(size_t position) const { return c_str()[position]; }
@ -263,8 +258,15 @@ public:
: strnicmp(c_str(), str, count); : 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 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 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 plString &other) const { return Compare(other) != 0; }
int Find(char ch, CaseSensitivity sense = kCaseSensitive) const; int Find(char ch, CaseSensitivity sense = kCaseSensitive) const;
@ -287,6 +289,13 @@ public:
plString ToUpper() const; plString ToUpper() const;
plString ToLower() 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: public:
struct less struct less
{ {
@ -416,9 +425,13 @@ public:
private: private:
friend plString operator+(const plString &left, const plString &right); 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 plString &right);
plString operator+(const plString &left, const char *right);
plString operator+(const char *left, const plString &right);
class plStringStream class plStringStream

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

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

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

@ -356,7 +356,7 @@ PF_CONSOLE_CMD( Net, // groupName
link.GetAgeInfo()->SetAgeFilename( params[0] ); link.GetAgeInfo()->SetAgeFilename( params[0] );
//link.GetAgeInfo()->SetAgeInstanceName( params[0] ); //link.GetAgeInfo()->SetAgeInstanceName( params[0] );
//link.GetAgeInfo()->SetAgeUserDefinedName( params[0] ); //link.GetAgeInfo()->SetAgeUserDefinedName( params[0] );
plUUID guid(params[1]); plUUID guid( (const char *)params[1] );
link.GetAgeInfo()->SetAgeInstanceGuid( &guid ); link.GetAgeInfo()->SetAgeInstanceGuid( &guid );
link.SetLinkingRules( plNetCommon::LinkingRules::kBasicLink ); link.SetLinkingRules( plNetCommon::LinkingRules::kBasicLink );
plNetLinkingMgr::GetInstance()->LinkToAge( &link ); plNetLinkingMgr::GetInstance()->LinkToAge( &link );
@ -379,7 +379,7 @@ PF_CONSOLE_CMD( Net,
{ {
plAgeLinkStruct link; plAgeLinkStruct link;
link.GetAgeInfo()->SetAgeFilename( params[0] ); 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 ); link.SetLinkingRules( plNetCommon::LinkingRules::kOriginalBook );
plNetLinkingMgr::GetInstance()->LinkToAge( &link ); plNetLinkingMgr::GetInstance()->LinkToAge( &link );
PrintString("Linking to age with original book..."); 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++ ) for( i = 0; i < fSigLabels.GetCount(); i++ )
{ {
if( fSigLabels[ i ] != nil ) delete [] fSigLabels[ i ];
delete [] fSigLabels[ i ];
} }
Unregister(); Unregister();

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

@ -2300,16 +2300,14 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
plSDLNotificationMsg* sn = plSDLNotificationMsg::ConvertNoRef(msg); plSDLNotificationMsg* sn = plSDLNotificationMsg::ConvertNoRef(msg);
if (sn) if (sn)
{ {
const char* tag = sn->fHintString.c_str(); plString tag = sn->fHintString;
if (tag == nil)
tag = "";
// yes... then call it // yes... then call it
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod( PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_SDLNotify], fPyFunctionInstances[kfunc_SDLNotify],
(char*)fFunctionNames[kfunc_SDLNotify], (char*)fFunctionNames[kfunc_SDLNotify],
"ssls", sn->fVar->GetName(), sn->fSDLName.c_str(), "ssls", sn->fVar->GetName().c_str(), sn->fSDLName.c_str(),
sn->fPlayerID, tag); sn->fPlayerID, tag.c_str());
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #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); plVarDescriptor* var = desc->GetVar(i);
const char* name = var->GetName(); plString name = var->GetName();
int count = var->GetCount(); int count = var->GetCount();
fMap[name] = SDLObj(nil, count, false); 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); SDLMap::iterator it = fMap.find(key);
if (it == fMap.end()) if (it == fMap.end())
{ {
char errmsg[256]; plString errmsg = plString::Format("SDL key %s not found", key.c_str());
sprintf(errmsg,"SDL key %s not found",key); PyErr_SetString(PyExc_KeyError, errmsg.c_str());
PyErr_SetString(PyExc_KeyError, errmsg);
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
@ -119,7 +118,7 @@ PyObject* plPythonSDLModifier::GetItem(const char* key)
return val; return val;
} }
void plPythonSDLModifier::ISetItem(const char* key, PyObject* value) void plPythonSDLModifier::ISetItem(const plString& key, PyObject* value)
{ {
if (!value || !PyTuple_Check(value)) if (!value || !PyTuple_Check(value))
{ {
@ -149,19 +148,19 @@ void plPythonSDLModifier::ISetItem(const char* key, PyObject* value)
oldObj.obj = value; oldObj.obj = value;
} }
void plPythonSDLModifier::SendToClients(const char* key) void plPythonSDLModifier::SendToClients(const plString& key)
{ {
SDLMap::iterator it = fMap.find(key); SDLMap::iterator it = fMap.find(key);
if (it != fMap.end()) if (it != fMap.end())
it->second.sendToClients = true; 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); AddNotifyForVar(selfkey.getKey(), key, tolerance);
} }
void plPythonSDLModifier::SetItem(const char* key, PyObject* value) void plPythonSDLModifier::SetItem(const plString& key, PyObject* value)
{ {
ISetItem(key, value); ISetItem(key, value);
IDirtySynchState(key); IDirtySynchState(key);
@ -169,7 +168,7 @@ void plPythonSDLModifier::SetItem(const char* key, PyObject* value)
void plPythonSDLModifier::SetItemFromSDLVar(plSimpleStateVariable* var) void plPythonSDLModifier::SetItemFromSDLVar(plSimpleStateVariable* var)
{ {
const char* name = var->GetName(); plString name = var->GetName();
// Get the SDL value in Python format // Get the SDL value in Python format
PyObject* pyVar = ISDLVarToPython(var); 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); 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) if (!value)
{ {
@ -269,7 +268,7 @@ const char* plPythonSDLModifier::GetSDLName() const
return fOwner->fPythonFile; 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); SDLMap::iterator it = fMap.find(name);
if (it != fMap.end()) 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); SDLMap::iterator it = fMap.find(name);
if (it != fMap.end()) if (it != fMap.end())
@ -297,7 +296,7 @@ void plPythonSDLModifier::ISetCurrentStateFrom(const plStateDataRecord* srcState
{ {
plSimpleStateVariable* var = vars[i]; plSimpleStateVariable* var = vars[i];
const char* name = var->GetName(); plString name = var->GetName();
// Get the SDL value in Python format // Get the SDL value in Python format
PyObject* pyVar = ISDLVarToPython(var); PyObject* pyVar = ISDLVarToPython(var);
@ -334,11 +333,11 @@ void plPythonSDLModifier::IPutCurrentStateIn(plStateDataRecord* dstState)
SDLMap::iterator it = fMap.begin(); SDLMap::iterator it = fMap.begin();
for (; it != fMap.end(); it++) 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); SDLMap::iterator it = fMap.find(name);
if (it != fMap.end()) 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, bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int varIdx, int type, PyObject* pyVar,
const char* hintstring) const plString& hintstring)
{ {
switch (type) switch (type)
{ {
@ -370,7 +369,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{ {
int v = PyInt_AsLong(pyVar); int v = PyInt_AsLong(pyVar);
var->Set(v, varIdx); var->Set(v, varIdx);
if (hintstring) if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring); var->GetNotificationInfo().SetHintString(hintstring);
return true; return true;
} }
@ -378,7 +377,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{ {
int v = (int)PyLong_AsLong(pyVar); int v = (int)PyLong_AsLong(pyVar);
var->Set(v, varIdx); var->Set(v, varIdx);
if (hintstring) if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring); var->GetNotificationInfo().SetHintString(hintstring);
return true; return true;
} }
@ -387,7 +386,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{ {
int v = (int)PyFloat_AsDouble(pyVar); int v = (int)PyFloat_AsDouble(pyVar);
var->Set(v, varIdx); var->Set(v, varIdx);
if (hintstring) if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring); var->GetNotificationInfo().SetHintString(hintstring);
return true; return true;
} }
@ -398,7 +397,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{ {
float v = (float)PyFloat_AsDouble(pyVar); float v = (float)PyFloat_AsDouble(pyVar);
var->Set(v, varIdx); var->Set(v, varIdx);
if (hintstring) if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring); var->GetNotificationInfo().SetHintString(hintstring);
return true; return true;
} }
@ -407,7 +406,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{ {
float v = (float)PyInt_AsLong(pyVar); float v = (float)PyInt_AsLong(pyVar);
var->Set(v, varIdx); var->Set(v, varIdx);
if (hintstring) if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring); var->GetNotificationInfo().SetHintString(hintstring);
return true; return true;
} }
@ -418,7 +417,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{ {
char* v = PyString_AsString(pyVar); char* v = PyString_AsString(pyVar);
var->Set(v, varIdx); var->Set(v, varIdx);
if (hintstring) if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring); var->GetNotificationInfo().SetHintString(hintstring);
} }
break; break;
@ -428,7 +427,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
pyKey* key = PythonInterface::GetpyKeyFromPython(pyVar); pyKey* key = PythonInterface::GetpyKeyFromPython(pyVar);
if ( key ) if ( key )
var->Set(key->getKey(),varIdx); var->Set(key->getKey(),varIdx);
if (hintstring) if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring); var->GetNotificationInfo().SetHintString(hintstring);
} }
break; break;
@ -438,7 +437,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{ {
double v = PyFloat_AsDouble(pyVar); double v = PyFloat_AsDouble(pyVar);
var->Set(v, varIdx); var->Set(v, varIdx);
if (hintstring) if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring); var->GetNotificationInfo().SetHintString(hintstring);
return true; return true;
} }
@ -446,7 +445,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
{ {
double v = (double)PyInt_AsLong(pyVar); double v = (double)PyInt_AsLong(pyVar);
var->Set(v, varIdx); var->Set(v, varIdx);
if (hintstring) if (!hintstring.IsNull())
var->GetNotificationInfo().SetHintString(hintstring); var->GetNotificationInfo().SetHintString(hintstring);
return true; return true;
} }
@ -462,7 +461,7 @@ bool plPythonSDLModifier::IPythonVarIdxToSDL(plSimpleStateVariable* var, int var
return false; return false;
} }
void plPythonSDLModifier::IPythonVarToSDL(plStateDataRecord* state, const char* name) void plPythonSDLModifier::IPythonVarToSDL(plStateDataRecord* state, const plString& name)
{ {
plSimpleStateVariable* var = state->FindVar(name); plSimpleStateVariable* var = state->FindVar(name);
PyObject* pyVar = nil; PyObject* pyVar = nil;
@ -482,7 +481,7 @@ void plPythonSDLModifier::IPythonVarToSDL(plStateDataRecord* state, const char*
{ {
PyObject* pyVarItem = PyTuple_GetItem(pyVar, i); PyObject* pyVarItem = PyTuple_GetItem(pyVar, i);
if (pyVarItem) 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 sendToClients;
bool skipLocalCheck; bool skipLocalCheck;
bool sendImmediate; bool sendImmediate;
std::string hintString; plString hintString;
SDLObj() : obj(nil), size(-1), sendToClients(false) {} SDLObj() : obj(nil), size(-1), sendToClients(false) {}
SDLObj(PyObject* obj, int size, bool sendToClients) : obj(obj), size(size), sendToClients(sendToClients) {} 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; SDLMap fMap;
plPythonFileMod* fOwner; plPythonFileMod* fOwner;
@ -83,11 +83,11 @@ protected:
PyObject* ISDLVarToPython(plSimpleStateVariable* var); PyObject* ISDLVarToPython(plSimpleStateVariable* var);
PyObject* ISDLVarIdxToPython(plSimpleStateVariable* var, int type, int idx); PyObject* ISDLVarIdxToPython(plSimpleStateVariable* var, int type, int idx);
void IPythonVarToSDL(plStateDataRecord* state, const char* name); void IPythonVarToSDL(plStateDataRecord* state, const plString& name);
bool IPythonVarIdxToSDL(plSimpleStateVariable* var, int varIdx, int type, PyObject* pyVar, const char* hintstring); bool IPythonVarIdxToSDL(plSimpleStateVariable* var, int varIdx, int type, PyObject* pyVar, const plString& hintstring);
void ISetItem(const char* key, PyObject* value); void ISetItem(const plString& key, PyObject* value);
void IDirtySynchState(const char* name, bool sendImmediate = false); void IDirtySynchState(const plString& name, bool sendImmediate = false);
void IPutCurrentStateIn(plStateDataRecord* dstState); void IPutCurrentStateIn(plStateDataRecord* dstState);
void ISetCurrentStateFrom(const plStateDataRecord* srcState); void ISetCurrentStateFrom(const plStateDataRecord* srcState);
@ -106,15 +106,15 @@ public:
static const plPythonSDLModifier* FindAgeSDL(); static const plPythonSDLModifier* FindAgeSDL();
static plKey FindAgeSDLTarget(); static plKey FindAgeSDLTarget();
void SetDefault(const char* key, PyObject* value); void SetDefault(const plString& key, PyObject* value);
void SendToClients(const char* key); void SendToClients(const plString& key);
void SetNotify(pyKey& selfkey, const char* key, float tolerance); void SetNotify(pyKey& selfkey, const plString& key, float tolerance);
PyObject* GetItem(const char* key); PyObject* GetItem(const plString& key);
void SetItem(const char* key, PyObject* value); void SetItem(const plString& key, PyObject* value);
void SetItemIdx(const char* key, int idx, PyObject* value, bool sendImmediate = false); void SetItemIdx(const plString& key, int idx, PyObject* value, bool sendImmediate = false);
void SetFlags(const char* name, bool sendImmediate, bool skipOwnershipCheck); void SetFlags(const plString& name, bool sendImmediate, bool skipOwnershipCheck);
void SetTagString(const char* name, const char* tag); void SetTagString(const plString& name, const plString& tag);
}; };
// A wrapper for plPythonSDLModifier that Python uses // 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); bool PyString_CheckEx(PyObject* obj);
PyObject* PyUnicode_FromStringEx(const plString& str); 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 // 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; return fRec;
} }
PyObject * pySDLStateDataRecord::FindVar( const char * name ) const PyObject * pySDLStateDataRecord::FindVar( const plString & name ) const
{ {
if ( !fRec ) if ( !fRec )
PYTHON_RETURN_NONE; PYTHON_RETURN_NONE;
@ -79,17 +79,17 @@ PyObject * pySDLStateDataRecord::FindVar( const char * name ) const
return pySimpleStateVariable::New( var ); return pySimpleStateVariable::New( var );
} }
const char *pySDLStateDataRecord::GetName() const plString pySDLStateDataRecord::GetName() const
{ {
if (!fRec) if (!fRec)
return nil; return "";
const plStateDescriptor *stateDesc = fRec->GetDescriptor(); const plStateDescriptor *stateDesc = fRec->GetDescriptor();
return stateDesc->GetName(); 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) if (!fRec)
return retVal; return retVal;
const plStateDescriptor *stateDesc = fRec->GetDescriptor(); const plStateDescriptor *stateDesc = fRec->GetDescriptor();
@ -225,16 +225,15 @@ bool pySimpleStateVariable::GetBool( int idx ) const
return v; return v;
} }
const char * pySimpleStateVariable::GetString( int idx ) const plString pySimpleStateVariable::GetString( int idx ) const
{ {
fString = "";
if ( fVar ) if ( fVar )
{ {
char v[256]; char v[256];
if ( fVar->Get( v, idx ) ) if ( fVar->Get( v, idx ) )
fString = v; return plString::FromUtf8(v);
} }
return fString.c_str(); return "";
} }
plKey pySimpleStateVariable::GetKey( int idx ) const plKey pySimpleStateVariable::GetKey( int idx ) const
@ -253,18 +252,18 @@ int pySimpleStateVariable::GetType() const
return varDesc->GetType(); return varDesc->GetType();
} }
const char *pySimpleStateVariable::GetDisplayOptions() const plString pySimpleStateVariable::GetDisplayOptions() const
{ {
if (!fVar) if (!fVar)
return nil; return "";
plVarDescriptor *varDesc = fVar->GetVarDescriptor(); plVarDescriptor *varDesc = fVar->GetVarDescriptor();
return varDesc->GetDisplayOptions(); return varDesc->GetDisplayOptions();
} }
const char *pySimpleStateVariable::GetDefault() const plString pySimpleStateVariable::GetDefault() const
{ {
if (!fVar) if (!fVar)
return nil; return "";
plVarDescriptor *varDesc = fVar->GetVarDescriptor(); plVarDescriptor *varDesc = fVar->GetVarDescriptor();
return varDesc->GetDefault(); return varDesc->GetDefault();
} }
@ -272,7 +271,7 @@ const char *pySimpleStateVariable::GetDefault() const
bool pySimpleStateVariable::IsInternal() const bool pySimpleStateVariable::IsInternal() const
{ {
if (!fVar) if (!fVar)
return nil; return false;
plVarDescriptor *varDesc = fVar->GetVarDescriptor(); plVarDescriptor *varDesc = fVar->GetVarDescriptor();
return varDesc->IsInternal(); return varDesc->IsInternal();
} }
@ -280,7 +279,7 @@ bool pySimpleStateVariable::IsInternal() const
bool pySimpleStateVariable::IsAlwaysNew() const bool pySimpleStateVariable::IsAlwaysNew() const
{ {
if (!fVar) if (!fVar)
return nil; return false;
plVarDescriptor *varDesc = fVar->GetVarDescriptor(); plVarDescriptor *varDesc = fVar->GetVarDescriptor();
return varDesc->IsAlwaysNew(); return varDesc->IsAlwaysNew();
} }

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

@ -90,9 +90,9 @@ public:
plStateDataRecord * GetRec() const; plStateDataRecord * GetRec() const;
///////////////////// /////////////////////
PyObject * FindVar( const char * name ) const; // returns pySimpleStateVariable PyObject * FindVar( const plString & name ) const; // returns pySimpleStateVariable
const char *GetName() const; plString GetName() const;
std::vector<std::string> GetVarList(); std::vector<plString> GetVarList();
void SetFromDefaults(bool timeStampNow); void SetFromDefaults(bool timeStampNow);
}; };
@ -101,7 +101,6 @@ class pySimpleStateVariable
{ {
private: private:
plSimpleStateVariable * fVar; plSimpleStateVariable * fVar;
mutable std::string fString; // for GetString()
protected: protected:
pySimpleStateVariable(); pySimpleStateVariable();
@ -133,12 +132,12 @@ public:
float GetFloat( int idx=0 ) const; float GetFloat( int idx=0 ) const;
double GetDouble( int idx=0 ) const; double GetDouble( int idx=0 ) const;
bool GetBool( 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; plKey GetKey( int idx=0 ) const;
int GetType() const; int GetType() const;
const char *GetDisplayOptions() const; plString GetDisplayOptions() const;
const char *GetDefault() const; plString GetDefault() const;
bool IsAlwaysNew() const; bool IsAlwaysNew() const;
bool IsInternal() 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) 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) 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()); PyObject* varList = PyList_New(vars.size());
for (int i = 0; i < vars.size(); i++) for (int i = 0; i < vars.size(); i++)
PyList_SetItem(varList, i, PyString_FromString(vars[i].c_str())); 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(getInt, GetInt, PyInt_FromLong)
STATEVAR_GET(getFloat, GetFloat, PyFloat_FromDouble) STATEVAR_GET(getFloat, GetFloat, PyFloat_FromDouble)
STATEVAR_GET(getDouble, GetDouble, 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) STATEVAR_GET(getKey, GetKey, pyKey::New)
// getBool is special cause of the way python represents booleans // 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) 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) 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) PYTHON_METHOD_DEFINITION_NOARGS(ptSimpleStateVariable, isAlwaysNew)

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

@ -74,11 +74,11 @@ public:
plSpawnPointInfo & SpawnPoint() { return fInfo; } plSpawnPointInfo & SpawnPoint() { return fInfo; }
void SetTitle( const char * v ) { fInfo.SetTitle( v ); } 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 ); } 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 ); } void SetCameraStack(const char * v ) { fInfo.SetCameraStack( v ); }
const char * GetCameraStack() const { return fInfo.GetCameraStack(); } plString GetCameraStack() const { return fInfo.GetCameraStack(); }
static PyObject* GetDefaultSpawnPoint(); static PyObject* GetDefaultSpawnPoint();
}; };
@ -105,11 +105,11 @@ public:
plSpawnPointInfo & SpawnPoint() { return fInfo; } plSpawnPointInfo & SpawnPoint() { return fInfo; }
void SetTitle( const char * v ) { fInfo.SetTitle( v ); } 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 ); } 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 ); } 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 #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) 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) PYTHON_METHOD_DEFINITION(ptSpawnPointInfo, setTitle, args)
@ -95,7 +95,7 @@ PYTHON_METHOD_DEFINITION(ptSpawnPointInfo, setTitle, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfo, getName) 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) PYTHON_METHOD_DEFINITION(ptSpawnPointInfo, setName, args)
@ -112,7 +112,7 @@ PYTHON_METHOD_DEFINITION(ptSpawnPointInfo, setName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfo, getCameraStack) 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) PYTHON_METHOD_DEFINITION(ptSpawnPointInfo, setCameraStack, args)
@ -191,7 +191,7 @@ PYTHON_NO_INIT_DEFINITION(ptSpawnPointInfoRef)
PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfoRef, getTitle) 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) PYTHON_METHOD_DEFINITION(ptSpawnPointInfoRef, setTitle, args)
@ -208,7 +208,7 @@ PYTHON_METHOD_DEFINITION(ptSpawnPointInfoRef, setTitle, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfoRef, getName) 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) PYTHON_METHOD_DEFINITION(ptSpawnPointInfoRef, setName, args)
@ -225,7 +225,7 @@ PYTHON_METHOD_DEFINITION(ptSpawnPointInfoRef, setName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptSpawnPointInfoRef, getCameraStack) 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) 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()); access.RemoveSpawnPoint(point.GetName());
} }
void pyVaultAgeLinkNode::RemoveSpawnPointByName( const char * spawnPtName ) void pyVaultAgeLinkNode::RemoveSpawnPointByName( const plString & spawnPtName )
{ {
if (!fNode) if (!fNode)
return; return;
@ -175,7 +175,7 @@ void pyVaultAgeLinkNode::RemoveSpawnPointByName( const char * spawnPtName )
access.RemoveSpawnPoint(spawnPtName); access.RemoveSpawnPoint(spawnPtName);
} }
bool pyVaultAgeLinkNode::HasSpawnPoint( const char * spawnPtName ) const bool pyVaultAgeLinkNode::HasSpawnPoint( const plString & spawnPtName ) const
{ {
if (!fNode) if (!fNode)
return false; 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 AddSpawnPointRef( pySpawnPointInfoRef & point ); // will only add if not there already.
void RemoveSpawnPoint( pySpawnPointInfo & point ); void RemoveSpawnPoint( pySpawnPointInfo & point );
void RemoveSpawnPointRef( pySpawnPointInfoRef & point ); void RemoveSpawnPointRef( pySpawnPointInfoRef & point );
void RemoveSpawnPointByName( const char * spawnPtName ); void RemoveSpawnPointByName( const plString & spawnPtName );
bool HasSpawnPoint( const char * spawnPtName ) const; bool HasSpawnPoint( const plString & spawnPtName ) const;
PyObject * GetSpawnPoints() const; // returns list of pySpawnPointInfo PyObject * GetSpawnPoints() const; // returns list of pySpawnPointInfo
PyObject * AsAgeLinkStruct() const; // returns pyAgeLinkStruct 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) { static unsigned CALLBACK CreateThreadProc (LPVOID param) {
#ifdef USE_VLD
VLDEnable();
#endif
PerfAddCounter(kAsyncPerfThreadsTotal, 1); PerfAddCounter(kAsyncPerfThreadsTotal, 1);
PerfAddCounter(kAsyncPerfThreadsCurr, 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 "plSDLModifierMsg.h"
#include "plSDL/plSDL.h" // ugh. #include "plSDL/plSDL.h" // ugh.
plSDLModifierMsg::plSDLModifierMsg(const char* sdlName, Action a) : plSDLModifierMsg::plSDLModifierMsg(const plString& sdlName, Action a) :
fSDLName(nil), fSDLName(sdlName),
fAction(a), fAction(a),
fState(nil), fState(nil),
fPlayerID(0), fPlayerID(0),
fManageStateMem(false), fManageStateMem(false),
fFlags(0) fFlags(0)
{ {
SetSDLName(sdlName);
SetBCastFlag(plMessage::kPropagateToModifiers); SetBCastFlag(plMessage::kPropagateToModifiers);
} }
@ -58,5 +57,4 @@ plSDLModifierMsg::~plSDLModifierMsg()
{ {
if ( fManageStateMem ) if ( fManageStateMem )
delete fState; delete fState;
delete [] fSDLName;
} }

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

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

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

@ -50,9 +50,9 @@ class plSDLNotificationMsg : public plMessage
public: public:
float fDelta; // change threshold float fDelta; // change threshold
const plSimpleStateVariable* fVar; 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 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() : fDelta(0), fVar(nil), fPlayerID(0) {}
~plSDLNotificationMsg() { } ~plSDLNotificationMsg() { }

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

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

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

@ -231,7 +231,7 @@ void plClothingSDLModifier::HandleSingleSDR(const plStateDataRecord *sdr, plClot
int i; int i;
uint8_t tint[3]; uint8_t tint[3];
float tintScalar[3]; float tintScalar[3];
if (!strcmp(sdr->GetDescriptor()->GetName(), kStrClothingDescName)) if (sdr->GetDescriptor()->GetName() == kStrClothingDescName)
{ {
// get item from clothesItem // get item from clothesItem
plSimpleStateVariable* itemVar = sdr->FindVar(kStrItem); 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 // skin tints
plSimpleStateVariable* skinVar = sdr->FindVar(kStrSkinTint); 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(); plSceneObject* sobj=GetTarget();
hsAssert(sobj, "plMorphSequenceSDLMod, nil target"); 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."); hsAssert(false, "Wrong type of state data record passed into plMorphSequenceSDLMod.");
return; 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) bool plSDLModifier::MsgReceive(plMessage* msg)
{ {
plSDLModifierMsg* sdlMsg = plSDLModifierMsg::ConvertNoRef(msg); plSDLModifierMsg* sdlMsg = plSDLModifierMsg::ConvertNoRef(msg);
if (sdlMsg && !stricmp(sdlMsg->GetSDLName(),GetSDLName())) if (sdlMsg && !sdlMsg->GetSDLName().CompareI(GetSDLName()))
{ {
uint32_t sendFlags = IApplyModFlags(sdlMsg->GetFlags()); uint32_t sendFlags = IApplyModFlags(sdlMsg->GetFlags());
@ -229,7 +229,7 @@ void plSDLModifier::ReceiveState(const plStateDataRecord* srcState)
plNetObjectDebugger::GetInstance()->SetDebugging(false); 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 // create a SDL notifier object
plStateChangeNotifier notifier(tolerance, key); plStateChangeNotifier notifier(tolerance, key);

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

@ -80,7 +80,7 @@ public:
plStateDataRecord* GetStateCache() const { return fStateCache; } plStateDataRecord* GetStateCache() const { return fStateCache; }
virtual void AddTarget(plSceneObject* so); 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 #endif // plSDLModifier_inc

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

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

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

@ -270,8 +270,8 @@ void plNCAgeJoiner::ExecNextOp () {
avatarName = "Male"; avatarName = "Male";
else else
avatarName = NetCommGetPlayer()->avatarDatasetName; avatarName = NetCommGetPlayer()->avatarDatasetName;
const char * linkInName = plNetLinkingMgr::GetInstance()->GetAgeLink()->SpawnPoint().GetName(); plString linkInName = plNetLinkingMgr::GetInstance()->GetAgeLink()->SpawnPoint().GetName();
am->LoadPlayer( avatarName, nil, linkInName ); am->LoadPlayer( avatarName, nil, linkInName.c_str() );
} }
else { else {
LogMsg(kLogPerf, L"AgeJoiner: Next:kPropagatePlayer"); 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. // discard the state if object not found in dataset.
hsLogEntry( DebugMsg( "Failed to find object %s in dataset. Discarding pending state '%s'", hsLogEntry( DebugMsg( "Failed to find object %s in dataset. Discarding pending state '%s'",
tmpUoid.StringIze().c_str(), tmpUoid.StringIze().c_str(),
pl->fSDRec->GetDescriptor()->GetName() ) ); pl->fSDRec->GetDescriptor()->GetName().c_str() ) );
delete pl; delete pl;
it = fPendingLoads.erase(it); it = fPendingLoads.erase(it);
continue; continue;
@ -645,9 +645,10 @@ void plNetClientMgr::ICheckPendingStateLoad(double secs)
#ifdef HS_DEBUGGING #ifdef HS_DEBUGGING
if (plNetObjectDebugger::GetInstance()->IsDebugObject(so)) if (plNetObjectDebugger::GetInstance()->IsDebugObject(so))
{ {
hsLogEntry( DebugMsg( "Delivering SDL state %s:%s", pl->fKey->GetName().c_str(), pl->fSDRec->GetDescriptor()->GetName() ) ); hsLogEntry( DebugMsg( "Delivering SDL state %s:%s", pl->fKey->GetName().c_str(),
// hsLogEntry(plNetObjectDebugger::GetInstance()->LogMsg(xtl::format("Dispatching SDL state, type %s to object:%s, locallyOwned=%d, st=%.3f rt=%.3f", pl->fSDRec->GetDescriptor()->GetName().c_str() ) );
// pl->fSDRec->GetDescriptor()->GetName(), pl->fKey->GetName(), // 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())); // so->IsLocallyOwned()==plSynchedObject::kYes, secs, hsTimer::GetSeconds()).c_str()));
// hsLogEntry( pl->fSDRec->DumpToObjectDebugger( "Delivering SDL state", false, 0 ) ); // 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 // 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...", 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() : "?", pl->fUoid.StringIze().c_str(), pl->fKey ? pl->fKey->GetUoid().StringIze().c_str() : "?",
( rawSecs - pl->fQueuedTime ) * pl->fQueueTimeResets); ( 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", 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() : "?", pl->fUoid.StringIze().c_str(), pl->fKey ? pl->fKey->GetUoid().StringIze().c_str() : "?",
( rawSecs - pl->fQueuedTime ) * pl->fQueueTimeResets, ( rawSecs - pl->fQueuedTime ) * pl->fQueueTimeResets,
so ? "(not loaded)" : "(not final)" ); 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 // extract stateDataRecord from msg
hsReadOnlyStream stream(m->StreamInfo()->GetStreamLen(), m->StreamInfo()->GetStreamBuf()); hsReadOnlyStream stream(m->StreamInfo()->GetStreamLen(), m->StreamInfo()->GetStreamBuf());
char* descName = nil; plString descName;
int ver; int ver;
plStateDataRecord::ReadStreamHeader(&stream, &descName, &ver); plStateDataRecord::ReadStreamHeader(&stream, &descName, &ver);
plStateDescriptor* des = plSDLMgr::GetInstance()->FindDescriptor(descName, ver); plStateDescriptor* des = plSDLMgr::GetInstance()->FindDescriptor(descName, ver);
if (stricmp(descName, kSDLAvatarPhysical) == 0) if (descName.CompareI(kSDLAvatarPhysical) == 0)
rwFlags |= plSDL::kKeepDirty; rwFlags |= plSDL::kKeepDirty;
// //
@ -287,13 +287,11 @@ MSG_HANDLER_DEFN(plNetClientMsgHandler,plNetMsgSDLState)
// queue up state // queue up state
nc->fPendingLoads.push_back(pl); nc->fPendingLoads.push_back(pl);
hsLogEntry( nc->DebugMsg( "Added pending SDL delivery for %s:%s", 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 else
delete sdRec; delete sdRec;
delete [] descName; // We've only used descName for a lookup (via SDR, and some error strings. Must delete now.
return hsOK; return hsOK;
} }

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

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

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

@ -598,11 +598,10 @@ static void INetCliAuthAgeRequestCallback (
s_age.ageVaultId = ageVaultId; s_age.ageVaultId = ageVaultId;
wchar_t ageInstIdStr[64]; wchar_t ageInstIdStr[64];
plString gameAddrStr = gameAddr.GetHostString();
LogMsg( LogMsg(
kLogPerf, kLogPerf,
L"Connecting to game server %s, ageInstId %s", L"Connecting to game server %s, ageInstId %s",
gameAddrStr.c_str(), gameAddr.GetHostString().ToWchar().GetData(),
GuidToString(ageInstId, ageInstIdStr, arrsize(ageInstIdStr)) GuidToString(ageInstId, ageInstIdStr, arrsize(ageInstIdStr))
); );
NetCliGameDisconnect(); 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)) else if (plNetMsgSDLState* sdlMsg = plNetMsgSDLState::ConvertNoRef(msg))
{ {
hsReadOnlyStream stream(sdlMsg->StreamInfo()->GetStreamLen(), sdlMsg->StreamInfo()->GetStreamBuf()); hsReadOnlyStream stream(sdlMsg->StreamInfo()->GetStreamLen(), sdlMsg->StreamInfo()->GetStreamBuf());
char* descName=nil; plString descName;
int ver; int ver;
if (plStateDataRecord::ReadStreamHeader(&stream, &descName, &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; int i;
@ -143,17 +143,16 @@ void plNetClientStatsRecorder::ILogMsg(plNetMessage* msg, const char* preText)
sdRec.GetDirtyVars(&vars); sdRec.GetDirtyVars(&vars);
for (i = 0; i < vars.size(); i++) 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; plStateDataRecord::SDVarsList sdVars;
sdRec.GetDirtySDVars(&sdVars); sdRec.GetDirtySDVars(&sdVars);
for (i = 0; i < sdVars.size(); i++) 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 else
fLog->AddLineF("%s%s", preText, msg->ClassName()); 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)) else if (plNetMsgSDLState* sdlMsg = plNetMsgSDLState::ConvertNoRef(msg))
{ {
hsReadOnlyStream stream(sdlMsg->StreamInfo()->GetStreamLen(), sdlMsg->StreamInfo()->GetStreamBuf()); hsReadOnlyStream stream(sdlMsg->StreamInfo()->GetStreamLen(), sdlMsg->StreamInfo()->GetStreamBuf());
char* descName=nil; plString descName;
int ver; int ver;
if (plStateDataRecord::ReadStreamHeader(&stream, &descName, &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; int i;
@ -348,17 +348,16 @@ void plNetClientStreamRecorder::ILogMsg(plNetMessage* msg, const char* preText)
sdRec.GetDirtyVars(&vars); sdRec.GetDirtyVars(&vars);
for (i = 0; i < vars.size(); i++) 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; plStateDataRecord::SDVarsList sdVars;
sdRec.GetDirtySDVars(&sdVars); sdRec.GetDirtySDVars(&sdVars);
for (i = 0; i < sdVars.size(); i++) 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 else
fLog->AddLineF("%s%s", preText, msg->ClassName()); 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"); s->LogReadLE( &fLinkingRules ,"LinkingRules");
if ( IsFlagSet( kHasSpawnPt_DEAD ) ) if ( IsFlagSet( kHasSpawnPt_DEAD ) )
{ {
std::string str; plString str;
s->LogSubStreamPushDesc("SpawnPt_DEAD"); s->LogSubStreamPushDesc("SpawnPt_DEAD");
plMsgStdStringHelper::Peek(str,s); plMsgStdStringHelper::Peek(str,s);
fSpawnPoint.SetName( str.c_str() ); fSpawnPoint.SetName( str );
if ( strcmp( fSpawnPoint.GetName(), kDefaultSpawnPtName )==0 ) if ( fSpawnPoint.GetName() == kDefaultSpawnPtName )
fSpawnPoint.SetTitle( kDefaultSpawnPtTitle ); fSpawnPoint.SetTitle( kDefaultSpawnPtTitle );
else else
fSpawnPoint.SetTitle( str.c_str() ); fSpawnPoint.SetTitle( str );
ClearFlag( kHasSpawnPt_DEAD ); ClearFlag( kHasSpawnPt_DEAD );
SetFlag( kHasSpawnPt ); SetFlag( kHasSpawnPt );
} }
@ -520,7 +520,7 @@ plString plAgeLinkStruct::AsString() const
{ {
ss << spacer ss << spacer
<< "Spwn:" << "Spwn:"
<< fSpawnPoint.AsStdString().c_str(); << fSpawnPoint.AsString();
spacer = kComma; spacer = kComma;
} }
if (HasAmCCR()) if (HasAmCCR())

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

@ -120,10 +120,10 @@ void plSpawnPointInfo::Reset()
(*this)=kDefaultSpawnPoint; (*this)=kDefaultSpawnPoint;
} }
std::string plSpawnPointInfo::AsStdString() const plString plSpawnPointInfo::AsString() const
{ {
return xtl::format( "t:%s,n:%s,c:%s", return plString::Format( "t:%s,n:%s,c:%s",
fTitle.size()?fTitle.c_str():"(nil)", fTitle.c_str("(nil)"),
fSpawnPt.size()?fSpawnPt.c_str():"(nil)", fSpawnPt.c_str("(nil)"),
fCameraStack.size()?fCameraStack.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 #define plSpawnPointInfo_h_inc
#include "hsStlUtils.h" #include "hsStlUtils.h"
#include "plString.h"
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
@ -55,24 +56,24 @@ class hsStream;
struct plSpawnPointInfo struct plSpawnPointInfo
{ {
std::string fTitle; // friendly title for GUIs plString fTitle; // friendly title for GUIs
std::string fSpawnPt; // name of spawn point in dataset plString fSpawnPt; // name of spawn point in dataset
std::string fCameraStack; plString fCameraStack;
plSpawnPointInfo(){} plSpawnPointInfo(){}
plSpawnPointInfo( const plSpawnPointInfo & other ) { (*this)=other; } plSpawnPointInfo( const plSpawnPointInfo & other ) { (*this)=other; }
plSpawnPointInfo( const char * title, const char * spawnPt ) plSpawnPointInfo( const plString & title, const plString & spawnPt )
: fTitle( title ), fSpawnPt( spawnPt ) {} : fTitle( title ), fSpawnPt( spawnPt ) {}
const char * GetTitle() const { return fTitle.c_str(); } plString GetTitle() const { return fTitle; }
void SetTitle( const char * v ) { fTitle=v; } void SetTitle( const plString & v ) { fTitle=v; }
const char * GetName() const { return fSpawnPt.c_str(); } plString GetName() const { return fSpawnPt; }
void SetName( const char * v ) { fSpawnPt = v; } void SetName( const plString & v ) { fSpawnPt = v; }
const char * GetCameraStack() const { return fCameraStack.c_str(); } plString GetCameraStack() const { return fCameraStack; }
void SetCameraStack( const char * v ) { fCameraStack=v; } void SetCameraStack( const plString & v ) { fCameraStack=v; }
void Reset(); void Reset();
void Read( hsStream * s ); void Read( hsStream * s );
void ReadOld( hsStream * s ); void ReadOld( hsStream * s );
void Write( hsStream * s ) const; void Write( hsStream * s ) const;
std::string AsStdString() const; plString AsString() const;
}; };
typedef std::vector<plSpawnPointInfo> plSpawnPointVec; 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->token = msg.token;
s_active->addr.SetHost(msg.srvAddr); s_active->addr.SetHost(msg.srvAddr);
plString logmsg = "SrvAuth addr: "; LogMsg(kLogPerf, "SrvAuth addr: %s", s_active->addr.GetHostString().c_str());
logmsg += s_active->addr.GetHostString();
LogMsg(kLogPerf, L"SrvAuth addr: %s", logmsg.c_str());
} }
} }
s_critsect.Leave(); s_critsect.Leave();

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

@ -107,10 +107,10 @@ namespace plSDL
class plStateVarNotificationInfo class plStateVarNotificationInfo
{ {
private: private:
std::string fHintString; plString fHintString;
public: public:
void SetHintString(const char* c) { fHintString=c; } void SetHintString(const plString& c) { fHintString=c; }
const char* GetHintString() const { return fHintString.c_str(); } plString GetHintString() const { return fHintString; }
void Read(hsStream* s, uint32_t readOptions); void Read(hsStream* s, uint32_t readOptions);
void Write(hsStream* s, uint32_t writeOptions) const; void Write(hsStream* s, uint32_t writeOptions) const;
@ -137,8 +137,8 @@ public:
plStateVariable() : fFlags(0) {} plStateVariable() : fFlags(0) {}
virtual ~plStateVariable() {} virtual ~plStateVariable() {}
const char* GetName() const { return GetVarDescriptor()->GetName(); } plString GetName() const { return GetVarDescriptor()->GetName(); }
bool IsNamed(const char* n) const { return (n && !stricmp(GetName(), n)); } bool IsNamed(const char* n) const { return (n && !GetName().CompareI(n)); }
virtual int GetCount() const = 0; virtual int GetCount() const = 0;
// conversion ops // conversion ops
@ -193,7 +193,7 @@ public:
int RemoveNotificationKey(plKey k); // returns number of keys left after removal int RemoveNotificationKey(plKey k); // returns number of keys left after removal
int RemoveNotificationKeys(KeyList keys); // 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 GetValue(float* i) const;
bool SetValue(float i); bool SetValue(float i);
@ -266,10 +266,10 @@ public:
void TimeStamp( const plUnifiedTime & ut=plUnifiedTime::GetCurrentTime() ); void TimeStamp( const plUnifiedTime & ut=plUnifiedTime::GetCurrentTime() );
void CopyFrom(plVarDescriptor* v); void CopyFrom(plVarDescriptor* v);
void CopyData(const plSimpleStateVariable* other, uint32_t writeOptions=0); 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 bool SetFromString(const plString& value, int idx, bool timeStampNow); // set value from string, type. return false on err
char* GetAsString(int idx) const; plString GetAsString(int idx) const;
bool ConvertTo(plSimpleVarDescriptor* toVar, bool force=false); // return false on err 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(); void Reset();
// setters // setters
@ -293,7 +293,7 @@ public:
// getters // getters
bool Get(int* value, int idx=0) const; bool Get(int* value, int idx=0) const;
bool Get(short* 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(float* value, int idx=0) const; // returns float or floatVector
bool Get(double* value, int idx=0) const; // returns double or doubleVector bool Get(double* value, int idx=0) const; // returns double or doubleVector
bool Get(bool* value, int idx=0) const; bool Get(bool* value, int idx=0) const;
@ -315,7 +315,7 @@ public:
void AddStateChangeNotification(plStateChangeNotifier& n); void AddStateChangeNotification(plStateChangeNotifier& n);
void RemoveStateChangeNotification(plKey notificationObj); // remove all with this key void RemoveStateChangeNotification(plKey notificationObj); // remove all with this key
void RemoveStateChangeNotification(plStateChangeNotifier n); // remove ones which match 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 DumpToObjectDebugger(bool dirtyOnly, int level) const;
void DumpToStream(hsStream* stream, bool dirtyOnly, int level) const; void DumpToStream(hsStream* stream, bool dirtyOnly, int level) const;
@ -407,18 +407,18 @@ protected:
plUoid fAssocObject; // optional plUoid fAssocObject; // optional
VarsList fVarsList; // list of variables VarsList fVarsList; // list of variables
VarsList fSDVarsList; // list of nested data records VarsList fSDVarsList; // list of nested data records
uint32_t fFlags; uint32_t fFlags;
static const uint8_t kIOVersion; // I/O Version static const uint8_t kIOVersion; // I/O Version
void IDeleteVarsList(VarsList& vars); 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 IInitDescriptor(const plStateDescriptor* sd);
void IReadHeader(hsStream* s); void IReadHeader(hsStream* s);
void IWriteHeader(hsStream* s) const; void IWriteHeader(hsStream* s) const;
bool IConvertVar(plSimpleStateVariable* fromVar, plSimpleStateVariable* toVar, bool force); 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 IGetNumUsedVars(const VarsList& vars) const;
int IGetUsedVars(const VarsList& varsOut, VarsList *varsIn) const; // build a list of vars that have data int IGetUsedVars(const VarsList& varsOut, VarsList *varsIn) const; // build a list of vars that have data
bool IHasUsedVars(const VarsList& vars) const; bool IHasUsedVars(const VarsList& vars) const;
@ -430,7 +430,7 @@ public:
CLASSNAME_REGISTER( plStateDataRecord ); CLASSNAME_REGISTER( plStateDataRecord );
GETINTERFACE_ANY( plStateDataRecord, plCreatable); GETINTERFACE_ANY( plStateDataRecord, plCreatable);
plStateDataRecord(const char* sdName, int version=plSDL::kLatestVersion); plStateDataRecord(const plString& sdName, int version=plSDL::kLatestVersion);
plStateDataRecord(plStateDescriptor* sd); plStateDataRecord(plStateDescriptor* sd);
plStateDataRecord(const plStateDataRecord &other, uint32_t writeOptions=0 ):fFlags(0) { CopyFrom(other, writeOptions); } plStateDataRecord(const plStateDataRecord &other, uint32_t writeOptions=0 ):fFlags(0) { CopyFrom(other, writeOptions); }
plStateDataRecord():fFlags(0) {} plStateDataRecord():fFlags(0) {}
@ -442,8 +442,8 @@ public:
uint32_t GetFlags() const { return fFlags; } uint32_t GetFlags() const { return fFlags; }
void SetFlags(uint32_t f) { fFlags =f; } void SetFlags(uint32_t f) { fFlags =f; }
plSimpleStateVariable* FindVar(const char* name) const { return (plSimpleStateVariable*)IFindVar(fVarsList, name); } plSimpleStateVariable* FindVar(const plString& name) const { return (plSimpleStateVariable*)IFindVar(fVarsList, name); }
plSDStateVariable* FindSDVar(const char* name) const { return (plSDStateVariable*)IFindVar(fSDVarsList, name); } plSDStateVariable* FindSDVar(const plString& name) const { return (plSDStateVariable*)IFindVar(fSDVarsList, name); }
plStateDataRecord& operator=(const plStateDataRecord& other) { CopyFrom(other); return *this; } plStateDataRecord& operator=(const plStateDataRecord& other) { CopyFrom(other); return *this; }
void CopyFrom(const plStateDataRecord& other, uint32_t writeOptions=0); void CopyFrom(const plStateDataRecord& other, uint32_t writeOptions=0);
@ -479,7 +479,7 @@ public:
bool HasDirtySDVars() const { return IHasDirtyVars(fSDVarsList); } bool HasDirtySDVars() const { return IHasDirtyVars(fSDVarsList); }
const plStateDescriptor* GetDescriptor() const { return fDescriptor; } 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 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); bool Read(hsStream* s, float timeConvert, uint32_t readOptions=0);
void Write(hsStream* s, float timeConvert, uint32_t writeOptions=0) const; 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; void WriteStreamHeader(hsStream* s, plUoid* objUoid=nil) const;
}; };
@ -543,7 +543,7 @@ public:
~plSDLMgr(); ~plSDLMgr();
static plSDLMgr* GetInstance(); 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;} 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 "HeadSpin.h"
#include "hsStlUtils.h" #include "hsStlUtils.h"
#include "plString.h"
// //
// Describes a variable in a state descriptor. // 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 kVariableLength = 0x4 // Var is defined as int foo[], so it's length is variable, starting at 0
}; };
protected: protected:
static const uint8_t kVersion; // for Read/Write format static const uint8_t kVersion; // for Read/Write format
char* fDefault; // set by .sdl plString fDefault; // set by .sdl
char* fName; // set by .sdl plString fName; // set by .sdl
int fCount; // set by .sdl int fCount; // set by .sdl
Type fType; // set by .sdl Type fType; // set by .sdl
char* fTypeString; // string version of fType plString fTypeString; // string version of fType
uint32_t fFlags; uint32_t fFlags;
std::string fDisplayOptions; // set by .sdl plString fDisplayOptions; // set by .sdl
public: public:
plVarDescriptor(); plVarDescriptor() : fCount(1), fType(kNone), fFlags(0) { }
virtual ~plVarDescriptor(); virtual ~plVarDescriptor() { }
virtual void CopyFrom(const plVarDescriptor* v); virtual void CopyFrom(const plVarDescriptor* v);
@ -119,26 +120,26 @@ public:
virtual const plSDVarDescriptor* GetAsSDVarDescriptor() const = 0; virtual const plSDVarDescriptor* GetAsSDVarDescriptor() const = 0;
// getters // getters
const char* GetDefault() const { return fDefault; } plString GetDefault() const { return fDefault; }
const char* GetName() const { return fName; } plString GetName() const { return fName; }
Type GetType() const { return fType; } Type GetType() const { return fType; }
const char* GetTypeString() const { return fTypeString; } plString GetTypeString() const { return fTypeString; }
int GetCount() const { return fCount; } int GetCount() const { return fCount; }
bool IsInternal() const { return (fFlags & kInternal) != 0; } bool IsInternal() const { return (fFlags & kInternal) != 0; }
bool IsAlwaysNew() const { return (fFlags & kAlwaysNew) != 0; } bool IsAlwaysNew() const { return (fFlags & kAlwaysNew) != 0; }
bool IsVariableLength() const { return (fFlags & kVariableLength) != 0; } bool IsVariableLength() const { return (fFlags & kVariableLength) != 0; }
const char* GetDisplayOptions() const { return fDisplayOptions.c_str(); } plString GetDisplayOptions() const { return fDisplayOptions; }
// setters // setters
void SetDefault(const char* n) { delete [] fDefault; fDefault= hsStrcpy(n); } void SetDefault(const plString& n) { fDefault = n; }
void SetName(const char* n) { delete [] fName; fName = hsStrcpy(n); } void SetName(const plString& n) { fName = n; }
void SetCount(int c) { fCount=c; } void SetCount(int c) { fCount=c; }
virtual bool SetType(const char* type); virtual bool SetType(const plString& type);
void SetType(Type t) { fType=t; } void SetType(Type t) { fType=t; }
void SetInternal(bool d) { if (d) fFlags |= kInternal; else fFlags &= ~kInternal; } void SetInternal(bool d) { if (d) fFlags |= kInternal; else fFlags &= ~kInternal; }
void SetAlwaysNew(bool d) { if (d) fFlags |= kAlwaysNew; else fFlags &= ~kAlwaysNew; } void SetAlwaysNew(bool d) { if (d) fFlags |= kAlwaysNew; else fFlags &= ~kAlwaysNew; }
void SetVariableLength(bool d) { if (d) fFlags |= kVariableLength; else fFlags &= ~kVariableLength; } 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 // IO
virtual bool Read(hsStream* s); virtual bool Read(hsStream* s);
@ -173,7 +174,7 @@ public:
int GetAtomicCount() const { return fAtomicCount; } int GetAtomicCount() const { return fAtomicCount; }
// setters // setters
bool SetType(const char* type); bool SetType(const plString& type);
void SetType(Type t) { plVarDescriptor::SetType(t); } // for lame compiler void SetType(Type t) { plVarDescriptor::SetType(t); } // for lame compiler
void SetAtomicType(Type t) { fAtomicType=t; } void SetAtomicType(Type t) { fAtomicType=t; }
@ -225,16 +226,16 @@ private:
typedef std::vector<plVarDescriptor*> VarsList; typedef std::vector<plVarDescriptor*> VarsList;
VarsList fVarsList; VarsList fVarsList;
int fVersion; int fVersion;
char* fName; plString fName;
std::string fFilename; // the filename this descriptor was read from std::string fFilename; // the filename this descriptor was read from
void IDeInit(); void IDeInit();
public: public:
plStateDescriptor() : fVersion(-1),fName(nil) {} plStateDescriptor() : fVersion(-1) {}
~plStateDescriptor(); ~plStateDescriptor();
// getters // getters
const char* GetName() const { return fName; } plString GetName() const { return fName; }
int GetNumVars() const { return fVarsList.size(); } int GetNumVars() const { return fVarsList.size(); }
plVarDescriptor* GetVar(int i) const { return fVarsList[i]; } plVarDescriptor* GetVar(int i) const { return fVarsList[i]; }
int GetVersion() const { return fVersion; } int GetVersion() const { return fVersion; }
@ -242,11 +243,11 @@ public:
// setters // setters
void SetVersion(int v) { fVersion=v; } 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 AddVar(plVarDescriptor* v) { fVarsList.push_back(v); }
void SetFilename( const char * n ) { fFilename=n;} 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 // IO
bool Read(hsStream* s); 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. // search latest and legacy descriptors for one that matches.
// if version is -1, search for latest descriptor with matching name // 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; return nil;
if ( !dl ) if ( !dl )
@ -116,7 +116,7 @@ plStateDescriptor* plSDLMgr::FindDescriptor(const char* name, int version, const
int highestFound = -1; int highestFound = -1;
for(it=(*dl).begin(); it!= (*dl).end(); it++) for(it=(*dl).begin(); it!= (*dl).end(); it++)
{ {
if (!stricmp((*it)->GetName(), name) ) if (!(*it)->GetName().CompareI(name) )
{ {
if ( (*it)->GetVersion()==version ) 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, bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char token[], plStateDescriptor*& curDesc,
plVarDescriptor*& curVar) const 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 ) if ( !curDesc )
return false; return false;
bool skipNext=false; bool skipNext=false;
std::string dbgStr; plString dbgStr;
static char seps[] = "( ,)[]"; static char seps[] = "( ,)[]";
// read type, name, cnt, [default] // read type, name, cnt, [default]
@ -180,7 +180,7 @@ bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char tok
// nested sdls // nested sdls
char* sdlName = token+1; char* sdlName = token+1;
plStateDescriptor* stateDesc = plSDLMgr::GetInstance()->FindDescriptor(sdlName, plSDL::kLatestVersion); 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()); sdlName, fileName).c_str());
curVar = new plSDVarDescriptor(stateDesc); curVar = new plSDVarDescriptor(stateDesc);
} }
@ -189,19 +189,19 @@ bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char tok
curDesc->AddVar(curVar); curDesc->AddVar(curVar);
bool ok=curVar->SetType(token); bool ok=curVar->SetType(token);
hsAssert(ok, xtl::format("Variable 'type' syntax problem with .sdl file, type=%s, fileName=%s", token, fileName).c_str()); hsAssert(ok, plString::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(); dbgStr = plString::Format("\tVAR Type=%s ", token);
// //
// NAME (foo[1]) // NAME (foo[1])
// //
if (stream->GetToken(token, kTokenLen)) 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()); fileName).c_str());
char* ptr = strtok( token, seps ); // skip [ 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); curVar->SetName(token);
// //
// COUNT // COUNT
@ -211,7 +211,7 @@ bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char tok
curVar->SetCount(cnt); curVar->SetCount(cnt);
if (cnt==0) if (cnt==0)
curVar->SetVariableLength(true); 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")) 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 // read state var type
std::string defaultStr; plString defaultStr;
plSimpleVarDescriptor* sVar=(plSimpleVarDescriptor*)curVar; plSimpleVarDescriptor* sVar=(plSimpleVarDescriptor*)curVar;
if (sVar) 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()); curVar->SetDefault(defaultStr);
dbgStr += std::string(" DEFAULT=") + defaultStr; dbgStr += " DEFAULT=" + defaultStr;
} }
} }
else else
if (!strcmp(token, "DISPLAYOPTION")) if (!strcmp(token, "DISPLAYOPTION"))
{ {
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());
dbgStr += std::string(" ") + token; dbgStr += plString(" ") + token;
bool read=stream->GetToken(token, kTokenLen); bool read=stream->GetToken(token, kTokenLen);
if (read) if (read)
{ {
std::string oldOptions=curVar->GetDisplayOptions(); plString oldOptions=curVar->GetDisplayOptions();
if (oldOptions.size()) if (!oldOptions.IsEmpty())
oldOptions += std::string(","); oldOptions += ",";
oldOptions += token; oldOptions += token;
curVar->SetDisplayOptions(oldOptions.c_str()); curVar->SetDisplayOptions(oldOptions);
dbgStr += std::string("=") + token; dbgStr += plString("=") + token;
if (!stricmp(token, "hidden")) if (!stricmp(token, "hidden"))
curVar->SetInternal(true); curVar->SetInternal(true);
} }
else 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 else
if (!strcmp(token, "DEFAULTOPTION")) if (!strcmp(token, "DEFAULTOPTION"))
{ {
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());
dbgStr += std::string(" ") + token; dbgStr += plString(" ") + token;
bool read=stream->GetToken(token, kTokenLen); bool read=stream->GetToken(token, kTokenLen);
if (read) if (read)
{ {
dbgStr += std::string("=") + token; dbgStr += plString("=") + token;
if (!stricmp(token, "vault")) if (!stricmp(token, "vault"))
curVar->SetAlwaysNew(true); curVar->SetAlwaysNew(true);
} }
else 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 else
if (!strcmp(token, "INTERNAL")) 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); curVar->SetInternal(true);
dbgStr += std::string(" ") + token; dbgStr += plString(" ") + token;
} }
else else
if (!strcmp(token, "PHASED")) 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); curVar->SetAlwaysNew(true);
dbgStr += std::string(" ") + token; dbgStr += plString(" ") + token;
} }
#endif #endif
else 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 // send notification msg to all registered recipients
// //
void plStateChangeNotifier::SendNotificationMsg(const plSimpleStateVariable* srcVar, const plSimpleStateVariable* dstVar, void plStateChangeNotifier::SendNotificationMsg(const plSimpleStateVariable* srcVar, const plSimpleStateVariable* dstVar,
const char* sdlName) const plString& sdlName)
{ {
plSDLNotificationMsg* m = new plSDLNotificationMsg; 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 // State Data
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
plStateDataRecord::plStateDataRecord(const char* name, int version) : fFlags(0) plStateDataRecord::plStateDataRecord(const plString& name, int version) : fFlags(0)
, fDescriptor( nil ) , fDescriptor( nil )
{ {
SetDescriptor(name, version); SetDescriptor(name, version);
@ -113,7 +113,7 @@ plStateDataRecord::~plStateDataRecord()
IDeleteVarsList(fSDVarsList); IDeleteVarsList(fSDVarsList);
} }
void plStateDataRecord::SetDescriptor(const char* name, int version) void plStateDataRecord::SetDescriptor(const plString& name, int version)
{ {
IInitDescriptor(name, version); IInitDescriptor(name, version);
} }
@ -125,10 +125,10 @@ void plStateDataRecord::IDeleteVarsList(VarsList& vars)
vars.clear(); 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); 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) if (sd)
IInitDescriptor(sd); IInitDescriptor(sd);
} }
@ -268,7 +268,7 @@ bool plStateDataRecord::Read(hsStream* s, float timeConvert, uint32_t readOption
{ {
if (plSDLMgr::GetInstance()->GetNetApp()) if (plSDLMgr::GetInstance()->GetNetApp())
plSDLMgr::GetInstance()->GetNetApp()->ErrorMsg("Failed reading SDL, desc %s", plSDLMgr::GetInstance()->GetNetApp()->ErrorMsg("Failed reading SDL, desc %s",
fDescriptor && fDescriptor->GetName() ? fDescriptor->GetName() : "?"); fDescriptor ? fDescriptor->GetName().c_str("?") : "?");
return false; return false;
} }
} }
@ -276,8 +276,8 @@ bool plStateDataRecord::Read(hsStream* s, float timeConvert, uint32_t readOption
catch(...) catch(...)
{ {
hsAssert( false, hsAssert( false,
xtl::format("Something bad happened while reading simple var data, desc:%s", plString::Format("Something bad happened while reading simple var data, desc:%s",
fDescriptor && fDescriptor->GetName() ? fDescriptor->GetName() : "?").c_str()); fDescriptor ? fDescriptor->GetName().c_str("?") : "?").c_str());
return false; return false;
} }
@ -302,7 +302,7 @@ bool plStateDataRecord::Read(hsStream* s, float timeConvert, uint32_t readOption
{ {
if (plSDLMgr::GetInstance()->GetNetApp()) if (plSDLMgr::GetInstance()->GetNetApp())
plSDLMgr::GetInstance()->GetNetApp()->ErrorMsg("Failed reading nested SDL, desc %s", plSDLMgr::GetInstance()->GetNetApp()->ErrorMsg("Failed reading nested SDL, desc %s",
fDescriptor && fDescriptor->GetName() ? fDescriptor->GetName() : "?"); fDescriptor ? fDescriptor->GetName().c_str("?") : "?");
return false; return false;
} }
} }
@ -310,15 +310,15 @@ bool plStateDataRecord::Read(hsStream* s, float timeConvert, uint32_t readOption
catch(...) catch(...)
{ {
hsAssert( false, hsAssert( false,
xtl::format("Something bad happened while reading nested var data, desc:%s", plString::Format("Something bad happened while reading nested var data, desc:%s",
fDescriptor && fDescriptor->GetName() ? fDescriptor->GetName() : "?").c_str()); fDescriptor ? fDescriptor->GetName().c_str("?") : "?").c_str());
return false; return false;
} }
// convert to latest descriptor // convert to latest descriptor
// Only really need to do this the first time this descriptor is read... // Only really need to do this the first time this descriptor is read...
plStateDescriptor* latestDesc=plSDLMgr::GetInstance()->FindDescriptor(fDescriptor->GetName(), plSDL::kLatestVersion); 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; bool forceConvert = (readOptions&plSDL::kForceConvert)!=0;
if ( latestDesc && ( forceConvert || ( fDescriptor->GetVersion()!=latestDesc->GetVersion() ) ) ) 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 // 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; uint16_t savFlags;
s->ReadLE(&savFlags); s->ReadLE(&savFlags);
if (!(savFlags & plSDL::kAddedVarLengthIO)) // using to establish a new version in the header, can delete in 8/03 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 return false; // bad version
} }
*name = s->ReadSafeString(); *name = s->ReadSafeString_TEMP();
*version = s->ReadLE16(); *version = s->ReadLE16();
if (objUoid) if (objUoid)
@ -492,13 +492,14 @@ void plStateDataRecord::UpdateFrom(const plStateDataRecord& other, uint32_t writ
if ( GetDescriptor()->GetVersion()!=other.GetDescriptor()->GetVersion() ) if ( GetDescriptor()->GetVersion()!=other.GetDescriptor()->GetVersion() )
{ {
plStateDescriptor* sd=plSDLMgr::GetInstance()->FindDescriptor( other.GetDescriptor()->GetName(), 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 ); ConvertTo( sd );
} }
hsAssert(other.GetDescriptor()==fDescriptor, hsAssert(other.GetDescriptor()==fDescriptor,
xtl::format("descriptor mismatch in UpdateFromDirty, SDL=%s,%s version %d %d", plString::Format("descriptor mismatch in UpdateFromDirty, SDL=%s,%s version %d %d",
GetDescriptor()->GetName(), other.GetDescriptor()->GetName(), GetDescriptor()->GetName().c_str(), other.GetDescriptor()->GetName().c_str(),
GetDescriptor()->GetVersion(), other.GetDescriptor()->GetVersion()).c_str()); GetDescriptor()->GetVersion(), other.GetDescriptor()->GetVersion()).c_str());
bool dirtyOnly = (writeOptions & plSDL::kDirtyOnly); bool dirtyOnly = (writeOptions & plSDL::kDirtyOnly);
@ -543,9 +544,9 @@ void plStateDataRecord::FlagDifferentState(const plStateDataRecord& other)
} }
else else
{ {
hsAssert(false, xtl::format("descriptor mismatch in FlagDifferentState, mine %s %d, other %s %d", hsAssert(false, plString::Format("descriptor mismatch in FlagDifferentState, mine %s %d, other %s %d",
fDescriptor->GetName(), fDescriptor->GetVersion(), fDescriptor->GetName().c_str(), fDescriptor->GetVersion(),
other.GetDescriptor()->GetName(), other.GetDescriptor()->GetVersion()).c_str()); other.GetDescriptor()->GetName().c_str(), other.GetDescriptor()->GetVersion()).c_str());
} }
} }
@ -597,9 +598,9 @@ void plStateDataRecord::FlagNewerState(const plStateDataRecord& other, bool resp
} }
else else
{ {
hsAssert(false, xtl::format("descriptor mismatch in FlagNewerState, mine %s %d, other %s %d", hsAssert(false, plString::Format("descriptor mismatch in FlagNewerState, mine %s %d, other %s %d",
fDescriptor->GetName(), fDescriptor->GetVersion(), fDescriptor->GetName().c_str(), fDescriptor->GetVersion(),
other.GetDescriptor()->GetName(), other.GetDescriptor()->GetVersion()).c_str()); other.GetDescriptor()->GetName().c_str(), other.GetDescriptor()->GetVersion()).c_str());
} }
} }
@ -651,16 +652,16 @@ bool plStateDataRecord::IConvertVar(plSimpleStateVariable* fromVar, plSimpleStat
return true; // ok 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++) 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]; return vars[i];
} }
if (plSDLMgr::GetInstance()->GetNetApp()) 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; return nil;
} }
@ -674,7 +675,7 @@ bool plStateDataRecord::ConvertTo( plStateDescriptor* other, bool force )
if (!other && !force) if (!other && !force)
return false; // err 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())) if ( !force && (other == fDescriptor || other->GetVersion()==fDescriptor->GetVersion()))
return true; // ok, nothing to do 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?"); 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)", 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, // make other StateData to represent other descriptor,
// this will be the destination for the convert operation // this will be the destination for the convert operation
@ -696,7 +697,7 @@ bool plStateDataRecord::ConvertTo( plStateDescriptor* other, bool force )
{ {
// get other var info // get other var info
plSimpleStateVariable* otherVar = otherStateData.GetVar(i); plSimpleStateVariable* otherVar = otherStateData.GetVar(i);
const char* otherVarName = otherVar->GetVarDescriptor()->GetName(); plString otherVarName = otherVar->GetVarDescriptor()->GetName();
// find corresponding var in my data // find corresponding var in my data
plSimpleStateVariable* myVar=FindVar(otherVarName); plSimpleStateVariable* myVar=FindVar(otherVarName);
@ -708,7 +709,7 @@ bool plStateDataRecord::ConvertTo( plStateDescriptor* other, bool force )
for(i=0;i<otherStateData.GetNumSDVars(); i++) for(i=0;i<otherStateData.GetNumSDVars(); i++)
{ {
plSDStateVariable* otherSDVar = otherStateData.GetSDVar(i); plSDStateVariable* otherSDVar = otherStateData.GetSDVar(i);
const char* otherSDVarName = otherSDVar->GetVarDescriptor()->GetName(); plString otherSDVarName = otherSDVar->GetVarDescriptor()->GetName();
// find corresponding var in my data // find corresponding var in my data
plSDStateVariable* mySDVar=FindSDVar(otherSDVarName); 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("%s%s", pad.c_str(),msg).c_str());
dbg->LogMsg(plString::Format("%sSDR(%p), desc=%s, showDirty=%d, numVars=%d, vol=%d", 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 // dump simple vars
for(i=0;i<fVarsList.size(); i++) 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()); 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()); stream->Write(logStr.GetSize(), logStr.c_str());
// dump simple vars // dump simple vars

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

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

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

@ -108,11 +108,9 @@ public:
void plStateVarNotificationInfo::Read(hsStream* s, uint32_t readOptions) void plStateVarNotificationInfo::Read(hsStream* s, uint32_t readOptions)
{ {
uint8_t saveFlags=s->ReadByte(); // unused uint8_t saveFlags=s->ReadByte(); // unused
char* hint=s->ReadSafeString(); plString hint=s->ReadSafeString_TEMP();
if (hint && !(readOptions & plSDL::kSkipNotificationInfo)) if (!hint.IsNull() && !(readOptions & plSDL::kSkipNotificationInfo))
fHintString = (const char*)hint; fHintString = hint;
// we're done with it...
delete[] hint;
} }
void plStateVarNotificationInfo::Write(hsStream* s, uint32_t writeOptions) const void plStateVarNotificationInfo::Write(hsStream* s, uint32_t writeOptions) const
@ -212,8 +210,8 @@ void plSimpleStateVariable::IDeAlloc()
} }
break; break;
default: default:
hsAssert(false, xtl::format("undefined atomic type:%d var:%s cnt:%d", hsAssert(false, plString::Format("undefined atomic type:%d var:%s cnt:%d",
type, GetName() ? GetName() : "?", GetCount()).c_str()); type, GetName().c_str("?"), GetCount()).c_str());
break; 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. // 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; return false;
std::string value = valueConst;
plVarDescriptor::Type type=fVar.GetAtomicType(); plVarDescriptor::Type type=fVar.GetAtomicType();
switch(type) switch(type)
{ {
@ -346,54 +343,47 @@ bool plSimpleStateVariable::SetFromString(const char* valueConst, int idx, bool
case plVarDescriptor::kByte: case plVarDescriptor::kByte:
{ {
// handles value in the form "(i,j,k)" for vectors // handles value in the form "(i,j,k)" for vectors
static char seps[] = "( ,)"; std::vector<plString> bits = value.Tokenize("( ,)");
char* ptr = strtok( (char*)value.c_str(), seps );
int i=idx*fVar.GetAtomicCount(); int i=idx*fVar.GetAtomicCount();
while (ptr) for (std::vector<plString>::iterator ptr = bits.begin(); ptr != bits.end(); ++ptr)
{ {
if ((type==plVarDescriptor::kInt) && fI) if ((type==plVarDescriptor::kInt) && fI)
fI[i++] = atoi(ptr); fI[i++] = ptr->ToInt();
else if (type==plVarDescriptor::kShort && fS) else if (type==plVarDescriptor::kShort && fS)
fS[i++] = (short)atoi(ptr); fS[i++] = static_cast<short>(ptr->ToInt());
else if (type==plVarDescriptor::kByte && fBy) 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) 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) else if ( (type==plVarDescriptor::kDouble || type==plVarDescriptor::kTime) && fD)
fD[i++] = atof(ptr); fD[i++] = ptr->ToDouble();
ptr = strtok(nil, seps);
} }
} }
break; break;
case plVarDescriptor::kBool: case plVarDescriptor::kBool:
{ {
// handles value in the form "(i,j,k)" for things like vectors // handles value in the form "(i,j,k)" for things like vectors
static char seps[] = "( ,)"; std::vector<plString> bits = value.Tokenize("( ,)");
char* ptr = strtok( (char*)value.c_str(), seps );
int i=idx*fVar.GetAtomicCount(); 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; fB[i++]=true;
else else if (!ptr->CompareI("false"))
if (!stricmp(ptr, "false"))
fB[i++]=false; fB[i++]=false;
else else
fB[i++] = (atoi(ptr) != 0); fB[i++] = (ptr->ToInt() != 0);
ptr = strtok(nil, seps);
} }
} }
break; break;
case plVarDescriptor::kString32: case plVarDescriptor::kString32:
{ {
// handles value in the form "(i,j,k)" for things like vectors // handles value in the form "(i,j,k)" for things like vectors
static char seps[] = "( ,)"; std::vector<plString> bits = value.Tokenize("( ,)");
char* ptr = strtok( (char*)value.c_str(), seps );
int i=idx*fVar.GetAtomicCount(); int i=idx*fVar.GetAtomicCount();
while (ptr) for (std::vector<plString>::iterator ptr = bits.begin(); ptr != bits.end(); ++ptr)
{ {
hsStrncpy(fS32[i++], ptr, 32); hsStrncpy(fS32[i++], ptr->c_str(), 32);
ptr = strtok(nil, seps);
} }
} }
break; break;
@ -419,12 +409,12 @@ void plSimpleStateVariable::IVarSet(bool timeStampNow/*=true*/)
// //
// Get value as string. // Get value as string.
// //
char* plSimpleStateVariable::GetAsString(int idx) const plString plSimpleStateVariable::GetAsString(int idx) const
{ {
int j; int j;
std::string str; plString str;
if (fVar.GetAtomicCount()>1) if (fVar.GetAtomicCount()>1)
str = str + "("; str += "(";
plVarDescriptor::Type type=fVar.GetAtomicType(); plVarDescriptor::Type type=fVar.GetAtomicType();
switch(type) switch(type)
@ -442,20 +432,20 @@ char* plSimpleStateVariable::GetAsString(int idx) const
for(j=0;j<fVar.GetAtomicCount();j++) for(j=0;j<fVar.GetAtomicCount();j++)
{ {
if (type==plVarDescriptor::kInt) if (type==plVarDescriptor::kInt)
str.append( xtl::format( "%d", fI[i++]) ); str += plString::Format( "%d", fI[i++]);
else if (type==plVarDescriptor::kShort) else if (type==plVarDescriptor::kShort)
str.append( xtl::format( "%d", fS[i++]) ); str += plString::Format( "%d", fS[i++]);
else if (type==plVarDescriptor::kByte) 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) 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) else if (type==plVarDescriptor::kDouble)
str.append( xtl::format( "%.3f", fD[i++]) ); str += plString::Format( "%.3f", fD[i++]);
else if (type==plVarDescriptor::kTime) else if (type==plVarDescriptor::kTime)
{ {
double tmp; double tmp;
Get(&tmp, i++); Get(&tmp, i++);
str.append( xtl::format( "%.3f", tmp) ); str += plString::Format( "%.3f", tmp);
} }
if (j==fVar.GetAtomicCount()-1) if (j==fVar.GetAtomicCount()-1)
@ -474,7 +464,7 @@ char* plSimpleStateVariable::GetAsString(int idx) const
int i=idx*fVar.GetAtomicCount(); int i=idx*fVar.GetAtomicCount();
for(j=0;j<fVar.GetAtomicCount();j++) 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) if (j==fVar.GetAtomicCount()-1)
{ {
@ -492,7 +482,7 @@ char* plSimpleStateVariable::GetAsString(int idx) const
int i=idx*fVar.GetAtomicCount(); int i=idx*fVar.GetAtomicCount();
for(j=0;j<fVar.GetAtomicCount();j++) 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) if (j==fVar.GetAtomicCount()-1)
{ {
@ -510,7 +500,7 @@ char* plSimpleStateVariable::GetAsString(int idx) const
int i=idx*fVar.GetAtomicCount(); int i=idx*fVar.GetAtomicCount();
for(j=0;j<fVar.GetAtomicCount();j++) for(j=0;j<fVar.GetAtomicCount();j++)
{ {
str.append( xtl::format( "%s", "other") ); str += "other";
if (j==fVar.GetAtomicCount()-1) if (j==fVar.GetAtomicCount()-1)
{ {
@ -524,7 +514,7 @@ char* plSimpleStateVariable::GetAsString(int idx) const
break; break;
} }
return hsStrcpy(str.c_str()); return str;
} }
// //
@ -2131,7 +2121,7 @@ case type: \
} \ } \
break; break;
void plSimpleStateVariable::NotifyStateChange(const plSimpleStateVariable* other, const char* sdlName) void plSimpleStateVariable::NotifyStateChange(const plSimpleStateVariable* other, const plString& sdlName)
{ {
if (fChangeNotifiers.size()==0) if (fChangeNotifiers.size()==0)
return; return;
@ -2174,8 +2164,8 @@ void plSimpleStateVariable::NotifyStateChange(const plSimpleStateVariable* other
if (plNetObjectDebuggerBase::GetInstance() && plNetObjectDebuggerBase::GetInstance()->GetDebugging()) if (plNetObjectDebuggerBase::GetInstance() && plNetObjectDebuggerBase::GetInstance()->GetDebugging())
{ {
plNetObjectDebuggerBase::GetInstance()->LogMsg( plNetObjectDebuggerBase::GetInstance()->LogMsg(
xtl::format("Var %s did %s send notification difference. Has %d notifiers with %d recipients.", plString::Format("Var %s did %s send notification difference. Has %d notifiers with %d recipients.",
GetName(), !notify ? "NOT" : "", fChangeNotifiers.size(), numNotifiers).c_str()); GetName().c_str(), !notify ? "NOT" : "", fChangeNotifiers.size(), numNotifiers).c_str());
} }
} }
@ -2290,12 +2280,12 @@ void plSimpleStateVariable::DumpToObjectDebugger(bool dirtyOnly, int level) cons
if (!dbg) if (!dbg)
return; return;
std::string pad; plString pad;
int i; int i;
for(i=0;i<level; i++) for(i=0;i<level; i++)
pad += " "; 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) if (GetCount()>1)
{ {
dbg->LogMsg(logMsg.c_str()); // it's going to be a long msg, so print it on its own line 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"; pad += "\t";
for(i=0;i<GetCount(); i++) for(i=0;i<GetCount(); i++)
{ {
char* s=GetAsString(i); plString s=GetAsString(i);
if (fVar.GetAtomicType() == plVarDescriptor::kTime) if (fVar.GetAtomicType() == plVarDescriptor::kTime)
{ {
const char* p=fT[i].PrintWMillis(); const char* p=fT[i].PrintWMillis();
logMsg += xtl::format( "%sVar:%d gameTime:%s pst:%s ts:%s", logMsg += plString::Format( "%sVar:%d gameTime:%s pst:%s ts:%s",
pad.c_str(), i, s ? s : "?", p, fTimeStamp.Format("%c").c_str() ); pad.c_str(), i, s.c_str("?"), p, fTimeStamp.Format("%c").c_str() );
} }
else else
{ {
logMsg +=xtl::format( "%sVar:%d value:%s ts:%s", logMsg += plString::Format( "%sVar:%d value:%s ts:%s",
pad.c_str(), i, s ? s : "?", fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c").c_str() ); pad.c_str(), i, s.c_str("?"), fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c").c_str() );
} }
delete [] s;
if ( !dirtyOnly ) if ( !dirtyOnly )
logMsg += xtl::format( " dirty:%d", IsDirty() ); logMsg += plString::Format( " dirty:%d", IsDirty() );
dbg->LogMsg(logMsg.c_str()); dbg->LogMsg(logMsg.c_str());
logMsg = ""; logMsg = "";
@ -2329,12 +2318,12 @@ void plSimpleStateVariable::DumpToObjectDebugger(bool dirtyOnly, int level) cons
void plSimpleStateVariable::DumpToStream(hsStream* stream, bool dirtyOnly, int level) const void plSimpleStateVariable::DumpToStream(hsStream* stream, bool dirtyOnly, int level) const
{ {
std::string pad; plString pad;
int i; int i;
for(i=0;i<level; i++) for(i=0;i<level; i++)
pad += " "; 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) if (GetCount()>1)
{ {
stream->WriteString(logMsg.c_str()); // it's going to be a long msg, so print it on its own line 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"; pad += "\t";
for(i=0;i<GetCount(); i++) for(i=0;i<GetCount(); i++)
{ {
char* s=GetAsString(i); plString s=GetAsString(i);
if (fVar.GetAtomicType() == plVarDescriptor::kTime) if (fVar.GetAtomicType() == plVarDescriptor::kTime)
{ {
const char* p=fT[i].PrintWMillis(); const char* p=fT[i].PrintWMillis();
logMsg += xtl::format( "%sVar:%d gameTime:%s pst:%s ts:%s", logMsg += plString::Format( "%sVar:%d gameTime:%s pst:%s ts:%s",
pad.c_str(), i, s ? s : "?", p, fTimeStamp.Format("%c").c_str() ); pad.c_str(), i, s.c_str("?"), p, fTimeStamp.Format("%c").c_str() );
} }
else else
{ {
logMsg +=xtl::format( "%sVar:%d value:%s ts:%s", logMsg += plString::Format( "%sVar:%d value:%s ts:%s",
pad.c_str(), i, s ? s : "?", fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c").c_str() ); pad.c_str(), i, s.c_str("?"), fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c").c_str() );
} }
delete [] s;
if ( !dirtyOnly ) if ( !dirtyOnly )
logMsg += xtl::format( " dirty:%d", IsDirty() ); logMsg += plString::Format( " dirty:%d", IsDirty() );
stream->WriteString(logMsg.c_str()); stream->WriteString(logMsg.c_str());
logMsg = ""; logMsg = "";
@ -2497,9 +2485,9 @@ void plSDStateVariable::CopyFrom(plSDStateVariable* other, uint32_t writeOptions
// //
void plSDStateVariable::UpdateFrom(plSDStateVariable* other, uint32_t writeOptions/*=0*/) void plSDStateVariable::UpdateFrom(plSDStateVariable* other, uint32_t writeOptions/*=0*/)
{ {
hsAssert(!stricmp(other->GetSDVarDescriptor()->GetName(), fVarDescriptor->GetName()), hsAssert(!other->GetSDVarDescriptor()->GetName().CompareI(fVarDescriptor->GetName()),
xtl::format("var descriptor mismatch in UpdateFrom, name %s,%s ver %d,%d", plString::Format("var descriptor mismatch in UpdateFrom, name %s,%s ver %d,%d",
GetName(), other->GetName()).c_str()); GetName().c_str(), other->GetName().c_str()).c_str());
Resize(other->GetCount()); // make sure sizes match Resize(other->GetCount()); // make sure sizes match
bool dirtyOnly = (writeOptions & plSDL::kDirtyOnly); bool dirtyOnly = (writeOptions & plSDL::kDirtyOnly);
@ -2521,8 +2509,8 @@ void plSDStateVariable::ConvertTo(plSDStateVariable* otherSDVar, bool force )
plStateDescriptor* otherSD=otherSDVar->GetSDVarDescriptor()->GetStateDescriptor(); plStateDescriptor* otherSD=otherSDVar->GetSDVarDescriptor()->GetStateDescriptor();
hsLogEntry( plNetApp::StaticDebugMsg( "SDSV(%p) converting %s from %s to %s (force:%d)", hsLogEntry( plNetApp::StaticDebugMsg( "SDSV(%p) converting %s from %s to %s (force:%d)",
this, fVarDescriptor->GetName(), fVarDescriptor->GetTypeString(), this, fVarDescriptor->GetName().c_str(), fVarDescriptor->GetTypeString().c_str(),
otherSDVar->GetSDVarDescriptor()->GetTypeString(), force ) ); otherSDVar->GetSDVarDescriptor()->GetTypeString().c_str(), force ) );
int j; int j;
for(j=0;j<GetCount(); 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 // 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. // 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; return false;
if (!stricmp(type, "vector3")) if (!type.CompareI("vector3"))
fType=kVector3; fType=kVector3;
else else
if (!stricmp(type, "point3")) if (!type.CompareI("point3"))
fType=kPoint3; fType=kPoint3;
else else
if (!stricmp(type, "rgb")) if (!type.CompareI("rgb"))
fType=kRGB; fType=kRGB;
else else
if (!stricmp(type, "rgba")) if (!type.CompareI("rgba"))
fType=kRGBA; fType=kRGBA;
else else
if (!stricmp(type, "rgb8")) if (!type.CompareI("rgb8"))
fType=kRGB8; fType=kRGB8;
else else
if (!stricmp(type, "rgba8")) if (!type.CompareI("rgba8"))
fType=kRGBA8; fType=kRGBA8;
else else
if (!strnicmp(type, "quat",4)) if (!type.CompareNI("quat", 4))
fType=kQuaternion; fType=kQuaternion;
else else
if (!stricmp(type, "rgba")) if (!type.CompareI("rgba"))
fType=kRGBA; fType=kRGBA;
else else
if (!stricmp(type, "int")) if (!type.CompareI("int"))
fType=kInt; fType=kInt;
else else
if (!stricmp(type, "byte")) if (!type.CompareI("byte"))
fType=kByte; fType=kByte;
else else
if (!stricmp(type, "short")) if (!type.CompareI("short"))
fType=kShort; fType=kShort;
else else
if (!stricmp(type, "float")) if (!type.CompareI("float"))
fType=kFloat; fType=kFloat;
else else
if (!stricmp(type, "double")) if (!type.CompareI("double"))
fType=kDouble; fType=kDouble;
else else
if (!stricmp(type, "time")) if (!type.CompareI("time"))
fType=kTime; fType=kTime;
else else
if (!stricmp(type, "ageTimeOfDay")) if (!type.CompareI("ageTimeOfDay"))
fType=kAgeTimeOfDay; fType=kAgeTimeOfDay;
else else
if (!stricmp(type, "bool")) if (!type.CompareI("bool"))
fType=kBool; fType=kBool;
else else
if (!stricmp(type, "string32")) if (!type.CompareI("string32"))
fType=kString32; fType=kString32;
else else
if (!stricmp(type, "plKey")) if (!type.CompareI("plKey"))
fType=kKey; fType=kKey;
else else
if (!stricmp(type, "message") || !stricmp(type, "creatable") ) if (!type.CompareI("message") || !type.CompareI("creatable") )
fType=kCreatable; fType=kCreatable;
else else
if (*type=='$') if (type.CharAt(0)=='$')
fType=kStateDescriptor; fType=kStateDescriptor;
else else
return false; // err return false; // err
delete [] fTypeString; fTypeString = type;
fTypeString = hsStrcpy(type);
return true; // ok return true; // ok
} }
@ -156,8 +137,7 @@ void plVarDescriptor::CopyFrom(const plVarDescriptor* other)
SetCount(other->GetCount()); SetCount(other->GetCount());
SetDisplayOptions(other->GetDisplayOptions()); SetDisplayOptions(other->GetDisplayOptions());
delete [] fTypeString; fTypeString=other->GetTypeString();
fTypeString=hsStrcpy(other->GetTypeString());
fType = other->GetType(); fType = other->GetType();
fFlags = other->fFlags; fFlags = other->fFlags;
@ -178,8 +158,7 @@ bool plVarDescriptor::Read(hsStream* s)
return false; return false;
} }
delete [] fName; fName=s->ReadSafeString_TEMP();
fName=s->ReadSafeString();
plMsgStdStringHelper::Peek(fDisplayOptions, s); plMsgStdStringHelper::Peek(fDisplayOptions, s);
@ -187,8 +166,7 @@ bool plVarDescriptor::Read(hsStream* s)
fType=(Type)s->ReadByte(); fType=(Type)s->ReadByte();
delete [] fDefault; fDefault = s->ReadSafeString_TEMP();
fDefault = s->ReadSafeString();
fFlags = s->ReadLE32(); fFlags = s->ReadLE32();
return true; return true;
@ -259,87 +237,84 @@ int plSimpleVarDescriptor::GetSize() const
// Set type from a string. Return false on err. // Set type from a string. Return false on err.
// Sets atomicCount and atomicType // Sets atomicCount and atomicType
// //
bool plSimpleVarDescriptor::SetType(const char* type) bool plSimpleVarDescriptor::SetType(const plString& type)
{ {
if (!type)
return false;
if (!plVarDescriptor::SetType(type)) if (!plVarDescriptor::SetType(type))
return false; return false;
if (!stricmp(type, "vector3")) if (!type.CompareI("vector3"))
{ {
fAtomicCount = 3; fAtomicCount = 3;
fAtomicType=kFloat; fAtomicType=kFloat;
} }
else else
if (!stricmp(type, "point3")) if (!type.CompareI("point3"))
{ {
fAtomicCount = 3; fAtomicCount = 3;
fAtomicType=kFloat; fAtomicType=kFloat;
} }
else else
if (!stricmp(type, "rgb")) if (!type.CompareI("rgb"))
{ {
fAtomicCount = 3; fAtomicCount = 3;
fAtomicType=kFloat; fAtomicType=kFloat;
} }
else else
if (!stricmp(type, "rgba")) if (!type.CompareI("rgba"))
{ {
fAtomicCount = 4; fAtomicCount = 4;
fAtomicType=kFloat; fAtomicType=kFloat;
} }
else else
if (!stricmp(type, "rgb8")) if (!type.CompareI("rgb8"))
{ {
fAtomicCount = 3; fAtomicCount = 3;
fAtomicType=kByte; fAtomicType=kByte;
} }
else else
if (!stricmp(type, "rgba8")) if (!type.CompareI("rgba8"))
{ {
fAtomicCount = 4; fAtomicCount = 4;
fAtomicType=kByte; fAtomicType=kByte;
} }
else else
if (!strnicmp(type, "quat",4)) if (!type.CompareNI("quat", 4))
{ {
fAtomicCount = 4; fAtomicCount = 4;
fAtomicType=kFloat; fAtomicType=kFloat;
} }
else else
if (!stricmp(type, "int")) if (!type.CompareI("int"))
fAtomicType=kInt; fAtomicType=kInt;
else else
if (!stricmp(type, "byte")) if (!type.CompareI("byte"))
fAtomicType=kByte; fAtomicType=kByte;
else else
if (!stricmp(type, "short")) if (!type.CompareI("short"))
fAtomicType=kShort; fAtomicType=kShort;
else else
if (!stricmp(type, "float")) if (!type.CompareI("float"))
fAtomicType=kFloat; fAtomicType=kFloat;
else else
if (!stricmp(type, "double")) if (!type.CompareI("double"))
fAtomicType=kDouble; fAtomicType=kDouble;
else else
if (!stricmp(type, "time")) if (!type.CompareI("time"))
fAtomicType=kTime; fAtomicType=kTime;
else else
if (!stricmp(type, "ageTimeOfDay")) if (!type.CompareI("ageTimeOfDay"))
fAtomicType=kAgeTimeOfDay; fAtomicType=kAgeTimeOfDay;
else else
if (!stricmp(type, "bool")) if (!type.CompareI("bool"))
fAtomicType=kBool; fAtomicType=kBool;
else else
if (!stricmp(type, "string32")) if (!type.CompareI("string32"))
fAtomicType=kString32; fAtomicType=kString32;
else else
if (!stricmp(type, "plKey")) if (!type.CompareI("plKey"))
fAtomicType=kKey; fAtomicType=kKey;
else else
if (!stricmp(type, "message") || !stricmp(type, "creatable")) if (!type.CompareI("message") || !type.CompareI("creatable"))
fAtomicType=kCreatable; fAtomicType=kCreatable;
else else
return false; // err return false; // err
@ -398,12 +373,11 @@ bool plSDVarDescriptor::Read(hsStream* s)
if (!plVarDescriptor::Read(s)) if (!plVarDescriptor::Read(s))
return false; return false;
char* sdName=s->ReadSafeString(); plString sdName=s->ReadSafeString_TEMP();
uint16_t version = s->ReadLE16(); uint16_t version = s->ReadLE16();
plStateDescriptor* sd=plSDLMgr::GetInstance()->FindDescriptor(sdName, version); 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); SetStateDesc(sd);
delete [] sdName;
return true; return true;
} }

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

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

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

@ -277,8 +277,8 @@ struct VaultAgeLinkNode : NetVaultNodeAccess {
#ifdef CLIENT #ifdef CLIENT
bool CopyTo (plAgeLinkStruct * link); bool CopyTo (plAgeLinkStruct * link);
void AddSpawnPoint (const plSpawnPointInfo & point); // will only add if not there already. void AddSpawnPoint (const plSpawnPointInfo & point); // will only add if not there already.
void RemoveSpawnPoint (const char spawnPtName[]); void RemoveSpawnPoint (const plString & spawnPtName);
bool HasSpawnPoint (const char spawnPtName[]) const; bool HasSpawnPoint (const plString & spawnPtName) const;
bool HasSpawnPoint (const plSpawnPointInfo & point) const; // compares spawn name only, not title. bool HasSpawnPoint (const plSpawnPointInfo & point) const; // compares spawn name only, not title.
void GetSpawnPoints (plSpawnPointVec * out) const; void GetSpawnPoints (plSpawnPointVec * out) const;
void SetSpawnPoints (const plSpawnPointVec & in); 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::kTime ||
var->GetType() == plVarDescriptor::kAgeTimeOfDay) 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) target_link_libraries(MaxMain winmm)
endif(WIN32) endif(WIN32)
if(USE_VLD)
target_link_libraries(MaxMain ${VLD_LIBRARY})
endif()
source_group("Header Files" FILES ${MaxMain_HEADERS}) source_group("Header Files" FILES ${MaxMain_HEADERS})
source_group("Resource Files" FILES ${MaxMain_RESOURCES}) source_group("Resource Files" FILES ${MaxMain_RESOURCES})
source_group("Source Files" FILES ${MaxMain_SOURCES}) 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) target_link_libraries(MaxPlasmaLights Ws2_32)
endif(WIN32) endif(WIN32)
if(USE_VLD)
target_link_libraries(MaxPlasmaLights ${VLD_LIBRARY})
endif()
source_group("Header Files" FILES ${MaxPlasmaLights_HEADERS}) source_group("Header Files" FILES ${MaxPlasmaLights_HEADERS})
source_group("Resource Files" FILES ${MaxPlasmaLights_RESOURCES}) source_group("Resource Files" FILES ${MaxPlasmaLights_RESOURCES})
source_group("Source Files" FILES ${MaxPlasmaLights_SOURCES}) source_group("Source Files" FILES ${MaxPlasmaLights_SOURCES})

4
Sources/Tools/plFontConverter/CMakeLists.txt

@ -45,6 +45,10 @@ if (WIN32)
target_link_libraries(plFontConverter shlwapi) target_link_libraries(plFontConverter shlwapi)
endif(WIN32) endif(WIN32)
if(USE_VLD)
target_link_libraries(plFontConverter ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plFontConverter_SOURCES}) source_group("Source Files" FILES ${plFontConverter_SOURCES})
source_group("Header Files" FILES ${plFontConverter_HEADERS}) source_group("Header Files" FILES ${plFontConverter_HEADERS})
source_group("Resource Files" FILES ${plFontConverter_RESOURCES}) 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 ${EXPAT_LIBRARY})
target_link_libraries(plLocalizationEditor comctl32) target_link_libraries(plLocalizationEditor comctl32)
if(USE_VLD)
target_link_libraries(plLocalizationEditor ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plLocalizationEditor_SOURCES}) source_group("Source Files" FILES ${plLocalizationEditor_SOURCES})
source_group("Header Files" FILES ${plLocalizationEditor_HEADERS}) source_group("Header Files" FILES ${plLocalizationEditor_HEADERS})
source_group("Resource Files" FILES ${plLocalizationEditor_RESOURCES}) 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 Ws2_32)
target_link_libraries(plResBrowser winmm) target_link_libraries(plResBrowser winmm)
target_link_libraries(plResBrowser strmiids) target_link_libraries(plResBrowser strmiids)
target_link_libraries(plResBrowser comctl32) target_link_libraries(plResBrowser comctl32)
target_link_libraries(plResBrowser shlwapi) target_link_libraries(plResBrowser shlwapi)
endif(WIN32) endif(WIN32)
if(USE_VLD)
target_link_libraries(plResBrowser ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plResBrowser_SOURCES}) source_group("Source Files" FILES ${plResBrowser_SOURCES})
source_group("Header Files" FILES ${plResBrowser_HEADERS}) source_group("Header Files" FILES ${plResBrowser_HEADERS})
source_group("Resource Files" FILES ${plResBrowser_RESOURCES}) 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