summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2015-12-11 08:09:30 +0100
committerBardur Arantsson <bardur@scientician.net>2015-12-11 08:09:30 +0100
commit97bcf1bc612d9920390c885b8dcea0b0cda6f246 (patch)
treef9890fb08cc717fbc8837b58945f32dd64929b45
parente4b4f4730a2fb39da766892adbf3419bf5e7f48f (diff)
Migrate z-rand.c to C++
- Include explicitly instead of via angband.h - Change to regular functions instead of macros.
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/angband.h1
-rw-r--r--src/birth.cc1
-rw-r--r--src/bldg.cc1
-rw-r--r--src/cave.cc1
-rw-r--r--src/cmd1.cc1
-rw-r--r--src/cmd2.cc1
-rw-r--r--src/cmd3.cc1
-rw-r--r--src/cmd4.cc1
-rw-r--r--src/cmd5.cc1
-rw-r--r--src/cmd6.cc1
-rw-r--r--src/cmd7.cc1
-rw-r--r--src/corrupt.cc1
-rw-r--r--src/dice.cc2
-rw-r--r--src/dungeon.cc1
-rw-r--r--src/files.cc1
-rw-r--r--src/gen_evol.cc1
-rw-r--r--src/gen_maze.cc1
-rw-r--r--src/generate.cc1
-rw-r--r--src/init1.cc1
-rw-r--r--src/joke.cc1
-rw-r--r--src/loadsave.cc1
-rw-r--r--src/melee1.cc1
-rw-r--r--src/melee2.cc1
-rw-r--r--src/mimic.cc1
-rw-r--r--src/monster2.cc1
-rw-r--r--src/monster3.cc1
-rw-r--r--src/object1.cc1
-rw-r--r--src/object2.cc1
-rw-r--r--src/powers.cc1
-rw-r--r--src/q_dragons.cc1
-rw-r--r--src/q_eol.cc1
-rw-r--r--src/q_evil.cc1
-rw-r--r--src/q_fireprof.cc1
-rw-r--r--src/q_god.cc1
-rw-r--r--src/q_haunted.cc1
-rw-r--r--src/q_hobbit.cc1
-rw-r--r--src/q_library.cc1
-rw-r--r--src/q_nazgul.cc1
-rw-r--r--src/q_one.cc1
-rw-r--r--src/q_poison.cc1
-rw-r--r--src/q_rand.cc1
-rw-r--r--src/q_shroom.cc1
-rw-r--r--src/q_thief.cc1
-rw-r--r--src/q_thrain.cc1
-rw-r--r--src/q_troll.cc1
-rw-r--r--src/q_wight.cc1
-rw-r--r--src/q_wolves.cc1
-rw-r--r--src/randart.cc1
-rw-r--r--src/skills.cc1
-rw-r--r--src/spells1.cc1
-rw-r--r--src/spells2.cc1
-rw-r--r--src/spells3.cc1
-rw-r--r--src/spells4.cc1
-rw-r--r--src/spells5.cc1
-rw-r--r--src/store.cc1
-rw-r--r--src/traps.cc1
-rw-r--r--src/wild.cc1
-rw-r--r--src/wizard2.cc1
-rw-r--r--src/xtra1.cc1
-rw-r--r--src/xtra2.cc1
-rw-r--r--src/z-rand.cc (renamed from src/z-rand.c)25
-rw-r--r--src/z-rand.hpp (renamed from src/z-rand.h)83
63 files changed, 113 insertions, 58 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1fc6a3b..942946f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -104,7 +104,7 @@ SET(SRCS_COMMON
xtra1.cc
xtra2.cc
z-form.c
- z-rand.c
+ z-rand.cc
z-term.c
z-util.c
)
diff --git a/src/angband.h b/src/angband.h
index ccf5295..5fbc94e 100644
--- a/src/angband.h
+++ b/src/angband.h
@@ -27,7 +27,6 @@ extern "C" {
*/
#include "z-util.h"
#include "z-form.h"
-#include "z-rand.h"
#include "z-term.h"
diff --git a/src/birth.cc b/src/birth.cc
index f6120a5..5d7e64b 100644
--- a/src/birth.cc
+++ b/src/birth.cc
@@ -54,6 +54,7 @@
#include "wilderness_map.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
#include <string>
diff --git a/src/bldg.cc b/src/bldg.cc
index dd43332..7095e8c 100644
--- a/src/bldg.cc
+++ b/src/bldg.cc
@@ -40,6 +40,7 @@
#include "variable.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
/* remember building location */
static int building_loc = 0;
diff --git a/src/cave.cc b/src/cave.cc
index 6a1c513..5ff3101 100644
--- a/src/cave.cc
+++ b/src/cave.cc
@@ -19,6 +19,7 @@
#include "util.h"
#include "variable.h"
#include "variable.hpp"
+#include "z-rand.hpp"
#include <cassert>
#include <vector>
diff --git a/src/cmd1.cc b/src/cmd1.cc
index c11ad4b..dbb888c 100644
--- a/src/cmd1.cc
+++ b/src/cmd1.cc
@@ -45,6 +45,7 @@
#include "wild.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
#define MAX_VAMPIRIC_DRAIN 100
diff --git a/src/cmd2.cc b/src/cmd2.cc
index fef0dd8..cfdeab4 100644
--- a/src/cmd2.cc
+++ b/src/cmd2.cc
@@ -48,6 +48,7 @@
#include "wilderness_type_info.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
#include <chrono>
#include <thread>
diff --git a/src/cmd3.cc b/src/cmd3.cc
index 154dd7b..d1e569e 100644
--- a/src/cmd3.cc
+++ b/src/cmd3.cc
@@ -36,6 +36,7 @@
#include "variable.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
#include <cassert>
#include <algorithm>
diff --git a/src/cmd4.cc b/src/cmd4.cc
index b0162a5..b260174 100644
--- a/src/cmd4.cc
+++ b/src/cmd4.cc
@@ -35,6 +35,7 @@
#include "variable.h"
#include "variable.hpp"
#include "xtra1.hpp"
+#include "z-rand.hpp"
#include <cassert>
#include <memory>
diff --git a/src/cmd5.cc b/src/cmd5.cc
index 2603b9a..a1dd5cb 100644
--- a/src/cmd5.cc
+++ b/src/cmd5.cc
@@ -39,6 +39,7 @@
#include "wizard2.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
#include <boost/noncopyable.hpp>
#include <boost/optional.hpp>
diff --git a/src/cmd6.cc b/src/cmd6.cc
index f27281d..0a5595f 100644
--- a/src/cmd6.cc
+++ b/src/cmd6.cc
@@ -47,6 +47,7 @@
#include "wizard2.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
#include <boost/algorithm/string/predicate.hpp>
#include <cassert>
diff --git a/src/cmd7.cc b/src/cmd7.cc
index 6f0412d..2317f8b 100644
--- a/src/cmd7.cc
+++ b/src/cmd7.cc
@@ -37,6 +37,7 @@
#include "variable.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
/*
* Describe class powers of Mindcrafters
diff --git a/src/corrupt.cc b/src/corrupt.cc
index d1a7c53..f182a9e 100644
--- a/src/corrupt.cc
+++ b/src/corrupt.cc
@@ -9,6 +9,7 @@
#include "variable.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
#include <cassert>
diff --git a/src/dice.cc b/src/dice.cc
index 637d277..187bae6 100644
--- a/src/dice.cc
+++ b/src/dice.cc
@@ -1,6 +1,6 @@
#include "dice.hpp"
-#include "z-rand.h"
+#include "z-rand.hpp"
#include <cassert>
diff --git a/src/dungeon.cc b/src/dungeon.cc
index db504f5..c4282a2 100644
--- a/src/dungeon.cc
+++ b/src/dungeon.cc
@@ -75,6 +75,7 @@
#include "wizard2.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
#include <boost/filesystem.hpp>
#include <cassert>
diff --git a/src/files.cc b/src/files.cc
index d135c39..30b3e5d 100644
--- a/src/files.cc
+++ b/src/files.cc
@@ -52,6 +52,7 @@
#include "wilderness_map.hpp"
#include "wilderness_type_info.hpp"
#include "xtra1.hpp"
+#include "z-rand.hpp"
#include <memory>
#include <unordered_set>
diff --git a/src/gen_evol.cc b/src/gen_evol.cc
index f6cee5a..6f3fbcb 100644
--- a/src/gen_evol.cc
+++ b/src/gen_evol.cc
@@ -15,6 +15,7 @@
#include "levels.hpp"
#include "player_type.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
/*
* Generate a game of life level :) and make it evolve
diff --git a/src/gen_maze.cc b/src/gen_maze.cc
index 9a3706f..22722e0 100644
--- a/src/gen_maze.cc
+++ b/src/gen_maze.cc
@@ -13,6 +13,7 @@
#include "generate.hpp"
#include "levels.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
#include <memory>
diff --git a/src/generate.cc b/src/generate.cc
index 0f24f7d..b573368 100644
--- a/src/generate.cc
+++ b/src/generate.cc
@@ -35,6 +35,7 @@
#include "vault_type.hpp"
#include "wild.hpp"
#include "wilderness_map.hpp"
+#include "z-rand.hpp"
#include <cassert>
#include <memory>
diff --git a/src/init1.cc b/src/init1.cc
index 216b655..66624ec 100644
--- a/src/init1.cc
+++ b/src/init1.cc
@@ -44,6 +44,7 @@
#include "vault_type.hpp"
#include "wilderness_map.hpp"
#include "wilderness_type_info.hpp"
+#include "z-rand.hpp"
#include <boost/algorithm/string/predicate.hpp>
diff --git a/src/joke.cc b/src/joke.cc
index fa66024..be27211 100644
--- a/src/joke.cc
+++ b/src/joke.cc
@@ -4,6 +4,7 @@
#include "options.hpp"
#include "util.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
static void gen_joke_place_monster(int r_idx)
{
diff --git a/src/loadsave.cc b/src/loadsave.cc
index c7ebf68..1fe550f 100644
--- a/src/loadsave.cc
+++ b/src/loadsave.cc
@@ -36,6 +36,7 @@
#include "variable.h"
#include "variable.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
#include <cassert>
#include <memory>
diff --git a/src/melee1.cc b/src/melee1.cc
index 9ec5f0c..bb4c06d 100644
--- a/src/melee1.cc
+++ b/src/melee1.cc
@@ -29,6 +29,7 @@
#include "variable.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
#include <boost/algorithm/string/predicate.hpp>
diff --git a/src/melee2.cc b/src/melee2.cc
index 8478add..ce2f11a 100644
--- a/src/melee2.cc
+++ b/src/melee2.cc
@@ -42,6 +42,7 @@
#include "util.hpp"
#include "variable.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
#include <cassert>
diff --git a/src/mimic.cc b/src/mimic.cc
index b888ec5..edf79f4 100644
--- a/src/mimic.cc
+++ b/src/mimic.cc
@@ -5,6 +5,7 @@
#include "stats.hpp"
#include "variable.hpp"
#include "xtra1.hpp"
+#include "z-rand.hpp"
#include <cassert>
diff --git a/src/monster2.cc b/src/monster2.cc
index 0be1cc3..3debb27 100644
--- a/src/monster2.cc
+++ b/src/monster2.cc
@@ -38,6 +38,7 @@
#include "wilderness_map.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
#include <algorithm>
#include <string>
diff --git a/src/monster3.cc b/src/monster3.cc
index 915a856..0d26538 100644
--- a/src/monster3.cc
+++ b/src/monster3.cc
@@ -24,6 +24,7 @@
#include "variable.h"
#include "variable.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
/*
* Is the mon,ster in friendly state(pet, friend, ..)
diff --git a/src/object1.cc b/src/object1.cc
index c38f225..6bbf23e 100644
--- a/src/object1.cc
+++ b/src/object1.cc
@@ -50,6 +50,7 @@
#include "variable.hpp"
#include "wilderness_type_info.hpp"
#include "xtra1.hpp"
+#include "z-rand.hpp"
#include <cassert>
diff --git a/src/object2.cc b/src/object2.cc
index 98d22c2..620037a 100644
--- a/src/object2.cc
+++ b/src/object2.cc
@@ -39,6 +39,7 @@
#include "variable.hpp"
#include "wilderness_map.hpp"
#include "xtra1.hpp"
+#include "z-rand.hpp"
#include <algorithm>
#include <cassert>
diff --git a/src/powers.cc b/src/powers.cc
index e1f15d5..a7db296 100644
--- a/src/powers.cc
+++ b/src/powers.cc
@@ -37,6 +37,7 @@
#include "variable.h"
#include "variable.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
/*
* Note: return value indicates the amount of mana to use
diff --git a/src/q_dragons.cc b/src/q_dragons.cc
index d6f5b1f..6c6084d 100644
--- a/src/q_dragons.cc
+++ b/src/q_dragons.cc
@@ -12,6 +12,7 @@
#include "tables.hpp"
#include "util.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
#define cquest (quest[QUEST_DRAGONS])
diff --git a/src/q_eol.cc b/src/q_eol.cc
index cfccd15..f27ce9d 100644
--- a/src/q_eol.cc
+++ b/src/q_eol.cc
@@ -17,6 +17,7 @@
#include "traps.hpp"
#include "util.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
#include <cassert>
diff --git a/src/q_evil.cc b/src/q_evil.cc
index 511644a..3bc953c 100644
--- a/src/q_evil.cc
+++ b/src/q_evil.cc
@@ -12,6 +12,7 @@
#include "tables.hpp"
#include "util.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
#define cquest (quest[QUEST_EVIL])
diff --git a/src/q_fireprof.cc b/src/q_fireprof.cc
index c561dbc..021cf2f 100644
--- a/src/q_fireprof.cc
+++ b/src/q_fireprof.cc
@@ -14,6 +14,7 @@
#include "traps.hpp"
#include "util.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
#include <cassert>
diff --git a/src/q_god.cc b/src/q_god.cc
index 754802f..0a3b07e 100644
--- a/src/q_god.cc
+++ b/src/q_god.cc
@@ -17,6 +17,7 @@
#include "variable.hpp"
#include "wilderness_map.hpp"
#include "wilderness_type_info.hpp"
+#include "z-rand.hpp"
#include <assert.h>
diff --git a/src/q_haunted.cc b/src/q_haunted.cc
index cbfaa17..57daa40 100644
--- a/src/q_haunted.cc
+++ b/src/q_haunted.cc
@@ -13,6 +13,7 @@
#include "tables.hpp"
#include "util.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
#define cquest (quest[QUEST_HAUNTED])
diff --git a/src/q_hobbit.cc b/src/q_hobbit.cc
index bc3659e..5a71711 100644
--- a/src/q_hobbit.cc
+++ b/src/q_hobbit.cc
@@ -16,6 +16,7 @@
#include "tables.hpp"
#include "util.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
#include <cassert>
diff --git a/src/q_library.cc b/src/q_library.cc
index 979fbb2..52a6729 100644
--- a/src/q_library.cc
+++ b/src/q_library.cc
@@ -15,6 +15,7 @@
#include "util.h"
#include "variable.h"
#include "variable.hpp"
+#include "z-rand.hpp"
#include <cassert>
diff --git a/src/q_nazgul.cc b/src/q_nazgul.cc
index 21bc95c..15a6a84 100644
--- a/src/q_nazgul.cc
+++ b/src/q_nazgul.cc
@@ -14,6 +14,7 @@
#include "tables.hpp"
#include "util.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
#include <cassert>
diff --git a/src/q_one.cc b/src/q_one.cc
index 1aa7761..3741e00 100644
--- a/src/q_one.cc
+++ b/src/q_one.cc
@@ -22,6 +22,7 @@
#include "town_type.hpp"
#include "util.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
#define cquest (quest[QUEST_ONE])
diff --git a/src/q_poison.cc b/src/q_poison.cc
index d8ecf94..a5b274b 100644
--- a/src/q_poison.cc
+++ b/src/q_poison.cc
@@ -17,6 +17,7 @@
#include "tables.hpp"
#include "util.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
#define cquest (quest[QUEST_POISON])
diff --git a/src/q_rand.cc b/src/q_rand.cc
index 5b26562..4ef7992 100644
--- a/src/q_rand.cc
+++ b/src/q_rand.cc
@@ -25,6 +25,7 @@
#include "tables.hpp"
#include "util.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
#include <cassert>
diff --git a/src/q_shroom.cc b/src/q_shroom.cc
index f3a7dd1..89b576d 100644
--- a/src/q_shroom.cc
+++ b/src/q_shroom.cc
@@ -16,6 +16,7 @@
#include "tables.hpp"
#include "util.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
#include <cassert>
diff --git a/src/q_thief.cc b/src/q_thief.cc
index 5019d9d..0f6543c 100644
--- a/src/q_thief.cc
+++ b/src/q_thief.cc
@@ -16,6 +16,7 @@
#include "tables.hpp"
#include "util.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
#define cquest (quest[QUEST_THIEVES])
diff --git a/src/q_thrain.cc b/src/q_thrain.cc
index 4cdb856..05def27 100644
--- a/src/q_thrain.cc
+++ b/src/q_thrain.cc
@@ -20,6 +20,7 @@
#include "tables.hpp"
#include "util.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
#include <cassert>
diff --git a/src/q_troll.cc b/src/q_troll.cc
index 7227c1c..fce3ad4 100644
--- a/src/q_troll.cc
+++ b/src/q_troll.cc
@@ -15,6 +15,7 @@
#include "tables.hpp"
#include "util.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
#include <cassert>
diff --git a/src/q_wight.cc b/src/q_wight.cc
index 499535c..f2cc630 100644
--- a/src/q_wight.cc
+++ b/src/q_wight.cc
@@ -14,6 +14,7 @@
#include "tables.hpp"
#include "util.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
#include <cassert>
diff --git a/src/q_wolves.cc b/src/q_wolves.cc
index 117e8d4..c5863b5 100644
--- a/src/q_wolves.cc
+++ b/src/q_wolves.cc
@@ -13,6 +13,7 @@
#include "tables.hpp"
#include "util.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
#define cquest (quest[QUEST_WOLVES])
diff --git a/src/randart.cc b/src/randart.cc
index 451bf94..5135438 100644
--- a/src/randart.cc
+++ b/src/randart.cc
@@ -20,6 +20,7 @@
#include "util.hpp"
#include "variable.h"
#include "variable.hpp"
+#include "z-rand.hpp"
#include <memory>
#include <vector>
diff --git a/src/skills.cc b/src/skills.cc
index 997b3bc..3a14a6c 100644
--- a/src/skills.cc
+++ b/src/skills.cc
@@ -37,6 +37,7 @@
#include "variable.h"
#include "variable.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
#include <algorithm>
#include <boost/algorithm/string/predicate.hpp>
diff --git a/src/spells1.cc b/src/spells1.cc
index 7cb6d2a..5d6722a 100644
--- a/src/spells1.cc
+++ b/src/spells1.cc
@@ -43,6 +43,7 @@
#include "wizard2.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
#include <chrono>
#include <thread>
diff --git a/src/spells2.cc b/src/spells2.cc
index b2f294b..08a643c 100644
--- a/src/spells2.cc
+++ b/src/spells2.cc
@@ -40,6 +40,7 @@
#include "variable.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
#include <boost/algorithm/string/predicate.hpp>
#include <cassert>
diff --git a/src/spells3.cc b/src/spells3.cc
index 78dec53..35604f7 100644
--- a/src/spells3.cc
+++ b/src/spells3.cc
@@ -27,6 +27,7 @@
#include "util.hpp"
#include "variable.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
#include <algorithm>
#include <cassert>
diff --git a/src/spells4.cc b/src/spells4.cc
index b4f924c..9e708e0 100644
--- a/src/spells4.cc
+++ b/src/spells4.cc
@@ -14,6 +14,7 @@
#include "util.hpp"
#include "util.h"
#include "variable.hpp"
+#include "z-rand.hpp"
#include <algorithm>
#include <cassert>
diff --git a/src/spells5.cc b/src/spells5.cc
index ca6351b..f503c82 100644
--- a/src/spells5.cc
+++ b/src/spells5.cc
@@ -5,6 +5,7 @@
#include "spells3.hpp"
#include "spells4.hpp"
#include "variable.hpp"
+#include "z-rand.hpp"
#include <cassert>
diff --git a/src/store.cc b/src/store.cc
index dad3c82..0fbe2e9 100644
--- a/src/store.cc
+++ b/src/store.cc
@@ -38,6 +38,7 @@
#include "variable.h"
#include "variable.hpp"
#include "xtra1.hpp"
+#include "z-rand.hpp"
#include <cassert>
diff --git a/src/traps.cc b/src/traps.cc
index d111951..99428cf 100644
--- a/src/traps.cc
+++ b/src/traps.cc
@@ -37,6 +37,7 @@
#include "variable.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
bool_ do_player_trap_call_out(void)
{
diff --git a/src/wild.cc b/src/wild.cc
index e9def09..7724176 100644
--- a/src/wild.cc
+++ b/src/wild.cc
@@ -26,6 +26,7 @@
#include "variable.hpp"
#include "wilderness_map.hpp"
#include "wilderness_type_info.hpp"
+#include "z-rand.hpp"
#include <memory>
diff --git a/src/wizard2.cc b/src/wizard2.cc
index 7bce50c..837d778 100644
--- a/src/wizard2.cc
+++ b/src/wizard2.cc
@@ -39,6 +39,7 @@
#include "wizard1.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
/*
* Adds a lvl to a monster
diff --git a/src/xtra1.cc b/src/xtra1.cc
index d213aa3..fd4a11f 100644
--- a/src/xtra1.cc
+++ b/src/xtra1.cc
@@ -47,6 +47,7 @@
#include "wilderness_map.hpp"
#include "wilderness_type_info.hpp"
#include "xtra2.hpp"
+#include "z-rand.hpp"
#include <cassert>
diff --git a/src/xtra2.cc b/src/xtra2.cc
index 87bfe0d..096f896 100644
--- a/src/xtra2.cc
+++ b/src/xtra2.cc
@@ -55,6 +55,7 @@
#include "wilderness_type_info.hpp"
#include "wizard2.hpp"
#include "xtra1.hpp"
+#include "z-rand.hpp"
#include <type_traits>
#include <cassert>
diff --git a/src/z-rand.c b/src/z-rand.cc
index ca5b49a..c06b789 100644
--- a/src/z-rand.c
+++ b/src/z-rand.cc
@@ -2,7 +2,7 @@
/* Purpose: a simple random number generator -BEN- */
-#include "z-rand.h"
+#include "z-rand.hpp"
@@ -154,7 +154,7 @@ s32b Rand_mod(s32b m)
* This method has no bias, and is much less affected by patterns
* in the "low" bits of the underlying RNG's.
*/
-s32b Rand_div(s32b m)
+static s32b Rand_div(s32b m)
{
u32b r, n;
@@ -351,5 +351,26 @@ s32b maxroll(s16b num, s16b sides)
return (num * sides);
}
+bool magik(int p) {
+ return rand_int(100) < p;
+}
+
+s32b rand_int(s32b m)
+{
+ return Rand_div(m);
+}
+s32b randint(s32b m)
+{
+ return rand_int(m) + 1;
+}
+s32b rand_range(s32b a, s32b b)
+{
+ return a + rand_int(1 + b - a);
+}
+
+s32b rand_spread(s32b a, s32b d)
+{
+ return a + rand_int(1 + d + d) - d;
+}
diff --git a/src/z-rand.h b/src/z-rand.hpp
index ba17dab..f2e3ce5 100644
--- a/src/z-rand.h
+++ b/src/z-rand.hpp
@@ -1,9 +1,5 @@
#pragma once
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#include "h-basic.h"
@@ -20,71 +16,52 @@ extern "C" {
-/**** Available macros ****/
+/**** Available Variables ****/
+
+
+extern bool_ Rand_quick;
+extern u32b Rand_value;
+extern u16b Rand_place;
+extern u32b Rand_state[RAND_DEG];
+
+
+/**** Available Functions ****/
+
+
+void Rand_state_init(u32b seed);
+s32b Rand_mod(s32b m);
+s16b randnor(int mean, int stand);
+s32b damroll(s16b num, s16b sides);
+s32b maxroll(s16b num, s16b sides);
+/**
+ * Evaluate to "true" p percent of the time.
+ */
+bool magik(s32b p);
/*
* Generates a random long integer X where O<=X<M.
* The integer X falls along a uniform distribution.
* For example, if M is 100, you get "percentile dice"
*/
-#define rand_int(M) \
- (Rand_div(M))
+s32b rand_int(s32b m);
+
+/*
+ * Generate a random long integer X where 1<=X<=M
+ * Also, "correctly" handle the case of M<=1
+ */
+s32b randint(s32b m);
/*
* Generates a random long integer X where A<=X<=B
* The integer X falls along a uniform distribution.
* Note: rand_range(0,N-1) == rand_int(N)
*/
-#define rand_range(A,B) \
- ((A) + (rand_int(1+(B)-(A))))
+s32b rand_range(s32b a, s32b b);
/*
* Generate a random long integer X where A-D<=X<=A+D
* The integer X falls along a uniform distribution.
* Note: rand_spread(A,D) == rand_range(A-D,A+D)
*/
-#define rand_spread(A,D) \
- ((A) + (rand_int(1+(D)+(D))) - (D))
-
-
-/*
- * Generate a random long integer X where 1<=X<=M
- * Also, "correctly" handle the case of M<=1
- */
-#define randint(M) \
- (rand_int(M) + 1)
-
-
-/*
- * Evaluate to TRUE "P" percent of the time
- */
-#define magik(P) \
- (rand_int(100) < (P))
-
-
-
-
-/**** Available Variables ****/
-
-
-extern bool_ Rand_quick;
-extern u32b Rand_value;
-extern u16b Rand_place;
-extern u32b Rand_state[RAND_DEG];
-
-
-/**** Available Functions ****/
-
-
-extern void Rand_state_init(u32b seed);
-extern s32b Rand_mod(s32b m);
-extern s32b Rand_div(s32b m);
-extern s16b randnor(int mean, int stand);
-extern s32b damroll(s16b num, s16b sides);
-extern s32b maxroll(s16b num, s16b sides);
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
+s32b rand_spread(s32b a, s32b d);