Commit Graph

1713 Commits

Author SHA1 Message Date
Patric Stout d3b2a576de
Feature: Plugin framework for Social Integration with Steam, Discord, GOG, etc (#11628) 2024-01-22 19:22:45 +00:00
Tyler Trahan 735abfe111
Codechange: Split dates and timers into Economy and Calendar time (#10700) 2024-01-22 09:04:34 -05:00
Rubidium 2d77f09a81 Codechange: use std::shared_ptr for vector of TCPConnecters 2024-01-20 23:03:44 +01:00
Rubidium 2d77cf9c80 Codechange: replace StrStartsWith/StrEndsWith with starts_with and ends_with 2024-01-17 19:48:22 +01:00
Rubidium aa5ba5bd7f Codechange: allow certain enumeration to be added
Otherwise C++20 doesn't like it.
2024-01-16 23:30:23 +01:00
Peter Nelson 7737aa6640 Codechange: Make all NWidgetPart arrays constexpr.
This ensures that the arrays are not created at runtime and prevents using non-constexpr values.
2024-01-16 21:57:05 +00:00
Patric Stout 6550682b49
Codechange: minor bits and pieces related to fmt::format() (#11806)
- Don't make run-time formatting what can be done compile-time.
- Be explicit about run-time formatting.
- Fix datetime printing.
2024-01-16 21:10:34 +00:00
Patric Stout 0b7410d979
Codechange: compile-time validate the string format of IConsolePrint (#11804)
This means we can no longer use runtime picking what string to use.
2024-01-16 21:04:35 +00:00
Rubidium 564441e822 Remove: Debug redirect over network
It does not work for dedicated servers because upon starting the process to
resolve the address to redirect to gets killed. Also with all the async going
on in the network code, the debug redirection will start very late in the
process.
2024-01-14 22:14:31 +01:00
Loïc Guilloux 93ba6d6776
Fix: compilation without precompiled headers (#11770) 2024-01-14 13:27:03 +01:00
Rubidium 3a676a5af0 Codechange: replace static inline with static for non-class functions 2024-01-06 13:37:33 +01:00
Peter Nelson 7a5106042f
Codechange: Use CompanyMask and company group statistics for auto clean tests. (#11693)
This function does not need to know how many vehicles there are, only that there is at least one.
2024-01-05 20:58:24 +00:00
Patric Stout 7788b68bbe
Fix: don't unneededly block on transmitting survey on exit (#11687) 2024-01-05 18:54:00 +00:00
Patric Stout 28e2576589
Fix: race-condition when quitting the game with libcurl (#11688)
There could be a callback in _new_http_callbacks that is not
processed yet. All callbacks in _http_callbacks were cancelled,
but not the ones in _new_http_callbacks
2024-01-05 18:48:21 +00:00
Rubidium e3f49ee7a0 Codechange: coding style fixes 2024-01-04 16:23:54 +01:00
Jonathan G Rennison 0075364c89 Fix: curl_global_cleanup called before libcurl HTTP thread exited 2024-01-04 13:41:24 +01:00
Jonathan G Rennison 51ef416b49 Fix: libcurl HTTP thread race at uninit preventing thread exit 2024-01-04 13:41:24 +01:00
Patric Stout aef49e9933
Fix: race-conditions in GUI updates when downloading HTTP files (#11639) 2024-01-02 22:05:25 +01:00
Jonathan G Rennison 502a52edd5
Fix: Spurious cancellations of HTTP content downloads (#11668) 2024-01-01 19:13:29 +00:00
Peter Nelson 7124b4eef1 Codechange: Use std::unique_ptr for all NWidgets. 2023-12-31 15:33:56 +00:00
Peter Nelson 9a3934ae23 Codechange: Use vector/unique_ptr inside widget containers.
This replaces a C-style double-linked-list which required all widgets
to have next/prev pointers, and removes the need for manual pointer management.
2023-12-31 15:33:56 +00:00
Charles Pigott 1e60734660
Fix: Compilation with DEBUG_DUMP_COMMANDS enabled (#11607) 2023-12-30 17:46:32 +00:00
Peter Nelson a0dfb76e34 Codechange: Replace mishmash of types for widget index with WidgetID.
Indices were stored as int, but often passed around as uint/uint8_t and casts.

Now they should all use WidgetID.
2023-12-30 00:23:57 +00:00
Peter Nelson b86182ab84 Codechange: Use std::map to provide indexed widget access.
This removes the need to determine the biggest widget index and replaces C-style memory handling.
2023-12-29 18:45:43 +00:00
Peter Nelson feb94d233d
Codechange: Remove deferred nested_array initialization path. (#11640)
Having two ways (`FillNestedArray` and `SetupSmallestSize`) to initialize
`Window::nested_array` introduces confusion.

Instead, make `FillNestedArray` the canonical way, always call it, and remove
init_array from `SetupSmallestSize`.
2023-12-29 14:27:04 +00:00
Patric Stout 11ba951250
Fix: race-condition when creating new HTTP requests from different threads (#11638) 2023-12-29 12:45:23 +01:00
Peter Nelson 33ff64ef74
Codechange: Simplify ConvertDateToYMD by returning YearMonthDay instead of outputting to a pointer. (#11637) 2023-12-28 21:34:08 +00:00
Rubidium 2072e532f7 Codechange: replace NULL with nullptr 2023-12-26 07:18:52 +01:00
Peter Nelson 6e8c27b8e5
Change: Hide bevel for resizeable sparse layout windows. (#11572)
When clicked, the button is still highlighted to show that it is active.

The bevel is controlled with widget_data by RWV_SHOW_BEVEL or RWV_HIDE_BEVEL values.
2023-12-10 17:25:36 +00:00
Peter Nelson 09251d993c
Change: Use sparse padding for network server list. (#11571) 2023-12-10 14:48:58 +00:00
Peter Nelson d6060a4d47
Change: Use sparse padding for start network server window. (#11569) 2023-12-09 23:35:46 +00:00
Peter Nelson a759d35f26
Fix #11352: Draw all network server info as multiline strings. (#11567)
This also allows the 'header' (which is not actually a widget) to grow
as necessary to fit the server name.
2023-12-09 20:43:36 +00:00
Peter Nelson dcf730f1f6 Codechange: Optionally allow passing state to GUIList sorter function.
GUIList sorter functions can currently only use global state, which makes per-window-instance sorting difficult.
2023-12-04 08:24:39 +00:00
Peter Nelson 9122b4eb47
Codechange: SetMinimalTextLines(1, 0) is implied for widgets with text. (#11536) 2023-12-03 22:42:50 +00:00
Peter Nelson cc528bd8fc Change: Adjust layout of Content and NewGRF Website buttons for consistency. 2023-12-03 18:52:33 +00:00
Peter Nelson 9a92e02fa7
Change: Add tooltips for text file buttons, and shorten Website / Readme buttons. (#11534) 2023-12-03 16:54:57 +00:00
rubidium42 27082f9efa Codechange: pass std::string references to OpenBrowser 2023-11-29 02:02:30 +01:00
Peter Nelson f268c90bd3
Change: Use sparse padding for content download window. (#11501) 2023-11-27 23:17:16 +00:00
Peter Nelson c18a1494b7
Codechange: Remove FONT_HEIGHT_... macros. (#11481)
These make it look like we're dealing with a constant, but actually each is a call to `GetCharacterHeight(...)`.
2023-11-21 19:04:24 +00:00
Peter Nelson ab535c0a86
Codechange: Add base() method to StrongType to allow access to the base type without casting. (#11445)
This removes the ability to explicitly cast to the base type, but the requirement
to use .base() means the conversion is still explicit.
2023-11-06 20:29:35 +00:00
Peter Nelson ef385499c7
Codechange: Remove ineffective NWidgetParts. (#11443) 2023-11-05 14:09:47 +00:00
Michael Lutz 071fdab236 Codechange: Replicate cursor screen backup to chat message display, removing explicit memory management.
Incidentally, this makes Blitter::GetBytesPerPixel unneeed.
2023-11-04 16:08:34 +01:00
Peter Nelson 18fb8e153f Codechange: Add __FILE__/__LINE__ of WindowDesc to WindowDesc.
This is to allow unit-tests to produce more useful output.
2023-11-02 22:25:01 +00:00
Rubidium a849b4e175 Fix: allow same length server password in the UI 2023-11-02 17:19:38 +01:00
Rubidium c6411168d8 Cleanup: missing spaces before continuation * in some comments 2023-11-01 22:56:11 +01:00
Peter Nelson bb50cbb772
Codechange: Assign/StoreSizePosition x/y can be negative. (#11416)
AssignSizePosition is used with negative values when an NWidgetMatrix is
scrolled, but they were passed as unsigned and then stored as signed.

Widget pos_x/pos_y were already made signed.
2023-11-01 18:44:23 +00:00
Peter Nelson 8a49c0eb2c Change: Use modalpopup spacing for network relay and survey windows. 2023-10-26 12:43:20 +01:00
Peter Nelson 59a2abd298 Codechange: Use unified NWidgetContainer methods instead of duplicating.
Most NWidgetContainer derivatives implemented Draw() and GetWidgetFromPos()
the same way. Move this these to NWidgetContainer itself to avoid repeating.
2023-10-21 14:26:36 +01:00
Peter Nelson 81ecbaaa33 Codechange: Hide multiplayer headers by setting width to zero.
Zero-width is how widgets are hidden elsewhere.
This removes the need for an extra array to lookup if a header is hidden.
2023-10-21 14:26:36 +01:00
Rubidium 37f84b7372 Codechange: replace x.size() != 0 with !x.empty() 2023-10-20 23:05:43 +02:00
Rubidium f16399f4c9 Codechange: replace x.size() > 0 with !x.empty() 2023-10-20 23:05:43 +02:00
Rubidium c9276c2959 Codechange: replace x.size() == 0 with x.empty() 2023-10-20 23:05:43 +02:00
Peter Nelson fd6f1e844a
Codechange: Avoid emplace_back(new()) into a unique_ptr. (#11384)
This could theoretically leave an unmanaged pointer in certain circumstances, and directly using
make_unique shows intent.
2023-10-20 18:40:48 +01:00
Peter Nelson e1c83869ed
Fix: Scale minimum width for server name by interface scale. (#11381) 2023-10-19 17:06:47 +00:00
Peter Nelson bdcf6b6acd Fix: Treat closing network relay window as a choice of "No".
Issue ConnectFailure when closing the window if the relay request is
considered unhandled.
2023-10-13 20:47:28 +01:00
Peter Nelson f379b31e28 Add: data parameter in Window::Close method.
This allows passing data when closing a window, e.g. to indicate how it was closed.
2023-10-13 20:47:28 +01:00
Peter Nelson 49dae08a3b Codechange: Add missing override specifiers. 2023-09-25 21:27:45 +01:00
frosch 5733145c59 Cleanup: Remove unneeded parameters. 2023-09-19 22:49:59 +02:00
frosch b5885295f0 Codechange: Use parameters, which should be used. 2023-09-19 22:49:59 +02:00
frosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 2023-09-19 22:49:59 +02:00
Rubidium 7ef22af2bb Codechange: introduce and use function to raise and dirty a set of widgets when they are lowered 2023-09-17 16:03:01 +02:00
Patric Stout 37e2f99c09
Change: store crash logs in JSON format (#11232) 2023-09-14 20:13:27 +02:00
Patric Stout ba67f39db6
Codechange: vendor the nlohmann-json library (#11290) 2023-09-13 16:11:34 +02:00
Tyler Trahan 701a61c9af Codechange: Delete date_type.h 2023-09-10 08:40:25 -04:00
Tyler Trahan 77173a6a10 Codechange: Move date consts and functions to CalendarTime and TimerGameCalendar classes 2023-09-10 08:40:25 -04:00
Tyler Trahan fca2b37726 Codechange: Move Ticks into their own class 2023-09-10 08:40:25 -04:00
PeterN afc1ea8135
Codechange: Using alias and std::array for company expense storage. (#11273)
This simplifies passing yearly expenses to functions and use of std algorithms.
2023-09-09 13:15:53 +00:00
Patric Stout 5f9b8aaa95
Codechange: [Script] use nlohmann for Squirrel <-> JSON conversion (#11251) 2023-09-06 13:14:12 +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
Bouke Haarsma 7e54418022
Codechange: workaround CMake/Xcode duplicate file name issue (#11186)
Having a library with files with the same name isn't supported in CMake's Xcode project file generation: https://gitlab.kitware.com/cmake/cmake/-/issues/20501. One of the files is renamed to work around this bug.
2023-09-02 19:46:52 +02:00
Patric Stout ecb4bb5161
Change: for surveys capture more information about the OpenTTD version (#11244) 2023-08-30 12:14:32 +02:00
Patric Stout a3d631ffed
Change: make nlohmann a mandatory library to build OpenTTD (#11235) 2023-08-28 19:04:36 +02:00
Patric Stout abc060525d
Add: calendar date for Survey results
This means no heuristics is possible on around which date people
play the game.
2023-08-28 13:02:52 +02:00
Patric Stout 299570b2c1
Codechange: make TimerGameCalendar Date and Year types strongly typed (#10761) 2023-08-12 18:14:21 +00:00
Patric Stout 01f55eb734
Codechange: introduce week/quarter triggers for TimerGameCalendar (#11189)
This simplifies code that triggers on these periods.
2023-08-12 16:02:11 +02:00
Tyler Trahan 93069066f9
Codechange: Use auto type when sorting dates (#11175) 2023-08-11 08:18:32 -04: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 af9b9327af Codechange: do not keep local variable for temporary string parameters 2023-07-03 18:08:03 +02:00
Rubidium 0ea3e338ab Codechange: replace buffer+strecpy with std::string 2023-06-29 17:32:27 +02:00
Rubidium f333372dd1 Codechange: let IConsoleCmdExec accept std::string 2023-06-29 06:06:15 +02:00
Jonathan G Rennison 55c07eed59
Change: Add separate setting for server sent commands per frame limit (#11023)
Set a higher default value for this setting.
Use the higher of this and existing commands per frame limit
setting for server-originating commands, e.g. GS.

This is to support the GSAsyncMode class.
This also avoids undue throttling when more than one
script is in operation (e.g. AIs).
2023-06-27 12:32:45 +01:00
Rubidium 700241410b Remove: support for not having getifaddrs 2023-06-27 12:35:07 +02:00
Jonathan G Rennison 4f6d75f97d Fix #11016: Defer deletion of client and server game socket handlers
This fixes various use after free scenarios in error handling paths
2023-06-25 12:02:32 +01:00
Jonathan G Rennison 19ae88fb63 Fix: Error logging in game and admin server HandlePacket
Don't invent a packet type in the log message if we can't/don't
read a packet type at all.
Fix packet type not being logged when appropriate.
2023-06-25 12:02:32 +01:00
Rubidium 836541b41c Codechange: use SetDParam and CopyOutDParam for tooltips 2023-06-17 10:01:19 +02:00
Owen Rudge 1a3d1bca59 Remove: OS/2 port 2023-06-16 14:29:14 +01:00
Rubidium d4c2043294 Codechange: remove a number of unneeded c_str() calls 2023-06-15 22:14:45 +02:00
Rubidium 13cdf5fffa Codechange: use std::filesystem::path for the language file's path 2023-06-08 23:20:28 +02:00
Rubidium a47de4b2ab Cleanup: remove DRAW_STRING_BUFFER constant 2023-06-06 18:08:11 +02:00
Rubidium 1fa432ca92 Codechange: replace C-style string building with C++-style building 2023-06-06 18:08:11 +02:00
Rubidium 55dfca1936 Codechange: replace seprintf with C++ style formatting 2023-06-05 23:25:59 +02:00
Rubidium c158089eff Codechange: use C++ style methods to combine a Utf8Encoded character and a formatted string 2023-06-04 23:32:02 +02:00
Patric Stout 21adfa7567
Fix: track "memory installed" for surveys less precisely (#10910)
It turns out, for Windows and Linux having the exact memory allows
for easy tracing of an individual. That is exactly against the idea
of the survey. And honestly, we don't need this precision.
2023-06-03 19:07:56 +00:00
Rubidium d9f8a4c380 Codechange: use std::string GetString variant 2023-05-31 19:31:09 +02:00
Rubidium f4b0ac2bd4 Codechange: use std::string for formatting settings 2023-05-24 22:42:01 +02:00
axet 60540f7df6 Change: Allow dedicated server to use threaded saves. (#10787)
Co-authored-by: Jonathan G Rennison <j.g.rennison@gmail.com>
2023-05-21 19:55:12 +02:00
Rubidium c518293135 Codechange: replace printf with fmt::print 2023-05-21 15:12:02 +02:00
Rubidium 3323402aaa Codechange: rename smallvec_type to container_func and use only when needed 2023-05-20 16:53:10 +02:00
Rubidium acec34a0fe Cleanup: remove MD5SumToString in lieu of FormatArrayAsHex 2023-05-19 11:24:44 +02:00
Rubidium d9a04ba446 Codechange: make the MD5 hash/digest/checksum variables a std::array 2023-05-19 11:24:44 +02:00