Commit graph

4131 commits

Author SHA1 Message Date
Dennis Felsing 34d3ddd9c2 Rename joystick to controller (settings, configs) (fixes #5419)
Also added one Localize
2022-06-15 13:05:14 +02:00
bors[bot] 89e0450359
Merge #5374
5374: Joystick support 🕹️ r=def- a=Robyt3

Port all the joystick support from vanilla:

- Joystick controls
  - support for up to 12 axis (we are using the low level SDL interface so we don't differentiate between X/Y axis, sliders etc.)
  - two axis can be used for X and Y cursor movement
  - cursor input ingame can be relative or absolute
  - support for binding up to 12 joystick buttons
  - support for binding up to 2 hats (each has 8 directions)
  - support for binding axis movement to controls (so you can move with one control stick and aim with the other)
  - multiple joysticks can be connected at the same time, but only one can be actively used, the selected joystick will be remembered based on a GUID
- Joystick UI integration
  - allow moving the UI cursor with the specified joystick axis
  - change `CComponent::OnMouseMove` to `OnCursorMove` to handle joystick separately with its own sensitivity settings
  - remove premultiplied mousesens everywhere
- Joystick settings menu (also: separate mouse and movement settings)
![screenshot_2022-06-08_22-46-08](https://user-images.githubusercontent.com/23437060/172713929-9db75dfe-8408-4d06-827d-cdb162872514.png)
![screenshot_2022-06-08_22-46-10](https://user-images.githubusercontent.com/23437060/172713932-8945feb3-5f41-434c-b555-f92beb22db58.png)
![screenshot_2022-06-08_22-46-11](https://user-images.githubusercontent.com/23437060/172713935-19bb5a47-97dd-4a1e-86e9-a3569bd557ff.png)

Other changes:

- Remove the old unused joystick implementation (with config variable `inp_joystick`).
- Remove an unused parameter.
- Add `CUIEx::DoScrollbarOption` and `IScrollbarScale`
  - renders label, current value and scrollbar
  - with linear and logarithmic scale implementations
  - used for the sensitivity and tolerance settings
  - could eventually be used for most scrollbar settings to reduce duplicate code
  - has flags for:
     - `SCROLLBAR_OPTION_INFINITE`: The scrollbar can be moved all the way to the right for another value that represents ∞. Internally this value is 0.
     - `SCROLLBAR_OPTION_NOCLAMPVALUE`: The scrollbar allows values outside the specified min/max range, e.g. the sensitivity settings can technically be as high as 100000 when set with the console.
- Add `CUIEx::DoScrollbarOptionLabeled`
  - a `DoScrollbarOption` for selecting from a finite number of options with a scrollbar
  - used for switching between relative and absolute input
  - might see more use in the future

Reference: https://github.com/teeworlds/teeworlds/pulls?q=is%3Apr+joystick

## Checklist

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


Co-authored-by: Robert Müller <robytemueller@gmail.com>
2022-06-14 18:01:11 +00:00
bors[bot] caf889d04a
Merge #5406
5406: Remove namespace tw r=Jupeyy a=heinrich5991

It didn't have a clear role, it just acted as a distinguisher between
two functions with the same name.

Rename `tw::time_get` to `time_get_nanoseconds` and delete the old
`time_get_nanoseconds`. Move `CCmdlineFix` and the typed
`net_socket_read_wait` function to the global namespace.

## 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 if it works standalone, system.c especially
- [ ] 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: heinrich5991 <heinrich5991@gmail.com>
2022-06-14 17:46:17 +00:00
bors[bot] 28ce480baa
Merge #5404
5404: Always send all tunings r=def- a=heinrich5991

It doesn't hurt since tunings after the last one are simply ignored.
This also stops future coders from introducing more and more cases in
this `if` chain.

## 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 if it works standalone, system.c especially
- [ ] 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: heinrich5991 <heinrich5991@gmail.com>
2022-06-13 22:10:51 +00:00
Robert Müller 92699de86c Add log_set_loglevel instead of depending on engine config 2022-06-13 23:21:41 +02:00
Robert Müller 55d48db711 Integrate joystick with game controls and menus/editor UI 2022-06-13 20:40:37 +02:00
Robert Müller 8757b1f41e Add joystick support to engine 2022-06-13 20:40:36 +02:00
Robert Müller de76fbfb6a Remove existing joystick implementation 2022-06-13 20:40:36 +02:00
ChillerDragon 3667061b68 Use nullptr in generated and editor
-Wzero-as-null-pointer-constant
2022-06-13 18:28:13 +02:00
heinrich5991 b3a3604c36 Remove namespace tw
It didn't have a clear role, it just acted as a distinguisher between
two functions with the same name.

Rename `tw::time_get` to `time_get_nanoseconds` and delete the old
`time_get_nanoseconds`. Move `CCmdlineFix` and the typed
`net_socket_read_wait` function to the global namespace.
2022-06-13 18:07:29 +02:00
heinrich5991 bc1d293e30 Always send all tunings
It doesn't hurt since tunings after the last one are simply ignored.
This also stops future coders from introducing more and more cases in
this `if` chain.
2022-06-13 17:00:09 +02:00
bors[bot] ae1876d141
Merge #5388
5388: Remove obsolete AfkTimer function r=def- a=ardadem

It does the same job with: 425f07c03d/src/game/server/gamecontroller.cpp (L48)

## 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 if it works standalone, system.c especially
- [ ] 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: Arda Demir <ddmirarda@gmail.com>
2022-06-12 11:26:06 +00:00
Chairn 14f7f2e041 Remaining formatting and fix github code scanning 2022-06-11 22:03:23 +02:00
Chairn e265a9f0a1 Remove useless float vector in vulkan backend 2022-06-11 21:43:45 +02:00
Chairn 01edaec628 Format vector variables names (fixes #5209) 2022-06-11 21:38:49 +02:00
Arda Demir c4492c27ea Move/rename AfkVoteTimer to AfkTimer 2022-06-11 21:11:28 +03:00
Arda Demir 18ab88d33e Remove obsolete AfkTimer function 2022-06-11 21:11:25 +03:00
bors[bot] 37780cbe6f
Merge #5106
5106: Fix dummy intended tick sent to server r=def- a=sjrc6

fixes https://github.com/ddnet/ddnet/issues/5044

Currently the dummy gives the server the wrong IntendedTick aka PredTick which (I think) makes it impossible for the server to correctly order inputs if they come early (i.e. if you're playing with high prediction margin).

Currently with dummy copy if you switch dummy with high prediction margin it will almost always desync, with this change it doesn't desync. 

The only reason dummy works at all is because it relies on this code in the server to change the tick that was sent to be the current game tick, if you remove it then dummy hammer and dummy copy breaks but normal players are unaffected.

e9b59e72ff/src/engine/server/server.cpp (L1632-L1633) 

I marked this PR as draft because it seems to cause some unexpected side effects:

with this change if you use dummy copy in solo part your dummy will be visually delayed, this doesn't change anything but it's different from how it was before and I don't understand why. 

the sound effects from hooking with dummy copy are also not as synced as they are with the wrong tick being sent (not sure why) 

I also didn't test all dummy mechanics or any advanced dummy binds which might somehow rely on the broken behavior. 


With wrong tick sent to server:

https://user-images.githubusercontent.com/22122579/168413464-92a3a44b-3b75-4894-8fb0-54e64ff421fa.mp4

With correct tick:

https://user-images.githubusercontent.com/22122579/168413459-eb6f299c-260a-4ddb-9972-3dea504aef41.mp4






## 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 if it works standalone, system.c especially
- [ ] 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: Tater <Mr.Potatooh@gmail.com>
2022-06-09 21:52:19 +00:00
Dennis Felsing d6e6599c8f Minor improvement for pagination
I thought I had committed this for #5375, but forgot
2022-06-09 11:24:19 +02:00
bors[bot] 16b8806302
Merge #5375
5375: Paginate bans (partially fixes #3691) r=Learath2 a=def-

20 elements per page, we have too many bot bans
![Screenshot 2022-06-08 at 23 53 16](https://user-images.githubusercontent.com/2335377/172724048-70d99f57-4e3c-451a-ada3-96affdf7cd6c.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 if it works standalone, system.c especially
- [ ] 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-06-09 09:03:16 +00:00
Dennis Felsing 2fceb1aa27 Paginate bans (partially fixes #3691)
20 elements per page, we have too many bot bans
2022-06-08 23:48:32 +02:00
Dennis Felsing 1e94d1fa79 Remove sv_checkpoint_save 2022-06-08 21:10:40 +02:00
Robert Müller 86e2d6791f Fix memory leak of CInput clipboard text 2022-06-06 22:14:05 +02:00
Robert Müller ec84e81e17 Replace Android-specific member variables with static variables 2022-06-06 22:14:05 +02:00
Robert Müller ff43b32257 Extract UpdateMouseState function 2022-06-06 22:06:56 +02:00
Robert Müller 9a17617a28 Let IInput::MouseRelative return true if mouse was moved 2022-06-06 22:06:56 +02:00
Robert Müller 92503fccec Add comments, order functions, fix parameter names in engine input 2022-06-06 22:06:55 +02:00
Robert Müller e6bd84d4fd Extract CCmdlineFix to call cmdline_fix and cmdline_free automatically 2022-06-06 12:46:58 +02:00
trml 2b48c376d6 Fix input getter for dummy 2022-06-06 04:17:55 +02:00
def af3b1bb0e7 Log rcon messages (fixes #5342) 2022-06-05 12:44:15 +02:00
bors[bot] b554039740
Merge #5320
5320: Fix prediction input timing r=def- a=trml

Fixes #5307 by updating the prediction to use the new input handling from #5032, and also removed some now no longer used code.

## 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 if it works standalone, system.c especially
- [ ] 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: trml <trml@users.noreply.github.com>
2022-06-04 22:37:03 +00:00
bors[bot] ce795572d2
Merge #5327
5327: Add CLockScope r=heinrich5991 a=def-

Remove unused lock and scope in threading.h

Not sure if this is preferred

We could also try switching to std::mutex and lock_guard

<!-- 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 if it works standalone, system.c especially
- [ ] 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-06-03 10:58:17 +00:00
Dennis Felsing 51909c19ab Add CLockScope
Remove unused lock and scope in threading.h

Not sure if this is preferred

We could also try switching to std::mutex
2022-06-03 12:21:23 +02:00
bors[bot] 2d53aeabce
Merge #5326
5326: Explicitly delete game server from list on shutdown r=def- a=heinrich5991

Also delete it explicitly when `sv_register` is set to register via less
protocols.

On shutdown, wait at most 1 second for the masterserver to respond,
otherwise allow up to 15 seconds.

Fixes https://github.com/ddnet/ddnet/issues/5157.

## 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 if it works standalone, system.c especially
- [ ] 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: heinrich5991 <heinrich5991@gmail.com>
2022-06-03 09:41:37 +00:00
heinrich5991 7fccfaf211 Explicitly delete game server from list on shutdown
Also delete it explicitly when `sv_register` is set to register via less
protocols.

On shutdown, wait at most 1 second for the masterserver to respond,
otherwise allow up to 15 seconds.

Fixes #5157.
2022-06-03 11:27:47 +02:00
trml 455b17e957 Update prediction to use new input handling 2022-06-02 22:35:10 +02:00
c0d3d3v d125c91825
send normal shields to old clients 2022-06-02 15:27:57 +02:00
bors[bot] 9dd46eb764
Merge #5260
5260: Pr thread safety negative r=heinrich5991 a=def-

WorkerThread is hard because `REQUIRES(!((CJobPool *)pUser)->m_Lock)` would require alias analysis or the function using that everywhere.

https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#negative

## 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 if it works standalone, system.c especially
- [ ] 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-06-01 11:17:30 +00:00
bors[bot] b623c3c124
Merge #5284
5284: add ellipsis again r=heinrich5991 a=C0D3D3V

![grafik](https://user-images.githubusercontent.com/14315968/171151688-a5fdb2a8-d070-4485-a187-ac768a32e854.png)
![grafik](https://user-images.githubusercontent.com/14315968/171151717-d36312d4-5e2e-4b50-af9a-7a202a1564a4.png)

`@Jupeyy`  can you please test if this also decreases the fps significant more than without this PR?


without ellipsis (and name in mini score hud flows over the left border):
![grafik](https://user-images.githubusercontent.com/14315968/171153136-af385267-af7a-4913-844e-4e95d60bf799.png)

with ellipsis:
![grafik](https://user-images.githubusercontent.com/14315968/171153237-0996600e-92aa-4b0c-b8f5-fdde05c2751b.png)


## 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 if it works standalone, system.c especially
- [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: c0d3d3v <c0d3d3v@mag-keinen-spam.de>
2022-06-01 10:05:57 +00:00
bors[bot] 27ebe08c72
Merge #5290 #5293
5290: Don't output as much in normal STUN behavior r=def- a=heinrich5991

Log send errors with debug instead of error severity. They're normal in case a protocol stack isn't initialized supported by the host or if there's no route.

Don't periodically retry STUN if successful. Trying again for each connection establishment is enough. Previously, it
was re-requested every 10 minutes.

Fixes #5273.

## 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 if it works standalone, system.c especially
- [ ] 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)


5293: Cleanup: Remove dead code, don't print datafile debug per default, remove misused static CUIRect r=def- a=Robyt3

- Remove dead (commented out) code.
- Don't print detailed datafile log messages, unless the datafile specific `DEBUG` flag is set.
- Use `static int` instead of `static CUIRect` as UI element ID.

## 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 if it works standalone, system.c especially
- [ ] 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: heinrich5991 <heinrich5991@gmail.com>
Co-authored-by: Robert Müller <robytemueller@gmail.com>
2022-05-31 18:54:56 +00:00
Robert Müller 7474ca201f Remove dead code 2022-05-31 19:32:07 +02:00
Robert Müller 7f24922b35 Print auxiliary datafile log messages only when DEBUG flag set 2022-05-31 19:32:07 +02:00
heinrich5991 92f27bdb30 Don't periodically retry STUN if successful
Trying again for each connection establishment is enough. Previously, it
was re-requested every 10 minutes.

Fixes #5273.
2022-05-31 17:53:11 +02:00
heinrich5991 71d47c3329 Log send errors with debug instead of error severity
They're normal in case a protocol stack isn't initialized supported
by the host or if there's no route.

CC #5273
2022-05-31 17:49:11 +02:00
bors[bot] d32b223636
Merge #5287 #5288
5287: Work around Windows's definition of `min`/`max` r=Jupeyy a=heinrich5991

This allows us to use `std::min`/`std::max`.

<!-- 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 if it works standalone, system.c especially
- [ ] 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)


5288: Remove outdated comment r=Jupeyy a=heinrich5991

The string comparison isn't actually done anymore, it's now done via a
boolean flag.

## 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 if it works standalone, system.c especially
- [ ] 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: heinrich5991 <heinrich5991@gmail.com>
2022-05-31 15:43:15 +00:00
heinrich5991 d0ff8114d6 Remove outdated comment
The string comparison isn't actually done anymore, it's now done via a
boolean flag.
2022-05-31 17:33:00 +02:00
heinrich5991 9da3f5c359 Only show port forward message if there's a problem
Previously, it was always shown.

Fixes #5203.
2022-05-31 16:39:54 +02:00
Dennis Felsing e31fa7051e Fix clamp in CStun::Update (fixes #5282) 2022-05-31 13:31:43 +02:00
c0d3d3v 0914c1260b
add ellipsis again 2022-05-31 12:20:45 +02:00
bors[bot] 4183ad6b47
Merge #5179
5179: Add loglevel config (fixes #5178, fixes #5174) r=heinrich5991 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 if it works standalone, system.c especially
- [ ] 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-05-31 08:21:03 +00:00