diff --git a/snd/sounds/target.wav b/snd/sounds/target.wav new file mode 100644 index 0000000..4718890 Binary files /dev/null and b/snd/sounds/target.wav differ diff --git a/src/pilot.c b/src/pilot.c index 6f52454..fa36ee6 100644 --- a/src/pilot.c +++ b/src/pilot.c @@ -20,7 +20,7 @@ #include "pilot.h" #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. */ @@ -1308,9 +1308,9 @@ static Fleet* fleet_parse(const xmlNodePtr parent) { memcpy(tmp->pilots+(tmp->npilots-1), pilot, sizeof(FleetPilot)); 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) MELEMENT(tmp->ai==NULL, "ai"); MELEMENT(tmp->faction==-1, "faction"); @@ -1348,13 +1348,13 @@ int fleet_load(void) { memcpy(fleet_stack+nfleets-1, tmp, sizeof(Fleet)); free(tmp); } - } while((node = node->next)); + } while(xml_nextNode(node)); xmlFreeDoc(doc); free(buf); xmlCleanupParser(); - DEBUG("Loaded %d fleet%c", nfleets, (nfleets==1)?' ':'s'); + DEBUG("Loaded %d fleet%s", nfleets, (nfleets==1) ? "" : "s"); return 0; } diff --git a/src/player.c b/src/player.c index cf74034..ed80e6b 100644 --- a/src/player.c +++ b/src/player.c @@ -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 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. */ static Pilot** player_stack = NULL; /**< Stack of ships player has. */ 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) { if(player_soundReserved) return; + /* Allocated channels. */ sound_reserve(PLAYER_RESERVED_CHANNELS); sound_createGroup(PLAYER_ENGINE_CHANNEL, 0, 1); /* Channel for engine noises. */ sound_createGroup(PLAYER_GUI_CHANNEL, 1, PLAYER_RESERVED_CHANNELS-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) * * @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. */ int player_outfitOwned(const char* outfitname) { @@ -600,7 +611,13 @@ int player_outfitOwned(const char* outfitname) { 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 i; @@ -623,7 +640,11 @@ void player_rmMissionCargo(unsigned int cargo_id) { 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) { double x, y; 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) { int i, j; double x, y; @@ -1668,6 +1693,10 @@ void player_targetHostile(void) { tp = pilot_stack[i]->id; } } + + if((tp != PLAYER_ID) && (tp != player_target)) + player_playSound(snd_target, 1); + player_target = tp; } @@ -1678,6 +1707,9 @@ void player_targetHostile(void) { */ void player_targetNext(void) { 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. */ void player_targetNearest(void) { + unsigned int t; + + t = player_target; player_target = pilot_getNearestPilot(player); + + if((player_target != PLAYER_ID) && (t != player_target)) + player_playSound(snd_target, 1); } /**