summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2015-02-23 09:12:01 +0100
committerBardur Arantsson <bardur@scientician.net>2015-02-23 09:12:01 +0100
commit37ac44add61e4547507770017dcb85b53c20acb5 (patch)
tree20d678f3d06cf850b39b1c20b1d21f9c8b49a5db /src
parent37cea853947851134b2e6f2e338d85ddc5378616 (diff)
Split util.cc function declarations into separate header files
We need one .h file and one .hpp since some of the functions are being called from plain C code.
Diffstat (limited to 'src')
-rw-r--r--src/birth.cc2
-rw-r--r--src/bldg.cc2
-rw-r--r--src/cave.cc2
-rw-r--r--src/cmd1.cc2
-rw-r--r--src/cmd2.cc2
-rw-r--r--src/cmd3.cc2
-rw-r--r--src/cmd4.cc2
-rw-r--r--src/cmd5.cc2
-rw-r--r--src/cmd6.cc1
-rw-r--r--src/cmd7.cc2
-rw-r--r--src/corrupt.cc1
-rw-r--r--src/dungeon.cc2
-rw-r--r--src/externs.h79
-rw-r--r--src/files.cc2
-rw-r--r--src/generate.cc1
-rw-r--r--src/gods.cc2
-rw-r--r--src/help.cc1
-rw-r--r--src/hiscore.cc5
-rw-r--r--src/init1.cc2
-rw-r--r--src/init2.cc2
-rw-r--r--src/joke.cc1
-rw-r--r--src/levels.cc2
-rw-r--r--src/loadsave.cc2
-rw-r--r--src/lua_bind.cc3
-rw-r--r--src/main-gcu.c1
-rw-r--r--src/main-gtk2.c1
-rw-r--r--src/main-sdl.c2
-rw-r--r--src/main-win.c1
-rw-r--r--src/main-x11.c1
-rw-r--r--src/main.c1
-rw-r--r--src/melee1.cc1
-rw-r--r--src/melee2.cc1
-rw-r--r--src/modules.cc2
-rw-r--r--src/monster1.cc2
-rw-r--r--src/monster2.cc1
-rw-r--r--src/monster3.cc2
-rw-r--r--src/notes.cc3
-rw-r--r--src/object1.cc2
-rw-r--r--src/object2.cc1
-rw-r--r--src/powers.cc2
-rw-r--r--src/q_betwen.cc1
-rw-r--r--src/q_bounty.cc2
-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_invas.cc1
-rw-r--r--src/q_library.cc2
-rw-r--r--src/q_main.cc3
-rw-r--r--src/q_narsil.cc2
-rw-r--r--src/q_nazgul.cc1
-rw-r--r--src/q_nirna.cc1
-rw-r--r--src/q_one.cc1
-rw-r--r--src/q_poison.cc1
-rw-r--r--src/q_shroom.cc1
-rw-r--r--src/q_spider.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_ultrag.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.cc2
-rw-r--r--src/spells2.cc2
-rw-r--r--src/spells3.cc3
-rw-r--r--src/spells4.cc2
-rw-r--r--src/squelch/automatizer.cc1
-rw-r--r--src/squelch/condition.cc1
-rw-r--r--src/squelch/condition_metadata.cc2
-rw-r--r--src/squelch/rule.cc1
-rw-r--r--src/squeltch.cc2
-rw-r--r--src/status.cc2
-rw-r--r--src/store.cc2
-rw-r--r--src/traps.cc1
-rw-r--r--src/util.cc7
-rw-r--r--src/util.h21
-rw-r--r--src/util.hpp68
-rw-r--r--src/variable.cc1
-rw-r--r--src/wild.cc1
-rw-r--r--src/wizard1.cc2
-rw-r--r--src/wizard2.cc2
-rw-r--r--src/xtra1.cc2
-rw-r--r--src/xtra2.cc2
88 files changed, 215 insertions, 92 deletions
diff --git a/src/birth.cc b/src/birth.cc
index fe65ad45..8004a9b6 100644
--- a/src/birth.cc
+++ b/src/birth.cc
@@ -24,6 +24,8 @@
#include "spells3.hpp"
#include "spells5.hpp"
#include "store.hpp"
+#include "util.hpp"
+#include "util.h"
#include "xtra1.hpp"
#include "xtra2.hpp"
diff --git a/src/bldg.cc b/src/bldg.cc
index 414f1758..95a52498 100644
--- a/src/bldg.cc
+++ b/src/bldg.cc
@@ -22,6 +22,8 @@
#include "q_bounty.h"
#include "spells2.hpp"
#include "store.hpp"
+#include "util.hpp"
+#include "util.h"
#include "xtra1.hpp"
#include "xtra2.hpp"
diff --git a/src/cave.cc b/src/cave.cc
index fb708d5d..39382cf4 100644
--- a/src/cave.cc
+++ b/src/cave.cc
@@ -3,6 +3,8 @@
#include "angband.h"
#include "q_rand.h"
#include "spells1.hpp"
+#include "util.hpp"
+#include "util.h"
#include <cassert>
#include <vector>
diff --git a/src/cmd1.cc b/src/cmd1.cc
index 4dff0df2..503b86d9 100644
--- a/src/cmd1.cc
+++ b/src/cmd1.cc
@@ -21,6 +21,8 @@
#include "spells2.hpp"
#include "spells3.hpp"
#include "traps.hpp"
+#include "util.hpp"
+#include "util.h"
#include "xtra1.hpp"
#include "xtra2.hpp"
diff --git a/src/cmd2.cc b/src/cmd2.cc
index b1504acb..ecf859ba 100644
--- a/src/cmd2.cc
+++ b/src/cmd2.cc
@@ -19,6 +19,8 @@
#include "spells2.hpp"
#include "spells3.hpp"
#include "traps.hpp"
+#include "util.hpp"
+#include "util.h"
#include "xtra1.hpp"
#include "xtra2.hpp"
diff --git a/src/cmd3.cc b/src/cmd3.cc
index 5a41af1e..d12f785a 100644
--- a/src/cmd3.cc
+++ b/src/cmd3.cc
@@ -14,6 +14,8 @@
#include "quark.h"
#include "squeltch.hpp"
#include "store.hpp"
+#include "util.hpp"
+#include "util.h"
#include "xtra1.hpp"
#include "xtra2.hpp"
diff --git a/src/cmd4.cc b/src/cmd4.cc
index 30d2557b..dbf0b2ef 100644
--- a/src/cmd4.cc
+++ b/src/cmd4.cc
@@ -14,6 +14,8 @@
#include "notes.hpp"
#include "skills.hpp"
#include "squeltch.hpp"
+#include "util.hpp"
+#include "util.h"
#include "xtra1.hpp"
#include <cassert>
diff --git a/src/cmd5.cc b/src/cmd5.cc
index 93f29a99..b61231e0 100644
--- a/src/cmd5.cc
+++ b/src/cmd5.cc
@@ -18,6 +18,8 @@
#include "spells2.hpp"
#include "spells4.hpp"
#include "spells5.hpp"
+#include "util.hpp"
+#include "util.h"
#include "quark.h"
#include "wizard2.hpp"
#include "xtra1.hpp"
diff --git a/src/cmd6.cc b/src/cmd6.cc
index 43033fbe..01a11c95 100644
--- a/src/cmd6.cc
+++ b/src/cmd6.cc
@@ -23,6 +23,7 @@
#include "spells2.hpp"
#include "spells5.hpp"
#include "store.hpp"
+#include "util.hpp"
#include "wizard2.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
diff --git a/src/cmd7.cc b/src/cmd7.cc
index 4b3e4ec0..7b4272b2 100644
--- a/src/cmd7.cc
+++ b/src/cmd7.cc
@@ -19,6 +19,8 @@
#include "skills.hpp"
#include "spells1.hpp"
#include "spells2.hpp"
+#include "util.hpp"
+#include "util.h"
#include "xtra1.hpp"
#include "xtra2.hpp"
diff --git a/src/corrupt.cc b/src/corrupt.cc
index f273cdde..c5dd5c51 100644
--- a/src/corrupt.cc
+++ b/src/corrupt.cc
@@ -1,5 +1,6 @@
#include "angband.h"
#include "xtra2.hpp"
+#include "util.hpp"
#include <cassert>
diff --git a/src/dungeon.cc b/src/dungeon.cc
index e52b00e7..287d5f2f 100644
--- a/src/dungeon.cc
+++ b/src/dungeon.cc
@@ -32,6 +32,8 @@
#include "spells5.hpp"
#include "squeltch.hpp"
#include "store.hpp"
+#include "util.hpp"
+#include "util.h"
#include "xtra1.hpp"
#include "xtra2.hpp"
diff --git a/src/externs.h b/src/externs.h
index 12da39c1..fc336de6 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -760,79 +760,6 @@ extern s16b m_bonus(int max, int level);
extern void object_gain_level(object_type *o_ptr);
extern s32b flag_cost(object_type * o_ptr, int plusses);
-/* util.c */
-extern s32b rescale(s32b x, s32b max, s32b new_max);
-extern bool_ input_box(cptr text, int y, int x, char *buf, int max);
-extern void draw_box(int y, int x, int h, int w);
-extern void display_list(int y, int x, int h, int w, cptr title, cptr *list, int max, int begin, int sel, byte sel_color);
-extern cptr get_player_race_name(int pr, int ps);
-extern cptr get_month_name(int month, bool_ full, bool_ compact);
-extern cptr get_day(int day);
-extern s32b bst(s32b what, s32b t);
-extern errr path_parse(char *buf, int max, cptr file);
-extern errr path_temp(char *buf, int max);
-extern errr path_build(char *buf, int max, cptr path, cptr file);
-extern FILE *my_fopen(cptr file, cptr mode);
-extern errr my_fgets(FILE *fff, char *buf, huge n);
-extern errr my_fputs(FILE *fff, cptr buf, huge n);
-extern errr my_fclose(FILE *fff);
-extern errr fd_kill(cptr file);
-extern errr fd_move(cptr file, cptr what);
-extern int fd_make(cptr file, int mode);
-extern int fd_open(cptr file, int flags);
-extern errr fd_seek(int fd, huge n);
-extern errr fd_read(int fd, char *buf, huge n);
-extern errr fd_write(int fd, cptr buf, huge n);
-extern errr fd_close(int fd);
-extern void flush(void);
-extern void bell(void);
-extern void sound(int num);
-extern void move_cursor(int row, int col);
-extern void text_to_ascii(char *buf, cptr str);
-extern void ascii_to_text(char *buf, cptr str);
-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 char inkey_scan(void);
-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);
-extern void cmsg_format(byte color, cptr fmt, ...);
-extern void msg_format(cptr fmt, ...);
-extern void screen_save(void);
-extern void screen_load(void);
-extern void c_put_str(byte attr, cptr str, int row, int col);
-extern void put_str(cptr str, int row, int col);
-extern void c_prt(byte attr, cptr str, int row, int col);
-extern void prt(cptr str, int row, int col);
-extern void text_out_to_screen(byte a, cptr str);
-extern void text_out_to_file(byte a, cptr str);
-extern void text_out(cptr str);
-extern void text_out_c(byte a, cptr str);
-extern void clear_screen(void);
-extern void clear_from(int row);
-extern bool_ askfor_aux_complete;
-extern bool_ askfor_aux(char *buf, int len);
-extern bool_ get_string(cptr prompt, char *buf, int len);
-extern bool_ get_check(cptr prompt);
-extern bool_ get_com(cptr prompt, char *command);
-extern s32b get_quantity(cptr prompt, s32b max);
-extern void pause_line(int row);
-extern char request_command_ignore_keymaps[];
-extern bool_ request_command_inven_mode;
-extern void request_command(int shopping);
-extern bool_ is_a_vowel(int ch);
-extern int get_keymap_dir(char ch);
-extern byte count_bits(u32b array);
-extern void strlower(char *buf);
-extern int test_monster_name(cptr name);
-extern int test_mego_name(cptr name);
-extern int test_item_name(cptr name);
-extern char msg_box(cptr text, int y, int x);
-extern timer_type *new_timer(void (*callback)(), s32b delay);
-extern int get_keymap_mode();
-
/* main.c */
extern bool_ private_check_user_directory(cptr dirpath);
@@ -866,12 +793,6 @@ extern tval_desc2 tvals[];
extern void user_name(char *buf, int id);
#endif
-/* util.c */
-extern void repeat_push(int what);
-extern bool_ repeat_pull(int *what);
-extern void repeat_check(void);
-extern void get_count(int number, int max);
-
/* script.c */
extern void init_lua_init(void);
diff --git a/src/files.cc b/src/files.cc
index f4621afd..2d6d22d8 100644
--- a/src/files.cc
+++ b/src/files.cc
@@ -16,6 +16,8 @@
#include "notes.hpp"
#include "skills.hpp"
#include "spells2.hpp"
+#include "util.hpp"
+#include "util.h"
#include "xtra1.hpp"
#include <memory>
diff --git a/src/generate.cc b/src/generate.cc
index bfab3bd1..a750abc6 100644
--- a/src/generate.cc
+++ b/src/generate.cc
@@ -12,6 +12,7 @@
#include "randart.hpp"
#include "spells1.hpp"
#include "traps.hpp"
+#include "util.hpp"
#include <cassert>
#include <memory>
diff --git a/src/gods.cc b/src/gods.cc
index 0c3297ed..83fd3aae 100644
--- a/src/gods.cc
+++ b/src/gods.cc
@@ -9,6 +9,8 @@
#include "angband.h"
#include "skills.hpp"
+#include "util.hpp"
+#include "util.h"
#include "xtra2.hpp"
#include <cassert>
diff --git a/src/help.cc b/src/help.cc
index b57ce0b3..68c3500c 100644
--- a/src/help.cc
+++ b/src/help.cc
@@ -12,6 +12,7 @@
#include "angband.h"
#include "hooks.h"
#include "skills.hpp"
+#include "util.hpp"
#define DESC_MAX 14
#define TRIGGERED_HELP_MAX 19
diff --git a/src/hiscore.cc b/src/hiscore.cc
index 357026da..2f17237f 100644
--- a/src/hiscore.cc
+++ b/src/hiscore.cc
@@ -1,8 +1,9 @@
#include "hiscore.h"
-#include <assert.h>
-
#include "angband.h"
+#include "util.hpp"
+
+#include <cassert>
int highscore_seek(int highscore_fd, int i)
{
diff --git a/src/init1.cc b/src/init1.cc
index 9af6d44c..f689e940 100644
--- a/src/init1.cc
+++ b/src/init1.cc
@@ -4,6 +4,8 @@
#include "skills.hpp"
#include "spells5.hpp"
#include "traps.hpp"
+#include "util.hpp"
+#include "util.h"
#include <boost/algorithm/string/predicate.hpp>
diff --git a/src/init2.cc b/src/init2.cc
index b6ce8894..16f5d8be 100644
--- a/src/init2.cc
+++ b/src/init2.cc
@@ -8,6 +8,8 @@
#include "spells3.hpp"
#include "squeltch.hpp"
#include "tome/make_array.hpp"
+#include "util.hpp"
+#include "util.h"
#include <cassert>
#include <type_traits>
diff --git a/src/joke.cc b/src/joke.cc
index 273c333a..ab1f070c 100644
--- a/src/joke.cc
+++ b/src/joke.cc
@@ -1,4 +1,5 @@
#include "angband.h"
+#include "util.hpp"
static void gen_joke_place_monster(int r_idx)
{
diff --git a/src/levels.cc b/src/levels.cc
index 71148fc5..54c697d0 100644
--- a/src/levels.cc
+++ b/src/levels.cc
@@ -11,6 +11,8 @@
*/
#include "angband.h"
+#include "util.hpp"
+#include "util.h"
/*
diff --git a/src/loadsave.cc b/src/loadsave.cc
index 4b774fdd..9aff9985 100644
--- a/src/loadsave.cc
+++ b/src/loadsave.cc
@@ -4,6 +4,8 @@
#include "modules.hpp"
#include "quark.h"
#include "hooks.h"
+#include "util.hpp"
+#include "util.h"
#include "xtra2.hpp"
#include <cassert>
diff --git a/src/lua_bind.cc b/src/lua_bind.cc
index 428dfc26..8857c222 100644
--- a/src/lua_bind.cc
+++ b/src/lua_bind.cc
@@ -14,11 +14,12 @@
#include "angband.h"
#include "cmd7.hpp"
#include "corrupt.hpp"
+#include "range.h"
#include "skills.hpp"
#include "spell_type.hpp"
#include "spells2.hpp"
#include "spells5.hpp"
-#include "range.h"
+#include "util.hpp"
#include <cassert>
#include <functional>
diff --git a/src/main-gcu.c b/src/main-gcu.c
index 357b889e..790f02f8 100644
--- a/src/main-gcu.c
+++ b/src/main-gcu.c
@@ -40,6 +40,7 @@
#include "angband.h"
+#include "util.h"
#ifdef USE_GCU
diff --git a/src/main-gtk2.c b/src/main-gtk2.c
index ab3ce50e..6fc85570 100644
--- a/src/main-gtk2.c
+++ b/src/main-gtk2.c
@@ -31,6 +31,7 @@
*/
#include "angband.h"
+#include "util.h"
/*
diff --git a/src/main-sdl.c b/src/main-sdl.c
index c9e70b73..03023b86 100644
--- a/src/main-sdl.c
+++ b/src/main-sdl.c
@@ -26,6 +26,8 @@
#ifdef USE_SDL
#include "angband.h"
+#include "util.h"
+
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
diff --git a/src/main-win.c b/src/main-win.c
index 26c55a8d..523e189e 100644
--- a/src/main-win.c
+++ b/src/main-win.c
@@ -68,6 +68,7 @@
#include "angband.h"
+#include "util.h"
#ifdef WINDOWS
diff --git a/src/main-x11.c b/src/main-x11.c
index 41d629cd..cb5eaa10 100644
--- a/src/main-x11.c
+++ b/src/main-x11.c
@@ -93,6 +93,7 @@
*/
#include "angband.h"
+#include "util.h"
#ifdef USE_X11
diff --git a/src/main.c b/src/main.c
index 467c4900..531d0edd 100644
--- a/src/main.c
+++ b/src/main.c
@@ -9,6 +9,7 @@
*/
#include "angband.h"
+#include "util.h"
diff --git a/src/melee1.cc b/src/melee1.cc
index b8a119f5..412c3b8b 100644
--- a/src/melee1.cc
+++ b/src/melee1.cc
@@ -14,6 +14,7 @@
#include "spells1.hpp"
#include "spells2.hpp"
#include "store.hpp"
+#include "util.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
diff --git a/src/melee2.cc b/src/melee2.cc
index 860c7f94..acff1f87 100644
--- a/src/melee2.cc
+++ b/src/melee2.cc
@@ -22,6 +22,7 @@
#include "spells1.hpp"
#include "spells2.hpp"
#include "traps.hpp"
+#include "util.hpp"
#include "xtra2.hpp"
#include <cassert>
diff --git a/src/modules.cc b/src/modules.cc
index 2c6d886c..0e82cbe8 100644
--- a/src/modules.cc
+++ b/src/modules.cc
@@ -11,6 +11,8 @@
#include "corrupt.hpp"
#include "hooks.h"
#include "spells2.hpp"
+#include "util.hpp"
+#include "util.h"
#include <cassert>
#include <chrono>
diff --git a/src/monster1.cc b/src/monster1.cc
index 3f4a3adc..a0a75a67 100644
--- a/src/monster1.cc
+++ b/src/monster1.cc
@@ -11,7 +11,7 @@
*/
#include "angband.h"
-
+#include "util.hpp"
/*
* Pronoun arrays, by gender.
diff --git a/src/monster2.cc b/src/monster2.cc
index 12cb81af..8582092a 100644
--- a/src/monster2.cc
+++ b/src/monster2.cc
@@ -12,6 +12,7 @@
#include "randart.hpp"
#include "spells1.hpp"
#include "spells2.hpp"
+#include "util.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
diff --git a/src/monster3.cc b/src/monster3.cc
index 9e7df503..039bcd94 100644
--- a/src/monster3.cc
+++ b/src/monster3.cc
@@ -10,6 +10,8 @@
#include "cmd2.hpp"
#include "gods.hpp"
#include "skills.hpp"
+#include "util.hpp"
+#include "util.h"
#include "xtra2.hpp"
/*
diff --git a/src/notes.cc b/src/notes.cc
index c223808d..46d32513 100644
--- a/src/notes.cc
+++ b/src/notes.cc
@@ -8,7 +8,10 @@
*/
#include "notes.hpp"
+
#include "angband.h"
+#include "util.hpp"
+#include "util.h"
/*
* Show the notes file on the screen
diff --git a/src/object1.cc b/src/object1.cc
index e33f2193..2f4ddf79 100644
--- a/src/object1.cc
+++ b/src/object1.cc
@@ -18,6 +18,8 @@
#include "spell_type.hpp"
#include "spells5.hpp"
#include "squeltch.hpp"
+#include "util.hpp"
+#include "util.h"
#include "xtra1.hpp"
#include <cassert>
diff --git a/src/object2.cc b/src/object2.cc
index 14e56b2d..e4a363c4 100644
--- a/src/object2.cc
+++ b/src/object2.cc
@@ -17,6 +17,7 @@
#include "spells2.hpp"
#include "spells3.hpp"
#include "spells5.hpp"
+#include "util.hpp"
#include "traps.hpp"
#include "xtra1.hpp"
diff --git a/src/powers.cc b/src/powers.cc
index cef654c6..60942f96 100644
--- a/src/powers.cc
+++ b/src/powers.cc
@@ -18,6 +18,8 @@
#include "spells1.hpp"
#include "spells2.hpp"
#include "traps.hpp"
+#include "util.hpp"
+#include "util.h"
#include "xtra2.hpp"
/*
diff --git a/src/q_betwen.cc b/src/q_betwen.cc
index 98d15570..d3c7a798 100644
--- a/src/q_betwen.cc
+++ b/src/q_betwen.cc
@@ -2,6 +2,7 @@
#include "cave.hpp"
#include "hooks.h"
+#include "util.hpp"
#define cquest (quest[QUEST_BETWEEN])
diff --git a/src/q_bounty.cc b/src/q_bounty.cc
index b7cd150e..80d71a53 100644
--- a/src/q_bounty.cc
+++ b/src/q_bounty.cc
@@ -1,5 +1,7 @@
#include "q_bounty.h"
+#include "util.hpp"
+
#define cquest (quest[QUEST_BOUNTY])
#define bounty_quest_monster (cquest.data[0])
diff --git a/src/q_dragons.cc b/src/q_dragons.cc
index 0ea831b3..d295526d 100644
--- a/src/q_dragons.cc
+++ b/src/q_dragons.cc
@@ -2,6 +2,7 @@
#include "cave.hpp"
#include "hooks.h"
+#include "util.hpp"
#define cquest (quest[QUEST_DRAGONS])
diff --git a/src/q_eol.cc b/src/q_eol.cc
index fab59960..19cc14e2 100644
--- a/src/q_eol.cc
+++ b/src/q_eol.cc
@@ -3,6 +3,7 @@
#include "cave.hpp"
#include "hooks.h"
#include "traps.hpp"
+#include "util.hpp"
#include <cassert>
diff --git a/src/q_evil.cc b/src/q_evil.cc
index 73972c95..0f14d48b 100644
--- a/src/q_evil.cc
+++ b/src/q_evil.cc
@@ -2,6 +2,7 @@
#include "cave.hpp"
#include "hooks.h"
+#include "util.hpp"
#define cquest (quest[QUEST_EVIL])
diff --git a/src/q_fireprof.cc b/src/q_fireprof.cc
index 23cb8eba..fa901f8e 100644
--- a/src/q_fireprof.cc
+++ b/src/q_fireprof.cc
@@ -2,6 +2,7 @@
#include "quark.h"
#include "hooks.h"
#include "traps.hpp"
+#include "util.hpp"
#include <cassert>
diff --git a/src/q_god.cc b/src/q_god.cc
index 7ce8b8f7..e10a597d 100644
--- a/src/q_god.cc
+++ b/src/q_god.cc
@@ -1,6 +1,7 @@
#include "q_god.h"
#include "quark.h"
#include "hooks.h"
+#include "util.hpp"
#include <assert.h>
diff --git a/src/q_haunted.cc b/src/q_haunted.cc
index a78c5e94..a3f96249 100644
--- a/src/q_haunted.cc
+++ b/src/q_haunted.cc
@@ -3,6 +3,7 @@
#include "cave.hpp"
#include "hooks.h"
#include "traps.hpp"
+#include "util.hpp"
#define cquest (quest[QUEST_HAUNTED])
diff --git a/src/q_hobbit.cc b/src/q_hobbit.cc
index 4d8085d5..94bc9ffe 100644
--- a/src/q_hobbit.cc
+++ b/src/q_hobbit.cc
@@ -3,6 +3,7 @@
#include "cave.hpp"
#include "messages.h"
#include "hooks.h"
+#include "util.hpp"
#include <cassert>
diff --git a/src/q_invas.cc b/src/q_invas.cc
index 0a8c41b8..4bb23c08 100644
--- a/src/q_invas.cc
+++ b/src/q_invas.cc
@@ -2,6 +2,7 @@
#include "cave.hpp"
#include "hooks.h"
+#include "util.hpp"
#define cquest (quest[QUEST_INVASION])
diff --git a/src/q_library.cc b/src/q_library.cc
index b87b346c..9dab74f4 100644
--- a/src/q_library.cc
+++ b/src/q_library.cc
@@ -3,6 +3,8 @@
#include "hooks.h"
#include "spells3.hpp"
#include "spells4.hpp"
+#include "util.hpp"
+#include "util.h"
#include <cassert>
diff --git a/src/q_main.cc b/src/q_main.cc
index 73969f1a..866e7ffa 100644
--- a/src/q_main.cc
+++ b/src/q_main.cc
@@ -1,5 +1,8 @@
#include "q_main.h"
+
#include "hooks.h"
+#include "util.hpp"
+
#include <cassert>
GENERATE_MONSTER_LOOKUP_FN(get_necromancer, "The Necromancer of Dol Guldur")
diff --git a/src/q_narsil.cc b/src/q_narsil.cc
index cd0e5b4b..367e674d 100644
--- a/src/q_narsil.cc
+++ b/src/q_narsil.cc
@@ -1,5 +1,7 @@
#include "q_narsil.h"
+
#include "hooks.h"
+#include "util.hpp"
#define cquest (quest[QUEST_NARSIL])
diff --git a/src/q_nazgul.cc b/src/q_nazgul.cc
index 9e528ece..51e45ba8 100644
--- a/src/q_nazgul.cc
+++ b/src/q_nazgul.cc
@@ -2,6 +2,7 @@
#include "cave.hpp"
#include "hooks.h"
+#include "util.hpp"
#include <cassert>
diff --git a/src/q_nirna.cc b/src/q_nirna.cc
index 8f5678c5..8ca57d81 100644
--- a/src/q_nirna.cc
+++ b/src/q_nirna.cc
@@ -2,6 +2,7 @@
#include "cave.hpp"
#include "hooks.h"
+#include "util.hpp"
#define cquest (quest[QUEST_NIRNAETH])
diff --git a/src/q_one.cc b/src/q_one.cc
index 1aab348b..1b6cabe8 100644
--- a/src/q_one.cc
+++ b/src/q_one.cc
@@ -2,6 +2,7 @@
#include "gods.hpp"
#include "hooks.h"
+#include "util.hpp"
#define cquest (quest[QUEST_ONE])
diff --git a/src/q_poison.cc b/src/q_poison.cc
index 98d29d77..0e40ac91 100644
--- a/src/q_poison.cc
+++ b/src/q_poison.cc
@@ -4,6 +4,7 @@
#include "quark.h"
#include "messages.h"
#include "hooks.h"
+#include "util.hpp"
#define cquest (quest[QUEST_POISON])
diff --git a/src/q_shroom.cc b/src/q_shroom.cc
index b512484a..15258139 100644
--- a/src/q_shroom.cc
+++ b/src/q_shroom.cc
@@ -3,6 +3,7 @@
#include "cave.hpp"
#include "messages.h"
#include "hooks.h"
+#include "util.hpp"
#include <cassert>
diff --git a/src/q_spider.cc b/src/q_spider.cc
index dbee4255..81d3006d 100644
--- a/src/q_spider.cc
+++ b/src/q_spider.cc
@@ -3,6 +3,7 @@
#include "cave.hpp"
#include "gods.hpp"
#include "hooks.h"
+#include "util.hpp"
#define cquest (quest[QUEST_SPIDER])
diff --git a/src/q_thief.cc b/src/q_thief.cc
index eb686a48..417aa4c8 100644
--- a/src/q_thief.cc
+++ b/src/q_thief.cc
@@ -3,6 +3,7 @@
#include "cave.hpp"
#include "hooks.h"
#include "spells2.hpp"
+#include "util.hpp"
#define cquest (quest[QUEST_THIEVES])
diff --git a/src/q_thrain.cc b/src/q_thrain.cc
index 1590304c..c2008450 100644
--- a/src/q_thrain.cc
+++ b/src/q_thrain.cc
@@ -5,6 +5,7 @@
#include "quark.h"
#include "randart.hpp"
#include "messages.h"
+#include "util.hpp"
#include <cassert>
diff --git a/src/q_troll.cc b/src/q_troll.cc
index 5d547b1a..036a1ad7 100644
--- a/src/q_troll.cc
+++ b/src/q_troll.cc
@@ -2,6 +2,7 @@
#include "cave.hpp"
#include "hooks.h"
+#include "util.hpp"
#include <cassert>
diff --git a/src/q_ultrag.cc b/src/q_ultrag.cc
index 90f90e6d..53ba4633 100644
--- a/src/q_ultrag.cc
+++ b/src/q_ultrag.cc
@@ -2,6 +2,7 @@
#include "cave.hpp"
#include "hooks.h"
+#include "util.hpp"
#define cquest (quest[QUEST_ULTRA_GOOD])
diff --git a/src/q_wight.cc b/src/q_wight.cc
index a07c617c..f322c612 100644
--- a/src/q_wight.cc
+++ b/src/q_wight.cc
@@ -3,6 +3,7 @@
#include "cave.hpp"
#include "quark.h"
#include "hooks.h"
+#include "util.hpp"
#include <cassert>
diff --git a/src/q_wolves.cc b/src/q_wolves.cc
index 9a68c7ca..2afa173e 100644
--- a/src/q_wolves.cc
+++ b/src/q_wolves.cc
@@ -2,6 +2,7 @@
#include "cave.hpp"
#include "hooks.h"
+#include "util.hpp"
#define cquest (quest[QUEST_WOLVES])
diff --git a/src/randart.cc b/src/randart.cc
index 95bd6b1c..d1306c43 100644
--- a/src/randart.cc
+++ b/src/randart.cc
@@ -10,6 +10,7 @@
#include "mimic.hpp"
#include "quark.h"
#include "spells2.hpp"
+#include "util.hpp"
#include <memory>
#include <vector>
diff --git a/src/skills.cc b/src/skills.cc
index c3fb3835..1e73ed25 100644
--- a/src/skills.cc
+++ b/src/skills.cc
@@ -19,6 +19,7 @@
#include "spells4.hpp"
#include "traps.hpp"
#include "util.hpp"
+#include "util.h"
#include "xtra2.hpp"
#include <algorithm>
diff --git a/src/spells1.cc b/src/spells1.cc
index 189ad043..cd7ae11b 100644
--- a/src/spells1.cc
+++ b/src/spells1.cc
@@ -20,6 +20,8 @@
#include "spells5.hpp"
#include "squeltch.hpp"
#include "traps.hpp"
+#include "util.hpp"
+#include "util.h"
#include "xtra1.hpp"
#include "xtra2.hpp"
diff --git a/src/spells2.cc b/src/spells2.cc
index ad851251..62fa3818 100644
--- a/src/spells2.cc
+++ b/src/spells2.cc
@@ -16,6 +16,8 @@
#include "skills.hpp"
#include "spells1.hpp"
#include "spells3.hpp"
+#include "util.hpp"
+#include "util.h"
#include "xtra1.hpp"
#include "xtra2.hpp"
diff --git a/src/spells3.cc b/src/spells3.cc
index 22bede27..0e19a492 100644
--- a/src/spells3.cc
+++ b/src/spells3.cc
@@ -3,6 +3,7 @@
#include "angband.h"
#include "cave.hpp"
#include "cmd5.hpp"
+#include "mimic.hpp"
#include "skills.hpp"
#include "spell_type.hpp"
#include "spell_idx_list.hpp"
@@ -10,7 +11,7 @@
#include "spells2.hpp"
#include "spells4.hpp"
#include "spells5.hpp"
-#include "mimic.hpp"
+#include "util.hpp"
#include "xtra2.hpp"
#include <algorithm>
diff --git a/src/spells4.cc b/src/spells4.cc
index 4198ead5..a5ec074c 100644
--- a/src/spells4.cc
+++ b/src/spells4.cc
@@ -9,6 +9,8 @@
#include "spells3.hpp"
#include "spells5.hpp"
#include "spells6.hpp"
+#include "util.hpp"
+#include "util.h"
#include <algorithm>
#include <cassert>
diff --git a/src/squelch/automatizer.cc b/src/squelch/automatizer.cc
index 742a0727..0ea04dae 100644
--- a/src/squelch/automatizer.cc
+++ b/src/squelch/automatizer.cc
@@ -5,6 +5,7 @@
#include "tome/squelch/cursor.hpp"
#include "tome/squelch/tree_printer.hpp"
#include "angband.h"
+#include "util.hpp"
namespace squelch {
diff --git a/src/squelch/condition.cc b/src/squelch/condition.cc
index ea2e9e40..8f839129 100644
--- a/src/squelch/condition.cc
+++ b/src/squelch/condition.cc
@@ -8,6 +8,7 @@
#include "angband.h"
#include "skills.hpp"
#include "quark.h"
+#include "util.hpp"
namespace squelch {
diff --git a/src/squelch/condition_metadata.cc b/src/squelch/condition_metadata.cc
index 35e1e3f3..7011617a 100644
--- a/src/squelch/condition_metadata.cc
+++ b/src/squelch/condition_metadata.cc
@@ -6,6 +6,8 @@
#include "tome/squelch/object_status.hpp"
#include "angband.h"
#include "skills.hpp"
+#include "util.hpp"
+#include "util.h"
namespace squelch {
diff --git a/src/squelch/rule.cc b/src/squelch/rule.cc
index 060ae257..c538e310 100644
--- a/src/squelch/rule.cc
+++ b/src/squelch/rule.cc
@@ -7,6 +7,7 @@
#include "../angband.h"
#include "../modules.hpp"
#include "../quark.h"
+#include "../util.hpp"
namespace squelch {
diff --git a/src/squeltch.cc b/src/squeltch.cc
index 1ff2c721..4ed30f9a 100644
--- a/src/squeltch.cc
+++ b/src/squeltch.cc
@@ -24,6 +24,8 @@
#include "tome/squelch/cursor.hpp"
#include "tome/squelch/object_status.hpp"
#include "tome/squelch/automatizer.hpp"
+#include "util.hpp"
+#include "util.h"
using squelch::action_type;
using squelch::action_mapping;
diff --git a/src/status.cc b/src/status.cc
index 8c21907b..c8b8621a 100644
--- a/src/status.cc
+++ b/src/status.cc
@@ -17,6 +17,8 @@
#include "angband.h"
#include "xtra1.hpp"
+#include "util.hpp"
+#include "util.h"
static void row_trival(const char*, s16b, u32b, s16b, u32b, int, u32b[INVEN_TOTAL - INVEN_WIELD + 2][7]);
static void row_bival(const char*, s16b, u32b, int, u32b[INVEN_TOTAL - INVEN_WIELD + 2][7]);
diff --git a/src/store.cc b/src/store.cc
index 0e574581..d5e75a97 100644
--- a/src/store.cc
+++ b/src/store.cc
@@ -18,6 +18,8 @@
#include "spell_type.hpp"
#include "skills.hpp"
#include "spells5.hpp"
+#include "util.hpp"
+#include "util.h"
#include "xtra1.hpp"
#include <cassert>
diff --git a/src/traps.cc b/src/traps.cc
index a45dfd59..11690667 100644
--- a/src/traps.cc
+++ b/src/traps.cc
@@ -14,6 +14,7 @@
#include "gods.hpp"
#include "spells1.hpp"
#include "spells2.hpp"
+#include "util.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
diff --git a/src/util.cc b/src/util.cc
index 55badc07..fbd2020c 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -3,6 +3,7 @@
/* Purpose: Angband utilities -BEN- */
#include "util.hpp"
+#include "util.h"
#include "angband.h"
#include "cmd3.hpp"
#include "cmd4.hpp"
@@ -3677,12 +3678,6 @@ char msg_box(cptr text, int y, int x)
return inkey();
}
-/* Rescale a value */
-s32b rescale(s32b x, s32b max, s32b new_max)
-{
- return (x * new_max) / max;
-}
-
/*
* Timers
*/
diff --git a/src/util.h b/src/util.h
new file mode 100644
index 00000000..b1d042ee
--- /dev/null
+++ b/src/util.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "h-basic.h"
+
+// C linkage required for these functions since main-* code uses them.
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern errr path_parse(char *buf, int max, cptr file);
+extern errr path_build(char *buf, int max, cptr path, cptr file);
+extern void bell(void);
+extern errr macro_add(cptr pat, cptr act);
+extern sint macro_find_exact(cptr pat);
+extern char inkey(void);
+extern void prt(cptr str, int row, int col);
+extern void pause_line(int row);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
diff --git a/src/util.hpp b/src/util.hpp
index a8f892db..e9a93be8 100644
--- a/src/util.hpp
+++ b/src/util.hpp
@@ -1,8 +1,72 @@
#pragma once
-#include "h-basic.h"
+#include "angband.h"
#include <vector>
#include <string>
-int ask_menu(cptr ask, const std::vector<std::string> &items);
+extern bool_ input_box(cptr text, int y, int x, char *buf, int max);
+extern void draw_box(int y, int x, int h, int w);
+extern void display_list(int y, int x, int h, int w, cptr title, cptr *list, int max, int begin, int sel, byte sel_color);
+extern cptr get_player_race_name(int pr, int ps);
+extern cptr get_month_name(int month, bool_ full, bool_ compact);
+extern cptr get_day(int day);
+extern s32b bst(s32b what, s32b t);
+extern errr path_temp(char *buf, int max);
+extern FILE *my_fopen(cptr file, cptr mode);
+extern errr my_fgets(FILE *fff, char *buf, huge n);
+extern errr my_fputs(FILE *fff, cptr buf, huge n);
+extern errr my_fclose(FILE *fff);
+extern errr fd_kill(cptr file);
+extern errr fd_move(cptr file, cptr what);
+extern int fd_make(cptr file, int mode);
+extern int fd_open(cptr file, int flags);
+extern errr fd_seek(int fd, huge n);
+extern errr fd_read(int fd, char *buf, huge n);
+extern errr fd_write(int fd, cptr buf, huge n);
+extern errr fd_close(int fd);
+extern void flush(void);
+extern void sound(int num);
+extern void move_cursor(int row, int col);
+extern void text_to_ascii(char *buf, cptr str);
+extern void ascii_to_text(char *buf, cptr str);
+extern char inkey_scan(void);
+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);
+extern void cmsg_format(byte color, cptr fmt, ...);
+extern void msg_format(cptr fmt, ...);
+extern void screen_save(void);
+extern void screen_load(void);
+extern void c_put_str(byte attr, cptr str, int row, int col);
+extern void put_str(cptr str, int row, int col);
+extern void c_prt(byte attr, cptr str, int row, int col);
+extern void text_out_to_screen(byte a, cptr str);
+extern void text_out_to_file(byte a, cptr str);
+extern void text_out(cptr str);
+extern void text_out_c(byte a, cptr str);
+extern void clear_from(int row);
+extern int ask_menu(cptr ask, const std::vector<std::string> &items);
+extern bool_ askfor_aux_complete;
+extern bool_ askfor_aux(char *buf, int len);
+extern bool_ get_string(cptr prompt, char *buf, int len);
+extern bool_ get_check(cptr prompt);
+extern bool_ get_com(cptr prompt, char *command);
+extern s32b get_quantity(cptr prompt, s32b max);
+extern char request_command_ignore_keymaps[];
+extern bool_ request_command_inven_mode;
+extern void request_command(int shopping);
+extern bool_ is_a_vowel(int ch);
+extern int get_keymap_dir(char ch);
+extern byte count_bits(u32b array);
+extern void strlower(char *buf);
+extern int test_monster_name(cptr name);
+extern int test_mego_name(cptr name);
+extern int test_item_name(cptr name);
+extern char msg_box(cptr text, int y, int x);
+extern timer_type *new_timer(void (*callback)(), s32b delay);
+extern int get_keymap_mode();
+extern void repeat_push(int what);
+extern bool_ repeat_pull(int *what);
+extern void repeat_check(void);
+extern void get_count(int number, int max);
diff --git a/src/variable.cc b/src/variable.cc
index 99099379..40254a54 100644
--- a/src/variable.cc
+++ b/src/variable.cc
@@ -11,6 +11,7 @@
*/
#include "angband.h"
+#include "util.hpp"
int max_macrotrigger = 0;
diff --git a/src/wild.cc b/src/wild.cc
index c9e64bc7..2fcbb14e 100644
--- a/src/wild.cc
+++ b/src/wild.cc
@@ -9,6 +9,7 @@
#include "angband.h"
#include "cave.hpp"
#include "hooks.h"
+#include "util.hpp"
#include <memory>
diff --git a/src/wizard1.cc b/src/wizard1.cc
index 53312975..ff90ad24 100644
--- a/src/wizard1.cc
+++ b/src/wizard1.cc
@@ -4,6 +4,8 @@
#include "angband.h"
#include "cmd7.hpp"
+#include "util.hpp"
+#include "util.h"
#include <vector>
diff --git a/src/wizard2.cc b/src/wizard2.cc
index 2be1dba6..bde242f1 100644
--- a/src/wizard2.cc
+++ b/src/wizard2.cc
@@ -18,6 +18,8 @@
#include "spells1.hpp"
#include "spells2.hpp"
#include "traps.hpp"
+#include "util.hpp"
+#include "util.h"
#include "xtra1.hpp"
#include "xtra2.hpp"
diff --git a/src/xtra1.cc b/src/xtra1.cc
index 25dd90a3..8f0b5a36 100644
--- a/src/xtra1.cc
+++ b/src/xtra1.cc
@@ -19,6 +19,8 @@
#include "skills.hpp"
#include "spells3.hpp"
#include "spells6.hpp"
+#include "util.hpp"
+#include "util.h"
#include "xtra2.hpp"
#include <cassert>
diff --git a/src/xtra2.cc b/src/xtra2.cc
index 2f374fde..cc95b6ca 100644
--- a/src/xtra2.cc
+++ b/src/xtra2.cc
@@ -20,6 +20,8 @@
#include "skills.hpp"
#include "spells1.hpp"
#include "spells2.hpp"
+#include "util.hpp"
+#include "util.h"
#include "wizard2.hpp"
#include "xtra1.hpp"