Commit graph

4671 commits

Author SHA1 Message Date
Jupeyy a077c01b80 Less translations for vk errors from backend 2023-01-04 18:19:53 +01:00
bors[bot] 6d3af742dd
Merge #6180
6180: Implement exact matches in search and exclude strings r=Robyt3 a=def-

Thanks to bencie for discussion

<!-- 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

- [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: Dennis Felsing <dennis@felsin9.de>
2023-01-03 18:16:03 +00:00
Robert Müller 9ea665cd69 Fix undefined demo timeline markers when recording is not stopped
When the demo recording is not stopped properly (e.g. client crashes during recording), the timeline markers and the demo length are not updated.
The length is always set to zero when starting the recording, but uninitialized memory is written for the timeline markers, which causes these demos to likely show the maximum number of markers with some markers possibly being outside the ticks that the demo contains.
This is fixed by initially setting all timeline marker data to zero when starting the recording.
2023-01-03 15:38:54 +01:00
Robert Müller c2c21298e2 Fix signed integer overflow on client input message
Swap mathematical operations to avoid multiplication by `1000`. As `time_freq()` returns the nanoseconds in a second (1e9), first dividing this number by 1000 does not lose any precision.

Also ensure that `IntendedTick` is in the valid range of ticks.

```
src/engine/server/server.cpp:1585:64: runtime error: signed integer overflow: 24185120014282423 * 1000 cannot be represented in type 'long int'
    0 0x55c165f220aa in CServer::ProcessClientPacket(CNetChunk*) src/engine/server/server.cpp:1579
    1 0x55c165f3a8d3 in CServer::PumpNetwork(bool) src/engine/server/server.cpp:2383
    2 0x55c165f51166 in CServer::Run() src/engine/server/server.cpp:2821
    3 0x55c165eb37d0 in main src/engine/server/main.cpp:191
    4 0x7f99e4c3ad8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    5 0x7f99e4c3ae3f in __libc_start_main_impl ../csu/libc-start.c:392
    6 0x55c165e7ab64 in _start (build-asan/DDNet-Server+0xd7ab64)
```
2023-01-03 14:10:58 +01:00
Robert Müller 706eb0d015 Remove unnecessary include in protocol, move definitions to cpp file
The include of `base/system.h` in `src/engine/shared/protocol.h` is not required and only used transitively in `teamscore.h` for `dbg_assert`.

To avoid adding back the include in `teamscore.h`, the function definitions are moved to the cpp file. Both definitions are moved for consistency.
2023-01-03 14:10:58 +01:00
Robert Müller e4b1db1b6d Fix spelling of NETMSG_AUTH_CHALLENGE constant 2023-01-03 14:10:57 +01:00
Robert Müller 25e01eb762 Add constants for minimum and maximum tick values 2023-01-03 14:10:57 +01:00
Robert Müller 179e3b1c4c Register application separately to specify its displayed name
The application itself must also be registered in a separate registry key, so its displayed name can be set.

See: https://learn.microsoft.com/en-us/windows/win32/shell/app-registration
2023-01-02 17:35:16 +01:00
Robert Müller 6e28ca6fe4 Extract method IStorage::GetBinaryPathAbsolute 2023-01-02 15:29:43 +01:00
bors[bot] b252f2e344
Merge #6199
6199: Register protocol and file extensions on client launch on Windows r=def- a=Robyt3

When launching the client on Windows, associate the protocol `ddnet` and the file extensions `.map` and `.demo` with the client executable.

See #6072.

## 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-01-02 12:58:15 +00:00
def 39b34bf40c Don't count (connecting) players for voting 2023-01-02 11:25:13 +01:00
Robert Müller 4118074768 Fix signed integer overflow when unpacking snapshot delta
```
src/engine/shared/snapshot.cpp:219:18: runtime error: signed integer overflow: -2011501152 + -1594687485 cannot be represented in type 'int'
    0 0x5593cbc3534c in CSnapshotDelta::UndiffItem(int const*, int*, int*, int, int*) src/engine/shared/snapshot.cpp:219
    1 0x5593cbc3852d in CSnapshotDelta::UnpackDelta(CSnapshot*, CSnapshot*, void const*, int) src/engine/shared/snapshot.cpp:442
    2 0x5593cbb881a6 in CDemoPlayer::DoTick() src/engine/shared/demo.cpp:624
    3 0x5593cbb9a907 in CDemoPlayer::Update(bool) src/engine/shared/demo.cpp:1016
    4 0x5593ca9f44da in CClient::Update() src/engine/client/client.cpp:2628
    5 0x5593caa199dd in CClient::Run() src/engine/client/client.cpp:3220
    6 0x5593caa970f3 in main src/engine/client/client.cpp:4717
    7 0x7fe086d04d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    8 0x7fe086d04e3f in __libc_start_main_impl ../csu/libc-start.c:392
    9 0x5593ca55e6f4 in _start (build-demofuzz/DDNet+0x24936f4)
```
2022-12-31 12:06:31 +01:00
Robert Müller d63a7a3c84 Fix left shift of negative value when unpacking snapshot delta
```
src/engine/shared/snapshot.cpp:693:28: runtime error: left shift of negative value -1
    0 0x55cae1608071 in CSnapshotBuilder::NewItem(int, int, int) src/engine/shared/snapshot.cpp:686
    1 0x55cae1603fe0 in CSnapshotDelta::UnpackDelta(CSnapshot*, CSnapshot*, void const*, int) src/engine/shared/snapshot.cpp:390
    2 0x55cae15544c6 in CDemoPlayer::DoTick() src/engine/shared/demo.cpp:624
    3 0x55cae1566c27 in CDemoPlayer::Update(bool) src/engine/shared/demo.cpp:1016
    4 0x55cae03c07fa in CClient::Update() src/engine/client/client.cpp:2628
    5 0x55cae03e5cfd in CClient::Run() src/engine/client/client.cpp:3220
    6 0x55cae0463413 in main src/engine/client/client.cpp:4717
    7 0x7fbc7d855d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    8 0x7fbc7d855e3f in __libc_start_main_impl ../csu/libc-start.c:392
    9 0x55cadff2aa14 in _start (build-demofuzz/DDNet+0x2493a14)
```
2022-12-31 12:06:31 +01:00
Robert Müller 6800bd90a4 Fix edge cases where demo tick seeking did not work
Instead of using hardcoded tick offsets, use the current/previous/next tick values from the demo info.

This fixes seeking the next tick not working for demos where the difference between the current and the next tick was greater than 3.
2022-12-30 21:05:46 +01:00
Robert Müller a3e48bef27 Prevent temporary demo file from being deleted multiple times
Each time the client disconnected or stopped a demo, it tried to delete the previous temporary replay file, which causes an error message "could not delete file" to be shown in the console.

This is prevented by clearing the current filename of the demo recorder after deleting the file.
2022-12-30 14:20:42 +01:00
Robert Müller a61eec8f1e Add DDNet settings button to unregister protocol and file extensions
Add a button to the Miscellaneous DDNet settings to manually unregister the protocol and file extension handlers.
2022-12-29 18:03:08 +01:00
Robert Müller db3d1f19a9 Register protocol and file extensions on client launch on Windows
When launching the client on Windows, associate the protocol `ddnet` and the file extensions `.map` and `.demo` with the client executable.
2022-12-29 18:03:08 +01:00
bors[bot] f230ad0bdc
Merge #6191
6191: Use own defines of format specifiers for MinGW (fixes #6187) r=Jupeyy a=Chairn

Counter proposition to #6188. Redefines our own specifiers

## 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: Chairn <chairn.nq@hotmail.fr>
2022-12-28 20:59:17 +00:00
bors[bot] 46209376ad
Merge #6164
6164: Automatically register ddnet:// url handler on macOS r=Robyt3 a=def-

Should work automatically on first time running client.

See https://hublog.hubmed.org/archives/001154

<!-- 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>
2022-12-26 15:53:33 +00:00
bors[bot] 667d588e55
Merge #6179
6179: Ignore connecting players in search terms when "Filter connecting players" is on r=heinrich5991 a=def-

Thanks to bencie for reporting

<!-- 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

- [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: Dennis Felsing <dennis@felsin9.de>
2022-12-26 01:27:13 +00:00
Chairn 3132c96a80 Use own defines of format specifiers for MinGW (fixes #6187) 2022-12-25 21:18:05 +01:00
def c3909d7cdb Just quiet curl warnings for now 2022-12-25 19:34:19 +01:00
Dennis Felsing 779b44fde5 Support .demo and .map files being dragged into client
Only tested on macOS, but should work everywhere
2022-12-24 01:06:06 +01:00
Dennis Felsing bfe4ced662 Automatically register ddnet:// url handler on macOS
Works automatically on first time running client. Whenever you click on
a URL it is automatically opened in the current client, same as writing
"connect ip:port" into F1.

See https://hublog.hubmed.org/archives/001154 and
https://wiki.libsdl.org/SDL2/SDL_DropEvent
2022-12-24 00:26:35 +01:00
Dennis Felsing 68625dd370 Implement exact matches in search and exclude strings
Thanks to bencie for discussion
2022-12-23 23:25:11 +01:00
Dennis Felsing f65f2bd1d1 Ignore connecting players in search terms when "Filter connecting players" is on
Thanks to bencie for reporting
2022-12-23 15:59:46 +01:00
Robert Müller 51e99b99cb Pass SDL event structure directly to handler functions
Instead of passing the generic `SDL_Event` to the handler functions and getting the specific structure inside the functions, pass the specific structure directly to the functions.
2022-12-18 12:41:54 +01:00
Robert Müller 2579f0be2f Add support for hot-plugging gamecontrollers
Handle the appropriate SDL events to open new joysticks when they are connected and remove joysticks when they are disconnected.

If the active joystick gets disconnected, then the first joystick in the list will be activated as a fallback.
If the previously activated joystick gets reconnected, it will be activated again automatically, as it is identified by the GUID stored in the configuration.
The stored joystick GUID is only updated when the user manually selects a new joystick in the controls settings or with the console.

Closes #6152.
2022-12-18 12:41:17 +01:00
Robert Müller 1eaa88b236 Handle ordinal joystick hat keys as combined cardinal hat keys
Instead of considering diagonal hat inputs (e.g. up-left) as separate keys, consider them as inputs for both cardinal directions (e.g. up and left) at the same time.

This improves input with gamecontrollers that map the D-Pad to a joystick hat, as it was impossible with the previous handling to move with hat-left/right and jump with hat-up at the same time.

This means that diagonal hat buttons can no longer be used in binds, because they are no longer considered distinct buttons. It's unlikely that they would ever be useful in this game, as real joystick POV hats would not be used anyway.

Closes #6120.
2022-12-17 17:18:01 +01:00
Dennis Felsing a59613e56f Use %zu formatter for size_t, not PRIu64 (which is for uint64_t) 2022-12-16 16:40:10 +01:00
Robert Müller a0553f2d40 Fix editor smooth zooming when joining/reloading game
Using `IClient::LocalTime` for smooth zooming in the editor causes the zoom to behave incorrectly when joining a game, as the local time is reset when joining a game.
This is fixed by adding a separate `IClient::GlobalTime` which is only set once when the client launches and never resets.
2022-12-15 18:18:06 +01:00
Jupeyy 5341fc37fd Minimal changes to default to Vulkan 2022-12-13 19:37:03 +01:00
Jupeyy 870ea8566e Improve error handling in vulkan
so it doesn't assert & shows a message box with the error and some tips
2022-12-13 18:11:26 +01:00
Jupeyy dff876d58c Add Localizable hint 2022-12-13 17:53:32 +01:00
Dennis Felsing 412a9461c0 Fix conflict resolution between #6013 and #5948
Thanks @Robyt3 for noticing
2022-12-12 14:13:32 +01:00
bors[bot] c96310464e
Merge #6119
6119: Fix client attempting to delete user directory when stopping replay demo r=Chairn a=Robyt3

When the client stops a replay demo and tries to remove the temporary file when being disconnected, it's not checked whether a recording of a replay demo has ever been started. In this case the filename is empty, which leads to the client trying to delete the user's directory, which will fail with an error message, as it's a folder and cannot be deleted with the function designed for deleting files.

This is fixed by calling the function `DemoRecorder_Stop` to delete the temporary demo file, as this function already makes sure that the filename is not empty.

## 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>
2022-12-11 14:43:51 +00:00
Robert Müller 144a69266c Fix client attempting to delete user directory when stopping replay demo
When the client stops a replay demo and tries to remove the temporary file when being disconnected, it's not checked whether a recording of a replay demo has ever been started.
In this case the filename is empty, which leads to the client trying to delete the user's directory, which will fail with an error message, as it's a folder and cannot be deleted with the function designed for deleting files.

This is fixed by calling the function `DemoRecorder_Stop` to delete the temporary demo file, as this function already makes sure that the filename is not empty.
2022-12-11 15:05:31 +01:00
Robert Müller 7958b999a3 Copy the demo timeline markers when slicing a demo
When slicing a demo, also copy the demo markers that are within the sliced segment to the new demo.

This also fixes timeline markers not being added to replay demos, as the replay demos are always created by slicing.

Closes #6116.
2022-12-11 14:34:21 +01:00
bors[bot] 5290193f1f
Merge #6110
6110: Remove successful queries from write backup r=def- a=Zwelf

Fixes #6106

Seems like I didn't tested before whether the rank got removed in the successful path.

## 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
- [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: Zwelf <zwelf@strct.cc>
2022-12-09 23:22:44 +00:00
bors[bot] ebe9024a66
Merge #6051
6051: Null-terminate string returned by mysql r=Zwelf a=def-

Found in #6050 that a 16 byte long name would be written, filling up the string entirely, no terminating '\0'

## 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>
2022-12-09 21:58:45 +00:00
Zwelf 9f1bbbe63b Remove successful queries from write backup 2022-12-09 20:06:14 +01:00
bors[bot] 3438e272af
Merge #6101
6101: Remove check for `pResponseToken`, which isn't used on this code path r=def- a=Robyt3

Closes #6100.

## 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>
2022-12-06 20:01:41 +00:00
Robert Müller 9bc0028b94 Remove check for pResponseToken, which isn't used on this code path
Closes #6100.
2022-12-06 20:37:59 +01:00
Robert Müller 7e1fc0344e Reduce duplicate code by extracting CNetBan::CBanPool::InsertUsed 2022-12-06 20:18:08 +01:00
Dennis Felsing b04cdacaeb Bump friends limit from 1024 to 4096 (fixes #6096) 2022-12-06 10:31:43 +01:00
Robert Müller 57d5c5a3d5 Use for-each loop instead of for-loop 2022-12-05 23:15:35 +01:00
Robert Müller 6d8fad775d Encapsulate m_ResortServerBrowser inside CServerBrowser
The variable `m_ResortServerBrowser` was only used in the client to pass it to the server browser. For better separation of concerns, this variable is moved inside `CServerBrowser` and the function `RequestResort` should be called to set it to `true`.

The existing variable `m_SortOnNextUpdate` is replaced with this, as it served the same purpose already. The variable name from upstream is used to reduce conflicts.
2022-12-05 23:15:35 +01:00
Robert Müller d0635246c8 Remove unused m_NeedRefresh variable 2022-12-05 23:13:06 +01:00
Robert Müller a6e0e37c4a Use consistent system name serverbrowser for log messages 2022-12-05 23:13:06 +01:00
Robert Müller 0c8aac6f05 Remove unnecessary MatchFound variable
This variable is always `1` when `m_ppServerlist[i]->m_Info.m_QuickSearchHit` is not `0`.
2022-12-05 23:13:02 +01:00
Robert Müller cbf08b0025 Change type of Filtered from int to bool 2022-12-05 23:12:28 +01:00
Robert Müller 1051a935a0 Use nullptr, '\0' and false instead of 0 2022-12-05 22:28:23 +01:00
Robert Müller c72861fb6d Rename class SortWrap to CSortWrap 2022-12-05 22:27:28 +01:00
Robert Müller 518210dfe1 Move variable declarations closer to usage 2022-12-05 22:27:14 +01:00
bors[bot] cf6e89c319
Merge #6035
6035: Fix various issues reported by cppcheck static analyser r=def- a=Robyt3

After generating `compile_commands.json` with cmake, I ran [cppcheck](https://cppcheck.sourceforge.io/) like this:

```
cppcheck --project=compile_commands.json -DWIN64 --suppressions-list=cppcheck.supp --enable=all 2>cppcheck.log
```

With these suppressions in `cppcheck.supp`:

```
cstyleCast
useStlAlgorithm
unusedFunction
variableScope
noExplicitConstructor
useInitializationList
noConstructor
uninitMemberVar
uninitMemberVarPrivate
uninitDerivedMemberVar
uninitStructMember
uninitvar
shadowFunction
memleakOnRealloc
internalAstError
virtualCallInConstructor
unknownMacro
noOperatorEq
noCopyConstructor
```

Many of these occur too often or are false positives. 

Here is a list of all remaining non-suppressed issues reported by cppcheck: [cppcheck.log](https://github.com/ddnet/ddnet/files/9997663/cppcheck.log)

And here is a list of all remaining issues including the suppressed ones: [cppcheck_all.log](https://github.com/ddnet/ddnet/files/9997662/cppcheck_all.log)

I couldn't get cppcheck's command line argument to ignore the external folders to work correctly, so I manually removed those entries from the files.

## 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>
2022-12-05 20:00:07 +00:00
bors[bot] be7242e010
Merge #6071 #6077 #6085 #6088 #6090
6071: Add logs for moderators (fixes #5433) r=def- a=Vy0x2

<!-- What is the motivation for the changes of this pull request? -->
issue #5433 
Moderators can access the last x minutes of the chat activity.
Every entry beside server messages will show the player name, player ip and client who wrote the message / who disconnected so moderators can get the players ip after something happened in case he left already.

The current implementation has a 4 minute time slot, messages older than 4 minutes are not shown.
To limit the memory usage its limited atm to 256 log-entries. In case of more messages than 256 in 4 minutes (unlikely), the oldest messages are overwritten.

I keep this as a draft for a while, because its my first pr and I am sure there is some improvement i did not see (or to improve the wording)
<!-- 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

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


6077: Add "Tools > Remove unused envelopes" to editor r=def- a=Robyt3

Add a new menu "Tools" next to the "File" menu, with a button to "Remove unused envelopes".

Clicking the button opens a confirmation popup to confirm the operation.

![editor-tools-menu](https://user-images.githubusercontent.com/23437060/205157109-62d53601-502a-4401-8c6f-f06c7e57e174.png)

Closes #2576.

## 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)


6085: Fix cmake args in workspace r=def- a=Jupeyy

current is completely wrong, since it overwrites the cmake internal settings. and e.g. prevent `-g`
Now it should in worst case only overwrite custom settings by the user. but dunno how often u actually do that anyway inside a IDE

but if someone knows better I'm glad to hear it

## 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)


6088: Pr fix uninit r=def- a=Jupeyy

<!-- 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)


6090: FIX: parse & colorify gametype Gores correctly r=heinrich5991 a=Avolicious

`@def-` The correct PR now :) Correct coloring the gamemode "Gores"
![193410660-5e757fd4-449f-4d0a-a719-4a0cc1e5a01e](https://user-images.githubusercontent.com/105295486/205684472-36cc6daa-bda4-4af1-a838-b7fe25a55dec.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
- [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: Vy0x2 <denispaul43@gmail.com>
Co-authored-by: Robert Müller <robytemueller@gmail.com>
Co-authored-by: Jupeyy <jupjopjap@gmail.com>
Co-authored-by: Avolicious <avolicious@kog.tw>
2022-12-05 16:12:05 +00:00
Zwelf a4b7c9d08a Store ranks in sqlite first to not loose them if server shuts down during stuck mysql transaction 2022-12-05 16:50:25 +01:00
Jupeyy 2fe7912b1f fix some valgrind conditional jump relies on uninit warnings 2022-12-04 22:54:18 +01:00
Robert Müller 9cba213310 Consistently use static const instead of const static 2022-11-29 23:32:32 +01:00
Robert Müller faa9f27808 Declare variables as const when possible
According to cppcheck's `constVariable` error:

```
src\engine\client\backend\opengl\opengl_sl.cpp:74:43: style: Variable 'Define' can be declared as reference to const [constVariable]
  for(CGLSLCompiler::SGLSLCompilerDefine &Define : pCompiler->m_vDefines)
                                          ^

src\engine\client\backend\vulkan\backend_vulkan.cpp:2149:12: style: Variable 'GraphicThreadCommandBuffer' can be declared as reference to const [constVariable]
     auto &GraphicThreadCommandBuffer = m_vvThreadDrawCommandBuffers[i + 1][m_CurImageIndex];
           ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3192:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
  auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
        ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3200:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
   auto &DescrSet = m_vTextures[State.m_Texture].m_VKStandard3DTexturedDescrSet;
         ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3810:13: style: Variable 'Mode' can be declared as reference to const [constVariable]
  for(auto &Mode : vPresentModeList)
            ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3818:13: style: Variable 'Mode' can be declared as reference to const [constVariable]
  for(auto &Mode : vPresentModeList)
            ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6511:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
   auto &DescrSet = m_vTextures[pCommand->m_State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
         ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6555:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
   auto &DescrSet = m_vTextures[pCommand->m_State.m_Texture].m_VKStandard3DTexturedDescrSet;
         ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6660:9: style: Variable 'MemBlock' can be declared as reference to const [constVariable]
  auto &MemBlock = m_vBufferObjects[BufferIndex].m_BufferObject.m_Mem;
        ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6799:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
  auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
        ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6808:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
   auto &DescrSet = m_vTextures[pCommand->m_State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
         ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6902:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
  auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
        ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6907:9: style: Variable 'TextTextureDescr' can be declared as reference to const [constVariable]
  auto &TextTextureDescr = m_vTextures[pCommand->m_TextTextureIndex].m_VKTextDescrSet;
        ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6961:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
  auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
        ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6970:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
   auto &DescrSet = m_vTextures[State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
         ^

src\game\client\components\hud.cpp:178:8: style: Variable 'aFlagCarrier' can be declared as const array [constVariable]
   int aFlagCarrier[2] = {
       ^
src\game\client\components\hud.cpp:519:16: style: Variable 's_aTextWidth' can be declared as const array [constVariable]
  static float s_aTextWidth[5] = {s_TextWidth0, s_TextWidth00, s_TextWidth000, s_TextWidth0000, s_TextWidth00000};
               ^

src\game\client\components\killmessages.cpp:305:30: style: Variable 'Client' can be declared as reference to const [constVariable]
   CGameClient::CClientData &Client = GameClient()->m_aClients[m_aKillmsgs[r].m_KillerID];
                             ^
src\game\client\components\killmessages.cpp:314:30: style: Variable 'Client' can be declared as reference to const [constVariable]
   CGameClient::CClientData &Client = GameClient()->m_aClients[m_aKillmsgs[r].m_VictimID];
                             ^

src\game\client\components\menus_ingame.cpp:243:12: style: Variable 'pInfoByName' can be declared as reference to const [constVariable]
 for(auto &pInfoByName : m_pClient->m_Snap.m_apInfoByName)
           ^
src\game\client\components\menus_ingame.cpp:530:12: style: Variable 'pInfoByName' can be declared as reference to const [constVariable]
 for(auto &pInfoByName : m_pClient->m_Snap.m_apInfoByName)
           ^

src\game\client\components\players.cpp:767:44: style: Variable 'CharacterInfo' can be declared as reference to const [constVariable]
  CGameClient::CSnapState::CCharacterInfo &CharacterInfo = m_pClient->m_Snap.m_aCharacters[i];
                                           ^

src\game\client\components\spectator.cpp:122:27: style: Variable 'Snap' can be declared as reference to const [constVariable]
 CGameClient::CSnapState &Snap = pSelf->m_pClient->m_Snap;
                          ^
src\game\client\components\spectator.cpp:221:12: style: Variable 'pInfo' can be declared as reference to const [constVariable]
 for(auto &pInfo : m_pClient->m_Snap.m_apInfoByDDTeamName)
           ^

src\game\client\gameclient.cpp:2220:15: style: Variable 'OwnClientData' can be declared as reference to const [constVariable]
 CClientData &OwnClientData = m_aClients[ownID];
              ^
src\game\client\gameclient.cpp:2227:16: style: Variable 'cData' can be declared as reference to const [constVariable]
  CClientData &cData = m_aClients[i];
               ^

src\game\client\prediction\entities\character.cpp:397:11: style: Variable 'aSpreading' can be declared as const array [constVariable]
    float aSpreading[] = {-0.185f, -0.070f, 0, 0.070f, 0.185f};
          ^

src\game\client\prediction\entities\laser.cpp:53:9: style: Variable 'HitPos' can be declared as reference to const [constVariable]
  vec2 &HitPos = pHit->Core()->m_Pos;
        ^

src\game\editor\auto_map.cpp:507:18: style: Variable 'Index' can be declared as reference to const [constVariable]
       for(auto &Index : pRule->m_vIndexList)
                 ^
src\game\editor\auto_map.cpp:518:18: style: Variable 'Index' can be declared as reference to const [constVariable]
       for(auto &Index : pRule->m_vIndexList)
                 ^

src\game\editor\editor.cpp:118:12: style: Variable 'Item' can be declared as reference to const [constVariable]
 for(auto &Item : vList)
           ^
src\game\editor\editor.cpp:2983:11: style: Variable 'aAspects' can be declared as const array [constVariable]
    float aAspects[] = {4.0f / 3.0f, 16.0f / 10.0f, 5.0f / 4.0f, 16.0f / 9.0f};
          ^
src\game\editor\editor.cpp:3141:15: style: Variable 's_aShift' can be declared as const array [constVariable]
   static int s_aShift[] = {24, 16, 8, 0};
              ^

src\engine\server\server.cpp:2807:14: style: Variable 'Client' can be declared as reference to const [constVariable]
   for(auto &Client : m_aClients)
             ^

src\engine\server\sql_string_helpers.cpp:51:6: style: Variable 'aTimes' can be declared as const array [constVariable]
 int aTimes[7] =
     ^

src\test\secure_random.cpp:24:6: style: Variable 'BOUNDS' can be declared as const array [constVariable]
 int BOUNDS[] = {2, 3, 4, 5, 10, 100, 127, 128, 129};
     ^
```
2022-11-29 23:32:32 +01:00
Robert Müller 98706d79d4 Mark parameters as const when possible
According to cppchecker's `constParameter` error:

```
src\engine\gfx\image_manipulation.cpp:7:58: style: Parameter 'pSrc' can be declared as pointer to const [constParameter]
static void Dilate(int w, int h, int BPP, unsigned char *pSrc, unsigned char *pDest, unsigned char AlphaThreshold = TW_DILATE_ALPHA_THRESHOLD)
                                                         ^
src\engine\gfx\image_manipulation.cpp:58:67: style: Parameter 'pSrc' can be declared as pointer to const [constParameter]
static void CopyColorValues(int w, int h, int BPP, unsigned char *pSrc, unsigned char *pDest)
                                                                  ^

src\engine\shared\network_conn.cpp:241:42: style: Parameter 'Addr' can be declared as reference to const [constParameter]
void CNetConnection::DirectInit(NETADDR &Addr, SECURITY_TOKEN SecurityToken, SECURITY_TOKEN Token, bool Sixup)
                                         ^

src\base\system.cpp:4060:71: style: Parameter 'random' can be declared as pointer to const [constParameter]
void generate_password(char *buffer, unsigned length, unsigned short *random, unsigned random_length)
                                                                      ^

src\engine\client\backend\vulkan\backend_vulkan.cpp:263:38: style: Parameter 'AllocatedMemory' can be declared as reference to const [constParameter]
  void Free(SMemoryHeapQueueElement &AllocatedMemory)
                                     ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:1708:47: style: Parameter 'ImgExtent' can be declared as reference to const [constParameter]
 static size_t ImageMipLevelCount(VkExtent3D &ImgExtent)
                                              ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:2801:29: style: Parameter 'Image' can be declared as reference to const [constParameter]
 void ImageBarrier(VkImage &Image, size_t MipMapBase, size_t MipMapCount, size_t LayerBase, size_t LayerCount, VkFormat Format, VkImageLayout OldLayout, VkImageLayout NewLayout)
                            ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6495:46: style: Parameter 'ExecBuffer' can be declared as reference to const [constParameter]
 void Cmd_Clear(SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SCommand_Clear *pCommand)
                                             ^

src\game\client\components\skins.cpp:83:72: style: Parameter 'pImg' can be declared as pointer to const [constParameter]
static void CheckMetrics(CSkin::SSkinMetricVariable &Metrics, uint8_t *pImg, int ImgWidth, int ImgX, int ImgY, int CheckWidth, int CheckHeight)
                                                                       ^

src\game\client\prediction\entities\character.h:106:37: style: Parameter 'pNewInput' can be declared as pointer to const [constParameter]
 void SetInput(CNetObj_PlayerInput *pNewInput)
                                    ^

src\game\client\prediction\gameworld.cpp:245:106: style: Parameter 'pNotThis' can be declared as pointer to const [constParameter]
CCharacter *CGameWorld::IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, CCharacter *pNotThis, int CollideWith, class CCharacter *pThisOnly)
                                                                                                         ^
src\game\client\prediction\gameworld.cpp:245:151: style: Parameter 'pThisOnly' can be declared as pointer to const [constParameter]
CCharacter *CGameWorld::IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, CCharacter *pNotThis, int CollideWith, class CCharacter *pThisOnly)
                                                                                                                                                      ^
src\game\client\prediction\gameworld.cpp:283:116: style: Parameter 'pNotThis' can be declared as pointer to const [constParameter]
std::list<class CCharacter *> CGameWorld::IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, class CEntity *pNotThis)
                                                                                                                   ^

src\game\client\ui.cpp:522:180: style: Parameter 'pReadCursor' can be declared as pointer to const [constParameter]
void CUI::DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, const SLabelProperties &LabelProps, int StrLen, CTextCursor *pReadCursor)
                                                                                                                                                                                   ^

src\game\client\ui_scrollregion.cpp:23:86: style: Parameter 'pParams' can be declared as pointer to const [constParameter]
void CScrollRegion::Begin(CUIRect *pClipRect, vec2 *pOutOffset, CScrollRegionParams *pParams)
                                                                                     ^

src\game\server\scoreworker.h:239:29: style: Parameter 'aTimeCp' can be declared as const array [constParameter]
 void Set(float Time, float aTimeCp[NUM_CHECKPOINTS])
                            ^

src\game\server\score.cpp:135:80: style: Parameter 'aTimeCp' can be declared as const array [constParameter]
void CScore::SaveScore(int ClientID, float Time, const char *pTimestamp, float aTimeCp[NUM_CHECKPOINTS], bool NotEligible)
                                                                               ^

src\game\server\teeinfo.cpp:40:57: style: Parameter 'pUseCustomColors' can be declared as pointer to const [constParameter]
CTeeInfo::CTeeInfo(const char *apSkinPartNames[6], int *pUseCustomColors, int *pSkinPartColors)
                                                        ^
src\game\server\teeinfo.cpp:40:80: style: Parameter 'pSkinPartColors' can be declared as pointer to const [constParameter]
CTeeInfo::CTeeInfo(const char *apSkinPartNames[6], int *pUseCustomColors, int *pSkinPartColors)
                                                                               ^
```
2022-11-29 23:32:31 +01:00
Robert Müller 2115c12282 Handle snap ID potentially being out of range
According to cppchecker's `arrayIndexOutOfBoundsCond` error:

```
src\engine\server\server.cpp:117:19: warning: Either the condition 'ID<0' is redundant or the array 'm_aIDs[32768]' is accessed at index 32768, which is out of bounds. [arrayIndexOutOfBoundsCond]
 dbg_assert(m_aIDs[ID].m_State == ID_ALLOCATED, "id is not allocated");
                  ^
src\engine\server\server.cpp:115:8: note: Assuming that condition 'ID<0' is not redundant
 if(ID < 0)
       ^
src\engine\server\server.cpp:117:19: note: Array index out of bounds
 dbg_assert(m_aIDs[ID].m_State == ID_ALLOCATED, "id is not allocated");
                  ^
src\engine\server\server.cpp:120:8: warning: Either the condition 'ID<0' is redundant or the array 'm_aIDs[32768]' is accessed at index 32768, which is out of bounds. [arrayIndexOutOfBoundsCond]
 m_aIDs[ID].m_State = ID_TIMED;
       ^
src\engine\server\server.cpp:115:8: note: Assuming that condition 'ID<0' is not redundant
 if(ID < 0)
       ^
src\engine\server\server.cpp:120:8: note: Array index out of bounds
 m_aIDs[ID].m_State = ID_TIMED;
       ^
src\engine\server\server.cpp:121:8: warning: Either the condition 'ID<0' is redundant or the array 'm_aIDs[32768]' is accessed at index 32768, which is out of bounds. [arrayIndexOutOfBoundsCond]
 m_aIDs[ID].m_Timeout = time_get() + time_freq() * 5;
       ^
src\engine\server\server.cpp:115:8: note: Assuming that condition 'ID<0' is not redundant
 if(ID < 0)
       ^
src\engine\server\server.cpp:121:8: note: Array index out of bounds
 m_aIDs[ID].m_Timeout = time_get() + time_freq() * 5;
       ^
src\engine\server\server.cpp:122:8: warning: Either the condition 'ID<0' is redundant or the array 'm_aIDs[32768]' is accessed at index 32768, which is out of bounds. [arrayIndexOutOfBoundsCond]
 m_aIDs[ID].m_Next = -1;
       ^
src\engine\server\server.cpp:115:8: note: Assuming that condition 'ID<0' is not redundant
 if(ID < 0)
       ^
src\engine\server\server.cpp:122:8: note: Array index out of bounds
 m_aIDs[ID].m_Next = -1;
       ^
```
2022-11-29 23:32:31 +01:00
Robert Müller d2868325b6 Fix potential null-pointer dereference in server logger
According to cppchecker's `nullPointerRedundantCheck` error:

```
src\engine\server\server_logger.cpp:29:3: warning: Either the condition 'm_pServer' is redundant or there is possible null pointer dereference: m_pServer. [nullPointerRedundantCheck]
  m_pServer->SendLogLine(pMessage);
  ^
src\engine\server\server_logger.cpp:19:7: note: Assuming that condition 'm_pServer' is not redundant
   if(m_pServer)
      ^
src\engine\server\server_logger.cpp:29:3: note: Null pointer dereference
  m_pServer->SendLogLine(pMessage);
  ^

```
2022-11-29 23:32:30 +01:00
Robert Müller 65aa584b9f Remove redundant conditional expressions
According to cppcheck's `redundantCondition` and `multiCondition` errors:

```
src\engine\client\backend\glsl_shader_compiler.cpp:70:39: style: Redundant condition: The condition '*(pBuff+1)' is redundant since '*(pBuff+1) == 'i'' is sufficient. [redundantCondition]
     if(*pBuff == ' ' && *(pBuff + 1) && *(pBuff + 1) == 'i' && *(pBuff + 2) == 'n')
                                      ^
src\engine\client\backend\glsl_shader_compiler.cpp:98:45: style: Redundant condition: The condition '*(pBuff+1)' is redundant since '*(pBuff+1) == 'u'' is sufficient. [redundantCondition]
      else if(*pBuff == 'o' && *(pBuff + 1) && *(pBuff + 1) == 'u' && *(pBuff + 2) == 't')
                                            ^

src\game\client\gameclient.cpp:1665:62: style: Redundant condition: m_aShowOthers[g_Config.m_ClDummy]!=SHOW_OTHERS_NOT_SET. 'A || (!A && B)' is equivalent to 'A || B' [redundantCondition]
 if(m_aShowOthers[g_Config.m_ClDummy] == SHOW_OTHERS_NOT_SET || (m_aShowOthers[g_Config.m_ClDummy] != SHOW_OTHERS_NOT_SET && m_aShowOthers[g_Config.m_ClDummy] != g_Config.m_ClShowOthers))
                                                             ^

src\game\client\prediction\entities\projectile.cpp:104:34: style: Redundant condition: pTargetChr. '!A || (A && B)' is equivalent to '!A || B' [redundantCondition]
  if(m_Explosive && (!pTargetChr || (pTargetChr && (!m_Freeze || (m_Type == WEAPON_SHOTGUN && Collide)))))
                                 ^

src\engine\client\backend\vulkan\backend_vulkan.cpp:6588:11: style: Expression is always true because 'else if' condition is opposite to previous condition at line 6578. [multiCondition]
  else if(!pCommand->m_ByResize)
          ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6578:14: note: first condition
  if(pCommand->m_ByResize)
             ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6588:11: note: else if condition is opposite to first condition
  else if(!pCommand->m_ByResize)
          ^
```
2022-11-29 23:32:28 +01:00
Robert Müller ca58bba82f Remove redundant bitwise operand
According to cppcheck's `badBitmaskCheck` error:

```
src\engine\client\client.cpp:422:26: style: Operator '|' with one operand equal to zero is redundant. [badBitmaskCheck]
  Packer.AddInt((0 << 1) | (pMsg->m_System ? 1 : 0)); // NETMSG_EX, NETMSGTYPE_EX
                         ^

src\engine\shared\snapshot.cpp:40:45: style: Operator '|' with one operand equal to zero is redundant. [badBitmaskCheck]
 int TypeItemIndex = GetItemIndex((0 << 16) | InternalType); // NETOBJTYPE_EX
                                            ^

src\engine\server\server.cpp:777:26: style: Operator '|' with one operand equal to zero is redundant. [badBitmaskCheck]
  Packer.AddInt((0 << 1) | (pMsg->m_System ? 1 : 0)); // NETMSG_EX, NETMSGTYPE_EX
                         ^
```
2022-11-29 23:32:28 +01:00
Robert Müller 45b645f890 Remove assignment of variable to self
According to cppcheck's `selfAssignment` error:

```
src\engine\client\backend\vulkan\backend_vulkan.cpp:5784:23: warning: Redundant assignment of 'DescrSetTextOutline' to itself. [selfAssignment]
  DescrSetTextOutline = DescrSetText;
                      ^
```
2022-11-29 23:32:27 +01:00
Robert Müller 54a13b1c12 Remove check for negative unsigned expression
According to cppcheck's `unsignedLessThanZero` error:

```
src\engine\shared\datafile.cpp:129:13: style: Checking if unsigned expression 'Bytes' is less than zero. [unsignedLessThanZero]
   if(Bytes <= 0)
            ^
```
2022-11-29 23:32:27 +01:00
Robert Müller e134e4e488 Remove redundant conditions (always either true or false)
According to cppcheck's `knownConditionTrueFalse` error:

```
src\base\system.cpp:1776:11: style: The comparison 'bytes == 0' is always true. [knownConditionTrueFalse]
 if(bytes == 0 && sock->ipv4sock >= 0)
          ^
src\base\system.cpp:1742:14: note: 'bytes' is assigned value '0' here.
 int bytes = 0;
             ^
src\base\system.cpp:1776:11: note: The comparison 'bytes == 0' is always true.
 if(bytes == 0 && sock->ipv4sock >= 0)
          ^

src\game\editor\io.cpp:887:33: style: Condition 'pSoundsItem->m_Version>=1' is always true [knownConditionTrueFalse]
      if(pSoundsItem->m_Version >= 1)
                                ^
src\game\editor\io.cpp:874:33: note: Assuming that condition 'pSoundsItem->m_Version<1' is not redundant
      if(pSoundsItem->m_Version < 1 || pSoundsItem->m_Version > CMapItemLayerSounds::CURRENT_VERSION)
                                ^
src\game\editor\io.cpp:887:33: note: Condition 'pSoundsItem->m_Version>=1' is always true
      if(pSoundsItem->m_Version >= 1)
                                ^
src\game\editor\io.cpp:914:33: style: Condition 'pSoundsItem->m_Version>=1' is always true [knownConditionTrueFalse]
      if(pSoundsItem->m_Version >= 1)
                                ^
src\game\editor\io.cpp:901:33: note: Assuming that condition 'pSoundsItem->m_Version<1' is not redundant
      if(pSoundsItem->m_Version < 1 || pSoundsItem->m_Version > CMapItemLayerSounds::CURRENT_VERSION)
                                ^
src\game\editor\io.cpp:914:33: note: Condition 'pSoundsItem->m_Version>=1' is always true
      if(pSoundsItem->m_Version >= 1)
                                ^

src\engine\client\backend\opengl\backend_opengl.cpp:207:68: style: Condition '*pStr=='\0'' is always false [knownConditionTrueFalse]
   else if(LastWasNumber && (*pStr == '.' || *pStr == ' ' || *pStr == '\0'))
                                                                   ^

src\game\client\components\maplayers.cpp:851:110: style: Condition 'DoTextureCoords' is always true [knownConditionTrueFalse]
        mem_copy_special(pUploadData + sizeof(vec2), pTmpTileTexCoords, sizeof(vec3), vtmpTiles.size() * 4, (DoTextureCoords ? (sizeof(vec2)) : 0));
                                                                                                             ^
src\game\client\components\maplayers.cpp:849:11: note: Assuming that condition 'DoTextureCoords' is not redundant
       if(DoTextureCoords)
          ^

src\game\client\components\maplayers.cpp:851:110: note: Condition 'DoTextureCoords' is always true
        mem_copy_special(pUploadData + sizeof(vec2), pTmpTileTexCoords, sizeof(vec3), vtmpTiles.size() * 4, (DoTextureCoords ? (sizeof(vec2)) : 0));
                                                                                                             ^

src\game\client\prediction\gameworld.cpp:567:5: style: Condition 'm_pParent' is always true [knownConditionTrueFalse]
 if(m_pParent && m_pParent->m_pChild && m_pParent->m_pChild != this)
    ^

src\game\client\components\menu_background.cpp:271:7: style: Condition 'NeedImageLoading' is always true [knownConditionTrueFalse]
   if(NeedImageLoading)
      ^
src\game\client\components\menu_background.cpp:268:23: note: Assignment 'NeedImageLoading=true', assigned value is 1
   NeedImageLoading = true;
                      ^
src\game\client\components\menu_background.cpp:271:7: note: Condition 'NeedImageLoading' is always true
   if(NeedImageLoading)
      ^

src\game\editor\editor.cpp:4991:6: style: Condition 'pEnvelope' is always true [knownConditionTrueFalse]
  if(pEnvelope)
     ^
```
2022-11-29 23:32:26 +01:00
Robert Müller fd208eaa1a Remove redundant variable assignments
The assigned values are never used, so the assignments can be removed or variable scopes can be reduced.

According to cppcheck's `unreadVariable` error.
2022-11-29 23:32:26 +01:00
Robert Müller 554fc19be0 Remove unused member SFontSizeChar::m_TouchTime 2022-11-29 23:28:37 +01:00
Robert Müller 94678ef3a3 Remove unused struct CDatafileData 2022-11-29 23:28:36 +01:00
Robert Müller 2e2cb47674 Fix client crash when launching with screenshot command
The client crashes when launching with `screenshot` in the command line, as the graphics are not available when the command is executed.
This is fixed by storing the command, so it's executed when everything is ready.
2022-11-29 23:08:52 +01:00
Robert Müller e07bd45e27 Fix stored commands using original callback instead of the chain
When stored commands (`CFGFLAG_STORE`) were executed with `CConsole::StoreCommands(false)`, the associated chained commands were not properly executed, if they were chained after the command has been stored (e.g. in `CMenus::OnInit`).
Storing the command saves the current callback and userdata, which were overridden by the chain callback and userdata, but the stored callback and userdata were not updated.
This is fixed by storing a pointer to the command itself, which will be updated when it is chained.

From teeworlds/teeworlds#2572.
2022-11-29 23:06:50 +01:00
Dennis Felsing 9912e44a9a Also remove appended / 2022-11-29 18:18:12 +01:00
Dennis Felsing 3fcf497850 Remove // in ddnet:// url handler 2022-11-29 18:15:09 +01:00
Robert Müller 0e77be2166 Fix client crash when unpacking a sixup packet
The client crashes when trying to unpack a packet that has the sixup flag set, as `CNetClient` does not pass pointers for the output parameters `pSecurityToken` and `pResponseToken` to `CNetBase::UnpackPacket`.
Since the client does not handle sixup packets, checks are added to return an error and ignore the packet instead of crashing due to a null pointer access.

This was found by fuzzing the data returned by `net_udp_recv` with radamsa.

```
==6200==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f8d0fb8ba56 bp 0x7ffcbf67c7f0 sp 0x7ffcbf67c7a8 T0)
==6200==The signal is caused by a WRITE memory access.
==6200==Hint: address points to the zero page.
    0 0x7f8d0fb8ba56  (/lib/x86_64-linux-gnu/libc.so.6+0xc4a56)
    1 0x563a7e250fbe in mem_copy src/base/system.cpp:208
    2 0x563a7e1bc6b6 in CNetBase::UnpackPacket(unsigned char*, int, CNetPacketConstruct*, bool&, int*, int*) src/engine/shared/network.cpp:263
    3 0x563a7e1bf57e in CNetClient::Recv(CNetChunk*) src/engine/shared/network_client.cpp:100
    4 0x563a7cfa76a2 in CClient::PumpNetwork() src/engine/client/client.cpp:2546
    5 0x563a7cfb7cf6 in CClient::Update() src/engine/client/client.cpp:2838
    6 0x563a7cfcfe47 in CClient::Run() src/engine/client/client.cpp:3214
    7 0x563a7d04c631 in main src/engine/client/client.cpp:4702
    8 0x7f8d0faf0d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    9 0x7f8d0faf0e3f in __libc_start_main_impl ../csu/libc-start.c:392
    10 0x563a7cb28754 in _start (build-asan/DDNet+0x2472754)

==8315==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f4accfe5a56 bp 0x7ffcf1318530 sp 0x7ffcf13184e8 T0)
==8315==The signal is caused by a WRITE memory access.
==8315==Hint: address points to the zero page.
    0 0x7f4accfe5a56  (/lib/x86_64-linux-gnu/libc.so.6+0xc4a56)
    1 0x560413603200 in mem_copy src/base/system.cpp:208
    2 0x56041356d9c7 in CNetBase::UnpackPacket(unsigned char*, int, CNetPacketConstruct*, bool&, int*, int*) src/engine/shared/network.cpp:224
    3 0x5604135717c0 in CNetClient::Recv(CNetChunk*) src/engine/shared/network_client.cpp:104
    4 0x5604123597e2 in CClient::PumpNetwork() src/engine/client/client.cpp:2546
    5 0x560412369e36 in CClient::Update() src/engine/client/client.cpp:2838
    6 0x560412381f87 in CClient::Run() src/engine/client/client.cpp:3214
    7 0x5604123fe771 in main src/engine/client/client.cpp:4702
    8 0x7f4accf4ad8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    9 0x7f4accf4ae3f in __libc_start_main_impl ../csu/libc-start.c:392
    10 0x560411eda894 in _start (build-asan/DDNet+0x2472894)
```
2022-11-24 21:12:40 +01:00
Robert Müller 26e35d3a56 Fix choppy demo seeking when start/end ticks are very large
Demo seeking for percent positions and relative time was choppy, when the first and last ticks of the demo are very large but close together (e.g. with 1308908156 to 1308905658, which are close to integer limit).
During the calculation of `WantedTick` both operands were promoted to `float`s, which caused the information of the smaller operand, i.e. the seeked percentage or relative time, to be mostly lost, so seeking was very inaccurate.
This is fixed by rounding the `float` operand to `int` before adding it to another `int`.
2022-11-21 00:22:46 +01:00
Robert Müller 7ae5b1474a Add TYPE_ALL_OR_ABSOLUTE and TYPE_SAVE_OR_ABSOLUTE storage types
The types are translated to `TYPE_ALL`/`TYPE_SAVE` respectively if a given path is relative and to `TYPE_ABSOLUTE` if a path is absolute.

These types are only supported with the `OpenFile`, `ReadFile`, `ReadFileStr` and `GetCompletePath` methods.

This reduces duplicate code when calling the methods.
2022-11-20 16:07:40 +01:00
Robert Müller 04be9d6e72 Add IInput::ShiftIsPressed and IInput::AltIsPressed
To avoid duplicate code when checking for both right and left shift or alt keys.
2022-11-15 21:17:55 +01:00
Dennis Felsing b5b15d2c6a Null-terminate string returned by mysql 2022-11-15 18:32:00 +01:00
bors[bot] b33c105fbc
Merge #5917
5917: report extra player info to master http r=def- a=edg-l

couldn't test yet

this doesnt show extra info on the client server list yet, just makes the server report it

<!-- 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: Edgar Luque <git@edgarluque.com>
2022-11-14 13:27:51 +00:00
Edgar 4a506f03a6
report extra player info to master http 2022-11-14 08:04:34 +01:00
Robert Müller 7185f028f1 Reduce duplicate code by using loop for snapshot types 2022-11-12 20:31:44 +01:00
Robert Müller c988a71d3e Fix aliasing warnings in CClient::DemoPlayer_Play
Fix warnings with `-fstrict-aliasing` and `-Wstrict-aliasing=2` by using char array instead of array of char pointers:

```
src/engine/client/client.cpp: In member function 'virtual const char* CClient::DemoPlayer_Play(const char*, int)':
src/engine/client/client.cpp:3858:123: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3858 |         m_aapSnapshots[g_Config.m_ClDummy][SNAP_CURRENT]->m_pSnap = (CSnapshot *)m_aaapDemorecSnapshotData[SNAP_CURRENT][0];
      |                                                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
src/engine/client/client.cpp:3859:126: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3859 |         m_aapSnapshots[g_Config.m_ClDummy][SNAP_CURRENT]->m_pAltSnap = (CSnapshot *)m_aaapDemorecSnapshotData[SNAP_CURRENT][1];
      |                                                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
src/engine/client/client.cpp:3864:117: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3864 |         m_aapSnapshots[g_Config.m_ClDummy][SNAP_PREV]->m_pSnap = (CSnapshot *)m_aaapDemorecSnapshotData[SNAP_PREV][0];
      |                                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
src/engine/client/client.cpp:3865:120: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3865 |         m_aapSnapshots[g_Config.m_ClDummy][SNAP_PREV]->m_pAltSnap = (CSnapshot *)m_aaapDemorecSnapshotData[SNAP_PREV][1];
      |                                                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
```

Snapshot data during demo playback was being stored in an array of `char *` instead of an array of `char`, which caused above aliasing warnings and used 8 times more memory for the snapshot storage than being necessary.
2022-11-12 20:27:45 +01:00
bors[bot] 06e3eb5641
Merge #6017
6017: Minor refactoring of demo related code r=def- a=Robyt3

Extracted from #6016.

## 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>
2022-11-06 22:00:54 +00:00
bors[bot] b21ba35225
Merge #5599
5599: Add support for Rust code in DDNet r=def- a=heinrich5991

The glue is done using the [cxx crate](https://cxx.rs/) on the Rust side.

As a proof-of-concept, only a small console command (`rust_version`) printing the currently used Rust version was added.

You can generate and open the Rust documentation using `DDNET_TEST_NO_LINK=1 cargo doc --open`.

You can run the Rust tests using `cmake --build <build dir> --target run_rust_tests`, they're automatically included in the `run_tests` target as well.

Rust tests don't work on Windows in debug mode on Windows because Rust cannot currently link with the debug version of the C stdlib on Windows: https://github.com/rust-lang/rust/issues/39016.

---

The stuff in `src/rust-bridge` is generated using
```
cxxbridge src/engine/shared/rust_version.rs --output src/rust-bridge/engine/shared/rust_version.cpp --output src/rust-bridge/engine/shared/rust_version.h
cxxbridge src/engine/console.rs --output src/rust-bridge/cpp/console.cpp --output src/rust-bridge/cpp/console.h
```

Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2022-11-06 21:40:48 +00:00
Robert Müller bbf36a226c Remove dead code 2022-11-06 16:25:25 +01:00
Robert Müller c2d2093c89 Use . for object access instead of getting a pointer first 2022-11-06 16:25:25 +01:00
Robert Müller 84c9506d3c Use loop for demo recorders to reduce duplicate code 2022-11-06 16:25:24 +01:00
bors[bot] 48d82e9bfd
Merge #6010 #6015
6010: Search for images/sounds in subfolders when readding in editor, show selection dialog if multiple files with the same are found, show error popup when file cannot be found r=heinrich5991 a=Robyt3

Search for the image/sound file in all subfolders of the mapres folder when using the "Readd" button in the editor.

Show an error popup when readding fails:

![errorpopup](https://user-images.githubusercontent.com/23437060/200087069-bb735f14-b56f-458a-9571-c013fc19e59d.png)

Show a selection dialog if multiple files with the same name are found in different subfolders:

![selectiondialog](https://user-images.githubusercontent.com/23437060/200125448-dccf47ba-d643-4f41-b256-eb90656ba693.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)


6015: Add tests for int packer r=heinrich5991 a=ChillerDragon

This is an effort to test the Integer packer code. It should hopefully also be useful as some kind of documentation for everyone trying to understand how ints are packed.

BTW github in my browser uses a weird angle for the slashes so it looks like this:

![image](https://user-images.githubusercontent.com/20344300/200165832-b35bae5c-6681-4a43-8a7c-b51b374b3da9.png)

In my vscode it looks nice tho:

![image](https://user-images.githubusercontent.com/20344300/200165853-c7cedc06-a053-4c4c-aad1-711c403e9b84.png)

Or in vim. So I blame the github web preview font being broken:

![image](https://user-images.githubusercontent.com/20344300/200165893-e30754eb-5570-433d-805d-3b8308ddd65d.png)


Co-authored-by: Robert Müller <robytemueller@gmail.com>
Co-authored-by: ChillerDragon <ChillerDragon@gmail.com>
2022-11-06 14:10:27 +00:00
Robert Müller 4d0cd7f807 Use traditional casts instead of functional-style casts 2022-11-06 11:52:21 +01:00
Robert Müller 83faed0952 Write sqlite file to storage unless given as absolute path 2022-11-05 16:32:45 +01:00
Robert Müller a62bf7c334 Write log files to storage unless given as absolute path 2022-11-05 16:30:24 +01:00
Robert Müller 896dd4ecd4 Add IStorage::FindFiles to find all files with a specific name
This function searches in all subfolder of the given folder and fills the given `std::vector` with all files with the given filename.

A `std::set` is used to prevent duplicate entries when a file with the same path is present in multiple storage locations. In that case we only need the path once, as we only use it against the highest priority storage location anyway.
2022-11-05 15:42:39 +01:00
Robert Müller b0a21dab09 Use bool for Load, Save, Append result, true on success
The `Append` method was returning `0` on success while `Load` and `Save` were returning `1`.
Now all three methods use a `bool` as return value and return `true` on success.

The call `SortImages()` is moved inside the `Append` method, as it should always be called when appending succeeded.
2022-11-03 20:17:06 +01:00
Jupeyy 365c48413f Switch to Vulkan 1.1
Since the vulkan loader drops support for useful extensions (or the extension loading process changed between 1.0 & 1.1, not sure)
Which causes OBS not to work
2022-11-02 12:54:04 +01:00
bors[bot] 571b0b36de
Merge #5770
5770: Fix physics change by weak hook fix (fixes #5769) r=def- a=fokkonaut

<!-- What is the motivation for the changes of this pull request -->
fixes #5769

## 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: fokkonaut <35420825+fokkonaut@users.noreply.github.com>
Co-authored-by: Jupeyy <jupjopjap@gmail.com>
2022-11-01 10:29:53 +00:00
Robert Müller d551617c34 Use str_copy instead of str_format with format "%s"
Using `str_format(aBuf, sizeof(aBuf), "%s", pStr)` is equivalent to `str_copy(aBuf, pStr, sizeof(aBuf))`. Using `str_copy` is more readable and also more efficient as there is no overhead from parsing the format string and from passing varargs.
2022-10-27 21:42:14 +02:00
Jupeyy 3b2dd73614 Rename config var to no weak only 2022-10-27 17:51:30 +02:00
Rafael Fontenelle cd14660307 Fix misspellings 2022-10-25 13:51:56 -03:00
Robert Müller 326a0a576d Fix slicing a demo opened with absolute path not working
Slicing a demo opened from command line with an absolute path did not work, as the game only tried to load the source demo from storage instead of using the given absolute path.
2022-10-24 20:15:49 +02:00
Robert Müller c0da3b93e4 Fix IME not being deactivated when editor is closed
Previously the IME was not deactivated when the editor is closed, so `SDL_TEXTINPUT` events where still being reported ingame after exiting the editor.
2022-10-21 21:31:21 +02:00
Robert Müller 75326e8393 Fix text input not working when entering editor with bind
When entering the editor with a custom bind (e.g. `bind e "cl_editor 1"`) or when opening it from the console while also immediately closing the console (e.g. with `cl_editor 1; toggle_local_console`), the IME state was not properly set to active, so SDL did not report any `SDL_TEXTINPUT` events, leading to editboxes in the editor not receiving any text.

The is fixed by always enabling the IME state when entering the editor, which was previously only done when using the Ctrl+Shift+E hotkey or coincidentally when the editor is activated while the IME is already active, i.e. when the menu or console is open.

Closes #5095.
2022-10-21 21:20:10 +02:00
Dennis Felsing eb27b26d8d Also ignore min value 2022-10-21 00:34:44 +02:00
Dennis Felsing 26a08360f8 Don't print max value when there is none (fixes #5953) 2022-10-21 00:09:30 +02:00
heinrich5991 623a8935fb Add client_score_kind field to serverinfo
It specifies whether the scores are to be interpreted as times (string
value starting with "time") or as points (string value starting with
"points").
2022-10-20 00:43:38 +02:00
heinrich5991 d8053fba7d Unify time score handling in the server
It's now always -1 for "no time" or a nonnegative integer for the number
of seconds it took the player to finish the map.
2022-10-20 00:43:38 +02:00
heinrich5991 dcd76fd3e1 Add support for Rust code in DDNet
The glue is done using the [cxx crate](https://cxx.rs/) on the Rust
side.

As a proof-of-concept, only a small console command (`rust_version`)
printing the currently used Rust version was added.

You can generate and open the Rust documentation using
`DDNET_TEST_NO_LINK=1 cargo doc --open`.

You can run the Rust tests using `cmake --build <build dir> --target
run_rust_tests`, they're automatically included in the `run_tests`
target as well.

Rust tests don't work on Windows in debug mode on Windows because Rust
cannot currently link with the debug version of the C stdlib on Windows:
https://github.com/rust-lang/rust/issues/39016.

---

The stuff in `src/rust-bridge` is generated using
```
cxxbridge src/engine/shared/rust_version.rs --output src/rust-bridge/engine/shared/rust_version.cpp --output src/rust-bridge/engine/shared/rust_version.h
cxxbridge src/engine/console.rs --output src/rust-bridge/cpp/console.cpp --output src/rust-bridge/cpp/console.h
```
2022-10-19 23:46:06 +02:00
Robert Müller 05eb1db436 Update zlib to version 1.2.13
Release notes: https://github.com/madler/zlib/releases/tag/v1.2.13
2022-10-14 14:53:24 +02:00
heinrich5991 ea17fc753e Enable antispoof for vanilla by default
Having it disabled opens up the server for attacks.
2022-10-13 09:55:39 +02:00
bors[bot] 6c3d0e999b
Merge #5933 #5941
5933: Inline `Is(GameType)` functions and remove support for legacy 64 player info protocol r=def- a=heinrich5991

## 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)


5941: Get away from vector for skins r=def- a=Jupeyy

most of the time it uses the index just to get the skin, downloaded skins change the index. Now its simply a heap object and downloaded skins load directly. Also the loading might be a bit faster bcs it had a loop lookup .Also O(1) lookup

not 100% tested. also fixes a bug with favorite skins hopefully
## 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: heinrich5991 <heinrich5991@gmail.com>
Co-authored-by: Jupeyy <jupjopjap@gmail.com>
2022-10-12 22:08:17 +00:00
Robert Müller 4bb549b68e Initialize the Windows COM library on all threads
Use threading model `COINIT_APARTMENTTHREADED` on threads that own a window (the main client thread) and `COINIT_MULTITHREADED` on all other threads.

Add assertions to ensure that the COM library is initialized successfully and only once per thread.

References:

- https://learn.microsoft.com/en-us/windows/win32/learnwin32/initializing-the-com-library
- https://learn.microsoft.com/en-us/windows/win32/com/single-threaded-apartments
- https://learn.microsoft.com/en-us/windows/win32/com/multithreaded-apartments

Yet another attempt at solving #5744.
2022-10-12 17:18:57 +02:00
heinrich5991 a595936fb5 Remove chat timeout code fallback heuristic
KoG is now on the newest version, we no longer need this.
2022-10-12 16:12:02 +02:00
heinrich5991 150485e3b0 Remove support for legacy 64 player info protocol
It was only being used for "Leak IP" favorites and LAN servers. Since
KoG has upgraded to latest DDNet, there aren't much servers left that
don't understand the new 64 player info protocol.

Keywords: fstd, dtsf
2022-10-12 16:12:02 +02:00
heinrich5991 a97a597592 Inline Is(GameType) functions
They are used for two purposes, coloring gametypes in the serverbrowser
and enabling backward compatibility. These are independent, we shouldn't
add more stuff to the backward compatibility, hence I split them up and
inlined them.
2022-10-11 16:05:46 +02:00
def c2d1118c90 Only announce servers using Steam/Discord integration which are registered 2022-10-09 16:16:54 +02:00
bors[bot] 6d7df66448
Merge #5918
5918: Constify snap more (inspired by upstream) r=Robyt3 a=ChillerDragon

Incorporate const added in those upstream commits:
d86d576217
e6b8518b49

## 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
- [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: ChillerDragon <ChillerDragon@gmail.com>
2022-10-09 13:53:05 +00:00
ChillerDragon 6d0b2ee44c Grammer fixes in snapshot doc
Thanks to @def-
2022-10-09 15:24:09 +02:00
ChillerDragon 9982a7bad3 Constify snap more (inspired by upstream)
Incorporate const added in those upstream commits:
d86d576217
e6b8518b49
2022-10-09 15:12:12 +02:00
ChillerDragon b2285855f5 Remove unused SnapInvalidateItem
suggested by @Robyt3 <3
2022-10-09 15:11:58 +02:00
def 317b2df7c0 Support multiple values to search/exclude (fixes #4119) 2022-10-07 18:21:14 +02:00
Robert Müller 3c5a9f7672 Print the operating system version on client/server launch 2022-10-03 13:19:31 +02:00
def 55ff665894 Less logging when loading maps on expected path 2022-10-01 22:46:39 +02:00
Robert Müller 9d1f393c55 Fix unknown command handler for filenames containing spaces
Pass the original string to the unknown command callback instead of the parsed command, as the latter ends at the first whitespace, which breaks for unknown commands (filenames) containing spaces.

Closes #5902.
2022-10-01 20:10:59 +02:00
Robert Müller f97067738e Use CreateFolder instead of fs_makedir + GetPath
As the former method is a wrapper for the latter two with additional log messages on errors.
2022-09-27 16:33:24 +02:00
Robert Müller 5482571c69 Add assertions for invalid storage arguments 2022-09-27 16:33:24 +02:00
Robert Müller a3f5d1b924 Use TYPE_SAVE instead of 0 2022-09-27 16:33:24 +02:00
Robert Müller 4fd983dc03 Add missing error handling for RenameBinaryFile 2022-09-27 16:33:24 +02:00
Robert Müller 481fb33efa Show log message when a storage path cannot be added 2022-09-27 15:25:04 +02:00
Robert Müller 2db41124b5 Use for-each loop for array apDirs 2022-09-27 15:25:04 +02:00
Robert Müller e21f9c609b Remove unnecessary virtual of GetPath method 2022-09-27 15:25:04 +02:00
Robert Müller 6fbcfb6fd9 Move variable declarations 2022-09-27 15:25:04 +02:00
Robert Müller c5d96eb0f6 Rename variable p to pStorage 2022-09-27 15:25:04 +02:00
fokkonaut a4383602c0 Fix windows build 2022-09-27 13:45:58 +02:00
bors[bot] c61e5586ff
Merge #5867
5867: Use ddnet.org on manpages r=heinrich5991 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>
2022-09-23 23:41:20 +00:00
Robert Müller 5825d5eb7f Fix map file argument not opening editor with absolute paths 2022-09-23 19:54:12 +02:00
Dennis Felsing e290a407d6 Fix other occurences of DDNet.tw 2022-09-23 10:59:36 +02:00
heinrich5991 884cf75cb8 Stop server if started with old curl and incompatible sv_register
This prevents accidentally falling victim to the bug #5858.
2022-09-22 00:09:02 +02:00
heinrich5991 4f2f3f4bba Only start registering once the server is fully started
This works around, i.e. fixes #5858 for curl versions < 7.77.0, as long
as the servers are only registered via IPv4 **OR** IPv6.

The bug that's being worked around is this:
84d2839740.

The bug makes curl reuse IPv6 connections when it is being requested to
connect via IPv4, making the registering fail. This commit works around
that by letting the server only register after having completely read
the config, so any `sv_register ipv4` should already be in effect.
2022-09-21 21:34:33 +02:00
heinrich5991 28359fb23d Also print the CURLcode on failed requests
This should help debugging the empty error messages we sometimes get on
servers.
2022-09-19 15:06:27 +02:00
bors[bot] 069e5a7c9d
Merge #5848 #5851
5848: Remove cl_http_map_download r=heinrich5991 a=def-

![screenshot-20220918@010406](https://user-images.githubusercontent.com/2335377/190879092-3ca64914-15c5-4835-9fe6-fd9fe75aa57d.png)
Causes problems with GER3
## 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)


5851: Respect reserved slots in old serverinfo r=heinrich5991 a=def-

Noticed in https://github.com/ddnet/ddnet/pull/5850 that reserved slots were not respected

<!-- 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: def <dennis@felsin9.de>
2022-09-18 11:40:11 +00:00
def fa80b157aa Respect reserved slots in old serverinfo
Noticed in https://github.com/ddnet/ddnet/pull/5850 that reserved slots
were not respected
2022-09-18 13:33:33 +02:00
def 3ed22cbe4e Send serverinfo when client joins
for GER3
2022-09-18 13:10:32 +02:00
def 9f4e883906 Remove cl_http_map_download 2022-09-18 01:03:15 +02:00
bors[bot] e61b850364
Merge #5843
5843: Laser menu tweaks; Changed some default colors r=def- a=VoxelDoesCode

fixes #5841 

![image](https://user-images.githubusercontent.com/95713843/190824834-a48913ec-360a-40a8-8b48-d278f5916493.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
- [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: VoxelDoesCode <bluheadcat@gmail.com>
2022-09-17 22:16:26 +00:00
VoxelDoesCode 71b073a45f New SG Laser default, Reset to defaults 2022-09-17 17:11:53 -04:00
VoxelDoesCode 5915d5531d Laser menu tweaks; Changed Freeze laser color 2022-09-16 18:28:36 -04:00
Learath f91a3069c3 Let CKernel clean-up. Use unused CSound::Shutdown 2022-09-16 16:50:19 +02:00
bors[bot] 55703c971c
Merge #5829
5829: Add HTTPS map download URL field for game servers r=def- a=heinrich5991

This allows every game server to provide its own HTTPS server for map
downloads. Since the ingame protocol for downloading map data is very
inefficient, this is desirable. Previously, only servers hosted by DDNet
could benefit from this.

Security concerns:
- Attackers can find out whether a given HTTPS GET request matches a
  known answer.

  This isn't deemed to be problematic as no cookies for authentication
  are sent and only the whole response can be matched.

- Sending requests to honeypot URLs to get people in legal trouble.

  This seems to be already possible with HTML image embeds, so it can't
  be that bad™.

- Downloading huge files, filling up a player's disk. The players might
  cancel when seeing huge files.

  There's a generous limit of 1 GiB per map file.

- Downloading huge files transparently compressed with gzip. See above.

Fixes #5812.

## 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: heinrich5991 <heinrich5991@gmail.com>
2022-09-15 08:54:46 +00:00
heinrich5991 716e8cd7f4 Add HTTPS map download URL field for game servers
This allows every game server to provide its own HTTPS server for map
downloads. Since the ingame protocol for downloading map data is very
inefficient, this is desirable. Previously, only servers hosted by DDNet
could benefit from this.

Security concerns:
- Attackers can find out whether a given HTTPS GET request matches a
  known answer.

  This isn't deemed to be problematic as no cookies for authentication
  are sent and only the whole response can be matched.

- Sending requests to honeypot URLs to get people in legal trouble.

  This seems to be already possible with HTML image embeds, so it can't
  be that bad™.

- Downloading huge files, filling up a player's disk. The players might
  cancel when seeing huge files.

  There's a generous limit of 1 GiB per map file.

- Downloading huge files transparently compressed with gzip. See above.

Fixes #5812.
2022-09-15 02:08:35 +02:00
heinrich5991 0bf941e6c9 Add MaxResponseSize to limit HTTP response sizes 2022-09-15 02:08:35 +02:00
heinrich5991 cb2614ff5c Treat manual aborts the same way as errors for map downloads 2022-09-15 02:08:34 +02:00
heinrich5991 9f1dd0d3c4 Disallow HTTP (without S) requests by default
Add a non-saved config variable `http_allow_insecure` to re-enable HTTP
support; this is mostly useful for testing stuff.

Disallowing HTTP by default allows fewer insecure data to be sent and
received by the DDNet client.
2022-09-15 01:29:13 +02:00
fokkonaut 5deeb299fa Add DDNetLaser to have more info about a laser shot 2022-09-15 01:01:32 +02:00
VoxelDoesCode 03b90f4f3d Added new cl colors and tweaked the settings menu
Merging of DoLaserPreview and static int fix

Replace if else statement with switch function

Adjusted RenderDropDown header to match

static int cbuttoncontainer fix, potential bugs
2022-09-15 01:01:04 +02:00
Dennis Felsing b26dd29a23 Use bindaddr for curl too (fixes #5831) 2022-09-13 19:45:17 +02:00
Dennis Felsing a67e30647e Add sv_sql_bindaddr (fixes #5830) 2022-09-13 17:09:53 +02:00
bors[bot] 766d9f66cc
Merge #5822
5822: Move skin info after the settings (settings can cause reload -> skin … r=heinrich5991 a=Jupeyy

…is invalid)
Also added an assert now, we dont want to render invalid textures ever since its always a logic bug

## 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: Jupeyy <jupjopjap@gmail.com>
2022-09-11 22:29:22 +00:00
heinrich5991 94446f65bd Ignore server info with control characters
This simply treats server info as invalid if it contains control
characters in any string.

Fixes #5826.
2022-09-11 23:42:05 +02:00
Jupeyy f59f79e02f Move skin info after the settings (settings can cause reload -> skin is invalid) 2022-09-10 15:03:59 +02:00
heinrich5991 5028423a0a Fix close messages not being shown when connecting
Previously, close messages were entirely ignored during the connection
process, this meant that ban messages weren't shown to players. Instead,
they'd see the standard "no answer from server yet" message.

Fixes #5792.
2022-09-03 20:25:22 +02:00
heinrich5991 887b24d8f5 Remove all references to memset
`memset` only worked with `CServer::CClient::STATE_EMPTY` by chance
because it is defined as 0.
2022-09-02 14:32:39 +02:00
bors[bot] 59db32e9c2
Merge #5763
5763: Fix png error handling by setting jmpbuf r=def- a=Jupeyy

else libpng will kill the thread on an error bcs it's a fatal error.

broken skin can be found in discord bugs channel weeb_okayu

## 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: Jupeyy <jupjopjap@gmail.com>
2022-08-31 08:57:02 +00:00
Robert Müller fe38caa7b4 Handle path/link arguments using the console argument parser
Add `IConsole::SetUnknownCommandCallback` to set a callback for unknown commands. The callback is used to handle connect links, .demo and .map files when parsing command line arguments.

This will allow paths/links to be passed at any argument position instead of only the first one.

And this fixes the command `play xyz.demo` not working due to `play ` being considered part of the path.
2022-08-30 22:17:04 +02:00
Robert Müller 13961db6a8 Allow demo/map arguments to be relative paths, allow using play
When passing .demo or .map paths as command line arguments, first check if the path can be found in the storage and then try resolving an absolute path.

Also delay execution of the `play` command until the client is ready so the command can be used from the command line. Although it doesn't work if there is only one argument, as this interferes with the .demo file handling.
2022-08-30 21:51:34 +02:00
def c479230d71 Use new ddnet.org domain 2022-08-30 10:09:06 +02:00
Robert Müller c6cc45471a Allow spectator mode to be changed while demo is paused
By updating and rendering the current tick again when changing the spectator mode while the demo playback is paused.

Refactoring: Extract `IDemoPlayer::ETickOffset`, `IDemoPlayer::SeekTick` and `CMenus::DemoSeekTick`.
2022-08-28 17:52:49 +02:00
Robert Müller 76cefa1c85 Faster and more precise demo skipping
- Approximate index of wanted keyframe to decrease linear search time.
- Only apply the magic `-5` to the Keyframe calculation, to make seeking with the mouse more accurate.
- After the method returns, the specified tick will be the _next_ tick being played instead of being the current tick.
2022-08-27 12:49:32 +02:00
Robert Müller 334bdad922 Fix demo intratick times not being updated when paused 2022-08-27 12:49:32 +02:00
Robert Müller 3ec4075ddb Move variable declarations closer to usages 2022-08-27 12:49:32 +02:00
Robert Müller 6f101f54af Rename method CDemoPlayer::time to Time 2022-08-27 12:49:32 +02:00
Robert Müller 64f326d626 Remove unused CDemoPlayer::NextFrame method 2022-08-27 11:39:03 +02:00
Robert Müller d369a5b693 Write messages to all active demo recorders 2022-08-25 17:57:04 +02:00
Robert Müller 63d0c8e170 Improve error message when map for demo cannot be found
Previously the playback did not start and no error messages was shown, when the map file cannot be found and no map data is embedded in the demo file.

Minor refactoring: Replace instances of `return pError` with semantically identical `return nullptr` to improve readability.
2022-08-25 17:57:04 +02:00
Robert Müller 3f1b702b90 Fix demos recorded without mapdata not being loadable
As the demo player skips the map data when loading the demo, the size of the map specified in the demo must be zero when no map data is embedded.
2022-08-25 17:57:04 +02:00
Robert Müller 5c2f162da2 Remove unused DemoRecorder_IsRecording method 2022-08-25 17:57:03 +02:00
Robert Müller c7ddb0ac47 Pad player demo filename with zeros instead of spaces 2022-08-25 17:57:03 +02:00
Dennis Felsing 2ccca3a50a Fix memset compilation
/home/deen/isos/ddnet/ddnet-source/src/tools/map_create_pixelart.cpp: In function ‘int InsertPixelArtQuads(CQuad*, int&, const CImageInfo&, const int*, const int*, const bool*)’:
/home/deen/isos/ddnet/ddnet-source/src/tools/map_create_pixelart.cpp:110:9: error: ‘memset’ was not declared in this scope
  110 |         memset(aVisitedPixels, 0, sizeof(bool) * Img.m_Height * Img.m_Width);
      |         ^~~~~~
/home/deen/isos/ddnet/ddnet-source/src/tools/map_create_pixelart.cpp:8:1: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
    7 | #include <game/mapitems.h>
  +++ |+#include <cstring>
    8 |
2022-08-25 14:07:49 +02:00
bors[bot] 49bed71932
Merge #5696
5696: Add option for parallax-aware zoom r=def- a=Fireball-Teeworlds

## How this works

Currently we have parallax X and Y parameters that control how far away a layer feels. Currently it's only taken into account for camera moving sideways.

This pull request makes zoom behave as if the camera was moving closer or further away, taking into account the distance to the layer.

In order to provide flexibility, this behaviour is using a separate parallax value, similar to how we have separate values for X and Y. Para Zoom will default to the minimum of parallax X, Y, clamped to be between 0 and 100. This seems to look well on most maps.

This pull request also introduces two new features to the Editor:
* Controls for configuring per-group Para Zoom value. If Custom Zoom is set to No, Para Zoom will automatically keep following to the default value described above, so that people new to the feature don't have to figure out how it works.
* Zoom button that previews the zoom behavior (next to Proof at the top).

## Editor Screenshots

### Para Zoom controls

![screenshot_2022-08-22_21-38-04](https://user-images.githubusercontent.com/68162181/186014490-f7b91245-460f-405f-8d5c-3f91db2a1b9a.png)

![screenshot_2022-08-22_21-37-58](https://user-images.githubusercontent.com/68162181/186014522-03b6e814-4dd9-4d07-9af9-7db5fb434a56.png)

### Zoom Button

![screenshot_2022-08-22_21-40-46](https://user-images.githubusercontent.com/68162181/186014856-2d1d499d-9011-439c-b217-536957e0c1e3.png)

![screenshot_2022-08-22_21-40-50](https://user-images.githubusercontent.com/68162181/186014874-6d2939d3-00ff-4327-a790-414b5151ba31.png)

## In-Game Screenshots

Video: https://youtu.be/W7eXQN0gRFI

This is an older version of the pull request that had an option to disable the new behaviour. The current version can only be disabled in map editor for a particular map.

### Springlobe 3

With new feature:
![screenshot_2022-08-02_04-28-19](https://user-images.githubusercontent.com/68162181/182286371-b67cee1c-73d8-4a24-a9c3-1b28340a3b42.png)

Without:
![screenshot_2022-08-02_04-28-25](https://user-images.githubusercontent.com/68162181/182286367-24555381-1700-4ff1-80c7-39e5dce63820.png)

### Beyond Dreams

With new feature:
![screenshot_2022-08-02_04-28-59](https://user-images.githubusercontent.com/68162181/182286322-114ecb90-0860-462c-9012-bb2f3ff848fb.png)

Without:
![screenshot_2022-08-02_04-28-55](https://user-images.githubusercontent.com/68162181/182286654-f34da72b-7991-4f42-89ad-679279fcb83e.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
- [ ] 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: Fireball <fireball.teeworlds@gmail.com>
2022-08-22 21:15:41 +00:00
Jupeyy dfaf3591c2 Fix png error handling by setting jmpbuf, else libpng will kill the thread 2022-08-22 17:47:28 +02:00
Robert Müller 37cadc5c09 Add CWindowsComLifecycle RAII wrapper for Windows COM library 2022-08-21 10:34:37 +02:00
Alexander Akulich 670f284194 Use GAME_NAME definition for engine initialization 2022-08-15 16:07:27 +03:00
Alexander Akulich 8ac84948c5 Extract server main() to its own file
Also extract CServerLogger to own files.
2022-08-15 16:07:27 +03:00
Alexander Akulich 301355d588 engine/server.h: Remove outdated comment 2022-08-15 15:05:59 +03:00
Robert Müller 3b1ef5642b Refactor DrawRect* methods:
- use `CORNER_*` constants and add missing constants
- fix array variable names
- use `size_t`
- extract duplicate computation into constant
- use `ColorRGBA` instead of `vec4`
2022-08-12 17:42:05 +02:00
Robert Müller 2a21cd6eab Move all DrawRect* methods from CRenderTools to IGraphics
As the methods do not depend on any game components they are moved to the engine graphics interface.
2022-08-12 17:42:05 +02:00
Robert Müller 7b20009980 Move CUI::CORNER_* enum to IGraphics::CORNER_*
Entirely automatic replacement in preparation for moving rect drawing methods from `CRenderTools` to `IGraphics`.
2022-08-12 17:42:04 +02:00
Robert Müller 9ad097da4d Refactor DrawCircle:
- improve argument names
- remove duplicate computation by adding `SegmentsAngle`
- rename variable `Array` to `aItems`
- use `std::size` and `size_t`
- remove unnecessary temporary variables
2022-08-12 17:42:03 +02:00
Robert Müller 237fdc76db Move CRenderTools::DrawCircle to IGraphics::DrawCircle
As this method does not depend on any game components it is be moved to the engine graphics interface.
2022-08-12 17:42:03 +02:00
Robert Müller 967c92f5d6 Encapsulate CGraph member variables
Make the member variables private and add `SetMin` to replace a usage of the member variables in `CDebugHud`. For completeness/symmetry, `SetMax` is also added.
2022-08-12 16:13:23 +02:00
Robert Müller 8c88005a42 Rename variables Array to aLineItems / aColorVertices 2022-08-12 16:13:03 +02:00
Robert Müller 11e60d32f0 Reuse CGraph::InsertAt in Add to reduce duplicate code 2022-08-12 16:13:03 +02:00
Robert Müller 44ca1f0d7b Use size_t for indices, replace unused return value with assert
The return value of `CGraph::InsertAt` was not checked. All uses of the function pass a correct index, so the return value is replaced with an assertion.
2022-08-12 16:13:03 +02:00
Robert Müller 3daa177830 Remove restriction for CGraph::MAX_VALUES to be a power of two
By using `% MAX_VALUES` instead of `& (MAX_VALUES - 1)` to wrap the index. Both work the same, but the latter only does for powers of two.
2022-08-12 16:13:03 +02:00
Robert Müller 8e0a935d5c Combine CGraph::ScaleMin and ScaleMax into Scale
As the methods are always called at the same time, they can be combined. This also improves the performance, as the array only needs to be iterated once.
2022-08-12 16:12:55 +02:00
Robert Müller f3eb93b83a Extend IConsole::PossibleCommands, add index to callback
`PossibleCommands` now passes the item index to the callback and returns the total number of items.

Add `EmptyPossibleCommandCallback` as default parameter.
2022-08-11 10:08:06 +02:00
bors[bot] f8fca99e62
Merge #5642
5642: Option to remove weak hook & bounce r=def- a=Jupeyy

Fixes #5641 
server side only

## 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: Jupeyy <jupjopjap@gmail.com>
2022-08-09 13:59:21 +00:00
bors[bot] dbe6d8cb29
Merge #5715
5715: Use djb2 for snapshot item hashlist r=def- a=Robyt3

The previous hash function was heavily biased towards the hash buckets 64-79, making those buckets overflow faster, which results in snapshot CRC errors and lags.

Using the djb2 hash yields an almost even distribution over the entire range of values.

Source for djb2: http://www.cse.yorku.ca/~oz/hash.html
(we incidentally use the same implementation for `str_quickhash`)

Sample which compares the usage of hash buckets in the test map from #5454 with the old and new hash function: [SnapshotHash.csv](https://github.com/ddnet/ddnet/files/9285148/SnapshotHash.csv) (this table also differentiates between the source and target of the snapshot delta)

Closes #4379.

## 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>
2022-08-08 22:38:22 +00:00
Robert Müller 243ab7c2f0 Use djb2 for snapshot item hashlist
The previous hash function was heavily biased towards the hash buckets 64-79, making those buckets overflow faster, which results in snapshot CRC errors and lags.

Using the djb2 hash yields an almost even distribution over the entire range of values.

http://www.cse.yorku.ca/~oz/hash.html
2022-08-08 23:21:45 +02:00
Robert Müller 573aedc323 Extract magic constant 64 into HASHLIST_BUCKET_SIZE 2022-08-08 22:34:47 +02:00
Robert Müller b99b861e1c Extract common expression into CalcHashID function 2022-08-08 22:30:14 +02:00
Dennis Felsing 526861f924 Update language files, remove half-translated graphics warning
Thanks to cheeser0613 for report
2022-08-08 16:10:48 +02:00
Fireball a90c86e9a5 Parallax-aware zoom
How this works: parallax values configure perceived distance from camera
when it's moving along x and y axes. Assume that zoom is moving the
camera away and scale layers accordingly, with background layers
(furtherst away) changing the least.

New per-ItemGroup (LayerGroup) setting allows to set the new parallax
value independently from the other two. This can be used to do tricks
like on Time Shop zoom correctly or make it feel like the camera is
changing the field of view at the same time as moving in space.
2022-08-05 00:40:58 +01:00
Robert Müller c696d93e41 Add documentation for IServer::GetClientVersion 2022-08-03 23:28:51 +02:00
Robert Müller ee339ebe30 Minor refactoring of GetClientInfo and SetClientDDNetVersion 2022-07-31 23:37:56 +02:00
Robert Müller 24b30434da Handle CServer::GetClientInfo return to fix use of undefined value
```
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:790:2: error: Undefined or garbage value returned to caller [clang-analyzer-core.uninitialized.UndefReturn,-warnings-as-errors]
        return Info.m_DDNetVersion;
        ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:785:5: note: Assuming 'ClientID' is not equal to SERVER_DEMO_CLIENT
        if(ClientID == SERVER_DEMO_CLIENT)
           ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:785:2: note: Taking false branch
        if(ClientID == SERVER_DEMO_CLIENT)
        ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:789:2: note: Calling 'CServer::GetClientInfo'
        GetClientInfo(ClientID, &Info);
        ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:646:13: note: Assuming 'ClientID' is >= 0
        dbg_assert(ClientID >= 0 && ClientID < MAX_CLIENTS, "client_id is not valid");
                   ^
/home/runner/work/ddnet/ddnet/src/base/tl/../system.h:58:38: note: expanded from macro 'dbg_assert'
#define dbg_assert(test, msg) assert(test)
                                     ^
/usr/include/assert.h:93:27: note: expanded from macro 'assert'
     (static_cast <bool> (expr)                                         \
                          ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:646:13: note: Left side of '&&' is true
        dbg_assert(ClientID >= 0 && ClientID < MAX_CLIENTS, "client_id is not valid");
                   ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:646:30: note: Assuming 'ClientID' is < MAX_CLIENTS
        dbg_assert(ClientID >= 0 && ClientID < MAX_CLIENTS, "client_id is not valid");
                                    ^
/home/runner/work/ddnet/ddnet/src/base/tl/../system.h:58:38: note: expanded from macro 'dbg_assert'
#define dbg_assert(test, msg) assert(test)
                                     ^
/usr/include/assert.h:93:27: note: expanded from macro 'assert'
     (static_cast <bool> (expr)                                         \
                          ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:646:2: note: '?' condition is true
        dbg_assert(ClientID >= 0 && ClientID < MAX_CLIENTS, "client_id is not valid");
        ^
/home/runner/work/ddnet/ddnet/src/base/tl/../system.h:58:31: note: expanded from macro 'dbg_assert'
#define dbg_assert(test, msg) assert(test)
                              ^
/usr/include/assert.h:93:7: note: expanded from macro 'assert'
     (static_cast <bool> (expr)                                         \
      ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:647:13: note: 'pInfo' is not equal to null
        dbg_assert(pInfo != 0, "info can not be null");
                   ^
/home/runner/work/ddnet/ddnet/src/base/tl/../system.h:58:38: note: expanded from macro 'dbg_assert'
#define dbg_assert(test, msg) assert(test)
                                     ^
/usr/include/assert.h:93:27: note: expanded from macro 'assert'
     (static_cast <bool> (expr)                                         \
                          ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:647:2: note: '?' condition is true
        dbg_assert(pInfo != 0, "info can not be null");
        ^
/home/runner/work/ddnet/ddnet/src/base/tl/../system.h:58:31: note: expanded from macro 'dbg_assert'
#define dbg_assert(test, msg) assert(test)
                              ^
/usr/include/assert.h:93:7: note: expanded from macro 'assert'
     (static_cast <bool> (expr)                                         \
      ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:649:5: note: Assuming field 'm_State' is not equal to STATE_INGAME
        if(m_aClients[ClientID].m_State == CClient::STATE_INGAME)
           ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:649:2: note: Taking false branch
        if(m_aClients[ClientID].m_State == CClient::STATE_INGAME)
        ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:667:2: note: Returning without writing to 'pInfo->m_DDNetVersion'
        return 0;
        ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:789:2: note: Returning from 'CServer::GetClientInfo'
        GetClientInfo(ClientID, &Info);
        ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:790:2: note: Undefined or garbage value returned to caller
        return Info.m_DDNetVersion;
        ^
```
2022-07-31 23:37:28 +02:00
Robert Müller 9a012312b8 Move and extend GetClientVersion to remove many version.h includes
The `CServer::GetClientVersion` method needs the `version.h` include, so it's moved from the header to the source file, so the include can be removed from the header.

The `GetClientVersion` method is often called with the same `Client != SERVER_DEMO_CLIENT ? GetClientVersion(Client) : CLIENT_VERSIONNR` expression, which also needs the `version.h` include. This expression is moved inside the method, so the include can be removed from all the server entities' and player code.

The `CGameContext::GetClientVersion` method is made a delegate to reduce duplicate code.

The includes of the server entities are also organized further.
2022-07-31 23:21:10 +02:00
Chairn c651936f38 Use copy assignment rather than copy variable one by one 2022-07-31 22:43:43 +02:00
def b33cbdde0a Remove unused backend_opengles.h 2022-07-31 09:44:50 +02:00
def 734790a4aa Fix deprecation warning in ffmpeg 5.1 (fixes #5681) 2022-07-31 00:58:15 +02:00
def c94de9b764 Further clang-tidy 14 issues (fixes #5612) 2022-07-27 09:07:47 +02:00
def 1944bc7052 Ignore Stack address escape clang-tidy warnings
/media/ddnet/src/engine/server.h:135:3: error: Address of stack memory associated with local variable 'aBuf' is still referred to by the stack variable 'tmp' upon returning to the caller.  This will be a dangling reference [clang-analyzer-core.StackAddressEscape,-warnings-as-errors]
                return SendPackMsgOne(pMsg, Flags, ClientID);
                ^
/media/ddnet/src/game/server/gamecontext.cpp:4084:5: note: Assuming the condition is false
        if(pFilter[0])
           ^~~~~~~~~~
/media/ddnet/src/game/server/gamecontext.cpp:4084:2: note: Taking false branch
        if(pFilter[0])
        ^
/media/ddnet/src/game/server/gamecontext.cpp:4088:2: note: Calling 'CGameContext::SendChatTarget'
        SendChatTarget(ClientID, aBuf);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/media/ddnet/src/game/server/gamecontext.cpp:401:5: note: Assuming field 'm_SvDemoChat' is not equal to 0
        if(g_Config.m_SvDemoChat)
           ^~~~~~~~~~~~~~~~~~~~~
/media/ddnet/src/game/server/gamecontext.cpp:401:2: note: Taking true branch
        if(g_Config.m_SvDemoChat)
        ^
/media/ddnet/src/game/server/gamecontext.cpp:402:3: note: Calling 'IServer::SendPackMsg'
                Server()->SendPackMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_NOSEND, -1);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/media/ddnet/src/engine/server.h:71:3: note: Taking true branch
                if(ClientID == -1)
                ^
/media/ddnet/src/engine/server.h:73:19: note: Assuming the condition is true
                        for(int i = 0; i < MaxClients(); i++)
                                       ^~~~~~~~~~~~~~~~
/media/ddnet/src/engine/server.h:73:4: note: Loop condition is true.  Entering loop body
                        for(int i = 0; i < MaxClients(); i++)
                        ^
/media/ddnet/src/engine/server.h:74:8: note: Assuming the condition is true
                                if(ClientIngame(i))
                                   ^~~~~~~~~~~~~~~
/media/ddnet/src/engine/server.h:74:5: note: Taking true branch
                                if(ClientIngame(i))
                                ^
/media/ddnet/src/engine/server.h:77:15: note: Calling 'IServer::SendPackMsgTranslate'
                                        Result = SendPackMsgTranslate(&tmp, Flags, i);
                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/media/ddnet/src/engine/server.h:118:6: note: Assuming field 'm_ClientID' is >= 0
                if(pMsg->m_ClientID >= 0 && !Translate(pMsg->m_ClientID, ClientID))
                   ^~~~~~~~~~~~~~~~~~~~~
/media/ddnet/src/engine/server.h:118:6: note: Left side of '&&' is true
/media/ddnet/src/engine/server.h:118:31: note: Assuming the condition is true
                if(pMsg->m_ClientID >= 0 && !Translate(pMsg->m_ClientID, ClientID))
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/media/ddnet/src/engine/server.h:118:3: note: Taking true branch
                if(pMsg->m_ClientID >= 0 && !Translate(pMsg->m_ClientID, ClientID))
                ^
/media/ddnet/src/engine/server.h:125:6: note: Assuming the condition is false
                if(IsSixup(ClientID))
                   ^~~~~~~~~~~~~~~~~
/media/ddnet/src/engine/server.h:125:3: note: Taking false branch
                if(IsSixup(ClientID))
                ^
/media/ddnet/src/engine/server.h:135:3: note: Address of stack memory associated with local variable 'aBuf' is still referred to by the stack variable 'tmp' upon returning to the caller.  This will be a dangling reference
                return SendPackMsgOne(pMsg, Flags, ClientID);
                ^
2022-07-27 09:07:20 +02:00
bors[bot] e8667b6075
Merge #5658
5658: Fix game freezing up on duplicate snapshot r=def- a=Fireball-Teeworlds

If a duplicate snapshot is received (for the same tick), we add both to the SnapshotStorage and end up with the same snapshot as both Cur and Prev. This results in GameInfraTick returning "inf" and results in "NaN" downstream in a few places, getting the CollLine logic stuck.

Some debug info (tcpdump, gdb, perf): https://gist.github.com/Fireball-Teeworlds/ad0016d2551a2e4d4cb5691023493856

Apparently this doesn't really happen in the wild, unless you have a buggy network stack. In which case it happens frequently enough to pinpoint the issue :D

 (fixes #5657)

## 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
- [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: Fireball <fireball.teeworlds@gmail.com>
2022-07-26 13:46:40 +00:00
Fireball 9689301410 Fix game freezing up on duplicate snapshot
If a duplicate snapshot is received (for the same tick), we add both to the SnapshotStorage and end up with the same snapshot as both Cur and Prev. This results in GameInfraTick returning "inf" and results in "NaN" downstream in a few places, getting the CollLine logic stuck.

Apparently this doesn't really happen in the wild, unless you have a buggy network stack. In which case it happens frequently enough to pinpoint the issue :D
2022-07-24 21:57:05 +01:00
Robert Müller 1398936f54 Minor refactoring of CDemoPlayer::DoTick:
- Decrease variable scopes
- Use `bool` instead of `int`
2022-07-24 19:01:45 +02:00
Robert Müller 4c397e479a Refactor CSnapshotBuilder::Finish using TotalSize and OffsetSize 2022-07-24 18:04:48 +02:00
Robert Müller 3863d41623 Validate snapshot size and member variables and demo snapshots
Add `CSnapshot::IsValid` to check if a snapshot unpacked from a snapshot delta or demo is valid:
- ensure number of items and data size are not negative
- ensure that the actual size of the snapshot matches the size derived from its member variables
- ensure item offsets are within the valid range
- ensure item sizes are not negative

Add `CSnapshot::TotalSize` and `CSnapshot::OffsetSize` utility functions.

Minor improvements to related error messages.

Fixes buffer overflow:

```
==47744==ERROR: AddressSanitizer: global-buffer-overflow on address 0x558618e3767f at pc 0x558614b9bdfb bp 0x7ffe58a32cd0 sp 0x7ffe58a32cc0
READ of size 4 at 0x558618e3767f thread T0
    0x558614b9bdfa in CSnapshotItem::Type() const src/engine/shared/snapshot.h:16
    0x558615c3c911 in CSnapshot::GetItemType(int) const src/engine/shared/snapshot.cpp:29
    0x558614aebaba in CClient::UnpackAndValidateSnapshot(CSnapshot*, CSnapshot*) src/engine/client/client.cpp:2264
    0x558614af87cb in CClient::OnDemoPlayerSnapshot(void*, int) src/engine/client/client.cpp:2598
    0x558615b9db1a in CDemoPlayer::DoTick() src/engine/shared/demo.cpp:659
    0x558615babd3f in CDemoPlayer::Update(bool) src/engine/shared/demo.cpp:1007
    0x558614afb08b in CClient::Update() src/engine/client/client.cpp:2686
    0x558614b1d9eb in CClient::Run() src/engine/client/client.cpp:3296
    0x558614b8e64f in main src/engine/client/client.cpp:4761
```

And fixes a buffer overflow that manifests itself as an internal ASan error:

```
=================================================================
==4755==AddressSanitizer CHECK failed: ../../../../src/libsanitizer/asan/asan_descriptions.cc:79 "((0 && "Address is not in memory and not in shadow?")) != (0)" (0x0, 0x0)
    0x7f0bf5f368be in AsanCheckFailed ../../../../src/libsanitizer/asan/asan_rtl.cc:72
    0x7f0bf5f54eee in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) ../../../../src/libsanitizer/sanitizer_common/sanitizer_termination.cc:77
    0x7f0bf5e4cb6f in GetShadowKind ../../../../src/libsanitizer/asan/asan_descriptions.cc:79
    0x7f0bf5e4cb6f in __asan::GetShadowAddressInformation(unsigned long, __asan::ShadowAddressDescription*) ../../../../src/libsanitizer/asan/asan_descriptions.cc:95
    0x7f0bf5e4cb6f in __asan::GetShadowAddressInformation(unsigned long, __asan::ShadowAddressDescription*) ../../../../src/libsanitizer/asan/asan_descriptions.cc:92
    0x7f0bf5e4e386 in __asan::AddressDescription::AddressDescription(unsigned long, unsigned long, bool) ../../../../src/libsanitizer/asan/asan_descriptions.cc:440
    0x7f0bf5e50e94 in __asan::ErrorGeneric::ErrorGeneric(unsigned int, unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long) ../../../../src/libsanitizer/asan/asan_errors.cc:380
    0x7f0bf5f35f4d in __asan::ReportGenericError(unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned int, bool) ../../../../src/libsanitizer/asan/asan_report.cc:460
    0x7f0bf5e86f5e in __interceptor_memset ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:762
    0x558234873f1d in mem_zero src/base/system.cpp:213
    0x55823481fc27 in CSnapshotBuilder::NewItem(int, int, int) src/engine/shared/snapshot.cpp:675
    0x55823481be65 in CSnapshotDelta::UnpackDelta(CSnapshot*, CSnapshot*, void const*, int) src/engine/shared/snapshot.cpp:380
    0x558234776641 in CDemoPlayer::DoTick() src/engine/shared/demo.cpp:631
    0x5582347861a9 in CDemoPlayer::Update(bool) src/engine/shared/demo.cpp:1007
    0x5582336d4c7d in CClient::Update() src/engine/client/client.cpp:2695
    0x5582336f75dd in CClient::Run() src/engine/client/client.cpp:3305
    0x558233768241 in main src/engine/client/client.cpp:4770
```
2022-07-24 18:00:39 +02:00
Jupeyy 88c4b69301 Add an option to remove weak hook & bounce 2022-07-21 17:04:16 +02:00
Robert Müller 687fd91414 Rename variable m_aEntries to m_vEntries 2022-07-18 21:43:59 +02:00
bors[bot] a9bc4ae113
Merge #5634
5634: Fix clang tidy accessing data pointer r=def- a=ChillerDragon

ddnet/src/engine/client/favorites.cpp:229:23: error: 'data' should be
used for accessing the data pointer instead of taking the address of the
0-th element [readability-container-data-pointer,-warnings-as-errors]
        int Index = pEntry - &m_aEntries[0];
                             ^~~~~~~~~~~~~~
                             (m_aEntries).data()

<!-- 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 (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: ChillerDragon <ChillerDragon@gmail.com>
2022-07-18 14:28:43 +00:00
Robert Müller b594a323a6 Change return type of CNetBase::IsSeqInBackroom from int to bool 2022-07-17 20:51:48 +02:00
Robert Müller 5f7d19d2e0 Use sizeof instead of hardcoded value 2022-07-17 20:51:11 +02:00
Robert Müller 4970a615d8 Remove dead code
The condition `Size < 1` is never true because the previous condition `Size < NET_PACKETHEADERSIZE` (`Size < 3`) already covers it.
2022-07-17 20:34:29 +02:00
ChillerDragon 0d4f38811e Fix clang tidy accessing data pointer
ddnet/src/engine/client/favorites.cpp:229:23: error: 'data' should be
used for accessing the data pointer instead of taking the address of the
0-th element [readability-container-data-pointer,-warnings-as-errors]
        int Index = pEntry - &m_aEntries[0];
                             ^~~~~~~~~~~~~~
                             (m_aEntries).data()
2022-07-16 16:00:38 +02:00
Alexander Akulich 1f264a042d CClient::DemoPlayer_Play: Load map info into m_CurrentServerInfo
This e.g. allows better heuristic in GetGameInfo() (from gameclient.cpp)
2022-07-14 23:38:20 +03:00
Alexander Akulich 6f6337cbf5 CDemoPlayer: Mark GetMapInfo() const 2022-07-14 23:38:20 +03:00
bors[bot] 482f15a711
Merge #5520 #5624
5520: Warn about pnglite-incompatible PNGs on load r=def- a=heinrich5991

This allows a larger range of PNGs to be loaded while still maintaining
backward compatibility with older clients by annoying the user.

This warning can be enabled by the `warn-pnglite-incompatible-images`
key in the https://info2.ddnet.tw/info JSON, if the key is not there or
the JSON hasn't been obtained yet, the warning is disabled. Since the
JSON is cached across restarts, it'll be effective for initially loaded
images from the second start.

## 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)


5624: Move message copy inside `SendPackMsgTranslate` r=def- a=Robyt3

Fix clang warning: Address of stack memory associated with local variable 'aBuf' is still referred to by the stack variable 'tmp' upon returning to the caller.  This will be a dangling reference [clang-analyzer-core.StackAddressEscape]

Mark the input parameters as const pointers and mark the protocol message `Pack` methods as const.

And remove a null check that only serves to hide programmer errors.

## 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: heinrich5991 <heinrich5991@gmail.com>
Co-authored-by: Robert Müller <robytemueller@gmail.com>
2022-07-14 16:38:08 +00:00
heinrich5991 994324b059 Warn about pnglite-incompatible PNGs on load
This allows a larger range of PNGs to be loaded while still maintaining
backward compatibility with older clients by annoying the user.

This warning can be enabled by the `warn-pnglite-incompatible-images`
key in the https://info2.ddnet.tw/info JSON, if the key is not there or
the JSON hasn't been obtained yet, the warning is disabled. Since the
JSON is cached across restarts, it'll be effective for initially loaded
images from the second start.
2022-07-14 18:22:46 +02:00
heinrich5991 4292c9ed77 Convert preprocessor #define to constexpr int 2022-07-14 18:22:46 +02:00
heinrich5991 44eb321d96 Fix name of an std::vector member 2022-07-14 18:22:44 +02:00
bors[bot] dafc3984dd
Merge #5511
5511: Rename cl_show_quads -> cl_showquads r=heinrich5991 a=def-

To reenable quads for everyone who accidentally disabled it or has the
bind to accidentally disable them

<!-- 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>
2022-07-13 20:12:45 +00:00
heinrich5991 7c984df17a Fix UDP connectivity check
The nonsensical index of `m_aNetClients` was introduced during my
rebasing of #5205.

Fixes #5618.
2022-07-11 20:48:28 +02:00
Robert Müller d99ed6d811 Remove null check that potentially hides programming errors 2022-07-11 19:11:32 +02:00
Robert Müller ba1608529e Move message copy inside SendPackMsgTranslate
Fix clang warning: Address of stack memory associated with local variable 'aBuf' is still referred to by the stack variable 'tmp' upon returning to the caller.  This will be a dangling reference [clang-analyzer-core.StackAddressEscape]

Mark the input parameters as const pointers and mark the protocol message `Pack` methods as const.
2022-07-11 19:02:16 +02:00
bors[bot] a3001f3bd1
Merge #5205
5205: Allow multiple addresses per server in the serverbrowser r=def- a=heinrich5991

Support is incomplete for `leak_ip_address_to_all_servers` (will only
ping the first address of each server) and for the `leak_ip` setting
(which will also only ping the first address of each server).

Fixes #5158.

## 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: heinrich5991 <heinrich5991@gmail.com>
2022-07-10 23:31:21 +00:00
bors[bot] 9e1b6cd1e9
Merge #5613
5613: Search in $PATH for server executable (fixes #5594) 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 (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: def <dennis@felsin9.de>
2022-07-10 23:08:57 +00:00
def aa788e228c Search in $PATH for server executable (fixes #5594) 2022-07-10 23:59:28 +02:00
Robert Müller a971a16ed5 Fix readability-duplicate-include 2022-07-10 21:57:13 +02:00
Robert Müller ec4175277e Fix readability-container-data-pointer 2022-07-10 21:42:57 +02:00
Robert Müller ad0ca6090a Fix modernize-use-bool-literals 2022-07-10 21:00:40 +02:00
heinrich5991 8996d152ab Allow multiple connect addresses
This allows the client to connect to servers that have both an IPv4 and
an IPv6 address, even if the client is only connected to one of the two.
The one faster to answer will be picked.

Timeout codes are now generated based on *all* of the server's
addresses.

Fixes #5158.
2022-07-10 16:57:10 +02:00
heinrich5991 89a4a0c5c6 Only compare with old STUN server address if we have any 2022-07-10 16:53:15 +02:00
heinrich5991 a9bf09f769 Move websocket address handling out of the client 2022-07-10 16:53:12 +02:00
heinrich5991 6600024f24 Allow multiple addresses per server in the serverbrowser
Support is incomplete for `leak_ip_address_to_all_servers` (will only
ping the first address of each server) and for the `leak_ip` setting
(which will also only ping the first address of each server).
2022-07-10 16:52:07 +02:00
def eb14755501 Fix compilation in video.cpp
/home/deen/isos/ddnet/ddnet-source/src/engine/client/video.cpp:829:9: error: ‘c’ was not declared in this s
cope
  829 |         c->thread_count = 1;
      |         ^
2022-07-10 01:08:33 +02:00
Alexander Akulich 6d9284adc1 Port some code to str_copy() template 2022-07-09 19:40:58 +03:00
bors[bot] e2f7f53bc8
Merge #5591
5591: (A bit) safer interface for text containers r=def- a=Jupeyy

For #5143
Maybe it helps identifying the problem earlier, maybe not^^

## 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: Jupeyy <jupjopjap@gmail.com>
2022-07-09 09:47:48 +00:00
Jupeyy c6589f3a5e (A bit) safer interface for text containers 2022-07-08 19:19:37 +02:00
Chairn b8840c4571 Replaced magic number with MAX_CHECKPOINTS 2022-07-08 18:01:33 +02:00
Chairn a69dc599a9 Huge variable naming format
Fix pointer and pointer array variable naming

Huge renaming to match our rules

Used regex: (?!(return|delete)\b)\b\w+ (m_|ms_|g_|gs_|s_)[^a]\w+\[
            (?!(return|delete)\b)\b\w+ (?!(m_|ms_|g_|gs_|s_))[^a]\w+\[

Further format static variables

Format almost all pointer names accordingly

Used regex: (?!(return)\b)\b\w+
\*(?!(m_p|p|s_p|m_ap|s_ap|g_p|g_ap|ap|gs_ap|ms_ap|gs_p|ms_p))\w+\b[^:\(p]

clang-format

Fix CI fail

Fix misnamed non pointer as pointer and non array as array

Used regex: (?!(return|delete)\b)\b\w+ (m_|ms_|g_|gs_|s_)p\w+\b
            (?!return\b)\b\w+ (ms_|m_|g_|gs_|s_)a\w+\b[^\[]

clang-format

Revert to SCREAMING_SNAKE_CASE and reinstate dead code
2022-07-08 18:01:29 +02:00