added option to preferences file, 'unit_genders',

which determines whether units with different genders should be used
This commit is contained in:
Dave White 2004-10-02 15:53:58 +00:00
parent cefce3bb8e
commit d96eec74c3
3 changed files with 23 additions and 1 deletions

View File

@ -47,6 +47,8 @@ bool message_private_on = true;
bool haloes = true;
bool unit_genders = true;
std::set<std::string> encountered_units_set;
std::set<std::string> encountered_terrains_set;
@ -62,6 +64,7 @@ manager::manager()
set_colour_cursors(prefs["colour_cursors"] == "yes");
set_show_haloes(prefs["show_haloes"] != "no");
set_show_unit_genders(prefs["unit_genders"] != "no");
std::vector<std::string> v;
v = config::split(prefs["encountered_units"]);
@ -560,6 +563,17 @@ void set_show_haloes(bool value)
prefs["show_haloes"] = value ? "yes" : "no";
}
bool show_unit_genders()
{
return unit_genders;
}
void set_show_unit_genders(bool value)
{
prefs["unit_genders"] = value ? "yes" : "no";
unit_genders = value;
}
std::set<std::string> &encountered_units() {
return encountered_units_set;
}

View File

@ -113,6 +113,9 @@ namespace preferences {
bool show_haloes();
void set_show_haloes(bool value);
bool show_unit_genders();
void set_show_unit_genders(bool value);
std::set<std::string> &encountered_units();
std::set<std::string> &encountered_terrains();

View File

@ -17,6 +17,7 @@
#include "language.hpp"
#include "log.hpp"
#include "pathfind.hpp"
#include "preferences.hpp"
#include "replay.hpp"
#include "unit.hpp"
#include "util.hpp"
@ -60,6 +61,10 @@ unit::unit(const game_data& data, const config& cfg) : state_(STATE_NORMAL),
unit_race::GENDER unit::generate_gender(const unit_type& type, bool gen)
{
if(preferences::show_unit_genders() == false) {
gen = false;
}
const std::vector<unit_race::GENDER>& genders = type.genders();
if(genders.empty() == false) {
return gen ? genders[get_random()%genders.size()] : genders.front();
@ -596,7 +601,7 @@ void unit::read(const game_data& data, const config& cfg)
assert(type_ != NULL);
const std::string& gender = cfg["gender"];
const std::string& gender = preferences::show_unit_genders() ? cfg["gender"] : "";
if(gender == "male") {
gender_ = unit_race::MALE;
} else if(gender == "female") {