Commit graph

2527 commits

Author SHA1 Message Date
Alexander Akulich 29688fb499 Remove cl_video_pause_on_start; reset the pause option on popup opened 2023-08-19 13:51:38 +03: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
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
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
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
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
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
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
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
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
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
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 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
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