Debian Codegraph @

misc/psrand.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/misc/psrand.cpp $
21 * $Revision: 2 $
22 * $Date: 4/21/99 11:05a $
23 * $Author: Kevin $
24 *
25 * Outrage random number generator code
26 *
27 * $Log: /DescentIII/Main/misc/psrand.cpp $
28 *
29 * 2 4/21/99 11:05a Kevin
30 * new ps_rand and ps_srand to replace rand & srand
31 *
32 * 1 4/21/99 10:16a Kevin
33 *
34 * $NoKeywords: $
35 */
36
37 #include "psrand.h"
38
39 static int32_t ps_holdrand = 1L;
40
41 // These are adapted from the C runtime lib. Pretty simple.
42
43 void ps_srand(uint32_t seed) { ps_holdrand = static_cast<int32_t>(seed); }
44
45 int32_t ps_rand(void) { return (((ps_holdrand = ps_holdrand * 214013L + 2531011L) >> 16) & 0x7fff); }