diff --git a/.gitignore b/.gitignore index 1f9d107c..c4f9a754 100644 --- a/.gitignore +++ b/.gitignore @@ -58,4 +58,5 @@ usrhooks.obj v_video.obj w_wad.obj wi_stuff.obj -z_zone.obj \ No newline at end of file +z_zone.obj +i_random.obj \ No newline at end of file diff --git a/I_RANDOM.OBJ b/I_RANDOM.OBJ new file mode 100644 index 00000000..836de691 Binary files /dev/null and b/I_RANDOM.OBJ differ diff --git a/d_main.c b/d_main.c index 28ef4c12..8033860a 100644 --- a/d_main.c +++ b/d_main.c @@ -38,6 +38,7 @@ #include "f_finale.h" #include "f_wipe.h" +#include "i_random.h" #include "m_misc.h" #include "m_menu.h" diff --git a/doomstat.h b/doomstat.h index 4e413552..f69091fb 100644 --- a/doomstat.h +++ b/doomstat.h @@ -179,9 +179,6 @@ extern int maxammo[NUMAMMO]; // File handling stuff. extern char basedefault[1024]; -// if true, load all graphics at level load -extern boolean precache; - // wipegamestate can be set to -1 // to force a wipe on the next draw extern gamestate_t wipegamestate; @@ -207,7 +204,6 @@ extern doomcom_t *doomcom; extern doomdata_t *netbuffer; extern ticcmd_t localcmds[BACKUPTICS]; -extern int rndindex; extern int maketic; extern int nettics; diff --git a/f_wipe.c b/f_wipe.c index a6afc342..66de8cbe 100644 --- a/f_wipe.c +++ b/f_wipe.c @@ -16,6 +16,10 @@ // Mission begin melt/wipe screen special effect. // +#include "doomstat.h" + +#include "i_random.h" + #include "z_zone.h" #include "i_system.h" #include "v_video.h" @@ -132,10 +136,10 @@ int wipe_initMelt(int width, // setup initial column positions // (y<0 => not ready to scroll yet) y = (int *)Z_Malloc(width * sizeof(int), PU_STATIC, 0); - y[0] = -(M_Random() % 16); + y[0] = -(M_Random % 16); for (i = 1; i < width; i++) { - r = (M_Random() % 3) - 1; + r = (M_Random % 3) - 1; y[i] = y[i - 1] + r; if (y[i] > 0) y[i] = 0; diff --git a/g_game.c b/g_game.c index b9a7ab87..1f954229 100644 --- a/g_game.c +++ b/g_game.c @@ -111,8 +111,6 @@ byte *demo_p; byte *demoend; boolean singledemo; // quit after playing a demo from cmdline -boolean precache = true; // if true, load all graphics at start - wbstartstruct_t wminfo; // parms for world map / intermission byte *savebuffer; @@ -1025,7 +1023,7 @@ void G_InitNew(skill_t skill, if ((map > 9) && (!commercial)) map = 9; - M_ClearRandom(); + I_ClearRandom(); if (skill == sk_nightmare || respawnparm) respawnmonsters = true; @@ -1212,9 +1210,7 @@ void G_DoPlayDemo(void) *demo_p++; // don't spend a lot of time in loadlevel - precache = false; G_InitNew(skill, episode, map); - precache = true; usergame = false; demoplayback = true; diff --git a/i_random.c b/i_random.c new file mode 100644 index 00000000..156f0426 --- /dev/null +++ b/i_random.c @@ -0,0 +1,30 @@ +#include "i_random.h" + +byte rndtable[256] = { + 0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66, + 74, 21, 211, 47, 80, 242, 154, 27, 205, 128, 161, 89, 77, 36, + 95, 110, 85, 48, 212, 140, 211, 249, 22, 79, 200, 50, 28, 188, + 52, 140, 202, 120, 68, 145, 62, 70, 184, 190, 91, 197, 152, 224, + 149, 104, 25, 178, 252, 182, 202, 182, 141, 197, 4, 81, 181, 242, + 145, 42, 39, 227, 156, 198, 225, 193, 219, 93, 122, 175, 249, 0, + 175, 143, 70, 239, 46, 246, 163, 53, 163, 109, 168, 135, 2, 235, + 25, 92, 20, 145, 138, 77, 69, 166, 78, 176, 173, 212, 166, 113, + 94, 161, 41, 50, 239, 49, 111, 164, 70, 60, 2, 37, 171, 75, + 136, 156, 11, 56, 42, 146, 138, 229, 73, 146, 77, 61, 98, 196, + 135, 106, 63, 197, 195, 86, 96, 203, 113, 101, 170, 247, 181, 113, + 80, 250, 108, 7, 255, 237, 129, 226, 79, 107, 112, 166, 103, 241, + 24, 223, 239, 120, 198, 58, 60, 82, 128, 3, 184, 66, 143, 224, + 145, 224, 81, 206, 163, 45, 63, 90, 168, 114, 59, 33, 159, 95, + 28, 139, 123, 98, 125, 196, 15, 70, 194, 253, 54, 14, 109, 226, + 71, 17, 161, 93, 186, 87, 244, 138, 20, 52, 123, 251, 26, 36, + 17, 46, 52, 231, 232, 76, 31, 221, 84, 37, 216, 165, 212, 106, + 197, 242, 98, 43, 39, 175, 254, 145, 190, 84, 118, 222, 187, 136, + 120, 163, 236, 249}; + +byte rndindex = 0; +byte prndindex = 0; + +void I_ClearRandom(void) +{ + rndindex = prndindex = 0; +} diff --git a/i_random.h b/i_random.h new file mode 100644 index 00000000..dc623959 --- /dev/null +++ b/i_random.h @@ -0,0 +1,21 @@ +#include "doomtype.h" + +// +// M_Random +// Returns a 0-255 number +// +extern byte rndtable[256]; +extern byte rndindex; +extern byte prndindex; + +// Which one is deterministic? + +// Returns a number from 0 to 255, +// from a lookup table. +#define M_Random rndtable[++rndindex] + +// As M_Random, but used only by the play simulation. +#define P_Random rndtable[++prndindex] + +// Fix randoms for demos. +void I_ClearRandom(void); diff --git a/m_misc.c b/m_misc.c index e8e09ae7..e71ad896 100644 --- a/m_misc.c +++ b/m_misc.c @@ -68,52 +68,6 @@ int M_CheckParm(char *check) return 0; } -// -// M_Random -// Returns a 0-255 number -// -unsigned char rndtable[256] = { - 0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66, - 74, 21, 211, 47, 80, 242, 154, 27, 205, 128, 161, 89, 77, 36, - 95, 110, 85, 48, 212, 140, 211, 249, 22, 79, 200, 50, 28, 188, - 52, 140, 202, 120, 68, 145, 62, 70, 184, 190, 91, 197, 152, 224, - 149, 104, 25, 178, 252, 182, 202, 182, 141, 197, 4, 81, 181, 242, - 145, 42, 39, 227, 156, 198, 225, 193, 219, 93, 122, 175, 249, 0, - 175, 143, 70, 239, 46, 246, 163, 53, 163, 109, 168, 135, 2, 235, - 25, 92, 20, 145, 138, 77, 69, 166, 78, 176, 173, 212, 166, 113, - 94, 161, 41, 50, 239, 49, 111, 164, 70, 60, 2, 37, 171, 75, - 136, 156, 11, 56, 42, 146, 138, 229, 73, 146, 77, 61, 98, 196, - 135, 106, 63, 197, 195, 86, 96, 203, 113, 101, 170, 247, 181, 113, - 80, 250, 108, 7, 255, 237, 129, 226, 79, 107, 112, 166, 103, 241, - 24, 223, 239, 120, 198, 58, 60, 82, 128, 3, 184, 66, 143, 224, - 145, 224, 81, 206, 163, 45, 63, 90, 168, 114, 59, 33, 159, 95, - 28, 139, 123, 98, 125, 196, 15, 70, 194, 253, 54, 14, 109, 226, - 71, 17, 161, 93, 186, 87, 244, 138, 20, 52, 123, 251, 26, 36, - 17, 46, 52, 231, 232, 76, 31, 221, 84, 37, 216, 165, 212, 106, - 197, 242, 98, 43, 39, 175, 254, 145, 190, 84, 118, 222, 187, 136, - 120, 163, 236, 249}; - -int rndindex = 0; -int prndindex = 0; - -// Which one is deterministic? -int P_Random(void) -{ - prndindex = (prndindex + 1) & 0xff; - return rndtable[prndindex]; -} - -int M_Random(void) -{ - rndindex = (rndindex + 1) & 0xff; - return rndtable[rndindex]; -} - -void M_ClearRandom(void) -{ - rndindex = prndindex = 0; -} - void M_ClearBox(fixed_t *box) { box[BOXTOP] = box[BOXRIGHT] = MININT; diff --git a/m_misc.h b/m_misc.h index d8ee94e4..d1fa98e3 100644 --- a/m_misc.h +++ b/m_misc.h @@ -38,16 +38,6 @@ M_WriteFile(char const *name, int M_ReadFile(char const *name, byte **buffer); -// Returns a number from 0 to 255, -// from a lookup table. -int M_Random(void); - -// As M_Random, but used only by the play simulation. -int P_Random(void); - -// Fix randoms for demos. -void M_ClearRandom(void); - // Bounding box coordinate storage. enum { diff --git a/makefile b/makefile index 6b3d842a..423adf2d 100644 --- a/makefile +++ b/makefile @@ -26,6 +26,7 @@ CCOPTS = /d2 /omaxet /zp8 /4r /ei /j /zq /i=dmx GLOBOBJS = & + i_random.obj & i_main.obj & i_ibm.obj & i_sound.obj & @@ -99,6 +100,7 @@ clean : .SYMBOLIC del *.exe del *.map del *.err + del i_random.obj del am_map.obj del d_main.obj del d_net.obj diff --git a/newdoom.lnk b/newdoom.lnk index 4b41f9bf..1853e2d9 100644 --- a/newdoom.lnk +++ b/newdoom.lnk @@ -14,6 +14,7 @@ lib audio_wf.lib format os2 le name newdoom +file i_random.obj file i_main.obj file i_ibm.obj file i_sound.obj diff --git a/p_enemy.c b/p_enemy.c index 0c76e5d1..f780ebb4 100644 --- a/p_enemy.c +++ b/p_enemy.c @@ -20,6 +20,8 @@ #include +#include "i_random.h" + #include "m_misc.h" #include "i_system.h" @@ -216,7 +218,7 @@ boolean P_CheckMissileRange(mobj_t *actor) if (actor->type == MT_CYBORG && dist > 160) dist = 160; - if (P_Random() < dist) + if (P_Random < dist) return false; return true; @@ -314,7 +316,7 @@ boolean P_TryWalk(mobj_t *actor) return false; } - actor->movecount = P_Random() & 15; + actor->movecount = P_Random & 15; return true; } @@ -359,7 +361,7 @@ void P_NewChaseDir(mobj_t *actor) } // try other directions - if (P_Random() > 200 || abs(deltay) > abs(deltax)) + if (P_Random > 200 || abs(deltay) > abs(deltax)) { tdir = d[1]; d[1] = d[2]; @@ -400,7 +402,7 @@ void P_NewChaseDir(mobj_t *actor) } // randomly determine direction of search - if (P_Random() & 1) + if (P_Random & 1) { for (tdir = DI_EAST; tdir <= DI_SOUTHEAST; @@ -580,12 +582,12 @@ void A_Look(mobj_t *actor) case sfx_posit1: case sfx_posit2: case sfx_posit3: - sound = sfx_posit1 + P_Random() % 3; + sound = sfx_posit1 + P_Random % 3; break; case sfx_bgsit1: case sfx_bgsit2: - sound = sfx_bgsit1 + P_Random() % 2; + sound = sfx_bgsit1 + P_Random % 2; break; default: @@ -695,7 +697,7 @@ void A_Chase(mobj_t *actor) } // make active sound - if (actor->info->activesound && P_Random() < 3) + if (actor->info->activesound && P_Random < 3) { S_StartSound(actor, actor->info->activesound); } @@ -717,7 +719,7 @@ void A_FaceTarget(mobj_t *actor) actor->target->y); if (actor->target->flags & MF_SHADOW) - actor->angle += (P_Random() - P_Random()) << 21; + actor->angle += (P_Random - P_Random) << 21; } // @@ -737,8 +739,8 @@ void A_PosAttack(mobj_t *actor) slope = P_AimLineAttack(actor, angle, MISSILERANGE); S_StartSound(actor, sfx_pistol); - angle += (P_Random() - P_Random()) << 20; - damage = ((P_Random() % 5) + 1) * 3; + angle += (P_Random - P_Random) << 20; + damage = ((P_Random % 5) + 1) * 3; P_LineAttack(actor, angle, MISSILERANGE, slope, damage); } @@ -760,8 +762,8 @@ void A_SPosAttack(mobj_t *actor) for (i = 0; i < 3; i++) { - angle = bangle + ((P_Random() - P_Random()) << 20); - damage = ((P_Random() % 5) + 1) * 3; + angle = bangle + ((P_Random - P_Random) << 20); + damage = ((P_Random % 5) + 1) * 3; P_LineAttack(actor, angle, MISSILERANGE, slope, damage); } } @@ -781,8 +783,8 @@ void A_CPosAttack(mobj_t *actor) bangle = actor->angle; slope = P_AimLineAttack(actor, bangle, MISSILERANGE); - angle = bangle + ((P_Random() - P_Random()) << 20); - damage = ((P_Random() % 5) + 1) * 3; + angle = bangle + ((P_Random - P_Random) << 20); + damage = ((P_Random % 5) + 1) * 3; P_LineAttack(actor, angle, MISSILERANGE, slope, damage); } @@ -791,7 +793,7 @@ void A_CPosRefire(mobj_t *actor) // keep firing unless target got out of sight A_FaceTarget(actor); - if (P_Random() < 40) + if (P_Random < 40) return; if (!actor->target || actor->target->health <= 0 || !P_CheckSight(actor, actor->target)) @@ -805,7 +807,7 @@ void A_SpidRefire(mobj_t *actor) // keep firing unless target got out of sight A_FaceTarget(actor); - if (P_Random() < 10) + if (P_Random < 10) return; if (!actor->target || actor->target->health <= 0 || !P_CheckSight(actor, actor->target)) @@ -839,7 +841,7 @@ void A_TroopAttack(mobj_t *actor) if (P_CheckMeleeRange(actor)) { S_StartSound(actor, sfx_claw); - damage = (P_Random() % 8 + 1) * 3; + damage = (P_Random % 8 + 1) * 3; P_DamageMobj(actor->target, actor, actor, damage); return; } @@ -858,7 +860,7 @@ void A_SargAttack(mobj_t *actor) A_FaceTarget(actor); if (P_CheckMeleeRange(actor)) { - damage = ((P_Random() % 10) + 1) * 4; + damage = ((P_Random % 10) + 1) * 4; P_DamageMobj(actor->target, actor, actor, damage); } } @@ -873,7 +875,7 @@ void A_HeadAttack(mobj_t *actor) A_FaceTarget(actor); if (P_CheckMeleeRange(actor)) { - damage = (P_Random() % 6 + 1) * 10; + damage = (P_Random % 6 + 1) * 10; P_DamageMobj(actor->target, actor, actor, damage); return; } @@ -901,7 +903,7 @@ void A_BruisAttack(mobj_t *actor) if (P_CheckMeleeRange(actor)) { S_StartSound(actor, sfx_claw); - damage = (P_Random() % 8 + 1) * 10; + damage = (P_Random % 8 + 1) * 10; P_DamageMobj(actor->target, actor, actor, damage); return; } @@ -951,7 +953,7 @@ void A_Tracer(mobj_t *actor) actor->z, MT_SMOKE); th->momz = FRACUNIT; - th->tics -= P_Random() & 3; + th->tics -= P_Random & 3; if (th->tics < 1) th->tics = 1; @@ -1022,7 +1024,7 @@ void A_SkelFist(mobj_t *actor) if (P_CheckMeleeRange(actor)) { - damage = ((P_Random() % 10) + 1) * 6; + damage = ((P_Random % 10) + 1) * 6; S_StartSound(actor, sfx_skepch); P_DamageMobj(actor->target, actor, actor, damage); } @@ -1427,12 +1429,12 @@ void A_Scream(mobj_t *actor) case sfx_podth1: case sfx_podth2: case sfx_podth3: - sound = sfx_podth1 + P_Random() % 3; + sound = sfx_podth1 + P_Random % 3; break; case sfx_bgdth1: case sfx_bgdth2: - sound = sfx_bgdth1 + P_Random() % 2; + sound = sfx_bgdth1 + P_Random % 2; break; default: @@ -1719,13 +1721,13 @@ void A_BrainScream(mobj_t *mo) for (x = mo->x - 196 * FRACUNIT; x < mo->x + 320 * FRACUNIT; x += FRACUNIT * 8) { y = mo->y - 320 * FRACUNIT; - z = 128 + P_Random() * 2 * FRACUNIT; + z = 128 + P_Random * 2 * FRACUNIT; th = P_SpawnMobj(x, y, z, MT_ROCKET); - th->momz = P_Random() * 512; + th->momz = P_Random * 512; P_SetMobjState(th, S_BRAINEXPLODE1); - th->tics -= P_Random() & 7; + th->tics -= P_Random & 7; if (th->tics < 1) th->tics = 1; } @@ -1740,15 +1742,15 @@ void A_BrainExplode(mobj_t *mo) int z; mobj_t *th; - x = mo->x + (P_Random() - P_Random()) * 2048; + x = mo->x + (P_Random - P_Random) * 2048; y = mo->y; - z = 128 + P_Random() * 2 * FRACUNIT; + z = 128 + P_Random * 2 * FRACUNIT; th = P_SpawnMobj(x, y, z, MT_ROCKET); - th->momz = P_Random() * 512; + th->momz = P_Random * 512; P_SetMobjState(th, S_BRAINEXPLODE1); - th->tics -= P_Random() & 7; + th->tics -= P_Random & 7; if (th->tics < 1) th->tics = 1; } @@ -1809,7 +1811,7 @@ void A_SpawnFly(mobj_t *mo) S_StartSound(fog, sfx_telept); // Randomly select monster to spawn. - r = P_Random(); + r = P_Random; // Probability distribution (kind of :), // decreasing likelihood. diff --git a/p_inter.c b/p_inter.c index c6ff2204..641e7e70 100644 --- a/p_inter.c +++ b/p_inter.c @@ -23,6 +23,8 @@ #include "doomstat.h" +#include "i_random.h" + #include "m_misc.h" #include "i_system.h" @@ -631,7 +633,7 @@ void P_KillMobj(mobj_t *source, } else P_SetMobjState(target, target->info->deathstate); - target->tics -= P_Random() & 3; + target->tics -= P_Random & 3; if (target->tics < 1) target->tics = 1; @@ -714,7 +716,7 @@ void P_DamageMobj(mobj_t *target, thrust = damage * (FRACUNIT >> 3) * 100 / target->info->mass; // make fall forwards sometimes - if (damage < 40 && damage > target->health && target->z - inflictor->z > 64 * FRACUNIT && (P_Random() & 1)) + if (damage < 40 && damage > target->health && target->z - inflictor->z > 64 * FRACUNIT && (P_Random & 1)) { ang += ANG180; thrust *= 4; @@ -776,7 +778,7 @@ void P_DamageMobj(mobj_t *target, return; } - if ((P_Random() < target->info->painchance) && !(target->flags & MF_SKULLFLY)) + if ((P_Random < target->info->painchance) && !(target->flags & MF_SKULLFLY)) { target->flags |= MF_JUSTHIT; // fight back! diff --git a/p_lights.c b/p_lights.c index 9dc91ddc..7ab9a989 100644 --- a/p_lights.c +++ b/p_lights.c @@ -17,6 +17,10 @@ // Muzzle flash? // +#include "doomstat.h" + +#include "i_random.h" + #include "z_zone.h" #include "m_misc.h" @@ -40,7 +44,7 @@ void T_FireFlicker(fireflicker_t *flick) if (--flick->count) return; - amount = (P_Random() & 3) * 16; + amount = (P_Random & 3) * 16; if (flick->sector->lightlevel - amount < flick->minlight) flick->sector->lightlevel = flick->minlight; @@ -88,12 +92,12 @@ void T_LightFlash(lightflash_t *flash) if (flash->sector->lightlevel == flash->maxlight) { flash->sector->lightlevel = flash->minlight; - flash->count = (P_Random() & flash->mintime) + 1; + flash->count = (P_Random & flash->mintime) + 1; } else { flash->sector->lightlevel = flash->maxlight; - flash->count = (P_Random() & flash->maxtime) + 1; + flash->count = (P_Random & flash->maxtime) + 1; } } @@ -120,7 +124,7 @@ void P_SpawnLightFlash(sector_t *sector) flash->minlight = P_FindMinSurroundingLight(sector, sector->lightlevel); flash->maxtime = 64; flash->mintime = 7; - flash->count = (P_Random() & flash->maxtime) + 1; + flash->count = (P_Random & flash->maxtime) + 1; } // @@ -176,7 +180,7 @@ void P_SpawnStrobeFlash(sector_t *sector, sector->special = 0; if (!inSync) - flash->count = (P_Random() & 7) + 1; + flash->count = (P_Random & 7) + 1; else flash->count = 1; } diff --git a/p_map.c b/p_map.c index 45a4053c..4a162473 100644 --- a/p_map.c +++ b/p_map.c @@ -19,6 +19,8 @@ #include +#include "i_random.h" + #include "m_misc.h" #include "i_system.h" @@ -252,7 +254,7 @@ boolean PIT_CheckThing(mobj_t *thing) // check for skulls slamming into things if (tmthing->flags & MF_SKULLFLY) { - damage = ((P_Random() % 8) + 1) * tmthing->info->damage; + damage = ((P_Random % 8) + 1) * tmthing->info->damage; P_DamageMobj(thing, tmthing, tmthing, damage); @@ -296,7 +298,7 @@ boolean PIT_CheckThing(mobj_t *thing) } // damage / explode - damage = ((P_Random() % 8) + 1) * tmthing->info->damage; + damage = ((P_Random % 8) + 1) * tmthing->info->damage; P_DamageMobj(thing, tmthing, tmthing->target, damage); // don't traverse any more @@ -1235,8 +1237,8 @@ boolean PIT_ChangeSector(mobj_t *thing) thing->y, thing->z + thing->height / 2, MT_BLOOD); - mo->momx = (P_Random() - P_Random()) << 12; - mo->momy = (P_Random() - P_Random()) << 12; + mo->momx = (P_Random - P_Random) << 12; + mo->momy = (P_Random - P_Random) << 12; } // keep checking (crush other things) diff --git a/p_mobj.c b/p_mobj.c index 73b40bc8..f1f72a3f 100644 --- a/p_mobj.c +++ b/p_mobj.c @@ -16,6 +16,8 @@ // Moving object handling. Spawn functions. // +#include "i_random.h" + #include "i_system.h" #include "z_zone.h" #include "m_misc.h" @@ -80,7 +82,7 @@ void P_ExplodeMissile(mobj_t *mo) P_SetMobjState(mo, mobjinfo[mo->type].deathstate); - mo->tics -= P_Random() & 3; + mo->tics -= P_Random & 3; if (mo->tics < 1) mo->tics = 1; @@ -436,7 +438,7 @@ void P_MobjThinker(mobj_t *mobj) if (leveltime & 31) return; - if (P_Random() > 4) + if (P_Random > 4) return; P_NightmareRespawn(mobj); @@ -472,7 +474,7 @@ P_SpawnMobj(fixed_t x, if (gameskill != sk_nightmare) mobj->reactiontime = info->reactiontime; - mobj->lastlook = P_Random() % MAXPLAYERS; + mobj->lastlook = P_Random % MAXPLAYERS; // do not set the state with P_SetMobjState, // because action routines can not be called yet st = &states[info->spawnstate]; @@ -655,7 +657,7 @@ void P_SpawnMapThing(mapthing_t *mthing) mobj->spawnpoint = *mthing; if (mobj->tics > 0) - mobj->tics = 1 + (P_Random() % mobj->tics); + mobj->tics = 1 + (P_Random % mobj->tics); if (mobj->flags & MF_COUNTKILL) totalkills++; if (mobj->flags & MF_COUNTITEM) @@ -681,11 +683,11 @@ void P_SpawnPuff(fixed_t x, { mobj_t *th; - z += ((P_Random() - P_Random()) << 10); + z += ((P_Random - P_Random) << 10); th = P_SpawnMobj(x, y, z, MT_PUFF); th->momz = FRACUNIT; - th->tics -= P_Random() & 3; + th->tics -= P_Random & 3; if (th->tics < 1) th->tics = 1; @@ -705,10 +707,10 @@ void P_SpawnBlood(fixed_t x, { mobj_t *th; - z += ((P_Random() - P_Random()) << 10); + z += ((P_Random - P_Random) << 10); th = P_SpawnMobj(x, y, z, MT_BLOOD); th->momz = FRACUNIT * 2; - th->tics -= P_Random() & 3; + th->tics -= P_Random & 3; if (th->tics < 1) th->tics = 1; @@ -726,7 +728,7 @@ void P_SpawnBlood(fixed_t x, // void P_CheckMissileSpawn(mobj_t *th) { - th->tics -= P_Random() & 3; + th->tics -= P_Random & 3; if (th->tics < 1) th->tics = 1; @@ -764,7 +766,7 @@ P_SpawnMissile(mobj_t *source, // fuzzy player if (dest->flags & MF_SHADOW) - an += (P_Random() - P_Random()) << 20; + an += (P_Random - P_Random) << 20; th->angle = an; an >>= ANGLETOFINESHIFT; diff --git a/p_plats.c b/p_plats.c index ab1e1ac5..4dea07f5 100644 --- a/p_plats.c +++ b/p_plats.c @@ -16,6 +16,8 @@ // Plats (i.e. elevator platforms) code, raising/lowering. // +#include "i_random.h" + #include "i_system.h" #include "z_zone.h" #include "m_misc.h" @@ -225,7 +227,7 @@ int EV_DoPlat(line_t *line, plat->high = sec->floorheight; plat->wait = 35 * PLATWAIT; - plat->status = P_Random() & 1; + plat->status = P_Random & 1; S_StartSound((mobj_t *)&sec->soundorg, sfx_pstart); break; diff --git a/p_pspr.c b/p_pspr.c index 77e22d75..b30e1244 100644 --- a/p_pspr.c +++ b/p_pspr.c @@ -17,6 +17,8 @@ // Action functions for weapons. // +#include "i_random.h" + #include "doomdef.h" #include "d_event.h" @@ -463,13 +465,13 @@ void A_Punch(player_t *player, int damage; int slope; - damage = (P_Random() % 10 + 1) << 1; + damage = (P_Random % 10 + 1) << 1; if (player->powers[pw_strength]) damage *= 10; angle = player->mo->angle; - angle += (P_Random() - P_Random()) << 18; + angle += (P_Random - P_Random) << 18; slope = P_AimLineAttack(player->mo, angle, MELEERANGE); P_LineAttack(player->mo, angle, MELEERANGE, slope, damage); @@ -494,9 +496,9 @@ void A_Saw(player_t *player, int damage; int slope; - damage = 2 * (P_Random() % 10 + 1); + damage = 2 * (P_Random % 10 + 1); angle = player->mo->angle; - angle += (P_Random() - P_Random()) << 18; + angle += (P_Random - P_Random) << 18; // use meleerange + 1 se the puff doesn't skip the flash slope = P_AimLineAttack(player->mo, angle, MELEERANGE + 1); @@ -559,7 +561,7 @@ void A_FirePlasma(player_t *player, P_SetPsprite(player, ps_flash, - weaponinfo[player->readyweapon].flashstate + (P_Random() & 1)); + weaponinfo[player->readyweapon].flashstate + (P_Random & 1)); P_SpawnPlayerMissile(player->mo, MT_PLASMA); } @@ -600,11 +602,11 @@ void P_GunShot(mobj_t *mo, angle_t angle; int damage; - damage = 5 * (P_Random() % 3 + 1); + damage = 5 * (P_Random % 3 + 1); angle = mo->angle; if (!accurate) - angle += (P_Random() - P_Random()) << 18; + angle += (P_Random - P_Random) << 18; P_LineAttack(mo, angle, MISSILERANGE, bulletslope, damage); } @@ -674,13 +676,13 @@ void A_FireShotgun2(player_t *player, for (i = 0; i < 20; i++) { - damage = 5 * (P_Random() % 3 + 1); + damage = 5 * (P_Random % 3 + 1); angle = player->mo->angle; - angle += (P_Random() - P_Random()) << 19; + angle += (P_Random - P_Random) << 19; P_LineAttack(player->mo, angle, MISSILERANGE, - bulletslope + ((P_Random() - P_Random()) << 5), damage); + bulletslope + ((P_Random - P_Random) << 5), damage); } } @@ -755,7 +757,7 @@ void A_BFGSpray(mobj_t *mo) damage = 0; for (j = 0; j < 15; j++) - damage += (P_Random() & 7) + 1; + damage += (P_Random & 7) + 1; P_DamageMobj(linetarget, mo->target, mo->target, damage); } diff --git a/p_setup.c b/p_setup.c index 648c68dc..0879d96b 100644 --- a/p_setup.c +++ b/p_setup.c @@ -612,8 +612,7 @@ void P_SetupLevel(int episode, P_SpawnSpecials(); // preload graphics - if (precache) - R_PrecacheLevel(); + R_PrecacheLevel(); } // diff --git a/p_spec.c b/p_spec.c index d22d183f..1459c79f 100644 --- a/p_spec.c +++ b/p_spec.c @@ -25,6 +25,8 @@ #include "doomdef.h" #include "doomstat.h" +#include "i_random.h" + #include "i_system.h" #include "z_zone.h" #include "m_misc.h" @@ -963,7 +965,7 @@ void P_PlayerInSpecialSector(player_t *player) // SUPER HELLSLIME DAMAGE case 4: // STROBE HURT - if (!player->powers[pw_ironfeet] || (P_Random() < 5)) + if (!player->powers[pw_ironfeet] || (P_Random < 5)) { if (!(leveltime & 0x1f)) P_DamageMobj(player->mo, NULL, NULL, 20); diff --git a/r_data.c b/r_data.c index 76c12a24..b4116e91 100644 --- a/r_data.c +++ b/r_data.c @@ -730,9 +730,6 @@ void R_PrecacheLevel(void) thinker_t *th; spriteframe_t *sf; - if (demoplayback) - return; - // Precache flats. flatpresent = alloca(numflats); memset(flatpresent, 0, numflats); diff --git a/st_stuff.c b/st_stuff.c index ff40e178..880fa5f1 100644 --- a/st_stuff.c +++ b/st_stuff.c @@ -20,6 +20,8 @@ #include +#include "i_random.h" + #include "i_system.h" #include "z_zone.h" #include "m_misc.h" @@ -869,7 +871,7 @@ void ST_Ticker(void) { st_clock++; - st_randomnumber = M_Random(); + st_randomnumber = M_Random; ST_updateWidgets(); st_oldhealth = plyr->health; } diff --git a/wi_stuff.c b/wi_stuff.c index 6fcf9deb..e198b6b1 100644 --- a/wi_stuff.c +++ b/wi_stuff.c @@ -18,6 +18,8 @@ #include +#include "i_random.h" + #include "z_zone.h" #include "m_misc.h" @@ -431,9 +433,9 @@ void WI_initAnimatedBack(void) // specify the next time to draw it if (a->type == ANIM_ALWAYS) - a->nexttic = bcnt + 1 + (M_Random() % a->period); + a->nexttic = bcnt + 1 + (M_Random % a->period); else if (a->type == ANIM_RANDOM) - a->nexttic = bcnt + 1 + a->data2 + (M_Random() % a->data1); + a->nexttic = bcnt + 1 + a->data2 + (M_Random % a->data1); else if (a->type == ANIM_LEVEL) a->nexttic = bcnt + 1; } @@ -471,7 +473,7 @@ void WI_updateAnimatedBack(void) if (a->ctr == a->nanims) { a->ctr = -1; - a->nexttic = bcnt + a->data2 + (M_Random() % a->data1); + a->nexttic = bcnt + a->data2 + (M_Random % a->data1); } else a->nexttic = bcnt + a->period;