In many places, std::copy was used with back_inserters, or other
std::inserters. These have in most cases been replaced by using the
ranged insert member function of each stl container. Firstly, this makes more
readable code. Also, this is often more efficient because,
if the compiler can find the distance between the source iterators,
it only has to make one block allocation and then fill it
with values. In other cases, containers were being default constructed
and then std::copy'd into with some form of inserter. These were cleaned up
by using the iterator range constructor instead.
Use of std::copy was especially egregious in the case of associative
containers such as map and set. Sometimes back_inserter was
being used, other times std::inserter set at front, but it doesn't matter
because there is no front or back when inserting, and it's much cleaner
to just use set or map::insert(iterator begin, iterator end).
In a cost_map each hex is mapped to total cost to reach this hex
(for one or multiple units).
Note that the runtime of find_reach() is not really affected
when the parameter full_cost_map is NULL (default).
This removes some overhead that accommodated edge-weights (which is
not needed since Wesnoth maps bear vertex weights). Testing indicates
a reduction in execution times on the order of 1%-4%. Not much, but
this function is called fairly often.
This is an updated version of (my) patch #3122.
This is a general overhaul of the class embodying movement types,
featuring:
* Better data encapsulation
* Less duplication of code between unit.cpp and unit_type.cpp
* Easier to use
* New files for the class (VC and XCode projects still need updating)
* New (shorter) name for the class
Some additional revisions will be coming.
The primary motivation for this was to get a class that embodies
movement costs (part of the data encapsulation).
(by hitting 2, 3, etc.) when that unit had already moved. (Future
moves assumed current movement was maximum movement.)
This is not a real fix, but it handles all current cases, so it is an
improvement.
If present it's used instead of the movement to calculate the sight of the unit.
Support for [vision_costs] in [movement_type].
If present it's used for the costs when calculationg the sight of the unit.
Modified pathfind::paths to take a unit as argument instead of its
location; updated all callers.
As observed by mattsc, the function did in its callstack
re-query the unit at the location of a passed private proxy unit,
calculating the reach for the unit in the unit_map at that
location instead of the private one.
The other pathfind bindings already work for private proxy
units. Private lua proxy units were introduced after the pathfinder
functions were already exposed in the lua API.