Commit graph

13366 commits

Author SHA1 Message Date
Dennis Felsing ae12d8d9f6
Merge pull request #7045 from Robyt3/Loglevel-Variable-Fixes
Save console output variables again, improve descriptions
2023-08-19 11:20:24 +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 db1452d0a8
Merge pull request #6988 from Marmare314/envelope-scale
implement scaling for envelope editor
2023-08-19 09:49:17 +00:00
Robert Müller 6ba328dfdb
Merge pull request #7009 from Possseidon/dev/multi-view-team
Allow automatic multi-view for players in a team
2023-08-19 09:01:10 +00: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
marmare314 23e2d9377d implement scaling for envelope editor 2023-08-16 15:06:41 +02:00
marmare314 fded5013eb Do not activate box selection when panning (fixes #7031 and #7030)
And do not pan while any other operation is in progress.
2023-08-16 12:17:06 +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
Alexander Akulich 6555799e85 Cleanup declarations 2023-08-15 19:02:17 +03: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
Edgar 21d358434f
Merge pull request #7014 from Marmare314/mapview
Add CEditorComponent to moduralize editor
2023-08-14 08:44:31 +00:00
marmare314 77e36c5062 change interface and fix scalelength 2023-08-14 10:12:06 +02:00
marmare314 a46f320d24 remove unnecessary include 2023-08-14 09:03:03 +02:00
marmare314 7925f9fd45 format 2023-08-14 08:59:01 +02:00
marmare314 72b0fbfada format 2023-08-14 08:53:59 +02:00
marmare314 2bcfbae841 Add CEditorComponent to moduralize editor
Refactor CSmoothZoom and introduce CMapView
2023-08-14 08:36:02 +02:00
Possseidon 07e9c5a684 Allow automatic multi-view for players in a team 2023-08-13 15:38:36 +02:00
Dennis Felsing 255092ff92
Merge pull request #7003 from Robyt3/Scoreworker-Query-Size-Fix
Increase another SQL query buffer size
2023-08-12 21:24:07 +00:00
Dennis Felsing 84c6cf2333
Merge pull request #7004 from Vy0x2/pr-poc-mv-clean
Fix smooth zoom with zero causing problems with multiview
2023-08-12 21:20:06 +00:00
Robert Müller defd8f7c96 Increase another SQL query buffer size
The `INSERT INTO` query could be truncated when using a longer table name prefix.
2023-08-12 19:42:05 +02:00
Samuele Radici 5e1ef437d8
Update connection_pool.cpp 2023-08-12 18:40:33 +02:00
devdenn 9db53bd7a0 Fix smooth zoom with zero causing problems with multiview 2023-08-12 18:07:47 +02:00
Dennis Felsing 26f08a1903 Version 17.2 2023-08-12 16:43:37 +02:00
Robert Müller 0196470e01 Fix SQL query buffer sizes being too small
In `LoadPlayerData` exactly the `LIMIT 1` clause was getting truncated from the query due to the buffer size being insufficient. Depending on the length of the table name prefix the query could have been truncated at any other position resulting in syntax errors.

In `ShowTeamTop5` the buffer size is increased because it could cause truncation with a longer than default table name prefix.
2023-08-11 17:20:45 +02:00
Robert Müller 29871fd5f6 Fix scoreboard time being reset when using /timecp
Using `/timecp` with a player name that has no time on the current map incorrectly cleared the player score/time causing it to not be shown in the scoreboard anymore.
2023-08-11 16:41:42 +02:00
Edgar 984eb47c87
Merge pull request #6995 from Vy0x2/pr-poc-mv-clean
Increase lower limit for zoom smoothness (multiview), fixes #6981
2023-08-11 11:48:37 +00:00
Dennis Felsing 8eab94bcac
Merge pull request #6992 from Marmare314/selection-order-bug
Switch order in which envelope points are selected
2023-08-10 20:22:53 +00:00
Dennis Felsing 7f636329b2
Merge pull request #6993 from Marmare314/hidden-channel-bug
Ignore hidden channels when selecting envelopes
2023-08-10 20:22:07 +00:00
devdenn 9eb73c9990 Increase lower limit for zoom smoothness (multiview), remove rarely used variable 2023-08-10 20:09:43 +02:00
marmare314 93332af243 Disallow adding overlapping envelope points
Also now round is used to convert the mouse position to fixed
precision time which places the added point closer to the mouse position.
2023-08-10 08:38:10 +02:00
marmare314 3d400b13b5 Ignore hidden channels when selecting envelopes
When two envelope points overlap it can happen that the hidden
one will be marked as hot. Then neither can be selected.
2023-08-10 08:27:17 +02:00
marmare314 e1931d216a Switch order in which envelope points are selected
When multiple envelope points could be selected, switch the order
such that the one that is visible is selected first.
2023-08-10 08:16:15 +02:00
Dennis Felsing 2ea102ac9f
Merge pull request #6984 from Robyt3/Settings-Controls-Localizable
Use `Localizable` instead of `Localize` inside comment
2023-08-08 21:18:13 +00:00
Robert Müller bfb64a47e6 Improve dbg_tuning, refactor CDebugHud::RenderTuning
Use different colors to highlight tuning parameters when using `dbg_tuning`:
- red: value changed globally
- blue: value changed only in current zone
- green: value changed globally but reset to default by tune zone
- grey: value unchanged globally and in current zone

In addition to this, with `dbg_tuning 1` the unchanged parameters and the velramp graphs are not shown anymore. With `dbg_tuning 2` all parameters and graphs are shown as it was previously the case with `dbg_tuning 1`.

The position of the debug information is adjusted so it overlaps less with the HUD. When many tuning parameters are shown, the parameters now wrap to another column instead of extending beyond the height of the screen.

Headers are also added to each column.
2023-08-08 21:16:17 +02:00
Robert Müller 738187d94e Refactor CDebugHud::RenderNetCorrections, improve layout
Also show current tune zone.

Show value on every line instead of having some lines without a value.

Improve labels.

Reduce duplicate code and improve readability.
2023-08-08 20:31:48 +02:00
Robert Müller 51e1f9d88f Refactor CDebugHud::RenderHint
Replace magic numbers with constants.
2023-08-08 20:31:48 +02:00
Robert Müller 30d3d4f94c Rename GetTunes to GetTuning and return const pointer
No need to copy all tuning parameters. Consistent naming with prediction code where `GetTuning` is also used.
2023-08-08 20:31:48 +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 262196bd2c Use Localizable instead of Localize inside comment 2023-08-08 20:26:56 +02:00
Edgar 43d3d6a876
avoid nullptr checks by initializing the pointers 2023-08-08 16:47:49 +02:00
Edgar 8d4f468edd
fix too long console commands not rendering help 2023-08-08 16:42:24 +02:00
Edgar 8d930dc8c7
Merge pull request #6980 from Robyt3/TextRender-Face-Uninitialized
Fix textrender variables being uninitialized
2023-08-07 19:09:33 +00:00
Robert Müller 0e161cf4d9 Fix textrender variables being uninitialized
Regression from #6952.
2023-08-07 17:53:54 +02:00
Edgar 50938a8a58
don't send empty chat messages 2023-08-07 17:07:12 +02:00
Zwelf 18dff9ef46 Fix /load from backup database
Saves were deleted without the team getting its state when /load and
/save both happened during mysql server not reachable.

Before this fix, the saves were only in the DDNet log output for
recovery, not in any database anymore.

`Write::BACKUP_FIRST` is 0 so always false, so the previous code
didn't harm other code paths (especially `Write::NORMAL`).
The saves were tried to retrieve two times from the database, therefore
at the second time it didn't exist anymore. One time erroneously in
`Write::BACKUP_FIRST` and the second time in `Write::NORMAL_FAILED`.

Fixes #6924
2023-08-07 15:35:39 +02:00
Robert Müller c4dcdad5cc Fix crash when using goto_tele in map without tele layer
The check for `goto_switch` is added for completeness but not strictly necessary, as this is also checked in `GetSwitchNumber`.
2023-08-06 23:41:15 +02:00
Dennis Felsing 42e16747a5
Merge pull request #6972 from Robyt3/Client-Vote-Option-Crash-Fix
Fix client crash with more than `MAX_VOTE_OPTIONS` vote options
2023-08-06 16:36:17 +00:00
Robert Müller 2ea82730ae Fix client crash with more than MAX_VOTE_OPTIONS vote options
The server does not allow adding more than `MAX_VOTE_OPTIONS` vote options, so the client will now also refuse to add more options than that.

Supersedes #6930.
2023-08-06 17:07:06 +02:00
ChillerDragon c5a4447fde Fix redirect release version
See #6969 (hihi)
2023-08-06 16:01:27 +02:00
Dennis Felsing 648d975571
Merge pull request #6937 from Robyt3/Base-Windows-File-HANDLE
Rework base IO functions on Windows using `HANDLE`
2023-08-06 12:11:13 +00: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
Robert Müller 92dc3d4a0f Fix emotes sometimes being shown for others tees
The `Translate` function modifies the first argument, so the client ID keeps changing when the function is being used in a loop. Additionally, calling `Translate` manually is not necessary for messages, as client IDs in messages are already automatically translated when using `SendPackMsg`. Both faults can cause emoticons to appear on the wrong players when the emote spamprotection limits emotes to nearby players.
2023-08-05 15:54:04 +02: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
Robert Müller 43739ea9aa When quitting/restarting client clear screen and render message
When quitting or restarting the client, clear the screen and render a message "Quitting. Please wait…" or "Restarting. Please wait…" respectively.

Previously the last frame would keep getting shown while the client is busy with cleanup tasks. Rendering a final message before the client window stops being updated provides a cleaner user experience.
2023-08-03 17:24:09 +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
Edgar b909cfadd8
Merge pull request #6943 from Robyt3/Editor-shared_ptr-Refactoring
Use `std::shared_ptr` for editor resources, fix crashes with brush
2023-08-01 09:13:59 +00: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
devdenn 4ea46f2df9 Fix malformed lines in some translation files 2023-07-29 19:13:24 +02:00
Robert Müller 88bb44ac93
Merge pull request #6944 from Marmare314/boxselect-envelopes
add box selection to envelope editor
2023-07-29 13:47:38 +00:00
marmare314 93e95bbd38 add box selection to envelope editor 2023-07-29 15:10:14 +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
Robert Müller 6f03aabb34 Use std::shared_ptr for editor resources, fix crashes with brush
Simplify memory management of groups, layers, images, sounds and envelopes by using `std::shared_ptr` for all of them.

Clear brush when creating a new map to prevent crash due to unloaded textures being used in tile layer. Closes #6935.

Also fix crash when restoring a saved brush after removing an image that is being used by it.
2023-07-28 21:17:19 +02:00
marmare314 862c0ca2fc make point hitbox bigger 2023-07-28 17:47:28 +02:00
Robert Müller 5b10547aec
Merge pull request #6916 from Vy0x2/pr-poc-mv-clean
Minor improvements to Multi-View
2023-07-28 15:00:42 +00:00
Robert Müller ef5ffedee6 Rework base IO functions on Windows using HANDLE
Switch to using the Windows-specific `HANDLE` and Windows API functions instead of `FILE *` and standard library functions in all Windows IO function implementations.

Using `CreateFileW` instead of `_wfsopen` to open files is necessary, as only `CreateFileW` allows specifying all necessary sharing flags. The sharing flags `FILE_SHARE_READ` and `FILE_SHARE_WRITE` were previously already specified by using `_SH_DENYNO` with `_wfsopen`, but `FILE_SHARE_DELETE` can only be set when using `CreateFileW`. The flags are necessary so files which are in use by the game can still be opened by other processes. In particular, `FILE_SHARE_DELETE` allows deleting/renaming of open files, which was previously not possible. This was causing the smart editor saving process that renames files to fail if a map file is currently in use.

Because `CreateFileW` returns a `HANDLE` instead of a `FILE *` we have to use the `HANDLE`-based Windows IO functions everywhere.

See: https://devblogs.microsoft.com/oldnewthing/20211022-00/?p=105822

Closes #6922.
2023-07-28 16:55:47 +02:00
Robert Müller 88cf4c4ccb
Merge pull request #6923 from Marmare314/envelope_grid
Add grid to envelope editor
2023-07-28 14:42:53 +00:00
devdenn 1c231a0dbd Minor improvements to Multi-View
Dont save the Multi-View variables
Multi-View can not longer be activated again after already active
Fix cl_multiview_use_freeview variable config
Players who killed will be removed from Multi-View even if the spec mode is not active
Multi-View personal zoom will be reseted when enabling Multi-View
Fix bug where a kill in a team will be taken into account
Improve the solo player experience in Multi-View
2023-07-28 16:34:35 +02:00
marmare314 babdbc4b17 add grid to envelope editor 2023-07-28 16:18:56 +02: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 03fd1b440b
Merge pull request #5398 from AssassinTee/feature/elasticity-tuning
implement tuning values for elasticity
2023-07-28 13:58:42 +00:00
Marvin Winkens e1ba77d3dc implement tuning values for elasticity
implement tuning values for elasticity

add grounded check to movebox and give jump back when bouncing

fix styling issues

fix jumps being given back at ceilings
2023-07-28 15:35:45 +02:00
Robert Müller b33c9ca977
Merge pull request #6934 from Marmare314/zoom-reset-big-values
handle big value ranges on envelope zoom reset
2023-07-28 13:25:46 +00:00
Robert Müller c2379591e0
Merge pull request #6941 from Marmare314/zoom-adaption
improve offset adaption for envelope zoom
2023-07-28 12:16:56 +00: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
Robert Müller 8b209f036e
Merge pull request #6872 from Marmare314/envelope_contextmenu
Multiple selection in envelope editor
2023-07-28 11:11:02 +00:00
marmare314 f3353e8062 improve offset adaption for envelope zoom
The offset adaption was not correct. Close to the origin it was not really noticeable,
but further away the points shifted offscreen when zooming.
2023-07-28 12:50:12 +02:00
marmare314 62ee646283 allow multiple selection in envelope editor 2023-07-28 12:41:25 +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
Robert Müller fd13ae5fd5
Merge pull request #6928 from sjrc6/pr-fix-gamesettings-crash
Fix client crash in ResetServerGameSettings
2023-07-27 18:45:41 +00:00
Tater 6bb2696c8b Fix crash in ResetServerGameSettings 2023-07-27 13:26:11 -05:00
marmare314 d964a3d327 handle big value ranges on envelope zoom reset 2023-07-27 19:47:06 +02:00
marmare314 873a8543df calculate zoom factor correctly for target zoom 2023-07-27 18:36:58 +02: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