A better fix for the unit_type problems.

Unlike the last one it does not break help and also fixes creating
units in debug mode.
This commit is contained in:
Jörg Hinrichs 2008-03-30 21:57:29 +00:00
parent 754f9fc5db
commit ce8f0b4a78
2 changed files with 9 additions and 4 deletions

View File

@ -971,6 +971,8 @@ const unit_types_preview_pane::details unit_types_preview_pane::get_details() co
if (t==NULL)
return det;
unit_type_data::instance().unit_types.build_unit_type(t->id(), unit_type::WITHOUT_ANIMATIONS);
std::string mod = "~RC(" + t->flag_rgb() + ">" + team::get_side_colour_index(side_) + ")";
det.image = image::get_image(t->image()+mod);

View File

@ -917,9 +917,6 @@ void unit_type_data::set_config(const config& cfg)
increment_set_config_progress();
}
//Add dummy unit
unit_types.insert(std::pair<const std::string,unit_type>("dummy_unit",unit_type()));
unsigned base_unit_count = 0;
for(i = cfg.child_range("unit_type"); i.first != i.second; ++i.first)
{
@ -1030,7 +1027,13 @@ unit_type_data::unit_type_map::const_iterator unit_type_data::unit_type_factory:
//This might happen if units of another era are requested (for example for savegames)
if (itor == types_.end()){
return types_.find("dummy_unit");
itor == types_.find("dummy_unit");
if (itor != types_.end())
return itor;
else{
types_.insert(std::pair<std::string, unit_type>("dummy_unit", unit_type()) );
return types_.find("dummy_unit");
}
}
//check if the unit_type is constructed and build it if necessary