Commit graph

5191 commits

Author SHA1 Message Date
Robert Müller fec7e89b00
Merge pull request #7356 from dobrykafe/pr-editor-stop-sound-preview
Editor: stop/pause sound previews
2023-10-23 16:52:32 +00:00
furo bf98eec518 Add option to disable regional rankings.
Set config to true in tests

Add test for `´sv_regional_rankings`
2023-10-23 14:02:22 +02:00
dobrykafe c304b3eef8 extract CEditor::OnDialogClose 2023-10-23 12:48:53 +02:00
Robert Müller bea7aea431 Encapsulate CHostLookup member variables
The host lookup job is currently only used for the DNSBL lookup on the server-side and in tests.
2023-10-22 13:38:56 +02:00
Robert Müller f8af7542c6 Move CHostLookup to separate compilation unit
The host lookup job and the engine interface are independent so they are moved to separate files.

The include of `engine.h` in `client.h` is therefore unnecessary and other includes also had to be adjusted because of this.

The variable `m_VersionServeraddr` is unused and therefore removed. The host lookup job is currently not used on the client-side.
2023-10-22 13:38:35 +02:00
Robert Müller 0e4f174f78 Check for all file errors in demo player, show demo error popup
Handle the return values of all uses of the `io_read`, `io_skip` and `io_tell` functions in `CDemoPlayer`, to handle truncated demo files and other unexpected file reading and seeking errors during demo playback.

Show more detailed error message popups when demos cannot be loaded due to errors and when demo playback is stopped unexpectedly due to errors. Previously, only a generic message "Error loading demo" was shown when loading failed and no error message was shown when demo playback is stopped due to errors.
2023-10-19 21:48:04 +02:00
Robert Müller 92e2e17f0f Validate ticks when reading demo chunk headers
Add checks to ensure that the ticks read from demo chunk headers are in the valid range (cf. `MIN_TICK` and `MAX_TICK` constants). Playing demos with invalid ticks is prevented entirely, as the invalid ticks would cause issues in other places. The server never uses ticks outside the valid range, so invalid ticks should never occur in correctly recorded demos.

Additionally, checks are added to detect if a tickmarker chunk with a tick delta occurs before a tickmarker chunk defining an initial tick. The tick delta is only meaningful when an initial tick has already been defined, so if this is not the case the demo is also considered invalid.
2023-10-19 21:41:20 +02:00
Robert Müller 6951795619 Add title to engine warnings and make auto-hiding optional
Make the title of warnings adjustable, with the default title being "Warning" to preserve existing code.

Make auto-hiding configurable, so the automatic closing of warning popups after 10 seconds can be toggled.
2023-10-19 21:40:55 +02:00
dobrykafe aafee689ca stop/pause sound previews 2023-10-18 13:27:31 +02:00
Robert Müller 8fea5998aa Mark functions as const when possible 2023-10-17 20:27:58 +02:00
Robert Müller 59b5fd2793 Fix graphs initially rendering incorrect values
Ensure only valid graph entries are used to render curve line segments.
2023-10-17 20:27:31 +02:00
Robert Müller 11423b88b1 Use full graph width for rendering curve
Previously, roughly one percent of the graph width was not used for the curve values.
2023-10-17 20:25:35 +02:00
Robert Müller 1a01d7657f Remove unused m_Graph member of CSmoothTime 2023-10-17 20:25:32 +02:00
Robert Müller e187bda620 Use bool instead of int 2023-10-17 20:24:45 +02:00
Robert Müller d92b7b5c5f Add enum for CSmoothTime adjust direction 2023-10-17 20:24:38 +02:00
Robert Müller fb96217147 Fix first value in graphs being incorrect
As the index was incremented before setting the value, the value at index 0 was not set correctly until the ringbuffer wraps around.
2023-10-17 20:23:35 +02:00
Robert Müller dc7fa1fbb2 Use ColorRGBA for CGraph entry color 2023-10-17 20:23:16 +02:00
Robert Müller 912355f9ec Move CSmoothTime class to separate compilation unit 2023-10-17 20:23:07 +02:00
Robert Müller ee51cac9e6 Move CGraph class to separate compilation unit 2023-10-17 20:22:48 +02:00
Robert Müller f1e74c12e9 Remove unused IDemoPlayer::GetDemoType and enum literals
We only show the string value directly in the UI instead of using the demotype enum literals. There also should not be any reason to change any logic depending on whether the current demo is a server- or client-demo.
2023-10-16 22:06:28 +02:00
Robert Müller af4b1c9c97 Remove tick error debug message
This is shown every time demo playback ends when reaching the end of the file and it does not really help debugging.
2023-10-16 22:06:19 +02:00
Robert Müller ed92a9e8c7 Remove redundant checks for missing SHA256 when recording demo
The SHA256 was effectively not optional anymore when recording demos, as it and the SHA256 extension UUID were always written to the demo file without checking for `nullptr`. Therefore the SHA256 is now passed by const reference instead of by pointer and redundant checks for `nullptr` are removed.
2023-10-16 21:53:37 +02:00
Robert Müller f7b8738f91 Remove obsolete TODO about improving demo player map checking
We already use `CClient::LoadMapSearch` to load maps for demo playback, so maps in the `maps` folder are already considered. Using the map CRC is deprecated, we do not want to check it.
2023-10-16 21:53:37 +02:00
Robert Müller dbbae72ca7 Move variable declarations closer to usages 2023-10-16 21:53:37 +02:00
Robert Müller 9b68b9deef Use bool instead of int 2023-10-16 21:53:36 +02:00
Robert Müller 1333ac34f4 Use nullptr instead of 0 and NULL 2023-10-16 21:53:36 +02:00
Robert Müller 568177114f Remove unnecessary parentheses 2023-10-16 21:53:36 +02:00
Robert Müller 82d94faf28 Refactor GetDemoName using IStorage::StripPathAndExtension
The functions were effectively identical already.
2023-10-16 21:53:32 +02:00
Robert Müller c3b8c94212 Use std::vector for demo player keyframes
Using an `std::vector` is simpler and more readable than first allocating a linked list on a heap and later copying the list to an array.

The variable `m_SeekablePoints` is removed from `CPlaybackInfo`, as it does not need to be exposed outside of `CDemoPlayer` and can be replaced with the size of the vector.
2023-10-16 21:53:29 +02:00
Robert Müller cd4a13e74c Remove unnecessary check for open file in ReadChunkHeader
The function is only used internally and never called when the file is not open.
2023-10-16 20:50:43 +02:00
Dennis Felsing 042a04d610
Merge pull request #7353 from Robyt3/Engine-Jobpool-Refactoring
Minor refactoring of engine jobpool
2023-10-15 22:29:33 +00:00
Robert Müller 22352316d8 Give jobpool worker threads different names based on index 2023-10-15 22:10:50 +02:00
Robert Müller ba5a974353 Increase jobpool thread count based on hardware concurrency
The client/server jobpools were previously only using a fixed number of 2 threads. Now the pools use `2 * hardware-concurrency + 2` threads, which should provide better performance overall, as we expect threads to often wait on I/O.
2023-10-15 22:10:49 +02:00
Robert Müller 2dcec6496f Use std::vector for jobpool threads
To simplify the usage and to support an arbitrary number of threads.
2023-10-15 22:00:25 +02:00
Robert Müller 9cbbc0aca6 Replace static variables in MouseRelative with member variable
Avoid using a global variable for last mouse position on Android.
2023-10-15 20:36:59 +02:00
Robert Müller d00283e885 Enable use of video recording for each demo player individually
Previously all demo players checked `IVideo::Current` to render a video, which would cause issues when rendering a demo while a demo slicing background job is running. Now video rendering can be toggled for each demo player individually and is only enabled for the main demo player.
2023-10-14 10:52:24 +02:00
Robert Müller 668e6fb14e Use member variables for demo player snapshot data
Use member instead of static variables for demo player snapshot data. The static variables would otherwise cause issues when multiple demo players are playing at the same time, especially demo players used in background jobs for replay demo slicing. This hopefully closes #7068.
2023-10-14 10:51:45 +02:00
Robert Müller 3af7de307a Preserve demo type when slicing
Previously all sliced demos used type "client", even if the original demo had type "server". Now the type of the original demo is copied when slicing.
2023-10-13 22:11:49 +02:00
Robert Müller 9030c5b155 Refactor CDemoEditor, fix clang-tidy NOLINT
Use composition instead of inheritance for demo player listener to avoid temporarily storing a pointer to a local variable in a member variable.

Fix demo player file not being closed when demo recorder file cannot be opened during demo slicing.
2023-10-13 20:46:08 +02:00
Robert Müller a0b708a0b2 Assert that demo recording/playback are properly started/stopped
Add assertions to check that demo recording/playback is not started when already running.

Add assertions to check that demo recording/playback is stopped before the respective demo recorder/player is destroyed.
2023-10-13 20:45:22 +02:00
Robert Müller 543e63ee71 Use IO_MAX_PATH_LENGTH for demo recorder/player filenames 2023-10-13 20:45:07 +02:00
Robert Müller 7a624d7911 Ensure demo player listener is initialized
Using `SetListener` is optional.
2023-10-13 20:02:13 +02:00
Robert Müller a19c51f545 Remove unused CHUNKFLAG_BIGSIZE 2023-10-13 20:02:13 +02:00
heinrich5991 5fbf02ae91
Merge pull request #7333 from Robyt3/Clang-Tidy-Remove-Nolint
Remove obsolete clang-tidy `NOLINT` comments
2023-10-11 15:49:46 +00:00
Robert Müller aa03aa0f60 Remove obsolete clang-tidy NOLINT comments
The TODO in the `Dilate` function is removed, as the code already appears to be safe without additional checks. The variable `k` is at most `(w * h - 1) * BPP`, as `ix` and `iy` are clamped to maximum `w - 1` and `h - 1` respectively. Because `p < BPP - 1` the index `k + p` is therefore always valid for the buffers. (The caller must ensure that the source and destination buffers are of size `w * h * BPP`.)
2023-10-11 17:22:59 +02:00
Dennis Felsing 60fa51ff13
Merge pull request #7309 from infclass/kaffeine/merge-client-data-structs
Extract client 'six' data types and use them for 'seven' data
2023-10-10 21:55:55 +00:00
Dennis Felsing 1fb0235f4b
Merge pull request #7327 from furo321/correct-max-length
Show correct max length in help text for `MACRO_CONFIG_STR`
2023-10-09 06:52:43 +00:00
furo f39792f330 Show correct max length in help text for MACRO_CONFIG_STR 2023-10-09 00:53:28 +02:00
Dennis Felsing 1f5a764cf5 Make sure notification object exists 2023-10-08 14:01:02 +02:00
Robert Müller d4fed2360e
Merge pull request #7208 from dobrykafe/pr-editor-toolbar-sounds
Enhance editor toolbar sounds
2023-10-08 09:06:15 +00:00
furo e1979d9c9b Use icons for editor mode switching.
Make the icons bigger.

Make it the same size as "group"
2023-10-08 01:17:20 +02:00
dobrykafe 8adbbc433c fix requested changes 2023-10-07 14:49:51 +02:00
Robert Müller 076a902684 Overhaul demo browser UI
Improve layout of demo browser buttons, search and checkbox. Use icons for most buttons. Decrease size of UI elements.

Move demo details from below the file browser to a side panel on the right, which is the same size as the server browser side panel. Use ellipsis to truncate the SHA256 instead of rendering only half of it with reduced font size. Show "map not included" instead of "0.00 KiB" for the map size of demos that don't include a map.

Remove the "Markers" column, as it is not very useful to see for all demos and sort by.

Closes #7275.
2023-10-06 21:46:13 +02:00
Alexander Akulich b6470e5a43 Use client 'six' data structs for client 'seven' data 2023-10-06 18:14:38 +03:00
dobrykafe 6e2ddfbeaf use nullptr instead of 0, add missing return statement 2023-10-06 17:09:20 +02:00
dobrykafe ca517f27b8 enhance editor toolbar sounds 2023-10-06 17:09:19 +02:00
Robert Müller fb7669ebb0 Fix clang-tidy modernize-use-override 2023-10-06 14:06:52 +02:00
Robert Müller b81fb37f82 Fix clang-tidy modernize-use-emplace 2023-10-06 14:06:20 +02:00
Edgar f5f57ee24c
Merge pull request #7283 from Robyt3/ImageLoader-Indexed-Fix
Fix images using indexed color palette not being loadable
2023-10-04 13:55:21 +00:00
Dennis Felsing 2e5ee8287e
Merge pull request #7008 from Robyt3/Datafile-String-Util
Add functions for reading/writing strings from/to datafile, minor refactoring of datafile/map reader
2023-10-03 20:54:40 +00:00
Robert Müller 6f1e08b6f4 Encapsulate/move IClient member variables 2023-10-03 17:56:17 +02:00
Robert Müller 7acf2c1573 Add functions for reading/writing strings from/to datafile
Simplify the usage of datafile reader and writer by adding utility functions to read and write zero-terminated UTF-8 strings.

Improve validation of string data read from datafiles. It is ensure that string data is null-terminated, has no internal NUL-characters and is valid UTF-8.

Fix loading of external sounds in the editor. The wrong path variable was being used, so the sound files would not be loaded from correct folder.

Add tests for new datafile reader/writer functions.
2023-10-03 16:07:15 +02:00
Robert Müller 106b04ee79 Add assertion for Index argument of ReplaceData function 2023-10-03 15:58:58 +02:00
Robert Müller 4716791c6d Add missing IMap::FindItemIndex delegate function 2023-10-03 15:58:58 +02:00
Robert Müller 6a5752d71e Use bool instead of int for Swap parameter 2023-10-03 15:58:58 +02:00
Robert Müller e68caafc07 Consistently order CDataFileReader and IMap functions 2023-10-03 15:58:58 +02:00
Dennis Felsing dbd9da3c7b
Merge pull request #7289 from Robyt3/Map-Version-Check
Ensure current map is not corrupted when loading another fails
2023-10-03 13:17:03 +00:00
Robert Müller 9096b089b9 Ensure current map is not corrupted when loading another fails
When `IMap::Load` fails, other components will continue to use the old map. However, if `IMap::Load` failed after the map was already successfully read with the datafile reader then other components kept their pointers to the old, invalid datafile reader items and data, causing random crashes in collision code. This is fixed by using a separate datafile reader to read the new map and only applying the datafile reader globally when loading was entirely successfully.

An error message is added for the case that a map has an unsupported version, which is currently the only case where a map can fail to load after the datafile was read successfully.

In particular, the block maps `blmapPepe`, `blmapV5` and `blmapDT-UPTU` did not have a version map item and were fixed separately.

Closes #7218. Regression from #5737.
2023-10-03 14:27:11 +02:00
Robert Müller b7e1e61988 Remove redundant argument of Dilate function
The pixel size (bytes per pixel) always has to be 4 for the `Dilate` function to work correctly. This is already checked before calling the function, so the redundant argument which is always `4` can be removed.
2023-10-03 13:52:37 +02:00
Robert Müller dab88177dd Fix images using indexed color palette not being loadable
The wrong color channel count was being used for loading images that use an indexed color palette, which was causing the loading to fail with the error "bytes in row incorrect". Now the correct color channel count is retrieved using the libpng API.

Closes #7157.
2023-10-02 12:21:20 +02:00
Robert Müller b1d90aaaf2 Store number of filtered players when filtering
Only update total number of filtered players when the filter is updated instead of calculating it every frame.
2023-10-01 20:53:29 +02:00
Dennis Felsing e0d906d9e1
Merge pull request #7272 from furo321/afk-optional2
Don't run `GET_INT` on afk attribute in `ProcessServerInfo`
2023-09-30 20:43:37 +00:00
furo a3064ae105 Don't run GET_INT on afk attribute in ProcessServerInfo 2023-09-30 20:51:20 +02:00
Dennis Felsing c8401aa38f
Merge pull request #7271 from furo321/afk-optional
Make IsAfk attribute optional
2023-09-30 18:22:09 +00:00
furo 3b2389daa4 Make IsAfk attribute optional 2023-09-30 19:56:01 +02:00
Robert Müller cf35594fa4 Extract UpdateServerFriends function, cache friends on server
Calculate the number of friends on each server when refreshing the friend state of the server info instead of every time the server entry is rendered.
2023-09-30 13:32:36 +02:00
Robert Müller 7e8442d394 Move and rename UpdateFilteredPlayers function, mark as const 2023-09-30 13:29:28 +02:00
Robert Müller 28d4451057 Add local variable Info to reduce duplicate code 2023-09-30 13:29:28 +02:00
Robert Müller 034962ae24 Add enum ERankState to replace magic numbers 2023-09-30 13:29:28 +02:00
Robert Müller dcff6d92f0 Add name for enum EClientScoreKind 2023-09-30 13:29:28 +02:00
Robert Müller 721a55c603 Remove game menus includes in engine
Use config manager to reset `ui_page` to the default, instead of using `CMenus::PAGE_DDNET` directly (which is the default).

Check current type of serverbrowser instead of checking the current `ui_page` against `CMenus::PAGE_DDNET` and `CMenus::PAGE_KOG`.
2023-09-30 13:29:28 +02:00
Robert Müller 6753e37772 Move function definitions to remove and organize includes 2023-09-30 13:29:27 +02:00
Robert Müller e78305e1cd Remove unused m_aFilter(Gametype)String variables 2023-09-30 13:29:27 +02:00
Dennis Felsing 3e2893e638
Merge pull request #7182 from dobrykafe/pr-show-direction
Ability to show local keypresses only
2023-09-30 09:35:20 +00:00
Robert Müller c64ec0f677 Limit effects of dbg_stress to features useful for debugging
Using `dbg_stress 1` now only does the following (in debug build):

- Randomly send inputs.
- Randomly send chat messages.
- Randomly connect/disconnect to server configured with `dbg_stress_server` (`localhost` by default).

Previously it also did the following, which is not useful for this debugging feature and only complicates the code unnecessarily:

- Cause images and sounds not to be loaded.
- Render only every tenth frame.
- Always use inactive graphics refresh rate.
2023-09-28 20:14:54 +02:00
Robert Müller 06948ddecd Remove remains of dbg_stress from server
Using `dbg_stress 1` on a server made clients always auto-join team 0 and nothing else, which is not useful on its own for stress testing.
2023-09-28 20:14:23 +02:00
Robert Müller 247ce38094 Remove unused variables m_RenderFrameTimeLow/High 2023-09-28 20:12:55 +02:00
Robert Müller 74192b9051 Add CSnapshot::EmptySnapshot, mark pointer arguments as const
Instead of keeping track of a permanently empty `CSnapshot` object in client and server separately, add `CSnapshot::EmptySnapshot` to access a singleton empty `CSnapshot`.

Mark pointer parameters of snapshot functions as `const` when possible.
2023-09-26 20:13:27 +02:00
Jupeyy 958676ae84
Merge pull request #7251 from Robyt3/Graphics-Texture-Index-DoubleFree-Assertion
Add assertion when double-freeing texture index, ensure OpenGL texture vectors are large enough
2023-09-25 18:51:04 +00:00
furo 25101d2cb0 Add missing descriptions of commands. 2023-09-24 23:21:10 +02:00
Robert Müller 96a68455ca Ensure OpenGL texture vectors are large enough
In the unlikely case that the wanted texture slot is larger than twice the size of the original texture vector.
2023-09-24 22:27:16 +02:00
Robert Müller 99cee23de4 Add assertion when double-freeing texture index
Simplify the handling of free texture indices by using `-1` only for indices which are currently in use, whereas the size of the vector is now used to indicate the last free index. Otherwise the assertions incorrectly detect the last texture index always being in use because `-1` was used for both states.
2023-09-24 22:24:51 +02:00
Robert Müller 9933c1350d
Merge pull request #7246 from furo321/register_conchain
Configs used in Register OnConfigChange should have Conchain
2023-09-24 17:54:31 +00:00
furo 4476dfacde Configs used in OnConfigChange should trigger Conchain 2023-09-24 15:31:43 +02:00
Dennis Felsing 5d220e337c
Merge pull request #7244 from furo321/suicide-penalty
Remove unused config, `sv_suicide_penalty`
2023-09-23 22:17:43 +00:00
furo 436c977f7e Remove unused config, sv_suicide_penalty 2023-09-23 23:51:16 +02:00
Robert Müller 2d4bac8c0c Ensure strings in demo header are zero-terminated and valid UTF-8
Previously, if the demo header strings did not contain zero-termination, the client would render the strings and any following non-zero memory from the demo header.

Now, demos will not be loaded, if any string in the header is not zero-terminated or not valid UTF-8.
2023-09-23 22:14:34 +02:00
VoxelDoesCode c4d325e09b Show if your friend is AFK through friends list
resolve mege conflict

AFK -> Afk (for consistency)
2023-09-23 00:54:13 +02:00
Robert Müller 1d711d6cf0 Correctly update auth keys when using auth_remove
When using `auth_remove`, the key indices for the default helper, mod and admin passwords were not properly adjusted, causing the wrong passwords to be used for the username-less logins.

The key indices for connected clients were also not properly adjusted, causing the wrong identity to be shown for currently authenticated clients when using the `status` command.

Closes #6427.
2023-09-22 21:12:20 +02:00
Dennis Felsing c042835c1d
Merge pull request #7234 from Robyt3/Input-PumpEvents
Fix double-click handling with `gfx_asyncrender_old 0`
2023-09-22 15:38:17 +00:00
Robert Müller 98bfed7859 Fix double-click handling with gfx_asyncrender_old 0
We need to call `SDL_PumpEvents()` to ensure that we have the latest keyboard, mouse and joystick state before we use it.

See:
- https://wiki.libsdl.org/SDL2/SDL_GetKeyboardState
- https://wiki.libsdl.org/SDL3/SDL_GetMouseState#code-examples

Closes #7052.
2023-09-22 17:09:39 +02:00
Robert Müller b9951dd411 Refactor and reorder RateConvert, DecodeOpus, DecodeWV
Pass sample by reference instead of by index, as the functions are only used internally and a valid sample is assured.
2023-09-21 23:52:44 +02:00
Robert Müller 7fe854d861 Reduce indentation, rename variables in Mix function 2023-09-21 23:52:40 +02:00
Robert Müller 07e18ebecb Replace most global variables in engine sound with member variables
Most variables used in the sound engine were static globals, as they are used in the static sound mixing function. The global variables are replaced by member variables, by passing the sound interface as user-data for the SDL mixing callback. The `Mix` function is made a public member function of `ISound` instead of being exposed using `ISoundMixFunc GetSoundMixFunc()`.

This allows to remove the direct dependency of the engine sound on the engine video, by instead passing the sound mixing function as a lambda to the engine video in the engine client.

The old WavPack reader function interface does support passing a user-data pointer to the callback function, so global variables are still used here.
2023-09-21 23:52:13 +02:00
Robert Müller a2de08a8db Add UpdateVolume function, remove unnecessary lock usage
Using the lock is not necessary, as the volume is already an atomic variable.
2023-09-21 23:44:59 +02:00
Robert Müller beaf263f3d Reorder SetChannel and SetListenerPos functions 2023-09-21 23:44:58 +02:00
Robert Müller b0356aea13 Rename argument, reduce indentation of SetVoiceTimeOffset 2023-09-21 23:44:58 +02:00
Robert Müller f169ce1c8c Use nullptr instead of 0, 0x0 and NULL 2023-09-21 23:44:58 +02:00
dobrykafe 7c710ddb96 add another value instead of new variable 2023-09-20 22:47:09 +02:00
Robert Müller 61a9095fc3 Remove unused IServerBrowser::TYPE_NONE, add NUM_TYPES 2023-09-20 17:03:24 +02:00
Dennis Felsing 60de0f191e
Merge pull request #7217 from furo321/gfx-screen-conchain
Add console chain for screen resolution commands.
2023-09-20 09:25:14 +00:00
furo 597350010f Add console chain for screen resolution commands. 2023-09-20 11:01:43 +02:00
Jupeyy fcbe429d4c Decrease descriptor pool's current size when descriptor is freed 2023-09-19 18:28:48 +02:00
Robert Müller ce65d57f2e Support dynamic list of "communities" in engine serverbrowser
Replace existing hard-coded support for two "networks" with support for a dynamic list of "communities" which are indexed by a string-ID, though right now the DDNet and KoG communities are still hard-coded. The communities now also support an arbitrary number of associated countries, types and servers. This is a refactoring to prepare for getting the list of communities dynamically from the server and removing the DDNet and KoG tabs from the serverbrowser.
2023-09-18 19:37:04 +02:00
Robert Müller 2973eee036 Refactor json parser usage in CServerInfo2::FromJsonRaw 2023-09-18 17:37:21 +02:00
Robert Müller ca1bec5bac Refactor json parser usage in CServerBrowser::LoadDDNetRanks 2023-09-18 17:37:15 +02:00
Robert Müller e82e197109 Use NUM_LOCS as static assertion for array size 2023-09-18 17:29:43 +02:00
Dennis Felsing a706074c82
Merge pull request #7203 from Robyt3/Serverbrowser-Memory-Leak
Fix memory leak of server browser entry UI elements
2023-09-17 20:13:01 +00:00
Robert Müller 816f1a5a01 Fix memory leak of server browser entry UI elements
New UI elements were being created for every server info after refreshing the server list. At the same time, old UI elements were not being deleted when the server info objects are deleted. The use of `mutable` for this purpose was also rather unclean.

Now, a separate `std::vector` of UI elements is kept for all server browser entries, instead of associating the UI elements directly with the server info.
2023-09-17 21:37:36 +02:00
Robert Müller 8dfa0b2198 Rename UpdateFilteredPlayers, remove mutable variable 2023-09-17 21:37:32 +02:00
Dennis Felsing e33b747a4c Increase password size limit from 32 to 128 2023-09-17 14:32:23 +02:00
Robert Müller 0b57d56f48 Overhaul server browser filter, details and friends tabs
Move the "Filter", "Info" and "Friends" tabs to the top, above the tab content. Use icons instead of text for the tabs. Use animator to animate the tabs on mouse-over. Closes #6613.

Make spacings, corners and font sizes used in the filter, details and friends tabs more consistent.

Remove some unnecessary dark UI rect backgrounds.

Improve alignment of the number of friends with the heart icon for entries in the server list.

Improve layout of countries and types filters. Make the filters scrollable when there are many entries.

Refactor most of the server browser in preparation for replacing the DDNet and KoG tabs with a community filter, which will work like the countries and types filters. Split rendering of different server browser sections into multiple functions to improve readability. Reduce duplicate code for the countries and types filters.
2023-09-16 13:45:52 +02:00
dobrykafe 74567a1a62 ability to show local keypresses only 2023-09-15 20:34:23 +02:00
Robert Müller 0ea4d6540a Overhaul demo player skipping UI and UX
Make the skipping duration adjustable with a dropdown menu. The dropdown menu includes the durations 1s, 5s, 10s, 30s, 1m, 5m and 10m. The default duration is 5s. Skipping durations longer than the current demo are not shown. The dropdown menu is only shown if two or more durations would be shown.

Add buttons for skipping the duration, which was previously only possible with the hotkeys.

Add Ctrl+Left/Right hotkeys for skipping to chapters.

Add Shift+Left/Right hotkeys for adjusting the skipping time.

The Left/Right arrow keys and the J/L keys work identically for all hotkeys now.

Ignore ctrl, shift and alt keys for demo speed changes with the mouse wheel, to better support actions like zooming being bound to alt+mousewheel etc.

Also handle keypad enter key for play/pause like the normal return key.

Use arrow up/down icon for speed adjustment buttons, so that the "backward/forward" icons can be used for duration skipping instead.

Closes #7064.
2023-09-13 21:03:04 +02:00
Jupeyy ca2926335b Disable scissor for clearing the framebuffer 2023-09-10 09:44:32 +02:00
Alexander Akulich 1074a5ff56 CMake: Use DDNet_VERSION to construct DDNET_VERSION_NUMBER 2023-09-08 23:13:00 +03:00
Dennis Felsing ee1b8baab5
Merge pull request #7145 from infclass/for-ddnet4
Cleanup CMake, adjust the version variables
2023-09-08 08:09:56 +00:00
Alexander Akulich d0ecb5f8dd CMake: Rework the versioning 2023-09-08 00:10:48 +03:00
heinrich5991 2bf2850b20
Merge pull request #7128 from ChillerDragon/pr_sixup_slot_info
Fix 0.7 clients not being able to join after slot change
2023-09-06 23:15:43 +00:00
Robert Müller dd8b2cd88a Fix incorrect text height when maximum number of lines specified
Check if maximum number of lines has been reached before starting a new line, to prevent the text cursor from reporting the wrong number of lines and text height in that case.
2023-09-06 19:16:42 +02:00
Robert Müller fe95919f63 Support longer lines being rendered in console
Don't truncate console lines at 255 bytes anymore. Especially lines containing many Unicode characters would be adversely affected by this limitation.

Instead, truncate console lines after 10 wrapped lines are rendered. Rendering too many lines at once currently breaks the console scrolling. Rendering an ellipsis is currently not possible when rendering text with a maximum line count.

Increase buffer sizes to handle long (esp. invalid) command inputs.

Closes #7132.
2023-09-06 19:16:00 +02:00
ChillerDragon 5a8e67b323 Fix 0.7 clients not being able to join after slot change
If the player slots update the 0.7 clients have to be informed
about it. Otherwise the client can block the join button
if the outdated playerslots are filled already.
2023-09-06 12:50:16 +02:00
heinrich5991 d2a12e01c1
Merge pull request #7126 from Robyt3/Graphics-Format-PixelSize
Add `CImageInfo::PixelSize` function, use `enum EImageFormat`
2023-09-06 09:57:59 +00:00
heinrich5991 86e0e9539d
Merge pull request #7135 from Moiman/typos
Fix typos
2023-09-05 21:04:33 +00:00
Harri Nieminen 4d9ff1d904 Fix typos
Found by codespell
2023-09-05 22:32:09 +03:00
Robert Müller 1604784669 Improve Windows pipe (FIFO) support
Use `WaitForPipeDrain` to deterministically wait for the pipe to drain instead of using `Start-Sleep`.

Use `Dispose` instead of `Close` to properly flush and close the pipe stream.

Add error handling for connection timeout and I/O errors.

Handle `ERROR_BROKEN_PIPE` separately when peeking at pipe, as this happens when the pipe is disconnected immediately after connecting it or after reading the previous message.

Don't ignore `ERROR_BAD_PIPE` anymore, as the pipe should never be in a disconnected (i.e. bad) state at this point of the function.
2023-09-05 19:15:09 +02:00
Robert Müller dde45f7a40 Add CImageInfo::PixelSize function, use enum EImageFormat
Use `enum EImageFormat` type for image format literals and variables.

Add `PixelSize` function to get the number of bytes/color channels per pixel for a specified image format.

Remove unused store format argument of texture loading functions. All textures are automatically being stored as RGBA, so the argument was unused. Also remove the therefore unused `FORMAT_AUTO`.

Rename variables consistently to `PixelSize` and use `size_t`, instead of mixing different names like `BPP` and `ColorChannelCount`.

Validate image format loaded from maps using `CImageInfo::ImageFormatFromInt`. Add `FORMAT_ERROR` to represent invalid formats.

Remove redundant `PixelSize` parameter from graphics backends and commands, which can be derived from the texture format.

Fix memory leak when RGB image data is being converted to RGBA format when saving map in editor.
2023-09-03 20:40:28 +02:00
Robert Müller ab6262d7ce Use nullptr instead of NULL 2023-09-02 12:07:46 +02:00
Robert Müller 872d6c9e5e Move variable declarations closer to usage/definition 2023-09-02 12:05:31 +02:00
Robert Müller ead33ba05a Add debug messages for all error cases in LoadPNG 2023-09-02 12:01:06 +02:00
Robert Müller 1ebd209f90
Merge pull request #7095 from Marmare314/refactor-a1
Refactor editor mapitems
2023-09-01 18:47:51 +00:00
marmare314 12d0608dfd let CEditorImage inherit CEditorComponent 2023-09-01 18:57:35 +02:00
Jupeyy 16115c204e
Merge pull request #7094 from Robyt3/Variable-Desc-Fixes
Remove `gfx_finish` config variable, remove `dbg_hitch` config variable, improve config variable descriptions, add missing descriptions
2023-08-30 18:28:25 +00:00
Robert Müller 98b3fe460a Fix typo in internal name of cl_assets_entities config variable
The name used in config is unchanged.
2023-08-30 20:07:12 +02:00
Robert Müller 943f98dc92 Improve config variable descriptions, add missing descriptions 2023-08-30 20:07:11 +02:00
Robert Müller 1028cedee3 Remove dbg_hitch config variable
This config variable was only settable in the server console but only read in the client, so it was effectively unusable. It also has no use case right now.
2023-08-30 20:07:11 +02:00
Robert Müller 31a80c976b Remove gfx_finish config variable
This config variable does not have any use case right now and only causes the rendering to be slowed down.
2023-08-30 20:07:11 +02:00
Robert Müller 0a290bc501 Remove unused enum literals 2023-08-30 17:58:21 +02:00
Robert Müller 95b1c7dc2b Hide client is not online log message except when using record
The log message is otherwise shown multiple times when starting the client.

Now it's only shown when the `record` command is used manually, i.e. not for automatically recorded demos anymore.
2023-08-29 22:05:16 +02:00
heinrich5991 ee32ceb1da
Merge pull request #7092 from furo321/pr_fix_ipv4only_registering
Don't register to ipv6 when sv_ipv4only is enabled. (fixes #7091)
2023-08-28 21:09:59 +00:00
furo b24b11f48e Move sv_ipv4only check to OnConfigChange 2023-08-28 22:45:53 +02:00
Dennis Felsing ff1a2a44d3
Merge pull request #7076 from dobrykafe/pr-fix-map-drag-and-drop
Add warning for unsaved editor changes when dragging a map file into the game
2023-08-28 13:49:58 +00:00
furo 8f73a9ea8c Fix style 2023-08-27 21:40:32 +02:00
furo 2b07832b9e Don't register to ipv6 when ipv4only is enabled. 2023-08-27 21:23:55 +02:00
heinrich5991 330d1ebaf6 Add possibility to persist game data past map changes 2023-08-27 16:11:45 +02:00
dobrykafe cb29ad2b4f dont switch to editor if loading fails 2023-08-26 22:13:13 +02:00
dobrykafe 5e923adcc9 fix map drag and drop 2023-08-26 18:14:13 +02:00
Dennis Felsing 23ed630a4e
Merge pull request #7065 from heinrich5991/pr_ddnet_teehistorian_antibot
Allow antibot to record data into teehistorian
2023-08-25 15:08:35 +00:00
heinrich5991 84948adad1 Allow antibot to record data into teehistorian 2023-08-25 14:26:09 +02:00
heinrich5991 548f2f6021
Merge pull request #7058 from Robyt3/Demo-Player-Pause-Indicator
Show indicator when pausing/unpausing in demo player
2023-08-25 11:55:03 +00:00
Robert Müller ec0522d58f Show indicator when pausing/unpausing in demo player
Render a pause/play icon in the center of the screen when pausing/unpausing while the menu is not active.

The icon fades in and out over 0.5 seconds and slightly increases in size over that time.

When starting demo rendering with initial pause, the pause indicator is rendered continuous until playback is first started, to ensure that the initial pause state is communicated clearly to the user. The initial pause indicator is not included in the rendered demo, but pausing and unpausing later during demo rendering will cause it to be included in the video, same as other UI elements. Closes #7044.

The config variable `cl_demo_show_pause` (`0/1`, default `1`) is added to hide the pause indicator entirely, for example to render a demo with multiple pauses without the indicator.

The pause indicator and also the existing speed indicator are not rendered (anymore) while the menu is active, as the menu already contains this information.
2023-08-25 13:29:17 +02:00
heinrich5991 b739c18a86
Merge pull request #7056 from Robyt3/Base-Number-Format-Optimization
Add `str_from_int` function
2023-08-25 11:16:00 +00:00
heinrich5991 1f13a693a5
Merge pull request #6744 from Zwelf/pr-fix-teehistorian-mapchange
Fix JoinVer and Join teehistorian chunks missing in some conditions
2023-08-25 11:15:43 +00:00
Zwelf 3c2d8afff6 Create new teehistorian event for player rejoin 2023-08-25 00:42:54 +02:00
Robert Müller d2c9750c65 Add str_from_int function
Add more efficient function for formatting integer values as strings.

A benchmark shows that using this function is significantly faster than using `str_format`. It is faster by a factor of 220 with Clang 15.0 O2 (https://quick-bench.com/q/BlNoLnlyqxipf4jvsFTUxKMHDJU) and by a factor of 11 with GCC 12.2 O2 (https://quick-bench.com/q/Fxf9lDCTqXBF4pIa_IyZ5R0IqYg).

This increases FPS in the editor by ~25% when many numbers are rendered for switch/tele/speedup/tune layers or with "Show Info" being enabled.

The additional static analysis for `std::to_chars` revealed that the wrong size was used in `CHud` for `aScoreTeam[TEAM_RED]` and `aScoreTeam[TEAM_BLUE]`.

This requires incrementing the macOS deployment target from 10.13 to 10.15.
2023-08-24 20:54:17 +02:00
heinrich5991 1c8a67f6f9
Merge pull request #7049 from Robyt3/Sqlite-Error-Assertion
Fix assertion failure when SQLite connection fails, Remove unused `IDbConnection::Copy`
2023-08-23 15:38:39 +00:00
Robert Müller 040731095e Fix assertion failure when SQLite connection fails
When connecting to the SQLite database fails, e.g. because the `.sqlite` file is corrupted, the server would crash with the assertion "Tried connecting while the connection is in use" when a player joins and performs any action.

This is fixed by resetting the use-flag when connecting to the SQLite database fails, which is the same behavior as for the MySQL database connection.
2023-08-22 20:40:36 +02:00
Robert Müller bb147328c2 Remove unused IDbConnection::Copy 2023-08-22 20:40:36 +02:00
ChillerDragon 796d79ad5b Replace 0.7 serverinfo magic number with enum 2023-08-22 13:53:08 +02:00
Dennis Felsing 55789819a3
Merge pull request #7026 from ChillerDragon/pr_auth_unused
NETMSG_AUTH_CHALLENGE is not used in 0.6 or 0.7
2023-08-22 09:59:58 +00:00
ChillerDragon 87640d7857 NETMSG_AUTH_CHALLENGE is not used in 0.6 or 0.7 2023-08-22 10:31:16 +02:00
Robert Müller 7c1a667486
Merge pull request #7046 from infclass/kaffeine/drop-rendering-paused-by-default
Remove cl_video_pause_on_start; reset the pause option on popup opened
2023-08-19 11:42:54 +00:00
Alexander Akulich 29688fb499 Remove cl_video_pause_on_start; reset the pause option on popup opened 2023-08-19 13:51:38 +03:00
Robert Müller bfe1175558 Save console output variables again, improve descriptions
As #6451 was partially reverted by #5434.
2023-08-19 10:53:47 +02:00
Dennis Felsing a44bd9d3e1 Shut down db connection pool (fixes #7036) 2023-08-17 14:35:58 +02:00
Dennis Felsing b52fa5e910
Merge pull request #7028 from Robyt3/Base-Str-Utf8-Offset-Functions
Add utility functions for converting UTF-8 bytes ↔ chars offsets
2023-08-15 21:10:38 +00:00
Zwelf d7164211e6 Rename OnClientEngineJoin and OnClientEngineDrop to make the name fit its usage 2023-08-15 22:22:42 +02:00
Zwelf b9458150e0 Fix JoinVer and Join teehistorian chunks missing in some conditions
vanilla 0.6 joins weren't recorded. Also after map change, for the
existing players these Join chunks were missing.  Just add these
message for existing players now and add OnClientEngineJoin in all
code paths with clients connecting.
2023-08-15 22:22:42 +02:00
Robert Müller af3870a64d Add utility functions for converting UTF-8 bytes ↔ chars offsets
Add `str_utf8_offset_bytes_to_chars` and `str_utf8_offset_chars_to_bytes` functions to base system to convert between byte and UTF-8 character offsets in UTF-8 strings.

Previously, this was separately implemented in the textrender and in the lineinput helper.

These textrender functions are entirely replaced by the new functions:

- `ITextRender::SelectionToUTF8OffSets` (by `str_utf8_offset_chars_to_bytes`)
- `ITextRender::UTF8OffToDecodedOff` (by `str_utf8_offset_bytes_to_chars`)
- `ITextRender::DecodedOffToUTF8Off` (by `str_utf8_offset_chars_to_bytes`)

These lineinput helper functions are reimplemented using the new functions:

- `CLineInput::OffsetFromActualToDisplay` (uses `str_utf8_offset_bytes_to_chars`)
- `CLineInput::OffsetFromDisplayToActual` (uses `str_utf8_offset_chars_to_bytes`)
2023-08-15 22:11:25 +02:00
Robert Müller 7168fb15d2 Move OnWindowResize listener to engine, handle editor
Register the `OnWindowResize` listener in the engine client instead of the game client and properly dispatch the event also to the editor, so text containers in the editor are cleared when the window is resized.

Closes #7018.
2023-08-15 20:17:27 +02:00
Robert Müller 5567c56d3a Reorder CClient interface pointers alphabetically 2023-08-15 19:47:52 +02:00
Robert Müller 15be3c3944 Remove unused m_DebugSoundIndex variable 2023-08-15 19:47:52 +02:00
Robert Müller f90e908c9d Reset text containers on language change
Fix text containers rendering broken text after the language is changed, as this cleared the glyph atlas without clearing the references to the glyph positions in the text containers. Now `OnWindowResize` is also called on language change to reset all text containers.

However, the glyph atlas is not cleared on normal window resize anymore, because this seems to be unnecessary.
2023-08-14 23:04:55 +02:00
Samuele Radici 5e1ef437d8
Update connection_pool.cpp 2023-08-12 18:40:33 +02:00
Robert Müller b98d519744 Use textrender for graphs, refactor CGraph::Render
Use textrender for rendering debug graph labels instead of using the debugging font and quad text.
2023-08-08 20:31:47 +02:00
Robert Müller be83d44470 Refactor CClient::DebugRender
Fix names of static variables. Remove dead code.
2023-08-08 20:31:47 +02:00
Robert Müller 0e161cf4d9 Fix textrender variables being uninitialized
Regression from #6952.
2023-08-07 17:53:54 +02:00
ChillerDragon c5a4447fde Fix redirect release version
See #6969 (hihi)
2023-08-06 16:01:27 +02:00
Robert Müller 75a368f552 Improve text rendering texture atlas utilization and performance
Replace skyline-based texture atlas algorithm with a rectangle packing algorithm that tracks empty atlas sections using `std::vector`s. The algorithm is very loosely inspired by https://github.com/TeamHypersomnia/rectpack2D.

Increases texture atlas utilization from ~70% to ~90-94%, i.e. less space in the atlas is unused.

Decreases the computational time to find suitable free regions in the atlas by factor 40x-164x (depending on atlas dimension and utilization). In absolute numbers, the computational time necessary for a glyph being added to the atlas is decreased from 0.0556ms-0.4679ms to 0.0013ms-0.0051ms (depending on atlas dimension and utilization).

The memory usage for the texture atlas algorithm increases from a maximum of ~128 KB to a maximum of ~3 MB.
2023-08-05 22:28:53 +02:00
Edgar 8c49c2ea4b
Merge pull request #6952 from Robyt3/TextRender-Font-Index-File
Add font index, support font family variants depending on language
2023-08-05 15:49:12 +00:00
heinrich5991 8fc5549306
Merge pull request #6876 from ChillerDragon/pr_new_connection_string
Support master server address format in client
2023-08-05 08:49:12 +00:00
ChillerDragon f701e2eb16 Support master server address format in client
This still works

	$ ./DDNet "connect 127.0.0.1"

But now also this works

	$ ./DDNet "connect tw-0.6+udp://ger10.ddnet.org:8303"
	2023-07-16 14:07:50 I engine: running on unix-linux-amd64
	2023-07-16 14:07:50 I client: starting...
	2023-07-16 14:07:50 I client: version 17.1.1 on linux amd64
	2023-07-16 14:07:50 I client: git revision hash: 7f100e2620
	2023-07-16 14:07:50 I client: connecting to 'tw-0.6+udp://ger10.ddnet.org:8303'
	2023-07-16 14:07:50 I host_lookup: host='ger10.ddnet.org' port=8303 3
	2023-07-16 14:07:51 I client: connected, sending info
2023-08-04 12:32:02 +02:00
heinrich5991 26cd03bca1
Merge pull request #6914 from ChillerDragon/pr_redirect
Allow server to redirect clients
2023-08-03 09:19:26 +00:00
Robert Müller d642abd722 Add font index, support font family variants depending on language
Add `fonts/index.json` which specifies:

- List of all font files that should be loaded (filenames).
- Default font (specified by family name or by family and style name).
- Font variants for different languages, using the name of the language file as key.
- Fallback fonts.
- Icon font.

There are characters (e.g. all in `刃直海角骨入`) that look different depending on the language of the content being Japanese, Simplified Chinese, Traditional Chinese and Hangul, because Unicode uses the same codepoint for characters regardless of the language. To render these characters correctly, the active variant font is switched depending on the selected language.

The `ITextRender` interface is changed so the current language variant can be set using `SetFontLanguageVariant` and the default and icon fonts can be toggled using `SetFontPreset`. The class `CFont` is removed entirely.

The text render is restructured: The font faces and font atlas are now managed by a separate class `CGlyphMap` like on upstream. As the text fill and outline textures always have the same size, the texture skyline only needs to be stored once and free positions in the atlas only need to be calculated once for each glyph instead of separately for the fill and outline textures.

The font files and their licenses are also updated:

- Update Source Han Sans to version 2.001.
- Update Glow Sans Japanese Compressed to version 0.93.
- Update Deja Vu Sans to version 2.37.
- Update Font Awesome icons font to March 2023 version.

Closes #6881.
2023-08-01 19:30:25 +02:00
heinrich5991 406bc261fb
Merge pull request #6958 from Zwelf/pr-fix-crash-dnsbl
Fix stack overflow in destructor when dnsbl object is kept too long alive
2023-08-01 09:40:04 +00:00
Edgar 27e846f8db
Merge pull request #5434 from heinrich5991/pr_ddnet_loglevels
Add separate log levels for each output
2023-08-01 09:20:06 +00:00
Zwelf d682d24eb5 Fix stack overflow in destructor when dnsbl object is kept too long alive
`shared_ptr`s of `CServer::m_pDnsblLookup[ClientID]` are set, but not
cleaned up when done. Therefore the Job is kept alive until the player
disconnects and a new player joins on that slot. Currently this means
that the full linked list of jobs is kept alive.

When the Job is overwritten with a new job, all the remaining objects in
the list can be dropped. With enough jobs, that is causing a stack
overflow in the destructor.

This patch fixes this overflow by making the lifetime independent of the
previous Job. Jobs can get dropped after processing them, even when the
previous job is still alive.

Fixes #6954
2023-08-01 11:14:53 +02:00
heinrich5991 c5e27b283b Delete fishy-looking assignment operator/copy constructor of IJob
Since they're not called anyway, they can go away.
2023-08-01 09:45:15 +02:00
Robert Müller 3b273500c5
Merge pull request #6942 from heinrich5991/pr_ddnet_game_settings_cleanup
ResetServerGameSettings → ResetGameSettings, remove flag argument
2023-07-29 08:48:05 +00:00
heinrich5991 a94b5c35bf ResetServerGameSettings → ResetGameSettings, remove flag argument
The old code looked pretty weird. It checked for `CFGFLAG_SERVER |
CFGFLAG_GAME` being set above, and then used the passed-in parameter to
find the command. I think it'd be better to just look for `CFGFLAG_GAME`
and then find the command using `CFGFLAG_GAME`.
2023-07-28 16:12:21 +02:00
heinrich5991 8b0f317aa0
Merge pull request #6939 from Robyt3/Datafile-Data-Decompress-Check
Check for errors when reading and decompressing datafile data
2023-07-28 11:38:32 +00:00
Robert Müller 7069d74beb Check for errors when reading and decompressing datafile data
Check if datafile data cannot be read entirely (according to the data size specified in the header) and check for decompression errors. In case of errors, let `GetData` return `nullptr` and `GetDataSize` return `0` for the respective index.

Internally the decompressed size is set to `-1` for data which failed to load, so loading of those data will not be attempted again because it would only fail again and can cause additional log messages.
2023-07-28 13:19:40 +02:00
heinrich5991 564a5958e1
Merge pull request #6940 from Robyt3/Graphics-Rect-Remove-Inverted-Corners
Remove inverted round rectangle corner drawing
2023-07-28 10:24:43 +00:00
Robert Müller c695fd750e Remove inverted round rectangle corner drawing
Rectangles with inverted round corners (`IGraphics::CORNER_I*`) are currently not used anywhere and also only supported when using `Draw4`.

They also feel clunky to use due to the inverted corners being drawn outside of the specified rectangle area.
2023-07-27 23:29:37 +02:00
Robert Müller 4233574085 Fix leak of map data when extracting map from demo fails 2023-07-27 21:27:39 +02:00
Tater 6bb2696c8b Fix crash in ResetServerGameSettings 2023-07-27 13:26:11 -05:00
ChillerDragon e3afe0dba4 Allow server to redirect clients
This is a preperation for #6754 (redirect players on map vote)
And an implementation of #5662 (redirect players)
2023-07-27 11:30:11 +02:00
Robert Müller 71500fd60c Improve server settings editor and status bar
Use icons for all server settings buttons. Rearrange and group buttons.

Show buttons in disabled state when they are not useable instead of hiding them.

Remove checker background from server settings list.

Overhaul hotkeys, also show hotkeys in the tooltips:
- Enter: add command
- Alt+Enter: update command (previously M)
- Alt+Up/Down: move command up/down (previously no hotkey)
- Delete: delete command

Don't activate command lineinput when selecting, moving or deleting elements, as this prevents the listbox from accepting the delete hotkey.

Fix server settings listbox being active while file dialog is open.

Ensure extra editor dragbar area matches the respective toolbar size.

Remove spacing on the left side of extra editors to improve alignment.

Increase status bar button sizes and make them consistent.

Use `enum` to track active extra editor instead of using multiple `bool`s.

Disable extra editor buttons when tile picker is shown, as the extra editors are not rendered in this case.
2023-07-25 21:21:54 +02:00
Robert Müller 880dab7e69 Port JSON writer from upstream
Port the `CJsonWriter` utility class from upstream, which makes outputting correct JSON easier.

Add `CJsonWriter` as an abstract class that can write to different outputs. Two implementations `CJsonFileWriter` (writes to a file) and `CJsonStringWriter` (writes to an `std::string`) are added. Upstream `CJsonWriter` can only write to files.

The same tests are added for both implementations. Duplicate code is avoided by using typed tests with two separate test fixtures.
2023-07-25 15:05:25 +02:00
Tater 4fe7aaa43f execute CFGFLAG_GAME configs on the client 2023-07-24 19:15:29 -05:00
heinrich5991 4f103d5a4c Revert "Allow server to redirect clients"
Discussion wasn't finished:
https://github.com/ddnet/ddnet/pull/6757#issuecomment-1648565562.

This reverts commit 9d2f4318d5.
2023-07-24 22:51:27 +02:00
heinrich5991 85566fbe92 Add separate log levels for each output
`stdout_output_level` for printing to stdout, `console_output_level` for
printing to local console and remote console and `loglevel` for the log
file.

Keep the old log level filters 0 for info and more severe, 1 for debug
and more severe and 2 for trace and more severe, introducing -1 for
warn, and -2 for error. -3 will show no log messages at all.
2023-07-24 22:43:05 +02:00
heinrich5991 e432dbb750
Merge pull request #6757 from ChillerDragon/pr_redirect
Allow server to redirect clients
2023-07-24 20:21:21 +00:00
Robert Müller 58927cdc8d Use size_t more in engine graphics 2023-07-20 21:58:17 +02:00
Robert Müller 78e23062c9 Add assertions for graphics command buffer allocation
When memory for a command or data in the command buffer cannot be allocated in `CGraphics_Threaded::AddCmd` and `CGraphics_Threaded::AllocCommandBufferData` the command buffer is cleared so it should always be possible to allocated memory successfully on the second try. Therefore assertions are added and the return values and inconsistent checks of the functions are removed.

The usage of `AddCmd` is simplified by automatically deriving an error message based on the type of the template parameter.
2023-07-20 21:58:17 +02:00
Robert Müller a96242b850 Extract CGraphics_Threaded::FindFreeTextureIndex function
To reduce duplicate code.
2023-07-20 21:58:16 +02:00
Robert Müller 3134d42ce6 Extract CGraphics_Threaded::FreeTextureIndex function
To reduce duplicate code.
2023-07-20 21:58:16 +02:00
Robert Müller b432feb9b0 Add assertion in CGraphics_Threaded::LoadTextureRawSub
To check for invalid texture handle.
2023-07-20 21:58:16 +02:00
Robert Müller 21bbc8be61 Improve filename length check for images
Only add assertion to prevent empty filename, as this causes Valgrind to crash.

Handle empty filename used for special null-image separately in gameclient.
2023-07-20 21:58:16 +02:00
heinrich5991 9c0c7550ba Don't support loading RGB images ingame
They're essentially unused and not supporting them ingame probably
allows to keep that part of the map format unused.

See https://github.com/ddnet/ddnet/pull/5737#issuecomment-1538284956 or
https://github.com/teeworlds/teeworlds/issues/2812.
2023-07-16 15:26:00 +02:00
Robert Müller 4ae0928b47 Support bezier envelope curves in maps and editor
Port map and editor support for `CURVETYPE_BEZIER` from upstream, i.e. support bezier curves with configurable in- and out-tangents for every envelope point.

The in- and out-tangents are represented by triangles and can be dragged in the envelope editor like the envelope points.

Support reading and writing the bezier information as a separate UUID-based map item. If the bezier information is not found, bezier will default to linear behavior. Old clients will still be able to read the new maps and ignore the unknown map item. The unknown curvetype will also be handled as linear by old clients.

Allow reading upstream maps that use `CMapItemEnvelope` version 3. On upstream, a different struct is used to store all envelope points including bezier information, which broke compatibility to old clients.

Fix holding Ctrl for slow envelope point editing not working for vertical movement.

Highlight the currently selected element (envelope point or bezier tangent marker) which is being used with the value/time edit boxes.

Hide the value/time edit boxes when no element is selected.
2023-07-16 12:46:34 +02:00
Robert Müller 785f03e73a Report actual data sizes in CDataFileReader::GetDataSize
Previously it reported the internal file data size (compressed). This
made the `map_resave` tool do the wrong job.

Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2023-07-16 12:46:33 +02:00
Robert Müller 32f2fe936a Extract CMap::ExtractTiles with more validation
To reduce duplicate code and to add validation for tile skip everywhere.

Add separate `CMapItemLayerTilemap::TILE_SKIP_MIN_VERSION` constant and change `CMapItemVersion::CURRENT_VERSION` back to the previous version, as maps with tile skip can be loaded but skip is not used when saving.
2023-07-16 12:46:33 +02:00
oy 9c4b0c03b4 Finished skip tile based map loading 2023-07-16 12:46:33 +02:00
oy 19d78b9f40 Made client/server check for correct map version on load 2023-07-16 12:46:32 +02:00
Dennis Felsing 265eb69284 Destroy engine before graphics (fixes #6857) 2023-07-15 10:52:04 +00:00
Robert Müller 8e2411f477 Fix invalid texture being invalid and causing crash with Vulkan
When starting with `dbg_stress 1` the invalid texture was never actually getting loaded, which was causing the client to crash when using the Vulkan backend and starting with `dbg_stress 1`.

Additionally ensure that the invalid texture is 16x16 pixels large and loaded with the texture flags to support usage for tile rendering.

Closes #6504.
2023-07-11 23:41:16 +02:00
Robert Müller 43109bec3c Show message in editor when player is moved ingame
Show a short message below the existing chat mentions message that is shown in the top left area of the editor above the layers/images/sounds button when the player character is moved ingame while the editor is open. The messages are cleared when the editor is activated and when the client is disconnected.

Closes #1993.
2023-07-11 18:19:27 +02:00
Robert Müller 01e4eb1b8c Fix text wrapping with long Unicode strings
Rewind one unicode codepoint instead of rewinding only one character (byte) when text does not fit.

Closes #6810.
2023-07-10 17:50:24 +02:00
Alexander Akulich 5ba2a21528 Client: Make it possible to start demo rendering pre-paused
The pause can be useful e.g. to adjust the camera position and zoom
right on the first video frame.
2023-07-08 15:43:42 +03:00
Alexander Akulich c172b369b2 Client: Set the speed index on demo rendering (fix later speed changes) 2023-07-08 04:09:48 +03:00
Alexander Akulich f93c6c7659 IDemoPlayer: Make SetSpeedIndex() actually set index 2023-07-08 04:09:46 +03:00
Alexander Akulich 0a657225ce CDataFileWriter: Make it clear that Add methods do not modify the data 2023-07-08 02:44:53 +03:00
Robert Müller b5524d6c52 Ensure ListDirectory/Info entries are unique
When multiple files or folder have the same name in multiple storage locations, only pass the first entry (file or folder, whichever comes first) to the callback. To prevent files with the same name form being listed multiple times, e.g. in the demo browser, editor file browser, and asset lists.
2023-07-03 20:06:40 +02:00
Robert Müller 569753125e Add IStorage::NumPaths to get number of storage locations 2023-07-03 20:06:39 +02:00
ChillerDragon 9d2f4318d5 Allow server to redirect clients
This is a preperation for #6754 (redirect players on map vote)
And an implementation of #5662 (redirect players)
2023-07-02 14:05:11 +02:00
bors[bot] c955905662
Merge #6796
6796: CSound: Initialize all members (fixes #6795) r=Robyt3 a=def-

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Dennis Felsing <dennis@felsin9.de>
2023-07-02 09:23:09 +00:00
Dennis Felsing 69ba84e62c CSound: Initialize all members (fixes #6795) 2023-07-01 19:50:20 +02:00
bors[bot] 4bd14933b8
Merge #6790 #6793
6790: Prevent /swap with paused players r=def- a=Robyt3

Prevent swapping if either of the players is paused (i.e. their character is not in the gameworld), as this can cause them to be stuck in midair after swapping, which can be exploited to skip parts.

## Checklist

- [X] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [X] Tested in combination with possibly related configuration options (servers with `sv_pauseable 0` were and are unaffected)
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


6793: Use `std::vector` and `std::deque` instead of most `std::list`s r=def- a=Robyt3

Use `std::vector` in cases where elements are only inserted at the end of the collection.

Use `std::deque` in cases where elements are only inserted/deleted at the beginning/end of the collection.

Use `std::list` in the remaining single case where elements are being removed from arbitrary positions and added at either the beginning or the end of the collection.

Adjust variables names. Don't use separate prefix for `std::deque`s and `std::list`s, as they are only used very rarely. Closes #6779.

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Robert Müller <robytemueller@gmail.com>
2023-07-01 16:04:13 +00:00
Robert Müller bc73ea30c7 Use std::vector and std::deque instead of most std::lists
Use `std::vector` in cases where elements are only inserted at the end of the collection.

Use `std::deque` in cases where elements are only inserted/deleted at the beginning/end of the collection.

Use `std::list` in the remaining single case where elements are being removed from arbitrary positions and added at either the beginning or the end of the collection.

Adjust variables names. Don't use separate prefix for `std::deque`s and `std::list`s, as they are only used very rarely. Closes #6779.
2023-07-01 15:44:35 +02:00
Robert Müller 8d890e6773 Remove unused GraphicsThread/GraphicsThreadProxy declarations 2023-07-01 13:41:49 +02:00
Jupeyy 251edfd756 Continue sleeping, with cl_refresh_rate if packet waked client up 2023-06-28 21:02:41 +02:00
bors[bot] 05ddfba954
Merge #6755
6755: Remove individual RGBA sliders from editor color picker, add shift+rightclick/leftclick to copy/paste color in editor r=Jupeyy a=Robyt3

Remove the individual RGBA sliders for editor color pickers and only show one button that opens the color picker popup instead.

Decrease size of layer and point popups that previously had color properties which need less space now.

Support shift-rightclicking color picker buttons to copy the color to the clipboard in RRGGBBAA hex format.

Support shift-leftclicking color picker buttons to paste a color from the clipboard in RGB, RGBA, RRGGBB or RRGGBBAA format with optional leading `#` or `$`.

Screenshots:
- Before:
![screenshot_2023-06-20_20-39-43](https://github.com/ddnet/ddnet/assets/23437060/4a8b230c-a66b-4e2a-9744-cb5f80f6a799)
- After:
![screenshot_2023-06-20_20-40-00](https://github.com/ddnet/ddnet/assets/23437060/517f90cf-06a5-4332-9eb8-6a87cbc91b32)
- After (color picker open):
![screenshot_2023-06-25_17-35-55](https://github.com/ddnet/ddnet/assets/23437060/30320b56-e4cb-4e93-bf7b-8cfc8d96620b)


Suggested by `@HiRavie` in https://github.com/ddnet/ddnet/pull/6743#issuecomment-1593886873, though it was easier and also looks better to me when the color picker button has exactly the same size as the other value selectors.

## Checklist

- [X] Tested the change ingame
- [X] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Robert Müller <robytemueller@gmail.com>
2023-06-27 19:29:43 +00:00
Robert Müller 2126d8570f Use separate thread to finish saving maps, add saving indicator
Compressing the data with zlib takes the majority of the time when saving a datafile. Therefore, compressing is now delayed until the `CDataFileWriter::Finish` function is called. This function is then off-loaded to another thread to make saving maps in the editor not block the rendering.

A message "Saving…" is shown in the bottom right of the editor view while a job to save a map is running in the background.

While a map is being finished in a background thread another save for the same filename cannot be initiated to prevent multiples accesses to the same file.

Closes #6762.
2023-06-26 21:58:04 +02:00
Robert Müller 1810d972f4 Autosave copy of current editor map periodically to auto folder
A copy of the map currently open in the editor is saved every 10 minutes to the `maps/auto` folder (interval configurable, see below). The automatically saved map uses the filename of the original map with an additional timestamp. Per map name 10 autosaves are kept in the `auto` folder before old autosaves will be deleted (number configurable, see below).

Add config variable `ed_autosave_interval` (0 - 240, default 10) to configure the interval in minutes at which a copy of the current editor map is automatically saved to the 'auto' folder.

Add config variable `ed_autosave_max` (0 - 1000, default 10) to configure the maximum number of autosaves that are kept per map name (0 = no limit).

Autosaving will not take place in the 5 seconds immediately after the map was last modified by the user, to avoid interrupting the user with the autosave.
This will only delay autosaving for up to 1 minute though, so autosaves are not prevented entirely, should the user continuously edit the map.

When the editor is reopened after being closed for more than 10 seconds, the autosave timer will be adjusted to compensate for the time that was not spent on editing in the editor.

When the map is saved manually by the user the autosave file is also updated, if it's outdated by at least half of the configured autosave interval. This ensures that autosaves are always available as a periodic backup of the map.

When a copy of the current map is saved, this does not update the autosave and will also no longer reset the modified state. The modified state should reflect whether changes have been made that are not saved to the current map file. As saving a copy does not update the current file, the modified state should not be reset in this case.

Closes #6693.
2023-06-26 21:58:04 +02:00
Robert Müller c25d20047b Add storage parameter to sound loading functions
So the storage type can be specified when loading sound files directly from the storage.
2023-06-25 21:25:34 +02:00
Robert Müller 9ecb010579 Use IO_MAX_PATH_LENGTH in CFileCollection 2023-06-25 10:49:57 +02:00
Robert Müller c966b5d752 Show circle icon next to editor filename when unsaved changes
Show a circle icon next to the filename in the editor menu bar when there are unsaved changes in the current map.
2023-06-22 19:34:17 +02:00
Robert Müller 2db569374d Add color_parse function to parse strings as colors
Parses RGB, RGBA, RRGGBB and RRGGBBAA hex color formats into any `color4_base`.

Reuse code from color parsing in console.
2023-06-20 23:22:33 +02:00
bors[bot] b938202ade
Merge #6742
6742: Run MysqlUninit later (fixes #6571) r=def- a=def-

Otherwise the mysql thread can still be running in the background while we uninitialize it.

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Dennis Felsing <dennis@felsin9.de>
2023-06-14 11:35:21 +00:00
Dennis Felsing 7e82bf3a53 Run MysqlUninit later (fixes #6571) 2023-06-14 13:12:48 +02:00
Dennis Felsing 35e4a2b311 Actually use AntibotFlags 2023-06-14 11:25:26 +02:00
Robert Müller 3ad581aeb8 Ensure proper buffer size is used with DDNet server filter
By passing the buffer size when calling `DDNetFilterAdd` and `DDNetFilterRem`.

Mark functions and pointer parameters as `const`.
2023-06-14 00:04:01 +02:00
Robert Müller 9a57def5a6 Add templated str_append function for arrays with fixed size 2023-06-14 00:04:01 +02:00
Jupeyy 845ba50842 Split emoticon sending into nearby and global players 2023-06-11 13:31:50 +02:00
Robert Müller 5b3f6e8ffd Use dropdown menu to select game controller
Instead of using one button to cycle through all controllers.
2023-06-09 14:04:35 +02:00
Robert Müller abfafa314a Add IGraphics::GetScreenName
To get the screen name for each screen index.
2023-06-08 12:52:34 +02:00
Dennis Felsing 07032ab0d0 Add logappend setting
To append to log file instead of overwriting it. To use you can create a
data/autoexec_client.cfg with:

logfile "client.log"
logappend 1

Enabled by default
2023-06-05 11:52:15 +02:00
Jupeyy 44039c2b39 Revert "make sure it's not modifying memory"
This reverts commit bc006dbf08.
2023-06-03 22:04:28 +02:00
Robert Müller b6cdbfbb2f Remove redundant CImageInfo variable
It's a POD object that is only zeroed and otherwise unused, so it's redundant.
2023-06-03 12:42:02 +02:00
Robert Müller f2d8bad506 Fix potential OOB write in CGraphics_Threaded::GetVideoModes
If `MaxModes` is smaller than `sizeof(g_aFakeModes)` then this caused more video modes to be copied to the output array than it can hold.
2023-06-03 12:41:44 +02:00
heinrich5991 ebacc0fb96 Change to username:password for reserved slots
This is a more common syntax.
2023-06-03 00:25:33 +02:00
Robert Müller 75227ed5ad Remove unused config variables:
- `dbg_focus`
- `gfx_tune_overlay`
- `sv_external_port`
- `dbg_pref`
- `dbg_stress_network`
- `sv_score_folder`
- `sv_rank_cheats`
2023-06-01 20:25:41 +02:00
Robert Müller cde1143528 Regenerate key lists with latest SDL version
Update `SDL_scancode.h` which is used by `gen_keys.py` to generate the list of keys enum (`keys.h`) and the list of key names (`keynames.h`) and regenerate the lists.

This adds support for 6 uncommonly used keys (audiorewind, audiofastforward, softleft, softright, call, endcall).
2023-05-30 23:39:47 +02:00
bors[bot] 8659578798
Merge #6657
6657: Allow rcon users access to reserved slots r=def- a=Learath2

<!-- What is the motivation for the changes of this pull request? -->
The password for the reserved slots keep getting leaked. Hopefully this will fix the issue.

<!-- Note that builds and other checks will be run for your change. Don't feel intimidated by failures in some of the checks. If you can't resolve them yourself, experienced devs can also resolve them before merging your pull request. -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [x] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [x] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Learath <learath2@gmail.com>
2023-05-30 10:40:20 +00:00
Robert Müller d0333f10b0 Fix flashing window not working with newer SDL versions
Minimum SDL version 2.0.16 is required for `SDL_FlashWindow`. The SDL version schema changes after version 2.0.22 to 2.24.0 etc. (minor version is used instead of patchlevel) which was causing the condition that checks for minimum version 2.0.16 to not work correctly with newer SDL versions.

Closes #6687.
2023-05-29 19:43:45 +02:00
bors[bot] 6c7f6a4494
Merge #6665
6665: Fix ordering of unfinished/unconnected tees r=heinrich5991 a=Learath2

<!-- What is the motivation for the changes of this pull request? -->
I thought there was initially a strict weak ordering issue here but upon further inspection noticed it's fine.
However, people with negative score were getting sorted undeterministically, basically every unfinished tee was treated as equal since `!comp(a, b) && !comp(b, a)`. Sorting them by name was the intention.

I also got rid of the old `INT_MIN` "hack", it was only there to make the code shorter and it's no longer possible with the newly flipped sign without flipping it back on the client which is ugly.

Also made `ScoreKind` `const`, not sure if any compiler optimizes on that but why not? If we ever move to C++20 this could be a generic lambda instead where we can template `ScoreKind` and make sure it gets optimized properly.

Tidbit: I treated score 0 as a normal score, I'm not sure what it implies. 

<!-- Note that builds and other checks will be run for your change. Don't feel intimidated by failures in some of the checks. If you can't resolve them yourself, experienced devs can also resolve them before merging your pull request. -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Learath <learath2@gmail.com>
2023-05-29 11:02:52 +00:00
bors[bot] d433a2fd1d
Merge #6677
6677: Use icons for refresh and connect buttons, refactor `DoButtonMenu` r=def- a=Robyt3

Use less space for refresh and connect buttons to improve layout with 5:4 and 4:3 resolutions. Closes #5605. Closes #5878.

The "Refreshing..." text is replaced with combined refresh and ellipsis icons.

Alpha and saturation of the green color of the connect button are increased.

Move `CMenus::DoButtonMenu` to `CUI::DoButton_Menu`. Simplify usage by adding `SMenuButtonProperties` parameter object for all optional arguments. Remove unused `ColorHot` parameter.

Screenshots:
- Before:
![screenshot_2023-05-27_19-52-37](https://github.com/ddnet/ddnet/assets/23437060/3bf27f53-b034-4147-97ee-5c24a5b68457)
- After:
![screenshot_2023-05-27_19-51-07](https://github.com/ddnet/ddnet/assets/23437060/702a9c1c-be07-4cd6-94b5-b4b0fd9b4fa1)
- After (when refreshing):
![screenshot_2023-05-27_19-56-15](https://github.com/ddnet/ddnet/assets/23437060/0a456467-6550-4ce7-b756-56e3bbbc4f43)


## Checklist

- [x] Tested the change ingame
- [x] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Robert Müller <robytemueller@gmail.com>
2023-05-27 19:53:09 +00:00
Robert Müller 36dd5c5075 Fix undefined behavior in CSnapshotDelta::DiffItem
Cast `int`s to `unsigned` before subtracting to ensure that integer wrapping is being used instead of causing undefined behavior. Same as in `UndiffItem`.

```
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/master/src/base/math.h:16:40 in
src/master/src/engine/shared/snapshot.cpp:206:21: runtime error: signed integer overflow: 256 - -2147483648 cannot be represented in type 'int'
    0 0x7650b7 in CSnapshotDelta::DiffItem(int const*, int const*, int*, int) src/master/src/engine/shared/snapshot.cpp:206:21
    1 0x765cea in CSnapshotDelta::CreateDelta(CSnapshot*, CSnapshot*, void*) src/master/src/engine/shared/snapshot.cpp:323:7
    2 0x51a0e2 in CServer::DoSnapshot() src/master/src/engine/server/server.cpp:964:36
    3 0x537486 in CServer::Run() src/master/src/engine/server/server.cpp:2818:6
    4 0x4feeb7 in main src/master/src/engine/server/main.cpp:190:21
    5 0x7fc51ec27d09 in __libc_start_main csu/../csu/libc-start.c:308:16
    6 0x4c3819 in _start (servers/DDNet-Server-ubsan+0x4c3819)

src/master/src/engine/shared/snapshot.cpp:206:21: runtime error: signed integer overflow: 1645289600 - -2139062144 cannot be represented in type 'int'
    0 0x7650b7 in CSnapshotDelta::DiffItem(int const*, int const*, int*, int) src/master/src/engine/shared/snapshot.cpp:206:21
    1 0x765cea in CSnapshotDelta::CreateDelta(CSnapshot*, CSnapshot*, void*) src/master/src/engine/shared/snapshot.cpp:323:7
    2 0x51a0e2 in CServer::DoSnapshot() src/master/src/engine/server/server.cpp:964:36
    3 0x537486 in CServer::Run() src/master/src/engine/server/server.cpp:2818:6
    4 0x4feeb7 in main src/master/src/engine/server/main.cpp:190:21
    5 0x7efd50c4ed09 in __libc_start_main csu/../csu/libc-start.c:308:16
    6 0x4c3819 in _start (servers/DDNet-Server-ubsan+0x4c3819)
```

See #6650.
2023-05-27 20:57:05 +02:00
Robert Müller 08e0a87ff1 Use icons for refresh and connect buttons, refactor DoButtonMenu
Use less space for refresh and connect buttons to improve layout with 5:4 and 4:3 resolutions. Closes #5605. Closes #5878.

The "Refreshing..." text is replaced with combined refresh and ellipsis icons.

Alpha and saturation of the green color of the connect button are increased.

Move `CMenus::DoButtonMenu` to `CUI::DoButton_Menu`. Simplify usage by adding `SMenuButtonProperties` parameter object for all optional arguments. Remove unused `ColorHot` parameter.
2023-05-27 19:48:32 +02:00
bors[bot] ba7b82258e
Merge #6673 #6676
6673: Clear Victim Team render info on skin changes r=Robyt3 a=Jupeyy

fixes #6662

This should fix the issue, I guess, by simply clearing the render info. I can't find an easy way to restore the original skins of the team members as we don't save their IDs.
I couldn't directly trigger the assert, but I could certainly see the skin getting invalid when killen the team and switch to "vanilla only skins". (Edit: When triggering it a few times I got the assert)

The code generally looks a bit hacky. Maybe the original author can refactor it a bit

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


6676: Show GPU info (if available) in assert r=Robyt3 a=Jupeyy

first part of #6672

![image](https://github.com/ddnet/ddnet/assets/6654924/0e9aec5a-528a-4e7a-a3fa-93108e55597e)



## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Jupeyy <jupjopjap@gmail.com>
2023-05-27 09:01:26 +00:00
Jupeyy 70d48140f0 Show GPU info (if available) in assert 2023-05-27 09:51:22 +02:00
Jupeyy ad40156a3b Wait for graphics thread's current execution to end before triggering the assert dialog 2023-05-27 09:34:21 +02:00
Jupeyy 52d61244cd Remove inp_mouseold config
Because it causes trouble with newer SDL2 versions
`https://github.com/libsdl-org/SDL/issues/7159`
2023-05-26 22:44:32 +02:00
Robert Müller 448a39768b Add inp_ime_native_ui to toggle native IME UI on Windows
Add `inp_ime_native_ui` on Windows to use native IME UI instead of rendering the candidate list in the client.

Always set the SDL hint to use native UI on non-Windows, as we cannot determine the list of candidates on those systems.
2023-05-26 15:39:28 +02:00
Learath a63404409b Fix ordering of unfinished/unconnected tees 2023-05-26 01:43:42 +02:00
Robert Müller 460cda85d7 Set minimum/maximum values for snd_rate
Hopefully prevent crashes that some users are experiencing when using very unreasonable `snd_rate` values.
2023-05-24 21:12:43 +02:00
Robert Müller fd0e9b18b4 Remove unused snd_device config variable 2023-05-24 21:12:43 +02:00
Learath 6f9c387e95 Add config option. Make it untidy per clang-tidy 2023-05-24 16:01:21 +02:00
Learath f1cee7475b Allow rcon users access to reserved slots 2023-05-24 15:19:09 +02:00
Edgar a4abc1fdd9
factor out scorekind backwards compat gametype check 2023-05-22 17:22:52 +02:00
Edgar 1d30462e50
clean time score handling, with positive time values 2023-05-22 16:36:46 +02:00
Edgar 8a3d8fc53f
fix time score info on server detail 2023-05-22 13:53:23 +02:00
Robert Müller ed554368ec Remove unused sv_sql_bindaddr config variable
Closes #6456.
2023-05-19 21:02:39 +02:00
bors[bot] 2d5321d8b7
Merge #6615
6615: Fix logging (fixes #6611) r=Robyt3 a=def-

`@heinrich5991` Was the atomic important? Could we have a lock instead if so?

Seems a bit annoying since atomic can't have a shared_ptr inside

![Screenshot 2023-05-18 at 18 02 32](https://github.com/ddnet/ddnet/assets/2335377/2f8bcc57-2301-4a65-ada2-0e51f2b8c200)

## Checklist

- [x] Tested the change ingame
- [x] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Dennis Felsing <dennis@felsin9.de>
2023-05-18 20:43:30 +00:00
Dennis Felsing bf1954b389 Fix logging (fixes #6611)
@heinrich5991 Was the atomic important? Could we have a lock instead if so?

Seems a bit annoying since atomic can't have a shared_ptr inside
2023-05-18 21:54:30 +02:00
Robert Müller 15f839960a Port friends list UI from 0.7
Separate friends list into three groups, which can be expanded and collapsed: online players, online clanmates and offline friends.

Friends with the same name/clan are no longer grouped together. Instead, each individual player that is online and has name/clan matching a friend is shown in either the online players or online clanmates group. Friends for which no matching players are found are shown in the offline group.

Friends in the friend list can no longer be selected. Instead, left-clicking a friend selects the server that the friend is on. Double-clicking a friend joins the server that they are playing on.

Render small X button in top-right corner of every friend list entry to remove the respective friend instead of using one button that removes the selected friend.

Change "Add Friend" button to "Add Clan" when only clan is entered.

Remove excess empty space from layout.

Closes #6326.
2023-05-18 16:46:26 +02:00
bors[bot] 6525e9e5dd
Merge #6604
6604: Clean up CServerLogger (fixes #6598) r=edg-l a=def-

<!-- What is the motivation for the changes of this pull request? -->

<!-- Note that builds and other checks will be run for your change. Don't feel intimidated by failures in some of the checks. If you can't resolve them yourself, experienced devs can also resolve them before merging your pull request. -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Dennis Felsing <dennis@felsin9.de>
2023-05-18 11:46:59 +00:00
Dennis Felsing caa76249d8 Clean up CServerLogger (fixes #6598) 2023-05-17 01:04:06 +02:00
bors[bot] 2901c19bed
Merge #6602
6602: Revert "Delay disconnecting until after render call" r=def- a=Robyt3

This reverts commit 5c90fd2b83.

Delaying the disconnecting causes issues when the client automatically disconnects immediately before connecting to another server or starting demo playback.

It's not necessary to delay the disconnecting to deal with #6387, as #6589 is already enough. It's easier to revert this instead of rewriting the client so connecting and starting demo playback are also delayed.

Closes #6595.

## Checklist

- [X] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Robert Müller <robytemueller@gmail.com>
2023-05-16 22:43:29 +00:00
Robert Müller 5ecd025d1d Revert "Delay disconnecting until after render call"
This reverts commit 5c90fd2b83.

Delaying the disconnecting causes issues when the client automatically disconnects immediately before connecting to another server or starting demo playback.

It's not necessary to delay the disconnecting to deal with #6387, as #6589 is already enough. It's easier to revert this instead of rewriting the client so connecting and starting demo playback are also delayed.

Closes #6595.
2023-05-16 19:34:21 +02:00
ChillerDragon c5eb15d9f6 Compare against correct enum in dummy connect 2023-05-16 16:38:55 +02:00
Robert Müller 2f2c86ced3 Move variable declarations closer to usages 2023-05-15 20:56:17 +02:00
Robert Müller cbde0bb7c6 Use nullptr instead of 0 2023-05-15 20:48:02 +02:00
Robert Müller cd9d0e5e16 Add default parameter values to CMap::GetItem 2023-05-15 20:48:01 +02:00
Robert Müller 7273574d68 Add missing CMap::NumData delegate function 2023-05-15 20:47:59 +02:00
Robert Müller 5e215f6ee3 Mark map and datafile functions as const when possible 2023-05-15 20:47:38 +02:00
Robert Müller 6b37c3dbf4 Reorder map and datafile functions 2023-05-15 20:46:50 +02:00
Robert Müller 52e1494347 Remove unused CDataFileReader::Unload function declaration 2023-05-15 20:28:39 +02:00
bors[bot] a38dea4454
Merge #6590
6590: Make text containers bit safer r=Robyt3 a=Jupeyy

From reading the code I couldn't understand how https://github.com/ddnet/ddnet/issues/5143#issuecomment-1546735484 could happen

either (checked = not the case):
 - [x] teini used an outdated client
 - [ ] i am blind
 - [ ] it was a name/clan -plate, scoreboard entry
 - [ ] it leaked somewhere in text.cpp or similar impl
 - [ ] it happened because of an outside write.

We don't really come further with this, so we should probably at least try it out?
`@Robyt3` your opinion? We can still always remove it again

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Jupeyy <jupjopjap@gmail.com>
2023-05-14 19:16:16 +00:00