Engine crasht ohne Grund

Posted By: irchel2

Engine crasht ohne Grund - 09/30/13 15:10

Ich verwende das shooter-template t_shooter_player.c usw. Funktioniert soweit einwandfrei, aber wenn ich sterbe, moechte ich gern noch nen versuch. Also von:

Code:
[...]
if((jump_on) && (current_height < tshooter_disttoground)) // jumping while player's feet are placed on the floor?
		{
			if (!snd_playing (jump_handle)) // if no jumping sound is playing, play the jumping sound now
				jump_handle = snd_play(tshooter_jump_wav, 70, 0);
			vertical_speed.z = tshooter_jump * time_step; // push the player upwards
		}
		// this c_move instruction does all the job, moving the player in the direction given by horizontal_speed (forward, backward, sideways) and vertical_speed (on the z axis)
		c_move (my, horizontal_speed.x , vertical_speed.x, IGNORE_PASSABLE | USE_BOX | GLIDE); 
		// player movement end
		wait(1);
	}
	camera.z -= 30; // bring the camera closer to the floor
	camera.roll = 40; // and rotate its view (the player is dead here)
}



(das geht wunderbar) zu:

Code:
[...]
if((jump_on) && (current_height < tshooter_disttoground)) // jumping while player's feet are placed on the floor?
		{
			if (!snd_playing (jump_handle)) // if no jumping sound is playing, play the jumping sound now
				jump_handle = snd_play(tshooter_jump_wav, 70, 0);
			vertical_speed.z = tshooter_jump * time_step; // push the player upwards
		}
		// this c_move instruction does all the job, moving the player in the direction given by horizontal_speed (forward, backward, sideways) and vertical_speed (on the z axis)
		c_move (my, horizontal_speed.x , vertical_speed.x, IGNORE_PASSABLE | USE_BOX | GLIDE); 
		// player movement end
		wait(1);
	}
	camera.z -= 30; // bring the camera closer to the floor
	camera.roll = 40; // and rotate its view (the player is dead here)
	wait(30);
	//printf("unded");
	camera.z += 30;
	camera.roll = 0;
	t_shooter_players_health = 100;
	goto restarto;
	//t_shooter_player();
}



was crasht, wenn man jumpt. So gehts wieder:

Code:
[...]
	if((jump_on) && (current_height < tshooter_disttoground)) // jumping while player's feet are placed on the floor?
		{
		//	if (!snd_playing (jump_handle)) // if no jumping sound is playing, play the jumping sound now
	//			jump_handle = snd_play(tshooter_jump_wav, 70, 0);
			vertical_speed.z = tshooter_jump * time_step; // push the player upwards
		}
		// this c_move instruction does all the job, moving the player in the direction given by horizontal_speed (forward, backward, sideways) and vertical_speed (on the z axis)
		c_move (my, horizontal_speed.x , vertical_speed.x, IGNORE_PASSABLE | USE_BOX | GLIDE); 
		// player movement end
		wait(1);
	}
	camera.z -= 30; // bring the camera closer to the floor
	camera.roll = 40; // and rotate its view (the player is dead here)
	wait(30);
	//printf("unded");
	camera.z += 30;
	camera.roll = 0;
	t_shooter_players_health = 100;
	goto restarto;
	//t_shooter_player();
}



alles extrem unlogisch. Ich denke da hab ich einen Engine-Bug gefunden, vielleicht im Thread-Management; wegen snd_play? Kann man single-thread erzwingen?

Oder seh ich hier was grundsaetzliches nicht?
Posted By: Uhrwerk

Re: Engine crasht ohne Grund - 09/30/13 15:49

Originally Posted By: irchel2
Kann man single-thread erzwingen?
Ja. Einfach nichts tun. Die Engine arbeitet immer nur mit einem Thread.

Leider zeigst Du ja nur einen Teil Deines Codes. Was passiert denn nach dem Label "restartto" ? Goto ist übrigens Teufelszeugs. Wenn es geht, solltest Du das vermeiden.

wait(30) wartet übrigens 30 frames. Du willst aber doch sicher eine bestimmte Zeitspanne warten, oder?
Posted By: irchel2

Re: Engine crasht ohne Grund - 09/30/13 16:07

Originally Posted By: Uhrwerk
Goto ist übrigens Teufelszeugs. Wenn es geht, solltest Du das vermeiden.



Warum denn das? Ohne goto seh ich nur noch einen Himmel voll Schleifen laugh
Posted By: Uhrwerk

Re: Engine crasht ohne Grund - 09/30/13 16:58

Ganz grob: Mit Schleifen, Funktionen usf. kannst Du dein Programm wunderbar strukturieren. Goto bewirkt leider das Gegenteil, weil die Struktur des Quellcodes dann dem späteren Programmfluß nicht mehr entspricht.

Es gibt Tonnen von Stoff online dazu...

Das Problem bleibt aber. Du zeigst nicht deinen kompletten Code. Du hast auch nicht geschrieben, was Du denn mit "crashen" meinst...
© 2024 lite-C Forums