Refactored out last uses of boost::ptr_vector
The cases in whiteboard/mapbuilder.hpp needed to be vectors of unique_ptrs since their objects have deleted copy constructors.
This commit is contained in:
parent
c0f26a4787
commit
601c10cadf
8 changed files with 20 additions and 27 deletions
|
@ -292,9 +292,7 @@ void location_palette::adjust_size(const SDL_Rect& target)
|
|||
// Just skip it in that case.
|
||||
if(items_fitting > 0 && num_visible_items() != items_fitting) {
|
||||
location_palette_item lpi(disp_.video(), *this);
|
||||
//Why does this need a pointer to a non-const as second paraeter?
|
||||
//TODO: we should write our own ptr_vector class, boost::ptr_vector has a lot of flaws.
|
||||
buttons_.resize(items_fitting, &lpi);
|
||||
buttons_.resize(items_fitting, lpi);
|
||||
}
|
||||
|
||||
set_location(target);
|
||||
|
@ -419,8 +417,7 @@ void location_palette::add_item(const std::string& id)
|
|||
const auto itor = std::upper_bound(items_.begin(), items_.end(), id, loc_id_comp);
|
||||
if(itor == items_.begin() || *(itor - 1) != id) {
|
||||
pos = std::distance(items_.begin(), items_.insert(itor, id));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
pos = std::distance(items_.begin(), itor);
|
||||
}
|
||||
selected_item_ = id;
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
#include "editor/palette/common_palette.hpp"
|
||||
#include "editor/palette/tristate_button.hpp"
|
||||
|
||||
#include <boost/ptr_container/ptr_vector.hpp>
|
||||
|
||||
class location_palette_item;
|
||||
class location_palette_button;
|
||||
class game_config_view;
|
||||
|
@ -115,7 +113,7 @@ private:
|
|||
std::string selected_item_;
|
||||
std::vector<std::string> items_;
|
||||
editor_toolkit& toolkit_;
|
||||
boost::ptr_vector<location_palette_item> buttons_;
|
||||
std::vector<location_palette_item> buttons_;
|
||||
std::unique_ptr<location_palette_button> button_add_;
|
||||
std::unique_ptr<location_palette_button> button_delete_;
|
||||
std::unique_ptr<location_palette_button> button_goto_;
|
||||
|
|
|
@ -54,7 +54,7 @@ config& replay_recorder_base::get_command_at(int pos)
|
|||
config& replay_recorder_base::add_child()
|
||||
{
|
||||
assert(pos_ <= size());
|
||||
commands_.insert(commands_.begin() + pos_, new config());
|
||||
commands_.insert(commands_.begin() + pos_, config());
|
||||
++pos_;
|
||||
return commands_[pos_ - 1];
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ config& replay_recorder_base::insert_command(int index)
|
|||
{
|
||||
++pos_;
|
||||
}
|
||||
return *commands_.insert(commands_.begin() + index, new config());
|
||||
return *commands_.insert(commands_.begin() + index, config());
|
||||
}
|
||||
|
||||
|
||||
|
@ -101,7 +101,7 @@ void replay_recorder_base::append_config(const config& data)
|
|||
}
|
||||
for(const config& command : data.child_range("command"))
|
||||
{
|
||||
commands_.push_back(new config(command));
|
||||
commands_.push_back(command);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,9 +113,9 @@ void replay_recorder_base::append_config(config& data)
|
|||
}
|
||||
for(config& command : data.child_range("command"))
|
||||
{
|
||||
config* new_config = new config();
|
||||
new_config->swap(command);
|
||||
commands_.push_back(new_config);
|
||||
config new_config {};
|
||||
new_config.swap(command);
|
||||
commands_.push_back(std::move(new_config));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
#pragma once
|
||||
#include <cassert>
|
||||
#include <boost/ptr_container/ptr_vector.hpp>
|
||||
|
||||
#include "config.hpp"
|
||||
|
||||
|
@ -55,7 +54,7 @@ public:
|
|||
void delete_upcoming_commands();
|
||||
protected:
|
||||
config upload_log_;
|
||||
boost::ptr_vector<config> commands_;
|
||||
std::vector<config> commands_;
|
||||
int pos_;
|
||||
};
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ static lg::log_domain log_plugins("plugins");
|
|||
#define WRN_PLG LOG_STREAM(warn, log_plugins)
|
||||
#define ERR_PLG LOG_STREAM(err, log_plugins)
|
||||
|
||||
|
||||
struct plugin {
|
||||
struct plugin
|
||||
{
|
||||
std::string name;
|
||||
std::string source;
|
||||
bool is_file;
|
||||
|
@ -118,7 +118,7 @@ void plugins_manager::start_plugin(std::size_t idx)
|
|||
std::size_t plugins_manager::add_plugin(const std::string & name, const std::string & prog)
|
||||
{
|
||||
std::size_t idx = plugins_.size();
|
||||
plugins_.push_back(new plugin);
|
||||
plugins_.emplace_back();
|
||||
|
||||
plugin & p = plugins_[idx];
|
||||
p.name = name;
|
||||
|
@ -131,7 +131,7 @@ std::size_t plugins_manager::add_plugin(const std::string & name, const std::str
|
|||
std::size_t plugins_manager::load_plugin(const std::string & name, const std::string & filename)
|
||||
{
|
||||
std::size_t idx = plugins_.size();
|
||||
plugins_.push_back(new plugin);
|
||||
plugins_.emplace_back();
|
||||
|
||||
plugin & p = plugins_[idx];
|
||||
p.name = name;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "config.hpp"
|
||||
#include "utils/make_enum.hpp"
|
||||
|
||||
#include <boost/ptr_container/ptr_vector.hpp>
|
||||
#include <string>
|
||||
|
||||
struct plugin;
|
||||
|
@ -67,7 +66,8 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
boost::ptr_vector<plugin> plugins_;
|
||||
// TODO: this used to use boost::ptr_vector. Need to consider if there are some performance implications to not doing so
|
||||
std::vector<plugin> plugins_;
|
||||
std::shared_ptr<bool> playing_;
|
||||
std::unique_ptr<application_lua_kernel> kernel_;
|
||||
};
|
||||
|
|
|
@ -69,7 +69,7 @@ void mapbuilder::pre_build()
|
|||
//Units will be restored to the unit map by destruction of removers_
|
||||
|
||||
if(!on_current_side && !u.is_visible_to_team(resources::gameboard->teams()[viewer_team()], false)) {
|
||||
removers_.push_back(new temporary_unit_remover(resources::gameboard->units(), u.get_location()));
|
||||
removers_.emplace_back(new temporary_unit_remover(resources::gameboard->units(), u.get_location()));
|
||||
|
||||
//Don't do anything else to the removed unit!
|
||||
continue;
|
||||
|
@ -78,7 +78,7 @@ void mapbuilder::pre_build()
|
|||
//Reset movement points, to be restored by destruction of resetters_
|
||||
|
||||
//restore movement points only to units not on the current side
|
||||
resetters_.push_back(new unit_movement_resetter(u,!on_current_side));
|
||||
resetters_.emplace_back(new unit_movement_resetter(u,!on_current_side));
|
||||
//make sure current side's units are not reset to full moves on first turn
|
||||
if(on_current_side) {
|
||||
acted_this_turn_.insert(&u);
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include "side_actions.hpp"
|
||||
|
||||
#include <boost/ptr_container/ptr_vector.hpp>
|
||||
#include <list>
|
||||
|
||||
#include "utility.hpp"
|
||||
|
@ -66,8 +65,8 @@ private:
|
|||
action_queue applied_actions_this_turn_;
|
||||
|
||||
//Used by pre_build()
|
||||
boost::ptr_vector<unit_movement_resetter> resetters_;
|
||||
boost::ptr_vector<temporary_unit_remover> removers_;
|
||||
std::vector<std::unique_ptr<unit_movement_resetter>> resetters_;
|
||||
std::vector<std::unique_ptr<temporary_unit_remover>> removers_;
|
||||
|
||||
//Used by process()
|
||||
std::set<unit const*> acted_this_turn_;
|
||||
|
|
Loading…
Add table
Reference in a new issue