Skip to content

Commit

Permalink
get rid of preprocessor conditional
Browse files Browse the repository at this point in the history
having 2 different implementations (one for c++11 and one for c++03)
makes the code harder to maintain.
  • Loading branch information
gfgtdf committed Nov 11, 2014
1 parent 73b523a commit f777c3c
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions src/scripting/game_lua_kernel.cpp
Expand Up @@ -96,6 +96,8 @@
#include <boost/bind.hpp> // for bind_t, bind
#include <boost/foreach.hpp> // for auto_any_base, etc
#include <boost/intrusive_ptr.hpp> // for intrusive_ptr
#include <boost/range/algorithm.hpp> // boost::copy
#include <boost/range/adaptors.hpp> // boost::adaptors::filtered
#include <boost/tuple/tuple.hpp> // for tuple
#include <cassert> // for assert
#include <cstring> // for strcmp, NULL
Expand Down Expand Up @@ -1586,11 +1588,9 @@ static int intf_find_reach(lua_State *L)
return 1;
}

#ifdef HAVE_CXX11
static bool intf_find_cost_map_helper(const unit * ptr) {
return ptr->get_location().valid();
}
#endif

/**
* Is called with one or more units and builds a cost map.
Expand Down Expand Up @@ -1618,18 +1618,7 @@ static int intf_find_cost_map(lua_State *L)
}
else if (!filter.null()) // 1. arg - filter
{
const unit_filter ufilt(filter, resources::filter_con);

#ifdef HAVE_CXX11
std::vector<const unit *> matches = ufilt.all_matches_on_map();
std::copy_if(matches.begin(), matches.end(), std::back_inserter(real_units), &intf_find_cost_map_helper);
#else
BOOST_FOREACH(const unit * u, ufilt.all_matches_on_map()) {
if (u->get_location().valid()) {
real_units.push_back(u);
}
}
#endif
boost::copy(unit_filter(filter, resources::filter_con).all_matches_on_map() | boost::adaptors::filtered(&intf_find_cost_map_helper), std::back_inserter(real_units));
}
else // 1. + 2. arg - coordinates
{
Expand Down

0 comments on commit f777c3c

Please sign in to comment.