Commit graph

15059 commits

Author SHA1 Message Date
Robert Müller 325e22d2de Fix crashes with dbg_dummies and sv_max_clients
Use the real number of maximum clients returned by the `MaxClients()` function instead of the `MAX_CLIENTS` constant to calculate the debug dummy client IDs to fix a crash when `sv_max_clients` is below `MAX_CLIENTS`.

Ensure the `dbg_dummies` value does not exceed the maximum number of clients.
2024-07-15 14:36:50 +02:00
Dennis Felsing b0f0292fc9
Merge pull request #8588 from Robyt3/Snapshot-Usage-Cleanup
Simplify usage of `IClient::SnapGetItem` function, remove unnecessary `IClient::SnapGetItem` function
2024-07-14 12:49:07 +00:00
Learath ebd266c419 Reset and regenerate m_aPeerAddrStr appropriately
Hopefully fixes #8587
2024-07-14 14:11:19 +02:00
Robert Müller 2f6c3abc90 Remove unnecessary IClient::SnapItemSize function
The item data size is already returned by the `IClient::SnapGetItem` function and getting only the size is not currently useful, so the additional `IClient::SnapItemSize` function is unnecessary.
2024-07-14 13:18:30 +02:00
Robert Müller e9646ba157 Simplify usage of IClient::SnapGetItem function
Let the `IClient::SnapGetItem` function return an `IClient::CSnapItem` directly instead of passing it as a pointer. Add the item data pointer as a member variable to `IClient::CSnapItem` instead of returning it separately. Therefore, the separate data pointer of the class `CSnapEntities` is also not necessary anymore.

Consistently mark the snapshot items and data as `const`. The C-style cast to `void *` in the `IClient::SnapGetItem` function was previously implicitly casting away the `const` of the snapshot pointers.
2024-07-14 13:15:44 +02:00
Robert Müller a31d6a571a Cleanup snapshot member variables in demo_extract_chat tool
Using `CSnapshotStorage::CHolder`s in the `demo_extract_chat` tool is not necessary, as only the member variable `m_pAltSnap` is being used in this tool. The regular snapshot data was copied into `m_pSnap` but never read. The other member variables were initialized but never read.
2024-07-13 22:51:31 +02:00
Robert Müller e277131cf8 Fix incorrect scoreboard size if blue team used without teams flag
When `GAMEFLAG_TEAMS` is not set, only the players of the red team are rendered in the scoreboard, but the size of the scoreboard was incorrectly calculated based on the size of the larger team (red or blue), which should only be done when `GAMEFLAG_TEAMS` is set.
2024-07-12 21:44:16 +02:00
Robert Müller 7cbfe1623d Avoid duplicate distance calculation
Add variable `NewVelLength` to avoid calculating `length(NewVel)` twice.
2024-07-11 18:02:51 +02:00
Robert Müller 660c1de8f2 Remove unnecessary use of this
The same variable `m_HookHitDisabled` is also being accessed without `this`.
2024-07-11 18:02:24 +02:00
Robert Müller 998adfcefc Remove redundant distance checks
The check `Distance > 0.0f` is redundant because the same check already exists in the outer if-statement and the variable `Distance` is never modified.

The check `D >= 0.0f` is redundant because mathematically any distance is greater or equal to zero.
2024-07-11 17:54:51 +02:00
Robert Müller aeee2f561d Remove dead code and obsolete TODO
It seems unlikely we that would want to introduce a variable to tweak the hook behavior at this point, so the TODO is removed.
2024-07-11 17:54:41 +02:00
Robert Müller 8e83049054
Merge pull request #8352 from ChillerDragon/pr_multi_cmd_helptext
Show help text when chaining multiple commands
2024-07-10 16:46:47 +00:00
Dennis Felsing 108d0dc715 Make FillAntibot faster 2024-07-10 15:06:16 +02:00
Learath 7fa0ef56f3 Include port 2024-07-09 20:27:40 +02:00
Learath 3cb390c6e6 net_addr_str only once 2024-07-09 20:17:34 +02:00
Robert Müller 350a57df60 Fix multiple redirected clients not dropped in the same tick
Closes #8551.
2024-07-09 18:10:42 +02:00
ChillerDragon 7b540ddb16 Remove support for space separation 2024-07-09 08:30:59 +08:00
Dennis Felsing 9143f2eac7
Merge pull request #8571 from Robyt3/Tools-Map-Extract-Refactoring
Improve `map_extract` tool: fix crash when opus file cannot be opened, improve logging, refactoring
2024-07-08 21:44:05 +00:00
Robert Müller 526251293c Use static_cast and const pointers for map items 2024-07-08 22:21:51 +02:00
Robert Müller 4c702395db Split map_extract tool into separate functions
Improve readability by splitting the `map_extract` tool into multiple functions.
2024-07-08 22:21:28 +02:00
Robert Müller b81ac61556 Unload image and sound data in map_extract tool sooner
Reduce the memory footprint of the tool by unloading the map data as soon as possible instead of only implicitly when the `CDataFileReader` is destructed.
2024-07-08 22:21:14 +02:00
Robert Müller c9467454d3 Improve logging of map_extract tool
Use `log_info` and `log_error` instead of `dbg_msg`.

Add error messages when output files cannot be opened for writing.

Move log messages regarding files being written so they are only printed when the files are actually being written.
2024-07-08 22:20:57 +02:00
Robert Müller 4c4b2e9edc Fix map_extract tool crashing if opus file cannot be opened 2024-07-08 22:20:51 +02:00
Robert Müller 1b4e8ce3d3
Merge pull request #8553 from art0007i/test
add "/setjumps" practice command and "setjumps" rcon command
2024-07-07 15:07:28 +00:00
art0007i 03f934c81e add "/setjumps" practice command and "setjumps" rcon command 2024-07-07 16:43:02 +02:00
Robert Müller dc73da4514
Merge pull request #8497 from archimede67/teamcount-sb
Add team size indicator
2024-07-07 10:30:28 +00:00
Corantin H 816c64235c Add team size indicator in scoreboard and through /team 2024-07-07 11:26:01 +02:00
Corantin H 698603d63c Fix various automapper issues
Fix invalid logic for skipping empty tiles in automapper
Fix partial default rule search
Fix reading from wrong layer when proceeding
2024-07-06 16:22:48 +02:00
Robert Müller 60ab717f03
Merge pull request #8564 from ChillerDragon/pr_clang_editor
Fix some clang warnings in the editor
2024-07-06 10:51:04 +00:00
ChillerDragon d6cf127056 Fix some clang warnings in the editor 2024-07-06 17:53:10 +08:00
ChillerDragon 7553ea6297 Improve clang variable naming checks
Introduces checks for more variable types.
And fixes false positives in newer clang versions.
2024-07-06 10:10:00 +08:00
ChillerDragon 43a493445b Also split commands on spaces 2024-07-06 07:59:52 +08:00
ChillerDragon 5d43d346e7 Also split commands on double quotes 2024-07-06 07:59:52 +08:00
ChillerDragon 6b0b49e414 Look at command under cursor not at the end of the line 2024-07-06 07:59:52 +08:00
ChillerDragon 54977d5745 Auto complete when chaining multiple commands
closed #7966
2024-07-06 07:59:51 +08:00
ChillerDragon 89437b7ef7 Fix console search with multiple commands 2024-07-06 07:59:51 +08:00
ChillerDragon c8656635b9 Show help text when chaining multiple commands 2024-07-06 07:59:51 +08:00
Dennis Felsing fb6a6ccc43
Merge pull request #8563 from Robyt3/Server-Random-Map-Crash
Fix server crash when starting with `random(_unfinished)_map`
2024-07-05 22:23:13 +00:00
Robert Müller ecafa10dfa Fix server crash when starting with random(_unfinished)_map
See #8559.
2024-07-05 20:31:52 +02:00
Robert Müller b05ca91a15 Use SDL_OpenURL to open links and files on Android
Opening links and files with the `open_link` and `open_file` functions does not work on Android, as the `open_link` function uses `fork` which is not supported on Android. This also seems to cause a strange bug where client networking partially breaks. Currently, after trying to open any link, connecting to servers is not possible anymore but the server browser still works, with the connection getting stuck randomly in the connecting/loading state.

SDL implements URL opening, including of file URIs, with the `SDL_OpenURL` function for most systems including Android. However, using `SDL_OpenURL` for all systems has several downsides:

1. The `SDL_OpenURL` function is only available since SDL 2.0.14, in particular not for the Ubuntu 20 CI runner. Hence, we would either have to conditionally compile the link opening function to a null-implementation or fallback to using the existing `open_link` function.
2. We would be undoing some additional fixes in the `open_link` function for Windows, which are not included in the Windows implementation of `SDL_OpenURL`.
3. This would also replace the use of `open` on UNIX with `xdg-open`.
4. This would move the functionality to open links and files from the base to the engine client, so we could not have tools or the server potentially making use of this functionality in the future (e.g. open a folder for convenience).

Implementing link and file opening for Android ourselves is too much effort and potentially made even harder by SDL already managing all the unique JVM resources in the `SDLActivity`.

Therefore, the `SDL_OpenURL` function is only used for Android, which is always based on the latest SDL2 version. The original `open_link` functionality is kept for the other systems. For this purpose, the `IClient::ViewLink` and `ViewFile` functions are added to wrap `open_link` and `open_file` for the client and also reduce some duplicate code for error logging.

Unfortunately, testing also revealed that `SDL_OpenURL` does not currently support opening file URIs, at least not of files the internal storage location, which all the DDNet client's files would be located in. At least opening URLs works and neither breaks networking anymore.
2024-07-05 17:53:11 +02:00
heinrich5991 447b44d290
Merge pull request #8558 from def-/pr-int-overflow
Fix integer overflow when computing tilemap size
2024-07-04 10:52:58 +00:00
Dennis Felsing 429777236b Fix integer overflow when computing tilemap size
Cherry-picked from d25869626a
2024-07-04 12:35:33 +02:00
Dennis Felsing 3806f324d8 Version 18.3.1 2024-07-04 12:33:40 +02:00
heinrich5991 77054c1134 Use Client()->PlayerName() for copied server info
Fixes #8554.

Alternative to #8555.
2024-07-03 14:22:15 +02:00
heinrich5991 9ccb87bf6b
Merge pull request #8538 from def-/pr-upnp
Support new UPNP API
2024-07-01 22:56:06 +00:00
Dennis Felsing a0da2d0978 Support new UPNP API
See c0a50ce33e
2024-07-02 00:32:46 +02:00
Dennis Felsing 8c21fa1928
Merge pull request #8544 from heinrich5991/pr_ddnet_libloc
mastersrv: Use `libloc` instead of our own CSV format for GeoIP
2024-07-01 22:15:47 +00:00
heinrich5991 20d58e6edb mastersrv: Fix warning about unused mut 2024-07-01 22:18:50 +02:00
Robert Müller dc56651c39 Various improvements to scoreboard rendering, refactoring
Scoreboard title

- In teamplay, color the title background red/blue for the respective teams (like in 0.7).
- In teamplay, swap the score location for the blue team, so the scores line up in the center (like in 0.7).
- Use textrender ellipsis instead of cutting the title string manually and potentially creating broken UTF-8.

Game over title

- Render the game over message in the color of the winning team (or yellow in case of draws).
- Adjust size and spacing of the message to prevent overlap.

Player list

- Add player list size variant for 17-24 players with two columns of up to 12 players. This previously used the variant for 32 players.

Goals

- Use textrender for alignment and properly center the time limit goal.
- Change localization text from `Round` to `Round %d/%d` so the numbers and punctuation can be formatted more correctly in some languages (e.g. right-to-left languages, Korean, Chinese).

Spectators

- Render spectators title and spectators starting in the same line to use space more effectively.
- Render as many lines of spectators as fit instead of only 4 lines.
- Render a placeholder text at the end when there are more spectators than fit.

Refactoring

- Use correct class for `NETMSGTYPE_SV_RECORDLEGACY` instead of depending on the structs `CNetMsg_Sv_Record` and `CNetMsg_Sv_RecordLegacy` being identical.
- Use `CUIRect` and `DoLabel` when possible.
2024-07-01 22:18:10 +02:00
heinrich5991 e0b62edb0b mastersrv: Use libloc instead of our own CSV format for GeoIP
This also makes GeoIP data more precise than our current state, from
`eu` to `eu:de` for Germany, i.e. adding country codes for all countries
and not only for China.

https://git.ipfire.org/?p=location/libloc.git

Current location data can be obtained from
https://location.ipfire.org/databases/1/location.db.xz.
2024-07-01 22:17:12 +02:00