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.
This commit is contained in:
Marco Cawthorne 2022-01-31 17:38:01 -08:00
parent eb01a1d8d2
commit a3a5f9d626
Signed by: eukara
GPG Key ID: C196CD8BA993248A
9 changed files with 57 additions and 23 deletions

View File

@ -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;

View File

@ -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;
}

8
src/shared/client.h Normal file
View File

@ -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;
};

11
src/shared/client.qc Normal file
View File

@ -0,0 +1,11 @@
void
base_client::ClientInputFrame(void)
{
}
void
base_client::base_client(void)
{
}

View File

@ -23,6 +23,7 @@
#endif
#include "../gs-entbase/shared/baseentity.h"
#include "client.h"
#include "player.h"
#include "damage.h"
#include "flags.h"

View File

@ -1,4 +1,5 @@
#includelist
client.qc
spectator.qc
pmove.qc
pmove_custom.qc

View File

@ -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);

View File

@ -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

View File

@ -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