Skip to content

Commit

Permalink
Fix #323 & deprecate g_smoothclients
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf6542 committed Sep 2, 2021
1 parent 343c14d commit 37182a4
Show file tree
Hide file tree
Showing 10 changed files with 169 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/cgame/cg_consolecmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,7 @@ void CG_InitConsoleCommands( void ) {
trap_AddCommand( "ref" );
trap_AddCommand("scs");
trap_AddCommand("specspeed");
trap_AddCommand("draw_hitboxes");
trap_AddCommand( "?" );
trap_AddCommand( "gib" ); // Kills player and sends him/her straight to limbo
trap_AddCommand( "pm" ); // Private message
Expand Down
3 changes: 2 additions & 1 deletion src/cgame/cg_ents.c
Original file line number Diff line number Diff line change
Expand Up @@ -2157,7 +2157,8 @@ void CG_AddPacketEntities( void ) {

// generate and add the entity from the playerstate
ps = &cg.predictedPlayerState;
BG_PlayerStateToEntityState( ps, &cg.predictedPlayerEntity.currentState, qfalse );
//BG_PlayerStateToEntityState( ps, &cg.predictedPlayerEntity.currentState, qfalse );
BG_PlayerStateToEntityStatePro(ps, &cg.predictedPlayerEntity.currentState, cg.time, qfalse); // RTCWPro
CG_AddCEntity( &cg.predictedPlayerEntity );

// lerp the non-predicted value for lightning gun origins
Expand Down
9 changes: 6 additions & 3 deletions src/cgame/cg_snapshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ void CG_SetInitialSnapshot( snapshot_t *snap ) {

cg.snap = snap;

BG_PlayerStateToEntityState( &snap->ps, &cg_entities[ snap->ps.clientNum ].currentState, qfalse );
//BG_PlayerStateToEntityState( &snap->ps, &cg_entities[ snap->ps.clientNum ].currentState, qfalse );
BG_PlayerStateToEntityStatePro(&snap->ps, &cg_entities[snap->ps.clientNum].currentState, cg.time, qfalse); // RTCWPro

// sort out solid entities
CG_BuildSolidList();
Expand Down Expand Up @@ -230,7 +231,8 @@ static void CG_TransitionSnapshot( void ) {
oldFrame = cg.snap;
cg.snap = cg.nextSnap;

BG_PlayerStateToEntityState( &cg.snap->ps, &cg_entities[ cg.snap->ps.clientNum ].currentState, qfalse );
//BG_PlayerStateToEntityState( &cg.snap->ps, &cg_entities[ cg.snap->ps.clientNum ].currentState, qfalse );
BG_PlayerStateToEntityStatePro(&cg.snap->ps, &cg_entities[cg.snap->ps.clientNum].currentState, cg.time, qfalse); // RTCWPro
cg_entities[ cg.snap->ps.clientNum ].interpolate = qfalse;

for ( i = 0 ; i < cg.snap->numEntities ; i++ ) {
Expand Down Expand Up @@ -276,7 +278,8 @@ static void CG_SetNextSnap( snapshot_t *snap ) {

cg.nextSnap = snap;

BG_PlayerStateToEntityState( &snap->ps, &cg_entities[ snap->ps.clientNum ].nextState, qfalse );
//BG_PlayerStateToEntityState( &snap->ps, &cg_entities[ snap->ps.clientNum ].nextState, qfalse );
BG_PlayerStateToEntityStatePro(&snap->ps, &cg_entities[snap->ps.clientNum].nextState, cg.time, qfalse); // RTCWPro
cg_entities[ cg.snap->ps.clientNum ].interpolate = qtrue;

// check for extrapolation errors
Expand Down
127 changes: 127 additions & 0 deletions src/game/bg_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4293,6 +4293,133 @@ void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s
s->aiState = ps->aiState;
}

/*
=====================
RTCWPro
Velocity & time
BG_PlayerStateToEntityStatePro
=====================
*/
void BG_PlayerStateToEntityStatePro(playerState_t* ps, entityState_t* s, int time, qboolean snap) {
int i;

if (ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPECTATOR) {
s->eType = ET_INVISIBLE;
}
else if (ps->stats[STAT_HEALTH] <= GIB_HEALTH)
{
s->eType = ET_INVISIBLE;
}
else
{
s->eType = ET_PLAYER;
}

s->number = ps->clientNum;
s->pos.trType = TR_INTERPOLATE;
s->pos.trTime = time; // help out new synced animations.

VectorCopy(ps->origin, s->pos.trBase);
if (snap)
{
SnapVector(s->pos.trBase);
}

// this wasn't in here?! Why!? It's in Quake 3
VectorCopy(ps->velocity, s->pos.trDelta);
if (snap)
{
SnapVector(s->pos.trDelta);
}

s->apos.trType = TR_INTERPOLATE;
VectorCopy(ps->viewangles, s->apos.trBase);
if (snap)
{
SnapVector(s->apos.trBase);
}

if (ps->movementDir > 128)
s->angles2[YAW] = (float)ps->movementDir - 256;
else
s->angles2[YAW] = ps->movementDir;

s->legsAnim = ps->legsAnim;
s->torsoAnim = ps->torsoAnim;
s->clientNum = ps->clientNum; // ET_PLAYER looks here instead of at number
// so corpses can also reference the proper config
// Ridah, let clients know if this person is using a mounted weapon
// so they don't show any client muzzle flashes

if (ps->persistant[PERS_HWEAPON_USE])
{
ps->eFlags |= EF_MG42_ACTIVE;
}
else
{
ps->eFlags &= ~EF_MG42_ACTIVE;
}

s->eFlags = ps->eFlags;

if (ps->stats[STAT_HEALTH] <= 0)
{
s->eFlags |= EF_DEAD;
}
else
{
s->eFlags &= ~EF_DEAD;
}

// from MP
if (ps->externalEvent) {
s->event = ps->externalEvent;
s->eventParm = ps->externalEventParm;
}
else if (ps->entityEventSequence < ps->eventSequence)
{
int seq;

if (ps->entityEventSequence < ps->eventSequence - MAX_EVENTS)
{
ps->entityEventSequence = ps->eventSequence - MAX_EVENTS;
}

seq = ps->entityEventSequence & (MAX_EVENTS - 1);
s->event = ps->events[seq] | ((ps->entityEventSequence & 3) << 8);
s->eventParm = ps->eventParms[seq];
ps->entityEventSequence++;
}
// end
// Ridah, now using a circular list of events for all entities
// add any new events that have been added to the playerState_t
// (possibly overwriting entityState_t events)
for (i = ps->oldEventSequence; i != ps->eventSequence; i++)
{
s->events[s->eventSequence & (MAX_EVENTS - 1)] = ps->events[i & (MAX_EVENTS - 1)];
s->eventParms[s->eventSequence & (MAX_EVENTS - 1)] = ps->eventParms[i & (MAX_EVENTS - 1)];
s->eventSequence++;
}
ps->oldEventSequence = ps->eventSequence;

s->weapon = ps->weapon;
s->groundEntityNum = ps->groundEntityNum;

s->powerups = 0;
for (i = 0; i < MAX_POWERUPS; i++)
{
if (ps->powerups[i]) {
s->powerups |= 1 << i;
}
}

s->aiChar = ps->aiChar; // Ridah
//s->loopSound = ps->loopSound;
s->teamNum = ps->teamNum;
s->aiState = ps->aiState; // xkan, 1/10/2003
}

//
// OSPx Stuff Below
//
Expand Down
1 change: 1 addition & 0 deletions src/game/bg_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,7 @@ void BG_AddPredictableEventToPlayerstate( int newEvent, int eventParm, player

void BG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean snap );
void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s, int time, qboolean snap );
void BG_PlayerStateToEntityStatePro(playerState_t* ps, entityState_t* s, int time, qboolean snap); // RTCWPro

qboolean BG_WeaponInWolfMP( int weapon );
qboolean BG_PlayerTouchesItem( playerState_t *ps, entityState_t *item, int atTime );
Expand Down
23 changes: 17 additions & 6 deletions src/game/g_active.c
Original file line number Diff line number Diff line change
Expand Up @@ -1244,11 +1244,14 @@ void ClientThink_real( gentity_t *ent ) {
// jpw

// sanity check the command time to prevent speedup cheating
if ( ucmd->serverTime > level.time + 200 ) {
if (ucmd->serverTime > level.time + 200)
{
ucmd->serverTime = level.time + 200;
// G_Printf("serverTime <<<<<\n" );
}
if ( ucmd->serverTime < level.time - 1000 ) {

if (ucmd->serverTime < level.time - 1000)
{
ucmd->serverTime = level.time - 1000;
// G_Printf("serverTime >>>>>\n" );
}
Expand Down Expand Up @@ -1607,12 +1610,16 @@ void ClientThink_real( gentity_t *ent ) {
ent->r.eventTime = level.time;
}

// RTCWPro
// Ridah, fixes jittery zombie movement
if ( g_smoothClients.integer ) {
/*if ( g_smoothClients.integer ) {
BG_PlayerStateToEntityStateExtraPolate( &ent->client->ps, &ent->s, ent->client->ps.commandTime, qtrue );
} else {
BG_PlayerStateToEntityState( &ent->client->ps, &ent->s, qtrue );
}
}*/

BG_PlayerStateToEntityStatePro(&ent->client->ps, &ent->s, ent->client->ps.commandTime, qtrue);
// RTCWPro end

if ( !( ent->client->ps.eFlags & EF_FIRING ) ) {
client->fireHeld = qfalse; // for grapple
Expand Down Expand Up @@ -2224,12 +2231,16 @@ void ClientEndFrame( gentity_t *ent ) {

// set the latest infor

// RTCWPro
// Ridah, fixes jittery zombie movement
if ( g_smoothClients.integer ) {
/*if ( g_smoothClients.integer ) {
BG_PlayerStateToEntityStateExtraPolate( &ent->client->ps, &ent->s, ent->client->ps.commandTime, ( ( ent->r.svFlags & SVF_CASTAI ) == 0 ) );
} else {
BG_PlayerStateToEntityState( &ent->client->ps, &ent->s, ( ( ent->r.svFlags & SVF_CASTAI ) == 0 ) );
}
}*/

BG_PlayerStateToEntityStatePro(&ent->client->ps, &ent->s, ent->client->ps.commandTime, qfalse);
// RTCWPro end

//SendPendingPredictableEvents( &ent->client->ps );

Expand Down
6 changes: 4 additions & 2 deletions src/game/g_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -2587,7 +2587,8 @@ void ClientSpawn( gentity_t *ent, qboolean revived ) {

// positively link the client, even if the command times are weird
if ( ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {
BG_PlayerStateToEntityState( &client->ps, &ent->s, qtrue );
//BG_PlayerStateToEntityState( &client->ps, &ent->s, qtrue );
BG_PlayerStateToEntityStatePro(&client->ps, &ent->s, level.time, qtrue); // RTCWPro
VectorCopy( ent->client->ps.origin, ent->r.currentOrigin );
trap_LinkEntity( ent );
}
Expand All @@ -2596,7 +2597,8 @@ void ClientSpawn( gentity_t *ent, qboolean revived ) {
ClientEndFrame( ent );

// clear entity state values
BG_PlayerStateToEntityState( &client->ps, &ent->s, qtrue );
//BG_PlayerStateToEntityState( &client->ps, &ent->s, qtrue );
BG_PlayerStateToEntityStatePro(&client->ps, &ent->s, level.time, qtrue); // RTCWPro

// show_bug.cgi?id=569
//G_ResetMarkers( ent );
Expand Down
2 changes: 1 addition & 1 deletion src/game/g_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ cvarTable_t gameCvarTable[] = {
{ &g_rankings, "g_rankings", "0", 0, 0, qfalse},
{ &g_userAim, "g_userAim", "1", CVAR_CHEAT, 0, qfalse },

{ &g_smoothClients, "g_smoothClients", "1", 0, 0, qfalse},
//{ &g_smoothClients, "g_smoothClients", "1", 0, 0, qfalse},
{ &pmove_fixed, "pmove_fixed", "0", CVAR_SYSTEMINFO, 0, qfalse},
{ &pmove_msec, "pmove_msec", "8", CVAR_SYSTEMINFO, 0, qfalse},

Expand Down
6 changes: 4 additions & 2 deletions src/game/g_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles ) {
}

// save results of pmove
BG_PlayerStateToEntityState( &player->client->ps, &player->s, qtrue );
//BG_PlayerStateToEntityState( &player->client->ps, &player->s, qtrue );
BG_PlayerStateToEntityStatePro(&player->client->ps, &player->s, level.time, qtrue); // RTCWPro

// use the precise origin for linking
VectorCopy( player->client->ps.origin, player->r.currentOrigin );
Expand Down Expand Up @@ -1708,7 +1709,8 @@ void clamp_playerbehindgun( gentity_t *self, gentity_t *other, vec3_t dang ) {
VectorCopy( point, other->client->ps.origin );

// save results of pmove
BG_PlayerStateToEntityState( &other->client->ps, &other->s, qfalse );
//BG_PlayerStateToEntityState( &other->client->ps, &other->s, qfalse );
BG_PlayerStateToEntityStatePro(&other->client->ps, &other->s, level.time, qfalse); // RTCWPro

// use the precise origin for linking
VectorCopy( other->client->ps.origin, other->r.currentOrigin );
Expand Down
9 changes: 6 additions & 3 deletions src/game/g_tramcar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,8 @@ void truck_cam_touch( gentity_t *self, gentity_t *other, trace_t *trace ) {
VectorCopy( point, other->client->ps.origin );

// save results of pmove
BG_PlayerStateToEntityState( &other->client->ps, &other->s, qtrue );
//BG_PlayerStateToEntityState( &other->client->ps, &other->s, qtrue );
BG_PlayerStateToEntityStatePro(&other->client->ps, &other->s, level.time, qtrue); // RTCWPro

// use the precise origin for linking
VectorCopy( other->client->ps.origin, other->r.currentOrigin );
Expand Down Expand Up @@ -1406,7 +1407,8 @@ void camera_cam_think( gentity_t *ent ) {
VectorCopy( point, player->client->ps.origin );

// save results of pmove
BG_PlayerStateToEntityState( &player->client->ps, &player->s, qtrue );
//BG_PlayerStateToEntityState( &player->client->ps, &player->s, qtrue );
BG_PlayerStateToEntityStatePro(&player->client->ps, &player->s, level.time, qtrue); // RTCWPro

// use the precise origin for linking
VectorCopy( player->client->ps.origin, player->r.currentOrigin );
Expand Down Expand Up @@ -1591,7 +1593,8 @@ void reset_players_pos( gentity_t *ent, gentity_t *other, gentity_t *activator )
VectorCopy( ent->s.origin2, player->client->ps.origin );

// save results of pmove
BG_PlayerStateToEntityState( &player->client->ps, &player->s, qtrue );
//BG_PlayerStateToEntityState( &player->client->ps, &player->s, qtrue );
BG_PlayerStateToEntityStatePro(&player->client->ps, &player->s, level.time, qtrue); // RTCWPro

// use the precise origin for linking
VectorCopy( player->client->ps.origin, player->r.currentOrigin );
Expand Down

0 comments on commit 37182a4

Please sign in to comment.