gzdoom/code/m_random.h

136 lines
4.1 KiB
C
Raw Normal View History

1998-07-14 00:00:00 +00:00
// Emacs style mode select -*- C++ -*-
1998-04-07 00:00:00 +00:00
//-----------------------------------------------------------------------------
//
1998-07-14 00:00:00 +00:00
// $Id: m_random.h,v 1.9 1998/05/01 14:20:31 killough Exp $
1998-04-07 00:00:00 +00:00
//
// Copyright (C) 1993-1996 by id Software, Inc.
//
// This source is available for distribution and/or modification
// only under the terms of the DOOM Source Code License as
// published by id Software. All rights reserved.
//
// The source is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
// for more details.
//
// DESCRIPTION:
//
1998-07-14 00:00:00 +00:00
// [RH] We now use BOOM's random number generator
//
1998-04-07 00:00:00 +00:00
//-----------------------------------------------------------------------------
#ifndef __M_RANDOM__
#define __M_RANDOM__
#include "doomtype.h"
1998-07-14 00:00:00 +00:00
// killough 1/19/98: rewritten to use to use a better random number generator
// in the new engine, although the old one is available for compatibility.
// killough 2/16/98:
//
// Make every random number generator local to each control-equivalent block.
// Critical for demo sync. Changing the order of this list breaks all previous
// versions' demos. The random number generators are made local to reduce the
// chances of sync problems. In Doom, if a single random number generator call
// was off, it would mess up all random number generators. This reduces the
// chances of it happening by making each RNG local to a control flow block.
//
// Notes to developers: if you want to reduce your demo sync hassles, follow
// this rule: for each call to P_Random you add, add a new class to the enum
// type below for each block of code which calls P_Random. If two calls to
// P_Random are not in "control-equivalent blocks", i.e. there are any cases
// where one is executed, and the other is not, put them in separate classes.
//
// Keep all current entries in this list the same, and in the order
// indicated by the #'s, because they're critical for preserving demo
// sync. Do not remove entries simply because they become unused later.
typedef enum {
pr_misc, // 0
pr_all_in_one, // 1
pr_dmspawn, // 2
pr_checkmissilerange, // 3
pr_trywalk, // 4
pr_newchasedir, // 5
pr_look, // 6
pr_chase, // 7
pr_facetarget, // 8
pr_posattack, // 9
pr_sposattack, // 10
pr_cposattack, // 11
pr_cposrefire, // 12
pr_spidrefire, // 13
pr_troopattack, // 14
pr_sargattack, // 15
pr_headattack, // 16
pr_bruisattack, // 17
pr_tracer, // 18
pr_skelfist, // 19
pr_scream, // 20
pr_brainscream, // 21
pr_brainexplode, // 22
pr_spawnfly, // 23
pr_killmobj, // 24
pr_damagemobj, // 25
pr_checkthing, // 26
pr_changesector, // 27
pr_explodemissile, // 28
pr_mobjthinker, // 29
pr_spawnmobj, // 30
pr_spawnmapthing, // 31
pr_spawnpuff, // 32
pr_spawnblood, // 33
pr_checkmissilespawn, // 34
pr_spawnmissile, // 35
pr_punch, // 36
pr_saw, // 37
pr_fireplasma, // 38
pr_gunshot, // 39
pr_fireshotgun2, // 40
pr_bfgspray, // 41
pr_checksight, // 42
pr_playerinspecialsector, // 43
pr_fireflicker, // 44
pr_lightflash, // 45
pr_spawnlightflash, // 46
pr_spawnstrobeflash, // 47
pr_doplat, // 48
pr_throwgib, // 49
pr_vel4dmg, // 50
pr_gengib, // 51
1998-12-22 00:00:00 +00:00
pr_acs, // 52
pr_animatepictures, // 53
pr_obituary, // 54
pr_quake, // 55
pr_playerscream, // 56
pr_playerpain, // 57
1998-07-14 00:00:00 +00:00
// Start new entries -- add new entries below
// End of new entries
NUMPRCLASS // MUST be last item in list
} pr_class_t;
1998-04-07 00:00:00 +00:00
1998-07-14 00:00:00 +00:00
// The random number generator's state.
typedef struct {
unsigned long seed[NUMPRCLASS]; // Each block's random seed
int rndindex, prndindex; // For compatibility support
} rng_t;
extern rng_t rng; // The rng's state
extern unsigned long rngseed; // The starting seed (not part of state)
1998-04-07 00:00:00 +00:00
// Returns a number from 0 to 255,
1998-07-14 00:00:00 +00:00
#define M_Random() P_Random(pr_misc)
1998-04-07 00:00:00 +00:00
1998-07-14 00:00:00 +00:00
// As M_Random, but used by the play simulation.
int P_Random(pr_class_t);
1998-04-07 00:00:00 +00:00
// Fix randoms for demos.
1998-07-14 00:00:00 +00:00
void M_ClearRandom(void);
1998-04-07 00:00:00 +00:00
#endif