Commit graph

16337 commits

Author SHA1 Message Date
bors[bot] dd1cfdc276
Merge #6335
6335: Add 0.7 system message constants r=def- a=ChillerDragon

The protocolglue allows using all network constants from 0.7 using the ``protocol7::`` prefix. Such as game messages snap objects etc. But system messages are still magic numbers.

Co-authored-by: ChillerDragon <chillerdragon@gmail.com>
2023-02-14 10:49:23 +00:00
ChillerDragon 4772428256 Add 0.7 system message constants 2023-02-14 11:40:55 +01:00
bors[bot] cb68791901
Merge #6330
6330: IServer: Add SnapNewItem() template to simplify the API, do some small refactoring r=def- a=Kaffeine

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

The idea is to simplify and refactor the game code step by step. This is the next step after a similar https://github.com/ddnet/ddnet/pull/5600

The key idea is that all those
```cpp
protocol7::CNetObj_SpectatorInfo *pSpectatorInfo = static_cast<protocol7::CNetObj_SpectatorInfo *>(Server()->SnapNewItem(NETOBJTYPE_SPECTATORINFO, m_ClientID, sizeof(protocol7::CNetObj_SpectatorInfo)));
```
are too verbose and error-prone.

We have the relation between `CNetObj_` classes and their corresponding `NETOBJTYPE_` so we can use it to remove most of the arguments and the cast.
With some small changes in the generated code (e.g. MsgID leveraged from NetMessage to NetObject) we can come to this:
```cpp
auto *pSpectatorInfo = Server()->SnapNewItem<protocol7::CNetObj_SpectatorInfo>(m_ClientID);
```
Yet, we do not use auto and personally I'm skeptic about `auto` in any non-obvious cases so I still keep the class name on the left side. The best show-case of the new API is:
```diff
`@@` -330,7 +330,7 `@@` void CGameContext::CreatePlayerSpawn(vec2 Pos, CClientMask Mask)
 void CGameContext::CreateDeath(vec2 Pos, int ClientID, CClientMask Mask)
 {
        // create the event
-       CNetEvent_Death *pEvent = (CNetEvent_Death *)m_Events.Create(NETEVENTTYPE_DEATH, sizeof(CNetEvent_Death), Mask);
+       CNetEvent_Death *pEvent = m_Events.Create<CNetEvent_Death>(Mask);
        if(pEvent)
        {
                pEvent->m_X = (int)Pos.x;
`@@` -345,7 +345,7 `@@` void CGameContext::CreateSound(vec2 Pos, int Sound, CClientMask Mask)
                return;
 
        // create a sound
-       CNetEvent_SoundWorld *pEvent = (CNetEvent_SoundWorld *)m_Events.Create(NETEVENTTYPE_SOUNDWORLD, sizeof(CNetEvent_SoundWorld), Mask);
+       CNetEvent_SoundWorld *pEvent = m_Events.Create<CNetEvent_SoundWorld>(Mask);
        if(pEvent)
        {
                pEvent->m_X = (int)Pos.x;
`@@` -376,7 +376,7 `@@` bool CGameContext::SnapLaserObject(const CSnapContext &Context, int SnapID, cons
 {
        if(Context.ClientVersion >= VERSION_DDNET_MULTI_LASER)
        {
-               CNetObj_DDNetLaser *pObj = static_cast<CNetObj_DDNetLaser *>(Server()->SnapNewItem(NETOBJTYPE_DDNETLASER, SnapID, sizeof(CNetObj_DDNetLaser)));
+               CNetObj_DDNetLaser *pObj = Server()->SnapNewItem<CNetObj_DDNetLaser>(SnapID);
                if(!pObj)
                        return false;
 
`@@` -390,7 +390,7 `@@` bool CGameContext::SnapLaserObject(const CSnapContext &Context, int SnapID, cons
        }
        else
        {
-               CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, SnapID, sizeof(CNetObj_Laser)));
+               CNetObj_Laser *pObj = Server()->SnapNewItem<CNetObj_Laser>(SnapID);
                if(!pObj)
                        return false;
```


The only difficulty is `protocol7` handling but I think I did it right (I had to change the logic for a bit and I still check it while waiting for your comments).

I can extract any of the commits to another PR if wanted.

As for 305670eecb I do not like to use CGameContext for the network stuff but we already have kinda similar helper functions and e.g. the NetObjHandlers there, and it is still a change to the better. **The long-term goal is to move that stuff to a new class** (e.g. some kind of protocol abstraction class or layer).

## 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: Alexander Akulich <akulichalexander@gmail.com>
2023-02-12 11:40:00 +00:00
Alexander Akulich 3a9e4ee067 Extract SnapPickup() to CGameContext helpers 2023-02-10 23:12:26 +03:00
Alexander Akulich 2ad5c020e0 Add a simpler IServer::SnapNewItem() API based on some more generated data 2023-02-10 23:12:24 +03:00
Alexander Akulich cc43d402d3 Extract SnapLaserObject() from entities to CGameContext helpers 2023-02-10 23:07:07 +03:00
Alexander Akulich f5d7174c36 GameContext: Use SERVER_DEMO_CLIENT instead of a magic number 2023-02-10 23:04:01 +03:00
Alexander Akulich 971e1b0093 server/pickup: Use enum values and struct size instead of magic numbers 2023-02-10 23:04:01 +03:00
bors[bot] 911bd0e69a
Merge #6282
6282: Add a refresh button to the editor file browser r=heinrich5991 a=Robyt3

![screenshot_2023-01-13_22-51-07](https://user-images.githubusercontent.com/23437060/212426385-f8c03e58-8e5d-4c47-9f19-865946c5be9c.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: Robert Müller <robytemueller@gmail.com>
2023-02-04 11:16:09 +00:00
bors[bot] b6f49bd670
Merge #6327
6327: Fix memory leak of editor preview image texture and data r=def- a=Robyt3

The texture of the previous preview image was not unloaded before loading the texture of the new image.

The PNG data was never freed either. It's not necessary to keep this data loaded after loading the texture.

## Checklist

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


Co-authored-by: Robert Müller <robytemueller@gmail.com>
2023-02-04 10:44:48 +00:00
Robert Müller 624f7df217 Fix memory leak of editor preview image texture and data
The texture of the previous preview image was not unloaded before loading the texture of the new image.

The PNG data was never freed either. It's not necessary to keep this data loaded after loading the texture.
2023-02-04 11:28:13 +01:00
bors[bot] b4d382d1b7
Merge #6325
6325: Add error message when saving screenshot fails r=Jupeyy 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>
2023-02-02 21:14:33 +00:00
Robert Müller 0a32e58367 Add error message when saving screenshot fails 2023-02-02 21:50:32 +01:00
bors[bot] bbcd1d0ff7
Merge #6322
6322: Fix wrong system name being used for logging client git revision 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>
2023-02-01 23:09:08 +00:00
Robert Müller bd5c39f528 Fix wrong system name being used for logging client git revision 2023-02-01 23:54:43 +01:00
bors[bot] d89434c364
Merge #6314
6314: Update Persian translations (by Quick) r=Robyt3 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>
2023-01-31 17:34:38 +00:00
bors[bot] 9bd43795c8
Merge #6293
6293: rewrite int64_t to bitset for clients mask r=Robyt3 a=0xfaulty

Alternative version for PR [#6292](https://github.com/ddnet/ddnet/pull/6292) with bitset used.
I did the naming as I would like, but I can change it if there is a more suitable one, typedef is just for shortening, can be removed.

## 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: Valentin Bashkirov <v.bashkirov@dev.tassta.com>
Co-authored-by: Valentin Bashkirov <valenteen3d@ya.ru>
2023-01-31 17:06:49 +00:00
Valentin Bashkirov 056ae4091d removed bitmask.h 2023-01-31 10:07:25 +01:00
Dennis Felsing f3f592caae Update Persian translations (by Quick) 2023-01-29 00:32:45 +01:00
bors[bot] e0315f528e
Merge #6313
6313: Use `str_copy` instead of `str_format`, minor fixes and refactoring r=Chairn a=Robyt3



## 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>
2023-01-28 16:17:47 +00:00
Robert Müller 52aa8ac22a Use str_copy instead of str_format
Using `str_format` without format arguments is equivalent to `str_copy`, but using the latter is more efficient and readable.

As `str_format` also returns the result `str_utf8_fix_truncation`, i.e. the potentially truncated string length, the return value is also added to `str_copy` so existing invocations don't need to be adjusted.
2023-01-28 16:37:33 +01:00
Robert Müller 34ef28c6b6 Fix empty chat message being sent when using moderate
When activating `moderate` on a server that already has another active moderator, `aBuf` contained undefined values and the empty or undefined message was sent to the clients.

Clients ignore empty chat messages and don't display or log them, but the empty message can be seen in the server console.

Now no buffer is used anymore, so no empty message can be sent.
2023-01-28 16:36:03 +01:00
Robert Müller 31bcc59a86 Print database connection error that was previously unused
The string copied into `aError` was previously unused because the function immediately returns.

Now the error is logged to the console.
2023-01-28 16:35:32 +01:00
Robert Müller 854dc47cf7 Replace unnecessary char buffers with pointers 2023-01-28 16:35:29 +01:00
bors[bot] 936ff4a444
Merge #5913
5913: Only use pthread_attr_set_qos_class_np if it's available r=heinrich5991 a=def-

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

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

## Checklist

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


Co-authored-by: Dennis Felsing <dennis@felsin9.de>
2023-01-27 22:21:23 +00:00
bors[bot] 7ca5dcdcad
Merge #6312
6312: Increase relative joystick movement based on input update time, disable relative joystick when console is open or window not focused 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>
2023-01-27 07:54:00 +00:00
Robert Müller 25216bfddb Increase relative joystick movement based on input update time
For relative mouse movement in SDL, the `SDL_GetRelativeMouseState` function always returns distance that the mouse moved since the last call of this function.

For joysticks, we only have access to the current axis values and no accumulated values.
This made the relative joystick movement speed decrease a lot when the client's refresh rate is low.
This is now counteracted by measuring the average time between calls of `IInput::Update` and multiplying the joystick movement by this number.

Closes #6296.
2023-01-26 23:37:52 +01:00
Robert Müller 35c863b4d2 Disable relative joystick when console is open or window not focused
It shouldn't be possible to move the joystick when the console is open or when the window is not focused.
2023-01-26 23:35:55 +01:00
Robert Müller f25ffd9669 Remove unused IInput::VideoRestartNeeded
The variable is never set to `true` so the function always returns `false` and any code depend on this variable was never executed.
2023-01-26 23:35:00 +01:00
Robert Müller c2e8f6738a Use bool instead of int for m_InputGrabbed 2023-01-26 23:35:00 +01:00
Robert Müller 25872820d7 Fix division by zero when joystick deadzone is at maximum
By preventing the actual deadzone value from reaching `1.0f`.
2023-01-26 23:34:54 +01:00
bors[bot] fbc3d9b19b
Merge #6311
6311: Fix Persian language crash (fixes #6310) 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

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


Co-authored-by: Dennis Felsing <dennis@felsin9.de>
2023-01-26 15:42:21 +00:00
Dennis Felsing 7d984ec4fe Fix Persian language crash (fixes #6310) 2023-01-26 16:36:56 +01:00
Dennis Felsing ccc6cd59de Only use pthread_attr_set_qos_class_np if it's available
Noticed in nixOS that DDNet package is marked as broken on Darwin for this reason:
https://github.com/NixOS/nixpkgs/blob/master/pkgs/games/ddnet/default.nix
2023-01-26 15:42:46 +01:00
Valentin Bashkirov 79f72a5d55 move typedef to protocol.h 2023-01-26 11:56:48 +01:00
bors[bot] 028ef41a52
Merge #6309
6309: Add buttons to move envelopes left and right, improve envelope UI layout, add tooltips for editboxes r=def- a=Robyt3

Screenshots:
- 1920x1080:
   - Sound 
     - Before: 
![1080p_1 old](https://user-images.githubusercontent.com/23437060/214678233-d628e229-d102-4cd9-82e2-4fb79564aaea.png)
     - After:
![1080p_1 new](https://user-images.githubusercontent.com/23437060/214678248-e5994d37-3fbb-44c3-aea9-a3097dee6011.png)
   - Pos
     - Before:
![1080p_2 old](https://user-images.githubusercontent.com/23437060/214678272-753eb556-5c39-4a85-9191-c90ea883632e.png)
     - After:
![1080p_2 new](https://user-images.githubusercontent.com/23437060/214678286-be433d03-d185-46a2-8620-e5dbd523de4e.png)
   - Color
     - Before:
![1080p_3 old](https://user-images.githubusercontent.com/23437060/214678340-e4bd2dc8-4a3e-49a0-b1ef-d65073808177.png)
     - After:
![1080p_3 new](https://user-images.githubusercontent.com/23437060/214678355-6ab10cc7-5c45-429f-8603-5808455ad165.png)
- 1024x768:
   - Sound
     - Before: 
![1024x768_1 old](https://user-images.githubusercontent.com/23437060/214678140-36d3fd6f-9fdc-4135-9538-bf403d5e0a95.png)
     - After:
![1024x768_1 new](https://user-images.githubusercontent.com/23437060/214678150-3ee65713-01b1-460c-bf9b-9a11846cb6e7.png)
   - Pos
     - Before:
![1024x768_2 old](https://user-images.githubusercontent.com/23437060/214678170-b16eb53b-d024-4c36-a35e-cb917c9c2a75.png)
     - After:
![1024x768_2 new](https://user-images.githubusercontent.com/23437060/214678177-964e027e-e876-41d0-a1e5-c39bc56171a3.png)
   - Color
     - Before:
![1024x768_3 old](https://user-images.githubusercontent.com/23437060/214678200-24aed2af-2274-4e12-b370-982e69523ed4.png)
     - After:
![1024x768_3 new](https://user-images.githubusercontent.com/23437060/214678208-2e10e959-8dd0-4e1d-a677-8e28a4d8360b.png)

Closes #4129.

## 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: Robert Müller <robytemueller@gmail.com>
2023-01-25 22:03:31 +00:00
Robert Müller 9054eb15aa Add buttons to move envelopes left and right, use unicode icons
Closes #4129.
2023-01-25 20:05:06 +01:00
Robert Müller b997fe97bc Decrease buffer size 2023-01-25 20:05:06 +01:00
Robert Müller 385fa4d36c Slightly decrease width of name editbox if total width is low 2023-01-25 20:05:06 +01:00
Robert Müller 2514f1d521 Align the editbox labels in the envelope editor with the editboxes 2023-01-25 20:05:06 +01:00
Robert Müller 27790be784 Reserve same space for all envelope channel buttons
Keep all the UI elements in the envelope editor at the same position, independent from the number of channels of the selected envelope.

Previously the UI elements changed their position due to different numbers of channels of the different envelope types. Now the space for the maximum number of channels is always reserved and the UI elements don't move around.
2023-01-25 20:05:06 +01:00
Robert Müller 7ce143bd9e Add CEnvPoint::MAX_CHANNELS constant 2023-01-25 20:05:05 +01:00
Robert Müller 3c42b224f5 Add margin to point value/time editboxes for low screen width
The labels for the editboxes are not shown when the screen width is low, but the spacing should still be applied to the editboxes in that case.
2023-01-25 20:05:05 +01:00
Robert Müller d6d8739031 Remove unnecessary temporary CUIRect 2023-01-25 20:05:05 +01:00
Robert Müller c62cc979cb Remove dead commented code 2023-01-25 20:05:05 +01:00
Robert Müller c9d8fedcee Use IGraphics::CORNER_NONE instead of 0 2023-01-25 20:05:05 +01:00
Robert Müller 3b4d2910ef Rename envelope Synchronized checkbox to Sync.
To gain more width of other controls.
2023-01-25 20:05:04 +01:00
Robert Müller 5b61691f25 Pass nullptr to CUIRect functions when result is unused 2023-01-25 20:05:04 +01:00
Robert Müller c86ef06c5c Add tooltip support for editboxes in editor
Add tooltips for envelope name, point value and point time.
2023-01-25 20:05:04 +01:00
bors[bot] cf32aa95f9
Merge #6308
6308: Fix Crash in CSafeTeam::Safe/Load r=def- a=Zwelf

Fixes #6304

`pEnt` is freed after removing, so must not be used in the next loop iteration.

## 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: Zwelf <zwelf@strct.cc>
2023-01-25 18:32:43 +00:00