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. 32
      Sources/Plasma/FeatureLib/pfMessage/pfGameGUIMsg.h
  12. 15
      Sources/Plasma/FeatureLib/pfMessage/pfKIMsg.h
  13. 9
      Sources/Plasma/FeatureLib/pfMessage/plClothingMsg.h
  14. 133
      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. 10
      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. 13
      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. 18
      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. 30
      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)
{
if( !(mov->GetFileName() && *mov->GetFileName()) )
if (mov->GetFileName().IsEmpty())
return true;
int i;
@ -869,7 +869,7 @@ bool plClient::IHandleMovieMsg(plMovieMsg* mov)
{
for( i = 0; i < fMovies.GetCount(); i++ )
{
if( !stricmp(mov->GetFileName(), fMovies[i]->GetFileName()) )
if (mov->GetFileName().CompareI(fMovies[i]->GetFileName()) == 0)
break;
}
}
@ -929,7 +929,7 @@ bool plClient::IHandleMovieMsg(plMovieMsg* mov)
// 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,
// we need to clear it out of our list.
if( !(fMovies[i]->GetFileName() && *fMovies[i]->GetFileName()) )
if (fMovies[i]->GetFileName().IsEmpty())
{
delete fMovies[i];
fMovies.Remove(i);
@ -1948,7 +1948,7 @@ void plClient::IServiceMovies()
int 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() )
{
delete fMovies[i];

65
Sources/Plasma/CoreLib/HeadSpin.cpp

@ -436,15 +436,13 @@ char *hsWStringToString( const wchar_t *str )
// Microsoft SAMPLE CODE
// 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
#ifndef VER_SUITE_PERSONAL
#define VER_SUITE_PERSONAL 0x200
#endif
hsTArray<char*> versionStrs;
std::vector<plString> versionStrs;
OSVERSIONINFOEX osvi;
BOOL bOsVersionInfoEx;
@ -461,7 +459,7 @@ char** DisplaySystemVersion()
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
return FALSE;
return std::vector<plString>();
}
switch (osvi.dwPlatformId)
@ -471,22 +469,25 @@ char** DisplaySystemVersion()
// Test for the product.
if ( osvi.dwMajorVersion <= 4 )
versionStrs.Append(hsStrcpy("Microsoft Windows NT "));
versionStrs.push_back("Microsoft Windows NT ");
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 )
versionStrs.Append(hsStrcpy ("Microsoft Windows XP "));
versionStrs.push_back("Microsoft Windows XP ");
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 )
versionStrs.Append(hsStrcpy ("Microsoft Windows 7 "));
versionStrs.push_back("Microsoft Windows 7 ");
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.
@ -495,19 +496,19 @@ char** DisplaySystemVersion()
if ( osvi.wProductType == VER_NT_WORKSTATION )
{
if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
versionStrs.Append(hsStrcpy ( "Personal " ));
versionStrs.push_back("Personal ");
else
versionStrs.Append(hsStrcpy ( "Professional " ));
versionStrs.push_back("Professional ");
}
else if ( osvi.wProductType == VER_NT_SERVER )
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
versionStrs.Append(hsStrcpy ( "DataCenter Server " ));
versionStrs.push_back("DataCenter Server ");
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
versionStrs.Append(hsStrcpy ( "Advanced Server " ));
versionStrs.push_back("Advanced Server ");
else
versionStrs.Append(hsStrcpy ( "Server " ));
versionStrs.push_back("Server ");
}
}
else
@ -523,28 +524,28 @@ char** DisplaySystemVersion()
(LPBYTE) szProductType, &dwBufLen);
RegCloseKey( hKey );
if ( lstrcmpi( "WINNT", szProductType) == 0 )
versionStrs.Append(hsStrcpy( "Professional " ));
versionStrs.push_back("Professional ");
if ( lstrcmpi( "LANMANNT", szProductType) == 0 )
versionStrs.Append(hsStrcpy( "Server " ));
versionStrs.push_back("Server ");
if ( lstrcmpi( "SERVERNT", szProductType) == 0 )
versionStrs.Append(hsStrcpy( "Advanced Server " ));
versionStrs.push_back("Advanced Server ");
}
// Display version, service pack (if any), and build number.
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.dwMinorVersion,
osvi.szCSDVersion,
osvi.dwBuildNumber & 0xFFFF).c_str()));
osvi.dwBuildNumber & 0xFFFF));
}
else
{
versionStrs.Append(hsStrcpy (plString::Format("%s (Build %d)\n",
versionStrs.push_back(plString::Format("%s (Build %d)\n",
osvi.szCSDVersion,
osvi.dwBuildNumber & 0xFFFF).c_str()));
osvi.dwBuildNumber & 0xFFFF));
}
break;
@ -552,34 +553,32 @@ char** DisplaySystemVersion()
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' )
versionStrs.Append(hsStrcpy("OSR2 " ));
versionStrs.push_back("OSR2 ");
}
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
{
versionStrs.Append(hsStrcpy ("Microsoft Windows 98 "));
versionStrs.push_back("Microsoft Windows 98 ");
if ( osvi.szCSDVersion[1] == 'A' )
versionStrs.Append(hsStrcpy("SE " ));
versionStrs.push_back("SE ");
}
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
{
versionStrs.Append(hsStrcpy ("Microsoft Windows Me "));
versionStrs.push_back("Microsoft Windows Me ");
}
break;
case VER_PLATFORM_WIN32s:
versionStrs.Append(hsStrcpy ("Microsoft Win32s "));
versionStrs.push_back("Microsoft Win32s ");
break;
}
versionStrs.Append(nil); // terminator
return versionStrs.DetachArray();
return versionStrs;
#else
return nil;
return std::vector<plString>();
#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)
char** DisplaySystemVersion();
/************************ Debug/Error Macros **************************/
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 )
, fWriterSema( 1 )
, fCallback( cb )
, fName( nil )
{
fName = hsStrcpy( name );
}
hsReaderWriterLock::~hsReaderWriterLock()
{
delete [] fName;
}
void hsReaderWriterLock::LockForReading()

5
Sources/Plasma/CoreLib/hsThread.h

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

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

@ -4427,7 +4427,7 @@ PF_CONSOLE_CMD( Access,
return;
}
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(params[0]);
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((const char *)params[0]);
if( !item )
return;
@ -6557,7 +6557,7 @@ PF_CONSOLE_CMD( Clothing, // Group name
{
hsTArray<plClosetItem> items;
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.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
{
plArmatureMod *avMod = plAvatarMgr::GetInstance()->GetLocalAvatar();
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(params[0]);
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((const char *)params[0]);
if (avMod && item)
{
@ -6584,7 +6584,7 @@ PF_CONSOLE_CMD( Clothing, // Group name
"Has your avatar remove the item of clothing specified" ) // Help string
{
plArmatureMod *avMod = plAvatarMgr::GetInstance()->GetLocalAvatar();
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(params[0]);
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((const char *)params[0]);
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
{
plArmatureMod *avMod = plAvatarMgr::GetInstance()->GetLocalAvatar();
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(params[0]);
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((const char *)params[0]);
uint8_t layer;
if ((int)params[4] == 2)
layer = plClothingElement::kLayerTint2;
@ -6652,7 +6652,7 @@ PF_CONSOLE_CMD( Clothing,
"string name",
"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
@ -6846,7 +6846,7 @@ PF_CONSOLE_CMD( Python,
const char* extraParms = "";
if (numParams > 1)
extraParms = params[1];
pfBackdoorMsg *msg = new pfBackdoorMsg( params[0],extraParms );
pfBackdoorMsg *msg = new pfBackdoorMsg((const char *)params[0], extraParms);
// send it off
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",
typeName,
kiMsg->GetString() != "" ? kiMsg->GetString().c_str() : "(nil)",
kiMsg->GetUser() ? kiMsg->GetUser() : "(nil)",
kiMsg->GetString().c_str("(nil)"),
kiMsg->GetUser().c_str("(nil)"),
kiMsg->GetPlayerID(),
kiMsg->GetDelay(),
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 )
{
pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kLoadDialog );
msg->SetString( params[ 0 ] );
msg->SetString( (const char *)params[ 0 ] );
plgDispatch::MsgSend( msg );
}
}
@ -148,8 +148,8 @@ PF_CONSOLE_CMD( Game, LoadLocalDialog, "string ageName, string dlgName", "Loads
if( mgrKey )
{
pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kLoadDialog );
msg->SetString( params[ 1 ] );
msg->SetAge( params[ 0 ] );
msg->SetString( (const char *)params[ 1 ] );
msg->SetAge( (const char *)params[ 0 ] );
plgDispatch::MsgSend( msg );
}
}
@ -161,7 +161,7 @@ PF_CONSOLE_CMD( Game, ShowDialog, "string dlgName", "Shows the given GUI dialog"
if( mgrKey )
{
pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kShowDialog );
msg->SetString( params[ 0 ] );
msg->SetString( (const char *)params[ 0 ] );
plgDispatch::MsgSend( msg );
}
}
@ -173,7 +173,7 @@ PF_CONSOLE_CMD( Game, HideDialog, "string dlgName", "Hides the given GUI dialog"
if( mgrKey )
{
pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kHideDialog );
msg->SetString( params[ 0 ] );
msg->SetString( (const char *)params[ 0 ] );
plgDispatch::MsgSend( msg );
}
}
@ -187,11 +187,11 @@ PF_CONSOLE_CMD( Game, SwitchDialog, "string olddlgName, string newdlgName", "Hid
if( mgrKey )
{
pfGameGUIMsg *msg = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kHideDialog );
msg->SetString( params[ 0 ] );
msg->SetString( (const char *)params[ 0 ] );
plgDispatch::MsgSend( msg );
pfGameGUIMsg *msg2 = new pfGameGUIMsg( mgrKey, pfGameGUIMsg::kShowDialog );
msg2->SetString( params[ 1 ] );
msg2->SetString( (const char *)params[ 1 ] );
plgDispatch::MsgSend( msg2 );
}
}

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

@ -181,11 +181,11 @@ bool pfGameGUIMgr::MsgReceive( plMessage* pMsg )
if( guiMsg != nil )
{
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 )
IShowDialog( guiMsg->GetString() );
IShowDialog(guiMsg->GetString().c_str());
else if( guiMsg->GetCommand() == pfGameGUIMsg::kHideDialog )
IHideDialog( guiMsg->GetString() );
IHideDialog(guiMsg->GetString().c_str());
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
{
protected:
char *fTarget;
char *fString;
plString fTarget;
plString fString;
public:
pfBackdoorMsg() : plMessage( nil, nil, nil ),fTarget(nil),fString(nil) {}
pfBackdoorMsg( const char* target, const char* string) : plMessage( nil, nil, nil )
pfBackdoorMsg() : 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
SetBCastFlag( plMessage::kNetPropagate );
SetBCastFlag( plMessage::kBCastByExactType );
fTarget = hsStrcpy( target );
fString = hsStrcpy( string );
}
~pfBackdoorMsg()
{
delete [] fTarget;
delete [] fString;
}
CLASSNAME_REGISTER( pfBackdoorMsg );
@ -81,19 +74,19 @@ class pfBackdoorMsg : public plMessage
virtual void Read(hsStream* s, hsResMgr* mgr)
{
plMessage::IMsgRead( s, mgr );
fTarget = s->ReadSafeString();
fString = s->ReadSafeString();
fTarget = s->ReadSafeString_TEMP();
fString = s->ReadSafeString_TEMP();
}
virtual void Write(hsStream* s, hsResMgr* mgr)
{
plMessage::IMsgWrite( s, mgr );
s->WriteSafeString( fTarget );
s->WriteSafeString( fString );
s->WriteSafeString(fTarget);
s->WriteSafeString(fString);
}
const char *GetTarget( void ) { return fTarget; }
const char *GetString( void ) { return fString; }
plString GetTarget() const { return fTarget; }
plString GetString() const { return fString; }
};

32
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 "pnMessage/plMessage.h"
#define GAME_GUI_MSG_STRING_SIZE (128)
class pfGameGUIMsg : public plMessage
{
protected:
uint8_t fCommand;
char fString[ 128 ];
char *fAge;
plString fString;
plString fAge;
public:
enum
@ -68,9 +70,8 @@ class pfGameGUIMsg : public plMessage
kLoadDialog
};
pfGameGUIMsg() : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); fAge = nil; }
pfGameGUIMsg( plKey &receiver, uint8_t command ) : plMessage( nil, nil, nil ) { AddReceiver( receiver ); fCommand = command; fAge = nil; }
~pfGameGUIMsg() { delete [] fAge; }
pfGameGUIMsg() : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); }
pfGameGUIMsg(plKey &receiver, uint8_t command) : plMessage(nil, nil, nil) { AddReceiver(receiver); fCommand = command; }
CLASSNAME_REGISTER( pfGameGUIMsg );
GETINTERFACE_ANY( pfGameGUIMsg, plMessage );
@ -79,25 +80,30 @@ class pfGameGUIMsg : public plMessage
{
plMessage::IMsgRead( s, mgr );
s->ReadLE( &fCommand );
s->Read( sizeof( fString ), fString );
fAge = s->ReadSafeString();
char buffer[GAME_GUI_MSG_STRING_SIZE];
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)
{
plMessage::IMsgWrite( s, mgr );
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 );
}
uint8_t GetCommand( void ) { return fCommand; }
uint8_t GetCommand() const { return fCommand; }
void SetString( const char *str ) { hsStrncpy( fString, str, sizeof( fString ) - 1 ); }
const char *GetString( void ) { return fString; }
void SetString(const plString &str) { fString = str; }
plString GetString() const { return fString; }
void SetAge( const char *str ) { delete [] fAge; if( str == nil ) fAge = nil; else fAge = hsStrcpy( str ); }
const char *GetAge( void ) { return fAge; }
void SetAge(const plString &age) { fAge = age; }
plString GetAge() const { return fAge; }
};
#endif // _pfGameGUIMsg_h

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

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

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

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

133
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
//
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
hsTArray<plClothingItem*> clothingList = plClothingMgr::GetClothingMgr()->GetItemList();
int numItems = clothingList.GetCount();
// create the string list to send to python...
std::vector<std::string> retVal;
std::vector<plString> retVal;
for (int i = 0; i < numItems; i++)
retVal.push_back(clothingList[i]->GetName());
@ -621,16 +621,13 @@ std::vector<PyObject*> cyAvatar::GetClosetClothingList(int32_t clothing_type)
PyObject* clothingItem = PyList_New(5);
// [0] = clothing name
PyList_SetItem(clothingItem, 0, PyString_FromString(item->GetName()));
PyList_SetItem(clothingItem, 0, PyString_FromPlString(item->GetName()));
// [1] = clothing type
PyList_SetItem(clothingItem, 1, PyInt_FromLong(item->fType));
// [2] = description
const char* description = ""; // assume an empty string
if ( item->fDescription != nil )
description = item->fDescription;
PyList_SetItem(clothingItem, 2, PyString_FromString(description));
PyList_SetItem(clothingItem, 2, PyString_FromPlString(item->fDescription));
// [3] = ptImage of icon
if ( item->fThumbnail != nil )
@ -640,10 +637,7 @@ std::vector<PyObject*> cyAvatar::GetClosetClothingList(int32_t clothing_type)
PyList_SetItem(clothingItem, 3, PyInt_FromLong(0));
// [4] = fCustomText
const char* custom = ""; // assume an empty string
if ( item->fCustomText != nil )
custom = item->fCustomText;
PyList_SetItem(clothingItem, 4, PyString_FromString(custom));
PyList_SetItem(clothingItem, 4, PyString_FromPlString(item->fCustomText));
retVal.push_back(clothingItem);
}
@ -689,16 +683,13 @@ std::vector<PyObject*> cyAvatar::GetAvatarClothingList()
plClothingItem* item = clothingList[i];
// [0] = clothing name
PyList_SetItem(clothingItem, 0, PyString_FromString(item->GetName()));
PyList_SetItem(clothingItem, 0, PyString_FromPlString(item->GetName()));
// [1] = clothing type
PyList_SetItem(clothingItem, 1, PyInt_FromLong(item->fType));
// [2] = description
const char* description = ""; // assume an empty string
if ( item->fDescription != nil )
description = item->fDescription;
PyList_SetItem(clothingItem, 2, PyString_FromString(description));
PyList_SetItem(clothingItem, 2, PyString_FromPlString(item->fDescription));
// [3] = ptImage of icon
if ( item->fThumbnail != nil )
@ -708,10 +699,7 @@ std::vector<PyObject*> cyAvatar::GetAvatarClothingList()
PyList_SetItem(clothingItem, 3, PyInt_FromLong(0));
// [4] = fCustomText
const char* custom = ""; // assume an empty string
if ( item->fCustomText != nil )
custom = item->fCustomText;
PyList_SetItem(clothingItem, 4, PyString_FromString(custom));
PyList_SetItem(clothingItem, 4, PyString_FromPlString(item->fCustomText));
retVal.push_back(clothingItem);
}
@ -743,16 +731,13 @@ std::vector<PyObject*> cyAvatar::GetWardrobeClothingList()
PyObject* closetItem = PyList_New(7);
// [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
PyList_SetItem(closetItem, 1, PyInt_FromLong(closetList[i].fItem->fType));
// [2] = description
const char* description = ""; // assume an empty string
if ( closetList[i].fItem->fDescription != nil )
description = closetList[i].fItem->fDescription;
PyList_SetItem(closetItem, 2, PyString_FromString(description));
PyList_SetItem(closetItem, 2, PyString_FromPlString(closetList[i].fItem->fDescription));
// [3] = ptImage of icon
if ( closetList[i].fItem->fThumbnail != nil )
@ -762,10 +747,7 @@ std::vector<PyObject*> cyAvatar::GetWardrobeClothingList()
PyList_SetItem(closetItem, 3, PyInt_FromLong(0));
// [4] = fCustomText
const char* custom = ""; // assume an empty string
if ( closetList[i].fItem->fCustomText != nil )
custom = closetList[i].fItem->fCustomText;
PyList_SetItem(closetItem, 4, PyString_FromString(custom));
PyList_SetItem(closetItem, 4, PyString_FromPlString(closetList[i].fItem->fCustomText));
// [5] = 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)
//
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 )
{
hsTArray<plClosetItem> items;
@ -844,16 +826,13 @@ std::vector<PyObject*> cyAvatar::GetUniqueMeshList(int32_t clothing_type)
PyObject* clothingItem = PyList_New(5);
// [0] = clothing name
PyList_SetItem(clothingItem, 0, PyString_FromString(item->GetName()));
PyList_SetItem(clothingItem, 0, PyString_FromPlString(item->GetName()));
// [1] = clothing type
PyList_SetItem(clothingItem, 1, PyInt_FromLong(item->fType));
// [2] = description
const char* description = ""; // assume an empty string
if ( item->fDescription != nil )
description = item->fDescription;
PyList_SetItem(clothingItem, 2, PyString_FromString(description));
PyList_SetItem(clothingItem, 2, PyString_FromPlString(item->fDescription));
// [3] = ptImage of icon
if ( item->fThumbnail != nil )
@ -863,10 +842,7 @@ std::vector<PyObject*> cyAvatar::GetUniqueMeshList(int32_t clothing_type)
PyList_SetItem(clothingItem, 3, PyInt_FromLong(0));
// [4] = fCustomText
const char* custom = ""; // assume an empty string
if ( item->fCustomText != nil )
custom = item->fCustomText;
PyList_SetItem(clothingItem, 4, PyString_FromString(custom));
PyList_SetItem(clothingItem, 4, PyString_FromPlString(item->fCustomText));
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
// : 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;
@ -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
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();
// create the string list to send to python... as a python object
int i;
@ -915,16 +891,13 @@ std::vector<PyObject*> cyAvatar::GetAllWithSameMesh(const char* clothing_name)
plClothingItem* item = clothingList[i];
// [0] = clothing name
PyList_SetItem(clothingItem, 0, PyString_FromString(item->GetName()));
PyList_SetItem(clothingItem, 0, PyString_FromPlString(item->GetName()));
// [1] = clothing type
PyList_SetItem(clothingItem, 1, PyInt_FromLong(item->fType));
// [2] = description
const char* description = ""; // assume an empty string
if ( item->fDescription != nil )
description = item->fDescription;
PyList_SetItem(clothingItem, 2, PyString_FromString(description));
PyList_SetItem(clothingItem, 2, PyString_FromPlString(item->fDescription));
// [3] = ptImage of icon
if ( item->fThumbnail != nil )
@ -934,10 +907,7 @@ std::vector<PyObject*> cyAvatar::GetAllWithSameMesh(const char* clothing_name)
PyList_SetItem(clothingItem, 3, PyInt_FromLong(0));
// [4] = fCustomText
const char* custom = ""; // assume an empty string
if ( item->fCustomText != nil )
custom = item->fCustomText;
PyList_SetItem(clothingItem, 4, PyString_FromString(custom));
PyList_SetItem(clothingItem, 4, PyString_FromPlString(item->fCustomText));
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
// : 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
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 )
{
// create list
PyObject* clothingItem = PyList_New(5);
// [0] = clothing name
PyList_SetItem(clothingItem, 0, PyString_FromString(match->GetName()));
PyList_SetItem(clothingItem, 0, PyString_FromPlString(match->GetName()));
// [1] = clothing type
PyList_SetItem(clothingItem, 1, PyInt_FromLong(match->fType));
// [2] = description
const char* description = ""; // assume an empty string
if ( match->fDescription != nil )
description = match->fDescription;
PyList_SetItem(clothingItem, 2, PyString_FromString(description));
PyList_SetItem(clothingItem, 2, PyString_FromPlString(match->fDescription));
// [3] = ptImage of icon
if ( match->fThumbnail != nil )
@ -985,10 +952,7 @@ PyObject* cyAvatar::GetMatchingClothingItem(const char* clothing_name)
PyList_SetItem(clothingItem, 3, PyInt_FromLong(0));
// [4] = fCustomText
const char* custom = ""; // assume an empty string
if ( match->fCustomText != nil )
custom = match->fCustomText;
PyList_SetItem(clothingItem, 4, PyString_FromString(custom));
PyList_SetItem(clothingItem, 4, PyString_FromPlString(match->fCustomText));
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
// : 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);
}
@ -1018,7 +982,7 @@ bool cyAvatar::WearClothingItem(const char* clothing_name)
// PURPOSE : Wear a particular piece of clothing based on name of clothing item
// : 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);
}
@ -1030,7 +994,7 @@ bool cyAvatar::RemoveClothingItem(const char* clothing_name)
//
// 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);
}
@ -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
//
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);
}
@ -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
// : 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;
// 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)
{
avMod = (plArmatureMod*)so->GetModifierByType(plArmatureMod::Index());
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((char*)clothing_name);
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(clothing_name);
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
// : 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;
// 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());
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((char*)clothing_name);
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(clothing_name);
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
//
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;
// 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());
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((char*)clothing_name);
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(clothing_name);
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
//
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;
// 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());
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((char*)clothing_name);
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(clothing_name);
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
//
const char* cyAvatar::GetClothingItemParameterString(const char* clothing_name)
plString cyAvatar::GetClothingItemParameterString(const plString& clothing_name)
{
const plArmatureMod *avMod = nil;
// 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());
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((char*)clothing_name);
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(clothing_name);
if (avMod && item)
{
if ( item->fCustomText != nil )
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
//
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
//
PyObject* cyAvatar::GetTintClothingItemL(const char* clothing_name, uint8_t layer)
PyObject* cyAvatar::GetTintClothingItemL(const plString& clothing_name, uint8_t layer)
{
const plArmatureMod *avMod = nil;
// 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());
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName((char*)clothing_name);
plClothingItem *item = plClothingMgr::GetClothingMgr()->FindItemByName(clothing_name);
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());
// returning nil means an error occurred
return nil;
@ -1371,7 +1332,7 @@ plMorphSequence* cyAvatar::LocalMorphSequence()
//
// 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);
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
//
float cyAvatar::GetMorph(const char* clothing_name, uint8_t layer)
float cyAvatar::GetMorph(const plString& clothing_name, uint8_t layer)
{
plMorphSequence* seq = LocalMorphSequence();
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
//
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)
//
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
// : 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
//
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
// : 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
// : 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
//
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
//
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
// : 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
// : 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
//
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
//
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
//
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
//
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
//
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
//
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
//
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;
}
std::vector<std::string> clothingList = self->fThis->GetEntireClothingList(clothingType);
std::vector<plString> clothingList = self->fThis->GetEntireClothingList(clothingType);
PyObject* retVal = PyList_New(clothingList.size());
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;
}

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 ( isNamedAttr == 0 )
if ( !parameter.fString.IsNull() )
value = PyString_FromString(parameter.fString.c_str());
value = PyString_FromPlString(parameter.fString);
break;
case plPythonParameter::kSceneObject:
case plPythonParameter::kSceneObjectList:
@ -1383,7 +1383,7 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
// create event list
PyObject* event = PyList_New(4);
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));
// depending on the data type create the data
@ -1882,7 +1882,7 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
case pfKIMsg::kRateIt:
value = PyTuple_New(3);
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,2,PyLong_FromLong(pkimsg->GetIntValue()));
break;
@ -1999,7 +1999,7 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
if ( mbrIndex != -1 )
{
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
{
@ -2155,8 +2155,8 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
else
{
// 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();
if (!fromName)
plString fromName = pkimsg->GetUser();
if (fromName.IsEmpty())
fromName = "Anonymous Coward";
player = pyPlayer::New(plNetClientMgr::GetInstance()->GetLocalPlayerKey(), fromName, pkimsg->GetPlayerID(), 0.0);
}
@ -2410,7 +2410,7 @@ bool plPythonFileMod::MsgReceive(plMessage* msg)
PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_OnBackdoorMsg],
(char*)fFunctionNames[kfunc_OnBackdoorMsg],
"ss", dt->GetTarget(), dt->GetString());
"ss", dt->GetTarget().c_str(), dt->GetString().c_str());
if ( retVal == nil )
{
// 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 "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();
// make the movie
if ( fMovieName)
if (!fMovieName.IsEmpty())
{
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kMake | plMovieMsg::kAddCallbacks);
mov->SetSender(fSelfKey);
@ -75,17 +75,14 @@ pyMoviePlayer::pyMoviePlayer(const char* movieName,pyKey& selfKey)
pyMoviePlayer::~pyMoviePlayer()
{
Stop();
delete [] fMovieName;
}
void pyMoviePlayer::MakeMovie(const char* movieName, pyKey& selfKey)
void pyMoviePlayer::MakeMovie(const plString& movieName, pyKey& selfKey)
{
Stop();
if (fMovieName)
delete [] fMovieName;
fMovieName = hsStrcpy(movieName);
fMovieName = movieName;
fSelfKey = selfKey.getKey();
if (fMovieName)
if (!fMovieName.IsEmpty())
{
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kMake | plMovieMsg::kAddCallbacks);
mov->SetSender(fSelfKey);
@ -99,7 +96,7 @@ void pyMoviePlayer::MakeMovie(const char* movieName, pyKey& selfKey)
void pyMoviePlayer::SetCenter(float x, float y)
{
if ( fMovieName)
if (!fMovieName.IsEmpty())
{
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kMove);
mov->SetSender(fSelfKey);
@ -111,7 +108,7 @@ void pyMoviePlayer::SetCenter(float x, float y)
void pyMoviePlayer::SetScale(float width, float height)
{
if ( fMovieName)
if (!fMovieName.IsEmpty())
{
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kScale);
mov->SetSender(fSelfKey);
@ -123,7 +120,7 @@ void pyMoviePlayer::SetScale(float width, float height)
void pyMoviePlayer::SetColor(pyColor color)
{
if ( fMovieName)
if (!fMovieName.IsEmpty())
{
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kColor);
mov->SetSender(fSelfKey);
@ -134,7 +131,7 @@ void pyMoviePlayer::SetColor(pyColor color)
void pyMoviePlayer::SetVolume(float volume)
{
if ( fMovieName)
if (!fMovieName.IsEmpty())
{
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kVolume);
mov->SetSender(fSelfKey);
@ -145,7 +142,7 @@ void pyMoviePlayer::SetVolume(float volume)
void pyMoviePlayer::SetOpacity(float opacity)
{
if ( fMovieName)
if (!fMovieName.IsEmpty())
{
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kOpacity);
mov->SetSender(fSelfKey);
@ -157,7 +154,7 @@ void pyMoviePlayer::SetOpacity(float opacity)
void pyMoviePlayer::Play()
{
if ( fMovieName)
if (!fMovieName.IsEmpty())
{
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kStart);
mov->SetSender(fSelfKey);
@ -167,7 +164,7 @@ void pyMoviePlayer::Play()
void pyMoviePlayer::PlayPaused()
{
if ( fMovieName)
if (!fMovieName.IsEmpty())
{
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kStart | plMovieMsg::kPause);
mov->SetSender(fSelfKey);
@ -177,7 +174,7 @@ void pyMoviePlayer::PlayPaused()
void pyMoviePlayer::Pause()
{
if ( fMovieName)
if (!fMovieName.IsEmpty())
{
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kPause);
mov->SetSender(fSelfKey);
@ -187,7 +184,7 @@ void pyMoviePlayer::Pause()
void pyMoviePlayer::Resume()
{
if ( fMovieName)
if (!fMovieName.IsEmpty())
{
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kResume);
mov->SetSender(fSelfKey);
@ -197,7 +194,7 @@ void pyMoviePlayer::Resume()
void pyMoviePlayer::Stop()
{
if ( fMovieName)
if (!fMovieName.IsEmpty())
{
plMovieMsg* mov = new plMovieMsg(fMovieName, plMovieMsg::kStop);
mov->SetSender(fSelfKey);

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

@ -56,24 +56,24 @@ class pyColor;
class pyMoviePlayer
{
protected:
char* fMovieName;
plString fMovieName;
plKey fSelfKey;
pyMoviePlayer(): fMovieName(nil), fSelfKey(nil) {} // only used by python glue, do NOT call
pyMoviePlayer(const char* movieName,pyKey& selfKey);
pyMoviePlayer(): fSelfKey(nil) {} // only used by python glue, do NOT call
pyMoviePlayer(const plString& movieName, pyKey& selfKey);
public:
~pyMoviePlayer();
// required functions for PyObject interoperability
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_CONVERT_FROM_DEFINITION(pyMoviePlayer); // converts a PyObject to a pyMoviePlayer (throws error if not correct type)
static void AddPlasmaClasses(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
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");
// 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);
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
{
fAvatarKey = nil;
fPlayerName = "";
fPlayerName = plString::Null;
fPlayerID = 0;
fDistSq = -1;
fIsCCR = 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();
fPlayerName = pname;
@ -65,7 +65,7 @@ pyPlayer::pyPlayer(pyKey& avKey, const char* pname, uint32_t pid, float distsq)
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;
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
pyPlayer::pyPlayer(const char* pname, uint32_t pid)
pyPlayer::pyPlayer(const plString& pname, uint32_t pid)
{
fAvatarKey = nil;
fPlayerName = pname;
@ -86,7 +86,7 @@ pyPlayer::pyPlayer(const char* pname, uint32_t pid)
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;
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 "pnKeyedObject/plKey.h"
#include <string>
#include "plString.h"
class pyPlayer
{
protected:
plKey fAvatarKey;
std::string fPlayerName;
plString fPlayerName;
uint32_t fPlayerID;
float fDistSq; // from local player, temp
bool fIsCCR;
bool fIsServer;
pyPlayer(); // only used by python glue, do NOT call
pyPlayer(pyKey& avKey, const char* pname, uint32_t pid, float distsq);
pyPlayer(plKey avKey, const char* pname, uint32_t pid, float distsq);
pyPlayer(pyKey& avKey, const plString& 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
pyPlayer(const char* pname, uint32_t pid);
pyPlayer(const plString& pname, uint32_t pid);
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
PYTHON_CLASS_NEW_FRIEND(ptPlayer);
static PyObject *New(pyKey& avKey, const char* pname, uint32_t pid, float distsq);
static PyObject *New(plKey avKey, const char* pname, uint32_t pid, float distsq);
static PyObject *New(const char* pname, uint32_t pid);
static PyObject *New(pyKey& avKey, const plString& pname, uint32_t pid, float distsq);
static PyObject *New(plKey avKey, const plString& pname, uint32_t pid, float distsq);
static PyObject *New(const plString& pname, uint32_t pid);
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)
@ -96,7 +96,7 @@ public:
plKey GetKey() const { return fAvatarKey; }
// for python access
const char * GetPlayerName() const { return fPlayerName.c_str();}
plString GetPlayerName() const { return fPlayerName; }
uint32_t GetPlayerID() const { return fPlayerID; }
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)
{
return PyString_FromString(self->fThis->GetPlayerName());
return PyString_FromPlString(self->fThis->GetPlayerName());
}
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)");
// 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);
newObj->fThis->Init(avKey.getKey(), pname, pid, distsq);
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);
newObj->fThis->Init(avKey, pname, pid, distsq);
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);
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
//
void plNotifyMsg::AddVariableEvent( const char* name, float number )
void plNotifyMsg::AddVariableEvent(const plString& name, float number)
{
// create the control key event record
proVariableEventData* pED = new proVariableEventData;
pED->fName = hsStrcpy(nil,name);
pED->fName = name;
pED->fDataType = proEventData::kFloat;
pED->fNumber.f = number;
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
//
void plNotifyMsg::AddVariableEvent( const char* name, int32_t number )
void plNotifyMsg::AddVariableEvent(const plString& name, int32_t number)
{
// create the control key event record
proVariableEventData* pED = new proVariableEventData;
pED->fName = hsStrcpy(nil,name);
pED->fName = name;
pED->fDataType = proEventData::kInt;
pED->fNumber.i = number;
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
//
void plNotifyMsg::AddVariableEvent( const char* name)
void plNotifyMsg::AddVariableEvent(const plString& name)
{
// create the control key event record
proVariableEventData* pED = new proVariableEventData;
pED->fName = hsStrcpy(nil,name);
pED->fName = name;
pED->fDataType = proEventData::kNull;
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
//
void plNotifyMsg::AddVariableEvent( const char* name, const plKey &key )
void plNotifyMsg::AddVariableEvent(const plString& name, const plKey &key)
{
// create the control key event record
proVariableEventData* pED = new proVariableEventData;
pED->fName = hsStrcpy(nil,name);
// pED->fName = (char*)name;
pED->fName = name;
pED->fDataType = proEventData::kKey;
pED->fKey = key;
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()
{
fName = nil;
fName = plString::Null;
}
void proVariableEventData::IDestruct()
{
if ( fName != nil )
delete [] fName;
fName = nil;
fName = plString::Null;
}
void proVariableEventData::IReadNumber(hsStream * stream) {
@ -1353,7 +1351,7 @@ void proVariableEventData::IWriteNumber(hsStream * stream) {
void proVariableEventData::IRead(hsStream* stream, hsResMgr* mgr)
{
fName = stream->ReadSafeString();
fName = stream->ReadSafeString_TEMP();
fDataType = stream->ReadLE32();
IReadNumber(stream);
fKey = mgr->ReadKey(stream);
@ -1381,7 +1379,7 @@ void proVariableEventData::IReadVersion(hsStream* s, hsResMgr* mgr)
contentFlags.Read(s);
if (contentFlags.IsBitSet(kProVariableName))
fName = s->ReadSafeString();
fName = s->ReadSafeString_TEMP();
if (contentFlags.IsBitSet(kProVariableDataType))
fDataType = s->ReadLE32();
if (contentFlags.IsBitSet(kProVariableNumber))

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

@ -179,7 +179,7 @@ protected:
};
proEventType(Variable)
char* fName; // name of variable
plString fName; // name of variable
int32_t fDataType; // type of data
// 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 AddPickEvent( const plKey &other, const plKey& self, bool enabled, hsPoint3 hitPoint );
void AddControlKeyEvent( int32_t key, bool down );
void AddVariableEvent( const char* name, float number );
void AddVariableEvent( const char* name, int32_t number );
void AddVariableEvent( const char* name );
void AddVariableEvent( const char *name, const plKey &key );
void AddVariableEvent( const plString& name, float number );
void AddVariableEvent( const plString& name, int32_t number );
void AddVariableEvent( const plString& name );
void AddVariableEvent( const plString& name, const plKey &key );
void AddFacingEvent( const plKey &other, const plKey &self, float dot, bool enabled);
void AddContainerEvent( const plKey &container, const plKey &contained, bool entering);
void AddActivateEvent( bool activate );

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

@ -77,8 +77,7 @@ class plAGAnim;
// PLANIMSTAGE default ctor
plAnimStage::plAnimStage()
: fAnimName(nil),
fNotify(0),
: fNotify(0),
fArmature(nil),
fBrain(nil),
fForwardType(kForwardNone),
@ -102,8 +101,9 @@ plAnimStage::plAnimStage()
{
}
plAnimStage::plAnimStage(const char *animName, uint8_t notify)
: fNotify(notify),
plAnimStage::plAnimStage(const plString &animName, uint8_t notify)
: fAnimName(animName),
fNotify(notify),
fArmature(nil),
fBrain(nil),
fForwardType(kForwardAuto), // different from default
@ -125,19 +125,19 @@ plAnimStage::plAnimStage(const char *animName, uint8_t notify)
fReverseOnIdle(false),
fDone(false)
{
fAnimName = hsStrcpy(animName);
}
// PLANIMSTAGE canonical ctor
plAnimStage::plAnimStage(const char *animName,
plAnimStage::plAnimStage(const plString &animName,
uint8_t notify,
ForwardType forward,
BackType back,
AdvanceType advance,
RegressType regress,
int loops)
: fArmature(nil),
: fAnimName(animName),
fArmature(nil),
fBrain(nil),
fNotify(notify),
fForwardType(forward),
@ -159,10 +159,9 @@ plAnimStage::plAnimStage(const char *animName,
fReverseOnIdle(false),
fDone(false)
{
fAnimName = hsStrcpy(animName);
}
plAnimStage::plAnimStage(const char *animName,
plAnimStage::plAnimStage(const plString &animName,
uint8_t notify,
ForwardType forward,
BackType back,
@ -173,7 +172,8 @@ plAnimStage::plAnimStage(const char *animName,
int advanceTo,
bool doRegressTo,
int regressTo)
: fArmature(nil),
: fAnimName(animName),
fArmature(nil),
fBrain(nil),
fNotify(notify),
fForwardType(forward),
@ -195,15 +195,11 @@ plAnimStage::plAnimStage(const char *animName,
fReverseOnIdle(false),
fDone(false)
{
fAnimName = hsStrcpy(animName);
}
// PLANIMSTAGE dtor
plAnimStage::~plAnimStage()
{
if(fAnimName)
delete[] fAnimName;
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...
// *** check back in a while....
@ -213,7 +209,7 @@ plAnimStage::~plAnimStage()
// ----------
const plAnimStage& plAnimStage::operator=(const plAnimStage& src)
{
fAnimName = hsStrcpy(src.fAnimName);
fAnimName = src.fAnimName;
fNotify = src.fNotify;
fForwardType = src.fForwardType;
fBackType = src.fBackType;
@ -260,12 +256,12 @@ plAGAnimInstance * plAnimStage::Attach(plArmatureMod *armature, plArmatureBrain
fAnimInstance->SetCurrentTime(fLocalTime);
#ifdef DEBUG_MULTISTAGE
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);
#endif
} else {
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);
#ifdef DEBUG_MULTISTAGE
plAvatarMgr::GetInstance()->GetLog()->AddLine(buf);
@ -332,10 +328,10 @@ bool plAnimStage::Detach(plArmatureMod *armature)
#ifdef DEBUG_MULTISTAGE
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);
#endif
// hsStatusMessageF("Detaching plAnimStage <%s>", fAnimName);
// hsStatusMessageF("Detaching plAnimStage <%s>", fAnimName.c_str());
if(fArmature) {
fArmature = nil;
@ -346,9 +342,7 @@ bool plAnimStage::Detach(plArmatureMod *armature)
}
#ifdef DEBUG_MULTISTAGE
} else {
char sbuf[256];
sprintf(sbuf,"AnimStage::Detach: stage already detached");
plAvatarMgr::GetInstance()->GetLog()->AddLine(sbuf);
plAvatarMgr::GetInstance()->GetLog()->AddLine("AnimStage::Detach: stage already detached");
#endif
// hsStatusMessageF("Detach: stage already detached.");
}
@ -535,7 +529,7 @@ bool plAnimStage::ITryAdvance(plArmatureMod *avMod)
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) {
stageDone = true;
}
@ -562,7 +556,7 @@ bool plAnimStage::ITryRegress(plArmatureMod *avMod)
// we may want to rename this to "ReachedStageEnd"
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) {
stageDone = true;
}
@ -570,12 +564,6 @@ bool plAnimStage::ITryRegress(plArmatureMod *avMod)
}
// GETANIMNAME
const char * plAnimStage::GetAnimName()
{
return fAnimName;
}
// GETFORWARDTYPE
plAnimStage::ForwardType plAnimStage::GetForwardType()
{
@ -728,27 +716,24 @@ int plAnimStage::GetPrevStage(int curStage)
}
// 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 += " ";
str << fAnimName;
str << " ";
if(fLoops) {
sprintf(strBuf, "loop(%d/%d)", fCurLoop, fLoops);
str += strBuf;
}
if(fLoops)
str << plString::Format("loop(%d/%d)", fCurLoop, fLoops);
sprintf(strBuf, "time: (%f/%f)", fLocalTime, fLength);
str += strBuf;
str << plString::Format("time: (%f/%f)", fLocalTime, fLength);
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)
debugTxt.DrawString(x, y, str.c_str());
debugTxt.DrawString(x, y, str.GetString().c_str());
else
debugTxt.DrawString(x, y, str.c_str(), 255, 255, 0);
debugTxt.DrawString(x, y, str.GetString().c_str(), 255, 255, 0);
y += lineHeight;
}
@ -756,8 +741,7 @@ void plAnimStage::DumpDebug(bool active, int &x, int &y, int lineHeight, char *s
// READ
void plAnimStage::Read(hsStream *stream, hsResMgr *mgr)
{
delete [] fAnimName;
fAnimName = stream->ReadSafeString();
fAnimName = stream->ReadSafeString_TEMP();
fNotify = stream->ReadByte();
fForwardType = (ForwardType)stream->ReadLE32();
fBackType = (BackType)stream->ReadLE32();

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

@ -50,6 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <vector>
#include "hsMatrix44.h"
#include "pnFactory/plCreatable.h"
#include "plString.h"
class plMessage;
class plAGAnimInstance;
@ -158,7 +159,7 @@ public:
animation attempts to reposition the avatar by having a
channel attached to the avatar's handle.
*/
plAnimStage(const char *animName,
plAnimStage(const plString &animName,
uint8_t notify,
ForwardType forward,
BackType backward,
@ -172,7 +173,7 @@ public:
will be played after this one, depending on which direction the stage is
moving.
*/
plAnimStage(const char *animName,
plAnimStage(const plString &animName,
uint8_t notify,
ForwardType forward,
BackType back,
@ -189,7 +190,7 @@ public:
\param animName The name of the animation controlled by this stage.
\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();
const plAnimStage& operator=(const plAnimStage& src);
@ -200,7 +201,7 @@ public:
bool MoveRelative(double worldTime, float delta, float &overage, plArmatureMod *avMod);
/** The name of the animation associated with this stage. */
const char * GetAnimName();
plString GetAnimName() const { return fAnimName; }
ForwardType GetForwardType();
void SetForwardType(ForwardType t);
@ -230,7 +231,7 @@ public:
plAGAnimInstance *GetAnimInstance() const { return fAnimInstance; };
bool GetReverseOnIdle() { return fReverseOnIdle; }
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
virtual void Read(hsStream *stream, hsResMgr *mgr);
@ -254,7 +255,7 @@ protected:
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
int fLoops; // how many times will this animation loop (after initial playthrough?)

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

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

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

@ -101,7 +101,7 @@ void plArmatureBehavior::Rewind()
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();
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);
blendBar[bars] = '\0';
plString details;
if (fAnim)
{
plString animName = fAnim->GetName();
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
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;
}

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 float GetStrength();
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
{

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

@ -81,7 +81,7 @@ public:
virtual bool LeaveAge();
virtual bool IsRunningTask() const;
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 Read(hsStream *stream, hsResMgr *mgr);

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

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

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

@ -103,9 +103,9 @@ public:
virtual void SaveToSDL(plStateDataRecord *sdl);
virtual void LoadFromSDL(const plStateDataRecord *sdl);
void DumpToDebugDisplay(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt);
const char * WorldDirStr(plClimbMsg::Direction dir);
const char *ModeStr(Mode mode);
void DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt);
static const char *WorldDirStr(plClimbMsg::Direction dir);
static const char *ModeStr(Mode mode);
// plasma protocol
virtual bool MsgReceive(plMessage *msg);
@ -173,9 +173,9 @@ private:
*/
bool IProcessExitStage(double time, float elapsed);
void IDumpClimbDirections(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt);
void IDumpDismountDirections(int &x, int &y, int lineHeight, char *strBuf, plDebugText &debugTxt);
void IDumpBlockedDirections(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, 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
}
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, strBuf, 0, 255, 255);
debugTxt.DrawString(x, y, "Brain type: Critter", 0, 255, 255);
y += lineHeight;
// extract the name from the behavior running
plString mode = "Mode: Unknown";
if (fBehaviors[fCurMode])
sprintf(strBuf, "Mode: %s", ((CritterBehavior*)(fBehaviors[fCurMode]))->Name().c_str());
else
sprintf(strBuf, "Mode: Unknown");
mode = plString::Format("Mode: %s", ((CritterBehavior*)(fBehaviors[fCurMode]))->Name().c_str());
// draw it
debugTxt.DrawString(x, y, strBuf);
debugTxt.DrawString(x, y, mode);
y += lineHeight;
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 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
static bool fDrawDebug;

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

@ -229,7 +229,7 @@ bool plAvBrainGeneric::MatchAnimNames(const char *names[], int count)
int i;
for (i = 0; i < count; i++)
{
if (strcmp(names[i], GetStage(i)->GetAnimName()))
if (GetStage(i)->GetAnimName() != names[i])
return false; // different names.
}
@ -946,7 +946,7 @@ void plAvBrainGeneric::SetBodyUsage(plAGAnim::BodyUsage bodyUsage)
// 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");
y += lineHeight;
@ -955,7 +955,7 @@ void plAvBrainGeneric::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *
for(int i = 0; i < stageCount; 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; }
/** 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
bool MsgReceive(plMessage *msg);

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

@ -896,28 +896,19 @@ bool plAvBrainHuman::LeaveAge()
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, strBuf);
debugTxt.DrawString(x, y, "Brain type: Human");
y += lineHeight;
const char *grounded = fWalkingStrategy->IsOnGround() ? "yes" : "no";
const char *pushing = (fWalkingStrategy->GetPushingPhysical() ? (fWalkingStrategy->GetFacingPushingPhysical() ? "facing" : "behind") : "none");
sprintf(strBuf, "Ground: %3s, AirTime: %5.2f (Peak: %5.2f), PushingPhys: %6s",
grounded, fWalkingStrategy->GetAirTime(), fWalkingStrategy->GetImpactTime(), pushing);
debugTxt.DrawString(x, y, strBuf);
debugTxt.DrawString(x, y, plString::Format("Ground: %3s, AirTime: %5.2f (Peak: %5.2f), PushingPhys: %6s",
grounded, fWalkingStrategy->GetAirTime(), fWalkingStrategy->GetImpactTime(), pushing));
y += lineHeight;
int i;
//strBuf[0] = '\0';
//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);
for (int i = 0; i < fBehaviors.GetCount(); i++)
fBehaviors[i]->DumpDebug(x, y, lineHeight, debugTxt);
debugTxt.DrawString(x, y, "Tasks:");
y += lineHeight;
@ -928,7 +919,7 @@ void plAvBrainHuman::DumpToDebugDisplay(int &x, int &y, int lineHeight, char *st
y += lineHeight;
int indentedX = x + 4;
fCurTask->DumpDebug("-", indentedX, y, lineHeight, strBuf, debugTxt);
fCurTask->DumpDebug("-", indentedX, y, lineHeight, debugTxt);
}
int tasks = fTaskQueue.size();
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++)
{
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 Read(hsStream *stream, hsResMgr *mgr);
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.
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, strBuf, 0, 255, 255);
debugTxt.DrawString(x, y, "Brain type: Swim", 0, 255, 255);
y += lineHeight;
switch(fMode) {
case kWading:
sprintf(strBuf, "Mode: Wading");
debugTxt.DrawString(x, y, "Mode: Wading");
break;
case kSwimming2D:
sprintf(strBuf, "Mode: Swimming2D");
debugTxt.DrawString(x, y, "Mode: Swimming2D");
break;
case kSwimming3D:
sprintf(strBuf, "Mode: Swimming3D");
debugTxt.DrawString(x, y, "Mode: Swimming3D");
break;
case kAbort:
sprintf(strBuf, "Mode: Abort (you should never see this)");
debugTxt.DrawString(x, y, "Mode: Abort (you should never see this)");
break;
default:
break;
}
debugTxt.DrawString(x, y, strBuf);
y += lineHeight;
float buoy = fSwimStrategy ? fSwimStrategy->GetBuoyancy() : 0.0f;
sprintf(strBuf, "Distance to surface: %f Buoyancy: %f", fSurfaceDistance, buoy);
debugTxt.DrawString(x, y, strBuf);
debugTxt.DrawString(x, y, plString::Format("Distance to surface: %f Buoyancy: %f", fSurfaceDistance, buoy));
y += lineHeight;
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, strBuf);
debugTxt.DrawString(x, y, plString::Format("Linear Velocity: (%5.2f, %5.2f, %5.2f)", linV.fX, linV.fY, linV.fZ));
y += lineHeight;
int 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 Suspend();
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 IsWalking();
bool IsWading();

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

@ -94,7 +94,7 @@ public:
virtual void LeaveAge(plArmatureMod *avatar) {}
/** 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
CLASSNAME_REGISTER( plAvTask );

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

@ -94,7 +94,7 @@ void plAvTaskBrain::Finish(plArmatureMod *avatar, plArmatureBrain *brain, double
// 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)
{

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

@ -75,7 +75,7 @@ public:
virtual void Finish(plArmatureMod *avatar, plArmatureBrain *brain, double time, float elapsed);
/** 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();

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

@ -556,44 +556,41 @@ bool plAvTaskSeek::IUpdateObjective(plArmatureMod *avatar)
// 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,
fPosition.fX, fPosition.fY, fPosition.fZ, fSeekPos.fX, fSeekPos.fY, fSeekPos.fZ);
debugTxt.DrawString(x, y, strBuf);
fPosition.fX, fPosition.fY, fPosition.fZ, fSeekPos.fX, fSeekPos.fY, fSeekPos.fZ));
y += lineHeight;
sprintf(strBuf, "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);
debugTxt.DrawString(x, y, strBuf);
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));
y += lineHeight;
sprintf(strBuf, " distFwd: %.3f distRt: %.3f shufRange: %.3f sidAngle: %.3f sidRange: %.3f, fMinWalk: %.3f",
fDistForward, fDistRight, fShuffleRange, fMaxSidleAngle, fMaxSidleRange, fMinFwdAngle);
debugTxt.DrawString(x, y, strBuf);
debugTxt.DrawString(x, y, plString::Format(" distFwd: %.3f distRt: %.3f shufRange: %.3f sidAngle: %.3f sidRange: %.3f, fMinWalk: %.3f",
fDistForward, fDistRight, fShuffleRange, fMaxSidleAngle, fMaxSidleRange, fMinFwdAngle));
y += lineHeight;
}
void plAvTaskSeek::DumpToAvatarLog(plArmatureMod *avatar)
{
plStatusLog *log = plAvatarMgr::GetInstance()->GetLog();
char strBuf[256];
avatar->GetMoveKeyString(strBuf);
log->AddLine(strBuf);
log->AddLine(avatar->GetMoveKeyString().c_str());
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,
fPosition.fX, fPosition.fY, fPosition.fZ, fSeekPos.fX, fSeekPos.fY, fSeekPos.fZ);
log->AddLine(strBuf);
fPosition.fX, fPosition.fY, fPosition.fZ,
fSeekPos.fX, fSeekPos.fY, fSeekPos.fZ).c_str());
sprintf(strBuf, " 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);
log->AddLine(strBuf);
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).c_str());
sprintf(strBuf, " distFwd: %.3f distRt: %.3f shufRange: %.3f sidAngle: %.3f sidRange: %.3f, fMinWalk: %.3f",
fDistForward, fDistRight, fShuffleRange, fMaxSidleAngle, fMaxSidleRange, fMinFwdAngle);
log->AddLine(strBuf);
log->AddLine(plString::Format(" distFwd: %.3f distRt: %.3f shufRange: %.3f sidAngle: %.3f sidRange: %.3f, fMinWalk: %.3f",
fDistForward, fDistRight, fShuffleRange,
fMaxSidleAngle, fMaxSidleRange, fMinFwdAngle).c_str());
}
/////////////////////////////////////////////////////////////////////////////////////////

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

@ -96,7 +96,7 @@ public:
virtual void LeaveAge(plArmatureMod *avatar);
/** 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);

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"
plClothingItem::plClothingItem() : fName(nil), fGroup(0), fTileset(0), fType(0), fSortOrder(0),
fDescription(nil), fCustomText(nil), fThumbnail(nil),
fAccessory(nil), fAccessoryName(nil)
plClothingItem::plClothingItem() : fGroup(0), fTileset(0), fType(0), fSortOrder(0),
fThumbnail(nil), fAccessory(nil)
{
int i;
fTextures.Reset();
@ -99,16 +98,8 @@ plClothingItem::plClothingItem() : fName(nil), fGroup(0), fTileset(0), fType(0),
plClothingItem::~plClothingItem()
{
while (fElementNames.GetCount() > 0)
delete [] fElementNames.Pop();
while (fTextures.GetCount() > 0)
delete [] fTextures.Pop();
delete [] fName;
delete [] fDescription;
delete [] fCustomText;
delete [] fAccessoryName;
}
bool plClothingItem::CanWearWith(plClothingItem *item)
@ -169,14 +160,14 @@ void plClothingItem::Read(hsStream *s, hsResMgr *mgr)
{
hsKeyedObject::Read(s, mgr);
fName = s->ReadSafeString();
fName = s->ReadSafeString_TEMP();
fGroup = s->ReadByte();
fType = s->ReadByte();
fTileset = s->ReadByte();
fSortOrder = s->ReadByte();
fCustomText = s->ReadSafeString();
fDescription = s->ReadSafeString();
fCustomText = s->ReadSafeString_TEMP();
fDescription = s->ReadSafeString_TEMP();
if (s->ReadBool())
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;
for (i = 0; i < tileCount; i++)
{
fElementNames.Append(s->ReadSafeString());
fElementNames.Append(s->ReadSafeString_TEMP());
int layerCount = s->ReadByte();
for (j = 0; j < layerCount; j++)
{
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
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);
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);
}
}
@ -306,10 +297,10 @@ bool plClothingItem::MsgReceive(plMessage* msg)
if (fTextures.GetCount() <= eMsg->fWhich)
fTextures.ExpandAndZero(eMsg->fWhich + 1);
if (fElementNames.GetCount() <= eMsg->fWhich)
fElementNames.ExpandAndZero(eMsg->fWhich + 1);
fElementNames.Expand(eMsg->fWhich + 1);
if (fElementNames.Get(eMsg->fWhich) == nil)
fElementNames.Set(eMsg->fWhich, hsStrcpy(eMsg->fElementName));
if (fElementNames.Get(eMsg->fWhich).IsEmpty())
fElementNames.Set(eMsg->fWhich, eMsg->fElementName);
if (fTextures.Get(eMsg->fWhich) == nil)
{
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()
{
delete [] fName;
delete [] fLayoutName;
}
plClothingBase::plClothingBase() : fBaseTexture(nil) {}
void plClothingBase::Read(hsStream* s, hsResMgr* mgr)
{
hsKeyedObject::Read(s, mgr);
fName = s->ReadSafeString();
fName = s->ReadSafeString_TEMP();
if (s->ReadBool())
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)
@ -640,7 +625,7 @@ void plClothingOutfit::IAddItem(plClothingItem *item)
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);
else
soundEffect->SetFootType(plArmatureEffectFootSound::kFootTypeShoe);
@ -1438,9 +1423,8 @@ void plClothingOutfit::IInstanceSharedMeshes(plClothingItem *item)
if (fAvatar)
fAvatar->ValidateMesh();
bool partialSort = item->fCustomText && strstr(item->fCustomText, "NeedsSort");
int i;
for (i = 0; i < plClothingItem::kMaxNumLODLevels; i++)
bool partialSort = (item->fCustomText.Find("NeedsSort") >= 0);
for (int i = 0; i < plClothingItem::kMaxNumLODLevels; i++)
{
const plSceneObject *so = fAvatar->GetClothingSO(i);
if (so != nil && item->fMeshes[i] != nil)
@ -1619,23 +1603,21 @@ plClothingMgr::~plClothingMgr()
delete fItems.Pop();
}
plClothingLayout *plClothingMgr::GetLayout(char *name)
plClothingLayout *plClothingMgr::GetLayout(const plString &name) const
{
int i;
for (i = 0; i < fLayouts.GetCount(); i++)
for (int i = 0; i < fLayouts.GetCount(); i++)
{
if (!strcmp(fLayouts.Get(i)->fName, name))
if (fLayouts.Get(i)->fName == name)
return fLayouts.Get(i);
}
return nil;
}
plClothingElement *plClothingMgr::FindElementByName(const char *name)
plClothingElement *plClothingMgr::FindElementByName(const plString &name) const
{
int i;
for (i = 0; i < fElements.GetCount(); i++)
for (int i = 0; i < fElements.GetCount(); i++)
{
if (!strcmp(fElements.Get(i)->fName, name))
if (fElements.Get(i)->fName == name)
return fElements.Get(i);
}
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;
int i;
for (i = 0; i < fItems.GetCount(); i++)
for (int i = 0; i < fItems.GetCount(); i++)
{
plClothingItem* item = fItems.Get(i);
if (!strcmp(item->fName, name))
if (item->fName == name)
return item;
}
return nil;
@ -1902,7 +1883,7 @@ void plClothingMgr::IAddItem(plClothingItem *item)
{
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));
break;
@ -1928,7 +1909,7 @@ void plClothingMgr::IAddItem(plClothingItem *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()->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
// to change plClothingMgr::IsLRMatch() as well
char *fName;
plString fName;
plSharedMesh *fMeshes[kMaxNumLODLevels];
hsTArray<plMipmap **> fTextures;
hsTArray<char *> fElementNames;
hsTArray<plString> fElementNames;
hsTArray<plClothingElement *> fElements;
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 fTileset;
uint8_t fSortOrder;
char *fDescription;
char *fCustomText;
plString fDescription;
plString fCustomText;
plMipmap *fThumbnail;
plClothingItem *fAccessory; // Forced accessory to always wear with this item.
uint8_t fDefaultTint1[3];
uint8_t fDefaultTint2[3];
char *fAccessoryName; // Export only
plString fAccessoryName; // Export only
@ -111,8 +111,8 @@ public:
CLASSNAME_REGISTER( plClothingItem );
GETINTERFACE_ANY( plClothingItem, hsKeyedObject );
void SetName(char *name) { delete fName; fName = hsStrcpy(name); }
const char* GetName() { return fName; }
void SetName(const plString &name) { fName = name; }
plString GetName() const { return fName; }
bool CanWearWith(plClothingItem *item);
bool WearBefore(plClothingItem *item); // Should we come before the arg item? (texture gen order)
bool HasBaseAlpha();
@ -138,17 +138,16 @@ public:
class plClothingBase : public hsKeyedObject
{
public:
char *fName;
plString fName;
plMipmap *fBaseTexture;
char *fLayoutName;
plString fLayoutName;
plClothingBase();
~plClothingBase();
CLASSNAME_REGISTER( plClothingBase );
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 Write(hsStream* s, hsResMgr* mgr);
@ -282,8 +281,8 @@ public:
CLASSNAME_REGISTER( plClothingMgr );
GETINTERFACE_ANY( plClothingMgr, hsKeyedObject );
plClothingLayout *GetLayout(char *name);
plClothingElement *FindElementByName(const char *name);
plClothingLayout *GetLayout(const plString &name) const;
plClothingElement *FindElementByName(const plString &name) const;
// Functions that just relate to the clothing you have permission to wear (closet)
@ -291,7 +290,7 @@ public:
void GetClosetItems(hsTArray<plClosetItem> &out);
// Functions that relate to all existing clothing
plClothingItem *FindItemByName(const char *name);
plClothingItem *FindItemByName(const plString &name) const;
hsTArray<plClothingItem*>& GetItemList() { return fItems; }
void GetItemsByGroup(uint8_t group, hsTArray<plClothingItem*> &out);
void GetItemsByGroupAndType(uint8_t group, uint8_t type, hsTArray<plClothingItem*> &out);
@ -305,7 +304,7 @@ public:
plClothingItem *GetLRMatch(plClothingItem *item);
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 void Init();

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

@ -519,7 +519,7 @@ bool plAvatarSDLModifier::IPutStageIn(plArmatureMod *avMod, plAnimStage *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::kStrForward)->Set((int)stage->GetForwardType());
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
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>");
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 "hsTemplates.h"
#include "plString.h"
// This file is intended to be an independent section so that plClothingMtl and plAvatarClothing
@ -71,21 +72,14 @@ public:
kLayerSkinLast = kLayerSkinBlend6,
};
char *fName;
plString fName;
uint32_t fXPos;
uint32_t fYPos;
uint32_t fWidth;
uint32_t fHeight;
plClothingElement(const char *name, uint32_t xPos, uint32_t yPos, uint32_t width, uint32_t height)
{
fName = hsStrcpy(name);
fXPos = xPos;
fYPos = yPos;
fWidth = width;
fHeight = height;
}
~plClothingElement() { delete [] fName; }
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) { }
static void GetElements(hsTArray<plClothingElement *> &out)
{
@ -127,10 +121,10 @@ public:
class plClothingLayout
{
public:
plClothingLayout(const char *name, uint32_t origWidth) { fName = hsStrcpy(name); fOrigWidth = origWidth; }
~plClothingLayout() { delete [] fName; }
plClothingLayout(const plString &name, uint32_t origWidth)
: fName(name), fOrigWidth(origWidth) { }
char *fName;
plString fName;
uint32_t fOrigWidth;
hsTArray<plClothingElement*> fElements;
/*

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

@ -145,7 +145,7 @@ bool plMultistageBehMod::MsgReceive(plMessage* msg)
plAnimStage* stage = new plAnimStage;
*stage = *((*fStages)[i]);
stages->push_back(stage);
if (strstr(stage->GetAnimName(),"adder") != nil)
if (stage->GetAnimName().Find("adder") >= 0)
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::plNPCSpawnMod()
: fModelName(nil),
fAccountName(nil),
fAutoSpawn(false),
: fAutoSpawn(false),
fNotify(nil)
{
}
// 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)
{
fModelName = hsStrcpy(modelName);
fAccountName = hsStrcpy(accountName);
fModelName = modelName;
fAccountName = accountName;
}
// plNPCSpawnMod dtor
plNPCSpawnMod::~plNPCSpawnMod()
{
if(fModelName)
{
delete[] fModelName;
fModelName = nil;
}
if(fAccountName)
{
delete[] fAccountName;
fAccountName = nil;
}
if (fNotify)
fNotify->UnRef();
}
@ -108,7 +96,7 @@ bool plNPCSpawnMod::Trigger()
// will netpropagate
if(this->IsLocallyOwned())
{
if(fModelName)
if (!fModelName.IsEmpty())
{
// spawn the NPC
plKey spawnPoint = GetTarget(0)->GetKey();
@ -140,8 +128,8 @@ void plNPCSpawnMod::Read(hsStream *stream, hsResMgr *mgr)
{
plSingleModifier::Read(stream, mgr);
fModelName = stream->ReadSafeString();
fAccountName = stream->ReadSafeString();
fModelName = stream->ReadSafeString_TEMP();
fAccountName = stream->ReadSafeString_TEMP();
fAutoSpawn = stream->ReadBool();
if(stream->ReadBool())
fNotify = plNotifyMsg::ConvertNoRef(mgr->ReadCreatable(stream));

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

@ -47,7 +47,7 @@ class plNPCSpawnMod : public plSingleModifier
{
public:
plNPCSpawnMod();
plNPCSpawnMod(const char * modelName, const char *accountName, bool autoSpawn);
plNPCSpawnMod(const plString &modelName, const plString &accountName, bool autoSpawn);
~plNPCSpawnMod();
bool Trigger();
@ -68,8 +68,8 @@ protected:
void ISendNotify(plKey &avatarKey); // send our notification message
private:
char *fModelName;
char *fAccountName;
plString fModelName;
plString fAccountName;
bool fAutoSpawn; // spawn immediately on loading
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.

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

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

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

@ -56,7 +56,7 @@ class plOneShotMod : public plMultiModifier
{
protected:
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 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?)
@ -64,10 +64,11 @@ protected:
bool fNoSeek;
public:
plOneShotMod();
plOneShotMod(const char *animName, bool drivable, bool reversable, float seekDuration, bool smartSeek,bool noSeek = false);
virtual ~plOneShotMod();
plOneShotMod(const plString &animName, bool drivable, bool reversable,
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 );
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
//////////////
// 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
//////////////////////
@ -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.");
}
// ISLOCAL
bool plArmatureUpdateMsg::IsLocal() const
{
return fIsLocal;
}
// ISPLAYERCONTROLLED
bool plArmatureUpdateMsg::IsPlayerControlled() const
{
return fIsPlayerControlled;
}
bool plArmatureUpdateMsg::IsInvis() const
{
return fIsInvis;
}
/////////////////////
// PLAVATARSETTYPEMSG
/////////////////////
@ -164,18 +119,6 @@ void plAvatarSetTypeMsg::Write(hsStream *stream, hsResMgr *mgr)
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
void plAvTaskMsg::Read(hsStream *stream, hsResMgr *mgr)
{
@ -562,11 +500,6 @@ plAvPushBrainMsg::plAvPushBrainMsg(const plKey& sender, const plKey &receiver, p
fBrain = brain;
}
// dtor
plAvPushBrainMsg::~plAvPushBrainMsg()
{
}
// READ
void plAvPushBrainMsg::Read(hsStream *stream, hsResMgr *mgr)
{
@ -583,62 +516,9 @@ void plAvPushBrainMsg::Write(hsStream *stream, hsResMgr *mgr)
mgr->WriteCreatable(stream, fBrain);
}
//////////////////
//
// PLAVPOPBRAINMSG
//
//////////////////
// default ctor
plAvPopBrainMsg::plAvPopBrainMsg()
{
}
// canonical ctor
plAvPopBrainMsg::plAvPopBrainMsg(const plKey &sender, const plKey &receiver)
: plAvTaskMsg(sender, receiver)
{
}
#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);
}
plAvatarStealthModeMsg::~plAvatarStealthModeMsg() {}
// READ stream mgr
void plAvatarStealthModeMsg::Read(hsStream *stream, hsResMgr *mgr)
{

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

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

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

@ -49,16 +49,16 @@ void plLoadAgeMsg::Read(hsStream* stream, hsResMgr* mgr)
{
plMessage::IMsgRead(stream, mgr);
delete [] fAgeFilename;
// read agename
uint8_t len;
stream->ReadLE(&len);
if (len)
{
fAgeFilename=new char[len+1];
stream->Read(len, fAgeFilename);
fAgeFilename[len]=0;
plStringBuffer<char> filename;
char* buffer = filename.CreateWritableBuffer(len);
stream->Read(len, buffer);
buffer[len] = 0;
fAgeFilename = filename;
}
fUnload = stream->ReadBool();
stream->ReadLE(&fPlayerID);
@ -70,11 +70,11 @@ void plLoadAgeMsg::Write(hsStream* stream, hsResMgr* mgr)
plMessage::IMsgWrite(stream, mgr);
// write agename
uint8_t len = fAgeFilename ? strlen(fAgeFilename) : 0;
uint8_t len = static_cast<uint8_t>(fAgeFilename.GetSize());
stream->WriteLE(len);
if (len)
{
stream->Write(len, fAgeFilename);
stream->Write(len, fAgeFilename.c_str());
}
stream->WriteBool(fUnload);
stream->WriteLE(fPlayerID);
@ -99,8 +99,7 @@ void plLoadAgeMsg::ReadVersion(hsStream* s, hsResMgr* mgr)
if (contentFlags.IsBitSet(kLoadAgeAgeName))
{
// read agename
delete [] fAgeFilename;
fAgeFilename = s->ReadSafeString();
fAgeFilename = s->ReadSafeString_TEMP();
}
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 "pnUUID/pnUUID.h"
#include "plString.h"
//
@ -55,19 +56,18 @@ class hsResMgr;
class plLoadAgeMsg : public plMessage
{
protected:
char* fAgeFilename; // the age to load/unload
plString fAgeFilename; // the age to load/unload
plUUID fAgeGuid;
bool fUnload; // true if we want to unload the age
int fPlayerID;
public:
plLoadAgeMsg() : fAgeFilename(nil), fUnload(false), fPlayerID(-1){ }
virtual ~plLoadAgeMsg() { delete [] fAgeFilename; }
plLoadAgeMsg() : fUnload(false), fPlayerID(-1) { }
CLASSNAME_REGISTER( plLoadAgeMsg );
GETINTERFACE_ANY( plLoadAgeMsg, plMessage );
void SetAgeFilename(const char* a) { delete [] fAgeFilename; fAgeFilename=a?hsStrcpy(a):nil; }
char* GetAgeFilename() const { return fAgeFilename; }
void SetAgeFilename(const plString& a) { fAgeFilename = a; }
plString GetAgeFilename() const { return fAgeFilename; }
void SetAgeGuid( const plUUID * v ) { fAgeGuid.CopyFrom( v ); }
const plUUID * GetAgeGuid() const { return &fAgeGuid; }

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

@ -85,28 +85,28 @@ protected:
float fVolume;
char* fFileName;
plString fFileName;
uint16_t fCmd;
hsTArray<plMessage*> fCallbacks;
public:
plMovieMsg(const char* n, uint16_t cmd)
plMovieMsg(const plString& name, uint16_t cmd)
: plMessage(nil, nil, nil)
{
fFileName = hsStrcpy(n);
fFileName = name;
SetCmd(cmd).MakeDefault();
}
plMovieMsg() : fFileName(nil), fCmd(kIgnore)
plMovieMsg() : fCmd(kIgnore)
{
MakeDefault();
}
virtual ~plMovieMsg()
{
delete [] fFileName;
int i;
for( i = 0; i < fCallbacks.GetCount(); i++ )
for (int i = 0; i < fCallbacks.GetCount(); i++)
{
hsRefCnt_SafeUnRef(fCallbacks[i]);
}
@ -157,8 +157,8 @@ public:
// Include the movie folder, e.g. "avi/porno.bik"
// String is copied, not pointer copy.
const char* GetFileName() const { return fFileName; }
plMovieMsg& SetFileName(const char* n) { delete [] fFileName; fFileName = hsStrcpy(n); return *this; }
plString GetFileName() const { return fFileName; }
plMovieMsg& SetFileName(const plString& name) { fFileName = name; return *this; }
// Color is mostly useful for alpha fade up and down.
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 "plMessage/plLoadCloneMsg.h"
plCloneSpawnModifier::plCloneSpawnModifier() : fTemplateName(nil), fExportTime(false)
plCloneSpawnModifier::plCloneSpawnModifier() : fExportTime(false)
{
}
plCloneSpawnModifier::~plCloneSpawnModifier()
{
delete [] fTemplateName;
}
void plCloneSpawnModifier::Read(hsStream *s, hsResMgr *mgr)
{
delete [] fTemplateName;
fTemplateName = s->ReadSafeString();
fTemplateName = s->ReadSafeString_TEMP();
plSingleModifier::Read(s, mgr);
}
@ -75,12 +69,6 @@ void plCloneSpawnModifier::Write(hsStream *s, hsResMgr *mgr)
plSingleModifier::Write(s, mgr);
}
void plCloneSpawnModifier::SetTemplateName(const char *templateName)
{
delete [] fTemplateName;
fTemplateName = hsStrcpy(templateName);
}
void plCloneSpawnModifier::SetTarget(plSceneObject* 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
{
protected:
char* fTemplateName;
plString fTemplateName;
bool fExportTime;
virtual bool IEval(double secs, float del, uint32_t dirty) { return true; }
public:
plCloneSpawnModifier();
~plCloneSpawnModifier();
CLASSNAME_REGISTER(plCloneSpawnModifier);
GETINTERFACE_ANY(plCloneSpawnModifier, plSingleModifier);
@ -64,7 +63,7 @@ public:
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
// 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
//
extern std::vector<plString> DisplaySystemVersion();
void plNetClientMgr::IDumpOSVersionInfo() const
{
DebugMsg("*** OS Info");
char** versionStrs = DisplaySystemVersion();
int i=0;
while(versionStrs && versionStrs[i])
{
DebugMsg(versionStrs[i]);
delete [] versionStrs[i];
i++;
}
delete [] versionStrs;
std::vector<plString> versionStrs = DisplaySystemVersion();
for (auto version = versionStrs.begin(); version != versionStrs.end(); ++version)
DebugMsg(version->c_str());
}
//

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

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

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

@ -66,12 +66,12 @@ HRESULT hsGDirect3DTnLEnumerate::SelectFromDevMode(const hsG3DDeviceRecord* devR
int 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;
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));
SetCurrentDevice(&GetDriver(i)->fDevices[j]);
@ -84,14 +84,12 @@ HRESULT hsGDirect3DTnLEnumerate::SelectFromDevMode(const hsG3DDeviceRecord* devR
}
}
}
char errStr[256];
sprintf(errStr, "Can't find requested device - %s:%s:%s:%s:%s",
plString errStr = plString::Format("Can't find requested device - %s:%s:%s:%s:%s",
devRec->GetG3DDeviceTypeName(),
devRec->GetDriverDesc(),
devRec->GetDriverName(),
devRec->GetDriverVersion(),
devRec->GetDeviceDesc());
devRec->GetDriverDesc().c_str(),
devRec->GetDriverName().c_str(),
devRec->GetDriverVersion().c_str(),
devRec->GetDeviceDesc().c_str());
DWORD enumFlags = 0;
int width = devMode->GetWidth();

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

@ -121,7 +121,9 @@ HRESULT plDXPixelShader::ICreate(plDXPipeline* pipe)
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());

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)
: fOwner(owner),
fErrorString(nil),
fPipe(nil)
{
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)
{
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
#include "plDXDeviceRef.h"
#include "plString.h"
class plShader;
class plDXPipeline;
@ -52,11 +53,11 @@ class plDXShader : public plDXDeviceRef
{
protected:
plShader* fOwner;
char* fErrorString;
plString fErrorString;
plDXPipeline* fPipe;
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 ISetConstants(plDXPipeline* pipe) = 0; // On error, sets error string.
@ -65,7 +66,7 @@ public:
plDXShader(plShader* owner);
virtual ~plDXShader();
const char* GetErrorString() const { return fErrorString; }
plString GetErrorString() const { return fErrorString; }
void SetOwner(plShader* owner);
};

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

@ -124,7 +124,9 @@ HRESULT plDXVertexShader::ICreate(plDXPipeline* pipe)
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());

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

@ -97,7 +97,6 @@ void hsG3DDeviceMode::Clear()
hsG3DDeviceRecord::hsG3DDeviceRecord()
: fFlags(kNone),
fG3DDeviceType(hsG3DDeviceSelector::kDevTypeUnknown),
fG3DDriverDesc(nil), fG3DDriverName(nil), fG3DDriverVersion(nil), fG3DDeviceDesc(nil),
fLayersAtOnce(0), fMemoryBytes(0),
fG3DHALorHEL(hsG3DDeviceSelector::kHHTypeUnknown),
fZBiasRating( 0 ), fLODBiasRating( 0 ),
@ -115,7 +114,6 @@ hsG3DDeviceRecord::~hsG3DDeviceRecord()
hsG3DDeviceRecord::hsG3DDeviceRecord(const hsG3DDeviceRecord& src)
: fFlags(kNone),
fG3DDeviceType(hsG3DDeviceSelector::kDevTypeUnknown),
fG3DDriverDesc(nil), fG3DDriverName(nil), fG3DDriverVersion(nil), fG3DDeviceDesc(nil),
fG3DHALorHEL(hsG3DDeviceSelector::kHHTypeUnknown),
fZBiasRating( src.fZBiasRating ), fLODBiasRating( 0 ),
fFogExpApproxStart( src.fFogExpApproxStart ), fFogExp2ApproxStart( src.fFogExp2ApproxStart ),
@ -162,30 +160,6 @@ hsG3DDeviceRecord& hsG3DDeviceRecord::operator=(const hsG3DDeviceRecord& src)
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
{
static const char* deviceNames[hsG3DDeviceSelector::kNumDevTypes] = {
@ -230,17 +204,10 @@ void hsG3DDeviceRecord::Clear()
{
fFlags = kNone;
delete [] fG3DDriverDesc;
fG3DDriverDesc = nil;
delete [] fG3DDriverName;
fG3DDriverName = nil;
delete [] fG3DDriverVersion;
fG3DDriverVersion = nil;
delete [] fG3DDeviceDesc;
fG3DDeviceDesc = nil;
fG3DDriverDesc = plString::Null;
fG3DDriverName = plString::Null;
fG3DDriverVersion = plString::Null;
fG3DDeviceDesc = plString::Null;
fCaps.Clear();
fLayersAtOnce = 0;
@ -268,14 +235,6 @@ hsG3DDeviceModeRecord::hsG3DDeviceModeRecord(const hsG3DDeviceRecord& devRec, co
{
}
hsG3DDeviceModeRecord::hsG3DDeviceModeRecord()
{
}
hsG3DDeviceModeRecord::~hsG3DDeviceModeRecord()
{
}
hsG3DDeviceModeRecord::hsG3DDeviceModeRecord(const hsG3DDeviceModeRecord& src)
{
*this = src;
@ -291,10 +250,6 @@ hsG3DDeviceModeRecord& hsG3DDeviceModeRecord::operator=(const hsG3DDeviceModeRec
///////////////////////////////////////////////////
///////////////////////////////////////////////////
hsG3DDeviceSelector::hsG3DDeviceSelector()
{
}
hsG3DDeviceSelector::~hsG3DDeviceSelector()
{
IClear();
@ -629,7 +584,6 @@ void hsG3DDeviceSelector::IFudgeDirectXDevice( hsG3DDeviceRecord &record,
D3DEnum_DriverInfo *driverInfo,
D3DEnum_DeviceInfo *deviceInfo )
{
char desc[ 512 ]; // Can't rely on D3D constant, since that's in another file now
uint32_t vendorID, deviceID;
char *szDriver, *szDesc;
@ -649,21 +603,18 @@ void hsG3DDeviceSelector::IFudgeDirectXDevice( hsG3DDeviceRecord &record,
}
/// So capitalization won't matter in our tests
hsAssert( strlen( szDesc ) < sizeof( desc ), "D3D device description longer than expected!" );
hsStrcpy( desc, szDesc );
hsStrLower( desc );
plString desc = plString::FromIso8859_1(szDesc).ToLower();
/// Detect ATI Radeon chipset
// We will probably need to differentiate between different Radeons at some point in
// 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;
const char* str = strstr(desc, "radeon");
if( str )
str += strlen("radeon");
if( str )
if (radeon >= 0)
{
const char* str = desc.c_str() + radeon + strlen("radeon");
if( 1 == sscanf(str, "%d", &series) )
{
if( (series >= 8000) && (series < 9000) )
@ -693,13 +644,13 @@ void hsG3DDeviceSelector::IFudgeDirectXDevice( hsG3DDeviceRecord &record,
/// Detect Intel i810 chipset
else if( deviceID == 0x00007125 &&
( 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" );
ISetFudgeFactors( kIntelI810Chipset, record );
}
/// 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" );
ISetFudgeFactors( kNVidiaGeForceFXChipset, record );

30
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 "hsBitVector.h"
#include "plString.h"
#ifdef HS_BUILD_FOR_WIN32
#define HS_SELECT_DIRECT3D // not supported on the Mac.
@ -149,10 +150,10 @@ protected:
uint32_t fG3DHALorHEL;
char* fG3DDriverDesc;
char* fG3DDriverName;
char* fG3DDriverVersion;
char* fG3DDeviceDesc;
plString fG3DDriverDesc;
plString fG3DDriverName;
plString fG3DDriverVersion;
plString fG3DDeviceDesc;
hsBitVector fCaps;
uint32_t fLayersAtOnce;
@ -188,19 +189,19 @@ public:
uint32_t GetMemoryBytes() const { return fMemoryBytes; }
const char* GetDriverDesc() const { return fG3DDriverDesc; }
const char* GetDriverName() const { return fG3DDriverName; }
const char* GetDriverVersion() const { return fG3DDriverVersion; }
const char* GetDeviceDesc() const { return fG3DDeviceDesc; }
plString GetDriverDesc() const { return fG3DDriverDesc; }
plString GetDriverName() const { return fG3DDriverName; }
plString GetDriverVersion() const { return fG3DDriverVersion; }
plString GetDeviceDesc() const { return fG3DDeviceDesc; }
void SetG3DDeviceType(uint32_t t) { fG3DDeviceType = t; }
void SetG3DHALorHEL(uint32_t h) { fG3DHALorHEL = h; }
void SetMemoryBytes(uint32_t b) { fMemoryBytes = b; }
void SetDriverDesc(const char* s);
void SetDriverName(const char* s);
void SetDriverVersion(const char* s);
void SetDeviceDesc(const char* s);
void SetDriverDesc(const plString& s) { fG3DDriverDesc = s; }
void SetDriverName(const plString& s) { fG3DDriverName = s; }
void SetDriverVersion(const plString& s) { fG3DDriverVersion = s; }
void SetDeviceDesc(const plString& s) { fG3DDeviceDesc = s; }
bool GetCap(uint32_t cap) const { return fCaps.IsBitSet(cap); }
void SetCap(uint32_t cap, bool on=true) { fCaps.SetBit(cap, on); }
@ -252,9 +253,8 @@ protected:
hsG3DDeviceRecord fDevice;
hsG3DDeviceMode fMode;
public:
hsG3DDeviceModeRecord();
hsG3DDeviceModeRecord() { }
hsG3DDeviceModeRecord(const hsG3DDeviceRecord& devRec, const hsG3DDeviceMode& devMode);
~hsG3DDeviceModeRecord();
hsG3DDeviceModeRecord(const hsG3DDeviceModeRecord& src);
hsG3DDeviceModeRecord& operator=(const hsG3DDeviceModeRecord& src);
@ -343,7 +343,7 @@ protected:
void ISetFudgeFactors( uint8_t chipsetID, hsG3DDeviceRecord &record );
public:
hsG3DDeviceSelector();
hsG3DDeviceSelector() { }
virtual ~hsG3DDeviceSelector();
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:
plBinkPlayer() : fFileName(nil) { }
~plBinkPlayer() { delete [] fFileName; }
plBinkPlayer() { }
static bool Init( hsWindowHndl hWnd) { return true; }
static bool DeInit() { return true; }
@ -83,14 +82,12 @@ class plBinkPlayer
for (int i = 0; i < fCallbacks.GetCount(); i++)
fCallbacks[i]->Send();
fCallbacks.Reset();
delete [] fFileName;
fFileName = nil;
fFileName = plString::Null;
return false;
}
void SetFileName(const char* filename) {
delete [] fFileName;
fFileName = hsStrcpy(filename);
void SetFileName(const plString& filename) {
fFileName = filename;
}
void SetColor(const hsColorRGBA& c) { }
void SetPosition(float x, float y) { }
@ -102,7 +99,7 @@ class plBinkPlayer
void SetPosition(const hsPoint2& p) { }
void SetScale(const hsPoint2& s) { }
const char* GetFileName() const { return fFileName; }
plString GetFileName() const { return fFileName; }
const hsColorRGBA GetColor() const { return hsColorRGBA(); }
const hsPoint2 GetPosition() const { return hsPoint2(); }
const hsPoint2 GetScale() const { return hsPoint2(); }
@ -125,7 +122,7 @@ class plBinkPlayer
hsColorRGBA GetFadeToColor() const { return hsColorRGBA(); }
private:
char* fFileName;
plString fFileName;
hsTArray<plMessage*> fCallbacks;
};

1
Sources/Tools/MaxComponent/CMakeLists.txt

@ -89,7 +89,6 @@ set(MaxComponent_HEADERS
plVolumeGadgetComponent.h
plWaterComponent.h
plXImposter.h
WavFileStructs.h
)
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++)
{
plBaseStage* stage = fStages[i];
ListView_AddString(hList, stage->GetName());
ListView_AddString(hList, stage->GetName().c_str());
}
// Make sure the column is wide enough
@ -323,19 +323,17 @@ void plMultistageBehComponent::IInitDlg()
// rename them all to start with zero instead.
void plMultistageBehComponent::FixStageNames()
{
if(fStages.size() > 0)
if (fStages.size() > 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++)
{
plBaseStage* stage = fStages[i];
char buf[64];
sprintf(buf, "Stage %d", i);
stage->SetName(buf);
stage->SetName(plString::Format("Stage %d", i));
}
}
}
@ -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
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_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 "plAvatar/plAnimStage.h"
plBaseStage::plBaseStage()
{
fName = nil;
}
plBaseStage::~plBaseStage()
{
delete [] fName;
}
BOOL plBaseStage::IStaticDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_INITDIALOG)
@ -96,24 +86,17 @@ void plBaseStage::IDestroyDlg(HWND hDlg)
GetCOREInterface()->DeleteRollupPage(hDlg);
}
const char* plBaseStage::GetName()
plString plBaseStage::GetName()
{
if (!fName)
fName = hsStrcpy("DefaultName");
if (fName.IsEmpty())
fName = "DefaultName";
return fName;
}
void plBaseStage::SetName(const char* name)
{
delete [] fName;
fName = hsStrcpy(name);
}
void plBaseStage::Read(hsStream *stream)
{
stream->ReadLE16();
delete [] fName;
fName = stream->ReadSafeString();
fName = stream->ReadSafeString_TEMP();
}
void plBaseStage::Write(hsStream *stream)
@ -124,7 +107,7 @@ void plBaseStage::Write(hsStream *stream)
void plBaseStage::IBaseClone(plBaseStage* clone)
{
clone->fName = hsStrcpy(fName);
clone->fName = fName;
}
////////////////////////////////////////////////////////////////////////////////
@ -134,7 +117,6 @@ HWND plStandardStage::fDlg = NULL;
plStandardStage::plStandardStage()
{
fAnimName = nil;
fNumLoops = 0;
fLoopForever = false;
fForward = 0;
@ -149,19 +131,13 @@ plStandardStage::plStandardStage()
fRegressTo = 0;
}
plStandardStage::~plStandardStage()
{
delete [] fAnimName;
}
void plStandardStage::Read(hsStream *stream)
{
plBaseStage::Read(stream);
uint16_t version = stream->ReadLE16();
delete [] fAnimName;
fAnimName = stream->ReadSafeString();
fAnimName = stream->ReadSafeString_TEMP();
fNumLoops = stream->ReadLE32();
fLoopForever = stream->ReadBool();
fForward = stream->ReadByte();
@ -329,10 +305,9 @@ void plStandardStage::IGetAnimName()
char buf[256];
edit->GetText(buf, sizeof(buf));
if (strcmp(buf, fAnimName) != 0)
if (fAnimName != buf)
{
delete [] fAnimName;
fAnimName = hsStrcpy(buf);
fAnimName = buf;
SetSaveRequiredFlag();
}
@ -387,7 +362,7 @@ static void LoadCombo(HWND hCombo, NameType* nameInt, int size, int curVal)
void plStandardStage::IInitDlg()
{
ICustEdit* edit = GetICustEdit(GetDlgItem(fDlg, IDC_ANIM_NAME));
edit->SetText(fAnimName);
edit->SetText(fAnimName.c_str());
HWND hForward = GetDlgItem(fDlg, IDC_FORWARD_COMBO);
LoadCombo(hForward, gForward, sizeof(gForward), fForward);
@ -446,7 +421,7 @@ plAnimStage* plStandardStage::CreateStage()
plBaseStage* plStandardStage::Clone()
{
plStandardStage* clone = new plStandardStage;
clone->fAnimName = hsStrcpy(fAnimName);
clone->fAnimName = fAnimName;
clone->fNumLoops = fNumLoops;
clone->fLoopForever = fLoopForever;
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==*/
#include "plString.h"
class plAnimStage;
class plBaseStage;
class hsStream;
@ -56,7 +58,7 @@ enum StageTypes
class plBaseStage
{
protected:
char* fName;
plString fName;
static BOOL CALLBACK IStaticDlgProc(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);
public:
plBaseStage();
virtual ~plBaseStage();
plBaseStage() { }
virtual ~plBaseStage() { }
// From StageTypes
virtual int GetType()=0;
@ -84,8 +86,8 @@ public:
virtual plBaseStage* Clone()=0;
const char* GetName();
void SetName(const char* name);
plString GetName(); // NOT const (this could change fName)
void SetName(const plString& name) { fName = name; }
};
class plStandardStage : public plBaseStage
@ -93,7 +95,7 @@ class plStandardStage : public plBaseStage
protected:
static HWND fDlg;
char *fAnimName;
plString fAnimName;
uint32_t fNumLoops;
bool fLoopForever;
uint8_t fForward;
@ -114,7 +116,7 @@ protected:
public:
plStandardStage();
~plStandardStage();
~plStandardStage() { }
int GetType() { return kStandard; }

8
Sources/Tools/MaxConvert/hsMaterialConverter.cpp

@ -4527,12 +4527,12 @@ plClothingItem *hsMaterialConverter::GenerateClothingItem(plClothingMtl *mtl, co
{
plString clothKeyName;
plClothingItem *cloth = new plClothingItem();
cloth->SetName(mtl->GetName());
cloth->SetName((const char *)mtl->GetName());
cloth->fSortOrder = (mtl->GetDefault() ? 0 : 1);
const char *accName = mtl->GetForcedAccessoryName();
if (accName && strcmp(accName, ""))
cloth->fAccessoryName = hsStrcpy(accName);
cloth->fAccessoryName = accName;
Color tint1 = mtl->GetDefaultTint1();
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[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);
plNodeRefMsg* nodeRefMsg = new plNodeRefMsg(plKeyFinder::Instance().FindSceneNodeKey(loc),
@ -4560,7 +4560,7 @@ plClothingItem *hsMaterialConverter::GenerateClothingItem(plClothingMtl *mtl, co
{
uint32_t clipLevels;
uint32_t startWidth;
char *elementName = tileset->fElements.Get(i)->fName;
plString elementName = tileset->fElements.Get(i)->fName;
plPlasmaMAXLayer *layer = (plPlasmaMAXLayer *)mtl->GetTexmap(i, j);
if (layer == nil || layer->GetPBBitmap() == nil)
continue;

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

@ -565,12 +565,12 @@ Interval plClothingMtl::DisplacementValidity(TimeValue t)
return iv;
}
plClothingElement *plClothingMtl::FindElementByName(char *name)
plClothingElement *plClothingMtl::FindElementByName(const plString &name) const
{
int 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 nil;

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

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

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

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

Loading…
Cancel
Save