summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/initfile.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-09 18:32:42 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-09 18:32:42 +0000
commitdbe4130e239966c0e524704123c0fb094a07e7ec (patch)
treeb8af350a2c73a21cfda3f11ad2163584e96011c9 /crawl-ref/source/initfile.cc
parentd108ecc79d0f633f43e6fa5f28f3f94c3d35adfd (diff)
downloadcrawl-ref-dbe4130e239966c0e524704123c0fb094a07e7ec.tar.gz
crawl-ref-dbe4130e239966c0e524704123c0fb094a07e7ec.zip
[Fix 1851878] Make options cls = random and race = random work in combination.
Also add the "Welcome, <name> the <species> <class>" 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
Diffstat (limited to 'crawl-ref/source/initfile.cc')
-rw-r--r--crawl-ref/source/initfile.cc22
1 files changed, 14 insertions, 8 deletions
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")
{