Commit graph

12324 commits

Author SHA1 Message Date
Jupeyy 19928aabd2 Adjust no weak prediction to updated server code 2022-12-15 18:36:29 +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
Robert Müller 612ef8358c Add separate ed_limit_max_zoom_level for editor
To completely separate zoom settings between ingame and editor.
2022-12-15 17:59:46 +01:00
bors[bot] 75d07350f6
Merge #6133
6133: Remove spammy log (thanks Skeith) r=Chairn 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-12-14 16:51:51 +00:00
Dennis Felsing d5cf3630ae Remove spammy log (thanks Skeith) 2022-12-14 17:39:18 +01:00
Patiga a4867d29c6 Make tileflag names consistent and intuitive
- `TILEFLAG_VFLIP` -> `TILEFLAG_FLIP_HORIZONTAL`
- `TILEFLAG_HFLIP` -> `TILEFLAG_FLIP_VERTICAL`

According to the native editor, the "Tiled" editor and image search, a
horizontal flip should be associated with switching left and right, modifying
the x coordinate.

I did not just switch the letters `H` and `V` to create compiler errors
where the original constants are used.

Whenever I was working with tileflags, the naming caused me to have no
idea what I was doing. I mostly had to resort to opening the resulting
map in the editor to see what the code does. This change aims to make
the naming intuitive and also consistent with the map editor.
2022-12-14 13:54:11 +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
Dennis Felsing fe4a8441bf Version 16.6 2022-12-11 23:05:33 +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
bors[bot] 4695a6b0f1
Merge #6118
6118: Copy the demo timeline markers when slicing a demo r=def- a=Robyt3

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.

## 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 13:55:50 +00: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
Robert Müller 71139f33f0 Add separate option for smooth zooming in editor
Add `ed_smooth_zoom_time` option for smooth zooming in editor separate from the `cl_smooth_zoom_time` that's used for smooth zooming ingame, as some mappers seem to prefer unsmooth zooming in the editor but smooth zooming ingame.
2022-12-11 13:14:55 +01:00
bors[bot] 63187f565f
Merge #6111
6111: Fix updating teamranks r=def- a=Zwelf

Fixes #6107

## 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: Zwelf <zwelf@strct.cc>
2022-12-10 12:59:27 +00:00
Zwelf b7205f5ef5 Fix updating teamranks 2022-12-10 00:51:16 +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] f8330950ef
Merge #6109
6109: Add button that tells you how to save power r=heinrich5991 a=def-

![Screenshot 2022-12-08 at 23 09 20](https://user-images.githubusercontent.com/2335377/206578008-d4e9be56-4aab-40eb-bb55-6b087f930888.png)
## Checklist

- [x] Tested the change ingame
- [x] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Dennis Felsing <dennis@felsin9.de>
2022-12-09 22:47:30 +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
Dennis Felsing 7c46b5190b Add button that tells you how to save power 2022-12-08 23:10:02 +01:00
NouaaTW 0bc4e7601e Colorify BW gamemode 2022-12-07 19:29:40 +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 0b3dad8dcd Reduce duplicate code by extracting CEditor::SnapToGrid 2022-12-06 20:18:08 +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] 2dcef1685b
Merge #6094
6094: Check if ghost is really used bcs IntsToStr returns weird stuff for 0… r=def- a=Jupeyy

… integers

--- ignore whitespaces

## 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-12-05 19:34:43 +00:00
Jupeyy bf9e8a4309 Check if ghost is really used bcs IntsToStr returns weird stuff for 0 integers 2022-12-05 20:11:20 +01:00
Dennis Felsing f9c7cc7475 Add credits 2022-12-05 19:21:36 +01: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
Avolicious 59db9ce54b FIX: parse & colorify gametype Gores correctly 2022-12-05 17:03:43 +01: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
Zwelf a7bc593725 Make semaphore wait handle EINTR
from `man sem_wait`:

    EINTR  The call was interrupted by a signal handler; see signal(7).
2022-12-05 16:48:10 +01:00
Zwelf f847215fd0 Notify about possible save codes right away 2022-12-05 16:48:10 +01:00
Jupeyy 2fe7912b1f fix some valgrind conditional jump relies on uninit warnings 2022-12-04 22:54:18 +01:00
Robert Müller 5425708b27 Reduce duplicate code by moving it outside of branches 2022-12-04 13:45:27 +01:00
Robert Müller d35975c9b9 Adjust quad point position and texture U/V relatively
When multiple quad points are selected, adjust the points' positions and texture U/V coordinates relatively instead of setting all points to the same value.

Closes #3359.
2022-12-04 13:45:26 +01:00
Robert Müller b852dad9a2 Fix demo name not being shown in demo player
And slightly increase space for the speed label.
2022-12-04 12:37:09 +01:00
Robert Müller 061f8625f4 Use HandleDemoSeeking for demo skipping
To ensure that components are reset when skipping and that envelopes are updated immediately.
2022-12-04 12:34:17 +01:00
bors[bot] acfc7f8c06
Merge #6060
6060: Add buttons+increased length on demo viewbar r=def- a=l-ouis

Aimed to add some more controls on the demo view bar:

Added tick step buttons and jump to next/prev marker buttons
Increased width of demo controls panel so it wasn't as cluttered
changed export cut icon to a common export icon instead of the camcorder icon
Centered the time multiplier between the buttons it was between

![image](https://user-images.githubusercontent.com/69405348/202874985-9d983959-9188-4d96-9a2d-633621e6f489.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: louis <louisaltgeer@gmail.com>
2022-12-04 11:09:39 +00:00
Zwelf 2268c08e05 Fix heap-buffer-overflow in DDNetLaser prediction code
Found while playing the Exit when doing the part at x:35 y:219.
Verified that with the fix applied the crash doesn't happen anymore.

asan output:

```
=================================================================
==10996==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x62000001de20 at pc 0x5555575208d0 bp 0x7fffffff4710 sp 0x7fffffff4708
READ of size 4 at 0x62000001de20 thread T0
[Detaching after fork from child process 11277]
    #0 0x5555575208cf in ExtractLaserInfoDDNet(CNetObj_DDNetLaser const*, CGameWorld*) /home/user/.local/bin/ddnet/src/src/game/client/laser_data.cpp:36:27
    #1 0x5555575af9c8 in CGameWorld::NetObjAdd(int, int, void const*, CNetObj_EntityEx const*) /home/user/.local/bin/ddnet/src/src/game/client/prediction/gameworld.cpp:493:11
    #2 0x5555574bf201 in CGameClient::UpdatePrediction() /home/user/.local/bin/ddnet/src/src/game/client/gameclient.cpp:2452:15
    #3 0x5555574aad89 in CGameClient::OnNewSnapshot() /home/user/.local/bin/ddnet/src/src/game/client/gameclient.cpp:1729:3
    #4 0x5555569562c7 in CClient::Update() /home/user/.local/bin/ddnet/src/src/engine/client/client.cpp:2751:22
    #5 0x55555696e4bd in CClient::Run() /home/user/.local/bin/ddnet/src/src/engine/client/client.cpp:3260:4
    #6 0x5555569caa8b in main /home/user/.local/bin/ddnet/src/src/engine/client/client.cpp:4753:11
    #7 0x7ffff4ea9d09 in __libc_start_main csu/../csu/libc-start.c:308:16
    #8 0x5555560f55c9 in _start (/home/user/.local/bin/ddnet/build-fast/DDNet+0xba15c9) (BuildId: 6d1b5aed4fc199ba75cdc083de5ada540ca4612b)

0x62000001de20 is located 0 bytes after 3488-byte region [0x62000001d080,0x62000001de20)
allocated by thread T0 here:
    #0 0x55555618e36e in __interceptor_malloc (/home/user/.local/bin/ddnet/build-fast/DDNet+0xc3a36e) (BuildId: 6d1b5aed4fc199ba75cdc083de5ada540ca4612b)
    #1 0x555556382591 in CSnapshotStorage::Add(int, long, int, void*, int, void*) /home/user/.local/bin/ddnet/src/src/engine/shared/snapshot.cpp:518:32
    #2 0x55555693aa6e in CClient::ProcessServerPacket(CNetChunk*, int, bool) /home/user/.local/bin/ddnet/src/src/engine/client/client.cpp:2088:31
    #3 0x55555694b48c in CClient::PumpNetwork() /home/user/.local/bin/ddnet/src/src/engine/client/client.cpp:2556:4
    #4 0x55555695ca61 in CClient::Update() /home/user/.local/bin/ddnet/src/src/engine/client/client.cpp:2868:2
    #5 0x55555696e4bd in CClient::Run() /home/user/.local/bin/ddnet/src/src/engine/client/client.cpp:3260:4
    #6 0x5555569caa8b in main /home/user/.local/bin/ddnet/src/src/engine/client/client.cpp:4753:11
    #7 0x7ffff4ea9d09 in __libc_start_main csu/../csu/libc-start.c:308:16

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/user/.local/bin/ddnet/src/src/game/client/laser_data.cpp:36:27 in ExtractLaserInfoDDNet(CNetObj_DDNetLaser const*, CGameWorld*)
Shadow bytes around the buggy address:
  0x62000001db80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x62000001dc00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x62000001dc80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x62000001dd00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x62000001dd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x62000001de00: 00 00 00 00[fa]fa fa fa fa fa fa fa fa fa fa fa
  0x62000001de80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x62000001df00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x62000001df80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x62000001e000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x62000001e080: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==10996==ABORTING
```
2022-12-04 10:19:35 +01:00
louis b5eef1b64b added offset, fix my git issues
added demomarker offset

Revert "why is this here"

This reverts commit a8c74b612300d6563b28a2bea733a0d3a7dd7f90.

fix
2022-12-03 23:41:50 -06:00
bors[bot] 8d17670c67
Merge #6082
6082: Fix incorrect cursor position after exiting pause/spec r=def- a=Robyt3

The cursor position was not correctly restored when exiting pause or spec, when the mouse was on the left side of the tee (x being negative).

This is caused by a calculation introduced in #1637 and #1830 that tries to ensure that the mouse can still be moved if it ends up inside the minimum mouse distance (`cl_mouse_min_distance` and `cl_dyncam_min_distance`). However, this did not consider that the x position can become negative, so the x position was also incorrectly changed when exiting pause.

This is fixed by reverting the changes, as this code has become obsolete and has been superseded by #2009 and #3884. The `CControls::ClampMousePos` function, which is called directly after restoring the position, already ensures that mouse is not stuck within the minimum mouse distance.

Closes #2591.

## Checklist

- [X] Tested the change ingame
- [ ] 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
- [ ] Considered possible null pointers and out of bounds array indexing
- [X] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Robert Müller <robytemueller@gmail.com>
2022-12-03 22:39:20 +00:00
Robert Müller c3286ff263 Fix incorrect cursor position after exiting pause/spec
The cursor position was not correctly restored when exiting pause or spec, when the mouse was on the left side of the tee (x being negative).

This is caused by a calculation introduced in #1637 and #1830 that tries to ensure that the mouse can still be moved if it ends up inside the minimum mouse distance (`cl_mouse_min_distance` and `cl_dyncam_min_distance`).
However, this did not consider that the x position can become negative, so the x position was also incorrectly changed when exiting pause.

This is fixed by reverting the changes, as this code has become obsolete and has been superseded by #2009 and #3884. The `CControls::ClampMousePos` function, which is called directly after restoring the position, already ensures that mouse is not stuck within the minimum mouse distance.

Closes #2591.
2022-12-03 22:20:53 +01:00
Robert Müller 5903c25799 Add cancel button to country popup, confirm with list item activation
Add "Cancel" button to country/region picker popup. It's already possible to cancel with the Escape key, so there should also be a button, which keeps the current selection.

Delegate the listbox activation (enter / double click on item) to the popup to confirm it. Enter was previously working but then broken by the logic that ensures that every hotkey is only consumed once. Now both enter and double click confirm the popup.

From teeworlds/teeworlds#2961.
2022-12-03 13:52:23 +01:00
Robert Müller 5994812a1c Rename variable CurSelection to s_CurSelection 2022-12-03 13:52:17 +01:00
Robert Müller 9b719ef61c Add confirmation popup for resetting controls to defaults
To avoid accidentally losing all binds.
2022-12-03 13:49:15 +01:00
Robert Müller a45f833afa Replace POPUP_SWITCH_SERVER with generic confirmation popup 2022-12-03 13:49:14 +01:00
Robert Müller cb1d9ccc98 Replace POPUP_REPLACE_VIDEO with generic confirmation popup
And show the name of the video that will be overwriten in the popup.

Make the buttons in `POPUP_RENDER_DEMO` the same height as in all other popups.
2022-12-03 13:49:14 +01:00
Robert Müller 8da68bf52a Replace POPUP_SOUNDERROR with generic message popup 2022-12-03 13:49:14 +01:00
Robert Müller 620e3e56db Replace POPUP_DISCONNECT(_DUMMY) with generic confirmation popup 2022-12-03 13:49:14 +01:00
Robert Müller f4708a3a00 Replace POPUP_REMOVE_FRIEND with generic confirmation popup
And show the name of the friend or clan that will be removed in the popup.
2022-12-03 13:49:13 +01:00
Robert Müller dd60c84426 Replace POPUP_DELETE_DEMO with generic confirmation popup
And show the name of the file that will be deleted in the popup.
2022-12-03 13:49:13 +01:00
Robert Müller 55b576cd7f Add generic confirm popup to menu, adapt generic message popup
Add a generic popup to confirm an operation to the menu and revise the generic message popup similar to this.

Both popups have a title and a message. The message popup has one button and the confirmation popup has two buttons.
For each button a label, the next popup after clicking the button, and a custom button handler can be set.

From teeworlds/teeworlds#2598.
2022-12-03 13:49:12 +01:00
Robert Müller 077b0eeaab Add "Tools > Remove unused envelopes" to editor
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.

Closes #2576.
2022-12-03 11:04:50 +01:00
Robert Müller f000fcea29 Add generic confirmation popup to editor
Add `CEditor::ShowPopupConfirm` to show a generic confirmation popup.

This popups shows a message and buttons to confirm or cancel an operation. The result will be available to the caller in the given `SConfirmPopupContext`.
2022-12-03 11:04:49 +01:00
Robert Müller 3ba51c476f Extract SSelectionPopupContext::Reset to reduce duplicate code 2022-12-03 11:04:49 +01:00
Vy0x2 36939475e2 Add logs for moderators 2022-12-01 00:55:52 +01:00
bors[bot] 3012a42ea0
Merge #6075 #6076
6075: Fix key reader text flashing for one frame, refactoring r=def- a=Robyt3

The key reader was displaying the old key for a frame. It now shows the new key immediately without flashing the old one after changing a bind.

Refactoring:

- The if-branches are restructured to be the same as on upstream.
- The function `GetKeyBindModifiersName` can be called without an additional check, because it returns an empty string when no modifier is pressed.
- The unused parameter `Checked` of the `DoButton_KeySelect` function is removed.

From teeworlds/teeworlds#2877.

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


6076: Fix stored commands using original callback instead of the chain, fix client crash when launching with `screenshot` command r=def- a=Robyt3



## Checklist

- [X] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Robert Müller <robytemueller@gmail.com>
2022-11-29 23:06:01 +00: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 aa321cd887 Move index check before usage, use std::size
According to cppchecker's `arrayIndexThenCheck` error:

```
src\game\client\race.cpp:24:30: style: Array index 'i' is used before limits check. [arrayIndexThenCheck]
  for(int i = 0; isdigit(pStr[i]) && i < 3; i++)
                             ^
```
2022-11-29 23:32:31 +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 0f2590801d Clarify operator precedence
According to cppcheck's `clarifyCalculation` error:

```
src\game\client\components\hud.cpp:196:49: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]
   float ImageSize = GameFlags & GAMEFLAG_FLAGS ? 16.0f : Split;
                                                ^
src\game\editor\layer_tiles.cpp:544:94: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]
    m_pTiles[y * m_Width + x].m_Flags ^= m_pTiles[y * m_Width + x].m_Flags & TILEFLAG_ROTATE ? TILEFLAG_HFLIP : TILEFLAG_VFLIP;
                                                                                             ^
src\game\editor\layer_tiles.cpp:560:94: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]
    m_pTiles[y * m_Width + x].m_Flags ^= m_pTiles[y * m_Width + x].m_Flags & TILEFLAG_ROTATE ? TILEFLAG_VFLIP : TILEFLAG_HFLIP;
                                                                                             ^
```
2022-11-29 23:32:30 +01:00
Robert Müller f46c9f9079 Remove redundant conditional expression before assignment
According to cppcheck's `duplicateConditionalAssign` error:

```
src\game\client\gameclient.cpp:1439:39: style: The statement 'if (m_aFlagDropTick[TEAM_RED]!=0) m_aFlagDropTick[TEAM_RED]=0' is logically equivalent to 'm_aFlagDropTick[TEAM_RED]=0'. [duplicateConditionalAssign]
    else if(m_aFlagDropTick[TEAM_RED] != 0)
                                      ^
src\game\client\gameclient.cpp:1440:32: note: Assignment 'm_aFlagDropTick[TEAM_RED]=0'
     m_aFlagDropTick[TEAM_RED] = 0;
                               ^
src\game\client\gameclient.cpp:1439:39: note: Condition 'm_aFlagDropTick[TEAM_RED]!=0' is redundant
    else if(m_aFlagDropTick[TEAM_RED] != 0)
                                      ^
src\game\client\gameclient.cpp:1446:40: style: The statement 'if (m_aFlagDropTick[TEAM_BLUE]!=0) m_aFlagDropTick[TEAM_BLUE]=0' is logically equivalent to 'm_aFlagDropTick[TEAM_BLUE]=0'. [duplicateConditionalAssign]
    else if(m_aFlagDropTick[TEAM_BLUE] != 0)
                                       ^
src\game\client\gameclient.cpp:1447:33: note: Assignment 'm_aFlagDropTick[TEAM_BLUE]=0'
     m_aFlagDropTick[TEAM_BLUE] = 0;
                                ^
src\game\client\gameclient.cpp:1446:40: note: Condition 'm_aFlagDropTick[TEAM_BLUE]!=0' is redundant
    else if(m_aFlagDropTick[TEAM_BLUE] != 0)
                                       ^
```
2022-11-29 23:32:30 +01:00
Robert Müller 19bf435d6a Remove redundant assignments
According to cppcheck's `redundantInitialization` and `redundantAssignment` errors:

```
src\game\client\ui.cpp:456:5: style: Redundant initialization for 'tw'. The initialized value is overwritten before it is read. [redundantInitialization]
 tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
    ^
src\game\client\ui.cpp:454:11: note: tw is initialized
 float tw = std::numeric_limits<float>::max();
          ^
src\game\client\ui.cpp:456:5: note: tw is overwritten
 tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
    ^
src\game\client\ui.cpp:529:5: style: Redundant initialization for 'tw'. The initialized value is overwritten before it is read. [redundantInitialization]
 tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
    ^
src\game\client\ui.cpp:527:11: note: tw is initialized
 float tw = std::numeric_limits<float>::max();
          ^
src\game\client\ui.cpp:529:5: note: tw is overwritten
 tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
    ^

src\game\editor\editor.cpp:6051:19: style: Variable 'm_Map.m_Modified' is reassigned a value before the old one has been used. [redundantAssignment]
 m_Map.m_Modified = false;
                  ^
src\game\editor\editor.cpp:6046:19: note: m_Map.m_Modified is assigned
 m_Map.m_Modified = false;
                  ^
src\game\editor\editor.cpp:6051:19: note: m_Map.m_Modified is overwritten
 m_Map.m_Modified = false;
                  ^

src\game\client\prediction\entities\character.cpp:1148:36: style: Variable 'm_LatestInput' is reassigned a value before the old one has been used. [redundantAssignment]
 m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input;
                                   ^
src\game\client\prediction\entities\character.cpp:1134:16: note: m_LatestInput is assigned
 m_LatestInput = m_LatestPrevInput = m_PrevInput = m_Input = m_SavedInput;
               ^
src\game\client\prediction\entities\character.cpp:1148:36: note: m_LatestInput is overwritten
 m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input;
                                   ^
src\game\client\prediction\entities\character.cpp:1148:20: style: Variable 'm_LatestPrevInput' is reassigned a value before the old one has been used. [redundantAssignment]
 m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input;
                   ^
src\game\client\prediction\entities\character.cpp:1134:36: note: m_LatestPrevInput is assigned
 m_LatestInput = m_LatestPrevInput = m_PrevInput = m_Input = m_SavedInput;
                                   ^
src\game\client\prediction\entities\character.cpp:1148:20: note: m_LatestPrevInput is overwritten
 m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input;
                   ^
src\game\client\prediction\entities\character.cpp:1148:50: style: Variable 'm_PrevInput' is reassigned a value before the old one has been used. [redundantAssignment]
 m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input;
                                                 ^
src\game\client\prediction\entities\character.cpp:1134:50: note: m_PrevInput is assigned
 m_LatestInput = m_LatestPrevInput = m_PrevInput = m_Input = m_SavedInput;
                                                 ^
src\game\client\prediction\entities\character.cpp:1148:50: note: m_PrevInput is overwritten
 m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input;
                                                 ^
```
2022-11-29 23:32:29 +01:00
Robert Müller 4197e8d0b0 Fix bool being assigned to float variable
According to cppcheck's `assignBoolToFloat` error:

```
src\game\client\components\menus_settings.cpp:634:13: style: Boolean value assigned to floating point variable. [assignBoolToFloat]
  Highlight = (m_Dummy) ? g_Config.m_ClDummyDefaultEyes == CurrentEyeEmote : g_Config.m_ClPlayerDefaultEyes == CurrentEyeEmote;
            ^
src\game\client\gameclient.cpp:320:23: style: Boolean value assigned to floating point variable. [assignBoolToFloat]
 m_LastDummyConnected = false;
                      ^
src\game\client\gameclient.cpp:563:23: style: Boolean value assigned to floating point variable. [assignBoolToFloat]
 m_LastDummyConnected = false;
                      ^
```
2022-11-29 23:32:28 +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 8e675878b0 Remove redundant null-checks
According to cppcheck's `nullPointerRedundantCheck` check:

```
src\game\client\components\menus_settings.cpp:729:8: warning: Either the condition 'pSkinToBeSelected==0' is redundant or there is possible null pointer dereference: pSkinToBeSelected. [nullPointerRedundantCheck]
   if((pSkinToBeSelected->GetName()[0] == 'x' && pSkinToBeSelected->GetName()[1] == '_'))
       ^
src\game\client\components\menus_settings.cpp:732:25: note: Assuming that condition 'pSkinToBeSelected==0' is not redundant
   if(pSkinToBeSelected == 0)
                        ^
src\game\client\components\menus_settings.cpp:729:8: note: Null pointer dereference
   if((pSkinToBeSelected->GetName()[0] == 'x' && pSkinToBeSelected->GetName()[1] == '_'))
       ^

src\game\editor\editor.cpp:5034:19: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck]
  float EndTime = pEnvelope->EndTime();
                  ^
src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant
   if(pEnvelope)
      ^
src\game\editor\editor.cpp:5034:19: note: Null pointer dereference
  float EndTime = pEnvelope->EndTime();
                  ^
src\game\editor\editor.cpp:5038:3: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck]
  pEnvelope->FindTopBottom(s_ActiveChannels);
  ^
src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant
   if(pEnvelope)
      ^
src\game\editor\editor.cpp:5038:3: note: Null pointer dereference
  pEnvelope->FindTopBottom(s_ActiveChannels);
  ^
src\game\editor\editor.cpp:5039:15: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck]
  float Top = pEnvelope->m_Top;
              ^
src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant
   if(pEnvelope)
      ^
src\game\editor\editor.cpp:5039:15: note: Null pointer dereference
  float Top = pEnvelope->m_Top;
              ^
src\game\editor\editor.cpp:5040:18: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck]
  float Bottom = pEnvelope->m_Bottom;
                 ^
src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant
   if(pEnvelope)
      ^
src\game\editor\editor.cpp:5040:18: note: Null pointer dereference
  float Bottom = pEnvelope->m_Bottom;
                 ^
src\game\editor\editor.cpp:5081:23: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck]
   for(int c = 0; c < pEnvelope->m_Channels; c++)
                      ^
src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant
   if(pEnvelope)
      ^
src\game\editor\editor.cpp:5081:23: note: Null pointer dereference
   for(int c = 0; c < pEnvelope->m_Channels; c++)
                      ^
```
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 39749a3ff8 Fix optional arguments of map_create_pixelart tool
According to cppcheck's `knownConditionTrueFalse` error:

```
src\tools\map_create_pixelart.cpp:58:24: style: Condition 'argc>=10' is always true [knownConditionTrueFalse]
 aArtOptions[0] = argc >= 10 ? str_toint(argv[10]) : true; //optimize
                       ^
src\tools\map_create_pixelart.cpp:34:10: note: Assuming that condition 'argc<11' is not redundant
 if(argc < 11 || argc > 12)
         ^
src\tools\map_create_pixelart.cpp:58:24: note: Condition 'argc>=10' is always true
 aArtOptions[0] = argc >= 10 ? str_toint(argv[10]) : true; //optimize
                       ^
src\tools\map_create_pixelart.cpp:59:24: style: Condition 'argc>=11' is always true [knownConditionTrueFalse]
 aArtOptions[1] = argc >= 11 ? str_toint(argv[11]) : false; //centralize
                       ^
src\tools\map_create_pixelart.cpp:34:10: note: Assuming condition 'argc<11' is false
 if(argc < 11 || argc > 12)
         ^
src\tools\map_create_pixelart.cpp:59:24: note: Condition 'argc>=11' is always true
 aArtOptions[1] = argc >= 11 ? str_toint(argv[11]) : false; //centralize
                       ^
```
2022-11-29 23:32:26 +01:00
Robert Müller be74dc9471 Return actual bool from bool function
According to cppcheck's `returnNonBoolInBooleanFunction` error.
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 0a0ddf2145 Pass parameters by const reference instead of value when possible
According to cppcheck's `passedByValue` error.
2022-11-29 23:32:25 +01:00
Robert Müller 78876abd46 Remove unused members CColumn::m_Flags 2022-11-29 23:32:23 +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
Robert Müller 0688355d7b Fix key reader text flashing for one frame, refactoring
The key reader was displaying the old key for a frame. It now shows the new key immediately without flashing the old one after changing a bind.

Refactoring:

- The if-branches are restructured to be the same as on upstream.
- The function `GetKeyBindModifiersName` can be called without an additional check, because it returns an empty string when no modifier is pressed.
- The unused parameter `Checked` of the `DoButton_KeySelect` function is removed.

From teeworlds/teeworlds#2877.
2022-11-29 22:25:47 +01:00
Robert Müller 10433e0c71 Reset teams when restarting round
The state of teams was not reset when restarting a round with `restart`, which led to various issues (#5144):

- Switchers kept their previous state instead of being reset to the initial state after restarting.
- Teams that started racing sometimes could not be joined after restarting.
- Sometimes teams cannot finish a race after restarting. I cannot reproduce this issue, so I don't know if it's fixed by these changes.
2022-11-29 21:56:59 +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
Vy0x2 ce9ad5b603 add reason to vote mutes, fix team chat 2022-11-27 18:58: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 5e06eefcd2 Implement smooth zoom for editor
Port the smooth zoom code from the ingame camera to the editor with some minor adjustments.

The smooth zoom animation time can be adjusted with the existing `cl_smooth_zoom_time` config variable.

Closes #2525.
2022-11-23 23:06:20 +01:00
bors[bot] 2333f8e353
Merge #6058
6058: Fix invalid demo cutting, Add slice highlighting r=Chairn a=VoxelDoesCode

Before, you could place an end slice before the beginning, creating a "zero second" demo, which doesn't play in client, and renders a corrupt file. I implemented a check where if the playhead is before the beginning slice, it won't place an end slice, and vice versa. 

I also added highlighting in between the slices, so that it's easier to see.
![image](https://user-images.githubusercontent.com/95713843/202870840-216df4d7-975e-496d-b122-c819ce7ae6ee.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-11-22 10:24:48 +00:00
VoxelDoesCode cc2e40dd90 Reset slice markers if invalid 2022-11-21 20:19:58 -05: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
bors[bot] 87679f59a8
Merge #6061
6061: Add friend counter + Change alignment of player count text r=def- a=l-ouis

Added friend counter, changed the alignment of player count indicator to better accommodate friend counter + line up with the "Players" text at the top of the tab

![image](https://user-images.githubusercontent.com/69405348/202891241-b76899cf-e65a-4085-804b-0a6877468fbc.png)

Fixes #5911


## 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: louis <louisaltgeer@gmail.com>
2022-11-20 19:36:16 +00:00
louis d791fa3412 Modified layout
Player count right justified
Heart on left, number of friends below heart
Slightly reduced space for server name column
2022-11-20 13:26:53 -06:00
louis 739c77d3d7 Added threshold, skips to end/beginning
Threshold makes skipping multiple times in a row consistent

If no markers ahead or behind, will skip to beginning or end
2022-11-20 12:12:00 -06: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
louis 1609422c95 fix clang format
removed blankspace
2022-11-20 08:52:01 -06:00
louis 615f8e9354 Update menus_browser.cpp
Added friend counter, changed alignment of player count indicator
2022-11-20 01:37:14 -06:00
louis 23287528ab Update menus_demo.cpp 2022-11-19 22:00:20 -06:00
louis a1680b30f7 Update menus_demo.cpp
fix clang style
2022-11-19 17:32:47 -06:00
louis 74c6c5c960 Add buttons+increased length
Added tick step buttons and jump to next/prev marker buttons

Increased width of demo controls panel

Centered the time multiplier
2022-11-19 16:36:57 -06:00
VoxelDoesCode 0761f4a8ae Fix invalid demo cutting, Add slice highlighting
Remove option (again)
2022-11-19 15:36:54 -05:00
bors[bot] 56088cb4b0
Merge #6054
6054: Fix editor crash when shifting left/right, fix wrong up/down shifting r=heinrich5991 a=Robyt3

Shifting left/right with a shift value greater than the layer's width crashed the game due to a heap-buffer-overflow.

Shifting up/down with a shift value greater or equal to half the layer's height did not correctly shift the entire layer.

The values of the enum constants `DIRECTION_*` are changed to consecutive numbers instead of exponents of two, as the directions cannot be combined together as flags.

Closes #6036.

## 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: Robert Müller <robytemueller@gmail.com>
2022-11-16 20:27:02 +00:00
Robert Müller 8c5bf10d44 Fix editor crash when shifting left/right, fix wrong up/down shifting
Shifting left/right with a shift value greater than the layer's width crashed the game due to a heap-buffer-overflow.

Shifting up/down with a shift value greater or equal to half the layer's height did not correctly shift the entire layer.

The values of the enum constants `DIRECTION_*` are changed to consecutive numbers instead of exponents of two, as the directions cannot be combined together as flags.

Closes #6036.
2022-11-16 20:55:44 +01:00
Robert Müller 4af20240fc Add Shift+G editor hotkey to toggle visibility of game layers
If any game layers are hidden, the hotkey will make them visible.
Else, if all game layers are visible, the hotkey will hide all of them.

Closes #4109.
2022-11-16 18:09:03 +01:00
Robert Müller ab9b6c2b80 Allow both shift keys to be used for all hotkeys
Handle both shift keys in some cases where only the left shift key was previously supported.

The `CChat::m_ReverseTAB` variable is removed because it's unnecessary.
2022-11-15 21:17:55 +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
Robert Müller 26c95de743 Remove dead code that compares pointers of different types
This condition cannot be true, as `pGroup` is a `CLayerGroup *` but the layers are `CLayer *`/`CLayerTiles *`/`CLayerGame *` etc., which are not part of the same inheritance hierarchy.

The method `CLayerGroup::Render` already ensures that game layers are not rendered below other layers.
2022-11-15 21:17:55 +01:00
Robert Müller 91ba786b67 Only disable clipping if it was previously enabled 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
bors[bot] bc4a5ee6f5
Merge #6033
6033: Add more tests for hashing, `CSemaphore` and utf8 confusables r=heinrich5991 a=Robyt3



## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [X] 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-12 20:28:52 +00:00
Robert Müller 7c63d3c277 Remove internal utf8 confusable functions from system.h
The functions `str_utf8_skeleton_begin` and `str_utf8_skeleton_next` and the `struct SKELETON` are only used internally, so they don't need to be exported.
2022-11-12 20:56:35 +01:00
Robert Müller 0bf31c671e Add tests for str_utf8_to_skeleton 2022-11-12 20:36:39 +01:00
Robert Müller dab6bbf4fd Add more tests for str_utf8_comp_confusable
Also check first string being shorter than second string. And check strings with equal and unequal prefix and suffix.
2022-11-12 20:36:38 +01:00
Robert Müller ab42651dc7 Add test for the CSemaphore wrapper 2022-11-12 20:36:38 +01:00
Robert Müller a113a03eaf Add tests for overloaded hash operators, use operator instead
Using `EXPECT_EQ` directly doesn't seem to register as code coverage for the `==` operators, so `EXPECT_TRUE` is used instead.
2022-11-12 20:36:38 +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
Robert Müller ea06a13429 Fix aliasing warnings in CGameContext::OnMapChange
Fix warnings with `-fstrict-aliasing` and `-Wstrict-aliasing=2` by not casting the map reader data to `int *`:

```
src/game/server/gamecontext.cpp: In member function 'virtual void CGameContext::OnMapChange(char*, int)':
src/game/server/gamecontext.cpp:3623:56: warning: dereferencing type-punned pointer might break strict-aliasing rules [-Wstrict-aliasing]
 3623 |                                         pData = (int *)&MapInfo;
      |                                                        ^~~~~~~~
src/game/server/gamecontext.cpp:3631:48: warning: dereferencing type-punned pointer might break strict-aliasing rules [-Wstrict-aliasing]
 3631 |                                 pData = (int *)&MapInfo;
      |                                                ^~~~~~~~
```

As the map reader data is return as `void *` and never used as `int *`, the redundant cast is removed to fix the warnings.

Also improve readability by moving `pInfo` variable declaration.
2022-11-12 20:18:32 +01:00
VoxelDoesCode 5d1bec5a83 Change editor UI, fix an overflow bug.
clang

clang2
2022-11-11 20:36:15 -05:00
bors[bot] aef6a8b370
Merge #6024
6024: Fix CGun::Fire server crash (fixes #6023) r=Learath2 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-11-11 10:32:15 +00:00
Dennis Felsing 3fff1fdc82 Don't cast write parameter for FindEntities
I think at the point where you use (CEntity **) apPlayersInRange the
compiler says this is a totally different value than apPlayersInRange
since they have a different type. And then it reorders the inlined
FindEntities code to be run afterwards, thus leading to undefined
behavior and crashes.
2022-11-09 23:08:00 +01:00
heinrich5991 80d72cf157 Fix being run from rust-analyzer with a clean environment
Detect that we're being run from rust-analyzer and don't link to C++
libraries in that case.

Fixes #6019.
2022-11-09 15:09:42 +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 2d1d7b9562 Replace duplicate condition with a check for empty string 2022-11-06 16:25:24 +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
ChillerDragon 0211f79ef0 Add tests for int packer 2022-11-06 14:49:40 +01:00
Robert Müller fcec553599 Use pi instead of 3.14159f 2022-11-06 11:52:21 +01:00
Robert Müller 4d0cd7f807 Use traditional casts instead of functional-style casts 2022-11-06 11:52:21 +01:00