PyObject* pyVault::FindNode( pyVaultNode* templateNode ) const { // See if we already have a matching node locally if (RelVaultNode * rvn = VaultGetNodeIncRef(templateNode->GetNode())) { PyObject * result = pyVaultNode::New(rvn); rvn->DecRef(); return result; } // See if a matching node exists on the server ARRAY(unsigned) nodeIds; VaultFindNodesAndWait(templateNode->GetNode(), &nodeIds); if (nodeIds.Count()) { // Only fetch the first matching node since this function returns a single node VaultFetchNodesAndWait(&nodeIds[0], 1); // If we fetched it successfully then it'll be in our local node cache now if (RelVaultNode * rvn = VaultGetNodeIncRef(nodeIds[0])) { PyObject * result = pyVaultNode::New(rvn); rvn->DecRef(); return result; } } PYTHON_RETURN_NONE; }
PyObject * pyVaultNodeRef::GetSaver () { if (!fParent || !fChild) return 0; RelVaultNode * saver = nil; if (RelVaultNode * child = VaultGetNodeIncRef(fChild->GetNodeId())) { if (unsigned saverId = child->GetRefOwnerId(fParent->GetNodeId())) { // Find the player info node representing the saver NetVaultNode * templateNode = new NetVaultNode; templateNode->IncRef(); templateNode->SetNodeType(plVault::kNodeType_PlayerInfo); VaultPlayerInfoNode access(templateNode); access.SetPlayerId(saverId); saver = VaultGetNodeIncRef(templateNode); if (!saver) { ARRAY(unsigned) nodeIds; VaultFindNodesAndWait(templateNode, &nodeIds); if (nodeIds.Count() > 0) { VaultFetchNodesAndWait(nodeIds.Ptr(), nodeIds.Count()); saver = VaultGetNodeIncRef(nodeIds[0]); } } templateNode->DecRef(); } child->DecRef(); } if (!saver) PYTHON_RETURN_NONE; PyObject * result = pyVaultPlayerInfoNode::New(saver); saver->DecRef(); return result; }
// Link a node to this one void pyVaultNode::LinkToNode(int nodeID, PyObject* cbObject, uint32_t cbContext) { pyVaultNodeOperationCallback * cb = new pyVaultNodeOperationCallback( cbObject ); if (fNode && nodeID) { // Hack the callbacks until vault notification is in place cb->VaultOperationStarted( cbContext ); if (RelVaultNode * rvn = VaultGetNodeIncRef(nodeID)) { cb->SetNode(rvn); cb->fPyNodeRef = pyVaultNodeRef::New(fNode, rvn); rvn->UnRef(); } VaultAddChildNode(fNode->GetNodeId(), nodeID, NetCommGetPlayer()->playerInt, (FVaultAddChildNodeCallback)_AddNodeCallback, cb ); } else { // manually make the callback cb->VaultOperationStarted( cbContext ); cb->VaultOperationComplete( cbContext, hsFail ); } }
unsigned pyVaultNodeRef::GetSaverID () { if (!fParent || !fChild) return 0; unsigned saverId = 0; if (RelVaultNode * child = VaultGetNodeIncRef(fChild->GetNodeId())) { saverId = child->GetRefOwnerId(fParent->GetNodeId()); child->DecRef(); } return saverId; }
bool VaultAgeLinkNode::CopyTo (plAgeLinkStruct * link) { if (RelVaultNode * me = VaultGetNodeIncRef(base->GetNodeId())) { if (RelVaultNode * info = me->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) { VaultAgeInfoNode access(info); access.CopyTo(link->GetAgeInfo()); me->DecRef(); return true; } me->DecRef(); } link->Clear(); return false; }
bool plNetLinkingMgr::IProcessVaultNotifyMsg(plVaultNotifyMsg* msg) { // No deferred link? Bye bye. if (fDeferredLink == nil) return false; plAgeLinkStruct* cur = GetAgeLink(); RelVaultNode* cVaultLink = nil; switch (msg->GetType()) { case plVaultNotifyMsg::kRegisteredChildAgeLink: case plVaultNotifyMsg::kRegisteredOwnedAge: case plVaultNotifyMsg::kRegisteredSubAgeLink: cVaultLink = VaultGetNodeIncRef(msg->GetArgs()->GetInt(plNetCommon::VaultTaskArgs::kAgeLinkNode)); break; default: return false; } if (cVaultLink != nil) { // This is something that Cyan does... >.< // It's very useful though... VaultAgeLinkNode accLink(cVaultLink); accLink.CopyTo(cur); if (RelVaultNode* rvnInfo = cVaultLink->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) { VaultAgeInfoNode accInfo(rvnInfo); accInfo.CopyTo(cur->GetAgeInfo()); rvnInfo->DecRef(); } IDoLink(fDeferredLink); fDeferredLink = nil; return true; cVaultLink->DecRef(); } return false; }
PyObject* pyVaultNode::GetCreatorNode( void ) { PyObject * result = nil; if (fNode) { RelVaultNode * templateNode = new RelVaultNode; templateNode->Ref(); templateNode->SetNodeType(plVault::kNodeType_PlayerInfo); VaultPlayerInfoNode plrInfo(templateNode); plrInfo.SetPlayerId(fNode->GetCreatorId()); if (RelVaultNode * rvn = VaultGetNodeIncRef(templateNode)) { result = pyVaultPlayerInfoNode::New(rvn); rvn->UnRef(); } templateNode->UnRef(); } if (result) return result; // just return a None object PYTHON_RETURN_NONE; }