Whitespace.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2001-05-19 23:31:20 +00:00
parent 5569f04a88
commit 2edaee8f5d
2 changed files with 124 additions and 166 deletions

View file

@ -1,8 +1,7 @@
/*
cl_parse.c
@description@
parse a message received from the server
Copyright (C) 1996-1997 Id Software, Inc.
@ -37,56 +36,54 @@
# include <strings.h>
#endif
#include "client.h"
#include "host.h"
#include "QF/cdaudio.h"
#include "QF/cmd.h"
#include "QF/console.h"
#include "QF/msg.h"
#include "QF/sys.h"
#include "sbar.h"
#include "QF/screen.h"
#include "server.h"
#include "QF/sound.h" // FIXME: DEFAULT_SOUND_PACKET_*
#include "game.h"
#include "QF/input.h"
#include "client.h"
#include "host.h"
#include "sbar.h"
#include "server.h"
#include "game.h"
char *svc_strings[] = {
"svc_bad",
"svc_nop",
"svc_disconnect",
"svc_updatestat",
"svc_version", // [long] server version
"svc_setview", // [short] entity number
"svc_sound", // <see code>
"svc_time", // [float] server time
"svc_print", // [string] null terminated string
"svc_stufftext", // [string] stuffed into client's
// console buffer
// the string should be \n terminated
"svc_setangle", // [vec3] set the view angle to this
// absolute value
"svc_version", // [long] server version
"svc_setview", // [short] entity number
"svc_sound", // <see code>
"svc_time", // [float] server time
"svc_print", // [string] null terminated string
"svc_stufftext", // [string] stuffed into client's console
// buffer the string should be \n terminated
"svc_setangle", // [vec3] set view angle to this absolute value
"svc_serverinfo", // [long] version
// [string] signon string
// [string]..[0]model cache [string]...[0]sounds cache
// [string]..[0]item cache
"svc_lightstyle", // [byte] [string]
"svc_updatename", // [byte] [string]
"svc_updatefrags", // [byte] [short]
"svc_clientdata", // <shortbits + data>
"svc_stopsound", // <see code>
"svc_updatecolors", // [byte] [byte]
"svc_particle", // [vec3] <variable>
"svc_damage", // [byte] impact [byte] blood [vec3]
// from
"svc_serverinfo", // [long] version
// [string] signon string
// [string]..[0]model cache
// [string]...[0]sounds cache
// [string]..[0]item cache
"svc_lightstyle", // [byte] [string]
"svc_updatename", // [byte] [string]
"svc_updatefrags", // [byte] [short]
"svc_clientdata", // <shortbits + data>
"svc_stopsound", // <see code>
"svc_updatecolors", // [byte] [byte]
"svc_particle", // [vec3] <variable>
"svc_damage", // [byte] impact [byte] blood [vec3] from
"svc_spawnstatic",
"OBSOLETE svc_spawnbinary",
"svc_spawnbaseline",
"svc_temp_entity", // <variable>
"svc_temp_entity", // <variable>
"svc_setpause",
"svc_signonnum",
"svc_centerprint",
@ -94,8 +91,8 @@ char *svc_strings[] = {
"svc_foundsecret",
"svc_spawnstaticsound",
"svc_intermission",
"svc_finale", // [string] music [string] text
"svc_cdtrack", // [byte] track [byte] looptrack
"svc_finale", // [string] music [string] text
"svc_cdtrack", // [byte] track [byte] looptrack
"svc_sellscreen",
"svc_cutscene"
};
@ -182,7 +179,7 @@ CL_KeepaliveMessage (void)
if (cls.demoplayback)
return;
// read messages from server, should just be nops
// read messages from server, should just be nops
old = *net_message->message;
memcpy (olddata, net_message->message->data, net_message->message->cursize);
@ -206,13 +203,13 @@ CL_KeepaliveMessage (void)
*net_message->message = old;
memcpy (net_message->message->data, olddata, net_message->message->cursize);
// check time
// check time
time = Sys_DoubleTime ();
if (time - lastmsg < 5)
return;
lastmsg = time;
// write out a nop
// write out a nop
Con_Printf ("--> client to server keepalive\n");
MSG_WriteByte (&cls.message, clc_nop);
@ -220,6 +217,7 @@ CL_KeepaliveMessage (void)
SZ_Clear (&cls.message);
}
struct model_s **snd_worldmodel = &cl.worldmodel;
@ -234,8 +232,7 @@ CL_ParseServerInfo (void)
Con_DPrintf ("Serverinfo packet received.\n");
// wipe the client_state_t struct
//
// wipe the client_state_t struct
CL_ClearState ();
// parse protocol version number
@ -244,7 +241,7 @@ CL_ParseServerInfo (void)
Con_Printf ("Server returned version %i, not %i", i, PROTOCOL_VERSION);
return;
}
// parse maxclients
// parse maxclients
cl.maxclients = MSG_ReadByte (net_message);
if (cl.maxclients < 1 || cl.maxclients > MAX_SCOREBOARD) {
Con_Printf ("Bad maxclients (%u) from server\n", cl.maxclients);
@ -252,23 +249,22 @@ CL_ParseServerInfo (void)
}
cl.scores = Hunk_AllocName (cl.maxclients * sizeof (*cl.scores), "scores");
// parse gametype
// parse gametype
cl.gametype = MSG_ReadByte (net_message);
// parse signon message
// parse signon message
str = MSG_ReadString (net_message);
strncpy (cl.levelname, str, sizeof (cl.levelname) - 1);
// seperate the printfs so the server message can have a color
Con_Printf
("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n");
// seperate the printfs so the server message can have a color
Con_Printf ("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n");
Con_Printf ("%c%s\n", 2, str);
// first we go through and touch all of the precache data that still
// happens to be in the cache, so precaching something else doesn't
// needlessly purge it
// precache models
// precache models
memset (cl.model_precache, 0, sizeof (cl.model_precache));
for (nummodels = 1;; nummodels++) {
str = MSG_ReadString (net_message);
@ -282,7 +278,7 @@ CL_ParseServerInfo (void)
Mod_TouchModel (str);
}
// precache sounds
// precache sounds
memset (cl.sound_precache, 0, sizeof (cl.sound_precache));
for (numsounds = 1;; numsounds++) {
str = MSG_ReadString (net_message);
@ -296,7 +292,7 @@ CL_ParseServerInfo (void)
S_TouchSound (str);
}
// now we try to load everything else until a cache allocation fails
// now we try to load everything else until a cache allocation fails
for (i = 1; i < nummodels; i++) {
cl.model_precache[i] = Mod_ForName (model_precache[i], false);
@ -314,8 +310,7 @@ CL_ParseServerInfo (void)
}
S_EndPrecaching ();
// local state
// local state
cl_entities[0].model = cl.worldmodel = cl.model_precache[1];
R_NewMap ();
@ -376,7 +371,7 @@ CL_ParseUpdate (int bits)
forcelink = false;
if (forcelink) {
//FIXME do this right (ie, protocol support)
//FIXME do this right (ie, protocol support)
ent->alpha = 1;
ent->scale = 1;
ent->glow_color = 254;
@ -441,7 +436,7 @@ CL_ParseUpdate (int bits)
else
ent->effects = ent->baseline->effects;
// shift the known values for interpolation
// shift the known values for interpolation
VectorCopy (ent->msg_origins[0], ent->msg_origins[1]);
VectorCopy (ent->msg_angles[0], ent->msg_angles[1]);
@ -540,7 +535,7 @@ CL_ParseClientdata (int bits)
cl.mvelocity[0][i] = 0;
}
// [always sent] if (bits & SU_ITEMS)
// [always sent] if (bits & SU_ITEMS)
i = MSG_ReadLong (net_message);
if (cl.stats[STAT_ITEMS] != i) { // set flash times
@ -626,7 +621,7 @@ CL_ParseStatic (void)
cl.num_statics++;
CL_ParseBaseline (ent);
// copy it to the current state
// copy it to the current state
ent->model = cl.model_precache[ent->baseline->modelindex];
ent->frame = ent->baseline->frame;
ent->colormap = vid.colormap;
@ -667,14 +662,14 @@ CL_ParseStaticSound (void)
int snd_viewentity;
void
CL_ParseServerMessage (void)
{
int cmd;
int i;
// if recording demos, copy the message out
//
// if recording demos, copy the message out
if (cl_shownet->int_val == 1)
Con_Printf ("%i ", net_message->message->cursize);
else if (cl_shownet->int_val == 2)
@ -682,8 +677,7 @@ CL_ParseServerMessage (void)
cl.onground = false; // unless the server says otherwise
// parse the message
//
// parse the message
MSG_BeginReading (net_message);
while (1) {

View file

@ -29,18 +29,17 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
#include <string.h>
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
# include <strings.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
# include <errno.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
# include <unistd.h>
#endif
#include "QF/cdaudio.h"
@ -74,33 +73,30 @@ char *svc_strings[] = {
"svc_nop",
"svc_disconnect",
"svc_updatestat",
"svc_version", // [long] server version
"svc_setview", // [short] entity number
"svc_sound", // <see code>
"svc_time", // [float] server time
"svc_print", // [string] null terminated string
"svc_stufftext", // [string] stuffed into client's
// console buffer
// the string should be \n terminated
"svc_setangle", // [vec3] set the view angle to this
// absolute value
"svc_version", // [long] server version
"svc_setview", // [short] entity number
"svc_sound", // <see code>
"svc_time", // [float] server time
"svc_print", // [string] null terminated string
"svc_stufftext", // [string] stuffed into client's console
// buffer the string should be \n terminated
"svc_setangle", // [vec3] set view angle to this absolute value
"svc_serverdata", // [long] version ...
"svc_lightstyle", // [byte] [string]
"svc_updatename", // [byte] [string]
"svc_updatefrags", // [byte] [short]
"svc_clientdata", // <shortbits + data>
"svc_stopsound", // <see code>
"svc_updatecolors", // [byte] [byte]
"svc_particle", // [vec3] <variable>
"svc_damage", // [byte] impact [byte] blood [vec3]
// from
"svc_serverdata", // [long] version ...
"svc_lightstyle", // [byte] [string]
"svc_updatename", // [byte] [string]
"svc_updatefrags", // [byte] [short]
"svc_clientdata", // <shortbits + data>
"svc_stopsound", // <see code>
"svc_updatecolors", // [byte] [byte]
"svc_particle", // [vec3] <variable>
"svc_damage", // [byte] impact [byte] blood [vec3] from
"svc_spawnstatic",
"OBSOLETE svc_spawnbinary",
"svc_spawnbaseline",
"svc_temp_entity", // <variable>
"svc_temp_entity", // <variable>
"svc_setpause",
"svc_signonnum",
"svc_centerprint",
@ -158,10 +154,9 @@ double parsecounttime;
int cl_spikeindex, cl_playerindex, cl_flagindex;
int cl_h_playerindex, cl_gib1index, cl_gib2index, cl_gib3index;
//=============================================================================
int packet_latency[NET_TIMINGS];
int
CL_CalcNet (void)
{
@ -192,7 +187,6 @@ CL_CalcNet (void)
return lost * 100 / NET_TIMINGS;
}
//=============================================================================
/*
CL_CheckOrDownloadFile
@ -249,10 +243,10 @@ CL_CheckOrDownloadFile (char *filename)
return false;
}
struct model_s **snd_worldmodel = &cl.worldmodel;
/*
Model_NextDownload
*/
void
Model_NextDownload (void)
{
@ -314,9 +308,7 @@ Model_NextDownload (void)
cl.worldmodel->checksum2));
}
/*
Sound_NextDownload
*/
void
Sound_NextDownload (void)
{
@ -356,9 +348,6 @@ Sound_NextDownload (void)
}
/*
CL_RequestNextDownload
*/
void
CL_RequestNextDownload (void)
{
@ -380,6 +369,7 @@ CL_RequestNextDownload (void)
}
}
/*
CL_ParseDownload
@ -457,7 +447,7 @@ CL_ParseDownload (void)
net_message->readcount += size;
if (percent != 100) {
// change display routines by zoid
// change display routines by zoid
// request next block
#if 0
Con_Printf (".");
@ -467,8 +457,8 @@ CL_ParseDownload (void)
}
#endif
if (percent != cls.downloadpercent)
VID_SetCaption (va
("Downloading %s %d%%", cls.downloadname, percent));
VID_SetCaption (va ("Downloading %s %d%%", cls.downloadname,
percent));
cls.downloadpercent = percent;
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
@ -511,10 +501,12 @@ CL_ParseDownload (void)
}
}
static byte *upload_data;
static int upload_pos;
static int upload_size;
void
CL_NextUpload (void)
{
@ -573,6 +565,7 @@ CL_StartUpload (byte * data, int size)
CL_NextUpload ();
}
qboolean
CL_IsUploading (void)
{
@ -581,6 +574,7 @@ CL_IsUploading (void)
return false;
}
void
CL_StopUpload (void)
{
@ -589,10 +583,12 @@ CL_StopUpload (void)
upload_data = NULL;
}
/*
SERVER CONNECTING MESSAGES
*/
void Draw_ClearCache (void);
void CL_ClearBaselines (void); // LordHavoc: BIG BUG-FIX!
@ -601,9 +597,7 @@ void CL_ClearBaselines (void); // LordHavoc: BIG BUG-FIX!
// (pending merge of nq and qw client_stat_t's)
int snd_viewentity;
/*
CL_ParseServerData
*/
void
CL_ParseServerData (void)
{
@ -614,13 +608,12 @@ CL_ParseServerData (void)
int protover;
Con_DPrintf ("Serverdata packet received.\n");
//
// wipe the client_state_t struct
//
// wipe the client_state_t struct
CL_ClearState ();
// parse protocol version number
// allow 2.2 and 2.29 demos to play
// parse protocol version number
// allow 2.2 and 2.29 demos to play
protover = MSG_ReadLong (net_message);
if (protover != PROTOCOL_VERSION &&
!(cls.demoplayback
@ -664,7 +657,7 @@ CL_ParseServerData (void)
cl.playernum &= ~128;
}
// FIXME: evil hack so NQ and QW can share sound code
// FIXME: evil hack so NQ and QW can share sound code
cl.viewentity = cl.playernum + 1;
snd_viewentity = cl.playernum + 1;
@ -685,8 +678,7 @@ CL_ParseServerData (void)
movevars.entgravity = MSG_ReadFloat (net_message);
// seperate the printfs so the server message can have a color
Con_Printf
("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n");
Con_Printf ("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n");
Con_Printf ("%c%s\n", 2, str);
// ask for the sound list next
@ -701,6 +693,7 @@ CL_ParseServerData (void)
CL_ClearBaselines ();
}
// LordHavoc: BIG BUG-FIX! Clear baselines each time it connects...
void
CL_ClearBaselines (void)
@ -717,9 +710,7 @@ CL_ClearBaselines (void)
}
}
/*
CL_ParseSoundlist
*/
void
CL_ParseSoundlist (void)
{
@ -727,8 +718,8 @@ CL_ParseSoundlist (void)
char *str;
int n;
// precache sounds
// memset (cl.sound_precache, 0, sizeof(cl.sound_precache));
// precache sounds
// memset (cl.sound_precache, 0, sizeof(cl.sound_precache));
numsounds = MSG_ReadByte (net_message);
@ -756,9 +747,7 @@ CL_ParseSoundlist (void)
Sound_NextDownload ();
}
/*
CL_ParseModellist
*/
void
CL_ParseModellist (void)
{
@ -766,7 +755,7 @@ CL_ParseModellist (void)
char *str;
int n;
// precache models and note certain default indexes
// precache models and note certain default indexes
nummodels = MSG_ReadByte (net_message);
for (;;) {
@ -784,7 +773,7 @@ CL_ParseModellist (void)
cl_playerindex = nummodels;
else if (!strcmp (cl.model_name[nummodels], "progs/flag.mdl"))
cl_flagindex = nummodels;
// for deadbodyfilter &gibfilter
// for deadbodyfilter & gibfilter
else if (!strcmp (cl.model_name[nummodels], "progs/h_player.mdl"))
cl_h_playerindex = nummodels;
else if (!strcmp (cl.model_name[nummodels], "progs/gib1.mdl"))
@ -809,9 +798,7 @@ CL_ParseModellist (void)
Model_NextDownload ();
}
/*
CL_ParseBaseline
*/
void
CL_ParseBaseline (entity_state_t *es)
{
@ -835,7 +822,6 @@ CL_ParseBaseline (entity_state_t *es)
}
/*
CL_ParseStatic
@ -866,9 +852,7 @@ CL_ParseStatic (void)
R_AddEfrags (ent);
}
/*
CL_ParseStaticSound
*/
void
CL_ParseStaticSound (void)
{
@ -886,14 +870,11 @@ CL_ParseStaticSound (void)
}
/*
ACTION MESSAGES
*/
/*
CL_ParseStartSoundPacket
*/
void
CL_ParseStartSoundPacket (void)
{
@ -944,7 +925,7 @@ CL_ParseClientdata (void)
float latency;
frame_t *frame;
// calculate simulated time of message
// calculate simulated time of message
oldparsecountmod = parsecountmod;
i = cls.netchan.incoming_acknowledged;
@ -956,23 +937,21 @@ CL_ParseClientdata (void)
frame->receivedtime = realtime;
// calculate latency
// calculate latency
latency = frame->receivedtime - frame->senttime;
if (latency < 0 || latency > 1.0) {
// Con_Printf ("Odd latency: %5.2f\n", latency);
// Con_Printf ("Odd latency: %5.2f\n", latency);
} else {
// drift the average latency towards the observed latency
if (latency < cls.latency)
cls.latency = latency;
else
cls.latency += 0.001; // drift up, so correction are needed
cls.latency += 0.001; // drift up, so correction is needed
}
}
/*
CL_UpdateUserinfo
*/
void
CL_ProcessUserInfo (int slot, player_info_t *player)
{
@ -994,9 +973,7 @@ CL_ProcessUserInfo (int slot, player_info_t *player)
CL_NewTranslation (slot);
}
/*
CL_UpdateUserinfo
*/
void
CL_UpdateUserinfo (void)
{
@ -1016,9 +993,7 @@ CL_UpdateUserinfo (void)
CL_ProcessUserInfo (slot, player);
}
/*
CL_SetInfo
*/
void
CL_SetInfo (void)
{
@ -1045,9 +1020,7 @@ CL_SetInfo (void)
CL_ProcessUserInfo (slot, player);
}
/*
CL_ServerInfo
*/
void
CL_ServerInfo (void)
{
@ -1064,16 +1037,14 @@ CL_ServerInfo (void)
Info_SetValueForKey (cl.serverinfo, key, value, MAX_SERVERINFO_STRING);
}
/*
CL_SetStat
*/
void
CL_SetStat (int stat, int value)
{
int j;
if (stat < 0 || stat >= MAX_CL_STATS)
// Sys_Error ("CL_SetStat: %i is invalid", stat);
// Sys_Error ("CL_SetStat: %i is invalid", stat);
Host_EndGame ("CL_SetStat: %i is invalid", stat);
Sbar_Changed ();
@ -1094,9 +1065,7 @@ CL_SetStat (int stat, int value)
cl.stats[stat] = value;
}
/*
CL_MuzzleFlash
*/
void
CL_MuzzleFlash (void)
{
@ -1128,10 +1097,9 @@ CL_MuzzleFlash (void)
#define SHOWNET(x) if (cl_shownet->int_val == 2) Con_Printf ("%3i:%s\n", net_message->readcount-1, x);
/*
CL_ParseServerMessage
*/
int received_framecount;
void
CL_ParseServerMessage (void)
{
@ -1143,9 +1111,7 @@ CL_ParseServerMessage (void)
cl.last_servermessage = realtime;
CL_ClearProjectiles ();
//
// if recording demos, copy the message out
//
// if recording demos, copy the message out
if (cl_shownet->int_val == 1)
Con_Printf ("%i ", net_message->message->cursize);
else if (cl_shownet->int_val == 2)
@ -1154,9 +1120,7 @@ CL_ParseServerMessage (void)
CL_ParseClientdata ();
//
// parse the message
//
// parse the message
while (1) {
if (net_message->badread) {
Host_EndGame ("CL_ParseServerMessage: Bad server message");
@ -1166,7 +1130,7 @@ CL_ParseServerMessage (void)
cmd = MSG_ReadByte (net_message);
if (cmd == -1) {
net_message->readcount++; // so the EOM showner has the right
net_message->readcount++; // so the EOM showner has the right
// value
SHOWNET ("END OF MESSAGE");
break;
@ -1182,7 +1146,7 @@ CL_ParseServerMessage (void)
break;
case svc_nop:
// Con_Printf ("svc_nop\n");
// Con_Printf ("svc_nop\n");
break;
case svc_disconnect:
@ -1237,13 +1201,13 @@ CL_ParseServerMessage (void)
case svc_setangle:
for (i = 0; i < 3; i++)
cl.viewangles[i] = MSG_ReadAngle (net_message);
// cl.viewangles[PITCH] = cl.viewangles[ROLL] = 0;
// cl.viewangles[PITCH] = cl.viewangles[ROLL] = 0;
break;
case svc_lightstyle:
i = MSG_ReadByte (net_message);
if (i >= MAX_LIGHTSTYLES)
// Sys_Error ("svc_lightstyle > MAX_LIGHTSTYLES");
// Sys_Error ("svc_lightstyle > MAX_LIGHTSTYLES");
Host_EndGame ("svc_lightstyle > MAX_LIGHTSTYLES");
strcpy (cl_lightstyle[i].map, MSG_ReadString (net_message));
cl_lightstyle[i].length = strlen (cl_lightstyle[i].map);