70899 Commits

Author SHA1 Message Date
Alexander van Gessel
45a61de238 Initialize all members
Found by coverity.
2018-01-24 16:16:52 +01:00
Gregory A Lundberg
b5f6e43efd
Fix Coverity 1385374 uninitialized member 2018-01-24 09:13:44 -06:00
Charles Dang
207e763401 Improved handling of race icons (fixes #2030)
* The editor_icon= key will now be respected in the Unit Preview Pane
* If no appropriate icon is found, a generic icon will be used instead, in both the editor
  and unit preview pane.
2018-01-25 00:10:02 +11:00
Charles Dang
8903ea9446 ToD Manager: don't write stub ToD to scenario file (fixes #2302) 2018-01-24 16:24:50 +11:00
Charles Dang
3dc8617ec9 Fixup c8b0833 (crash when creating scenario in Editor)
There's no AI manager in the editor (a game state is required), nor a need for one, so I simply
disabled the AI initialization if we're not in the editor.
2018-01-24 16:12:57 +11:00
Gregory A Lundberg
e9e22f30b7 fix wreorder variable initialized before other 2018-01-24 14:29:01 +11:00
Jyrki Vesterinen
c8b0833b1a Make AI manager a singleton
Fixes #2372.

It turned out that the AI kept dangling references to the old Lua state,
and crashed while destroying AI contexts for destroyed sides.

The best way to avoid it is to ensure that game_state, which already owns
the Lua state, also owns the AI. That way, the AI will be destroyed before
the Lua state and a dangling reference can't stay.
2018-01-24 14:29:01 +11:00
Charles Dang
671cebe035 TSG: tweak description slightly
[ci skip]
2018-01-24 12:00:14 +11:00
Charles Dang
e432ec3358 GUI2/Drop Down Menu: fixed row toggle callback not firing when selecting row
Regression introduced in 775970f9209a423f0f0d383c0d7634ae722f825b since set_value_bool
no longer automatically fired the event.
2018-01-24 10:39:47 +11:00
vgaming
728204665c fix code problems found by luacheck (#2388)
fix code problems found by luacheck

Second iteration of the process, now handling data/lua/wml/*.lua

luacheck command used to find bugs:
  luacheck ./*.lua --globals wesnoth wml --codes --ignore 542 213
Additionally, error code 211 (unused variables) could be ignored,
as using underscore convention `_` is controversial in
wesnoth ( see https://github.com/wesnoth/wesnoth/pull/2380#discussion_r162519341 )

Actual bugs found:
* items.lua, access of global `write_name` instead of local `cfg.write_name`
* kill.lua, typo `primary_unit` -> `primary`
* bad code style: global `i` instead of local `i`
  (would conflict with 3-rd party code if it would use global `i`, too)
2018-01-23 13:35:04 -06:00
pentarctagon
729b2984f7 Have cmake not copy over everything for server-only installs. 2018-01-23 13:26:34 -06:00
Charles Dang
e34341145f Campaign Selection: removed excess borders around sort buttons
[ci skip]
2018-01-23 17:12:47 +11:00
Charles Dang
2e7b041eb5 Fixed map labels jumping around the map on scroll (fixes #2333)
Fixup 089fc02c298e7e4f6ed6bc57935cbf4811a03234. Not sure why this works, though.
-xmove, -ymove worked fine on accelerated_rendering... Or perhaps I just didn't
notice this issue.
2018-01-23 17:12:46 +11:00
Alexander van Gessel
32119a5a05 Initialize all members
Found by coverity.
2018-01-22 17:29:24 +01:00
Gregory A Lundberg
84da344dbe
Fix errors in f23305f7e247
MSCV may accept a modifer between typename and the type name, but clang and gcc don't.
2018-01-22 09:50:52 -06:00
Charles Dang
f23305f7e2 Formatting cleanup: T const& -> const T& 2018-01-23 01:26:23 +11:00
V N
f4e9ac3f8f remove executable flag from images 2018-01-22 23:11:14 +11:00
Charles Dang
da3a0ed7cf Added [lua] conditional tag
Also made conditions fail if they encountered a syntax or runtime error. This seems the
more logical behavior than passing.

WML conditional tags were split into their own Lua file. The one in lua/wml/object.lua
relies on local variables so was left there.
2018-01-22 23:03:16 +11:00
Wedge009
ff3412b67a Avoid type mismatch warning.
std::streamsize definition says that negative values are never used (outside std::strstreambuf constructor).
2018-01-22 15:51:59 +11:00
pentarctagon
1192b0f1e5 Rename the Khalid's shield bash to pommel strike.
The sprite has two swords, not a shield.
2018-01-22 12:04:42 +11:00
josteph
a2be9c8f86 Hide 'Rails' and 'Fake Shroud' terrains in the unit help pages when impassable.
Fixes #1399. Supersedes #536.
2018-01-22 11:54:09 +11:00
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