Commit graph

49 commits

Author SHA1 Message Date
Martin Hrubý
50301f84e3 Fix building with Xcode 10 (#3460)
Resolves #3458.
2018-08-16 15:06:00 +03:00
Martin Hrubý (hrubymar10)
bc4d22dc72 Migrate links to https if available - Fwd c18537edc0 2018-07-16 19:07:08 +11:00
Charles Dang
226a7f7d02 Removed preference to disable halos
There's really no reason to have this anymore. It was (AFAIK) introduced years ago
as a performance-saving measure, then was moved to Advanced Preferences in 1.13 since
modern PCs mostly have no issues. With accelerated rendering, there's even less of a
reason to have this.
2018-06-29 15:07:48 +11:00
Charles Dang
ed8a8a48f7 Used std::string::front() and back() in more places 2018-05-28 15:14:37 +11:00
Charles Dang
b24de54fb9 Removed now-unused preference getters/setters 2018-05-25 11:26:02 +11:00
Charles Dang
0dc5656c32 Convert C-style casts to static_cast 2018-05-13 22:36:50 +11:00
Charles Dang
ccbb736a18 Use std::time_t instead of plain C time_t 2018-05-13 22:13:33 +11:00
Charles Dang
2bf4d68c87 Catch all exceptions (where possible) as const references
A few catch blocks modify something in their exceptions, so those are kept non-const.
2018-05-13 15:48:14 +11:00
Charles Dang
78e8ac51d7 Fixed Boost header deprecation warning on 1.67 and later
Also removed one unnecessary inclusion of the header of the same.
2018-04-29 05:34:56 +11:00
Charles Dang
2ec5c6ee5c Cleaned up more unnecessary includes 2018-04-21 23:19:55 +11:00
Charles Dang
b81a702cfa Removed unused Ping Timeout preference
It no longer had any effect. The selective_ping flag is set was ignored by the
server since it now utilizes TCP keepalive.
2018-04-20 13:07:36 +11:00
Iris Morelle
fc88cdff3b Fix segfault when trying to log into the MP server with an empty password
Probable regression introduced in commit
02ab29d2f1 (1.13.14).
2018-04-17 22:09:23 -03:00
Charles Dang
50407c1e8e Cleaned up some joystick-related code I missed (fixup d384b96) 2018-04-14 14:33:56 +11:00
Celtic Minstrel
8f6613ea09 Fix #2745 2018-04-11 21:05:31 -04:00
Charles Dang
1deacd89f6 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.
2018-04-04 18:54:29 +03:00
Iris Morelle
c5b3947e4a Replace all instances of naked vgettext() calls with VGETTEXT()
The vgettext() function, while declared in src/formula/string_utils.hpp,
actually has its implementation out-of-line in
src/formula/string_utils.cpp where GETTEXT_TEXTDOMAIN is defined to
"wesnoth-lib". Because vgettext() is implemented in terms of the _()
function (an inline wrapper around translation::dsgettext()), it passes
the textdomain defined in the file where it was implemented as a
parameter.

This means that every case of vgettext() being used in other code units
where GETTEXT_TEXTDOMAIN is not defined to "wesnoth-lib", is broken if
the string being looked upon doesn't coincidentally exist in the
wesnoth-lib textdomain.

Ages ago, to work around this limitation, an overload of vgettext() that
takes the textdomain name as a parameter was introduced (see commit
0ba3d05204). Since this form of vgettext()
is rather unwieldy to use (and in particular, the xgettext message
extraction tool mistakes the first argument for the msgid, see below), a
VGETTEXT() macro was also added that uses the GETTEXT_TEXTDOMAIN symbol
defined in the file where the call is made, and thus we get the correct
string from the correct textdomain.

Switching all cases of naked vgettext() in mainline to VGETTEXT() fixes
a myriad of situations where an interpolated string that has an extant
translation does not actually get translated in practice because of the
mismatched textdomain reference (see issue #2709 for an example with MP
game titles). I couldn't find any cases of the companion vngettext()
function (which handles plurals) being used in the wild naked, but for
future reference it also has a companion VNGETTEXT() macro to pass the
correct textdomain to its textdomain-parameter overload.

One caveat is that this commit DOES break the string freeze in one
particular case -- src/units/unit.cpp has a case where the
textdomain-parameter version of naked vgettext() was in use with
"wesnoth" as the first parameter, and xgettext misidentified this as a
translation entry for a "wesnoth" string in the file's assigned
textdomain (which is the default textdomain, wesnoth). So this will
result in the next pot-update both removing the spurious "wesnoth"
string AND adding the correct string to the relevant catalogue template
("<span color=\"$color\">$number_or_percent</span> HP").
to that textdomain.

Other than that, I believe this does not break the string freeze in any
other fashion and it shouldn't result in any regressions for i18n.

It might be worth considering in the future renaming vgettext() and
vngettext() to names that make people less likely to misidentify them as
functions they can freely call directly without regard to the textdomain
assignment issue.
2018-03-23 04:18:01 -03:00
Charles Dang
fc2a58f693 Use std::size_t everywhere instead of plain size_t
Excludes:
* spirit_po/
* xBRZ/
2018-03-19 11:56:04 +11:00
Charles Dang
26e8c148b1 GUI2: split default return value enum into its own file
This avoid having to include gui/widgets/window.hpp every time you just want to
check a dialog's return value.
2018-03-12 12:03:48 +11:00
Charles Dang
a7f6862210 More include cleanups
Cleaned up unnecessary inclusions of:
* event.hpp
* exceptions.hpp
* formatter.hpp
* hash.hpp
* image.hpp
* sound.hpp
* team.hpp
* tstring.hpp
* wml_exception.hpp
2018-03-11 23:22:02 +11:00
Charles Dang
4ba33d464e Cleaned up text rendering-related includes 2018-03-11 21:46:21 +11: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
87289338f4 Preferences: delete any MP passwords saved with the legacy MP method
Even though we switched to encrypted local password storage a while back, any passwords
saved with the old plaintext method remained in player's preferences file and were loaded
by the game where there's no reason they couldn't have been directly accessed.
2018-02-23 16:24:29 +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
Charles Dang
5c9380e58a Default to fullscreen on, tweak default window res
It makes more sense as a game to start with fullscreen enabled. As for the default res,
it's unlikely to be used (only crops up if the saved resolution value is invalid), but
it makes sense to use a more modern widescreen resolution.
2018-02-16 21:11:44 +11:00
Charles Dang
f773996a93 Minor cleanups to some resolution/window size code
* Cleaned up preferences::resolution() implementation.
* Don't call the above twice on SDL window init.
* Made a variable name clearer.
2018-02-16 21:05:47 +11:00
Charles Dang
1855266104 Fixed standing animation toggle not taking immediate effect (fixes #1653) 2018-02-14 10:46:51 +11:00
Matthias Krüger
a2168d2e24 codespell fixes to /src 2018-02-08 21:54:09 +11:00
Charles Dang
6eb7e700ee Editor: handle transition update values with an enum
Instead of this weird fake enum.
2018-02-06 03:21:19 +11:00
Charles Dang
574fd0ec4b Call display method instead of game_display if latter doesn't override
The proliferation of game_display::get_singleton() was due to 786233d5c9
where I replaced resources::screen (itself a game_display* pointer) with the game_display singleton.

Using the game_display pointer has already caused one case of UB (issue #2447), so I figured it best to
call the base class pointer in all cases where a game_display-specific function or override was not used.
2018-02-06 03:06:17 +11:00
Charles Dang
786233d5c9 Replace resources::screen with game_display singleton
This is consistent with the use of display::get_singleton() (in fact, it's the same
pointer). It also makes the code more readable, and means we get to further clean up
the resources set.
2018-01-26 12:36:45 +11:00
Charles Dang
9614a4280a Cleaned up various util includes 2018-01-22 11:21:59 +11:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Jyrki Vesterinen
b710af1716 Fix #2285: GCC-dev compiler warnings 2017-12-09 18:30:49 +02:00
Charles Dang
bc414b7264 Cleaned up a couple dozen unnecessary forward declarations 2017-12-03 09:05:39 +11:00
Charles Dang
eab8380fc4 Avoid copying temp configs when adding config children (where possible)
A few of them are quite small, so this has no performance effect on those, but a few others
are potentially quite large, such as the one in campaign_server.cpp.
2017-12-03 07:37:12 +11:00
Charles Dang
a21697fef3 Cleaned up various areas of code related to setting window resolution
* Added a point ctor that takes an SDL_Point.
* Added a toggle_fullscreen function to CVideo.
* Change all management of resolution data to use point instead of std::pair<int, int>. This
  shortens the code considerably.
* Cleaned up preferences_dialog::set_resolution_list
* Made CVideo::set_resolution return a bool indicating whether resolution was changed.
* Swapped which of the two set_resolution overloads contains the main implementation.
* Moved the events::raise_resize_event() call when setting resolution to the CVideo function
  where it should have always been (instead of the prefs dialog callback). This is a pretty
  essential component and having it localized in one place meant any other area of the code
  that might have called set_resolution wouldn't have it.
2017-11-27 05:53:23 +11:00
Charles Dang
c67f5c352a Cleaned up more unnecessary CVideo function arguments and class members
* Dropped unused CVideo class member references.
* Replaced the lone usecase of the CVideo member in loadgame with the singleton and removed said member.
* Removed CVideo references from a bunch of addon management functions.
* Cleaned up a *lot* of now-unnecessary forward CVideo declarations.
2017-11-21 03:07:23 +11:00
Charles Dang
f2b31ba082 Massive cleanup of GUI2 display/show and execute functions implementations and related CVideo arguments
This a two part commit. First:
----------------------------------------------------------------------------------------------------
Added and deployed two new helper macros for the standard implementations of the static execute
and display functions. I also made use of a variadic template in order greatly simplify code
maintenance. Now, even if the dialog's ctor parameters change, no one has to worry about updating
the associated execute/display functions (though of course, this only applies if the helper macros
are used). \o/

I did not deploy the macro in cases where there were multiple overloads or the functions did more
than just show their dialogs. I might add an additional __VA_ARGS_ parameter to the macros later.
Do note for the end_credits dialog I moved the default empty-string parameter from the display
function to the ctor.

Second:
----------------------------------------------------------------------------------------------------
Another change is that modal_dialog::show and modeless_dialog::show no longer take CVideo arguments.
Since the video argument couldn't be included in the parameter pack (maintaining the argument would
have meant making it the first one, which would be just as much work), and using CVideo::get_singleton
in the macros would require adding video.hpp includes in a whole bunch of files, I simply removed the
argument. I had been intending to do this for a while anyway.

This therefor also removes the CVideo argument from:
* All dialog display/execute functions.
* modal_dialog::show
* modal_dialog::build_window
* modeless_dialog::show
* modeless_dialog::build_window
* wml_exception::show
* gui2::show_message
* gui2::show_error_message
* gui2::show_transient_message
* gui2::show_transient_error_message
* gui2::show_wml_message
* gui2::build
* gui2:🪟:window
* gui2::dialogs::tip::show
* Various GUI2-related Lua functions. The video_dispatch helper was also removed.
* Any functions that took a CVideo argument for the sole purpose of passing it to one of the above.

Ya know, all these damn CVideo arguments didn't actually do anything, besides an occasional check to
CVideo::faked. At the end of the pipeline, they just got assigned to the video_ member of gui2::window.
Huge code bloat for nothing.
2017-11-20 19:24:41 +11:00
Charles Dang
457d42f200 Removed unused sort_list and iconize_list MP preferences
These have no effect in the GUI2 lobby, nor do I intend to make use of them (plus the lobby has
its own sort controls anyway). I'm assuming they were for the GUI1 lobby.
2017-11-10 14:31:55 +11:00
Charles Dang
67a43390f8 Preferences Dialog: fixed friends list row being added even if username was a duplicate
This fixes #2156.

preferences::add_acquaintance replaces the existing friend entry if the given username
has already been added to the acquaintance list, but the prefs dialog always added a
new row unconditionally. I've changed it to only add a new row if the username creates
a new entry, else replace the appropriate exiting row.
2017-11-03 11:18:31 +11:00
Charles Dang
85179772a6 Use config::clear over assignment to default-constructed object 2017-10-06 12:27:39 +11:00
Jyrki Vesterinen
dc5e8b36ea Restore --max-fps
@gfgtdf explained in IRC that it's often used to slow Wesnoth down (instead
of speeding it up, as I had assumed).

This should also allow unit tests to compile again.
2017-07-22 23:35:53 +03:00
Jyrki Vesterinen
4e4d7b5277 Rewrite the FPS cap implementation
The FPS cap, originally implemented in 2007, is very poorly done. It
doesn't take frame time variance into account, and is therefore almost
guaranteed to cause missed frames all the time. It doesn't increase timer
granularity on Windows, which causes SDL_Delay() to often take much longer
than intended. And it's hardcoded for 50 FPS, which fits poorly with 60 Hz
displays.

This new implementation fixes all those issues.

My experience is that the game feels much, much smoother with the new
implementation, perfectly competitive with 1.12. In my opinion, performance
is now at an acceptable level for a stable release.
2017-07-22 15:48:46 +03:00
lundberg
1a13b05118 Prevent warning about data loss by conversion 2017-05-27 16:28:26 -05:00
Celtic Minstrel
ebe360dfa5 Use RAII for all that zero-filling 2017-05-12 15:57:16 -04:00
Celtic Minstrel
894ee43643 Use RC4 cipher for encrypting the password data.
Use vectors whenever handling keys or possibly-encrypted data
2017-05-12 15:57:14 -04:00
Celtic Minstrel
9365538b3b Don't store the user's password in plaintext in the prefs file
The game now supports @ or = in usernames for the purpose of saving them to a file.

Though I don't think these are allowed currently, it's probably better to
support it from the start rather than having things break if they later
become allowed.
2017-05-12 15:56:41 -04:00
Charles Dang
2101353d36 Convert include guards to the shorter #pragma once
Turns out I mistook @celticminstrel's opinion that we should use include guards over pragma (737916e).
Since all major compilers support `#pragma once`, there's no reason not to use it.

For future mergability reasons, this excludes src/spirit_po and src/xBRZ. It also excludes src/boost-patched.
2017-05-09 19:41:37 +11:00
Charles Dang
e4f03fe459 Moved all preferences source files into a single folder 2017-05-04 11:04:19 +11:00