Commit Graph

212 Commits

Author SHA1 Message Date
frosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 2023-09-19 22:49:59 +02:00
Peter Nelson e8015e497d Codechange: Use begin/end of nwidget parts of begin/length.
This simplifies processing nwidget parts as, unlike the remaining length, the pointer to the end of the list never changes. This is the same principle as we use(d) for tracking end instead of length for C-style strings.

And this removes 160~ instances of the lengthof() macro.
2023-09-04 10:20:45 +01:00
Rubidium eaae0bb5e7 Codechange: automatic adding of _t to (u)int types, and WChar to char32_t
for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
2023-07-19 19:30:14 +02:00
Rubidium 1fa432ca92 Codechange: replace C-style string building with C++-style building 2023-06-06 18:08:11 +02:00
Rubidium d9f8a4c380 Codechange: use std::string GetString variant 2023-05-31 19:31:09 +02:00
Rubidium acec34a0fe Cleanup: remove MD5SumToString in lieu of FormatArrayAsHex 2023-05-19 11:24:44 +02:00
Patric Stout 7634553d22 Feature: opt-in survey when exiting a game
On first start-up, the game will ask if you want to participate
in our automated survey. You have to opt-in, and can easily opt-out
(via the Options) at any time.

When opt-in, whenever you exit a game, a JSON blob will be send
to the survey server hosted by OpenTTD. This JSON blob contains
information that gives a global picture of the game just played:
- What settings were used
- How many humans vs AIs
- How long the game has been played
- Basic information about the OS / CPU

All this information is kept very generic, so there is no
chance we send private information to our survey server.
Nothing in the JSON blob could identify you as a person; it
mostly tells about the game played. At any time you can see
what the JSON blob includes, by pressing the "Preview Survey
Results" button in-game.
2023-05-14 23:22:02 +02:00
Peter Nelson 941dbadf9e Codechange: Add and use GetScrolledItemFromWidget to get a list item.
This function returns an iterator, either to the selected item or the
container's end.

This makes handling the result more robust as indices are not used.
2023-05-12 21:45:32 +01:00
Peter Nelson d2034d9c38 Codechange: Scrollbar methods now accept size_t.
This clears up a lot of casts from size_t to int.
2023-05-07 20:25:44 +01:00
Rubidium 877349c13d Codechange: use std::string for text file name resolution 2023-05-05 08:54:29 +02:00
Rubidium a312a6c1b2 Codechange: make md5sumToString std::string compatible 2023-05-04 23:23:32 +02:00
Tyler Trahan ba3de0383a
Codechange: Pass more std::string to StringFilter::AddLine() (#10743) 2023-04-30 10:23:05 +02:00
Rubidium c829930440 Codechange: replace strnatcmp with C++ string capable version 2023-04-29 12:07:45 +02:00
Rubidium b221fa3c5a Codechange: use fmt::format_to instead of seprintf to create the search URL 2023-04-28 19:53:03 +02:00
Patric Stout dea2dea881 Fix: reset content download progress to zero if falling back to TCP
Otherwise this chain of events can happen:
- You already have a (partial) file downloaded
- You start the download, and HTTP fails
- This resets the download progress to the current size of the file
- The TCP download starts at a very large value (UINT32_MAX - filesize)

It now resets to 0% done when any negative value is being given.
As added bonus, we no longer have to query how much was already
downloaded.
2023-02-15 23:48:06 +01:00
Rubidium 4e65ec1dc4 Codechange: do not declare functions in blocks 2023-01-29 20:28:45 +01:00
Peter Nelson ecb5393c55 Change: Standardize progress bar layout.
Progress bars are drawn differently depending on when it was added, with
different layouts and sizes.

This change adds a standard padding size to use, and makes all progress
bars visually similar, with scaled padding.
2022-11-12 18:28:39 +00:00
Peter Nelson 890b2666d3 Change: Use scaled WidgetDimensions. 2022-11-12 18:28:39 +00:00
Peter Nelson b6ed595176 Codechange: Prefer suggested widget padding. 2022-11-12 18:28:39 +00:00
Peter Nelson 6f95e04005 Change: Use Rect helpers for widget drawing.
This replaces repetitive and sometimes unwieldy use of constants.
2022-11-12 18:28:39 +00:00
Peter Nelson dc1b84aa1e Cleanup: Text widgets are capable of drawing text without assistance.
Remove custom text drawing of some widgets in favour of standard text
widgets.
2022-10-16 14:24:51 +02:00
rubidium42 05005dcdfa Codechange: [Network] Use std::string instead of char[] for the name of the file that is downloading 2021-06-15 06:13:00 +02:00
rubidium42 e3717ae903 Codechange: [ContentInfo] Use std::string instead of string buffers 2021-06-10 20:09:44 +02:00
rubidium42 df181bb641 Codechange: [ContentInfo] Use a vector for dependencies instead of custom allocation 2021-06-10 20:09:44 +02:00
rubidium42 9c424ab741 Codechange: [ContentInfo] Use StringList for tags instead of custom allocations 2021-06-10 20:09:44 +02:00
glx22 5799402f7a Codechange: Rename window related DeleteXXX to match new behaviour 2021-05-29 21:08:25 +02:00
glx22 994bf19aef Fix f6d5c01: Delay deletion when closing windows 2021-05-29 21:08:25 +02:00
Patric Stout a403653805
Codechange: [Network] split CloseSocket and CloseConnection more clearly (#9261)
* Codechange: [Network] split CloseSocket and CloseConnection more clearly

- CloseSocket now closes the actual OS socket.
- CloseConnection frees up the resources to just before CloseSocket.
- dtors call CloseSocket / CloseConnection where needed.
2021-05-13 11:46:51 +02:00
Rubidium bf4fe19a66 Codechange: merge duplicated logic to scroll in lists by key into a single function 2021-04-21 21:12:08 +02:00
Patric Stout 970fedd78c Add: make modal windows update more smooth
Basically, modal windows had their own thread-locking for what
drawing was possible. This is a bit nonsense now we have a
game-thread. And it makes much more sense to do things like
NewGRFScan and GenerateWorld in the game-thread, and not in a
thread next to the game-thread.

This commit changes that: it removes the threads for NewGRFScan
and GenerateWorld, and just runs the code in the game-thread.
On regular intervals it allows the draw-thread to do a tick,
which gives a much smoother look and feel.

It does slow down NewGRFScan and GenerateWorld ever so slightly
as it spends more time on drawing. But the slowdown is not
measureable on my machines (with 700+ NewGRFs / 4kx4k map and
a Debug build).

Running without a game-thread means NewGRFScan and GenerateWorld
are now blocking.
2021-03-10 13:41:18 +01:00
Patric Stout ac2b5e57cf
Fix: mention our websites with https:// (instead of http://) (#8657)
It is 2021. Nobody should advertise http anymore. Not even us.
2021-02-08 19:07:34 +01:00
Charles Pigott 9b800a96ed
Codechange: Remove min/max functions in favour of STL variants (#8502) 2021-01-08 11:16:18 +01:00
Yexo a9b3312d1a Fix #8024: make online content gui more responsive while loading
Previously the internal content list was invalidated and sorted for
every new item added. Now the sorting is delayed until the GUI is
drawn, which means we only sort once per GUI tick.

Since the amount of incoming items per GUI tick is not controlled by
the GUI but rather by network speed, we were previously doing a lot
of duplicate work per tick, causing the mouse cursor to lag while
the list was initialized.
2020-06-01 10:59:11 +02:00
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 2019-11-10 17:59:20 +00:00
JMcKiern 04f659e768 Fix: Some typos found using codespell 2019-09-29 21:27:32 +01:00
glx 2db88953e7 Codechange: use std::sort() in GUIList 2019-04-13 12:49:18 +01:00
Henry Wilson 7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 2019-04-10 23:22:20 +02:00
PeterN 9244dad3f1
Fix #7434: Incorrect use of vector iterator. (#7437) 2019-03-29 17:42:32 +00:00
glx22 66dd7c3879
Fix: MSVC warnings (#7423) 2019-03-28 00:09:33 +01:00
Henry Wilson c01a2e2a81 Codechange: Removed SmallVector completely 2019-03-26 20:15:57 +00:00
Henry Wilson ab711e6942 Codechange: Replaced SmallVector::[Begin|End]() with std alternatives 2019-03-26 20:15:57 +00:00
Henry Wilson 297fd3dda3 Codechange: Replaced SmallVector::Include() with include() 2019-03-26 20:15:57 +00:00
Henry Wilson 2bc2de9034 Codechange: Replaced SmallVector::Find() with std::find() 2019-03-26 20:15:57 +00:00
Henry Wilson a0f36a50e6 Codechange: Replaced SmallVector::Append() with std::vector::[push|emplace]_back() 2019-03-26 20:15:57 +00:00
Henry Wilson 097328c3d7 Codechange: Replaced SmallVector::Get() const with std alternatives 2019-03-26 20:15:57 +00:00
Henry Wilson a690936ed7 Codechange: Replace SmallVector::Length() with std::vector::size() 2019-03-26 20:15:57 +00:00
Henry Wilson 9cba6f7193 Codechange: Replaced SmallVector::Compact() with std::vector::shrink_to_fit() 2019-03-26 20:15:57 +00:00
Henry Wilson bfd79e59dc Codechange: Replace SmallVector::Clear() with std::vector::clear() 2019-03-26 20:15:57 +00:00
peter1138 07de9d6c3f Codechange: Use override keyword in networking classes. 2019-03-24 17:38:42 +00:00
peter1138 317f69c152 Codechange: Use override specifier in Window-derived classes. 2019-03-24 16:10:04 +01:00