A bit more diff reduction before attempting to merge client code.

This commit is contained in:
Bill Currie 2011-08-27 10:25:41 +09:00
parent 514f085e88
commit 28d9c7234c
4 changed files with 96 additions and 68 deletions

View file

@ -1,5 +1,5 @@
/* /*
cl_main.c cl_ents.c
entity parsing and management entity parsing and management
@ -28,8 +28,7 @@
# include "config.h" # include "config.h"
#endif #endif
static __attribute__ ((used)) const char rcsid[] = static __attribute__ ((used)) const char rcsid[] = "$Id$";
"$Id$";
#include "QF/cbuf.h" #include "QF/cbuf.h"
#include "QF/cmd.h" #include "QF/cmd.h"
@ -63,7 +62,7 @@ cl_entity_state_t cl_baselines[MAX_EDICTS];
void void
CL_ClearEnts (void) CL_ClearEnts (void)
{ {
int i; size_t i;
// clear other arrays // clear other arrays
memset (cl_entities, 0, sizeof (cl_entities)); memset (cl_entities, 0, sizeof (cl_entities));
@ -77,56 +76,77 @@ CL_ClearEnts (void)
} }
static void static void
CL_NewDlight (int key, vec3_t org, int effects) CL_NewDlight (int key, vec3_t org, int effects, byte glow_size,
byte glow_color)
{ {
float radius; float radius;
float time = 0.1;
dlight_t *dl; dlight_t *dl;
static quat_t normal = {0.4, 0.2, 0.05, 0.7}; static quat_t normal = {0.4, 0.2, 0.05, 0.7};
static quat_t red = {0.5, 0.05, 0.05, 0.7}; static quat_t red = {0.5, 0.05, 0.05, 0.7};
static quat_t blue = {0.05, 0.05, 0.5, 0.7}; static quat_t blue = {0.05, 0.05, 0.5, 0.7};
static quat_t purple = {0.5, 0.05, 0.5, 0.7}; static quat_t purple = {0.5, 0.05, 0.5, 0.7};
if (!(effects & (EF_BLUE | EF_RED | EF_BRIGHTLIGHT | EF_DIMLIGHT))) effects &= EF_BLUE | EF_RED | EF_BRIGHTLIGHT | EF_DIMLIGHT;
return; if (!effects) {
if (!glow_size)
return;
}
dl = R_AllocDlight (key); dl = R_AllocDlight (key);
if (!dl) if (!dl)
return; return;
VectorCopy (org, dl->origin); VectorCopy (org, dl->origin);
radius = 200 + (rand () & 31); if (effects & (EF_BLUE | EF_RED | EF_BRIGHTLIGHT | EF_DIMLIGHT)) {
if (effects & EF_BRIGHTLIGHT) { radius = 200 + (rand () & 31);
radius += 200; if (effects & EF_BRIGHTLIGHT) {
dl->origin[2] += 16; radius += 200;
} dl->origin[2] += 16;
if (effects & EF_DIMLIGHT) }
if (effects & ~EF_DIMLIGHT) if (effects & EF_DIMLIGHT)
radius -= 100; if (effects & ~EF_DIMLIGHT)
dl->radius = radius; radius -= 100;
dl->die = cl.time + time; dl->radius = radius;
dl->die = cl.time + 0.1;
switch (effects & (EF_BLUE | EF_RED)) { switch (effects & (EF_RED | EF_BLUE)) {
case EF_RED | EF_BLUE: case EF_RED | EF_BLUE:
QuatCopy (purple, dl->color); QuatCopy (purple, dl->color);
break; break;
case EF_RED: case EF_RED:
QuatCopy (red, dl->color); QuatCopy (red, dl->color);
break; break;
case EF_BLUE: case EF_BLUE:
QuatCopy (blue, dl->color); QuatCopy (blue, dl->color);
break; break;
default: default:
QuatCopy (normal, dl->color); QuatCopy (normal, dl->color);
break; break;
}
}
if (glow_size) {
dl->radius += glow_size < 128 ? glow_size * 8.0 :
(glow_size - 256) * 8.0;
dl->die = cl.time + 0.1;
if (glow_color) {
if (glow_color == 255) {
dl->color[0] = dl->color[1] = dl->color[2] = 1.0;
} else {
byte *tempcolor;
tempcolor = (byte *) &d_8to24table[glow_color];
VectorScale (tempcolor, 1 / 255.0, dl->color);
}
}
} }
} }
/* /*
CL_LerpPoint CL_LerpPoint
Determines the fraction between the last two messages that the objects Determines the fraction between the last two messages at which the
should be put at. objects should be put.
*/ */
static float static float
CL_LerpPoint (void) CL_LerpPoint (void)
@ -296,7 +316,7 @@ CL_RelinkEntities (void)
ent->lerpflags |= LERP_RESETANIM | LERP_RESETANIM2; ent->lerpflags |= LERP_RESETANIM | LERP_RESETANIM2;
#endif #endif
} }
CL_NewDlight (i, ent->origin, state->effects); CL_NewDlight (i, ent->origin, state->effects, 0, 0);
if (VectorDistance_fast (state->msg_origins[1], ent->origin) if (VectorDistance_fast (state->msg_origins[1], ent->origin)
> (256 * 256)) > (256 * 256))
VectorCopy (ent->origin, state->msg_origins[1]); VectorCopy (ent->origin, state->msg_origins[1]);

View file

@ -101,7 +101,7 @@ const char *svc_strings[] = {
"svc_foundsecret", "svc_foundsecret",
"svc_spawnstaticsound", "svc_spawnstaticsound",
"svc_intermission", "svc_intermission",
"svc_finale", // [string] music [string] text "svc_finale", // [string] text
"svc_cdtrack", // [byte] track [byte] looptrack "svc_cdtrack", // [byte] track [byte] looptrack
"svc_sellscreen", "svc_sellscreen",
"svc_cutscene", "svc_cutscene",

View file

@ -28,8 +28,7 @@
# include "config.h" # include "config.h"
#endif #endif
static __attribute__ ((used)) const char rcsid[] = static __attribute__ ((used)) const char rcsid[] = "$Id$";
"$Id$";
#ifdef HAVE_STRING_H #ifdef HAVE_STRING_H
# include <string.h> # include <string.h>
@ -67,9 +66,9 @@ entity_t cl_flag_ents[MAX_CLIENTS];
entity_t cl_packet_ents[512]; // FIXME: magic number entity_t cl_packet_ents[512]; // FIXME: magic number
void void
CL_ClearEnts () CL_ClearEnts (void)
{ {
unsigned int i; size_t i;
for (i = 0; i < sizeof (cl_packet_ents) / sizeof (cl_packet_ents[0]); i++) for (i = 0; i < sizeof (cl_packet_ents) / sizeof (cl_packet_ents[0]); i++)
CL_Init_Entity (&cl_packet_ents[i]); CL_Init_Entity (&cl_packet_ents[i]);
@ -83,7 +82,7 @@ static void
CL_NewDlight (int key, vec3_t org, int effects, byte glow_size, CL_NewDlight (int key, vec3_t org, int effects, byte glow_size,
byte glow_color) byte glow_color)
{ {
float radius; float radius;
dlight_t *dl; dlight_t *dl;
static quat_t normal = {0.4, 0.2, 0.05, 0.7}; static quat_t normal = {0.4, 0.2, 0.05, 0.7};
static quat_t red = {0.5, 0.05, 0.05, 0.7}; static quat_t red = {0.5, 0.05, 0.05, 0.7};
@ -112,6 +111,7 @@ CL_NewDlight (int key, vec3_t org, int effects, byte glow_size,
radius -= 100; radius -= 100;
dl->radius = radius; dl->radius = radius;
dl->die = cl.time + 0.1; dl->die = cl.time + 0.1;
switch (effects & (EF_RED | EF_BLUE)) { switch (effects & (EF_RED | EF_BLUE)) {
case EF_RED | EF_BLUE: case EF_RED | EF_BLUE:
QuatCopy (purple, dl->color); QuatCopy (purple, dl->color);
@ -136,12 +136,10 @@ CL_NewDlight (int key, vec3_t org, int effects, byte glow_size,
if (glow_color == 255) { if (glow_color == 255) {
dl->color[0] = dl->color[1] = dl->color[2] = 1.0; dl->color[0] = dl->color[1] = dl->color[2] = 1.0;
} else { } else {
unsigned char *tempcolor; byte *tempcolor;
tempcolor = (byte *) &d_8to24table[glow_color]; tempcolor = (byte *) &d_8to24table[glow_color];
dl->color[0] = tempcolor[0] / 255.0; VectorScale (tempcolor, 1 / 255.0, dl->color);
dl->color[1] = tempcolor[1] / 255.0;
dl->color[2] = tempcolor[2] / 255.0;
} }
} }
} }

View file

@ -117,17 +117,13 @@ const char *svc_strings[] = {
"svc_foundsecret", "svc_foundsecret",
"svc_spawnstaticsound", "svc_spawnstaticsound",
"svc_intermission", "svc_intermission",
"svc_finale", "svc_finale", // [string] text
"svc_cdtrack", // [byte] track
"svc_cdtrack",
"svc_sellscreen", "svc_sellscreen",
"svc_smallkick", "svc_smallkick",
"svc_bigkick", "svc_bigkick",
"svc_updateping", "svc_updateping",
"svc_updateentertime", "svc_updateentertime",
"svc_updatestatlong", "svc_updatestatlong",
"svc_muzzleflash", "svc_muzzleflash",
"svc_updateuserinfo", "svc_updateuserinfo",
@ -141,7 +137,6 @@ const char *svc_strings[] = {
"svc_deltapacketentities", "svc_deltapacketentities",
"svc_maxspeed", "svc_maxspeed",
"svc_entgravity", "svc_entgravity",
"svc_setinfo", "svc_setinfo",
"svc_serverinfo", "svc_serverinfo",
"svc_updatepl", "svc_updatepl",
@ -160,6 +155,7 @@ const char *svc_strings[] = {
"NEW PROTOCOL" "NEW PROTOCOL"
}; };
dstring_t *centerprint;
int oldparsecountmod; int oldparsecountmod;
int parsecountmod; int parsecountmod;
double parsecounttime; double parsecounttime;
@ -1173,6 +1169,10 @@ CL_ServerInfo (void)
// movevars.ktjump = atof (value); // movevars.ktjump = atof (value);
// FIXME: need to set to 0.5 otherwise, outside of else structure // FIXME: need to set to 0.5 otherwise, outside of else structure
} }
if (!centerprint)
centerprint = dstring_newstr ();
else
dstring_clearstr (centerprint);
} }
static void static void
@ -1246,7 +1246,7 @@ int received_framecount;
void void
CL_ParseServerMessage (void) CL_ParseServerMessage (void)
{ {
const char *s; const char *str;
static dstring_t *stuffbuf; static dstring_t *stuffbuf;
int cmd = 0, i, j; int cmd = 0, i, j;
@ -1304,55 +1304,60 @@ CL_ParseServerMessage (void)
dstring_t *p = 0; dstring_t *p = 0;
i = MSG_ReadByte (net_message); i = MSG_ReadByte (net_message);
s = MSG_ReadString (net_message); str = MSG_ReadString (net_message);
if (i == PRINT_CHAT) { if (i == PRINT_CHAT) {
if (!CL_Chat_Allow_Message (s)) if (!CL_Chat_Allow_Message (str))
break; break;
// TODO: cl_nofake 2 -- accept fake messages from teammates // TODO: cl_nofake 2 -- accept fake messages from teammates
if (cl_nofake->int_val) { if (cl_nofake->int_val) {
char *c; char *c;
p = dstring_strdup (s); p = dstring_strdup (str);
for (c = p->str; *c; c++) { for (c = p->str; *c; c++) {
if (*c == '\r') if (*c == '\r')
*c = '#'; *c = '#';
} }
s = p->str; str = p->str;
} }
Con_SetOrMask (128); Con_SetOrMask (128);
S_LocalSound ("misc/talk.wav"); S_LocalSound ("misc/talk.wav");
if (cl_chat_e->func) if (cl_chat_e->func)
GIB_Event_Callback (cl_chat_e, 1, s); GIB_Event_Callback (cl_chat_e, 1, str);
Team_ParseChat (s); Team_ParseChat (str);
} }
Sys_Printf ("%s", s); Sys_Printf ("%s", str);
if (p) if (p)
dstring_delete (p); dstring_delete (p);
Con_SetOrMask (0); Con_SetOrMask (0);
break; break;
} }
case svc_centerprint: case svc_centerprint:
Sbar_CenterPrint (MSG_ReadString (net_message)); str = MSG_ReadString (net_message);
if (strcmp (str, centerprint->str)) {
dstring_copystr (centerprint, str);
//FIXME logging
}
Sbar_CenterPrint (str);
break; break;
case svc_stufftext: case svc_stufftext:
s = MSG_ReadString (net_message); str = MSG_ReadString (net_message);
if (s[strlen (s) - 1] == '\n') { if (str[strlen (str) - 1] == '\n') {
if (stuffbuf && stuffbuf->str[0]) { if (stuffbuf && stuffbuf->str[0]) {
Sys_MaskPrintf (SYS_DEV, "stufftext: %s%s\n", Sys_MaskPrintf (SYS_DEV, "stufftext: %s%s\n",
stuffbuf->str, s); stuffbuf->str, str);
Cbuf_AddText (cl_stbuf, stuffbuf->str); Cbuf_AddText (cl_stbuf, stuffbuf->str);
dstring_clearstr (stuffbuf); dstring_clearstr (stuffbuf);
} else { } else {
Sys_MaskPrintf (SYS_DEV, "stufftext: %s\n", s); Sys_MaskPrintf (SYS_DEV, "stufftext: %s\n", str);
} }
Cbuf_AddText (cl_stbuf, s); Cbuf_AddText (cl_stbuf, str);
} else { } else {
Sys_MaskPrintf (SYS_DEV, "partial stufftext: %s\n", s); Sys_MaskPrintf (SYS_DEV, "partial stufftext: %s\n", str);
if (!stuffbuf) if (!stuffbuf)
stuffbuf = dstring_newstr (); stuffbuf = dstring_newstr ();
dstring_appendstr (stuffbuf, s); dstring_appendstr (stuffbuf, str);
} }
break; break;
@ -1507,7 +1512,12 @@ CL_ParseServerMessage (void)
r_force_fullscreen = 1; r_force_fullscreen = 1;
cl.completed_time = realtime; cl.completed_time = realtime;
vid.recalc_refdef = true; // go to full screen vid.recalc_refdef = true; // go to full screen
Sbar_CenterPrint (MSG_ReadString (net_message)); str = MSG_ReadString (net_message);
if (strcmp (str, centerprint->str)) {
dstring_copystr (centerprint, str);
//FIXME logging
}
Sbar_CenterPrint (str);
break; break;
case svc_sellscreen: case svc_sellscreen: