Commit f25aca2
committed
fix(keys): Refactor to fix continuous use handling
We refactored the "use key handling" to correctly
work with entities that use the continuous use
functionality, like the health station.
Why?
Previous efforts to consolidate "use key handling"
led to a regression where continuous use
did not work as intended anymore when directly
looking at such an entity.
Though, it still worked when using the use key
in the proximity of the entity without directly
looking at it or running into it with the use
key held down, because the server then handled
the continuous use by itself.
This is behavior that the client cannot "block",
so we needed to refactor this code to use the
server-side continuous use handling as its only
source of truth again.
The root cause for this issue was that the client
suppressed further use handling after sending
the net message to the server, which caused the
server-side `KeyPressed` check to return false in
the timer.
Simply changing this would not be sufficient,
as we need still to suppress this handling for the
other use-cases, like weapon pickup or remote use.
Changes:
We mainly refactored the server-side
"use key handling" and client-side key suppression
to fix this issue and simplify the code.
Also, the continous use execution frequency is now
every tick again, instead of every 0.1 seconds.
The actual continuous execution is now handled by
solely by the server again.
The `TTT2PlayerUseEntity` net message code was
refactored to only handle its special cases like
spectator use, remote use and weapon pickup.
We send this message from within the bind handler
on the client if applicable.
This code is still necessary, as these are cases
where the normal use handling is not triggered
by the server due to the items being out of reach
or may not be correctly prioritized e.g.
the wrong weapon being picked up instead of
the intended looked at entity.
The corpse search and old `UseOverride` handling
was moved back to the original TTT way of handling
it, by utilizing the `KeyRelease` hook.
We did not modify the code here and merely copied
over the original code again.
Removed `ENT.CanUseKey` from placeable entities
as it is not needed anymore with the new handling.
Removed now obsolete `IsSpecialUsableEntity` and
`IsUsableEntity` functions.
Refactored `ClientUse` function to be client only
and always block further use handling.
This function is generally useful for client-side
only use key handling, e.g., for UI interactions.
E.g. the C4 uses this to open the C4 menu
when the use key is pressed while looking at it.1 parent 5d9a353 commit f25aca2
File tree
9 files changed
+122
-199
lines changed- gamemodes/terrortown
- entities/entities
- ttt_c4
- gamemode
- client
- server
9 files changed
+122
-199
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
23 | 29 | | |
24 | 30 | | |
25 | 31 | | |
| |||
Lines changed: 0 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
| |||
55 | 53 | | |
56 | 54 | | |
57 | 55 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | 56 | | |
82 | 57 | | |
83 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
721 | 721 | | |
722 | 722 | | |
723 | 723 | | |
724 | | - | |
725 | | - | |
726 | | - | |
| 724 | + | |
727 | 725 | | |
728 | 726 | | |
729 | 727 | | |
| |||
733 | 731 | | |
734 | 732 | | |
735 | 733 | | |
736 | | - | |
737 | | - | |
738 | 734 | | |
739 | 735 | | |
740 | 736 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | 14 | | |
17 | 15 | | |
18 | 16 | | |
| |||
Lines changed: 0 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | 201 | | |
215 | 202 | | |
216 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
67 | 79 | | |
68 | 80 | | |
69 | 81 | | |
| |||
76 | 88 | | |
77 | 89 | | |
78 | 90 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
| 91 | + | |
97 | 92 | | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 93 | + | |
102 | 94 | | |
103 | 95 | | |
104 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
105 | 112 | | |
106 | 113 | | |
107 | | - | |
108 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
109 | 124 | | |
110 | 125 | | |
111 | 126 | | |
112 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
113 | 131 | | |
114 | | - | |
115 | | - | |
| 132 | + | |
| 133 | + | |
116 | 134 | | |
117 | 135 | | |
| 136 | + | |
118 | 137 | | |
119 | 138 | | |
| 139 | + | |
| 140 | + | |
120 | 141 | | |
121 | 142 | | |
122 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | 5 | | |
14 | 6 | | |
15 | 7 | | |
| |||
78 | 70 | | |
79 | 71 | | |
80 | 72 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | 73 | | |
114 | 74 | | |
115 | 75 | | |
| |||
0 commit comments