737
737
static void CG_CalcEntityLerpPositions( centity_t *cent ) {
739
// if this player does not want to see extrapolated players
740
if ( !cg_smoothClients.integer ) {
741
// make sure the clients use TR_INTERPOLATE
742
if ( cent->currentState.number < MAX_CLIENTS ) {
743
cent->currentState.pos.trType = TR_INTERPOLATE;
744
cent->nextState.pos.trType = TR_INTERPOLATE;
739
//unlagged - projectile nudge
740
// this will be set to how far forward projectiles will be extrapolated
742
//unlagged - projectile nudge
744
//unlagged - smooth clients #2
745
// this is done server-side now - cg_smoothClients is undefined
746
// players will always be TR_INTERPOLATE
748
// if this player does not want to see extrapolated players
749
if ( !cg_smoothClients.integer ) {
750
// make sure the clients use TR_INTERPOLATE
751
if ( cent->currentState.number < MAX_CLIENTS ) {
752
cent->currentState.pos.trType = TR_INTERPOLATE;
753
cent->nextState.pos.trType = TR_INTERPOLATE;
757
//unlagged - smooth clients #2
748
759
if ( cent->interpolate && cent->currentState.pos.trType == TR_INTERPOLATE ) {
749
760
CG_InterpolateEntityPosition( cent );
761
// just use the current frame and evaluate as best we can
762
BG_EvaluateTrajectory( ¢->currentState.pos, cg.time, cent->lerpOrigin );
763
BG_EvaluateTrajectory( ¢->currentState.apos, cg.time, cent->lerpAngles );
772
//unlagged - timenudge extrapolation
773
// interpolating failed (probably no nextSnap), so extrapolate
774
// this can also happen if the teleport bit is flipped, but that
775
// won't be noticeable
776
if ( cent->currentState.number < MAX_CLIENTS &&
777
cent->currentState.clientNum != cg.predictedPlayerState.clientNum ) {
778
cent->currentState.pos.trType = TR_LINEAR_STOP;
779
cent->currentState.pos.trTime = cg.snap->serverTime;
780
cent->currentState.pos.trDuration = 1000 / sv_fps.integer;
782
//unlagged - timenudge extrapolation
784
//unlagged - projectile nudge
785
// if it's a missile but not a grappling hook
786
if ( cent->currentState.eType == ET_MISSILE && cent->currentState.weapon != WP_GRAPPLING_HOOK ) {
787
// if it's one of ours
788
if ( cent->currentState.otherEntityNum == cg.clientNum ) {
789
// extrapolate one server frame's worth - this will correct for tiny
790
// visual inconsistencies introduced by backward-reconciling all players
791
// one server frame before running projectiles
792
timeshift = 1000 / sv_fps.integer;
794
// if it's not, and it's not a grenade launcher
795
else if ( cent->currentState.weapon != WP_GRENADE_LAUNCHER ) {
796
// extrapolate based on cg_projectileNudge
797
timeshift = cg_projectileNudge.integer + 1000 / sv_fps.integer;
801
// just use the current frame and evaluate as best we can
802
// BG_EvaluateTrajectory( ¢->currentState.pos, cg.time, cent->lerpOrigin );
803
// BG_EvaluateTrajectory( ¢->currentState.apos, cg.time, cent->lerpAngles );
804
BG_EvaluateTrajectory( ¢->currentState.pos, cg.time + timeshift, cent->lerpOrigin );
805
BG_EvaluateTrajectory( ¢->currentState.apos, cg.time + timeshift, cent->lerpAngles );
807
// if there's a time shift
808
if ( timeshift != 0 ) {
812
BG_EvaluateTrajectory( ¢->currentState.pos, cg.time, lastOrigin );
814
CG_Trace( &tr, lastOrigin, vec3_origin, vec3_origin, cent->lerpOrigin, cent->currentState.number, MASK_SHOT );
816
// don't let the projectile go through the floor
817
if ( tr.fraction < 1.0f ) {
818
cent->lerpOrigin[0] = lastOrigin[0] + tr.fraction * ( cent->lerpOrigin[0] - lastOrigin[0] );
819
cent->lerpOrigin[1] = lastOrigin[1] + tr.fraction * ( cent->lerpOrigin[1] - lastOrigin[1] );
820
cent->lerpOrigin[2] = lastOrigin[2] + tr.fraction * ( cent->lerpOrigin[2] - lastOrigin[2] );
823
//unlagged - projectile nudge
765
825
// adjust for riding a mover if it wasn't rolled into the predicted
1028
1088
// lerp the non-predicted value for lightning gun origins
1029
1089
CG_CalcEntityLerpPositions( &cg_entities[ cg.snap->ps.clientNum ] );
1091
//unlagged - early transitioning
1092
if ( cg.nextSnap ) {
1093
// pre-add some of the entities sent over by the server
1094
// we have data for them and they don't need to interpolate
1095
for ( num = 0 ; num < cg.nextSnap->numEntities ; num++ ) {
1096
cent = &cg_entities[ cg.nextSnap->entities[ num ].number ];
1097
if ( cent->nextState.eType == ET_MISSILE || cent->nextState.eType == ET_GENERAL ) {
1098
// transition it immediately and add it
1099
CG_TransitionEntity( cent );
1100
cent->interpolate = qtrue;
1101
CG_AddCEntity( cent );
1105
//unlagged - early transitioning
1031
1107
// add each entity sent over by the server
1032
1108
for ( num = 0 ; num < cg.snap->numEntities ; num++ ) {
1033
1109
cent = &cg_entities[ cg.snap->entities[ num ].number ];
1034
CG_AddCEntity( cent );
1110
//unlagged - early transitioning
1111
if ( !cg.nextSnap || (cent->nextState.eType != ET_MISSILE && cent->nextState.eType != ET_GENERAL) ) {
1112
//unlagged - early transitioning
1113
CG_AddCEntity( cent );