Manual networking of all base-entities. This shouldn't be necessary,
but, as the engine-bug that's as old as time itself that has been responsible for prediction being wonky has still not been fixed, I have to do this. Maybe it'll be for worse, maybe it'll be for the better.
This commit is contained in:
parent
9386b7f158
commit
673cf9dbf8
8 changed files with 205 additions and 2 deletions
|
@ -4,6 +4,7 @@ all:
|
|||
make menu
|
||||
make games
|
||||
make mods
|
||||
make plugins
|
||||
|
||||
menu:
|
||||
$(CC) menu-fn/progs.src
|
||||
|
@ -35,3 +36,6 @@ mods:
|
|||
mkdir -p ../hunger/data.pk3dir
|
||||
$(CC) client/hunger/progs.src
|
||||
$(CC) server/hunger/progs.src
|
||||
|
||||
plugins:
|
||||
$(CC) plugins/chatsounds.src
|
||||
|
|
|
@ -27,6 +27,11 @@ void CSQC_Ent_Update(float new)
|
|||
t = readbyte();
|
||||
|
||||
switch (t) {
|
||||
case ENT_ENTITY:
|
||||
CBaseEntity me = (CBaseEntity)self;
|
||||
spawnfunc_CBaseEntity();
|
||||
me.ReadEntity(readfloat());
|
||||
break;
|
||||
case ENT_PLAYER:
|
||||
Player_ReadEntity(new);
|
||||
break;
|
||||
|
|
|
@ -16,6 +16,21 @@
|
|||
|
||||
string __fullspawndata;
|
||||
|
||||
// keep in sync with client/baseentity.cpp
|
||||
enumflags
|
||||
{
|
||||
BASEFL_CHANGED_ORIGIN,
|
||||
BASEFL_CHANGED_ANGLES,
|
||||
BASEFL_CHANGED_MODELINDEX,
|
||||
BASEFL_CHANGED_SIZE,
|
||||
BASEFL_CHANGED_SOLID,
|
||||
BASEFL_CHANGED_FRAME,
|
||||
BASEFL_CHANGED_SKIN,
|
||||
BASEFL_CHANGED_MOVETYPE,
|
||||
BASEFL_CHANGED_ALPHA,
|
||||
BASEFL_CHANGED_EFFECTS
|
||||
};
|
||||
|
||||
class CBaseEntity
|
||||
{
|
||||
string targetname;
|
||||
|
@ -26,8 +41,56 @@ class CBaseEntity
|
|||
virtual void() Init;
|
||||
virtual void() Initialized;
|
||||
virtual void(string, string) SpawnKey;
|
||||
virtual void(float flChanged) ReadEntity;
|
||||
};
|
||||
|
||||
void CBaseEntity::ReadEntity(float flChanged)
|
||||
{
|
||||
if (flChanged & BASEFL_CHANGED_ORIGIN) {
|
||||
origin[0] = readcoord();
|
||||
origin[1] = readcoord();
|
||||
origin[2] = readcoord();
|
||||
}
|
||||
if (flChanged & BASEFL_CHANGED_ANGLES) {
|
||||
angles[0] = readfloat();
|
||||
angles[1] = readfloat();
|
||||
angles[2] = readfloat();
|
||||
}
|
||||
if (flChanged & BASEFL_CHANGED_MODELINDEX) {
|
||||
modelindex = readshort();
|
||||
}
|
||||
if (flChanged & BASEFL_CHANGED_SOLID) {
|
||||
solid = readbyte();
|
||||
}
|
||||
if (flChanged & BASEFL_CHANGED_MOVETYPE) {
|
||||
movetype = readbyte();
|
||||
}
|
||||
if (flChanged & BASEFL_CHANGED_SIZE) {
|
||||
mins[0] = readcoord();
|
||||
mins[1] = readcoord();
|
||||
mins[2] = readcoord();
|
||||
maxs[0] = readcoord();
|
||||
maxs[1] = readcoord();
|
||||
maxs[2] = readcoord();
|
||||
}
|
||||
if (flChanged & BASEFL_CHANGED_FRAME) {
|
||||
frame = readbyte();
|
||||
}
|
||||
if (flChanged & BASEFL_CHANGED_SKIN) {
|
||||
skin = readbyte();
|
||||
}
|
||||
if (flChanged & BASEFL_CHANGED_ALPHA) {
|
||||
alpha = readfloat();
|
||||
}
|
||||
if (flChanged & BASEFL_CHANGED_EFFECTS) {
|
||||
effects = readfloat();
|
||||
}
|
||||
|
||||
drawmask = MASK_ENGINE;
|
||||
setorigin(this, origin);
|
||||
setsize(this, mins, maxs);
|
||||
}
|
||||
|
||||
void CBaseEntity::SpawnKey(string strField, string strKey)
|
||||
{
|
||||
switch (strField) {
|
||||
|
|
|
@ -24,6 +24,21 @@ enum
|
|||
RM_ADDITIVE
|
||||
};
|
||||
|
||||
// keep in sync with client/baseentity.cpp
|
||||
enumflags
|
||||
{
|
||||
BASEFL_CHANGED_ORIGIN,
|
||||
BASEFL_CHANGED_ANGLES,
|
||||
BASEFL_CHANGED_MODELINDEX,
|
||||
BASEFL_CHANGED_SIZE,
|
||||
BASEFL_CHANGED_SOLID,
|
||||
BASEFL_CHANGED_FRAME,
|
||||
BASEFL_CHANGED_SKIN,
|
||||
BASEFL_CHANGED_MOVETYPE,
|
||||
BASEFL_CHANGED_ALPHA,
|
||||
BASEFL_CHANGED_EFFECTS
|
||||
};
|
||||
|
||||
class CBaseEntity
|
||||
{
|
||||
string m_strTarget;
|
||||
|
@ -34,6 +49,18 @@ class CBaseEntity
|
|||
vector m_oldOrigin;
|
||||
vector m_oldAngle;
|
||||
|
||||
vector oldnet_origin;
|
||||
vector oldnet_angles;
|
||||
float oldnet_modelindex;
|
||||
vector oldnet_mins;
|
||||
vector oldnet_maxs;
|
||||
float oldnet_solid;
|
||||
float oldnet_movetype;
|
||||
float oldnet_alpha;
|
||||
float oldnet_frame;
|
||||
float oldnet_skin;
|
||||
float oldnet_effects;
|
||||
|
||||
float m_rendermode;
|
||||
float m_renderamt;
|
||||
vector m_rendercolor;
|
||||
|
@ -44,11 +71,108 @@ class CBaseEntity
|
|||
virtual void() Hide;
|
||||
virtual void() RendermodeUpdate;
|
||||
virtual void() ParentUpdate;
|
||||
virtual float(entity, float) SendEntity;
|
||||
};
|
||||
|
||||
/* Make sure StartFrame calls this */
|
||||
float CBaseEntity::SendEntity(entity ePEnt, float fChanged)
|
||||
{
|
||||
WriteByte(MSG_ENTITY, ENT_ENTITY);
|
||||
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) {
|
||||
WriteFloat(MSG_ENTITY, angles[0]);
|
||||
WriteFloat(MSG_ENTITY, angles[1]);
|
||||
WriteFloat(MSG_ENTITY, angles[2]);
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (fChanged & BASEFL_CHANGED_ALPHA) {
|
||||
WriteFloat(MSG_ENTITY, alpha);
|
||||
}
|
||||
if (fChanged & BASEFL_CHANGED_EFFECTS) {
|
||||
WriteFloat(MSG_ENTITY, effects);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Make sure StartFrame calls this */
|
||||
void CBaseEntity::ParentUpdate(void)
|
||||
{
|
||||
/* Check our fields for networking */
|
||||
if (origin != oldnet_origin) {
|
||||
SendFlags |= BASEFL_CHANGED_ORIGIN;
|
||||
oldnet_origin = origin;
|
||||
}
|
||||
if (angles != oldnet_angles) {
|
||||
SendFlags |= BASEFL_CHANGED_ANGLES;
|
||||
oldnet_angles = angles;
|
||||
}
|
||||
if (modelindex != oldnet_modelindex) {
|
||||
SendFlags |= BASEFL_CHANGED_MODELINDEX;
|
||||
oldnet_modelindex = modelindex;
|
||||
}
|
||||
if (mins != oldnet_mins) {
|
||||
SendFlags |= BASEFL_CHANGED_SIZE;
|
||||
oldnet_mins = mins;
|
||||
}
|
||||
if (maxs != oldnet_maxs) {
|
||||
SendFlags |= BASEFL_CHANGED_SIZE;
|
||||
oldnet_maxs = maxs;
|
||||
}
|
||||
if (solid != oldnet_solid) {
|
||||
SendFlags |= BASEFL_CHANGED_SOLID;
|
||||
oldnet_solid = solid;
|
||||
}
|
||||
if (movetype != oldnet_movetype) {
|
||||
SendFlags |= BASEFL_CHANGED_MOVETYPE;
|
||||
oldnet_movetype = movetype;
|
||||
}
|
||||
if (frame != oldnet_frame) {
|
||||
SendFlags |= BASEFL_CHANGED_FRAME;
|
||||
oldnet_frame = frame;
|
||||
}
|
||||
if (skin != oldnet_skin) {
|
||||
SendFlags |= BASEFL_CHANGED_SKIN;
|
||||
oldnet_skin = skin;
|
||||
}
|
||||
if (alpha != oldnet_alpha) {
|
||||
SendFlags |= BASEFL_CHANGED_ALPHA;
|
||||
oldnet_alpha = alpha;
|
||||
}
|
||||
if (effects != oldnet_effects) {
|
||||
SendFlags |= BASEFL_CHANGED_EFFECTS;
|
||||
oldnet_effects = effects;
|
||||
}
|
||||
|
||||
if (m_parent) {
|
||||
entity p = find(world, CBaseEntity::m_strTargetName, m_parent);
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ init(float prevprogs)
|
|||
print(sprintf("Found %s\n", search_getfilename(list, i)));
|
||||
}
|
||||
search_end(list);
|
||||
|
||||
|
||||
chatfile = fopen("chatsounds.txt", FILE_READ);
|
||||
|
||||
if (chatfile < 0) {
|
||||
|
|
|
@ -21,6 +21,11 @@ void main(void)
|
|||
|
||||
void StartFrame(void)
|
||||
{
|
||||
for (entity a = world; (a = findfloat(a, gflags, GF_CANRESPAWN));) {
|
||||
CBaseEntity ent = (CBaseEntity)a;
|
||||
ent.ParentUpdate();
|
||||
}
|
||||
|
||||
Game_StartFrame();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
*/
|
||||
|
||||
enum {
|
||||
ENT_PLAYER = 1,
|
||||
ENT_ENTITY = 1,
|
||||
ENT_PLAYER,
|
||||
ENT_NPC,
|
||||
ENT_AMBIENTSOUND,
|
||||
ENT_SPRITE,
|
||||
|
|
|
@ -88,6 +88,7 @@ w_taurus_draw(void)
|
|||
{
|
||||
#ifdef CSQC
|
||||
Weapons_SetModel("models/v_taurus.mdl");
|
||||
Weapons_ViewAnimation(TAURUS_DRAW);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue