mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-22 02:11:19 +00:00
- and svc_temp_entity too. Probably the last I'll do today.
This commit is contained in:
parent
96e4e1a232
commit
c2807a6da1
3 changed files with 125 additions and 108 deletions
|
@ -69,6 +69,17 @@ typedef struct net_svc_sound_s
|
|||
int entity;
|
||||
} net_svc_sound_t;
|
||||
|
||||
typedef struct net_svc_tempentity_s
|
||||
{
|
||||
byte type;
|
||||
vec3_t position;
|
||||
byte gunshotcount; // gunshot sparks
|
||||
byte colorstart; // palette start (I think?)
|
||||
byte colorlength; // palette length
|
||||
vec3_t beamend; // beam endpos
|
||||
short beamentity; // beam entity
|
||||
} net_svc_tempentity_t;
|
||||
|
||||
typedef struct net_svc_updateuserinfo_s
|
||||
{
|
||||
byte slot;
|
||||
|
@ -110,6 +121,8 @@ qboolean NET_SVC_Damage_Parse (net_svc_damage_t *damage, msg_t *message);
|
|||
qboolean NET_SVC_ServerData_Parse (net_svc_serverdata_t *serverdata,
|
||||
msg_t *message);
|
||||
qboolean NET_SVC_Sound_Parse (net_svc_sound_t *sound, msg_t *message);
|
||||
qboolean NET_SVC_TempEntity_Parse (net_svc_tempentity_t *tempentity,
|
||||
msg_t *message);
|
||||
qboolean NET_SVC_UpdateUserInfo_Parse (net_svc_updateuserinfo_t *updateuserinfo,
|
||||
msg_t *message);
|
||||
qboolean NET_SVC_SetInfo_Parse (net_svc_setinfo_t *setinfo, msg_t *message);
|
||||
|
|
|
@ -50,6 +50,7 @@ static const char rcsid[] =
|
|||
#include "cl_main.h"
|
||||
#include "cl_tent.h"
|
||||
#include "client.h"
|
||||
#include "net_svc.h"
|
||||
#include "r_dynamic.h"
|
||||
|
||||
#define MAX_BEAMS 8
|
||||
|
@ -182,42 +183,31 @@ CL_AllocExplosion (void)
|
|||
}
|
||||
|
||||
void
|
||||
CL_ParseBeam (model_t *m)
|
||||
CL_ParseBeam (net_svc_tempentity_t *tempentity, model_t *m)
|
||||
{
|
||||
beam_t *b;
|
||||
int ent, i;
|
||||
vec3_t start, end;
|
||||
|
||||
ent = MSG_ReadShort (net_message);
|
||||
|
||||
start[0] = MSG_ReadCoord (net_message);
|
||||
start[1] = MSG_ReadCoord (net_message);
|
||||
start[2] = MSG_ReadCoord (net_message);
|
||||
|
||||
end[0] = MSG_ReadCoord (net_message);
|
||||
end[1] = MSG_ReadCoord (net_message);
|
||||
end[2] = MSG_ReadCoord (net_message);
|
||||
int i;
|
||||
|
||||
// override any beam with the same entity
|
||||
for (i = 0, b = cl_beams; i < MAX_BEAMS; i++, b++)
|
||||
if (b->entity == ent) {
|
||||
b->entity = ent;
|
||||
if (b->entity == tempentity->beamentity) {
|
||||
b->entity = tempentity->beamentity;
|
||||
b->model = m;
|
||||
b->endtime = cl.time + 0.2;
|
||||
b->seed = rand();
|
||||
VectorCopy (start, b->start);
|
||||
VectorCopy (end, b->end);
|
||||
VectorCopy (tempentity->position, b->start);
|
||||
VectorCopy (tempentity->beamend, b->end);
|
||||
return;
|
||||
}
|
||||
// find a free beam
|
||||
for (i = 0, b = cl_beams; i < MAX_BEAMS; i++, b++) {
|
||||
if (!b->model || b->endtime < cl.time) {
|
||||
b->entity = ent;
|
||||
b->entity = tempentity->beamentity;
|
||||
b->model = m;
|
||||
b->endtime = cl.time + 0.2;
|
||||
b->seed = rand();
|
||||
VectorCopy (start, b->start);
|
||||
VectorCopy (end, b->end);
|
||||
VectorCopy (tempentity->position, b->start);
|
||||
VectorCopy (tempentity->beamend, b->end);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -227,79 +217,63 @@ CL_ParseBeam (model_t *m)
|
|||
void
|
||||
CL_ParseTEnt (void)
|
||||
{
|
||||
byte type;
|
||||
dlight_t *dl;
|
||||
explosion_t *ex;
|
||||
int colorStart, colorLength, rnd;
|
||||
int cnt = -1;
|
||||
vec3_t pos;
|
||||
int rnd;
|
||||
net_svc_tempentity_t tempentity;
|
||||
|
||||
type = MSG_ReadByte (net_message);
|
||||
switch (type) {
|
||||
NET_SVC_TempEntity_Parse (&tempentity, net_message);
|
||||
|
||||
switch (tempentity.type) {
|
||||
case TE_WIZSPIKE: // spike hitting wall
|
||||
pos[0] = MSG_ReadCoord (net_message);
|
||||
pos[1] = MSG_ReadCoord (net_message);
|
||||
pos[2] = MSG_ReadCoord (net_message);
|
||||
R_RunSpikeEffect (pos, prot_to_rend[type]);
|
||||
S_StartSound (-1, 0, cl_sfx_wizhit, pos, 1, 1);
|
||||
R_RunSpikeEffect (tempentity.position, prot_to_rend[tempentity.type]);
|
||||
S_StartSound (-1, 0, cl_sfx_wizhit, tempentity.position, 1, 1);
|
||||
break;
|
||||
|
||||
case TE_KNIGHTSPIKE: // spike hitting wall
|
||||
pos[0] = MSG_ReadCoord (net_message);
|
||||
pos[1] = MSG_ReadCoord (net_message);
|
||||
pos[2] = MSG_ReadCoord (net_message);
|
||||
R_RunSpikeEffect (pos, prot_to_rend[type]);
|
||||
S_StartSound (-1, 0, cl_sfx_knighthit, pos, 1, 1);
|
||||
R_RunSpikeEffect (tempentity.position, prot_to_rend[tempentity.type]);
|
||||
S_StartSound (-1, 0, cl_sfx_knighthit, tempentity.position, 1, 1);
|
||||
break;
|
||||
|
||||
case TE_SPIKE: // spike hitting wall
|
||||
pos[0] = MSG_ReadCoord (net_message);
|
||||
pos[1] = MSG_ReadCoord (net_message);
|
||||
pos[2] = MSG_ReadCoord (net_message);
|
||||
R_RunSpikeEffect (pos, prot_to_rend[type]);
|
||||
R_RunSpikeEffect (tempentity.position, prot_to_rend[tempentity.type]);
|
||||
|
||||
if (rand () % 5)
|
||||
S_StartSound (-1, 0, cl_sfx_tink1, pos, 1, 1);
|
||||
S_StartSound (-1, 0, cl_sfx_tink1, tempentity.position, 1, 1);
|
||||
else {
|
||||
rnd = rand () & 3;
|
||||
if (rnd == 1)
|
||||
S_StartSound (-1, 0, cl_sfx_ric1, pos, 1, 1);
|
||||
S_StartSound (-1, 0, cl_sfx_ric1, tempentity.position, 1, 1);
|
||||
else if (rnd == 2)
|
||||
S_StartSound (-1, 0, cl_sfx_ric2, pos, 1, 1);
|
||||
S_StartSound (-1, 0, cl_sfx_ric2, tempentity.position, 1, 1);
|
||||
else
|
||||
S_StartSound (-1, 0, cl_sfx_ric3, pos, 1, 1);
|
||||
S_StartSound (-1, 0, cl_sfx_ric3, tempentity.position, 1, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case TE_SUPERSPIKE: // super spike hitting wall
|
||||
pos[0] = MSG_ReadCoord (net_message);
|
||||
pos[1] = MSG_ReadCoord (net_message);
|
||||
pos[2] = MSG_ReadCoord (net_message);
|
||||
R_RunSpikeEffect (pos, prot_to_rend[type]);
|
||||
R_RunSpikeEffect (tempentity.position, prot_to_rend[tempentity.type]);
|
||||
|
||||
if (rand () % 5)
|
||||
S_StartSound (-1, 0, cl_sfx_tink1, pos, 1, 1);
|
||||
S_StartSound (-1, 0, cl_sfx_tink1, tempentity.position, 1, 1);
|
||||
else {
|
||||
rnd = rand () & 3;
|
||||
if (rnd == 1)
|
||||
S_StartSound (-1, 0, cl_sfx_ric1, pos, 1, 1);
|
||||
S_StartSound (-1, 0, cl_sfx_ric1, tempentity.position, 1, 1);
|
||||
else if (rnd == 2)
|
||||
S_StartSound (-1, 0, cl_sfx_ric2, pos, 1, 1);
|
||||
S_StartSound (-1, 0, cl_sfx_ric2, tempentity.position, 1, 1);
|
||||
else
|
||||
S_StartSound (-1, 0, cl_sfx_ric3, pos, 1, 1);
|
||||
S_StartSound (-1, 0, cl_sfx_ric3, tempentity.position, 1, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case TE_EXPLOSION: // rocket explosion
|
||||
// particles
|
||||
pos[0] = MSG_ReadCoord (net_message);
|
||||
pos[1] = MSG_ReadCoord (net_message);
|
||||
pos[2] = MSG_ReadCoord (net_message);
|
||||
R_ParticleExplosion (pos);
|
||||
R_ParticleExplosion (tempentity.position);
|
||||
|
||||
// light
|
||||
dl = R_AllocDlight (0);
|
||||
VectorCopy (pos, dl->origin);
|
||||
VectorCopy (tempentity.position, dl->origin);
|
||||
dl->radius = 350;
|
||||
dl->die = cl.time + 0.5;
|
||||
dl->decay = 300;
|
||||
|
@ -308,94 +282,78 @@ CL_ParseTEnt (void)
|
|||
dl->color[2] = 0.24;
|
||||
|
||||
// sound
|
||||
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
|
||||
S_StartSound (-1, 0, cl_sfx_r_exp3, tempentity.position, 1, 1);
|
||||
|
||||
// sprite
|
||||
ex = CL_AllocExplosion ();
|
||||
VectorCopy (pos, ex->ent.origin);
|
||||
VectorCopy (tempentity.position, ex->ent.origin);
|
||||
ex->start = cl.time;
|
||||
ex->ent.model = cl_spr_explod;
|
||||
break;
|
||||
|
||||
case TE_TAREXPLOSION: // tarbaby explosion
|
||||
pos[0] = MSG_ReadCoord (net_message);
|
||||
pos[1] = MSG_ReadCoord (net_message);
|
||||
pos[2] = MSG_ReadCoord (net_message);
|
||||
R_BlobExplosion (pos);
|
||||
R_BlobExplosion (tempentity.position);
|
||||
|
||||
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
|
||||
S_StartSound (-1, 0, cl_sfx_r_exp3, tempentity.position, 1, 1);
|
||||
break;
|
||||
|
||||
case TE_LIGHTNING1: // lightning bolts
|
||||
CL_ParseBeam (cl_mod_bolt);
|
||||
CL_ParseBeam (&tempentity, cl_mod_bolt);
|
||||
break;
|
||||
|
||||
case TE_LIGHTNING2: // lightning bolts
|
||||
CL_ParseBeam (cl_mod_bolt2);
|
||||
CL_ParseBeam (&tempentity, cl_mod_bolt2);
|
||||
break;
|
||||
|
||||
case TE_LIGHTNING3: // lightning bolts
|
||||
CL_ParseBeam (cl_mod_bolt3);
|
||||
CL_ParseBeam (&tempentity, cl_mod_bolt3);
|
||||
break;
|
||||
|
||||
// PGM 01/21/97
|
||||
case TE_BEAM: // grappling hook beam
|
||||
CL_ParseBeam (Mod_ForName ("progs/beam.mdl", true));
|
||||
CL_ParseBeam (&tempentity, Mod_ForName ("progs/beam.mdl", true));
|
||||
break;
|
||||
// PGM 01/21/97
|
||||
|
||||
case TE_LAVASPLASH:
|
||||
pos[0] = MSG_ReadCoord (net_message);
|
||||
pos[1] = MSG_ReadCoord (net_message);
|
||||
pos[2] = MSG_ReadCoord (net_message);
|
||||
R_LavaSplash (pos);
|
||||
R_LavaSplash (tempentity.position);
|
||||
break;
|
||||
|
||||
case TE_TELEPORT:
|
||||
pos[0] = MSG_ReadCoord (net_message);
|
||||
pos[1] = MSG_ReadCoord (net_message);
|
||||
pos[2] = MSG_ReadCoord (net_message);
|
||||
R_TeleportSplash (pos);
|
||||
R_TeleportSplash (tempentity.position);
|
||||
break;
|
||||
|
||||
case TE_EXPLOSION2: // color mapped explosion
|
||||
pos[0] = MSG_ReadCoord (net_message);
|
||||
pos[1] = MSG_ReadCoord (net_message);
|
||||
pos[2] = MSG_ReadCoord (net_message);
|
||||
colorStart = MSG_ReadByte (net_message);
|
||||
colorLength = MSG_ReadByte (net_message);
|
||||
R_ParticleExplosion2 (pos, colorStart, colorLength);
|
||||
R_ParticleExplosion2 (tempentity.position,
|
||||
tempentity.colorstart,
|
||||
tempentity.colorlength);
|
||||
dl = R_AllocDlight (0);
|
||||
VectorCopy (pos, dl->origin);
|
||||
VectorCopy (tempentity.position, dl->origin);
|
||||
dl->radius = 350;
|
||||
dl->die = cl.time + 0.5;
|
||||
dl->decay = 300;
|
||||
dl->color[0] = vid_basepal[(colorStart + (rand() % colorLength)) *
|
||||
3] * (1.0 / 255.0);
|
||||
dl->color[1] = vid_basepal[(colorStart + (rand() % colorLength)) *
|
||||
3 + 1] * (1.0 / 255.0);
|
||||
dl->color[2] = vid_basepal[(colorStart + (rand() % colorLength)) *
|
||||
3 + 2] * (1.0 / 255.0);
|
||||
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
|
||||
dl->color[0] = vid_basepal[(tempentity.colorstart
|
||||
+ (rand() % tempentity.colorlength))
|
||||
* 3] * (1.0 / 255.0);
|
||||
dl->color[1] = vid_basepal[(tempentity.colorstart
|
||||
+ (rand() % tempentity.colorlength))
|
||||
* 3 + 1] * (1.0 / 255.0);
|
||||
dl->color[2] = vid_basepal[(tempentity.colorstart
|
||||
+ (rand() % tempentity.colorlength))
|
||||
* 3 + 2] * (1.0 / 255.0);
|
||||
S_StartSound (-1, 0, cl_sfx_r_exp3, tempentity.position, 1, 1);
|
||||
break;
|
||||
|
||||
case TE_GUNSHOT: // bullet hitting wall
|
||||
case TE_BLOOD: // bullets hitting body
|
||||
cnt = MSG_ReadByte (net_message) * 20;
|
||||
pos[0] = MSG_ReadCoord (net_message);
|
||||
pos[1] = MSG_ReadCoord (net_message);
|
||||
pos[2] = MSG_ReadCoord (net_message);
|
||||
R_RunPuffEffect (pos, prot_to_rend[type], cnt);
|
||||
R_RunPuffEffect (tempentity.position, prot_to_rend[tempentity.type],
|
||||
tempentity.gunshotcount * 20);
|
||||
break;
|
||||
|
||||
case TE_LIGHTNINGBLOOD: // lightning hitting body
|
||||
pos[0] = MSG_ReadCoord (net_message);
|
||||
pos[1] = MSG_ReadCoord (net_message);
|
||||
pos[2] = MSG_ReadCoord (net_message);
|
||||
|
||||
// light
|
||||
dl = R_AllocDlight (0);
|
||||
VectorCopy (pos, dl->origin);
|
||||
VectorCopy (tempentity.position, dl->origin);
|
||||
dl->radius = 150;
|
||||
dl->die = cl.time + 0.1;
|
||||
dl->decay = 200;
|
||||
|
@ -403,11 +361,11 @@ CL_ParseTEnt (void)
|
|||
dl->color[1] = 0.40;
|
||||
dl->color[2] = 0.65;
|
||||
|
||||
R_RunPuffEffect (pos, prot_to_rend[type], cnt);
|
||||
R_RunPuffEffect (tempentity.position, prot_to_rend[tempentity.type], 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
Sys_Error ("CL_ParseTEnt: bad type");
|
||||
Sys_Error ("CL_ParseTEnt: bad tempentity.type");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -103,15 +103,15 @@ NET_SVC_ServerData_Parse (net_svc_serverdata_t *serverdata, msg_t *message)
|
|||
qboolean
|
||||
NET_SVC_Sound_Parse (net_svc_sound_t *sound, msg_t *message)
|
||||
{
|
||||
int i;
|
||||
int i, header;
|
||||
|
||||
sound->channel = MSG_ReadShort (message);
|
||||
if (sound->channel & SND_VOLUME)
|
||||
header = MSG_ReadShort (message);
|
||||
if (header & SND_VOLUME)
|
||||
sound->volume = MSG_ReadByte (message) / 255.0;
|
||||
else
|
||||
sound->volume = DEFAULT_SOUND_PACKET_VOLUME / 255.0;
|
||||
|
||||
if (sound->channel & SND_ATTENUATION)
|
||||
if (header & SND_ATTENUATION)
|
||||
sound->attenuation = MSG_ReadByte (message) / 64.0;
|
||||
else
|
||||
sound->attenuation = DEFAULT_SOUND_PACKET_ATTENUATION;
|
||||
|
@ -121,8 +121,54 @@ NET_SVC_Sound_Parse (net_svc_sound_t *sound, msg_t *message)
|
|||
for (i = 0; i < 3; i++)
|
||||
sound->position[i] = MSG_ReadCoord (message);
|
||||
|
||||
sound->entity = (sound->channel >> 3) & 1023;
|
||||
sound->channel &= 7;
|
||||
sound->entity = (header >> 3) & 1023;
|
||||
sound->channel = header & 7;
|
||||
|
||||
return message->badread;
|
||||
}
|
||||
|
||||
qboolean
|
||||
NET_SVC_TempEntity_Parse (net_svc_tempentity_t *tempentity, msg_t *message)
|
||||
{
|
||||
int i;
|
||||
|
||||
tempentity->type = MSG_ReadByte (message);
|
||||
switch (tempentity->type) {
|
||||
case TE_WIZSPIKE:
|
||||
case TE_KNIGHTSPIKE:
|
||||
case TE_SPIKE:
|
||||
case TE_SUPERSPIKE:
|
||||
case TE_EXPLOSION:
|
||||
case TE_TAREXPLOSION:
|
||||
case TE_LAVASPLASH:
|
||||
case TE_TELEPORT:
|
||||
case TE_LIGHTNINGBLOOD:
|
||||
for (i = 0; i < 3; i++)
|
||||
tempentity->position[i] = MSG_ReadCoord (message);
|
||||
break;
|
||||
case TE_LIGHTNING1:
|
||||
case TE_LIGHTNING2:
|
||||
case TE_LIGHTNING3:
|
||||
case TE_BEAM:
|
||||
tempentity->beamentity = MSG_ReadShort (message);
|
||||
for (i = 0; i < 3; i++)
|
||||
tempentity->position[i] = MSG_ReadCoord (message);
|
||||
for (i = 0; i < 3; i++)
|
||||
tempentity->beamend[i] = MSG_ReadCoord (message);
|
||||
break;
|
||||
case TE_EXPLOSION2:
|
||||
for (i = 0; i < 3; i++)
|
||||
tempentity->position[i] = MSG_ReadCoord (message);
|
||||
tempentity->colorstart = MSG_ReadByte (message);
|
||||
tempentity->colorlength = MSG_ReadByte (message);
|
||||
break;
|
||||
case TE_GUNSHOT:
|
||||
case TE_BLOOD:
|
||||
tempentity->gunshotcount = MSG_ReadByte (message);
|
||||
for (i = 0; i < 3; i++)
|
||||
tempentity->position[i] = MSG_ReadCoord (message);
|
||||
break;
|
||||
}
|
||||
|
||||
return message->badread;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue