Patched for QSG Standard 2 (Extend Protocol).

Unfinished, renderer effects are only half implimented at this point.
This commit is contained in:
James Brown 2000-06-25 13:00:19 +00:00
parent f6ec000127
commit 089a0a35d0
16 changed files with 273 additions and 64 deletions

View file

@ -11,7 +11,7 @@ AM_INIT_AUTOMAKE(quakeforge, 0.1.99pre2)
dnl Define the proper name and extra version numbers for package
PROGRAM=QuakeForge
QW_VERSION=2.40
QSG_VERSION=1.0
QSG_VERSION=2.0
AC_DEFINE_UNQUOTED(PROGRAM, "$PROGRAM")
AC_DEFINE_UNQUOTED(QW_VERSION, "$QW_VERSION")

View file

@ -75,59 +75,37 @@
#define svc_nop 1
#define svc_disconnect 2
#define svc_updatestat 3 // [byte] [byte]
//define svc_version 4 // [long] server version
#define svc_setview 5 // [short] entity number
#define svc_sound 6 // <see code>
//define svc_time 7 // [float] server time
#define svc_print 8 // [byte] id [string] null terminated string
#define svc_stufftext 9 // [string] stuffed into client's console buffer
// the string should be \n terminated
#define svc_setangle 10 // [angle3] set the view angle to this absolute value
#define svc_serverdata 11 // [long] protocol ...
#define svc_serverdata 11 // [long] protocol ...
#define svc_lightstyle 12 // [byte] [string]
//define svc_updatename 13 // [byte] [string]
#define svc_updatefrags 14 // [byte] [short]
//define svc_clientdata 15 // <shortbits + data>
#define svc_stopsound 16 // <see code>
//define svc_updatecolors 17 // [byte] [byte] [byte]
//define svc_particle 18 // [vec3] <variable>
#define svc_damage 19
#define svc_damage 19
#define svc_spawnstatic 20
// svc_spawnbinary 21
#define svc_spawnbaseline 22
#define svc_temp_entity 23 // variable
#define svc_setpause 24 // [byte] on / off
// svc_signonnum 25 // [byte] used for the signon sequence
#define svc_centerprint 26 // [string] to put in center of the screen
#define svc_killedmonster 27
#define svc_foundsecret 28
#define svc_spawnstaticsound 29 // [coord3] [byte] samp [byte] vol [byte] aten
#define svc_intermission 30 // [vec3_t] origin [vec3_t] angle
#define svc_finale 31 // [string] text
#define svc_cdtrack 32 // [byte] track
#define svc_cdtrack 32 // [byte] track
#define svc_sellscreen 33
#define svc_smallkick 34 // set client punchangle to 2
#define svc_bigkick 35 // set client punchangle to 4
#define svc_updateping 36 // [byte] [short]
#define svc_updateentertime 37 // [byte] [float]
#define svc_updatestatlong 38 // [byte] [long]
#define svc_muzzleflash 39 // [short] entity
#define svc_updateuserinfo 40 // [byte] slot [long] uid
// [string] userinfo
// [string] userinfo
#define svc_download 41 // [short] size [size bytes]
#define svc_playerinfo 42 // variable
#define svc_nails 43 // [byte] num [48 bits] xyzpy 12 12 12 4 8
@ -211,6 +189,30 @@
#define U_EFFECTS (1<<5)
#define U_SOLID (1<<6) // the entity should be solid for prediction
///////////////////////////////////////////////////////////////////////////
// QSG Protocol Extensions (Version 2)
// Network definitions for the engine, as defined in protocol.h
#define U_EXTEND1 (1<<7)
#define U_ALPHA (1<<17) // 1 byte, 0.0-1.0 = 0-255 (Unsent if 1)
#define U_SCALE (1<<18) // 1 byte, scale / 16 positive, (Unsent if 1)
#define U_EFFECTS2 (1<<19) // 1 byte, .effects & 0xFF00
#define U_GLOWSIZE (1<<20) // 1 byte, float/8.0, signed. Unsent if 1
#define U_GLOWCOLOR (1<<21) // 1 byte, palette index, default, 254.
#define U_COLORMOD (1<<22) // 1 byte, rrrgggbb. Model tinting
#define U_EXTEND2 (1<<23) // Another byte to follow
#define U_GLOWTRAIL (1<<24) // Leave U_GLOW* trail
#define U_VIEWMODEL (1<<25) // Attach model to view (relative). Owner only
#define U_FRAME2 (1<<26) // 1 byte .frame & 0xFF00 (second byte)
#define U_UNUSED27 (1<<27) // future expansion
#define U_UNUSED28 (1<<28) // future expansion
#define U_UNUSED29 (1<<29) // future expansion
#define U_UNUSED30 (1<<30) // future expansion
#define U_EXTEND3 (1<<31) // another byte to follow, future expansion
//==============================================
// a sound with no channel is a local only sound
@ -274,6 +276,10 @@ typedef struct
int colormap;
int skinnum;
int effects;
byte glowsize;
byte glowcolor;
byte colormod;
} entity_state_t;

View file

@ -51,31 +51,37 @@ typedef struct efrag_s
typedef struct entity_s
{
int keynum; // for matching entities in different frames
vec3_t origin;
vec3_t angles;
struct model_s *model; // NULL = no model
int frame;
byte *colormap;
int skinnum; // for Alias models
int keynum; // for matching entities in different frames
vec3_t origin;
vec3_t angles;
struct model_s *model; // NULL = no model
int frame;
byte *colormap;
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)
int visframe; // last frame this entity was
struct efrag_s *efrag; // linked list of efrags (FIXME)
int visframe; // last frame this entity was
// found in an active leaf
// only used for static objects
int dlightframe; // dynamic lighting
int dlightbits;
int dlightframe; // dynamic lighting
int dlightbits;
float colormod[3]; // color tint for model
float alpha; // opacity (alpha) of the model
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
int trivial_accept;
struct mnode_s *topnode; // for bmodels, first world node
// that splits bmodel, or NULL if
// not split
int trivial_accept;
struct mnode_s *topnode; // for bmodels, first world node
// that splits bmodel, or NULL if
// not split
} entity_t;
// !!! if this is changed, it must be changed in asm_draw.h too !!!

View file

@ -214,6 +214,7 @@ typedef struct client_s
netchan_t netchan;
int msecs, msec_cheating;
double last_check;
int stdver;
} client_t;
// a client can leave the server in one of four ways:

View file

@ -243,9 +243,6 @@
/* Define if you have the m library (-lm). */
#undef HAVE_LIBM
/* Define if you want the QSG standards */
#define QSG_VERSION "1.0"
/* Posix, needed for limits.h and Unix stuffs to work right */
#define _POSIX_

View file

@ -243,10 +243,6 @@
/* Define if you have the m library (-lm). */
#undef HAVE_LIBM
/* Define if you want the QSG standards */
#define QSG_VERSION "1.0"
/* Posix, needed for limits.h and Unix stuffs to work right */
#define _POSIX_

View file

@ -32,6 +32,6 @@
#define PROGRAM "QuakeForge"
#define VERSION "0.1.99pre2"
#define QW_VERSION "2.40"
#define QSG_VERSION "1.0"
#define QSG_VERSION "2.0"
#endif // _VERSION_H

View file

@ -209,6 +209,14 @@ void CL_ParseDelta (entity_state_t *from, entity_state_t *to, int bits)
if (bits&(1<<i))
bitcounts[i]++;
if (bits & U_EXTEND1)
{
bits |= MSG_ReadByte() << 16;
if (bits & U_EXTEND2)
bits |= MSG_ReadByte() << 24;
}
to->flags = bits;
if (bits & U_MODEL)
@ -244,6 +252,15 @@ void CL_ParseDelta (entity_state_t *from, entity_state_t *to, int bits)
if (bits & U_ANGLE3)
to->angles[2] = MSG_ReadAngle();
if (bits & U_GLOWSIZE)
to->glowsize = MSG_ReadByte();
if (bits & U_GLOWCOLOR)
to->glowcolor = MSG_ReadByte();
if (bits & U_GLOWCOLOR)
to->colormod = MSG_ReadByte();
if (bits & U_SOLID)
{
// FIXME
@ -499,7 +516,19 @@ void CL_LinkPacketEntities (void)
ent->scoreboard = NULL;
}
// set skin
// Ender: Extend (Colormod) [QSG - Begin]
// N.B: All messy code below is the sole fault of LordHavoc and
// 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->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
ent->skinnum = s1->skinnum;
// set frame

View file

@ -1143,6 +1143,7 @@ void CL_Init (void)
// sprintf (st, "%s-%04d", QW_VERSION, build_number());
sprintf (st, "%s", QW_VERSION);
Info_SetValueForStarKey (cls.userinfo, "*ver", st, MAX_INFO_STRING);
Info_SetValueForStarKey (cls.userinfo, "stdver", QSG_VERSION, MAX_INFO_STRING);
CL_InitInput ();
CL_InitTEnts ();

View file

@ -89,6 +89,8 @@ mleaf_t *r_viewleaf, *r_oldviewleaf;
int d_lightstylevalue[256]; // 8.8 fraction of base light value
vec3_t shadecolor; // Ender (Extend) Colormod
void R_MarkLeaves (void);
cvar_t *r_norefresh;
@ -390,7 +392,12 @@ void GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum)
// normals and vertexes come from the frame list
l = shadedots[verts->lightnormalindex] * shadelight;
glColor3f (l, l, l);
// Ender: Test (Colormod)
// if (shadecolor[0] || shadecolor[1] || shadecolor[2]) {
// glColor3f(shadecolor[0] * l, shadecolor[1] * l, shadecolor[2] * l);
// } else {
glColor3f (l, l, l);
// }
glVertex3f (verts->v[0], verts->v[1], verts->v[2]);
verts++;
} while (--count);
@ -494,7 +501,6 @@ void R_SetupAliasFrame (int frame, aliashdr_t *paliashdr)
}
/*
=================
R_DrawAliasModel
@ -531,6 +537,11 @@ void R_DrawAliasModel (entity_t *e)
ambientlight = shadelight = R_LightPoint (currententity->origin);
// Ender (Extend)
shadecolor[0] = currententity->colormod[0];
shadecolor[1] = currententity->colormod[1];
shadecolor[2] = currententity->colormod[2];
// allways give the gun some light
if (e == &cl.viewent && ambientlight < 24)
ambientlight = shadelight = 24;

View file

@ -63,7 +63,7 @@ int skytexturenum;
#define GL_RGBA4 0
#endif
extern vec3_t shadecolor; // Ender (Extend) Colormod
int lightmap_bytes; // 1 or 4
int lightmap_textures;
@ -707,7 +707,7 @@ void R_DrawWaterSurfaces (void)
glColor4f (0.5, 0.5, 0.5, r_wateralpha->value);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
} else
glColor3f (0.5, 0.5, 0.5);
glColor3f (0.5, 0.5, 0.5);
if (!gl_texsort->value) {
if (!waterchain)
@ -837,7 +837,14 @@ void R_DrawBrushModel (entity_t *e)
if (R_CullBox (mins, maxs))
return;
glColor3f (1.0, 1.0, 1.0);
// Ender: Extend (Alpha) [QSG - Begin]
// glEnable(GL_BLEND);
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
// Note: glColor4f and gl_texsort->value = 1 for alpha! :)
glColor3f (1, 1, 1);
// Ender: Extend (Alpha) [QSG - End]
memset (lightmap_polys, 0, sizeof(lightmap_polys));
VectorSubtract (r_refdef.vieworg, e->origin, modelorg);

View file

@ -24,7 +24,7 @@ COM_sources=\
sys_win.obj
SV_sources=\
pr_cmds.obj pr_edict.obj pr_exec.obj \
pr_cmds.obj pr_edict.obj pr_exec.obj pr_offs.obj\
sv_init.obj sv_main.obj sv_misc.obj sv_model.obj sv_nchan.obj sv_ents.obj \
sv_send.obj sv_move.obj sv_phys.obj sv_user.obj sv_ccmds.obj \
world.obj sv_cvar.obj model.obj \

View file

@ -49,6 +49,7 @@
#endif
void SV_Error (char *error, ...);
void FindEdictFieldOffsets();
dprograms_t *progs;
dfunction_t *pr_functions;
@ -1087,6 +1088,8 @@ void PR_LoadProgs (void)
SpectatorThink = (func_t)(f - pr_functions);
if ((f = ED_FindFunction ("SpectatorDisconnect")) != NULL)
SpectatorDisconnect = (func_t)(f - pr_functions);
FindEdictFieldOffsets();
}

73
source/pr_offs.c Normal file
View file

@ -0,0 +1,73 @@
/*
pr_offs.c
Quick QuakeC offset access
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "pr_comp.h"
#include "progs.h"
#include "console.h"
#include "server.h"
#include "world.h"
#include "msg.h"
#include "cmd.h"
#include "commdef.h"
#include "info.h"
#include <stdlib.h>
#include <math.h>
#include <string.h>
int eval_alpha, eval_fullbright, eval_colormod, eval_glowsize, eval_glowcolor;
int FindFieldOffset(char *field)
{
ddef_t *d;
d = ED_FindField(field);
if (!d)
return 0;
return d->ofs*4;
}
eval_t *GETEDICTFIELDVALUE(edict_t *ed, int fieldoffset)
{
if (!fieldoffset)
return NULL;
return (eval_t*)((char*)&ed->v + fieldoffset);
}
void FindEdictFieldOffsets()
{
eval_alpha = FindFieldOffset("alpha");
eval_fullbright = FindFieldOffset("fullbright");
eval_colormod = FindFieldOffset("colormod");
eval_glowsize = FindFieldOffset("glow_size");
eval_glowcolor = FindFieldOffset("glow_color");
};

View file

@ -41,6 +41,12 @@
#include "sys.h"
#include "pmove.h"
// Ender Extends (QSG - Begin)
// HACK HACK HACK
extern int eval_alpha, eval_fullbright, eval_colormod, eval_glowsize, eval_glowcolor;
// Ender Extends (QSG - End)
eval_t *GETEDICTFIELDVALUE(edict_t *ed, int fieldoffset);
/*
=============================================================================
@ -173,7 +179,7 @@ Writes part of a packetentities message.
Can delta from either a baseline or a previous packet_entity
==================
*/
void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qboolean force)
void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qboolean force, int stdver)
{
int bits;
int i;
@ -213,6 +219,19 @@ void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qb
if ( to->modelindex != from->modelindex )
bits |= U_MODEL;
// Ender (QSG - Begin)
if (stdver > 1) {
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)
bits |= U_MOREBITS;
@ -236,6 +255,14 @@ void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qb
if (bits & U_MOREBITS)
MSG_WriteByte (msg, bits&255);
// 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)
MSG_WriteByte (msg, to->modelindex);
if (bits & U_FRAME)
@ -258,6 +285,15 @@ void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qb
MSG_WriteCoord (msg, to->origin[2]);
if (bits & U_ANGLE3)
MSG_WriteAngle(msg, to->angles[2]);
// Ender (QSG - Begin)
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);
// Ender (QSG - End)
}
/*
@ -307,7 +343,7 @@ void SV_EmitPacketEntities (client_t *client, packet_entities_t *to, sizebuf_t *
if (newnum == oldnum)
{ // delta update from old position
//Con_Printf ("delta %i\n", newnum);
SV_WriteDelta (&from->entities[oldindex], &to->entities[newindex], msg, false);
SV_WriteDelta (&from->entities[oldindex], &to->entities[newindex], msg, false, client->stdver);
oldindex++;
newindex++;
continue;
@ -317,7 +353,7 @@ void SV_EmitPacketEntities (client_t *client, packet_entities_t *to, sizebuf_t *
{ // this is a new entity, send it from the baseline
ent = EDICT_NUM(newnum);
//Con_Printf ("baseline %i\n", newnum);
SV_WriteDelta (&ent->baseline, &to->entities[newindex], msg, true);
SV_WriteDelta (&ent->baseline, &to->entities[newindex], msg, true, client->stdver);
newindex++;
continue;
}
@ -526,7 +562,49 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg)
state->colormap = ent->v.colormap;
state->skinnum = ent->v.skin;
state->effects = ent->v.effects;
}
// Ender: EXTEND (QSG - Begin)
{
eval_t *val;
state->glowsize = 0;
state->glowcolor = 254;
state->colormod = 255;
if (val = GETEDICTFIELDVALUE(ent, eval_glowsize)) {
state->glowsize = (int) val->_float >> 3;
if (state->glowsize > 127)
state->glowsize = 127;
if (state->glowsize < -128)
state->glowsize = -128;
}
if (val = GETEDICTFIELDVALUE(ent, eval_glowcolor)) {
if (val->_float != 0)
state->glowcolor = (int) val->_float;
}
if (val = GETEDICTFIELDVALUE(ent, eval_colormod)) {
if (val->vector[0] != 0 || val->vector[1] != 0 || val->vector[2] != 0) {
int modred, modgreen, modblue;
modred = val->vector[0] * 8.0;
if (modred < 0) modred = 0;
if (modred > 7) modred = 7;
modgreen = val->vector[1] * 8.0;
if (modgreen < 0) modgreen = 0;
if (modgreen > 7) modgreen = 7;
modblue = val->vector[2] * 4.0;
if (modblue < 0) modblue = 0;
if (modblue > 3) modblue = 3;
state->colormod = (modred << 5) | (modgreen << 2) | modblue;
}
}
}
// Ender: EXTEND (QSG - End)
}
// encode the packet entities as a delta from the
// last packetentities acknowledged by the client

View file

@ -1622,6 +1622,7 @@ void SV_ExtractFromUserinfo (client_t *cl)
cl->messagelevel = atoi(val);
}
cl->stdver = atoi(Info_ValueForKey (cl->userinfo, "stdver"));
}