[Add] Targetting sounds implemented.

[Add] More doxygen.
This commit is contained in:
Allanis 2013-09-06 16:37:38 +01:00
parent eae283417f
commit fc3276464a
3 changed files with 47 additions and 9 deletions

BIN
snd/sounds/target.wav Normal file

Binary file not shown.

View File

@ -20,7 +20,7 @@
#include "pilot.h" #include "pilot.h"
#define XML_ID "Fleets" /**< XML section identifier. */ #define XML_ID "Fleets" /**< XML section identifier. */
#define XML_FLEET "fleet #define XML_FLEET "fleet"
#define FLEET_DATA "../dat/fleet.xml" /**< Where to find fleet data. */ #define FLEET_DATA "../dat/fleet.xml" /**< Where to find fleet data. */
@ -1308,9 +1308,9 @@ static Fleet* fleet_parse(const xmlNodePtr parent) {
memcpy(tmp->pilots+(tmp->npilots-1), pilot, sizeof(FleetPilot)); memcpy(tmp->pilots+(tmp->npilots-1), pilot, sizeof(FleetPilot));
free(pilot); free(pilot);
} }
} while((cur = cur->next)); } while(xml_nextNode(cur));
} }
} while((node = node->next)); } while(xml_nextNode(node));
#define MELEMENT(o,s) if(o) WARN("Fleet '%s' missing '"s"' element", tmp->name) #define MELEMENT(o,s) if(o) WARN("Fleet '%s' missing '"s"' element", tmp->name)
MELEMENT(tmp->ai==NULL, "ai"); MELEMENT(tmp->ai==NULL, "ai");
MELEMENT(tmp->faction==-1, "faction"); MELEMENT(tmp->faction==-1, "faction");
@ -1348,13 +1348,13 @@ int fleet_load(void) {
memcpy(fleet_stack+nfleets-1, tmp, sizeof(Fleet)); memcpy(fleet_stack+nfleets-1, tmp, sizeof(Fleet));
free(tmp); free(tmp);
} }
} while((node = node->next)); } while(xml_nextNode(node));
xmlFreeDoc(doc); xmlFreeDoc(doc);
free(buf); free(buf);
xmlCleanupParser(); xmlCleanupParser();
DEBUG("Loaded %d fleet%c", nfleets, (nfleets==1)?' ':'s'); DEBUG("Loaded %d fleet%s", nfleets, (nfleets==1) ? "" : "s");
return 0; return 0;
} }

View File

@ -53,6 +53,12 @@ static Ship* player_ship = NULL; /**< Temp ship to hold when naming it. *
static double player_px, player_py, player_vx, player_vy, player_dir; /**< More hack. */ static double player_px, player_py, player_vx, player_vy, player_dir; /**< More hack. */
static int player_credits = 0; /**< Temp hack on create. */ static int player_credits = 0; /**< Temp hack on create. */
/*
* Player sounds.
*/
static int snd_target = -1;
static int snd_jump = -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. */
static char** player_lstack = NULL; /**< Names of the planet the ships are at. */ static char** player_lstack = NULL; /**< Names of the planet the ships are at. */
@ -478,10 +484,15 @@ static int player_soundReserved = 0; /**< Has the player already reserved sound?
static void player_initSound(void) { static void player_initSound(void) {
if(player_soundReserved) return; if(player_soundReserved) return;
/* Allocated channels. */
sound_reserve(PLAYER_RESERVED_CHANNELS); sound_reserve(PLAYER_RESERVED_CHANNELS);
sound_createGroup(PLAYER_ENGINE_CHANNEL, 0, 1); /* Channel for engine noises. */ sound_createGroup(PLAYER_ENGINE_CHANNEL, 0, 1); /* Channel for engine noises. */
sound_createGroup(PLAYER_GUI_CHANNEL, 1, PLAYER_RESERVED_CHANNELS-1); sound_createGroup(PLAYER_GUI_CHANNEL, 1, PLAYER_RESERVED_CHANNELS-1);
player_soundReserved = 1; player_soundReserved = 1;
/* Get sounds. */
snd_target = sound_get("target");
snd_jump = sound_get("jump");
} }
/** /**
@ -587,7 +598,7 @@ const char* player_rating(void) {
* @fn int player_outfitOwned(const char* outfitname) * @fn int player_outfitOwned(const char* outfitname)
* *
* @brief Get how many of the outfits the player owns. * @brief Get how many of the outfits the player owns.
* @param outfitname Outfit to check how many the player owns of. * @param outfitname Outfit to check how many the player owns.
* @return The number of outfits matching outfitname owned. * @return The number of outfits matching outfitname owned.
*/ */
int player_outfitOwned(const char* outfitname) { int player_outfitOwned(const char* outfitname) {
@ -600,7 +611,13 @@ int player_outfitOwned(const char* outfitname) {
return 0; return 0;
} }
/* Return how many of the commodity the player has. */ /**
* @fn int player_cargoOwned(const char* commodityname)
*
* @brief Get how many of the commodity the player has.
* @param commodityname Commodity to check how many the player has.
* @return The number of commodities owned matching commodityname.
*/
int player_cargoOwned(const char* commodityname) { int player_cargoOwned(const char* commodityname) {
int i; int i;
@ -623,7 +640,11 @@ void player_rmMissionCargo(unsigned int cargo_id) {
return; /* Success. */ return; /* Success. */
} }
/* Render the background player stuff, namely planet target */ /**
* @fn void player_renderBG(void)
*
* @brief Render the background player stuff, namely planet target gfx.
*/
void player_renderBG(void) { void player_renderBG(void) {
double x, y; double x, y;
glColour* c; glColour* c;
@ -689,7 +710,11 @@ void player_render(void) {
} }
} }
/* Render the player's GUI. */ /**
* @fn void player_renderGUI(void)
*
* @brief Render the players GUI.
*/
void player_renderGUI(void) { void player_renderGUI(void) {
int i, j; int i, j;
double x, y; double x, y;
@ -1668,6 +1693,10 @@ void player_targetHostile(void) {
tp = pilot_stack[i]->id; tp = pilot_stack[i]->id;
} }
} }
if((tp != PLAYER_ID) && (tp != player_target))
player_playSound(snd_target, 1);
player_target = tp; player_target = tp;
} }
@ -1678,6 +1707,9 @@ void player_targetHostile(void) {
*/ */
void player_targetNext(void) { void player_targetNext(void) {
player_target = pilot_getNextID(player_target); player_target = pilot_getNextID(player_target);
if(player_target != PLAYER_ID)
player_playSound(snd_target, 1);
} }
/** /**
@ -1686,7 +1718,13 @@ void player_targetNext(void) {
* @brief Player targets nearest pilot. * @brief Player targets nearest pilot.
*/ */
void player_targetNearest(void) { void player_targetNearest(void) {
unsigned int t;
t = player_target;
player_target = pilot_getNearestPilot(player); player_target = pilot_getNearestPilot(player);
if((player_target != PLAYER_ID) && (t != player_target))
player_playSound(snd_target, 1);
} }
/** /**