Commit graph

11838 commits

Author SHA1 Message Date
Robert Müller 37cadc5c09 Add CWindowsComLifecycle RAII wrapper for Windows COM library 2022-08-21 10:34:37 +02:00
bors[bot] 4fc6a5b924
Merge #5754 #5757
5754: Auto refresh skins when changing related settings r=def- a=Jupeyy

motivation: downloaded skins aren't resettet, e.g. if they failed before. config change -> resets everything

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


5757: Make file link absolute, add `fs_is_relative_path` r=def- a=Robyt3

This fixes links not opening for relative paths, as links like `file://temp/skins` cannot be resolved by the shell.

Closes #5746.

## Checklist

- [X] Tested the change ingame (only on Windows)
- [ ] 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>
Co-authored-by: Robert Müller <robytemueller@gmail.com>
2022-08-20 20:34:45 +00:00
Robert Müller 21fe945ca7 Make file link absolute, add fs_is_relative_path
This fixes links not opening for relative paths, as links like `file://temp/skins` cannot be resolved by the shell.
2022-08-20 20:56:46 +02:00
Robert Müller ec55212c52 Fix symlink handling of fs_listdir
On Windows, the check was incorrectly using logical or instead of bitwise or. Checking for the flag `FILE_ATTRIBUTE_REPARSE_POINT` is not necessary, as the `FILE_ATTRIBUTE_DIRECTORY` will correctly be set when the target of a symbolic link is a directory. This otherwise causes symbolic links to files to be incorrectly handled as directories.

On Linux, the minor performance optimization of using `entry->d_type` is reverted and `fs_is_dir` is used instead. This internally uses `stat`, which correctly returns the attributes for the symbolic link targets.
2022-08-20 15:57:43 +02:00
Jupeyy 6e5c5cba8f Filter vanilla only skins at loading already 2022-08-20 14:39:25 +02:00
Jupeyy d1b8d53619 Auto refresh skins when changing related settings 2022-08-20 13:42:28 +02:00
bors[bot] 6a5d99daf1
Merge #5749
5749: Editor: added the possibility to duplicate layers r=def- a=archimede67

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

Suggested by Pulsar a few years ago, I finally had the motivation to do it. We can now duplicate any non-special layer (tiles, quads and sounds) thanks to a button just above the delete button.

![image](https://user-images.githubusercontent.com/13364635/185260070-cd5b4c8f-5827-457c-b505-176751003dbc.png)

For each duplicated layers, all the necessary properties are duplicated, for example name, color, flags, etc.
For a tile layer, all the placed tiles are copied. Same goes for a sound layer, all sources are copied. And for the quads layer, all the quads are duplicated.

## Checklist

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


Co-authored-by: Corantin H <archi0670@gmail.com>
2022-08-19 13:25:44 +00:00
Corantin H 29a3baaa75 Editor: added the possibility to duplicate layers 2022-08-19 13:20:50 +02:00
VoxelDoesCode fa98ad1e36 Remove the need for file_icons.png 2022-08-19 01:05:02 -04:00
bors[bot] ecc5ca5602
Merge #5750
5750: List symlinks in list_dir r=def- a=Patiga

This functionality was lost in 082e26d5b
In my case I have a lot of symlinks in the maps folder (Downloads, ddnet-maps, map_archive)

On windows, I have neither tested this behavior before nor after this patch. Could someone maybe try it out there?

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

## Checklist

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


Co-authored-by: Patiga <dev@patiga.eu>
2022-08-18 12:08:31 +00:00
Patiga b580b83d31 List symlinks in list_dir
This functionality was lost in 082e26d5b
In my case I have a lot of symlinks in the maps folder (Downloads,
ddnet-maps, map_archive)
2022-08-18 12:51:22 +02:00
VoxelDoesCode 1807bb7b1e Update icons and clean up 2022-08-17 20:28:24 -04:00
VoxelDoesCode 470ee65db9 DoButton_Sprite > DoButtonFontIcon 2022-08-17 04:28:09 -04:00
VoxelDoesCode a1617dcf56 Replace all images with unicode chars 2022-08-17 03:58:13 -04:00
Robert Müller f0b0d4c163 Improve "couldn't open..." error messages by listing target 2022-08-16 17:35:47 +02:00
Robert Müller f0c74f72ba Smooth console completion scrolling 2022-08-15 23:20:37 +02:00
Alexander Akulich 670f284194 Use GAME_NAME definition for engine initialization 2022-08-15 16:07:27 +03:00
Alexander Akulich 8ac84948c5 Extract server main() to its own file
Also extract CServerLogger to own files.
2022-08-15 16:07:27 +03:00
Alexander Akulich ec16daa4b4 CCharacter: Drop non-const IsAlive() getter 2022-08-15 15:05:59 +03:00
Alexander Akulich 301355d588 engine/server.h: Remove outdated comment 2022-08-15 15:05:59 +03:00
bors[bot] 4826eb1df0
Merge #5730
5730: Move `CUIRect` to separate file, move `CRenderTools::DrawUIRect/4` to `CUIRect::Draw/4`, merge `CUIEx` into `CUI` r=def- a=Robyt3

Adopt UI refactorings from upstream:
- move `CUIRect` into a separate file
  - this allows some includes of `ui.h` to be removed, most importantly in `render.h`
- move `CRenderTools::DrawUIRect/4` to `CUIRect::Draw/4`
  - this object orientied calling style makes it easier to write the code

The `CUIEx` class is merged into the `CUI` class, as there is no need for two different UI classes anymore.

## Checklist

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


Co-authored-by: Robert Müller <robytemueller@gmail.com>
2022-08-14 11:55:24 +00:00
bors[bot] cebcc885ab
Merge #5735
5735: Minor refactoring of editor IO r=def- a=Robyt3

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

## Checklist

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


Co-authored-by: Robert Müller <robytemueller@gmail.com>
2022-08-14 11:24:15 +00:00
Robert Müller 813522f1fc Add/use temporary variables to improve readability 2022-08-14 13:12:21 +02:00
Robert Müller 45a20ff277 Only load and unload normal tile layer data if necessary 2022-08-14 13:12:21 +02:00
sctt eab5fb10e3
Fixed index typo map_find_env 2022-08-13 21:54:56 +02:00
sctt 77fa0acbb1
Fixed index typo map_find_env 2022-08-13 21:49:53 +02:00
sctt 71622eabb4
Fix map_find_env style 2022-08-13 19:29:16 +02:00
sctt e21ade4294
Rename map_find_env to map_find_env.cpp 2022-08-13 19:10:03 +02:00
sctt c8b4b3f631
Added map_find_env tool 2022-08-13 18:53:56 +02:00
c0d3d3v 780c4db7dd
do an int check for m_FreezeEnd instad of float, becuase it is int 2022-08-13 15:43:38 +02:00
c0d3d3v 0aa46b54ea
small fix for #5729 2022-08-12 22:38:13 +02:00
Robert Müller 51fb3e9a22 Merge CUIEx class into CUI
There is no need to separate the UI in two classes anymore, as the dependency on `CRenderTools` has been removed.
2022-08-12 19:59:19 +02:00
Robert Müller 95550fd6a9 Move CRenderTools::DrawUIRect/4 to CUIRect::Draw/4
Use `ColorRGBA` instead of `vec4` for `Draw4`.
2022-08-12 19:37:08 +02:00
Robert Müller 7b390808bc Replace ui.h include with ui_rect.h, organize other includes 2022-08-12 19:37:08 +02:00
Robert Müller 680dd052d7 Add documentation for CUIRect::Inside 2022-08-12 19:37:07 +02:00
Robert Müller 49164dfcdf Improve argument names of CUIRect::Inside 2022-08-12 19:37:07 +02:00
Robert Müller b50309dd5c Move CUIRect class into its own files 2022-08-12 19:37:07 +02:00
Robert Müller 4005b82743 Move CRenderTools::DrawUIElRect to CUIElement::SUIElementRect::Draw
This method draws a particular UI element rectangle so it should be a member method.
2022-08-12 17:42:05 +02:00
Robert Müller 3b1ef5642b Refactor DrawRect* methods:
- use `CORNER_*` constants and add missing constants
- fix array variable names
- use `size_t`
- extract duplicate computation into constant
- use `ColorRGBA` instead of `vec4`
2022-08-12 17:42:05 +02:00
Robert Müller 2a21cd6eab Move all DrawRect* methods from CRenderTools to IGraphics
As the methods do not depend on any game components they are moved to the engine graphics interface.
2022-08-12 17:42:05 +02:00
Robert Müller 7b20009980 Move CUI::CORNER_* enum to IGraphics::CORNER_*
Entirely automatic replacement in preparation for moving rect drawing methods from `CRenderTools` to `IGraphics`.
2022-08-12 17:42:04 +02:00
Robert Müller 9ad097da4d Refactor DrawCircle:
- improve argument names
- remove duplicate computation by adding `SegmentsAngle`
- rename variable `Array` to `aItems`
- use `std::size` and `size_t`
- remove unnecessary temporary variables
2022-08-12 17:42:03 +02:00
Robert Müller 237fdc76db Move CRenderTools::DrawCircle to IGraphics::DrawCircle
As this method does not depend on any game components it is be moved to the engine graphics interface.
2022-08-12 17:42:03 +02:00
Robert Müller 967c92f5d6 Encapsulate CGraph member variables
Make the member variables private and add `SetMin` to replace a usage of the member variables in `CDebugHud`. For completeness/symmetry, `SetMax` is also added.
2022-08-12 16:13:23 +02:00
Robert Müller 8c88005a42 Rename variables Array to aLineItems / aColorVertices 2022-08-12 16:13:03 +02:00
Robert Müller 11e60d32f0 Reuse CGraph::InsertAt in Add to reduce duplicate code 2022-08-12 16:13:03 +02:00
Robert Müller 44ca1f0d7b Use size_t for indices, replace unused return value with assert
The return value of `CGraph::InsertAt` was not checked. All uses of the function pass a correct index, so the return value is replaced with an assertion.
2022-08-12 16:13:03 +02:00
Robert Müller 3daa177830 Remove restriction for CGraph::MAX_VALUES to be a power of two
By using `% MAX_VALUES` instead of `& (MAX_VALUES - 1)` to wrap the index. Both work the same, but the latter only does for powers of two.
2022-08-12 16:13:03 +02:00
Robert Müller b314db5454 Use CGraph::MAX_VALUES instead of magic value in debughud 2022-08-12 16:13:02 +02:00
Robert Müller 8e0a935d5c Combine CGraph::ScaleMin and ScaleMax into Scale
As the methods are always called at the same time, they can be combined. This also improves the performance, as the array only needs to be iterated once.
2022-08-12 16:12:55 +02:00
Robert Müller e99f7ab106 Extract StrCopyUntilSpace and use existing str_* functions
Minor refactoring to reduce duplicate code. Eventually this method could be extended to handle completion for other arguments except the first one.
2022-08-11 19:30:54 +02:00
Robert Müller 33bb576202 Show completion options for tune params in console
Currently supports `tune`, `tune_reset` and `toggle_tune`.

For `tune_zone` the tune name is the second argument, so this is more difficult to handle.
2022-08-11 10:11:03 +02:00
Robert Müller 6af8f46526 Add CTuningParams::PossibleTunings to find tune params by name 2022-08-11 10:11:00 +02:00
Robert Müller 047c88d797 Refactor console completion input handling according to upstream 2022-08-11 10:08:59 +02:00
Robert Müller f3eb93b83a Extend IConsole::PossibleCommands, add index to callback
`PossibleCommands` now passes the item index to the callback and returns the total number of items.

Add `EmptyPossibleCommandCallback` as default parameter.
2022-08-11 10:08:06 +02:00
Robert Müller 680abb6405 Encapsulate CTuningParams::ms_apNames with CTuningParams::Name 2022-08-11 10:07:45 +02:00
Robert Müller 85a41f46dc Allow tune command to list current tuning parameter value
Extend `tune` so the current value of a given tuning variable is printed if no new value is given, so it works like commands in the console. For example `tune player_collision` will print the current value of the variable, whereas `tune player_collision 0` will change the value like before.
2022-08-11 10:04:52 +02:00
Robert Müller 56d6290734 Print the actual tuning value after setting it
Get the actual tuning value after setting it, as the value that was applied may differ due to overflow or rounding errors.
2022-08-11 10:04:36 +02:00
Robert Müller e3bb8bc370 Allow tune_reset to reset a single tune
Extend `tune_reset` so a single tuning value can be reset to default. For example `tune_reset player_collision` will reset just the `player_collision` tuning, whereas `tune_reset` will reset all to defaults like before.
2022-08-11 10:00:26 +02:00
Robert Müller 46ec2e0a24 Print incorrect tuning parameter name on error 2022-08-11 10:00:21 +02:00
Robert Müller 54aff02286 Add success/error message to dump_(local|remote)_console commands 2022-08-11 09:52:19 +02:00
Robert Müller 43fdeb8468 Rename tune_dump to tunes, improve descriptions 2022-08-11 09:48:41 +02:00
Robert Müller ca31b495a9 Rename dump_binds command to binds, fix typo in description 2022-08-11 09:48:34 +02:00
Dennis Felsing d003cc6ee2 Use current backlog page instead of old (fixes #5719)
Better fix by Robyt3
2022-08-10 17:27:24 +02:00
Fireball 5d886d80f8 Parallax Zoom: use CMapItemGroupEx to store parallax value 2022-08-10 03:05:23 +01:00
Robert Müller a8e3ac1184 Minor refactoring: use int64_t instead of long long 2022-08-09 18:48:06 +02:00
Robert Müller 1e10cd3c7d Optimize conditional expression 2022-08-09 18:48:05 +02:00
Robert Müller 62445ac006 Remove unused HermiteBasis1 function 2022-08-09 18:48:05 +02:00
Robert Müller 05af632524 Rename variables v to Value 2022-08-09 18:48:05 +02:00
Robert Müller 1e6fd63204 Rename variables id to KeyID 2022-08-09 18:48:04 +02:00
bors[bot] 57849a128c
Merge #5717
5717: Check fully transparent quads with negative alpha r=def- a=Jupeyy

fixes #5716

Co-authored-by: Jupeyy <jupjopjap@gmail.com>
2022-08-09 15:49:32 +00:00
Jupeyy bc865ab087
Check transparency even for negative alpha 2022-08-09 17:44:09 +02:00
bors[bot] f8fca99e62
Merge #5642
5642: Option to remove weak hook & bounce r=def- a=Jupeyy

Fixes #5641 
server side only

## Checklist

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


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

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

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

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

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

Closes #4379.

## Checklist

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


Co-authored-by: Robert Müller <robytemueller@gmail.com>
2022-08-08 22:38:22 +00:00
Robert Müller 243ab7c2f0 Use djb2 for snapshot item hashlist
The previous hash function was heavily biased towards the hash buckets 64-79, making those buckets overflow faster, which results in snapshot CRC errors and lags.

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

http://www.cse.yorku.ca/~oz/hash.html
2022-08-08 23:21:45 +02:00
Robert Müller 573aedc323 Extract magic constant 64 into HASHLIST_BUCKET_SIZE 2022-08-08 22:34:47 +02:00
Robert Müller b99b861e1c Extract common expression into CalcHashID function 2022-08-08 22:30:14 +02:00
Dennis Felsing 614a5b35bc Easter egg 2022-08-08 16:37:17 +02:00
Dennis Felsing 526861f924 Update language files, remove half-translated graphics warning
Thanks to cheeser0613 for report
2022-08-08 16:10:48 +02:00
Fireball 4ed997f304 Parallax Zoom: fix QuadEnvPoint scaling (and other UI distances) 2022-08-06 16:45:03 +01:00
bors[bot] aeca43fbdb
Merge #5706
5706: Fix shift-leftclick-drag with empty selection to delete (fixes #5705) r=C0D3D3V a=def-

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

## Checklist

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


Co-authored-by: Dennis Felsing <dennis@felsin9.de>
2022-08-06 10:54:33 +00:00
Fireball 54f7a9817d Parallax Zoom: Zoom preview button in Editor
Known issue: Quad Env Points are scaled incorrectly for Groups with
ParallaxZoom != 100 (in Zoom mode).
2022-08-06 02:30:37 +01:00
Fireball 5bf7f60bf6 Parallax Zoom: Add default zoom option to the editor
Safe defaults for map editing: unless opted-in, Parallax Zoom
will default to maximum(parallax{x,y}).
2022-08-06 01:31:42 +01:00
Dennis Felsing a41f1c1def Fix shift-leftclick-drag with empty selection to delete (fixes #5705) 2022-08-06 02:09:15 +02:00
Fireball a90c86e9a5 Parallax-aware zoom
How this works: parallax values configure perceived distance from camera
when it's moving along x and y axes. Assume that zoom is moving the
camera away and scale layers accordingly, with background layers
(furtherst away) changing the least.

New per-ItemGroup (LayerGroup) setting allows to set the new parallax
value independently from the other two. This can be used to do tricks
like on Time Shop zoom correctly or make it feel like the camera is
changing the field of view at the same time as moving in space.
2022-08-05 00:40:58 +01:00
Robert Müller b1e4d60fae Fix buffer-overflow in editor on shift-clicking brush
1. Open any map, including an empty one.
2. Select a brush, e.g. size 2x2.
3. Shift click to repeat the brush over a larger area, e.g. 10x10.
4. This causes a buffer-overflow / crash with ASAN:

```
=================================================================
==4826==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6060000f5040 at pc 0x55db7d0aa743 bp 0x7fffe4e191f0 sp 0x7fffe4e191e0
READ of size 4 at 0x6060000f5040 thread T0
    0 0x55db7d0aa742 in CLayerTiles::GetTile(int, int) src/game/editor/layer_tiles.cpp:50
    1 0x55db7d0d23e1 in CLayerTiles::FillSelection(bool, CLayer*, CUIRect) src/game/editor/layer_tiles.cpp:437
    2 0x55db7cf196e9 in CEditor::DoMapEditor(CUIRect) src/game/editor/editor.cpp:2641
    3 0x55db7cfa7755 in CEditor::Render() src/game/editor/editor.cpp:5747
    4 0x55db7cfd2a56 in CEditor::OnRender() src/game/editor/editor.cpp:6437
    5 0x55db7c23e02d in CClient::Run() src/engine/client/client.cpp:3374
    6 0x55db7c2a9f7b in main src/engine/client/client.cpp:4762

0x6060000f5040 is located 0 bytes to the right of 64-byte region [0x6060000f5000,0x6060000f5040)
allocated by thread T0 here:
    0 0x7f9b21db5787 in operator new[](unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:107
    1 0x55db7d0a9a86 in CLayerTiles::CLayerTiles(int, int) src/game/editor/layer_tiles.cpp:39
    2 0x55db7d0cf0ed in CLayerTiles::BrushGrab(CLayerGroup*, CUIRect) src/game/editor/layer_tiles.cpp:387
    3 0x55db7cf18191 in CEditor::DoMapEditor(CUIRect) src/game/editor/editor.cpp:2612
    4 0x55db7cfa7755 in CEditor::Render() src/game/editor/editor.cpp:5747
    5 0x55db7cfd2a56 in CEditor::OnRender() src/game/editor/editor.cpp:6437
    6 0x55db7c23e02d in CClient::Run() src/engine/client/client.cpp:3374

SUMMARY: AddressSanitizer: heap-buffer-overflow src/game/editor/layer_tiles.cpp:50 in CLayerTiles::GetTile(int, int)
Shadow bytes around the buggy address:
  0x0c0c800169b0: 00 00 00 fa fa fa fa fa 00 00 00 00 00 00 00 fa
  0x0c0c800169c0: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
  0x0c0c800169d0: fd fd fd fd fd fd fd fa fa fa fa fa fd fd fd fd
  0x0c0c800169e0: fd fd fd fd fa fa fa fa fd fd fd fd fd fd fd fa
  0x0c0c800169f0: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
=>0x0c0c80016a00: 00 00 00 00 00 00 00 00[fa]fa fa fa fd fd fd fd
  0x0c0c80016a10: fd fd fd fa fa fa fa fa fd fd fd fd fd fd fd fa
  0x0c0c80016a20: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
  0x0c0c80016a30: fd fd fd fd fd fd fd fa fa fa fa fa fd fd fd fd
  0x0c0c80016a40: fd fd fd fa fa fa fa fa fd fd fd fd fd fd fd fa
  0x0c0c80016a50: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
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
  Shadow gap:              cc
==4826==ABORTING
```
2022-08-04 23:39:40 +02:00
Robert Müller c696d93e41 Add documentation for IServer::GetClientVersion 2022-08-03 23:28:51 +02:00
bors[bot] b4914d5d27
Merge #5692
5692: Refactor `GetClientVersion`, remove many `version.h` includes, fix potential use of undefined value r=def- a=Robyt3

Some refactoring to reduce duplicate code and to remove includes.

## Checklist

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


Co-authored-by: Robert Müller <robytemueller@gmail.com>
2022-08-01 21:21:18 +00:00
Robert Müller ee339ebe30 Minor refactoring of GetClientInfo and SetClientDDNetVersion 2022-07-31 23:37:56 +02:00
Robert Müller 24b30434da Handle CServer::GetClientInfo return to fix use of undefined value
```
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:790:2: error: Undefined or garbage value returned to caller [clang-analyzer-core.uninitialized.UndefReturn,-warnings-as-errors]
        return Info.m_DDNetVersion;
        ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:785:5: note: Assuming 'ClientID' is not equal to SERVER_DEMO_CLIENT
        if(ClientID == SERVER_DEMO_CLIENT)
           ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:785:2: note: Taking false branch
        if(ClientID == SERVER_DEMO_CLIENT)
        ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:789:2: note: Calling 'CServer::GetClientInfo'
        GetClientInfo(ClientID, &Info);
        ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:646:13: note: Assuming 'ClientID' is >= 0
        dbg_assert(ClientID >= 0 && ClientID < MAX_CLIENTS, "client_id is not valid");
                   ^
/home/runner/work/ddnet/ddnet/src/base/tl/../system.h:58:38: note: expanded from macro 'dbg_assert'
#define dbg_assert(test, msg) assert(test)
                                     ^
/usr/include/assert.h:93:27: note: expanded from macro 'assert'
     (static_cast <bool> (expr)                                         \
                          ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:646:13: note: Left side of '&&' is true
        dbg_assert(ClientID >= 0 && ClientID < MAX_CLIENTS, "client_id is not valid");
                   ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:646:30: note: Assuming 'ClientID' is < MAX_CLIENTS
        dbg_assert(ClientID >= 0 && ClientID < MAX_CLIENTS, "client_id is not valid");
                                    ^
/home/runner/work/ddnet/ddnet/src/base/tl/../system.h:58:38: note: expanded from macro 'dbg_assert'
#define dbg_assert(test, msg) assert(test)
                                     ^
/usr/include/assert.h:93:27: note: expanded from macro 'assert'
     (static_cast <bool> (expr)                                         \
                          ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:646:2: note: '?' condition is true
        dbg_assert(ClientID >= 0 && ClientID < MAX_CLIENTS, "client_id is not valid");
        ^
/home/runner/work/ddnet/ddnet/src/base/tl/../system.h:58:31: note: expanded from macro 'dbg_assert'
#define dbg_assert(test, msg) assert(test)
                              ^
/usr/include/assert.h:93:7: note: expanded from macro 'assert'
     (static_cast <bool> (expr)                                         \
      ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:647:13: note: 'pInfo' is not equal to null
        dbg_assert(pInfo != 0, "info can not be null");
                   ^
/home/runner/work/ddnet/ddnet/src/base/tl/../system.h:58:38: note: expanded from macro 'dbg_assert'
#define dbg_assert(test, msg) assert(test)
                                     ^
/usr/include/assert.h:93:27: note: expanded from macro 'assert'
     (static_cast <bool> (expr)                                         \
                          ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:647:2: note: '?' condition is true
        dbg_assert(pInfo != 0, "info can not be null");
        ^
/home/runner/work/ddnet/ddnet/src/base/tl/../system.h:58:31: note: expanded from macro 'dbg_assert'
#define dbg_assert(test, msg) assert(test)
                              ^
/usr/include/assert.h:93:7: note: expanded from macro 'assert'
     (static_cast <bool> (expr)                                         \
      ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:649:5: note: Assuming field 'm_State' is not equal to STATE_INGAME
        if(m_aClients[ClientID].m_State == CClient::STATE_INGAME)
           ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:649:2: note: Taking false branch
        if(m_aClients[ClientID].m_State == CClient::STATE_INGAME)
        ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:667:2: note: Returning without writing to 'pInfo->m_DDNetVersion'
        return 0;
        ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:789:2: note: Returning from 'CServer::GetClientInfo'
        GetClientInfo(ClientID, &Info);
        ^
/home/runner/work/ddnet/ddnet/src/engine/server/server.cpp:790:2: note: Undefined or garbage value returned to caller
        return Info.m_DDNetVersion;
        ^
```
2022-07-31 23:37:28 +02:00
Robert Müller 9a012312b8 Move and extend GetClientVersion to remove many version.h includes
The `CServer::GetClientVersion` method needs the `version.h` include, so it's moved from the header to the source file, so the include can be removed from the header.

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

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

The includes of the server entities are also organized further.
2022-07-31 23:21:10 +02:00
bors[bot] 1110d0e40e
Merge #5686
5686: Fix editor image delete r=def- a=Jupeyy

fixes #5675

## 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: Jupeyy <jupjopjap@gmail.com>
2022-07-31 21:11:15 +00:00
Chairn c651936f38 Use copy assignment rather than copy variable one by one 2022-07-31 22:43:43 +02:00
bors[bot] 730c54a603
Merge #5678
5678: Reset selected quads when switching layers (fixes #5673) r=Jupeyy a=def-

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

## Checklist

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


Co-authored-by: def <dennis@felsin9.de>
2022-07-31 20:03:31 +00:00
Jupeyy 982139922c Fix editor image delete 2022-07-31 21:39:18 +02:00
Robert Müller 1d6dca8c24 Fix accesses to vector with index -1 by adding static button IDs 2022-07-31 13:13:53 +02:00
Robert Müller 344e50f76f Remove dead code 2022-07-31 13:10:03 +02:00
def 76e3db9725 Reset selected quads when switching layers (fixes #5673) 2022-07-31 09:45:06 +02:00
def b33cbdde0a Remove unused backend_opengles.h 2022-07-31 09:44:50 +02:00
def fc5cfb6f6c Remove CFlag dead code (fixes #5677) 2022-07-31 09:44:50 +02:00