From e65edca7069df81cc0c8811fb30709a754ae00c3 Mon Sep 17 00:00:00 2001 From: wolf6542 Date: Tue, 20 Jul 2021 23:05:44 +0300 Subject: [PATCH] Fix #323 --- src/cgame/cg_consolecmds.c | 1 + src/cgame/cg_ents.c | 3 +- src/cgame/cg_snapshot.c | 9 ++- src/game/bg_misc.c | 123 ++++++++++++++++++++++++++++++++++++- src/game/g_active.c | 12 ++-- src/game/g_client.c | 6 +- src/game/g_misc.c | 6 +- src/game/g_tramcar.c | 9 ++- 8 files changed, 153 insertions(+), 16 deletions(-) diff --git a/src/cgame/cg_consolecmds.c b/src/cgame/cg_consolecmds.c index 68b7b363..0406f541 100644 --- a/src/cgame/cg_consolecmds.c +++ b/src/cgame/cg_consolecmds.c @@ -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 diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c index b8fe5931..1171f901 100644 --- a/src/cgame/cg_ents.c +++ b/src/cgame/cg_ents.c @@ -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 diff --git a/src/cgame/cg_snapshot.c b/src/cgame/cg_snapshot.c index 5c6962fb..238cd252 100644 --- a/src/cgame/cg_snapshot.c +++ b/src/cgame/cg_snapshot.c @@ -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(); @@ -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++ ) { @@ -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 diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index c4880eb5..951db321 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -4084,7 +4084,7 @@ void BG_AddPredictableEventToPlayerstate( int newEvent, int eventParm, playerSta ps->eventSequence++; } - +#if 0 /* ======================== BG_PlayerStateToEntityState @@ -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 +} /* ======================== diff --git a/src/game/g_active.c b/src/game/g_active.c index 5ec4238f..771bb8cd 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -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 @@ -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 ); diff --git a/src/game/g_client.c b/src/game/g_client.c index 4e2105f8..677f7fd5 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -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 ); } @@ -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 ); diff --git a/src/game/g_misc.c b/src/game/g_misc.c index 98b5c12f..570190a3 100644 --- a/src/game/g_misc.c +++ b/src/game/g_misc.c @@ -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 ); @@ -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 ); diff --git a/src/game/g_tramcar.c b/src/game/g_tramcar.c index e4f10769..1c56b16d 100644 --- a/src/game/g_tramcar.c +++ b/src/game/g_tramcar.c @@ -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 ); @@ -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 ); @@ -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 );