From dbe4130e239966c0e524704123c0fb094a07e7ec Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Sun, 9 Mar 2008 18:32:42 +0000 Subject: [Fix 1851878] Make options cls = random and race = random work in combination. Also add the "Welcome, the " to the selection screens for weapons and such. While this mostly is necessary if you've got cls and race both set to random, it is also useful for people like me who cannot remember what combination they've just chosen. :p git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3557 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/initfile.cc | 22 ++++++++++++++-------- crawl-ref/source/newgame.cc | 37 ++++++++++++++++++++++++++++++------- 2 files changed, 44 insertions(+), 15 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 0e6e1f2d85..22fb404cfc 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -321,8 +321,11 @@ static fire_type str_to_fire_types( const std::string &str ) static char str_to_race( const std::string &str ) { - int index = -1; + if (str == "random") + return '*'; + int index = -1; + if (str.length() == 1) // old system of using menu letter return (str[0]); else if (str.length() == 2) // scan abbreviations @@ -332,11 +335,17 @@ static char str_to_race( const std::string &str ) if (index == -1) index = get_species_index_by_name( str.c_str() ); + if (index == -1) + fprintf( stderr, "Unknown race choice: %s\n", str.c_str() ); + return ((index != -1) ? index_to_letter( index ) : 0); } static int str_to_class( const std::string &str ) { + if (str == "random") + return '*'; + int index = -1; if (str.length() == 1) // old system of using menu letter @@ -348,7 +357,10 @@ static int str_to_class( const std::string &str ) if (index == -1) index = get_class_index_by_name( str.c_str() ); - return ((index != -1) ? index_to_letter( index ) : 0); + if (index == -1) + fprintf( stderr, "Unknown class choice: %s\n", str.c_str() ); + + return ((index != -1) ? index_to_letter( index ) : 0); } static bool read_bool( const std::string &field, bool def_value ) @@ -2066,16 +2078,10 @@ void game_options::read_option_line(const std::string &str, bool runscript) else if (key == "race") { race = str_to_race( field ); - - if (race == 0) - fprintf( stderr, "Unknown race choice: %s\n", field.c_str() ); } else if (key == "class") { cls = str_to_class( field ); - - if (cls == 0) - fprintf( stderr, "Unknown class choice: %s\n", field.c_str() ); } else if (key == "auto_list") { diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc index 9adc168062..244e4720cc 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -533,6 +533,20 @@ static std::string prev_startup_description(void) get_opt_class_name(Options.prev_cls); } +// Output full character info when weapons/books/religion are chosen. +static void print_character_info() +{ + // At this point all of name, species and class should be decided. + if (strlen(you.your_name) > 0 + && you.char_class != JOB_UNKNOWN && you.species != SP_UNKNOWN) + { + cprintf("Welcome, "); + textcolor( YELLOW ); + cprintf("%s the %s %s." EOL, you.your_name, species_name(you.species, 1).c_str(), + get_class_name(you.char_class)); + } +} + int give_first_conjuration_book() { // Assume the fire/earth book, as conjurations is strong with fire -- bwr @@ -1064,6 +1078,7 @@ static undead_state_type get_undead_state(const species_type sp) bool new_game(void) { + clrscr(); init_player(); if (!crawl_state.startup_errors.empty() @@ -1112,6 +1127,7 @@ game_start: else { if (Options.race != 0 && Options.cls != 0 + && Options.race != '*' && Options.cls != '*' && !class_allowed(get_species(letter_to_index(Options.race)), get_class(letter_to_index(Options.cls)))) { @@ -1880,8 +1896,11 @@ static bool choose_book( item_def& book, int firstbook, int numbooks ) if ( !Options.random_pick ) { + clrscr(); + print_character_info(); + textcolor( CYAN ); - cprintf(EOL " You have a choice of books:" EOL); + cprintf(EOL "You have a choice of books:" EOL); textcolor( LIGHTGREY ); for (int i=0; i < numbooks; ++i) @@ -1975,9 +1994,10 @@ static bool choose_weapon() if (!Options.random_pick && Options.weapon != WPN_RANDOM) { clrscr(); + print_character_info(); textcolor( CYAN ); - cprintf(EOL " You have a choice of weapons:" EOL); + cprintf(EOL "You have a choice of weapons:" EOL); textcolor( LIGHTGREY ); bool prevmatch = false; @@ -3755,9 +3775,10 @@ bool give_items_skills() else { clrscr(); - + print_character_info(); + textcolor( CYAN ); - cprintf(EOL " Which god do you wish to serve?" EOL); + cprintf(EOL "Which god do you wish to serve?" EOL); textcolor( LIGHTGREY ); cprintf("a - Zin (for traditional priests)" EOL); @@ -4360,9 +4381,10 @@ bool give_items_skills() else { clrscr(); - + print_character_info(); + textcolor( CYAN ); - cprintf(EOL " From where do you draw your power?" EOL); + cprintf(EOL "From where do you draw your power?" EOL); textcolor( LIGHTGREY ); cprintf("a - Necromantic magic" EOL); @@ -4486,9 +4508,10 @@ bool give_items_skills() else { clrscr(); + print_character_info(); textcolor( CYAN ); - cprintf(EOL " Which god of chaos do you wish to serve?" EOL); + cprintf(EOL "Which god of chaos do you wish to serve?" EOL); textcolor( LIGHTGREY ); cprintf("a - Xom of Chaos" EOL); -- cgit v1.2.3-54-g00ecf