Commit Graph

18746 Commits

Author SHA1 Message Date
William Davis 881e1da51d
Change: Use gender-neutral pronouns in console command messages (and comments) (#9203) 2021-05-08 11:02:30 +01:00
Patric Stout f187708b3b
Fix f7e390bd: getpeername() doesn't work on closed sockets (#9213) 2021-05-08 11:57:41 +02:00
PeterN 8c3fa2a3bf
Fix #9209: Excessive time resizing highscore/news window when screen is too small. (#9210)
If the highscore/news window panel size, which is now scaled by GUI zoom, is larger than the screen size, a loop will be entered where the window is repeatedly resized.

This is resolved by removing the minimal size from the panel, as the window is always resized to cover the screen anyway. This means the screen size can never be too small.
2021-05-08 09:54:32 +01:00
Peter Nelson dd41de8931 Codechange: Slider widget used different range for drawing vs setting.
Using the same range for setting means that no workaround for setting the extremes is necessary.
2021-05-08 09:54:14 +01:00
Peter Nelson d8e06e590a Codechange: Make GetCurrentRect() conform to usual Rect bounds, and reuse it.
Similar code is already repeated in other locations.
2021-05-08 09:53:55 +01:00
Peter Nelson 52b16237ad Codechange: Don't update window contents if scrollbar position has not moved. 2021-05-08 09:52:54 +01:00
Peter Nelson 8321ef0061 Codechange: Set specific widgets dirty instead of window. 2021-05-08 09:52:54 +01:00
rubidium42 e2774354b4
Codechange: [Network] Change ChatMessage's message to std::string and simplify some code 2021-05-08 10:19:42 +02:00
embeddedt a879996012
Fix: [Emscripten] Use non-XDG directories to simplify lolac storage (#9207) 2021-05-08 09:43:17 +02:00
translators b56c03b120 Update: Translations from eints
dutch: 2 changes by Afoklala
2021-05-07 18:59:46 +00:00
Patric Stout f7e390bdc0
Feature: use Happy Eyeballs to make network connections (TCP-only) (#9199)
Hostnames like "content.openttd.org" resolve into multiple IPv4 and IPv6.
It is possible that either of the IPs is not working, either due to
a poorly configured OS (having IPv6 but no valid route), broken network
paths, or a service that is temporary unavailable.

Instead of trying the IPs one by one, waiting for a 3s timeout between
each, be a bit more like browsers, and stack attempts on top of each
other with slight delays. This is called Happy Eyebells.

Initially, try the first IPv6 address. If within 250ms there is no
connection yet, try the first IPv4 address. 250ms later, try the
second IPv6 address, etc, till all addresses are tried.

If any connection is created, abort all the other (pending) connections
and use the one that is created. If all fail 3s after the last connect(),
trigger a timeout for all.
2021-05-06 23:13:35 +02:00
rubidium42 f1dfa661a1 Codechange: [Network] Use std::string for NetworkGameInfo 2021-05-06 21:45:36 +02:00
rubidium42 cb89d22cf2 Codechange: add DrawString(Multiline) that accepts std::string& 2021-05-06 21:45:36 +02:00
rubidium42 6bca9e090d Codechange: add SetDParamStr that accepts std::string& 2021-05-06 21:45:36 +02:00
translators f313a539a5 Update: Translations from eints
portuguese: 1 change by azulcosta
2021-05-06 18:59:49 +00:00
rubidium42 3d91eee919 Codechange: [Network] Move connection string parsing away from C-strings 2021-05-06 20:33:26 +02:00
rubidium42 6c4a65eeb8 Codechange: [Network] Use std::string for NetworkAddress' host name 2021-05-06 20:33:26 +02:00
rubidium42 dcef3209a6 Codechange: [Network] Use new/delete instead of calloc/free for NetworkGameList 2021-05-06 20:33:26 +02:00
rubidium42 dc05917287 Add: [[nodiscard]] to std::string str_validate 2021-05-06 20:31:02 +02:00
Patric Stout f94fb93779
Codechange: use connection_string in favour of NetworkAddress (#9197)
We now resolve the connection_string to a NetworkAddress in a much
later state. This means there are fewer places constructing a NetworkAddress.

The main benefit of this is in later PRs that introduce different types
of NetworkAddresses. Storing this in things like NetworkGameList is
rather complex, especially as NetworkAddress has to be mutable at all
times.

Additionally, the NetworkAddress is a complex object to store simple
information: how to connect to this server.
2021-05-05 23:21:14 +02:00
Rubidium ead30dc725 Cleanup: [Network] Remove variable from NetworkGameInfo that is only used during deserialisation 2021-05-05 21:01:23 +02:00
rubidium42 e7581fd42d Change: [Network] Update server's NetworkServerGameInfo only when needed
Split the updating in a "static" version that only needs to be called when a new map is loaded or some settings are changed, and a "dynamic" version that updates everything that changes regularly such as the current game date or the number of spectators.
2021-05-05 21:01:23 +02:00
rubidium42 72bd62fd70 Codechange: [Network] Use a single NetworkServerGameInfo object at server side and serialize that for the clients 2021-05-05 21:01:23 +02:00
translators 24e7cb4947 Update: Translations from eints
english (us): 1 change by 2TallTyler
russian: 1 change by Ln-Wolf
finnish: 4 changes by hpiirai
2021-05-05 18:58:22 +00:00
Loïc Guilloux 605bd24674
Cleanup: Leftover static const variable from a3b356e (#9194) 2021-05-05 15:32:41 +01:00
rubidium42 a432009f06 Cleanup: [Fluidsynth] Comply better with the coding style 2021-05-05 16:03:34 +02:00
translators fa206bf2e3 Update: Translations from eints
english (us): 1 change by 2TallTyler
estonian: 49 changes by siimsoni
korean: 1 change by telk5093
hungarian: 45 changes by baliball
finnish: 12 changes by hpiirai
spanish: 1 change by JohnBoyFan
2021-05-04 18:58:09 +00:00
Tyler Trahan 176d65b472
Change: Use gender-neutral pronouns in english.txt (#9189) 2021-05-04 13:28:01 +02:00
glx22 2feb801e56 Codechange: Replace FOR_ALL_ROADTRAMTYPES with range-based for loops 2021-05-03 19:46:57 +02:00
glx22 983c7ade60 Codechange: Replace FOR_ALL_SEARCHPATHS with range-based for loops 2021-05-03 19:46:57 +02:00
glx22 34215f7faa Codechange: Replace FOR_ALL_TARS with range-based for loops 2021-05-03 19:46:57 +02:00
rubidium42 7bcc472f73 Add: [Network] Reading std::string from a packet 2021-05-03 17:56:05 +02:00
rubidium42 ba409e8c45 Add: [Network] Writing std::string to a packet 2021-05-03 17:56:05 +02:00
translators 8228021afe Update: Translations from eints
norwegian (bokmal): 1 change by Anolitt
spanish (mexican): 1 change by absay
korean: 1 change by telk5093
russian: 48 changes by Ln-Wolf
catalan: 1 change by J0anJosep
portuguese: 1 change by azulcosta
portuguese (brazilian): 1 change by Vimerum
2021-05-03 15:50:01 +00:00
rubidium42 6bd7f8816d
Fix #9117, 04ce1f07: [Fluidsynth] Infinite wait when stopping song (#9181)
In FluidSynth 2.2.0 an extra state was added to denote stopping. To transition
from this state to a stopped state the rendering needs to be running. Since
04ce1f07 locking was added that skipped the rendering when something else held
a lock, so the state would never get to stopped and join would never return.
2021-05-03 16:40:19 +01:00
PeterN 08781d96ed
Fix: Query windows may be partially drawn initially. (#9184)
Query window was not marked dirty after being moved on init. It was then marked dirty once the white border flash completed.
2021-05-03 16:39:20 +01:00
PeterN 0bc6f32346
Fix #9174: Don't update text effect if it has been reset. (#9183) 2021-05-03 15:12:47 +01:00
Jonathan G Rennison ece9a356dc
Fix #9113: Assertion failure when removing airport with order backup (#9182) 2021-05-03 15:03:25 +01:00
translators 1a1def99dc Update: Translations from eints
norwegian (bokmal): 24 changes by Anolitt
russian: 8 changes by Ln-Wolf
dutch: 46 changes by Afoklala
spanish: 43 changes by MontyMontana
french: 44 changes by arikover
2021-05-02 18:15:54 +00:00
Milek7 20762f9117
Codechange: Acquire video buffer before taking game state lock to prevent erratic fast forward behaviour (#9140) 2021-05-02 19:10:07 +01:00
Peter Nelson 756034fa27 Codechange: Validate custom station platform layout tiles are permitted values only. 2021-05-02 17:15:27 +01:00
Peter Nelson a3e49178d1 Codechange: Use std::vector for NewGRF station tile sprite layouts. 2021-05-02 17:15:27 +01:00
Peter Nelson bd1a20f6ee Codechange: Use std::vector for NewGRF station platform layouts.
This avoids the need to custom memory management and additional members.

This also resolves use-after-free if modifying copied layouts, so presumably nobody has ever done that.
2021-05-02 17:15:27 +01:00
Michael Lutz 1f159f79de Fix #9147: Delay making screenshots until the next draw tick as we may not access the video buffer from the game thread. 2021-05-02 17:57:24 +02:00
Michael Lutz 91b8ce073f Codechange: Generalise the delayed blitter change to a generic video driver command queue. 2021-05-02 17:57:24 +02:00
frosch 2cf5df2a50 Fix: [NewGRF] industry variable 66 and object variable 46 clamped the squared-euclidian distance to 16 bit, when they should not. 2021-05-02 13:45:43 +01:00
frosch 84aa17cea6 Fix: [NewGRF] industry variables 65 and 66 ignored the parameter, and always used the north tile. 2021-05-02 13:45:43 +01:00
rubidium42 56aa6d0edd Fix: [Network] Reading beyond the length of the server's ID when hashing password
Under normal circumstances the server's ID is 32 characters excluding '\0', however this can be changed at the server. This ID is sent to the server for company name hashing. The client reads it into a statically allocated buffer of 33 bytes, but fills only the bytes it received from the server. However, the hash assumes all 33 bytes are set, thus potentially reading uninitialized data, or a part of the server ID of a previous game in the hashing routine.
It is still reading from memory assigned to the server ID, so nothing bad happens, except that company passwords might not work correctly.
2021-05-02 11:51:28 +02:00
PeterN 18651dd8b1
Fix: Update text effect size when font zoom is changed. (#9174) 2021-05-02 10:43:14 +01:00
PeterN 256dbee255
Fix: Crash when extra viewport height is zero with sign in view. (#9175)
If a viewport sign straddles the top of a viewport, a crash will occur if the viewport height is zero. This is resolved by simply not attempting to draw the viewport in this situation, consistent with other widgets.
2021-05-02 10:21:27 +01:00
Peter Nelson 18fb1c3866 Codechange: Warn if randomaction2 group count is not a power of 2.
Previously noted by a comment, this does not need to be guarded against as non-powers of 2 will not cause issues beyond the choice of results being reduced.
2021-05-02 09:41:01 +01:00
Peter Nelson 6b0b1bb3de Cleanup: Use range iterator to evaluate DeterministicSpriteGroup. 2021-05-02 09:41:01 +01:00
Peter Nelson 913d8a7f28 Cleanup: Use std::vector in RandomSpriteGroup. 2021-05-02 09:41:01 +01:00
Peter Nelson 1aeaf39954 Cleanup: Use std::vector in DeterministicSpriteGroup. 2021-05-02 09:41:01 +01:00
Peter Nelson f785a70a2b Cleanup: Use std::vector in RealSpriteGroup. 2021-05-02 09:41:01 +01:00
rubidium42 e097c83c83 Codechange: move some OS abstraction method implementations out of the header 2021-05-01 19:36:22 +02:00
rubidium42 22720332eb Codechange: encapsulate network error handling 2021-05-01 19:36:22 +02:00
rubidium42 0eb17a70af Codechange: rename NetworkError to ShowNetworkError 2021-05-01 19:36:22 +02:00
Matt Kimber 520595ff87
Fix 3d7ab09: stopped trains not updating viewport hash when reversed for a second time (#9165) 2021-05-01 18:14:50 +01:00
rubidium42 05394d5216 Fix #6598: Prevent invalid memory accesses when abandoning a join from within a network game
One could join a network game from within an already running network game. This would call a NetworkDisconnect, but keeps the UI alive. If, during that process the join is aborted, e.g. by cancelling on a password dialog, you would still be in your network game but also get shown the server list.
Solve all the underlying problems by falling back to the main UI when (re)connecting to a(nother) server.
2021-05-01 18:30:08 +02:00
rubidium42 83985fe26f Codechange: Move join information into a single structure 2021-05-01 18:30:08 +02:00
rubidium42 39c51c35f4 Fix #6598: Do not disconnect before company number validation
NetworkClientConnectGame already does a NetworkDisconnect, so no reason to do it here
2021-05-01 18:30:08 +02:00
rubidium42 3bd416bfdb Change: [Console] Show help when passing invalid company number 2021-05-01 18:30:08 +02:00
rubidium42 0345f99180 Feature: make the town directory horizontally resizable 2021-05-01 13:30:27 +02:00
rubidium42 40528db993 Fix #9152, Fix #9153: screenshot command showed error messages when successful 2021-05-01 11:54:41 +02:00
Peter Nelson 9c6c0a0966 Codechange: Scale sprite font height once on init instead of every call to GetHeight().
Scaling is not expensive, but it does not change either, and this avoids the need for a virtual method call. This cascades back to all GetCharacterHeight(FS_xxx) and FONT_HEIGHT_xxx calls.
2021-05-01 10:41:39 +01:00
Peter Nelson ce55cd0ce7 Cleanup: Use GetDefaultFontHeight() call instead of direct access.
This makes this part of font size setup in FreeTypeFontCache consist with OSX and Windows variants.
2021-05-01 10:41:39 +01:00
Peter Nelson 49aa392440 Fix: Cargo legend blob in cargo payment rate window did not rescale. 2021-04-30 17:08:15 +01:00
Peter Nelson 055067c49c Fix: Scale cargo lines in industry chain window.
Replaces constant pixel values with values scaled based on font size.
This allows the industry chain to maintain a consistent look across
different sizes. Previously all except cargo line height were fixed.
2021-04-30 17:08:15 +01:00
Peter Nelson 254ffe9dcc Fix: Scale industry chain legend blob by font size. 2021-04-30 17:08:15 +01:00
Peter Nelson 957beaaefc Fix: Improved scaling and spacing of sign list window.
Both company icon sprite and text now centred within each row, and extra
padding added to avoid the sprites running into each other.
2021-04-30 17:08:15 +01:00
Peter Nelson 617e85cc65 Fix: Scale legend blobs in Fund new industry window. 2021-04-30 17:08:15 +01:00
Peter Nelson 5434d63f91 Fix: Scale smallmap legend 'blob' to fit text. 2021-04-30 17:08:15 +01:00
Peter Nelson af70195e44 Fix: Tidy up sizing of sprite aligner window sprite list. 2021-04-30 17:08:15 +01:00
Peter Nelson 1df510c297 Fix: Company Key window scaling. 2021-04-30 17:08:15 +01:00
Peter Nelson 09206be054 Fix: Use unscaled values for padding OSK 2021-04-30 17:08:15 +01:00
Peter Nelson 56a6f66903 Codechange: Use text lines instead of pixel height of font for link graph widgets. 2021-04-30 17:08:15 +01:00
Peter Nelson 63cc340dc1 Codechange: Apply minimum size to toolbar widgets 2021-04-30 17:08:15 +01:00
Peter Nelson d32df00b5c Codechange: No longer necessary to manually resize volume sliders. 2021-04-30 17:08:15 +01:00
Peter Nelson 4791ff2862 Fix: Recalculate padding and minimum sizes when GUI or Font zoom is changed. 2021-04-30 17:08:15 +01:00
Peter Nelson 6fe5353da2 Cleanup: Set unchanging scrollbar properties in constructor. 2021-04-30 17:08:15 +01:00
Peter Nelson 03a43b8247 Cleanup: Call SetMinimalSize instead of setting min_y directly. 2021-04-30 17:08:15 +01:00
Peter Nelson f5569763c9 Fix: Specify width when width is required instead of top. 2021-04-30 17:08:15 +01:00
Peter Nelson 2efa390a7d Codechange: Simplify calling of DrawCharCentered() 2021-04-30 17:08:15 +01:00
Peter Nelson 4f93dd95e4 Cleanup: Tidy up resize, fill and minimal size on widgets in town list window. 2021-04-30 17:08:15 +01:00
Peter Nelson 4c6cca459a Cleanup: Remove fairly redundant DrawDropdown() function. 2021-04-30 17:08:15 +01:00
Peter Nelson 5153e1b6e3 Cleanup: Horizontal widget size is commonly width rather than length. 2021-04-30 17:08:15 +01:00
PeterN 3dbd6475fe
Codechange: Use C++ features for train wagon overrides. (#9141)
This removes the need for C-style array management and allows use of iterators to perform wagon override lookups.
2021-04-30 12:03:07 +01:00
Patric Stout 665a3928e2 Remove: performance measurements in YAPF
YAPF was constantly measuring its performance, but only at
certain debug-levels this information was shown.

Now after years, I sincerely wonder if anyone still knows about this
feature and who still use it. Especially with the new framerate window,
this detailed performance is not as meaningful anymore as it once
was.
2021-04-30 12:48:41 +02:00
Patric Stout e162aff7a3 Cleanup: remove weird left-over comment in yapf.hpp 2021-04-30 12:48:41 +02:00
Patric Stout 69118d063f
Change: use TCP for everything except for master-server and initial server scan (#9130)
This means that pressing Refresh button and adding servers manually
now uses TCP.

The master-server and initial scan are still UDP as they will be
replaced by Game Coordinator; no need to change this now.

If we query a server that is too old, show a proper warning to the
user informing him the server is too old.
2021-04-30 11:34:47 +02:00
rubidium42 f00564eeb2
Fix: String validation could leave invalid Utf8 encoded strings (#9096)
In case a character was encoded in multiple bytes, but required fewer bytes to be encoded, the first byte would be copied to the output leaving an invalid Utf8 encoded string. Later uses of the validated string would use the same decode logic, which would yield a question mark and just read a single byte, so nothing dangerous happened.
Furthermore, because the next byte would not be a first byte of an encoded Utf8 character, the last few valid characters could be removed by the validation as well.
2021-04-29 23:16:41 +01:00
PeterN f018471b36
Cleanup: Remove old FiosList helper methods. (#9139) 2021-04-29 22:46:42 +01:00
glx22 9a8756d7ed Codechange: Replace FOR_ALL_CARGOSPECS with range-based for loops 2021-04-29 21:08:24 +02:00
glx22 14e92bd8e2 Codechange: Replace window related FOR_ALL with range-based for loops 2021-04-29 21:08:24 +02:00
rubidium42 a61696d6c5 Change: [Network] Encapsulate logic about the connection string to the network code (#23) 2021-04-29 20:12:11 +02:00
Patric Stout be37a2cab8 Codechange: use NetworkAddress instead of two host/port variables where possible
This also means we no longer need last_host/last_port, but can
just use a single last_joined setting.
2021-04-29 20:12:11 +02:00
Patric Stout 99f998805b Codechange: use std::string over stack-based strings if possible 2021-04-29 20:12:11 +02:00
Patric Stout a8afbe74bf Cleanup: remove write-only variable "hostname" in NetworkGameList 2021-04-29 20:12:11 +02:00
PeterN 0b460bf4a1
Fix: 'Cache' top and bottom lines of textfile viewer to avoid overdraw. (#9131)
* Fix: 'Cache' top and bottom lines of textfile viewer to avoid overdraw.

The text file viewer calculated the number of lines required to set the scrollbar, but did not retain this information, so this was recalculated on every draw operation. This includes overdrawing text outside the bounds of the current scroll position.

With this change the top and bottom lines for each line of text are remembered, and reflowing is avoided where possible. Text outside the current scroll bounds is not drawn.
Additionally the scroll interval is now based on text lines instead of pixel lines, which increases the text capacity depending on the font size.

* Fix: Limit text viewer to showing 64k lines.

Text files with more than 64k wrapped lines would exceed the scrollbar capacity and cause an assert. This is harder to reach now that the scrollbar counts lines instead of pixels.
2021-04-29 18:58:26 +01:00