Skip to content

Commit

Permalink
Fix #323
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf6542 committed Jul 20, 2021
1 parent f1df989 commit e65edca
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 16 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( "players" ); // Prints user info (IP, GUID, STATUS..)
trap_AddCommand( "ref" );
trap_AddCommand("scs");
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_PlayerStateToEntityState(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_PlayerStateToEntityState(&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_PlayerStateToEntityState(&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_PlayerStateToEntityState(&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
123 changes: 122 additions & 1 deletion src/game/bg_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4084,7 +4084,7 @@ void BG_AddPredictableEventToPlayerstate( int newEvent, int eventParm, playerSta
ps->eventSequence++;
}


#if 0
/*
========================
BG_PlayerStateToEntityState
Expand Down Expand Up @@ -4191,6 +4191,127 @@ void BG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean
s->teamNum = ps->teamNum;
s->aiState = ps->aiState;
}
#endif

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

if (ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPECTATOR) {// || ps->pm_flags & PMF_LIMBO ) { // JPW NERVE limbo
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
}

/*
========================
Expand Down
12 changes: 8 additions & 4 deletions src/game/g_active.c
Original file line number Diff line number Diff line change
Expand Up @@ -1591,11 +1591,13 @@ void ClientThink_real( gentity_t *ent ) {
}

// 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_PlayerStateToEntityState(&ent->client->ps, &ent->s, level.time, qtrue); // RTCWPro

if ( !( ent->client->ps.eFlags & EF_FIRING ) ) {
client->fireHeld = qfalse; // for grapple
Expand Down Expand Up @@ -2207,11 +2209,13 @@ void ClientEndFrame( gentity_t *ent ) {
// set the latest infor

// 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_PlayerStateToEntityState(&ent->client->ps, &ent->s, level.time, qfalse); // RTCWPro

//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 @@ -2510,7 +2510,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_PlayerStateToEntityState(&client->ps, &ent->s, level.time, qtrue); // RTCWPro
VectorCopy( ent->client->ps.origin, ent->r.currentOrigin );
trap_LinkEntity( ent );
}
Expand All @@ -2519,7 +2520,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_PlayerStateToEntityState(&client->ps, &ent->s, level.time, qtrue); // RTCWPro

// show_bug.cgi?id=569
//G_ResetMarkers( ent );
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_PlayerStateToEntityState(&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_PlayerStateToEntityState(&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_PlayerStateToEntityState(&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_PlayerStateToEntityState(&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_PlayerStateToEntityState(&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 e65edca

Please sign in to comment.