[Fix] Segfault when trying to land on a system with no planets.

This commit is contained in:
Allanis 2013-06-02 13:57:00 +01:00
parent fee98162a6
commit a6805df42d
2 changed files with 10 additions and 4 deletions

View File

@ -79,7 +79,8 @@ void gl_bindCamera(const Vec2* pos);
// Circle drawing.
void gl_drawCircle(const double x, const double y, const double r);
void gl_drawCircleInRect(const double x, const double y, const double r,
const double rc, const double ry, const double rw, const double rh);
const double rc, const double ry, const double rw,
const double rh);
// Initialize/cleanup.
int gl_init(void);

View File

@ -1178,6 +1178,10 @@ void player_targetPlanet(void) {
// Attempt to land or target closest planet if no land target.
void player_land(void) {
int i;
int tp;
double td, d;
if(landed) {
// Player is already landed.
takeoff();
@ -1211,9 +1215,10 @@ void player_land(void) {
land(planet); // Land the player.
} else {
// Get nearest planet target.
int i;
int tp;
double td, d;
if(cur_system->nplanets == 0) {
player_message("There are no planets to land on.");
return;
}
td = -1; // Temp distance.
tp = -1; // Temp planet.