Browse Source

Merge pull request #380 from zrax/nuke_hsStrcpy

Reduce dependency on hsStrcpy
Adam Johnson 11 years ago
parent
commit
acb92852c8
  1. 8
      Sources/Plasma/Apps/plClient/plClient.cpp
  2. 65
      Sources/Plasma/CoreLib/HeadSpin.cpp
  3. 2
      Sources/Plasma/CoreLib/HeadSpin.h
  4. 9
      Sources/Plasma/CoreLib/hsThread.cpp
  5. 5
      Sources/Plasma/CoreLib/hsThread.h
  6. 14
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp
  7. 4
      Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp
  8. 14
      Sources/Plasma/FeatureLib/pfConsole/pfGameConsoleCommands.cpp
  9. 6
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGameGUIMgr.cpp
  10. 29
      Sources/Plasma/FeatureLib/pfMessage/pfBackdoorMsg.h
  11. 34
      Sources/Plasma/FeatureLib/pfMessage/pfGameGUIMsg.h
  12. 15
      Sources/Plasma/FeatureLib/pfMessage/pfKIMsg.h
  13. 11
      Sources/Plasma/FeatureLib/pfMessage/plClothingMsg.h
  14. 135
      Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp
  15. 34
      Sources/Plasma/FeatureLib/pfPython/cyAvatar.h
  16. 4
      Sources/Plasma/FeatureLib/pfPython/cyAvatarGlue.cpp
  17. 14
      Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp
  18. 35
      Sources/Plasma/FeatureLib/pfPython/pyMoviePlayer.cpp
  19. 12
      Sources/Plasma/FeatureLib/pfPython/pyMoviePlayer.h
  20. 2
      Sources/Plasma/FeatureLib/pfPython/pyMoviePlayerGlue.cpp
  21. 10
      Sources/Plasma/FeatureLib/pfPython/pyPlayer.cpp
  22. 20
      Sources/Plasma/FeatureLib/pfPython/pyPlayer.h
  23. 8
      Sources/Plasma/FeatureLib/pfPython/pyPlayerGlue.cpp
  24. 28
      Sources/Plasma/NucleusLib/pnMessage/plNotifyMsg.cpp
  25. 10
      Sources/Plasma/NucleusLib/pnMessage/plNotifyMsg.h
  26. 74
      Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp
  27. 19
      Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.h
  28. 90
      Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp
  29. 6
      Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h
  30. 9
      Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp
  31. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.h
  32. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrain.h
  33. 108
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp
  34. 12
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.h
  35. 14
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.cpp
  36. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.h
  37. 6
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainGeneric.cpp
  38. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainGeneric.h
  39. 25
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp
  40. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.h
  41. 147
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainStaticNPC.cpp
  42. 22
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp
  43. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.h
  44. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvTask.h
  45. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvTaskBrain.cpp
  46. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvTaskBrain.h
  47. 41
      Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.cpp
  48. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvTaskSeek.h
  49. 81
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp
  50. 29
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.h
  51. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarSDLModifier.cpp
  52. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp
  53. 20
      Sources/Plasma/PubUtilLib/plAvatar/plClothingLayout.h
  54. 2
      Sources/Plasma/PubUtilLib/plAvatar/plMultistageBehMod.cpp
  55. 26
      Sources/Plasma/PubUtilLib/plAvatar/plNPCSpawnMod.cpp
  56. 6
      Sources/Plasma/PubUtilLib/plAvatar/plNPCSpawnMod.h
  57. 22
      Sources/Plasma/PubUtilLib/plAvatar/plOneShotMod.cpp
  58. 9
      Sources/Plasma/PubUtilLib/plAvatar/plOneShotMod.h
  59. 122
      Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.cpp
  60. 29
      Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.h
  61. 17
      Sources/Plasma/PubUtilLib/plMessage/plLoadAgeMsg.cpp
  62. 10
      Sources/Plasma/PubUtilLib/plMessage/plLoadAgeMsg.h
  63. 26
      Sources/Plasma/PubUtilLib/plMessage/plMovieMsg.h
  64. 16
      Sources/Plasma/PubUtilLib/plModifier/plCloneSpawnModifier.cpp
  65. 5
      Sources/Plasma/PubUtilLib/plModifier/plCloneSpawnModifier.h
  66. 14
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp
  67. 10
      Sources/Plasma/PubUtilLib/plPipeline/DX/plDXDeviceRef.h
  68. 16
      Sources/Plasma/PubUtilLib/plPipeline/DX/plDXEnumerate.cpp
  69. 4
      Sources/Plasma/PubUtilLib/plPipeline/DX/plDXPixelShader.cpp
  70. 12
      Sources/Plasma/PubUtilLib/plPipeline/DX/plDXShader.cpp
  71. 7
      Sources/Plasma/PubUtilLib/plPipeline/DX/plDXShader.h
  72. 4
      Sources/Plasma/PubUtilLib/plPipeline/DX/plDXVertexShader.cpp
  73. 71
      Sources/Plasma/PubUtilLib/plPipeline/hsG3DDeviceSelector.cpp
  74. 42
      Sources/Plasma/PubUtilLib/plPipeline/hsG3DDeviceSelector.h
  75. 15
      Sources/Plasma/PubUtilLib/plPipeline/plBinkPlayer.h
  76. 1
      Sources/Tools/MaxComponent/CMakeLists.txt
  77. 41
      Sources/Tools/MaxComponent/WavFileStructs.h
  78. 14
      Sources/Tools/MaxComponent/plMultistageBehComponent.cpp
  79. 45
      Sources/Tools/MaxComponent/plMultistageStage.cpp
  80. 16
      Sources/Tools/MaxComponent/plMultistageStage.h
  81. 8
      Sources/Tools/MaxConvert/hsMaterialConverter.cpp
  82. 4
      Sources/Tools/MaxPlasmaMtls/Materials/plClothingMtl.cpp
  83. 3
      Sources/Tools/MaxPlasmaMtls/Materials/plClothingMtl.h
  84. 4
      Sources/Tools/MaxPlasmaMtls/Materials/plClothingMtlPBDec.h

8
Sources/Plasma/Apps/plClient/plClient.cpp

@ -860,7 +860,7 @@ bool plClient::MsgReceive(plMessage* msg)
//============================================================================ //============================================================================
bool plClient::IHandleMovieMsg(plMovieMsg* mov) bool plClient::IHandleMovieMsg(plMovieMsg* mov)
{ {
if( !(mov->GetFileName() && *mov->GetFileName()) ) if (mov->GetFileName().IsEmpty())
return true; return true;
int i; int i;
@ -869,7 +869,7 @@ bool plClient::IHandleMovieMsg(plMovieMsg* mov)
{ {
for( i = 0; i < fMovies.GetCount(); i++ ) for( i = 0; i < fMovies.GetCount(); i++ )
{ {
if( !stricmp(mov->GetFileName(), fMovies[i]->GetFileName()) ) if (mov->GetFileName().CompareI(fMovies[i]->GetFileName()) == 0)
break; break;
} }
} }
@ -929,7 +929,7 @@ bool plClient::IHandleMovieMsg(plMovieMsg* mov)
// If a movie has lost its filename, it means something went horribly wrong // If a movie has lost its filename, it means something went horribly wrong
// with playing it and it has shutdown. Or we just stopped it. Either way, // with playing it and it has shutdown. Or we just stopped it. Either way,
// we need to clear it out of our list. // we need to clear it out of our list.
if( !(fMovies[i]->GetFileName() && *fMovies[i]->GetFileName()) ) if (fMovies[i]->GetFileName().IsEmpty())
{ {
delete fMovies[i]; delete fMovies[i];
fMovies.Remove(i); fMovies.Remove(i);
@ -1948,7 +1948,7 @@ void plClient::IServiceMovies()
int i; int i;
for( i = 0; i < fMovies.GetCount(); i++ ) for( i = 0; i < fMovies.GetCount(); i++ )
{ {
hsAssert(fMovies[i]->GetFileName() && *fMovies[i]->GetFileName(), "Lost our movie"); hsAssert(!fMovies[i]->GetFileName().IsEmpty(), "Lost our movie");
if( !fMovies[i]->NextFrame() ) if( !fMovies[i]->NextFrame() )
{ {
delete fMovies[i]; delete fMovies[i];

65
Sources/Plasma/CoreLib/HeadSpin.cpp

@ -436,15 +436,13 @@ char *hsWStringToString( const wchar_t *str )
// Microsoft SAMPLE CODE // Microsoft SAMPLE CODE
// returns array of allocated version info strings or nil // returns array of allocated version info strings or nil
// //
char** DisplaySystemVersion() std::vector<plString> DisplaySystemVersion()
{ {
// TODO: I so want to std::vector<plString> this, but that requires
// including more headers in HeadSpin.h :(
#if HS_BUILD_FOR_WIN32 #if HS_BUILD_FOR_WIN32
#ifndef VER_SUITE_PERSONAL #ifndef VER_SUITE_PERSONAL
#define VER_SUITE_PERSONAL 0x200 #define VER_SUITE_PERSONAL 0x200
#endif #endif
hsTArray<char*> versionStrs; std::vector<plString> versionStrs;
OSVERSIONINFOEX osvi; OSVERSIONINFOEX osvi;
BOOL bOsVersionInfoEx; BOOL bOsVersionInfoEx;
@ -461,7 +459,7 @@ char** DisplaySystemVersion()
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
return FALSE; return std::vector<plString>();
} }
switch (osvi.dwPlatformId) switch (osvi.dwPlatformId)
@ -471,22 +469,25 @@ char** DisplaySystemVersion()
// Test for the product. // Test for the product.
if ( osvi.dwMajorVersion <= 4 ) if ( osvi.dwMajorVersion <= 4 )
versionStrs.Append(hsStrcpy("Microsoft Windows NT ")); versionStrs.push_back("Microsoft Windows NT ");
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 ) if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
versionStrs.Append(hsStrcpy ("Microsoft Windows 2000 ")); versionStrs.push_back("Microsoft Windows 2000 ");
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 ) if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
versionStrs.Append(hsStrcpy ("Microsoft Windows XP ")); versionStrs.push_back("Microsoft Windows XP ");
if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 ) if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 )
versionStrs.Append(hsStrcpy ("Microsoft Windows Vista ")); versionStrs.push_back("Microsoft Windows Vista ");
if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1 ) if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1 )
versionStrs.Append(hsStrcpy ("Microsoft Windows 7 ")); versionStrs.push_back("Microsoft Windows 7 ");
if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 2 ) if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 2 )
versionStrs.Append(hsStrcpy ("Microsoft Windows 8 ")); versionStrs.push_back("Microsoft Windows 8 ");
if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 3 )
versionStrs.push_back("Microsoft Windows 8.1 ");
// Test for product type. // Test for product type.
@ -495,19 +496,19 @@ char** DisplaySystemVersion()
if ( osvi.wProductType == VER_NT_WORKSTATION ) if ( osvi.wProductType == VER_NT_WORKSTATION )
{ {
if( osvi.wSuiteMask & VER_SUITE_PERSONAL ) if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
versionStrs.Append(hsStrcpy ( "Personal " )); versionStrs.push_back("Personal ");
else else
versionStrs.Append(hsStrcpy ( "Professional " )); versionStrs.push_back("Professional ");
} }
else if ( osvi.wProductType == VER_NT_SERVER ) else if ( osvi.wProductType == VER_NT_SERVER )
{ {
if( osvi.wSuiteMask & VER_SUITE_DATACENTER ) if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
versionStrs.Append(hsStrcpy ( "DataCenter Server " )); versionStrs.push_back("DataCenter Server ");
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
versionStrs.Append(hsStrcpy ( "Advanced Server " )); versionStrs.push_back("Advanced Server ");
else else
versionStrs.Append(hsStrcpy ( "Server " )); versionStrs.push_back("Server ");
} }
} }
else else
@ -523,28 +524,28 @@ char** DisplaySystemVersion()
(LPBYTE) szProductType, &dwBufLen); (LPBYTE) szProductType, &dwBufLen);
RegCloseKey( hKey ); RegCloseKey( hKey );
if ( lstrcmpi( "WINNT", szProductType) == 0 ) if ( lstrcmpi( "WINNT", szProductType) == 0 )
versionStrs.Append(hsStrcpy( "Professional " )); versionStrs.push_back("Professional ");
if ( lstrcmpi( "LANMANNT", szProductType) == 0 ) if ( lstrcmpi( "LANMANNT", szProductType) == 0 )
versionStrs.Append(hsStrcpy( "Server " )); versionStrs.push_back("Server ");
if ( lstrcmpi( "SERVERNT", szProductType) == 0 ) if ( lstrcmpi( "SERVERNT", szProductType) == 0 )
versionStrs.Append(hsStrcpy( "Advanced Server " )); versionStrs.push_back("Advanced Server ");
} }
// Display version, service pack (if any), and build number. // Display version, service pack (if any), and build number.
if ( osvi.dwMajorVersion <= 4 ) if ( osvi.dwMajorVersion <= 4 )
{ {
versionStrs.Append(hsStrcpy (plString::Format("version %d.%d %s (Build %d)\n", versionStrs.push_back(plString::Format("version %d.%d %s (Build %d)\n",
osvi.dwMajorVersion, osvi.dwMajorVersion,
osvi.dwMinorVersion, osvi.dwMinorVersion,
osvi.szCSDVersion, osvi.szCSDVersion,
osvi.dwBuildNumber & 0xFFFF).c_str())); osvi.dwBuildNumber & 0xFFFF));
} }
else else
{ {
versionStrs.Append(hsStrcpy (plString::Format("%s (Build %d)\n", versionStrs.push_back(plString::Format("%s (Build %d)\n",
osvi.szCSDVersion, osvi.szCSDVersion,
osvi.dwBuildNumber & 0xFFFF).c_str())); osvi.dwBuildNumber & 0xFFFF));
} }
break; break;
@ -552,34 +553,32 @@ char** DisplaySystemVersion()
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0) if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
{ {
versionStrs.Append(hsStrcpy ("Microsoft Windows 95 ")); versionStrs.push_back("Microsoft Windows 95 ");
if ( osvi.szCSDVersion[1] == 'C' || osvi.szCSDVersion[1] == 'B' ) if ( osvi.szCSDVersion[1] == 'C' || osvi.szCSDVersion[1] == 'B' )
versionStrs.Append(hsStrcpy("OSR2 " )); versionStrs.push_back("OSR2 ");
} }
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10) if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
{ {
versionStrs.Append(hsStrcpy ("Microsoft Windows 98 ")); versionStrs.push_back("Microsoft Windows 98 ");
if ( osvi.szCSDVersion[1] == 'A' ) if ( osvi.szCSDVersion[1] == 'A' )
versionStrs.Append(hsStrcpy("SE " )); versionStrs.push_back("SE ");
} }
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90) if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
{ {
versionStrs.Append(hsStrcpy ("Microsoft Windows Me ")); versionStrs.push_back("Microsoft Windows Me ");
} }
break; break;
case VER_PLATFORM_WIN32s: case VER_PLATFORM_WIN32s:
versionStrs.Append(hsStrcpy ("Microsoft Win32s ")); versionStrs.push_back("Microsoft Win32s ");
break; break;
} }
versionStrs.Append(nil); // terminator return versionStrs;
return versionStrs.DetachArray();
#else #else
return nil; return std::vector<plString>();
#endif #endif
} }

2
Sources/Plasma/CoreLib/HeadSpin.h

@ -438,8 +438,6 @@ inline float hsRadiansToDegrees(float rad) { return float(rad * (180 / M_PI)); }
#define hsFopen(name, mode) fopen(name, mode) #define hsFopen(name, mode) fopen(name, mode)
char** DisplaySystemVersion();
/************************ Debug/Error Macros **************************/ /************************ Debug/Error Macros **************************/
typedef void (*hsDebugMessageProc)(const char message[]); typedef void (*hsDebugMessageProc)(const char message[]);

9
Sources/Plasma/CoreLib/hsThread.cpp

@ -47,18 +47,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
hsReaderWriterLock::hsReaderWriterLock( const char * name, Callback * cb ) hsReaderWriterLock::hsReaderWriterLock(Callback * cb)
: fReaderCount( 0 ) : fReaderCount( 0 )
, fWriterSema( 1 ) , fWriterSema( 1 )
, fCallback( cb ) , fCallback( cb )
, fName( nil )
{ {
fName = hsStrcpy( name );
}
hsReaderWriterLock::~hsReaderWriterLock()
{
delete [] fName;
} }
void hsReaderWriterLock::LockForReading() void hsReaderWriterLock::LockForReading()

5
Sources/Plasma/CoreLib/hsThread.h

@ -223,13 +223,11 @@ public:
virtual void OnUnlockingForWrite( hsReaderWriterLock * lock ) {} virtual void OnUnlockingForWrite( hsReaderWriterLock * lock ) {}
virtual void OnUnlockedForWrite( hsReaderWriterLock * lock ) {} virtual void OnUnlockedForWrite( hsReaderWriterLock * lock ) {}
}; };
hsReaderWriterLock( const char * name="<unnamed>", Callback * cb=nil ); hsReaderWriterLock(Callback * cb=nullptr);
~hsReaderWriterLock();
void LockForReading(); void LockForReading();
void UnlockForReading(); void UnlockForReading();
void LockForWriting(); void LockForWriting();
void UnlockForWriting(); void UnlockForWriting();
const char * GetName() const { return fName; }
private: private:
int fReaderCount; int fReaderCount;
@ -237,7 +235,6 @@ private:
hsMutex fReaderLock; hsMutex fReaderLock;
hsSemaphore fWriterSema; hsSemaphore fWriterSema;
Callback * fCallback; Callback * fCallback;
char * fName;
}; };
class hsLockForReading class hsLockForReading

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

@ -4427,7 +4427,7 @@ PF_CONSOLE_CMD( Access,
return; return;
} }
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(params[0]); plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((const char *)params[0]);
if( !item ) if( !item )
return; return;
@ -6557,7 +6557,7 @@ PF_CONSOLE_CMD( Clothing, // Group name
{ {
hsTArray<plClosetItem> items; hsTArray<plClosetItem> items;
items.SetCount(1); items.SetCount(1);
items[0].fItem = plClothingMgr::GetClothingMgr()->FindItemByName(params[0]); items[0].fItem = plClothingMgr::GetClothingMgr()->FindItemByName((const char *)params[0]);
items[0].fOptions.fTint1.Set(params[1], params[2], params[3], 1.f); items[0].fOptions.fTint1.Set(params[1], params[2], params[3], 1.f);
items[0].fOptions.fTint2.Set(params[4], params[5], params[6], 1.f); items[0].fOptions.fTint2.Set(params[4], params[5], params[6], 1.f);
@ -6570,7 +6570,7 @@ PF_CONSOLE_CMD( Clothing, // Group name
"Has your avatar wear the item of clothing specified" ) // Help string "Has your avatar wear the item of clothing specified" ) // Help string
{ {
plArmatureMod *avMod = plAvatarMgr::GetInstance()->GetLocalAvatar(); plArmatureMod *avMod = plAvatarMgr::GetInstance()->GetLocalAvatar();
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(params[0]); plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((const char *)params[0]);
if (avMod && item) if (avMod && item)
{ {
@ -6584,7 +6584,7 @@ PF_CONSOLE_CMD( Clothing, // Group name
"Has your avatar remove the item of clothing specified" ) // Help string "Has your avatar remove the item of clothing specified" ) // Help string
{ {
plArmatureMod *avMod = plAvatarMgr::GetInstance()->GetLocalAvatar(); plArmatureMod *avMod = plAvatarMgr::GetInstance()->GetLocalAvatar();
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(params[0]); plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((const char *)params[0]);
if (avMod && item) if (avMod && item)
{ {
@ -6598,7 +6598,7 @@ PF_CONSOLE_CMD( Clothing, // Group name
"Change the color of an item of clothing you're wearing" ) // Help string "Change the color of an item of clothing you're wearing" ) // Help string
{ {
plArmatureMod *avMod = plAvatarMgr::GetInstance()->GetLocalAvatar(); plArmatureMod *avMod = plAvatarMgr::GetInstance()->GetLocalAvatar();
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(params[0]); plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((const char *)params[0]);
uint8_t layer; uint8_t layer;
if ((int)params[4] == 2) if ((int)params[4] == 2)
layer = plClothingElement::kLayerTint2; layer = plClothingElement::kLayerTint2;
@ -6652,7 +6652,7 @@ PF_CONSOLE_CMD( Clothing,
"string name", "string name",
"Switch your avatar to a different gender ('Male' / 'Female')" ) "Switch your avatar to a different gender ('Male' / 'Female')" )
{ {
plClothingMgr::ChangeAvatar(params[0]); plClothingMgr::ChangeAvatar((const char *)params[0]);
} }
PF_CONSOLE_CMD( Clothing, // Group name PF_CONSOLE_CMD( Clothing, // Group name
@ -6846,7 +6846,7 @@ PF_CONSOLE_CMD( Python,
const char* extraParms = ""; const char* extraParms = "";
if (numParams > 1) if (numParams > 1)
extraParms = params[1]; extraParms = params[1];
pfBackdoorMsg *msg = new pfBackdoorMsg( params[0],extraParms ); pfBackdoorMsg *msg = new pfBackdoorMsg((const char *)params[0], extraParms);
// send it off // send it off
plgDispatch::MsgSend( msg ); plgDispatch::MsgSend( msg );
} }

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

@ -259,8 +259,8 @@ static bool DumpSpecificMsgInfo(plMessage* msg, plString& info)
info = plString::Format("Type: %s Str: %s User: %s(%d) Delay: %f Int: %d", info = plString::Format("Type: %s Str: %s User: %s(%d) Delay: %f Int: %d",
typeName, typeName,
kiMsg->GetString() != "" ? kiMsg->GetString().c_str() : "(nil)", kiMsg->GetString().c_str("(nil)"),
kiMsg->GetUser() ? kiMsg->GetUser() : "(nil)", kiMsg->GetUser().c_str("(nil)"),
kiMsg->GetPlayerID(), kiMsg->GetPlayerID(),
kiMsg->GetDelay(), kiMsg->GetDelay(),
kiMsg->GetIntValue()); kiMsg->GetIntValue());

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

@ -136,7 +136,7 @@ PF_CONSOLE_CMD( Game, LoadDialog, "string dlgName", "Loads the given GUI dialog
if( mgrKey ) if( mgrKey )
{ {
pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kLoadDialog ); pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kLoadDialog );
msg->SetString( params[ 0 ] ); msg->SetString( (const char *)params[ 0 ] );
plgDispatch::MsgSend( msg ); plgDispatch::MsgSend( msg );
} }
} }
@ -148,8 +148,8 @@ PF_CONSOLE_CMD( Game, LoadLocalDialog, "string ageName, string dlgName", "Loads
if( mgrKey ) if( mgrKey )
{ {
pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kLoadDialog ); pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kLoadDialog );
msg->SetString( params[ 1 ] ); msg->SetString( (const char *)params[ 1 ] );
msg->SetAge( params[ 0 ] ); msg->SetAge( (const char *)params[ 0 ] );
plgDispatch::MsgSend( msg ); plgDispatch::MsgSend( msg );
} }
} }
@ -161,7 +161,7 @@ PF_CONSOLE_CMD( Game, ShowDialog, "string dlgName", "Shows the given GUI dialog"
if( mgrKey ) if( mgrKey )
{ {
pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kShowDialog ); pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kShowDialog );
msg->SetString( params[ 0 ] ); msg->SetString( (const char *)params[ 0 ] );
plgDispatch::MsgSend( msg ); plgDispatch::MsgSend( msg );
} }
} }
@ -173,7 +173,7 @@ PF_CONSOLE_CMD( Game, HideDialog, "string dlgName", "Hides the given GUI dialog"
if( mgrKey ) if( mgrKey )
{ {
pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kHideDialog ); pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kHideDialog );
msg->SetString( params[ 0 ] ); msg->SetString( (const char *)params[ 0 ] );
plgDispatch::MsgSend( msg ); plgDispatch::MsgSend( msg );
} }
} }
@ -187,11 +187,11 @@ PF_CONSOLE_CMD( Game, SwitchDialog, "string olddlgName, string newdlgName", "Hid
if( mgrKey ) if( mgrKey )
{ {
pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kHideDialog ); pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kHideDialog );
msg->SetString( params[ 0 ] ); msg->SetString( (const char *)params[ 0 ] );
plgDispatch::MsgSend( msg ); plgDispatch::MsgSend( msg );
pfGameGUIMsg *msg2 = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kShowDialog ); pfGameGUIMsg *msg2 = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kShowDialog );
msg2->SetString( params[ 1 ] ); msg2->SetString( (const char *)params[ 1 ] );
plgDispatch::MsgSend( msg2 ); plgDispatch::MsgSend( msg2 );
} }
} }

6
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGameGUIMgr.cpp

@ -181,11 +181,11 @@ bool pfGameGUIMgr::MsgReceive( plMessage* pMsg )
if( guiMsg != nil ) if( guiMsg != nil )
{ {
if( guiMsg->GetCommand() == pfGameGUIMsg::kLoadDialog ) if( guiMsg->GetCommand() == pfGameGUIMsg::kLoadDialog )
LoadDialog( guiMsg->GetString(), nil, guiMsg->GetAge() ); LoadDialog(guiMsg->GetString().c_str(), nil, guiMsg->GetAge().c_str());
else if( guiMsg->GetCommand() == pfGameGUIMsg::kShowDialog ) else if( guiMsg->GetCommand() == pfGameGUIMsg::kShowDialog )
IShowDialog( guiMsg->GetString() ); IShowDialog(guiMsg->GetString().c_str());
else if( guiMsg->GetCommand() == pfGameGUIMsg::kHideDialog ) else if( guiMsg->GetCommand() == pfGameGUIMsg::kHideDialog )
IHideDialog( guiMsg->GetString() ); IHideDialog(guiMsg->GetString().c_str());
return true; return true;
} }

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

@ -55,24 +55,17 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
class pfBackdoorMsg : public plMessage class pfBackdoorMsg : public plMessage
{ {
protected: protected:
char *fTarget; plString fTarget;
char *fString; plString fString;
public: public:
pfBackdoorMsg() : plMessage( nil, nil, nil ),fTarget(nil),fString(nil) {} pfBackdoorMsg() : plMessage(nil, nil, nil) {}
pfBackdoorMsg( const char* target, const char* string) : plMessage( nil, nil, nil ) pfBackdoorMsg(const plString& target, const plString& string)
: plMessage(nil, nil, nil), fTarget(target), fString(string)
{ {
// across the net and just to those listening // across the net and just to those listening
SetBCastFlag( plMessage::kNetPropagate ); SetBCastFlag( plMessage::kNetPropagate );
SetBCastFlag( plMessage::kBCastByExactType ); SetBCastFlag( plMessage::kBCastByExactType );
fTarget = hsStrcpy( target );
fString = hsStrcpy( string );
}
~pfBackdoorMsg()
{
delete [] fTarget;
delete [] fString;
} }
CLASSNAME_REGISTER( pfBackdoorMsg ); CLASSNAME_REGISTER( pfBackdoorMsg );
@ -81,19 +74,19 @@ class pfBackdoorMsg : public plMessage
virtual void Read(hsStream* s, hsResMgr* mgr) virtual void Read(hsStream* s, hsResMgr* mgr)
{ {
plMessage::IMsgRead( s, mgr ); plMessage::IMsgRead( s, mgr );
fTarget = s->ReadSafeString(); fTarget = s->ReadSafeString_TEMP();
fString = s->ReadSafeString(); fString = s->ReadSafeString_TEMP();
} }
virtual void Write(hsStream* s, hsResMgr* mgr) virtual void Write(hsStream* s, hsResMgr* mgr)
{ {
plMessage::IMsgWrite( s, mgr ); plMessage::IMsgWrite( s, mgr );
s->WriteSafeString( fTarget ); s->WriteSafeString(fTarget);
s->WriteSafeString( fString ); s->WriteSafeString(fString);
} }
const char *GetTarget( void ) { return fTarget; } plString GetTarget() const { return fTarget; }
const char *GetString( void ) { return fString; } plString GetString() const { return fString; }
}; };

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

@ -52,13 +52,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsStream.h" #include "hsStream.h"
#include "pnMessage/plMessage.h" #include "pnMessage/plMessage.h"
#define GAME_GUI_MSG_STRING_SIZE (128)
class pfGameGUIMsg : public plMessage class pfGameGUIMsg : public plMessage
{ {
protected: protected:
uint8_t fCommand; uint8_t fCommand;
char fString[ 128 ]; plString fString;
char *fAge; plString fAge;
public: public:
enum enum
@ -68,9 +70,8 @@ class pfGameGUIMsg : public plMessage
kLoadDialog kLoadDialog
}; };
pfGameGUIMsg() : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); fAge = nil; } pfGameGUIMsg() : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); }
pfGameGUIMsg( plKey &receiver, uint8_t command ) : plMessage( nil, nil, nil ) { AddReceiver( receiver ); fCommand = command; fAge = nil; } pfGameGUIMsg(plKey &receiver, uint8_t command) : plMessage(nil, nil, nil) { AddReceiver(receiver); fCommand = command; }
~pfGameGUIMsg() { delete [] fAge; }
CLASSNAME_REGISTER( pfGameGUIMsg ); CLASSNAME_REGISTER( pfGameGUIMsg );
GETINTERFACE_ANY( pfGameGUIMsg, plMessage ); GETINTERFACE_ANY( pfGameGUIMsg, plMessage );
@ -79,25 +80,30 @@ class pfGameGUIMsg : public plMessage
{ {
plMessage::IMsgRead( s, mgr ); plMessage::IMsgRead( s, mgr );
s->ReadLE( &fCommand ); s->ReadLE( &fCommand );
s->Read( sizeof( fString ), fString ); char buffer[GAME_GUI_MSG_STRING_SIZE];
fAge = s->ReadSafeString(); s->Read(sizeof(buffer), buffer);
buffer[GAME_GUI_MSG_STRING_SIZE - 1] = 0;
fString = buffer;
fAge = s->ReadSafeString_TEMP();
} }
virtual void Write(hsStream* s, hsResMgr* mgr) virtual void Write(hsStream* s, hsResMgr* mgr)
{ {
plMessage::IMsgWrite( s, mgr ); plMessage::IMsgWrite( s, mgr );
s->WriteLE( fCommand ); s->WriteLE( fCommand );
s->Write( sizeof( fString ), fString ); char buffer[GAME_GUI_MSG_STRING_SIZE];
strncpy(buffer, fString.c_str(), GAME_GUI_MSG_STRING_SIZE);
s->Write(sizeof(buffer), buffer);
s->WriteSafeString( fAge ); s->WriteSafeString( fAge );
} }
uint8_t GetCommand( void ) { return fCommand; } uint8_t GetCommand() const { return fCommand; }
void SetString( const char *str ) { hsStrncpy( fString, str, sizeof( fString ) - 1 ); } void SetString(const plString &str) { fString = str; }
const char *GetString( void ) { return fString; } plString GetString() const { return fString; }
void SetAge( const char *str ) { delete [] fAge; if( str == nil ) fAge = nil; else fAge = hsStrcpy( str ); } void SetAge(const plString &age) { fAge = age; }
const char *GetAge( void ) { return fAge; } plString GetAge() const { return fAge; }
}; };
#endif // _pfGameGUIMsg_h #endif // _pfGameGUIMsg_h

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

@ -64,7 +64,7 @@ class pfKIMsg : public plMessage
uint32_t fFlags; uint32_t fFlags;
// for the hack chat message thingy // for the hack chat message thingy
char *fUser; plString fUser;
uint32_t fPlayerID; uint32_t fPlayerID;
plString fString; plString fString;
@ -77,8 +77,8 @@ class pfKIMsg : public plMessage
void IInit() void IInit()
{ {
fCommand = kNoCommand; fCommand = kNoCommand;
fString = ""; fString = plString::Null;
fUser = nil; fUser = plString::Null;
fPlayerID = 0; fPlayerID = 0;
fFlags = 0; fFlags = 0;
fDelay = 0.0; fDelay = 0.0;
@ -180,7 +180,6 @@ class pfKIMsg : public plMessage
pfKIMsg() : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); IInit(); } pfKIMsg() : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); IInit(); }
pfKIMsg( uint8_t command ) : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); IInit(); fCommand = command; } pfKIMsg( uint8_t command ) : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); IInit(); fCommand = command; }
pfKIMsg( plKey &receiver, uint8_t command ) : plMessage( nil, nil, nil ) { AddReceiver( receiver ); IInit(); fCommand = command; } pfKIMsg( plKey &receiver, uint8_t command ) : plMessage( nil, nil, nil ) { AddReceiver( receiver ); IInit(); fCommand = command; }
~pfKIMsg() { delete [] fUser; }
CLASSNAME_REGISTER( pfKIMsg ); CLASSNAME_REGISTER( pfKIMsg );
GETINTERFACE_ANY( pfKIMsg, plMessage ); GETINTERFACE_ANY( pfKIMsg, plMessage );
@ -189,7 +188,7 @@ class pfKIMsg : public plMessage
{ {
plMessage::IMsgRead( s, mgr ); plMessage::IMsgRead( s, mgr );
s->ReadLE( &fCommand ); s->ReadLE( &fCommand );
fUser = s->ReadSafeString(); fUser = s->ReadSafeString_TEMP();
fPlayerID = s->ReadLE32(); fPlayerID = s->ReadLE32();
fString = s->ReadSafeWString_TEMP(); fString = s->ReadSafeWString_TEMP();
fFlags = s->ReadLE32(); fFlags = s->ReadLE32();
@ -214,9 +213,9 @@ class pfKIMsg : public plMessage
void SetString( const plString &str ) { fString = str; } void SetString( const plString &str ) { fString = str; }
plString GetString( void ) { return fString; } plString GetString( void ) { return fString; }
void SetUser( const char *str, uint32_t pid=0 ) { fUser = hsStrcpy( str ); fPlayerID = pid; } void SetUser(const plString &str, uint32_t pid=0) { fUser = str; fPlayerID = pid; }
const char *GetUser( void ) { return fUser; } plString GetUser() const { return fUser; }
uint32_t GetPlayerID( void ) { return fPlayerID; } uint32_t GetPlayerID() const { return fPlayerID; }
void SetFlags( uint32_t flags ) { fFlags = flags; } void SetFlags( uint32_t flags ) { fFlags = flags; }
uint32_t GetFlags( void ) const { return fFlags; } uint32_t GetFlags( void ) const { return fFlags; }

11
Sources/Plasma/FeatureLib/pfMessage/plClothingMsg.h

@ -96,16 +96,15 @@ public:
class plElementRefMsg : public plGenRefMsg class plElementRefMsg : public plGenRefMsg
{ {
public: public:
char *fElementName; plString fElementName;
uint32_t fLayer; uint32_t fLayer;
plElementRefMsg() : plGenRefMsg(), fElementName(nil), fLayer(1) {} plElementRefMsg() : plGenRefMsg(), fLayer(1) {}
plElementRefMsg(const plKey &r, uint8_t c, int which, int type, char *name, uint8_t layer) : plGenRefMsg(r, c, which, type) plElementRefMsg(const plKey &r, uint8_t c, int which, int type, const plString &name, uint8_t layer) : plGenRefMsg(r, c, which, type)
{ {
fLayer = layer; fLayer = layer;
fElementName = hsStrcpy(name); fElementName = name;
} }
~plElementRefMsg() { delete [] fElementName; }
CLASSNAME_REGISTER( plElementRefMsg ); CLASSNAME_REGISTER( plElementRefMsg );
GETINTERFACE_ANY( plElementRefMsg, plGenRefMsg ); GETINTERFACE_ANY( plElementRefMsg, plGenRefMsg );

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

@ -567,14 +567,14 @@ int32_t cyAvatar::GetAvatarClothingGroup()
// //
// PURPOSE : Return a list of the wearable items for this avatar of that clothing_type // PURPOSE : Return a list of the wearable items for this avatar of that clothing_type
// //
std::vector<std::string> cyAvatar::GetEntireClothingList(int32_t clothing_type) std::vector<plString> cyAvatar::GetEntireClothingList(int32_t clothing_type)
{ {
// Currently, just all the clothing available will be returned // Currently, just all the clothing available will be returned
hsTArray<plClothingItem*> clothingList = plClothingMgr::GetClothingMgr()->GetItemList(); hsTArray<plClothingItem*> clothingList = plClothingMgr::GetClothingMgr()->GetItemList();
int numItems = clothingList.GetCount(); int numItems = clothingList.GetCount();
// create the string list to send to python... // create the string list to send to python...
std::vector<std::string> retVal; std::vector<plString> retVal;
for (int i = 0; i < numItems; i++) for (int i = 0; i < numItems; i++)
retVal.push_back(clothingList[i]->GetName()); retVal.push_back(clothingList[i]->GetName());
@ -621,16 +621,13 @@ std::vector<PyObject*> cyAvatar::GetClosetClothingList(int32_t clothing_type)
PyObject* clothingItem = PyList_New(5); PyObject* clothingItem = PyList_New(5);
// [0] = clothing name // [0] = clothing name
PyList_SetItem(clothingItem, 0, PyString_FromString(item->GetName())); PyList_SetItem(clothingItem, 0, PyString_FromPlString(item->GetName()));
// [1] = clothing type // [1] = clothing type
PyList_SetItem(clothingItem, 1, PyInt_FromLong(item->fType)); PyList_SetItem(clothingItem, 1, PyInt_FromLong(item->fType));
// [2] = description // [2] = description
const char* description = ""; // assume an empty string PyList_SetItem(clothingItem, 2, PyString_FromPlString(item->fDescription));
if ( item->fDescription != nil )
description = item->fDescription;
PyList_SetItem(clothingItem, 2, PyString_FromString(description));
// [3] = ptImage of icon // [3] = ptImage of icon
if ( item->fThumbnail != nil ) if ( item->fThumbnail != nil )
@ -640,10 +637,7 @@ std::vector<PyObject*> cyAvatar::GetClosetClothingList(int32_t clothing_type)
PyList_SetItem(clothingItem, 3, PyInt_FromLong(0)); PyList_SetItem(clothingItem, 3, PyInt_FromLong(0));
// [4] = fCustomText // [4] = fCustomText
const char* custom = ""; // assume an empty string PyList_SetItem(clothingItem, 4, PyString_FromPlString(item->fCustomText));
if ( item->fCustomText != nil )
custom = item->fCustomText;
PyList_SetItem(clothingItem, 4, PyString_FromString(custom));
retVal.push_back(clothingItem); retVal.push_back(clothingItem);
} }
@ -689,16 +683,13 @@ std::vector<PyObject*> cyAvatar::GetAvatarClothingList()
plClothingItem* item = clothingList[i]; plClothingItem* item = clothingList[i];
// [0] = clothing name // [0] = clothing name
PyList_SetItem(clothingItem, 0, PyString_FromString(item->GetName())); PyList_SetItem(clothingItem, 0, PyString_FromPlString(item->GetName()));
// [1] = clothing type // [1] = clothing type
PyList_SetItem(clothingItem, 1, PyInt_FromLong(item->fType)); PyList_SetItem(clothingItem, 1, PyInt_FromLong(item->fType));
// [2] = description // [2] = description
const char* description = ""; // assume an empty string PyList_SetItem(clothingItem, 2, PyString_FromPlString(item->fDescription));
if ( item->fDescription != nil )
description = item->fDescription;
PyList_SetItem(clothingItem, 2, PyString_FromString(description));
// [3] = ptImage of icon // [3] = ptImage of icon
if ( item->fThumbnail != nil ) if ( item->fThumbnail != nil )
@ -708,10 +699,7 @@ std::vector<PyObject*> cyAvatar::GetAvatarClothingList()
PyList_SetItem(clothingItem, 3, PyInt_FromLong(0)); PyList_SetItem(clothingItem, 3, PyInt_FromLong(0));
// [4] = fCustomText // [4] = fCustomText
const char* custom = ""; // assume an empty string PyList_SetItem(clothingItem, 4, PyString_FromPlString(item->fCustomText));
if ( item->fCustomText != nil )
custom = item->fCustomText;
PyList_SetItem(clothingItem, 4, PyString_FromString(custom));
retVal.push_back(clothingItem); retVal.push_back(clothingItem);
} }
@ -743,16 +731,13 @@ std::vector<PyObject*> cyAvatar::GetWardrobeClothingList()
PyObject* closetItem = PyList_New(7); PyObject* closetItem = PyList_New(7);
// [0] = clothing name // [0] = clothing name
PyList_SetItem(closetItem, 0, PyString_FromString(closetList[i].fItem->GetName())); PyList_SetItem(closetItem, 0, PyString_FromPlString(closetList[i].fItem->GetName()));
// [1] = clothing type // [1] = clothing type
PyList_SetItem(closetItem, 1, PyInt_FromLong(closetList[i].fItem->fType)); PyList_SetItem(closetItem, 1, PyInt_FromLong(closetList[i].fItem->fType));
// [2] = description // [2] = description
const char* description = ""; // assume an empty string PyList_SetItem(closetItem, 2, PyString_FromPlString(closetList[i].fItem->fDescription));
if ( closetList[i].fItem->fDescription != nil )
description = closetList[i].fItem->fDescription;
PyList_SetItem(closetItem, 2, PyString_FromString(description));
// [3] = ptImage of icon // [3] = ptImage of icon
if ( closetList[i].fItem->fThumbnail != nil ) if ( closetList[i].fItem->fThumbnail != nil )
@ -762,10 +747,7 @@ std::vector<PyObject*> cyAvatar::GetWardrobeClothingList()
PyList_SetItem(closetItem, 3, PyInt_FromLong(0)); PyList_SetItem(closetItem, 3, PyInt_FromLong(0));
// [4] = fCustomText // [4] = fCustomText
const char* custom = ""; // assume an empty string PyList_SetItem(closetItem, 4, PyString_FromPlString(closetList[i].fItem->fCustomText));
if ( closetList[i].fItem->fCustomText != nil )
custom = closetList[i].fItem->fCustomText;
PyList_SetItem(closetItem, 4, PyString_FromString(custom));
// [5] = fTint1 // [5] = fTint1
PyList_SetItem(closetItem, 5, pyColor::New(closetList[i].fOptions.fTint1)); PyList_SetItem(closetItem, 5, pyColor::New(closetList[i].fOptions.fTint1));
@ -787,9 +769,9 @@ std::vector<PyObject*> cyAvatar::GetWardrobeClothingList()
// //
// PURPOSE : To add a clothing item to the avatar's wardrobe (closet) // PURPOSE : To add a clothing item to the avatar's wardrobe (closet)
// //
void cyAvatar::AddWardrobeClothingItem(const char* clothing_name,pyColor& tint1,pyColor& tint2) void cyAvatar::AddWardrobeClothingItem(const plString& clothing_name,pyColor& tint1,pyColor& tint2)
{ {
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((char*)clothing_name); plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(clothing_name);
if ( item ) if ( item )
{ {
hsTArray<plClosetItem> items; hsTArray<plClosetItem> items;
@ -844,16 +826,13 @@ std::vector<PyObject*> cyAvatar::GetUniqueMeshList(int32_t clothing_type)
PyObject* clothingItem = PyList_New(5); PyObject* clothingItem = PyList_New(5);
// [0] = clothing name // [0] = clothing name
PyList_SetItem(clothingItem, 0, PyString_FromString(item->GetName())); PyList_SetItem(clothingItem, 0, PyString_FromPlString(item->GetName()));
// [1] = clothing type // [1] = clothing type
PyList_SetItem(clothingItem, 1, PyInt_FromLong(item->fType)); PyList_SetItem(clothingItem, 1, PyInt_FromLong(item->fType));
// [2] = description // [2] = description
const char* description = ""; // assume an empty string PyList_SetItem(clothingItem, 2, PyString_FromPlString(item->fDescription));
if ( item->fDescription != nil )
description = item->fDescription;
PyList_SetItem(clothingItem, 2, PyString_FromString(description));
// [3] = ptImage of icon // [3] = ptImage of icon
if ( item->fThumbnail != nil ) if ( item->fThumbnail != nil )
@ -863,10 +842,7 @@ std::vector<PyObject*> cyAvatar::GetUniqueMeshList(int32_t clothing_type)
PyList_SetItem(clothingItem, 3, PyInt_FromLong(0)); PyList_SetItem(clothingItem, 3, PyInt_FromLong(0));
// [4] = fCustomText // [4] = fCustomText
const char* custom = ""; // assume an empty string PyList_SetItem(clothingItem, 4, PyString_FromPlString(item->fCustomText));
if ( item->fCustomText != nil )
custom = item->fCustomText;
PyList_SetItem(clothingItem, 4, PyString_FromString(custom));
retVal.push_back(clothingItem); retVal.push_back(clothingItem);
} }
@ -885,7 +861,7 @@ std::vector<PyObject*> cyAvatar::GetUniqueMeshList(int32_t clothing_type)
// PURPOSE : Return a list of clothing items that have the same mesh as // PURPOSE : Return a list of clothing items that have the same mesh as
// : the item passed in // : the item passed in
// //
std::vector<PyObject*> cyAvatar::GetAllWithSameMesh(const char* clothing_name) std::vector<PyObject*> cyAvatar::GetAllWithSameMesh(const plString& clothing_name)
{ {
std::vector<PyObject*> retVal; std::vector<PyObject*> retVal;
@ -903,7 +879,7 @@ std::vector<PyObject*> cyAvatar::GetAllWithSameMesh(const char* clothing_name)
{ {
// Get all clothes with the same mesh as the one passed in // Get all clothes with the same mesh as the one passed in
hsTArray<plClothingItem*> clothingList; hsTArray<plClothingItem*> clothingList;
plClothingMgr::GetClothingMgr()->GetAllWithSameMesh(plClothingMgr::GetClothingMgr()->FindItemByName((char*)clothing_name), clothingList); plClothingMgr::GetClothingMgr()->GetAllWithSameMesh(plClothingMgr::GetClothingMgr()->FindItemByName(clothing_name), clothingList);
int numItems = clothingList.GetCount(); int numItems = clothingList.GetCount();
// create the string list to send to python... as a python object // create the string list to send to python... as a python object
int i; int i;
@ -915,16 +891,13 @@ std::vector<PyObject*> cyAvatar::GetAllWithSameMesh(const char* clothing_name)
plClothingItem* item = clothingList[i]; plClothingItem* item = clothingList[i];
// [0] = clothing name // [0] = clothing name
PyList_SetItem(clothingItem, 0, PyString_FromString(item->GetName())); PyList_SetItem(clothingItem, 0, PyString_FromPlString(item->GetName()));
// [1] = clothing type // [1] = clothing type
PyList_SetItem(clothingItem, 1, PyInt_FromLong(item->fType)); PyList_SetItem(clothingItem, 1, PyInt_FromLong(item->fType));
// [2] = description // [2] = description
const char* description = ""; // assume an empty string PyList_SetItem(clothingItem, 2, PyString_FromPlString(item->fDescription));
if ( item->fDescription != nil )
description = item->fDescription;
PyList_SetItem(clothingItem, 2, PyString_FromString(description));
// [3] = ptImage of icon // [3] = ptImage of icon
if ( item->fThumbnail != nil ) if ( item->fThumbnail != nil )
@ -934,10 +907,7 @@ std::vector<PyObject*> cyAvatar::GetAllWithSameMesh(const char* clothing_name)
PyList_SetItem(clothingItem, 3, PyInt_FromLong(0)); PyList_SetItem(clothingItem, 3, PyInt_FromLong(0));
// [4] = fCustomText // [4] = fCustomText
const char* custom = ""; // assume an empty string PyList_SetItem(clothingItem, 4, PyString_FromPlString(item->fCustomText));
if ( item->fCustomText != nil )
custom = item->fCustomText;
PyList_SetItem(clothingItem, 4, PyString_FromString(custom));
retVal.push_back(clothingItem); retVal.push_back(clothingItem);
} }
@ -955,27 +925,24 @@ std::vector<PyObject*> cyAvatar::GetAllWithSameMesh(const char* clothing_name)
// PURPOSE : Return the clothing item that matches this one // PURPOSE : Return the clothing item that matches this one
// : If no match then returns the number 0 // : If no match then returns the number 0
// //
PyObject* cyAvatar::GetMatchingClothingItem(const char* clothing_name) PyObject* cyAvatar::GetMatchingClothingItem(const plString& clothing_name)
{ {
// Get all the clothes that we can wear // Get all the clothes that we can wear
hsTArray<plClothingItem*> clothingList; hsTArray<plClothingItem*> clothingList;
plClothingItem* match = plClothingMgr::GetClothingMgr()->GetLRMatch(plClothingMgr::GetClothingMgr()->FindItemByName((char*)clothing_name)); plClothingItem* match = plClothingMgr::GetClothingMgr()->GetLRMatch(plClothingMgr::GetClothingMgr()->FindItemByName(clothing_name));
if ( match ) if ( match )
{ {
// create list // create list
PyObject* clothingItem = PyList_New(5); PyObject* clothingItem = PyList_New(5);
// [0] = clothing name // [0] = clothing name
PyList_SetItem(clothingItem, 0, PyString_FromString(match->GetName())); PyList_SetItem(clothingItem, 0, PyString_FromPlString(match->GetName()));
// [1] = clothing type // [1] = clothing type
PyList_SetItem(clothingItem, 1, PyInt_FromLong(match->fType)); PyList_SetItem(clothingItem, 1, PyInt_FromLong(match->fType));
// [2] = description // [2] = description
const char* description = ""; // assume an empty string PyList_SetItem(clothingItem, 2, PyString_FromPlString(match->fDescription));
if ( match->fDescription != nil )
description = match->fDescription;
PyList_SetItem(clothingItem, 2, PyString_FromString(description));
// [3] = ptImage of icon // [3] = ptImage of icon
if ( match->fThumbnail != nil ) if ( match->fThumbnail != nil )
@ -985,10 +952,7 @@ PyObject* cyAvatar::GetMatchingClothingItem(const char* clothing_name)
PyList_SetItem(clothingItem, 3, PyInt_FromLong(0)); PyList_SetItem(clothingItem, 3, PyInt_FromLong(0));
// [4] = fCustomText // [4] = fCustomText
const char* custom = ""; // assume an empty string PyList_SetItem(clothingItem, 4, PyString_FromPlString(match->fCustomText));
if ( match->fCustomText != nil )
custom = match->fCustomText;
PyList_SetItem(clothingItem, 4, PyString_FromString(custom));
return clothingItem; return clothingItem;
} }
@ -1005,7 +969,7 @@ PyObject* cyAvatar::GetMatchingClothingItem(const char* clothing_name)
// PURPOSE : Wear a particular piece of clothing based on name of clothing item // PURPOSE : Wear a particular piece of clothing based on name of clothing item
// : returns 0, if clothing item was not found // : returns 0, if clothing item was not found
// //
bool cyAvatar::WearClothingItem(const char* clothing_name) bool cyAvatar::WearClothingItem(const plString& clothing_name)
{ {
return WearClothingItemU(clothing_name,true); return WearClothingItemU(clothing_name,true);
} }
@ -1018,7 +982,7 @@ bool cyAvatar::WearClothingItem(const char* clothing_name)
// PURPOSE : Wear a particular piece of clothing based on name of clothing item // PURPOSE : Wear a particular piece of clothing based on name of clothing item
// : returns false, if clothing item was not found // : returns false, if clothing item was not found
// //
bool cyAvatar::RemoveClothingItem(const char* clothing_name) bool cyAvatar::RemoveClothingItem(const plString& clothing_name)
{ {
return RemoveClothingItemU(clothing_name,true); return RemoveClothingItemU(clothing_name,true);
} }
@ -1030,7 +994,7 @@ bool cyAvatar::RemoveClothingItem(const char* clothing_name)
// //
// PURPOSE : Tint a clothing item, i.e. change the color of it // PURPOSE : Tint a clothing item, i.e. change the color of it
// //
bool cyAvatar::TintClothingItem(const char* clothing_name, pyColor& tint) bool cyAvatar::TintClothingItem(const plString& clothing_name, pyColor& tint)
{ {
return TintClothingItemU(clothing_name,tint,true); return TintClothingItemU(clothing_name,tint,true);
} }
@ -1044,7 +1008,7 @@ bool cyAvatar::TintClothingItem(const char* clothing_name, pyColor& tint)
// //
// PURPOSE : Tint a clothing item, i.e. change the color of it // PURPOSE : Tint a clothing item, i.e. change the color of it
// //
bool cyAvatar::TintClothingItemLayer(const char* clothing_name, pyColor& tint, uint8_t layer) bool cyAvatar::TintClothingItemLayer(const plString& clothing_name, pyColor& tint, uint8_t layer)
{ {
return TintClothingItemLayerU(clothing_name,tint,layer,true); return TintClothingItemLayerU(clothing_name,tint,layer,true);
} }
@ -1058,7 +1022,7 @@ bool cyAvatar::TintClothingItemLayer(const char* clothing_name, pyColor& tint, u
// PURPOSE : Wear a particular piece of clothing based on name of clothing item // PURPOSE : Wear a particular piece of clothing based on name of clothing item
// : returns 0, if clothing item was not found // : returns 0, if clothing item was not found
// //
bool cyAvatar::WearClothingItemU(const char* clothing_name, bool update) bool cyAvatar::WearClothingItemU(const plString& clothing_name, bool update)
{ {
const plArmatureMod *avMod = nil; const plArmatureMod *avMod = nil;
// we can really only talk to one avatar, so just get the first one (which is probably the only one) // we can really only talk to one avatar, so just get the first one (which is probably the only one)
@ -1068,7 +1032,7 @@ bool cyAvatar::WearClothingItemU(const char* clothing_name, bool update)
if (so != nil) if (so != nil)
{ {
avMod = (plArmatureMod*)so->GetModifierByType(plArmatureMod::Index()); avMod = (plArmatureMod*)so->GetModifierByType(plArmatureMod::Index());
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((char*)clothing_name); plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(clothing_name);
if (avMod && item) if (avMod && item)
{ {
@ -1092,7 +1056,7 @@ bool cyAvatar::WearClothingItemU(const char* clothing_name, bool update)
// PURPOSE : Wear a particular piece of clothing based on name of clothing item // PURPOSE : Wear a particular piece of clothing based on name of clothing item
// : returns false, if clothing item was not found // : returns false, if clothing item was not found
// //
bool cyAvatar::RemoveClothingItemU(const char* clothing_name, bool update) bool cyAvatar::RemoveClothingItemU(const plString& clothing_name, bool update)
{ {
const plArmatureMod *avMod = nil; const plArmatureMod *avMod = nil;
// we can really only talk to one avatar, so just get the first one (which is probably the only one) // we can really only talk to one avatar, so just get the first one (which is probably the only one)
@ -1103,7 +1067,7 @@ bool cyAvatar::RemoveClothingItemU(const char* clothing_name, bool update)
{ {
avMod = (plArmatureMod*)so->GetModifierByType(plArmatureMod::Index()); avMod = (plArmatureMod*)so->GetModifierByType(plArmatureMod::Index());
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((char*)clothing_name); plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(clothing_name);
if (avMod && item) if (avMod && item)
{ {
@ -1126,7 +1090,7 @@ bool cyAvatar::RemoveClothingItemU(const char* clothing_name, bool update)
// //
// PURPOSE : Tint a clothing item, i.e. change the color of it // PURPOSE : Tint a clothing item, i.e. change the color of it
// //
bool cyAvatar::TintClothingItemU(const char* clothing_name, pyColor& tint, bool update) bool cyAvatar::TintClothingItemU(const plString& clothing_name, pyColor& tint, bool update)
{ {
const plArmatureMod *avMod = nil; const plArmatureMod *avMod = nil;
// we can really only talk to one avatar, so just get the first one (which is probably the only one) // we can really only talk to one avatar, so just get the first one (which is probably the only one)
@ -1137,7 +1101,7 @@ bool cyAvatar::TintClothingItemU(const char* clothing_name, pyColor& tint, bool
{ {
avMod = (plArmatureMod*)so->GetModifierByType(plArmatureMod::Index()); avMod = (plArmatureMod*)so->GetModifierByType(plArmatureMod::Index());
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((char*)clothing_name); plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(clothing_name);
if (avMod && item) if (avMod && item)
{ {
@ -1159,7 +1123,7 @@ bool cyAvatar::TintClothingItemU(const char* clothing_name, pyColor& tint, bool
// //
// PURPOSE : Tint a clothing item, i.e. change the color of it // PURPOSE : Tint a clothing item, i.e. change the color of it
// //
bool cyAvatar::TintClothingItemLayerU(const char* clothing_name, pyColor& tint, uint8_t layer, bool update) bool cyAvatar::TintClothingItemLayerU(const plString& clothing_name, pyColor& tint, uint8_t layer, bool update)
{ {
const plArmatureMod *avMod = nil; const plArmatureMod *avMod = nil;
// we can really only talk to one avatar, so just get the first one (which is probably the only one) // we can really only talk to one avatar, so just get the first one (which is probably the only one)
@ -1170,7 +1134,7 @@ bool cyAvatar::TintClothingItemLayerU(const char* clothing_name, pyColor& tint,
{ {
avMod = (plArmatureMod*)so->GetModifierByType(plArmatureMod::Index()); avMod = (plArmatureMod*)so->GetModifierByType(plArmatureMod::Index());
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((char*)clothing_name); plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(clothing_name);
if (avMod && item) if (avMod && item)
{ {
@ -1195,7 +1159,7 @@ bool cyAvatar::TintClothingItemLayerU(const char* clothing_name, pyColor& tint,
// //
// PURPOSE : Get the custom parameter string for a clothing item // PURPOSE : Get the custom parameter string for a clothing item
// //
const char* cyAvatar::GetClothingItemParameterString(const char* clothing_name) plString cyAvatar::GetClothingItemParameterString(const plString& clothing_name)
{ {
const plArmatureMod *avMod = nil; const plArmatureMod *avMod = nil;
// we can really only talk to one avatar, so just get the first one (which is probably the only one) // we can really only talk to one avatar, so just get the first one (which is probably the only one)
@ -1206,14 +1170,11 @@ const char* cyAvatar::GetClothingItemParameterString(const char* clothing_name)
{ {
avMod = (plArmatureMod*)so->GetModifierByType(plArmatureMod::Index()); avMod = (plArmatureMod*)so->GetModifierByType(plArmatureMod::Index());
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((char*)clothing_name); plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(clothing_name);
if (avMod && item) if (avMod && item)
{ {
if ( item->fCustomText != nil ) return item->fCustomText;
return item->fCustomText;
else
return "";
} }
} }
} }
@ -1229,9 +1190,9 @@ const char* cyAvatar::GetClothingItemParameterString(const char* clothing_name)
// //
// PURPOSE : Get the tint a clothing item, i.e. change the color of it // PURPOSE : Get the tint a clothing item, i.e. change the color of it
// //
PyObject* cyAvatar::GetTintClothingItem(const char* clothing_name) PyObject* cyAvatar::GetTintClothingItem(const plString& clothing_name)
{ {
return GetTintClothingItemL(clothing_name,1); return GetTintClothingItemL(clothing_name, 1);
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -1241,7 +1202,7 @@ PyObject* cyAvatar::GetTintClothingItem(const char* clothing_name)
// //
// PURPOSE : Get the tint a clothing item, i.e. change the color of it // PURPOSE : Get the tint a clothing item, i.e. change the color of it
// //
PyObject* cyAvatar::GetTintClothingItemL(const char* clothing_name, uint8_t layer) PyObject* cyAvatar::GetTintClothingItemL(const plString& clothing_name, uint8_t layer)
{ {
const plArmatureMod *avMod = nil; const plArmatureMod *avMod = nil;
// we can really only talk to one avatar, so just get the first one (which is probably the only one) // we can really only talk to one avatar, so just get the first one (which is probably the only one)
@ -1252,7 +1213,7 @@ PyObject* cyAvatar::GetTintClothingItemL(const char* clothing_name, uint8_t laye
{ {
avMod = (plArmatureMod*)so->GetModifierByType(plArmatureMod::Index()); avMod = (plArmatureMod*)so->GetModifierByType(plArmatureMod::Index());
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((char*)clothing_name); plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(clothing_name);
if (avMod && item) if (avMod && item)
{ {
@ -1267,7 +1228,7 @@ PyObject* cyAvatar::GetTintClothingItemL(const char* clothing_name, uint8_t laye
} }
} }
plString errmsg = plString::Format("Cannot find clothing item %s to find out what tint it is", clothing_name); plString errmsg = plString::Format("Cannot find clothing item %s to find out what tint it is", clothing_name.c_str());
PyErr_SetString(PyExc_KeyError, errmsg.c_str()); PyErr_SetString(PyExc_KeyError, errmsg.c_str());
// returning nil means an error occurred // returning nil means an error occurred
return nil; return nil;
@ -1371,7 +1332,7 @@ plMorphSequence* cyAvatar::LocalMorphSequence()
// //
// PURPOSE : Set the morph value of a specific layer of clothing // PURPOSE : Set the morph value of a specific layer of clothing
// //
void cyAvatar::SetMorph(const char* clothing_name, uint8_t layer, float value) void cyAvatar::SetMorph(const plString& clothing_name, uint8_t layer, float value)
{ {
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(clothing_name); plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(clothing_name);
if( !item ) if( !item )
@ -1422,7 +1383,7 @@ void cyAvatar::SetMorph(const char* clothing_name, uint8_t layer, float value)
// //
// PURPOSE : Returns the current morph value of the specific layer of clothing // PURPOSE : Returns the current morph value of the specific layer of clothing
// //
float cyAvatar::GetMorph(const char* clothing_name, uint8_t layer) float cyAvatar::GetMorph(const plString& clothing_name, uint8_t layer)
{ {
plMorphSequence* seq = LocalMorphSequence(); plMorphSequence* seq = LocalMorphSequence();
if( !seq ) if( !seq )

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

@ -138,7 +138,7 @@ public:
// //
// PURPOSE : Return a list of the wearable items for this avatar of that clothing_type // PURPOSE : Return a list of the wearable items for this avatar of that clothing_type
// //
virtual std::vector<std::string> GetEntireClothingList(int32_t clothing_type); virtual std::vector<plString> GetEntireClothingList(int32_t clothing_type);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -175,7 +175,7 @@ public:
// //
// PURPOSE : To add a clothing item to the avatar's wardrobe (closet) // PURPOSE : To add a clothing item to the avatar's wardrobe (closet)
// //
virtual void AddWardrobeClothingItem(const char* clothing_name,pyColor& tint1,pyColor& tint2); virtual void AddWardrobeClothingItem(const plString& clothing_name,pyColor& tint1,pyColor& tint2);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -196,7 +196,7 @@ public:
// PURPOSE : Return a list of clothing items that have the same mesh as // PURPOSE : Return a list of clothing items that have the same mesh as
// : the item passed in // : the item passed in
// //
virtual std::vector<PyObject*> GetAllWithSameMesh(const char* clothing_name); virtual std::vector<PyObject*> GetAllWithSameMesh(const plString& clothing_name);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -205,7 +205,7 @@ public:
// //
// PURPOSE : Return the clothing item that matches this one // PURPOSE : Return the clothing item that matches this one
// //
virtual PyObject* GetMatchingClothingItem(const char* clothing_name); virtual PyObject* GetMatchingClothingItem(const plString& clothing_name);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -215,7 +215,7 @@ public:
// PURPOSE : Wear a particular piece of clothing based on name of clothing item // PURPOSE : Wear a particular piece of clothing based on name of clothing item
// : returns 0, if clothing item was not found // : returns 0, if clothing item was not found
// //
virtual bool WearClothingItem(const char* clothing_name); virtual bool WearClothingItem(const plString& clothing_name);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -225,7 +225,7 @@ public:
// PURPOSE : Remove (take off) a particular piece of clothing based on name of clothing item // PURPOSE : Remove (take off) a particular piece of clothing based on name of clothing item
// : returns 0, if clothing item was not found // : returns 0, if clothing item was not found
// //
virtual bool RemoveClothingItem(const char* clothing_name); virtual bool RemoveClothingItem(const plString& clothing_name);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -234,7 +234,7 @@ public:
// //
// PURPOSE : Tint a clothing item, i.e. change the color of it // PURPOSE : Tint a clothing item, i.e. change the color of it
// //
virtual bool TintClothingItem(const char* clothing_name, pyColor& tint); virtual bool TintClothingItem(const plString& clothing_name, pyColor& tint);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -245,7 +245,7 @@ public:
// //
// PURPOSE : Tint a clothing item, i.e. change the color of it // PURPOSE : Tint a clothing item, i.e. change the color of it
// //
virtual bool TintClothingItemLayer(const char* clothing_name, pyColor& tint, uint8_t layer); virtual bool TintClothingItemLayer(const plString& clothing_name, pyColor& tint, uint8_t layer);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -255,7 +255,7 @@ public:
// PURPOSE : Wear a particular piece of clothing based on name of clothing item // PURPOSE : Wear a particular piece of clothing based on name of clothing item
// : returns 0, if clothing item was not found // : returns 0, if clothing item was not found
// //
virtual bool WearClothingItemU(const char* clothing_name, bool update); virtual bool WearClothingItemU(const plString& clothing_name, bool update);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -265,7 +265,7 @@ public:
// PURPOSE : Remove (take off) a particular piece of clothing based on name of clothing item // PURPOSE : Remove (take off) a particular piece of clothing based on name of clothing item
// : returns 0, if clothing item was not found // : returns 0, if clothing item was not found
// //
virtual bool RemoveClothingItemU(const char* clothing_name, bool update); virtual bool RemoveClothingItemU(const plString& clothing_name, bool update);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -274,7 +274,7 @@ public:
// //
// PURPOSE : Tint a clothing item, i.e. change the color of it // PURPOSE : Tint a clothing item, i.e. change the color of it
// //
virtual bool TintClothingItemU(const char* clothing_name, pyColor& tint, bool update); virtual bool TintClothingItemU(const plString& clothing_name, pyColor& tint, bool update);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -285,7 +285,7 @@ public:
// //
// PURPOSE : Tint a clothing item, i.e. change the color of it // PURPOSE : Tint a clothing item, i.e. change the color of it
// //
virtual bool TintClothingItemLayerU(const char* clothing_name, pyColor& tint, uint8_t layer, bool update); virtual bool TintClothingItemLayerU(const plString& clothing_name, pyColor& tint, uint8_t layer, bool update);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -294,7 +294,7 @@ public:
// //
// PURPOSE : Get the custom parameter string for a clothing item // PURPOSE : Get the custom parameter string for a clothing item
// //
virtual const char* GetClothingItemParameterString(const char* clothing_name); virtual plString GetClothingItemParameterString(const plString& clothing_name);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -303,7 +303,7 @@ public:
// //
// PURPOSE : Get the tint a clothing item, i.e. change the color of it // PURPOSE : Get the tint a clothing item, i.e. change the color of it
// //
virtual PyObject* GetTintClothingItem(const char* clothing_name); virtual PyObject* GetTintClothingItem(const plString& clothing_name);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -312,7 +312,7 @@ public:
// //
// PURPOSE : Get the tint a clothing item, i.e. change the color of it // PURPOSE : Get the tint a clothing item, i.e. change the color of it
// //
virtual PyObject* GetTintClothingItemL(const char* clothing_name, uint8_t layer); virtual PyObject* GetTintClothingItemL(const plString& clothing_name, uint8_t layer);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -351,7 +351,7 @@ public:
// //
// PURPOSE : Set the morph value of a specific layer of clothing // PURPOSE : Set the morph value of a specific layer of clothing
// //
virtual void SetMorph(const char* clothing_name, uint8_t layer, float value); virtual void SetMorph(const plString& clothing_name, uint8_t layer, float value);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -361,7 +361,7 @@ public:
// //
// PURPOSE : Returns the current morph value of the specific layer of clothing // PURPOSE : Returns the current morph value of the specific layer of clothing
// //
virtual float GetMorph(const char* clothing_name, uint8_t layer); virtual float GetMorph(const plString& clothing_name, uint8_t layer);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //

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

@ -223,10 +223,10 @@ PYTHON_METHOD_DEFINITION(ptAvatar, getEntireClothingList, args)
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
std::vector<std::string> clothingList = self->fThis->GetEntireClothingList(clothingType); std::vector<plString> clothingList = self->fThis->GetEntireClothingList(clothingType);
PyObject* retVal = PyList_New(clothingList.size()); PyObject* retVal = PyList_New(clothingList.size());
for (int i = 0; i < clothingList.size(); i++) for (int i = 0; i < clothingList.size(); i++)
PyList_SetItem(retVal, i, PyString_FromString(clothingList[i].c_str())); PyList_SetItem(retVal, i, PyString_FromPlString(clothingList[i]));
return retVal; return retVal;
} }

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

@ -647,7 +647,7 @@ void plPythonFileMod::AddTarget(plSceneObject* sobj)
// 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.fString.IsNull() ) if ( !parameter.fString.IsNull() )
value = PyString_FromString(parameter.fString.c_str()); value = PyString_FromPlString(parameter.fString);
break; break;
case plPythonParameter::kSceneObject: case plPythonParameter::kSceneObject:
case plPythonParameter::kSceneObjectList: case plPythonParameter::kSceneObjectList:
@ -1383,7 +1383,7 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
// create event list // create event list
PyObject* event = PyList_New(4); PyObject* event = PyList_New(4);
PyList_SetItem(event, 0, PyLong_FromLong((long)proEventData::kVariable)); PyList_SetItem(event, 0, PyLong_FromLong((long)proEventData::kVariable));
PyList_SetItem(event, 1, PyString_FromString(eventData->fName)); PyList_SetItem(event, 1, PyString_FromPlString(eventData->fName));
PyList_SetItem(event, 2, PyLong_FromLong(eventData->fDataType)); PyList_SetItem(event, 2, PyLong_FromLong(eventData->fDataType));
// depending on the data type create the data // depending on the data type create the data
@ -1882,7 +1882,7 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
case pfKIMsg::kRateIt: case pfKIMsg::kRateIt:
value = PyTuple_New(3); value = PyTuple_New(3);
str = pkimsg->GetString().ToWchar(); str = pkimsg->GetString().ToWchar();
PyTuple_SetItem(value,0,PyString_FromString(pkimsg->GetUser())); PyTuple_SetItem(value,0,PyString_FromPlString(pkimsg->GetUser()));
PyTuple_SetItem(value,1,PyUnicode_FromWideChar(str, str.GetSize())); PyTuple_SetItem(value,1,PyUnicode_FromWideChar(str, str.GetSize()));
PyTuple_SetItem(value,2,PyLong_FromLong(pkimsg->GetIntValue())); PyTuple_SetItem(value,2,PyLong_FromLong(pkimsg->GetIntValue()));
break; break;
@ -1999,7 +1999,7 @@ bool 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().c_str(), mbr->GetPlayerID(), mbr->GetDistSq()); player = pyPlayer::New(mbr->GetAvatarKey(), mbr->GetPlayerName(), mbr->GetPlayerID(), mbr->GetDistSq());
} }
else else
{ {
@ -2155,8 +2155,8 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
else else
{ {
// else if we could not find the player in our list, then just return a string of the user's name // else if we could not find the player in our list, then just return a string of the user's name
const char * fromName = pkimsg->GetUser(); plString fromName = pkimsg->GetUser();
if (!fromName) if (fromName.IsEmpty())
fromName = "Anonymous Coward"; fromName = "Anonymous Coward";
player = pyPlayer::New(plNetClientMgr::GetInstance()->GetLocalPlayerKey(), fromName, pkimsg->GetPlayerID(), 0.0); player = pyPlayer::New(plNetClientMgr::GetInstance()->GetLocalPlayerKey(), fromName, pkimsg->GetPlayerID(), 0.0);
} }
@ -2410,7 +2410,7 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
PyObject* retVal = PyObject_CallMethod( PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_OnBackdoorMsg], fPyFunctionInstances[kfunc_OnBackdoorMsg],
(char*)fFunctionNames[kfunc_OnBackdoorMsg], (char*)fFunctionNames[kfunc_OnBackdoorMsg],
"ss", dt->GetTarget(), dt->GetString()); "ss", dt->GetTarget().c_str(), dt->GetString().c_str());
if ( retVal == nil ) if ( retVal == nil )
{ {
// if there was an error make sure that the stderr gets flushed so it can be seen // if there was an error make sure that the stderr gets flushed so it can be seen

35
Sources/Plasma/FeatureLib/pfPython/pyMoviePlayer.cpp

@ -54,12 +54,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plMessage/plMovieMsg.h" #include "plMessage/plMovieMsg.h"
#include "pfMessage/pfMovieEventMsg.h" #include "pfMessage/pfMovieEventMsg.h"
pyMoviePlayer::pyMoviePlayer(const char* movieName,pyKey& selfKey) pyMoviePlayer::pyMoviePlayer(const plString& movieName, pyKey& selfKey)
{ {
fMovieName = hsStrcpy(movieName); fMovieName = movieName;
fSelfKey = selfKey.getKey(); fSelfKey = selfKey.getKey();
// make the movie // make the movie
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kMake | plMovieMsg::kAddCallbacks); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kMake | plMovieMsg::kAddCallbacks);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -75,17 +75,14 @@ pyMoviePlayer::pyMoviePlayer(const char* movieName,pyKey& selfKey)
pyMoviePlayer::~pyMoviePlayer() pyMoviePlayer::~pyMoviePlayer()
{ {
Stop(); Stop();
delete [] fMovieName;
} }
void pyMoviePlayer::MakeMovie(const char* movieName, pyKey& selfKey) void pyMoviePlayer::MakeMovie(const plString& movieName, pyKey& selfKey)
{ {
Stop(); Stop();
if (fMovieName) fMovieName = movieName;
delete [] fMovieName;
fMovieName = hsStrcpy(movieName);
fSelfKey = selfKey.getKey(); fSelfKey = selfKey.getKey();
if (fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kMake | plMovieMsg::kAddCallbacks); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kMake | plMovieMsg::kAddCallbacks);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -99,7 +96,7 @@ void pyMoviePlayer::MakeMovie(const char* movieName, pyKey& selfKey)
void pyMoviePlayer::SetCenter(float x, float y) void pyMoviePlayer::SetCenter(float x, float y)
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kMove); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kMove);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -111,7 +108,7 @@ void pyMoviePlayer::SetCenter(float x, float y)
void pyMoviePlayer::SetScale(float width, float height) void pyMoviePlayer::SetScale(float width, float height)
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kScale); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kScale);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -123,7 +120,7 @@ void pyMoviePlayer::SetScale(float width, float height)
void pyMoviePlayer::SetColor(pyColor color) void pyMoviePlayer::SetColor(pyColor color)
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kColor); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kColor);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -134,7 +131,7 @@ void pyMoviePlayer::SetColor(pyColor color)
void pyMoviePlayer::SetVolume(float volume) void pyMoviePlayer::SetVolume(float volume)
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kVolume); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kVolume);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -145,7 +142,7 @@ void pyMoviePlayer::SetVolume(float volume)
void pyMoviePlayer::SetOpacity(float opacity) void pyMoviePlayer::SetOpacity(float opacity)
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kOpacity); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kOpacity);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -157,7 +154,7 @@ void pyMoviePlayer::SetOpacity(float opacity)
void pyMoviePlayer::Play() void pyMoviePlayer::Play()
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kStart); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kStart);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -167,7 +164,7 @@ void pyMoviePlayer::Play()
void pyMoviePlayer::PlayPaused() void pyMoviePlayer::PlayPaused()
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kStart | plMovieMsg::kPause); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kStart | plMovieMsg::kPause);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -177,7 +174,7 @@ void pyMoviePlayer::PlayPaused()
void pyMoviePlayer::Pause() void pyMoviePlayer::Pause()
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kPause); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kPause);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -187,7 +184,7 @@ void pyMoviePlayer::Pause()
void pyMoviePlayer::Resume() void pyMoviePlayer::Resume()
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kResume); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kResume);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);
@ -197,7 +194,7 @@ void pyMoviePlayer::Resume()
void pyMoviePlayer::Stop() void pyMoviePlayer::Stop()
{ {
if ( fMovieName) if (!fMovieName.IsEmpty())
{ {
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kStop); plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kStop);
mov->SetSender(fSelfKey); mov->SetSender(fSelfKey);

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

@ -56,24 +56,24 @@ class pyColor;
class pyMoviePlayer class pyMoviePlayer
{ {
protected: protected:
char* fMovieName; plString fMovieName;
plKey fSelfKey; plKey fSelfKey;
pyMoviePlayer(): fMovieName(nil), fSelfKey(nil) {} // only used by python glue, do NOT call pyMoviePlayer(): fSelfKey(nil) {} // only used by python glue, do NOT call
pyMoviePlayer(const char* movieName,pyKey& selfKey); pyMoviePlayer(const plString& movieName, pyKey& selfKey);
public: public:
~pyMoviePlayer(); ~pyMoviePlayer();
// required functions for PyObject interoperability // required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMoviePlayer); PYTHON_CLASS_NEW_FRIEND(ptMoviePlayer);
static PyObject *New(const char* movieName, pyKey& selfKey); static PyObject *New(const plString& movieName, pyKey& selfKey);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMoviePlayer object PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMoviePlayer object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMoviePlayer); // converts a PyObject to a pyMoviePlayer (throws error if not correct type) PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMoviePlayer); // converts a PyObject to a pyMoviePlayer (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m); static void AddPlasmaClasses(PyObject *m);
static void AddPlasmaConstantsClasses(PyObject *m); static void AddPlasmaConstantsClasses(PyObject *m);
void MakeMovie(const char* movieName, pyKey& selfKey); // only used by python glue, do NOT call void MakeMovie(const plString& movieName, pyKey& selfKey); // only used by python glue, do NOT call
// getters and setters // getters and setters
virtual void SetCenter(float x, float y); virtual void SetCenter(float x, float y);

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

@ -164,7 +164,7 @@ PYTHON_END_METHODS_TABLE;
PLASMA_DEFAULT_TYPE(ptMoviePlayer, "Params: movieName,selfKey\nAccessor class to play in the MoviePlayer"); PLASMA_DEFAULT_TYPE(ptMoviePlayer, "Params: movieName,selfKey\nAccessor class to play in the MoviePlayer");
// required functions for PyObject interoperability // required functions for PyObject interoperability
PyObject *pyMoviePlayer::New(const char* movieName, pyKey& selfKey) PyObject *pyMoviePlayer::New(const plString& movieName, pyKey& selfKey)
{ {
ptMoviePlayer *newObj = (ptMoviePlayer*)ptMoviePlayer_type.tp_new(&ptMoviePlayer_type, NULL, NULL); ptMoviePlayer *newObj = (ptMoviePlayer*)ptMoviePlayer_type.tp_new(&ptMoviePlayer_type, NULL, NULL);
newObj->fThis->MakeMovie(movieName, selfKey); newObj->fThis->MakeMovie(movieName, selfKey);

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

@ -48,14 +48,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
pyPlayer::pyPlayer() // only used by python glue, do NOT call pyPlayer::pyPlayer() // only used by python glue, do NOT call
{ {
fAvatarKey = nil; fAvatarKey = nil;
fPlayerName = ""; fPlayerName = plString::Null;
fPlayerID = 0; fPlayerID = 0;
fDistSq = -1; fDistSq = -1;
fIsCCR = false; fIsCCR = false;
fIsServer = false; fIsServer = false;
} }
pyPlayer::pyPlayer(pyKey& avKey, const char* pname, uint32_t pid, float distsq) pyPlayer::pyPlayer(pyKey& avKey, const plString& pname, uint32_t pid, float distsq)
{ {
fAvatarKey = avKey.getKey(); fAvatarKey = avKey.getKey();
fPlayerName = pname; fPlayerName = pname;
@ -65,7 +65,7 @@ pyPlayer::pyPlayer(pyKey& avKey, const char* pname, uint32_t pid, float distsq)
fIsServer = false; fIsServer = false;
} }
pyPlayer::pyPlayer(plKey avKey, const char* pname, uint32_t pid, float distsq) pyPlayer::pyPlayer(plKey avKey, const plString& pname, uint32_t pid, float distsq)
{ {
fAvatarKey = avKey; fAvatarKey = avKey;
fPlayerName = pname; fPlayerName = pname;
@ -76,7 +76,7 @@ pyPlayer::pyPlayer(plKey avKey, const char* pname, uint32_t pid, float distsq)
} }
// another way to create a player with just a name and number // another way to create a player with just a name and number
pyPlayer::pyPlayer(const char* pname, uint32_t pid) pyPlayer::pyPlayer(const plString& pname, uint32_t pid)
{ {
fAvatarKey = nil; fAvatarKey = nil;
fPlayerName = pname; fPlayerName = pname;
@ -86,7 +86,7 @@ pyPlayer::pyPlayer(const char* pname, uint32_t pid)
fIsServer = false; fIsServer = false;
} }
void pyPlayer::Init(plKey avKey, const char* pname, uint32_t pid, float distsq) // used by python glue, do NOT call void pyPlayer::Init(plKey avKey, const plString& pname, uint32_t pid, float distsq) // used by python glue, do NOT call
{ {
fAvatarKey = avKey; fAvatarKey = avKey;
fPlayerName = pname; fPlayerName = pname;

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

@ -51,31 +51,31 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
#include "pnKeyedObject/plKey.h" #include "pnKeyedObject/plKey.h"
#include <string> #include "plString.h"
class pyPlayer class pyPlayer
{ {
protected: protected:
plKey fAvatarKey; plKey fAvatarKey;
std::string fPlayerName; plString fPlayerName;
uint32_t fPlayerID; uint32_t fPlayerID;
float fDistSq; // from local player, temp float fDistSq; // from local player, temp
bool fIsCCR; bool fIsCCR;
bool fIsServer; bool fIsServer;
pyPlayer(); // only used by python glue, do NOT call pyPlayer(); // only used by python glue, do NOT call
pyPlayer(pyKey& avKey, const char* pname, uint32_t pid, float distsq); pyPlayer(pyKey& avKey, const plString& pname, uint32_t pid, float distsq);
pyPlayer(plKey avKey, const char* pname, uint32_t pid, float distsq); pyPlayer(plKey avKey, const plString& pname, uint32_t pid, float distsq);
// another way to create a player with just a name and number // another way to create a player with just a name and number
pyPlayer(const char* pname, uint32_t pid); pyPlayer(const plString& pname, uint32_t pid);
public: public:
void Init(plKey avKey, const char* pname, uint32_t pid, float distsq); // used by python glue, do NOT call void Init(plKey avKey, const plString& pname, uint32_t pid, float distsq); // used by python glue, do NOT call
// required functions for PyObject interoperability // required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptPlayer); PYTHON_CLASS_NEW_FRIEND(ptPlayer);
static PyObject *New(pyKey& avKey, const char* pname, uint32_t pid, float distsq); static PyObject *New(pyKey& avKey, const plString& pname, uint32_t pid, float distsq);
static PyObject *New(plKey avKey, const char* pname, uint32_t pid, float distsq); static PyObject *New(plKey avKey, const plString& pname, uint32_t pid, float distsq);
static PyObject *New(const char* pname, uint32_t pid); static PyObject *New(const plString& pname, uint32_t pid);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyPlayer object PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyPlayer object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyPlayer); // converts a PyObject to a pyPlayer (throws error if not correct type) PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyPlayer); // converts a PyObject to a pyPlayer (throws error if not correct type)
@ -96,7 +96,7 @@ public:
plKey GetKey() const { return fAvatarKey; } plKey GetKey() const { return fAvatarKey; }
// for python access // for python access
const char * GetPlayerName() const { return fPlayerName.c_str();} plString GetPlayerName() const { return fPlayerName; }
uint32_t GetPlayerID() const { return fPlayerID; } uint32_t GetPlayerID() const { return fPlayerID; }
float GetDistSq() const { return fDistSq; } float GetDistSq() const { return fDistSq; }

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

@ -137,7 +137,7 @@ PYTHON_RICH_COMPARE_DEFINITION(ptPlayer, obj1, obj2, compareType)
PYTHON_METHOD_DEFINITION_NOARGS(ptPlayer, getPlayerName) PYTHON_METHOD_DEFINITION_NOARGS(ptPlayer, getPlayerName)
{ {
return PyString_FromString(self->fThis->GetPlayerName()); return PyString_FromPlString(self->fThis->GetPlayerName());
} }
PYTHON_METHOD_DEFINITION_NOARGS(ptPlayer, getPlayerID) PYTHON_METHOD_DEFINITION_NOARGS(ptPlayer, getPlayerID)
@ -180,21 +180,21 @@ PYTHON_END_METHODS_TABLE;
PLASMA_CUSTOM_TYPE(ptPlayer, "Params: avkey,name,playerID,distanceSq\nAnd optionally __init__(name,playerID)"); PLASMA_CUSTOM_TYPE(ptPlayer, "Params: avkey,name,playerID,distanceSq\nAnd optionally __init__(name,playerID)");
// required functions for PyObject interoperability // required functions for PyObject interoperability
PyObject *pyPlayer::New(pyKey& avKey, const char* pname, uint32_t pid, float distsq) PyObject *pyPlayer::New(pyKey& avKey, const plString& pname, uint32_t pid, float distsq)
{ {
ptPlayer *newObj = (ptPlayer*)ptPlayer_type.tp_new(&ptPlayer_type, NULL, NULL); ptPlayer *newObj = (ptPlayer*)ptPlayer_type.tp_new(&ptPlayer_type, NULL, NULL);
newObj->fThis->Init(avKey.getKey(), pname, pid, distsq); newObj->fThis->Init(avKey.getKey(), pname, pid, distsq);
return (PyObject*)newObj; return (PyObject*)newObj;
} }
PyObject *pyPlayer::New(plKey avKey, const char* pname, uint32_t pid, float distsq) PyObject *pyPlayer::New(plKey avKey, const plString& pname, uint32_t pid, float distsq)
{ {
ptPlayer *newObj = (ptPlayer*)ptPlayer_type.tp_new(&ptPlayer_type, NULL, NULL); ptPlayer *newObj = (ptPlayer*)ptPlayer_type.tp_new(&ptPlayer_type, NULL, NULL);
newObj->fThis->Init(avKey, pname, pid, distsq); newObj->fThis->Init(avKey, pname, pid, distsq);
return (PyObject*)newObj; return (PyObject*)newObj;
} }
PyObject *pyPlayer::New(const char* pname, uint32_t pid) PyObject *pyPlayer::New(const plString& pname, uint32_t pid)
{ {
ptPlayer *newObj = (ptPlayer*)ptPlayer_type.tp_new(&ptPlayer_type, NULL, NULL); ptPlayer *newObj = (ptPlayer*)ptPlayer_type.tp_new(&ptPlayer_type, NULL, NULL);
newObj->fThis->Init(nil, pname, pid, -1); newObj->fThis->Init(nil, pname, pid, -1);

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

@ -589,11 +589,11 @@ void plNotifyMsg::AddControlKeyEvent( int32_t key, bool down )
// //
// PURPOSE : Add a variable event record to this notify message // PURPOSE : Add a variable event record to this notify message
// //
void plNotifyMsg::AddVariableEvent( const char* name, float number ) void plNotifyMsg::AddVariableEvent(const plString& name, float number)
{ {
// create the control key event record // create the control key event record
proVariableEventData* pED = new proVariableEventData; proVariableEventData* pED = new proVariableEventData;
pED->fName = hsStrcpy(nil,name); pED->fName = name;
pED->fDataType = proEventData::kFloat; pED->fDataType = proEventData::kFloat;
pED->fNumber.f = number; pED->fNumber.f = number;
fEvents.Append(pED); // then add it to the list of event records fEvents.Append(pED); // then add it to the list of event records
@ -607,11 +607,11 @@ void plNotifyMsg::AddVariableEvent( const char* name, float number )
// //
// PURPOSE : Add a variable event record to this notify message // PURPOSE : Add a variable event record to this notify message
// //
void plNotifyMsg::AddVariableEvent( const char* name, int32_t number ) void plNotifyMsg::AddVariableEvent(const plString& name, int32_t number)
{ {
// create the control key event record // create the control key event record
proVariableEventData* pED = new proVariableEventData; proVariableEventData* pED = new proVariableEventData;
pED->fName = hsStrcpy(nil,name); pED->fName = name;
pED->fDataType = proEventData::kInt; pED->fDataType = proEventData::kInt;
pED->fNumber.i = number; pED->fNumber.i = number;
fEvents.Append(pED); // then add it to the list of event records fEvents.Append(pED); // then add it to the list of event records
@ -624,11 +624,11 @@ void plNotifyMsg::AddVariableEvent( const char* name, int32_t number )
// //
// PURPOSE : Add a variable event record to this notify message // PURPOSE : Add a variable event record to this notify message
// //
void plNotifyMsg::AddVariableEvent( const char* name) void plNotifyMsg::AddVariableEvent(const plString& name)
{ {
// create the control key event record // create the control key event record
proVariableEventData* pED = new proVariableEventData; proVariableEventData* pED = new proVariableEventData;
pED->fName = hsStrcpy(nil,name); pED->fName = name;
pED->fDataType = proEventData::kNull; pED->fDataType = proEventData::kNull;
fEvents.Append(pED); // then add it to the list of event records fEvents.Append(pED); // then add it to the list of event records
} }
@ -641,12 +641,11 @@ void plNotifyMsg::AddVariableEvent( const char* name)
// //
// PURPOSE : Add a variable event record to this notify message // PURPOSE : Add a variable event record to this notify message
// //
void plNotifyMsg::AddVariableEvent( const char* name, const plKey &key ) void plNotifyMsg::AddVariableEvent(const plString& name, const plKey &key)
{ {
// create the control key event record // create the control key event record
proVariableEventData* pED = new proVariableEventData; proVariableEventData* pED = new proVariableEventData;
pED->fName = hsStrcpy(nil,name); pED->fName = name;
// pED->fName = (char*)name;
pED->fDataType = proEventData::kKey; pED->fDataType = proEventData::kKey;
pED->fKey = key; pED->fKey = key;
fEvents.Append(pED); // then add it to the list of event records fEvents.Append(pED); // then add it to the list of event records
@ -1312,13 +1311,12 @@ void proControlKeyEventData::IWriteVersion(hsStream* s, hsResMgr* mgr)
void proVariableEventData::IInit() void proVariableEventData::IInit()
{ {
fName = nil; fName = plString::Null;
} }
void proVariableEventData::IDestruct() void proVariableEventData::IDestruct()
{ {
if ( fName != nil ) fName = plString::Null;
delete [] fName;
fName = nil;
} }
void proVariableEventData::IReadNumber(hsStream * stream) { void proVariableEventData::IReadNumber(hsStream * stream) {
@ -1353,7 +1351,7 @@ void proVariableEventData::IWriteNumber(hsStream * stream) {
void proVariableEventData::IRead(hsStream* stream, hsResMgr* mgr) void proVariableEventData::IRead(hsStream* stream, hsResMgr* mgr)
{ {
fName = stream->ReadSafeString(); fName = stream->ReadSafeString_TEMP();
fDataType = stream->ReadLE32(); fDataType = stream->ReadLE32();
IReadNumber(stream); IReadNumber(stream);
fKey = mgr->ReadKey(stream); fKey = mgr->ReadKey(stream);
@ -1381,7 +1379,7 @@ void proVariableEventData::IReadVersion(hsStream* s, hsResMgr* mgr)
contentFlags.Read(s); contentFlags.Read(s);
if (contentFlags.IsBitSet(kProVariableName)) if (contentFlags.IsBitSet(kProVariableName))
fName = s->ReadSafeString(); fName = s->ReadSafeString_TEMP();
if (contentFlags.IsBitSet(kProVariableDataType)) if (contentFlags.IsBitSet(kProVariableDataType))
fDataType = s->ReadLE32(); fDataType = s->ReadLE32();
if (contentFlags.IsBitSet(kProVariableNumber)) if (contentFlags.IsBitSet(kProVariableNumber))

10
Sources/Plasma/NucleusLib/pnMessage/plNotifyMsg.h

@ -179,7 +179,7 @@ protected:
}; };
proEventType(Variable) proEventType(Variable)
char* fName; // name of variable plString fName; // name of variable
int32_t fDataType; // type of data int32_t fDataType; // type of data
// Can't be a union, sadly, but it isn't that much of a waste of space... // Can't be a union, sadly, but it isn't that much of a waste of space...
@ -375,10 +375,10 @@ public:
void AddCollisionEvent( bool enter, const plKey &other, const plKey &self, bool onlyOneCollision=true ); void AddCollisionEvent( bool enter, const plKey &other, const plKey &self, bool onlyOneCollision=true );
void AddPickEvent( const plKey &other, const plKey& self, bool enabled, hsPoint3 hitPoint ); void AddPickEvent( const plKey &other, const plKey& self, bool enabled, hsPoint3 hitPoint );
void AddControlKeyEvent( int32_t key, bool down ); void AddControlKeyEvent( int32_t key, bool down );
void AddVariableEvent( const char* name, float number ); void AddVariableEvent( const plString& name, float number );
void AddVariableEvent( const char* name, int32_t number ); void AddVariableEvent( const plString& name, int32_t number );
void AddVariableEvent( const char* name ); void AddVariableEvent( const plString& name );
void AddVariableEvent( const char *name, const plKey &key ); void AddVariableEvent( const plString& name, const plKey &key );
void AddFacingEvent( const plKey &other, const plKey &self, float dot, bool enabled); void AddFacingEvent( const plKey &other, const plKey &self, float dot, bool enabled);
void AddContainerEvent( const plKey &container, const plKey &contained, bool entering); void AddContainerEvent( const plKey &container, const plKey &contained, bool entering);
void AddActivateEvent( bool activate ); void AddActivateEvent( bool activate );

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

@ -77,8 +77,7 @@ class plAGAnim;
// PLANIMSTAGE default ctor // PLANIMSTAGE default ctor
plAnimStage::plAnimStage() plAnimStage::plAnimStage()
: fAnimName(nil), : fNotify(0),
fNotify(0),
fArmature(nil), fArmature(nil),
fBrain(nil), fBrain(nil),
fForwardType(kForwardNone), fForwardType(kForwardNone),
@ -102,8 +101,9 @@ plAnimStage::plAnimStage()
{ {
} }
plAnimStage::plAnimStage(const char *animName, uint8_t notify) plAnimStage::plAnimStage(const plString &animName, uint8_t notify)
: fNotify(notify), : fAnimName(animName),
fNotify(notify),
fArmature(nil), fArmature(nil),
fBrain(nil), fBrain(nil),
fForwardType(kForwardAuto), // different from default fForwardType(kForwardAuto), // different from default
@ -125,19 +125,19 @@ plAnimStage::plAnimStage(const char *animName, uint8_t notify)
fReverseOnIdle(false), fReverseOnIdle(false),
fDone(false) fDone(false)
{ {
fAnimName = hsStrcpy(animName);
} }
// PLANIMSTAGE canonical ctor // PLANIMSTAGE canonical ctor
plAnimStage::plAnimStage(const char *animName, plAnimStage::plAnimStage(const plString &animName,
uint8_t notify, uint8_t notify,
ForwardType forward, ForwardType forward,
BackType back, BackType back,
AdvanceType advance, AdvanceType advance,
RegressType regress, RegressType regress,
int loops) int loops)
: fArmature(nil), : fAnimName(animName),
fArmature(nil),
fBrain(nil), fBrain(nil),
fNotify(notify), fNotify(notify),
fForwardType(forward), fForwardType(forward),
@ -159,10 +159,9 @@ plAnimStage::plAnimStage(const char *animName,
fReverseOnIdle(false), fReverseOnIdle(false),
fDone(false) fDone(false)
{ {
fAnimName = hsStrcpy(animName);
} }
plAnimStage::plAnimStage(const char *animName, plAnimStage::plAnimStage(const plString &animName,
uint8_t notify, uint8_t notify,
ForwardType forward, ForwardType forward,
BackType back, BackType back,
@ -173,7 +172,8 @@ plAnimStage::plAnimStage(const char *animName,
int advanceTo, int advanceTo,
bool doRegressTo, bool doRegressTo,
int regressTo) int regressTo)
: fArmature(nil), : fAnimName(animName),
fArmature(nil),
fBrain(nil), fBrain(nil),
fNotify(notify), fNotify(notify),
fForwardType(forward), fForwardType(forward),
@ -195,15 +195,11 @@ plAnimStage::plAnimStage(const char *animName,
fReverseOnIdle(false), fReverseOnIdle(false),
fDone(false) fDone(false)
{ {
fAnimName = hsStrcpy(animName);
} }
// PLANIMSTAGE dtor // PLANIMSTAGE dtor
plAnimStage::~plAnimStage() plAnimStage::~plAnimStage()
{ {
if(fAnimName)
delete[] fAnimName;
hsAssert(fAnimInstance == nil, "plAnimStage still has anim instance during destruction. (that's bad.)"); hsAssert(fAnimInstance == nil, "plAnimStage still has anim instance during destruction. (that's bad.)");
// we could delete the animation instance here, but it should have been deleted already... // we could delete the animation instance here, but it should have been deleted already...
// *** check back in a while.... // *** check back in a while....
@ -213,7 +209,7 @@ plAnimStage::~plAnimStage()
// ---------- // ----------
const plAnimStage& plAnimStage::operator=(const plAnimStage& src) const plAnimStage& plAnimStage::operator=(const plAnimStage& src)
{ {
fAnimName = hsStrcpy(src.fAnimName); fAnimName = src.fAnimName;
fNotify = src.fNotify; fNotify = src.fNotify;
fForwardType = src.fForwardType; fForwardType = src.fForwardType;
fBackType = src.fBackType; fBackType = src.fBackType;
@ -260,12 +256,12 @@ plAGAnimInstance * plAnimStage::Attach(plArmatureMod *armature, plArmatureBrain
fAnimInstance->SetCurrentTime(fLocalTime); fAnimInstance->SetCurrentTime(fLocalTime);
#ifdef DEBUG_MULTISTAGE #ifdef DEBUG_MULTISTAGE
char sbuf[256]; char sbuf[256];
sprintf(sbuf,"AnimStage::Attach - attaching stage %s",fAnimName); snprintf(sbuf, arrsize(sbuf), "AnimStage::Attach - attaching stage %s", fAnimName.c_str());
plAvatarMgr::GetInstance()->GetLog()->AddLine(sbuf); plAvatarMgr::GetInstance()->GetLog()->AddLine(sbuf);
#endif #endif
} else { } else {
char buf[256]; char buf[256];
sprintf(buf, "Can't find animation <%s> for animation stage. Anything could happen.", fAnimName); snprintf(buf, arrsize(buf), "Can't find animation <%s> for animation stage. Anything could happen.", fAnimName.c_str());
hsAssert(false, buf); hsAssert(false, buf);
#ifdef DEBUG_MULTISTAGE #ifdef DEBUG_MULTISTAGE
plAvatarMgr::GetInstance()->GetLog()->AddLine(buf); plAvatarMgr::GetInstance()->GetLog()->AddLine(buf);
@ -332,10 +328,10 @@ bool plAnimStage::Detach(plArmatureMod *armature)
#ifdef DEBUG_MULTISTAGE #ifdef DEBUG_MULTISTAGE
char sbuf[256]; char sbuf[256];
sprintf(sbuf,"AnimStage::Detach - detaching stage %s",fAnimName); snprintf(sbuf, arrsize(sbuf), "AnimStage::Detach - detaching stage %s", fAnimName.c_str());
plAvatarMgr::GetInstance()->GetLog()->AddLine(sbuf); plAvatarMgr::GetInstance()->GetLog()->AddLine(sbuf);
#endif #endif
// hsStatusMessageF("Detaching plAnimStage <%s>", fAnimName); // hsStatusMessageF("Detaching plAnimStage <%s>", fAnimName.c_str());
if(fArmature) { if(fArmature) {
fArmature = nil; fArmature = nil;
@ -346,9 +342,7 @@ bool plAnimStage::Detach(plArmatureMod *armature)
} }
#ifdef DEBUG_MULTISTAGE #ifdef DEBUG_MULTISTAGE
} else { } else {
char sbuf[256]; plAvatarMgr::GetInstance()->GetLog()->AddLine("AnimStage::Detach: stage already detached");
sprintf(sbuf,"AnimStage::Detach: stage already detached");
plAvatarMgr::GetInstance()->GetLog()->AddLine(sbuf);
#endif #endif
// hsStatusMessageF("Detach: stage already detached."); // hsStatusMessageF("Detach: stage already detached.");
} }
@ -535,7 +529,7 @@ bool plAnimStage::ITryAdvance(plArmatureMod *avMod)
bool stageDone = false; bool stageDone = false;
// hsStatusMessageF("Sending advance message for stage <%s>\n", fAnimName); // hsStatusMessageF("Sending advance message for stage <%s>\n", fAnimName.c_str());
if(fAdvanceType == kAdvanceAuto || fAdvanceType == kAdvanceOnMove) { if(fAdvanceType == kAdvanceAuto || fAdvanceType == kAdvanceOnMove) {
stageDone = true; stageDone = true;
} }
@ -562,7 +556,7 @@ bool plAnimStage::ITryRegress(plArmatureMod *avMod)
// we may want to rename this to "ReachedStageEnd" // we may want to rename this to "ReachedStageEnd"
ISendNotify(kNotifyRegress, proEventData::kRegressPrevStage, avMod, fBrain); ISendNotify(kNotifyRegress, proEventData::kRegressPrevStage, avMod, fBrain);
// hsStatusMessageF("Sending regress message for stage <%s>\n", fAnimName); // hsStatusMessageF("Sending regress message for stage <%s>\n", fAnimName.c_str());
if(fRegressType == kRegressAuto) { if(fRegressType == kRegressAuto) {
stageDone = true; stageDone = true;
} }
@ -570,12 +564,6 @@ bool plAnimStage::ITryRegress(plArmatureMod *avMod)
} }
// GETANIMNAME
const char * plAnimStage::GetAnimName()
{
return fAnimName;
}
// GETFORWARDTYPE // GETFORWARDTYPE
plAnimStage::ForwardType plAnimStage::GetForwardType() plAnimStage::ForwardType plAnimStage::GetForwardType()
{ {
@ -728,27 +716,24 @@ int plAnimStage::GetPrevStage(int curStage)
} }
// DUMPDEBUG // DUMPDEBUG
void plAnimStage::DumpDebug(bool active, int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt) void plAnimStage::DumpDebug(bool active, int &x, int &y, int lineHeight, plDebugText &debugTxt)
{ {
std::string str; plStringStream str;
str += fAnimName; str << fAnimName;
str += " "; str << " ";
if(fLoops) { if(fLoops)
sprintf(strBuf, "loop(%d/%d)", fCurLoop, fLoops); str << plString::Format("loop(%d/%d)", fCurLoop, fLoops);
str += strBuf;
}
sprintf(strBuf, "time: (%f/%f)", fLocalTime, fLength); str << plString::Format("time: (%f/%f)", fLocalTime, fLength);
str += strBuf;
if(active) if(active)
debugTxt.DrawString(x, y, str.c_str(), 0, 255, 0); debugTxt.DrawString(x, y, str.GetString().c_str(), 0, 255, 0);
else if(fAnimInstance) else if(fAnimInstance)
debugTxt.DrawString(x, y, str.c_str()); debugTxt.DrawString(x, y, str.GetString().c_str());
else else
debugTxt.DrawString(x, y, str.c_str(), 255, 255, 0); debugTxt.DrawString(x, y, str.GetString().c_str(), 255, 255, 0);
y += lineHeight; y += lineHeight;
} }
@ -756,8 +741,7 @@ void plAnimStage::DumpDebug(bool active, int &x, int &y, int lineHeight, char *s
// READ // READ
void plAnimStage::Read(hsStream *stream, hsResMgr *mgr) void plAnimStage::Read(hsStream *stream, hsResMgr *mgr)
{ {
delete [] fAnimName; fAnimName = stream->ReadSafeString_TEMP();
fAnimName = stream->ReadSafeString();
fNotify = stream->ReadByte(); fNotify = stream->ReadByte();
fForwardType = (ForwardType)stream->ReadLE32(); fForwardType = (ForwardType)stream->ReadLE32();
fBackType = (BackType)stream->ReadLE32(); fBackType = (BackType)stream->ReadLE32();

19
Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.h

@ -50,6 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <vector> #include <vector>
#include "hsMatrix44.h" #include "hsMatrix44.h"
#include "pnFactory/plCreatable.h" #include "pnFactory/plCreatable.h"
#include "plString.h"
class plMessage; class plMessage;
class plAGAnimInstance; class plAGAnimInstance;
@ -158,7 +159,7 @@ public:
animation attempts to reposition the avatar by having a animation attempts to reposition the avatar by having a
channel attached to the avatar's handle. channel attached to the avatar's handle.
*/ */
plAnimStage(const char *animName, plAnimStage(const plString &animName,
uint8_t notify, uint8_t notify,
ForwardType forward, ForwardType forward,
BackType backward, BackType backward,
@ -172,7 +173,7 @@ public:
will be played after this one, depending on which direction the stage is will be played after this one, depending on which direction the stage is
moving. moving.
*/ */
plAnimStage(const char *animName, plAnimStage(const plString &animName,
uint8_t notify, uint8_t notify,
ForwardType forward, ForwardType forward,
BackType back, BackType back,
@ -189,7 +190,7 @@ public:
\param animName The name of the animation controlled by this stage. \param animName The name of the animation controlled by this stage.
\param notify Flags for when to send notify messages \param notify Flags for when to send notify messages
*/ */
plAnimStage(const char *animName, uint8_t notify); plAnimStage(const plString &animName, uint8_t notify);
virtual ~plAnimStage(); virtual ~plAnimStage();
const plAnimStage& operator=(const plAnimStage& src); const plAnimStage& operator=(const plAnimStage& src);
@ -200,7 +201,7 @@ public:
bool MoveRelative(double worldTime, float delta, float &overage, plArmatureMod *avMod); bool MoveRelative(double worldTime, float delta, float &overage, plArmatureMod *avMod);
/** The name of the animation associated with this stage. */ /** The name of the animation associated with this stage. */
const char * GetAnimName(); plString GetAnimName() const { return fAnimName; }
ForwardType GetForwardType(); ForwardType GetForwardType();
void SetForwardType(ForwardType t); void SetForwardType(ForwardType t);
@ -230,7 +231,7 @@ public:
plAGAnimInstance *GetAnimInstance() const { return fAnimInstance; }; plAGAnimInstance *GetAnimInstance() const { return fAnimInstance; };
bool GetReverseOnIdle() { return fReverseOnIdle; } bool GetReverseOnIdle() { return fReverseOnIdle; }
void SetReverseOnIdle(bool onOff) { fReverseOnIdle = onOff; } void SetReverseOnIdle(bool onOff) { fReverseOnIdle = onOff; }
void DumpDebug(bool active, int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt); void DumpDebug(bool active, int &x, int &y, int lineHeight, plDebugText &debugTxt);
// STANDARD PLASMA PROTOCOL // STANDARD PLASMA PROTOCOL
virtual void Read(hsStream *stream, hsResMgr *mgr); virtual void Read(hsStream *stream, hsResMgr *mgr);
@ -254,14 +255,14 @@ protected:
bool ISendNotify(uint32_t notifyMask, uint32_t notifyType, plArmatureMod *armature, plArmatureBrain *brain); bool ISendNotify(uint32_t notifyMask, uint32_t notifyType, plArmatureMod *armature, plArmatureBrain *brain);
char *fAnimName; // the name of our animation plString fAnimName; // the name of our animation
uint8_t fNotify; // flags for which events will cause notification events uint8_t fNotify; // flags for which events will cause notification events
int fLoops; // how many times will this animation loop (after initial playthrough?) int fLoops; // how many times will this animation loop (after initial playthrough?)
bool fDoAdvanceTo; // advance to a specific stage instead of n + 1 bool fDoAdvanceTo; // advance to a specific stage instead of n + 1
uint32_t fAdvanceTo; // the stage to advance to, provided fDoAdvanceTo is true uint32_t fAdvanceTo; // the stage to advance to, provided fDoAdvanceTo is true
bool fDoRegressTo; // regress to a specific stage instaed of n - 1 bool fDoRegressTo; // regress to a specific stage instaed of n - 1
uint32_t fRegressTo; // the stage to regress true, provided fDoRegressTo is true uint32_t fRegressTo; // the stage to regress true, provided fDoRegressTo is true
// --- these are derived & kept for bookkeeping // --- these are derived & kept for bookkeeping
plAGAnimInstance *fAnimInstance; plAGAnimInstance *fAnimInstance;

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

@ -2649,7 +2649,6 @@ void plArmatureLODMod::Write(hsStream *stream, hsResMgr *mgr)
int plArmatureMod::RefreshDebugDisplay() int plArmatureMod::RefreshDebugDisplay()
{ {
plDebugText &debugTxt = plDebugText::Instance(); plDebugText &debugTxt = plDebugText::Instance();
char strBuf[ 2048 ];
int lineHeight = debugTxt.GetFontSize() + 4; int lineHeight = debugTxt.GetFontSize() + 4;
uint32_t scrnWidth, scrnHeight; uint32_t scrnWidth, scrnHeight;
@ -2657,14 +2656,13 @@ int plArmatureMod::RefreshDebugDisplay()
int y = 10; int y = 10;
int x = 10; int x = 10;
DumpToDebugDisplay(x, y, lineHeight, strBuf, debugTxt); DumpToDebugDisplay(x, y, lineHeight, debugTxt);
return y; return y;
} }
void plArmatureMod::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt) void plArmatureMod::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{ {
sprintf(strBuf, "Armature <%s>:", fRootName.c_str()); debugTxt.DrawString(x, y, plString::Format("Armature <%s>:", fRootName.c_str()), 255, 128, 128);
debugTxt.DrawString(x, y, strBuf, 255, 128, 128);
y += lineHeight; y += lineHeight;
plSceneObject * SO = GetTarget(0); plSceneObject * SO = GetTarget(0);
@ -2675,9 +2673,8 @@ void plArmatureMod::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *str
hsPoint3 worldPos = l2w.GetTranslate(); hsPoint3 worldPos = l2w.GetTranslate();
const char *opaque = IsOpaque() ? "yes" : "no"; const char *opaque = IsOpaque() ? "yes" : "no";
sprintf(strBuf, "position(world): %.2f, %.2f, %.2f Opaque: %3s", debugTxt.DrawString(x, y, plString::Format("position(world): %.2f, %.2f, %.2f Opaque: %3s",
worldPos.fX, worldPos.fY, worldPos.fZ, opaque); worldPos.fX, worldPos.fY, worldPos.fZ, opaque));
debugTxt.DrawString(x, y, strBuf);
y += lineHeight; y += lineHeight;
const char* frozen = "n.a."; const char* frozen = "n.a.";
@ -2688,32 +2685,34 @@ void plArmatureMod::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *str
plKey world = nil; plKey world = nil;
if (fController) if (fController)
world = fController->GetSubworld(); world = fController->GetSubworld();
sprintf(strBuf, "In world: %s Frozen: %s", world ? world->GetName().c_str() : "nil", frozen); debugTxt.DrawString(x, y, plString::Format("In world: %s Frozen: %s",
debugTxt.DrawString(x,y, strBuf); world ? world->GetName().c_str() : "nil", frozen));
y+= lineHeight; y+= lineHeight;
plString details;
if (fController) if (fController)
{ {
hsPoint3 physPos; hsPoint3 physPos;
GetPositionAndRotationSim(&physPos, nil); GetPositionAndRotationSim(&physPos, nil);
const hsVector3& vel = fController->GetLinearVelocity(); const hsVector3& vel = fController->GetLinearVelocity();
sprintf(strBuf, "position(physical): <%.2f, %.2f, %.2f> velocity: <%5.2f, %5.2f, %5.2f>", physPos.fX, physPos.fY, physPos.fZ, vel.fX, vel.fY, vel.fZ); details = plString::Format("position(physical): <%.2f, %.2f, %.2f> velocity: <%5.2f, %5.2f, %5.2f>",
physPos.fX, physPos.fY, physPos.fZ, vel.fX, vel.fY, vel.fZ);
} }
else else
{ {
sprintf(strBuf, "position(physical): no controller"); details = "position(physical): no controller";
} }
debugTxt.DrawString(x, y, strBuf); debugTxt.DrawString(x, y, details);
y += lineHeight; y += lineHeight;
} }
DebugDumpMoveKeys(x, y, lineHeight, strBuf, debugTxt); DebugDumpMoveKeys(x, y, lineHeight, debugTxt);
int i; int i;
for(i = 0; i < fBrains.size(); i++) for(i = 0; i < fBrains.size(); i++)
{ {
plArmatureBrain *brain = fBrains[i]; plArmatureBrain *brain = fBrains[i];
brain->DumpToDebugDisplay(x, y, lineHeight, strBuf, debugTxt); brain->DumpToDebugDisplay(x, y, lineHeight, debugTxt);
} }
if (fClothingOutfit) if (fClothingOutfit)
@ -2722,30 +2721,30 @@ void plArmatureMod::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *str
debugTxt.DrawString(x, y, "ItemsWorn:"); debugTxt.DrawString(x, y, "ItemsWorn:");
y += lineHeight; y += lineHeight;
strBuf[0] = '\0'; plStringStream outfit;
int itemCount = 0; int itemCount = 0;
for (i = 0; i < fClothingOutfit->fItems.GetCount(); i++) for (i = 0; i < fClothingOutfit->fItems.GetCount(); i++)
{ {
if (itemCount == 0) if (itemCount == 0)
strcat(strBuf, " "); outfit << " ";
strcat(strBuf, fClothingOutfit->fItems[i]->fName); outfit << fClothingOutfit->fItems[i]->fName;
itemCount++; itemCount++;
if (itemCount == 4) if (itemCount == 4)
{ {
debugTxt.DrawString(x, y, strBuf); debugTxt.DrawString(x, y, outfit.GetString());
itemCount = 0; itemCount = 0;
strBuf[0] = '\0'; outfit.Truncate();
y += lineHeight; y += lineHeight;
} }
if (itemCount > 0) if (itemCount > 0)
strcat(strBuf, ", "); outfit << ", ";
} }
if (itemCount > 0) if (itemCount > 0)
{ {
debugTxt.DrawString(x, y, strBuf); debugTxt.DrawString(x, y, outfit.GetString());
y += lineHeight; y += lineHeight;
} }
} }
@ -2756,11 +2755,11 @@ void plArmatureMod::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *str
debugTxt.DrawString(x, y, "Relevance Regions:"); debugTxt.DrawString(x, y, "Relevance Regions:");
y += lineHeight; y += lineHeight;
sprintf(strBuf, " In: %s", plRelevanceMgr::Instance()->GetRegionNames(fRegionsImIn).c_str()); debugTxt.DrawString(x, y, plString::Format(" In: %s",
debugTxt.DrawString(x, y, strBuf); plRelevanceMgr::Instance()->GetRegionNames(fRegionsImIn).c_str()));
y += lineHeight; y += lineHeight;
sprintf(strBuf, " Care about: %s", plRelevanceMgr::Instance()->GetRegionNames(fRegionsICareAbout).c_str()); debugTxt.DrawString(x, y, plString::Format(" Care about: %s",
debugTxt.DrawString(x, y, strBuf); plRelevanceMgr::Instance()->GetRegionNames(fRegionsICareAbout).c_str()));
y += lineHeight; y += lineHeight;
} }
} }
@ -2799,42 +2798,43 @@ void plAvBoneMap::AddBoneMapping(uint32_t boneID, const plSceneObject *SO)
(fImp->fMap)[boneID] = SO; (fImp->fMap)[boneID] = SO;
} }
void plArmatureMod::DebugDumpMoveKeys(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt) void plArmatureMod::DebugDumpMoveKeys(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{ {
char buff[256]; debugTxt.DrawString(x, y, plString::Format("Mouse Input Map: %s",
sprintf(buff, "Mouse Input Map: %s", plAvatarInputInterface::GetInstance()->GetInputMapName()); plAvatarInputInterface::GetInstance()->GetInputMapName()));
debugTxt.DrawString(x, y, buff);
y += lineHeight; y += lineHeight;
sprintf(buff, "Turn strength: %.2f (key: %.2f, analog: %.2f)", GetTurnStrength(), GetKeyTurnStrength(), GetAnalogTurnStrength()); debugTxt.DrawString(x, y, plString::Format("Turn strength: %.2f (key: %.2f, analog: %.2f)",
debugTxt.DrawString(x, y, buff); GetTurnStrength(), GetKeyTurnStrength(), GetAnalogTurnStrength()));
y += lineHeight; y += lineHeight;
GetMoveKeyString(buff); debugTxt.DrawString(x, y, GetMoveKeyString());
debugTxt.DrawString(x, y, buff);
y += lineHeight; y += lineHeight;
} }
void plArmatureMod::GetMoveKeyString(char *buff) plString plArmatureMod::GetMoveKeyString() const
{ {
sprintf(buff, "Move keys: "); plStringStream keys;
keys << "Move keys: ";
if(FastKeyDown()) if(FastKeyDown())
strcat(buff, "FAST "); keys << "FAST ";
if(StrafeKeyDown()) if(StrafeKeyDown())
strcat(buff, "STRAFE "); keys << "STRAFE ";
if(ForwardKeyDown()) if(ForwardKeyDown())
strcat(buff, "FORWARD "); keys << "FORWARD ";
if(BackwardKeyDown()) if(BackwardKeyDown())
strcat(buff, "BACKWARD "); keys << "BACKWARD ";
if(TurnLeftKeyDown()) if(TurnLeftKeyDown())
strcat(buff, "TURNLEFT "); keys << "TURNLEFT ";
if(TurnRightKeyDown()) if(TurnRightKeyDown())
strcat(buff, "TURNRIGHT "); keys << "TURNRIGHT ";
if(StrafeLeftKeyDown()) if(StrafeLeftKeyDown())
strcat(buff, "STRAFELEFT "); keys << "STRAFELEFT ";
if(StrafeRightKeyDown()) if(StrafeRightKeyDown())
strcat(buff, "STRAFERIGHT "); keys << "STRAFERIGHT ";
if(JumpKeyDown()) if(JumpKeyDown())
strcat(buff, "JUMP "); keys << "JUMP ";
return keys.GetString();
} }

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

@ -278,8 +278,8 @@ public:
void SetTurnLeftKeyDown(bool status = true); void SetTurnLeftKeyDown(bool status = true);
void SetTurnRightKeyDown(bool status = true); void SetTurnRightKeyDown(bool status = true);
void SetJumpKeyDown(); void SetJumpKeyDown();
void DebugDumpMoveKeys(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt); void DebugDumpMoveKeys(int &x, int &y, int lineHeight, plDebugText &debugTxt);
void GetMoveKeyString(char *buff); plString GetMoveKeyString() const;
void SynchIfLocal(double timeNow, int force); // Just physical state void SynchIfLocal(double timeNow, int force); // Just physical state
void SynchInputState(uint32_t rcvID = kInvalidPlayerID); void SynchInputState(uint32_t rcvID = kInvalidPlayerID);
@ -310,7 +310,7 @@ public:
void SetRootName(const plString &name); void SetRootName(const plString &name);
int RefreshDebugDisplay(); int RefreshDebugDisplay();
void DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt); void DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt);
void SetDebugState(bool state) { fDebugOn = (state != 0); } void SetDebugState(bool state) { fDebugOn = (state != 0); }
bool GetDebugState() { return fDebugOn; } bool GetDebugState() { return fDebugOn; }

9
Sources/Plasma/PubUtilLib/plAvatar/plAvBehaviors.cpp

@ -101,7 +101,7 @@ void plArmatureBehavior::Rewind()
fAnim->SetCurrentTime(0.0f, true); fAnim->SetCurrentTime(0.0f, true);
} }
void plArmatureBehavior::DumpDebug(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt) void plArmatureBehavior::DumpDebug(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{ {
float strength = GetStrength(); float strength = GetStrength();
const char *onOff = strength > 0 ? "on" : "off"; const char *onOff = strength > 0 ? "on" : "off";
@ -109,16 +109,17 @@ void plArmatureBehavior::DumpDebug(int &x, int &y, int lineHeight, char *strBuf,
int bars = (int)min(10 * strength, 10); int bars = (int)min(10 * strength, 10);
blendBar[bars] = '\0'; blendBar[bars] = '\0';
plString details;
if (fAnim) if (fAnim)
{ {
plString animName = fAnim->GetName(); plString animName = fAnim->GetName();
float time = fAnim->GetTimeConvert()->CurrentAnimTime(); float time = fAnim->GetTimeConvert()->CurrentAnimTime();
sprintf(strBuf, "%20s %3s time: %5.2f %s", animName.c_str(), onOff, time, blendBar); details = plString::Format("%20s %3s time: %5.2f %s", animName.c_str(), onOff, time, blendBar);
} }
else else
sprintf(strBuf, " Behavior %2d %3s %s", fIndex, onOff, blendBar); details = plString::Format(" Behavior %2d %3s %s", fIndex, onOff, blendBar);
debugTxt.DrawString(x, y, strBuf); debugTxt.DrawString(x, y, details);
y += lineHeight; y += lineHeight;
} }

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

@ -65,7 +65,7 @@ public:
virtual void SetStrength(float val, float rate = 0.f); // default instant change virtual void SetStrength(float val, float rate = 0.f); // default instant change
virtual float GetStrength(); virtual float GetStrength();
virtual void Rewind(); virtual void Rewind();
void DumpDebug(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt); void DumpDebug(int &x, int &y, int lineHeight, plDebugText &debugTxt);
enum enum
{ {

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

@ -81,7 +81,7 @@ public:
virtual bool LeaveAge(); virtual bool LeaveAge();
virtual bool IsRunningTask() const; virtual bool IsRunningTask() const;
virtual void QueueTask(plAvTask *task); virtual void QueueTask(plAvTask *task);
virtual void DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt) {} virtual void DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt) {}
virtual void Write(hsStream *stream, hsResMgr *mgr); virtual void Write(hsStream *stream, hsResMgr *mgr);
virtual void Read(hsStream *stream, hsResMgr *mgr); virtual void Read(hsStream *stream, hsResMgr *mgr);

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

@ -884,7 +884,7 @@ void plAvBrainClimb::LoadFromSDL(const plStateDataRecord *sdl)
// DumpToDebugDisplay -------------------------------------------------------------------------------------- // DumpToDebugDisplay --------------------------------------------------------------------------------------
// ------------------ // ------------------
void plAvBrainClimb::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt) void plAvBrainClimb::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{ {
debugTxt.DrawString(x, y, "Brain type: Climb"); debugTxt.DrawString(x, y, "Brain type: Climb");
y += lineHeight; y += lineHeight;
@ -896,99 +896,99 @@ void plAvBrainClimb::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *st
debugTxt.DrawString(x,y, buffy); debugTxt.DrawString(x,y, buffy);
y += lineHeight; y += lineHeight;
IDumpClimbDirections(x, y, lineHeight, strBuf, debugTxt); IDumpClimbDirections(x, y, lineHeight, debugTxt);
IDumpDismountDirections(x, y, lineHeight, strBuf, debugTxt); IDumpDismountDirections(x, y, lineHeight, debugTxt);
IDumpBlockedDirections(x, y, lineHeight, strBuf, debugTxt); IDumpBlockedDirections(x, y, lineHeight, debugTxt);
fUp->DumpDebug(fUp == fCurStage, x, y, lineHeight, strBuf, debugTxt); fUp->DumpDebug(fUp == fCurStage, x, y, lineHeight, debugTxt);
fDown->DumpDebug(fDown == fCurStage, x, y, lineHeight, strBuf, debugTxt); fDown->DumpDebug(fDown == fCurStage, x, y, lineHeight, debugTxt);
fLeft->DumpDebug(fLeft == fCurStage, x, y, lineHeight, strBuf, debugTxt); fLeft->DumpDebug(fLeft == fCurStage, x, y, lineHeight, debugTxt);
fRight->DumpDebug(fRight == fCurStage, x, y, lineHeight, strBuf, debugTxt); fRight->DumpDebug(fRight == fCurStage, x, y, lineHeight, debugTxt);
fMountUp->DumpDebug(fMountUp == fCurStage, x, y, lineHeight, strBuf, debugTxt); fMountUp->DumpDebug(fMountUp == fCurStage, x, y, lineHeight, debugTxt);
fMountDown->DumpDebug(fMountDown == fCurStage, x, y, lineHeight, strBuf, debugTxt); fMountDown->DumpDebug(fMountDown == fCurStage, x, y, lineHeight, debugTxt);
fMountLeft->DumpDebug(fMountLeft == fCurStage, x, y, lineHeight, strBuf, debugTxt); fMountLeft->DumpDebug(fMountLeft == fCurStage, x, y, lineHeight, debugTxt);
fMountRight->DumpDebug(fMountRight == fCurStage, x, y, lineHeight, strBuf, debugTxt); fMountRight->DumpDebug(fMountRight == fCurStage, x, y, lineHeight, debugTxt);
fDismountUp->DumpDebug(fDismountUp == fCurStage, x, y, lineHeight, strBuf, debugTxt); fDismountUp->DumpDebug(fDismountUp == fCurStage, x, y, lineHeight, debugTxt);
fDismountDown->DumpDebug(fDismountDown == fCurStage, x, y, lineHeight, strBuf, debugTxt); fDismountDown->DumpDebug(fDismountDown == fCurStage, x, y, lineHeight, debugTxt);
fDismountLeft->DumpDebug(fDismountLeft == fCurStage, x, y, lineHeight, strBuf, debugTxt); fDismountLeft->DumpDebug(fDismountLeft == fCurStage, x, y, lineHeight, debugTxt);
fDismountRight->DumpDebug(fDismountRight == fCurStage, x, y, lineHeight, strBuf, debugTxt); fDismountRight->DumpDebug(fDismountRight == fCurStage, x, y, lineHeight, debugTxt);
fIdle->DumpDebug(fIdle == fCurStage, x, y, lineHeight, strBuf, debugTxt); fIdle->DumpDebug(fIdle == fCurStage, x, y, lineHeight, debugTxt);
fRelease->DumpDebug(fRelease == fCurStage, x, y, lineHeight, strBuf, debugTxt); fRelease->DumpDebug(fRelease == fCurStage, x, y, lineHeight, debugTxt);
fFallOff->DumpDebug(fFallOff == fCurStage, x, y, lineHeight, strBuf, debugTxt); fFallOff->DumpDebug(fFallOff == fCurStage, x, y, lineHeight, debugTxt);
} }
// IDumpClimbDirections -------------------------------------------------------------------------------------- // IDumpClimbDirections --------------------------------------------------------------------------------------
// -------------------- // --------------------
void plAvBrainClimb::IDumpClimbDirections(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt) void plAvBrainClimb::IDumpClimbDirections(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{ {
const char * prolog = "Allowed directions: "; static const char prolog[] = "Allowed directions: ";
std::string str; plStringStream str;
str = prolog; str << prolog;
if(fAllowedDirections & plClimbMsg::kUp) if(fAllowedDirections & plClimbMsg::kUp)
str = str + "UP "; str << "UP ";
if(fAllowedDirections & plClimbMsg::kDown) if(fAllowedDirections & plClimbMsg::kDown)
str = str + "DOWN "; str << "DOWN ";
if(fAllowedDirections & plClimbMsg::kLeft) if(fAllowedDirections & plClimbMsg::kLeft)
str = str + "LEFT "; str << "LEFT ";
if(fAllowedDirections & plClimbMsg::kRight) if(fAllowedDirections & plClimbMsg::kRight)
str = str + "RIGHT "; str << "RIGHT ";
if(str.size() == strlen(prolog)) if(str.GetLength() == strlen(prolog))
str = str + "- NONE -"; str << "- NONE -";
debugTxt.DrawString(x, y, str.c_str()); debugTxt.DrawString(x, y, str.GetString());
y += lineHeight; y += lineHeight;
} }
// IDumpDismountDirections -------------------------------------------------------------------------------------- // IDumpDismountDirections --------------------------------------------------------------------------------------
// ----------------------- // -----------------------
void plAvBrainClimb::IDumpDismountDirections(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt) void plAvBrainClimb::IDumpDismountDirections(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{ {
const char * prolog = "Enabled dismounts: "; static const char prolog[] = "Enabled dismounts: ";
std::string str; plStringStream str;
str = prolog; str << prolog;
if(fAllowedDismounts & plClimbMsg::kUp) if(fAllowedDismounts & plClimbMsg::kUp)
str = str + "UP "; str << "UP ";
if(fAllowedDismounts & plClimbMsg::kDown) if(fAllowedDismounts & plClimbMsg::kDown)
str = str + "DOWN "; str << "DOWN ";
if(fAllowedDismounts & plClimbMsg::kLeft) if(fAllowedDismounts & plClimbMsg::kLeft)
str = str + "LEFT "; str << "LEFT ";
if(fAllowedDismounts & plClimbMsg::kRight) if(fAllowedDismounts & plClimbMsg::kRight)
str = str + "RIGHT "; str << "RIGHT ";
if(str.size() == strlen(prolog)) if(str.GetLength() == strlen(prolog))
str = str + "- NONE -"; str << "- NONE -";
debugTxt.DrawString(x, y, str.c_str()); debugTxt.DrawString(x, y, str.GetString());
y += lineHeight; y += lineHeight;
} }
void plAvBrainClimb::IDumpBlockedDirections(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt) void plAvBrainClimb::IDumpBlockedDirections(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{ {
const char * prolog = "Physically blocked: "; static const char prolog[] = "Physically blocked: ";
std::string str; plStringStream str;
str = prolog; str << prolog;
if(fOldPhysicallyBlockedDirections & plClimbMsg::kUp) if(fOldPhysicallyBlockedDirections & plClimbMsg::kUp)
str = str + "UP "; str << "UP ";
if(fOldPhysicallyBlockedDirections & plClimbMsg::kDown) if(fOldPhysicallyBlockedDirections & plClimbMsg::kDown)
str = str + "DOWN "; str << "DOWN ";
if(fOldPhysicallyBlockedDirections & plClimbMsg::kLeft) if(fOldPhysicallyBlockedDirections & plClimbMsg::kLeft)
str = str + "LEFT "; str << "LEFT ";
if(fOldPhysicallyBlockedDirections & plClimbMsg::kRight) if(fOldPhysicallyBlockedDirections & plClimbMsg::kRight)
str = str + "RIGHT "; str << "RIGHT ";
if(str.size() == strlen(prolog)) if(str.GetLength() == strlen(prolog))
str = str + "- NONE -"; str << "- NONE -";
debugTxt.DrawString(x, y, str.c_str()); debugTxt.DrawString(x, y, str.GetString());
y += lineHeight; y += lineHeight;
} }
const char * plAvBrainClimb::WorldDirStr(plClimbMsg::Direction dir) const char *plAvBrainClimb::WorldDirStr(plClimbMsg::Direction dir)
{ {
switch(dir) switch(dir)
{ {

12
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.h

@ -103,9 +103,9 @@ public:
virtual void SaveToSDL(plStateDataRecord *sdl); virtual void SaveToSDL(plStateDataRecord *sdl);
virtual void LoadFromSDL(const plStateDataRecord *sdl); virtual void LoadFromSDL(const plStateDataRecord *sdl);
void DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt); void DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt);
const char * WorldDirStr(plClimbMsg::Direction dir); static const char *WorldDirStr(plClimbMsg::Direction dir);
const char *ModeStr(Mode mode); static const char *ModeStr(Mode mode);
// plasma protocol // plasma protocol
virtual bool MsgReceive(plMessage *msg); virtual bool MsgReceive(plMessage *msg);
@ -173,9 +173,9 @@ private:
*/ */
bool IProcessExitStage(double time, float elapsed); bool IProcessExitStage(double time, float elapsed);
void IDumpClimbDirections(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt); void IDumpClimbDirections(int &x, int &y, int lineHeight, plDebugText &debugTxt);
void IDumpDismountDirections(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt); void IDumpDismountDirections(int &x, int &y, int lineHeight, plDebugText &debugTxt);
void IDumpBlockedDirections(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt); void IDumpBlockedDirections(int &x, int &y, int lineHeight, plDebugText &debugTxt);
//////////////////////////// ////////////////////////////
// //

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

@ -435,23 +435,21 @@ void plAvBrainCritter::RemoveReceiver(const plKey key)
return; // not found, do nothing return; // not found, do nothing
} }
void plAvBrainCritter::DumpToDebugDisplay(int& x, int& y, int lineHeight, char* strBuf, plDebugText& debugTxt) void plAvBrainCritter::DumpToDebugDisplay(int& x, int& y, int lineHeight, plDebugText& debugTxt)
{ {
sprintf(strBuf, "Brain type: Critter"); debugTxt.DrawString(x, y, "Brain type: Critter", 0, 255, 255);
debugTxt.DrawString(x, y, strBuf, 0, 255, 255);
y += lineHeight; y += lineHeight;
// extract the name from the behavior running // extract the name from the behavior running
plString mode = "Mode: Unknown";
if (fBehaviors[fCurMode]) if (fBehaviors[fCurMode])
sprintf(strBuf, "Mode: %s", ((CritterBehavior*)(fBehaviors[fCurMode]))->Name().c_str()); mode = plString::Format("Mode: %s", ((CritterBehavior*)(fBehaviors[fCurMode]))->Name().c_str());
else
sprintf(strBuf, "Mode: Unknown");
// draw it // draw it
debugTxt.DrawString(x, y, strBuf); debugTxt.DrawString(x, y, mode);
y += lineHeight; y += lineHeight;
for (int i = 0; i < fBehaviors.GetCount(); ++i) for (int i = 0; i < fBehaviors.GetCount(); ++i)
fBehaviors[i]->DumpDebug(x, y, lineHeight, strBuf, debugTxt); fBehaviors[i]->DumpDebug(x, y, lineHeight, debugTxt);
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

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

@ -133,7 +133,7 @@ public:
void AddReceiver(const plKey key); void AddReceiver(const plKey key);
void RemoveReceiver(const plKey key); void RemoveReceiver(const plKey key);
virtual void DumpToDebugDisplay(int& x, int& y, int lineHeight, char* strBuf, plDebugText& debugTxt); virtual void DumpToDebugDisplay(int& x, int& y, int lineHeight, plDebugText& debugTxt);
// For the console // For the console
static bool fDrawDebug; static bool fDrawDebug;

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

@ -229,7 +229,7 @@ bool plAvBrainGeneric::MatchAnimNames(const char *names[], int count)
int i; int i;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
if (strcmp(names[i], GetStage(i)->GetAnimName())) if (GetStage(i)->GetAnimName() != names[i])
return false; // different names. return false; // different names.
} }
@ -946,7 +946,7 @@ void plAvBrainGeneric::SetBodyUsage(plAGAnim::BodyUsage bodyUsage)
// DumpToDebugDisplay ---------------------------------------------------------------------------------------- // DumpToDebugDisplay ----------------------------------------------------------------------------------------
// ------------------- // -------------------
void plAvBrainGeneric::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt) void plAvBrainGeneric::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{ {
debugTxt.DrawString(x, y, "Brain type: Generic AKA Multistage"); debugTxt.DrawString(x, y, "Brain type: Generic AKA Multistage");
y += lineHeight; y += lineHeight;
@ -955,7 +955,7 @@ void plAvBrainGeneric::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *
for(int i = 0; i < stageCount; i++) for(int i = 0; i < stageCount; i++)
{ {
plAnimStage *stage = (*fStages)[i]; plAnimStage *stage = (*fStages)[i];
stage->DumpDebug(i == fCurStage, x, y, lineHeight, strBuf, debugTxt); stage->DumpDebug(i == fCurStage, x, y, lineHeight, debugTxt);
} }
} }

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

@ -252,7 +252,7 @@ public:
MoveMode GetMoveMode() { return fMoveMode; } MoveMode GetMoveMode() { return fMoveMode; }
/** Output the brain's status to the avatar debug screen. */ /** Output the brain's status to the avatar debug screen. */
virtual void DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt); virtual void DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt);
// plasma protocol // plasma protocol
bool MsgReceive(plMessage *msg); bool MsgReceive(plMessage *msg);

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

@ -896,28 +896,19 @@ bool plAvBrainHuman::LeaveAge()
return false; return false;
} }
void plAvBrainHuman::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt) void plAvBrainHuman::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{ {
sprintf(strBuf, "Brain type: Human"); debugTxt.DrawString(x, y, "Brain type: Human");
debugTxt.DrawString(x, y, strBuf);
y += lineHeight; y += lineHeight;
const char *grounded = fWalkingStrategy->IsOnGround() ? "yes" : "no"; const char *grounded = fWalkingStrategy->IsOnGround() ? "yes" : "no";
const char *pushing = (fWalkingStrategy->GetPushingPhysical() ? (fWalkingStrategy->GetFacingPushingPhysical() ? "facing" : "behind") : "none"); const char *pushing = (fWalkingStrategy->GetPushingPhysical() ? (fWalkingStrategy->GetFacingPushingPhysical() ? "facing" : "behind") : "none");
sprintf(strBuf, "Ground: %3s, AirTime: %5.2f (Peak: %5.2f), PushingPhys: %6s", debugTxt.DrawString(x, y, plString::Format("Ground: %3s, AirTime: %5.2f (Peak: %5.2f), PushingPhys: %6s",
grounded, fWalkingStrategy->GetAirTime(), fWalkingStrategy->GetImpactTime(), pushing); grounded, fWalkingStrategy->GetAirTime(), fWalkingStrategy->GetImpactTime(), pushing));
debugTxt.DrawString(x, y, strBuf);
y += lineHeight; y += lineHeight;
int i; for (int i = 0; i < fBehaviors.GetCount(); i++)
//strBuf[0] = '\0'; fBehaviors[i]->DumpDebug(x, y, lineHeight, debugTxt);
//for (i = 0; i < 32; i++)
// strcat(strBuf, fPreconditions & (0x1 << i) ? "1" : "0");
//debugTxt.DrawString(x, y, strBuf);
//y += lineHeight;
for (i = 0; i < fBehaviors.GetCount(); i++)
fBehaviors[i]->DumpDebug(x, y, lineHeight, strBuf, debugTxt);
debugTxt.DrawString(x, y, "Tasks:"); debugTxt.DrawString(x, y, "Tasks:");
y += lineHeight; y += lineHeight;
@ -928,7 +919,7 @@ void plAvBrainHuman::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *st
y += lineHeight; y += lineHeight;
int indentedX = x + 4; int indentedX = x + 4;
fCurTask->DumpDebug("-", indentedX, y, lineHeight, strBuf, debugTxt); fCurTask->DumpDebug("-", indentedX, y, lineHeight, debugTxt);
} }
int tasks = fTaskQueue.size(); int tasks = fTaskQueue.size();
if(tasks > 0) if(tasks > 0)
@ -941,7 +932,7 @@ void plAvBrainHuman::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *st
for (int i = 0; i < tasks; i++) for (int i = 0; i < tasks; i++)
{ {
plAvTask *each = fTaskQueue[i]; plAvTask *each = fTaskQueue[i];
each->DumpDebug("-", indentedX, y, lineHeight, strBuf, debugTxt); each->DumpDebug("-", indentedX, y, lineHeight, debugTxt);
} }
} }
} }

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

@ -97,7 +97,7 @@ public:
virtual void Write(hsStream *stream, hsResMgr *mgr); virtual void Write(hsStream *stream, hsResMgr *mgr);
virtual void Read(hsStream *stream, hsResMgr *mgr); virtual void Read(hsStream *stream, hsResMgr *mgr);
virtual bool MsgReceive(plMessage *msg); virtual bool MsgReceive(plMessage *msg);
virtual void DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt); virtual void DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt);
// Hardwired Identifiers for all the canonical bones. // Hardwired Identifiers for all the canonical bones.
enum HumanBoneID { enum HumanBoneID {

147
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainStaticNPC.cpp

@ -1,147 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//class plAvBrainStaticNPC : public plAvBrain
//{
//
//};
//
///** \class plAvBrain
// Virtual base class for the modular avatar & creature brains.
// A brain is a modular object which can be installed into a plArmatureMod
// to drive it around in the scene. Some brains are for creature ai;
// others intepret user input. The most interesting brain for reference is
// probably plAvBrainHuman, which implements the control system for the
// user's avatar.
// /sa plAvBrainHuman, plArmatureMod
//*/
//class plAvBrainStaticNPC : public plAvBrainStaticNPC
//{
//public:
// /** Default constructor - constructs the brain but does not attach it.
// Brains are always constructed before being Pushed onto the armature
// they seek to control. */
// plAvBrain();
//
// /** Destructor. Automatically called on a brain when it is popped from the armature. */
// virtual ~plAvBrain();
//
// // BRAIN PROTOCOL
// /** This brain has just been freshly pushed onto an armature and is now
// in primary control. Note that brains beneath it on the stack may
// still have effect on the armature; any messages which the top
// brain doesn't handle will propagate down to the next brain in line.
// */
// virtual bool Activate(plArmatureMod *avMod);
//
// /** Has the brain resolved all its load-time dependencies? This is a mechanism
// to allow newly loading creatures to reach a known state before they
// are asked to load secondary state or to interact with the environment.
// */
// virtual bool IsReady();
//
// /** This brain has just been removed from its armature and is about to be destructed. */
// virtual bool Deactivate();
//
// /** This is the top brain and it's time for it to evaluate. Called during eval
// time for the armature modifier. Only the topmost brain gets an apply
// call; others must do any necessary background work during MsgReceive. */
// virtual bool Apply(double timeNow, hsScalar elapsed);
//
// /** Another brain has been pushed atop this brain. Drop into the background.
// We'll still receive any messages that the upper brain doesn't eat. */
// virtual bool Suspend();
//
// /** We were suspended, but now we're on top of the brain stack again. */
// virtual bool Resume();
//
// // \name Spawning \{
// /** Do any necessary custom action upon spawning afresh in a new age.
// For the human brain, this simply consists of noting that we have
// spawned and we can stop trying to do so. */
// virtual void Spawn(double timeNow) {};
//
// /** Custom behavior for entering an age. Binding the camera, audio source, etc. */
// virtual void EnterAge(bool reSpawn) {};
//
// /** Custom behavior for leaving an age. Free any attachments to camera, audio, etc. */
// virtual void LeaveAge() {};
//
// // TASKS
// // tasks are operations that must be done in sequence.
// /** Push a new task onto the end of our FIFO task queue. Will not
// run until all the tasks ahead of it have run.
// \sa plAvTask
// */
// virtual void QueueTask(plAvTask *task);
//
//
// virtual void DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt);
//
//
// // PLASMOTICS
// CLASSNAME_REGISTER( plAvBrain );
// GETINTERFACE_ANY( plAvBrain, plCreatable );
//
// virtual void Write(hsStream *stream, hsResMgr *mgr);
// virtual void Read(hsStream *stream, hsResMgr *mgr);
//
// virtual void SaveAux(hsStream *stream, hsResMgr *mgr);
// virtual void LoadAux(hsStream *stream, hsResMgr *mgr, double time);
//
// virtual bool MsgReceive(plMessage *msg);
//
//
//protected:
// plArmatureMod *fAvMod; // the avatar we're controlling
//
// // TASKS
// // -- variables
// typedef std::deque<plAvTask *> plAvTaskQueue;
// plAvTaskQueue fTaskQueue; // FIFO queue of tasks we're working on
// plAvTask *fCurTask; // the task we're working on right now
// // -- methods
// virtual bool IHandleTaskMsg(plAvTaskMsg *msg); // respond to a task scheduling message
// void IProcessTasks(double time, hsScalar elapsed); // process current task and start new one if necessary
//
// bool fSuspended;
//};
//

22
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp

@ -594,42 +594,38 @@ bool plAvBrainSwim::IHandleControlMsg(plControlEventMsg* msg)
} }
void plAvBrainSwim::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt) void plAvBrainSwim::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt)
{ {
sprintf(strBuf, "Brain type: Swim"); debugTxt.DrawString(x, y, "Brain type: Swim", 0, 255, 255);
debugTxt.DrawString(x, y, strBuf, 0, 255, 255);
y += lineHeight; y += lineHeight;
switch(fMode) { switch(fMode) {
case kWading: case kWading:
sprintf(strBuf, "Mode: Wading"); debugTxt.DrawString(x, y, "Mode: Wading");
break; break;
case kSwimming2D: case kSwimming2D:
sprintf(strBuf, "Mode: Swimming2D"); debugTxt.DrawString(x, y, "Mode: Swimming2D");
break; break;
case kSwimming3D: case kSwimming3D:
sprintf(strBuf, "Mode: Swimming3D"); debugTxt.DrawString(x, y, "Mode: Swimming3D");
break; break;
case kAbort: case kAbort:
sprintf(strBuf, "Mode: Abort (you should never see this)"); debugTxt.DrawString(x, y, "Mode: Abort (you should never see this)");
break; break;
default: default:
break; break;
} }
debugTxt.DrawString(x, y, strBuf);
y += lineHeight; y += lineHeight;
float buoy = fSwimStrategy ? fSwimStrategy->GetBuoyancy() : 0.0f; float buoy = fSwimStrategy ? fSwimStrategy->GetBuoyancy() : 0.0f;
sprintf(strBuf, "Distance to surface: %f Buoyancy: %f", fSurfaceDistance, buoy); debugTxt.DrawString(x, y, plString::Format("Distance to surface: %f Buoyancy: %f", fSurfaceDistance, buoy));
debugTxt.DrawString(x, y, strBuf);
y += lineHeight; y += lineHeight;
hsVector3 linV = fAvMod->GetController()->GetAchievedLinearVelocity(); hsVector3 linV = fAvMod->GetController()->GetAchievedLinearVelocity();
sprintf(strBuf, "Linear Velocity: (%5.2f, %5.2f, %5.2f)", linV.fX, linV.fY, linV.fZ); debugTxt.DrawString(x, y, plString::Format("Linear Velocity: (%5.2f, %5.2f, %5.2f)", linV.fX, linV.fY, linV.fZ));
debugTxt.DrawString(x, y, strBuf);
y += lineHeight; y += lineHeight;
int i; int i;
for (i = 0; i < fBehaviors.GetCount(); i++) for (i = 0; i < fBehaviors.GetCount(); i++)
fBehaviors[i]->DumpDebug(x, y, lineHeight, strBuf, debugTxt); fBehaviors[i]->DumpDebug(x, y, lineHeight, debugTxt);
} }

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

@ -66,7 +66,7 @@ public:
virtual void Deactivate(); virtual void Deactivate();
virtual void Suspend(); virtual void Suspend();
virtual void Resume(); virtual void Resume();
virtual void DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt); virtual void DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt);
bool MsgReceive(plMessage *msg); bool MsgReceive(plMessage *msg);
bool IsWalking(); bool IsWalking();
bool IsWading(); bool IsWading();

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

@ -94,7 +94,7 @@ public:
virtual void LeaveAge(plArmatureMod *avatar) {} virtual void LeaveAge(plArmatureMod *avatar) {}
/** dump descriptive stuff to the given debug text */ /** dump descriptive stuff to the given debug text */
virtual void DumpDebug(const char *name, int &x, int&y, int lineHeight, char *strBuf, plDebugText &debugTxt); virtual void DumpDebug(const char *name, int &x, int&y, int lineHeight, plDebugText &debugTxt);
// plasma protocol // plasma protocol
CLASSNAME_REGISTER( plAvTask ); CLASSNAME_REGISTER( plAvTask );

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

@ -94,7 +94,7 @@ void plAvTaskBrain::Finish(plArmatureMod *avatar, plArmatureBrain *brain, double
// DumpDebug ------------------------------------------------------------------------------------------------------ // DumpDebug ------------------------------------------------------------------------------------------------------
// ---------- // ----------
void plAvTaskBrain::DumpDebug(const char *name, int &x, int&y, int lineHeight, char *strBuf, plDebugText &debugTxt) void plAvTaskBrain::DumpDebug(const char *name, int &x, int&y, int lineHeight, plDebugText &debugTxt)
{ {
if(fBrain) if(fBrain)
{ {

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

@ -75,7 +75,7 @@ public:
virtual void Finish(plArmatureMod *avatar, plArmatureBrain *brain, double time, float elapsed); virtual void Finish(plArmatureMod *avatar, plArmatureBrain *brain, double time, float elapsed);
/** dump descriptive stuff to the given debug text */ /** dump descriptive stuff to the given debug text */
virtual void DumpDebug(const char *name, int &x, int&y, int lineHeight, char *strBuf, plDebugText &debugTxt); virtual void DumpDebug(const char *name, int &x, int&y, int lineHeight, plDebugText &debugTxt);
plArmatureBrain *GetBrain(); plArmatureBrain *GetBrain();

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

@ -556,44 +556,41 @@ bool plAvTaskSeek::IUpdateObjective(plArmatureMod *avatar)
// DumpDebug ----------------------------------------------------------------------------------------------------- // DumpDebug -----------------------------------------------------------------------------------------------------
// ---------- // ----------
void plAvTaskSeek::DumpDebug(const char *name, int &x, int&y, int lineHeight, char *strBuf, plDebugText &debugTxt) void plAvTaskSeek::DumpDebug(const char *name, int &x, int&y, int lineHeight, plDebugText &debugTxt)
{ {
sprintf(strBuf, "duration: %.2f pos: (%.3f, %.3f, %.3f) goalPos: (%.3f, %.3f, %.3f) ", debugTxt.DrawString(x, y, plString::Format("duration: %.2f pos: (%.3f, %.3f, %.3f) goalPos: (%.3f, %.3f, %.3f) ",
hsTimer::GetSysSeconds() - fStartTime, hsTimer::GetSysSeconds() - fStartTime,
fPosition.fX, fPosition.fY, fPosition.fZ, fSeekPos.fX, fSeekPos.fY, fSeekPos.fZ); fPosition.fX, fPosition.fY, fPosition.fZ, fSeekPos.fX, fSeekPos.fY, fSeekPos.fZ));
debugTxt.DrawString(x, y, strBuf);
y += lineHeight; y += lineHeight;
sprintf(strBuf, "positioning: %d rotating %d goalVec: (%.3f, %.3f, %.3f) dist: %.3f angFwd: %.3f angRt: %.3f", debugTxt.DrawString(x, y, plString::Format("positioning: %d rotating %d goalVec: (%.3f, %.3f, %.3f) dist: %.3f angFwd: %.3f angRt: %.3f",
fStillPositioning, fStillRotating, fGoalVec.fX, fGoalVec.fY, fGoalVec.fZ, fDistance, fAngForward, fAngRight); fStillPositioning, fStillRotating, fGoalVec.fX, fGoalVec.fY, fGoalVec.fZ,
debugTxt.DrawString(x, y, strBuf); fDistance, fAngForward, fAngRight));
y += lineHeight; y += lineHeight;
sprintf(strBuf, " distFwd: %.3f distRt: %.3f shufRange: %.3f sidAngle: %.3f sidRange: %.3f, fMinWalk: %.3f", debugTxt.DrawString(x, y, plString::Format(" distFwd: %.3f distRt: %.3f shufRange: %.3f sidAngle: %.3f sidRange: %.3f, fMinWalk: %.3f",
fDistForward, fDistRight, fShuffleRange, fMaxSidleAngle, fMaxSidleRange, fMinFwdAngle); fDistForward, fDistRight, fShuffleRange, fMaxSidleAngle, fMaxSidleRange, fMinFwdAngle));
debugTxt.DrawString(x, y, strBuf);
y += lineHeight; y += lineHeight;
} }
void plAvTaskSeek::DumpToAvatarLog(plArmatureMod *avatar) void plAvTaskSeek::DumpToAvatarLog(plArmatureMod *avatar)
{ {
plStatusLog *log = plAvatarMgr::GetInstance()->GetLog(); plStatusLog *log = plAvatarMgr::GetInstance()->GetLog();
char strBuf[256]; log->AddLine(avatar->GetMoveKeyString().c_str());
avatar->GetMoveKeyString(strBuf);
log->AddLine(strBuf);
sprintf(strBuf, " duration: %.2f pos: (%.3f, %.3f, %.3f) goalPos: (%.3f, %.3f, %.3f) ", log->AddLine(plString::Format(" duration: %.2f pos: (%.3f, %.3f, %.3f) goalPos: (%.3f, %.3f, %.3f) ",
hsTimer::GetSysSeconds() - fStartTime, hsTimer::GetSysSeconds() - fStartTime,
fPosition.fX, fPosition.fY, fPosition.fZ, fSeekPos.fX, fSeekPos.fY, fSeekPos.fZ); fPosition.fX, fPosition.fY, fPosition.fZ,
log->AddLine(strBuf); fSeekPos.fX, fSeekPos.fY, fSeekPos.fZ).c_str());
sprintf(strBuf, " positioning: %d rotating %d goalVec: (%.3f, %.3f, %.3f) dist: %.3f angFwd: %.3f angRt: %.3f", log->AddLine(plString::Format(" positioning: %d rotating %d goalVec: (%.3f, %.3f, %.3f) dist: %.3f angFwd: %.3f angRt: %.3f",
fStillPositioning, fStillRotating, fGoalVec.fX, fGoalVec.fY, fGoalVec.fZ, fDistance, fAngForward, fAngRight); fStillPositioning, fStillRotating,
log->AddLine(strBuf); fGoalVec.fX, fGoalVec.fY, fGoalVec.fZ,
fDistance, fAngForward, fAngRight).c_str());
sprintf(strBuf, " distFwd: %.3f distRt: %.3f shufRange: %.3f sidAngle: %.3f sidRange: %.3f, fMinWalk: %.3f", log->AddLine(plString::Format(" distFwd: %.3f distRt: %.3f shufRange: %.3f sidAngle: %.3f sidRange: %.3f, fMinWalk: %.3f",
fDistForward, fDistRight, fShuffleRange, fMaxSidleAngle, fMaxSidleRange, fMinFwdAngle); fDistForward, fDistRight, fShuffleRange,
log->AddLine(strBuf); fMaxSidleAngle, fMaxSidleRange, fMinFwdAngle).c_str());
} }
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////

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

@ -96,7 +96,7 @@ public:
virtual void LeaveAge(plArmatureMod *avatar); virtual void LeaveAge(plArmatureMod *avatar);
/** Spew "useful" information to the game screen. Used when Avatar.Debug is active. */ /** Spew "useful" information to the game screen. Used when Avatar.Debug is active. */
virtual void DumpDebug(const char *name, int &x, int&y, int lineHeight, char *strBuf, plDebugText &debugTxt); virtual void DumpDebug(const char *name, int &x, int&y, int lineHeight, plDebugText &debugTxt);
void DumpToAvatarLog(plArmatureMod *avatar); void DumpToAvatarLog(plArmatureMod *avatar);

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

@ -80,9 +80,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plNetClientComm/plNetClientComm.h" #include "plNetClientComm/plNetClientComm.h"
plClothingItem::plClothingItem() : fName(nil), fGroup(0), fTileset(0), fType(0), fSortOrder(0), plClothingItem::plClothingItem() : fGroup(0), fTileset(0), fType(0), fSortOrder(0),
fDescription(nil), fCustomText(nil), fThumbnail(nil), fThumbnail(nil), fAccessory(nil)
fAccessory(nil), fAccessoryName(nil)
{ {
int i; int i;
fTextures.Reset(); fTextures.Reset();
@ -99,16 +98,8 @@ plClothingItem::plClothingItem() : fName(nil), fGroup(0), fTileset(0), fType(0),
plClothingItem::~plClothingItem() plClothingItem::~plClothingItem()
{ {
while (fElementNames.GetCount() > 0)
delete [] fElementNames.Pop();
while (fTextures.GetCount() > 0) while (fTextures.GetCount() > 0)
delete [] fTextures.Pop(); delete [] fTextures.Pop();
delete [] fName;
delete [] fDescription;
delete [] fCustomText;
delete [] fAccessoryName;
} }
bool plClothingItem::CanWearWith(plClothingItem *item) bool plClothingItem::CanWearWith(plClothingItem *item)
@ -169,14 +160,14 @@ void plClothingItem::Read(hsStream *s, hsResMgr *mgr)
{ {
hsKeyedObject::Read(s, mgr); hsKeyedObject::Read(s, mgr);
fName = s->ReadSafeString(); fName = s->ReadSafeString_TEMP();
fGroup = s->ReadByte(); fGroup = s->ReadByte();
fType = s->ReadByte(); fType = s->ReadByte();
fTileset = s->ReadByte(); fTileset = s->ReadByte();
fSortOrder = s->ReadByte(); fSortOrder = s->ReadByte();
fCustomText = s->ReadSafeString(); fCustomText = s->ReadSafeString_TEMP();
fDescription = s->ReadSafeString(); fDescription = s->ReadSafeString_TEMP();
if (s->ReadBool()) if (s->ReadBool())
mgr->ReadKeyNotifyMe(s, new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, -1), plRefFlags::kActiveRef); // thumbnail mgr->ReadKeyNotifyMe(s, new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, -1), plRefFlags::kActiveRef); // thumbnail
@ -184,13 +175,13 @@ void plClothingItem::Read(hsStream *s, hsResMgr *mgr)
int i, j; int i, j;
for (i = 0; i < tileCount; i++) for (i = 0; i < tileCount; i++)
{ {
fElementNames.Append(s->ReadSafeString()); fElementNames.Append(s->ReadSafeString_TEMP());
int layerCount = s->ReadByte(); int layerCount = s->ReadByte();
for (j = 0; j < layerCount; j++) for (j = 0; j < layerCount; j++)
{ {
int layer = s->ReadByte(); int layer = s->ReadByte();
mgr->ReadKeyNotifyMe(s, new plElementRefMsg(GetKey(), plRefMsg::kOnCreate, i, -1, nil, layer), plRefFlags::kActiveRef); // texture mgr->ReadKeyNotifyMe(s, new plElementRefMsg(GetKey(), plRefMsg::kOnCreate, i, -1, plString::Null, layer), plRefFlags::kActiveRef); // texture
} }
} }
@ -274,13 +265,13 @@ void plClothingItem::Write(hsStream *s, hsResMgr *mgr)
// EXPORT ONLY // EXPORT ONLY
plKey accessoryKey = nil; plKey accessoryKey = nil;
if (fAccessoryName) if (!fAccessoryName.IsEmpty())
{ {
plString strBuf = plString::Format("CItm_%s", fAccessoryName); plString strBuf = plString::Format("CItm_%s", fAccessoryName.c_str());
accessoryKey = plKeyFinder::Instance().StupidSearch("GlobalClothing", "", plClothingItem::Index(), strBuf); accessoryKey = plKeyFinder::Instance().StupidSearch("GlobalClothing", "", plClothingItem::Index(), strBuf);
if (accessoryKey == nil) if (accessoryKey == nil)
{ {
strBuf = plString::Format("Couldn't find accessory \"%s\". It won't show at runtime.", fAccessoryName); strBuf = plString::Format("Couldn't find accessory \"%s\". It won't show at runtime.", fAccessoryName.c_str());
hsMessageBox(strBuf.c_str(), GetKeyName().c_str(), hsMessageBoxNormal); hsMessageBox(strBuf.c_str(), GetKeyName().c_str(), hsMessageBoxNormal);
} }
} }
@ -306,10 +297,10 @@ bool plClothingItem::MsgReceive(plMessage* msg)
if (fTextures.GetCount() <= eMsg->fWhich) if (fTextures.GetCount() <= eMsg->fWhich)
fTextures.ExpandAndZero(eMsg->fWhich + 1); fTextures.ExpandAndZero(eMsg->fWhich + 1);
if (fElementNames.GetCount() <= eMsg->fWhich) if (fElementNames.GetCount() <= eMsg->fWhich)
fElementNames.ExpandAndZero(eMsg->fWhich + 1); fElementNames.Expand(eMsg->fWhich + 1);
if (fElementNames.Get(eMsg->fWhich) == nil) if (fElementNames.Get(eMsg->fWhich).IsEmpty())
fElementNames.Set(eMsg->fWhich, hsStrcpy(eMsg->fElementName)); fElementNames.Set(eMsg->fWhich, eMsg->fElementName);
if (fTextures.Get(eMsg->fWhich) == nil) if (fTextures.Get(eMsg->fWhich) == nil)
{ {
plMipmap **layers = new plMipmap*[plClothingElement::kLayerMax]; plMipmap **layers = new plMipmap*[plClothingElement::kLayerMax];
@ -378,22 +369,16 @@ bool plClosetItem::IsMatch(plClosetItem *other)
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
plClothingBase::plClothingBase() : fName(nil), fBaseTexture(nil), fLayoutName(nil) {} plClothingBase::plClothingBase() : fBaseTexture(nil) {}
plClothingBase::~plClothingBase()
{
delete [] fName;
delete [] fLayoutName;
}
void plClothingBase::Read(hsStream* s, hsResMgr* mgr) void plClothingBase::Read(hsStream* s, hsResMgr* mgr)
{ {
hsKeyedObject::Read(s, mgr); hsKeyedObject::Read(s, mgr);
fName = s->ReadSafeString(); fName = s->ReadSafeString_TEMP();
if (s->ReadBool()) if (s->ReadBool())
mgr->ReadKeyNotifyMe(s, new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, -1), plRefFlags::kActiveRef); mgr->ReadKeyNotifyMe(s, new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, -1), plRefFlags::kActiveRef);
fLayoutName = s->ReadSafeString(); fLayoutName = s->ReadSafeString_TEMP();
} }
void plClothingBase::Write(hsStream* s, hsResMgr* mgr) void plClothingBase::Write(hsStream* s, hsResMgr* mgr)
@ -640,7 +625,7 @@ void plClothingOutfit::IAddItem(plClothingItem *item)
if (soundEffect) if (soundEffect)
{ {
if (!strcmp(item->fName, "03_MLFoot04_01") || !strcmp(item->fName, "03_FLFoot04_01")) if (item->fName == "03_MLFoot04_01" || item->fName == "03_FLFoot04_01")
soundEffect->SetFootType(plArmatureEffectFootSound::kFootTypeBare); soundEffect->SetFootType(plArmatureEffectFootSound::kFootTypeBare);
else else
soundEffect->SetFootType(plArmatureEffectFootSound::kFootTypeShoe); soundEffect->SetFootType(plArmatureEffectFootSound::kFootTypeShoe);
@ -1438,9 +1423,8 @@ void plClothingOutfit::IInstanceSharedMeshes(plClothingItem *item)
if (fAvatar) if (fAvatar)
fAvatar->ValidateMesh(); fAvatar->ValidateMesh();
bool partialSort = item->fCustomText && strstr(item->fCustomText, "NeedsSort"); bool partialSort = (item->fCustomText.Find("NeedsSort") >= 0);
int i; for (int i = 0; i < plClothingItem::kMaxNumLODLevels; i++)
for (i = 0; i < plClothingItem::kMaxNumLODLevels; i++)
{ {
const plSceneObject *so = fAvatar->GetClothingSO(i); const plSceneObject *so = fAvatar->GetClothingSO(i);
if (so != nil && item->fMeshes[i] != nil) if (so != nil && item->fMeshes[i] != nil)
@ -1619,23 +1603,21 @@ plClothingMgr::~plClothingMgr()
delete fItems.Pop(); delete fItems.Pop();
} }
plClothingLayout *plClothingMgr::GetLayout(char *name) plClothingLayout *plClothingMgr::GetLayout(const plString &name) const
{ {
int i; for (int i = 0; i < fLayouts.GetCount(); i++)
for (i = 0; i < fLayouts.GetCount(); i++)
{ {
if (!strcmp(fLayouts.Get(i)->fName, name)) if (fLayouts.Get(i)->fName == name)
return fLayouts.Get(i); return fLayouts.Get(i);
} }
return nil; return nil;
} }
plClothingElement *plClothingMgr::FindElementByName(const char *name) plClothingElement *plClothingMgr::FindElementByName(const plString &name) const
{ {
int i; for (int i = 0; i < fElements.GetCount(); i++)
for (i = 0; i < fElements.GetCount(); i++)
{ {
if (!strcmp(fElements.Get(i)->fName, name)) if (fElements.Get(i)->fName == name)
return fElements.Get(i); return fElements.Get(i);
} }
return nil; return nil;
@ -1750,16 +1732,15 @@ void plClothingMgr::FilterUniqueMeshes(hsTArray<plClothingItem*> &items)
} }
} }
plClothingItem *plClothingMgr::FindItemByName(const char *name) plClothingItem *plClothingMgr::FindItemByName(const plString &name) const
{ {
if (!name) if (name.IsEmpty())
return nil; return nil;
int i; for (int i = 0; i < fItems.GetCount(); i++)
for (i = 0; i < fItems.GetCount(); i++)
{ {
plClothingItem* item = fItems.Get(i); plClothingItem* item = fItems.Get(i);
if (!strcmp(item->fName, name)) if (item->fName == name)
return item; return item;
} }
return nil; return nil;
@ -1902,7 +1883,7 @@ void plClothingMgr::IAddItem(plClothingItem *item)
{ {
for (j = 0; j < fElements.GetCount(); j++) for (j = 0; j < fElements.GetCount(); j++)
{ {
if (!strcmp(item->fElementNames.Get(i), fElements.Get(j)->fName)) if (item->fElementNames.Get(i) == fElements.Get(j)->fName)
{ {
item->fElements.Set(i, fElements.Get(j)); item->fElements.Set(i, fElements.Get(j));
break; break;
@ -1928,7 +1909,7 @@ void plClothingMgr::IAddItem(plClothingItem *item)
hsAssert(false, "Couldn't match all elements of added clothing item."); hsAssert(false, "Couldn't match all elements of added clothing item.");
} }
void plClothingMgr::ChangeAvatar(const char* name, const plFileName &clothingFile) void plClothingMgr::ChangeAvatar(const plString& name, const plFileName &clothingFile)
{ {
plAvatarMgr::GetInstance()->UnLoadLocalPlayer(); plAvatarMgr::GetInstance()->UnLoadLocalPlayer();
plAvatarMgr::GetInstance()->LoadPlayerFromFile(name, "", clothingFile); plAvatarMgr::GetInstance()->LoadPlayerFromFile(name, "", clothingFile);

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

@ -85,23 +85,23 @@ public:
// If you change the format of a clothing item, chances are you need // If you change the format of a clothing item, chances are you need
// to change plClothingMgr::IsLRMatch() as well // to change plClothingMgr::IsLRMatch() as well
char *fName; plString fName;
plSharedMesh *fMeshes[kMaxNumLODLevels]; plSharedMesh *fMeshes[kMaxNumLODLevels];
hsTArray<plMipmap **> fTextures; hsTArray<plMipmap **> fTextures;
hsTArray<char *> fElementNames; hsTArray<plString> fElementNames;
hsTArray<plClothingElement *> fElements; hsTArray<plClothingElement *> fElements;
uint8_t fGroup; // Each avatar can wear one of the available groups uint8_t fGroup; // Each avatar can wear one of the available groups
uint8_t fType; // Each group has multiple types of clothes (shirt/pants/etc) uint8_t fType; // Each group has multiple types of clothes (shirt/pants/etc)
uint8_t fTileset; uint8_t fTileset;
uint8_t fSortOrder; uint8_t fSortOrder;
char *fDescription; plString fDescription;
char *fCustomText; plString fCustomText;
plMipmap *fThumbnail; plMipmap *fThumbnail;
plClothingItem *fAccessory; // Forced accessory to always wear with this item. plClothingItem *fAccessory; // Forced accessory to always wear with this item.
uint8_t fDefaultTint1[3]; uint8_t fDefaultTint1[3];
uint8_t fDefaultTint2[3]; uint8_t fDefaultTint2[3];
char *fAccessoryName; // Export only plString fAccessoryName; // Export only
@ -111,8 +111,8 @@ public:
CLASSNAME_REGISTER( plClothingItem ); CLASSNAME_REGISTER( plClothingItem );
GETINTERFACE_ANY( plClothingItem, hsKeyedObject ); GETINTERFACE_ANY( plClothingItem, hsKeyedObject );
void SetName(char *name) { delete fName; fName = hsStrcpy(name); } void SetName(const plString &name) { fName = name; }
const char* GetName() { return fName; } plString GetName() const { return fName; }
bool CanWearWith(plClothingItem *item); bool CanWearWith(plClothingItem *item);
bool WearBefore(plClothingItem *item); // Should we come before the arg item? (texture gen order) bool WearBefore(plClothingItem *item); // Should we come before the arg item? (texture gen order)
bool HasBaseAlpha(); bool HasBaseAlpha();
@ -138,17 +138,16 @@ public:
class plClothingBase : public hsKeyedObject class plClothingBase : public hsKeyedObject
{ {
public: public:
char *fName; plString fName;
plMipmap *fBaseTexture; plMipmap *fBaseTexture;
char *fLayoutName; plString fLayoutName;
plClothingBase(); plClothingBase();
~plClothingBase();
CLASSNAME_REGISTER( plClothingBase ); CLASSNAME_REGISTER( plClothingBase );
GETINTERFACE_ANY( plClothingBase, hsKeyedObject ); GETINTERFACE_ANY( plClothingBase, hsKeyedObject );
void SetLayoutName(char *name) { delete fLayoutName; fLayoutName = hsStrcpy(name); } void SetLayoutName(const plString &name) { fLayoutName = name; }
virtual void Read(hsStream* s, hsResMgr* mgr); virtual void Read(hsStream* s, hsResMgr* mgr);
virtual void Write(hsStream* s, hsResMgr* mgr); virtual void Write(hsStream* s, hsResMgr* mgr);
@ -282,8 +281,8 @@ public:
CLASSNAME_REGISTER( plClothingMgr ); CLASSNAME_REGISTER( plClothingMgr );
GETINTERFACE_ANY( plClothingMgr, hsKeyedObject ); GETINTERFACE_ANY( plClothingMgr, hsKeyedObject );
plClothingLayout *GetLayout(char *name); plClothingLayout *GetLayout(const plString &name) const;
plClothingElement *FindElementByName(const char *name); plClothingElement *FindElementByName(const plString &name) const;
// Functions that just relate to the clothing you have permission to wear (closet) // Functions that just relate to the clothing you have permission to wear (closet)
@ -291,7 +290,7 @@ public:
void GetClosetItems(hsTArray<plClosetItem> &out); void GetClosetItems(hsTArray<plClosetItem> &out);
// Functions that relate to all existing clothing // Functions that relate to all existing clothing
plClothingItem *FindItemByName(const char *name); plClothingItem *FindItemByName(const plString &name) const;
hsTArray<plClothingItem*>& GetItemList() { return fItems; } hsTArray<plClothingItem*>& GetItemList() { return fItems; }
void GetItemsByGroup(uint8_t group, hsTArray<plClothingItem*> &out); void GetItemsByGroup(uint8_t group, hsTArray<plClothingItem*> &out);
void GetItemsByGroupAndType(uint8_t group, uint8_t type, hsTArray<plClothingItem*> &out); void GetItemsByGroupAndType(uint8_t group, uint8_t type, hsTArray<plClothingItem*> &out);
@ -305,7 +304,7 @@ public:
plClothingItem *GetLRMatch(plClothingItem *item); plClothingItem *GetLRMatch(plClothingItem *item);
bool IsLRMatch(plClothingItem *item1, plClothingItem *item2); bool IsLRMatch(plClothingItem *item1, plClothingItem *item2);
static void ChangeAvatar(const char* name, const plFileName &clothingFile = ""); static void ChangeAvatar(const plString& name, const plFileName &clothingFile = "");
static plClothingMgr *GetClothingMgr() { return fInstance; } static plClothingMgr *GetClothingMgr() { return fInstance; }
static void Init(); static void Init();

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

@ -519,7 +519,7 @@ bool plAvatarSDLModifier::IPutStageIn(plArmatureMod *avMod, plAnimStage *stage,
{ {
if(stage) if(stage)
{ {
dstState->FindVar(StandardStageVarNames::kStrName)->Set(stage->GetAnimName()); dstState->FindVar(StandardStageVarNames::kStrName)->Set(stage->GetAnimName().c_str());
dstState->FindVar(StandardStageVarNames::kStrNumLoops)->Set(stage->GetNumLoops()); dstState->FindVar(StandardStageVarNames::kStrNumLoops)->Set(stage->GetNumLoops());
dstState->FindVar(StandardStageVarNames::kStrForward)->Set((int)stage->GetForwardType()); dstState->FindVar(StandardStageVarNames::kStrForward)->Set((int)stage->GetForwardType());
dstState->FindVar(StandardStageVarNames::kStrBackward)->Set((int)stage->GetBackType()); dstState->FindVar(StandardStageVarNames::kStrBackward)->Set((int)stage->GetBackType());

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

@ -107,7 +107,7 @@ void plAvTask::Finish(plArmatureMod *avatar, plArmatureBrain *brain, double time
// DUMPDEBUG // DUMPDEBUG
void plAvTask::DumpDebug(const char *name, int &x, int&y, int lineHeight, char *strBuf, plDebugText &debugTxt) void plAvTask::DumpDebug(const char *name, int &x, int&y, int lineHeight, plDebugText &debugTxt)
{ {
debugTxt.DrawString(x, y, "<anonymous task>"); debugTxt.DrawString(x, y, "<anonymous task>");
y += lineHeight; y += lineHeight;

20
Sources/Plasma/PubUtilLib/plAvatar/plClothingLayout.h

@ -44,6 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include "plString.h"
// This file is intended to be an independent section so that plClothingMtl and plAvatarClothing // This file is intended to be an independent section so that plClothingMtl and plAvatarClothing
@ -71,21 +72,14 @@ public:
kLayerSkinLast = kLayerSkinBlend6, kLayerSkinLast = kLayerSkinBlend6,
}; };
char *fName; plString fName;
uint32_t fXPos; uint32_t fXPos;
uint32_t fYPos; uint32_t fYPos;
uint32_t fWidth; uint32_t fWidth;
uint32_t fHeight; uint32_t fHeight;
plClothingElement(const char *name, uint32_t xPos, uint32_t yPos, uint32_t width, uint32_t height) plClothingElement(const plString &name, uint32_t xPos, uint32_t yPos, uint32_t width, uint32_t height)
{ : fName(name), fXPos(xPos), fYPos(yPos), fWidth(width), fHeight(height) { }
fName = hsStrcpy(name);
fXPos = xPos;
fYPos = yPos;
fWidth = width;
fHeight = height;
}
~plClothingElement() { delete [] fName; }
static void GetElements(hsTArray<plClothingElement *> &out) static void GetElements(hsTArray<plClothingElement *> &out)
{ {
@ -127,10 +121,10 @@ public:
class plClothingLayout class plClothingLayout
{ {
public: public:
plClothingLayout(const char *name, uint32_t origWidth) { fName = hsStrcpy(name); fOrigWidth = origWidth; } plClothingLayout(const plString &name, uint32_t origWidth)
~plClothingLayout() { delete [] fName; } : fName(name), fOrigWidth(origWidth) { }
char *fName; plString fName;
uint32_t fOrigWidth; uint32_t fOrigWidth;
hsTArray<plClothingElement*> fElements; hsTArray<plClothingElement*> fElements;
/* /*

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

@ -145,7 +145,7 @@ bool plMultistageBehMod::MsgReceive(plMessage* msg)
plAnimStage* stage = new plAnimStage; plAnimStage* stage = new plAnimStage;
*stage = *((*fStages)[i]); *stage = *((*fStages)[i]);
stages->push_back(stage); stages->push_back(stage);
if (strstr(stage->GetAnimName(),"adder") != nil) if (stage->GetAnimName().Find("adder") >= 0)
ladder = true; ladder = true;
} }

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

@ -59,34 +59,22 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// plNPCSpawnMod ctor // plNPCSpawnMod ctor
plNPCSpawnMod::plNPCSpawnMod() plNPCSpawnMod::plNPCSpawnMod()
: fModelName(nil), : fAutoSpawn(false),
fAccountName(nil),
fAutoSpawn(false),
fNotify(nil) fNotify(nil)
{ {
} }
// plNPCSpawnMod ctor modelName accountName // plNPCSpawnMod ctor modelName accountName
plNPCSpawnMod::plNPCSpawnMod(const char * modelName, const char * accountName, bool autoSpawn) plNPCSpawnMod::plNPCSpawnMod(const plString &modelName, const plString &accountName, bool autoSpawn)
: fAutoSpawn(autoSpawn), fNotify(nil) : fAutoSpawn(autoSpawn), fNotify(nil)
{ {
fModelName = hsStrcpy(modelName); fModelName = modelName;
fAccountName = hsStrcpy(accountName); fAccountName = accountName;
} }
// plNPCSpawnMod dtor // plNPCSpawnMod dtor
plNPCSpawnMod::~plNPCSpawnMod() plNPCSpawnMod::~plNPCSpawnMod()
{ {
if(fModelName)
{
delete[] fModelName;
fModelName = nil;
}
if(fAccountName)
{
delete[] fAccountName;
fAccountName = nil;
}
if (fNotify) if (fNotify)
fNotify->UnRef(); fNotify->UnRef();
} }
@ -108,7 +96,7 @@ bool plNPCSpawnMod::Trigger()
// will netpropagate // will netpropagate
if(this->IsLocallyOwned()) if(this->IsLocallyOwned())
{ {
if(fModelName) if (!fModelName.IsEmpty())
{ {
// spawn the NPC // spawn the NPC
plKey spawnPoint = GetTarget(0)->GetKey(); plKey spawnPoint = GetTarget(0)->GetKey();
@ -140,8 +128,8 @@ void plNPCSpawnMod::Read(hsStream *stream, hsResMgr *mgr)
{ {
plSingleModifier::Read(stream, mgr); plSingleModifier::Read(stream, mgr);
fModelName = stream->ReadSafeString(); fModelName = stream->ReadSafeString_TEMP();
fAccountName = stream->ReadSafeString(); fAccountName = stream->ReadSafeString_TEMP();
fAutoSpawn = stream->ReadBool(); fAutoSpawn = stream->ReadBool();
if(stream->ReadBool()) if(stream->ReadBool())
fNotify = plNotifyMsg::ConvertNoRef(mgr->ReadCreatable(stream)); fNotify = plNotifyMsg::ConvertNoRef(mgr->ReadCreatable(stream));

6
Sources/Plasma/PubUtilLib/plAvatar/plNPCSpawnMod.h

@ -47,7 +47,7 @@ class plNPCSpawnMod : public plSingleModifier
{ {
public: public:
plNPCSpawnMod(); plNPCSpawnMod();
plNPCSpawnMod(const char * modelName, const char *accountName, bool autoSpawn); plNPCSpawnMod(const plString &modelName, const plString &accountName, bool autoSpawn);
~plNPCSpawnMod(); ~plNPCSpawnMod();
bool Trigger(); bool Trigger();
@ -68,8 +68,8 @@ protected:
void ISendNotify(plKey &avatarKey); // send our notification message void ISendNotify(plKey &avatarKey); // send our notification message
private: private:
char *fModelName; plString fModelName;
char *fAccountName; plString fAccountName;
bool fAutoSpawn; // spawn immediately on loading bool fAutoSpawn; // spawn immediately on loading
plKey fSpawnedKey; // if we want to be able to spawn many things, we should make this a vector plKey fSpawnedKey; // if we want to be able to spawn many things, we should make this a vector
plNotifyMsg *fNotify; // notify message that we send when we spawn. plNotifyMsg *fNotify; // notify message that we send when we spawn.

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

@ -61,37 +61,36 @@ plOneShotMod::plOneShotMod()
fReversable(false), fReversable(false),
fSeekDuration(1.0f), fSeekDuration(1.0f),
fSmartSeek(false), fSmartSeek(false),
fAnimName(nil),
fNoSeek(false) fNoSeek(false)
{ {
// this constructor is called from the loader. // this constructor is called from the loader.
} }
// CTOR(char *) // CTOR(char *)
plOneShotMod::plOneShotMod(const char *animName, plOneShotMod::plOneShotMod(const plString &animName,
bool drivable, bool drivable,
bool reversable, bool reversable,
float seekDuration, float seekDuration,
bool smartSeek, bool smartSeek,
bool noSeek) bool noSeek)
: fDrivable(drivable), : fAnimName(animName),
fDrivable(drivable),
fReversable(reversable), fReversable(reversable),
fSeekDuration(seekDuration), fSeekDuration(seekDuration),
fSmartSeek((float)smartSeek), fSmartSeek((float)smartSeek),
fNoSeek(noSeek) fNoSeek(noSeek)
{ {
fAnimName = hsStrcpy(animName);
} }
// INIT // INIT
void plOneShotMod::Init(const char *animName, void plOneShotMod::Init(const plString &animName,
bool drivable, bool drivable,
bool reversable, bool reversable,
float seekDuration, float seekDuration,
bool smartSeek, bool smartSeek,
bool noSeek) bool noSeek)
{ {
fAnimName = hsStrcpy(animName); fAnimName = animName;
fDrivable = drivable; fDrivable = drivable;
fReversable = reversable; fReversable = reversable;
fSeekDuration = seekDuration; fSeekDuration = seekDuration;
@ -99,15 +98,6 @@ void plOneShotMod::Init(const char *animName,
fNoSeek = noSeek; fNoSeek = noSeek;
} }
// DTOR()
plOneShotMod::~plOneShotMod()
{
if(fAnimName) {
delete[] fAnimName;
fAnimName = nil;
}
}
// MSGRECEIVE // MSGRECEIVE
bool plOneShotMod::MsgReceive(plMessage* msg) bool plOneShotMod::MsgReceive(plMessage* msg)
@ -164,7 +154,7 @@ void plOneShotMod::Read(hsStream *stream, hsResMgr *mgr)
plMultiModifier::Read(stream, mgr); plMultiModifier::Read(stream, mgr);
// read in the name of the animation itself // read in the name of the animation itself
fAnimName = stream->ReadSafeString(); fAnimName = stream->ReadSafeString_TEMP();
fSeekDuration = stream->ReadLEScalar(); fSeekDuration = stream->ReadLEScalar();
fDrivable = stream->ReadBool(); fDrivable = stream->ReadBool();
fReversable = stream->ReadBool(); fReversable = stream->ReadBool();

9
Sources/Plasma/PubUtilLib/plAvatar/plOneShotMod.h

@ -56,7 +56,7 @@ class plOneShotMod : public plMultiModifier
{ {
protected: protected:
virtual bool IEval(double secs, float del, uint32_t dirty) {return true;} virtual bool IEval(double secs, float del, uint32_t dirty) {return true;}
char * fAnimName; // the name of the animation associated with this one-shot plString fAnimName; // the name of the animation associated with this one-shot
bool fDrivable; // whether the user can control the position of the animation bool fDrivable; // whether the user can control the position of the animation
bool fReversable; // whether the user can back up the animation (fDrivable must be true as well) bool fReversable; // whether the user can back up the animation (fDrivable must be true as well)
float fSeekDuration; // how long to take to get to the seek point (??? should this be speed instead?) float fSeekDuration; // how long to take to get to the seek point (??? should this be speed instead?)
@ -64,10 +64,11 @@ protected:
bool fNoSeek; bool fNoSeek;
public: public:
plOneShotMod(); plOneShotMod();
plOneShotMod(const char *animName, bool drivable, bool reversable, float seekDuration, bool smartSeek,bool noSeek = false); plOneShotMod(const plString &animName, bool drivable, bool reversable,
virtual ~plOneShotMod(); float seekDuration, bool smartSeek, bool noSeek = false);
void Init(const char *animName, bool drivable, bool reversable, float seekDuration, bool smartSeek, bool noSeek = false); void Init(const plString &animName, bool drivable, bool reversable,
float seekDuration, bool smartSeek, bool noSeek = false);
CLASSNAME_REGISTER( plOneShotMod ); CLASSNAME_REGISTER( plOneShotMod );
GETINTERFACE_ANY( plOneShotMod, plMultiModifier ); GETINTERFACE_ANY( plOneShotMod, plMultiModifier );

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

@ -55,34 +55,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#endif #endif
//////////////
// PLAVATARMSG
//////////////
// CTOR()
plAvatarMsg::plAvatarMsg()
: plMessage()
{
}
// CTOR(sender, receiver, time)
plAvatarMsg::plAvatarMsg(const plKey &sender, const plKey &receiver)
: plMessage(sender, receiver, nil)
{
}
// READ
void plAvatarMsg::Read(hsStream *stream, hsResMgr *mgr)
{
plMessage::IMsgRead(stream, mgr);
}
// WRITE
void plAvatarMsg::Write(hsStream *stream, hsResMgr *mgr)
{
plMessage::IMsgWrite(stream, mgr);
}
////////////////////// //////////////////////
// PLARMATUREUPDATEMSG // PLARMATUREUPDATEMSG
////////////////////// //////////////////////
@ -119,23 +91,6 @@ void plArmatureUpdateMsg::Write(hsStream *stream, hsResMgr *mgr)
hsAssert(false, "This message is not supposed to travel over the network or persist in a file."); hsAssert(false, "This message is not supposed to travel over the network or persist in a file.");
} }
// ISLOCAL
bool plArmatureUpdateMsg::IsLocal() const
{
return fIsLocal;
}
// ISPLAYERCONTROLLED
bool plArmatureUpdateMsg::IsPlayerControlled() const
{
return fIsPlayerControlled;
}
bool plArmatureUpdateMsg::IsInvis() const
{
return fIsInvis;
}
///////////////////// /////////////////////
// PLAVATARSETTYPEMSG // PLAVATARSETTYPEMSG
///////////////////// /////////////////////
@ -164,18 +119,6 @@ void plAvatarSetTypeMsg::Write(hsStream *stream, hsResMgr *mgr)
stream->WriteBool(fIsPlayer); stream->WriteBool(fIsPlayer);
} }
// SETISPLAYER
void plAvatarSetTypeMsg::SetIsPlayer(bool is)
{
fIsPlayer = is;
}
// ISPLAYER
bool plAvatarSetTypeMsg::IsPlayer()
{
return fIsPlayer;
}
////////////// //////////////
@ -198,11 +141,6 @@ plAvTaskMsg::plAvTaskMsg(const plKey &sender, const plKey &receiver, plAvTask *t
{ {
} }
plAvTask *plAvTaskMsg::GetTask()
{
return fTask;
}
// READ // READ
void plAvTaskMsg::Read(hsStream *stream, hsResMgr *mgr) void plAvTaskMsg::Read(hsStream *stream, hsResMgr *mgr)
{ {
@ -562,11 +500,6 @@ plAvPushBrainMsg::plAvPushBrainMsg(const plKey& sender, const plKey &receiver, p
fBrain = brain; fBrain = brain;
} }
// dtor
plAvPushBrainMsg::~plAvPushBrainMsg()
{
}
// READ // READ
void plAvPushBrainMsg::Read(hsStream *stream, hsResMgr *mgr) void plAvPushBrainMsg::Read(hsStream *stream, hsResMgr *mgr)
{ {
@ -583,62 +516,9 @@ void plAvPushBrainMsg::Write(hsStream *stream, hsResMgr *mgr)
mgr->WriteCreatable(stream, fBrain); mgr->WriteCreatable(stream, fBrain);
} }
//////////////////
//
// PLAVPOPBRAINMSG
//
//////////////////
// default ctor
plAvPopBrainMsg::plAvPopBrainMsg()
{
}
// canonical ctor
plAvPopBrainMsg::plAvPopBrainMsg(const plKey &sender, const plKey &receiver)
: plAvTaskMsg(sender, receiver)
{
}
#endif // SERVER #endif // SERVER
/////////////////
////
//// PLAVEMOTEMSG
////
/////////////////
//
//// default ctor
//plAvEmoteMsg::plAvEmoteMsg()
//: fAnimName(nil)
//{
//}
//
//// canonical ctor
//plAvEmoteMsg::plAvEmoteMsg(plKey sender, plKey receiver, char *name)
//: plAvTaskMsg(sender, receiver)
//{
// fAnimName = hsStrcpy(name);
//}
//
//// READ
//void plAvEmoteMsg::Read(hsStream *stream, hsResMgr *mgr)
//{
// plAvTaskMsg::Read(stream, mgr);
// fAnimName = stream->ReadSafeString();
//}
//
//// WRITE
//void plAvEmoteMsg::Write(hsStream *stream, hsResMgr *mgr)
//{
// plAvTaskMsg::Write(stream, mgr);
// stream->WriteSafeString(fAnimName);
/////////////////////////// ///////////////////////////
// //
@ -651,8 +531,6 @@ plAvatarStealthModeMsg::plAvatarStealthModeMsg() : plAvatarMsg(), fMode(kStealth
SetBCastFlag(plMessage::kBCastByExactType); SetBCastFlag(plMessage::kBCastByExactType);
} }
plAvatarStealthModeMsg::~plAvatarStealthModeMsg() {}
// READ stream mgr // READ stream mgr
void plAvatarStealthModeMsg::Read(hsStream *stream, hsResMgr *mgr) void plAvatarStealthModeMsg::Read(hsStream *stream, hsResMgr *mgr)
{ {

29
Sources/Plasma/PubUtilLib/plMessage/plAvatarMsg.h

@ -64,15 +64,17 @@ class plAvatarMsg : public plMessage
{ {
public: public:
// tors // tors
plAvatarMsg(); plAvatarMsg() : plMessage() { }
plAvatarMsg(const plKey &sender, const plKey &receiver); plAvatarMsg(const plKey &sender, const plKey &receiver)
: plMessage(sender, receiver, nil) { }
// plasma protocol // plasma protocol
CLASSNAME_REGISTER( plAvatarMsg ); CLASSNAME_REGISTER( plAvatarMsg );
GETINTERFACE_ANY( plAvatarMsg, plMessage ); GETINTERFACE_ANY( plAvatarMsg, plMessage );
virtual void Read(hsStream *stream, hsResMgr *mgr); virtual void Read(hsStream *stream, hsResMgr *mgr) { plMessage::IMsgRead(stream, mgr); }
virtual void Write(hsStream *stream, hsResMgr *mgr); virtual void Write(hsStream *stream, hsResMgr *mgr) { plMessage::IMsgWrite(stream, mgr); }
}; };
@ -90,13 +92,13 @@ public:
plArmatureMod *armature); plArmatureMod *armature);
/** The avatar that sent this message is the local avatar for this client. */ /** The avatar that sent this message is the local avatar for this client. */
bool IsLocal() const; bool IsLocal() const { return fIsLocal; }
void SetIsLocal(bool on) { fIsLocal = on; } void SetIsLocal(bool on) { fIsLocal = on; }
/** The avatar that sent this message is controlled by a human being -- although /** The avatar that sent this message is controlled by a human being -- although
not necessarily a local human being. */ not necessarily a local human being. */
bool IsPlayerControlled() const; bool IsPlayerControlled() const { return fIsPlayerControlled; }
void SetIsPlayerControlled(bool on) { fIsPlayerControlled = on; } void SetIsPlayerControlled(bool on) { fIsPlayerControlled = on; }
bool IsInvis() const; bool IsInvis() const { return fIsInvis; }
void SetInvis(bool val) { fIsInvis = val; } void SetInvis(bool val) { fIsInvis = val; }
// plasma protocol // plasma protocol
@ -124,8 +126,8 @@ public:
plAvatarSetTypeMsg(const plKey &sender, const plKey &receiver); plAvatarSetTypeMsg(const plKey &sender, const plKey &receiver);
// theoretically we will someday achieve a broader taxonomy // theoretically we will someday achieve a broader taxonomy
void SetIsPlayer(bool is); void SetIsPlayer(bool is) { fIsPlayer = is; }
bool IsPlayer(); bool IsPlayer() const { return fIsPlayer; }
CLASSNAME_REGISTER(plAvatarSetTypeMsg); CLASSNAME_REGISTER(plAvatarSetTypeMsg);
GETINTERFACE_ANY(plAvatarSetTypeMsg, plAvatarMsg); GETINTERFACE_ANY(plAvatarSetTypeMsg, plAvatarMsg);
@ -151,7 +153,7 @@ public:
plAvTaskMsg(const plKey &sender, const plKey &receiver); plAvTaskMsg(const plKey &sender, const plKey &receiver);
plAvTaskMsg(const plKey &sender, const plKey &receiver, plAvTask *task); plAvTaskMsg(const plKey &sender, const plKey &receiver, plAvTask *task);
plAvTask *GetTask(); plAvTask *GetTask() const { return fTask; }
// plasma protocol // plasma protocol
CLASSNAME_REGISTER( plAvTaskMsg ); CLASSNAME_REGISTER( plAvTaskMsg );
@ -344,7 +346,6 @@ public:
// tors // tors
plAvPushBrainMsg(); plAvPushBrainMsg();
plAvPushBrainMsg(const plKey& sender, const plKey &receiver, plArmatureBrain *brain); plAvPushBrainMsg(const plKey& sender, const plKey &receiver, plArmatureBrain *brain);
~plAvPushBrainMsg();
CLASSNAME_REGISTER( plAvPushBrainMsg ); CLASSNAME_REGISTER( plAvPushBrainMsg );
GETINTERFACE_ANY( plAvPushBrainMsg, plAvTaskMsg); GETINTERFACE_ANY( plAvPushBrainMsg, plAvTaskMsg);
@ -364,8 +365,9 @@ class plAvPopBrainMsg : public plAvTaskMsg
{ {
public: public:
// tors // tors
plAvPopBrainMsg(); plAvPopBrainMsg() { }
plAvPopBrainMsg(const plKey &sender, const plKey &receiver); plAvPopBrainMsg(const plKey &sender, const plKey &receiver)
: plAvTaskMsg(sender, receiver) { }
CLASSNAME_REGISTER( plAvPopBrainMsg ); CLASSNAME_REGISTER( plAvPopBrainMsg );
GETINTERFACE_ANY( plAvPopBrainMsg, plAvTaskMsg); GETINTERFACE_ANY( plAvPopBrainMsg, plAvTaskMsg);
@ -379,7 +381,6 @@ class plAvatarStealthModeMsg : public plAvatarMsg
{ {
public: public:
plAvatarStealthModeMsg(); plAvatarStealthModeMsg();
~plAvatarStealthModeMsg();
// modes // modes
enum enum

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

@ -49,16 +49,16 @@ void plLoadAgeMsg::Read(hsStream* stream, hsResMgr* mgr)
{ {
plMessage::IMsgRead(stream, mgr); plMessage::IMsgRead(stream, mgr);
delete [] fAgeFilename;
// read agename // read agename
uint8_t len; uint8_t len;
stream->ReadLE(&len); stream->ReadLE(&len);
if (len) if (len)
{ {
fAgeFilename=new char[len+1]; plStringBuffer<char> filename;
stream->Read(len, fAgeFilename); char* buffer = filename.CreateWritableBuffer(len);
fAgeFilename[len]=0; stream->Read(len, buffer);
buffer[len] = 0;
fAgeFilename = filename;
} }
fUnload = stream->ReadBool(); fUnload = stream->ReadBool();
stream->ReadLE(&fPlayerID); stream->ReadLE(&fPlayerID);
@ -70,11 +70,11 @@ void plLoadAgeMsg::Write(hsStream* stream, hsResMgr* mgr)
plMessage::IMsgWrite(stream, mgr); plMessage::IMsgWrite(stream, mgr);
// write agename // write agename
uint8_t len = fAgeFilename ? strlen(fAgeFilename) : 0; uint8_t len = static_cast<uint8_t>(fAgeFilename.GetSize());
stream->WriteLE(len); stream->WriteLE(len);
if (len) if (len)
{ {
stream->Write(len, fAgeFilename); stream->Write(len, fAgeFilename.c_str());
} }
stream->WriteBool(fUnload); stream->WriteBool(fUnload);
stream->WriteLE(fPlayerID); stream->WriteLE(fPlayerID);
@ -99,8 +99,7 @@ void plLoadAgeMsg::ReadVersion(hsStream* s, hsResMgr* mgr)
if (contentFlags.IsBitSet(kLoadAgeAgeName)) if (contentFlags.IsBitSet(kLoadAgeAgeName))
{ {
// read agename // read agename
delete [] fAgeFilename; fAgeFilename = s->ReadSafeString_TEMP();
fAgeFilename = s->ReadSafeString();
} }
if (contentFlags.IsBitSet(kLoadAgeUnload)) if (contentFlags.IsBitSet(kLoadAgeUnload))

10
Sources/Plasma/PubUtilLib/plMessage/plLoadAgeMsg.h

@ -44,6 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnMessage/plMessage.h" #include "pnMessage/plMessage.h"
#include "pnUUID/pnUUID.h" #include "pnUUID/pnUUID.h"
#include "plString.h"
// //
@ -55,19 +56,18 @@ class hsResMgr;
class plLoadAgeMsg : public plMessage class plLoadAgeMsg : public plMessage
{ {
protected: protected:
char* fAgeFilename; // the age to load/unload plString fAgeFilename; // the age to load/unload
plUUID fAgeGuid; plUUID fAgeGuid;
bool fUnload; // true if we want to unload the age bool fUnload; // true if we want to unload the age
int fPlayerID; int fPlayerID;
public: public:
plLoadAgeMsg() : fAgeFilename(nil), fUnload(false), fPlayerID(-1){ } plLoadAgeMsg() : fUnload(false), fPlayerID(-1) { }
virtual ~plLoadAgeMsg() { delete [] fAgeFilename; }
CLASSNAME_REGISTER( plLoadAgeMsg ); CLASSNAME_REGISTER( plLoadAgeMsg );
GETINTERFACE_ANY( plLoadAgeMsg, plMessage ); GETINTERFACE_ANY( plLoadAgeMsg, plMessage );
void SetAgeFilename(const char* a) { delete [] fAgeFilename; fAgeFilename=a?hsStrcpy(a):nil; } void SetAgeFilename(const plString& a) { fAgeFilename = a; }
char* GetAgeFilename() const { return fAgeFilename; } plString GetAgeFilename() const { return fAgeFilename; }
void SetAgeGuid( const plUUID * v ) { fAgeGuid.CopyFrom( v ); } void SetAgeGuid( const plUUID * v ) { fAgeGuid.CopyFrom( v ); }
const plUUID * GetAgeGuid() const { return &fAgeGuid; } const plUUID * GetAgeGuid() const { return &fAgeGuid; }

26
Sources/Plasma/PubUtilLib/plMessage/plMovieMsg.h

@ -78,35 +78,35 @@ protected:
hsColorRGBA fColor; hsColorRGBA fColor;
hsColorRGBA fFadeInColor; hsColorRGBA fFadeInColor;
float fFadeInSecs; float fFadeInSecs;
hsColorRGBA fFadeOutColor; hsColorRGBA fFadeOutColor;
float fFadeOutSecs; float fFadeOutSecs;
float fVolume; float fVolume;
char* fFileName; plString fFileName;
uint16_t fCmd; uint16_t fCmd;
hsTArray<plMessage*> fCallbacks; hsTArray<plMessage*> fCallbacks;
public: public:
plMovieMsg(const char* n, uint16_t cmd) plMovieMsg(const plString& name, uint16_t cmd)
: plMessage(nil, nil, nil) : plMessage(nil, nil, nil)
{ {
fFileName = hsStrcpy(n); fFileName = name;
SetCmd(cmd).MakeDefault(); SetCmd(cmd).MakeDefault();
} }
plMovieMsg() : fFileName(nil), fCmd(kIgnore)
plMovieMsg() : fCmd(kIgnore)
{ {
MakeDefault(); MakeDefault();
} }
virtual ~plMovieMsg() virtual ~plMovieMsg()
{ {
delete [] fFileName; for (int i = 0; i < fCallbacks.GetCount(); i++)
int i;
for( i = 0; i < fCallbacks.GetCount(); i++ )
{ {
hsRefCnt_SafeUnRef(fCallbacks[i]); hsRefCnt_SafeUnRef(fCallbacks[i]);
} }
@ -157,8 +157,8 @@ public:
// Include the movie folder, e.g. "avi/porno.bik" // Include the movie folder, e.g. "avi/porno.bik"
// String is copied, not pointer copy. // String is copied, not pointer copy.
const char* GetFileName() const { return fFileName; } plString GetFileName() const { return fFileName; }
plMovieMsg& SetFileName(const char* n) { delete [] fFileName; fFileName = hsStrcpy(n); return *this; } plMovieMsg& SetFileName(const plString& name) { fFileName = name; return *this; }
// Color is mostly useful for alpha fade up and down. // Color is mostly useful for alpha fade up and down.
const hsColorRGBA& GetColor() const { return fColor; } const hsColorRGBA& GetColor() const { return fColor; }

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

@ -53,19 +53,13 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnMessage/plNodeRefMsg.h" #include "pnMessage/plNodeRefMsg.h"
#include "plMessage/plLoadCloneMsg.h" #include "plMessage/plLoadCloneMsg.h"
plCloneSpawnModifier::plCloneSpawnModifier() : fTemplateName(nil), fExportTime(false) plCloneSpawnModifier::plCloneSpawnModifier() : fExportTime(false)
{ {
} }
plCloneSpawnModifier::~plCloneSpawnModifier()
{
delete [] fTemplateName;
}
void plCloneSpawnModifier::Read(hsStream *s, hsResMgr *mgr) void plCloneSpawnModifier::Read(hsStream *s, hsResMgr *mgr)
{ {
delete [] fTemplateName; fTemplateName = s->ReadSafeString_TEMP();
fTemplateName = s->ReadSafeString();
plSingleModifier::Read(s, mgr); plSingleModifier::Read(s, mgr);
} }
@ -75,12 +69,6 @@ void plCloneSpawnModifier::Write(hsStream *s, hsResMgr *mgr)
plSingleModifier::Write(s, mgr); plSingleModifier::Write(s, mgr);
} }
void plCloneSpawnModifier::SetTemplateName(const char *templateName)
{
delete [] fTemplateName;
fTemplateName = hsStrcpy(templateName);
}
void plCloneSpawnModifier::SetTarget(plSceneObject* so) void plCloneSpawnModifier::SetTarget(plSceneObject* so)
{ {
fTarget = so; fTarget = so;

5
Sources/Plasma/PubUtilLib/plModifier/plCloneSpawnModifier.h

@ -47,14 +47,13 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
class plCloneSpawnModifier : public plSingleModifier class plCloneSpawnModifier : public plSingleModifier
{ {
protected: protected:
char* fTemplateName; plString fTemplateName;
bool fExportTime; bool fExportTime;
virtual bool IEval(double secs, float del, uint32_t dirty) { return true; } virtual bool IEval(double secs, float del, uint32_t dirty) { return true; }
public: public:
plCloneSpawnModifier(); plCloneSpawnModifier();
~plCloneSpawnModifier();
CLASSNAME_REGISTER(plCloneSpawnModifier); CLASSNAME_REGISTER(plCloneSpawnModifier);
GETINTERFACE_ANY(plCloneSpawnModifier, plSingleModifier); GETINTERFACE_ANY(plCloneSpawnModifier, plSingleModifier);
@ -64,7 +63,7 @@ public:
virtual void SetTarget(plSceneObject* so); virtual void SetTarget(plSceneObject* so);
void SetTemplateName(const char *templateName); void SetTemplateName(const plString &templateName) { fTemplateName = templateName; }
// Set this to true at export time so the clone mod won't try to make a // Set this to true at export time so the clone mod won't try to make a
// clone when it's attached // clone when it's attached

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

@ -300,18 +300,14 @@ bool plNetClientMgr::Log(const char* str) const
// //
// Display OS version info for log // Display OS version info for log
// //
extern std::vector<plString> DisplaySystemVersion();
void plNetClientMgr::IDumpOSVersionInfo() const void plNetClientMgr::IDumpOSVersionInfo() const
{ {
DebugMsg("*** OS Info"); DebugMsg("*** OS Info");
char** versionStrs = DisplaySystemVersion(); std::vector<plString> versionStrs = DisplaySystemVersion();
int i=0; for (auto version = versionStrs.begin(); version != versionStrs.end(); ++version)
while(versionStrs && versionStrs[i]) DebugMsg(version->c_str());
{
DebugMsg(versionStrs[i]);
delete [] versionStrs[i];
i++;
}
delete [] versionStrs;
} }
// //

10
Sources/Plasma/PubUtilLib/plPipeline/DX/plDXDeviceRef.h

@ -67,11 +67,11 @@ class plDXDeviceRef : public hsGDeviceRef
public: public:
void Unlink( void ); void Unlink();
void Link( plDXDeviceRef **back ); void Link(plDXDeviceRef **back);
plDXDeviceRef *GetNext( void ) { return fNext; } plDXDeviceRef *GetNext() const { return fNext; }
bool IsLinked( void ) { return fBack != nil; } bool IsLinked() const { return fBack != nullptr; }
virtual void Release( void ) { } virtual void Release() { }
plDXDeviceRef(); plDXDeviceRef();

16
Sources/Plasma/PubUtilLib/plPipeline/DX/plDXEnumerate.cpp

@ -66,12 +66,12 @@ HRESULT hsGDirect3DTnLEnumerate::SelectFromDevMode(const hsG3DDeviceRecord* devR
int i; int i;
for( i = 0; i < GetNumDrivers(); i++ ) for( i = 0; i < GetNumDrivers(); i++ )
{ {
if( !stricmp(GetDriver(i)->fAdapterInfo.Description, devRec->GetDriverDesc()) ) if (devRec->GetDriverDesc().CompareI(GetDriver(i)->fAdapterInfo.Description) == 0)
{ {
int j; int j;
for( j = 0; j < GetDriver(i)->fDevices.GetCount(); j++ ) for( j = 0; j < GetDriver(i)->fDevices.GetCount(); j++ )
{ {
if( !stricmp(GetDriver(i)->fDevices[j].fStrName, devRec->GetDeviceDesc()) ) if (devRec->GetDeviceDesc().CompareI(GetDriver(i)->fDevices[j].fStrName) == 0)
{ {
SetCurrentDriver(GetDriver(i)); SetCurrentDriver(GetDriver(i));
SetCurrentDevice(&GetDriver(i)->fDevices[j]); SetCurrentDevice(&GetDriver(i)->fDevices[j]);
@ -84,14 +84,12 @@ HRESULT hsGDirect3DTnLEnumerate::SelectFromDevMode(const hsG3DDeviceRecord* devR
} }
} }
} }
char errStr[256]; plString errStr = plString::Format("Can't find requested device - %s:%s:%s:%s:%s",
sprintf(errStr, "Can't find requested device - %s:%s:%s:%s:%s",
devRec->GetG3DDeviceTypeName(), devRec->GetG3DDeviceTypeName(),
devRec->GetDriverDesc(), devRec->GetDriverDesc().c_str(),
devRec->GetDriverName(), devRec->GetDriverName().c_str(),
devRec->GetDriverVersion(), devRec->GetDriverVersion().c_str(),
devRec->GetDeviceDesc()); devRec->GetDeviceDesc().c_str());
DWORD enumFlags = 0; DWORD enumFlags = 0;
int width = devMode->GetWidth(); int width = devMode->GetWidth();

4
Sources/Plasma/PubUtilLib/plPipeline/DX/plDXPixelShader.cpp

@ -121,7 +121,9 @@ HRESULT plDXPixelShader::ICreate(plDXPipeline* pipe)
if( FAILED(hr) ) if( FAILED(hr) )
{ {
return IOnError(hr, compilationErrors ? (char*)compilationErrors->GetBufferPointer() : "File not found"); return IOnError(hr, compilationErrors
? reinterpret_cast<const char *>(compilationErrors->GetBufferPointer())
: "File not found");
} }
shaderCodes = (DWORD*)(compiledShader->GetBufferPointer()); shaderCodes = (DWORD*)(compiledShader->GetBufferPointer());

12
Sources/Plasma/PubUtilLib/plPipeline/DX/plDXShader.cpp

@ -54,7 +54,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
plDXShader::plDXShader(plShader* owner) plDXShader::plDXShader(plShader* owner)
: fOwner(owner), : fOwner(owner),
fErrorString(nil),
fPipe(nil) fPipe(nil)
{ {
owner->SetDeviceRef(this); owner->SetDeviceRef(this);
@ -77,17 +76,6 @@ void plDXShader::SetOwner(plShader* owner)
} }
} }
const char* plDXShader::ISetError(const char* errStr)
{
delete [] fErrorString;
if( errStr )
fErrorString = hsStrcpy(errStr);
else
fErrorString = nil;
return fErrorString;
}
HRESULT plDXShader::IOnError(HRESULT hr, const char* errStr) HRESULT plDXShader::IOnError(HRESULT hr, const char* errStr)
{ {
ISetError(errStr); ISetError(errStr);

7
Sources/Plasma/PubUtilLib/plPipeline/DX/plDXShader.h

@ -44,6 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plDXShader_inc #define plDXShader_inc
#include "plDXDeviceRef.h" #include "plDXDeviceRef.h"
#include "plString.h"
class plShader; class plShader;
class plDXPipeline; class plDXPipeline;
@ -52,11 +53,11 @@ class plDXShader : public plDXDeviceRef
{ {
protected: protected:
plShader* fOwner; plShader* fOwner;
char* fErrorString; plString fErrorString;
plDXPipeline* fPipe; plDXPipeline* fPipe;
HRESULT IOnError(HRESULT hr, const char* errStr); HRESULT IOnError(HRESULT hr, const char* errStr);
const char* ISetError(const char* errStr); void ISetError(const char* errStr) { fErrorString = errStr; }
virtual HRESULT ICreate(plDXPipeline* pipe) = 0; virtual HRESULT ICreate(plDXPipeline* pipe) = 0;
virtual HRESULT ISetConstants(plDXPipeline* pipe) = 0; // On error, sets error string. virtual HRESULT ISetConstants(plDXPipeline* pipe) = 0; // On error, sets error string.
@ -65,7 +66,7 @@ public:
plDXShader(plShader* owner); plDXShader(plShader* owner);
virtual ~plDXShader(); virtual ~plDXShader();
const char* GetErrorString() const { return fErrorString; } plString GetErrorString() const { return fErrorString; }
void SetOwner(plShader* owner); void SetOwner(plShader* owner);
}; };

4
Sources/Plasma/PubUtilLib/plPipeline/DX/plDXVertexShader.cpp

@ -124,7 +124,9 @@ HRESULT plDXVertexShader::ICreate(plDXPipeline* pipe)
if( FAILED(hr) ) if( FAILED(hr) )
{ {
return IOnError(hr, compilationErrors ? (char*)compilationErrors->GetBufferPointer() : "File not found"); return IOnError(hr, compilationErrors
? reinterpret_cast<const char *>(compilationErrors->GetBufferPointer())
: "File not found");
} }
shaderCodes = (DWORD*)(compiledShader->GetBufferPointer()); shaderCodes = (DWORD*)(compiledShader->GetBufferPointer());

71
Sources/Plasma/PubUtilLib/plPipeline/hsG3DDeviceSelector.cpp

@ -97,7 +97,6 @@ void hsG3DDeviceMode::Clear()
hsG3DDeviceRecord::hsG3DDeviceRecord() hsG3DDeviceRecord::hsG3DDeviceRecord()
: fFlags(kNone), : fFlags(kNone),
fG3DDeviceType(hsG3DDeviceSelector::kDevTypeUnknown), fG3DDeviceType(hsG3DDeviceSelector::kDevTypeUnknown),
fG3DDriverDesc(nil), fG3DDriverName(nil), fG3DDriverVersion(nil), fG3DDeviceDesc(nil),
fLayersAtOnce(0), fMemoryBytes(0), fLayersAtOnce(0), fMemoryBytes(0),
fG3DHALorHEL(hsG3DDeviceSelector::kHHTypeUnknown), fG3DHALorHEL(hsG3DDeviceSelector::kHHTypeUnknown),
fZBiasRating( 0 ), fLODBiasRating( 0 ), fZBiasRating( 0 ), fLODBiasRating( 0 ),
@ -115,7 +114,6 @@ hsG3DDeviceRecord::~hsG3DDeviceRecord()
hsG3DDeviceRecord::hsG3DDeviceRecord(const hsG3DDeviceRecord& src) hsG3DDeviceRecord::hsG3DDeviceRecord(const hsG3DDeviceRecord& src)
: fFlags(kNone), : fFlags(kNone),
fG3DDeviceType(hsG3DDeviceSelector::kDevTypeUnknown), fG3DDeviceType(hsG3DDeviceSelector::kDevTypeUnknown),
fG3DDriverDesc(nil), fG3DDriverName(nil), fG3DDriverVersion(nil), fG3DDeviceDesc(nil),
fG3DHALorHEL(hsG3DDeviceSelector::kHHTypeUnknown), fG3DHALorHEL(hsG3DDeviceSelector::kHHTypeUnknown),
fZBiasRating( src.fZBiasRating ), fLODBiasRating( 0 ), fZBiasRating( src.fZBiasRating ), fLODBiasRating( 0 ),
fFogExpApproxStart( src.fFogExpApproxStart ), fFogExp2ApproxStart( src.fFogExp2ApproxStart ), fFogExpApproxStart( src.fFogExpApproxStart ), fFogExp2ApproxStart( src.fFogExp2ApproxStart ),
@ -162,30 +160,6 @@ hsG3DDeviceRecord& hsG3DDeviceRecord::operator=(const hsG3DDeviceRecord& src)
return *this; return *this;
} }
void hsG3DDeviceRecord::SetDriverDesc( const char *s )
{
delete [] fG3DDriverDesc;
fG3DDriverDesc = s ? hsStrcpy(s) : nil;
}
void hsG3DDeviceRecord::SetDriverName( const char *s )
{
delete [] fG3DDriverName;
fG3DDriverName = s ? hsStrcpy(s) : nil;
}
void hsG3DDeviceRecord::SetDriverVersion( const char *s )
{
delete [] fG3DDriverVersion;
fG3DDriverVersion = s ? hsStrcpy(s) : nil;
}
void hsG3DDeviceRecord::SetDeviceDesc( const char *s )
{
delete [] fG3DDeviceDesc;
fG3DDeviceDesc = s ? hsStrcpy(s) : nil;
}
const char* hsG3DDeviceRecord::GetG3DDeviceTypeName() const const char* hsG3DDeviceRecord::GetG3DDeviceTypeName() const
{ {
static const char* deviceNames[hsG3DDeviceSelector::kNumDevTypes] = { static const char* deviceNames[hsG3DDeviceSelector::kNumDevTypes] = {
@ -230,17 +204,10 @@ void hsG3DDeviceRecord::Clear()
{ {
fFlags = kNone; fFlags = kNone;
delete [] fG3DDriverDesc; fG3DDriverDesc = plString::Null;
fG3DDriverDesc = nil; fG3DDriverName = plString::Null;
fG3DDriverVersion = plString::Null;
delete [] fG3DDriverName; fG3DDeviceDesc = plString::Null;
fG3DDriverName = nil;
delete [] fG3DDriverVersion;
fG3DDriverVersion = nil;
delete [] fG3DDeviceDesc;
fG3DDeviceDesc = nil;
fCaps.Clear(); fCaps.Clear();
fLayersAtOnce = 0; fLayersAtOnce = 0;
@ -268,14 +235,6 @@ hsG3DDeviceModeRecord::hsG3DDeviceModeRecord(const hsG3DDeviceRecord& devRec, co
{ {
} }
hsG3DDeviceModeRecord::hsG3DDeviceModeRecord()
{
}
hsG3DDeviceModeRecord::~hsG3DDeviceModeRecord()
{
}
hsG3DDeviceModeRecord::hsG3DDeviceModeRecord(const hsG3DDeviceModeRecord& src) hsG3DDeviceModeRecord::hsG3DDeviceModeRecord(const hsG3DDeviceModeRecord& src)
{ {
*this = src; *this = src;
@ -291,10 +250,6 @@ hsG3DDeviceModeRecord& hsG3DDeviceModeRecord::operator=(const hsG3DDeviceModeRec
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
hsG3DDeviceSelector::hsG3DDeviceSelector()
{
}
hsG3DDeviceSelector::~hsG3DDeviceSelector() hsG3DDeviceSelector::~hsG3DDeviceSelector()
{ {
IClear(); IClear();
@ -629,7 +584,6 @@ void hsG3DDeviceSelector::IFudgeDirectXDevice( hsG3DDeviceRecord &record,
D3DEnum_DriverInfo *driverInfo, D3DEnum_DriverInfo *driverInfo,
D3DEnum_DeviceInfo *deviceInfo ) D3DEnum_DeviceInfo *deviceInfo )
{ {
char desc[ 512 ]; // Can't rely on D3D constant, since that's in another file now
uint32_t vendorID, deviceID; uint32_t vendorID, deviceID;
char *szDriver, *szDesc; char *szDriver, *szDesc;
@ -649,21 +603,18 @@ void hsG3DDeviceSelector::IFudgeDirectXDevice( hsG3DDeviceRecord &record,
} }
/// So capitalization won't matter in our tests /// So capitalization won't matter in our tests
hsAssert( strlen( szDesc ) < sizeof( desc ), "D3D device description longer than expected!" ); plString desc = plString::FromIso8859_1(szDesc).ToLower();
hsStrcpy( desc, szDesc );
hsStrLower( desc );
/// Detect ATI Radeon chipset /// Detect ATI Radeon chipset
// We will probably need to differentiate between different Radeons at some point in // We will probably need to differentiate between different Radeons at some point in
// the future, but not now. // the future, but not now.
if (stricmp(szDriver, "ati2dvag.dll") == 0 || strstr(desc, "radeon") != nullptr) ssize_t radeon = desc.Find("radeon");
if (stricmp(szDriver, "ati2dvag.dll") == 0 || radeon >= 0)
{ {
int series = 0; int series = 0;
const char* str = strstr(desc, "radeon"); if (radeon >= 0)
if( str )
str += strlen("radeon");
if( str )
{ {
const char* str = desc.c_str() + radeon + strlen("radeon");
if( 1 == sscanf(str, "%d", &series) ) if( 1 == sscanf(str, "%d", &series) )
{ {
if( (series >= 8000) && (series < 9000) ) if( (series >= 8000) && (series < 9000) )
@ -693,13 +644,13 @@ void hsG3DDeviceSelector::IFudgeDirectXDevice( hsG3DDeviceRecord &record,
/// Detect Intel i810 chipset /// Detect Intel i810 chipset
else if( deviceID == 0x00007125 && else if( deviceID == 0x00007125 &&
( stricmp( szDriver, "i81xdd.dll" ) == 0 ( stricmp( szDriver, "i81xdd.dll" ) == 0
|| ( strstr( desc, "intel" ) != nil && strstr( desc, "810" ) != nil ) ) ) || ( desc.Find("intel") >= 0 && desc.Find("810") >= 0 ) ) )
{ {
hsStatusMessage( "== Using fudge factors for an Intel i810 chipset ==\n" ); hsStatusMessage( "== Using fudge factors for an Intel i810 chipset ==\n" );
ISetFudgeFactors( kIntelI810Chipset, record ); ISetFudgeFactors( kIntelI810Chipset, record );
} }
/// Detect for a GeForc FX card. We only need to nerf the really low end one. /// Detect for a GeForc FX card. We only need to nerf the really low end one.
else if( strstr( desc, "nvidia" ) != nil && strstr( desc, "geforce fx 5200" ) != nil ) else if( desc.Find("nvidia") >= 0 && desc.Find("geforce fx 5200") >= 0 )
{ {
hsStatusMessage( "== Using fudge factors for an NVidia GeForceFX-based chipset ==\n" ); hsStatusMessage( "== Using fudge factors for an NVidia GeForceFX-based chipset ==\n" );
ISetFudgeFactors( kNVidiaGeForceFXChipset, record ); ISetFudgeFactors( kNVidiaGeForceFXChipset, record );

42
Sources/Plasma/PubUtilLib/plPipeline/hsG3DDeviceSelector.h

@ -59,6 +59,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsTemplates.h" #include "hsTemplates.h"
#include "hsBitVector.h" #include "hsBitVector.h"
#include "plString.h"
#ifdef HS_BUILD_FOR_WIN32 #ifdef HS_BUILD_FOR_WIN32
#define HS_SELECT_DIRECT3D // not supported on the Mac. #define HS_SELECT_DIRECT3D // not supported on the Mac.
@ -143,20 +144,20 @@ public:
protected: protected:
uint32_t fFlags; uint32_t fFlags;
uint32_t fG3DDeviceType; uint32_t fG3DDeviceType;
uint32_t fG3DHALorHEL; uint32_t fG3DHALorHEL;
char* fG3DDriverDesc; plString fG3DDriverDesc;
char* fG3DDriverName; plString fG3DDriverName;
char* fG3DDriverVersion; plString fG3DDriverVersion;
char* fG3DDeviceDesc; plString fG3DDeviceDesc;
hsBitVector fCaps; hsBitVector fCaps;
uint32_t fLayersAtOnce; uint32_t fLayersAtOnce;
uint32_t fMemoryBytes; uint32_t fMemoryBytes;
hsTArray<hsG3DDeviceMode> fModes; hsTArray<hsG3DDeviceMode> fModes;
@ -188,19 +189,19 @@ public:
uint32_t GetMemoryBytes() const { return fMemoryBytes; } uint32_t GetMemoryBytes() const { return fMemoryBytes; }
const char* GetDriverDesc() const { return fG3DDriverDesc; } plString GetDriverDesc() const { return fG3DDriverDesc; }
const char* GetDriverName() const { return fG3DDriverName; } plString GetDriverName() const { return fG3DDriverName; }
const char* GetDriverVersion() const { return fG3DDriverVersion; } plString GetDriverVersion() const { return fG3DDriverVersion; }
const char* GetDeviceDesc() const { return fG3DDeviceDesc; } plString GetDeviceDesc() const { return fG3DDeviceDesc; }
void SetG3DDeviceType(uint32_t t) { fG3DDeviceType = t; } void SetG3DDeviceType(uint32_t t) { fG3DDeviceType = t; }
void SetG3DHALorHEL(uint32_t h) { fG3DHALorHEL = h; } void SetG3DHALorHEL(uint32_t h) { fG3DHALorHEL = h; }
void SetMemoryBytes(uint32_t b) { fMemoryBytes = b; } void SetMemoryBytes(uint32_t b) { fMemoryBytes = b; }
void SetDriverDesc(const char* s); void SetDriverDesc(const plString& s) { fG3DDriverDesc = s; }
void SetDriverName(const char* s); void SetDriverName(const plString& s) { fG3DDriverName = s; }
void SetDriverVersion(const char* s); void SetDriverVersion(const plString& s) { fG3DDriverVersion = s; }
void SetDeviceDesc(const char* s); void SetDeviceDesc(const plString& s) { fG3DDeviceDesc = s; }
bool GetCap(uint32_t cap) const { return fCaps.IsBitSet(cap); } bool GetCap(uint32_t cap) const { return fCaps.IsBitSet(cap); }
void SetCap(uint32_t cap, bool on=true) { fCaps.SetBit(cap, on); } void SetCap(uint32_t cap, bool on=true) { fCaps.SetBit(cap, on); }
@ -252,9 +253,8 @@ protected:
hsG3DDeviceRecord fDevice; hsG3DDeviceRecord fDevice;
hsG3DDeviceMode fMode; hsG3DDeviceMode fMode;
public: public:
hsG3DDeviceModeRecord(); hsG3DDeviceModeRecord() { }
hsG3DDeviceModeRecord(const hsG3DDeviceRecord& devRec, const hsG3DDeviceMode& devMode); hsG3DDeviceModeRecord(const hsG3DDeviceRecord& devRec, const hsG3DDeviceMode& devMode);
~hsG3DDeviceModeRecord();
hsG3DDeviceModeRecord(const hsG3DDeviceModeRecord& src); hsG3DDeviceModeRecord(const hsG3DDeviceModeRecord& src);
hsG3DDeviceModeRecord& operator=(const hsG3DDeviceModeRecord& src); hsG3DDeviceModeRecord& operator=(const hsG3DDeviceModeRecord& src);
@ -343,7 +343,7 @@ protected:
void ISetFudgeFactors( uint8_t chipsetID, hsG3DDeviceRecord &record ); void ISetFudgeFactors( uint8_t chipsetID, hsG3DDeviceRecord &record );
public: public:
hsG3DDeviceSelector(); hsG3DDeviceSelector() { }
virtual ~hsG3DDeviceSelector(); virtual ~hsG3DDeviceSelector();
void RemoveUnusableDevModes(bool bTough); // Removes modes and devices not allowed supported in release void RemoveUnusableDevModes(bool bTough); // Removes modes and devices not allowed supported in release

15
Sources/Plasma/PubUtilLib/plPipeline/plBinkPlayer.h

@ -57,8 +57,7 @@ class plBinkPlayer
{ {
public: public:
plBinkPlayer() : fFileName(nil) { } plBinkPlayer() { }
~plBinkPlayer() { delete [] fFileName; }
static bool Init( hsWindowHndl hWnd) { return true; } static bool Init( hsWindowHndl hWnd) { return true; }
static bool DeInit() { return true; } static bool DeInit() { return true; }
@ -83,14 +82,12 @@ class plBinkPlayer
for (int i = 0; i < fCallbacks.GetCount(); i++) for (int i = 0; i < fCallbacks.GetCount(); i++)
fCallbacks[i]->Send(); fCallbacks[i]->Send();
fCallbacks.Reset(); fCallbacks.Reset();
delete [] fFileName; fFileName = plString::Null;
fFileName = nil;
return false; return false;
} }
void SetFileName(const char* filename) { void SetFileName(const plString& filename) {
delete [] fFileName; fFileName = filename;
fFileName = hsStrcpy(filename);
} }
void SetColor(const hsColorRGBA& c) { } void SetColor(const hsColorRGBA& c) { }
void SetPosition(float x, float y) { } void SetPosition(float x, float y) { }
@ -102,7 +99,7 @@ class plBinkPlayer
void SetPosition(const hsPoint2& p) { } void SetPosition(const hsPoint2& p) { }
void SetScale(const hsPoint2& s) { } void SetScale(const hsPoint2& s) { }
const char* GetFileName() const { return fFileName; } plString GetFileName() const { return fFileName; }
const hsColorRGBA GetColor() const { return hsColorRGBA(); } const hsColorRGBA GetColor() const { return hsColorRGBA(); }
const hsPoint2 GetPosition() const { return hsPoint2(); } const hsPoint2 GetPosition() const { return hsPoint2(); }
const hsPoint2 GetScale() const { return hsPoint2(); } const hsPoint2 GetScale() const { return hsPoint2(); }
@ -125,7 +122,7 @@ class plBinkPlayer
hsColorRGBA GetFadeToColor() const { return hsColorRGBA(); } hsColorRGBA GetFadeToColor() const { return hsColorRGBA(); }
private: private:
char* fFileName; plString fFileName;
hsTArray<plMessage*> fCallbacks; hsTArray<plMessage*> fCallbacks;
}; };

1
Sources/Tools/MaxComponent/CMakeLists.txt

@ -89,7 +89,6 @@ set(MaxComponent_HEADERS
plVolumeGadgetComponent.h plVolumeGadgetComponent.h
plWaterComponent.h plWaterComponent.h
plXImposter.h plXImposter.h
WavFileStructs.h
) )
set(MaxComponent_RESOURCES set(MaxComponent_RESOURCES

41
Sources/Tools/MaxComponent/WavFileStructs.h

@ -1,41 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/

14
Sources/Tools/MaxComponent/plMultistageBehComponent.cpp

@ -306,7 +306,7 @@ void plMultistageBehComponent::IInitDlg()
for (int i = 0; i < fStages.size(); i++) for (int i = 0; i < fStages.size(); i++)
{ {
plBaseStage* stage = fStages[i]; plBaseStage* stage = fStages[i];
ListView_AddString(hList, stage->GetName()); ListView_AddString(hList, stage->GetName().c_str());
} }
// Make sure the column is wide enough // Make sure the column is wide enough
@ -323,19 +323,17 @@ void plMultistageBehComponent::IInitDlg()
// rename them all to start with zero instead. // rename them all to start with zero instead.
void plMultistageBehComponent::FixStageNames() void plMultistageBehComponent::FixStageNames()
{ {
if(fStages.size() > 0) if (fStages.size() > 0)
{ {
plBaseStage* stage = fStages[0]; plBaseStage* stage = fStages[0];
const char * stageName = stage->GetName(); plString stageName = stage->GetName();
if(strcmp(stageName, "Stage 1") == 0) if (stageName == "Stage 1")
{ {
for (int i = 0; i < fStages.size(); i++) for (int i = 0; i < fStages.size(); i++)
{ {
plBaseStage* stage = fStages[i]; plBaseStage* stage = fStages[i];
char buf[64]; stage->SetName(plString::Format("Stage %d", i));
sprintf(buf, "Stage %d", i);
stage->SetName(buf);
} }
} }
} }
@ -362,7 +360,7 @@ BOOL plMultistageBehComponent::IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPAR
// Add the new stage to the list and make sure the list is wide enough // Add the new stage to the list and make sure the list is wide enough
HWND hList = GetDlgItem(fDlg, IDC_STAGE_LIST); HWND hList = GetDlgItem(fDlg, IDC_STAGE_LIST);
int idx = ListView_AddString(hList, stage->GetName()); int idx = ListView_AddString(hList, stage->GetName().c_str());
ListView_SetColumnWidth(hList, 0, LVSCW_AUTOSIZE); ListView_SetColumnWidth(hList, 0, LVSCW_AUTOSIZE);
ListView_SetItemState(hList, idx, LVIS_SELECTED, LVIS_SELECTED); ListView_SetItemState(hList, idx, LVIS_SELECTED, LVIS_SELECTED);

45
Sources/Tools/MaxComponent/plMultistageStage.cpp

@ -53,16 +53,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plMultistageStage.h" #include "plMultistageStage.h"
#include "plAvatar/plAnimStage.h" #include "plAvatar/plAnimStage.h"
plBaseStage::plBaseStage()
{
fName = nil;
}
plBaseStage::~plBaseStage()
{
delete [] fName;
}
BOOL plBaseStage::IStaticDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) BOOL plBaseStage::IStaticDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
if (msg == WM_INITDIALOG) if (msg == WM_INITDIALOG)
@ -96,24 +86,17 @@ void plBaseStage::IDestroyDlg(HWND hDlg)
GetCOREInterface()->DeleteRollupPage(hDlg); GetCOREInterface()->DeleteRollupPage(hDlg);
} }
const char* plBaseStage::GetName() plString plBaseStage::GetName()
{ {
if (!fName) if (fName.IsEmpty())
fName = hsStrcpy("DefaultName"); fName = "DefaultName";
return fName; return fName;
} }
void plBaseStage::SetName(const char* name)
{
delete [] fName;
fName = hsStrcpy(name);
}
void plBaseStage::Read(hsStream *stream) void plBaseStage::Read(hsStream *stream)
{ {
stream->ReadLE16(); stream->ReadLE16();
delete [] fName; fName = stream->ReadSafeString_TEMP();
fName = stream->ReadSafeString();
} }
void plBaseStage::Write(hsStream *stream) void plBaseStage::Write(hsStream *stream)
@ -124,7 +107,7 @@ void plBaseStage::Write(hsStream *stream)
void plBaseStage::IBaseClone(plBaseStage* clone) void plBaseStage::IBaseClone(plBaseStage* clone)
{ {
clone->fName = hsStrcpy(fName); clone->fName = fName;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -134,7 +117,6 @@ HWND plStandardStage::fDlg = NULL;
plStandardStage::plStandardStage() plStandardStage::plStandardStage()
{ {
fAnimName = nil;
fNumLoops = 0; fNumLoops = 0;
fLoopForever = false; fLoopForever = false;
fForward = 0; fForward = 0;
@ -149,19 +131,13 @@ plStandardStage::plStandardStage()
fRegressTo = 0; fRegressTo = 0;
} }
plStandardStage::~plStandardStage()
{
delete [] fAnimName;
}
void plStandardStage::Read(hsStream *stream) void plStandardStage::Read(hsStream *stream)
{ {
plBaseStage::Read(stream); plBaseStage::Read(stream);
uint16_t version = stream->ReadLE16(); uint16_t version = stream->ReadLE16();
delete [] fAnimName; fAnimName = stream->ReadSafeString_TEMP();
fAnimName = stream->ReadSafeString();
fNumLoops = stream->ReadLE32(); fNumLoops = stream->ReadLE32();
fLoopForever = stream->ReadBool(); fLoopForever = stream->ReadBool();
fForward = stream->ReadByte(); fForward = stream->ReadByte();
@ -329,10 +305,9 @@ void plStandardStage::IGetAnimName()
char buf[256]; char buf[256];
edit->GetText(buf, sizeof(buf)); edit->GetText(buf, sizeof(buf));
if (strcmp(buf, fAnimName) != 0) if (fAnimName != buf)
{ {
delete [] fAnimName; fAnimName = buf;
fAnimName = hsStrcpy(buf);
SetSaveRequiredFlag(); SetSaveRequiredFlag();
} }
@ -387,7 +362,7 @@ static void LoadCombo(HWND hCombo, NameType* nameInt, int size, int curVal)
void plStandardStage::IInitDlg() void plStandardStage::IInitDlg()
{ {
ICustEdit* edit = GetICustEdit(GetDlgItem(fDlg, IDC_ANIM_NAME)); ICustEdit* edit = GetICustEdit(GetDlgItem(fDlg, IDC_ANIM_NAME));
edit->SetText(fAnimName); edit->SetText(fAnimName.c_str());
HWND hForward = GetDlgItem(fDlg, IDC_FORWARD_COMBO); HWND hForward = GetDlgItem(fDlg, IDC_FORWARD_COMBO);
LoadCombo(hForward, gForward, sizeof(gForward), fForward); LoadCombo(hForward, gForward, sizeof(gForward), fForward);
@ -446,7 +421,7 @@ plAnimStage* plStandardStage::CreateStage()
plBaseStage* plStandardStage::Clone() plBaseStage* plStandardStage::Clone()
{ {
plStandardStage* clone = new plStandardStage; plStandardStage* clone = new plStandardStage;
clone->fAnimName = hsStrcpy(fAnimName); clone->fAnimName = fAnimName;
clone->fNumLoops = fNumLoops; clone->fNumLoops = fNumLoops;
clone->fLoopForever = fLoopForever; clone->fLoopForever = fLoopForever;
clone->fForward = fForward; clone->fForward = fForward;

16
Sources/Tools/MaxComponent/plMultistageStage.h

@ -40,6 +40,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "plString.h"
class plAnimStage; class plAnimStage;
class plBaseStage; class plBaseStage;
class hsStream; class hsStream;
@ -56,7 +58,7 @@ enum StageTypes
class plBaseStage class plBaseStage
{ {
protected: protected:
char* fName; plString fName;
static BOOL CALLBACK IStaticDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); static BOOL CALLBACK IStaticDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
virtual BOOL IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); virtual BOOL IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
@ -67,8 +69,8 @@ protected:
void IBaseClone(plBaseStage* clone); void IBaseClone(plBaseStage* clone);
public: public:
plBaseStage(); plBaseStage() { }
virtual ~plBaseStage(); virtual ~plBaseStage() { }
// From StageTypes // From StageTypes
virtual int GetType()=0; virtual int GetType()=0;
@ -84,8 +86,8 @@ public:
virtual plBaseStage* Clone()=0; virtual plBaseStage* Clone()=0;
const char* GetName(); plString GetName(); // NOT const (this could change fName)
void SetName(const char* name); void SetName(const plString& name) { fName = name; }
}; };
class plStandardStage : public plBaseStage class plStandardStage : public plBaseStage
@ -93,7 +95,7 @@ class plStandardStage : public plBaseStage
protected: protected:
static HWND fDlg; static HWND fDlg;
char *fAnimName; plString fAnimName;
uint32_t fNumLoops; uint32_t fNumLoops;
bool fLoopForever; bool fLoopForever;
uint8_t fForward; uint8_t fForward;
@ -114,7 +116,7 @@ protected:
public: public:
plStandardStage(); plStandardStage();
~plStandardStage(); ~plStandardStage() { }
int GetType() { return kStandard; } int GetType() { return kStandard; }

8
Sources/Tools/MaxConvert/hsMaterialConverter.cpp

@ -4527,12 +4527,12 @@ plClothingItem *hsMaterialConverter::GenerateClothingItem(plClothingMtl *mtl, co
{ {
plString clothKeyName; plString clothKeyName;
plClothingItem *cloth = new plClothingItem(); plClothingItem *cloth = new plClothingItem();
cloth->SetName(mtl->GetName()); cloth->SetName((const char *)mtl->GetName());
cloth->fSortOrder = (mtl->GetDefault() ? 0 : 1); cloth->fSortOrder = (mtl->GetDefault() ? 0 : 1);
const char *accName = mtl->GetForcedAccessoryName(); const char *accName = mtl->GetForcedAccessoryName();
if (accName && strcmp(accName, "")) if (accName && strcmp(accName, ""))
cloth->fAccessoryName = hsStrcpy(accName); cloth->fAccessoryName = accName;
Color tint1 = mtl->GetDefaultTint1(); Color tint1 = mtl->GetDefaultTint1();
Color tint2 = mtl->GetDefaultTint2(); Color tint2 = mtl->GetDefaultTint2();
@ -4543,7 +4543,7 @@ plClothingItem *hsMaterialConverter::GenerateClothingItem(plClothingMtl *mtl, co
cloth->fDefaultTint2[1] = (uint8_t)(tint2.g * 255.f); cloth->fDefaultTint2[1] = (uint8_t)(tint2.g * 255.f);
cloth->fDefaultTint2[2] = (uint8_t)(tint2.b * 255.f); cloth->fDefaultTint2[2] = (uint8_t)(tint2.b * 255.f);
clothKeyName = plString::Format("CItm_%s", cloth->fName); clothKeyName = plString::Format("CItm_%s", cloth->fName.c_str());
hsgResMgr::ResMgr()->NewKey(clothKeyName, cloth, loc); hsgResMgr::ResMgr()->NewKey(clothKeyName, cloth, loc);
plNodeRefMsg* nodeRefMsg = new plNodeRefMsg(plKeyFinder::Instance().FindSceneNodeKey(loc), plNodeRefMsg* nodeRefMsg = new plNodeRefMsg(plKeyFinder::Instance().FindSceneNodeKey(loc),
@ -4560,7 +4560,7 @@ plClothingItem *hsMaterialConverter::GenerateClothingItem(plClothingMtl *mtl, co
{ {
uint32_t clipLevels; uint32_t clipLevels;
uint32_t startWidth; uint32_t startWidth;
char *elementName = tileset->fElements.Get(i)->fName; plString elementName = tileset->fElements.Get(i)->fName;
plPlasmaMAXLayer *layer = (plPlasmaMAXLayer *)mtl->GetTexmap(i, j); plPlasmaMAXLayer *layer = (plPlasmaMAXLayer *)mtl->GetTexmap(i, j);
if (layer == nil || layer->GetPBBitmap() == nil) if (layer == nil || layer->GetPBBitmap() == nil)
continue; continue;

4
Sources/Tools/MaxPlasmaMtls/Materials/plClothingMtl.cpp

@ -565,12 +565,12 @@ Interval plClothingMtl::DisplacementValidity(TimeValue t)
return iv; return iv;
} }
plClothingElement *plClothingMtl::FindElementByName(char *name) plClothingElement *plClothingMtl::FindElementByName(const plString &name) const
{ {
int i; int i;
for (i = 0; i < fElements.GetCount(); i++) for (i = 0; i < fElements.GetCount(); i++)
{ {
if (!strcmp(fElements.Get(i)->fName, name)) if (fElements.Get(i)->fName == name)
return fElements.Get(i); return fElements.Get(i);
} }
return nil; return nil;

3
Sources/Tools/MaxPlasmaMtls/Materials/plClothingMtl.h

@ -48,6 +48,7 @@ class Bitmap;
class plClothingItem; class plClothingItem;
class plMaxNode; class plMaxNode;
class plClothingElement; class plClothingElement;
class plString;
class Texmap; class Texmap;
#define CLOTHING_MTL_CLASS_ID Class_ID(0x792c6de4, 0x1f952b65) #define CLOTHING_MTL_CLASS_ID Class_ID(0x792c6de4, 0x1f952b65)
@ -130,7 +131,7 @@ public:
hsTArray<plClothingElement *> fElements; hsTArray<plClothingElement *> fElements;
virtual void InitTilesets(); virtual void InitTilesets();
virtual void ReleaseTilesets(); virtual void ReleaseTilesets();
plClothingElement *FindElementByName(char *name); plClothingElement *FindElementByName(const plString &name) const;
int GetTilesetIndex() { return fBasicPB->GetInt(ParamID(kTileset)); } int GetTilesetIndex() { return fBasicPB->GetInt(ParamID(kTileset)); }
Texmap *GetTexmap(int index, int layer); Texmap *GetTexmap(int index, int layer);

4
Sources/Tools/MaxPlasmaMtls/Materials/plClothingMtlPBDec.h

@ -195,8 +195,8 @@ public:
{ {
plClothingElement *element = tileset->fElements.Get(i); plClothingElement *element = tileset->fElements.Get(i);
SendMessage(GetDlgItem(hWnd, plClothingMtl::TextConstants[2 * i]), SendMessage(GetDlgItem(hWnd, plClothingMtl::TextConstants[2 * i]),
WM_SETTEXT, NULL, (LPARAM)element->fName); WM_SETTEXT, NULL, (LPARAM)element->fName.c_str());
sprintf(buff, "(%d, %d)", element->fWidth, element->fHeight); snprintf(buff, arrsize(buff), "(%d, %d)", element->fWidth, element->fHeight);
SendMessage(GetDlgItem(hWnd, plClothingMtl::TextConstants[2 * i + 1]), SendMessage(GetDlgItem(hWnd, plClothingMtl::TextConstants[2 * i + 1]),
WM_SETTEXT, NULL, (LPARAM)buff); WM_SETTEXT, NULL, (LPARAM)buff);

Loading…
Cancel
Save