Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,014 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
A7.5 ent_create / ent_remove crash #448750
02/20/15 08:13
02/20/15 08:13
Joined: Aug 2014
Posts: 57
Y
Yking Offline OP
Junior Member
Yking  Offline OP
Junior Member
Y

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:
Quote:

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 Offline
Expert
Kartoffel  Offline
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
Y
Yking Offline OP
Junior Member
Yking  Offline OP
Junior Member
Y

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 Offline
Expert
Kartoffel  Offline
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: Kartoffel] #448755
02/20/15 12:05
02/20/15 12:05
Joined: Aug 2014
Posts: 57
Y
Yking Offline OP
Junior Member
Yking  Offline OP
Junior Member
Y

Joined: Aug 2014
Posts: 57
Thanks for the reply,
I changed the name but still get a crash frown

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 Offline
Expert
Kartoffel  Offline
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: Kartoffel] #448759
02/20/15 13:40
02/20/15 13:40
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
Code:
void testa()
{
	ENTITY* dummy=NULL;
	while(1)
	{
		if(!dummy)
		{
			wait(-2);
			dummy=ent_create("test.mdl",vector(1,1,1),NULL);
		}
		if(dummy!=NULL)
		{
			wait(-2);
			ptr_remove(dummy);
			//wait(1);
			beep();
			dummy=NULL;	
		}
		
		else
		{
			wait(1);
		}
	}
}



Compulsive compiler
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
Y
Yking Offline OP
Junior Member
Yking  Offline OP
Junior Member
Y

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:

Quote:

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
W
Wjbender Offline
User
Wjbender  Offline
User
W

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
Y
Yking Offline OP
Junior Member
Yking  Offline OP
Junior Member
Y

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
Quote:

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 shocked

Page 1 of 2 1 2

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1