From 39871138e6e4b73239bb3b5c6e20d9ee14baf06c Mon Sep 17 00:00:00 2001
From: Allanis <allanis@saracraft.net>
Date: Sat, 1 Jun 2013 17:39:20 +0100
Subject: [PATCH] [Add] Conserve hyperspace path when taking off.

---
 src/land.c   | 8 +++++++-
 src/player.c | 2 ++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/land.c b/src/land.c
index 2de1023..e2c4510 100644
--- a/src/land.c
+++ b/src/land.c
@@ -62,6 +62,9 @@ Planet* land_planet = NULL;
 static Mission* mission_computer = NULL;
 static int mission_ncomputer = 0;
 
+// Player stuff.
+extern int hyperspace_target;
+
 // Window stuff.
 static int land_wid = 0; // Primary land window.
 // For the second opened land window
@@ -1024,7 +1027,7 @@ void land(Planet* p) {
 
 // Takeoff from the planet.
 void takeoff(void) {
-  int  sw, sh, i;
+  int  sw, sh, i, h;
   char* lt;
 
   if(!landed) return;
@@ -1055,7 +1058,10 @@ void takeoff(void) {
   player_message("taking off from %s on %s", land_planet->name, lt);
   free(lt);
 
+  // Initialize the new space.
+  h = hyperspace_target;
   space_init(NULL);
+  hyperspace_target = h;
 
   // Cleanup.
   save_all(); // Must be before cleaning up planet. Duh!
diff --git a/src/player.c b/src/player.c
index a2f8463..8cb445e 100644
--- a/src/player.c
+++ b/src/player.c
@@ -335,6 +335,8 @@ void player_swapShip(char* shipname) {
 void player_cleanup(void) {
   int i;
 
+  player_clear();
+
   // Cleanup name.
   if(player_name != NULL) free(player_name);