Browse Source

Allow passing a clothing file to LoadAvatar and plStringify whatever we encounter on our way

Florian Meißner 11 years ago
parent
commit
7e66aee382
  1. 31
      Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp
  2. 4
      Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h
  3. 5
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp
  4. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.h
  5. 32
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp
  6. 9
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.h
  7. 106
      Sources/Plasma/PubUtilLib/plMessage/plLoadAvatarMsg.cpp
  8. 24
      Sources/Plasma/PubUtilLib/plMessage/plLoadAvatarMsg.h
  9. 2
      Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp
  10. 3
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp

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

@ -784,29 +784,22 @@ void plArmatureMod::WindowActivate(bool active)
} }
} }
char *plArmatureMod::fSpawnPointOverride = nil; plString plArmatureMod::fSpawnPointOverride;
void plArmatureMod::SetSpawnPointOverride( const char *overrideObjName ) void plArmatureMod::SetSpawnPointOverride(const plString &overrideObjName)
{ {
delete [] fSpawnPointOverride; fSpawnPointOverride = overrideObjName.ToLower();
if( overrideObjName == nil )
fSpawnPointOverride = nil;
else
{
fSpawnPointOverride = hsStrcpy( overrideObjName );
strlwr( fSpawnPointOverride );
}
} }
int plArmatureMod::IFindSpawnOverride( void ) int plArmatureMod::IFindSpawnOverride()
{ {
if( fSpawnPointOverride == nil || fSpawnPointOverride[ 0 ] == 0 ) if (fSpawnPointOverride.IsEmpty())
return -1; return -1;
int i; int i;
plAvatarMgr *mgr = plAvatarMgr::GetInstance(); plAvatarMgr *mgr = plAvatarMgr::GetInstance();
for( i = 0; i < mgr->NumSpawnPoints(); i++ ) for (i = 0; i < mgr->NumSpawnPoints(); i++)
{ {
const plString &name = mgr->GetSpawnPoint( i )->GetTarget(0)->GetKeyName(); const plString &name = mgr->GetSpawnPoint(i)->GetTarget(0)->GetKeyName();
if (name.Find(fSpawnPointOverride, plString::kCaseInsensitive) >= 0) if (name.Find(fSpawnPointOverride, plString::kCaseInsensitive) >= 0)
return i; // Found it! return i; // Found it!
} }
@ -1300,15 +1293,9 @@ bool plArmatureMod::MsgReceive(plMessage* msg)
} }
} }
// copy the user string over
const char* userStr = avLoadMsg->GetUserStr();
if (userStr)
fUserStr = userStr;
else
fUserStr = "";
return true; return true;
} }
plLoadCloneMsg *cloneMsg = plLoadCloneMsg::ConvertNoRef(msg); plLoadCloneMsg *cloneMsg = plLoadCloneMsg::ConvertNoRef(msg);
if (cloneMsg) if (cloneMsg)

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

@ -329,7 +329,7 @@ public:
static void SetMouseTurnSensitivity(float val) { fMouseTurnSensitivity = val / 150.f; } static void SetMouseTurnSensitivity(float val) { fMouseTurnSensitivity = val / 150.f; }
static float GetMouseTurnSensitivity() { return fMouseTurnSensitivity * 150.f; } static float GetMouseTurnSensitivity() { return fMouseTurnSensitivity * 150.f; }
static void SetSpawnPointOverride( const char *overrideObjName ); static void SetSpawnPointOverride(const plString &overrideObjName);
static void WindowActivate(bool active); static void WindowActivate(bool active);
void SetFollowerParticleSystemSO(plSceneObject *follower); void SetFollowerParticleSystemSO(plSceneObject *follower);
plSceneObject *GetFollowerParticleSystemSO(); plSceneObject *GetFollowerParticleSystemSO();
@ -426,7 +426,7 @@ protected:
hsTArray<const plSceneObject*> fClothToSOMap; hsTArray<const plSceneObject*> fClothToSOMap;
plArmatureEffectsMgr *fEffects; plArmatureEffectsMgr *fEffects;
plSceneObject *fFollowerParticleSystemSO; plSceneObject *fFollowerParticleSystemSO;
static char *fSpawnPointOverride; static plString fSpawnPointOverride;
// These vectors are used with relevance regions for culling out other objects // These vectors are used with relevance regions for culling out other objects
hsBitVector fRegionsImIn; hsBitVector fRegionsImIn;

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

@ -1832,9 +1832,8 @@ void plClothingMgr::IAddItem(plClothingItem *item)
hsAssert(false, "Couldn't match all elements of added clothing item."); hsAssert(false, "Couldn't match all elements of added clothing item.");
} }
void plClothingMgr::ChangeAvatar(char *name) void plClothingMgr::ChangeAvatar(const char* name, const plFileName &clothingFile)
{ {
plAvatarMgr::GetInstance()->UnLoadLocalPlayer(); plAvatarMgr::GetInstance()->UnLoadLocalPlayer();
plAvatarMgr::GetInstance()->LoadPlayer(name, nil); plAvatarMgr::GetInstance()->LoadPlayerFromFile(name, "", clothingFile);
} }

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

@ -281,7 +281,7 @@ public:
plClothingItem *GetLRMatch(plClothingItem *item); plClothingItem *GetLRMatch(plClothingItem *item);
bool IsLRMatch(plClothingItem *item1, plClothingItem *item2); bool IsLRMatch(plClothingItem *item1, plClothingItem *item2);
static void ChangeAvatar(char *name); static void ChangeAvatar(const char* name, const plFileName &clothingFile = "");
static plClothingMgr *GetClothingMgr() { return fInstance; } static plClothingMgr *GetClothingMgr() { return fInstance; }
static void Init(); static void Init();

32
Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp

@ -149,12 +149,12 @@ void plAvatarMgr::IReset()
fActiveCoops.clear(); fActiveCoops.clear();
} }
plKey plAvatarMgr::LoadPlayer(const char *name, const char *account) plKey plAvatarMgr::LoadPlayer(const plString &name, const plString &account)
{ {
return LoadAvatar(name, account, true, nil, nil); return LoadAvatar(name, account, true, nullptr, nullptr);
} }
plKey plAvatarMgr::LoadPlayer(const char *name, const char *account, const char *linkInName) plKey plAvatarMgr::LoadPlayer(const plString &name, const plString &account, const plString &linkInName)
{ {
// what we'd like to do is turn the linkInName into a spawn point key and // what we'd like to do is turn the linkInName into a spawn point key and
// put that into the plLoadAvatarMsg, which is already set up to handle // put that into the plLoadAvatarMsg, which is already set up to handle
@ -163,29 +163,34 @@ plKey plAvatarMgr::LoadPlayer(const char *name, const char *account, const char
// so we're goin to do this the "old way" for now. // so we're goin to do this the "old way" for now.
plArmatureMod::SetSpawnPointOverride(linkInName); plArmatureMod::SetSpawnPointOverride(linkInName);
return LoadAvatar(name, account, true, nil, nil); return LoadAvatar(name, account, true, nullptr, nullptr);
} }
plKey plAvatarMgr::LoadPlayerFromFile(const plString &name, const plString &account, const plFileName &clothingFile)
{
return LoadAvatar(name, account, true, nullptr, nullptr, "", clothingFile);
}
plKey plAvatarMgr::LoadAvatar(const char *name, const char *accountName, bool isPlayer, plKey spawnPoint, plAvTask *initialTask, const char *userStr /*=nil*/) plKey plAvatarMgr::LoadAvatar(plString name, plString accountName, bool isPlayer, plKey spawnPoint, plAvTask *initialTask,
const plString &userStr, const plFileName &clothingFile)
{ {
// *** account is currently unused. the idea is that eventually an NPC will // *** account is currently unused. the idea is that eventually an NPC will
// *** be able to use a customization account // *** be able to use a customization account
plKey result = nil; plKey result = nullptr;
plKey requestor = GetKey(); // avatar manager is always the requestor for avatar loads plKey requestor = GetKey(); // avatar manager is always the requestor for avatar loads
plNetClientMgr *netMgr = plNetClientMgr::GetInstance(); plNetClientMgr *netMgr = plNetClientMgr::GetInstance();
if(netMgr) // can't clone without the net manager if(netMgr) // can't clone without the net manager
{ {
hsAssert(name, "name required by LoadPlayer fxn"); hsAssert(!name.IsEmpty(), "name required by LoadPlayer fxn");
netMgr->DebugMsg("Local: Loading player %s", name); netMgr->DebugMsg("Local: Loading player %s", name.c_str());
// look up player by key name provided by user. // look up player by key name provided by user.
// this string search should be replaced with some other method of // this string search should be replaced with some other method of
// avatar selection and key lookup. // avatar selection and key lookup.
// Get the location for the player first // Get the location for the player first
plKey playerKey = nil; plKey playerKey = nullptr;
const plLocation& globalLoc = plKeyFinder::Instance().FindLocation("GlobalAvatars", name); const plLocation& globalLoc = plKeyFinder::Instance().FindLocation("GlobalAvatars", name);
const plLocation& maleLoc = plKeyFinder::Instance().FindLocation("GlobalAvatars", "Male"); const plLocation& maleLoc = plKeyFinder::Instance().FindLocation("GlobalAvatars", "Male");
const plLocation& custLoc = plKeyFinder::Instance().FindLocation("CustomAvatars", name); const plLocation& custLoc = plKeyFinder::Instance().FindLocation("CustomAvatars", name);
@ -199,14 +204,13 @@ plKey plAvatarMgr::LoadAvatar(const char *name, const char *accountName, bool is
const plLocation& loc = (globalLoc.IsValid() ? globalLoc : custLoc.IsValid() ? custLoc : maleLoc); const plLocation& loc = (globalLoc.IsValid() ? globalLoc : custLoc.IsValid() ? custLoc : maleLoc);
#endif #endif
plString theName = name; if (loc == maleLoc)
if ( loc == maleLoc ) name = "Male";
theName = "Male";
if (loc.IsValid()) if (loc.IsValid())
{ {
plUoid uID(loc, plSceneObject::Index(), theName); plUoid uID(loc, plSceneObject::Index(), name);
plLoadAvatarMsg *cloneMsg = new plLoadAvatarMsg (uID, requestor, 0, isPlayer, spawnPoint, initialTask, userStr); plLoadAvatarMsg *cloneMsg = new plLoadAvatarMsg(uID, requestor, 0, isPlayer, spawnPoint, initialTask, userStr);
result = cloneMsg->GetCloneKey(); result = cloneMsg->GetCloneKey();
// the clone message is automatically addressed to the net client manager // the clone message is automatically addressed to the net client manager

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

@ -48,6 +48,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include <map> #include <map>
#include "plFileSystem.h"
#include "hsGeometry3.h" #include "hsGeometry3.h"
#include "pnKeyedObject/hsKeyedObject.h" #include "pnKeyedObject/hsKeyedObject.h"
@ -113,9 +114,11 @@ public:
plOneShotMod *FindOneShot(const plString &name); plOneShotMod *FindOneShot(const plString &name);
// \} // \}
plKey LoadPlayer(const char* name, const char *account); plKey LoadPlayer(const plString &name, const plString &account);
plKey LoadPlayer(const char* name, const char *account, const char *linkName); plKey LoadPlayer(const plString &name, const plString &account, const plString &linkName);
plKey LoadAvatar(const char *name, const char *accountName, bool isPlayer, plKey spawnPoint, plAvTask *initialTask, const char *userStr = nil); plKey LoadPlayerFromFile(const plString &name, const plString &account, const plFileName &clothingFile);
plKey LoadAvatar(plString name, plString accountName, bool isPlayer, plKey spawnPoint, plAvTask *initialTask,
const plString &userStr = "", const plFileName &clothingFile = "");
/** /**
* Unload an avatar clone * Unload an avatar clone

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

@ -58,44 +58,30 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// CTOR (default) // CTOR (default)
plLoadAvatarMsg::plLoadAvatarMsg() plLoadAvatarMsg::plLoadAvatarMsg()
: fIsPlayer(false), : fIsPlayer(false),
fSpawnPoint(nil), fSpawnPoint(nullptr),
fInitialTask(nil), fInitialTask(nullptr)
fUserStr(nil)
{ {
} }
// CTOR uoidToClone, requestorKey, userData, isPlayer, spawnPOint, initialTask // CTOR uoidToClone, requestorKey, userData, isPlayer, spawnPOint, initialTask
plLoadAvatarMsg::plLoadAvatarMsg(const plUoid &uoidToClone, const plKey &requestorKey, uint32_t userData, plLoadAvatarMsg::plLoadAvatarMsg(const plUoid &uoidToClone, const plKey &requestorKey, uint32_t userData,
bool isPlayer, const plKey &spawnPoint, plAvTask *initialTask, const char* userStr /*= nil*/) bool isPlayer, const plKey &spawnPoint, plAvTask *initialTask, const plString &userStr)
: plLoadCloneMsg(uoidToClone, requestorKey, userData), : plLoadCloneMsg(uoidToClone, requestorKey, userData),
fIsPlayer(isPlayer), fIsPlayer(isPlayer),
fSpawnPoint(spawnPoint), fSpawnPoint(spawnPoint),
fInitialTask(initialTask), fInitialTask(initialTask),
fUserStr(nil) // setting to nil so SetUserStr doesn't try to nuke garbage fUserStr(userStr)
{ {
SetUserStr(userStr);
} }
plLoadAvatarMsg::plLoadAvatarMsg(const plKey &existing, const plKey &requestor, uint32_t userData, plLoadAvatarMsg::plLoadAvatarMsg(const plKey &existing, const plKey &requestor, uint32_t userData,
bool isPlayer, bool isLoading, const char* userStr /*= nil*/) bool isPlayer, bool isLoading, const plString &userStr)
: plLoadCloneMsg(existing, requestor, userData, isLoading), : plLoadCloneMsg(existing, requestor, userData, isLoading),
fIsPlayer(isPlayer), fIsPlayer(isPlayer),
fSpawnPoint(nil), fSpawnPoint(nullptr),
fInitialTask(nil), fInitialTask(nullptr),
fUserStr(nil) // setting to nil so SetUserStr doesn't try to nuke garbage fUserStr(userStr)
{
SetUserStr(userStr);
}
// DTOR
plLoadAvatarMsg::~plLoadAvatarMsg()
{ {
if (fUserStr)
{
delete [] fUserStr;
fUserStr = nil;
}
} }
void plLoadAvatarMsg::Read(hsStream* stream, hsResMgr* mgr) void plLoadAvatarMsg::Read(hsStream* stream, hsResMgr* mgr)
@ -107,12 +93,7 @@ void plLoadAvatarMsg::Read(hsStream* stream, hsResMgr* mgr)
{ {
fInitialTask = plAvTask::ConvertNoRef(mgr->ReadCreatable(stream)); fInitialTask = plAvTask::ConvertNoRef(mgr->ReadCreatable(stream));
} }
if (fUserStr) fUserStr = stream->ReadSafeString_TEMP();
{
delete [] fUserStr;
fUserStr = nil;
}
fUserStr = stream->ReadSafeString();
} }
void plLoadAvatarMsg::Write(hsStream *stream, hsResMgr *mgr) void plLoadAvatarMsg::Write(hsStream *stream, hsResMgr *mgr)
@ -150,13 +131,8 @@ void plLoadAvatarMsg::ReadVersion(hsStream* stream, hsResMgr* mgr)
if (contentFlags.IsBitSet(kLoadAvatarMsgSpawnPoint)) if (contentFlags.IsBitSet(kLoadAvatarMsgSpawnPoint))
fSpawnPoint = mgr->ReadKey(stream); fSpawnPoint = mgr->ReadKey(stream);
if (fUserStr)
{
delete [] fUserStr;
fUserStr = nil;
}
if (contentFlags.IsBitSet(kLoadAvatarMsgUserStr)) if (contentFlags.IsBitSet(kLoadAvatarMsgUserStr))
fUserStr = stream->ReadSafeString(); fUserStr = stream->ReadSafeString_TEMP();
} }
void plLoadAvatarMsg::WriteVersion(hsStream* stream, hsResMgr* mgr) void plLoadAvatarMsg::WriteVersion(hsStream* stream, hsResMgr* mgr)
@ -179,63 +155,5 @@ void plLoadAvatarMsg::WriteVersion(hsStream* stream, hsResMgr* mgr)
stream->WriteSafeString(fUserStr); stream->WriteSafeString(fUserStr);
} }
// SETISPLAYER
void plLoadAvatarMsg::SetIsPlayer(bool is)
{
fIsPlayer = is;
}
// GETISPLAYER
bool plLoadAvatarMsg::GetIsPlayer()
{
return fIsPlayer;
}
// SETSPAWNPOINT
void plLoadAvatarMsg::SetSpawnPoint(const plKey &spawnPoint)
{
fSpawnPoint = spawnPoint;
}
// GETSPAWNPOINT
plKey plLoadAvatarMsg::GetSpawnPoint()
{
return fSpawnPoint;
}
// SETINITIALTASK
void plLoadAvatarMsg::SetInitialTask(plAvTask *initialTask)
{
fInitialTask = initialTask;
}
// GETINITIALTASK
plAvTask * plLoadAvatarMsg::GetInitialTask()
{
return fInitialTask;
}
// SETUSERSTR
void plLoadAvatarMsg::SetUserStr(const char *userStr)
{
if (fUserStr)
delete [] fUserStr;
if (!userStr)
{
fUserStr = nil;
return;
}
fUserStr = new char[strlen(userStr) + 1];
strcpy(fUserStr, userStr);
fUserStr[strlen(userStr)] = '\0';
}
// GETUSERSTR
const char* plLoadAvatarMsg::GetUserStr()
{
return fUserStr;
}
#endif // ndef SERVER #endif // ndef SERVER
#endif // ndef NO_AV_MSGS #endif // ndef NO_AV_MSGS

24
Sources/Plasma/PubUtilLib/plMessage/plLoadAvatarMsg.h

@ -83,7 +83,7 @@ public:
\param userStr - a string that the user can set \param userStr - a string that the user can set
*/ */
plLoadAvatarMsg(const plUoid &uoidToClone, const plKey &requestorKey, uint32_t userData, plLoadAvatarMsg(const plUoid &uoidToClone, const plKey &requestorKey, uint32_t userData,
bool isPlayer, const plKey &spawnPoint, plAvTask *initialTask, const char *userStr = nil); bool isPlayer, const plKey &spawnPoint, plAvTask *initialTask, const plString &userStr = "");
/** Use this form if you're sending a message about an existing clone -- either /** Use this form if you're sending a message about an existing clone -- either
to propagate it to other machines or to tell them to unload it. to propagate it to other machines or to tell them to unload it.
@ -97,21 +97,19 @@ public:
\param userStr - a string that the user can set \param userStr - a string that the user can set
*/ */
plLoadAvatarMsg(const plKey &existing, const plKey &requestorKey, uint32_t userData, plLoadAvatarMsg(const plKey &existing, const plKey &requestorKey, uint32_t userData,
bool isPlayer, bool isLoading, const char *userStr = nil); bool isPlayer, bool isLoading, const plString &userStr = "");
virtual ~plLoadAvatarMsg(); void SetIsPlayer(bool is) { fIsPlayer = is; }
bool GetIsPlayer() { return fIsPlayer; }
void SetIsPlayer(bool is); void SetSpawnPoint(const plKey &spawnPoint) { fSpawnPoint = spawnPoint; }
bool GetIsPlayer(); plKey GetSpawnPoint() { return fSpawnPoint; }
void SetSpawnPoint(const plKey &spawnSceneObjectKey); void SetInitialTask(plAvTask *task) { fInitialTask = task; }
plKey GetSpawnPoint(); plAvTask * GetInitialTask() { return fInitialTask; }
void SetInitialTask(plAvTask *task); void SetUserStr(const plString &userStr) { fUserStr = userStr; }
plAvTask * GetInitialTask(); plString GetUserStr() { return fUserStr; }
void SetUserStr(const char *userStr);
const char* GetUserStr();
CLASSNAME_REGISTER(plLoadAvatarMsg); CLASSNAME_REGISTER(plLoadAvatarMsg);
GETINTERFACE_ANY(plLoadAvatarMsg, plLoadCloneMsg); GETINTERFACE_ANY(plLoadAvatarMsg, plLoadCloneMsg);
@ -126,7 +124,7 @@ protected:
bool fIsPlayer; bool fIsPlayer;
plKey fSpawnPoint; plKey fSpawnPoint;
plAvTask *fInitialTask; plAvTask *fInitialTask;
char *fUserStr; plString fUserStr;
}; };

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

@ -281,7 +281,7 @@ void plNCAgeJoiner::ExecNextOp () {
else else
avatarName = NetCommGetPlayer()->avatarDatasetName; avatarName = NetCommGetPlayer()->avatarDatasetName;
plString linkInName = plNetLinkingMgr::GetInstance()->GetAgeLink()->SpawnPoint().GetName(); plString linkInName = plNetLinkingMgr::GetInstance()->GetAgeLink()->SpawnPoint().GetName();
am->LoadPlayer( avatarName, nil, linkInName.c_str() ); am->LoadPlayer(avatarName, "", linkInName);
} }
else { else {
LogMsg(kLogPerf, L"AgeJoiner: Next:kPropagatePlayer"); LogMsg(kLogPerf, L"AgeJoiner: Next:kPropagatePlayer");

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

@ -198,9 +198,6 @@ void plNetClientMgr::Shutdown()
IRemoveCloneRoom(); IRemoveCloneRoom();
// RATHER BAD DEBUG HACK: Clear the spawn override in armatureMod so there's no memory leak
plArmatureMod::SetSpawnPointOverride( nil );
VaultDestroy(); VaultDestroy();
} }

Loading…
Cancel
Save