Exemplo n.º 1
0
void plSimulationMgr::UpdateDetectorsInScene(plKey world, plKey avatar, hsPoint3& pos, bool entering)
{
    // search thru the actors in a scene looking for convex hull detectors and see if the avatar is inside it
    // ... and then send appropiate collision message if needed
    NxScene* scene = GetScene(world);
    plSceneObject* avObj = plSceneObject::ConvertNoRef(avatar->ObjectIsLoaded());
    const plCoordinateInterface* ci = avObj->GetCoordinateInterface();
    hsPoint3 soPos = ci->GetWorldPos();
    if (scene)
    {
        uint32_t numActors = scene->getNbActors();
        NxActor** actors = scene->getActors();

        for (int i = 0; i < numActors; i++)
        {
            plPXPhysical* physical = (plPXPhysical*)actors[i]->userData;
            if (physical && physical->DoDetectorHullWorkaround())
            {
                if ( physical->IsObjectInsideHull(pos) )
                {
                    physical->SetInsideConvexHull(entering);
                    // we are entering this world... say we entered this detector
                    ISendCollisionMsg(physical->GetObjectKey(), avatar, entering);
                }
            }
        }
    }
}
Exemplo n.º 2
0
bool plPluginResManager::NukeKeyAndObject(plKey& objectKey)
{
    class plPublicRefKey : public plKeyImp
    {
    public:
        uint16_t GetRefCount() const { return fRefCount; }
    };

    plKeyImp* keyData = (plKeyImp*)objectKey;

    // Check the ref count on the object. Nobody should have a ref to it
    // except the key
    hsKeyedObject* object = objectKey->ObjectIsLoaded();
    if (object != nil)
    {
        if (keyData->GetActiveRefs())
            // Somebody still has a ref to this object, so we can't nuke it
            return false;
    }

    // Nobody has a ref to the object, so we're clear to nuke
    keyData->SetObjectPtr(nil);

    // Check the key. The refcount should be 1 at this point, for the copy
    // we're holding in this function. Nobody else should be holding the key
    // now that the object is gone.
    if (((plPublicRefKey*)keyData)->GetRefCount() > 1)
        return false;

    // Nuke out the key as well
    objectKey = nil;

    // All done!
    return true;
}
Exemplo n.º 3
0
 virtual bool EatKey(const plKey& key)
 {
     plBitmap* bmap = plBitmap::ConvertNoRef(key->ObjectIsLoaded());
     if (bmap != nil)
         fTELog->AddTexture(bmap);
     return true;    // Always continue
 }
Exemplo n.º 4
0
//
// a remote ccr is turning [in]visible
//
void plNetClientMgr::MakeCCRInvisible(plKey avKey, int level)
{
    if (!avKey)
    {
        ErrorMsg("Failed to make remote CCR Invisible, nil avatar key");
        return;
    }
        
    if (level<0)
    {
        ErrorMsg("Failed to make remote CCR Invisible, negative level");
        return;
    }
    
    if (!avKey->ObjectIsLoaded() || !avKey->ObjectIsLoaded()->IsFinal())
    {
        hsAssert(false, "avatar not loaded or final");
        return;
    }
    
    plAvatarStealthModeMsg *msg = new plAvatarStealthModeMsg();
    msg->SetSender(avKey);
    msg->fLevel = level;

    if (GetCCRLevel()<level)    // I'm a lower level than him, so he's invisible to me
        msg->fMode = plAvatarStealthModeMsg::kStealthCloaked;       
    else
    {
        // he's visible to me
        if (AmCCR() && level > 0)
            msg->fMode = plAvatarStealthModeMsg::kStealthCloakedButSeen;    // draw as semi-invis
        else
            msg->fMode = plAvatarStealthModeMsg::kStealthVisible;
    }

    DebugMsg("Handled MakeCCRInvisible - sending stealth msg");;

    // This fxn is called when avatar SDL state is received from the server,
    // so this msg will inherit the 'non-local' status of the parent sdl msg.
    // That means that the avatar linkSound won't receive it, since the linkSound
    // is set as localOnly.
    // So, terminate the remote cascade and start a new (local) cascade.
    msg->SetBCastFlag(plMessage::kNetStartCascade); 
    
    msg->Send();
}
Exemplo n.º 5
0
 virtual bool EatKey(const plKey& key)
 {
     if (key->GetUoid().GetClassType() == plSceneNode::Index())
     {
         plSceneNode* sn = plSceneNode::ConvertNoRef(key->ObjectIsLoaded());
         if (sn != nil)
             sn->OptimizeDrawables();
     }
     return true;    // Always continue
 }
Exemplo n.º 6
0
void plAvTaskSeek::SetTarget(plKey target)
{
    hsAssert(target, "Bad key to seek task");
    if(target)
    {
        fSeekObject = plSceneObject::ConvertNoRef(target->ObjectIsLoaded());
    }
    else
    {
        fSeekObject = nil;
    }
}
Exemplo n.º 7
0
//
// write to net msg and send to server
//
void plSDLModifier::ISendNetMsg(plStateDataRecord*& state, plKey senderKey, uint32_t sendFlags)
{
    hsAssert(senderKey, "nil senderKey?");

    plSynchedObject* sobj = plSynchedObject::ConvertNoRef(senderKey->ObjectIsLoaded());
    if (sobj && (sobj->IsInSDLVolatileList(GetSDLName())))
        state->SetFlags(state->GetFlags() | plStateDataRecord::kVolatile);

    bool dirtyOnly = (sendFlags & plSynchedObject::kForceFullSend) == 0;
    bool broadcast = (sendFlags & plSynchedObject::kBCastToClients) != 0;
    int writeOptions=0;

//  if (dirtyOnly)
        writeOptions |= plSDL::kDirtyOnly;
    if (broadcast)
        writeOptions |= plSDL::kBroadcast;

    writeOptions |= plSDL::kTimeStampOnRead;


    // send to server
    plNetMsgSDLState* msg = state->PrepNetMsg(0, writeOptions);
    msg->SetNetProtocol(kNetProtocolCli2Game);
    msg->ObjectInfo()->SetUoid(senderKey->GetUoid());

    if (sendFlags & plSynchedObject::kNewState)
        msg->SetBit(plNetMessage::kNewSDLState);

    if (sendFlags & plSynchedObject::kUseRelevanceRegions)
        msg->SetBit(plNetMessage::kUseRelevanceRegions);

    if (sendFlags & plSynchedObject::kDontPersistOnServer)
        msg->SetPersistOnServer(false);

    if (sendFlags & plSynchedObject::kIsAvatarState)
        msg->SetIsAvatarState(true);

    if (broadcast && plNetClientApp::GetInstance())
    {
        msg->SetPlayerID(plNetClientApp::GetInstance()->GetPlayerID());
    }

    plNetClientApp::GetInstance()->SendMsg(msg);
    msg->UnRef();

    fSentOrRecvdState = true;
}
Exemplo n.º 8
0
void plWinAudible::SetSceneObject(plKey obj)
{
    plKey oldKey = nil;
    // remove old SDL mod
    if (fSDLMod && fSceneObj && fSceneObj != obj)
    {
        oldKey = fSceneObj;
        plSceneObject* so=plSceneObject::ConvertNoRef(fSceneObj->ObjectIsLoaded());
        if (so)
            so->RemoveModifier(fSDLMod);
        delete fSDLMod;
        fSDLMod=nil;
    }

    fSceneObj = obj;
    plSceneObject* so=plSceneObject::ConvertNoRef(obj ? obj->ObjectIsLoaded() : nil);
    if (so)
    {
        so->RemoveModifier(fSDLMod);        
        delete fSDLMod;
        fSDLMod=new plSoundSDLModifier;
        so->AddModifier(fSDLMod);
    }

    for( int i = 0; i < fSoundObjs.Count(); i++ )
    {                                   
        if( fSoundObjs[ i ] != nil && fSoundObjs[ i ]->GetKey() != nil )        
        {
            if( obj != nil )
            {
                plGenRefMsg *replaceMsg = new plGenRefMsg( fSoundObjs[ i ]->GetKey(), plRefMsg::kOnReplace, 0, plSound::kRefParentSceneObject );
                hsgResMgr::ResMgr()->AddViaNotify( obj, replaceMsg, plRefFlags::kPassiveRef );
            }
            else if( oldKey != nil )
                fSoundObjs[ i ]->GetKey()->Release( oldKey );
        }
    }                                       
}
Exemplo n.º 9
0
bool    plCommonObjLib::RemoveObjectAndKey( plKey &key )
{
    if (!key)
    {
        hsAssert( false, "Received RemoveObjectAndKey() call for a key that is invalid. Nillifying key anyway." );
        key = nil;
        return true;
    }
    hsKeyedObject *object = hsKeyedObject::ConvertNoRef( key->ObjectIsLoaded() );
    if( object == nil )
    {
        hsAssert( false, "Received RemoveObjectAndKey() call for a key that isn't loaded. Nillifying key anyway." );
        key = nil;
        return true;
    }

    int idx = fObjects.Find( object );
    if( idx == fObjects.kMissingIndex )
    {
        hsAssert( false, "Trying to RemoveObjectAndKey() for a common object not in the lib." );
        key = nil;
        return true;
    }

    // Unref and remove from our list
    fObjects[ idx ]->GetKey()->UnRefObject();
    fObjects.Remove( idx );

    // Nuke out the key and its object
    if( !plPluginResManager::ResMgr()->NukeKeyAndObject( key ) )
    {
        hsAssert( false, "Trouble nuking out the key for this texture. Problems abound...." );
        return false;
    }

    // All done!
    return true;
}