Separate networking between CBaseEntity and CBaseMonster, needs

cleaning.
This commit is contained in:
Marco Cawthorne 2021-09-12 00:13:24 +02:00
parent 10b2ff1fca
commit f884b3d35d
Signed by: eukara
GPG key ID: C196CD8BA993248A
8 changed files with 287 additions and 6 deletions

View file

@ -933,6 +933,9 @@ CSQC_Ent_Update(float new)
}
me.ReceiveEntity(readfloat());
break;
case ENT_MONSTER:
basemonster_readentity(new);
break;
case ENT_VEHICLE:
basevehicle_readentity(new);
break;

View file

@ -9,6 +9,7 @@ materials.h
client/defs.h
client/basefx.qc
shared/baseentity.qc
client/basemonster.qc
shared/basevehicle.qc
client/env_cubemap.qc
client/env_glow.qc

View file

@ -0,0 +1,144 @@
class
CBaseMonster:CBaseEntity
{
void(void) CBaseMonster;
virtual void(void) customphysics;
virtual float(void) predraw;
};
void
CBaseMonster::customphysics(void)
{
/* Page intentionally left blank */
}
float
CBaseMonster::predraw(void)
{
float render;
render = CBaseEntity::predraw();
/* mouth flapping action */
bonecontrol5 = getchannellevel(this, CHAN_VOICE) * 20;
m_flBaseTime = frame1time;
ProcessWordQue();
return render;
}
/*
============
CBaseMonster::ReceiveEntity
============
*/
void
CBaseMonster::ReceiveEntity(float flChanged)
{
if (flChanged & BASEFL_CHANGED_ORIGIN) {
origin[0] = readcoord();
origin[1] = readcoord();
origin[2] = readcoord();
}
if (flChanged & BASEFL_CHANGED_ANGLES) {
angles[0] = readshort() / (32767 / 360);
angles[1] = readshort() / (32767 / 360);
angles[2] = readshort() / (32767 / 360);
}
if (flChanged & BASEFL_CHANGED_MODELINDEX) {
setmodelindex(this, readshort());
}
if (flChanged & BASEFL_CHANGED_SOLID) {
solid = readbyte();
}
if (flChanged & BASEFL_CHANGED_MOVETYPE) {
movetype = readbyte();
if (movetype == MOVETYPE_PHYSICS) {
movetype = MOVETYPE_NONE;
}
}
if (flChanged & BASEFL_CHANGED_SIZE) {
mins[0] = readcoord();
mins[1] = readcoord();
mins[2] = readcoord();
maxs[0] = readcoord();
maxs[1] = readcoord();
maxs[2] = readcoord();
setsize(this, mins, maxs);
}
if (flChanged & BASEFL_CHANGED_FRAME) {
frame1time = 0.0;
frame2time = 0.0f;
frame = readbyte();
}
if (flChanged & BASEFL_CHANGED_SKIN) {
skin = readbyte() - 128;
}
if (flChanged & BASEFL_CHANGED_EFFECTS) {
effects = readfloat();
}
if (flChanged & BASEFL_CHANGED_BODY) {
m_iBody = readbyte();
setcustomskin(this, "", sprintf("geomset 1 %i\n", m_iBody));
}
if (flChanged & BASEFL_CHANGED_SCALE) {
scale = readfloat();
}
if (flChanged & BASEFL_CHANGED_VELOCITY) {
velocity[0] = readfloat();
velocity[1] = readfloat();
velocity[2] = readfloat();
}
#ifdef GS_RENDERFX
if (flChanged & BASEFL_CHANGED_RENDERFX) {
m_iRenderFX = readbyte();
}
if (flChanged & BASEFL_CHANGED_RENDERMODE) {
m_iRenderMode = readbyte();
}
if (flChanged & BASEFL_CHANGED_RENDERCOLOR) {
m_vecRenderColor[0] = readfloat();
m_vecRenderColor[1] = readfloat();
m_vecRenderColor[2] = readfloat();
}
if (flChanged & BASEFL_CHANGED_RENDERAMT) {
m_flRenderAmt = readfloat();
}
#else
if (flChanged & BASEFL_CHANGED_ALPHA) {
alpha = readfloat();
}
#endif
if (modelindex) {
drawmask = MASK_ENGINE;
} else {
drawmask = 0;
}
if (scale == 0.0)
scale = 1.0f;
setorigin(this, origin);
}
void
CBaseMonster::CBaseMonster(void)
{
CBaseEntity::CBaseEntity();
};
void
basemonster_readentity(float new)
{
CBaseMonster me = (CBaseMonster)self;
if (new) {
spawnfunc_CBaseMonster();
}
me.ReceiveEntity(readfloat());
}

View file

@ -169,4 +169,6 @@ class CBaseMonster:CBaseEntity
virtual int(void) AnimWalk;
virtual int(void) AnimRun;
virtual void(float) AnimPlay;
virtual float(entity, float) SendEntity;
};

View file

@ -572,6 +572,141 @@ CBaseMonster::SpawnKey(string strKey, string strValue)
}
}
/* Make sure StartFrame calls this */
float
CBaseMonster::SendEntity(entity ePEnt, float fChanged)
{
if (!modelindex)
return (0);
if (clienttype(ePEnt) != CLIENTTYPE_REAL)
return (0);
WriteByte(MSG_ENTITY, ENT_MONSTER);
/* newly popped into the PVS, sadly this is the only hacky way to check
* for this right now. convince the engine maintainer to make this more sensible */
if (fChanged == 0xFFFFFF) {
/* check for defaults. if these are predictable fields, don't even bother
* networking them! you're just wasting bandwidth. */
if (frame == 0)
fChanged &= ~BASEFL_CHANGED_FRAME;
if (skin == 0)
fChanged &= ~BASEFL_CHANGED_SKIN;
if (effects == 0)
fChanged &= ~BASEFL_CHANGED_EFFECTS;
if (m_iBody == 0)
fChanged &= ~BASEFL_CHANGED_BODY;
if (scale == 0.0 || scale == 1.0)
fChanged &= ~BASEFL_CHANGED_SCALE;
if (origin == [0,0,0])
fChanged &= ~BASEFL_CHANGED_ORIGIN;
if (angles == [0,0,0])
fChanged &= ~BASEFL_CHANGED_ANGLES;
if (velocity == [0,0,0])
fChanged &= ~BASEFL_CHANGED_VELOCITY;
if (mins == [0,0,0] && maxs == [0,0,0])
fChanged &= ~BASEFL_CHANGED_SIZE;
if (solid == SOLID_NOT)
fChanged &= ~BASEFL_CHANGED_SOLID;
if (movetype == MOVETYPE_NONE)
fChanged &= ~BASEFL_CHANGED_MOVETYPE;
#ifdef GS_RENDERFX
if (m_iRenderMode == RM_NORMAL)
fChanged &= ~BASEFL_CHANGED_RENDERMODE;
#endif
}
/* don't network triggers unless provoked */
/*if (cvar("developer") == 0 && m_iRenderMode == RM_TRIGGER)
return (0);*/
#ifdef GS_RENDERFX
/* let's not waste networking power on certain render-modes where they would
* not apply anyway. this seems sensible enough. */
if (m_iRenderMode == RM_NORMAL || m_iRenderMode == RM_TRIGGER) {
fChanged &= ~BASEFL_CHANGED_RENDERCOLOR;
fChanged &= ~BASEFL_CHANGED_RENDERAMT;
}
#endif
/* broadcast how much data is expected to be read */
WriteFloat(MSG_ENTITY, fChanged);
/* really trying to get our moneys worth with 23 bits of mantissa */
if (fChanged & BASEFL_CHANGED_ORIGIN) {
WriteCoord(MSG_ENTITY, origin[0]);
WriteCoord(MSG_ENTITY, origin[1]);
WriteCoord(MSG_ENTITY, origin[2]);
}
if (fChanged & BASEFL_CHANGED_ANGLES) {
WriteShort(MSG_ENTITY, angles[0] * 32767 / 360);
WriteShort(MSG_ENTITY, angles[1] * 32767 / 360);
WriteShort(MSG_ENTITY, angles[2] * 32767 / 360);
}
if (fChanged & BASEFL_CHANGED_MODELINDEX) {
WriteShort(MSG_ENTITY, modelindex);
}
if (fChanged & BASEFL_CHANGED_SOLID) {
WriteByte(MSG_ENTITY, solid);
}
if (fChanged & BASEFL_CHANGED_MOVETYPE) {
WriteByte(MSG_ENTITY, movetype);
}
if (fChanged & BASEFL_CHANGED_SIZE) {
WriteCoord(MSG_ENTITY, mins[0]);
WriteCoord(MSG_ENTITY, mins[1]);
WriteCoord(MSG_ENTITY, mins[2]);
WriteCoord(MSG_ENTITY, maxs[0]);
WriteCoord(MSG_ENTITY, maxs[1]);
WriteCoord(MSG_ENTITY, maxs[2]);
}
if (fChanged & BASEFL_CHANGED_FRAME) {
WriteByte(MSG_ENTITY, frame);
}
if (fChanged & BASEFL_CHANGED_SKIN) {
WriteByte(MSG_ENTITY, skin + 128);
}
if (fChanged & BASEFL_CHANGED_EFFECTS) {
WriteFloat(MSG_ENTITY, effects);
}
if (fChanged & BASEFL_CHANGED_BODY) {
WriteByte(MSG_ENTITY, m_iBody);
}
if (fChanged & BASEFL_CHANGED_SCALE) {
WriteFloat(MSG_ENTITY, scale);
}
if (fChanged & BASEFL_CHANGED_VELOCITY) {
WriteFloat(MSG_ENTITY, velocity[0]);
WriteFloat(MSG_ENTITY, velocity[1]);
WriteFloat(MSG_ENTITY, velocity[2]);
}
#ifdef GS_RENDERFX
if (fChanged & BASEFL_CHANGED_RENDERFX) {
WriteByte(MSG_ENTITY, m_iRenderFX);
}
if (fChanged & BASEFL_CHANGED_RENDERMODE) {
WriteByte(MSG_ENTITY, m_iRenderMode);
}
if (fChanged & BASEFL_CHANGED_RENDERCOLOR) {
WriteFloat(MSG_ENTITY, m_vecRenderColor[0]);
WriteFloat(MSG_ENTITY, m_vecRenderColor[1]);
WriteFloat(MSG_ENTITY, m_vecRenderColor[2]);
}
if (fChanged & BASEFL_CHANGED_RENDERAMT) {
WriteFloat(MSG_ENTITY, m_flRenderAmt);
}
#else
if (fChanged & BASEFL_CHANGED_ALPHA) {
WriteFloat(MSG_ENTITY, alpha);
}
#endif
return (1);
}
void
CBaseMonster::CBaseMonster(void)
{

View file

@ -106,15 +106,9 @@ CBaseEntity::predraw(void)
alpha = 0.25f;
}
/* mouth flapping action */
bonecontrol5 = getchannellevel(this, CHAN_VOICE) * 20;
m_flBaseTime = frame1time;
if (serverkeyfloat(SERVERKEY_PAUSESTATE) != 1)
frame1time += frametime;
ProcessWordQue();
processmodelevents(modelindex, frame, m_flBaseTime,
frame1time, ClientGame_ModelEvent);

View file

@ -19,6 +19,7 @@ enum
{
ENT_NONE,
ENT_ENTITY,
ENT_MONSTER,
ENT_PLAYER,
ENT_SPECTATOR,
ENT_AMBIENTSOUND,

View file

@ -137,6 +137,7 @@ Sound_ParseField(int i, int a)
break;
case "distshader":
g_sounds[i].distshader = argv(1);
break;
case "sample":
if (a == 2) {
dprint("\tAdded sample ");