mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-01-19 07:51:03 +00:00
Merge branch 'scanbuild'
This branch brings fixes to some potential problems found by clangs "scan-build" tool. The biggest change is es new PRNG, which should fox some problems related to bad pseudo random number, noticeable especially after long session. The new PRNG is also a prerequiste to Windows support.
This commit is contained in:
commit
088ed50566
65 changed files with 508 additions and 401 deletions
3
Makefile
3
Makefile
|
@ -269,6 +269,7 @@ release/baseq2/game.so : LDFLAGS += -shared
|
|||
# Used by the game
|
||||
GAME_OBJS_ = \
|
||||
src/common/shared/flash.o \
|
||||
src/common/shared/rand.o \
|
||||
src/common/shared/shared.o \
|
||||
src/game/g_ai.o \
|
||||
src/game/g_chase.o \
|
||||
|
@ -368,6 +369,7 @@ CLIENT_OBJS_ := \
|
|||
src/common/model/cm_bsp.o \
|
||||
src/common/model/cm_vis.o \
|
||||
src/common/shared/flash.o \
|
||||
src/common/shared/rand.o \
|
||||
src/common/shared/shared.o \
|
||||
src/common/unzip/ioapi.o \
|
||||
src/common/unzip/unzip.o \
|
||||
|
@ -417,6 +419,7 @@ SERVER_OBJS_ := \
|
|||
src/common/model/cm_boxtracing.o \
|
||||
src/common/model/cm_bsp.o \
|
||||
src/common/model/cm_vis.o \
|
||||
src/common/shared/rand.o \
|
||||
src/common/shared/shared.o \
|
||||
src/common/unzip/ioapi.o \
|
||||
src/common/unzip/unzip.o \
|
||||
|
|
|
@ -338,7 +338,7 @@ SCR_ReadNextFrame(void) {
|
|||
FS_Read(&size, 4, (size_t)cl.cinematic_file);
|
||||
size = LittleLong(size);
|
||||
|
||||
if (size > sizeof(compressed) || size < 1)
|
||||
if ((unsigned long)size > sizeof(compressed) || size < 1)
|
||||
Com_Error(ERR_DROP, "Bad compressed frame size");
|
||||
|
||||
FS_Read(compressed, size, (size_t)cl.cinematic_file);
|
||||
|
|
|
@ -49,7 +49,7 @@ static const char *env_suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"};
|
|||
|
||||
void CL_RequestNextDownload (void)
|
||||
{
|
||||
unsigned map_checksum; /* for detecting cheater maps */
|
||||
unsigned int map_checksum; /* for detecting cheater maps */
|
||||
char fn[MAX_OSPATH];
|
||||
dmdl_t *pheader;
|
||||
|
||||
|
@ -313,7 +313,7 @@ void CL_RequestNextDownload (void)
|
|||
|
||||
CM_LoadMap (cl.configstrings[CS_MODELS+1], true, &map_checksum);
|
||||
|
||||
if (map_checksum != atoi(cl.configstrings[CS_MAPCHECKSUM]))
|
||||
if (map_checksum != (int)strtol(cl.configstrings[CS_MAPCHECKSUM], (char **)NULL, 10))
|
||||
{
|
||||
Com_Error (ERR_DROP, "Local map version differs from server: %i != '%s'\n",
|
||||
map_checksum, cl.configstrings[CS_MAPCHECKSUM]);
|
||||
|
|
|
@ -66,10 +66,10 @@ void CL_AddMuzzleFlash (void) {
|
|||
VectorMA (dl->origin, 16, rv, dl->origin);
|
||||
|
||||
if (silenced)
|
||||
dl->radius = 100.0f + (rand()&31);
|
||||
dl->radius = 100.0f + (randk()&31);
|
||||
|
||||
else
|
||||
dl->radius = 200.0f + (rand()&31);
|
||||
dl->radius = 200.0f + (randk()&31);
|
||||
|
||||
dl->minlight = 32;
|
||||
dl->die = cl.time;
|
||||
|
@ -103,7 +103,7 @@ void CL_AddMuzzleFlash (void) {
|
|||
dl->color[0] = 1;
|
||||
dl->color[1] = 1;
|
||||
dl->color[2] = 0;
|
||||
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (rand() % 5) + 1);
|
||||
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (randk() % 5) + 1);
|
||||
S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0);
|
||||
break;
|
||||
case MZ_SHOTGUN:
|
||||
|
@ -120,35 +120,35 @@ void CL_AddMuzzleFlash (void) {
|
|||
S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound("weapons/sshotf1b.wav"), volume, ATTN_NORM, 0);
|
||||
break;
|
||||
case MZ_CHAINGUN1:
|
||||
dl->radius = 200.0f + (rand()&31);
|
||||
dl->radius = 200.0f + (randk()&31);
|
||||
dl->color[0] = 1;
|
||||
dl->color[1] = 0.25;
|
||||
dl->color[2] = 0;
|
||||
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (rand() % 5) + 1);
|
||||
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (randk() % 5) + 1);
|
||||
S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0);
|
||||
break;
|
||||
case MZ_CHAINGUN2:
|
||||
dl->radius = 225.0f + (rand()&31);
|
||||
dl->radius = 225.0f + (randk()&31);
|
||||
dl->color[0] = 1;
|
||||
dl->color[1] = 0.5;
|
||||
dl->color[2] = 0;
|
||||
dl->die = cl.time + 0.1; /* long delay */
|
||||
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (rand() % 5) + 1);
|
||||
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (randk() % 5) + 1);
|
||||
S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0);
|
||||
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (rand() % 5) + 1);
|
||||
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (randk() % 5) + 1);
|
||||
S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0.05);
|
||||
break;
|
||||
case MZ_CHAINGUN3:
|
||||
dl->radius = 250.0f + (rand()&31);
|
||||
dl->radius = 250.0f + (randk()&31);
|
||||
dl->color[0] = 1;
|
||||
dl->color[1] = 1;
|
||||
dl->color[2] = 0;
|
||||
dl->die = cl.time + 0.1; /* long delay */
|
||||
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (rand() % 5) + 1);
|
||||
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (randk() % 5) + 1);
|
||||
S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0);
|
||||
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (rand() % 5) + 1);
|
||||
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (randk() % 5) + 1);
|
||||
S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0.033f);
|
||||
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (rand() % 5) + 1);
|
||||
Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%lub.wav", (randk() % 5) + 1);
|
||||
S_StartSound (NULL, i, CHAN_WEAPON, S_RegisterSound(soundname), volume, ATTN_NORM, 0.066f);
|
||||
break;
|
||||
case MZ_RAILGUN:
|
||||
|
@ -298,7 +298,7 @@ void CL_AddMuzzleFlash2 (void) {
|
|||
|
||||
dl = CL_AllocDlight (ent);
|
||||
VectorCopy (origin, dl->origin);
|
||||
dl->radius = 200.0f + (rand()&31);
|
||||
dl->radius = 200.0f + (randk()&31);
|
||||
dl->minlight = 32;
|
||||
dl->die = cl.time;
|
||||
|
||||
|
@ -481,7 +481,7 @@ void CL_AddMuzzleFlash2 (void) {
|
|||
dl->color[2] = 0;
|
||||
CL_ParticleEffect (origin, vec3_origin, 0, 40);
|
||||
CL_SmokeAndFlash(origin);
|
||||
Com_sprintf(soundname, sizeof(soundname), "tank/tnkatk2%c.wav", 'a' + (char) (rand() % 5));
|
||||
Com_sprintf(soundname, sizeof(soundname), "tank/tnkatk2%c.wav", 'a' + (char) (randk() % 5));
|
||||
S_StartSound (NULL, ent, CHAN_WEAPON, S_RegisterSound(soundname), 1, ATTN_NORM, 0);
|
||||
break;
|
||||
|
||||
|
@ -681,7 +681,7 @@ void CL_AddMuzzleFlash2 (void) {
|
|||
case MZ2_WIDOW2_BEAM_SWEEP_9:
|
||||
case MZ2_WIDOW2_BEAM_SWEEP_10:
|
||||
case MZ2_WIDOW2_BEAM_SWEEP_11:
|
||||
dl->radius = 300.0f + (rand()&100);
|
||||
dl->radius = 300.0f + (randk()&100);
|
||||
dl->color[0] = 1;
|
||||
dl->color[1] = 1;
|
||||
dl->color[2] = 0;
|
||||
|
@ -709,12 +709,12 @@ void CL_TeleporterParticles (entity_state_t *ent) {
|
|||
p->color = 0xdb;
|
||||
|
||||
for (j=0 ; j<2 ; j++) {
|
||||
p->org[j] = ent->origin[j] - 16 + (rand()&31);
|
||||
p->vel[j] = crand()*14;
|
||||
p->org[j] = ent->origin[j] - 16 + (randk()&31);
|
||||
p->vel[j] = crandk()*14;
|
||||
}
|
||||
|
||||
p->org[2] = ent->origin[2] - 8 + (rand()&7);
|
||||
p->vel[2] = 80 + (rand()&7);
|
||||
p->org[2] = ent->origin[2] - 8 + (randk()&7);
|
||||
p->vel[2] = 80 + (randk()&7);
|
||||
|
||||
p->accel[0] = p->accel[1] = 0;
|
||||
p->accel[2] = -PARTICLE_GRAVITY;
|
||||
|
@ -742,26 +742,26 @@ void CL_LogoutEffect (vec3_t org, int type) {
|
|||
p->time = time;
|
||||
|
||||
if (type == MZ_LOGIN)
|
||||
p->color = 0xd0 + (rand()&7);
|
||||
p->color = 0xd0 + (randk()&7);
|
||||
|
||||
else if (type == MZ_LOGOUT)
|
||||
p->color = 0x40 + (rand()&7);
|
||||
p->color = 0x40 + (randk()&7);
|
||||
|
||||
else
|
||||
p->color = 0xe0 + (rand()&7);
|
||||
p->color = 0xe0 + (randk()&7);
|
||||
|
||||
p->org[0] = org[0] - 16 + frand()*32;
|
||||
p->org[1] = org[1] - 16 + frand()*32;
|
||||
p->org[2] = org[2] - 24 + frand()*56;
|
||||
p->org[0] = org[0] - 16 + frandk()*32;
|
||||
p->org[1] = org[1] - 16 + frandk()*32;
|
||||
p->org[2] = org[2] - 24 + frandk()*56;
|
||||
|
||||
for (j=0 ; j<3 ; j++)
|
||||
p->vel[j] = crand()*20;
|
||||
p->vel[j] = crandk()*20;
|
||||
|
||||
p->accel[0] = p->accel[1] = 0;
|
||||
p->accel[2] = -PARTICLE_GRAVITY;
|
||||
p->alpha = 1.0;
|
||||
|
||||
p->alphavel = -1.0 / (1.0 + frand()*0.3);
|
||||
p->alphavel = -1.0 / (1.0 + frandk()*0.3);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -781,19 +781,19 @@ void CL_ItemRespawnParticles (vec3_t org) {
|
|||
active_particles = p;
|
||||
|
||||
p->time = time;
|
||||
p->color = 0xd4 + (rand()&3);
|
||||
p->org[0] = org[0] + crand()*8;
|
||||
p->org[1] = org[1] + crand()*8;
|
||||
p->org[2] = org[2] + crand()*8;
|
||||
p->color = 0xd4 + (randk()&3);
|
||||
p->org[0] = org[0] + crandk()*8;
|
||||
p->org[1] = org[1] + crandk()*8;
|
||||
p->org[2] = org[2] + crandk()*8;
|
||||
|
||||
for (j=0 ; j<3 ; j++)
|
||||
p->vel[j] = crand()*8;
|
||||
p->vel[j] = crandk()*8;
|
||||
|
||||
p->accel[0] = p->accel[1] = 0;
|
||||
p->accel[2] = -PARTICLE_GRAVITY*0.2;
|
||||
p->alpha = 1.0;
|
||||
|
||||
p->alphavel = -1.0f / (1.0f + frand()*0.3f);
|
||||
p->alphavel = -1.0f / (1.0f + frandk()*0.3f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -813,18 +813,18 @@ void CL_ExplosionParticles (vec3_t org) {
|
|||
active_particles = p;
|
||||
|
||||
p->time = time;
|
||||
p->color = 0xe0 + (rand()&7);
|
||||
p->color = 0xe0 + (randk()&7);
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = org[j] + ((rand()%32)-16);
|
||||
p->vel[j] = (rand()%384)-192;
|
||||
p->org[j] = org[j] + ((randk()%32)-16);
|
||||
p->vel[j] = (randk()%384)-192;
|
||||
}
|
||||
|
||||
p->accel[0] = p->accel[1] = 0;
|
||||
p->accel[2] = -PARTICLE_GRAVITY;
|
||||
p->alpha = 1.0;
|
||||
|
||||
p->alphavel = -0.8f / (0.5f + frand()*0.3f);
|
||||
p->alphavel = -0.8f / (0.5f + frandk()*0.3f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -846,24 +846,24 @@ void CL_BigTeleportParticles (vec3_t org) {
|
|||
active_particles = p;
|
||||
|
||||
p->time = time;
|
||||
p->color = colortable[rand()&3];
|
||||
p->color = colortable[randk()&3];
|
||||
|
||||
angle = M_PI*2*(rand()&1023)/1023.0f;
|
||||
dist = (float)(rand()&31);
|
||||
angle = M_PI*2*(randk()&1023)/1023.0f;
|
||||
dist = (float)(randk()&31);
|
||||
p->org[0] = org[0] + (float)cos(angle)*dist;
|
||||
p->vel[0] = (float)cos(angle)*(70+(rand()&63));
|
||||
p->vel[0] = (float)cos(angle)*(70+(randk()&63));
|
||||
p->accel[0] = -(float)cos(angle)*100;
|
||||
|
||||
p->org[1] = org[1] + (float)sin(angle)*dist;
|
||||
p->vel[1] = (float)sin(angle)*(70+(rand()&63));
|
||||
p->vel[1] = (float)sin(angle)*(70+(randk()&63));
|
||||
p->accel[1] = -(float)sin(angle)*100;
|
||||
|
||||
p->org[2] = org[2] + 8 + (rand()%90);
|
||||
p->vel[2] = -100 + (rand()&31);
|
||||
p->org[2] = org[2] + 8 + (randk()%90);
|
||||
p->vel[2] = -100 + (randk()&31);
|
||||
p->accel[2] = PARTICLE_GRAVITY*4;
|
||||
p->alpha = 1.0;
|
||||
|
||||
p->alphavel = -0.3f / (0.5f + frand()*0.3f);
|
||||
p->alphavel = -0.3f / (0.5f + frandk()*0.3f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -890,19 +890,19 @@ void CL_BlasterParticles (vec3_t org, vec3_t dir) {
|
|||
active_particles = p;
|
||||
|
||||
p->time = time;
|
||||
p->color = 0xe0 + (rand()&7);
|
||||
d = rand()&15;
|
||||
p->color = 0xe0 + (randk()&7);
|
||||
d = randk()&15;
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = org[j] + ((rand()&7)-4) + d*dir[j];
|
||||
p->vel[j] = dir[j] * 30 + crand()*40;
|
||||
p->org[j] = org[j] + ((randk()&7)-4) + d*dir[j];
|
||||
p->vel[j] = dir[j] * 30 + crandk()*40;
|
||||
}
|
||||
|
||||
p->accel[0] = p->accel[1] = 0;
|
||||
p->accel[2] = -PARTICLE_GRAVITY;
|
||||
p->alpha = 1.0;
|
||||
|
||||
p->alphavel = -1.0f / (0.5f + frand()*0.3f);
|
||||
p->alphavel = -1.0f / (0.5f + frandk()*0.3f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -938,12 +938,12 @@ void CL_BlasterTrail (vec3_t start, vec3_t end) {
|
|||
p->time = time;
|
||||
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0f / (0.3f+frand()*0.2f);
|
||||
p->alphavel = -1.0f / (0.3f+frandk()*0.2f);
|
||||
p->color = 0xe0;
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = move[j] + crand();
|
||||
p->vel[j] = crand()*5;
|
||||
p->org[j] = move[j] + crandk();
|
||||
p->vel[j] = crandk()*5;
|
||||
p->accel[j] = 0;
|
||||
}
|
||||
|
||||
|
@ -983,12 +983,12 @@ void CL_QuadTrail (vec3_t start, vec3_t end) {
|
|||
p->time = time;
|
||||
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0f / (0.8f+frand()*0.2f);
|
||||
p->alphavel = -1.0f / (0.8f+frandk()*0.2f);
|
||||
p->color = 115;
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = move[j] + crand()*16;
|
||||
p->vel[j] = crand()*5;
|
||||
p->org[j] = move[j] + crandk()*16;
|
||||
p->vel[j] = crandk()*5;
|
||||
p->accel[j] = 0;
|
||||
}
|
||||
|
||||
|
@ -1028,12 +1028,12 @@ void CL_FlagTrail (vec3_t start, vec3_t end, int color) {
|
|||
p->time = time;
|
||||
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0f / (0.8f+frand()*0.2f);
|
||||
p->alphavel = -1.0f / (0.8f+frandk()*0.2f);
|
||||
p->color = color;
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = move[j] + crand()*16;
|
||||
p->vel[j] = crand()*5;
|
||||
p->org[j] = move[j] + crandk()*16;
|
||||
p->vel[j] = crandk()*5;
|
||||
p->accel[j] = 0;
|
||||
}
|
||||
|
||||
|
@ -1080,7 +1080,7 @@ void CL_DiminishingTrail (vec3_t start, vec3_t end, centity_t *old, int flags) {
|
|||
return;
|
||||
|
||||
/* drop less particles as it flies */
|
||||
if ((rand()&1023) < old->trailcount) {
|
||||
if ((randk()&1023) < old->trailcount) {
|
||||
p = free_particles;
|
||||
free_particles = p->next;
|
||||
p->next = active_particles;
|
||||
|
@ -1091,12 +1091,12 @@ void CL_DiminishingTrail (vec3_t start, vec3_t end, centity_t *old, int flags) {
|
|||
|
||||
if (flags & EF_GIB) {
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0f / (1+frand()*0.4f);
|
||||
p->color = 0xe8 + (rand()&7);
|
||||
p->alphavel = -1.0f / (1+frandk()*0.4f);
|
||||
p->color = 0xe8 + (randk()&7);
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = move[j] + crand()*orgscale;
|
||||
p->vel[j] = crand()*velscale;
|
||||
p->org[j] = move[j] + crandk()*orgscale;
|
||||
p->vel[j] = crandk()*velscale;
|
||||
p->accel[j] = 0;
|
||||
}
|
||||
|
||||
|
@ -1104,12 +1104,12 @@ void CL_DiminishingTrail (vec3_t start, vec3_t end, centity_t *old, int flags) {
|
|||
|
||||
} else if (flags & EF_GREENGIB) {
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0f / (1+frand()*0.4f);
|
||||
p->color = 0xdb + (rand()&7);
|
||||
p->alphavel = -1.0f / (1+frandk()*0.4f);
|
||||
p->color = 0xdb + (randk()&7);
|
||||
|
||||
for (j=0; j< 3; j++) {
|
||||
p->org[j] = move[j] + crand()*orgscale;
|
||||
p->vel[j] = crand()*velscale;
|
||||
p->org[j] = move[j] + crandk()*orgscale;
|
||||
p->vel[j] = crandk()*velscale;
|
||||
p->accel[j] = 0;
|
||||
}
|
||||
|
||||
|
@ -1117,12 +1117,12 @@ void CL_DiminishingTrail (vec3_t start, vec3_t end, centity_t *old, int flags) {
|
|||
|
||||
} else {
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0f / (1+frand()*0.2f);
|
||||
p->color = 4 + (rand()&7);
|
||||
p->alphavel = -1.0f / (1+frandk()*0.2f);
|
||||
p->color = 4 + (randk()&7);
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = move[j] + crand()*orgscale;
|
||||
p->vel[j] = crand()*velscale;
|
||||
p->org[j] = move[j] + crandk()*orgscale;
|
||||
p->vel[j] = crandk()*velscale;
|
||||
}
|
||||
|
||||
p->accel[2] = 20;
|
||||
|
@ -1180,7 +1180,7 @@ void CL_RocketTrail (vec3_t start, vec3_t end, centity_t *old) {
|
|||
if (!free_particles)
|
||||
return;
|
||||
|
||||
if ( (rand()&7) == 0) {
|
||||
if ( (randk()&7) == 0) {
|
||||
p = free_particles;
|
||||
free_particles = p->next;
|
||||
p->next = active_particles;
|
||||
|
@ -1190,12 +1190,12 @@ void CL_RocketTrail (vec3_t start, vec3_t end, centity_t *old) {
|
|||
p->time = time;
|
||||
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0f / (1+frand()*0.2f);
|
||||
p->color = 0xdc + (rand()&3);
|
||||
p->alphavel = -1.0f / (1+frandk()*0.2f);
|
||||
p->color = 0xdc + (randk()&3);
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = move[j] + crand()*5;
|
||||
p->vel[j] = crand()*20;
|
||||
p->org[j] = move[j] + crandk()*5;
|
||||
p->vel[j] = crandk()*20;
|
||||
}
|
||||
|
||||
p->accel[2] = -PARTICLE_GRAVITY;
|
||||
|
@ -1246,8 +1246,8 @@ void CL_RailTrail (vec3_t start, vec3_t end) {
|
|||
VectorMA (dir, s, up, dir);
|
||||
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0f / (1+frand()*0.2f);
|
||||
p->color = clr + (rand()&7);
|
||||
p->alphavel = -1.0f / (1+frandk()*0.2f);
|
||||
p->color = clr + (randk()&7);
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = move[j] + dir[j]*3;
|
||||
|
@ -1276,12 +1276,12 @@ void CL_RailTrail (vec3_t start, vec3_t end) {
|
|||
VectorClear (p->accel);
|
||||
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0f / (0.6f+frand()*0.2f);
|
||||
p->color = 0x0 + (rand()&15);
|
||||
p->alphavel = -1.0f / (0.6f+frandk()*0.2f);
|
||||
p->color = 0x0 + (randk()&15);
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = move[j] + crand()*3;
|
||||
p->vel[j] = crand()*3;
|
||||
p->org[j] = move[j] + crandk()*3;
|
||||
p->vel[j] = crandk()*3;
|
||||
p->accel[j] = 0;
|
||||
}
|
||||
|
||||
|
@ -1321,8 +1321,8 @@ void CL_IonripperTrail (vec3_t start, vec3_t ent) {
|
|||
|
||||
p->time = time;
|
||||
p->alpha = 0.5;
|
||||
p->alphavel = -1.0f / (0.3f + frand() * 0.2f);
|
||||
p->color = 0xe4 + (rand()&3);
|
||||
p->alphavel = -1.0f / (0.3f + frandk() * 0.2f);
|
||||
p->color = 0xe4 + (randk()&3);
|
||||
|
||||
for (j=0; j<3; j++) {
|
||||
p->org[j] = move[j];
|
||||
|
@ -1375,12 +1375,12 @@ void CL_BubbleTrail (vec3_t start, vec3_t end) {
|
|||
p->time = time;
|
||||
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0f / (1+frand()*0.2f);
|
||||
p->color = 4 + (rand()&7);
|
||||
p->alphavel = -1.0f / (1+frandk()*0.2f);
|
||||
p->color = 4 + (randk()&7);
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = move[j] + crand()*2;
|
||||
p->vel[j] = crand()*5;
|
||||
p->org[j] = move[j] + crandk()*2;
|
||||
p->vel[j] = crandk()*5;
|
||||
}
|
||||
|
||||
p->vel[2] += 6;
|
||||
|
@ -1406,7 +1406,7 @@ void CL_FlyParticles (vec3_t origin, int count) {
|
|||
|
||||
if (!avelocities[0][0]) {
|
||||
for (i=0 ; i<NUMVERTEXNORMALS*3 ; i++)
|
||||
avelocities[0][i] = (rand()&255) * 0.01f;
|
||||
avelocities[0][i] = (randk()&255) * 0.01f;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1495,7 +1495,7 @@ void CL_BfgParticles (entity_t *ent) {
|
|||
|
||||
if (!avelocities[0][0]) {
|
||||
for (i=0 ; i<NUMVERTEXNORMALS*3 ; i++)
|
||||
avelocities[0][i] = (rand()&255) * 0.01f;
|
||||
avelocities[0][i] = (randk()&255) * 0.01f;
|
||||
}
|
||||
|
||||
ltime = time / 1000.0;
|
||||
|
@ -1578,12 +1578,12 @@ void CL_TrapParticles (entity_t *ent) {
|
|||
p->time = time;
|
||||
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0f / (0.3f+frand()*0.2f);
|
||||
p->alphavel = -1.0f / (0.3f+frandk()*0.2f);
|
||||
p->color = 0xe0;
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = move[j] + crand();
|
||||
p->vel[j] = crand()*15;
|
||||
p->org[j] = move[j] + crandk();
|
||||
p->vel[j] = crandk()*15;
|
||||
p->accel[j] = 0;
|
||||
}
|
||||
|
||||
|
@ -1614,20 +1614,20 @@ void CL_TrapParticles (entity_t *ent) {
|
|||
active_particles = p;
|
||||
|
||||
p->time = time;
|
||||
p->color = 0xe0 + (rand()&3);
|
||||
p->color = 0xe0 + (randk()&3);
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0f / (0.3f + (rand()&7) * 0.02f);
|
||||
p->alphavel = -1.0f / (0.3f + (randk()&7) * 0.02f);
|
||||
|
||||
p->org[0] = org[0] + i + ((rand()&23) * crand());
|
||||
p->org[1] = org[1] + j + ((rand()&23) * crand());
|
||||
p->org[2] = org[2] + k + ((rand()&23) * crand());
|
||||
p->org[0] = org[0] + i + ((randk()&23) * crandk());
|
||||
p->org[1] = org[1] + j + ((randk()&23) * crandk());
|
||||
p->org[2] = org[2] + k + ((randk()&23) * crandk());
|
||||
|
||||
dir[0] = j * 8.0f;
|
||||
dir[1] = i * 8.0f;
|
||||
dir[2] = k * 8.0f;
|
||||
|
||||
VectorNormalize (dir);
|
||||
vel = (float)(50 + (rand()&63));
|
||||
vel = (float)(50 + (randk()&63));
|
||||
VectorScale (dir, vel, p->vel);
|
||||
|
||||
p->accel[0] = p->accel[1] = 0;
|
||||
|
@ -1652,18 +1652,18 @@ void CL_BFGExplosionParticles (vec3_t org) {
|
|||
active_particles = p;
|
||||
|
||||
p->time = time;
|
||||
p->color = 0xd0 + (rand()&7);
|
||||
p->color = 0xd0 + (randk()&7);
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = org[j] + ((rand()%32)-16);
|
||||
p->vel[j] = (rand()%384)-192;
|
||||
p->org[j] = org[j] + ((randk()%32)-16);
|
||||
p->vel[j] = (randk()%384)-192;
|
||||
}
|
||||
|
||||
p->accel[0] = p->accel[1] = 0;
|
||||
p->accel[2] = -PARTICLE_GRAVITY;
|
||||
p->alpha = 1.0;
|
||||
|
||||
p->alphavel = -0.8f / (0.5f + frand()*0.3f);
|
||||
p->alphavel = -0.8f / (0.5f + frandk()*0.3f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1687,20 +1687,20 @@ void CL_TeleportParticles (vec3_t org) {
|
|||
active_particles = p;
|
||||
|
||||
p->time = time;
|
||||
p->color = 7 + (rand()&7);
|
||||
p->color = 7 + (randk()&7);
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0f / (0.3f + (rand()&7) * 0.02f);
|
||||
p->alphavel = -1.0f / (0.3f + (randk()&7) * 0.02f);
|
||||
|
||||
p->org[0] = org[0] + i + (rand()&3);
|
||||
p->org[1] = org[1] + j + (rand()&3);
|
||||
p->org[2] = org[2] + k + (rand()&3);
|
||||
p->org[0] = org[0] + i + (randk()&3);
|
||||
p->org[1] = org[1] + j + (randk()&3);
|
||||
p->org[2] = org[2] + k + (randk()&3);
|
||||
|
||||
dir[0] = j*8.0f;
|
||||
dir[1] = i*8.0f;
|
||||
dir[2] = k*8.0f;
|
||||
|
||||
VectorNormalize (dir);
|
||||
vel = (float)(50 + (rand()&63));
|
||||
vel = (float)(50 + (randk()&63));
|
||||
VectorScale (dir, vel, p->vel);
|
||||
|
||||
p->accel[0] = p->accel[1] = 0;
|
||||
|
@ -1727,7 +1727,7 @@ void CL_EntityEvent (entity_state_t *ent) {
|
|||
case EV_FOOTSTEP:
|
||||
|
||||
if (cl_footsteps->value)
|
||||
S_StartSound (NULL, ent->number, CHAN_BODY, cl_sfx_footsteps[rand()&3], 1, ATTN_NORM, 0);
|
||||
S_StartSound (NULL, ent->number, CHAN_BODY, cl_sfx_footsteps[randk()&3], 1, ATTN_NORM, 0);
|
||||
|
||||
break;
|
||||
case EV_FALLSHORT:
|
||||
|
@ -1815,7 +1815,7 @@ void CL_DebugTrail (vec3_t start, vec3_t end) {
|
|||
VectorClear (p->vel);
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -0.1f;
|
||||
p->color = 0x74 + (rand()&7);
|
||||
p->color = 0x74 + (randk()&7);
|
||||
VectorCopy (move, p->org);
|
||||
VectorAdd (move, vec, move);
|
||||
}
|
||||
|
@ -1852,15 +1852,15 @@ void CL_SmokeTrail (vec3_t start, vec3_t end, int colorStart, int colorRun, int
|
|||
p->time = time;
|
||||
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0f / (1+frand()*0.5f);
|
||||
p->color = colorStart + (float)(rand() % colorRun);
|
||||
p->alphavel = -1.0f / (1+frandk()*0.5f);
|
||||
p->color = colorStart + (float)(randk() % colorRun);
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = move[j] + crand()*3;
|
||||
p->org[j] = move[j] + crandk()*3;
|
||||
p->accel[j] = 0;
|
||||
}
|
||||
|
||||
p->vel[2] = 20 + crand()*5;
|
||||
p->vel[2] = 20 + crandk()*5;
|
||||
|
||||
VectorAdd (move, vec, move);
|
||||
}
|
||||
|
@ -1888,7 +1888,7 @@ void CL_ForceWall (vec3_t start, vec3_t end, int color8) {
|
|||
if (!free_particles)
|
||||
return;
|
||||
|
||||
if (frand() > 0.3) {
|
||||
if (frandk() > 0.3) {
|
||||
p = free_particles;
|
||||
free_particles = p->next;
|
||||
p->next = active_particles;
|
||||
|
@ -1898,17 +1898,17 @@ void CL_ForceWall (vec3_t start, vec3_t end, int color8) {
|
|||
p->time = time;
|
||||
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0f / (3.0+frand()*0.5f);
|
||||
p->alphavel = -1.0f / (3.0+frandk()*0.5f);
|
||||
p->color = color8;
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = move[j] + crand()*3;
|
||||
p->org[j] = move[j] + crandk()*3;
|
||||
p->accel[j] = 0;
|
||||
}
|
||||
|
||||
p->vel[0] = 0;
|
||||
p->vel[1] = 0;
|
||||
p->vel[2] = -40 - (crand()*10);
|
||||
p->vel[2] = -40 - (crandk()*10);
|
||||
}
|
||||
|
||||
VectorAdd (move, vec, move);
|
||||
|
@ -1947,12 +1947,12 @@ void CL_BubbleTrail2 (vec3_t start, vec3_t end, int dist) {
|
|||
p->time = time;
|
||||
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0f / (1+frand()*0.1f);
|
||||
p->color = 4 + (rand()&7);
|
||||
p->alphavel = -1.0f / (1+frandk()*0.1f);
|
||||
p->color = 4 + (randk()&7);
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = move[j] + crand()*2;
|
||||
p->vel[j] = crand()*10;
|
||||
p->org[j] = move[j] + crandk()*2;
|
||||
p->vel[j] = crandk()*10;
|
||||
}
|
||||
|
||||
p->org[2] -= 4;
|
||||
|
@ -2035,7 +2035,7 @@ void CL_Heatbeam (vec3_t start, vec3_t forward) {
|
|||
|
||||
p->alpha = 0.5;
|
||||
p->alphavel = -1000.0;
|
||||
p->color = 223 - (rand()&7);
|
||||
p->color = 223 - (randk()&7);
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = move[j] + dir[j]*3;
|
||||
|
@ -2069,23 +2069,23 @@ void CL_ParticleSteamEffect (vec3_t org, vec3_t dir, int color, int count, int m
|
|||
active_particles = p;
|
||||
|
||||
p->time = time;
|
||||
p->color = color + (rand()&7);
|
||||
p->color = color + (randk()&7);
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = org[j] + magnitude*0.1f*crand();
|
||||
p->org[j] = org[j] + magnitude*0.1f*crandk();
|
||||
}
|
||||
|
||||
VectorScale (dir, magnitude, p->vel);
|
||||
d = crand()*magnitude/3;
|
||||
d = crandk()*magnitude/3;
|
||||
VectorMA (p->vel, d, r, p->vel);
|
||||
d = crand()*magnitude/3;
|
||||
d = crandk()*magnitude/3;
|
||||
VectorMA (p->vel, d, u, p->vel);
|
||||
|
||||
p->accel[0] = p->accel[1] = 0;
|
||||
p->accel[2] = -PARTICLE_GRAVITY/2;
|
||||
p->alpha = 1.0;
|
||||
|
||||
p->alphavel = -1.0f / (0.5f + frand()*0.3f);
|
||||
p->alphavel = -1.0f / (0.5f + frandk()*0.3f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2109,23 +2109,23 @@ void CL_ParticleSteamEffect2 (cl_sustain_t *self) {
|
|||
active_particles = p;
|
||||
|
||||
p->time = cl.time;
|
||||
p->color = self->color + (rand()&7);
|
||||
p->color = self->color + (randk()&7);
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = self->org[j] + self->magnitude*0.1*crand();
|
||||
p->org[j] = self->org[j] + self->magnitude*0.1*crandk();
|
||||
}
|
||||
|
||||
VectorScale (dir, self->magnitude, p->vel);
|
||||
d = crand()*self->magnitude/3;
|
||||
d = crandk()*self->magnitude/3;
|
||||
VectorMA (p->vel, d, r, p->vel);
|
||||
d = crand()*self->magnitude/3;
|
||||
d = crandk()*self->magnitude/3;
|
||||
VectorMA (p->vel, d, u, p->vel);
|
||||
|
||||
p->accel[0] = p->accel[1] = 0;
|
||||
p->accel[2] = -PARTICLE_GRAVITY/2;
|
||||
p->alpha = 1.0;
|
||||
|
||||
p->alphavel = -1.0 / (0.5 + frand()*0.3);
|
||||
p->alphavel = -1.0 / (0.5 + frandk()*0.3);
|
||||
}
|
||||
|
||||
self->nextthink += self->thinkinterval;
|
||||
|
@ -2208,9 +2208,9 @@ void CL_Tracker_Shell(vec3_t origin) {
|
|||
p->alpha = 1.0;
|
||||
p->alphavel = INSTANT_PARTICLE;
|
||||
p->color = 0;
|
||||
dir[0] = crand();
|
||||
dir[1] = crand();
|
||||
dir[2] = crand();
|
||||
dir[0] = crandk();
|
||||
dir[1] = crandk();
|
||||
dir[2] = crandk();
|
||||
VectorNormalize(dir);
|
||||
|
||||
VectorMA(origin, 40, dir, p->org);
|
||||
|
@ -2240,9 +2240,9 @@ void CL_MonsterPlasma_Shell(vec3_t origin) {
|
|||
p->alpha = 1.0;
|
||||
p->alphavel = INSTANT_PARTICLE;
|
||||
p->color = 0xe0;
|
||||
dir[0] = crand();
|
||||
dir[1] = crand();
|
||||
dir[2] = crand();
|
||||
dir[0] = crandk();
|
||||
dir[1] = crandk();
|
||||
dir[2] = crandk();
|
||||
VectorNormalize(dir);
|
||||
|
||||
VectorMA(origin, 10, dir, p->org);
|
||||
|
@ -2274,10 +2274,10 @@ void CL_Widowbeamout (cl_sustain_t *self) {
|
|||
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = INSTANT_PARTICLE;
|
||||
p->color = colortable[rand()&3];
|
||||
dir[0] = crand();
|
||||
dir[1] = crand();
|
||||
dir[2] = crand();
|
||||
p->color = colortable[randk()&3];
|
||||
dir[0] = crandk();
|
||||
dir[1] = crandk();
|
||||
dir[2] = crandk();
|
||||
VectorNormalize(dir);
|
||||
|
||||
VectorMA(self->org, (45.0 * ratio), dir, p->org);
|
||||
|
@ -2309,10 +2309,10 @@ void CL_Nukeblast (cl_sustain_t *self) {
|
|||
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = INSTANT_PARTICLE;
|
||||
p->color = colortable[rand()&3];
|
||||
dir[0] = crand();
|
||||
dir[1] = crand();
|
||||
dir[2] = crand();
|
||||
p->color = colortable[randk()&3];
|
||||
dir[0] = crandk();
|
||||
dir[1] = crandk();
|
||||
dir[2] = crandk();
|
||||
VectorNormalize(dir);
|
||||
|
||||
VectorMA(self->org, (200.0 * ratio), dir, p->org);
|
||||
|
@ -2338,10 +2338,10 @@ void CL_WidowSplash (vec3_t org) {
|
|||
active_particles = p;
|
||||
|
||||
p->time = time;
|
||||
p->color = colortable[rand()&3];
|
||||
dir[0] = crand();
|
||||
dir[1] = crand();
|
||||
dir[2] = crand();
|
||||
p->color = colortable[randk()&3];
|
||||
dir[0] = crandk();
|
||||
dir[1] = crandk();
|
||||
dir[2] = crandk();
|
||||
VectorNormalize(dir);
|
||||
VectorMA(org, 45.0, dir, p->org);
|
||||
VectorMA(vec3_origin, 40.0, dir, p->vel);
|
||||
|
@ -2349,7 +2349,7 @@ void CL_WidowSplash (vec3_t org) {
|
|||
p->accel[0] = p->accel[1] = 0;
|
||||
p->alpha = 1.0;
|
||||
|
||||
p->alphavel = -0.8f / (0.5f + frand()*0.3f);
|
||||
p->alphavel = -0.8f / (0.5f + frandk()*0.3f);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2377,9 +2377,9 @@ void CL_Tracker_Explode(vec3_t origin) {
|
|||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0;
|
||||
p->color = 0;
|
||||
dir[0] = crand();
|
||||
dir[1] = crand();
|
||||
dir[2] = crand();
|
||||
dir[0] = crandk();
|
||||
dir[1] = crandk();
|
||||
dir[2] = crandk();
|
||||
VectorNormalize(dir);
|
||||
VectorScale(dir, -1, backdir);
|
||||
|
||||
|
@ -2422,12 +2422,12 @@ void CL_TagTrail (vec3_t start, vec3_t end, int color) {
|
|||
p->time = time;
|
||||
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0f / (0.8f+frand()*0.2f);
|
||||
p->alphavel = -1.0f / (0.8f+frandk()*0.2f);
|
||||
p->color = color;
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = move[j] + crand()*16;
|
||||
p->vel[j] = crand()*5;
|
||||
p->org[j] = move[j] + crandk()*16;
|
||||
p->vel[j] = crandk()*5;
|
||||
p->accel[j] = 0;
|
||||
}
|
||||
|
||||
|
@ -2453,18 +2453,18 @@ void CL_ColorExplosionParticles (vec3_t org, int color, int run) {
|
|||
active_particles = p;
|
||||
|
||||
p->time = time;
|
||||
p->color = color + (rand() % run);
|
||||
p->color = color + (randk() % run);
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = org[j] + ((rand()%32)-16);
|
||||
p->vel[j] = (rand()%256)-128;
|
||||
p->org[j] = org[j] + ((randk()%32)-16);
|
||||
p->vel[j] = (randk()%256)-128;
|
||||
}
|
||||
|
||||
p->accel[0] = p->accel[1] = 0;
|
||||
p->accel[2] = -PARTICLE_GRAVITY;
|
||||
p->alpha = 1.0;
|
||||
|
||||
p->alphavel = -0.4f / (0.6f + frand()*0.2f);
|
||||
p->alphavel = -0.4f / (0.6f + frandk()*0.2f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2492,22 +2492,22 @@ void CL_ParticleSmokeEffect (vec3_t org, vec3_t dir, int color, int count, int m
|
|||
active_particles = p;
|
||||
|
||||
p->time = time;
|
||||
p->color = color + (rand()&7);
|
||||
p->color = color + (randk()&7);
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = org[j] + magnitude*0.1f*crand();
|
||||
p->org[j] = org[j] + magnitude*0.1f*crandk();
|
||||
}
|
||||
|
||||
VectorScale (dir, magnitude, p->vel);
|
||||
d = crand()*magnitude/3;
|
||||
d = crandk()*magnitude/3;
|
||||
VectorMA (p->vel, d, r, p->vel);
|
||||
d = crand()*magnitude/3;
|
||||
d = crandk()*magnitude/3;
|
||||
VectorMA (p->vel, d, u, p->vel);
|
||||
|
||||
p->accel[0] = p->accel[1] = p->accel[2] = 0;
|
||||
p->alpha = 1.0;
|
||||
|
||||
p->alphavel = -1.0f / (0.5f + frand()*0.3f);
|
||||
p->alphavel = -1.0f / (0.5f + frandk()*0.3f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2535,19 +2535,19 @@ void CL_BlasterParticles2 (vec3_t org, vec3_t dir, unsigned int color) {
|
|||
active_particles = p;
|
||||
|
||||
p->time = time;
|
||||
p->color = color + (rand()&7);
|
||||
d = (float)(rand()&15);
|
||||
p->color = color + (randk()&7);
|
||||
d = (float)(randk()&15);
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = org[j] + ((rand()&7)-4) + d*dir[j];
|
||||
p->vel[j] = dir[j] * 30 + crand()*40;
|
||||
p->org[j] = org[j] + ((randk()&7)-4) + d*dir[j];
|
||||
p->vel[j] = dir[j] * 30 + crandk()*40;
|
||||
}
|
||||
|
||||
p->accel[0] = p->accel[1] = 0;
|
||||
p->accel[2] = -PARTICLE_GRAVITY;
|
||||
p->alpha = 1.0;
|
||||
|
||||
p->alphavel = -1.0f / (0.5f + frand()*0.3f);
|
||||
p->alphavel = -1.0f / (0.5f + frandk()*0.3f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2587,11 +2587,11 @@ void CL_BlasterTrail2 (vec3_t start, vec3_t end) {
|
|||
p->time = time;
|
||||
|
||||
p->alpha = 1.0;
|
||||
p->alphavel = -1.0f / (float)(0.3f+frand()*0.2f);
|
||||
p->alphavel = -1.0f / (float)(0.3f+frandk()*0.2f);
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = move[j] + crand();
|
||||
p->vel[j] = crand()*5;
|
||||
p->org[j] = move[j] + crandk();
|
||||
p->vel[j] = crandk()*5;
|
||||
p->accel[j] = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ void CL_AddPacketEntities (frame_t *frame) {
|
|||
if ( renderfx & RF_BEAM ) {
|
||||
/* the four beam colors are encoded in 32 bits of skinnum (hack) */
|
||||
ent.alpha = 0.30f;
|
||||
ent.skinnum = (s1->skinnum >> ((rand() % 4)*8)) & 0xff;
|
||||
ent.skinnum = (s1->skinnum >> ((randk() % 4)*8)) & 0xff;
|
||||
ent.model = NULL;
|
||||
|
||||
} else {
|
||||
|
@ -451,7 +451,7 @@ void CL_AddPacketEntities (frame_t *frame) {
|
|||
} else if (effects & EF_TRAP) {
|
||||
ent.origin[2] += 32;
|
||||
CL_TrapParticles (&ent);
|
||||
i = (rand()%100) + 100;
|
||||
i = (randk()%100) + 100;
|
||||
V_AddLight (ent.origin, i, 1, 0.8f, 0.1f);
|
||||
|
||||
} else if (effects & EF_FLAG1) {
|
||||
|
|
|
@ -70,7 +70,7 @@ void KeyDown (kbutton_t *b) {
|
|||
c = Cmd_Argv(1);
|
||||
|
||||
if (c[0])
|
||||
k = atoi(c);
|
||||
k = (int)strtol(c, (char **)NULL, 10);
|
||||
|
||||
else
|
||||
k = -1; /* typed manually at the console for continuous down */
|
||||
|
@ -94,7 +94,7 @@ void KeyDown (kbutton_t *b) {
|
|||
|
||||
/* save timestamp */
|
||||
c = Cmd_Argv(2);
|
||||
b->downtime = atoi(c);
|
||||
b->downtime = (int)strtol(c, (char **)NULL, 10);
|
||||
|
||||
if (!b->downtime)
|
||||
b->downtime = sys_frame_time - 100;
|
||||
|
@ -110,7 +110,7 @@ void KeyUp (kbutton_t *b) {
|
|||
c = Cmd_Argv(1);
|
||||
|
||||
if (c[0])
|
||||
k = atoi(c);
|
||||
k = (int)strtol(c, (char **)NULL, 10);
|
||||
|
||||
else {
|
||||
/* typed manually at the console, assume for unsticking, so clear all */
|
||||
|
@ -136,7 +136,7 @@ void KeyUp (kbutton_t *b) {
|
|||
|
||||
/* save timestamp */
|
||||
c = Cmd_Argv(2);
|
||||
uptime = atoi(c);
|
||||
uptime = (int)strtol(c, (char **)NULL, 10);
|
||||
|
||||
if (uptime)
|
||||
b->msec += uptime - b->downtime;
|
||||
|
@ -243,7 +243,7 @@ void IN_UseUp (void) {
|
|||
}
|
||||
|
||||
void IN_Impulse (void) {
|
||||
in_impulse=atoi(Cmd_Argv(1));
|
||||
in_impulse=(int)strtol(Cmd_Argv(1), (char **)NULL, 10);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -438,7 +438,7 @@ void CL_Precache_f (void)
|
|||
|
||||
precache_check = CS_MODELS;
|
||||
|
||||
precache_spawncount = atoi(Cmd_Argv(1));
|
||||
precache_spawncount = (int)strtol(Cmd_Argv(1), (char **)NULL, 10);
|
||||
precache_model = 0;
|
||||
precache_model_skin = 0;
|
||||
|
||||
|
|
|
@ -576,7 +576,7 @@ void CL_ConnectionlessPacket (void)
|
|||
/* challenge from the server we are connecting to */
|
||||
if (!strcmp(c, "challenge"))
|
||||
{
|
||||
cls.challenge = atoi(Cmd_Argv(1));
|
||||
cls.challenge = (int)strtol(Cmd_Argv(1), (char **)NULL, 10);
|
||||
CL_SendConnectPacket ();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -838,12 +838,12 @@ void CL_ParseConfigString (void) {
|
|||
else if (i == CS_CDTRACK) {
|
||||
if (cl.refresh_prepped) {
|
||||
#ifdef CDA
|
||||
CDAudio_Play (atoi(cl.configstrings[CS_CDTRACK]), true);
|
||||
CDAudio_Play ((int)strtol(cl.configstrings[CS_CDTRACK], (char **)NULL, 10), true);
|
||||
#endif
|
||||
|
||||
#ifdef OGG
|
||||
/* OGG/Vorbis */
|
||||
if (atoi(cl.configstrings[CS_CDTRACK]) < 10) {
|
||||
if ((int)strtol(cl.configstrings[CS_CDTRACK], (char **)NULL, 10) < 10) {
|
||||
char tmp[3] = "0";
|
||||
OGG_ParseCmd(strcat(tmp, cl.configstrings[CS_CDTRACK]));
|
||||
|
||||
|
|
|
@ -57,19 +57,19 @@ void CL_ParticleEffect (vec3_t org, vec3_t dir, int color, int count) {
|
|||
active_particles = p;
|
||||
|
||||
p->time = cl.time;
|
||||
p->color = color + (rand()&7);
|
||||
d = rand()&31;
|
||||
p->color = color + (randk()&7);
|
||||
d = randk()&31;
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = org[j] + ((rand()&7)-4) + d*dir[j];
|
||||
p->vel[j] = crand()*20;
|
||||
p->org[j] = org[j] + ((randk()&7)-4) + d*dir[j];
|
||||
p->vel[j] = crandk()*20;
|
||||
}
|
||||
|
||||
p->accel[0] = p->accel[1] = 0;
|
||||
p->accel[2] = -PARTICLE_GRAVITY+0.2f;
|
||||
p->alpha = 1.0;
|
||||
|
||||
p->alphavel = -1.0 / (0.5 + frand()*0.3);
|
||||
p->alphavel = -1.0 / (0.5 + frandk()*0.3);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,20 +90,20 @@ void CL_ParticleEffect2 (vec3_t org, vec3_t dir, int color, int count) {
|
|||
active_particles = p;
|
||||
|
||||
p->time = time;
|
||||
p->color = color + (rand()&7);
|
||||
p->color = color + (randk()&7);
|
||||
|
||||
d = rand()&7;
|
||||
d = randk()&7;
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = org[j] + ((rand()&7)-4) + d*dir[j];
|
||||
p->vel[j] = crand()*20;
|
||||
p->org[j] = org[j] + ((randk()&7)-4) + d*dir[j];
|
||||
p->vel[j] = crandk()*20;
|
||||
}
|
||||
|
||||
p->accel[0] = p->accel[1] = 0;
|
||||
p->accel[2] = -PARTICLE_GRAVITY;
|
||||
p->alpha = 1.0;
|
||||
|
||||
p->alphavel = -1.0f / (0.5f + frand()*0.3f);
|
||||
p->alphavel = -1.0f / (0.5f + frandk()*0.3f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,18 +126,18 @@ void CL_ParticleEffect3 (vec3_t org, vec3_t dir, int color, int count) {
|
|||
p->time = time;
|
||||
p->color = color;
|
||||
|
||||
d = rand()&7;
|
||||
d = randk()&7;
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = org[j] + ((rand()&7)-4) + d*dir[j];
|
||||
p->vel[j] = crand()*20;
|
||||
p->org[j] = org[j] + ((randk()&7)-4) + d*dir[j];
|
||||
p->vel[j] = crandk()*20;
|
||||
}
|
||||
|
||||
p->accel[0] = p->accel[1] = 0;
|
||||
p->accel[2] = PARTICLE_GRAVITY;
|
||||
p->alpha = 1.0;
|
||||
|
||||
p->alphavel = -1.0f / (0.5f + frand()*0.3f);
|
||||
p->alphavel = -1.0f / (0.5f + frandk()*0.3f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,22 +221,22 @@ void CL_GenericParticleEffect (vec3_t org, vec3_t dir, int color, int count, int
|
|||
p->time = time;
|
||||
|
||||
if (numcolors > 1)
|
||||
p->color = color + (rand() & numcolors);
|
||||
p->color = color + (randk() & numcolors);
|
||||
|
||||
else
|
||||
p->color = color;
|
||||
|
||||
d = (float)(rand() & dirspread);
|
||||
d = (float)(randk() & dirspread);
|
||||
|
||||
for (j=0 ; j<3 ; j++) {
|
||||
p->org[j] = org[j] + ((rand()&7)-4) + d*dir[j];
|
||||
p->vel[j] = crand()*20;
|
||||
p->org[j] = org[j] + ((randk()&7)-4) + d*dir[j];
|
||||
p->vel[j] = crandk()*20;
|
||||
}
|
||||
|
||||
p->accel[0] = p->accel[1] = 0;
|
||||
p->accel[2] = -PARTICLE_GRAVITY;
|
||||
p->alpha = 1.0;
|
||||
|
||||
p->alphavel = -1.0f / (0.5f + frand()*alphavel);
|
||||
p->alphavel = -1.0f / (0.5f + frandk()*alphavel);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ void CL_PredictMovement (void) {
|
|||
/* copy current state to pmove */
|
||||
pm.trace = CL_PMTrace;
|
||||
pm.pointcontents = CL_PMpointcontents;
|
||||
pm_airaccelerate = atof(cl.configstrings[CS_AIRACCEL]);
|
||||
pm_airaccelerate = strtod(cl.configstrings[CS_AIRACCEL], (char **)NULL);
|
||||
pm.s = cl.frame.playerstate.pmove;
|
||||
|
||||
VectorSet (pm.mins, -16, -16, -24);
|
||||
|
|
|
@ -312,15 +312,15 @@ void SCR_Sky_f (void) {
|
|||
}
|
||||
|
||||
if (Cmd_Argc() > 2)
|
||||
rotate = (float)atof(Cmd_Argv(2));
|
||||
rotate = (float)strtod(Cmd_Argv(2), (char **)NULL);
|
||||
|
||||
else
|
||||
rotate = 0;
|
||||
|
||||
if (Cmd_Argc() == 6) {
|
||||
axis[0] = (float)atof(Cmd_Argv(3));
|
||||
axis[1] = (float)atof(Cmd_Argv(4));
|
||||
axis[2] = (float)atof(Cmd_Argv(5));
|
||||
axis[0] = (float)strtod(Cmd_Argv(3), (char **)NULL);
|
||||
axis[1] = (float)strtod(Cmd_Argv(4), (char **)NULL);
|
||||
axis[2] = (float)strtod(Cmd_Argv(5), (char **)NULL);
|
||||
|
||||
} else {
|
||||
axis[0] = 0;
|
||||
|
@ -810,44 +810,44 @@ void SCR_ExecuteLayoutString (char *s) {
|
|||
|
||||
if (!strcmp(token, "xl")) {
|
||||
token = COM_Parse (&s);
|
||||
x = atoi(token);
|
||||
x = (int)strtol(token, (char **)NULL, 10);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp(token, "xr")) {
|
||||
token = COM_Parse (&s);
|
||||
x = viddef.width + atoi(token);
|
||||
x = viddef.width + (int)strtol(token, (char **)NULL, 10);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp(token, "xv")) {
|
||||
token = COM_Parse (&s);
|
||||
x = viddef.width/2 - 160 + atoi(token);
|
||||
x = viddef.width/2 - 160 + (int)strtol(token, (char **)NULL, 10);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp(token, "yt")) {
|
||||
token = COM_Parse (&s);
|
||||
y = atoi(token);
|
||||
y = (int)strtol(token, (char **)NULL, 10);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp(token, "yb")) {
|
||||
token = COM_Parse (&s);
|
||||
y = viddef.height + atoi(token);
|
||||
y = viddef.height + (int)strtol(token, (char **)NULL, 10);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp(token, "yv")) {
|
||||
token = COM_Parse (&s);
|
||||
y = viddef.height/2 - 120 + atoi(token);
|
||||
y = viddef.height/2 - 120 + (int)strtol(token, (char **)NULL, 10);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp(token, "pic")) {
|
||||
/* draw a pic from a stat number */
|
||||
token = COM_Parse (&s);
|
||||
index = atoi(token);
|
||||
index = (int)strtol(token, (char **)NULL, 10);
|
||||
|
||||
if (index < 0 || index >= sizeof(cl.frame.playerstate.stats))
|
||||
Com_Error (ERR_DROP, "bad stats index %d (0x%x)", index, index);
|
||||
|
@ -871,14 +871,14 @@ void SCR_ExecuteLayoutString (char *s) {
|
|||
int score, ping, time;
|
||||
|
||||
token = COM_Parse (&s);
|
||||
x = viddef.width/2 - 160 + atoi(token);
|
||||
x = viddef.width/2 - 160 + (int)strtol(token, (char **)NULL, 10);
|
||||
token = COM_Parse (&s);
|
||||
y = viddef.height/2 - 120 + atoi(token);
|
||||
y = viddef.height/2 - 120 + (int)strtol(token, (char **)NULL, 10);
|
||||
SCR_AddDirtyPoint (x, y);
|
||||
SCR_AddDirtyPoint (x+159, y+31);
|
||||
|
||||
token = COM_Parse (&s);
|
||||
value = atoi(token);
|
||||
value = (int)strtol(token, (char **)NULL, 10);
|
||||
|
||||
if (value >= MAX_CLIENTS || value < 0)
|
||||
Com_Error (ERR_DROP, "client >= MAX_CLIENTS");
|
||||
|
@ -886,13 +886,13 @@ void SCR_ExecuteLayoutString (char *s) {
|
|||
ci = &cl.clientinfo[value];
|
||||
|
||||
token = COM_Parse (&s);
|
||||
score = atoi(token);
|
||||
score = (int)strtol(token, (char **)NULL, 10);
|
||||
|
||||
token = COM_Parse (&s);
|
||||
ping = atoi(token);
|
||||
ping = (int)strtol(token, (char **)NULL, 10);
|
||||
|
||||
token = COM_Parse (&s);
|
||||
time = atoi(token);
|
||||
time = (int)strtol(token, (char **)NULL, 10);
|
||||
|
||||
DrawAltString (x+32, y, ci->name);
|
||||
DrawString (x+32, y+8, "Score: ");
|
||||
|
@ -913,14 +913,14 @@ void SCR_ExecuteLayoutString (char *s) {
|
|||
char block[80];
|
||||
|
||||
token = COM_Parse (&s);
|
||||
x = viddef.width/2 - 160 + atoi(token);
|
||||
x = viddef.width/2 - 160 + (int)strtol(token, (char **)NULL, 10);
|
||||
token = COM_Parse (&s);
|
||||
y = viddef.height/2 - 120 + atoi(token);
|
||||
y = viddef.height/2 - 120 + (int)strtol(token, (char **)NULL, 10);
|
||||
SCR_AddDirtyPoint (x, y);
|
||||
SCR_AddDirtyPoint (x+159, y+31);
|
||||
|
||||
token = COM_Parse (&s);
|
||||
value = atoi(token);
|
||||
value = (int)strtol(token, (char **)NULL, 10);
|
||||
|
||||
if (value >= MAX_CLIENTS || value < 0)
|
||||
Com_Error (ERR_DROP, "client >= MAX_CLIENTS");
|
||||
|
@ -928,10 +928,10 @@ void SCR_ExecuteLayoutString (char *s) {
|
|||
ci = &cl.clientinfo[value];
|
||||
|
||||
token = COM_Parse (&s);
|
||||
score = atoi(token);
|
||||
score = (int)strtol(token, (char **)NULL, 10);
|
||||
|
||||
token = COM_Parse (&s);
|
||||
ping = atoi(token);
|
||||
ping = (int)strtol(token, (char **)NULL, 10);
|
||||
|
||||
if (ping > 999)
|
||||
ping = 999;
|
||||
|
@ -959,9 +959,9 @@ void SCR_ExecuteLayoutString (char *s) {
|
|||
if (!strcmp(token, "num")) {
|
||||
/* draw a number */
|
||||
token = COM_Parse (&s);
|
||||
width = atoi(token);
|
||||
width = (int)strtol(token, (char **)NULL, 10);
|
||||
token = COM_Parse (&s);
|
||||
value = cl.frame.playerstate.stats[atoi(token)];
|
||||
value = cl.frame.playerstate.stats[(int)strtol(token, (char **)NULL, 10)];
|
||||
SCR_DrawField (x, y, 0, width, value);
|
||||
continue;
|
||||
}
|
||||
|
@ -1033,7 +1033,7 @@ void SCR_ExecuteLayoutString (char *s) {
|
|||
|
||||
if (!strcmp(token, "stat_string")) {
|
||||
token = COM_Parse (&s);
|
||||
index = atoi(token);
|
||||
index = (int)strtol(token, (char **)NULL, 10);
|
||||
|
||||
if (index < 0 || index >= MAX_CONFIGSTRINGS)
|
||||
Com_Error (ERR_DROP, "Bad stat_string index");
|
||||
|
@ -1074,7 +1074,7 @@ void SCR_ExecuteLayoutString (char *s) {
|
|||
if (!strcmp(token, "if")) {
|
||||
/* draw a number */
|
||||
token = COM_Parse (&s);
|
||||
value = cl.frame.playerstate.stats[atoi(token)];
|
||||
value = cl.frame.playerstate.stats[(int)strtol(token, (char **)NULL, 10)];
|
||||
|
||||
if (!value) {
|
||||
/* skip to endif */
|
||||
|
|
|
@ -434,7 +434,7 @@ void CL_ParseLaser (int colors) {
|
|||
VectorCopy (start, l->ent.origin);
|
||||
VectorCopy (end, l->ent.oldorigin);
|
||||
l->ent.alpha = 0.30f;
|
||||
l->ent.skinnum = (colors >> ((rand() % 4)*8)) & 0xff;
|
||||
l->ent.skinnum = (colors >> ((randk() % 4)*8)) & 0xff;
|
||||
l->ent.model = NULL;
|
||||
l->ent.frame = 4;
|
||||
l->endtime = cl.time + 100;
|
||||
|
@ -592,7 +592,7 @@ void CL_ParseTEnt (void) {
|
|||
if (type != TE_SPARKS) {
|
||||
CL_SmokeAndFlash(pos);
|
||||
/* impact sound */
|
||||
cnt = rand()&15;
|
||||
cnt = randk()&15;
|
||||
|
||||
if (cnt == 1)
|
||||
S_StartSound (pos, 0, 0, cl_sfx_ric1, 1, ATTN_NORM, 0);
|
||||
|
@ -642,7 +642,7 @@ void CL_ParseTEnt (void) {
|
|||
CL_ParticleEffect (pos, dir, color, cnt);
|
||||
|
||||
if (r == SPLASH_SPARKS) {
|
||||
r = rand() & 3;
|
||||
r = randk() & 3;
|
||||
|
||||
if (r == 0)
|
||||
S_StartSound (pos, 0, 0, cl_sfx_spark5, 1, ATTN_STATIC, 0);
|
||||
|
@ -725,7 +725,7 @@ void CL_ParseTEnt (void) {
|
|||
ex->ent.model = cl_mod_explo4;
|
||||
ex->frames = 19;
|
||||
ex->baseframe = 30;
|
||||
ex->ent.angles[1] = (float)(rand() % 360);
|
||||
ex->ent.angles[1] = (float)(randk() % 360);
|
||||
EXPLOSION_PARTICLES (pos);
|
||||
|
||||
if (type == TE_GRENADE_EXPLOSION_WATER)
|
||||
|
@ -747,10 +747,10 @@ void CL_ParseTEnt (void) {
|
|||
ex->lightcolor[0] = 1.0;
|
||||
ex->lightcolor[1] = 0.5;
|
||||
ex->lightcolor[2] = 0.5;
|
||||
ex->ent.angles[1] = (float)(rand() % 360);
|
||||
ex->ent.angles[1] = (float)(randk() % 360);
|
||||
ex->ent.model = cl_mod_explo4;
|
||||
|
||||
if (frand() < 0.5)
|
||||
if (frandk() < 0.5)
|
||||
ex->baseframe = 15;
|
||||
|
||||
ex->frames = 15;
|
||||
|
@ -773,7 +773,7 @@ void CL_ParseTEnt (void) {
|
|||
ex->lightcolor[0] = 1.0;
|
||||
ex->lightcolor[1] = 0.5;
|
||||
ex->lightcolor[2] = 0.5;
|
||||
ex->ent.angles[1] = (float)(rand() % 360);
|
||||
ex->ent.angles[1] = (float)(randk() % 360);
|
||||
|
||||
if (type != TE_EXPLOSION1_BIG)
|
||||
ex->ent.model = cl_mod_explo4;
|
||||
|
@ -781,7 +781,7 @@ void CL_ParseTEnt (void) {
|
|||
else
|
||||
ex->ent.model = cl_mod_explo4_big;
|
||||
|
||||
if (frand() < 0.5)
|
||||
if (frandk() < 0.5)
|
||||
ex->baseframe = 15;
|
||||
|
||||
ex->frames = 15;
|
||||
|
@ -856,7 +856,7 @@ void CL_ParseTEnt (void) {
|
|||
ex->type = ex_flash;
|
||||
ex->ent.flags = RF_BEAM;
|
||||
ex->start = cl.frame.servertime - 0.1f;
|
||||
ex->light = 100 + (float)(rand()%75);
|
||||
ex->light = 100 + (float)(randk()%75);
|
||||
ex->lightcolor[0] = 1.0f;
|
||||
ex->lightcolor[1] = 1.0f;
|
||||
ex->lightcolor[2] = 0.3f;
|
||||
|
@ -956,10 +956,10 @@ void CL_ParseTEnt (void) {
|
|||
ex->lightcolor[0] = 1.0;
|
||||
ex->lightcolor[1] = 0.5;
|
||||
ex->lightcolor[2] = 0.5;
|
||||
ex->ent.angles[1] = rand() % 360;
|
||||
ex->ent.angles[1] = randk() % 360;
|
||||
ex->ent.model = cl_mod_explo4;
|
||||
|
||||
if (frand() < 0.5)
|
||||
if (frandk() < 0.5)
|
||||
ex->baseframe = 15;
|
||||
|
||||
ex->frames = 15;
|
||||
|
@ -1158,7 +1158,7 @@ void CL_AddBeams (void) {
|
|||
ent.flags = RF_FULLBRIGHT;
|
||||
ent.angles[0] = pitch;
|
||||
ent.angles[1] = yaw;
|
||||
ent.angles[2] = (float)(rand()%360);
|
||||
ent.angles[2] = (float)(randk()%360);
|
||||
V_AddEntity (&ent);
|
||||
return;
|
||||
}
|
||||
|
@ -1171,12 +1171,12 @@ void CL_AddBeams (void) {
|
|||
ent.flags = RF_FULLBRIGHT;
|
||||
ent.angles[0] = -pitch;
|
||||
ent.angles[1] = yaw + 180.0f;
|
||||
ent.angles[2] = (float)(rand()%360);
|
||||
ent.angles[2] = (float)(randk()%360);
|
||||
|
||||
} else {
|
||||
ent.angles[0] = pitch;
|
||||
ent.angles[1] = yaw;
|
||||
ent.angles[2] = (float)(rand()%360);
|
||||
ent.angles[2] = (float)(randk()%360);
|
||||
}
|
||||
|
||||
V_AddEntity (&ent);
|
||||
|
@ -1377,7 +1377,7 @@ void CL_AddPlayerBeams (void) {
|
|||
ent.flags = RF_FULLBRIGHT;
|
||||
ent.angles[0] = pitch;
|
||||
ent.angles[1] = yaw;
|
||||
ent.angles[2] = (float)(rand()%360);
|
||||
ent.angles[2] = (float)(randk()%360);
|
||||
V_AddEntity (&ent);
|
||||
return;
|
||||
}
|
||||
|
@ -1397,12 +1397,12 @@ void CL_AddPlayerBeams (void) {
|
|||
ent.flags = RF_FULLBRIGHT;
|
||||
ent.angles[0] = -pitch;
|
||||
ent.angles[1] = yaw + 180.0f;
|
||||
ent.angles[2] = (float)(rand()%360);
|
||||
ent.angles[2] = (float)(randk()%360);
|
||||
|
||||
} else {
|
||||
ent.angles[0] = pitch;
|
||||
ent.angles[1] = yaw;
|
||||
ent.angles[2] = (float)(rand()%360);
|
||||
ent.angles[2] = (float)(randk()%360);
|
||||
}
|
||||
|
||||
V_AddEntity (&ent);
|
||||
|
|
|
@ -286,7 +286,7 @@ void CL_PrepRefresh (void) {
|
|||
/* set sky textures and speed */
|
||||
Com_Printf ("sky\r", i);
|
||||
SCR_UpdateScreen ();
|
||||
rotate = (float)atof (cl.configstrings[CS_SKYROTATE]);
|
||||
rotate = (float)strtod(cl.configstrings[CS_SKYROTATE], (char **)NULL);
|
||||
sscanf (cl.configstrings[CS_SKYAXIS], "%f %f %f",
|
||||
&axis[0], &axis[1], &axis[2]);
|
||||
re.SetSky (cl.configstrings[CS_SKY], rotate, axis);
|
||||
|
@ -310,12 +310,12 @@ void CL_PrepRefresh (void) {
|
|||
#endif
|
||||
} else {
|
||||
#ifdef CDA
|
||||
CDAudio_Play (atoi(cl.configstrings[CS_CDTRACK]), true);
|
||||
CDAudio_Play ((int)strtol(cl.configstrings[CS_CDTRACK], (char **)NULL, 10), true);
|
||||
#endif
|
||||
|
||||
#ifdef OGG
|
||||
/* OGG/Vorbis */
|
||||
if (atoi(cl.configstrings[CS_CDTRACK]) < 10) {
|
||||
if ((int)strtol(cl.configstrings[CS_CDTRACK], (char **)NULL, 10) < 10) {
|
||||
char tmp[3] = "0";
|
||||
OGG_ParseCmd(strcat(tmp, cl.configstrings[CS_CDTRACK]));
|
||||
|
||||
|
|
|
@ -1121,7 +1121,7 @@ static void CDShuffleFunc(void *unused) {
|
|||
Cvar_Set("ogg_sequence", "loop");
|
||||
|
||||
if(ogg->value) {
|
||||
if (atoi(cl.configstrings[CS_CDTRACK]) < 10) {
|
||||
if ((int)strtol(cl.configstrings[CS_CDTRACK], (char **)NULL, 10) < 10) {
|
||||
char tmp[2] = "0";
|
||||
OGG_ParseCmd(strcat(tmp, cl.configstrings[CS_CDTRACK]));
|
||||
|
||||
|
@ -1151,7 +1151,7 @@ static void UpdateCDVolumeFunc( void *unused ) {
|
|||
CDAudio_RandomPlay();
|
||||
|
||||
} else {
|
||||
CDAudio_Play(atoi(cl.configstrings[CS_CDTRACK]), true);
|
||||
CDAudio_Play((int)strtol(cl.configstrings[CS_CDTRACK], (char **)NULL, 10), true);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -1174,7 +1174,7 @@ static void UpdateOGGVolumeFunc( void *unused ) {
|
|||
OGG_Init();
|
||||
OGG_Stop();
|
||||
|
||||
if (atoi(cl.configstrings[CS_CDTRACK]) < 10) {
|
||||
if ((int)strtol(cl.configstrings[CS_CDTRACK], (char **)NULL, 10) < 10) {
|
||||
char tmp[3] = "0";
|
||||
OGG_ParseCmd(strcat(tmp, cl.configstrings[CS_CDTRACK]));
|
||||
|
||||
|
@ -2401,9 +2401,9 @@ static void StartServerActionFunc( void *self ) {
|
|||
|
||||
strcpy( startmap, strchr( mapnames[s_startmap_list.curvalue], '\n' ) + 1 );
|
||||
|
||||
maxclients = (float)atof( s_maxclients_field.buffer );
|
||||
timelimit = (float)atof( s_timelimit_field.buffer );
|
||||
fraglimit = (float)atof( s_fraglimit_field.buffer );
|
||||
maxclients = (float)strtod( s_maxclients_field.buffer, (char **)NULL );
|
||||
timelimit = (float)strtod( s_timelimit_field.buffer, (char **)NULL );
|
||||
fraglimit = (float)strtod( s_fraglimit_field.buffer, (char **)NULL );
|
||||
|
||||
Cvar_SetValue( "maxclients", ClampCvar( 0, maxclients, maxclients ) );
|
||||
Cvar_SetValue ("timelimit", ClampCvar( 0, timelimit, timelimit ) );
|
||||
|
|
|
@ -1014,6 +1014,7 @@ S_AddLoopSounds ( void )
|
|||
return;
|
||||
}
|
||||
|
||||
memset(&sounds, 0, sizeof(int) * MAX_EDICTS);
|
||||
S_BuildSoundList( sounds );
|
||||
|
||||
for ( i = 0; i < cl.frame.num_entities; i++ )
|
||||
|
|
|
@ -133,7 +133,6 @@ OGG_Init ( void )
|
|||
/* Initialize variables. */
|
||||
if ( ogg_first_init )
|
||||
{
|
||||
srand( time( NULL ) );
|
||||
ogg_buffer = NULL;
|
||||
ogg_curfile = -1;
|
||||
ogg_info = NULL;
|
||||
|
@ -559,7 +558,7 @@ OGG_Sequence ( void )
|
|||
|
||||
else if ( strcmp( ogg_sequence->string, "random" ) == 0 )
|
||||
{
|
||||
OGG_Open( ABS, rand() % ogg_numfiles );
|
||||
OGG_Open( ABS, randk() % ogg_numfiles );
|
||||
}
|
||||
|
||||
else if ( strcmp( ogg_sequence->string, "loop" ) == 0 )
|
||||
|
@ -690,17 +689,17 @@ OGG_ParseCmd ( char *arg )
|
|||
switch ( arg [ 0 ] )
|
||||
{
|
||||
case '#':
|
||||
n = atoi( arg + 1 ) - 1;
|
||||
n = (int)strtol( arg + 1, (char **)NULL, 10) - 1;
|
||||
OGG_Open( ABS, n );
|
||||
break;
|
||||
case '?':
|
||||
OGG_Open( ABS, rand() % ogg_numfiles );
|
||||
OGG_Open( ABS, randk() % ogg_numfiles );
|
||||
break;
|
||||
case '>':
|
||||
|
||||
if ( strlen( arg ) > 1 )
|
||||
{
|
||||
OGG_Open( REL, atoi( arg + 1 ) );
|
||||
OGG_Open( REL, (int)strtol( arg + 1, (char **)NULL, 10 ) );
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -713,7 +712,7 @@ OGG_ParseCmd ( char *arg )
|
|||
|
||||
if ( strlen( arg ) > 1 )
|
||||
{
|
||||
OGG_Open( REL, -atoi( arg + 1 ) );
|
||||
OGG_Open( REL, -(int)strtol( arg + 1, (char **)NULL, 10 ) );
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -793,13 +792,13 @@ OGG_SeekCmd ( void )
|
|||
switch ( Cmd_Argv( 1 ) [ 0 ] )
|
||||
{
|
||||
case '>':
|
||||
OGG_Seek( REL, atof( Cmd_Argv( 1 ) + 1 ) );
|
||||
OGG_Seek( REL, strtod( Cmd_Argv( 1 ) + 1 , (char **)NULL ) );
|
||||
break;
|
||||
case '<':
|
||||
OGG_Seek( REL, -atof( Cmd_Argv( 1 ) + 1 ) );
|
||||
OGG_Seek( REL, -strtod( Cmd_Argv( 1 ) + 1, (char **)NULL ) );
|
||||
break;
|
||||
default:
|
||||
OGG_Seek( ABS, atof( Cmd_Argv( 1 ) ) );
|
||||
OGG_Seek( ABS, strtod( Cmd_Argv( 1 ), (char **)NULL ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ float Cvar_VariableValue (char *var_name)
|
|||
if (!var)
|
||||
return 0;
|
||||
|
||||
return atof (var->string);
|
||||
return strtod(var->string, (char **)NULL);
|
||||
}
|
||||
|
||||
const char *Cvar_VariableString (const char *var_name)
|
||||
|
@ -141,7 +141,7 @@ cvar_t *Cvar_Get (char *var_name, char *var_value, int flags)
|
|||
var->name = CopyString (var_name);
|
||||
var->string = CopyString (var_value);
|
||||
var->modified = true;
|
||||
var->value = atof (var->string);
|
||||
var->value = strtod(var->string, (char **)NULL);
|
||||
|
||||
/* link the variable in */
|
||||
var->next = cvar_vars;
|
||||
|
@ -205,7 +205,7 @@ cvar_t *Cvar_Set2 (char *var_name, char *value, qboolean force)
|
|||
else
|
||||
{
|
||||
var->string = CopyString(value);
|
||||
var->value = (float)atof (var->string);
|
||||
var->value = (float)strtod(var->string, (char **)NULL);
|
||||
|
||||
if (!strcmp(var->name, "game"))
|
||||
{
|
||||
|
@ -238,7 +238,7 @@ cvar_t *Cvar_Set2 (char *var_name, char *value, qboolean force)
|
|||
Z_Free (var->string);
|
||||
|
||||
var->string = CopyString(value);
|
||||
var->value = atof (var->string);
|
||||
var->value = strtod(var->string, (char **)NULL);
|
||||
|
||||
return var;
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ cvar_t *Cvar_FullSet (char *var_name, char *value, int flags)
|
|||
Z_Free (var->string);
|
||||
|
||||
var->string = CopyString(value);
|
||||
var->value = (float)atof (var->string);
|
||||
var->value = (float)strtod(var->string, (char **)NULL);
|
||||
|
||||
var->flags = flags;
|
||||
|
||||
|
@ -307,7 +307,7 @@ void Cvar_GetLatchedVars (void)
|
|||
Z_Free (var->string);
|
||||
var->string = var->latched_string;
|
||||
var->latched_string = NULL;
|
||||
var->value = atof(var->string);
|
||||
var->value = strtod(var->string, (char **)NULL);
|
||||
|
||||
if (!strcmp(var->name, "game"))
|
||||
{
|
||||
|
|
|
@ -699,9 +699,6 @@ void Com_SetServerState (int state);
|
|||
unsigned Com_BlockChecksum (void *buffer, int length);
|
||||
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 *modder;
|
||||
extern cvar_t *dedicated;
|
||||
|
|
|
@ -229,6 +229,14 @@ void Info_RemoveKey(char *s, char *key);
|
|||
void Info_SetValueForKey(char *s, char *key, char *value);
|
||||
qboolean Info_Validate(char *s);
|
||||
|
||||
/* ============================================= */
|
||||
|
||||
/* Random number generator */
|
||||
int randk(void);
|
||||
float frandk(void);
|
||||
float crandk(void);
|
||||
void randk_seed(void);
|
||||
|
||||
/*
|
||||
* ==============================================================
|
||||
*
|
||||
|
|
|
@ -157,16 +157,6 @@ byte COM_BlockSequenceCRCByte (byte *base, int length, int sequence)
|
|||
return r;
|
||||
}
|
||||
|
||||
float frand(void)
|
||||
{
|
||||
return (rand()&32767)* (1.0/32767);
|
||||
}
|
||||
|
||||
float crand(void)
|
||||
{
|
||||
return (rand()&32767)* (2.0/32767) - 1;
|
||||
}
|
||||
|
||||
#ifndef DEDICATED_ONLY
|
||||
void Key_Init (void);
|
||||
void SCR_EndLoadingPlaque (void);
|
||||
|
|
|
@ -156,6 +156,9 @@ void CM_ClipBoxToBrush (vec3_t mins, vec3_t maxs, vec3_t p1, vec3_t p2,
|
|||
if (enterfrac < 0)
|
||||
enterfrac = 0;
|
||||
|
||||
if (clipplane == NULL)
|
||||
Com_Error(ERR_FATAL, "clipplane was NULL!\n");
|
||||
|
||||
trace->fraction = enterfrac;
|
||||
trace->plane = *clipplane;
|
||||
trace->surface = &(leadside->surface->c);
|
||||
|
|
|
@ -501,7 +501,7 @@ cmodel_t *CM_InlineModel (char *name)
|
|||
if (!name || name[0] != '*')
|
||||
Com_Error (ERR_DROP, "CM_InlineModel: bad name");
|
||||
|
||||
num = atoi (name+1);
|
||||
num = (int)strtol(name+1, (char **)NULL, 10);
|
||||
|
||||
if (num < 1 || num >= numcmodels)
|
||||
Com_Error (ERR_DROP, "CM_InlineModel: bad number");
|
||||
|
|
97
src/common/shared/rand.c
Normal file
97
src/common/shared/rand.c
Normal file
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* KISS PRNG (c) 2011 Shinobu
|
||||
*
|
||||
* This file was optained from zuttobenkyou.wordpress.com
|
||||
* and modified by the Yamagi Quake II developers.
|
||||
*
|
||||
* LICENSE: Public domain
|
||||
*
|
||||
* =======================================================================
|
||||
*
|
||||
* KISS PRNG, as devised by Dr. George Marsaglia
|
||||
*
|
||||
* =======================================================================
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define QSIZE 0x200000
|
||||
#define CNG (cng = 6906969069ULL * cng + 13579)
|
||||
#define XS (xs ^= (xs << 13), xs ^= (xs >> 17), xs ^= (xs << 43))
|
||||
#define KISS (B64MWC() + CNG + XS)
|
||||
|
||||
static uint64_t QARY[QSIZE];
|
||||
static int j;
|
||||
static uint64_t carry;
|
||||
static uint64_t xs;
|
||||
static uint64_t cng;
|
||||
|
||||
uint64_t
|
||||
B64MWC(void)
|
||||
{
|
||||
uint64_t t, x;
|
||||
|
||||
j = (j + 1) & (QSIZE - 1);
|
||||
x = QARY[j];
|
||||
t = (x << 28) + carry;
|
||||
carry = (x >> 36) - (t < x);
|
||||
return QARY[j] = t - x;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate a pseudorandom
|
||||
* integer >0.
|
||||
*/
|
||||
int
|
||||
randk(void)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = (int)KISS;
|
||||
r = (r < 0) ? (r * -1) : r;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate a pseudorandom
|
||||
* signed float between
|
||||
* 0 and 1.
|
||||
*/
|
||||
float
|
||||
frandk(void)
|
||||
{
|
||||
return (randk()&32767)* (1.0/32767);
|
||||
}
|
||||
|
||||
/* Generate a pseudorandom
|
||||
* float between -1 and 1.
|
||||
*/
|
||||
float
|
||||
crandk(void)
|
||||
{
|
||||
return (randk()&32767)* (2.0/32767) - 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Seeds the PRNG
|
||||
*/
|
||||
void
|
||||
randk_seed(void)
|
||||
{
|
||||
uint64_t i;
|
||||
|
||||
/* Seed QARY[] with CNG+XS: */
|
||||
for (i = 0; i < QSIZE; i++)
|
||||
{
|
||||
QARY[i] = CNG + XS;
|
||||
}
|
||||
|
||||
/* Run through several rounds
|
||||
to warm up the state */
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
randk();
|
||||
}
|
||||
}
|
||||
|
|
@ -1110,7 +1110,9 @@ Com_sprintf(char *dest, int size, char *fmt, ...)
|
|||
if ((len >= size) || (len == size))
|
||||
{
|
||||
Com_Printf("Com_sprintf: overflow\n");
|
||||
len = size - 1;
|
||||
|
||||
dest = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
bigbuffer[size - 1] = '\0';
|
||||
|
|
|
@ -766,7 +766,7 @@ M_CheckAttack(edict_t *self)
|
|||
if (enemy_range == RANGE_MELEE)
|
||||
{
|
||||
/* don't always melee in easy mode */
|
||||
if ((skill->value == 0) && (rand() & 3))
|
||||
if ((skill->value == 0) && (randk() & 3))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -249,7 +249,7 @@ Cmd_Give_f(edict_t *ent)
|
|||
{
|
||||
if (gi.argc() == 3)
|
||||
{
|
||||
ent->health = atoi(gi.argv(2));
|
||||
ent->health = (int)strtol(gi.argv(2), (char **)NULL, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -399,7 +399,7 @@ Cmd_Give_f(edict_t *ent)
|
|||
{
|
||||
if (gi.argc() == 3)
|
||||
{
|
||||
ent->client->pers.inventory[index] = atoi(gi.argv(2));
|
||||
ent->client->pers.inventory[index] = (int)strtol(gi.argv(2), (char **)NULL, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -965,7 +965,7 @@ Cmd_Wave_f(edict_t *ent)
|
|||
return;
|
||||
}
|
||||
|
||||
i = atoi(gi.argv(1));
|
||||
i = (int)strtol(gi.argv(1), (char **)NULL, 10);
|
||||
|
||||
/* can't wave when ducked */
|
||||
if (ent->client->ps.pmove.pm_flags & PMF_DUCKED)
|
||||
|
|
|
@ -151,7 +151,7 @@ DoRespawn(edict_t *ent)
|
|||
{
|
||||
}
|
||||
|
||||
choice = rand() % count;
|
||||
choice = count ? randk() % count : 0;
|
||||
|
||||
for (count = 0, ent = master; count < choice; ent = ent->chain, count++)
|
||||
{
|
||||
|
@ -1301,13 +1301,13 @@ Drop_Item(edict_t *ent, gitem_t *item)
|
|||
dropped->s.effects = item->world_model_flags;
|
||||
dropped->s.renderfx = RF_GLOW;
|
||||
|
||||
if (rand() > 0.5)
|
||||
if (randk() > 0.5)
|
||||
{
|
||||
dropped->s.angles[1] += rand()*45;
|
||||
dropped->s.angles[1] += randk()*45;
|
||||
}
|
||||
else
|
||||
{
|
||||
dropped->s.angles[1] -= rand()*45;
|
||||
dropped->s.angles[1] -= randk()*45;
|
||||
}
|
||||
|
||||
VectorSet (dropped->mins, -16, -16, -16);
|
||||
|
|
|
@ -312,7 +312,7 @@ ThrowClientHead(edict_t *self, int damage)
|
|||
return;
|
||||
}
|
||||
|
||||
if (rand() & 1)
|
||||
if (randk() & 1)
|
||||
{
|
||||
gibname = "models/objects/gibs/head2/tris.md2";
|
||||
self->s.skinnum = 1; /* second skin is player */
|
||||
|
@ -1681,7 +1681,7 @@ SP_misc_banner(edict_t *ent)
|
|||
ent->movetype = MOVETYPE_NONE;
|
||||
ent->solid = SOLID_NOT;
|
||||
ent->s.modelindex = gi.modelindex("models/objects/banner/tris.md2");
|
||||
ent->s.frame = rand() % 16;
|
||||
ent->s.frame = randk() % 16;
|
||||
gi.linkentity(ent);
|
||||
|
||||
ent->think = misc_banner_think;
|
||||
|
|
|
@ -816,7 +816,7 @@ monster_start(edict_t *self)
|
|||
if (self->monsterinfo.currentmove)
|
||||
{
|
||||
self->s.frame = self->monsterinfo.currentmove->firstframe +
|
||||
(rand() % (self->monsterinfo.currentmove->lastframe -
|
||||
(randk() % (self->monsterinfo.currentmove->lastframe -
|
||||
self->monsterinfo.currentmove->firstframe + 1));
|
||||
}
|
||||
|
||||
|
|
|
@ -400,13 +400,13 @@ ED_ParseField(const char *key, const char *value, edict_t *ent)
|
|||
((float *)(b + f->ofs))[2] = vec[2];
|
||||
break;
|
||||
case F_INT:
|
||||
*(int *)(b + f->ofs) = atoi(value);
|
||||
*(int *)(b + f->ofs) = (int)strtol(value, (char **)NULL, 10);
|
||||
break;
|
||||
case F_FLOAT:
|
||||
*(float *)(b + f->ofs) = atof(value);
|
||||
*(float *)(b + f->ofs) = strtod(value, (char **)NULL);
|
||||
break;
|
||||
case F_ANGLEHACK:
|
||||
v = atof(value);
|
||||
v = strtod(value, (char **)NULL);
|
||||
((float *)(b + f->ofs))[0] = 0;
|
||||
((float *)(b + f->ofs))[1] = v;
|
||||
((float *)(b + f->ofs))[2] = 0;
|
||||
|
|
|
@ -115,7 +115,7 @@ StringToFilter(char *s, ipfilter_t *f)
|
|||
}
|
||||
|
||||
num[j] = 0;
|
||||
b[i] = atoi(num);
|
||||
b[i] = (int)strtol(num, (char **)NULL, 10);
|
||||
|
||||
if (b[i] != 0)
|
||||
{
|
||||
|
|
|
@ -785,7 +785,7 @@ SP_trigger_gravity(edict_t *self)
|
|||
}
|
||||
|
||||
InitTrigger(self);
|
||||
self->gravity = atoi(st.gravity);
|
||||
self->gravity = (int)strtol(st.gravity, (char **)NULL, 10);
|
||||
self->touch = trigger_gravity_touch;
|
||||
}
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ G_PickTarget(char *targetname)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
return choice[rand() % num_choices];
|
||||
return choice[randk() % num_choices];
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -779,7 +779,7 @@ rocket_touch(edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf)
|
|||
if ((surf) && !(surf->flags &
|
||||
(SURF_WARP | SURF_TRANS33 | SURF_TRANS66 | SURF_FLOWING)))
|
||||
{
|
||||
n = rand() % 5;
|
||||
n = randk() % 5;
|
||||
|
||||
while (n--)
|
||||
{
|
||||
|
|
|
@ -487,7 +487,7 @@ extern edict_t *g_edicts;
|
|||
#define LLOFS(x) (size_t)&(((level_locals_t *)NULL)->x)
|
||||
#define CLOFS(x) (size_t)&(((gclient_t *)NULL)->x)
|
||||
|
||||
#define random() ((rand() & 0x7fff) / ((float)0x7fff))
|
||||
#define random() ((randk() & 0x7fff) / ((float)0x7fff))
|
||||
#define crandom() (2.0 * (random() - 0.5))
|
||||
|
||||
extern cvar_t *maxentities;
|
||||
|
|
|
@ -215,7 +215,7 @@ berserk_attack_spike(edict_t *self)
|
|||
return;
|
||||
}
|
||||
|
||||
fire_hit(self, aim, (15 + (rand() % 6)), 400); /* Faster attack -- upwards and backwards */
|
||||
fire_hit(self, aim, (15 + (randk() % 6)), 400); /* Faster attack -- upwards and backwards */
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -259,7 +259,7 @@ berserk_attack_club(edict_t *self)
|
|||
}
|
||||
|
||||
VectorSet(aim, MELEE_DISTANCE, self->mins[0], -4);
|
||||
fire_hit(self, aim, (5 + (rand() % 6)), 400); /* Slower attack */
|
||||
fire_hit(self, aim, (5 + (randk() % 6)), 400); /* Slower attack */
|
||||
}
|
||||
|
||||
mframe_t berserk_frames_attack_club[] = {
|
||||
|
@ -325,7 +325,7 @@ berserk_melee(edict_t *self)
|
|||
return;
|
||||
}
|
||||
|
||||
if ((rand() % 2) == 0)
|
||||
if ((randk() % 2) == 0)
|
||||
{
|
||||
self->monsterinfo.currentmove = &berserk_move_attack_spike;
|
||||
}
|
||||
|
|
|
@ -774,7 +774,6 @@ Jorg_CheckAttack(edict_t *self)
|
|||
vec3_t temp;
|
||||
float chance;
|
||||
trace_t tr;
|
||||
qboolean enemy_infront;
|
||||
int enemy_range;
|
||||
float enemy_yaw;
|
||||
|
||||
|
@ -802,7 +801,6 @@ Jorg_CheckAttack(edict_t *self)
|
|||
}
|
||||
}
|
||||
|
||||
enemy_infront = infront(self, self->enemy);
|
||||
enemy_range = range(self, self->enemy);
|
||||
VectorSubtract(self->enemy->s.origin, self->s.origin, temp);
|
||||
enemy_yaw = vectoyaw(temp);
|
||||
|
|
|
@ -457,7 +457,7 @@ brain_hit_right(edict_t *self)
|
|||
|
||||
VectorSet(aim, MELEE_DISTANCE, self->maxs[0], 8);
|
||||
|
||||
if (fire_hit(self, aim, (15 + (rand() % 5)), 40))
|
||||
if (fire_hit(self, aim, (15 + (randk() % 5)), 40))
|
||||
{
|
||||
gi.sound(self, CHAN_WEAPON, sound_melee3, 1, ATTN_NORM, 0);
|
||||
}
|
||||
|
@ -486,7 +486,7 @@ brain_hit_left(edict_t *self)
|
|||
|
||||
VectorSet(aim, MELEE_DISTANCE, self->mins[0], 8);
|
||||
|
||||
if (fire_hit(self, aim, (15 + (rand() % 5)), 40))
|
||||
if (fire_hit(self, aim, (15 + (randk() % 5)), 40))
|
||||
{
|
||||
gi.sound(self, CHAN_WEAPON, sound_melee3, 1, ATTN_NORM, 0);
|
||||
}
|
||||
|
@ -546,7 +546,7 @@ brain_tentacle_attack(edict_t *self)
|
|||
|
||||
VectorSet(aim, MELEE_DISTANCE, 0, 8);
|
||||
|
||||
if (fire_hit(self, aim, (10 + (rand() % 5)), -600) && (skill->value > 0))
|
||||
if (fire_hit(self, aim, (10 + (randk() % 5)), -600) && (skill->value > 0))
|
||||
{
|
||||
self->spawnflags |= 65536;
|
||||
}
|
||||
|
|
|
@ -518,7 +518,7 @@ chick_die(edict_t *self, edict_t *inflictor /* unused */,
|
|||
self->deadflag = DEAD_DEAD;
|
||||
self->takedamage = DAMAGE_YES;
|
||||
|
||||
n = rand() % 2;
|
||||
n = randk() % 2;
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
|
@ -635,7 +635,7 @@ ChickSlash(edict_t *self)
|
|||
|
||||
VectorSet(aim, MELEE_DISTANCE, self->mins[0], 10);
|
||||
gi.sound(self, CHAN_WEAPON, sound_melee_swing, 1, ATTN_NORM, 0);
|
||||
fire_hit(self, aim, (10 + (rand() % 6)), 100);
|
||||
fire_hit(self, aim, (10 + (randk() % 6)), 100);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -339,7 +339,7 @@ flipper_pain(edict_t *self, edict_t *other /* unused */,
|
|||
return; /* no pain anims in nightmare */
|
||||
}
|
||||
|
||||
n = (rand() + 1) % 2;
|
||||
n = (randk() + 1) % 2;
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
|
|
|
@ -633,7 +633,7 @@ floater_wham(edict_t *self)
|
|||
static vec3_t aim = {MELEE_DISTANCE, 0, 0};
|
||||
|
||||
gi.sound(self, CHAN_WEAPON, sound_attack3, 1, ATTN_NORM, 0);
|
||||
fire_hit(self, aim, 5 + rand() % 6, -50);
|
||||
fire_hit(self, aim, 5 + randk() % 6, -50);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -666,7 +666,7 @@ floater_zap(edict_t *self)
|
|||
gi.multicast(origin, MULTICAST_PVS);
|
||||
|
||||
T_Damage(self->enemy, self, self, dir, self->enemy->s.origin,
|
||||
vec3_origin, 5 + rand() % 6, -10, DAMAGE_ENERGY,
|
||||
vec3_origin, 5 + randk() % 6, -10, DAMAGE_ENERGY,
|
||||
MOD_UNKNOWN);
|
||||
}
|
||||
|
||||
|
@ -727,7 +727,7 @@ floater_pain(edict_t *self, edict_t *other /* unused */,
|
|||
return; /* no pain anims in nightmare */
|
||||
}
|
||||
|
||||
n = (rand() + 1) % 3;
|
||||
n = (randk() + 1) % 3;
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
|
|
|
@ -777,7 +777,7 @@ flyer_pain(edict_t *self, edict_t *other /* unused */,
|
|||
return; /* no pain anims in nightmare */
|
||||
}
|
||||
|
||||
n = rand() % 3;
|
||||
n = randk() % 3;
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
|
|
|
@ -200,7 +200,7 @@ GaldiatorMelee(edict_t *self)
|
|||
|
||||
VectorSet(aim, MELEE_DISTANCE, self->mins[0], -4);
|
||||
|
||||
if (fire_hit(self, aim, (20 + (rand() % 5)), 300))
|
||||
if (fire_hit(self, aim, (20 + (randk() % 5)), 300))
|
||||
{
|
||||
gi.sound(self, CHAN_AUTO, sound_cleaver_hit, 1, ATTN_NORM, 0);
|
||||
}
|
||||
|
|
|
@ -398,7 +398,7 @@ gunner_pain(edict_t *self, edict_t *other /* unused */,
|
|||
|
||||
self->pain_debounce_time = level.time + 3;
|
||||
|
||||
if (rand() & 1)
|
||||
if (randk() & 1)
|
||||
{
|
||||
gi.sound(self, CHAN_VOICE, sound_pain, 1, ATTN_NORM, 0);
|
||||
}
|
||||
|
|
|
@ -294,7 +294,7 @@ infantry_pain(edict_t *self, edict_t *other /* unused */,
|
|||
return; /* no pain anims in nightmare */
|
||||
}
|
||||
|
||||
n = rand() % 2;
|
||||
n = randk() % 2;
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
|
@ -533,7 +533,7 @@ infantry_die(edict_t *self, edict_t *inflictor /* unused */,
|
|||
self->deadflag = DEAD_DEAD;
|
||||
self->takedamage = DAMAGE_YES;
|
||||
|
||||
n = rand() % 3;
|
||||
n = randk() % 3;
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
|
@ -652,7 +652,7 @@ infantry_cock_gun(edict_t *self)
|
|||
}
|
||||
|
||||
gi.sound(self, CHAN_WEAPON, sound_weapon_cock, 1, ATTN_NORM, 0);
|
||||
n = (rand() & 15) + 3 + 7;
|
||||
n = (randk() & 15) + 3 + 7;
|
||||
self->monsterinfo.pausetime = level.time + n * FRAMETIME;
|
||||
}
|
||||
|
||||
|
@ -725,7 +725,7 @@ infantry_smack(edict_t *self)
|
|||
|
||||
VectorSet(aim, MELEE_DISTANCE, 0, 0);
|
||||
|
||||
if (fire_hit(self, aim, (5 + (rand() % 5)), 50))
|
||||
if (fire_hit(self, aim, (5 + (randk() % 5)), 50))
|
||||
{
|
||||
gi.sound(self, CHAN_WEAPON, sound_punch_hit, 1, ATTN_NORM, 0);
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ insane_scream(edict_t *self)
|
|||
return;
|
||||
}
|
||||
|
||||
gi.sound(self, CHAN_VOICE, sound_scream[rand() % 8], 1, ATTN_IDLE, 0);
|
||||
gi.sound(self, CHAN_VOICE, sound_scream[randk() % 8], 1, ATTN_IDLE, 0);
|
||||
}
|
||||
|
||||
void insane_stand(edict_t *self);
|
||||
|
@ -660,7 +660,7 @@ insane_pain(edict_t *self, edict_t *other /* unused */,
|
|||
|
||||
self->pain_debounce_time = level.time + 3;
|
||||
|
||||
r = 1 + (rand() & 1);
|
||||
r = 1 + (randk() & 1);
|
||||
|
||||
if (self->health < 25)
|
||||
{
|
||||
|
@ -857,7 +857,7 @@ insane_die(edict_t *self, edict_t *inflictor /* unused */,
|
|||
}
|
||||
|
||||
gi.sound(self, CHAN_VOICE, gi.soundindex(va("player/male/death%i.wav",
|
||||
(rand() % 4) + 1)), 1, ATTN_IDLE, 0);
|
||||
(randk() % 4) + 1)), 1, ATTN_IDLE, 0);
|
||||
|
||||
self->deadflag = DEAD_DEAD;
|
||||
self->takedamage = DAMAGE_YES;
|
||||
|
@ -955,6 +955,6 @@ SP_misc_insane(edict_t *self)
|
|||
else
|
||||
{
|
||||
walkmonster_start(self);
|
||||
self->s.skinnum = rand() % 3;
|
||||
self->s.skinnum = randk() % 3;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -556,7 +556,7 @@ SV_NewChaseDir(edict_t *actor, edict_t *enemy, float dist)
|
|||
}
|
||||
|
||||
/* try other directions */
|
||||
if (((rand() & 3) & 1) || (abs(deltay) > abs(deltax)))
|
||||
if (((randk() & 3) & 1) || (abs(deltay) > abs(deltax)))
|
||||
{
|
||||
tdir = d[1];
|
||||
d[1] = d[2];
|
||||
|
@ -581,7 +581,7 @@ SV_NewChaseDir(edict_t *actor, edict_t *enemy, float dist)
|
|||
return;
|
||||
}
|
||||
|
||||
if (rand() & 1) /* randomly determine direction of search */
|
||||
if (randk() & 1) /* randomly determine direction of search */
|
||||
{
|
||||
for (tdir = 0; tdir <= 315; tdir += 45)
|
||||
{
|
||||
|
@ -668,7 +668,7 @@ M_MoveToGoal(edict_t *ent, float dist)
|
|||
}
|
||||
|
||||
/* bump around... */
|
||||
if (((rand() & 3) == 1) || !SV_StepDirection(ent, ent->ideal_yaw, dist))
|
||||
if (((randk() & 3) == 1) || !SV_StepDirection(ent, ent->ideal_yaw, dist))
|
||||
{
|
||||
if (ent->inuse)
|
||||
{
|
||||
|
|
|
@ -51,7 +51,7 @@ mutant_step(edict_t *self)
|
|||
return;
|
||||
}
|
||||
|
||||
n = (rand() + 1) % 3;
|
||||
n = (randk() + 1) % 3;
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
|
@ -331,7 +331,7 @@ mutant_hit_left(edict_t *self)
|
|||
|
||||
VectorSet(aim, MELEE_DISTANCE, self->mins[0], 8);
|
||||
|
||||
if (fire_hit(self, aim, (10 + (rand() % 5)), 100))
|
||||
if (fire_hit(self, aim, (10 + (randk() % 5)), 100))
|
||||
{
|
||||
gi.sound(self, CHAN_WEAPON, sound_hit, 1, ATTN_NORM, 0);
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ mutant_hit_right(edict_t *self)
|
|||
|
||||
VectorSet(aim, MELEE_DISTANCE, self->maxs[0], 8);
|
||||
|
||||
if (fire_hit(self, aim, (10 + (rand() % 5)), 100))
|
||||
if (fire_hit(self, aim, (10 + (randk() % 5)), 100))
|
||||
{
|
||||
gi.sound(self, CHAN_WEAPON, sound_hit2, 1, ATTN_NORM, 0);
|
||||
}
|
||||
|
|
|
@ -614,7 +614,7 @@ soldier_fire(edict_t *self, int flash_number)
|
|||
{
|
||||
if (!(self->monsterinfo.aiflags & AI_HOLD_FRAME))
|
||||
{
|
||||
self->monsterinfo.pausetime = level.time + (3 + rand() % 8) * FRAMETIME;
|
||||
self->monsterinfo.pausetime = level.time + (3 + randk() % 8) * FRAMETIME;
|
||||
}
|
||||
|
||||
monster_fire_bullet(self, start, aim, 2, 4,
|
||||
|
@ -1514,7 +1514,7 @@ soldier_die(edict_t *self, edict_t *inflictor /* unused */,
|
|||
return;
|
||||
}
|
||||
|
||||
n = rand() % 5;
|
||||
n = randk() % 5;
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
|
|
|
@ -781,7 +781,7 @@ BossExplode(edict_t *self)
|
|||
|
||||
self->think = BossExplode;
|
||||
VectorCopy(self->s.origin, org);
|
||||
org[2] += 24 + (rand() & 15);
|
||||
org[2] += 24 + (randk() & 15);
|
||||
|
||||
switch (self->count++)
|
||||
{
|
||||
|
|
|
@ -959,7 +959,7 @@ player_die(edict_t *self, edict_t *inflictor, edict_t *attacker,
|
|||
}
|
||||
|
||||
gi.sound(self, CHAN_VOICE, gi.soundindex(va("*death%i.wav",
|
||||
(rand() % 4) + 1)), 1, ATTN_NORM, 0);
|
||||
(randk() % 4) + 1)), 1, ATTN_NORM, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1174,7 +1174,7 @@ SelectRandomDeathmatchSpawnPoint(void)
|
|||
}
|
||||
}
|
||||
|
||||
selection = rand() % count;
|
||||
selection = randk() % count;
|
||||
|
||||
spot = NULL;
|
||||
|
||||
|
@ -1742,7 +1742,7 @@ PutClientInServer(edict_t *ent)
|
|||
}
|
||||
else
|
||||
{
|
||||
client->ps.fov = atoi(Info_ValueForKey(client->pers.userinfo, "fov"));
|
||||
client->ps.fov = (int)strtol(Info_ValueForKey(client->pers.userinfo, "fov"), (char **)NULL, 10);
|
||||
|
||||
if (client->ps.fov < 1)
|
||||
{
|
||||
|
@ -1978,7 +1978,7 @@ ClientUserinfoChanged(edict_t *ent, char *userinfo)
|
|||
}
|
||||
else
|
||||
{
|
||||
ent->client->ps.fov = atoi(Info_ValueForKey(userinfo, "fov"));
|
||||
ent->client->ps.fov = (int)strtol(Info_ValueForKey(userinfo, "fov"), (char **)NULL, 10);
|
||||
|
||||
if (ent->client->ps.fov < 1)
|
||||
{
|
||||
|
@ -1995,7 +1995,7 @@ ClientUserinfoChanged(edict_t *ent, char *userinfo)
|
|||
|
||||
if (strlen(s))
|
||||
{
|
||||
ent->client->pers.hand = atoi(s);
|
||||
ent->client->pers.hand = (int)strtol(s, (char **)NULL, 10);
|
||||
}
|
||||
|
||||
/* save off the userinfo in case we want to check something later */
|
||||
|
|
|
@ -162,7 +162,7 @@ BeginIntermission(edict_t *targ)
|
|||
else
|
||||
{
|
||||
/* chose one of four spots */
|
||||
i = rand() & 3;
|
||||
i = randk() & 3;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
|
@ -461,7 +461,7 @@ void
|
|||
G_SetStats(edict_t *ent)
|
||||
{
|
||||
gitem_t *item;
|
||||
int index, cells;
|
||||
int index, cells = 0;
|
||||
int power_armor_type;
|
||||
|
||||
if (!ent)
|
||||
|
@ -469,8 +469,6 @@ G_SetStats(edict_t *ent)
|
|||
return;
|
||||
}
|
||||
|
||||
cells = 0;
|
||||
|
||||
/* health */
|
||||
ent->client->ps.stats[STAT_HEALTH_ICON] = level.pic_health;
|
||||
ent->client->ps.stats[STAT_HEALTH] = ent->health;
|
||||
|
@ -489,8 +487,6 @@ G_SetStats(edict_t *ent)
|
|||
ent->client->pers.inventory[ent->client->ammo_index];
|
||||
}
|
||||
|
||||
cells = 0;
|
||||
|
||||
/* armor */
|
||||
power_armor_type = PowerArmorType(ent);
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ P_DamageFeedback(edict_t *player)
|
|||
!(player->flags & FL_GODMODE) &&
|
||||
(client->invincible_framenum <= level.framenum))
|
||||
{
|
||||
r = 1 + (rand() & 1);
|
||||
r = 1 + (randk() & 1);
|
||||
player->pain_debounce_time = level.time + 0.7;
|
||||
|
||||
if (player->health < 25)
|
||||
|
@ -875,7 +875,7 @@ P_WorldEffects(void)
|
|||
gi.sound(current_player, CHAN_VOICE,
|
||||
gi.soundindex("player/drown1.wav"), 1, ATTN_NORM, 0);
|
||||
}
|
||||
else if (rand() & 1)
|
||||
else if (randk() & 1)
|
||||
{
|
||||
gi.sound(current_player, CHAN_VOICE,
|
||||
gi.soundindex("*gurp1.wav"), 1, ATTN_NORM, 0);
|
||||
|
@ -910,7 +910,7 @@ P_WorldEffects(void)
|
|||
(current_player->pain_debounce_time <= level.time) &&
|
||||
(current_client->invincible_framenum < level.framenum))
|
||||
{
|
||||
if (rand() & 1)
|
||||
if (randk() & 1)
|
||||
{
|
||||
gi.sound(current_player, CHAN_VOICE,
|
||||
gi.soundindex("player/burn1.wav"), 1, ATTN_NORM, 0);
|
||||
|
|
|
@ -586,7 +586,7 @@ Weapon_Generic(edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST,
|
|||
{
|
||||
if (ent->client->ps.gunframe == pause_frames[n])
|
||||
{
|
||||
if (rand() & 15)
|
||||
if (randk() & 15)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -749,7 +749,7 @@ Weapon_Grenade(edict_t *ent)
|
|||
(ent->client->ps.gunframe == 39) ||
|
||||
(ent->client->ps.gunframe == 48))
|
||||
{
|
||||
if (rand() & 15)
|
||||
if (randk() & 15)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ Mod_ForName ( char *name, qboolean crash )
|
|||
/* inline models are grabbed only from worldmodel */
|
||||
if ( name [ 0 ] == '*' )
|
||||
{
|
||||
i = atoi( name + 1 );
|
||||
i = (int)strtol( name + 1, (char **)NULL, 10 );
|
||||
|
||||
if ( ( i < 1 ) || !r_worldmodel || ( i >= r_worldmodel->numsubmodels ) )
|
||||
{
|
||||
|
|
|
@ -1208,10 +1208,10 @@ R_DrawWorld ( void )
|
|||
|
||||
R_DrawTextureChains();
|
||||
R_BlendLightmaps();
|
||||
|
||||
R_DrawSkyBox();
|
||||
|
||||
R_DrawTriangleOutlines();
|
||||
|
||||
currententity = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -149,7 +149,7 @@ CDAudio_RandomPlay ( void )
|
|||
{
|
||||
do
|
||||
{
|
||||
f = ( (float) rand() ) / ( (float) RAND_MAX + 1.0 );
|
||||
f = ( (float) randk() ) / ( (float) RAND_MAX + 1.0 );
|
||||
track = (int) ( cd_id->numtracks * f );
|
||||
}
|
||||
while ( !track_bools [ track ] );
|
||||
|
@ -441,13 +441,13 @@ CD_f ()
|
|||
|
||||
if ( !Q_strcasecmp( command, "play" ) )
|
||||
{
|
||||
CDAudio_Play( (byte) atoi( Cmd_Argv( 2 ) ), false );
|
||||
CDAudio_Play( (byte) (int)strtol( Cmd_Argv( 2 ), (char **)NULL, 10 ), false );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !Q_strcasecmp( command, "loop" ) )
|
||||
{
|
||||
CDAudio_Play( (byte) atoi( Cmd_Argv( 2 ) ), true );
|
||||
CDAudio_Play( (byte) (int)strtol( Cmd_Argv( 2 ), (char **)NULL, 10 ), true );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ SV_SetPlayer ( void )
|
|||
/* numeric values are just slot numbers */
|
||||
if ( ( s [ 0 ] >= '0' ) && ( s [ 0 ] <= '9' ) )
|
||||
{
|
||||
idnum = atoi( Cmd_Argv( 1 ) );
|
||||
idnum = (int)strtol( Cmd_Argv( 1 ), (char **)NULL, 10 );
|
||||
|
||||
if ( ( idnum < 0 ) || ( idnum >= maxclients->value ) )
|
||||
{
|
||||
|
|
|
@ -64,7 +64,7 @@ SVC_Info ( void )
|
|||
return; /* ignore in single player */
|
||||
}
|
||||
|
||||
version = atoi( Cmd_Argv( 1 ) );
|
||||
version = (int)strtol( Cmd_Argv( 1 ), (char **)NULL, 10 );
|
||||
|
||||
if ( version != PROTOCOL_VERSION )
|
||||
{
|
||||
|
@ -132,7 +132,7 @@ SVC_GetChallenge ( void )
|
|||
if ( i == MAX_CHALLENGES )
|
||||
{
|
||||
/* overwrite the oldest */
|
||||
svs.challenges [ oldest ].challenge = rand() & 0x7fff;
|
||||
svs.challenges [ oldest ].challenge = randk() & 0x7fff;
|
||||
svs.challenges [ oldest ].adr = net_from;
|
||||
svs.challenges [ oldest ].time = curtime;
|
||||
i = oldest;
|
||||
|
@ -163,7 +163,7 @@ SVC_DirectConnect ( void )
|
|||
|
||||
Com_DPrintf( "SVC_DirectConnect ()\n" );
|
||||
|
||||
version = atoi( Cmd_Argv( 1 ) );
|
||||
version = (int)strtol( Cmd_Argv( 1 ), (char **)NULL, 10 );
|
||||
|
||||
if ( version != PROTOCOL_VERSION )
|
||||
{
|
||||
|
@ -172,9 +172,9 @@ SVC_DirectConnect ( void )
|
|||
return;
|
||||
}
|
||||
|
||||
qport = atoi( Cmd_Argv( 2 ) );
|
||||
qport = (int)strtol( Cmd_Argv( 2 ), (char **)NULL, 10 );
|
||||
|
||||
challenge = atoi( Cmd_Argv( 3 ) );
|
||||
challenge = (int)strtol( Cmd_Argv( 3 ), (char **)NULL, 10 );
|
||||
|
||||
strncpy( userinfo, Cmd_Argv( 4 ), sizeof ( userinfo ) - 1 );
|
||||
userinfo [ sizeof ( userinfo ) - 1 ] = 0;
|
||||
|
|
|
@ -278,7 +278,7 @@ SV_SpawnServer ( char *server, char *spawnpoint, server_state_t serverstate, qbo
|
|||
ge->RunFrame();
|
||||
|
||||
/* verify game didn't clobber important stuff */
|
||||
if ( (int) checksum != atoi( sv.configstrings [ CS_MAPCHECKSUM ] ) )
|
||||
if ( (int) checksum != (int)strtol( sv.configstrings [ CS_MAPCHECKSUM ], (char **)NULL, 10 ) )
|
||||
{
|
||||
Com_Error( ERR_DROP, "Game DLL corrupted server configstrings" );
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ SV_InitGame ( void )
|
|||
Cvar_FullSet( "maxclients", "1", CVAR_SERVERINFO | CVAR_LATCH );
|
||||
}
|
||||
|
||||
svs.spawncount = rand();
|
||||
svs.spawncount = randk();
|
||||
svs.clients = Z_Malloc( sizeof ( client_t ) * maxclients->value );
|
||||
svs.num_client_entities = maxclients->value * UPDATE_BACKUP * 64;
|
||||
svs.client_entities = Z_Malloc( sizeof ( entity_state_t ) * svs.num_client_entities );
|
||||
|
|
|
@ -391,7 +391,7 @@ SV_Frame ( int msec )
|
|||
svs.realtime += msec;
|
||||
|
||||
/* keep the random time dependent */
|
||||
rand();
|
||||
randk();
|
||||
|
||||
/* check timeouts */
|
||||
SV_CheckTimeouts();
|
||||
|
@ -546,7 +546,7 @@ SV_UserinfoChanged ( client_t *cl )
|
|||
|
||||
if ( strlen( val ) )
|
||||
{
|
||||
i = atoi( val );
|
||||
i = (int)strtol( val, (char **)NULL, 10 );
|
||||
cl->rate = i;
|
||||
|
||||
if ( cl->rate < 100 )
|
||||
|
@ -569,7 +569,7 @@ SV_UserinfoChanged ( client_t *cl )
|
|||
|
||||
if ( strlen( val ) )
|
||||
{
|
||||
cl->messagelevel = atoi( val );
|
||||
cl->messagelevel = (int)strtol( val, (char **)NULL, 10 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -124,14 +124,14 @@ SV_Configstrings_f ( void )
|
|||
}
|
||||
|
||||
/* handle the case of a level changing while a client was connecting */
|
||||
if ( atoi( Cmd_Argv( 1 ) ) != svs.spawncount )
|
||||
if ( (int)strtol( Cmd_Argv( 1 ), (char **)NULL, 10 ) != svs.spawncount )
|
||||
{
|
||||
Com_Printf( "SV_Configstrings_f from different level\n" );
|
||||
SV_New_f();
|
||||
return;
|
||||
}
|
||||
|
||||
start = atoi( Cmd_Argv( 2 ) );
|
||||
start = (int)strtol( Cmd_Argv( 2 ), (char **)NULL, 10 );
|
||||
|
||||
/* write a packet full of data */
|
||||
while ( sv_client->netchan.message.cursize < MAX_MSGLEN / 2 && start < MAX_CONFIGSTRINGS )
|
||||
|
@ -175,14 +175,14 @@ SV_Baselines_f ( void )
|
|||
}
|
||||
|
||||
/* handle the case of a level changing while a client was connecting */
|
||||
if ( atoi( Cmd_Argv( 1 ) ) != svs.spawncount )
|
||||
if ( (int)strtol( Cmd_Argv( 1 ), (char **)NULL, 10 ) != svs.spawncount )
|
||||
{
|
||||
Com_Printf( "SV_Baselines_f from different level\n" );
|
||||
SV_New_f();
|
||||
return;
|
||||
}
|
||||
|
||||
start = atoi( Cmd_Argv( 2 ) );
|
||||
start = (int)strtol( Cmd_Argv( 2 ), (char **)NULL, 10 );
|
||||
|
||||
memset( &nullstate, 0, sizeof ( nullstate ) );
|
||||
|
||||
|
@ -220,7 +220,7 @@ SV_Begin_f ( void )
|
|||
Com_DPrintf( "Begin() from %s\n", sv_client->name );
|
||||
|
||||
/* handle the case of a level changing while a client was connecting */
|
||||
if ( atoi( Cmd_Argv( 1 ) ) != svs.spawncount )
|
||||
if ( (int)strtol( Cmd_Argv( 1 ), (char **)NULL, 10 ) != svs.spawncount )
|
||||
{
|
||||
Com_Printf( "SV_Begin_f from different level\n" );
|
||||
SV_New_f();
|
||||
|
@ -295,7 +295,7 @@ SV_BeginDownload_f ( void )
|
|||
|
||||
if ( Cmd_Argc() > 2 )
|
||||
{
|
||||
offset = atoi( Cmd_Argv( 2 ) ); /* downloaded offset */
|
||||
offset = (int)strtol( Cmd_Argv( 2 ), (char **)NULL, 10 ); /* downloaded offset */
|
||||
}
|
||||
|
||||
/* hacked by zoid to allow more conrol over download
|
||||
|
@ -407,7 +407,7 @@ SV_Nextserver ( void )
|
|||
void
|
||||
SV_Nextserver_f ( void )
|
||||
{
|
||||
if ( atoi( Cmd_Argv( 1 ) ) != svs.spawncount )
|
||||
if ( (int)strtol( Cmd_Argv( 1 ), (char **)NULL, 10 ) != svs.spawncount )
|
||||
{
|
||||
Com_DPrintf( "Nextserver() from wrong level, from %s\n", sv_client->name );
|
||||
return; /* leftover from last server */
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "header/unix.h"
|
||||
|
||||
cvar_t *nostdout;
|
||||
uid_t saved_euid;
|
||||
|
||||
int
|
||||
main ( int argc, char **argv )
|
||||
|
@ -45,9 +44,28 @@ main ( int argc, char **argv )
|
|||
/* register signal handler */
|
||||
registerHandler();
|
||||
|
||||
/* go back to real user for config loads */
|
||||
saved_euid = geteuid();
|
||||
seteuid( getuid() );
|
||||
/* Prevent running Quake II as root. Only very mad
|
||||
minded or stupid people even think about it. :) */
|
||||
if (getuid() == 0)
|
||||
{
|
||||
printf("Quake II shouldn't be run as root! Backing out to save your ass. If\n");
|
||||
printf("you really know what you're doing, edit src/unix/main.c and remove\n");
|
||||
printf("this check. But don't complain if Quake II eats your dog afterwards!\n");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enforce the real UID to
|
||||
prevent setuid crap */
|
||||
if (getuid() != geteuid())
|
||||
{
|
||||
printf("The effective UID is not the real UID! Your binary is probably marked\n");
|
||||
printf("'setuid'. That is not good idea, please fix it :) If you really know\n");
|
||||
printf("what you're doin edit src/unix/main.c and remove this check. Don't\n");
|
||||
printf("complain if Quake II eats your dog afterwards!\n");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* enforce C locale */
|
||||
setenv("LC_ALL", "C", 1);
|
||||
|
@ -79,7 +97,11 @@ main ( int argc, char **argv )
|
|||
|
||||
printf("Platform: %s\n", BUILDSTRING);
|
||||
printf("Architecture: %s\n", CPUSTRING);
|
||||
|
||||
/* Seed PRNG */
|
||||
randk_seed();
|
||||
|
||||
/* Initialze the game */
|
||||
Qcommon_Init( argc, argv );
|
||||
|
||||
fcntl( 0, F_SETFL, fcntl( 0, F_GETFL, 0 ) | FNDELAY );
|
||||
|
|
|
@ -215,7 +215,6 @@ VID_LoadRefresh ( char *name )
|
|||
char fn [ MAX_OSPATH ];
|
||||
char *path;
|
||||
struct stat st;
|
||||
extern uid_t saved_euid;
|
||||
|
||||
if ( reflib_active )
|
||||
{
|
||||
|
@ -237,11 +236,7 @@ VID_LoadRefresh ( char *name )
|
|||
|
||||
Com_Printf( "----- refresher initialization -----\n");
|
||||
|
||||
/* regain root */
|
||||
seteuid( saved_euid );
|
||||
|
||||
path = Cvar_Get( "basedir", ".", CVAR_NOSET )->string;
|
||||
|
||||
snprintf( fn, MAX_OSPATH, "%s/%s", path, name );
|
||||
|
||||
if ( stat( fn, &st ) == -1 )
|
||||
|
@ -301,7 +296,7 @@ VID_LoadRefresh ( char *name )
|
|||
( ( IN_BackendMouseButtons_fp = dlsym( reflib_library, "IN_BackendMouseButtons" ) ) == NULL ) ||
|
||||
( ( IN_BackendMove_fp = dlsym( reflib_library, "IN_BackendMove" ) ) == NULL ) )
|
||||
{
|
||||
Sys_Error( "No input backend init functions in REF.\n" );
|
||||
Com_Error( ERR_FATAL, "No input backend init functions in REF.\n" );
|
||||
}
|
||||
|
||||
if ( IN_BackendInit_fp )
|
||||
|
@ -321,16 +316,12 @@ VID_LoadRefresh ( char *name )
|
|||
( ( IN_Update_fp = dlsym( reflib_library, "IN_Update" ) ) == NULL ) ||
|
||||
( ( IN_Close_fp = dlsym( reflib_library, "IN_Close" ) ) == NULL ) )
|
||||
{
|
||||
Sys_Error( "No keyboard input functions in REF.\n" );
|
||||
Com_Error( ERR_FATAL, "No keyboard input functions in REF.\n" );
|
||||
}
|
||||
|
||||
IN_KeyboardInit_fp( Do_Key_Event );
|
||||
Key_ClearStates();
|
||||
|
||||
/* give up root now */
|
||||
setreuid( getuid(), getuid() );
|
||||
setegid( getgid() );
|
||||
|
||||
Com_Printf( "------------------------------------\n\n" );
|
||||
reflib_active = true;
|
||||
return ( true );
|
||||
|
|
Loading…
Reference in a new issue