summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Feinberg <pleasingfung@gmail.com>2014-07-27 22:09:02 -0700
committerNicholas Feinberg <pleasingfung@gmail.com>2014-07-27 22:09:02 -0700
commite4d45b9975e28eb14152e6d629fb5fc4241d6d48 (patch)
tree9ffa699101b9ff50503a9c5c3042c01ba4e7bbf7
parent46567feccad9b89219b613130d1581e10f40e6c1 (diff)
downloadcrawl-ref-e4d45b9975e28eb14152e6d629fb5fc4241d6d48.tar.gz
crawl-ref-e4d45b9975e28eb14152e6d629fb5fc4241d6d48.zip
Move held_status() from stuff.cc to traps.cc
Also add some comments to stuff.h, categorizing functions for later removal.
-rw-r--r--crawl-ref/source/l_you.cc1
-rw-r--r--crawl-ref/source/status.cc2
-rw-r--r--crawl-ref/source/stuff.cc8
-rw-r--r--crawl-ref/source/stuff.h41
-rw-r--r--crawl-ref/source/throw.cc1
-rw-r--r--crawl-ref/source/traps.cc17
-rw-r--r--crawl-ref/source/traps.h1
7 files changed, 51 insertions, 20 deletions
diff --git a/crawl-ref/source/l_you.cc b/crawl-ref/source/l_you.cc
index 54da83e2e1..7e104aea1d 100644
--- a/crawl-ref/source/l_you.cc
+++ b/crawl-ref/source/l_you.cc
@@ -35,6 +35,7 @@
#include "spl-util.h"
#include "stuff.h"
#include "transform.h"
+#include "traps.h"
#include "travel.h"
/*
diff --git a/crawl-ref/source/status.cc b/crawl-ref/source/status.cc
index 633c953838..1a4b82876f 100644
--- a/crawl-ref/source/status.cc
+++ b/crawl-ref/source/status.cc
@@ -19,7 +19,7 @@
#include "terrain.h"
#include "transform.h"
#include "spl-transloc.h"
-#include "stuff.h"
+#include "traps.h"
#include "duration-data.h"
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index 55565371fc..8021d3a82b 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -536,14 +536,6 @@ void canned_msg(canned_message_type which_message)
}
}
-const char* held_status(actor *act)
-{
- if (get_trapping_net(act->pos(), true) != NON_ITEM)
- return "held in a net";
- else
- return "caught in a web";
-}
-
// Like yesno, but requires a full typed answer.
// Unlike yesno, prompt should have no trailing space.
// Returns true if the user typed "yes", false if something else or cancel.
diff --git a/crawl-ref/source/stuff.h b/crawl-ref/source/stuff.h
index da3e888bc2..7f7e0f332e 100644
--- a/crawl-ref/source/stuff.h
+++ b/crawl-ref/source/stuff.h
@@ -9,11 +9,19 @@
#include <map>
#include "player.h"
+// time
+
string make_time_string(time_t abs_time, bool terse = false);
string make_file_time(time_t when);
+// redraw
+
void set_redraw_status(uint64_t flags);
+void redraw_screen();
+
+// stepdowns
+
enum rounding_type
{
ROUND_DOWN,
@@ -25,18 +33,29 @@ double stepdown(double value, double step);
int stepdown(int value, int step, rounding_type = ROUND_CLOSE, int max = 0);
int stepdown_value(int base_value, int stepping, int first_step,
int last_step, int ceiling_value);
+
+// ????
+
int get_ch();
+// IO
+
void cio_init();
void cio_cleanup();
+
+// ending
+
NORETURN void end(int exit_code, bool print_err = false, PRINTF(2, = NULL));
NORETURN void game_ended();
NORETURN void game_ended_with_error(const string &message);
-void redraw_screen();
+class game_ended_condition : public exception
+{
+};
+
+// canned messages & prompts
void canned_msg(canned_message_type which_message);
-const char* held_status(actor *act = &you);
bool yes_or_no(PRINTF(0, ));
typedef map<int, int> explicit_keymap;
@@ -48,22 +67,22 @@ bool yesno(const char * str, bool safe, int safeanswer,
int yesnoquit(const char* str, bool safe = true, int safeanswer = 0,
bool allow_all = false, bool clear_after = true,
- char alt_yes = 'Y', char alt_yes2 = 'Y');
+ char alt_yes = 'Y', char alt_yes2 = 'Y');
+
+int prompt_for_quantity(const char *prompt);
+int prompt_for_int(const char *prompt, bool nonneg);
+double prompt_for_float(const char* prompt);
+
+// letter <-> index mapping
char index_to_letter(int the_index);
int letter_to_index(int the_letter);
+// maybebools
+
maybe_bool frombool(bool b);
bool tobool(maybe_bool mb, bool def);
bool tobool(maybe_bool mb);
-class game_ended_condition : public exception
-{
-};
-
-int prompt_for_quantity(const char *prompt);
-int prompt_for_int(const char *prompt, bool nonneg);
-double prompt_for_float(const char* prompt);
-
#endif
diff --git a/crawl-ref/source/throw.cc b/crawl-ref/source/throw.cc
index 4370676555..89c1da6b4c 100644
--- a/crawl-ref/source/throw.cc
+++ b/crawl-ref/source/throw.cc
@@ -44,6 +44,7 @@
#include "teleport.h"
#include "terrain.h"
#include "transform.h"
+#include "traps.h"
#include "view.h"
#include "viewchar.h"
diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc
index b45ac5a83f..39da0b2c4b 100644
--- a/crawl-ref/source/traps.cc
+++ b/crawl-ref/source/traps.cc
@@ -289,6 +289,23 @@ int get_trapping_net(const coord_def& where, bool trapped)
return NON_ITEM;
}
+/**
+ * Return a string describing the reason a given actor is ensnared. (Since nets
+ * & webs use the same status.
+ *
+ * @param actor The ensnared actor.
+ * @return Either 'held in a net' or 'caught in a web'.
+ */
+const char* held_status(actor *act)
+{
+ act = act ? act : &you;
+
+ if (get_trapping_net(act->pos(), true) != NON_ITEM)
+ return "held in a net";
+ else
+ return "caught in a web";
+}
+
// If there are more than one net on this square
// split off one of them for checking/setting values.
static void _maybe_split_nets(item_def &item, const coord_def& where)
diff --git a/crawl-ref/source/traps.h b/crawl-ref/source/traps.h
index 76ba70942d..39c0980981 100644
--- a/crawl-ref/source/traps.h
+++ b/crawl-ref/source/traps.h
@@ -23,6 +23,7 @@ void free_stationary_net(int item_index);
void handle_traps(trap_type trt, int i, bool trap_known);
int get_trapping_net(const coord_def& where, bool trapped = true);
+const char* held_status(actor *act = NULL);
bool monster_caught_in_net(monster* mon, actor *agent);
bool player_caught_in_net();
void clear_trapping_net();