diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-20 10:41:45 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-20 10:41:45 +0000 |
commit | 9c8871bc3e50d51e3898ff5594b9d4f73f15c55b (patch) | |
tree | 1f440752e7877fb9e626fa44c35d82d154939d73 /crawl-ref/source/state.h | |
parent | 68b3b5ac3474ceac470591c2a19e8e15b7d9d2ee (diff) | |
download | crawl-ref-9c8871bc3e50d51e3898ff5594b9d4f73f15c55b.tar.gz crawl-ref-9c8871bc3e50d51e3898ff5594b9d4f73f15c55b.zip |
Make extra-sure that a monster won't be announced to have come into view, only
to immediately move out of view, by introducing the notion of the currently
acting monster to crawl_state, and only flushing out the "comes into view"
message in mpr() for the currently acting monster. Not sure if it's worth it
just for the sake of avoiding doing a "has this monster just now come into
view" check in every place that a monster might issue a message, but at least
this way we won't miss any places such a check should be placed.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8623 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/state.h')
-rw-r--r-- | crawl-ref/source/state.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/crawl-ref/source/state.h b/crawl-ref/source/state.h index 23c6675dfd..58bfa30090 100644 --- a/crawl-ref/source/state.h +++ b/crawl-ref/source/state.h @@ -13,6 +13,9 @@ #include <vector> #include <stdio.h> +class monsters; +class mon_acting; + struct god_act_state { public: @@ -83,6 +86,9 @@ protected: god_act_state god_act; std::vector<god_act_state> god_act_stack; + monsters* mon_act; + std::vector<monsters*> mon_act_stack; + public: game_state(); @@ -120,7 +126,16 @@ public: std::vector<god_act_state> other_gods_acting() const; + bool is_mon_acting() const; + monsters* which_mon_acting() const; + void inc_mon_acting(monsters* mon); + void dec_mon_acting(monsters* mon); + void clear_mon_acting(); + void mon_gone(monsters* mon); + void dump(FILE* file); + + friend class mon_acting; }; extern game_state crawl_state; @@ -146,4 +161,24 @@ private: god_type god; }; +class mon_acting +{ +public: + mon_acting(monsters* _mon) : mon(_mon) + { + crawl_state.inc_mon_acting(_mon); + } + + ~mon_acting() + { + // Monster might have died in the meantime. + if (mon == crawl_state.mon_act) + crawl_state.dec_mon_acting(mon); + } + +private: + monsters *mon; +}; + + #endif |