Skip to content

Commit

Permalink
Few minor code cleanups I had sitting around
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Jan 16, 2021
1 parent f29ff05 commit 6a0baa5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/ai/formula/ai.cpp
Expand Up @@ -260,8 +260,7 @@ pathfind::teleport_map formula_ai::get_allowed_teleports(unit_map::iterator& uni

void formula_ai::add_formula_function(const std::string& name, const_formula_ptr formula, const_formula_ptr precondition, const std::vector<std::string>& args)
{
formula_function_ptr fcn(new user_formula_function(name,formula,precondition,args));
function_table_.add_function(name, std::move(fcn));
function_table_.add_function(name, std::make_shared<user_formula_function>(name, formula, precondition, args));
}

namespace {
Expand Down
4 changes: 2 additions & 2 deletions src/gui/dialogs/attack_predictions.cpp
Expand Up @@ -385,15 +385,15 @@ hp_probability_vector attack_predictions::get_hitpoint_probabilities(const std::
}

// Then sort by descending probability.
std::sort(temp_vec.begin(), temp_vec.end(), [](const hp_probability_t& pair1, const hp_probability_t& pair2) {
std::sort(temp_vec.begin(), temp_vec.end(), [](const auto& pair1, const auto& pair2) {
return pair1.second > pair2.second;
});

// Take only the highest probability values.;
std::copy_n(temp_vec.begin(), std::min<int>(graph_max_rows, temp_vec.size()), std::back_inserter(res));

// Then, we sort the hitpoint values in descending order.
std::sort(res.begin(), res.end(), [](const hp_probability_t& pair1, const hp_probability_t& pair2) {
std::sort(res.begin(), res.end(), [](const auto& pair1, const auto& pair2) {
return pair1.first > pair2.first;
});

Expand Down
4 changes: 1 addition & 3 deletions src/gui/dialogs/attack_predictions.hpp
Expand Up @@ -29,9 +29,7 @@ class drawing;

namespace dialogs
{

using hp_probability_t = std::pair<int, double>;
using hp_probability_vector = std::vector<hp_probability_t>;
using hp_probability_vector = std::vector<std::pair<int, double>>;

class attack_predictions : public modal_dialog
{
Expand Down
7 changes: 1 addition & 6 deletions src/units/unit.hpp
Expand Up @@ -207,14 +207,9 @@ class unit : public std::enable_shared_from_this<unit>

unit_ptr clone() const
{
return unit_ptr(std::shared_ptr<unit>(new unit(*this)));
return std::shared_ptr<unit>(new unit(*this));
}

//unit_ptr shared_from_this()
//{
// return unit_ptr(this);
//}

virtual ~unit();

void swap(unit&);
Expand Down

0 comments on commit 6a0baa5

Please sign in to comment.