made it so 'gender' works with move_unit_fake

This commit is contained in:
Dave White 2004-08-13 03:11:31 +00:00
parent 6bbcd30a36
commit 896b85613d
7 changed files with 26 additions and 10 deletions

View file

@ -433,9 +433,10 @@ bool event_handler::handle_event_command(const queued_event& event_info, const s
//the visual effect
else if(cmd == "move_unit_fake") {
const std::string& type = cfg["type"];
const unit_race::GENDER gender = cfg["gender"] == "female" ? unit_race::FEMALE : unit_race::MALE;
const game_data::unit_type_map::const_iterator itor = game_data_ptr->unit_types.find(type);
if(itor != game_data_ptr->unit_types.end()) {
unit dummy_unit(&itor->second,0,false,true);
unit dummy_unit(&itor->second,0,false,true,gender);
const std::vector<std::string> xvals = config::split(cfg["x"]);
const std::vector<std::string> yvals = config::split(cfg["y"]);
std::vector<gamemap::location> path;

View file

@ -381,6 +381,7 @@ void load_game(const game_data& data, const std::string& name, game_state& state
void save_game(const game_state& state)
{
log_scope("save_game");
std::string name = state.label;
std::replace(name.begin(),name.end(),' ','_');
@ -389,17 +390,20 @@ void save_game(const game_state& state)
write_game(state,cfg);
const std::string fname = get_saves_dir() + "/" + name;
/*
write_file(fname,cfg.write());
config& summary = save_summary(state.label);
extract_summary_data_from_save(state,summary);
const int mod_time = static_cast<int>(file_create_time(fname));
summary["mod_time"] = str_cast(mod_time);
write_save_index();
*/
} catch(io_exception& e) {
throw gamestatus::save_game_failed(e.what());
};
}
}
namespace {
@ -450,6 +454,7 @@ void delete_save_summary(const std::string& save)
void write_save_index()
{
log_scope("write_save_index()");
try {
write_file(get_save_index_file(),save_index().write());
} catch(io_exception& e) {

View file

@ -13,4 +13,8 @@
#include "log.hpp"
#include <unistd.h>
#include <sstream>
int scope_logger::indent = 0;

View file

@ -25,18 +25,24 @@
struct scope_logger
{
scope_logger(const std::string& str) : ticks_(SDL_GetTicks()), str_(str) {
for(int i = 0; i != indent; ++i)
std::cerr << " ";
++indent;
do_indent();
std::cerr << "BEGIN: " << str_ << "\n";
do_indent();
++indent;
}
~scope_logger() {
const int ticks = SDL_GetTicks() - ticks_;
--indent;
do_indent();
do_indent();
std::cerr << "END: " << str_ << " (took " << ticks << "ms)\n";
}
void do_indent()
{
for(int i = 0; i != indent; ++i)
std::cerr << " ";
std::cerr << "END: " << str_ << " (took " << ticks << "ms)\n";
}
private:

View file

@ -162,7 +162,7 @@ void turn_info::turn_slice()
tooltips::process(mousex,mousey,mouse_flags & SDL_BUTTON_LMASK);
const int scroll_threshold = preferences::fullscreen() ? 5 : 0;
const int scroll_threshold = 5;
if(key_[SDLK_UP] || mousey < scroll_threshold)
gui_.scroll(0,-preferences::scroll_speed());

View file

@ -67,8 +67,8 @@ unit_race::GENDER unit::generate_gender(const unit_type& type, bool gen)
}
//constructor for creating a new unit
unit::unit(const unit_type* t, int side, bool use_traits, bool dummy_unit) :
gender_(generate_gender(*t,use_traits)),
unit::unit(const unit_type* t, int side, bool use_traits, bool dummy_unit, unit_race::GENDER gender) :
gender_(dummy_unit ? gender : generate_gender(*t,use_traits)),
type_(t->get_gender_unit_type(gender_)), state_(STATE_NORMAL),
hitpoints_(type_->hitpoints()),
maxHitpoints_(type_->hitpoints()),

View file

@ -32,7 +32,7 @@ public:
friend struct unit_movement_resetter;
unit(const game_data& data, const config& cfg);
unit(const unit_type* t, int side, bool use_traits=false, bool dummy_unit=false);
unit(const unit_type* t, int side, bool use_traits=false, bool dummy_unit=false, unit_race::GENDER gender=unit_race::MALE);
//a constructor used when advancing a unit
unit(const unit_type* t, const unit& u);