diff --git a/src/pilot.c b/src/pilot.c index bf5221e..e39086e 100644 --- a/src/pilot.c +++ b/src/pilot.c @@ -19,8 +19,8 @@ #include "map.h" #include "pilot.h" -#define XML_ID "Fleets" /**< XML section identifier. */ -#define XML_FLEET "fleet" +#define XML_ID "Fleets" /**< XML document identifier. */ +#define XML_FLEET "fleet" /**< XML individual fleet identifier. */ #define FLEET_DATA "../dat/fleet.xml" /**< Where to find fleet data. */ @@ -36,7 +36,7 @@ int pilot_nstack = 0; /**< Same. */ static int pilot_mstack = 0; /** Memory allocated for pilot_stack. */ extern Pilot* player; -extern unsigned int player_crating; +extern unsigned int player_crating; /**< Players combat rating. */ /* Stack of fleets. */ static Fleet* fleet_stack = NULL; /** Fleet stack. */ @@ -707,6 +707,23 @@ static void pilot_hyperspace(Pilot* p) { } } +/** + * @fn void pilot_hyperspaceAbort(Pilot* p) + * + * @brief Stops the pilot from hyperspaceing. + * + * Can only stop in preperation mode. + * @param p Pilot to handle stop hyperspace. + */ +void pilot_hyperspaceAbort(Pilot* p) { + if(!pilot_isFlag(p, PILOT_HYPERSPACE)) { + if(pilot_isFlag(p, PILOT_HYP_BEGIN)) + pilot_rmFlag(p, PILOT_HYP_BEGIN); + if(pilot_isFlag(p, PILOT_HYP_PREP)) + pilot_rmFlag(p, PILOT_HYP_PREP); + } +} + int pilot_addOutfit(Pilot* pilot, Outfit* outfit, int quantity) { int i, q, free_space; char* osec; diff --git a/src/pilot.h b/src/pilot.h index 61ac066..efd7aa9 100644 --- a/src/pilot.h +++ b/src/pilot.h @@ -222,6 +222,7 @@ void pilot_setSecondary(Pilot* p, const char* secondary); void pilot_setAmmo(Pilot* p); void pilot_setAfterburner(Pilot* p); double pilot_face(Pilot* p, const double dir); +void pilot_hyperspaceAbort(Pilot* p); /* Outfits. */ int pilot_freeSpace(Pilot* p); /* Pilot space. */ int pilot_addOutfit(Pilot* pilot, Outfit* outfit, int quantity); diff --git a/src/player.c b/src/player.c index 4473cac..3fc7bf0 100644 --- a/src/player.c +++ b/src/player.c @@ -1665,12 +1665,17 @@ void player_targetHyperspace(void) { */ void player_jump(void) { int i; - if((hyperspace_target == -1) || - pilot_isFlag(player, PILOT_HYP_PREP) || - pilot_isFlag(player, PILOT_HYP_BEGIN) || - pilot_isFlag(player, PILOT_HYPERSPACE)) + /* Must have a jump target and not be already jumping. */ + if((hyperspace_target == -1) || pilot_isFlag(player, PILOT_HYPERSPACE)) return; + /* Already jumping, so we break jump. */ + if(pilot_isFlag(player, PILOT_HYP_PREP)) { + pilot_hyperspaceAbort(player); + player_message("Aborting hyperspace sequence."); + return; + } + i = space_hyperspace(player); if(i == -1)