Commit graph

8654 commits

Author SHA1 Message Date
VoxelDoesCode 5d1bec5a83 Change editor UI, fix an overflow bug.
clang

clang2
2022-11-11 20:36:15 -05: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
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 2d1d7b9562 Replace duplicate condition with a check for empty string 2022-11-06 16:25:24 +01:00
bors[bot] 48d82e9bfd
Merge #6010 #6015
6010: Search for images/sounds in subfolders when readding in editor, show selection dialog if multiple files with the same are found, show error popup when file cannot be found r=heinrich5991 a=Robyt3

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

Show an error popup when readding fails:

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

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

![selectiondialog](https://user-images.githubusercontent.com/23437060/200125448-dccf47ba-d643-4f41-b256-eb90656ba693.png)


## Checklist

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


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

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

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

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

In my vscode it looks nice tho:

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

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

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


Co-authored-by: Robert Müller <robytemueller@gmail.com>
Co-authored-by: ChillerDragon <ChillerDragon@gmail.com>
2022-11-06 14:10:27 +00:00
Robert Müller 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 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 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
bors[bot] e71ce8fcde
Merge #5998
5998: Fix Ctrl+F hotkey not checking for Ctrl key, minor improvement to tile details popup layout 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-01 22:10:19 +00:00
Robert Müller 886ec990fe Add missing check for modifier of Ctrl+F hotkey
The hotkey for the "Find empty slot" button was not correctly checking for a pressed modifier, so it was already being trigger by just the key F instead of the desired Ctrl+F.
2022-11-01 23:01:32 +01:00
Robert Müller 8e9b4ddcd2 Refactor tile details popup height, variable names
The height is calculated based on the number of rows and the row height instead of being entirely hardcoded, which makes maintenance easier.
The total height of the speedup popup was slightly too large, which is also fixed by this.
Variable names and their declaration positions are also refactored.
2022-11-01 23:01:28 +01:00
Robert Müller 0db4b5fe0c Refactor border button condition, move button variable
The conditions can be combined into one if-statement to better readability.
2022-11-01 22:30:56 +01:00
Robert Müller c29d4b984c Remove redundant CUIRects, improve find button height
Some of the CUIRects were calculated but never used.
The height of the "Find empty slot" button is made consistent with the height of the properties shifters.
2022-11-01 22:29:12 +01:00
Robert Müller d6d88d4370 Allow selecting switch number 0 in editor again
This reverts part of #5993 to allow switch number 0 to be selected again.
Switch number 0 is permanently enabled, so it useful for tiles that should always be switched on.
Eventually tiles that don't work with switch 0 (e.g. switch open/close tiles) should be made unplaceable and the switch number should be hidden for tiles where it doesn't have any effect (e.g. jump tiles). See #5995.
2022-11-01 21:52:49 +01:00
bors[bot] 846b569a86
Merge #5994
5994: Change editor hotkey Ctrl+A to Ctrl+T for layer/tile details r=def- a=Robyt3

The hotkey Ctrl+A is already active universally in the editor to open and append a map to the current one. This collides with the hotkeys for opening the layer/tile details popup for tune, tele, speedup and switch layers, which is only active when a layer of said type is select. Pressing the hotkey in this context opens the popup and the append dialog at the same time, which is undesirable. Therefore the hotkey to open the layer/tile details is changed to Ctrl+T instead. This combination is currently unused and seems approriate, as the T could stand for "Tile details".

## 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-01 12:35:28 +00:00
Robert Müller c916e5d262 Change editor hotkey Ctrl+A to Ctrl+T for layer/tile details
The hotkey Ctrl+A is already active universally in the editor to open and append a map to the current one.
This collides with the hotkeys for opening the layer/tile details popup for tune, tele, speedup and switch layers, which is only active when a layer of said type is select.
Pressing the hotkey in this context opens the popup and the append dialog at the same time, which is undesirable.
Therefore the hotkey to open the layer/tile details is changed to Ctrl+T instead. This combination is currently unused and seems approriate, as the T could stand for "Tile details".
2022-11-01 13:13:22 +01:00
Robert Müller c6fa29eb56 Fix incorrect minimum values for tele, speedup and switch layers
It was possible to select tele number 0, speedup force 0 and switch number 0 in the layer details in the editor, because some of the bounds checks or calculations were not excluding the value 0.
As placing those tiles with the value 0 in the editor is not possible and the tiles with this value are ignored by server and client, it also shouldn't be possible to select those values in the first place.
2022-11-01 12:11:18 +01:00
bors[bot] 571b0b36de
Merge #5770
5770: Fix physics change by weak hook fix (fixes #5769) r=def- a=fokkonaut

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

## Checklist

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


Co-authored-by: fokkonaut <35420825+fokkonaut@users.noreply.github.com>
Co-authored-by: Jupeyy <jupjopjap@gmail.com>
2022-11-01 10:29:53 +00:00
def a237ee5f6d Improve callvote arguments by making them more specific
Should make it a bit clearer how to call a vote from F1
2022-10-29 14:45:24 +02:00
Robert Müller 6c8fa6b4f0 Rename variable aBuf to pBuf, use size_t for buffer size 2022-10-27 22:21:08 +02:00
Robert Müller d551617c34 Use str_copy instead of str_format with format "%s"
Using `str_format(aBuf, sizeof(aBuf), "%s", pStr)` is equivalent to `str_copy(aBuf, pStr, sizeof(aBuf))`. Using `str_copy` is more readable and also more efficient as there is no overhead from parsing the format string and from passing varargs.
2022-10-27 21:42:14 +02:00
Jupeyy 3b2dd73614 Rename config var to no weak only 2022-10-27 17:51:30 +02:00
fokkonaut cedc315a70 Fix physics change by weak hook fix (fixes #5769) 2022-10-27 17:44:54 +02:00
bors[bot] 47b351134a
Merge #5985
5985: Fix large editor popups being outside of screen, add margin r=def- a=Robyt3

Large editor popups could be positioned outside of the screen area, when they could not be positioned below or to the right of the cursor without overflowing. This is fixed by making sure the popup does not overflow the top or left side of the screen after adjusting its position.

A small margin is also added so popups don't start or end immediately at the screen border.

Closes #5982.

## 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-10-25 22:08:44 +00:00
Dennis Felsing 1f5d7a0afd Version 16.5 2022-10-25 23:21:02 +02:00
Robert Müller 6b7563a90b Fix large editor popups being outside of screen, add margin
Large editor popups could be positioned outside of the screen area, when they could not be positioned below or to the right of the cursor without overflowing. This is fixed by making sure the popup does not overflow the top or left side of the screen after adjusting its position.

A small margin is also added so popups don't start or end immediately at the screen border.

Closes #5982.
2022-10-25 20:16:39 +02:00
Rafael Fontenelle cd14660307 Fix misspellings 2022-10-25 13:51:56 -03:00
Robert Müller 6ef3adaa23 Fix long demo names being truncated in popups and UI
Use `IO_MAX_PATH_LENGTH` for all demo filenames and paths, so long demo names and demo names containing many unicode characters are not so easily truncated in the cut, rename and render dialogs.

Use combination of `str_endswith` and `str_append` to append file extensions, instead of using `str_comp_nocase` and `str_format`. Thereby only support creating demos and video files with lower case file extension, as only demo files with lower case file extension are shown in the client anyway.
2022-10-24 20:42:52 +02:00
Robert Müller b486028838 Remove dead code
The `PopupMessage` was never shown, as the next line activates `POPUP_REPLACE_VIDEO` which immediates overrides the message popup.
2022-10-24 20:18:09 +02:00
Robert Müller 997af452d0 Fix crash when cutting a demo opened from command line
When playing a demo without opening the demo menu first, i.e. from command line argument or with `play` command from the main menu, clicking the demo slice button crashes the game, as the code tries to use the filename of the currently selected demo while there is no demo selected, i.e. `m_DemolistSelectedIndex == -1`.
Also, when using the play command after opening the demo menu, the initial filename selected for cutting was incorrectly set to the currently selected demo.

This is fixed by getting the name of the current demo file from the demo player instead, when cutting a demo.
Though the cut demo will be saved to the last demo folder selected (or the demos directory) instead of being saved to the same directory as the original demo.
2022-10-24 20:14:04 +02:00
Robert Müller 3c1cd89ae6 Append file extension before checking for identical cut demo filename
The file extension needs to be appended to the cut demo name before checking whether the name matches the currently playing file, otherwise the "Please use a different name" error message is not shown and instead the "File already exists" question is shown.
2022-10-24 19:53:42 +02:00
Robert Müller be45604354 Fix demo file not being closed after showing error message
When entering the name of an existing demo file into the Slice demo dialog and pressing the Ok button twice, the file handle that's used for checking for the demo file's existence is not closed, hence the cut demo file cannot be deleted until the client is closed.
2022-10-24 19:48:44 +02:00
Robert Müller f5a16c1c77 Fix crash in editor when using up/down keys on empty images list 2022-10-21 20:28:30 +02:00
Robert Müller 4a683e024a Fix crash in editor when using up/down keys on empty sounds list 2022-10-21 20:28:00 +02:00
bors[bot] 8feba4ecf6
Merge #5966
5966: Fix duplicate description of cl_default_zoom_level r=heinrich5991 a=def-

Since #5894 is not landing

<!-- 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-10-21 11:53:55 +00:00
Dennis Felsing f7bc58b056 Fix duplicate description of cl_default_zoom_level
Since #5894 is not landing
2022-10-21 00:12:07 +02:00
bors[bot] 53080e3e14
Merge #5938
5938: Hex Values in the editor's info feature r=heinrich5991 a=VoxelDoesCode

Add an option when the info button is selected, you can show the hexadecimal values for a tile rather than 1-255. This has some benefits, as it aligns in a perfect grid. Can help with making and test automappers.

![image](https://user-images.githubusercontent.com/95713843/195209286-82dd04d5-f469-4932-bbd7-93ec3fd32f99.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-10-19 22:47:35 +00:00
heinrich5991 dcd76fd3e1 Add support for Rust code in DDNet
The glue is done using the [cxx crate](https://cxx.rs/) on the Rust
side.

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

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

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

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

---

The stuff in `src/rust-bridge` is generated using
```
cxxbridge src/engine/shared/rust_version.rs --output src/rust-bridge/engine/shared/rust_version.cpp --output src/rust-bridge/engine/shared/rust_version.h
cxxbridge src/engine/console.rs --output src/rust-bridge/cpp/console.cpp --output src/rust-bridge/cpp/console.h
```
2022-10-19 23:46:06 +02:00
Jupeyy b70fc39571 fix skin click ptr 2022-10-19 20:18:43 +02:00
Robert Müller c78f71b2b9 Fix client crash when server does not send gameinfo 2022-10-15 19:43:26 +02:00
Zwelf 0e0e55eb43 Fix example name in mapbug description 2022-10-13 11:51:18 +02:00