File tree Expand file tree Collapse file tree 5 files changed +23
-5
lines changed
addons/source-python/packages/source-python Expand file tree Collapse file tree 5 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ def _precache(self):
104
104
"""Precache the path."""
105
105
self ._precache_method (self ._path , self ._preload )
106
106
107
- def _server_spawn (self , game_event ):
107
+ def _server_spawn (self , ** kwargs ):
108
108
"""Precache the object on map change."""
109
109
self ._precache ()
110
110
Original file line number Diff line number Diff line change 17
17
from events .manager import game_event_manager
18
18
# Hooks
19
19
from hooks .exceptions import except_hooks
20
+ # KeyValues
21
+ from keyvalues import KeyValues
20
22
# Memory
23
+ from memory import get_object_pointer
21
24
from memory import get_virtual_function
22
25
from memory import make_object
23
26
from memory .hooks import PreHook
@@ -176,14 +179,19 @@ def _pre_game_event(args):
176
179
# Create a variable to know what to do after all pre-events are called
177
180
event_action = EventAction .CONTINUE
178
181
182
+ # Convert the GameEvent object into a dictionary
183
+ # TODO: use data or some other means to get the offset
184
+ kwargs = make_object (
185
+ KeyValues , get_object_pointer (game_event ).get_pointer (8 )).as_dict ()
186
+
179
187
# Loop through all callbacks in the pre-event's list
180
188
for callback in pre_event_manager [event_name ]:
181
189
182
190
# Use try/except in case an error occurs during in the callback
183
191
try :
184
192
185
193
# Call the callback and get its return value
186
- current_action = callback (game_event )
194
+ current_action = callback (** kwargs )
187
195
188
196
# Is the return value invalid?
189
197
if (current_action is not None and
Original file line number Diff line number Diff line change 8
8
# Source.Python Imports
9
9
# Hooks
10
10
from hooks .exceptions import except_hooks
11
+ # KeyValues
12
+ from keyvalues import KeyValues
11
13
# Loggers
12
14
from loggers import _sp_logger
15
+ # Memory
16
+ from memory import get_object_pointer
17
+ from memory import make_object
13
18
14
19
15
20
# =============================================================================
@@ -82,14 +87,19 @@ def remove(self, callback):
82
87
83
88
def fire_game_event (self , game_event ):
84
89
"""Loop through all callbacks for an event and calls them."""
90
+ # Convert the GameEvent object into a dictionary
91
+ # TODO: use data or some other means to get the offset
92
+ kwargs = make_object (
93
+ KeyValues , get_object_pointer (game_event ).get_pointer (8 )).as_dict ()
94
+
85
95
# Loop through each callback in the event's list
86
96
for callback in self :
87
97
88
98
# Try to call the callback
89
99
try :
90
100
91
101
# Call the callback
92
- callback (game_event )
102
+ callback (** kwargs )
93
103
94
104
# Was an error encountered?
95
105
except :
Original file line number Diff line number Diff line change @@ -150,7 +150,7 @@ def cursor(self):
150
150
"""Return the cursor instance."""
151
151
return self ._cursor
152
152
153
- def server_spawn (self , game_event ):
153
+ def server_spawn (self , ** kwargs ):
154
154
"""Store the dictionary to the database on map change."""
155
155
self .connection .commit ()
156
156
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ def _add_to_download_table(self, item):
82
82
# Add the given file to the downloadables table.
83
83
self .download_table .add_string (item , item )
84
84
85
- def server_spawn (self , game_event ):
85
+ def server_spawn (self , ** kwargs ):
86
86
"""Add all items stored as downloadables to the stringtable."""
87
87
# Refresh the downloadables table instance
88
88
self ._refresh_table_instance ()
You can’t perform that action at this time.
0 commit comments