I am currently trying to isolate a more or less severe problem in my Superku game and have written the following level protocol function (that gets automatically called directly after level_load in my script):

Click to reveal..
Code:
on_l = level_protocol;

void level_protocol()
{
	var p_file,e_count = 0,e_res = 1;
	STRING* str_tmp = str_create("");

	sys_marker("LP1");
	str_cpy(str_tmp,level_name);
	str_trunc(str_tmp,4);
	if(key_l) str_cat(str_tmp,"_protocol_forced.txt");
	else str_cat(str_tmp,"_protocol.txt");
	p_file = file_open_write(str_tmp);
	
	sys_marker("LP2");
	file_str_write(p_file,"Functions:");
	char* funcname;
	ENTITY* ent;
	while(e_res)
	{
		sys_marker("L2A");
		if(!engine_gettaskinfo(e_count,&funcname,&ent)) break;
		sys_marker("L2B");
		file_str_write(p_file,"\nFunction: ");
		file_var_write(p_file,e_count);
		file_str_write(p_file,"\n-name: ");
		sys_marker("L2C");
		if(funcname) file_str_write(p_file,funcname);
		sys_marker("L2D");
		file_str_write(p_file,"\n-me entity: ");
		if(ent) file_var_write(p_file,ent->link.index);
		e_count++;
	}
	sys_marker("LP3");
	file_str_write(p_file,"\nEntities:");
	e_count = 0;
	for(you = ent_next(NULL); you; you = ent_next(you))
	{
		e_count++;
		file_str_write(p_file,"\nEntity: ");
		file_var_write(p_file,e_count);
		file_str_write(p_file,"\n-filename: ");
		str_for_entfile(str_tmp,you);
		file_str_write(p_file,str_tmp);
		file_str_write(p_file,"\n-link id: ");
		file_var_write(p_file,you->link.index);
		file_str_write(p_file,"\n-link name: ");
		if(you->link.name) file_str_write(p_file,you->link.name);
		file_str_write(p_file,str_printf(NULL,"\n-pos: (%d,%d,%d)",(int)your.x,(int)your.y,(int)your.z));
		file_str_write(p_file,str_printf(NULL,"\n-pan: (%d,%d,%d)",(int)your.pan,(int)your.tilt,(int)your.roll));
		file_str_write(p_file,str_printf(NULL,"\n-scale: (%d,%d,%d)",(int)your.scale_x,(int)your.scale_y,(int)your.scale_z));
		file_str_write(p_file,str_printf(NULL,"\n-flags: (%d,%d,%d)",(int)your.eflags,(int)your.flags2,(int)your.emask));
	}
	sys_marker("LP4");
	file_str_write(p_file,"\nEntities in total: ");
	file_var_write(p_file,e_count);
	file_str_write(p_file,"\nLoading errors: ");
	file_var_write(p_file,last_error);
	file_close(p_file);
	sys_marker(NULL);
	ptr_remove(str_tmp);
}



After level_load I press [L] to write the level protocol and there normally appear two functions without name or a completely scrambled name and with ent->link.index on -1 (invalid handle), 0 or some other much too big index value. Sometimes on the first or second or third try that I press [L] I get a function crash in "L2C".
This does not happen in small test projects, neither the crash nor functions without/ with weird names.

If you have a (preferably bigger) project and a minute of time please give it a try and call the function a few times!

Thanks.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends