summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/state.h
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref/source/state.h')
-rw-r--r--crawl-ref/source/state.h100
1 files changed, 92 insertions, 8 deletions
diff --git a/crawl-ref/source/state.h b/crawl-ref/source/state.h
index 2be86b8a76..cd572ed865 100644
--- a/crawl-ref/source/state.h
+++ b/crawl-ref/source/state.h
@@ -13,6 +13,21 @@
#ifndef STATE_H
#define STATE_H
+#include "enum.h"
+#include <vector>
+
+struct god_act_state
+{
+public:
+
+ god_act_state();
+ void reset();
+
+ god_type which_god;
+ bool retribution;
+ int depth;
+};
+
// Track various aspects of Crawl game state.
struct game_state
{
@@ -38,21 +53,90 @@ struct game_state
void (*terminal_resize_handler)();
void (*terminal_resize_check)();
- game_state() : mouse_enabled(false), waiting_for_command(false),
- terminal_resized(false), io_inited(false), need_save(false),
- saving_game(false), updating_scores(false),
- seen_hups(0), map_stat_gen(false), unicode_ok(false),
- glyph2strfn(NULL), multibyte_strlen(NULL),
- terminal_resize_handler(NULL), terminal_resize_check(NULL)
- {
- }
+ bool doing_prev_cmd_again;
+ command_type prev_cmd;
+ std::deque<int> prev_cmd_keys;
+
+ command_type repeat_cmd;
+ std::deque<int> repeat_cmd_keys;
+ bool cmd_repeat_start;
+ int cmd_repeat_count;
+ int cmd_repeat_goal;
+ int prev_cmd_repeat_goal;
+ int prev_repetition_turn;
+ bool cmd_repeat_started_unsafe;
+
+ std::vector<std::string> startup_errors;
+
+ std::vector<std::string> input_line_strs;
+ unsigned int input_line_curr;
+
+ bool level_annotation_shown;
+
+protected:
+ void reset_cmd_repeat();
+ void reset_cmd_again();
+
+ god_act_state god_act;
+ std::vector<god_act_state> god_act_stack;
+
+public:
+ game_state();
+
+ void add_startup_error(const std::string &error);
+ void show_startup_errors();
+
+ bool is_replaying_keys() const;
+
+ bool is_repeating_cmd() const;
+
+ void cancel_cmd_repeat(std::string reason = "");
+ void cancel_cmd_again(std::string reason = "");
+
+ void cant_cmd_repeat(std::string reason = "");
+ void cant_cmd_again(std::string reason = "");
+
+ void zero_turns_taken();
void check_term_size() const
{
if (terminal_resize_check)
(*terminal_resize_check)();
}
+
+ bool is_god_acting() const;
+ bool is_god_retribution() const;
+ god_type which_god_acting() const;
+ void inc_god_acting(bool is_retribution = false);
+ void inc_god_acting(god_type which_god, bool is_retribution = false);
+ void dec_god_acting();
+ void dec_god_acting(god_type which_god);
+ void clear_god_acting();
+
+ std::vector<god_act_state> other_gods_acting() const;
};
+
extern game_state crawl_state;
+class god_acting
+{
+public:
+ god_acting(bool is_retribution = false)
+ : god(you.religion)
+ {
+ crawl_state.inc_god_acting(god, is_retribution);
+ }
+ god_acting(god_type who, bool is_retribution = false)
+ : god(who)
+ {
+ crawl_state.inc_god_acting(god, is_retribution);
+ }
+ ~god_acting()
+ {
+ crawl_state.dec_god_acting(god);
+ }
+private:
+ god_type god;
+};
+
#endif