Resubmitting fix for fail-to-buy multiple mount lasers, this time properly (I hope). Apologies for the previous mess.

This commit is contained in:
AnotherCommander 2018-11-18 10:53:34 +01:00
parent 81ec5bd9e0
commit 5cbf9c85e8

View File

@ -10127,7 +10127,6 @@ static NSString *last_outfitting_key=nil;
double priceFactor = 1.0;
OOCreditsQuantity tradeIn = 0;
BOOL isRepair = NO;
NSUInteger multiplier = 1;
// repairs cost 50%
if ([self hasEquipmentItem:eqKeyDamaged])
@ -10143,45 +10142,6 @@ static NSString *last_outfitting_key=nil;
price = [self adjustPriceByScriptForEqKey:eqKey withCurrent:price];
// apply the multiple laser multiplier
if ([eqType isPrimaryWeapon])
{
switch (chosen_weapon_facing)
{
case WEAPON_FACING_FORWARD:
if (_multiplyWeapons)
{
multiplier = [forwardWeaponOffset count];
}
break;
case WEAPON_FACING_AFT:
if (_multiplyWeapons)
{
multiplier = [aftWeaponOffset count];
}
break;
case WEAPON_FACING_PORT:
if (_multiplyWeapons)
{
multiplier = [portWeaponOffset count];
}
break;
case WEAPON_FACING_STARBOARD:
if (_multiplyWeapons)
{
multiplier = [starboardWeaponOffset count];
}
break;
case WEAPON_FACING_NONE:
break;
}
price *= multiplier;
}
StationEntity *dockedStation = [self dockedStation];
if (dockedStation)
{
@ -10192,7 +10152,6 @@ static NSString *last_outfitting_key=nil;
if (price > credits)
{
// not enough money
return NO;
}
@ -10207,33 +10166,76 @@ static NSString *last_outfitting_key=nil;
OOWeaponType chosen_weapon = OOWeaponTypeFromEquipmentIdentifierStrict(eqKey);
OOWeaponType current_weapon = nil;
NSUInteger multiplier = 1;
switch (chosen_weapon_facing)
{
case WEAPON_FACING_FORWARD:
current_weapon = forward_weapon_type;
forward_weapon_type = chosen_weapon;
if (_multiplyWeapons)
{
multiplier = [forwardWeaponOffset count];
}
break;
case WEAPON_FACING_AFT:
current_weapon = aft_weapon_type;
aft_weapon_type = chosen_weapon;
if (_multiplyWeapons)
{
multiplier = [aftWeaponOffset count];
}
break;
case WEAPON_FACING_PORT:
current_weapon = port_weapon_type;
port_weapon_type = chosen_weapon;
if (_multiplyWeapons)
{
multiplier = [portWeaponOffset count];
}
break;
case WEAPON_FACING_STARBOARD:
current_weapon = starboard_weapon_type;
starboard_weapon_type = chosen_weapon;
if (_multiplyWeapons)
{
multiplier = [starboardWeaponOffset count];
}
break;
case WEAPON_FACING_NONE:
break;
}
// we've already checked for price being less than available credits, so we're good to go here
price *= multiplier;
if (price > credits)
{
// not enough money - ensure that weapon
// type is reset to what it was before
// the attempt to buy took place
switch (chosen_weapon_facing)
{
case WEAPON_FACING_FORWARD:
forward_weapon_type = current_weapon;
break;
case WEAPON_FACING_AFT:
aft_weapon_type = current_weapon;
break;
case WEAPON_FACING_PORT:
port_weapon_type = current_weapon;
break;
case WEAPON_FACING_STARBOARD:
starboard_weapon_type = current_weapon;
break;
case WEAPON_FACING_NONE:
break;
}
return NO;
}
credits -= price;
// Refund current_weapon