diff --git a/src/input.c b/src/input.c index 609c682..00bcd7f 100644 --- a/src/input.c +++ b/src/input.c @@ -13,6 +13,7 @@ #include "board.h" #include "map.h" #include "escort.h" +#include "land.h" #include "input.h" #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) && \ !pilot_isFlag(player, PILOT_HYP_BEGIN) && \ !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) { unsigned int t; @@ -344,13 +347,13 @@ static void input_key(int keynum, double value, int kabs) { player_land(); } } - else if(KEY("thyperspace") && INGAME() && NOHYP()) { + else if(KEY("thyperspace") && NOHYP() && NOLAND() && NODEAD()) { if(value == KEY_PRESS) { player_abortAutonav(); player_targetHyperspace(); } } - else if(KEY("starmap") && NOHYP()) { + else if(KEY("starmap") && NOHYP() && NODEAD()) { if(value == KEY_PRESS) map_open(); } else if(KEY("jump") && INGAME()) { diff --git a/src/map.c b/src/map.c index 67d803e..f20ff64 100644 --- a/src/map.c +++ b/src/map.c @@ -280,6 +280,16 @@ static void map_update(void) { 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. */ static int map_inPath(StarSystem* sys) { 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. */ /* The node struct. */ diff --git a/src/map.h b/src/map.h index 0f470aa..1d4abb8 100644 --- a/src/map.h +++ b/src/map.h @@ -3,8 +3,10 @@ /* Open the map window. */ void map_open(void); +int map_isOpen(void); /* Misc. */ +void map_select(StarSystem* sys); void map_clear(void); void map_jump(void); diff --git a/src/player.c b/src/player.c index 2c6cd42..b006c5f 100644 --- a/src/player.c +++ b/src/player.c @@ -59,7 +59,8 @@ static int player_credits = 0; /**< Temp hack on create. */ * Player sounds. */ 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. */ static Pilot** player_stack = NULL; /**< Stack of ships player has. */ @@ -604,8 +605,9 @@ static void player_initSound(void) { player_soundReserved = 1; /* Get sounds. */ - snd_target = sound_get("target"); - snd_jump = sound_get("jump"); + snd_target = sound_get("target"); + snd_jump = sound_get("jump"); + snd_nav = sound_get("nav"); } /** @@ -1660,9 +1662,10 @@ void player_targetPlanet(void) { hyperspace_target = -1; player_rmFlag(PLAYER_LANDACK); + /* No target. */ if((planet_target == -1) && (cur_system->nplanets > 0)) { - /* No target. */ planet_target = 0; + player_playSound(snd_nav, 1); return; } @@ -1671,6 +1674,7 @@ void player_targetPlanet(void) { if(planet_target >= cur_system->nplanets) /* Last system. */ planet_target = -1; + else player_playSound(snd_nav, 1); } /** @@ -1765,6 +1769,11 @@ void player_targetHyperspace(void) { if(hyperspace_target >= cur_system->njumps) hyperspace_target = -1; + else + player_playSound(snd_nav, 1); + + if((hyperspace_target != -1) && map_isOpen()) + map_select(&systems_stack[cur_system->jumps[hyperspace_target]]); } /**