|
|
@ -42,6 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
|
|
|
|
|
|
|
|
|
|
#include <Python.h> |
|
|
|
#include <Python.h> |
|
|
|
#include "plgDispatch.h" |
|
|
|
#include "plgDispatch.h" |
|
|
|
|
|
|
|
#include "hsResMgr.h" |
|
|
|
#include "pyKey.h" |
|
|
|
#include "pyKey.h" |
|
|
|
#pragma hdrstop |
|
|
|
#pragma hdrstop |
|
|
|
|
|
|
|
|
|
|
@ -49,6 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
|
|
|
|
|
|
|
|
|
|
#include "plResMgr/plKeyFinder.h" |
|
|
|
#include "plResMgr/plKeyFinder.h" |
|
|
|
#include "pnKeyedObject/plKey.h" |
|
|
|
#include "pnKeyedObject/plKey.h" |
|
|
|
|
|
|
|
#include "pnKeyedObject/plKeyImp.h" |
|
|
|
#include "pnKeyedObject/plFixedKey.h" |
|
|
|
#include "pnKeyedObject/plFixedKey.h" |
|
|
|
#include "plMessage/plLinkToAgeMsg.h" |
|
|
|
#include "plMessage/plLinkToAgeMsg.h" |
|
|
|
#include "plMessage/plConsoleMsg.h" |
|
|
|
#include "plMessage/plConsoleMsg.h" |
|
|
@ -220,6 +222,23 @@ PyObject* cyMisc::FindSceneObject(const plString& name, const char* ageName) |
|
|
|
return pySceneObject::New(key); |
|
|
|
return pySceneObject::New(key); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PyObject* cyMisc::FindSceneObjects(const plString& name) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// assume that we won't find the sceneobject (key is equal to nil)
|
|
|
|
|
|
|
|
std::vector<plKey> keys; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( !name.IsNull() ) |
|
|
|
|
|
|
|
plKeyFinder::Instance().ReallyStupidSubstringSearch(name, plSceneObject::Index(), keys); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PyObject* result = PyList_New(keys.size()); |
|
|
|
|
|
|
|
for (size_t i=0; i < keys.size(); i++) |
|
|
|
|
|
|
|
PyList_SET_ITEM(result, i, pySceneObject::New(keys[i])); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PyObject* cyMisc::FindActivator(const plString& name) |
|
|
|
PyObject* cyMisc::FindActivator(const plString& name) |
|
|
|
{ |
|
|
|
{ |
|
|
|
plKey key = nil; |
|
|
|
plKey key = nil; |
|
|
@ -302,7 +321,7 @@ void cyMisc::ClearTimerCallbacks(pyKey& selfkey) |
|
|
|
//
|
|
|
|
//
|
|
|
|
// PURPOSE : Attach an object to another object, knowing only their pyKeys
|
|
|
|
// PURPOSE : Attach an object to another object, knowing only their pyKeys
|
|
|
|
//
|
|
|
|
//
|
|
|
|
void cyMisc::AttachObject(pyKey& ckey, pyKey& pkey) |
|
|
|
void cyMisc::AttachObject(pyKey& ckey, pyKey& pkey, bool netForce) |
|
|
|
{ |
|
|
|
{ |
|
|
|
plKey childKey = ckey.getKey(); |
|
|
|
plKey childKey = ckey.getKey(); |
|
|
|
plKey parentKey = pkey.getKey(); |
|
|
|
plKey parentKey = pkey.getKey(); |
|
|
@ -312,10 +331,16 @@ void cyMisc::AttachObject(pyKey& ckey, pyKey& pkey) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// create the attach message to attach the child
|
|
|
|
// create the attach message to attach the child
|
|
|
|
plAttachMsg* pMsg = new plAttachMsg(parentKey, childKey->GetObjectPtr(), plRefMsg::kOnRequest); |
|
|
|
plAttachMsg* pMsg = new plAttachMsg(parentKey, childKey->GetObjectPtr(), plRefMsg::kOnRequest); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (netForce) { |
|
|
|
|
|
|
|
pMsg->SetBCastFlag(plMessage::kNetPropagate); |
|
|
|
|
|
|
|
pMsg->SetBCastFlag(plMessage::kNetForce); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
plgDispatch::MsgSend( pMsg ); |
|
|
|
plgDispatch::MsgSend( pMsg ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
void cyMisc::AttachObjectSO(pySceneObject& cobj, pySceneObject& pobj) |
|
|
|
void cyMisc::AttachObjectSO(pySceneObject& cobj, pySceneObject& pobj, bool netForce) |
|
|
|
{ |
|
|
|
{ |
|
|
|
plKey childKey = cobj.getObjKey(); |
|
|
|
plKey childKey = cobj.getObjKey(); |
|
|
|
plKey parentKey = pobj.getObjKey(); |
|
|
|
plKey parentKey = pobj.getObjKey(); |
|
|
@ -325,6 +350,12 @@ void cyMisc::AttachObjectSO(pySceneObject& cobj, pySceneObject& pobj) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// create the attach message to attach the child
|
|
|
|
// create the attach message to attach the child
|
|
|
|
plAttachMsg* pMsg = new plAttachMsg(parentKey, childKey->GetObjectPtr(), plRefMsg::kOnRequest); |
|
|
|
plAttachMsg* pMsg = new plAttachMsg(parentKey, childKey->GetObjectPtr(), plRefMsg::kOnRequest); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (netForce) { |
|
|
|
|
|
|
|
pMsg->SetBCastFlag(plMessage::kNetPropagate); |
|
|
|
|
|
|
|
pMsg->SetBCastFlag(plMessage::kNetForce); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
plgDispatch::MsgSend( pMsg ); |
|
|
|
plgDispatch::MsgSend( pMsg ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -338,7 +369,7 @@ void cyMisc::AttachObjectSO(pySceneObject& cobj, pySceneObject& pobj) |
|
|
|
//
|
|
|
|
//
|
|
|
|
// PURPOSE : Attach an object to another object, knowing only their pyKeys
|
|
|
|
// PURPOSE : Attach an object to another object, knowing only their pyKeys
|
|
|
|
//
|
|
|
|
//
|
|
|
|
void cyMisc::DetachObject(pyKey& ckey, pyKey& pkey) |
|
|
|
void cyMisc::DetachObject(pyKey& ckey, pyKey& pkey, bool netForce) |
|
|
|
{ |
|
|
|
{ |
|
|
|
plKey childKey = ckey.getKey(); |
|
|
|
plKey childKey = ckey.getKey(); |
|
|
|
plKey parentKey = pkey.getKey(); |
|
|
|
plKey parentKey = pkey.getKey(); |
|
|
@ -348,10 +379,16 @@ void cyMisc::DetachObject(pyKey& ckey, pyKey& pkey) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// create the attach message to detach the child
|
|
|
|
// create the attach message to detach the child
|
|
|
|
plAttachMsg* pMsg = new plAttachMsg(parentKey, childKey->GetObjectPtr(), plRefMsg::kOnRemove); |
|
|
|
plAttachMsg* pMsg = new plAttachMsg(parentKey, childKey->GetObjectPtr(), plRefMsg::kOnRemove); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (netForce) { |
|
|
|
|
|
|
|
pMsg->SetBCastFlag(plMessage::kNetPropagate); |
|
|
|
|
|
|
|
pMsg->SetBCastFlag(plMessage::kNetForce); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
plgDispatch::MsgSend( pMsg ); |
|
|
|
plgDispatch::MsgSend( pMsg ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
void cyMisc::DetachObjectSO(pySceneObject& cobj, pySceneObject& pobj) |
|
|
|
void cyMisc::DetachObjectSO(pySceneObject& cobj, pySceneObject& pobj, bool netForce) |
|
|
|
{ |
|
|
|
{ |
|
|
|
plKey childKey = cobj.getObjKey(); |
|
|
|
plKey childKey = cobj.getObjKey(); |
|
|
|
plKey parentKey = pobj.getObjKey(); |
|
|
|
plKey parentKey = pobj.getObjKey(); |
|
|
@ -361,6 +398,12 @@ void cyMisc::DetachObjectSO(pySceneObject& cobj, pySceneObject& pobj) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// create the attach message to detach the child
|
|
|
|
// create the attach message to detach the child
|
|
|
|
plAttachMsg* pMsg = new plAttachMsg(parentKey, childKey->GetObjectPtr(), plRefMsg::kOnRemove); |
|
|
|
plAttachMsg* pMsg = new plAttachMsg(parentKey, childKey->GetObjectPtr(), plRefMsg::kOnRemove); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (netForce) { |
|
|
|
|
|
|
|
pMsg->SetBCastFlag(plMessage::kNetPropagate); |
|
|
|
|
|
|
|
pMsg->SetBCastFlag(plMessage::kNetForce); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
plgDispatch::MsgSend( pMsg ); |
|
|
|
plgDispatch::MsgSend( pMsg ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1415,7 +1458,7 @@ int cyMisc::GetNumRemotePlayers() |
|
|
|
// PURPOSE : page in, hold or out a particular node
|
|
|
|
// PURPOSE : page in, hold or out a particular node
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
void cyMisc::PageInNodes(const std::vector<std::string> & nodeNames, const char* age) |
|
|
|
void cyMisc::PageInNodes(const std::vector<std::string> & nodeNames, const char* age, bool netForce) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (hsgResMgr::ResMgr()) |
|
|
|
if (hsgResMgr::ResMgr()) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1424,6 +1467,11 @@ void cyMisc::PageInNodes(const std::vector<std::string> & nodeNames, const char* |
|
|
|
plKey clientKey = hsgResMgr::ResMgr()->FindKey(kClient_KEY); |
|
|
|
plKey clientKey = hsgResMgr::ResMgr()->FindKey(kClient_KEY); |
|
|
|
msg->AddReceiver(clientKey); |
|
|
|
msg->AddReceiver(clientKey); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (netForce) { |
|
|
|
|
|
|
|
msg->SetBCastFlag(plMessage::kNetPropagate); |
|
|
|
|
|
|
|
msg->SetBCastFlag(plMessage::kNetForce); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int numNames = nodeNames.size(); |
|
|
|
int numNames = nodeNames.size(); |
|
|
|
for (int i = 0; i < numNames; i++) |
|
|
|
for (int i = 0; i < numNames; i++) |
|
|
|
msg->AddRoomLoc(plKeyFinder::Instance().FindLocation(age ? age : NetCommGetAge()->ageDatasetName, nodeNames[i].c_str())); |
|
|
|
msg->AddRoomLoc(plKeyFinder::Instance().FindLocation(age ? age : NetCommGetAge()->ageDatasetName, nodeNames[i].c_str())); |
|
|
@ -1432,7 +1480,7 @@ void cyMisc::PageInNodes(const std::vector<std::string> & nodeNames, const char* |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void cyMisc::PageOutNode(const char* nodeName) |
|
|
|
void cyMisc::PageOutNode(const char* nodeName, bool netForce) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ( hsgResMgr::ResMgr() ) |
|
|
|
if ( hsgResMgr::ResMgr() ) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1441,6 +1489,11 @@ void cyMisc::PageOutNode(const char* nodeName) |
|
|
|
plKey clientKey = hsgResMgr::ResMgr()->FindKey( kClient_KEY ); |
|
|
|
plKey clientKey = hsgResMgr::ResMgr()->FindKey( kClient_KEY ); |
|
|
|
pMsg1->AddReceiver( clientKey ); |
|
|
|
pMsg1->AddReceiver( clientKey ); |
|
|
|
pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation("", nodeName)); |
|
|
|
pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation("", nodeName)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (netForce) { |
|
|
|
|
|
|
|
pMsg1->SetBCastFlag(plMessage::kNetPropagate); |
|
|
|
|
|
|
|
pMsg1->SetBCastFlag(plMessage::kNetForce); |
|
|
|
|
|
|
|
} |
|
|
|
plgDispatch::MsgSend(pMsg1); |
|
|
|
plgDispatch::MsgSend(pMsg1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2866,3 +2919,37 @@ void cyMisc::VaultDownload(unsigned nodeId) |
|
|
|
nil |
|
|
|
nil |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PyObject* cyMisc::CloneKey(pyKey* object, bool loading) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plKey obj = object->getKey(); |
|
|
|
|
|
|
|
plUoid uoid = obj->GetUoid(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plLoadCloneMsg* cloneMsg; |
|
|
|
|
|
|
|
if (uoid.IsClone()) |
|
|
|
|
|
|
|
cloneMsg = new plLoadCloneMsg(obj, plNetClientMgr::GetInstance()->GetKey(), 0, loading); |
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
cloneMsg = new plLoadCloneMsg(uoid, plNetClientMgr::GetInstance()->GetKey(), 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cloneMsg->SetBCastFlag(plMessage::kNetPropagate); |
|
|
|
|
|
|
|
cloneMsg->SetBCastFlag(plMessage::kNetForce); |
|
|
|
|
|
|
|
cloneMsg->Send(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return pyKey::New(cloneMsg->GetCloneKey()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PyObject* cyMisc::FindClones(pyKey* object) { |
|
|
|
|
|
|
|
plKey obj = object->getKey(); |
|
|
|
|
|
|
|
plUoid uoid = obj->GetUoid(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plKeyImp* imp = ((plKeyImp*)obj); |
|
|
|
|
|
|
|
uint32_t cloneNum = imp->GetNumClones(); |
|
|
|
|
|
|
|
PyObject* keyList = PyList_New(cloneNum); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i=0; i < cloneNum; i++) { |
|
|
|
|
|
|
|
PyObject* key = pyKey::New(imp->GetCloneByIdx(i)); |
|
|
|
|
|
|
|
PyList_SET_ITEM(keyList, i, key); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return keyList; |
|
|
|
|
|
|
|
} |
|
|
|