crash with ent_playloop and pXent_getspeed

Posted By: oliver2s

crash with ent_playloop and pXent_getspeed - 10/10/13 08:43

I get an engine when I using ent_playsound in combination with the "pXent_getspeed" function from "car.c" in gamestudio folder ("\include\"):

What sound file you are using doesn't matter. It crashes with wav and ogg. The file is also not broken, I've tried many different sound files, even some files vom gamestudio folder.

Code:
#include <acknex.h>
#include <ackphysx.h>

SOUND* snd_test="test.wav";
var snd_hndl=0;

//this function is from /include/car.c in gamestudio folder
var pXent_getspeed(ENTITY* ent)
{
	VECTOR vSpeed,vDir;
	pXent_getvelocity(ent,vSpeed,NULL);
	vec_for_angle(vDir,ent.pan);
// speed in km/h, assume 40 quants = 1 m	
	var speed = vec_dot(vDir,vSpeed) * (60.*60.)/(40.*1000.); 
	if (abs(speed) < 1) 
		return 0;
	else 
		return speed;
}

void main()
{
	physX_open();
	level_load(NULL);
	
	ENTITY* ent_tmp=ent_create(CUBE_MDL,nullvector,NULL);
	pXent_settype(ent_tmp,PH_RIGID,PH_BOX);
	
	wait(-3);
	
	while(1)
	{
		pXent_getspeed(ent_tmp);
		
		if(!snd_playing(snd_hndl))
		{
			snd_hndl=ent_playloop(ent_tmp,snd_test,100);
		}
		
		wait(1);
	}
}

Posted By: jcl

Re: crash with ent_playloop and pXent_getspeed - 10/11/13 10:23

Thanks, I'll look into that. A possible reason is that snd_playing is called with a zero handle, but normally the function should then return and not crash.
Posted By: oliver2s

Re: crash with ent_playloop and pXent_getspeed - 10/11/13 12:00

[EDIT]: oops, I accidently edited my post instead of creating a new one.
Posted By: oliver2s

Re: crash with ent_playloop and pXent_getspeed - 10/15/13 13:59

Can you confirm the crash?
Posted By: rojart

Re: crash with ent_playloop and pXent_getspeed - 10/15/13 14:58

By the way the same happens with knights_on_wheels.c sample under car_noise function by ent_playloop in car.c file.
© 2024 lite-C Forums