summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-01-20 05:27:28 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-01-20 05:27:28 +0000
commit90e4386f60d35d54fefa08a5f5266499e1a6e529 (patch)
treeab94d485c627d2beebcd0fd948c09eea22a96694 /crawl-ref
parentee3bb90a15c95e9c8c59805ad4b2e4edb334f288 (diff)
downloadcrawl-ref-90e4386f60d35d54fefa08a5f5266499e1a6e529.tar.gz
crawl-ref-90e4386f60d35d54fefa08a5f5266499e1a6e529.zip
When causing dungeon-wide effects for Nemelex and Beogh abandonment,
only display the associated messages if the effects actually changed something. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3305 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/decks.cc31
-rw-r--r--crawl-ref/source/files.cc6
-rw-r--r--crawl-ref/source/files.h2
-rw-r--r--crawl-ref/source/religion.cc12
4 files changed, 39 insertions, 12 deletions
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index 475def8b60..0dfec01396 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -2746,11 +2746,13 @@ static void unmark_and_shuffle_deck(item_def& deck)
{
unmark_deck(deck);
shuffle_deck(deck);
- }
+ }
}
-static void shuffle_all_decks_on_level()
+static bool shuffle_all_decks_on_level()
{
+ bool success = false;
+
for ( int i = 0; i < MAX_ITEMS; ++i )
{
item_def& item(mitm[i]);
@@ -2763,12 +2765,18 @@ static void shuffle_all_decks_on_level()
static_cast<int>(you.where_are_you));
#endif
unmark_and_shuffle_deck(item);
+
+ success = true;
}
}
+
+ return success;
}
-static void shuffle_inventory_decks()
+static bool shuffle_inventory_decks()
{
+ bool success = false;
+
for ( int i = 0; i < ENDOFPACK; ++i )
{
item_def& item(you.inv[i]);
@@ -2779,13 +2787,24 @@ static void shuffle_inventory_decks()
item.name(DESC_PLAIN).c_str());
#endif
unmark_and_shuffle_deck(item);
+
+ success = true;
}
}
+
+ return success;
}
void nemelex_shuffle_decks()
{
- apply_to_all_dungeons(shuffle_all_decks_on_level);
- shuffle_inventory_decks();
- god_speaks(GOD_NEMELEX_XOBEH, "You hear Nemelex chuckle.");
+ bool success = false;
+
+ if (apply_to_all_dungeons(shuffle_all_decks_on_level))
+ success = true;
+
+ if (shuffle_inventory_decks())
+ success = true;
+
+ if (success)
+ god_speaks(GOD_NEMELEX_XOBEH, "You hear Nemelex chuckle.");
}
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index f21f792461..f9444b77f6 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -1461,7 +1461,7 @@ void restore_game(void)
}
}
-void apply_to_all_dungeons(void (*applicator)())
+bool apply_to_all_dungeons(bool (*applicator)())
{
const branch_type original_branch = you.where_are_you;
const int original_level = you.your_level;
@@ -1472,7 +1472,7 @@ void apply_to_all_dungeons(void (*applicator)())
const coord_def old_pos(you.pos());
// Apply to current level, then save it out.
- applicator();
+ bool success = applicator();
save_level(original_level, original_type, original_branch);
you.level_type = LEVEL_DUNGEON;
@@ -1516,6 +1516,8 @@ void apply_to_all_dungeons(void (*applicator)())
load( DNGN_STONE_STAIRS_DOWN_I, LOAD_VISITOR,
original_type, original_level, original_branch );
+
+ return success;
}
static bool determine_version( FILE *restoreFile,
diff --git a/crawl-ref/source/files.h b/crawl-ref/source/files.h
index 8300e8134c..c8c62db257 100644
--- a/crawl-ref/source/files.h
+++ b/crawl-ref/source/files.h
@@ -81,7 +81,7 @@ void save_game_state();
* *********************************************************************** */
void restore_game(void);
-void apply_to_all_dungeons(void (*applicator)());
+bool apply_to_all_dungeons(bool (*applicator)());
// last updated 12may2000 {dlb}
/* ***********************************************************************
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 13b923f950..9146cea387 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -2690,8 +2690,10 @@ void divine_retribution( god_type god )
dec_penance( god, 1 + random2(3) );
}
-static void orcish_followers_on_level_abandon_you()
+static bool orcish_followers_on_level_abandon_you()
{
+ bool success = false;
+
for ( int i = 0; i < MAX_MONSTERS; ++i )
{
monsters *monster = &menv[i];
@@ -2710,8 +2712,12 @@ static void orcish_followers_on_level_abandon_you()
monster->attitude = ATT_HOSTILE;
monster->behaviour = BEH_HOSTILE;
// for now CREATED_FRIENDLY stays
+
+ success = true;
}
}
+
+ return success;
}
// Upon excommunication, ex-Beoghites lose all their orcish followers.
@@ -2725,8 +2731,8 @@ static bool beogh_followers_abandon_you()
if (you.religion != GOD_BEOGH)
{
- apply_to_all_dungeons(orcish_followers_on_level_abandon_you);
- reconvert = true;
+ reconvert =
+ apply_to_all_dungeons(orcish_followers_on_level_abandon_you);
}
else
{