First pass at updating nq particles. Compiles. Crashes. Taniwha wanted a look. Flee in terror.

Also has bunches of cleanups, including string.h/strings.h ifdefs, whitespace, and removal of pointless comments.
This commit is contained in:
Ragnvald Maartmann-Moe IV 2001-05-09 05:41:34 +00:00
parent 80814f5437
commit f6374b48ce
56 changed files with 2934 additions and 2989 deletions

View file

@ -31,23 +31,20 @@
# include "config.h"
#endif
#include "r_local.h"
#include "QF/qargs.h"
#include "QF/compat.h"
#include "QF/console.h"
#include "server.h"
#include "QF/msg.h"
#include "r_local.h"
#include "server.h"
#define MAX_PARTICLES 2048 // default max # of particles at one
// time
#define ABSOLUTE_MIN_PARTICLES 512 // no fewer than this no matter
// what's
// on the command line
int ramp1[8] = { 0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61 };
int ramp2[8] = { 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x68, 0x66 };
int ramp3[8] = { 0x6d, 0x6b, 6, 5, 4, 3 };
particle_t *active_particles, *free_particles;
particle_t *particles;
@ -55,13 +52,8 @@ int r_numparticles;
vec3_t r_pright, r_pup, r_ppn;
extern cvar_t *gl_particles;
/*
===============
R_InitParticles
===============
*/
void
R_InitParticles (void)
{
@ -124,12 +116,6 @@ R_DarkFieldParticles (entity_t *ent)
#endif
/*
===============
R_EntityParticles
===============
*/
#define NUMVERTEXNORMALS 162
extern float r_avertexnormals[NUMVERTEXNORMALS][3];
vec3_t avelocities[NUMVERTEXNORMALS];
@ -197,74 +183,6 @@ R_EntityParticles (entity_t *ent)
}
/*
===============
R_ClearParticles
===============
*/
void
R_ClearParticles (void)
{
int i;
free_particles = &particles[0];
active_particles = NULL;
for (i = 0; i < r_numparticles; i++)
particles[i].next = &particles[i + 1];
particles[r_numparticles - 1].next = NULL;
}
void
R_ReadPointFile_f (void)
{
QFile *f;
vec3_t org;
int r;
int c;
particle_t *p;
char name[MAX_OSPATH];
char buf[256];
snprintf (name, sizeof (name), "maps/%s.pts", sv.name);
COM_FOpenFile (name, &f);
if (!f) {
Con_Printf ("couldn't open %s\n", name);
return;
}
Con_Printf ("Reading %s...\n", name);
c = 0;
for (;;) {
if (!Qgets (f, buf, sizeof (buf)))
break;
r = sscanf (buf, "%f %f %f\n", &org[0], &org[1], &org[2]);
if (r != 3)
break;
c++;
if (!free_particles) {
Con_Printf ("Not enough free particles\n");
break;
}
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->die = 99999;
p->color = (-c) & 15;
p->type = pt_static;
VectorCopy (vec3_origin, p->vel);
VectorCopy (org, p->org);
}
Qclose (f);
Con_Printf ("%i points read\n", c);
}
/*
===============
R_ParseParticleEffect
@ -290,356 +208,5 @@ R_ParseParticleEffect (void)
else
count = msgcount;
R_RunParticleEffect (org, dir, color, count);
}
/*
===============
R_ParticleExplosion
===============
*/
void
R_ParticleExplosion (vec3_t org)
{
int i, j;
particle_t *p;
for (i = 0; i < 1024; i++) {
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->die = cl.time + 5;
p->color = ramp1[0];
p->ramp = rand () & 3;
if (i & 1) {
p->type = pt_explode;
for (j = 0; j < 3; j++) {
p->org[j] = org[j] + ((rand () % 32) - 16);
p->vel[j] = (rand () % 512) - 256;
}
} else {
p->type = pt_explode2;
for (j = 0; j < 3; j++) {
p->org[j] = org[j] + ((rand () % 32) - 16);
p->vel[j] = (rand () % 512) - 256;
}
}
}
}
/*
===============
R_ParticleExplosion2
===============
*/
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;
}
}
}
/*
===============
R_BlobExplosion
===============
*/
void
R_BlobExplosion (vec3_t org)
{
int i, j;
particle_t *p;
for (i = 0; i < 1024; i++) {
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->die = cl.time + 1 + (rand () & 8) * 0.05;
if (i & 1) {
p->type = pt_blob;
p->color = 66 + rand () % 6;
for (j = 0; j < 3; j++) {
p->org[j] = org[j] + ((rand () % 32) - 16);
p->vel[j] = (rand () % 512) - 256;
}
} else {
p->type = pt_blob2;
p->color = 150 + rand () % 6;
for (j = 0; j < 3; j++) {
p->org[j] = org[j] + ((rand () % 32) - 16);
p->vel[j] = (rand () % 512) - 256;
}
}
}
}
/*
===============
R_RunParticleEffect
===============
*/
void
R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count)
{
int i, j;
particle_t *p;
for (i = 0; i < count; i++) {
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
if (count == 1024) { // rocket explosion
p->die = cl.time + 5;
p->color = ramp1[0];
p->ramp = rand () & 3;
if (i & 1) {
p->type = pt_explode;
for (j = 0; j < 3; j++) {
p->org[j] = org[j] + ((rand () % 32) - 16);
p->vel[j] = (rand () % 512) - 256;
}
} else {
p->type = pt_explode2;
for (j = 0; j < 3; j++) {
p->org[j] = org[j] + ((rand () % 32) - 16);
p->vel[j] = (rand () % 512) - 256;
}
}
} else {
p->die = cl.time + 0.1 * (rand () % 5);
p->color = (color & ~7) + (rand () & 7);
p->type = pt_slowgrav;
for (j = 0; j < 3; j++) {
p->org[j] = org[j] + ((rand () & 15) - 8);
p->vel[j] = dir[j] * 15; // + (rand()%300)-150;
}
}
}
}
/*
===============
R_LavaSplash
===============
*/
void
R_LavaSplash (vec3_t org)
{
int i, j, k;
particle_t *p;
float vel;
vec3_t dir;
for (i = -16; i < 16; i++)
for (j = -16; j < 16; j++)
for (k = 0; k < 1; k++) {
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->die = cl.time + 2 + (rand () & 31) * 0.02;
p->color = 224 + (rand () & 7);
p->type = pt_slowgrav;
dir[0] = j * 8 + (rand () & 7);
dir[1] = i * 8 + (rand () & 7);
dir[2] = 256;
p->org[0] = org[0] + dir[0];
p->org[1] = org[1] + dir[1];
p->org[2] = org[2] + (rand () & 63);
VectorNormalize (dir);
vel = 50 + (rand () & 63);
VectorScale (dir, vel, p->vel);
}
}
/*
===============
R_TeleportSplash
===============
*/
void
R_TeleportSplash (vec3_t org)
{
int i, j, k;
particle_t *p;
float vel;
vec3_t dir;
for (i = -16; i < 16; i += 4)
for (j = -16; j < 16; j += 4)
for (k = -24; k < 32; k += 4) {
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->die = cl.time + 0.2 + (rand () & 7) * 0.02;
p->color = 7 + (rand () & 7);
p->type = pt_slowgrav;
dir[0] = j * 8;
dir[1] = i * 8;
dir[2] = k * 8;
p->org[0] = org[0] + i + (rand () & 3);
p->org[1] = org[1] + j + (rand () & 3);
p->org[2] = org[2] + k + (rand () & 3);
VectorNormalize (dir);
vel = 50 + (rand () & 63);
VectorScale (dir, vel, p->vel);
}
}
void
R_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent)
{
vec3_t vec;
float len;
int j;
particle_t *p;
int dec;
static int tracercount;
if (type == 0)
R_AddFire (start, end, ent);
if (!gl_particles->int_val)
return;
VectorSubtract (end, start, vec);
len = VectorNormalize (vec);
if (type < 128)
dec = 3;
else {
dec = 1;
type -= 128;
}
while (len > 0) {
len -= dec;
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
VectorCopy (vec3_origin, p->vel);
p->die = cl.time + 2;
switch (type) {
case 0: // rocket trail
p->ramp = (rand () & 3);
p->color = ramp3[(int) p->ramp];
p->type = pt_fire;
for (j = 0; j < 3; j++)
p->org[j] = start[j] + ((rand () % 6) - 3);
break;
case 1: // smoke smoke
p->ramp = (rand () & 3) + 2;
p->color = ramp3[(int) p->ramp];
p->type = pt_fire;
for (j = 0; j < 3; j++)
p->org[j] = start[j] + ((rand () % 6) - 3);
break;
case 2: // blood
p->type = pt_grav;
p->color = 67 + (rand () & 3);
for (j = 0; j < 3; j++)
p->org[j] = start[j] + ((rand () % 6) - 3);
break;
case 3:
case 5: // tracer
p->die = cl.time + 0.5;
p->type = pt_static;
if (type == 3)
p->color = 52 + ((tracercount & 4) << 1);
else
p->color = 230 + ((tracercount & 4) << 1);
tracercount++;
VectorCopy (start, p->org);
if (tracercount & 1) {
p->vel[0] = 30 * vec[1];
p->vel[1] = 30 * -vec[0];
} else {
p->vel[0] = 30 * -vec[1];
p->vel[1] = 30 * vec[0];
}
break;
case 4: // slight blood
p->type = pt_grav;
p->color = 67 + (rand () & 3);
for (j = 0; j < 3; j++)
p->org[j] = start[j] + ((rand () % 6) - 3);
len -= 3;
break;
case 6: // voor trail
p->color = 9 * 16 + 8 + (rand () & 3);
p->type = pt_static;
p->die = cl.time + 0.3;
for (j = 0; j < 3; j++)
p->org[j] = start[j] + ((rand () & 15) - 8);
break;
}
VectorAdd (start, vec, start);
}
R_RunParticleEffect (org, color, count);
}