Commit graph

14573 commits

Author SHA1 Message Date
Robert Müller c6e195a399 Use std::vector<CNameBan> instead of array 2022-05-27 16:31:18 +02:00
Robert Müller 4a023342b7 Use std::vector<CName> instead of array, adjust variable name 2022-05-27 16:31:18 +02:00
Robert Müller ce54a0d075 Use std::vector<CMenuImage> instead of array 2022-05-27 16:31:18 +02:00
Robert Müller 24ad383211 Use std::vector<CSourceQueueEntry> instead of array 2022-05-27 16:31:18 +02:00
Robert Müller d3eb9d6fe7 Use std::vector<std::string> instead of array 2022-05-27 16:31:18 +02:00
Robert Müller 0f097a0490 Use std::vector<char *> instead of array in gamecontext 2022-05-27 12:13:30 +02:00
Robert Müller 80103888ea Use std::vector<char *> instead of array in config_store 2022-05-27 12:13:30 +02:00
bors[bot] 7348bf4d56
Merge #5246
5246: Use std::vector instead of sorted_array, remove base/tl/sorted_array.h r=def- a=heinrich5991

This replaces all usages of `sorted_array` with `std::vector`. This requires the following general changes:

- `add_unsorted` is replaced with `push_back`.
- `add` is replaced with `push_back` and subsequent `sort` or `stable_sort` must be ensured.
  - In some cases, immediately sorting the entire list after adding an item was unavoidable. Previously items were added at the correct position, which was O(N) because all items after the inserted one had to be moved in any case.
- `sort_range` is replaced with `sort` or `stable_sort`.
- `size` returns a `size_t` instead of `int`, so to fix sign comparison warnings, casts are added where necessary or types of loop variables are changed to `size_t` where possible. For-each loops are also used where possible / where required by clang-tidy.
- `find_binary` is replaced with `std::equal_range`. This can only find items of the same type, so some wrappers, that only have the relevant fields set, need to be created for searching.

In terms of behavior, this should not change anything, except maybe `CLocalizationDatabase` for the better. As far as I understand it, at lot of the code there was not doing anything. It assumes that binary search can return a range of multiple entries, but the equality/comparison function is based on hash and context hash. This means that any item in this range will match the given hash and context hash already, so all of the following checks are redundant. I changed this to first do a lookup with the hash and context hash and if that fails do another lookup with the default context hash.

I have also already replaced `base/tl/array.h` with `std::vector`, removing all of `base/tl` except `threading.h`. I'll make a separate PR later because this caused a lot more changes especially in the editor that I first want to test and review myself.

Naming of `array`/`sorted_array`/`std::vector` variables was rather inconsistent (sometimes prefix `a` or `l` is used), so ~~I chose to not use any prefix for all new `std::vector`s~~ heinrich5991 left them as-is.

## 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>
2022-05-27 08:51:55 +00:00
bors[bot] 61c81fa0f2
Merge #5240
5240: Fix crash when graphics init failed (fixes #5237) r=heinrich5991 a=def-

## 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: Dennis Felsing <dennis@felsin9.de>
2022-05-26 22:17:15 +00:00
Robert Müller de1de5e7bd Use emplace_back for CFriendItem 2022-05-27 00:14:07 +02:00
Robert Müller 476af1286d Use emplace_back for CCommand, fix member variable names 2022-05-27 00:13:26 +02:00
Robert Müller d0b5d096f5 Use emplace_back for CString 2022-05-27 00:03:13 +02:00
Robert Müller bea74f3d4f Remove base/tl/sorted_array.h 2022-05-27 00:03:13 +02:00
Robert Müller a76cdb254e Use std::vector<CDownloadSkin> instead of sorted_array 2022-05-27 00:03:13 +02:00
Robert Müller 0859da7e6a Use std::vector<CSkin> instead of sorted_array 2022-05-27 00:03:13 +02:00
Robert Müller ae8f5e87c7 Use std::vector<CNameIndexed> instead of sorted_array 2022-05-27 00:03:13 +02:00
Robert Müller 5cc76d286f Use std::vector<CGhostItem> instead of sorted_array 2022-05-27 00:03:13 +02:00
Robert Müller b24f318450 Use std::vector<CFriendItem> instead of sorted_array 2022-05-27 00:03:13 +02:00
Robert Müller de23bf912d Use std::vector<CString> instead of sorted_array, improve string search 2022-05-27 00:03:13 +02:00
Robert Müller 359093cab8 Use std::vector<CDemoItem> instead of sorted_array 2022-05-27 00:03:13 +02:00
Robert Müller 96c97d5bb7 Use std::vector for assets menu list items instead of sorted_array 2022-05-26 23:49:30 +02:00
Robert Müller 2ea0c49f8b Use std::vector<CCommand> instead of sorted_array 2022-05-26 23:49:30 +02:00
Robert Müller 662cb58132 Use std::vector<CFilelistItem> instead of sorted_array 2022-05-26 23:49:30 +02:00
Robert Müller 0032f6f2c2 Use std::vector<CCountryFlag> instead of sorted_array 2022-05-26 23:49:27 +02:00
Robert Müller 295c395c8c Use std::vector<CUISkin> instead of sorted_array 2022-05-26 23:47:37 +02:00
bors[bot] 551275af78
Merge #5235
5235: Enable less controversial cppcoreguidelines clang-tidy checks r=heinrich5991 a=def-

<!-- 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: Dennis Felsing <dennis@felsin9.de>
2022-05-26 21:45:56 +00:00
Robert Müller 97dd8105fd Use std::vector<CLanguage> instead of sorted_array 2022-05-26 23:42:06 +02:00
Robert Müller 9dece943e7 Use std::vector<CMapNameItem> instead of sorted_array 2022-05-26 23:42:06 +02:00
Robert Müller 9b2f0fe3c4 Remove unused includes of base/tl/array.h and sorted_array.h 2022-05-26 23:42:06 +02:00
bors[bot] 0648f22d7a
Merge #5236
5236: Don't enable colors when stdout is redirected to a file (fixes #5233) 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: Dennis Felsing <dennis@felsin9.de>
2022-05-26 21:24:38 +00:00
bors[bot] e63b8e2bb5
Merge #5183
5183: render allways the nameplate of a specchar (or the real player) r=def- a=C0D3D3V

fokkonaut uses spec chars in addition to normal players in his mod, so the names should also be displayed in addition to the player name

## 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>
2022-05-26 21:06:19 +00:00
bors[bot] 74b94b3e71
Merge #5245
5245: disable dragger beams soon, not only every 150ms r=def- a=C0D3D3V

The check whether a dragger is active, I somehow forgot in the dragger beams. Sorry! Actually, I should have noticed this during testing. But when I tested Fall into the Future today, it seemed strange to me (already at the first part). I should have noticed it when I tested it. I have compared that in any case with 15.9.1 and looked at the code again and saw that there the check is made every tick.


## 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>
2022-05-26 20:47:48 +00:00
c0d3d3v 62c99515d5
disable dragger beams soon, not only every 150ms 2022-05-26 19:49:51 +02:00
bors[bot] aa5471f98d
Merge #5244
5244: Remove predicted character from gameworld before calling base class d… r=Jupeyy a=trml

…estructor

cc #5241

I believe this fixes #5238. Edit: Seems to fix #5239 as well (no longer crashes in OnPredict while being in a map and zooming in/out).

After looking at the code I think it could need a larger cleanup (and Im not 100% happy with this solution), so I plan to look more into this and the related code afterwards.

## 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: trml <trml@users.noreply.github.com>
2022-05-26 17:36:42 +00:00
trml 2402edcb8a Remove predicted character from gameworld before calling base class destructor 2022-05-26 19:08:46 +02:00
Dennis Felsing ac2657bfce Fix crash when graphics init failed (fixes #5237) 2022-05-26 13:04:39 +02:00
Dennis Felsing d2e9a78483 Don't enable colors when stdout is redirected to a file (fixes #5233) 2022-05-26 12:32:24 +02:00
Dennis Felsing f3123086f8 Add portability-* clang-tidy checks 2022-05-26 12:18:56 +02:00
Dennis Felsing e3f27b6897 Enable less controversial cppcoreguidelines clang-tidy checks 2022-05-26 12:13:36 +02:00
bors[bot] 3b81157013
Merge #5231
5231: Fix windows crash r=def- a=C0D3D3V

Fixes #5226

I tested it in a Windows VM.
`@sjrc6` is it correct that `TempCore` is this way zero initialized, can you check that maybe in the debugger? I do not want to change the behaviour, even tho the core is read in two lines later with `TempCore.ReadCharacter(pCharacter);`

## 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>
2022-05-26 08:57:22 +00:00
c0d3d3v 62cad6ba51
use value initialization in Evolve lambda 2022-05-26 08:26:27 +02:00
c0d3d3v cf03ada052
revert to SetHookedPlayer in ReadCharacterCore 2022-05-26 07:45:34 +02:00
bors[bot] 8e3d5c1b59
Merge #5006
5006: Add integration test script and coverage map r=heinrich5991 a=ChillerDragon

The ``scripts/integration_test.sh`` runs two clients and one server. Lets the two clients connect for a few seconds.
The goal is to get some automated runtime tests. Even tho the the two clients do not move they will touch a few gametiles by falling through them. This covers a few basic game mechanics like: freeze, draggers, bullets, solo, shields, tele, speedup, collision, player collision and map finishes.

This pr adds a new directory ``test/`` at the root of the repository. Holding a test map. (not sure if thats cool 🤷 )

The script can be run locally using ``scripts/integration_test.sh [build directory]`` using ``build`` as a default. It will catch client/server crashes and check if sqlite ranks are inserted. If built with asan/ubsan it will catch these errors too. Probably not too useful for local testing since it most likely will not cover the currently developed features.

In the CI it will use a ASan + UBSan build directory and thus catch all basic issues caused by simple  client server interaction.

![image](https://user-images.githubusercontent.com/20344300/163870637-acc5b16d-042b-407a-b223-febcd2565c97.png)


Co-authored-by: Dennis Felsing <dennis@felsin9.de>
Co-authored-by: ChillerDrgon <ChillerDragon@gmail.com>
2022-05-25 23:44:46 +00:00
Dennis Felsing e3116217de test -> integration_test 2022-05-26 01:34:18 +02:00
bors[bot] f7434be778
Merge #5219
5219: macOS fixes r=heinrich5991 a=def-

```
ld64.lld: warning: /opt/homebrew/opt/freetype/lib/libfreetype.6.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/opt/freetype/lib/libfreetype.6.dylib
ld64.lld: warning: /usr/local/lib/libGLEW.2.2.0.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /usr/local/lib/libGLEW.2.2.0.dylib
ld64.lld: warning: /opt/homebrew/Cellar/wavpack/5.4.0/lib/libwavpack.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/Cellar/wavpack/5.4.0/lib/libwavpack.dylib
ld64.lld: warning: /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libavformat.59.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libavformat.59.dylib
ld64.lld: warning: /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libavcodec.59.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libavcodec.59.dylib
ld64.lld: warning: /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libavutil.57.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libavutil.57.dylib
ld64.lld: warning: /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libswscale.6.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libswscale.6.dylib
ld64.lld: warning: /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libswresample.4.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libswresample.4.dylib
ld64.lld: warning: /opt/homebrew/Cellar/opusfile/0.12/lib/libopusfile.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/Cellar/opusfile/0.12/lib/libopusfile.dylib
ld64.lld: warning: /opt/homebrew/Cellar/opus/1.3.1/lib/libopus.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/Cellar/opus/1.3.1/lib/libopus.dylib
ld64.lld: warning: /opt/homebrew/Cellar/libogg/1.3.5/lib/libogg.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/Cellar/libogg/1.3.5/lib/libogg.dylib
ld64.lld: error: undefined symbol: ___glewBindSampler
>>> referenced by CMakeFiles/DDNet.dir/src/engine/client/backend/opengl/backend_opengl.cpp.o

ld64.lld: error: undefined symbol: ___glewBindSampler
>>> referenced by CMakeFiles/DDNet.dir/src/engine/client/backend/opengl/backend_opengl.cpp.o
[...]
```
<!-- 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: Dennis Felsing <dennis@felsin9.de>
2022-05-25 23:28:29 +00:00
Dennis Felsing 68bcd21eff asan+ubsan clean 2022-05-26 01:22:14 +02:00
ChillerDrgon 05efc25f32 Add integration test script and coverage map 2022-05-26 00:37:45 +02:00
Dennis Felsing 604142da3a Try other fix for tautological 2022-05-26 00:37:33 +02:00
Dennis Felsing 3a231b07e1 Fix new Obj-C deprecation warnings
src/macos/server.mm:74:29: warning: 'NSOKButton' is deprecated: first deprecated in macOS 10.10 [-Wdeprecated-declarations]
                        if([openDlg runModal] != NSOKButton)
                                                 ^~~~~~~~~~
                                                 NSModalResponseOK
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSPanel.h:51:5: note: 'NSOKButton' has been explicitly marked deprecated here
    NSOKButton API_DEPRECATED_WITH_REPLACEMENT("NSModalResponseOK", macos(10.0,10.10)) = NSModalResponseOK,
    ^
src/macos/server.mm:90:14: warning: 'NSTitledWindowMask' is deprecated: first deprecated in macOS 10.12 [-Wdeprecated-declarations]
                styleMask: NSTitledWindowMask
                           ^~~~~~~~~~~~~~~~~~
                           NSWindowStyleMaskTitled
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:885:32: note: 'NSTitledWindowMask' has been explicitly marked deprecated here
static const NSWindowStyleMask NSTitledWindowMask API_DEPRECATED_WITH_REPLACEMENT("NSWindowStyleMaskTitled", macos(10.0,10.12)) = NSWindowStyleMaskTitled;
                               ^
src/macos/server.mm:91:5: warning: 'NSClosableWindowMask' is deprecated: first deprecated in macOS 10.12 [-Wdeprecated-declarations]
                | NSClosableWindowMask
                  ^~~~~~~~~~~~~~~~~~~~
                  NSWindowStyleMaskClosable
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:886:32: note: 'NSClosableWindowMask' has been explicitly marked deprecated here
static const NSWindowStyleMask NSClosableWindowMask API_DEPRECATED_WITH_REPLACEMENT("NSWindowStyleMaskClosable", macos(10.0,10.12)) = NSWindowStyleMaskClosable;
                               ^
src/macos/server.mm:92:5: warning: 'NSMiniaturizableWindowMask' is deprecated: first deprecated in macOS 10.12 [-Wdeprecated-declarations]
                | NSMiniaturizableWindowMask
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
                  NSWindowStyleMaskMiniaturizable
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:887:32: note: 'NSMiniaturizableWindowMask' has been explicitly marked deprecated here
static const NSWindowStyleMask NSMiniaturizableWindowMask API_DEPRECATED_WITH_REPLACEMENT("NSWindowStyleMaskMiniaturizable", macos(10.0,10.12)) = NSWindowStyleMaskMiniaturizable;
                               ^
4 warnings generated.
2022-05-26 00:37:33 +02:00
Dennis Felsing 64e6ba55a1 Increase macOS target version to 10.13
src/game/client/components/tooltips.cpp:58:39: error: 'value' is unavailable: introduced in macOS 10.13
                CTooltip &Tooltip = m_ActiveTooltip.value();
                                                    ^
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/optional:959:27: note: 'value' has been explicitly marked unavailable here
    constexpr value_type& value() &
                          ^
2022-05-26 00:37:33 +02:00