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. 13
      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. 24
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListElement.h
  16. 12
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIMultiLineEditCtrl.cpp
  17. 4
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIMultiLineEditCtrl.h
  18. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIProgressCtrl.cpp
  19. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUITextBoxMod.cpp
  20. 8
      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. 47
      Sources/Plasma/NucleusLib/pnNetCommon/plGenericVar.h
  50. 52
      Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.cpp
  51. 33
      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. 8
      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. 41
      Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.cpp
  74. 13
      Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.h
  75. 31
      Sources/Plasma/PubUtilLib/plGImage/plDynSurfaceWriter.cpp
  76. 10
      Sources/Plasma/PubUtilLib/plGImage/plDynSurfaceWriter.h
  77. 69
      Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp
  78. 17
      Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.h
  79. 44
      Sources/Plasma/PubUtilLib/plGImage/plFont.cpp
  80. 14
      Sources/Plasma/PubUtilLib/plGImage/plFont.h
  81. 24
      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. 6
      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. 12
      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));
GetCryptKey(cryptKey, arrsize(cryptKey));
char* temp;
plString temp;
pLoginParam->remember = false;
pLoginParam->username[0] = '\0';
@ -893,10 +893,9 @@ static void LoadUserPass (LoginDialogParam *pLoginParam)
{
temp = stream->ReadSafeString();
if (temp)
if (!temp.IsEmpty())
{
StrCopy(pLoginParam->username, temp, kMaxAccountNameLength);
delete[] temp;
StrCopy(pLoginParam->username, temp.c_str(), kMaxAccountNameLength);
}
pLoginParam->remember = stream->ReadBool();

46
Sources/Plasma/CoreLib/hsStream.cpp

@ -158,7 +158,7 @@ uint32_t hsStream::WriteSafeWStringLong(const plString &string)
return 0;
}
plString hsStream::ReadSafeStringLong_TEMP()
plString hsStream::ReadSafeStringLong()
{
plStringBuffer<char> name;
uint32_t numChars = ReadLE32();
@ -179,15 +179,7 @@ plString hsStream::ReadSafeStringLong_TEMP()
return name;
}
char *hsStream::ReadSafeStringLong()
{
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()
plString hsStream::ReadSafeWStringLong()
{
plStringBuffer<uint16_t> retVal;
uint32_t numChars = ReadLE32();
@ -209,17 +201,6 @@ plString hsStream::ReadSafeWStringLong_TEMP()
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)
{
int len = string.GetSize();
@ -261,7 +242,7 @@ uint32_t hsStream::WriteSafeWString(const plString &string)
return 0;
}
plString hsStream::ReadSafeString_TEMP()
plString hsStream::ReadSafeString()
{
plStringBuffer<char> name;
uint16_t numChars = ReadLE16();
@ -293,15 +274,7 @@ plString hsStream::ReadSafeString_TEMP()
return name;
}
char *hsStream::ReadSafeString()
{
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()
plString hsStream::ReadSafeWString()
{
plStringBuffer<uint16_t> retVal;
uint32_t numChars = ReadLE16();
@ -326,17 +299,6 @@ plString hsStream::ReadSafeWString_TEMP()
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
{
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 LogRead(byteCount, buffer, desc) Read(byteCount, buffer)
#define LogReadSafeString() ReadSafeString()
#define LogReadSafeString_TEMP() ReadSafeString_TEMP()
#define LogReadSafeStringLong() ReadSafeStringLong();
#define LogSkip(deltaByteCount, desc) Skip(deltaByteCount)
#define LogReadLE(value, desc) ReadLE(value)
@ -126,18 +125,13 @@ public:
uint32_t WriteSafeStringLong(const plString &string); // uses 4 bytes for length
uint32_t WriteSafeWStringLong(const plString &string);
char * ReadSafeStringLong();
wchar_t * ReadSafeWStringLong();
plString ReadSafeStringLong();
plString ReadSafeWStringLong();
uint32_t WriteSafeString(const plString &string); // uses 2 bytes for length
uint32_t WriteSafeWString(const plString &string);
char * ReadSafeString();
wchar_t * ReadSafeWString();
plString ReadSafeStringLong_TEMP();
plString ReadSafeWStringLong_TEMP();
plString ReadSafeString_TEMP();
plString ReadSafeWString_TEMP();
plString ReadSafeString();
plString ReadSafeWString();
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);

2
Sources/Plasma/CoreLib/plGeneric.cpp

@ -144,7 +144,7 @@ int plGeneric::Read(hsStream* stream)
break;
case kString:
fStringVal = stream->ReadSafeWString_TEMP();
fStringVal = stream->ReadSafeWString();
break;
}
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 <cstdarg>
#include <cstdint>
#include <cctype>
#include <vector>
/** Single Unicode character code unit */
@ -598,6 +599,42 @@ public:
static plString Fill(size_t count, char c);
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. */
struct less_i
{

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

@ -336,7 +336,7 @@ PF_CONSOLE_CMD( Net, // groupName
"Link to an age." ) // helpString
{
plAgeLinkStruct link;
link.GetAgeInfo()->SetAgeFilename( params[0] );
link.GetAgeInfo()->SetAgeFilename( (const char *)params[0] );
link.SetLinkingRules( plNetCommon::LinkingRules::kBasicLink );
plNetLinkingMgr::GetInstance()->LinkToAge( &link );
PrintString("Linking to age...");
@ -350,7 +350,7 @@ PF_CONSOLE_CMD( Net, // groupName
"Link to a specific age by guid." ) // helpString
{
plAgeLinkStruct link;
link.GetAgeInfo()->SetAgeFilename( params[0] );
link.GetAgeInfo()->SetAgeFilename( (const char *)params[0] );
//link.GetAgeInfo()->SetAgeInstanceName( params[0] );
//link.GetAgeInfo()->SetAgeUserDefinedName( params[0] );
plUUID guid( (const char *)params[1] );
@ -375,7 +375,7 @@ PF_CONSOLE_CMD( Net,
"Link to specified age using Original Age Linking Book rules" )
{
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.SetLinkingRules( plNetCommon::LinkingRules::kOriginalBook );
plNetLinkingMgr::GetInstance()->LinkToAge( &link );
@ -388,7 +388,7 @@ PF_CONSOLE_CMD( Net,
"Link to specified age using Personal Age Linking Book rules" )
{
plAgeLinkStruct link;
link.GetAgeInfo()->SetAgeFilename( params[0] );
link.GetAgeInfo()->SetAgeFilename( (const char *)params[0] );
link.SetLinkingRules( plNetCommon::LinkingRules::kOwnedBook );
plNetLinkingMgr::GetInstance()->LinkToAge( &link );
PrintString("Linking to age I own...");
@ -400,7 +400,7 @@ PF_CONSOLE_CMD( Net,
"Link to specified age using Personal Age Linking Book rules" )
{
plAgeLinkStruct link;
link.GetAgeInfo()->SetAgeFilename( params[0] );
link.GetAgeInfo()->SetAgeFilename( (const char *)params[0] );
link.SetLinkingRules( plNetCommon::LinkingRules::kVisitBook );
plNetLinkingMgr::GetInstance()->LinkToAge( &link );
PrintString("Linking to age I can visit...");
@ -412,7 +412,7 @@ PF_CONSOLE_CMD( Net,
"Link to a sub-age of the current age" )
{
plAgeLinkStruct link;
link.GetAgeInfo()->SetAgeFilename( params[0] );
link.GetAgeInfo()->SetAgeFilename( (const char *)params[0] );
link.SetLinkingRules( plNetCommon::LinkingRules::kSubAgeBook );
plNetLinkingMgr::GetInstance()->LinkToAge( &link );
PrintString("Linking to a sub-age...");
@ -481,7 +481,7 @@ PF_CONSOLE_CMD( Net,
plNetLinkingMgr * lm = plNetLinkingMgr::GetInstance();
plAgeInfoStruct info;
info.SetAgeFilename( params[0] );
info.SetAgeFilename( (const char *)params[0] );
plAgeLinkStruct link;
if (!VaultGetOwnedAgeLink(&info, &link)) {
@ -806,8 +806,8 @@ PF_CONSOLE_CMD( Net_Vault,
"Add an instance of the specified age to your bookshelf" )
{
plAgeLinkStruct link;
link.GetAgeInfo()->SetAgeFilename( params[0] );
link.GetAgeInfo()->SetAgeInstanceName( params[0] );
link.GetAgeInfo()->SetAgeFilename( (const char *)params[0] );
link.GetAgeInfo()->SetAgeInstanceName( (const char *)params[0] );
plUUID guid = plUUID::Generate();
link.GetAgeInfo()->SetAgeInstanceGuid( &guid);
link.SetSpawnPoint( kDefaultSpawnPoint );
@ -822,7 +822,7 @@ PF_CONSOLE_CMD( Net_Vault,
"Remove the specified age from your bookshelf" )
{
plAgeInfoStruct info;
info.SetAgeFilename( params[0] );
info.SetAgeFilename( (const char *)params[0] );
bool success = VaultUnregisterOwnedAgeAndWait(&info);
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" )
{
plAgeLinkStruct link;
link.GetAgeInfo()->SetAgeFilename( params[0] );
link.GetAgeInfo()->SetAgeInstanceName( params[0] );
link.GetAgeInfo()->SetAgeFilename( (const char *)params[0] );
link.GetAgeInfo()->SetAgeInstanceName( (const char *)params[0] );
plUUID guid = plUUID::Generate();
link.GetAgeInfo()->SetAgeInstanceGuid( &guid);
link.SetSpawnPoint( kDefaultSpawnPoint );
@ -850,7 +850,7 @@ PF_CONSOLE_CMD( Net_Vault,
"Remove all instances of the specified age from your private links" )
{
plAgeInfoStruct info;
info.SetAgeFilename( params[0] );
info.SetAgeFilename( (const char *)params[0] );
unsigned count = 0;
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();
for( i = 0; i < count; i++ )
fAnimationKeys.Append( mgr->ReadKey( s ) );
fAnimName = s->ReadSafeString_TEMP();
fAnimName = s->ReadSafeString();
fMouseOverAnimKeys.Reset();
count = s->ReadLE32();
for( i = 0; i < count; i++ )
fMouseOverAnimKeys.Append( mgr->ReadKey( s ) );
fMouseOverAnimName = s->ReadSafeString_TEMP();
fMouseOverAnimName = s->ReadSafeString();
fNotifyType = s->ReadLE32();
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++ )
fAnimationKeys.Append( mgr->ReadKey( s ) );
fAnimName = s->ReadSafeString_TEMP();
fAnimName = s->ReadSafeString();
fChecked = s->ReadBool();
}

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

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

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

@ -74,7 +74,7 @@ class pfGUIColorScheme : public hsRefCnt
hsColorRGBA fSelForeColor, fSelBackColor;
bool fTransparent;
char *fFontFace;
plString fFontFace;
uint8_t fFontSize;
uint8_t fFontFlags;
@ -86,18 +86,17 @@ class pfGUIColorScheme : public hsRefCnt
};
pfGUIColorScheme();
~pfGUIColorScheme();
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 Write( hsStream *s );
bool IsBold( void ) { return ( fFontFlags & kFontBold ) ? true : false; }
bool IsItalic( void ) { return ( fFontFlags & kFontItalic ) ? true : false; }
bool IsShadowed( void ) { return ( fFontFlags & kFontShadowed ) ? true : false; }
bool IsBold() const { return ( fFontFlags & kFontBold ) ? true : false; }
bool IsItalic() const { return ( fFontFlags & kFontItalic ) ? true : false; }
bool IsShadowed() const { return ( fFontFlags & kFontShadowed ) ? true : false; }
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();
for( i = 0; i < count; i++ )
fAnimationKeys.Append( mgr->ReadKey( s ) );
fAnimName = s->ReadSafeString_TEMP();
fAnimName = s->ReadSafeString();
fAnimTimesCalced = false;

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

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

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

@ -186,10 +186,8 @@ class pfGUIListBoxMod : public pfGUIControlMod
uint16_t GetNumElements( void );
pfGUIListElement *GetElement( uint16_t idx );
uint16_t AddString( const char *string );
uint16_t AddString( const wchar_t *string );
int16_t FindString( const char *toCompareTo );
int16_t FindString( const wchar_t *toCompareTo );
uint16_t AddString( const plString &string );
int16_t FindString( const plString &toCompareTo );
// Export only
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 //////////////////////////////////////////////////
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 ////////////////////////////////////////////////////////////////
@ -107,18 +93,14 @@ void pfGUIListText::Read( hsStream *s, hsResMgr *mgr )
{
pfGUIListElement::Read( s, mgr );
char *text = s->ReadSafeString();
fText = hsStringToWString(text);
delete [] text;
fText = s->ReadSafeString();
}
void pfGUIListText::Write( hsStream *s, hsResMgr *mgr )
{
pfGUIListElement::Write( s, mgr );
char *text = hsWStringToString(fText);
s->WriteSafeString(text);
delete [] text;
s->WriteSafeString(fText);
}
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 )
return -2;
return wcscmp( GetText(), 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;
return GetText().Compare(text->GetText());
}
void pfGUIListText::SetJustify( JustifyTypes justify )
@ -295,26 +258,14 @@ int pfGUIListPicture::CompareTo( pfGUIListElement *rightSide )
//// 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 ////////////////////////////////////////////////////////////////
@ -323,18 +274,14 @@ void pfGUIListTreeRoot::Read( hsStream *s, hsResMgr *mgr )
{
pfGUIListElement::Read( s, mgr );
char *temp = s->ReadSafeString();
fText = hsStringToWString(temp);
delete [] temp;
fText = s->ReadSafeString();
}
void pfGUIListTreeRoot::Write( hsStream *s, hsResMgr *mgr )
{
pfGUIListElement::Write( s, mgr );
char *temp = hsWStringToString(fText);
s->WriteSafeString( temp );
delete [] temp;
s->WriteSafeString(fText);
}
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 )
return -2;
return wcscmp( GetTitle(), 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;
return GetTitle().Compare(text->GetTitle());
}
void pfGUIListTreeRoot::AddChild( pfGUIListElement *el )

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

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

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

@ -349,7 +349,7 @@ void pfGUIMultiLineEditCtrl::IPostSetUpDynTextMap( void )
fFontFlagsSet |= kFontStyleSet;
}
fDynTextMap->SetFont( fFontFace.c_str(), fFontSize, fFontStyle,
fDynTextMap->SetFont( fFontFace, fFontSize, fFontStyle,
HasFlag( kXparentBgnd ) ? false : true );
// 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 );
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 );
// 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
IReadStyleCode( pos, currStyle );
if( !dontRender )
fDynTextMap->SetFont( fFontFace.c_str(), fFontSize , GetColorScheme()->fFontFlags | currStyle,
fDynTextMap->SetFont( fFontFace, fFontSize , GetColorScheme()->fFontFlags | currStyle,
HasFlag( kXparentBgnd ) ? false : true );
}
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;
fFontFlagsSet |= kFontFaceSet;
fDynTextMap->SetFont( fFontFace.c_str(), fFontSize, fFontStyle,
fDynTextMap->SetFont( fFontFace, fFontSize, fFontStyle,
HasFlag( kXparentBgnd ) ? false : true );
fDynTextMap->CalcStringWidth( "The quick brown fox jumped over the lazy dog.", &fLineHeight );
}
@ -1850,7 +1850,7 @@ void pfGUIMultiLineEditCtrl::SetFontSize(uint8_t fontSize)
fFontSize = fontSize;
fFontFlagsSet |= kFontSizeSet;
fCalcedFontSize = fontSize;
fDynTextMap->SetFont( fFontFace.c_str(), fFontSize, fFontStyle,
fDynTextMap->SetFont( fFontFace, fFontSize, fFontStyle,
HasFlag( kXparentBgnd ) ? false : true );
fDynTextMap->CalcStringWidth( "The quick brown fox jumped over the lazy dog.", &fLineHeight );
}

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

@ -129,7 +129,7 @@ class pfGUIMultiLineEditCtrl : public pfGUIControlMod
pfGUIMultiLineEditProc *fEventProc; // where we send events to
std::string fFontFace;
plString fFontFace;
hsColorRGBA fFontColor;
uint8_t fFontSize;
uint8_t fFontStyle;
@ -271,7 +271,7 @@ class pfGUIMultiLineEditCtrl : public pfGUIControlMod
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 SetFontSize(uint8_t fontSize);
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();
for( i = 0; i < count; i++ )
fAnimationKeys.Append( mgr->ReadKey( s ) );
fAnimName = s->ReadSafeString_TEMP();
fAnimName = s->ReadSafeString();
fAnimTimesCalced = false;
}

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

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

8
Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp

@ -2609,7 +2609,7 @@ void pfJournalBook::IRenderPage( uint32_t page, uint32_t whichDTMap, bool sup
uint16_t width, height, y, x, ascent, lastX, lastY;
uint8_t fontFlags, fontSize;
const wchar_t *fontFace;
plString fontFace;
hsColorRGBA fontColor;
int16_t fontSpacing;
bool needSFX = false;
@ -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
// 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
{
@ -3369,7 +3369,7 @@ void pfJournalBook::IFindFontProps( uint32_t chunkIdx, const wchar_t *&face,
// What do we (still) need?
if( !( found & kFace ) && chunk->fText != L"" )
{
face = chunk->fText.c_str();
face = plString::FromWchar(chunk->fText.c_str());
found |= kFace;
}
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
if( !( found & kFace ) )
face = L"Arial";
face = "Arial";
if( !( found & kSize ) )
size = 24;
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
// 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
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)
{
plMessage::IMsgRead( s, mgr );
fTarget = s->ReadSafeString_TEMP();
fString = s->ReadSafeString_TEMP();
fTarget = s->ReadSafeString();
fString = s->ReadSafeString();
}
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);
buffer[GAME_GUI_MSG_STRING_SIZE - 1] = 0;
fString = buffer;
fAge = s->ReadSafeString_TEMP();
fAge = s->ReadSafeString();
}
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 );
s->ReadLE( &fCommand );
fUser = s->ReadSafeString_TEMP();
fUser = s->ReadSafeString();
fPlayerID = s->ReadLE32();
fString = s->ReadSafeWString_TEMP();
fString = s->ReadSafeWString();
fFlags = s->ReadLE32();
fDelay = s->ReadLEScalar();
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();
fMovieName = stream->ReadSafeString_TEMP();
fMovieName = stream->ReadSafeString();
}
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
//
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);
}
@ -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
//
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);
}
@ -632,7 +632,7 @@ PyObject* cyMisc::GetAgeInfo()
}
const char* cyMisc::GetPrevAgeName()
plString cyMisc::GetPrevAgeName()
{
plNetLinkingMgr* nmgr = plNetLinkingMgr::GetInstance();
if (nmgr)
@ -641,7 +641,7 @@ const char* cyMisc::GetPrevAgeName()
if (als)
return als->GetAgeInfo()->GetAgeFilename();
}
return nil;
return plString::Null;
}
PyObject* cyMisc::GetPrevAgeInfo()
@ -2919,7 +2919,7 @@ PyObject* cyMisc::GetAIAvatarsByModelName(const char* name)
{
PyObject* tuple = PyTuple_New(2);
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);
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
//
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
// 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 PyObject* GetAgeInfo(); // returns pyAgeInfoStruct
static const char* GetPrevAgeName();
static plString GetPrevAgeName();
static PyObject* GetPrevAgeInfo();
// current time in current age
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")
{
return PyString_FromString(cyMisc::GetPrevAgeName());
return PyString_FromPlString(cyMisc::GetPrevAgeName());
}
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()
{
fPythonFile = nil;
fModule = nil;
fLocalNotify= true;
fIsFirstTimeEval = true;
@ -401,12 +400,6 @@ plPythonFileMod::~plPythonFileMod()
fSelfKey = nil;
}
// get rid of the python code
if ( fPythonFile )
{
delete [] fPythonFile;
fPythonFile = nil;
}
// then get rid of this module
// NOTE: fModule shouldn't be made in the plugin, only at runtime
if ( !fModuleName.IsNull() && fModule )
@ -438,14 +431,14 @@ bool plPythonFileMod::ILoadPythonCode()
#ifndef PLASMA_EXTERNAL_RELEASE
// get code from file and execute in module
// 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())
{
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
// ...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) )
{
// we've loaded the code into our module
@ -461,7 +454,7 @@ bool plPythonFileMod::ILoadPythonCode()
}
DisplayPythonOutput();
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);
hsAssert(0,errMsg);
return false;
@ -476,7 +469,7 @@ bool plPythonFileMod::ILoadPythonCode()
DisplayPythonOutput();
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);
hsAssert(0,errMsg);
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
{
// was there a python file module with this?
if ( fPythonFile )
if ( !fPythonFile.IsEmpty() )
{
// has the module not been initialized yet
if ( !fModule )
@ -523,7 +516,7 @@ void plPythonFileMod::AddTarget(plSceneObject* sobj)
// set the name of the file (in the global dictionary of the module)
PyObject* dict = PyModule_GetDict(fModule);
PyObject* pfilename = PyString_FromString(fPythonFile);
PyObject* pfilename = PyString_FromPlString(fPythonFile);
PyDict_SetItemString(dict, "glue_name", pfilename);
// next we need to:
// - create instance of class
@ -542,7 +535,7 @@ void plPythonFileMod::AddTarget(plSceneObject* sobj)
{
// display any output (NOTE: this would be disabled in production)
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);
hsAssert(0, errMsg);
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::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);
ptuple = PyTuple_New(1);
PyTuple_SetItem(ptuple, 0, PyString_FromString(ageName));
PyTuple_SetItem(ptuple, 0, PyString_FromPlString(ageName));
}
}
break;
@ -2933,10 +2927,9 @@ void plPythonFileMod::DisplayPythonOutput()
// : Compile it into a Python code object
// : (This is usually called by the component)
//
void plPythonFileMod::SetSourceFile(const char* filename)
void plPythonFileMod::SetSourceFile(const plString& filename)
{
delete [] fPythonFile;
fPythonFile = hsStrcpy(filename);
fPythonFile = filename;
}
/////////////////////////////////////////////////////////////////////////////
@ -2996,12 +2989,6 @@ void plPythonFileMod::Read(hsStream* stream, hsResMgr* mgr)
plMultiModifier::Read(stream, mgr);
// 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();
// 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);
char* fPythonFile;
plString fPythonFile;
plString fModuleName;
// the list of receivers that want to be notified
@ -131,7 +131,7 @@ public:
plPythonSDLModifier* GetSDLMod() { return fSDLMod; }
bool WasLocalNotify() { return fLocalNotify; }
plPipeline* GetPipeline() { return fPipe; }
virtual void SetSourceFile(const char* filename);
virtual void SetSourceFile(const plString& filename);
virtual int getPythonOutput(std::string* line);
virtual void ReportError();
virtual void DisplayPythonOutput();

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

@ -68,7 +68,7 @@ protected:
std::vector<hsStream*> fPackStreams;
bool fPackNotFound; // No pack file, don't keep trying
typedef std::map<std::string, plPackOffsetInfo> FileOffset;
typedef std::map<plString, plPackOffsetInfo> FileOffset;
FileOffset fFileOffsets;
plPythonPack();
@ -81,16 +81,16 @@ public:
bool Open();
void Close();
PyObject* OpenPacked(const char *fileName);
bool IsPackedFile(const char* fileName);
PyObject* OpenPacked(const plString& sfileName);
bool IsPackedFile(const plString& fileName);
};
PyObject* PythonPack::OpenPythonPacked(const char* fileName)
PyObject* PythonPack::OpenPythonPacked(const plString& fileName)
{
return plPythonPack::Instance().OpenPacked(fileName);
}
bool PythonPack::IsItPythonPacked(const char* fileName)
bool PythonPack::IsItPythonPacked(const plString& fileName)
{
return plPythonPack::Instance().IsPackedFile(fileName);
}
@ -148,9 +148,7 @@ bool plPythonPack::Open()
for (int i = 0; i < numFiles; i++)
{
// and pack the index into our own data structure
char* buf = fPackStream->ReadSafeString();
std::string pythonName = buf; // reading a "string" from a hsStream directly into a stl string causes memory loss
delete [] buf;
plString pythonName = fPackStream->ReadSafeString();
uint32_t offset = fPackStream->ReadLE32();
plPackOffsetInfo offsetInfo;
@ -191,13 +189,12 @@ void plPythonPack::Close()
fFileOffsets.clear();
}
PyObject* plPythonPack::OpenPacked(const char* fileName)
PyObject* plPythonPack::OpenPacked(const plString& fileName)
{
if (!Open())
return nil;
std::string pythonName = fileName;
pythonName += ".py";
plString pythonName = fileName + ".py";
FileOffset::iterator it = fFileOffsets.find(pythonName);
if (it != fFileOffsets.end())
@ -213,7 +210,7 @@ PyObject* plPythonPack::OpenPacked(const char* fileName)
char *buf = new char[size];
uint32_t readSize = fPackStream->Read(size, buf);
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
PyObject *pythonCode = PyMarshal_ReadObjectFromString(buf, size);
@ -227,13 +224,12 @@ PyObject* plPythonPack::OpenPacked(const char* fileName)
return nil;
}
bool plPythonPack::IsPackedFile(const char* fileName)
bool plPythonPack::IsPackedFile(const plString& fileName)
{
if (!Open())
return nil;
std::string pythonName = fileName;
pythonName += ".py";
plString pythonName = fileName + ".py";
FileOffset:: iterator it = fFileOffsets.find(pythonName);
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
typedef struct _object PyObject;
class plString;
namespace PythonPack
{
PyObject* OpenPythonPacked(const char* fileName);
bool IsItPythonPacked(const char* fileName);
PyObject* OpenPythonPacked(const plString& fileName);
bool IsItPythonPacked(const plString& fileName);
}
#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
{
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)
@ -566,7 +568,7 @@ PyObject* plPythonSDLModifier::ISDLVarToPython(plSimpleStateVariable* var)
return pyTuple;
}
bool plPythonSDLModifier::HasSDL(const char* pythonFile)
bool plPythonSDLModifier::HasSDL(const plString& pythonFile)
{
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 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
static const plPythonSDLModifier* FindAgeSDL();
static plKey FindAgeSDLTarget();

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

@ -81,42 +81,42 @@ void pyAgeInfoStruct::CopyFromRef( const pyAgeInfoStructRef & other )
fAgeInfo.CopyFrom( other.GetAgeInfo() );
}
const char * pyAgeInfoStruct::GetAgeFilename() const
plString pyAgeInfoStruct::GetAgeFilename() const
{
return fAgeInfo.GetAgeFilename();
}
void pyAgeInfoStruct::SetAgeFilename( const char * v )
void pyAgeInfoStruct::SetAgeFilename( const plString & v )
{
fAgeInfo.SetAgeFilename( v );
}
const char * pyAgeInfoStruct::GetAgeInstanceName() const
plString pyAgeInfoStruct::GetAgeInstanceName() const
{
return fAgeInfo.GetAgeInstanceName();
}
void pyAgeInfoStruct::SetAgeInstanceName( const char * v )
void pyAgeInfoStruct::SetAgeInstanceName( const plString & v )
{
fAgeInfo.SetAgeInstanceName( v );
}
const char * pyAgeInfoStruct::GetAgeUserDefinedName() const
plString pyAgeInfoStruct::GetAgeUserDefinedName() const
{
return fAgeInfo.GetAgeUserDefinedName();
}
void pyAgeInfoStruct::SetAgeUserDefinedName( const char * v )
void pyAgeInfoStruct::SetAgeUserDefinedName( const plString & v )
{
fAgeInfo.SetAgeUserDefinedName( v );
}
const char * pyAgeInfoStruct::GetAgeDescription() const
plString pyAgeInfoStruct::GetAgeDescription() const
{
return fAgeInfo.GetAgeDescription();
}
void pyAgeInfoStruct::SetAgeDescription( const char * v )
void pyAgeInfoStruct::SetAgeDescription( const plString & v )
{
fAgeInfo.SetAgeDescription( v );
}
@ -132,12 +132,12 @@ void pyAgeInfoStruct::SetAgeInstanceGuid( const char * guid )
if ( guid[0] == '@' )
{
// if it starts with an @ then do a meta kind of GUID
std::string curInst = fAgeInfo.GetAgeInstanceName();
std::string y = curInst + guid;
plString curInst = fAgeInfo.GetAgeInstanceName();
plString y = curInst + guid;
plMD5Checksum hash;
hash.Start();
hash.AddTo(y.length(), (uint8_t*)y.c_str());
hash.AddTo(y.GetSize(), (uint8_t*)y.c_str());
hash.Finish();
const char* md5sum = hash.GetAsHexString();
@ -180,9 +180,9 @@ void pyAgeInfoStruct::SetAgeLanguage( int32_t v )
plString pyAgeInfoStruct::GetDisplayName() const
{
const char* instance = GetAgeInstanceName();
const char* user = GetAgeUserDefinedName();
bool namesEqual = (stricmp(user, instance) == 0); // Ae'gura Ae'gura
plString instance = GetAgeInstanceName();
plString user = GetAgeUserDefinedName();
bool namesEqual = (user.CompareI(instance) == 0); // Ae'gura Ae'gura
if (namesEqual)
return instance;
@ -190,9 +190,9 @@ plString pyAgeInfoStruct::GetDisplayName() const
{
int32_t seq = GetAgeSequenceNumber();
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
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() );
}
const char * pyAgeInfoStructRef::GetAgeFilename() const
plString pyAgeInfoStructRef::GetAgeFilename() const
{
return fAgeInfo.GetAgeFilename();
}
void pyAgeInfoStructRef::SetAgeFilename( const char * v )
void pyAgeInfoStructRef::SetAgeFilename( const plString & v )
{
fAgeInfo.SetAgeFilename( v );
}
const char * pyAgeInfoStructRef::GetAgeInstanceName() const
plString pyAgeInfoStructRef::GetAgeInstanceName() const
{
return fAgeInfo.GetAgeInstanceName();
}
void pyAgeInfoStructRef::SetAgeInstanceName( const char * v )
void pyAgeInfoStructRef::SetAgeInstanceName( const plString & v )
{
fAgeInfo.SetAgeInstanceName( v );
}
const char * pyAgeInfoStructRef::GetAgeUserDefinedName() const
plString pyAgeInfoStructRef::GetAgeUserDefinedName() const
{
return fAgeInfo.GetAgeUserDefinedName();
}
void pyAgeInfoStructRef::SetAgeUserDefinedName( const char * v )
void pyAgeInfoStructRef::SetAgeUserDefinedName( const plString & v )
{
fAgeInfo.SetAgeUserDefinedName( v );
}
@ -265,9 +265,9 @@ void pyAgeInfoStructRef::SetAgeSequenceNumber( int32_t v )
plString pyAgeInfoStructRef::GetDisplayName() const
{
const char* instance = GetAgeInstanceName();
const char* user = GetAgeUserDefinedName();
bool namesEqual = (stricmp(user, instance) == 0); // Ae'gura Ae'gura
plString instance = GetAgeInstanceName();
plString user = GetAgeUserDefinedName();
bool namesEqual = (user.CompareI(instance) == 0); // Ae'gura Ae'gura
if (namesEqual)
return instance;
@ -275,8 +275,8 @@ plString pyAgeInfoStructRef::GetDisplayName() const
{
int32_t seq = GetAgeSequenceNumber();
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
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();
void CopyFrom( const pyAgeInfoStruct & other );
void CopyFromRef( const pyAgeInfoStructRef & other );
const char * GetAgeFilename() const;
void SetAgeFilename( const char * v );
const char * GetAgeInstanceName() const;
void SetAgeInstanceName( const char * v );
const char * GetAgeUserDefinedName() const;
void SetAgeUserDefinedName( const char * v );
const char * GetAgeDescription() const;
void SetAgeDescription( const char * v );
plString GetAgeFilename() const;
void SetAgeFilename( const plString & v );
plString GetAgeInstanceName() const;
void SetAgeInstanceName( const plString & v );
plString GetAgeUserDefinedName() const;
void SetAgeUserDefinedName( const plString & v );
plString GetAgeDescription() const;
void SetAgeDescription( const plString & v );
const char * GetAgeInstanceGuid() const;
void SetAgeInstanceGuid( const char * guid );
int32_t GetAgeSequenceNumber() const;
@ -132,12 +132,12 @@ public:
const plAgeInfoStruct * GetAgeInfo() const { return &fAgeInfo; }
void CopyFrom( const pyAgeInfoStruct & other );
void CopyFromRef( const pyAgeInfoStructRef & other );
const char * GetAgeFilename() const;
void SetAgeFilename( const char * v );
const char * GetAgeInstanceName() const;
void SetAgeInstanceName( const char * v );
const char * GetAgeUserDefinedName() const;
void SetAgeUserDefinedName( const char * v );
plString GetAgeFilename() const;
void SetAgeFilename( const plString & v );
plString GetAgeInstanceName() const;
void SetAgeInstanceName( const plString & v );
plString GetAgeUserDefinedName() const;
void SetAgeUserDefinedName( const plString & v );
const char * GetAgeInstanceGuid() const;
void SetAgeInstanceGuid( const char * guid );
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)
{
return PyString_FromString(self->fThis->GetAgeFilename());
return PyString_FromPlString(self->fThis->GetAgeFilename());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeFilename, args)
@ -132,7 +132,7 @@ PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeFilename, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeInstanceName)
{
return PyString_FromString(self->fThis->GetAgeInstanceName());
return PyString_FromPlString(self->fThis->GetAgeInstanceName());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeInstanceName, args)
@ -149,7 +149,7 @@ PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeInstanceName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeUserDefinedName)
{
return PyString_FromString(self->fThis->GetAgeUserDefinedName());
return PyString_FromPlString(self->fThis->GetAgeUserDefinedName());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeUserDefinedName, args)
@ -166,7 +166,7 @@ PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeUserDefinedName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeDescription)
{
return PyString_FromString(self->fThis->GetAgeDescription());
return PyString_FromPlString(self->fThis->GetAgeDescription());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeDescription, args)
@ -325,7 +325,7 @@ PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, copyFrom, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeFilename)
{
return PyString_FromString(self->fThis->GetAgeFilename());
return PyString_FromPlString(self->fThis->GetAgeFilename());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeFilename, args)
@ -342,7 +342,7 @@ PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeFilename, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeInstanceName)
{
return PyString_FromString(self->fThis->GetAgeInstanceName());
return PyString_FromPlString(self->fThis->GetAgeInstanceName());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeInstanceName, args)
@ -359,7 +359,7 @@ PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeInstanceName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeUserDefinedName)
{
return PyString_FromString(self->fThis->GetAgeUserDefinedName());
return PyString_FromPlString(self->fThis->GetAgeUserDefinedName());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeUserDefinedName, args)

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

@ -81,12 +81,12 @@ class pfColorListElement : public pfGUIListText
if ( string1 )
{
fString1 = hsStringToWString(string1);
fText = nil;
fText = plString::Null;
}
else
{
fString1 = nil;
fText = L"";
fText = "";
}
fTextColor1 = color1;
if (string2)
@ -105,12 +105,12 @@ class pfColorListElement : public pfGUIListText
{
fString1 = new wchar_t[wcslen(string1)+1];
wcscpy(fString1,string1);
fText = nil;
fText = plString::Null;
}
else
{
fString1 = nil;
fText = L"";
fText = "";
}
fTextColor1 = color1;
if (string2)
@ -132,7 +132,7 @@ class pfColorListElement : public pfGUIListText
{
delete [] fString1;
fString1 = nil;
fText = nil;
fText = plString::Null;
}
if ( fString2 )
delete [] fString2;
@ -287,14 +287,7 @@ class pfListTextInBox : public pfGUIListText
uint32_t fMinHeight;
public:
pfListTextInBox( const char *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 )
pfListTextInBox( const plString &text, uint32_t min_width=0, uint32_t min_height=0 ) : pfGUIListText( text )
{
fMinWidth = min_width;
fMinHeight = min_height;
@ -510,14 +503,7 @@ uint16_t pyGUIControlListBox::GetNumElements( void )
return 0;
}
void pyGUIControlListBox::SetElement( uint16_t idx, const char* text )
{
wchar_t *wText = hsStringToWString(text);
SetElementW(idx,wText);
delete [] wText;
}
void pyGUIControlListBox::SetElementW( uint16_t idx, std::wstring text )
void pyGUIControlListBox::SetElement( uint16_t idx, const plString& text )
{
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
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 )
{
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 )
plString pyGUIControlListBox::GetElement( uint16_t idx )
{
if ( fGCkey )
{
@ -596,18 +573,10 @@ std::wstring pyGUIControlListBox::GetElementW( uint16_t idx )
}
}
}
return L"";
}
int16_t pyGUIControlListBox::AddString( const char *string )
{
wchar_t *wString = hsStringToWString(string);
int16_t retVal = AddStringW(wString);
delete [] wString;
return retVal;
return "";
}
int16_t pyGUIControlListBox::AddStringW( std::wstring string )
int16_t pyGUIControlListBox::AddString( const plString &string )
{
if ( fGCkey )
{
@ -615,7 +584,7 @@ int16_t pyGUIControlListBox::AddStringW( std::wstring string )
pfGUIListBoxMod* plbmod = pfGUIListBoxMod::ConvertNoRef(fGCkey->ObjectIsLoaded());
if ( plbmod )
{
pfGUIListText *element = new pfGUIListText( string.c_str() );
pfGUIListText *element = new pfGUIListText(string);
if( fBuildRoots.GetCount() > 0 )
fBuildRoots[ fBuildRoots.GetCount() - 1 ]->AddChild( element );
return plbmod->AddElement( element );
@ -642,22 +611,14 @@ int16_t pyGUIControlListBox::AddImage( pyImage& image, bool respectAlpha )
}
int16_t pyGUIControlListBox::FindString( const char *toCompareTo )
{
wchar_t *wToCompareTo = hsStringToWString(toCompareTo);
int16_t retVal = FindStringW(wToCompareTo);
delete [] wToCompareTo;
return retVal;
}
int16_t pyGUIControlListBox::FindStringW( std::wstring toCompareTo )
int16_t pyGUIControlListBox::FindString( const plString &toCompareTo )
{
if ( fGCkey )
{
// get the pointer to the modifier
pfGUIListBoxMod* plbmod = pfGUIListBoxMod::ConvertNoRef(fGCkey->ObjectIsLoaded());
if ( plbmod )
return plbmod->FindString(toCompareTo.c_str());
return plbmod->FindString(toCompareTo);
}
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 )
{
@ -754,23 +715,6 @@ int16_t pyGUIControlListBox::AddStringInBox( const char *string, uint32_t min_wi
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 )
{
if ( fGCkey )
@ -927,14 +871,7 @@ void pyGUIControlListBox::Unclickable( void )
}
}
void pyGUIControlListBox::AddBranch( const char *name, bool initiallyOpen )
{
wchar_t *wName = hsStringToWString(name);
AddBranchW(wName,initiallyOpen);
delete [] wName;
}
void pyGUIControlListBox::AddBranchW( std::wstring name, bool initiallyOpen )
void pyGUIControlListBox::AddBranch( const plString &name, bool initiallyOpen )
{
if ( fGCkey )
{
@ -942,7 +879,7 @@ void pyGUIControlListBox::AddBranchW( std::wstring name, bool initiallyOpen )
pfGUIListBoxMod* plbmod = pfGUIListBoxMod::ConvertNoRef(fGCkey->ObjectIsLoaded());
if ( plbmod )
{
pfGUIListTreeRoot *root = new pfGUIListTreeRoot( name.c_str() );
pfGUIListTreeRoot *root = new pfGUIListTreeRoot(name);
root->ShowChildren( initiallyOpen );
if( fBuildRoots.GetCount() > 0 )

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

@ -88,15 +88,12 @@ public:
virtual int32_t GetSelection( void );
virtual void SetSelection( int32_t item );
virtual void Refresh( void );
virtual void SetElement( uint16_t idx, const char* text );
virtual void SetElementW( uint16_t idx, std::wstring text );
virtual void SetElement( uint16_t idx, const plString& text );
virtual void RemoveElement( uint16_t index );
virtual void ClearAllElements( void );
virtual uint16_t GetNumElements( void );
virtual std::string GetElement( uint16_t idx );
virtual std::wstring GetElementW( uint16_t idx );
virtual int16_t AddString( const char *string );
virtual int16_t AddStringW( std::wstring string );
virtual plString GetElement( uint16_t idx );
virtual int16_t AddString( const plString &string );
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 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 SetSwatchEdgeOffset( uint32_t size );
virtual void SetStringJustify( uint16_t idx, uint32_t justify);
virtual int16_t FindString( const char *toCompareTo );
virtual int16_t FindStringW( std::wstring toCompareTo );
virtual int16_t FindString( const plString &toCompareTo );
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 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 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 int16_t AddStringInBox( const char *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 int16_t AddStringInBox( const plString &string, uint32_t min_width, uint32_t min_height );
virtual void ScrollToBegin( void );
virtual void ScrollToEnd( void );
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
// via additional AddBranch() calls. Call CloseBranch() to stop writing elements to that branch.
void AddBranch( const char *name, bool initiallyOpen );
void AddBranchW( std::wstring name, bool initiallyOpen );
void AddBranch( const plString &name, bool initiallyOpen );
void CloseBranch( void );
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");
PYTHON_RETURN_ERROR;
}
self->fThis->SetElementW(index, text);
self->fThis->SetElement(index, plString::FromWchar(text));
PYTHON_RETURN_NONE;
}
@ -148,7 +148,7 @@ PYTHON_METHOD_DEFINITION(ptGUIControlListBox, getElement, args)
PyErr_SetString(PyExc_TypeError, "getElement expects an unsigned short");
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)
@ -159,8 +159,7 @@ PYTHON_METHOD_DEFINITION(ptGUIControlListBox, getElementW, args)
PyErr_SetString(PyExc_TypeError, "getElementW expects an unsigned short");
PYTHON_RETURN_ERROR;
}
std::wstring retVal = self->fThis->GetElementW(index);
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
return PyUnicode_FromStringEx(self->fThis->GetElement(index));
}
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");
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)
@ -217,7 +216,7 @@ PYTHON_METHOD_DEFINITION(ptGUIControlListBox, findStringW, args)
PyErr_SetString(PyExc_TypeError, "findStringW expects a unicode string");
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)
@ -387,7 +386,7 @@ PYTHON_METHOD_DEFINITION(ptGUIControlListBox, addBranchW, args)
wchar_t* name = new wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, name, strLen);
name[strLen] = L'\0';
self->fThis->AddBranchW(name, initiallyOpen != 0);
self->fThis->AddBranch(plString::FromWchar(name), initiallyOpen != 0);
delete [] name;
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
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
if ( fPyFileMod )

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

@ -123,7 +123,7 @@ public:
// get a notify list item
virtual plKey GetNotifyListItem(int32_t i);
// 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
virtual void EnableControlKeyEvents();

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

@ -76,9 +76,9 @@ public:
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 SetServerAddr(const char * val) { fInfo.SetServerAddr( val ); }
void SetServerAddr(const plString & val) { fInfo.SetServerAddr( val ); }
void SetServerPort(uint16_t val) { fInfo.SetServerPort( val ); }
void SetServerGuid(const char * val) { fServerGuid.FromString( val ); fInfo.SetServerGuid( &fServerGuid ); }
bool HasServerName() const { return fInfo.HasServerName(); }
@ -86,9 +86,9 @@ public:
bool HasServerAddr() const { return fInfo.HasServerAddr(); }
bool HasServerPort() const { return fInfo.HasServerPort(); }
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(); }
const char * GetServerAddr() const { return fInfo.GetServerAddr(); }
plString GetServerAddr() const { return fInfo.GetServerAddr(); }
uint16_t GetServerPort() const { return fInfo.GetServerPort(); }
const char * GetServerGuid() const { fServerGuid.CopyFrom( fInfo.GetServerGuid() ); return fServerGuid.AsString().c_str(); }
};
@ -116,9 +116,9 @@ public:
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 SetServerAddr(const char * val) { fInfo.SetServerAddr( val ); }
void SetServerAddr(const plString & val) { fInfo.SetServerAddr( val ); }
void SetServerPort(uint16_t val) { fInfo.SetServerPort( val ); }
void SetServerGuid(const char * val) { fServerGuid.FromString( val ); fInfo.SetServerGuid( &fServerGuid ); }
bool HasServerName() const { return fInfo.HasServerName(); }
@ -126,9 +126,9 @@ public:
bool HasServerAddr() const { return fInfo.HasServerAddr(); }
bool HasServerPort() const { return fInfo.HasServerPort(); }
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(); }
const char * GetServerAddr() const { return fInfo.GetServerAddr(); }
plString GetServerAddr() const { return fInfo.GetServerAddr(); }
uint16_t GetServerPort() const { return fInfo.GetServerPort(); }
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)
{
return PyString_FromString(self->fThis->GetServerName());
return PyString_FromPlString(self->fThis->GetServerName());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfo, getServerType)
@ -153,7 +153,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfo, getServerType)
PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfo, getServerAddr)
{
return PyString_FromString(self->fThis->GetServerAddr());
return PyString_FromPlString(self->fThis->GetServerAddr());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfo, getServerPort)
@ -306,7 +306,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfoRef, hasServerGuid)
PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfoRef, getServerName)
{
return PyString_FromString(self->fThis->GetServerName());
return PyString_FromPlString(self->fThis->GetServerName());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfoRef, getServerType)
@ -316,7 +316,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfoRef, getServerType)
PYTHON_METHOD_DEFINITION_NOARGS(ptNetServerSessionInfoRef, getServerAddr)
{
return PyString_FromString(self->fThis->GetServerAddr());
return PyString_FromPlString(self->fThis->GetServerAddr());
}
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')
{
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
{
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();
link.GetAgeInfo()->SetAgeInstanceGuid(&guid);
link.GetAgeInfo()->SetAgeUserDefinedName( title.c_str() );
link.GetAgeInfo()->SetAgeDescription( desc.c_str() );
link.GetAgeInfo()->SetAgeUserDefinedName(title);
link.GetAgeInfo()->SetAgeDescription(desc);
VaultRegisterOwnedAge(&link);
}

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

@ -169,7 +169,7 @@ void plUoid::Read(hsStream* s)
s->LogReadLE(&fClassType, "ClassType");
s->LogReadLE(&fObjectID, "ObjectID");
s->LogSubStreamPushDesc("ObjectName");
fObjectName = s->LogReadSafeString_TEMP();
fObjectName = s->LogReadSafeString();
// conditional cloneIDs read
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)
{
fName = stream->ReadSafeString_TEMP();
fName = stream->ReadSafeString();
fDataType = stream->ReadLE32();
IReadNumber(stream);
fKey = mgr->ReadKey(stream);
@ -1379,7 +1379,7 @@ void proVariableEventData::IReadVersion(hsStream* s, hsResMgr* mgr)
contentFlags.Read(s);
if (contentFlags.IsBitSet(kProVariableName))
fName = s->ReadSafeString_TEMP();
fName = s->ReadSafeString();
if (contentFlags.IsBitSet(kProVariableDataType))
fDataType = s->ReadLE32();
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==*/
#include "hsStream.h"
#include "plGenericVar.h"
#include "hsMemory.h"
//////////////////////////////////////////////////////
// plGenericType
@ -55,116 +54,93 @@ void plGenericType::Reset()
void plGenericType::CopyFrom(const plGenericType& c)
{
IDeallocString();
fType = c.fType;
if (fType==kString || fType==kAny)
{
fS=hsStrcpy(c.fS);
fS = c.fS;
}
else
{
HSMemory::BlockMove((void*)&c.fI, (void*)&fI, 4);
memmove(&fD, &c.fD, sizeof(double));
}
}
//// 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!" );
static int32_t i;
if( fType == kAny )
{
hsAssert( fS != nil, "Weird parameter during conversion" );
i = atoi( fS );
return i;
return fS.ToInt();
}
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!" );
static uint32_t i;
if( fType == kAny )
{
hsAssert( fS != nil, "Weird parameter during conversion" );
i = atoi( fS );
return i;
return fS.ToUInt();
}
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!" );
static double d;
if( fType == kAny )
{
hsAssert( fS != nil, "Weird parameter during conversion" );
d = atof( fS );
return d;
return fS.ToDouble();
}
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!" );
static float f;
if( fType == kAny )
{
hsAssert( fS != nil, "Weird parameter during conversion" );
f = (float)atof( fS );
return f;
return fS.ToFloat();
}
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!" );
static bool b;
if( fType == kAny )
{
hsAssert( fS != nil, "Weird parameter during conversion" );
if( atoi( fS ) > 0 || stricmp( fS, "true" ) == 0 )
b = true;
else
b = false;
return b;
return (fS.ToInt() > 0 || fS.CompareI("true") == 0);
}
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!" );
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!" );
static char c;
if( fType == kAny )
{
hsAssert( fS != nil, "Weird parameter during conversion" );
c = fS[ 0 ];
return c;
return fS.CharAt(0);
}
return fC;
@ -172,7 +148,6 @@ const char & plGenericType::IToChar( void ) const
void plGenericType::Read(hsStream* s)
{
IDeallocString();
s->ReadLE(&fType);
switch ( fType )
@ -244,7 +219,6 @@ void plGenericType::Write(hsStream* s)
///////////////////////////////////////////////////
void plGenericVar::Read(hsStream* s)
{
delete [] fName;
fName = s->ReadSafeString();
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
{
switch (fType)

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

@ -53,9 +53,6 @@ class hsStream;
//
class plGenericType
{
public:
typedef char* CharPtr;
protected:
union
{
@ -64,9 +61,9 @@ protected:
float fF;
double fD;
bool fB;
CharPtr fS;
char fC;
};
plString fS;
public:
@ -86,20 +83,19 @@ public:
protected:
uint8_t fType;
const int32_t &IToInt( void ) const;
const uint32_t &IToUInt( void ) const;
const float &IToFloat( void ) const;
const double &IToDouble( void ) const;
const bool &IToBool( void ) const;
const CharPtr &IToString( void ) const;
const char &IToChar( void ) const;
int32_t IToInt( void ) const;
uint32_t IToUInt( void ) const;
float IToFloat( void ) const;
double IToDouble( void ) const;
bool IToBool( void ) const;
plString IToString( void ) const;
char IToChar( void ) const;
void IDeallocString() { if (fType==kString || fType==kAny) {delete [] fS; fS=nil;} }
public:
plGenericType() : fType(kNone) { Reset(); }
plGenericType(const plGenericType& c) { CopyFrom(c); }
virtual ~plGenericType() { IDeallocString(); }
virtual ~plGenericType() { }
plGenericType& operator=(const plGenericType& c) { CopyFrom(c); return *this; }
@ -110,7 +106,7 @@ public:
operator double() const { return IToDouble(); }
operator float() const { return IToFloat(); }
operator bool() const { return IToBool(); }
operator const CharPtr() const { return IToString(); }
operator plString() const { return IToString(); }
operator char() const { return IToChar(); }
void SetType(Types t) { fType=t; }
@ -124,7 +120,7 @@ public:
void Set( float f ) { fF = f; fType = kFloat; }
void Set( double d ) { fD = d; fType = kDouble; }
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; }
// explicit set
@ -133,11 +129,10 @@ public:
void SetFloat( float f ) { fF = f; fType = kFloat; }
void SetDouble( double d ) { fD = d; fType = kDouble; }
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 SetAny( CharPtr s ) { IDeallocString(); fS = hsStrcpy(s); fType = kAny; }
void SetAny( const plString& s ) { fS = s; fType = kAny; }
void SetNone( void ) { fType = kNone; }
void SetVar(Types t, unsigned int size, void* val);
virtual void Read(hsStream* s);
virtual void Write(hsStream* s);
@ -150,17 +145,17 @@ class plGenericVar
{
protected:
plGenericType fValue;
char* fName;
plString fName;
public:
plGenericVar(const plGenericVar &c) : fName(nil) { CopyFrom(c); }
plGenericVar(const char* name=nil) : fName(nil) { SetName(name); }
virtual ~plGenericVar() { delete [] fName; }
plGenericVar(const plGenericVar &c) { CopyFrom(c); }
plGenericVar(const plString& name="") : fName(name) { }
virtual ~plGenericVar() { }
virtual void Reset() { Value().Reset(); } // reset runtime state, not inherent state
plGenericVar& operator=(const plGenericVar &c) { CopyFrom(c); return *this; }
void CopyFrom(const plGenericVar &c) { delete [] fName; fName=hsStrcpy(c.GetName()); fValue=c.Value(); }
const char* GetName() const { return fName; }
void SetName(const char* n) { delete [] fName; fName = hsStrcpy(n); }
void CopyFrom(const plGenericVar &c) { fName=c.GetName(); fValue=c.Value(); }
plString GetName() const { return fName; }
void SetName(const plString& n) { fName = n; }
plGenericType& Value() { return fValue; }
const plGenericType& Value() const { return fValue; }
@ -186,7 +181,7 @@ public:
operator float() const { return (float)fValue; }
operator double() const { return (double)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; }
};

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

@ -190,7 +190,7 @@ void plSynchedObject::RegisterSynchedValueFriend(plSynchedValueBase* v)
//
// 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,
(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.
// 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 0
if (plNetClientApp::GetInstance())
plNetClientApp::GetInstance()->DebugMsg("NotOKToDirty - Not queueing SDL state, obj %s, sdl %s",
GetKeyName(), SDLStateName);
GetKeyName().c_str(), SDLStateName.c_str());
#endif
return false;
}
@ -220,7 +220,7 @@ bool plSynchedObject::DirtySynchState(const char* SDLStateName, uint32_t synchFl
#if 0
if (plNetClientApp::GetInstance())
plNetClientApp::GetInstance()->DebugMsg("LocalOnly Object - Not queueing SDL msg, obj %s, sdl %s",
GetKeyName(), SDLStateName);
GetKeyName().c_str(), SDLStateName.c_str());
#endif
return false;
}
@ -236,7 +236,7 @@ bool plSynchedObject::DirtySynchState(const char* SDLStateName, uint32_t synchFl
{
if (plNetClientApp::GetInstance())
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.
// 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;
std::vector<StateDefn>::iterator it=fDirtyStates.begin();
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)
(*it).fSendFlags |= kForceFullSend;
@ -282,7 +282,7 @@ void plSynchedObject::IAddDirtyState(plKey objKey, const char* sdlName, uint32_t
{
#if 0
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
}
}
@ -290,12 +290,12 @@ void plSynchedObject::IAddDirtyState(plKey objKey, const char* sdlName, uint32_t
//
// STATIC
//
void plSynchedObject::IRemoveDirtyState(plKey objKey, const char* sdlName)
void plSynchedObject::IRemoveDirtyState(plKey objKey, const plString& sdlName)
{
std::vector<StateDefn>::iterator it=fDirtyStates.begin();
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);
break;
@ -342,7 +342,7 @@ void plSynchedObject::Read(hsStream* stream, hsResMgr* mgr)
int i;
for(i=0;i<num;i++)
{
std::string s;
plString s;
plMsgStdStringHelper::Peek(s, stream);
fSDLExcludeList.push_back(s);
}
@ -356,7 +356,7 @@ void plSynchedObject::Read(hsStream* stream, hsResMgr* mgr)
int i;
for(i=0;i<num;i++)
{
std::string s;
plString s;
plMsgStdStringHelper::Peek(s, stream);
fSDLVolatileList.push_back(s);
}
@ -449,7 +449,7 @@ void plSynchedObject::CallDirtyNotifiers() {}
//
// 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?
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
//
bool plSynchedObject::IOKToNetwork(const char* sdlName, uint32_t* synchFlags) const
bool plSynchedObject::IOKToNetwork(const plString& sdlName, uint32_t* synchFlags) const
{
// determine destination
bool dstServerOnly=false, dstClientsOnly=false, dstClientsAndServer=false;
@ -523,14 +523,14 @@ bool plSynchedObject::IOKToNetwork(const char* sdlName, uint32_t* synchFlags) co
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
SDLStateList::const_iterator it = list.begin();
for(; it != list.end(); it++)
if (!stricmp((*it).c_str(), sdlName))
if (it->CompareI(sdlName) == 0)
return it;
return it; // .end(), false
@ -540,19 +540,19 @@ plSynchedObject::SDLStateList::const_iterator plSynchedObject::IFindInSDLStateLi
// 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())
{
fSDLExcludeList.push_back(sdlName); // Don't dupe sdlName, std::string will copy
fSDLExcludeList.push_back(sdlName);
fSynchFlags |= kExcludePersistentState;
}
}
}
void plSynchedObject::RemoveFromSDLExcludeList(const char* sdlName)
void plSynchedObject::RemoveFromSDLExcludeList(const plString& sdlName)
{
SDLStateList::const_iterator it=IFindInSDLStateList(fSDLExcludeList, sdlName);
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)
return true;
@ -579,9 +579,9 @@ bool plSynchedObject::IsInSDLExcludeList(const char* sdlName) const
// 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())
{
@ -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);
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)
return true;

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

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

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

@ -144,7 +144,7 @@ public:
{
MakeDirty(); // dirty value
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 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 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
bool plSound::DirtySynchState(const char* sdlName /* kSDLSound */, uint32_t sendFlags)
bool plSound::DirtySynchState(const plString& sdlName /* kSDLSound */, uint32_t sendFlags)
{
/*
if( sdlName == nil )

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

@ -239,7 +239,7 @@ public:
virtual void UpdateSoftVolume( bool enable, bool firstTime = false );
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
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( &fDataLength );
fFileName = s->ReadSafeString_TEMP();
fFileName = s->ReadSafeString();
s->ReadLE( &fHeader.fFormatTag );
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);
// read in the name of the animation itself
fName = stream->ReadSafeString_TEMP();
fName = stream->ReadSafeString();
fStart = stream->ReadLEScalar();
fEnd = stream->ReadLEScalar();
@ -412,7 +412,7 @@ void plATCAnim::Read(hsStream *stream, hsResMgr *mgr)
int numMarkers = stream->ReadLE32();
for (i = 0; i < numMarkers; i++)
{
plString name = stream->ReadSafeString_TEMP();
plString name = stream->ReadSafeString();
float time = stream->ReadLEFloat();
fMarkers[name] = time;
}
@ -420,7 +420,7 @@ void plATCAnim::Read(hsStream *stream, hsResMgr *mgr)
int numLoops = stream->ReadLE32();
for (i = 0; i < numLoops; i++)
{
plString name = stream->ReadSafeString_TEMP();
plString name = stream->ReadSafeString();
float begin = stream->ReadLEScalar();
float end = stream->ReadLEScalar();
fLoops[name] = std::pair<float,float>(begin,end);
@ -665,28 +665,13 @@ float plEmoteAnim::GetFadeOut() const
plAgeGlobalAnim::plAgeGlobalAnim()
: plAGAnim()
{
fGlobalVarName = nil;
}
// ctor --------------------------------------------------------------------
// -----
plAgeGlobalAnim::plAgeGlobalAnim(const plString &name, double start, double end)
: plAGAnim(name, start, end),
fGlobalVarName(nil)
{
}
// dtor ---------------------------
// -----
plAgeGlobalAnim::~plAgeGlobalAnim()
{
delete [] fGlobalVarName;
}
void plAgeGlobalAnim::SetGlobalVarName(char *name)
: plAGAnim(name, start, end)
{
delete [] fGlobalVarName;
fGlobalVarName = hsStrcpy(name);
}

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

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

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

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

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

@ -119,7 +119,7 @@ void plAGChannel::Read(hsStream *stream, hsResMgr *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
//
bool plAGMasterMod::DirtySynchState(const char* SDLStateName, uint32_t synchFlags)
bool plAGMasterMod::DirtySynchState(const plString& SDLStateName, uint32_t synchFlags)
{
if(GetNumTargets() > 0 && (!fIsGrouped || fIsGroupMaster))
{

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

@ -206,7 +206,7 @@ public:
virtual void Read(hsStream * stream, hsResMgr *mgr);
bool HasRunningAnims();
bool DirtySynchState(const char* SDLStateName, uint32_t synchFlags);
bool DirtySynchState(const plString& SDLStateName, uint32_t synchFlags);
CLASSNAME_REGISTER( plAGMasterMod );
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);
// read in the name of the modifier
fChannelName = stream->ReadSafeString_TEMP();
fChannelName = stream->ReadSafeString();
}
// 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
void plAnimStage::Read(hsStream *stream, hsResMgr *mgr)
{
fAnimName = stream->ReadSafeString_TEMP();
fAnimName = stream->ReadSafeString();
fNotify = stream->ReadByte();
fForwardType = (ForwardType)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->WriteSafeString(fAnimationPrefix);
stream->WriteSafeString(fBodyAgeName.c_str());
stream->WriteSafeString(fBodyFootstepSoundPage.c_str());
stream->WriteSafeString(fBodyAgeName);
stream->WriteSafeString(fBodyFootstepSoundPage);
}
void plArmatureMod::Read(hsStream * stream, hsResMgr *mgr)
@ -1756,7 +1756,7 @@ void plArmatureMod::Read(hsStream * stream, hsResMgr *mgr)
fMeshKeys.push_back(mgr->ReadKey(stream));
// read the root name string
fRootName = stream->ReadSafeString_TEMP();
fRootName = stream->ReadSafeString();
// read in the brains
int nBrains = stream->ReadLE32();
@ -1780,9 +1780,7 @@ void plArmatureMod::Read(hsStream * stream, hsResMgr *mgr)
// Attach the Footstep emitter scene object
hsResMgr *mgr = hsgResMgr::ResMgr();
const char *age = fBodyAgeName.c_str();
const char *page = fBodyFootstepSoundPage.c_str();
const plLocation &gLoc = plKeyFinder::Instance().FindLocation(age, page);
const plLocation &gLoc = plKeyFinder::Instance().FindLocation(fBodyAgeName, fBodyFootstepSoundPage);
if (gLoc.IsValid())
{
@ -1823,23 +1821,17 @@ void plArmatureMod::Read(hsStream * stream, hsResMgr *mgr)
fPhysHeight = stream->ReadLEFloat();
fPhysWidth = stream->ReadLEFloat();
fAnimationPrefix = stream->ReadSafeString_TEMP();
char *temp = stream->ReadSafeString();
fBodyAgeName = temp;
delete [] temp;
temp = stream->ReadSafeString();
fBodyFootstepSoundPage = temp;
delete [] temp;
fAnimationPrefix = stream->ReadSafeString();
fBodyAgeName = stream->ReadSafeString();
fBodyFootstepSoundPage = stream->ReadSafeString();
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
if (SDLStateName && stricmp(SDLStateName, kSDLAvatar))
if (SDLStateName.CompareI(kSDLAvatar) != 0)
{
return false;
}
@ -2561,9 +2553,9 @@ int plArmatureMod::GetKILevel()
return VaultGetKILevel();
}
void plArmatureMod::SetLinkInAnim(const char *animName)
void plArmatureMod::SetLinkInAnim(const plString &animName)
{
if (animName)
if (!animName.IsNull())
{
plAGAnim *anim = FindCustomAnim(animName);
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 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);
plClothingOutfit *GetClothingOutfit() const { return fClothingOutfit; }
plClothingSDLModifier *GetClothingSDLMod() const { return fClothingSDLMod; }
@ -340,7 +340,7 @@ public:
bool IsKILowestLevel();
int GetKILevel();
void SetLinkInAnim(const char *animName);
void SetLinkInAnim(const plString &animName);
plKey GetLinkInAnimKey() const;
enum
@ -369,11 +369,11 @@ public:
void SetPhysicalDims(float height, float width) { fPhysHeight = height; fPhysWidth = width; }
void SetBodyAgeName(const char* ageName) {if (ageName) fBodyAgeName = ageName; else fBodyAgeName = "";}
void SetBodyFootstepSoundPage(const char* pageName) {if (pageName) fBodyFootstepSoundPage = pageName; else fBodyFootstepSoundPage = "";}
void SetBodyAgeName(const plString& ageName) { fBodyAgeName = ageName; }
void SetBodyFootstepSoundPage(const plString& pageName) { fBodyFootstepSoundPage = pageName; }
void SetAnimationPrefix(const plString& prefix) { fAnimationPrefix = prefix; }
const char* GetUserStr() {return fUserStr.c_str();}
plString GetUserStr() const { return fUserStr; }
protected:
void IInitDefaults();
@ -443,12 +443,12 @@ protected:
bool fDontPanicLink;
// strings for animations, age names, footstep sounds, etc
std::string fBodyAgeName;
std::string fBodyFootstepSoundPage;
plString fBodyAgeName;
plString fBodyFootstepSoundPage;
plString fAnimationPrefix;
// user-defined string assigned to this avatar
std::string fUserStr;
plString fUserStr;
};
// PLARMATURELOD

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

@ -160,14 +160,14 @@ void plClothingItem::Read(hsStream *s, hsResMgr *mgr)
{
hsKeyedObject::Read(s, mgr);
fName = s->ReadSafeString_TEMP();
fName = s->ReadSafeString();
fGroup = s->ReadByte();
fType = s->ReadByte();
fTileset = s->ReadByte();
fSortOrder = s->ReadByte();
fCustomText = s->ReadSafeString_TEMP();
fDescription = s->ReadSafeString_TEMP();
fCustomText = s->ReadSafeString();
fDescription = s->ReadSafeString();
if (s->ReadBool())
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;
for (i = 0; i < tileCount; i++)
{
fElementNames.Append(s->ReadSafeString_TEMP());
fElementNames.Append(s->ReadSafeString());
int layerCount = s->ReadByte();
for (j = 0; j < layerCount; j++)
@ -375,10 +375,10 @@ void plClothingBase::Read(hsStream* s, hsResMgr* mgr)
{
hsKeyedObject::Read(s, mgr);
fName = s->ReadSafeString_TEMP();
fName = s->ReadSafeString();
if (s->ReadBool())
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)
@ -1405,7 +1405,7 @@ bool plClothingOutfit::MsgReceive(plMessage* msg)
// TESTING SDL
// 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
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 Write(hsStream* s, hsResMgr* mgr);
bool DirtySynchState(const char* SDLStateName, uint32_t synchFlags);
bool DirtySynchState(const plString& SDLStateName, uint32_t synchFlags);
void StripAccessories();
void WearDefaultClothing();

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

@ -465,7 +465,7 @@ void plAvAnimTask::LeaveAge(plArmatureMod *avatar)
// READ
void plAvAnimTask::Read(hsStream *stream, hsResMgr *mgr)
{
fAnimName = stream->ReadSafeString_TEMP();
fAnimName = stream->ReadSafeString();
fInitialBlend = stream->ReadLEScalar();
fTargetBlend = stream->ReadLEScalar();
fFadeSpeed = stream->ReadLEScalar();
@ -802,8 +802,8 @@ void plAvOneShotLinkTask::Write(hsStream *stream, hsResMgr *mgr)
void plAvOneShotLinkTask::Read(hsStream *stream, hsResMgr *mgr)
{
plAvOneShotTask::Read(stream, mgr);
fAnimName = stream->ReadSafeString_TEMP();
fMarkerName = stream->ReadSafeString_TEMP();
fAnimName = stream->ReadSafeString();
fMarkerName = stream->ReadSafeString();
}
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
fGuestAcceptMsg = nil;
fSynchBone = stream->ReadSafeString_TEMP();
fSynchBone = stream->ReadSafeString();
fAutoStartGuest = stream->ReadBool();
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);
fModelName = stream->ReadSafeString_TEMP();
fAccountName = stream->ReadSafeString_TEMP();
fModelName = stream->ReadSafeString();
fAccountName = stream->ReadSafeString();
fAutoSpawn = stream->ReadBool();
if(stream->ReadBool())
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);
// read in the name of the animation itself
fAnimName = stream->ReadSafeString_TEMP();
fAnimName = stream->ReadSafeString();
fSeekDuration = stream->ReadLEScalar();
fDrivable = stream->ReadBool();
fReversable = stream->ReadBool();

41
Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.cpp

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

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

@ -86,7 +86,6 @@ plDynSurfaceWriter::plWinSurface::plWinSurface()
fWidth = fHeight = 0;
fSaveNum = 0;
fFontFace = nil;
fFontSize = 0;
fFontFlags = 0;
fFontAntiAliasRGB = false;
@ -207,8 +206,7 @@ void plDynSurfaceWriter::plWinSurface::Release( void )
fBits = nil;
fWidth = fHeight = 0;
delete [] fFontFace;
fFontFace = nil;
fFontFace = plString::Null;
fFontSize = 0;
fFontFlags = 0;
fFontAntiAliasRGB = false;
@ -231,19 +229,18 @@ static int SafeStrCmp( const char *str1, const char *str2 )
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 )
return true;
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 != nil ) ? hsStrcpy( face ) : nil;
fFontFace = face;
fFontSize = size;
fFontFlags = flags;
fFontAntiAliasRGB = aaRGB;
@ -256,7 +253,7 @@ void plDynSurfaceWriter::plWinSurface::SetFont( const char *face, uint16_t si
fFont = nil;
}
if( face == nil )
if (face.IsEmpty())
return;
bool bold = ( fFontFlags & plDynSurfaceWriter::kFontBold ) ? true : false;
@ -283,10 +280,10 @@ void plDynSurfaceWriter::plWinSurface::SetFont( const char *face, uint16_t si
if( fFont == nil )
{
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 = nil;
fFontFace = plString::Null;
fFontSize = 0;
return;
}
@ -385,7 +382,7 @@ void plDynSurfaceWriter::IInit( void )
fJustify = kLeftJustify;
fFlags = 0;
fFlushed = true;
fFontFace = nil;
fFontFace = plString::Null;
fFontSize = 0;
fFontBlockedRGB = false;
}
@ -401,8 +398,7 @@ void plDynSurfaceWriter::Reset( void )
fCurrTarget = nil;
fFlushed = true;
delete [] fFontFace;
fFontFace = nil;
fFontFace = plString::Null;
fFontSize = 0;
}
@ -514,8 +510,7 @@ void plDynSurfaceWriter::SwitchTarget( plDynamicTextMap *target )
if( hadToAllocate )
{
delete [] fFontFace;
fFontFace = nil;
fFontFace = plString::Null;
fFontSize = 0;
fFontFlags = 0;
}
@ -701,7 +696,7 @@ void plDynSurfaceWriter::SetFont( const char *face, uint16_t size, uint8_t fo
//// 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 );

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

@ -148,14 +148,14 @@ class plDynSurfaceWriter
void IRefreshOSJustify( void );
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;
uint32_t fFlags;
Justify fJustify;
bool fFlushed;
char *fFontFace;
plString fFontFace;
uint16_t fFontSize;
uint8_t fFontFlags;
bool fFontAntiAliasRGB;
@ -182,7 +182,7 @@ class plDynSurfaceWriter
uint16_t fWidth, fHeight;
char *fFontFace;
plString fFontFace;
uint16_t fFontSize;
uint8_t fFontFlags;
bool fFontAntiAliasRGB, fFontBlockedRGB;
@ -194,8 +194,8 @@ class plDynSurfaceWriter
void Release( void );
bool WillFit( uint16_t w, uint16_t h );
bool FontMatches( const char *face, uint16_t size, uint8_t flags, bool aaRGB );
void SetFont( 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 plString &face, uint16_t size, uint8_t flags, bool aaRGB );
};
class plWinRGBSurface : public plWinSurface

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

@ -77,7 +77,7 @@ plProfile_Extern(MemMipmaps);
plDynamicTextMap::plDynamicTextMap()
: 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)
{
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 )
: fInitBuffer(nullptr), fFontFace(nullptr)
: fInitBuffer(nullptr)
{
Create( width, height, hasAlpha, extraWidth, extraHeight );
}
@ -163,8 +163,7 @@ void plDynamicTextMap::Reset( void )
delete [] fInitBuffer;
fInitBuffer = nil;
delete [] fFontFace;
fFontFace = nil;
fFontFace = plString::Null;
// Destroy the old texture ref, since we're no longer using it
SetDeviceRef( nil );
@ -413,22 +412,21 @@ void plDynamicTextMap::SetJustify( Justify j )
//// 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
// if( !IIsValid() )
// return;
delete [] fFontFace;
if (plLocalization::UsingUnicode())
{
// 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
hsStatusMessageF("We are using a unicode language, overriding font choice of %s", face ? face : "nil");
fFontFace = hsStrcpy( "Unicode" );
hsStatusMessageF("We are using a unicode language, overriding font choice of %s", face.c_str("nil"));
fFontFace = "Unicode";
}
else
fFontFace = ( face != nil ) ? hsStrcpy( face ) : nil;
fFontFace = face;
fFontSize = size;
fFontFlags = fontFlags;
fFontAntiAliasRGB = antiAliasRGB;
@ -439,11 +437,9 @@ void plDynamicTextMap::SetFont( const char *face, uint16_t size, uint8_t font
if ( fCurrFont == nil )
{
if (!fCurrFont)
hsStatusMessageF("Font missing - %s. Using Arial", fFontFace ? fFontFace : "nil");
hsStatusMessageF("Font missing - %s. Using Arial", fFontFace.c_str("nil"));
if ( fFontFace )
delete [] fFontFace;
fFontFace = hsStrcpy( "Arial" );
fFontFace = "Arial";
// lets try again with Arial
fCurrFont = plFontCache::GetInstance().GetFont( fFontFace, (uint8_t)fFontSize,
( ( 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 ///////////////////////////////////////////////////////////
void plDynamicTextMap::SetLineSpacing( int16_t spacing )
@ -515,11 +504,10 @@ void plDynamicTextMap::DrawString( uint16_t x, uint16_t y, const wchar_t *tex
//// 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);
DrawClippedString(x,y,wText,width,height);
delete [] wText;
// TEMP
DrawClippedString(x, y, text.ToWchar().GetData(), width, 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 ////////////////////////////////////////////////////////
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);
DrawClippedString(x,y,wText,clipX,clipY,width,height);
delete [] wText;
// TEMP
DrawClippedString(x, y, text.ToWchar().GetData(), width, 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 ////////////////////////////////////////////////////////
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);
DrawWrappedString(x,y,wText,width,height,lastX,lastY);
delete [] wText;
// TEMP
DrawWrappedString(x, y, text.ToWchar().GetData(), width, height, lastX, 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 //////////////////////////////////////////////////////////
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);
uint16_t w = CalcStringWidth(wText,height);
delete [] wText;
return w;
// TEMP
return CalcStringWidth(text.ToWchar().GetData(), height);
}
uint16_t plDynamicTextMap::CalcStringWidth( const wchar_t *text, uint16_t *height )
@ -614,11 +598,10 @@ void plDynamicTextMap::SetFirstLineIndent( int16_t indent )
//// 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);
CalcWrappedStringSize(wText,width,height,firstClippedChar,maxAscent,lastX,lastY);
delete [] wText;
// TEMP
CalcWrappedStringSize(text.ToWchar().GetData(), width, height, firstClippedChar, maxAscent, lastX, 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 );
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 )
SetLineSpacing( textMsg->fLineSpacing );
@ -902,7 +885,7 @@ void plDynamicTextMap::Swap( plDynamicTextMap *other )
SWAP_ME( bool, fShadowed, other->fShadowed );
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( uint8_t, fFontFlags, other->fFontFlags );
SWAP_ME( bool, fFontAntiAliasRGB, other->fFontAntiAliasRGB );

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

@ -152,23 +152,22 @@ class plDynamicTextMap : public plMipmap
kFontShadowed = 0x04
};
void SetFont( const char *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 SetFont( const plString &face, uint16_t size, uint8_t fontFlags = 0, bool antiAliasRGB = true );
void SetLineSpacing( int16_t spacing );
void SetTextColor( hsColorRGBA &color, bool blockRGB = false );
void SetJustify( Justify j );
void DrawString( uint16_t x, uint16_t y, const char *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 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 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 );
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 );
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 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 );
@ -201,7 +200,7 @@ class plDynamicTextMap : public plMipmap
// Gets for font values
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; }
bool GetFontAARGB( void ) const { return fFontAntiAliasRGB; }
hsColorRGBA GetFontColor( void ) const { return fFontColor; }
@ -225,7 +224,7 @@ class plDynamicTextMap : public plMipmap
bool fHasAlpha, fShadowed;
Justify fJustify;
char *fFontFace;
plString fFontFace;
uint16_t fFontSize;
uint8_t fFontFlags;
bool fFontAntiAliasRGB;

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

@ -117,7 +117,7 @@ void plFont::IClear( bool onConstruct )
if( !onConstruct )
delete [] fBMapData;
memset( fFace, 0, sizeof( fFace ) );
fFace = plString::Null;
fSize = 0;
fFlags = 0;
@ -141,16 +141,6 @@ void plFont::IClear( bool onConstruct )
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 )
{
hsKeyedObject::Read( s, mgr );
@ -232,12 +222,10 @@ static inline bool IIsDrawableWordBreak( const char c )
// The base render function. Additional options are specified externally,
// 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
wchar_t *wideString = hsStringToWString(string);
RenderString(mip,x,y,wideString,lastX,lastY);
delete [] wideString;
// TEMP
RenderString(mip, x, y, string.ToWchar().GetData(), lastX, lastY);
}
@ -990,7 +978,7 @@ void plFont::IRenderCharNull( const plCharacter &c )
//// CalcString Variations ////////////////////////////////////////////////////
uint16_t plFont::CalcStringWidth( const char *string )
uint16_t plFont::CalcStringWidth( const plString &string )
{
uint16_t w, h, a, lX, lY;
uint32_t s;
@ -1006,12 +994,10 @@ uint16_t plFont::CalcStringWidth( const wchar_t *string )
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
wchar_t *wideString = hsStringToWString(string);
CalcStringExtents(wideString,width,height,ascent,firstClippedChar,lastX,lastY);
delete [] wideString;
CalcStringExtents(string.ToWchar().GetData(), width, height, ascent, firstClippedChar, lastX, 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();
}
char faceName[ 256 ], deviceName[ 256 ];
char faceName[ 257 ], deviceName[ 256 ];
if( fntInfo.face != 0 )
{
stream->SetPosition( fntInfo.face );
@ -1207,7 +1193,8 @@ bool plFont::LoadFromFNTStream( hsStream *stream )
if( faceName[ i ] == 0 )
break;
}
strncpy( fFace, faceName, sizeof( fFace ) );
faceName[256] = 0;
fFace = faceName;
}
if( fntInfo.device != 0 )
{
@ -1926,7 +1913,11 @@ bool plFont::LoadFromBDF( const char *path, plBDFConvertCallback *callback )
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();
s->ReadLE( &fFlags );
@ -1959,7 +1950,10 @@ bool plFont::ReadRaw( 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->WriteLE( fFlags );

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

@ -131,7 +131,7 @@ class plFont : public hsKeyedObject
friend class plBDFCharsParser;
// Font face and size. This is just used for IDing purposes, not for rendering
char fFace[ 256 ];
plString fFace;
uint8_t fSize;
uint32_t fFlags;
@ -244,7 +244,7 @@ class plFont : public hsKeyedObject
virtual void Read( 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; }
uint16_t GetFirstChar( void ) const { return fFirstChar; }
uint16_t GetNumChars( void ) const { return fCharacters.GetCount(); }
@ -256,8 +256,8 @@ class plFont : public hsKeyedObject
uint32_t GetBitmapHeight( void ) const { return fHeight; }
uint8_t GetBitmapBPP( void ) const { return fBPP; }
void SetFace( const char *face );
void SetSize( uint8_t size );
void SetFace( const plString &face ) { fFace = face; }
void SetSize( uint8_t size ) { fSize = size; }
void SetFlags( uint32_t flags ) { fFlags = flags; }
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; }
@ -275,12 +275,12 @@ class plFont : public hsKeyedObject
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 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 );
uint16_t CalcStringWidth( const char *string );
uint16_t CalcStringWidth( const plString &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 );
bool LoadFromFNT( const char *path );

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

@ -89,22 +89,15 @@ 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;
int currDeltaSize = 100000;
char toFind[ 256 ];
strcpy( toFind, face );
strlwr( toFind );
for( i = 0; i < fCache.GetCount(); i++ )
{
char thisOne[ 256 ];
strcpy( thisOne, fCache[ i ]->GetFace() );
strlwr( thisOne );
if( strncmp( thisOne, toFind, strlen( toFind ) ) == 0 &&
if (fCache[i]->GetFace().CompareNI(face, face.GetSize()) == 0 &&
(fCache[i]->GetFlags() == fontFlags))
{
int delta = fCache[ i ]->GetSize() - size;
@ -126,17 +119,16 @@ plFont *plFontCache::GetFont( const char *face, uint8_t size, uint32_t fontFlag
}
// 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
char *c = strchr( toFind, ' ' );
if( c != nil )
// asking for "Times New Roman", so strip all but the first word from our font and try the search again
ssize_t sp = face.Find(' ');
if (sp >= 0)
{
*c = 0;
return GetFont( toFind, size, fontFlags );
return GetFont(face.Left(sp), size, fontFlags);
}
else if( fontFlags != 0 )
{
// 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 )
{
//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;
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 );
}

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

@ -91,7 +91,7 @@ class plFontCache : public hsKeyedObject
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 );
// void FreeFont( HFONT font );

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

@ -92,7 +92,7 @@ plWinFontCache &plWinFontCache::GetInstance( void )
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;
@ -105,7 +105,7 @@ HFONT plWinFontCache::IFindFont( const char *face, int height, int weight, boo
fFontCache[ i ].fItalic == italic &&
fFontCache[ i ].fQuality == quality )
{
if( strcmp( fFontCache[ i ].fFace, face ) == 0 )
if (fFontCache[i].fFace == face)
return fFontCache[ i ].fFont;
}
}
@ -113,7 +113,7 @@ HFONT plWinFontCache::IFindFont( const char *face, int height, int weight, boo
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;
int i;
@ -122,12 +122,12 @@ HFONT plWinFontCache::IMakeFont( const char *face, int height, int weight, boo
// Find a cached name for us
for( i = 0; i < fFontNameCache.GetCount(); i++ )
{
if( strcmp( face, fFontNameCache[ i ] ) == 0 )
if (face == fFontNameCache[i])
break;
}
if( i == fFontNameCache.GetCount() )
fFontNameCache.Append( hsStrcpy( face ) );
fFontNameCache.Append(face);
myRec.fFace = fFontNameCache[ i ];
myRec.fHeight = height;
@ -135,8 +135,8 @@ HFONT plWinFontCache::IMakeFont( const char *face, int height, int weight, boo
myRec.fItalic = italic;
myRec.fQuality = quality;
myRec.fFont = CreateFont( height, 0, 0, 0, weight, italic ? TRUE : FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH, face );
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.ToWchar().GetData() );
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";
if( static_cast<bool>(fontInfo.lfItalic) != italic )
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";
if( err != nil )
@ -199,13 +199,14 @@ HFONT plWinFontCache::IMakeFont( const char *face, int height, int weight, boo
}
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;
}
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 );
if( font == nil )
@ -226,8 +227,6 @@ void plWinFontCache::Clear( void )
DeleteObject( fFontCache[ i ].fFont );
fFontCache.Reset();
for( i = 0; i < fFontNameCache.GetCount(); i++ )
delete [] fFontNameCache[ i ];
fFontNameCache.Reset();
for( i = 0; i < fCustFonts.GetCount(); i++ )

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

@ -80,7 +80,7 @@ class plWinFontCache
public:
HFONT fFont;
char *fFace; // Pointer is owned by fFontNameCache
plString fFace;
int fHeight;
int fWeight;
bool fItalic;
@ -98,15 +98,15 @@ class plWinFontCache
bool fInShutdown;
hsTArray<plFontRecord> fFontCache;
hsTArray<char *> fFontNameCache;
hsTArray<plString> fFontNameCache;
char *fCustFontDir;
hsTArray<plCustFont *> fCustFonts;
plWinFontCache();
HFONT IFindFont( const char *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 IFindFont( const plString &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 );
@ -115,7 +115,7 @@ class plWinFontCache
virtual ~plWinFontCache();
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 Clear( void );

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

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

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

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

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

@ -68,17 +68,14 @@ void plAIMsg::Read(hsStream* stream, hsResMgr* mgr)
{
plMessage::IMsgRead(stream, mgr);
char* temp = stream->ReadSafeString();
if (temp)
fBrainUserStr = temp;
delete [] temp;
fBrainUserStr = stream->ReadSafeString();
}
void plAIMsg::Write(hsStream* stream, hsResMgr* 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 Write(hsStream* stream, hsResMgr* mgr);
void BrainUserString(const std::string& userStr) {fBrainUserStr = userStr;}
std::string BrainUserString() const {return fBrainUserStr;}
void BrainUserString(const plString& userStr) {fBrainUserStr = userStr;}
plString BrainUserString() const {return fBrainUserStr;}
// enum for all messages to make things easier for people that use us
enum
@ -75,7 +75,7 @@ public:
};
private:
std::string fBrainUserStr;
plString fBrainUserStr;
};
// 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(&fTime);
fAnimName = stream->ReadSafeString_TEMP();
fLoopName = stream->ReadSafeString_TEMP();
fAnimName = stream->ReadSafeString();
fLoopName = stream->ReadSafeString();
}
void plAnimCmdMsg::Write(hsStream* stream, hsResMgr* mgr)
@ -134,7 +134,7 @@ void plAGCmdMsg::Read(hsStream* stream, hsResMgr* mgr)
stream->ReadLE(&fAmp);
stream->ReadLE(&fAmpRate);
fAnimName = stream->ReadSafeString_TEMP();
fAnimName = stream->ReadSafeString();
}
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);
fAnimName = stream->ReadSafeString_TEMP();
fAnimName = stream->ReadSafeString();
fDrivable = 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 );
fColor.Read( s );
fString = s->ReadSafeWString_TEMP();
fString = s->ReadSafeWString();
fImageKey = mgr->ReadKey( s );
s->ReadLE( &fFlags );
@ -301,7 +301,7 @@ void plDynamicTextMsg::ReadVersion(hsStream* s, hsResMgr* mgr)
if (contentFlags.IsBitSet(kDynTextMsgColor))
fColor.Read( s );
if (contentFlags.IsBitSet(kDynTextMsgString))
fString = s->ReadSafeWString_TEMP();
fString = s->ReadSafeWString();
if (contentFlags.IsBitSet(kDynTextMsgImageKey))
fImageKey = mgr->ReadKey( s );
if (contentFlags.IsBitSet(kDynTextMsgFlags))

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

@ -62,9 +62,9 @@ class plInputIfaceMgrMsg : public plMessage
uint8_t fCommand;
plInputInterface *fInterface;
uint32_t fPageID;
const char* ageName;
const char* ageFileName;
const char* spawnPoint;
plString ageName;
plString ageFileName;
plString spawnPoint;
plUUID ageInstanceGuid;
plKey fAvKey;
public:
@ -88,10 +88,10 @@ class plInputIfaceMgrMsg : public plMessage
kSetShareAgeInstanceGuid,
};
plInputIfaceMgrMsg() : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); fInterface = nil; ageName = ageFileName = spawnPoint = 0; 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( uint8_t command ) : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); fCommand = command; 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; ageName = ageFileName = spawnPoint = 0;}
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; }
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; }
~plInputIfaceMgrMsg();
CLASSNAME_REGISTER( plInputIfaceMgrMsg );
@ -119,18 +119,18 @@ class plInputIfaceMgrMsg : public plMessage
mgr->WriteKey(s,fAvKey);
}
void SetAgeName(const char* s) { ageName = s; }
const char* GetAgeName() { return ageName; }
void SetAgeFileName(const char* s) { ageFileName = s; }
const char* GetAgeFileName() { return ageFileName; }
void SetSpawnPoint(const char* s) { spawnPoint = s; }
const char* GetSpawnPoint() { return spawnPoint; }
void SetAgeName(const plString& s) { ageName = s; }
plString GetAgeName() const { return ageName; }
void SetAgeFileName(const plString& s) { ageFileName = s; }
plString GetAgeFileName() const { return ageFileName; }
void SetSpawnPoint(const plString& s) { spawnPoint = s; }
plString GetSpawnPoint() const { return spawnPoint; }
void SetAgeInstanceGuid(const plUUID& guid) { ageInstanceGuid = guid; }
const plUUID& GetAgeInstanceGuid() { return ageInstanceGuid; }
uint8_t GetCommand( void ) { return fCommand; }
uint32_t GetPageID( void ) { return fPageID; }
const plUUID& GetAgeInstanceGuid() const { return ageInstanceGuid; }
uint8_t GetCommand() const { return fCommand; }
uint32_t GetPageID() const { return fPageID; }
void SetIFace( plInputInterface *iface );
plInputInterface *GetIFace( void ) const { return fInterface; }
plInputInterface *GetIFace() const { return fInterface; }
plKey& GetAvKey( void ) { return fAvKey; }
const plKey& GetAvKey( void ) const { return fAvKey; }
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() : 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 );
}
plLinkToAgeMsg::~plLinkToAgeMsg()
{
delete [] fLinkInAnimName;
}
void plLinkToAgeMsg::PlayLinkSfx(bool linkIn, bool linkOut)
{
if (linkIn)

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

@ -66,12 +66,11 @@ class plLinkToAgeMsg : public plMessage
uint8_t fFlags;
plAgeLinkStruct fAgeLink;
char* fLinkInAnimName;
plString fLinkInAnimName;
public:
plLinkToAgeMsg();
plLinkToAgeMsg( const plAgeLinkStruct * link );
virtual ~plLinkToAgeMsg();
CLASSNAME_REGISTER( plLinkToAgeMsg );
GETINTERFACE_ANY( plLinkToAgeMsg, plMessage );
@ -83,8 +82,8 @@ public:
bool PlayLinkInSfx() const { return (fFlags & kMuteLinkInSfx) == 0; }
bool PlayLinkOutSfx() const { return (fFlags & kMuteLinkOutSfx) == 0; }
const char * GetLinkInAnimName() { return fLinkInAnimName; }
void SetLinkInAnimName(const char* name) { delete [] fLinkInAnimName; fLinkInAnimName = hsStrcpy(name); }
plString GetLinkInAnimName() { return fLinkInAnimName; }
void SetLinkInAnimName(const plString& name) { fLinkInAnimName = name; }
void Read(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))
{
// read agename
fAgeFilename = s->ReadSafeString_TEMP();
fAgeFilename = s->ReadSafeString();
}
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));
}
fUserStr = stream->ReadSafeString_TEMP();
fUserStr = stream->ReadSafeString();
}
void plLoadAvatarMsg::Write(hsStream *stream, hsResMgr *mgr)
@ -132,7 +132,7 @@ void plLoadAvatarMsg::ReadVersion(hsStream* stream, hsResMgr* mgr)
fSpawnPoint = mgr->ReadKey(stream);
if (contentFlags.IsBitSet(kLoadAvatarMsgUserStr))
fUserStr = stream->ReadSafeString_TEMP();
fUserStr = stream->ReadSafeString();
}
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);
for (int i = 0; i < size; i++)
{
plString marker = stream->ReadSafeString_TEMP();
plString marker = stream->ReadSafeString();
plKey receiver = mgr->ReadKey(stream);
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)
{
fTemplateName = s->ReadSafeString_TEMP();
fTemplateName = s->ReadSafeString();
plSingleModifier::Read(s, mgr);
}

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

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

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
//
const char* plNetClientMgr::GetNextAgeFilename()
plString plNetClientMgr::GetNextAgeFilename() const
{
// set when we start linking to an age.
plNetLinkingMgr * lm = plNetLinkingMgr::GetInstance();

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

Loading…
Cancel
Save