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. 23
      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. 28
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp
  6. 9
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.h
  7. 102
      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

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

@ -784,23 +784,16 @@ 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;
if( overrideObjName == nil )
fSpawnPointOverride = nil;
else
{
fSpawnPointOverride = hsStrcpy( overrideObjName );
strlwr( fSpawnPointOverride );
}
fSpawnPointOverride = overrideObjName.ToLower();
}
int plArmatureMod::IFindSpawnOverride( void )
int plArmatureMod::IFindSpawnOverride()
{
if( fSpawnPointOverride == nil || fSpawnPointOverride[ 0 ] == 0 )
if (fSpawnPointOverride.IsEmpty())
return -1;
int i;
plAvatarMgr *mgr = plAvatarMgr::GetInstance();
@ -1300,12 +1293,6 @@ bool plArmatureMod::MsgReceive(plMessage* msg)
}
}
// copy the user string over
const char* userStr = avLoadMsg->GetUserStr();
if (userStr)
fUserStr = userStr;
else
fUserStr = "";
return true;
}

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

@ -329,7 +329,7 @@ public:
static void SetMouseTurnSensitivity(float val) { fMouseTurnSensitivity = val / 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);
void SetFollowerParticleSystemSO(plSceneObject *follower);
plSceneObject *GetFollowerParticleSystemSO();
@ -426,7 +426,7 @@ protected:
hsTArray<const plSceneObject*> fClothToSOMap;
plArmatureEffectsMgr *fEffects;
plSceneObject *fFollowerParticleSystemSO;
static char *fSpawnPointOverride;
static plString fSpawnPointOverride;
// These vectors are used with relevance regions for culling out other objects
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.");
}
void plClothingMgr::ChangeAvatar(char *name)
void plClothingMgr::ChangeAvatar(const char* name, const plFileName &clothingFile)
{
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);
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 void Init();

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

@ -149,12 +149,12 @@ void plAvatarMgr::IReset()
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
// 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.
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
// *** 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
plNetClientMgr *netMgr = plNetClientMgr::GetInstance();
if(netMgr) // can't clone without the net manager
{
hsAssert(name, "name required by LoadPlayer fxn");
netMgr->DebugMsg("Local: Loading player %s", name);
hsAssert(!name.IsEmpty(), "name required by LoadPlayer fxn");
netMgr->DebugMsg("Local: Loading player %s", name.c_str());
// look up player by key name provided by user.
// this string search should be replaced with some other method of
// avatar selection and key lookup.
// Get the location for the player first
plKey playerKey = nil;
plKey playerKey = nullptr;
const plLocation& globalLoc = plKeyFinder::Instance().FindLocation("GlobalAvatars", name);
const plLocation& maleLoc = plKeyFinder::Instance().FindLocation("GlobalAvatars", "Male");
const plLocation& custLoc = plKeyFinder::Instance().FindLocation("CustomAvatars", name);
@ -199,13 +204,12 @@ plKey plAvatarMgr::LoadAvatar(const char *name, const char *accountName, bool is
const plLocation& loc = (globalLoc.IsValid() ? globalLoc : custLoc.IsValid() ? custLoc : maleLoc);
#endif
plString theName = name;
if (loc == maleLoc)
theName = "Male";
name = "Male";
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);
result = cloneMsg->GetCloneKey();

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 <map>
#include "plFileSystem.h"
#include "hsGeometry3.h"
#include "pnKeyedObject/hsKeyedObject.h"
@ -113,9 +114,11 @@ public:
plOneShotMod *FindOneShot(const plString &name);
// \}
plKey LoadPlayer(const char* name, const char *account);
plKey LoadPlayer(const char* name, const char *account, const char *linkName);
plKey LoadAvatar(const char *name, const char *accountName, bool isPlayer, plKey spawnPoint, plAvTask *initialTask, const char *userStr = nil);
plKey LoadPlayer(const plString &name, const plString &account);
plKey LoadPlayer(const plString &name, const plString &account, const plString &linkName);
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

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

@ -58,44 +58,30 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// CTOR (default)
plLoadAvatarMsg::plLoadAvatarMsg()
: fIsPlayer(false),
fSpawnPoint(nil),
fInitialTask(nil),
fUserStr(nil)
fSpawnPoint(nullptr),
fInitialTask(nullptr)
{
}
// CTOR uoidToClone, requestorKey, userData, isPlayer, spawnPOint, initialTask
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),
fIsPlayer(isPlayer),
fSpawnPoint(spawnPoint),
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,
bool isPlayer, bool isLoading, const char* userStr /*= nil*/)
bool isPlayer, bool isLoading, const plString &userStr)
: plLoadCloneMsg(existing, requestor, userData, isLoading),
fIsPlayer(isPlayer),
fSpawnPoint(nil),
fInitialTask(nil),
fUserStr(nil) // setting to nil so SetUserStr doesn't try to nuke garbage
fSpawnPoint(nullptr),
fInitialTask(nullptr),
fUserStr(userStr)
{
SetUserStr(userStr);
}
// DTOR
plLoadAvatarMsg::~plLoadAvatarMsg()
{
if (fUserStr)
{
delete [] fUserStr;
fUserStr = nil;
}
}
void plLoadAvatarMsg::Read(hsStream* stream, hsResMgr* mgr)
@ -107,12 +93,7 @@ void plLoadAvatarMsg::Read(hsStream* stream, hsResMgr* mgr)
{
fInitialTask = plAvTask::ConvertNoRef(mgr->ReadCreatable(stream));
}
if (fUserStr)
{
delete [] fUserStr;
fUserStr = nil;
}
fUserStr = stream->ReadSafeString();
fUserStr = stream->ReadSafeString_TEMP();
}
void plLoadAvatarMsg::Write(hsStream *stream, hsResMgr *mgr)
@ -150,13 +131,8 @@ void plLoadAvatarMsg::ReadVersion(hsStream* stream, hsResMgr* mgr)
if (contentFlags.IsBitSet(kLoadAvatarMsgSpawnPoint))
fSpawnPoint = mgr->ReadKey(stream);
if (fUserStr)
{
delete [] fUserStr;
fUserStr = nil;
}
if (contentFlags.IsBitSet(kLoadAvatarMsgUserStr))
fUserStr = stream->ReadSafeString();
fUserStr = stream->ReadSafeString_TEMP();
}
void plLoadAvatarMsg::WriteVersion(hsStream* stream, hsResMgr* mgr)
@ -179,63 +155,5 @@ void plLoadAvatarMsg::WriteVersion(hsStream* stream, hsResMgr* mgr)
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 NO_AV_MSGS

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

@ -83,7 +83,7 @@ public:
\param userStr - a string that the user can set
*/
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
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
*/
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);
bool GetIsPlayer();
void SetSpawnPoint(const plKey &spawnPoint) { fSpawnPoint = spawnPoint; }
plKey GetSpawnPoint() { return fSpawnPoint; }
void SetSpawnPoint(const plKey &spawnSceneObjectKey);
plKey GetSpawnPoint();
void SetInitialTask(plAvTask *task) { fInitialTask = task; }
plAvTask * GetInitialTask() { return fInitialTask; }
void SetInitialTask(plAvTask *task);
plAvTask * GetInitialTask();
void SetUserStr(const char *userStr);
const char* GetUserStr();
void SetUserStr(const plString &userStr) { fUserStr = userStr; }
plString GetUserStr() { return fUserStr; }
CLASSNAME_REGISTER(plLoadAvatarMsg);
GETINTERFACE_ANY(plLoadAvatarMsg, plLoadCloneMsg);
@ -126,7 +124,7 @@ protected:
bool fIsPlayer;
plKey fSpawnPoint;
plAvTask *fInitialTask;
char *fUserStr;
plString fUserStr;
};

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

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

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

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

Loading…
Cancel
Save