6
6
# >> IMPORTS
7
7
# =============================================================================
8
8
# Source.Python Imports
9
+ # Core
10
+ from core import SOURCE_ENGINE_BRANCH
9
11
# Entities
10
12
from entities .hooks import EntityPreHook
11
13
from entities .hooks import EntityCondition
17
19
from players .entity import Player
18
20
# Memory
19
21
from memory import make_object
22
+ from memory import get_object_pointer
23
+ from memory import get_size
24
+
25
+
26
+ # =============================================================================
27
+ # >> CONSTANTS
28
+ # =============================================================================
29
+ USER_CMD_SIZE = get_size (UserCmd )
20
30
21
31
22
32
# =============================================================================
@@ -29,19 +39,29 @@ def _pre_player_run_command(args):
29
39
return
30
40
31
41
player = make_object (Player , args [0 ])
32
- user_cmd = make_object (UserCmd , args [1 ])
42
+
43
+ # https://github.com/Source-Python-Dev-Team/Source.Python/issues/149
44
+ use_rtti_fix = SOURCE_ENGINE_BRANCH == 'tf2' and player .is_fake_client ()
45
+ if use_rtti_fix :
46
+ user_cmd = UserCmd ()
47
+ user_cmd_ptr = get_object_pointer (user_cmd )
48
+ args [1 ].copy (user_cmd_ptr , USER_CMD_SIZE )
49
+ else :
50
+ user_cmd = make_object (UserCmd , args [1 ])
33
51
34
52
if on_player_run_command_listener_manager :
35
53
on_player_run_command_listener_manager .notify (player , user_cmd )
36
54
37
55
if on_button_state_changed_listener_manager :
38
56
_handle_button_state_changed (player , player .buttons , user_cmd .buttons )
39
57
58
+ if use_rtti_fix :
59
+ user_cmd_ptr .copy (args [1 ], USER_CMD_SIZE )
60
+
40
61
41
62
def _handle_button_state_changed (player , old_buttons , new_buttons ):
42
63
if old_buttons == new_buttons :
43
64
return
44
65
45
66
on_button_state_changed_listener_manager .notify (
46
67
player , old_buttons , new_buttons )
47
-
0 commit comments