summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/clua.cc2
-rw-r--r--crawl-ref/source/debug.cc8
-rw-r--r--crawl-ref/source/decks.cc74
-rw-r--r--crawl-ref/source/decks.h1
-rw-r--r--crawl-ref/source/describe.cc24
-rw-r--r--crawl-ref/source/hiscores.cc5
-rw-r--r--crawl-ref/source/initfile.cc3
-rw-r--r--crawl-ref/source/items.cc7
-rw-r--r--crawl-ref/source/player.cc2
-rw-r--r--crawl-ref/source/religion.cc190
-rw-r--r--crawl-ref/source/religion.h2
-rw-r--r--crawl-ref/source/xom.cc6
12 files changed, 153 insertions, 171 deletions
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc
index be98456849..a823f21464 100644
--- a/crawl-ref/source/clua.cc
+++ b/crawl-ref/source/clua.cc
@@ -716,7 +716,7 @@ LUARET1(you_name, string, you.your_name)
LUARET1(you_race, string,
species_name(you.species, you.experience_level).c_str())
LUARET1(you_class, string, get_class_name(you.char_class))
-LUARET1(you_god, string, god_name(you.religion))
+LUARET1(you_god, string, god_name(you.religion).c_str())
LUARET1(you_good_god, boolean,
lua_isstring(ls, 1) ? is_good_god(str_to_god(lua_tostring(ls, 1)))
: is_good_god(you.religion))
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index e6c0eb867b..27f5c1c514 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -2045,16 +2045,14 @@ void debug_get_religion(void)
if (specs[0] == '\0')
return;
+ strlwr(specs);
+
god_type god = GOD_NO_GOD;
for (int i = 1; i < NUM_GODS; i++)
{
const god_type gi = static_cast<god_type>(i);
- char name[80];
- strncpy(name, god_name(gi), sizeof(name));
-
- char *ptr = strstr( strlwr(name), strlwr(specs) );
- if (ptr != NULL)
+ if ( lowercase_string(god_name(gi)).find(specs) != std::string::npos)
{
god = gi;
break;
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index b8ce78bc31..3f83a89dab 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -20,6 +20,7 @@
#include "cio.h"
#include "dungeon.h"
#include "effects.h"
+#include "files.h"
#include "food.h"
#include "invent.h"
#include "it_use2.h"
@@ -197,7 +198,6 @@ static void shuffle_deck(item_def &deck)
ASSERT(props.exists("cards"));
CrawlVector &cards = props["cards"];
- ASSERT(cards.size() > 1);
CrawlVector &flags = props["card_flags"];
ASSERT(flags.size() == cards.size());
@@ -1966,6 +1966,9 @@ static void sage_card(int power, deck_rarity_type rarity)
int result = -1;
for (int i = 0; i < NUM_SKILLS; ++i )
{
+ if ( skill_name(i) == NULL )
+ continue;
+
if ( you.skills[i] < MAX_SKILL_LEVEL )
{
const int curweight = 1 + you.skills[i] * (40-you.skills[i]) * c;
@@ -2605,3 +2608,72 @@ void init_deck(item_def &item)
item.plus2 = 0;
item.colour = deck_rarity_to_color((deck_rarity_type) item.special);
}
+
+static void unmark_deck(item_def& deck)
+{
+ if ( !is_deck(deck) )
+ return;
+
+ CrawlHashTable &props = deck.props;
+ if ( !props.exists("card_flags") )
+ return;
+
+ CrawlVector &flags = props["card_flags"];
+
+ for ( unsigned int i = 0; i < flags.size(); ++i )
+ flags[i] =
+ static_cast<char>((static_cast<char>(flags[i]) & ~CFLAG_MARKED));
+
+ // We'll be mean and leave non_brownie_draws as-is.
+ props["num_marked"] = static_cast<char>(0);
+}
+
+static void unmark_and_shuffle_deck(item_def& deck)
+{
+ if ( is_deck(deck) )
+ {
+ unmark_deck(deck);
+ shuffle_deck(deck);
+ }
+}
+
+static void shuffle_all_decks_on_level()
+{
+ for ( int i = 0; i < MAX_ITEMS; ++i )
+ {
+ item_def& item(mitm[i]);
+ if ( is_valid_item(item) && is_deck(item) )
+ {
+#ifdef DEBUG_DIAGNOSTICS
+ mprf(MSGCH_DIAGNOSTICS, "Shuffling: %s on level %d, branch %d",
+ item.name(DESC_PLAIN).c_str(),
+ static_cast<int>(you.your_level),
+ static_cast<int>(you.where_are_you));
+#endif
+ unmark_and_shuffle_deck(item);
+ }
+ }
+}
+
+static void shuffle_inventory_decks()
+{
+ for ( int i = 0; i < ENDOFPACK; ++i )
+ {
+ item_def& item(you.inv[i]);
+ if ( is_valid_item(item) && is_deck(item) )
+ {
+#ifdef DEBUG_DIAGNOSTICS
+ mprf(MSGCH_DIAGNOSTICS, "Shuffling in inventory: %s",
+ item.name(DESC_PLAIN).c_str());
+#endif
+ unmark_and_shuffle_deck(item);
+ }
+ }
+}
+
+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.");
+}
diff --git a/crawl-ref/source/decks.h b/crawl-ref/source/decks.h
index 79f7a3536c..bb0d704c05 100644
--- a/crawl-ref/source/decks.h
+++ b/crawl-ref/source/decks.h
@@ -125,6 +125,7 @@ bool deck_peek();
bool deck_mark();
bool deck_stack();
bool choose_deck_and_draw();
+void nemelex_shuffle_decks();
// Return true if it was a "genuine" draw, false otherwise.
bool card_effect(card_type which_card, deck_rarity_type rarity,
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index ab2d6e613d..e0a1b4b1d8 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -3936,7 +3936,7 @@ static bool print_god_abil_desc( int god, int numpower )
static std::string describe_favour_generic(god_type which_god)
{
- std::string godname = god_name(which_god);
+ const std::string godname = god_name(which_god);
return (you.piety > 130) ? "A prized avatar of " + godname + ".":
(you.piety > 100) ? "A shining star in the eyes of " + godname + "." :
(you.piety > 70) ? "A rising star in the eyes of " + godname + "." :
@@ -3980,8 +3980,8 @@ static std::string religion_help( god_type god )
if (!player_under_penance() && you.piety > 160
&& !you.num_gifts[god])
{
- result += "You can pray at an altar to ask "
- + std::string(god_name(god)) + " to bless a ";
+ result += "You can pray at an altar to ask " + god_name(god)
+ + " to bless a ";
result += (god == GOD_ZIN ? "mace" : "long sword");
result += ".";
}
@@ -3991,8 +3991,8 @@ static std::string religion_help( god_type god )
if (!player_under_penance() && you.piety > 160
&& !you.num_gifts[god])
{
- result += "You can pray at an altar to ask "
- + std::string(god_name(god)) + " to bless your weapon." EOL;
+ result += "You can pray at an altar to ask " + god_name(god)
+ + " to bless your weapon." EOL;
} // fall through
case GOD_OKAWARU:
@@ -4046,7 +4046,7 @@ void describe_god( god_type which_god, bool give_title )
//mv: print god's name and title - if you can think up better titles
//I have nothing against
textcolor(colour);
- cprintf( "%s", god_name(which_god,true)); //print long god's name
+ cprintf( "%s", god_name(which_god, true).c_str()); //print long god's name
cprintf (EOL EOL);
//mv: print god's description
@@ -4265,7 +4265,7 @@ void describe_god( god_type which_god, bool give_title )
(you.penance[which_god] > 0) ? "%s is ready to forgive your sins." :
(you.worshipped[which_god]) ? "%s is ambivalent towards you."
: "%s is neutral towards you.",
- god_name(which_god) );
+ god_name(which_god).c_str() );
}
else
{
@@ -4296,28 +4296,28 @@ void describe_god( god_type which_god, bool give_title )
"";
have_any = true;
- cprintf( "%s %s watches over you%s." EOL, god_name(which_god),
- how, when );
+ cprintf( "%s %s watches over you%s." EOL,
+ god_name(which_god).c_str(), how, when );
}
if (which_god == GOD_ZIN && you.piety >= 30)
{
have_any = true;
cprintf("Praying to %s will provide sustenance if starving."
- EOL, god_name(which_god));
+ EOL, god_name(which_god).c_str());
}
if (which_god == GOD_TROG)
{
have_any = true;
cprintf("You can call upon %s to burn books in your surroundings."
- EOL, god_name(which_god));
+ EOL, god_name(which_god).c_str());
}
else if (which_god == GOD_ELYVILON)
{
have_any = true;
cprintf("You can call upon %s to destroy weapons "
- "lying on the ground." EOL, god_name(which_god));
+ "lying on the ground." EOL, god_name(which_god).c_str());
}
// mv: No abilities (except divine protection) under penance
diff --git a/crawl-ref/source/hiscores.cc b/crawl-ref/source/hiscores.cc
index dd06f0a0c7..cf3ef6ee47 100644
--- a/crawl-ref/source/hiscores.cc
+++ b/crawl-ref/source/hiscores.cc
@@ -690,7 +690,8 @@ void scorefile_entry::set_base_xlog_fields() const
// Don't write No God to save some space.
if (god != -1)
- fields->add_field("god", "%s", god == GOD_NO_GOD? "" : god_name(god));
+ fields->add_field("god", "%s", god == GOD_NO_GOD? "" :
+ god_name(god).c_str());
if (wiz_mode)
fields->add_field("wiz", "%d", wiz_mode);
@@ -1292,7 +1293,7 @@ scorefile_entry::character_description(death_desc_verbosity verbosity) const
(piety >= 50) ? "a Believer" :
(piety >= 30) ? "a Follower"
: "an Initiate",
- god_name( god ),
+ god_name(god).c_str(),
(penance > 0) ? " (penitent)." : "." );
desc += scratch;
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index 488ecb2de2..5e66290cc5 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -66,10 +66,9 @@ god_type str_to_god(std::string god)
return (GOD_RANDOM);
for (int i = GOD_NO_GOD; i < NUM_GODS; ++i)
- {
if (lowercase_string(god_name(static_cast<god_type>(i))) == god)
return (static_cast<god_type>(i));
- }
+
return (GOD_NO_GOD);
}
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index 60b760aca3..c813175175 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -1087,13 +1087,12 @@ std::string origin_desc(const item_def &item)
desc += "You drew the Genie ";
break;
case AQ_WIZMODE:
- desc += "Your wizardly powers created "
- + article_it(item) + " ";
+ desc += "Your wizardly powers created "+article_it(item)+" ";
break;
default:
if (iorig > GOD_NO_GOD && iorig < NUM_GODS)
- desc += std::string(god_name(static_cast<god_type>(iorig)))
- + " gifted " + article_it(item) + " to you ";
+ desc += god_name(static_cast<god_type>(iorig))
+ + " gifted " + article_it(item) + " to you ";
else
// Bug really.
desc += "You stumbled upon " + article_it(item) + " ";
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index f38d9cc6a5..05ad9c7f98 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -2701,7 +2701,7 @@ void level_change(bool skip_ability_increase)
{
// necessary for the time being, as level_change() is called
// directly sometimes {dlb}
- you.redraw_experience = 1;
+ you.redraw_experience = true;
while (you.experience_level < 27
&& you.experience > exp_needed(you.experience_level + 2))
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index d7cdd7361b..a21d4aaa8b 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -941,8 +941,7 @@ static bool confirm_pray_sacrifice()
std::string god_prayer_reaction()
{
- std::string result;
- result += god_name(you.religion);
+ std::string result = god_name(you.religion);
if (!crawl_state.need_save && crawl_state.updating_scores)
result += " was ";
else
@@ -1027,7 +1026,8 @@ void pray()
}
mprf(MSGCH_PRAY, "You %s prayer to %s.",
- was_praying ? "renew your" : "offer a", god_name(you.religion));
+ was_praying ? "renew your" : "offer a",
+ god_name(you.religion).c_str());
// ...otherwise, they offer what they're standing on
if ( you.religion == GOD_NEMELEX_XOBEH && altar_god == GOD_NO_GOD )
@@ -1060,141 +1060,52 @@ void pray()
} // end pray()
-const char *god_name( god_type which_god, bool long_name ) // mv - rewritten
+std::string god_name( god_type which_god, bool long_name )
{
- static char godname_buff[80];
-
switch (which_god)
{
- case GOD_NO_GOD:
- sprintf(godname_buff, "No God");
- break;
- case GOD_RANDOM:
- sprintf(godname_buff, "random");
- break;
- case GOD_ZIN:
- sprintf(godname_buff, "Zin%s", long_name ? " the Law-Giver" : "");
- break;
- case GOD_SHINING_ONE:
- strcpy(godname_buff, "The Shining One");
- break;
- case GOD_KIKUBAAQUDGHA:
- strcpy(godname_buff, "Kikubaaqudgha");
- break;
+ case GOD_NO_GOD: return "No God";
+ case GOD_RANDOM: return "random";
+ case GOD_ZIN: return (long_name ? "Zin the Law-Giver" : "Zin");
+ case GOD_SHINING_ONE: return "The Shining One";
+ case GOD_KIKUBAAQUDGHA: return "Kikubaaqudgha";
case GOD_YREDELEMNUL:
- sprintf(godname_buff, "Yredelemnul%s", long_name ? " the Dark" : "");
- break;
+ return (long_name ? "Yredelemnul the Dark" : "Yredelemnul");
+ case GOD_VEHUMET: return "Vehumet";
+ case GOD_OKAWARU: return (long_name ? "Warmaster Okawaru" : "Okawaru");
+ case GOD_MAKHLEB: return (long_name ? "Makhleb the Destroyer" : "Makhleb");
+ case GOD_SIF_MUNA:
+ return (long_name ? "Sif Muna the Loreminder" : "Sif Muna");
+ case GOD_TROG: return (long_name ? "Trog the Wrathful" : "Trog");
+ case GOD_NEMELEX_XOBEH: return "Nemelex Xobeh";
+ case GOD_ELYVILON: return (long_name ? "Elyvilon the Healer" : "Elyvilon");
+ case GOD_LUGONU: return (long_name ? "Lugonu the Unformed" : "Lugonu");
+ case GOD_BEOGH: return (long_name ? "Beogh the Brigand" : "Beogh");
+
case GOD_XOM:
- strcpy(godname_buff, "Xom");
- if (long_name)
+ if (!long_name)
+ return "Xom";
+ else
{
- strcat(godname_buff, " ");
- switch(random2(30))
- {
- default:
- strcat(godname_buff, "of Chaos");
- break;
- case 1:
- strcat(godname_buff, "the Random");
- if (coinflip())
- strcat(godname_buff, coinflip()?"master":" Number God");
- break;
- case 2:
- strcat(godname_buff, "the Tricky");
- break;
- case 3:
- sprintf( godname_buff, "Xom the %sredictable", coinflip() ? "Less-P"
- : "Unp" );
- break;
- case 4:
- strcat(godname_buff, "of Many Doors");
- break;
- case 5:
- strcat(godname_buff, "the Capricious");
- break;
- case 6:
- strcat(godname_buff, "of ");
- strcat(godname_buff, coinflip() ? "Bloodstained" : "Enforced");
- strcat(godname_buff, " Whimsey");
- break;
- case 7:
- strcat(godname_buff, "\"What was your username?\" *clickity-click*");
- break;
- case 8:
- strcat(godname_buff, "of Bone-Dry Humour");
- break;
- case 9:
- strcat(godname_buff, "of ");
- strcat(godname_buff, coinflip() ? "Malevolent" : "Malicious");
- strcat(godname_buff, " Giggling");
- break;
- case 10:
- strcat(godname_buff, "the Psycho");
- strcat(godname_buff, coinflip() ? "tic" : "path");
- break;
- case 11:
- strcat(godname_buff, "of ");
- switch(random2(5))
- {
- case 0: strcat(godname_buff, "Gnomic"); break;
- case 1: strcat(godname_buff, "Ineffable"); break;
- case 2: strcat(godname_buff, "Fickle"); break;
- case 3: strcat(godname_buff, "Swiftly Tilting"); break;
- case 4: strcat(godname_buff, "Unknown"); break;
- }
- strcat(godname_buff, " Intent");
- if (coinflip())
- strcat(godname_buff, "ion");
- break;
- case 12:
- sprintf(godname_buff, "The Xom-Meister");
- if (coinflip())
- strcat(godname_buff, ", Xom-a-lom-a-ding-dong");
- else if (coinflip())
- strcat(godname_buff, ", Xom-o-Rama");
- else if (coinflip())
- strcat(godname_buff, ", Xom-Xom-bo-Bom, Banana-Fana-fo-Fom");
- break;
- case 13:
- strcat(godname_buff, "the Begetter of ");
- strcat(godname_buff, coinflip() ? "Turbulence" : "Discontinuities");
- break;
- }
+ const char* xom_names[] = {
+ "Xom the Random", "Xom the Random Number God",
+ "Xom the Tricky", "Xom the Less-Predictable",
+ "Xom the Unpredictable", "Xom of Many Doors",
+ "Xom the Capricious", "Xom of Bloodstained Whimsey",
+ "Xom of Enforced Whimsey", "Xom of Bone-Dry Humour",
+ "Xom of Malevolent Giggling", "Xom of Malicious Giggling",
+ "Xom the Psychotic", "Xom the Psychopath",
+ "Xom of Gnomic Intent", "Xom the Fickle",
+ "Xom of Unknown Intention", "The Xom-Meister",
+ "Xom the Begetter of Turbulence"
+ };
+ return (one_chance_in(3) ? RANDOM_ELEMENT(xom_names)
+ : "Xom of Chaos");
}
- break;
- case GOD_VEHUMET:
- strcpy(godname_buff, "Vehumet");
- break;
- case GOD_OKAWARU:
- sprintf(godname_buff, "%sOkawaru", long_name ? "Warmaster " : "");
- break;
- case GOD_MAKHLEB:
- sprintf(godname_buff, "Makhleb%s", long_name ? " the Destroyer" : "");
- break;
- case GOD_SIF_MUNA:
- sprintf(godname_buff, "Sif Muna%s", long_name ? " the Loreminder" : "");
- break;
- case GOD_TROG:
- sprintf(godname_buff, "Trog%s", long_name ? " the Wrathful" : "");
- break;
- case GOD_NEMELEX_XOBEH:
- strcpy(godname_buff, "Nemelex Xobeh");
- break;
- case GOD_ELYVILON:
- sprintf(godname_buff, "Elyvilon%s", long_name ? " the Healer" : "");
- break;
- case GOD_LUGONU:
- sprintf(godname_buff, "Lugonu%s", long_name? " the Unformed" : "");
- break;
- case GOD_BEOGH:
- sprintf(godname_buff, "Beogh%s", long_name? " the Brigand" : "");
- break;
- default:
- sprintf(godname_buff, "The Buggy One (%d)", which_god);
+ case NUM_GODS: return "Buggy";
}
-
- return (godname_buff);
-} // end god_name()
+ return "";
+}
void god_speaks( god_type god, const char *mesg )
{
@@ -2968,12 +2879,15 @@ void excommunication(void)
divine_retribution( old_god );
break;
- // these like to haunt players for a bit more than the standard
- case GOD_NEMELEX_XOBEH:
case GOD_SIF_MUNA:
inc_penance( old_god, 50 );
break;
+ case GOD_NEMELEX_XOBEH:
+ nemelex_shuffle_decks();
+ inc_penance( old_god, 50 );
+ break;
+
case GOD_LUGONU:
if ( you.level_type == LEVEL_DUNGEON )
{
@@ -3333,7 +3247,7 @@ void god_pitch(god_type which_god)
mprf("You %s the altar of %s.",
you.species == SP_NAGA ? "coil in front of"
: "kneel at",
- god_name(which_god));
+ god_name(which_god).c_str());
more();
// Note: using worship we could make some gods not allow followers to
@@ -3493,7 +3407,7 @@ void god_smites_you(god_type god, kill_method_type death_type,
!player_under_penance() && you.piety > random2(400))
{
snprintf(info, INFO_SIZE, "Mortal, I have averted the wrath "
- "of %s... this time.", god_name(god));
+ "of %s... this time.", god_name(god).c_str());
god_speaks(you.religion, info);
}
else
@@ -3687,14 +3601,12 @@ void handle_god_time(void)
// yet another wrapper for mpr() {dlb}:
void simple_god_message(const char *event, god_type which_deity)
{
- char buff[ INFO_SIZE ];
-
if (which_deity == GOD_NO_GOD)
which_deity = you.religion;
- snprintf( buff, sizeof(buff), "%s%s", god_name( which_deity ), event );
-
- god_speaks( which_deity, buff );
+ std::string msg = god_name(which_deity);
+ msg += event;
+ god_speaks( which_deity, msg.c_str() );
}
int god_colour( god_type god ) //mv - added
diff --git a/crawl-ref/source/religion.h b/crawl-ref/source/religion.h
index 989f2b716a..04df6bddfa 100644
--- a/crawl-ref/source/religion.h
+++ b/crawl-ref/source/religion.h
@@ -35,7 +35,7 @@ enum harm_protection_type
bool is_priest_god(god_type god);
void simple_god_message( const char *event, god_type which_deity = GOD_NO_GOD );
int piety_breakpoint(int i);
-const char *god_name(god_type which_god, bool long_name = false); //mv
+std::string god_name(god_type which_god, bool long_name = false);
void dec_penance(int val);
void dec_penance(god_type god, int val);
diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc
index 741f47309a..fae507cd1c 100644
--- a/crawl-ref/source/xom.cc
+++ b/crawl-ref/source/xom.cc
@@ -905,13 +905,13 @@ void xom_acts(bool niceness, int sever)
niceness = false;
mprf(MSGCH_GOD, which_god,
"%s asks Xom for help in punishing you, and Xom happily "
- "agrees.", god_name(which_god));
+ "agrees.", god_name(which_god).c_str());
}
else
{
niceness = true;
- mprf(MSGCH_GOD, which_god,
- "%s calls in a favour from Xom.", god_name(which_god));
+ mprf(MSGCH_GOD, which_god, "%s calls in a favour from Xom.",
+ god_name(which_god).c_str());
}
}