Fix for trade-ins (like selling missiles or replacing lasers) not working.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1272 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Nikos Barkas 2007-12-13 10:54:44 +00:00
parent 3e845c4299
commit 1dd0b50f52
2 changed files with 17 additions and 12 deletions

View File

@ -626,6 +626,7 @@ typedef enum
- (OOGUIScreenID) guiScreen;
- (void) buySelectedItem;
- (void) doTradeIn:(OOCreditsQuantity)tradeInValue forPriceFactor:(double)priceFactor;
- (BOOL) tryBuyingItem:(int) index;
- (BOOL) marketFlooded:(int) index;
- (BOOL) tryBuyingCommodity:(int) index;

View File

@ -5188,7 +5188,6 @@ static int last_outfitting_index;
double price_factor = 1.0;
OOCargoQuantity cargo_space = max_cargo - current_cargo;
OOCreditsQuantity tradeIn = 0;
BOOL done = NO;
// repairs cost 50%
if ([self hasExtraEquipment:eq_key_damaged])
@ -5290,7 +5289,7 @@ static int last_outfitting_index;
case WEAPON_NONE :
break;
}
[self doTradeIn:tradeIn forPriceFactor:price_factor];
[self setGuiToEquipShipScreen:-1:-1];
return YES;
}
@ -5333,6 +5332,7 @@ static int last_outfitting_index;
default :
break;
}
[self doTradeIn:tradeIn forPriceFactor:price_factor];
}
// maintain ship
@ -5406,6 +5406,7 @@ static int last_outfitting_index;
}
}
missiles = 0;
[self doTradeIn:tradeIn forPriceFactor:price_factor];
[self setGuiToEquipShipScreen:-1:-1];
return YES;
}
@ -5420,18 +5421,21 @@ static int last_outfitting_index;
[self addExtraEquipment:eq_key];
[self setGuiToEquipShipScreen:-1:-1];
done = YES;
break;
return YES;
}
}
if (tradeIn != 0)
{
if (price_factor < 1.0f) tradeIn *= price_factor;
credits += tradeIn;
}
return NO;
}
return done;
-(void) doTradeIn:(OOCreditsQuantity)tradeInValue forPriceFactor:(double)priceFactor
{
if (tradeInValue != 0)
{
if (priceFactor < 1.0f) tradeInValue *= priceFactor;
credits += tradeInValue;
}
}