Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* Code clean up and polish.

  • Loading branch information...
commit 81af0da05c9dd334a9979f5f0829353feed27cbe 1 parent 613eacd
@bobbens bobbens authored
Showing with 25 additions and 27 deletions.
  1. +5 −5 src/equipment.c
  2. +19 −21 src/pilot_outfit.c
  3. +1 −1  src/pilot_outfit.h
View
10 src/equipment.c
@@ -409,7 +409,7 @@ static void equipment_renderColumn( double x, double y, double w, double h,
else {
if ((o != NULL) &&
(lst[i].sslot->slot.type == o->slot.type)) {
- if (pilot_canEquip( p, &lst[i], o, 1 ) != NULL)
+ if (pilot_canEquip( p, &lst[i], o ) != NULL)
c = &cRed;
else
c = &cDConsole;
@@ -613,7 +613,7 @@ static void equipment_renderOverlayColumn( double x, double y, double w, double
if ((i==mover) && (wgt->canmodify)) {
if (lst[i].outfit != NULL) {
top = 1;
- display = pilot_canEquip( wgt->selected, &lst[i], lst[i].outfit, 0 );
+ display = pilot_canEquip( wgt->selected, &lst[i], NULL );
if (display != NULL)
c = &cRed;
else {
@@ -624,7 +624,7 @@ static void equipment_renderOverlayColumn( double x, double y, double w, double
else if ((wgt->outfit != NULL) &&
(lst->sslot->slot.type == wgt->outfit->slot.type)) {
top = 0;
- display = pilot_canEquip( wgt->selected, &lst[i], wgt->outfit, 1 );
+ display = pilot_canEquip( wgt->selected, &lst[i], wgt->outfit );
if (display != NULL)
c = &cRed;
else {
@@ -1066,7 +1066,7 @@ static int equipment_swapSlot( unsigned int wid, Pilot *p, PilotOutfitSlot *slot
o = slot->outfit;
/* Must be able to remove. */
- if (pilot_canEquip( eq_wgt.selected, slot, o, 0 ) != NULL)
+ if (pilot_canEquip( eq_wgt.selected, slot, NULL ) != NULL)
return 0;
/* Remove ammo first. */
@@ -1100,7 +1100,7 @@ static int equipment_swapSlot( unsigned int wid, Pilot *p, PilotOutfitSlot *slot
return 0;
/* Must be able to add. */
- if (pilot_canEquip( eq_wgt.selected, slot, o, 1 ) != NULL)
+ if (pilot_canEquip( eq_wgt.selected, slot, o ) != NULL)
return 0;
/* Add outfit to ship. */
View
40 src/pilot_outfit.c
@@ -364,7 +364,7 @@ int pilot_addOutfitTest( Pilot* pilot, Outfit* outfit, PilotOutfitSlot *s, int w
pilot->name, outfit->name );
return -1;
}
- else if ((str = pilot_canEquip( pilot, s, outfit, 1)) != NULL) {
+ else if ((str = pilot_canEquip( pilot, s, outfit)) != NULL) {
if (warn)
WARN( "Pilot '%s': Trying to add outfit but %s",
pilot->name, str );
@@ -449,7 +449,7 @@ int pilot_rmOutfit( Pilot* pilot, PilotOutfitSlot *s )
const char *str;
int ret;
- str = pilot_canEquip( pilot, s, s->outfit, 0 );
+ str = pilot_canEquip( pilot, s, NULL );
if (str != NULL) {
WARN("Pilot '%s': Trying to remove outfit but %s",
pilot->name, str );
@@ -543,37 +543,35 @@ static int pilot_hasOutfitLimit( Pilot *p, const char *limit )
*
* @param p Pilot to check if can equip.
* @param s Slot being checked to see if it can equip/remove an outfit.
- * @param o Outfit to check.
- * @param add Whether or not to consider it's being added or removed.
+ * @param o Outfit to check (NULL if being removed).
* @return NULL if can swap, or error message if can't.
*/
-const char* pilot_canEquip( Pilot *p, PilotOutfitSlot *s, Outfit *o, int add )
+const char* pilot_canEquip( Pilot *p, PilotOutfitSlot *s, Outfit *o )
{
Outfit *o_old;
const char *err;
/* Just in case. */
- if ((p==NULL) || (o==NULL))
+ if ((p==NULL) || (s==NULL))
return "Nothing selected.";
- /* Check slot type. */
- if ((s != NULL) && !outfit_fitsSlot( o, &s->sslot->slot ))
- return "Does not fit slot.";
-
- /* Check outfit limit. */
- if (add && (o->limit != NULL) && pilot_hasOutfitLimit( p, o->limit ))
- return "Already have an outfit of this type installed";
-
- /* Check fighter bay. */
- if (!add && (s!=NULL) && (s->u.ammo.deployed > 0))
- return "Recall the fighters first";
+ if (o!=NULL) {
+ /* Check slot type. */
+ if (!outfit_fitsSlot( o, &s->sslot->slot ))
+ return "Does not fit slot.";
+ /* Check outfit limit. */
+ if ((o->limit != NULL) && pilot_hasOutfitLimit( p, o->limit ))
+ return "Already have an outfit of this type installed";
+ }
+ else {
+ /* Check fighter bay. */
+ if ((o==NULL) && (s!=NULL) && (s->u.ammo.deployed > 0))
+ return "Recall the fighters first";
+ }
/* Swap outfit. */
o_old = s->outfit;
- if (add)
- s->outfit = o;
- else
- s->outfit = NULL;
+ s->outfit = o;
/* Check sanity. */
pilot_calcStats( p );
View
2  src/pilot_outfit.h
@@ -27,7 +27,7 @@ int pilot_maxAmmo( Pilot* pilot );
/* Checks. */
const char* pilot_checkSanity( Pilot *p );
-const char* pilot_canEquip( Pilot *p, PilotOutfitSlot *s, Outfit *o, int add );
+const char* pilot_canEquip( Pilot *p, PilotOutfitSlot *s, Outfit *o );
/* Lockons. */
void pilot_lockUpdateSlot( Pilot *p, PilotOutfitSlot *o, Pilot *t, double *a, double dt );
Please sign in to comment.
Something went wrong with that request. Please try again.