Commit graph

14984 commits

Author SHA1 Message Date
ChillerDragon 05d97cafb2 Stop demo when gameworld is reset
Currently the per tee demos are only stopped when a character dies.
But the Reset() method in the gameworld destroys characters without
killing them.

This allows to do world resets without calling gamecontext shutdown
while sv_player_demo_record is active. Which is nice for round based
game modes.

```C++
void CGameWorld::Reset()
{
	// reset all entities
	for(auto *pEnt : m_apFirstEntityTypes)
		for(; pEnt;)
		{
			m_pNextTraverseEntity = pEnt->m_pNextTypeEntity;
			pEnt->Reset();
			pEnt = m_pNextTraverseEntity;
		}
	RemoveEntities();

	GameServer()->m_pController->OnReset();
	RemoveEntities();

	m_ResetRequested = false;

	GameServer()->CreateAllEntities(false);
}
```
2024-06-02 21:35:05 +08:00
Dennis Felsing 19b704d600
Merge pull request #8433 from Robyt3/Scoreboard-Recording-Notification-Refactoring
Fix truncated scoreboard recording notification, refactoring
2024-06-02 11:30:53 +00:00
Dennis Felsing 9986eaf6e9
Merge pull request #8435 from Robyt3/Translations-Ellipsis-Consistency
Consistently use `…` instead of `...` in translations
2024-06-02 11:28:15 +00:00
Dennis Felsing 3ba9fee8a8
Merge pull request #8430 from Robyt3/Localization-Fixes
Fix language file being loaded twice when starting, improve error handling for invalid translation files
2024-06-02 11:20:59 +00:00
Dennis Felsing da0df30497
Merge pull request #8356 from furo321/split-practice-commands
Add `/practicecmdlist`
2024-06-02 11:19:06 +00:00
Dennis Felsing bcc7412847
Merge pull request #8406 from l-ouis/master
Add confetti particles on finish
2024-06-02 11:15:16 +00:00
Robert Müller 37abc9039a Consistently use instead of ... in translations 2024-06-02 12:57:15 +02:00
Robert Müller cc7d6c393d Fix truncated scoreboard recording notification, refactoring
With some languages the buffers for the scoreboard recording notification were not large enough when recording all 4 types of demos at the same time.

Reduce duplicate code. Avoid unnecessary, slow `str_format` for concatenation. Use UI functions for drawing the background and text.
2024-06-02 11:54:23 +02:00
Robert Müller bbf54ec625
Merge pull request #8318 from ChillerDragon/pr_clang_tidy_19
Add support for clang tidy 19
2024-06-02 08:52:47 +00:00
Robert Müller 6cfe54b9c5
Merge pull request #8338 from ChillerDragon/pr_goto_tele_refactor
Fix `goto_tele` not finding all teleporters
2024-06-02 08:47:30 +00:00
Robert Müller 94325cdf78 Improve error handling for invalid translation files
Fix crash when reading a translation file that ends unexpectedly after a context line.

Make error messages about malformed translation files more detailed.

Fix incorrect line numbers in the error message because context lines were not counted.

Use `log_error` for error messages.
2024-06-02 10:36:00 +02:00
Louis Geer 9492ca574b Add confetti particles on finish
Add confetti particles on finish

added common base to finish netevent

review fixes

change netevent to ddnet.org
2024-06-02 11:00:06 +09:00
Robert Müller f762e2364f Fix language file being loaded twice when starting
Ignore language file config variable being set initially in the conchain (i.e. when `GlobalTime` still returns zero) and check whether the value changed before reloading the language.
2024-06-01 22:24:05 +02:00
furo 4e552d0f98 Add /practicecmdlist 2024-06-01 18:51:53 +02:00
Dennis Felsing f1c2d10cd7
Merge pull request #8424 from Robyt3/Cleanup-str_copy
Consistently use `str_copy` instead of `mem_copy` for strings
2024-06-01 15:18:37 +00:00
Robert Müller 24d12e4820 Consistently use str_copy instead of mem_copy for strings 2024-06-01 13:55:20 +02:00
Robert Müller 2a3cc8fd55 Make map download progress and speed label translatable 2024-06-01 13:01:37 +02:00
heinrich5991 a5ca7c64e0
Merge pull request #8409 from ChillerDragon/pr_const_char
Mark some character methods const
2024-05-29 00:31:19 +00:00
ChillerDragon ffd0da09e9 Mark some character methods const 2024-05-29 08:13:16 +08:00
Robert Müller bd5ca951a7 Prevent UI elements from being hovered while key reader is active
Since the key reader will intercept the next input, the other UI elements should not react to the hovered mouse.
2024-05-27 20:20:25 +02:00
ChillerDragon 59cb7ef5a9 Fix clang-analyzer-unix.StdCLibraryFunctions
```
/home/chiller/Desktop/git/ddnet/src/base/system.cpp:1989:10: error: The 1st argument to 'connect' is < 0 but should be >= 0 [clang-analyzer-unix.StdCLibraryFunctions,-warnings-as-errors]
 1989 |                 return connect(sock->ipv4sock, (struct sockaddr *)&addr, sizeof(addr));
      |                        ^
```
2024-05-26 19:31:54 +08:00
ChillerDragon 64505273a9 Remove redundant casts 2024-05-26 19:31:54 +08:00
ChillerDragon 0a505c25d7 Don't return from void methods 2024-05-26 19:31:54 +08:00
ChillerDragon c4f68f50ea Remove unnecessary object creation in emplace_front
Fixes

```
/home/chiller/Desktop/git/ddnet/src/engine/client/updater.cpp:186:27: error: unnecessary temporary object created while calling emplace_front [modernize-use-emplace,-warnings-as-errors]
  186 |         m_FileJobs.emplace_front(std::make_pair(pFile, Job));
      |                                  ^~~~~~~~~~~~~~~          ~
```
2024-05-26 19:31:54 +08:00
Robert Müller 583845fc60 Ensure return value of secure_random_init is always checked 2024-05-26 11:59:26 +02:00
Robert Müller 986508e091 Improve Android storage usage, faster launch, remove permissions
Split the user storage location and the data folder in the app specific external storage in the folders `data` and `user` instead of writing the user setting directly to the external storage.

Remove unnecessary storage permissions. The client only accesses files in its own external storage location, hence these permissions are not necessary for Android API 19 and higher, which is always given as we only target API 19 and higher.

Only unpack changed assets when their hash in the integrity index is different instead of unpacking all assets again, so the app starts faster after updates. Avoid unpacking the entire integrity index file unless it changed, by initially reading only the first hash directly from the asset, so the app starts faster when the data is up-to-date.

Add error handling for external storage not being accessible and other I/O errors during unpacking of assets.

Add `android_main.h` header to export the `InitAndroid` function and potentially other functions in the future. The `extern "C"` and `__attribute__((visibility("default")))` attributes seem to be unnecessary, as this function is only called directly from the native code like many other functions without these attributes.

Initialize the Android storage after the loggers, so the log message are printed properly.

Add documentation for the use of `std::exit` on Android, which is used to forcefully terminate the entire process, to ensure that static variables will be initialized correctly when the app is started again after quitting. Returning from the main function is not enough, as this only results in the native thread terminating, but the Java thread will continue. Java does not support unloading libraries once they have been loaded, so all static variables will not have their expected initial values anymore when the app is started again after quitting.

Use `fs_chdir` and `fs_makedir` instead of `chdir` and `mkdir`.
2024-05-25 21:09:42 +02:00
heinrich5991 1e11fffb03
Merge pull request #8390 from Robyt3/Base-chdir-getcwd-Cleanup
Minor refactoring of `fs_chdir` and `fs_getcwd` functions
2024-05-22 21:25:27 +00:00
heinrich5991 848f4a846b
Merge pull request #8334 from Robyt3/Android-Building-Fix
Fix the Android build and improve the Android building `README.md`
2024-05-22 21:19:40 +00:00
Robert Müller 68d474c81f
Merge pull request #8363 from heinrich5991/pr_ddnet_str_from_int
Optimize `str_format(…, …, "%d", …)` using templates
2024-05-22 21:01:17 +00:00
Robert Müller f04bea6b4b Minor refactoring of fs_chdir and fs_getcwd functions
Remove unnecessary `fs_is_dir` check in the `fs_chdir` function. The `SetCurrentDirectoryW` and `chdir` functions would already include such necessary checks anyway.

Assert that `GetCurrentDirectoryW` was successful instead of logging an error message. This function should only potentially fail if the current working directory was changed by another thread between the two calls, which should not happen in our code.
2024-05-22 19:22:23 +02:00
Dennis Felsing 9048bf2997
Merge pull request #7820 from gerdoe-jr/set-rescue
Add `/rescuemode` support
2024-05-22 17:22:07 +00:00
heinrich5991 df9980ee3e Optimize str_format(…, …, "%d", …) using templates
This would make the function `str_from_int` unnecessary, at least
user-facing.

Advantage: User doesn't have to care about `str_from_int`/`str_format`
distinction.

Disadvantage: We're adding some template programming to `system.h`,
potentially slowing all compilation.
2024-05-22 14:44:46 +02:00
heinrich5991 612a71f874
Merge pull request #8351 from ChillerDragon/pr_rcon_percentage
Show percentage of loaded rcon commands (closed #7769)
2024-05-22 08:39:40 +00:00
Steve Biedermann 3af8c00fc7 allow ipv4 econ to succeed, even if ipv6 econ fails to open port 2024-05-21 20:55:30 +02:00
Robert Müller dfae99da76 Fix unused variable Silent in client.cpp on Android 2024-05-21 17:36:46 +02:00
Robert Müller 4a2a23530c Fix integrity_save.txt file not being closed 2024-05-21 17:36:46 +02:00
Robert Müller b2b0cd0c81 Fix shadowed variable declarations in android_main.cpp 2024-05-21 17:36:46 +02:00
Robert Müller 7da8308c3f Remove cl_ddrace_scoreboard and cl_demo_assume_race settings
Time score will now always be used for any game with the flag `GAMEINFOFLAG_TIMESCORE` set in the `CNetObj_GameInfoEx` object. If the flag is not set, points score is used instead.

Backwards compatibility for old demos, that were recorded without this net object and flag, is removed. For old demos, points score is always assumed now.

Closes #6700.
2024-05-20 11:07:01 +02:00
Robert Müller c0a6f5a927 Revert "Always clear window with black color instead of background color"
This reverts commit caa062c88c.

As this decreased FPS and caused the background quad to be rendered twice when using a map background in entities mode.
2024-05-19 20:01:56 +02:00
Robert Müller 05c825947a Force landscape orientation and hide title bar on Android
Always force landscape orientation to be used for the game on Android.

Hide the title bar so it is not shown when starting the game. There is also a bug with SDL currently that leads to the title bar and status bar being shown permanently after minimizing and reopening the app, which is alleviated by hiding the title bar.
2024-05-19 12:58:33 +02:00
Robert Müller caa062c88c Always clear window with black color instead of background color
Always use black color to clear the window with all graphics backends, instead of using `cl_background_color` or `cl_background_entities_color`, respectively, as the clear color. The respective map background color is rendered using a quad in `CMapLayers` instead, so this should not affect appearance of maps. This does not have any noticeable effect on FPS. Previously, the unused part of the window (when it is resized smaller than 5:4 aspect ratio), was colored using the map background color, whereas now it will be cleared black consistently.

The color parameters of the `IGraphics::Clear` function and of the `SCommand_Clear` command are removed, as we always expect the screen to be cleared black now.

The parameter `ForceClearNow` of the `IGraphics::Clear` function was already unused previously and is also removed.
2024-05-18 15:20:17 +02:00
Dennis Felsing fcacef5fbb
Merge pull request #8362 from Robyt3/Android-Backbutton-Handling
Translate back-button to escape-key on Android, quit if Android back-button is pressed 3 times within 1 second
2024-05-18 01:10:32 +00:00
Robert Müller 91848f0be6 Quit if Android back-button is pressed 3 times within 1 second
Interpret fast repeated presses of the back-button (3 times within 1 second) as a quit-event, so the app can be quit cleanly and quickly without using the UI. The client settings are otherwise not saved if the app is closed by minimizing it using the home button and waiting for the OS to kill it or by discarding it in the recent apps view.
2024-05-17 19:37:44 +02:00
Robert Müller bba606feae Translate back-button to escape-key on Android
Translate the Android back-button to the escape-key, so it can be used to navigate back in menus, open/close the ingame menu, close the editor etc.

Trap the Android back button by setting the `SDL_ANDROID_TRAP_BACK_BUTTON` hint, so it can be handled in our code reliably instead of letting the system handle it.
2024-05-17 19:36:35 +02:00
Robert Müller 554f244ef2 Remove redundant graphics backend functions returning RGBA format
The graphics backends only support the RGBA format with the `SCommand_Texture_Create` and `SCommand_Texture_Update` commands, so the `TexFormatToOpenGLFormat`, `TextureFormatToVulkanFormat` and `TexFormatToNewOpenGLFormat` functions and the command member variables for the format are unnecessary. The `TexFormatToNewOpenGLFormat` function was unused.
2024-05-17 19:36:11 +02:00
archimede67 0f5b14c043
Merge pull request #8360 from Robyt3/UI-ButtonLogic-Consistency
Fix inconsistent behavior of scrollbars, key readers, edit boxes, value selectors and editor sound seekbars
2024-05-16 21:25:46 +00:00
heinrich5991 392fc0ba9a str_from_intstr_format 2024-05-14 21:37:02 +02:00
Vlad 4532a64b2b Add rescuemodes
May `/rescuemode` be case-insensitive

clang-tidy

conflicts

clang-tidy

`CMDFLAG_PRACTICE`
2024-05-14 09:19:50 +03:00
ChillerDragon f3a686bc62 Show percentage of loaded rcon commands
closed #7769
2024-05-14 08:46:17 +08:00
heinrich5991 03b13cb9f5
Merge pull request #8355 from Patiga/fix-pixelart
Fix off-by-one error in map_create_pixelart
2024-05-13 22:37:13 +00:00
yrrrmmbl a93ad48dce add cl_show_chat_team to only show team members' messages 2024-05-13 19:18:41 +02:00
Robert Müller f3bb5feffc
Merge pull request #8347 from Jupeyy/pr_vk_minirefactor
Fix segfault when swapchain images change (e.g. toggling Vsync)
2024-05-12 20:16:30 +00:00
Robert Müller 1c123f2324 Fix inconsistent button behavior of remaining UI elements
Fix edit boxes, scrollbars, value selectors and the editor sound seekbar being activated by holding the left mouse button from outside the UI element and then hovering it, which is inconsistent with the behavior of the `DoButtonLogic` function.
2024-05-12 18:16:06 +02:00
Robert Müller d431a5cdeb Fix inconsistent key reader button behavior
Use the `DoButtonLogic` function directly for the key reader buttons in the controls settings. Now, the key reader will only be activated when the left click is initiated and completed inside the key reader button. Previously, the key reader would be activated immediately when holding the left mouse button from outside and then hovering the key reader, and the key reader was already activated by the press-event, whereas now it will only be activated by the release event of the left mouse button. The active key reader UI ID is now tracked as a member variable of `CMenusKeyBinder` to avoid using static variables for this purpose.
2024-05-12 18:15:49 +02:00
Robert Müller e822d6878b Fix scrollregion scrollbar position offset after releasing handle
The scrollregion scrollbar was not being deactivated if the handle is continued to be hovered after releasing it, causing the handle to become offset with the position of the click on the next activation of the handle.
2024-05-12 18:15:39 +02:00
heinrich5991 0562be67f4
Merge pull request #8353 from Robyt3/Client-Demo-Seekbar-UX-Fixes
Fix demo seekbar tooltip not shown while seekbar is active, fix demo seekbar being activated by held button press
2024-05-12 01:45:33 +00:00
heinrich5991 acde8806db
Merge pull request #8354 from Robyt3/Menus-Settings-Controller-Size-Fix
Fix height of controller settings with exactly 1 controller
2024-05-12 01:26:08 +00:00
Patiga 4f62980541 Fix off-by-one error in map_create_pixelart 2024-05-11 19:53:56 +02:00
Robert Müller b8cb67379c Fix height of controller settings with exactly 1 controller
The controller name is also shown if there is only exactly one controller connected, but the height was not increased for the additional row.
2024-05-11 15:10:15 +02:00
Robert Müller c6c8f2eab6 Fix demo seekbar being activated by held button press
The seekbar is immediately activated if the mouse button is held while moving the mouse over the seekbar, which is inconsistent with the general `DoButtonLogic` behavior. This is problematic on Android, where the first mouse button is always pressed while the mouse is being moved, causing the seekbar to steal focus immediately when hovered.
2024-05-11 12:29:33 +02:00
Robert Müller 7d0774a00d Fix demo seekbar tooltip not shown while seekbar is active
The tooltip was not shown if the seekbar is the active item, i.e. when the first mouse button is held down and the seekbar is currently updating the demo player.
2024-05-11 12:26:46 +02:00
ChillerDragon 4f4f32615a Keep respawned players in multi view list on pvp servers
Assume every server that does not have ddnet or race in its gametype to be a pvp server.
This allows spectators to follow multiple players during a fng/ctf/gctf/ictf round.

Related issue #7509
2024-05-11 08:52:42 +08:00
Robert Müller 74e2e04b7d Remove unused CImageInfo::ImageFormatFromInt
Since the image format is not parsed from maps anymore, this function is unnecessary.
2024-05-10 21:44:49 +02:00
furo 3491624184 Fix crash when not specifying optimize, centralize or invalid amount of arguments 2024-05-10 19:05:58 +02:00
Jupeyy 15afc50865 Don't recreate DescriptorSetLayouts if swapchain image count changes 2024-05-10 18:48:09 +02:00
Jupeyy 128302d726 Cleanup Vulkan now takes SwapchainCount as explicit parameter.
This fixes a crash if the swapchain count changed.
fixes #8328
2024-05-10 18:48:09 +02:00
Jupeyy 2655627a4b Rename m_CurFrames to make clear it's about the sync objects.
Use one more sync object than there are inflight frames.
Remove unused memory sync objects.
2024-05-10 18:48:05 +02:00
furo 7cd9d8bbb4 Prevent using map_create_pixelart with the same input and output path 2024-05-10 18:42:55 +02:00
furo 39dd6ea499 Fix wrong filename used in dbg_msg 2024-05-10 18:20:33 +02:00
furo d5b06a4482 Use IO_MAX_PATH_LENGTH instead of 64 2024-05-10 18:18:24 +02:00
Robert Müller c80592063a Fix size of chat history entry allocation
The `-1` in the size calculation for the ringbuffer allocation of chat history entries was incorrect, so the entries potentially didn't fit the zero terminator. Because `mem_copy` was used, the string was also not zero terminated explicitly.
2024-05-10 10:53:23 +02:00
ChillerDragon 257a0bacc8 Store all tele types in vectors 2024-05-10 08:59:19 +08:00
heinrich5991 60dbd73ee3
Merge pull request #8333 from BlaiZephyr/change-time-timestamp-type
Change type from int to int64_t
2024-05-09 08:01:17 +00:00
meloƞ aec0dc9e0e Change type from int to int64_t 2024-05-09 08:42:19 +02:00
gerdoe-jr 4f0d8a5a1f add set_view_relative 2024-05-09 06:28:55 +03:00
ChillerDragon 6f75087d9f Refactor goto_tele
Fixes a bug of some teleporters being skipped.
Improves performance by only iterating all teleporters instead of every tile in the map.
2024-05-09 11:20:59 +08:00
heinrich5991 c211e874aa Fix 0.7 tokens after #8322
They're also read as big-endian integers now.

Thanks to @ChillerDragon for noticing.

Fixes #8330.
2024-05-08 14:17:02 +02:00
Dennis Felsing f214c1101b
Merge pull request #8326 from heinrich5991/pr_ddnet_no_map_image_rgb
Remove RGB images from the map file format
2024-05-08 04:56:19 +00:00
heinrich5991 8a64feabc3 Remove RGB images from the map file format
Cherry-picked from https://github.com/teeworlds/teeworlds/pull/2822.

CC https://github.com/teeworlds/teeworlds/issues/2812
CC https://github.com/teeworlds/teeworlds/issues/962

Since DDNet never saved these kinds of images, this should cause no
issues.
2024-05-07 14:31:06 +02:00
heinrich5991 3a48b8e6cf Revert "Initialize all ghost item member (Closed #8297)"
This reverts commit f319ed239a.

Initializing these variables with junk data doesn't seem to be an
improvement over not initializing them. It hides potential Valgrind
warnings about data accesses to uninitialized memory though.

f319ed239a (r1590801501)
2024-05-07 14:25:29 +02:00
Dennis Felsing df30321f52
Merge pull request #8324 from ewancg/chat-practice
Add chat commands for toggling weapons in practice mode
2024-05-07 05:42:38 +00:00
Dennis Felsing ae2c9e2999
Merge pull request #8323 from Robyt3/Client-Particles-Smoke-Nudge
Fix smoke particles sometimes being stuck inside solid tiles
2024-05-07 01:21:37 +00:00
Ewan Green 87cab3ebd9 change GetPracticeCharacter() to not be static, fix solo checks 2024-05-06 15:06:42 -06:00
Ewan Green ba5b39d294 change forgotten functions to use practice check 2024-05-06 14:08:51 -06:00
Ewan Green bf78d7fb48 cleanup 2024-05-06 14:03:17 -06:00
Ewan Green d6449872a4 add weapon chat commands for practice mode 2024-05-06 13:57:16 -06:00
heinrich5991 36712db0f1 Use network tokens in big-endian byte order consistently
Previously, it was handled inconsistently on big-endian machines and
caused connection failures.
2024-05-06 20:33:17 +02:00
Robert Müller 6cbc85f229 Fix smoke particles sometimes being stuck inside solid tiles
Nudge the initial position for explosions' smoke particles slightly towards the edge of the closest non-solid tile, if it would otherwise be inside a solid tile, so the smoke particles do not get stuck inside solid tiles on explosion events happening at the edges of tiles but slightly inside them. The physical position of the explosion event is unchanged, so this does not affect physics. The explosion sprite is still rendered at the physical position of the explosion, to preserve the apprearance.
2024-05-06 16:03:36 +02:00
Robert Müller d4e3f6fc01
Merge pull request #8316 from ChillerDragon/pr_use_sendchat
Use SendChat() in DbgStress
2024-05-06 08:52:47 +00:00
ChillerDragon 3c606dd1e4 Don't access static ConCommandStatus with a member
Fixes this clang-tidy 19 warning

```
/home/chiller/Desktop/git/ddnet/src/engine/shared/console.cpp:739:2: error: static member accessed through instance [readability-static-accessed-through-instance,-warnings-as-errors]
  739 |         pConsole->ConCommandStatus(&Result, pConsole);
      |         ^~~~~~~~~~
      |         CConsole::
```
2024-05-06 11:48:47 +08:00
ChillerDragon 28f3ac3e87 Use SendChat() in DbgStress 2024-05-06 11:09:18 +08:00
ChillerDragon 44d065888f Rename CChat::SayChat to CChat::SendChatQueued
Also replace one code snippet with a call to SendChatQueued
2024-05-06 09:49:35 +08:00
ChillerDragon 33baeb8f28 Rename CChat::Say to CChat::SendChat
Follows the convention set by the other methods that send network packets.
2024-05-06 09:23:19 +08:00
Robert Müller 1551dda3e9 Also unload collision and layers when unloading map
Ensure that the `CCollision` and `CLayers` instances do not keep any pointers to the map data after the map has been unloaded.
2024-05-05 12:41:18 +02:00
Robert Müller 7d640e1f98
Merge pull request #8309 from ChillerDragon/pr_init_ghost
Initialize all ghost item member (Closed #8297)
2024-05-05 09:37:54 +00:00
Robert Müller bf2343d60b
Merge pull request #8312 from ChillerDragon/pr_fix_misleading_demo_snap_var_names
Make demo snap variable names more obvious
2024-05-05 09:18:38 +00:00
ChillerDragon 1a3bb727c5 Make demo snap variable names more obvious
Closed #8245
2024-05-05 16:01:55 +08:00
Dennis Felsing 2b2e57c2bb
Merge pull request #8308 from ChillerDragon/pr_team_enum
Use enum for teams (Closed #8306)
2024-05-05 03:59:35 +00:00
ChillerDragon f319ed239a Initialize all ghost item member (Closed #8297) 2024-05-05 11:47:05 +08:00
ChillerDragon 0b6bb8287a Use enum for teams (Closed #8306) 2024-05-05 11:38:29 +08:00