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. 64
      Sources/Plasma/CoreLib/plGeneric.cpp
  21. 15
      Sources/Plasma/CoreLib/plGeneric.h
  22. 185
      Sources/Plasma/CoreLib/plString.cpp
  23. 169
      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. 31
      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. 8
      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. 73
      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 "plPipeline/hsG3DDeviceSelector.h"
#include "plFile/plEncryptedStream.h"
#include "plFile/plFileUtils.h"
#include "plFileUtils.h"
#include "plInputCore/plInputManager.h"
#include "plInputCore/plInputInterfaceMgr.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 "plScene/plPageTreeMgr.h"
#include "plScene/plVisMgr.h"
#include "plFile/hsFiles.h"
#include "hsFiles.h"
#include "pfKI/pfKI.h"
@ -1286,7 +1286,7 @@ void plClient::IRoomUnloaded(plSceneNode* node)
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 "pnProduct/pnProduct.h"
#include "plNetGameLib/plNetGameLib.h"
#include "plFile/plFileUtils.h"
#include "plFileUtils.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"))
{
uint32_t dataLen = stream.GetSizeLeft();
char* eulaData = new char[dataLen + 1];
plStringBuffer<char> eula;
char* eulaData = eula.CreateWritableBuffer(dataLen);
memset(eulaData, 0, dataLen + 1);
stream.Read(dataLen, eulaData);
plString str = plString::Steal(eulaData);
SetDlgItemTextW(hwndDlg, IDC_URULOGIN_EULATEXT, _TEMP_CONVERT_TO_WCHAR_T(str));
SetDlgItemTextW(hwndDlg, IDC_URULOGIN_EULATEXT, plString(eula).ToWchar());
}
else // no TOS found, go ahead
EndDialog(hwndDlg, true);
@ -998,15 +998,15 @@ static void SaveUserPass (LoginDialogParam *pLoginParam, char *password)
memset(cryptKey, 0, sizeof(cryptKey));
GetCryptKey(cryptKey, arrsize(cryptKey));
plString theUser = _TEMP_CONVERT_FROM_LITERAL(pLoginParam->username);
plString thePass = (_TEMP_CONVERT_FROM_LITERAL(password)).Left(kMaxPasswordLength);
plString theUser = pLoginParam->username;
plString thePass = plString(password).Left(kMaxPasswordLength);
// if the password field is the fake string then we've already
// loaded the namePassHash from the file
if (thePass.Compare(FAKE_PASS_STRING) != 0)
{
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) {
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)
NetCommSetAuthTokenAndOS(nil, L"mac");
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
{
cmdLine << _TEMP_CONVERT_FROM_WCHAR_T(s_patcherExeName);
cmdLine << plString::FromWchar(s_patcherExeName);
GetAuthSrvHostnames(&addrs);
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
*==LICENSE==*/
#include "plFile/hsFiles.h"
#include "hsFiles.h"
#include "plFile/plEncryptedStream.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
*==LICENSE==*/
#include "plFile/hsFiles.h"
#include "plFile/plFileUtils.h"
#include "hsFiles.h"
#include "plFileUtils.h"
#include "plFile/plSecureStream.h"
#include "pnProduct/pnProduct.h"
@ -61,15 +61,15 @@ void print_help() {
printf("\tplFileSecure (<directory> <ext>)|[/generate /default]\n");
printf("\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("/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(" <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(" 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");
}
@ -103,7 +103,7 @@ void GenerateKey(bool useDefault)
}
hsUNIXStream out;
out.Open(plFileUtils::kKeyFilename, "wb");
out.Open(plSecureStream::kKeyFilename, "wb");
out.Write(sizeof(uint32_t) * arrsize(key), (void*)key);
out.Close();
}
@ -204,7 +204,7 @@ int main(int argc, char *argv[])
else
{
uint32_t key[4];
plFileUtils::GetSecureEncryptionKey(plFileUtils::kKeyFilename, key, arrsize(key));
plSecureStream::GetSecureEncryptionKey(plSecureStream::kKeyFilename, key, arrsize(key));
SecureFiles(directory, ext, key);
}
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==*/
#include "hsTimer.h"
#include "plFile/hsFiles.h"
#include "plFile/plFileUtils.h"
#include "hsFiles.h"
#include "plFileUtils.h"
#include "plResMgr/plResManager.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 "hsStream.h"
#include "plFile/hsFiles.h"
#include "hsFiles.h"
#include <vector>
#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 "plNetGameLib/plNetGameLib.h"
#include "pnEncryption/plChecksum.h"
#include "plFile/plFileUtils.h"
#include "plFileUtils.h"
#include "plCompression/plZlibStream.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)
if(NOT WCHAR_BYTES)
@ -19,6 +20,7 @@ set(CoreLib_SOURCES
hsCritSect.cpp
hsExceptionStack.cpp
hsFastMath.cpp
hsFiles.cpp
hsGeometry3.cpp
hsMatrix33.cpp
hsMatrix44.cpp
@ -34,6 +36,7 @@ set(CoreLib_SOURCES
hsThread.cpp
hsWide.cpp
pcSmallRect.cpp
plFileUtils.cpp
plGeneric.cpp
plLoadMask.cpp
plString.cpp
@ -43,14 +46,15 @@ set(CoreLib_SOURCES
if(WIN32 AND NOT CYGWIN)
set(CoreLib_SOURCES ${CoreLib_SOURCES}
hsThread_Win.cpp
hsFiles_Win.cpp
)
endif(WIN32 AND NOT CYGWIN)
if(UNIX)
set(CoreLib_SOURCES ${CoreLib_SOURCES}
hsThread_Unix.cpp
hsFiles_Unix.cpp
)
endif(UNIX)
set(CoreLib_HEADERS
HeadSpin.h
@ -62,6 +66,7 @@ set(CoreLib_HEADERS
hsCritSect.h
hsExceptions.h
hsFastMath.h
hsFiles.h
hsGeometry3.h
hsHashTable.h
hsMatrix44.h
@ -79,6 +84,7 @@ set(CoreLib_HEADERS
hsThread.h
hsWide.h
pcSmallRect.h
plFileUtils.h
plGeneric.h
plLoadMask.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.
// Use "correct" stricmp based on the selected compiler / library
#if HS_BUILD_FOR_WIN32
#if _MSC_VER
# define stricmp _stricmp
# define strnicmp _strnicmp
# define wcsicmp _wcsicmp

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

12
Sources/Plasma/CoreLib/hsStream.h

@ -124,22 +124,20 @@ public:
virtual bool IsCompressed() { return false; }
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 WriteFmtV(const char * fmt, va_list av);
uint32_t WriteSafeStringLong(const char *string); // uses 4 bytes for length
uint32_t WriteSafeWStringLong(const wchar_t *string);
uint32_t WriteSafeStringLong(const plString &string); // uses 4 bytes for length
uint32_t WriteSafeWStringLong(const plString &string);
char * ReadSafeStringLong();
wchar_t * ReadSafeWStringLong();
uint32_t WriteSafeString(const char *string); // uses 2 bytes for length
uint32_t WriteSafeWString(const wchar_t *string);
uint32_t WriteSafeString(const plString &string); // uses 2 bytes for length
uint32_t WriteSafeWString(const plString &string);
char * ReadSafeString();
wchar_t * ReadSafeWString();
uint32_t WriteSafeString(const plString &string); // uses 2 bytes for length
uint32_t WriteSafeWString(const plString &string);
plString ReadSafeString_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 "plUnifiedTime/plUnifiedTime.h"
#include "plSecureStream.h" // for the default key
#include "plUnifiedTime.h"
#include <time.h>
#include <sys/types.h>
@ -503,61 +501,3 @@ uint32_t plFileUtils::GetFileSize( const wchar_t *path )
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
{
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
bool CreateDir( const char *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
void ConcatFileName(char* path, const char* 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);
};

64
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 char* 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),
plGeneric::plGeneric(const plString& val): fType(kString), fBoolVal(false), fIntVal(0), fFloatVal(0.0),
fStringVal(val) {}
void plGeneric::IReset()
@ -76,7 +59,7 @@ void plGeneric::IReset()
fBoolVal = false;
fIntVal = 0;
fFloatVal = 0.0;
fStringVal = L"";
fStringVal = "";
}
plGeneric& plGeneric::operator=(const bool& val)
@ -103,35 +86,7 @@ plGeneric& plGeneric::operator=(const double& val)
return *this;
}
plGeneric& plGeneric::operator=(const char* 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)
plGeneric& plGeneric::operator=(const plString& val)
{
IReset();
fType = kString;
@ -161,7 +116,7 @@ int plGeneric::Write(hsStream* stream)
break;
case kString:
stream->WriteSafeWString(fStringVal.c_str());
stream->WriteSafeWString(fStringVal);
break;
}
return stream->GetPosition();
@ -189,15 +144,8 @@ int plGeneric::Read(hsStream* stream)
break;
case kString:
{
wchar_t* temp = stream->ReadSafeWString();
if (temp)
{
fStringVal = temp;
delete [] temp;
}
}
fStringVal = stream->ReadSafeWString_TEMP();
break;
}
return stream->GetPosition();
}
}

15
Sources/Plasma/CoreLib/plGeneric.h

@ -62,7 +62,7 @@ private:
bool fBoolVal;
int fIntVal;
double fFloatVal;
std::wstring fStringVal;
plString fStringVal;
void IReset();
@ -71,19 +71,13 @@ public:
plGeneric(const bool& val);
plGeneric(const int& val);
plGeneric(const double& val);
plGeneric(const char* val);
plGeneric(const std::string& val);
plGeneric(const wchar_t* val);
plGeneric(const std::wstring& val);
plGeneric(const plString& val);
void SetToNull() {IReset();}
plGeneric& operator=(const bool& val);
plGeneric& operator=(const int& val);
plGeneric& operator=(const double& val);
plGeneric& operator=(const char* val);
plGeneric& operator=(const std::string& val);
plGeneric& operator=(const wchar_t* val);
plGeneric& operator=(const std::wstring& val);
plGeneric& operator=(const plString& val);
// 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
@ -91,8 +85,7 @@ public:
operator bool() const {return fBoolVal;}
operator int() const {return fIntVal;}
operator double() const {return fFloatVal;}
operator const wchar_t*() const {return fStringVal.c_str();}
operator std::wstring() const {return fStringVal;}
operator plString() const {return fStringVal;}
int Write(hsStream* stream);
int Read(hsStream* stream);

185
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
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
or by snail mail at:
Cyan Worlds, Inc.
@ -29,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <cstring>
#include <cstdlib>
#include <wchar.h>
#include <memory>
const plString plString::Null;
@ -67,7 +84,7 @@ size_t wcsnlen(const wchar_t *s, size_t maxlen)
#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) {
fUtf8Buffer = plStringBuffer<char>();
@ -77,10 +94,17 @@ void plString::IConvertFromUtf8(const char *utf8, size_t size, bool steal)
if ((int32_t)size < 0)
size = strnlen(utf8, -(int32_t)size);
operator=(plStringBuffer<char>(utf8, size));
}
plString &plString::operator=(const plStringBuffer<char> &init)
{
fUtf8Buffer = init;
#ifdef _DEBUG
// Check to make sure the string is actually valid UTF-8
const char *sp = utf8;
while (sp < utf8 + size) {
const char *sp = fUtf8Buffer.GetData();
while (sp < fUtf8Buffer.GetData() + fUtf8Buffer.GetSize()) {
unsigned char unichar = *sp++;
if ((unichar & 0xF8) == 0xF0) {
// Four bytes
@ -102,16 +126,14 @@ void plString::IConvertFromUtf8(const char *utf8, size_t size, bool steal)
}
#endif
fUtf8Buffer = steal ? plStringBuffer<char>::Steal(utf8, size)
: plStringBuffer<char>(utf8, size);
return *this;
}
void plString::IConvertFromUtf16(const uint16_t *utf16, size_t size)
{
if (utf16 == nil) {
fUtf8Buffer = plStringBuffer<char>();
fUtf8Buffer = plStringBuffer<char>();
if (utf16 == nil)
return;
}
if ((int32_t)size < 0)
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
char *utf8 = new char[convlen + 1];
char *utf8 = fUtf8Buffer.CreateWritableBuffer(convlen);
char *dp = utf8;
sp = utf16;
while (sp < utf16 + size) {
@ -174,8 +196,6 @@ void plString::IConvertFromUtf16(const uint16_t *utf16, size_t size)
++sp;
}
utf8[convlen] = 0;
fUtf8Buffer = plStringBuffer<char>::Steal(utf8, convlen);
}
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
IConvertFromUtf16((const uint16_t *)wstr, size);
#else
if (wstr == nil) {
fUtf8Buffer = plStringBuffer<char>();
fUtf8Buffer = plStringBuffer<char>();
if (wstr == nil)
return;
}
if ((int32_t)size < 0)
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
char *utf8 = new char[convlen + 1];
char *utf8 = fUtf8Buffer.CreateWritableBuffer(convlen);
char *dp = utf8;
sp = wstr;
while (sp < wstr + size) {
@ -239,17 +258,14 @@ void plString::IConvertFromWchar(const wchar_t *wstr, size_t size)
++sp;
}
utf8[convlen] = 0;
fUtf8Buffer = plStringBuffer<char>::Steal(utf8, convlen);
#endif
}
void plString::IConvertFromIso8859_1(const char *astr, size_t size)
{
if (astr == nil) {
fUtf8Buffer = plStringBuffer<char>();
fUtf8Buffer = plStringBuffer<char>();
if (astr == nil)
return;
}
if ((int32_t)size < 0)
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
char *utf8 = new char[convlen + 1];
char *utf8 = fUtf8Buffer.CreateWritableBuffer(convlen);
char *dp = utf8;
sp = astr;
while (sp < astr + size) {
@ -278,14 +294,13 @@ void plString::IConvertFromIso8859_1(const char *astr, size_t size)
++sp;
}
utf8[convlen] = 0;
fUtf8Buffer = plStringBuffer<char>::Steal(utf8, convlen);
}
plStringBuffer<uint16_t> plString::ToUtf16() const
{
if (IsNull())
return plStringBuffer<uint16_t>();
plStringBuffer<uint16_t> result;
if (IsEmpty())
return result;
// Calculate the UTF-16 size
size_t convlen = 0;
@ -308,7 +323,7 @@ plStringBuffer<uint16_t> plString::ToUtf16() const
}
// And perform the actual conversion
uint16_t *ustr = new uint16_t[convlen + 1];
uint16_t *ustr = result.CreateWritableBuffer(convlen);
uint16_t *dp = ustr;
sp = utf8;
while (sp < utf8 + srcSize) {
@ -336,7 +351,7 @@ plStringBuffer<uint16_t> plString::ToUtf16() const
}
ustr[convlen] = 0;
return plStringBuffer<uint16_t>::Steal(ustr, convlen);
return result;
}
plStringBuffer<wchar_t> plString::ToWchar() const
@ -346,8 +361,9 @@ plStringBuffer<wchar_t> plString::ToWchar() const
plStringBuffer<uint16_t> utf16 = ToUtf16();
return *reinterpret_cast<plStringBuffer<wchar_t>*>(&utf16);
#else
if (IsNull())
return plStringBuffer<wchar_t>();
plStringBuffer<uint16_t> result;
if (IsEmpty())
return result;
// Calculate the UCS-4 size
size_t convlen = 0;
@ -367,7 +383,7 @@ plStringBuffer<wchar_t> plString::ToWchar() const
}
// And perform the actual conversion
wchar_t *wstr = new wchar_t[convlen + 1];
wchar_t *wstr = result.CreateWritableBuffer(convlen);
wchar_t *dp = wstr;
sp = utf8;
while (sp < utf8 + srcSize) {
@ -391,14 +407,15 @@ plStringBuffer<wchar_t> plString::ToWchar() const
}
wstr[convlen] = 0;
return plStringBuffer<wchar_t>::Steal(wstr, convlen);
return result;
#endif
}
plStringBuffer<char> plString::ToIso8859_1() const
{
if (IsNull())
return plStringBuffer<char>();
plStringBuffer<char> result;
if (IsEmpty())
return result;
// Calculate the ASCII size
size_t convlen = 0;
@ -418,7 +435,7 @@ plStringBuffer<char> plString::ToIso8859_1() const
}
// And perform the actual conversion
char *astr = new char[convlen + 1];
char *astr = result.CreateWritableBuffer(convlen);
char *dp = astr;
sp = utf8;
while (sp < utf8 + srcSize) {
@ -442,45 +459,45 @@ plStringBuffer<char> plString::ToIso8859_1() const
}
astr[convlen] = 0;
return plStringBuffer<char>::Steal(astr, convlen);
return result;
}
plStringBuffer<UniChar> plString::GetUnicodeArray() const
{
static UniChar empty[1] = {0};
if (IsNull())
return plStringBuffer<UniChar>(empty, 0);
plStringBuffer<UniChar> result;
if (IsEmpty())
return result;
size_t convlen = GetUniCharCount();
UniChar *ustr = new UniChar[convlen + 1];
UniChar *ustr = result.CreateWritableBuffer(convlen);
iterator iter = GetIterator();
size_t dp = 0;
while (!iter.AtEnd())
ustr[dp++] = *iter++;
ustr[convlen] = 0;
return plStringBuffer<UniChar>::Steal(ustr, convlen);
return result;
}
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
{
return static_cast<unsigned int>(strtoul(s_str(), nil, base));
return static_cast<unsigned int>(strtoul(c_str(), nil, base));
}
float plString::ToFloat() const
{
// strtof is C99, which MS doesn't support...
return (float)strtod(s_str(), nil);
return (float)strtod(c_str(), nil);
}
double plString::ToDouble() const
{
return strtod(s_str(), nil);
return strtod(c_str(), nil);
}
// Microsoft doesn't provide this for us
@ -501,22 +518,21 @@ plString plString::IFormat(const char *fmt, va_list vptr)
int size = 4096;
for ( ;; ) {
va_copy(vptr, vptr_save);
char *bigbuffer = new char[size];
chars = vsnprintf(bigbuffer, size, fmt, vptr);
std::auto_ptr<char> bigbuffer(new char[size]);
chars = vsnprintf(bigbuffer.get(), size, fmt, vptr);
if (chars >= 0)
return plString::Steal(bigbuffer);
return plString::FromUtf8(bigbuffer.get(), chars);
delete [] bigbuffer;
size *= 2;
}
} else if (chars >= 256) {
va_copy(vptr, vptr_save);
char *bigbuffer = new char[chars+1];
vsnprintf(bigbuffer, chars+1, fmt, vptr);
return plString::Steal(bigbuffer);
std::auto_ptr<char> bigbuffer(new char[chars+1]);
vsnprintf(bigbuffer.get(), chars+1, fmt, vptr);
return plString::FromUtf8(bigbuffer.get(), chars);
}
return plString::FromUtf8(buffer);
return plString::FromUtf8(buffer, chars);
}
plString plString::Format(const char *fmt, ...)
@ -531,11 +547,10 @@ plString plString::Format(const char *fmt, ...)
int plString::Find(char ch, CaseSensitivity sense) const
{
if (sense == kCaseSensitive) {
const char *cp = strchr(s_str(), ch);
const char *cp = strchr(c_str(), ch);
return cp ? (cp - c_str()) : -1;
} else {
// No need to check for null, since s_str() will return { 0 } if it is null
const char *cp = s_str();
const char *cp = c_str();
while (*cp) {
if (tolower(*cp) == tolower(ch))
return cp - c_str();
@ -550,7 +565,7 @@ int plString::FindLast(char ch, CaseSensitivity sense) const
return -1;
if (sense == kCaseSensitive) {
const char *cp = strrchr(s_str(), ch);
const char *cp = strrchr(c_str(), ch);
return cp ? (cp - c_str()) : -1;
} else {
const char *cp = c_str();
@ -570,7 +585,7 @@ int plString::Find(const char *str, CaseSensitivity sense) const
return -1;
if (sense == kCaseSensitive) {
const char *cp = strstr(s_str(), str);
const char *cp = strstr(c_str(), str);
return cp ? (cp - c_str()) : -1;
} else {
// The easy way
@ -651,69 +666,49 @@ plString plString::Substr(int start, size_t size) const
if (start == 0 && size == maxSize)
return *this;
char *substr = new char[size + 1];
plString sub;
char *substr = sub.fUtf8Buffer.CreateWritableBuffer(size);
memcpy(substr, c_str() + start, size);
substr[size] = 0;
// Don't re-check UTF-8 on this
plString str;
str.fUtf8Buffer = plStringBuffer<char>::Steal(substr, size);
return str;
return sub;
}
plString plString::ToUpper() const
{
// TODO: Unicode-aware case conversion
size_t size = GetSize();
char *dupe = new char[size + 1];
plString str;
char *dupe = str.fUtf8Buffer.CreateWritableBuffer(fUtf8Buffer.GetSize());
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[fUtf8Buffer.GetSize()] = 0;
// Don't re-check UTF-8 on this
plString str;
str.fUtf8Buffer = plStringBuffer<char>::Steal(dupe, size);
return str;
}
plString plString::ToLower() const
{
// TODO: Unicode-aware case conversion
size_t size = GetSize();
char *dupe = new char[size + 1];
plString str;
char *dupe = str.fUtf8Buffer.CreateWritableBuffer(fUtf8Buffer.GetSize());
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[fUtf8Buffer.GetSize()] = 0;
// Don't re-check UTF-8 on this
plString str;
str.fUtf8Buffer = plStringBuffer<char>::Steal(dupe, size);
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)
{
size_t catsize = left.GetSize() + right.GetSize();
char *catstr = new char[catsize + 1];
memcpy(catstr, left.s_str(), left.GetSize());
memcpy(catstr + left.GetSize(), right.s_str(), right.GetSize());
catstr[catsize] = 0;
plString cat;
char *catstr = cat.fUtf8Buffer.CreateWritableBuffer(left.GetSize() + right.GetSize());
memcpy(catstr, left.c_str(), left.GetSize());
memcpy(catstr + left.GetSize(), right.c_str(), right.GetSize());
catstr[cat.fUtf8Buffer.GetSize()] = 0;
// Don't re-check UTF-8 on this
plString str;
str.fUtf8Buffer = plStringBuffer<char>::Steal(catstr, catsize);
return str;
return cat;
}
plStringStream &plStringStream::append(const char *data, size_t length)

169
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
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
or by snail mail at:
Cyan Worlds, Inc.
@ -29,21 +45,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.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;
#define SSO_CHARS (16)
template <typename _Ch>
class plStringBuffer
{
@ -52,10 +58,9 @@ private:
{
unsigned int fRefs;
const _Ch *fStringData;
const size_t fSize;
StringRef(const _Ch *data, const size_t size)
: fRefs(1), fStringData(data), fSize(size) { }
StringRef(const _Ch *data)
: fRefs(1), fStringData(data) { }
inline void AddRef() { ++fRefs; }
inline void DecRef()
@ -67,52 +72,74 @@ private:
}
};
StringRef *fData;
union {
StringRef *fData;
_Ch fShort[SSO_CHARS];
};
size_t fSize;
bool IHaveACow() const { return fSize >= SSO_CHARS; }
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;
if (fData)
memcpy(fShort, copy.fShort, sizeof(fShort));
if (IHaveACow())
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);
copyData[size] = 0;
fData = new StringRef(copyData, size);
if (IHaveACow())
fData = new StringRef(copyData);
}
~plStringBuffer<_Ch>()
{
if (fData)
if (IHaveACow())
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)
{
if (copy.fData)
if (copy.IHaveACow())
copy.fData->AddRef();
if (fData)
if (IHaveACow())
fData->DecRef();
fData = copy.fData;
memcpy(fShort, copy.fShort, sizeof(fShort));
fSize = copy.fSize;
return *this;
}
const _Ch *GetData() const { return fData ? fData->fStringData : 0; }
size_t GetSize() const { return fData ? fData->fSize : 0; }
const _Ch *GetData() const { return IHaveACow() ? fData->fStringData : fShort; }
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:
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 IConvertFromWchar(const wchar_t *wstr, size_t size);
void IConvertFromIso8859_1(const char *astr, size_t size);
@ -136,20 +163,24 @@ private:
public:
plString() { }
//plString(const char *utf8) { IConvertFromUtf8(utf8, kSizeAuto, false); }
//plString(const wchar_t *wstr) { IConvertFromWchar(wstr, kSizeAuto); }
#ifndef PLSTRING_POLLUTE_ASCII_CAST
plString(const char *cstr) { IConvertFromUtf8(cstr, kSizeAuto); }
#endif
plString(const plString &copy) : fUtf8Buffer(copy.fUtf8Buffer) { }
plString(const plStringBuffer<char> &init) { operator=(init); }
//plString &operator=(const char *utf8) { IConvertFromUtf8(utf8, kSizeAuto, false); return *this; }
//plString &operator=(const wchar_t *wstr) { IConvertFromWchar(wstr, kSizeAuto); return *this; }
#ifndef PLSTRING_POLLUTE_ASCII_CAST
plString &operator=(const char *cstr) { IConvertFromUtf8(cstr, kSizeAuto); return *this; }
#endif
plString &operator=(const plString &copy) { fUtf8Buffer = copy.fUtf8Buffer; return *this; }
plString &operator=(const plStringBuffer<char> &init);
plString &operator+=(const plString &str);
plString &operator+=(const plString &str) { return operator=(*this + str); }
static inline plString FromUtf8(const char *utf8, size_t size = kSizeAuto)
{
plString str;
str.IConvertFromUtf8(utf8, size, false);
str.IConvertFromUtf8(utf8, size);
return str;
}
@ -174,8 +205,11 @@ public:
return str;
}
const char *c_str() const { return fUtf8Buffer.GetData(); }
const char *s_str(const char *safe = "") const { return c_str() ? c_str() : safe; }
#ifndef PLSTRING_POLLUTE_C_STR
const char *c_str(const char *substitute = "") const
{ return IsEmpty() ? substitute : fUtf8Buffer.GetData(); }
#endif
char CharAt(size_t position) const { return c_str()[position]; }
plStringBuffer<char> ToUtf8() const { return fUtf8Buffer; }
@ -188,7 +222,10 @@ public:
size_t GetSize() const { return fUtf8Buffer.GetSize(); }
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;
unsigned int ToUInt(int base = 0) const;
@ -197,12 +234,6 @@ public:
static plString Format(const char *fmt, ...);
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 {
kCaseSensitive, kCaseInsensitive
@ -210,32 +241,26 @@ public:
int Compare(const plString &str, CaseSensitivity sense = kCaseSensitive) const
{
if (c_str() == str.c_str())
return 0;
return (sense == kCaseSensitive) ? strcmp(s_str(), str.s_str())
: stricmp(s_str(), str.s_str());
return (sense == kCaseSensitive) ? strcmp(c_str(), str.c_str())
: stricmp(c_str(), str.c_str());
}
int Compare(const char *str, CaseSensitivity sense = kCaseSensitive) const
{
return (sense == kCaseSensitive) ? strcmp(s_str(), str)
: stricmp(s_str(), str);
return (sense == kCaseSensitive) ? strcmp(c_str(), str)
: stricmp(c_str(), str);
}
int CompareN(const plString &str, size_t count, CaseSensitivity sense = kCaseSensitive) const
{
if (c_str() == str.c_str())
return 0;
return (sense == kCaseSensitive) ? strncmp(s_str(), str.s_str(), count)
: strnicmp(s_str(), str.s_str(), count);
return (sense == kCaseSensitive) ? strncmp(c_str(), str.c_str(), count)
: strnicmp(c_str(), str.c_str(), count);
}
int CompareN(const char *str, size_t count, CaseSensitivity sense = kCaseSensitive) const
{
return (sense == kCaseSensitive) ? strncmp(s_str(), str, count)
: strnicmp(s_str(), str, count);
return (sense == kCaseSensitive) ? strncmp(c_str(), str, count)
: strnicmp(c_str(), str, count);
}
bool operator<(const plString &other) const { return Compare(other) < 0; }
@ -263,25 +288,25 @@ public:
plString ToLower() const;
public:
struct less : public std::binary_function<plString, plString, bool>
struct less
{
bool operator()(const plString &_L, const plString &_R) const
{ 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
{ 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
{ 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
{ return _L.Compare(_R, kCaseInsensitive) == 0; }
@ -376,7 +401,7 @@ public:
const char *m_end;
};
iterator GetIterator() const { return iterator(s_str(), GetSize()); }
iterator GetIterator() const { return iterator(c_str(), GetSize()); }
size_t GetUniCharCount() const
{
@ -414,7 +439,7 @@ public:
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; }

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(),
layerAnim->GetTimeConvert().CurrentAnimTime(),
layerAnim->GetTimeConvert().WorldToAnimTimeNoUpdate(hsTimer::GetSysSeconds()));
txt.DrawString(x, y, _TEMP_CONVERT_TO_CONST_CHAR(str));
txt.DrawString(x, y, str.c_str());
y += yOff;
}
layer = layer->GetOverLay();
@ -149,7 +149,7 @@ void plAnimDebugList::ShowReport()
continue;
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;
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(),
anim->GetTimeConvert()->CurrentAnimTime(),
anim->GetTimeConvert()->WorldToAnimTimeNoUpdate(hsTimer::GetSysSeconds()));
txt.DrawString(x, y, _TEMP_CONVERT_TO_CONST_CHAR(str));
txt.DrawString(x, y, str.c_str());
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==*/
#include <stdlib.h>
#include <cmath>
#include "HeadSpin.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 "hsMatrix44.h"
#include "hsBitVector.h"
#include <vector>
class plPipeline;
class plCameraModifier1;

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

@ -77,7 +77,7 @@ void pfMarkerInfo::Init()
plLocation markerLoc = plKeyFinder::Instance().FindLocation("GlobalMarkers", "Markers");
if (markerLoc.IsValid())
fMarkerUoid = plUoid(markerLoc, plSceneObject::Index(), _TEMP_CONVERT_FROM_LITERAL("MarkerRoot"));
fMarkerUoid = plUoid(markerLoc, plSceneObject::Index(), "MarkerRoot");
else
fMarkerUoid.Invalidate();
}
@ -101,7 +101,7 @@ void pfMarkerInfo::Spawn(MarkerType type)
plLocation markerLoc = plKeyFinder::Instance().FindLocation("GlobalMarkers", "Markers");
if (markerLoc.IsValid())
fMarkerUoid = plUoid(markerLoc, plSceneObject::Index(), _TEMP_CONVERT_FROM_LITERAL("MarkerRoot"));
fMarkerUoid = plUoid(markerLoc, plSceneObject::Index(), "MarkerRoot");
else
{
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);
if(spawn)
{
plString soName = _TEMP_CONVERT_FROM_LITERAL("(none)");
plString soName = "(none)";
if (spawn->GetNumTargets() > 0)
{

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

@ -334,7 +334,7 @@ bool pfConsole::MsgReceive( plMessage *msg )
case kSrv2Cli_GameMgr_InviteReceived: {
const Srv2Cli_GameMgr_InviteReceived & gmMsg = *(const Srv2Cli_GameMgr_InviteReceived *)gameMgrMsg->netMsg;
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;
@ -343,7 +343,7 @@ bool pfConsole::MsgReceive( plMessage *msg )
case kSrv2Cli_GameMgr_InviteRevoked: {
const Srv2Cli_GameMgr_InviteRevoked & gmMsg = *(const Srv2Cli_GameMgr_InviteRevoked *)gameMgrMsg->netMsg;
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;

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"
//end for agedefn test
#include "plFile/hsFiles.h"
#include "hsFiles.h"
#include "pnSceneObject/plAudioInterface.h"
#include "plStatusLog/plStatusLog.h"
@ -6980,7 +6980,7 @@ PF_CONSOLE_CMD( Python,
args = plString::Format("(%s,)", tmp);
}
else
args = _TEMP_CONVERT_FROM_LITERAL("()");
args = "()";
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"
//end for agedefn test
#include "plFile/hsFiles.h"
#include "hsFiles.h"
#include "plStatusLog/plStatusLog.h"
@ -231,12 +231,12 @@ PF_CONSOLE_CMD( Net, // groupName
{
// send chat text
plString text=plNetClientMgr::GetInstance()->GetPlayerName();
text += _TEMP_CONVERT_FROM_LITERAL(":");
text += ":";
int i;
for(i=0;i<numParams;i++)
{
text += plString::FromUtf8( (char*)params[i] );
text += _TEMP_CONVERT_FROM_LITERAL(" ");
text += " ";
}
plConsoleMsg *cMsg = new plConsoleMsg( plConsoleMsg::kAddLine, text.c_str() );
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 "plCrash_Private.h"
#include "plFile/plFileUtils.h"
#include "plFileUtils.h"
#include "pnProduct/pnProduct.h"
#ifdef HS_BUILD_FOR_WIN32

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

@ -498,7 +498,7 @@ static bool showBounds = false;
if( showBounds )
{
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

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

@ -388,7 +388,7 @@ bool pfGUIEditBoxMod::HandleKeyEvent( pfGameGUIMgr::EventType event, plKeyDef
{
if (key == KEY_C)
{
plClipboard::GetInstance().SetClipboardText(_TEMP_CONVERT_FROM_WCHAR_T(fBuffer));
plClipboard::GetInstance().SetClipboardText(plString::FromWchar(fBuffer));
}
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...
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)
{

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

@ -121,8 +121,8 @@ void pfGUITextBoxMod::IUpdate( void )
fDynTextMap->ClearToColor( GetColorScheme()->fBackColor );
std::wstring drawStr;
if (fUseLocalizationPath && !fLocalizationPath.empty() && pfLocalizationMgr::InstanceValid())
drawStr = pfLocalizationMgr::Instance().GetString(fLocalizationPath.c_str());
if (fUseLocalizationPath && !fLocalizationPath.IsEmpty() && pfLocalizationMgr::InstanceValid())
drawStr = pfLocalizationMgr::Instance().GetString(fLocalizationPath.ToWchar().GetData());
else
{
if( fText != nil )
@ -170,9 +170,7 @@ void pfGUITextBoxMod::Read( hsStream *s, hsResMgr *mgr )
fUseLocalizationPath = s->ReadBool();
if (fUseLocalizationPath)
{
wchar_t* temp = s->ReadSafeWString();
fLocalizationPath = temp;
delete [] temp;
fLocalizationPath = s->ReadSafeWString_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
// and the path isn't empty
bool useLoc = fUseLocalizationPath && !fLocalizationPath.empty();
bool useLoc = fUseLocalizationPath && !fLocalizationPath.IsEmpty();
s->WriteBool(useLoc);
if (useLoc)
s->WriteSafeWString(fLocalizationPath.c_str());
s->WriteSafeWString(fLocalizationPath);
}
//// HandleMouseDown/Up //////////////////////////////////////////////////////
@ -240,22 +238,12 @@ void pfGUITextBoxMod::SetText( const wchar_t *text )
IUpdate();
}
void pfGUITextBoxMod::SetLocalizationPath(const wchar_t* path)
void pfGUITextBoxMod::SetLocalizationPath(const plString& path)
{
if (path)
if (!path.IsNull())
fLocalizationPath = path;
}
void pfGUITextBoxMod::SetLocalizationPath(const char* path)
{
if (path)
{
wchar_t* wPath = hsStringToWString(path);
fLocalizationPath = wPath;
delete [] wPath;
}
}
void pfGUITextBoxMod::SetUseLocalizationPath(bool use)
{
fUseLocalizationPath = use;

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

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

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

@ -143,7 +143,7 @@ static void OnScoreCreate(
int32_t value
) {
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);
msg->Send(p->fReceiver);
delete p;
@ -165,7 +165,7 @@ static void OnScoreFound(
for (uint32_t i = 0; i < scoreCount; ++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;

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

@ -472,7 +472,7 @@ pfBookData::pfBookData(const plString &guiName /* = nil */)
if (!guiName.IsEmpty())
fGUIName = guiName;
else
fGUIName = _TEMP_CONVERT_FROM_LITERAL("BkBook");
fGUIName = "BkBook";
}
pfBookData::~pfBookData()
@ -1140,9 +1140,9 @@ std::map<plString,pfBookData*> pfJournalBook::fBookGUIs;
void pfJournalBook::SingletonInit( void )
{
fBookGUIs[_TEMP_CONVERT_FROM_LITERAL("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());
fBookGUIs[_TEMP_CONVERT_FROM_LITERAL("BkBook")]->LoadGUI();
fBookGUIs["BkBook"] = new pfBookData(); // load the default book data object
hsgResMgr::ResMgr()->NewKey("BkBook",fBookGUIs["BkBook"],pfGameGUIMgr::GetInstance()->GetKey()->GetUoid().GetLocation());
fBookGUIs["BkBook"]->LoadGUI();
}
void pfJournalBook::SingletonShutdown( void )
@ -1207,7 +1207,7 @@ pfJournalBook::pfJournalBook( const char *esHTMLSource, plKey coverImageKey, plK
if (!guiName.IsEmpty())
fCurBookGUI = guiName;
else
fCurBookGUI = _TEMP_CONVERT_FROM_LITERAL("BkBook");
fCurBookGUI = "BkBook";
if (fBookGUIs.find(fCurBookGUI) == fBookGUIs.end())
{
fBookGUIs[fCurBookGUI] = new pfBookData(fCurBookGUI);
@ -1243,7 +1243,7 @@ pfJournalBook::pfJournalBook( const wchar_t *esHTMLSource, plKey coverImageKey,
if (!guiName.IsEmpty())
fCurBookGUI = guiName;
else
fCurBookGUI = _TEMP_CONVERT_FROM_LITERAL("BkBook");
fCurBookGUI = "BkBook";
if (fBookGUIs.find(fCurBookGUI) == fBookGUIs.end())
{
fBookGUIs[fCurBookGUI] = new pfBookData(fCurBookGUI);
@ -1292,7 +1292,7 @@ void pfJournalBook::SetGUI( const plString &guiName )
if (!guiName.IsEmpty())
fCurBookGUI = guiName;
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
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
plMipmap *mip;
if( cName.Find( ".png" ) >= 0 )
mip = plPNG::Instance().ReadFromFile( _TEMP_CONVERT_TO_CONST_CHAR( cName ) );
mip = plPNG::Instance().ReadFromFile( cName.c_str() );
else
mip = plJPEG::Instance().ReadFromFile( _TEMP_CONVERT_TO_CONST_CHAR( cName ) );
mip = plJPEG::Instance().ReadFromFile( cName.c_str() );
hsgResMgr::ResMgr()->NewKey( cName, mip, loc );
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 "plFile/hsFiles.h"
#include "hsFiles.h"
#include "plFile/plEncryptedStream.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";
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;
}

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

@ -67,7 +67,7 @@ class pfKIMsg : public plMessage
// for the hack chat message thingy
char *fUser;
uint32_t fPlayerID;
std::wstring fString;
plString fString;
// for the SetChatFadeDelay
float fDelay;
@ -78,7 +78,7 @@ class pfKIMsg : public plMessage
void IInit()
{
fCommand = kNoCommand;
fString = L"";
fString = "";
fUser = nil;
fPlayerID = 0;
fFlags = 0;
@ -192,14 +192,7 @@ class pfKIMsg : public plMessage
s->ReadLE( &fCommand );
fUser = s->ReadSafeString();
fPlayerID = s->ReadLE32();
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;
fString = s->ReadSafeWString_TEMP();
fFlags = s->ReadLE32();
fDelay = s->ReadLEScalar();
fValue = s->ReadLE32();
@ -211,31 +204,29 @@ class pfKIMsg : public plMessage
s->WriteLE( fCommand );
s->WriteSafeString( fUser );
s->WriteLE32( fPlayerID );
s->WriteSafeWString( fString.c_str() );
s->WriteSafeWString( fString );
s->WriteLE32( fFlags );
s->WriteLEScalar(fDelay);
s->WriteLE32( fValue );
}
uint8_t GetCommand( void ) const { return fCommand; }
uint8_t GetCommand( void ) const { return fCommand; }
void SetString( const char *str );
void SetString( const wchar_t *str ) { fString = str; }
std::string GetString( void );
std::wstring GetStringU( void ) { return fString; }
void SetString( const plString &str ) { fString = str; }
plString GetString( void ) { return fString; }
void SetUser( const char *str, uint32_t pid=0 ) { fUser = hsStrcpy( str ); fPlayerID = pid; }
const char *GetUser( void ) { return fUser; }
uint32_t GetPlayerID( void ) { return fPlayerID; }
uint32_t GetPlayerID( void ) { return fPlayerID; }
void SetFlags( uint32_t flags ) { fFlags = flags; }
uint32_t GetFlags( void ) const { return fFlags; }
uint32_t GetFlags( void ) const { return fFlags; }
void SetDelay( float delay ) { fDelay = delay; }
float GetDelay( void ) { return fDelay; }
float GetDelay( void ) { return fDelay; }
void SetIntValue( int32_t value ) { fValue = value; }
int32_t GetIntValue( void ) { return fValue; }
int32_t GetIntValue( void ) { return fValue; }
#endif // def KI_CONSTANTS_ONLY
};

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
pfKIMsg *msg = new pfKIMsg( pfKIMsg::kHACKChatMsg );
msg->SetString( message );
msg->SetString( plString::FromWchar(message) );
msg->SetUser( from.GetPlayerName(), from.GetPlayerID() );
msg->SetFlags( flags );
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
pfKIMsg *msg = new pfKIMsg( (uint8_t)command );
msg->SetString( value );
msg->SetString( plString::FromWchar( value ) );
// send it off
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;
}
pyKey* key = pyKey::ConvertFrom(keyObj);
return PyString_FromString(cyMisc::GetClientName(*key).s_str());
return PyString_FromString(cyMisc::GetClientName(*key).c_str());
}
else
return PyString_FromString(cyMisc::GetLocalClientName().c_str());

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

@ -1862,7 +1862,7 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
// yes...
// find the value that would go with a command
PyObject* value;
std::wstring str;
plStringBuffer<wchar_t> str;
switch (pkimsg->GetCommand())
{
case pfKIMsg::kSetChatFadeDelay:
@ -1873,8 +1873,8 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
break;
case pfKIMsg::kYesNoDialog:
value = PyTuple_New(2);
str = pkimsg->GetStringU();
PyTuple_SetItem(value, 0, PyUnicode_FromWideChar(str.c_str(), str.length()));
str = pkimsg->GetString().ToWchar();
PyTuple_SetItem(value, 0, PyUnicode_FromWideChar(str, str.GetSize()));
PyTuple_SetItem(value, 1, pyKey::New(pkimsg->GetSender()));
break;
case pfKIMsg::kGZInRange:
@ -1884,23 +1884,23 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
break;
case pfKIMsg::kRateIt:
value = PyTuple_New(3);
str = pkimsg->GetStringU();
str = pkimsg->GetString().ToWchar();
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()));
break;
case pfKIMsg::kRegisterImager:
value = PyTuple_New(2);
str = pkimsg->GetStringU();
PyTuple_SetItem(value, 0, PyUnicode_FromWideChar(str.c_str(), str.length()));
str = pkimsg->GetString().ToWchar();
PyTuple_SetItem(value, 0, PyUnicode_FromWideChar(str, str.GetSize()));
PyTuple_SetItem(value, 1, pyKey::New(pkimsg->GetSender()));
break;
case pfKIMsg::kAddPlayerDevice:
case pfKIMsg::kRemovePlayerDevice:
{
str = pkimsg->GetStringU();
if ( str.length() > 0 )
value = PyUnicode_FromWideChar(str.c_str(), str.length());
str = pkimsg->GetString().ToWchar();
if ( str.GetSize() > 0 )
value = PyUnicode_FromWideChar(str, str.GetSize());
else
{
Py_INCREF(Py_None);
@ -1915,8 +1915,8 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
case pfKIMsg::kKIOKDialogNoQuit:
case pfKIMsg::kGZFlashUpdate:
case pfKIMsg::kKICreateMarkerNode:
str = pkimsg->GetStringU();
value = PyUnicode_FromWideChar(str.c_str(), str.length());
str = pkimsg->GetString().ToWchar();
value = PyUnicode_FromWideChar(str, str.GetSize());
break;
case pfKIMsg::kMGStartCGZGame:
case pfKIMsg::kMGStopCGZGame:
@ -2905,7 +2905,7 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
void plPythonFileMod::ReportError()
{
plString objectName = this->GetKeyName();
objectName += _TEMP_CONVERT_FROM_LITERAL(" - ");
objectName += " - ";
PythonInterface::WriteToStdErr(objectName.c_str());
@ -3050,4 +3050,4 @@ void plPythonFileMod::Write(hsStream* stream, hsResMgr* mgr)
//// kGlobalNameKonstant /////////////////////////////////////////////////
// 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 "plFile/hsFiles.h"
#include "hsFiles.h"
#include "plFile/plSecureStream.h"
#include "plFile/plStreamSource.h"

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

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

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

@ -607,7 +607,7 @@ const plPythonSDLModifier* plPythonSDLModifier::FindAgeSDL()
return sdlMod;
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
{
@ -616,11 +616,11 @@ const plPythonSDLModifier* plPythonSDLModifier::FindAgeSDL()
else
if (!key->ObjectIsLoaded())
plNetClientApp::StaticErrorMsg("key %s not loaded for age sdl %s",
key->GetName().s_str("?"), ageName);
key->GetName().c_str("?"), ageName);
else
if (!plPythonFileMod::ConvertNoRef(key->ObjectIsLoaded()))
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

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

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

@ -61,8 +61,8 @@ PyObject* pyGameScoreMsg::CreateFinal(pfGameScoreMsg* msg)
plString pyGameScoreMsg::GetError() const
{
if (fMsg)
return _TEMP_CONVERT_FROM_WCHAR_T(NetErrorToString(fMsg->GetResult()));
return _TEMP_CONVERT_FROM_LITERAL("pfGameScoreMsg is NULL");
return plString::FromWchar(NetErrorToString(fMsg->GetResult()));
return "pfGameScoreMsg is NULL";
}
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))
{
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;
}
else
@ -313,7 +313,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtLoadPNGFromDisk, args, "Params: filename,width
if (PyString_CheckEx(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;
}
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 <string>
#include <vector>
class cyAnimation;
class pyImage;
@ -84,8 +84,8 @@ public:
// required functions for PyObject interoperability
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::wstring 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 = "");
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)
@ -94,8 +94,8 @@ public:
static void AddPlasmaConstantsClasses(PyObject *m);
// 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::wstring 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 = "");
// Interface functions per book
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 "pnKeyedObject/plKey.h"
#include <string>
class pyPlayer
{

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

@ -103,7 +103,7 @@ PYTHON_INIT_DEFINITION(ptPlayer, args, keywords)
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;
}

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

@ -223,7 +223,7 @@ plString pySceneObject::GetName()
{
if ( fSceneObjects.Count() > 0 )
return fSceneObjects[0]->GetName();
return _TEMP_CONVERT_FROM_LITERAL("");
return "";
}
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 "pnKeyedObject/plKey.h"
#include "hsTemplates.h"
#include <vector>
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
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)
{
fLog->SetForceLog(true);
@ -85,7 +85,7 @@ bool pyStatusLog::Write(plString text)
{
if (fLog)
{
fLog->AddLine(_TEMP_CONVERT_TO_CONST_CHAR(text));
fLog->AddLine(text.c_str());
return true;
}
@ -100,7 +100,7 @@ bool pyStatusLog::WriteColor(plString text, pyColor& color)
((uint32_t)(color.getRed()*255)<<16) +
((uint32_t)(color.getGreen()*255)<<8) +
((uint32_t)(color.getBlue()*255));
fLog->AddLine( _TEMP_CONVERT_TO_CONST_CHAR(text), st_color );
fLog->AddLine( text.c_str(), st_color );
return true;
}

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

@ -673,8 +673,8 @@ void pyVault::CreateNeighborhood()
plUUID guid(GuidGenerate());
link.GetAgeInfo()->SetAgeInstanceGuid(&guid);
link.GetAgeInfo()->SetAgeUserDefinedName( _TEMP_CONVERT_TO_CONST_CHAR(title) );
link.GetAgeInfo()->SetAgeDescription( _TEMP_CONVERT_TO_CONST_CHAR(desc) );
link.GetAgeInfo()->SetAgeUserDefinedName( title.c_str() );
link.GetAgeInfo()->SetAgeDescription( desc.c_str() );
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 "plCompression/plZlibStream.h"
#include "pnEncryption/plChecksum.h"
#include "plFile/plFileUtils.h"
#include "plFileUtils.h"
#include "plFile/plSecureStream.h"
#include "plFile/plStreamSource.h"
#include "plMessage/plNetCommMsgs.h"

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

@ -341,7 +341,7 @@ void plDispatch::IMsgDispatch()
uint32_t rcvTicks = hsTimer::GetPrecTickCount();
// 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)";
uint32_t clonePlayerID = 0;
if (plDispatchLogBase::IsLoggingLong())

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

@ -70,7 +70,7 @@ plString hsKeyedObject::GetKeyName() const
if (fpKey)
return fpKey->GetName();
else
return _TEMP_CONVERT_FROM_LITERAL("(unknown)");
return "(unknown)";
}
hsKeyedObject::~hsKeyedObject()
@ -145,7 +145,7 @@ void hsKeyedObject::UnRegisterAsManual(plUoid& inUoid)
#if !HS_BUILD_FOR_UNIX // disable for unix servers
hsAssert(false,
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
}
((plKeyImp*)fpKey)->UnRegister();

73
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
// 3) Make sure the Obj is unique for this location/Type Combo... (validated at runtime)
#define _TCFL _TEMP_CONVERT_FROM_LITERAL
plKeySeed SeedList[] = {
// Key Enum Type Obj
{ kFirst_Fixed_KEY, CLASS_INDEX_SCOPED( plSceneObject ), _TCFL("kFirst_Fixed_KEY") },
{ kLOSObject_KEY, CLASS_INDEX_SCOPED( plLOSDispatch ), _TCFL("kLOSObject_KEY"), },
{ kTimerCallbackManager_KEY, CLASS_INDEX_SCOPED( plTimerCallbackManager ), _TCFL("kTimerCallbackManager_KEY"), },
{ kConsoleObject_KEY, CLASS_INDEX_SCOPED( pfConsole ), _TCFL("kConsoleObject_KEY"), },
{ kAudioSystem_KEY, CLASS_INDEX_SCOPED( plAudioSystem ), _TCFL("kAudioSystem_KEY"), },
{ kInput_KEY, CLASS_INDEX_SCOPED( plInputManager ), _TCFL("kInput_KEY"), },
{ kClient_KEY, CLASS_INDEX_SCOPED( plClient ), _TCFL("kClient_KEY"), },
{ kNetClientMgr_KEY, CLASS_INDEX_SCOPED( plNetClientMgr ), _TCFL("kNetClientMgr_KEY"), },
{ kListenerMod_KEY, CLASS_INDEX_SCOPED( plListener ), _TCFL("kListenerMod_KEY"), },
{ kTransitionMgr_KEY, CLASS_INDEX_SCOPED( plTransitionMgr ), _TCFL("kTransitionMgr_KEY"), },
{ kLinkEffectsMgr_KEY, CLASS_INDEX_SCOPED( plLinkEffectsMgr ), _TCFL("kLinkEffectsMgr_KEY"), },
{ kGameGUIMgr_KEY, CLASS_INDEX_SCOPED( pfGameGUIMgr ), _TCFL("kGameGUIMgr_KEY"), },
{ kGameGUIDynamicDlg_KEY, CLASS_INDEX_SCOPED( plSceneNode ), _TCFL("kGameGUIDynamicDlg_KEY"), },
{ kVirtualCamera1_KEY, CLASS_INDEX_SCOPED( plVirtualCam1 ), _TCFL("kVirtualCamera_KEY"), },
{ kDefaultCameraMod1_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), _TCFL("kDefaultCameraMod1_KEY"), },
{ kKIGUIGlue_KEY, CLASS_INDEX_SCOPED( pfKI ), _TCFL("kKIGUIGlue_KEY"), },
{ kClothingMgr_KEY, CLASS_INDEX_SCOPED( plClothingMgr ), _TCFL("kClothingMgr_KEY"), },
{ kInputInterfaceMgr_KEY, CLASS_INDEX_SCOPED( plInputInterfaceMgr ), _TCFL("kInputInterfaceMgr_KEY"), },
{ kAVIWriter_KEY, CLASS_INDEX_SCOPED( plAVIWriter ), _TCFL("kAVIWriter_KEY"), },
{ kResManagerHelper_KEY, CLASS_INDEX_SCOPED( plResManagerHelper ), _TCFL("kResManagerHelper_KEY"), },
{ kAvatarMgr_KEY, CLASS_INDEX_SCOPED( plAvatarMgr ), _TCFL("kAvatarMgr_KEY"), },
{ kSimulationMgr_KEY, CLASS_INDEX_SCOPED( plSimulationMgr ), _TCFL("kSimulationMgr_KEY"), },
{ kTransitionCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), _TCFL("kTransitionCamera_KEY"), },
{ kCCRMgr_KEY, CLASS_INDEX_SCOPED( plCCRMgr ), _TCFL("kCCRMgr_KEY"), },
{ kNetClientCloneRoom_KEY, CLASS_INDEX_SCOPED( plSceneNode ), _TCFL("kNetClientCloneRoom_KEY"), },
{ kMarkerMgr_KEY, CLASS_INDEX_SCOPED( pfMarkerMgr ), _TCFL("kMarkerMgr_KEY"), },
{ kAutoProfile_KEY, CLASS_INDEX_SCOPED( plAutoProfile ), _TCFL("kAutoProfile_KEY"), },
{ kGlobalVisMgr_KEY, CLASS_INDEX_SCOPED( plVisMgr ), _TCFL("kGlobalVisMgr_KEY"), },
{ kFontCache_KEY, CLASS_INDEX_SCOPED( plFontCache ), _TCFL("kFontCache_KEY"), },
{ kRelevanceMgr_KEY, CLASS_INDEX_SCOPED( plRelevanceMgr ), _TCFL("kRelevanceMgr_KEY"), },
{ kJournalBookMgr_KEY, CLASS_INDEX_SCOPED( pfJournalBook ), _TCFL("kJournalBookMgr_KEY") },
{ kAgeLoader_KEY, CLASS_INDEX_SCOPED( plAgeLoader), _TCFL("kAgeLoader_KEY") },
{ kBuiltIn3rdPersonCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), _TCFL("kBuiltIn3rdPersonCamera_KEY"), },
{ kSecurePreloader_KEY, CLASS_INDEX_SCOPED( pfSecurePreloader ), _TCFL("kSecurePreloader_KEY"), },
{ kFirst_Fixed_KEY, CLASS_INDEX_SCOPED( plSceneObject ), "kFirst_Fixed_KEY", },
{ kLOSObject_KEY, CLASS_INDEX_SCOPED( plLOSDispatch ), "kLOSObject_KEY", },
{ kTimerCallbackManager_KEY, CLASS_INDEX_SCOPED( plTimerCallbackManager ), "kTimerCallbackManager_KEY", },
{ kConsoleObject_KEY, CLASS_INDEX_SCOPED( pfConsole ), "kConsoleObject_KEY", },
{ kAudioSystem_KEY, CLASS_INDEX_SCOPED( plAudioSystem ), "kAudioSystem_KEY", },
{ kInput_KEY, CLASS_INDEX_SCOPED( plInputManager ), "kInput_KEY", },
{ kClient_KEY, CLASS_INDEX_SCOPED( plClient ), "kClient_KEY", },
{ kNetClientMgr_KEY, CLASS_INDEX_SCOPED( plNetClientMgr ), "kNetClientMgr_KEY", },
{ kListenerMod_KEY, CLASS_INDEX_SCOPED( plListener ), "kListenerMod_KEY", },
{ kTransitionMgr_KEY, CLASS_INDEX_SCOPED( plTransitionMgr ), "kTransitionMgr_KEY", },
{ kLinkEffectsMgr_KEY, CLASS_INDEX_SCOPED( plLinkEffectsMgr ), "kLinkEffectsMgr_KEY", },
{ kGameGUIMgr_KEY, CLASS_INDEX_SCOPED( pfGameGUIMgr ), "kGameGUIMgr_KEY", },
{ kGameGUIDynamicDlg_KEY, CLASS_INDEX_SCOPED( plSceneNode ), "kGameGUIDynamicDlg_KEY", },
{ kVirtualCamera1_KEY, CLASS_INDEX_SCOPED( plVirtualCam1 ), "kVirtualCamera_KEY", },
{ kDefaultCameraMod1_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), "kDefaultCameraMod1_KEY", },
{ kKIGUIGlue_KEY, CLASS_INDEX_SCOPED( pfKI ), "kKIGUIGlue_KEY", },
{ kClothingMgr_KEY, CLASS_INDEX_SCOPED( plClothingMgr ), "kClothingMgr_KEY", },
{ kInputInterfaceMgr_KEY, CLASS_INDEX_SCOPED( plInputInterfaceMgr ), "kInputInterfaceMgr_KEY", },
{ kAVIWriter_KEY, CLASS_INDEX_SCOPED( plAVIWriter ), "kAVIWriter_KEY", },
{ kResManagerHelper_KEY, CLASS_INDEX_SCOPED( plResManagerHelper ), "kResManagerHelper_KEY", },
{ kAvatarMgr_KEY, CLASS_INDEX_SCOPED( plAvatarMgr ), "kAvatarMgr_KEY", },
{ kSimulationMgr_KEY, CLASS_INDEX_SCOPED( plSimulationMgr ), "kSimulationMgr_KEY", },
{ kTransitionCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), "kTransitionCamera_KEY", },
{ kCCRMgr_KEY, CLASS_INDEX_SCOPED( plCCRMgr ), "kCCRMgr_KEY", },
{ kNetClientCloneRoom_KEY, CLASS_INDEX_SCOPED( plSceneNode ), "kNetClientCloneRoom_KEY", },
{ kMarkerMgr_KEY, CLASS_INDEX_SCOPED( pfMarkerMgr ), "kMarkerMgr_KEY", },
{ kAutoProfile_KEY, CLASS_INDEX_SCOPED( plAutoProfile ), "kAutoProfile_KEY", },
{ kGlobalVisMgr_KEY, CLASS_INDEX_SCOPED( plVisMgr ), "kGlobalVisMgr_KEY", },
{ kFontCache_KEY, CLASS_INDEX_SCOPED( plFontCache ), "kFontCache_KEY", },
{ kRelevanceMgr_KEY, CLASS_INDEX_SCOPED( plRelevanceMgr ), "kRelevanceMgr_KEY", },
{ kJournalBookMgr_KEY, CLASS_INDEX_SCOPED( pfJournalBook ), "kJournalBookMgr_KEY", },
{ kAgeLoader_KEY, CLASS_INDEX_SCOPED( plAgeLoader), "kAgeLoader_KEY", },
{ kBuiltIn3rdPersonCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), "kBuiltIn3rdPersonCamera_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

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

@ -68,7 +68,7 @@ static uint16_t kClassType = CLASS_INDEX_SCOPED(plSceneNode);
static uint32_t kCloneID = 0;
bool IsTrackedKey(const plKeyImp* key)
{
return (strcmp(key->GetName(), kObjName) == 0) &&
return (key->GetName() == kObjName) &&
key->GetUoid().GetClassType() == kClassType &&
key->GetUoid().GetCloneID() == kCloneID;
}
@ -348,7 +348,7 @@ void plKeyImp::AddNotifyCreated(plRefMsg* msg, plRefFlags::Type flags)
#ifdef LOG_ACTIVE_REFS
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);
}
#endif // LOG_ACTIVE_REFS
@ -635,7 +635,8 @@ void plKeyImp::IRelease(plKeyImp* iTargetKey)
// it has been notified it is going away.
#ifdef LOG_ACTIVE_REFS
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
if (isActive && iTargetKey->GetActiveRefs() && !iTargetKey->DecActiveRefs())

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

@ -142,13 +142,13 @@ bool plMsgForwarder::IForwardCallbackMsg(plMessage *msg)
#if 0
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
}
}
#if 0
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
IForwardMsg(callbackMsg);

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

@ -275,7 +275,7 @@ void plLogicModBase::UnTrigger()
#ifdef HS_DEBUGGING
char str[256];
sprintf(str, "LogicModifier %s is Un-triggering, activatorType=%d\n",
GetKeyName(), HasFlag(kTypeActivator));
GetKeyName().c_str(), HasFlag(kTypeActivator));
plNetClientApp::GetInstance()->DebugMsg(str);
#endif
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 );
char buf[40];
uuid_unparse( g, buf );
out = _TEMP_CONVERT_FROM_LITERAL( buf );
out = buf;
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
{
out = _TEMP_CONVERT_FROM_LITERAL("");
out = "";
unsigned char * ubuf;
RPC_STATUS s;
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 "hsStlUtils.h"
#include "plFile/hsFiles.h"
#include "hsFiles.h"
#include "plFile/plInitFileReader.h"
#include "plFile/plEncryptedStream.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 "plFile/hsFiles.h"
#include "plFile/plFileUtils.h"
#include "hsFiles.h"
#include "plFileUtils.h"
#include "plFile/plInitFileReader.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 "plCompression/plZlibStream.h"
#include "pnEncryption/plChecksum.h"
#include "plFile/plFileUtils.h"
#include "plFileUtils.h"
#include "plMessage/plResPatcherMsg.h"
#include "pnNetBase/pnNbError.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->SetDataRange( 0, 100, 100 );
fDebugPlate->SetColors( 0x80202000 );
fDebugPlate->SetTitle( _TEMP_CONVERT_TO_CONST_CHAR( GetKeyName() ) ); // Bleah
fDebugPlate->SetTitle( GetKeyName().c_str() ); // Bleah
fDebugPlate->SetLabelText( "Desired", "Curr", "Soft", "Dist" );
}
@ -190,7 +190,7 @@ void plSound::SetCurrDebugPlate( const plKey soundKey )
{
fDebugPlate->ClearData();
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 "plgDispatch.h"
#include "plProfile.h"
#include "plFile/hsFiles.h"
#include "hsFiles.h"
#include "plWin32Sound.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 "hsTimer.h"
#include "plFile/hsFiles.h"
#include "plFile/plFileUtils.h"
#include "hsFiles.h"
#include "plFileUtils.h"
#include "plUnifiedTime/plUnifiedTime.h"
#include "plBufferedFileReader.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 "hsResMgr.h"
#include "pnMessage/plRefMsg.h"
#include "plFile/plFileUtils.h"
#include "plFile/hsFiles.h"
#include "plFileUtils.h"
#include "hsFiles.h"
#include "plUnifiedTime/plUnifiedTime.h"
#include "plStatusLog/plStatusLog.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
extern const char *gGlobalAnimName = nil;
extern const char *gGlobalChannelName = nil;
plString gGlobalAnimName;
plString gGlobalChannelName;
#endif // TRACK_AG_ALLOCS
/////////////////////////////////////////////////////////////////////////////////////////
@ -172,7 +172,7 @@ plAGAnimInstance::plAGAnimInstance(plAGAnim * anim, plAGMasterMod * master,
fFadeBlend = fFadeAmp = false;
#ifdef TRACK_AG_ALLOCS
gGlobalAnimName = nil;
gGlobalAnimName = "";
#endif // TRACK_AG_ALLOCS
}

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

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

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

@ -104,10 +104,6 @@ public:
void SetChannelName(const plString &name);
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.
The applicator can still be forced to apply using the force
paramater of the Apply function. */

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

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

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

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

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

@ -277,7 +277,7 @@ plAGAnimInstance * plAnimStage::Attach(plArmatureMod *armature, plArmatureBrain
if(fAnimInstance)
{
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;
// this is too early to send the enter notify. we're attached, but we may not
// have faded in yet.

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

@ -663,7 +663,7 @@ void plArmatureMod::IInitDefaults()
fDontPanicLink = false;
fBodyAgeName = "GlobalAvatars";
fBodyFootstepSoundPage = "Audio";
fAnimationPrefix = _TEMP_CONVERT_FROM_LITERAL("Male");
fAnimationPrefix = "Male";
fUserStr = "";
}
@ -1034,7 +1034,7 @@ void plArmatureMod::PanicLink(bool playLinkOutAnim /* = true */)
plString animName = MakeAnimationName("FallingLinkOut");
task->SetAnimName(animName);
task->SetMarkerName(_TEMP_CONVERT_FROM_LITERAL("touch"));
task->SetMarkerName("touch");
plAvTaskMsg *taskMsg = new plAvTaskMsg(GetKey(), GetKey(), task);
taskMsg->Send();
@ -1057,7 +1057,7 @@ void plArmatureMod::PersonalLink()
plAvOneShotLinkTask *task = new plAvOneShotLinkTask;
plString animName = MakeAnimationName("PersonalLink");
task->SetAnimName(animName);
task->SetMarkerName(_TEMP_CONVERT_FROM_LITERAL("touch"));
task->SetMarkerName("touch");
plAvTaskMsg *taskMsg = new plAvTaskMsg(GetKey(), GetKey(), task);
taskMsg->SetBCastFlag(plMessage::kNetPropagate);
@ -1781,7 +1781,7 @@ void plArmatureMod::Read(hsStream * stream, hsResMgr *mgr)
if (gLoc.IsValid())
{
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);
if (fFootSoundSOKey)
{
@ -1791,7 +1791,7 @@ void plArmatureMod::Read(hsStream * stream, hsResMgr *mgr)
}
// 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);
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);
// Get the linking sound
plUoid LinkUoid(gLoc, plSceneObject::Index(), _TEMP_CONVERT_FROM_LITERAL("LinkSoundSource"));
plUoid LinkUoid(gLoc, plSceneObject::Index(), "LinkSoundSource");
fLinkSoundSOKey = mgr->FindKey(LinkUoid);
if (fLinkSoundSOKey)
{
@ -1896,7 +1896,7 @@ void plArmatureMod::ICustomizeApplicator()
{
plArmatureModBase::ICustomizeApplicator();
const plAGModifier *agMod = GetChannelMod(_TEMP_CONVERT_FROM_LITERAL("Bone_Root"), true);
const plAGModifier *agMod = GetChannelMod("Bone_Root", true);
if (agMod)
{
// 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
{
return fAnimationPrefix + _TEMP_CONVERT_FROM_LITERAL(baseName);
return fAnimationPrefix + baseName;
}
plString plArmatureMod::GetRootName()

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

@ -714,7 +714,7 @@ void plAvBrainClimb::ICalcProbeLengths()
hsAssert(up, "Couldn't find ClimbUp animation.");
if(up)
{
GetStartToEndTransform(up, &upMove, nil, _TEMP_CONVERT_FROM_LITERAL("Handle"));
GetStartToEndTransform(up, &upMove, nil, "Handle");
fVerticalProbeLength = upMove.GetTranslate().fZ;
} else
fVerticalProbeLength = 4.0f; // guess
@ -722,7 +722,7 @@ void plAvBrainClimb::ICalcProbeLengths()
hsAssert(left, "Couldn't find ClimbLeft animation.");
if(left)
{
GetStartToEndTransform(left, &leftMove, nil, _TEMP_CONVERT_FROM_LITERAL("Handle"));
GetStartToEndTransform(left, &leftMove, nil, "Handle");
fHorizontalProbeLength = leftMove.GetTranslate().fX;
} else
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
{
if ((behavior >= fBehaviors.Count()) || (behavior < 0))
return _TEMP_CONVERT_FROM_LITERAL("");
return "";
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++)
{
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);
if( bone )

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

@ -535,7 +535,7 @@ bool plAvTaskSeek::IUpdateObjective(plArmatureMod *avatar)
plAGAnim *anim = avatar->FindCustomAnim(fAnimName);
// don't need to do this every frame; the animation doesn't change.
// *** 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
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);
#endif
plString theName = _TEMP_CONVERT_FROM_LITERAL(name);
plString theName = name;
if ( loc == maleLoc )
theName = _TEMP_CONVERT_FROM_LITERAL("Male");
theName = "Male";
if (loc.IsValid())
{
@ -1012,7 +1012,7 @@ void plAvatarMgr::OfferLinkingBook(plKey hostKey, plKey guestKey, plMessage *lin
brainG->AddStage(guestAccept);
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);

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

@ -249,7 +249,7 @@ bool plAvSeekTask::Start(plArmatureMod *avatar, plArmatureBrain *brain, double t
{
hsMatrix44 adjustment;
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;
}
break;
@ -624,7 +624,7 @@ bool plAvOneShotTask::Start(plArmatureMod *avatar, plArmatureBrain *brain, doubl
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)
{
plMatrixDifferenceApp *differ = avatar->GetRootAnimator();

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

@ -161,7 +161,7 @@ bool plMultistageBehMod::MsgReceive(plMessage* msg)
#ifdef DEBUG_MULTISTAGE
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);
#endif
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
// animation. That's what this next line is doing. It's a bit unintuitive
// 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;
hsPoint3 distP = candidateGoal.GetTranslate() - curPosition;
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;
log.Open("log\\GBuf.log", "ab");
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.Close();
#endif
@ -386,8 +386,8 @@ static void ILogSpan(plStatusLog* statusLog, plGeometrySpan* geo, plVertexSpan*
uint32_t ptr = cell->fVtxStart + span->fCellOffset * stride;
statusLog->AddLineF("From obj <%s> mat <%s> size %d bytes grp=%d (%d offset)",
geo->fMaxOwner.s_str("<unknown>"),
geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "<unknown>",
geo->fMaxOwner.c_str("<unknown>"),
geo->fMaterial ? geo->fMaterial->GetKeyName().c_str() : "<unknown>",
geo->GetVertexSize(geo->fFormat) * geo->fNumVerts + sizeof(uint16_t) * geo->fNumIndices,
span->fGroupIdx,
ptr
@ -404,8 +404,8 @@ static void ILogSpan(plStatusLog* statusLog, plGeometrySpan* geo, plVertexSpan*
else
{
statusLog->AddLineF("Instanced obj <%s> mat <%s> grp=%d (%d/%d/%d/%d/%d/%d/%d/%d)",
geo->fMaxOwner.s_str("<unknown>"),
geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "<unknown>",
geo->fMaxOwner.c_str("<unknown>"),
geo->fMaterial ? geo->fMaterial->GetKeyName().c_str() : "<unknown>",
span->fGroupIdx,
span->fVBufferIdx,
span->fCellIdx,
@ -423,8 +423,8 @@ static void ILogSpan(plStatusLog* statusLog, plGeometrySpan* geo, plVertexSpan*
if( geo->fProps & plGeometrySpan::kFirstInstance )
{
statusLog->AddLineF("From obj <%s> mat <%s> size %d bytes grp=%d (%d/%d/%d/%d/%d)",
geo->fMaxOwner.s_str("<unknown>"),
geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "<unknown>",
geo->fMaxOwner.c_str("<unknown>"),
geo->fMaterial ? geo->fMaterial->GetKeyName().c_str() : "<unknown>",
geo->GetVertexSize(geo->fFormat) * geo->fNumVerts + sizeof(uint16_t) * geo->fNumIndices,
span->fGroupIdx,
span->fVBufferIdx,
@ -437,8 +437,8 @@ static void ILogSpan(plStatusLog* statusLog, plGeometrySpan* geo, plVertexSpan*
else
{
statusLog->AddLineF("Instanced obj <%s> mat <%s> grp=%d (%d/%d/%d/%d/%d)",
geo->fMaxOwner.s_str("<unknown>"),
geo->fMaterial ? geo->fMaterial->GetKey()->GetName().c_str() : "<unknown>",
geo->fMaxOwner.c_str("<unknown>"),
geo->fMaterial ? geo->fMaterial->GetKeyName().c_str() : "<unknown>",
span->fGroupIdx,
span->fVBufferIdx,
span->fCellIdx,

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

@ -114,7 +114,7 @@ void plInstanceDrawInterface::AddSharedMesh(plSharedMesh *mesh, hsGMaterial *mat
#ifdef MF_NOSHADOW_ACC
// TESTHACKERY FOLLOWS - GlassesNoShadow
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;
#endif // MF_NOSHADOW_ACC

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

@ -158,10 +158,10 @@ hsGMaterial* plProxyGen::IMakeProxyMaterial() const
hsGMaterial* retVal = new hsGMaterial();
plString buff;
if( !GetKey()->GetName().IsNull() )
buff = plString::Format("%s_Material", GetKey()->GetName().c_str());
if( !GetKeyName().IsNull() )
buff = plString::Format("%s_Material", GetKeyName().c_str());
else
buff = _TEMP_CONVERT_FROM_LITERAL("ProxyMaterial");
buff = "ProxyMaterial";
hsgResMgr::ResMgr()->NewKey( buff, retVal, GetKey() ? GetKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc );
plLayer *lay = retVal->MakeBaseLayer();
@ -233,10 +233,10 @@ void plProxyGen::IGenerateProxy()
if( fProxyDrawables[idx] && !fProxyDrawables[idx]->GetKey() )
{
plString buff;
if( !GetKey()->GetName().IsNull() )
buff = plString::Format("%s_ProxyDrawable", GetKey()->GetName().c_str());
if( !GetKeyName().IsNull() )
buff = plString::Format("%s_ProxyDrawable", GetKeyName().c_str());
else
buff = _TEMP_CONVERT_FROM_LITERAL("ProxyDrawable");
buff = "ProxyDrawable";
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})
set(plFile_SOURCES
hsFiles.cpp
plBrowseFolder.cpp
plEncryptedStream.cpp
plFileUtils.cpp
plInitFileReader.cpp
plSecureStream.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
hsFiles.h
plBrowseFolder.h
plEncryptedStream.h
plFileUtils.h
plInitFileReader.h
plSecureStream.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;
const char plSecureStream::kKeyFilename[] = "encryption.key";
const wchar_t plSecureStream::kWKeyFilename[] = L"encryption.key";
plSecureStream::plSecureStream(bool deleteOnExit, uint32_t* key) :
fRef(INVALID_HANDLE_VALUE),
fActualFileSize(0),
@ -757,3 +760,61 @@ hsStream* plSecureStream::OpenSecureFileWrite(const wchar_t* fileName, uint32_t*
s->Open(fileName, L"wb");
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 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

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

@ -128,7 +128,7 @@ hsStream* plStreamSource::GetFile(std::wstring filename)
if (plSecureStream::IsSecureFile(sFilename.c_str()))
{
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!");
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 "plStatusLog/plStatusLog.h"
#include "plFile/hsFiles.h"
#include "hsFiles.h"
#include "pnMessage/plRefMsg.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() )
newRecord->fKeyName = mip->GetKeyName();
else
newRecord->fKeyName = _TEMP_CONVERT_FROM_LITERAL( "<noKey>" );
newRecord->fKeyName = "<noKey>";
if( mip->fCompressionType != kDirectXCompression )
newRecord->fUncompressedInfo.fType = mip->fUncompressedInfo.fType;
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 "plStatusLog/plStatusLog.h"
#include "plFile/hsFiles.h"
#include "hsFiles.h"
#include "plGImage/plDynSurfaceWriter.h"
#if HS_BUILD_FOR_WIN32

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

Loading…
Cancel
Save