Browse Source

More odds and ends from Mystler's PRs

(cherry picked from commit eb40f86349)
working_subtitles
Mystler 2 years ago committed by rarified
parent
commit
a82188cbf4
  1. 23
      Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp
  2. 4
      Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h
  3. 8
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp
  4. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.h
  5. 33
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp
  6. 9
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.h
  7. 101
      Sources/Plasma/PubUtilLib/plMessage/plLoadAvatarMsg.cpp
  8. 24
      Sources/Plasma/PubUtilLib/plMessage/plLoadAvatarMsg.h
  9. 67
      Sources/Plasma/PubUtilLib/plMessage/plLoadClothingMsg.h
  10. 3
      Sources/Plasma/PubUtilLib/plMessage/plMessageCreatable.h
  11. 4
      Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp
  12. 3
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp

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

@ -788,30 +788,23 @@ 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;
int i;
plAvatarMgr *mgr = plAvatarMgr::GetInstance();
for( i = 0; i < mgr->NumSpawnPoints(); i++ )
for (i = 0; i < mgr->NumSpawnPoints(); i++)
{
char str2[ 256 ];
strcpy(str2, mgr->GetSpawnPoint( i )->GetTarget(0)->GetKeyName());
strcpy(str2, mgr->GetSpawnPoint(i)->GetTarget(0)->GetKeyName());
strlwr(str2);
if (strstr(str2, fSpawnPointOverride) != nil)

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

@ -330,7 +330,7 @@ public:
static void SetMouseTurnSensitivity(hsScalar val) { fMouseTurnSensitivity = val / 150.f; }
static hsScalar 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();
@ -428,7 +428,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;

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

@ -431,8 +431,8 @@ hsBool plClothingBase::MsgReceive(plMessage* msg)
/////////////////////////////////////////////////////////////////////////////
plClothingOutfit::plClothingOutfit() :
fTargetLayer(nullptr), fBase(nullptr), fGroup(0), fAvatar(nullptr), fSynchClients(false), fMaterial(nullptr),
fVaultSaveEnabled(true), fMorphsInitDone(false)
fTargetLayer(nullptr), fBase(nullptr), fGroup(0), fAvatar(nullptr), fSynchClients(false), fMaterial(nullptr),
fVaultSaveEnabled(true), fMorphsInitDone(false)
{
fSkinTint.Set(1.f, 0.84, 0.71, 1.f);
fItems.Reset();
@ -1938,9 +1938,9 @@ 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

@ -303,7 +303,7 @@ public:
plClothingItem *GetLRMatch(plClothingItem *item);
hsBool 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();

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

@ -83,6 +83,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "../plMessage/plMemberUpdateMsg.h"
#include "../plMessage/plAvatarMsg.h"
#include "../plMessage/plAvCoopMsg.h"
#include "plMessage/plLoadClothingMsg.h"
#include "../pnMessage/plTimeMsg.h"
#include "../plStatusLog/plStatusLog.h"
@ -153,12 +154,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
@ -167,29 +168,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);
@ -204,8 +210,13 @@ plKey plAvatarMgr::LoadAvatar(const char *name, const char *accountName, bool is
if (loc.IsValid())
{
plUoid uID(loc, plSceneObject::Index(), theName);
plLoadAvatarMsg *cloneMsg = TRACKED_NEW plLoadAvatarMsg (uID, requestor, 0, isPlayer, spawnPoint, initialTask, userStr);
plUoid uID(loc, plSceneObject::Index(), name);
plLoadAvatarMsg *cloneMsg = new plLoadAvatarMsg(uID, requestor, 0, isPlayer, spawnPoint, initialTask, userStr);
if (clothingFile.IsValid())
{
plLoadClothingMsg *clothingMsg = new plLoadClothingMsg(clothingFile);
cloneMsg->SetTriggerMsg(clothingMsg);
}
result = cloneMsg->GetCloneKey();
// the clone message is automatically addressed to the net client manager

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

@ -47,6 +47,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsStlUtils.h"
#include "hsStlSortUtils.h"
#include "plFileSystem.h"
#include "hsGeometry3.h"
#include "../pnKeyedObject/hsKeyedObject.h"
@ -112,9 +113,11 @@ public:
plOneShotMod *FindOneShot(char *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 - player or npc - both locally and remotely. */
void UnLoadAvatar(plKey avKey, bool isPlayer);
/** send our (already loaded) local player to newly-associated clients - used when linking */

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

@ -58,44 +58,31 @@ 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 userData,
hsBool isPlayer, const plKey &spawnPoint, plAvTask *initialTask, const char* userStr /*= nil*/)
hsBool 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 userData,
hsBool isPlayer, hsBool isLoading, const char* userStr /*= nil*/)
hsBool 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 +94,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 +132,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 +156,5 @@ void plLoadAvatarMsg::WriteVersion(hsStream* stream, hsResMgr* mgr)
stream->WriteSafeString(fUserStr);
}
// SETISPLAYER
void plLoadAvatarMsg::SetIsPlayer(bool is)
{
fIsPlayer = is;
}
// GETISPLAYER
hsBool 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 = TRACKED_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 userData,
hsBool isPlayer, const plKey &spawnPoint, plAvTask *initialTask, const char *userStr = nil);
hsBool 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 userData,
hsBool isPlayer, hsBool isLoading, const char *userStr = nil);
hsool isPlayer, bool isLoading, const plString &userStr = "");
virtual ~plLoadAvatarMsg();
void SetIsPlayer(bool is) { fIsPlayer = is; }
bool GetIsPlayer() { return fIsPlayer; }
void SetIsPlayer(bool is);
hsBool 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:
hsBool fIsPlayer;
plKey fSpawnPoint;
plAvTask *fInitialTask;
char *fUserStr;
plString fUserStr;
};

67
Sources/Plasma/PubUtilLib/plMessage/plLoadClothingMsg.h

@ -0,0 +1,67 @@
/*==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==*/
#ifndef plLoadClothingMsg_INC
#define plLoadClothingMsg_INC
#include "plFileSystem.h"
#include "pnMessage/plMessage.h"
/** This message is sent when we want to load our clothing from a file. */
class plLoadClothingMsg : public plMessage {
private:
plFileName fClothingFile;
public:
plLoadClothingMsg() { }
plLoadClothingMsg(const plFileName& file) : fClothingFile(file) { }
CLASSNAME_REGISTER(plLoadClothingMsg);
GETINTERFACE_ANY(plLoadClothingMsg, plMessage);
void Read(hsStream*, hsResMgr*) { }
void Write(hsStream*, hsResMgr*) { }
plFileName GetClothingFile() const { return fClothingFile; }
};
#endif // plLoadClothingMsg_INC

3
Sources/Plasma/PubUtilLib/plMessage/plMessageCreatable.h

@ -370,6 +370,9 @@ REGISTER_CREATABLE(plLoadCloneMsg);
# include "plLoadAvatarMsg.h"
REGISTER_CREATABLE(plLoadAvatarMsg);
#include "plLoadClothingMsg.h"
REGISTER_CREATABLE(plLoadClothingMsg);
# include "plAvCoopMsg.h"
REGISTER_CREATABLE(plAvCoopMsg);

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

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

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

@ -202,9 +202,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