fix whitespace
add command line option --unit, -u, to run scenario as a unit test

This is the initial commit for --unit, -u, unit test option.
This option is a modified version of --test, -t. Scenarios will
run in the same context essentially, but will terminate on
scenario end.

The exit code of wesnoth is 0 (PASS) if the scenario ended with
LEVEL_RESULT VICTORY, or LEVEL_RESULT NONE.

The exit code of wesnoth is 1 (FAIL) otherwise.

Higher exit codes may reflect a failure for a reason other than
the scenario ending in defate.
make unit tests run headlessly

specifying --unit is similar to --nogui. that is, this check is
essentially ||'d in at all places where --nogui would be checked
add WML macros for unit test scenarios

contains "generic_unit_test", "return" and "assert" macros
add WML unit test examples, and include the test directory

add some trivial tests, and the _main.cfg files to ensure they are included
add wml unit tests two and three

- test two tests a basic property of events
- test three tests unit placement on the map in
  case of a collision
add wml_unit_tests test aggregator script

This bash script runs a sequence of WML unit test scenarios.
If all pass the result is 0.
If any fails, the result is 1, and the std::cerr stored in "error.log".
We also add error.log to the .gitignore list.

It shows how --timeout and --validcache may be used in such a script
unit test timeouts: first attempt

use an SDL_Alarm to try to abort the process if it goes over time.
correct thread model for unit test timeouts

it seems that child threads can't terminate the whole process,
so we need to instead use a worker thread and make the
main thread the timer / return thread.
add --timeout to wml_unit_tests script

use the timeout feature as appropriate for automatic testing
add replay validation to unit tests

after unit tests play, then unless --noreplaycheck flag is used,
they save a replay at the end of the scenario (using autosave
code path), without compression. then they try to load it and
play it to completion.
this is the initial attempt.
Insert lua_unit's contained pointer directly

Not copying the unit improves the speed of wesnoth.put_unit by two orders
of magnitude from lua's perspective.

To do this, we have to take ownership of any owned pointer from lua_unit.
We do this by not running lua_unit's destructor, but just overwriting the memory it's in.
ai_helper.get_live_units: don't use filter_wml

It’s slow, the new method is between 10 and 20 times faster.
Lua AIs: do not use empty tables as filters

It’s faster not to provide any argument to wesnoth.get_units() if all
units are to be found.
Prevent Malifor from respawning in cave wall
ai_helper: remove a debug message

It’s served its purpose and is not needed any more.
add precise_timestamps setter
commandline option for precise timestamps
enable msvc bool conversion check.

we now enable warning 4800. I ran though the msvc compile with this
warning and i found some (in overlay.hpp, unit.cpp, whiteboard/move.cpp)
unintended implicit bool b = cfg["attributename"] casts that use
the implicit attribute_value to int cast and then a int to bool cast.
So for attributename=true b would be false. So i believe this
is a useful warning.

There are also a lot of implicit int to bool cast from the SDL and LUA
C-libraries which use int instead of bool because C doesn't have bool.
In this case this warning is less useful, but i still think it's worth
it since a "!= 0" or "== 1" isn't cost.

Plus if someone really wants to disable this warning he can still
disable it in the msvc project settings, while before is was not
possible for someone to enable this warning the the settings.
more robust replay.cpp functions

we now add nonundoable commands at the current position instead of
assuming
at_end(), this way nonundoable replay entrys like speak can now also be
added
while we are not at end.
Usually playturn_network_adapter ensures that we are always are at_end()
and i didn't get any error with the previous solution but the new
solution
is just more robust in case something goes wrong.
Note that we cannot add nonundoable commands at end if we aren’t at end
because
in that case the user would see the message again when he replays it.
Note that we cannot just do this for normal command because it might
bring the
replay in disorder.