Commit graph

144 commits

Author SHA1 Message Date
loonycyborg
0e06f70dda Made regex for matching network addresses stricter 2019-01-06 12:49:50 +03:00
loonycyborg
34e2ef12c7 Add support for ipv6 addresses to addon client and multiplayer client
ipv6 address must be specifid surrounded by [], like [ipv6_address]:port,
since otherwise impossible to disambiguate colons separating ipv6 quads
from the colon delimiting port
2019-01-04 17:45:39 +03:00
josteph
91db37daab irdya_date: Fix comparison of BW/BF years returning true for both 12 BW < 34 BW and 34 BW < 12 BW.
The block on line 99 was entered for BW years, but shouldn't have been.

Fixes #3187.

(cherry picked from commit 5e97d1505f)
2018-10-19 19:12:55 +00:00
Martin Hrubý (hrubymar10)
674fda85b7 Migrate links to https if available - Fwd c18537edc0
(cherry-picked from commit bc4d22dc72)
2018-10-07 03:23:36 +00:00
gfgtdf
745abef62d cancel faction_select when the game starts
or when the hosts assigned  control of  that side to another player.

(cherry-picked from commit 2dd6557449)
2018-10-07 03:23:04 +00:00
Charles Dang
eb9a219c5f Used std::string::front() and back() in more places
(cherry-picked from commit ed8a8a48f7)
2018-10-07 03:21:54 +00:00
Charles Dang
2a6d9454de Replaced round_double and round_portable with std::round
std::round(double) uses the desired half-away-from-0 method.

(cherry-picked from commit 29fcbd053d)
2018-10-07 03:19:14 +00:00
Charles Dang
68f066d94a Removed bind_void
This is no longer needed with the compilers we support. It is needed on VS 2013, but
we dropped that. Don't know when GCC or Clang stopped needed it (if they ever did).

I'm guessing the "function that returns a value cannot be bound in a function type
that returns void" behavior wasn't an intentional design. Additionally, I don't believe
point 1 raised in the accompanying comment has ever been true... if so, pretty sure
we wouldn't have been able to build at all.

Also removed unnecessary global.hpp include from functional.hpp.

(cherry-picked from commit 17fc9d71db)
2018-10-07 03:19:12 +00:00
Martin Hrubý
b41d523461 Fixed typo
(cherry-picked from commit 31192cb44b)
2018-10-07 03:18:50 +00:00
Charles Dang
dfce371287 Convert custom unicode type aliases to proper types (available as of C++11)
This changes:
utf8::char_t   ->  char
utf8::string   ->  std::string
utf16::char_t  ->  char16_t
utf16::string  ->  std::u16string
ucs4::char_t   ->  char32_t
ucs4::string   ->  std::u32string

utf16::string and ucs4::string are now proper strings instead of vectors of characters too.

In order to get this change to compile at all, I needed to add a ucs4_convert_impl::convert_impl
specialization for wchar_t alongside the new char16_t specialization; both point to the same
conversion implementation type.

This commit doesn't do any additional cleanup. I'm sure if we looked, we could get rid of a
lot of the custom conversion code and probably a bunch of stuff that might have had to do with
supporting utf16::string and ucs4::string being vectors instead of basic_string specializations.
Either way, I don't know the code (or encoding handling in general) to make a call as to what's
needed or not. I'll let someone else do that.

(cherry-picked from commit 1deacd89f6)
2018-10-07 03:18:49 +00:00
Charles Dang
45f871067f Use std::size_t everywhere instead of plain size_t
Excludes:
* spirit_po/
* xBRZ/

(cherry-picked from commit fc2a58f693)
2018-10-07 03:17:59 +00:00
Charles Dang
7785d711ed Removed the type trait alias wrappers
This completely removes the wrappers for aliases included in c++14. It also enables
use of the value alias wrappers, since we now have variable templates.

(cherry-picked from commit c1fcba17b7)
2018-10-07 03:17:55 +00:00
Charles Dang
4f1c4dcafd Used std::put time everywhere
The utils::put_time wrapper was only for GCC 4.x.

(cherry-picked from commit 80c2d1a405)
2018-10-07 03:17:55 +00:00
Charles Dang
24cc0b01d4 Used constexpr and noexcept keywords directly
We can do this now since were bumping min compiler support.

(cherry-picked from commit 8120843b2e)
2018-10-07 03:17:55 +00:00
Charles Dang
950a156712 Addressed most of the remaining whitespace issues from #2613
[ci skip]
2018-03-11 14:59:37 +11:00
Charles Dang
e270a7c665 Formatting cleanup: > > to '>>`
Allowed since C++11. Might as well use it everywhere.
2018-02-21 12:11:21 +11:00
Matthias Krüger
a2168d2e24 codespell fixes to /src 2018-02-08 21:54:09 +11:00
Gregory A Lundberg
c0689b7924
prefer prefix ++
cppcheck (via Codacy) points out it's better to use prefix ++ on iterators in a for statement.
2018-01-28 09:07:28 -06:00
Charles Dang
f23305f7e2 Formatting cleanup: T const& -> const T& 2018-01-23 01:26:23 +11:00
Jyrki Vesterinen
0db553ef36 Restore bounded_add()
Partial revert of commit ecbb15e1c6.

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
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
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Gregory A Lundberg
f35d2d892d Misleading comment
'toward zero' is confusing since it can round up or down.

The correct comment is 'round half up, to the nearest integer'.

Closes #2330
2017-12-28 14:27:29 -06:00
Charles Dang
056d7ac8f8 Game Events: refactored event handler storage
This throws out the custom smart_list class in favor of a plain std::list. It also greatly simplifies
a few things. First, event handlers no longer remove themselves from the main list in event_handlers.
Now they just flag themselves as disabled (which means they will never execute once marked) and cleaned
up later in a newly added cleanup stage. This means a handler no longer needs to keep its index in the
active handler vector.

This removal of reliance on indices also means I could add the aforementioned cleanup stage. With the
smart_list code, event handlers were never actually removed from the active vector, nor any weak_ptrs
pointing to them removed either. This wasn't exactly a problem, since the handlers were stored via
shared_ptrs which would then simply be null after one deleted itself. Still, it's cleaner to drop any
invalid ones (and unlockable weak_ptrs) from any relevant containers. I've opted to do this in
manager::execute_on_events. Seems a good enough place as any.

The net result of this is the code is much cleaner. We're able to get rid of a bunch of unnecessary
feelers into various classes. This also makes the manager::iteration dereference code a lot easier
to understand. There certainly could be further refactoring, but I think this is a good start.
2017-11-29 08:04:08 +11:00
Charles Dang
693735d90c Fixed a bunch of log output and code comment typos
[ci skip]
2017-11-24 01:14:03 +11:00
Charles Dang
237b7a00bc Silence -Wunused-private-field warnings on Clang (fixes #2164) 2017-11-03 18:08:01 +11:00
Charles Dang
d78ed1c36d Fixup 7ee39bfc1a (include was added to the wrong file) 2017-10-29 13:56:28 +11:00
gfgtdf
e9c6dff56a Slider refactor
1) We now use a single function to set slider min/max value, this fixes #1641
   (sliders having a temporary invalid (min > max) state between set_min() and
   set_max() calls)
2) I split the sliders_base class from the scrollbar_base class to not
   accidently break the rather complicated scrollbar_base class while
   refactoring sliders.
3) We don't use floats in the slider code to make sure no rounding errors happen.
4) This fixes #1539 by removing slider::in_orthoginal (which made it impossible
   to pull a slider to its maximum/minimum) and intead clamping the mouse
   position in range.
5) This fixes #1656 and #1767 by refactoriung code (that bug happend mainly
   because the old code used variables that contained the position in 'steps'
   as pixel position and vice versa)
6) Sliders now 'snap' to the correct values just like the gui1 sliders did.
7) Slider positions are now poperly rounded to its neariest values
   instead of just beeing 'floored'
2017-10-29 01:13:48 +02:00
Charles Dang
20eb42477c Cleaned up shared_ptr assignment
Made use of reset, make_shared, or direct assignment instead of creating new shared_ptrs.
2017-09-12 11:15:47 +11:00
Jyrki Vesterinen
138cefe4f1 Revert "Fix Coverity Warning - Uninitialized"
This reverts commit 61ad1d42c4.

I already fixed that warning in
670bcf71a3 (diff-b42d7aeb9fa3e3fa79ae8bafd6f5783d)

The newer commit didn't semantically change anything, it only made the
code two characters longer.
2017-09-05 23:30:24 +03:00
Gregory A Lundberg
61ad1d42c4 Fix Coverity Warning - Uninitialized
Closes
    CID 1380147

Message was date_result.month was not initialized. Added initialization.
2017-09-06 07:25:50 +11:00
Jyrki Vesterinen
670bcf71a3 Address a bunch of Coverity Scan warnings 2017-09-01 23:24:04 +03:00
Gregory A Lundberg
d0a8f0a858 Fix warning: extra semicolon 2017-08-25 15:30:54 +11:00
Charles Dang
99d854ff21 Irdya Datetime: formatting cleanup
Also removed the erroneous 2003 copyright start, since this is a new file.
2017-08-16 04:42:09 +11:00
Jyrki Vesterinen
78f0ef8d6c Fix build of unit tests 2017-08-15 19:44:07 +03:00
Celtic Minstrel
54d5c6f3a8 Better translatable strings for Irdya years 2017-08-14 13:10:53 -04:00
Celtic Minstrel
25a0d099a9 Enable sorting campaign list in chronological or lexicographical order 2017-08-14 12:36:07 -04:00
Gregory A Lundberg
e5d678b69f Correct documentation comments for pedantic clang
It appears clang 4.0 now checks documenation comments
2017-07-25 12:12:09 -05:00
Jyrki Vesterinen
56433d12a3 Merge branch 'login_save_crypt' 2017-05-22 20:10:09 +03:00
Charles Dang
db582c09ea Removed iterator_extend util class
The WMI container was the last use of it, and there are similar equivalents in boost if we ever need
such a thing in the future.
2017-05-19 06:58:34 +11:00
Jyrki Vesterinen
fb8506dbac Fix build with Visual Studio
First, VS2015 doesn't appear to support importing alias templates directly,
so let's make an alias template ourselves and import every alias we need.

That approach doesn't work with VS2013, apparently due to lack of support
for expression SFINAE. Thus, we now use our custom alias templates on
VS2013.

Also, I moved type_trait_aliases.hpp to the wesnothlib project where it
belongs.

Note that because of requiring expression SFINAE on VS2015, building
Wesnoth on VS2015 now requires that Update 1 or above is installed.
2017-05-16 21:08:26 +03:00
Charles Dang
96ea0eb6b9 Removed trailing tabs and whitespaces from C++ source
[ci skip]

I ran the command used in 9b7b1751fd, excluding results in lua/ and spirit_po/.

Also, once again, for some reason actions/vision.hpp gets registered as massively changed
(similar to f11fa0652a) despite nothing really having changed at all.
2017-05-16 06:46:43 +11:00
Charles Dang
4d17fa12cf Deployed type trait aliases 2017-05-16 02:41:57 +11:00
Charles Dang
70d37c4389 Fixup 01d5907 to satisfy the preprocessor gods 2017-05-16 02:11:31 +11:00
Charles Dang
01d59074eb Fixups to type trait aliases
* Apparently, even VS 2013 includes the general type alias templates. Allow their use there.
* Removed broken C++11 value alias templates (values aren't even allowed this fashion).
* VS 2015 Update 2 apparently both introduced support for variable templates and added them for type traits. Updated accordingly.
* Blocked off the entire variable template section until we bump out min compiler version, since there's no way to implement
  them without variable templates.
2017-05-16 02:02:53 +11:00
Charles Dang
723297efed Added alias templates for const_clone
[ci skip]
2017-05-15 20:59:14 +11:00
Charles Dang
7e3b91ef8c Fixup compilation of type trait aliases
Turns out 'inline constexpr' is a C++17 feature. Fallback to 'static constexpr' with C++14,
except with VS < 2017, where variable templates are not supported.
2017-05-15 20:51:11 +11:00