Ejemplo n.º 1
0
// 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 );
    }
}
Ejemplo n.º 2
0
static void IAddPlayer_NodesFound(ENetError result, void* param, unsigned nodeIdCount, const unsigned nodeIds[])
{
    NetVaultNode* parent = static_cast<NetVaultNode*>(param);
    if (nodeIdCount)
        VaultAddChildNode(parent->GetNodeId(), nodeIds[0], VaultGetPlayerId(), nullptr, nullptr);
    parent->DecRef();
}
Ejemplo n.º 3
0
PyObject* pyVaultNode::AddNode(pyVaultNode* pynode, PyObject* cbObject, uint32_t cbContext)
{
    pyVaultNodeOperationCallback * cb = new pyVaultNodeOperationCallback(cbObject);

    if ( fNode && pynode && pynode->GetNode() )
    {
        // Hack the callbacks until vault notification is in place
        cb->VaultOperationStarted(cbContext);

        int hsResult = hsOK;
        if ( !pynode->GetID() )
        {
            // Block here until node is created and fetched =(
            ASSERT(pynode->GetNode()->GetNodeType());
            ENetError result;
            RelVaultNode * newNode = VaultCreateNodeAndWaitIncRef(
                pynode->GetNode(),
                &result
            );
            
            if (newNode) {
                newNode->Ref();
                pynode->fNode->UnRef();
                pynode->fNode = newNode;
            }
            else {
                hsResult = hsFail;
            }
        }

        PyObject* nodeRef = cb->fPyNodeRef = pyVaultNodeRef::New(fNode, pynode->fNode);
        Py_INCREF(nodeRef); // The callback steals the ref, according to Eric...
        cb->SetNode(pynode->fNode);

        VaultAddChildNode(fNode->GetNodeId(),
                          pynode->fNode->GetNodeId(),
                          NetCommGetPlayer()->playerInt,
                          (FVaultAddChildNodeCallback)_AddNodeCallback,
                          cb
        );

        // Evil undocumented functionality that some fool
        // decided to use in xKI.py. Really???
        return nodeRef;
    }
    else
    {
        // manually make the callback
        cb->VaultOperationStarted( cbContext );
        cb->VaultOperationComplete(hsFail);
    }

    // just return a None object
    PYTHON_RETURN_NONE;
}
Ejemplo n.º 4
0
void pyVaultPlayerInfoListNode::AddPlayer( uint32_t playerID )
{
    if (HasPlayer(playerID) || !fNode)
        return;

    NetVaultNode* templateNode = new NetVaultNode();
    templateNode->IncRef();
    templateNode->SetNodeType(plVault::kNodeType_PlayerInfo);
    VaultPlayerInfoNode access(templateNode);
    access.SetPlayerId(playerID);

    ARRAY(uint32_t) nodeIds;
    VaultLocalFindNodes(templateNode, &nodeIds);

    // So, if we know about this node, we can take it easy. If not, we lazy load it.
    if (nodeIds.Count())
        VaultAddChildNode(fNode->GetNodeId(), nodeIds[0], VaultGetPlayerId(), nullptr, nullptr);
    else {
        fNode->IncRef();
        VaultFindNodes(templateNode, IAddPlayer_NodesFound, fNode);
    }
}
Ejemplo n.º 5
0
void plNetLinkingMgr::IPostProcessLink( void )
{
    // Grab some useful things...
    plAgeLinkStruct* link = GetAgeLink();
    plAgeInfoStruct* info = link->GetAgeInfo();

    bool city = (info->GetAgeFilename().CompareI(kCityAgeFilename) == 0);
    bool hood = (info->GetAgeFilename().CompareI(kNeighborhoodAgeFilename) == 0);
    bool psnl = (info->GetAgeFilename().CompareI(kPersonalAgeFilename) == 0);

    // Update our online status 
    if (RelVaultNode* rvnInfo = VaultGetPlayerInfoNodeIncRef()) {
        VaultPlayerInfoNode accInfo(rvnInfo);
        wchar_t ageInstName[MAX_PATH];
        plUUID ageInstGuid = *info->GetAgeInstanceGuid();
        StrToUnicode(ageInstName, info->GetAgeInstanceName(), arrsize(ageInstName));
        accInfo.SetAgeInstName(ageInstName);
        accInfo.SetAgeInstUuid(ageInstGuid);
        accInfo.SetOnline(true);
        rvnInfo->DecRef();
    }
    
    switch (link->GetLinkingRules()) {

        case plNetCommon::LinkingRules::kOwnedBook: {
            // SPECIAL CASE: City: Every player ever created would be in the list; avoid that.
            if (city)
                break;
                
            {   // Ensure we're in the AgeOwners folder
                RelVaultNode* fldr = VaultGetAgeAgeOwnersFolderIncRef();
                RelVaultNode* info = VaultGetPlayerInfoNodeIncRef();
                
                if (fldr && info)
                    if (!fldr->IsParentOf(info->GetNodeId(), 1))
                        VaultAddChildNode(
                            fldr->GetNodeId(),
                            info->GetNodeId(),
                            NetCommGetPlayer()->playerInt,
                            nil,
                            nil
                        );
                
                if (fldr)
                    fldr->DecRef();
                if (info)
                    info->DecRef();
            }
        }
        break;  

        case plNetCommon::LinkingRules::kVisitBook: {
            // SPECIAL CASE: City: Every player ever created would be in the list; avoid that.
            if (city)
                break;
                
            {   // Ensure we're in the CanVisit folder
                RelVaultNode* fldr = VaultGetAgeCanVisitFolderIncRef();
                RelVaultNode* info = VaultGetPlayerInfoNodeIncRef();
                
                if (fldr && info)
                    if (!fldr->IsParentOf(info->GetNodeId(), 1))
                        VaultAddChildNode(
                            fldr->GetNodeId(),
                            info->GetNodeId(),
                            NetCommGetPlayer()->playerInt,
                            nil,
                            nil
                        );
                
                if (fldr)
                    fldr->DecRef();
                if (info)
                    info->DecRef();
            }
        }
        break;
        
        case plNetCommon::LinkingRules::kSubAgeBook: {
            // Register the previous age as a sub age of the current one so that we can link back to that instance
            plAgeLinkStruct subAgeLink;
            VaultAgeFindOrCreateSubAgeLink(GetPrevAgeLink()->GetAgeInfo(), &subAgeLink, NetCommGetAge()->ageInstId);
        }
        break;
    }
}