Don't use a shared_ptr for recall list handling
This commit is contained in:
parent
c401f2db15
commit
e750b58519
3 changed files with 20 additions and 20 deletions
|
@ -172,7 +172,7 @@ void tunit_recall::pre_show(twindow& window)
|
|||
find_widget<tbutton>(&window, "show_help", false),
|
||||
std::bind(&tunit_recall::show_help, this, std::ref(window)));
|
||||
|
||||
for(const unit_const_ptr& unit : *recall_list_) {
|
||||
for(const unit_const_ptr& unit : recall_list_) {
|
||||
std::map<std::string, string_map> row_data;
|
||||
string_map column;
|
||||
|
||||
|
@ -227,12 +227,12 @@ void tunit_recall::pre_show(twindow& window)
|
|||
filter_options_.push_back(filter_text);
|
||||
}
|
||||
|
||||
list.register_sorting_option(0, [this](const int i) { return (*recall_list_)[i]->type_name().str(); });
|
||||
list.register_sorting_option(1, [this](const int i) { return (*recall_list_)[i]->name().str(); });
|
||||
list.register_sorting_option(2, [this](const int i) { return (*recall_list_)[i]->level(); });
|
||||
list.register_sorting_option(3, [this](const int i) { return (*recall_list_)[i]->experience(); });
|
||||
list.register_sorting_option(0, [this](const int i) { return recall_list_[i]->type_name().str(); });
|
||||
list.register_sorting_option(1, [this](const int i) { return recall_list_[i]->name().str(); });
|
||||
list.register_sorting_option(2, [this](const int i) { return recall_list_[i]->level(); });
|
||||
list.register_sorting_option(3, [this](const int i) { return recall_list_[i]->experience(); });
|
||||
list.register_sorting_option(4, [this](const int i) {
|
||||
return !(*recall_list_)[i]->trait_names().empty() ? (*recall_list_)[i]->trait_names().front().str() : "";
|
||||
return !recall_list_[i]->trait_names().empty() ? recall_list_[i]->trait_names().front().str() : "";
|
||||
});
|
||||
|
||||
list_item_clicked(window);
|
||||
|
@ -240,12 +240,12 @@ void tunit_recall::pre_show(twindow& window)
|
|||
|
||||
void tunit_recall::dismiss_unit(twindow& window)
|
||||
{
|
||||
LOG_DP << "Recall list units:\n"; dump_recall_list_to_console(*recall_list_);
|
||||
LOG_DP << "Recall list units:\n"; dump_recall_list_to_console(recall_list_);
|
||||
|
||||
tlistbox& list = find_widget<tlistbox>(&window, "recall_list", false);
|
||||
const int index = list.get_selected_row();
|
||||
|
||||
const unit& u = *recall_list_->at(index);
|
||||
const unit& u = *recall_list_[index].get();
|
||||
|
||||
// If the unit is of level > 1, or is close to advancing, we warn the player about it
|
||||
std::stringstream message;
|
||||
|
@ -273,7 +273,7 @@ void tunit_recall::dismiss_unit(twindow& window)
|
|||
}
|
||||
}
|
||||
|
||||
*recall_list_->erase(recall_list_->begin() + index);
|
||||
recall_list_.erase(recall_list_.begin() + index);
|
||||
|
||||
// Remove the entry from the dialog list
|
||||
list.remove_row(index);
|
||||
|
@ -315,7 +315,7 @@ void tunit_recall::list_item_clicked(twindow& window)
|
|||
}
|
||||
|
||||
find_widget<tunit_preview_pane>(&window, "unit_details", false)
|
||||
.set_displayed_unit(recall_list_->at(selected_row).get());
|
||||
.set_displayed_unit(recall_list_[selected_row].get());
|
||||
}
|
||||
|
||||
void tunit_recall::post_show(twindow& window)
|
||||
|
|
|
@ -33,7 +33,7 @@ class ttext_;
|
|||
|
||||
class tunit_recall : public tdialog
|
||||
{
|
||||
typedef std::shared_ptr<std::vector<unit_const_ptr> > recalls_ptr_vector;
|
||||
typedef std::vector<unit_const_ptr> recalls_ptr_vector;
|
||||
|
||||
public:
|
||||
tunit_recall(recalls_ptr_vector& recall_list, team& team);
|
||||
|
|
|
@ -614,16 +614,16 @@ void menu_handler::recall(int side_num, const map_location &last_hex)
|
|||
|
||||
team ¤t_team = teams()[side_num - 1];
|
||||
|
||||
std::shared_ptr<std::vector<unit_const_ptr > > recall_list_team = std::make_shared<std::vector<unit_const_ptr> >();
|
||||
std::vector<unit_const_ptr> recall_list_team;
|
||||
{ wb::future_map future; // ensures recall list has planned recalls removed
|
||||
*recall_list_team = actions::get_recalls(side_num, last_hex);
|
||||
recall_list_team = actions::get_recalls(side_num, last_hex);
|
||||
}
|
||||
|
||||
gui_->draw(); //clear the old menu
|
||||
|
||||
|
||||
DBG_WB <<"menu_handler::recall: Contents of wb-modified recall list:\n";
|
||||
for(const unit_const_ptr & unit : *recall_list_team)
|
||||
for(const unit_const_ptr & unit : recall_list_team)
|
||||
{
|
||||
DBG_WB << unit->name() << " [" << unit->id() <<"]\n";
|
||||
}
|
||||
|
@ -634,7 +634,7 @@ void menu_handler::recall(int side_num, const map_location &last_hex)
|
|||
" veteran survivors from a previous scenario)"));
|
||||
return;
|
||||
}
|
||||
if(recall_list_team->empty()) {
|
||||
if(recall_list_team.empty()) {
|
||||
gui2::show_transient_message(gui_->video(), "",
|
||||
_("You currently can't recall at the highlighted location"));
|
||||
return;
|
||||
|
@ -655,8 +655,8 @@ void menu_handler::recall(int side_num, const map_location &last_hex)
|
|||
// if it does we use it elsewise we use the team.recall_cost()
|
||||
// the magic number -1 is what it gets set to if the unit doesn't
|
||||
// have a special recall_cost of its own.
|
||||
if(recall_list_team->at(res)->recall_cost() > -1) {
|
||||
unit_cost = recall_list_team->at(res)->recall_cost();
|
||||
if(recall_list_team[res]->recall_cost() > -1) {
|
||||
unit_cost = recall_list_team[res]->recall_cost();
|
||||
}
|
||||
|
||||
int wb_gold = pc_.get_whiteboard() ? pc_.get_whiteboard()->get_spent_gold_for(side_num) : 0;
|
||||
|
@ -678,16 +678,16 @@ void menu_handler::recall(int side_num, const map_location &last_hex)
|
|||
map_location recall_from = map_location::null_location();
|
||||
std::string err;
|
||||
{ wb::future_map_if_active future; // future unit map removes invisible units from map, don't do this outside of planning mode
|
||||
err = actions::find_recall_location(side_num, recall_location, recall_from, *(recall_list_team->at(res)));
|
||||
err = actions::find_recall_location(side_num, recall_location, recall_from, *recall_list_team[res].get());
|
||||
} // end planned unit map scope
|
||||
if(!err.empty()) {
|
||||
gui2::show_transient_message(gui_->video(), "", err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pc_.get_whiteboard() || !pc_.get_whiteboard()->save_recall(*recall_list_team->at(res), side_num, recall_location)) {
|
||||
if (!pc_.get_whiteboard() || !pc_.get_whiteboard()->save_recall(*recall_list_team[res].get(), side_num, recall_location)) {
|
||||
bool success = synced_context::run_and_throw("recall",
|
||||
replay_helper::get_recall(recall_list_team->at(res)->id(), recall_location, recall_from),
|
||||
replay_helper::get_recall(recall_list_team[res]->id(), recall_location, recall_from),
|
||||
true,
|
||||
true,
|
||||
synced_context::ignore_error_function);
|
||||
|
|
Loading…
Add table
Reference in a new issue