Browse Source

Merge pull request #382 from zrax/ReadSafeString_plString

Get rid of hsStream::ReadSafe(W)String(Long)_TEMP
Adam Johnson 11 years ago
parent
commit
37948af058
  1. 7
      Sources/Plasma/Apps/plClient/winmain.cpp
  2. 46
      Sources/Plasma/CoreLib/hsStream.cpp
  3. 14
      Sources/Plasma/CoreLib/hsStream.h
  4. 2
      Sources/Plasma/CoreLib/plGeneric.cpp
  5. 37
      Sources/Plasma/CoreLib/plString.h
  6. 26
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp
  7. 4
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIButtonMod.cpp
  8. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICheckBoxCtrl.cpp
  9. 18
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIControlMod.cpp
  10. 17
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIControlMod.h
  11. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIKnobCtrl.cpp
  12. 15
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListBoxMod.cpp
  13. 6
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListBoxMod.h
  14. 100
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListElement.cpp
  15. 26
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListElement.h
  16. 12
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIMultiLineEditCtrl.cpp
  17. 8
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIMultiLineEditCtrl.h
  18. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIProgressCtrl.cpp
  19. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUITextBoxMod.cpp
  20. 12
      Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp
  21. 2
      Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.h
  22. 4
      Sources/Plasma/FeatureLib/pfMessage/pfBackdoorMsg.h
  23. 2
      Sources/Plasma/FeatureLib/pfMessage/pfGameGUIMsg.h
  24. 4
      Sources/Plasma/FeatureLib/pfMessage/pfKIMsg.h
  25. 2
      Sources/Plasma/FeatureLib/pfMessage/pfMovieEventMsg.cpp
  26. 10
      Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp
  27. 6
      Sources/Plasma/FeatureLib/pfPython/cyMisc.h
  28. 2
      Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp
  29. 39
      Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp
  30. 4
      Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.h
  31. 26
      Sources/Plasma/FeatureLib/pfPython/plPythonPack.cpp
  32. 5
      Sources/Plasma/FeatureLib/pfPython/plPythonPack.h
  33. 6
      Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp
  34. 2
      Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.h
  35. 54
      Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.cpp
  36. 28
      Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.h
  37. 14
      Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStructGlue.cpp
  38. 97
      Sources/Plasma/FeatureLib/pfPython/pyGUIControlListBox.cpp
  39. 18
      Sources/Plasma/FeatureLib/pfPython/pyGUIControlListBox.h
  40. 13
      Sources/Plasma/FeatureLib/pfPython/pyGUIControlListBoxGlue.cpp
  41. 2
      Sources/Plasma/FeatureLib/pfPython/pyKey.cpp
  42. 2
      Sources/Plasma/FeatureLib/pfPython/pyKey.h
  43. 16
      Sources/Plasma/FeatureLib/pfPython/pyNetServerSessionInfo.h
  44. 8
      Sources/Plasma/FeatureLib/pfPython/pyNetServerSessionInfoGlue.cpp
  45. 8
      Sources/Plasma/FeatureLib/pfPython/pyVault.cpp
  46. 2
      Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp
  47. 4
      Sources/Plasma/NucleusLib/pnMessage/plNotifyMsg.cpp
  48. 114
      Sources/Plasma/NucleusLib/pnNetCommon/plGenericVar.cpp
  49. 65
      Sources/Plasma/NucleusLib/pnNetCommon/plGenericVar.h
  50. 52
      Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.cpp
  51. 35
      Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.h
  52. 2
      Sources/Plasma/NucleusLib/pnNetCommon/plSynchedValue.h
  53. 6
      Sources/Plasma/NucleusLib/pnUtils/pnUtStr.h
  54. 2
      Sources/Plasma/PubUtilLib/plAudio/plSound.cpp
  55. 2
      Sources/Plasma/PubUtilLib/plAudio/plSound.h
  56. 2
      Sources/Plasma/PubUtilLib/plAudioCore/plSoundBuffer.cpp
  57. 23
      Sources/Plasma/PubUtilLib/plAvatar/plAGAnim.cpp
  58. 10
      Sources/Plasma/PubUtilLib/plAvatar/plAGAnim.h
  59. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAGApplicator.cpp
  60. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAGChannel.cpp
  61. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.cpp
  62. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAGMasterMod.h
  63. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAGModifier.cpp
  64. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp
  65. 30
      Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp
  66. 16
      Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h
  67. 14
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp
  68. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.h
  69. 6
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp
  70. 2
      Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp
  71. 4
      Sources/Plasma/PubUtilLib/plAvatar/plNPCSpawnMod.cpp
  72. 2
      Sources/Plasma/PubUtilLib/plAvatar/plOneShotMod.cpp
  73. 45
      Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.cpp
  74. 13
      Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.h
  75. 31
      Sources/Plasma/PubUtilLib/plGImage/plDynSurfaceWriter.cpp
  76. 20
      Sources/Plasma/PubUtilLib/plGImage/plDynSurfaceWriter.h
  77. 69
      Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp
  78. 23
      Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.h
  79. 44
      Sources/Plasma/PubUtilLib/plGImage/plFont.cpp
  80. 26
      Sources/Plasma/PubUtilLib/plGImage/plFont.h
  81. 28
      Sources/Plasma/PubUtilLib/plGImage/plFontCache.cpp
  82. 2
      Sources/Plasma/PubUtilLib/plGImage/plFontCache.h
  83. 23
      Sources/Plasma/PubUtilLib/plGImage/plWinFontCache.cpp
  84. 10
      Sources/Plasma/PubUtilLib/plGImage/plWinFontCache.h
  85. 11
      Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp
  86. 8
      Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.h
  87. 7
      Sources/Plasma/PubUtilLib/plMessage/plAIMsg.cpp
  88. 6
      Sources/Plasma/PubUtilLib/plMessage/plAIMsg.h
  89. 6
      Sources/Plasma/PubUtilLib/plMessage/plAnimCmdMsg.cpp
  90. 2
      Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.cpp
  91. 4
      Sources/Plasma/PubUtilLib/plMessage/plDynamicTextMsg.cpp
  92. 34
      Sources/Plasma/PubUtilLib/plMessage/plInputIfaceMgrMsg.h
  93. 9
      Sources/Plasma/PubUtilLib/plMessage/plLinkToAgeMsg.cpp
  94. 7
      Sources/Plasma/PubUtilLib/plMessage/plLinkToAgeMsg.h
  95. 2
      Sources/Plasma/PubUtilLib/plMessage/plLoadAgeMsg.cpp
  96. 4
      Sources/Plasma/PubUtilLib/plMessage/plLoadAvatarMsg.cpp
  97. 2
      Sources/Plasma/PubUtilLib/plMessage/plOneShotCallbacks.cpp
  98. 2
      Sources/Plasma/PubUtilLib/plModifier/plCloneSpawnModifier.cpp
  99. 14
      Sources/Plasma/PubUtilLib/plNetClient/plLinkEffectsMgr.cpp
  100. 2
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp
  101. Some files were not shown because too many files have changed in this diff Show More

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

@ -872,7 +872,7 @@ static void LoadUserPass (LoginDialogParam *pLoginParam)
ZeroMemory(cryptKey, sizeof(cryptKey)); ZeroMemory(cryptKey, sizeof(cryptKey));
GetCryptKey(cryptKey, arrsize(cryptKey)); GetCryptKey(cryptKey, arrsize(cryptKey));
char* temp; plString temp;
pLoginParam->remember = false; pLoginParam->remember = false;
pLoginParam->username[0] = '\0'; pLoginParam->username[0] = '\0';
@ -893,10 +893,9 @@ static void LoadUserPass (LoginDialogParam *pLoginParam)
{ {
temp = stream->ReadSafeString(); temp = stream->ReadSafeString();
if (temp) if (!temp.IsEmpty())
{ {
StrCopy(pLoginParam->username, temp, kMaxAccountNameLength); StrCopy(pLoginParam->username, temp.c_str(), kMaxAccountNameLength);
delete[] temp;
} }
pLoginParam->remember = stream->ReadBool(); pLoginParam->remember = stream->ReadBool();

46
Sources/Plasma/CoreLib/hsStream.cpp

@ -158,7 +158,7 @@ uint32_t hsStream::WriteSafeWStringLong(const plString &string)
return 0; return 0;
} }
plString hsStream::ReadSafeStringLong_TEMP() plString hsStream::ReadSafeStringLong()
{ {
plStringBuffer<char> name; plStringBuffer<char> name;
uint32_t numChars = ReadLE32(); uint32_t numChars = ReadLE32();
@ -179,15 +179,7 @@ plString hsStream::ReadSafeStringLong_TEMP()
return name; return name;
} }
char *hsStream::ReadSafeStringLong() plString hsStream::ReadSafeWStringLong()
{
plString name = ReadSafeStringLong_TEMP();
char *buff = new char[name.GetSize() + 1];
memcpy(buff, name.c_str(), name.GetSize() + 1);
return buff;
}
plString hsStream::ReadSafeWStringLong_TEMP()
{ {
plStringBuffer<uint16_t> retVal; plStringBuffer<uint16_t> retVal;
uint32_t numChars = ReadLE32(); uint32_t numChars = ReadLE32();
@ -209,17 +201,6 @@ plString hsStream::ReadSafeWStringLong_TEMP()
return plString::FromUtf16(retVal); return plString::FromUtf16(retVal);
} }
wchar_t *hsStream::ReadSafeWStringLong()
{
// Horribly inefficient (convert to UTF-8 and then back to UTF-16), which
// is why this should go away completely after plString has taken over
// the world^H^H^H^H^HPlasma
plStringBuffer<wchar_t> retVal = ReadSafeWStringLong_TEMP().ToWchar();
wchar_t *buff = new wchar_t[retVal.GetSize() + 1];
memcpy(buff, retVal.GetData(), retVal.GetSize() + 1);
return buff;
}
uint32_t hsStream::WriteSafeString(const plString &string) uint32_t hsStream::WriteSafeString(const plString &string)
{ {
int len = string.GetSize(); int len = string.GetSize();
@ -261,7 +242,7 @@ uint32_t hsStream::WriteSafeWString(const plString &string)
return 0; return 0;
} }
plString hsStream::ReadSafeString_TEMP() plString hsStream::ReadSafeString()
{ {
plStringBuffer<char> name; plStringBuffer<char> name;
uint16_t numChars = ReadLE16(); uint16_t numChars = ReadLE16();
@ -293,15 +274,7 @@ plString hsStream::ReadSafeString_TEMP()
return name; return name;
} }
char *hsStream::ReadSafeString() plString hsStream::ReadSafeWString()
{
plString name = ReadSafeString_TEMP();
char *buff = new char[name.GetSize() + 1];
memcpy(buff, name.c_str(), name.GetSize() + 1);
return buff;
}
plString hsStream::ReadSafeWString_TEMP()
{ {
plStringBuffer<uint16_t> retVal; plStringBuffer<uint16_t> retVal;
uint32_t numChars = ReadLE16(); uint32_t numChars = ReadLE16();
@ -326,17 +299,6 @@ plString hsStream::ReadSafeWString_TEMP()
return plString::FromUtf16(retVal); return plString::FromUtf16(retVal);
} }
wchar_t *hsStream::ReadSafeWString()
{
// Horribly inefficient (convert to UTF-8 and then back to UTF-16), which
// is why this should go away completely after plString has taken over
// the world^H^H^H^H^HPlasma
plStringBuffer<wchar_t> retVal = ReadSafeWString_TEMP().ToWchar();
wchar_t *buff = new wchar_t[retVal.GetSize() + 1];
memcpy(buff, retVal.GetData(), retVal.GetSize() + 1);
return buff;
}
bool hsStream::Read4Bytes(void *pv) // Virtual, faster version in sub classes bool hsStream::Read4Bytes(void *pv) // Virtual, faster version in sub classes
{ {
int knt = this->Read(sizeof(uint32_t), pv); int knt = this->Read(sizeof(uint32_t), pv);

14
Sources/Plasma/CoreLib/hsStream.h

@ -55,7 +55,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define hsReadOnlyLoggingStream hsReadOnlyStream #define hsReadOnlyLoggingStream hsReadOnlyStream
#define LogRead(byteCount, buffer, desc) Read(byteCount, buffer) #define LogRead(byteCount, buffer, desc) Read(byteCount, buffer)
#define LogReadSafeString() ReadSafeString() #define LogReadSafeString() ReadSafeString()
#define LogReadSafeString_TEMP() ReadSafeString_TEMP()
#define LogReadSafeStringLong() ReadSafeStringLong(); #define LogReadSafeStringLong() ReadSafeStringLong();
#define LogSkip(deltaByteCount, desc) Skip(deltaByteCount) #define LogSkip(deltaByteCount, desc) Skip(deltaByteCount)
#define LogReadLE(value, desc) ReadLE(value) #define LogReadLE(value, desc) ReadLE(value)
@ -126,18 +125,13 @@ public:
uint32_t WriteSafeStringLong(const plString &string); // uses 4 bytes for length uint32_t WriteSafeStringLong(const plString &string); // uses 4 bytes for length
uint32_t WriteSafeWStringLong(const plString &string); uint32_t WriteSafeWStringLong(const plString &string);
char * ReadSafeStringLong(); plString ReadSafeStringLong();
wchar_t * ReadSafeWStringLong(); plString ReadSafeWStringLong();
uint32_t WriteSafeString(const plString &string); // uses 2 bytes for length uint32_t WriteSafeString(const plString &string); // uses 2 bytes for length
uint32_t WriteSafeWString(const plString &string); uint32_t WriteSafeWString(const plString &string);
char * ReadSafeString(); plString ReadSafeString();
wchar_t * ReadSafeWString(); plString ReadSafeWString();
plString ReadSafeStringLong_TEMP();
plString ReadSafeWStringLong_TEMP();
plString ReadSafeString_TEMP();
plString ReadSafeWString_TEMP();
bool GetToken(char *s, uint32_t maxLen=uint32_t(-1), const char beginComment=kComment, const char endComment=kEolnCode); bool GetToken(char *s, uint32_t maxLen=uint32_t(-1), const char beginComment=kComment, const char endComment=kEolnCode);
bool ReadLn(char* s, uint32_t maxLen=uint32_t(-1), const char beginComment=kComment, const char endComment=kEolnCode); bool ReadLn(char* s, uint32_t maxLen=uint32_t(-1), const char beginComment=kComment, const char endComment=kEolnCode);

2
Sources/Plasma/CoreLib/plGeneric.cpp

@ -144,7 +144,7 @@ int plGeneric::Read(hsStream* stream)
break; break;
case kString: case kString:
fStringVal = stream->ReadSafeWString_TEMP(); fStringVal = stream->ReadSafeWString();
break; break;
} }
return stream->GetPosition(); return stream->GetPosition();

37
Sources/Plasma/CoreLib/plString.h

@ -48,6 +48,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <cstring> #include <cstring>
#include <cstdarg> #include <cstdarg>
#include <cstdint> #include <cstdint>
#include <cctype>
#include <vector> #include <vector>
/** Single Unicode character code unit */ /** Single Unicode character code unit */
@ -598,6 +599,42 @@ public:
static plString Fill(size_t count, char c); static plString Fill(size_t count, char c);
public: public:
/** Functor that hashes a string for unordered containers.
* \note The hash is case sensitive.
*/
struct hash
{
// TODO: This doesn't really use enough bits to be useful when
// size_t is 64-bits.
size_t operator()(const plString& str) const
{
size_t hash = 0;
for (size_t i = 0; i < str.GetSize(); ++i) {
hash += fetch_char(str, i);
hash += (hash << 10);
hash ^= (hash >> 6);
}
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
return hash;
}
protected:
virtual char fetch_char(const plString& str, size_t index) const
{ return str.CharAt(index); }
};
/** Functor that hashes a string for unordered containers.
* \remarks This returns the hash of the lower-case variant of the string.
*/
struct hash_i : public hash
{
protected:
virtual char fetch_char(const plString& str, size_t index) const
{ return tolower(str.CharAt(index)); }
};
/** Functor which compares two strings case-insensitively for sorting. */ /** Functor which compares two strings case-insensitively for sorting. */
struct less_i struct less_i
{ {

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

@ -336,7 +336,7 @@ PF_CONSOLE_CMD( Net, // groupName
"Link to an age." ) // helpString "Link to an age." ) // helpString
{ {
plAgeLinkStruct link; plAgeLinkStruct link;
link.GetAgeInfo()->SetAgeFilename( params[0] ); link.GetAgeInfo()->SetAgeFilename( (const char *)params[0] );
link.SetLinkingRules( plNetCommon::LinkingRules::kBasicLink ); link.SetLinkingRules( plNetCommon::LinkingRules::kBasicLink );
plNetLinkingMgr::GetInstance()->LinkToAge( &link ); plNetLinkingMgr::GetInstance()->LinkToAge( &link );
PrintString("Linking to age..."); PrintString("Linking to age...");
@ -350,7 +350,7 @@ PF_CONSOLE_CMD( Net, // groupName
"Link to a specific age by guid." ) // helpString "Link to a specific age by guid." ) // helpString
{ {
plAgeLinkStruct link; plAgeLinkStruct link;
link.GetAgeInfo()->SetAgeFilename( params[0] ); link.GetAgeInfo()->SetAgeFilename( (const char *)params[0] );
//link.GetAgeInfo()->SetAgeInstanceName( params[0] ); //link.GetAgeInfo()->SetAgeInstanceName( params[0] );
//link.GetAgeInfo()->SetAgeUserDefinedName( params[0] ); //link.GetAgeInfo()->SetAgeUserDefinedName( params[0] );
plUUID guid( (const char *)params[1] ); plUUID guid( (const char *)params[1] );
@ -375,7 +375,7 @@ PF_CONSOLE_CMD( Net,
"Link to specified age using Original Age Linking Book rules" ) "Link to specified age using Original Age Linking Book rules" )
{ {
plAgeLinkStruct link; plAgeLinkStruct link;
link.GetAgeInfo()->SetAgeFilename( params[0] ); link.GetAgeInfo()->SetAgeFilename( (const char *)params[0] );
link.SpawnPoint() = plSpawnPointInfo( (const char *)params[1], (const char *)params[1] ); link.SpawnPoint() = plSpawnPointInfo( (const char *)params[1], (const char *)params[1] );
link.SetLinkingRules( plNetCommon::LinkingRules::kOriginalBook ); link.SetLinkingRules( plNetCommon::LinkingRules::kOriginalBook );
plNetLinkingMgr::GetInstance()->LinkToAge( &link ); plNetLinkingMgr::GetInstance()->LinkToAge( &link );
@ -388,7 +388,7 @@ PF_CONSOLE_CMD( Net,
"Link to specified age using Personal Age Linking Book rules" ) "Link to specified age using Personal Age Linking Book rules" )
{ {
plAgeLinkStruct link; plAgeLinkStruct link;
link.GetAgeInfo()->SetAgeFilename( params[0] ); link.GetAgeInfo()->SetAgeFilename( (const char *)params[0] );
link.SetLinkingRules( plNetCommon::LinkingRules::kOwnedBook ); link.SetLinkingRules( plNetCommon::LinkingRules::kOwnedBook );
plNetLinkingMgr::GetInstance()->LinkToAge( &link ); plNetLinkingMgr::GetInstance()->LinkToAge( &link );
PrintString("Linking to age I own..."); PrintString("Linking to age I own...");
@ -400,7 +400,7 @@ PF_CONSOLE_CMD( Net,
"Link to specified age using Personal Age Linking Book rules" ) "Link to specified age using Personal Age Linking Book rules" )
{ {
plAgeLinkStruct link; plAgeLinkStruct link;
link.GetAgeInfo()->SetAgeFilename( params[0] ); link.GetAgeInfo()->SetAgeFilename( (const char *)params[0] );
link.SetLinkingRules( plNetCommon::LinkingRules::kVisitBook ); link.SetLinkingRules( plNetCommon::LinkingRules::kVisitBook );
plNetLinkingMgr::GetInstance()->LinkToAge( &link ); plNetLinkingMgr::GetInstance()->LinkToAge( &link );
PrintString("Linking to age I can visit..."); PrintString("Linking to age I can visit...");
@ -412,7 +412,7 @@ PF_CONSOLE_CMD( Net,
"Link to a sub-age of the current age" ) "Link to a sub-age of the current age" )
{ {
plAgeLinkStruct link; plAgeLinkStruct link;
link.GetAgeInfo()->SetAgeFilename( params[0] ); link.GetAgeInfo()->SetAgeFilename( (const char *)params[0] );
link.SetLinkingRules( plNetCommon::LinkingRules::kSubAgeBook ); link.SetLinkingRules( plNetCommon::LinkingRules::kSubAgeBook );
plNetLinkingMgr::GetInstance()->LinkToAge( &link ); plNetLinkingMgr::GetInstance()->LinkToAge( &link );
PrintString("Linking to a sub-age..."); PrintString("Linking to a sub-age...");
@ -481,7 +481,7 @@ PF_CONSOLE_CMD( Net,
plNetLinkingMgr * lm = plNetLinkingMgr::GetInstance(); plNetLinkingMgr * lm = plNetLinkingMgr::GetInstance();
plAgeInfoStruct info; plAgeInfoStruct info;
info.SetAgeFilename( params[0] ); info.SetAgeFilename( (const char *)params[0] );
plAgeLinkStruct link; plAgeLinkStruct link;
if (!VaultGetOwnedAgeLink(&info, &link)) { if (!VaultGetOwnedAgeLink(&info, &link)) {
@ -806,8 +806,8 @@ PF_CONSOLE_CMD( Net_Vault,
"Add an instance of the specified age to your bookshelf" ) "Add an instance of the specified age to your bookshelf" )
{ {
plAgeLinkStruct link; plAgeLinkStruct link;
link.GetAgeInfo()->SetAgeFilename( params[0] ); link.GetAgeInfo()->SetAgeFilename( (const char *)params[0] );
link.GetAgeInfo()->SetAgeInstanceName( params[0] ); link.GetAgeInfo()->SetAgeInstanceName( (const char *)params[0] );
plUUID guid = plUUID::Generate(); plUUID guid = plUUID::Generate();
link.GetAgeInfo()->SetAgeInstanceGuid( &guid); link.GetAgeInfo()->SetAgeInstanceGuid( &guid);
link.SetSpawnPoint( kDefaultSpawnPoint ); link.SetSpawnPoint( kDefaultSpawnPoint );
@ -822,7 +822,7 @@ PF_CONSOLE_CMD( Net_Vault,
"Remove the specified age from your bookshelf" ) "Remove the specified age from your bookshelf" )
{ {
plAgeInfoStruct info; plAgeInfoStruct info;
info.SetAgeFilename( params[0] ); info.SetAgeFilename( (const char *)params[0] );
bool success = VaultUnregisterOwnedAgeAndWait(&info); bool success = VaultUnregisterOwnedAgeAndWait(&info);
PrintStringF(PrintString, "Operation %s.", success ? "Successful" : "Failed"); PrintStringF(PrintString, "Operation %s.", success ? "Successful" : "Failed");
} }
@ -834,8 +834,8 @@ PF_CONSOLE_CMD( Net_Vault,
"Add an instance of the specified age to your private links" ) "Add an instance of the specified age to your private links" )
{ {
plAgeLinkStruct link; plAgeLinkStruct link;
link.GetAgeInfo()->SetAgeFilename( params[0] ); link.GetAgeInfo()->SetAgeFilename( (const char *)params[0] );
link.GetAgeInfo()->SetAgeInstanceName( params[0] ); link.GetAgeInfo()->SetAgeInstanceName( (const char *)params[0] );
plUUID guid = plUUID::Generate(); plUUID guid = plUUID::Generate();
link.GetAgeInfo()->SetAgeInstanceGuid( &guid); link.GetAgeInfo()->SetAgeInstanceGuid( &guid);
link.SetSpawnPoint( kDefaultSpawnPoint ); link.SetSpawnPoint( kDefaultSpawnPoint );
@ -850,7 +850,7 @@ PF_CONSOLE_CMD( Net_Vault,
"Remove all instances of the specified age from your private links" ) "Remove all instances of the specified age from your private links" )
{ {
plAgeInfoStruct info; plAgeInfoStruct info;
info.SetAgeFilename( params[0] ); info.SetAgeFilename( (const char *)params[0] );
unsigned count = 0; unsigned count = 0;
while (VaultUnregisterVisitAgeAndWait(&info)) while (VaultUnregisterVisitAgeAndWait(&info))

4
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIButtonMod.cpp

@ -196,13 +196,13 @@ void pfGUIButtonMod::Read( hsStream *s, hsResMgr *mgr )
uint32_t i, count = s->ReadLE32(); uint32_t i, count = s->ReadLE32();
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
fAnimationKeys.Append( mgr->ReadKey( s ) ); fAnimationKeys.Append( mgr->ReadKey( s ) );
fAnimName = s->ReadSafeString_TEMP(); fAnimName = s->ReadSafeString();
fMouseOverAnimKeys.Reset(); fMouseOverAnimKeys.Reset();
count = s->ReadLE32(); count = s->ReadLE32();
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
fMouseOverAnimKeys.Append( mgr->ReadKey( s ) ); fMouseOverAnimKeys.Append( mgr->ReadKey( s ) );
fMouseOverAnimName = s->ReadSafeString_TEMP(); fMouseOverAnimName = s->ReadSafeString();
fNotifyType = s->ReadLE32(); fNotifyType = s->ReadLE32();
mgr->ReadKeyNotifyMe( s, new plGenRefMsg( GetKey(), plRefMsg::kOnCreate, -1, kRefDraggable ), plRefFlags::kActiveRef ); mgr->ReadKeyNotifyMe( s, new plGenRefMsg( GetKey(), plRefMsg::kOnCreate, -1, kRefDraggable ), plRefFlags::kActiveRef );

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

@ -96,7 +96,7 @@ void pfGUICheckBoxCtrl::Read( hsStream *s, hsResMgr *mgr )
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
fAnimationKeys.Append( mgr->ReadKey( s ) ); fAnimationKeys.Append( mgr->ReadKey( s ) );
fAnimName = s->ReadSafeString_TEMP(); fAnimName = s->ReadSafeString();
fChecked = s->ReadBool(); fChecked = s->ReadBool();
} }

18
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIControlMod.cpp

@ -85,7 +85,7 @@ void pfGUIColorScheme::IReset( void )
fSelForeColor.Set( 1, 1, 1, 1 ); fSelForeColor.Set( 1, 1, 1, 1 );
fSelBackColor.Set( 0, 0, 1, 1 ); fSelBackColor.Set( 0, 0, 1, 1 );
fTransparent = false; fTransparent = false;
fFontFace = hsStrcpy( "Times New Roman" ); fFontFace = "Times New Roman";
fFontSize = 10; fFontSize = 10;
fFontFlags = 0; fFontFlags = 0;
} }
@ -95,11 +95,6 @@ pfGUIColorScheme::pfGUIColorScheme()
IReset(); IReset();
} }
pfGUIColorScheme::~pfGUIColorScheme()
{
delete [] fFontFace;
}
pfGUIColorScheme::pfGUIColorScheme( hsColorRGBA &foreColor, hsColorRGBA &backColor ) pfGUIColorScheme::pfGUIColorScheme( hsColorRGBA &foreColor, hsColorRGBA &backColor )
{ {
IReset(); IReset();
@ -107,20 +102,14 @@ pfGUIColorScheme::pfGUIColorScheme( hsColorRGBA &foreColor, hsColorRGBA &backCol
fBackColor = backColor; fBackColor = backColor;
} }
pfGUIColorScheme::pfGUIColorScheme( const char *face, uint8_t size, uint8_t fontFlags ) pfGUIColorScheme::pfGUIColorScheme( const plString &face, uint8_t size, uint8_t fontFlags )
{ {
IReset(); IReset();
fFontFace = hsStrcpy( face ); fFontFace = face;
fFontSize = size; fFontSize = size;
fFontFlags = fontFlags; fFontFlags = fontFlags;
} }
void pfGUIColorScheme::SetFontFace( const char *face )
{
delete [] fFontFace;
fFontFace = hsStrcpy( face );
}
void pfGUIColorScheme::Read( hsStream *s ) void pfGUIColorScheme::Read( hsStream *s )
{ {
fForeColor.Read( s ); fForeColor.Read( s );
@ -129,7 +118,6 @@ void pfGUIColorScheme::Read( hsStream *s )
fSelBackColor.Read( s ); fSelBackColor.Read( s );
fTransparent = s->ReadBOOL(); fTransparent = s->ReadBOOL();
delete [] fFontFace;
fFontFace = s->ReadSafeString(); fFontFace = s->ReadSafeString();
s->ReadLE( &fFontSize ); s->ReadLE( &fFontSize );
s->ReadLE( &fFontFlags ); s->ReadLE( &fFontFlags );

17
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIControlMod.h

@ -74,9 +74,9 @@ class pfGUIColorScheme : public hsRefCnt
hsColorRGBA fSelForeColor, fSelBackColor; hsColorRGBA fSelForeColor, fSelBackColor;
bool fTransparent; bool fTransparent;
char *fFontFace; plString fFontFace;
uint8_t fFontSize; uint8_t fFontSize;
uint8_t fFontFlags; uint8_t fFontFlags;
enum FontFlags enum FontFlags
{ {
@ -86,18 +86,17 @@ class pfGUIColorScheme : public hsRefCnt
}; };
pfGUIColorScheme(); pfGUIColorScheme();
~pfGUIColorScheme();
pfGUIColorScheme( hsColorRGBA &foreColor, hsColorRGBA &backColor ); pfGUIColorScheme( hsColorRGBA &foreColor, hsColorRGBA &backColor );
pfGUIColorScheme( const char *face, uint8_t size, uint8_t fontFlags ); pfGUIColorScheme( const plString &face, uint8_t size, uint8_t fontFlags );
void SetFontFace( const char *face ); void SetFontFace(const plString &face) { fFontFace = face; }
void Read( hsStream *s ); void Read( hsStream *s );
void Write( hsStream *s ); void Write( hsStream *s );
bool IsBold( void ) { return ( fFontFlags & kFontBold ) ? true : false; } bool IsBold() const { return ( fFontFlags & kFontBold ) ? true : false; }
bool IsItalic( void ) { return ( fFontFlags & kFontItalic ) ? true : false; } bool IsItalic() const { return ( fFontFlags & kFontItalic ) ? true : false; }
bool IsShadowed( void ) { return ( fFontFlags & kFontShadowed ) ? true : false; } bool IsShadowed() const { return ( fFontFlags & kFontShadowed ) ? true : false; }
protected: protected:

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

@ -106,7 +106,7 @@ void pfGUIKnobCtrl::Read( hsStream *s, hsResMgr *mgr )
uint32_t i, count = s->ReadLE32(); uint32_t i, count = s->ReadLE32();
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
fAnimationKeys.Append( mgr->ReadKey( s ) ); fAnimationKeys.Append( mgr->ReadKey( s ) );
fAnimName = s->ReadSafeString_TEMP(); fAnimName = s->ReadSafeString();
fAnimTimesCalced = false; fAnimTimesCalced = false;

15
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListBoxMod.cpp

@ -1152,23 +1152,12 @@ void pfGUIListBoxMod::ClearAllElements( void )
HandleExtendedEvent( pfGUIListBoxMod::kListCleared ); HandleExtendedEvent( pfGUIListBoxMod::kListCleared );
} }
uint16_t pfGUIListBoxMod::AddString( const char *string ) uint16_t pfGUIListBoxMod::AddString( const plString &string )
{ {
return AddElement( new pfGUIListText( string ) ); return AddElement( new pfGUIListText( string ) );
} }
uint16_t pfGUIListBoxMod::AddString( const wchar_t *string ) int16_t pfGUIListBoxMod::FindString( const plString &toCompareTo )
{
return AddElement( new pfGUIListText( string ) );
}
int16_t pfGUIListBoxMod::FindString( const char *toCompareTo )
{
pfGUIListText text( toCompareTo );
return FindElement( &text );
}
int16_t pfGUIListBoxMod::FindString( const wchar_t *toCompareTo )
{ {
pfGUIListText text( toCompareTo ); pfGUIListText text( toCompareTo );
return FindElement( &text ); return FindElement( &text );

6
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListBoxMod.h

@ -186,10 +186,8 @@ class pfGUIListBoxMod : public pfGUIControlMod
uint16_t GetNumElements( void ); uint16_t GetNumElements( void );
pfGUIListElement *GetElement( uint16_t idx ); pfGUIListElement *GetElement( uint16_t idx );
uint16_t AddString( const char *string ); uint16_t AddString( const plString &string );
uint16_t AddString( const wchar_t *string ); int16_t FindString( const plString &toCompareTo );
int16_t FindString( const char *toCompareTo );
int16_t FindString( const wchar_t *toCompareTo );
// Export only // Export only
void SetScrollCtrl( pfGUIValueCtrl *ctrl ) { fScrollControl = ctrl; } void SetScrollCtrl( pfGUIValueCtrl *ctrl ) { fScrollControl = ctrl; }

100
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListElement.cpp

@ -77,28 +77,14 @@ void pfGUIListElement::Write( hsStream *s, hsResMgr *mgr )
//// Constructor/Destructor ////////////////////////////////////////////////// //// Constructor/Destructor //////////////////////////////////////////////////
pfGUIListText::pfGUIListText() : pfGUIListElement( kText ) pfGUIListText::pfGUIListText()
: pfGUIListElement(kText), fJustify(kLeftJustify)
{ {
fText = nil;
fJustify = kLeftJustify;
} }
pfGUIListText::pfGUIListText( const char *text ) : pfGUIListElement( kText ) pfGUIListText::pfGUIListText( const plString &text )
: pfGUIListElement(kText), fText(text), fJustify(kLeftJustify)
{ {
fText = hsStringToWString(text);
fJustify = kLeftJustify;
}
pfGUIListText::pfGUIListText( const wchar_t *text ) : pfGUIListElement( kText )
{
fText = new wchar_t[ wcslen( text ) + 1 ];
wcscpy( fText, text );
fJustify = kLeftJustify;
}
pfGUIListText::~pfGUIListText()
{
delete [] fText;
} }
//// Virtuals //////////////////////////////////////////////////////////////// //// Virtuals ////////////////////////////////////////////////////////////////
@ -107,18 +93,14 @@ void pfGUIListText::Read( hsStream *s, hsResMgr *mgr )
{ {
pfGUIListElement::Read( s, mgr ); pfGUIListElement::Read( s, mgr );
char *text = s->ReadSafeString(); fText = s->ReadSafeString();
fText = hsStringToWString(text);
delete [] text;
} }
void pfGUIListText::Write( hsStream *s, hsResMgr *mgr ) void pfGUIListText::Write( hsStream *s, hsResMgr *mgr )
{ {
pfGUIListElement::Write( s, mgr ); pfGUIListElement::Write( s, mgr );
char *text = hsWStringToString(fText); s->WriteSafeString(fText);
s->WriteSafeString(text);
delete [] text;
} }
bool pfGUIListText::Draw( plDynamicTextMap *textGen, uint16_t x, uint16_t y, uint16_t maxWidth, uint16_t maxHeight ) bool pfGUIListText::Draw( plDynamicTextMap *textGen, uint16_t x, uint16_t y, uint16_t maxWidth, uint16_t maxHeight )
@ -158,26 +140,7 @@ int pfGUIListText::CompareTo( pfGUIListElement *rightSide )
if( text->fType != kText ) if( text->fType != kText )
return -2; return -2;
return wcscmp( GetText(), text->GetText() ); return GetText().Compare(text->GetText());
}
void pfGUIListText::SetText( const char *text )
{
wchar_t *wText = hsStringToWString(text);
SetText(wText);
delete [] wText;
}
void pfGUIListText::SetText( const wchar_t *text )
{
delete [] fText;
if( text != nil )
{
fText = new wchar_t[ wcslen( text ) + 1 ];
wcscpy( fText, text );
}
else
fText = nil;
} }
void pfGUIListText::SetJustify( JustifyTypes justify ) void pfGUIListText::SetJustify( JustifyTypes justify )
@ -295,26 +258,14 @@ int pfGUIListPicture::CompareTo( pfGUIListElement *rightSide )
//// Constructor/Destructor ////////////////////////////////////////////////// //// Constructor/Destructor //////////////////////////////////////////////////
pfGUIListTreeRoot::pfGUIListTreeRoot() : pfGUIListElement( kTreeRoot ) pfGUIListTreeRoot::pfGUIListTreeRoot()
: pfGUIListElement(kTreeRoot), fShowChildren(true)
{ {
fText = nil;
fShowChildren = true;
} }
pfGUIListTreeRoot::pfGUIListTreeRoot( const char *text ) : pfGUIListElement( kTreeRoot ) pfGUIListTreeRoot::pfGUIListTreeRoot( const plString &text )
: pfGUIListElement(kTreeRoot), fText(text)
{ {
fText = hsStringToWString(text);
}
pfGUIListTreeRoot::pfGUIListTreeRoot( const wchar_t *text ) : pfGUIListElement( kTreeRoot )
{
fText = new wchar_t[ wcslen( text ) + 1 ];
wcscpy( fText, text );
}
pfGUIListTreeRoot::~pfGUIListTreeRoot()
{
delete [] fText;
} }
//// Virtuals //////////////////////////////////////////////////////////////// //// Virtuals ////////////////////////////////////////////////////////////////
@ -323,18 +274,14 @@ void pfGUIListTreeRoot::Read( hsStream *s, hsResMgr *mgr )
{ {
pfGUIListElement::Read( s, mgr ); pfGUIListElement::Read( s, mgr );
char *temp = s->ReadSafeString(); fText = s->ReadSafeString();
fText = hsStringToWString(temp);
delete [] temp;
} }
void pfGUIListTreeRoot::Write( hsStream *s, hsResMgr *mgr ) void pfGUIListTreeRoot::Write( hsStream *s, hsResMgr *mgr )
{ {
pfGUIListElement::Write( s, mgr ); pfGUIListElement::Write( s, mgr );
char *temp = hsWStringToString(fText); s->WriteSafeString(fText);
s->WriteSafeString( temp );
delete [] temp;
} }
bool pfGUIListTreeRoot::Draw( plDynamicTextMap *textGen, uint16_t x, uint16_t y, uint16_t maxWidth, uint16_t maxHeight ) bool pfGUIListTreeRoot::Draw( plDynamicTextMap *textGen, uint16_t x, uint16_t y, uint16_t maxWidth, uint16_t maxHeight )
@ -416,26 +363,7 @@ int pfGUIListTreeRoot::CompareTo( pfGUIListElement *rightSide )
if( text->fType != kTreeRoot ) if( text->fType != kTreeRoot )
return -2; return -2;
return wcscmp( GetTitle(), text->GetTitle() ); return GetTitle().Compare(text->GetTitle());
}
void pfGUIListTreeRoot::SetTitle( const char *text )
{
wchar_t *wText = hsStringToWString(text);
SetTitle(wText);
delete [] wText;
}
void pfGUIListTreeRoot::SetTitle( const wchar_t *text )
{
delete [] fText;
if( text != nil )
{
fText = new wchar_t[ wcslen( text ) + 1 ];
wcscpy( fText, text );
}
else
fText = nil;
} }
void pfGUIListTreeRoot::AddChild( pfGUIListElement *el ) void pfGUIListTreeRoot::AddChild( pfGUIListElement *el )

26
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListElement.h

@ -118,15 +118,13 @@ class pfGUIListText : public pfGUIListElement
protected: protected:
wchar_t *fText; plString fText;
uint8_t fJustify; // This is not our JustifyTypes, but from plDynamicTextMap uint8_t fJustify; // This is not our JustifyTypes, but from plDynamicTextMap
public: public:
pfGUIListText(); pfGUIListText();
pfGUIListText( const char *text ); pfGUIListText( const plString &text );
pfGUIListText( const wchar_t *text );
virtual ~pfGUIListText();
virtual void Read( hsStream *s, hsResMgr *mgr ); virtual void Read( hsStream *s, hsResMgr *mgr );
virtual void Write( hsStream *s, hsResMgr *mgr ); virtual void Write( hsStream *s, hsResMgr *mgr );
@ -139,9 +137,8 @@ class pfGUIListText : public pfGUIListElement
virtual void SetJustify( JustifyTypes justify ); virtual void SetJustify( JustifyTypes justify );
// These two are virtual so we can derive and override them // These two are virtual so we can derive and override them
virtual const wchar_t *GetText( void ) { return fText; } virtual plString GetText() const { return fText; }
virtual void SetText( const char *text ); virtual void SetText(const plString &text) { fText = text; }
virtual void SetText( const wchar_t *text );
}; };
class pfGUIListPicture : public pfGUIListElement class pfGUIListPicture : public pfGUIListElement
@ -176,7 +173,7 @@ class pfGUIListTreeRoot : public pfGUIListElement
{ {
protected: protected:
wchar_t *fText; plString fText;
bool fShowChildren; bool fShowChildren;
hsTArray<pfGUIListElement *> fChildren; hsTArray<pfGUIListElement *> fChildren;
@ -184,9 +181,7 @@ class pfGUIListTreeRoot : public pfGUIListElement
public: public:
pfGUIListTreeRoot(); pfGUIListTreeRoot();
pfGUIListTreeRoot( const char *text ); pfGUIListTreeRoot( const plString &text );
pfGUIListTreeRoot( const wchar_t *text );
virtual ~pfGUIListTreeRoot();
virtual void Read( hsStream *s, hsResMgr *mgr ); virtual void Read( hsStream *s, hsResMgr *mgr );
virtual void Write( hsStream *s, hsResMgr *mgr ); virtual void Write( hsStream *s, hsResMgr *mgr );
@ -197,11 +192,10 @@ class pfGUIListTreeRoot : public pfGUIListElement
virtual bool MouseClicked( uint16_t localX, uint16_t localY ); virtual bool MouseClicked( uint16_t localX, uint16_t localY );
const wchar_t *GetTitle( void ) { return fText; } const plString GetTitle() const { return fText; }
void SetTitle( const char *text ); void SetTitle(const plString &text) { fText = text; }
void SetTitle( const wchar_t *text );
uint32_t GetNumChildren( void ) const { return fChildren.GetCount(); } uint32_t GetNumChildren() const { return fChildren.GetCount(); }
pfGUIListElement *GetChild( uint32_t i ) const { return fChildren[ i ]; } pfGUIListElement *GetChild( uint32_t i ) const { return fChildren[ i ]; }
void AddChild( pfGUIListElement *el ); void AddChild( pfGUIListElement *el );

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

@ -349,7 +349,7 @@ void pfGUIMultiLineEditCtrl::IPostSetUpDynTextMap( void )
fFontFlagsSet |= kFontStyleSet; fFontFlagsSet |= kFontStyleSet;
} }
fDynTextMap->SetFont( fFontFace.c_str(), fFontSize, fFontStyle, fDynTextMap->SetFont( fFontFace, fFontSize, fFontStyle,
HasFlag( kXparentBgnd ) ? false : true ); HasFlag( kXparentBgnd ) ? false : true );
// Calculate a height for each line // Calculate a height for each line
@ -572,7 +572,7 @@ uint32_t pfGUIMultiLineEditCtrl::IRenderLine( uint16_t x, uint16_t y, int32_t s
IFindLastStyleCode( start, currStyle ); IFindLastStyleCode( start, currStyle );
fDynTextMap->SetTextColor( currColor, HasFlag( kXparentBgnd ) ? true : false ); fDynTextMap->SetTextColor( currColor, HasFlag( kXparentBgnd ) ? true : false );
fDynTextMap->SetFont( fFontFace.c_str(), fFontSize, GetColorScheme()->fFontFlags | currStyle, fDynTextMap->SetFont( fFontFace, fFontSize, GetColorScheme()->fFontFlags | currStyle,
HasFlag( kXparentBgnd ) ? false : true ); HasFlag( kXparentBgnd ) ? false : true );
// Now, start from our start and go to the end and keep eating up as many chunks // Now, start from our start and go to the end and keep eating up as many chunks
@ -609,7 +609,7 @@ uint32_t pfGUIMultiLineEditCtrl::IRenderLine( uint16_t x, uint16_t y, int32_t s
// Read style and switch to that one // Read style and switch to that one
IReadStyleCode( pos, currStyle ); IReadStyleCode( pos, currStyle );
if( !dontRender ) if( !dontRender )
fDynTextMap->SetFont( fFontFace.c_str(), fFontSize , GetColorScheme()->fFontFlags | currStyle, fDynTextMap->SetFont( fFontFace, fFontSize , GetColorScheme()->fFontFlags | currStyle,
HasFlag( kXparentBgnd ) ? false : true ); HasFlag( kXparentBgnd ) ? false : true );
} }
else if( buffer[ pos ] == L'\n' ) else if( buffer[ pos ] == L'\n' )
@ -1836,11 +1836,11 @@ void pfGUIMultiLineEditCtrl::IHitBeginningOfControlList(int32_t cursorPos)
} }
} }
void pfGUIMultiLineEditCtrl::SetFontFace(std::string fontFace) void pfGUIMultiLineEditCtrl::SetFontFace(const plString &fontFace)
{ {
fFontFace = fontFace; fFontFace = fontFace;
fFontFlagsSet |= kFontFaceSet; fFontFlagsSet |= kFontFaceSet;
fDynTextMap->SetFont( fFontFace.c_str(), fFontSize, fFontStyle, fDynTextMap->SetFont( fFontFace, fFontSize, fFontStyle,
HasFlag( kXparentBgnd ) ? false : true ); HasFlag( kXparentBgnd ) ? false : true );
fDynTextMap->CalcStringWidth( "The quick brown fox jumped over the lazy dog.", &fLineHeight ); fDynTextMap->CalcStringWidth( "The quick brown fox jumped over the lazy dog.", &fLineHeight );
} }
@ -1850,7 +1850,7 @@ void pfGUIMultiLineEditCtrl::SetFontSize(uint8_t fontSize)
fFontSize = fontSize; fFontSize = fontSize;
fFontFlagsSet |= kFontSizeSet; fFontFlagsSet |= kFontSizeSet;
fCalcedFontSize = fontSize; fCalcedFontSize = fontSize;
fDynTextMap->SetFont( fFontFace.c_str(), fFontSize, fFontStyle, fDynTextMap->SetFont( fFontFace, fFontSize, fFontStyle,
HasFlag( kXparentBgnd ) ? false : true ); HasFlag( kXparentBgnd ) ? false : true );
fDynTextMap->CalcStringWidth( "The quick brown fox jumped over the lazy dog.", &fLineHeight ); fDynTextMap->CalcStringWidth( "The quick brown fox jumped over the lazy dog.", &fLineHeight );
} }

8
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIMultiLineEditCtrl.h

@ -129,10 +129,10 @@ class pfGUIMultiLineEditCtrl : public pfGUIControlMod
pfGUIMultiLineEditProc *fEventProc; // where we send events to pfGUIMultiLineEditProc *fEventProc; // where we send events to
std::string fFontFace; plString fFontFace;
hsColorRGBA fFontColor; hsColorRGBA fFontColor;
uint8_t fFontSize; uint8_t fFontSize;
uint8_t fFontStyle; uint8_t fFontStyle;
enum flagsSet enum flagsSet
{ {
kFontFaceSet = 1, kFontFaceSet = 1,
@ -271,7 +271,7 @@ class pfGUIMultiLineEditCtrl : public pfGUIControlMod
uint8_t GetFontSize() {return fFontSize;} // because we're too cool to use the color scheme crap uint8_t GetFontSize() {return fFontSize;} // because we're too cool to use the color scheme crap
void SetFontFace(std::string fontFace); void SetFontFace(const plString &fontFace);
void SetFontColor(hsColorRGBA fontColor) {fFontColor = fontColor; fFontFlagsSet |= kFontColorSet;} void SetFontColor(hsColorRGBA fontColor) {fFontColor = fontColor; fFontFlagsSet |= kFontColorSet;}
void SetFontSize(uint8_t fontSize); void SetFontSize(uint8_t fontSize);
void SetFontStyle(uint8_t fontStyle) {fFontStyle = fontStyle; fFontFlagsSet |= kFontStyleSet;} void SetFontStyle(uint8_t fontStyle) {fFontStyle = fontStyle; fFontFlagsSet |= kFontStyleSet;}

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

@ -108,7 +108,7 @@ void pfGUIProgressCtrl::Read( hsStream *s, hsResMgr *mgr )
uint32_t i, count = s->ReadLE32(); uint32_t i, count = s->ReadLE32();
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
fAnimationKeys.Append( mgr->ReadKey( s ) ); fAnimationKeys.Append( mgr->ReadKey( s ) );
fAnimName = s->ReadSafeString_TEMP(); fAnimName = s->ReadSafeString();
fAnimTimesCalced = false; fAnimTimesCalced = false;
} }

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

@ -169,7 +169,7 @@ void pfGUITextBoxMod::Read( hsStream *s, hsResMgr *mgr )
fUseLocalizationPath = s->ReadBool(); fUseLocalizationPath = s->ReadBool();
if (fUseLocalizationPath) if (fUseLocalizationPath)
{ {
fLocalizationPath = s->ReadSafeWString_TEMP(); fLocalizationPath = s->ReadSafeWString();
} }
} }

12
Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp

@ -2608,10 +2608,10 @@ void pfJournalBook::IRenderPage( uint32_t page, uint32_t whichDTMap, bool sup
uint32_t idx; uint32_t idx;
uint16_t width, height, y, x, ascent, lastX, lastY; uint16_t width, height, y, x, ascent, lastX, lastY;
uint8_t fontFlags, fontSize; uint8_t fontFlags, fontSize;
const wchar_t *fontFace; plString fontFace;
hsColorRGBA fontColor; hsColorRGBA fontColor;
int16_t fontSpacing; int16_t fontSpacing;
bool needSFX = false; bool needSFX = false;
// Find and set initial font properties // Find and set initial font properties
@ -3339,7 +3339,7 @@ void pfJournalBook::ISetDecalLayers(hsGMaterial *material,hsTArray<plLayerInterf
// Starting at the given chunk, works backwards to determine the full set of current // Starting at the given chunk, works backwards to determine the full set of current
// font properties at that point, or assigns defaults if none were specified // font properties at that point, or assigns defaults if none were specified
void pfJournalBook::IFindFontProps( uint32_t chunkIdx, const wchar_t *&face, uint8_t &size, uint8_t &flags, hsColorRGBA &color, int16_t &spacing ) void pfJournalBook::IFindFontProps( uint32_t chunkIdx, plString &face, uint8_t &size, uint8_t &flags, hsColorRGBA &color, int16_t &spacing )
{ {
enum Which enum Which
{ {
@ -3369,7 +3369,7 @@ void pfJournalBook::IFindFontProps( uint32_t chunkIdx, const wchar_t *&face,
// What do we (still) need? // What do we (still) need?
if( !( found & kFace ) && chunk->fText != L"" ) if( !( found & kFace ) && chunk->fText != L"" )
{ {
face = chunk->fText.c_str(); face = plString::FromWchar(chunk->fText.c_str());
found |= kFace; found |= kFace;
} }
if( !( found & kSize ) && chunk->fFontSize > 0 ) if( !( found & kSize ) && chunk->fFontSize > 0 )
@ -3403,7 +3403,7 @@ void pfJournalBook::IFindFontProps( uint32_t chunkIdx, const wchar_t *&face,
// Set any un-found defaults // Set any un-found defaults
if( !( found & kFace ) ) if( !( found & kFace ) )
face = L"Arial"; face = "Arial";
if( !( found & kSize ) ) if( !( found & kSize ) )
size = 24; size = 24;
if( !( found & kFlags ) ) if( !( found & kFlags ) )

2
Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.h

@ -535,7 +535,7 @@ class pfJournalBook : public hsKeyedObject
// Starting at the given chunk, works backwards to determine the full set of current // Starting at the given chunk, works backwards to determine the full set of current
// font properties at that point, or assigns defaults if none were specified // font properties at that point, or assigns defaults if none were specified
void IFindFontProps( uint32_t chunkIdx, const wchar_t *&face, uint8_t &size, uint8_t &flags, hsColorRGBA &color, int16_t &spacing ); void IFindFontProps( uint32_t chunkIdx, plString &face, uint8_t &size, uint8_t &flags, hsColorRGBA &color, int16_t &spacing );
// Find the last paragraph chunk and thus the last par alignment settings // Find the last paragraph chunk and thus the last par alignment settings
uint8_t IFindLastAlignment( void ) const; uint8_t IFindLastAlignment( void ) const;

4
Sources/Plasma/FeatureLib/pfMessage/pfBackdoorMsg.h

@ -74,8 +74,8 @@ class pfBackdoorMsg : public plMessage
virtual void Read(hsStream* s, hsResMgr* mgr) virtual void Read(hsStream* s, hsResMgr* mgr)
{ {
plMessage::IMsgRead( s, mgr ); plMessage::IMsgRead( s, mgr );
fTarget = s->ReadSafeString_TEMP(); fTarget = s->ReadSafeString();
fString = s->ReadSafeString_TEMP(); fString = s->ReadSafeString();
} }
virtual void Write(hsStream* s, hsResMgr* mgr) virtual void Write(hsStream* s, hsResMgr* mgr)

2
Sources/Plasma/FeatureLib/pfMessage/pfGameGUIMsg.h

@ -84,7 +84,7 @@ class pfGameGUIMsg : public plMessage
s->Read(sizeof(buffer), buffer); s->Read(sizeof(buffer), buffer);
buffer[GAME_GUI_MSG_STRING_SIZE - 1] = 0; buffer[GAME_GUI_MSG_STRING_SIZE - 1] = 0;
fString = buffer; fString = buffer;
fAge = s->ReadSafeString_TEMP(); fAge = s->ReadSafeString();
} }
virtual void Write(hsStream* s, hsResMgr* mgr) virtual void Write(hsStream* s, hsResMgr* mgr)

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

@ -188,9 +188,9 @@ class pfKIMsg : public plMessage
{ {
plMessage::IMsgRead( s, mgr ); plMessage::IMsgRead( s, mgr );
s->ReadLE( &fCommand ); s->ReadLE( &fCommand );
fUser = s->ReadSafeString_TEMP(); fUser = s->ReadSafeString();
fPlayerID = s->ReadLE32(); fPlayerID = s->ReadLE32();
fString = s->ReadSafeWString_TEMP(); fString = s->ReadSafeWString();
fFlags = s->ReadLE32(); fFlags = s->ReadLE32();
fDelay = s->ReadLEScalar(); fDelay = s->ReadLEScalar();
fValue = s->ReadLE32(); fValue = s->ReadLE32();

2
Sources/Plasma/FeatureLib/pfMessage/pfMovieEventMsg.cpp

@ -49,7 +49,7 @@ void pfMovieEventMsg::Read(hsStream* stream, hsResMgr* mgr)
fReason = (Reason)stream->ReadByte(); fReason = (Reason)stream->ReadByte();
fMovieName = stream->ReadSafeString_TEMP(); fMovieName = stream->ReadSafeString();
} }
void pfMovieEventMsg::Write(hsStream* stream, hsResMgr* mgr) void pfMovieEventMsg::Write(hsStream* stream, hsResMgr* mgr)

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

@ -443,7 +443,7 @@ void cyMisc::DetachObjectSO(pySceneObject& cobj, pySceneObject& pobj, bool netFo
// //
// PURPOSE : set the Python modifier to be dirty and asked to be saved out // PURPOSE : set the Python modifier to be dirty and asked to be saved out
// //
void cyMisc::SetDirtySyncState(pyKey &selfkey, const char* SDLStateName, uint32_t sendFlags) void cyMisc::SetDirtySyncState(pyKey &selfkey, const plString& SDLStateName, uint32_t sendFlags)
{ {
selfkey.DirtySynchState(SDLStateName, sendFlags); selfkey.DirtySynchState(SDLStateName, sendFlags);
} }
@ -455,7 +455,7 @@ void cyMisc::SetDirtySyncState(pyKey &selfkey, const char* SDLStateName, uint32_
// //
// PURPOSE : set the Python modifier to be dirty and asked to be saved out // PURPOSE : set the Python modifier to be dirty and asked to be saved out
// //
void cyMisc::SetDirtySyncStateWithClients(pyKey &selfkey, const char* SDLStateName, uint32_t sendFlags) void cyMisc::SetDirtySyncStateWithClients(pyKey &selfkey, const plString& SDLStateName, uint32_t sendFlags)
{ {
selfkey.DirtySynchState(SDLStateName, sendFlags|plSynchedObject::kBCastToClients); selfkey.DirtySynchState(SDLStateName, sendFlags|plSynchedObject::kBCastToClients);
} }
@ -632,7 +632,7 @@ PyObject* cyMisc::GetAgeInfo()
} }
const char* cyMisc::GetPrevAgeName() plString cyMisc::GetPrevAgeName()
{ {
plNetLinkingMgr* nmgr = plNetLinkingMgr::GetInstance(); plNetLinkingMgr* nmgr = plNetLinkingMgr::GetInstance();
if (nmgr) if (nmgr)
@ -641,7 +641,7 @@ const char* cyMisc::GetPrevAgeName()
if (als) if (als)
return als->GetAgeInfo()->GetAgeFilename(); return als->GetAgeInfo()->GetAgeFilename();
} }
return nil; return plString::Null;
} }
PyObject* cyMisc::GetPrevAgeInfo() PyObject* cyMisc::GetPrevAgeInfo()
@ -2919,7 +2919,7 @@ PyObject* cyMisc::GetAIAvatarsByModelName(const char* name)
{ {
PyObject* tuple = PyTuple_New(2); PyObject* tuple = PyTuple_New(2);
PyTuple_SetItem(tuple, 0, pyCritterBrain::New(critterBrain)); PyTuple_SetItem(tuple, 0, pyCritterBrain::New(critterBrain));
PyTuple_SetItem(tuple, 1, PyString_FromString(armMod->GetUserStr())); PyTuple_SetItem(tuple, 1, PyString_FromPlString(armMod->GetUserStr()));
PyList_Append(avList, tuple); PyList_Append(avList, tuple);
Py_DECREF(tuple); Py_DECREF(tuple);

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

@ -217,7 +217,7 @@ public:
// //
// PURPOSE : set the Python modifier to be dirty and asked to be saved out // PURPOSE : set the Python modifier to be dirty and asked to be saved out
// //
static void SetDirtySyncState(pyKey &selfkey, const char* SDLStateName, uint32_t sendFlags); static void SetDirtySyncState(pyKey &selfkey, const plString& SDLStateName, uint32_t sendFlags);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -227,7 +227,7 @@ public:
// PURPOSE : set the Python modifier to be dirty and asked to be saved out // PURPOSE : set the Python modifier to be dirty and asked to be saved out
// specifies that state should be sent to other clients as well as server // specifies that state should be sent to other clients as well as server
// //
static void SetDirtySyncStateWithClients(pyKey &selfkey, const char* SDLStateName, uint32_t sendFlags); static void SetDirtySyncStateWithClients(pyKey &selfkey, const plString& SDLStateName, uint32_t sendFlags);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -300,7 +300,7 @@ public:
// //
static const char* GetAgeName(); static const char* GetAgeName();
static PyObject* GetAgeInfo(); // returns pyAgeInfoStruct static PyObject* GetAgeInfo(); // returns pyAgeInfoStruct
static const char* GetPrevAgeName(); static plString GetPrevAgeName();
static PyObject* GetPrevAgeInfo(); static PyObject* GetPrevAgeInfo();
// current time in current age // current time in current age
static uint32_t GetAgeTime( void ); static uint32_t GetAgeTime( void );

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

@ -68,7 +68,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetAgeTime, "DEPRECIATED - use ptDniInf
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetPrevAgeName, "Returns filename of previous age visited") PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetPrevAgeName, "Returns filename of previous age visited")
{ {
return PyString_FromString(cyMisc::GetPrevAgeName()); return PyString_FromPlString(cyMisc::GetPrevAgeName());
} }
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetPrevAgeInfo, "Returns ptAgeInfoStruct of previous age visited") PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetPrevAgeInfo, "Returns ptAgeInfoStruct of previous age visited")

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

@ -336,7 +336,6 @@ bool plPythonFileMod::fAtConvertTime = false;
// //
plPythonFileMod::plPythonFileMod() plPythonFileMod::plPythonFileMod()
{ {
fPythonFile = nil;
fModule = nil; fModule = nil;
fLocalNotify= true; fLocalNotify= true;
fIsFirstTimeEval = true; fIsFirstTimeEval = true;
@ -401,12 +400,6 @@ plPythonFileMod::~plPythonFileMod()
fSelfKey = nil; fSelfKey = nil;
} }
// get rid of the python code
if ( fPythonFile )
{
delete [] fPythonFile;
fPythonFile = nil;
}
// then get rid of this module // then get rid of this module
// NOTE: fModule shouldn't be made in the plugin, only at runtime // NOTE: fModule shouldn't be made in the plugin, only at runtime
if ( !fModuleName.IsNull() && fModule ) if ( !fModuleName.IsNull() && fModule )
@ -438,14 +431,14 @@ bool plPythonFileMod::ILoadPythonCode()
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
// get code from file and execute in module // get code from file and execute in module
// see if the file exists first before trying to import it // see if the file exists first before trying to import it
plFileName pyfile = plFileName::Join(".", "python", plString::Format("%s.py", fPythonFile)); plFileName pyfile = plFileName::Join(".", "python", plString::Format("%s.py", fPythonFile.c_str()));
if (plFileInfo(pyfile).Exists()) if (plFileInfo(pyfile).Exists())
{ {
char fromLoad[256]; char fromLoad[256];
//sprintf(fromLoad,"from %s import *", fPythonFile); //sprintf(fromLoad,"from %s import *", fPythonFile.c_str());
// ok... we can't really use import because Python remembers too much where global variables came from // ok... we can't really use import because Python remembers too much where global variables came from
// ...and using execfile make it sure that globals are defined in this module and not in the imported module // ...and using execfile make it sure that globals are defined in this module and not in the imported module
sprintf(fromLoad,"execfile('.\\\\python\\\\%s.py')", fPythonFile); sprintf(fromLoad,"execfile('.\\\\python\\\\%s.py')", fPythonFile.c_str());
if ( PythonInterface::RunString( fromLoad, fModule) ) if ( PythonInterface::RunString( fromLoad, fModule) )
{ {
// we've loaded the code into our module // we've loaded the code into our module
@ -461,7 +454,7 @@ bool plPythonFileMod::ILoadPythonCode()
} }
DisplayPythonOutput(); DisplayPythonOutput();
char errMsg[256]; char errMsg[256];
sprintf(errMsg,"Python file %s.py had errors!!! Could not load.",fPythonFile); snprintf(errMsg, arrsize(errMsg), "Python file %s.py had errors!!! Could not load.", fPythonFile.c_str());
PythonInterface::WriteToLog(errMsg); PythonInterface::WriteToLog(errMsg);
hsAssert(0,errMsg); hsAssert(0,errMsg);
return false; return false;
@ -476,7 +469,7 @@ bool plPythonFileMod::ILoadPythonCode()
DisplayPythonOutput(); DisplayPythonOutput();
char errMsg[256]; char errMsg[256];
sprintf(errMsg,"Python file %s.py was not found.",fPythonFile); snprintf(errMsg, arrsize(errMsg), "Python file %s.py was not found.", fPythonFile.c_str());
PythonInterface::WriteToLog(errMsg); PythonInterface::WriteToLog(errMsg);
hsAssert(0,errMsg); hsAssert(0,errMsg);
return false; return false;
@ -503,7 +496,7 @@ void plPythonFileMod::AddTarget(plSceneObject* sobj)
if ( !fAtConvertTime ) // if this is just an Add that's during a convert, then don't do anymore if ( !fAtConvertTime ) // if this is just an Add that's during a convert, then don't do anymore
{ {
// was there a python file module with this? // was there a python file module with this?
if ( fPythonFile ) if ( !fPythonFile.IsEmpty() )
{ {
// has the module not been initialized yet // has the module not been initialized yet
if ( !fModule ) if ( !fModule )
@ -523,7 +516,7 @@ void plPythonFileMod::AddTarget(plSceneObject* sobj)
// set the name of the file (in the global dictionary of the module) // set the name of the file (in the global dictionary of the module)
PyObject* dict = PyModule_GetDict(fModule); PyObject* dict = PyModule_GetDict(fModule);
PyObject* pfilename = PyString_FromString(fPythonFile); PyObject* pfilename = PyString_FromPlString(fPythonFile);
PyDict_SetItemString(dict, "glue_name", pfilename); PyDict_SetItemString(dict, "glue_name", pfilename);
// next we need to: // next we need to:
// - create instance of class // - create instance of class
@ -542,7 +535,7 @@ void plPythonFileMod::AddTarget(plSceneObject* sobj)
{ {
// display any output (NOTE: this would be disabled in production) // display any output (NOTE: this would be disabled in production)
char errMsg[256]; char errMsg[256];
sprintf(errMsg,"Python file %s.py, instance not found.",fPythonFile); snprintf(errMsg, arrsize(errMsg), "Python file %s.py, instance not found.", fPythonFile.c_str());
PythonInterface::WriteToLog(errMsg); PythonInterface::WriteToLog(errMsg);
hsAssert(0, errMsg); hsAssert(0, errMsg);
return; // if we can't create the instance then there is nothing to do here return; // if we can't create the instance then there is nothing to do here
@ -2096,10 +2089,11 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
case plVaultNotifyMsg::kPublicAgeCreated: case plVaultNotifyMsg::kPublicAgeCreated:
case plVaultNotifyMsg::kPublicAgeRemoved: { case plVaultNotifyMsg::kPublicAgeRemoved: {
if (const char * ageName = vaultNotifyMsg->GetArgs()->GetString(plNetCommon::VaultTaskArgs::kAgeFilename)) { plString ageName = vaultNotifyMsg->GetArgs()->GetString(plNetCommon::VaultTaskArgs::kAgeFilename);
if (!ageName.IsEmpty()) {
Py_DECREF(ptuple); Py_DECREF(ptuple);
ptuple = PyTuple_New(1); ptuple = PyTuple_New(1);
PyTuple_SetItem(ptuple, 0, PyString_FromString(ageName)); PyTuple_SetItem(ptuple, 0, PyString_FromPlString(ageName));
} }
} }
break; break;
@ -2933,10 +2927,9 @@ void plPythonFileMod::DisplayPythonOutput()
// : Compile it into a Python code object // : Compile it into a Python code object
// : (This is usually called by the component) // : (This is usually called by the component)
// //
void plPythonFileMod::SetSourceFile(const char* filename) void plPythonFileMod::SetSourceFile(const plString& filename)
{ {
delete [] fPythonFile; fPythonFile = filename;
fPythonFile = hsStrcpy(filename);
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -2996,12 +2989,6 @@ void plPythonFileMod::Read(hsStream* stream, hsResMgr* mgr)
plMultiModifier::Read(stream, mgr); plMultiModifier::Read(stream, mgr);
// read in the compile python code (pyc) // read in the compile python code (pyc)
if ( fPythonFile )
{
// if we already have some code, get rid of it!
delete [] fPythonFile;
fPythonFile = nil;
}
fPythonFile = stream->ReadSafeString(); fPythonFile = stream->ReadSafeString();
// then read in the list of receivers that want to be notified // then read in the list of receivers that want to be notified

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

@ -73,7 +73,7 @@ protected:
plString IMakeModuleName(plSceneObject* sobj); plString IMakeModuleName(plSceneObject* sobj);
char* fPythonFile; plString fPythonFile;
plString fModuleName; plString fModuleName;
// the list of receivers that want to be notified // the list of receivers that want to be notified
@ -131,7 +131,7 @@ public:
plPythonSDLModifier* GetSDLMod() { return fSDLMod; } plPythonSDLModifier* GetSDLMod() { return fSDLMod; }
bool WasLocalNotify() { return fLocalNotify; } bool WasLocalNotify() { return fLocalNotify; }
plPipeline* GetPipeline() { return fPipe; } plPipeline* GetPipeline() { return fPipe; }
virtual void SetSourceFile(const char* filename); virtual void SetSourceFile(const plString& filename);
virtual int getPythonOutput(std::string* line); virtual int getPythonOutput(std::string* line);
virtual void ReportError(); virtual void ReportError();
virtual void DisplayPythonOutput(); virtual void DisplayPythonOutput();

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

@ -68,7 +68,7 @@ protected:
std::vector<hsStream*> fPackStreams; std::vector<hsStream*> fPackStreams;
bool fPackNotFound; // No pack file, don't keep trying bool fPackNotFound; // No pack file, don't keep trying
typedef std::map<std::string, plPackOffsetInfo> FileOffset; typedef std::map<plString, plPackOffsetInfo> FileOffset;
FileOffset fFileOffsets; FileOffset fFileOffsets;
plPythonPack(); plPythonPack();
@ -81,16 +81,16 @@ public:
bool Open(); bool Open();
void Close(); void Close();
PyObject* OpenPacked(const char *fileName); PyObject* OpenPacked(const plString& sfileName);
bool IsPackedFile(const char* fileName); bool IsPackedFile(const plString& fileName);
}; };
PyObject* PythonPack::OpenPythonPacked(const char* fileName) PyObject* PythonPack::OpenPythonPacked(const plString& fileName)
{ {
return plPythonPack::Instance().OpenPacked(fileName); return plPythonPack::Instance().OpenPacked(fileName);
} }
bool PythonPack::IsItPythonPacked(const char* fileName) bool PythonPack::IsItPythonPacked(const plString& fileName)
{ {
return plPythonPack::Instance().IsPackedFile(fileName); return plPythonPack::Instance().IsPackedFile(fileName);
} }
@ -148,9 +148,7 @@ bool plPythonPack::Open()
for (int i = 0; i < numFiles; i++) for (int i = 0; i < numFiles; i++)
{ {
// and pack the index into our own data structure // and pack the index into our own data structure
char* buf = fPackStream->ReadSafeString(); plString pythonName = fPackStream->ReadSafeString();
std::string pythonName = buf; // reading a "string" from a hsStream directly into a stl string causes memory loss
delete [] buf;
uint32_t offset = fPackStream->ReadLE32(); uint32_t offset = fPackStream->ReadLE32();
plPackOffsetInfo offsetInfo; plPackOffsetInfo offsetInfo;
@ -191,13 +189,12 @@ void plPythonPack::Close()
fFileOffsets.clear(); fFileOffsets.clear();
} }
PyObject* plPythonPack::OpenPacked(const char* fileName) PyObject* plPythonPack::OpenPacked(const plString& fileName)
{ {
if (!Open()) if (!Open())
return nil; return nil;
std::string pythonName = fileName; plString pythonName = fileName + ".py";
pythonName += ".py";
FileOffset::iterator it = fFileOffsets.find(pythonName); FileOffset::iterator it = fFileOffsets.find(pythonName);
if (it != fFileOffsets.end()) if (it != fFileOffsets.end())
@ -213,7 +210,7 @@ PyObject* plPythonPack::OpenPacked(const char* fileName)
char *buf = new char[size]; char *buf = new char[size];
uint32_t readSize = fPackStream->Read(size, buf); uint32_t readSize = fPackStream->Read(size, buf);
hsAssert(readSize <= size, plString::Format("Python PackFile %s: Incorrect amount of data, read %d instead of %d", hsAssert(readSize <= size, plString::Format("Python PackFile %s: Incorrect amount of data, read %d instead of %d",
fileName, readSize, size).c_str()); fileName.c_str(), readSize, size).c_str());
// let the python marshal make it back into a code object // let the python marshal make it back into a code object
PyObject *pythonCode = PyMarshal_ReadObjectFromString(buf, size); PyObject *pythonCode = PyMarshal_ReadObjectFromString(buf, size);
@ -227,13 +224,12 @@ PyObject* plPythonPack::OpenPacked(const char* fileName)
return nil; return nil;
} }
bool plPythonPack::IsPackedFile(const char* fileName) bool plPythonPack::IsPackedFile(const plString& fileName)
{ {
if (!Open()) if (!Open())
return nil; return nil;
std::string pythonName = fileName; plString pythonName = fileName + ".py";
pythonName += ".py";
FileOffset:: iterator it = fFileOffsets.find(pythonName); FileOffset:: iterator it = fFileOffsets.find(pythonName);
if (it != fFileOffsets.end()) if (it != fFileOffsets.end())

5
Sources/Plasma/FeatureLib/pfPython/plPythonPack.h

@ -43,11 +43,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plPythonPack_h_inc #define plPythonPack_h_inc
typedef struct _object PyObject; typedef struct _object PyObject;
class plString;
namespace PythonPack namespace PythonPack
{ {
PyObject* OpenPythonPacked(const char* fileName); PyObject* OpenPythonPacked(const plString& fileName);
bool IsItPythonPacked(const char* fileName); bool IsItPythonPacked(const plString& fileName);
} }
#endif // plPythonPack_h_inc #endif // plPythonPack_h_inc

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

@ -265,7 +265,9 @@ void plPythonSDLModifier::SetItemIdx(const plString& key, int idx, PyObject* val
const char* plPythonSDLModifier::GetSDLName() const const char* plPythonSDLModifier::GetSDLName() const
{ {
return fOwner->fPythonFile; // NOTE: Not changing GetSDLName since most implementations of this
// virtual function just return a stored string literal.
return fOwner->fPythonFile.c_str();
} }
void plPythonSDLModifier::SetFlags(const plString& name, bool sendImmediate, bool skipOwnershipCheck) void plPythonSDLModifier::SetFlags(const plString& name, bool sendImmediate, bool skipOwnershipCheck)
@ -566,7 +568,7 @@ PyObject* plPythonSDLModifier::ISDLVarToPython(plSimpleStateVariable* var)
return pyTuple; return pyTuple;
} }
bool plPythonSDLModifier::HasSDL(const char* pythonFile) bool plPythonSDLModifier::HasSDL(const plString& pythonFile)
{ {
return (plSDLMgr::GetInstance()->FindDescriptor(pythonFile, plSDL::kLatestVersion) != nil); return (plSDLMgr::GetInstance()->FindDescriptor(pythonFile, plSDL::kLatestVersion) != nil);
} }

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

@ -101,7 +101,7 @@ public:
virtual const char* GetSDLName() const; virtual const char* GetSDLName() const;
virtual void SetItemFromSDLVar(plSimpleStateVariable* var); virtual void SetItemFromSDLVar(plSimpleStateVariable* var);
static bool HasSDL(const char* pythonFile); static bool HasSDL(const plString& pythonFile);
// find the Age global SDL guy... if there is one // find the Age global SDL guy... if there is one
static const plPythonSDLModifier* FindAgeSDL(); static const plPythonSDLModifier* FindAgeSDL();
static plKey FindAgeSDLTarget(); static plKey FindAgeSDLTarget();

54
Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.cpp

@ -81,42 +81,42 @@ void pyAgeInfoStruct::CopyFromRef( const pyAgeInfoStructRef & other )
fAgeInfo.CopyFrom( other.GetAgeInfo() ); fAgeInfo.CopyFrom( other.GetAgeInfo() );
} }
const char * pyAgeInfoStruct::GetAgeFilename() const plString pyAgeInfoStruct::GetAgeFilename() const
{ {
return fAgeInfo.GetAgeFilename(); return fAgeInfo.GetAgeFilename();
} }
void pyAgeInfoStruct::SetAgeFilename( const char * v ) void pyAgeInfoStruct::SetAgeFilename( const plString & v )
{ {
fAgeInfo.SetAgeFilename( v ); fAgeInfo.SetAgeFilename( v );
} }
const char * pyAgeInfoStruct::GetAgeInstanceName() const plString pyAgeInfoStruct::GetAgeInstanceName() const
{ {
return fAgeInfo.GetAgeInstanceName(); return fAgeInfo.GetAgeInstanceName();
} }
void pyAgeInfoStruct::SetAgeInstanceName( const char * v ) void pyAgeInfoStruct::SetAgeInstanceName( const plString & v )
{ {
fAgeInfo.SetAgeInstanceName( v ); fAgeInfo.SetAgeInstanceName( v );
} }
const char * pyAgeInfoStruct::GetAgeUserDefinedName() const plString pyAgeInfoStruct::GetAgeUserDefinedName() const
{ {
return fAgeInfo.GetAgeUserDefinedName(); return fAgeInfo.GetAgeUserDefinedName();
} }
void pyAgeInfoStruct::SetAgeUserDefinedName( const char * v ) void pyAgeInfoStruct::SetAgeUserDefinedName( const plString & v )
{ {
fAgeInfo.SetAgeUserDefinedName( v ); fAgeInfo.SetAgeUserDefinedName( v );
} }
const char * pyAgeInfoStruct::GetAgeDescription() const plString pyAgeInfoStruct::GetAgeDescription() const
{ {
return fAgeInfo.GetAgeDescription(); return fAgeInfo.GetAgeDescription();
} }
void pyAgeInfoStruct::SetAgeDescription( const char * v ) void pyAgeInfoStruct::SetAgeDescription( const plString & v )
{ {
fAgeInfo.SetAgeDescription( v ); fAgeInfo.SetAgeDescription( v );
} }
@ -132,12 +132,12 @@ void pyAgeInfoStruct::SetAgeInstanceGuid( const char * guid )
if ( guid[0] == '@' ) if ( guid[0] == '@' )
{ {
// if it starts with an @ then do a meta kind of GUID // if it starts with an @ then do a meta kind of GUID
std::string curInst = fAgeInfo.GetAgeInstanceName(); plString curInst = fAgeInfo.GetAgeInstanceName();
std::string y = curInst + guid; plString y = curInst + guid;
plMD5Checksum hash; plMD5Checksum hash;
hash.Start(); hash.Start();
hash.AddTo(y.length(), (uint8_t*)y.c_str()); hash.AddTo(y.GetSize(), (uint8_t*)y.c_str());
hash.Finish(); hash.Finish();
const char* md5sum = hash.GetAsHexString(); const char* md5sum = hash.GetAsHexString();
@ -180,9 +180,9 @@ void pyAgeInfoStruct::SetAgeLanguage( int32_t v )
plString pyAgeInfoStruct::GetDisplayName() const plString pyAgeInfoStruct::GetDisplayName() const
{ {
const char* instance = GetAgeInstanceName(); plString instance = GetAgeInstanceName();
const char* user = GetAgeUserDefinedName(); plString user = GetAgeUserDefinedName();
bool namesEqual = (stricmp(user, instance) == 0); // Ae'gura Ae'gura bool namesEqual = (user.CompareI(instance) == 0); // Ae'gura Ae'gura
if (namesEqual) if (namesEqual)
return instance; return instance;
@ -190,9 +190,9 @@ plString pyAgeInfoStruct::GetDisplayName() const
{ {
int32_t seq = GetAgeSequenceNumber(); int32_t seq = GetAgeSequenceNumber();
if (seq > 0) if (seq > 0)
return plString::Format("%s (%d) %s", user, seq, instance); return plString::Format("%s (%d) %s", user.c_str(), seq, instance.c_str());
else else
return plString::Format("%s %s", user, instance); return plString::Format("%s %s", user.c_str(), instance.c_str());
} }
} }
@ -211,32 +211,32 @@ void pyAgeInfoStructRef::CopyFromRef( const pyAgeInfoStructRef & other )
fAgeInfo.CopyFrom( other.GetAgeInfo() ); fAgeInfo.CopyFrom( other.GetAgeInfo() );
} }
const char * pyAgeInfoStructRef::GetAgeFilename() const plString pyAgeInfoStructRef::GetAgeFilename() const
{ {
return fAgeInfo.GetAgeFilename(); return fAgeInfo.GetAgeFilename();
} }
void pyAgeInfoStructRef::SetAgeFilename( const char * v ) void pyAgeInfoStructRef::SetAgeFilename( const plString & v )
{ {
fAgeInfo.SetAgeFilename( v ); fAgeInfo.SetAgeFilename( v );
} }
const char * pyAgeInfoStructRef::GetAgeInstanceName() const plString pyAgeInfoStructRef::GetAgeInstanceName() const
{ {
return fAgeInfo.GetAgeInstanceName(); return fAgeInfo.GetAgeInstanceName();
} }
void pyAgeInfoStructRef::SetAgeInstanceName( const char * v ) void pyAgeInfoStructRef::SetAgeInstanceName( const plString & v )
{ {
fAgeInfo.SetAgeInstanceName( v ); fAgeInfo.SetAgeInstanceName( v );
} }
const char * pyAgeInfoStructRef::GetAgeUserDefinedName() const plString pyAgeInfoStructRef::GetAgeUserDefinedName() const
{ {
return fAgeInfo.GetAgeUserDefinedName(); return fAgeInfo.GetAgeUserDefinedName();
} }
void pyAgeInfoStructRef::SetAgeUserDefinedName( const char * v ) void pyAgeInfoStructRef::SetAgeUserDefinedName( const plString & v )
{ {
fAgeInfo.SetAgeUserDefinedName( v ); fAgeInfo.SetAgeUserDefinedName( v );
} }
@ -265,9 +265,9 @@ void pyAgeInfoStructRef::SetAgeSequenceNumber( int32_t v )
plString pyAgeInfoStructRef::GetDisplayName() const plString pyAgeInfoStructRef::GetDisplayName() const
{ {
const char* instance = GetAgeInstanceName(); plString instance = GetAgeInstanceName();
const char* user = GetAgeUserDefinedName(); plString user = GetAgeUserDefinedName();
bool namesEqual = (stricmp(user, instance) == 0); // Ae'gura Ae'gura bool namesEqual = (user.CompareI(instance) == 0); // Ae'gura Ae'gura
if (namesEqual) if (namesEqual)
return instance; return instance;
@ -275,8 +275,8 @@ plString pyAgeInfoStructRef::GetDisplayName() const
{ {
int32_t seq = GetAgeSequenceNumber(); int32_t seq = GetAgeSequenceNumber();
if (seq > 0) if (seq > 0)
return plString::Format("%s (%d) %s", user, seq, instance); return plString::Format("%s (%d) %s", user.c_str(), seq, instance.c_str());
else else
return plString::Format("%s %s", user, instance); return plString::Format("%s %s", user.c_str(), instance.c_str());
} }
} }

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

@ -87,14 +87,14 @@ public:
static void PythonModDef(); static void PythonModDef();
void CopyFrom( const pyAgeInfoStruct & other ); void CopyFrom( const pyAgeInfoStruct & other );
void CopyFromRef( const pyAgeInfoStructRef & other ); void CopyFromRef( const pyAgeInfoStructRef & other );
const char * GetAgeFilename() const; plString GetAgeFilename() const;
void SetAgeFilename( const char * v ); void SetAgeFilename( const plString & v );
const char * GetAgeInstanceName() const; plString GetAgeInstanceName() const;
void SetAgeInstanceName( const char * v ); void SetAgeInstanceName( const plString & v );
const char * GetAgeUserDefinedName() const; plString GetAgeUserDefinedName() const;
void SetAgeUserDefinedName( const char * v ); void SetAgeUserDefinedName( const plString & v );
const char * GetAgeDescription() const; plString GetAgeDescription() const;
void SetAgeDescription( const char * v ); void SetAgeDescription( const plString & v );
const char * GetAgeInstanceGuid() const; const char * GetAgeInstanceGuid() const;
void SetAgeInstanceGuid( const char * guid ); void SetAgeInstanceGuid( const char * guid );
int32_t GetAgeSequenceNumber() const; int32_t GetAgeSequenceNumber() const;
@ -132,12 +132,12 @@ public:
const plAgeInfoStruct * GetAgeInfo() const { return &fAgeInfo; } const plAgeInfoStruct * GetAgeInfo() const { return &fAgeInfo; }
void CopyFrom( const pyAgeInfoStruct & other ); void CopyFrom( const pyAgeInfoStruct & other );
void CopyFromRef( const pyAgeInfoStructRef & other ); void CopyFromRef( const pyAgeInfoStructRef & other );
const char * GetAgeFilename() const; plString GetAgeFilename() const;
void SetAgeFilename( const char * v ); void SetAgeFilename( const plString & v );
const char * GetAgeInstanceName() const; plString GetAgeInstanceName() const;
void SetAgeInstanceName( const char * v ); void SetAgeInstanceName( const plString & v );
const char * GetAgeUserDefinedName() const; plString GetAgeUserDefinedName() const;
void SetAgeUserDefinedName( const char * v ); void SetAgeUserDefinedName( const plString & v );
const char * GetAgeInstanceGuid() const; const char * GetAgeInstanceGuid() const;
void SetAgeInstanceGuid( const char * guid ); void SetAgeInstanceGuid( const char * guid );
int32_t GetAgeSequenceNumber() const; int32_t GetAgeSequenceNumber() const;

14
Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStructGlue.cpp

@ -115,7 +115,7 @@ PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, copyFrom, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeFilename) PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeFilename)
{ {
return PyString_FromString(self->fThis->GetAgeFilename()); return PyString_FromPlString(self->fThis->GetAgeFilename());
} }
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeFilename, args) PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeFilename, args)
@ -132,7 +132,7 @@ PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeFilename, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeInstanceName) PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeInstanceName)
{ {
return PyString_FromString(self->fThis->GetAgeInstanceName()); return PyString_FromPlString(self->fThis->GetAgeInstanceName());
} }
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeInstanceName, args) PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeInstanceName, args)
@ -149,7 +149,7 @@ PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeInstanceName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeUserDefinedName) PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeUserDefinedName)
{ {
return PyString_FromString(self->fThis->GetAgeUserDefinedName()); return PyString_FromPlString(self->fThis->GetAgeUserDefinedName());
} }
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeUserDefinedName, args) PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeUserDefinedName, args)
@ -166,7 +166,7 @@ PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeUserDefinedName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeDescription) PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeDescription)
{ {
return PyString_FromString(self->fThis->GetAgeDescription()); return PyString_FromPlString(self->fThis->GetAgeDescription());
} }
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeDescription, args) PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeDescription, args)
@ -325,7 +325,7 @@ PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, copyFrom, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeFilename) PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeFilename)
{ {
return PyString_FromString(self->fThis->GetAgeFilename()); return PyString_FromPlString(self->fThis->GetAgeFilename());
} }
PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeFilename, args) PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeFilename, args)
@ -342,7 +342,7 @@ PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeFilename, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeInstanceName) PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeInstanceName)
{ {
return PyString_FromString(self->fThis->GetAgeInstanceName()); return PyString_FromPlString(self->fThis->GetAgeInstanceName());
} }
PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeInstanceName, args) PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeInstanceName, args)
@ -359,7 +359,7 @@ PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeInstanceName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeUserDefinedName) PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeUserDefinedName)
{ {
return PyString_FromString(self->fThis->GetAgeUserDefinedName()); return PyString_FromPlString(self->fThis->GetAgeUserDefinedName());
} }
PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeUserDefinedName, args) PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeUserDefinedName, args)

97
Sources/Plasma/FeatureLib/pfPython/pyGUIControlListBox.cpp

@ -81,12 +81,12 @@ class pfColorListElement : public pfGUIListText
if ( string1 ) if ( string1 )
{ {
fString1 = hsStringToWString(string1); fString1 = hsStringToWString(string1);
fText = nil; fText = plString::Null;
} }
else else
{ {
fString1 = nil; fString1 = nil;
fText = L""; fText = "";
} }
fTextColor1 = color1; fTextColor1 = color1;
if (string2) if (string2)
@ -105,12 +105,12 @@ class pfColorListElement : public pfGUIListText
{ {
fString1 = new wchar_t[wcslen(string1)+1]; fString1 = new wchar_t[wcslen(string1)+1];
wcscpy(fString1,string1); wcscpy(fString1,string1);
fText = nil; fText = plString::Null;
} }
else else
{ {
fString1 = nil; fString1 = nil;
fText = L""; fText = "";
} }
fTextColor1 = color1; fTextColor1 = color1;
if (string2) if (string2)
@ -132,7 +132,7 @@ class pfColorListElement : public pfGUIListText
{ {
delete [] fString1; delete [] fString1;
fString1 = nil; fString1 = nil;
fText = nil; fText = plString::Null;
} }
if ( fString2 ) if ( fString2 )
delete [] fString2; delete [] fString2;
@ -287,14 +287,7 @@ class pfListTextInBox : public pfGUIListText
uint32_t fMinHeight; uint32_t fMinHeight;
public: public:
pfListTextInBox( const char *text, uint32_t min_width=0, uint32_t min_height=0 ) : pfGUIListText( text ) pfListTextInBox( const plString &text, uint32_t min_width=0, uint32_t min_height=0 ) : pfGUIListText( text )
{
fMinWidth = min_width;
fMinHeight = min_height;
fJustify = pfGUIListText::kCenter;
}
pfListTextInBox( const wchar_t *text, uint32_t min_width=0, uint32_t min_height=0 ) : pfGUIListText( text )
{ {
fMinWidth = min_width; fMinWidth = min_width;
fMinHeight = min_height; fMinHeight = min_height;
@ -510,14 +503,7 @@ uint16_t pyGUIControlListBox::GetNumElements( void )
return 0; return 0;
} }
void pyGUIControlListBox::SetElement( uint16_t idx, const char* text ) void pyGUIControlListBox::SetElement( uint16_t idx, const plString& text )
{
wchar_t *wText = hsStringToWString(text);
SetElementW(idx,wText);
delete [] wText;
}
void pyGUIControlListBox::SetElementW( uint16_t idx, std::wstring text )
{ {
if ( fGCkey ) if ( fGCkey )
{ {
@ -532,7 +518,7 @@ void pyGUIControlListBox::SetElementW( uint16_t idx, std::wstring text )
{ {
// if its a text element type then it should be safe to cast it to a pfGUIListText // if its a text element type then it should be safe to cast it to a pfGUIListText
pfGUIListText* letext = (pfGUIListText*)le; pfGUIListText* letext = (pfGUIListText*)le;
letext->SetText(text.c_str()); letext->SetText(text);
} }
} }
} }
@ -562,16 +548,7 @@ void pyGUIControlListBox::SetStringJustify( uint16_t idx, uint32_t justify)
} }
std::string pyGUIControlListBox::GetElement( uint16_t idx ) plString pyGUIControlListBox::GetElement( uint16_t idx )
{
std::wstring wRetVal = GetElementW(idx);
char *temp = hsWStringToString(wRetVal.c_str());
std::string retVal = temp;
delete [] temp;
return retVal;
}
std::wstring pyGUIControlListBox::GetElementW( uint16_t idx )
{ {
if ( fGCkey ) if ( fGCkey )
{ {
@ -596,18 +573,10 @@ std::wstring pyGUIControlListBox::GetElementW( uint16_t idx )
} }
} }
} }
return L""; return "";
}
int16_t pyGUIControlListBox::AddString( const char *string )
{
wchar_t *wString = hsStringToWString(string);
int16_t retVal = AddStringW(wString);
delete [] wString;
return retVal;
} }
int16_t pyGUIControlListBox::AddStringW( std::wstring string ) int16_t pyGUIControlListBox::AddString( const plString &string )
{ {
if ( fGCkey ) if ( fGCkey )
{ {
@ -615,7 +584,7 @@ int16_t pyGUIControlListBox::AddStringW( std::wstring string )
pfGUIListBoxMod* plbmod = pfGUIListBoxMod::ConvertNoRef(fGCkey->ObjectIsLoaded()); pfGUIListBoxMod* plbmod = pfGUIListBoxMod::ConvertNoRef(fGCkey->ObjectIsLoaded());
if ( plbmod ) if ( plbmod )
{ {
pfGUIListText *element = new pfGUIListText( string.c_str() ); pfGUIListText *element = new pfGUIListText(string);
if( fBuildRoots.GetCount() > 0 ) if( fBuildRoots.GetCount() > 0 )
fBuildRoots[ fBuildRoots.GetCount() - 1 ]->AddChild( element ); fBuildRoots[ fBuildRoots.GetCount() - 1 ]->AddChild( element );
return plbmod->AddElement( element ); return plbmod->AddElement( element );
@ -642,22 +611,14 @@ int16_t pyGUIControlListBox::AddImage( pyImage& image, bool respectAlpha )
} }
int16_t pyGUIControlListBox::FindString( const char *toCompareTo ) int16_t pyGUIControlListBox::FindString( const plString &toCompareTo )
{
wchar_t *wToCompareTo = hsStringToWString(toCompareTo);
int16_t retVal = FindStringW(wToCompareTo);
delete [] wToCompareTo;
return retVal;
}
int16_t pyGUIControlListBox::FindStringW( std::wstring toCompareTo )
{ {
if ( fGCkey ) if ( fGCkey )
{ {
// get the pointer to the modifier // get the pointer to the modifier
pfGUIListBoxMod* plbmod = pfGUIListBoxMod::ConvertNoRef(fGCkey->ObjectIsLoaded()); pfGUIListBoxMod* plbmod = pfGUIListBoxMod::ConvertNoRef(fGCkey->ObjectIsLoaded());
if ( plbmod ) if ( plbmod )
return plbmod->FindString(toCompareTo.c_str()); return plbmod->FindString(toCompareTo);
} }
return -1; return -1;
} }
@ -737,7 +698,7 @@ void pyGUIControlListBox::Add2TextWColorW( std::wstring str1, pyColor& textcolor
} }
} }
int16_t pyGUIControlListBox::AddStringInBox( const char *string, uint32_t min_width, uint32_t min_height ) int16_t pyGUIControlListBox::AddStringInBox( const plString &string, uint32_t min_width, uint32_t min_height )
{ {
if ( fGCkey ) if ( fGCkey )
{ {
@ -754,23 +715,6 @@ int16_t pyGUIControlListBox::AddStringInBox( const char *string, uint32_t min_wi
return -1; return -1;
} }
int16_t pyGUIControlListBox::AddStringInBoxW( std::wstring string, uint32_t min_width, uint32_t min_height )
{
if ( fGCkey )
{
// get the pointer to the modifier
pfGUIListBoxMod* plbmod = pfGUIListBoxMod::ConvertNoRef(fGCkey->ObjectIsLoaded());
if ( plbmod )
{
pfListTextInBox *element = new pfListTextInBox( string.c_str(), min_width, min_height );
if( fBuildRoots.GetCount() > 0 )
fBuildRoots[ fBuildRoots.GetCount() - 1 ]->AddChild( element );
return plbmod->AddElement( element );
}
}
return -1;
}
int16_t pyGUIControlListBox::AddImageInBox( pyImage& image, uint32_t x, uint32_t y, uint32_t width, uint32_t height, bool respectAlpha ) int16_t pyGUIControlListBox::AddImageInBox( pyImage& image, uint32_t x, uint32_t y, uint32_t width, uint32_t height, bool respectAlpha )
{ {
if ( fGCkey ) if ( fGCkey )
@ -927,14 +871,7 @@ void pyGUIControlListBox::Unclickable( void )
} }
} }
void pyGUIControlListBox::AddBranch( const char *name, bool initiallyOpen ) void pyGUIControlListBox::AddBranch( const plString &name, bool initiallyOpen )
{
wchar_t *wName = hsStringToWString(name);
AddBranchW(wName,initiallyOpen);
delete [] wName;
}
void pyGUIControlListBox::AddBranchW( std::wstring name, bool initiallyOpen )
{ {
if ( fGCkey ) if ( fGCkey )
{ {
@ -942,7 +879,7 @@ void pyGUIControlListBox::AddBranchW( std::wstring name, bool initiallyOpen )
pfGUIListBoxMod* plbmod = pfGUIListBoxMod::ConvertNoRef(fGCkey->ObjectIsLoaded()); pfGUIListBoxMod* plbmod = pfGUIListBoxMod::ConvertNoRef(fGCkey->ObjectIsLoaded());
if ( plbmod ) if ( plbmod )
{ {
pfGUIListTreeRoot *root = new pfGUIListTreeRoot( name.c_str() ); pfGUIListTreeRoot *root = new pfGUIListTreeRoot(name);
root->ShowChildren( initiallyOpen ); root->ShowChildren( initiallyOpen );
if( fBuildRoots.GetCount() > 0 ) if( fBuildRoots.GetCount() > 0 )

18
Sources/Plasma/FeatureLib/pfPython/pyGUIControlListBox.h

@ -88,15 +88,12 @@ public:
virtual int32_t GetSelection( void ); virtual int32_t GetSelection( void );
virtual void SetSelection( int32_t item ); virtual void SetSelection( int32_t item );
virtual void Refresh( void ); virtual void Refresh( void );
virtual void SetElement( uint16_t idx, const char* text ); virtual void SetElement( uint16_t idx, const plString& text );
virtual void SetElementW( uint16_t idx, std::wstring text );
virtual void RemoveElement( uint16_t index ); virtual void RemoveElement( uint16_t index );
virtual void ClearAllElements( void ); virtual void ClearAllElements( void );
virtual uint16_t GetNumElements( void ); virtual uint16_t GetNumElements( void );
virtual std::string GetElement( uint16_t idx ); virtual plString GetElement( uint16_t idx );
virtual std::wstring GetElementW( uint16_t idx ); virtual int16_t AddString( const plString &string );
virtual int16_t AddString( const char *string );
virtual int16_t AddStringW( std::wstring string );
virtual int16_t AddImage( pyImage& image, bool respectAlpha ); virtual int16_t AddImage( pyImage& image, bool respectAlpha );
virtual int16_t AddImageInBox( pyImage& image, uint32_t x, uint32_t y, uint32_t width, uint32_t height, bool respectAlpha ); virtual int16_t AddImageInBox( pyImage& image, uint32_t x, uint32_t y, uint32_t width, uint32_t height, bool respectAlpha );
virtual int16_t AddImageAndSwatchesInBox( pyImage& image, uint32_t x, uint32_t y, uint32_t width, uint32_t height, bool respectAlpha, virtual int16_t AddImageAndSwatchesInBox( pyImage& image, uint32_t x, uint32_t y, uint32_t width, uint32_t height, bool respectAlpha,
@ -104,16 +101,14 @@ public:
virtual void SetSwatchSize( uint32_t size ); virtual void SetSwatchSize( uint32_t size );
virtual void SetSwatchEdgeOffset( uint32_t size ); virtual void SetSwatchEdgeOffset( uint32_t size );
virtual void SetStringJustify( uint16_t idx, uint32_t justify); virtual void SetStringJustify( uint16_t idx, uint32_t justify);
virtual int16_t FindString( const char *toCompareTo ); virtual int16_t FindString( const plString &toCompareTo );
virtual int16_t FindStringW( std::wstring toCompareTo );
virtual int16_t AddTextWColor( const char *str, pyColor& textcolor, uint32_t inheritalpha); virtual int16_t AddTextWColor( const char *str, pyColor& textcolor, uint32_t inheritalpha);
virtual int16_t AddTextWColorW( std::wstring str, pyColor& textcolor, uint32_t inheritalpha); virtual int16_t AddTextWColorW( std::wstring str, pyColor& textcolor, uint32_t inheritalpha);
virtual int16_t AddTextWColorWSize( const char *str, pyColor& textcolor, uint32_t inheritalpha, int32_t fontsize); virtual int16_t AddTextWColorWSize( const char *str, pyColor& textcolor, uint32_t inheritalpha, int32_t fontsize);
virtual int16_t AddTextWColorWSizeW( std::wstring str, pyColor& textcolor, uint32_t inheritalpha, int32_t fontsize); virtual int16_t AddTextWColorWSizeW( std::wstring str, pyColor& textcolor, uint32_t inheritalpha, int32_t fontsize);
virtual void Add2TextWColor( const char *str1, pyColor& textcolor1,const char *str2, pyColor& textcolor2, uint32_t inheritalpha); virtual void Add2TextWColor( const char *str1, pyColor& textcolor1,const char *str2, pyColor& textcolor2, uint32_t inheritalpha);
virtual void Add2TextWColorW( std::wstring str1, pyColor& textcolor1, std::wstring str2, pyColor& textcolor2, uint32_t inheritalpha); virtual void Add2TextWColorW( std::wstring str1, pyColor& textcolor1, std::wstring str2, pyColor& textcolor2, uint32_t inheritalpha);
virtual int16_t AddStringInBox( const char *string, uint32_t min_width, uint32_t min_height ); virtual int16_t AddStringInBox( const plString &string, uint32_t min_width, uint32_t min_height );
virtual int16_t AddStringInBoxW( std::wstring string, uint32_t min_width, uint32_t min_height );
virtual void ScrollToBegin( void ); virtual void ScrollToBegin( void );
virtual void ScrollToEnd( void ); virtual void ScrollToEnd( void );
virtual void SetScrollPos( int32_t pos ); virtual void SetScrollPos( int32_t pos );
@ -125,8 +120,7 @@ public:
// To create tree branches, call AddBranch() with a name, then add elements as usual, including new sub-branches // To create tree branches, call AddBranch() with a name, then add elements as usual, including new sub-branches
// via additional AddBranch() calls. Call CloseBranch() to stop writing elements to that branch. // via additional AddBranch() calls. Call CloseBranch() to stop writing elements to that branch.
void AddBranch( const char *name, bool initiallyOpen ); void AddBranch( const plString &name, bool initiallyOpen );
void AddBranchW( std::wstring name, bool initiallyOpen );
void CloseBranch( void ); void CloseBranch( void );
void RemoveSelection( int32_t item ); void RemoveSelection( int32_t item );

13
Sources/Plasma/FeatureLib/pfPython/pyGUIControlListBoxGlue.cpp

@ -136,7 +136,7 @@ PYTHON_METHOD_DEFINITION(ptGUIControlListBox, setElementW, args)
PyErr_SetString(PyExc_TypeError, "setElementW expects an unsigned short and a unicode string"); PyErr_SetString(PyExc_TypeError, "setElementW expects an unsigned short and a unicode string");
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
self->fThis->SetElementW(index, text); self->fThis->SetElement(index, plString::FromWchar(text));
PYTHON_RETURN_NONE; PYTHON_RETURN_NONE;
} }
@ -148,7 +148,7 @@ PYTHON_METHOD_DEFINITION(ptGUIControlListBox, getElement, args)
PyErr_SetString(PyExc_TypeError, "getElement expects an unsigned short"); PyErr_SetString(PyExc_TypeError, "getElement expects an unsigned short");
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
return PyString_FromString(self->fThis->GetElement(index).c_str()); return PyString_FromPlString(self->fThis->GetElement(index));
} }
PYTHON_METHOD_DEFINITION(ptGUIControlListBox, getElementW, args) PYTHON_METHOD_DEFINITION(ptGUIControlListBox, getElementW, args)
@ -159,8 +159,7 @@ PYTHON_METHOD_DEFINITION(ptGUIControlListBox, getElementW, args)
PyErr_SetString(PyExc_TypeError, "getElementW expects an unsigned short"); PyErr_SetString(PyExc_TypeError, "getElementW expects an unsigned short");
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
std::wstring retVal = self->fThis->GetElementW(index); return PyUnicode_FromStringEx(self->fThis->GetElement(index));
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
} }
PYTHON_METHOD_DEFINITION(ptGUIControlListBox, setStringJustify, args) PYTHON_METHOD_DEFINITION(ptGUIControlListBox, setStringJustify, args)
@ -195,7 +194,7 @@ PYTHON_METHOD_DEFINITION(ptGUIControlListBox, addStringW, args)
PyErr_SetString(PyExc_TypeError, "addStringW expects a unicode string"); PyErr_SetString(PyExc_TypeError, "addStringW expects a unicode string");
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
return PyInt_FromLong(self->fThis->AddStringW(text)); return PyInt_FromLong(self->fThis->AddString(plString::FromWchar(text)));
} }
PYTHON_METHOD_DEFINITION(ptGUIControlListBox, findString, args) PYTHON_METHOD_DEFINITION(ptGUIControlListBox, findString, args)
@ -217,7 +216,7 @@ PYTHON_METHOD_DEFINITION(ptGUIControlListBox, findStringW, args)
PyErr_SetString(PyExc_TypeError, "findStringW expects a unicode string"); PyErr_SetString(PyExc_TypeError, "findStringW expects a unicode string");
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
return PyInt_FromLong(self->fThis->FindStringW(text)); return PyInt_FromLong(self->fThis->FindString(plString::FromWchar(text)));
} }
PYTHON_METHOD_DEFINITION(ptGUIControlListBox, addImage, args) PYTHON_METHOD_DEFINITION(ptGUIControlListBox, addImage, args)
@ -387,7 +386,7 @@ PYTHON_METHOD_DEFINITION(ptGUIControlListBox, addBranchW, args)
wchar_t* name = new wchar_t[strLen + 1]; wchar_t* name = new wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, name, strLen); PyUnicode_AsWideChar((PyUnicodeObject*)textObj, name, strLen);
name[strLen] = L'\0'; name[strLen] = L'\0';
self->fThis->AddBranchW(name, initiallyOpen != 0); self->fThis->AddBranch(plString::FromWchar(name), initiallyOpen != 0);
delete [] name; delete [] name;
PYTHON_RETURN_NONE; PYTHON_RETURN_NONE;
} }

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

@ -206,7 +206,7 @@ plKey pyKey::GetNotifyListItem(int32_t i)
// Set the dirty state on the PythonModifier // Set the dirty state on the PythonModifier
void pyKey::DirtySynchState(const char* SDLStateName, uint32_t sendFlags) void pyKey::DirtySynchState(const plString& SDLStateName, uint32_t sendFlags)
{ {
// see if we have a PythonFileModifier pointer // see if we have a PythonFileModifier pointer
if ( fPyFileMod ) if ( fPyFileMod )

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

@ -123,7 +123,7 @@ public:
// get a notify list item // get a notify list item
virtual plKey GetNotifyListItem(int32_t i); virtual plKey GetNotifyListItem(int32_t i);
// Set the dirty state on the PythonModifier // Set the dirty state on the PythonModifier
virtual void DirtySynchState(const char* SDLStateName, uint32_t sendFlags); virtual void DirtySynchState(const plString& SDLStateName, uint32_t sendFlags);
// register and unregister for control key envents // register and unregister for control key envents
virtual void EnableControlKeyEvents(); virtual void EnableControlKeyEvents();

16
Sources/Plasma/FeatureLib/pfPython/pyNetServerSessionInfo.h

@ -76,9 +76,9 @@ public:
plNetServerSessionInfo & ServerInfo() { return fInfo; } plNetServerSessionInfo & ServerInfo() { return fInfo; }
void SetServerName(const char * val) { fInfo.SetServerName( val ); } void SetServerName(const plString & val) { fInfo.SetServerName( val ); }
void SetServerType(uint8_t val) { fInfo.SetServerType( val ); } void SetServerType(uint8_t val) { fInfo.SetServerType( val ); }
void SetServerAddr(const char * val) { fInfo.SetServerAddr( val ); } void SetServerAddr(const plString & val) { fInfo.SetServerAddr( val ); }
void SetServerPort(uint16_t val) { fInfo.SetServerPort( val ); } void SetServerPort(uint16_t val) { fInfo.SetServerPort( val ); }
void SetServerGuid(const char * val) { fServerGuid.FromString( val ); fInfo.SetServerGuid( &fServerGuid ); } void SetServerGuid(const char * val) { fServerGuid.FromString( val ); fInfo.SetServerGuid( &fServerGuid ); }
bool HasServerName() const { return fInfo.HasServerName(); } bool HasServerName() const { return fInfo.HasServerName(); }
@ -86,9 +86,9 @@ public:
bool HasServerAddr() const { return fInfo.HasServerAddr(); } bool HasServerAddr() const { return fInfo.HasServerAddr(); }
bool HasServerPort() const { return fInfo.HasServerPort(); } bool HasServerPort() const { return fInfo.HasServerPort(); }
bool HasServerGuid() const { return fInfo.HasServerGuid(); } bool HasServerGuid() const { return fInfo.HasServerGuid(); }
const char * GetServerName() const { return fInfo.GetServerName(); } plString GetServerName() const { return fInfo.GetServerName(); }
uint8_t GetServerType() const { return fInfo.GetServerType(); } uint8_t GetServerType() const { return fInfo.GetServerType(); }
const char * GetServerAddr() const { return fInfo.GetServerAddr(); } plString GetServerAddr() const { return fInfo.GetServerAddr(); }
uint16_t GetServerPort() const { return fInfo.GetServerPort(); } uint16_t GetServerPort() const { return fInfo.GetServerPort(); }
const char * GetServerGuid() const { fServerGuid.CopyFrom( fInfo.GetServerGuid() ); return fServerGuid.AsString().c_str(); } const char * GetServerGuid() const { fServerGuid.CopyFrom( fInfo.GetServerGuid() ); return fServerGuid.AsString().c_str(); }
}; };
@ -116,9 +116,9 @@ public:
static void AddPlasmaClasses(PyObject *m); static void AddPlasmaClasses(PyObject *m);
void SetServerName(const char * val) { fInfo.SetServerName( val ); } void SetServerName(const plString & val) { fInfo.SetServerName( val ); }
void SetServerType(uint8_t val) { fInfo.SetServerType( val ); } void SetServerType(uint8_t val) { fInfo.SetServerType( val ); }
void SetServerAddr(const char * val) { fInfo.SetServerAddr( val ); } void SetServerAddr(const plString & val) { fInfo.SetServerAddr( val ); }
void SetServerPort(uint16_t val) { fInfo.SetServerPort( val ); } void SetServerPort(uint16_t val) { fInfo.SetServerPort( val ); }
void SetServerGuid(const char * val) { fServerGuid.FromString( val ); fInfo.SetServerGuid( &fServerGuid ); } void SetServerGuid(const char * val) { fServerGuid.FromString( val ); fInfo.SetServerGuid( &fServerGuid ); }
bool HasServerName() const { return fInfo.HasServerName(); } bool HasServerName() const { return fInfo.HasServerName(); }
@ -126,9 +126,9 @@ public:
bool HasServerAddr() const { return fInfo.HasServerAddr(); } bool HasServerAddr() const { return fInfo.HasServerAddr(); }
bool HasServerPort() const { return fInfo.HasServerPort(); } bool HasServerPort() const { return fInfo.HasServerPort(); }
bool HasServerGuid() const { return fInfo.HasServerGuid(); } bool HasServerGuid() const { return fInfo.HasServerGuid(); }
const char * GetServerName() const { return fInfo.GetServerName(); } plString GetServerName() const { return fInfo.GetServerName(); }
uint8_t GetServerType() const { return fInfo.GetServerType(); } uint8_t GetServerType() const { return fInfo.GetServerType(); }
const char * GetServerAddr() const { return fInfo.GetServerAddr(); } plString GetServerAddr() const { return fInfo.GetServerAddr(); }
uint16_t GetServerPort() const { return fInfo.GetServerPort(); } uint16_t GetServerPort() const { return fInfo.GetServerPort(); }
const char * GetServerGuid() const { fServerGuid.CopyFrom( fInfo.GetServerGuid() ); return fServerGuid.AsString().c_str(); } const char * GetServerGuid() const { fServerGuid.CopyFrom( fInfo.GetServerGuid() ); return fServerGuid.AsString().c_str(); }
}; };

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

@ -143,7 +143,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfo, hasServerGuid)
PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfo, getServerName) PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfo, getServerName)
{ {
return PyString_FromString(self->fThis->GetServerName()); return PyString_FromPlString(self->fThis->GetServerName());
} }
PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfo, getServerType) PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfo, getServerType)
@ -153,7 +153,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfo, getServerType)
PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfo, getServerAddr) PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfo, getServerAddr)
{ {
return PyString_FromString(self->fThis->GetServerAddr()); return PyString_FromPlString(self->fThis->GetServerAddr());
} }
PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfo, getServerPort) PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfo, getServerPort)
@ -306,7 +306,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfoRef, hasServerGuid)
PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfoRef, getServerName) PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfoRef, getServerName)
{ {
return PyString_FromString(self->fThis->GetServerName()); return PyString_FromPlString(self->fThis->GetServerName());
} }
PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfoRef, getServerType) PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfoRef, getServerType)
@ -316,7 +316,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfoRef, getServerType)
PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfoRef, getServerAddr) PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfoRef, getServerAddr)
{ {
return PyString_FromString(self->fThis->GetServerAddr()); return PyString_FromPlString(self->fThis->GetServerAddr());
} }
PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfoRef, getServerPort) PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfoRef, getServerPort)

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

@ -671,18 +671,18 @@ void pyVault::CreateNeighborhood()
if (nc->GetPlayerName().CharAt(nameLen - 1) == 's' || nc->GetPlayerName().CharAt(nameLen - 1) == 'S') if (nc->GetPlayerName().CharAt(nameLen - 1) == 's' || nc->GetPlayerName().CharAt(nameLen - 1) == 'S')
{ {
title = plString::Format( "%s'", nc->GetPlayerName().c_str() ); title = plString::Format( "%s'", nc->GetPlayerName().c_str() );
desc = plString::Format( "%s' %s", nc->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() ); desc = plString::Format( "%s' %s", nc->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName().c_str() );
} }
else else
{ {
title = plString::Format( "%s's", nc->GetPlayerName().c_str() ); title = plString::Format( "%s's", nc->GetPlayerName().c_str() );
desc = plString::Format( "%s's %s", nc->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() ); desc = plString::Format( "%s's %s", nc->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName().c_str() );
} }
plUUID guid = plUUID::Generate(); plUUID guid = plUUID::Generate();
link.GetAgeInfo()->SetAgeInstanceGuid(&guid); link.GetAgeInfo()->SetAgeInstanceGuid(&guid);
link.GetAgeInfo()->SetAgeUserDefinedName( title.c_str() ); link.GetAgeInfo()->SetAgeUserDefinedName(title);
link.GetAgeInfo()->SetAgeDescription( desc.c_str() ); link.GetAgeInfo()->SetAgeDescription(desc);
VaultRegisterOwnedAge(&link); VaultRegisterOwnedAge(&link);
} }

2
Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp

@ -169,7 +169,7 @@ void plUoid::Read(hsStream* s)
s->LogReadLE(&fClassType, "ClassType"); s->LogReadLE(&fClassType, "ClassType");
s->LogReadLE(&fObjectID, "ObjectID"); s->LogReadLE(&fObjectID, "ObjectID");
s->LogSubStreamPushDesc("ObjectName"); s->LogSubStreamPushDesc("ObjectName");
fObjectName = s->LogReadSafeString_TEMP(); fObjectName = s->LogReadSafeString();
// conditional cloneIDs read // conditional cloneIDs read
if (contents & kHasCloneIDs) if (contents & kHasCloneIDs)

4
Sources/Plasma/NucleusLib/pnMessage/plNotifyMsg.cpp

@ -1351,7 +1351,7 @@ void proVariableEventData::IWriteNumber(hsStream * stream) {
void proVariableEventData::IRead(hsStream* stream, hsResMgr* mgr) void proVariableEventData::IRead(hsStream* stream, hsResMgr* mgr)
{ {
fName = stream->ReadSafeString_TEMP(); fName = stream->ReadSafeString();
fDataType = stream->ReadLE32(); fDataType = stream->ReadLE32();
IReadNumber(stream); IReadNumber(stream);
fKey = mgr->ReadKey(stream); fKey = mgr->ReadKey(stream);
@ -1379,7 +1379,7 @@ void proVariableEventData::IReadVersion(hsStream* s, hsResMgr* mgr)
contentFlags.Read(s); contentFlags.Read(s);
if (contentFlags.IsBitSet(kProVariableName)) if (contentFlags.IsBitSet(kProVariableName))
fName = s->ReadSafeString_TEMP(); fName = s->ReadSafeString();
if (contentFlags.IsBitSet(kProVariableDataType)) if (contentFlags.IsBitSet(kProVariableDataType))
fDataType = s->ReadLE32(); fDataType = s->ReadLE32();
if (contentFlags.IsBitSet(kProVariableNumber)) if (contentFlags.IsBitSet(kProVariableNumber))

114
Sources/Plasma/NucleusLib/pnNetCommon/plGenericVar.cpp

@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "hsStream.h" #include "hsStream.h"
#include "plGenericVar.h" #include "plGenericVar.h"
#include "hsMemory.h"
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
// plGenericType // plGenericType
@ -55,116 +54,93 @@ void plGenericType::Reset()
void plGenericType::CopyFrom(const plGenericType& c) void plGenericType::CopyFrom(const plGenericType& c)
{ {
IDeallocString();
fType = c.fType; fType = c.fType;
if (fType==kString || fType==kAny) if (fType==kString || fType==kAny)
{ {
fS=hsStrcpy(c.fS); fS = c.fS;
} }
else else
{ {
HSMemory::BlockMove((void*)&c.fI, (void*)&fI, 4); memmove(&fD, &c.fD, sizeof(double));
} }
} }
//// Conversion Functions //////////////////////////////////////////////////// //// Conversion Functions ////////////////////////////////////////////////////
const int32_t & plGenericType::IToInt( void ) const int32_t plGenericType::IToInt( void ) const
{ {
hsAssert( fType == kInt || fType == kAny, "Trying to use a non-int parameter as an int!" ); hsAssert( fType == kInt || fType == kAny, "Trying to use a non-int parameter as an int!" );
static int32_t i;
if( fType == kAny ) if( fType == kAny )
{ {
hsAssert( fS != nil, "Weird parameter during conversion" ); return fS.ToInt();
i = atoi( fS );
return i;
} }
return fI; return fI;
} }
const uint32_t & plGenericType::IToUInt( void ) const uint32_t plGenericType::IToUInt( void ) const
{ {
hsAssert( fType == kUInt || fType == kAny, "Trying to use a non-int parameter as an int!" ); hsAssert( fType == kUInt || fType == kAny, "Trying to use a non-int parameter as an int!" );
static uint32_t i;
if( fType == kAny ) if( fType == kAny )
{ {
hsAssert( fS != nil, "Weird parameter during conversion" ); return fS.ToUInt();
i = atoi( fS );
return i;
} }
return fU; return fU;
} }
const double & plGenericType::IToDouble( void ) const double plGenericType::IToDouble( void ) const
{ {
hsAssert( fType == kDouble || fType == kAny, "Trying to use a non-float parameter as a Double!" ); hsAssert( fType == kDouble || fType == kAny, "Trying to use a non-float parameter as a Double!" );
static double d;
if( fType == kAny ) if( fType == kAny )
{ {
hsAssert( fS != nil, "Weird parameter during conversion" ); return fS.ToDouble();
d = atof( fS );
return d;
} }
return fD; return fD;
} }
const float & plGenericType::IToFloat( void ) const float plGenericType::IToFloat( void ) const
{ {
hsAssert( fType == kFloat || fType == kAny, "Trying to use a non-float parameter as a float!" ); hsAssert( fType == kFloat || fType == kAny, "Trying to use a non-float parameter as a float!" );
static float f;
if( fType == kAny ) if( fType == kAny )
{ {
hsAssert( fS != nil, "Weird parameter during conversion" ); return fS.ToFloat();
f = (float)atof( fS );
return f;
} }
return fF; return fF;
} }
const bool & plGenericType::IToBool( void ) const bool plGenericType::IToBool( void ) const
{ {
hsAssert( fType == kBool || fType == kAny, "Trying to use a non-bool parameter as a bool!" ); hsAssert( fType == kBool || fType == kAny, "Trying to use a non-bool parameter as a bool!" );
static bool b;
if( fType == kAny ) if( fType == kAny )
{ {
hsAssert( fS != nil, "Weird parameter during conversion" ); return (fS.ToInt() > 0 || fS.CompareI("true") == 0);
if( atoi( fS ) > 0 || stricmp( fS, "true" ) == 0 )
b = true;
else
b = false;
return b;
} }
return fB; return fB;
} }
const plGenericType::CharPtr & plGenericType::IToString( void ) const plString plGenericType::IToString( void ) const
{ {
hsAssert( fType == kString || fType == kAny, "Trying to use a non-string parameter as a string!" ); hsAssert( fType == kString || fType == kAny, "Trying to use a non-string parameter as a string!" );
return fS; return fS;
} }
const char & plGenericType::IToChar( void ) const char plGenericType::IToChar( void ) const
{ {
hsAssert( fType == kChar || fType == kAny, "Trying to use a non-char parameter as a char!" ); hsAssert( fType == kChar || fType == kAny, "Trying to use a non-char parameter as a char!" );
static char c;
if( fType == kAny ) if( fType == kAny )
{ {
hsAssert( fS != nil, "Weird parameter during conversion" ); return fS.CharAt(0);
c = fS[ 0 ];
return c;
} }
return fC; return fC;
@ -172,7 +148,6 @@ const char & plGenericType::IToChar( void ) const
void plGenericType::Read(hsStream* s) void plGenericType::Read(hsStream* s)
{ {
IDeallocString();
s->ReadLE(&fType); s->ReadLE(&fType);
switch ( fType ) switch ( fType )
@ -244,7 +219,6 @@ void plGenericType::Write(hsStream* s)
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
void plGenericVar::Read(hsStream* s) void plGenericVar::Read(hsStream* s)
{ {
delete [] fName;
fName = s->ReadSafeString(); fName = s->ReadSafeString();
fValue.Read(s); fValue.Read(s);
} }
@ -258,64 +232,6 @@ void plGenericVar::Write(hsStream* s)
////////////////////////////////// //////////////////////////////////
void plGenericType::SetVar(Types t, unsigned int size, void* val)
{
fType = t;
switch (t)
{
case kInt :
{
hsAssert(size <= sizeof(fI), "plGenericType::SetVar size too large for int");
memcpy(&fI, val, size);
break;
}
case kUInt :
{
hsAssert(size <= sizeof(fU), "plGenericType::SetVar size too large for unsigned int");
memcpy(&fU, val, size);
break;
}
case kFloat :
{
hsAssert(size <= sizeof(fF), "plGenericType::SetVar size too large for float");
memcpy(&fF, val, size);
break;
}
case kDouble :
{
hsAssert(size <= sizeof(fD), "plGenericType::SetVar size too large for double");
memcpy(&fD, val, size);
break;
}
case kBool :
{
hsAssert(size <= sizeof(fB), "plGenericType::SetVar size too large for bool");
memcpy(&fB, val, size);
break;
}
case kChar :
{
hsAssert(size <= sizeof(fC), "plGenericType::SetVar size too large for char");
memcpy(&fC, val, size);
break;
}
case kString :
{
delete [] fS;
fS = new char[size+1];
memcpy(fS,val,size);
fS[size] = 0;
break;
}
case kNone :
break;
default:
hsAssert(false,"plGenericType::SetVar unknown type");
}
}
plString plGenericType::GetAsString() const plString plGenericType::GetAsString() const
{ {
switch (fType) switch (fType)

65
Sources/Plasma/NucleusLib/pnNetCommon/plGenericVar.h

@ -53,21 +53,18 @@ class hsStream;
// //
class plGenericType class plGenericType
{ {
public:
typedef char* CharPtr;
protected: protected:
union union
{ {
int32_t fI; int32_t fI;
uint32_t fU; uint32_t fU;
float fF; float fF;
double fD; double fD;
bool fB; bool fB;
CharPtr fS;
char fC; char fC;
}; };
plString fS;
public: public:
enum Types enum Types
@ -86,20 +83,19 @@ public:
protected: protected:
uint8_t fType; uint8_t fType;
const int32_t &IToInt( void ) const; int32_t IToInt( void ) const;
const uint32_t &IToUInt( void ) const; uint32_t IToUInt( void ) const;
const float &IToFloat( void ) const; float IToFloat( void ) const;
const double &IToDouble( void ) const; double IToDouble( void ) const;
const bool &IToBool( void ) const; bool IToBool( void ) const;
const CharPtr &IToString( void ) const; plString IToString( void ) const;
const char &IToChar( void ) const; char IToChar( void ) const;
void IDeallocString() { if (fType==kString || fType==kAny) {delete [] fS; fS=nil;} }
public: public:
plGenericType() : fType(kNone) { Reset(); } plGenericType() : fType(kNone) { Reset(); }
plGenericType(const plGenericType& c) { CopyFrom(c); } plGenericType(const plGenericType& c) { CopyFrom(c); }
virtual ~plGenericType() { IDeallocString(); } virtual ~plGenericType() { }
plGenericType& operator=(const plGenericType& c) { CopyFrom(c); return *this; } plGenericType& operator=(const plGenericType& c) { CopyFrom(c); return *this; }
@ -110,34 +106,33 @@ public:
operator double() const { return IToDouble(); } operator double() const { return IToDouble(); }
operator float() const { return IToFloat(); } operator float() const { return IToFloat(); }
operator bool() const { return IToBool(); } operator bool() const { return IToBool(); }
operator const CharPtr() const { return IToString(); } operator plString() const { return IToString(); }
operator char() const { return IToChar(); } operator char() const { return IToChar(); }
void SetType(Types t) { fType=t; } void SetType(Types t) { fType=t; }
uint8_t GetType( void ) const { return fType; } uint8_t GetType( void ) const { return fType; }
plString GetAsString() const; plString GetAsString() const;
// implicit set // implicit set
void Set( int32_t i ) { fI = i; fType = kInt; } void Set( int32_t i ) { fI = i; fType = kInt; }
void Set( uint32_t i ) { fU = i; fType = kUInt; } void Set( uint32_t i ) { fU = i; fType = kUInt; }
void Set( float f ) { fF = f; fType = kFloat; } void Set( float f ) { fF = f; fType = kFloat; }
void Set( double d ) { fD = d; fType = kDouble; } void Set( double d ) { fD = d; fType = kDouble; }
void Set( bool b ) { fB = b; fType = kBool; } void Set( bool b ) { fB = b; fType = kBool; }
void Set( CharPtr s ) { IDeallocString(); fS = hsStrcpy(s); fType = kString; } void Set( const plString& s ) { fS = s; fType = kString; }
void Set( char c ) { fC = c; fType = kChar; } void Set( char c ) { fC = c; fType = kChar; }
// explicit set // explicit set
void SetInt( int32_t i ) { fI = i; fType = kInt; } void SetInt( int32_t i ) { fI = i; fType = kInt; }
void SetUInt( uint32_t i ) { fU = i; fType = kUInt; } void SetUInt( uint32_t i ) { fU = i; fType = kUInt; }
void SetFloat( float f ) { fF = f; fType = kFloat; } void SetFloat( float f ) { fF = f; fType = kFloat; }
void SetDouble( double d ) { fD = d; fType = kDouble; } void SetDouble( double d ) { fD = d; fType = kDouble; }
void SetBool( bool b ) { fB = b; fType = kBool; } void SetBool( bool b ) { fB = b; fType = kBool; }
void SetString( CharPtr s ) { IDeallocString(); fS = hsStrcpy(s); fType = kString; } void SetString( const plString& s ) { fS = s; fType = kString; }
void SetChar( char c ) { fC = c; fType = kChar; } void SetChar( char c ) { fC = c; fType = kChar; }
void SetAny( CharPtr s ) { IDeallocString(); fS = hsStrcpy(s); fType = kAny; } void SetAny( const plString& s ) { fS = s; fType = kAny; }
void SetNone( void ) { fType = kNone; } void SetNone( void ) { fType = kNone; }
void SetVar(Types t, unsigned int size, void* val);
virtual void Read(hsStream* s); virtual void Read(hsStream* s);
virtual void Write(hsStream* s); virtual void Write(hsStream* s);
@ -150,17 +145,17 @@ class plGenericVar
{ {
protected: protected:
plGenericType fValue; plGenericType fValue;
char* fName; plString fName;
public: public:
plGenericVar(const plGenericVar &c) : fName(nil) { CopyFrom(c); } plGenericVar(const plGenericVar &c) { CopyFrom(c); }
plGenericVar(const char* name=nil) : fName(nil) { SetName(name); } plGenericVar(const plString& name="") : fName(name) { }
virtual ~plGenericVar() { delete [] fName; } virtual ~plGenericVar() { }
virtual void Reset() { Value().Reset(); } // reset runtime state, not inherent state virtual void Reset() { Value().Reset(); } // reset runtime state, not inherent state
plGenericVar& operator=(const plGenericVar &c) { CopyFrom(c); return *this; } plGenericVar& operator=(const plGenericVar &c) { CopyFrom(c); return *this; }
void CopyFrom(const plGenericVar &c) { delete [] fName; fName=hsStrcpy(c.GetName()); fValue=c.Value(); } void CopyFrom(const plGenericVar &c) { fName=c.GetName(); fValue=c.Value(); }
const char* GetName() const { return fName; } plString GetName() const { return fName; }
void SetName(const char* n) { delete [] fName; fName = hsStrcpy(n); } void SetName(const plString& n) { fName = n; }
plGenericType& Value() { return fValue; } plGenericType& Value() { return fValue; }
const plGenericType& Value() const { return fValue; } const plGenericType& Value() const { return fValue; }
@ -186,7 +181,7 @@ public:
operator float() const { return (float)fValue; } operator float() const { return (float)fValue; }
operator double() const { return (double)fValue; } operator double() const { return (double)fValue; }
operator bool() const { return (bool)fValue; } operator bool() const { return (bool)fValue; }
operator const char *() const { return (const char *)fValue; } operator plString() const { return (plString)fValue; }
operator char() const { return (char)fValue; } operator char() const { return (char)fValue; }
}; };

52
Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.cpp

@ -190,7 +190,7 @@ void plSynchedObject::RegisterSynchedValueFriend(plSynchedValueBase* v)
// //
// send sdl state msg immediately // send sdl state msg immediately
// //
void plSynchedObject::SendSDLStateMsg(const char* SDLStateName, uint32_t synchFlags /*SendSDLStateFlags*/) void plSynchedObject::SendSDLStateMsg(const plString& SDLStateName, uint32_t synchFlags /*SendSDLStateFlags*/)
{ {
plSDLModifierMsg* sdlMsg = new plSDLModifierMsg(SDLStateName, plSDLModifierMsg* sdlMsg = new plSDLModifierMsg(SDLStateName,
(synchFlags & kBCastToClients) ? plSDLModifierMsg::kSendToServerAndClients : plSDLModifierMsg::kSendToServer /* action */); (synchFlags & kBCastToClients) ? plSDLModifierMsg::kSendToServerAndClients : plSDLModifierMsg::kSendToServer /* action */);
@ -203,14 +203,14 @@ void plSynchedObject::SendSDLStateMsg(const char* SDLStateName, uint32_t synchFl
// Tell an object to send an sdl state update. // Tell an object to send an sdl state update.
// The request will get queued (returns true) // The request will get queued (returns true)
// //
bool plSynchedObject::DirtySynchState(const char* SDLStateName, uint32_t synchFlags /*SendSDLStateFlags*/) bool plSynchedObject::DirtySynchState(const plString& SDLStateName, uint32_t synchFlags /*SendSDLStateFlags*/)
{ {
if (!IOKToDirty(SDLStateName)) if (!IOKToDirty(SDLStateName))
{ {
#if 0 #if 0
if (plNetClientApp::GetInstance()) if (plNetClientApp::GetInstance())
plNetClientApp::GetInstance()->DebugMsg("NotOKToDirty - Not queueing SDL state, obj %s, sdl %s", plNetClientApp::GetInstance()->DebugMsg("NotOKToDirty - Not queueing SDL state, obj %s, sdl %s",
GetKeyName(), SDLStateName); GetKeyName().c_str(), SDLStateName.c_str());
#endif #endif
return false; return false;
} }
@ -220,7 +220,7 @@ bool plSynchedObject::DirtySynchState(const char* SDLStateName, uint32_t synchFl
#if 0 #if 0
if (plNetClientApp::GetInstance()) if (plNetClientApp::GetInstance())
plNetClientApp::GetInstance()->DebugMsg("LocalOnly Object - Not queueing SDL msg, obj %s, sdl %s", plNetClientApp::GetInstance()->DebugMsg("LocalOnly Object - Not queueing SDL msg, obj %s, sdl %s",
GetKeyName(), SDLStateName); GetKeyName().c_str(), SDLStateName.c_str());
#endif #endif
return false; return false;
} }
@ -236,7 +236,7 @@ bool plSynchedObject::DirtySynchState(const char* SDLStateName, uint32_t synchFl
{ {
if (plNetClientApp::GetInstance()) if (plNetClientApp::GetInstance())
plNetClientApp::GetInstance()->DebugMsg("Queueing SDL state with 'maybe' ownership, obj %s, sdl %s", plNetClientApp::GetInstance()->DebugMsg("Queueing SDL state with 'maybe' ownership, obj %s, sdl %s",
GetKeyName().c_str(), SDLStateName); GetKeyName().c_str(), SDLStateName.c_str());
} }
} }
@ -256,13 +256,13 @@ bool plSynchedObject::DirtySynchState(const char* SDLStateName, uint32_t synchFl
// add state defn if not already there. // add state defn if not already there.
// if there adjust flags if necessary // if there adjust flags if necessary
// //
void plSynchedObject::IAddDirtyState(plKey objKey, const char* sdlName, uint32_t sendFlags) void plSynchedObject::IAddDirtyState(plKey objKey, const plString& sdlName, uint32_t sendFlags)
{ {
bool found=false; bool found=false;
std::vector<StateDefn>::iterator it=fDirtyStates.begin(); std::vector<StateDefn>::iterator it=fDirtyStates.begin();
for( ; it != fDirtyStates.end(); it++) for( ; it != fDirtyStates.end(); it++)
{ {
if ((*it).fObjKey==objKey && !stricmp((*it).fSDLName.c_str(), sdlName)) if (it->fObjKey == objKey && it->fSDLName.CompareI(sdlName) == 0)
{ {
if (sendFlags & kForceFullSend) if (sendFlags & kForceFullSend)
(*it).fSendFlags |= kForceFullSend; (*it).fSendFlags |= kForceFullSend;
@ -282,7 +282,7 @@ void plSynchedObject::IAddDirtyState(plKey objKey, const char* sdlName, uint32_t
{ {
#if 0 #if 0
plNetClientApp::GetInstance()->DebugMsg("Not queueing diplicate request for SDL state, obj %s, sdl %s", plNetClientApp::GetInstance()->DebugMsg("Not queueing diplicate request for SDL state, obj %s, sdl %s",
objKey->GetName(), sdlName); objKey->GetName().c_str(), sdlName.c_str());
#endif #endif
} }
} }
@ -290,12 +290,12 @@ void plSynchedObject::IAddDirtyState(plKey objKey, const char* sdlName, uint32_t
// //
// STATIC // STATIC
// //
void plSynchedObject::IRemoveDirtyState(plKey objKey, const char* sdlName) void plSynchedObject::IRemoveDirtyState(plKey objKey, const plString& sdlName)
{ {
std::vector<StateDefn>::iterator it=fDirtyStates.begin(); std::vector<StateDefn>::iterator it=fDirtyStates.begin();
for( ; it != fDirtyStates.end(); it++) for( ; it != fDirtyStates.end(); it++)
{ {
if ((*it).fObjKey==objKey && !stricmp((*it).fSDLName.c_str(), sdlName)) if (it->fObjKey == objKey && it->fSDLName.CompareI(sdlName) == 0)
{ {
fDirtyStates.erase(it); fDirtyStates.erase(it);
break; break;
@ -342,7 +342,7 @@ void plSynchedObject::Read(hsStream* stream, hsResMgr* mgr)
int i; int i;
for(i=0;i<num;i++) for(i=0;i<num;i++)
{ {
std::string s; plString s;
plMsgStdStringHelper::Peek(s, stream); plMsgStdStringHelper::Peek(s, stream);
fSDLExcludeList.push_back(s); fSDLExcludeList.push_back(s);
} }
@ -356,7 +356,7 @@ void plSynchedObject::Read(hsStream* stream, hsResMgr* mgr)
int i; int i;
for(i=0;i<num;i++) for(i=0;i<num;i++)
{ {
std::string s; plString s;
plMsgStdStringHelper::Peek(s, stream); plMsgStdStringHelper::Peek(s, stream);
fSDLVolatileList.push_back(s); fSDLVolatileList.push_back(s);
} }
@ -449,7 +449,7 @@ void plSynchedObject::CallDirtyNotifiers() {}
// //
// return true if it's ok to dirty this object // return true if it's ok to dirty this object
// //
bool plSynchedObject::IOKToDirty(const char* SDLStateName) const bool plSynchedObject::IOKToDirty(const plString& SDLStateName) const
{ {
// is synching disabled? // is synching disabled?
bool synchDisabled = (GetSynchDisabled()!=0); bool synchDisabled = (GetSynchDisabled()!=0);
@ -471,7 +471,7 @@ bool plSynchedObject::IOKToDirty(const char* SDLStateName) const
// //
// return true if this object should send his SDL msg (for persistence or synch) over the net // return true if this object should send his SDL msg (for persistence or synch) over the net
// //
bool plSynchedObject::IOKToNetwork(const char* sdlName, uint32_t* synchFlags) const bool plSynchedObject::IOKToNetwork(const plString& sdlName, uint32_t* synchFlags) const
{ {
// determine destination // determine destination
bool dstServerOnly=false, dstClientsOnly=false, dstClientsAndServer=false; bool dstServerOnly=false, dstClientsOnly=false, dstClientsAndServer=false;
@ -523,14 +523,14 @@ bool plSynchedObject::IOKToNetwork(const char* sdlName, uint32_t* synchFlags) co
return false; return false;
} }
plSynchedObject::SDLStateList::const_iterator plSynchedObject::IFindInSDLStateList(const SDLStateList& list, const char* sdlName) const plSynchedObject::SDLStateList::const_iterator plSynchedObject::IFindInSDLStateList(const SDLStateList& list, const plString& sdlName) const
{ {
if (!sdlName) if (sdlName.IsEmpty())
return list.end(); // false return list.end(); // false
SDLStateList::const_iterator it = list.begin(); SDLStateList::const_iterator it = list.begin();
for(; it != list.end(); it++) for(; it != list.end(); it++)
if (!stricmp((*it).c_str(), sdlName)) if (it->CompareI(sdlName) == 0)
return it; return it;
return it; // .end(), false return it; // .end(), false
@ -540,19 +540,19 @@ plSynchedObject::SDLStateList::const_iterator plSynchedObject::IFindInSDLStateLi
// EXCLUDE LIST // EXCLUDE LIST
/////////////////////////// ///////////////////////////
void plSynchedObject::AddToSDLExcludeList(const char* sdlName) void plSynchedObject::AddToSDLExcludeList(const plString& sdlName)
{ {
if (sdlName) if (!sdlName.IsEmpty())
{ {
if (IFindInSDLStateList(fSDLExcludeList, sdlName)==fSDLExcludeList.end()) if (IFindInSDLStateList(fSDLExcludeList, sdlName)==fSDLExcludeList.end())
{ {
fSDLExcludeList.push_back(sdlName); // Don't dupe sdlName, std::string will copy fSDLExcludeList.push_back(sdlName);
fSynchFlags |= kExcludePersistentState; fSynchFlags |= kExcludePersistentState;
} }
} }
} }
void plSynchedObject::RemoveFromSDLExcludeList(const char* sdlName) void plSynchedObject::RemoveFromSDLExcludeList(const plString& sdlName)
{ {
SDLStateList::const_iterator it=IFindInSDLStateList(fSDLExcludeList, sdlName); SDLStateList::const_iterator it=IFindInSDLStateList(fSDLExcludeList, sdlName);
if (it != fSDLExcludeList.end()) if (it != fSDLExcludeList.end())
@ -563,7 +563,7 @@ void plSynchedObject::RemoveFromSDLExcludeList(const char* sdlName)
} }
} }
bool plSynchedObject::IsInSDLExcludeList(const char* sdlName) const bool plSynchedObject::IsInSDLExcludeList(const plString& sdlName) const
{ {
if ((fSynchFlags & kExcludeAllPersistentState) != 0) if ((fSynchFlags & kExcludeAllPersistentState) != 0)
return true; return true;
@ -579,9 +579,9 @@ bool plSynchedObject::IsInSDLExcludeList(const char* sdlName) const
// VOLATILE LIST // VOLATILE LIST
/////////////////////////// ///////////////////////////
void plSynchedObject::AddToSDLVolatileList(const char* sdlName) void plSynchedObject::AddToSDLVolatileList(const plString& sdlName)
{ {
if (sdlName) if (!sdlName.IsEmpty())
{ {
if (IFindInSDLStateList(fSDLVolatileList,sdlName)==fSDLVolatileList.end()) if (IFindInSDLStateList(fSDLVolatileList,sdlName)==fSDLVolatileList.end())
{ {
@ -591,7 +591,7 @@ void plSynchedObject::AddToSDLVolatileList(const char* sdlName)
} }
} }
void plSynchedObject::RemoveFromSDLVolatileList(const char* sdlName) void plSynchedObject::RemoveFromSDLVolatileList(const plString& sdlName)
{ {
SDLStateList::const_iterator it=IFindInSDLStateList(fSDLVolatileList,sdlName); SDLStateList::const_iterator it=IFindInSDLStateList(fSDLVolatileList,sdlName);
if (it != fSDLVolatileList.end()) if (it != fSDLVolatileList.end())
@ -602,7 +602,7 @@ void plSynchedObject::RemoveFromSDLVolatileList(const char* sdlName)
} }
} }
bool plSynchedObject::IsInSDLVolatileList(const char* sdlName) const bool plSynchedObject::IsInSDLVolatileList(const plString& sdlName) const
{ {
if ((fSynchFlags & kAllStateIsVolatile) != 0) if ((fSynchFlags & kAllStateIsVolatile) != 0)
return true; return true;

35
Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.h

@ -89,17 +89,18 @@ public:
struct StateDefn struct StateDefn
{ {
plKey fObjKey; plKey fObjKey;
uint32_t fSendFlags; uint32_t fSendFlags;
std::string fSDLName; plString fSDLName;
plSynchedObject* GetObject() const { return plSynchedObject::ConvertNoRef(fObjKey->ObjectIsLoaded()); } plSynchedObject* GetObject() const { return plSynchedObject::ConvertNoRef(fObjKey->ObjectIsLoaded()); }
StateDefn() : fObjKey(nil),fSendFlags(0) {} StateDefn() : fObjKey(nil),fSendFlags(0) {}
StateDefn(plKey k, uint32_t f, const char* sdlName) : fObjKey(k),fSendFlags(f) { fSDLName=sdlName; } StateDefn(plKey k, uint32_t f, const plString& sdlName)
: fObjKey(k), fSendFlags(f), fSDLName(sdlName) { }
}; };
private: private:
typedef std::vector<std::string> SDLStateList; typedef std::vector<plString> SDLStateList;
SDLStateList fSDLExcludeList; SDLStateList fSDLExcludeList;
SDLStateList fSDLVolatileList; SDLStateList fSDLVolatileList;
uint32_t fSynchFlags; uint32_t fSynchFlags;
@ -110,12 +111,12 @@ private:
static plSynchedObject* fStaticSynchedObj; // static which temporarily holds address of each object's synchMgr static plSynchedObject* fStaticSynchedObj; // static which temporarily holds address of each object's synchMgr
static std::vector<StateDefn> fDirtyStates; static std::vector<StateDefn> fDirtyStates;
static void IRemoveDirtyState(plKey o, const char* sdlName); static void IRemoveDirtyState(plKey o, const plString& sdlName);
static void IAddDirtyState(plKey o, const char* sdlName, uint32_t sendFlags); static void IAddDirtyState(plKey o, const plString& sdlName, uint32_t sendFlags);
bool IOKToDirty(const char* SDLStateName) const; bool IOKToDirty(const plString& SDLStateName) const;
SDLStateList::const_iterator IFindInSDLStateList(const SDLStateList& list, const char* sdlName) const; SDLStateList::const_iterator IFindInSDLStateList(const SDLStateList& list, const plString& sdlName) const;
protected: protected:
bool IOKToNetwork(const char* sdlName, uint32_t* synchFlags) const; bool IOKToNetwork(const plString& sdlName, uint32_t* synchFlags) const;
public: public:
plSynchedObject(); plSynchedObject();
virtual ~plSynchedObject(); virtual ~plSynchedObject();
@ -136,8 +137,8 @@ public:
virtual void SetNetGroup(plNetGroupId netGroup) { fNetGroup = netGroup; } virtual void SetNetGroup(plNetGroupId netGroup) { fNetGroup = netGroup; }
plNetGroupId SelectNetGroup(plKey groupKey); plNetGroupId SelectNetGroup(plKey groupKey);
virtual bool DirtySynchState(const char* sdlName, uint32_t sendFlags); virtual bool DirtySynchState(const plString& sdlName, uint32_t sendFlags);
void SendSDLStateMsg(const char* SDLStateName, uint32_t synchFlags); // don't use, only for net code void SendSDLStateMsg(const plString& SDLStateName, uint32_t synchFlags); // don't use, only for net code
void ClearSynchFlagsBit(uint32_t f) { fSynchFlags &= ~f; } void ClearSynchFlagsBit(uint32_t f) { fSynchFlags &= ~f; }
@ -168,14 +169,14 @@ public:
void SetLocalOnly(bool b) { if (b) fSynchFlags |= kLocalOnly; else fSynchFlags &= ~kLocalOnly; } void SetLocalOnly(bool b) { if (b) fSynchFlags |= kLocalOnly; else fSynchFlags &= ~kLocalOnly; }
// disable particular types of persistence // disable particular types of persistence
void AddToSDLExcludeList(const char*); void AddToSDLExcludeList(const plString&);
void RemoveFromSDLExcludeList(const char*); void RemoveFromSDLExcludeList(const plString&);
bool IsInSDLExcludeList(const char*) const; bool IsInSDLExcludeList(const plString&) const;
// make volatile particular types of state // make volatile particular types of state
void AddToSDLVolatileList(const char*); void AddToSDLVolatileList(const plString&);
void RemoveFromSDLVolatileList(const char*); void RemoveFromSDLVolatileList(const plString&);
bool IsInSDLVolatileList(const char*) const; bool IsInSDLVolatileList(const plString&) const;
// //
// synched value stuff, currently unused // synched value stuff, currently unused

2
Sources/Plasma/NucleusLib/pnNetCommon/plSynchedValue.h

@ -144,7 +144,7 @@ public:
{ {
MakeDirty(); // dirty value MakeDirty(); // dirty value
if (GetSynchedObject()) if (GetSynchedObject())
GetSynchedObject()->DirtySynchState(nil, 0); // dirty owner GetSynchedObject()->DirtySynchState(plString::Null, 0); // dirty owner
} }
} }

6
Sources/Plasma/NucleusLib/pnUtils/pnUtStr.h

@ -118,6 +118,12 @@ unsigned StrToAnsi (char * dest, const wchar_t source[], unsigned destChars, uns
unsigned StrToUnicode (wchar_t * dest, const char source[], unsigned destChars); unsigned StrToUnicode (wchar_t * dest, const char source[], unsigned destChars);
unsigned StrToUnicode (wchar_t * dest, const char source[], unsigned destChars, unsigned codePage); unsigned StrToUnicode (wchar_t * dest, const char source[], unsigned destChars, unsigned codePage);
// FIXME: Get rid of these
inline unsigned StrToUnicode(wchar_t * dest, const plString & source, unsigned destChars)
{ return StrToUnicode(dest, source.c_str(), destChars); }
inline unsigned StrToUnicode(wchar_t * dest, const plString & source, unsigned destChars, unsigned codePage)
{ return StrToUnicode(dest, source.c_str(), destChars, codePage); }
float StrToFloat (const char source[], const char ** endptr); float StrToFloat (const char source[], const char ** endptr);
float StrToFloat (const wchar_t source[], const wchar_t ** endptr); float StrToFloat (const wchar_t source[], const wchar_t ** endptr);

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

@ -1480,7 +1480,7 @@ plDrawableSpans* plSound::CreateProxy(const hsMatrix44& l2w, hsGMaterial* mat, h
// call when state has changed // call when state has changed
bool plSound::DirtySynchState(const char* sdlName /* kSDLSound */, uint32_t sendFlags) bool plSound::DirtySynchState(const plString& sdlName /* kSDLSound */, uint32_t sendFlags)
{ {
/* /*
if( sdlName == nil ) if( sdlName == nil )

2
Sources/Plasma/PubUtilLib/plAudio/plSound.h

@ -239,7 +239,7 @@ public:
virtual void UpdateSoftVolume( bool enable, bool firstTime = false ); virtual void UpdateSoftVolume( bool enable, bool firstTime = false );
virtual bool MsgReceive( plMessage* pMsg ); virtual bool MsgReceive( plMessage* pMsg );
virtual bool DirtySynchState( const char *sdlName = nil, uint32_t sendFlags = 0 ); // call when state has changed virtual bool DirtySynchState( const plString &sdlName = "", uint32_t sendFlags = 0 ); // call when state has changed
// Tests whether this sound is within range of the given position, not counting soft regions // Tests whether this sound is within range of the given position, not counting soft regions
bool IsWithinRange( const hsPoint3 &listenerPos, float *distSquared ); bool IsWithinRange( const hsPoint3 &listenerPos, float *distSquared );

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

@ -219,7 +219,7 @@ void plSoundBuffer::Read( hsStream *s, hsResMgr *mgr )
s->ReadLE( &fFlags ); s->ReadLE( &fFlags );
s->ReadLE( &fDataLength ); s->ReadLE( &fDataLength );
fFileName = s->ReadSafeString_TEMP(); fFileName = s->ReadSafeString();
s->ReadLE( &fHeader.fFormatTag ); s->ReadLE( &fHeader.fFormatTag );
s->ReadLE( &fHeader.fNumChannels ); s->ReadLE( &fHeader.fNumChannels );

23
Sources/Plasma/PubUtilLib/plAvatar/plAGAnim.cpp

@ -217,7 +217,7 @@ void plAGAnim::Read(hsStream *stream, hsResMgr *mgr)
plSynchedObject::Read(stream, mgr); plSynchedObject::Read(stream, mgr);
// read in the name of the animation itself // read in the name of the animation itself
fName = stream->ReadSafeString_TEMP(); fName = stream->ReadSafeString();
fStart = stream->ReadLEScalar(); fStart = stream->ReadLEScalar();
fEnd = stream->ReadLEScalar(); fEnd = stream->ReadLEScalar();
@ -412,7 +412,7 @@ void plATCAnim::Read(hsStream *stream, hsResMgr *mgr)
int numMarkers = stream->ReadLE32(); int numMarkers = stream->ReadLE32();
for (i = 0; i < numMarkers; i++) for (i = 0; i < numMarkers; i++)
{ {
plString name = stream->ReadSafeString_TEMP(); plString name = stream->ReadSafeString();
float time = stream->ReadLEFloat(); float time = stream->ReadLEFloat();
fMarkers[name] = time; fMarkers[name] = time;
} }
@ -420,7 +420,7 @@ void plATCAnim::Read(hsStream *stream, hsResMgr *mgr)
int numLoops = stream->ReadLE32(); int numLoops = stream->ReadLE32();
for (i = 0; i < numLoops; i++) for (i = 0; i < numLoops; i++)
{ {
plString name = stream->ReadSafeString_TEMP(); plString name = stream->ReadSafeString();
float begin = stream->ReadLEScalar(); float begin = stream->ReadLEScalar();
float end = stream->ReadLEScalar(); float end = stream->ReadLEScalar();
fLoops[name] = std::pair<float,float>(begin,end); fLoops[name] = std::pair<float,float>(begin,end);
@ -665,30 +665,15 @@ float plEmoteAnim::GetFadeOut() const
plAgeGlobalAnim::plAgeGlobalAnim() plAgeGlobalAnim::plAgeGlobalAnim()
: plAGAnim() : plAGAnim()
{ {
fGlobalVarName = nil;
} }
// ctor -------------------------------------------------------------------- // ctor --------------------------------------------------------------------
// ----- // -----
plAgeGlobalAnim::plAgeGlobalAnim(const plString &name, double start, double end) plAgeGlobalAnim::plAgeGlobalAnim(const plString &name, double start, double end)
: plAGAnim(name, start, end), : plAGAnim(name, start, end)
fGlobalVarName(nil)
{ {
} }
// dtor ---------------------------
// -----
plAgeGlobalAnim::~plAgeGlobalAnim()
{
delete [] fGlobalVarName;
}
void plAgeGlobalAnim::SetGlobalVarName(char *name)
{
delete [] fGlobalVarName;
fGlobalVarName = hsStrcpy(name);
}
// Read --------------------------------------------------- // Read ---------------------------------------------------
// ----- // -----

10
Sources/Plasma/PubUtilLib/plAvatar/plAGAnim.h

@ -417,11 +417,9 @@ public:
/** Construct with name, start time, and end time (within the max note track) /** Construct with name, start time, and end time (within the max note track)
*/ */
plAgeGlobalAnim(const plString &name, double begin, double end); plAgeGlobalAnim(const plString &name, double begin, double end);
/** Destruct, freeing the underlying animation data. */
virtual ~plAgeGlobalAnim(); plString GetGlobalVarName() const { return fGlobalVarName; }
void SetGlobalVarName(const plString &name) { fGlobalVarName = name; }
const char * GetGlobalVarName() const { return fGlobalVarName; }
void SetGlobalVarName(char *name);
// PLASMA PROTOCOL // PLASMA PROTOCOL
// rtti // rtti
@ -433,7 +431,7 @@ public:
virtual void Write(hsStream* stream, hsResMgr* mgr); virtual void Write(hsStream* stream, hsResMgr* mgr);
protected: protected:
char *fGlobalVarName; // Name of the SDL variable we animate on. plString fGlobalVarName; // Name of the SDL variable we animate on.
}; };
// USEFUL HELPER FUNCTIONS // USEFUL HELPER FUNCTIONS

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

@ -138,7 +138,7 @@ void plAGApplicator::Read(hsStream *stream, hsResMgr *mgr)
fEnabled = stream->ReadBool(); fEnabled = stream->ReadBool();
fChannel = nil; // Whatever is reading this applicator in should know what channel to assign it fChannel = nil; // Whatever is reading this applicator in should know what channel to assign it
fChannelName = stream->ReadSafeString_TEMP(); fChannelName = stream->ReadSafeString();
} }
// IGETxI // IGETxI

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

@ -119,7 +119,7 @@ void plAGChannel::Read(hsStream *stream, hsResMgr *mgr)
{ {
plCreatable::Read(stream, mgr); plCreatable::Read(stream, mgr);
fName = stream->ReadSafeString_TEMP(); fName = stream->ReadSafeString();
} }
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////

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

@ -799,7 +799,7 @@ bool plAGMasterMod::HasRunningAnims()
// //
// Send SDL sendState msg to object's plAGMasterSDLModifier // Send SDL sendState msg to object's plAGMasterSDLModifier
// //
bool plAGMasterMod::DirtySynchState(const char* SDLStateName, uint32_t synchFlags) bool plAGMasterMod::DirtySynchState(const plString& SDLStateName, uint32_t synchFlags)
{ {
if(GetNumTargets() > 0 && (!fIsGrouped || fIsGroupMaster)) if(GetNumTargets() > 0 && (!fIsGrouped || fIsGroupMaster))
{ {

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

@ -206,7 +206,7 @@ public:
virtual void Read(hsStream * stream, hsResMgr *mgr); virtual void Read(hsStream * stream, hsResMgr *mgr);
bool HasRunningAnims(); bool HasRunningAnims();
bool DirtySynchState(const char* SDLStateName, uint32_t synchFlags); bool DirtySynchState(const plString& SDLStateName, uint32_t synchFlags);
CLASSNAME_REGISTER( plAGMasterMod ); CLASSNAME_REGISTER( plAGMasterMod );
GETINTERFACE_ANY( plAGMasterMod, plModifier ); GETINTERFACE_ANY( plAGMasterMod, plModifier );

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

@ -269,7 +269,7 @@ void plAGModifier::Read(hsStream *stream, hsResMgr *mgr)
plSingleModifier::Read(stream, mgr); plSingleModifier::Read(stream, mgr);
// read in the name of the modifier // read in the name of the modifier
fChannelName = stream->ReadSafeString_TEMP(); fChannelName = stream->ReadSafeString();
} }
// WRITE // WRITE

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

@ -741,7 +741,7 @@ void plAnimStage::DumpDebug(bool active, int &x, int &y, int lineHeight, plDebug
// READ // READ
void plAnimStage::Read(hsStream *stream, hsResMgr *mgr) void plAnimStage::Read(hsStream *stream, hsResMgr *mgr)
{ {
fAnimName = stream->ReadSafeString_TEMP(); fAnimName = stream->ReadSafeString();
fNotify = stream->ReadByte(); fNotify = stream->ReadByte();
fForwardType = (ForwardType)stream->ReadLE32(); fForwardType = (ForwardType)stream->ReadLE32();
fBackType = (BackType)stream->ReadLE32(); fBackType = (BackType)stream->ReadLE32();

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

@ -1743,8 +1743,8 @@ void plArmatureMod::Write(hsStream *stream, hsResMgr *mgr)
stream->WriteLEFloat(fPhysWidth); stream->WriteLEFloat(fPhysWidth);
stream->WriteSafeString(fAnimationPrefix); stream->WriteSafeString(fAnimationPrefix);
stream->WriteSafeString(fBodyAgeName.c_str()); stream->WriteSafeString(fBodyAgeName);
stream->WriteSafeString(fBodyFootstepSoundPage.c_str()); stream->WriteSafeString(fBodyFootstepSoundPage);
} }
void plArmatureMod::Read(hsStream * stream, hsResMgr *mgr) void plArmatureMod::Read(hsStream * stream, hsResMgr *mgr)
@ -1756,7 +1756,7 @@ void plArmatureMod::Read(hsStream * stream, hsResMgr *mgr)
fMeshKeys.push_back(mgr->ReadKey(stream)); fMeshKeys.push_back(mgr->ReadKey(stream));
// read the root name string // read the root name string
fRootName = stream->ReadSafeString_TEMP(); fRootName = stream->ReadSafeString();
// read in the brains // read in the brains
int nBrains = stream->ReadLE32(); int nBrains = stream->ReadLE32();
@ -1780,9 +1780,7 @@ void plArmatureMod::Read(hsStream * stream, hsResMgr *mgr)
// Attach the Footstep emitter scene object // Attach the Footstep emitter scene object
hsResMgr *mgr = hsgResMgr::ResMgr(); hsResMgr *mgr = hsgResMgr::ResMgr();
const char *age = fBodyAgeName.c_str(); const plLocation &gLoc = plKeyFinder::Instance().FindLocation(fBodyAgeName, fBodyFootstepSoundPage);
const char *page = fBodyFootstepSoundPage.c_str();
const plLocation &gLoc = plKeyFinder::Instance().FindLocation(age, page);
if (gLoc.IsValid()) if (gLoc.IsValid())
{ {
@ -1823,23 +1821,17 @@ void plArmatureMod::Read(hsStream * stream, hsResMgr *mgr)
fPhysHeight = stream->ReadLEFloat(); fPhysHeight = stream->ReadLEFloat();
fPhysWidth = stream->ReadLEFloat(); fPhysWidth = stream->ReadLEFloat();
fAnimationPrefix = stream->ReadSafeString_TEMP(); fAnimationPrefix = stream->ReadSafeString();
fBodyAgeName = stream->ReadSafeString();
fBodyFootstepSoundPage = stream->ReadSafeString();
char *temp = stream->ReadSafeString();
fBodyAgeName = temp;
delete [] temp;
temp = stream->ReadSafeString();
fBodyFootstepSoundPage = temp;
delete [] temp;
plgDispatch::Dispatch()->RegisterForExactType(plAvatarStealthModeMsg::Index(), GetKey()); plgDispatch::Dispatch()->RegisterForExactType(plAvatarStealthModeMsg::Index(), GetKey());
} }
bool plArmatureMod::DirtySynchState(const char* SDLStateName, uint32_t synchFlags) bool plArmatureMod::DirtySynchState(const plString& SDLStateName, uint32_t synchFlags)
{ {
// skip requests to synch non-avatar state // skip requests to synch non-avatar state
if (SDLStateName && stricmp(SDLStateName, kSDLAvatar)) if (SDLStateName.CompareI(kSDLAvatar) != 0)
{ {
return false; return false;
} }
@ -2561,9 +2553,9 @@ int plArmatureMod::GetKILevel()
return VaultGetKILevel(); return VaultGetKILevel();
} }
void plArmatureMod::SetLinkInAnim(const char *animName) void plArmatureMod::SetLinkInAnim(const plString &animName)
{ {
if (animName) if (!animName.IsNull())
{ {
plAGAnim *anim = FindCustomAnim(animName); plAGAnim *anim = FindCustomAnim(animName);
fLinkInAnimKey = (anim ? anim->GetKey() : nil); fLinkInAnimKey = (anim ? anim->GetKey() : nil);

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

@ -283,7 +283,7 @@ public:
void SynchIfLocal(double timeNow, int force); // Just physical state void SynchIfLocal(double timeNow, int force); // Just physical state
void SynchInputState(uint32_t rcvID = kInvalidPlayerID); void SynchInputState(uint32_t rcvID = kInvalidPlayerID);
bool DirtySynchState(const char* SDLStateName, uint32_t synchFlags ); bool DirtySynchState(const plString& SDLStateName, uint32_t synchFlags );
bool DirtyPhysicalSynchState(uint32_t synchFlags); bool DirtyPhysicalSynchState(uint32_t synchFlags);
plClothingOutfit *GetClothingOutfit() const { return fClothingOutfit; } plClothingOutfit *GetClothingOutfit() const { return fClothingOutfit; }
plClothingSDLModifier *GetClothingSDLMod() const { return fClothingSDLMod; } plClothingSDLModifier *GetClothingSDLMod() const { return fClothingSDLMod; }
@ -340,7 +340,7 @@ public:
bool IsKILowestLevel(); bool IsKILowestLevel();
int GetKILevel(); int GetKILevel();
void SetLinkInAnim(const char *animName); void SetLinkInAnim(const plString &animName);
plKey GetLinkInAnimKey() const; plKey GetLinkInAnimKey() const;
enum enum
@ -369,11 +369,11 @@ public:
void SetPhysicalDims(float height, float width) { fPhysHeight = height; fPhysWidth = width; } void SetPhysicalDims(float height, float width) { fPhysHeight = height; fPhysWidth = width; }
void SetBodyAgeName(const char* ageName) {if (ageName) fBodyAgeName = ageName; else fBodyAgeName = "";} void SetBodyAgeName(const plString& ageName) { fBodyAgeName = ageName; }
void SetBodyFootstepSoundPage(const char* pageName) {if (pageName) fBodyFootstepSoundPage = pageName; else fBodyFootstepSoundPage = "";} void SetBodyFootstepSoundPage(const plString& pageName) { fBodyFootstepSoundPage = pageName; }
void SetAnimationPrefix(const plString& prefix) { fAnimationPrefix = prefix; } void SetAnimationPrefix(const plString& prefix) { fAnimationPrefix = prefix; }
const char* GetUserStr() {return fUserStr.c_str();} plString GetUserStr() const { return fUserStr; }
protected: protected:
void IInitDefaults(); void IInitDefaults();
@ -443,12 +443,12 @@ protected:
bool fDontPanicLink; bool fDontPanicLink;
// strings for animations, age names, footstep sounds, etc // strings for animations, age names, footstep sounds, etc
std::string fBodyAgeName; plString fBodyAgeName;
std::string fBodyFootstepSoundPage; plString fBodyFootstepSoundPage;
plString fAnimationPrefix; plString fAnimationPrefix;
// user-defined string assigned to this avatar // user-defined string assigned to this avatar
std::string fUserStr; plString fUserStr;
}; };
// PLARMATURELOD // PLARMATURELOD

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

@ -160,14 +160,14 @@ void plClothingItem::Read(hsStream *s, hsResMgr *mgr)
{ {
hsKeyedObject::Read(s, mgr); hsKeyedObject::Read(s, mgr);
fName = s->ReadSafeString_TEMP(); fName = s->ReadSafeString();
fGroup = s->ReadByte(); fGroup = s->ReadByte();
fType = s->ReadByte(); fType = s->ReadByte();
fTileset = s->ReadByte(); fTileset = s->ReadByte();
fSortOrder = s->ReadByte(); fSortOrder = s->ReadByte();
fCustomText = s->ReadSafeString_TEMP(); fCustomText = s->ReadSafeString();
fDescription = s->ReadSafeString_TEMP(); fDescription = s->ReadSafeString();
if (s->ReadBool()) if (s->ReadBool())
mgr->ReadKeyNotifyMe(s, new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, -1), plRefFlags::kActiveRef); // thumbnail mgr->ReadKeyNotifyMe(s, new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, -1), plRefFlags::kActiveRef); // thumbnail
@ -175,7 +175,7 @@ void plClothingItem::Read(hsStream *s, hsResMgr *mgr)
int i, j; int i, j;
for (i = 0; i < tileCount; i++) for (i = 0; i < tileCount; i++)
{ {
fElementNames.Append(s->ReadSafeString_TEMP()); fElementNames.Append(s->ReadSafeString());
int layerCount = s->ReadByte(); int layerCount = s->ReadByte();
for (j = 0; j < layerCount; j++) for (j = 0; j < layerCount; j++)
@ -375,10 +375,10 @@ void plClothingBase::Read(hsStream* s, hsResMgr* mgr)
{ {
hsKeyedObject::Read(s, mgr); hsKeyedObject::Read(s, mgr);
fName = s->ReadSafeString_TEMP(); fName = s->ReadSafeString();
if (s->ReadBool()) if (s->ReadBool())
mgr->ReadKeyNotifyMe(s, new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, -1), plRefFlags::kActiveRef); mgr->ReadKeyNotifyMe(s, new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, -1), plRefFlags::kActiveRef);
fLayoutName = s->ReadSafeString_TEMP(); fLayoutName = s->ReadSafeString();
} }
void plClothingBase::Write(hsStream* s, hsResMgr* mgr) void plClothingBase::Write(hsStream* s, hsResMgr* mgr)
@ -1405,7 +1405,7 @@ bool plClothingOutfit::MsgReceive(plMessage* msg)
// TESTING SDL // TESTING SDL
// Send clothing sendState msg to object's plClothingSDLModifier // Send clothing sendState msg to object's plClothingSDLModifier
// //
bool plClothingOutfit::DirtySynchState(const char* SDLStateName, uint32_t synchFlags) bool plClothingOutfit::DirtySynchState(const plString& SDLStateName, uint32_t synchFlags)
{ {
plSynchEnabler ps(true); // make sure synching is enabled, since this happens during load plSynchEnabler ps(true); // make sure synching is enabled, since this happens during load
synchFlags |= plSynchedObject::kForceFullSend; // TEMP synchFlags |= plSynchedObject::kForceFullSend; // TEMP

2
Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.h

@ -195,7 +195,7 @@ public:
virtual void Read(hsStream* s, hsResMgr* mgr); virtual void Read(hsStream* s, hsResMgr* mgr);
virtual void Write(hsStream* s, hsResMgr* mgr); virtual void Write(hsStream* s, hsResMgr* mgr);
bool DirtySynchState(const char* SDLStateName, uint32_t synchFlags); bool DirtySynchState(const plString& SDLStateName, uint32_t synchFlags);
void StripAccessories(); void StripAccessories();
void WearDefaultClothing(); void WearDefaultClothing();

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

@ -465,7 +465,7 @@ void plAvAnimTask::LeaveAge(plArmatureMod *avatar)
// READ // READ
void plAvAnimTask::Read(hsStream *stream, hsResMgr *mgr) void plAvAnimTask::Read(hsStream *stream, hsResMgr *mgr)
{ {
fAnimName = stream->ReadSafeString_TEMP(); fAnimName = stream->ReadSafeString();
fInitialBlend = stream->ReadLEScalar(); fInitialBlend = stream->ReadLEScalar();
fTargetBlend = stream->ReadLEScalar(); fTargetBlend = stream->ReadLEScalar();
fFadeSpeed = stream->ReadLEScalar(); fFadeSpeed = stream->ReadLEScalar();
@ -802,8 +802,8 @@ void plAvOneShotLinkTask::Write(hsStream *stream, hsResMgr *mgr)
void plAvOneShotLinkTask::Read(hsStream *stream, hsResMgr *mgr) void plAvOneShotLinkTask::Read(hsStream *stream, hsResMgr *mgr)
{ {
plAvOneShotTask::Read(stream, mgr); plAvOneShotTask::Read(stream, mgr);
fAnimName = stream->ReadSafeString_TEMP(); fAnimName = stream->ReadSafeString();
fMarkerName = stream->ReadSafeString_TEMP(); fMarkerName = stream->ReadSafeString();
} }
void plAvOneShotLinkTask::SetMarkerName(const plString &name) void plAvOneShotLinkTask::SetMarkerName(const plString &name)

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

@ -398,7 +398,7 @@ void plCoopCoordinator::Read(hsStream *stream, hsResMgr *mgr)
else else
fGuestAcceptMsg = nil; fGuestAcceptMsg = nil;
fSynchBone = stream->ReadSafeString_TEMP(); fSynchBone = stream->ReadSafeString();
fAutoStartGuest = stream->ReadBool(); fAutoStartGuest = stream->ReadBool();
fInitiatorID = fHostBrain->GetInitiatorID(); fInitiatorID = fHostBrain->GetInitiatorID();

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

@ -128,8 +128,8 @@ void plNPCSpawnMod::Read(hsStream *stream, hsResMgr *mgr)
{ {
plSingleModifier::Read(stream, mgr); plSingleModifier::Read(stream, mgr);
fModelName = stream->ReadSafeString_TEMP(); fModelName = stream->ReadSafeString();
fAccountName = stream->ReadSafeString_TEMP(); fAccountName = stream->ReadSafeString();
fAutoSpawn = stream->ReadBool(); fAutoSpawn = stream->ReadBool();
if(stream->ReadBool()) if(stream->ReadBool())
fNotify = plNotifyMsg::ConvertNoRef(mgr->ReadCreatable(stream)); fNotify = plNotifyMsg::ConvertNoRef(mgr->ReadCreatable(stream));

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

@ -154,7 +154,7 @@ void plOneShotMod::Read(hsStream *stream, hsResMgr *mgr)
plMultiModifier::Read(stream, mgr); plMultiModifier::Read(stream, mgr);
// read in the name of the animation itself // read in the name of the animation itself
fAnimName = stream->ReadSafeString_TEMP(); fAnimName = stream->ReadSafeString();
fSeekDuration = stream->ReadLEScalar(); fSeekDuration = stream->ReadLEScalar();
fDrivable = stream->ReadBool(); fDrivable = stream->ReadBool();
fReversable = stream->ReadBool(); fReversable = stream->ReadBool();

45
Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.cpp

@ -41,6 +41,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "HeadSpin.h" #include "HeadSpin.h"
#include <algorithm>
#include "hsStream.h" #include "hsStream.h"
#include "hsResMgr.h" #include "hsResMgr.h"
@ -59,30 +60,18 @@ plClientResMgr& plClientResMgr::Instance(void)
return theInstance; return theInstance;
} }
plClientResMgr::plClientResMgr()
{
this->ClientResources = new std::map<std::string, plMipmap*>;
}
plClientResMgr::~plClientResMgr() plClientResMgr::~plClientResMgr()
{ {
if (this->ClientResources) { for (auto it = ClientResources.begin(); it != ClientResources.end(); ++it) {
std::map<std::string, plMipmap*>::iterator it; if (it->second)
it->second->UnRef();
for (it = this->ClientResources->begin(); it != this->ClientResources->end(); ++it) {
if (it->second)
it->second->UnRef();
}
delete this->ClientResources;
} }
} }
void plClientResMgr::ILoadResources(const char* resfile) void plClientResMgr::ILoadResources(const plFileName& resfile)
{ {
if (!resfile) { if (!resfile.IsValid())
return; return;
}
hsUNIXStream in; hsUNIXStream in;
@ -96,21 +85,19 @@ void plClientResMgr::ILoadResources(const char* resfile)
num_resources = in.ReadLE32(); num_resources = in.ReadLE32();
for (int i = 0; i < num_resources; i++) { for (int i = 0; i < num_resources; i++) {
plMipmap* res_data = NULL; plMipmap* res_data = nullptr;
uint32_t res_size = 0; uint32_t res_size = 0;
char* tmp_name = in.ReadSafeStringLong(); plString res_name = in.ReadSafeStringLong();
std::string res_name = std::string(tmp_name); plString extension = plFileName(res_name).GetFileExt();
std::string res_type = res_name.substr(res_name.length() - 4, 4);
delete[] tmp_name;
// Version 1 doesn't encode format, so we'll try some simple // Version 1 doesn't encode format, so we'll try some simple
// extension sniffing // extension sniffing
if (res_type == ".png") { if (extension == "png") {
// Read resource stream size, but the PNG has that info in the header // Read resource stream size, but the PNG has that info in the header
// so it's not needed // so it's not needed
res_size = in.ReadLE32(); res_size = in.ReadLE32();
res_data = plPNG::Instance().ReadFromStream(&in); res_data = plPNG::Instance().ReadFromStream(&in);
} else if (res_type == ".jpg") { } else if (extension == "jpg") {
// Don't read resource stream size, as plJPEG's reader will need it // Don't read resource stream size, as plJPEG's reader will need it
res_data = plJPEG::Instance().ReadFromStream(&in); res_data = plJPEG::Instance().ReadFromStream(&in);
} else { } else {
@ -122,7 +109,7 @@ void plClientResMgr::ILoadResources(const char* resfile)
in.Skip(res_size); in.Skip(res_size);
} }
(*this->ClientResources)[res_name] = res_data; ClientResources[res_name] = res_data;
} }
break; break;
@ -134,12 +121,12 @@ void plClientResMgr::ILoadResources(const char* resfile)
} }
} }
plMipmap* plClientResMgr::getResource(const char* resname) plMipmap* plClientResMgr::getResource(const plString& resname)
{ {
plMipmap* resmipmap = NULL; plMipmap* resmipmap = nullptr;
std::map<std::string, plMipmap*>::iterator it = this->ClientResources->find(resname); auto it = ClientResources.find(resname);
if (it != this->ClientResources->end()) { if (it != ClientResources.end()) {
resmipmap = it->second; resmipmap = it->second;
} else { } else {
hsAssert(resmipmap, "Unknown client resource requested."); hsAssert(resmipmap, "Unknown client resource requested.");

13
Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.h

@ -43,22 +43,23 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef _plClientResMgr_h #ifndef _plClientResMgr_h
#define _plClientResMgr_h #define _plClientResMgr_h
#include <map> #include <unordered_map>
#include <string>
class plMipmap; class plMipmap;
class plString;
class plFileName;
class plClientResMgr { class plClientResMgr {
protected: protected:
std::map<std::string, plMipmap*>* ClientResources; std::unordered_map<plString, plMipmap*, plString::hash> ClientResources;
public: public:
plClientResMgr(); plClientResMgr() { }
~plClientResMgr(); ~plClientResMgr();
void ILoadResources(const char* resfile); void ILoadResources(const plFileName& resfile);
plMipmap* getResource(const char* resname); plMipmap* getResource(const plString& resname);
static plClientResMgr& Instance(void); static plClientResMgr& Instance(void);
}; };

31
Sources/Plasma/PubUtilLib/plGImage/plDynSurfaceWriter.cpp

@ -86,7 +86,6 @@ plDynSurfaceWriter::plWinSurface::plWinSurface()
fWidth = fHeight = 0; fWidth = fHeight = 0;
fSaveNum = 0; fSaveNum = 0;
fFontFace = nil;
fFontSize = 0; fFontSize = 0;
fFontFlags = 0; fFontFlags = 0;
fFontAntiAliasRGB = false; fFontAntiAliasRGB = false;
@ -207,8 +206,7 @@ void plDynSurfaceWriter::plWinSurface::Release( void )
fBits = nil; fBits = nil;
fWidth = fHeight = 0; fWidth = fHeight = 0;
delete [] fFontFace; fFontFace = plString::Null;
fFontFace = nil;
fFontSize = 0; fFontSize = 0;
fFontFlags = 0; fFontFlags = 0;
fFontAntiAliasRGB = false; fFontAntiAliasRGB = false;
@ -231,19 +229,18 @@ static int SafeStrCmp( const char *str1, const char *str2 )
return -1; return -1;
} }
bool plDynSurfaceWriter::plWinSurface::FontMatches( const char *face, uint16_t size, uint8_t flags, bool aaRGB ) bool plDynSurfaceWriter::plWinSurface::FontMatches( const plString &face, uint16_t size, uint8_t flags, bool aaRGB )
{ {
if( SafeStrCmp( face, fFontFace ) == 0 && fFontSize == size && if( face == fFontFace && fFontSize == size &&
fFontFlags == flags && fFontAntiAliasRGB == aaRGB ) fFontFlags == flags && fFontAntiAliasRGB == aaRGB )
return true; return true;
return false; return false;
} }
void plDynSurfaceWriter::plWinSurface::SetFont( const char *face, uint16_t size, uint8_t flags, bool aaRGB ) void plDynSurfaceWriter::plWinSurface::SetFont( const plString &face, uint16_t size, uint8_t flags, bool aaRGB )
{ {
delete [] fFontFace; fFontFace = face;
fFontFace = ( face != nil ) ? hsStrcpy( face ) : nil;
fFontSize = size; fFontSize = size;
fFontFlags = flags; fFontFlags = flags;
fFontAntiAliasRGB = aaRGB; fFontAntiAliasRGB = aaRGB;
@ -256,7 +253,7 @@ void plDynSurfaceWriter::plWinSurface::SetFont( const char *face, uint16_t si
fFont = nil; fFont = nil;
} }
if( face == nil ) if (face.IsEmpty())
return; return;
bool bold = ( fFontFlags & plDynSurfaceWriter::kFontBold ) ? true : false; bool bold = ( fFontFlags & plDynSurfaceWriter::kFontBold ) ? true : false;
@ -283,10 +280,10 @@ void plDynSurfaceWriter::plWinSurface::SetFont( const char *face, uint16_t si
if( fFont == nil ) if( fFont == nil )
{ {
hsAssert( false, "Cannot create Windows font for plDynSurfaceWriter" ); hsAssert( false, "Cannot create Windows font for plDynSurfaceWriter" );
plStatusLog::AddLineS( "pipeline.log", "ERROR: Cannot allocate font for RGB surface! (face: %s, size: %d %s %s)", face, nHeight, bold ? "bold" : "", italic ? "italic" : "" ); plStatusLog::AddLineS( "pipeline.log", "ERROR: Cannot allocate font for RGB surface! (face: %s, size: %d %s %s)",
face.c_str(), nHeight, bold ? "bold" : "", italic ? "italic" : "" );
delete [] fFontFace; fFontFace = plString::Null;
fFontFace = nil;
fFontSize = 0; fFontSize = 0;
return; return;
} }
@ -385,7 +382,7 @@ void plDynSurfaceWriter::IInit( void )
fJustify = kLeftJustify; fJustify = kLeftJustify;
fFlags = 0; fFlags = 0;
fFlushed = true; fFlushed = true;
fFontFace = nil; fFontFace = plString::Null;
fFontSize = 0; fFontSize = 0;
fFontBlockedRGB = false; fFontBlockedRGB = false;
} }
@ -401,8 +398,7 @@ void plDynSurfaceWriter::Reset( void )
fCurrTarget = nil; fCurrTarget = nil;
fFlushed = true; fFlushed = true;
delete [] fFontFace; fFontFace = plString::Null;
fFontFace = nil;
fFontSize = 0; fFontSize = 0;
} }
@ -514,8 +510,7 @@ void plDynSurfaceWriter::SwitchTarget( plDynamicTextMap *target )
if( hadToAllocate ) if( hadToAllocate )
{ {
delete [] fFontFace; fFontFace = plString::Null;
fFontFace = nil;
fFontSize = 0; fFontSize = 0;
fFontFlags = 0; fFontFlags = 0;
} }
@ -701,7 +696,7 @@ void plDynSurfaceWriter::SetFont( const char *face, uint16_t size, uint8_t fo
//// ISetFont ///////////////////////////////////////////////////////////////// //// ISetFont /////////////////////////////////////////////////////////////////
void plDynSurfaceWriter::ISetFont( const char *face, uint16_t size, uint8_t fontFlags, bool antiAliasRGB ) void plDynSurfaceWriter::ISetFont( const plString &face, uint16_t size, uint8_t fontFlags, bool antiAliasRGB )
{ {
fFlags = ( fFlags & ~kFontShadowed ) | ( fontFlags & kFontShadowed ); fFlags = ( fFlags & ~kFontShadowed ) | ( fontFlags & kFontShadowed );

20
Sources/Plasma/PubUtilLib/plGImage/plDynSurfaceWriter.h

@ -148,16 +148,16 @@ class plDynSurfaceWriter
void IRefreshOSJustify( void ); void IRefreshOSJustify( void );
void ISetTextColor( hsColorRGBA &color, bool blockRGB ); void ISetTextColor( hsColorRGBA &color, bool blockRGB );
void ISetFont( const char *face, uint16_t size, uint8_t fontFlags = 0, bool antiAliasRGB = true ); void ISetFont( const plString &face, uint16_t size, uint8_t fontFlags = 0, bool antiAliasRGB = true );
plDynamicTextMap *fCurrTarget; plDynamicTextMap *fCurrTarget;
uint32_t fFlags; uint32_t fFlags;
Justify fJustify; Justify fJustify;
bool fFlushed; bool fFlushed;
char *fFontFace; plString fFontFace;
uint16_t fFontSize; uint16_t fFontSize;
uint8_t fFontFlags; uint8_t fFontFlags;
bool fFontAntiAliasRGB; bool fFontAntiAliasRGB;
bool fFontBlockedRGB; bool fFontBlockedRGB;
@ -180,11 +180,11 @@ class plDynSurfaceWriter
COLORREF fTextColor; COLORREF fTextColor;
int fSaveNum; int fSaveNum;
uint16_t fWidth, fHeight; uint16_t fWidth, fHeight;
char *fFontFace; plString fFontFace;
uint16_t fFontSize; uint16_t fFontSize;
uint8_t fFontFlags; uint8_t fFontFlags;
bool fFontAntiAliasRGB, fFontBlockedRGB; bool fFontAntiAliasRGB, fFontBlockedRGB;
plWinSurface(); plWinSurface();
@ -194,8 +194,8 @@ class plDynSurfaceWriter
void Release( void ); void Release( void );
bool WillFit( uint16_t w, uint16_t h ); bool WillFit( uint16_t w, uint16_t h );
bool FontMatches( const char *face, uint16_t size, uint8_t flags, bool aaRGB ); bool FontMatches( const plString &face, uint16_t size, uint8_t flags, bool aaRGB );
void SetFont( const char *face, uint16_t size, uint8_t flags, bool aaRGB ); void SetFont( const plString &face, uint16_t size, uint8_t flags, bool aaRGB );
}; };
class plWinRGBSurface : public plWinSurface class plWinRGBSurface : public plWinSurface

69
Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp

@ -77,7 +77,7 @@ plProfile_Extern(MemMipmaps);
plDynamicTextMap::plDynamicTextMap() plDynamicTextMap::plDynamicTextMap()
: fVisWidth(0), fVisHeight(0), fHasAlpha(false), fJustify(kLeftJustify), : fVisWidth(0), fVisHeight(0), fHasAlpha(false), fJustify(kLeftJustify),
fInitBuffer(nullptr), fFontFace(nullptr), fFontSize(0), fFontFlags(0), fInitBuffer(nullptr), fFontSize(0), fFontFlags(0),
fFontAntiAliasRGB(false), fFontBlockRGB(false), fHasCreateBeenCalled(false) fFontAntiAliasRGB(false), fFontBlockRGB(false), fHasCreateBeenCalled(false)
{ {
fFontColor.Set(0, 0, 0, 1); fFontColor.Set(0, 0, 0, 1);
@ -89,7 +89,7 @@ plDynamicTextMap::~plDynamicTextMap()
} }
plDynamicTextMap::plDynamicTextMap( uint32_t width, uint32_t height, bool hasAlpha, uint32_t extraWidth, uint32_t extraHeight ) plDynamicTextMap::plDynamicTextMap( uint32_t width, uint32_t height, bool hasAlpha, uint32_t extraWidth, uint32_t extraHeight )
: fInitBuffer(nullptr), fFontFace(nullptr) : fInitBuffer(nullptr)
{ {
Create( width, height, hasAlpha, extraWidth, extraHeight ); Create( width, height, hasAlpha, extraWidth, extraHeight );
} }
@ -163,8 +163,7 @@ void plDynamicTextMap::Reset( void )
delete [] fInitBuffer; delete [] fInitBuffer;
fInitBuffer = nil; fInitBuffer = nil;
delete [] fFontFace; fFontFace = plString::Null;
fFontFace = nil;
// Destroy the old texture ref, since we're no longer using it // Destroy the old texture ref, since we're no longer using it
SetDeviceRef( nil ); SetDeviceRef( nil );
@ -413,22 +412,21 @@ void plDynamicTextMap::SetJustify( Justify j )
//// SetFont ////////////////////////////////////////////////////////////////// //// SetFont //////////////////////////////////////////////////////////////////
void plDynamicTextMap::SetFont( const char *face, uint16_t size, uint8_t fontFlags, bool antiAliasRGB ) void plDynamicTextMap::SetFont( const plString &face, uint16_t size, uint8_t fontFlags, bool antiAliasRGB )
{ {
// ===> Don't need to validate creation // ===> Don't need to validate creation
// if( !IIsValid() ) // if( !IIsValid() )
// return; // return;
delete [] fFontFace;
if (plLocalization::UsingUnicode()) if (plLocalization::UsingUnicode())
{ {
// unicode has a bunch of chars that most fonts don't have, so we override the font choice with one // unicode has a bunch of chars that most fonts don't have, so we override the font choice with one
// that will work with the desired language // that will work with the desired language
hsStatusMessageF("We are using a unicode language, overriding font choice of %s", face ? face : "nil"); hsStatusMessageF("We are using a unicode language, overriding font choice of %s", face.c_str("nil"));
fFontFace = hsStrcpy( "Unicode" ); fFontFace = "Unicode";
} }
else else
fFontFace = ( face != nil ) ? hsStrcpy( face ) : nil; fFontFace = face;
fFontSize = size; fFontSize = size;
fFontFlags = fontFlags; fFontFlags = fontFlags;
fFontAntiAliasRGB = antiAliasRGB; fFontAntiAliasRGB = antiAliasRGB;
@ -439,11 +437,9 @@ void plDynamicTextMap::SetFont( const char *face, uint16_t size, uint8_t font
if ( fCurrFont == nil ) if ( fCurrFont == nil )
{ {
if (!fCurrFont) if (!fCurrFont)
hsStatusMessageF("Font missing - %s. Using Arial", fFontFace ? fFontFace : "nil"); hsStatusMessageF("Font missing - %s. Using Arial", fFontFace.c_str("nil"));
if ( fFontFace ) fFontFace = "Arial";
delete [] fFontFace;
fFontFace = hsStrcpy( "Arial" );
// lets try again with Arial // lets try again with Arial
fCurrFont = plFontCache::GetInstance().GetFont( fFontFace, (uint8_t)fFontSize, fCurrFont = plFontCache::GetInstance().GetFont( fFontFace, (uint8_t)fFontSize,
( ( fFontFlags & kFontBold ) ? plFont::kFlagBold : 0 ) | ( ( fFontFlags & kFontBold ) ? plFont::kFlagBold : 0 ) |
@ -458,13 +454,6 @@ void plDynamicTextMap::SetFont( const char *face, uint16_t size, uint8_t font
} }
} }
void plDynamicTextMap::SetFont( const wchar_t *face, uint16_t size, uint8_t fontFlags , bool antiAliasRGB )
{
char *sFace = hsWStringToString(face);
SetFont(sFace,size,fontFlags,antiAliasRGB);
delete [] sFace;
}
//// SetLineSpacing /////////////////////////////////////////////////////////// //// SetLineSpacing ///////////////////////////////////////////////////////////
void plDynamicTextMap::SetLineSpacing( int16_t spacing ) void plDynamicTextMap::SetLineSpacing( int16_t spacing )
@ -515,11 +504,10 @@ void plDynamicTextMap::DrawString( uint16_t x, uint16_t y, const wchar_t *tex
//// DrawClippedString //////////////////////////////////////////////////////// //// DrawClippedString ////////////////////////////////////////////////////////
void plDynamicTextMap::DrawClippedString( int16_t x, int16_t y, const char *text, uint16_t width, uint16_t height ) void plDynamicTextMap::DrawClippedString( int16_t x, int16_t y, const plString &text, uint16_t width, uint16_t height )
{ {
wchar_t *wText = hsStringToWString(text); // TEMP
DrawClippedString(x,y,wText,width,height); DrawClippedString(x, y, text.ToWchar().GetData(), width, height);
delete [] wText;
} }
void plDynamicTextMap::DrawClippedString( int16_t x, int16_t y, const wchar_t *text, uint16_t width, uint16_t height ) void plDynamicTextMap::DrawClippedString( int16_t x, int16_t y, const wchar_t *text, uint16_t width, uint16_t height )
@ -536,11 +524,10 @@ void plDynamicTextMap::DrawClippedString( int16_t x, int16_t y, const wchar_t
//// DrawClippedString //////////////////////////////////////////////////////// //// DrawClippedString ////////////////////////////////////////////////////////
void plDynamicTextMap::DrawClippedString( int16_t x, int16_t y, const char *text, uint16_t clipX, uint16_t clipY, uint16_t width, uint16_t height ) void plDynamicTextMap::DrawClippedString( int16_t x, int16_t y, const plString &text, uint16_t clipX, uint16_t clipY, uint16_t width, uint16_t height )
{ {
wchar_t *wText = hsStringToWString(text); // TEMP
DrawClippedString(x,y,wText,clipX,clipY,width,height); DrawClippedString(x, y, text.ToWchar().GetData(), width, height);
delete [] wText;
} }
void plDynamicTextMap::DrawClippedString( int16_t x, int16_t y, const wchar_t *text, uint16_t clipX, uint16_t clipY, uint16_t width, uint16_t height ) void plDynamicTextMap::DrawClippedString( int16_t x, int16_t y, const wchar_t *text, uint16_t clipX, uint16_t clipY, uint16_t width, uint16_t height )
@ -556,11 +543,10 @@ void plDynamicTextMap::DrawClippedString( int16_t x, int16_t y, const wchar_t
//// DrawWrappedString //////////////////////////////////////////////////////// //// DrawWrappedString ////////////////////////////////////////////////////////
void plDynamicTextMap::DrawWrappedString( uint16_t x, uint16_t y, const char *text, uint16_t width, uint16_t height, uint16_t *lastX, uint16_t *lastY ) void plDynamicTextMap::DrawWrappedString( uint16_t x, uint16_t y, const plString &text, uint16_t width, uint16_t height, uint16_t *lastX, uint16_t *lastY )
{ {
wchar_t *wText = hsStringToWString(text); // TEMP
DrawWrappedString(x,y,wText,width,height,lastX,lastY); DrawWrappedString(x, y, text.ToWchar().GetData(), width, height, lastX, lastY);
delete [] wText;
} }
void plDynamicTextMap::DrawWrappedString( uint16_t x, uint16_t y, const wchar_t *text, uint16_t width, uint16_t height, uint16_t *lastX, uint16_t *lastY ) void plDynamicTextMap::DrawWrappedString( uint16_t x, uint16_t y, const wchar_t *text, uint16_t width, uint16_t height, uint16_t *lastX, uint16_t *lastY )
@ -577,12 +563,10 @@ void plDynamicTextMap::DrawWrappedString( uint16_t x, uint16_t y, const wchar
//// CalcStringWidth ////////////////////////////////////////////////////////// //// CalcStringWidth //////////////////////////////////////////////////////////
uint16_t plDynamicTextMap::CalcStringWidth( const char *text, uint16_t *height ) uint16_t plDynamicTextMap::CalcStringWidth( const plString &text, uint16_t *height )
{ {
wchar_t *wText = hsStringToWString(text); // TEMP
uint16_t w = CalcStringWidth(wText,height); return CalcStringWidth(text.ToWchar().GetData(), height);
delete [] wText;
return w;
} }
uint16_t plDynamicTextMap::CalcStringWidth( const wchar_t *text, uint16_t *height ) uint16_t plDynamicTextMap::CalcStringWidth( const wchar_t *text, uint16_t *height )
@ -614,11 +598,10 @@ void plDynamicTextMap::SetFirstLineIndent( int16_t indent )
//// CalcWrappedStringSize //////////////////////////////////////////////////// //// CalcWrappedStringSize ////////////////////////////////////////////////////
void plDynamicTextMap::CalcWrappedStringSize( const char *text, uint16_t *width, uint16_t *height, uint32_t *firstClippedChar, uint16_t *maxAscent, uint16_t *lastX, uint16_t *lastY ) void plDynamicTextMap::CalcWrappedStringSize( const plString &text, uint16_t *width, uint16_t *height, uint32_t *firstClippedChar, uint16_t *maxAscent, uint16_t *lastX, uint16_t *lastY )
{ {
wchar_t *wText = hsStringToWString(text); // TEMP
CalcWrappedStringSize(wText,width,height,firstClippedChar,maxAscent,lastX,lastY); CalcWrappedStringSize(text.ToWchar().GetData(), width, height, firstClippedChar, maxAscent, lastX, lastY);
delete [] wText;
} }
void plDynamicTextMap::CalcWrappedStringSize( const wchar_t *text, uint16_t *width, uint16_t *height, uint32_t *firstClippedChar, uint16_t *maxAscent, uint16_t *lastX, uint16_t *lastY ) void plDynamicTextMap::CalcWrappedStringSize( const wchar_t *text, uint16_t *width, uint16_t *height, uint32_t *firstClippedChar, uint16_t *maxAscent, uint16_t *lastX, uint16_t *lastY )
@ -816,7 +799,7 @@ bool plDynamicTextMap::MsgReceive( plMessage *msg )
SetTextColor( textMsg->fColor, textMsg->fBlockRGB ); SetTextColor( textMsg->fColor, textMsg->fBlockRGB );
if( (textMsg->fCmd & plDynamicTextMsg::kSetFont ) && !textMsg->fString.IsNull()) if( (textMsg->fCmd & plDynamicTextMsg::kSetFont ) && !textMsg->fString.IsNull())
SetFont( textMsg->fString.ToWchar(), textMsg->fX, (uint8_t)(textMsg->fFlags) ); SetFont( textMsg->fString, textMsg->fX, (uint8_t)(textMsg->fFlags) );
if( textMsg->fCmd & plDynamicTextMsg::kSetLineSpacing ) if( textMsg->fCmd & plDynamicTextMsg::kSetLineSpacing )
SetLineSpacing( textMsg->fLineSpacing ); SetLineSpacing( textMsg->fLineSpacing );
@ -902,7 +885,7 @@ void plDynamicTextMap::Swap( plDynamicTextMap *other )
SWAP_ME( bool, fShadowed, other->fShadowed ); SWAP_ME( bool, fShadowed, other->fShadowed );
SWAP_ME( Justify, fJustify, other->fJustify ); SWAP_ME( Justify, fJustify, other->fJustify );
SWAP_ME( char *, fFontFace, other->fFontFace ); SWAP_ME( plString, fFontFace, other->fFontFace );
SWAP_ME( uint16_t, fFontSize, other->fFontSize ); SWAP_ME( uint16_t, fFontSize, other->fFontSize );
SWAP_ME( uint8_t, fFontFlags, other->fFontFlags ); SWAP_ME( uint8_t, fFontFlags, other->fFontFlags );
SWAP_ME( bool, fFontAntiAliasRGB, other->fFontAntiAliasRGB ); SWAP_ME( bool, fFontAntiAliasRGB, other->fFontAntiAliasRGB );

23
Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.h

@ -152,23 +152,22 @@ class plDynamicTextMap : public plMipmap
kFontShadowed = 0x04 kFontShadowed = 0x04
}; };
void SetFont( const char *face, uint16_t size, uint8_t fontFlags = 0, bool antiAliasRGB = true ); void SetFont( const plString &face, uint16_t size, uint8_t fontFlags = 0, bool antiAliasRGB = true );
void SetFont( const wchar_t *face, uint16_t size, uint8_t fontFlags = 0, bool antiAliasRGB = true );
void SetLineSpacing( int16_t spacing ); void SetLineSpacing( int16_t spacing );
void SetTextColor( hsColorRGBA &color, bool blockRGB = false ); void SetTextColor( hsColorRGBA &color, bool blockRGB = false );
void SetJustify( Justify j ); void SetJustify( Justify j );
void DrawString( uint16_t x, uint16_t y, const char *text ); void DrawString( uint16_t x, uint16_t y, const char *text );
void DrawString( uint16_t x, uint16_t y, const wchar_t *text ); void DrawString( uint16_t x, uint16_t y, const wchar_t *text );
void DrawClippedString( int16_t x, int16_t y, const char *text, uint16_t width, uint16_t height ); void DrawClippedString( int16_t x, int16_t y, const plString &text, uint16_t width, uint16_t height );
void DrawClippedString( int16_t x, int16_t y, const wchar_t *text, uint16_t width, uint16_t height ); void DrawClippedString( int16_t x, int16_t y, const wchar_t *text, uint16_t width, uint16_t height );
void DrawClippedString( int16_t x, int16_t y, const char *text, uint16_t clipX, uint16_t clipY, uint16_t width, uint16_t height ); void DrawClippedString( int16_t x, int16_t y, const plString &text, uint16_t clipX, uint16_t clipY, uint16_t width, uint16_t height );
void DrawClippedString( int16_t x, int16_t y, const wchar_t *text, uint16_t clipX, uint16_t clipY, uint16_t width, uint16_t height ); void DrawClippedString( int16_t x, int16_t y, const wchar_t *text, uint16_t clipX, uint16_t clipY, uint16_t width, uint16_t height );
void DrawWrappedString( uint16_t x, uint16_t y, const char *text, uint16_t width, uint16_t height, uint16_t *lastX = nil, uint16_t *lastY = nil ); void DrawWrappedString( uint16_t x, uint16_t y, const plString &text, uint16_t width, uint16_t height, uint16_t *lastX = nil, uint16_t *lastY = nil );
void DrawWrappedString( uint16_t x, uint16_t y, const wchar_t *text, uint16_t width, uint16_t height, uint16_t *lastX = nil, uint16_t *lastY = nil ); void DrawWrappedString( uint16_t x, uint16_t y, const wchar_t *text, uint16_t width, uint16_t height, uint16_t *lastX = nil, uint16_t *lastY = nil );
uint16_t CalcStringWidth( const char *text, uint16_t *height = nil ); uint16_t CalcStringWidth( const plString &text, uint16_t *height = nil );
uint16_t CalcStringWidth( const wchar_t *text, uint16_t *height = nil ); uint16_t CalcStringWidth( const wchar_t *text, uint16_t *height = nil );
void CalcWrappedStringSize( const char *text, uint16_t *width, uint16_t *height, uint32_t *firstClippedChar = nil, uint16_t *maxAscent = nil, uint16_t *lastX = nil, uint16_t *lastY = nil ); void CalcWrappedStringSize( const plString &text, uint16_t *width, uint16_t *height, uint32_t *firstClippedChar = nil, uint16_t *maxAscent = nil, uint16_t *lastX = nil, uint16_t *lastY = nil );
void CalcWrappedStringSize( const wchar_t *text, uint16_t *width, uint16_t *height, uint32_t *firstClippedChar = nil, uint16_t *maxAscent = nil, uint16_t *lastX = nil, uint16_t *lastY = nil ); void CalcWrappedStringSize( const wchar_t *text, uint16_t *width, uint16_t *height, uint32_t *firstClippedChar = nil, uint16_t *maxAscent = nil, uint16_t *lastX = nil, uint16_t *lastY = nil );
void FillRect( uint16_t x, uint16_t y, uint16_t width, uint16_t height, hsColorRGBA &color ); void FillRect( uint16_t x, uint16_t y, uint16_t width, uint16_t height, hsColorRGBA &color );
void FrameRect( uint16_t x, uint16_t y, uint16_t width, uint16_t height, hsColorRGBA &color ); void FrameRect( uint16_t x, uint16_t y, uint16_t width, uint16_t height, hsColorRGBA &color );
@ -201,8 +200,8 @@ class plDynamicTextMap : public plMipmap
// Gets for font values // Gets for font values
Justify GetFontJustify( void ) const { return fJustify; } Justify GetFontJustify( void ) const { return fJustify; }
const char *GetFontFace( void ) const { return fFontFace; } plString GetFontFace( void ) const { return fFontFace; }
uint16_t GetFontSize( void ) const { return fFontSize; } uint16_t GetFontSize( void ) const { return fFontSize; }
bool GetFontAARGB( void ) const { return fFontAntiAliasRGB; } bool GetFontAARGB( void ) const { return fFontAntiAliasRGB; }
hsColorRGBA GetFontColor( void ) const { return fFontColor; } hsColorRGBA GetFontColor( void ) const { return fFontColor; }
bool GetFontBlockRGB( void ) const { return fFontBlockRGB; } bool GetFontBlockRGB( void ) const { return fFontBlockRGB; }
@ -225,9 +224,9 @@ class plDynamicTextMap : public plMipmap
bool fHasAlpha, fShadowed; bool fHasAlpha, fShadowed;
Justify fJustify; Justify fJustify;
char *fFontFace; plString fFontFace;
uint16_t fFontSize; uint16_t fFontSize;
uint8_t fFontFlags; uint8_t fFontFlags;
bool fFontAntiAliasRGB; bool fFontAntiAliasRGB;
hsColorRGBA fFontColor; hsColorRGBA fFontColor;
bool fFontBlockRGB; bool fFontBlockRGB;

44
Sources/Plasma/PubUtilLib/plGImage/plFont.cpp

@ -117,7 +117,7 @@ void plFont::IClear( bool onConstruct )
if( !onConstruct ) if( !onConstruct )
delete [] fBMapData; delete [] fBMapData;
memset( fFace, 0, sizeof( fFace ) ); fFace = plString::Null;
fSize = 0; fSize = 0;
fFlags = 0; fFlags = 0;
@ -141,16 +141,6 @@ void plFont::IClear( bool onConstruct )
fRenderInfo.fLineSpacing = 0; fRenderInfo.fLineSpacing = 0;
} }
void plFont::SetFace( const char *face )
{
strncpy( fFace, face, sizeof( fFace ) );
}
void plFont::SetSize( uint8_t size )
{
fSize = size;
}
void plFont::Read( hsStream *s, hsResMgr *mgr ) void plFont::Read( hsStream *s, hsResMgr *mgr )
{ {
hsKeyedObject::Read( s, mgr ); hsKeyedObject::Read( s, mgr );
@ -232,12 +222,10 @@ static inline bool IIsDrawableWordBreak( const char c )
// The base render function. Additional options are specified externally, // The base render function. Additional options are specified externally,
// so that their effects can be cached for optimization // so that their effects can be cached for optimization
void plFont::RenderString( plMipmap *mip, uint16_t x, uint16_t y, const char *string, uint16_t *lastX, uint16_t *lastY ) void plFont::RenderString( plMipmap *mip, uint16_t x, uint16_t y, const plString &string, uint16_t *lastX, uint16_t *lastY )
{ {
// convert the char string to a wchar_t string // TEMP
wchar_t *wideString = hsStringToWString(string); RenderString(mip, x, y, string.ToWchar().GetData(), lastX, lastY);
RenderString(mip,x,y,wideString,lastX,lastY);
delete [] wideString;
} }
@ -990,7 +978,7 @@ void plFont::IRenderCharNull( const plCharacter &c )
//// CalcString Variations //////////////////////////////////////////////////// //// CalcString Variations ////////////////////////////////////////////////////
uint16_t plFont::CalcStringWidth( const char *string ) uint16_t plFont::CalcStringWidth( const plString &string )
{ {
uint16_t w, h, a, lX, lY; uint16_t w, h, a, lX, lY;
uint32_t s; uint32_t s;
@ -1006,12 +994,10 @@ uint16_t plFont::CalcStringWidth( const wchar_t *string )
return w; return w;
} }
void plFont::CalcStringExtents( const char *string, uint16_t &width, uint16_t &height, uint16_t &ascent, uint32_t &firstClippedChar, uint16_t &lastX, uint16_t &lastY ) void plFont::CalcStringExtents( const plString &string, uint16_t &width, uint16_t &height, uint16_t &ascent, uint32_t &firstClippedChar, uint16_t &lastX, uint16_t &lastY )
{ {
// convert the char string to a wchar_t string // convert the char string to a wchar_t string
wchar_t *wideString = hsStringToWString(string); CalcStringExtents(string.ToWchar().GetData(), width, height, ascent, firstClippedChar, lastX, lastY);
CalcStringExtents(wideString,width,height,ascent,firstClippedChar,lastX,lastY);
delete [] wideString;
} }
void plFont::CalcStringExtents( const wchar_t *string, uint16_t &width, uint16_t &height, uint16_t &ascent, uint32_t &firstClippedChar, uint16_t &lastX, uint16_t &lastY ) void plFont::CalcStringExtents( const wchar_t *string, uint16_t &width, uint16_t &height, uint16_t &ascent, uint32_t &firstClippedChar, uint16_t &lastX, uint16_t &lastY )
@ -1197,7 +1183,7 @@ bool plFont::LoadFromFNTStream( hsStream *stream )
charEntries[ i ].offset = stream->ReadLE32(); charEntries[ i ].offset = stream->ReadLE32();
} }
char faceName[ 256 ], deviceName[ 256 ]; char faceName[ 257 ], deviceName[ 256 ];
if( fntInfo.face != 0 ) if( fntInfo.face != 0 )
{ {
stream->SetPosition( fntInfo.face ); stream->SetPosition( fntInfo.face );
@ -1207,7 +1193,8 @@ bool plFont::LoadFromFNTStream( hsStream *stream )
if( faceName[ i ] == 0 ) if( faceName[ i ] == 0 )
break; break;
} }
strncpy( fFace, faceName, sizeof( fFace ) ); faceName[256] = 0;
fFace = faceName;
} }
if( fntInfo.device != 0 ) if( fntInfo.device != 0 )
{ {
@ -1926,7 +1913,11 @@ bool plFont::LoadFromBDF( const char *path, plBDFConvertCallback *callback )
bool plFont::ReadRaw( hsStream *s ) bool plFont::ReadRaw( hsStream *s )
{ {
s->Read( sizeof( fFace ), fFace ); char face_buf[257];
s->Read(256, face_buf);
face_buf[256] = 0;
fFace = face_buf;
fSize = s->ReadByte(); fSize = s->ReadByte();
s->ReadLE( &fFlags ); s->ReadLE( &fFlags );
@ -1959,7 +1950,10 @@ bool plFont::ReadRaw( hsStream *s )
bool plFont::WriteRaw( hsStream *s ) bool plFont::WriteRaw( hsStream *s )
{ {
s->Write( sizeof( fFace ), fFace ); char face_buf[256] = { 0 };
memcpy(face_buf, fFace.c_str(), fFace.GetSize() * sizeof(char));
s->Write(sizeof(face_buf), face_buf);
s->WriteByte( fSize ); s->WriteByte( fSize );
s->WriteLE( fFlags ); s->WriteLE( fFlags );

26
Sources/Plasma/PubUtilLib/plGImage/plFont.h

@ -131,7 +131,7 @@ class plFont : public hsKeyedObject
friend class plBDFCharsParser; friend class plBDFCharsParser;
// Font face and size. This is just used for IDing purposes, not for rendering // Font face and size. This is just used for IDing purposes, not for rendering
char fFace[ 256 ]; plString fFace;
uint8_t fSize; uint8_t fSize;
uint32_t fFlags; uint32_t fFlags;
@ -244,20 +244,20 @@ class plFont : public hsKeyedObject
virtual void Read( hsStream *s, hsResMgr *mgr ); virtual void Read( hsStream *s, hsResMgr *mgr );
virtual void Write( hsStream *s, hsResMgr *mgr ); virtual void Write( hsStream *s, hsResMgr *mgr );
const char *GetFace( void ) const { return fFace; } plString GetFace( void ) const { return fFace; }
uint8_t GetSize( void ) const { return fSize; } uint8_t GetSize( void ) const { return fSize; }
uint16_t GetFirstChar( void ) const { return fFirstChar; } uint16_t GetFirstChar( void ) const { return fFirstChar; }
uint16_t GetNumChars( void ) const { return fCharacters.GetCount(); } uint16_t GetNumChars( void ) const { return fCharacters.GetCount(); }
uint32_t GetFlags( void ) const { return fFlags; } uint32_t GetFlags( void ) const { return fFlags; }
float GetDescent( void ) const { return (float)fFontDescent; } float GetDescent( void ) const { return (float)fFontDescent; }
float GetAscent( void ) const { return (float)fFontAscent; } float GetAscent( void ) const { return (float)fFontAscent; }
uint32_t GetBitmapWidth( void ) const { return fWidth; } uint32_t GetBitmapWidth( void ) const { return fWidth; }
uint32_t GetBitmapHeight( void ) const { return fHeight; } uint32_t GetBitmapHeight( void ) const { return fHeight; }
uint8_t GetBitmapBPP( void ) const { return fBPP; } uint8_t GetBitmapBPP( void ) const { return fBPP; }
void SetFace( const char *face ); void SetFace( const plString &face ) { fFace = face; }
void SetSize( uint8_t size ); void SetSize( uint8_t size ) { fSize = size; }
void SetFlags( uint32_t flags ) { fFlags = flags; } void SetFlags( uint32_t flags ) { fFlags = flags; }
void SetFlag( uint32_t flag, bool on ) { if( on ) fFlags |= flag; else fFlags &= ~flag; } void SetFlag( uint32_t flag, bool on ) { if( on ) fFlags |= flag; else fFlags &= ~flag; }
bool IsFlagSet( uint32_t flag ) { if( fFlags & flag ) return true; return false; } bool IsFlagSet( uint32_t flag ) { if( fFlags & flag ) return true; return false; }
@ -275,12 +275,12 @@ class plFont : public hsKeyedObject
void SetRenderClipping( int16_t x, int16_t y, int16_t width, int16_t height ); void SetRenderClipping( int16_t x, int16_t y, int16_t width, int16_t height );
void SetRenderWrapping( int16_t x, int16_t y, int16_t width, int16_t height ); void SetRenderWrapping( int16_t x, int16_t y, int16_t width, int16_t height );
void RenderString( plMipmap *mip, uint16_t x, uint16_t y, const char *string, uint16_t *lastX = nil, uint16_t *lastY = nil ); void RenderString( plMipmap *mip, uint16_t x, uint16_t y, const plString &string, uint16_t *lastX = nil, uint16_t *lastY = nil );
void RenderString( plMipmap *mip, uint16_t x, uint16_t y, const wchar_t *string, uint16_t *lastX = nil, uint16_t *lastY = nil ); void RenderString( plMipmap *mip, uint16_t x, uint16_t y, const wchar_t *string, uint16_t *lastX = nil, uint16_t *lastY = nil );
uint16_t CalcStringWidth( const char *string ); uint16_t CalcStringWidth( const plString &string );
uint16_t CalcStringWidth( const wchar_t *string ); uint16_t CalcStringWidth( const wchar_t *string );
void CalcStringExtents( const char *string, uint16_t &width, uint16_t &height, uint16_t &ascent, uint32_t &firstClippedChar, uint16_t &lastX, uint16_t &lastY ); void CalcStringExtents( const plString &string, uint16_t &width, uint16_t &height, uint16_t &ascent, uint32_t &firstClippedChar, uint16_t &lastX, uint16_t &lastY );
void CalcStringExtents( const wchar_t *string, uint16_t &width, uint16_t &height, uint16_t &ascent, uint32_t &firstClippedChar, uint16_t &lastX, uint16_t &lastY ); void CalcStringExtents( const wchar_t *string, uint16_t &width, uint16_t &height, uint16_t &ascent, uint32_t &firstClippedChar, uint16_t &lastX, uint16_t &lastY );
bool LoadFromFNT( const char *path ); bool LoadFromFNT( const char *path );

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

@ -89,23 +89,16 @@ void plFontCache::Clear( void )
{ {
} }
plFont *plFontCache::GetFont( const char *face, uint8_t size, uint32_t fontFlags ) plFont *plFontCache::GetFont( const plString &face, uint8_t size, uint32_t fontFlags )
{ {
uint32_t i, currIdx = (uint32_t)-1; uint32_t i, currIdx = (uint32_t)-1;
int currDeltaSize = 100000; int currDeltaSize = 100000;
char toFind[ 256 ];
strcpy( toFind, face );
strlwr( toFind );
for( i = 0; i < fCache.GetCount(); i++ ) for( i = 0; i < fCache.GetCount(); i++ )
{ {
char thisOne[ 256 ]; if (fCache[i]->GetFace().CompareNI(face, face.GetSize()) == 0 &&
strcpy( thisOne, fCache[ i ]->GetFace() ); (fCache[i]->GetFlags() == fontFlags))
strlwr( thisOne );
if( strncmp( thisOne, toFind, strlen( toFind ) ) == 0 &&
( fCache[ i ]->GetFlags() == fontFlags ) )
{ {
int delta = fCache[ i ]->GetSize() - size; int delta = fCache[ i ]->GetSize() - size;
if( delta < 0 ) if( delta < 0 )
@ -125,18 +118,17 @@ plFont *plFontCache::GetFont( const char *face, uint8_t size, uint32_t fontFlag
return fCache[ currIdx ]; return fCache[ currIdx ];
} }
// If we failed, it's possible we have a face saved as "Times", for example, and someone's // If we failed, it's possible we have a face saved as "Times", for example, and someone's
// asking for "Times New Roman", so strip all but the first uint16_t from our font and try the search again // asking for "Times New Roman", so strip all but the first word from our font and try the search again
char *c = strchr( toFind, ' ' ); ssize_t sp = face.Find(' ');
if( c != nil ) if (sp >= 0)
{ {
*c = 0; return GetFont(face.Left(sp), size, fontFlags);
return GetFont( toFind, size, fontFlags );
} }
else if( fontFlags != 0 ) else if( fontFlags != 0 )
{ {
// Hmm, well ok, just to be nice, try without our flags // Hmm, well ok, just to be nice, try without our flags
plFont *f = GetFont( toFind, size, 0 ); plFont *f = GetFont( face, size, 0 );
if( f != nil ) if( f != nil )
{ {
//plStatusLog::AddLineS( "pipeline.log", "Warning: plFontCache is substituting %s %d regular (flags 0x%x could not be matched)", f->GetFace(), f->GetSize(), fontFlags ); //plStatusLog::AddLineS( "pipeline.log", "Warning: plFontCache is substituting %s %d regular (flags 0x%x could not be matched)", f->GetFace(), f->GetSize(), fontFlags );
@ -171,7 +163,7 @@ void plFontCache::ILoadCustomFonts( void )
plString keyName; plString keyName;
if (font->GetKey() == nil) if (font->GetKey() == nil)
{ {
keyName = plString::Format( "%s-%d", font->GetFace(), font->GetSize() ); keyName = plString::Format( "%s-%d", font->GetFace().c_str(), font->GetSize() );
hsgResMgr::ResMgr()->NewKey( keyName, font, plLocation::kGlobalFixedLoc ); hsgResMgr::ResMgr()->NewKey( keyName, font, plLocation::kGlobalFixedLoc );
} }

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

@ -91,7 +91,7 @@ class plFontCache : public hsKeyedObject
static plFontCache &GetInstance( void ); static plFontCache &GetInstance( void );
plFont *GetFont( const char *face, uint8_t size, uint32_t fontFlags ); plFont *GetFont( const plString &face, uint8_t size, uint32_t fontFlags );
// HFONT GetMeAFont( const char *face, int height, int weight, bool italic, uint32_t quality ); // HFONT GetMeAFont( const char *face, int height, int weight, bool italic, uint32_t quality );
// void FreeFont( HFONT font ); // void FreeFont( HFONT font );

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

@ -92,7 +92,7 @@ plWinFontCache &plWinFontCache::GetInstance( void )
return cache; return cache;
} }
HFONT plWinFontCache::IFindFont( const char *face, int height, int weight, bool italic, uint32_t quality ) HFONT plWinFontCache::IFindFont( const plString &face, int height, int weight, bool italic, uint32_t quality )
{ {
int i; int i;
@ -105,7 +105,7 @@ HFONT plWinFontCache::IFindFont( const char *face, int height, int weight, boo
fFontCache[ i ].fItalic == italic && fFontCache[ i ].fItalic == italic &&
fFontCache[ i ].fQuality == quality ) fFontCache[ i ].fQuality == quality )
{ {
if( strcmp( fFontCache[ i ].fFace, face ) == 0 ) if (fFontCache[i].fFace == face)
return fFontCache[ i ].fFont; return fFontCache[ i ].fFont;
} }
} }
@ -113,7 +113,7 @@ HFONT plWinFontCache::IFindFont( const char *face, int height, int weight, boo
return nil; return nil;
} }
HFONT plWinFontCache::IMakeFont( const char *face, int height, int weight, bool italic, uint32_t quality ) HFONT plWinFontCache::IMakeFont( const plString &face, int height, int weight, bool italic, uint32_t quality )
{ {
plFontRecord myRec; plFontRecord myRec;
int i; int i;
@ -122,12 +122,12 @@ HFONT plWinFontCache::IMakeFont( const char *face, int height, int weight, boo
// Find a cached name for us // Find a cached name for us
for( i = 0; i < fFontNameCache.GetCount(); i++ ) for( i = 0; i < fFontNameCache.GetCount(); i++ )
{ {
if( strcmp( face, fFontNameCache[ i ] ) == 0 ) if (face == fFontNameCache[i])
break; break;
} }
if( i == fFontNameCache.GetCount() ) if( i == fFontNameCache.GetCount() )
fFontNameCache.Append( hsStrcpy( face ) ); fFontNameCache.Append(face);
myRec.fFace = fFontNameCache[ i ]; myRec.fFace = fFontNameCache[ i ];
myRec.fHeight = height; myRec.fHeight = height;
@ -135,8 +135,8 @@ HFONT plWinFontCache::IMakeFont( const char *face, int height, int weight, boo
myRec.fItalic = italic; myRec.fItalic = italic;
myRec.fQuality = quality; myRec.fQuality = quality;
myRec.fFont = CreateFont( height, 0, 0, 0, weight, italic ? TRUE : FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, myRec.fFont = CreateFontW( height, 0, 0, 0, weight, italic ? TRUE : FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH, face ); CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH, face.ToWchar().GetData() );
if( myRec.fFont != nil ) if( myRec.fFont != nil )
{ {
@ -156,7 +156,7 @@ HFONT plWinFontCache::IMakeFont( const char *face, int height, int weight, boo
err = "Weight of created font does not match"; err = "Weight of created font does not match";
if( static_cast<bool>(fontInfo.lfItalic) != italic ) if( static_cast<bool>(fontInfo.lfItalic) != italic )
err = "Italic-ness of created font does not match"; err = "Italic-ness of created font does not match";
if( stricmp( fontInfo.lfFaceName, face ) != 0 ) if( face.CompareI(fontInfo.lfFaceName) != 0 )
err = "Face of created font does not match"; err = "Face of created font does not match";
if( err != nil ) if( err != nil )
@ -199,13 +199,14 @@ HFONT plWinFontCache::IMakeFont( const char *face, int height, int weight, boo
} }
else else
{ {
plStatusLog::AddLineS( "pipeline.log", "ERROR: CreateFont() call FAILED (face: %s, size: %d %s %s)", face, -height, weight == FW_BOLD ? "bold" : "", italic ? "italic" : "" ); plStatusLog::AddLineS( "pipeline.log", "ERROR: CreateFont() call FAILED (face: %s, size: %d %s %s)",
face.c_str(), -height, weight == FW_BOLD ? "bold" : "", italic ? "italic" : "" );
} }
return myRec.fFont; return myRec.fFont;
} }
HFONT plWinFontCache::GetMeAFont( const char *face, int height, int weight, bool italic, uint32_t quality ) HFONT plWinFontCache::GetMeAFont( const plString &face, int height, int weight, bool italic, uint32_t quality )
{ {
HFONT font = IFindFont( face, height, weight, italic, quality ); HFONT font = IFindFont( face, height, weight, italic, quality );
if( font == nil ) if( font == nil )
@ -226,8 +227,6 @@ void plWinFontCache::Clear( void )
DeleteObject( fFontCache[ i ].fFont ); DeleteObject( fFontCache[ i ].fFont );
fFontCache.Reset(); fFontCache.Reset();
for( i = 0; i < fFontNameCache.GetCount(); i++ )
delete [] fFontNameCache[ i ];
fFontNameCache.Reset(); fFontNameCache.Reset();
for( i = 0; i < fCustFonts.GetCount(); i++ ) for( i = 0; i < fCustFonts.GetCount(); i++ )

10
Sources/Plasma/PubUtilLib/plGImage/plWinFontCache.h

@ -80,7 +80,7 @@ class plWinFontCache
public: public:
HFONT fFont; HFONT fFont;
char *fFace; // Pointer is owned by fFontNameCache plString fFace;
int fHeight; int fHeight;
int fWeight; int fWeight;
bool fItalic; bool fItalic;
@ -98,15 +98,15 @@ class plWinFontCache
bool fInShutdown; bool fInShutdown;
hsTArray<plFontRecord> fFontCache; hsTArray<plFontRecord> fFontCache;
hsTArray<char *> fFontNameCache; hsTArray<plString> fFontNameCache;
char *fCustFontDir; char *fCustFontDir;
hsTArray<plCustFont *> fCustFonts; hsTArray<plCustFont *> fCustFonts;
plWinFontCache(); plWinFontCache();
HFONT IFindFont( const char *face, int height, int weight, bool italic, uint32_t quality ); HFONT IFindFont( const plString &face, int height, int weight, bool italic, uint32_t quality );
HFONT IMakeFont( const char *face, int height, int weight, bool italic, uint32_t quality ); HFONT IMakeFont( const plString &face, int height, int weight, bool italic, uint32_t quality );
void ILoadCustomFonts( void ); void ILoadCustomFonts( void );
@ -115,7 +115,7 @@ class plWinFontCache
virtual ~plWinFontCache(); virtual ~plWinFontCache();
static plWinFontCache &GetInstance( void ); static plWinFontCache &GetInstance( void );
HFONT GetMeAFont( const char *face, int height, int weight, bool italic, uint32_t quality ); HFONT GetMeAFont( const plString &face, int height, int weight, bool italic, uint32_t quality );
void FreeFont( HFONT font ); void FreeFont( HFONT font );
void Clear( void ); void Clear( void );

11
Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp

@ -108,7 +108,6 @@ bool plSceneInputInterface::fShowLOS = false;
plSceneInputInterface::plSceneInputInterface() plSceneInputInterface::plSceneInputInterface()
{ {
fPipe = nil; fPipe = nil;
fSpawnPoint = nil;
fAgeInstanceGuid.Clear(); fAgeInstanceGuid.Clear();
fInstance = this; fInstance = this;
SetEnabled( true ); // Always enabled SetEnabled( true ); // Always enabled
@ -840,11 +839,11 @@ void plSceneInputInterface::ILinkOffereeToAge()
unsigned nameLen = plNetClientMgr::GetInstance()->GetPlayerName().GetSize(); unsigned nameLen = plNetClientMgr::GetInstance()->GetPlayerName().GetSize();
if (plNetClientMgr::GetInstance()->GetPlayerName().CharAt(nameLen - 1) == 's' || plNetClientMgr::GetInstance()->GetPlayerName().CharAt(nameLen - 1) == 'S') { if (plNetClientMgr::GetInstance()->GetPlayerName().CharAt(nameLen - 1) == 's' || plNetClientMgr::GetInstance()->GetPlayerName().CharAt(nameLen - 1) == 'S') {
title = plString::Format( "%s'", plNetClientMgr::GetInstance()->GetPlayerName().c_str() ); title = plString::Format( "%s'", plNetClientMgr::GetInstance()->GetPlayerName().c_str() );
desc = plString::Format( "%s' %s", plNetClientMgr::GetInstance()->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() ); desc = plString::Format( "%s' %s", plNetClientMgr::GetInstance()->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName().c_str() );
} }
else { else {
title = plString::Format( "%s's", plNetClientMgr::GetInstance()->GetPlayerName().c_str() ); title = plString::Format( "%s's", plNetClientMgr::GetInstance()->GetPlayerName().c_str() );
desc = plString::Format( "%s's %s", plNetClientMgr::GetInstance()->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() ); desc = plString::Format( "%s's %s", plNetClientMgr::GetInstance()->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName().c_str() );
} }
info.SetAgeUserDefinedName( title.c_str() ); info.SetAgeUserDefinedName( title.c_str() );
@ -869,7 +868,7 @@ void plSceneInputInterface::ILinkOffereeToAge()
linkNode->DecRef(); linkNode->DecRef();
} }
if (fSpawnPoint) { if (!fSpawnPoint.IsEmpty()) {
plSpawnPointInfo spawnPoint; plSpawnPointInfo spawnPoint;
spawnPoint.SetName(fSpawnPoint); spawnPoint.SetName(fSpawnPoint);
link.SetSpawnPoint(spawnPoint); link.SetSpawnPoint(spawnPoint);
@ -878,12 +877,12 @@ void plSceneInputInterface::ILinkOffereeToAge()
// We now own the age, offer it // We now own the age, offer it
if (0 == stricmp(fOfferedAgeFile, kPersonalAgeFilename)) if (fOfferedAgeFile.CompareI(kPersonalAgeFilename) == 0)
plNetLinkingMgr::GetInstance()->OfferLinkToPlayer(&link, fOffereeID, fManager->GetKey()); plNetLinkingMgr::GetInstance()->OfferLinkToPlayer(&link, fOffereeID, fManager->GetKey());
else else
plNetLinkingMgr::GetInstance()->LinkPlayerToAge(&link, fOffereeID); plNetLinkingMgr::GetInstance()->LinkPlayerToAge(&link, fOffereeID);
if (!fPendingLink && stricmp(fOfferedAgeFile, kPersonalAgeFilename)) if (!fPendingLink && fOfferedAgeFile.CompareI(kPersonalAgeFilename) != 0)
{ {
// tell our local dialog to pop up again... // tell our local dialog to pop up again...
plKey avKey = plNetClientMgr::GetInstance()->GetLocalPlayerKey(); plKey avKey = plNetClientMgr::GetInstance()->GetLocalPlayerKey();

8
Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.h

@ -82,10 +82,10 @@ class plSceneInputInterface : public plInputInterface
int fBookMode; // are we in offer book mode? int fBookMode; // are we in offer book mode?
plKey fBookKey; // key for the python file modifier for the book we are offering plKey fBookKey; // key for the python file modifier for the book we are offering
plKey fOffereeKey; plKey fOffereeKey;
uint32_t fOffereeID; // ID for the guy who's accepted our link offer uint32_t fOffereeID; // ID for the guy who's accepted our link offer
const char* fOfferedAgeFile; plString fOfferedAgeFile;
const char* fOfferedAgeInstance; plString fOfferedAgeInstance;
const char* fSpawnPoint; plString fSpawnPoint;
plUUID fAgeInstanceGuid; plUUID fAgeInstanceGuid;
struct clickableTest struct clickableTest
{ {

7
Sources/Plasma/PubUtilLib/plMessage/plAIMsg.cpp

@ -68,17 +68,14 @@ void plAIMsg::Read(hsStream* stream, hsResMgr* mgr)
{ {
plMessage::IMsgRead(stream, mgr); plMessage::IMsgRead(stream, mgr);
char* temp = stream->ReadSafeString(); fBrainUserStr = stream->ReadSafeString();
if (temp)
fBrainUserStr = temp;
delete [] temp;
} }
void plAIMsg::Write(hsStream* stream, hsResMgr* mgr) void plAIMsg::Write(hsStream* stream, hsResMgr* mgr)
{ {
plMessage::IMsgWrite(stream, mgr); plMessage::IMsgWrite(stream, mgr);
stream->WriteSafeString(fBrainUserStr.c_str()); stream->WriteSafeString(fBrainUserStr);
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

6
Sources/Plasma/PubUtilLib/plMessage/plAIMsg.h

@ -63,8 +63,8 @@ public:
virtual void Read(hsStream* stream, hsResMgr* mgr); virtual void Read(hsStream* stream, hsResMgr* mgr);
virtual void Write(hsStream* stream, hsResMgr* mgr); virtual void Write(hsStream* stream, hsResMgr* mgr);
void BrainUserString(const std::string& userStr) {fBrainUserStr = userStr;} void BrainUserString(const plString& userStr) {fBrainUserStr = userStr;}
std::string BrainUserString() const {return fBrainUserStr;} plString BrainUserString() const {return fBrainUserStr;}
// enum for all messages to make things easier for people that use us // enum for all messages to make things easier for people that use us
enum enum
@ -75,7 +75,7 @@ public:
}; };
private: private:
std::string fBrainUserStr; plString fBrainUserStr;
}; };
// message spammed to anyone listening so they can grab the brain's key and talk to it // message spammed to anyone listening so they can grab the brain's key and talk to it

6
Sources/Plasma/PubUtilLib/plMessage/plAnimCmdMsg.cpp

@ -86,8 +86,8 @@ void plAnimCmdMsg::Read(hsStream* stream, hsResMgr* mgr)
stream->ReadLE(&fSpeedChangeRate); stream->ReadLE(&fSpeedChangeRate);
stream->ReadLE(&fTime); stream->ReadLE(&fTime);
fAnimName = stream->ReadSafeString_TEMP(); fAnimName = stream->ReadSafeString();
fLoopName = stream->ReadSafeString_TEMP(); fLoopName = stream->ReadSafeString();
} }
void plAnimCmdMsg::Write(hsStream* stream, hsResMgr* mgr) void plAnimCmdMsg::Write(hsStream* stream, hsResMgr* mgr)
@ -134,7 +134,7 @@ void plAGCmdMsg::Read(hsStream* stream, hsResMgr* mgr)
stream->ReadLE(&fAmp); stream->ReadLE(&fAmp);
stream->ReadLE(&fAmpRate); stream->ReadLE(&fAmpRate);
fAnimName = stream->ReadSafeString_TEMP(); fAnimName = stream->ReadSafeString();
} }
void plAGCmdMsg::Write(hsStream* stream, hsResMgr* mgr) void plAGCmdMsg::Write(hsStream* stream, hsResMgr* mgr)

2
Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.cpp

@ -313,7 +313,7 @@ void plAvOneShotMsg::Read(hsStream *stream, hsResMgr *mgr)
{ {
plAvSeekMsg::Read(stream, mgr); plAvSeekMsg::Read(stream, mgr);
fAnimName = stream->ReadSafeString_TEMP(); fAnimName = stream->ReadSafeString();
fDrivable = stream->ReadBool(); fDrivable = stream->ReadBool();
fReversible = stream->ReadBool(); fReversible = stream->ReadBool();
} }

4
Sources/Plasma/PubUtilLib/plMessage/plDynamicTextMsg.cpp

@ -216,7 +216,7 @@ void plDynamicTextMsg::Read( hsStream *s, hsResMgr *mgr )
fClearColor.Read( s ); fClearColor.Read( s );
fColor.Read( s ); fColor.Read( s );
fString = s->ReadSafeWString_TEMP(); fString = s->ReadSafeWString();
fImageKey = mgr->ReadKey( s ); fImageKey = mgr->ReadKey( s );
s->ReadLE( &fFlags ); s->ReadLE( &fFlags );
@ -301,7 +301,7 @@ void plDynamicTextMsg::ReadVersion(hsStream* s, hsResMgr* mgr)
if (contentFlags.IsBitSet(kDynTextMsgColor)) if (contentFlags.IsBitSet(kDynTextMsgColor))
fColor.Read( s ); fColor.Read( s );
if (contentFlags.IsBitSet(kDynTextMsgString)) if (contentFlags.IsBitSet(kDynTextMsgString))
fString = s->ReadSafeWString_TEMP(); fString = s->ReadSafeWString();
if (contentFlags.IsBitSet(kDynTextMsgImageKey)) if (contentFlags.IsBitSet(kDynTextMsgImageKey))
fImageKey = mgr->ReadKey( s ); fImageKey = mgr->ReadKey( s );
if (contentFlags.IsBitSet(kDynTextMsgFlags)) if (contentFlags.IsBitSet(kDynTextMsgFlags))

34
Sources/Plasma/PubUtilLib/plMessage/plInputIfaceMgrMsg.h

@ -62,9 +62,9 @@ class plInputIfaceMgrMsg : public plMessage
uint8_t fCommand; uint8_t fCommand;
plInputInterface *fInterface; plInputInterface *fInterface;
uint32_t fPageID; uint32_t fPageID;
const char* ageName; plString ageName;
const char* ageFileName; plString ageFileName;
const char* spawnPoint; plString spawnPoint;
plUUID ageInstanceGuid; plUUID ageInstanceGuid;
plKey fAvKey; plKey fAvKey;
public: public:
@ -88,10 +88,10 @@ class plInputIfaceMgrMsg : public plMessage
kSetShareAgeInstanceGuid, kSetShareAgeInstanceGuid,
}; };
plInputIfaceMgrMsg() : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); fInterface = nil; ageName = ageFileName = spawnPoint = 0; fAvKey = nil; } plInputIfaceMgrMsg() : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); fInterface = nil; fAvKey = nil; }
plInputIfaceMgrMsg( plKey &receiver, uint8_t command ) : plMessage( nil, nil, nil ) { AddReceiver( receiver ); fCommand = command; fInterface = nil; fAvKey = nil; ageName = ageFileName = spawnPoint = 0;} plInputIfaceMgrMsg( plKey &receiver, uint8_t command ) : plMessage( nil, nil, nil ) { AddReceiver( receiver ); fCommand = command; fInterface = nil; fAvKey = nil; }
plInputIfaceMgrMsg( uint8_t command ) : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); fCommand = command; fInterface = nil; fAvKey = nil; ageName = ageFileName = spawnPoint = 0;} plInputIfaceMgrMsg( uint8_t command ) : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); fCommand = command; fInterface = nil; fAvKey = nil; }
plInputIfaceMgrMsg( uint8_t command, uint32_t pageID ) : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); fCommand = command; fPageID = pageID; fInterface = nil; fAvKey = nil; ageName = ageFileName = spawnPoint = 0;} plInputIfaceMgrMsg( uint8_t command, uint32_t pageID ) : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); fCommand = command; fPageID = pageID; fInterface = nil; fAvKey = nil; }
~plInputIfaceMgrMsg(); ~plInputIfaceMgrMsg();
CLASSNAME_REGISTER( plInputIfaceMgrMsg ); CLASSNAME_REGISTER( plInputIfaceMgrMsg );
@ -119,18 +119,18 @@ class plInputIfaceMgrMsg : public plMessage
mgr->WriteKey(s,fAvKey); mgr->WriteKey(s,fAvKey);
} }
void SetAgeName(const char* s) { ageName = s; } void SetAgeName(const plString& s) { ageName = s; }
const char* GetAgeName() { return ageName; } plString GetAgeName() const { return ageName; }
void SetAgeFileName(const char* s) { ageFileName = s; } void SetAgeFileName(const plString& s) { ageFileName = s; }
const char* GetAgeFileName() { return ageFileName; } plString GetAgeFileName() const { return ageFileName; }
void SetSpawnPoint(const char* s) { spawnPoint = s; } void SetSpawnPoint(const plString& s) { spawnPoint = s; }
const char* GetSpawnPoint() { return spawnPoint; } plString GetSpawnPoint() const { return spawnPoint; }
void SetAgeInstanceGuid(const plUUID& guid) { ageInstanceGuid = guid; } void SetAgeInstanceGuid(const plUUID& guid) { ageInstanceGuid = guid; }
const plUUID& GetAgeInstanceGuid() { return ageInstanceGuid; } const plUUID& GetAgeInstanceGuid() const { return ageInstanceGuid; }
uint8_t GetCommand( void ) { return fCommand; } uint8_t GetCommand() const { return fCommand; }
uint32_t GetPageID( void ) { return fPageID; } uint32_t GetPageID() const { return fPageID; }
void SetIFace( plInputInterface *iface ); void SetIFace( plInputInterface *iface );
plInputInterface *GetIFace( void ) const { return fInterface; } plInputInterface *GetIFace() const { return fInterface; }
plKey& GetAvKey( void ) { return fAvKey; } plKey& GetAvKey( void ) { return fAvKey; }
const plKey& GetAvKey( void ) const { return fAvKey; } const plKey& GetAvKey( void ) const { return fAvKey; }
void SetAvKey( plKey& k ) { fAvKey = k; } void SetAvKey( plKey& k ) { fAvKey = k; }

9
Sources/Plasma/PubUtilLib/plMessage/plLinkToAgeMsg.cpp

@ -53,20 +53,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// //
// plLinkToAgeMsg // plLinkToAgeMsg
plLinkToAgeMsg::plLinkToAgeMsg() : fLinkInAnimName(nil), fFlags(0) plLinkToAgeMsg::plLinkToAgeMsg() : fFlags(0)
{ {
} }
plLinkToAgeMsg::plLinkToAgeMsg( const plAgeLinkStruct * link ) : fLinkInAnimName(nil), fFlags(0) plLinkToAgeMsg::plLinkToAgeMsg( const plAgeLinkStruct * link ) : fFlags(0)
{ {
fAgeLink.CopyFrom( link ); fAgeLink.CopyFrom( link );
} }
plLinkToAgeMsg::~plLinkToAgeMsg()
{
delete [] fLinkInAnimName;
}
void plLinkToAgeMsg::PlayLinkSfx(bool linkIn, bool linkOut) void plLinkToAgeMsg::PlayLinkSfx(bool linkIn, bool linkOut)
{ {
if (linkIn) if (linkIn)

7
Sources/Plasma/PubUtilLib/plMessage/plLinkToAgeMsg.h

@ -66,12 +66,11 @@ class plLinkToAgeMsg : public plMessage
uint8_t fFlags; uint8_t fFlags;
plAgeLinkStruct fAgeLink; plAgeLinkStruct fAgeLink;
char* fLinkInAnimName; plString fLinkInAnimName;
public: public:
plLinkToAgeMsg(); plLinkToAgeMsg();
plLinkToAgeMsg( const plAgeLinkStruct * link ); plLinkToAgeMsg( const plAgeLinkStruct * link );
virtual ~plLinkToAgeMsg();
CLASSNAME_REGISTER( plLinkToAgeMsg ); CLASSNAME_REGISTER( plLinkToAgeMsg );
GETINTERFACE_ANY( plLinkToAgeMsg, plMessage ); GETINTERFACE_ANY( plLinkToAgeMsg, plMessage );
@ -83,8 +82,8 @@ public:
bool PlayLinkInSfx() const { return (fFlags & kMuteLinkInSfx) == 0; } bool PlayLinkInSfx() const { return (fFlags & kMuteLinkInSfx) == 0; }
bool PlayLinkOutSfx() const { return (fFlags & kMuteLinkOutSfx) == 0; } bool PlayLinkOutSfx() const { return (fFlags & kMuteLinkOutSfx) == 0; }
const char * GetLinkInAnimName() { return fLinkInAnimName; } plString GetLinkInAnimName() { return fLinkInAnimName; }
void SetLinkInAnimName(const char* name) { delete [] fLinkInAnimName; fLinkInAnimName = hsStrcpy(name); } void SetLinkInAnimName(const plString& name) { fLinkInAnimName = name; }
void Read(hsStream* stream, hsResMgr* mgr); void Read(hsStream* stream, hsResMgr* mgr);
void Write(hsStream* stream, hsResMgr* mgr); void Write(hsStream* stream, hsResMgr* mgr);

2
Sources/Plasma/PubUtilLib/plMessage/plLoadAgeMsg.cpp

@ -99,7 +99,7 @@ void plLoadAgeMsg::ReadVersion(hsStream* s, hsResMgr* mgr)
if (contentFlags.IsBitSet(kLoadAgeAgeName)) if (contentFlags.IsBitSet(kLoadAgeAgeName))
{ {
// read agename // read agename
fAgeFilename = s->ReadSafeString_TEMP(); fAgeFilename = s->ReadSafeString();
} }
if (contentFlags.IsBitSet(kLoadAgeUnload)) if (contentFlags.IsBitSet(kLoadAgeUnload))

4
Sources/Plasma/PubUtilLib/plMessage/plLoadAvatarMsg.cpp

@ -93,7 +93,7 @@ void plLoadAvatarMsg::Read(hsStream* stream, hsResMgr* mgr)
{ {
fInitialTask = plAvTask::ConvertNoRef(mgr->ReadCreatable(stream)); fInitialTask = plAvTask::ConvertNoRef(mgr->ReadCreatable(stream));
} }
fUserStr = stream->ReadSafeString_TEMP(); fUserStr = stream->ReadSafeString();
} }
void plLoadAvatarMsg::Write(hsStream *stream, hsResMgr *mgr) void plLoadAvatarMsg::Write(hsStream *stream, hsResMgr *mgr)
@ -132,7 +132,7 @@ void plLoadAvatarMsg::ReadVersion(hsStream* stream, hsResMgr* mgr)
fSpawnPoint = mgr->ReadKey(stream); fSpawnPoint = mgr->ReadKey(stream);
if (contentFlags.IsBitSet(kLoadAvatarMsgUserStr)) if (contentFlags.IsBitSet(kLoadAvatarMsgUserStr))
fUserStr = stream->ReadSafeString_TEMP(); fUserStr = stream->ReadSafeString();
} }
void plLoadAvatarMsg::WriteVersion(hsStream* stream, hsResMgr* mgr) void plLoadAvatarMsg::WriteVersion(hsStream* stream, hsResMgr* mgr)

2
Sources/Plasma/PubUtilLib/plMessage/plOneShotCallbacks.cpp

@ -74,7 +74,7 @@ void plOneShotCallbacks::Read(hsStream* stream, hsResMgr* mgr)
fCallbacks.reserve(size); fCallbacks.reserve(size);
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
{ {
plString marker = stream->ReadSafeString_TEMP(); plString marker = stream->ReadSafeString();
plKey receiver = mgr->ReadKey(stream); plKey receiver = mgr->ReadKey(stream);
int16_t user = stream->ReadLE16(); int16_t user = stream->ReadLE16();

2
Sources/Plasma/PubUtilLib/plModifier/plCloneSpawnModifier.cpp

@ -59,7 +59,7 @@ plCloneSpawnModifier::plCloneSpawnModifier() : fExportTime(false)
void plCloneSpawnModifier::Read(hsStream *s, hsResMgr *mgr) void plCloneSpawnModifier::Read(hsStream *s, hsResMgr *mgr)
{ {
fTemplateName = s->ReadSafeString_TEMP(); fTemplateName = s->ReadSafeString();
plSingleModifier::Read(s, mgr); plSingleModifier::Read(s, mgr);
} }

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

@ -374,16 +374,16 @@ bool plLinkEffectsMgr::MsgReceive(plMessage *msg)
if (linkKey == nc->GetLocalPlayerKey()) if (linkKey == nc->GetLocalPlayerKey())
{ {
if(lm) { if(lm) {
const char *ageName = lm->GetAgeLink()->GetAgeInfo()->GetAgeFilename(); plString ageName = lm->GetAgeLink()->GetAgeInfo()->GetAgeFilename();
const char *prevAgeName = lm->GetPrevAgeLink()->GetAgeInfo()->GetAgeFilename(); plString prevAgeName = lm->GetPrevAgeLink()->GetAgeInfo()->GetAgeFilename();
bool linkToStartup = ageName && !stricmp(ageName, kStartUpAgeFilename ); // To Startup bool linkToStartup = ageName.CompareI(kStartUpAgeFilename) == 0; // To Startup
bool linkFromStartup = prevAgeName && !stricmp(prevAgeName, kStartUpAgeFilename); // Leaving Startup bool linkFromStartup = prevAgeName.CompareI(kStartUpAgeFilename) == 0; // Leaving Startup
bool cleftSolved = VaultHasChronicleEntry( kCleftSolved ); bool cleftSolved = VaultHasChronicleEntry( kCleftSolved );
bool linkToACA = ageName && !stricmp(ageName, kAvCustomizationFilename); bool linkToACA = ageName.CompareI(kAvCustomizationFilename) == 0;
bool linkFromACA = prevAgeName && !stricmp(prevAgeName, kAvCustomizationFilename); bool linkFromACA = prevAgeName.CompareI(kAvCustomizationFilename) == 0;
bool linkToFissureDrop = lm && bool linkToFissureDrop = lm &&
lm->GetAgeLink()->HasSpawnPt() && lm->GetAgeLink()->HasSpawnPt() &&
@ -606,4 +606,4 @@ void plLinkEffectsMgr::IRemovePseudo(plKey avatarKey)
} }
} }
} }

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

@ -1144,7 +1144,7 @@ bool plNetClientMgr::ObjectInLocalAge(const plSynchedObject* obj) const
// //
// the next age we are going to // the next age we are going to
// //
const char* plNetClientMgr::GetNextAgeFilename() plString plNetClientMgr::GetNextAgeFilename() const
{ {
// set when we start linking to an age. // set when we start linking to an age.
plNetLinkingMgr * lm = plNetLinkingMgr::GetInstance(); plNetLinkingMgr * lm = plNetLinkingMgr::GetInstance();

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

Loading…
Cancel
Save