Commit graph

12110 commits

Author SHA1 Message Date
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
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
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
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
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
Robert Müller 83faed0952 Write sqlite file to storage unless given as absolute path 2022-11-05 16:32:45 +01:00
Robert Müller a62bf7c334 Write log files to storage unless given as absolute path 2022-11-05 16:30:24 +01:00
Robert Müller 964f839410 Show selection popup when multiple images/sounds with same name exist
When readding a sound/image and multiple files with the name exist, a popup is shown that allows the user to choose the wanted file.
If exactly one file is found, it is used without showing a dialog.
As before, if no file is found, an error message popup is shown.
2022-11-05 15:42:39 +01:00
Robert Müller 812a884c06 Add generic selection popup to editor
Add `CEditor::ShowPopupSelection` to show a generic selection popup.

This popups shows a message and buttons for all entries in a `std::set`. Exactly one entry can be selected and the selection will be available to the caller in the given `SSelectionPopupContext`.
2022-11-05 15:42:39 +01:00
Robert Müller 896dd4ecd4 Add IStorage::FindFiles to find all files with a specific name
This function searches in all subfolder of the given folder and fills the given `std::vector` with all files with the given filename.

A `std::set` is used to prevent duplicate entries when a file with the same path is present in multiple storage locations. In that case we only need the path once, as we only use it against the highest priority storage location anyway.
2022-11-05 15:42:39 +01:00
Robert Müller 940f5df225 Search for images/sounds in subfolders when readding, add error popup
Use `FindFile` to search for the image/sound file in all subfolders of the mapres folder when using the "Readd" button in the editor.

Show an error message popup when readding fails, i.e. when the file could not be found.
2022-11-05 00:16:44 +01:00
Robert Müller 7079925966 Add generic popup message to editor (e.g. for error message popups)
Add `CEditor::ShowPopupMessage` function to show a generic message in a popup.

The message text and color are configurable with the `SMessagePopupContext` argument object.
Instances of this class must have a static memory location, as the message needs to be available after the `ShowPopupMessage` function returns, and the address of this object is used to uniquely identify it in the UI.
2022-11-05 00:16:44 +01:00
bors[bot] 8d7442e328
Merge #6002 #6003
6002: Explain -DANTIBOT=ON a bit better (fixes #6001) r=heinrich5991 a=def-

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

<!-- Note that builds and other checks will be run for your change. Don't feel intimidated by failures in some of the checks. If you can't resolve them yourself, experienced devs can also resolve them before merging your pull request. -->

## Checklist

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


6003: Fix height and margin of sound and image popups 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: Dennis Felsing <dennis@felsin9.de>
Co-authored-by: Robert Müller <robytemueller@gmail.com>
2022-11-04 18:55:46 +00:00
Robert Müller c5bbccfe07 Also append sounds when appending a map to another map 2022-11-03 20:21:45 +01:00
Robert Müller b0a21dab09 Use bool for Load, Save, Append result, true on success
The `Append` method was returning `0` on success while `Load` and `Save` were returning `1`.
Now all three methods use a `bool` as return value and return `true` on success.

The call `SortImages()` is moved inside the `Append` method, as it should always be called when appending succeeded.
2022-11-03 20:17:06 +01:00
Robert Müller 40dbb1b992 Fix height and margin of sound and image popups
The height of the sound popup was too small, as it was not updated when the "Readd" button was added.

The additional `2.0f` margin at the top of the popups is removed, as all popup menus already have default `5.0f` margins on all sides.

The height of the image popup for external images was not including this margin to begin with, so it was slightly too small but is correct now.
The height of the image popup for embedded images is adjusted to no longer include this margin.

Pass `nullptr` instead of calculating unused `CUIRect` values.
2022-11-03 19:53:21 +01:00
Robert Müller abf795d9da Invoke static methods without a class instance
The methods `ReplaceImage` and `ReplaceSound` are static, so they should be called without an object.
2022-11-03 19:32:10 +01:00
Jupeyy 365c48413f Switch to Vulkan 1.1
Since the vulkan loader drops support for useful extensions (or the extension loading process changed between 1.0 & 1.1, not sure)
Which causes OBS not to work
2022-11-02 12:54:04 +01:00