Commit graph

4274 commits

Author SHA1 Message Date
Chairn a3a85bee5f Remove useless typedef in c++ 2022-06-25 21:05:54 +02:00
Robert Müller 87cb948166 Clamp number of demo timeline markers to valid range 2022-06-25 16:57:25 +02:00
Jupeyy eb3406c4cf Add missing capability for GLES backend 2022-06-25 16:11:04 +02:00
Chairn a50ddb75ff clang-format 2022-06-25 15:30:39 +02:00
Chairn 5f5b80ae57 Use [[fallthrough]] attribute rather than comment 2022-06-25 15:21:44 +02:00
c0d3d3v ed2c514aa7
Change help text of cl_asset_extras 2022-06-25 10:28:54 +02:00
bors[bot] 34da9f2282
Merge #5489
5489: Fix build with -DUPNP=ON r=def- a=ChillerDragon

We should have a CI that builds the same cmake settings as this arch package

https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=ddnet-git

Co-authored-by: ChillerDragon <ChillerDragon@gmail.com>
2022-06-24 13:58:00 +00:00
ChillerDragon 0163aa56ac Fix build with -DUPNP=ON 2022-06-24 14:16:29 +02:00
Dennis Felsing 805f6ac431 Fix win32 discord compilation
/home/deen/isos/ddnet/ddnet-source/src/engine/client/discord.cpp: In function ‘EDiscordResult (* GetDiscordCreate())(DiscordVersion, DiscordCreateParams*, IDiscordCore**)’:
/home/deen/isos/ddnet/ddnet-source/src/engine/client/discord.cpp:25:16: error: invalid conversion from ‘EDiscordResult (__attribute__((stdcall)) *)(DiscordVersion, DiscordCreateParams*, IDiscordCore**)’ {aka ‘EDiscordResult (__attribute__((stdcall)) *)(int, DiscordCreateParams*, IDiscordCore**)’} to ‘FDiscordCreate’ {aka ‘EDiscordResult (*)(int, DiscordCreateParams*, IDiscordCore**)’} [-fpermissive]
   25 |         return DiscordCreate;
      |                ^~~~~~~~~~~~~
      |                |
      |                EDiscordResult (__attribute__((stdcall)) *)(DiscordVersion, DiscordCreateParams*, IDiscordCore**) {aka EDiscordResult (__attribute__((stdcall)) *)(int, DiscordCreateParams*, IDiscordCore**)}
2022-06-24 10:06:04 +02:00
Robert Müller 52a78c45ef Fix memory leak of OpenGL 2 buffer object data
```
Direct leak of 216320 byte(s) in 3 object(s) allocated from:
    #0 0x7f5e05924808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x559b8ca66278 in CCommandProcessorFragment_OpenGL2::Cmd_CreateBufferObject(CCommandBuffer::SCommand_CreateBufferObject const*) src/engine/client/backend/opengl/backend_opengl.cpp:1901
    #2 0x559b8ca47fe7 in CCommandProcessorFragment_OpenGL::RunCommand(CCommandBuffer::SCommand const*) src/engine/client/backend/opengl/backend_opengl.cpp:1107
    #3 0x559b8cdf811b in CCommandProcessor_SDL_GL::RunBuffer(CCommandBuffer*) src/engine/client/backend_sdl.cpp:248
    #4 0x559b8cdf4262 in CGraphicsBackend_Threaded::ThreadFunc(void*) src/engine/client/backend_sdl.cpp:77
    #5 0x559b8dfc58a5 in thread_run src/base/system.cpp:721
    #6 0x7f5e03bf6608 in start_thread /build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c:477
```
2022-06-23 19:58:39 +02:00
bors[bot] b75289df35
Merge #4829 #5343 #5465
4829: Added map_replace_area tool r=def- a=sctt

Motivation:
sometimes mappers need to copy a certain area from a map to another (but also to a different position of the same map).
that's very time consuming on complex maps, as tiles and quads layers have to be manually copied one by one.

map_replace_area is designed to automatically replace all the tiles and quads from a specific area to another.
`Usage: map_replace_area <from_map> <from_x> <from_y> <to_map> <to_x> <to_y> <width> <height> <output_map>`

PoW screenshots attached below.

note: for the moment map_replace_area suppose that you are working on the same map  (that's what i needed), that means source and destination maps must have the same layers structure, or else an error is returned.
but i understand it might be useful to also work on totally different maps, in that case users must be able specify layers they want to consider by associating source map layers to destination map layers (by using a config file maybe).
i'm probably going to make another PR to add this enhancement in the future.

PoW:
![Screenshot from 2022-03-16 18-08-12](https://user-images.githubusercontent.com/3328841/158650515-17c31639-28f7-4e19-954a-b5734ee82703.png)
![Screenshot from 2022-03-16 18-08-43](https://user-images.githubusercontent.com/3328841/158650512-6e21f2b4-538f-4974-aaa2-2983551d24b4.png)
![Screenshot from 2022-03-16 18-11-50](https://user-images.githubusercontent.com/3328841/158650510-d00a05a9-a2e8-4df2-8674-0c80fd894f66.png)

5343: Add rcon and chat to integration test r=def- a=ChillerDragon

Add more action to the integration test script: chat messages, chat commands, rcon commands.
This unlocks more code coverage at runtime to catch asan issues.

It adds a very restrictive regex on the log format. But I am happy to maintain that in case changes to the log output happen.
The current version is already supporting heinrichs refactor https://github.com/ddnet/ddnet/pull/5036

Also ensure chat messages arrive in the correct format. Would have catched the following issues:
https://github.com/ddnet/ddnet/issues/5342
https://github.com/ddnet/ddnet/issues/5340
https://github.com/ddnet/ddnet/issues/5302
https://github.com/ddnet/ddnet/pull/5126

DEPENDS ON:

https://github.com/ddnet/ddnet/issues/5342
https://github.com/ddnet/ddnet/issues/5340

5465: Change from pnglite to libpng for PNG reading r=def- a=heinrich5991

This is desirable mainly because libpng is maintained and pnglite is
not. pnglite was last updated in 2007 (15 years ago) and probably has a
lot of security vulnerabilities.

libpng is an actively maintained library also used by browsers like
Firefox or Chromium, so it's less likely to contain security
vulnerabilities, also it's more likely to be packaged by Linux
distributions.

This also refuses to load images of types not supported by pnglite,
which allows us to think about backward compatibility while also
introducing libpng.

## 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: sctt <scottistefano91@gmail.com>
Co-authored-by: term <term@term.sinervis.pri>
Co-authored-by: f <scottistefano91@gmail.com>
Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
Co-authored-by: ChillerDragon <ChillerDragon@gmail.com>
Co-authored-by: def <dennis@felsin9.de>
Co-authored-by: Jupeyy <jupjopjap@gmail.com>
2022-06-21 16:21:47 +00:00
heinrich5991 4625b55ad6 Move PNG handling to src/engine/gfx
This way, it's no longer compiled into the server.
2022-06-21 15:26:23 +02:00
heinrich5991 955084693d Refuse to load images of types not supported by pnglite
This allows us to think about backward compatibility while also
introducing libpng.
2022-06-21 13:37:14 +02:00
Jupeyy 65ad57a448 Change from pnglite to libpng for PNG reading
This is desirable mainly because libpng is maintained and pnglite is
not. pnglite was last updated in 2007 (15 years ago) and probably has a
lot of security vulnerabilities.

libpng is an actively maintained library also used by browsers like
Firefox or Chromium, so it's less likely to contain security
vulnerabilities, also it's more likely to be packaged by Linux
distributions.
2022-06-21 13:37:14 +02:00
Dennis Felsing af1f0de5fb
Merge pull request #5453 from Robyt3/Joystick-Close-Before-SDL-Quit
Fix segfault in `SDL_JoystickClose` on client quit
2022-06-20 23:47:59 +02:00
Robert Müller 3f1f94c9d8 Fix segfault in SDL_JoystickClose on client quit
Instead of closing the joysticks manually, use `SDL_QuitSubSystem(SDL_INIT_JOYSTICK)` to quit the entire subsystem, which will also close all joysticks correctly.

The engine input destructor is replaced with a `Shutdown` method so we can control when it is called, i.e. before calling `SDL_Quit`, which forcefully quits all subsystems.

`CJoystick::Close` is removed as we don't need to close joysticks manually anymore.
2022-06-18 11:57:57 +02:00
Robert Müller a1851ed4e4 Organize engine-server includes 2022-06-17 20:32:56 +02:00
Robert Müller 23cce5415e Organize engine-client includes 2022-06-17 17:46:43 +02:00
Robert Müller 32707f6354 Remove unused CVideo constructor argument, organize includes 2022-06-17 17:39:26 +02:00
Robert Müller 2c9696cefd Use existing typedef instead of duplicating arguments 2022-06-17 17:39:26 +02:00
Robert Müller 557ee84001 Organize base includes 2022-06-17 17:39:25 +02:00
Robert Müller 4048bbbf5c Organize engine-shared includes 2022-06-17 17:39:24 +02:00
Robert Müller da5ec5a0d2 Include <iterator> instead of <array> for std::size
As `std::size` nominally resides in `<iterator>`.
2022-06-17 17:39:24 +02:00
Robert Müller 82e8ab5236 Fix shader code vector size not being updated after copy 2022-06-16 19:54:27 +02:00
Robert Müller dc52377fc5 Use ReadFile to read shader 2022-06-16 10:19:38 +02:00
Robert Müller 0a463320cf Use ReadFile to load server maps 2022-06-16 10:19:37 +02:00
Robert Müller 5d49ee3684 Use ReadFile to load updater index json 2022-06-16 10:19:37 +02:00
Robert Müller ceca44ea23 Use io_read_all to load icon font 2022-06-16 10:19:37 +02:00
Robert Müller 74d7d4fe78 Use ReadFile to load wv/opus sound files 2022-06-16 10:19:37 +02:00
Robert Müller 7050022b08 Use ReadFile in CServerBrowser::LoadDDNetInfoJson 2022-06-16 10:19:36 +02:00
Robert Müller 93536b8977 Use io_read_all to load font files 2022-06-16 10:19:36 +02:00
Robert Müller c1c8797f84 Add IStorage::ReadFile and ReadFileStr:
Storage wrappers around `io_read_all` and `io_read_all_str`.
2022-06-16 10:19:36 +02:00
c0d3d3v 781f2e7b57
add cl_show_jumps_indicator option 2022-06-15 22:05:44 +02:00
c0d3d3v 2475e844e0
Add extras texture + asset tab 2022-06-15 22:03:52 +02:00
c0d3d3v 167f2afc11
remove tile info messages and freeze/ninja stars for new clients using version checking 2022-06-15 22:01:35 +02:00
Chairn b80af9beb3 Fix wrongly corrected naming introduced in #5391 2022-06-15 21:09:57 +02:00
bors[bot] b8a82f71aa
Merge #5429
5429: More vector naming format r=heinrich5991 a=Chairn

Following of https://github.com/ddnet/ddnet/pull/5391

## 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: Chairn <chairn.nq@hotmail.fr>
2022-06-15 17:41:08 +00:00
Chairn c9345e7d32 More vector naming format 2022-06-15 19:37:37 +02:00
Robert Müller eb7e210fc1 Separate editor update and render to fix slow joystick input 2022-06-15 17:37:22 +02:00
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
def 5768e52a13 Minor fixes 2022-06-07 00:33:01 +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 de55d49c72 Fix motd undef behavior
Conditional jump or move depends on uninitialised value(s)
   at 0x2158DA: int IServer::SendPackMsg<CNetMsg_Sv_Motd, 0>(CNetMsg_Sv_Motd*, int, int) (server.h:73)
   by 0x1FE02F: CGameContext::SendMotd(int) (gamecontext.cpp:538)
   by 0x20A874: CGameContext::ConchainSpecialMotdupdate(IConsole::IResult*, void*, void (*)(IConsole::IResult*, void*), void*) (gamecontext.cpp:3124)
   by 0x145A23: CConsole::Con_Chain(IConsole::IResult*, void*) (console.cpp:1202)
   by 0x132086: CConsole::ExecuteLineStroked(int, char const*, int, bool) (console.cpp:528)
   by 0x1323A7: CConsole::ExecuteLine(char const*, int, bool) (console.cpp:582)
   by 0x1326B1: CConsole::ExecuteFile(char const*, int, bool, int) (console.cpp:625)
   by 0x1C60E9: main (server.cpp:3874)
 Uninitialised value was created by a heap allocation
   at 0x483BE63: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x1C5900: CreateServer() (server.cpp:3755)
   by 0x1C5C4C: main (server.cpp:3818)
2022-06-05 20:52:04 +02:00
def 735b0bdf4a fifo: read() doesn't null-terminate!
valgrind found this with ChillerDragon's integration script extension
2022-06-05 20:15:55 +02:00
def 1db79fb493 Log rcon messages (fixes #5342) 2022-06-05 19:26:39 +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
bors[bot] 760cb99574
Merge #5271
5271: Time out for POST requests too (hopefully fixes #5198) r=heinrich5991 a=def-

Untested because the issue is sporadic. But I think it makes sense to have a timeout even if this is not the root cause.

## 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: def <dennis@felsin9.de>
2022-05-31 08:01:38 +00:00
c0d3d3v 19ae17366d
penalty tiles can be used to get a time of 0:00:01, this is fixed by
letting the tees die, before that happens
2022-05-30 20:53:04 +02:00
Robert Müller 91d2ba1865 Organize game-client includes 2022-05-29 21:24:43 +02:00
Robert Müller 0101e94a63 Organize engine-server includes 2022-05-29 21:24:43 +02:00
Robert Müller 4b36584ca1 Organize engine-client includes 2022-05-29 21:24:43 +02:00
Robert Müller 31533d5e2a Organize engine-shared includes 2022-05-29 20:02:22 +02:00
def 3e60cd83d0 Time out for POST requests too (hopefully fixes #5198) 2022-05-29 19:15:36 +02:00
bors[bot] 719e3e4385
Merge #5264 #5266
5264: Prevent users from setting port 1-1023 r=Jupeyy a=def-

Following user report that they set cl_port 1 and it didn't work

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


5266: Use std::make_unique (fixes #5166) r=Jupeyy a=def-

No idea why clang-tidy's modernize-... didn't work

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


Co-authored-by: def <dennis@felsin9.de>
2022-05-28 16:01:32 +00:00
def 19dcd44fbe Use std::make_unique (fixes #5166)
No idea why clang-tidy's modernize-... didn't work
2022-05-28 14:46:55 +02:00
def a3c1a4c540 Prevent users from setting port 1-1023
Following user report that they set cl_port 1 and it didn't work
2022-05-28 13:42:28 +02:00
bors[bot] ccf0622984
Merge #5252
5252: Use std::vector instead of array, remove base/tl/array.h, algorithm.h, allocator.h, range.h r=def- a=Robyt3

Replaces all usages of `array` with `std::vector`.

I adjusted variable names of variables I changed to use the `v` prefix. Not so in the editor however, as there are already many changes due to clang-tidy enforcing the use of for-each loops.

This allows us to remove all remaining `base/tl` headers except `threading.h`.

Clang-tidy now finds `clang-analyzer-cplusplus.NewDelete` (Use of memory after it is freed), which is also fixed here, though it appears to be a false-positive.

This last remaining usages of `goto` are also 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 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: Robert Müller <robytemueller@gmail.com>
2022-05-28 10:56:21 +00:00
Jupeyy 23683a701e Remove alpha threshold from map_optmize 2022-05-28 09:15:08 +02:00
Dennis Felsing 174b855774 Enable -Wthread-safety-negative (as suggested by Chairn) 2022-05-28 02:14:46 +02:00
bors[bot] 862faa255a
Merge #5256
5256: Use double for traffic calculations r=def- a=Jupeyy

fixes #5207

Not going to rewrite rn since it relies on normilization of the time.
Hope this is enough, floats probs struggle with time_freq and time differences being so huge

## 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: Jupeyy <jupjopjap@gmail.com>
2022-05-27 18:19:38 +00:00
Jupeyy d4b1bec6fe Use double for traffic calculations 2022-05-27 19:40:27 +02:00
Jupeyy d7cdc14819 Don't ever skip any frame 2022-05-27 17:54:58 +02:00
Robert Müller 3f8fb732a3 Use std::vector<CKey> instead of array 2022-05-27 16:31:18 +02:00
Robert Müller c6e195a399 Use std::vector<CNameBan> instead of array 2022-05-27 16:31:18 +02:00
Robert Müller 4a023342b7 Use std::vector<CName> instead of array, adjust variable name 2022-05-27 16:31:18 +02:00
Robert Müller ae8f5e87c7 Use std::vector<CNameIndexed> instead of sorted_array 2022-05-27 00:03:13 +02:00
bors[bot] 00c167148d
Merge #5194
5194: Revert Ellipsis (alternative to #5193) 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-25 14:46:16 +00:00
Chairn 0076edf499 Remove useless setting 2022-05-25 00:12:38 +02:00
bors[bot] 03f95108b4
Merge #5063
5063: Reworked Draggers and Turrets AND show always hooks if they are in the field of view  r=def- a=C0D3D3V

Fixes #3622, #4723 #4798 and #5054

Here you can find a comparison video with 16.0.3: https://youtu.be/bYwLB1cEMI8

This now also includes the changes from https://github.com/ddnet/ddnet/pull/4980 
So please also see my monologue here: https://github.com/ddnet/ddnet/pull/4980

Physic that got changed by this PR:
- Solo players are not included in the calculation of the next team players to the dragger/turrets. This does not affect any map.
- Turrets get switched correctly if players are solo
- Plasma bullets fired by turrets on solo player only explode for solo players and the other way around (except if they unsolo)
- Plasma bullets can no longer be intercepted by other teams 
- Turrets can shot now independently at the speed of sv_plasma_per_sec for  every team and every solo player


This should be tested by some more players before it get merged!

This reduces the use of snap id's tested here: https://youtu.be/G3nVtdH0--Q 
from 16000 to 69
test with the new dragger: https://youtu.be/mzNrDHP7HQs
I did not add the terminal of the server because you basically see no change in the used snap ids 
The videos are with cl_predict off

Comparison of the new turrets: https://streamable.com/8us8lk
left old turrets, right the new ones

We should delete ranks on (that where made after 13 Jun 2019):
https://ddnet.tw/maps/Increase-32-Your-32-Speed
https://ddnet.tw/maps/Fall-32-into-32-the-32-Future
https://ddnet.tw/maps/turboSeks

## 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
- [x] Considered possible null pointers and out of bounds array indexing
- [only on 3 maps] 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-05-24 18:26:08 +00:00
heinrich5991 c93658f929 Make sure we don't accidentally initialize libcurl in a thread 2022-05-23 17:21:27 +02:00
heinrich5991 76ed324b66 Call HttpInit in server
Otherwise `curl_global_init` would be called from the first
`curl_easy_init`, but `curl_global_init` isn't threadsafe.

Fixes #5195.
2022-05-23 17:20:45 +02:00
bors[bot] 064dc2c0c5
Merge #5196
5196: Break early out of loop r=heinrich5991 a=ChillerDragon



Co-authored-by: ChillerDragon <ChillerDragon@gmail.com>
2022-05-23 07:31:34 +00:00
bors[bot] 847454f3be
Merge #5189
5189: Fix 0 byte malloc in register.cpp (fixes #5187) r=heinrich5991 a=def-

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


Co-authored-by: def <dennis@felsin9.de>
2022-05-23 07:15:54 +00:00
ChillerDragon e54f0ee97b Break early out of loop 2022-05-23 08:32:00 +02:00
def 76efcc616b Fix 0 byte malloc in register.cpp (fixes #5187) 2022-05-23 00:24:22 +02:00
def 0c8bf5c3aa Revert "Ellipsis at end in scoreboard and hud"
This reverts commit f278399bd1.
2022-05-22 23:04:32 +02:00
def 590eb2c5d1 Revert "Render full text when it still fits"
This reverts commit c4bcf3d628.
2022-05-22 23:01:00 +02:00
c0d3d3v b751a2e098
Reworked Draggers 2022-05-22 21:59:33 +02:00
bors[bot] 85ce4fc0a8
Merge #5185
5185:  Fix pickups moving on their own (fixes #5137) r=C0D3D3V a=def-

Supersedes #5181 

Objects should be initialized fully, otherwise they are super easy to misuse and get weird undefined behavior that happens rarely.

## 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-22 14:32:21 +00:00
Jupeyy 1e6df0c7a9 Lower max allowed FSAA on OpenGL 2022-05-22 14:42:21 +02:00
def 3116494f6e Fix some uninitialized variables, found with valgrind 2022-05-22 12:18:49 +02:00
Zwelf 86f57289c6 Record player switch in teehistorian 2022-05-21 21:37:17 +02:00
Zwelf b99d8dc259 Always apply last sent input
Makes teehistorian during spawn more reproduceable.
Currently during respawn the first applied input doesn't get recorded.
Always appliying the last sent input fixes this.
2022-05-21 21:34:30 +02:00
def c4bcf3d628 Render full text when it still fits 2022-05-21 12:12:00 +02:00
def 38b2a8d592 Add loglevel config (fixes #5178, fixes #5174) 2022-05-21 12:06:54 +02:00
Robert Müller fade4d2984 Extract CConsole::TraverseChain, fix toggle with multiple chains 2022-05-20 19:41:31 +02:00
bors[bot] e7140caf8b
Merge #5064
5064: Add HTTP masterserver registering and HTTP masterserver r=def- a=heinrich5991

Registering
-----------

The idea is that game servers push their server info to the
masterservers every 15 seconds or when the server info changes, but not
more than once per second.

The game servers do not support the old registering protocol anymore,
the backward compatibility is handled by the masterserver.

The register call is a HTTP POST to a URL like
`https://master1.ddnet.tw/ddnet/15/register` and looks like this:
```http
POST /ddnet/15/register HTTP/1.1
Address: tw-0.6+udp://connecting-address.invalid:8303
Secret: 81fa3955-6f83-4290-818d-31c0906b1118
Challenge-Secret: 81fa3955-6f83-4290-818d-31c0906b1118:tw0.6/ipv6
Info-Serial: 0

{
	"max_clients": 64,
	"max_players": 64,
	"passworded": false,
	"game_type": "TestDDraceNetwork",
	"name": "My DDNet server",
	"map": {
		"name": "dm1",
		"sha256": "0b0c481d77519c32fbe85624ef16ec0fa9991aec7367ad538bd280f28d8c26cf",
		"size": 5805
	},
	"version": "0.6.4, 16.0.3",
	"clients": []
}
```

The `Address` header declares that the server wants to register itself as
a `tw-0.6+udp` server, i.e. a server speaking a Teeworlds-0.6-compatible
protocol.

The free-form `Secret` header is used as a server identity, the server
list will be deduplicated via this secret.

The free-form `Challenge-Secret` is sent back via UDP for a port forward
check.  This might have security implications as the masterserver can be
asked to send a UDP packet containing some user-controlled bytes. This
is somewhat mitigated by the fact that it can only go to an
attacker-controlled IP address.

The `Info-Serial` header is an integer field that should increase each
time the server info (in the body) changes. The masterserver uses that
field to ensure that it doesn't use old server infos.

The body is a free-form JSON object set by the game server. It should
contain certain keys in the correct form to be accepted by clients. The
body is optional if the masterserver already confirmed the reception of
the info with the given `Info-Serial`.

Not shown in this payload is the `Connless-Token` header that is used
for Teeworlds 0.7 style communication.

Also not shown is the `Challenge-Token` that should be included once the
server receives the challenge token via UDP.

The masterserver responds with a `200 OK` with a body like this:

```
{"status":"success"}
```

The `status` field can be `success` if the server was successfully
registered on the masterserver, `need_challenge` if the masterserver
wants the correct `Challenge-Token` header before the register process
is successful, `need_info` if the server sent an empty body but the
masterserver doesn't actually know the server info.

It can also be `error` if the request was malformed, only in this case
an HTTP status code except `200 OK` is sent.

Synchronization
---------------

The masterserver keeps state and outputs JSON files every second.

```json
{
	"servers": [
		{
			"addresses": [
				"tw-0.6+udp://127.0.0.1:8303",
				"tw-0.6+udp://[::1]:8303"
			],
			"info_serial": 0,
			"info": {
				"max_clients": 64,
				"max_players": 64,
				"passworded": false,
				"game_type": "TestDDraceNetwork",
				"name": "My DDNet server",
				"map": {
					"name": "dm1",
					"sha256": "0b0c481d77519c32fbe85624ef16ec0fa9991aec7367ad538bd280f28d8c26cf",
					"size": 5805
				},
				"version": "0.6.4, 16.0.3",
				"clients": []
			}
		}
	]
}
```

`servers.json` (or configured by `--out`) is a server list that is
compatible with DDNet 15.5+ clients. It is a JSON object containing a
single key `servers` with a list of game servers. Each game server is
represented by a JSON object with an `addresses` key containing a list
of all known addresses of the server and an `info` key containing the
free-form server info sent by the game server. The free-form `info` JSON
object re-encoded by the master server and thus canonicalized and
stripped of any whitespace characters outside strings.

```json
{
	"kind": "mastersrv",
	"now": 1816002,
	"secrets": {
		"tw-0.6+udp://127.0.0.1:8303": {
			"ping_time": 1811999,
			"secret": "42d8f991-f2fa-46e5-a9ae-ebcc93846feb"
		},
		"tw-0.6+udp://[::1]:8303": {
			"ping_time": 1811999,
			"secret": "42d8f991-f2fa-46e5-a9ae-ebcc93846feb"
		}
	},
	"servers": {
		"42d8f991-f2fa-46e5-a9ae-ebcc93846feb": {
			"info_serial": 0,
			"info": {
				"max_clients": 64,
				"max_players": 64,
				"passworded": false,
				"game_type": "TestDDraceNetwork",
				"name": "My DDNet server",
				"map": {
					"name": "dm1",
					"sha256": "0b0c481d77519c32fbe85624ef16ec0fa9991aec7367ad538bd280f28d8c26cf",
					"size": 5805
				},
				"version": "0.6.4, 16.0.3",
				"clients": []
			}
		}
	}
}
```

`--write-dump` outputs a JSON file compatible with `--read-dump-dir`,
this can be used to synchronize servers across different masterservers.
`--read-dump-dir` is also used to ingest servers from the backward
compatibility layer that pings each server for their server info using
the old protocol.

The `kind` field describe that this is `mastersrv` output and not from a
`backcompat`. This is used for prioritizing `mastersrv` information over
`backcompat` information.

The `now` field contains an integer describing the current time in
milliseconds relative an unspecified epoch that is fixed for each JSON
file. This is done instead of using the current time as the epoch for
better compression of non-changing data.

`secrets` is a map from each server address and to a JSON object
containing the last ping time (`ping_time`) in milliseconds relative to
the same epoch as before, and the server secret (`secret`) that is used
to unify server infos from different addresses of the same logical
server.

`servers` is a map from the aforementioned `secret`s to the
corresponding `info_serial` and `info`.

```json
[
	"tw-0.6+udp://127.0.0.1:8303",
	"tw-0.6+udp://[::1]:8303"
]
```

`--write-addresses` outputs a JSON file containing all addresses
corresponding to servers that are registered to HTTP masterservers. It
does not contain the servers that are obtained via backward
compatibility measures.

This file can be used by an old-style masterserver to also list
new-style servers without the game servers having to register there.

An implementation of this can be found at
https://github.com/heinrich5991/teeworlds/tree/mastersrv_6_backcompat
for Teeworlds 0.5/0.6 masterservers and at
https://github.com/heinrich5991/teeworlds/tree/mastersrv_7_backcompat
for Teeworlds 0.7 masterservers.

All these JSON files can be sent over the network in an efficient way
using https://github.com/heinrich5991/twmaster-collect. It establishes a
zstd-compressed TCP connection authenticated by a string token that is
sent in plain-text. It watches the specified file and transmits it every
time it changes. Due to the zstd-compression, the data sent over the
network is similar to the size of a diff.

Implementation
--------------

The masterserver implementation was done in Rust.

The current gameserver register implementation doesn't support more than
one masterserver for registering.

Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2022-05-20 17:01:20 +00:00
heinrich5991 6b65ccb945 Add HTTP masterserver registering and HTTP masterserver
Registering
-----------

The idea is that game servers push their server info to the
masterservers every 15 seconds or when the server info changes, but not
more than once per second.

The game servers do not support the old registering protocol anymore,
the backward compatibility is handled by the masterserver.

The register call is a HTTP POST to a URL like
`https://master1.ddnet.tw/ddnet/15/register` and looks like this:
```json
POST /ddnet/15/register HTTP/1.1
Address: tw-0.6+udp://connecting-address.invalid:8303
Secret: 81fa3955-6f83-4290-818d-31c0906b1118
Challenge-Secret: 81fa3955-6f83-4290-818d-31c0906b1118:tw0.6/ipv6
Info-Serial: 0

{
	"max_clients": 64,
	"max_players": 64,
	"passworded": false,
	"game_type": "TestDDraceNetwork",
	"name": "My DDNet server",
	"map": {
		"name": "dm1",
		"sha256": "0b0c481d77519c32fbe85624ef16ec0fa9991aec7367ad538bd280f28d8c26cf",
		"size": 5805
	},
	"version": "0.6.4, 16.0.3",
	"clients": []
}
```

The `Address` header declares that the server wants to register itself as
a `tw-0.6+udp` server, i.e. a server speaking a Teeworlds-0.6-compatible
protocol.

The free-form `Secret` header is used as a server identity, the server
list will be deduplicated via this secret.

The free-form `Challenge-Secret` is sent back via UDP for a port forward
check.  This might have security implications as the masterserver can be
asked to send a UDP packet containing some user-controlled bytes. This
is somewhat mitigated by the fact that it can only go to an
attacker-controlled IP address.

The `Info-Serial` header is an integer field that should increase each
time the server info (in the body) changes. The masterserver uses that
field to ensure that it doesn't use old server infos.

The body is a free-form JSON object set by the game server. It should
contain certain keys in the correct form to be accepted by clients. The
body is optional if the masterserver already confirmed the reception of
the info with the given `Info-Serial`.

Not shown in this payload is the `Connless-Token` header that is used
for Teeworlds 0.7 style communication.

Also not shown is the `Challenge-Token` that should be included once the
server receives the challenge token via UDP.

The masterserver responds with a `200 OK` with a body like this:

```
{"status":"success"}
```

The `status` field can be `success` if the server was successfully
registered on the masterserver, `need_challenge` if the masterserver
wants the correct `Challenge-Token` header before the register process
is successful, `need_info` if the server sent an empty body but the
masterserver doesn't actually know the server info.

It can also be `error` if the request was malformed, only in this case
an HTTP status code except `200 OK` is sent.

Synchronization
---------------

The masterserver keeps state and outputs JSON files every second.

```json
{
	"servers": [
		{
			"addresses": [
				"tw-0.6+udp://127.0.0.1:8303",
				"tw-0.6+udp://[::1]:8303"
			],
			"info_serial": 0,
			"info": {
				"max_clients": 64,
				"max_players": 64,
				"passworded": false,
				"game_type": "TestDDraceNetwork",
				"name": "My DDNet server",
				"map": {
					"name": "dm1",
					"sha256": "0b0c481d77519c32fbe85624ef16ec0fa9991aec7367ad538bd280f28d8c26cf",
					"size": 5805
				},
				"version": "0.6.4, 16.0.3",
				"clients": []
			}
		}
	]
}
```

`servers.json` (or configured by `--out`) is a server list that is
compatible with DDNet 15.5+ clients. It is a JSON object containing a
single key `servers` with a list of game servers. Each game server is
represented by a JSON object with an `addresses` key containing a list
of all known addresses of the server and an `info` key containing the
free-form server info sent by the game server. The free-form `info` JSON
object re-encoded by the master server and thus canonicalized and
stripped of any whitespace characters outside strings.

```json
{
	"kind": "mastersrv",
	"now": 1816002,
	"secrets": {
		"tw-0.6+udp://127.0.0.1:8303": {
			"ping_time": 1811999,
			"secret": "42d8f991-f2fa-46e5-a9ae-ebcc93846feb"
		},
		"tw-0.6+udp://[::1]:8303": {
			"ping_time": 1811999,
			"secret": "42d8f991-f2fa-46e5-a9ae-ebcc93846feb"
		}
	},
	"servers": {
		"42d8f991-f2fa-46e5-a9ae-ebcc93846feb": {
			"info_serial": 0,
			"info": {
				"max_clients": 64,
				"max_players": 64,
				"passworded": false,
				"game_type": "TestDDraceNetwork",
				"name": "My DDNet server",
				"map": {
					"name": "dm1",
					"sha256": "0b0c481d77519c32fbe85624ef16ec0fa9991aec7367ad538bd280f28d8c26cf",
					"size": 5805
				},
				"version": "0.6.4, 16.0.3",
				"clients": []
			}
		}
	}
}
```

`--write-dump` outputs a JSON file compatible with `--read-dump-dir`,
this can be used to synchronize servers across different masterservers.
`--read-dump-dir` is also used to ingest servers from the backward
compatibility layer that pings each server for their server info using
the old protocol.

The `kind` field describe that this is `mastersrv` output and not from a
`backcompat`. This is used for prioritizing `mastersrv` information over
`backcompat` information.

The `now` field contains an integer describing the current time in
milliseconds relative an unspecified epoch that is fixed for each JSON
file. This is done instead of using the current time as the epoch for
better compression of non-changing data.

`secrets` is a map from each server address and to a JSON object
containing the last ping time (`ping_time`) in milliseconds relative to
the same epoch as before, and the server secret (`secret`) that is used
to unify server infos from different addresses of the same logical
server.

`servers` is a map from the aforementioned `secret`s to the
corresponding `info_serial` and `info`.

```json
[
	"tw-0.6+udp://127.0.0.1:8303",
	"tw-0.6+udp://[::1]:8303"
]
```

`--write-addresses` outputs a JSON file containing all addresses
corresponding to servers that are registered to HTTP masterservers. It
does not contain the servers that are obtained via backward
compatibility measures.

This file can be used by an old-style masterserver to also list
new-style servers without the game servers having to register there.

An implementation of this can be found at
https://github.com/heinrich5991/teeworlds/tree/mastersrv_6_backcompat
for Teeworlds 0.5/0.6 masterservers and at
https://github.com/heinrich5991/teeworlds/tree/mastersrv_7_backcompat
for Teeworlds 0.7 masterservers.

All these JSON files can be sent over the network in an efficient way
using https://github.com/heinrich5991/twmaster-collect. It establishes a
zstd-compressed TCP connection authenticated by a string token that is
sent in plain-text. It watches the specified file and transmits it every
time it changes. Due to the zstd-compression, the data sent over the
network is similar to the size of a diff.

Implementation
--------------

The masterserver implementation was done in Rust.

The current gameserver register implementation doesn't support more than
one masterserver for registering.
2022-05-20 08:58:32 +02:00
Robert Müller 2ebaa76194 Remove cl_show_console and -c / --console cmdline options 2022-05-19 21:24:19 +02:00
heinrich5991 96f1fbcc70 Make dbg_curl 1 use the normal logging 2022-05-19 21:06:05 +02:00
heinrich5991 177cdfdde9 Fix memleak of multiply chained console commands 2022-05-19 21:06:05 +02:00
Dennis Felsing 4b72f7d95c Minor clang-tidy fix with -DWEBSOCKETS=ON -DUPNP=ON 2022-05-19 18:57:49 +02:00
bors[bot] 8ff87f6e6f
Merge #5001
5001: Ellipsis at end in scoreboard and hud r=heinrich5991 a=def-

Looks nicer to have consistent length in HUD, more clear that something is cut off with the ellipsis.
![screenshot_2022-04-18_12-57-22](https://user-images.githubusercontent.com/2335377/163799128-89788d67-cf3e-4215-b716-7ee0a348f1b2.png)
Thoughts on kill message?
## 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: def <dennis@felsin9.de>
2022-05-19 09:18:11 +00:00
Dennis Felsing d1eba47cf8 Add override in mysql code too (fixes #5139) 2022-05-19 10:35:24 +02:00
def f278399bd1 Ellipsis at end in scoreboard and hud 2022-05-18 23:46:11 +02:00
bors[bot] 609987730c
Merge #5075
5075: Switch to nanoseconds r=def- a=Jupeyy

Modern hardware is too fast, updates sometimes take less than a few microseconds.
It's easier in the long run if we use a bigger range to avoid calculation problems.

possibly f i x e s #5051 (needs testing from bencie for the main bug, but fixes what `@sjrc6` found)

Also took the moment to use more chrono so we can at some point switch to a typesafe time.

Hopefully I didnt miss any value ^^

## 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: Jupeyy <jupjopjap@gmail.com>
Co-authored-by: Dennis Felsing <dennis@felsin9.de>
2022-05-18 16:59:36 +00:00
Jupeyy a7bc8781a9 Put assert for text containers after printing all non empty text containers 2022-05-18 18:25:48 +02:00
Jupeyy 3c597aff95 Switch to nanoseconds 2022-05-18 18:05:41 +02:00
heinrich5991 4fb050ccb7 Use STUN to determine UDP connectivity and show diagnostics
These diagnostics are supposed to guide the user to problem resolution.
They're displayed if no packet is received from the server within one
second of connecting.

No message if we don't have STUN servers.

"Trying to determine UDP connectivity..." if no answer has been received
from the STUN server yet and it hasn't timed out yet.

"UDP seems to be filtered." if the STUN request has timed out.

"UDP and TCP IP addresses seem to be different. Try disabling VPN,
proxy or network accelerators." if the STUN request has returned an IP
address different from the one obtained via HTTP from info2.ddnet.tw.

"No answer from server yet." otherwise, if the STUN request has returned
no interesting data, indicating that it's likely the game server's
fault.
2022-05-18 09:21:31 +02:00
heinrich5991 ec45a7338a Add bare-bones STUN protocol support
Implemented according to RFC 5389.
2022-05-18 09:20:54 +02:00
heinrich5991 407644deef Change IClient::ServerAddress to give the actual server address
Previously, it'd take the string entered by the user, before applying
its transformations. Add `IClient::ConnectAddressString` for the old
behavior.
2022-05-18 09:20:53 +02:00
Dennis Felsing 402cccf8f2 Add override in code behind CONF_DISCORD, disable clang-tidy check 2022-05-18 01:19:35 +02:00
Chairn 583d6e6c01 Mark virtual function as override using a script:
while IFS= read -r line; do file=${line%%:*}; lineno=$(echo $line | cut
-d':' -f2); echo "Treating $file line $lineno"; sed -i -e
"${lineno}s/virtual //" -e "${lineno}s/);\$/) override;/" -e
"${lineno}s/)\$/) override/" -e "${lineno}s/const\$/const override/" -e
"${lineno}s/) {/) override {/" -e "${lineno}s/) const {/) const override
{/" -e "${lineno}s/const;$/const override;/" "$file"; done < a
2022-05-17 23:47:32 +02:00