[Add] Player can abort hyperspaec jump sequence.

This commit is contained in:
Allanis 2013-10-15 23:38:49 +01:00
parent 2fdeecaefa
commit 93fd1eef4d
3 changed files with 30 additions and 7 deletions

View File

@ -19,8 +19,8 @@
#include "map.h" #include "map.h"
#include "pilot.h" #include "pilot.h"
#define XML_ID "Fleets" /**< XML section identifier. */ #define XML_ID "Fleets" /**< XML document identifier. */
#define XML_FLEET "fleet" #define XML_FLEET "fleet" /**< XML individual fleet identifier. */
#define FLEET_DATA "../dat/fleet.xml" /**< Where to find fleet data. */ #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. */ static int pilot_mstack = 0; /** Memory allocated for pilot_stack. */
extern Pilot* player; extern Pilot* player;
extern unsigned int player_crating; extern unsigned int player_crating; /**< Players combat rating. */
/* Stack of fleets. */ /* Stack of fleets. */
static Fleet* fleet_stack = NULL; /** Fleet stack. */ 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 pilot_addOutfit(Pilot* pilot, Outfit* outfit, int quantity) {
int i, q, free_space; int i, q, free_space;
char* osec; char* osec;

View File

@ -222,6 +222,7 @@ void pilot_setSecondary(Pilot* p, const char* secondary);
void pilot_setAmmo(Pilot* p); void pilot_setAmmo(Pilot* p);
void pilot_setAfterburner(Pilot* p); void pilot_setAfterburner(Pilot* p);
double pilot_face(Pilot* p, const double dir); double pilot_face(Pilot* p, const double dir);
void pilot_hyperspaceAbort(Pilot* p);
/* Outfits. */ /* Outfits. */
int pilot_freeSpace(Pilot* p); /* Pilot space. */ int pilot_freeSpace(Pilot* p); /* Pilot space. */
int pilot_addOutfit(Pilot* pilot, Outfit* outfit, int quantity); int pilot_addOutfit(Pilot* pilot, Outfit* outfit, int quantity);

View File

@ -1665,12 +1665,17 @@ void player_targetHyperspace(void) {
*/ */
void player_jump(void) { void player_jump(void) {
int i; int i;
if((hyperspace_target == -1) || /* Must have a jump target and not be already jumping. */
pilot_isFlag(player, PILOT_HYP_PREP) || if((hyperspace_target == -1) || pilot_isFlag(player, PILOT_HYPERSPACE))
pilot_isFlag(player, PILOT_HYP_BEGIN) ||
pilot_isFlag(player, PILOT_HYPERSPACE))
return; 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); i = space_hyperspace(player);
if(i == -1) if(i == -1)