[Add] pilot_getAmmo.

This commit is contained in:
Allanis 2013-11-09 00:23:57 +00:00
parent e829e71347
commit 9c2e35c472
2 changed files with 25 additions and 0 deletions

View File

@ -498,6 +498,30 @@ void pilot_setAmmo(Pilot* p) {
p->ammo = NULL; p->ammo = NULL;
} }
/**
* @fn int pilot_getAmmo(Pilot* p, Outfit* o)
* @param p Pilot to get amount of ammo for.
* @param o Outfit to get ammo for.
* @return Amount of ammo for o on p.
*/
int pilot_getAmmo(Pilot* p, Outfit* o) {
int i;
char* name;
/* Must be a launcher. */
if(!outfit_isLauncher(o))
return 0;
/* Try to find the ammo. */
name = o->u.lau.ammo;
for(i = 0; i < p->noutfits; i++)
if(strcmp(p->outfits[i].outfit->name, name)==0)
return p->outfits[i].quantity;
/* Assume none. */
return 0;
}
/** /**
* @fn void pilot_setAfterburner(Pilot* p) * @fn void pilot_setAfterburner(Pilot* p)
* *

View File

@ -220,6 +220,7 @@ void pilot_hit(Pilot* p, const Solid* w, const unsigned int shooter,
void pilot_switchSecondary(Pilot* p, int i); void pilot_switchSecondary(Pilot* p, int i);
void pilot_setSecondary(Pilot* p, const char* secondary); void pilot_setSecondary(Pilot* p, const char* secondary);
void pilot_setAmmo(Pilot* p); void pilot_setAmmo(Pilot* p);
int pilot_getAmmo(Pilot* p, Outfit* o);
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); void pilot_hyperspaceAbort(Pilot* p);