MSG_(Read|Write)(Coord|Angle|CoordAngle)V. Cleanups, and preparation for use of vector ops in msg.c.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2001-12-12 21:56:09 +00:00
parent 195dd1032e
commit 2db08923e8
20 changed files with 247 additions and 396 deletions

View file

@ -36,9 +36,12 @@ void MSG_WriteShort (sizebuf_t *sb, unsigned int c);
void MSG_WriteLong (sizebuf_t *sb, unsigned int c); void MSG_WriteLong (sizebuf_t *sb, unsigned int c);
void MSG_WriteFloat (sizebuf_t *sb, float f); void MSG_WriteFloat (sizebuf_t *sb, float f);
void MSG_WriteString (sizebuf_t *sb, const char *s); void MSG_WriteString (sizebuf_t *sb, const char *s);
void MSG_WriteCoord (sizebuf_t *sb, float f); void MSG_WriteCoord (sizebuf_t *sb, float coord);
void MSG_WriteAngle (sizebuf_t *sb, float f); void MSG_WriteCoordV (sizebuf_t *sb, vec3_t coord);
void MSG_WriteAngle16 (sizebuf_t *sb, float f); void MSG_WriteCoordAngleV (sizebuf_t *sb, vec3_t coord, vec3_t angles);
void MSG_WriteAngle (sizebuf_t *sb, float angle);
void MSG_WriteAngleV (sizebuf_t *sb, vec3_t angles);
void MSG_WriteAngle16 (sizebuf_t *sb, float angle16);
typedef struct msg_s { typedef struct msg_s {
int readcount; int readcount;
@ -59,8 +62,10 @@ const char *MSG_ReadString (msg_t *msg);
const char *MSG_ReadStringLine (msg_t *msg); const char *MSG_ReadStringLine (msg_t *msg);
float MSG_ReadCoord (msg_t *msg); float MSG_ReadCoord (msg_t *msg);
void MSG_ReadCoord3 (msg_t *msg, vec3_t coord); void MSG_ReadCoordV (msg_t *msg, vec3_t coord);
float MSG_ReadAngle (msg_t *msg); float MSG_ReadAngle (msg_t *msg);
void MSG_ReadCoordAngleV (msg_t *msg, vec3_t coord, vec3_t angles);
void MSG_ReadAngleV (msg_t *msg, vec3_t angles);
float MSG_ReadAngle16 (msg_t *msg); float MSG_ReadAngle16 (msg_t *msg);
#endif #endif

View file

@ -116,21 +116,50 @@ MSG_WriteString (sizebuf_t *sb, const char *s)
} }
void void
MSG_WriteCoord (sizebuf_t *sb, float f) MSG_WriteCoord (sizebuf_t *sb, float coord)
{ {
MSG_WriteShort (sb, (unsigned int) (f * 8.0)); MSG_WriteShort (sb, (unsigned int) (coord * 8.0));
} }
void void
MSG_WriteAngle (sizebuf_t *sb, float f) MSG_WriteCoordV (sizebuf_t *sb, vec3_t coord)
{ {
MSG_WriteByte (sb, (unsigned int) (f * 256 / 360) & 255); int i;
for (i = 0; i < 3; i++)
MSG_WriteShort (sb, (unsigned int) (coord[i] * 8.0));
} }
void void
MSG_WriteAngle16 (sizebuf_t *sb, float f) MSG_WriteCoordAngleV (sizebuf_t *sb, vec3_t coord, vec3_t angles)
{ {
MSG_WriteShort (sb, (unsigned int) (f * 65536 / 360) & 65535); int i;
for (i = 0; i < 3; i++) {
MSG_WriteShort (sb, (unsigned int) (coord[i] * 8.0));
MSG_WriteByte (sb, (unsigned int) (angles[i] * 256 / 360) & 255);
}
}
void
MSG_WriteAngle (sizebuf_t *sb, float angle)
{
MSG_WriteByte (sb, (unsigned int) (angle * 256 / 360) & 255);
}
void
MSG_WriteAngleV (sizebuf_t *sb, vec3_t angles)
{
int i;
for (i = 0; i < 3; i++)
MSG_WriteByte (sb, (unsigned int) (angles[i] * 256 / 360) & 255);
}
void
MSG_WriteAngle16 (sizebuf_t *sb, float angle16)
{
MSG_WriteShort (sb, (unsigned int) (angle16 * 65536 / 360) & 65535);
} }
@ -272,11 +301,23 @@ MSG_ReadCoord (msg_t *msg)
} }
void void
MSG_ReadCoord3 (msg_t *msg, vec3_t coord) MSG_ReadCoordV (msg_t *msg, vec3_t coord)
{ {
coord[0] = MSG_ReadShort (msg) * (1.0 / 8.0); int i;
coord[1] = MSG_ReadShort (msg) * (1.0 / 8.0);
coord[2] = MSG_ReadShort (msg) * (1.0 / 8.0); for (i = 0; i < 3; i++)
coord[i] = MSG_ReadShort (msg) * (1.0 / 8.0);
}
void
MSG_ReadCoordAngleV (msg_t *msg, vec3_t coord, vec3_t angles)
{
int i;
for (i = 0; i < 3; i++) {
coord[i] = MSG_ReadShort (msg) * (1.0 / 8.0);
angles[i] = MSG_ReadChar (msg) * (360.0 / 256.0);
}
} }
float float
@ -285,6 +326,15 @@ MSG_ReadAngle (msg_t *msg)
return MSG_ReadChar (msg) * (360.0 / 256.0); return MSG_ReadChar (msg) * (360.0 / 256.0);
} }
void
MSG_ReadAngleV (msg_t *msg, vec3_t angles)
{
int i;
for (i = 0; i < 3; i++)
angles[i] = MSG_ReadChar (msg) * (360.0 / 256.0);
}
float float
MSG_ReadAngle16 (msg_t *msg) MSG_ReadAngle16 (msg_t *msg)
{ {

View file

@ -540,7 +540,7 @@ void
CL_SendMove (usercmd_t *cmd) CL_SendMove (usercmd_t *cmd)
{ {
byte data[128]; byte data[128];
int bits, i; int bits;
sizebuf_t buf; sizebuf_t buf;
buf.maxsize = 128; buf.maxsize = 128;
@ -554,8 +554,7 @@ CL_SendMove (usercmd_t *cmd)
MSG_WriteFloat (&buf, cl.mtime[0]); // so server can get ping times MSG_WriteFloat (&buf, cl.mtime[0]); // so server can get ping times
for (i = 0; i < 3; i++) MSG_WriteAngleV (&buf, cl.viewangles);
MSG_WriteAngle (&buf, cl.viewangles[i]);
MSG_WriteShort (&buf, cmd->forwardmove); MSG_WriteShort (&buf, cmd->forwardmove);
MSG_WriteShort (&buf, cmd->sidemove); MSG_WriteShort (&buf, cmd->sidemove);

View file

@ -151,7 +151,7 @@ CL_ParseStartSoundPacket (void)
if (ent > MAX_EDICTS) if (ent > MAX_EDICTS)
Host_Error ("CL_ParseStartSoundPacket: ent = %i", ent); Host_Error ("CL_ParseStartSoundPacket: ent = %i", ent);
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, S_StartSound (ent, channel, cl.sound_precache[sound_num], pos,
volume / 255.0, attenuation); volume / 255.0, attenuation);
@ -484,18 +484,15 @@ CL_ParseUpdate (int bits)
void void
CL_ParseBaseline (cl_entity_state_t *state) CL_ParseBaseline (cl_entity_state_t *state)
{ {
int i;
state->baseline.modelindex = MSG_ReadByte (net_message); state->baseline.modelindex = MSG_ReadByte (net_message);
state->baseline.frame = MSG_ReadByte (net_message); state->baseline.frame = MSG_ReadByte (net_message);
state->baseline.colormap = MSG_ReadByte (net_message); state->baseline.colormap = MSG_ReadByte (net_message);
state->baseline.skin = MSG_ReadByte (net_message); state->baseline.skin = MSG_ReadByte (net_message);
for (i = 0; i < 3; i++) {
state->baseline.origin[i] = MSG_ReadCoord (net_message); MSG_ReadCoordAngleV (net_message, state->baseline.origin,
state->baseline.angles[i] = MSG_ReadAngle (net_message); state->baseline.angles);
}
// LordHavoc: set up the baseline to account for new effects (alpha, // LordHavoc: set up baseline for new effects (alpha, colormod, etc)
// colormod, etc)
state->baseline.alpha = 255; state->baseline.alpha = 255;
state->baseline.scale = 16; state->baseline.scale = 16;
state->baseline.glow_color = 254; state->baseline.glow_color = 254;
@ -646,7 +643,7 @@ CL_ParseStaticSound (void)
int sound_num, vol, atten; int sound_num, vol, atten;
vec3_t org; vec3_t org;
MSG_ReadCoord3 (net_message, org); MSG_ReadCoordV (net_message, org);
sound_num = MSG_ReadByte (net_message); sound_num = MSG_ReadByte (net_message);
vol = MSG_ReadByte (net_message); vol = MSG_ReadByte (net_message);
atten = MSG_ReadByte (net_message); atten = MSG_ReadByte (net_message);
@ -746,8 +743,7 @@ CL_ParseServerMessage (void)
break; break;
case svc_setangle: case svc_setangle:
for (i = 0; i < 3; i++) MSG_ReadAngleV (net_message, cl.viewangles);
cl.viewangles[i] = MSG_ReadAngle (net_message);
break; break;
case svc_setview: case svc_setview:
@ -778,7 +774,7 @@ CL_ParseServerMessage (void)
if (i >= cl.maxclients) if (i >= cl.maxclients)
Host_Error ("CL_ParseServerMessage: svc_updatename > " Host_Error ("CL_ParseServerMessage: svc_updatename > "
"MAX_SCOREBOARD"); "MAX_SCOREBOARD");
strcpy (cl.scores[i].name, MSG_ReadString (net_message)); strcpy (cl.scores[i].name, MSG_ReadString (net_message));
break; break;
case svc_updatefrags: case svc_updatefrags:

View file

@ -186,8 +186,8 @@ CL_ParseBeam (model_t *m)
ent = MSG_ReadShort (net_message); ent = MSG_ReadShort (net_message);
MSG_ReadCoord3 (net_message, start); MSG_ReadCoordV (net_message, start);
MSG_ReadCoord3 (net_message, end); MSG_ReadCoordV (net_message, end);
// override any beam with the same entity // override any beam with the same entity
for (i = 0, b = cl_beams; i < MAX_BEAMS; i++, b++) for (i = 0, b = cl_beams; i < MAX_BEAMS; i++, b++)
@ -233,19 +233,19 @@ CL_ParseTEnt (void)
} }
switch (type) { switch (type) {
case TE_WIZSPIKE: // spike hitting wall case TE_WIZSPIKE: // spike hitting wall
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_WizSpikeEffect (pos); R_WizSpikeEffect (pos);
S_StartSound (-1, 0, cl_sfx_wizhit, pos, 1, 1); S_StartSound (-1, 0, cl_sfx_wizhit, pos, 1, 1);
break; break;
case TE_KNIGHTSPIKE: // spike hitting wall case TE_KNIGHTSPIKE: // spike hitting wall
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_KnightSpikeEffect (pos); R_KnightSpikeEffect (pos);
S_StartSound (-1, 0, cl_sfx_knighthit, pos, 1, 1); S_StartSound (-1, 0, cl_sfx_knighthit, pos, 1, 1);
break; break;
case TE_SPIKE: // spike hitting wall case TE_SPIKE: // spike hitting wall
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_SpikeEffect (pos); R_SpikeEffect (pos);
if (rand () % 5) if (rand () % 5)
@ -262,7 +262,7 @@ CL_ParseTEnt (void)
break; break;
case TE_SUPERSPIKE: // super spike hitting wall case TE_SUPERSPIKE: // super spike hitting wall
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_SuperSpikeEffect (pos); R_SuperSpikeEffect (pos);
if (rand () % 5) if (rand () % 5)
@ -280,7 +280,7 @@ CL_ParseTEnt (void)
case TE_EXPLOSION: // rocket explosion case TE_EXPLOSION: // rocket explosion
// particles // particles
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_ParticleExplosion (pos); R_ParticleExplosion (pos);
// light // light
@ -304,7 +304,7 @@ CL_ParseTEnt (void)
break; break;
case TE_TAREXPLOSION: // tarbaby explosion case TE_TAREXPLOSION: // tarbaby explosion
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_BlobExplosion (pos); R_BlobExplosion (pos);
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
@ -329,17 +329,17 @@ CL_ParseTEnt (void)
// PGM 01/21/97 // PGM 01/21/97
case TE_LAVASPLASH: case TE_LAVASPLASH:
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_LavaSplash (pos); R_LavaSplash (pos);
break; break;
case TE_TELEPORT: case TE_TELEPORT:
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_TeleportSplash (pos); R_TeleportSplash (pos);
break; break;
case TE_EXPLOSION2: // color mapped explosion case TE_EXPLOSION2: // color mapped explosion
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
colorStart = MSG_ReadByte (net_message); colorStart = MSG_ReadByte (net_message);
colorLength = MSG_ReadByte (net_message); colorLength = MSG_ReadByte (net_message);
R_ParticleExplosion2 (pos, colorStart, colorLength); R_ParticleExplosion2 (pos, colorStart, colorLength);
@ -358,18 +358,18 @@ CL_ParseTEnt (void)
break; break;
case TE_GUNSHOT: // bullet hitting wall case TE_GUNSHOT: // bullet hitting wall
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_GunshotEffect (pos, 20); R_GunshotEffect (pos, 20);
break; break;
case TE_BLOOD: // bullet hitting body case TE_BLOOD: // bullet hitting body
cnt = MSG_ReadByte (net_message) * 20; cnt = MSG_ReadByte (net_message) * 20;
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_BloodPuffEffect (pos, cnt); R_BloodPuffEffect (pos, cnt);
break; break;
case TE_LIGHTNINGBLOOD: // lightning hitting body case TE_LIGHTNINGBLOOD: // lightning hitting body
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
// light // light
dl = R_AllocDlight (0); dl = R_AllocDlight (0);
@ -490,7 +490,7 @@ CL_ParseParticleEffect (void)
int i, count, color; int i, count, color;
vec3_t org, dir; vec3_t org, dir;
MSG_ReadCoord3 (net_message, org); MSG_ReadCoordV (net_message, org);
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
dir[i] = MSG_ReadChar (net_message) * (15.0 / 16.0); dir[i] = MSG_ReadChar (net_message) * (15.0 / 16.0);
count = MSG_ReadByte (net_message); count = MSG_ReadByte (net_message);

View file

@ -216,7 +216,7 @@ V_ParseDamage (void)
armor = MSG_ReadByte (net_message); armor = MSG_ReadByte (net_message);
blood = MSG_ReadByte (net_message); blood = MSG_ReadByte (net_message);
MSG_ReadCoord3 (net_message, from); MSG_ReadCoordV (net_message, from);
count = blood * 0.5 + armor * 0.5; count = blood * 0.5 + armor * 0.5;
if (count < 10) if (count < 10)

View file

@ -52,11 +52,6 @@ int current_skill;
void Mod_Print (void); void Mod_Print (void);
/*
==================
Host_Quit_f
==================
*/
void void
Host_Quit_f (void) Host_Quit_f (void)
@ -71,12 +66,6 @@ Host_Quit_f (void)
Sys_Quit (); Sys_Quit ();
} }
/*
==================
Host_Status_f
==================
*/
void void
Host_Status_f (void) Host_Status_f (void)
{ {
@ -125,11 +114,9 @@ Host_Status_f (void)
/* /*
================== Host_God_f
Host_God_f
Sets client to godmode Sets client to godmode
==================
*/ */
void void
Host_God_f (void) Host_God_f (void)
@ -160,7 +147,8 @@ Host_Notarget_f (void)
if (*sv_globals.deathmatch && !host_client->privileged) if (*sv_globals.deathmatch && !host_client->privileged)
return; return;
SVfloat (sv_player, flags) = (int) SVfloat (sv_player, flags) ^ FL_NOTARGET; SVfloat (sv_player, flags) = (int) SVfloat (sv_player, flags) ^
FL_NOTARGET;
if (!((int) SVfloat (sv_player, flags) & FL_NOTARGET)) if (!((int) SVfloat (sv_player, flags) & FL_NOTARGET))
SV_ClientPrintf ("notarget OFF\n"); SV_ClientPrintf ("notarget OFF\n");
else else
@ -192,11 +180,9 @@ Host_Noclip_f (void)
} }
/* /*
================== Host_Fly_f
Host_Fly_f
Sets client to flymode Sets client to flymode
==================
*/ */
void void
Host_Fly_f (void) Host_Fly_f (void)
@ -218,13 +204,6 @@ Host_Fly_f (void)
} }
} }
/*
==================
Host_Ping_f
==================
*/
void void
Host_Ping_f (void) Host_Ping_f (void)
{ {
@ -249,23 +228,14 @@ Host_Ping_f (void)
} }
} }
/* // SERVER TRANSITIONS =========================================================
===============================================================================
SERVER TRANSITIONS
===============================================================================
*/
/* /*
====================== Host_Map_f
Host_Map_f
handle a handle a
map <servername> map <servername>
command from the console. Active clients are kicked off. command from the console. Active clients are kicked off.
======================
*/ */
void void
Host_Map_f (void) Host_Map_f (void)
@ -315,11 +285,9 @@ Host_Map_f (void)
} }
/* /*
================== Host_Changelevel_f
Host_Changelevel_f
Goes to a new map, taking all clients along Goes to a new map, taking all clients along
==================
*/ */
void void
Host_Changelevel_f (void) Host_Changelevel_f (void)
@ -327,7 +295,8 @@ Host_Changelevel_f (void)
char level[MAX_QPATH]; char level[MAX_QPATH];
if (Cmd_Argc () != 2) { if (Cmd_Argc () != 2) {
Con_Printf ("changelevel <levelname> : continue game on a new level\n"); Con_Printf ("changelevel <levelname> : continue game on a new "
"level\n");
return; return;
} }
if (!sv.active || cls.demoplayback) { if (!sv.active || cls.demoplayback) {
@ -340,11 +309,9 @@ Host_Changelevel_f (void)
} }
/* /*
================== Host_Restart_f
Host_Restart_f
Restarts the current server for a dead player Restarts the current server for a dead player
==================
*/ */
void void
Host_Restart_f (void) Host_Restart_f (void)
@ -357,18 +324,15 @@ Host_Restart_f (void)
if (cmd_source != src_command) if (cmd_source != src_command)
return; return;
strcpy (mapname, sv.name); // must copy out, because it gets strcpy (mapname, sv.name); // must copy out, because it gets
// cleared // cleared in sv_spawnserver
// in sv_spawnserver
SV_SpawnServer (mapname); SV_SpawnServer (mapname);
} }
/* /*
================== Host_Reconnect_f
Host_Reconnect_f
This command causes the client to wait for the signon messages again. This command causes the client to wait for the signon messages again.
This is sent just before a server changes levels This is sent just before a server changes levels
==================
*/ */
void void
Host_Reconnect_f (void) Host_Reconnect_f (void)
@ -378,11 +342,9 @@ Host_Reconnect_f (void)
} }
/* /*
===================== Host_Connect_f
Host_Connect_f
User command to connect to server User command to connect to server
=====================
*/ */
void void
Host_Connect_f (void) Host_Connect_f (void)
@ -399,23 +361,14 @@ Host_Connect_f (void)
Host_Reconnect_f (); Host_Reconnect_f ();
} }
// LOAD / SAVE GAME ===========================================================
/*
===============================================================================
LOAD / SAVE GAME
===============================================================================
*/
#define SAVEGAME_VERSION 5 #define SAVEGAME_VERSION 5
/* /*
=============== Host_SavegameComment
Host_SavegameComment
Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current
===============
*/ */
void void
Host_SavegameComment (char *text) Host_SavegameComment (char *text)
@ -429,19 +382,13 @@ Host_SavegameComment (char *text)
snprintf (kills, sizeof (kills), "kills:%3i/%3i", cl.stats[STAT_MONSTERS], snprintf (kills, sizeof (kills), "kills:%3i/%3i", cl.stats[STAT_MONSTERS],
cl.stats[STAT_TOTALMONSTERS]); cl.stats[STAT_TOTALMONSTERS]);
memcpy (text + 22, kills, strlen (kills)); memcpy (text + 22, kills, strlen (kills));
// convert space to _ to make stdio happy // convert space to _ to make stdio happy
for (i = 0; i < SAVEGAME_COMMENT_LENGTH; i++) for (i = 0; i < SAVEGAME_COMMENT_LENGTH; i++)
if (text[i] == ' ') if (text[i] == ' ')
text[i] = '_'; text[i] = '_';
text[SAVEGAME_COMMENT_LENGTH] = '\0'; text[SAVEGAME_COMMENT_LENGTH] = '\0';
} }
/*
===============
Host_Savegame_f
===============
*/
void void
Host_Savegame_f (void) Host_Savegame_f (void)
{ {
@ -479,7 +426,8 @@ Host_Savegame_f (void)
} }
for (i = 0; i < svs.maxclients; i++) { for (i = 0; i < svs.maxclients; i++) {
if (svs.clients[i].active && (SVfloat (svs.clients[i].edict, health) <= 0)) { if (svs.clients[i].active && (SVfloat (svs.clients[i].edict, health)
<= 0)) {
Con_Printf ("Can't savegame with a dead player\n"); Con_Printf ("Can't savegame with a dead player\n");
return; return;
} }
@ -504,8 +452,7 @@ Host_Savegame_f (void)
Qprintf (f, "%s\n", sv.name); Qprintf (f, "%s\n", sv.name);
Qprintf (f, "%f\n", sv.time); Qprintf (f, "%f\n", sv.time);
// write the light styles // write the light styles
for (i = 0; i < MAX_LIGHTSTYLES; i++) { for (i = 0; i < MAX_LIGHTSTYLES; i++) {
if (sv.lightstyles[i]) if (sv.lightstyles[i])
Qprintf (f, "%s\n", sv.lightstyles[i]); Qprintf (f, "%s\n", sv.lightstyles[i]);
@ -523,12 +470,6 @@ Host_Savegame_f (void)
Con_Printf ("done.\n"); Con_Printf ("done.\n");
} }
/*
===============
Host_Loadgame_f
===============
*/
void void
Host_Loadgame_f (void) Host_Loadgame_f (void)
{ {
@ -558,8 +499,8 @@ Host_Loadgame_f (void)
snprintf (name, sizeof (name), "%s/%s", com_gamedir, Cmd_Argv (1)); snprintf (name, sizeof (name), "%s/%s", com_gamedir, Cmd_Argv (1));
COM_DefaultExtension (name, ".sav"); COM_DefaultExtension (name, ".sav");
// we can't call SCR_BeginLoadingPlaque, because too much stack space has // we can't call SCR_BeginLoadingPlaque, because too much stack space has
// been used. The menu calls it before stuffing loadgame command // been used. The menu calls it before stuffing loadgame command
// SCR_BeginLoadingPlaque (); // SCR_BeginLoadingPlaque ();
Con_Printf ("Loading game from %s...\n", name); Con_Printf ("Loading game from %s...\n", name);
@ -583,7 +524,8 @@ Host_Loadgame_f (void)
Qgets (f, buf, sizeof (buf)); Qgets (f, buf, sizeof (buf));
sscanf (buf, "%f\n", &spawn_parms[i]); sscanf (buf, "%f\n", &spawn_parms[i]);
} }
// this silliness is so we can load 1.06 save files, which have float skill values // this silliness is so we can load 1.06 save files, which have float skill
// values
Qgets (f, buf, sizeof (buf)); Qgets (f, buf, sizeof (buf));
sscanf (buf, "%f\n", &tfloat); sscanf (buf, "%f\n", &tfloat);
current_skill = (int) (tfloat + 0.1); current_skill = (int) (tfloat + 0.1);
@ -604,8 +546,7 @@ Host_Loadgame_f (void)
sv.paused = true; // pause until all clients connect sv.paused = true; // pause until all clients connect
sv.loadgame = true; sv.loadgame = true;
// load the light styles // load the light styles
for (i = 0; i < MAX_LIGHTSTYLES; i++) { for (i = 0; i < MAX_LIGHTSTYLES; i++) {
Qgets (f, buf, sizeof (buf)); Qgets (f, buf, sizeof (buf));
sscanf (buf, "%s\n", str); sscanf (buf, "%s\n", str);
@ -613,7 +554,7 @@ Host_Loadgame_f (void)
strcpy (sv.lightstyles[i], str); strcpy (sv.lightstyles[i], str);
} }
// load the edicts out of the savegame file // load the edicts out of the savegame file
entnum = -1; // -1 is the globals entnum = -1; // -1 is the globals
while (!Qeof (f)) { while (!Qeof (f)) {
for (i = 0; i < sizeof (str) - 1; i++) { for (i = 0; i < sizeof (str) - 1; i++) {
@ -667,14 +608,8 @@ Host_Loadgame_f (void)
} }
} }
//============================================================================ //============================================================================
/*
======================
Host_Name_f
======================
*/
void void
Host_Name_f (void) Host_Name_f (void)
{ {
@ -705,14 +640,12 @@ Host_Name_f (void)
SVstring (host_client->edict, netname) = SVstring (host_client->edict, netname) =
PR_SetString (&sv_pr_state, host_client->name); PR_SetString (&sv_pr_state, host_client->name);
// send notification to all clients // send notification to all clients
MSG_WriteByte (&sv.reliable_datagram, svc_updatename); MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients); MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
MSG_WriteString (&sv.reliable_datagram, host_client->name); MSG_WriteString (&sv.reliable_datagram, host_client->name);
} }
void void
Host_Version_f (void) Host_Version_f (void)
{ {
@ -747,12 +680,12 @@ Host_Say (qboolean teamonly)
p = Hunk_TempAlloc (strlen(Cmd_Args (1)) + 1); p = Hunk_TempAlloc (strlen(Cmd_Args (1)) + 1);
strcpy (p, Cmd_Args (1)); strcpy (p, Cmd_Args (1));
// remove quotes if present // remove quotes if present
if (*p == '"') { if (*p == '"') {
p++; p++;
p[strlen (p) - 1] = 0; p[strlen (p) - 1] = 0;
} }
// turn on color set 1 // turn on color set 1
if (!fromServer) if (!fromServer)
snprintf (text, sizeof (text), "%c%s: ", 1, save->name); snprintf (text, sizeof (text), "%c%s: ", 1, save->name);
else else
@ -768,8 +701,9 @@ Host_Say (qboolean teamonly)
for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++) { for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++) {
if (!client || !client->active || !client->spawned) if (!client || !client->active || !client->spawned)
continue; continue;
if (teamplay->int_val && teamonly if (teamplay->int_val && teamonly && SVfloat (client->edict, team) !=
&& SVfloat (client->edict, team) != SVfloat (save->edict, team)) continue; SVfloat (save->edict, team))
continue;
host_client = client; host_client = client;
SV_ClientPrintf ("%s", text); SV_ClientPrintf ("%s", text);
} }
@ -778,21 +712,18 @@ Host_Say (qboolean teamonly)
Con_Printf ("%s", &text[1]); Con_Printf ("%s", &text[1]);
} }
void void
Host_Say_f (void) Host_Say_f (void)
{ {
Host_Say (false); Host_Say (false);
} }
void void
Host_Say_Team_f (void) Host_Say_Team_f (void)
{ {
Host_Say (true); Host_Say (true);
} }
void void
Host_Tell_f (void) Host_Tell_f (void)
{ {
@ -816,12 +747,12 @@ Host_Tell_f (void)
p = Hunk_TempAlloc (strlen(Cmd_Args (1)) + 1); p = Hunk_TempAlloc (strlen(Cmd_Args (1)) + 1);
strcpy (p, Cmd_Args (1)); strcpy (p, Cmd_Args (1));
// remove quotes if present // remove quotes if present
if (*p == '"') { if (*p == '"') {
p++; p++;
p[strlen (p) - 1] = 0; p[strlen (p) - 1] = 0;
} }
// check length & truncate if necessary // check length & truncate if necessary
j = sizeof (text) - 2 - strlen (text); // -2 for /n and null terminator j = sizeof (text) - 2 - strlen (text); // -2 for /n and null terminator
if (strlen (p) > j) if (strlen (p) > j)
p[j] = 0; p[j] = 0;
@ -842,11 +773,6 @@ Host_Tell_f (void)
host_client = save; host_client = save;
} }
/*
==================
Host_Kill_f
==================
*/
void void
Host_Kill_f (void) Host_Kill_f (void)
{ {
@ -861,17 +787,10 @@ Host_Kill_f (void)
} }
*sv_globals.time = sv.time; *sv_globals.time = sv.time;
*sv_globals.self = *sv_globals.self = EDICT_TO_PROG (&sv_pr_state, sv_player);
EDICT_TO_PROG (&sv_pr_state, sv_player);
PR_ExecuteProgram (&sv_pr_state, sv_funcs.ClientKill); PR_ExecuteProgram (&sv_pr_state, sv_funcs.ClientKill);
} }
/*
==================
Host_Pause_f
==================
*/
void void
Host_Pause_f (void) Host_Pause_f (void)
{ {
@ -887,10 +806,12 @@ Host_Pause_f (void)
if (sv.paused) { if (sv.paused) {
SV_BroadcastPrintf ("%s paused the game\n", SV_BroadcastPrintf ("%s paused the game\n",
PR_GetString (&sv_pr_state, SVstring (sv_player, netname))); PR_GetString (&sv_pr_state,
SVstring (sv_player, netname)));
} else { } else {
SV_BroadcastPrintf ("%s unpaused the game\n", SV_BroadcastPrintf ("%s unpaused the game\n",
PR_GetString (&sv_pr_state, SVstring (sv_player, netname))); PR_GetString (&sv_pr_state,
SVstring (sv_player, netname)));
} }
// send notification to all clients // send notification to all clients
@ -901,12 +822,6 @@ Host_Pause_f (void)
//=========================================================================== //===========================================================================
/*
==================
Host_PreSpawn_f
==================
*/
void void
Host_PreSpawn_f (void) Host_PreSpawn_f (void)
{ {
@ -926,11 +841,6 @@ Host_PreSpawn_f (void)
host_client->sendsignon = true; host_client->sendsignon = true;
} }
/*
==================
Host_Spawn_f
==================
*/
void void
Host_Spawn_f (void) Host_Spawn_f (void)
{ {
@ -947,45 +857,36 @@ Host_Spawn_f (void)
Con_Printf ("Spawn not valid -- already spawned\n"); Con_Printf ("Spawn not valid -- already spawned\n");
return; return;
} }
// run the entrance script // run the entrance script
if (sv.loadgame) { // loaded games are fully inited if (sv.loadgame) { // loaded games are fully inited already
// already
// if this is the last client to be connected, unpause // if this is the last client to be connected, unpause
sv.paused = false; sv.paused = false;
} else { } else {
// set up the edict // set up the edict
ent = host_client->edict; ent = host_client->edict;
memset (&ent->v, 0, sv_pr_state.progs->entityfields * 4); memset (&ent->v, 0, sv_pr_state.progs->entityfields * 4);
SVfloat (ent, colormap) = NUM_FOR_EDICT (&sv_pr_state, ent); SVfloat (ent, colormap) = NUM_FOR_EDICT (&sv_pr_state, ent);
SVfloat (ent, team) = (host_client->colors & 15) + 1; SVfloat (ent, team) = (host_client->colors & 15) + 1;
SVstring (ent, netname) = PR_SetString (&sv_pr_state, host_client->name); SVstring (ent, netname) = PR_SetString (&sv_pr_state,
host_client->name);
// copy spawn parms out of the client_t // copy spawn parms out of the client_t
for (i = 0; i < NUM_SPAWN_PARMS; i++) for (i = 0; i < NUM_SPAWN_PARMS; i++)
sv_globals.parms[i] = host_client->spawn_parms[i]; sv_globals.parms[i] = host_client->spawn_parms[i];
// call the spawn function // call the spawn function
*sv_globals.time = sv.time; *sv_globals.time = sv.time;
*sv_globals.self = *sv_globals.self = EDICT_TO_PROG (&sv_pr_state, sv_player);
EDICT_TO_PROG (&sv_pr_state, sv_player); PR_ExecuteProgram (&sv_pr_state, sv_funcs.ClientConnect);
PR_ExecuteProgram (&sv_pr_state,
sv_funcs.ClientConnect);
if ((Sys_DoubleTime () - host_client->netconnection->connecttime) <= if ((Sys_DoubleTime () - host_client->netconnection->connecttime) <=
sv.time) Con_Printf ("%s entered the game\n", host_client->name); sv.time) Con_Printf ("%s entered the game\n", host_client->name);
PR_ExecuteProgram (&sv_pr_state, sv_funcs.PutClientInServer);
PR_ExecuteProgram (&sv_pr_state,
sv_funcs.PutClientInServer);
} }
// send all current names, colors, and frag counts
// send all current names, colors, and frag counts
SZ_Clear (&host_client->message); SZ_Clear (&host_client->message);
// send time of update // send time of update
MSG_WriteByte (&host_client->message, svc_time); MSG_WriteByte (&host_client->message, svc_time);
MSG_WriteFloat (&host_client->message, sv.time); MSG_WriteFloat (&host_client->message, sv.time);
@ -1001,16 +902,14 @@ Host_Spawn_f (void)
MSG_WriteByte (&host_client->message, client->colors); MSG_WriteByte (&host_client->message, client->colors);
} }
// send all current light styles // send all current light styles
for (i = 0; i < MAX_LIGHTSTYLES; i++) { for (i = 0; i < MAX_LIGHTSTYLES; i++) {
MSG_WriteByte (&host_client->message, svc_lightstyle); MSG_WriteByte (&host_client->message, svc_lightstyle);
MSG_WriteByte (&host_client->message, (char) i); MSG_WriteByte (&host_client->message, (char) i);
MSG_WriteString (&host_client->message, sv.lightstyles[i]); MSG_WriteString (&host_client->message, sv.lightstyles[i]);
} }
// // send some stats
// send some stats
//
MSG_WriteByte (&host_client->message, svc_updatestat); MSG_WriteByte (&host_client->message, svc_updatestat);
MSG_WriteByte (&host_client->message, STAT_TOTALSECRETS); MSG_WriteByte (&host_client->message, STAT_TOTALSECRETS);
MSG_WriteLong (&host_client->message, MSG_WriteLong (&host_client->message,
@ -1031,17 +930,15 @@ Host_Spawn_f (void)
MSG_WriteLong (&host_client->message, MSG_WriteLong (&host_client->message,
*sv_globals.killed_monsters); *sv_globals.killed_monsters);
// send a fixangle
// // Never send a roll angle, because savegames can catch the server
// send a fixangle // in a state where it is expecting the client to correct the angle
// Never send a roll angle, because savegames can catch the server // and it won't happen if the game was just loaded, so you wind up
// in a state where it is expecting the client to correct the angle // with a permanent head tilt
// and it won't happen if the game was just loaded, so you wind up
// with a permanent head tilt
ent = EDICT_NUM (&sv_pr_state, 1 + (host_client - svs.clients)); ent = EDICT_NUM (&sv_pr_state, 1 + (host_client - svs.clients));
MSG_WriteByte (&host_client->message, svc_setangle); MSG_WriteByte (&host_client->message, svc_setangle);
for (i = 0; i < 2; i++) MSG_WriteAngle (&host_client->message, SVvector (ent, angles)[0]);
MSG_WriteAngle (&host_client->message, SVvector (ent, angles)[i]); MSG_WriteAngle (&host_client->message, SVvector (ent, angles)[1]);
MSG_WriteAngle (&host_client->message, 0); MSG_WriteAngle (&host_client->message, 0);
SV_WriteClientdataToMessage (sv_player, &host_client->message); SV_WriteClientdataToMessage (sv_player, &host_client->message);
@ -1051,11 +948,6 @@ Host_Spawn_f (void)
host_client->sendsignon = true; host_client->sendsignon = true;
} }
/*
==================
Host_Begin_f
==================
*/
void void
Host_Begin_f (void) Host_Begin_f (void)
{ {
@ -1069,13 +961,10 @@ Host_Begin_f (void)
//=========================================================================== //===========================================================================
/* /*
================== Host_Kick_f
Host_Kick_f
Kicks a user off of the server Kicks a user off of the server
==================
*/ */
void void
Host_Kick_f (void) Host_Kick_f (void)
@ -1149,21 +1038,10 @@ Host_Kick_f (void)
host_client = save; host_client = save;
} }
/* // DEBUGGING TOOLS ============================================================
===============================================================================
DEBUGGING TOOLS
===============================================================================
*/
// FIXME: This cheat should be re-implemented OUTSIDE the engine! // FIXME: This cheat should be re-implemented OUTSIDE the engine!
#if 0 #if 0
/*
==================
Host_Give_f
==================
*/
void void
Host_Give_f (void) Host_Give_f (void)
{ {
@ -1302,7 +1180,6 @@ Host_Give_f (void)
} }
#endif #endif
edict_t * edict_t *
FindViewthing (void) FindViewthing (void)
{ {
@ -1311,18 +1188,14 @@ FindViewthing (void)
for (i = 0; i < sv.num_edicts; i++) { for (i = 0; i < sv.num_edicts; i++) {
e = EDICT_NUM (&sv_pr_state, i); e = EDICT_NUM (&sv_pr_state, i);
if (!strcmp (PR_GetString (&sv_pr_state, SVstring (e, classname)), "viewthing")) if (!strcmp (PR_GetString (&sv_pr_state, SVstring (e, classname)),
"viewthing"))
return e; return e;
} }
Con_Printf ("No viewthing on map\n"); Con_Printf ("No viewthing on map\n");
return NULL; return NULL;
} }
/*
==================
Host_Viewmodel_f
==================
*/
void void
Host_Viewmodel_f (void) Host_Viewmodel_f (void)
{ {
@ -1343,11 +1216,6 @@ Host_Viewmodel_f (void)
cl.model_precache[(int) SVfloat (e, modelindex)] = m; cl.model_precache[(int) SVfloat (e, modelindex)] = m;
} }
/*
==================
Host_Viewframe_f
==================
*/
void void
Host_Viewframe_f (void) Host_Viewframe_f (void)
{ {
@ -1367,7 +1235,6 @@ Host_Viewframe_f (void)
SVfloat (e, frame) = f; SVfloat (e, frame) = f;
} }
void void
PrintFrameName (model_t *m, int frame) PrintFrameName (model_t *m, int frame)
{ {
@ -1383,11 +1250,6 @@ PrintFrameName (model_t *m, int frame)
Cache_Release (&m->cache); Cache_Release (&m->cache);
} }
/*
==================
Host_Viewnext_f
==================
*/
void void
Host_Viewnext_f (void) Host_Viewnext_f (void)
{ {
@ -1406,11 +1268,6 @@ Host_Viewnext_f (void)
PrintFrameName (m, SVfloat (e, frame)); PrintFrameName (m, SVfloat (e, frame));
} }
/*
==================
Host_Viewprev_f
==================
*/
void void
Host_Viewprev_f (void) Host_Viewprev_f (void)
{ {
@ -1430,20 +1287,8 @@ Host_Viewprev_f (void)
PrintFrameName (m, SVfloat (e, frame)); PrintFrameName (m, SVfloat (e, frame));
} }
/* // DEMO LOOP CONTROL ==========================================================
===============================================================================
DEMO LOOP CONTROL
===============================================================================
*/
/*
==================
Host_Startdemos_f
==================
*/
void void
Host_Startdemos_f (void) Host_Startdemos_f (void)
{ {
@ -1472,13 +1317,10 @@ Host_Startdemos_f (void)
cls.demonum = -1; cls.demonum = -1;
} }
/* /*
================== Host_Demos_f
Host_Demos_f
Return to looping demos Return to looping demos
==================
*/ */
void void
Host_Demos_f (void) Host_Demos_f (void)
@ -1492,11 +1334,9 @@ Host_Demos_f (void)
} }
/* /*
================== Host_Stopdemo_f
Host_Stopdemo_f
Return to looping demos Return to looping demos
==================
*/ */
void void
Host_Stopdemo_f (void) Host_Stopdemo_f (void)
@ -1511,11 +1351,6 @@ Host_Stopdemo_f (void)
//============================================================================= //=============================================================================
/*
==================
Host_InitCommands
==================
*/
void void
Host_InitCommands (void) Host_InitCommands (void)
{ {

View file

@ -370,18 +370,18 @@ PF_particle (progs_t *pr)
void void
PF_ambientsound (progs_t *pr) PF_ambientsound (progs_t *pr)
{ {
const char **check; const char **check;
const char *samp; const char *samp;
float *pos; float *pos;
float vol, attenuation; float vol, attenuation;
int i, soundnum; int soundnum;
pos = G_VECTOR (pr, OFS_PARM0); pos = G_VECTOR (pr, OFS_PARM0);
samp = G_STRING (pr, OFS_PARM1); samp = G_STRING (pr, OFS_PARM1);
vol = G_FLOAT (pr, OFS_PARM2); vol = G_FLOAT (pr, OFS_PARM2);
attenuation = G_FLOAT (pr, OFS_PARM3); attenuation = G_FLOAT (pr, OFS_PARM3);
// check to see if samp was properly precached // check to see if samp was properly precached
for (soundnum = 0, check = sv.sound_precache; *check; check++, soundnum++) for (soundnum = 0, check = sv.sound_precache; *check; check++, soundnum++)
if (!strcmp (*check, samp)) if (!strcmp (*check, samp))
break; break;
@ -390,14 +390,11 @@ PF_ambientsound (progs_t *pr)
Con_Printf ("no precache: %s\n", samp); Con_Printf ("no precache: %s\n", samp);
return; return;
} }
// add an svc_spawnambient command to the level signon packet
// add an svc_spawnambient command to the level signon packet
MSG_WriteByte (&sv.signon, svc_spawnstaticsound); MSG_WriteByte (&sv.signon, svc_spawnstaticsound);
for (i = 0; i < 3; i++) MSG_WriteCoordV (&sv.signon, pos);
MSG_WriteCoord (&sv.signon, pos[i]);
MSG_WriteByte (&sv.signon, soundnum); MSG_WriteByte (&sv.signon, soundnum);
MSG_WriteByte (&sv.signon, vol * 255); MSG_WriteByte (&sv.signon, vol * 255);
MSG_WriteByte (&sv.signon, attenuation * 64); MSG_WriteByte (&sv.signon, attenuation * 64);
@ -1114,23 +1111,26 @@ void
PF_makestatic (progs_t *pr) PF_makestatic (progs_t *pr)
{ {
edict_t *ent; edict_t *ent;
int i;
ent = G_EDICT (pr, OFS_PARM0); ent = G_EDICT (pr, OFS_PARM0);
MSG_WriteByte (&sv.signon, svc_spawnstatic); MSG_WriteByte (&sv.signon, svc_spawnstatic);
MSG_WriteByte (&sv.signon, SV_ModelIndex (PR_GetString (pr, SVstring (ent, model)))); MSG_WriteByte (&sv.signon,
SV_ModelIndex (PR_GetString (pr, SVstring (ent, model))));
MSG_WriteByte (&sv.signon, SVfloat (ent, frame)); MSG_WriteByte (&sv.signon, SVfloat (ent, frame));
MSG_WriteByte (&sv.signon, SVfloat (ent, colormap)); MSG_WriteByte (&sv.signon, SVfloat (ent, colormap));
MSG_WriteByte (&sv.signon, SVfloat (ent, skin)); MSG_WriteByte (&sv.signon, SVfloat (ent, skin));
for (i = 0; i < 3; i++) {
MSG_WriteCoordAngleV (&sv.signon, SVvector (ent, origin),
SVvector (ent, angles));
/* for (i = 0; i < 3; i++) { // FIXME: DESPAIR
MSG_WriteCoord (&sv.signon, SVvector (ent, origin)[i]); MSG_WriteCoord (&sv.signon, SVvector (ent, origin)[i]);
MSG_WriteAngle (&sv.signon, SVvector (ent, angles)[i]); MSG_WriteAngle (&sv.signon, SVvector (ent, angles)[i]);
} } */
// throw the entity away now // throw the entity away now
ED_Free (pr, ent); ED_Free (pr, ent);
} }
@ -1166,7 +1166,7 @@ PF_changelevel (progs_t *pr)
{ {
char *s; char *s;
// make sure we don't issue two changelevels // make sure we don't issue two changelevels
if (svs.changelevel_issued) if (svs.changelevel_issued)
return; return;
svs.changelevel_issued = true; svs.changelevel_issued = true;
@ -1334,7 +1334,8 @@ PF_rotate_bbox (progs_t *pr)
VectorScale (offsets[j][0], -1, hull->clip_maxs); VectorScale (offsets[j][0], -1, hull->clip_maxs);
// set up the clip planes // set up the clip planes
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
hull->planes[i].dist = calc_dist (verts[i], dir[i / 2], offsets[j]); hull->planes[i].dist = calc_dist (verts[i], dir[i / 2],
offsets[j]);
hull->planes[i].type = 4; hull->planes[i].type = 4;
VectorCopy (dir[i / 2], hull->planes[i].normal); VectorCopy (dir[i / 2], hull->planes[i].normal);
//Con_Printf ("%f %f %f %f\n", //Con_Printf ("%f %f %f %f\n",
@ -1345,7 +1346,6 @@ PF_rotate_bbox (progs_t *pr)
} }
} }
void void
PF_Fixme (progs_t *pr) PF_Fixme (progs_t *pr)
{ {

View file

@ -91,9 +91,7 @@ SV_StartParticle (vec3_t org, vec3_t dir, int color, int count)
if (sv.datagram.cursize > MAX_DATAGRAM - 16) if (sv.datagram.cursize > MAX_DATAGRAM - 16)
return; return;
MSG_WriteByte (&sv.datagram, svc_particle); MSG_WriteByte (&sv.datagram, svc_particle);
MSG_WriteCoord (&sv.datagram, org[0]); MSG_WriteCoordV (&sv.datagram, org);
MSG_WriteCoord (&sv.datagram, org[1]);
MSG_WriteCoord (&sv.datagram, org[2]);
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
v = dir[i] * 16; v = dir[i] * 16;
if (v > 127) if (v > 127)
@ -166,7 +164,7 @@ SV_StartSound (edict_t *entity, int channel, const char *sample, int volume,
MSG_WriteByte (&sv.datagram, attenuation * 64); MSG_WriteByte (&sv.datagram, attenuation * 64);
MSG_WriteShort (&sv.datagram, channel); MSG_WriteShort (&sv.datagram, channel);
MSG_WriteByte (&sv.datagram, sound_num); MSG_WriteByte (&sv.datagram, sound_num);
for (i = 0; i < 3; i++) for (i=0; i < 3; i++)
MSG_WriteCoord (&sv.datagram, SVvector (entity, origin)[i] + 0.5 * MSG_WriteCoord (&sv.datagram, SVvector (entity, origin)[i] + 0.5 *
(SVvector (entity, mins)[i] + (SVvector (entity, mins)[i] +
SVvector (entity, maxs)[i])); SVvector (entity, maxs)[i]));
@ -523,11 +521,10 @@ SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
MSG_WriteByte (msg, svc_damage); MSG_WriteByte (msg, svc_damage);
MSG_WriteByte (msg, SVfloat (ent, dmg_save)); MSG_WriteByte (msg, SVfloat (ent, dmg_save));
MSG_WriteByte (msg, SVfloat (ent, dmg_take)); MSG_WriteByte (msg, SVfloat (ent, dmg_take));
for (i = 0; i < 3; i++) for (i=0; i < 3; i++)
MSG_WriteCoord (msg, SVvector (other, origin)[i] + 0.5 * MSG_WriteCoord (msg, SVvector (other, origin)[i] + 0.5 *
(SVvector (other, mins)[i] + (SVvector (other, mins)[i] +
SVvector (other, maxs)[i])); SVvector (other, maxs)[i]));
SVfloat (ent, dmg_take) = 0; SVfloat (ent, dmg_take) = 0;
SVfloat (ent, dmg_save) = 0; SVfloat (ent, dmg_save) = 0;
} }
@ -538,8 +535,7 @@ SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
// a fixangle might get lost in a dropped packet. Oh well. // a fixangle might get lost in a dropped packet. Oh well.
if (SVfloat (ent, fixangle)) { if (SVfloat (ent, fixangle)) {
MSG_WriteByte (msg, svc_setangle); MSG_WriteByte (msg, svc_setangle);
for (i = 0; i < 3; i++) MSG_WriteAngleV (msg, SVvector (ent, angles));
MSG_WriteAngle (msg, SVvector (ent, angles)[i]);
SVfloat (ent, fixangle) = 0; SVfloat (ent, fixangle) = 0;
} }
@ -807,7 +803,7 @@ SV_ModelIndex (const char *name)
void void
SV_CreateBaseline (void) SV_CreateBaseline (void)
{ {
int entnum, i; int entnum;
edict_t *svent; edict_t *svent;
for (entnum = 0; entnum < sv.num_edicts; entnum++) { for (entnum = 0; entnum < sv.num_edicts; entnum++) {
@ -844,16 +840,13 @@ SV_CreateBaseline (void)
MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->frame); MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->frame);
MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->colormap); MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->colormap);
MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->skin); MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->skin);
for (i = 0; i < 3; i++) {
MSG_WriteCoord (&sv.signon, MSG_WriteCoordAngleV (&sv.signon,
((entity_state_t*)svent->data)->origin[i]); ((entity_state_t*)svent->data)->origin,
MSG_WriteAngle (&sv.signon, ((entity_state_t*)svent->data)->angles);
((entity_state_t*)svent->data)->angles[i]);
}
} }
} }
/* /*
SV_SendReconnect SV_SendReconnect

View file

@ -420,8 +420,7 @@ SV_ReadClientMove (usercmd_t *move)
host_client->num_pings++; host_client->num_pings++;
// read current angles // read current angles
for (i = 0; i < 3; i++) MSG_ReadAngleV (net_message, angle);
angle[i] = MSG_ReadAngle (net_message);
VectorCopy (angle, SVvector (host_client->edict, v_angle)); VectorCopy (angle, SVvector (host_client->edict, v_angle));

View file

@ -425,9 +425,7 @@ Cam_Track (usercmd_t *cmd)
sizeof (desired_position)) sizeof (desired_position))
!= 0) { != 0) {
MSG_WriteByte (&cls.netchan.message, clc_tmove); MSG_WriteByte (&cls.netchan.message, clc_tmove);
MSG_WriteCoord (&cls.netchan.message, desired_position[0]); MSG_WriteCoordV (&cls.netchan.message, desired_position);
MSG_WriteCoord (&cls.netchan.message, desired_position[1]);
MSG_WriteCoord (&cls.netchan.message, desired_position[2]);
// move there locally immediately // move there locally immediately
VectorCopy (desired_position, self->origin); VectorCopy (desired_position, self->origin);
} }
@ -441,9 +439,7 @@ Cam_Track (usercmd_t *cmd)
cmd->forwardmove = cmd->sidemove = cmd->upmove = 0; cmd->forwardmove = cmd->sidemove = cmd->upmove = 0;
if (len > 16) { // close enough? if (len > 16) { // close enough?
MSG_WriteByte (&cls.netchan.message, clc_tmove); MSG_WriteByte (&cls.netchan.message, clc_tmove);
MSG_WriteCoord (&cls.netchan.message, desired_position[0]); MSG_WriteCoordV (&cls.netchan.message, desired_position);
MSG_WriteCoord (&cls.netchan.message, desired_position[1]);
MSG_WriteCoord (&cls.netchan.message, desired_position[2]);
} }
// move there locally immediately // move there locally immediately
VectorCopy (desired_position, self->origin); VectorCopy (desired_position, self->origin);

View file

@ -566,10 +566,7 @@ CL_Record_f (void)
MSG_WriteByte (&buf, ent->frame); MSG_WriteByte (&buf, ent->frame);
MSG_WriteByte (&buf, 0); MSG_WriteByte (&buf, 0);
MSG_WriteByte (&buf, ent->skinnum); MSG_WriteByte (&buf, ent->skinnum);
for (j = 0; j < 3; j++) { MSG_WriteCoordAngleV (&buf, ent->origin, ent->angles);
MSG_WriteCoord (&buf, ent->origin[j]);
MSG_WriteAngle (&buf, ent->angles[j]);
}
if (buf.cursize > MAX_MSGLEN / 2) { if (buf.cursize > MAX_MSGLEN / 2) {
CL_WriteRecordDemoMessage (&buf, seq++); CL_WriteRecordDemoMessage (&buf, seq++);
@ -593,10 +590,7 @@ CL_Record_f (void)
MSG_WriteByte (&buf, es->frame); MSG_WriteByte (&buf, es->frame);
MSG_WriteByte (&buf, es->colormap); MSG_WriteByte (&buf, es->colormap);
MSG_WriteByte (&buf, es->skinnum); MSG_WriteByte (&buf, es->skinnum);
for (j = 0; j < 3; j++) { MSG_WriteCoordAngleV (&buf, es->origin, es->angles);
MSG_WriteCoord (&buf, es->origin[j]);
MSG_WriteAngle (&buf, es->angles[j]);
}
if (buf.cursize > MAX_MSGLEN / 2) { if (buf.cursize > MAX_MSGLEN / 2) {
CL_WriteRecordDemoMessage (&buf, seq++); CL_WriteRecordDemoMessage (&buf, seq++);

View file

@ -610,7 +610,7 @@ CL_ParsePlayerinfo (void)
flags = state->flags = MSG_ReadShort (net_message); flags = state->flags = MSG_ReadShort (net_message);
state->messagenum = cl.parsecount; state->messagenum = cl.parsecount;
MSG_ReadCoord3 (net_message, state->origin); MSG_ReadCoordV (net_message, state->origin);
state->frame = MSG_ReadByte (net_message); state->frame = MSG_ReadByte (net_message);

View file

@ -802,18 +802,14 @@ CL_ParseModellist (void)
void void
CL_ParseBaseline (entity_state_t *es) CL_ParseBaseline (entity_state_t *es)
{ {
int i;
es->modelindex = MSG_ReadByte (net_message); es->modelindex = MSG_ReadByte (net_message);
es->frame = MSG_ReadByte (net_message); es->frame = MSG_ReadByte (net_message);
es->colormap = MSG_ReadByte (net_message); es->colormap = MSG_ReadByte (net_message);
es->skinnum = MSG_ReadByte (net_message); es->skinnum = MSG_ReadByte (net_message);
for (i = 0; i < 3; i++) {
es->origin[i] = MSG_ReadCoord (net_message); MSG_ReadCoordAngleV (net_message, es->origin, es->angles);
es->angles[i] = MSG_ReadAngle (net_message);
} // LordHavoc: set up baseline to for new effects (alpha, colormod, etc)
// LordHavoc: set up the baseline to account for new effects (alpha,
// colormod, etc)
es->alpha = 255; es->alpha = 255;
es->scale = 16; es->scale = 16;
es->glow_color = 254; es->glow_color = 254;
@ -857,7 +853,7 @@ CL_ParseStaticSound (void)
int sound_num, vol, atten; int sound_num, vol, atten;
vec3_t org; vec3_t org;
MSG_ReadCoord3 (net_message, org); MSG_ReadCoordV (net_message, org);
sound_num = MSG_ReadByte (net_message); sound_num = MSG_ReadByte (net_message);
vol = MSG_ReadByte (net_message); vol = MSG_ReadByte (net_message);
atten = MSG_ReadByte (net_message); atten = MSG_ReadByte (net_message);
@ -888,7 +884,7 @@ CL_ParseStartSoundPacket (void)
sound_num = MSG_ReadByte (net_message); sound_num = MSG_ReadByte (net_message);
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
ent = (channel >> 3) & 1023; ent = (channel >> 3) & 1023;
channel &= 7; channel &= 7;
@ -1214,8 +1210,7 @@ CL_ParseServerMessage (void)
break; break;
case svc_setangle: case svc_setangle:
for (i = 0; i < 3; i++) MSG_ReadAngleV (net_message, cl.viewangles);
cl.viewangles[i] = MSG_ReadAngle (net_message);
// cl.viewangles[PITCH] = cl.viewangles[ROLL] = 0; // cl.viewangles[PITCH] = cl.viewangles[ROLL] = 0;
break; break;
@ -1317,15 +1312,13 @@ CL_ParseServerMessage (void)
cl.completed_time = realtime; cl.completed_time = realtime;
vid.recalc_refdef = true; // go to full screen vid.recalc_refdef = true; // go to full screen
Con_DPrintf ("intermission simorg: "); Con_DPrintf ("intermission simorg: ");
MSG_ReadCoord3 (net_message, cl.simorg); MSG_ReadCoordV (net_message, cl.simorg);
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++)
Con_DPrintf ("%f ", cl.simorg[i]); Con_DPrintf ("%f ", cl.simorg[i]);
}
Con_DPrintf ("\nintermission simangles: "); Con_DPrintf ("\nintermission simangles: ");
for (i = 0; i < 3; i++) { MSG_ReadAngleV (net_message, cl.simangles);
cl.simangles[i] = MSG_ReadAngle (net_message); for (i = 0; i < 3; i++)
Con_DPrintf ("%f ", cl.simangles[i]); Con_DPrintf ("%f ", cl.simangles[i]);
}
Con_DPrintf ("\n"); Con_DPrintf ("\n");
VectorCopy (vec3_origin, cl.simvel); VectorCopy (vec3_origin, cl.simvel);
break; break;

View file

@ -191,8 +191,8 @@ CL_ParseBeam (model_t *m)
ent = MSG_ReadShort (net_message); ent = MSG_ReadShort (net_message);
MSG_ReadCoord3 (net_message, start); MSG_ReadCoordV (net_message, start);
MSG_ReadCoord3 (net_message, end); MSG_ReadCoordV (net_message, end);
// override any beam with the same entity // override any beam with the same entity
for (i = 0, b = cl_beams; i < MAX_BEAMS; i++, b++) for (i = 0, b = cl_beams; i < MAX_BEAMS; i++, b++)
@ -233,19 +233,19 @@ CL_ParseTEnt (void)
type = MSG_ReadByte (net_message); type = MSG_ReadByte (net_message);
switch (type) { switch (type) {
case TE_WIZSPIKE: // spike hitting wall case TE_WIZSPIKE: // spike hitting wall
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_WizSpikeEffect (pos); R_WizSpikeEffect (pos);
S_StartSound (-1, 0, cl_sfx_wizhit, pos, 1, 1); S_StartSound (-1, 0, cl_sfx_wizhit, pos, 1, 1);
break; break;
case TE_KNIGHTSPIKE: // spike hitting wall case TE_KNIGHTSPIKE: // spike hitting wall
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_KnightSpikeEffect (pos); R_KnightSpikeEffect (pos);
S_StartSound (-1, 0, cl_sfx_knighthit, pos, 1, 1); S_StartSound (-1, 0, cl_sfx_knighthit, pos, 1, 1);
break; break;
case TE_SPIKE: // spike hitting wall case TE_SPIKE: // spike hitting wall
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_SpikeEffect (pos); R_SpikeEffect (pos);
if (rand () % 5) if (rand () % 5)
@ -262,7 +262,7 @@ CL_ParseTEnt (void)
break; break;
case TE_SUPERSPIKE: // super spike hitting wall case TE_SUPERSPIKE: // super spike hitting wall
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_SuperSpikeEffect (pos); R_SuperSpikeEffect (pos);
if (rand () % 5) if (rand () % 5)
@ -280,7 +280,7 @@ CL_ParseTEnt (void)
case TE_EXPLOSION: // rocket explosion case TE_EXPLOSION: // rocket explosion
// particles // particles
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_ParticleExplosion (pos); R_ParticleExplosion (pos);
// light // light
@ -304,7 +304,7 @@ CL_ParseTEnt (void)
break; break;
case TE_TAREXPLOSION: // tarbaby explosion case TE_TAREXPLOSION: // tarbaby explosion
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_BlobExplosion (pos); R_BlobExplosion (pos);
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
@ -329,17 +329,17 @@ CL_ParseTEnt (void)
// PGM 01/21/97 // PGM 01/21/97
case TE_LAVASPLASH: case TE_LAVASPLASH:
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_LavaSplash (pos); R_LavaSplash (pos);
break; break;
case TE_TELEPORT: case TE_TELEPORT:
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_TeleportSplash (pos); R_TeleportSplash (pos);
break; break;
case TE_EXPLOSION2: // color mapped explosion case TE_EXPLOSION2: // color mapped explosion
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
colorStart = MSG_ReadByte (net_message); colorStart = MSG_ReadByte (net_message);
colorLength = MSG_ReadByte (net_message); colorLength = MSG_ReadByte (net_message);
R_ParticleExplosion2 (pos, colorStart, colorLength); R_ParticleExplosion2 (pos, colorStart, colorLength);
@ -359,18 +359,18 @@ CL_ParseTEnt (void)
case TE_GUNSHOT: // bullet hitting wall case TE_GUNSHOT: // bullet hitting wall
cnt = MSG_ReadByte (net_message) * 20; cnt = MSG_ReadByte (net_message) * 20;
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_GunshotEffect (pos, cnt); R_GunshotEffect (pos, cnt);
break; break;
case TE_BLOOD: // bullet hitting body case TE_BLOOD: // bullet hitting body
cnt = MSG_ReadByte (net_message) * 20; cnt = MSG_ReadByte (net_message) * 20;
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
R_BloodPuffEffect (pos, cnt); R_BloodPuffEffect (pos, cnt);
break; break;
case TE_LIGHTNINGBLOOD: // lightning hitting body case TE_LIGHTNINGBLOOD: // lightning hitting body
MSG_ReadCoord3 (net_message, pos); MSG_ReadCoordV (net_message, pos);
// light // light
dl = R_AllocDlight (0); dl = R_AllocDlight (0);

View file

@ -430,8 +430,7 @@ SV_WritePlayersToClient (client_t *client, edict_t *clent, byte * pvs,
MSG_WriteByte (msg, j); MSG_WriteByte (msg, j);
MSG_WriteShort (msg, pflags); MSG_WriteShort (msg, pflags);
for (i = 0; i < 3; i++) MSG_WriteCoordV (msg, SVvector (ent, origin));
MSG_WriteCoord (msg, SVvector (ent, origin)[i]);
MSG_WriteByte (msg, SVfloat (ent, frame)); MSG_WriteByte (msg, SVfloat (ent, frame));

View file

@ -104,7 +104,7 @@ SV_FlushSignon (void)
void void
SV_CreateBaseline (void) SV_CreateBaseline (void)
{ {
int i, entnum; int entnum;
edict_t *svent; edict_t *svent;
for (entnum = 0; entnum < sv.num_edicts; entnum++) { for (entnum = 0; entnum < sv.num_edicts; entnum++) {
@ -150,12 +150,10 @@ SV_CreateBaseline (void)
MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->frame); MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->frame);
MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->colormap); MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->colormap);
MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->skinnum); MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->skinnum);
for (i = 0; i < 3; i++) {
MSG_WriteCoord (&sv.signon, MSG_WriteCoordAngleV (&sv.signon,
((entity_state_t*)svent->data)->origin[i]); ((entity_state_t*)svent->data)->origin,
MSG_WriteAngle (&sv.signon, ((entity_state_t*)svent->data)->angles);
((entity_state_t*)svent->data)->angles[i]);
}
} }
} }

View file

@ -281,7 +281,7 @@ PF_ambientsound (progs_t *pr)
const char *samp; const char *samp;
float *pos; float *pos;
float vol, attenuation; float vol, attenuation;
int i, soundnum; int soundnum;
pos = G_VECTOR (pr, OFS_PARM0); pos = G_VECTOR (pr, OFS_PARM0);
samp = G_STRING (pr, OFS_PARM1); samp = G_STRING (pr, OFS_PARM1);
@ -300,8 +300,7 @@ PF_ambientsound (progs_t *pr)
// add an svc_spawnambient command to the level signon packet // add an svc_spawnambient command to the level signon packet
MSG_WriteByte (&sv.signon, svc_spawnstaticsound); MSG_WriteByte (&sv.signon, svc_spawnstaticsound);
for (i = 0; i < 3; i++) MSG_WriteCoordV (&sv.signon, pos);
MSG_WriteCoord (&sv.signon, pos[i]);
MSG_WriteByte (&sv.signon, soundnum); MSG_WriteByte (&sv.signon, soundnum);
@ -1145,7 +1144,6 @@ PF_makestatic (progs_t *pr)
{ {
const char *model; const char *model;
edict_t *ent; edict_t *ent;
int i;
ent = G_EDICT (pr, OFS_PARM0); ent = G_EDICT (pr, OFS_PARM0);
@ -1158,11 +1156,9 @@ PF_makestatic (progs_t *pr)
MSG_WriteByte (&sv.signon, SVfloat (ent, frame)); MSG_WriteByte (&sv.signon, SVfloat (ent, frame));
MSG_WriteByte (&sv.signon, SVfloat (ent, colormap)); MSG_WriteByte (&sv.signon, SVfloat (ent, colormap));
MSG_WriteByte (&sv.signon, SVfloat (ent, skin)); MSG_WriteByte (&sv.signon, SVfloat (ent, skin));
for (i = 0; i < 3; i++) {
MSG_WriteCoord (&sv.signon, SVvector (ent, origin)[i]);
MSG_WriteAngle (&sv.signon, SVvector (ent, angles)[i]);
}
MSG_WriteCoordAngleV (&sv.signon, SVvector (ent, origin),
SVvector (ent, angles));
// throw the entity away now // throw the entity away now
ED_Free (pr, ent); ED_Free (pr, ent);
} }

View file

@ -483,8 +483,7 @@ SV_StartSound (edict_t *entity, int channel, const char *sample, int volume,
if (channel & SND_ATTENUATION) if (channel & SND_ATTENUATION)
MSG_WriteByte (&sv.multicast, attenuation * 64); MSG_WriteByte (&sv.multicast, attenuation * 64);
MSG_WriteByte (&sv.multicast, sound_num); MSG_WriteByte (&sv.multicast, sound_num);
for (i = 0; i < 3; i++) MSG_WriteCoordV (&sv.multicast, origin);
MSG_WriteCoord (&sv.multicast, origin[i]);
if (use_phs) if (use_phs)
SV_Multicast (origin, reliable ? MULTICAST_PHS_R : MULTICAST_PHS); SV_Multicast (origin, reliable ? MULTICAST_PHS_R : MULTICAST_PHS);
@ -541,15 +540,13 @@ SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg)
MSG_WriteCoord (msg, SVvector (other, origin)[i] + 0.5 * MSG_WriteCoord (msg, SVvector (other, origin)[i] + 0.5 *
(SVvector (other, mins)[i] + (SVvector (other, mins)[i] +
SVvector (other, maxs)[i])); SVvector (other, maxs)[i]));
SVfloat (ent, dmg_take) = 0; SVfloat (ent, dmg_take) = 0;
SVfloat (ent, dmg_save) = 0; SVfloat (ent, dmg_save) = 0;
} }
// a fixangle might get lost in a dropped packet. Oh well. // a fixangle might get lost in a dropped packet. Oh well.
if (SVfloat (ent, fixangle)) { if (SVfloat (ent, fixangle)) {
MSG_WriteByte (msg, svc_setangle); MSG_WriteByte (msg, svc_setangle);
for (i = 0; i < 3; i++) MSG_WriteAngleV (msg, SVvector (ent, angles));
MSG_WriteAngle (msg, SVvector (ent, angles)[i]);
SVfloat (ent, fixangle) = 0; SVfloat (ent, fixangle) = 0;
} }
} }

View file

@ -548,7 +548,8 @@ SV_Begin_f (void)
ent = EDICT_NUM (&sv_pr_state, 1 + (host_client - svs.clients)); ent = EDICT_NUM (&sv_pr_state, 1 + (host_client - svs.clients));
MSG_WriteByte (&host_client->netchan.message, svc_setangle); MSG_WriteByte (&host_client->netchan.message, svc_setangle);
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
MSG_WriteAngle (&host_client->netchan.message, SVvector (ent, angles)[i]); MSG_WriteAngle (&host_client->netchan.message,
SVvector (ent, angles)[i]);
MSG_WriteAngle (&host_client->netchan.message, 0); MSG_WriteAngle (&host_client->netchan.message, 0);
#endif #endif
} }
@ -1782,7 +1783,7 @@ SV_ExecuteClientMessage (client_t *cl)
break; break;
case clc_tmove: case clc_tmove:
MSG_ReadCoord3 (net_message, o); MSG_ReadCoordV (net_message, o);
// only allowed by spectators // only allowed by spectators
if (host_client->spectator) { if (host_client->spectator) {
VectorCopy (o, SVvector (sv_player, origin)); VectorCopy (o, SVvector (sv_player, origin));