Commit graph

14715 commits

Author SHA1 Message Date
Robert Müller 5295ba3ded Improve readability by breaking early and reducing indentation
Remove unnecessary temporary variables and parenthesis.
2024-04-13 11:10:47 +02:00
Robert Müller 9cd51576d4 Rename static variable ActionTaken to s_ActionTaken 2024-04-13 11:10:45 +02:00
Robert Müller fd7a1600f6 Remove redundant checks of client state
These conditions are contained in an `if(State() == IClient::STATE_ONLINE)` branch and the state does not change while inside this branch, so these checks are unnecessary.
2024-04-13 11:10:25 +02:00
Robert Müller 507b097ad8 Remove unnecessary cleanup in CClient::LoadMap function
The number of received snapshots is already correctly reset in the `CClient::OnEnterGame` function for the main and dummy connections.
2024-04-13 11:07:19 +02:00
Robert Müller 5da64c54fd Fix tee briefly appearing at previous position when joining
Previously, when connecting to servers repeatedly, the local tee would appear at the position it had on the previous server for a short time when joining.

This (and potentially other bugs) are fixed by clearing all game related `CGameClient` member variables in the `OnReset` function. Additionally, the `OnReset` function is now used in the `OnInit` function to ensure everything is initialized correctly when starting the client and to avoid duplicating the code.

In particular, this bug was limited to use of `cl_predict 1`, because the predicted gameworlds were not being reset when disconnecting, causing the predicted world and character from the previous server to be used. This bug was introduced in version 15.6, which added the predicted gameworlds in #1620. Closes #4339.
2024-04-11 21:37:53 +02:00
Robert Müller e4fd16e6a5
Merge pull request #8200 from def-/pr-default-team0mode
Enable team0mode by default again
2024-04-11 18:21:26 +00:00
Dennis Felsing 1adae02291
Merge pull request #8199 from dobrykafe/pr-team0mode-fix
Prevent enabling `/team0mode` while practice mode is active
2024-04-11 16:45:22 +00:00
Dennis Felsing 387608a361 Enable team0mode by default again
Since we have https://github.com/ddnet/ddnet/pull/8199 now
2024-04-12 00:31:09 +08:00
dobrykafe 083f7ba7ab prevent enabling /team0mode while practice mode is active 2024-04-11 18:26:56 +02:00
Dennis Felsing e1ab2ea07e Add sv_team0mode 2024-04-12 00:15:38 +08:00
Robert Müller 01a995e5ec Track country/type filters separately for internet/favorites tabs
For the internet/favorite tabs, instead of combining the country/type filters of all communities in one view, track the country/type filters separately for these tabs using the new, reserved community name `all`. This should make the filters less confusing to use, as changing the country/type filters in one tab will not influence the other tabs anymore. Though the country/type filters of the internet and favorite tabs are still combined, as this is also the case for the community filter.

However, this made it possible to select country/type filters that exclude all servers, by first excluding some countries/types and then changing the selected communities so all selectable countries/types are excluded. To prevent this, the filters will now include all countries/types, if they would otherwise exclude all selectable countries/types.

To do this more efficiently, the community cache is moved from the menus to the engine serverbrowser. To avoid using the UI page in the engine serverbrowser, the serverbrowser type is instead used to detect if the community cache should be updated. This required additional changes in the menus to ensure that the UI page and the serverbrowser type stay in sync with each other, which would otherwise cause incorrect server entries to be shown for one frame when switching tabs. The serverbrowser type is now refreshed immediately when the menu page is changed with the `CMenus::SetMenuPage` function, which allowed removing duplicate code for the server browser tab buttons. The `CMenus::RefreshBrowserTab` function does not take the page to be refreshed as argument anymore, as it always was only used to refresh the current page. Instead, a `bool` argument is used to specify whether the refresh should be forced even if the server browser type has not changed.

Closes #8158.
2024-04-10 21:40:02 +02:00
Robert Müller 394ed87ac9 Avoid copy of CServerInfo in loop in IsRegistered 2024-04-10 21:08:29 +02:00
Dennis Felsing 67dfd7b434
Merge pull request #8193 from furo321/fix-typo
Fix typo in `/team0mode` description
2024-04-08 16:03:40 +00:00
furo 077d7c5afb Fix typo in /team0mode description 2024-04-08 17:01:15 +02:00
Dennis Felsing 8f58cbaea3
Merge pull request #8192 from dobrykafe/pr-conchain-bg-entities
Add console chain for `ClBackgroundEntities`
2024-04-08 12:39:00 +00:00
dobrykafe fd5d334cd1 add console chain for ClBackgroundEntities 2024-04-08 12:26:25 +02:00
furo 7fcac2adc2 Rename /flock to /team0mode 2024-04-07 18:48:39 +02:00
Dennis Felsing 3a75f838ac Address reviewer comment 2024-04-07 16:41:21 +08:00
dobrykafe 4c40e6c83f change /mode -> /flock 2024-04-07 16:39:27 +08:00
dobrykafe 672cfb6236 add /mode allowing teams to behave like team 0 2024-04-07 16:37:13 +08:00
Robert Müller 2e15b7d02f Let CUi::DoScrollbarOption return true if value changed
Reduce duplicate code when using the `CUi::DoScrollbarOption` function.
2024-04-04 21:00:26 +02:00
Dennis Felsing c20baa5035
Merge pull request #8186 from ChillerDragon/pr_optimize_demo_snap
Remove demo snap buffer and mem copy
2024-04-04 05:39:17 +00:00
ChillerDragon c5fb857893 Remove demo snap buffer and mem copy
Adding the snap to the demo is the last usage of `pTmpBuffer3`
all prior usages of it copy the data if needed.
So we can edit it in place. No need to copy it into a new buffer.
2024-04-04 07:38:52 +08:00
Robert Müller 3c6fce376d Remove unused CTextCursor variable 2024-04-03 22:01:10 +02:00
Dennis Felsing e263ce9bdc
Merge pull request #8181 from dobrykafe/pr-discord-activity
Show Discord activity when offline
2024-04-03 05:35:16 +00:00
Dennis Felsing 7286a05dd4
Merge pull request #8182 from furo321/ec-password
Specify that `ec_password` is required to be set for econ to be enabled
2024-04-03 05:34:40 +00:00
furo ff1b1ae7b0 Specify that ec_password is required to be set for econ to be enabled 2024-04-03 00:24:24 +02:00
dobrykafe 990bb9b1ef show discord activity when offline 2024-04-02 23:57:17 +02:00
Robert Müller 44cd59379d Improve layout of settings menus and restart message
Remove unnecessary, inconsistent margin at the top of all settings menus.

Reserve space for restart message and button only when necessary, so more height is available for settings menus per default.

Improve vertical alignment of restart message and button with settings menus.

Ensure consistent margin on all sides of settings menus.
2024-04-02 21:28:15 +02:00
Robert Müller 7727628eeb Improve layout of Appearance settings
Use consistent margins for all settings pages and titles.

Fix chat preview overlapping with the restart warning.

Simplify layout code. Remove array of `CButtonContainer`s with arbitrary size and use individual variables instead.
2024-04-02 21:28:15 +02:00
Robert Müller 1a9f15d11b Render loading popup also while loading demo files
As this can take a few seconds for large demos.
2024-04-01 16:44:10 +02:00
Dennis Felsing 9122080514
Merge pull request #8170 from Robyt3/Gameclient-Render-Checks
Improve performance when rendering menus
2024-04-01 03:58:07 +00:00
Dennis Felsing 295b095d29
Merge pull request #8167 from Robyt3/Client-Rcon-Username-State-Fix
Fix rcon username not reset when disconnecting while connecting
2024-04-01 03:06:10 +00:00
Dennis Felsing c9f0075330
Merge pull request #8166 from Robyt3/Browser-Favorite-Communities-Increase
Increase maximum number of favorite communities from 3 to 5
2024-04-01 03:00:26 +00:00
Robert Müller 2790530bbe Increase maximum number of favorite communities from 3 to 5
Simply hide the favorite community tabs in the offline server browser with screen resolutions where not enough width is available.

The ingame server browser can always show at least 5 favorite community tabs with all screen resolutions.
2024-03-31 20:17:51 +02:00
Robert Müller b730d9d890 Improve performance when rendering menus
Skip rendering various client components (players, ghosts, nameplates, HUD etc.) while not ingame to improve performance. This increases FPS when rendering the start menu by around 300-400 both in debug and release builds.

This also fixes potential crashes when components using the map data where rendered while the client is loading a new map.
2024-03-31 15:30:19 +02:00
Robert Müller a287669500 Reset tuning of dummy and main when disconnecting
Instead of only resetting the tuning for either one which is currently active.
2024-03-31 12:48:43 +02:00
Robert Müller 830e8fea8c Fix rcon username not reset when disconnecting while connecting
The rcon username requirement was not reset correctly when disconnecting from a server while connecting/loading, at which point the `NETMSG_RCONTYPE` message has already been received.

Closes #4170.
2024-03-31 11:17:29 +02:00
Edgar 8412d2be6e
Merge pull request #8160 from edg-l/incl_algo
include algorithm in jobs.cpp, try to fix #8159
2024-03-30 10:46:57 +00:00
Edgar 78cb4d4373
include algorithm in jobs.cpp, try to fix #8159 2024-03-28 20:14:16 +01:00
Robert Müller 2b8af7f40f Pass arguments as CImageInfo to graphics functions
Pass `CImageInfo` arguments to various graphics and text render functions instead of passing the components (data pointer, width, height, format/pixel size) of the image info separately.

Pass texture/file name to loading functions when available to improve error/warning messages.
2024-03-27 21:12:02 +01:00
Robert Müller 8218dbb6f8 Add CImageInfo::DataSize convenience function
To calculate the size of the image data based on its width, height and pixel size.
2024-03-27 21:12:02 +01:00
Robert Müller b4a22e2fee Refactor client state handling in menus
Split menu rendering explicitly by client state. This makes the code more readable by not mixing code for rendering different states together as much and fixes issues where the menu was being rendered inconsistently for one frame when the state is changed, at the cost of some additional duplicated code.

The fullscreen popups shown when in the connecting and loading client states are now hard-coded for these states, instead of being mixed together with the other fullscreen popups, which can be shown when offline, ingame or during demo playback.

As a side effect of rendering the demo controls like the regular menu, the UI color will now also affect the demo controls menu background.

Move `CBackground::ChangePosition` calls inside functions to reduce duplicate code and improve readability.

Remove unnecessary `CMenus::m_ActivePage` variable.

Closes #7834.
2024-03-25 20:48:52 +01:00
Dennis Felsing 58ee780fa7
Merge pull request #8155 from ChillerDragon/pr_add_missing_includes
Add missing includes
2024-03-25 07:51:18 +00:00
ChillerDragon e4c136d324 Add missing includes 2024-03-25 14:24:08 +08:00
Robert Müller 015390a51e Fix recursive folder creation with mixed slashes and drive letters
The function `fs_makedir_rec_for` for recursively creating folders did not handle paths containing backslashes correctly and only created folders after every occurrence of a regular slash. This could cause the recursive folder creation to fail when a parent folder is not created before the child folder. For example when recursively creating folders for the path `D:\Games/DDNet\downloadedskins`, the `DDNet` folder was not being created because this path segment does not end in a forward slash. Now, backslashes are handled the same as regular slashes, which is consistent with the other filesystem functions.

Additionally, the function tried to create folders for drive letters on Windows (e.g. `C:` and `D:`). Trying to create a system drive as a folder will fail due to access being denied, whereas it seems to work for already existing non-system drives. For example when recursively creating folders for the path `C:/Games/DDNet/downloadedskins`, the `C:` "folder" could not be created which caused the entire operation to fail. Now, the function will not try to create folders for drive letters anymore, i.e. if the name of the to be created folder ends with `:`.

Closes #8148.
2024-03-24 12:33:56 +01:00
Dennis Felsing 7e8dc57194
Merge pull request #8150 from furo321/freezebar-fix
Fix freeze bar not being correct after returning from pause
2024-03-23 23:26:04 +00:00
Dennis Felsing a4aafb78bd
Merge pull request #8147 from dobrykafe/pr-fix-style
`fix_style.py`: check for newline at the end of source files
2024-03-23 23:24:02 +00:00
Dennis Felsing eefcb83a4f
Merge pull request #8144 from Robyt3/Client-Skin-Reset-Cleanup
Use `CTeeRenderInfo::Reset`
2024-03-23 23:22:44 +00:00
c0d3d3v ab3991f821 fix freeze bar not beeing correct after returning from pause
m_FreezeStart is now corrected by the ticks the character was paused
Possible physical changes: Until now it was possible if you sit inside freeze to re-freeze instant
after unpause. Now you re-freeze after the second that was dawned before
the pause. I do not excpect that this is used on any map, and it did not
bring any benifit.
2024-03-23 23:05:14 +01:00