Client: Disable some expensive routines when paused.

This commit is contained in:
Marco Cawthorne 2022-07-18 10:02:04 -07:00
parent 0ae901f5e1
commit d7418151f0
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
8 changed files with 50 additions and 8 deletions

View File

@ -526,6 +526,9 @@ CSQC_Input_Frame(void)
{
entity me;
if (Util_IsPaused())
return;
CSQC_UpdateSeat();
me = pSeat->m_ePlayer;

View File

@ -26,6 +26,9 @@ Propagate our pmove state to whatever the current frame before its stomped on
void
Predict_EntityUpdate(player pl, float new)
{
if (Util_IsPaused())
return;
/* this is a new client entity, let's set it up right */
if (new || self.classname != "player") {
spawnfunc_player();

View File

@ -253,7 +253,7 @@ class NSMonster:NSNavAI
virtual int(void) AttackRanged;
virtual float(void) MeleeMaxDistance;
virtual int(void) MeleeCondition;
virtual bool(void) MeleeCondition;
virtual bool(entity enemy) IsValidEnemy;

View File

@ -140,10 +140,10 @@ NSMonster::MeleeMaxDistance(void)
}
/* Whether or not we should attempt a melee attack */
int
bool
NSMonster::MeleeCondition(void)
{
return (vlen(origin - m_eEnemy.origin) < MeleeMaxDistance()) ? TRUE : FALSE;
return (vlen(origin - m_eEnemy.origin) < MeleeMaxDistance()) ? true : false;
}
float

View File

@ -369,16 +369,29 @@ NSTalkMonster::TalkStopFollow(void)
void
NSTalkMonster::FollowPlayer(void)
{
float flPlayerDist;
input_angles = vectoangles(m_eFollowingChain.origin - origin);
input_angles[0] = 0;
input_angles[1] = Math_FixDelta(input_angles[1]);
input_angles[2] = 0;
/* for best results, we want to ignore the Z plane
this avoids the problem of a follower spinning
around when above/below you on a platform */
vector vecParent = m_eFollowingChain.origin;
vecParent[2] = origin[2];
flPlayerDist = vlen(vecParent - origin);
/* Give up after 1024 units */
if (vlen(m_eFollowingChain.origin - origin) > 1024) {
if (flPlayerDist > 1024) {
m_eFollowing = world;
} else if (vlen(m_eFollowingChain.origin - origin) > 64) {
input_movevalues[0] = GetChaseSpeed();
} else if (flPlayerDist > 64) {
/* if we're close enough, we ought to walk */
if (flPlayerDist > 256)
input_movevalues[0] = GetChaseSpeed();
else
input_movevalues[0] = GetWalkSpeed();
other = world;
traceline(origin, m_eFollowingChain.origin, MOVE_OTHERONLY, this);

View File

@ -48,6 +48,9 @@ void
NSClientPlayer::PreFrame(void)
{
#ifdef CLIENT
if (Util_IsPaused())
return;
/* this is where a game/mod would decide to add more prediction rollback
* information. */
PredictPreFrame();
@ -86,6 +89,9 @@ void
NSClientPlayer::PostFrame(void)
{
#ifdef CLIENT
if (Util_IsPaused())
return;
/* give the game/mod a chance to roll back its values too */
PredictPostFrame();
setorigin(this, origin); /* update bounds */
@ -101,7 +107,10 @@ NSClientPlayer::PostFrame(void)
void
NSClientPlayer::ClientInput(void)
{
{
if (Util_IsPaused())
return;
XR_InputFrame(this);
if (!Client_InIntermission() && IsFakeSpectator()) {
@ -174,7 +183,10 @@ This is basically CSQC_Input_Frame! So games can override this as they please.
*/
void
NSClientPlayer::ClientInputFrame(void)
{
{
if (Util_IsPaused())
return;
if (IsFakeSpectator()) {
NSClientSpectator::ClientInputFrame();
return;

View File

@ -120,6 +120,7 @@ Empty(void)
void Util_Destroy(void);
string Util_TimeToString(float fTime);
int Util_IsTeamplay(void);
bool Util_IsPaused(void);
__wrap void
dprint(string m)

View File

@ -14,6 +14,16 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
bool
Util_IsPaused(void)
{
#ifdef CLIENT
return serverkeyfloat(SERVERKEY_PAUSESTATE) == 1 ? true : false;
#else
return false;
#endif
}
void
Util_Destroy(void)
{