Browse Source

Merge pull request #146 from zrax/plString

plString (take two)
NadnerbD 13 years ago
parent
commit
053600d952
  1. 24
      Sources/Plasma/Apps/plClient/plClient.cpp
  2. 2
      Sources/Plasma/Apps/plClient/winmain.cpp
  3. 13
      Sources/Plasma/CoreLib/CMakeLists.txt
  4. 26
      Sources/Plasma/CoreLib/hsStream.cpp
  5. 10
      Sources/Plasma/CoreLib/hsStream.h
  6. 8
      Sources/Plasma/CoreLib/plGeneric.h
  7. 705
      Sources/Plasma/CoreLib/plString.cpp
  8. 425
      Sources/Plasma/CoreLib/plString.h
  9. 24
      Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.cpp
  10. 4
      Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.h
  11. 4
      Sources/Plasma/FeatureLib/pfAnimation/plFollowMod.cpp
  12. 4
      Sources/Plasma/FeatureLib/pfAnimation/plLineFollowMod.cpp
  13. 4
      Sources/Plasma/FeatureLib/pfAnimation/plViewFaceModifier.cpp
  14. 18
      Sources/Plasma/FeatureLib/pfAudio/plListener.cpp
  15. 4
      Sources/Plasma/FeatureLib/pfAudio/plRandomSoundMod.cpp
  16. 6
      Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp
  17. 4
      Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp
  18. 2
      Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h
  19. 4
      Sources/Plasma/FeatureLib/pfCharacter/pfMarkerInfo.cpp
  20. 36
      Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp
  21. 14
      Sources/Plasma/FeatureLib/pfConsole/pfConsole.cpp
  22. 246
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp
  23. 18
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp
  24. 2
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleDirSrc.cpp
  25. 8
      Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp
  26. 2
      Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp
  27. 34
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIButtonMod.cpp
  28. 9
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIButtonMod.h
  29. 19
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICheckBoxCtrl.cpp
  30. 7
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICheckBoxCtrl.h
  31. 4
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIControlMod.cpp
  32. 10
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICtrlGenerator.cpp
  33. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICtrlGenerator.h
  34. 2
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIDialogMod.cpp
  35. 19
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIKnobCtrl.cpp
  36. 11
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIKnobCtrl.h
  37. 3
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIListElement.cpp
  38. 3
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIPopUpMenu.cpp
  39. 19
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIProgressCtrl.cpp
  40. 9
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIProgressCtrl.h
  41. 89
      Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp
  42. 18
      Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.h
  43. 8
      Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp
  44. 4
      Sources/Plasma/FeatureLib/pfPython/cyAvatar.h
  45. 6
      Sources/Plasma/FeatureLib/pfPython/cyAvatarGlue.cpp
  46. 67
      Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp
  47. 18
      Sources/Plasma/FeatureLib/pfPython/cyMisc.h
  48. 4
      Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp
  49. 4
      Sources/Plasma/FeatureLib/pfPython/cyMiscGlue3.cpp
  50. 34
      Sources/Plasma/FeatureLib/pfPython/cyMiscGlue4.cpp
  51. 12
      Sources/Plasma/FeatureLib/pfPython/cyPhysics.cpp
  52. 75
      Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp
  53. 16
      Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.h
  54. 37
      Sources/Plasma/FeatureLib/pfPython/plPythonParameter.h
  55. 9
      Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp
  56. 12
      Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.cpp
  57. 9
      Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.h
  58. 14
      Sources/Plasma/FeatureLib/pfPython/pyCritterBrain.cpp
  59. 2
      Sources/Plasma/FeatureLib/pfPython/pyCritterBrain.h
  60. 7
      Sources/Plasma/FeatureLib/pfPython/pyImage.cpp
  61. 21
      Sources/Plasma/FeatureLib/pfPython/pyJournalBook.cpp
  62. 18
      Sources/Plasma/FeatureLib/pfPython/pyJournalBook.h
  63. 14
      Sources/Plasma/FeatureLib/pfPython/pyJournalBookGlue.cpp
  64. 3
      Sources/Plasma/FeatureLib/pfPython/pyKey.h
  65. 12
      Sources/Plasma/FeatureLib/pfPython/pyNetServerSessionInfo.h
  66. 58
      Sources/Plasma/FeatureLib/pfPython/pySceneObject.cpp
  67. 4
      Sources/Plasma/FeatureLib/pfPython/pySceneObject.h
  68. 4
      Sources/Plasma/FeatureLib/pfPython/pySceneObjectGlue.cpp
  69. 20
      Sources/Plasma/FeatureLib/pfPython/pyVault.cpp
  70. 3
      Sources/Plasma/FeatureLib/pfPython/pyVaultImageNode.cpp
  71. 3
      Sources/Plasma/FeatureLib/pfSurface/plLayerMovie.cpp
  72. 4
      Sources/Plasma/NucleusLib/inc/hsResMgr.h
  73. 6
      Sources/Plasma/NucleusLib/pnDispatch/plDispatch.cpp
  74. 13
      Sources/Plasma/NucleusLib/pnKeyedObject/hsKeyedObject.cpp
  75. 4
      Sources/Plasma/NucleusLib/pnKeyedObject/hsKeyedObject.h
  76. 83
      Sources/Plasma/NucleusLib/pnKeyedObject/plFixedKey.cpp
  77. 5
      Sources/Plasma/NucleusLib/pnKeyedObject/plKey.h
  78. 7
      Sources/Plasma/NucleusLib/pnKeyedObject/plKeyImp.cpp
  79. 2
      Sources/Plasma/NucleusLib/pnKeyedObject/plKeyImp.h
  80. 4
      Sources/Plasma/NucleusLib/pnKeyedObject/plMsgForwarder.cpp
  81. 34
      Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.cpp
  82. 23
      Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.h
  83. 12
      Sources/Plasma/NucleusLib/pnMessage/plEventCallbackMsg.h
  84. 42
      Sources/Plasma/NucleusLib/pnMessage/plMessage.cpp
  85. 14
      Sources/Plasma/NucleusLib/pnMessage/plMessage.h
  86. 32
      Sources/Plasma/NucleusLib/pnModifier/plLogicModBase.cpp
  87. 2
      Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.h
  88. 30
      Sources/Plasma/NucleusLib/pnNetCommon/plNetServers.h
  89. 2
      Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.cpp
  90. 13
      Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp
  91. 10
      Sources/Plasma/NucleusLib/pnUUID/pnUUID.h
  92. 4
      Sources/Plasma/NucleusLib/pnUUID/pnUUID_Unix.cpp
  93. 6
      Sources/Plasma/NucleusLib/pnUUID/pnUUID_Win32.cpp
  94. 2
      Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.h
  95. 18
      Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoaderPaging.cpp
  96. 9
      Sources/Plasma/PubUtilLib/plAudible/plWinAudible.cpp
  97. 10
      Sources/Plasma/PubUtilLib/plAudio/plAudioSystem.cpp
  98. 12
      Sources/Plasma/PubUtilLib/plAudio/plSound.cpp
  99. 3
      Sources/Plasma/PubUtilLib/plAudio/plVoiceChat.cpp
  100. 16
      Sources/Plasma/PubUtilLib/plAudio/plWin32GroupedSound.cpp
  101. Some files were not shown because too many files have changed in this diff Show More

24
Sources/Plasma/Apps/plClient/plClient.cpp

@ -630,7 +630,7 @@ hsBool plClient::MsgReceive(plMessage* msg)
{ {
case plClientRefMsg::kLoadRoom : case plClientRefMsg::kLoadRoom :
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
plStatusLog::AddLineS( "pageouts.log", ".. ClientRefMsg received for room %s", pRefMsg->GetRef() != nil ? pRefMsg->GetRef()->GetKey()->GetUoid().GetObjectName() : "nilref" ); plStatusLog::AddLineS( "pageouts.log", ".. ClientRefMsg received for room %s", pRefMsg->GetRef() != nil ? pRefMsg->GetRef()->GetKey()->GetUoid().GetObjectName().c_str() : "nilref" );
#endif #endif
// was it that the room was loaded? // was it that the room was loaded?
@ -780,11 +780,10 @@ hsBool plClient::MsgReceive(plMessage* msg)
plEventCallbackMsg* callback = plEventCallbackMsg::ConvertNoRef(msg); plEventCallbackMsg* callback = plEventCallbackMsg::ConvertNoRef(msg);
if( callback ) if( callback )
{ {
char str[256]; plString str = plString::Format("Callback event from %s\n", callback->GetSender()
sprintf(str, "Callback event from %s\n", callback->GetSender() ? callback->GetSender()->GetName().c_str()
? callback->GetSender()->GetName() : "Unknown");
: "Unknown"); hsStatusMessage(str.c_str());
hsStatusMessage(str);
static int gotten = 0; static int gotten = 0;
if( ++gotten > 5 ) if( ++gotten > 5 )
{ {
@ -1095,14 +1094,16 @@ void plClient::IUnloadRooms(const std::vector<plLocation>& locs)
if (node) if (node)
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
plStatusLog::AddLineS("pageouts.log", "SceneNode for %s loaded; Removing node", node->GetKey()->GetUoid().GetObjectName()); plStatusLog::AddLineS("pageouts.log", "SceneNode for %s loaded; Removing node",
node->GetKey()->GetUoid().GetObjectName().c_str());
#endif #endif
fPageMgr->RemoveNode(node); fPageMgr->RemoveNode(node);
} }
else else
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
plStatusLog::AddLineS("pageouts.log", "SceneNode for %s NOT loaded", nodeKey->GetUoid().GetObjectName()); plStatusLog::AddLineS("pageouts.log", "SceneNode for %s NOT loaded",
nodeKey->GetUoid().GetObjectName().c_str());
#endif #endif
} }
GetKey()->Release(nodeKey); // release notify interest in scene node GetKey()->Release(nodeKey); // release notify interest in scene node
@ -1118,7 +1119,8 @@ void plClient::IUnloadRooms(const std::vector<plLocation>& locs)
fCurrentNode = nil; fCurrentNode = nil;
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
plStatusLog::AddLineS("pageouts.log", "Telling netClientMgr about paging out %s", nodeKey->GetUoid().GetObjectName()); plStatusLog::AddLineS("pageouts.log", "Telling netClientMgr about paging out %s",
nodeKey->GetUoid().GetObjectName().c_str());
#endif #endif
if (plNetClientMgr::GetInstance() != nil) if (plNetClientMgr::GetInstance() != nil)
@ -1242,7 +1244,7 @@ void plClient::IRoomLoaded(plSceneNode* node, bool hold)
plgDispatch::MsgSend(loadmsg); plgDispatch::MsgSend(loadmsg);
} }
else else
hsStatusMessageF("Done loading hold room %s, t=%f\n", pRmKey->GetName(), hsTimer::GetSeconds()); hsStatusMessageF("Done loading hold room %s, t=%f\n", pRmKey->GetName().c_str(), hsTimer::GetSeconds());
plLocation loc = pRmKey->GetUoid().GetLocation(); plLocation loc = pRmKey->GetUoid().GetLocation();
for (int i = 0; i < fRoomsLoading.size(); i++) for (int i = 0; i < fRoomsLoading.size(); i++)
@ -1280,7 +1282,7 @@ void plClient::IRoomUnloaded(plSceneNode* node)
void plClient::IReadKeyedObjCallback(plKey key) void plClient::IReadKeyedObjCallback(plKey key)
{ {
fInstance->IIncProgress(1, key->GetName()); fInstance->IIncProgress(1, _TEMP_CONVERT_TO_CONST_CHAR(key->GetName()));
} }
//============================================================================ //============================================================================

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

@ -1129,8 +1129,8 @@ void StatusCallback(void *param)
} }
} }
delete [] statusUrl;
curl_easy_cleanup(hCurl); curl_easy_cleanup(hCurl);
delete [] statusUrl;
s_statusEvent.Signal(); s_statusEvent.Signal();
} }

13
Sources/Plasma/CoreLib/CMakeLists.txt

@ -1,5 +1,16 @@
add_definitions(-D_LIB) add_definitions(-D_LIB)
if(NOT WCHAR_BYTES)
include(CheckTypeSize)
check_type_size("wchar_t" WCHAR_BYTES)
if(NOT WCHAR_BYTES)
message(FATAL_ERROR "Could not determine sizeof(wchar_t)")
set(WCHAR_BYTES 0)
endif(NOT WCHAR_BYTES)
endif(NOT WCHAR_BYTES)
add_definitions(-DWCHAR_BYTES=${WCHAR_BYTES})
set(CoreLib_SOURCES set(CoreLib_SOURCES
HeadSpin.cpp HeadSpin.cpp
hsBitVector.cpp hsBitVector.cpp
@ -24,6 +35,7 @@ set(CoreLib_SOURCES
pcSmallRect.cpp pcSmallRect.cpp
plGeneric.cpp plGeneric.cpp
plLoadMask.cpp plLoadMask.cpp
plString.cpp
plViewTransform.cpp plViewTransform.cpp
) )
@ -72,6 +84,7 @@ set(CoreLib_HEADERS
plLoadMask.h plLoadMask.h
plQuality.h plQuality.h
plRefCnt.h plRefCnt.h
plString.h
plTweak.h plTweak.h
plViewTransform.h plViewTransform.h
) )

26
Sources/Plasma/CoreLib/hsStream.cpp

@ -322,6 +322,32 @@ wchar_t *hsStream::ReadSafeWString()
return retVal; return retVal;
} }
uint32_t hsStream::WriteSafeString(const plString &string)
{
return WriteSafeString(_TEMP_CONVERT_TO_CONST_CHAR(string));
}
uint32_t hsStream::WriteSafeWString(const plString &string)
{
return WriteSafeWString(_TEMP_CONVERT_TO_WCHAR_T(string));
}
plString hsStream::ReadSafeString_TEMP()
{
char *buffer = ReadSafeString();
plString result = plString::FromIso8859_1(buffer);
delete [] buffer;
return result;
}
plString hsStream::ReadSafeWString_TEMP()
{
wchar_t *wbuffer = ReadSafeWString();
plString result = plString::FromWchar(wbuffer);
delete [] wbuffer;
return result;
}
hsBool hsStream::Read4Bytes(void *pv) // Virtual, faster version in sub classes hsBool hsStream::Read4Bytes(void *pv) // Virtual, faster version in sub classes
{ {
int knt = this->Read(sizeof(uint32_t), pv); int knt = this->Read(sizeof(uint32_t), pv);

10
Sources/Plasma/CoreLib/hsStream.h

@ -46,6 +46,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsMemory.h" #include "hsMemory.h"
#include "plString.h"
namespace hsPackFileSys { namespace hsPackFileSys {
struct FileEntry; struct FileEntry;
@ -58,7 +59,8 @@ struct FileEntry;
#ifndef STREAM_LOGGER #ifndef STREAM_LOGGER
#define hsReadOnlyLoggingStream hsReadOnlyStream #define hsReadOnlyLoggingStream hsReadOnlyStream
#define LogRead(byteCount, buffer, desc) Read(byteCount, buffer) #define LogRead(byteCount, buffer, desc) Read(byteCount, buffer)
#define LogReadSafeString() ReadSafeString(); #define LogReadSafeString() ReadSafeString()
#define LogReadSafeString_TEMP() ReadSafeString_TEMP()
#define LogReadSafeStringLong() ReadSafeStringLong(); #define LogReadSafeStringLong() ReadSafeStringLong();
#define LogSkip(deltaByteCount, desc) Skip(deltaByteCount) #define LogSkip(deltaByteCount, desc) Skip(deltaByteCount)
#define LogReadLE(value, desc) ReadLE(value) #define LogReadLE(value, desc) ReadLE(value)
@ -129,6 +131,7 @@ public:
virtual hsBool IsCompressed() { return false; } virtual hsBool IsCompressed() { return false; }
uint32_t WriteString(const char cstring[]); uint32_t WriteString(const char cstring[]);
uint32_t WriteString_TEMP(const plString & string) { return WriteString(string.c_str()); }
uint32_t WriteFmt(const char * fmt, ...); uint32_t WriteFmt(const char * fmt, ...);
uint32_t WriteFmtV(const char * fmt, va_list av); uint32_t WriteFmtV(const char * fmt, va_list av);
@ -142,6 +145,11 @@ public:
char * ReadSafeString(); char * ReadSafeString();
wchar_t * ReadSafeWString(); wchar_t * ReadSafeWString();
uint32_t WriteSafeString(const plString &string); // uses 2 bytes for length
uint32_t WriteSafeWString(const plString &string);
plString ReadSafeString_TEMP();
plString ReadSafeWString_TEMP();
hsBool GetToken(char *s, uint32_t maxLen=uint32_t(-1), const char beginComment=kComment, const char endComment=kEolnCode); hsBool GetToken(char *s, uint32_t maxLen=uint32_t(-1), const char beginComment=kComment, const char endComment=kEolnCode);
hsBool ReadLn(char* s, uint32_t maxLen=uint32_t(-1), const char beginComment=kComment, const char endComment=kEolnCode); hsBool ReadLn(char* s, uint32_t maxLen=uint32_t(-1), const char beginComment=kComment, const char endComment=kEolnCode);

8
Sources/Plasma/CoreLib/plGeneric.h

@ -88,11 +88,11 @@ public:
// the cast functions will NOT cast from one type to another, use // the cast functions will NOT cast from one type to another, use
// GetType() to determine the type of parameter, then cast it to that type // GetType() to determine the type of parameter, then cast it to that type
GenericType GetType() const {return fType;} GenericType GetType() const {return fType;}
operator const bool() const {return fBoolVal;} operator bool() const {return fBoolVal;}
operator const int() const {return fIntVal;} operator int() const {return fIntVal;}
operator const double() const {return fFloatVal;} operator double() const {return fFloatVal;}
operator const wchar_t*() const {return fStringVal.c_str();} operator const wchar_t*() const {return fStringVal.c_str();}
operator const std::wstring() const {return fStringVal;} operator std::wstring() const {return fStringVal;}
int Write(hsStream* stream); int Write(hsStream* stream);
int Read(hsStream* stream); int Read(hsStream* stream);

705
Sources/Plasma/CoreLib/plString.cpp

@ -0,0 +1,705 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "plString.h"
#include <cstring>
#include <cstdlib>
#include <wchar.h>
const plString plString::Null;
#if !defined(WCHAR_BYTES) || (WCHAR_BYTES != 2) && (WCHAR_BYTES != 4)
#error "WCHAR_BYTES must be either 2 (16-bit) or 4 (32-bit)!"
#endif
#if WCHAR_BYTES == 2
#define u16slen(str, max) wcsnlen((const wchar_t *)(str), (max))
#else
static inline size_t u16slen(const uint16_t *ustr, size_t max)
{
size_t length = 0;
for ( ; *ustr++ && max--; ++length)
;
return length;
}
#endif
#define BADCHAR_REPLACEMENT (0xFFFDul)
void plString::IConvertFromUtf8(const char *utf8, size_t size, bool steal)
{
if (utf8 == nil) {
fUtf8Buffer = plStringBuffer<char>();
return;
}
if ((long)size < 0)
size = strnlen(utf8, -(long)size);
#ifdef _DEBUG
// Check to make sure the string is actually valid UTF-8
const char *sp = utf8;
while (sp < utf8 + size) {
unsigned char unichar = *sp++;
if ((unichar & 0xF8) == 0xF0) {
// Four bytes
hsAssert((*sp++) & 0x80, "Invalid UTF-8 sequence byte (1)");
hsAssert((*sp++) & 0x80, "Invalid UTF-8 sequence byte (2)");
hsAssert((*sp++) & 0x80, "Invalid UTF-8 sequence byte (3)");
} else if ((unichar & 0xF0) == 0xE0) {
// Three bytes
hsAssert((*sp++) & 0x80, "Invalid UTF-8 sequence byte (1)");
hsAssert((*sp++) & 0x80, "Invalid UTF-8 sequence byte (2)");
} else if ((unichar & 0xE0) == 0xC0) {
// Two bytes
hsAssert((*sp++) & 0x80, "Invalid UTF-8 sequence byte (1)");
} else if ((unichar & 0xC0) == 0x80) {
hsAssert(0, "Invalid UTF-8 marker byte");
} else if ((unichar & 0x80) != 0) {
hsAssert(0, "UTF-8 character out of range");
}
}
#endif
fUtf8Buffer = steal ? plStringBuffer<char>::Steal(utf8, size)
: plStringBuffer<char>(utf8, size);
}
void plString::IConvertFromUtf16(const uint16_t *utf16, size_t size)
{
if (utf16 == nil) {
fUtf8Buffer = plStringBuffer<char>();
return;
}
if ((long)size < 0)
size = u16slen(utf16, -(long)size);
// Calculate the UTF-8 size
size_t convlen = 0;
const uint16_t *sp = utf16;
while (sp < utf16 + size) {
if (*sp >= 0xD800 && *sp <= 0xDFFF) {
// Surrogate pair
convlen += 4;
++sp;
}
else if (*sp > 0x7FF)
convlen += 3;
else if (*sp > 0x7F)
convlen += 2;
else
convlen += 1;
++sp;
}
// And perform the actual conversion
char *utf8 = new char[convlen + 1];
char *dp = utf8;
sp = utf16;
while (sp < utf16 + size) {
if (*sp >= 0xD800 && *sp <= 0xDFFF) {
// Surrogate pair
unsigned int unichar = 0x10000;
if (sp + 1 >= utf16 + size) {
hsAssert(0, "Incomplete surrogate pair in UTF-16 data");
unichar = BADCHAR_REPLACEMENT;
} else if (*sp < 0xDC00) {
unichar += (*sp++ & 0x3FF) << 10;
hsAssert(*sp >= 0xDC00 && *sp <= 0xDFFF,
"Invalid surrogate pair in UTF-16 data");
unichar += (*sp & 0x3FF);
} else {
unichar += (*sp++ & 0x3FF);
hsAssert(*sp >= 0xD800 && *sp < 0xDC00,
"Invalid surrogate pair in UTF-16 data");
unichar += (*sp & 0x3FF) << 10;
}
*dp++ = 0xF0 | ((unichar >> 18) & 0x07);
*dp++ = 0x80 | ((unichar >> 12) & 0x3F);
*dp++ = 0x80 | ((unichar >> 6) & 0x3F);
*dp++ = 0x80 | ((unichar ) & 0x3F);
} else if (*sp > 0x7FF) {
*dp++ = 0xF0 | ((*sp >> 12) & 0x0F);
*dp++ = 0x80 | ((*sp >> 6) & 0x3F);
*dp++ = 0x80 | ((*sp ) & 0x3F);
} else if (*sp > 0x7F) {
*dp++ = 0xF0 | ((*sp >> 6) & 0x1F);
*dp++ = 0x80 | ((*sp ) & 0x3F);
} else {
*dp++ = (char)(*sp);
}
++sp;
}
utf8[convlen] = 0;
fUtf8Buffer = plStringBuffer<char>::Steal(utf8, convlen);
}
void plString::IConvertFromWchar(const wchar_t *wstr, size_t size)
{
#if WCHAR_BYTES == 2
// We assume that if sizeof(wchar_t) == 2, the data is UTF-16 already
IConvertFromUtf16((const uint16_t *)wstr, size);
#else
if (wstr == nil) {
fUtf8Buffer = plStringBuffer<char>();
return;
}
if ((long)size < 0)
size = wcsnlen(wstr, -(long)size);
// Calculate the UTF-8 size
size_t convlen = 0;
const wchar_t *sp = wstr;
while (sp < wstr + size) {
if (*sp > 0x10FFFF) {
hsAssert(0, "UCS-4 character out of range");
convlen += 3; // Use U+FFFD for release builds
}
else if (*sp > 0xFFFF)
convlen += 4;
else if (*sp > 0x7FF)
convlen += 3;
else if (*sp > 0x7F)
convlen += 2;
else
convlen += 1;
++sp;
}
// And perform the actual conversion
char *utf8 = new char[convlen + 1];
char *dp = utf8;
sp = wstr;
while (sp < wstr + size) {
if (*sp > 0x10FFFF) {
// Character out of range; Use U+FFFD instead
*dp++ = 0xE0 | ((BADCHAR_REPLACEMENT >> 12) & 0x0F);
*dp++ = 0x80 | ((BADCHAR_REPLACEMENT >> 6) & 0x3F);
*dp++ = 0x80 | ((BADCHAR_REPLACEMENT ) & 0x3F);
} else if (*sp > 0xFFFF) {
*dp++ = 0xF0 | ((*sp >> 18) & 0x07);
*dp++ = 0x80 | ((*sp >> 12) & 0x3F);
*dp++ = 0x80 | ((*sp >> 6) & 0x3F);
*dp++ = 0x80 | ((*sp ) & 0x3F);
} else if (*sp > 0x7FF) {
*dp++ = 0xF0 | ((*sp >> 12) & 0x0F);
*dp++ = 0x80 | ((*sp >> 6) & 0x3F);
*dp++ = 0x80 | ((*sp ) & 0x3F);
} else if (*sp > 0x7F) {
*dp++ = 0xF0 | ((*sp >> 6) & 0x1F);
*dp++ = 0x80 | ((*sp ) & 0x3F);
} else {
*dp++ = (char)(*sp);
}
++sp;
}
utf8[convlen] = 0;
fUtf8Buffer = plStringBuffer<char>::Steal(utf8, convlen);
#endif
}
void plString::IConvertFromIso8859_1(const char *astr, size_t size)
{
if (astr == nil) {
fUtf8Buffer = plStringBuffer<char>();
return;
}
if ((long)size < 0)
size = strnlen(astr, -(long)size);
// Calculate the UTF-8 size
size_t convlen = 0;
const char *sp = astr;
while (sp < astr + size) {
if ((*sp++) & 0x80)
convlen += 2;
else
convlen += 1;
}
// And perform the actual conversion
char *utf8 = new char[convlen + 1];
char *dp = utf8;
sp = astr;
while (sp < astr + size) {
if (*astr & 0x80) {
*dp++ = 0xC0 | ((*sp >> 6) & 0x1F);
*dp++ = 0x80 | ((*sp ) & 0x3F);
} else {
*dp++ = *sp;
}
++sp;
}
utf8[convlen] = 0;
fUtf8Buffer = plStringBuffer<char>::Steal(utf8, convlen);
}
plStringBuffer<uint16_t> plString::ToUtf16() const
{
if (IsNull())
return plStringBuffer<uint16_t>();
// Calculate the UTF-16 size
size_t convlen = 0;
const char *utf8 = fUtf8Buffer.GetData();
const char *sp = utf8;
size_t srcSize = fUtf8Buffer.GetSize();
while (sp < utf8 + srcSize) {
if ((*sp & 0xF8) == 0xF0) {
// Will require a surrogate pair
++convlen;
sp += 4;
}
else if ((*sp & 0xF0) == 0xE0)
sp += 3;
else if ((*sp & 0xE0) == 0xC0)
sp += 2;
else
sp += 1;
++convlen;
}
// And perform the actual conversion
uint16_t *ustr = new uint16_t[convlen + 1];
uint16_t *dp = ustr;
sp = utf8;
while (sp < utf8 + srcSize) {
unsigned int unichar;
if ((*sp & 0xF8) == 0xF0) {
unichar = (*sp++ & 0x07) << 18;
unichar |= (*sp++ & 0x3F) << 12;
unichar |= (*sp++ & 0x3F) << 6;
unichar |= (*sp++ & 0x3F);
*dp++ = 0xD800 | ((unichar >> 10) & 0x3FF);
*dp++ = 0xDC00 | ((unichar ) & 0x3FF);
} else if ((*sp & 0xF0) == 0xE0) {
unichar = (*sp++ & 0x0F) << 12;
unichar |= (*sp++ & 0x3F) << 6;
unichar |= (*sp++ & 0x3F);
*dp++ = unichar;
} else if ((*sp & 0xE0) == 0xC0) {
unichar = (*sp++ & 0x1F) << 6;
unichar |= (*sp++ & 0x3F);
*dp++ = unichar;
} else {
*dp++ = *sp++;
}
}
ustr[convlen] = 0;
return plStringBuffer<uint16_t>::Steal(ustr, convlen);
}
plStringBuffer<wchar_t> plString::ToWchar() const
{
#if WCHAR_BYTES == 2
// We assume that if sizeof(wchar_t) == 2, the data is UTF-16 already
plStringBuffer<uint16_t> utf16 = ToUtf16();
return *reinterpret_cast<plStringBuffer<wchar_t>*>(&utf16);
#else
if (IsNull())
return plStringBuffer<wchar_t>();
// Calculate the UCS-4 size
size_t convlen = 0;
const char *utf8 = fUtf8Buffer.GetData();
const char *sp = utf8;
size_t srcSize = fUtf8Buffer.GetSize();
while (sp < utf8 + srcSize) {
if ((*sp & 0xF8) == 0xF0)
sp += 4;
else if ((*sp & 0xF0) == 0xE0)
sp += 3;
else if ((*sp & 0xE0) == 0xC0)
sp += 2;
else
sp += 1;
++convlen;
}
// And perform the actual conversion
wchar_t *wstr = new wchar_t[convlen + 1];
wchar_t *dp = wstr;
sp = utf8;
while (sp < utf8 + srcSize) {
unsigned int unichar;
if ((*sp & 0xF8) == 0xF0) {
unichar = (*sp++ & 0x07) << 18;
unichar |= (*sp++ & 0x3F) << 12;
unichar |= (*sp++ & 0x3F) << 6;
unichar |= (*sp++ & 0x3F);
} else if ((*sp & 0xF0) == 0xE0) {
unichar = (*sp++ & 0x0F) << 12;
unichar |= (*sp++ & 0x3F) << 6;
unichar |= (*sp++ & 0x3F);
} else if ((*sp & 0xE0) == 0xC0) {
unichar = (*sp++ & 0x1F) << 6;
unichar |= (*sp++ & 0x3F);
} else {
unichar = *sp++;
}
*dp++ = unichar;
}
wstr[convlen] = 0;
return plStringBuffer<wchar_t>::Steal(wstr, convlen);
#endif
}
plStringBuffer<char> plString::ToIso8859_1() const
{
if (IsNull())
return plStringBuffer<char>();
// Calculate the ASCII size
size_t convlen = 0;
const char *utf8 = fUtf8Buffer.GetData();
const char *sp = utf8;
size_t srcSize = fUtf8Buffer.GetSize();
while (sp < utf8 + srcSize) {
if ((*sp & 0xF8) == 0xF0)
sp += 4;
else if ((*sp & 0xF0) == 0xE0)
sp += 3;
else if ((*sp & 0xE0) == 0xC0)
sp += 2;
else
sp += 1;
++convlen;
}
// And perform the actual conversion
char *astr = new char[convlen + 1];
char *dp = astr;
sp = utf8;
while (sp < utf8 + srcSize) {
unsigned int unichar;
if ((*sp & 0xF8) == 0xF0) {
unichar = (*sp++ & 0x07) << 18;
unichar |= (*sp++ & 0x3F) << 12;
unichar |= (*sp++ & 0x3F) << 6;
unichar |= (*sp++ & 0x3F);
} else if ((*sp & 0xF0) == 0xE0) {
unichar = (*sp++ & 0x0F) << 12;
unichar |= (*sp++ & 0x3F) << 6;
unichar |= (*sp++ & 0x3F);
} else if ((*sp & 0xE0) == 0xC0) {
unichar = (*sp++ & 0x1F) << 6;
unichar |= (*sp++ & 0x3F);
} else {
unichar = *sp++;
}
*dp++ = (unichar < 0xFF) ? unichar : '?';
}
astr[convlen] = 0;
return plStringBuffer<char>::Steal(astr, convlen);
}
plStringBuffer<UniChar> plString::GetUnicodeArray() const
{
static UniChar empty[1] = {0};
if (IsNull())
return plStringBuffer<UniChar>(empty, 0);
size_t convlen = GetUniCharCount();
UniChar *ustr = new UniChar[convlen + 1];
iterator iter = GetIterator();
size_t dp = 0;
while (!iter.AtEnd())
ustr[dp++] = *iter++;
ustr[convlen] = 0;
return plStringBuffer<UniChar>::Steal(ustr, convlen);
}
int plString::ToInt(int base) const
{
return static_cast<int>(strtol(s_str(), nil, base));
}
unsigned int plString::ToUInt(int base) const
{
return static_cast<unsigned int>(strtoul(s_str(), nil, base));
}
float plString::ToFloat() const
{
// strtof is C99, which MS doesn't support...
return (float)strtod(s_str(), nil);
}
double plString::ToDouble() const
{
return strtod(s_str(), nil);
}
// Microsoft doesn't provide this for us
#ifdef _MSC_VER
#define va_copy(dest, src) (dest) = (src)
#endif
plString plString::IFormat(const char *fmt, va_list vptr)
{
char buffer[256];
va_list vptr_save;
va_copy(vptr_save, vptr);
int chars = vsnprintf(buffer, 256, fmt, vptr);
if (chars < 0) {
// We will need to try this multiple times until we get a
// large enough buffer :(
int size = 4096;
for ( ;; ) {
va_copy(vptr, vptr_save);
char *bigbuffer = new char[size];
chars = vsnprintf(bigbuffer, size, fmt, vptr);
if (chars >= 0)
return plString::Steal(bigbuffer);
delete [] bigbuffer;
size *= 2;
}
} else if (chars >= 256) {
va_copy(vptr, vptr_save);
char *bigbuffer = new char[chars+1];
vsnprintf(bigbuffer, chars+1, fmt, vptr);
return plString::Steal(bigbuffer);
}
return plString::FromUtf8(buffer);
}
plString plString::Format(const char *fmt, ...)
{
va_list vptr;
va_start(vptr, fmt);
plString str = IFormat(fmt, vptr);
va_end(vptr);
return str;
}
int plString::Find(char ch, CaseSensitivity sense) const
{
if (sense == kCaseSensitive) {
const char *cp = strchr(s_str(), ch);
return cp ? (cp - c_str()) : -1;
} else {
// No need to check for null, since s_str() will return { 0 } if it is null
const char *cp = s_str();
while (*cp) {
if (tolower(*cp) == tolower(ch))
return cp - c_str();
}
return -1;
}
}
int plString::FindLast(char ch, CaseSensitivity sense) const
{
if (IsEmpty())
return -1;
if (sense == kCaseSensitive) {
const char *cp = strrchr(s_str(), ch);
return cp ? (cp - c_str()) : -1;
} else {
const char *cp = c_str();
cp += strlen(cp);
while (--cp >= c_str()) {
if (tolower(*cp) == tolower(ch))
return cp - c_str();
}
return -1;
}
}
int plString::Find(const char *str, CaseSensitivity sense) const
{
if (!str || !str[0])
return -1;
if (sense == kCaseSensitive) {
const char *cp = strstr(s_str(), str);
return cp ? (cp - c_str()) : -1;
} else {
// The easy way
size_t len = strlen(str);
const char *cp = c_str();
while (*cp) {
if (strnicmp(cp, str, len) == 0)
return cp - c_str();
++cp;
}
return -1;
}
}
static bool in_set(char key, const char *charset)
{
for (const char *cs = charset; *cs; ++cs) {
if (*cs == key)
return true;
}
return false;
}
plString plString::TrimLeft(const char *charset) const
{
if (IsEmpty())
return Null;
const char *cp = c_str();
while (*cp && in_set(*cp, charset))
++cp;
return Substr(cp - c_str());
}
plString plString::TrimRight(const char *charset) const
{
if (IsEmpty())
return Null;
const char *cp = c_str();
cp += strlen(cp);
while (--cp >= c_str() && in_set(*cp, charset))
;
return Substr(0, cp - c_str() + 1);
}
plString plString::Trim(const char *charset) const
{
if (IsEmpty())
return Null;
const char *lp = c_str();
const char *rp = lp + strlen(lp);
while (*lp && in_set(*lp, charset))
++lp;
while (--rp >= lp && in_set(*rp, charset))
;
return Substr(lp - c_str(), rp - lp + 1);
}
plString plString::Substr(int start, size_t size) const
{
size_t maxSize = GetSize();
if (start > maxSize)
return Null;
if (start < 0)
start = 0;
if (start + size > maxSize)
size = maxSize - start;
if (start == 0 && size == maxSize)
return *this;
char *substr = new char[size + 1];
memcpy(substr, c_str() + start, size);
substr[size] = 0;
// Don't re-check UTF-8 on this
plString str;
str.fUtf8Buffer = plStringBuffer<char>::Steal(substr, size);
return str;
}
plString &plString::operator+=(const plString &str)
{
size_t catsize = GetSize() + str.GetSize();
char *catstr = new char[catsize + 1];
memcpy(catstr, s_str(), GetSize());
memcpy(catstr + GetSize(), str.s_str(), str.GetSize());
catstr[catsize] = 0;
fUtf8Buffer = plStringBuffer<char>::Steal(catstr, catsize);
return *this;
}
plString operator+(const plString &left, const plString &right)
{
size_t catsize = left.GetSize() + right.GetSize();
char *catstr = new char[catsize + 1];
memcpy(catstr, left.s_str(), left.GetSize());
memcpy(catstr + left.GetSize(), right.s_str(), right.GetSize());
catstr[catsize] = 0;
// Don't re-check UTF-8 on this
plString str;
str.fUtf8Buffer = plStringBuffer<char>::Steal(catstr, catsize);
return str;
}
plStringStream &plStringStream::operator<<(const char *text)
{
size_t length = strlen(text);
if (fLength + length > fBufSize) {
char *bigger = new char[fBufSize * 2];
memcpy(bigger, fBuffer, fBufSize);
delete [] fBuffer;
fBuffer = bigger;
fBufSize *= 2;
}
memcpy(fBuffer + fLength, text, length);
fLength += length;
return *this;
}
plStringStream &plStringStream::operator<<(int num)
{
char buffer[12];
snprintf(buffer, 12, "%d", num);
return operator<<(buffer);
}
plStringStream &plStringStream::operator<<(unsigned int num)
{
char buffer[12];
snprintf(buffer, 12, "%u", num);
return operator<<(buffer);
}
plStringStream &plStringStream::operator<<(char ch)
{
char buffer[2] = { ch, 0 };
return operator<<(buffer);
}

425
Sources/Plasma/CoreLib/plString.h

@ -0,0 +1,425 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plString_Defined
#define plString_Defined
#include "HeadSpin.h"
#include <stddef.h>
#include <vector>
#include <functional>
/* NOTE & TODO:
* These macros are intentionally annoyingly named, to mark what code
* needs to be cleaned up after a larger portion of Plasma is converted
* to plString.
*/
#define _TEMP_CONVERT_FROM_LITERAL(x) plString::FromUtf8((x))
#define _TEMP_CONVERT_FROM_WCHAR_T(x) plString::FromWchar((x))
#define _TEMP_CONVERT_TO_CONST_CHAR(x) ((x).c_str())
#define _TEMP_CONVERT_TO_WCHAR_T(x) ((x).ToWchar().GetData())
typedef unsigned int UniChar;
template <typename _Ch>
class plStringBuffer
{
private:
struct StringRef
{
unsigned int fRefs;
const _Ch *fStringData;
const size_t fSize;
StringRef(const _Ch *data, const size_t size)
: fRefs(1), fStringData(data), fSize(size) { }
inline void AddRef() { ++fRefs; }
inline void DecRef()
{
if (--fRefs == 0) {
delete [] fStringData;
delete this;
}
}
};
StringRef *fData;
public:
plStringBuffer() : fData(nil) { }
plStringBuffer(const plStringBuffer<_Ch> &copy)
{
fData = copy.fData;
if (fData)
fData->AddRef();
}
plStringBuffer(const _Ch *data, size_t size)
{
_Ch *copyData = new _Ch[size + 1];
memcpy(copyData, data, size);
copyData[size] = 0;
fData = new StringRef(copyData, size);
}
~plStringBuffer<_Ch>()
{
if (fData)
fData->DecRef();
}
static plStringBuffer<_Ch> Steal(const _Ch *data, size_t size)
{
plStringBuffer<_Ch> string;
string.fData = new StringRef(data, size);
return string;
}
plStringBuffer<_Ch> &operator=(const plStringBuffer<_Ch> &copy)
{
if (copy.fData)
copy.fData->AddRef();
if (fData)
fData->DecRef();
fData = copy.fData;
return *this;
}
const _Ch *GetData() const { return fData ? fData->fStringData : 0; }
size_t GetSize() const { return fData ? fData->fSize : 0; }
};
class plString
{
#pragma warning(push)
#pragma warning(disable : 4146)
enum {
kSizeAuto = (size_t)(-2147483648L)
};
#pragma warning(pop)
public:
static const plString Null;
private:
plStringBuffer<char> fUtf8Buffer;
void IConvertFromUtf8(const char *utf8, size_t size, bool steal);
void IConvertFromUtf16(const uint16_t *utf16, size_t size);
void IConvertFromWchar(const wchar_t *wstr, size_t size);
void IConvertFromIso8859_1(const char *astr, size_t size);
public:
plString() { }
//plString(const char *utf8) { IConvertFromUtf8(utf8, kSizeAuto, false); }
//plString(const wchar_t *wstr) { IConvertFromWchar(wstr, kSizeAuto); }
plString(const plString &copy) : fUtf8Buffer(copy.fUtf8Buffer) { }
//plString &operator=(const char *utf8) { IConvertFromUtf8(utf8, kSizeAuto, false); return *this; }
//plString &operator=(const wchar_t *wstr) { IConvertFromWchar(wstr, kSizeAuto); return *this; }
plString &operator=(const plString &copy) { fUtf8Buffer = copy.fUtf8Buffer; return *this; }
plString &operator+=(const plString &str);
static inline plString FromUtf8(const char *utf8, size_t size = kSizeAuto)
{
plString str;
str.IConvertFromUtf8(utf8, size, false);
return str;
}
static inline plString FromUtf16(const uint16_t *utf16, size_t size = kSizeAuto)
{
plString str;
str.IConvertFromUtf16(utf16, size);
return str;
}
static inline plString FromWchar(const wchar_t *wstr, size_t size = kSizeAuto)
{
plString str;
str.IConvertFromWchar(wstr, size);
return str;
}
static inline plString FromIso8859_1(const char *astr, size_t size = kSizeAuto)
{
plString str;
str.IConvertFromIso8859_1(astr, size);
return str;
}
const char *c_str() const { return fUtf8Buffer.GetData(); }
const char *s_str(const char *safe = "") const { return c_str() ? c_str() : safe; }
char CharAt(size_t position) const { return c_str()[position]; }
plStringBuffer<char> ToUtf8() const { return fUtf8Buffer; }
plStringBuffer<uint16_t> ToUtf16() const;
plStringBuffer<wchar_t> ToWchar() const;
plStringBuffer<char> ToIso8859_1() const;
// For use in displaying characters in a GUI
plStringBuffer<UniChar> GetUnicodeArray() const;
size_t GetSize() const { return fUtf8Buffer.GetSize(); }
bool IsEmpty() const { return fUtf8Buffer.GetSize() == 0; }
bool IsNull() const { return fUtf8Buffer.GetData() == 0; }
int ToInt(int base = 0) const;
unsigned int ToUInt(int base = 0) const;
float ToFloat() const;
double ToDouble() const;
static plString Format(const char *fmt, ...);
static plString IFormat(const char *fmt, va_list vptr);
static plString Steal(const char *utf8, size_t size = kSizeAuto)
{
plString str;
str.IConvertFromUtf8(utf8, size, true);
return str;
}
enum CaseSensitivity {
kCaseSensitive, kCaseInsensitive
};
int Compare(const plString &str, CaseSensitivity sense = kCaseSensitive) const
{
if (c_str() == str.c_str())
return 0;
return (sense == kCaseSensitive) ? strcmp(s_str(), str.s_str())
: stricmp(s_str(), str.s_str());
}
int Compare(const char *str, CaseSensitivity sense = kCaseSensitive) const
{
return (sense == kCaseSensitive) ? strcmp(s_str(), str)
: stricmp(s_str(), str);
}
int CompareN(const plString &str, size_t count, CaseSensitivity sense = kCaseSensitive) const
{
if (c_str() == str.c_str())
return 0;
return (sense == kCaseSensitive) ? strncmp(s_str(), str.s_str(), count)
: strnicmp(s_str(), str.s_str(), count);
}
int CompareN(const char *str, size_t count, CaseSensitivity sense = kCaseSensitive) const
{
return (sense == kCaseSensitive) ? strncmp(s_str(), str, count)
: strnicmp(s_str(), str, count);
}
bool operator<(const plString &other) const { return Compare(other) < 0; }
bool operator==(const plString &other) const { return Compare(other) == 0; }
bool operator!=(const plString &other) const { return Compare(other) != 0; }
int Find(char ch, CaseSensitivity sense = kCaseSensitive) const;
int FindLast(char ch, CaseSensitivity sense = kCaseSensitive) const;
int Find(const char *str, CaseSensitivity sense = kCaseSensitive) const;
int Find(const plString &str, CaseSensitivity sense = kCaseSensitive) const
{ return Find(str.c_str(), sense); }
plString TrimLeft(const char *charset = " \t\n\r") const;
plString TrimRight(const char *charset = " \t\n\r") const;
plString Trim(const char *charset = " \t\n\r") const;
plString Substr(int start, size_t size = kSizeAuto) const;
plString Left(size_t size) const { return Substr(0, size); }
plString Right(size_t size) const { return Substr(GetSize() - size, size); }
public:
struct less : public std::binary_function<plString, plString, bool>
{
bool operator()(const plString &_L, const plString &_R) const
{ return _L.Compare(_R, kCaseSensitive) < 0; }
};
struct less_i : public std::binary_function<plString, plString, bool>
{
bool operator()(const plString &_L, const plString &_R) const
{ return _L.Compare(_R, kCaseInsensitive) < 0; }
};
struct equal : public std::binary_function<plString, plString, bool>
{
bool operator()(const plString &_L, const plString &_R) const
{ return _L.Compare(_R, kCaseSensitive) == 0; }
};
struct equal_i : public std::binary_function<plString, plString, bool>
{
bool operator()(const plString &_L, const plString &_R) const
{ return _L.Compare(_R, kCaseInsensitive) == 0; }
};
public:
struct iterator
{
iterator() : m_ptr(nil), m_end(nil) { }
iterator(const iterator &copy) : m_ptr(copy.m_ptr), m_end(copy.m_end) { }
iterator &operator=(const iterator &copy)
{ m_ptr = copy.m_ptr; m_end = copy.m_end; return *this; }
iterator &operator++()
{
if ((*m_ptr & 0xF8) == 0xF0)
m_ptr += 4;
else if ((*m_ptr & 0xF0) == 0xE0)
m_ptr += 3;
else if ((*m_ptr & 0xE0) == 0xC0)
m_ptr += 2;
else
m_ptr += 1;
return *this;
}
iterator operator++(int)
{
iterator iter_save = *this;
(void) operator++();
return iter_save;
}
iterator &operator+=(size_t delta)
{
while (delta) {
operator++();
--delta;
}
return *this;
}
iterator operator+(size_t delta) const
{
iterator copy(*this);
copy += delta;
return copy;
}
int operator-(const iterator &other) const
{
return (int)(m_ptr - other.m_ptr);
}
bool operator==(const iterator &other) const { return m_ptr == other.m_ptr; }
bool operator!=(const iterator &other) const { return m_ptr != other.m_ptr; }
bool operator<(const iterator &other) const { return m_ptr < other.m_ptr; }
bool operator>(const iterator &other) const { return m_ptr > other.m_ptr; }
bool operator<=(const iterator &other) const { return m_ptr <= other.m_ptr; }
bool operator>=(const iterator &other) const { return m_ptr >= other.m_ptr; }
UniChar operator*() const
{
UniChar ch;
if ((*m_ptr & 0xF8) == 0xF0) {
ch = (m_ptr[0] & 0x07) << 18;
ch |= (m_ptr[1] & 0x3F) << 12;
ch |= (m_ptr[2] & 0x3F) << 6;
ch |= (m_ptr[3] & 0x3F);
} else if ((*m_ptr & 0xF0) == 0xE0) {
ch = (m_ptr[0] & 0x0F) << 12;
ch |= (m_ptr[1] & 0x3F) << 6;
ch |= (m_ptr[2] & 0x3F);
} else if ((*m_ptr & 0xE0) == 0xC0) {
ch = (m_ptr[0] & 0x1F) << 6;
ch |= (m_ptr[1] & 0x3F);
} else {
ch = m_ptr[0];
}
return ch;
}
bool AtEnd() const { return m_ptr >= m_end; }
bool IsValid() const { return m_ptr != 0; }
private:
friend class plString;
iterator(const char *ptr, size_t size) : m_ptr(ptr), m_end(ptr + size) { }
const char *m_ptr;
const char *m_end;
};
iterator GetIterator() const { return iterator(s_str(), GetSize()); }
size_t GetUniCharCount() const
{
iterator iter = GetIterator();
size_t count = 0;
while (!iter.AtEnd()) {
++iter;
++count;
}
return count;
}
private:
friend plString operator+(const plString &left, const plString &right);
};
plString operator+(const plString &left, const plString &right);
class plStringStream
{
public:
plStringStream() : fBufSize(256), fLength(0)
{
fBuffer = new char[fBufSize];
}
~plStringStream() { delete [] fBuffer; }
plStringStream &operator<<(const char *text);
plStringStream &operator<<(int num);
plStringStream &operator<<(unsigned int num);
plStringStream &operator<<(char ch);
plStringStream &operator<<(const plString &text)
{
return operator<<(text.s_str());
}
size_t GetLength() const { return fLength; }
plString GetString() { return plString::FromUtf8(fBuffer, fLength); }
private:
char *fBuffer;
size_t fBufSize;
size_t fLength;
};
#endif //plString_Defined

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

@ -53,7 +53,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plResMgr/plKeyFinder.h" #include "plResMgr/plKeyFinder.h"
#include "plPipeline/plDebugText.h" #include "plPipeline/plDebugText.h"
void plAnimDebugList::AddObjects(char *subString) void plAnimDebugList::AddObjects(const plString &subString)
{ {
std::vector<plKey> keys; std::vector<plKey> keys;
std::vector<plKey>::iterator i; std::vector<plKey>::iterator i;
@ -79,18 +79,18 @@ void plAnimDebugList::AddObjects(char *subString)
} }
} }
void plAnimDebugList::RemoveObjects(char *subString) void plAnimDebugList::RemoveObjects(const plString &subString)
{ {
int i; int i;
for (i = fMaterialKeys.GetCount() - 1; i >= 0; i--) for (i = fMaterialKeys.GetCount() - 1; i >= 0; i--)
{ {
if (strstr(fMaterialKeys[i]->GetName(), subString)) if (fMaterialKeys[i]->GetName().Find(subString) >= 0)
fMaterialKeys.Remove(i); fMaterialKeys.Remove(i);
} }
for (i = fSOKeys.GetCount() - 1; i >= 0; i--) for (i = fSOKeys.GetCount() - 1; i >= 0; i--)
{ {
if (strstr(fSOKeys[i]->GetName(), subString)) if (fSOKeys[i]->GetName().Find(subString) >= 0)
fSOKeys.Remove(i); fSOKeys.Remove(i);
} }
} }
@ -104,7 +104,7 @@ void plAnimDebugList::ShowReport()
int y,x,i,j; int y,x,i,j;
const int yOff=10, startY=40, startX=10; const int yOff=10, startY=40, startX=10;
char str[256]; plString str;
x = startX; x = startX;
y = startY; y = startY;
@ -124,10 +124,10 @@ void plAnimDebugList::ShowReport()
plLayerAnimation *layerAnim = plLayerAnimation::ConvertNoRef(layer); plLayerAnimation *layerAnim = plLayerAnimation::ConvertNoRef(layer);
if (layerAnim) if (layerAnim)
{ {
sprintf(str, "%s: %s %.3f (%.3f)", mat->GetKeyName(), layerAnim->GetKeyName(), str = plString::Format("%s: %s %.3f (%.3f)", mat->GetKeyName().c_str(), layerAnim->GetKeyName().c_str(),
layerAnim->GetTimeConvert().CurrentAnimTime(), layerAnim->GetTimeConvert().CurrentAnimTime(),
layerAnim->GetTimeConvert().WorldToAnimTimeNoUpdate(hsTimer::GetSysSeconds())); layerAnim->GetTimeConvert().WorldToAnimTimeNoUpdate(hsTimer::GetSysSeconds()));
txt.DrawString(x, y, str); txt.DrawString(x, y, _TEMP_CONVERT_TO_CONST_CHAR(str));
y += yOff; y += yOff;
} }
layer = layer->GetOverLay(); layer = layer->GetOverLay();
@ -137,7 +137,7 @@ void plAnimDebugList::ShowReport()
y += yOff; y += yOff;
txt.DrawString(x, y, "AGMaster Anims", 255, 255, 255, 255, plDebugText::kStyleBold); txt.DrawString(x, y, "AGMaster Anims", 255, 255, 255, 255, plDebugText::kStyleBold);
y += yOff; y += yOff;
for (i = 0; i < fSOKeys.GetCount(); i++) for (i = 0; i < fSOKeys.GetCount(); i++)
{ {
plSceneObject *so = plSceneObject::ConvertNoRef(fSOKeys[i]->ObjectIsLoaded()); plSceneObject *so = plSceneObject::ConvertNoRef(fSOKeys[i]->ObjectIsLoaded());
@ -148,17 +148,17 @@ void plAnimDebugList::ShowReport()
if (!mod) if (!mod)
continue; continue;
sprintf(str, " %s", so->GetKeyName()); str = plString::Format(" %s", so->GetKeyName().c_str());
txt.DrawString(x, y, str); txt.DrawString(x, y, _TEMP_CONVERT_TO_CONST_CHAR(str));
y += yOff; y += yOff;
for (j = 0; j < mod->GetNumATCAnimations(); j++) for (j = 0; j < mod->GetNumATCAnimations(); j++)
{ {
plAGAnimInstance *anim = mod->GetATCAnimInstance(j); plAGAnimInstance *anim = mod->GetATCAnimInstance(j);
sprintf(str, " %s: %.3f (%.3f)", anim->GetAnimation()->GetName(), str = plString::Format(" %s: %.3f (%.3f)", anim->GetAnimation()->GetName().c_str(),
anim->GetTimeConvert()->CurrentAnimTime(), anim->GetTimeConvert()->CurrentAnimTime(),
anim->GetTimeConvert()->WorldToAnimTimeNoUpdate(hsTimer::GetSysSeconds())); anim->GetTimeConvert()->WorldToAnimTimeNoUpdate(hsTimer::GetSysSeconds()));
txt.DrawString(x, y, str); txt.DrawString(x, y, _TEMP_CONVERT_TO_CONST_CHAR(str));
y += yOff; y += yOff;
} }
} }

4
Sources/Plasma/FeatureLib/pfAnimation/plAnimDebugList.h

@ -55,8 +55,8 @@ public:
plAnimDebugList() : fEnabled(false) {} plAnimDebugList() : fEnabled(false) {}
~plAnimDebugList() {} ~plAnimDebugList() {}
void AddObjects(char *subString); void AddObjects(const plString &subString);
void RemoveObjects(char *subString); void RemoveObjects(const plString &subString);
void ShowReport(); void ShowReport();
}; };

4
Sources/Plasma/FeatureLib/pfAnimation/plFollowMod.cpp

@ -69,11 +69,11 @@ hsBool plFollowMod::MsgReceive(plMessage* msg)
plRenderMsg* rend = plRenderMsg::ConvertNoRef(msg); plRenderMsg* rend = plRenderMsg::ConvertNoRef(msg);
if( rend ) if( rend )
{ {
plProfile_BeginLap(FollowMod, this->GetKey()->GetUoid().GetObjectName()); plProfile_BeginLap(FollowMod, this->GetKey()->GetUoid().GetObjectName().c_str());
fLeaderL2W = rend->Pipeline()->GetCameraToWorld(); fLeaderL2W = rend->Pipeline()->GetCameraToWorld();
fLeaderW2L = rend->Pipeline()->GetWorldToCamera(); fLeaderW2L = rend->Pipeline()->GetWorldToCamera();
fLeaderSet = true; fLeaderSet = true;
plProfile_EndLap(FollowMod, this->GetKey()->GetUoid().GetObjectName()); plProfile_EndLap(FollowMod, this->GetKey()->GetUoid().GetObjectName().c_str());
return true; return true;
} }
plListenerMsg* list = plListenerMsg::ConvertNoRef(msg); plListenerMsg* list = plListenerMsg::ConvertNoRef(msg);

4
Sources/Plasma/FeatureLib/pfAnimation/plLineFollowMod.cpp

@ -257,11 +257,11 @@ hsBool plLineFollowMod::MsgReceive(plMessage* msg)
plRenderMsg* rend = plRenderMsg::ConvertNoRef(msg); plRenderMsg* rend = plRenderMsg::ConvertNoRef(msg);
if( rend ) if( rend )
{ {
plProfile_BeginLap(LineFollow, this->GetKey()->GetUoid().GetObjectName()); plProfile_BeginLap(LineFollow, this->GetKey()->GetUoid().GetObjectName().c_str());
hsPoint3 oldPos = fSearchPos; hsPoint3 oldPos = fSearchPos;
fSearchPos = rend->Pipeline()->GetViewPositionWorld(); fSearchPos = rend->Pipeline()->GetViewPositionWorld();
ICheckForPop(oldPos, fSearchPos); ICheckForPop(oldPos, fSearchPos);
plProfile_EndLap(LineFollow, this->GetKey()->GetUoid().GetObjectName()); plProfile_EndLap(LineFollow, this->GetKey()->GetUoid().GetObjectName().c_str());
return true; return true;
} }
plListenerMsg* list = plListenerMsg::ConvertNoRef(msg); plListenerMsg* list = plListenerMsg::ConvertNoRef(msg);

4
Sources/Plasma/FeatureLib/pfAnimation/plViewFaceModifier.cpp

@ -278,7 +278,7 @@ hsBool plViewFaceModifier::MsgReceive(plMessage* msg)
if( rend ) if( rend )
{ {
plProfile_BeginLap(ViewFace, this->GetKey()->GetUoid().GetObjectName()); plProfile_BeginLap(ViewFace, this->GetKey()->GetUoid().GetObjectName().c_str());
if( HasFlag(kFaceCam) ) if( HasFlag(kFaceCam) )
{ {
@ -314,7 +314,7 @@ hsBool plViewFaceModifier::MsgReceive(plMessage* msg)
IFacePoint(rend->Pipeline(), fFacePoint); IFacePoint(rend->Pipeline(), fFacePoint);
plProfile_EndLap(ViewFace, this->GetKey()->GetUoid().GetObjectName()); plProfile_EndLap(ViewFace, this->GetKey()->GetUoid().GetObjectName().c_str());
return true; return true;
} }
plArmatureUpdateMsg* armMsg = plArmatureUpdateMsg::ConvertNoRef(msg); plArmatureUpdateMsg* armMsg = plArmatureUpdateMsg::ConvertNoRef(msg);

18
Sources/Plasma/FeatureLib/pfAudio/plListener.cpp

@ -182,21 +182,21 @@ hsBool plListener::IEval(double secs, float del, uint32_t dirty)
if( fPrintDbgInfo ) if( fPrintDbgInfo )
{ {
char str[ 256 ]; plString str;
sprintf( str, "Direction: (%3.2f,%3.2f,%3.2f) from %s", dir.fX, dir.fY, dir.fZ, ( facingType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName() : "VCam" ); str = plString::Format( "Direction: (%3.2f,%3.2f,%3.2f) from %s", dir.fX, dir.fY, dir.fZ, ( facingType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName().c_str() : "VCam" );
plDebugText::Instance().DrawString( x, y, str, (uint32_t)0xffffffff ); plDebugText::Instance().DrawString( x, y, str.c_str(), (uint32_t)0xffffffff );
y += 12; y += 12;
sprintf( str, "Up: (%3.2f,%3.2f,%3.2f) from %s", up.fX, up.fY, up.fZ, ( facingType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName() : "VCam" ); str = plString::Format( "Up: (%3.2f,%3.2f,%3.2f) from %s", up.fX, up.fY, up.fZ, ( facingType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName().c_str() : "VCam" );
plDebugText::Instance().DrawString( x, y, str, (uint32_t)0xffffffff ); plDebugText::Instance().DrawString( x, y, str.c_str(), (uint32_t)0xffffffff );
y += 12; y += 12;
sprintf( str, "Position: (%3.2f,%3.2f,%3.2f) from %s", position.fX, position.fY, position.fZ, ( posType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName() : "VCam" ); str = plString::Format( "Position: (%3.2f,%3.2f,%3.2f) from %s", position.fX, position.fY, position.fZ, ( posType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName().c_str() : "VCam" );
plDebugText::Instance().DrawString( x, y, str, (uint32_t)0xffffffff ); plDebugText::Instance().DrawString( x, y, str.c_str(), (uint32_t)0xffffffff );
y += 12; y += 12;
sprintf( str, "Velocity: (%3.2f,%3.2f,%3.2f) from %s", velocity.fX, velocity.fY, velocity.fZ, ( velType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName() : "VCam" ); str = plString::Format( "Velocity: (%3.2f,%3.2f,%3.2f) from %s", velocity.fX, velocity.fY, velocity.fZ, ( velType == kObject ) ? pRefObject->GetKey()->GetUoid().GetObjectName().c_str() : "VCam" );
plDebugText::Instance().DrawString( x, y, str, (uint32_t)0xffffffff ); plDebugText::Instance().DrawString( x, y, str.c_str(), (uint32_t)0xffffffff );
y += 12; y += 12;
} }
plgDispatch::MsgSend( msg ); plgDispatch::MsgSend( msg );

4
Sources/Plasma/FeatureLib/pfAudio/plRandomSoundMod.cpp

@ -253,9 +253,9 @@ void plRandomSoundMod::IPlayNext()
if (plgAudioSys::AreExtendedLogsEnabled()) if (plgAudioSys::AreExtendedLogsEnabled())
{ {
if (fGroups) if (fGroups)
plStatusLog::AddLineS("audio.log", "%s: Playing sound #%d from group %d", GetTarget(0)->GetKeyName(), fCurrent, fCurrentGroup); plStatusLog::AddLineS("audio.log", "%s: Playing sound #%d from group %d", GetTarget(0)->GetKeyName().c_str(), fCurrent, fCurrentGroup);
else else
plStatusLog::AddLineS("audio.log", "%s: Playing sound #%d", GetTarget(0)->GetKeyName(), fCurrent); plStatusLog::AddLineS("audio.log", "%s: Playing sound #%d", GetTarget(0)->GetKeyName().c_str(), fCurrent);
} }
fEndTimes[fCurrent] = hsTimer::GetSysSeconds() + currLen; fEndTimes[fCurrent] = hsTimer::GetSysSeconds() + currLen;

6
Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp

@ -1026,7 +1026,7 @@ void plCameraBrain1_Avatar::Update(hsBool forced)
if (fFlags.IsBitSet(kIsTransitionCamera)) if (fFlags.IsBitSet(kIsTransitionCamera))
{ {
if (GetKey()) if (GetKey())
hsStatusMessageF("%s thinks it's the transition camera\n",GetKeyName()); hsStatusMessageF("%s thinks it's the transition camera\n", GetKeyName().c_str());
} }
else else
{ {
@ -1318,8 +1318,8 @@ hsBool plCameraBrain1_FirstPerson::MsgReceive(plMessage* msg)
plSceneObject* child = (plSceneObject*)ci->GetChild(i)->GetOwner(); plSceneObject* child = (plSceneObject*)ci->GetChild(i)->GetOwner();
if (child) if (child)
{ {
const char* name = child->GetKeyName(); const plString& name = child->GetKeyName();
if (stricmp(name, "FPCameraOrigin") == 0) if (name.Compare("FPCameraOrigin", plString::kCaseInsensitive) == 0)
{ {
fPosNode = child; fPosNode = child;
SetOffset(hsVector3(0,0,0)); SetOffset(hsVector3(0,0,0));

4
Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp

@ -533,11 +533,11 @@ void plVirtualCam1::SetRender(hsBool render)
} }
// hack, hack, hack // hack, hack, hack
hsBool plVirtualCam1::RestoreFromName(const char* name) hsBool plVirtualCam1::RestoreFromName(const plString& name)
{ {
for(int i = 0; i < fCamerasLoaded.Count(); i++) for(int i = 0; i < fCamerasLoaded.Count(); i++)
{ {
if (strcmp(name, fCamerasLoaded[i]->GetKeyName()) == 0) if (name.Compare(fCamerasLoaded[i]->GetKeyName()) == 0)
{ {
RebuildStack(fCamerasLoaded[i]->GetKey()); RebuildStack(fCamerasLoaded[i]->GetKey());
return true; return true;

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

@ -170,7 +170,7 @@ public:
void ClearStack(); void ClearStack();
void AddCameraLoaded(plSceneObject* pCam) { fCamerasLoaded.Append(pCam); } void AddCameraLoaded(plSceneObject* pCam) { fCamerasLoaded.Append(pCam); }
hsBool RestoreFromName(const char* name); hsBool RestoreFromName(const plString& name);
void StartUnPan(); void StartUnPan();
// these are for console access // these are for console access
static hsBool fUseAccelOverride, freeze, alwaysCutForColin, WalkPan3rdPerson,StayInFirstPersonForever; static hsBool fUseAccelOverride, freeze, alwaysCutForColin, WalkPan3rdPerson,StayInFirstPersonForever;

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

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

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

@ -112,9 +112,9 @@ PF_CONSOLE_FILE_DUMMY(Avatar)
// //
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
plKey FindSceneObjectByName(const char* name, const char* ageName, char* statusStr, bool subString=false); plKey FindSceneObjectByName(const plString& name, const char* ageName, char* statusStr, bool subString=false);
plKey FindObjectByName(const char* name, int type, const char* ageName, char* statusStr, bool subString=false); plKey FindObjectByName(const plString& name, int type, const char* ageName, char* statusStr, bool subString=false);
plKey FindObjectByNameAndType(const char* name, const char* typeName, const char* ageName, plKey FindObjectByNameAndType(const plString& name, const char* typeName, const char* ageName,
char* statusStr, bool subString=false); char* statusStr, bool subString=false);
void PrintStringF(void pfun(const char *),const char * fmt, ...); void PrintStringF(void pfun(const char *),const char * fmt, ...);
@ -173,7 +173,7 @@ PF_CONSOLE_CMD( Avatar_Spawn, Show, "", "Print a list of spawn points.")
const plSpawnModifier * spawn = mgr->GetSpawnPoint(i); const plSpawnModifier * spawn = mgr->GetSpawnPoint(i);
if(spawn) if(spawn)
{ {
PrintStringF(PrintString, "%d. %s", i, spawn->GetKey()->GetName()); PrintStringF(PrintString, "%d. %s", i, spawn->GetKey()->GetName().c_str());
} }
} }
} }
@ -353,7 +353,7 @@ PF_CONSOLE_CMD( Avatar_Turn, SetMouseTurnSensitivity, "float sensitivity", "Set
PF_CONSOLE_CMD( Avatar_Multistage, Trigger, "string multiComp", "Triggers the named Multistage Animation component") PF_CONSOLE_CMD( Avatar_Multistage, Trigger, "string multiComp", "Triggers the named Multistage Animation component")
{ {
char str[256]; char str[256];
plKey key = FindObjectByNameAndType((const char*)params[0], "plMultistageBehMod", nil, str, true); plKey key = FindObjectByNameAndType(plString::FromUtf8(params[0]), "plMultistageBehMod", nil, str, true);
PrintString(str); PrintString(str);
if (key) if (key)
@ -464,8 +464,8 @@ PF_CONSOLE_CMD( Avatar,
"Mark whether avatars in regionA want updates on those on regionB" ) "Mark whether avatars in regionA want updates on those on regionB" )
{ {
plRelevanceMgr *mgr = plRelevanceMgr::Instance(); plRelevanceMgr *mgr = plRelevanceMgr::Instance();
char *regA = params[0]; plString regA = plString::FromUtf8(params[0]);
char *regB = params[1]; plString regB = plString::FromUtf8(params[1]);
mgr->MarkRegion(mgr->GetIndex(regA), mgr->GetIndex(regB), params[2]); mgr->MarkRegion(mgr->GetIndex(regA), mgr->GetIndex(regB), params[2]);
} }
@ -484,7 +484,7 @@ PF_CONSOLE_CMD( Avatar,
PF_CONSOLE_CMD( Avatar, SeekPoint, "string seekpoint", "Move to the given seekpoint.") PF_CONSOLE_CMD( Avatar, SeekPoint, "string seekpoint", "Move to the given seekpoint.")
{ {
char *spName = params[0]; plString spName = plString::FromUtf8(params[0]);
plArmatureMod *avatar = plAvatarMgr::GetInstance()->GetLocalAvatar(); plArmatureMod *avatar = plAvatarMgr::GetInstance()->GetLocalAvatar();
@ -586,7 +586,7 @@ PF_CONSOLE_CMD( Avatar, ClickToTurn, "bool b", "Set click-to-turn functionality.
PF_CONSOLE_CMD( Avatar, FakeLinkToObj, "string objName", "Pseudo-Link the avatar to the specified object's location") PF_CONSOLE_CMD( Avatar, FakeLinkToObj, "string objName", "Pseudo-Link the avatar to the specified object's location")
{ {
char *spName = params[0]; plString spName = plString::FromUtf8(params[0]);
char buff[256]; char buff[256];
plKey seekKey = FindSceneObjectByName(spName, nil, buff); plKey seekKey = FindSceneObjectByName(spName, nil, buff);
if (!seekKey) if (!seekKey)
@ -632,11 +632,11 @@ PF_CONSOLE_CMD( Avatar_Physics, TogglePhysical, "", "Disable/enable physics on t
PF_CONSOLE_CMD( Avatar_Anim, BlendAnim, "string Animation, float blendFactor", "Blend the given animation with the current animation.") PF_CONSOLE_CMD( Avatar_Anim, BlendAnim, "string Animation, float blendFactor", "Blend the given animation with the current animation.")
{ {
char *animationName = params[0]; plString animationName = plString::FromUtf8(params[0]);
float blendFactor = params[1]; float blendFactor = params[1];
plArmatureMod *avatar = plAvatarMgr::GetInstance()->GetLocalAvatar(); plArmatureMod *avatar = plAvatarMgr::GetInstance()->GetLocalAvatar();
if (avatar && animationName) if (avatar && !animationName.IsNull())
{ {
plAGAnim * anim = plAGAnim::FindAnim(animationName); plAGAnim * anim = plAGAnim::FindAnim(animationName);
if(anim) if(anim)
@ -650,12 +650,12 @@ PF_CONSOLE_CMD( Avatar_Anim, BlendAnim, "string Animation, float blendFactor", "
PF_CONSOLE_CMD( Avatar_Anim, BlendAnimPri, "string Animation, float blendFactor, int priority", "Blend animation using priority.") PF_CONSOLE_CMD( Avatar_Anim, BlendAnimPri, "string Animation, float blendFactor, int priority", "Blend animation using priority.")
{ {
char *animationName = params[0]; plString animationName = plString::FromUtf8(params[0]);
float blendFactor = params[1]; float blendFactor = params[1];
int priority = params[2]; int priority = params[2];
plArmatureMod *avatar = plAvatarMgr::GetInstance()->GetLocalAvatar(); plArmatureMod *avatar = plAvatarMgr::GetInstance()->GetLocalAvatar();
if (avatar && animationName) if (avatar && !animationName.IsNull())
{ {
plAGAnim * anim = plAGAnim::FindAnim(animationName); plAGAnim * anim = plAGAnim::FindAnim(animationName);
if(anim) if(anim)
@ -671,15 +671,15 @@ PF_CONSOLE_CMD( Avatar_Anim, PlaySimpleAnim, "string AvatarName, string Animatio
{ {
plArmatureMod *avatar = plAvatarMgr::GetInstance()->FindAvatarByModelName(params[0]); plArmatureMod *avatar = plAvatarMgr::GetInstance()->FindAvatarByModelName(params[0]);
if (avatar) if (avatar)
avatar->PlaySimpleAnim(params[1]); avatar->PlaySimpleAnim(plString::FromUtf8(params[1]));
} }
PF_CONSOLE_CMD( Avatar_Anim, DetachAnim, "string Animation", "Remove the given animation from the avatar.") PF_CONSOLE_CMD( Avatar_Anim, DetachAnim, "string Animation", "Remove the given animation from the avatar.")
{ {
char *animationName = params[0]; plString animationName = plString::FromUtf8(params[0]);
plArmatureMod *avatar = plAvatarMgr::GetInstance()->GetLocalAvatar(); plArmatureMod *avatar = plAvatarMgr::GetInstance()->GetLocalAvatar();
if (avatar && animationName) if (avatar && !animationName.IsNull())
{ {
plAGAnimInstance * instance = avatar->FindAnimInstance(animationName); plAGAnimInstance * instance = avatar->FindAnimInstance(animationName);
if(instance) if(instance)
@ -691,11 +691,11 @@ PF_CONSOLE_CMD( Avatar_Anim, DetachAnim, "string Animation", "Remove the given a
PF_CONSOLE_CMD( Avatar_Anim, SetBlend, "string Animation, float blend", "Set the blend of the given animation.") PF_CONSOLE_CMD( Avatar_Anim, SetBlend, "string Animation, float blend", "Set the blend of the given animation.")
{ {
char *animationName = params[0]; plString animationName = plString::FromUtf8(params[0]);
float blend = params[1]; float blend = params[1];
plArmatureMod *avatar = plAvatarMgr::GetInstance()->GetLocalAvatar(); plArmatureMod *avatar = plAvatarMgr::GetInstance()->GetLocalAvatar();
if (avatar && animationName) if (avatar && !animationName.IsNull())
{ {
plAGAnimInstance *anim = avatar->FindAnimInstance(animationName); plAGAnimInstance *anim = avatar->FindAnimInstance(animationName);
if(anim) if(anim)

14
Sources/Plasma/FeatureLib/pfConsole/pfConsole.cpp

@ -333,8 +333,8 @@ hsBool pfConsole::MsgReceive( plMessage *msg )
// InviteReceived // InviteReceived
case kSrv2Cli_GameMgr_InviteReceived: { case kSrv2Cli_GameMgr_InviteReceived: {
const Srv2Cli_GameMgr_InviteReceived & gmMsg = *(const Srv2Cli_GameMgr_InviteReceived *)gameMgrMsg->netMsg; const Srv2Cli_GameMgr_InviteReceived & gmMsg = *(const Srv2Cli_GameMgr_InviteReceived *)gameMgrMsg->netMsg;
const char * inviterName = plNetClientMgr::GetInstance()->GetPlayerNameById(gmMsg.inviterId); const plString & inviterName = plNetClientMgr::GetInstance()->GetPlayerNameById(gmMsg.inviterId);
AddLineF("[GameMgr] Invite received: %S, %u. Inviter: %s", pfGameMgr::GetInstance()->GetGameNameByTypeId(gmMsg.gameTypeId), gmMsg.newGameId, inviterName ? inviterName : "<Unknown>"); AddLineF("[GameMgr] Invite received: %S, %u. Inviter: %s", pfGameMgr::GetInstance()->GetGameNameByTypeId(gmMsg.gameTypeId), gmMsg.newGameId, inviterName.s_str("<Unknown>"));
} }
return true; return true;
@ -342,8 +342,8 @@ hsBool pfConsole::MsgReceive( plMessage *msg )
// InviteRevoked // InviteRevoked
case kSrv2Cli_GameMgr_InviteRevoked: { case kSrv2Cli_GameMgr_InviteRevoked: {
const Srv2Cli_GameMgr_InviteRevoked & gmMsg = *(const Srv2Cli_GameMgr_InviteRevoked *)gameMgrMsg->netMsg; const Srv2Cli_GameMgr_InviteRevoked & gmMsg = *(const Srv2Cli_GameMgr_InviteRevoked *)gameMgrMsg->netMsg;
const char * inviterName = plNetClientMgr::GetInstance()->GetPlayerNameById(gmMsg.inviterId); const plString & inviterName = plNetClientMgr::GetInstance()->GetPlayerNameById(gmMsg.inviterId);
AddLineF("[GameMgr] Invite revoked: %S, %u. Inviter: %s", pfGameMgr::GetInstance()->GetGameNameByTypeId(gmMsg.gameTypeId), gmMsg.newGameId, inviterName ? inviterName : "<Unknown>"); AddLineF("[GameMgr] Invite revoked: %S, %u. Inviter: %s", pfGameMgr::GetInstance()->GetGameNameByTypeId(gmMsg.gameTypeId), gmMsg.newGameId, inviterName.s_str("<Unknown>"));
} }
return true; return true;
@ -372,7 +372,7 @@ hsBool pfConsole::MsgReceive( plMessage *msg )
cli->GetName(), cli->GetName(),
cli->GetGameId(), cli->GetGameId(),
netMsg.playerId netMsg.playerId
? plNetClientMgr::GetInstance()->GetPlayerNameById(netMsg.playerId) ? plNetClientMgr::GetInstance()->GetPlayerNameById(netMsg.playerId).c_str()
: "Computer" : "Computer"
); );
} }
@ -387,7 +387,7 @@ hsBool pfConsole::MsgReceive( plMessage *msg )
cli->GetName(), cli->GetName(),
cli->GetGameId(), cli->GetGameId(),
netMsg.playerId netMsg.playerId
? plNetClientMgr::GetInstance()->GetPlayerNameById(netMsg.playerId) ? plNetClientMgr::GetInstance()->GetPlayerNameById(netMsg.playerId).c_str()
: "Computer" : "Computer"
); );
} }
@ -503,7 +503,7 @@ hsBool pfConsole::MsgReceive( plMessage *msg )
const Srv2Cli_TTT_MoveMade & netMsg = *(const Srv2Cli_TTT_MoveMade *)gameCliMsg->netMsg; const Srv2Cli_TTT_MoveMade & netMsg = *(const Srv2Cli_TTT_MoveMade *)gameCliMsg->netMsg;
const char * playerName const char * playerName
= netMsg.playerId = netMsg.playerId
? plNetClientMgr::GetInstance()->GetPlayerNameById(netMsg.playerId) ? plNetClientMgr::GetInstance()->GetPlayerNameById(netMsg.playerId).c_str()
: "Computer"; : "Computer";
AddLineF( AddLineF(
"[Game %s:%u] %s moved:", "[Game %s:%u] %s moved:",

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

@ -265,9 +265,9 @@ PF_CONSOLE_FILE_DUMMY(Main)
// utility functions // utility functions
// //
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
plKey FindSceneObjectByName(const char* name, const char* ageName, char* statusStr, bool subString=false); plKey FindSceneObjectByName(const plString& name, const char* ageName, char* statusStr, bool subString=false);
plKey FindObjectByName(const char* name, int type, const char* ageName, char* statusStr, bool subString=false); plKey FindObjectByName(const plString& name, int type, const char* ageName, char* statusStr, bool subString=false);
plKey FindObjectByNameAndType(const char* name, const char* typeName, const char* ageName, plKey FindObjectByNameAndType(const plString& name, const char* typeName, const char* ageName,
char* statusStr, bool subString=false); char* statusStr, bool subString=false);
void PrintStringF(void pfun(const char *),const char * fmt, ...); void PrintStringF(void pfun(const char *),const char * fmt, ...);
@ -275,9 +275,9 @@ void PrintStringF(void pfun(const char *),const char * fmt, ...);
// Find an object from name, type (int), and optionally age. // Find an object from name, type (int), and optionally age.
// Name can be an alias specified by saying $foo // Name can be an alias specified by saying $foo
// //
plKey FindObjectByName(const char* name, int type, const char* ageName, char* statusStr, bool subString) plKey FindObjectByName(const plString& name, int type, const char* ageName, char* statusStr, bool subString)
{ {
if (!name) if (name.IsNull())
{ {
if (statusStr) if (statusStr)
sprintf(statusStr, "Object name is nil"); sprintf(statusStr, "Object name is nil");
@ -336,10 +336,10 @@ plKey FindObjectByName(const char* name, int type, const char* ageName, char* st
// Name can be an alias specified by saying $foo. // Name can be an alias specified by saying $foo.
// Will load the object if necessary. // Will load the object if necessary.
// //
plKey FindSceneObjectByName(const char* name, const char* ageName, char* statusStr, bool subString) plKey FindSceneObjectByName(const plString& name, const char* ageName, char* statusStr, bool subString)
{ {
plKey key=FindObjectByName(name, plSceneObject::Index(), ageName, statusStr, subString); plKey key=FindObjectByName(name, plSceneObject::Index(), ageName, statusStr, subString);
if (!plSceneObject::ConvertNoRef(key ? key->ObjectIsLoaded() : nil)) if (!plSceneObject::ConvertNoRef(key ? key->ObjectIsLoaded() : nil))
{ {
if (statusStr) if (statusStr)
@ -354,7 +354,7 @@ plKey FindSceneObjectByName(const char* name, const char* ageName, char* statusS
// Find an object from name, type (string) and optionally age. // Find an object from name, type (string) and optionally age.
// Name can be an alias specified by saying $foo // Name can be an alias specified by saying $foo
// //
plKey FindObjectByNameAndType(const char* name, const char* typeName, const char* ageName, plKey FindObjectByNameAndType(const plString& name, const char* typeName, const char* ageName,
char* statusStr, bool subString) char* statusStr, bool subString)
{ {
if (!typeName) if (!typeName)
@ -1577,7 +1577,7 @@ PF_CONSOLE_CMD( Graphics_Renderer, GrabCubeMap,
"Take cubemap from sceneObject's position and name it prefix_XX.jpg") "Take cubemap from sceneObject's position and name it prefix_XX.jpg")
{ {
char str[512]; char str[512];
const char* objName = params[0]; plString objName = plString::FromUtf8(params[0]);
plKey key = FindSceneObjectByName(objName, nil, str); plKey key = FindSceneObjectByName(objName, nil, str);
PrintString( str ); PrintString( str );
if( !key ) if( !key )
@ -1841,7 +1841,7 @@ PF_CONSOLE_CMD( Graphics_Show, SingleSound,
const char *ageName = plAgeLoader::GetInstance()->GetCurrAgeDesc().GetAgeName(); const char *ageName = plAgeLoader::GetInstance()->GetCurrAgeDesc().GetAgeName();
plKey key = FindSceneObjectByName( params[ 0 ], ageName, str, true ); plKey key = FindSceneObjectByName( plString::FromUtf8( params[ 0 ] ), ageName, str, true );
plSceneObject *obj = ( key != nil ) ? plSceneObject::ConvertNoRef( key->GetObjectPtr() ) : nil; plSceneObject *obj = ( key != nil ) ? plSceneObject::ConvertNoRef( key->GetObjectPtr() ) : nil;
if( !obj ) if( !obj )
{ {
@ -2173,7 +2173,7 @@ PF_CONSOLE_CMD( App,
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(params[0], nil, str); plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plSceneObject* obj = plSceneObject::ConvertNoRef(key->GetObjectPtr()); plSceneObject* obj = plSceneObject::ConvertNoRef(key->GetObjectPtr());
if( !obj ) if( !obj )
{ {
@ -2250,7 +2250,7 @@ PF_CONSOLE_CMD( App,
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(params[0], nil, str); plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plSceneObject* obj = plSceneObject::ConvertNoRef(key->GetObjectPtr()); plSceneObject* obj = plSceneObject::ConvertNoRef(key->GetObjectPtr());
if( !obj ) if( !obj )
{ {
@ -2304,18 +2304,18 @@ PF_CONSOLE_CMD( App,
"Enable/Disable/Toggle display of named CamView object" ) "Enable/Disable/Toggle display of named CamView object" )
{ {
char str[256]; char str[256];
char* name = params[0]; plString name = plString::FromUtf8(params[0]);
plKey key = FindSceneObjectByName(name, nil, str); plKey key = FindSceneObjectByName(name, nil, str);
if( !key ) if( !key )
{ {
sprintf(str, "%s - Not Found!", name); sprintf(str, "%s - Not Found!", name.c_str());
PrintString(str); PrintString(str);
return; return;
} }
plSceneObject* obj = plSceneObject::ConvertNoRef(key->GetObjectPtr()); plSceneObject* obj = plSceneObject::ConvertNoRef(key->GetObjectPtr());
if( !obj ) if( !obj )
{ {
sprintf(str, "%s - Not Found!", name); sprintf(str, "%s - Not Found!", name.c_str());
PrintString(str); PrintString(str);
return; return;
} }
@ -2328,11 +2328,11 @@ PF_CONSOLE_CMD( App,
} }
if( i >= obj->GetNumModifiers() ) if( i >= obj->GetNumModifiers() )
{ {
sprintf(str, "%s - No CamView Modifier found!", name); sprintf(str, "%s - No CamView Modifier found!", name.c_str());
PrintString(str); PrintString(str);
return; return;
} }
strcpy(str, name); strcpy(str, name.c_str());
plAnimCmdMsg* cmd = new plAnimCmdMsg(nil, obj->GetModifier(i)->GetKey(), nil); plAnimCmdMsg* cmd = new plAnimCmdMsg(nil, obj->GetModifier(i)->GetKey(), nil);
@ -2723,12 +2723,12 @@ void MyHandyPrintFunction( const plKey &obj, void (*PrintString)( const char
if( peeker->GetUoid().IsClone() ) if( peeker->GetUoid().IsClone() )
PrintStringF( PrintString, "%d refs on %s, clone %d:%d: loaded=%d", PrintStringF( PrintString, "%d refs on %s, clone %d:%d: loaded=%d",
peeker->PeekNumNotifies(), obj->GetUoid().GetObjectName(), peeker->PeekNumNotifies(), obj->GetUoid().GetObjectName().c_str(),
peeker->GetUoid().GetCloneID(), peeker->GetUoid().GetClonePlayerID(), peeker->GetUoid().GetCloneID(), peeker->GetUoid().GetClonePlayerID(),
obj->ObjectIsLoaded() ? 1 : 0); obj->ObjectIsLoaded() ? 1 : 0);
else else
PrintStringF( PrintString, "%d refs on %s: loaded=%d", PrintStringF( PrintString, "%d refs on %s: loaded=%d",
peeker->PeekNumNotifies(), obj->GetUoid().GetObjectName(), obj->ObjectIsLoaded() ? 1 : 0 ); peeker->PeekNumNotifies(), obj->GetUoid().GetObjectName().c_str(), obj->ObjectIsLoaded() ? 1 : 0 );
if( peeker->PeekNumNotifies() == 0 ) if( peeker->PeekNumNotifies() == 0 )
return; return;
@ -2754,7 +2754,8 @@ void MyHandyPrintFunction( const plKey &obj, void (*PrintString)( const char
limit--; limit--;
const plKey rcvr = msg->GetReceiver( j ); const plKey rcvr = msg->GetReceiver( j );
PrintStringF( PrintString, " %s:%s", plFactory::GetNameOfClass( rcvr->GetUoid().GetClassType() ), rcvr->GetUoid().GetObjectName() ); PrintStringF( PrintString, " %s:%s", plFactory::GetNameOfClass( rcvr->GetUoid().GetClassType() ),
rcvr->GetUoid().GetObjectName().c_str() );
} }
} }
} }
@ -2770,7 +2771,7 @@ PF_CONSOLE_CMD( Registry, ListRefs, "string keyType, string keyName", "For the g
"the objects who currently have active refs on it." ) "the objects who currently have active refs on it." )
{ {
char result[ 256 ]; char result[ 256 ];
plKey obj = FindObjectByNameAndType( params[ 1 ], params[ 0 ], nil, result); plKey obj = FindObjectByNameAndType( plString::FromUtf8( params[ 1 ] ), params[ 0 ], nil, result);
if( obj == nil ) if( obj == nil )
{ {
PrintString( result ); PrintString( result );
@ -2928,7 +2929,7 @@ PF_CONSOLE_CMD( Camera, // groupName
"increase drive turn rate" ) // helpString "increase drive turn rate" ) // helpString
{ {
plCameraBrain1_Drive::fTurnRate += 20.0f; plCameraBrain1_Drive::fTurnRate += 20.0f;
} }
PF_CONSOLE_CMD( Camera, // groupName PF_CONSOLE_CMD( Camera, // groupName
@ -2939,15 +2940,14 @@ PF_CONSOLE_CMD( Camera, // groupName
plCameraBrain1_Drive::fTurnRate -= 20.0f; plCameraBrain1_Drive::fTurnRate -= 20.0f;
if (plCameraBrain1_Drive::fTurnRate < 0.0) if (plCameraBrain1_Drive::fTurnRate < 0.0)
plCameraBrain1_Drive::fTurnRate = 20.0f; plCameraBrain1_Drive::fTurnRate = 20.0f;
} }
PF_CONSOLE_CMD( Camera, SwitchTo, "string cameraName", "Switch to the named camera") PF_CONSOLE_CMD( Camera, SwitchTo, "string cameraName", "Switch to the named camera")
{ {
char str[256]; char str[256];
char foo[256]; plString foo = plString::Format("%s_", (char*)params[0]);
sprintf(foo, "%s_", (const char*)params[0]);
plKey key = FindObjectByNameAndType(foo, "plCameraModifier1", nil, str, true); plKey key = FindObjectByNameAndType(foo, "plCameraModifier1", nil, str, true);
PrintString(str); PrintString(str);
@ -3071,7 +3071,7 @@ PF_CONSOLE_CMD( Camera, // groupName
PF_CONSOLE_GROUP( Logic ) PF_CONSOLE_GROUP( Logic )
static plLogicModBase *FindLogicMod(const char *name) static plLogicModBase *FindLogicMod(const plString &name)
{ {
char str[256]; char str[256];
plKey key = FindObjectByNameAndType(name, "plLogicModifier", nil, str, true); plKey key = FindObjectByNameAndType(name, "plLogicModifier", nil, str, true);
@ -3085,7 +3085,7 @@ static plLogicModBase *FindLogicMod(const char *name)
PF_CONSOLE_CMD( Logic, TriggerDetectorNum, "int detectorNum", "Triggers the detector with this number (from ListDetectors)") PF_CONSOLE_CMD( Logic, TriggerDetectorNum, "int detectorNum", "Triggers the detector with this number (from ListDetectors)")
{ {
std::vector<std::string> activatorNames; std::vector<plString> activatorNames;
plKeyFinder::Instance().GetActivatorNames(activatorNames); plKeyFinder::Instance().GetActivatorNames(activatorNames);
int activatorNum = params[0]; int activatorNum = params[0];
@ -3095,21 +3095,21 @@ PF_CONSOLE_CMD( Logic, TriggerDetectorNum, "int detectorNum", "Triggers the dete
return; return;
} }
plLogicModBase *mod = FindLogicMod(activatorNames[activatorNum-1].c_str()); plLogicModBase *mod = FindLogicMod(activatorNames[activatorNum-1]);
if (mod) if (mod)
mod->ConsoleTrigger(plNetClientMgr::GetInstance()->GetLocalPlayerKey()); mod->ConsoleTrigger(plNetClientMgr::GetInstance()->GetLocalPlayerKey());
} }
PF_CONSOLE_CMD( Logic, TriggerDetector, "string detectorComp", "Triggers the named detector component") PF_CONSOLE_CMD( Logic, TriggerDetector, "string detectorComp", "Triggers the named detector component")
{ {
plLogicModBase *mod = FindLogicMod((const char*)params[0]); plLogicModBase *mod = FindLogicMod(plString::FromUtf8(params[0]));
if (mod) if (mod)
mod->ConsoleTrigger(plNetClientMgr::GetInstance()->GetLocalPlayerKey()); mod->ConsoleTrigger(plNetClientMgr::GetInstance()->GetLocalPlayerKey());
} }
PF_CONSOLE_CMD(Logic, EnableDetector, "string detectorComp, bool enable", "Enables/disables the named detector component") PF_CONSOLE_CMD(Logic, EnableDetector, "string detectorComp, bool enable", "Enables/disables the named detector component")
{ {
plLogicModBase *mod = FindLogicMod((const char*)params[0]); plLogicModBase *mod = FindLogicMod(plString::FromUtf8(params[0]));
if (mod) if (mod)
{ {
plEnableMsg* enableMsg = new plEnableMsg; plEnableMsg* enableMsg = new plEnableMsg;
@ -3154,7 +3154,7 @@ PF_CONSOLE_CMD( Logic, TriggerResponderNum, "int responderNum, ...", "Triggers t
return; return;
} }
std::vector<std::string> responderNames; std::vector<plString> responderNames;
plKeyFinder::Instance().GetResponderNames(responderNames); plKeyFinder::Instance().GetResponderNames(responderNames);
int responderNum = params[0]; int responderNum = params[0];
@ -3171,7 +3171,7 @@ PF_CONSOLE_CMD( Logic, TriggerResponderNum, "int responderNum, ...", "Triggers t
} }
char str[256]; char str[256];
plKey key = FindObjectByNameAndType(responderNames[responderNum-1].c_str(), "plResponderModifier", nil, str, true); plKey key = FindObjectByNameAndType(responderNames[responderNum-1], "plResponderModifier", nil, str, true);
PrintString(str); PrintString(str);
if (key) if (key)
@ -3187,7 +3187,7 @@ PF_CONSOLE_CMD( Logic, TriggerResponder, "string responderComp, ...", "Triggers
} }
char str[256]; char str[256];
plKey key = FindObjectByNameAndType(params[0], "plResponderModifier", nil, str, true); plKey key = FindObjectByNameAndType(plString::FromUtf8(params[0]), "plResponderModifier", nil, str, true);
PrintString(str); PrintString(str);
int responderState = -1; int responderState = -1;
@ -3209,7 +3209,7 @@ PF_CONSOLE_CMD( Logic, FastForwardResponder, "string responderComp, ...", "Fastf
} }
char str[256]; char str[256];
plKey key = FindObjectByNameAndType(params[0], "plResponderModifier", nil, str, true); plKey key = FindObjectByNameAndType(plString::FromUtf8(params[0]), "plResponderModifier", nil, str, true);
PrintString(str); PrintString(str);
int responderState = -1; int responderState = -1;
@ -3224,7 +3224,7 @@ PF_CONSOLE_CMD( Logic, FastForwardResponder, "string responderComp, ...", "Fastf
PF_CONSOLE_CMD(Logic, ListDetectors, "", "Prints the names of the loaded detectors to the console") PF_CONSOLE_CMD(Logic, ListDetectors, "", "Prints the names of the loaded detectors to the console")
{ {
std::vector<std::string> activatorNames; std::vector<plString> activatorNames;
plKeyFinder::Instance().GetActivatorNames(activatorNames); plKeyFinder::Instance().GetActivatorNames(activatorNames);
for (int i = 0; i < activatorNames.size(); i++) for (int i = 0; i < activatorNames.size(); i++)
@ -3237,7 +3237,7 @@ PF_CONSOLE_CMD(Logic, ListDetectors, "", "Prints the names of the loaded detecto
PF_CONSOLE_CMD(Logic, ListResponders, "", "Prints the names of the loaded responders to the console") PF_CONSOLE_CMD(Logic, ListResponders, "", "Prints the names of the loaded responders to the console")
{ {
std::vector<std::string> responderNames; std::vector<plString> responderNames;
plKeyFinder::Instance().GetResponderNames(responderNames); plKeyFinder::Instance().GetResponderNames(responderNames);
for (int i = 0; i < responderNames.size(); i++) for (int i = 0; i < responderNames.size(); i++)
@ -3520,7 +3520,7 @@ PF_CONSOLE_CMD( Audio, SetVolume,
"string obj, float vol", "Sets the volume on a given object. 1 is max volume, 0 is silence" ) "string obj, float vol", "Sets the volume on a given object. 1 is max volume, 0 is silence" )
{ {
char str[ 256 ]; char str[ 256 ];
plKey key = FindSceneObjectByName(params[ 0 ], nil, str); plKey key = FindSceneObjectByName(plString::FromUtf8(params[ 0 ]), nil, str);
if( key == nil ) if( key == nil )
return; return;
@ -3549,7 +3549,7 @@ PF_CONSOLE_CMD( Audio, IsolateSound,
plKey key; plKey key;
plAudioSysMsg *asMsg; plAudioSysMsg *asMsg;
key = FindSceneObjectByName( params[ 0 ], nil, str ); key = FindSceneObjectByName( plString::FromUtf8( params[ 0 ] ), nil, str );
if( key == nil ) if( key == nil )
{ {
sprintf( str, "Cannot find sound %s", (char *)params[ 0 ] ); sprintf( str, "Cannot find sound %s", (char *)params[ 0 ] );
@ -3975,7 +3975,7 @@ PF_CONSOLE_CMD( Nav, UnloadPlayer, // Group name, Function name
"unloads a named player" ) // Help string "unloads a named player" ) // Help string
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(params[0], nil, str); plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
PrintString("UnloadPlayer (console version) is currently broken. Hassle Matt."); PrintString("UnloadPlayer (console version) is currently broken. Hassle Matt.");
// plNetClientMgr::UnloadPlayer(key); // plNetClientMgr::UnloadPlayer(key);
} }
@ -3993,12 +3993,12 @@ PF_CONSOLE_CMD( Nav, MovePlayer, // Group name, Function name
"moves a player from one paging unit to another" ) // Help string "moves a player from one paging unit to another" ) // Help string
{ {
char str[256]; char str[256];
plKey playerKey = FindSceneObjectByName(params[0], nil, str); plKey playerKey = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
PrintString(str); PrintString(str);
if( !playerKey ) if( !playerKey )
return; return;
plKey nodeKey = FindObjectByName(params[1], plSceneNode::Index(), nil, str); plKey nodeKey = FindObjectByName(plString::FromUtf8(params[1]), plSceneNode::Index(), nil, str);
PrintString(str); PrintString(str);
if( !nodeKey ) if( !nodeKey )
return; return;
@ -4303,9 +4303,8 @@ PF_CONSOLE_CMD( Access,
"Set the weight for a morphMod" ) "Set the weight for a morphMod" )
{ {
char str[256]; char str[256];
char name[256];
char* preFix = params[0]; char* preFix = params[0];
sprintf(name, "%s_plMorphSequence_0", preFix); plString name = plString::Format("%s_plMorphSequence_0", preFix);
plKey key = FindObjectByName(name, plMorphSequence::Index(), nil, str); plKey key = FindObjectByName(name, plMorphSequence::Index(), nil, str);
PrintString(str); PrintString(str);
if (!key) if (!key)
@ -4329,9 +4328,8 @@ PF_CONSOLE_CMD( Access,
"Activate a morphMod" ) "Activate a morphMod" )
{ {
char str[256]; char str[256];
char name[256];
char* preFix = params[0]; char* preFix = params[0];
sprintf(name, "%s_plMorphSequence_2", preFix); plString name = plString::Format("%s_plMorphSequence_2", preFix);
plKey key = FindObjectByName(name, plMorphSequence::Index(), nil, str); plKey key = FindObjectByName(name, plMorphSequence::Index(), nil, str);
PrintString(str); PrintString(str);
if (!key) if (!key)
@ -4341,7 +4339,7 @@ PF_CONSOLE_CMD( Access,
seq->Activate(); seq->Activate();
sprintf(str, "%s Active\n", name); sprintf(str, "%s Active\n", name.c_str());
PrintString(str); PrintString(str);
} }
@ -4351,9 +4349,8 @@ PF_CONSOLE_CMD( Access,
"Activate a morphMod" ) "Activate a morphMod" )
{ {
char str[256]; char str[256];
char name[256];
char* preFix = params[0]; char* preFix = params[0];
sprintf(name, "%s_plMorphSequence_2", preFix); plString name = plString::Format("%s_plMorphSequence_2", preFix);
plKey key = FindObjectByName(name, plMorphSequence::Index(), nil, str); plKey key = FindObjectByName(name, plMorphSequence::Index(), nil, str);
PrintString(str); PrintString(str);
if (!key) if (!key)
@ -4363,7 +4360,7 @@ PF_CONSOLE_CMD( Access,
seq->DeActivate(); seq->DeActivate();
sprintf(str, "%s Unactive\n", name); sprintf(str, "%s Unactive\n", name.c_str());
PrintString(str); PrintString(str);
} }
////////////////// //////////////////
@ -4508,9 +4505,7 @@ PF_CONSOLE_CMD( Access,
seq->Activate(); seq->Activate();
char str[256]; PrintString(plString::Format("%s Active\n", seq->GetKey()->GetName().c_str()).c_str());
sprintf(str, "%s Active\n", seq->GetKey()->GetName());
PrintString(str);
} }
PF_CONSOLE_CMD( Access, PF_CONSOLE_CMD( Access,
@ -4527,9 +4522,7 @@ PF_CONSOLE_CMD( Access,
seq->DeActivate(); seq->DeActivate();
char str[256]; PrintString(plString::Format("%s Unactive\n", seq->GetKey()->GetName().c_str()).c_str());
sprintf(str, "%s Unactive\n", seq->GetKey()->GetName());
PrintString(str);
} }
PF_CONSOLE_CMD( Access, PF_CONSOLE_CMD( Access,
@ -4537,7 +4530,6 @@ PF_CONSOLE_CMD( Access,
"string clothItem", "string clothItem",
"Set face morphMod to affect a clothing item" ) "Set face morphMod to affect a clothing item" )
{ {
char str[256];
plMorphSequence* seq = LocalMorphSequence(); plMorphSequence* seq = LocalMorphSequence();
if( !seq ) if( !seq )
{ {
@ -4552,8 +4544,8 @@ PF_CONSOLE_CMD( Access,
seq->SetUseSharedMesh(true); seq->SetUseSharedMesh(true);
seq->AddSharedMesh(item->fMeshes[plClothingItem::kLODHigh]); seq->AddSharedMesh(item->fMeshes[plClothingItem::kLODHigh]);
sprintf(str, "%s on item %s\n", seq->GetKey()->GetName(), (char *)params[0]); PrintString(plString::Format("%s on item %s\n", seq->GetKey()->GetName().c_str(),
PrintString(str); (char *)params[0]).c_str());
} }
#include "pfSurface/plFadeOpacityMod.h" #include "pfSurface/plFadeOpacityMod.h"
@ -4578,7 +4570,7 @@ PF_CONSOLE_CMD( Access,
"Test fading on visibility" ) "Test fading on visibility" )
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(params[0], nil, str); plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
PrintString(str); PrintString(str);
if( !key ) if( !key )
return; return;
@ -4610,7 +4602,7 @@ PF_CONSOLE_CMD( Access,
"Set the los test marker" ) "Set the los test marker" )
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(params[0], nil, str); plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
PrintString(str); PrintString(str);
if( !key ) if( !key )
return; return;
@ -4624,7 +4616,7 @@ PF_CONSOLE_CMD( Access,
"Set the Los hack marker" ) "Set the Los hack marker" )
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(params[0], nil, str); plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
PrintString(str); PrintString(str);
plSceneObject* so = nil; plSceneObject* so = nil;
@ -4699,7 +4691,7 @@ PF_CONSOLE_CMD( Access,
"Fire shot along gun's z-axis, creating decal of radius <radius>, with optional max-range (def 1000)" ) "Fire shot along gun's z-axis, creating decal of radius <radius>, with optional max-range (def 1000)" )
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(params[0], nil, str); plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
PrintString(str); PrintString(str);
if( !key ) if( !key )
return; return;
@ -4780,7 +4772,7 @@ PF_CONSOLE_CMD( Access,
"Add particle system <psys> to bulletMgr <bull>") "Add particle system <psys> to bulletMgr <bull>")
{ {
char str[256]; char str[256];
plKey bullKey = FindObjectByName(params[0], plDynaBulletMgr::Index(), nil, str, false); plKey bullKey = FindObjectByName(plString::FromUtf8(params[0]), plDynaBulletMgr::Index(), nil, str, false);
PrintString(str); PrintString(str);
if( !(bullKey && bullKey->GetObjectPtr()) ) if( !(bullKey && bullKey->GetObjectPtr()) )
{ {
@ -4788,7 +4780,7 @@ PF_CONSOLE_CMD( Access,
return; return;
} }
plKey sysKey = FindSceneObjectByName(params[1], nil, str); plKey sysKey = FindSceneObjectByName(plString::FromUtf8(params[1]), nil, str);
if( !(sysKey && sysKey->GetObjectPtr()) ) if( !(sysKey && sysKey->GetObjectPtr()) )
{ {
PrintString("Psys not found"); PrintString("Psys not found");
@ -4985,7 +4977,7 @@ static void IDisplayWaveVal(PrintFunk PrintString, plWaveSet7* wave, plWaveCmd::
PrintString(buff); PrintString(buff);
} }
static plWaveSet7* IGetWaveSet(PrintFunk PrintString, const char* name) static plWaveSet7* IGetWaveSet(PrintFunk PrintString, const plString& name)
{ {
char str[256]; char str[256];
plKey waveKey = FindObjectByName(name, plWaveSet7::Index(), nil, str, false); plKey waveKey = FindObjectByName(name, plWaveSet7::Index(), nil, str, false);
@ -5001,7 +4993,7 @@ static plWaveSet7* IGetWaveSet(PrintFunk PrintString, const char* name)
return waveSet; return waveSet;
} }
static plWaveSet7* ICheckWaveParams(PrintFunk PrintString, const char* name, int numParams, int n, plWaveCmd::Cmd cmd) static plWaveSet7* ICheckWaveParams(PrintFunk PrintString, const plString& name, int numParams, int n, plWaveCmd::Cmd cmd)
{ {
if( !numParams ) if( !numParams )
{ {
@ -5038,7 +5030,7 @@ static float LimitVal(float val, float lo, float hi, PrintFunk PrintString)
static bool ISendWaveCmd1f(PrintFunk PrintString, pfConsoleCmdParam* params, int numParams, plWaveCmd::Cmd cmd) static bool ISendWaveCmd1f(PrintFunk PrintString, pfConsoleCmdParam* params, int numParams, plWaveCmd::Cmd cmd)
{ {
plWaveSet7* wave = ICheckWaveParams(PrintString, params[0], numParams, 2, cmd); plWaveSet7* wave = ICheckWaveParams(PrintString, plString::FromUtf8(params[0]), numParams, 2, cmd);
if( !wave ) if( !wave )
return false; return false;
@ -5117,7 +5109,7 @@ static bool ISendWaveCmd1f(PrintFunk PrintString, pfConsoleCmdParam* params, int
static bool ISendWaveCmd2f(PrintFunk PrintString, pfConsoleCmdParam* params, int numParams, plWaveCmd::Cmd cmd) static bool ISendWaveCmd2f(PrintFunk PrintString, pfConsoleCmdParam* params, int numParams, plWaveCmd::Cmd cmd)
{ {
plWaveSet7* wave = ICheckWaveParams(PrintString, params[0], numParams, 3, cmd); plWaveSet7* wave = ICheckWaveParams(PrintString, plString::FromUtf8(params[0]), numParams, 3, cmd);
if( !wave ) if( !wave )
return false; return false;
@ -5160,7 +5152,7 @@ static bool ISendWaveCmd2f(PrintFunk PrintString, pfConsoleCmdParam* params, int
static bool ISendWaveCmd3f(PrintFunk PrintString, pfConsoleCmdParam* params, int numParams, plWaveCmd::Cmd cmd) static bool ISendWaveCmd3f(PrintFunk PrintString, pfConsoleCmdParam* params, int numParams, plWaveCmd::Cmd cmd)
{ {
plWaveSet7* wave = ICheckWaveParams(PrintString, params[0], numParams, 4, cmd); plWaveSet7* wave = ICheckWaveParams(PrintString, plString::FromUtf8(params[0]), numParams, 4, cmd);
if( !wave ) if( !wave )
return false; return false;
@ -5198,7 +5190,7 @@ static bool ISendWaveCmd3f(PrintFunk PrintString, pfConsoleCmdParam* params, int
static bool ISendWaveCmd4c(PrintFunk PrintString, pfConsoleCmdParam* params, int numParams, plWaveCmd::Cmd cmd) static bool ISendWaveCmd4c(PrintFunk PrintString, pfConsoleCmdParam* params, int numParams, plWaveCmd::Cmd cmd)
{ {
plWaveSet7* wave = ICheckWaveParams(PrintString, params[0], numParams, 4, cmd); plWaveSet7* wave = ICheckWaveParams(PrintString, plString::FromUtf8(params[0]), numParams, 4, cmd);
if( !wave ) if( !wave )
return false; return false;
@ -5234,7 +5226,7 @@ PF_CONSOLE_CMD( Wave, Log, // Group name, Function name
"string waveSet", // Params none "string waveSet", // Params none
"Toggle logging for waves" ) // Help string "Toggle logging for waves" ) // Help string
{ {
const char* name = params[0]; plString name = plString::FromUtf8(params[0]);
plWaveSet7* waveSet = IGetWaveSet(PrintString, name); plWaveSet7* waveSet = IGetWaveSet(PrintString, name);
if( waveSet ) if( waveSet )
{ {
@ -5245,7 +5237,7 @@ PF_CONSOLE_CMD( Wave, Log, // Group name, Function name
waveSet->StopLog(); waveSet->StopLog();
char buff[256]; char buff[256];
sprintf(buff, "Logging for %s now %s", name, logging ? "on" : "off"); sprintf(buff, "Logging for %s now %s", name.c_str(), logging ? "on" : "off");
PrintString(buff); PrintString(buff);
} }
} }
@ -5254,7 +5246,7 @@ PF_CONSOLE_CMD( Wave, Graph, // Group name, Function name
"string waveSet", // Params none "string waveSet", // Params none
"Toggle graphing lens for waves" ) // Help string "Toggle graphing lens for waves" ) // Help string
{ {
const char* name = params[0]; plString name = plString::FromUtf8(params[0]);
plWaveSet7* waveSet = IGetWaveSet(PrintString, name); plWaveSet7* waveSet = IGetWaveSet(PrintString, name);
if( waveSet ) if( waveSet )
{ {
@ -5265,7 +5257,7 @@ PF_CONSOLE_CMD( Wave, Graph, // Group name, Function name
waveSet->StopGraph(); waveSet->StopGraph();
char buff[256]; char buff[256];
sprintf(buff, "Graphing for %s now %s", name, graphing ? "on" : "off"); sprintf(buff, "Graphing for %s now %s", name.c_str(), graphing ? "on" : "off");
PrintString(buff); PrintString(buff);
} }
} }
@ -5469,7 +5461,7 @@ PF_CONSOLE_CMD( SceneObject_SetEnable, Drawable, // Group name, Function name
"Enable or disable drawing of a sceneobject" ) // Help string "Enable or disable drawing of a sceneobject" ) // Help string
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(params[0], nil, str); plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
PrintString(str); PrintString(str);
if (!key) if (!key)
return; return;
@ -5488,7 +5480,7 @@ PF_CONSOLE_CMD( SceneObject_SetEnable, Physical, // Group name, Function name
"Enable or disable the physical of a sceneobject" ) // Help string "Enable or disable the physical of a sceneobject" ) // Help string
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(params[0], nil, str); plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
PrintString(str); PrintString(str);
if (!key) if (!key)
return; return;
@ -5530,7 +5522,7 @@ PF_CONSOLE_CMD( SceneObject_SetEnable, Audible, // Group name, Function name
"Enable or disable the audible of a sceneobject" ) // Help string "Enable or disable the audible of a sceneobject" ) // Help string
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(params[0], nil, str); plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
PrintString(str); PrintString(str);
if (!key) if (!key)
return; return;
@ -5549,7 +5541,7 @@ PF_CONSOLE_CMD( SceneObject_SetEnable, All, // Group name, Function name
"Enable or disable all fxns of a sceneobject" ) // Help string "Enable or disable all fxns of a sceneobject" ) // Help string
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(params[0], nil, str); plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
PrintString(str); PrintString(str);
if (!key) if (!key)
return; return;
@ -5569,8 +5561,8 @@ PF_CONSOLE_CMD( SceneObject, Attach, // Group name, Function name
{ {
char str[256]; char str[256];
const char* childName = params[0]; plString childName = plString::FromUtf8(params[0]);
const char* parentName = params[1]; plString parentName = plString::FromUtf8(params[1]);
plKey childKey = FindSceneObjectByName(childName, nil, str); plKey childKey = FindSceneObjectByName(childName, nil, str);
if( !childKey ) if( !childKey )
@ -5596,7 +5588,7 @@ PF_CONSOLE_CMD( SceneObject, Attach, // Group name, Function name
plAttachMsg* attMsg = new plAttachMsg(parentKey, child, plRefMsg::kOnRequest, nil); plAttachMsg* attMsg = new plAttachMsg(parentKey, child, plRefMsg::kOnRequest, nil);
plgDispatch::MsgSend(attMsg); plgDispatch::MsgSend(attMsg);
sprintf(str, "%s now child of %s", childName, parentName); sprintf(str, "%s now child of %s", childName.c_str(), parentName.c_str());
PrintString(str); PrintString(str);
} }
@ -5607,7 +5599,7 @@ PF_CONSOLE_CMD( SceneObject, Detach, // Group name, Function name
{ {
char str[256]; char str[256];
const char* childName = params[0]; plString childName = plString::FromUtf8(params[0]);
plKey childKey = FindSceneObjectByName(childName, nil, str); plKey childKey = FindSceneObjectByName(childName, nil, str);
if( !childKey ) if( !childKey )
@ -5632,13 +5624,13 @@ PF_CONSOLE_CMD( SceneObject, Detach, // Group name, Function name
plAttachMsg* attMsg = new plAttachMsg(parentKey, child, plRefMsg::kOnRemove, nil); plAttachMsg* attMsg = new plAttachMsg(parentKey, child, plRefMsg::kOnRemove, nil);
plgDispatch::MsgSend(attMsg); plgDispatch::MsgSend(attMsg);
sprintf(str, "%s detached from %s", childName, parentKey->GetName()); sprintf(str, "%s detached from %s", childName.c_str(), parentKey->GetName().c_str());
PrintString(str); PrintString(str);
return; return;
} }
else else
{ {
sprintf(str, "%s not attached to anything", childName); sprintf(str, "%s not attached to anything", childName.c_str());
PrintString(str); PrintString(str);
return; return;
} }
@ -6193,7 +6185,7 @@ PF_CONSOLE_CMD( Age, SetSDLBool, "string varName, bool value, int index", "Set t
PF_CONSOLE_GROUP( ParticleSystem ) // Defines a main command group PF_CONSOLE_GROUP( ParticleSystem ) // Defines a main command group
void UpdateParticleParam(char *objName, int32_t paramID, float value, void (*PrintString)(const char *)) void UpdateParticleParam(const plString &objName, int32_t paramID, float value, void (*PrintString)(const char *))
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(objName, nil, str); plKey key = FindSceneObjectByName(objName, nil, str);
@ -6222,7 +6214,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name
"string objName, float value", // Params "string objName, float value", // Params
"Set the particles-per-second generated" ) // Help string "Set the particles-per-second generated" ) // Help string
{ {
UpdateParticleParam(params[0], plParticleUpdateMsg::kParamParticlesPerSecond, params[1], PrintString); UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamParticlesPerSecond, params[1], PrintString);
} }
PF_CONSOLE_CMD( ParticleSystem, // Group name PF_CONSOLE_CMD( ParticleSystem, // Group name
@ -6230,7 +6222,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name
"string objName, float value", // Params "string objName, float value", // Params
"Set the initial range of pitch of generated particles" ) // Help string "Set the initial range of pitch of generated particles" ) // Help string
{ {
UpdateParticleParam(params[0], plParticleUpdateMsg::kParamInitPitchRange, params[1], PrintString); UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamInitPitchRange, params[1], PrintString);
} }
PF_CONSOLE_CMD( ParticleSystem, // Group name PF_CONSOLE_CMD( ParticleSystem, // Group name
@ -6238,7 +6230,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name
"string objName, float value", // Params "string objName, float value", // Params
"Set the initial range of yaw of generated particles" ) // Help string "Set the initial range of yaw of generated particles" ) // Help string
{ {
UpdateParticleParam(params[0], plParticleUpdateMsg::kParamInitYawRange, params[1], PrintString); UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamInitYawRange, params[1], PrintString);
} }
PF_CONSOLE_CMD( ParticleSystem, // Group name PF_CONSOLE_CMD( ParticleSystem, // Group name
@ -6246,7 +6238,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name
"string objName, float value", // Params "string objName, float value", // Params
"Set the minimum initial velocity of generated particles" ) // Help string "Set the minimum initial velocity of generated particles" ) // Help string
{ {
UpdateParticleParam(params[0], plParticleUpdateMsg::kParamVelMin, params[1], PrintString); UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamVelMin, params[1], PrintString);
} }
PF_CONSOLE_CMD( ParticleSystem, // Group name PF_CONSOLE_CMD( ParticleSystem, // Group name
@ -6254,7 +6246,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name
"string objName, float value", // Params "string objName, float value", // Params
"Set the maximum initial velocity of generated particles" ) // Help string "Set the maximum initial velocity of generated particles" ) // Help string
{ {
UpdateParticleParam(params[0], plParticleUpdateMsg::kParamVelMax, params[1], PrintString); UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamVelMax, params[1], PrintString);
} }
PF_CONSOLE_CMD( ParticleSystem, // Group name PF_CONSOLE_CMD( ParticleSystem, // Group name
@ -6262,7 +6254,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name
"string objName, float value", // Params "string objName, float value", // Params
"Set the width of generated particles" ) // Help string "Set the width of generated particles" ) // Help string
{ {
UpdateParticleParam(params[0], plParticleUpdateMsg::kParamXSize, params[1], PrintString); UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamXSize, params[1], PrintString);
} }
PF_CONSOLE_CMD( ParticleSystem, // Group name PF_CONSOLE_CMD( ParticleSystem, // Group name
@ -6270,7 +6262,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name
"string objName, float value", // Params "string objName, float value", // Params
"Set the height of generated particles" ) // Help string "Set the height of generated particles" ) // Help string
{ {
UpdateParticleParam(params[0], plParticleUpdateMsg::kParamYSize, params[1], PrintString); UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamYSize, params[1], PrintString);
} }
PF_CONSOLE_CMD( ParticleSystem, // Group name PF_CONSOLE_CMD( ParticleSystem, // Group name
@ -6278,7 +6270,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name
"string objName, float value", // Params "string objName, float value", // Params
"Set the minimum width/height scaling of generated particles" ) // Help string "Set the minimum width/height scaling of generated particles" ) // Help string
{ {
UpdateParticleParam(params[0], plParticleUpdateMsg::kParamScaleMin, params[1], PrintString); UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamScaleMin, params[1], PrintString);
} }
PF_CONSOLE_CMD( ParticleSystem, // Group name PF_CONSOLE_CMD( ParticleSystem, // Group name
@ -6286,7 +6278,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name
"string objName, float value", // Params "string objName, float value", // Params
"Set the maximum width/height scaling of generated particles" ) // Help string "Set the maximum width/height scaling of generated particles" ) // Help string
{ {
UpdateParticleParam(params[0], plParticleUpdateMsg::kParamScaleMax, params[1], PrintString); UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamScaleMax, params[1], PrintString);
} }
PF_CONSOLE_CMD( ParticleSystem, // Group name PF_CONSOLE_CMD( ParticleSystem, // Group name
@ -6294,7 +6286,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name
"string objName, float value", // Params "string objName, float value", // Params
"Set the remaining life of the particle generator" ) // Help string "Set the remaining life of the particle generator" ) // Help string
{ {
UpdateParticleParam(params[0], plParticleUpdateMsg::kParamGenLife, params[1], PrintString); UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamGenLife, params[1], PrintString);
} }
PF_CONSOLE_CMD( ParticleSystem, // Group name PF_CONSOLE_CMD( ParticleSystem, // Group name
@ -6302,7 +6294,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name
"string objName, float value", // Params "string objName, float value", // Params
"Set the minimum lifespan of generated particles (negative values make them immortal)" ) // Help string "Set the minimum lifespan of generated particles (negative values make them immortal)" ) // Help string
{ {
UpdateParticleParam(params[0], plParticleUpdateMsg::kParamPartLifeMin, params[1], PrintString); UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamPartLifeMin, params[1], PrintString);
} }
PF_CONSOLE_CMD( ParticleSystem, // Group name PF_CONSOLE_CMD( ParticleSystem, // Group name
@ -6310,7 +6302,7 @@ PF_CONSOLE_CMD( ParticleSystem, // Group name
"string objName, float value", // Params "string objName, float value", // Params
"Set the max lifespan of generated particles" ) // Help string "Set the max lifespan of generated particles" ) // Help string
{ {
UpdateParticleParam(params[0], plParticleUpdateMsg::kParamPartLifeMax, params[1], PrintString); UpdateParticleParam(plString::FromUtf8(params[0]), plParticleUpdateMsg::kParamPartLifeMax, params[1], PrintString);
} }
PF_CONSOLE_CMD( ParticleSystem, PF_CONSOLE_CMD( ParticleSystem,
@ -6319,7 +6311,7 @@ PF_CONSOLE_CMD( ParticleSystem,
"Creates a system (if necessary) on the avatar, and transfers particles" ) "Creates a system (if necessary) on the avatar, and transfers particles" )
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(params[0], nil, str); plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
if (key == nil) if (key == nil)
return; return;
@ -6338,7 +6330,7 @@ PF_CONSOLE_CMD( ParticleSystem,
"Flag some particles for death." ) "Flag some particles for death." )
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(params[0], nil, str); plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
if (key == nil) if (key == nil)
return; return;
@ -6357,7 +6349,7 @@ PF_CONSOLE_CMD( ParticleSystem,
PF_CONSOLE_SUBGROUP( ParticleSystem, Flock ) PF_CONSOLE_SUBGROUP( ParticleSystem, Flock )
static plParticleFlockEffect *FindFlock(char *objName) static plParticleFlockEffect *FindFlock(const plString &objName)
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(objName, nil, str); plKey key = FindSceneObjectByName(objName, nil, str);
@ -6385,7 +6377,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock,
"string objName, float x, float y, float z", "string objName, float x, float y, float z",
"Set the flock's goal to be an offset from its sceneObject") "Set the flock's goal to be an offset from its sceneObject")
{ {
plParticleEffect *flock = FindFlock(params[0]); plParticleEffect *flock = FindFlock(plString::FromUtf8(params[0]));
if (flock) if (flock)
{ {
(new plParticleFlockMsg(nil, flock->GetKey(), 0, plParticleFlockMsg::kFlockCmdSetOffset, params[1], params[2], params[3]))->Send(); (new plParticleFlockMsg(nil, flock->GetKey(), 0, plParticleFlockMsg::kFlockCmdSetOffset, params[1], params[2], params[3]))->Send();
@ -6397,7 +6389,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock,
"string objName, float x, float y, float z", "string objName, float x, float y, float z",
"Set the goal for particles that leave the flock") "Set the goal for particles that leave the flock")
{ {
plParticleEffect *flock = FindFlock(params[0]); plParticleEffect *flock = FindFlock(plString::FromUtf8(params[0]));
if (flock) if (flock)
{ {
(new plParticleFlockMsg(nil, flock->GetKey(), 0, plParticleFlockMsg::kFlockCmdSetDissentPoint, params[1], params[2], params[3]))->Send(); (new plParticleFlockMsg(nil, flock->GetKey(), 0, plParticleFlockMsg::kFlockCmdSetDissentPoint, params[1], params[2], params[3]))->Send();
@ -6409,7 +6401,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock,
"string objName, float value", "string objName, float value",
"") "")
{ {
plParticleFlockEffect *flock = FindFlock(params[0]); plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0]));
if (flock) if (flock)
flock->SetInfluenceAvgRadius(params[1]); flock->SetInfluenceAvgRadius(params[1]);
else else
@ -6421,7 +6413,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock,
"string objName, float value", "string objName, float value",
"") "")
{ {
plParticleFlockEffect *flock = FindFlock(params[0]); plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0]));
if (flock) if (flock)
flock->SetInfluenceRepelRadius(params[1]); flock->SetInfluenceRepelRadius(params[1]);
else else
@ -6433,7 +6425,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock,
"string objName, float value", "string objName, float value",
"") "")
{ {
plParticleFlockEffect *flock = FindFlock(params[0]); plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0]));
if (flock) if (flock)
flock->SetGoalRadius(params[1]); flock->SetGoalRadius(params[1]);
else else
@ -6445,7 +6437,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock,
"string objName, float value", "string objName, float value",
"") "")
{ {
plParticleFlockEffect *flock = FindFlock(params[0]); plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0]));
if (flock) if (flock)
flock->SetFullChaseRadius(params[1]); flock->SetFullChaseRadius(params[1]);
else else
@ -6457,7 +6449,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock,
"string objName, float value", "string objName, float value",
"") "")
{ {
plParticleFlockEffect *flock = FindFlock(params[0]); plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0]));
if (flock) if (flock)
flock->SetConformStr(params[1]); flock->SetConformStr(params[1]);
else else
@ -6469,7 +6461,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock,
"string objName, float value", "string objName, float value",
"") "")
{ {
plParticleFlockEffect *flock = FindFlock(params[0]); plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0]));
if (flock) if (flock)
flock->SetRepelStr(params[1]); flock->SetRepelStr(params[1]);
else else
@ -6481,7 +6473,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock,
"string objName, float value", "string objName, float value",
"") "")
{ {
plParticleFlockEffect *flock = FindFlock(params[0]); plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0]));
if (flock) if (flock)
flock->SetGoalOrbitStr(params[1]); flock->SetGoalOrbitStr(params[1]);
else else
@ -6493,7 +6485,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock,
"string objName, float value", "string objName, float value",
"") "")
{ {
plParticleFlockEffect *flock = FindFlock(params[0]); plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0]));
if (flock) if (flock)
flock->SetGoalChaseStr(params[1]); flock->SetGoalChaseStr(params[1]);
else else
@ -6505,7 +6497,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock,
"string objName, float value", "string objName, float value",
"") "")
{ {
plParticleFlockEffect *flock = FindFlock(params[0]); plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0]));
if (flock) if (flock)
flock->SetMaxOrbitSpeed(params[1]); flock->SetMaxOrbitSpeed(params[1]);
else else
@ -6517,7 +6509,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock,
"string objName, float value", "string objName, float value",
"") "")
{ {
plParticleFlockEffect *flock = FindFlock(params[0]); plParticleFlockEffect *flock = FindFlock(plString::FromUtf8(params[0]));
if (flock) if (flock)
flock->SetMaxChaseSpeed(params[1]); flock->SetMaxChaseSpeed(params[1]);
else else
@ -6535,7 +6527,7 @@ PF_CONSOLE_CMD( ParticleSystem_Flock,
PF_CONSOLE_GROUP( Animation ) // Defines a main command group PF_CONSOLE_GROUP( Animation ) // Defines a main command group
void SendAnimCmdMsg(char *objName, plMessage *msg) void SendAnimCmdMsg(const plString &objName, plMessage *msg)
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(objName, nil, str); plKey key = FindSceneObjectByName(objName, nil, str);
@ -6556,9 +6548,9 @@ PF_CONSOLE_CMD( Animation, // Group name
{ {
plAnimCmdMsg *msg = new plAnimCmdMsg(); plAnimCmdMsg *msg = new plAnimCmdMsg();
msg->SetCmd(plAnimCmdMsg::kContinue); msg->SetCmd(plAnimCmdMsg::kContinue);
msg->SetAnimName(nil); msg->SetAnimName(plString::Null);
msg->SetBCastFlag(plMessage::kPropagateToModifiers); msg->SetBCastFlag(plMessage::kPropagateToModifiers);
SendAnimCmdMsg(params[0], msg); SendAnimCmdMsg(plString::FromUtf8(params[0]), msg);
} }
PF_CONSOLE_CMD( Animation, // Group name PF_CONSOLE_CMD( Animation, // Group name
@ -6568,9 +6560,9 @@ PF_CONSOLE_CMD( Animation, // Group name
{ {
plAnimCmdMsg *msg = new plAnimCmdMsg(); plAnimCmdMsg *msg = new plAnimCmdMsg();
msg->SetCmd(plAnimCmdMsg::kStop); msg->SetCmd(plAnimCmdMsg::kStop);
msg->SetAnimName(nil); msg->SetAnimName(plString::Null);
msg->SetBCastFlag(plMessage::kPropagateToModifiers); msg->SetBCastFlag(plMessage::kPropagateToModifiers);
SendAnimCmdMsg(params[0], msg); SendAnimCmdMsg(plString::FromUtf8(params[0]), msg);
} }
PF_CONSOLE_CMD( Animation, // Group name PF_CONSOLE_CMD( Animation, // Group name
@ -6582,9 +6574,9 @@ PF_CONSOLE_CMD( Animation, // Group name
msg->SetCmd(plAGCmdMsg::kSetBlend); msg->SetCmd(plAGCmdMsg::kSetBlend);
msg->fBlend = params[2]; msg->fBlend = params[2];
msg->fBlendRate = params[3]; msg->fBlendRate = params[3];
msg->SetAnimName(params[1]); msg->SetAnimName(plString::FromUtf8(params[1]));
msg->SetBCastFlag(plMessage::kPropagateToModifiers); msg->SetBCastFlag(plMessage::kPropagateToModifiers);
SendAnimCmdMsg(params[0], msg); SendAnimCmdMsg(plString::FromUtf8(params[0]), msg);
} }
PF_CONSOLE_CMD( Animation, // Group name PF_CONSOLE_CMD( Animation, // Group name
@ -6596,9 +6588,9 @@ PF_CONSOLE_CMD( Animation, // Group name
msg->SetCmd(plAGCmdMsg::kSetAmp); msg->SetCmd(plAGCmdMsg::kSetAmp);
msg->fAmp = params[2]; msg->fAmp = params[2];
msg->fAmpRate = params[3]; msg->fAmpRate = params[3];
msg->SetAnimName(params[1]); msg->SetAnimName(plString::FromUtf8(params[1]));
msg->SetBCastFlag(plMessage::kPropagateToModifiers); msg->SetBCastFlag(plMessage::kPropagateToModifiers);
SendAnimCmdMsg(params[0], msg); SendAnimCmdMsg(plString::FromUtf8(params[0]), msg);
} }
PF_CONSOLE_CMD( Animation, // Group name PF_CONSOLE_CMD( Animation, // Group name
@ -6610,9 +6602,9 @@ PF_CONSOLE_CMD( Animation, // Group name
msg->SetCmd(plAnimCmdMsg::kSetSpeed); msg->SetCmd(plAnimCmdMsg::kSetSpeed);
msg->fSpeed = params[2]; msg->fSpeed = params[2];
msg->fSpeedChangeRate = params[3]; msg->fSpeedChangeRate = params[3];
msg->SetAnimName(params[1]); msg->SetAnimName(plString::FromUtf8(params[1]));
msg->SetBCastFlag(plMessage::kPropagateToModifiers); msg->SetBCastFlag(plMessage::kPropagateToModifiers);
SendAnimCmdMsg(params[0], msg); SendAnimCmdMsg(plString::FromUtf8(params[0]), msg);
} }
PF_CONSOLE_CMD( Animation, PF_CONSOLE_CMD( Animation,
@ -6622,7 +6614,7 @@ PF_CONSOLE_CMD( Animation,
{ {
plAnimDebugList *adl = plClient::GetInstance()->fAnimDebugList; plAnimDebugList *adl = plClient::GetInstance()->fAnimDebugList;
if (adl) if (adl)
adl->AddObjects(params[0]); adl->AddObjects(plString::FromUtf8(params[0]));
} }
PF_CONSOLE_CMD( Animation, PF_CONSOLE_CMD( Animation,
@ -6632,7 +6624,7 @@ PF_CONSOLE_CMD( Animation,
{ {
plAnimDebugList *adl = plClient::GetInstance()->fAnimDebugList; plAnimDebugList *adl = plClient::GetInstance()->fAnimDebugList;
if (adl) if (adl)
adl->RemoveObjects(params[0]); adl->RemoveObjects(plString::FromUtf8(params[0]));
} }
PF_CONSOLE_CMD( Animation, PF_CONSOLE_CMD( Animation,

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

@ -197,9 +197,9 @@ PF_CONSOLE_FILE_DUMMY(Net)
// utility functions // utility functions
// //
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
plKey FindSceneObjectByName(const char* name, const char* ageName, char* statusStr, bool subString=false); plKey FindSceneObjectByName(const plString& name, const char* ageName, char* statusStr, bool subString=false);
plKey FindObjectByName(const char* name, int type, const char* ageName, char* statusStr, bool subString=false); plKey FindObjectByName(const plString& name, int type, const char* ageName, char* statusStr, bool subString=false);
plKey FindObjectByNameAndType(const char* name, const char* typeName, const char* ageName, plKey FindObjectByNameAndType(const plString& name, const char* typeName, const char* ageName,
char* statusStr, bool subString=false); char* statusStr, bool subString=false);
void PrintStringF(void pfun(const char *),const char * fmt, ...); void PrintStringF(void pfun(const char *),const char * fmt, ...);
@ -230,13 +230,13 @@ PF_CONSOLE_CMD( Net, // groupName
"broadcast chat msg" ) // helpString "broadcast chat msg" ) // helpString
{ {
// send chat text // send chat text
std::string text=plNetClientMgr::GetInstance()->GetPlayerName(); plString text=plNetClientMgr::GetInstance()->GetPlayerName();
text += ":"; text += _TEMP_CONVERT_FROM_LITERAL(":");
int i; int i;
for(i=0;i<numParams;i++) for(i=0;i<numParams;i++)
{ {
text += (char*)params[i]; text += plString::FromUtf8( (char*)params[i] );
text += " "; text += _TEMP_CONVERT_FROM_LITERAL(" ");
} }
plConsoleMsg *cMsg = new plConsoleMsg( plConsoleMsg::kAddLine, text.c_str() ); plConsoleMsg *cMsg = new plConsoleMsg( plConsoleMsg::kAddLine, text.c_str() );
cMsg->SetBCastFlag(plMessage::kNetPropagate | plMessage::kNetForce); cMsg->SetBCastFlag(plMessage::kNetPropagate | plMessage::kNetForce);
@ -510,7 +510,7 @@ PF_CONSOLE_CMD( Net, // groupName
"Instructs the server to only send me updates about this object periodically" ) // helpString "Instructs the server to only send me updates about this object periodically" ) // helpString
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(params[0], nil, str); plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
PrintString(str); PrintString(str);
if (!key) if (!key)
return; return;
@ -1017,7 +1017,7 @@ PF_CONSOLE_CMD(
return; return;
} }
if (unsigned playerId = plNetClientMgr::GetInstance()->GetPlayerIdByName((const char *)params[1])) { if (unsigned playerId = plNetClientMgr::GetInstance()->GetPlayerIdByName(plString::FromUtf8((const char *)params[1]))) {
ttt->InvitePlayer(playerId); ttt->InvitePlayer(playerId);
PrintStringF(PrintString, "Sent invite to playerId %u", playerId); PrintStringF(PrintString, "Sent invite to playerId %u", playerId);
} }

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

@ -102,7 +102,7 @@ hsBool pfConsoleDirSrc::ParseDirectory(const std::wstring& path, const std::wst
error << errorMsg << L":\n\nCommand: '" << errorLine << L"'\n\nPress OK to continue parsing files."; error << errorMsg << L":\n\nCommand: '" << errorLine << L"'\n\nPress OK to continue parsing files.";
hsMessageBox(error.str().c_str(), caption.str().c_str(), hsMessageBoxNormal); hsMessageBox(error.str().c_str(), caption.str().c_str(), hsMessageBoxNormal);
delete [] errorMsg; delete [] errorMsg;
delete [] errorLine; delete [] errorLine;

8
Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp

@ -44,7 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "pnMessage/plMessage.h" #include "pnMessage/plMessage.h"
#include "pnKeyedObject/plKey.h" #include "pnKeyedObject/plKey.h"
#include "plString.h"
static bool DumpSpecificMsgInfo(plMessage* msg, std::string& info); static bool DumpSpecificMsgInfo(plMessage* msg, std::string& info);
@ -137,9 +137,9 @@ void plDispatchLog::DumpMsg(plMessage* msg, int numReceivers, int sendTimeMs, in
fLog->AddLineF("%sDispatched (%d) %d ms: time=%d CName=%s, sndr=%s, rcvr(%d)=%s, flags=0x%lx, tstamp=%f\n", fLog->AddLineF("%sDispatched (%d) %d ms: time=%d CName=%s, sndr=%s, rcvr(%d)=%s, flags=0x%lx, tstamp=%f\n",
indentStr, numReceivers, sendTimeMs, indentStr, numReceivers, sendTimeMs,
int(sendTime), msg->ClassName(), msg->fSender?msg->fSender->GetName():"nil", int(sendTime), msg->ClassName(), msg->fSender?msg->fSender->GetName().c_str():"nil",
msg->GetNumReceivers(), msg->GetNumReceivers() && msg->GetReceiver(0) msg->GetNumReceivers(), msg->GetNumReceivers() && msg->GetReceiver(0)
? msg->GetReceiver(0)->GetName():"nil", ? msg->GetReceiver(0)->GetName().c_str():"nil",
msg->fBCastFlags, msg->fTimeStamp); msg->fBCastFlags, msg->fTimeStamp);
lastTime=curTime; lastTime=curTime;
@ -319,7 +319,7 @@ static bool DumpSpecificMsgInfo(plMessage* msg, std::string& info)
GetType(kOnRequest); GetType(kOnRequest);
GetType(kOnRemove); GetType(kOnRemove);
GetType(kOnReplace); GetType(kOnReplace);
xtl::format(info, "Obj: %s RefType: %s", refMsg->GetRef()->GetKeyName(), typeName); xtl::format(info, "Obj: %s RefType: %s", refMsg->GetRef()->GetKeyName().c_str(), typeName);
return true; return true;
} }

2
Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp

@ -279,7 +279,7 @@ hsBool pfConsoleEngine::ExecuteFile( const wchar_t *fileName )
if( !RunCommand( string, DummyPrintFn ) ) if( !RunCommand( string, DummyPrintFn ) )
{ {
sprintf( string, "Error in console file %s, command line %d: %s", fileName, line, fErrorMsg ); sprintf( string, "Error in console file %S, command line %d: %s", fileName, line, fErrorMsg );
ISetErrorMsg( string ); ISetErrorMsg( string );
stream->Close(); stream->Close();
delete stream; delete stream;

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

@ -150,8 +150,6 @@ void pfGUIButtonMod::StartDragging( void )
pfGUIButtonMod::pfGUIButtonMod() pfGUIButtonMod::pfGUIButtonMod()
{ {
fAnimName = nil;
fMouseOverAnimName = nil;
fDraggable = nil; fDraggable = nil;
fOrigHandler = nil; fOrigHandler = nil;
@ -161,12 +159,6 @@ pfGUIButtonMod::pfGUIButtonMod()
SetFlag( kWantsInterest ); SetFlag( kWantsInterest );
} }
pfGUIButtonMod::~pfGUIButtonMod()
{
delete [] fAnimName;
delete [] fMouseOverAnimName;
}
//// IEval /////////////////////////////////////////////////////////////////// //// IEval ///////////////////////////////////////////////////////////////////
hsBool pfGUIButtonMod::IEval( double secs, float del, uint32_t dirty ) hsBool pfGUIButtonMod::IEval( double secs, float del, uint32_t dirty )
@ -204,13 +196,13 @@ void pfGUIButtonMod::Read( hsStream *s, hsResMgr *mgr )
uint32_t i, count = s->ReadLE32(); uint32_t i, count = s->ReadLE32();
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
fAnimationKeys.Append( mgr->ReadKey( s ) ); fAnimationKeys.Append( mgr->ReadKey( s ) );
fAnimName = s->ReadSafeString(); fAnimName = s->ReadSafeString_TEMP();
fMouseOverAnimKeys.Reset(); fMouseOverAnimKeys.Reset();
count = s->ReadLE32(); count = s->ReadLE32();
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
fMouseOverAnimKeys.Append( mgr->ReadKey( s ) ); fMouseOverAnimKeys.Append( mgr->ReadKey( s ) );
fMouseOverAnimName = s->ReadSafeString(); fMouseOverAnimName = s->ReadSafeString_TEMP();
fNotifyType = s->ReadLE32(); fNotifyType = s->ReadLE32();
mgr->ReadKeyNotifyMe( s, new plGenRefMsg( GetKey(), plRefMsg::kOnCreate, -1, kRefDraggable ), plRefFlags::kActiveRef ); mgr->ReadKeyNotifyMe( s, new plGenRefMsg( GetKey(), plRefMsg::kOnCreate, -1, kRefDraggable ), plRefFlags::kActiveRef );
@ -366,30 +358,16 @@ void pfGUIButtonMod::SetInteresting( hsBool i )
} }
void pfGUIButtonMod::SetAnimationKeys( hsTArray<plKey> &keys, const char *name ) void pfGUIButtonMod::SetAnimationKeys( hsTArray<plKey> &keys, const plString &name )
{ {
fAnimationKeys = keys; fAnimationKeys = keys;
delete [] fAnimName; fAnimName = name;
if( name != nil )
{
fAnimName = new char[ strlen( name ) + 1 ];
strcpy( fAnimName, name );
}
else
fAnimName = nil;
} }
void pfGUIButtonMod::SetMouseOverAnimKeys( hsTArray<plKey> &keys, const char *name ) void pfGUIButtonMod::SetMouseOverAnimKeys( hsTArray<plKey> &keys, const plString &name )
{ {
fMouseOverAnimKeys = keys; fMouseOverAnimKeys = keys;
delete [] fMouseOverAnimName; fMouseOverAnimName = name;
if( name != nil )
{
fMouseOverAnimName = new char[ strlen( name ) + 1 ];
strcpy( fMouseOverAnimName, name );
}
else
fMouseOverAnimName = nil;
} }

9
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIButtonMod.h

@ -60,10 +60,10 @@ class pfGUIButtonMod : public pfGUIControlMod
protected: protected:
hsTArray<plKey> fAnimationKeys; hsTArray<plKey> fAnimationKeys;
char *fAnimName; plString fAnimName;
hsTArray<plKey> fMouseOverAnimKeys; hsTArray<plKey> fMouseOverAnimKeys;
char *fMouseOverAnimName; plString fMouseOverAnimName;
hsBool fClicking; hsBool fClicking;
hsBool fTriggering; hsBool fTriggering;
@ -83,7 +83,6 @@ class pfGUIButtonMod : public pfGUIControlMod
public: public:
pfGUIButtonMod(); pfGUIButtonMod();
virtual ~pfGUIButtonMod();
CLASSNAME_REGISTER( pfGUIButtonMod ); CLASSNAME_REGISTER( pfGUIButtonMod );
GETINTERFACE_ANY( pfGUIButtonMod, pfGUIControlMod ); GETINTERFACE_ANY( pfGUIButtonMod, pfGUIControlMod );
@ -130,8 +129,8 @@ class pfGUIButtonMod : public pfGUIControlMod
void StopDragging( hsBool cancel ); void StopDragging( hsBool cancel );
// Export only // Export only
void SetAnimationKeys( hsTArray<plKey> &keys, const char *name ); void SetAnimationKeys( hsTArray<plKey> &keys, const plString &name );
void SetMouseOverAnimKeys( hsTArray<plKey> &keys, const char *name ); void SetMouseOverAnimKeys( hsTArray<plKey> &keys, const plString &name );
}; };
#endif // _pfGUIButtonMod_h #endif // _pfGUIButtonMod_h

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

@ -65,18 +65,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
pfGUICheckBoxCtrl::pfGUICheckBoxCtrl() pfGUICheckBoxCtrl::pfGUICheckBoxCtrl()
{ {
fAnimName = nil;
SetFlag( kWantsInterest ); SetFlag( kWantsInterest );
fChecked = false; fChecked = false;
fClicking = false; fClicking = false;
fPlaySound = true; fPlaySound = true;
} }
pfGUICheckBoxCtrl::~pfGUICheckBoxCtrl()
{
delete [] fAnimName;
}
//// IEval /////////////////////////////////////////////////////////////////// //// IEval ///////////////////////////////////////////////////////////////////
hsBool pfGUICheckBoxCtrl::IEval( double secs, float del, uint32_t dirty ) hsBool pfGUICheckBoxCtrl::IEval( double secs, float del, uint32_t dirty )
@ -102,7 +96,7 @@ void pfGUICheckBoxCtrl::Read( hsStream *s, hsResMgr *mgr )
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
fAnimationKeys.Append( mgr->ReadKey( s ) ); fAnimationKeys.Append( mgr->ReadKey( s ) );
fAnimName = s->ReadSafeString(); fAnimName = s->ReadSafeString_TEMP();
fChecked = s->ReadBool(); fChecked = s->ReadBool();
} }
@ -197,17 +191,10 @@ void pfGUICheckBoxCtrl::SetChecked( hsBool checked, hsBool immediate /*= fals
} }
} }
void pfGUICheckBoxCtrl::SetAnimationKeys( hsTArray<plKey> &keys, const char *name ) void pfGUICheckBoxCtrl::SetAnimationKeys( hsTArray<plKey> &keys, const plString &name )
{ {
fAnimationKeys = keys; fAnimationKeys = keys;
delete [] fAnimName; fAnimName = name;
if( name != nil )
{
fAnimName = new char[ strlen( name ) + 1 ];
strcpy( fAnimName, name );
}
else
fAnimName = nil;
} }
//// IGetDesiredCursor /////////////////////////////////////////////////////// //// IGetDesiredCursor ///////////////////////////////////////////////////////

7
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICheckBoxCtrl.h

@ -59,7 +59,7 @@ class pfGUICheckBoxCtrl : public pfGUIControlMod
protected: protected:
hsTArray<plKey> fAnimationKeys; hsTArray<plKey> fAnimationKeys;
char *fAnimName; plString fAnimName;
hsBool fClicking; hsBool fClicking;
hsBool fChecked; hsBool fChecked;
@ -72,7 +72,6 @@ class pfGUICheckBoxCtrl : public pfGUIControlMod
public: public:
pfGUICheckBoxCtrl(); pfGUICheckBoxCtrl();
virtual ~pfGUICheckBoxCtrl();
CLASSNAME_REGISTER( pfGUICheckBoxCtrl ); CLASSNAME_REGISTER( pfGUICheckBoxCtrl );
GETINTERFACE_ANY( pfGUICheckBoxCtrl, pfGUIControlMod ); GETINTERFACE_ANY( pfGUICheckBoxCtrl, pfGUIControlMod );
@ -94,7 +93,7 @@ class pfGUICheckBoxCtrl : public pfGUIControlMod
void DontPlaySounds() { fPlaySound = false; } // should the checkbox play sounds? void DontPlaySounds() { fPlaySound = false; } // should the checkbox play sounds?
const hsTArray<plKey> &GetAnimationKeys( void ) const { return fAnimationKeys; } const hsTArray<plKey> &GetAnimationKeys( void ) const { return fAnimationKeys; }
const char *GetAnimationName( void ) const { return fAnimName; } plString GetAnimationName( void ) const { return fAnimName; }
enum SoundEvents enum SoundEvents
{ {
@ -105,7 +104,7 @@ class pfGUICheckBoxCtrl : public pfGUIControlMod
}; };
// Export only // Export only
void SetAnimationKeys( hsTArray<plKey> &keys, const char *name ); void SetAnimationKeys( hsTArray<plKey> &keys, const plString &name );
}; };
#endif // _pfGUICheckBoxCtrl_h #endif // _pfGUICheckBoxCtrl_h

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

@ -587,11 +587,11 @@ hsBool pfGUIControlMod::MsgReceive( plMessage *msg )
if( rend ) if( rend )
{ {
plProfile_BeginLap(GUITime, this->GetKey()->GetUoid().GetObjectName()); plProfile_BeginLap(GUITime, this->GetKey()->GetUoid().GetObjectName().c_str());
// Only need it once // Only need it once
if( ISetUpDynTextMap( rend->Pipeline() ) ) if( ISetUpDynTextMap( rend->Pipeline() ) )
plgDispatch::Dispatch()->UnRegisterForExactType( plRenderMsg::Index(), GetKey() ); plgDispatch::Dispatch()->UnRegisterForExactType( plRenderMsg::Index(), GetKey() );
plProfile_EndLap(GUITime, this->GetKey()->GetUoid().GetObjectName()); plProfile_EndLap(GUITime, this->GetKey()->GetUoid().GetObjectName().c_str());
return true; return true;
} }

10
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICtrlGenerator.cpp

@ -122,22 +122,20 @@ pfGUICtrlGenerator &pfGUICtrlGenerator::Instance( void )
//// IGetNextKeyName ///////////////////////////////////////////////////////// //// IGetNextKeyName /////////////////////////////////////////////////////////
void pfGUICtrlGenerator::IGetNextKeyName( char *name, const char *prefix ) plString pfGUICtrlGenerator::IGetNextKeyName( const char *prefix )
{ {
static uint32_t keyCount = 0; static uint32_t keyCount = 0;
return plString::Format( "%s%d", prefix, keyCount++ );
sprintf( name, "%s%d", prefix, keyCount++ );
} }
//// IAddKey ///////////////////////////////////////////////////////////////// //// IAddKey /////////////////////////////////////////////////////////////////
plKey pfGUICtrlGenerator::IAddKey( hsKeyedObject *ko, const char *prefix ) plKey pfGUICtrlGenerator::IAddKey( hsKeyedObject *ko, const char *prefix )
{ {
char keyName[ 128 ]; plString keyName;
IGetNextKeyName( keyName, prefix ); keyName = IGetNextKeyName( prefix );
return hsgResMgr::ResMgr()->NewKey( keyName, ko, plLocation::kGlobalFixedLoc ); return hsgResMgr::ResMgr()->NewKey( keyName, ko, plLocation::kGlobalFixedLoc );
} }

2
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUICtrlGenerator.h

@ -85,7 +85,7 @@ class pfGUICtrlGenerator
plKey IAddKey( hsKeyedObject *ko, const char *prefix ); plKey IAddKey( hsKeyedObject *ko, const char *prefix );
void IGetNextKeyName( char *name, const char *prefix ); plString IGetNextKeyName( const char *prefix );
hsGMaterial *ICreateSolidMaterial( hsColorRGBA &color ); hsGMaterial *ICreateSolidMaterial( hsColorRGBA &color );

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

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

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

@ -69,7 +69,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//// Constructor/Destructor ////////////////////////////////////////////////// //// Constructor/Destructor //////////////////////////////////////////////////
pfGUIKnobCtrl::pfGUIKnobCtrl() : pfGUIKnobCtrl::pfGUIKnobCtrl() :
fAnimName(nil),
fDragStart(0.f, 0.f, 0.f), fDragStart(0.f, 0.f, 0.f),
fDragging(false), fDragging(false),
fAnimStartPos(0.f, 0.f, 0.f), fAnimStartPos(0.f, 0.f, 0.f),
@ -83,11 +82,6 @@ pfGUIKnobCtrl::pfGUIKnobCtrl() :
SetFlag( kWantsInterest ); SetFlag( kWantsInterest );
} }
pfGUIKnobCtrl::~pfGUIKnobCtrl()
{
delete [] fAnimName;
}
//// IEval /////////////////////////////////////////////////////////////////// //// IEval ///////////////////////////////////////////////////////////////////
hsBool pfGUIKnobCtrl::IEval( double secs, float del, uint32_t dirty ) hsBool pfGUIKnobCtrl::IEval( double secs, float del, uint32_t dirty )
@ -112,7 +106,7 @@ void pfGUIKnobCtrl::Read( hsStream *s, hsResMgr *mgr )
uint32_t i, count = s->ReadLE32(); uint32_t i, count = s->ReadLE32();
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
fAnimationKeys.Append( mgr->ReadKey( s ) ); fAnimationKeys.Append( mgr->ReadKey( s ) );
fAnimName = s->ReadSafeString(); fAnimName = s->ReadSafeString_TEMP();
fAnimTimesCalced = false; fAnimTimesCalced = false;
@ -262,17 +256,10 @@ void pfGUIKnobCtrl::HandleMouseDrag( hsPoint3 &mousePt, uint8_t modifiers )
//// SetAnimationKeys //////////////////////////////////////////////////////// //// SetAnimationKeys ////////////////////////////////////////////////////////
void pfGUIKnobCtrl::SetAnimationKeys( hsTArray<plKey> &keys, const char *name ) void pfGUIKnobCtrl::SetAnimationKeys( hsTArray<plKey> &keys, const plString &name )
{ {
fAnimationKeys = keys; fAnimationKeys = keys;
delete [] fAnimName; fAnimName = name;
if( name != nil )
{
fAnimName = new char[ strlen( name ) + 1 ];
strcpy( fAnimName, name );
}
else
fAnimName = nil;
} }
//// ICalcAnimTimes ////////////////////////////////////////////////////////// //// ICalcAnimTimes //////////////////////////////////////////////////////////

11
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIKnobCtrl.h

@ -58,17 +58,17 @@ class pfGUIKnobCtrl : public pfGUIValueCtrl
protected: protected:
hsTArray<plKey> fAnimationKeys; hsTArray<plKey> fAnimationKeys;
char *fAnimName; plString fAnimName;
hsPoint3 fDragStart; hsPoint3 fDragStart;
float fDragValue; float fDragValue;
hsBool fDragging; hsBool fDragging;
hsPoint3 fAnimStartPos, fAnimEndPos; // Calculated at export time for kMapToScreenRange hsPoint3 fAnimStartPos, fAnimEndPos; // Calculated at export time for kMapToScreenRange
float fDragRangeMin, fDragRangeMax; float fDragRangeMin, fDragRangeMax;
// Computed once, once an anim is loaded that we can compute this with // Computed once, once an anim is loaded that we can compute this with
float fAnimBegin, fAnimEnd; float fAnimBegin, fAnimEnd;
hsBool fAnimTimesCalced; hsBool fAnimTimesCalced;
virtual hsBool IEval( double secs, float del, uint32_t dirty ); // called only by owner object's Eval() virtual hsBool IEval( double secs, float del, uint32_t dirty ); // called only by owner object's Eval()
@ -80,7 +80,6 @@ class pfGUIKnobCtrl : public pfGUIValueCtrl
public: public:
pfGUIKnobCtrl(); pfGUIKnobCtrl();
virtual ~pfGUIKnobCtrl();
CLASSNAME_REGISTER( pfGUIKnobCtrl ); CLASSNAME_REGISTER( pfGUIKnobCtrl );
GETINTERFACE_ANY( pfGUIKnobCtrl, pfGUIValueCtrl ); GETINTERFACE_ANY( pfGUIKnobCtrl, pfGUIValueCtrl );
@ -109,7 +108,7 @@ class pfGUIKnobCtrl : public pfGUIValueCtrl
virtual void SetCurrValue( float v ); virtual void SetCurrValue( float v );
// Export only // Export only
void SetAnimationKeys( hsTArray<plKey> &keys, const char *name ); void SetAnimationKeys( hsTArray<plKey> &keys, const plString &name );
void SetScreenRange( const hsPoint3 &startPos, const hsPoint3 &endPos ) { fAnimStartPos = startPos; fAnimEndPos = endPos; } void SetScreenRange( const hsPoint3 &startPos, const hsPoint3 &endPos ) { fAnimStartPos = startPos; fAnimEndPos = endPos; }
}; };

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

@ -221,8 +221,7 @@ pfGUIListPicture::pfGUIListPicture( plKey mipKey, hsBool respectAlpha ) : pfGUIL
{ {
// Gotta make and grab an uncompressed one // Gotta make and grab an uncompressed one
plMipmap *uncompBuffer = hsCodecManager::Instance().CreateUncompressedMipmap( mip, hsCodecManager::k32BitDepth ); plMipmap *uncompBuffer = hsCodecManager::Instance().CreateUncompressedMipmap( mip, hsCodecManager::k32BitDepth );
char str[ 512 ]; plString str = plString::Format( "%s_uncomp", mip->GetKeyName().c_str() );
sprintf( str, "%s_uncomp", mip->GetKeyName() );
fMipmapKey = hsgResMgr::ResMgr()->NewKey( str, uncompBuffer, fMipmapKey->GetUoid().GetLocation() ); fMipmapKey = hsgResMgr::ResMgr()->NewKey( str, uncompBuffer, fMipmapKey->GetUoid().GetLocation() );
fMipmapKey->RefObject(); fMipmapKey->RefObject();
} }

3
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIPopUpMenu.cpp

@ -97,8 +97,7 @@ class pfPopUpKeyGenerator
plKey CreateKey( hsKeyedObject *ko ) plKey CreateKey( hsKeyedObject *ko )
{ {
char name[ 256 ]; plString name = plString::Format( "%s-%d", fPrefix, fKeyCount++ );
sprintf( name, "%s-%d", fPrefix, fKeyCount++ );
return hsgResMgr::ResMgr()->NewKey( name, ko, fLoc ); return hsgResMgr::ResMgr()->NewKey( name, ko, fLoc );
} }

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

@ -72,15 +72,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
pfGUIProgressCtrl::pfGUIProgressCtrl() : fStopSoundTimer(99) pfGUIProgressCtrl::pfGUIProgressCtrl() : fStopSoundTimer(99)
{ {
fAnimTimesCalced = false; fAnimTimesCalced = false;
fAnimName = nil;
fPlaySound = true; fPlaySound = true;
} }
pfGUIProgressCtrl::~pfGUIProgressCtrl()
{
delete [] fAnimName;
}
//// IEval /////////////////////////////////////////////////////////////////// //// IEval ///////////////////////////////////////////////////////////////////
hsBool pfGUIProgressCtrl::IEval( double secs, float del, uint32_t dirty ) hsBool pfGUIProgressCtrl::IEval( double secs, float del, uint32_t dirty )
@ -114,7 +108,7 @@ void pfGUIProgressCtrl::Read( hsStream *s, hsResMgr *mgr )
uint32_t i, count = s->ReadLE32(); uint32_t i, count = s->ReadLE32();
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
fAnimationKeys.Append( mgr->ReadKey( s ) ); fAnimationKeys.Append( mgr->ReadKey( s ) );
fAnimName = s->ReadSafeString(); fAnimName = s->ReadSafeString_TEMP();
fAnimTimesCalced = false; fAnimTimesCalced = false;
} }
@ -141,17 +135,10 @@ void pfGUIProgressCtrl::UpdateBounds( hsMatrix44 *invXformMatrix, hsBool forc
//// SetAnimationKeys //////////////////////////////////////////////////////// //// SetAnimationKeys ////////////////////////////////////////////////////////
void pfGUIProgressCtrl::SetAnimationKeys( hsTArray<plKey> &keys, const char *name ) void pfGUIProgressCtrl::SetAnimationKeys( hsTArray<plKey> &keys, const plString &name )
{ {
fAnimationKeys = keys; fAnimationKeys = keys;
delete [] fAnimName; fAnimName = name;
if( name != nil )
{
fAnimName = new char[ strlen( name ) + 1 ];
strcpy( fAnimName, name );
}
else
fAnimName = nil;
} }
//// ICalcAnimTimes ////////////////////////////////////////////////////////// //// ICalcAnimTimes //////////////////////////////////////////////////////////

9
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIProgressCtrl.h

@ -58,10 +58,10 @@ class pfGUIProgressCtrl : public pfGUIValueCtrl
protected: protected:
hsTArray<plKey> fAnimationKeys; hsTArray<plKey> fAnimationKeys;
char *fAnimName; plString fAnimName;
// Computed once, once an anim is loaded that we can compute this with // Computed once, once an anim is loaded that we can compute this with
float fAnimBegin, fAnimEnd; float fAnimBegin, fAnimEnd;
hsBool fAnimTimesCalced; hsBool fAnimTimesCalced;
hsBool fPlaySound; hsBool fPlaySound;
@ -69,12 +69,11 @@ class pfGUIProgressCtrl : public pfGUIValueCtrl
hsBool ICalcAnimTimes( void ); hsBool ICalcAnimTimes( void );
const uint32_t fStopSoundTimer; const uint32_t fStopSoundTimer;
public: public:
pfGUIProgressCtrl(); pfGUIProgressCtrl();
virtual ~pfGUIProgressCtrl();
CLASSNAME_REGISTER( pfGUIProgressCtrl ); CLASSNAME_REGISTER( pfGUIProgressCtrl );
GETINTERFACE_ANY( pfGUIProgressCtrl, pfGUIValueCtrl ); GETINTERFACE_ANY( pfGUIProgressCtrl, pfGUIValueCtrl );
@ -103,7 +102,7 @@ class pfGUIProgressCtrl : public pfGUIValueCtrl
void DontPlaySounds() { fPlaySound = false; } void DontPlaySounds() { fPlaySound = false; }
// Export only // Export only
void SetAnimationKeys( hsTArray<plKey> &keys, const char *name ); void SetAnimationKeys( hsTArray<plKey> &keys, const plString &name );
}; };
#endif // _pfGUIProgressCtrl_h #endif // _pfGUIProgressCtrl_h

89
Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp

@ -445,7 +445,7 @@ public:
//// Book data class ///////////////////////////////////////////////////////// //// Book data class /////////////////////////////////////////////////////////
pfBookData::pfBookData(const char *guiName /* = nil */) pfBookData::pfBookData(const plString &guiName /* = nil */)
{ {
fCurrBook = nil; fCurrBook = nil;
fDialog = nil; fDialog = nil;
@ -469,10 +469,10 @@ pfBookData::pfBookData(const char *guiName /* = nil */)
fEditable = false; fEditable = false;
fAdjustCursorTo = -1; fAdjustCursorTo = -1;
if (guiName) if (!guiName.IsEmpty())
fGUIName = guiName; fGUIName = guiName;
else else
fGUIName = "BkBook"; fGUIName = _TEMP_CONVERT_FROM_LITERAL("BkBook");
} }
pfBookData::~pfBookData() pfBookData::~pfBookData()
@ -867,7 +867,7 @@ void pfBookData::ITriggerPageFlip(hsBool flipBackwards, hsBool immediate)
// in MAX, we just use a GUI check box to grab them for us, even though we never // in MAX, we just use a GUI check box to grab them for us, even though we never
// actually use the functionality of the checkbox itself // actually use the functionality of the checkbox itself
const hsTArray<plKey> &keys = fTurnPageButton->GetAnimationKeys(); const hsTArray<plKey> &keys = fTurnPageButton->GetAnimationKeys();
const char *animName = fTurnPageButton->GetAnimationName(); plString animName = fTurnPageButton->GetAnimationName();
plAnimCmdMsg *msg = new plAnimCmdMsg(); plAnimCmdMsg *msg = new plAnimCmdMsg();
if (immediate) if (immediate)
@ -1136,18 +1136,18 @@ void pfBookData::EnableEditGUI(hsBool enable/* =true */)
//// Our Singleton Stuff ///////////////////////////////////////////////////// //// Our Singleton Stuff /////////////////////////////////////////////////////
//pfJournalBook *pfJournalBook::fInstance = nil; //pfJournalBook *pfJournalBook::fInstance = nil;
std::map<std::string,pfBookData*> pfJournalBook::fBookGUIs; std::map<plString,pfBookData*> pfJournalBook::fBookGUIs;
void pfJournalBook::SingletonInit( void ) void pfJournalBook::SingletonInit( void )
{ {
fBookGUIs["BkBook"] = new pfBookData(); // load the default book data object fBookGUIs[_TEMP_CONVERT_FROM_LITERAL("BkBook")] = new pfBookData(); // load the default book data object
hsgResMgr::ResMgr()->NewKey("BkBook",fBookGUIs["BkBook"],pfGameGUIMgr::GetInstance()->GetKey()->GetUoid().GetLocation()); hsgResMgr::ResMgr()->NewKey(_TEMP_CONVERT_FROM_LITERAL("BkBook"),fBookGUIs[_TEMP_CONVERT_FROM_LITERAL("BkBook")],pfGameGUIMgr::GetInstance()->GetKey()->GetUoid().GetLocation());
fBookGUIs["BkBook"]->LoadGUI(); fBookGUIs[_TEMP_CONVERT_FROM_LITERAL("BkBook")]->LoadGUI();
} }
void pfJournalBook::SingletonShutdown( void ) void pfJournalBook::SingletonShutdown( void )
{ {
std::map<std::string,pfBookData*>::iterator i = fBookGUIs.begin(); std::map<plString,pfBookData*>::iterator i = fBookGUIs.begin();
while (i != fBookGUIs.end()) while (i != fBookGUIs.end())
{ {
pfBookData *bookData = i->second; pfBookData *bookData = i->second;
@ -1158,7 +1158,7 @@ void pfJournalBook::SingletonShutdown( void )
fBookGUIs.clear(); fBookGUIs.clear();
} }
void pfJournalBook::LoadGUI( const char *guiName ) void pfJournalBook::LoadGUI( const plString &guiName )
{ {
if (fBookGUIs.find(guiName) == fBookGUIs.end()) // is it already loaded? if (fBookGUIs.find(guiName) == fBookGUIs.end()) // is it already loaded?
{ // nope, load it { // nope, load it
@ -1168,11 +1168,11 @@ void pfJournalBook::LoadGUI( const char *guiName )
} }
} }
void pfJournalBook::UnloadGUI( const char *guiName ) void pfJournalBook::UnloadGUI( const plString &guiName )
{ {
if (strcmp(guiName,"BkBook")==0) if (guiName.Compare("BkBook")==0)
return; // do not allow people to unload the default book gui return; // do not allow people to unload the default book gui
std::map<std::string,pfBookData*>::iterator loc = fBookGUIs.find(guiName); std::map<plString,pfBookData*>::iterator loc = fBookGUIs.find(guiName);
if (loc != fBookGUIs.end()) // make sure it's loaded if (loc != fBookGUIs.end()) // make sure it's loaded
{ {
fBookGUIs[guiName]->GetKey()->UnRefObject(); fBookGUIs[guiName]->GetKey()->UnRefObject();
@ -1183,17 +1183,17 @@ void pfJournalBook::UnloadGUI( const char *guiName )
void pfJournalBook::UnloadAllGUIs() void pfJournalBook::UnloadAllGUIs()
{ {
std::map<std::string,pfBookData*>::iterator i = fBookGUIs.begin(); std::map<plString,pfBookData*>::iterator i = fBookGUIs.begin();
std::vector<std::string> names; std::vector<plString> names;
while (i != fBookGUIs.end()) while (i != fBookGUIs.end())
{ {
std::string name = i->first; plString name = i->first;
names.push_back(name); // store a list of keys names.push_back(name); // store a list of keys
i++; i++;
} }
int idx; int idx;
for (idx = 0; idx < names.size(); idx++) for (idx = 0; idx < names.size(); idx++)
UnloadGUI(names[idx].c_str()); // UnloadGUI won't unload BkBook UnloadGUI(names[idx]); // UnloadGUI won't unload BkBook
} }
//// Constructor ///////////////////////////////////////////////////////////// //// Constructor /////////////////////////////////////////////////////////////
@ -1202,16 +1202,16 @@ void pfJournalBook::UnloadAllGUIs()
// key is the keyed object to send event messages to (see <img> tag). // key is the keyed object to send event messages to (see <img> tag).
pfJournalBook::pfJournalBook( const char *esHTMLSource, plKey coverImageKey, plKey callbackKey /*= nil*/, pfJournalBook::pfJournalBook( const char *esHTMLSource, plKey coverImageKey, plKey callbackKey /*= nil*/,
const plLocation &hintLoc /* = plLocation::kGlobalFixedLoc */, const char *guiName /* = nil */ ) const plLocation &hintLoc /* = plLocation::kGlobalFixedLoc */, const plString &guiName /* = nil */ )
{ {
if (guiName && (strcmp(guiName,"") != 0)) if (!guiName.IsEmpty())
fCurBookGUI = guiName; fCurBookGUI = guiName;
else else
fCurBookGUI = "BkBook"; fCurBookGUI = _TEMP_CONVERT_FROM_LITERAL("BkBook");
if (fBookGUIs.find(fCurBookGUI) == fBookGUIs.end()) if (fBookGUIs.find(fCurBookGUI) == fBookGUIs.end())
{ {
fBookGUIs[fCurBookGUI] = new pfBookData(fCurBookGUI.c_str()); fBookGUIs[fCurBookGUI] = new pfBookData(fCurBookGUI);
hsgResMgr::ResMgr()->NewKey(fCurBookGUI.c_str(),fBookGUIs[fCurBookGUI],pfGameGUIMgr::GetInstance()->GetKey()->GetUoid().GetLocation()); hsgResMgr::ResMgr()->NewKey(fCurBookGUI,fBookGUIs[fCurBookGUI],pfGameGUIMgr::GetInstance()->GetKey()->GetUoid().GetLocation());
fBookGUIs[fCurBookGUI]->LoadGUI(); fBookGUIs[fCurBookGUI]->LoadGUI();
} }
@ -1238,16 +1238,16 @@ pfJournalBook::pfJournalBook( const char *esHTMLSource, plKey coverImageKey, plK
} }
pfJournalBook::pfJournalBook( const wchar_t *esHTMLSource, plKey coverImageKey, plKey callbackKey /*= nil*/, pfJournalBook::pfJournalBook( const wchar_t *esHTMLSource, plKey coverImageKey, plKey callbackKey /*= nil*/,
const plLocation &hintLoc /* = plLocation::kGlobalFixedLoc */, const char *guiName /* = nil */ ) const plLocation &hintLoc /* = plLocation::kGlobalFixedLoc */, const plString &guiName /* = nil */ )
{ {
if (guiName && (strcmp(guiName,"") != 0)) if (!guiName.IsEmpty())
fCurBookGUI = guiName; fCurBookGUI = guiName;
else else
fCurBookGUI = "BkBook"; fCurBookGUI = _TEMP_CONVERT_FROM_LITERAL("BkBook");
if (fBookGUIs.find(fCurBookGUI) == fBookGUIs.end()) if (fBookGUIs.find(fCurBookGUI) == fBookGUIs.end())
{ {
fBookGUIs[fCurBookGUI] = new pfBookData(fCurBookGUI.c_str()); fBookGUIs[fCurBookGUI] = new pfBookData(fCurBookGUI);
hsgResMgr::ResMgr()->NewKey(fCurBookGUI.c_str(),fBookGUIs[fCurBookGUI],pfGameGUIMgr::GetInstance()->GetKey()->GetUoid().GetLocation()); hsgResMgr::ResMgr()->NewKey(fCurBookGUI,fBookGUIs[fCurBookGUI],pfGameGUIMgr::GetInstance()->GetKey()->GetUoid().GetLocation());
fBookGUIs[fCurBookGUI]->LoadGUI(); fBookGUIs[fCurBookGUI]->LoadGUI();
} }
@ -1287,12 +1287,12 @@ hsBool pfJournalBook::MsgReceive( plMessage *pMsg )
return hsKeyedObject::MsgReceive( pMsg ); return hsKeyedObject::MsgReceive( pMsg );
} }
void pfJournalBook::SetGUI( const char *guiName ) void pfJournalBook::SetGUI( const plString &guiName )
{ {
if (guiName && (strcmp(guiName,"") != 0)) if (!guiName.IsEmpty())
fCurBookGUI = guiName; fCurBookGUI = guiName;
if (fBookGUIs.find(fCurBookGUI) == fBookGUIs.end()) if (fBookGUIs.find(fCurBookGUI) == fBookGUIs.end())
fCurBookGUI = "BkBook"; // requested GUI isn't loaded, so use default GUI fCurBookGUI = _TEMP_CONVERT_FROM_LITERAL("BkBook"); // requested GUI isn't loaded, so use default GUI
SetEditable(fWantEditing); // make sure that if we want editing, to set it SetEditable(fWantEditing); // make sure that if we want editing, to set it
ICompileSource(fUncompiledSource.c_str(), fDefLoc); // recompile the source to be safe ICompileSource(fUncompiledSource.c_str(), fDefLoc); // recompile the source to be safe
} }
@ -1474,7 +1474,7 @@ void pfJournalBook::ITriggerCloseWithNotify( hsBool closeNotOpen, hsBool imme
fBookGUIs[fCurBookGUI]->CurrentlyOpen(!closeNotOpen); fBookGUIs[fCurBookGUI]->CurrentlyOpen(!closeNotOpen);
const hsTArray<plKey> &keys = fBookGUIs[fCurBookGUI]->CoverButton()->GetAnimationKeys(); const hsTArray<plKey> &keys = fBookGUIs[fCurBookGUI]->CoverButton()->GetAnimationKeys();
const char *animName = fBookGUIs[fCurBookGUI]->CoverButton()->GetAnimationName(); plString animName = fBookGUIs[fCurBookGUI]->CoverButton()->GetAnimationName();
plAnimCmdMsg *msg = new plAnimCmdMsg(); plAnimCmdMsg *msg = new plAnimCmdMsg();
if( !immediate ) if( !immediate )
@ -2498,20 +2498,19 @@ void pfJournalBook::IFreeSource( void )
plKey pfJournalBook::IGetMipmapKey( const wchar_t *name, const plLocation &loc ) plKey pfJournalBook::IGetMipmapKey( const wchar_t *name, const plLocation &loc )
{ {
char *cName = hsWStringToString(name); plString cName = plString::FromWchar(name);
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
if( strchr( cName, '/' ) != nil || strchr( cName, '\\' ) != nil ) if( cName.Find( '/' ) >= 0 || cName.Find( '\\' ) >= 0 )
{ {
// For internal use only--allow local path names of PNG and JPEG images, to // For internal use only--allow local path names of PNG and JPEG images, to
// facilitate fast prototyping // facilitate fast prototyping
plMipmap *mip; plMipmap *mip;
if( strstr( cName, ".png" ) != nil ) if( cName.Find( ".png" ) >= 0 )
mip = plPNG::Instance().ReadFromFile( cName ); mip = plPNG::Instance().ReadFromFile( _TEMP_CONVERT_TO_CONST_CHAR( cName ) );
else else
mip = plJPEG::Instance().ReadFromFile( cName ); mip = plJPEG::Instance().ReadFromFile( _TEMP_CONVERT_TO_CONST_CHAR( cName ) );
hsgResMgr::ResMgr()->NewKey( cName, mip, loc ); hsgResMgr::ResMgr()->NewKey( cName, mip, loc );
delete [] cName;
return mip->GetKey(); return mip->GetKey();
} }
#endif #endif
@ -2521,7 +2520,6 @@ plKey pfJournalBook::IGetMipmapKey( const wchar_t *name, const plLocation &loc
plKey key = hsgResMgr::ResMgr()->FindKey( myUoid ); plKey key = hsgResMgr::ResMgr()->FindKey( myUoid );
if( key != nil ) if( key != nil )
{ {
delete [] cName;
return key; return key;
} }
@ -2532,7 +2530,6 @@ plKey pfJournalBook::IGetMipmapKey( const wchar_t *name, const plLocation &loc
key = hsgResMgr::ResMgr()->FindKey( myUoid ); key = hsgResMgr::ResMgr()->FindKey( myUoid );
if( key != nil ) if( key != nil )
{ {
delete [] cName;
return key; return key;
} }
@ -2545,13 +2542,11 @@ plKey pfJournalBook::IGetMipmapKey( const wchar_t *name, const plLocation &loc
key = plKeyFinder::Instance().StupidSearch( thisAge, nil, plMipmap::Index(), cName, true ); key = plKeyFinder::Instance().StupidSearch( thisAge, nil, plMipmap::Index(), cName, true );
if( key != nil ) if( key != nil )
{ {
delete [] cName;
return key; return key;
} }
} }
} }
delete [] cName;
return nil; return nil;
} }
@ -3040,13 +3035,13 @@ plLayerBink *pfJournalBook::IMakeMovieLayer(pfEsHTMLChunk *chunk, uint16_t x, ui
// We'll need a unique name. This is a hack, but an effective hack. // We'll need a unique name. This is a hack, but an effective hack.
static int uniqueSuffix = 0; static int uniqueSuffix = 0;
char buff[256]; plString buff;
sprintf(buff, "%s_%d_ml", GetKey()->GetName(), uniqueSuffix); buff = plString::Format("%s_%d_ml", GetKey()->GetName().c_str(), uniqueSuffix);
layer = new plLayer; layer = new plLayer;
hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation()); hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation());
sprintf(buff, "%s_%d_m", GetKey()->GetName(), uniqueSuffix++); buff = plString::Format("%s_%d_m", GetKey()->GetName().c_str(), uniqueSuffix++);
movieLayer = new plLayerBink; movieLayer = new plLayerBink;
hsgResMgr::ResMgr()->NewKey(buff, movieLayer, GetKey()->GetUoid().GetLocation()); hsgResMgr::ResMgr()->NewKey(buff, movieLayer, GetKey()->GetUoid().GetLocation());
movieLayer->GetKey()->RefObject(); // we want to own a ref so we can nuke it at will movieLayer->GetKey()->RefObject(); // we want to own a ref so we can nuke it at will
@ -3189,8 +3184,7 @@ plLayerInterface *pfJournalBook::IMakeBaseLayer(plMipmap *image)
// We'll need a unique name. This is a hack, but an effective hack. // We'll need a unique name. This is a hack, but an effective hack.
static int uniqueSuffix = 0; static int uniqueSuffix = 0;
char buff[256]; plString buff = plString::Format("%s_%d", GetKey()->GetName().c_str(), uniqueSuffix++);
sprintf(buff, "%s_%d", GetKey()->GetName(), uniqueSuffix++);
plLayer* layer = new plLayer; plLayer* layer = new plLayer;
hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation()); hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation());
@ -3244,8 +3238,7 @@ plLayerInterface *pfJournalBook::IMakeDecalLayer(pfEsHTMLChunk *decalChunk, plMi
// We'll need a unique name. This is a hack, but an effective hack. // We'll need a unique name. This is a hack, but an effective hack.
static int uniqueSuffix = 0; static int uniqueSuffix = 0;
char buff[256]; plString buff = plString::Format("%s_%d_d", GetKey()->GetName().c_str(), uniqueSuffix++);
sprintf(buff, "%s_%d_d", GetKey()->GetName(), uniqueSuffix++);
plLayer* layer = new plLayer; plLayer* layer = new plLayer;
hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation()); hsgResMgr::ResMgr()->NewKey(buff, layer, GetKey()->GetUoid().GetLocation());

18
Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.h

@ -211,7 +211,7 @@ public:
kTurnBackPage kTurnBackPage
}; };
pfBookData(const char *guiName = nil); pfBookData(const plString &guiName = plString::Null);
virtual ~pfBookData(); virtual ~pfBookData();
void LoadGUI(); // need this seperate because the plKey isn't setup until the constructor is done void LoadGUI(); // need this seperate because the plKey isn't setup until the constructor is done
@ -284,7 +284,7 @@ protected:
kRefDefaultCover kRefDefaultCover
}; };
std::string fGUIName; plString fGUIName;
// The pointer to our dialog // The pointer to our dialog
pfGUIDialogMod *fDialog; pfGUIDialogMod *fDialog;
@ -362,8 +362,8 @@ class pfJournalBook : public hsKeyedObject
// The constructor takes in the esHTML source for the journal, along with // The constructor takes in the esHTML source for the journal, along with
// the name of the mipmap to use as the cover of the book. The callback // the name of the mipmap to use as the cover of the book. The callback
// key is the keyed object to send event messages to (see <img> tag). // key is the keyed object to send event messages to (see <img> tag).
pfJournalBook( const char *esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, const plLocation &hintLoc = plLocation::kGlobalFixedLoc, const char *guiName = nil ); pfJournalBook( const char *esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, const plLocation &hintLoc = plLocation::kGlobalFixedLoc, const plString &guiName = plString::Null );
pfJournalBook( const wchar_t *esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, const plLocation &hintLoc = plLocation::kGlobalFixedLoc, const char *guiName = nil ); pfJournalBook( const wchar_t *esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, const plLocation &hintLoc = plLocation::kGlobalFixedLoc, const plString &guiName = plString::Null );
virtual ~pfJournalBook(); virtual ~pfJournalBook();
@ -380,15 +380,15 @@ class pfJournalBook : public hsKeyedObject
static void SingletonShutdown( void ); static void SingletonShutdown( void );
// loads a gui // loads a gui
static void LoadGUI( const char *guiName ); static void LoadGUI( const plString &guiName );
// unloads a gui if we don't need it any more and want to free up memory // unloads a gui if we don't need it any more and want to free up memory
static void UnloadGUI( const char *guiName ); static void UnloadGUI( const plString &guiName );
// unloads all GUIs except for the default // unloads all GUIs except for the default
static void UnloadAllGUIs(); static void UnloadAllGUIs();
void SetGUI( const char *guiName ); void SetGUI( const plString &guiName );
// Shows the book, optionally starting open or closed // Shows the book, optionally starting open or closed
void Show( hsBool startOpened = false ); void Show( hsBool startOpened = false );
@ -505,8 +505,8 @@ class pfJournalBook : public hsKeyedObject
// Current list of linkable image chunks we have visible on the screen, for quick hit testing // Current list of linkable image chunks we have visible on the screen, for quick hit testing
hsTArray<pfEsHTMLChunk *> fVisibleLinks; hsTArray<pfEsHTMLChunk *> fVisibleLinks;
static std::map<std::string,pfBookData*> fBookGUIs; static std::map<plString,pfBookData*> fBookGUIs;
std::string fCurBookGUI; plString fCurBookGUI;
enum Refs enum Refs
{ {

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

@ -175,7 +175,7 @@ plKey cyAvatar::IFindArmatureModKey(plKey avKey)
// PURPOSE : oneShot Avatar (must already be there) // PURPOSE : oneShot Avatar (must already be there)
// //
void cyAvatar::OneShot(pyKey &seekKey, float duration, hsBool usePhysics, void cyAvatar::OneShot(pyKey &seekKey, float duration, hsBool usePhysics,
const char *animName, hsBool drivable, hsBool reversible) const plString &animName, hsBool drivable, hsBool reversible)
{ {
if ( fRecvr.Count() > 0 ) if ( fRecvr.Count() > 0 )
{ {
@ -186,7 +186,7 @@ void cyAvatar::OneShot(pyKey &seekKey, float duration, hsBool usePhysics,
seekKey.getKey(), // Mark D told me to do it ...paulg seekKey.getKey(), // Mark D told me to do it ...paulg
duration, duration,
usePhysics, usePhysics,
animName, // Constructor will do a copy. -mf- hsStrcpy(animName), animName,
drivable, drivable,
reversible); reversible);
@ -1274,7 +1274,7 @@ PyObject* cyAvatar::GetTintClothingItemL(const char* clothing_name, uint8_t laye
} }
char errmsg[256]; char errmsg[256];
sprintf(errmsg,"Cannot find clothing item %d to find out what tint it is",clothing_name); sprintf(errmsg,"Cannot find clothing item %s to find out what tint it is",clothing_name);
PyErr_SetString(PyExc_KeyError, errmsg); PyErr_SetString(PyExc_KeyError, errmsg);
// returning nil means an error occurred // returning nil means an error occurred
return nil; return nil;
@ -1587,7 +1587,7 @@ void cyAvatar::ExitSubWorld()
// //
// PURPOSE : Place the Avatar into the subworld of the sceneobject specified // PURPOSE : Place the Avatar into the subworld of the sceneobject specified
// //
void cyAvatar::PlaySimpleAnimation(const char* animName) void cyAvatar::PlaySimpleAnimation(const plString& animName)
{ {
// make sure that there is atleast one avatar scene object attached (should be) // make sure that there is atleast one avatar scene object attached (should be)
if ( fRecvr.Count() > 0) if ( fRecvr.Count() > 0)

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

@ -103,7 +103,7 @@ public:
// oneShot Avatar (must already be there) // oneShot Avatar (must already be there)
virtual void OneShot(pyKey &seekKey, float duration, hsBool usePhysics, virtual void OneShot(pyKey &seekKey, float duration, hsBool usePhysics,
const char *animName, hsBool drivable, hsBool reversible); const plString &animName, hsBool drivable, hsBool reversible);
// oneShot Avatar // oneShot Avatar
virtual void RunBehavior(pyKey &behKey, hsBool netForce, hsBool netProp); virtual void RunBehavior(pyKey &behKey, hsBool netForce, hsBool netProp);
@ -412,7 +412,7 @@ public:
// //
virtual void ExitSubWorld(); virtual void ExitSubWorld();
virtual void PlaySimpleAnimation(const char* animName); virtual void PlaySimpleAnimation(const plString& animName);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //

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

@ -89,8 +89,7 @@ PYTHON_METHOD_DEFINITION(ptAvatar, oneShot, args)
} }
pyKey* key = pyKey::ConvertFrom(keyObj); pyKey* key = pyKey::ConvertFrom(keyObj);
std::string animNameStr = animName; // convert to string (for safety) self->fThis->OneShot(*key, duration, usePhysics != 0, plString::FromUtf8(animName), drivable != 0, reversable != 0);
self->fThis->OneShot(*key, duration, usePhysics != 0, animNameStr.c_str(), drivable != 0, reversable != 0);
PYTHON_RETURN_NONE; PYTHON_RETURN_NONE;
} }
@ -592,8 +591,7 @@ PYTHON_METHOD_DEFINITION(ptAvatar, playSimpleAnimation, args)
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
std::string animNameStr = animName; // convert to a string (for safety) self->fThis->PlaySimpleAnimation(plString::FromUtf8(animName));
self->fThis->PlaySimpleAnimation(animNameStr.c_str());
PYTHON_RETURN_NONE; PYTHON_RETURN_NONE;
} }

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

@ -194,12 +194,12 @@ void cyMisc::ConsoleNet(const char* command, hsBool netForce)
// PURPOSE : Execute a console command from a python script, // PURPOSE : Execute a console command from a python script,
// optionally propagate over the net // optionally propagate over the net
// //
PyObject* cyMisc::FindSceneObject(const char* name, const char* ageName) PyObject* cyMisc::FindSceneObject(const plString& name, const char* ageName)
{ {
// assume that we won't find the sceneobject (key is equal to nil) // assume that we won't find the sceneobject (key is equal to nil)
plKey key=nil; plKey key=nil;
if ( name || name[0] != 0) if ( !name.IsEmpty() )
{ {
const char* theAge = ageName; const char* theAge = ageName;
if ( ageName[0] == 0 ) if ( ageName[0] == 0 )
@ -209,18 +209,17 @@ PyObject* cyMisc::FindSceneObject(const char* name, const char* ageName)
if ( key == nil ) if ( key == nil )
{ {
char errmsg[256]; plString errmsg = plString::Format("Sceneobject %s not found",name.c_str());
sprintf(errmsg,"Sceneobject %s not found",name); PyErr_SetString(PyExc_NameError, errmsg.c_str());
PyErr_SetString(PyExc_NameError, errmsg);
return nil; // return nil cause we errored return nil; // return nil cause we errored
} }
return pySceneObject::New(key); return pySceneObject::New(key);
} }
PyObject* cyMisc::FindActivator(const char* name) PyObject* cyMisc::FindActivator(const plString& name)
{ {
plKey key = nil; plKey key = nil;
if (name && strlen(name) > 0) if (!name.IsEmpty())
{ {
std::vector<plKey> keylist; std::vector<plKey> keylist;
plKeyFinder::Instance().ReallyStupidActivatorSearch(name, keylist); plKeyFinder::Instance().ReallyStupidActivatorSearch(name, keylist);
@ -453,10 +452,9 @@ hsBool cyMisc::WasLocallyNotified(pyKey &selfkey)
// PURPOSE : Return the net client (account) name of the player whose avatar // PURPOSE : Return the net client (account) name of the player whose avatar
// key is provided. // key is provided.
// //
const char* cyMisc::GetClientName(pyKey &avKey) plString cyMisc::GetClientName(pyKey &avKey)
{ {
const char* ret=plNetClientMgr::GetInstance()->GetPlayerName(avKey.getKey()); return plNetClientMgr::GetInstance()->GetPlayerName(avKey.getKey());
return (ret==nil) ? "" : ret;
} }
PyObject* cyMisc::GetAvatarKeyFromClientID(int clientID) PyObject* cyMisc::GetAvatarKeyFromClientID(int clientID)
@ -547,7 +545,7 @@ hsBool cyMisc::ValidateKey(pyKey& key)
// //
// PURPOSE : Return the local net client (account) name // PURPOSE : Return the local net client (account) name
// //
const char* cyMisc::GetLocalClientName() plString cyMisc::GetLocalClientName()
{ {
return plNetClientMgr::GetInstance()->GetPlayerName(); return plNetClientMgr::GetInstance()->GetPlayerName();
} }
@ -946,7 +944,7 @@ PyObject* cyMisc::GetLocalAvatar()
PyObject* cyMisc::GetLocalPlayer() PyObject* cyMisc::GetLocalPlayer()
{ {
return pyPlayer::New(plNetClientMgr::GetInstance()->GetLocalPlayerKey(), return pyPlayer::New(plNetClientMgr::GetInstance()->GetLocalPlayerKey(),
plNetClientMgr::GetInstance()->GetPlayerName(), plNetClientMgr::GetInstance()->GetPlayerName().c_str(),
plNetClientMgr::GetInstance()->GetPlayerID(), plNetClientMgr::GetInstance()->GetPlayerID(),
0.0 ); 0.0 );
} }
@ -1003,7 +1001,7 @@ std::vector<PyObject*> cyMisc::GetPlayerList()
// only non-ignored people in list and not in ignore list // only non-ignored people in list and not in ignore list
if ( !VaultAmIgnoringPlayer ( mbr->GetPlayerID()) ) if ( !VaultAmIgnoringPlayer ( mbr->GetPlayerID()) )
{ {
PyObject* playerObj = pyPlayer::New(avkey, mbr->GetPlayerName(), mbr->GetPlayerID(), mbr->GetDistSq()); PyObject* playerObj = pyPlayer::New(avkey, mbr->GetPlayerName().c_str(), mbr->GetPlayerID(), mbr->GetDistSq());
pyPlayer* player = pyPlayer::ConvertFrom(playerObj); // accesses internal pyPlayer object pyPlayer* player = pyPlayer::ConvertFrom(playerObj); // accesses internal pyPlayer object
// modifies playerObj // modifies playerObj
@ -1038,7 +1036,7 @@ std::vector<PyObject*> cyMisc::GetPlayerListDistanceSorted()
// only non-ignored people in list and not in ignore list // only non-ignored people in list and not in ignore list
if ( !VaultAmIgnoringPlayer ( mbr->GetPlayerID()) ) if ( !VaultAmIgnoringPlayer ( mbr->GetPlayerID()) )
{ {
PyObject* playerObj = pyPlayer::New(avkey, mbr->GetPlayerName(), mbr->GetPlayerID(), mbr->GetDistSq()); PyObject* playerObj = pyPlayer::New(avkey, mbr->GetPlayerName().c_str(), mbr->GetPlayerID(), mbr->GetDistSq());
pyPlayer* player = pyPlayer::ConvertFrom(playerObj); // accesses internal pyPlayer object pyPlayer* player = pyPlayer::ConvertFrom(playerObj); // accesses internal pyPlayer object
// modifies playerObj // modifies playerObj
@ -1916,7 +1914,7 @@ int cyMisc::GetNumParticles(pyKey& host)
} }
void cyMisc::SetLightColorValue(pyKey& light, std::string lightName, float r, float g, float b, float a) void cyMisc::SetLightColorValue(pyKey& light, const plString& lightName, float r, float g, float b, float a)
{ {
// lightName is the name of the light object attached to the light that we want to talk to // lightName is the name of the light object attached to the light that we want to talk to
// for the bug lights, this would be "RTOmni-BugLightTest" // for the bug lights, this would be "RTOmni-BugLightTest"
@ -1964,7 +1962,7 @@ void cyMisc::SetLightColorValue(pyKey& light, std::string lightName, float r, fl
} }
#include "pnMessage/plEnableMsg.h" #include "pnMessage/plEnableMsg.h"
void cyMisc::SetLightAnimationOn(pyKey& light, std::string lightName, hsBool start) void cyMisc::SetLightAnimationOn(pyKey& light, const plString& lightName, hsBool start)
{ {
// lightName is the name of the light object attached to the light that we want to talk to // lightName is the name of the light object attached to the light that we want to talk to
// for the bug lights, this would be "RTOmni-BugLightTest" // for the bug lights, this would be "RTOmni-BugLightTest"
@ -2364,7 +2362,7 @@ public:
if ( guid ) if ( guid )
{ {
PyObject* retVal = PyObject_CallMethod(fPyObject, "publicAgeRemoved", "s", guid->AsString()); PyObject* retVal = PyObject_CallMethod(fPyObject, "publicAgeRemoved", "s", guid->AsString().c_str());
Py_XDECREF(retVal); Py_XDECREF(retVal);
} }
} }
@ -2455,28 +2453,25 @@ const char* cyMisc::GetCameraNumber(int number)
plCameraModifier1* pCam = plVirtualCam1::Instance()->GetCameraNumber(number-1); plCameraModifier1* pCam = plVirtualCam1::Instance()->GetCameraNumber(number-1);
if (pCam->GetTarget()) if (pCam->GetTarget())
{ {
const char* ret = pCam->GetTarget()->GetKeyName(); const char* ret = pCam->GetTarget()->GetKeyName().c_str();
(ret==nil) ? "empty" : ret; plString str = plString::Format("saving camera named %s to chronicle\n",ret);
char str[256]; plVirtualCam1::Instance()->AddMsgToLog(str.c_str());
sprintf(str, "saving camera named %s to chronicle\n",ret);
plVirtualCam1::Instance()->AddMsgToLog(str);
return ret; return ret;
} }
plVirtualCam1::Instance()->AddMsgToLog("sending empty to camera chronicle\n"); plVirtualCam1::Instance()->AddMsgToLog("sending empty to camera chronicle\n");
return "empty"; return "empty";
} }
void cyMisc::RebuildCameraStack(const char* name, const char* ageName) void cyMisc::RebuildCameraStack(const plString& name, const char* ageName)
{ {
plKey key=nil; plKey key=nil;
char str[256]; plString str = plString::Format("attempting to restore camera named %s from chronicle\n",name.c_str());
sprintf(str, "attempting to restore camera named %s from chronicle\n",name); plVirtualCam1::Instance()->AddMsgToLog(str.c_str());
plVirtualCam1::Instance()->AddMsgToLog(str);
if (name.Compare("empty") == 0)
if (strcmp(name, "empty") == 0)
return; return;
if ( name || name[0] != 0) if ( !name.IsEmpty() )
{ {
key=plKeyFinder::Instance().StupidSearch(nil,nil,plSceneObject::Index(), name, false); key=plKeyFinder::Instance().StupidSearch(nil,nil,plSceneObject::Index(), name, false);
} }
@ -2487,9 +2482,8 @@ void cyMisc::RebuildCameraStack(const char* name, const char* ageName)
{ {
// give up and force built in 3rd person // give up and force built in 3rd person
plVirtualCam1::Instance()->PushThirdPerson(); plVirtualCam1::Instance()->PushThirdPerson();
char errmsg[256]; plString errmsg = plString::Format("Sceneobject %s not found",name.c_str());
sprintf(errmsg,"Sceneobject %s not found",name); PyErr_SetString(PyExc_NameError, errmsg.c_str());
PyErr_SetString(PyExc_NameError, errmsg);
} }
} }
else else
@ -2512,9 +2506,8 @@ void cyMisc::RebuildCameraStack(const char* name, const char* ageName)
} }
} }
plVirtualCam1::Instance()->PushThirdPerson(); plVirtualCam1::Instance()->PushThirdPerson();
char errmsg[256]; plString errmsg = plString::Format("Sceneobject %s has no camera modifier",name.c_str());
sprintf(errmsg,"Sceneobject %s has no camera modifier",name); PyErr_SetString(PyExc_NameError, errmsg.c_str());
PyErr_SetString(PyExc_NameError, errmsg);
} }
} }
@ -2676,10 +2669,10 @@ void cyMisc::FakeLinkToObject(pyKey& avatar, pyKey& object)
plgDispatch::MsgSend(msg); plgDispatch::MsgSend(msg);
} }
void cyMisc::FakeLinkToObjectNamed(const char* name) void cyMisc::FakeLinkToObjectNamed(const plString& name)
{ {
plKey key = nil; plKey key = nil;
if ( name || name[0] != 0) if ( !name.IsEmpty() )
{ {
key = plKeyFinder::Instance().StupidSearch(nil,nil,plSceneObject::Index(), name, false); key = plKeyFinder::Instance().StupidSearch(nil,nil,plSceneObject::Index(), name, false);
} }

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

@ -142,8 +142,8 @@ public:
// PURPOSE : Execute a console command from a python script, // PURPOSE : Execute a console command from a python script,
// optionally propagate over the net // optionally propagate over the net
// //
static PyObject* FindSceneObject(const char* name, const char* ageName); // returns pySceneObject static PyObject* FindSceneObject(const plString& name, const char* ageName); // returns pySceneObject
static PyObject* FindActivator(const char* name); // returns pyKey static PyObject* FindActivator(const plString& name); // returns pyKey
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -252,7 +252,7 @@ public:
// PURPOSE : Return the net client (account) name of the player whose avatar // PURPOSE : Return the net client (account) name of the player whose avatar
// key is provided. // key is provided.
// //
static const char* GetClientName(pyKey &avKey); static plString GetClientName(pyKey &avKey);
static PyObject* GetAvatarKeyFromClientID(int clientID); // returns pyKey static PyObject* GetAvatarKeyFromClientID(int clientID); // returns pyKey
static int GetLocalClientID(); static int GetLocalClientID();
@ -268,7 +268,7 @@ public:
// //
// PURPOSE : Return the local net client (account) name // PURPOSE : Return the local net client (account) name
// //
static const char* GetLocalClientName(); static plString GetLocalClientName();
// //
@ -697,8 +697,8 @@ public:
static void SetParticleOffset(float x, float y, float z, pyKey& particles); static void SetParticleOffset(float x, float y, float z, pyKey& particles);
static void KillParticles(float time, float pct, pyKey& particles); static void KillParticles(float time, float pct, pyKey& particles);
static int GetNumParticles(pyKey& host); static int GetNumParticles(pyKey& host);
static void SetLightColorValue(pyKey& light, std::string lightName, float r, float g, float b, float a); static void SetLightColorValue(pyKey& light, const plString& lightName, float r, float g, float b, float a);
static void SetLightAnimationOn(pyKey& light, std::string lightName, hsBool start); static void SetLightAnimationOn(pyKey& light, const plString& lightName, hsBool start);
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// //
// Function : RegisterForControlEventMessages // Function : RegisterForControlEventMessages
@ -799,7 +799,7 @@ public:
static int GetNumCameras(); static int GetNumCameras();
static const char* GetCameraNumber(int number); static const char* GetCameraNumber(int number);
static void RebuildCameraStack(const char* name, const char* ageName); static void RebuildCameraStack(const plString& name, const char* ageName);
static void PyClearCameraStack(); static void PyClearCameraStack();
static void RecenterCamera(); static void RecenterCamera();
static bool IsFirstPerson(); static bool IsFirstPerson();
@ -877,8 +877,8 @@ public:
// PURPOSE : takes an avatar key and an object key and fake-links the avatar // PURPOSE : takes an avatar key and an object key and fake-links the avatar
// to that object's position. appears to be a link to other players // to that object's position. appears to be a link to other players
// //
static void FakeLinkToObject(pyKey& avatar, pyKey& object); static void FakeLinkToObject(pyKey& avatar, pyKey& object);
static void FakeLinkToObjectNamed(const char* name); static void FakeLinkToObjectNamed(const plString& name);
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// //

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

@ -112,10 +112,10 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtGetClientName, args, "Params: avatarKey=None\n
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
pyKey* key = pyKey::ConvertFrom(keyObj); pyKey* key = pyKey::ConvertFrom(keyObj);
return PyString_FromString(cyMisc::GetClientName(*key)); return PyString_FromString(cyMisc::GetClientName(*key).s_str());
} }
else else
return PyString_FromString(cyMisc::GetLocalClientName()); return PyString_FromString(cyMisc::GetLocalClientName().c_str());
} }
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetLocalAvatar, "This will return a ptSceneobject of the local avatar\n" PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetLocalAvatar, "This will return a ptSceneobject of the local avatar\n"

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

@ -183,7 +183,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtFindSceneobject, args, "Params: name,ageName\n
PyErr_SetString(PyExc_TypeError, "PtFindSceneobject expects two strings"); PyErr_SetString(PyExc_TypeError, "PtFindSceneobject expects two strings");
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
return cyMisc::FindSceneObject(name, ageName); return cyMisc::FindSceneObject(plString::FromUtf8(name), ageName);
} }
PYTHON_GLOBAL_METHOD_DEFINITION(PtFindActivator, args, "Params: name\nThis will try to find an activator based on its name\n" PYTHON_GLOBAL_METHOD_DEFINITION(PtFindActivator, args, "Params: name\nThis will try to find an activator based on its name\n"
@ -197,7 +197,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtFindActivator, args, "Params: name\nThis will
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
return cyMisc::FindActivator(name); return cyMisc::FindActivator(plString::FromUtf8(name));
} }
PYTHON_BASIC_GLOBAL_METHOD_DEFINITION(PtClearCameraStack, cyMisc::ClearCameraStack, "Clears the camera stack") PYTHON_BASIC_GLOBAL_METHOD_DEFINITION(PtClearCameraStack, cyMisc::ClearCameraStack, "Clears the camera stack")

34
Sources/Plasma/FeatureLib/pfPython/cyMiscGlue4.cpp

@ -141,23 +141,17 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtSetLightValue, args, "Params: key,name,r,g,b,a
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
pyKey* key = pyKey::ConvertFrom(keyObj); pyKey* key = pyKey::ConvertFrom(keyObj);
std::string name = ""; plString name;
if (PyUnicode_Check(nameObj)) if (PyUnicode_Check(nameObj))
{ {
int strLen = PyUnicode_GetSize(nameObj); PyObject* utf8 = PyUnicode_AsUTF8String(nameObj);
wchar_t* text = new wchar_t[strLen + 1]; name = plString::FromUtf8(PyString_AsString(utf8));
PyUnicode_AsWideChar((PyUnicodeObject*)nameObj, text, strLen); Py_DECREF(utf8);
text[strLen] = L'\0';
char* cText = hsWStringToString(text);
name = cText;
delete [] cText;
delete [] text;
} }
else if (PyString_Check(nameObj)) else if (PyString_Check(nameObj))
{ {
// we'll allow this, just in case something goes weird // we'll allow this, just in case something goes weird
char* text = PyString_AsString(nameObj); name = plString::FromUtf8(PyString_AsString(nameObj));
name = text;
} }
else else
{ {
@ -184,23 +178,17 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtSetLightAnimStart, args, "Params: key,name,sta
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
pyKey* key = pyKey::ConvertFrom(keyObj); pyKey* key = pyKey::ConvertFrom(keyObj);
std::string name = ""; plString name;
if (PyUnicode_Check(nameObj)) if (PyUnicode_Check(nameObj))
{ {
int strLen = PyUnicode_GetSize(nameObj); PyObject* utf8 = PyUnicode_AsUTF8String(nameObj);
wchar_t* text = new wchar_t[strLen + 1]; name = plString::FromUtf8(PyString_AsString(utf8));
PyUnicode_AsWideChar((PyUnicodeObject*)nameObj, text, strLen); Py_DECREF(utf8);
text[strLen] = L'\0';
char* cText = hsWStringToString(text);
name = cText;
delete [] cText;
delete [] text;
} }
else if (PyString_Check(nameObj)) else if (PyString_Check(nameObj))
{ {
// we'll allow this, just in case something goes weird // we'll allow this, just in case something goes weird
char* text = PyString_AsString(nameObj); name = plString::FromUtf8(PyString_AsString(nameObj));
name = text;
} }
else else
{ {
@ -363,7 +351,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtRebuildCameraStack, args, "Params: name,ageNam
PyErr_SetString(PyExc_TypeError, "PtRebuildCameraStack expects two strings"); PyErr_SetString(PyExc_TypeError, "PtRebuildCameraStack expects two strings");
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
cyMisc::RebuildCameraStack(name, ageName); cyMisc::RebuildCameraStack(plString::FromUtf8(name), ageName);
PYTHON_RETURN_NONE; PYTHON_RETURN_NONE;
} }

12
Sources/Plasma/FeatureLib/pfPython/cyPhysics.cpp

@ -334,9 +334,9 @@ void cyPhysics::Move(pyVector3& direction, float distance)
} }
else else
{ {
char errmsg[256]; plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName()); obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
} }
} }
} }
@ -404,9 +404,9 @@ void cyPhysics::Rotate(float rad, pyVector3& axis)
} }
else else
{ {
char errmsg[256]; plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName()); obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
} }
} }
} }

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

@ -331,7 +331,6 @@ hsBool plPythonFileMod::fAtConvertTime = false;
plPythonFileMod::plPythonFileMod() plPythonFileMod::plPythonFileMod()
{ {
fPythonFile = nil; fPythonFile = nil;
fModuleName = nil;
fModule = nil; fModule = nil;
fLocalNotify= true; fLocalNotify= true;
fIsFirstTimeEval = true; fIsFirstTimeEval = true;
@ -404,26 +403,25 @@ plPythonFileMod::~plPythonFileMod()
} }
// then get rid of this module // then get rid of this module
// NOTE: fModule shouldn't be made in the plugin, only at runtime // NOTE: fModule shouldn't be made in the plugin, only at runtime
if ( fModuleName && fModule ) if ( !fModuleName.IsNull() && fModule )
{ {
//_PyModule_Clear(fModule); //_PyModule_Clear(fModule);
PyObject *m; PyObject *m;
PyObject *modules = PyImport_GetModuleDict(); PyObject *modules = PyImport_GetModuleDict();
if( modules && (m = PyDict_GetItemString(modules, fModuleName)) && PyModule_Check(m)) if( modules && (m = PyDict_GetItemString(modules, fModuleName.c_str())) && PyModule_Check(m))
{ {
hsStatusMessageF("Module %s removed from python dictionary",fModuleName); hsStatusMessageF("Module %s removed from python dictionary",fModuleName.c_str());
PyDict_DelItemString(modules, fModuleName); PyDict_DelItemString(modules, fModuleName.c_str());
} }
else else
{ {
hsStatusMessageF("Module %s not found in python dictionary. Already removed?",fModuleName); hsStatusMessageF("Module %s not found in python dictionary. Already removed?",fModuleName.c_str());
} }
// the above code should have unloaded the module from python, so it will delete itself, therefore // the above code should have unloaded the module from python, so it will delete itself, therefore
// we need to set our pointer to nil to make sure we don't try to use it // we need to set our pointer to nil to make sure we don't try to use it
fModule = nil; fModule = nil;
} }
delete [] fModuleName; fModuleName = plString::Null;
fModuleName = nil;
} }
#include "plPythonPack.h" #include "plPythonPack.h"
@ -510,11 +508,8 @@ void plPythonFileMod::AddTarget(plSceneObject* sobj)
{ {
plKey pkey = sobj->GetKey(); plKey pkey = sobj->GetKey();
// nope, must be the first object. Then use it as the basis for the module // nope, must be the first object. Then use it as the basis for the module
char modulename[256]; fModuleName = IMakeModuleName(sobj);
IMakeModuleName(modulename,sobj); fModule = PythonInterface::CreateModule(fModuleName.c_str());
delete [] fModuleName;
fModuleName = StrDup(modulename);
fModule = PythonInterface::CreateModule(modulename);
// if we can't create the instance then there is nothing to do here // if we can't create the instance then there is nothing to do here
if (!ILoadPythonCode()) if (!ILoadPythonCode())
@ -634,24 +629,23 @@ void plPythonFileMod::AddTarget(plSceneObject* sobj)
NamedComponent comp; NamedComponent comp;
comp.isActivator = (isNamedAttr == 1); comp.isActivator = (isNamedAttr == 1);
comp.id = parameter.fID; comp.id = parameter.fID;
comp.name = new char[strlen(parameter.datarecord.fString) + 1]; comp.name = parameter.fString;
strcpy(comp.name, parameter.datarecord.fString);
fNamedCompQueue.Append(comp); fNamedCompQueue.Append(comp);
} }
else else
{ {
if (isNamedAttr == 1) if (isNamedAttr == 1)
IFindActivatorAndAdd(parameter.datarecord.fString, parameter.fID); IFindActivatorAndAdd(parameter.fString, parameter.fID);
else else
IFindResponderAndAdd(parameter.datarecord.fString, parameter.fID); IFindResponderAndAdd(parameter.fString, parameter.fID);
} }
} }
} }
// if it wasn't a named string then must be normal string type // if it wasn't a named string then must be normal string type
if ( isNamedAttr == 0 ) if ( isNamedAttr == 0 )
if ( parameter.datarecord.fString != nil ) if ( !parameter.fString.IsNull() )
value = PyString_FromString(parameter.datarecord.fString); value = PyString_FromString(parameter.fString.c_str());
break; break;
case plPythonParameter::kSceneObject: case plPythonParameter::kSceneObject:
case plPythonParameter::kSceneObjectList: case plPythonParameter::kSceneObjectList:
@ -951,7 +945,7 @@ void plPythonFileMod::HandleDiscardedKey( plKeyEventMsg *msg )
// //
// NOTE: This modifier wasn't intended to have multiple targets // NOTE: This modifier wasn't intended to have multiple targets
// //
void plPythonFileMod::IMakeModuleName(char* modulename,plSceneObject* sobj) plString plPythonFileMod::IMakeModuleName(plSceneObject* sobj)
{ {
// Forgive my general crapulance... // Forgive my general crapulance...
// This strips underscores out of module names // This strips underscores out of module names
@ -960,13 +954,14 @@ void plPythonFileMod::IMakeModuleName(char* modulename,plSceneObject* sobj)
plKey pKey = GetKey(); plKey pKey = GetKey();
plKey sKey = sobj->GetKey(); plKey sKey = sobj->GetKey();
const char* pKeyName = pKey->GetName(); const char* pKeyName = pKey->GetName().c_str();
const char* pSobjName = sKey->GetName(); const char* pSobjName = sKey->GetName().c_str();
uint16_t len = hsStrlen(pKeyName); uint16_t len = pKey->GetName().GetSize();
uint16_t slen = hsStrlen(pSobjName); uint16_t slen = sKey->GetName().GetSize();
hsAssert(len+slen < 256, "Warning: String length exceeds 256 characters."); hsAssert(len+slen < 256, "Warning: String length exceeds 256 characters.");
char modulename[256];
int i, k = 0; int i, k = 0;
for(i = 0; i < slen; i++) for(i = 0; i < slen; i++)
@ -983,6 +978,7 @@ void plPythonFileMod::IMakeModuleName(char* modulename,plSceneObject* sobj)
} }
modulename[k] = '\0'; modulename[k] = '\0';
plString name = plString::FromUtf8(modulename);
// check to see if we are attaching to a clone? // check to see if we are attaching to a clone?
plKeyImp* pKeyImp = (plKeyImp*)(sKey); plKeyImp* pKeyImp = (plKeyImp*)(sKey);
@ -992,7 +988,7 @@ void plPythonFileMod::IMakeModuleName(char* modulename,plSceneObject* sobj)
// add the cloneID to the end of the module name // add the cloneID to the end of the module name
// and set the fIAmAClone flag // and set the fIAmAClone flag
uint32_t cloneID = pKeyImp->GetUoid().GetCloneID(); uint32_t cloneID = pKeyImp->GetUoid().GetCloneID();
sprintf(modulename,"%s%d",modulename,cloneID); name += plString::Format("%d", cloneID);
fAmIAttachedToClone = true; fAmIAttachedToClone = true;
} }
@ -1001,8 +997,10 @@ void plPythonFileMod::IMakeModuleName(char* modulename,plSceneObject* sobj)
{ {
// if not unique then add the sequence number to the end of the modulename // if not unique then add the sequence number to the end of the modulename
uint32_t seqID = pKeyImp->GetUoid().GetLocation().GetSequenceNumber(); uint32_t seqID = pKeyImp->GetUoid().GetLocation().GetSequenceNumber();
sprintf(modulename,"%s%d",modulename,seqID); name += plString::Format("%d", seqID);
} }
return name;
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -1047,9 +1045,9 @@ void plPythonFileMod::ISetKeyValue(const plKey& key, int32_t id)
// PURPOSE : find a responder by name in all age and page locations // PURPOSE : find a responder by name in all age and page locations
// : and add to the Parameter list // : and add to the Parameter list
// //
void plPythonFileMod::IFindResponderAndAdd(const char *responderName, int32_t id) void plPythonFileMod::IFindResponderAndAdd(const plString &responderName, int32_t id)
{ {
if ( responderName != nil ) if ( !responderName.IsNull() )
{ {
std::vector<plKey> keylist; std::vector<plKey> keylist;
const plLocation &loc = GetKey()->GetUoid().GetLocation(); const plLocation &loc = GetKey()->GetUoid().GetLocation();
@ -1075,9 +1073,9 @@ void plPythonFileMod::IFindResponderAndAdd(const char *responderName, int32_t id
// PURPOSE : find a responder by name in all age and page locations // PURPOSE : find a responder by name in all age and page locations
// : and add to the Parameter list // : and add to the Parameter list
// //
void plPythonFileMod::IFindActivatorAndAdd(const char *activatorName, int32_t id) void plPythonFileMod::IFindActivatorAndAdd(const plString &activatorName, int32_t id)
{ {
if ( activatorName != nil ) if ( !activatorName.IsNull() )
{ {
std::vector<plKey> keylist; std::vector<plKey> keylist;
const plLocation &loc = GetKey()->GetUoid().GetLocation(); const plLocation &loc = GetKey()->GetUoid().GetLocation();
@ -1236,8 +1234,6 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
IFindActivatorAndAdd(comp.name, comp.id); IFindActivatorAndAdd(comp.name, comp.id);
else else
IFindResponderAndAdd(comp.name, comp.id); IFindResponderAndAdd(comp.name, comp.id);
delete [] comp.name;
} }
fNamedCompQueue.Reset(); fNamedCompQueue.Reset();
@ -1756,9 +1752,9 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
{ {
// yes... // yes...
// call it // call it
char* roomname = ""; const char* roomname = "";
if ( pRLNMsg->GetRoom() != nil ) if ( pRLNMsg->GetRoom() != nil )
roomname = (char*)pRLNMsg->GetRoom()->GetName(); roomname = pRLNMsg->GetRoom()->GetName().c_str();
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod( PyObject* retVal = PyObject_CallMethod(
@ -1965,7 +1961,7 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
if ( mbrIndex != -1 ) if ( mbrIndex != -1 )
{ {
plNetTransportMember *mbr = plNetClientMgr::GetInstance()->TransportMgr().GetMember( mbrIndex ); plNetTransportMember *mbr = plNetClientMgr::GetInstance()->TransportMgr().GetMember( mbrIndex );
player = pyPlayer::New(mbr->GetAvatarKey(), mbr->GetPlayerName(), mbr->GetPlayerID(), mbr->GetDistSq()); player = pyPlayer::New(mbr->GetAvatarKey(), mbr->GetPlayerName().c_str(), mbr->GetPlayerID(), mbr->GetDistSq());
} }
else else
{ {
@ -2837,11 +2833,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
// //
void plPythonFileMod::ReportError() void plPythonFileMod::ReportError()
{ {
char objectName[128]; plString objectName = this->GetKeyName();
StrCopy(objectName, this->GetKeyName(), arrsize(objectName)); objectName += _TEMP_CONVERT_FROM_LITERAL(" - ");
StrPack(objectName, " - ", arrsize(objectName));
PythonInterface::WriteToStdErr(objectName); PythonInterface::WriteToStdErr(objectName.c_str());
PyErr_Print(); // make sure the error is printed PyErr_Print(); // make sure the error is printed
PyErr_Clear(); // clear the error PyErr_Clear(); // clear the error
@ -2984,4 +2979,4 @@ void plPythonFileMod::Write(hsStream* stream, hsResMgr* mgr)
//// kGlobalNameKonstant ///////////////////////////////////////////////// //// kGlobalNameKonstant /////////////////////////////////////////////////
// My continued attempt to spread the CORRECT way to spell konstant. -mcn // My continued attempt to spread the CORRECT way to spell konstant. -mcn
char plPythonFileMod::kGlobalNameKonstant[] = "VeryVerySpecialPythonFileMod"; plString plPythonFileMod::kGlobalNameKonstant = _TEMP_CONVERT_FROM_LITERAL("VeryVerySpecialPythonFileMod");

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

@ -74,10 +74,10 @@ protected:
hsBool IEval(double secs, float del, uint32_t dirty); hsBool IEval(double secs, float del, uint32_t dirty);
void IMakeModuleName(char* modulename,plSceneObject* sobj); plString IMakeModuleName(plSceneObject* sobj);
char* fPythonFile; char* fPythonFile;
char* fModuleName; plString fModuleName;
// the list of receivers that want to be notified // the list of receivers that want to be notified
hsTArray<plKey> fReceivers; hsTArray<plKey> fReceivers;
@ -104,15 +104,15 @@ protected:
struct NamedComponent struct NamedComponent
{ {
char* name; plString name;
int32_t id; int32_t id;
bool isActivator; bool isActivator;
}; };
hsTArray<NamedComponent> fNamedCompQueue; hsTArray<NamedComponent> fNamedCompQueue;
virtual void IFindResponderAndAdd(const char *responderName, int32_t id); virtual void IFindResponderAndAdd(const plString &responderName, int32_t id);
virtual void IFindActivatorAndAdd(const char *activatorName, int32_t id); virtual void IFindActivatorAndAdd(const plString &activatorName, int32_t id);
void ISetKeyValue(const plKey& key, int32_t id); void ISetKeyValue(const plKey& key, int32_t id);
bool ILoadPythonCode(); bool ILoadPythonCode();
@ -210,7 +210,7 @@ public:
static const char* fFunctionNames[]; static const char* fFunctionNames[];
// The konstant hard-coded name to be used for all global pythonFileMods // The konstant hard-coded name to be used for all global pythonFileMods
static char kGlobalNameKonstant[]; static plString kGlobalNameKonstant;
// API for processing discarded keys as the deafult key catcher // API for processing discarded keys as the deafult key catcher
void HandleDiscardedKey( plKeyEventMsg *msg ); void HandleDiscardedKey( plKeyEventMsg *msg );

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

@ -94,17 +94,16 @@ public:
// the data of the value // the data of the value
union union
{ {
int32_t fIntNumber; int32_t fIntNumber;
float fFloatNumber; float fFloatNumber;
hsBool fBool; hsBool fBool;
char* fString;
} datarecord; } datarecord;
plKey fObjectKey; // the plKey of the scene object (should be part of the union, but unions don't allow complex types) plKey fObjectKey; // the plKey of the scene object (should be part of the union, but unions don't allow complex types)
plString fString;
plPythonParameter() plPythonParameter()
@ -147,7 +146,7 @@ public:
SetTobool(other.datarecord.fBool); SetTobool(other.datarecord.fBool);
break; break;
case kString: case kString:
SetToString(other.datarecord.fString); SetToString(other.fString);
break; break;
case kSceneObject: case kSceneObject:
SetToSceneObject(other.fObjectKey); SetToSceneObject(other.fObjectKey);
@ -174,7 +173,7 @@ public:
SetToAnimation(other.fObjectKey); SetToAnimation(other.fObjectKey);
break; break;
case kAnimationName: case kAnimationName:
SetToAnimationName(other.datarecord.fString); SetToAnimationName(other.fString);
break; break;
case kBehavior: case kBehavior:
SetToBehavior(other.fObjectKey); SetToBehavior(other.fObjectKey);
@ -214,10 +213,6 @@ public:
void SetToNone() void SetToNone()
{ {
// remove the string if one was created
if ( fValueType == kString || fValueType == kAnimationName )
delete [] datarecord.fString;
fValueType = kNone; fValueType = kNone;
} }
@ -239,11 +234,11 @@ public:
fValueType = kbool; fValueType = kbool;
datarecord.fBool = state; datarecord.fBool = state;
} }
void SetToString(const char* string) void SetToString(const plString& string)
{ {
SetToNone(); SetToNone();
fValueType = kString; fValueType = kString;
datarecord.fString = hsStrcpy(string); fString = string;
} }
void SetToSceneObject(plKey key, hsBool list=false) void SetToSceneObject(plKey key, hsBool list=false)
{ {
@ -302,11 +297,11 @@ public:
fValueType = kAnimation; fValueType = kAnimation;
fObjectKey = key; fObjectKey = key;
} }
void SetToAnimationName(const char* string) void SetToAnimationName(const plString& string)
{ {
SetToNone(); SetToNone();
fValueType = kAnimationName; fValueType = kAnimationName;
datarecord.fString = hsStrcpy(string); fString = string;
} }
void SetToBehavior(plKey key) void SetToBehavior(plKey key)
{ {
@ -380,11 +375,13 @@ public:
count = stream->ReadLE32(); count = stream->ReadLE32();
if ( count != 0 ) if ( count != 0 )
{ {
datarecord.fString = new char[count+1]; char *buffer = new char[count];
stream->ReadLE(count,datarecord.fString); stream->ReadLE(count, buffer);
buffer[count-1] = 0;
fString = plString::Steal(buffer, count);
} }
else else
datarecord.fString = nil; fString = plString::Null;
break; break;
case kSceneObject: case kSceneObject:
@ -430,13 +427,13 @@ public:
case kString: case kString:
case kAnimationName: case kAnimationName:
if ( datarecord.fString != nil ) if ( !fString.IsNull() )
count = hsStrlen(datarecord.fString)+1; count = fString.GetSize()+1;
else else
count = 0; count = 0;
stream->WriteLE(count); stream->WriteLE(count);
if ( count != 0 ) if ( count != 0 )
stream->WriteLE(count,datarecord.fString); stream->WriteLE(count, fString.c_str());
break; break;
case kSceneObject: case kSceneObject:

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

@ -604,21 +604,20 @@ const plPythonSDLModifier* plPythonSDLModifier::FindAgeSDL()
return sdlMod; return sdlMod;
plNetClientApp::StaticErrorMsg("pfmod %s has a nil python SDL modifier for age sdl %s", plNetClientApp::StaticErrorMsg("pfmod %s has a nil python SDL modifier for age sdl %s",
pfmod->GetKeyName() ? pfmod->GetKeyName() : "?", ageName); pfmod->GetKeyName().s_str("?"), ageName);
} }
else else
{ {
char str[256];
if (!key) if (!key)
plNetClientApp::StaticErrorMsg("nil key %s for age sdl %s", ageName, oid.StringIze(str)); plNetClientApp::StaticErrorMsg("nil key %s for age sdl %s", ageName, oid.StringIze().c_str());
else else
if (!key->ObjectIsLoaded()) if (!key->ObjectIsLoaded())
plNetClientApp::StaticErrorMsg("key %s not loaded for age sdl %s", plNetClientApp::StaticErrorMsg("key %s not loaded for age sdl %s",
key->GetName() ? key->GetName() : "?", ageName); key->GetName().s_str("?"), ageName);
else else
if (!plPythonFileMod::ConvertNoRef(key->ObjectIsLoaded())) if (!plPythonFileMod::ConvertNoRef(key->ObjectIsLoaded()))
plNetClientApp::StaticErrorMsg("key %s is not a python file mod for age sdl %s", plNetClientApp::StaticErrorMsg("key %s is not a python file mod for age sdl %s",
key->GetName() ? key->GetName() : "?", ageName); key->GetName().s_str("?"), ageName);
} }
} }
else else

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

@ -118,7 +118,7 @@ void pyAgeInfoStruct::SetAgeDescription( const char * v )
const char * pyAgeInfoStruct::GetAgeInstanceGuid() const const char * pyAgeInfoStruct::GetAgeInstanceGuid() const
{ {
fAgeInstanceGuidStr = fAgeInfo.GetAgeInstanceGuid()->AsStdString(); fAgeInstanceGuidStr = fAgeInfo.GetAgeInstanceGuid()->AsString();
return fAgeInstanceGuidStr.c_str(); return fAgeInstanceGuidStr.c_str();
} }
@ -164,9 +164,9 @@ const char * pyAgeInfoStruct::GetDisplayName() const
{ {
int32_t seq = GetAgeSequenceNumber(); int32_t seq = GetAgeSequenceNumber();
if ( seq>0 ) if ( seq>0 )
xtl::format( fDisplayName, "%s (%d) %s", GetAgeUserDefinedName(), seq, GetAgeInstanceName() ); fDisplayName = plString::Format( "%s (%d) %s", GetAgeUserDefinedName(), seq, GetAgeInstanceName() );
else else
xtl::format( fDisplayName, "%s %s", GetAgeUserDefinedName(), GetAgeInstanceName() ); fDisplayName = plString::Format( "%s %s", GetAgeUserDefinedName(), GetAgeInstanceName() );
return fDisplayName.c_str(); return fDisplayName.c_str();
} }
@ -217,7 +217,7 @@ void pyAgeInfoStructRef::SetAgeUserDefinedName( const char * v )
const char * pyAgeInfoStructRef::GetAgeInstanceGuid() const const char * pyAgeInfoStructRef::GetAgeInstanceGuid() const
{ {
fAgeInstanceGuidStr = fAgeInfo.GetAgeInstanceGuid()->AsStdString(); fAgeInstanceGuidStr = fAgeInfo.GetAgeInstanceGuid()->AsString();
return fAgeInstanceGuidStr.c_str(); return fAgeInstanceGuidStr.c_str();
} }
@ -241,8 +241,8 @@ const char * pyAgeInfoStructRef::GetDisplayName() const
{ {
int32_t seq = GetAgeSequenceNumber(); int32_t seq = GetAgeSequenceNumber();
if ( seq>0 ) if ( seq>0 )
xtl::format( fDisplayName, "%s (%d) %s", GetAgeUserDefinedName(), seq, GetAgeInstanceName() ); fDisplayName = plString::Format( "%s (%d) %s", GetAgeUserDefinedName(), seq, GetAgeInstanceName() );
else else
xtl::format( fDisplayName, "%s %s", GetAgeUserDefinedName(), GetAgeInstanceName() ); fDisplayName = plString::Format( "%s %s", GetAgeUserDefinedName(), GetAgeInstanceName() );
return fDisplayName.c_str(); return fDisplayName.c_str();
} }

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

@ -57,14 +57,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
class pyVaultAgeInfoNode; class pyVaultAgeInfoNode;
class pyAgeInfoStructRef; class pyAgeInfoStructRef;
class plString;
class pyAgeInfoStruct class pyAgeInfoStruct
{ {
private: private:
plAgeInfoStruct fAgeInfo; plAgeInfoStruct fAgeInfo;
mutable std::string fAgeInstanceGuidStr; // for getting Age Instance GUID mutable plString fAgeInstanceGuidStr; // for getting Age Instance GUID
mutable std::string fDisplayName; // used by GetDisplayName() mutable plString fDisplayName; // used by GetDisplayName()
protected: protected:
pyAgeInfoStruct(); pyAgeInfoStruct();
@ -112,8 +113,8 @@ private:
static plAgeInfoStruct fDefaultAgeInfo; // created so a default constructor could be made for python. Do NOT use static plAgeInfoStruct fDefaultAgeInfo; // created so a default constructor could be made for python. Do NOT use
plAgeInfoStruct & fAgeInfo; plAgeInfoStruct & fAgeInfo;
mutable std::string fAgeInstanceGuidStr; // for getting Age Instance GUID mutable plString fAgeInstanceGuidStr; // for getting Age Instance GUID
mutable std::string fDisplayName; // used by GetDisplayName() mutable plString fDisplayName; // used by GetDisplayName()
protected: protected:
pyAgeInfoStructRef(): fAgeInfo( fDefaultAgeInfo ) {} // only here for the python glue... do NOT call directly pyAgeInfoStructRef(): fAgeInfo( fDefaultAgeInfo ) {} // only here for the python glue... do NOT call directly

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

@ -105,42 +105,42 @@ bool pyCritterBrain::RunningBehavior(const std::string& behaviorName) const
std::string pyCritterBrain::BehaviorName(int behavior) const std::string pyCritterBrain::BehaviorName(int behavior) const
{ {
if (!fBrain) if (!fBrain)
return false; return nil;
return fBrain->BehaviorName(behavior); return fBrain->BehaviorName(behavior);
} }
std::string pyCritterBrain::AnimationName(int behavior) const plString pyCritterBrain::AnimationName(int behavior) const
{ {
if (!fBrain) if (!fBrain)
return false; return plString::Null;
return fBrain->AnimationName(behavior); return fBrain->AnimationName(behavior);
} }
int pyCritterBrain::CurBehavior() const int pyCritterBrain::CurBehavior() const
{ {
if (!fBrain) if (!fBrain)
return false; return 0;
return fBrain->CurBehavior(); return fBrain->CurBehavior();
} }
int pyCritterBrain::NextBehavior() const int pyCritterBrain::NextBehavior() const
{ {
if (!fBrain) if (!fBrain)
return false; return 0;
return fBrain->NextBehavior(); return fBrain->NextBehavior();
} }
std::string pyCritterBrain::IdleBehaviorName() const std::string pyCritterBrain::IdleBehaviorName() const
{ {
if (!fBrain) if (!fBrain)
return false; return nil;
return fBrain->IdleBehaviorName(); return fBrain->IdleBehaviorName();
} }
std::string pyCritterBrain::RunBehaviorName() const std::string pyCritterBrain::RunBehaviorName() const
{ {
if (!fBrain) if (!fBrain)
return false; return nil;
return fBrain->RunBehaviorName(); return fBrain->RunBehaviorName();
} }

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

@ -92,7 +92,7 @@ public:
bool RunningBehavior(const std::string& behaviorName) const; bool RunningBehavior(const std::string& behaviorName) const;
std::string BehaviorName(int behavior) const; std::string BehaviorName(int behavior) const;
std::string AnimationName(int behavior) const; plString AnimationName(int behavior) const;
int CurBehavior() const; int CurBehavior() const;
int NextBehavior() const; int NextBehavior() const;

7
Sources/Plasma/FeatureLib/pfPython/pyImage.cpp

@ -200,7 +200,7 @@ PyObject* pyImage::LoadJPEGFromDisk(const wchar_t* filename, uint16_t width, uin
} }
// let's create a nice name for this thing based on the filename // let's create a nice name for this thing based on the filename
std::string name = "PtImageFromDisk_"; plString name = _TEMP_CONVERT_FROM_LITERAL("PtImageFromDisk_");
const wchar_t* i = filename; const wchar_t* i = filename;
int charsChecked = 0; int charsChecked = 0;
@ -219,10 +219,9 @@ PyObject* pyImage::LoadJPEGFromDisk(const wchar_t* filename, uint16_t width, uin
i++; i++;
} }
char* cName = hsWStringToString(i); name += plString::FromWchar(i);
name = name + cName;
hsgResMgr::ResMgr()->NewKey(name.c_str(), theMipmap, plLocation::kGlobalFixedLoc); hsgResMgr::ResMgr()->NewKey(name, theMipmap, plLocation::kGlobalFixedLoc);
return pyImage::New( theMipmap ); return pyImage::New( theMipmap );
} }

21
Sources/Plasma/FeatureLib/pfPython/pyJournalBook.cpp

@ -58,8 +58,7 @@ uint32_t pyJournalBook::fNextKeyID = 0;
void pyJournalBook::IMakeNewKey( void ) void pyJournalBook::IMakeNewKey( void )
{ {
char name[ 128 ]; plString name = plString::Format( "pyJournalBook-%d", fNextKeyID++ );
sprintf( name, "pyJournalBook-%d", fNextKeyID++ );
hsgResMgr::ResMgr()->NewKey( name, fBook, plLocation::kGlobalFixedLoc ); hsgResMgr::ResMgr()->NewKey( name, fBook, plLocation::kGlobalFixedLoc );
fBook->GetKey()->RefObject(); fBook->GetKey()->RefObject();
@ -96,14 +95,14 @@ pyJournalBook::pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, py
IMakeNewKey(); IMakeNewKey();
} }
pyJournalBook::pyJournalBook( const char *esHTMLSource, pyImage &coverImage, pyKey callbackKey, const char *guiName ) pyJournalBook::pyJournalBook( const char *esHTMLSource, pyImage &coverImage, pyKey callbackKey, const plString &guiName )
{ {
fBook = new pfJournalBook( esHTMLSource, coverImage.GetKey(), callbackKey.getKey(), fBook = new pfJournalBook( esHTMLSource, coverImage.GetKey(), callbackKey.getKey(),
callbackKey.getKey() != nil ? callbackKey.getKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc, guiName ); callbackKey.getKey() != nil ? callbackKey.getKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc, guiName );
IMakeNewKey(); IMakeNewKey();
} }
pyJournalBook::pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, pyKey callbackKey, const char *guiName ) pyJournalBook::pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, pyKey callbackKey, const plString &guiName )
{ {
fBook = new pfJournalBook( esHTMLSource.c_str(), coverImage.GetKey(), callbackKey.getKey(), fBook = new pfJournalBook( esHTMLSource.c_str(), coverImage.GetKey(), callbackKey.getKey(),
callbackKey.getKey() != nil ? callbackKey.getKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc, guiName ); callbackKey.getKey() != nil ? callbackKey.getKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc, guiName );
@ -135,7 +134,7 @@ pyJournalBook::~pyJournalBook()
} }
} }
void pyJournalBook::MakeBook(std::string esHTMLSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, std::string guiName /* = "" */) void pyJournalBook::MakeBook(std::string esHTMLSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, plString guiName /* = "" */)
{ {
if (fBook) if (fBook)
fBook->GetKey()->UnRefObject(); fBook->GetKey()->UnRefObject();
@ -144,11 +143,11 @@ void pyJournalBook::MakeBook(std::string esHTMLSource, plKey coverImageKey /* =
if (callbackKey != nil) if (callbackKey != nil)
loc = callbackKey->GetUoid().GetLocation(); loc = callbackKey->GetUoid().GetLocation();
fBook = new pfJournalBook(esHTMLSource.c_str(), coverImageKey, callbackKey, loc, guiName.c_str()); fBook = new pfJournalBook(esHTMLSource.c_str(), coverImageKey, callbackKey, loc, guiName);
IMakeNewKey(); IMakeNewKey();
} }
void pyJournalBook::MakeBook(std::wstring esHTMLSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, std::string guiName /* = "" */) void pyJournalBook::MakeBook(std::wstring esHTMLSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, plString guiName /* = "" */)
{ {
if (fBook) if (fBook)
fBook->GetKey()->UnRefObject(); fBook->GetKey()->UnRefObject();
@ -157,7 +156,7 @@ void pyJournalBook::MakeBook(std::wstring esHTMLSource, plKey coverImageKey /* =
if (callbackKey != nil) if (callbackKey != nil)
loc = callbackKey->GetUoid().GetLocation(); loc = callbackKey->GetUoid().GetLocation();
fBook = new pfJournalBook(esHTMLSource.c_str(), coverImageKey, callbackKey, loc, guiName.c_str()); fBook = new pfJournalBook(esHTMLSource.c_str(), coverImageKey, callbackKey, loc, guiName);
IMakeNewKey(); IMakeNewKey();
} }
@ -235,18 +234,18 @@ void pyJournalBook::AllowPageTurning( bool allow )
fBook->AllowPageTurning(allow); fBook->AllowPageTurning(allow);
} }
void pyJournalBook::SetGUI( const char *guiName ) void pyJournalBook::SetGUI( const plString &guiName )
{ {
if (fBook != nil) if (fBook != nil)
fBook->SetGUI(guiName); fBook->SetGUI(guiName);
} }
void pyJournalBook::LoadGUI( const char *guiName ) void pyJournalBook::LoadGUI( const plString &guiName )
{ {
pfJournalBook::LoadGUI(guiName); pfJournalBook::LoadGUI(guiName);
} }
void pyJournalBook::UnloadGUI( const char *guiName ) void pyJournalBook::UnloadGUI( const plString &guiName )
{ {
pfJournalBook::UnloadGUI(guiName); pfJournalBook::UnloadGUI(guiName);
} }

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

@ -78,8 +78,8 @@ protected:
pyJournalBook( std::wstring esHTMLSource, pyKey callbackKey ); pyJournalBook( std::wstring esHTMLSource, pyKey callbackKey );
pyJournalBook( const char *esHTMLSource, pyImage &coverImage, pyKey callbackKey ); pyJournalBook( const char *esHTMLSource, pyImage &coverImage, pyKey callbackKey );
pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, pyKey callbackKey ); pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, pyKey callbackKey );
pyJournalBook( const char *esHTMLSource, pyImage &coverImage, pyKey callbackKey, const char *guiName ); pyJournalBook( const char *esHTMLSource, pyImage &coverImage, pyKey callbackKey, const plString &guiName );
pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, pyKey callbackKey, const char *guiName ); pyJournalBook( std::wstring esHTMLSource, pyImage &coverImage, pyKey callbackKey, const plString &guiName );
public: public:
virtual ~pyJournalBook(); virtual ~pyJournalBook();
@ -88,8 +88,8 @@ public:
// required functions for PyObject interoperability // required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptBook); PYTHON_CLASS_NEW_FRIEND(ptBook);
static PyObject *New(std::string htmlSource, plKey coverImageKey = nil, plKey callbackKey = nil, std::string guiName = ""); static PyObject *New(std::string htmlSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = _TEMP_CONVERT_FROM_LITERAL(""));
static PyObject *New(std::wstring htmlSource, plKey coverImageKey = nil, plKey callbackKey = nil, std::string guiName = ""); static PyObject *New(std::wstring htmlSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = _TEMP_CONVERT_FROM_LITERAL(""));
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyJournalBook object PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyJournalBook object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyJournalBook); // converts a PyObject to a pyJournalBook (throws error if not correct type) PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyJournalBook); // converts a PyObject to a pyJournalBook (throws error if not correct type)
@ -98,8 +98,8 @@ public:
static void AddPlasmaConstantsClasses(PyObject *m); static void AddPlasmaConstantsClasses(PyObject *m);
// Deletes the existing book and re-creates it, for use by the python glue // Deletes the existing book and re-creates it, for use by the python glue
void MakeBook(std::string esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, std::string guiName = ""); void MakeBook(std::string esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = _TEMP_CONVERT_FROM_LITERAL(""));
void MakeBook(std::wstring esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, std::string guiName = ""); void MakeBook(std::wstring esHTMLSource, plKey coverImageKey = nil, plKey callbackKey = nil, plString guiName = _TEMP_CONVERT_FROM_LITERAL(""));
// Interface functions per book // Interface functions per book
virtual void Show( hsBool startOpened ); virtual void Show( hsBool startOpened );
@ -117,10 +117,10 @@ public:
virtual void SetSize( float width, float height ); virtual void SetSize( float width, float height );
virtual void SetGUI( const char *guiName ); virtual void SetGUI( const plString &guiName );
static void LoadGUI( const char *guiName ); static void LoadGUI( const plString &guiName );
static void UnloadGUI( const char *guiName ); static void UnloadGUI( const plString &guiName );
static void UnloadAllGUIs(); static void UnloadAllGUIs();
virtual PyObject *GetMovie( uint8_t index ); // returns cyAnimation virtual PyObject *GetMovie( uint8_t index ); // returns cyAnimation

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

@ -101,9 +101,9 @@ PYTHON_INIT_DEFINITION(ptBook, args, keywords)
callbackKey = pyKey::ConvertFrom(callbackObj)->getKey(); callbackKey = pyKey::ConvertFrom(callbackObj)->getKey();
} }
std::string guiNameStr = ""; plString guiNameStr;
if (guiName) if (guiName)
guiNameStr = guiName; guiNameStr = plString::FromUtf8(guiName);
// convert the sourcecode object // convert the sourcecode object
if (PyUnicode_Check(sourceObj)) if (PyUnicode_Check(sourceObj))
@ -225,7 +225,7 @@ PYTHON_METHOD_DEFINITION(ptBook, setGUI, args)
PyErr_SetString(PyExc_TypeError, "setGUI expects a string"); PyErr_SetString(PyExc_TypeError, "setGUI expects a string");
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
self->fThis->SetGUI(guiName); self->fThis->SetGUI(plString::FromUtf8(guiName));
PYTHON_RETURN_NONE; PYTHON_RETURN_NONE;
} }
@ -293,14 +293,14 @@ PYTHON_END_METHODS_TABLE;
PLASMA_DEFAULT_TYPE(ptBook, "Params: esHTMLSource,coverImage=None,callbackKey=None,guiName=''\nCreates a new book"); PLASMA_DEFAULT_TYPE(ptBook, "Params: esHTMLSource,coverImage=None,callbackKey=None,guiName=''\nCreates a new book");
// required functions for PyObject interoperability // required functions for PyObject interoperability
PyObject *pyJournalBook::New(std::string htmlSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, std::string guiName /* = "" */) PyObject *pyJournalBook::New(std::string htmlSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, plString guiName /* = "" */)
{ {
ptBook *newObj = (ptBook*)ptBook_type.tp_new(&ptBook_type, NULL, NULL); ptBook *newObj = (ptBook*)ptBook_type.tp_new(&ptBook_type, NULL, NULL);
newObj->fThis->MakeBook(htmlSource, coverImageKey, callbackKey, guiName); newObj->fThis->MakeBook(htmlSource, coverImageKey, callbackKey, guiName);
return (PyObject*)newObj; return (PyObject*)newObj;
} }
PyObject *pyJournalBook::New(std::wstring htmlSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, std::string guiName /* = "" */) PyObject *pyJournalBook::New(std::wstring htmlSource, plKey coverImageKey /* = nil */, plKey callbackKey /* = nil */, plString guiName /* = "" */)
{ {
ptBook *newObj = (ptBook*)ptBook_type.tp_new(&ptBook_type, NULL, NULL); ptBook *newObj = (ptBook*)ptBook_type.tp_new(&ptBook_type, NULL, NULL);
newObj->fThis->MakeBook(htmlSource, coverImageKey, callbackKey, guiName); newObj->fThis->MakeBook(htmlSource, coverImageKey, callbackKey, guiName);
@ -329,7 +329,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtLoadBookGUI, args, "Params: guiName\nLoads the
PyErr_SetString(PyExc_TypeError, "PtLoadBookGUI expects a string"); PyErr_SetString(PyExc_TypeError, "PtLoadBookGUI expects a string");
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
pyJournalBook::LoadGUI(guiName); pyJournalBook::LoadGUI(plString::FromUtf8(guiName));
PYTHON_RETURN_NONE; PYTHON_RETURN_NONE;
} }
@ -341,7 +341,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtUnloadBookGUI, args, "Params: guiName\nUnloads
PyErr_SetString(PyExc_TypeError, "PtUnloadBookGUI expects a string"); PyErr_SetString(PyExc_TypeError, "PtUnloadBookGUI expects a string");
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
pyJournalBook::UnloadGUI(guiName); pyJournalBook::UnloadGUI(plString::FromUtf8(guiName));
PYTHON_RETURN_NONE; PYTHON_RETURN_NONE;
} }

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

@ -52,6 +52,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnKeyedObject/plKey.h" #include "pnKeyedObject/plKey.h"
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
#include "plString.h"
class plPythonFileMod; class plPythonFileMod;
class pySceneObject; class pySceneObject;
@ -98,7 +99,7 @@ public:
// getter and setters // getter and setters
virtual plKey getKey() { return fKey; } virtual plKey getKey() { return fKey; }
virtual void setKey(plKey key) { fKey=key; } virtual void setKey(plKey key) { fKey=key; }
virtual const char* getName() const { return fKey ? fKey->GetName() : "nil"; } virtual const char* getName() const { return fKey ? fKey->GetName().c_str() : "nil"; }
#ifndef BUILDING_PYPLASMA #ifndef BUILDING_PYPLASMA
PyObject* GetPySceneObject(); PyObject* GetPySceneObject();

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

@ -89,10 +89,10 @@ public:
bool HasServerPort() const { return fInfo.HasServerPort(); } bool HasServerPort() const { return fInfo.HasServerPort(); }
bool HasServerGuid() const { return fInfo.HasServerGuid(); } bool HasServerGuid() const { return fInfo.HasServerGuid(); }
const char * GetServerName() const { return fInfo.GetServerName(); } const char * GetServerName() const { return fInfo.GetServerName(); }
uint8_t GetServerType() const { return fInfo.GetServerType(); } uint8_t GetServerType() const { return fInfo.GetServerType(); }
const char * GetServerAddr() const { return fInfo.GetServerAddr(); } const char * GetServerAddr() const { return fInfo.GetServerAddr(); }
uint16_t GetServerPort() const { return fInfo.GetServerPort(); } uint16_t GetServerPort() const { return fInfo.GetServerPort(); }
const char * GetServerGuid() const { fServerGuid.CopyFrom( fInfo.GetServerGuid() ); return fServerGuid.AsString(); } const char * GetServerGuid() const { fServerGuid.CopyFrom( fInfo.GetServerGuid() ); return fServerGuid.AsString().c_str(); }
}; };
@ -129,10 +129,10 @@ public:
bool HasServerPort() const { return fInfo.HasServerPort(); } bool HasServerPort() const { return fInfo.HasServerPort(); }
bool HasServerGuid() const { return fInfo.HasServerGuid(); } bool HasServerGuid() const { return fInfo.HasServerGuid(); }
const char * GetServerName() const { return fInfo.GetServerName(); } const char * GetServerName() const { return fInfo.GetServerName(); }
uint8_t GetServerType() const { return fInfo.GetServerType(); } uint8_t GetServerType() const { return fInfo.GetServerType(); }
const char * GetServerAddr() const { return fInfo.GetServerAddr(); } const char * GetServerAddr() const { return fInfo.GetServerAddr(); }
uint16_t GetServerPort() const { return fInfo.GetServerPort(); } uint16_t GetServerPort() const { return fInfo.GetServerPort(); }
const char * GetServerGuid() const { fServerGuid.CopyFrom( fInfo.GetServerGuid() ); return fServerGuid.AsString(); } const char * GetServerGuid() const { fServerGuid.CopyFrom( fInfo.GetServerGuid() ); return fServerGuid.AsString().c_str(); }
}; };

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

@ -210,21 +210,21 @@ void pySceneObject::SetNetForce(hsBool state)
} }
const char* pySceneObject::GetName() plString pySceneObject::GetName()
{ {
if ( fSceneObjects.Count() > 0 ) if ( fSceneObjects.Count() > 0 )
return fSceneObjects[0]->GetName(); return fSceneObjects[0]->GetName();
return ""; return _TEMP_CONVERT_FROM_LITERAL("");
} }
PyObject* pySceneObject::findObj(const char* name) PyObject* pySceneObject::findObj(const plString& name)
{ {
PyObject* pSobj = nil; PyObject* pSobj = nil;
// search through the plKeys that we have looking for this name // search through the plKeys that we have looking for this name
int i; int i;
for ( i=0; i<fSceneObjects.Count(); i++ ) for ( i=0; i<fSceneObjects.Count(); i++ )
{ {
if ( hsStrEQ(name,fSceneObjects[i]->GetName()) ) if ( name == fSceneObjects[i]->GetName() )
{ {
pSobj = pySceneObject::New(fSceneObjects[i],fPyMod); pSobj = pySceneObject::New(fSceneObjects[i],fPyMod);
break; break;
@ -235,7 +235,7 @@ PyObject* pySceneObject::findObj(const char* name)
if ( pSobj == nil ) if ( pSobj == nil )
{ {
// throw a Python error, so the coder knows it didn't work // throw a Python error, so the coder knows it didn't work
PyErr_SetString(PyExc_KeyError, name); PyErr_SetString(PyExc_KeyError, name.c_str());
} }
return pSobj; return pSobj;
@ -284,9 +284,9 @@ PyObject* pySceneObject::GetLocalToWorld()
return pyMatrix44::New((hsMatrix44)ci->GetLocalToWorld()); return pyMatrix44::New((hsMatrix44)ci->GetLocalToWorld());
else else
{ {
char errmsg[256]; plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName()); obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
return nil; // return nil to tell python we errored return nil; // return nil to tell python we errored
} }
} }
@ -313,9 +313,9 @@ PyObject* pySceneObject::GetWorldToLocal()
return pyMatrix44::New((hsMatrix44)ci->GetWorldToLocal()); return pyMatrix44::New((hsMatrix44)ci->GetWorldToLocal());
else else
{ {
char errmsg[256]; plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName()); obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
return nil; // return nil to tell python we errored return nil; // return nil to tell python we errored
} }
} }
@ -342,9 +342,9 @@ PyObject* pySceneObject::GetLocalToParent()
return pyMatrix44::New((hsMatrix44)ci->GetLocalToParent()); return pyMatrix44::New((hsMatrix44)ci->GetLocalToParent());
else else
{ {
char errmsg[256]; plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName()); obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
return nil; // return nil to tell python we errored return nil; // return nil to tell python we errored
} }
} }
@ -371,9 +371,9 @@ PyObject* pySceneObject::GetParentToLocal()
return pyMatrix44::New((hsMatrix44)ci->GetParentToLocal()); return pyMatrix44::New((hsMatrix44)ci->GetParentToLocal());
else else
{ {
char errmsg[256]; plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName()); obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
return nil; // return nil to tell python we errored return nil; // return nil to tell python we errored
} }
} }
@ -416,9 +416,9 @@ PyObject* pySceneObject::GetWorldPosition()
return pyPoint3::New((hsPoint3)ci->GetWorldPos()); return pyPoint3::New((hsPoint3)ci->GetWorldPos());
else else
{ {
char errmsg[256]; plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName()); obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
return nil; // return nil to tell python we errored return nil; // return nil to tell python we errored
} }
} }
@ -445,9 +445,9 @@ PyObject* pySceneObject::GetViewVector()
return pyVector3::New(ci->GetLocalToWorld().GetAxis(hsMatrix44::kView)); return pyVector3::New(ci->GetLocalToWorld().GetAxis(hsMatrix44::kView));
else else
{ {
char errmsg[256]; plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName()); obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
return nil; // return nil to tell python we errored return nil; // return nil to tell python we errored
} }
} }
@ -474,9 +474,9 @@ PyObject* pySceneObject::GetUpVector()
return pyVector3::New(ci->GetLocalToWorld().GetAxis(hsMatrix44::kUp)); return pyVector3::New(ci->GetLocalToWorld().GetAxis(hsMatrix44::kUp));
else else
{ {
char errmsg[256]; plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName()); obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
return nil; // return nil to tell python we errored return nil; // return nil to tell python we errored
} }
} }
@ -503,9 +503,9 @@ PyObject* pySceneObject::GetRightVector()
return pyVector3::New(ci->GetLocalToWorld().GetAxis(hsMatrix44::kRight)); return pyVector3::New(ci->GetLocalToWorld().GetAxis(hsMatrix44::kRight));
else else
{ {
char errmsg[256]; plString errmsg = plString::Format("Sceneobject %s does not have a coordinate interface.",
sprintf(errmsg,"Sceneobject %s does not have a coordinate interface.",obj->GetKeyName()); obj->GetKeyName().c_str());
PyErr_SetString(PyExc_RuntimeError, errmsg); PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
return nil; // return nil to tell python we errored return nil; // return nil to tell python we errored
} }
} }

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

@ -114,9 +114,9 @@ public:
virtual void SetNetForce(hsBool state); virtual void SetNetForce(hsBool state);
virtual PyObject* findObj(const char* name); // pySceneObject virtual PyObject* findObj(const plString& name); // pySceneObject
virtual const char* GetName(); virtual plString GetName();
virtual std::vector<PyObject*> GetResponders(); // pyKey list virtual std::vector<PyObject*> GetResponders(); // pyKey list
virtual std::vector<PyObject*> GetPythonMods(); // pyKey list virtual std::vector<PyObject*> GetPythonMods(); // pyKey list
// //

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

@ -151,12 +151,12 @@ PYTHON_METHOD_DEFINITION(ptSceneobject, findObject, args)
PyErr_SetString(PyExc_TypeError, "findObject expects a string"); PyErr_SetString(PyExc_TypeError, "findObject expects a string");
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
return self->fThis->findObj(name); return self->fThis->findObj(plString::FromUtf8(name));
} }
PYTHON_METHOD_DEFINITION_NOARGS(ptSceneobject, getName) PYTHON_METHOD_DEFINITION_NOARGS(ptSceneobject, getName)
{ {
return PyString_FromString(self->fThis->GetName()); return PyString_FromString(self->fThis->GetName().c_str());
} }
PYTHON_METHOD_DEFINITION_NOARGS(ptSceneobject, getResponders) PYTHON_METHOD_DEFINITION_NOARGS(ptSceneobject, getResponders)

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

@ -654,25 +654,25 @@ void pyVault::CreateNeighborhood()
link.GetAgeInfo()->SetAgeFilename(kNeighborhoodAgeFilename); link.GetAgeInfo()->SetAgeFilename(kNeighborhoodAgeFilename);
link.GetAgeInfo()->SetAgeInstanceName(kNeighborhoodAgeInstanceName); link.GetAgeInfo()->SetAgeInstanceName(kNeighborhoodAgeInstanceName);
std::string title; plString title;
std::string desc; plString desc;
unsigned nameLen = StrLen(nc->GetPlayerName()); unsigned nameLen = nc->GetPlayerName().GetSize();
if (nc->GetPlayerName()[nameLen - 1] == 's' || nc->GetPlayerName()[nameLen - 1] == 'S') if (nc->GetPlayerName().CharAt(nameLen - 1) == 's' || nc->GetPlayerName().CharAt(nameLen - 1) == 'S')
{ {
xtl::format( title, "%s'", nc->GetPlayerName() ); title = plString::Format( "%s'", nc->GetPlayerName().c_str() );
xtl::format( desc, "%s' %s", nc->GetPlayerName(), link.GetAgeInfo()->GetAgeInstanceName() ); desc = plString::Format( "%s' %s", nc->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() );
} }
else else
{ {
xtl::format( title, "%s's", nc->GetPlayerName() ); title = plString::Format( "%s's", nc->GetPlayerName().c_str() );
xtl::format( desc, "%s's %s", nc->GetPlayerName(), link.GetAgeInfo()->GetAgeInstanceName() ); desc = plString::Format( "%s's %s", nc->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() );
} }
plUUID guid(GuidGenerate()); plUUID guid(GuidGenerate());
link.GetAgeInfo()->SetAgeInstanceGuid(&guid); link.GetAgeInfo()->SetAgeInstanceGuid(&guid);
link.GetAgeInfo()->SetAgeUserDefinedName( title.c_str() ); link.GetAgeInfo()->SetAgeUserDefinedName( _TEMP_CONVERT_TO_CONST_CHAR(title) );
link.GetAgeInfo()->SetAgeDescription( desc.c_str() ); link.GetAgeInfo()->SetAgeDescription( _TEMP_CONVERT_TO_CONST_CHAR(desc) );
VaultRegisterOwnedAge(&link); VaultRegisterOwnedAge(&link);
} }

3
Sources/Plasma/FeatureLib/pfPython/pyVaultImageNode.cpp

@ -64,8 +64,7 @@ static unsigned s_keyseq;
//============================================================================ //============================================================================
static plKey CreateAndRefImageKey (unsigned nodeId, plMipmap * mipmap) { static plKey CreateAndRefImageKey (unsigned nodeId, plMipmap * mipmap) {
char keyName[MAX_PATH]; plString keyName = plString::Format("VaultImg_%u_%u", nodeId, s_keyseq++);
StrPrintf(keyName, arrsize(keyName), "VaultImg_%u_%u", nodeId, s_keyseq++);
plKey key = hsgResMgr::ResMgr()->NewKey(keyName, mipmap, plLocation::kGlobalFixedLoc); plKey key = hsgResMgr::ResMgr()->NewKey(keyName, mipmap, plLocation::kGlobalFixedLoc);

3
Sources/Plasma/FeatureLib/pfSurface/plLayerMovie.cpp

@ -115,8 +115,7 @@ hsBool plLayerMovie::ISetupBitmap()
memset(b->GetImage(), 0x10, b->GetHeight() * b->GetRowBytes() ); memset(b->GetImage(), 0x10, b->GetHeight() * b->GetRowBytes() );
b->SetFlags( b->GetFlags() | plMipmap::kDontThrowAwayImage ); b->SetFlags( b->GetFlags() | plMipmap::kDontThrowAwayImage );
char name[ 256 ]; plString name = plString::Format( "%s_BMap", fMovieName );
sprintf( name, "%s_BMap", fMovieName );
hsgResMgr::ResMgr()->NewKey( name, b, plLocation::kGlobalFixedLoc ); hsgResMgr::ResMgr()->NewKey( name, b, plLocation::kGlobalFixedLoc );
*fTexture = (plBitmap *)b; *fTexture = (plBitmap *)b;

4
Sources/Plasma/NucleusLib/inc/hsResMgr.h

@ -105,7 +105,7 @@ public:
//--------------------------- //---------------------------
// Registry Modification Functions // Registry Modification Functions
//--------------------------- //---------------------------
virtual plKey NewKey(const char* name, hsKeyedObject* object, const plLocation& loc, const plLoadMask& m = plLoadMask::kAlways)=0; virtual plKey NewKey(const plString& name, hsKeyedObject* object, const plLocation& loc, const plLoadMask& m = plLoadMask::kAlways)=0;
virtual plKey NewKey(plUoid& newUoid, hsKeyedObject* object)=0; virtual plKey NewKey(plUoid& newUoid, hsKeyedObject* object)=0;
virtual plDispatchBase* Dispatch()=0; virtual plDispatchBase* Dispatch()=0;
@ -118,7 +118,7 @@ protected:
friend class plKeyImp; friend class plKeyImp;
friend class plArmatureMod; // Temp hack until a findkey/clone issue is fixed. -Bob friend class plArmatureMod; // Temp hack until a findkey/clone issue is fixed. -Bob
virtual plKey ReRegister(const char *nm, const plUoid& oid)=0; virtual plKey ReRegister(const plString& nm, const plUoid& oid)=0;
virtual hsBool ReadObject(plKeyImp* key)=0; // plKeys call this when needed virtual hsBool ReadObject(plKeyImp* key)=0; // plKeys call this when needed
// Sets a key as used or unused in the registry. When all keys in a page of a // Sets a key as used or unused in the registry. When all keys in a page of a

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

@ -332,7 +332,7 @@ void plDispatch::IMsgDispatch()
{ {
hsLogEntry(plNetObjectDebuggerBase::GetInstance()->LogMsg( hsLogEntry(plNetObjectDebuggerBase::GetInstance()->LogMsg(
xtl::format("<RCV> object:%s, GameMessage %s st=%.3f rt=%.3f", xtl::format("<RCV> object:%s, GameMessage %s st=%.3f rt=%.3f",
ko->GetKeyName(), msg->ClassName(), hsTimer::GetSysSeconds(), hsTimer::GetSeconds()).c_str())); ko->GetKeyName().c_str(), msg->ClassName(), hsTimer::GetSysSeconds(), hsTimer::GetSeconds()).c_str()));
} }
} }
} }
@ -341,7 +341,7 @@ void plDispatch::IMsgDispatch()
uint32_t rcvTicks = hsTimer::GetPrecTickCount(); uint32_t rcvTicks = hsTimer::GetPrecTickCount();
// Object could be deleted by this message, so we need to log this stuff now // Object could be deleted by this message, so we need to log this stuff now
const char* keyname = "(unknown)"; plString keyname = _TEMP_CONVERT_FROM_LITERAL("(unknown)");
const char* className = "(unknown)"; const char* className = "(unknown)";
uint32_t clonePlayerID = 0; uint32_t clonePlayerID = 0;
if (plDispatchLogBase::IsLoggingLong()) if (plDispatchLogBase::IsLoggingLong())
@ -373,7 +373,7 @@ void plDispatch::IMsgDispatch()
float rcvTime = (float)(hsTimer::PrecTicksToSecs(rcvTicks) * 1000.f); float rcvTime = (float)(hsTimer::PrecTicksToSecs(rcvTicks) * 1000.f);
// If the receiver takes more than 5 ms to process its message, log it // If the receiver takes more than 5 ms to process its message, log it
if (rcvTime > 5.f) if (rcvTime > 5.f)
plDispatchLogBase::GetInstance()->LogLongReceive(keyname, className, clonePlayerID, msg, rcvTime); plDispatchLogBase::GetInstance()->LogLongReceive(keyname.c_str(), className, clonePlayerID, msg, rcvTime);
} }
#endif // PLASMA_EXTERNAL_RELEASE #endif // PLASMA_EXTERNAL_RELEASE

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

@ -65,12 +65,12 @@ hsBool hsKeyedObject::SendRef(plRefMsg* refMsg, plRefFlags::Type flags)
return hsgResMgr::SendRef(key, refMsg, flags); return hsgResMgr::SendRef(key, refMsg, flags);
} }
const char* hsKeyedObject::GetKeyName() const plString hsKeyedObject::GetKeyName() const
{ {
if (fpKey) if (fpKey)
return fpKey->GetName(); return fpKey->GetName();
else else
return "(unknown)"; return _TEMP_CONVERT_FROM_LITERAL("(unknown)");
} }
hsKeyedObject::~hsKeyedObject() hsKeyedObject::~hsKeyedObject()
@ -123,7 +123,7 @@ void hsKeyedObject::UnRegisterAs(plFixedKeyId fixedKey)
UnRegisterAsManual(uoid); UnRegisterAsManual(uoid);
} }
plKey hsKeyedObject::RegisterAsManual(plUoid& meUoid, const char* p) plKey hsKeyedObject::RegisterAsManual(plUoid& meUoid, const plString& p)
{ {
hsAssert(meUoid.GetClassType() == ClassIndex(),"Registering as wrong type!"); hsAssert(meUoid.GetClassType() == ClassIndex(),"Registering as wrong type!");
// Really should be a NewKey() call just for fixed keys, so change this once player rooms behave // Really should be a NewKey() call just for fixed keys, so change this once player rooms behave
@ -143,12 +143,9 @@ void hsKeyedObject::UnRegisterAsManual(plUoid& inUoid)
if (!(inUoid == myUoid)) if (!(inUoid == myUoid))
{ {
#if !HS_BUILD_FOR_UNIX // disable for unix servers #if !HS_BUILD_FOR_UNIX // disable for unix servers
char inStr[255], myStr[255];
inUoid.StringIze(inStr);
myUoid.StringIze(myStr);
hsAssert(false, hsAssert(false,
xtl::format("Request to Unregister wrong FixedKey, keyName=%s, inUoid=%s, myUoid=%s", plString::Format("Request to Unregister wrong FixedKey, keyName=%s, inUoid=%s, myUoid=%s",
fpKey->GetName() ? fpKey->GetName() : "?", inStr, myStr).c_str()); fpKey->GetName().s_str("?"), inUoid.StringIze().c_str(), myUoid.StringIze().c_str()).c_str());
#endif #endif
} }
((plKeyImp*)fpKey)->UnRegister(); ((plKeyImp*)fpKey)->UnRegister();

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

@ -62,7 +62,7 @@ public:
GETINTERFACE_ANY(hsKeyedObject, plReceiver); GETINTERFACE_ANY(hsKeyedObject, plReceiver);
const plKey& GetKey() const { return fpKey; } const plKey& GetKey() const { return fpKey; }
const char* GetKeyName() const; plString GetKeyName() const;
virtual void Validate(); virtual void Validate();
virtual hsBool IsFinal() { return true; }; // experimental; currently "is ready to process Loads" virtual hsBool IsFinal() { return true; }; // experimental; currently "is ready to process Loads"
@ -85,7 +85,7 @@ public:
void UnRegisterAs(plFixedKeyId fixedKey); void UnRegisterAs(plFixedKeyId fixedKey);
// used when manually loading the player room // used when manually loading the player room
plKey RegisterAsManual(plUoid& uoid, const char* p); plKey RegisterAsManual(plUoid& uoid, const plString& p);
void UnRegisterAsManual(plUoid& uoid); void UnRegisterAsManual(plUoid& uoid);
// If you want clone keys to share a type of object, override this function for it. // If you want clone keys to share a type of object, override this function for it.

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

@ -63,12 +63,12 @@ struct plKeySeed
plFixedKeyId feFixedKey; plFixedKeyId feFixedKey;
// NOTE: The following fields are broken out to make adding to the fixed key list easier. // NOTE: The following fields are broken out to make adding to the fixed key list easier.
// However, what they really are, are just the fields of plUoid (including plLocation) // However, what they really are, are just the fields of plUoid (including plLocation)
uint16_t fType; uint16_t fType;
const char *fObj; plString fObj;
hsBool Match( plKeySeed *p ) hsBool Match( plKeySeed *p )
{ {
if( ( fType == p->fType ) && stricmp( p->fObj, fObj ) == 0 ) if( ( fType == p->fType ) && p->fObj.Compare( fObj, plString::kCaseInsensitive ) == 0 )
{ {
return true; return true;
} }
@ -82,48 +82,50 @@ struct plKeySeed
// 2) Be sure your ClassIndex CLASS_INDEX(plSceneObject) matches the type of object you want to have the fixedKey // 2) Be sure your ClassIndex CLASS_INDEX(plSceneObject) matches the type of object you want to have the fixedKey
// 3) Make sure the Obj is unique for this location/Type Combo... (validated at runtime) // 3) Make sure the Obj is unique for this location/Type Combo... (validated at runtime)
#define _TCFL _TEMP_CONVERT_FROM_LITERAL
plKeySeed SeedList[] = { plKeySeed SeedList[] = {
// Key Enum Type Obj // Key Enum Type Obj
{ kFirst_Fixed_KEY, CLASS_INDEX_SCOPED( plSceneObject ), "kFirst_Fixed_KEY" }, { kFirst_Fixed_KEY, CLASS_INDEX_SCOPED( plSceneObject ), _TCFL("kFirst_Fixed_KEY") },
{ kLOSObject_KEY, CLASS_INDEX_SCOPED( plLOSDispatch ), "kLOSObject_KEY", }, { kLOSObject_KEY, CLASS_INDEX_SCOPED( plLOSDispatch ), _TCFL("kLOSObject_KEY"), },
{ kTimerCallbackManager_KEY, CLASS_INDEX_SCOPED( plTimerCallbackManager ), "kTimerCallbackManager_KEY", }, { kTimerCallbackManager_KEY, CLASS_INDEX_SCOPED( plTimerCallbackManager ), _TCFL("kTimerCallbackManager_KEY"), },
{ kConsoleObject_KEY, CLASS_INDEX_SCOPED( pfConsole ), "kConsoleObject_KEY", }, { kConsoleObject_KEY, CLASS_INDEX_SCOPED( pfConsole ), _TCFL("kConsoleObject_KEY"), },
{ kAudioSystem_KEY, CLASS_INDEX_SCOPED( plAudioSystem ), "kAudioSystem_KEY", }, { kAudioSystem_KEY, CLASS_INDEX_SCOPED( plAudioSystem ), _TCFL("kAudioSystem_KEY"), },
{ kInput_KEY, CLASS_INDEX_SCOPED( plInputManager ), "kInput_KEY", }, { kInput_KEY, CLASS_INDEX_SCOPED( plInputManager ), _TCFL("kInput_KEY"), },
{ kClient_KEY, CLASS_INDEX_SCOPED( plClient ), "kClient_KEY", }, { kClient_KEY, CLASS_INDEX_SCOPED( plClient ), _TCFL("kClient_KEY"), },
{ kNetClientMgr_KEY, CLASS_INDEX_SCOPED( plNetClientMgr ), "kNetClientMgr_KEY", }, { kNetClientMgr_KEY, CLASS_INDEX_SCOPED( plNetClientMgr ), _TCFL("kNetClientMgr_KEY"), },
{ kListenerMod_KEY, CLASS_INDEX_SCOPED( plListener ), "kListenerMod_KEY", }, { kListenerMod_KEY, CLASS_INDEX_SCOPED( plListener ), _TCFL("kListenerMod_KEY"), },
{ kTransitionMgr_KEY, CLASS_INDEX_SCOPED( plTransitionMgr ), "kTransitionMgr_KEY", }, { kTransitionMgr_KEY, CLASS_INDEX_SCOPED( plTransitionMgr ), _TCFL("kTransitionMgr_KEY"), },
{ kLinkEffectsMgr_KEY, CLASS_INDEX_SCOPED( plLinkEffectsMgr ), "kLinkEffectsMgr_KEY", }, { kLinkEffectsMgr_KEY, CLASS_INDEX_SCOPED( plLinkEffectsMgr ), _TCFL("kLinkEffectsMgr_KEY"), },
{ kGameGUIMgr_KEY, CLASS_INDEX_SCOPED( pfGameGUIMgr ), "kGameGUIMgr_KEY", }, { kGameGUIMgr_KEY, CLASS_INDEX_SCOPED( pfGameGUIMgr ), _TCFL("kGameGUIMgr_KEY"), },
{ kGameGUIDynamicDlg_KEY, CLASS_INDEX_SCOPED( plSceneNode ), "kGameGUIDynamicDlg_KEY", }, { kGameGUIDynamicDlg_KEY, CLASS_INDEX_SCOPED( plSceneNode ), _TCFL("kGameGUIDynamicDlg_KEY"), },
{ kVirtualCamera1_KEY, CLASS_INDEX_SCOPED( plVirtualCam1 ), "kVirtualCamera_KEY", }, { kVirtualCamera1_KEY, CLASS_INDEX_SCOPED( plVirtualCam1 ), _TCFL("kVirtualCamera_KEY"), },
{ kDefaultCameraMod1_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), "kDefaultCameraMod1_KEY", }, { kDefaultCameraMod1_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), _TCFL("kDefaultCameraMod1_KEY"), },
{ kKIGUIGlue_KEY, CLASS_INDEX_SCOPED( pfKI ), "kKIGUIGlue_KEY", }, { kKIGUIGlue_KEY, CLASS_INDEX_SCOPED( pfKI ), _TCFL("kKIGUIGlue_KEY"), },
{ kClothingMgr_KEY, CLASS_INDEX_SCOPED( plClothingMgr ), "kClothingMgr_KEY", }, { kClothingMgr_KEY, CLASS_INDEX_SCOPED( plClothingMgr ), _TCFL("kClothingMgr_KEY"), },
{ kInputInterfaceMgr_KEY, CLASS_INDEX_SCOPED( plInputInterfaceMgr ), "kInputInterfaceMgr_KEY", }, { kInputInterfaceMgr_KEY, CLASS_INDEX_SCOPED( plInputInterfaceMgr ), _TCFL("kInputInterfaceMgr_KEY"), },
{ kAVIWriter_KEY, CLASS_INDEX_SCOPED( plAVIWriter ), "kAVIWriter_KEY", }, { kAVIWriter_KEY, CLASS_INDEX_SCOPED( plAVIWriter ), _TCFL("kAVIWriter_KEY"), },
{ kResManagerHelper_KEY, CLASS_INDEX_SCOPED( plResManagerHelper ), "kResManagerHelper_KEY", }, { kResManagerHelper_KEY, CLASS_INDEX_SCOPED( plResManagerHelper ), _TCFL("kResManagerHelper_KEY"), },
{ kAvatarMgr_KEY, CLASS_INDEX_SCOPED( plAvatarMgr ), "kAvatarMgr_KEY", }, { kAvatarMgr_KEY, CLASS_INDEX_SCOPED( plAvatarMgr ), _TCFL("kAvatarMgr_KEY"), },
{ kSimulationMgr_KEY, CLASS_INDEX_SCOPED( plSimulationMgr ), "kSimulationMgr_KEY", }, { kSimulationMgr_KEY, CLASS_INDEX_SCOPED( plSimulationMgr ), _TCFL("kSimulationMgr_KEY"), },
{ kTransitionCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), "kTransitionCamera_KEY", }, { kTransitionCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), _TCFL("kTransitionCamera_KEY"), },
{ kCCRMgr_KEY, CLASS_INDEX_SCOPED( plCCRMgr ), "kCCRMgr_KEY", }, { kCCRMgr_KEY, CLASS_INDEX_SCOPED( plCCRMgr ), _TCFL("kCCRMgr_KEY"), },
{ kNetClientCloneRoom_KEY, CLASS_INDEX_SCOPED( plSceneNode ), "kNetClientCloneRoom_KEY", }, { kNetClientCloneRoom_KEY, CLASS_INDEX_SCOPED( plSceneNode ), _TCFL("kNetClientCloneRoom_KEY"), },
{ kMarkerMgr_KEY, CLASS_INDEX_SCOPED( pfMarkerMgr ), "kMarkerMgr_KEY", }, { kMarkerMgr_KEY, CLASS_INDEX_SCOPED( pfMarkerMgr ), _TCFL("kMarkerMgr_KEY"), },
{ kAutoProfile_KEY, CLASS_INDEX_SCOPED( plAutoProfile ), "kAutoProfile_KEY", }, { kAutoProfile_KEY, CLASS_INDEX_SCOPED( plAutoProfile ), _TCFL("kAutoProfile_KEY"), },
{ kGlobalVisMgr_KEY, CLASS_INDEX_SCOPED( plVisMgr ), "kGlobalVisMgr_KEY", }, { kGlobalVisMgr_KEY, CLASS_INDEX_SCOPED( plVisMgr ), _TCFL("kGlobalVisMgr_KEY"), },
{ kFontCache_KEY, CLASS_INDEX_SCOPED( plFontCache ), "kFontCache_KEY", }, { kFontCache_KEY, CLASS_INDEX_SCOPED( plFontCache ), _TCFL("kFontCache_KEY"), },
{ kRelevanceMgr_KEY, CLASS_INDEX_SCOPED( plRelevanceMgr ), "kRelevanceMgr_KEY", }, { kRelevanceMgr_KEY, CLASS_INDEX_SCOPED( plRelevanceMgr ), _TCFL("kRelevanceMgr_KEY"), },
{ kJournalBookMgr_KEY, CLASS_INDEX_SCOPED( pfJournalBook ), "kJournalBookMgr_KEY" }, { kJournalBookMgr_KEY, CLASS_INDEX_SCOPED( pfJournalBook ), _TCFL("kJournalBookMgr_KEY") },
{ kAgeLoader_KEY, CLASS_INDEX_SCOPED( plAgeLoader), "kAgeLoader_KEY" }, { kAgeLoader_KEY, CLASS_INDEX_SCOPED( plAgeLoader), _TCFL("kAgeLoader_KEY") },
{ kBuiltIn3rdPersonCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), "kBuiltIn3rdPersonCamera_KEY", }, { kBuiltIn3rdPersonCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), _TCFL("kBuiltIn3rdPersonCamera_KEY"), },
{ kSecurePreloader_KEY, CLASS_INDEX_SCOPED( pfSecurePreloader ), "kSecurePreloader_KEY", }, { kSecurePreloader_KEY, CLASS_INDEX_SCOPED( pfSecurePreloader ), _TCFL("kSecurePreloader_KEY"), },
{ kLast_Fixed_KEY, CLASS_INDEX_SCOPED( plSceneObject ), "kLast_Fixed_KEY", } { kLast_Fixed_KEY, CLASS_INDEX_SCOPED( plSceneObject ), _TCFL("kLast_Fixed_KEY"), }
}; };
#undef _TCFL
//// plFixedKeyValidator ///////////////////////////////////////////////////// //// plFixedKeyValidator /////////////////////////////////////////////////////
@ -166,14 +168,13 @@ plUoid::plUoid(plFixedKeyId fixedkey)
{ {
hsAssert(fixedkey < kLast_Fixed_KEY, "Request for Fixed key is out of Range"); hsAssert(fixedkey < kLast_Fixed_KEY, "Request for Fixed key is out of Range");
fObjectName = nil;
Invalidate(); Invalidate();
plKeySeed* p= &SeedList[fixedkey]; plKeySeed* p= &SeedList[fixedkey];
fLocation = plLocation::kGlobalFixedLoc; fLocation = plLocation::kGlobalFixedLoc;
fClassType = p->fType; fClassType = p->fType;
fObjectName = hsStrcpy(p->fObj); fObjectName = p->fObj;
fObjectID = 0; fObjectID = 0;
fCloneID = 0; fCloneID = 0;
fClonePlayerID = 0; fClonePlayerID = 0;

5
Sources/Plasma/NucleusLib/pnKeyedObject/plKey.h

@ -44,6 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include "plRefFlags.h" #include "plRefFlags.h"
#include "plString.h"
class hsKeyedObject; class hsKeyedObject;
class plRefMsg; class plRefMsg;
@ -96,7 +97,7 @@ class plKeyData
{ {
public: public:
virtual const plUoid& GetUoid() const=0; virtual const plUoid& GetUoid() const=0;
virtual const char* GetName() const=0; virtual const plString& GetName() const=0;
virtual hsKeyedObject* GetObjectPtr()=0; virtual hsKeyedObject* GetObjectPtr()=0;
virtual hsKeyedObject* ObjectIsLoaded() const=0; virtual hsKeyedObject* ObjectIsLoaded() const=0;
@ -130,7 +131,7 @@ protected:
#ifdef HS_DEBUGGING #ifdef HS_DEBUGGING
// Debugging info fields // Debugging info fields
const char* fIDName; plString fIDName;
const char* fClassType; const char* fClassType;
#endif #endif

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

@ -55,8 +55,8 @@ plProfile_CreateMemCounter("Keys", "Memory", KeyMem);
static uint32_t CalcKeySize(plKeyImp* key) static uint32_t CalcKeySize(plKeyImp* key)
{ {
uint32_t nameLen = 0; uint32_t nameLen = 0;
if (key->GetUoid().GetObjectName()) if (!key->GetUoid().GetObjectName().IsNull())
nameLen = strlen(key->GetUoid().GetObjectName()) + 1; nameLen = key->GetUoid().GetObjectName().GetSize() + 1;
return sizeof(plKeyImp) + nameLen; return sizeof(plKeyImp) + nameLen;
} }
@ -81,7 +81,6 @@ plKeyImp::plKeyImp() :
fCloneOwner(nil) fCloneOwner(nil)
{ {
#ifdef HS_DEBUGGING #ifdef HS_DEBUGGING
fIDName = nil;
fClassType = nil; fClassType = nil;
#endif #endif
} }
@ -143,7 +142,7 @@ void plKeyImp::SetUoid(const plUoid& uoid)
#endif #endif
} }
const char* plKeyImp::GetName() const const plString& plKeyImp::GetName() const
{ {
return fUoid.GetObjectName(); return fUoid.GetObjectName();
} }

2
Sources/Plasma/NucleusLib/pnKeyedObject/plKeyImp.h

@ -59,7 +59,7 @@ public:
virtual ~plKeyImp(); virtual ~plKeyImp();
virtual const plUoid& GetUoid() const { return fUoid; } virtual const plUoid& GetUoid() const { return fUoid; }
virtual const char* GetName() const; virtual const plString& GetName() const;
virtual hsKeyedObject* GetObjectPtr(); virtual hsKeyedObject* GetObjectPtr();
virtual hsKeyedObject* ObjectIsLoaded() const; virtual hsKeyedObject* ObjectIsLoaded() const;

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

@ -167,7 +167,7 @@ hsBool plMsgForwarder::IForwardCallbackMsg(plMessage *msg)
if (--fc->fNumCallbacks == 0) if (--fc->fNumCallbacks == 0)
{ {
hsStatusMessageF("plEventCallbackMsg received, erasing, sender=%s, remoteMsg=%d\n", hsStatusMessageF("plEventCallbackMsg received, erasing, sender=%s, remoteMsg=%d\n",
msg->GetSender() ? msg->GetSender()->GetName() : "nil", msg->HasBCastFlag(plMessage::kNetNonLocal)); msg->GetSender() ? msg->GetSender()->GetName().c_str() : "nil", msg->HasBCastFlag(plMessage::kNetNonLocal));
fCallbacks.erase(eventMsg); fCallbacks.erase(eventMsg);
@ -190,7 +190,7 @@ hsBool plMsgForwarder::IForwardCallbackMsg(plMessage *msg)
else else
{ {
hsStatusMessageF("! Unknown plEventCallbackMsg received, sender=%s, remoteMsg=%d\n", hsStatusMessageF("! Unknown plEventCallbackMsg received, sender=%s, remoteMsg=%d\n",
msg->GetSender() ? msg->GetSender()->GetName() : "nil", msg->HasBCastFlag(plMessage::kNetNonLocal)); msg->GetSender() ? msg->GetSender()->GetName().c_str() : "nil", msg->HasBCastFlag(plMessage::kNetNonLocal));
hsAssert(0, "Unknown plEventCallbackMsg received"); hsAssert(0, "Unknown plEventCallbackMsg received");
} }
return true; return true;

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

@ -118,10 +118,9 @@ hsBool plLocation::IsVirtual() const
} }
// THIS SHOULD BE FOR DEBUGGING ONLY <hint hint> // THIS SHOULD BE FOR DEBUGGING ONLY <hint hint>
char* plLocation::StringIze(char* str) const // Format to displayable string plString plLocation::StringIze() const // Format to displayable string
{ {
sprintf(str, "S0x%xF0x%x", fSequenceNumber, int(fFlags)); return plString::Format("S0x%xF0x%x", fSequenceNumber, int(fFlags));
return str;
} }
plLocation plLocation::MakeReserved(uint32_t number) plLocation plLocation::MakeReserved(uint32_t number)
@ -136,21 +135,19 @@ plLocation plLocation::MakeNormal(uint32_t number)
//// plUoid ////////////////////////////////////////////////////////////////// //// plUoid //////////////////////////////////////////////////////////////////
plUoid::plUoid(const plLocation& location, uint16_t classType, const char* objectName, const plLoadMask& m) plUoid::plUoid(const plLocation& location, uint16_t classType, const plString& objectName, const plLoadMask& m)
{ {
fObjectName = nil;
Invalidate(); Invalidate();
fLocation = location; fLocation = location;
fClassType = classType; fClassType = classType;
fObjectName = hsStrcpy(objectName); fObjectName = objectName;
fLoadMask = m; fLoadMask = m;
fClonePlayerID = 0; fClonePlayerID = 0;
} }
plUoid::plUoid(const plUoid& src) plUoid::plUoid(const plUoid& src)
{ {
fObjectName = nil;
Invalidate(); Invalidate();
*this = src; *this = src;
} }
@ -162,7 +159,7 @@ plUoid::~plUoid()
void plUoid::Read(hsStream* s) void plUoid::Read(hsStream* s)
{ {
hsAssert(fObjectName == nil, "Reading over an old uoid? You're just asking for trouble, aren't you?"); hsAssert(fObjectName.IsNull(), "Reading over an old uoid? You're just asking for trouble, aren't you?");
// first read contents flags // first read contents flags
uint8_t contents = s->ReadByte(); uint8_t contents = s->ReadByte();
@ -178,7 +175,7 @@ void plUoid::Read(hsStream* s)
s->LogReadLE(&fClassType, "ClassType"); s->LogReadLE(&fClassType, "ClassType");
s->LogReadLE(&fObjectID, "ObjectID"); s->LogReadLE(&fObjectID, "ObjectID");
s->LogSubStreamPushDesc("ObjectName"); s->LogSubStreamPushDesc("ObjectName");
fObjectName = s->LogReadSafeString(); fObjectName = s->LogReadSafeString_TEMP();
// conditional cloneIDs read // conditional cloneIDs read
if (contents & kHasCloneIDs) if (contents & kHasCloneIDs)
@ -229,9 +226,7 @@ void plUoid::Invalidate()
fCloneID = 0; fCloneID = 0;
fClonePlayerID = 0; fClonePlayerID = 0;
fClassType = 0; fClassType = 0;
if (fObjectName) fObjectName = plString::Null;
delete [] fObjectName;
fObjectName = nil;
fLocation.Invalidate(); fLocation.Invalidate();
fLoadMask = plLoadMask::kAlways; fLoadMask = plLoadMask::kAlways;
@ -239,7 +234,7 @@ void plUoid::Invalidate()
hsBool plUoid::IsValid() const hsBool plUoid::IsValid() const
{ {
if (!fLocation.IsValid() || fObjectName == nil) if (!fLocation.IsValid() || fObjectName.IsNull())
return false; return false;
return true; return true;
@ -250,7 +245,7 @@ hsBool plUoid::operator==(const plUoid& u) const
return fLocation == u.fLocation return fLocation == u.fLocation
&& fLoadMask == u.fLoadMask && fLoadMask == u.fLoadMask
&& fClassType == u.fClassType && fClassType == u.fClassType
&& hsStrEQ(fObjectName, u.fObjectName) && fObjectName == u.fObjectName
&& fObjectID == u.fObjectID && fObjectID == u.fObjectID
&& fCloneID == u.fCloneID && fCloneID == u.fCloneID
&& fClonePlayerID == u.fClonePlayerID; && fClonePlayerID == u.fClonePlayerID;
@ -262,9 +257,7 @@ plUoid& plUoid::operator=(const plUoid& rhs)
fCloneID = rhs.fCloneID; fCloneID = rhs.fCloneID;
fClonePlayerID = rhs.fClonePlayerID; fClonePlayerID = rhs.fClonePlayerID;
fClassType = rhs.fClassType; fClassType = rhs.fClassType;
if (fObjectName) fObjectName = rhs.fObjectName;
delete [] fObjectName;
fObjectName = hsStrcpy(rhs.fObjectName);
fLocation = rhs.fLocation; fLocation = rhs.fLocation;
fLoadMask = rhs.fLoadMask; fLoadMask = rhs.fLoadMask;
@ -272,13 +265,12 @@ plUoid& plUoid::operator=(const plUoid& rhs)
} }
// THIS SHOULD BE FOR DEBUGGING ONLY <hint hint> // THIS SHOULD BE FOR DEBUGGING ONLY <hint hint>
char* plUoid::StringIze(char* str) const // Format to displayable string plString plUoid::StringIze() const // Format to displayable string
{ {
sprintf(str, "(0x%x:0x%x:%s:C:[%u,%u])", return plString::Format("(0x%x:0x%x:%s:C:[%u,%u])",
fLocation.GetSequenceNumber(), fLocation.GetSequenceNumber(),
int(fLocation.GetFlags()), int(fLocation.GetFlags()),
fObjectName, fObjectName.c_str(),
GetClonePlayerID(), GetClonePlayerID(),
GetCloneID()); GetCloneID());
return str;
} }

23
Sources/Plasma/NucleusLib/pnKeyedObject/plUoid.h

@ -57,6 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include "plFixedKey.h" #include "plFixedKey.h"
#include "plLoadMask.h" #include "plLoadMask.h"
#include "plString.h"
class hsStream; class hsStream;
@ -124,7 +125,7 @@ public:
bool operator<(const plLocation& loc ) const { return fSequenceNumber < loc.fSequenceNumber; } bool operator<(const plLocation& loc ) const { return fSequenceNumber < loc.fSequenceNumber; }
// THIS SHOULD BE FOR DEBUGGING ONLY <hint hint> // THIS SHOULD BE FOR DEBUGGING ONLY <hint hint>
char* StringIze(char* str) const; // Format to displayable string. Returns the same string for convenience plString StringIze() const; // Format to displayable string.
static plLocation MakeReserved(uint32_t number); static plLocation MakeReserved(uint32_t number);
static plLocation MakeNormal(uint32_t number); static plLocation MakeNormal(uint32_t number);
@ -143,15 +144,15 @@ public:
class plUoid class plUoid
{ {
public: public:
plUoid() { fObjectName = nil; Invalidate(); } plUoid() { Invalidate(); }
plUoid(const plLocation& location, uint16_t classType, const char* objectName, const plLoadMask& m=plLoadMask::kAlways); plUoid(const plLocation& location, uint16_t classType, const plString& objectName, const plLoadMask& m=plLoadMask::kAlways);
plUoid(plFixedKeyId fixedKey); plUoid(plFixedKeyId fixedKey);
plUoid(const plUoid& src); plUoid(const plUoid& src);
~plUoid(); ~plUoid();
const plLocation& GetLocation() const { return fLocation; } const plLocation& GetLocation() const { return fLocation; }
uint16_t GetClassType() const { return fClassType; } uint16_t GetClassType() const { return fClassType; }
const char* GetObjectName() const { return fObjectName; } const plString& GetObjectName() const { return fObjectName; }
const plLoadMask& GetLoadMask() const { return fLoadMask; } const plLoadMask& GetLoadMask() const { return fLoadMask; }
void Read(hsStream* s); void Read(hsStream* s);
@ -174,7 +175,7 @@ public:
void SetObjectID(uint32_t id) { fObjectID = id; } void SetObjectID(uint32_t id) { fObjectID = id; }
// THIS SHOULD BE FOR DEBUGGING ONLY <hint hint> // THIS SHOULD BE FOR DEBUGGING ONLY <hint hint>
char* StringIze(char* str) const; // Format to displayable string plString StringIze() const; // Format to displayable string
protected: protected:
enum ContentsFlags // for read/write functions enum ContentsFlags // for read/write functions
@ -183,11 +184,11 @@ protected:
kHasLoadMask = 0x2, kHasLoadMask = 0x2,
}; };
uint32_t fObjectID; uint32_t fObjectID;
uint32_t fClonePlayerID; // The ID of the player who made this clone uint32_t fClonePlayerID; // The ID of the player who made this clone
uint16_t fCloneID; // The ID of this clone (unique per client) uint16_t fCloneID; // The ID of this clone (unique per client)
uint16_t fClassType; uint16_t fClassType;
char* fObjectName; plString fObjectName;
plLocation fLocation; plLocation fLocation;
plLoadMask fLoadMask; plLoadMask fLoadMask;
}; };

12
Sources/Plasma/NucleusLib/pnMessage/plEventCallbackMsg.h

@ -63,14 +63,14 @@ enum CallbackEvent
class plEventCallbackMsg : public plMessage class plEventCallbackMsg : public plMessage
{ {
protected: protected:
public: public:
float fEventTime; // the time for time events float fEventTime; // the time for time events
CallbackEvent fEvent; // the event CallbackEvent fEvent; // the event
int16_t fIndex; // the index of the object we want the event to come from int16_t fIndex; // the index of the object we want the event to come from
// (where applicable, required for sounds) // (where applicable, required for sounds)
int16_t fRepeats; // -1 for infinite repeats, 0 for one call, no repeats int16_t fRepeats; // -1 for infinite repeats, 0 for one call, no repeats
int16_t fUser; // User defined data, useful for keeping track of multiple callbacks int16_t fUser; // User defined data, useful for keeping track of multiple callbacks
plEventCallbackMsg() : fEventTime(0.0f), fEvent((CallbackEvent)0), fRepeats(-1), fUser(0), fIndex(0) {;} plEventCallbackMsg() : fEventTime(0.0f), fEvent((CallbackEvent)0), fRepeats(-1), fUser(0), fIndex(0) {;}
plEventCallbackMsg (const plKey &s, plEventCallbackMsg (const plKey &s,
@ -78,7 +78,7 @@ public:
const double* t) : const double* t) :
plMessage(s, r, t), plMessage(s, r, t),
fEventTime(0.0f), fEvent((CallbackEvent)0), fRepeats(-1), fUser(0), fIndex(0) {;} fEventTime(0.0f), fEvent((CallbackEvent)0), fRepeats(-1), fUser(0), fIndex(0) {;}
plEventCallbackMsg(const plKey &receiver, CallbackEvent e, int idx=0, float t=0, int16_t repeats=-1, uint16_t user=0) : plEventCallbackMsg(const plKey &receiver, CallbackEvent e, int idx=0, float t=0, int16_t repeats=-1, uint16_t user=0) :
plMessage(nil, receiver, nil), fEvent(e), fIndex(idx), fEventTime(t), fRepeats(repeats), fUser(user) {} plMessage(nil, receiver, nil), fEvent(e), fIndex(idx), fEventTime(t), fRepeats(repeats), fUser(user) {}

42
Sources/Plasma/NucleusLib/pnMessage/plMessage.cpp

@ -256,6 +256,18 @@ int plMsgStdStringHelper::PokeBig(const char * buf, uint32_t bufsz, hsStream* st
return stream->GetPosition(); return stream->GetPosition();
} }
int plMsgStdStringHelper::Poke(const plString & stringref, hsStream* stream, const uint32_t peekOptions)
{
std::string temp = stringref.c_str();
return Poke(temp, stream, peekOptions);
}
int plMsgStdStringHelper::PokeBig(const plString & stringref, hsStream* stream, const uint32_t peekOptions)
{
std::string temp = stringref.c_str();
return PokeBig(temp, stream, peekOptions);
}
// STATIC // STATIC
int plMsgStdStringHelper::Peek(std::string & stringref, hsStream* stream, const uint32_t peekOptions) int plMsgStdStringHelper::Peek(std::string & stringref, hsStream* stream, const uint32_t peekOptions)
{ {
@ -301,6 +313,22 @@ int plMsgStdStringHelper::PeekBig(std::string & stringref, hsStream* stream, co
return stream->GetPosition(); return stream->GetPosition();
} }
int plMsgStdStringHelper::Peek(plString & stringref, hsStream* stream, const uint32_t peekOptions)
{
std::string temp;
int pos = Peek(temp, stream, peekOptions);
stringref = plString::FromIso8859_1(temp.c_str(), temp.size());
return pos;
}
int plMsgStdStringHelper::PeekBig(plString & stringref, hsStream* stream, const uint32_t peekOptions)
{
std::string temp;
int pos = PeekBig(temp, stream, peekOptions);
stringref = plString::FromIso8859_1(temp.c_str(), temp.size());
return pos;
}
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// STATIC // STATIC
@ -371,6 +399,20 @@ int plMsgCStringHelper::Peek(char *& str, hsStream* stream, const uint32_t peekO
return stream->GetPosition(); return stream->GetPosition();
} }
int plMsgCStringHelper::Poke(const plString & str, hsStream* stream, const uint32_t peekOptions)
{
return Poke(str.c_str(), stream, peekOptions);
}
int plMsgCStringHelper::Peek(plString & str, hsStream* stream, const uint32_t peekOptions)
{
char * temp = nil;
int pos = Peek(temp, stream, peekOptions);
str = plString::FromIso8859_1(temp);
delete [] temp;
return pos;
}
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////

14
Sources/Plasma/NucleusLib/pnMessage/plMessage.h

@ -50,6 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
class plKey; class plKey;
class hsStream; class hsStream;
class plString;
// Base class for messages only has enough info to route it // Base class for messages only has enough info to route it
// and send it over the wire (Read/Write). // and send it over the wire (Read/Write).
@ -134,12 +135,12 @@ public:
hsBool Send(const plKey r=nil, hsBool async=false); // Message will self-destruct after send. hsBool Send(const plKey r=nil, hsBool async=false); // Message will self-destruct after send.
hsBool SendAndKeep(const plKey r=nil, hsBool async=false); // Message won't self-destruct after send. hsBool SendAndKeep(const plKey r=nil, hsBool async=false); // Message won't self-destruct after send.
const double GetTimeStamp() const { return fTimeStamp; } double GetTimeStamp() const { return fTimeStamp; }
plMessage& SetTimeStamp(double t) { fTimeStamp = t; return *this; } plMessage& SetTimeStamp(double t) { fTimeStamp = t; return *this; }
hsBool HasBCastFlag(uint32_t f) const { return 0 != (fBCastFlags & f); } hsBool HasBCastFlag(uint32_t f) const { return 0 != (fBCastFlags & f); }
plMessage& SetBCastFlag(uint32_t f, hsBool on=true) { if( on )fBCastFlags |= f; else fBCastFlags &= ~f; return *this; } plMessage& SetBCastFlag(uint32_t f, hsBool on=true) { if( on )fBCastFlags |= f; else fBCastFlags &= ~f; return *this; }
void SetAllBCastFlags(uint32_t f) { fBCastFlags=f; } void SetAllBCastFlags(uint32_t f) { fBCastFlags=f; }
uint32_t GetAllBCastFlags() const { return fBCastFlags; } uint32_t GetAllBCastFlags() const { return fBCastFlags; }
@ -171,8 +172,12 @@ struct plMsgStdStringHelper
static int PokeBig(const std::string & stringref, hsStream* stream, const uint32_t peekOptions=0); static int PokeBig(const std::string & stringref, hsStream* stream, const uint32_t peekOptions=0);
static int Poke(const char * buf, uint32_t bufsz, hsStream* stream, const uint32_t peekOptions=0); static int Poke(const char * buf, uint32_t bufsz, hsStream* stream, const uint32_t peekOptions=0);
static int PokeBig(const char * buf, uint32_t bufsz, hsStream* stream, const uint32_t peekOptions=0); static int PokeBig(const char * buf, uint32_t bufsz, hsStream* stream, const uint32_t peekOptions=0);
static int Poke(const plString & stringref, hsStream* stream, const uint32_t peekOptions=0);
static int PokeBig(const plString & stringref, hsStream* stream, const uint32_t peekOptions=0);
static int Peek(std::string & stringref, hsStream* stream, const uint32_t peekOptions=0); static int Peek(std::string & stringref, hsStream* stream, const uint32_t peekOptions=0);
static int PeekBig(std::string & stringref, hsStream* stream, const uint32_t peekOptions=0); static int PeekBig(std::string & stringref, hsStream* stream, const uint32_t peekOptions=0);
static int Peek(plString & stringref, hsStream* stream, const uint32_t peekOptions=0);
static int PeekBig(plString & stringref, hsStream* stream, const uint32_t peekOptions=0);
}; };
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
@ -185,13 +190,16 @@ struct plMsgXtlStringHelper
}; };
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// reads/writes your char * field // reads/writes your char * field (deprecated)
struct plMsgCStringHelper struct plMsgCStringHelper
{ {
static int Poke(const char * str, hsStream* stream, const uint32_t peekOptions=0); static int Poke(const char * str, hsStream* stream, const uint32_t peekOptions=0);
// deletes str and reallocates. you must delete [] str; // deletes str and reallocates. you must delete [] str;
static int Peek(char *& str, hsStream* stream, const uint32_t peekOptions=0); static int Peek(char *& str, hsStream* stream, const uint32_t peekOptions=0);
static int Poke(const plString & str, hsStream* stream, const uint32_t peekOptions=0);
static int Peek(plString & str, hsStream* stream, const uint32_t peekOptions=0);
}; };
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////

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

@ -141,11 +141,10 @@ hsBool plLogicModBase::MsgReceive(plMessage* msg)
hsAssert(pSMsg->GetType() != plServerReplyMsg::kUnInit, "uninit server reply msg"); hsAssert(pSMsg->GetType() != plServerReplyMsg::kUnInit, "uninit server reply msg");
#if 1 #if 1
char str[256]; plNetClientApp::GetInstance()->DebugMsg("LM: LogicModifier %s recvd trigger request reply:%s, wasRequesting=%d, t=%f\n",
sprintf(str, "LM: LogicModifier %s recvd trigger request reply:%s, wasRequesting=%d, t=%f\n", GetKeyName(), GetKeyName().c_str(),
pSMsg->GetType() == plServerReplyMsg::kDeny ? "denied" : "confirmed", pSMsg->GetType() == plServerReplyMsg::kDeny ? "denied" : "confirmed",
HasFlag(kRequestingTrigger), hsTimer::GetSysSeconds()); HasFlag(kRequestingTrigger), hsTimer::GetSysSeconds());
plNetClientApp::GetInstance()->DebugMsg(str);
#endif #endif
if (pSMsg->GetType() == plServerReplyMsg::kDeny) if (pSMsg->GetType() == plServerReplyMsg::kDeny)
@ -191,21 +190,17 @@ void plLogicModBase::RequestTrigger(hsBool netRequest)
if (HasFlag(kTriggered)) if (HasFlag(kTriggered))
{ {
#if 1 #if 1
char str[256]; plNetClientApp::GetInstance()->DebugMsg("LM: %s ignoring RequestTrigger(), already triggered, t=%f\n",
sprintf(str, "LM: %s ignoring RequestTrigger(), already triggered, t=%f\n", GetKeyName(), GetKeyName().c_str(), hsTimer::GetSysSeconds());
hsTimer::GetSysSeconds());
plNetClientApp::GetInstance()->DebugMsg(str);
#endif #endif
return; return;
} }
if (HasFlag(kRequestingTrigger)) if (HasFlag(kRequestingTrigger))
{ {
#if 1 #if 1
char str[256]; plNetClientApp::GetInstance()->DebugMsg("LM: %s ignoring RequestTrigger(), already requesting trigger, t=%f\n",
sprintf(str, "LM: %s ignoring RequestTrigger(), already requesting trigger, t=%f\n", GetKeyName(), GetKeyName().c_str(), hsTimer::GetSysSeconds());
hsTimer::GetSysSeconds());
plNetClientApp::GetInstance()->DebugMsg(str);
#endif #endif
return; return;
@ -220,9 +215,8 @@ void plLogicModBase::RequestTrigger(hsBool netRequest)
SetFlag(kRequestingTrigger); SetFlag(kRequestingTrigger);
#if 1 #if 1
char str[256]; plNetClientApp::GetInstance()->DebugMsg("LM: %s Setting RequestingTriggert=%f\n",
sprintf(str, "LM: %s Setting RequestingTriggert=%f\n", GetKeyName(), hsTimer::GetSysSeconds()); GetKeyName().c_str(), hsTimer::GetSysSeconds());
plNetClientApp::GetInstance()->DebugMsg(str);
#endif #endif
} }
@ -256,12 +250,10 @@ void plLogicModBase::PreTrigger(hsBool netRequest)
void plLogicModBase::Trigger(hsBool netRequest) void plLogicModBase::Trigger(hsBool netRequest)
{ {
#if 1 #if 1
char str[256]; plNetClientApp::GetInstance()->DebugMsg("LogicModifier %s is triggering, activatorType=%d\n",
sprintf(str, "LogicModifier %s is triggering, activatorType=%d\n", GetKeyName().c_str(), HasFlag(kTypeActivator));
GetKeyName(), HasFlag(kTypeActivator));
plNetClientApp::GetInstance()->DebugMsg(str);
#endif #endif
ClearFlag(kRequestingTrigger); ClearFlag(kRequestingTrigger);
if (!HasFlag(kMultiTrigger)) if (!HasFlag(kMultiTrigger))
SetFlag(kTriggered); SetFlag(kTriggered);

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

@ -178,7 +178,7 @@ public:
// functions that all net client apps should implement // functions that all net client apps should implement
virtual int SendMsg(plNetMessage* msg) = 0; virtual int SendMsg(plNetMessage* msg) = 0;
virtual uint32_t GetPlayerID() const = 0; virtual uint32_t GetPlayerID() const = 0;
virtual const char * GetPlayerName( const plKey avKey=nil ) const = 0; virtual plString GetPlayerName( const plKey avKey=nil ) const = 0;
// commonly used net client app functions // commonly used net client app functions
virtual float GetCurrentAgeTimeOfDayPercent() const { hsAssert(false, "stub"); return 0.; } virtual float GetCurrentAgeTimeOfDayPercent() const { hsAssert(false, "stub"); return 0.; }

30
Sources/Plasma/NucleusLib/pnNetCommon/plNetServers.h

@ -102,8 +102,8 @@ class plNetServerAgentConstants
{ {
public: public:
static const char* GetName() { return "Server_Agent"; } static const char* GetName() { return "Server_Agent"; }
static const uint16_t GetPort() { return 4800; } static uint16_t GetPort() { return 4800; }
static const plNetServerConstants::ServerTypes GetType() { return plNetServerConstants::kAgent; } static plNetServerConstants::ServerTypes GetType() { return plNetServerConstants::kAgent; }
}; };
@ -111,8 +111,8 @@ class plNetLookupServerConstants
{ {
public: public:
static const char* GetName() { return "Lookup_Server"; } static const char* GetName() { return "Lookup_Server"; }
static const uint16_t GetPort() { return 2000; } static uint16_t GetPort() { return 2000; }
static const plNetServerConstants::ServerTypes GetType() { return plNetServerConstants::kLookup; } static plNetServerConstants::ServerTypes GetType() { return plNetServerConstants::kLookup; }
}; };
@ -120,8 +120,8 @@ class plNetLobbyServerConstants
{ {
public: public:
static const char* GetName() { return "Generated_Lobby"; } static const char* GetName() { return "Generated_Lobby"; }
static const uint16_t GetPort() { return 5000; } static uint16_t GetPort() { return 5000; }
static const plNetServerConstants::ServerTypes GetType() { return plNetServerConstants::kLobby; } static plNetServerConstants::ServerTypes GetType() { return plNetServerConstants::kLobby; }
}; };
@ -129,8 +129,8 @@ class plNetVaultServerConstants
{ {
public: public:
static const char* GetName() { return "Vault_Server"; } static const char* GetName() { return "Vault_Server"; }
static const uint16_t GetPort() { return 2001; } static uint16_t GetPort() { return 2001; }
static const plNetServerConstants::ServerTypes GetType() { return plNetServerConstants::kVault; } static plNetServerConstants::ServerTypes GetType() { return plNetServerConstants::kVault; }
}; };
@ -138,8 +138,8 @@ class plNetAuthServerConstants
{ {
public: public:
static const char* GetName() { return "Auth_Server"; } static const char* GetName() { return "Auth_Server"; }
static const uint16_t GetPort() { return 2002; } static uint16_t GetPort() { return 2002; }
static const plNetServerConstants::ServerTypes GetType() { return plNetServerConstants::kAuth; } static plNetServerConstants::ServerTypes GetType() { return plNetServerConstants::kAuth; }
}; };
@ -147,17 +147,17 @@ class plNetAdminServerConstants
{ {
public: public:
static const char* GetName() { return "Admin_Server"; } static const char* GetName() { return "Admin_Server"; }
static const uint16_t GetPort() { return 2003; } static uint16_t GetPort() { return 2003; }
static const plNetServerConstants::ServerTypes GetType() { return plNetServerConstants::kAdmin; } static plNetServerConstants::ServerTypes GetType() { return plNetServerConstants::kAdmin; }
}; };
class plNetGameServerConstants class plNetGameServerConstants
{ {
public: public:
static const char* GetName() { return "Game_Server"; } static const char* GetName() { return "Game_Server"; }
static const uint16_t GetLowPort() { return 5001;} static uint16_t GetLowPort() { return 5001;}
static const uint16_t GetHighPort() { return 6001;} static uint16_t GetHighPort() { return 6001;}
static const plNetServerConstants::ServerTypes GetType() { return plNetServerConstants::kGame; } static plNetServerConstants::ServerTypes GetType() { return plNetServerConstants::kGame; }
}; };

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

@ -236,7 +236,7 @@ hsBool plSynchedObject::DirtySynchState(const char* SDLStateName, uint32_t synch
{ {
if (plNetClientApp::GetInstance()) if (plNetClientApp::GetInstance())
plNetClientApp::GetInstance()->DebugMsg("Queueing SDL state with 'maybe' ownership, obj %s, sdl %s", plNetClientApp::GetInstance()->DebugMsg("Queueing SDL state with 'maybe' ownership, obj %s, sdl %s",
GetKeyName(), SDLStateName); GetKeyName().c_str(), SDLStateName);
} }
} }

13
Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp

@ -47,6 +47,11 @@ plUUID::plUUID()
Clear(); Clear();
} }
plUUID::plUUID( const plString & s )
{
FromString( s );
}
plUUID::plUUID( const char * s ) plUUID::plUUID( const char * s )
{ {
FromString( s ); FromString( s );
@ -73,10 +78,10 @@ void plUUID::Write( hsStream * s)
s->Write( sizeof( fData ), (const void*)fData ); s->Write( sizeof( fData ), (const void*)fData );
} }
const char * plUUID::AsString() const { plString plUUID::AsString() const {
static std::string str; plString str;
ToStdString(str); ToString(str);
return str.c_str(); return str;
} }
plUUID::operator Uuid () const { plUUID::operator Uuid () const {

10
Sources/Plasma/NucleusLib/pnUUID/pnUUID.h

@ -47,6 +47,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnUtils/pnUtUuid.h" #include "pnUtils/pnUtUuid.h"
class hsStream; class hsStream;
class plString;
class plUUID class plUUID
{ {
@ -62,6 +63,7 @@ public:
plUUID(); plUUID();
plUUID( const char * s ); plUUID( const char * s );
plUUID( const plString & s );
plUUID( const plUUID & other ); plUUID( const plUUID & other );
plUUID( const Uuid & uuid ); plUUID( const Uuid & uuid );
void Clear(); void Clear();
@ -72,12 +74,12 @@ public:
int CompareTo( const plUUID * v ) const; int CompareTo( const plUUID * v ) const;
bool IsEqualTo( const plUUID * v ) const; bool IsEqualTo( const plUUID * v ) const;
bool FromString( const char * str ); bool FromString( const char * str );
bool ToStdString( std::string & out ) const; bool FromString( const plString & str ) { return FromString( str.c_str() ); }
inline std::string AsStdString() const { return AsString(); } bool ToString( plString & out ) const;
const char * AsString() const; // returns static buffer plString AsString() const;
void Read( hsStream * s ); void Read( hsStream * s );
void Write( hsStream * s ); void Write( hsStream * s );
operator std::string ( void ) const { return AsStdString();} operator plString ( void ) const { return AsString();}
bool operator==( const plUUID & other ) const { return IsEqualTo( &other ); } bool operator==( const plUUID & other ) const { return IsEqualTo( &other ); }
bool operator!=( const plUUID & other ) const { return !IsEqualTo( &other ); } bool operator!=( const plUUID & other ) const { return !IsEqualTo( &other ); }
int operator <( const plUUID & other ) const { return CompareTo( &other ); } int operator <( const plUUID & other ) const { return CompareTo( &other ); }

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

@ -106,13 +106,13 @@ bool plUUID::FromString( const char * str )
return true; return true;
} }
bool plUUID::ToStdString( std::string & out ) const bool plUUID::ToString( plString & out ) const
{ {
uuid_t g; uuid_t g;
plUUIDHelper::CopyToNative( g, this ); plUUIDHelper::CopyToNative( g, this );
char buf[40]; char buf[40];
uuid_unparse( g, buf ); uuid_unparse( g, buf );
out = buf; out = _TEMP_CONVERT_FROM_LITERAL( buf );
return true; return true;
} }

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

@ -88,15 +88,15 @@ bool plUUID::FromString( const char * str )
return RPC_S_OK == UuidFromString( (unsigned char *)str, (GUID *)this ); return RPC_S_OK == UuidFromString( (unsigned char *)str, (GUID *)this );
} }
bool plUUID::ToStdString( std::string & out ) const bool plUUID::ToString( plString & out ) const
{ {
out = ""; out = _TEMP_CONVERT_FROM_LITERAL("");
unsigned char * ubuf; unsigned char * ubuf;
RPC_STATUS s; RPC_STATUS s;
s = UuidToString( (GUID *) this, &ubuf ); s = UuidToString( (GUID *) this, &ubuf );
bool success = ( s==RPC_S_OK ); bool success = ( s==RPC_S_OK );
if ( success ) if ( success )
out = (char*)ubuf; out = plString::FromIso8859_1( (char*)ubuf );
RpcStringFree( &ubuf ); RpcStringFree( &ubuf );
return success; return success;
} }

2
Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.h

@ -135,7 +135,7 @@ public:
bool ReadFromFile( const char *fileNameToReadFrom ) ; bool ReadFromFile( const char *fileNameToReadFrom ) ;
void Read(hsStream* stream); void Read(hsStream* stream);
void Write(hsStream* stream) const; void Write(hsStream* stream) const;
// Overload for plInitSectionTokenReader // Overload for plInitSectionTokenReader
virtual const char *GetSectionName( void ) const; virtual const char *GetSectionName( void ) const;

18
Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoaderPaging.cpp

@ -69,17 +69,17 @@ bool ReportRoomToServer(const plKey &key)
plLocation keyLoc=key->GetUoid().GetLocation(); plLocation keyLoc=key->GetUoid().GetLocation();
bool skip=(keyLoc.IsReserved() || keyLoc.IsVirtual() || bool skip=(keyLoc.IsReserved() || keyLoc.IsVirtual() ||
// HACK ALERT - replace with new uoid type flags // HACK ALERT - replace with new uoid type flags
(key->GetName() && (!key->GetName().IsNull() &&
(!strnicmp(key->GetName(), "global", 6) || (!key->GetName().CompareN("global", 6, plString::kCaseInsensitive) ||
strstr(key->GetName(), "_Male") || key->GetName().Find("_Male") >= 0 ||
strstr(key->GetName(), "_Female") key->GetName().Find("_Female") >= 0
) )
) )
); );
if (skip) if (skip)
hsLogEntry(plNetApp::StaticDebugMsg("Not reporting room %s to server, reserved=%d, virtual=%d", hsLogEntry(plNetApp::StaticDebugMsg("Not reporting room %s to server, reserved=%d, virtual=%d",
key->GetName(), keyLoc.IsReserved(), keyLoc.IsVirtual())); key->GetName().c_str(), keyLoc.IsReserved(), keyLoc.IsVirtual()));
return !skip; return !skip;
} }
@ -110,7 +110,7 @@ void plAgeLoader::FinishedPagingInRoom(plKey* rmKey, int numRms)
continue; continue;
pagingMsg->AddRoom(key); pagingMsg->AddRoom(key);
hsLogEntry(nc->DebugMsg("\tSending PageIn/RequestState msg, room=%s\n", key->GetName())); hsLogEntry(nc->DebugMsg("\tSending PageIn/RequestState msg, room=%s\n", key->GetName().c_str()));
} }
if( pagingMsg->GetNumRooms() > 0 ) // all rooms were reserved if( pagingMsg->GetNumRooms() > 0 ) // all rooms were reserved
{ {
@ -148,7 +148,7 @@ void plAgeLoader::FinishedPagingOutRoom(plKey* rmKey, int numRms)
if( found != fPendingPageOuts.end() ) if( found != fPendingPageOuts.end() )
{ {
fPendingPageOuts.erase( found ); fPendingPageOuts.erase( found );
nc->DebugMsg("Finished paging out room %s", rmKey[i]->GetName()); nc->DebugMsg("Finished paging out room %s", rmKey[i]->GetName().c_str());
} }
} }
@ -179,7 +179,7 @@ void plAgeLoader::StartPagingOutRoom(plKey* rmKey, int numRms)
continue; continue;
pagingMsg.AddRoom(rmKey[i]); pagingMsg.AddRoom(rmKey[i]);
nc->DebugMsg("\tSending PageOut msg, room=%s", rmKey[i]->GetName()); nc->DebugMsg("\tSending PageOut msg, room=%s", rmKey[i]->GetName().c_str());
} }
if (!pagingMsg.GetNumRooms()) // all rooms were reserved if (!pagingMsg.GetNumRooms()) // all rooms were reserved
@ -205,7 +205,7 @@ void plAgeLoader::IgnorePagingOutRoom(plKey* rmKey, int numRms)
if( found != fPendingPageOuts.end() ) if( found != fPendingPageOuts.end() )
{ {
fPendingPageOuts.erase( found ); fPendingPageOuts.erase( found );
nc->DebugMsg("Ignoring paged out room %s", rmKey[i]->GetName()); nc->DebugMsg("Ignoring paged out room %s", rmKey[i]->GetName().c_str());
} }
} }

9
Sources/Plasma/PubUtilLib/plAudible/plWinAudible.cpp

@ -421,7 +421,8 @@ void plWinAudible::SetFilename(int index, const char *filename, hsBool isCompres
} }
else else
{ {
plStatusLog::AddLineS("audio.log", "Cannot set filename of non-streaming sound. %s", fSoundObjs[ index ]->GetKeyName()); plStatusLog::AddLineS("audio.log", "Cannot set filename of non-streaming sound. %s",
fSoundObjs[ index ]->GetKeyName().c_str());
} }
} }
@ -473,9 +474,7 @@ void plWinAudible::Read(hsStream* s, hsResMgr* mgr)
void plWinAudible::IAssignSoundKey( plSound *sound, const char *name, uint32_t i ) void plWinAudible::IAssignSoundKey( plSound *sound, const char *name, uint32_t i )
{ {
char keyName[ 256 ]; plString keyName = plString::Format( "%s_%d", name, i );
sprintf( keyName, "%s_%d", name, i );
hsgResMgr::ResMgr()->NewKey( keyName, sound, GetKey() ? GetKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc ); hsgResMgr::ResMgr()->NewKey( keyName, sound, GetKey() ? GetKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc );
} }
@ -607,7 +606,7 @@ int plWinAudible::GetSoundIndex(const char *keyname) const
for( int i = 0; i < fSoundObjs.Count(); i++) for( int i = 0; i < fSoundObjs.Count(); i++)
{ {
if(!fSoundObjs[i]) continue; if(!fSoundObjs[i]) continue;
if(!strcmp(fSoundObjs[i]->GetKeyName(), keyname )) if(!fSoundObjs[i]->GetKeyName().Compare( keyname ))
{ {
return i; return i;
} }

10
Sources/Plasma/PubUtilLib/plAudio/plAudioSystem.cpp

@ -798,7 +798,7 @@ void plAudioSystem::IUpdateSoftSounds( const hsPoint3 &newPosition )
sortedList->fRank, sortedList->fRank,
sound->GetVolume() ? sound->GetVolumeRank() / sound->GetVolume() : 0, sound->GetVolume() ? sound->GetVolumeRank() / sound->GetVolume() : 0,
sound->GetEAXSettings().GetCurrSofts().GetOcclusion(), sound->GetEAXSettings().GetCurrSofts().GetOcclusion(),
sound->GetKeyName() sound->GetKeyName().c_str()
); );
} }
else else
@ -809,7 +809,7 @@ void plAudioSystem::IUpdateSoftSounds( const hsPoint3 &newPosition )
sound->GetPriority(), sound->GetPriority(),
sortedList->fRank, sortedList->fRank,
sound->GetVolume() ? sound->GetVolumeRank() / sound->GetVolume() : 0, sound->GetVolume() ? sound->GetVolumeRank() / sound->GetVolume() : 0,
sound->GetKeyName() sound->GetKeyName().c_str()
); );
} }
i++; i++;
@ -833,7 +833,7 @@ void plAudioSystem::IUpdateSoftSounds( const hsPoint3 &newPosition )
"%d %1.2f %s", "%d %1.2f %s",
sound->GetPriority(), sound->GetPriority(),
sound->GetVolume() ? sound->GetVolumeRank() / sound->GetVolume() : 0, sound->GetVolume() ? sound->GetVolumeRank() / sound->GetVolume() : 0,
sound->GetKeyName() sound->GetKeyName().c_str()
); );
} }
@ -934,7 +934,7 @@ hsBool plAudioSystem::MsgReceive(plMessage* msg)
{ {
//if( fListener ) //if( fListener )
{ {
plProfile_BeginLap(AudioUpdate, this->GetKey()->GetUoid().GetObjectName()); plProfile_BeginLap(AudioUpdate, this->GetKey()->GetUoid().GetObjectName().c_str());
if(hsTimer::GetMilliSeconds() - fLastUpdateTimeMs > UPDATE_TIME_MS) if(hsTimer::GetMilliSeconds() - fLastUpdateTimeMs > UPDATE_TIME_MS)
{ {
IUpdateSoftSounds( fCurrListenerPos ); IUpdateSoftSounds( fCurrListenerPos );
@ -947,7 +947,7 @@ hsBool plAudioSystem::MsgReceive(plMessage* msg)
} }
//fCommittedListenerPos = fCurrListenerPos; //fCommittedListenerPos = fCurrListenerPos;
} }
plProfile_EndLap(AudioUpdate, this->GetKey()->GetUoid().GetObjectName()); plProfile_EndLap(AudioUpdate, this->GetKey()->GetUoid().GetObjectName().c_str());
} }
return true; return true;

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

@ -141,10 +141,10 @@ void plSound::IPrintDbgMessage( const char *msg, hsBool isError )
if( isError ) if( isError )
// ourLog->AddLineF( plStatusLog::kRed, "ERROR: %s (%s)", msg, GetKey() ? GetKeyName() : "unkeyed" ); // ourLog->AddLineF( plStatusLog::kRed, "ERROR: %s (%s)", msg, GetKey() ? GetKeyName() : "unkeyed" );
ourLog->AddLineS( "audio.log", plStatusLog::kRed, "ERROR: %s (%s)", msg, GetKey() ? GetKeyName() : "unkeyed" ); ourLog->AddLineS( "audio.log", plStatusLog::kRed, "ERROR: %s (%s)", msg, GetKey() ? GetKeyName().c_str() : "unkeyed" );
else else
// ourLog->AddLineF( "%s (%s)", msg, GetKey() ? GetKeyName() : "unkeyed" ); // ourLog->AddLineF( "%s (%s)", msg, GetKey() ? GetKeyName() : "unkeyed" );
ourLog->AddLineS( "audio.log", "%s (%s)", msg, GetKey() ? GetKeyName() : "unkeyed" ); ourLog->AddLineS( "audio.log", "%s (%s)", msg, GetKey() ? GetKeyName().c_str() : "unkeyed" );
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -163,7 +163,7 @@ void plSound::IUpdateDebugPlate( void )
fDebugPlate->SetPosition( -0.5, 0 ); fDebugPlate->SetPosition( -0.5, 0 );
fDebugPlate->SetDataRange( 0, 100, 100 ); fDebugPlate->SetDataRange( 0, 100, 100 );
fDebugPlate->SetColors( 0x80202000 ); fDebugPlate->SetColors( 0x80202000 );
fDebugPlate->SetTitle( (char *)GetKeyName() ); // Bleah fDebugPlate->SetTitle( _TEMP_CONVERT_TO_CONST_CHAR( GetKeyName() ) ); // Bleah
fDebugPlate->SetLabelText( "Desired", "Curr", "Soft", "Dist" ); fDebugPlate->SetLabelText( "Desired", "Curr", "Soft", "Dist" );
} }
@ -190,7 +190,7 @@ void plSound::SetCurrDebugPlate( const plKey soundKey )
{ {
fDebugPlate->ClearData(); fDebugPlate->ClearData();
fDebugPlate->SetVisible( true ); fDebugPlate->SetVisible( true );
fDebugPlate->SetTitle( (char *)fCurrDebugPlateSound->GetKeyName() ); // Bleah fDebugPlate->SetTitle( _TEMP_CONVERT_TO_CONST_CHAR( fCurrDebugPlateSound->GetKeyName() ) ); // Bleah
} }
} }
} }
@ -590,7 +590,7 @@ void plSound::IStartFade( plFadeParams *params, float offsetIntoFade )
fFadeInParams.fVolStart = fCurrVolume; // Hopefully, we got to fFadedVolume, but maybe not fFadeInParams.fVolStart = fCurrVolume; // Hopefully, we got to fFadedVolume, but maybe not
fFadeInParams.fVolEnd = fDesiredVol; fFadeInParams.fVolEnd = fDesiredVol;
fCurrFadeParams = &fFadeInParams; fCurrFadeParams = &fFadeInParams;
plStatusLog::AddLineS("audio.log", "Fading in %s", GetKeyName()); plStatusLog::AddLineS("audio.log", "Fading in %s", GetKeyName().c_str());
} }
else else
fCurrFadeParams = params; fCurrFadeParams = params;
@ -809,7 +809,7 @@ bool plSound::ILoadDataBuffer( void )
if(!buffer) if(!buffer)
{ {
hsAssert(false, "unable to load sound buffer"); hsAssert(false, "unable to load sound buffer");
plStatusLog::AddLineS("audio.log", "Unable to load sound buffer: %s", GetKeyName()); plStatusLog::AddLineS("audio.log", "Unable to load sound buffer: %s", GetKeyName().c_str());
return false; return false;
} }
SetLength( buffer->GetDataLengthInSecs() ); SetLength( buffer->GetDataLengthInSecs() );

3
Sources/Plasma/PubUtilLib/plAudio/plVoiceChat.cpp

@ -408,8 +408,7 @@ plVoiceSound::plVoiceSound()
fEAXSettings.SetRoomParams(-1200, -100, 0, 0); fEAXSettings.SetRoomParams(-1200, -100, 0, 0);
fLastUpdate = 0; fLastUpdate = 0;
char keyName[32]; plString keyName = plString::Format("VoiceSound_%d", fCount);
snprintf(keyName, arrsize(keyName), "VoiceSound_%d", fCount);
fCount++; fCount++;
hsgResMgr::ResMgr()->NewKey(keyName, this, plLocation::kGlobalFixedLoc); hsgResMgr::ResMgr()->NewKey(keyName, this, plLocation::kGlobalFixedLoc);
} }

16
Sources/Plasma/PubUtilLib/plAudio/plWin32GroupedSound.cpp

@ -160,9 +160,8 @@ hsBool plWin32GroupedSound::LoadSound( hsBool is3D )
// We need it to be resident to read in // We need it to be resident to read in
if( retVal == plSoundBuffer::kError) if( retVal == plSoundBuffer::kError)
{ {
char str[ 256 ]; plString str = plString::Format("Unable to open .wav file %s", fDataBufferKey ? fDataBufferKey->GetName().c_str() : "nil");
sprintf( str, "Unable to open .wav file %s", fDataBufferKey ? fDataBufferKey->GetName() : "nil"); IPrintDbgMessage( str.c_str(), true );
IPrintDbgMessage( str, true );
fFailed = true; fFailed = true;
return false; return false;
} }
@ -229,9 +228,8 @@ hsBool plWin32GroupedSound::LoadSound( hsBool is3D )
IFillCurrentSound( 0 ); IFillCurrentSound( 0 );
// Logging // Logging
char str[ 256 ]; plString str = plString::Format(" Grouped %s %s allocated (%d msec).", buffer->GetFileName() != nil ? "file" : "buffer",
sprintf( str, " Grouped %s %s allocated (%d msec).", buffer->GetFileName() != nil ? "file" : "buffer", buffer->GetFileName() != nil ? buffer->GetFileName() : buffer->GetKey()->GetUoid().GetObjectName().c_str(),
buffer->GetFileName() != nil ? buffer->GetFileName() : buffer->GetKey()->GetUoid().GetObjectName(),
//fDSoundBuffer->IsHardwareAccelerated() ? "hardware" : "software", //fDSoundBuffer->IsHardwareAccelerated() ? "hardware" : "software",
//fDSoundBuffer->IsStaticVoice() ? "static" : "dynamic", //fDSoundBuffer->IsStaticVoice() ? "static" : "dynamic",
#ifdef PL_PROFILE_ENABLED #ifdef PL_PROFILE_ENABLED
@ -239,11 +237,11 @@ hsBool plWin32GroupedSound::LoadSound( hsBool is3D )
#else #else
0 ); 0 );
#endif #endif
IPrintDbgMessage( str ); IPrintDbgMessage( str.c_str() );
if( GetKey() != nil && GetKeyName() != nil && strstr( GetKeyName(), "Footstep" ) != nil ) if( GetKey() != nil && GetKeyName().Find( "Footstep" ) >= 0 )
; ;
else else
plStatusLog::AddLineS( "audioTimes.log", "%s (%s)", str, GetKey() ? GetKeyName() : "unkeyed" ); plStatusLog::AddLineS( "audioTimes.log", "%s (%s)", str.c_str(), GetKey() ? GetKeyName().c_str() : "unkeyed" );
fTotalBytes = bufferSize; fTotalBytes = bufferSize;

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

Loading…
Cancel
Save