EntityPreHook "touch" crashing

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

EntityPreHook "touch" crashing

Postby Kami » Sun Jan 15, 2017 2:10 pm

So I'm using this code on a Linux hl2dm dedicated server:

Syntax: Select all

@EntityPreHook(EntityCondition.equals_entity_classname('prop_physics'), 'touch')
def pre_start_touch(stack):
entity = make_object(Entity, stack[0])
other = make_object(Entity, stack[1])


Everything is fine until I dare to touch any func_door_rotating. Touching one will lead to a crash. Its not an usual crash, but rather the server does not respond for some time and then suggests that there must have been an infinite loop and restarts the whole thing.

Any idea what may cause this? Thanks :)
Last edited by Ayuto on Sun Jan 15, 2017 3:52 pm, edited 1 time in total.
Reason: code -> python
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: EntityPreHook "touch" crashing

Postby L'In20Cible » Sun Jan 15, 2017 3:48 pm

First step would be to debug your code to know exactly which line is crashing.

Syntax: Select all

@EntityPreHook(EntityCondition.equals_entity_classname('prop_physics'), 'touch')
def pre_start_touch(stack):
print(1)
entity = make_object(Entity, stack[0])
print(2)
other = make_object(Entity, stack[1])
print(3)
Also, you can use [python] instead of [code].
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: EntityPreHook "touch" crashing

Postby Kami » Sun Jan 15, 2017 4:11 pm

It goes all the way to the 3, which seems strange, as that should be the player entity right?

Edit: thinking about it, that does not make any sense. wouldn't that mean that it does not crash there at all?

Edit2: Okay, so I tried instead of actually getting an entity to just print a debug message:

Syntax: Select all

@EntityPreHook(EntityCondition.equals_entity_classname('prop_physics'), 'touch')
def pre_start_touch(stack):
core.console_message('\ntest\n')


same result. to rule anything else out: I use the newest SP and have nothing else loaded than this code. And without it beeing loaded It does not crash.

did I do something wrong with EntityCondition wrong maybe?
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: EntityPreHook "touch" crashing

Postby satoon101 » Sun Jan 15, 2017 4:45 pm

Not necessarily (in regards to your first edit). So, a couple questions. Is that the only thing in your pre-hook? Like, is "print(3)" the very last thing in that function? Also, is there more to the plugin than this, or have you tested with only this function? If you haven't, please do that to confirm that this small snippet can replicate the issue on its own (make sure no other plugins are running, as well).

Lastly, I'm not sure what you are attempting to do, but I wonder if start_touch could work better in your situation.
Image
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: EntityPreHook "touch" crashing

Postby Kami » Sun Jan 15, 2017 4:48 pm

I edited my last post again but for clarity: Its only this small snippet that is running and causing the issues!

The end goal would be to touch an entity and destroy it after that (picking up a crowbar you threw away before). But this lines alone do cause the crash.

Edit: "start_touch" does result in the same crash

This is the error I get after the server does not respond for 30 seconds or so:

Code: Select all

WatchDog! Server took too long to process (probably infinite loop).
Host_Error: WatchdogHandler called - server exiting.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: EntityPreHook "touch" crashing

Postby Ayuto » Sun Jan 15, 2017 6:06 pm

I experienced that issue a couple of weeks ago as well. However, right now I'm unable to reproduce it. I will try again tomorrow.
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: EntityPreHook "touch" crashing

Postby Kami » Sun Jan 15, 2017 7:08 pm

I think I was able to narrow down what part was crashing!

Using this code did not result in any crash:

Syntax: Select all

@EntityPreHook(EntityCondition.is_player, 'touch')
def pre_start_touch(stack):
entity = make_object(Entity, stack[0])
other = make_object(Entity, stack[1])
core.console_message("\n%s and %s\n" % (entity.classname,other.classname))


So I guess the

Code: Select all

equals_entity_classname('prop_physics')
part was responsible for the crash?

Edit: Maybe I was wrong, still experiencing the same crashes. I will report back when I know whats up
User avatar
D3CEPTION
Senior Member
Posts: 129
Joined: Tue Jan 26, 2016 1:24 pm
Location: Switzerland

Re: EntityPreHook "touch" crashing

Postby D3CEPTION » Mon Jan 16, 2017 3:51 am

have you tried not hooking into "func_door_rotating" to see if it still crashes on touch?
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: EntityPreHook "touch" crashing

Postby Kami » Mon Jan 16, 2017 6:35 pm

How would I achieve to exlude func_door_rotating from beeing hooked? Sorry, I'm still pretty noobish when it comes to the entity Stuff :D
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: EntityPreHook "touch" crashing

Postby Ayuto » Mon Jan 16, 2017 8:39 pm

You can't really exclude it, because the CRotDoor does not implement its own Touch method. Thus, it's falling back to the CBaseEntity implementation and there are other prop_physics entities, which use the CBaseEntity implementation as well.

Unfortunately, I didn't have time today to do some tests, but I hope I will be able to do them at the weekend. This could be an issue with DynamicHooks caused by the ugly implementation needed for post hooks (I always wanted to improve that^^).

What about using OnEntityOutput instead and listening to OnStartTouch?
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: EntityPreHook "touch" crashing

Postby L'In20Cible » Mon Jan 16, 2017 10:11 pm

Ayuto wrote:What about using OnEntityOutput instead and listening to OnStartTouch?

It won't have the same behavior, though. Touch is called everytime the VPhysics is detecting a collision between two entities that have the correct solid type (every frame, but maybe different thread) while OnStartTouch (or simply start_touch from our data) is called only the first time and won't be called again till StopTouch is detected. Depending what he is trying to do, it may not be viable. But... what is he trying to do is the main question. I would be curious to know if the code crash when False is returned to stop the original function from being called. However, I can see in the SDK that CBaseDoor have some "chained touching" implementation that seem to call the Touch function after calling SetChaining(true) so calling SetChaining(false) might be needed to avoid a loop-hole.

Anyways, what game? What OS? What map? Coords of the entity? Complete code? Would be easier for everyone that try to debug.
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: EntityPreHook "touch" crashing

Postby Kami » Tue Jan 17, 2017 4:47 am

No problem!

Game: HL2DM
OS: Ubuntu 14.04 LTS
Map: dm_erde
Coords (of one of the crashing func_door_rotating): Vector(-234.5, 1032.5, 312.1600036621094)

Smallest snippet that is able to reproduce the crash:

Syntax: Select all

@EntityPreHook(EntityCondition.equals_entity_classname('prop_physics'), 'touch')
def pre_start_touch(stack):
core.console_message('\ntest\n')
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: EntityPreHook "touch" crashing

Postby L'In20Cible » Tue Jan 17, 2017 4:59 am

Awesome, ty!

Fun fact: translate "merde" from french to english, lol.

EDIT: Do you have a download link for this map? I'm not finding it anywhere.
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: EntityPreHook "touch" crashing

Postby Kami » Tue Jan 17, 2017 5:06 am

Actually Erde means Earth in german! But I like the merde version better ;D

I uploaded it for you :

http://www.filedropper.com/processing/filedownload.php?id=dmerde
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: EntityPreHook "touch" crashing

Postby L'In20Cible » Tue Jan 17, 2017 5:09 am

Kami wrote:Actually Erde means Earth in german! But I like the merde version better ;D

Makes more sense now. :tongue:


Ty!
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: EntityPreHook "touch" crashing

Postby L'In20Cible » Tue Jan 17, 2017 5:26 am

This site seems to have some trouble. It adds the following header to the archive:

Code: Select all

<br />
<b>Deprecated</b>:  mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in <b>/home/filedrop/public_html/files/db.php</b> on line <b>7</b><br />


So if anyone is trying to download it, remove that header prior to extract the map.

EDIT: However, the map itself seems corrupted or incomplete. Console is yielding the following and the server won't startup and freeze upon loading it.

Code: Select all

material "maps/dm_erde_sauv/tile/tilewall009d_1331_-376_20" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_1331_-376_20" not found.
material "maps/dm_erde_sauv/glass/glasswindowbreak070a_733_-656_64" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-876_-94_190" not found.
material "maps/dm_erde_sauv/glass/glasswindowbreak070a_725_-322_375" not found.
material "maps/dm_erde_sauv/concrete/concretefloor013c_-840_-397_147" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-840_-397_147" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-665_-385_180" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_-845_-383_16" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-1291_-670_321" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-311_722_325" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_-311_722_325" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_442_-1441_128" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_244_-289_-23" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_86_-114_50" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_251_-484_-23" not found.
material "maps/dm_erde_sauv/tile/tilewall006a_1331_-376_20" not found.
material "maps/dm_erde_sauv/nature/gravelfloor002b_251_-484_-23" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-257_-124_50" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-848_352_336" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-258_-641_50" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_443_-130_50" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_570_402_371" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-1307_5_313" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-1293_220_313" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-1202_-77_313" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-1304_-520_318" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_160_392_224" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-655_642_325" not found.
material "maps/dm_erde_sauv/tile/tilewall006a_725_-322_375" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_90_-647_50" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-1503_-325_306" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_882_-50_371" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_160_392_224" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_248_-118_156" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-83_-183_50" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_386_-612_383" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_-257_-124_50" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-886_-683_190" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_400_-1027_272" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_400_-1027_272" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_821_-618_40" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_725_-322_375" not found.
material "maps/dm_erde_sauv/concrete/concretefloor013c_-665_-385_180" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_-258_-641_50" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_573_89_371" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_730_-59_375" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_877_163_371" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_86_-114_50" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_-83_-183_50" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_160_392_224" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_244_-289_-23" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_-104_-120_156" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_443_-130_50" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_269_-181_50" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_248_-118_156" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_90_-647_50" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_400_-1027_272" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_-89_-631_156" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_251_-484_-23" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_443_-642_50" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_265_-624_156" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_1293_-284_-23" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_725_-262_375" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_879_-256_371" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_733_-656_64" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_593_-393_371" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_833_-599_377" not found.
material "maps/dm_erde_sauv/tile/tilefloor009a_-89_-631_156" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-89_-631_156" not found.
material "maps/dm_erde_sauv/tile/tilefloor009a_265_-624_156" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_265_-624_156" not found.
material "maps/dm_erde_sauv/tile/tilefloor009a_639_-879_50" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_443_-642_50" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_639_-879_50" not found.
material "maps/dm_erde_sauv/tile/tilefloor009a_269_-181_50" not found.
material "maps/dm_erde_sauv/tile/tilefloor009a_160_392_224" not found.
material "maps/dm_erde_sauv/tile/tilefloor009a_-83_-183_50" not found.
material "maps/dm_erde_sauv/tile/tilefloor009a_-665_-385_180" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-104_-120_156" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-30_-439_97" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_-30_-439_97" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_733_-656_64" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_593_-393_371" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_725_-322_375" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_894_-609_40" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_894_-609_40" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_1338_-476_-23" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_-665_-385_180" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_160_392_224" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_-1304_-520_318" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_-1503_-325_306" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_646_444_571" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-137_916_304" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_138_929_320" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_138_929_320" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_138_990_320" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-1061_495_313" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-102_1188_304" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_646_444_571" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_1059_-88_40" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_725_-262_375" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_1059_-88_40" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_879_-256_371" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_1293_-284_-23" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_1353_-62_498" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_-137_916_304" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_138_929_320" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_138_929_320" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_-137_916_304" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_604_936_562" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_138_1048_320" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_138_1048_320" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_370_1229_304" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_601_709_343" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_833_-599_377" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_233_665_276" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_471_984_310" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_807_1171_310" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_821_942_310" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_812_769_310" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_1154_177_482" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_836_1358_310" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_604_936_562" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_370_1229_304" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_-102_1188_304" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_599_-1210_103" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_575_-1441_123" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_836_1358_310" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_138_1048_320" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_899_601_808" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_604_936_562" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_386_-612_383" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_639_-879_50" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_656_-609_377" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_847_-426_620" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_656_-609_377" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_847_-426_620" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_835_515_371" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_835_515_371" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_877_163_371" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_570_402_371" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_573_89_371" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_882_-50_371" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_730_-59_375" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_1157_-264_482" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_849_-334_844" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_849_241_834" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_1433_-266_500" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_1430_175_500" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_822_-86_1012" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_646_444_571" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_849_-334_844" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_1157_-264_482" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_830_131_1012" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_835_-223_1012" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_-1202_-77_313" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_-876_-94_190" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_386_-612_383" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_599_-1210_103" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_575_-1441_123" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_1433_-266_500" not found.
material "maps/dm_erde_sauv/metal/metalwall045a_-102_1188_304" not found.
material "maps/dm_erde_sauv/metal/metalwall045a_138_1048_320" not found.
material "maps/dm_erde_sauv/metal/metalwall045a_604_936_562" not found.
material "maps/dm_erde_sauv/metal/metalwall045a_899_601_808" not found.
material "maps/dm_erde_sauv/metal/metalwall045a_370_1229_304" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-845_-383_16" not found.
material "maps/dm_erde_sauv/concrete/concretefloor013c_-886_-683_190" not found.
material "maps/dm_erde_sauv/concrete/concretefloor013c_-876_-94_190" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_807_1171_310" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_601_709_343" not found.
material "maps/dm_erde_sauv/nature/gravelfloor002b_244_-289_-23" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_599_-1210_103" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_442_-1441_128" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_-66_-553_50" not found.
material "maps/dm_erde_sauv/tile/tilefloor009a_248_-118_156" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_269_-181_50" not found.
material "maps/dm_erde_sauv/tile/tilefloor009a_-104_-120_156" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_-1293_220_313" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_-1293_220_313" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_-1061_495_313" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_-1307_5_313" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_-1061_495_313" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_-655_642_325" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_-848_352_336" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_-655_642_325" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_-311_722_325" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_-102_1188_304" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_138_990_320" not found.
material "maps/dm_erde_sauv/tile/tilewall009b_288_-546_50" not found.
material "maps/dm_erde_sauv/glass/glasswindowbreak070a_821_942_310" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_1154_177_482" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_821_-618_40" not found.
material "maps/dm_erde_sauv/tile/tilewall009d_812_769_310" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_-886_-683_190" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_-1291_-670_321" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_-886_-683_190" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_847_-426_620" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_-1291_-670_321" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_-1304_-520_318" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_-1503_-325_306" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_-1307_5_313" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_-1202_-77_313" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_-848_352_336" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_573_89_371" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_835_515_371" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_570_402_371" not found.
material "maps/dm_erde_sauv/tile/tilewall006b_573_89_371" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_233_665_276" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_570_402_371" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_443_-130_50" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_877_163_371" not found.
material "maps/dm_erde_sauv/tile/tilewall006c_730_-59_375" not found.
material "maps/dm_erde_sauv/glass/glasswindowbreak070a_725_-262_375" not found.
material "maps/dm_erde_sauv/glass/glasswindowbreak070a_730_-59_375" not found.
material "maps/dm_erde_sauv/glass/glasswindowbreak070a_138_929_320" not found.
material "maps/dm_erde_sauv/glass/glasswindowbreak070a_138_990_320" not found.
material "maps/dm_erde_sauv/glass/glasswindowbreak070a_138_1048_320" not found.
material "maps/dm_erde_sauv/glass/glasswindowbreak070a_-258_-641_50" not found.
material "maps/dm_erde_sauv/glass/glasswindowbreak070a_-257_-124_50" not found.
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: EntityPreHook "touch" crashing

Postby Kami » Tue Jan 17, 2017 6:19 pm

Okay, I have a test server up:

IP: 176.9.155.153:28240
Password: 1234

type in "Merde" in the chat and it will change to dm_erde if its not on the map already^^ This should give you a working version I hope
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: EntityPreHook "touch" crashing

Postby Painkiller » Tue Jan 17, 2017 6:58 pm

User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: EntityPreHook "touch" crashing

Postby L'In20Cible » Tue Jan 17, 2017 8:45 pm

I made some testing and the crash doesn't occurs when you touch the func_door_rotating. In fact, it does crash when you touch the prop_dynamic that have the func_door_rotating as parent. Calling an hooked function within a callback always been crashing and since the original function is calling the Touch function for its parent, it does crash. So no matter the entity you touch, that does have a valid parent, it will crash unless you block the original call. The only solution I can think of, would be to mimic the original call and calling the trampoline for its parent. For example, something like this:

Syntax: Select all

# ../addons/source-python/plugins/testing/testing.py

# ============================================================================
# >> IMPORTS
# ============================================================================
# Source.Python Imports
# Entities
from entities.entity import Entity
from entities.hooks import EntityCondition
from entities.hooks import EntityPreHook
from entities.helpers import index_from_pointer
from entities.helpers import index_from_inthandle
# Memory
from memory import NULL
from memory import Convention
from memory import DataType

# ============================================================================
# >> HOOKS
# ============================================================================
@EntityPreHook(
EntityCondition.equals_entity_classname('prop_physics'), 'touch')
def pre_touch(stack):
entity = Entity(index_from_pointer(stack[0]))
other = Entity(index_from_pointer(stack[1]))
on_touch(entity, other)
ptr = entity.get_property_pointer('m_pfnTouch')
if ptr != NULL:
func = ptr.make_function(Convention.THISCALL,
(DataType.POINTER, DataType.POINTER), DataType.VOID)
func(entity, other)
handle = entity.get_property_int('m_pParent')
if handle != -1:
parent = Entity(index_from_inthandle(handle))
parent.touch.call_trampoline(other)
on_touch(parent, other)
return False


# ============================================================================
# >> CALLBACKS
# ============================================================================
def on_touch(entity, other):
print(entity.classname, 'is touching', other.classname)
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: EntityPreHook "touch" crashing

Postby Kami » Sat Jan 21, 2017 10:18 am

Would there be any drawbacks to this if I just do whatever I need to do in the hook and return False (without the trampoline)? It seems that this solved the crash for me.

Anyways, thank you very much for your help! :>

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 23 guests