summaryrefslogtreecommitdiff
path: root/apps/plugins/doom/m_random.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/doom/m_random.h')
-rw-r--r--apps/plugins/doom/m_random.h148
1 files changed, 148 insertions, 0 deletions
diff --git a/apps/plugins/doom/m_random.h b/apps/plugins/doom/m_random.h
new file mode 100644
index 0000000000..67c1a3ba4b
--- /dev/null
+++ b/apps/plugins/doom/m_random.h
@@ -0,0 +1,148 @@
1/* Emacs style mode select -*- C++ -*-
2 *-----------------------------------------------------------------------------
3 *
4 *
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
11 *
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.
16 *
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.
21 *
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
25 * 02111-1307, USA.
26 *
27 * DESCRIPTION:
28 * Functions to return random numbers.
29 *
30 *-----------------------------------------------------------------------------*/
31
32
33#ifndef __M_RANDOM__
34#define __M_RANDOM__
35
36#include "doomtype.h"
37
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.
40
41// killough 2/16/98:
42//
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.
49//
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.
55//
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.
59
60typedef enum {
61 pr_skullfly, // #1
62 pr_damage, // #2
63 pr_crush, // #3
64 pr_genlift, // #4
65 pr_killtics, // #5
66 pr_damagemobj, // #6
67 pr_painchance, // #7
68 pr_lights, // #8
69 pr_explode, // #9
70 pr_respawn, // #10
71 pr_lastlook, // #11
72 pr_spawnthing, // #12
73 pr_spawnpuff, // #13
74 pr_spawnblood, // #14
75 pr_missile, // #15
76 pr_shadow, // #16
77 pr_plats, // #17
78 pr_punch, // #18
79 pr_punchangle, // #19
80 pr_saw, // #20
81 pr_plasma, // #21
82 pr_gunshot, // #22
83 pr_misfire, // #23
84 pr_shotgun, // #24
85 pr_bfg, // #25
86 pr_slimehurt, // #26
87 pr_dmspawn, // #27
88 pr_missrange, // #28
89 pr_trywalk, // #29
90 pr_newchase, // #30
91 pr_newchasedir, // #31
92 pr_see, // #32
93 pr_facetarget, // #33
94 pr_posattack, // #34
95 pr_sposattack, // #35
96 pr_cposattack, // #36
97 pr_spidrefire, // #37
98 pr_troopattack, // #38
99 pr_sargattack, // #39
100 pr_headattack, // #40
101 pr_bruisattack, // #41
102 pr_tracer, // #42
103 pr_skelfist, // #43
104 pr_scream, // #44
105 pr_brainscream, // #45
106 pr_cposrefire, // #46
107 pr_brainexp, // #47
108 pr_spawnfly, // #48
109 pr_misc, // #49
110 pr_all_in_one, // #50
111 /* CPhipps - new entries from MBF, mostly unused for now */
112 pr_opendoor, // #51
113 pr_targetsearch, // #52
114 pr_friends, // #53
115 pr_threshold, // #54
116 pr_skiptarget, // #55
117 pr_enemystrafe, // #56
118 pr_avoidcrush, // #57
119 pr_stayonlift, // #58
120 pr_helpfriend, // #59
121 pr_dropoff, // #60
122 pr_randomjump, // #61
123 pr_defect, // #62 // Start new entries -- add new entries below
124
125 // End of new entries
126 NUMPRCLASS // MUST be last item in list
127} pr_class_t;
128
129// The random number generator's state.
130typedef struct {
131 unsigned long seed[NUMPRCLASS]; // Each block's random seed
132 int rndindex, prndindex; // For compatibility support
133} rng_t;
134
135extern rng_t rng; // The rng's state
136
137extern unsigned long rngseed; // The starting seed (not part of state)
138
139// Returns a number from 0 to 255,
140#define M_Random() P_Random(pr_misc)
141
142// As M_Random, but used by the play simulation.
143int P_Random(pr_class_t);
144
145// Fix randoms for demos.
146void M_ClearRandom(void);
147
148#endif