MCPcopy Create free account
hub / github.com/JACoders/OpenJK / PlayerStateToEntityState

Function PlayerStateToEntityState

code/game/bg_misc.cpp:613–705  ·  view source on GitHub ↗

======================== PlayerStateToEntityState This is done after each set of usercmd_t on the server, and after local prediction on the client ======================== */

Source from the content-addressed store, hash-verified

611========================
612*/
613void PlayerStateToEntityState( playerState_t *ps, entityState_t *s )
614{
615 int i;
616
617 if ( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPECTATOR )
618 {
619 s->eType = ET_INVISIBLE;
620 }
621 /*else if ( ps->stats[STAT_HEALTH] <= GIB_HEALTH )
622 {
623 s->eType = ET_INVISIBLE;
624 } */
625 else
626 {
627 s->eType = ET_PLAYER;
628 }
629
630 s->number = ps->clientNum;
631
632 s->pos.trType = TR_INTERPOLATE;
633 VectorCopy( ps->origin, s->pos.trBase );
634 //SnapVector( s->pos.trBase );
635
636 s->apos.trType = TR_INTERPOLATE;
637 VectorCopy( ps->viewangles, s->apos.trBase );
638 //SnapVector( s->apos.trBase );
639
640 s->angles2[YAW] = ps->movementDir;
641 s->legsAnim = ps->legsAnim;
642 s->torsoAnim = ps->torsoAnim;
643 s->clientNum = ps->clientNum; // ET_PLAYER looks here instead of at number
644 // so corpses can also reference the proper config
645 s->eFlags = ps->eFlags;
646
647 // new sabre stuff
648 s->saberActive = ps->SaberActive();//WHY is this on the entityState_t, too???
649 s->saberInFlight = ps->saberInFlight;
650
651 // NOTE: Although we store this stuff locally on a vehicle, who's to say we
652 // can't bring back these variables and fill them at the appropriate time? -Aurelio
653 // We need to bring these in from the vehicle NPC.
654 if ( g_entities[ps->clientNum].client && g_entities[ps->clientNum].client->NPC_class == CLASS_VEHICLE && g_entities[ps->clientNum].NPC )
655 {
656 Vehicle_t *pVeh = g_entities[ps->clientNum].m_pVehicle;
657 s->vehicleArmor = pVeh->m_iArmor;
658 VectorCopy( pVeh->m_vOrientation, s->vehicleAngles );
659 }
660
661 s->weapon = ps->weapon;
662 s->groundEntityNum = ps->groundEntityNum;
663
664 s->powerups = 0;
665 for ( i = 0 ; i < MAX_POWERUPS ; i++ ) {
666 if ( ps->powerups[ i ] ) {
667 s->powerups |= 1 << i;
668 }
669 }
670#if 0

Callers 5

ClientSpawnFunction · 0.70
TeleportPlayerFunction · 0.70
NPC_ApplyRoffFunction · 0.70
ClientThink_realFunction · 0.70
CG_AddPacketEntitiesFunction · 0.50

Calls 4

VectorCopyFunction · 0.85
AngleVectorsFunction · 0.85
DotProductFunction · 0.85
SaberActiveMethod · 0.80

Tested by

no test coverage detected