summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/cmd1.c3
-rw-r--r--src/cmd3.c1
-rw-r--r--src/cmd5.c2
-rw-r--r--src/cmd7.c1
-rw-r--r--src/dungeon.c3
-rw-r--r--src/externs.h4
-rw-r--r--src/init2.c5
-rw-r--r--src/loadsave.c1
-rw-r--r--src/melee2.c2
-rw-r--r--src/object1.c1
-rw-r--r--src/plots.c1
-rw-r--r--src/powers.c2
-rw-r--r--src/q_god.c3
-rw-r--r--src/quark.c88
-rw-r--r--src/quark.h10
-rw-r--r--src/randart.c2
-rw-r--r--src/squeltch.c3
-rw-r--r--src/store.c2
-rw-r--r--src/util.c68
-rw-r--r--src/variable.c11
-rw-r--r--src/xtra2.c3
22 files changed, 134 insertions, 83 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 22563cd4..0e71e07b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -15,6 +15,7 @@ SET(SRCS
generate.c gen_maze.c gen_evol.c wild.c levels.c store.c bldg.c
cmovie.c
wizard2.c init2.c birth.c wizard1.c init1.c main.c
+ quark.c
# Lua bits:
lua_bind.c script.c
)
diff --git a/src/cmd1.c b/src/cmd1.c
index ce43c008..98fa264b 100644
--- a/src/cmd1.c
+++ b/src/cmd1.c
@@ -11,6 +11,9 @@
*/
#include "angband.h"
+
+#include "quark.h"
+
#define MAX_VAMPIRIC_DRAIN 100
diff --git a/src/cmd3.c b/src/cmd3.c
index 02dbc1c4..d648a0dc 100644
--- a/src/cmd3.c
+++ b/src/cmd3.c
@@ -12,6 +12,7 @@
#include "angband.h"
+#include "quark.h"
/*
* Display p_ptr->inventory
diff --git a/src/cmd5.c b/src/cmd5.c
index 7b7d334d..51fd6f17 100644
--- a/src/cmd5.c
+++ b/src/cmd5.c
@@ -15,6 +15,8 @@
#include <assert.h>
+#include "quark.h"
+
/* Maximum number of tries for teleporting */
#define MAX_TRIES 300
diff --git a/src/cmd7.c b/src/cmd7.c
index cb655526..0276a6b6 100644
--- a/src/cmd7.c
+++ b/src/cmd7.c
@@ -13,6 +13,7 @@
#include "angband.h"
+#include "quark.h"
/*
* Describe class powers of Mindcrafters
diff --git a/src/dungeon.c b/src/dungeon.c
index 9bcb6839..3bf40690 100644
--- a/src/dungeon.c
+++ b/src/dungeon.c
@@ -11,8 +11,11 @@
*/
#include "angband.h"
+
#include <assert.h>
+#include "quark.h"
+
#define TY_CURSE_CHANCE 100
#define DG_CURSE_CHANCE 50
#define AUTO_CURSE_CHANCE 15
diff --git a/src/externs.h b/src/externs.h
index 3a4c50b5..2bd48d10 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -321,8 +321,6 @@ extern cptr *macro__pat;
extern cptr *macro__act;
extern bool_ *macro__cmd;
extern char *macro__buf;
-extern s16b quark__num;
-extern cptr *quark__str;
extern u32b option_flag[8];
extern u32b option_mask[8];
extern u32b window_flag[ANGBAND_TERM_MAX];
@@ -2042,8 +2040,6 @@ extern void keymap_init(void);
extern errr macro_add(cptr pat, cptr act);
extern sint macro_find_exact(cptr pat);
extern char inkey(void);
-extern cptr quark_str(s16b num);
-extern s16b quark_add(cptr str);
extern void display_message(int x, int y, int split, byte color, cptr t);
extern void cmsg_print(byte color, cptr msg);
extern void msg_print(cptr msg);
diff --git a/src/init2.c b/src/init2.c
index dfb8a5dc..1e5ff17f 100644
--- a/src/init2.c
+++ b/src/init2.c
@@ -7,6 +7,7 @@
#include <assert.h>
#include "messages.h"
+#include "quark.h"
/*
* This file is used to initialise various variables and arrays for the
@@ -1948,8 +1949,8 @@ static errr init_misc(void)
/*** Prepare the various "bizarre" arrays ***/
- /* Quark variables */
- C_MAKE(quark__str, QUARK_MAX, cptr);
+ /* Initialize quark subsystem */
+ quark_init();
/* Initialize messages subsystem */
message_init();
diff --git a/src/loadsave.c b/src/loadsave.c
index de3bcd60..4ec7a02a 100644
--- a/src/loadsave.c
+++ b/src/loadsave.c
@@ -7,6 +7,7 @@
#include "angband.h"
#include "messages.h"
+#include "quark.h"
static void do_byte(byte *, int);
static void do_bool(bool_ *, int);
diff --git a/src/melee2.c b/src/melee2.c
index 2880c99c..5443a214 100644
--- a/src/melee2.c
+++ b/src/melee2.c
@@ -16,7 +16,9 @@
*/
#include "angband.h"
+
#include "messages.h"
+#include "quark.h"
#define SPEAK_CHANCE 8
#define GRINDNOISE 20
diff --git a/src/object1.c b/src/object1.c
index 7d40a8c3..21161dea 100644
--- a/src/object1.c
+++ b/src/object1.c
@@ -12,6 +12,7 @@
#include "angband.h"
+#include "quark.h"
/*
* Hack -- note that "TERM_MULTI" is now just "TERM_VIOLET".
diff --git a/src/plots.c b/src/plots.c
index 754ab401..ce60b446 100644
--- a/src/plots.c
+++ b/src/plots.c
@@ -15,6 +15,7 @@
#include <assert.h>
#include "messages.h"
+#include "quark.h"
/* #define DEBUG_HOOK */
diff --git a/src/powers.c b/src/powers.c
index a12d55f6..afc4a13a 100644
--- a/src/powers.c
+++ b/src/powers.c
@@ -12,6 +12,8 @@
#include "angband.h"
+#include "quark.h"
+
/*
* Note: return value indicates the amount of mana to use
*/
diff --git a/src/q_god.c b/src/q_god.c
index a01a60a9..82f90a25 100644
--- a/src/q_god.c
+++ b/src/q_god.c
@@ -1,6 +1,9 @@
#include "angband.h"
+
#include <assert.h>
+#include "quark.h"
+
#define cquest (quest[QUEST_GOD])
#define cquest_quests_given (cquest.data[0])
#define cquest_relics_found (cquest.data[1])
diff --git a/src/quark.c b/src/quark.c
new file mode 100644
index 00000000..32efaaa0
--- /dev/null
+++ b/src/quark.c
@@ -0,0 +1,88 @@
+#include "quark.h"
+
+#include "angband.h"
+
+/*
+ * The number of quarks
+ */
+static s16b quark__num = 0;
+
+
+/*
+ * The pointers to the quarks [QUARK_MAX]
+ */
+static cptr *quark__str = NULL;
+
+
+/*
+ * Initialize the quark subsystem
+ */
+void quark_init()
+{
+ quark__num = 0;
+ C_MAKE(quark__str, QUARK_MAX, cptr);
+}
+
+
+/*
+* We use a global array for all inscriptions to reduce the memory
+* spent maintaining inscriptions. Of course, it is still possible
+* to run out of inscription memory, especially if too many different
+* inscriptions are used, but hopefully this will be rare.
+*
+* We use dynamic string allocation because otherwise it is necessary
+* to pre-guess the amount of quark activity. We limit the total
+* number of quarks, but this is much easier to "expand" as needed.
+*
+* Any two items with the same inscription will have the same "quark"
+* index, which should greatly reduce the need for inscription space.
+*
+* Note that "quark zero" is NULL and should not be "dereferenced".
+*/
+
+/*
+* Add a new "quark" to the set of quarks.
+*/
+s16b quark_add(cptr str)
+{
+ int i;
+
+ /* Look for an existing quark */
+ for (i = 1; i < quark__num; i++)
+ {
+ /* Check for equality */
+ if (streq(quark__str[i], str)) return (i);
+ }
+
+ /* Paranoia -- Require room */
+ if (quark__num == QUARK_MAX) return (0);
+
+ /* New maximal quark */
+ quark__num = i + 1;
+
+ /* Add a new quark */
+ quark__str[i] = string_make(str);
+
+ /* Return the index */
+ return (i);
+}
+
+
+/*
+* This function looks up a quark
+*/
+cptr quark_str(s16b i)
+{
+ cptr q;
+
+ /* Verify */
+ if ((i < 0) || (i >= quark__num)) i = 0;
+
+ /* Access the quark */
+ q = quark__str[i];
+
+ /* Return the quark */
+ return (q);
+}
+
+
diff --git a/src/quark.h b/src/quark.h
new file mode 100644
index 00000000..93cb938f
--- /dev/null
+++ b/src/quark.h
@@ -0,0 +1,10 @@
+#ifndef H_eeb941c7_1a44_405a_8db3_ba14732c5b94
+#define H_eeb941c7_1a44_405a_8db3_ba14732c5b94
+
+#include "h-type.h"
+
+void quark_init();
+cptr quark_str(s16b num);
+s16b quark_add(cptr str);
+
+#endif
diff --git a/src/randart.c b/src/randart.c
index 580fa144..10fd51b0 100644
--- a/src/randart.c
+++ b/src/randart.c
@@ -12,6 +12,8 @@
#include "angband.h"
+#include "quark.h"
+
/* Chance of using syllables to form the name instead of the "template" files */
#define TABLE_NAME 45
#define A_CURSED 13
diff --git a/src/squeltch.c b/src/squeltch.c
index 5fb95d75..d79e1989 100644
--- a/src/squeltch.c
+++ b/src/squeltch.c
@@ -11,8 +11,11 @@
*/
#include "angband.h"
+
#include <jansson.h>
+#include "quark.h"
+
#define RULES_MAX 4096
#define STACK_MAX 1024
diff --git a/src/store.c b/src/store.c
index e62701d9..cca3be85 100644
--- a/src/store.c
+++ b/src/store.c
@@ -12,6 +12,8 @@
#include "angband.h"
+#include "quark.h"
+
#define STORE_GENERAL_STORE "General Store"
#define STORE_ARMOURY "Armoury"
#define STORE_WEAPONSMITH "Weaponsmith"
diff --git a/src/util.c b/src/util.c
index a9a9d10a..cf72eb1f 100644
--- a/src/util.c
+++ b/src/util.c
@@ -4,8 +4,9 @@
#include "angband.h"
-#include "messages.h"
+#include "messages.h"
+#include "quark.h"
@@ -2064,71 +2065,6 @@ char inkey(void)
return (ch);
}
-
-
-
-/*
-* We use a global array for all inscriptions to reduce the memory
-* spent maintaining inscriptions. Of course, it is still possible
-* to run out of inscription memory, especially if too many different
-* inscriptions are used, but hopefully this will be rare.
-*
-* We use dynamic string allocation because otherwise it is necessary
-* to pre-guess the amount of quark activity. We limit the total
-* number of quarks, but this is much easier to "expand" as needed.
-*
-* Any two items with the same inscription will have the same "quark"
-* index, which should greatly reduce the need for inscription space.
-*
-* Note that "quark zero" is NULL and should not be "dereferenced".
-*/
-
-/*
-* Add a new "quark" to the set of quarks.
-*/
-s16b quark_add(cptr str)
-{
- int i;
-
- /* Look for an existing quark */
- for (i = 1; i < quark__num; i++)
- {
- /* Check for equality */
- if (streq(quark__str[i], str)) return (i);
- }
-
- /* Paranoia -- Require room */
- if (quark__num == QUARK_MAX) return (0);
-
- /* New maximal quark */
- quark__num = i + 1;
-
- /* Add a new quark */
- quark__str[i] = string_make(str);
-
- /* Return the index */
- return (i);
-}
-
-
-/*
-* This function looks up a quark
-*/
-cptr quark_str(s16b i)
-{
- cptr q;
-
- /* Verify */
- if ((i < 0) || (i >= quark__num)) i = 0;
-
- /* Access the quark */
- q = quark__str[i];
-
- /* Return the quark */
- return (q);
-}
-
-
/*
* Hack -- flush
*/
diff --git a/src/variable.c b/src/variable.c
index ab9bf699..af89fdcf 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -483,17 +483,6 @@ char *macro__buf;
/*
- * The number of quarks
- */
-s16b quark__num;
-
-/*
- * The pointers to the quarks [QUARK_MAX]
- */
-cptr *quark__str;
-
-
-/*
* The array of normal options
*/
u32b option_flag[8];
diff --git a/src/xtra2.c b/src/xtra2.c
index 1569f442..6594e482 100644
--- a/src/xtra2.c
+++ b/src/xtra2.c
@@ -12,8 +12,11 @@
*/
#include "angband.h"
+
#include <assert.h>
+#include "quark.h"
+
/*
* Invoke The Rush
*/