void plSceneInputInterface::ILinkOffereeToAge()
{
    // check vault to see if we've got an instance of the offered age now, if not create one and wait until we get a reply...
    plAgeInfoStruct info;
    info.SetAgeFilename(fOfferedAgeFile);
    info.SetAgeInstanceName(fOfferedAgeInstance);

    bool isAgeInstanceGuidSet = fAgeInstanceGuid.IsSet();
    
    plAgeLinkStruct link;
    
    if (isAgeInstanceGuidSet) {
        info.SetAgeInstanceGuid(&fAgeInstanceGuid);
        link.GetAgeInfo()->CopyFrom(&info);

        fAgeInstanceGuid.Clear();
    }
    else if (!VaultGetOwnedAgeLink(&info, &link)) {
    
        // We must have an owned copy of the age before we can offer it, so make one now
        plUUID guid(GuidGenerate());
        info.SetAgeInstanceGuid(&guid);
        std::string title;
        std::string desc;

        unsigned nameLen = plNetClientMgr::GetInstance()->GetPlayerName().GetSize();
        if (plNetClientMgr::GetInstance()->GetPlayerName().CharAt(nameLen - 1) == 's' || plNetClientMgr::GetInstance()->GetPlayerName().CharAt(nameLen - 1) == 'S') {
            xtl::format( title, "%s'", plNetClientMgr::GetInstance()->GetPlayerName().c_str() );
            xtl::format( desc, "%s' %s", plNetClientMgr::GetInstance()->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() );
        }
        else {
            xtl::format( title, "%s's", plNetClientMgr::GetInstance()->GetPlayerName().c_str() );
            xtl::format( desc, "%s's %s", plNetClientMgr::GetInstance()->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() );
        }

        info.SetAgeUserDefinedName( title.c_str() );
        info.SetAgeDescription( desc.c_str() );

        link.GetAgeInfo()->CopyFrom(&info);
        if (!VaultRegisterOwnedAgeAndWait(&link)) {
            // failed to become an owner of the age for some reason, offer cannot continue
            return;
        }
    }
    else if (RelVaultNode * linkNode = VaultGetOwnedAgeLinkIncRef(&info)) {
        // We have the age in our AgesIOwnFolder. If its volatile, dump it for the new one.
        VaultAgeLinkNode linkAcc(linkNode);
        if (linkAcc.volat) {
            if (VaultUnregisterOwnedAgeAndWait(link.GetAgeInfo())) {
                plUUID guid(GuidGenerate());
                link.GetAgeInfo()->SetAgeInstanceGuid(&guid);
                VaultRegisterOwnedAgeAndWait(&link);
            }
        }
        linkNode->DecRef();
    }

    if (fSpawnPoint) {
        plSpawnPointInfo spawnPoint;
        spawnPoint.SetName(fSpawnPoint);
        link.SetSpawnPoint(spawnPoint);
    }
    
            
    // We now own the age, offer it

    if (0 == stricmp(fOfferedAgeFile, kPersonalAgeFilename))
        plNetLinkingMgr::GetInstance()->OfferLinkToPlayer(&link, fOffereeID, fManager->GetKey());
    else
        plNetLinkingMgr::GetInstance()->LinkPlayerToAge(&link, fOffereeID);
        
    if (!fPendingLink && stricmp(fOfferedAgeFile, kPersonalAgeFilename))
    {   
        // tell our local dialog to pop up again...
        plKey avKey = plNetClientMgr::GetInstance()->GetLocalPlayerKey();
        ISendOfferNotification(avKey, 0, false);
        // make them clickable again(in case they come back?)
        //IManageIgnoredAvatars(fOffereeKey, false);
        
        fBookMode = kNotOffering;
        fOffereeKey = nil;
        fPendingLink = false;
    }
    else // this is a yeesha book link, must wait for multistage callbacks
    {
        // commented out until after 0.9
        fBookMode = kOfferLinkPending;
        fPendingLink = true;
//          fBookMode = kNotOffering;
//          fOffereeKey = nil;
//          fPendingLink = false;
//          ISendAvatarDisabledNotification(true);
    }
}
Esempio n. 2
0
void pyVault::RegisterOwnedAge( const pyAgeLinkStruct & link )
{
    VaultRegisterOwnedAgeAndWait(link.GetAgeLink());
}