2828from listeners import ListenerManager
2929# Memory
3030from memory import make_object
31+ from memory import get_object_pointer
32+ from memory import get_size
3133from memory import get_virtual_function
3234from memory .hooks import PreHook
3335from memory .hooks import PostHook
@@ -171,9 +173,16 @@ def _pre_send_user_message(args):
171173 if not user_message_hooks and not protobuf_user_message_hooks :
172174 return
173175
174- # Replace original recipients filter
175- tmp_recipients = make_object (BaseRecipientFilter , args [1 ])
176- _recipients .update (* tuple (tmp_recipients ), clear = True )
176+ try :
177+ # Replace original recipients filter
178+ tmp_recipients = make_object (BaseRecipientFilter , args [1 ])
179+ _recipients .update (* tuple (tmp_recipients ), clear = True )
180+ except RuntimeError :
181+ # Patch for issue #314
182+ tmp_recipients = RecipientFilter ()
183+ (args [1 ] + 4 ).copy (get_object_pointer (tmp_recipients ) + 4 ,
184+ get_size (RecipientFilter ) - 4 )
185+ _recipients .update (* tuple (tmp_recipients ), clear = True )
177186 args [1 ] = _recipients
178187
179188 buffer = make_object (ProtobufMessage , args [3 ])
@@ -200,9 +209,16 @@ def _pre_send_user_message(args):
200209else :
201210 @PreHook (get_virtual_function (engine_server , 'UserMessageBegin' ))
202211 def _pre_user_message_begin (args ):
203- # Replace original recipients filter
204- tmp_recipients = make_object (BaseRecipientFilter , args [1 ])
205- _recipients .update (* tuple (tmp_recipients ), clear = True )
212+ try :
213+ # Replace original recipients filter
214+ tmp_recipients = make_object (BaseRecipientFilter , args [1 ])
215+ _recipients .update (* tuple (tmp_recipients ), clear = True )
216+ except RuntimeError :
217+ # Patch for issue #314
218+ tmp_recipients = RecipientFilter ()
219+ (args [1 ] + 4 ).copy (get_object_pointer (tmp_recipients ) + 4 ,
220+ get_size (RecipientFilter ) - 4 )
221+ _recipients .update (* tuple (tmp_recipients ), clear = True )
206222 args [1 ] = _recipients
207223
208224 @PostHook (get_virtual_function (engine_server , 'UserMessageBegin' ))
@@ -260,4 +276,4 @@ def _pre_message_end(args):
260276 # Update buffer if data has been changed
261277 if data .has_been_changed ():
262278 buffer_write .seek_to_bit (0 )
263- impl .write (buffer_write , data )
279+ impl .write (buffer_write , data )
0 commit comments