|
A7.5 ent_create / ent_remove crash
#448750
02/20/15 08:13
02/20/15 08:13
|
Joined: Aug 2014
Posts: 57
Yking
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2014
Posts: 57
|
Hello everyone, I have problems with my code and I can't find a solution to my problem. Maybe I suck at searching, but I don't really know how to specify my question. I have the following code-example: while (1) { ENTITY* dummy; dummy = ent_create (NULL, vector(1,1,1), NULL); ent_remove(dummy); wait(-1); }
It is supposed to create some empty object, delete it again, wait one second and keep doing this. But I keep getting a crash. I thought that ent_remove would completely remove the entity so I can create it again. The vector would be different later everytime in case you wonder. Did I overlook anything? Thanks for any help. Yours, Ykinger
|
|
|
Re: A7.5 ent_create / ent_remove crash
[Re: Yking]
#448751
02/20/15 08:17
02/20/15 08:17
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
well the problem could be, that you delete the entity immediately after creating it
POTATO-MAN saves the day! - Random
|
|
|
Re: A7.5 ent_create / ent_remove crash
[Re: Kartoffel]
#448752
02/20/15 08:32
02/20/15 08:32
|
Joined: Aug 2014
Posts: 57
Yking
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2014
Posts: 57
|
Thanks for the help, but even if I add more wait()-commands inbetween, it crashes every time after the first loop.
Edit: with ptr_remove() it does not seem to work aswell
Last edited by Yking; 02/20/15 08:55.
|
|
|
Re: A7.5 ent_create / ent_remove crash
[Re: Yking]
#448753
02/20/15 09:56
02/20/15 09:56
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
maybe the name dummy is used by something else
POTATO-MAN saves the day! - Random
|
|
|
Re: A7.5 ent_create / ent_remove crash
[Re: Yking]
#448757
02/20/15 12:50
02/20/15 12:50
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
when I try the code it works perfectly.
the mistake must be somewhere else.. :S
POTATO-MAN saves the day! - Random
|
|
|
Re: A7.5 ent_create / ent_remove crash
[Re: Wjbender]
#448761
02/20/15 14:18
02/20/15 14:18
|
Joined: Aug 2014
Posts: 57
Yking
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2014
Posts: 57
|
Thanks for all the help so far, I tried the code and as Kartoffel said, the problem is somewhere else. I did not include the following because I thought it would not be important. This Entity that I want to create every loop, shall after it is created do a c_scan to scan for other entities. Like the following: while (1) { ENTITY* dummy; dummy = ent_create (NULL, vector(1,1,1), NULL);
dummy.emask = ENABLE_DETECT; dummy.event = message_on_screen; c_scan(dummy.x,dummy.pan,vector(360,180,1000),SCAN_ENTS | IGNORE_ME); wait(1);
ptr_remove(dummy); wait(-1); }
When I remove the c_scan, all of the rest works fine. With the c_scan enabled, the loop will trigger my event one time and crash the next time. Edit: There are other Entities around so the event gets triggered, they have nothing to do with this script.
Last edited by Yking; 02/20/15 14:20.
|
|
|
Re: A7.5 ent_create / ent_remove crash
[Re: Yking]
#448763
02/20/15 15:04
02/20/15 15:04
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
the code I gave you would help you out in determining the problem because it should help only executing code when the entity pointer's empty/exist ..
since you only provided the code that "is not the problem" , there is nothing to find in it which "is the problem" from our side , therefore the most logical effort I could give , I already gave ..
if you want help , you must try narrowing it down to where the problem is , and provide that also .
jb
Last edited by Wjbender; 02/20/15 15:06.
Compulsive compiler
|
|
|
Re: A7.5 ent_create / ent_remove crash
[Re: Wjbender]
#448764
02/20/15 15:24
02/20/15 15:24
|
Joined: Aug 2014
Posts: 57
Yking
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2014
Posts: 57
|
Okay I understand, thanks for your replay Wjbender. I used your code, implemented it 1:1 and added my 3 lines of c_scan-code if(!dummy) { wait(-2); dummy=ent_create("test.mdl",vector(1,1,1),NULL); dummy.emask = ENABLE_DETECT; dummy.event = message_on_screen; c_scan(dummy.x,dummy.pan,vector(360,180,1000),SCAN_ENTS | IGNORE_ME); }
and so on..
but I still get the same error. The entity gets created, then I hear the beep (which means it got deleted) and then it crashes. When I remove my 3 lines of c_scan-code then I hear multiple beeps, so the entity gets created, deleted, created, deleted and so on just fine. So I narrowed it down to my 3 lines of c_scan-code I think, which work only the first time, then they crash. The c_scan is supposed to detect entities around my dummy (which are placed there by another function, they are nothing special, but are in reach of my c_scan) What I expect to happen would be: My dummy gets created, he scans, sees entities around him and triggers my c_scan_event (message on screen with printf) and then the dummy gets deleted. Right after he gets deleted he will get created again and all starts over. I hope I am not too confusing, I have not coded for a loooong time
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|