merge of cl_tents and r_efrag.

This commit is contained in:
Bill Currie 2001-05-15 21:34:54 +00:00
parent e7c2ed82db
commit e61c33c9d9
11 changed files with 490 additions and 263 deletions

View file

@ -81,16 +81,6 @@ typedef struct
#define SIGNONS 4 // signon messages to receive before connected
#define MAX_BEAMS 24
typedef struct
{
int entity;
struct model_s *model;
float endtime;
vec3_t start, end;
} beam_t;
#define MAX_EFRAGS 640
#define MAX_MAPSTRING 2048
@ -284,8 +274,6 @@ extern entity_t cl_entities[MAX_EDICTS];
extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
extern dlight_t cl_dlights[MAX_DLIGHTS];
extern entity_t cl_temp_entities[MAX_TEMP_ENTITIES];
extern beam_t cl_beams[MAX_BEAMS];
//=============================================================================
@ -363,7 +351,12 @@ void V_SetContentsColor (int contents);
//
// cl_tent
//
void CL_InitTEnts (void);
void CL_TEnts_Init (void);
void CL_ClearEnts (void);
void CL_ClearTEnts (void);
void CL_Init_Entity (struct entity_s *ent);
struct entity_s **CL_NewTempEntity (void);
void CL_ParseTEnt (void);
void CL_SignonReply (void);
void Cvar_Info (struct cvar_s *var);

View file

@ -167,16 +167,16 @@
#define TE_LIGHTNING3 9
#define TE_LAVASPLASH 10
#define TE_TELEPORT 11
#define TE_EXPLOSION2 12
// PGM 01/21/97
#define TE_BEAM 13
// PGM 01/21/97
#define TE_BLOOD 12
#define TE_LIGHTNINGBLOOD 13
#ifdef QUAKE2
#define TE_IMPLOSION 14
#define TE_RAILTRAIL 15
#endif
#define TE_EXPLOSION2 16
// PGM 01/21/97
#define TE_BEAM 17
// PGM 01/21/97
typedef struct entity_state_s
{

View file

@ -176,8 +176,6 @@ CL_ClearState (void)
memset (cl_entities, 0, sizeof (cl_entities));
memset (cl_dlights, 0, sizeof (cl_dlights));
memset (cl_lightstyle, 0, sizeof (cl_lightstyle));
memset (cl_temp_entities, 0, sizeof (cl_temp_entities));
memset (cl_beams, 0, sizeof (cl_beams));
// allocate the efrags and chain together into a free list
cl.free_efrags = cl_efrags;
@ -553,6 +551,7 @@ CL_LerpPoint (void)
void
CL_RelinkEntities (void)
{
entity_t **_ent;
entity_t *ent;
int i, j;
float frac, f, d;
@ -564,8 +563,6 @@ CL_RelinkEntities (void)
// determine partial update time
frac = CL_LerpPoint ();
cl_numvisedicts = 0;
// interpolate player info
for (i = 0; i < 3; i++)
cl.velocity[i] = cl.mvelocity[1][i] +
@ -713,10 +710,8 @@ CL_RelinkEntities (void)
if (ent->effects & EF_NODRAW)
continue;
#endif
if (cl_numvisedicts < MAX_VISEDICTS) {
cl_visedicts[cl_numvisedicts] = ent;
cl_numvisedicts++;
}
if ((_ent = CL_NewTempEntity ()))
*_ent = ent;
}
}
@ -748,6 +743,8 @@ CL_ReadFromServer (void)
if (cl_shownet->int_val)
Con_Printf ("\n");
cl_numvisedicts = 0;
CL_RelinkEntities ();
CL_UpdateTEnts ();
@ -798,7 +795,7 @@ CL_Init (void)
SZ_Alloc (&cls.message, 1024);
CL_InitInput ();
CL_InitTEnts ();
CL_TEnts_Init ();
Cmd_AddCommand ("entities", CL_PrintEntities_f, "No Description");
Cmd_AddCommand ("disconnect", CL_Disconnect_f, "No Description");

View file

@ -29,19 +29,49 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <math.h>
#include <stdlib.h>
#include "QF/console.h"
#include "QF/model.h"
#include "QF/msg.h"
#include "QF/sound.h"
#include "QF/sys.h"
#include "client.h"
#include "protocol.h"
#include "render.h"
#include "r_dynamic.h"
#define MAX_BEAMS 8
#define MAX_BEAM_ENTS 20
typedef struct {
int entity;
struct model_s *model;
float endtime;
vec3_t start, end;
entity_t ent_list[MAX_BEAM_ENTS];
int ent_count;
} beam_t;
int num_temp_entities;
entity_t cl_temp_entities[MAX_TEMP_ENTITIES];
beam_t cl_beams[MAX_BEAMS];
#define MAX_EXPLOSIONS 8
typedef struct {
float start;
entity_t ent;
} explosion_t;
explosion_t cl_explosions[MAX_EXPLOSIONS];
sfx_t *cl_sfx_wizhit;
sfx_t *cl_sfx_knighthit;
sfx_t *cl_sfx_tink1;
@ -56,7 +86,7 @@ sfx_t *cl_sfx_rail;
void
CL_InitTEnts (void)
CL_TEnts_Init (void)
{
cl_sfx_wizhit = S_PrecacheSound ("wizard/hit.wav");
cl_sfx_knighthit = S_PrecacheSound ("hknight/hit.wav");
@ -72,6 +102,65 @@ CL_InitTEnts (void)
}
void
CL_Init_Entity (entity_t *ent)
{
memset (ent, 0, sizeof (*ent));
ent->colormap = vid.colormap;
#if 0
ent->glow_size = 0;
ent->glow_color = 254;
ent->alpha = 1;
ent->scale = 1;
ent->colormod[0] = ent->colormod[1] = ent->colormod[2] = 1;
#endif
ent->pose1 = ent->pose2 = -1;
}
void
CL_ClearTEnts (void)
{
int i;
memset (&cl_beams, 0, sizeof (cl_beams));
memset (&cl_explosions, 0, sizeof (cl_explosions));
for (i = 0; i < MAX_BEAMS; i++) {
int j;
for (j = 0; j < MAX_BEAM_ENTS; j++) {
CL_Init_Entity(&cl_beams[i].ent_list[j]);
}
}
for (i = 0; i < MAX_EXPLOSIONS; i++) {
CL_Init_Entity(&cl_explosions[i].ent);
}
}
explosion_t *
CL_AllocExplosion (void)
{
int i;
float time;
int index;
for (i = 0; i < MAX_EXPLOSIONS; i++)
if (!cl_explosions[i].ent.model)
return &cl_explosions[i];
// find the oldest explosion
time = cl.time;
index = 0;
for (i = 0; i < MAX_EXPLOSIONS; i++)
if (cl_explosions[i].start < time) {
time = cl_explosions[i].start;
index = i;
}
return &cl_explosions[index];
}
void
CL_ParseBeam (model_t *m)
{
@ -90,7 +179,7 @@ CL_ParseBeam (model_t *m)
end[1] = MSG_ReadCoord (net_message);
end[2] = MSG_ReadCoord (net_message);
// 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++)
if (b->entity == ent) {
b->entity = ent;
@ -100,7 +189,7 @@ CL_ParseBeam (model_t *m)
VectorCopy (end, b->end);
return;
}
// find a free beam
// 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;
@ -118,243 +207,240 @@ CL_ParseBeam (model_t *m)
void
CL_ParseTEnt (void)
{
int type;
byte type;
vec3_t pos;
#ifdef QUAKE2
vec3_t endpos;
#endif
dlight_t *dl;
int rnd;
//int cnt = -1;
int colorStart, colorLength;
explosion_t *ex;
int cnt = -1;
type = MSG_ReadByte (net_message);
//XXX FIXME this is to get around an nq/qw protocol colission
if (1) {
if (type == TE_BLOOD)
type = TE_EXPLOSION2;
else if (type == TE_LIGHTNINGBLOOD)
type = TE_BEAM;
}
switch (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, type);
// R_RunParticleEffect (pos, vec3_origin, 20, 30);
S_StartSound (-1, 0, cl_sfx_wizhit, pos, 1, 1);
break;
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, type);
S_StartSound (-1, 0, cl_sfx_wizhit, pos, 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, type);
// R_RunParticleEffect (pos, vec3_origin, 226, 20);
S_StartSound (-1, 0, cl_sfx_knighthit, pos, 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, type);
S_StartSound (-1, 0, cl_sfx_knighthit, pos, 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, type);
// R_RunParticleEffect (pos, vec3_origin, 0, 10);
if (rand () % 5)
S_StartSound (-1, 0, cl_sfx_tink1, pos, 1, 1);
else {
rnd = rand () & 3;
if (rnd == 1)
S_StartSound (-1, 0, cl_sfx_ric1, pos, 1, 1);
else if (rnd == 2)
S_StartSound (-1, 0, cl_sfx_ric2, pos, 1, 1);
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, type);
if (rand () % 5)
S_StartSound (-1, 0, cl_sfx_tink1, pos, 1, 1);
else {
rnd = rand () & 3;
if (rnd == 1)
S_StartSound (-1, 0, cl_sfx_ric1, pos, 1, 1);
else if (rnd == 2)
S_StartSound (-1, 0, cl_sfx_ric2, pos, 1, 1);
else
S_StartSound (-1, 0, cl_sfx_ric3, pos, 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, type);
if (rand () % 5)
S_StartSound (-1, 0, cl_sfx_tink1, pos, 1, 1);
else {
rnd = rand () & 3;
if (rnd == 1)
S_StartSound (-1, 0, cl_sfx_ric1, pos, 1, 1);
else if (rnd == 2)
S_StartSound (-1, 0, cl_sfx_ric2, pos, 1, 1);
else
S_StartSound (-1, 0, cl_sfx_ric3, pos, 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);
// light
dl = CL_AllocDlight (0);
VectorCopy (pos, dl->origin);
dl->radius = 350;
dl->die = cl.time + 0.5;
dl->decay = 300;
dl->color[0] = 0.86;
dl->color[1] = 0.31;
dl->color[2] = 0.24;
// sound
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
// sprite
ex = CL_AllocExplosion ();
VectorCopy (pos, ex->ent.origin);
ex->start = cl.time;
ex->ent.model = Mod_ForName ("progs/s_explod.spr", true);
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);
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
break;
case TE_LIGHTNING1: // lightning bolts
CL_ParseBeam (Mod_ForName ("progs/bolt.mdl", true));
break;
case TE_LIGHTNING2: // lightning bolts
CL_ParseBeam (Mod_ForName ("progs/bolt2.mdl", true));
break;
case TE_LIGHTNING3: // lightning bolts
CL_ParseBeam (Mod_ForName ("progs/bolt3.mdl", true));
break;
// PGM 01/21/97
case TE_BEAM: // grappling hook beam
CL_ParseBeam (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);
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);
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);
dl = CL_AllocDlight (0);
VectorCopy (pos, dl->origin);
dl->radius = 350;
dl->die = cl.time + 0.5;
dl->decay = 300;
dl->color[0] = 0.86;
dl->color[1] = 0.31;
dl->color[2] = 0.24;
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
break;
case TE_GUNSHOT: // bullet hitting wall
case TE_BLOOD: // bullets hitting body
if (type == TE_GUNSHOT)
cnt = 20;
else
S_StartSound (-1, 0, cl_sfx_ric3, pos, 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, type);
// R_RunParticleEffect (pos, vec3_origin, 0, 20);
if (rand () % 5)
S_StartSound (-1, 0, cl_sfx_tink1, pos, 1, 1);
else {
rnd = rand () & 3;
if (rnd == 1)
S_StartSound (-1, 0, cl_sfx_ric1, pos, 1, 1);
else if (rnd == 2)
S_StartSound (-1, 0, cl_sfx_ric2, pos, 1, 1);
else
S_StartSound (-1, 0, cl_sfx_ric3, pos, 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);
// light
dl = CL_AllocDlight (0);
VectorCopy (pos, dl->origin);
dl->radius = 350;
dl->die = cl.time + 0.5;
dl->decay = 300;
dl->color[0] = 0.86;
dl->color[1] = 0.31;
dl->color[2] = 0.24;
// sound
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
/* CL_AllocExplosion?
// sprite
ex = CL_AllocExplosion ();
VectorCopy (pos, ex->ent.origin);
ex->start = cl.time;
ex->ent.model = Mod_ForName ("progs/s_explod.spr", true);
*/
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);
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
break;
case TE_LIGHTNING1: // lightning bolts
CL_ParseBeam (Mod_ForName ("progs/bolt.mdl", true));
break;
case TE_LIGHTNING2: // lightning bolts
CL_ParseBeam (Mod_ForName ("progs/bolt2.mdl", true));
break;
case TE_LIGHTNING3: // lightning bolts
CL_ParseBeam (Mod_ForName ("progs/bolt3.mdl", true));
break;
// PGM 01/21/97
case TE_BEAM: // grappling hook beam
CL_ParseBeam (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);
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);
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);
dl = CL_AllocDlight (0);
VectorCopy (pos, dl->origin);
dl->radius = 350;
dl->die = cl.time + 0.5;
dl->decay = 300;
dl->color[0] = 0.86;
dl->color[1] = 0.31;
dl->color[2] = 0.24;
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
break;
case TE_GUNSHOT: // bullet hitting wall
//cnt = MSG_ReadByte (net_message);
pos[0] = MSG_ReadCoord (net_message);
pos[1] = MSG_ReadCoord (net_message);
pos[2] = MSG_ReadCoord (net_message);
R_RunPuffEffect (pos, 0, 20);
break;
cnt = MSG_ReadByte (net_message);
/* FALLTHROUGH */
case TE_LIGHTNINGBLOOD: // lightning hitting body
pos[0] = MSG_ReadCoord (net_message);
pos[1] = MSG_ReadCoord (net_message);
pos[2] = MSG_ReadCoord (net_message);
R_RunPuffEffect (pos, type, cnt);
break;
#ifdef QUAKE2
case TE_IMPLOSION:
pos[0] = MSG_ReadCoord (net_message);
pos[1] = MSG_ReadCoord (net_message);
pos[2] = MSG_ReadCoord (net_message);
S_StartSound (-1, 0, cl_sfx_imp, pos, 1, 1);
break;
case TE_IMPLOSION:
pos[0] = MSG_ReadCoord (net_message);
pos[1] = MSG_ReadCoord (net_message);
pos[2] = MSG_ReadCoord (net_message);
S_StartSound (-1, 0, cl_sfx_imp, pos, 1, 1);
break;
case TE_RAILTRAIL:
pos[0] = MSG_ReadCoord (net_message);
pos[1] = MSG_ReadCoord (net_message);
pos[2] = MSG_ReadCoord (net_message);
endpos[0] = MSG_ReadCoord (net_message);
endpos[1] = MSG_ReadCoord (net_message);
endpos[2] = MSG_ReadCoord (net_message);
S_StartSound (-1, 0, cl_sfx_rail, pos, 1, 1);
S_StartSound (-1, 1, cl_sfx_r_exp3, endpos, 1, 1);
/* Need updating to new Particle API
R_RocketTrail (pos, endpos, 0 + 128);
R_ParticleExplosion (endpos);
*/
dl = CL_AllocDlight (-1);
VectorCopy (endpos, dl->origin);
dl->radius = 350;
dl->die = cl.time + 0.5;
dl->decay = 300;
dl->color[0] = 0.86;
dl->color[1] = 0.31;
dl->color[2] = 0.24;
break;
case TE_RAILTRAIL:
pos[0] = MSG_ReadCoord (net_message);
pos[1] = MSG_ReadCoord (net_message);
pos[2] = MSG_ReadCoord (net_message);
endpos[0] = MSG_ReadCoord (net_message);
endpos[1] = MSG_ReadCoord (net_message);
endpos[2] = MSG_ReadCoord (net_message);
S_StartSound (-1, 0, cl_sfx_rail, pos, 1, 1);
S_StartSound (-1, 1, cl_sfx_r_exp3, endpos, 1, 1);
/* Need updating to new Particle API
R_RocketTrail (pos, endpos, 0 + 128);
R_ParticleExplosion (endpos);
*/
dl = CL_AllocDlight (-1);
VectorCopy (endpos, dl->origin);
dl->radius = 350;
dl->die = cl.time + 0.5;
dl->decay = 300;
dl->color[0] = 0.86;
dl->color[1] = 0.31;
dl->color[2] = 0.24;
break;
#endif
default:
Sys_Error ("CL_ParseTEnt: bad type");
default:
Sys_Error ("CL_ParseTEnt: bad type");
}
}
entity_t *
entity_t **
CL_NewTempEntity (void)
{
entity_t *ent;
if (cl_numvisedicts == MAX_VISEDICTS)
return NULL;
if (num_temp_entities == MAX_TEMP_ENTITIES)
return NULL;
ent = &cl_temp_entities[num_temp_entities];
memset (ent, 0, sizeof (*ent));
num_temp_entities++;
cl_visedicts[cl_numvisedicts] = ent;
cl_numvisedicts++;
ent->colormap = vid.colormap;
return ent;
return &cl_visedicts[cl_numvisedicts++];
}
void
CL_UpdateTEnts (void)
CL_UpdateBeams (void)
{
int i;
beam_t *b;
vec3_t dist, org;
float d;
entity_t *ent;
entity_t **ent;
float yaw, pitch;
float forward;
num_temp_entities = 0;
// update lightning
// update lightning
for (i = 0, b = cl_beams; i < MAX_BEAMS; i++, b++) {
if (!b->model || b->endtime < cl.time)
continue;
@ -386,19 +472,54 @@ CL_UpdateTEnts (void)
// add new entities for the lightning
VectorCopy (b->start, org);
d = VectorNormalize (dist);
while (d > 0) {
b->ent_count = 0;
while (d > 0 && b->ent_count < MAX_BEAM_ENTS) {
ent = CL_NewTempEntity ();
if (!ent)
return;
VectorCopy (org, ent->origin);
ent->model = b->model;
ent->angles[0] = pitch;
ent->angles[1] = yaw;
ent->angles[2] = rand () % 360;
*ent = &b->ent_list[b->ent_count++];
VectorCopy (org, (*ent)->origin);
(*ent)->model = b->model;
(*ent)->angles[0] = pitch;
(*ent)->angles[1] = yaw;
(*ent)->angles[2] = rand () % 360;
VectorMA (org, 30, dist, org);
VectorMA(org, 30, dist, org);
d -= 30;
}
}
}
void
CL_UpdateExplosions (void)
{
int i;
int f;
explosion_t *ex;
entity_t **ent;
for (i = 0, ex = cl_explosions; i < MAX_EXPLOSIONS; i++, ex++) {
if (!ex->ent.model)
continue;
f = 10 * (cl.time - ex->start);
if (f >= ex->ent.model->numframes) {
ex->ent.model = NULL;
continue;
}
ent = CL_NewTempEntity ();
if (!ent)
return;
ex->ent.frame = f;
*ent = &ex->ent;
}
}
void
CL_UpdateTEnts (void)
{
CL_UpdateBeams ();
CL_UpdateExplosions ();
}

View file

@ -1087,7 +1087,7 @@ R_Mirror (void)
{
float d;
msurface_t *s;
entity_t *ent;
entity_t **ent;
if (!mirror)
return;
@ -1106,11 +1106,9 @@ R_Mirror (void)
r_refdef.viewangles[1] = atan2 (vpn[1], vpn[0]) / M_PI * 180;
r_refdef.viewangles[2] = -r_refdef.viewangles[2];
ent = &cl_entities[cl.viewentity];
if (cl_numvisedicts < MAX_VISEDICTS) {
cl_visedicts[cl_numvisedicts] = ent;
cl_numvisedicts++;
}
ent = CL_NewTempEntity();
if (ent)
*ent = &cl_entities[cl.viewentity];
gldepthmin = 0.5;
gldepthmax = 1;

View file

@ -243,9 +243,11 @@ R_StoreEfrags (efrag_t **ppefrag)
case mod_sprite:
pent = pefrag->entity;
if ((pent->visframe != r_framecount) &&
(cl_numvisedicts < MAX_VISEDICTS)) {
cl_visedicts[cl_numvisedicts++] = pent;
if (pent->visframe != r_framecount) {
entity_t **ent = CL_NewTempEntity ();
if (!ent)
return;
*ent = pent;
// mark that we've recorded this entity for this frame
pent->visframe = r_framecount;

View file

@ -244,6 +244,14 @@
#define TE_TELEPORT 11
#define TE_BLOOD 12
#define TE_LIGHTNINGBLOOD 13
#ifdef QUAKE2
#define TE_IMPLOSION 14
#define TE_RAILTRAIL 15
#endif
#define TE_EXPLOSION2 16
// PGM 01/21/97
#define TE_BEAM 17
// PGM 01/21/97
/*

View file

@ -63,8 +63,6 @@ static struct predicted_player {
vec3_t origin; // predicted origin
} predicted_players[MAX_CLIENTS];
entity_t **CL_NewTempEntity (void);
entity_t cl_packet_ents[512]; // FIXME: magic number
entity_t cl_flag_ents[MAX_CLIENTS];
entity_t cl_player_ents[MAX_CLIENTS];

View file

@ -39,16 +39,17 @@
#include <math.h>
#include <stdlib.h>
#include "QF/console.h"
#include "QF/model.h"
#include "QF/msg.h"
#include "QF/sound.h"
#include "QF/sys.h"
#include "cl_ents.h"
#include "cl_main.h"
#include "cl_tent.h"
#include "client.h"
#include "QF/console.h"
#include "host.h"
#include "QF/model.h"
#include "QF/msg.h"
#include "r_dynamic.h"
#include "QF/sound.h"
#define MAX_BEAMS 8
#define MAX_BEAM_ENTS 20
@ -81,6 +82,10 @@ sfx_t *cl_sfx_ric1;
sfx_t *cl_sfx_ric2;
sfx_t *cl_sfx_ric3;
sfx_t *cl_sfx_r_exp3;
#ifdef QUAKE2
sfx_t *cl_sfx_imp;
sfx_t *cl_sfx_rail;
#endif
void
@ -93,6 +98,10 @@ CL_TEnts_Init (void)
cl_sfx_ric2 = S_PrecacheSound ("weapons/ric2.wav");
cl_sfx_ric3 = S_PrecacheSound ("weapons/ric3.wav");
cl_sfx_r_exp3 = S_PrecacheSound ("weapons/r_exp3.wav");
#ifdef QUAKE2
cl_sfx_imp = S_PrecacheSound ("shambler/sattck1.wav");
cl_sfx_rail = S_PrecacheSound ("weapons/lstart.wav");
#endif
}
@ -201,8 +210,12 @@ CL_ParseTEnt (void)
{
byte type;
vec3_t pos;
#ifdef QUAKE2
vec3_t endpos;
#endif
dlight_t *dl;
int rnd;
int colorStart, colorLength;
explosion_t *ex;
int cnt = -1;
@ -213,7 +226,6 @@ CL_ParseTEnt (void)
pos[1] = MSG_ReadCoord (net_message);
pos[2] = MSG_ReadCoord (net_message);
R_RunSpikeEffect (pos, type);
// R_RunParticleEffect (pos, 20, 30);
S_StartSound (-1, 0, cl_sfx_wizhit, pos, 1, 1);
break;
@ -222,7 +234,6 @@ CL_ParseTEnt (void)
pos[1] = MSG_ReadCoord (net_message);
pos[2] = MSG_ReadCoord (net_message);
R_RunSpikeEffect (pos, type);
// R_RunParticleEffect (pos, 226, 20);
S_StartSound (-1, 0, cl_sfx_knighthit, pos, 1, 1);
break;
@ -231,7 +242,6 @@ CL_ParseTEnt (void)
pos[1] = MSG_ReadCoord (net_message);
pos[2] = MSG_ReadCoord (net_message);
R_RunSpikeEffect (pos, type);
// R_RunParticleEffect (pos, 0, 10);
if (rand () % 5)
S_StartSound (-1, 0, cl_sfx_tink1, pos, 1, 1);
@ -251,7 +261,6 @@ CL_ParseTEnt (void)
pos[1] = MSG_ReadCoord (net_message);
pos[2] = MSG_ReadCoord (net_message);
R_RunSpikeEffect (pos, type);
// R_RunParticleEffect (pos, 0, 20);
if (rand () % 5)
S_StartSound (-1, 0, cl_sfx_tink1, pos, 1, 1);
@ -314,6 +323,12 @@ CL_ParseTEnt (void)
CL_ParseBeam (Mod_ForName ("progs/bolt3.mdl", true));
break;
// PGM 01/21/97
case TE_BEAM: // grappling hook beam
CL_ParseBeam (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);
@ -328,6 +343,24 @@ CL_ParseTEnt (void)
R_TeleportSplash (pos);
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);
dl = CL_AllocDlight (0);
VectorCopy (pos, dl->origin);
dl->radius = 350;
dl->die = cl.time + 0.5;
dl->decay = 300;
dl->color[0] = 0.86;
dl->color[1] = 0.31;
dl->color[2] = 0.24;
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
break;
case TE_GUNSHOT: // bullet hitting wall
case TE_BLOOD: // bullets hitting body
cnt = MSG_ReadByte (net_message);
@ -336,11 +369,42 @@ CL_ParseTEnt (void)
pos[1] = MSG_ReadCoord (net_message);
pos[2] = MSG_ReadCoord (net_message);
R_RunPuffEffect (pos, type, cnt);
// R_RunParticleEffect (pos, 0, 20*cnt);
break;
#ifdef QUAKE2
case TE_IMPLOSION:
pos[0] = MSG_ReadCoord (net_message);
pos[1] = MSG_ReadCoord (net_message);
pos[2] = MSG_ReadCoord (net_message);
S_StartSound (-1, 0, cl_sfx_imp, pos, 1, 1);
break;
case TE_RAILTRAIL:
pos[0] = MSG_ReadCoord (net_message);
pos[1] = MSG_ReadCoord (net_message);
pos[2] = MSG_ReadCoord (net_message);
endpos[0] = MSG_ReadCoord (net_message);
endpos[1] = MSG_ReadCoord (net_message);
endpos[2] = MSG_ReadCoord (net_message);
S_StartSound (-1, 0, cl_sfx_rail, pos, 1, 1);
S_StartSound (-1, 1, cl_sfx_r_exp3, endpos, 1, 1);
/* Need updating to new Particle API
R_RocketTrail (pos, endpos, 0 + 128);
R_ParticleExplosion (endpos);
*/
dl = CL_AllocDlight (-1);
VectorCopy (endpos, dl->origin);
dl->radius = 350;
dl->die = cl.time + 0.5;
dl->decay = 300;
dl->color[0] = 0.86;
dl->color[1] = 0.31;
dl->color[2] = 0.24;
break;
#endif
default:
Host_EndGame ("CL_ParseTEnt: bad type");
Sys_Error ("CL_ParseTEnt: bad type");
}
}

View file

@ -228,6 +228,22 @@ R_ParticleExplosion (vec3_t org)
}
void
R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength)
{
int i;
int colorMod = 0;
if (!r_particles->int_val)
return;
for (i = 0; i < 512; i++) {
particle_new_random (pt_blob, part_tex_dot, org, 16, 2, 256, (cl.time + 0.3), (colorStart + (colorMod % colorLength)), 255);
colorMod++;
}
}
void
R_BlobExplosion (vec3_t org)
{

View file

@ -233,6 +233,36 @@ R_ParticleExplosion (vec3_t org)
}
void
R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength)
{
int i, j;
particle_t *p;
int colorMod = 0;
for (i=0; i<512; i++)
{
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->die = cl.time + 0.3;
p->color = colorStart + (colorMod % colorLength);
colorMod++;
p->type = pt_blob;
for (j=0 ; j<3 ; j++)
{
p->org[j] = org[j] + ((rand()%32)-16);
p->vel[j] = (rand()%512)-256;
}
}
}
void
R_BlobExplosion (vec3_t org)
{