Fixed up Endy's EXTEND support - everything should work now.

This commit is contained in:
Forest Hale 2000-07-01 04:56:13 +00:00
parent 99836b2862
commit 968efda8ed
7 changed files with 181 additions and 63 deletions

View file

@ -277,10 +277,12 @@ typedef struct
int skinnum; int skinnum;
int effects; int effects;
byte glowsize; // LordHavoc: Endy neglected to mark this as a QSG version 2 thingy...
byte glowcolor; byte alpha;
byte colormod; byte scale;
byte alpha; byte glowsize;
byte glowcolor;
byte colormod;
} entity_state_t; } entity_state_t;

View file

@ -49,39 +49,36 @@ typedef struct efrag_s
struct efrag_s *entnext; struct efrag_s *entnext;
} efrag_t; } efrag_t;
// LordHavoc: reindented this after 'Endy was here', also added scale.
typedef struct entity_s typedef struct entity_s
{ {
int keynum; // for matching entities in different frames int keynum; // for matching entities in different frames
vec3_t origin; vec3_t origin;
vec3_t angles; vec3_t angles;
struct model_s *model; // NULL = no model struct model_s *model; // NULL = no model
int frame; int frame;
byte *colormap; byte *colormap;
int skinnum; // for Alias models int skinnum; // for Alias models
struct player_info_s *scoreboard; // identify player struct player_info_s *scoreboard; // identify player
float syncbase; float syncbase;
struct efrag_s *efrag; // linked list of efrags (FIXME) struct efrag_s *efrag; // linked list of efrags (FIXME)
int visframe; // last frame this entity was int visframe; // last frame this entity was found in an active leaf, only used for static objects
// found in an active leaf
// only used for static objects
int dlightframe; // dynamic lighting
int dlightbits;
float colormod[3]; // color tint for model int dlightframe; // dynamic lighting
float alpha; // opacity (alpha) of the model int dlightbits;
float glowsize; // how big the glow is
byte glowcolor; // color of glow and particle trail (paletted)
byte glowtrail; // leaves a trail of particles
// FIXME: could turn these into a union float colormod[3]; // color tint for model
int trivial_accept; float alpha; // opacity (alpha) of the model
struct mnode_s *topnode; // for bmodels, first world node float scale; // size scaler of the model
// that splits bmodel, or NULL if float glowsize; // how big the glow is (can be negative)
// not split byte glowcolor; // color of glow (paletted)
// FIXME: could turn these into a union
int trivial_accept;
struct mnode_s *topnode; // for bmodels, first world node that splits bmodel, or NULL if not split
} entity_t; } entity_t;
// !!! if this is changed, it must be changed in asm_draw.h too !!! // !!! if this is changed, it must be changed in asm_draw.h too !!!

View file

@ -209,13 +209,13 @@ void CL_ParseDelta (entity_state_t *from, entity_state_t *to, int bits)
// if (bits&(1<<i)) // if (bits&(1<<i))
// bitcounts[i]++; // bitcounts[i]++;
if (bits & U_EXTEND1) // LordHavoc: Endy neglected to mark this as being part of the QSG version 2 stuff...
{ if (bits & U_EXTEND1)
bits |= MSG_ReadByte() << 16; {
if (bits & U_EXTEND2) bits |= MSG_ReadByte() << 16;
bits |= MSG_ReadByte() << 24; if (bits & U_EXTEND2)
} bits |= MSG_ReadByte() << 24;
}
to->flags = bits; to->flags = bits;
@ -252,18 +252,24 @@ void CL_ParseDelta (entity_state_t *from, entity_state_t *to, int bits)
if (bits & U_ANGLE3) if (bits & U_ANGLE3)
to->angles[2] = MSG_ReadAngle(); to->angles[2] = MSG_ReadAngle();
if (bits & U_GLOWSIZE) // LordHavoc: Endy neglected to mark this as being part of the QSG version 2 stuff...
to->glowsize = MSG_ReadByte(); // rearranged it and implemented missing effects
// Ender (QSG - Begin)
if (bits & U_GLOWCOLOR) if (bits & U_ALPHA)
to->glowcolor = MSG_ReadByte(); to->alpha = MSG_ReadByte();
if (bits & U_SCALE)
if (bits & U_COLORMOD) to->scale = MSG_ReadByte();
to->colormod = MSG_ReadByte(); if (bits & U_EFFECTS2)
to->effects = (to->effects & 0xFF) | (MSG_ReadByte() << 8);
if (bits & U_ALPHA) if (bits & U_GLOWSIZE)
to->alpha = MSG_ReadByte(); to->glowsize = MSG_ReadByte();
if (bits & U_GLOWCOLOR)
to->glowcolor = MSG_ReadByte();
if (bits & U_COLORMOD)
to->colormod = MSG_ReadByte();
if (bits & U_FRAME2)
to->frame = (to->frame & 0xFF) | (MSG_ReadByte() << 8);
// Ender (QSG - End)
if (bits & U_SOLID) if (bits & U_SOLID)
{ {
@ -520,11 +526,26 @@ void CL_LinkPacketEntities (void)
ent->scoreboard = NULL; ent->scoreboard = NULL;
} }
// LordHavoc: until a new protocol is written, there's no room for alpha and such
ent->glowsize = 0; // LordHavoc: cleaned up Endy's coding style, and fixed Endy's bugs
ent->glowcolor = 254; // Ender: Extend (Colormod) [QSG - Begin]
ent->alpha = 1; // N.B: All messy code below is the sole fault of LordHavoc and
ent->colormod[0] = ent->colormod[1] = ent->colormod[2] = 1; // his futile attempts to save bandwidth. :)
//
ent->glowsize = s1->glowsize < 128 ? s1->glowsize * 8.0 : (s1->glowsize - 256) * 8.0;
ent->glowcolor = s1->glowcolor;
ent->alpha = s1->alpha / 255.0;
if (s1->colormod == 255)
ent->colormod[0] = ent->colormod[1] = ent->colormod[2] = 1;
else
{
ent->colormod[0] = (float) ((s1->colormod >> 5) & 7) * (1.0 / 7.0);
ent->colormod[1] = (float) ((s1->colormod >> 2) & 7) * (1.0 / 7.0);
ent->colormod[2] = (float) (s1->colormod & 3) * (1.0 / 3.0);
}
//
// Ender: Extend (Colormod) [QSG - End]
// set skin // set skin
ent->skinnum = s1->skinnum; ent->skinnum = s1->skinnum;

View file

@ -755,6 +755,12 @@ void CL_ParseBaseline (entity_state_t *es)
es->origin[i] = MSG_ReadCoord (); es->origin[i] = MSG_ReadCoord ();
es->angles[i] = MSG_ReadAngle (); es->angles[i] = MSG_ReadAngle ();
} }
// LordHavoc: set up the baseline to account for new effects (alpha, colormod, etc)
es->alpha = 255;
es->scale = 16;
es->glowcolor = 254;
es->glowsize = 0;
es->colormod = 255;
} }
@ -789,6 +795,13 @@ void CL_ParseStatic (void)
VectorCopy (es.origin, ent->origin); VectorCopy (es.origin, ent->origin);
VectorCopy (es.angles, ent->angles); VectorCopy (es.angles, ent->angles);
// LordHavoc: make static entities visible
ent->alpha = 1;
ent->scale = 16;
ent->glowsize = 0;
ent->glowcolor = 254;
ent->colormod[0] = ent->colormod[1] = ent->colormod[2] = 1;
R_AddEfrags (ent); R_AddEfrags (ent);
} }

View file

@ -43,9 +43,7 @@
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
int eval_alpha, eval_scale, eval_glowsize, eval_glowcolor, eval_colormod;
// LordHavoc: disabled (needs new protocol)
//int eval_alpha, eval_fullbright, eval_colormod, eval_glowsize, eval_glowcolor;
int FindFieldOffset(char *field) int FindFieldOffset(char *field)
{ {
@ -68,12 +66,9 @@ eval_t *GETEDICTFIELDVALUE(edict_t *ed, int fieldoffset)
void FindEdictFieldOffsets() void FindEdictFieldOffsets()
{ {
// LordHavoc: disabled (needs new protocol)
/*
eval_alpha = FindFieldOffset("alpha"); eval_alpha = FindFieldOffset("alpha");
eval_fullbright = FindFieldOffset("fullbright"); eval_scale = FindFieldOffset("scale");
eval_colormod = FindFieldOffset("colormod");
eval_glowsize = FindFieldOffset("glow_size"); eval_glowsize = FindFieldOffset("glow_size");
eval_glowcolor = FindFieldOffset("glow_color"); eval_glowcolor = FindFieldOffset("glow_color");
*/ eval_colormod = FindFieldOffset("colormod");
}; };

View file

@ -41,6 +41,10 @@
#include "sys.h" #include "sys.h"
#include "pmove.h" #include "pmove.h"
// LordHavoc: added and removed certain eval_ items
// Ender Extends (QSG - Begin)
extern int eval_alpha, eval_scale, eval_glowsize, eval_glowcolor, eval_colormod;
// Ender Extends (QSG - End)
extern eval_t *GETEDICTFIELDVALUE(edict_t *ed, int fieldoffset); extern eval_t *GETEDICTFIELDVALUE(edict_t *ed, int fieldoffset);
/* /*
@ -215,6 +219,32 @@ void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qb
if ( to->modelindex != from->modelindex ) if ( to->modelindex != from->modelindex )
bits |= U_MODEL; bits |= U_MODEL;
// LordHavoc: cleaned up Endy's coding style, and added missing effects
// Ender (QSG - Begin)
if (stdver > 1)
{
if (to->alpha != from->alpha)
bits |= U_ALPHA;
if (to->scale != from->scale)
bits |= U_SCALE;
if (to->glowsize != from->glowsize)
bits |= U_GLOWSIZE;
if (to->glowcolor != from->glowcolor)
bits |= U_GLOWCOLOR;
if (to->colormod != from->colormod)
bits |= U_COLORMOD;
}
if (bits >= 16777216)
bits |= U_EXTEND2;
if (bits >= 65536)
bits |= U_EXTEND1;
// Ender (QSG - End)
if (bits & 511) if (bits & 511)
bits |= U_MOREBITS; bits |= U_MOREBITS;
@ -239,6 +269,14 @@ void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qb
if (bits & U_MOREBITS) if (bits & U_MOREBITS)
MSG_WriteByte (msg, bits&255); MSG_WriteByte (msg, bits&255);
// LordHavoc: cleaned up Endy's tabs
// Ender (QSG - Begin)
if (bits & U_EXTEND1)
MSG_WriteByte (msg, bits>>16);
if (bits & U_EXTEND2)
MSG_WriteByte (msg, bits>>24);
// Ender (QSG - End)
if (bits & U_MODEL) if (bits & U_MODEL)
MSG_WriteByte (msg, to->modelindex); MSG_WriteByte (msg, to->modelindex);
if (bits & U_FRAME) if (bits & U_FRAME)
@ -261,6 +299,24 @@ void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qb
MSG_WriteCoord (msg, to->origin[2]); MSG_WriteCoord (msg, to->origin[2]);
if (bits & U_ANGLE3) if (bits & U_ANGLE3)
MSG_WriteAngle(msg, to->angles[2]); MSG_WriteAngle(msg, to->angles[2]);
// LordHavoc: cleaned up Endy's tabs, rearranged bytes, and implemented missing effects
// Ender (QSG - Begin)
if (bits & U_ALPHA)
MSG_WriteByte(msg, to->alpha);
if (bits & U_SCALE)
MSG_WriteByte(msg, to->scale);
if (bits & U_EFFECTS2)
MSG_WriteByte(msg, (to->effects >> 8));
if (bits & U_GLOWSIZE)
MSG_WriteByte(msg, to->glowsize);
if (bits & U_GLOWCOLOR)
MSG_WriteByte(msg, to->glowcolor);
if (bits & U_COLORMOD)
MSG_WriteByte(msg, to->colormod);
if (bits & U_FRAME2)
MSG_WriteByte(msg, (to->frame >> 8));
// Ender (QSG - End)
} }
/* /*
@ -529,7 +585,35 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg)
state->colormap = ent->v.colormap; state->colormap = ent->v.colormap;
state->skinnum = ent->v.skin; state->skinnum = ent->v.skin;
state->effects = ent->v.effects; state->effects = ent->v.effects;
}
// LordHavoc: cleaned up Endy's coding style, shortened the code,
// and implemented missing effects
// Ender: EXTEND (QSG - Begin)
{
eval_t *val;
state->glowsize = 0;
state->glowcolor = 254;
state->colormod = 255;
state->alpha = 255;
state->scale = 16;
if ((val = GETEDICTFIELDVALUE(ent, eval_alpha)) && val->_float != 0)
state->alpha = bound(0, val->_float, 1) * 255.0;
if ((val = GETEDICTFIELDVALUE(ent, eval_scale)) && val->_float != 0)
state->scale = bound(0, val->_float, 15.9375) * 16.0;
if ((val = GETEDICTFIELDVALUE(ent, eval_glowsize)) && val->_float != 0)
state->glowsize = bound(-1024, (int)val->_float, 1016) >> 3;
if ((val = GETEDICTFIELDVALUE(ent, eval_glowcolor)) && val->_float != 0)
state->glowcolor = (int) val->_float;
if ((val = GETEDICTFIELDVALUE(ent, eval_colormod)) && (val->vector[0] != 0 || val->vector[1] != 0 || val->vector[2] != 0))
state->colormod = ((int) (bound(0, val->vector[0], 1) * 7.0) << 5) | ((int) (bound(0, val->vector[1], 1) * 7.0) << 2) | (int) (bound(0, val->vector[2], 1) * 3.0);
}
// Ender: EXTEND (QSG - End)
}
// encode the packet entities as a delta from the // encode the packet entities as a delta from the
// last packetentities acknowledged by the client // last packetentities acknowledged by the client

View file

@ -129,6 +129,12 @@ void SV_CreateBaseline (void)
svent->baseline.modelindex = svent->baseline.modelindex =
SV_ModelIndex(PR_GetString(svent->v.model)); SV_ModelIndex(PR_GetString(svent->v.model));
} }
// LordHavoc: setup baseline to include new effects
svent->baseline.alpha = 255;
svent->baseline.scale = 16;
svent->baseline.glowsize = 0;
svent->baseline.glowcolor = 254;
svent->baseline.colormap = 255;
// //
// flush the signon message out to a seperate buffer if // flush the signon message out to a seperate buffer if