diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-10-02 11:38:37 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-10-02 11:38:37 +0000 |
commit | 6b34259b6ce235196c3f2f70e706d9235dc100cb (patch) | |
tree | 3721090b7a2f55185e57286f368924a44a7525f7 /crawl-ref/source | |
parent | 4ff73ba59f0c4cd921620150ac3da663e467adee (diff) | |
download | crawl-ref-6b34259b6ce235196c3f2f70e706d9235dc100cb.tar.gz crawl-ref-6b34259b6ce235196c3f2f70e706d9235dc100cb.zip |
Replaced inc_god_acting/dec_god_acting pairing with god_acting objects.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2299 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/religion.cc | 40 | ||||
-rw-r--r-- | crawl-ref/source/state.h | 22 | ||||
-rw-r--r-- | crawl-ref/source/xom.cc | 30 |
3 files changed, 40 insertions, 52 deletions
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 9eb3ce6ee0..26a7c89765 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -559,7 +559,7 @@ static void do_god_gift(bool prayed_for) if (prayed_for != (you.religion == GOD_ZIN)) return; - crawl_state.inc_god_acting(); + god_acting gdact; #if DEBUG_DIAGNOSTICS || DEBUG_GIFTS int old_gifts = you.num_gifts[ you.religion ]; @@ -835,7 +835,6 @@ static void do_god_gift(bool prayed_for) mprf(MSGCH_DIAGNOSTICS, "Total number of gifts from this god: %d", you.num_gifts[ you.religion ] ); #endif - crawl_state.dec_god_acting(); } static bool is_risky_sacrifice(const item_def& item) @@ -1145,7 +1144,7 @@ bool did_god_conduct( conduct_type thing_done, int level, const actor *victim ) if (you.religion == GOD_NO_GOD || you.religion == GOD_XOM) return (false); - crawl_state.inc_god_acting(); + god_acting gdact; switch (thing_done) { @@ -1603,8 +1602,6 @@ bool did_god_conduct( conduct_type thing_done, int level, const actor *victim ) } #endif - crawl_state.dec_god_acting(); - return (ret); } @@ -1726,8 +1723,8 @@ bool ely_destroy_weapons() { if (you.religion != GOD_ELYVILON) return false; - - crawl_state.inc_god_acting(); + + god_acting gdact; bool success = false; int i = igrd[you.x_pos][you.y_pos]; @@ -1770,9 +1767,6 @@ bool ely_destroy_weapons() { mpr("There are no weapons here to destroy!"); } - - crawl_state.dec_god_acting(); - return success; } @@ -1782,7 +1776,7 @@ bool trog_burn_books() if (you.religion != GOD_TROG) return (false); - crawl_state.inc_god_acting(); + god_acting gdact; int i = igrd[you.x_pos][you.y_pos]; while (i != NON_ITEM) @@ -1888,7 +1882,6 @@ bool trog_burn_books() simple_god_message(" is delighted!", GOD_TROG); gain_piety(totalpiety); } - crawl_state.dec_god_acting(); return (true); } @@ -2543,7 +2536,7 @@ void divine_retribution( god_type god ) if (god == you.religion && is_good_god(god) ) return; - crawl_state.inc_god_acting(god, true); + god_acting gdact(god, true); // Just the thought of retribution (getting this far) mollifies // the god by at least a point... the punishment might reduce @@ -2595,7 +2588,6 @@ void divine_retribution( god_type god ) } } } - crawl_state.dec_god_acting(god); } // upon excommunication, (now ex) Beogh adepts lose their orcish followers @@ -2688,7 +2680,7 @@ bool followers_abandon_you() // Destroying orcish idols (a.k.a. idols of Beogh) may anger Beogh void beogh_idol_revenge() { - crawl_state.inc_god_acting(GOD_BEOGH, true); + god_acting gdact(GOD_BEOGH, true); // Beogh watches his charges closely, but for others doesn't always notice if (you.religion == GOD_BEOGH @@ -2745,15 +2737,12 @@ void beogh_idol_revenge() did_god_conduct(DID_ATTACK_FRIEND, 8); } } - - crawl_state.dec_god_acting(GOD_BEOGH); } void excommunication(void) { const god_type old_god = you.religion; - - crawl_state.inc_god_acting(old_god, true); + god_acting gdact(old_god, true); take_note(Note(NOTE_LOSE_GOD, old_god)); @@ -2846,8 +2835,6 @@ void excommunication(void) inc_penance( old_god, 25 ); break; } - - crawl_state.dec_god_acting(old_god); } // end excommunication() static bool bless_weapon( int god, int brand, int colour ) @@ -2910,7 +2897,7 @@ void altar_prayer(void) if (you.religion == GOD_XOM) return; - crawl_state.inc_god_acting(); + god_acting gdact; // TSO blesses long swords with holy wrath if (you.religion == GOD_SHINING_ONE @@ -2964,8 +2951,6 @@ void altar_prayer(void) } offer_items(); - - crawl_state.dec_god_acting(); } // end altar_prayer() static bool god_likes_items(god_type god) @@ -3012,7 +2997,7 @@ void offer_items() if (you.religion == GOD_NO_GOD || !god_likes_items(you.religion)) return; - crawl_state.inc_god_acting(); + god_acting gdact; int num_sacced = 0; int i = igrd[you.x_pos][you.y_pos]; @@ -3138,8 +3123,6 @@ void offer_items() if (num_sacced > 0 && you.religion == GOD_NEMELEX_XOBEH) show_pure_deck_chances(); #endif - - crawl_state.dec_god_acting(); } void god_pitch(god_type which_god) @@ -3163,9 +3146,8 @@ void god_pitch(god_type which_god) if (which_god == GOD_LUGONU && you.penance[GOD_LUGONU]) { simple_god_message(" is most displeased with you!", which_god); - crawl_state.inc_god_acting(GOD_LUGONU, true); + god_acting gdact(GOD_LUGONU, true); lugonu_retribution(); - crawl_state.dec_god_acting(GOD_LUGONU); return; } diff --git a/crawl-ref/source/state.h b/crawl-ref/source/state.h index 8e5a9cc4b5..4b4952026a 100644 --- a/crawl-ref/source/state.h +++ b/crawl-ref/source/state.h @@ -107,6 +107,28 @@ public: 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 diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc index 3c4cc6f6b7..0269c0ef5e 100644 --- a/crawl-ref/source/xom.cc +++ b/crawl-ref/source/xom.cc @@ -207,7 +207,7 @@ void xom_makes_you_cast_random_spell(int sever) { int spellenum = sever; - crawl_state.inc_god_acting(GOD_XOM); + god_acting gdact(GOD_XOM); const int nxomspells = ARRAYSIZE(xom_spells); if (spellenum >= nxomspells) @@ -223,8 +223,6 @@ void xom_makes_you_cast_random_spell(int sever) #endif your_spells(spell, sever, false); - - crawl_state.dec_god_acting(GOD_XOM); } static void xom_make_item(object_class_type base, @@ -241,15 +239,13 @@ static void xom_make_item(object_class_type base, return; } - crawl_state.inc_god_acting(GOD_XOM); + god_acting gdact(GOD_XOM); move_item_to_grid( &thing_created, you.x_pos, you.y_pos ); canned_msg(MSG_SOMETHING_APPEARS); stop_running(); origin_acquired(mitm[thing_created], GOD_XOM); - - crawl_state.dec_god_acting(GOD_XOM); } static object_class_type get_unrelated_wield_class(object_class_type ref) @@ -283,9 +279,7 @@ static object_class_type get_unrelated_wield_class(object_class_type ref) static bool xom_annoyance_gift(int power) { - // Can't simply use unwind_var because of the way that god act - // state is maintained. - crawl_state.inc_god_acting(GOD_XOM); + god_acting gdact(GOD_XOM); if (coinflip() && player_in_a_dangerous_place()) { @@ -301,7 +295,6 @@ static bool xom_annoyance_gift(int power) xom_make_item(weapon->base_type, weapon->sub_type, power * 3); else acquirement(weapon->base_type, GOD_XOM); - crawl_state.dec_god_acting(GOD_XOM); return (true); } @@ -314,7 +307,6 @@ static bool xom_annoyance_gift(int power) // A random ring. (Not necessarily a good one.) god_speaks(GOD_XOM, RANDOM_ELEMENT(xom_try_this)); xom_make_item(OBJ_JEWELLERY, get_random_ring_type(), power * 3); - crawl_state.dec_god_acting(GOD_XOM); return (true); }; @@ -325,7 +317,6 @@ static bool xom_annoyance_gift(int power) // you an amulet. Ha ha! god_speaks(GOD_XOM, RANDOM_ELEMENT(xom_try_this)); xom_make_item(OBJ_JEWELLERY, get_random_amulet_type(), power * 3); - crawl_state.dec_god_acting(GOD_XOM); return (true); }; @@ -338,7 +329,6 @@ static bool xom_annoyance_gift(int power) // a ring. Ha ha! god_speaks(GOD_XOM, RANDOM_ELEMENT(xom_try_this_ring)); xom_make_item(OBJ_JEWELLERY, get_random_ring_type(), power * 3); - crawl_state.dec_god_acting(GOD_XOM); return (true); } @@ -355,12 +345,10 @@ static bool xom_annoyance_gift(int power) acquirement(objtype, GOD_XOM); else xom_make_item(objtype, OBJ_RANDOM, power * 3); - crawl_state.dec_god_acting(GOD_XOM); return (true); } } - crawl_state.dec_god_acting(GOD_XOM); return (false); } @@ -403,9 +391,8 @@ bool xom_gives_item(int power) (r == 6) ? OBJ_MISCELLANY : OBJ_GOLD; - crawl_state.inc_god_acting(GOD_XOM); + god_acting gdact(GOD_XOM); acquirement(objtype, GOD_XOM); - crawl_state.dec_god_acting(GOD_XOM); } else { @@ -492,7 +479,7 @@ static bool xom_is_good(int sever) // Okay, now for the nicer stuff (note: these things are not // necessarily nice): - crawl_state.inc_god_acting(GOD_XOM); + god_acting gdact(GOD_XOM); if (random2(sever) <= 1) { temp_rand = random2(4); @@ -675,7 +662,6 @@ static bool xom_is_good(int sever) done = true; } - crawl_state.dec_god_acting(GOD_XOM); return (done); } @@ -686,8 +672,8 @@ static bool xom_is_bad(int sever) bool done = false; bolt beam; - - crawl_state.inc_god_acting(GOD_XOM); + + god_acting gdact(GOD_XOM); // begin "Bad Things" while (!done) @@ -877,8 +863,6 @@ static bool xom_is_bad(int sever) } } - crawl_state.dec_god_acting(GOD_XOM); - return (done); } |