mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-17 10:52:46 +00:00
Track NPC clones
Manual state management in python was kind of fiddly, so let's track all avatar clones in the NetApp and unload them as needed. This also seems to fix a potential bug in plNPCSpawnMod (is that even used?).
This commit is contained in:
@ -217,11 +217,17 @@ plKey plAvatarMgr::LoadAvatar(const char *name, const char *accountName, bool is
|
||||
return result;
|
||||
}
|
||||
|
||||
void plAvatarMgr::UnLoadAvatar(plKey avatarKey, bool isPlayer)
|
||||
void plAvatarMgr::UnLoadAvatar(const plKey& avatarKey, bool isPlayer, bool netPropagate) const
|
||||
{
|
||||
hsBool isLoading = false;
|
||||
plLoadAvatarMsg *msg = new plLoadAvatarMsg(avatarKey, GetKey(), 0, isPlayer, isLoading);
|
||||
msg->Send();
|
||||
if (avatarKey)
|
||||
{
|
||||
plKey requestor = GetKey();
|
||||
plLoadAvatarMsg* msg = new plLoadAvatarMsg(avatarKey, requestor, 0, isPlayer, false);
|
||||
|
||||
// only netprop if the user has a death wish
|
||||
msg->SetBCastFlag(plMessage::kNetPropagate, netPropagate);
|
||||
msg->Send();
|
||||
}
|
||||
}
|
||||
|
||||
// our player's already loaded locally, but we've just linked into an age and others there need to be
|
||||
@ -271,22 +277,6 @@ bool plAvatarMgr::UnPropagateLocalPlayer()
|
||||
return false;
|
||||
}
|
||||
|
||||
// UNLOADREMOTEPLAYER
|
||||
void plAvatarMgr::UnLoadRemotePlayer(plKey remotePlayer)
|
||||
{
|
||||
if(remotePlayer)
|
||||
{
|
||||
plKey requestor = GetKey();
|
||||
bool isPlayer = true;
|
||||
hsBool isLoading = false;
|
||||
plLoadAvatarMsg * msg = new plLoadAvatarMsg(remotePlayer, requestor, 0, isPlayer, isLoading);
|
||||
|
||||
// don't propagate over the network. this is just for removing our local version
|
||||
msg->SetBCastFlag(plMessage::kNetPropagate, false);
|
||||
msg->Send();
|
||||
}
|
||||
}
|
||||
|
||||
// UNLOADLOCALPLAYER
|
||||
void plAvatarMgr::UnLoadLocalPlayer()
|
||||
{
|
||||
|
@ -115,15 +115,21 @@ public:
|
||||
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);
|
||||
/** Unload an avatar - player or npc - both locally and remotely. */
|
||||
void UnLoadAvatar(plKey avKey, bool isPlayer);
|
||||
|
||||
/**
|
||||
* Unload an avatar clone
|
||||
*
|
||||
* This unloads the clone of an avatar (remote player or NPC) from our local game.
|
||||
* The avatar clone can be unloaded globally by setting netPropagate; however, this
|
||||
* is highly discouraged.
|
||||
*/
|
||||
void UnLoadAvatar(const plKey& avKey, bool isPlayer, bool netPropagate=false) const;
|
||||
/** send our (already loaded) local player to newly-associated clients - used when linking */
|
||||
void PropagateLocalPlayer(int spawnPoint = -1);
|
||||
/** Unload our local player on other machines because we're leaving this age.
|
||||
The player will stay around on our local machine, though. */
|
||||
bool UnPropagateLocalPlayer();
|
||||
|
||||
void UnLoadRemotePlayer(plKey playerKey);
|
||||
void UnLoadLocalPlayer();
|
||||
|
||||
void AddAvatar(plArmatureMod *avatar);
|
||||
|
@ -99,16 +99,6 @@ void plNPCSpawnMod::AddTarget(plSceneObject* so)
|
||||
Trigger();
|
||||
}
|
||||
|
||||
void plNPCSpawnMod::RemoveTarget(plSceneObject *so)
|
||||
{
|
||||
plSingleModifier::RemoveTarget(so);
|
||||
|
||||
if(fSpawnedKey)
|
||||
{
|
||||
plAvatarMgr::GetInstance()->UnLoadAvatar(fSpawnedKey, false);
|
||||
}
|
||||
}
|
||||
|
||||
// TRIGGER
|
||||
bool plNPCSpawnMod::Trigger()
|
||||
{
|
||||
@ -123,6 +113,7 @@ bool plNPCSpawnMod::Trigger()
|
||||
// spawn the NPC
|
||||
plKey spawnPoint = GetTarget(0)->GetKey();
|
||||
|
||||
// Note: we will be unloaded by the NetApp's NPC magick
|
||||
fSpawnedKey = plAvatarMgr::GetInstance()->LoadAvatar(fModelName, fAccountName, false, spawnPoint, nil);
|
||||
|
||||
ISendNotify(fSpawnedKey);
|
||||
|
@ -58,7 +58,6 @@ public:
|
||||
GETINTERFACE_ANY( plNPCSpawnMod, plSingleModifier );
|
||||
|
||||
virtual void AddTarget(plSceneObject* so);
|
||||
virtual void RemoveTarget(plSceneObject *so);
|
||||
// hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
virtual void Read(hsStream *stream, hsResMgr *mgr);
|
||||
|
Reference in New Issue
Block a user