1 /* Emacs style mode select -*- C++ -*-
2 *-----------------------------------------------------------------------------
5 * PrBoom a Doom port merged with LxDoom and LSDLDoom
6 * based on BOOM, a modified and improved DOOM engine
7 * Copyright (C) 1999 by
8 * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
9 * Copyright (C) 1999-2000 by
10 * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
28 * Functions to return random numbers.
30 *-----------------------------------------------------------------------------*/
38 // killough 1/19/98: rewritten to use to use a better random number generator
39 // in the new engine, although the old one is available for compatibility.
43 // Make every random number generator local to each control-equivalent block.
44 // Critical for demo sync. Changing the order of this list breaks all previous
45 // versions' demos. The random number generators are made local to reduce the
46 // chances of sync problems. In Doom, if a single random number generator call
47 // was off, it would mess up all random number generators. This reduces the
48 // chances of it happening by making each RNG local to a control flow block.
50 // Notes to developers: if you want to reduce your demo sync hassles, follow
51 // this rule: for each call to P_Random you add, add a new class to the enum
52 // type below for each block of code which calls P_Random. If two calls to
53 // P_Random are not in "control-equivalent blocks", i.e. there are any cases
54 // where one is executed, and the other is not, put them in separate classes.
56 // Keep all current entries in this list the same, and in the order
57 // indicated by the #'s, because they're critical for preserving demo
58 // sync. Do not remove entries simply because they become unused later.
91 pr_newchasedir
, // #31
98 pr_troopattack
, // #38
100 pr_headattack
, // #40
101 pr_bruisattack
, // #41
105 pr_brainscream
, // #45
106 pr_cposrefire
, // #46
110 pr_all_in_one
, // #50
111 /* CPhipps - new entries from MBF, mostly unused for now */
113 pr_targetsearch
, // #52
116 pr_skiptarget
, // #55
117 pr_enemystrafe
, // #56
118 pr_avoidcrush
, // #57
119 pr_stayonlift
, // #58
120 pr_helpfriend
, // #59
122 pr_randomjump
, // #61
123 pr_defect
, // #62 // Start new entries -- add new entries below
125 // End of new entries
126 NUMPRCLASS
// MUST be last item in list
129 // The random number generator's state.
131 unsigned long seed
[NUMPRCLASS
]; // Each block's random seed
132 int rndindex
, prndindex
; // For compatibility support
135 extern rng_t rng
; // The rng's state
137 extern unsigned long rngseed
; // The starting seed (not part of state)
139 // Returns a number from 0 to 255,
140 #define M_Random() P_Random(pr_misc)
142 // As M_Random, but used by the play simulation.
143 int P_Random(pr_class_t
);
145 // Fix randoms for demos.
146 void M_ClearRandom(void);