Editor: don't make unit type copies in the editor palette

This commit is contained in:
Charles Dang 2018-06-29 05:53:44 +11:00
parent 292d6f407c
commit 9e29c2f1d1
4 changed files with 5 additions and 5 deletions

View file

@ -98,7 +98,7 @@ editor_action* mouse_action_unit::up_left(editor_display& disp, int x, int y)
return nullptr;
}
unit_type type = unit_palette_.selected_fg_item();
const unit_type& type = unit_palette_.selected_fg_item();
// Does this serve a purpose other than making sure the type is built?
// (Calling unit_types.build_unit_type(type) would now accomplish that

View file

@ -330,7 +330,7 @@ void editor_palette<Item>::draw_contents()
// Force compilation of the following template instantiations
template class editor_palette<t_translation::terrain_code>;
template class editor_palette<unit_type>;
template class editor_palette<const unit_type&>;
template class editor_palette<overlay>;
} // end namespace editor

View file

@ -97,8 +97,8 @@ void unit_palette::draw_item(const unit_type& u, surface& image, std::stringstre
unit_palette::unit_palette(editor_display &gui, const config& cfg,
editor_toolkit &toolkit)
//TODO avoid magic numbers
: editor_palette<unit_type>(gui, cfg, 36, 4, toolkit),
selected_bg_items_()
: editor_palette<const unit_type&>(gui, cfg, 36, 4, toolkit)
, selected_bg_items_()
{
}

View file

@ -29,7 +29,7 @@ class editor_toolkit;
//std::string get_selected_terrain();
/** Palette where the terrain to be drawn can be selected. */
class unit_palette : public editor_palette<unit_type> {
class unit_palette : public editor_palette<const unit_type&> {
public:
unit_palette(editor_display &gui,