91 Commits

Author SHA1 Message Date
Nathan Walker
5eee20be97 clean up instances of std::copy
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).
2014-03-19 21:23:27 -05:00
Mark de Wever
a2b8589143 Adds -Wextra-semi to pedantic compilation.
Also fixes all warning messages.
2014-01-26 14:24:12 +01:00
Mark de Wever
e8aef9dd37 Remove several Doxygen commit parameters.
The parameters were not part of the function signature.

The issue was found by Clang 3.4.
2014-01-05 16:36:16 +01:00
Ignacio R. Morelle
a4f47a63c7 New Year copyright update 2014-01-01 02:08:52 -03:00
fendrin
cd515e2f5f Fix spelling mistake. 2013-10-19 15:13:24 +02:00
flix
828c4bfb6b Modify lua function find_cost_map
- Add optin to use current moves instead of max_moves.
- Output a quadrupple
- Optional table for a standart location filter
2013-10-09 15:30:42 +02:00
flix
9b87de58b4 Add a feature to build a cost_map in pathfind.xpp
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).
2013-07-14 20:04:25 +02:00
Eric S. Raymond
043c4f9fd3 Remove $Id$ cookies. 2013-03-26 21:41:37 -04:00
J. Tyne
ccd9274c18 Support calculating vision paths without a complete unit. 2013-02-24 01:24:34 +00:00
J. Tyne
47b8f92309 More efficient version of find_routes().
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.
2013-02-23 01:14:32 +00:00
J. Tyne
2695f53f8f Some variable name changes taken from patch #3122.
Splitting these from the logic changes should make it easier to check
them.
2013-02-22 22:59:17 +00:00
J. Tyne
0892ebfbfa Wrap the pathfind/*.cpp files in "namespace pathfind".
This is instead of individually qualifying each (non-static) function
in these files as being in the namespace.
2013-02-22 22:34:05 +00:00
J. Tyne
7798fb3ad1 Refactor the interface to find_routes().
This function is local to pathfind.cpp, so this has very limited
impact. It will allow a reduction in the data stored in the undo
stack, though.
2013-02-22 19:51:04 +00:00
J. Tyne
34ed836039 Streamline some #include dependencies. 2013-02-22 15:27:57 +00:00
J. Tyne
73120612e3 Remove an unneeded class declaration.
This became unneeded in r56363, but I forgot to remove it.
2013-02-22 14:50:52 +00:00
J. Tyne
fd24c3c7c4 Documentation corrections/updates. 2013-02-22 00:13:46 +00:00
J. Tyne
e8d9dc33a6 Eliminate an unused parameter.
It would take more work to use this parameter, and all current uses
would have this parameter always be *resources::units anyway.
2013-02-21 22:22:05 +00:00
J. Tyne
31f1fb1be3 Eliminate a parameter that is always *resources::teams. 2013-02-21 21:37:00 +00:00
J. Tyne
cefb07f63b Eliminate a parameter that is always *resources::game_map. 2013-02-21 20:55:50 +00:00
J. Tyne
bb70a29017 Overhaul of unit_movement_type
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).
2013-02-20 02:25:14 +00:00
J. Tyne
51273aceb4 Eliminate some parameters that are always *resources::game_map. 2013-02-15 02:38:42 +00:00
Mark de Wever
f02a7bbd69 Fix some doxygen warnings. 2013-02-10 21:45:23 +00:00
Mark de Wever
e5b193d1e9 Fix a missing new year update. 2013-01-09 19:56:57 +00:00
Mark de Wever
43b71f2ff0 New year copyright update. 2013-01-01 09:22:03 +00:00
Mark de Wever
637436dba6 Remove an unused private field.
Issue found by Clang 3.2.
2012-12-22 13:40:15 +00:00
Mark de Wever
8d465edf34 Remove an unused private field.
Issue found by Clang 3.2.

Also renamed the 'height' member to the width is really is.
2012-12-22 13:39:32 +00:00
Alexander van Gessel
ff26ab4415 Replace some cast-to-string,lexical-cast-back with to_int and the like 2012-10-21 03:21:38 +01:00
J. Tyne
ea6acc4730 Make unit_ability_list's data private,
...and add definitions that allow the class to be used with
BOOST_FOREACH. This makes some code easier to read.
2012-08-25 18:11:06 +00:00
J. Tyne
0a0a3a83cd Quick fix for a problem viewing a unit's future moves
(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.
2012-08-06 02:04:24 +00:00
J. Tyne
f3631cd713 Get rid of parameters that are always...
...*resources::game_map, *resources::units.
2012-07-20 22:17:33 +00:00
J. Tyne
4680619bbc Prevent recruitment/recalling into/through shrouded hexes.
Rest of the fix for bug #19844.
2012-07-08 20:23:08 +00:00
Fabian Müller
5a5f696df6 Added a default to the switch over the pathfinding cost types. 2012-07-08 15:39:59 +00:00
Sergey Popov
6b6eafb213 Use BOOST_FOREACH directly instead of #define foreach BOOST_FOREACH
The define is extremely unreliable, will break compile with boost >=
1.50 and upstream can't fix issues with it, see
https://svn.boost.org/trac/boost/ticket/6131
2012-07-07 00:49:45 +00:00
Anonymissimus
ea64fce777 remove the default I case I added in 2012-05-08T14:00:37Z!anonymissimus@arcor.de
since gcc screams in case someone adds a value to the enum and it's
not handled in the switch
2012-05-08 19:03:00 +00:00
Anonymissimus
1f25d43a9e fix a MSVC9 compiler warning about "cost" being possibly uninitialized
(atm the enumeration doesn't have more types
so it could not have happened...)
2012-05-08 14:00:37 +00:00
Fabian Müller
fbbfadfc6b Support for jamming and report for vision and jamming in the unit help.
Changelog follows.
2012-05-08 00:05:33 +00:00
Fabian Müller
b6597782ee Support for vision= in [unit] and [unit_type].
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.
2012-04-30 18:03:48 +00:00
J. Tyne
af04480128 New specialization of "paths" class to implement vision.
Consequentially, shift edge-finding from clear_shroud_loc() to find_routes().

(Allows more streamlining, to come later.)
2012-04-13 19:49:11 +00:00
J. Tyne
dcd73d3ca3 Streamline enemy_zoc() and find_routes().
(Pass the current team as a parameter rather than team vector + current side.)
2012-04-13 18:59:17 +00:00
Anonymissimus
fba24f7ca0 Fix wesnoth.find_reach failing for private lua proxy units.
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.
2012-03-18 00:19:09 +00:00
Ignacio R. Morelle
f281c17fc1 Convert remaining uses of utils::string_bool()...
...on config attributes to use config::attribute_value::to_bool()
2012-02-29 09:11:28 +00:00
Ignacio R. Morelle
6ca69b2df5 New year copyright update 2012-01-07 02:35:17 +00:00
Nils Kneuper
68acf4157d fixed a gcc warning in src/pathfind/astarsearch.cpp...
...when compilung under openbsd (fixed bug #19095, thanks George
Koehler <kernigh>)
2011-12-04 13:30:13 +00:00
Gabriel Morin
451b902b25 Added operator== to pathfind::marked_route::mark struct. 2011-11-23 13:39:24 +00:00
Alexander van Gessel
81e0a2007f Revert token t_token commits from 2011-09-08T19:15:40Z!thonsew@yahoo.com on. 2011-10-10 03:43:29 +01:00
Thonsew
fcba175936 Updated terrain_filter to
1. Use t_token in place of string literals to improve speed

2. Use unordered_set in place of std::set to improve terrain filter
lookup times.
2011-09-08 19:16:12 +00:00
Gabriel Morin
192e7a017e Completely removed the waypoint functionality on 'w' key,
...since the whiteboard is now an adequate replacement.

Fixes bug #17060
2011-09-08 00:52:38 +00:00
Steven Panek
565fdc7801 Ran umcpropfix. 2011-06-20 23:23:26 +00:00
Alexander van Gessel
b8f090d386 Ignore toplevel [tunnel]s rather than failing an assertion (bug #18201) 2011-06-13 16:39:38 +01:00
Fabian Müller
6c8fa57dfe Documented the c++ interface to the [tunnel] feature. 2011-03-09 11:42:09 +00:00