[Change] Made setSecondary static for minor optimization.
This commit is contained in:
parent
3d85fa67f6
commit
22ebaef033
15
src/pilot.c
15
src/pilot.c
@ -74,6 +74,7 @@ void pilot_free(Pilot* p); /* Externed in player.c */
|
|||||||
static int fleet_parse(Fleet* tmp, const xmlNodePtr parent);
|
static int fleet_parse(Fleet* tmp, const xmlNodePtr parent);
|
||||||
static void pilot_dead(Pilot* p);
|
static void pilot_dead(Pilot* p);
|
||||||
static int pilot_setOutfitMounts(Pilot* p, PilotOutfit* po, int o, int q);
|
static int pilot_setOutfitMounts(Pilot* p, PilotOutfit* po, int o, int q);
|
||||||
|
static void pilot_setSecondary(Pilot* p, Outfit* o);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the pilots position in the stack.
|
* @brief Get the pilots position in the stack.
|
||||||
@ -552,11 +553,11 @@ void pilot_runHook(Pilot* p, int hook_type) {
|
|||||||
* @param p Pilot to set secondary weapon.
|
* @param p Pilot to set secondary weapon.
|
||||||
* @param secondary Name of the secondary weapon to set.
|
* @param secondary Name of the secondary weapon to set.
|
||||||
*/
|
*/
|
||||||
void pilot_setSecondary(Pilot* p, const char* secondary) {
|
static void pilot_setSecondary(Pilot* p, Outfit* o) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* No need for ammo if there is no secondary. */
|
/* No need for ammo if there is no secondary. */
|
||||||
if(secondary == NULL) {
|
if(o == NULL) {
|
||||||
p->secondary = NULL;
|
p->secondary = NULL;
|
||||||
p->ammo = NULL;
|
p->ammo = NULL;
|
||||||
return;
|
return;
|
||||||
@ -564,7 +565,7 @@ void pilot_setSecondary(Pilot* p, const char* secondary) {
|
|||||||
|
|
||||||
/* Find the secondary and set ammo appropriately. */
|
/* Find the secondary and set ammo appropriately. */
|
||||||
for(i = 0; i < p->noutfits; i++) {
|
for(i = 0; i < p->noutfits; i++) {
|
||||||
if(strcmp(secondary, p->outfits[i].outfit->name)==0) {
|
if(p->outfits[i].outfit == o) {
|
||||||
p->secondary = &p->outfits[i];
|
p->secondary = &p->outfits[i];
|
||||||
pilot_setAmmo(p);
|
pilot_setAmmo(p);
|
||||||
return;
|
return;
|
||||||
@ -991,7 +992,7 @@ static int pilot_setOutfitMounts(Pilot* p, PilotOutfit* po, int o, int q) {
|
|||||||
int pilot_addOutfit(Pilot* pilot, Outfit* outfit, int quantity) {
|
int pilot_addOutfit(Pilot* pilot, Outfit* outfit, int quantity) {
|
||||||
int i;
|
int i;
|
||||||
int o, q, free_space;
|
int o, q, free_space;
|
||||||
char* osec;
|
Outfit* osec;
|
||||||
PilotOutfit* po;
|
PilotOutfit* po;
|
||||||
|
|
||||||
free_space = pilot_freeSpace(pilot);
|
free_space = pilot_freeSpace(pilot);
|
||||||
@ -1040,7 +1041,7 @@ int pilot_addOutfit(Pilot* pilot, Outfit* outfit, int quantity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Hacks in case it reallocs. */
|
/* Hacks in case it reallocs. */
|
||||||
osec = (pilot->secondary) ? pilot->secondary->outfit->name : NULL;
|
osec = (pilot->secondary) ? pilot->secondary->outfit : NULL;
|
||||||
/* No need for ammo since it's already handled in setSecondary, */
|
/* No need for ammo since it's already handled in setSecondary, */
|
||||||
/* since pilot has only one afterburner it's handled at the end. */
|
/* since pilot has only one afterburner it's handled at the end. */
|
||||||
|
|
||||||
@ -1085,7 +1086,7 @@ int pilot_addOutfit(Pilot* pilot, Outfit* outfit, int quantity) {
|
|||||||
*/
|
*/
|
||||||
int pilot_rmOutfit(Pilot* pilot, Outfit* outfit, int quantity) {
|
int pilot_rmOutfit(Pilot* pilot, Outfit* outfit, int quantity) {
|
||||||
int i, j, q, c, o;
|
int i, j, q, c, o;
|
||||||
char* osec;
|
Outfit* osec;
|
||||||
PilotOutfit* po;
|
PilotOutfit* po;
|
||||||
|
|
||||||
c = (outfit_isMod(outfit)) ? outfit->u.mod.cargo : 0;
|
c = (outfit_isMod(outfit)) ? outfit->u.mod.cargo : 0;
|
||||||
@ -1112,7 +1113,7 @@ int pilot_rmOutfit(Pilot* pilot, Outfit* outfit, int quantity) {
|
|||||||
q += po->quantity;
|
q += po->quantity;
|
||||||
|
|
||||||
/* Hack in case it reallocs - Can happen even when shrinking. */
|
/* Hack in case it reallocs - Can happen even when shrinking. */
|
||||||
osec = (pilot->secondary) ? pilot->secondary->outfit->name : NULL;
|
osec = (pilot->secondary) ? pilot->secondary->outfit : NULL;
|
||||||
|
|
||||||
/* Free some memory if needed. */
|
/* Free some memory if needed. */
|
||||||
if(po->mounts != NULL)
|
if(po->mounts != NULL)
|
||||||
|
@ -244,7 +244,6 @@ void pilot_hyperspaceAbort(Pilot* p);
|
|||||||
/* Special outfit stuff. */
|
/* Special outfit stuff. */
|
||||||
int pilot_getMount(Pilot* p, int id, Vec2* v);
|
int pilot_getMount(Pilot* p, int id, Vec2* v);
|
||||||
void pilot_switchSecondary(Pilot* p, int i);
|
void pilot_switchSecondary(Pilot* p, int i);
|
||||||
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);
|
int pilot_getAmmo(Pilot* p, Outfit* o);
|
||||||
void pilot_setAfterburner(Pilot* p);
|
void pilot_setAfterburner(Pilot* p);
|
||||||
|
Loading…
Reference in New Issue
Block a user