Browse Source

Merge pull request #228 from zrax/plString

plStrings part two

--HG--
rename : Sources/Plasma/PubUtilLib/plFile/hsFiles.cpp => Sources/Plasma/CoreLib/hsFiles.cpp
rename : Sources/Plasma/PubUtilLib/plFile/hsFiles.h => Sources/Plasma/CoreLib/hsFiles.h
rename : Sources/Plasma/PubUtilLib/plFile/hsFiles_Mac.cpp => Sources/Plasma/CoreLib/hsFiles_Mac.cpp
rename : Sources/Plasma/PubUtilLib/plFile/hsFiles_PS2.cpp => Sources/Plasma/CoreLib/hsFiles_PS2.cpp
rename : Sources/Plasma/PubUtilLib/plFile/hsFiles_Unix.cpp => Sources/Plasma/CoreLib/hsFiles_Unix.cpp
rename : Sources/Plasma/PubUtilLib/plFile/hsFiles_Win.cpp => Sources/Plasma/CoreLib/hsFiles_Win.cpp
rename : Sources/Plasma/PubUtilLib/plFile/plFileUtils.cpp => Sources/Plasma/CoreLib/plFileUtils.cpp
rename : Sources/Plasma/PubUtilLib/plFile/plFileUtils.h => Sources/Plasma/CoreLib/plFileUtils.h
Adam Johnson 12 years ago
parent
commit
0ce539963a
  1. 6
      Sources/Plasma/Apps/plClient/plClient.cpp
  2. 18
      Sources/Plasma/Apps/plClient/winmain.cpp
  3. 2
      Sources/Plasma/Apps/plFileEncrypt/main.cpp
  4. 16
      Sources/Plasma/Apps/plFileSecure/main.cpp
  5. 4
      Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp
  6. 2
      Sources/Plasma/Apps/plPythonPack/main.cpp
  7. 2
      Sources/Plasma/Apps/plUruLauncher/Pch.h
  8. 8
      Sources/Plasma/CoreLib/CMakeLists.txt
  9. 2
      Sources/Plasma/CoreLib/HeadSpin.h
  10. 0
      Sources/Plasma/CoreLib/hsFiles.cpp
  11. 0
      Sources/Plasma/CoreLib/hsFiles.h
  12. 0
      Sources/Plasma/CoreLib/hsFiles_Mac.cpp
  13. 0
      Sources/Plasma/CoreLib/hsFiles_PS2.cpp
  14. 0
      Sources/Plasma/CoreLib/hsFiles_Unix.cpp
  15. 0
      Sources/Plasma/CoreLib/hsFiles_Win.cpp
  16. 72
      Sources/Plasma/CoreLib/hsStream.cpp
  17. 12
      Sources/Plasma/CoreLib/hsStream.h
  18. 62
      Sources/Plasma/CoreLib/plFileUtils.cpp
  19. 9
      Sources/Plasma/CoreLib/plFileUtils.h
  20. 62
      Sources/Plasma/CoreLib/plGeneric.cpp
  21. 15
      Sources/Plasma/CoreLib/plGeneric.h
  22. 179
      Sources/Plasma/CoreLib/plString.cpp
  23. 167
      Sources/Plasma/CoreLib/plString.h
  24. 6
      Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.cpp
  25. 1
      Sources/Plasma/FeatureLib/pfAnimation/plRandomCommandMod.cpp
  26. 1
      Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h
  27. 4
      Sources/Plasma/FeatureLib/pfCharacter/pfMarkerInfo.cpp
  28. 2
      Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp
  29. 4
      Sources/Plasma/FeatureLib/pfConsole/pfConsole.cpp
  30. 4
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp
  31. 6
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp
  32. 2
      Sources/Plasma/FeatureLib/pfCrashHandler/plCrashSrv.cpp
  33. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDialogMod.cpp
  34. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.cpp
  35. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIMultiLineEditCtrl.cpp
  36. 26
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUITextBoxMod.cpp
  37. 5
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUITextBoxMod.h
  38. 4
      Sources/Plasma/FeatureLib/pfGameScoreMgr/pfGameScoreMgr.cpp
  39. 18
      Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp
  40. 2
      Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp
  41. 15
      Sources/Plasma/FeatureLib/pfMessage/pfKIMsg.cpp
  42. 21
      Sources/Plasma/FeatureLib/pfMessage/pfKIMsg.h
  43. 4
      Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp
  44. 2
      Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp
  45. 28
      Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp
  46. 2
      Sources/Plasma/FeatureLib/pfPython/plPythonPack.cpp
  47. 6
      Sources/Plasma/FeatureLib/pfPython/plPythonParameter.h
  48. 6
      Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp
  49. 1
      Sources/Plasma/FeatureLib/pfPython/pyGUIControlTextBox.h
  50. 1
      Sources/Plasma/FeatureLib/pfPython/pyGUIPopUpMenu.h
  51. 4
      Sources/Plasma/FeatureLib/pfPython/pyGameScoreMsg.cpp
  52. 4
      Sources/Plasma/FeatureLib/pfPython/pyImageGlue.cpp
  53. 10
      Sources/Plasma/FeatureLib/pfPython/pyJournalBook.h
  54. 1
      Sources/Plasma/FeatureLib/pfPython/pyPlayer.h
  55. 2
      Sources/Plasma/FeatureLib/pfPython/pyPlayerGlue.cpp
  56. 2
      Sources/Plasma/FeatureLib/pfPython/pySceneObject.cpp
  57. 1
      Sources/Plasma/FeatureLib/pfPython/pySceneObject.h
  58. 6
      Sources/Plasma/FeatureLib/pfPython/pyStatusLog.cpp
  59. 4
      Sources/Plasma/FeatureLib/pfPython/pyVault.cpp
  60. 2
      Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.cpp
  61. 2
      Sources/Plasma/NucleusLib/pnDispatch/plDispatch.cpp
  62. 4
      Sources/Plasma/NucleusLib/pnKeyedObject/hsKeyedObject.cpp
  63. 77
      Sources/Plasma/NucleusLib/pnKeyedObject/plFixedKey.cpp
  64. 7
      Sources/Plasma/NucleusLib/pnKeyedObject/plKeyImp.cpp
  65. 4
      Sources/Plasma/NucleusLib/pnKeyedObject/plMsgForwarder.cpp
  66. 2
      Sources/Plasma/NucleusLib/pnModifier/plLogicModBase.cpp
  67. 2
      Sources/Plasma/NucleusLib/pnUUID/pnUUID_Unix.cpp
  68. 2
      Sources/Plasma/NucleusLib/pnUUID/pnUUID_Win32.cpp
  69. 2
      Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.cpp
  70. 4
      Sources/Plasma/PubUtilLib/plAgeDescription/plAgeManifest.cpp
  71. 2
      Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp
  72. 4
      Sources/Plasma/PubUtilLib/plAudio/plSound.cpp
  73. 2
      Sources/Plasma/PubUtilLib/plAudio/plWin32StreamingSound.cpp
  74. 4
      Sources/Plasma/PubUtilLib/plAudioCore/plAudioFileReader.cpp
  75. 4
      Sources/Plasma/PubUtilLib/plAudioCore/plSoundBuffer.cpp
  76. 6
      Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.cpp
  77. 4
      Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.h
  78. 4
      Sources/Plasma/PubUtilLib/plAvatar/plAGApplicator.h
  79. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAGChannel.cpp
  80. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp
  81. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp
  82. 16
      Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp
  83. 4
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp
  84. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.cpp
  85. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp
  86. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp
  87. 6
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp
  88. 4
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp
  89. 2
      Sources/Plasma/PubUtilLib/plAvatar/plMultistageBehMod.cpp
  90. 2
      Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.cpp
  91. 18
      Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpansExport.cpp
  92. 2
      Sources/Plasma/PubUtilLib/plDrawable/plInstanceDrawInterface.cpp
  93. 12
      Sources/Plasma/PubUtilLib/plDrawable/plProxyGen.cpp
  94. 10
      Sources/Plasma/PubUtilLib/plFile/CMakeLists.txt
  95. 61
      Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp
  96. 9
      Sources/Plasma/PubUtilLib/plFile/plSecureStream.h
  97. 2
      Sources/Plasma/PubUtilLib/plFile/plStreamSource.cpp
  98. 2
      Sources/Plasma/PubUtilLib/plGImage/plFontCache.cpp
  99. 2
      Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp
  100. 2
      Sources/Plasma/PubUtilLib/plGImage/plWinFontCache.cpp
  101. Some files were not shown because too many files have changed in this diff Show More

6
Sources/Plasma/Apps/plClient/plClient.cpp

@ -57,7 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsTimer.h" #include "hsTimer.h"
#include "plPipeline/hsG3DDeviceSelector.h" #include "plPipeline/hsG3DDeviceSelector.h"
#include "plFile/plEncryptedStream.h" #include "plFile/plEncryptedStream.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plInputCore/plInputManager.h" #include "plInputCore/plInputManager.h"
#include "plInputCore/plInputInterfaceMgr.h" #include "plInputCore/plInputInterfaceMgr.h"
#include "plInputCore/plInputDevice.h" #include "plInputCore/plInputDevice.h"
@ -83,7 +83,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pfConsole/pfConsoleDirSrc.h" #include "pfConsole/pfConsoleDirSrc.h"
#include "plScene/plPageTreeMgr.h" #include "plScene/plPageTreeMgr.h"
#include "plScene/plVisMgr.h" #include "plScene/plVisMgr.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "pfKI/pfKI.h" #include "pfKI/pfKI.h"
@ -1286,7 +1286,7 @@ void plClient::IRoomUnloaded(plSceneNode* node)
void plClient::IReadKeyedObjCallback(plKey key) void plClient::IReadKeyedObjCallback(plKey key)
{ {
fInstance->IIncProgress(1, _TEMP_CONVERT_TO_CONST_CHAR(key->GetName())); fInstance->IIncProgress(1, key->GetName().c_str());
} }
//============================================================================ //============================================================================

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

@ -71,7 +71,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "pnProduct/pnProduct.h" #include "pnProduct/pnProduct.h"
#include "plNetGameLib/plNetGameLib.h" #include "plNetGameLib/plNetGameLib.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plPhysX/plSimulationMgr.h" #include "plPhysX/plSimulationMgr.h"
@ -964,12 +964,12 @@ BOOL CALLBACK UruTOSDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
if (stream.Open("TOS.txt", "rt")) if (stream.Open("TOS.txt", "rt"))
{ {
uint32_t dataLen = stream.GetSizeLeft(); uint32_t dataLen = stream.GetSizeLeft();
char* eulaData = new char[dataLen + 1]; plStringBuffer<char> eula;
char* eulaData = eula.CreateWritableBuffer(dataLen);
memset(eulaData, 0, dataLen + 1); memset(eulaData, 0, dataLen + 1);
stream.Read(dataLen, eulaData); stream.Read(dataLen, eulaData);
plString str = plString::Steal(eulaData); SetDlgItemTextW(hwndDlg, IDC_URULOGIN_EULATEXT, plString(eula).ToWchar());
SetDlgItemTextW(hwndDlg, IDC_URULOGIN_EULATEXT, _TEMP_CONVERT_TO_WCHAR_T(str));
} }
else // no TOS found, go ahead else // no TOS found, go ahead
EndDialog(hwndDlg, true); EndDialog(hwndDlg, true);
@ -998,15 +998,15 @@ static void SaveUserPass (LoginDialogParam *pLoginParam, char *password)
memset(cryptKey, 0, sizeof(cryptKey)); memset(cryptKey, 0, sizeof(cryptKey));
GetCryptKey(cryptKey, arrsize(cryptKey)); GetCryptKey(cryptKey, arrsize(cryptKey));
plString theUser = _TEMP_CONVERT_FROM_LITERAL(pLoginParam->username); plString theUser = pLoginParam->username;
plString thePass = (_TEMP_CONVERT_FROM_LITERAL(password)).Left(kMaxPasswordLength); plString thePass = plString(password).Left(kMaxPasswordLength);
// if the password field is the fake string then we've already // if the password field is the fake string then we've already
// loaded the namePassHash from the file // loaded the namePassHash from the file
if (thePass.Compare(FAKE_PASS_STRING) != 0) if (thePass.Compare(FAKE_PASS_STRING) != 0)
{ {
wchar_t domain[15]; wchar_t domain[15];
PathSplitEmail(_TEMP_CONVERT_TO_WCHAR_T(theUser), nil, 0, domain, arrsize(domain), nil, 0, nil, 0, 0); PathSplitEmail(theUser.ToWchar(), nil, 0, domain, arrsize(domain), nil, 0, nil, 0, 0);
if (StrLen(domain) == 0 || StrCmpI(domain, L"gametap") == 0) { if (StrLen(domain) == 0 || StrCmpI(domain, L"gametap") == 0) {
plSHA1Checksum shasum(StrLen(password) * sizeof(password[0]), (uint8_t*)password); plSHA1Checksum shasum(StrLen(password) * sizeof(password[0]), (uint8_t*)password);
@ -1026,7 +1026,7 @@ static void SaveUserPass (LoginDialogParam *pLoginParam, char *password)
} }
} }
NetCommSetAccountUsernamePassword(_TEMP_CONVERT_TO_WCHAR_T(theUser), pLoginParam->namePassHash); NetCommSetAccountUsernamePassword(theUser.ToWchar(), pLoginParam->namePassHash);
if (TGIsCider) if (TGIsCider)
NetCommSetAuthTokenAndOS(nil, L"mac"); NetCommSetAuthTokenAndOS(nil, L"mac");
else else
@ -1436,7 +1436,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
if (!eventExists) // if it is missing, assume patcher wasn't launched if (!eventExists) // if it is missing, assume patcher wasn't launched
{ {
cmdLine << _TEMP_CONVERT_FROM_WCHAR_T(s_patcherExeName); cmdLine << plString::FromWchar(s_patcherExeName);
GetAuthSrvHostnames(&addrs); GetAuthSrvHostnames(&addrs);
if(strlen(addrs[0])) if(strlen(addrs[0]))

2
Sources/Plasma/Apps/plFileEncrypt/main.cpp

@ -39,7 +39,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021 Mead, WA 99021
*==LICENSE==*/ *==LICENSE==*/
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plFile/plEncryptedStream.h" #include "plFile/plEncryptedStream.h"
#include "pnProduct/pnProduct.h" #include "pnProduct/pnProduct.h"

16
Sources/Plasma/Apps/plFileSecure/main.cpp

@ -39,8 +39,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021 Mead, WA 99021
*==LICENSE==*/ *==LICENSE==*/
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plFile/plSecureStream.h" #include "plFile/plSecureStream.h"
#include "pnProduct/pnProduct.h" #include "pnProduct/pnProduct.h"
@ -61,15 +61,15 @@ void print_help() {
printf("\tplFileSecure (<directory> <ext>)|[/generate /default]\n"); printf("\tplFileSecure (<directory> <ext>)|[/generate /default]\n");
printf("\n"); printf("\n");
printf("<directory> <ext> : The directory and extension of files to secure. Cannot\n"); printf("<directory> <ext> : The directory and extension of files to secure. Cannot\n");
printf(" be used with /generate. Uses the %s file in\n", plFileUtils::kKeyFilename); printf(" be used with /generate. Uses the %s file in\n", plSecureStream::kKeyFilename);
printf(" the current directory (or default key if no file exists)\n"); printf(" the current directory (or default key if no file exists)\n");
printf("/generate : Generates a random key and writes it to a %s\n", plFileUtils::kKeyFilename); printf("/generate : Generates a random key and writes it to a %s\n", plSecureStream::kKeyFilename);
printf(" file in the current directory. Cannot be used with\n"); printf(" file in the current directory. Cannot be used with\n");
printf(" <directory> <ext>\n"); printf(" <directory> <ext>\n");
printf("/default : If used with /generate, creates a %s file\n", plFileUtils::kKeyFilename); printf("/default : If used with /generate, creates a %s file\n", plSecureStream::kKeyFilename);
printf(" with the default key. If used with <directory> <ext>, it\n"); printf(" with the default key. If used with <directory> <ext>, it\n");
printf(" secures with the default key instead of the\n"); printf(" secures with the default key instead of the\n");
printf(" %s file's key\n", plFileUtils::kKeyFilename); printf(" %s file's key\n", plSecureStream::kKeyFilename);
printf("\n"); printf("\n");
} }
@ -103,7 +103,7 @@ void GenerateKey(bool useDefault)
} }
hsUNIXStream out; hsUNIXStream out;
out.Open(plFileUtils::kKeyFilename, "wb"); out.Open(plSecureStream::kKeyFilename, "wb");
out.Write(sizeof(uint32_t) * arrsize(key), (void*)key); out.Write(sizeof(uint32_t) * arrsize(key), (void*)key);
out.Close(); out.Close();
} }
@ -204,7 +204,7 @@ int main(int argc, char *argv[])
else else
{ {
uint32_t key[4]; uint32_t key[4];
plFileUtils::GetSecureEncryptionKey(plFileUtils::kKeyFilename, key, arrsize(key)); plSecureStream::GetSecureEncryptionKey(plSecureStream::kKeyFilename, key, arrsize(key));
SecureFiles(directory, ext, key); SecureFiles(directory, ext, key);
} }
return 0; return 0;

4
Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp

@ -41,8 +41,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "hsTimer.h" #include "hsTimer.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plResMgr/plResManager.h" #include "plResMgr/plResManager.h"
#include "plResMgr/plResMgrSettings.h" #include "plResMgr/plResMgrSettings.h"

2
Sources/Plasma/Apps/plPythonPack/main.cpp

@ -42,7 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "PythonInterface.h" #include "PythonInterface.h"
#include "hsStream.h" #include "hsStream.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include <vector> #include <vector>
#include <string> #include <string>

2
Sources/Plasma/Apps/plUruLauncher/Pch.h

@ -62,7 +62,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnNetCli/pnNetCli.h" #include "pnNetCli/pnNetCli.h"
#include "plNetGameLib/plNetGameLib.h" #include "plNetGameLib/plNetGameLib.h"
#include "pnEncryption/plChecksum.h" #include "pnEncryption/plChecksum.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plCompression/plZlibStream.h" #include "plCompression/plZlibStream.h"
#include "plClientPatcher/UruPlayer.h" #include "plClientPatcher/UruPlayer.h"

8
Sources/Plasma/CoreLib/CMakeLists.txt

@ -1,3 +1,4 @@
include_directories(../PubUtilLib/plUnifiedTime) # EVIL: For plFileUtils.cpp
add_definitions(-D_LIB) add_definitions(-D_LIB)
if(NOT WCHAR_BYTES) if(NOT WCHAR_BYTES)
@ -19,6 +20,7 @@ set(CoreLib_SOURCES
hsCritSect.cpp hsCritSect.cpp
hsExceptionStack.cpp hsExceptionStack.cpp
hsFastMath.cpp hsFastMath.cpp
hsFiles.cpp
hsGeometry3.cpp hsGeometry3.cpp
hsMatrix33.cpp hsMatrix33.cpp
hsMatrix44.cpp hsMatrix44.cpp
@ -34,6 +36,7 @@ set(CoreLib_SOURCES
hsThread.cpp hsThread.cpp
hsWide.cpp hsWide.cpp
pcSmallRect.cpp pcSmallRect.cpp
plFileUtils.cpp
plGeneric.cpp plGeneric.cpp
plLoadMask.cpp plLoadMask.cpp
plString.cpp plString.cpp
@ -43,15 +46,16 @@ set(CoreLib_SOURCES
if(WIN32 AND NOT CYGWIN) if(WIN32 AND NOT CYGWIN)
set(CoreLib_SOURCES ${CoreLib_SOURCES} set(CoreLib_SOURCES ${CoreLib_SOURCES}
hsThread_Win.cpp hsThread_Win.cpp
hsFiles_Win.cpp
) )
endif(WIN32 AND NOT CYGWIN) endif(WIN32 AND NOT CYGWIN)
if(UNIX) if(UNIX)
set(CoreLib_SOURCES ${CoreLib_SOURCES} set(CoreLib_SOURCES ${CoreLib_SOURCES}
hsThread_Unix.cpp hsThread_Unix.cpp
hsFiles_Unix.cpp
) )
endif(UNIX) endif(UNIX)
set(CoreLib_HEADERS set(CoreLib_HEADERS
HeadSpin.h HeadSpin.h
hsBiExpander.h hsBiExpander.h
@ -62,6 +66,7 @@ set(CoreLib_HEADERS
hsCritSect.h hsCritSect.h
hsExceptions.h hsExceptions.h
hsFastMath.h hsFastMath.h
hsFiles.h
hsGeometry3.h hsGeometry3.h
hsHashTable.h hsHashTable.h
hsMatrix44.h hsMatrix44.h
@ -79,6 +84,7 @@ set(CoreLib_HEADERS
hsThread.h hsThread.h
hsWide.h hsWide.h
pcSmallRect.h pcSmallRect.h
plFileUtils.h
plGeneric.h plGeneric.h
plLoadMask.h plLoadMask.h
plQuality.h plQuality.h

2
Sources/Plasma/CoreLib/HeadSpin.h

@ -366,7 +366,7 @@ char * hsFormatStr(const char * fmt, ...); // You are responsible for returned
char * hsFormatStrV(const char * fmt, va_list args); // You are responsible for returned memory. char * hsFormatStrV(const char * fmt, va_list args); // You are responsible for returned memory.
// Use "correct" stricmp based on the selected compiler / library // Use "correct" stricmp based on the selected compiler / library
#if HS_BUILD_FOR_WIN32 #if _MSC_VER
# define stricmp _stricmp # define stricmp _stricmp
# define strnicmp _strnicmp # define strnicmp _strnicmp
# define wcsicmp _wcsicmp # define wcsicmp _wcsicmp

0
Sources/Plasma/PubUtilLib/plFile/hsFiles.cpp → Sources/Plasma/CoreLib/hsFiles.cpp

0
Sources/Plasma/PubUtilLib/plFile/hsFiles.h → Sources/Plasma/CoreLib/hsFiles.h

0
Sources/Plasma/PubUtilLib/plFile/hsFiles_Mac.cpp → Sources/Plasma/CoreLib/hsFiles_Mac.cpp

0
Sources/Plasma/PubUtilLib/plFile/hsFiles_PS2.cpp → Sources/Plasma/CoreLib/hsFiles_PS2.cpp

0
Sources/Plasma/PubUtilLib/plFile/hsFiles_Unix.cpp → Sources/Plasma/CoreLib/hsFiles_Unix.cpp

0
Sources/Plasma/PubUtilLib/plFile/hsFiles_Win.cpp → Sources/Plasma/CoreLib/hsFiles_Win.cpp

72
Sources/Plasma/CoreLib/hsStream.cpp

@ -139,40 +139,35 @@ uint32_t hsStream::WriteFmtV(const char * fmt, va_list av)
return Write( buf.length(), buf.data() ); return Write( buf.length(), buf.data() );
} }
uint32_t hsStream::WriteSafeStringLong(const char *string) uint32_t hsStream::WriteSafeStringLong(const plString &string)
{ {
uint32_t len = 0; uint32_t len = string.GetSize();
if (string)
len = strlen(string);
WriteLE32(len); WriteLE32(len);
if (len > 0) if (len > 0)
{ {
char *buff = new char[len+1]; const char *buffp = string.c_str();
int i; uint32_t i;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
buff[i] = ~string[i]; WriteByte(~buffp[i]);
} }
buff[len] = '\0'; return i;
uint32_t result = Write(len, buff);
delete [] buff;
return result;
} }
else else
return 0; return 0;
} }
uint32_t hsStream::WriteSafeWStringLong(const wchar_t *string) uint32_t hsStream::WriteSafeWStringLong(const plString &string)
{ {
uint32_t len = wcslen(string); plStringBuffer<wchar_t> wbuff = string.ToWchar();
uint32_t len = wbuff.GetSize();
WriteLE32(len); WriteLE32(len);
if (len > 0) if (len > 0)
{ {
int i; const wchar_t *buffp = wbuff.GetData();
for (i=0; i<len; i++) for (uint32_t i=0; i<len; i++)
{ {
wchar_t buff = ~string[i]; WriteLE16((uint16_t)~buffp[i]);
WriteLE16((uint16_t)buff);
} }
WriteLE16((uint16_t)L'\0'); WriteLE16((uint16_t)L'\0');
} }
@ -224,46 +219,41 @@ wchar_t *hsStream::ReadSafeWStringLong()
return retVal; return retVal;
} }
uint32_t hsStream::WriteSafeString(const char *string) uint32_t hsStream::WriteSafeString(const plString &string)
{ {
int len = 0; int len = string.GetSize();
if (string) hsAssert(len<0xf000, plString::Format("string len of %d is too long for WriteSafeString %s, use WriteSafeStringLong",
len = strlen(string); len, string.c_str()).c_str() );
hsAssert(len<0xf000, xtl::format("string len of %d is too long for WriteSafeString %s, use WriteSafeStringLong",
string, len).c_str() );
WriteLE16(len | 0xf000); WriteLE16(len | 0xf000);
if (len > 0) if (len > 0)
{ {
char *buff = new char[len+1]; uint32_t i;
int i; const char *buffp = string.c_str();
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
buff[i] = ~string[i]; WriteByte(~buffp[i]);
} }
buff[len] = '\0'; return i;
uint32_t result = Write(len, buff);
delete [] buff;
return result;
} }
else else
return 0; return 0;
} }
uint32_t hsStream::WriteSafeWString(const wchar_t *string) uint32_t hsStream::WriteSafeWString(const plString &string)
{ {
int len = wcslen(string); plStringBuffer<wchar_t> wbuff = string.ToWchar();
uint32_t len = wbuff.GetSize();
hsAssert(len<0xf000, xtl::format("string len of %d is too long for WriteSafeWString, use WriteSafeWStringLong", hsAssert(len<0xf000, xtl::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)
{ {
int i; const wchar_t *buffp = wbuff.GetData();
for (i=0; i<len; i++) for (uint32_t i=0; i<len; i++)
{ {
wchar_t buff = ~string[i]; WriteLE16((uint16_t)~buffp[i]);
WriteLE16((uint16_t)buff);
} }
WriteLE16((uint16_t)L'\0'); WriteLE16((uint16_t)L'\0');
} }
@ -328,16 +318,6 @@ wchar_t *hsStream::ReadSafeWString()
return retVal; return retVal;
} }
uint32_t hsStream::WriteSafeString(const plString &string)
{
return WriteSafeString(_TEMP_CONVERT_TO_CONST_CHAR(string));
}
uint32_t hsStream::WriteSafeWString(const plString &string)
{
return WriteSafeWString(_TEMP_CONVERT_TO_WCHAR_T(string));
}
plString hsStream::ReadSafeString_TEMP() plString hsStream::ReadSafeString_TEMP()
{ {
char *buffer = ReadSafeString(); char *buffer = ReadSafeString();

12
Sources/Plasma/CoreLib/hsStream.h

@ -124,22 +124,20 @@ public:
virtual bool IsCompressed() { return false; } virtual bool IsCompressed() { return false; }
uint32_t WriteString(const char cstring[]); uint32_t WriteString(const char cstring[]);
uint32_t WriteString(const plString & string) { return WriteString(_TEMP_CONVERT_TO_CONST_CHAR(string)); } 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);
uint32_t WriteSafeStringLong(const char *string); // uses 4 bytes for length uint32_t WriteSafeStringLong(const plString &string); // uses 4 bytes for length
uint32_t WriteSafeWStringLong(const wchar_t *string); uint32_t WriteSafeWStringLong(const plString &string);
char * ReadSafeStringLong(); char * ReadSafeStringLong();
wchar_t * ReadSafeWStringLong(); wchar_t * ReadSafeWStringLong();
uint32_t WriteSafeString(const char *string); // uses 2 bytes for length uint32_t WriteSafeString(const plString &string); // uses 2 bytes for length
uint32_t WriteSafeWString(const wchar_t *string); uint32_t WriteSafeWString(const plString &string);
char * ReadSafeString(); char * ReadSafeString();
wchar_t * ReadSafeWString(); wchar_t * ReadSafeWString();
uint32_t WriteSafeString(const plString &string); // uses 2 bytes for length
uint32_t WriteSafeWString(const plString &string);
plString ReadSafeString_TEMP(); plString ReadSafeString_TEMP();
plString ReadSafeWString_TEMP(); plString ReadSafeWString_TEMP();

62
Sources/Plasma/PubUtilLib/plFile/plFileUtils.cpp → Sources/Plasma/CoreLib/plFileUtils.cpp

@ -57,9 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsStringTokenizer.h" #include "hsStringTokenizer.h"
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime.h"
#include "plSecureStream.h" // for the default key
#include <time.h> #include <time.h>
#include <sys/types.h> #include <sys/types.h>
@ -503,61 +501,3 @@ uint32_t plFileUtils::GetFileSize( const wchar_t *path )
return len; return len;
} }
//// GetSecureEncryptionKey //////////////////////////////////////////////////
bool plFileUtils::GetSecureEncryptionKey(const char* filename, uint32_t* key, unsigned length)
{
wchar_t* wFilename = hsStringToWString(filename);
bool ret = GetSecureEncryptionKey(wFilename, key, length);
delete [] wFilename;
return ret;
}
bool plFileUtils::GetSecureEncryptionKey(const wchar_t* filename, uint32_t* key, unsigned length)
{
// looks for an encryption key file in the same directory, and reads it
std::wstring sFilename = filename;
// grab parent directory
size_t loc = sFilename.rfind(L"\\");
if (loc == std::wstring::npos)
loc = sFilename.rfind(L"/");
std::wstring sDir;
if (loc != std::wstring::npos)
sDir = sFilename.substr(0, loc);
else // no directory
sDir = L"./";
if ((sDir[sDir.length()-1] != L'/') && (sDir[sDir.length()-1] != L'\\'))
sDir += L'/'; // add the slash, if it doesn't has one
// now add the key filename
std::wstring keyFile = sDir + kWKeyFilename;
if (FileExists(keyFile.c_str()))
{
// file exists, read from it
hsUNIXStream file;
file.Open(keyFile.c_str(), L"rb");
unsigned bytesToRead = length * sizeof(uint32_t);
uint8_t* buffer = (uint8_t*)malloc(bytesToRead);
unsigned bytesRead = file.Read(bytesToRead, buffer);
file.Close();
unsigned memSize = min(bytesToRead, bytesRead);
memcpy(key, buffer, memSize);
free(buffer);
return true;
}
// file doesn't exist, use default key
unsigned memSize = min(length, arrsize(plSecureStream::kDefaultKey));
memSize *= sizeof(uint32_t);
memcpy(key, plSecureStream::kDefaultKey, memSize);
return false;
}

9
Sources/Plasma/PubUtilLib/plFile/plFileUtils.h → Sources/Plasma/CoreLib/plFileUtils.h

@ -56,9 +56,6 @@ class plUnifiedTime;
namespace plFileUtils namespace plFileUtils
{ {
static const char kKeyFilename[] = "encryption.key";
static const wchar_t kWKeyFilename[] = L"encryption.key";
// Creates the directory specified. Returns false if unsuccessful or directory already exists // Creates the directory specified. Returns false if unsuccessful or directory already exists
bool CreateDir( const char *path ); bool CreateDir( const char *path );
bool CreateDir( const wchar_t *path ); bool CreateDir( const wchar_t *path );
@ -113,12 +110,6 @@ namespace plFileUtils
// Concatenates fileName onto path, making sure to add a slash if necessary // Concatenates fileName onto path, making sure to add a slash if necessary
void ConcatFileName(char* path, const char* fileName); void ConcatFileName(char* path, const char* fileName);
void ConcatFileName(wchar_t* path, const wchar_t* fileName); void ConcatFileName(wchar_t* path, const wchar_t* fileName);
// searches the parent directory of filename for the encryption key file, and reads it
// into the key passed in. Returns false if the key file didn't exist (and sets key to
// the default key)
bool GetSecureEncryptionKey(const char* filename, uint32_t* key, unsigned length);
bool GetSecureEncryptionKey(const wchar_t* filename, uint32_t* key, unsigned length);
}; };

62
Sources/Plasma/CoreLib/plGeneric.cpp

@ -50,24 +50,7 @@ plGeneric::plGeneric(const int& val): fType(kInt), fBoolVal(false), fIntVal(val)
plGeneric::plGeneric(const double& val): fType(kFloat), fBoolVal(false), fIntVal(0), fFloatVal(val) {} plGeneric::plGeneric(const double& val): fType(kFloat), fBoolVal(false), fIntVal(0), fFloatVal(val) {}
plGeneric::plGeneric(const char* val): fType(kString), fBoolVal(false), fIntVal(0), fFloatVal(0.0) plGeneric::plGeneric(const plString& val): fType(kString), fBoolVal(false), fIntVal(0), fFloatVal(0.0),
{
wchar_t* temp = hsStringToWString(val);
fStringVal = temp;
delete [] temp;
}
plGeneric::plGeneric(const std::string& val): fType(kString), fBoolVal(false), fIntVal(0), fFloatVal(0.0)
{
wchar_t* temp = hsStringToWString(val.c_str());
fStringVal = temp;
delete [] temp;
}
plGeneric::plGeneric(const wchar_t* val): fType(kString), fBoolVal(false), fIntVal(0), fFloatVal(0.0),
fStringVal(val) {}
plGeneric::plGeneric(const std::wstring& val): fType(kString), fBoolVal(false), fIntVal(0), fFloatVal(0.0),
fStringVal(val) {} fStringVal(val) {}
void plGeneric::IReset() void plGeneric::IReset()
@ -76,7 +59,7 @@ void plGeneric::IReset()
fBoolVal = false; fBoolVal = false;
fIntVal = 0; fIntVal = 0;
fFloatVal = 0.0; fFloatVal = 0.0;
fStringVal = L""; fStringVal = "";
} }
plGeneric& plGeneric::operator=(const bool& val) plGeneric& plGeneric::operator=(const bool& val)
@ -103,35 +86,7 @@ plGeneric& plGeneric::operator=(const double& val)
return *this; return *this;
} }
plGeneric& plGeneric::operator=(const char* val) plGeneric& plGeneric::operator=(const plString& val)
{
IReset();
fType = kString;
wchar_t* temp = hsStringToWString(val);
fStringVal = temp;
delete [] temp;
return *this;
}
plGeneric& plGeneric::operator=(const std::string& val)
{
IReset();
fType = kString;
wchar_t* temp = hsStringToWString(val.c_str());
fStringVal = temp;
delete [] temp;
return *this;
}
plGeneric& plGeneric::operator=(const wchar_t* val)
{
IReset();
fType = kString;
fStringVal = val;
return *this;
}
plGeneric& plGeneric::operator=(const std::wstring& val)
{ {
IReset(); IReset();
fType = kString; fType = kString;
@ -161,7 +116,7 @@ int plGeneric::Write(hsStream* stream)
break; break;
case kString: case kString:
stream->WriteSafeWString(fStringVal.c_str()); stream->WriteSafeWString(fStringVal);
break; break;
} }
return stream->GetPosition(); return stream->GetPosition();
@ -189,14 +144,7 @@ int plGeneric::Read(hsStream* stream)
break; break;
case kString: case kString:
{ fStringVal = stream->ReadSafeWString_TEMP();
wchar_t* temp = stream->ReadSafeWString();
if (temp)
{
fStringVal = temp;
delete [] temp;
}
}
break; break;
} }
return stream->GetPosition(); return stream->GetPosition();

15
Sources/Plasma/CoreLib/plGeneric.h

@ -62,7 +62,7 @@ private:
bool fBoolVal; bool fBoolVal;
int fIntVal; int fIntVal;
double fFloatVal; double fFloatVal;
std::wstring fStringVal; plString fStringVal;
void IReset(); void IReset();
@ -71,19 +71,13 @@ public:
plGeneric(const bool& val); plGeneric(const bool& val);
plGeneric(const int& val); plGeneric(const int& val);
plGeneric(const double& val); plGeneric(const double& val);
plGeneric(const char* val); plGeneric(const plString& val);
plGeneric(const std::string& val);
plGeneric(const wchar_t* val);
plGeneric(const std::wstring& val);
void SetToNull() {IReset();} void SetToNull() {IReset();}
plGeneric& operator=(const bool& val); plGeneric& operator=(const bool& val);
plGeneric& operator=(const int& val); plGeneric& operator=(const int& val);
plGeneric& operator=(const double& val); plGeneric& operator=(const double& val);
plGeneric& operator=(const char* val); plGeneric& operator=(const plString& val);
plGeneric& operator=(const std::string& val);
plGeneric& operator=(const wchar_t* val);
plGeneric& operator=(const std::wstring& val);
// the cast functions will NOT cast from one type to another, use // the cast functions will NOT cast from one type to another, use
// GetType() to determine the type of parameter, then cast it to that type // GetType() to determine the type of parameter, then cast it to that type
@ -91,8 +85,7 @@ public:
operator bool() const {return fBoolVal;} operator bool() const {return fBoolVal;}
operator int() const {return fIntVal;} operator int() const {return fIntVal;}
operator double() const {return fFloatVal;} operator double() const {return fFloatVal;}
operator const wchar_t*() const {return fStringVal.c_str();} operator plString() const {return fStringVal;}
operator std::wstring() const {return fStringVal;}
int Write(hsStream* stream); int Write(hsStream* stream);
int Read(hsStream* stream); int Read(hsStream* stream);

179
Sources/Plasma/CoreLib/plString.cpp

@ -16,6 +16,22 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at: or by snail mail at:
Cyan Worlds, Inc. Cyan Worlds, Inc.
@ -29,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <cstring> #include <cstring>
#include <cstdlib> #include <cstdlib>
#include <wchar.h> #include <wchar.h>
#include <memory>
const plString plString::Null; const plString plString::Null;
@ -67,7 +84,7 @@ size_t wcsnlen(const wchar_t *s, size_t maxlen)
#define BADCHAR_REPLACEMENT (0xFFFDul) #define BADCHAR_REPLACEMENT (0xFFFDul)
void plString::IConvertFromUtf8(const char *utf8, size_t size, bool steal) void plString::IConvertFromUtf8(const char *utf8, size_t size)
{ {
if (utf8 == nil) { if (utf8 == nil) {
fUtf8Buffer = plStringBuffer<char>(); fUtf8Buffer = plStringBuffer<char>();
@ -77,10 +94,17 @@ void plString::IConvertFromUtf8(const char *utf8, size_t size, bool steal)
if ((int32_t)size < 0) if ((int32_t)size < 0)
size = strnlen(utf8, -(int32_t)size); size = strnlen(utf8, -(int32_t)size);
operator=(plStringBuffer<char>(utf8, size));
}
plString &plString::operator=(const plStringBuffer<char> &init)
{
fUtf8Buffer = init;
#ifdef _DEBUG #ifdef _DEBUG
// Check to make sure the string is actually valid UTF-8 // Check to make sure the string is actually valid UTF-8
const char *sp = utf8; const char *sp = fUtf8Buffer.GetData();
while (sp < utf8 + size) { while (sp < fUtf8Buffer.GetData() + fUtf8Buffer.GetSize()) {
unsigned char unichar = *sp++; unsigned char unichar = *sp++;
if ((unichar & 0xF8) == 0xF0) { if ((unichar & 0xF8) == 0xF0) {
// Four bytes // Four bytes
@ -102,16 +126,14 @@ void plString::IConvertFromUtf8(const char *utf8, size_t size, bool steal)
} }
#endif #endif
fUtf8Buffer = steal ? plStringBuffer<char>::Steal(utf8, size) return *this;
: plStringBuffer<char>(utf8, size);
} }
void plString::IConvertFromUtf16(const uint16_t *utf16, size_t size) void plString::IConvertFromUtf16(const uint16_t *utf16, size_t size)
{ {
if (utf16 == nil) {
fUtf8Buffer = plStringBuffer<char>(); fUtf8Buffer = plStringBuffer<char>();
if (utf16 == nil)
return; return;
}
if ((int32_t)size < 0) if ((int32_t)size < 0)
size = u16slen(utf16, -(int32_t)size); size = u16slen(utf16, -(int32_t)size);
@ -135,7 +157,7 @@ void plString::IConvertFromUtf16(const uint16_t *utf16, size_t size)
} }
// And perform the actual conversion // And perform the actual conversion
char *utf8 = new char[convlen + 1]; char *utf8 = fUtf8Buffer.CreateWritableBuffer(convlen);
char *dp = utf8; char *dp = utf8;
sp = utf16; sp = utf16;
while (sp < utf16 + size) { while (sp < utf16 + size) {
@ -174,8 +196,6 @@ void plString::IConvertFromUtf16(const uint16_t *utf16, size_t size)
++sp; ++sp;
} }
utf8[convlen] = 0; utf8[convlen] = 0;
fUtf8Buffer = plStringBuffer<char>::Steal(utf8, convlen);
} }
void plString::IConvertFromWchar(const wchar_t *wstr, size_t size) void plString::IConvertFromWchar(const wchar_t *wstr, size_t size)
@ -184,10 +204,9 @@ void plString::IConvertFromWchar(const wchar_t *wstr, size_t size)
// We assume that if sizeof(wchar_t) == 2, the data is UTF-16 already // We assume that if sizeof(wchar_t) == 2, the data is UTF-16 already
IConvertFromUtf16((const uint16_t *)wstr, size); IConvertFromUtf16((const uint16_t *)wstr, size);
#else #else
if (wstr == nil) {
fUtf8Buffer = plStringBuffer<char>(); fUtf8Buffer = plStringBuffer<char>();
if (wstr == nil)
return; return;
}
if ((int32_t)size < 0) if ((int32_t)size < 0)
size = wcsnlen(wstr, -(int32_t)size); size = wcsnlen(wstr, -(int32_t)size);
@ -212,7 +231,7 @@ void plString::IConvertFromWchar(const wchar_t *wstr, size_t size)
} }
// And perform the actual conversion // And perform the actual conversion
char *utf8 = new char[convlen + 1]; char *utf8 = fUtf8Buffer.CreateWritableBuffer(convlen);
char *dp = utf8; char *dp = utf8;
sp = wstr; sp = wstr;
while (sp < wstr + size) { while (sp < wstr + size) {
@ -239,17 +258,14 @@ void plString::IConvertFromWchar(const wchar_t *wstr, size_t size)
++sp; ++sp;
} }
utf8[convlen] = 0; utf8[convlen] = 0;
fUtf8Buffer = plStringBuffer<char>::Steal(utf8, convlen);
#endif #endif
} }
void plString::IConvertFromIso8859_1(const char *astr, size_t size) void plString::IConvertFromIso8859_1(const char *astr, size_t size)
{ {
if (astr == nil) {
fUtf8Buffer = plStringBuffer<char>(); fUtf8Buffer = plStringBuffer<char>();
if (astr == nil)
return; return;
}
if ((int32_t)size < 0) if ((int32_t)size < 0)
size = strnlen(astr, -(int32_t)size); size = strnlen(astr, -(int32_t)size);
@ -265,7 +281,7 @@ void plString::IConvertFromIso8859_1(const char *astr, size_t size)
} }
// And perform the actual conversion // And perform the actual conversion
char *utf8 = new char[convlen + 1]; char *utf8 = fUtf8Buffer.CreateWritableBuffer(convlen);
char *dp = utf8; char *dp = utf8;
sp = astr; sp = astr;
while (sp < astr + size) { while (sp < astr + size) {
@ -278,14 +294,13 @@ void plString::IConvertFromIso8859_1(const char *astr, size_t size)
++sp; ++sp;
} }
utf8[convlen] = 0; utf8[convlen] = 0;
fUtf8Buffer = plStringBuffer<char>::Steal(utf8, convlen);
} }
plStringBuffer<uint16_t> plString::ToUtf16() const plStringBuffer<uint16_t> plString::ToUtf16() const
{ {
if (IsNull()) plStringBuffer<uint16_t> result;
return plStringBuffer<uint16_t>(); if (IsEmpty())
return result;
// Calculate the UTF-16 size // Calculate the UTF-16 size
size_t convlen = 0; size_t convlen = 0;
@ -308,7 +323,7 @@ plStringBuffer<uint16_t> plString::ToUtf16() const
} }
// And perform the actual conversion // And perform the actual conversion
uint16_t *ustr = new uint16_t[convlen + 1]; uint16_t *ustr = result.CreateWritableBuffer(convlen);
uint16_t *dp = ustr; uint16_t *dp = ustr;
sp = utf8; sp = utf8;
while (sp < utf8 + srcSize) { while (sp < utf8 + srcSize) {
@ -336,7 +351,7 @@ plStringBuffer<uint16_t> plString::ToUtf16() const
} }
ustr[convlen] = 0; ustr[convlen] = 0;
return plStringBuffer<uint16_t>::Steal(ustr, convlen); return result;
} }
plStringBuffer<wchar_t> plString::ToWchar() const plStringBuffer<wchar_t> plString::ToWchar() const
@ -346,8 +361,9 @@ plStringBuffer<wchar_t> plString::ToWchar() const
plStringBuffer<uint16_t> utf16 = ToUtf16(); plStringBuffer<uint16_t> utf16 = ToUtf16();
return *reinterpret_cast<plStringBuffer<wchar_t>*>(&utf16); return *reinterpret_cast<plStringBuffer<wchar_t>*>(&utf16);
#else #else
if (IsNull()) plStringBuffer<uint16_t> result;
return plStringBuffer<wchar_t>(); if (IsEmpty())
return result;
// Calculate the UCS-4 size // Calculate the UCS-4 size
size_t convlen = 0; size_t convlen = 0;
@ -367,7 +383,7 @@ plStringBuffer<wchar_t> plString::ToWchar() const
} }
// And perform the actual conversion // And perform the actual conversion
wchar_t *wstr = new wchar_t[convlen + 1]; wchar_t *wstr = result.CreateWritableBuffer(convlen);
wchar_t *dp = wstr; wchar_t *dp = wstr;
sp = utf8; sp = utf8;
while (sp < utf8 + srcSize) { while (sp < utf8 + srcSize) {
@ -391,14 +407,15 @@ plStringBuffer<wchar_t> plString::ToWchar() const
} }
wstr[convlen] = 0; wstr[convlen] = 0;
return plStringBuffer<wchar_t>::Steal(wstr, convlen); return result;
#endif #endif
} }
plStringBuffer<char> plString::ToIso8859_1() const plStringBuffer<char> plString::ToIso8859_1() const
{ {
if (IsNull()) plStringBuffer<char> result;
return plStringBuffer<char>(); if (IsEmpty())
return result;
// Calculate the ASCII size // Calculate the ASCII size
size_t convlen = 0; size_t convlen = 0;
@ -418,7 +435,7 @@ plStringBuffer<char> plString::ToIso8859_1() const
} }
// And perform the actual conversion // And perform the actual conversion
char *astr = new char[convlen + 1]; char *astr = result.CreateWritableBuffer(convlen);
char *dp = astr; char *dp = astr;
sp = utf8; sp = utf8;
while (sp < utf8 + srcSize) { while (sp < utf8 + srcSize) {
@ -442,45 +459,45 @@ plStringBuffer<char> plString::ToIso8859_1() const
} }
astr[convlen] = 0; astr[convlen] = 0;
return plStringBuffer<char>::Steal(astr, convlen); return result;
} }
plStringBuffer<UniChar> plString::GetUnicodeArray() const plStringBuffer<UniChar> plString::GetUnicodeArray() const
{ {
static UniChar empty[1] = {0}; plStringBuffer<UniChar> result;
if (IsEmpty())
if (IsNull()) return result;
return plStringBuffer<UniChar>(empty, 0);
size_t convlen = GetUniCharCount(); size_t convlen = GetUniCharCount();
UniChar *ustr = new UniChar[convlen + 1]; UniChar *ustr = result.CreateWritableBuffer(convlen);
iterator iter = GetIterator(); iterator iter = GetIterator();
size_t dp = 0; size_t dp = 0;
while (!iter.AtEnd()) while (!iter.AtEnd())
ustr[dp++] = *iter++; ustr[dp++] = *iter++;
ustr[convlen] = 0; ustr[convlen] = 0;
return plStringBuffer<UniChar>::Steal(ustr, convlen);
return result;
} }
int plString::ToInt(int base) const int plString::ToInt(int base) const
{ {
return static_cast<int>(strtol(s_str(), nil, base)); return static_cast<int>(strtol(c_str(), nil, base));
} }
unsigned int plString::ToUInt(int base) const unsigned int plString::ToUInt(int base) const
{ {
return static_cast<unsigned int>(strtoul(s_str(), nil, base)); return static_cast<unsigned int>(strtoul(c_str(), nil, base));
} }
float plString::ToFloat() const float plString::ToFloat() const
{ {
// strtof is C99, which MS doesn't support... // strtof is C99, which MS doesn't support...
return (float)strtod(s_str(), nil); return (float)strtod(c_str(), nil);
} }
double plString::ToDouble() const double plString::ToDouble() const
{ {
return strtod(s_str(), nil); return strtod(c_str(), nil);
} }
// Microsoft doesn't provide this for us // Microsoft doesn't provide this for us
@ -501,22 +518,21 @@ plString plString::IFormat(const char *fmt, va_list vptr)
int size = 4096; int size = 4096;
for ( ;; ) { for ( ;; ) {
va_copy(vptr, vptr_save); va_copy(vptr, vptr_save);
char *bigbuffer = new char[size]; std::auto_ptr<char> bigbuffer(new char[size]);
chars = vsnprintf(bigbuffer, size, fmt, vptr); chars = vsnprintf(bigbuffer.get(), size, fmt, vptr);
if (chars >= 0) if (chars >= 0)
return plString::Steal(bigbuffer); return plString::FromUtf8(bigbuffer.get(), chars);
delete [] bigbuffer;
size *= 2; size *= 2;
} }
} else if (chars >= 256) { } else if (chars >= 256) {
va_copy(vptr, vptr_save); va_copy(vptr, vptr_save);
char *bigbuffer = new char[chars+1]; std::auto_ptr<char> bigbuffer(new char[chars+1]);
vsnprintf(bigbuffer, chars+1, fmt, vptr); vsnprintf(bigbuffer.get(), chars+1, fmt, vptr);
return plString::Steal(bigbuffer); return plString::FromUtf8(bigbuffer.get(), chars);
} }
return plString::FromUtf8(buffer); return plString::FromUtf8(buffer, chars);
} }
plString plString::Format(const char *fmt, ...) plString plString::Format(const char *fmt, ...)
@ -531,11 +547,10 @@ plString plString::Format(const char *fmt, ...)
int plString::Find(char ch, CaseSensitivity sense) const int plString::Find(char ch, CaseSensitivity sense) const
{ {
if (sense == kCaseSensitive) { if (sense == kCaseSensitive) {
const char *cp = strchr(s_str(), ch); const char *cp = strchr(c_str(), ch);
return cp ? (cp - c_str()) : -1; return cp ? (cp - c_str()) : -1;
} else { } else {
// No need to check for null, since s_str() will return { 0 } if it is null const char *cp = c_str();
const char *cp = s_str();
while (*cp) { while (*cp) {
if (tolower(*cp) == tolower(ch)) if (tolower(*cp) == tolower(ch))
return cp - c_str(); return cp - c_str();
@ -550,7 +565,7 @@ int plString::FindLast(char ch, CaseSensitivity sense) const
return -1; return -1;
if (sense == kCaseSensitive) { if (sense == kCaseSensitive) {
const char *cp = strrchr(s_str(), ch); const char *cp = strrchr(c_str(), ch);
return cp ? (cp - c_str()) : -1; return cp ? (cp - c_str()) : -1;
} else { } else {
const char *cp = c_str(); const char *cp = c_str();
@ -570,7 +585,7 @@ int plString::Find(const char *str, CaseSensitivity sense) const
return -1; return -1;
if (sense == kCaseSensitive) { if (sense == kCaseSensitive) {
const char *cp = strstr(s_str(), str); const char *cp = strstr(c_str(), str);
return cp ? (cp - c_str()) : -1; return cp ? (cp - c_str()) : -1;
} else { } else {
// The easy way // The easy way
@ -651,69 +666,49 @@ plString plString::Substr(int start, size_t size) const
if (start == 0 && size == maxSize) if (start == 0 && size == maxSize)
return *this; return *this;
char *substr = new char[size + 1]; plString sub;
char *substr = sub.fUtf8Buffer.CreateWritableBuffer(size);
memcpy(substr, c_str() + start, size); memcpy(substr, c_str() + start, size);
substr[size] = 0; substr[size] = 0;
// Don't re-check UTF-8 on this return sub;
plString str;
str.fUtf8Buffer = plStringBuffer<char>::Steal(substr, size);
return str;
} }
plString plString::ToUpper() const plString plString::ToUpper() const
{ {
// TODO: Unicode-aware case conversion // TODO: Unicode-aware case conversion
size_t size = GetSize(); plString str;
char *dupe = new char[size + 1]; char *dupe = str.fUtf8Buffer.CreateWritableBuffer(fUtf8Buffer.GetSize());
const char *self = c_str(); const char *self = c_str();
for (size_t i = 0; i < size; ++i) for (size_t i = 0; i < fUtf8Buffer.GetSize(); ++i)
dupe[i] = toupper(self[i]); dupe[i] = toupper(self[i]);
dupe[fUtf8Buffer.GetSize()] = 0;
// Don't re-check UTF-8 on this
plString str;
str.fUtf8Buffer = plStringBuffer<char>::Steal(dupe, size);
return str; return str;
} }
plString plString::ToLower() const plString plString::ToLower() const
{ {
// TODO: Unicode-aware case conversion // TODO: Unicode-aware case conversion
size_t size = GetSize(); plString str;
char *dupe = new char[size + 1]; char *dupe = str.fUtf8Buffer.CreateWritableBuffer(fUtf8Buffer.GetSize());
const char *self = c_str(); const char *self = c_str();
for (size_t i = 0; i < size; ++i) for (size_t i = 0; i < fUtf8Buffer.GetSize(); ++i)
dupe[i] = tolower(self[i]); dupe[i] = tolower(self[i]);
dupe[fUtf8Buffer.GetSize()] = 0;
// Don't re-check UTF-8 on this
plString str;
str.fUtf8Buffer = plStringBuffer<char>::Steal(dupe, size);
return str; return str;
} }
plString &plString::operator+=(const plString &str)
{
size_t catsize = GetSize() + str.GetSize();
char *catstr = new char[catsize + 1];
memcpy(catstr, s_str(), GetSize());
memcpy(catstr + GetSize(), str.s_str(), str.GetSize());
catstr[catsize] = 0;
fUtf8Buffer = plStringBuffer<char>::Steal(catstr, catsize);
return *this;
}
plString operator+(const plString &left, const plString &right) plString operator+(const plString &left, const plString &right)
{ {
size_t catsize = left.GetSize() + right.GetSize(); plString cat;
char *catstr = new char[catsize + 1]; char *catstr = cat.fUtf8Buffer.CreateWritableBuffer(left.GetSize() + right.GetSize());
memcpy(catstr, left.s_str(), left.GetSize()); memcpy(catstr, left.c_str(), left.GetSize());
memcpy(catstr + left.GetSize(), right.s_str(), right.GetSize()); memcpy(catstr + left.GetSize(), right.c_str(), right.GetSize());
catstr[catsize] = 0; catstr[cat.fUtf8Buffer.GetSize()] = 0;
// Don't re-check UTF-8 on this return cat;
plString str;
str.fUtf8Buffer = plStringBuffer<char>::Steal(catstr, catsize);
return str;
} }
plStringStream &plStringStream::append(const char *data, size_t length) plStringStream &plStringStream::append(const char *data, size_t length)

167
Sources/Plasma/CoreLib/plString.h

@ -16,6 +16,22 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at: or by snail mail at:
Cyan Worlds, Inc. Cyan Worlds, Inc.
@ -29,21 +45,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include <stddef.h> #include <stddef.h>
#include <vector>
#include <functional>
/* NOTE & TODO:
* These macros are intentionally annoyingly named, to mark what code
* needs to be cleaned up after a larger portion of Plasma is converted
* to plString.
*/
#define _TEMP_CONVERT_FROM_LITERAL(x) plString::FromUtf8((x))
#define _TEMP_CONVERT_FROM_WCHAR_T(x) plString::FromWchar((x))
#define _TEMP_CONVERT_TO_CONST_CHAR(x) ((x).c_str())
#define _TEMP_CONVERT_TO_WCHAR_T(x) ((x).ToWchar().GetData())
typedef unsigned int UniChar; typedef unsigned int UniChar;
#define SSO_CHARS (16)
template <typename _Ch> template <typename _Ch>
class plStringBuffer class plStringBuffer
{ {
@ -52,10 +58,9 @@ private:
{ {
unsigned int fRefs; unsigned int fRefs;
const _Ch *fStringData; const _Ch *fStringData;
const size_t fSize;
StringRef(const _Ch *data, const size_t size) StringRef(const _Ch *data)
: fRefs(1), fStringData(data), fSize(size) { } : fRefs(1), fStringData(data) { }
inline void AddRef() { ++fRefs; } inline void AddRef() { ++fRefs; }
inline void DecRef() inline void DecRef()
@ -67,52 +72,74 @@ private:
} }
}; };
union {
StringRef *fData; StringRef *fData;
_Ch fShort[SSO_CHARS];
};
size_t fSize;
bool IHaveACow() const { return fSize >= SSO_CHARS; }
public: public:
plStringBuffer() : fData(nil) { } plStringBuffer() : fSize(0) { memset(fShort, 0, sizeof(fShort)); }
plStringBuffer(const plStringBuffer<_Ch> &copy) plStringBuffer(const plStringBuffer<_Ch> &copy) : fSize(copy.fSize)
{ {
fData = copy.fData; memcpy(fShort, copy.fShort, sizeof(fShort));
if (fData) if (IHaveACow())
fData->AddRef(); fData->AddRef();
} }
plStringBuffer(const _Ch *data, size_t size) plStringBuffer(const _Ch *data, size_t size) : fSize(size)
{ {
_Ch *copyData = new _Ch[size + 1]; memset(fShort, 0, sizeof(fShort));
_Ch *copyData = IHaveACow() ? new _Ch[size + 1] : fShort;
memcpy(copyData, data, size); memcpy(copyData, data, size);
copyData[size] = 0; copyData[size] = 0;
fData = new StringRef(copyData, size); if (IHaveACow())
fData = new StringRef(copyData);
} }
~plStringBuffer<_Ch>() ~plStringBuffer<_Ch>()
{ {
if (fData) if (IHaveACow())
fData->DecRef(); fData->DecRef();
} }
static plStringBuffer<_Ch> Steal(const _Ch *data, size_t size)
{
plStringBuffer<_Ch> string;
string.fData = new StringRef(data, size);
return string;
}
plStringBuffer<_Ch> &operator=(const plStringBuffer<_Ch> &copy) plStringBuffer<_Ch> &operator=(const plStringBuffer<_Ch> &copy)
{ {
if (copy.fData) if (copy.IHaveACow())
copy.fData->AddRef(); copy.fData->AddRef();
if (fData) if (IHaveACow())
fData->DecRef(); fData->DecRef();
fData = copy.fData;
memcpy(fShort, copy.fShort, sizeof(fShort));
fSize = copy.fSize;
return *this; return *this;
} }
const _Ch *GetData() const { return fData ? fData->fStringData : 0; } const _Ch *GetData() const { return IHaveACow() ? fData->fStringData : fShort; }
size_t GetSize() const { return fData ? fData->fSize : 0; } size_t GetSize() const { return fSize; }
operator const _Ch *() const { return GetData(); }
// From Haxxia with love
// NOTE: The client is expected to nul-terminate the returned buffer!
_Ch *CreateWritableBuffer(size_t size)
{
if (IHaveACow())
fData->DecRef();
fSize = size;
if (IHaveACow()) {
_Ch *writable = new _Ch[fSize + 1];
fData = new StringRef(writable);
return writable;
} else {
return fShort;
}
}
}; };
@ -128,7 +155,7 @@ public:
private: private:
plStringBuffer<char> fUtf8Buffer; plStringBuffer<char> fUtf8Buffer;
void IConvertFromUtf8(const char *utf8, size_t size, bool steal); void IConvertFromUtf8(const char *utf8, size_t size);
void IConvertFromUtf16(const uint16_t *utf16, size_t size); void IConvertFromUtf16(const uint16_t *utf16, size_t size);
void IConvertFromWchar(const wchar_t *wstr, size_t size); void IConvertFromWchar(const wchar_t *wstr, size_t size);
void IConvertFromIso8859_1(const char *astr, size_t size); void IConvertFromIso8859_1(const char *astr, size_t size);
@ -136,20 +163,24 @@ private:
public: public:
plString() { } plString() { }
//plString(const char *utf8) { IConvertFromUtf8(utf8, kSizeAuto, false); } #ifndef PLSTRING_POLLUTE_ASCII_CAST
//plString(const wchar_t *wstr) { IConvertFromWchar(wstr, 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 &operator=(const char *utf8) { IConvertFromUtf8(utf8, kSizeAuto, false); return *this; } #ifndef PLSTRING_POLLUTE_ASCII_CAST
//plString &operator=(const wchar_t *wstr) { IConvertFromWchar(wstr, 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 plString &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)
{ {
plString str; plString str;
str.IConvertFromUtf8(utf8, size, false); str.IConvertFromUtf8(utf8, size);
return str; return str;
} }
@ -174,8 +205,11 @@ public:
return str; return str;
} }
const char *c_str() const { return fUtf8Buffer.GetData(); } #ifndef PLSTRING_POLLUTE_C_STR
const char *s_str(const char *safe = "") const { return c_str() ? c_str() : safe; } const char *c_str(const char *substitute = "") const
{ 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]; }
plStringBuffer<char> ToUtf8() const { return fUtf8Buffer; } plStringBuffer<char> ToUtf8() const { return fUtf8Buffer; }
@ -188,7 +222,10 @@ public:
size_t GetSize() const { return fUtf8Buffer.GetSize(); } size_t GetSize() const { return fUtf8Buffer.GetSize(); }
bool IsEmpty() const { return fUtf8Buffer.GetSize() == 0; } bool IsEmpty() const { return fUtf8Buffer.GetSize() == 0; }
bool IsNull() const { return fUtf8Buffer.GetData() == 0; }
// TODO: Evaluate whether Plasma actually needs to distinguish between
// empty and NULL strings. Ideally, only IsEmpty should be required.
bool IsNull() const { return IsEmpty(); }
int ToInt(int base = 0) const; int ToInt(int base = 0) const;
unsigned int ToUInt(int base = 0) const; unsigned int ToUInt(int base = 0) const;
@ -197,12 +234,6 @@ public:
static plString Format(const char *fmt, ...); static plString Format(const char *fmt, ...);
static plString IFormat(const char *fmt, va_list vptr); static plString IFormat(const char *fmt, va_list vptr);
static plString Steal(const char *utf8, size_t size = kSizeAuto)
{
plString str;
str.IConvertFromUtf8(utf8, size, true);
return str;
}
enum CaseSensitivity { enum CaseSensitivity {
kCaseSensitive, kCaseInsensitive kCaseSensitive, kCaseInsensitive
@ -210,32 +241,26 @@ public:
int Compare(const plString &str, CaseSensitivity sense = kCaseSensitive) const int Compare(const plString &str, CaseSensitivity sense = kCaseSensitive) const
{ {
if (c_str() == str.c_str()) return (sense == kCaseSensitive) ? strcmp(c_str(), str.c_str())
return 0; : stricmp(c_str(), str.c_str());
return (sense == kCaseSensitive) ? strcmp(s_str(), str.s_str())
: stricmp(s_str(), str.s_str());
} }
int Compare(const char *str, CaseSensitivity sense = kCaseSensitive) const int Compare(const char *str, CaseSensitivity sense = kCaseSensitive) const
{ {
return (sense == kCaseSensitive) ? strcmp(s_str(), str) return (sense == kCaseSensitive) ? strcmp(c_str(), str)
: stricmp(s_str(), str); : stricmp(c_str(), str);
} }
int CompareN(const plString &str, size_t count, CaseSensitivity sense = kCaseSensitive) const int CompareN(const plString &str, size_t count, CaseSensitivity sense = kCaseSensitive) const
{ {
if (c_str() == str.c_str()) return (sense == kCaseSensitive) ? strncmp(c_str(), str.c_str(), count)
return 0; : strnicmp(c_str(), str.c_str(), count);
return (sense == kCaseSensitive) ? strncmp(s_str(), str.s_str(), count)
: strnicmp(s_str(), str.s_str(), count);
} }
int CompareN(const char *str, size_t count, CaseSensitivity sense = kCaseSensitive) const int CompareN(const char *str, size_t count, CaseSensitivity sense = kCaseSensitive) const
{ {
return (sense == kCaseSensitive) ? strncmp(s_str(), str, count) return (sense == kCaseSensitive) ? strncmp(c_str(), str, count)
: strnicmp(s_str(), str, count); : strnicmp(c_str(), str, count);
} }
bool operator<(const plString &other) const { return Compare(other) < 0; } bool operator<(const plString &other) const { return Compare(other) < 0; }
@ -263,25 +288,25 @@ public:
plString ToLower() const; plString ToLower() const;
public: public:
struct less : public std::binary_function<plString, plString, bool> struct less
{ {
bool operator()(const plString &_L, const plString &_R) const bool operator()(const plString &_L, const plString &_R) const
{ return _L.Compare(_R, kCaseSensitive) < 0; } { return _L.Compare(_R, kCaseSensitive) < 0; }
}; };
struct less_i : public std::binary_function<plString, plString, bool> struct less_i
{ {
bool operator()(const plString &_L, const plString &_R) const bool operator()(const plString &_L, const plString &_R) const
{ return _L.Compare(_R, kCaseInsensitive) < 0; } { return _L.Compare(_R, kCaseInsensitive) < 0; }
}; };
struct equal : public std::binary_function<plString, plString, bool> struct equal
{ {
bool operator()(const plString &_L, const plString &_R) const bool operator()(const plString &_L, const plString &_R) const
{ return _L.Compare(_R, kCaseSensitive) == 0; } { return _L.Compare(_R, kCaseSensitive) == 0; }
}; };
struct equal_i : public std::binary_function<plString, plString, bool> struct equal_i
{ {
bool operator()(const plString &_L, const plString &_R) const bool operator()(const plString &_L, const plString &_R) const
{ return _L.Compare(_R, kCaseInsensitive) == 0; } { return _L.Compare(_R, kCaseInsensitive) == 0; }
@ -376,7 +401,7 @@ public:
const char *m_end; const char *m_end;
}; };
iterator GetIterator() const { return iterator(s_str(), GetSize()); } iterator GetIterator() const { return iterator(c_str(), GetSize()); }
size_t GetUniCharCount() const size_t GetUniCharCount() const
{ {
@ -414,7 +439,7 @@ public:
plStringStream &operator<<(const plString &text) plStringStream &operator<<(const plString &text)
{ {
return append(text.s_str(), text.GetSize()); return append(text.c_str(), text.GetSize());
} }
size_t GetLength() const { return fLength; } size_t GetLength() const { return fLength; }

6
Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.cpp

@ -127,7 +127,7 @@ void plAnimDebugList::ShowReport()
str = plString::Format("%s: %s %.3f (%.3f)", mat->GetKeyName().c_str(), layerAnim->GetKeyName().c_str(), str = plString::Format("%s: %s %.3f (%.3f)", mat->GetKeyName().c_str(), layerAnim->GetKeyName().c_str(),
layerAnim->GetTimeConvert().CurrentAnimTime(), layerAnim->GetTimeConvert().CurrentAnimTime(),
layerAnim->GetTimeConvert().WorldToAnimTimeNoUpdate(hsTimer::GetSysSeconds())); layerAnim->GetTimeConvert().WorldToAnimTimeNoUpdate(hsTimer::GetSysSeconds()));
txt.DrawString(x, y, _TEMP_CONVERT_TO_CONST_CHAR(str)); txt.DrawString(x, y, str.c_str());
y += yOff; y += yOff;
} }
layer = layer->GetOverLay(); layer = layer->GetOverLay();
@ -149,7 +149,7 @@ void plAnimDebugList::ShowReport()
continue; continue;
str = plString::Format(" %s", so->GetKeyName().c_str()); str = plString::Format(" %s", so->GetKeyName().c_str());
txt.DrawString(x, y, _TEMP_CONVERT_TO_CONST_CHAR(str)); txt.DrawString(x, y, str.c_str());
y += yOff; y += yOff;
for (j = 0; j < mod->GetNumATCAnimations(); j++) for (j = 0; j < mod->GetNumATCAnimations(); j++)
@ -158,7 +158,7 @@ void plAnimDebugList::ShowReport()
str = plString::Format(" %s: %.3f (%.3f)", anim->GetAnimation()->GetName().c_str(), str = plString::Format(" %s: %.3f (%.3f)", anim->GetAnimation()->GetName().c_str(),
anim->GetTimeConvert()->CurrentAnimTime(), anim->GetTimeConvert()->CurrentAnimTime(),
anim->GetTimeConvert()->WorldToAnimTimeNoUpdate(hsTimer::GetSysSeconds())); anim->GetTimeConvert()->WorldToAnimTimeNoUpdate(hsTimer::GetSysSeconds()));
txt.DrawString(x, y, _TEMP_CONVERT_TO_CONST_CHAR(str)); txt.DrawString(x, y, str.c_str());
y += yOff; y += yOff;
} }
} }

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

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

1
Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h

@ -46,6 +46,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnKeyedObject/hsKeyedObject.h" #include "pnKeyedObject/hsKeyedObject.h"
#include "hsMatrix44.h" #include "hsMatrix44.h"
#include "hsBitVector.h" #include "hsBitVector.h"
#include <vector>
class plPipeline; class plPipeline;
class plCameraModifier1; class plCameraModifier1;

4
Sources/Plasma/FeatureLib/pfCharacter/pfMarkerInfo.cpp

@ -77,7 +77,7 @@ void pfMarkerInfo::Init()
plLocation markerLoc = plKeyFinder::Instance().FindLocation("GlobalMarkers", "Markers"); plLocation markerLoc = plKeyFinder::Instance().FindLocation("GlobalMarkers", "Markers");
if (markerLoc.IsValid()) if (markerLoc.IsValid())
fMarkerUoid = plUoid(markerLoc, plSceneObject::Index(), _TEMP_CONVERT_FROM_LITERAL("MarkerRoot")); fMarkerUoid = plUoid(markerLoc, plSceneObject::Index(), "MarkerRoot");
else else
fMarkerUoid.Invalidate(); fMarkerUoid.Invalidate();
} }
@ -101,7 +101,7 @@ void pfMarkerInfo::Spawn(MarkerType type)
plLocation markerLoc = plKeyFinder::Instance().FindLocation("GlobalMarkers", "Markers"); plLocation markerLoc = plKeyFinder::Instance().FindLocation("GlobalMarkers", "Markers");
if (markerLoc.IsValid()) if (markerLoc.IsValid())
fMarkerUoid = plUoid(markerLoc, plSceneObject::Index(), _TEMP_CONVERT_FROM_LITERAL("MarkerRoot")); fMarkerUoid = plUoid(markerLoc, plSceneObject::Index(), "MarkerRoot");
else else
{ {
hsAssert(false, "Unable to spawn markers because the marker age was not loaded or found"); hsAssert(false, "Unable to spawn markers because the marker age was not loaded or found");

2
Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp

@ -173,7 +173,7 @@ PF_CONSOLE_CMD( Avatar_Spawn, Show, "", "Print a list of spawn points.")
const plSpawnModifier * spawn = mgr->GetSpawnPoint(i); const plSpawnModifier * spawn = mgr->GetSpawnPoint(i);
if(spawn) if(spawn)
{ {
plString soName = _TEMP_CONVERT_FROM_LITERAL("(none)"); plString soName = "(none)";
if (spawn->GetNumTargets() > 0) if (spawn->GetNumTargets() > 0)
{ {

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

@ -334,7 +334,7 @@ bool pfConsole::MsgReceive( plMessage *msg )
case kSrv2Cli_GameMgr_InviteReceived: { case kSrv2Cli_GameMgr_InviteReceived: {
const Srv2Cli_GameMgr_InviteReceived & gmMsg = *(const Srv2Cli_GameMgr_InviteReceived *)gameMgrMsg->netMsg; const Srv2Cli_GameMgr_InviteReceived & gmMsg = *(const Srv2Cli_GameMgr_InviteReceived *)gameMgrMsg->netMsg;
const plString & inviterName = plNetClientMgr::GetInstance()->GetPlayerNameById(gmMsg.inviterId); const plString & inviterName = plNetClientMgr::GetInstance()->GetPlayerNameById(gmMsg.inviterId);
AddLineF("[GameMgr] Invite received: %S, %u. Inviter: %s", pfGameMgr::GetInstance()->GetGameNameByTypeId(gmMsg.gameTypeId), gmMsg.newGameId, inviterName.s_str("<Unknown>")); AddLineF("[GameMgr] Invite received: %S, %u. Inviter: %s", pfGameMgr::GetInstance()->GetGameNameByTypeId(gmMsg.gameTypeId), gmMsg.newGameId, inviterName.c_str("<Unknown>"));
} }
return true; return true;
@ -343,7 +343,7 @@ bool pfConsole::MsgReceive( plMessage *msg )
case kSrv2Cli_GameMgr_InviteRevoked: { case kSrv2Cli_GameMgr_InviteRevoked: {
const Srv2Cli_GameMgr_InviteRevoked & gmMsg = *(const Srv2Cli_GameMgr_InviteRevoked *)gameMgrMsg->netMsg; const Srv2Cli_GameMgr_InviteRevoked & gmMsg = *(const Srv2Cli_GameMgr_InviteRevoked *)gameMgrMsg->netMsg;
const plString & inviterName = plNetClientMgr::GetInstance()->GetPlayerNameById(gmMsg.inviterId); const plString & inviterName = plNetClientMgr::GetInstance()->GetPlayerNameById(gmMsg.inviterId);
AddLineF("[GameMgr] Invite revoked: %S, %u. Inviter: %s", pfGameMgr::GetInstance()->GetGameNameByTypeId(gmMsg.gameTypeId), gmMsg.newGameId, inviterName.s_str("<Unknown>")); AddLineF("[GameMgr] Invite revoked: %S, %u. Inviter: %s", pfGameMgr::GetInstance()->GetGameNameByTypeId(gmMsg.gameTypeId), gmMsg.newGameId, inviterName.c_str("<Unknown>"));
} }
return true; return true;

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

@ -155,7 +155,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
//end for agedefn test //end for agedefn test
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "pnSceneObject/plAudioInterface.h" #include "pnSceneObject/plAudioInterface.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
@ -6980,7 +6980,7 @@ PF_CONSOLE_CMD( Python,
args = plString::Format("(%s,)", tmp); args = plString::Format("(%s,)", tmp);
} }
else else
args = _TEMP_CONVERT_FROM_LITERAL("()"); args = "()";
PythonInterface::RunFunctionSafe("xCheat", params[0], args.c_str()); PythonInterface::RunFunctionSafe("xCheat", params[0], args.c_str());

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

@ -84,7 +84,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
//end for agedefn test //end for agedefn test
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
@ -231,12 +231,12 @@ PF_CONSOLE_CMD( Net, // groupName
{ {
// send chat text // send chat text
plString text=plNetClientMgr::GetInstance()->GetPlayerName(); plString text=plNetClientMgr::GetInstance()->GetPlayerName();
text += _TEMP_CONVERT_FROM_LITERAL(":"); text += ":";
int i; int i;
for(i=0;i<numParams;i++) for(i=0;i<numParams;i++)
{ {
text += plString::FromUtf8( (char*)params[i] ); text += plString::FromUtf8( (char*)params[i] );
text += _TEMP_CONVERT_FROM_LITERAL(" "); text += " ";
} }
plConsoleMsg *cMsg = new plConsoleMsg( plConsoleMsg::kAddLine, text.c_str() ); plConsoleMsg *cMsg = new plConsoleMsg( plConsoleMsg::kAddLine, text.c_str() );
cMsg->SetBCastFlag(plMessage::kNetPropagate | plMessage::kNetForce); cMsg->SetBCastFlag(plMessage::kNetPropagate | plMessage::kNetForce);

2
Sources/Plasma/FeatureLib/pfCrashHandler/plCrashSrv.cpp

@ -42,7 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plCrashSrv.h" #include "plCrashSrv.h"
#include "plCrash_Private.h" #include "plCrash_Private.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "pnProduct/pnProduct.h" #include "pnProduct/pnProduct.h"
#ifdef HS_BUILD_FOR_WIN32 #ifdef HS_BUILD_FOR_WIN32

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDialogMod.cpp

@ -498,7 +498,7 @@ static bool showBounds = false;
if( showBounds ) if( showBounds )
{ {
const hsBounds3 &bnds = fMousedCtrl->GetBounds(); const hsBounds3 &bnds = fMousedCtrl->GetBounds();
plDebugText::Instance().DrawString( (uint16_t)(bnds.GetMins().fX), (uint16_t)(bnds.GetMins().fY), _TEMP_CONVERT_TO_CONST_CHAR( fMousedCtrl->GetKeyName() ), (uint32_t)0xffffff00 ); plDebugText::Instance().DrawString( (uint16_t)(bnds.GetMins().fX), (uint16_t)(bnds.GetMins().fY), fMousedCtrl->GetKeyName().c_str(), (uint32_t)0xffffff00 );
} }
#endif #endif

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIEditBoxMod.cpp

@ -388,7 +388,7 @@ bool pfGUIEditBoxMod::HandleKeyEvent( pfGameGUIMgr::EventType event, plKeyDef
{ {
if (key == KEY_C) if (key == KEY_C)
{ {
plClipboard::GetInstance().SetClipboardText(_TEMP_CONVERT_FROM_WCHAR_T(fBuffer)); plClipboard::GetInstance().SetClipboardText(plString::FromWchar(fBuffer));
} }
else if (key == KEY_V) else if (key == KEY_V)
{ {

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIMultiLineEditCtrl.cpp

@ -1113,7 +1113,7 @@ bool pfGUIMultiLineEditCtrl::HandleKeyEvent( pfGameGUIMgr::EventType event, p
// Too lazy to worry about that... // Too lazy to worry about that...
if (key == KEY_C) if (key == KEY_C)
{ {
plClipboard::GetInstance().SetClipboardText(_TEMP_CONVERT_FROM_WCHAR_T(fBuffer.AcquireArray())); plClipboard::GetInstance().SetClipboardText(plString::FromWchar(fBuffer.AcquireArray()));
} }
else if (key == KEY_V) else if (key == KEY_V)
{ {

26
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUITextBoxMod.cpp

@ -121,8 +121,8 @@ void pfGUITextBoxMod::IUpdate( void )
fDynTextMap->ClearToColor( GetColorScheme()->fBackColor ); fDynTextMap->ClearToColor( GetColorScheme()->fBackColor );
std::wstring drawStr; std::wstring drawStr;
if (fUseLocalizationPath && !fLocalizationPath.empty() && pfLocalizationMgr::InstanceValid()) if (fUseLocalizationPath && !fLocalizationPath.IsEmpty() && pfLocalizationMgr::InstanceValid())
drawStr = pfLocalizationMgr::Instance().GetString(fLocalizationPath.c_str()); drawStr = pfLocalizationMgr::Instance().GetString(fLocalizationPath.ToWchar().GetData());
else else
{ {
if( fText != nil ) if( fText != nil )
@ -170,9 +170,7 @@ void pfGUITextBoxMod::Read( hsStream *s, hsResMgr *mgr )
fUseLocalizationPath = s->ReadBool(); fUseLocalizationPath = s->ReadBool();
if (fUseLocalizationPath) if (fUseLocalizationPath)
{ {
wchar_t* temp = s->ReadSafeWString(); fLocalizationPath = s->ReadSafeWString_TEMP();
fLocalizationPath = temp;
delete [] temp;
} }
} }
@ -192,11 +190,11 @@ void pfGUITextBoxMod::Write( hsStream *s, hsResMgr *mgr )
// Make sure we only write out to use localization path if the box is checked // Make sure we only write out to use localization path if the box is checked
// and the path isn't empty // and the path isn't empty
bool useLoc = fUseLocalizationPath && !fLocalizationPath.empty(); bool useLoc = fUseLocalizationPath && !fLocalizationPath.IsEmpty();
s->WriteBool(useLoc); s->WriteBool(useLoc);
if (useLoc) if (useLoc)
s->WriteSafeWString(fLocalizationPath.c_str()); s->WriteSafeWString(fLocalizationPath);
} }
//// HandleMouseDown/Up ////////////////////////////////////////////////////// //// HandleMouseDown/Up //////////////////////////////////////////////////////
@ -240,22 +238,12 @@ void pfGUITextBoxMod::SetText( const wchar_t *text )
IUpdate(); IUpdate();
} }
void pfGUITextBoxMod::SetLocalizationPath(const wchar_t* path) void pfGUITextBoxMod::SetLocalizationPath(const plString& path)
{ {
if (path) if (!path.IsNull())
fLocalizationPath = path; fLocalizationPath = path;
} }
void pfGUITextBoxMod::SetLocalizationPath(const char* path)
{
if (path)
{
wchar_t* wPath = hsStringToWString(path);
fLocalizationPath = wPath;
delete [] wPath;
}
}
void pfGUITextBoxMod::SetUseLocalizationPath(bool use) void pfGUITextBoxMod::SetUseLocalizationPath(bool use)
{ {
fUseLocalizationPath = use; fUseLocalizationPath = use;

5
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUITextBoxMod.h

@ -59,7 +59,7 @@ class pfGUITextBoxMod : public pfGUIControlMod
protected: protected:
wchar_t *fText; wchar_t *fText;
std::wstring fLocalizationPath; plString fLocalizationPath;
bool fUseLocalizationPath; bool fUseLocalizationPath;
@ -99,8 +99,7 @@ class pfGUITextBoxMod : public pfGUIControlMod
void SetText( const char *text ); void SetText( const char *text );
void SetText( const wchar_t *text ); void SetText( const wchar_t *text );
void SetLocalizationPath(const wchar_t* path); void SetLocalizationPath(const plString& path);
void SetLocalizationPath(const char* path);
void SetUseLocalizationPath(bool use); void SetUseLocalizationPath(bool use);
virtual void UpdateColorScheme() { IPostSetUpDynTextMap(); IUpdate(); } virtual void UpdateColorScheme() { IPostSetUpDynTextMap(); IUpdate(); }

4
Sources/Plasma/FeatureLib/pfGameScoreMgr/pfGameScoreMgr.cpp

@ -143,7 +143,7 @@ static void OnScoreCreate(
int32_t value int32_t value
) { ) {
ScoreUpdateParam* p = (ScoreUpdateParam*)param; ScoreUpdateParam* p = (ScoreUpdateParam*)param;
pfGameScore* score = new pfGameScore(scoreId, ownerId, _TEMP_CONVERT_FROM_LITERAL(gameName), gameType, value); pfGameScore* score = new pfGameScore(scoreId, ownerId, gameName, gameType, value);
pfGameScoreUpdateMsg* msg = new pfGameScoreUpdateMsg(result, score, value); pfGameScoreUpdateMsg* msg = new pfGameScoreUpdateMsg(result, score, value);
msg->Send(p->fReceiver); msg->Send(p->fReceiver);
delete p; delete p;
@ -165,7 +165,7 @@ static void OnScoreFound(
for (uint32_t i = 0; i < scoreCount; ++i) for (uint32_t i = 0; i < scoreCount; ++i)
{ {
const NetGameScore ngs = scores[i]; const NetGameScore ngs = scores[i];
vec[i] = new pfGameScore(ngs.scoreId, ngs.ownerId, _TEMP_CONVERT_FROM_WCHAR_T(ngs.gameName), ngs.gameType, ngs.value); vec[i] = new pfGameScore(ngs.scoreId, ngs.ownerId, plString::FromWchar(ngs.gameName), ngs.gameType, ngs.value);
} }
ScoreFindParam* p = (ScoreFindParam*)param; ScoreFindParam* p = (ScoreFindParam*)param;

18
Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp

@ -472,7 +472,7 @@ pfBookData::pfBookData(const plString &guiName /* = nil */)
if (!guiName.IsEmpty()) if (!guiName.IsEmpty())
fGUIName = guiName; fGUIName = guiName;
else else
fGUIName = _TEMP_CONVERT_FROM_LITERAL("BkBook"); fGUIName = "BkBook";
} }
pfBookData::~pfBookData() pfBookData::~pfBookData()
@ -1140,9 +1140,9 @@ std::map<plString,pfBookData*> pfJournalBook::fBookGUIs;
void pfJournalBook::SingletonInit( void ) void pfJournalBook::SingletonInit( void )
{ {
fBookGUIs[_TEMP_CONVERT_FROM_LITERAL("BkBook")] = new pfBookData(); // load the default book data object fBookGUIs["BkBook"] = new pfBookData(); // load the default book data object
hsgResMgr::ResMgr()->NewKey(_TEMP_CONVERT_FROM_LITERAL("BkBook"),fBookGUIs[_TEMP_CONVERT_FROM_LITERAL("BkBook")],pfGameGUIMgr::GetInstance()->GetKey()->GetUoid().GetLocation()); hsgResMgr::ResMgr()->NewKey("BkBook",fBookGUIs["BkBook"],pfGameGUIMgr::GetInstance()->GetKey()->GetUoid().GetLocation());
fBookGUIs[_TEMP_CONVERT_FROM_LITERAL("BkBook")]->LoadGUI(); fBookGUIs["BkBook"]->LoadGUI();
} }
void pfJournalBook::SingletonShutdown( void ) void pfJournalBook::SingletonShutdown( void )
@ -1207,7 +1207,7 @@ pfJournalBook::pfJournalBook( const char *esHTMLSource, plKey coverImageKey, plK
if (!guiName.IsEmpty()) if (!guiName.IsEmpty())
fCurBookGUI = guiName; fCurBookGUI = guiName;
else else
fCurBookGUI = _TEMP_CONVERT_FROM_LITERAL("BkBook"); fCurBookGUI = "BkBook";
if (fBookGUIs.find(fCurBookGUI) == fBookGUIs.end()) if (fBookGUIs.find(fCurBookGUI) == fBookGUIs.end())
{ {
fBookGUIs[fCurBookGUI] = new pfBookData(fCurBookGUI); fBookGUIs[fCurBookGUI] = new pfBookData(fCurBookGUI);
@ -1243,7 +1243,7 @@ pfJournalBook::pfJournalBook( const wchar_t *esHTMLSource, plKey coverImageKey,
if (!guiName.IsEmpty()) if (!guiName.IsEmpty())
fCurBookGUI = guiName; fCurBookGUI = guiName;
else else
fCurBookGUI = _TEMP_CONVERT_FROM_LITERAL("BkBook"); fCurBookGUI = "BkBook";
if (fBookGUIs.find(fCurBookGUI) == fBookGUIs.end()) if (fBookGUIs.find(fCurBookGUI) == fBookGUIs.end())
{ {
fBookGUIs[fCurBookGUI] = new pfBookData(fCurBookGUI); fBookGUIs[fCurBookGUI] = new pfBookData(fCurBookGUI);
@ -1292,7 +1292,7 @@ void pfJournalBook::SetGUI( const plString &guiName )
if (!guiName.IsEmpty()) if (!guiName.IsEmpty())
fCurBookGUI = guiName; fCurBookGUI = guiName;
if (fBookGUIs.find(fCurBookGUI) == fBookGUIs.end()) if (fBookGUIs.find(fCurBookGUI) == fBookGUIs.end())
fCurBookGUI = _TEMP_CONVERT_FROM_LITERAL("BkBook"); // requested GUI isn't loaded, so use default GUI fCurBookGUI = "BkBook"; // requested GUI isn't loaded, so use default GUI
SetEditable(fWantEditing); // make sure that if we want editing, to set it SetEditable(fWantEditing); // make sure that if we want editing, to set it
ICompileSource(fUncompiledSource.c_str(), fDefLoc); // recompile the source to be safe ICompileSource(fUncompiledSource.c_str(), fDefLoc); // recompile the source to be safe
} }
@ -2506,9 +2506,9 @@ plKey pfJournalBook::IGetMipmapKey( const wchar_t *name, const plLocation &loc
// facilitate fast prototyping // facilitate fast prototyping
plMipmap *mip; plMipmap *mip;
if( cName.Find( ".png" ) >= 0 ) if( cName.Find( ".png" ) >= 0 )
mip = plPNG::Instance().ReadFromFile( _TEMP_CONVERT_TO_CONST_CHAR( cName ) ); mip = plPNG::Instance().ReadFromFile( cName.c_str() );
else else
mip = plJPEG::Instance().ReadFromFile( _TEMP_CONVERT_TO_CONST_CHAR( cName ) ); mip = plJPEG::Instance().ReadFromFile( cName.c_str() );
hsgResMgr::ResMgr()->NewKey( cName, mip, loc ); hsgResMgr::ResMgr()->NewKey( cName, mip, loc );
return mip->GetKey(); return mip->GetKey();

2
Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp

@ -50,7 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plResMgr/plLocalization.h" #include "plResMgr/plLocalization.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plFile/plEncryptedStream.h" #include "plFile/plEncryptedStream.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"

15
Sources/Plasma/FeatureLib/pfMessage/pfKIMsg.cpp

@ -49,18 +49,3 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
const char* pfKIMsg::kChronicleKILevel = "PlayerKILevel"; const char* pfKIMsg::kChronicleKILevel = "PlayerKILevel";
void pfKIMsg::SetString( const char *str )
{
wchar_t *temp = hsStringToWString( str );
fString = temp;
delete [] temp;
}
std::string pfKIMsg::GetString( void )
{
char *temp = hsWStringToString( fString.c_str() );
std::string retVal = temp;
delete [] temp;
return retVal;
}

21
Sources/Plasma/FeatureLib/pfMessage/pfKIMsg.h

@ -67,7 +67,7 @@ class pfKIMsg : public plMessage
// for the hack chat message thingy // for the hack chat message thingy
char *fUser; char *fUser;
uint32_t fPlayerID; uint32_t fPlayerID;
std::wstring fString; plString fString;
// for the SetChatFadeDelay // for the SetChatFadeDelay
float fDelay; float fDelay;
@ -78,7 +78,7 @@ class pfKIMsg : public plMessage
void IInit() void IInit()
{ {
fCommand = kNoCommand; fCommand = kNoCommand;
fString = L""; fString = "";
fUser = nil; fUser = nil;
fPlayerID = 0; fPlayerID = 0;
fFlags = 0; fFlags = 0;
@ -192,14 +192,7 @@ class pfKIMsg : public plMessage
s->ReadLE( &fCommand ); s->ReadLE( &fCommand );
fUser = s->ReadSafeString(); fUser = s->ReadSafeString();
fPlayerID = s->ReadLE32(); fPlayerID = s->ReadLE32();
fString = s->ReadSafeWString_TEMP();
wchar_t *temp = s->ReadSafeWString();
if (temp) // apparently ReadSafeWString can return null, which std::wstring doesn't like being assigned
fString = temp;
else
fString = L"";
delete [] temp;
fFlags = s->ReadLE32(); fFlags = s->ReadLE32();
fDelay = s->ReadLEScalar(); fDelay = s->ReadLEScalar();
fValue = s->ReadLE32(); fValue = s->ReadLE32();
@ -211,7 +204,7 @@ class pfKIMsg : public plMessage
s->WriteLE( fCommand ); s->WriteLE( fCommand );
s->WriteSafeString( fUser ); s->WriteSafeString( fUser );
s->WriteLE32( fPlayerID ); s->WriteLE32( fPlayerID );
s->WriteSafeWString( fString.c_str() ); s->WriteSafeWString( fString );
s->WriteLE32( fFlags ); s->WriteLE32( fFlags );
s->WriteLEScalar(fDelay); s->WriteLEScalar(fDelay);
s->WriteLE32( fValue ); s->WriteLE32( fValue );
@ -219,10 +212,8 @@ class pfKIMsg : public plMessage
uint8_t GetCommand( void ) const { return fCommand; } uint8_t GetCommand( void ) const { return fCommand; }
void SetString( const char *str ); void SetString( const plString &str ) { fString = str; }
void SetString( const wchar_t *str ) { fString = str; } plString GetString( void ) { return fString; }
std::string GetString( void );
std::wstring GetStringU( void ) { return fString; }
void SetUser( const char *str, uint32_t pid=0 ) { fUser = hsStrcpy( str ); fPlayerID = pid; } void SetUser( const char *str, uint32_t pid=0 ) { fUser = hsStrcpy( str ); fPlayerID = pid; }
const char *GetUser( void ) { return fUser; } const char *GetUser( void ) { return fUser; }

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

@ -1127,7 +1127,7 @@ uint32_t cyMisc::SendRTChat(pyPlayer& from, const std::vector<pyPlayer*> & tolis
{ {
// create the messge that will contain the chat message // create the messge that will contain the chat message
pfKIMsg *msg = new pfKIMsg( pfKIMsg::kHACKChatMsg ); pfKIMsg *msg = new pfKIMsg( pfKIMsg::kHACKChatMsg );
msg->SetString( message ); msg->SetString( plString::FromWchar(message) );
msg->SetUser( from.GetPlayerName(), from.GetPlayerID() ); msg->SetUser( from.GetPlayerName(), from.GetPlayerID() );
msg->SetFlags( flags ); msg->SetFlags( flags );
msg->SetBCastFlag(plMessage::kNetPropagate | plMessage::kNetForce); msg->SetBCastFlag(plMessage::kNetPropagate | plMessage::kNetForce);
@ -1199,7 +1199,7 @@ void cyMisc::SendKIMessageS(uint32_t command, const wchar_t* value)
// create the mesage to send // create the mesage to send
pfKIMsg *msg = new pfKIMsg( (uint8_t)command ); pfKIMsg *msg = new pfKIMsg( (uint8_t)command );
msg->SetString( value ); msg->SetString( plString::FromWchar( value ) );
// send it off // send it off
plgDispatch::MsgSend( msg ); plgDispatch::MsgSend( msg );

2
Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp

@ -115,7 +115,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtGetClientName, args, "Params: avatarKey=None\n
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
pyKey* key = pyKey::ConvertFrom(keyObj); pyKey* key = pyKey::ConvertFrom(keyObj);
return PyString_FromString(cyMisc::GetClientName(*key).s_str()); return PyString_FromString(cyMisc::GetClientName(*key).c_str());
} }
else else
return PyString_FromString(cyMisc::GetLocalClientName().c_str()); return PyString_FromString(cyMisc::GetLocalClientName().c_str());

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

@ -1862,7 +1862,7 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
// yes... // yes...
// find the value that would go with a command // find the value that would go with a command
PyObject* value; PyObject* value;
std::wstring str; plStringBuffer<wchar_t> str;
switch (pkimsg->GetCommand()) switch (pkimsg->GetCommand())
{ {
case pfKIMsg::kSetChatFadeDelay: case pfKIMsg::kSetChatFadeDelay:
@ -1873,8 +1873,8 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
break; break;
case pfKIMsg::kYesNoDialog: case pfKIMsg::kYesNoDialog:
value = PyTuple_New(2); value = PyTuple_New(2);
str = pkimsg->GetStringU(); str = pkimsg->GetString().ToWchar();
PyTuple_SetItem(value, 0, PyUnicode_FromWideChar(str.c_str(), str.length())); PyTuple_SetItem(value, 0, PyUnicode_FromWideChar(str, str.GetSize()));
PyTuple_SetItem(value, 1, pyKey::New(pkimsg->GetSender())); PyTuple_SetItem(value, 1, pyKey::New(pkimsg->GetSender()));
break; break;
case pfKIMsg::kGZInRange: case pfKIMsg::kGZInRange:
@ -1884,23 +1884,23 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
break; break;
case pfKIMsg::kRateIt: case pfKIMsg::kRateIt:
value = PyTuple_New(3); value = PyTuple_New(3);
str = pkimsg->GetStringU(); str = pkimsg->GetString().ToWchar();
PyTuple_SetItem(value,0,PyString_FromString(pkimsg->GetUser())); PyTuple_SetItem(value,0,PyString_FromString(pkimsg->GetUser()));
PyTuple_SetItem(value,1,PyUnicode_FromWideChar(str.c_str(), str.length())); PyTuple_SetItem(value,1,PyUnicode_FromWideChar(str, str.GetSize()));
PyTuple_SetItem(value,2,PyLong_FromLong(pkimsg->GetIntValue())); PyTuple_SetItem(value,2,PyLong_FromLong(pkimsg->GetIntValue()));
break; break;
case pfKIMsg::kRegisterImager: case pfKIMsg::kRegisterImager:
value = PyTuple_New(2); value = PyTuple_New(2);
str = pkimsg->GetStringU(); str = pkimsg->GetString().ToWchar();
PyTuple_SetItem(value, 0, PyUnicode_FromWideChar(str.c_str(), str.length())); PyTuple_SetItem(value, 0, PyUnicode_FromWideChar(str, str.GetSize()));
PyTuple_SetItem(value, 1, pyKey::New(pkimsg->GetSender())); PyTuple_SetItem(value, 1, pyKey::New(pkimsg->GetSender()));
break; break;
case pfKIMsg::kAddPlayerDevice: case pfKIMsg::kAddPlayerDevice:
case pfKIMsg::kRemovePlayerDevice: case pfKIMsg::kRemovePlayerDevice:
{ {
str = pkimsg->GetStringU(); str = pkimsg->GetString().ToWchar();
if ( str.length() > 0 ) if ( str.GetSize() > 0 )
value = PyUnicode_FromWideChar(str.c_str(), str.length()); value = PyUnicode_FromWideChar(str, str.GetSize());
else else
{ {
Py_INCREF(Py_None); Py_INCREF(Py_None);
@ -1915,8 +1915,8 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
case pfKIMsg::kKIOKDialogNoQuit: case pfKIMsg::kKIOKDialogNoQuit:
case pfKIMsg::kGZFlashUpdate: case pfKIMsg::kGZFlashUpdate:
case pfKIMsg::kKICreateMarkerNode: case pfKIMsg::kKICreateMarkerNode:
str = pkimsg->GetStringU(); str = pkimsg->GetString().ToWchar();
value = PyUnicode_FromWideChar(str.c_str(), str.length()); value = PyUnicode_FromWideChar(str, str.GetSize());
break; break;
case pfKIMsg::kMGStartCGZGame: case pfKIMsg::kMGStartCGZGame:
case pfKIMsg::kMGStopCGZGame: case pfKIMsg::kMGStopCGZGame:
@ -2905,7 +2905,7 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
void plPythonFileMod::ReportError() void plPythonFileMod::ReportError()
{ {
plString objectName = this->GetKeyName(); plString objectName = this->GetKeyName();
objectName += _TEMP_CONVERT_FROM_LITERAL(" - "); objectName += " - ";
PythonInterface::WriteToStdErr(objectName.c_str()); PythonInterface::WriteToStdErr(objectName.c_str());
@ -3050,4 +3050,4 @@ void plPythonFileMod::Write(hsStream* stream, hsResMgr* mgr)
//// kGlobalNameKonstant ///////////////////////////////////////////////// //// kGlobalNameKonstant /////////////////////////////////////////////////
// My continued attempt to spread the CORRECT way to spell konstant. -mcn // My continued attempt to spread the CORRECT way to spell konstant. -mcn
plString plPythonFileMod::kGlobalNameKonstant = _TEMP_CONVERT_FROM_LITERAL("VeryVerySpecialPythonFileMod"); plString plPythonFileMod::kGlobalNameKonstant("VeryVerySpecialPythonFileMod");

2
Sources/Plasma/FeatureLib/pfPython/plPythonPack.cpp

@ -54,7 +54,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plPythonPack.h" #include "plPythonPack.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plFile/plSecureStream.h" #include "plFile/plSecureStream.h"
#include "plFile/plStreamSource.h" #include "plFile/plStreamSource.h"

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

@ -376,10 +376,11 @@ public:
count = stream->ReadLE32(); count = stream->ReadLE32();
if ( count != 0 ) if ( count != 0 )
{ {
char *buffer = new char[count]; plStringBuffer<char> str;
char *buffer = str.CreateWritableBuffer(count-1);
stream->ReadLE(count, buffer); stream->ReadLE(count, buffer);
buffer[count-1] = 0; buffer[count-1] = 0;
fString = plString::Steal(buffer, count); fString = str;
} }
else else
fString = plString::Null; fString = plString::Null;
@ -433,7 +434,6 @@ public:
else else
count = 0; count = 0;
stream->WriteLE(count); stream->WriteLE(count);
if ( count != 0 )
stream->WriteLE(count, fString.c_str()); stream->WriteLE(count, fString.c_str());
break; break;

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

@ -607,7 +607,7 @@ const plPythonSDLModifier* plPythonSDLModifier::FindAgeSDL()
return sdlMod; return sdlMod;
plNetClientApp::StaticErrorMsg("pfmod %s has a nil python SDL modifier for age sdl %s", plNetClientApp::StaticErrorMsg("pfmod %s has a nil python SDL modifier for age sdl %s",
pfmod->GetKeyName().s_str("?"), ageName); pfmod->GetKeyName().c_str("?"), ageName);
} }
else else
{ {
@ -616,11 +616,11 @@ const plPythonSDLModifier* plPythonSDLModifier::FindAgeSDL()
else else
if (!key->ObjectIsLoaded()) if (!key->ObjectIsLoaded())
plNetClientApp::StaticErrorMsg("key %s not loaded for age sdl %s", plNetClientApp::StaticErrorMsg("key %s not loaded for age sdl %s",
key->GetName().s_str("?"), ageName); key->GetName().c_str("?"), ageName);
else else
if (!plPythonFileMod::ConvertNoRef(key->ObjectIsLoaded())) if (!plPythonFileMod::ConvertNoRef(key->ObjectIsLoaded()))
plNetClientApp::StaticErrorMsg("key %s is not a python file mod for age sdl %s", plNetClientApp::StaticErrorMsg("key %s is not a python file mod for age sdl %s",
key->GetName().s_str("?"), ageName); key->GetName().c_str("?"), ageName);
} }
} }
else else

1
Sources/Plasma/FeatureLib/pfPython/pyGUIControlTextBox.h

@ -51,6 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyGUIControl.h" #include "pyGUIControl.h"
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
#include <string>
class pyColor; class pyColor;
class pfGUIColorScheme; class pfGUIColorScheme;

1
Sources/Plasma/FeatureLib/pfPython/pyGUIPopUpMenu.h

@ -52,6 +52,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnKeyedObject/plKey.h" #include "pnKeyedObject/plKey.h"
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
#include "pnKeyedObject/plUoid.h" #include "pnKeyedObject/plUoid.h"
#include <string>
class pfGUIPopUpMenu; class pfGUIPopUpMenu;
class pyColor; class pyColor;

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

@ -61,8 +61,8 @@ PyObject* pyGameScoreMsg::CreateFinal(pfGameScoreMsg* msg)
plString pyGameScoreMsg::GetError() const plString pyGameScoreMsg::GetError() const
{ {
if (fMsg) if (fMsg)
return _TEMP_CONVERT_FROM_WCHAR_T(NetErrorToString(fMsg->GetResult())); return plString::FromWchar(NetErrorToString(fMsg->GetResult()));
return _TEMP_CONVERT_FROM_LITERAL("pfGameScoreMsg is NULL"); return "pfGameScoreMsg is NULL";
} }
bool pyGameScoreMsg::IsValid() const bool pyGameScoreMsg::IsValid() const

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

@ -291,7 +291,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtLoadJPEGFromDisk, args, "Params: filename,widt
if (PyString_CheckEx(filenameObj)) if (PyString_CheckEx(filenameObj))
{ {
plString text = PyString_AsStringEx(filenameObj); plString text = PyString_AsStringEx(filenameObj);
PyObject* ret = pyImage::LoadJPEGFromDisk(_TEMP_CONVERT_TO_WCHAR_T(text), width, height); PyObject* ret = pyImage::LoadJPEGFromDisk(text.ToWchar(), width, height);
return ret; return ret;
} }
else else
@ -313,7 +313,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtLoadPNGFromDisk, args, "Params: filename,width
if (PyString_CheckEx(filenameObj)) if (PyString_CheckEx(filenameObj))
{ {
plString text = PyString_AsStringEx(filenameObj); plString text = PyString_AsStringEx(filenameObj);
PyObject* ret = pyImage::LoadPNGFromDisk(_TEMP_CONVERT_TO_WCHAR_T(text), width, height); PyObject* ret = pyImage::LoadPNGFromDisk(text.ToWchar(), width, height);
return ret; return ret;
} }
else else

10
Sources/Plasma/FeatureLib/pfPython/pyJournalBook.h

@ -49,7 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
#include <string> #include <vector>
class cyAnimation; class cyAnimation;
class pyImage; class pyImage;
@ -84,8 +84,8 @@ public:
// required functions for PyObject interoperability // required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptBook); PYTHON_CLASS_NEW_FRIEND(ptBook);
static PyObject *New(std::string htmlSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = _TEMP_CONVERT_FROM_LITERAL("")); static PyObject *New(std::string htmlSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = "");
static PyObject *New(std::wstring htmlSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = _TEMP_CONVERT_FROM_LITERAL("")); static PyObject *New(std::wstring htmlSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = "");
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyJournalBook object PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyJournalBook object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyJournalBook); // converts a PyObject to a pyJournalBook (throws error if not correct type) PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyJournalBook); // converts a PyObject to a pyJournalBook (throws error if not correct type)
@ -94,8 +94,8 @@ public:
static void AddPlasmaConstantsClasses(PyObject *m); static void AddPlasmaConstantsClasses(PyObject *m);
// Deletes the existing book and re-creates it, for use by the python glue // Deletes the existing book and re-creates it, for use by the python glue
void MakeBook(std::string esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = _TEMP_CONVERT_FROM_LITERAL("")); void MakeBook(std::string esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = "");
void MakeBook(std::wstring esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = _TEMP_CONVERT_FROM_LITERAL("")); void MakeBook(std::wstring esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = "");
// Interface functions per book // Interface functions per book
virtual void Show( bool startOpened ); virtual void Show( bool startOpened );

1
Sources/Plasma/FeatureLib/pfPython/pyPlayer.h

@ -51,6 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
#include "pnKeyedObject/plKey.h" #include "pnKeyedObject/plKey.h"
#include <string>
class pyPlayer class pyPlayer
{ {

2
Sources/Plasma/FeatureLib/pfPython/pyPlayerGlue.cpp

@ -103,7 +103,7 @@ PYTHON_INIT_DEFINITION(ptPlayer, args, keywords)
PYTHON_RETURN_INIT_ERROR; PYTHON_RETURN_INIT_ERROR;
} }
self->fThis->Init(key, _TEMP_CONVERT_TO_CONST_CHAR(name), pid, distSeq); self->fThis->Init(key, name.c_str(), pid, distSeq);
PYTHON_RETURN_INIT_OK; PYTHON_RETURN_INIT_OK;
} }

2
Sources/Plasma/FeatureLib/pfPython/pySceneObject.cpp

@ -223,7 +223,7 @@ plString pySceneObject::GetName()
{ {
if ( fSceneObjects.Count() > 0 ) if ( fSceneObjects.Count() > 0 )
return fSceneObjects[0]->GetName(); return fSceneObjects[0]->GetName();
return _TEMP_CONVERT_FROM_LITERAL(""); return "";
} }
PyObject* pySceneObject::findObj(const plString& name) PyObject* pySceneObject::findObj(const plString& name)

1
Sources/Plasma/FeatureLib/pfPython/pySceneObject.h

@ -52,6 +52,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
#include "pnKeyedObject/plKey.h" #include "pnKeyedObject/plKey.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include <vector>
class pyMatrix44; class pyMatrix44;

6
Sources/Plasma/FeatureLib/pfPython/pyStatusLog.cpp

@ -72,7 +72,7 @@ bool pyStatusLog::Open(plString logName, uint32_t numLines, uint32_t flags)
// create a status log guy for this // create a status log guy for this
fICreatedLog = true; fICreatedLog = true;
fLog = plStatusLogMgr::GetInstance().CreateStatusLog( (uint8_t)numLines, _TEMP_CONVERT_TO_CONST_CHAR(logName), flags ); fLog = plStatusLogMgr::GetInstance().CreateStatusLog( (uint8_t)numLines, logName.c_str(), flags );
if (fLog) if (fLog)
{ {
fLog->SetForceLog(true); fLog->SetForceLog(true);
@ -85,7 +85,7 @@ bool pyStatusLog::Write(plString text)
{ {
if (fLog) if (fLog)
{ {
fLog->AddLine(_TEMP_CONVERT_TO_CONST_CHAR(text)); fLog->AddLine(text.c_str());
return true; return true;
} }
@ -100,7 +100,7 @@ bool pyStatusLog::WriteColor(plString text, pyColor& color)
((uint32_t)(color.getRed()*255)<<16) + ((uint32_t)(color.getRed()*255)<<16) +
((uint32_t)(color.getGreen()*255)<<8) + ((uint32_t)(color.getGreen()*255)<<8) +
((uint32_t)(color.getBlue()*255)); ((uint32_t)(color.getBlue()*255));
fLog->AddLine( _TEMP_CONVERT_TO_CONST_CHAR(text), st_color ); fLog->AddLine( text.c_str(), st_color );
return true; return true;
} }

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

@ -673,8 +673,8 @@ void pyVault::CreateNeighborhood()
plUUID guid(GuidGenerate()); plUUID guid(GuidGenerate());
link.GetAgeInfo()->SetAgeInstanceGuid(&guid); link.GetAgeInfo()->SetAgeInstanceGuid(&guid);
link.GetAgeInfo()->SetAgeUserDefinedName( _TEMP_CONVERT_TO_CONST_CHAR(title) ); link.GetAgeInfo()->SetAgeUserDefinedName( title.c_str() );
link.GetAgeInfo()->SetAgeDescription( _TEMP_CONVERT_TO_CONST_CHAR(desc) ); link.GetAgeInfo()->SetAgeDescription( desc.c_str() );
VaultRegisterOwnedAge(&link); VaultRegisterOwnedAge(&link);
} }

2
Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.cpp

@ -46,7 +46,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plgDispatch.h" #include "plgDispatch.h"
#include "plCompression/plZlibStream.h" #include "plCompression/plZlibStream.h"
#include "pnEncryption/plChecksum.h" #include "pnEncryption/plChecksum.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plFile/plSecureStream.h" #include "plFile/plSecureStream.h"
#include "plFile/plStreamSource.h" #include "plFile/plStreamSource.h"
#include "plMessage/plNetCommMsgs.h" #include "plMessage/plNetCommMsgs.h"

2
Sources/Plasma/NucleusLib/pnDispatch/plDispatch.cpp

@ -341,7 +341,7 @@ void plDispatch::IMsgDispatch()
uint32_t rcvTicks = hsTimer::GetPrecTickCount(); uint32_t rcvTicks = hsTimer::GetPrecTickCount();
// Object could be deleted by this message, so we need to log this stuff now // Object could be deleted by this message, so we need to log this stuff now
plString keyname = _TEMP_CONVERT_FROM_LITERAL("(unknown)"); plString keyname = "(unknown)";
const char* className = "(unknown)"; const char* className = "(unknown)";
uint32_t clonePlayerID = 0; uint32_t clonePlayerID = 0;
if (plDispatchLogBase::IsLoggingLong()) if (plDispatchLogBase::IsLoggingLong())

4
Sources/Plasma/NucleusLib/pnKeyedObject/hsKeyedObject.cpp

@ -70,7 +70,7 @@ plString hsKeyedObject::GetKeyName() const
if (fpKey) if (fpKey)
return fpKey->GetName(); return fpKey->GetName();
else else
return _TEMP_CONVERT_FROM_LITERAL("(unknown)"); return "(unknown)";
} }
hsKeyedObject::~hsKeyedObject() hsKeyedObject::~hsKeyedObject()
@ -145,7 +145,7 @@ void hsKeyedObject::UnRegisterAsManual(plUoid& inUoid)
#if !HS_BUILD_FOR_UNIX // disable for unix servers #if !HS_BUILD_FOR_UNIX // disable for unix servers
hsAssert(false, hsAssert(false,
plString::Format("Request to Unregister wrong FixedKey, keyName=%s, inUoid=%s, myUoid=%s", plString::Format("Request to Unregister wrong FixedKey, keyName=%s, inUoid=%s, myUoid=%s",
fpKey->GetName().s_str("?"), inUoid.StringIze().c_str(), myUoid.StringIze().c_str()).c_str()); fpKey->GetName().c_str("?"), inUoid.StringIze().c_str(), myUoid.StringIze().c_str()).c_str());
#endif #endif
} }
((plKeyImp*)fpKey)->UnRegister(); ((plKeyImp*)fpKey)->UnRegister();

77
Sources/Plasma/NucleusLib/pnKeyedObject/plFixedKey.cpp

@ -82,48 +82,47 @@ struct plKeySeed
// 2) Be sure your ClassIndex CLASS_INDEX(plSceneObject) matches the type of object you want to have the fixedKey // 2) Be sure your ClassIndex CLASS_INDEX(plSceneObject) matches the type of object you want to have the fixedKey
// 3) Make sure the Obj is unique for this location/Type Combo... (validated at runtime) // 3) Make sure the Obj is unique for this location/Type Combo... (validated at runtime)
#define _TCFL _TEMP_CONVERT_FROM_LITERAL
plKeySeed SeedList[] = { plKeySeed SeedList[] = {
// Key Enum Type Obj // Key Enum Type Obj
{ kFirst_Fixed_KEY, CLASS_INDEX_SCOPED( plSceneObject ), _TCFL("kFirst_Fixed_KEY") }, { kFirst_Fixed_KEY, CLASS_INDEX_SCOPED( plSceneObject ), "kFirst_Fixed_KEY", },
{ kLOSObject_KEY, CLASS_INDEX_SCOPED( plLOSDispatch ), _TCFL("kLOSObject_KEY"), }, { kLOSObject_KEY, CLASS_INDEX_SCOPED( plLOSDispatch ), "kLOSObject_KEY", },
{ kTimerCallbackManager_KEY, CLASS_INDEX_SCOPED( plTimerCallbackManager ), _TCFL("kTimerCallbackManager_KEY"), }, { kTimerCallbackManager_KEY, CLASS_INDEX_SCOPED( plTimerCallbackManager ), "kTimerCallbackManager_KEY", },
{ kConsoleObject_KEY, CLASS_INDEX_SCOPED( pfConsole ), _TCFL("kConsoleObject_KEY"), }, { kConsoleObject_KEY, CLASS_INDEX_SCOPED( pfConsole ), "kConsoleObject_KEY", },
{ kAudioSystem_KEY, CLASS_INDEX_SCOPED( plAudioSystem ), _TCFL("kAudioSystem_KEY"), }, { kAudioSystem_KEY, CLASS_INDEX_SCOPED( plAudioSystem ), "kAudioSystem_KEY", },
{ kInput_KEY, CLASS_INDEX_SCOPED( plInputManager ), _TCFL("kInput_KEY"), }, { kInput_KEY, CLASS_INDEX_SCOPED( plInputManager ), "kInput_KEY", },
{ kClient_KEY, CLASS_INDEX_SCOPED( plClient ), _TCFL("kClient_KEY"), }, { kClient_KEY, CLASS_INDEX_SCOPED( plClient ), "kClient_KEY", },
{ kNetClientMgr_KEY, CLASS_INDEX_SCOPED( plNetClientMgr ), _TCFL("kNetClientMgr_KEY"), }, { kNetClientMgr_KEY, CLASS_INDEX_SCOPED( plNetClientMgr ), "kNetClientMgr_KEY", },
{ kListenerMod_KEY, CLASS_INDEX_SCOPED( plListener ), _TCFL("kListenerMod_KEY"), }, { kListenerMod_KEY, CLASS_INDEX_SCOPED( plListener ), "kListenerMod_KEY", },
{ kTransitionMgr_KEY, CLASS_INDEX_SCOPED( plTransitionMgr ), _TCFL("kTransitionMgr_KEY"), }, { kTransitionMgr_KEY, CLASS_INDEX_SCOPED( plTransitionMgr ), "kTransitionMgr_KEY", },
{ kLinkEffectsMgr_KEY, CLASS_INDEX_SCOPED( plLinkEffectsMgr ), _TCFL("kLinkEffectsMgr_KEY"), }, { kLinkEffectsMgr_KEY, CLASS_INDEX_SCOPED( plLinkEffectsMgr ), "kLinkEffectsMgr_KEY", },
{ kGameGUIMgr_KEY, CLASS_INDEX_SCOPED( pfGameGUIMgr ), _TCFL("kGameGUIMgr_KEY"), }, { kGameGUIMgr_KEY, CLASS_INDEX_SCOPED( pfGameGUIMgr ), "kGameGUIMgr_KEY", },
{ kGameGUIDynamicDlg_KEY, CLASS_INDEX_SCOPED( plSceneNode ), _TCFL("kGameGUIDynamicDlg_KEY"), }, { kGameGUIDynamicDlg_KEY, CLASS_INDEX_SCOPED( plSceneNode ), "kGameGUIDynamicDlg_KEY", },
{ kVirtualCamera1_KEY, CLASS_INDEX_SCOPED( plVirtualCam1 ), _TCFL("kVirtualCamera_KEY"), }, { kVirtualCamera1_KEY, CLASS_INDEX_SCOPED( plVirtualCam1 ), "kVirtualCamera_KEY", },
{ kDefaultCameraMod1_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), _TCFL("kDefaultCameraMod1_KEY"), }, { kDefaultCameraMod1_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), "kDefaultCameraMod1_KEY", },
{ kKIGUIGlue_KEY, CLASS_INDEX_SCOPED( pfKI ), _TCFL("kKIGUIGlue_KEY"), }, { kKIGUIGlue_KEY, CLASS_INDEX_SCOPED( pfKI ), "kKIGUIGlue_KEY", },
{ kClothingMgr_KEY, CLASS_INDEX_SCOPED( plClothingMgr ), _TCFL("kClothingMgr_KEY"), }, { kClothingMgr_KEY, CLASS_INDEX_SCOPED( plClothingMgr ), "kClothingMgr_KEY", },
{ kInputInterfaceMgr_KEY, CLASS_INDEX_SCOPED( plInputInterfaceMgr ), _TCFL("kInputInterfaceMgr_KEY"), }, { kInputInterfaceMgr_KEY, CLASS_INDEX_SCOPED( plInputInterfaceMgr ), "kInputInterfaceMgr_KEY", },
{ kAVIWriter_KEY, CLASS_INDEX_SCOPED( plAVIWriter ), _TCFL("kAVIWriter_KEY"), }, { kAVIWriter_KEY, CLASS_INDEX_SCOPED( plAVIWriter ), "kAVIWriter_KEY", },
{ kResManagerHelper_KEY, CLASS_INDEX_SCOPED( plResManagerHelper ), _TCFL("kResManagerHelper_KEY"), }, { kResManagerHelper_KEY, CLASS_INDEX_SCOPED( plResManagerHelper ), "kResManagerHelper_KEY", },
{ kAvatarMgr_KEY, CLASS_INDEX_SCOPED( plAvatarMgr ), _TCFL("kAvatarMgr_KEY"), }, { kAvatarMgr_KEY, CLASS_INDEX_SCOPED( plAvatarMgr ), "kAvatarMgr_KEY", },
{ kSimulationMgr_KEY, CLASS_INDEX_SCOPED( plSimulationMgr ), _TCFL("kSimulationMgr_KEY"), }, { kSimulationMgr_KEY, CLASS_INDEX_SCOPED( plSimulationMgr ), "kSimulationMgr_KEY", },
{ kTransitionCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), _TCFL("kTransitionCamera_KEY"), }, { kTransitionCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), "kTransitionCamera_KEY", },
{ kCCRMgr_KEY, CLASS_INDEX_SCOPED( plCCRMgr ), _TCFL("kCCRMgr_KEY"), }, { kCCRMgr_KEY, CLASS_INDEX_SCOPED( plCCRMgr ), "kCCRMgr_KEY", },
{ kNetClientCloneRoom_KEY, CLASS_INDEX_SCOPED( plSceneNode ), _TCFL("kNetClientCloneRoom_KEY"), }, { kNetClientCloneRoom_KEY, CLASS_INDEX_SCOPED( plSceneNode ), "kNetClientCloneRoom_KEY", },
{ kMarkerMgr_KEY, CLASS_INDEX_SCOPED( pfMarkerMgr ), _TCFL("kMarkerMgr_KEY"), }, { kMarkerMgr_KEY, CLASS_INDEX_SCOPED( pfMarkerMgr ), "kMarkerMgr_KEY", },
{ kAutoProfile_KEY, CLASS_INDEX_SCOPED( plAutoProfile ), _TCFL("kAutoProfile_KEY"), }, { kAutoProfile_KEY, CLASS_INDEX_SCOPED( plAutoProfile ), "kAutoProfile_KEY", },
{ kGlobalVisMgr_KEY, CLASS_INDEX_SCOPED( plVisMgr ), _TCFL("kGlobalVisMgr_KEY"), }, { kGlobalVisMgr_KEY, CLASS_INDEX_SCOPED( plVisMgr ), "kGlobalVisMgr_KEY", },
{ kFontCache_KEY, CLASS_INDEX_SCOPED( plFontCache ), _TCFL("kFontCache_KEY"), }, { kFontCache_KEY, CLASS_INDEX_SCOPED( plFontCache ), "kFontCache_KEY", },
{ kRelevanceMgr_KEY, CLASS_INDEX_SCOPED( plRelevanceMgr ), _TCFL("kRelevanceMgr_KEY"), }, { kRelevanceMgr_KEY, CLASS_INDEX_SCOPED( plRelevanceMgr ), "kRelevanceMgr_KEY", },
{ kJournalBookMgr_KEY, CLASS_INDEX_SCOPED( pfJournalBook ), _TCFL("kJournalBookMgr_KEY") }, { kJournalBookMgr_KEY, CLASS_INDEX_SCOPED( pfJournalBook ), "kJournalBookMgr_KEY", },
{ kAgeLoader_KEY, CLASS_INDEX_SCOPED( plAgeLoader), _TCFL("kAgeLoader_KEY") }, { kAgeLoader_KEY, CLASS_INDEX_SCOPED( plAgeLoader), "kAgeLoader_KEY", },
{ kBuiltIn3rdPersonCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), _TCFL("kBuiltIn3rdPersonCamera_KEY"), }, { kBuiltIn3rdPersonCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), "kBuiltIn3rdPersonCamera_KEY", },
{ kSecurePreloader_KEY, CLASS_INDEX_SCOPED( pfSecurePreloader ), _TCFL("kSecurePreloader_KEY"), }, { kSecurePreloader_KEY, CLASS_INDEX_SCOPED( pfSecurePreloader ), "kSecurePreloader_KEY", },
{ kLast_Fixed_KEY, CLASS_INDEX_SCOPED( plSceneObject ), _TCFL("kLast_Fixed_KEY"), } { kLast_Fixed_KEY, CLASS_INDEX_SCOPED( plSceneObject ), "kLast_Fixed_KEY", }
}; };
#undef _TCFL #undef _TCFL

7
Sources/Plasma/NucleusLib/pnKeyedObject/plKeyImp.cpp

@ -68,7 +68,7 @@ static uint16_t kClassType = CLASS_INDEX_SCOPED(plSceneNode);
static uint32_t kCloneID = 0; static uint32_t kCloneID = 0;
bool IsTrackedKey(const plKeyImp* key) bool IsTrackedKey(const plKeyImp* key)
{ {
return (strcmp(key->GetName(), kObjName) == 0) && return (key->GetName() == kObjName) &&
key->GetUoid().GetClassType() == kClassType && key->GetUoid().GetClassType() == kClassType &&
key->GetUoid().GetCloneID() == kCloneID; key->GetUoid().GetCloneID() == kCloneID;
} }
@ -348,7 +348,7 @@ void plKeyImp::AddNotifyCreated(plRefMsg* msg, plRefFlags::Type flags)
#ifdef LOG_ACTIVE_REFS #ifdef LOG_ACTIVE_REFS
if (IsTrackedKey(this)) if (IsTrackedKey(this))
{ {
hsStatusMessageF("@@@ %s(%s) adding active ref to %s (%d total)", msg->GetReceiver(0)->GetName(), hsStatusMessageF("@@@ %s(%s) adding active ref to %s (%d total)", msg->GetReceiver(0)->GetName().c_str(),
plFactory::GetNameOfClass(msg->GetReceiver(0)->GetUoid().GetClassType()), kObjName, fNumActiveRefs+1); plFactory::GetNameOfClass(msg->GetReceiver(0)->GetUoid().GetClassType()), kObjName, fNumActiveRefs+1);
} }
#endif // LOG_ACTIVE_REFS #endif // LOG_ACTIVE_REFS
@ -635,7 +635,8 @@ void plKeyImp::IRelease(plKeyImp* iTargetKey)
// it has been notified it is going away. // it has been notified it is going away.
#ifdef LOG_ACTIVE_REFS #ifdef LOG_ACTIVE_REFS
if (isActive && IsTrackedKey(iTargetKey)) if (isActive && IsTrackedKey(iTargetKey))
hsStatusMessageF("@@@ %s(%s) releasing active ref on %s (%d total)", GetName(), plFactory::GetNameOfClass(GetUoid().GetClassType()), kObjName, iTargetKey->fNumActiveRefs-1); hsStatusMessageF("@@@ %s(%s) releasing active ref on %s (%d total)", GetName().c_str(),
plFactory::GetNameOfClass(GetUoid().GetClassType()), kObjName, iTargetKey->fNumActiveRefs-1);
#endif // LOG_ACTIVE_REFS #endif // LOG_ACTIVE_REFS
if (isActive && iTargetKey->GetActiveRefs() && !iTargetKey->DecActiveRefs()) if (isActive && iTargetKey->GetActiveRefs() && !iTargetKey->DecActiveRefs())

4
Sources/Plasma/NucleusLib/pnKeyedObject/plMsgForwarder.cpp

@ -142,13 +142,13 @@ bool plMsgForwarder::IForwardCallbackMsg(plMessage *msg)
#if 0 #if 0
hsStatusMessageF("Adding CBMsg, eventSender=%s, eventRemoteMsg=%d\n", hsStatusMessageF("Adding CBMsg, eventSender=%s, eventRemoteMsg=%d\n",
event->GetSender() ? event->GetSender()->GetName() : "nil", fc->fNetPropogate); event->GetSender() ? event->GetSender()->GetName().c_str() : "nil", fc->fNetPropogate);
#endif #endif
} }
} }
#if 0 #if 0
hsStatusMessageF("Fwding CBMsg, sender=%s, remoteMsg=%d", hsStatusMessageF("Fwding CBMsg, sender=%s, remoteMsg=%d",
msg->GetSender() ? msg->GetSender()->GetName() : "nil", msg->HasBCastFlag(plMessage::kNetNonLocal)); msg->GetSender() ? msg->GetSender()->GetName().c_str() : "nil", msg->HasBCastFlag(plMessage::kNetNonLocal));
#endif #endif
IForwardMsg(callbackMsg); IForwardMsg(callbackMsg);

2
Sources/Plasma/NucleusLib/pnModifier/plLogicModBase.cpp

@ -275,7 +275,7 @@ void plLogicModBase::UnTrigger()
#ifdef HS_DEBUGGING #ifdef HS_DEBUGGING
char str[256]; char str[256];
sprintf(str, "LogicModifier %s is Un-triggering, activatorType=%d\n", sprintf(str, "LogicModifier %s is Un-triggering, activatorType=%d\n",
GetKeyName(), HasFlag(kTypeActivator)); GetKeyName().c_str(), HasFlag(kTypeActivator));
plNetClientApp::GetInstance()->DebugMsg(str); plNetClientApp::GetInstance()->DebugMsg(str);
#endif #endif
fNotify->SetSender(this->GetKey()); fNotify->SetSender(this->GetKey());

2
Sources/Plasma/NucleusLib/pnUUID/pnUUID_Unix.cpp

@ -112,7 +112,7 @@ bool plUUID::ToString( plString & out ) const
plUUIDHelper::CopyToNative( g, this ); plUUIDHelper::CopyToNative( g, this );
char buf[40]; char buf[40];
uuid_unparse( g, buf ); uuid_unparse( g, buf );
out = _TEMP_CONVERT_FROM_LITERAL( buf ); out = buf;
return true; return true;
} }

2
Sources/Plasma/NucleusLib/pnUUID/pnUUID_Win32.cpp

@ -90,7 +90,7 @@ bool plUUID::FromString( const char * str )
bool plUUID::ToString( plString & out ) const bool plUUID::ToString( plString & out ) const
{ {
out = _TEMP_CONVERT_FROM_LITERAL(""); out = "";
unsigned char * ubuf; unsigned char * ubuf;
RPC_STATUS s; RPC_STATUS s;
s = UuidToString( (GUID *) this, &ubuf ); s = UuidToString( (GUID *) this, &ubuf );

2
Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.cpp

@ -44,7 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAgeDescription.h" #include "plAgeDescription.h"
#include "hsStlUtils.h" #include "hsStlUtils.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plFile/plInitFileReader.h" #include "plFile/plInitFileReader.h"
#include "plFile/plEncryptedStream.h" #include "plFile/plEncryptedStream.h"
#include "hsStringTokenizer.h" #include "hsStringTokenizer.h"

4
Sources/Plasma/PubUtilLib/plAgeDescription/plAgeManifest.cpp

@ -51,8 +51,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAgeManifest.h" #include "plAgeManifest.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plFile/plInitFileReader.h" #include "plFile/plInitFileReader.h"
#include "hsStringTokenizer.h" #include "hsStringTokenizer.h"

2
Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp

@ -46,7 +46,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAgeLoader/plAgeLoader.h" #include "plAgeLoader/plAgeLoader.h"
#include "plCompression/plZlibStream.h" #include "plCompression/plZlibStream.h"
#include "pnEncryption/plChecksum.h" #include "pnEncryption/plChecksum.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plMessage/plResPatcherMsg.h" #include "plMessage/plResPatcherMsg.h"
#include "pnNetBase/pnNbError.h" #include "pnNetBase/pnNbError.h"
#include "plNetGameLib/plNetGameLib.h" #include "plNetGameLib/plNetGameLib.h"

4
Sources/Plasma/PubUtilLib/plAudio/plSound.cpp

@ -163,7 +163,7 @@ void plSound::IUpdateDebugPlate( void )
fDebugPlate->SetPosition( -0.5, 0 ); fDebugPlate->SetPosition( -0.5, 0 );
fDebugPlate->SetDataRange( 0, 100, 100 ); fDebugPlate->SetDataRange( 0, 100, 100 );
fDebugPlate->SetColors( 0x80202000 ); fDebugPlate->SetColors( 0x80202000 );
fDebugPlate->SetTitle( _TEMP_CONVERT_TO_CONST_CHAR( GetKeyName() ) ); // Bleah fDebugPlate->SetTitle( GetKeyName().c_str() ); // Bleah
fDebugPlate->SetLabelText( "Desired", "Curr", "Soft", "Dist" ); fDebugPlate->SetLabelText( "Desired", "Curr", "Soft", "Dist" );
} }
@ -190,7 +190,7 @@ void plSound::SetCurrDebugPlate( const plKey soundKey )
{ {
fDebugPlate->ClearData(); fDebugPlate->ClearData();
fDebugPlate->SetVisible( true ); fDebugPlate->SetVisible( true );
fDebugPlate->SetTitle( _TEMP_CONVERT_TO_CONST_CHAR( fCurrDebugPlateSound->GetKeyName() ) ); // Bleah fDebugPlate->SetTitle( fCurrDebugPlateSound->GetKeyName().c_str() ); // Bleah
} }
} }
} }

2
Sources/Plasma/PubUtilLib/plAudio/plWin32StreamingSound.cpp

@ -44,7 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsGeometry3.h" #include "hsGeometry3.h"
#include "plgDispatch.h" #include "plgDispatch.h"
#include "plProfile.h" #include "plProfile.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plWin32Sound.h" #include "plWin32Sound.h"
#include "plWin32StreamingSound.h" #include "plWin32StreamingSound.h"

4
Sources/Plasma/PubUtilLib/plAudioCore/plAudioFileReader.cpp

@ -55,8 +55,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAudioCore.h" #include "plAudioCore.h"
//#include "hsTimer.h" //#include "hsTimer.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
#include "plBufferedFileReader.h" #include "plBufferedFileReader.h"
#include "plCachedFileReader.h" #include "plCachedFileReader.h"

4
Sources/Plasma/PubUtilLib/plAudioCore/plSoundBuffer.cpp

@ -49,8 +49,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plgDispatch.h" #include "plgDispatch.h"
#include "hsResMgr.h" #include "hsResMgr.h"
#include "pnMessage/plRefMsg.h" #include "pnMessage/plRefMsg.h"
#include "plFile/plFileUtils.h" #include "plFileUtils.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "hsTimer.h" #include "hsTimer.h"

6
Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.cpp

@ -78,8 +78,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// //
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
#ifdef TRACK_AG_ALLOCS #ifdef TRACK_AG_ALLOCS
extern const char *gGlobalAnimName = nil; plString gGlobalAnimName;
extern const char *gGlobalChannelName = nil; plString gGlobalChannelName;
#endif // TRACK_AG_ALLOCS #endif // TRACK_AG_ALLOCS
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
@ -172,7 +172,7 @@ plAGAnimInstance::plAGAnimInstance(plAGAnim * anim, plAGMasterMod * master,
fFadeBlend = fFadeAmp = false; fFadeBlend = fFadeAmp = false;
#ifdef TRACK_AG_ALLOCS #ifdef TRACK_AG_ALLOCS
gGlobalAnimName = nil; gGlobalAnimName = "";
#endif // TRACK_AG_ALLOCS #endif // TRACK_AG_ALLOCS
} }

4
Sources/Plasma/PubUtilLib/plAvatar/plAGAnimInstance.h

@ -261,8 +261,8 @@ protected:
//#endif //#endif
#ifdef TRACK_AG_ALLOCS #ifdef TRACK_AG_ALLOCS
extern const char *gGlobalAnimName; extern plString gGlobalAnimName;
extern const char *gGlobalChannelName; extern plString gGlobalChannelName;
void RegisterAGAlloc(plAGChannel *object, const char *chanName, const char *animName, uint16_t classIndex); void RegisterAGAlloc(plAGChannel *object, const char *chanName, const char *animName, uint16_t classIndex);
void UnRegisterAGAlloc(plAGChannel *object); void UnRegisterAGAlloc(plAGChannel *object);

4
Sources/Plasma/PubUtilLib/plAvatar/plAGApplicator.h

@ -104,10 +104,6 @@ public:
void SetChannelName(const plString &name); void SetChannelName(const plString &name);
plString GetChannelName(); plString GetChannelName();
// TEMP plString REVISIT
// Because I'm TOO LAZY to keep converting all these calls to SetChannelName
void SetChannelName(const char *name) { SetChannelName(_TEMP_CONVERT_FROM_LITERAL(name)); }
/** Optionally suppress the action of this applicator. /** Optionally suppress the action of this applicator.
The applicator can still be forced to apply using the force The applicator can still be forced to apply using the force
paramater of the Apply function. */ paramater of the Apply function. */

2
Sources/Plasma/PubUtilLib/plAvatar/plAGChannel.cpp

@ -61,7 +61,7 @@ plAGChannel::plAGChannel()
{ {
#ifdef TRACK_AG_ALLOCS #ifdef TRACK_AG_ALLOCS
fName = gGlobalAnimName; fName = gGlobalAnimName;
RegisterAGAlloc(this, gGlobalChannelName, gGlobalAnimName, this->ClassIndex()); RegisterAGAlloc(this, gGlobalChannelName.c_str(), gGlobalAnimName.c_str(), this->ClassIndex());
#endif // TRACK_AG_ALLOCS #endif // TRACK_AG_ALLOCS
} }

2
Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp

@ -631,7 +631,7 @@ bool plAGMasterMod::MsgReceive(plMessage* msg)
plString targetName = cmdMsg->GetAnimName(); plString targetName = cmdMsg->GetAnimName();
if (targetName.IsNull()) if (targetName.IsNull())
targetName = _TEMP_CONVERT_FROM_LITERAL(ENTIRE_ANIMATION_NAME); targetName = ENTIRE_ANIMATION_NAME;
plAGAnimInstance *inst = FindAnimInstance(targetName); plAGAnimInstance *inst = FindAnimInstance(targetName);
if (inst != nil) if (inst != nil)

2
Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp

@ -277,7 +277,7 @@ plAGAnimInstance * plAnimStage::Attach(plArmatureMod *armature, plArmatureBrain
if(fAnimInstance) if(fAnimInstance)
{ {
fAnimInstance->Stop(); // we'll be setting the time directly. fAnimInstance->Stop(); // we'll be setting the time directly.
fAnimatedHandle = (fAnimInstance->GetAnimation()->GetChannel(_TEMP_CONVERT_FROM_LITERAL("Handle")) != nil); fAnimatedHandle = (fAnimInstance->GetAnimation()->GetChannel("Handle") != nil);
fAttached = true; fAttached = true;
// this is too early to send the enter notify. we're attached, but we may not // this is too early to send the enter notify. we're attached, but we may not
// have faded in yet. // have faded in yet.

16
Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp

@ -663,7 +663,7 @@ void plArmatureMod::IInitDefaults()
fDontPanicLink = false; fDontPanicLink = false;
fBodyAgeName = "GlobalAvatars"; fBodyAgeName = "GlobalAvatars";
fBodyFootstepSoundPage = "Audio"; fBodyFootstepSoundPage = "Audio";
fAnimationPrefix = _TEMP_CONVERT_FROM_LITERAL("Male"); fAnimationPrefix = "Male";
fUserStr = ""; fUserStr = "";
} }
@ -1034,7 +1034,7 @@ void plArmatureMod::PanicLink(bool playLinkOutAnim /* = true */)
plString animName = MakeAnimationName("FallingLinkOut"); plString animName = MakeAnimationName("FallingLinkOut");
task->SetAnimName(animName); task->SetAnimName(animName);
task->SetMarkerName(_TEMP_CONVERT_FROM_LITERAL("touch")); task->SetMarkerName("touch");
plAvTaskMsg *taskMsg = new plAvTaskMsg(GetKey(), GetKey(), task); plAvTaskMsg *taskMsg = new plAvTaskMsg(GetKey(), GetKey(), task);
taskMsg->Send(); taskMsg->Send();
@ -1057,7 +1057,7 @@ void plArmatureMod::PersonalLink()
plAvOneShotLinkTask *task = new plAvOneShotLinkTask; plAvOneShotLinkTask *task = new plAvOneShotLinkTask;
plString animName = MakeAnimationName("PersonalLink"); plString animName = MakeAnimationName("PersonalLink");
task->SetAnimName(animName); task->SetAnimName(animName);
task->SetMarkerName(_TEMP_CONVERT_FROM_LITERAL("touch")); task->SetMarkerName("touch");
plAvTaskMsg *taskMsg = new plAvTaskMsg(GetKey(), GetKey(), task); plAvTaskMsg *taskMsg = new plAvTaskMsg(GetKey(), GetKey(), task);
taskMsg->SetBCastFlag(plMessage::kNetPropagate); taskMsg->SetBCastFlag(plMessage::kNetPropagate);
@ -1781,7 +1781,7 @@ void plArmatureMod::Read(hsStream * stream, hsResMgr *mgr)
if (gLoc.IsValid()) if (gLoc.IsValid())
{ {
const plUoid &myUoid = GetKey()->GetUoid(); const plUoid &myUoid = GetKey()->GetUoid();
plUoid SOUoid(gLoc, plSceneObject::Index(), _TEMP_CONVERT_FROM_LITERAL("FootstepSoundObject")); plUoid SOUoid(gLoc, plSceneObject::Index(), "FootstepSoundObject");
fFootSoundSOKey = mgr->FindKey(SOUoid); fFootSoundSOKey = mgr->FindKey(SOUoid);
if (fFootSoundSOKey) if (fFootSoundSOKey)
{ {
@ -1791,7 +1791,7 @@ void plArmatureMod::Read(hsStream * stream, hsResMgr *mgr)
} }
// Add the effect to our effects manager // Add the effect to our effects manager
plUoid effectUoid(gLoc, plArmatureEffectFootSound::Index(), _TEMP_CONVERT_FROM_LITERAL("FootstepSounds") ); plUoid effectUoid(gLoc, plArmatureEffectFootSound::Index(), "FootstepSounds");
plKey effectKey = mgr->FindKey(effectUoid); plKey effectKey = mgr->FindKey(effectUoid);
if (effectKey) if (effectKey)
{ {
@ -1802,7 +1802,7 @@ void plArmatureMod::Read(hsStream * stream, hsResMgr *mgr)
mgr->AddViaNotify(effectKey, new plGenRefMsg(effectMgrKey, plRefMsg::kOnCreate, -1, -1), plRefFlags::kActiveRef); mgr->AddViaNotify(effectKey, new plGenRefMsg(effectMgrKey, plRefMsg::kOnCreate, -1, -1), plRefFlags::kActiveRef);
// Get the linking sound // Get the linking sound
plUoid LinkUoid(gLoc, plSceneObject::Index(), _TEMP_CONVERT_FROM_LITERAL("LinkSoundSource")); plUoid LinkUoid(gLoc, plSceneObject::Index(), "LinkSoundSource");
fLinkSoundSOKey = mgr->FindKey(LinkUoid); fLinkSoundSOKey = mgr->FindKey(LinkUoid);
if (fLinkSoundSOKey) if (fLinkSoundSOKey)
{ {
@ -1896,7 +1896,7 @@ void plArmatureMod::ICustomizeApplicator()
{ {
plArmatureModBase::ICustomizeApplicator(); plArmatureModBase::ICustomizeApplicator();
const plAGModifier *agMod = GetChannelMod(_TEMP_CONVERT_FROM_LITERAL("Bone_Root"), true); const plAGModifier *agMod = GetChannelMod("Bone_Root", true);
if (agMod) if (agMod)
{ {
// are there any applicators that manipulate the transform? // are there any applicators that manipulate the transform?
@ -2379,7 +2379,7 @@ bool plArmatureMod::FindMatchingGenericBrain(const char *names[], int count)
plString plArmatureMod::MakeAnimationName(const char *baseName) const plString plArmatureMod::MakeAnimationName(const char *baseName) const
{ {
return fAnimationPrefix + _TEMP_CONVERT_FROM_LITERAL(baseName); return fAnimationPrefix + baseName;
} }
plString plArmatureMod::GetRootName() plString plArmatureMod::GetRootName()

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

@ -714,7 +714,7 @@ void plAvBrainClimb::ICalcProbeLengths()
hsAssert(up, "Couldn't find ClimbUp animation."); hsAssert(up, "Couldn't find ClimbUp animation.");
if(up) if(up)
{ {
GetStartToEndTransform(up, &upMove, nil, _TEMP_CONVERT_FROM_LITERAL("Handle")); GetStartToEndTransform(up, &upMove, nil, "Handle");
fVerticalProbeLength = upMove.GetTranslate().fZ; fVerticalProbeLength = upMove.GetTranslate().fZ;
} else } else
fVerticalProbeLength = 4.0f; // guess fVerticalProbeLength = 4.0f; // guess
@ -722,7 +722,7 @@ void plAvBrainClimb::ICalcProbeLengths()
hsAssert(left, "Couldn't find ClimbLeft animation."); hsAssert(left, "Couldn't find ClimbLeft animation.");
if(left) if(left)
{ {
GetStartToEndTransform(left, &leftMove, nil, _TEMP_CONVERT_FROM_LITERAL("Handle")); GetStartToEndTransform(left, &leftMove, nil, "Handle");
fHorizontalProbeLength = leftMove.GetTranslate().fX; fHorizontalProbeLength = leftMove.GetTranslate().fX;
} else } else
fHorizontalProbeLength = 3.0f; // guess fHorizontalProbeLength = 3.0f; // guess

2
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.cpp

@ -300,7 +300,7 @@ std::string plAvBrainCritter::BehaviorName(int behavior) const
plString plAvBrainCritter::AnimationName(int behavior) const plString plAvBrainCritter::AnimationName(int behavior) const
{ {
if ((behavior >= fBehaviors.Count()) || (behavior < 0)) if ((behavior >= fBehaviors.Count()) || (behavior < 0))
return _TEMP_CONVERT_FROM_LITERAL(""); return "";
return ((CritterBehavior*)fBehaviors[behavior])->AnimName(); return ((CritterBehavior*)fBehaviors[behavior])->AnimName();
} }

2
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp

@ -309,7 +309,7 @@ void plAvBrainHuman::IInitBoneMap()
for(int i = 0; i < numTuples; i++) for(int i = 0; i < numTuples; i++)
{ {
HumanBoneID id = tupleMap[i].fID; HumanBoneID id = tupleMap[i].fID;
plString name = _TEMP_CONVERT_FROM_LITERAL(tupleMap[i].fName); plString name = tupleMap[i].fName;
const plSceneObject * bone = this->fAvMod->FindBone(name); const plSceneObject * bone = this->fAvMod->FindBone(name);
if( bone ) if( bone )

2
Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp

@ -535,7 +535,7 @@ bool plAvTaskSeek::IUpdateObjective(plArmatureMod *avatar)
plAGAnim *anim = avatar->FindCustomAnim(fAnimName); plAGAnim *anim = avatar->FindCustomAnim(fAnimName);
// don't need to do this every frame; the animation doesn't change. // don't need to do this every frame; the animation doesn't change.
// *** cache the adjustment; // *** cache the adjustment;
GetStartToEndTransform(anim, nil, &adjustment, _TEMP_CONVERT_FROM_LITERAL("Handle")); // actually getting end-to-start GetStartToEndTransform(anim, nil, &adjustment, "Handle"); // actually getting end-to-start
// ... but we do still need to multiply by the (potentially changed) target // ... but we do still need to multiply by the (potentially changed) target
targL2W = targL2W * adjustment; targL2W = targL2W * adjustment;
} }

6
Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp

@ -199,9 +199,9 @@ plKey plAvatarMgr::LoadAvatar(const char *name, const char *accountName, bool is
const plLocation& loc = (globalLoc.IsValid() ? globalLoc : custLoc.IsValid() ? custLoc : maleLoc); const plLocation& loc = (globalLoc.IsValid() ? globalLoc : custLoc.IsValid() ? custLoc : maleLoc);
#endif #endif
plString theName = _TEMP_CONVERT_FROM_LITERAL(name); plString theName = name;
if ( loc == maleLoc ) if ( loc == maleLoc )
theName = _TEMP_CONVERT_FROM_LITERAL("Male"); theName = "Male";
if (loc.IsValid()) if (loc.IsValid())
{ {
@ -1012,7 +1012,7 @@ void plAvatarMgr::OfferLinkingBook(plKey hostKey, plKey guestKey, plMessage *lin
brainG->AddStage(guestAccept); brainG->AddStage(guestAccept);
brainG->AddStage(guestAcceptIdle); brainG->AddStage(guestAcceptIdle);
plCoopCoordinator *coord = new plCoopCoordinator(hostKey, guestKey, brainH, brainG, _TEMP_CONVERT_FROM_LITERAL("Convergence"), 1, 1, linkMsg, true); plCoopCoordinator *coord = new plCoopCoordinator(hostKey, guestKey, brainH, brainG, "Convergence", 1, 1, linkMsg, true);
plAvCoopMsg *coMg = new plAvCoopMsg(hostKey, coord); plAvCoopMsg *coMg = new plAvCoopMsg(hostKey, coord);

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

@ -249,7 +249,7 @@ bool plAvSeekTask::Start(plArmatureMod *avatar, plArmatureBrain *brain, double t
{ {
hsMatrix44 adjustment; hsMatrix44 adjustment;
plAGAnim *anim = avatar->FindCustomAnim(fAnimName); plAGAnim *anim = avatar->FindCustomAnim(fAnimName);
GetStartToEndTransform(anim, nil, &adjustment, _TEMP_CONVERT_FROM_LITERAL("Handle")); // actually getting end-to-start GetStartToEndTransform(anim, nil, &adjustment, "Handle"); // actually getting end-to-start
targetL2W = targetL2W * adjustment; targetL2W = targetL2W * adjustment;
} }
break; break;
@ -624,7 +624,7 @@ bool plAvOneShotTask::Start(plArmatureMod *avatar, plArmatureBrain *brain, doubl
plgDispatch::MsgSend( pMsg ); // whoosh... off it goes plgDispatch::MsgSend( pMsg ); // whoosh... off it goes
} }
fMoveHandle = (fAnimInstance->GetAnimation()->GetChannel(_TEMP_CONVERT_FROM_LITERAL("Handle")) != nil); fMoveHandle = (fAnimInstance->GetAnimation()->GetChannel("Handle") != nil);
if(fMoveHandle) if(fMoveHandle)
{ {
plMatrixDifferenceApp *differ = avatar->GetRootAnimator(); plMatrixDifferenceApp *differ = avatar->GetRootAnimator();

2
Sources/Plasma/PubUtilLib/plAvatar/plMultistageBehMod.cpp

@ -161,7 +161,7 @@ bool plMultistageBehMod::MsgReceive(plMessage* msg)
#ifdef DEBUG_MULTISTAGE #ifdef DEBUG_MULTISTAGE
char sbuf[256]; char sbuf[256];
sprintf(sbuf,"plMultistageModMsg - starting multistage from %s",sender->GetName()); sprintf(sbuf,"plMultistageModMsg - starting multistage from %s",sender->GetName().c_str());
plAvatarMgr::GetInstance()->GetLog()->AddLine(sbuf); plAvatarMgr::GetInstance()->GetLog()->AddLine(sbuf);
#endif #endif
plAvSeekMsg *seeker = new plAvSeekMsg(nil, avModKey, seekKey, 1.0f, fSmartSeek); plAvSeekMsg *seeker = new plAvSeekMsg(nil, avModKey, seekKey, 1.0f, fSmartSeek);

2
Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.cpp

@ -279,7 +279,7 @@ bool IIsClosestAnim(const char *animName, hsMatrix44 &sitGoal, float &closestDis
// The first step is to get the transform from the end to the beginning of the // The first step is to get the transform from the end to the beginning of the
// animation. That's what this next line is doing. It's a bit unintuitive // animation. That's what this next line is doing. It's a bit unintuitive
// until you look at the parameter definitions. // until you look at the parameter definitions.
GetStartToEndTransform(anim, nil, &animEndToStart, _TEMP_CONVERT_FROM_LITERAL("Handle")); GetStartToEndTransform(anim, nil, &animEndToStart, "Handle");
hsMatrix44 candidateGoal = sitGoal * animEndToStart; hsMatrix44 candidateGoal = sitGoal * animEndToStart;
hsPoint3 distP = candidateGoal.GetTranslate() - curPosition; hsPoint3 distP = candidateGoal.GetTranslate() - curPosition;
hsVector3 distV(distP.fX, distP.fY, distP.fZ); hsVector3 distV(distP.fX, distP.fY, distP.fZ);

18
Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpansExport.cpp

@ -197,7 +197,7 @@ void plDrawableSpans::Write( hsStream* s, hsResMgr* mgr )
hsUNIXStream log; hsUNIXStream log;
log.Open("log\\GBuf.log", "ab"); log.Open("log\\GBuf.log", "ab");
char buf[256]; char buf[256];
sprintf(buf, "Drawable Span: %s, GroupNum: %u\r\n", GetKeyName(), i); sprintf(buf, "Drawable Span: %s, GroupNum: %u\r\n", GetKeyName().c_str(), i);
log.WriteString(buf); log.WriteString(buf);
log.Close(); log.Close();
#endif #endif
@ -386,8 +386,8 @@ static void ILogSpan(plStatusLog* statusLog, plGeometrySpan* geo, plVertexSpan*
uint32_t ptr = cell->fVtxStart + span->fCellOffset * stride; uint32_t ptr = cell->fVtxStart + span->fCellOffset * stride;
statusLog->AddLineF("From obj <%s> mat <%s> size %d bytes grp=%d (%d offset)", statusLog->AddLineF("From obj <%s> mat <%s> size %d bytes grp=%d (%d offset)",
geo->fMaxOwner.s_str("<unknown>"), geo->fMaxOwner.c_str("<unknown>"),
geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "<unknown>", geo->fMaterial ? geo->fMaterial->GetKeyName().c_str() : "<unknown>",
geo->GetVertexSize(geo->fFormat) * geo->fNumVerts + sizeof(uint16_t) * geo->fNumIndices, geo->GetVertexSize(geo->fFormat) * geo->fNumVerts + sizeof(uint16_t) * geo->fNumIndices,
span->fGroupIdx, span->fGroupIdx,
ptr ptr
@ -404,8 +404,8 @@ static void ILogSpan(plStatusLog* statusLog, plGeometrySpan* geo, plVertexSpan*
else else
{ {
statusLog->AddLineF("Instanced obj <%s> mat <%s> grp=%d (%d/%d/%d/%d/%d/%d/%d/%d)", statusLog->AddLineF("Instanced obj <%s> mat <%s> grp=%d (%d/%d/%d/%d/%d/%d/%d/%d)",
geo->fMaxOwner.s_str("<unknown>"), geo->fMaxOwner.c_str("<unknown>"),
geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "<unknown>", geo->fMaterial ? geo->fMaterial->GetKeyName().c_str() : "<unknown>",
span->fGroupIdx, span->fGroupIdx,
span->fVBufferIdx, span->fVBufferIdx,
span->fCellIdx, span->fCellIdx,
@ -423,8 +423,8 @@ static void ILogSpan(plStatusLog* statusLog, plGeometrySpan* geo, plVertexSpan*
if( geo->fProps & plGeometrySpan::kFirstInstance ) if( geo->fProps & plGeometrySpan::kFirstInstance )
{ {
statusLog->AddLineF("From obj <%s> mat <%s> size %d bytes grp=%d (%d/%d/%d/%d/%d)", statusLog->AddLineF("From obj <%s> mat <%s> size %d bytes grp=%d (%d/%d/%d/%d/%d)",
geo->fMaxOwner.s_str("<unknown>"), geo->fMaxOwner.c_str("<unknown>"),
geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "<unknown>", geo->fMaterial ? geo->fMaterial->GetKeyName().c_str() : "<unknown>",
geo->GetVertexSize(geo->fFormat) * geo->fNumVerts + sizeof(uint16_t) * geo->fNumIndices, geo->GetVertexSize(geo->fFormat) * geo->fNumVerts + sizeof(uint16_t) * geo->fNumIndices,
span->fGroupIdx, span->fGroupIdx,
span->fVBufferIdx, span->fVBufferIdx,
@ -437,8 +437,8 @@ static void ILogSpan(plStatusLog* statusLog, plGeometrySpan* geo, plVertexSpan*
else else
{ {
statusLog->AddLineF("Instanced obj <%s> mat <%s> grp=%d (%d/%d/%d/%d/%d)", statusLog->AddLineF("Instanced obj <%s> mat <%s> grp=%d (%d/%d/%d/%d/%d)",
geo->fMaxOwner.s_str("<unknown>"), geo->fMaxOwner.c_str("<unknown>"),
geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "<unknown>", geo->fMaterial ? geo->fMaterial->GetKeyName().c_str() : "<unknown>",
span->fGroupIdx, span->fGroupIdx,
span->fVBufferIdx, span->fVBufferIdx,
span->fCellIdx, span->fCellIdx,

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

@ -114,7 +114,7 @@ void plInstanceDrawInterface::AddSharedMesh(plSharedMesh *mesh, hsGMaterial *mat
#ifdef MF_NOSHADOW_ACC #ifdef MF_NOSHADOW_ACC
// TESTHACKERY FOLLOWS - GlassesNoShadow // TESTHACKERY FOLLOWS - GlassesNoShadow
uint32_t noShadHack = 0; uint32_t noShadHack = 0;
if( mesh->GetKey() && (strstr(mesh->GetKey()->GetName(), "lasses") || strstr(mesh->GetKey()->GetName(), "oggles")) ) if( mesh->GetKey() && (mesh->GetKey()->GetName().Find("lasses") >= 0 || mesh->GetKey()->GetName().Find("oggles") >= 0) )
noShadHack = plGeometrySpan::kPropNoShadowCast; noShadHack = plGeometrySpan::kPropNoShadowCast;
#endif // MF_NOSHADOW_ACC #endif // MF_NOSHADOW_ACC

12
Sources/Plasma/PubUtilLib/plDrawable/plProxyGen.cpp

@ -158,10 +158,10 @@ hsGMaterial* plProxyGen::IMakeProxyMaterial() const
hsGMaterial* retVal = new hsGMaterial(); hsGMaterial* retVal = new hsGMaterial();
plString buff; plString buff;
if( !GetKey()->GetName().IsNull() ) if( !GetKeyName().IsNull() )
buff = plString::Format("%s_Material", GetKey()->GetName().c_str()); buff = plString::Format("%s_Material", GetKeyName().c_str());
else else
buff = _TEMP_CONVERT_FROM_LITERAL("ProxyMaterial"); buff = "ProxyMaterial";
hsgResMgr::ResMgr()->NewKey( buff, retVal, GetKey() ? GetKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc ); hsgResMgr::ResMgr()->NewKey( buff, retVal, GetKey() ? GetKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc );
plLayer *lay = retVal->MakeBaseLayer(); plLayer *lay = retVal->MakeBaseLayer();
@ -233,10 +233,10 @@ void plProxyGen::IGenerateProxy()
if( fProxyDrawables[idx] && !fProxyDrawables[idx]->GetKey() ) if( fProxyDrawables[idx] && !fProxyDrawables[idx]->GetKey() )
{ {
plString buff; plString buff;
if( !GetKey()->GetName().IsNull() ) if( !GetKeyName().IsNull() )
buff = plString::Format("%s_ProxyDrawable", GetKey()->GetName().c_str()); buff = plString::Format("%s_ProxyDrawable", GetKeyName().c_str());
else else
buff = _TEMP_CONVERT_FROM_LITERAL("ProxyDrawable"); buff = "ProxyDrawable";
hsgResMgr::ResMgr()->NewKey( buff, fProxyDrawables[ idx ], GetKey() ? GetKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc ); hsgResMgr::ResMgr()->NewKey( buff, fProxyDrawables[ idx ], GetKey() ? GetKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc );
} }

10
Sources/Plasma/PubUtilLib/plFile/CMakeLists.txt

@ -5,26 +5,16 @@ include_directories("../../PubUtilLib")
include_directories(${ZLIB_INCLUDE_DIR}) include_directories(${ZLIB_INCLUDE_DIR})
set(plFile_SOURCES set(plFile_SOURCES
hsFiles.cpp
plBrowseFolder.cpp plBrowseFolder.cpp
plEncryptedStream.cpp plEncryptedStream.cpp
plFileUtils.cpp
plInitFileReader.cpp plInitFileReader.cpp
plSecureStream.cpp plSecureStream.cpp
plStreamSource.cpp plStreamSource.cpp
) )
if(WIN32)
set(plFile_SOURCES ${plFile_SOURCES} hsFiles_Win.cpp)
else(WIN32)
set(plFile_SOURCES ${plFile_SOURCES} hsFiles_Unix.cpp)
endif(WIN32)
set(plFile_HEADERS set(plFile_HEADERS
hsFiles.h
plBrowseFolder.h plBrowseFolder.h
plEncryptedStream.h plEncryptedStream.h
plFileUtils.h
plInitFileReader.h plInitFileReader.h
plSecureStream.h plSecureStream.h
plStreamSource.h plStreamSource.h

61
Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp

@ -62,6 +62,9 @@ static const int kFileStartOffset = kMagicStringLen + sizeof(uint32_t);
static const int kMaxBufferedFileSize = 10*1024; static const int kMaxBufferedFileSize = 10*1024;
const char plSecureStream::kKeyFilename[] = "encryption.key";
const wchar_t plSecureStream::kWKeyFilename[] = L"encryption.key";
plSecureStream::plSecureStream(bool deleteOnExit, uint32_t* key) : plSecureStream::plSecureStream(bool deleteOnExit, uint32_t* key) :
fRef(INVALID_HANDLE_VALUE), fRef(INVALID_HANDLE_VALUE),
fActualFileSize(0), fActualFileSize(0),
@ -757,3 +760,61 @@ hsStream* plSecureStream::OpenSecureFileWrite(const wchar_t* fileName, uint32_t*
s->Open(fileName, L"wb"); s->Open(fileName, L"wb");
return s; return s;
} }
//// GetSecureEncryptionKey //////////////////////////////////////////////////
bool plSecureStream::GetSecureEncryptionKey(const char* filename, uint32_t* key, unsigned length)
{
wchar_t* wFilename = hsStringToWString(filename);
bool ret = GetSecureEncryptionKey(wFilename, key, length);
delete [] wFilename;
return ret;
}
bool plSecureStream::GetSecureEncryptionKey(const wchar_t* filename, uint32_t* key, unsigned length)
{
// looks for an encryption key file in the same directory, and reads it
std::wstring sFilename = filename;
// grab parent directory
size_t loc = sFilename.rfind(L"\\");
if (loc == std::wstring::npos)
loc = sFilename.rfind(L"/");
std::wstring sDir;
if (loc != std::wstring::npos)
sDir = sFilename.substr(0, loc);
else // no directory
sDir = L"./";
if ((sDir[sDir.length()-1] != L'/') && (sDir[sDir.length()-1] != L'\\'))
sDir += L'/'; // add the slash, if it doesn't has one
// now add the key filename
std::wstring keyFile = sDir + kWKeyFilename;
if (plFileUtils::FileExists(keyFile.c_str()))
{
// file exists, read from it
hsUNIXStream file;
file.Open(keyFile.c_str(), L"rb");
unsigned bytesToRead = length * sizeof(uint32_t);
uint8_t* buffer = (uint8_t*)malloc(bytesToRead);
unsigned bytesRead = file.Read(bytesToRead, buffer);
file.Close();
unsigned memSize = min(bytesToRead, bytesRead);
memcpy(key, buffer, memSize);
free(buffer);
return true;
}
// file doesn't exist, use default key
unsigned memSize = min(length, arrsize(plSecureStream::kDefaultKey));
memSize *= sizeof(uint32_t);
memcpy(key, plSecureStream::kDefaultKey, memSize);
return false;
}

9
Sources/Plasma/PubUtilLib/plFile/plSecureStream.h

@ -131,6 +131,15 @@ public:
static hsStream* OpenSecureFileWrite(const wchar_t* fileName, uint32_t* key = nil); static hsStream* OpenSecureFileWrite(const wchar_t* fileName, uint32_t* key = nil);
static const uint32_t kDefaultKey[4]; // our default encryption key static const uint32_t kDefaultKey[4]; // our default encryption key
// searches the parent directory of filename for the encryption key file, and reads it
// into the key passed in. Returns false if the key file didn't exist (and sets key to
// the default key)
static bool GetSecureEncryptionKey(const char* filename, uint32_t* key, unsigned length);
static bool GetSecureEncryptionKey(const wchar_t* filename, uint32_t* key, unsigned length);
static const char kKeyFilename[];
static const wchar_t kWKeyFilename[];
}; };
#endif // plSecureStream_h_inc #endif // plSecureStream_h_inc

2
Sources/Plasma/PubUtilLib/plFile/plStreamSource.cpp

@ -128,7 +128,7 @@ hsStream* plStreamSource::GetFile(std::wstring filename)
if (plSecureStream::IsSecureFile(sFilename.c_str())) if (plSecureStream::IsSecureFile(sFilename.c_str()))
{ {
uint32_t encryptionKey[4]; uint32_t encryptionKey[4];
if (!plFileUtils::GetSecureEncryptionKey(sFilename.c_str(), encryptionKey, 4)) if (!plSecureStream::GetSecureEncryptionKey(sFilename.c_str(), encryptionKey, 4))
{ {
FATAL("Hey camper... You need an NTD key file!"); FATAL("Hey camper... You need an NTD key file!");
return nil; return nil;

2
Sources/Plasma/PubUtilLib/plGImage/plFontCache.cpp

@ -57,7 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plFont.h" #include "plFont.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "pnMessage/plRefMsg.h" #include "pnMessage/plRefMsg.h"
#include "hsResMgr.h" #include "hsResMgr.h"

2
Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp

@ -2138,7 +2138,7 @@ void plMipmap::IAddToMemRecord( plMipmap *mip, plRecord::Method method )
if( mip->GetKey() ) if( mip->GetKey() )
newRecord->fKeyName = mip->GetKeyName(); newRecord->fKeyName = mip->GetKeyName();
else else
newRecord->fKeyName = _TEMP_CONVERT_FROM_LITERAL( "<noKey>" ); newRecord->fKeyName = "<noKey>";
if( mip->fCompressionType != kDirectXCompression ) if( mip->fCompressionType != kDirectXCompression )
newRecord->fUncompressedInfo.fType = mip->fUncompressedInfo.fType; newRecord->fUncompressedInfo.fType = mip->fUncompressedInfo.fType;
else else

2
Sources/Plasma/PubUtilLib/plGImage/plWinFontCache.cpp

@ -63,7 +63,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plWinFontCache.h" #include "plWinFontCache.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "plFile/hsFiles.h" #include "hsFiles.h"
#include "plGImage/plDynSurfaceWriter.h" #include "plGImage/plDynSurfaceWriter.h"
#if HS_BUILD_FOR_WIN32 #if HS_BUILD_FOR_WIN32

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save