Commit graph

15653 commits

Author SHA1 Message Date
SollyBunny ae04851a9a Echo colors persist + Better pFrom for chat 2024-11-12 23:32:45 +00:00
ChillerDragon 32cb056549 Make the client able to have tee's without weapons
Closed #8758
2024-11-11 16:58:36 +08:00
Zwelf 1b6e5a9295 Fix incomplete Teehistorian chunks being written
Save/Load code are up to 65536 bytes long. However, Packer only has a
buffer of 2048 bytes. Writing SAVE_SUCCESS and LOAD_SUCCESS chunks
likely for saves with 3 or more tees.

This increases the buffer size for all packing including networking
packets and is therefore probably not the optimal solution. An
alternative would be to create an additional packer CLargePacker or make
the size a template argument.

The suggested change is the simplest fix adding not much complexity, but
increases the chance of overrunning the stack size. I'm open to take
another approach.
2024-11-09 22:27:53 +01:00
Robert Müller 7ebaf1b9ad Use quad container for race flag in finish infomessages
Avoid uploading quad for race flag in finish infomessages every frame by adding it to the existing quad container.
2024-11-09 10:56:09 +01:00
Dennis Felsing b710f32a06
Merge pull request #9220 from KebsCS/pr-rcon-auth-dummy
Auto rcon auth both main and dummy
2024-11-08 22:27:22 +00:00
Dennis Felsing 6a0b0fc04b
Merge pull request #9200 from SollyBunny/cl_hook_coll_size_other
Add cl_hook_coll_size_other & +hookcoll button in UI
2024-11-08 22:26:55 +00:00
KebsCS 1801dbd491
Auto rcon auth both main and dummy 2024-11-08 21:29:19 +01:00
Zwelf 022f101c4b
Merge pull request #9006 from Robyt3/Editor-File-Dialog-Fixes
Fix editor `Save As` confirmation, prevent opening empty filename
2024-11-08 18:49:15 +00:00
Zwelf 73357a45dc
Merge pull request #9020 from ChillerDragon/pr_dbg_sql
Add ``dbg_sql`` config to hide non error sql logs
2024-11-07 22:28:49 +00:00
Robert Müller 1ceb7d0212 Fix incorrect rendering of menu and entities background maps
Load the map images for the menu and entities background maps before the respective map layers. Otherwise, the total number of images is `0` when loading the layers, which causes the images of tiles and quads layers to be considered invalid during the initialization, which results in the wrong tile/quad memory layout being used.

Regression from #9213.
2024-11-07 21:03:45 +01:00
Dennis Felsing 50d8dfeb6a
Merge pull request #9214 from KebsCS/pr-fix-tuning
Fix invalid prediction tuning in tune zone 0
2024-11-07 06:41:50 +00:00
KebsCS eb3b850ba9
Fix invalid prediction tuning in tune zone 0 2024-11-07 00:39:10 +01:00
Robert Müller 8f37729f5b Improve map image validation
- Add check for map image data being loaded from map to avoid null pointer access.
- Add check for size of map image data to avoid out-of-bounds reads.
- Add check for map layer item not being found to avoid null pointer access.
- Fix inconsistent handling of layers with invalid images. In some cases only `-1` was considered non-textured whereas all invalid values should be.
- Ensure correct texture is always used for game layers instead of considering the image property of game layers which cannot be set via the map editor.
- Skip loading images which are not used by any quads or tiles layers.
- Replace member variable `m_aTextureUsedByTileOrQuadLayerFlag` with local variable.
- Mark pointers as `const` when possible.
- Avoid C-style casts.
2024-11-06 22:49:09 +01:00
Dennis Felsing fb7d8ab912
Merge pull request #9210 from Robyt3/Client-Mapsounds-Validation
Improve map sound validation and performance
2024-11-06 07:26:24 +00:00
Rei-Tw 82b274cc0e Implement bans_find command.
This rcon command simplifies searching for all ban records for a specific IP if the ban list has too many records.
2024-11-06 01:19:23 +01:00
SollyBunny 96b3b70a7d Add cl_hook_coll_size_other & +hookcoll button in UI 2024-11-05 22:33:11 +00:00
Robert Müller 06fcfe03b0 Improve map sound validation and performance
- Add check for map sound data being loaded from map to avoid null pointer access.
- Add check for size of sound source data to avoid out-of-bounds reads.
- Avoid iterating over all groups and layers and then performing a linear search on the sound queue entries every frame to update the sounds. Instead, store a pointer to the respective `CMapItemGroup` for every queue entry, so iterating over the queue once is enough to update all sound queue entries.
- Move check for sound layer index outside of loop as the value does not change.
- Avoid creating source queue entries for sounds that could not be loaded.
- Mark pointers as `const` when possible.
2024-11-05 22:18:48 +01:00
Robert Müller f0c9faf654 Refactor CSkins7 accessor functions and 0.7 skin json parsing
- Combine `CSkins7::FindSkinPart` and `CSkins7::GetSkinPart` functions into `CSkins7::FindSkinPart` function to simplify the usage.
- Replace `CSkins7::Num` and `CSkins7::Get` functions with `CSkins7::GetSkins` function to return all skins to improve readability using for-each loops.
- Replace `CSkins7::NumSkinPart` and `CSkins7::GetSkinPart` functions with `CSkins7::GetSkinParts` function to return all skin parts to improve readability using for-each loops.
- Add `CSkins7::FindSkinPartOrNullptr` function to find a skin by name or return `nullptr` if it's not found. Let the `CSkins7::FindSkinPart` function return the desired part, then the default part, and lastly the placeholder part.
- Add `CSkins7::FindDefaultSkinPart` function to find the default skin part or placeholder skin part (never `nullptr`).
- Remove redundant check for duplicate skin parts. This is already prevented by the `IStorage::ListDirectory` function.
- Remove separate placeholder skin that was being used to initialized every loaded and created skin.
- Remove unused `CSkins7::GetInitAmount` function.
- Add `CSkins7::InitPlaceholderSkinParts` function to initialize the placeholder skin parts. Keep placeholder skin parts separate from normal skin parts, i.e. not in the vectors of parts.
- Rename `CSkins7::AddSkin` function to `AddSkinFromConfigVariables` for clarity about its behavior.
- Fix `CSkins7::RandomizeSkin` function not terminating if there exist only special skin parts for any part type.
- Add `CSkins7::XmasHatTexture` and `CSkins7::BotDecorationTexture` getter functions instead of exposing the respective member variables.
- Improve validation when parsing 0.7 skin json format. Fail loading and log error messages on invalid skin json files instead of silently loading incorrect/incomplete skins.
2024-11-04 23:03:35 +01:00
ChillerDragon 3ea862c850 Send password on reconnect
Closed #9201
2024-11-04 08:08:02 +08:00
Robert Müller fe78331e80 More efficient glyph uploading, fix crash with very large glyphs
Avoid using the `m_aaGlyphData` temporary buffer for uploading glyphs. Instead, allocate the required memory for the glyphs directly and allow the graphics backend to take ownership of the buffer when updating text textures. This avoids copying the glyph data into the temporary buffer when uploading individual glyphs.

This also avoids crashes when rendering very large glyphs with large font sizes, due to the buffer `m_aaGlyphData` having a fixed size of `64 * 1024` while the maximum glyph size is not checked. This fixed size could be exceeded with glyphs larger than 256² in rendered dimensions. There should currently be no glyph in our fonts which is that large and also no font size so large that this could happen.
2024-11-03 14:30:38 +01:00
Robert Müller a7a5c0ea7a Add checks for unsupported glyph pixel mode
Skip rendering glyphs which don't use the 1-byte grayscale pixel mode.
2024-11-03 14:30:29 +01:00
Robert Müller f5179df6d0 Avoid unnecessary copy of glyph data for entities text
Copy the glyph data directly from the font bitmap buffer to the target image instead of using `m_aaGlyphData` as a temporary buffer.
2024-11-03 14:30:15 +01:00
Robert Müller eecaf4cdfc Remove redundant BmpWidth/BmpHeight variables
They are identical to the `Width`/`Height` variables which specify the size of the glyph in the atlas texture.
2024-11-03 14:30:06 +01:00
Robert Müller 2a39a1a318 Fix player info being resent too fast/slow depending on FPS
The change info message was being resent too fast/slow because `m_aCheckInfo` was decremented every frame whereas it was intended to be decremented every tick. As `m_aCheckInfo` is set to `Client()->GameTickSpeed()` after sending the info, it's likely that this was intended as one second delay. With debug messages is can be confirmed that the change info message was previously resent more than 10 times per second with high FPS on a local server.

Also fix the info resending delay not being reset when reconnecting a dummy on 0.7 servers.
2024-11-02 11:00:48 +01:00
Dennis Felsing 812da8e13b
Merge pull request #9195 from KebsCS/pr-q-spec
Change default Q bind to /spec
2024-11-02 06:28:01 +00:00
KebsCS b086b2185d
Change default Q bind to /spec 2024-11-02 00:16:03 +01:00
Robert Müller d58e043180 Fix alignment of dropdown popup menu with some button widths
Pass the popup menu positions and sizes as `float`s instead of truncating them to `int`s.
2024-11-01 18:04:30 +01:00
Robert Müller e965ccdcac Fix upper bound of hook collision line width scrollbar
The maximum value of the config variable is only `20`. Regression from #9138.
2024-11-01 11:00:11 +01:00
Dennis Felsing 19aa7fbb77 Version 18.8 2024-11-01 09:11:04 +01:00
Dennis Felsing 6bcf8ead49 Fix clang-tidy 2024-11-01 08:32:26 +01:00
Robert Müller 96eb49ad3f Improve error handling on invalid fonts and font index
Log more detailed error messages when fonts could not be loaded and when the font index is malformed. Show warning popup on client launch if any font failed to load, although this warning won't be readable if all fonts failed to be loaded.
2024-11-01 00:16:14 +01:00
KebsCS 6dc11bbb89
Fix chat command preview overlap 2024-10-31 21:33:52 +01:00
Dennis Felsing 215c683692
Merge pull request #9182 from Robyt3/Client-clear_chat-Command
Add `clear_chat` command
2024-10-30 22:30:58 +00:00
Robert Müller c978ecec39 Add clear_chat command
Add a command to clear all lines of chat messages, same as the `clear_local_console`/`clear_remote_console` commands for the consoles. This is useful for example when taking screenshots or recording videos with initially empty chat.
2024-10-30 23:06:25 +01:00
Dennis Felsing df3eeffa3d
Merge pull request #9180 from KebsCS/pr-fix-tele-brush
Fix editor tele layer brush number
2024-10-30 08:13:21 +00:00
KebsCS 768384a8da
Fix editor tele layer brush number 2024-10-30 01:12:45 +01:00
Robert Müller 9b4a80d8b7 Improve ghost file validation
Fix out-of-bounds reads in ghost loader when current chunk does not contain enough data for expected number of items.

Improve validation of ghost header information. Ensure strings (owner and map name) are null-terminated and valid UTF-8 to avoid crashes. Avoid duplicate code for validating header.

Remove `static` buffers for compression and decompression of ghost data, which would prevent parallelizing ghost recording and loading. Switch between the main buffer and only one temporary buffer instead of using two temporary buffers.

Automatically delete the ghost file when the recording is stopped with the number of ticks or time being invalid, i.e. when ghost recording will be restarted. This should ensure that invalid ghost files are not left behind if recording is not immediately restarted after being stopped, e.g. due to edge cases like standing inside a start-tile.

Use `int32_t` for `DiffItem` and `UndiffItem` data pointers as these functions are expected to operate on 32-bit integers. Ensure chunk and item data is aligned with `int32_t` to avoid potential unaligned accesses. Use `size_t` for size arguments.

Add assertions to ghost loader and recorder functions to ensure their correct usage. Ensure a file is not already open when opening another one and ensure that a file is open when reading/writing. Ensure that the ghost data type is valid, i.e. between `0` and `0xFF` because it is packed into an `unsigned char`. Ensure data size is valid and aligned with `int32_t`, otherwise data would be packed incorrectly by the `DiffItem` function. Improve error messages, consistent with the error messages of the demo player and recorder. Use the `log_*` functions for logging. Use the same color for all ghost-related log messages.

Avoid `system.h` include in `ghost.h` by moving `CGhostHeader` function definitions to `ghost.cpp`.

Closes #7413.
2024-10-29 21:19:07 +01:00
Robert Müller 402c6aa985 Fix editor Save As confirmation, prevent opening empty filename
The confirmation popup was not shown for the Save As dialog anymore, due to the label being changed to `Save As` for the respective quick action. This check based on string comparison is rather brittle and can be replaced with comparison of the storage type with `IStorage::TYPE_SAVE`.

When the file dialog is used to open files, prevent opening files with an empty filename if enter is pressed while no file is selected (i.e. when the filter excludes all entries).
2024-10-27 15:40:00 +01:00
Robert Müller 2cd8721cde Use std::vector for console execution queue
Simplify the code by replacing the usage of a linked list and heap with an `std::vector`.

The assignment operators are replaced with copy constructors to use `std::vector`.
2024-10-27 11:02:43 +01:00
Robert Müller 3ec2564acc Fix console result client ID sometimes being uninitialized
Add the client ID as a constructor argument to `CResult` to ensure that it is initialized.
2024-10-27 11:02:43 +01:00
ChillerDragon 386d456484 Fix vanilla demo tuning 2024-10-27 10:06:47 +08:00
Dennis Felsing cb508bdbe1
Merge pull request #9171 from heinrich5991/pr_ddnet_mastersrv_ddper
mastersrv: Add DDPer support
2024-10-26 18:22:43 +00:00
heinrich5991 9067dc5a2a
Merge pull request #9164 from Robyt3/Base-Log-Color-Macros
Add `log_*_color` macros, deprecate `IConsole::Print`
2024-10-26 15:43:35 +00:00
heinrich5991 ff87fac384 mastersrv: Add DDPer support
This allows DDPer to continue using our mastersrv while not showing up
in the DDNet client.
2024-10-26 17:19:45 +02:00
Robert Müller 14facd5a4f Ensure file is moved when fs_rename function returns on Windows
Use the flag `MOVEFILE_WRITE_THROUGH` with the `MoveFileExW` function on Windows to ensure that the file is renamed/moved on the disk before the function returns. Otherwise, if the function returns before the file is moved, subsequent loading of the file with this name may fail sporadically.

See https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexw
2024-10-26 10:20:33 +02:00
Robert Müller 565e79fa04 Remove redundant check of key for text input events
Input events with `IInput::FLAG_TEXT` never have a key, so this additional check for modifier keys is redundant.
2024-10-25 22:05:00 +02:00
Robert Müller a93cba1a4f Use CLayer::IsEntitiesLayer function to avoid duplicate code 2024-10-24 22:42:39 +02:00
Robert Müller e2df30a59e Add log_*_color macros, deprecate IConsole::Print
Add `log_error_color`, `log_warn_color`, `log_info_color`, `log_debug_color` and `log_trace_color` macros to wrap `log_log_color` function with specific log levels.

Add comment to mark the `IConsole::Print` function as deprecated in favor of the `log_*` functions, which should be preferred for the following reasons:

- They support `printf`-formatting without a separate buffer.
- They support all five log levels.
- They do not require a pointer to `IConsole` to be used.
- Consistency of logging code.
2024-10-23 17:52:54 +02:00
Emir Marincic 5a716ae463
Merge pull request #9163 from Robyt3/Console-Format-Removal
Remove obsolete `IConsole::Format` function, fix `show_ips` output
2024-10-21 22:21:16 +00:00
Robert Müller 66c5609ae4 Remove obsolete IConsole::Format function, fix show_ips output
The `IConsole::Format` function was previously used to format the log and rcon output, but it has become obsolete when the logging was refactored.

The function was still being used to format the output of the `show_ips` command in the rcon, which was causing this particular rcon line to have the old log format (e.g. `[12:34:56][server]: Value: 0`). Now, `IConsole::Print` is used directly, as this causes the output to be sent with the correct format and only to the rcon command user.

The `IConsole::FPrintCallback` function pointer typedef is also obsolete and unused.
2024-10-21 23:35:30 +02:00