70728 Commits

Author SHA1 Message Date
Charles Dang
9614a4280a Cleaned up various util includes 2018-01-22 11:21:59 +11:00
Jyrki Vesterinen
0db553ef36 Restore bounded_add()
Partial revert of commit ecbb15e1c6d1106ff2f8e540c584523481426c04.

Replacing bounded_add() with std::clamp() in these contexts disables
time-of-day bonuses, since ToD bonuses (the base value in these functions)
are almost always outside the range set in terrain properties.
2018-01-21 17:27:51 +02:00
Charles Dang
ecbb15e1c6 Minor cleanups to math utils
* Dropped bounded_add for clamp. There's a slight behavior change with this, namely that
  base is no longer returned if it falls outside the bounds. However, for both usecases of
  bounded_add, that behavior doesn't make sense. The wiki clearly states min/max_light=
  define the bounds for light=.

* Replaced gcd with Boost's gcd function. We already use the latter in the Preferences
  dialog, so this is more consistent.

* Simplified the implementation of in_ranges.
2018-01-21 18:12:06 +11:00
vgaming
8ba6e5f40e fix code problems found by luacheck (#2380)
actual bugs found:
* backwards_compatibility.lua (undeclared global "helper")
* core.lua (use of undeclared global "helper")
* wml_tags.transform_unit had wrong code to deal with recall_cost
* wrong variable name in cave_map_generator
2018-01-20 23:05:58 -05:00
Celtic Minstrel
6fac83d3ad
Fix C++14 and C++17 detection 2018-01-20 22:03:01 -05:00
Charles Dang
d3e2ab9d22 Formatting cleanup of utils::contains impl
Makes this bit much easier to read.
2018-01-21 13:54:44 +11:00
Charles Dang
eb52503934 Remove use of __builtin_expect when building with GCC
__builtin_expect is something that should only be used if you're very sure it will result in
an optimization (see http://blog.man7.org/2012/10/how-much-do-builtinexpect-likely-and.html).

This code was added back in 2008. It seems it was part of an effort to get the preprocessor
functioning faster. It looks like mordante played some role in the decision of where to use
the LIKELY and UNLIKELY macros, so it's possible it had some use at the time (he's a rather
experienced programmer).

However, it's better to let the compiler automatically optimize code itself. I haven't done
any profiling on the preprocessor speed with or without __builtin_expect, but it doesn't seem
worth keeping this around and having to test every so often whether it's still useful or has
become a performance hit instead.

It's also worth noting that I myself noticed what seems a perceptible performance improvement
in the game (again, not backed by profiling) when I switched from TDM GCC to MSVC 2017. IIRC,
I'm using at least quick LTO for my builds. Apples and oranges, yes, but it also proves there
are likely various compiler options (such as LTO) which could improve performance on their own,
and better, than trying to point the program down branch paths ourselves.
2018-01-21 13:54:06 +11:00
Charles Dang
ba5ddc4bcb Use std::clamp with C++17 2018-01-21 13:54:06 +11:00
Charles Dang
deee52ce19 Added condition to define HAVE_CXX17 macro 2018-01-21 13:54:05 +11:00
Jyrki Vesterinen
220ac5f276 Disable control characters in autogenerated filenames (#2366)
On Windows, win32 programs such as Wesnoth aren't allowed to use control
characters in filenames, and therefore attempting to create a save file
whose name contains control characters will always fail. In addition, some
control characters (newlines in particular) also break Wesnoth's UI, as
regular text fields aren't intended to display multiple lines.

Fixes #2366.
2018-01-20 18:08:17 +02:00
newfrenchy83
9d2765e73a Update Wesnoth Code::Blocks project files (#2386) 2018-01-20 17:04:39 +02:00
newfrenchy83
1aaac42d3b Update wesnoth.cbp 2018-01-20 14:59:26 +02:00
josteph
24392b98ea Revert part of "GUI2 Textbox: Remove the other two emacs keybindings"
This reverts part of commit 468c6e0f494793d57b0b1264894cd7f0b0383fa2.

Ctrl+A was removed because its emacs meaning is surprising to some
people.  Ctrl+E was removed because it was the counterpart of Ctrl+A.
Ctrl+U however doesn't conflict with anything else, and it's useful
to some people (me), so reinstate it.
2018-01-20 11:40:40 +11:00
pentarctagon
5b31b87f6a MP: Renames the Khalifate to Dunefolk.
Part of an effort to make the faction better fit into Wesnoth. See:
https://forums.wesnoth.org/viewtopic.php?f=12&t=47643
https://forums.wesnoth.org/viewtopic.php?f=12&t=47703
2018-01-19 17:28:40 -05:00
Jyrki Vesterinen
fbb0e0229c Improve consistency of WML name validation functions
* moved the new function next to valid_id()
* renamed to valid_tag(), and renamed valid_id() to valid_attribute()
* removed unnecessary parentheses I forgot in
* changed the name of valid_id()'s parameter from "id" to "name"
* changed WML parser to use valid_tag() when it validates tag names

Thanks to @CelticMinstrel who told me about config::valid_id().
2018-01-19 20:27:53 +02:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
josteph
e952cb7c8b UI: Colorize the 'damage versus' tooltip and align the unit names. 2018-01-19 14:33:12 +11:00
Charles Dang
fa6df6d664 Core: wmlindent run
[ci skip]
2018-01-19 12:34:36 +11:00
Charles Dang
e938ac4147 EI S17: fixed incorrect type_tree key (should be type_adv_tree)
[ci skip]

Former was the old name before it was renamed to the latter.
2018-01-19 12:29:57 +11:00
Charles Dang
ae8f554e58 Campaigns: wmllint run
[ci skip]
2018-01-19 12:24:50 +11:00
Charles Dang
ca7e3c126d Campaigns: wmlindent run
[ci skip]
2018-01-19 12:20:04 +11:00
Charles Dang
10561d3e53 Remove empty [on_redo] action
This was introduced this development cycle (1.13) in 2015 (commit 6010455f563f4b16bb89f2df6893908a36251cdc)
and removed in 33c2e6aa67c9377f170f9302204a8de10c200564. Presumably the action was left for backwards
compatibility, but we do not guarantee backwards compatibility for changes that never made it to a stable
release.
2018-01-19 12:13:42 +11:00
doofus-01
48fa7d9461 remove specific mention of horses 2018-01-19 10:28:38 +11:00
doofus-01
c669a75e67 touch-up archer sprites 2018-01-19 10:28:38 +11:00
doofus-01
b5b1539143 base sprites for Quenoth scouts 2018-01-19 10:28:38 +11:00
V N
5209271db3 Lua: add variables metatable
The implementation differs from already-existing
wml.variable.proxy in that it does not try to proxy table sub-fields,
and is fast & simple.

Example usage:
wml.variables.test = 123
print(wml.variables.test)
2018-01-19 09:53:06 +11:00
Charles Dang
ba8aa80af8 Used a deque instead of a vector for active event handlers
Since events can be added and removed constantly, this should be more performance-friendly than
a vector since it avoids reallocations. Though, since this container only holds shared_ptrs instead
of the objects themselves, it probably doesn't make that much difference right now, but I might
switch to object-direct storage in the future. Not sure.
2018-01-18 20:48:52 +11:00
Jyrki Vesterinen
7aa39dc451 Go back to std::isalnum()
It turned out that it works fine as long as it's called with a char
rather than unsigned char. (But to add to the confusion, the other
variant of the function in <cctype> *requires* that cast.)
2018-01-18 10:05:24 +02:00
Jyrki Vesterinen
19e17e9417 Replace std::isalnum() with a hand-rolled implementation
The function seems to just throw std::bad_cast() in libstdc++ and libc++.
Fortunately it's very easy to write our own implementation instead.

Thanks to @Pentarctagon for the stack trace.
2018-01-18 09:41:57 +02:00
Richard Kettering
b969940ba4 Added frames for a ne stalwart attack. 2018-01-17 23:03:00 -06:00
Charles Dang
b8703b4527 MP Create Game: fix game load functionality being broken (fixes #2340)
Regression from 175e64cfaa0a18c85b5387d4464256b6c8cdf1cf.
2018-01-18 13:15:17 +11:00
Jyrki Vesterinen
52e3772c86 Lua API: reject invalid WML tag names (#2375)
Tags that the WML parser rejects shouldn't be possible to create with Lua,
either. This ensures that a UMC author can't accidentally, or deliberately,
inject such tags into the game state and make saving the game impossible.

Fixes #2375.
2018-01-17 23:52:34 +02:00
Jyrki Vesterinen
1386e3945c Added unit tests about which WML tag names Lua API accepts 2018-01-17 23:23:13 +02:00
Jyrki Vesterinen
3bc36efa58 Refuse to save if game state can't be represented as valid WML (#2375)
Such a save file can't be loaded anyway.
This way, at least the player can't overwrite an existing, working save
with one that cannot be loaded.
2018-01-17 21:05:44 +02:00
Alexander van Gessel
5df406869a
Clarify lifetime of defines maps
Wrap the bare pointer in a unique_ptr and move it into the sink.
2018-01-16 22:58:46 +01:00
Alexander van Gessel
f453f1422b
Indicate ownership transfer using unique_ptr argument
Best practice according to GotW #91.
https://herbsutter.com/2013/06/05/gotw-91-solution-smart-pointer-parameters/
2018-01-16 13:37:01 +01:00
Alexander van Gessel
65dd884b50
Store pointers in unique_ptr 2018-01-16 11:32:17 +01:00
Gregory A Lundberg
bbdb5ad86a
Fix control reaches end of non-void function
This only compiles on MS Visual C++ version 12.0, or earlier (Visual Studio 2013, or earlier).
2018-01-13 11:20:43 -06:00
Gregory A Lundberg
312af6064f
Remove incorrect noexcept clause
Do not mark a function as not throwing exceptions when it plainly does.
2018-01-13 10:36:00 -06:00
newfrenchy83
ceec498904 Update changelog (#2361)
(updated by ai0867)
2018-01-13 10:46:34 -05:00
Jyrki Vesterinen
8731930402 Fix: canceling attempt to reconnect didn't close addon manager
Only happened if the player used the buttons in the addon list: the buttons
in the right panel worked fine. The problem was that the addon list caught
the addons_client::user_exit exception separately and didn't rethrow it
when necessary, unlike the addon manager itself.

I decided to simply throw a different exception instead.
2018-01-13 14:59:58 +02:00
Jyrki Vesterinen
735c054bd3 Don't reconnect to server when the player cancels connecting to server
Requested by @loonycyborg.
2018-01-13 14:59:58 +02:00
Jyrki Vesterinen
c9ec111cf1 Addon client: close connection if the player cancels the download
This ensures that the game won't interpret the rest of the addon as a
response for the client's next request.

Fixes #2203.
2018-01-13 14:59:58 +02:00
Gunter Labes
03b6ad568c
Continue if there is an old executable
Chances are that the previous build works just as well.
We just need it for config file parsing which does not change often.
2018-01-12 19:14:41 +01:00
Sergey Popov
ed6ad71f48
Merge pull request #2329 from GregoryLundberg/GL_I2327
Implement MP Moderation
2018-01-12 17:50:19 +03:00
Charles Dang
8ae99bc86a Added some event unit tests by @Pentarctagon
Tests event execution order and events with variable names.
2018-01-11 13:12:28 -05:00
Charles Dang
88b0fe5953 Further reworking of event iteration interface
Fixes #2312. Turns out constructing a list of matching handlers breaks some undocumented
behavior, namely events being executed in the order they're added (usually the order in
which they appear in the WML). It also broke certain variable substitution by moving variable
interpolation wholly before any event execution, as opposed to between each event.

This commit implements an even simpler method: simply iterating through every registered
handler in order, checking for a name match on each one, and if it passes, immediately
executing the provided function. Cleanup will only occur once the toplevel call to
execute_on_events is completed.

This commit also removes the immediately cleanup upon removing a handler. This should
ensure (I didn't test explicitly, but from other incidental issues I'm sure this is the
case) the size of the main vector doesn't change during iteration.

I also changed the pre-add standardization code to only affect event names without variables.
Variable names are standardized later after variable substitution.
2018-01-11 13:12:28 -05:00
Gregory A Lundberg
395f8fac78
Fix doccomment 2018-01-10 18:02:44 -06:00
Jyrki Vesterinen
a65596e5b5 Fixed: label editor could create empty undoable action chain (#2306)
Empty action chains are not allowed, attempting to partially undo an empty
chain causes a fatal error.

This commit fixes some of the breakage reported in #2306, but not all.
2018-01-09 20:27:05 +02:00
Allefant
4de5cdc7d3 update the addon manager for "simple WML" 2018-01-09 09:23:50 +01:00