[Add] Can now cycle systems with 'h' in map. [Fix] Cannot open map while dead.
This commit is contained in:
parent
9539e22d8b
commit
9a60a3d062
@ -13,6 +13,7 @@
|
|||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "escort.h"
|
#include "escort.h"
|
||||||
|
#include "land.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
|
||||||
#define KEY_PRESS ( 1.) /**< Key is pressed. */
|
#define KEY_PRESS ( 1.) /**< Key is pressed. */
|
||||||
@ -195,6 +196,8 @@ int input_getKeybind(char* keybind, KeybindType* type, SDLMod* mod, int* reverse
|
|||||||
(player && !pilot_isFlag(player, PILOT_HYP_PREP) && \
|
(player && !pilot_isFlag(player, PILOT_HYP_PREP) && \
|
||||||
!pilot_isFlag(player, PILOT_HYP_BEGIN) && \
|
!pilot_isFlag(player, PILOT_HYP_BEGIN) && \
|
||||||
!pilot_isFlag(player, PILOT_HYPERSPACE)) /**< Make sure player isn't jumping. */
|
!pilot_isFlag(player, PILOT_HYPERSPACE)) /**< Make sure player isn't jumping. */
|
||||||
|
#define NODEAD() (player) /**< Player isn't dead. */
|
||||||
|
#define NOLAND() (!landed) /**< Player isn't landed. */
|
||||||
static void input_key(int keynum, double value, int kabs) {
|
static void input_key(int keynum, double value, int kabs) {
|
||||||
unsigned int t;
|
unsigned int t;
|
||||||
|
|
||||||
@ -344,13 +347,13 @@ static void input_key(int keynum, double value, int kabs) {
|
|||||||
player_land();
|
player_land();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(KEY("thyperspace") && INGAME() && NOHYP()) {
|
else if(KEY("thyperspace") && NOHYP() && NOLAND() && NODEAD()) {
|
||||||
if(value == KEY_PRESS) {
|
if(value == KEY_PRESS) {
|
||||||
player_abortAutonav();
|
player_abortAutonav();
|
||||||
player_targetHyperspace();
|
player_targetHyperspace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(KEY("starmap") && NOHYP()) {
|
else if(KEY("starmap") && NOHYP() && NODEAD()) {
|
||||||
if(value == KEY_PRESS) map_open();
|
if(value == KEY_PRESS) map_open();
|
||||||
}
|
}
|
||||||
else if(KEY("jump") && INGAME()) {
|
else if(KEY("jump") && INGAME()) {
|
||||||
|
20
src/map.c
20
src/map.c
@ -280,6 +280,16 @@ static void map_update(void) {
|
|||||||
window_modifyText(map_wid, "txtSystemStatus", buf);
|
window_modifyText(map_wid, "txtSystemStatus", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn int map_isOpen(void)
|
||||||
|
*
|
||||||
|
* @brief Check to see if the map is open.
|
||||||
|
* @return 0 if map is closed, non-zero if it's open.
|
||||||
|
*/
|
||||||
|
int map_isOpen(void) {
|
||||||
|
return (map_wid > 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Return 1 if sys is part of the map_path. */
|
/* Return 1 if sys is part of the map_path. */
|
||||||
static int map_inPath(StarSystem* sys) {
|
static int map_inPath(StarSystem* sys) {
|
||||||
int i, f;
|
int i, f;
|
||||||
@ -551,6 +561,16 @@ void map_jump(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn void map_select(StarSystem* sys)
|
||||||
|
*
|
||||||
|
* @brief Selects the system in the map.
|
||||||
|
* @param sys System to select.
|
||||||
|
*/
|
||||||
|
void map_select(StarSystem* sys) {
|
||||||
|
map_selected = sys - systems_stack;
|
||||||
|
}
|
||||||
|
|
||||||
/* A* Algorithm fo shortest path finding. */
|
/* A* Algorithm fo shortest path finding. */
|
||||||
|
|
||||||
/* The node struct. */
|
/* The node struct. */
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
|
|
||||||
/* Open the map window. */
|
/* Open the map window. */
|
||||||
void map_open(void);
|
void map_open(void);
|
||||||
|
int map_isOpen(void);
|
||||||
|
|
||||||
/* Misc. */
|
/* Misc. */
|
||||||
|
void map_select(StarSystem* sys);
|
||||||
void map_clear(void);
|
void map_clear(void);
|
||||||
void map_jump(void);
|
void map_jump(void);
|
||||||
|
|
||||||
|
11
src/player.c
11
src/player.c
@ -60,6 +60,7 @@ static int player_credits = 0; /**< Temp hack on create. */
|
|||||||
*/
|
*/
|
||||||
static int snd_target = -1;
|
static int snd_target = -1;
|
||||||
static int snd_jump = -1;
|
static int snd_jump = -1;
|
||||||
|
static int snd_nav = -1;
|
||||||
|
|
||||||
/* Player pilot stack - Ships she owns. */
|
/* Player pilot stack - Ships she owns. */
|
||||||
static Pilot** player_stack = NULL; /**< Stack of ships player has. */
|
static Pilot** player_stack = NULL; /**< Stack of ships player has. */
|
||||||
@ -606,6 +607,7 @@ static void player_initSound(void) {
|
|||||||
/* Get sounds. */
|
/* Get sounds. */
|
||||||
snd_target = sound_get("target");
|
snd_target = sound_get("target");
|
||||||
snd_jump = sound_get("jump");
|
snd_jump = sound_get("jump");
|
||||||
|
snd_nav = sound_get("nav");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1660,9 +1662,10 @@ void player_targetPlanet(void) {
|
|||||||
hyperspace_target = -1;
|
hyperspace_target = -1;
|
||||||
player_rmFlag(PLAYER_LANDACK);
|
player_rmFlag(PLAYER_LANDACK);
|
||||||
|
|
||||||
if((planet_target == -1) && (cur_system->nplanets > 0)) {
|
|
||||||
/* No target. */
|
/* No target. */
|
||||||
|
if((planet_target == -1) && (cur_system->nplanets > 0)) {
|
||||||
planet_target = 0;
|
planet_target = 0;
|
||||||
|
player_playSound(snd_nav, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1671,6 +1674,7 @@ void player_targetPlanet(void) {
|
|||||||
if(planet_target >= cur_system->nplanets)
|
if(planet_target >= cur_system->nplanets)
|
||||||
/* Last system. */
|
/* Last system. */
|
||||||
planet_target = -1;
|
planet_target = -1;
|
||||||
|
else player_playSound(snd_nav, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1765,6 +1769,11 @@ void player_targetHyperspace(void) {
|
|||||||
|
|
||||||
if(hyperspace_target >= cur_system->njumps)
|
if(hyperspace_target >= cur_system->njumps)
|
||||||
hyperspace_target = -1;
|
hyperspace_target = -1;
|
||||||
|
else
|
||||||
|
player_playSound(snd_nav, 1);
|
||||||
|
|
||||||
|
if((hyperspace_target != -1) && map_isOpen())
|
||||||
|
map_select(&systems_stack[cur_system->jumps[hyperspace_target]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user