5179: Add loglevel config (fixes#5178, fixes#5174) r=heinrich5991 a=def-
<!-- What is the motivation for the changes of this pull request -->
## 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 if it works standalone, system.c especially
- [ ] 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: def <dennis@felsin9.de>
5271: Time out for POST requests too (hopefully fixes#5198) r=heinrich5991 a=def-
Untested because the issue is sporadic. But I think it makes sense to have a timeout even if this is not the root cause.
## 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 if it works standalone, system.c especially
- [ ] 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: def <dennis@felsin9.de>
5277: penalty tiles can be used to get a time of 00:00:01, this is fixed by letting the tees die, before that happens r=def- a=C0D3D3V
Also map gets reloaded if the server tick overflows. We could add a warning, that the server reloads soon, or save all players and load them after map reload. But I think that is such a rare event, we can just reload the map without these nice things.
fixes#5170
we should check the following maps for cheated times:
- just every fly
- puzzle partners
- time shop
## Checklist
- [x] Tested the change ingame See https://youtu.be/lQPU60XN8Nk
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [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: c0d3d3v <c0d3d3v@mag-keinen-spam.de>
5280: fix swap does not swap no collision and no hook r=def- a=C0D3D3V
- remove duplicated variable for no collision and no hook
fixes https://github.com/ddnet/ddnet/issues/5279https://youtu.be/3VM64OVNgYM
I chose the no variables because I found them more meaningful than the one without no. Furthermore, the initialisation with false corresponds to the standard initialisation.
## 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 if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [x] 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: c0d3d3v <c0d3d3v@mag-keinen-spam.de>
5276: Organize includes: Include only what's necessary and only where necessary r=def- a=Robyt3
I used https://github.com/include-what-you-use/include-what-you-use to find unused includes and then manually adjusted their usages.
Why? See https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md. This PR removes unused includes or moves the includes so they are used where necessary, to achieve the first two benefits listed there.
Eventually IWYU could be used to also add all includes that are transitively needed (thereby doing what the tool name implies), so refactoring could be made easier, as the includes of every file would be independent from those of other files.
We can have a separate discussion about organizing the includes further. For example how includes should be grouped and how those groups should be ordered. Right now clang-format just enforces alphabetical ordering for all includes in a group. Also to what extent should forward-declarations be used instead of includes.
IWYU usage after compiling and adding it to the path:
```
mkdir build
cd build
CC="clang" CXX="clang++" cmake -G "Unix Makefiles" -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-Xiwyu;--no_comments;-Xiwyu;--no_fwd_decls;-Xiwyu;--quoted_includes_first" -B . ..
make 2> iwyu.log
```
Adding IWYU to the CI would likely be too much effort, as the changes that IWYU proposes need to be manually reviewed, as there are some false-positives, especially with conditional includes/usages of includes.
## 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 if it works standalone, system.c especially
- [ ] 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>
5272: Handle failed socket creation (fixes#5267) r=heinrich5991 a=def-
by returning nullpointer, as the calling functions expect
Broken in 471bb441a1
<!-- What is the motivation for the changes of this pull request -->
## 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 if it works standalone, system.c especially
- [ ] 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: def <dennis@felsin9.de>
5269: Introduce and use constexpr CCharacterCore::PhysicalSize r=def- a=Kaffeine
Add `Collision()` getter to server CEntity to make it easier to sync the server and prediction implementations (e.g. `IsGrounded()` imps are now identical).
## 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 if it works standalone, system.c especially
- [ ] 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: Alexander Akulich <akulichalexander@gmail.com>
5268: Execute the dragger_beam tick one tick earlier. And stop it one tick earlier r=def- a=C0D3D3V
fixes#5263
`@bencie` could you please confirm it fixes the problem?
## 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 if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [x] 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: c0d3d3v <c0d3d3v@mag-keinen-spam.de>
5264: Prevent users from setting port 1-1023 r=Jupeyy a=def-
Following user report that they set cl_port 1 and it didn't work
<!-- What is the motivation for the changes of this pull request -->
## 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 if it works standalone, system.c especially
- [ ] 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)
5266: Use std::make_unique (fixes#5166) r=Jupeyy a=def-
No idea why clang-tidy's modernize-... didn't work
<!-- What is the motivation for the changes of this 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 if it works standalone, system.c especially
- [ ] 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: def <dennis@felsin9.de>
5265: Cleanup prediction entity handling a little r=def- a=trml
I looked over the remaining code for creating/removing entities in the prediction, and only ended up making some smaller changes:
- More consistent use of InsertEntity/RemoveEntity/Destroy
- Fixed one instance in gameclient.cpp where an entity was removed but not deleted (could potentially have been a memory leak)
- Removed some old code for retaining information about the characters after they left the snapshot (the client should only rely on the snapshot for prediction of players)
## 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 if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [x] 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: trml <trml@users.noreply.github.com>
5252: Use std::vector instead of array, remove base/tl/array.h, algorithm.h, allocator.h, range.h r=def- a=Robyt3
Replaces all usages of `array` with `std::vector`.
I adjusted variable names of variables I changed to use the `v` prefix. Not so in the editor however, as there are already many changes due to clang-tidy enforcing the use of for-each loops.
This allows us to remove all remaining `base/tl` headers except `threading.h`.
Clang-tidy now finds `clang-analyzer-cplusplus.NewDelete` (Use of memory after it is freed), which is also fixed here, though it appears to be a false-positive.
This last remaining usages of `goto` are also removed.
## 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 if it works standalone, system.c especially
- [ ] 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>
5262: Remove alpha threshold from map_optmize r=def- a=Jupeyy
Since it was removed from dilate's copy values, and also makes more sense anyway.
Images should always be identifiable by all visible pixels
## 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 if it works standalone, system.c especially
- [ ] 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: Jupeyy <jupjopjap@gmail.com>
5261: Fix possible misuse of comma r=def- a=Chairn
Found with -Wcomma using clang.
## 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 if it works standalone, system.c especially
- [ ] 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: Chairn <chairn.nq@hotmail.fr>
5259: reintroduce shotgun bug r=def- a=C0D3D3V
fixes#5258
bug got fixed by the math changes in 68bcd21eff
This fix introduces a hard coded velocity that the player would get like before. (It could be that this has slightly other behaviour, because before the produced NaN values where converted to ints in CCharacterCore::Quantize (so some other logic may be confronted with the NaN values before), but it should most likely not be noticeable because it is fast enough)
We could now make this bug optional, by adding it to our mapbugs, or adding a server setting for it.
## 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 if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [x] 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: c0d3d3v <c0d3d3v@mag-keinen-spam.de>
5255: fix windows server crash on client spawn r=def- a=C0D3D3V
The continuation of removing mem_zero over CCharacterCore.
I have tested the server in a Windows VM -> no crash
## 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 if it works standalone, system.c especially
- [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: c0d3d3v <c0d3d3v@mag-keinen-spam.de>
5254: Fix ingame menu button behavior when holding mouse button r=def- a=Robyt3
Fixes the following behavior:
1. Player is ingame and the ingame menu is opened with Esc
2. A mouse button is held down on one of the ingame menu buttons (e.g. the spectate button)
3. The ingame menu is closed without moving the mouse away from the button
4. The mouse button is released while ingame
5. The menu is opened again
- Current behavior: The hovered button is immediately activated, as soon as the menu opens, due to the released mouse state being handled as a click.
- Fixed behavior: The button is not activated. Instead another call to `FinishCheck` is added so it's also called when the menu is not active, to clear the active UI item in that case.
As well as the following:
1. The menu is closed while the mouse cursor is hovering over a button.
2. The mouse button is pressed and held while the menu is closed.
3. The menu is opened again.
- Current behavior: The menu button is already held down and when the player releases the mouse button it will immediately be activated.
- Fixed behavior: The button is not activated immediately, by clearing the hot item and next hot item variables in `FinishCheck`.
The latter behavior can still occur when entering the editor instead of closing the ingame menu.
Closes#3560. Closes#5229.
The first two commits are identical to upstream https://github.com/teeworlds/teeworlds/pull/3158, where those issues also exist. The last commit adapts upstream behavior so buttons can only become hot when the mouse is not pressed.
## 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 if it works standalone, system.c especially
- [ ] 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)
5257: Refactoring: Move CMenus::UseMouseButtons to CUI::SetEnabled, extract CRenderTools::RenderCursor r=def- a=Robyt3
Adopt changes from upstream.
## 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 if it works standalone, system.c especially
- [ ] 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>