Refactored equipment restriction tests, and apply them in addEquipmentItem: as well as the shopping screen. Added new class representing equipment types, currently only used in these tests. Added new equipment restrictions: requires_free_passenger_berth, requires_full_fuel, requires_non_full_fuel.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1689 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
53e5244d68
commit
a8b39c4c9a
@ -26,7 +26,7 @@ endif
|
||||
OBJC_PROGRAM_NAME = oolite
|
||||
|
||||
oolite_C_FILES = legacy_random.c strlcpy.c OOTCPStreamDecoder.c
|
||||
oolite_OBJC_FILES = OOCocoa.m Comparison.m AI.m DustEntity.m Entity.m GameController.m GuiDisplayGen.m HeadUpDisplay.m main.m MyOpenGLView.m OpenGLSprite.m ParticleEntity.m PlanetEntity.m PlayerEntityLegacyScriptEngine.m PlayerEntityContracts.m PlayerEntityControls.m PlayerEntityLoadSave.m PlayerEntitySound.m PlayerEntity.m ResourceManager.m RingEntity.m ShipEntityAI.m ShipEntity.m SkyEntity.m StationEntity.m Universe.m OOSound.m SDLMusic.m NSFileManagerOOExtensions.m JoystickHandler.m PlayerEntityStickMapper.m OOBasicSoundReferencePoint.m OOBasicSoundSource.m OOCharacter.m OOTrumble.m WormholeEntity.m NSScannerOOExtensions.m OOXMLExtensions.m NSMutableDictionaryOOExtensions.m Geometry.m Octree.m CollisionRegion.m OOColor.m OOLogging.m OOCacheManager.m OOCache.m OOStringParsing.m OOCollectionExtractors.m OOVector.m OOMatrix.m OOQuaternion.m OOVoxel.m OOTriangle.m OOPListParsing.m OOFastArithmetic.m OOTextureScaling.m OOConstToString.m OOScript.m OOJSScript.m OOJavaScriptEngine.m OOPListScript.m NSStringOOExtensions.m PlayerEntityScriptMethods.m OOWeakReference.m OOJSEntity.m EntityOOJavaScriptExtensions.m OOJSQuaternion.m OOMaterial.m OOShaderMaterial.m OOShaderProgram.m OOShaderUniform.m OOTexture.m OOTextureLoader.m OOPNGTextureLoader.m OOOpenGLExtensionManager.m OOBasicMaterial.m OOSingleTextureMaterial.m OOCPUInfo.m OOSelfDrawingEntity.m OOEntityWithDrawable.m OODrawable.m OOJSVector.m OOMesh.m OOOpenGL.m OOGraphicsResetManager.m OOProbabilisticTextureManager.m OODebugGLDrawing.m OOShaderUniformMethodType.m OOAsyncQueue.m TextureStore.m OOOXPVerifier.m OOOXPVerifierStage.m OOFileScannerVerifierStage.m OOCheckRequiresPListVerifierStage.m OOCheckDemoShipsPListVerifierStage.m OOCheckEquipmentPListVerifierStage.m OOTextureVerifierStage.m OOModelVerifierStage.m OOCheckShipDataPListVerifierStage.m OOPListSchemaVerifier.m OOJSShip.m OOJSPlayer.m OOJSCall.m OOJSStation.m OOJSSystem.m OOLegacyEventHandlerScript.m OOJSOolite.m OORoleSet.m OOJSGlobal.m OOJSMissionVariables.m OOJSMission.m OOPriorityQueue.m OOScriptTimer.m OOJSTimer.m OOJSClock.m OODebugSupport.m OODebugMonitor.m OOJSConsole.m OODebugTCPConsoleClient.m OOTCPStreamDecoderAbstractionLayer.m OOEntityFilterPredicate.m OOJSPlanet.m OOJSWorldScripts.m OOJSSun.m NSThreadOOExtensions.m OOEncodingConverter.m OOJSSound.m OOJSSoundSource.m OOMusicController.m OOLogHeader.m OOJSSpecialFunctions.m OOSpatialReference.m OOSkyDrawable.m OOFilteringEnumerator.m OOSoundSourcePool.m ShipEntityScriptMethods.m OOShipRegistry.m OOProbabilitySet.m OOJSSystemInfo.m NSDictionaryOOExtensions.m
|
||||
oolite_OBJC_FILES = OOCocoa.m Comparison.m AI.m DustEntity.m Entity.m GameController.m GuiDisplayGen.m HeadUpDisplay.m main.m MyOpenGLView.m OpenGLSprite.m ParticleEntity.m PlanetEntity.m PlayerEntityLegacyScriptEngine.m PlayerEntityContracts.m PlayerEntityControls.m PlayerEntityLoadSave.m PlayerEntitySound.m PlayerEntity.m ResourceManager.m RingEntity.m ShipEntityAI.m ShipEntity.m SkyEntity.m StationEntity.m Universe.m OOSound.m SDLMusic.m NSFileManagerOOExtensions.m JoystickHandler.m PlayerEntityStickMapper.m OOBasicSoundReferencePoint.m OOBasicSoundSource.m OOCharacter.m OOTrumble.m WormholeEntity.m NSScannerOOExtensions.m OOXMLExtensions.m NSMutableDictionaryOOExtensions.m Geometry.m Octree.m CollisionRegion.m OOColor.m OOLogging.m OOCacheManager.m OOCache.m OOStringParsing.m OOCollectionExtractors.m OOVector.m OOMatrix.m OOQuaternion.m OOVoxel.m OOTriangle.m OOPListParsing.m OOFastArithmetic.m OOTextureScaling.m OOConstToString.m OOScript.m OOJSScript.m OOJavaScriptEngine.m OOPListScript.m NSStringOOExtensions.m PlayerEntityScriptMethods.m OOWeakReference.m OOJSEntity.m EntityOOJavaScriptExtensions.m OOJSQuaternion.m OOMaterial.m OOShaderMaterial.m OOShaderProgram.m OOShaderUniform.m OOTexture.m OOTextureLoader.m OOPNGTextureLoader.m OOOpenGLExtensionManager.m OOBasicMaterial.m OOSingleTextureMaterial.m OOCPUInfo.m OOSelfDrawingEntity.m OOEntityWithDrawable.m OODrawable.m OOJSVector.m OOMesh.m OOOpenGL.m OOGraphicsResetManager.m OOProbabilisticTextureManager.m OODebugGLDrawing.m OOShaderUniformMethodType.m OOAsyncQueue.m TextureStore.m OOOXPVerifier.m OOOXPVerifierStage.m OOFileScannerVerifierStage.m OOCheckRequiresPListVerifierStage.m OOCheckDemoShipsPListVerifierStage.m OOCheckEquipmentPListVerifierStage.m OOTextureVerifierStage.m OOModelVerifierStage.m OOCheckShipDataPListVerifierStage.m OOPListSchemaVerifier.m OOJSShip.m OOJSPlayer.m OOJSCall.m OOJSStation.m OOJSSystem.m OOLegacyEventHandlerScript.m OOJSOolite.m OORoleSet.m OOJSGlobal.m OOJSMissionVariables.m OOJSMission.m OOPriorityQueue.m OOScriptTimer.m OOJSTimer.m OOJSClock.m OODebugSupport.m OODebugMonitor.m OOJSConsole.m OODebugTCPConsoleClient.m OOTCPStreamDecoderAbstractionLayer.m OOEntityFilterPredicate.m OOJSPlanet.m OOJSWorldScripts.m OOJSSun.m NSThreadOOExtensions.m OOEncodingConverter.m OOJSSound.m OOJSSoundSource.m OOMusicController.m OOLogHeader.m OOJSSpecialFunctions.m OOSpatialReference.m OOSkyDrawable.m OOFilteringEnumerator.m OOSoundSourcePool.m ShipEntityScriptMethods.m OOShipRegistry.m OOProbabilitySet.m OOJSSystemInfo.m NSDictionaryOOExtensions.m OOEquipmentType.m
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/objc.make
|
||||
include GNUmakefile.postamble
|
||||
|
@ -403,6 +403,8 @@
|
||||
1A5E46300C32DACE008104B4 /* OOShaderUniformMethodType.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5E462E0C32DACE008104B4 /* OOShaderUniformMethodType.h */; };
|
||||
1A60AFB70D56093B0070510D /* OOMusicController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A60AFB50D56093B0070510D /* OOMusicController.h */; };
|
||||
1A60AFB80D56093B0070510D /* OOMusicController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A60AFB60D56093B0070510D /* OOMusicController.m */; };
|
||||
1A62F0FD0E26A2A000897506 /* OOEquipmentType.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A62F0FB0E26A2A000897506 /* OOEquipmentType.m */; };
|
||||
1A62F0FE0E26A2A000897506 /* OOEquipmentType.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A62F0FC0E26A2A000897506 /* OOEquipmentType.h */; };
|
||||
1A6515100CCC9E2E0054D01B /* oolite-standard-vertex.vertex in Copy Shaders */ = {isa = PBXBuildFile; fileRef = 1A65150D0CCC9E220054D01B /* oolite-standard-vertex.vertex */; };
|
||||
1A6515110CCC9E2E0054D01B /* oolite-default-shader.fragment in Copy Shaders */ = {isa = PBXBuildFile; fileRef = 1A65150E0CCC9E220054D01B /* oolite-default-shader.fragment */; };
|
||||
1A6B1EF00C9AA5C6000717CF /* OOScriptTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6B1EEE0C9AA5C6000717CF /* OOScriptTimer.h */; };
|
||||
@ -1414,6 +1416,8 @@
|
||||
1A5E462E0C32DACE008104B4 /* OOShaderUniformMethodType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOShaderUniformMethodType.h; sourceTree = "<group>"; };
|
||||
1A60AFB50D56093B0070510D /* OOMusicController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOMusicController.h; sourceTree = "<group>"; };
|
||||
1A60AFB60D56093B0070510D /* OOMusicController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOMusicController.m; sourceTree = "<group>"; };
|
||||
1A62F0FB0E26A2A000897506 /* OOEquipmentType.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOEquipmentType.m; sourceTree = "<group>"; };
|
||||
1A62F0FC0E26A2A000897506 /* OOEquipmentType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOEquipmentType.h; sourceTree = "<group>"; };
|
||||
1A65150D0CCC9E220054D01B /* oolite-standard-vertex.vertex */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "oolite-standard-vertex.vertex"; sourceTree = "<group>"; };
|
||||
1A65150E0CCC9E220054D01B /* oolite-default-shader.fragment */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "oolite-default-shader.fragment"; sourceTree = "<group>"; };
|
||||
1A6B1EEE0C9AA5C6000717CF /* OOScriptTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOScriptTimer.h; sourceTree = "<group>"; };
|
||||
@ -2327,7 +2331,7 @@
|
||||
1A8A3C1B0B96407A007D20B8 /* User Interface */,
|
||||
1A8A3BFB0B963F91007D20B8 /* Utilities */,
|
||||
1A8A3BF20B963F3C007D20B8 /* Mac-specific */,
|
||||
1ACEA3BC0C915A1600C7CE97 /* Ship management */,
|
||||
1ACEA3BC0C915A1600C7CE97 /* Item management */,
|
||||
1A3A04610BC547DC00B5E2D9 /* OOTypes.h */,
|
||||
25161144099544390037C2E1 /* Universe.h */,
|
||||
25161143099544390037C2E1 /* Universe.m */,
|
||||
@ -2617,15 +2621,17 @@
|
||||
path = Doc;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1ACEA3BC0C915A1600C7CE97 /* Ship management */ = {
|
||||
1ACEA3BC0C915A1600C7CE97 /* Item management */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1ACEA3470C91507000C7CE97 /* OORoleSet.h */,
|
||||
1ACEA3480C91507000C7CE97 /* OORoleSet.m */,
|
||||
1A0479E70DC9F81000EE1CD0 /* OOShipRegistry.h */,
|
||||
1A0479E80DC9F81000EE1CD0 /* OOShipRegistry.m */,
|
||||
1A62F0FC0E26A2A000897506 /* OOEquipmentType.h */,
|
||||
1A62F0FB0E26A2A000897506 /* OOEquipmentType.m */,
|
||||
);
|
||||
name = "Ship management";
|
||||
name = "Item management";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1AD0C6B90C47B70F0070BD23 /* Smart Crash Reports */ = {
|
||||
@ -2879,6 +2885,7 @@
|
||||
1A047A450DCA0F4F00EE1CD0 /* NSDictionaryOOExtensions.h in Headers */,
|
||||
1A047B7E0DCB3D7500EE1CD0 /* OOProbabilitySet.h in Headers */,
|
||||
1A9322970DF53C33003FD306 /* OOJSSystemInfo.h in Headers */,
|
||||
1A62F0FE0E26A2A000897506 /* OOEquipmentType.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -3229,6 +3236,7 @@
|
||||
1A047A460DCA0F4F00EE1CD0 /* NSDictionaryOOExtensions.m in Sources */,
|
||||
1A047B7F0DCB3D7500EE1CD0 /* OOProbabilitySet.m in Sources */,
|
||||
1A9322980DF53C33003FD306 /* OOJSSystemInfo.m in Sources */,
|
||||
1A62F0FD0E26A2A000897506 /* OOEquipmentType.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -11,6 +11,8 @@
|
||||
<dict>
|
||||
<key>available_to_all</key>
|
||||
<true/>
|
||||
<key>requires_non_full_fuel</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</array>
|
||||
<array>
|
||||
|
@ -105,7 +105,7 @@ this.addToScreen = function ()
|
||||
|
||||
this.missionOffers = function ()
|
||||
{
|
||||
if (guiScreen == "GUI_SCREEN_MISSION" || (mission.choice && mission.choice != "")) return;
|
||||
if (guiScreen == "GUI_SCREEN_MISSION" || (mission.choice && mission.choice != "") || !player.docked) return;
|
||||
|
||||
// there will be a "missionScreenEnded" or a "missionChoiceWasReset" in future to react to.
|
||||
if (player.dockedStation.isMainStation)
|
||||
|
@ -45,7 +45,7 @@ MA 02110-1301, USA.
|
||||
NSDictionary *stateMachine;
|
||||
NSString *stateMachineName;
|
||||
NSString *currentState;
|
||||
NSMutableDictionary *pendingMessages;
|
||||
NSMutableSet *pendingMessages;
|
||||
|
||||
NSMutableArray *aiStack;
|
||||
|
||||
|
@ -84,7 +84,7 @@ static AI *sCurrentlyRunningAI = nil;
|
||||
self = [super init];
|
||||
|
||||
aiStack = [[NSMutableArray alloc] init];
|
||||
pendingMessages = [[NSMutableDictionary alloc] init];
|
||||
pendingMessages = [[NSMutableSet alloc] init];
|
||||
|
||||
nextThinkTime = [[NSDate distantFuture] timeIntervalSinceNow]; // don't think for a while
|
||||
thinkTimeInterval = AI_THINK_INTERVAL;
|
||||
@ -211,7 +211,7 @@ static AI *sCurrentlyRunningAI = nil;
|
||||
stateMachineName = [[pickledMachine objectForKey:@"stateMachineName"] retain];
|
||||
|
||||
[pendingMessages release];
|
||||
pendingMessages = [[pickledMachine objectForKey:@"pendingMessages"] mutableCopy]; // restore a MUTABLE array
|
||||
pendingMessages = [[pickledMachine objectForKey:@"pendingMessages"] mutableCopy]; // restore a MUTABLE set
|
||||
|
||||
[aiStack removeObjectAtIndex:0]; // POP
|
||||
}
|
||||
@ -473,15 +473,8 @@ static AI *sCurrentlyRunningAI = nil;
|
||||
|
||||
[self reactToMessage:@"UPDATE"];
|
||||
|
||||
if (pendingMessages != nil)
|
||||
{
|
||||
if ([pendingMessages count] > 0)
|
||||
{
|
||||
ms_list = [pendingMessages allKeys];
|
||||
}
|
||||
|
||||
[pendingMessages removeAllObjects];
|
||||
}
|
||||
if ([pendingMessages count] > 0) ms_list = [pendingMessages allObjects];
|
||||
[pendingMessages removeAllObjects];
|
||||
|
||||
if (ms_list != nil)
|
||||
{
|
||||
@ -504,7 +497,7 @@ static AI *sCurrentlyRunningAI = nil;
|
||||
format:@"AI pendingMessages overflow for %@", ownerDesc];
|
||||
}
|
||||
|
||||
[pendingMessages setObject: ms forKey: ms];
|
||||
[pendingMessages addObject:ms];
|
||||
}
|
||||
|
||||
|
||||
|
@ -438,13 +438,13 @@ static GLfloat texture_uv_array[10400 * 2];
|
||||
|
||||
seed_for_planet_description(p_seed);
|
||||
|
||||
NSMutableDictionary* planetinfo = [NSMutableDictionary dictionaryWithDictionary:[UNIVERSE generateSystemData:p_seed]];
|
||||
int radius_km = [[planetinfo objectForKey:KEY_RADIUS] intValue];
|
||||
int techlevel = [[planetinfo objectForKey:KEY_TECHLEVEL] intValue];
|
||||
NSMutableDictionary* planetInfo = [NSMutableDictionary dictionaryWithDictionary:[UNIVERSE generateSystemData:p_seed]];
|
||||
int radius_km = [[planetInfo objectForKey:KEY_RADIUS] intValue];
|
||||
int techlevel = [[planetInfo objectForKey:KEY_TECHLEVEL] intValue];
|
||||
|
||||
if ([planetinfo objectForKey:@"texture"])
|
||||
if ([planetInfo objectForKey:@"texture"])
|
||||
{
|
||||
textureName = [TextureStore getTextureNameFor:[planetinfo stringForKey:@"texture"]];
|
||||
textureName = [TextureStore getTextureNameFor:[planetInfo stringForKey:@"texture"]];
|
||||
isTextured = (textureName != 0);
|
||||
}
|
||||
|
||||
@ -477,7 +477,7 @@ static GLfloat texture_uv_array[10400 * 2];
|
||||
|
||||
[self rescaleTo:1.0];
|
||||
|
||||
percent_land = [planetinfo intForKey:@"percent_land" defaultValue:24 + (gen_rnd_number() % 48)];
|
||||
percent_land = [planetInfo intForKey:@"percent_land" defaultValue:24 + (gen_rnd_number() % 48)];
|
||||
|
||||
// save the current random number generator seed
|
||||
RNG_Seed saved_seed = currentRandomSeed();
|
||||
@ -489,7 +489,7 @@ static GLfloat texture_uv_array[10400 * 2];
|
||||
else
|
||||
r_seed[i] = 100; // sea
|
||||
}
|
||||
[planetinfo setObject:[NSNumber numberWithFloat:0.01 * percent_land] forKey:@"land_fraction"];
|
||||
[planetInfo setObject:[NSNumber numberWithFloat:0.01 * percent_land] forKey:@"land_fraction"];
|
||||
|
||||
polar_color_factor = 1.0;
|
||||
|
||||
@ -503,8 +503,8 @@ static GLfloat texture_uv_array[10400 * 2];
|
||||
}
|
||||
|
||||
//// possibly get land_hsb and sea_hsb from planetinfo.plist entry
|
||||
ScanVectorFromString([planetinfo objectForKey:@"land_hsb_color"], &land_hsb);
|
||||
ScanVectorFromString([planetinfo objectForKey:@"sea_hsb_color"], &sea_hsb);
|
||||
ScanVectorFromString([planetInfo objectForKey:@"land_hsb_color"], &land_hsb);
|
||||
ScanVectorFromString([planetInfo objectForKey:@"sea_hsb_color"], &sea_hsb);
|
||||
|
||||
// polar areas are brighter but have less color (closer to white)
|
||||
land_polar_hsb.x = land_hsb.x; land_polar_hsb.y = (land_hsb.y / 5.0); land_polar_hsb.z = 1.0 - (land_hsb.z / 10.0);
|
||||
@ -532,16 +532,16 @@ static GLfloat texture_uv_array[10400 * 2];
|
||||
amb_polar_sea[2] = [amb_polar_sea_color greenComponent];
|
||||
amb_polar_sea[3] = 1.0;
|
||||
|
||||
[planetinfo setObject:amb_land_color forKey:@"land_color"];
|
||||
[planetinfo setObject:amb_sea_color forKey:@"sea_color"];
|
||||
[planetinfo setObject:amb_polar_land_color forKey:@"polar_land_color"];
|
||||
[planetinfo setObject:amb_polar_sea_color forKey:@"polar_sea_color"];
|
||||
[planetInfo setObject:amb_land_color forKey:@"land_color"];
|
||||
[planetInfo setObject:amb_sea_color forKey:@"sea_color"];
|
||||
[planetInfo setObject:amb_polar_land_color forKey:@"polar_land_color"];
|
||||
[planetInfo setObject:amb_polar_sea_color forKey:@"polar_sea_color"];
|
||||
|
||||
#ifdef ALLOW_PROCEDURAL_PLANETS
|
||||
if (procGen)
|
||||
{
|
||||
fillRanNoiseBuffer();
|
||||
textureName = [TextureStore getPlanetTextureNameFor: planetinfo intoData: &textureData];
|
||||
textureName = [TextureStore getPlanetTextureNameFor: planetInfo intoData: &textureData];
|
||||
isTextured = (textureName != 0);
|
||||
isShadered = NO;
|
||||
#ifndef NO_SHADERS
|
||||
@ -554,7 +554,7 @@ static GLfloat texture_uv_array[10400 * 2];
|
||||
NSLog(@"TESTING: creating planet shader from:\n%@", shader_info);
|
||||
shader_program = [TextureStore shaderProgramFromDictionary:shader_info];
|
||||
isShadered = (shader_program != NULL_SHADER);
|
||||
normalMapTextureName = [TextureStore getPlanetNormalMapNameFor: planetinfo intoData: &normalMapTextureData];
|
||||
normalMapTextureName = [TextureStore getPlanetNormalMapNameFor: planetInfo intoData: &normalMapTextureData];
|
||||
NSLog(@"TESTING: planet-surface-shader: %d normalMapTextureName: %d", (int)shader_program, (int)normalMapTextureName);
|
||||
}
|
||||
}
|
||||
@ -581,11 +581,11 @@ static GLfloat texture_uv_array[10400 * 2];
|
||||
[self scaleVertices];
|
||||
|
||||
// set speed of rotation
|
||||
rotational_velocity = [planetinfo floatForKey:@"rotation_speed" defaultValue:0.005 * randf()]; // 0.0 .. 0.005 avr 0.0025
|
||||
rotational_velocity *= [planetinfo floatForKey:@"rotation_speed_factor" defaultValue:1.0f];
|
||||
rotational_velocity = [planetInfo floatForKey:@"rotation_speed" defaultValue:0.005 * randf()]; // 0.0 .. 0.005 avr 0.0025
|
||||
rotational_velocity *= [planetInfo floatForKey:@"rotation_speed_factor" defaultValue:1.0f];
|
||||
// do atmosphere
|
||||
|
||||
atmosphere = [[PlanetEntity alloc] initAsAtmosphereForPlanet:self dictionary:planetinfo];
|
||||
atmosphere = [[PlanetEntity alloc] initAsAtmosphereForPlanet:self dictionary:planetInfo];
|
||||
|
||||
isPlanet = YES;
|
||||
|
||||
@ -720,10 +720,10 @@ static GLfloat texture_uv_array[10400 * 2];
|
||||
|
||||
seed_for_planet_description(p_seed);
|
||||
|
||||
NSDictionary *planetinfo = [UNIVERSE generateSystemData:p_seed];
|
||||
NSDictionary *planetInfo = [UNIVERSE generateSystemData:p_seed];
|
||||
int radius_km;
|
||||
|
||||
radius_km = [dict intForKey:@"radius" defaultValue:[[planetinfo objectForKey:KEY_RADIUS] intValue]];
|
||||
radius_km = [dict intForKey:@"radius" defaultValue:[[planetInfo objectForKey:KEY_RADIUS] intValue]];
|
||||
|
||||
shuttles_on_ground = 0;
|
||||
last_launch_time = 0.0;
|
||||
@ -748,7 +748,7 @@ static GLfloat texture_uv_array[10400 * 2];
|
||||
|
||||
[self rescaleTo:1.0];
|
||||
|
||||
percent_land = [planetinfo intForKey:@"percent_land" defaultValue:24 + (gen_rnd_number() % 48)];
|
||||
percent_land = [planetInfo intForKey:@"percent_land" defaultValue:24 + (gen_rnd_number() % 48)];
|
||||
if (isTextured) percent_land = 0;
|
||||
|
||||
// save the current random number generator seed
|
||||
@ -877,10 +877,10 @@ static GLfloat texture_uv_array[10400 * 2];
|
||||
|
||||
seed_for_planet_description(p_seed);
|
||||
|
||||
NSDictionary *planetinfo = [UNIVERSE generateSystemData:p_seed];
|
||||
NSDictionary *planetInfo = [UNIVERSE generateSystemData:p_seed];
|
||||
int radius_km;
|
||||
|
||||
radius_km = [dict intForKey:@"radius" defaultValue:[[planetinfo objectForKey:KEY_RADIUS] intValue]];
|
||||
radius_km = [dict intForKey:@"radius" defaultValue:[[planetInfo objectForKey:KEY_RADIUS] intValue]];
|
||||
|
||||
shuttles_on_ground = 0;
|
||||
last_launch_time = 0.0;
|
||||
@ -905,7 +905,7 @@ static GLfloat texture_uv_array[10400 * 2];
|
||||
|
||||
[self rescaleTo:1.0];
|
||||
|
||||
percent_land = [planetinfo intForKey:@"percent_land" defaultValue:24 + (gen_rnd_number() % 48)];
|
||||
percent_land = [planetInfo intForKey:@"percent_land" defaultValue:24 + (gen_rnd_number() % 48)];
|
||||
if (isTextured) percent_land = 100;
|
||||
|
||||
// save the current random number generator seed
|
||||
|
@ -56,6 +56,7 @@ MA 02110-1301, USA.
|
||||
#import "OOMusicController.h"
|
||||
#import "OOEntityFilterPredicate.h"
|
||||
#import "OOShipRegistry.h"
|
||||
#import "OOEquipmentType.h"
|
||||
|
||||
#import "OOScript.h"
|
||||
#import "OOScriptTimer.h"
|
||||
@ -917,8 +918,8 @@ static PlayerEntity *sSharedPlayer = nil;
|
||||
|
||||
[self setSystem_seed:[UNIVERSE findSystemAtCoords:[self galaxy_coordinates] withGalaxySeed:[self galaxy_seed]]];
|
||||
|
||||
[self setGalacticHyperspaceBehaviourTo:[[UNIVERSE planetinfo] stringForKey:@"galactic_hyperspace_behaviour" defaultValue:@"GALACTIC_HYPERSPACE_BEHAVIOUR_STANDARD"]];
|
||||
[self setGalacticHyperspaceFixedCoordsTo:[[UNIVERSE planetinfo] stringForKey:@"galactic_hyperspace_fixed_coords" defaultValue:@"96 96"]];
|
||||
[self setGalacticHyperspaceBehaviourTo:[[UNIVERSE planetInfo] stringForKey:@"galactic_hyperspace_behaviour" defaultValue:@"GALACTIC_HYPERSPACE_BEHAVIOUR_STANDARD"]];
|
||||
[self setGalacticHyperspaceFixedCoordsTo:[[UNIVERSE planetInfo] stringForKey:@"galactic_hyperspace_fixed_coords" defaultValue:@"96 96"]];
|
||||
|
||||
[[OOMusicController sharedController] stop];
|
||||
[OOScriptTimer noteGameReset];
|
||||
@ -1332,16 +1333,15 @@ double scoopSoundPlayTime = 0.0;
|
||||
external_temp *= 100;
|
||||
|
||||
// do Revised sun-skimming check here...
|
||||
if ([self hasScoop] && alt1 > 0.75 && fuel < PLAYER_MAX_FUEL)
|
||||
if ([self hasScoop] && alt1 > 0.75 && [self fuel] < [self fuelCapacity])
|
||||
{
|
||||
fuel_accumulator += (float)(delta_t * flightSpeed * 0.010);
|
||||
scoopsActive = YES;
|
||||
while (fuel_accumulator > 1.0)
|
||||
{
|
||||
fuel ++;
|
||||
[self setFuel:[self fuel] + 1];
|
||||
fuel_accumulator -= 1.0f;
|
||||
}
|
||||
if (fuel > PLAYER_MAX_FUEL) fuel = PLAYER_MAX_FUEL;
|
||||
[UNIVERSE displayCountdownMessage:DESC(@"fuel-scoop-active") forCount:1.0];
|
||||
}
|
||||
}
|
||||
@ -2146,9 +2146,9 @@ double scoopSoundPlayTime = 0.0;
|
||||
{
|
||||
if (fuel <= 0.0f)
|
||||
return 0.0f;
|
||||
if (fuel > (GLfloat)PLAYER_MAX_FUEL)
|
||||
if (fuel > [self fuelCapacity])
|
||||
return 1.0f;
|
||||
return (GLfloat)fuel / (GLfloat)PLAYER_MAX_FUEL;
|
||||
return (GLfloat)fuel / (GLfloat)[self fuelCapacity];
|
||||
}
|
||||
|
||||
|
||||
@ -3357,7 +3357,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
NSString* system_name = nil;
|
||||
if (([system_key hasSuffix:@"MISSILE"])||([system_key hasSuffix:@"MINE"])||([system_key isEqual:@"EQ_CARGO_BAY"]))
|
||||
return;
|
||||
NSArray* eq = [UNIVERSE equipmentdata];
|
||||
NSArray* eq = [UNIVERSE equipmentData];
|
||||
unsigned i;
|
||||
for (i = 0; (i < [eq count])&&(!system_name); i++)
|
||||
{
|
||||
@ -4002,7 +4002,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
{
|
||||
NSMutableArray *quip = [NSMutableArray array];
|
||||
unsigned i;
|
||||
NSArray *equipmentinfo = [UNIVERSE equipmentdata];
|
||||
NSArray *equipmentinfo = [UNIVERSE equipmentData];
|
||||
|
||||
for (i =0; i < [equipmentinfo count]; i++)
|
||||
{
|
||||
@ -4612,7 +4612,7 @@ static int last_outfitting_index;
|
||||
|
||||
last_outfitting_index = skip;
|
||||
|
||||
NSArray *equipdata = [UNIVERSE equipmentdata];
|
||||
NSArray *equipdata = [UNIVERSE equipmentData];
|
||||
|
||||
OOCargoQuantityDelta cargo_space = max_cargo - current_cargo;
|
||||
if (cargo_space < 0) cargo_space = 0;
|
||||
@ -4694,63 +4694,11 @@ static int last_outfitting_index;
|
||||
|
||||
if (isOK)
|
||||
{
|
||||
BOOL requiresEmptyPylon = NO,
|
||||
requiresMountedPylon = NO,
|
||||
requiresClean = NO,
|
||||
requiresNotClean = NO;
|
||||
OOCargoQuantity requiresCargoSpace = 0;
|
||||
id requiresEquipment = nil;
|
||||
id incompatibleWithEquipment = nil;
|
||||
|
||||
// check built-in requirements
|
||||
if ([self hasEquipmentItem:eq_key]) isOK = NO;
|
||||
if (([eq_key isEqualToString:@"EQ_FUEL"])&&(fuel >= PLAYER_MAX_FUEL)) isOK = NO; // check if fuel space free
|
||||
if (([eq_key hasSuffix:@"MISSILE"]||[eq_key hasSuffix:@"MINE"])) requiresEmptyPylon = YES; // Kept for compatibility with existing missiles/mines that don't specify it.
|
||||
if (([eq_key isEqualToString:@"EQ_PASSENGER_BERTH_REMOVAL"])&&(max_passengers - [passengers count] < 1)) isOK = NO;
|
||||
if (techlevel < min_techlevel) isOK = NO;
|
||||
if ([eq_key isEqual:@"EQ_RENOVATION"] && !((75 <= ship_trade_in_factor)&&(ship_trade_in_factor < 85))) isOK = NO;
|
||||
|
||||
// check custom requirements
|
||||
requiresEmptyPylon = [eq_extra_info_dict boolForKey:@"requires_empty_pylon" defaultValue:requiresEmptyPylon];
|
||||
requiresMountedPylon = [eq_extra_info_dict boolForKey:@"requires_mounted_pylon" defaultValue:requiresMountedPylon];
|
||||
requiresCargoSpace = [eq_extra_info_dict unsignedIntForKey:@"requires_cargo_space" defaultValue:requiresCargoSpace];
|
||||
requiresEquipment = [eq_extra_info_dict objectForKey:@"requires_equipment" defaultValue:requiresEquipment];
|
||||
incompatibleWithEquipment = [eq_extra_info_dict objectForKey:@"incompatible_with_equipment" defaultValue:incompatibleWithEquipment];
|
||||
if ([eq_extra_info_dict objectForKey:@"requires_clean"]) requiresClean = YES;
|
||||
if ([eq_extra_info_dict objectForKey:@"requires_not_clean"]) requiresNotClean = YES;
|
||||
|
||||
if (isOK)
|
||||
{
|
||||
if (requiresEmptyPylon && missiles >= max_missiles) isOK = NO;
|
||||
else if (requiresMountedPylon && missiles == 0) isOK = NO;
|
||||
else if ((OOCargoQuantity)cargo_space < requiresCargoSpace) isOK = NO;
|
||||
else if (requiresEquipment != nil && ![self hasEquipmentItem:requiresEquipment]) isOK = NO;
|
||||
else if (incompatibleWithEquipment != nil && [self hasEquipmentItem:incompatibleWithEquipment]) isOK = NO;
|
||||
else if (requiresClean && [self legalStatus] != 0) isOK = NO;
|
||||
else if (requiresNotClean && [self legalStatus] == 0) isOK = NO;
|
||||
}
|
||||
if (![self canAddEquipment:eq_key]) isOK = NO;
|
||||
}
|
||||
|
||||
if (isOK && [eq_extra_info_dict objectForKey:@"conditions"])
|
||||
{
|
||||
[self debugOn];
|
||||
id conds = [eq_extra_info_dict objectForKey:@"conditions"];
|
||||
if ([conds isKindOfClass:[NSString class]])
|
||||
{
|
||||
if (![self scriptTestCondition:(NSString *) conds]) isOK = NO;
|
||||
}
|
||||
else if ([conds isKindOfClass:[NSArray class]])
|
||||
{
|
||||
NSArray* conditions = (NSArray*)conds;
|
||||
unsigned i;
|
||||
for (i = 0; i < [conditions count]; i++)
|
||||
if (![self scriptTestCondition:(NSString *)[conditions objectAtIndex:i]]) isOK = NO;
|
||||
}
|
||||
[self debugOff];
|
||||
}
|
||||
|
||||
if (isOK)
|
||||
[equipment_allowed addUnsignedInteger:i];
|
||||
if (isOK) [equipment_allowed addUnsignedInteger:i];
|
||||
|
||||
if ((int)i == itemForSelectFacing)
|
||||
{
|
||||
@ -4933,8 +4881,8 @@ static int last_outfitting_index;
|
||||
if (![key hasPrefix:@"More:"])
|
||||
{
|
||||
int item = [key intValue];
|
||||
NSString* desc = (NSString *)[(NSArray *)[[UNIVERSE equipmentdata] objectAtIndex:item] objectAtIndex:EQUIPMENT_LONG_DESC_INDEX];
|
||||
NSString* eq_key = (NSString *)[(NSArray *)[[UNIVERSE equipmentdata] objectAtIndex:item] objectAtIndex:EQUIPMENT_KEY_INDEX];
|
||||
NSString* desc = (NSString *)[(NSArray *)[[UNIVERSE equipmentData] objectAtIndex:item] objectAtIndex:EQUIPMENT_LONG_DESC_INDEX];
|
||||
NSString* eq_key = (NSString *)[(NSArray *)[[UNIVERSE equipmentData] objectAtIndex:item] objectAtIndex:EQUIPMENT_KEY_INDEX];
|
||||
NSString* eq_key_damaged = [NSString stringWithFormat:@"%@_DAMAGED", eq_key];
|
||||
if ([self hasEquipmentItem:eq_key_damaged])
|
||||
desc = [NSString stringWithFormat:DESC(@"upgradeinfo-@-price-is-for-repairing"), desc];
|
||||
@ -5114,11 +5062,11 @@ static int last_outfitting_index;
|
||||
- (BOOL) tryBuyingItem:(int) index
|
||||
{
|
||||
// note this doesn't check the availability by tech-level
|
||||
NSArray *equipdata = [UNIVERSE equipmentdata];
|
||||
NSArray *equipdata = [UNIVERSE equipmentData];
|
||||
OOCreditsQuantity price_per_unit = [[equipdata arrayAtIndex:index] unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
|
||||
NSString *eq_key = [[equipdata arrayAtIndex:index] stringAtIndex:EQUIPMENT_KEY_INDEX];
|
||||
NSString *eq_key_damaged = [NSString stringWithFormat:@"%@_DAMAGED", eq_key];
|
||||
double price = ([eq_key isEqual:@"EQ_FUEL"]) ? ((PLAYER_MAX_FUEL - fuel) * price_per_unit) : (price_per_unit);
|
||||
double price = price_per_unit;
|
||||
double price_factor = 1.0;
|
||||
OOCargoQuantityDelta cargo_space = max_cargo - current_cargo;
|
||||
OOCreditsQuantity tradeIn = 0;
|
||||
@ -5243,8 +5191,8 @@ static int last_outfitting_index;
|
||||
|
||||
if ([eq_key isEqual:@"EQ_FUEL"])
|
||||
{
|
||||
fuel = PLAYER_MAX_FUEL;
|
||||
credits -= price;
|
||||
fuel = [self fuelCapacity];
|
||||
credits -= ([self fuelCapacity] - [self fuel]) * price_per_unit;
|
||||
[self setGuiToEquipShipScreen:-1:-1];
|
||||
return YES;
|
||||
}
|
||||
@ -5637,6 +5585,30 @@ static int last_outfitting_index;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) canAddEquipment:(NSString *)equipmentKey
|
||||
{
|
||||
if ([equipmentKey isEqual:@"EQ_RENOVATION"] && !((75 <= ship_trade_in_factor) && (ship_trade_in_factor < 85))) return NO;
|
||||
if (![super canAddEquipment:equipmentKey]) return NO;
|
||||
|
||||
NSArray *conditions = [[OOEquipmentType equipmentTypeWithIdentifier:equipmentKey] conditions];
|
||||
if (conditions != nil)
|
||||
{
|
||||
NSEnumerator *condEnum = nil;
|
||||
NSString *condition = nil;
|
||||
|
||||
for (condEnum = [conditions objectEnumerator]; (condition = [condEnum nextObject]); )
|
||||
{
|
||||
if ([condition isKindOfClass:[NSString class]])
|
||||
{
|
||||
if (![self scriptTestCondition:condition]) return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (void) addEquipmentItem:(NSString *)equipmentKey
|
||||
{
|
||||
// deal with trumbles..
|
||||
@ -5718,6 +5690,24 @@ static int last_outfitting_index;
|
||||
}
|
||||
|
||||
|
||||
- (unsigned) passengerCount
|
||||
{
|
||||
return [passengers count];
|
||||
}
|
||||
|
||||
|
||||
- (unsigned) passengerCapacity
|
||||
{
|
||||
return max_passengers;
|
||||
}
|
||||
|
||||
|
||||
- (unsigned) missileCapacity
|
||||
{
|
||||
return max_missiles;
|
||||
}
|
||||
|
||||
|
||||
// time delay method for playing afterburner sounds
|
||||
// this overlaps two sounds each 2 seconds long, but with a .5s
|
||||
// crossfade
|
||||
|
@ -1420,7 +1420,7 @@ static NSMutableDictionary* currentShipyard = nil;
|
||||
NSDictionary *shipDict = [ship_info dictionaryForKey:SHIPYARD_KEY_SHIP];
|
||||
|
||||
// get a full tank for free
|
||||
fuel = PLAYER_MAX_FUEL;
|
||||
[self setFuel:[self fuelCapacity]];
|
||||
|
||||
// this ship has a clean record
|
||||
legalStatus = 0;
|
||||
@ -1447,7 +1447,7 @@ static NSMutableDictionary* currentShipyard = nil;
|
||||
|
||||
// keep track of portable equipment..
|
||||
|
||||
NSArray *equipment = [UNIVERSE equipmentdata];
|
||||
NSArray *equipment = [UNIVERSE equipmentData];
|
||||
NSMutableSet *portable_equipment = [NSMutableSet set];
|
||||
NSEnumerator *eqEnum = nil;
|
||||
NSString *eq_desc = nil;
|
||||
|
@ -1226,7 +1226,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
||||
|
||||
if ([equipString isEqual:@"EQ_FUEL"])
|
||||
{
|
||||
fuel = PLAYER_MAX_FUEL;
|
||||
[self setFuel:[self fuelCapacity]];
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1447,7 +1447,6 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
||||
else
|
||||
{
|
||||
[scriptTarget setFuel:(scriptTargetFuelBeforeAward + delta)];
|
||||
if ([scriptTarget fuel] > PLAYER_MAX_FUEL) [scriptTarget setFuel:PLAYER_MAX_FUEL];
|
||||
}
|
||||
}
|
||||
|
||||
@ -2170,7 +2169,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
||||
if ((e_class == CLASS_NEUTRAL)||(e_class == CLASS_POLICE)||(e_class == CLASS_MILITARY)||(e_class == CLASS_THARGOID))
|
||||
{
|
||||
AI* se1AI = [se1 getAI];
|
||||
[se1 setFuel: PLAYER_MAX_FUEL];
|
||||
[se1 setFuel:MAX(PLAYER_MAX_FUEL, [se1 fuelCapacity])];
|
||||
[se1AI setStateMachine:@"exitingTraderAI.plist"];
|
||||
[se1AI setState:@"EXIT_SYSTEM"];
|
||||
// FIXME: I don't think the following line does anything meaningful. -- Ahruman
|
||||
@ -2190,7 +2189,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
||||
|
||||
if (!UNIVERSE)
|
||||
return;
|
||||
NSDictionary* dict = [[UNIVERSE planetinfo] dictionaryForKey:planetKey];
|
||||
NSDictionary* dict = [[UNIVERSE planetInfo] dictionaryForKey:planetKey];
|
||||
if (!dict)
|
||||
{
|
||||
OOLog(@"script.error.addPlanet.keyNotFound", @"ERROR - could not find an entry in planetinfo.plist for '%@'", planetKey);
|
||||
@ -2237,7 +2236,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
||||
|
||||
if (!UNIVERSE)
|
||||
return;
|
||||
NSDictionary* dict = [[UNIVERSE planetinfo] dictionaryForKey:moonKey];
|
||||
NSDictionary* dict = [[UNIVERSE planetInfo] dictionaryForKey:moonKey];
|
||||
if (!dict)
|
||||
{
|
||||
OOLog(@"script.error.addPlanet.keyNotFound", @"ERROR - could not find an entry in planetinfo.plist for '%@'", moonKey);
|
||||
|
@ -357,14 +357,26 @@ MA 02110-1301, USA.
|
||||
- (void)respondToAttackFrom:(Entity *)from becauseOf:(Entity *)other;
|
||||
|
||||
// Equipment
|
||||
- (BOOL) hasEquipmentItem:(id)equipmentKeys; // This can take a string or an set or array of strings. If a collection, returns YES if ship has _any_ of the specified equipment.
|
||||
- (BOOL) hasAllEquipment:(id)equipmentKeys; // As above, but requires _all_ equipment in collection.
|
||||
- (BOOL) hasEquipmentItem:(id)equipmentKeys; // This can take a string or an set or array of strings. If a collection, returns YES if ship has _any_ of the specified equipment.
|
||||
- (BOOL) hasAllEquipment:(id)equipmentKeys; // As above, but requires _all_ equipment in collection.
|
||||
- (BOOL) canAddEquipment:(NSString *)equipmentKey; // Test ability to add equipment, taking equipment-specific constriants into account.
|
||||
- (void) addEquipmentItem:(NSString *)equipmentKey;
|
||||
/* NOTE: for legacy reasons, canAddEquipment: returns YES if given a missile
|
||||
or mine type, but addEquipmentItem: does nothing in those cases. This
|
||||
should probably be cleaned up by making addEquipmentItem: mount stores.
|
||||
*/
|
||||
- (NSEnumerator *) equipmentEnumerator;
|
||||
- (unsigned) equipmentCount;
|
||||
- (void) removeEquipmentItem:(NSString *)equipmentKey;
|
||||
- (void) removeAllEquipment;
|
||||
|
||||
// Passengers - not supported for NPCs, but interface is here for genericity.
|
||||
- (unsigned) passengerCount;
|
||||
- (unsigned) passengerCapacity;
|
||||
|
||||
- (unsigned) missileCount;
|
||||
- (unsigned) missileCapacity;
|
||||
|
||||
// Tests for the various special-cased equipment items
|
||||
- (BOOL) hasScoop;
|
||||
- (BOOL) hasECM;
|
||||
@ -490,9 +502,10 @@ MA 02110-1301, USA.
|
||||
- (NSArray*) crew;
|
||||
- (void) setCrew: (NSArray*) crewArray;
|
||||
|
||||
|
||||
// Fuel and capacity in tenths of light-years.
|
||||
- (OOFuelQuantity) fuel;
|
||||
- (void) setFuel:(OOFuelQuantity) amount;
|
||||
- (OOFuelQuantity) fuelCapacity;
|
||||
|
||||
- (void) setRoll:(double) amount;
|
||||
- (void) setPitch:(double) amount;
|
||||
|
@ -58,6 +58,7 @@ MA 02110-1301, USA.
|
||||
#import "GuiDisplayGen.h"
|
||||
#import "HeadUpDisplay.h"
|
||||
#import "OOEntityFilterPredicate.h"
|
||||
#import "OOEquipmentType.h"
|
||||
|
||||
#import "OODebugGLDrawing.h"
|
||||
|
||||
@ -1678,16 +1679,56 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) canAddEquipment:(NSString *)equipmentKey
|
||||
{
|
||||
OOEquipmentType *eqType = nil;
|
||||
|
||||
eqType = [OOEquipmentType equipmentTypeWithIdentifier:equipmentKey];
|
||||
if (eqType == nil) return NO;
|
||||
|
||||
// FIXME: deal with special handling of missiles and mines.
|
||||
if ([self hasEquipmentItem:equipmentKey]) return NO;
|
||||
|
||||
if ([eqType requiresEmptyPylon] && [self missileCount] >= [self missileCapacity]) return NO;
|
||||
if ([eqType requiresMountedPylon] && [self missileCount] == 0) return NO;
|
||||
if ([self availableCargoSpace] < [eqType requiredCargoSpace]) return NO;
|
||||
if ([eqType requiredEquipment] != nil && ![self hasEquipmentItem:[eqType requiredEquipment]]) return NO;
|
||||
if ([eqType incompatibleEquipment] != nil && [self hasEquipmentItem:[eqType incompatibleEquipment]]) return NO;
|
||||
if ([eqType requiresCleanLegalRecord] && [self legalStatus] != 0) return NO;
|
||||
if ([eqType requiresNonCleanLegalRecord] && [self legalStatus] == 0) return NO;
|
||||
if ([eqType requiresFreePassengerBerth] && [self passengerCount] >= [self passengerCapacity]) return NO;
|
||||
if ([eqType requiresFullFuel] && [self fuel] < [self fuelCapacity]) return NO;
|
||||
if ([eqType requiresNonFullFuel] && [self fuel] >= [self fuelCapacity]) return NO;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (void) addEquipmentItem:(NSString *)equipmentKey
|
||||
{
|
||||
if (equipmentKey == nil) return;
|
||||
OOEquipmentType *eqType = nil;
|
||||
|
||||
if (![self canAddEquipment:equipmentKey]) return;
|
||||
eqType = [OOEquipmentType equipmentTypeWithIdentifier:equipmentKey];
|
||||
|
||||
// FIXME: deal with special handling of missiles and mines.
|
||||
if ([eqType isMissileOrMine]) return;
|
||||
|
||||
if (_equipment == nil) _equipment = [[NSMutableSet alloc] init];
|
||||
|
||||
// if we've got a damaged one of these - remove it first
|
||||
NSString* damaged_eq_key = [equipmentKey stringByAppendingString:@"_DAMAGED"];
|
||||
[_equipment removeObject:damaged_eq_key];
|
||||
// if we heve one of these with a differen damage status - remove it first
|
||||
NSString *alterKey = nil;
|
||||
if ([equipmentKey hasSuffix:@"_DAMAGED"])
|
||||
{
|
||||
alterKey = [equipmentKey substringToIndex:[equipmentKey length] - [@"_DAMAGED" length]];
|
||||
}
|
||||
else
|
||||
{
|
||||
alterKey = [equipmentKey stringByAppendingString:@"_DAMAGED"];
|
||||
}
|
||||
[_equipment removeObject:alterKey];
|
||||
|
||||
// add the equipment and set the necessary flags and data accordingly
|
||||
// add the equipment
|
||||
[_equipment addObject:equipmentKey];
|
||||
}
|
||||
|
||||
@ -1716,6 +1757,29 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
[_equipment release];
|
||||
_equipment = nil;
|
||||
}
|
||||
- (unsigned) passengerCount
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
- (unsigned) passengerCapacity
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
- (unsigned) missileCount
|
||||
{
|
||||
return missiles;
|
||||
}
|
||||
|
||||
|
||||
- (unsigned) missileCapacity
|
||||
{
|
||||
// FIXME: need useful maximum from shipdata key max_missiles (or missiles if no max specified).
|
||||
return missiles;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) hasScoop
|
||||
@ -3689,9 +3753,16 @@ NSComparisonResult planetSort(id i1, id i2, void* context)
|
||||
|
||||
- (void) setFuel:(OOFuelQuantity) amount
|
||||
{
|
||||
if (amount > [self fuelCapacity]) amount = [self fuelCapacity];
|
||||
|
||||
fuel = amount;
|
||||
if (fuel > PLAYER_MAX_FUEL)
|
||||
fuel = PLAYER_MAX_FUEL;
|
||||
}
|
||||
|
||||
|
||||
- (OOFuelQuantity) fuelCapacity
|
||||
{
|
||||
// FIXME: shipdata.plist can allow greater fuel quantities (without extending hyperspace range). Need some consistency here.
|
||||
return PLAYER_MAX_FUEL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1696,10 +1696,7 @@ WormholeEntity* whole;
|
||||
|
||||
- (void) addFuel:(NSString*) fuel_number
|
||||
{
|
||||
int extra_fuel = [fuel_number intValue];
|
||||
fuel += 10 * extra_fuel;
|
||||
if (fuel > PLAYER_MAX_FUEL)
|
||||
fuel = PLAYER_MAX_FUEL;
|
||||
[self setFuel:[self fuel] + [fuel_number intValue] * 10];
|
||||
}
|
||||
|
||||
|
||||
|
@ -1428,10 +1428,10 @@ OOINLINE BOOL RowInRange(OOGUIRow row, NSRange range)
|
||||
star2.y = (float)(g_seed2.b * vscale + voffset);
|
||||
double d = distanceBetweenPlanetPositions(g_seed.d, g_seed.b, g_seed2.d, g_seed2.b);
|
||||
|
||||
if (d <= (PLAYER_MAX_FUEL / 10.0f)) // another_commander - Default to 7.0 LY.
|
||||
if (d <= ([player fuelCapacity] / 10.0f)) // another_commander - Default to 7.0 LY.
|
||||
{
|
||||
glVertex3f(x+star.x, y+star.y, z );
|
||||
glVertex3f(x+star2.x, y+star2.y, z );
|
||||
glVertex3f(x+star.x, y+star.y, z);
|
||||
glVertex3f(x+star2.x, y+star2.y, z);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
|
108
src/Core/OOEquipmentType.h
Normal file
108
src/Core/OOEquipmentType.h
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
|
||||
OOEquipmentType.h
|
||||
|
||||
Manage the set of installed ships.
|
||||
|
||||
|
||||
Oolite
|
||||
Copyright (C) 2004-2008 Giles C Williams and contributors
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
|
||||
|
||||
This file may also be distributed under the MIT/X11 license:
|
||||
|
||||
Copyright (C) 2008 Jens Ayton
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#import "OOCocoa.h"
|
||||
#import "OOTypes.h"
|
||||
|
||||
|
||||
@interface OOEquipmentType: NSObject <NSCopying>
|
||||
{
|
||||
@private
|
||||
OOTechLevelID _techLevel;
|
||||
OOCreditsQuantity _price;
|
||||
NSString *_name;
|
||||
NSString *_identifier;
|
||||
NSString *_description;
|
||||
unsigned _isAvailableToAll: 1,
|
||||
_requiresEmptyPylon: 1,
|
||||
_requiresMountedPylon: 1,
|
||||
_requiresClean: 1,
|
||||
_requiresNotClean: 1,
|
||||
_portableBetweenShips: 1,
|
||||
_requiresFreePassengerBerth: 1,
|
||||
_requiresFullFuel: 1,
|
||||
_requiresNonFullFuel: 1,
|
||||
_isMissileOrMine: 1;
|
||||
OOCargoQuantity _requiredCargoSpace;
|
||||
NSSet *_requiredEquipment;
|
||||
NSSet *_incompatibleEquipment;
|
||||
NSArray *_conditions;
|
||||
}
|
||||
|
||||
+ (void) loadEquipment; // Load equipment data; called on loading and when changing to/from strict mode.
|
||||
|
||||
+ (NSArray *) allEquipmentTypes;
|
||||
+ (OOEquipmentType *) equipmentTypeWithIdentifier:(NSString *)identifier;
|
||||
|
||||
- (NSString *) identifier;
|
||||
- (NSString *) name; // localized
|
||||
- (NSString *) descriptiveText; // localized
|
||||
- (OOTechLevelID) techLevel;
|
||||
- (OOCreditsQuantity) price; // Tenths of credits
|
||||
|
||||
- (BOOL) isAvailableToAll;
|
||||
- (BOOL) requiresEmptyPylon;
|
||||
- (BOOL) requiresMountedPylon;
|
||||
- (BOOL) requiresCleanLegalRecord;
|
||||
- (BOOL) requiresNonCleanLegalRecord;
|
||||
- (BOOL) requiresFreePassengerBerth;
|
||||
- (BOOL) requiresFullFuel;
|
||||
- (BOOL) requiresNonFullFuel;
|
||||
- (BOOL) isMissileOrMine;
|
||||
- (BOOL) isPortableBetweenShips;
|
||||
|
||||
- (OOCargoQuantity) requiredCargoSpace;
|
||||
- (NSSet *) requiredEquipment; // Sets of equipment identifiers
|
||||
- (NSSet *) incompatibleEquipment;
|
||||
|
||||
// FIXME: should have general mechanism to handle scripts or legacy conditions.
|
||||
- (NSArray *) conditions;
|
||||
|
||||
@end
|
350
src/Core/OOEquipmentType.m
Normal file
350
src/Core/OOEquipmentType.m
Normal file
@ -0,0 +1,350 @@
|
||||
/*
|
||||
|
||||
OOEquipmentType.h
|
||||
|
||||
Manage the set of installed ships.
|
||||
|
||||
|
||||
Oolite
|
||||
Copyright (C) 2004-2008 Giles C Williams and contributors
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
|
||||
|
||||
This file may also be distributed under the MIT/X11 license:
|
||||
|
||||
Copyright (C) 2008 Jens Ayton
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#import "OOEquipmentType.h"
|
||||
#import "Universe.h"
|
||||
#import "OOCollectionExtractors.h"
|
||||
|
||||
|
||||
static NSArray *sEquipmentTypes = nil;
|
||||
static NSDictionary *sEquipmentTypesByIdentifier = nil;
|
||||
|
||||
|
||||
@interface OOEquipmentType (Private)
|
||||
|
||||
- (id) initWithInfo:(NSArray *)info;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation OOEquipmentType
|
||||
|
||||
+ (void) loadEquipment
|
||||
{
|
||||
NSArray *equipmentData = nil;
|
||||
NSMutableArray *equipmentTypes = nil;
|
||||
NSMutableDictionary *equipmentTypesByIdentifier = nil;
|
||||
NSArray *itemInfo = nil;
|
||||
OOEquipmentType *item = nil;
|
||||
NSEnumerator *itemEnum = nil;
|
||||
|
||||
equipmentData = [UNIVERSE equipmentData];
|
||||
|
||||
[sEquipmentTypes release];
|
||||
sEquipmentTypes = nil;
|
||||
equipmentTypes = [NSMutableArray arrayWithCapacity:[equipmentData count]];
|
||||
[sEquipmentTypesByIdentifier release];
|
||||
sEquipmentTypesByIdentifier = nil;
|
||||
equipmentTypesByIdentifier = [NSMutableDictionary dictionaryWithCapacity:[equipmentData count]];
|
||||
|
||||
for (itemEnum = [equipmentData objectEnumerator]; (itemInfo = [itemEnum nextObject]); )
|
||||
{
|
||||
item = [[[OOEquipmentType alloc] initWithInfo:itemInfo] autorelease];
|
||||
if (item != nil)
|
||||
{
|
||||
[equipmentTypes addObject:item];
|
||||
[equipmentTypesByIdentifier setObject:item forKey:[item identifier]];
|
||||
}
|
||||
}
|
||||
|
||||
sEquipmentTypes = [equipmentTypes copy];
|
||||
sEquipmentTypesByIdentifier = [equipmentTypesByIdentifier copy];
|
||||
}
|
||||
|
||||
|
||||
+ (NSArray *) allEquipmentTypes
|
||||
{
|
||||
return sEquipmentTypes;
|
||||
}
|
||||
|
||||
|
||||
+ (OOEquipmentType *) equipmentTypeWithIdentifier:(NSString *)identifier
|
||||
{
|
||||
return [sEquipmentTypesByIdentifier objectForKey:identifier];
|
||||
}
|
||||
|
||||
|
||||
- (id) initWithInfo:(NSArray *)info
|
||||
{
|
||||
BOOL OK = YES;
|
||||
NSDictionary *extra = nil;
|
||||
|
||||
self = [super init];
|
||||
if (self == nil) OK = NO;
|
||||
|
||||
if (OK && [info count] <= EQUIPMENT_LONG_DESC_INDEX) OK = NO;
|
||||
|
||||
if (OK)
|
||||
{
|
||||
// Read required attributes
|
||||
_techLevel = [info unsignedIntAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
|
||||
_price = [info unsignedIntAtIndex:EQUIPMENT_PRICE_INDEX];
|
||||
_name = [[info stringAtIndex:EQUIPMENT_SHORT_DESC_INDEX] retain];
|
||||
_identifier = [[info stringAtIndex:EQUIPMENT_KEY_INDEX] retain];
|
||||
_description = [[info stringAtIndex:EQUIPMENT_LONG_DESC_INDEX] retain];
|
||||
|
||||
if (_name == nil || _identifier == nil || _description == nil)
|
||||
{
|
||||
OOLog(@"equipment.load", @"***** ERROR: Invalid equipment.plist entry - missing name, identifier or description (\"%@\", %@, \"%@\")", _name, _identifier, _description);
|
||||
OK = NO;
|
||||
}
|
||||
}
|
||||
|
||||
if (OK)
|
||||
{
|
||||
// Implied attributes for backwards-compatibility
|
||||
if ([_identifier hasSuffix:@"_MISSILE"] || [_identifier hasSuffix:@"_MINE"])
|
||||
{
|
||||
_isMissileOrMine = YES;
|
||||
_requiresEmptyPylon = YES;
|
||||
}
|
||||
else if ([_identifier isEqualToString:@"EQ_PASSENGER_BERTH_REMOVAL"])
|
||||
{
|
||||
_requiresFreePassengerBerth = YES;
|
||||
}
|
||||
else if ([_identifier isEqualToString:@"EQ_FUEL"])
|
||||
{
|
||||
_requiresNonFullFuel = YES;
|
||||
}
|
||||
}
|
||||
|
||||
if (OK && [info count] > EQUIPMENT_EXTRA_INFO_INDEX)
|
||||
{
|
||||
// Read extra info dictionary
|
||||
extra = [info dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX];
|
||||
if (extra != nil)
|
||||
{
|
||||
_isAvailableToAll = [extra boolForKey:@"available_to_all" defaultValue:_isAvailableToAll];
|
||||
_requiresEmptyPylon = [extra boolForKey:@"requires_empty_pylon" defaultValue:_requiresEmptyPylon];
|
||||
_requiresMountedPylon = [extra boolForKey:@"requires_mounted_pylon" defaultValue:_requiresMountedPylon];
|
||||
_requiresClean = [extra boolForKey:@"requires_clean" defaultValue:_requiresClean];
|
||||
_requiresNotClean = [extra boolForKey:@"requires_not_clean" defaultValue:_requiresNotClean];
|
||||
_portableBetweenShips = [extra boolForKey:@"portable_between_ships" defaultValue:_portableBetweenShips];
|
||||
_requiresFreePassengerBerth = [extra boolForKey:@"requires_free_passenger_berth" defaultValue:_requiresFreePassengerBerth];
|
||||
_requiresFullFuel = [extra boolForKey:@"requires_full_fuel" defaultValue:_requiresFullFuel];
|
||||
_requiresNonFullFuel = [extra boolForKey:@"requires_non_full_fuel" defaultValue:_requiresNonFullFuel];
|
||||
|
||||
_requiredCargoSpace = [extra unsignedIntForKey:@"requires_cargo_space" defaultValue:_requiredCargoSpace];
|
||||
|
||||
id object = [extra objectForKey:@"requires_equipment"];
|
||||
if ([object isKindOfClass:[NSString class]]) _requiredEquipment = [[NSSet setWithObject:object] retain];
|
||||
else if ([object isKindOfClass:[NSArray class]]) _requiredEquipment = [[NSSet setWithArray:object] retain];
|
||||
else if (object != nil)
|
||||
{
|
||||
OOLog(@"equipment.load", @"***** ERROR: requires_equipment for equipment item %@ is not a string or an array.", _identifier);
|
||||
}
|
||||
|
||||
object = [extra objectForKey:@"incompatible_with_equipment"];
|
||||
if ([object isKindOfClass:[NSString class]]) _incompatibleEquipment = [[NSSet setWithObject:object] retain];
|
||||
else if ([object isKindOfClass:[NSArray class]]) _incompatibleEquipment = [[NSSet setWithArray:object] retain];
|
||||
else if (object != nil)
|
||||
{
|
||||
OOLog(@"equipment.load", @"***** ERROR: incompatible_with_equipment for equipment item %@ is not a string or an array.", _identifier);
|
||||
}
|
||||
|
||||
object = [extra objectForKey:@"conditions"];
|
||||
if ([object isKindOfClass:[NSString class]]) _conditions = [[NSArray arrayWithObject:object] retain];
|
||||
else if ([object isKindOfClass:[NSArray class]]) _conditions = [object retain];
|
||||
else if (object != nil)
|
||||
{
|
||||
OOLog(@"equipment.load", @"***** ERROR: conditions for equipment item %@ is not a string or an array.", _identifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!OK)
|
||||
{
|
||||
[self release];
|
||||
self = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[_name release];
|
||||
[_identifier release];
|
||||
[_description release];
|
||||
[_requiredEquipment release];
|
||||
[_incompatibleEquipment release];
|
||||
[_conditions release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
- (id) copyWithZone:(NSZone *)zone
|
||||
{
|
||||
// OOEquipmentTypes are immutable.
|
||||
return [self retain];
|
||||
}
|
||||
|
||||
|
||||
- (NSString *) descriptionComponents
|
||||
{
|
||||
return [NSString stringWithFormat:@"%@ \"%@\"", _identifier, _name];
|
||||
}
|
||||
|
||||
|
||||
- (NSString *) identifier
|
||||
{
|
||||
return _identifier;
|
||||
}
|
||||
|
||||
|
||||
- (NSString *) name
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
||||
- (NSString *) descriptiveText
|
||||
{
|
||||
return _description;
|
||||
}
|
||||
|
||||
|
||||
- (OOTechLevelID) techLevel
|
||||
{
|
||||
return _techLevel;
|
||||
}
|
||||
|
||||
|
||||
- (OOCreditsQuantity) price
|
||||
{
|
||||
return _price;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) isAvailableToAll
|
||||
{
|
||||
return _isAvailableToAll;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) requiresEmptyPylon
|
||||
{
|
||||
return _requiresEmptyPylon;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) requiresMountedPylon
|
||||
{
|
||||
return _requiresMountedPylon;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) requiresCleanLegalRecord
|
||||
{
|
||||
return _requiresClean;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) requiresNonCleanLegalRecord
|
||||
{
|
||||
return _requiresNotClean;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) requiresFreePassengerBerth
|
||||
{
|
||||
return _requiresFreePassengerBerth;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) requiresFullFuel
|
||||
{
|
||||
return _requiresFullFuel;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) requiresNonFullFuel
|
||||
{
|
||||
return _requiresNonFullFuel;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) isMissileOrMine
|
||||
{
|
||||
return _isMissileOrMine;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) isPortableBetweenShips
|
||||
{
|
||||
return _portableBetweenShips;
|
||||
}
|
||||
|
||||
|
||||
- (OOCargoQuantity) requiredCargoSpace
|
||||
{
|
||||
return _requiredCargoSpace;
|
||||
}
|
||||
|
||||
|
||||
- (NSSet *) requiredEquipment
|
||||
{
|
||||
return _requiredEquipment;
|
||||
}
|
||||
|
||||
|
||||
- (NSSet *) incompatibleEquipment
|
||||
{
|
||||
return _incompatibleEquipment;
|
||||
}
|
||||
|
||||
|
||||
- (NSArray *) conditions
|
||||
{
|
||||
return _conditions;
|
||||
}
|
||||
|
||||
@end
|
@ -49,8 +49,8 @@ MA 02110-1301, USA.
|
||||
|
||||
// routines to create textures...
|
||||
|
||||
+ (GLuint) getPlanetTextureNameFor:(NSDictionary*)planetinfo intoData:(unsigned char **)textureData;
|
||||
+ (GLuint) getPlanetNormalMapNameFor:(NSDictionary*)planetinfo intoData:(unsigned char **)textureData;
|
||||
+ (GLuint) getPlanetTextureNameFor:(NSDictionary*)planetInfo intoData:(unsigned char **)textureData;
|
||||
+ (GLuint) getPlanetNormalMapNameFor:(NSDictionary*)planetInfo intoData:(unsigned char **)textureData;
|
||||
+ (GLuint) getCloudTextureNameFor:(OOColor*) color: (GLfloat) impress: (GLfloat) bias intoData:(unsigned char **)textureData;
|
||||
|
||||
void fillRanNoiseBuffer();
|
||||
|
@ -123,7 +123,7 @@ GLuint max_texture_dimension = 512; // conservative start
|
||||
}
|
||||
|
||||
|
||||
+ (GLuint) getPlanetTextureNameFor:(NSDictionary*)planetinfo intoData:(unsigned char **)textureData
|
||||
+ (GLuint) getPlanetTextureNameFor:(NSDictionary*)planetInfo intoData:(unsigned char **)textureData
|
||||
{
|
||||
GLuint texName;
|
||||
|
||||
@ -140,15 +140,15 @@ GLuint max_texture_dimension = 512; // conservative start
|
||||
if (textureData)
|
||||
(*textureData) = imageBuffer;
|
||||
|
||||
float land_fraction = [[planetinfo objectForKey:@"land_fraction"] floatValue];
|
||||
float land_fraction = [[planetInfo objectForKey:@"land_fraction"] floatValue];
|
||||
float sea_bias = land_fraction - 1.0;
|
||||
|
||||
OOLog(kOOLogPlanetTextureGen, @"genning texture for land_fraction %.5f", land_fraction);
|
||||
|
||||
OOColor* land_color = (OOColor*)[planetinfo objectForKey:@"land_color"];
|
||||
OOColor* sea_color = (OOColor*)[planetinfo objectForKey:@"sea_color"];
|
||||
OOColor* polar_land_color = (OOColor*)[planetinfo objectForKey:@"polar_land_color"];
|
||||
OOColor* polar_sea_color = (OOColor*)[planetinfo objectForKey:@"polar_sea_color"];
|
||||
OOColor* land_color = (OOColor*)[planetInfo objectForKey:@"land_color"];
|
||||
OOColor* sea_color = (OOColor*)[planetInfo objectForKey:@"sea_color"];
|
||||
OOColor* polar_land_color = (OOColor*)[planetInfo objectForKey:@"polar_land_color"];
|
||||
OOColor* polar_sea_color = (OOColor*)[planetInfo objectForKey:@"polar_sea_color"];
|
||||
|
||||
fillSquareImageWithPlanetTex( imageBuffer, texture_w, 4, 1.0, sea_bias,
|
||||
sea_color,
|
||||
@ -172,7 +172,7 @@ GLuint max_texture_dimension = 512; // conservative start
|
||||
return texName;
|
||||
}
|
||||
|
||||
+ (GLuint) getPlanetNormalMapNameFor:(NSDictionary*)planetinfo intoData:(unsigned char **)textureData
|
||||
+ (GLuint) getPlanetNormalMapNameFor:(NSDictionary*)planetInfo intoData:(unsigned char **)textureData
|
||||
{
|
||||
GLuint texName;
|
||||
|
||||
@ -189,7 +189,7 @@ GLuint max_texture_dimension = 512; // conservative start
|
||||
if (textureData)
|
||||
(*textureData) = imageBuffer;
|
||||
|
||||
float land_fraction = [[planetinfo objectForKey:@"land_fraction"] floatValue];
|
||||
float land_fraction = [[planetInfo objectForKey:@"land_fraction"] floatValue];
|
||||
float sea_bias = land_fraction - 1.0;
|
||||
|
||||
OOLog(@"textureStore.genNormalMap", @"genning normal map for land_fraction %.5f", land_fraction);
|
||||
|
@ -191,16 +191,16 @@ enum
|
||||
|
||||
NSDictionary *shipyard; // holds data on all ships for sale, loaded at initialisation
|
||||
|
||||
NSDictionary *commoditylists; // holds data on commodities for various types of station, loaded at initialisation
|
||||
NSArray *commoditydata; // holds data on commodities extracted from commoditylists
|
||||
NSDictionary *commodityLists; // holds data on commodities for various types of station, loaded at initialisation
|
||||
NSArray *commodityData; // holds data on commodities extracted from commodityLists
|
||||
|
||||
NSDictionary *illegal_goods; // holds the legal penalty for illicit commodities, loaded at initialisation
|
||||
NSDictionary *descriptions; // holds descriptive text for lots of stuff, loaded at initialisation
|
||||
NSDictionary *customsounds; // holds descriptive audio for lots of stuff, loaded at initialisation
|
||||
NSDictionary *characters; // holds descriptons of characters
|
||||
NSDictionary *planetinfo; // holds overrides for individual planets, keyed by "g# p#" where g# is the galaxy number 0..7 and p# the planet number 0..255
|
||||
NSDictionary *planetInfo; // holds overrides for individual planets, keyed by "g# p#" where g# is the galaxy number 0..7 and p# the planet number 0..255
|
||||
NSDictionary *missiontext; // holds descriptive text for missions, loaded at initialisation
|
||||
NSArray *equipmentdata; // holds data on available equipment, loaded at initialisation
|
||||
NSArray *equipmentData; // holds data on available equipment, loaded at initialisation
|
||||
NSSet *pirateVictimRoles; // Roles listed in pirateVictimRoles.plist.
|
||||
NSDictionary *autoAIMap; // Default AIs for roles from autoAImap.plist.
|
||||
|
||||
@ -487,14 +487,14 @@ enum
|
||||
- (NSDictionary *) routeFromSystem:(OOSystemID) start toSystem:(OOSystemID) goal;
|
||||
- (NSArray *) neighboursToSystem:(OOSystemID) system_number;
|
||||
|
||||
- (NSMutableDictionary*) localPlanetInfoOverrides;
|
||||
- (NSMutableDictionary *) localPlanetInfoOverrides;
|
||||
- (void) setLocalPlanetInfoOverrides:(NSDictionary*) dict;
|
||||
|
||||
- (NSDictionary*) planetinfo;
|
||||
- (NSDictionary *) planetInfo;
|
||||
|
||||
- (NSArray *) equipmentdata;
|
||||
- (NSDictionary *) commoditylists;
|
||||
- (NSArray *) commoditydata;
|
||||
- (NSArray *) equipmentData;
|
||||
- (NSDictionary *) commodityLists;
|
||||
- (NSArray *) commodityData;
|
||||
|
||||
- (BOOL) generateEconomicDataWithEconomy:(OOEconomyID) economy andRandomFactor:(int) random_factor;
|
||||
- (NSArray *) commodityDataForEconomy:(OOEconomyID) economy andStation:(StationEntity *)some_station andRandomFactor:(int) random_factor;
|
||||
|
@ -51,6 +51,7 @@ MA 02110-1301, USA.
|
||||
#import "OOCharacter.h"
|
||||
#import "OOShipRegistry.h"
|
||||
#import "OOProbabilitySet.h"
|
||||
#import "OOEquipmentType.h"
|
||||
|
||||
#import "PlayerEntity.h"
|
||||
#import "PlayerEntityContracts.h"
|
||||
@ -213,8 +214,8 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
|
||||
|
||||
shipyard = [[ResourceManager dictionaryFromFilesNamed:@"shipyard.plist" inFolder:@"Config" andMerge:YES] retain];
|
||||
|
||||
commoditylists = [(NSDictionary *)[ResourceManager dictionaryFromFilesNamed:@"commodities.plist" inFolder:@"Config" andMerge:YES] retain];
|
||||
commoditydata = [[NSArray arrayWithArray:[commoditylists arrayForKey:@"default"]] retain];
|
||||
commodityLists = [(NSDictionary *)[ResourceManager dictionaryFromFilesNamed:@"commodities.plist" inFolder:@"Config" andMerge:YES] retain];
|
||||
commodityData = [[NSArray arrayWithArray:[commodityLists arrayForKey:@"default"]] retain];
|
||||
|
||||
illegal_goods = [[ResourceManager dictionaryFromFilesNamed:@"illegal_goods.plist" inFolder:@"Config" andMerge:YES] retain];
|
||||
|
||||
@ -223,13 +224,14 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
|
||||
customsounds = [[ResourceManager dictionaryFromFilesNamed:@"customsounds.plist" inFolder:@"Config" andMerge:YES] retain];
|
||||
[self preloadSounds];
|
||||
|
||||
planetinfo = [[ResourceManager dictionaryFromFilesNamed:@"planetinfo.plist" inFolder:@"Config" mergeMode:MERGE_SMART cache:YES] retain];
|
||||
planetInfo = [[ResourceManager dictionaryFromFilesNamed:@"planetinfo.plist" inFolder:@"Config" mergeMode:MERGE_SMART cache:YES] retain];
|
||||
|
||||
pirateVictimRoles = [[NSSet alloc] initWithArray:[ResourceManager arrayFromFilesNamed:@"pirate-victim-roles.plist" inFolder:@"Config" andMerge:YES]];
|
||||
|
||||
autoAIMap = [ResourceManager dictionaryFromFilesNamed:@"autoAImap.plist" inFolder:@"Config" andMerge:YES];
|
||||
|
||||
equipmentdata = [[ResourceManager arrayFromFilesNamed:@"equipment.plist" inFolder:@"Config" andMerge:YES] retain];
|
||||
equipmentData = [[ResourceManager arrayFromFilesNamed:@"equipment.plist" inFolder:@"Config" andMerge:YES] retain];
|
||||
[OOEquipmentType loadEquipment];
|
||||
|
||||
localPlanetInfoOverrides = [[NSMutableDictionary alloc] initWithCapacity:8];
|
||||
|
||||
@ -309,16 +311,16 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
|
||||
[entities release];
|
||||
[shipyard release];
|
||||
|
||||
[commoditylists release];
|
||||
[commoditydata release];
|
||||
[commodityLists release];
|
||||
[commodityData release];
|
||||
|
||||
[illegal_goods release];
|
||||
[descriptions release];
|
||||
[characters release];
|
||||
[customsounds release];
|
||||
[planetinfo release];
|
||||
[planetInfo release];
|
||||
[missiontext release];
|
||||
[equipmentdata release];
|
||||
[equipmentData release];
|
||||
[demo_ships release];
|
||||
[gameView release];
|
||||
|
||||
@ -453,11 +455,11 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
|
||||
[shipyard autorelease];
|
||||
shipyard = [[ResourceManager dictionaryFromFilesNamed:@"shipyard.plist" inFolder:@"Config" andMerge:YES] retain];
|
||||
|
||||
[commoditylists autorelease];
|
||||
commoditylists = [[ResourceManager dictionaryFromFilesNamed:@"commodities.plist" inFolder:@"Config" andMerge:YES] retain];
|
||||
[commodityLists autorelease];
|
||||
commodityLists = [[ResourceManager dictionaryFromFilesNamed:@"commodities.plist" inFolder:@"Config" andMerge:YES] retain];
|
||||
|
||||
[commoditydata autorelease];
|
||||
commoditydata = [[NSArray arrayWithArray:[commoditylists arrayForKey:@"default"]] retain];
|
||||
[commodityData autorelease];
|
||||
commodityData = [[NSArray arrayWithArray:[commodityLists arrayForKey:@"default"]] retain];
|
||||
|
||||
[illegal_goods autorelease];
|
||||
illegal_goods = [[ResourceManager dictionaryFromFilesNamed:@"illegal_goods.plist" inFolder:@"Config" andMerge:YES] retain];
|
||||
@ -471,20 +473,21 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
|
||||
[customsounds autorelease];
|
||||
customsounds = [[ResourceManager dictionaryFromFilesNamed:@"customsounds.plist" inFolder:@"Config" andMerge:YES] retain];
|
||||
|
||||
[planetinfo autorelease];
|
||||
planetinfo = [[ResourceManager dictionaryFromFilesNamed:@"planetinfo.plist" inFolder:@"Config" mergeMode:MERGE_SMART cache:YES] retain];
|
||||
[planetInfo autorelease];
|
||||
planetInfo = [[ResourceManager dictionaryFromFilesNamed:@"planetinfo.plist" inFolder:@"Config" mergeMode:MERGE_SMART cache:YES] retain];
|
||||
|
||||
[pirateVictimRoles autorelease];
|
||||
pirateVictimRoles = [[NSSet alloc] initWithArray:[ResourceManager arrayFromFilesNamed:@"pirate-victim-roles.plist" inFolder:@"Config" andMerge:YES]];
|
||||
|
||||
[equipmentdata autorelease];
|
||||
equipmentdata = [[ResourceManager arrayFromFilesNamed:@"equipment.plist" inFolder:@"Config" andMerge:YES] retain];
|
||||
if (strict && ([equipmentdata count] > NUMBER_OF_STRICT_EQUIPMENT_ITEMS))
|
||||
[equipmentData autorelease];
|
||||
equipmentData = [[ResourceManager arrayFromFilesNamed:@"equipment.plist" inFolder:@"Config" andMerge:YES] retain];
|
||||
if (strict && ([equipmentData count] > NUMBER_OF_STRICT_EQUIPMENT_ITEMS))
|
||||
{
|
||||
NSArray* strict_equipment = [equipmentdata subarrayWithRange:NSMakeRange(0, NUMBER_OF_STRICT_EQUIPMENT_ITEMS)]; // alloc retains
|
||||
[equipmentdata autorelease];
|
||||
equipmentdata = [strict_equipment retain];
|
||||
NSArray* strict_equipment = [equipmentData subarrayWithRange:NSMakeRange(0, NUMBER_OF_STRICT_EQUIPMENT_ITEMS)]; // alloc retains
|
||||
[equipmentData autorelease];
|
||||
equipmentData = [strict_equipment retain];
|
||||
}
|
||||
[OOEquipmentType loadEquipment];
|
||||
if(showDemo)
|
||||
{
|
||||
[demo_ships release];
|
||||
@ -736,9 +739,9 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
|
||||
|
||||
// check at this point
|
||||
// for scripted overrides for this insterstellar area
|
||||
[systeminfo addEntriesFromDictionary:[planetinfo dictionaryForKey:PLANETINFO_UNIVERSAL_KEY]];
|
||||
[systeminfo addEntriesFromDictionary:[planetinfo dictionaryForKey:@"interstellar space"]];
|
||||
[systeminfo addEntriesFromDictionary:[planetinfo dictionaryForKey:override_key]];
|
||||
[systeminfo addEntriesFromDictionary:[planetInfo dictionaryForKey:PLANETINFO_UNIVERSAL_KEY]];
|
||||
[systeminfo addEntriesFromDictionary:[planetInfo dictionaryForKey:@"interstellar space"]];
|
||||
[systeminfo addEntriesFromDictionary:[planetInfo dictionaryForKey:override_key]];
|
||||
[systeminfo addEntriesFromDictionary:[localPlanetInfoOverrides dictionaryForKey:override_key]];
|
||||
}
|
||||
|
||||
@ -2994,10 +2997,10 @@ static BOOL IsCandidateMainStationPredicate(Entity *entity, void *parameter)
|
||||
NSArray *itemData = nil;
|
||||
NSString *itemType = nil;
|
||||
|
||||
count = [equipmentdata count];
|
||||
count = [equipmentData count];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
itemData = [equipmentdata arrayAtIndex:i];
|
||||
itemData = [equipmentData arrayAtIndex:i];
|
||||
itemType = [itemData stringAtIndex:EQUIPMENT_KEY_INDEX];
|
||||
|
||||
if ([itemType isEqual:weapon_key])
|
||||
@ -3039,12 +3042,12 @@ static BOOL IsCandidateMainStationPredicate(Entity *entity, void *parameter)
|
||||
reverse the probabilities for scarce goods.
|
||||
*/
|
||||
NSMutableArray *accumulator = [NSMutableArray arrayWithCapacity:how_many];
|
||||
OOCargoQuantity quantities[[commoditydata count]];
|
||||
OOCargoQuantity quantities[[commodityData count]];
|
||||
OOCargoQuantity total_quantity = 0;
|
||||
unsigned i;
|
||||
for (i = 0; i < [commoditydata count]; i++)
|
||||
for (i = 0; i < [commodityData count]; i++)
|
||||
{
|
||||
OOCargoQuantity q = [[commoditydata arrayAtIndex:i] unsignedIntAtIndex:MARKET_QUANTITY];
|
||||
OOCargoQuantity q = [[commodityData arrayAtIndex:i] unsignedIntAtIndex:MARKET_QUANTITY];
|
||||
if (scarce)
|
||||
{
|
||||
if (q < 64) q = 64 - q;
|
||||
@ -3146,7 +3149,7 @@ static BOOL IsCandidateMainStationPredicate(Entity *entity, void *parameter)
|
||||
|
||||
- (OOCargoType) getRandomCommodity
|
||||
{
|
||||
return Ranrot() % [commoditydata count];
|
||||
return Ranrot() % [commodityData count];
|
||||
}
|
||||
|
||||
|
||||
@ -3155,9 +3158,9 @@ static BOOL IsCandidateMainStationPredicate(Entity *entity, void *parameter)
|
||||
OOMassUnit units;
|
||||
unsigned commidityIndex = (unsigned)co_type;
|
||||
|
||||
if (co_type < 0 || [commoditydata count] <= commidityIndex) return 0;
|
||||
if (co_type < 0 || [commodityData count] <= commidityIndex) return 0;
|
||||
|
||||
units = [[commoditydata arrayAtIndex:commidityIndex] intAtIndex:MARKET_UNITS];
|
||||
units = [[commodityData arrayAtIndex:commidityIndex] intAtIndex:MARKET_UNITS];
|
||||
switch (units)
|
||||
{
|
||||
case 0 : // TONNES
|
||||
@ -3176,9 +3179,9 @@ static BOOL IsCandidateMainStationPredicate(Entity *entity, void *parameter)
|
||||
|
||||
- (NSArray *)commodityDataForType:(OOCargoType)type
|
||||
{
|
||||
if (type < 0 || [commoditydata count] <= (unsigned)type) return nil;
|
||||
if (type < 0 || [commodityData count] <= (unsigned)type) return nil;
|
||||
|
||||
return [commoditydata arrayAtIndex:type];
|
||||
return [commodityData arrayAtIndex:type];
|
||||
}
|
||||
|
||||
|
||||
@ -3187,15 +3190,15 @@ static BOOL IsCandidateMainStationPredicate(Entity *entity, void *parameter)
|
||||
unsigned i, count;
|
||||
NSString *name;
|
||||
|
||||
count = [commoditydata count];
|
||||
count = [commodityData count];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
/* Bug: NSNotFound being returned for valid names.
|
||||
Analysis: Looking for name in commoditydata rather than ith element.
|
||||
Fix: look in [commoditydata objectAtIndex:i].
|
||||
Analysis: Looking for name in commodityData rather than ith element.
|
||||
Fix: look in [commodityData objectAtIndex:i].
|
||||
-- Ahruman 20070714
|
||||
*/
|
||||
name = [[commoditydata arrayAtIndex:i] stringAtIndex:MARKET_NAME];
|
||||
name = [[commodityData arrayAtIndex:i] stringAtIndex:MARKET_NAME];
|
||||
if ([co_name caseInsensitiveCompare:name] == NSOrderedSame)
|
||||
{
|
||||
return i;
|
||||
@ -5908,9 +5911,9 @@ OOINLINE BOOL EntityInRange(Vector p1, Entity *e2, float range)
|
||||
// for scripted overrides for this planet
|
||||
NSDictionary *overrides = nil;
|
||||
|
||||
overrides = [planetinfo dictionaryForKey:PLANETINFO_UNIVERSAL_KEY];
|
||||
overrides = [planetInfo dictionaryForKey:PLANETINFO_UNIVERSAL_KEY];
|
||||
if (overrides != nil) [systemdata addEntriesFromDictionary:overrides];
|
||||
overrides = [planetinfo dictionaryForKey:override_key];
|
||||
overrides = [planetInfo dictionaryForKey:override_key];
|
||||
if (overrides != nil) [systemdata addEntriesFromDictionary:overrides];
|
||||
overrides = [localPlanetInfoOverrides dictionaryForKey:override_key];
|
||||
if (overrides != nil) [systemdata addEntriesFromDictionary:overrides];
|
||||
@ -6510,7 +6513,7 @@ OOINLINE BOOL EntityInRange(Vector p1, Entity *e2, float range)
|
||||
}
|
||||
|
||||
|
||||
- (NSMutableDictionary *)localPlanetInfoOverrides;
|
||||
- (NSMutableDictionary *) localPlanetInfoOverrides;
|
||||
{
|
||||
return localPlanetInfoOverrides;
|
||||
}
|
||||
@ -6549,27 +6552,27 @@ OOINLINE BOOL EntityInRange(Vector p1, Entity *e2, float range)
|
||||
}
|
||||
|
||||
|
||||
- (NSDictionary*) planetinfo
|
||||
- (NSDictionary *) planetInfo
|
||||
{
|
||||
return planetinfo;
|
||||
return planetInfo;
|
||||
}
|
||||
|
||||
|
||||
- (NSArray *) equipmentdata
|
||||
- (NSArray *) equipmentData
|
||||
{
|
||||
return equipmentdata;
|
||||
return equipmentData;
|
||||
}
|
||||
|
||||
|
||||
- (NSDictionary *) commoditylists
|
||||
- (NSDictionary *) commodityLists
|
||||
{
|
||||
return commoditylists;
|
||||
return commodityLists;
|
||||
}
|
||||
|
||||
|
||||
- (NSArray *) commoditydata
|
||||
- (NSArray *) commodityData
|
||||
{
|
||||
return commoditydata;
|
||||
return commodityData;
|
||||
}
|
||||
|
||||
|
||||
@ -6577,10 +6580,10 @@ OOINLINE BOOL EntityInRange(Vector p1, Entity *e2, float range)
|
||||
{
|
||||
StationEntity *some_station = [self station];
|
||||
NSString *stationRole = [some_station primaryRole];
|
||||
if ([commoditylists arrayForKey:stationRole] == nil) stationRole = @"default";
|
||||
if ([commodityLists arrayForKey:stationRole] == nil) stationRole = @"default";
|
||||
|
||||
[commoditydata release];
|
||||
commoditydata = [[self commodityDataForEconomy:economy andStation:some_station andRandomFactor:random_factor] retain];
|
||||
[commodityData release];
|
||||
commodityData = [[self commodityDataForEconomy:economy andStation:some_station andRandomFactor:random_factor] retain];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@ -6593,9 +6596,9 @@ OOINLINE BOOL EntityInRange(Vector p1, Entity *e2, float range)
|
||||
|
||||
stationRole = [[self currentSystemData] stringForKey:@"market"];
|
||||
if (stationRole == nil) stationRole = [some_station primaryRole];
|
||||
if ([commoditylists arrayForKey:stationRole] == nil) stationRole = @"default";
|
||||
if ([commodityLists arrayForKey:stationRole] == nil) stationRole = @"default";
|
||||
|
||||
ourEconomy = [NSMutableArray arrayWithArray:[commoditylists arrayForKey:stationRole]];
|
||||
ourEconomy = [NSMutableArray arrayWithArray:[commodityLists arrayForKey:stationRole]];
|
||||
|
||||
for (i = 0; i < [ourEconomy count]; i++)
|
||||
{
|
||||
@ -7178,14 +7181,14 @@ double estimatedTimeForJourney(double distance, int hops)
|
||||
NSString* equipment = [options stringAtIndex:option_index];
|
||||
int eq_index = NSNotFound;
|
||||
unsigned q;
|
||||
for (q = 0; (q < [equipmentdata count])&&(eq_index == NSNotFound) ; q++)
|
||||
for (q = 0; (q < [equipmentData count])&&(eq_index == NSNotFound) ; q++)
|
||||
{
|
||||
if ([equipment isEqual:[[equipmentdata arrayAtIndex:q] stringAtIndex:EQUIPMENT_KEY_INDEX]])
|
||||
if ([equipment isEqual:[[equipmentData arrayAtIndex:q] stringAtIndex:EQUIPMENT_KEY_INDEX]])
|
||||
eq_index = q;
|
||||
}
|
||||
if (eq_index != NSNotFound)
|
||||
{
|
||||
NSArray* equipment_info = [equipmentdata arrayAtIndex:eq_index];
|
||||
NSArray* equipment_info = [equipmentData arrayAtIndex:eq_index];
|
||||
//all amounts are x/10 due to being represented in tenths of credits
|
||||
OOCreditsQuantity eq_price = [equipment_info unsignedIntAtIndex:EQUIPMENT_PRICE_INDEX] / 10;
|
||||
unsigned eq_techlevel = [equipment_info unsignedIntAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
|
||||
@ -7534,11 +7537,11 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
|
||||
{
|
||||
NSString* item_key = [mut_extras stringAtIndex:i];
|
||||
NSString* item_desc = nil;
|
||||
for (j = 0; ((j < [equipmentdata count])&&(!item_desc)) ; j++)
|
||||
for (j = 0; ((j < [equipmentData count])&&(!item_desc)) ; j++)
|
||||
{
|
||||
NSString *eq_type = [[equipmentdata arrayAtIndex:j] stringAtIndex:EQUIPMENT_KEY_INDEX];
|
||||
NSString *eq_type = [[equipmentData arrayAtIndex:j] stringAtIndex:EQUIPMENT_KEY_INDEX];
|
||||
if ([eq_type isEqual:item_key])
|
||||
item_desc = [[equipmentdata arrayAtIndex:j] stringAtIndex:EQUIPMENT_SHORT_DESC_INDEX];
|
||||
item_desc = [[equipmentData arrayAtIndex:j] stringAtIndex:EQUIPMENT_SHORT_DESC_INDEX];
|
||||
}
|
||||
if (item_desc)
|
||||
{
|
||||
@ -7568,11 +7571,11 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
|
||||
{
|
||||
NSString* item_key = [options stringAtIndex:i];
|
||||
NSString* item_desc = nil;
|
||||
for (j = 0; ((j < [equipmentdata count])&&(!item_desc)) ; j++)
|
||||
for (j = 0; ((j < [equipmentData count])&&(!item_desc)) ; j++)
|
||||
{
|
||||
NSString *eq_type = [[equipmentdata arrayAtIndex:j] stringAtIndex:EQUIPMENT_KEY_INDEX];
|
||||
NSString *eq_type = [[equipmentData arrayAtIndex:j] stringAtIndex:EQUIPMENT_KEY_INDEX];
|
||||
if ([eq_type isEqual:item_key])
|
||||
item_desc = [[equipmentdata arrayAtIndex:j] stringAtIndex:EQUIPMENT_SHORT_DESC_INDEX];
|
||||
item_desc = [[equipmentData arrayAtIndex:j] stringAtIndex:EQUIPMENT_SHORT_DESC_INDEX];
|
||||
}
|
||||
if (item_desc)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user