recruit::recruit(size_t team_index, const std::string& unit_name, const map_location& recruit_hex): action(team_index), unit_name_(unit_name), recruit_hex_(recruit_hex), temp_unit_(create_corresponding_unit()), valid_(true), fake_unit_(create_corresponding_unit(), wb::fake_unit_deleter()), temp_cost_() { fake_unit_->set_location(recruit_hex_); fake_unit_->set_movement(0); fake_unit_->set_attacks(0); fake_unit_->set_ghosted(false); resources::screen->place_temporary_unit(fake_unit_.get()); }
recruit::recruit(size_t team_index, bool hidden, const std::string& unit_name, const map_location& recruit_hex): action(team_index,hidden), unit_name_(unit_name), recruit_hex_(recruit_hex), temp_unit_(create_corresponding_unit()), //auto-ptr ownership transfer fake_unit_(unit_ptr(new unit(*temp_unit_))), //temp_unit_ *copied* into new fake unit cost_(0) { this->init(); }
recruit::recruit(const config& cfg, bool hidden) : action(cfg,hidden) , unit_name_(cfg["unit_name_"]) , recruit_hex_(cfg.child("recruit_hex_")["x"],cfg.child("recruit_hex_")["y"], wml_loc()) , temp_unit_() , fake_unit_() , cost_(0) { // Validate unit_name_ if(!unit_types.find(unit_name_)) throw action::ctor_err("recruit: Invalid recruit unit type"); // Construct temp_unit_ and fake_unit_ temp_unit_ = create_corresponding_unit(); //auto-ptr ownership transfer fake_unit_.reset(unit_ptr (new unit(*temp_unit_))), //temp_unit_ copied into new fake_unit this->init(); }