From a3a5f9d626685f93f4b75e050e6d736fa00f1604 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Mon, 31 Jan 2022 17:38:01 -0800 Subject: [PATCH] Client: Some fixes for handling player/spectator classes, both share now the same parent class on both client and server. Fix crash with spectators and input-frame overrides. Add 'additive' command to fontdefs. --- src/client/entry.qc | 13 ++----------- src/client/font.qc | 4 ++++ src/shared/client.h | 8 ++++++++ src/shared/client.qc | 11 +++++++++++ src/shared/defs.h | 1 + src/shared/include.src | 1 + src/shared/player.h | 2 +- src/shared/spectator.h | 14 +++++++------- src/shared/spectator.qc | 26 ++++++++++++++++++++++---- 9 files changed, 57 insertions(+), 23 deletions(-) create mode 100644 src/shared/client.h create mode 100644 src/shared/client.qc diff --git a/src/client/entry.qc b/src/client/entry.qc index 328e3bc9..581ffbf8 100644 --- a/src/client/entry.qc +++ b/src/client/entry.qc @@ -517,7 +517,7 @@ CSQC_Input_Frame(void) } else if (self.classname == "spectator") { spectator spec; spec = (spectator)pSeat->m_ePlayer; - pl.ClientInputFrame(); + spec.ClientInputFrame(); } } @@ -934,16 +934,7 @@ CSQC_Ent_Update(float new) pl.ReceiveEntity(new, a); break; case ENT_SPECTATOR: - spectator spec = (spectator)self; - if (new || self.classname != "spectator") { - spawnfunc_spectator(); - spec.classname = "spectator"; - spec.solid = SOLID_SLIDEBOX; - spec.drawmask = MASK_ENGINE; - spec.customphysics = Empty; - setsize(spec, [0,0,0], [0,0,0]); - } - spec.ReceiveEntity(new); + Spectator_ReadEntity(new); break; case ENT_SPRITE: env_sprite spr = (env_sprite)self; diff --git a/src/client/font.qc b/src/client/font.qc index 1eeb0675..80e58d26 100644 --- a/src/client/font.qc +++ b/src/client/font.qc @@ -66,6 +66,10 @@ Font_Load(string strFile, font_s &fntNew) case "flags": fntNew.iFlags = (int)stof(argv(1)); break; + case "additive": + if (stof(argv(1)) == 1) + fntNew.iFlags = DRAWFLAG_ADDITIVE; + break; default: break; } diff --git a/src/shared/client.h b/src/shared/client.h new file mode 100644 index 00000000..f55b2cb2 --- /dev/null +++ b/src/shared/client.h @@ -0,0 +1,8 @@ + +/* both base_player and base_spectator are based off this class */ +class +base_client:NSSurfacePropEntity +{ + void(void) base_client; + virtual void(void) ClientInputFrame; +}; diff --git a/src/shared/client.qc b/src/shared/client.qc new file mode 100644 index 00000000..c8480b9b --- /dev/null +++ b/src/shared/client.qc @@ -0,0 +1,11 @@ +void +base_client::ClientInputFrame(void) +{ + +} + +void +base_client::base_client(void) +{ + +} diff --git a/src/shared/defs.h b/src/shared/defs.h index 654f7f89..2ae32c38 100644 --- a/src/shared/defs.h +++ b/src/shared/defs.h @@ -23,6 +23,7 @@ #endif #include "../gs-entbase/shared/baseentity.h" +#include "client.h" #include "player.h" #include "damage.h" #include "flags.h" diff --git a/src/shared/include.src b/src/shared/include.src index 10bfbd53..5b2c96ae 100644 --- a/src/shared/include.src +++ b/src/shared/include.src @@ -1,4 +1,5 @@ #includelist +client.qc spectator.qc pmove.qc pmove_custom.qc diff --git a/src/shared/player.h b/src/shared/player.h index 49e6c6e8..03b90a52 100644 --- a/src/shared/player.h +++ b/src/shared/player.h @@ -29,7 +29,7 @@ #define VEC_CHANGED(x,y) (x ##_net[y] != x[y]) class -base_player:NSSurfacePropEntity +base_player:base_client { PREDICTED_FLOAT(health); PREDICTED_FLOAT(armor); diff --git a/src/shared/spectator.h b/src/shared/spectator.h index d4f01c63..42f827a6 100644 --- a/src/shared/spectator.h +++ b/src/shared/spectator.h @@ -15,11 +15,7 @@ typedef enum SPECMODE_OVERVIEW } spectatorMode_t; -#ifdef SERVER -class spectator:NSEntity -#else -class spectator -#endif +class spectator:base_client { vector origin_net; vector velocity_net; @@ -49,7 +45,11 @@ class spectator virtual void(void) RunClientCommand; #else virtual void(void) ClientInputFrame; - virtual void(float) ReceiveEntity; + virtual void(float,float) ReceiveEntity; virtual float(void) predraw; #endif -}; +}; + +#ifdef CLIENT +void Spectator_ReadEntity(float new); +#endif diff --git a/src/shared/spectator.qc b/src/shared/spectator.qc index b72c25ff..80f94bdc 100644 --- a/src/shared/spectator.qc +++ b/src/shared/spectator.qc @@ -101,9 +101,9 @@ spectator::ClientInputFrame(void) } void -spectator::ReceiveEntity(float new) +spectator::ReceiveEntity(float new, float fl) { - float fl; + if (new == FALSE) { /* Go through all the physics code between the last received frame * and the newest frame and keep the changes this time around instead @@ -132,8 +132,6 @@ spectator::ReceiveEntity(float new) /* seed for our prediction table */ sequence = servercommandframe; - fl = readfloat(); - if (fl & SPECFL_ORIGIN) { origin[0] = readcoord(); origin[1] = readcoord(); @@ -401,3 +399,23 @@ spectator::spectator(void) forceinfokey(this, "*spec", "1"); #endif } + +#ifdef CLIENT +void +Spectator_ReadEntity(float new) +{ + spectator spec = (spectator)self; + + if (new || self.classname != "spectator") { + spawnfunc_spectator(); + spec.classname = "spectator"; + spec.solid = SOLID_SLIDEBOX; + spec.drawmask = MASK_ENGINE; + spec.customphysics = Empty; + setsize(spec, [0,0,0], [0,0,0]); + } + + float flags = readfloat(); + spec.ReceiveEntity(new, flags); +} +#endif