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
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (dr_panther, 7th_zorro), 1,203 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
acknex .exe crashing on ent_remove!!! #245797
01/12/09 00:04
01/12/09 00:04
Joined: Sep 2008
Posts: 5
Bullshark Offline OP
Newbie
Bullshark  Offline OP
Newbie

Joined: Sep 2008
Posts: 5
Hello!

I´m having a serious problem that I haven´t been able to solve, whenever I use ent_remove or ptr remove acknex.exe crashes (Windows diplays a "acknex.exe has stopped working" sign).

Any ideas on how to fix this?

Here's an example code, just in case I'm using them wrong:

Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <mtlFX.c>
///////////////////////////////
ENTITY* star_ent;

function star_event() 
{
	switch (event_type)
	{
		case EVENT_ENTITY:
				beep();
				ent_remove(me);
				wait(1);	
			return;
		
		case EVENT_BLOCK:
				beep();
				ent_remove(me);
				wait(1);			
			return;
		
	}
}

action star_fall()
{
	my.emask |= IGNORE_PASSABLE | ENABLE_BLOCK | ENABLE_ENTITY ;
	my.event = star_event;
}

function main()
{
	level_load("Test.WMB");
	wait(2);
	star_ent = ent_create("star.mdl",vector(0,0,300),star_fall); 
	phent_settype(star_ent, PH_RIGID, PH_POLY);
	phent_setgroup( star_ent, 1 ); 
	phent_setmass(star_ent,0.1,PH_BOX);	
	phent_setdamping (star_ent, 15, 0 );
	phent_enable( star_ent, 1 );
	ph_setgravity(vector(0,0,-100));
	ph_selectgroup( 1 );
	while(1)
	{
		wait(1);
	}
}


The wmb file only has a block to act as the ground for collision.

Thanks in advance for your help.

----------------------------
System:
* Windows Vista Pro 64 bits
* Core 2 Duo 2.13 Ghz Processor
* 5 Gb RAM
* nvidia 8800GTS video card
----------------------------

Re: acknex .exe crashing on ent_remove!!! [Re: Bullshark] #245799
01/12/09 00:25
01/12/09 00:25
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
I don't know anything about physics because I never used it. But, what are all your waits for? The manual as a "common mistakes" section although I don't know how they named it. It might be helpful for you.
There shouldn't be any wait(1); in an event function. I guess those are the reason for the crash.
And, whatfor is the while loop in the main function? That makes no sense.

Re: acknex .exe crashing on ent_remove!!! [Re: Pappenheimer] #245800
01/12/09 01:02
01/12/09 01:02
Joined: Sep 2008
Posts: 5
Bullshark Offline OP
Newbie
Bullshark  Offline OP
Newbie

Joined: Sep 2008
Posts: 5
Hi Pappenheimer, unfortunately even without the waits or the while it still crashes at ent_remove(me).

I have even replaced ent_remove(me) for ent remove(star_ent) just to make sure the pointer was right. Still same result.

Any more ideas on how to fix this or what could be causing it?

Thanx.

Re: acknex .exe crashing on ent_remove!!! [Re: Bullshark] #245801
01/12/09 01:10
01/12/09 01:10
Joined: Oct 2007
Posts: 5,210
Ä°stanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
Ä°stanbul, Turkey
try if this removes it:

if(me!=NULL) ent_remove(me);


3333333333
Re: acknex .exe crashing on ent_remove!!! [Re: Quad] #245803
01/12/09 01:41
01/12/09 01:41
Joined: Sep 2008
Posts: 5
Bullshark Offline OP
Newbie
Bullshark  Offline OP
Newbie

Joined: Sep 2008
Posts: 5
nope, still crashes! but thanks anyway Quadraxas.

Re: acknex .exe crashing on ent_remove!!! [Re: Bullshark] #245806
01/12/09 02:59
01/12/09 02:59
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Some or all of following may be inaccurate or erroneous.
...wait(1) before ent_remove(ENTITY*) in event (else instance = dangerous instruction)?
......wait(1);
......if (me != NULL) { ent_remove(me); }
...(below) removal in action not event
Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <mtlFX.c>
///////////////////////////////

#define _hit skill38

ENTITY* star_ent;

function star_event() 
{
	switch (event_type)
	{
		case EVENT_ENTITY:
				beep();
				my._hit = 1;
				my.event = NULL;
			return;
		
		case EVENT_BLOCK:
				beep();
				my._hit = 1;
				my.event = NULL;
			return;
		
	}
}

action star_fall()
{
	my.emask |= IGNORE_PASSABLE | ENABLE_BLOCK | ENABLE_ENTITY ;
	my.event = star_event;
	while(me != NULL) {
		if (my._hit == 1) {
			break;
		}
		wait(1);
	}
	if (me != NULL) {
		phent_enable(me, 0);
		ent_remove(me);
	}
}

function main()
{
	level_load("Test.WMB");
	wait(2);
	star_ent = ent_create("star.mdl",vector(0,0,300),star_fall); 
	phent_settype(star_ent, PH_RIGID, PH_POLY);
	phent_setgroup( star_ent, 1 ); 
	phent_setmass(star_ent,0.1,PH_BOX);	
	phent_setdamping (star_ent, 15, 0 );
	phent_enable( star_ent, 1 );
	ph_setgravity(vector(0,0,-100));
	ph_selectgroup( 1 );
	
}


Re: acknex .exe crashing on ent_remove!!! [Re: testDummy] #245807
01/12/09 03:09
01/12/09 03:09
Joined: Sep 2008
Posts: 5
Bullshark Offline OP
Newbie
Bullshark  Offline OP
Newbie

Joined: Sep 2008
Posts: 5
WOW! that worked!!! thank you very much testDummy!!! Just one more question, does the entity become NULL after ent_remove?

Thank you all for your help, I really apreciate it.

Re: [SOLVED]acknex .exe crashing on ent_remove!!! [Re: Bullshark] #245812
01/12/09 04:03
01/12/09 04:03
Joined: Sep 2008
Posts: 5
Bullshark Offline OP
Newbie
Bullshark  Offline OP
Newbie

Joined: Sep 2008
Posts: 5
Nevermind, I got everything up and running. Thanks again to everyone for your help.

Re: acknex .exe crashing on ent_remove!!! [Re: Pappenheimer] #245834
01/12/09 09:45
01/12/09 09:45
Joined: Aug 2005
Posts: 343
Germany
HPW Offline
Senior Member
HPW  Offline
Senior Member

Joined: Aug 2005
Posts: 343
Germany
Originally Posted By: Pappenheimer
... There shouldn't be any wait(1); in an event function. I guess those are the reason for the crash. ...


This is not true.
You can have wait(1) in your event functions.
To avoid crashes you should set the wait(1) before the ent_remove.
This info was posted by JCL long time ago and I used it many times this way without crashes.

And here I found the description in the manual:
Quote:

If for some reason the event function must perform such 'critical instructions', they must be preceded by a wait(1) for delaying them to the next frame. Then it's safe.


Last edited by HPW; 01/12/09 09:48.

Evil Blood (v. 0.52) RPG
Commport.de (Social Network Community)

Moderated by  HeelX, Spirit 

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