Raised This Month: $ Target: $400
 0% 

FM_AddToFullPack


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-18-2009 , 18:06   Re: FM_AddToFullPack
Reply With Quote #5

PHP Code:
/* 
AddToFullPack 

Return 1 if the entity state has been filled in for the ent and the entity will be propagated to the client, 0 otherwise 

state is the server maintained copy of the state info that is transmitted to the client 
a MOD could alter values copied into state to send the "host" a different look for a particular entity update, etc. 
e and ent are the entity that is being added to the update, if 1 is returned 
host is the player's edict of the player whom we are sending the update to 
player is 1 if the ent/e is a player and 0 otherwise 
pSet is either the PAS or PVS that we previous set up.  We can use it to ask the engine to filter the entity against the PAS or PVS. 
we could also use the pas/ pvs that we set in SetupVisibility, if we wanted to.  Caching the value is valid in that case, but still only for the current frame 
*/ 
int AddToFullPackstruct entity_state_s *stateint eedict_t *entedict_t *hostint hostflagsint playerunsigned char *pSet 

    
int                    i

    
// don't send if flagged for NODRAW and it's not the host getting the message 
    
if ( ( ent->v.effects == EF_NODRAW ) && 
         ( 
ent != host ) ) 
        return 
0

    
// Ignore ents without valid / visible models 
    
if ( !ent->v.modelindex || !STRINGent->v.model ) ) 
        return 
0

    
// Don't send spectators to other players 
    
if ( ( ent->v.flags FL_SPECTATOR ) && ( ent != host ) ) 
    { 
        return 
0
    } 

    
// Ignore if not the host and not touching a PVS/PAS leaf 
    // If pSet is NULL, then the test will always succeed and the entity will be added to the update 
    
if ( ent != host 
    { 
        if ( !
ENGINE_CHECK_VISIBILITY( (const struct edict_s *)entpSet ) ) 
        { 
            return 
0
        } 
    } 


    
// Don't send entity to local client if the client says it's predicting the entity itself. 
    
if ( ent->v.flags FL_SKIPLOCALHOST 
    { 
        if ( ( 
hostflags ) && ( ent->v.owner == host ) ) 
            return 
0
    } 
     
    if ( 
host->v.groupinfo 
    { 
        
UTIL_SetGroupTracehost->v.groupinfoGROUP_OP_AND ); 

        
// Should always be set, of course 
        
if ( ent->v.groupinfo 
        { 
            if ( 
g_groupop == GROUP_OP_AND 
            { 
                if ( !(
ent->v.groupinfo host->v.groupinfo ) ) 
                    return 
0
            } 
            else if ( 
g_groupop == GROUP_OP_NAND 
            { 
                if ( 
ent->v.groupinfo host->v.groupinfo 
                    return 
0
            } 
        } 

        
UTIL_UnsetGroupTrace(); 
    } 

    
memsetstate0sizeof( *state ) ); 

    
// Assign index so we can track this entity from frame to frame and 
    //  delta from it. 
    
state->number      e
    
state->entityType ENTITY_NORMAL
     
    
// Flag custom entities. 
    
if ( ent->v.flags FL_CUSTOMENTITY 
    { 
        
state->entityType ENTITY_BEAM
    } 

    
//  
    // Copy state data 
    // 

    // Round animtime to nearest millisecond 
    
state->animtime   = (int)(1000.0 ent->v.animtime ) / 1000.0

    
memcpystate->originent->v.originsizeof( float ) ); 
    
memcpystate->anglesent->v.anglessizeof( float ) ); 
    
memcpystate->minsent->v.minssizeof( float ) ); 
    
memcpystate->maxsent->v.maxssizeof( float ) ); 

    
memcpystate->startposent->v.startpossizeof( float ) ); 
    
memcpystate->endposent->v.endpossizeof( float ) ); 

    
state->impacttime ent->v.impacttime
    
state->starttime ent->v.starttime

    
state->modelindex ent->v.modelindex
         
    
state->frame      ent->v.frame

    
state->skin       ent->v.skin
    
state->effects    ent->v.effects

    
// This non-player entity is being moved by the game .dll and not the physics simulation system 
    //  make sure that we interpolate it's position on the client if it moves 
    
if ( !player && 
         
ent->v.animtime && 
         
ent->v.velocity] == &&  
         
ent->v.velocity] == &&  
         
ent->v.velocity] == 
    { 
        
state->eflags |= EFLAG_SLERP
    } 

    
state->scale      ent->v.scale
    
state->solid      ent->v.solid
    
state->colormap   ent->v.colormap

    
state->movetype   ent->v.movetype
    
state->sequence   ent->v.sequence
    
state->framerate  ent->v.framerate
    
state->body       ent->v.body

    for (
04i++) 
    { 
        
state->controller[i] = ent->v.controller[i]; 
    } 

    for (
02i++) 
    { 
        
state->blending[i]   = ent->v.blending[i]; 
    } 

    
state->rendermode    ent->v.rendermode
    
state->renderamt     ent->v.renderamt;  
    
state->renderfx      ent->v.renderfx
    
state->rendercolor.ent->v.rendercolor.x
    
state->rendercolor.ent->v.rendercolor.y
    
state->rendercolor.ent->v.rendercolor.z

    
state->aiment 0
    if ( 
ent->v.aiment 
    { 
        
state->aiment ENTINDEXent->v.aiment ); 
    } 

    
state->owner 0
    if ( 
ent->v.owner 
    { 
        
int owner ENTINDEXent->v.owner ); 
         
        
// Only care if owned by a player 
        
if ( owner >= && owner <= gpGlobals->maxClients 
        { 
            
state->owner owner;     
        } 
    } 

    
// HACK:  Somewhat... 
    // Class is overridden for non-players to signify a breakable glass object ( sort of a class? ) 
    
if ( !player 
    { 
        
state->playerclass  ent->v.playerclass
    } 

    
// Special stuff for players only 
    
if ( player 
    { 
        
memcpystate->basevelocityent->v.basevelocitysizeof( float ) ); 

        
state->weaponmodel  MODEL_INDEXSTRINGent->v.weaponmodel ) ); 
        
state->gaitsequence ent->v.gaitsequence
        
state->spectator ent->v.flags FL_SPECTATOR
        
state->friction     ent->v.friction

        
state->gravity      ent->v.gravity
//        state->team            = ent->v.team; 
//         
        
state->usehull      = ( ent->v.flags FL_DUCKING ) ? 0
        
state->health        ent->v.health
    } 

    return 
1

THis is a thing that I haven't seen it on the forums yet, anyway it is good.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode