Fixed damaged equipment handling.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1692 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
fb3b2b7ebe
commit
51748cae1c
@ -583,7 +583,7 @@ waitingForStickCallback: 1;
|
|||||||
- (void) docked;
|
- (void) docked;
|
||||||
|
|
||||||
- (void) setGuiToStatusScreen;
|
- (void) setGuiToStatusScreen;
|
||||||
- (NSArray *) equipmentList;
|
- (NSArray *) equipmentList; // Each entry is an array with a string followed by a boolean indicating availability (NO = damaged).
|
||||||
- (NSArray *) cargoList;
|
- (NSArray *) cargoList;
|
||||||
- (void) setGuiToSystemDataScreen;
|
- (void) setGuiToSystemDataScreen;
|
||||||
- (NSArray *) markedDestinations;
|
- (NSArray *) markedDestinations;
|
||||||
|
@ -3996,31 +3996,45 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
NSMutableArray *quip = [NSMutableArray arrayWithCapacity:[eqTypes count]];
|
NSMutableArray *quip = [NSMutableArray arrayWithCapacity:[eqTypes count]];
|
||||||
NSEnumerator *eqTypeEnum = nil;
|
NSEnumerator *eqTypeEnum = nil;
|
||||||
OOEquipmentType *eqType = nil;
|
OOEquipmentType *eqType = nil;
|
||||||
|
NSString *desc = nil;
|
||||||
|
|
||||||
for (eqTypeEnum = [eqTypes objectEnumerator]; (eqType = [eqTypeEnum nextObject]); )
|
for (eqTypeEnum = [eqTypes objectEnumerator]; (eqType = [eqTypeEnum nextObject]); )
|
||||||
{
|
{
|
||||||
if ([self hasEquipmentItem:[eqType identifier]])
|
if ([self hasEquipmentItem:[eqType identifier]])
|
||||||
{
|
{
|
||||||
[quip addObject:[eqType name]];
|
[quip addObject:[NSArray arrayWithObjects:[eqType name], [NSNumber numberWithBool:YES], nil]];
|
||||||
}
|
}
|
||||||
else if (![UNIVERSE strict])
|
else if (![UNIVERSE strict])
|
||||||
{
|
{
|
||||||
// Check for damaged version
|
// Check for damaged version
|
||||||
if ([self hasEquipmentItem:[[eqType identifier] stringByAppendingString:@"_DAMAGED"]])
|
if ([self hasEquipmentItem:[[eqType identifier] stringByAppendingString:@"_DAMAGED"]])
|
||||||
{
|
{
|
||||||
[quip addObject:[NSString stringWithFormat:DESC(@"equipment-@-not-available"), [eqType name]]];
|
desc = [NSString stringWithFormat:DESC(@"equipment-@-not-available"), [eqType name]];
|
||||||
|
[quip addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:NO], nil]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forward_weapon > WEAPON_NONE)
|
if (forward_weapon > WEAPON_NONE)
|
||||||
[quip addObject:[NSString stringWithFormat:DESC(@"equipment-fwd-weapon-@"),[UNIVERSE descriptionForArrayKey:@"weapon_name" index:forward_weapon]]];
|
{
|
||||||
|
desc = [NSString stringWithFormat:DESC(@"equipment-fwd-weapon-@"),[UNIVERSE descriptionForArrayKey:@"weapon_name" index:forward_weapon]];
|
||||||
|
[quip addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:YES], nil]];
|
||||||
|
}
|
||||||
if (aft_weapon > WEAPON_NONE)
|
if (aft_weapon > WEAPON_NONE)
|
||||||
[quip addObject:[NSString stringWithFormat:DESC(@"equipment-aft-weapon-@"),[UNIVERSE descriptionForArrayKey:@"weapon_name" index:aft_weapon]]];
|
{
|
||||||
|
desc = [NSString stringWithFormat:DESC(@"equipment-aft-weapon-@"),[UNIVERSE descriptionForArrayKey:@"weapon_name" index:aft_weapon]];
|
||||||
|
[quip addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:YES], nil]];
|
||||||
|
}
|
||||||
if (starboard_weapon > WEAPON_NONE)
|
if (starboard_weapon > WEAPON_NONE)
|
||||||
[quip addObject:[NSString stringWithFormat:DESC(@"equipment-stb-weapon-@"),[UNIVERSE descriptionForArrayKey:@"weapon_name" index:starboard_weapon]]];
|
{
|
||||||
|
desc = [NSString stringWithFormat:DESC(@"equipment-stb-weapon-@"),[UNIVERSE descriptionForArrayKey:@"weapon_name" index:starboard_weapon]];
|
||||||
|
[quip addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:YES], nil]];
|
||||||
|
}
|
||||||
if (port_weapon > WEAPON_NONE)
|
if (port_weapon > WEAPON_NONE)
|
||||||
[quip addObject:[NSString stringWithFormat:DESC(@"equipment-port-weapon-@"),[UNIVERSE descriptionForArrayKey:@"weapon_name" index:port_weapon]]];
|
{
|
||||||
|
desc = [NSString stringWithFormat:DESC(@"equipment-port-weapon-@"),[UNIVERSE descriptionForArrayKey:@"weapon_name" index:port_weapon]];
|
||||||
|
[quip addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:YES], nil]];
|
||||||
|
}
|
||||||
|
|
||||||
if (max_passengers > 0)
|
if (max_passengers > 0)
|
||||||
{
|
{
|
||||||
@ -4028,12 +4042,13 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
// may have quite different ways of phrasing the two.
|
// may have quite different ways of phrasing the two.
|
||||||
if (max_passengers > 1)
|
if (max_passengers > 1)
|
||||||
{
|
{
|
||||||
[quip addObject:[NSString stringWithFormat:DESC(@"equipment-multiple-pass-berth-@"), max_passengers]];
|
desc = [NSString stringWithFormat:DESC(@"equipment-multiple-pass-berth-@"), max_passengers];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[quip addObject:DESC(@"equipment-single-pass-berth-@")];
|
desc = DESC(@"equipment-single-pass-berth-@");
|
||||||
}
|
}
|
||||||
|
[quip addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:YES], nil]];
|
||||||
}
|
}
|
||||||
|
|
||||||
return quip;
|
return quip;
|
||||||
|
@ -1240,7 +1240,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
|||||||
OOLog(kOOLogSyntaxAwardEquipment, @"SCRIPT ERROR in %@ ***** CANNOT award undamaged weapon:'%@'. Damaged weapons can be awarded instead.", CurrentScriptDesc(), equipString);
|
OOLog(kOOLogSyntaxAwardEquipment, @"SCRIPT ERROR in %@ ***** CANNOT award undamaged weapon:'%@'. Damaged weapons can be awarded instead.", CurrentScriptDesc(), equipString);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ([equipString hasSuffix:@"_DAMAGED"] && [self hasEquipmentItem:[equipString substringToIndex:[equipString length]-8]])
|
if ([equipString hasSuffix:@"_DAMAGED"] && [self hasEquipmentItem:[equipString substringToIndex:[equipString length] - [@"_DAMAGED" length]]])
|
||||||
{
|
{
|
||||||
OOLog(kOOLogSyntaxAwardEquipment, @"SCRIPT ERROR in %@ ***** CANNOT award damaged equipment:'%@'. Undamaged version already equipped.", CurrentScriptDesc(), equipString);
|
OOLog(kOOLogSyntaxAwardEquipment, @"SCRIPT ERROR in %@ ***** CANNOT award damaged equipment:'%@'. Undamaged version already equipped.", CurrentScriptDesc(), equipString);
|
||||||
}
|
}
|
||||||
|
@ -1683,6 +1683,11 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
|||||||
{
|
{
|
||||||
OOEquipmentType *eqType = nil;
|
OOEquipmentType *eqType = nil;
|
||||||
|
|
||||||
|
if ([equipmentKey hasSuffix:@"_DAMAGED"])
|
||||||
|
{
|
||||||
|
equipmentKey = [equipmentKey substringToIndex:[equipmentKey length] - [@"_DAMAGED" length]];
|
||||||
|
}
|
||||||
|
|
||||||
eqType = [OOEquipmentType equipmentTypeWithIdentifier:equipmentKey];
|
eqType = [OOEquipmentType equipmentTypeWithIdentifier:equipmentKey];
|
||||||
if (eqType == nil) return NO;
|
if (eqType == nil) return NO;
|
||||||
|
|
||||||
|
@ -762,18 +762,22 @@ OOINLINE BOOL RowInRange(OOGUIRow row, NSRange range)
|
|||||||
for (i=0; i < equipment_list_items_count; i++)
|
for (i=0; i < equipment_list_items_count; i++)
|
||||||
{
|
{
|
||||||
// Damaged items in the equipment list appear in orange color.
|
// Damaged items in the equipment list appear in orange color.
|
||||||
BOOL is_eqpt_damaged = [[eqptList objectAtIndex:i] hasSuffix:DESC(@"equipment-not-available")];
|
NSArray *info = [eqptList objectAtIndex:i];
|
||||||
if (is_eqpt_damaged == YES) glColor4f (1.0f, 0.5f, 0.0f, 1.0f);
|
NSString *name = [info stringAtIndex:0];
|
||||||
|
BOOL damaged = ![info boolAtIndex:1];
|
||||||
|
|
||||||
|
if (damaged) glColor4f (1.0f, 0.5f, 0.0f, 1.0f);
|
||||||
|
|
||||||
if (i < eqpt_items_per_column)
|
if (i < eqpt_items_per_column)
|
||||||
{
|
{
|
||||||
drawString ([eqptList objectAtIndex:i], -220, 40 - (15 * i), z, NSMakeSize(15,15));
|
drawString (name, -220, 40 - (15 * i), z, NSMakeSize(15, 15));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
drawString ([eqptList objectAtIndex:i], 50, 40 - (15 * (i - eqpt_items_per_column)), z, NSMakeSize(15,15));
|
drawString (name, 50, 40 - (15 * (i - eqpt_items_per_column)), z, NSMakeSize(15, 15));
|
||||||
}
|
}
|
||||||
glColor4f (1.0f, 1.0f, 0.0f, 1.0f); // Reset text color to yellow.
|
|
||||||
|
if (damaged) glColor4f (1.0f, 1.0f, 0.0f, 1.0f); // Reset text color to yellow.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7233,6 +7233,8 @@ double estimatedTimeForJourney(double distance, int hops)
|
|||||||
if (passenger_berths == 0)
|
if (passenger_berths == 0)
|
||||||
{
|
{
|
||||||
// This will be needed to construct the description for passenger berths.
|
// This will be needed to construct the description for passenger berths.
|
||||||
|
// Note: use of lowercaseString is bad from an i18n perspective,
|
||||||
|
// but the string is never actually shown anyway...
|
||||||
passengerBerthLongDesc = [NSString stringWithFormat:@"%@", [eqLongDesc lowercaseString]];
|
passengerBerthLongDesc = [NSString stringWithFormat:@"%@", [eqLongDesc lowercaseString]];
|
||||||
}
|
}
|
||||||
passenger_berths++;
|
passenger_berths++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user