Commit graph

616 commits

Author SHA1 Message Date
heinrich5991 49bc150afd Refactor: Distinguish between two concepts previously called "Dummy"
On the one hand variables called "Dummy" would tell us whether the
current action refers to the currently inactive tee ("dummy"). On the
other hand, these variables could tell us whether the current action
refers to the main connection to the server, or the secondary one. The
latter use case is now renamed to "Client", with the choices
`CLIENT_MAIN`, `CLIENT_DUMMY` (and `CLIENT_CONTACT`).

Perhaps better names could be found, especially since `Client` also
refers to the engine client class in the game code.

I tried to not fix bugs unless it would complicate the code.
2022-01-21 01:54:14 +01:00
ChillerDragon e4be3f5241 Shutdown components 2022-01-20 12:20:29 +01:00
bors[bot] 48e53470cd
Merge #4581 #4590 #4593 #4607
4581: Adjustable prediction margin r=def- a=trml

This adds an option to adjust how early the client sends an input for a given tick. In vanilla this value is hardcoded to 10 milliseconds before the next tick, which is good for low-latency gameplay and/or when you have a stable connection, but sometimes it could perhaps be useful to increase the value, to either test something with a high ping (without having to joing a high-ping server or use on a 3rd party program like tc/netem), or for counteracting the effect of jitter and jumping ping.

The last part comes at a tradeoff for higher ping though, and it also doesn't handle lag caused by packet loss, but it I have found it useful in some situations when playing race/solo/dummy with a bad connection. Since it's a bit experimental I only added it as an f1 option and not stored between sessions, and also added a gameinfo flag to only support it on servers that implement #1441.

Edit: Also attempted to cleanup variable names for tick calculations in client.cpp slightly.

## Checklist

- [x] Tested the change ingame
- [ ] 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)


4590: Remove extra projectiles r=def- a=trml

Aligns the code with vanilla, and cleans up things a bit
(same as [329e6261f3](url))

These were used to show projectiles a tick (or fraction of a tick) earlier than they otherwise would (and they were also sent without extrainfo since they didn't matter for prediction), so removing them would perhaps not make a noticeable difference. (and perhaps also less of a difference now since weapon input isn't applied before the start of a tick anymore).

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


4593: Fix compiler warning with new ffmpeg version (currently built from git) r=heinrich5991 a=def-

```
src/engine/client/video.cpp:102:32: error: assigning to 'AVOutputFormat *' from 'const struct AVOutputFormat *' discards qualifiers
        m_pFormat = m_pFormatContext->oformat;
                    ~~~~~~~~~~~~~~~~~~^~~~~~~
src/engine/client/video.cpp:571:13: error: assigning to 'AVCodec *' from 'const AVCodec *' discards qualifiers
        *ppCodec = avcodec_find_encoder(CodecId);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
<!-- 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)


4607: Adopt upstream input (especially double click) handling, refactoring r=def- a=Robyt3

This adopts the 0.7 way of handling double clicks, by checking `Event.button.clicks` of the `SDL_Event`. The double click is stored as a flag which is cleared when the `MouseDoubleClick()` function is called (d215c73206 and 7977b46d36).

This reverts 72a6e20, as this hack is no longer required (closes #1745). Double clicking a friend in the friend list still works (#444) with both `gfx_asyncrender_old 0` and `1`.

Refactorings and minor fixes synchronizing with upstream:

- Only copy SDL keystate of _keyboard_ keys and mem_zero the rest to ensure out of bounds SDL keys don't trigger mouse keys.
- Rename variables and use SDL constants.
- Reduce unnecessary indentation.

## Checklist

- [X] Tested the change ingame
- [ ] 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
- [X] 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: trml <trml@users.noreply.github.com>
Co-authored-by: Dennis Felsing <dennis@felsin9.de>
Co-authored-by: Robert Müller <robert.mueller@uni-siegen.de>
Co-authored-by: oy <Tom_Adams@web.de>
2022-01-17 23:36:14 +00:00
trml 30093e44c5 Remove extra projectiles 2022-01-13 00:46:11 +01:00
Wohoo 2017464282 Livefreeze implementation with CHARACTERFLAG_NO_MOVEMENTS flag.
Freeze and Unfreeze tiles added to switch layer too.
2022-01-07 16:53:40 +01:00
def 2963c30755 Fix run_on_join being run on normal player again (fixes #4494) 2021-12-20 23:19:43 +01:00
Robert Müller a61c45550d rename Init method and move implementation 2021-12-03 20:26:27 +01:00
def 13044e093c Fix some more undefined behavior with super (fixes #4412) 2021-11-29 17:12:50 +01:00
bors[bot] 0443a3ef65
Merge #4341
4341: Make laser doors show correctly when spectating other players r=def- a=trml

Makes the server send the switch state of other players while spectating others, otherwise the switch state of your own player (including when spectating in freeview).

Also changed the client a little to both handle situations where the server only sends one SWITCHSTATE netobject (then it just uses that team) or all (then it chooses the team that maintains the above behavior). I'm not sure if the latter would really be useful (but since the netobject contains a team it would be possible to do so).

## 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>
2021-11-09 08:40:52 +00:00
trml 57387b5965 Fix switch state when spectating other players 2021-11-08 23:51:28 +01:00
trml 8db53f2a03 Fix sort comparator 2021-11-07 11:00:48 +01:00
Jupeyy d4dd3e6969 Use delete[] for m_pSwitchers 2021-11-06 18:12:07 +01:00
Jupeyy 0d17665137 Revert "Add new mouse state"
This reverts commit e4cb348db2.
2021-10-23 13:48:21 +02:00
trml 85a99d174d Preprocess snap items to make getting EntityEx faster 2021-10-22 00:40:17 +02:00
bors[bot] fce6776c38
Merge #4095 #4176
4095: [Concept] Add new mouse state (ingame mouse) r=def- a=Jupeyy

This would remove ui_mousesense and use the desktop cursor position instead for menus and editor
This would also fix the editor cursor to not move faster than in menus.
That's probably how most games would handle menus, instead of using relative mouse mode
And this would work for touch inputs.

The normal gameplay relative mouse is ofc NOT affected by any kind

Opinions?

Missing:
- [x] m_MouseSlow in menus
- [x] Make desktop cursor invisible
- [x] Some components that use ui mouse
- [x] Remove focus in/out relative mouse state changes, fixed with next SDL version


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


4176: Entity switch prediction r=def- a=trml

Adds the prediction for pickups and projectiles (based on #4108)

For blinking entities (deactivated by switch) I also used the extended info to make the blinking effect happen client-side. So instead of the server omitting the projectile/pickup from the snapshot every N ticks (which prevented some things like explosive bullets from being predicted correctly), the server will keep sending the item and let the client decide how to show it.

Added doors as well, and changed how they are sent (and rendered) in a similar way (by always sending both endpoints and using a fixed m_StartTick instead of updating it every tick).

An idea was that this could potentially reduce network traffic a bit (in addition to helping with prediction), especially for stationary items that are rarely/never have to be updated (doors and pickups).

This makes CItems::OnRender a bit more complex, and it could perhaps be cleaned up some way (either using something like CProjectileData, or by moving more of the logic into RenderProjectile/Laser/Pickup).

Some things missing:
- Add more entities (draggers, light, gun)
- Entities are not correctly shown when in super (e.g. doors are shown as closed, and should be open)

## 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
- [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: Jupeyy <jupjopjap@gmail.com>
Co-authored-by: trml <trml@users.noreply.github.com>
2021-10-16 16:38:18 +00:00
trml 71e5b7ed3a Fix switch state for super, cleanup door snapping, add dragger/gun/light 2021-10-14 22:59:39 +02:00
Jupeyy e4cb348db2 Add new mouse state 2021-10-07 16:48:25 +02:00
bors[bot] 43e69905bc
Merge #4157
4157: invalidate texture when unloading a texture. r=heinrich5991 a=ChillerDragon

Closes https://github.com/teeworlds/teeworlds/issues/1450

(cherry picked from commit 23a1b80f60)

<!-- 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: oy <Tom_Adams@web.de>
Co-authored-by: ChillerDragon <ChillerDragon@gmail.com>
2021-10-06 15:16:00 +00:00
bors[bot] 560d2ad1a3
Merge #4166
4166: Update default tune zone, when no local character is alive and tune zones don't exist r=heinrich5991 a=Jupeyy

fixes #4140

## 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>
2021-09-27 20:55:07 +00:00
ChillerDragon a5ae3bf869 Fix nullptr when using Config() in components 2021-09-27 21:37:20 +02:00
trml 8448f9ef04 Predict switch projectiles and pickups, make blinking effect client-side 2021-09-19 14:14:00 +02:00
Jupeyy 5dee9a3833 Always update default tune zone 2021-09-15 23:27:16 +02:00
bors[bot] f2dd9a0ab3
Merge #4167
4167: Update world config even if the local character is dead r=Jupeyy a=heinrich5991

Interesting for weapons etc.

<!-- 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: heinrich5991 <heinrich5991@gmail.com>
2021-09-15 18:33:43 +00:00
heinrich5991 b7fe9b112c Clear game info on connect
Previously, the old game info persevered into the next server.
2021-09-15 16:22:50 +02:00
heinrich5991 ca2d85107e Update world config even if the local character is dead
Interesting for weapons etc.
2021-09-15 16:05:30 +02:00
ChillerDragon de4e1ea644 Merge UnloadTexture with UnloadTextureNew 2021-09-15 13:19:54 +02:00
Jupeyy 9deac14667 Use gametick as int for emoticon calculation, add the fraction seperately 2021-09-15 01:06:30 +02:00
heinrich5991 91b60e6981 Make emoticons smoother 2021-09-13 16:26:48 +02:00
heinrich5991 43379503fc
Merge pull request #4114 from fokkonaut/pr-switch
Send switch states only for own team
2021-09-13 13:40:07 +02:00
bors[bot] 89e3d694b9
Merge #4152
4152: Make use of IO_MAX_PATH_LENGTH r=heinrich5991 a=ChillerDragon

Inspired by
0a7d0fee7c

<!-- 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: ChillerDragon <ChillerDragon@gmail.com>
2021-09-13 10:31:26 +00:00
ChillerDragon 3eb3dcd48b Make use of IO_MAX_PATH_LENGTH
Inspired by
0a7d0fee7c
2021-09-13 12:14:50 +02:00
fokkonaut 7aa4652715 Always send correct zoom dimensions 2021-09-11 01:08:32 +02:00
bors[bot] 73e71951b9
Merge #3960 #4006 #4103
3960: Display colors for strong / weak hook states r=Jupeyy a=BloodWod-513

<!-- What is the motivation for the changes of this pull request -->
Off by default, cl_nameplates_strongweak 1 to enable;
Also shown in debug mode (ctrl-shift-d);
You can change the colors in the HUD.

![hkUp2p8chGA](https://user-images.githubusercontent.com/33897884/126379859-1dc29c09-57fb-4d4b-9810-a4f0b09599a0.jpg)
![WCZx_ZR8fQ0](https://user-images.githubusercontent.com/33897884/126379863-3f25295a-ca36-4184-a0ed-1946b40ed967.jpg)
## Checklist
- [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
- [x] 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)


4006: Add /team -1 r=Jupeyy a=gerdoe-jr

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

## Checklist
In addition for #4005.

Now /team -1 forces player to first empty team.

- [x] Tested the change ingame
- [ ] 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
- [x] 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)


4103: Fix swap resets switches. r=Jupeyy a=edg-l

Fixes #3806

<!-- 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
- [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: BloodWod <dayn_2013@mail.ru>
Co-authored-by: Ilya <33897884+BloodWod-513@users.noreply.github.com>
Co-authored-by: gerdoe-jr <gerdoexx@gmail.com>
Co-authored-by: Edgar Luque <git@edgarluque.com>
2021-08-24 12:23:12 +00:00
fokkonaut 69fe35f288 Send switch states per team and cleanup 2021-08-23 23:26:36 +02:00
trml 08ef63a64c Add prediction for switch tiles 2021-08-19 01:11:38 +02:00
BloodWod 4dd37f63a6 refactoring 2021-08-17 21:33:14 +05:00
Edgar 1dd91feec6
send switch state to the client 2021-08-16 11:15:23 +02:00
Learath c1446c5ce4 Populate jetpack field properly 2021-08-08 13:36:25 +03:00
BloodWod f66abb79bf Added color for strong and weak states 2021-07-20 22:39:44 +05:00
Jupeyy 7e55b64556 Remove global CGameClient instance 2021-07-12 12:53:08 +02:00
Jupeyy 26c5332dc6 Remove components pointers 2021-07-12 12:14:02 +02:00
Jupeyy 8451775821 Make components member of CGameClient 2021-07-12 12:07:31 +02:00
Jupeyy a663799188 uint64 -> uint64_t, int64 -> int64_t 2021-06-24 17:19:17 +02:00
Freddie Wang 500ba7609f Respect tunezone for characters 2021-05-13 00:57:50 +08:00
Freddie Wang 223f21530c Get rid of redundant tuning data in CGameWorld 2021-05-01 10:34:20 +08:00
bors[bot] c82970cf09
Merge #3788
3788: Allow unpredicted TuneZone settings for projectiles and lasers r=def- a=TsFreddie

Video demo: https://cdn.discordapp.com/attachments/293493549758939136/834971531464671252/2021-04-23_09-57-35.mp4
(notice the speed difference between player's shotgun bullets and the bouncing ones)

Video demo2: https://cdn.discordapp.com/attachments/293493549758939136/834990657147764736/demotopleftisnew.mp4
(Right: before, Left: after)

Since TuneZones are known (baked into the map), and entities' position received are known. We have a pretty good reason, if the server is believed to make use of it (GAMEINFOFLAG_PREDICT_DDRACE_TILES), to make entities always reference TuneZone settings, even if they are not predicted. 

Introduced a new worldconfig, `m_UseTuneZones`, that ignores antiping settings and apply TuneZone where applicable if the server is believed to support TuneZone.

When antiping is off, predictedworld is still inactive and only the rendering are affected, making them still **unpredicted** but now with correct intra-tick interpolations.


## Checklist

- [x] Tested the change ingame
- [x] Provided screenshots if it is a visual change
- [x] Tested in combination with possibly related configuration options (with different antiping settings and ping)
- [ ] 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 (client-side only)
- [ ] 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: Freddie Wang <tsfreddiewang@gmail.com>
2021-04-25 09:38:12 +00:00
Freddie Wang b1051d2398 always use inferred tuning instead of current one 2021-04-23 13:53:54 +08:00
Freddie Wang f18a47ae30 set m_usetunezones before local char spawns 2021-04-23 13:17:41 +08:00
Freddie Wang d2faabe913 force tunezone 2021-04-23 11:01:38 +08:00
Freddie Wang bef5dee897 Fix dummy's airjump trigger 2021-04-22 20:58:30 +08:00