Commit graph

12721 commits

Author SHA1 Message Date
Robert Müller 301567507f Fix client crash when spectating on server with missing game info 2023-04-10 17:27:21 +02:00
Robert Müller 8f5708a882 Use TextBoundingBox for tooltip rendering
Calculate correct height for tooltip and apply consistent padding.

Ensure tooltip width and height do not exceed size of screen.
2023-04-10 17:22:10 +02:00
Robert Müller a6f9fdd6d5 Add function to get caret position to ITextRender
Add `CaretPosition` function to get position of text caret. Replace some existing usages of `TextWidth`, which would no longer work correctly for multi-line text.

Having this function is also useful when porting the upstream UI lineinput.
2023-04-10 17:22:10 +02:00
Robert Müller 9ad2f9f4df Add functions to get text bounding box to ITextRender
Add separate `STextBoundingBox` to describe text bounding box (same as on upstream). Add `GetBoundingBoxTextContainer` to get bounding box for a text container. Add `TextBoundingBox` function to get bounding box with old text render interface.

Using this function to get the bounding box width and height is cleaner than using `TextWidth`. This function additionally can get the bounding box X and Y position for convenience.

Some usages of `TextWidth` are replaced with `TextBoundingBox` to improve readability.

It will be useful to have these functions when porting the upstream UI lineinput.
2023-04-10 17:22:10 +02:00
Robert Müller 8507a651d1 Refactor vertical alignment in UI
Add separate constants `TEXTALIGN_TOP`, `TEXTALIGN_MIDDLE` and `TEXTALIGN_BOTTOM` for vertical alignment.

Add shorthand constants for all possible combinations of horizontal and vertical alignment, e.g. `TEXTALIGN_MC` for `TEXTALIGN_MIDDLE | TEXTALIGN_CENTER`.

Replace usage of `SLabelProperties::m_AlignVertically` with these constants in all menu and editor code for more convenient and versatile alignment of text. Use combined horizontal-vertical alignment constants for all existing labels. Manually adjust layout for some elements which were initially misaligned with the new implementation.

Refactoring:

- Use `CORNER_NONE` instead of `0`.
- Improve some `CUIRect` variables names and usage.
2023-04-10 17:22:09 +02:00
Robert Müller 76ad9e2e3b Use Localizable instead of comment with Localize 2023-04-10 16:43:53 +02:00
Robert Müller bf1e757581 Fix incorrect text width calculation when cursor not starting at X=0
Previously when calculating `m_LongestLineWidth` for a `CTextCursor` the position `m_StartX` of the cursor was always zero, because `m_LongestLineWidth` was only used to calculate the text width with a non-rendered cursor aligned at (0, 0).

To ensure that the calculation is correct also when the text cursor is not positioned at X=0, the width calculation must be offset by the start position.
2023-04-10 16:06:17 +02:00
Robert Müller 430e96346f Fix inconsistent text wrapping of popup labels
Round up the calculated text width to prevent inconsistent text wrapping in the popups in cases where the current text width is very close to the maximum line width.
2023-04-09 20:10:44 +02:00
Robert Müller 6decf14137 Use Text instead of TextEx for popup labels
To reduce duplicate code and ensure that the same flags are used with `TextWidth` and when actually rendering the text.
2023-04-09 20:10:44 +02:00
Robert Müller 9bb9c7ce6b Replace usages of TextLineCount with TextWidth
Calculate text height for popups with `TextWidth` instead of using `TextLineCount`, which can be incorrect if the aligned font size differs from the normal one.
2023-04-09 20:10:44 +02:00
Robert Müller 9693d4beac Fix vertical centering of multi-line UI labels
Also calculate text height in `TextWidth`.

Use calculated text height to verically center UI labels.

The text cursor flags (in particular, the `TEXTFLAG_STOP_AT_END` flag) must also be passed to `TextWidth`. Otherwise, for example, when `TEXTFLAG_STOP_AT_END` is missing, the wrong text height is calculated, as text is rendered over multiple lines instead of stopping at the end of the first line.

Closes #5396.
2023-04-09 20:10:09 +02:00
Robert Müller 07c59d130b Minor refactoring of DoLabel functions 2023-04-09 20:10:09 +02:00
Robert Müller 0ca6d06fba Fix incorrect text width calculation of multi-line text
For text spanning multiple lines `TextWidth` only returned the length of the last line instead of the length of the longest line.
2023-04-09 20:10:09 +02:00
Robert Müller ad69d62015 Fix long words being printed over maximum line width
When the text render encounters long words which must be broken up, ensure that the words do not exceed the maximum line width.

Closes #6354.
2023-04-09 20:09:52 +02:00
Robert Müller ede3e5631f Move generic popup handling to UI (port from editor and upstream)
Support using editor popup rendering in game client.

Support unlimited number of popup menus instead of maximum of 8.

Fix non-active popups handling key events. Add `Active` parameter to popup function, so key events are only processed by the active (top-most) popup. Previously the "New folder" popup could be confirmed with enter while an error message is shown, which causes multiple error messages to stack.

Allow popups to close without closing their child popups. Previously a popup could not open another popup and close itself immediately afterwards, as this was causing the newly opened popup to be closed instead.

Support using return/enter keys to confirm binary choice popups and to close message popups for more convenient usage.
2023-04-07 17:16:16 +02:00
bors[bot] fdcb2668e8
Merge #6502
6502: Improve editor file browser button layout when screen width is low r=def- a=Robyt3

Move "Map details" button from editor file browser to file menu.

Decrease button spacing in editor file browser when screen width is low (4:3 and 5:4 resolutions).

Screenshots:
- File menu:
   - Before: 
![file-menu old](https://user-images.githubusercontent.com/23437060/230586902-079a042d-0223-4a97-b228-ec8a4fae43d1.png)
   - After:
![file-menu new](https://user-images.githubusercontent.com/23437060/230589757-ef18d6d8-f8f0-4a2b-bc35-219349d6a7e7.png)
- File browser (800x600):
   - Before:
![save 800x600 old](https://user-images.githubusercontent.com/23437060/230591373-11b3e0c8-ce3f-4e8e-9fd1-297f8276de28.png)
   - After:
![save 800x600 new](https://user-images.githubusercontent.com/23437060/230591387-162de3fc-95e9-41ea-94a8-9b7b46ac97cb.png)
- File browser (1280x1024):
   - Before:
![save 1280x1024 old](https://user-images.githubusercontent.com/23437060/230591411-5dddd9de-4773-4dc9-a77b-61d5d4de4dc6.png)
   - After:
![save 1280x1024 new](https://user-images.githubusercontent.com/23437060/230591422-1ee8c941-9eb2-4e13-9268-de591b5b72f5.png)
- File browser (1920x1080):
   - Before:
![save 1920x1080 old](https://user-images.githubusercontent.com/23437060/230591437-146e961a-3e55-463f-988e-0d7eef92b439.png)
   - After:
![save 1920x1080 new](https://user-images.githubusercontent.com/23437060/230591445-931718f4-81fb-4c87-a018-f377a5c473df.png)

## Checklist

- [X] Tested the change ingame
- [X] 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-04-07 11:12:40 +00:00
Robert Müller 5fb9f5db5b Decrease button spacing in editor file browser when screen width low
To prevent the buttons from overlapping in 4:3 and 5:4 resolutions.
2023-04-07 12:00:09 +02:00
Robert Müller b7e8168e4b Move "Map details" button from editor file browser to file menu
There is not enought space for the button in the file browser on 4:3 and 5:4 resolutions.

The button fits in the file menu, as it allows to adjust the map details which are specific to the current map file.
2023-04-07 12:00:09 +02:00
Robert Müller 72775f236b Let CUI::Screen return a const pointer
Callers should never modify the UI screen.
2023-04-07 11:50:48 +02:00
Robert Müller eaa4e19188 Fix image/sound readding broken by error messages
When an image/sound is readded, this reuses the `ReplaceImage/Sound` callback functions. The added error handling to prevent duplicate images/sounds was causing this to not work, as the image/sound being readded was already present. The implementation is separated from the callback functions and an additional parameter is added to toggle the duplicate name check.

Previously this was hard to notice, as the error message popup was not shown due to the top-most popup being closed immediately. This will be fixed separately by a larger refactoring, so a popup can close itself immediately after opening another popup without closing the child popup instead.

Closes #6500.
2023-04-07 10:58:57 +02:00
bors[bot] b4c114450c
Merge #6492
6492: Refactor editor popups, improve layout of new folder, map details and event popups r=def- a=Robyt3

- New folder popup:
   - Before: 
![new_folder old](https://user-images.githubusercontent.com/23437060/229349012-66aa4156-7f2c-4132-9cf3-da7451f93b09.png)
   - After:
![new_folder new](https://user-images.githubusercontent.com/23437060/229349015-d53a07f8-baa4-46f6-af7d-50d302e5d784.png)
- Map details popup:
   - Before: 
![map_details old](https://user-images.githubusercontent.com/23437060/229349023-0febb078-0948-4820-bda5-98a8e560ffb8.png)
   - After:
![map_details new](https://user-images.githubusercontent.com/23437060/229349027-8cdcc47d-e71b-43f2-9f7c-533993772afd.png)
- New map event popup:
   - Before: 
![new_map old](https://user-images.githubusercontent.com/23437060/229349034-dea63fb4-0f2c-4a93-8235-ab06224d0a89.png)
   - After:
![new_map new](https://user-images.githubusercontent.com/23437060/229349039-863451ba-8154-427f-a30b-7c7e542aa0b5.png)
- Load current map popup:
   - Before: 
![load_map_current old](https://user-images.githubusercontent.com/23437060/229349045-fe8eabed-2a64-46cf-b0d7-e71c2297e0ac.png)
   - After:
![load_map_current new](https://user-images.githubusercontent.com/23437060/229349051-1877c1ec-713e-41da-b52e-19ba004b467e.png)
- Large layer popup:
   - Before: 
![large_layer old](https://user-images.githubusercontent.com/23437060/229349053-93301856-5f96-4c42-b7e1-d79afeaa9281.png)
   - After:
![large_layer new](https://user-images.githubusercontent.com/23437060/229349369-5c42c3ae-619c-4ff8-9b78-515415703bf4.png)

## Checklist

- [X] Tested the change ingame
- [X] 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-04-06 21:47:11 +00:00
Valentin Bashkirov 85485d23ce highlight game type 2023-04-05 20:02:25 +02:00
Robert Müller aa08cfabc2 Fix swapping with dragger beams and plasmas
The client ID referenced by dragger beams and plasmas must also be swapped when two clients are swapped, as those entities should refer to the same character entity as before the swap.

For dragger beams, swapping previously caused the active beams to switch target to another character.

For plasmas, swapping previously caused already shot plasmas to not have an effect on their original target character.

Closes #5865.
2023-04-04 20:07:17 +02:00
Dennis Felsing 90861d9dda Get rid of unused warning 2023-04-04 09:08:38 +02:00
VoxelDoesCode df48c44e78 Bring every Font Icon unicode into a namespace
Fix namespace hopefully
2023-04-03 20:25:28 -04:00
VoxelDoesCode 0dfced4ca4 Bring Team logic into teams.cpp
MsgPlus -> Msg
2023-04-02 21:40:39 -04:00
Robert Müller 3c841f7ad8 Refactor CEditor::PopupEntities 2023-04-02 13:16:15 +02:00
Robert Müller 9391155360 Refactor CEditor::PopupColorPicker 2023-04-02 13:16:14 +02:00
Robert Müller 8bdf2cf7a9 Refactor CEditor::PopupGoto 2023-04-02 13:16:14 +02:00
Robert Müller d5a24d718b Refactor CEditor::PopupTune 2023-04-02 13:16:14 +02:00
Robert Müller c4b2531bb1 Refactor CEditor::PopupSwitch 2023-04-02 13:16:14 +02:00
Robert Müller b839c68350 Refactor CEditor::PopupSpeedup 2023-04-02 13:16:13 +02:00
Robert Müller 04c1e06e71 Refactor CEditor::PopupSelectConfigAutoMap 2023-04-02 13:16:13 +02:00
Robert Müller 03e7cfc9e4 Refactor CEditor::PopupSelectGametileOp 2023-04-02 13:16:13 +02:00
Robert Müller c730cd490a Refactor CEditor::PopupSelectSound 2023-04-02 13:16:12 +02:00
Robert Müller f3f44ca6b2 Refactor CEditor::PopupSelectImage 2023-04-02 13:16:12 +02:00
Robert Müller b20cf7865c Refactor CEditor::PopupEvent and improve layout
Swap buttons so confirm button is on the right and cancel button is on the left consistently.

Decrease empty space and popup size.

Add missing title for `POPEVENT_LOADCURRENT` (caught by the added assertion).

Improve messages by adding additional empty line for existing line breaks.
2023-04-02 13:16:12 +02:00
Robert Müller 91ce99b65b Refactor CEditor::PopupSound 2023-04-02 12:54:36 +02:00
Robert Müller 7289f7d504 Refactor CEditor::PopupImage 2023-04-02 12:54:36 +02:00
Robert Müller e09a771937 Refactor CEditor::PopupPoint 2023-04-02 12:54:36 +02:00
Robert Müller 04d9e2b54a Refactor CEditor::PopupMapInfo and improve layout
Swap buttons so confirm button is on the right and cancel button is on the left consistently.

Decrease empty space and popup size.
2023-04-02 12:54:36 +02:00
Robert Müller 141571cc55 Refactor CEditor::PopupNewFolder and improve layout
Swap buttons so confirm button is on the right and cancel button is on the left consistently.

Decrease empty space and popup size.
2023-04-02 12:54:35 +02:00
Robert Müller 5cfecdb42f Refactor CEditor::PopupSource 2023-04-02 12:54:35 +02:00
Robert Müller 2146d7bd92 Refactor CEditor::PopupQuad 2023-04-02 12:54:35 +02:00
Robert Müller 9f5de0c884 Refactor CEditor::PopupLayer 2023-04-02 12:54:35 +02:00
Robert Müller eda808e385 Refactor CEditor::PopupGroup 2023-04-02 12:54:35 +02:00
Robert Müller c1ffc8bf12 Refactor CEditor::PopupMenuFile 2023-04-02 12:54:34 +02:00
Robert Müller df91bb9b43 Refactor layer properties functions 2023-04-02 12:54:34 +02:00
Robert Müller c6d14e5fa1 Move all editor popup function definitions to popups.cpp
Editor code for the popups should be located in `popups.cpp`.
2023-04-02 12:52:37 +02:00
Robert Müller caac7b06e2 Fix static usage of POPEVENT_* enum literals
The `POPEVENT_*` enum literals should be used in a static manner.
2023-04-02 12:52:37 +02:00
Robert Müller 3d343c8758 Remove unnecessary popup debug message 2023-04-02 12:52:37 +02:00
Robert Müller f4c3fee617 Use ShowFileDialogError instead of ShowPopupMessage
To reduce duplicate code.
2023-04-02 12:52:37 +02:00
Dennis Felsing 1b1f2a0621 Version 16.9 2023-04-02 12:03:41 +02:00
bors[bot] 3bd24f322f
Merge #6490
6490: Improve collision entity access error message r=Chairn a=Robyt3

See #6489.

## Checklist

- [X] 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-04-01 22:29:29 +00:00
Robert Müller ed26be0917 Improve collision entity access error message
See #6489.
2023-04-02 00:03:30 +02:00
Robert Müller ab73cc718f Refactor entity bounds check 2023-04-02 00:01:17 +02:00
ChillerDragon fd437e0f76 Apache RequestHeader needs the headers module 2023-04-01 16:35:09 +02:00
Dennis Felsing 5fa2fefd35 Remove unused DoFilter
Thanks to cheeser0613
2023-04-01 13:39:20 +02:00
bors[bot] 02086e4023
Merge #6268
6268: Quit when configured bindaddr cannot be resolved, quit client when failing to open network client for 25 times  r=def- a=Robyt3



## Checklist

- [X] 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-03-31 15:44:26 +00:00
Jupeyy ffe3d26e59 fix start size of freezing flakes particles & vel of player death 2023-03-28 21:33:48 +02:00
bors[bot] a27dbb1219
Merge #6435
6435: add proof mode for menu backgrounds closes #3009 r=def- a=Marmare314


![backgroundproof](https://user-images.githubusercontent.com/49279081/225979288-3fb43d41-79f7-477e-8479-6b3d106fbd5b.gif)

## Checklist

- [x] Tested the change ingame
- [x] 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
- [x] Considered possible null pointers and out of bounds array indexing
- [x] 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: marmare314 <49279081+Marmare314@users.noreply.github.com>
2023-03-27 14:48:18 +00:00
marmare314 927c80167f update selected layer correctly after dragging 2023-03-27 09:13:39 +02:00
marmare314 93d204f0ca show duplicate positions in tooltip 2023-03-27 08:51:02 +02:00
VoxelDoesCode 5b1a716aa2 Simplify KillMsgTeams NetMsg, fixing bugs
Clang format before squash

Split apart OnMessage() before squash

forgot something
2023-03-26 23:32:34 -04:00
bors[bot] e3575b1ae8
Merge #6469
6469: Add new contributor r=Robyt3 a=def-

<!-- What is the motivation for the changes of this pull request? -->

<!-- Note that builds and other checks will be run for your change. Don't feel intimidated by failures in some of the checks. If you can't resolve them yourself, experienced devs can also resolve them before merging your pull request. -->

## 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-03-26 16:14:00 +00:00
bors[bot] b207826df1
Merge #6470
6470: Fix ninja not getting predicted r=heinrich5991 a=Zwelf

Fixes #6464

This was regressed by #6246 by the wrong transformation of `if(!m_FreezeTime)` to `if(m_FreezeTime != 0)` instead of the correct `if(m_FreezeTime == 0)`.

And take additional measure to never set m_FreezeTime to a negative number in client prediction code.

## Checklist

- [x] 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: Zwelf <zwelf@strct.cc>
2023-03-26 14:50:25 +00:00
Zwelf d40ff12d9a Fix ninja dash not getting predicted correctly
Fixes #6464

This was regressed by #6246 by the wrong transformation of `if(!m_FreezeTime)`
to `if(m_FreezeTime != 0)` instead of the correct `if(m_FreezeTime == 0)`.

And take additional measure to never set m_FreezeTime to a negative
number in client prediction code.
2023-03-26 16:42:31 +02:00
Dennis Felsing 6b0656ff85 Add new contributor 2023-03-26 16:28:06 +02:00
bors[bot] a9674afb02
Merge #6451 #6466
6451: Fix `console_enable_colors` not being used, save `console_output_level` and `console_enable_colors` variables r=def- a=Robyt3

Closes #6447.

## Checklist

- [X] 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)


6466: Fix rcon login when disconnecting dummy and when username used r=def- a=Robyt3

When connecting a dummy and then logging into rcon only the dummy is logged in. When disconnecting the dummy, the main client was not automatically logged in. When logging in with the main client and then connecting the dummy, the dummy was already authenticated automatically. Now the main client is also authenticated automatically when disconnecting an authenticated dummy.

This automatic authentication was also not working correctly if the login used a username, as only the password was stored. Now both username and password are stored to correctly authenticate the main or dummy client.

The stored username and password are completely cleared when disconnecting, so they are not stored in memory longer than necessary.

Closes #5586.

## Checklist

- [X] 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-03-26 12:59:00 +00:00
bors[bot] 0cf6f15590
Merge #6461
6461: Check if HTTP request task is aborted in completion callback r=def- a=Robyt3

It's possible for the HTTP request task to be aborted after the curl request has finished, so the returned `State` will be `HTTP_DONE` but `m_Abort` is `true`. The `State` never changes to `HTTP_ABORTED`, because the progress callback is not called after the HTTP request has completed.

This causes the client to crash when a skin download is aborted after the HTTP request finished but before the completion callback is called.

This is fixed by checking if `m_Abort` is `true` and setting the `State` to `HTTP_ABORTED` at the beginning of the completion callback.

Closes #3567.

## Checklist

- [X] 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-03-26 12:40:47 +00:00
Robert Müller 7bc17b2bd8 Fix rcon login when disconnecting dummy and when username used
When connecting a dummy and then logging into rcon only the dummy is logged in. When disconnecting the dummy, the main client was not automatically logged in. When logging in with the main client and then connecting the dummy, the dummy was already authenticated automatically. Now the main client is also authenticated automatically when disconnecting an authenticated dummy.

This automatic authentication was also not working correctly if the login used a username, as only the password was stored. Now both username and password are stored to correctly authenticate the main or dummy client.

The stored username and password are completely cleared when disconnecting, so they are not stored in memory longer than necessary.

Closes #5586.
2023-03-26 14:00:50 +02:00
Robert Müller 1b19895204 Ensure texture is cleared when rendering MOTD background
Seems like there are cases where the texture is not cleared when the MOTD background is rendered, so part of the font texture is used for the round rect.
2023-03-26 13:15:36 +02:00
bors[bot] 214053ec9a
Merge #6459
6459: Add random skin button r=def- a=HiRavie

Adds a button for generating a random skin in tee settings. The logic generates handsome tees more often than not.
Intentionally didn't add a console command so it's not possible to make annoying skin change binds with this.
![random_skin](https://user-images.githubusercontent.com/65019210/227658839-5e8f3a4b-4e7c-4561-90c9-21a267d61a3a.png)

## Checklist

- [x] Tested the change ingame
- [x] Provided screenshots if it is a visual change
- [x] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [x] Considered possible null pointers and out of bounds array indexing
- [x] 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: Ravie <65019210+HiRavie@users.noreply.github.com>
2023-03-25 23:08:15 +00:00
Robert Müller fda8507d03 Add "Delete" button to editor file browser
To delete files and empty folders from the user's save directory.

Only files and folders from the user's save directory can be deleted. Only empty folders can be deleted.

Error message popups are shown when the deletion fails.

Closes #6272.
2023-03-25 16:59:02 +01:00
Robert Müller 6f1533ee18 Group UI code of right and left editor file dialog buttons
Move UI code for "New folder" button close to the code the "Map details" button.
2023-03-25 16:58:51 +01:00
Robert Müller fd98ed0295 Add IStorage::RemoveFolder
Wrapper for `fs_removedir`.
2023-03-25 16:58:51 +01:00
bors[bot] f2df34847b
Merge #6460
6460: Replace usage of `fmodf` with `std::fmod` r=heinrich5991 a=Robyt3

Leftover from #6372.

## 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-03-25 15:24:59 +00:00
Ravie 20ac914e0e Tooltip ID 2023-03-25 16:13:29 +01:00
Ravie eb41ecf3d7 Icon button, tooltip and various fixes 2023-03-25 15:43:25 +01:00
Robert Müller aa0ad18f1b Refactor net_set_blocking and net_set_non_blocking
Reduce duplicate code by using loop and by merging implementation of `net_set_blocking` and `net_set_non_blocking`.
2023-03-25 15:36:50 +01:00
Ravie 705be7c6e3 Implement random skin button 2023-03-25 13:11:47 +01:00
Robert Müller ddb21ec49e Check if HTTP request task is aborted in completion callback
It's possible for the HTTP request task to be aborted after the curl request has finished, so the returned `State` will be `HTTP_DONE` but `m_Abort` is `true`. The `State` never changes to `HTTP_ABORTED`, because the progress callback is not called after the HTTP request has completed.

This causes the client to crash when a skin download is aborted after the HTTP request finished but before the completion callback is called.

This is fixed by checking if `m_Abort` is `true` and setting the `State` to `HTTP_ABORTED` at the beginning of the completion callback.

Closes #3567.
2023-03-25 12:43:19 +01:00
Robert Müller 3c3a8021d2 Replace usage of fmodf with std::fmod
Leftover from #6372.
2023-03-25 10:28:26 +01:00
bors[bot] 6808b62b74
Merge #6457
6457: Fix and improve twping tool r=def- a=Robyt3



## Checklist

- [X] 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-03-24 08:02:47 +00:00
Robert Müller f4ee220395 Show twping timeout if no ping response is received, add exit code
Return exit code `0` if ping successful. Return `1` if timeout. Return `-1` if incorrect argument.
2023-03-23 23:26:07 +01:00
Robert Müller 71976256d8 Refactor twping variables 2023-03-23 23:11:30 +01:00
Robert Müller fae9ed1b5e Add missing initialization to twping
The tool doesn't work without initializing secure random and network.
2023-03-23 23:07:47 +01:00
Robert Müller 7c7d3b7732 Use logger instead of <cstdio> in twping 2023-03-23 23:06:49 +01:00
Robert Müller 156a1e9d14 Quit client when failing to open network client for 25 times
Prevent endless loop when client fails to open network client forever, by quitting the client after 25 failed attempts.

As described in #5555, although it doesn't fix the actual issue.
2023-03-23 21:36:04 +01:00
Robert Müller 85f5e9c5f9 Quit when configured bindaddr cannot be resolved
Quit client and server if the configured bindaddr cannot be resolved.

Disable econ if configured bindaddr cannot be resolved.

To ensure that the configured bindaddr is not silently ignored.
2023-03-23 21:34:07 +01:00
Robert Müller 2c518f2778 Remove redundant return value and rename method
Rename `LoadData` to `LoadDebugFont` so it's clearer what the method does.

The return value that is always `1` and not checked in some cases is removed.
2023-03-23 21:07:22 +01:00
Robert Müller 880ced2de0 Fix dummy tee being able to ping main tee in chat
Main and dummy tee cannot ping each other anymore. Other main and dummy tees can still ping your own main and dummy tees.

We must ensure to only use `m_aLocalIDs[1]` when the dummy is connected, as this ID is not updated when no dummy is connected, so it can refer to another client if you disconnect your dummy and another client subsequently takes its client ID.

Closes #3699.
2023-03-23 20:24:28 +01:00
bors[bot] 971b166488
Merge #6439
6439: Refactor `random` functions r=heinrich5991 a=Robyt3



## 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-03-23 12:56:55 +00:00
Dennis Felsing 5252667204 Round by millisecond, not centisecond (fixes #6453)
Some servers seem to allow times with millisecond precision, official
DDNet doesn't, so never noticed this issue.
2023-03-23 09:47:48 +01:00
Robert Müller 9f3c59000e Save console_output_level and console_enable_colors variables 2023-03-22 22:16:53 +01:00
Robert Müller 6760532491 Fix console_enable_colors not being used 2023-03-22 22:11:47 +01:00
bors[bot] 8057d591db
Merge #6449
6449: Select language on first start based on user locale r=heinrich5991 a=Robyt3

Closes #2459.

## Checklist

- [X] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [X] Tested in combination with possibly related configuration options
- [X] Written a unit test (especially base/) or added coverage to integration test
- [X] Considered possible null pointers and out of bounds array indexing
- [X] 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-03-21 20:52:04 +00:00
Robert Müller a91b51c8a2 Select language on first start based on user locale
On first client start (when `cl_show_welcome` is `1`), determine the user locale with `os_locale_str` and initially select the most fitting language for this locale.

For this the language index must also be loaded immediately on client launch, before the initial language is loaded.
2023-03-21 21:17:40 +01:00
Robert Müller cddbc78592 Add RFC 3066 language tags to language index
Add RFC 3066 language tags to language index in order to identify the language to select when first starting the game based on the user's locale.

Multiple language tags can be specified per entry separated with a semicolon, as some languages have different tags that do not share a unique prefix (e.g., Simplified and Traditional Chinese).
2023-03-21 21:17:40 +01:00
Robert Müller 481698c7d0 Move CLanguage and LoadLanguageIndexfile to localization
The `CLanguage` class and `LoadLanguageIndexfile` function are more appropriately located in the file for the other localization functions.
2023-03-21 21:17:40 +01:00