Den Zufallsgenerator wieder raus

This commit is contained in:
Yamagi Burmeister 2010-06-17 15:11:51 +00:00
parent 9447523700
commit f65ec5eff8
8 changed files with 85 additions and 192 deletions

View file

@ -199,8 +199,7 @@ COMMON_OBJS = \
build/common/files.o \ build/common/files.o \
build/common/md4.o \ build/common/md4.o \
build/common/net_chan.o \ build/common/net_chan.o \
build/common/pmove.o \ build/common/pmove.o
build/common/rand.o
# ---------- # ----------
@ -272,8 +271,7 @@ DEDICATED_SERVER_COMMON_OBJS = \
build/dedicated_server_common/files.o \ build/dedicated_server_common/files.o \
build/dedicated_server_common/md4.o \ build/dedicated_server_common/md4.o \
build/dedicated_server_common/net_chan.o \ build/dedicated_server_common/net_chan.o \
build/dedicated_server_common/pmove.o \ build/dedicated_server_common/pmove.o
build/dedicated_server_common/rand.o
# ---------- # ----------
@ -491,9 +489,6 @@ build/common/net_chan.o : src/common/net_chan.c
build/common/pmove.o : src/common/pmove.c build/common/pmove.o : src/common/pmove.c
$(CC) $(CFLAGS_CLIENT) -o $@ -c $< $(CC) $(CFLAGS_CLIENT) -o $@ -c $<
build/common/rand.o : src/common/rand.c
$(CC) $(CFLAGS_CLIENT) -o $@ -c $<
# ---------- # ----------
build/unzip/ioapi.o : src/unzip/ioapi.c build/unzip/ioapi.o : src/unzip/ioapi.c
@ -624,9 +619,6 @@ build/dedicated_server_common/net_chan.o : src/common/net_chan.c
build/dedicated_server_common/pmove.o : src/common/pmove.c build/dedicated_server_common/pmove.o : src/common/pmove.c
$(CC) $(CFLAGS_DEDICATED_SERVER) -o $@ -c $< $(CC) $(CFLAGS_DEDICATED_SERVER) -o $@ -c $<
build/dedicated_server_common/rand.o : src/common/rand.c
$(CC) $(CFLAGS_DEDICATED_SERVER) -o $@ -c $<
# ---------- # ----------
# Dedicated server POSIX build # Dedicated server POSIX build

View file

@ -706,7 +706,7 @@ void CL_AddPacketEntities (frame_t *frame) {
if ( renderfx & RF_BEAM ) { if ( renderfx & RF_BEAM ) {
/* the four beam colors are encoded in 32 bits of skinnum (hack) */ /* the four beam colors are encoded in 32 bits of skinnum (hack) */
ent.alpha = 0.30f; ent.alpha = 0.30f;
ent.skinnum = (s1->skinnum >> ((mtrand() % 4)*8)) & 0xff; ent.skinnum = (s1->skinnum >> ((rand() % 4)*8)) & 0xff;
ent.model = NULL; ent.model = NULL;
} else { } else {
@ -987,7 +987,7 @@ void CL_AddPacketEntities (frame_t *frame) {
} else if (effects & EF_TRAP) { } else if (effects & EF_TRAP) {
ent.origin[2] += 32; ent.origin[2] += 32;
CL_TrapParticles (&ent); CL_TrapParticles (&ent);
i = (mtrand()%100) + 100; i = (rand()%100) + 100;
V_AddLight (ent.origin, i, 1, 0.8f, 0.1f); V_AddLight (ent.origin, i, 1, 0.8f, 0.1f);
} else if (effects & EF_FLAG1) { } else if (effects & EF_FLAG1) {

View file

@ -191,10 +191,10 @@ void CL_ParseMuzzleFlash (void) {
VectorMA (dl->origin, 16, rv, dl->origin); VectorMA (dl->origin, 16, rv, dl->origin);
if (silenced) if (silenced)
dl->radius = 100.0f + (mtrand()&31); dl->radius = 100.0f + (rand()&31);
else else
dl->radius = 200.0f + (mtrand()&31); dl->radius = 200.0f + (rand()&31);
dl->minlight = 32; dl->minlight = 32;
dl->die = cl.time; dl->die = cl.time;
@ -228,7 +228,7 @@ void CL_ParseMuzzleFlash (void) {
dl->color[0] = 1; dl->color[0] = 1;
dl->color[1] = 1; dl->color[1] = 1;
dl->color[2] = 0; dl->color[2] = 0;
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (mtrand() % 5) + 1); Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (rand() % 5) + 1);
S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0); S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0);
break; break;
case MZ_SHOTGUN: case MZ_SHOTGUN:
@ -245,35 +245,35 @@ void CL_ParseMuzzleFlash (void) {
S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound("weapons/sshotf1b.wav"), volume, ATTN_NORM, 0); S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound("weapons/sshotf1b.wav"), volume, ATTN_NORM, 0);
break; break;
case MZ_CHAINGUN1: case MZ_CHAINGUN1:
dl->radius = 200.0f + (mtrand()&31); dl->radius = 200.0f + (rand()&31);
dl->color[0] = 1; dl->color[0] = 1;
dl->color[1] = 0.25; dl->color[1] = 0.25;
dl->color[2] = 0; dl->color[2] = 0;
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (mtrand() % 5) + 1); Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (rand() % 5) + 1);
S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0); S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0);
break; break;
case MZ_CHAINGUN2: case MZ_CHAINGUN2:
dl->radius = 225.0f + (mtrand()&31); dl->radius = 225.0f + (rand()&31);
dl->color[0] = 1; dl->color[0] = 1;
dl->color[1] = 0.5; dl->color[1] = 0.5;
dl->color[2] = 0; dl->color[2] = 0;
dl->die = cl.time + 0.1; /* long delay */ dl->die = cl.time + 0.1; /* long delay */
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (mtrand() % 5) + 1); Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (rand() % 5) + 1);
S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0); S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0);
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (mtrand() % 5) + 1); Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (rand() % 5) + 1);
S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0.05); S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0.05);
break; break;
case MZ_CHAINGUN3: case MZ_CHAINGUN3:
dl->radius = 250.0f + (mtrand()&31); dl->radius = 250.0f + (rand()&31);
dl->color[0] = 1; dl->color[0] = 1;
dl->color[1] = 1; dl->color[1] = 1;
dl->color[2] = 0; dl->color[2] = 0;
dl->die = cl.time + 0.1; /* long delay */ dl->die = cl.time + 0.1; /* long delay */
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (mtrand() % 5) + 1); Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (rand() % 5) + 1);
S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0); S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0);
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (mtrand() % 5) + 1); Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (rand() % 5) + 1);
S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0.033f); S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0.033f);
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (mtrand() % 5) + 1); Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (rand() % 5) + 1);
S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0.066f); S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0.066f);
break; break;
case MZ_RAILGUN: case MZ_RAILGUN:
@ -423,7 +423,7 @@ void CL_ParseMuzzleFlash2 (void) {
dl = CL_AllocDlight (ent); dl = CL_AllocDlight (ent);
VectorCopy (origin, dl->origin); VectorCopy (origin, dl->origin);
dl->radius = 200.0f + (mtrand()&31); dl->radius = 200.0f + (rand()&31);
dl->minlight = 32; dl->minlight = 32;
dl->die = cl.time; dl->die = cl.time;
@ -606,7 +606,7 @@ void CL_ParseMuzzleFlash2 (void) {
dl->color[2] = 0; dl->color[2] = 0;
CL_ParticleEffect (origin, vec3_origin, 0, 40); CL_ParticleEffect (origin, vec3_origin, 0, 40);
CL_SmokeAndFlash(origin); CL_SmokeAndFlash(origin);
Com_sprintf(soundname, sizeof(soundname), "tank/tnkatk2%c.wav", 'a' + (char) (mtrand() % 5)); Com_sprintf(soundname, sizeof(soundname), "tank/tnkatk2%c.wav", 'a' + (char) (rand() % 5));
S_StartSound (NULL, ent, CHAN_WEAPON, S_RegisterSound(soundname), 1, ATTN_NORM, 0); S_StartSound (NULL, ent, CHAN_WEAPON, S_RegisterSound(soundname), 1, ATTN_NORM, 0);
break; break;
@ -806,7 +806,7 @@ void CL_ParseMuzzleFlash2 (void) {
case MZ2_WIDOW2_BEAM_SWEEP_9: case MZ2_WIDOW2_BEAM_SWEEP_9:
case MZ2_WIDOW2_BEAM_SWEEP_10: case MZ2_WIDOW2_BEAM_SWEEP_10:
case MZ2_WIDOW2_BEAM_SWEEP_11: case MZ2_WIDOW2_BEAM_SWEEP_11:
dl->radius = 300.0f + (mtrand()&100); dl->radius = 300.0f + (rand()&100);
dl->color[0] = 1; dl->color[0] = 1;
dl->color[1] = 1; dl->color[1] = 1;
dl->color[2] = 0; dl->color[2] = 0;
@ -876,11 +876,11 @@ void CL_ParticleEffect (vec3_t org, vec3_t dir, int color, int count) {
active_particles = p; active_particles = p;
p->time = cl.time; p->time = cl.time;
p->color = color + (mtrand()&7); p->color = color + (rand()&7);
d = (float)(mtrand()&31); d = rand()&31;
for (j=0 ; j<3 ; j++) { for (j=0 ; j<3 ; j++) {
p->org[j] = org[j] + ((float)(mtrand()&7)-4) + d*dir[j]; p->org[j] = org[j] + ((rand()&7)-4) + d*dir[j];
p->vel[j] = crand()*20; p->vel[j] = crand()*20;
} }
@ -909,12 +909,12 @@ void CL_ParticleEffect2 (vec3_t org, vec3_t dir, int color, int count) {
active_particles = p; active_particles = p;
p->time = time; p->time = time;
p->color = color + (mtrand()&7); p->color = color + (rand()&7);
d = (float)(mtrand()&7); d = rand()&7;
for (j=0 ; j<3 ; j++) { for (j=0 ; j<3 ; j++) {
p->org[j] = org[j] + ((float)(mtrand()&7)-4) + d*dir[j]; p->org[j] = org[j] + ((rand()&7)-4) + d*dir[j];
p->vel[j] = crand()*20; p->vel[j] = crand()*20;
} }
@ -945,10 +945,10 @@ void CL_ParticleEffect3 (vec3_t org, vec3_t dir, int color, int count) {
p->time = time; p->time = time;
p->color = color; p->color = color;
d = (float)(mtrand()&7); d = rand()&7;
for (j=0 ; j<3 ; j++) { for (j=0 ; j<3 ; j++) {
p->org[j] = org[j] + ((mtrand()&7)-4) + d*dir[j]; p->org[j] = org[j] + ((rand()&7)-4) + d*dir[j];
p->vel[j] = crand()*20; p->vel[j] = crand()*20;
} }
@ -979,12 +979,12 @@ void CL_TeleporterParticles (entity_state_t *ent) {
p->color = 0xdb; p->color = 0xdb;
for (j=0 ; j<2 ; j++) { for (j=0 ; j<2 ; j++) {
p->org[j] = ent->origin[j] - 16 + (mtrand()&31); p->org[j] = ent->origin[j] - 16 + (rand()&31);
p->vel[j] = crand()*14; p->vel[j] = crand()*14;
} }
p->org[2] = ent->origin[2] - 8 + (mtrand()&7); p->org[2] = ent->origin[2] - 8 + (rand()&7);
p->vel[2] = 80 + (mtrand()&7); p->vel[2] = 80 + (rand()&7);
p->accel[0] = p->accel[1] = 0; p->accel[0] = p->accel[1] = 0;
p->accel[2] = -PARTICLE_GRAVITY; p->accel[2] = -PARTICLE_GRAVITY;
@ -1012,13 +1012,13 @@ void CL_LogoutEffect (vec3_t org, int type) {
p->time = time; p->time = time;
if (type == MZ_LOGIN) if (type == MZ_LOGIN)
p->color = 0xd0 + (mtrand()&7); p->color = 0xd0 + (rand()&7);
else if (type == MZ_LOGOUT) else if (type == MZ_LOGOUT)
p->color = 0x40 + (mtrand()&7); p->color = 0x40 + (rand()&7);
else else
p->color = 0xe0 + (mtrand()&7); p->color = 0xe0 + (rand()&7);
p->org[0] = org[0] - 16 + frand()*32; p->org[0] = org[0] - 16 + frand()*32;
p->org[1] = org[1] - 16 + frand()*32; p->org[1] = org[1] - 16 + frand()*32;
@ -1051,7 +1051,7 @@ void CL_ItemRespawnParticles (vec3_t org) {
active_particles = p; active_particles = p;
p->time = time; p->time = time;
p->color = 0xd4 + (mtrand()&3); p->color = 0xd4 + (rand()&3);
p->org[0] = org[0] + crand()*8; p->org[0] = org[0] + crand()*8;
p->org[1] = org[1] + crand()*8; p->org[1] = org[1] + crand()*8;
p->org[2] = org[2] + crand()*8; p->org[2] = org[2] + crand()*8;
@ -1083,7 +1083,7 @@ void CL_ExplosionParticles (vec3_t org) {
active_particles = p; active_particles = p;
p->time = time; p->time = time;
p->color = 0xe0 + (mtrand()&7); p->color = 0xe0 + (rand()&7);
for (j=0 ; j<3 ; j++) { for (j=0 ; j<3 ; j++) {
p->org[j] = org[j] + ((rand()%32)-16); p->org[j] = org[j] + ((rand()%32)-16);
@ -1116,20 +1116,20 @@ void CL_BigTeleportParticles (vec3_t org) {
active_particles = p; active_particles = p;
p->time = time; p->time = time;
p->color = colortable[mtrand()&3]; p->color = colortable[rand()&3];
angle = M_PI*2*(mtrand()&1023)/1023.0f; angle = M_PI*2*(rand()&1023)/1023.0f;
dist = (float)(mtrand()&31); dist = (float)(rand()&31);
p->org[0] = org[0] + (float)cos(angle)*dist; p->org[0] = org[0] + (float)cos(angle)*dist;
p->vel[0] = (float)cos(angle)*(70+(mtrand()&63)); p->vel[0] = (float)cos(angle)*(70+(rand()&63));
p->accel[0] = -(float)cos(angle)*100; p->accel[0] = -(float)cos(angle)*100;
p->org[1] = org[1] + (float)sin(angle)*dist; p->org[1] = org[1] + (float)sin(angle)*dist;
p->vel[1] = (float)sin(angle)*(70+(mtrand()&63)); p->vel[1] = (float)sin(angle)*(70+(rand()&63));
p->accel[1] = -(float)sin(angle)*100; p->accel[1] = -(float)sin(angle)*100;
p->org[2] = org[2] + 8 + (mtrand()%90); p->org[2] = org[2] + 8 + (rand()%90);
p->vel[2] = -100 + (mtrand()&31); p->vel[2] = -100 + (rand()&31);
p->accel[2] = PARTICLE_GRAVITY*4; p->accel[2] = PARTICLE_GRAVITY*4;
p->alpha = 1.0; p->alpha = 1.0;
@ -1157,11 +1157,11 @@ void CL_BlasterParticles (vec3_t org, vec3_t dir) {
active_particles = p; active_particles = p;
p->time = time; p->time = time;
p->color = 0xe0 + (mtrand()&7); p->color = 0xe0 + (rand()&7);
d = (float)(mtrand()&15); d = rand()&15;
for (j=0 ; j<3 ; j++) { for (j=0 ; j<3 ; j++) {
p->org[j] = org[j] + ((mtrand()&7)-4) + d*dir[j]; p->org[j] = org[j] + ((rand()&7)-4) + d*dir[j];
p->vel[j] = dir[j] * 30 + crand()*40; p->vel[j] = dir[j] * 30 + crand()*40;
} }
@ -1347,7 +1347,7 @@ void CL_DiminishingTrail (vec3_t start, vec3_t end, centity_t *old, int flags) {
return; return;
/* drop less particles as it flies */ /* drop less particles as it flies */
if ((mtrand()&1023) < old->trailcount) { if ((rand()&1023) < old->trailcount) {
p = free_particles; p = free_particles;
free_particles = p->next; free_particles = p->next;
p->next = active_particles; p->next = active_particles;
@ -1359,7 +1359,7 @@ void CL_DiminishingTrail (vec3_t start, vec3_t end, centity_t *old, int flags) {
if (flags & EF_GIB) { if (flags & EF_GIB) {
p->alpha = 1.0; p->alpha = 1.0;
p->alphavel = -1.0f / (1+frand()*0.4f); p->alphavel = -1.0f / (1+frand()*0.4f);
p->color = 0xe8 + (mtrand()&7); p->color = 0xe8 + (rand()&7);
for (j=0 ; j<3 ; j++) { for (j=0 ; j<3 ; j++) {
p->org[j] = move[j] + crand()*orgscale; p->org[j] = move[j] + crand()*orgscale;
@ -1372,7 +1372,7 @@ void CL_DiminishingTrail (vec3_t start, vec3_t end, centity_t *old, int flags) {
} else if (flags & EF_GREENGIB) { } else if (flags & EF_GREENGIB) {
p->alpha = 1.0; p->alpha = 1.0;
p->alphavel = -1.0f / (1+frand()*0.4f); p->alphavel = -1.0f / (1+frand()*0.4f);
p->color = 0xdb + (mtrand()&7); p->color = 0xdb + (rand()&7);
for (j=0; j< 3; j++) { for (j=0; j< 3; j++) {
p->org[j] = move[j] + crand()*orgscale; p->org[j] = move[j] + crand()*orgscale;
@ -1385,7 +1385,7 @@ void CL_DiminishingTrail (vec3_t start, vec3_t end, centity_t *old, int flags) {
} else { } else {
p->alpha = 1.0; p->alpha = 1.0;
p->alphavel = -1.0f / (1+frand()*0.2f); p->alphavel = -1.0f / (1+frand()*0.2f);
p->color = 4 + (mtrand()&7); p->color = 4 + (rand()&7);
for (j=0 ; j<3 ; j++) { for (j=0 ; j<3 ; j++) {
p->org[j] = move[j] + crand()*orgscale; p->org[j] = move[j] + crand()*orgscale;
@ -1447,7 +1447,7 @@ void CL_RocketTrail (vec3_t start, vec3_t end, centity_t *old) {
if (!free_particles) if (!free_particles)
return; return;
if ( (mtrand()&7) == 0) { if ( (rand()&7) == 0) {
p = free_particles; p = free_particles;
free_particles = p->next; free_particles = p->next;
p->next = active_particles; p->next = active_particles;
@ -1458,7 +1458,7 @@ void CL_RocketTrail (vec3_t start, vec3_t end, centity_t *old) {
p->alpha = 1.0; p->alpha = 1.0;
p->alphavel = -1.0f / (1+frand()*0.2f); p->alphavel = -1.0f / (1+frand()*0.2f);
p->color = 0xdc + (mtrand()&3); p->color = 0xdc + (rand()&3);
for (j=0 ; j<3 ; j++) { for (j=0 ; j<3 ; j++) {
p->org[j] = move[j] + crand()*5; p->org[j] = move[j] + crand()*5;
@ -1514,7 +1514,7 @@ void CL_RailTrail (vec3_t start, vec3_t end) {
p->alpha = 1.0; p->alpha = 1.0;
p->alphavel = -1.0f / (1+frand()*0.2f); p->alphavel = -1.0f / (1+frand()*0.2f);
p->color = clr + (mtrand()&7); p->color = clr + (rand()&7);
for (j=0 ; j<3 ; j++) { for (j=0 ; j<3 ; j++) {
p->org[j] = move[j] + dir[j]*3; p->org[j] = move[j] + dir[j]*3;
@ -1589,7 +1589,7 @@ void CL_IonripperTrail (vec3_t start, vec3_t ent) {
p->time = time; p->time = time;
p->alpha = 0.5; p->alpha = 0.5;
p->alphavel = -1.0f / (0.3f + frand() * 0.2f); p->alphavel = -1.0f / (0.3f + frand() * 0.2f);
p->color = 0xe4 + (mtrand()&3); p->color = 0xe4 + (rand()&3);
for (j=0; j<3; j++) { for (j=0; j<3; j++) {
p->org[j] = move[j]; p->org[j] = move[j];
@ -1643,7 +1643,7 @@ void CL_BubbleTrail (vec3_t start, vec3_t end) {
p->alpha = 1.0; p->alpha = 1.0;
p->alphavel = -1.0f / (1+frand()*0.2f); p->alphavel = -1.0f / (1+frand()*0.2f);
p->color = 4 + (mtrand()&7); p->color = 4 + (rand()&7);
for (j=0 ; j<3 ; j++) { for (j=0 ; j<3 ; j++) {
p->org[j] = move[j] + crand()*2; p->org[j] = move[j] + crand()*2;
@ -1673,7 +1673,7 @@ void CL_FlyParticles (vec3_t origin, int count) {
if (!avelocities[0][0]) { if (!avelocities[0][0]) {
for (i=0 ; i<NUMVERTEXNORMALS*3 ; i++) for (i=0 ; i<NUMVERTEXNORMALS*3 ; i++)
avelocities[0][i] = (mtrand()&255) * 0.01f; avelocities[0][i] = (rand()&255) * 0.01f;
} }
@ -1763,7 +1763,7 @@ void CL_BfgParticles (entity_t *ent) {
if (!avelocities[0][0]) { if (!avelocities[0][0]) {
for (i=0 ; i<NUMVERTEXNORMALS*3 ; i++) for (i=0 ; i<NUMVERTEXNORMALS*3 ; i++)
avelocities[0][i] = (mtrand()&255) * 0.01f; avelocities[0][i] = (rand()&255) * 0.01f;
} }
ltime = time / 1000.0; ltime = time / 1000.0;
@ -1883,20 +1883,20 @@ void CL_TrapParticles (entity_t *ent) {
active_particles = p; active_particles = p;
p->time = time; p->time = time;
p->color = 0xe0 + (mtrand()&3); p->color = 0xe0 + (rand()&3);
p->alpha = 1.0; p->alpha = 1.0;
p->alphavel = -1.0f / (0.3f + (mtrand()&7) * 0.02f); p->alphavel = -1.0f / (0.3f + (rand()&7) * 0.02f);
p->org[0] = org[0] + i + ((mtrand()&23) * crand()); p->org[0] = org[0] + i + ((rand()&23) * crand());
p->org[1] = org[1] + j + ((mtrand()&23) * crand()); p->org[1] = org[1] + j + ((rand()&23) * crand());
p->org[2] = org[2] + k + ((mtrand()&23) * crand()); p->org[2] = org[2] + k + ((rand()&23) * crand());
dir[0] = j * 8.0f; dir[0] = j * 8.0f;
dir[1] = i * 8.0f; dir[1] = i * 8.0f;
dir[2] = k * 8.0f; dir[2] = k * 8.0f;
VectorNormalize (dir); VectorNormalize (dir);
vel = (float)(50 + (mtrand()&63)); vel = (float)(50 + (rand()&63));
VectorScale (dir, vel, p->vel); VectorScale (dir, vel, p->vel);
p->accel[0] = p->accel[1] = 0; p->accel[0] = p->accel[1] = 0;
@ -1921,11 +1921,11 @@ void CL_BFGExplosionParticles (vec3_t org) {
active_particles = p; active_particles = p;
p->time = time; p->time = time;
p->color = 0xd0 + (mtrand()&7); p->color = 0xd0 + (rand()&7);
for (j=0 ; j<3 ; j++) { for (j=0 ; j<3 ; j++) {
p->org[j] = org[j] + crand() * 16; p->org[j] = org[j] + ((rand()%32)-16);
p->vel[j] = crand() * 192; p->vel[j] = (rand()%384)-192;
} }
p->accel[0] = p->accel[1] = 0; p->accel[0] = p->accel[1] = 0;
@ -1956,20 +1956,20 @@ void CL_TeleportParticles (vec3_t org) {
active_particles = p; active_particles = p;
p->time = time; p->time = time;
p->color = 7 + (mtrand()&7); p->color = 7 + (rand()&7);
p->alpha = 1.0; p->alpha = 1.0;
p->alphavel = -1.0f / (0.3f + (mtrand()&7) * 0.02f); p->alphavel = -1.0f / (0.3f + (rand()&7) * 0.02f);
p->org[0] = org[0] + i + (mtrand()&3); p->org[0] = org[0] + i + (rand()&3);
p->org[1] = org[1] + j + (mtrand()&3); p->org[1] = org[1] + j + (rand()&3);
p->org[2] = org[2] + k + (mtrand()&3); p->org[2] = org[2] + k + (rand()&3);
dir[0] = j*8.0f; dir[0] = j*8.0f;
dir[1] = i*8.0f; dir[1] = i*8.0f;
dir[2] = k*8.0f; dir[2] = k*8.0f;
VectorNormalize (dir); VectorNormalize (dir);
vel = (float)(50 + (mtrand()&63)); vel = (float)(50 + (rand()&63));
VectorScale (dir, vel, p->vel); VectorScale (dir, vel, p->vel);
p->accel[0] = p->accel[1] = 0; p->accel[0] = p->accel[1] = 0;
@ -2057,7 +2057,7 @@ void CL_EntityEvent (entity_state_t *ent) {
case EV_FOOTSTEP: case EV_FOOTSTEP:
if (cl_footsteps->value) if (cl_footsteps->value)
S_StartSound (NULL, ent->number, CHAN_BODY, cl_sfx_footsteps[mtrand()&3], 1, ATTN_NORM, 0); S_StartSound (NULL, ent->number, CHAN_BODY, cl_sfx_footsteps[rand()&3], 1, ATTN_NORM, 0);
break; break;
case EV_FALLSHORT: case EV_FALLSHORT:

View file

@ -1334,6 +1334,16 @@ byte COM_BlockSequenceCRCByte (byte *base, int length, int sequence)
//======================================================== //========================================================
float frand(void)
{
return (rand()&32767)* (1.0/32767);
}
float crand(void)
{
return (rand()&32767)* (2.0/32767) - 1;
}
#ifndef DEDICATED_ONLY #ifndef DEDICATED_ONLY
void Key_Init (void); void Key_Init (void);
void SCR_EndLoadingPlaque (void); void SCR_EndLoadingPlaque (void);
@ -1367,9 +1377,6 @@ void Qcommon_Init (int argc, char **argv)
z_chain.next = z_chain.prev = &z_chain; z_chain.next = z_chain.prev = &z_chain;
/* seed the PRNG */
ini_rand (5489U);
// prepare enough of the subsystems to handle // prepare enough of the subsystems to handle
// cvar and command buffer management // cvar and command buffer management
COM_InitArgv (argc, argv); COM_InitArgv (argc, argv);

View file

@ -759,6 +759,9 @@ void Com_SetServerState (int state);
unsigned Com_BlockChecksum (void *buffer, int length); unsigned Com_BlockChecksum (void *buffer, int length);
byte COM_BlockSequenceCRCByte (byte *base, int length, int sequence); byte COM_BlockSequenceCRCByte (byte *base, int length, int sequence);
float frand(void); // 0 ti 1
float crand(void); // -1 to 1
extern cvar_t *developer; extern cvar_t *developer;
extern cvar_t *modder; extern cvar_t *modder;
extern cvar_t *dedicated; extern cvar_t *dedicated;
@ -832,13 +835,5 @@ void SV_Init (void);
void SV_Shutdown (char *finalmsg, qboolean reconnect); void SV_Shutdown (char *finalmsg, qboolean reconnect);
void SV_Frame (int msec); void SV_Frame (int msec);
typedef struct
{
int count;
unsigned int cnst [ 2 ], vec [ 624 ];
} rand_work_t;
extern rand_work_t rand_work;
void ini_rand (unsigned int u);
int mtrand (void);

View file

@ -1,91 +0,0 @@
/* PRNG based on Mersenne Twister (M. Matsumoto and T. Nishimura, 1998). */
#include "qcommon.h"
#define RAND_M 397
#define RAND_N 624
#define MASK_U 0x80000000U
#define MASK_L 0x7fffffffU
#define MASK32 0xffffffffU
rand_work_t rand_work;
void
ini_rand ( unsigned int u )
{
int i;
rand_work.count = RAND_N;
rand_work.cnst [ 0 ] = 0;
rand_work.cnst [ 1 ] = 0x9908b0dfU;
u &= MASK32;
rand_work.vec [ 0 ] = u;
for ( i = 1; i < RAND_N; i++ )
{
u = i + 1812433253U * ( u ^ ( u >> 30 ) );
u &= MASK32;
rand_work.vec [ i ] = u;
}
}
int
mtrand ( void )
{
int u, u0, u1, u2;
int i;
if ( rand_work.count == RAND_N )
{
rand_work.count = 0;
for ( i = 0; i < RAND_N - RAND_M; i++ )
{
u = rand_work.vec [ i ] & MASK_U;
u |= rand_work.vec [ i + 1 ] & MASK_L;
u0 = rand_work.vec [ i + RAND_M ];
u1 = u >> 1;
u2 = rand_work.cnst [ u & 1 ];
rand_work.vec [ i ] = u0 ^ u1 ^ u2;
}
for ( ; i < RAND_N - 1; i++ )
{
u = rand_work.vec [ i ] & MASK_U;
u |= rand_work.vec [ i + 1 ] & MASK_L;
u0 = rand_work.vec [ i + RAND_M - RAND_N ];
u1 = u >> 1;
u2 = rand_work.cnst [ u & 1 ];
rand_work.vec [ i ] = u0 ^ u1 ^ u2;
}
u = rand_work.vec [ RAND_N - 1 ] & MASK_U;
u |= rand_work.vec [ 0 ] & MASK_L;
u0 = rand_work.vec [ RAND_M - 1 ];
u1 = u >> 1;
u2 = rand_work.cnst [ u & 1 ];
rand_work.vec [ RAND_N - 1 ] = u0 ^ u1 ^ u2;
}
u = rand_work.vec [ rand_work.count++ ];
u ^= ( u >> 11 );
u ^= ( u << 7 ) & 0x9d2c5680U;
u ^= ( u << 15 ) & 0xefc60000U;
u ^= ( u >> 18 );
if ( u < 0)
{
return ( ( u * -1 ) / 3 );
}
else
{
return ( u / 3 );
}
}

View file

@ -506,10 +506,6 @@ extern edict_t *g_edicts;
#define LLOFS(x) (size_t)&(((level_locals_t *)NULL)->x) #define LLOFS(x) (size_t)&(((level_locals_t *)NULL)->x)
#define CLOFS(x) (size_t)&(((gclient_t *)NULL)->x) #define CLOFS(x) (size_t)&(((gclient_t *)NULL)->x)
#ifdef random
#undef random
#endif
#define random() ((rand () & 0x7fff) / ((float)0x7fff)) #define random() ((rand () & 0x7fff) / ((float)0x7fff))
#define crandom() (2.0 * (random() - 0.5)) #define crandom() (2.0 * (random() - 0.5))

View file

@ -31,12 +31,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
typedef unsigned char byte; typedef unsigned char byte;
typedef enum {false, true} qboolean; typedef enum {false, true} qboolean;
//32 bit float precision caps this to 0.00000000023283064f which gives max result of .99999998407391880
#define random() ((mtrand() * 0.00000000023283064f))
#define frand() (random())
#define crand() (((int)mtrand() - 0x7FFFFFFF) * 0.000000000465661287307739257812f)
#ifndef NULL #ifndef NULL
#define NULL ((void *)0) #define NULL ((void *)0)