* Fixed backing up of log (OS X only).

* Only release plist parsing error messages under OS X (this is a documented requirement that doesn't follow normal usage, and isn't the right thing under GNUstep.)
* Work on shipdata.plist and model verifier stages.
* equipment_price_factor fixes: exploit when low equipment_price_factor doesn't affect refund prices, minimum equipment_price_factor of 0.5.
* Made fuel unsigned.
* Implemented property list schema verifier to simplify implementation of plist checkers.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1104 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Jens Ayton 2007-07-25 16:43:29 +00:00
parent b5d7ca37ee
commit 97211c9285
23 changed files with 2217 additions and 274 deletions

View File

@ -26,7 +26,7 @@ endif
OBJC_PROGRAM_NAME = oolite
oolite_C_FILES = legacy_random.c strlcpy.c
oolite_OBJC_FILES = 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
oolite_OBJC_FILES = 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
include $(GNUSTEP_MAKEFILES)/objc.make
include GNUmakefile.postamble

View File

@ -2335,8 +2335,6 @@
<real>0.5</real>
<key>max_flight_speed</key>
<real>50</real>
<key>max_missiles</key>
<integer>0</integer>
<key>missile_launch_position</key>
<string>0.0 0.0 4.5</string>
<key>missiles</key>
@ -2355,14 +2353,6 @@
</array>
<key>thrust</key>
<real>5</real>
<key>view_position_aft</key>
<string>0.0 0.0 -1.67</string>
<key>view_position_forward</key>
<string>0.0 0.0 4.18</string>
<key>view_position_port</key>
<string>-1.31 0.76 0.34</string>
<key>view_position_starboard</key>
<string>1.31 0.76 0.34</string>
<key>weapon_position_aft</key>
<string>0.0 0.0 -1.67</string>
<key>weapon_position_forward</key>
@ -2418,8 +2408,6 @@
<real>3.6</real>
<key>max_flight_speed</key>
<real>300</real>
<key>max_missiles</key>
<integer>2</integer>
<key>missile_launch_position</key>
<string>0.0 -10.5 16.5</string>
<key>missiles</key>
@ -2617,8 +2605,6 @@
<real>3</real>
<key>max_flight_speed</key>
<real>300</real>
<key>max_missiles</key>
<integer>1</integer>
<key>missile_launch_position</key>
<string>0.0 -2.0 10.0</string>
<key>missiles</key>
@ -2631,16 +2617,6 @@
<string>pirate oolite-gecko</string>
<key>thrust</key>
<real>45</real>
<key>view_position_aft</key>
<string>0.0 5.0 -20.0</string>
<key>view_position_forward</key>
<string>0.0 1.9375 5.0</string>
<key>view_position_port</key>
<string>-11.85 2.825 -3.5</string>
<key>view_position_starboard</key>
<string>11.85 2.825 -3.5</string>
<key>weapon_position_aft</key>
<string>0.0 -5.0 -20.0</string>
<key>weapon_position_forward</key>
<string>0.0 0.0417 16.6667</string>
<key>weapon_position_port</key>
@ -2702,8 +2678,6 @@
<real>8</real>
<key>max_flight_speed</key>
<real>0.0</real>
<key>max_missiles</key>
<integer>0</integer>
<key>missiles</key>
<integer>0</integer>
<key>model</key>
@ -2782,8 +2756,6 @@
<real>2.75</real>
<key>max_flight_speed</key>
<real>300</real>
<key>max_missiles</key>
<integer>0</integer>
<key>missile_launch_position</key>
<string>0.0 -3.5 16.5</string>
<key>missiles</key>
@ -2796,14 +2768,6 @@
<string>pirate hunter oolite-krait</string>
<key>thrust</key>
<real>35</real>
<key>view_position_aft</key>
<string>0.0 5.0 -20.0</string>
<key>view_position_forward</key>
<string>0.0 3.0 16.0</string>
<key>view_position_port</key>
<string>-11.25 2.5 6.625</string>
<key>view_position_starboard</key>
<string>11.25 2.5 6.625</string>
<key>weapon_position_aft</key>
<string>0.0 -5.0 -20.0</string>
<key>weapon_position_forward</key>
@ -2849,8 +2813,6 @@
<real>2.1</real>
<key>max_flight_speed</key>
<real>320</real>
<key>max_missiles</key>
<integer>0</integer>
<key>missile_launch_position</key>
<string>0.0 -3.5 3.5</string>
<key>missiles</key>
@ -2863,14 +2825,6 @@
<string>pirate oolite-mamba</string>
<key>thrust</key>
<real>32</real>
<key>view_position_aft</key>
<string>0.0 4.5 -27.5</string>
<key>view_position_forward</key>
<string>0.0 2.4 5.5</string>
<key>view_position_port</key>
<string>-12.125 0.0 0.0</string>
<key>view_position_starboard</key>
<string>12.125 0.0 0.0</string>
<key>weapon_position_aft</key>
<string>0.0 -4.5 -27.5</string>
<key>weapon_position_forward</key>
@ -2912,8 +2866,6 @@
<real>2.1</real>
<key>max_flight_speed</key>
<real>320</real>
<key>max_missiles</key>
<integer>0</integer>
<key>missile_launch_position</key>
<string>0.0 -3.5 3.5</string>
<key>missiles</key>
@ -2926,14 +2878,6 @@
<string>escort oolite-mamba-escort</string>
<key>thrust</key>
<real>32</real>
<key>view_position_aft</key>
<string>0.0 4.5 -27.5</string>
<key>view_position_forward</key>
<string>0.0 2.4 5.5</string>
<key>view_position_port</key>
<string>-12.125 0.0 0.0</string>
<key>view_position_starboard</key>
<string>12.125 0.0 0.0</string>
<key>weapon_position_aft</key>
<string>0.0 -4.5 -27.5</string>
<key>weapon_position_forward</key>
@ -2971,8 +2915,6 @@
<real>10</real>
<key>max_flight_speed</key>
<real>750</real>
<key>max_missiles</key>
<integer>0</integer>
<key>missiles</key>
<integer>0</integer>
<key>model</key>
@ -3028,8 +2970,6 @@
<real>2.5</real>
<key>max_flight_speed</key>
<real>300</real>
<key>max_missiles</key>
<integer>2</integer>
<key>missile_launch_position</key>
<string>0.0 -7.75 0.5</string>
<key>missiles</key>
@ -3225,8 +3165,6 @@
<real>2.5</real>
<key>max_flight_speed</key>
<real>300</real>
<key>max_missiles</key>
<integer>2</integer>
<key>missile_launch_position</key>
<string>0.0 -7.75 0.5</string>
<key>missiles</key>
@ -3426,8 +3364,6 @@
<real>2</real>
<key>max_flight_speed</key>
<real>200</real>
<key>max_missiles</key>
<integer>2</integer>
<key>missile_launch_position</key>
<string>0.0 -20.5 -18.0</string>
<key>missiles</key>
@ -3493,8 +3429,6 @@
<real>2</real>
<key>max_flight_speed</key>
<real>200</real>
<key>max_missiles</key>
<integer>2</integer>
<key>missile_launch_position</key>
<string>0.0 -20.5 -18.0</string>
<key>missiles</key>
@ -3694,8 +3628,6 @@
<real>2</real>
<key>max_flight_speed</key>
<real>200</real>
<key>max_missiles</key>
<integer>2</integer>
<key>missile_launch_position</key>
<string>0.0 -20.5 -18.0</string>
<key>missiles</key>
@ -3778,8 +3710,6 @@
<real>8</real>
<key>max_flight_speed</key>
<real>0.0</real>
<key>max_missiles</key>
<integer>0</integer>
<key>max_scavengers</key>
<integer>1</integer>
<key>missiles</key>
@ -3878,8 +3808,6 @@
<real>2</real>
<key>max_flight_speed</key>
<real>80</real>
<key>max_missiles</key>
<integer>0</integer>
<key>missile_launch_position</key>
<string>0.0 -7.25 15.0</string>
<key>missiles</key>
@ -3892,14 +3820,6 @@
<string>shuttle oolite-shuttle</string>
<key>thrust</key>
<real>16</real>
<key>view_position_aft</key>
<string>0.0 15.0 -49.5</string>
<key>view_position_forward</key>
<string>0.0 2.25 14.5</string>
<key>view_position_port</key>
<string>-3.0 1.5 13.5</string>
<key>view_position_starboard</key>
<string>3.0 1.5 13.5</string>
<key>weapon_position_aft</key>
<string>0.0 0.0 -17.5</string>
<key>weapon_position_forward</key>
@ -3941,8 +3861,6 @@
<real>2.8</real>
<key>max_flight_speed</key>
<real>370</real>
<key>max_missiles</key>
<integer>0</integer>
<key>missile_launch_position</key>
<string>0.0 -3.0 6.0</string>
<key>missiles</key>
@ -3955,14 +3873,6 @@
<string>pirate hunter oolite-sidewinder</string>
<key>thrust</key>
<real>37</real>
<key>view_position_aft</key>
<string>0.0 7.0 -17.5</string>
<key>view_position_forward</key>
<string>0.0 2.5 5.83</string>
<key>view_position_port</key>
<string>-16.67 2.5 -5.83</string>
<key>view_position_starboard</key>
<string>16.67 2.5 -5.83</string>
<key>weapon_position_aft</key>
<string>0.0 -6.5 -17.5</string>
<key>weapon_position_forward</key>
@ -4004,8 +3914,6 @@
<real>2.8</real>
<key>max_flight_speed</key>
<real>370</real>
<key>max_missiles</key>
<integer>0</integer>
<key>missile_launch_position</key>
<string>0.0 -3.0 6.0</string>
<key>missiles</key>
@ -4018,14 +3926,6 @@
<string>escort hunter oolite-sidewinder-escort</string>
<key>thrust</key>
<real>37</real>
<key>view_position_aft</key>
<string>0.0 7.0 -17.5</string>
<key>view_position_forward</key>
<string>0.0 2.5 5.83</string>
<key>view_position_port</key>
<string>-16.67 2.5 -5.83</string>
<key>view_position_starboard</key>
<string>16.67 2.5 -5.83</string>
<key>weapon_position_aft</key>
<string>0.0 -6.5 -17.5</string>
<key>weapon_position_forward</key>
@ -4193,8 +4093,6 @@
<real>2</real>
<key>max_flight_speed</key>
<real>500</real>
<key>max_missiles</key>
<integer>5</integer>
<key>missile_role</key>
<string>thargon</string>
<key>missile_launch_position</key>
@ -4245,8 +4143,6 @@
<real>2</real>
<key>max_flight_speed</key>
<real>100</real>
<key>max_missiles</key>
<integer>0</integer>
<key>missile_launch_position</key>
<string>0.0 -5.5 0.5</string>
<key>missiles</key>
@ -4259,14 +4155,6 @@
<string>shuttle oolite-transporter</string>
<key>thrust</key>
<real>20</real>
<key>view_position_aft</key>
<string>0.0 2.5 -17.5</string>
<key>view_position_forward</key>
<string>0.0 0.17 13.67</string>
<key>view_position_port</key>
<string>-5.83 0.17 9.83</string>
<key>view_position_starboard</key>
<string>5.83 0.17 9.83</string>
<key>weapon_position_aft</key>
<string>0.0 -1.0 -17.5</string>
<key>weapon_position_forward</key>
@ -4311,8 +4199,6 @@
<real>2</real>
<key>max_flight_speed</key>
<real>100</real>
<key>max_missiles</key>
<integer>0</integer>
<key>missile_launch_position</key>
<string>0.0 -5.5 0.5</string>
<key>missiles</key>
@ -4325,14 +4211,6 @@
<string>miner oolite-transporter-miner</string>
<key>thrust</key>
<real>20</real>
<key>view_position_aft</key>
<string>0.0 2.5 -17.5</string>
<key>view_position_forward</key>
<string>0.0 0.17 13.67</string>
<key>view_position_port</key>
<string>-5.83 0.17 9.83</string>
<key>view_position_starboard</key>
<string>5.83 0.17 9.83</string>
<key>weapon_position_aft</key>
<string>0.0 -1.0 -17.5</string>
<key>weapon_position_forward</key>
@ -4377,8 +4255,6 @@
<real>2.8</real>
<key>max_flight_speed</key>
<real>320</real>
<key>max_missiles</key>
<integer>1</integer>
<key>missile_launch_position</key>
<string>0.0 -8.5 -11.0</string>
<key>missiles</key>
@ -4408,14 +4284,6 @@
</array>
<key>thrust</key>
<real>32</real>
<key>view_position_aft</key>
<string>0.0 6.0 -27.5</string>
<key>view_position_forward</key>
<string>0.0 6.0 6.875</string>
<key>view_position_port</key>
<string>-6.25 4.0 0.0</string>
<key>view_position_starboard</key>
<string>6.25 4.0 0.0</string>
<key>weapon_position_aft</key>
<string>0.0 0.0 -27.5</string>
<key>weapon_position_forward</key>
@ -4465,8 +4333,6 @@
<real>4.2</real>
<key>max_flight_speed</key>
<real>520</real>
<key>max_missiles</key>
<integer>3</integer>
<key>missile_launch_position</key>
<string>0.0 -10.5 -9.0</string>
<key>missiles</key>
@ -4496,14 +4362,6 @@
</array>
<key>thrust</key>
<real>50</real>
<key>view_position_aft</key>
<string>0.0 8.0 -32.0</string>
<key>view_position_forward</key>
<string>0.0 6.0 12.8</string>
<key>view_position_port</key>
<string>-10.5 3.0 8.9</string>
<key>view_position_starboard</key>
<string>10.5 3.0 8.9</string>
<key>weapon_position_aft</key>
<string>0.0 -8.0 -32.0</string>
<key>weapon_position_forward</key>
@ -4548,8 +4406,6 @@
<real>2.8</real>
<key>max_flight_speed</key>
<real>360</real>
<key>max_missiles</key>
<integer>1</integer>
<key>missile_launch_position</key>
<string>0.0 -8.5 -11.0</string>
<key>missiles</key>
@ -4562,14 +4418,6 @@
<string>wingman oolite-viper-pursuit</string>
<key>thrust</key>
<real>36</real>
<key>view_position_aft</key>
<string>0.0 6.0 -27.5</string>
<key>view_position_forward</key>
<string>0.0 6.0 6.875</string>
<key>view_position_port</key>
<string>-6.25 4.0 0.0</string>
<key>view_position_starboard</key>
<string>6.25 4.0 0.0</string>
<key>weapon_position_aft</key>
<string>0.0 0.0 -27.5</string>
<key>weapon_position_forward</key>
@ -4609,8 +4457,6 @@
<real>2</real>
<key>max_flight_speed</key>
<real>110</real>
<key>max_missiles</key>
<integer>0</integer>
<key>missile_launch_position</key>
<string>0.0 -6.5 13.0</string>
<key>missiles</key>
@ -4623,14 +4469,6 @@
<string>shuttle oolite-worm</string>
<key>thrust</key>
<real>12</real>
<key>view_position_aft</key>
<string>0.0 4.8 -17.5</string>
<key>view_position_forward</key>
<string>0.0 -1.2 11.5</string>
<key>view_position_port</key>
<string>-10.25 0.0 -2.5</string>
<key>view_position_starboard</key>
<string>10.25 0.0 -2.5</string>
<key>weapon_position_aft</key>
<string>0.0 -4.8 -17.5</string>
<key>weapon_position_forward</key>
@ -4672,8 +4510,6 @@
<real>2</real>
<key>max_flight_speed</key>
<real>100</real>
<key>max_missiles</key>
<integer>0</integer>
<key>missile_launch_position</key>
<string>0.0 -6.5 13.0</string>
<key>missiles</key>
@ -4686,14 +4522,6 @@
<string>miner oolite-worm-miner</string>
<key>thrust</key>
<real>12</real>
<key>view_position_aft</key>
<string>0.0 4.8 -17.5</string>
<key>view_position_forward</key>
<string>0.0 -1.2 11.5</string>
<key>view_position_port</key>
<string>-10.25 0.0 -2.5</string>
<key>view_position_starboard</key>
<string>10.25 0.0 -2.5</string>
<key>weapon_position_aft</key>
<string>0.0 -4.8 -17.5</string>
<key>weapon_position_forward</key>
@ -4732,8 +4560,6 @@
<real>10</real>
<key>max_flight_speed</key>
<real>750</real>
<key>max_missiles</key>
<integer>0</integer>
<key>missiles</key>
<integer>0</integer>
<key>model</key>
@ -4829,8 +4655,6 @@
<string>Question Mark</string>
<key>roles</key>
<string>oo-unknown-ship oolite-unknown-ship</string>
<key>scanClass</key>
<string>CLASS_NEUTRAL</string>
<key>smooth</key>
<true/>
<key>materials</key>

View File

@ -81,7 +81,7 @@
skipDirectories =
(
// Directories to silently skip (version control systems make these)
// Directories to silently skip (version control systems make these).
".svn",
"CVS"
);
@ -239,38 +239,438 @@
"custom_views",
"max_missiles"
);
validWeaponTypes =
(
"WEAPON_NONE",
"WEAPON_PLASMA_CANNON",
"WEAPON_PULSE_LASER",
"WEAPON_BEAM_LASER",
"WEAPON_MINING_LASER",
"WEAPON_MILITARY_LASER",
"WEAPON_THARGOID_LASER"
);
validScanClasses =
(
"CLASS_NOT_SET",
"CLASS_BUOY",
"CLASS_CARGO",
"CLASS_MILITARY",
"CLASS_MISSILE",
"CLASS_POLICE",
"CLASS_ROCK",
"CLASS_STATION",
"CLASS_THARGOID"
);
validCargoTypes =
(
"CARGO_NOT_CARGO",
"CARGO_SLAVES",
"CARGO_ALLOY",
"CARGO_MINERALS",
"CARGO_THARGOID",
"CARGO_RANDOM",
"CARGO_SCRIPTED_ITEM",
"CARGO_CHARACTER"
);
entrySchema =
{
type = "dictionary";
$definitions =
{
// "Special" types referred to above.
$weaponType =
{
type = "enumeration";
values =
(
"WEAPON_NONE",
"WEAPON_PLASMA_CANNON",
"WEAPON_PULSE_LASER",
"WEAPON_BEAM_LASER",
"WEAPON_MINING_LASER",
"WEAPON_MILITARY_LASER",
"WEAPON_THARGOID_LASER"
);
};
$materialDict =
{
type = "dictionary";
schema =
{
ambient = "$colorSpecifier";
diffuse = "$colorSpecifier";
diffuse_map = "$textureSpecifier";
emission = "$colorSpecifier";
shininess =
{
type = "positiveInteger";
max = "128";
};
specular = "$colorSpecifier";
fragment_shader = "$shaderFileName";
textures =
{
type = "array";
valueType = "$textureSpecifier";
};
uniforms =
{
type = "dictionary";
valueType =
{
type = "oneOf";
options =
(
"string",
{
type = "dictionary";
schema =
{
asMatrix = "boolean";
binding = "string";
clamped = "boolean";
normalized = "boolean";
type =
{
type = "enumeration";
values =
(
"binding",
"float",
"real",
"int",
"integer",
"texture"
);
};
value = "float";
};
}
);
};
};
vertex_shader = "$shaderFileName";
};
};
$textureSpecifier =
{
type = "oneOf";
options =
(
"string",
{
type = "dictionary";
schema =
{
anisotropy = "positiveFloat";
mag_filter =
{
type = "enumeration";
values =
(
"nearest",
"linear"
);
};
min_filter =
{
type = "enumeration";
values =
(
"nearest",
"linear",
"mipmap",
"default"
);
};
name = "string";
no_shrink = "boolean";
repeat_s = "boolean";
repeat_t = "boolean";
texture_LOD_bias = "float";
};
}
);
};
$scanClass =
{
type = "enumeration";
values =
(
"CLASS_NOT_SET",
"CLASS_BUOY",
"CLASS_CARGO",
"CLASS_MILITARY",
"CLASS_MISSILE",
"CLASS_POLICE",
"CLASS_ROCK",
"CLASS_STATION",
"CLASS_THARGOID"
);
};
$cargoType =
{
type = "enumeration";
values =
(
"CARGO_NOT_CARGO",
"CARGO_SLAVES",
"CARGO_ALLOY",
"CARGO_MINERALS",
"CARGO_THARGOID",
"CARGO_RANDOM",
"CARGO_SCRIPTED_ITEM",
"CARGO_CHARACTER"
);
};
$customViewSpec =
{
type = "dictionary";
schema =
{
view_description = "string";
view_position = "vector";
view_orientation = "quaternion";
weapon_facing =
{
type = "enumeration";
filter = "lowerCase";
values =
(
"forward",
"aft",
"port",
"starboard"
);
};
};
};
// Types handled in code.
$modelName =
{
type = "delegatedType";
baseType =
{
type = "string";
filter = "lowerCase";
requiredSuffix = ".dat";
};
key = "modelName";
};
$colorSpecifier =
{
type = "delegatedType";
baseType =
{
type = "oneOf";
options =
(
"array",
"dictionary",
"string"
);
};
key = "colorSpecifier";
};
$textureFileName =
{
type = "delegatedType";
baseType =
{
type = "string";
filter = "lowerCase";
requiredSuffix = ".png";
};
key = "textureFileName";
};
$aiFileName =
{
type = "delegatedType";
baseType =
{
type = "string";
filter = "lowerCase";
requiredSuffix = ".plist";
};
key = "aiFileName";
};
$shaderFileName =
{
type = "delegatedType";
baseType =
{
type = "string";
filter = "lowerCase";
requiredSuffix =
(
".vertex",
".vert",
".fragment",
".frag"
);
};
key = "shaderFileName";
};
$exhaustSpecifier =
{
type = "delegatedType";
baseType = "string";
key = "exhaustSpecifier";
};
$subEntitySpecifier =
{
type = "delegatedType";
baseType = "string";
key = "subEntitySpecifier";
};
$scriptActions =
{
type = "delegatedType";
baseType = "array";
key = "scriptActions";
};
$characterKey =
{
type = "delegatedType";
baseType = "string";
key = "characterKey";
};
$shipRole =
{
type = "delegatedType";
baseType = "string";
key = "shipRole";
};
$shipKey =
{
type = "delegatedType";
baseType = "string";
key = "shipKey";
};
$roles =
{
type = "delegatedType";
baseType = "string";
key = "roles";
};
$scriptCondition =
{
type = "delegatedType";
baseType = "string";
key = "scriptCondition";
};
$scriptCouplet =
{
type = "delegatedType";
baseType = "dictionary";
key = "scriptCouplet";
};
$portDimensions =
{
type = "delegatedType";
baseType = "string";
key = "portDimensions";
};
$extraEquipmentDictionary =
{
type = "delegatedType";
baseType = "dictionary";
key = "extraEquipmentDictionary";
};
$hudFileName =
{
type = "delegatedType";
baseType = "string";
key = "hudFileName";
};
$cargoCarried =
{
type = "delegatedType";
baseType = "string";
key = "cargoCarried";
};
};
schema =
{
like_ship = "$shipRole";
max_flight_speed = "positiveFloat";
max_flight_roll = "positiveFloat";
max_flight_pitch = "positiveFloat";
max_flight_yaw = "positiveFloat";
thrust = "positiveFloat";
accuracy = "float";
max_energy = "positiveFloat";
energy_recharge_rate = "positiveFloat";
forward_weapon_type = "$weaponType";
aft_weapon_type = "$weaponType";
weapon_energy = "positiveFloat";
scanner_range = "positiveFloat";
missiles = "positiveInteger";
has_ecm = "fuzzyBoolean";
has_scoop = "fuzzyBoolean";
has_escape_pod = "positiveInteger";
has_energy_bomb = "fuzzyBoolean";
has_fuel_injection = "fuzzyBoolean";
has_cloaking_device = "fuzzyBoolean";
has_military_jammer = "fuzzyBoolean";
has_military_scanner_filter = "fuzzyBoolean";
fragment_chance = "fuzzyBoolean";
has_shield_booster = "fuzzyBoolean";
has_shield_enhancer = "fuzzyBoolean";
fuel = "positiveInteger";
bounty = "positiveInteger";
ai_type = "$aiFileName";
max_cargo = "positiveInteger";
likely_cargo = "positiveInteger";
extra_cargo = "positiveInteger";
cargo_carried = "$cargoCarried";
cargo_type = "$cargoType";
model = "$modelName";
materials = "$materialDict";
shaders = "$materialDict";
smooth = "boolean";
density = "positiveFloat";
name = "string";
roles = "$roles";
exhaust =
{
type = "array";
valueType = "$exhaustSpecifier";
};
is_hulk = "boolean";
subentities =
{
type = "array";
valueType = "$subEntitySpecifier";
};
frangible = "boolean";
laser_color = "$colorSpecifier";
scanClass = "$scanClass";
launch_actions = "$scriptActions";
script_actions = "$scriptActions";
death_actions = "$scriptActions";
setup_actions = "$scriptActions";
escorts = "positiveInteger";
beacon = "string";
rotational_velocity = "quaternion";
track_contacts = "boolean";
weapon_position_forward = "vector";
weapon_position_aft = "vector";
weapon_position_port = "vector";
weapon_position_starboard = "vector";
scoop_position = "vector";
heat_insulation = "positiveFloat";
pilot = "$characterKey";
unpiloted = "fuzzyBoolean";
escort-role = "$shipRole";
escort-ship = "$shipKey";
missile_launch_position = "vector";
missile_role = "$shipRole";
escape_pod_model = "$modelName";
aft_eject_position = "vector";
auto_ai = "boolean";
rotating = "boolean";
defense_ship = "$shipKey";
defense_ship_role = "$shipRole";
hasShipyard =
{
type = "oneOf";
options =
(
"$scriptCondition",
"boolean"
);
};
conditions = "$scriptCouplet";
port_radius = "positiveFloat";
port_dimensions = "$portDimensions";
equivalent_tech_level = "integer";
max_scavengers = "positiveInteger";
max_defense_ships = "positiveInteger";
max_police = "positiveInteger";
equipment_price_factor = "positiveFloat";
extra_equipment = "$extraEquipmentDictionary";
hud = "$hudFileName";
view_position_forward = "vector";
view_position_aft = "vector";
view_position_port = "vector";
view_position_starboard = "vector";
custom_views =
{
type = "array";
valueType = "$customViewSpec";
};
max_missiles = "positiveInteger";
};
};
};
}

View File

@ -223,7 +223,6 @@ enum
- (id)init
{
BOOL OK = YES;
NSString *basePath = nil;
NSString *logPath = nil;
NSString *oldPath = nil;
NSFileManager *fmgr = nil;
@ -231,11 +230,11 @@ enum
// We'll need these for a couple of things.
fmgr = [NSFileManager defaultManager];
basePath = GetLogBasePath();
logPath = OOLogHandlerGetLogPath();
// If there is an existing file, move it to Previous.log.
if ([fmgr fileExistsAtPath:logPath])
{
oldPath = [basePath stringByAppendingPathComponent:@"Previous.log"];
oldPath = [GetLogBasePath() stringByAppendingPathComponent:@"Previous.log"];
[fmgr removeFileAtPath:oldPath handler:nil];
if (![fmgr movePath:logPath toPath:oldPath handler:nil])
{
@ -350,10 +349,10 @@ enum
sysModel = GetSysCtlString("hw.model");
Gestalt(gestaltPhysicalRAMSizeInMegabytes, (long *)&sysPhysMem);
preamble = [NSString stringWithFormat:@"Opening log for %@ version %@ [" CPU_TYPE_STRING "] at %@.\n"
preamble = [NSString stringWithFormat:@"Opening log for %@ version %@ [" CPU_TYPE_STRING "] under Mac OS X %@ at %@.\n"
"Machine type: %@, %u MiB memory, CPU: %@.\n"
"Note that the contents of the log file can be adjusted by editing logcontrol.plist.\n",
GetAppName(), versionString, [NSDate date],
GetAppName(), versionString, [[NSProcessInfo processInfo] operatingSystemVersionString], [NSDate date],
sysModel, sysPhysMem, GetCPUDescription()];
[self asyncLogMessage:preamble];
}

View File

@ -1017,7 +1017,7 @@ static NSString * const kOOLogEntityUpdateError = @"entity.linkedList.update.
- (void)subEntityReallyDied:(ShipEntity *)sub
{
OOLog(@"entity.bug", @"%s called for non-ship entity %@ by %@", __FUNCTION__, self, sub);
OOLog(@"entity.bug", @"%s called for non-ship entity %p by %p", __FUNCTION__, self, sub);
}

View File

@ -4989,11 +4989,11 @@ static int last_outfitting_index;
- (BOOL) tryBuyingItem:(int) index
{
// note this doesn't check the availability by tech-level
NSArray *equipdata = [UNIVERSE equipmentdata];
int price_per_unit = [[[equipdata objectAtIndex:index] objectAtIndex:EQUIPMENT_PRICE_INDEX] intValue];
NSString *eq_key = [[equipdata objectAtIndex:index] objectAtIndex: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) ;
NSArray *equipdata = [UNIVERSE equipmentdata];
OOCreditsQuantity price_per_unit = [[[equipdata objectAtIndex:index] objectAtIndex:EQUIPMENT_PRICE_INDEX] intValue];
NSString *eq_key = [[equipdata objectAtIndex:index] objectAtIndex: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_factor = 1.0;
OOCargoQuantity cargo_space = max_cargo - current_cargo;
@ -5066,30 +5066,39 @@ static int last_outfitting_index;
credits -= price;
// refund here for current_weapon;
// refund here for current_weapon
/* BUG: equipment_price_factor does not affect trade-ins. This means
that an equipment_price_factor less than one can be exploited.
Analysis: price factor simply not being applied here.
Fix: trivial.
Acknowledgment: bug and fix both reported by Cmdr James on forum.
-- Ahruman 20070724
*/
OOCreditsQuantity tradeIn = 0;
switch (current_weapon)
{
case WEAPON_PLASMA_CANNON :
credits += [UNIVERSE getPriceForWeaponSystemWithKey:@"EQ_WEAPON_TWIN_PLASMA_CANNON"];
tradeIn = [UNIVERSE getPriceForWeaponSystemWithKey:@"EQ_WEAPON_TWIN_PLASMA_CANNON"];
break;
case WEAPON_PULSE_LASER :
credits += [UNIVERSE getPriceForWeaponSystemWithKey:@"EQ_WEAPON_PULSE_LASER"];
tradeIn = [UNIVERSE getPriceForWeaponSystemWithKey:@"EQ_WEAPON_PULSE_LASER"];
break;
case WEAPON_BEAM_LASER :
credits += [UNIVERSE getPriceForWeaponSystemWithKey:@"EQ_WEAPON_BEAM_LASER"];
tradeIn = [UNIVERSE getPriceForWeaponSystemWithKey:@"EQ_WEAPON_BEAM_LASER"];
break;
case WEAPON_MINING_LASER :
credits += [UNIVERSE getPriceForWeaponSystemWithKey:@"EQ_WEAPON_MINING_LASER"];
tradeIn = [UNIVERSE getPriceForWeaponSystemWithKey:@"EQ_WEAPON_MINING_LASER"];
break;
case WEAPON_MILITARY_LASER :
credits += [UNIVERSE getPriceForWeaponSystemWithKey:@"EQ_WEAPON_MILITARY_LASER"];
tradeIn = [UNIVERSE getPriceForWeaponSystemWithKey:@"EQ_WEAPON_MILITARY_LASER"];
break;
case WEAPON_THARGOID_LASER :
credits += [UNIVERSE getPriceForWeaponSystemWithKey:@"EQ_WEAPON_THARGOID_LASER"];
tradeIn = [UNIVERSE getPriceForWeaponSystemWithKey:@"EQ_WEAPON_THARGOID_LASER"];
break;
case WEAPON_NONE :
break;
}
if (price_factor < 1.0f) credits += tradeIn * price_factor;
[self setGuiToEquipShipScreen:-1:-1];
return YES;

View File

@ -1194,11 +1194,13 @@ static int scriptRandomSeed = -1; // ensure proper random function
- (void) awardFuel:(NSString *)valueString // add to fuel up to 7.0 LY
{
fuel += 10 * [valueString floatValue];
if (fuel > PLAYER_MAX_FUEL)
fuel = PLAYER_MAX_FUEL;
if (fuel < 0)
fuel = 0;
int delta = 10 * [valueString floatValue];
if (delta < 0 && fuel < (unsigned)-delta) fuel = 0;
else
{
fuel += delta;
if (fuel > PLAYER_MAX_FUEL) fuel = PLAYER_MAX_FUEL;
}
}

View File

@ -166,7 +166,7 @@ MA 02110-1301, USA.
canFragment: 1, // Can it break into wreckage?
suppressExplosion: 1; // Avoid exploding on death (script hook)
int fuel; // witch-space fuel
OOFuelQuantity fuel; // witch-space fuel
GLfloat fuel_accumulator;
OOCargoQuantity likely_cargo; // likely amount of cargo (for merchantmen, this is what is spilled as loot)
@ -404,8 +404,8 @@ MA 02110-1301, USA.
- (void) setAI:(AI *) ai;
- (AI *) getAI;
- (int) fuel;
- (void) setFuel:(int) amount;
- (OOFuelQuantity) fuel;
- (void) setFuel:(OOFuelQuantity) amount;
- (void) setRoll:(double) amount;
- (void) setPitch:(double) amount;

View File

@ -200,18 +200,18 @@ static NSString * const kOOLogEntityBehaviourChanged = @"entity.behaviour.change
// Moved here from above upgrade loading so that ships start with full energy banks. -- Ahruman
energy = maxEnergy;
fuel = [shipDict intForKey:@"fuel"]; // Does it make sense that this defaults to 0? Should it not be 70? -- Ahruman
fuel = [shipDict unsignedShortForKey:@"fuel"]; // Does it make sense that this defaults to 0? Should it not be 70? -- Ahruman
fuel_accumulator = 1.0;
bounty = [shipDict intForKey:@"bounty"];
bounty = [shipDict unsignedIntForKey:@"bounty"];
[shipAI autorelease];
shipAI = [[AI alloc] init];
[shipAI setStateMachine:[shipDict stringForKey:@"ai_type" defaultValue:@"nullAI.plist"]];
max_cargo = [shipDict intForKey:@"max_cargo"];
likely_cargo = [shipDict intForKey:@"likely_cargo"];
extra_cargo = [shipDict intForKey:@"extra_cargo" defaultValue:15];
max_cargo = [shipDict unsignedIntForKey:@"max_cargo"];
likely_cargo = [shipDict unsignedIntForKey:@"likely_cargo"];
extra_cargo = [shipDict unsignedIntForKey:@"extra_cargo" defaultValue:15];
NSString *cargoString = [shipDict stringForKey:@"cargo_carried"];
if (cargoString != nil)
@ -3002,17 +3002,15 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
}
- (int) fuel
- (OOFuelQuantity) fuel
{
return fuel;
}
- (void) setFuel:(int) amount
- (void) setFuel:(OOFuelQuantity) amount
{
fuel = amount;
if (fuel < 0)
fuel = 0;
if (fuel > PLAYER_MAX_FUEL)
fuel = PLAYER_MAX_FUEL;
}

View File

@ -771,8 +771,9 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
max_scavengers = [dict unsignedIntForKey:@"max_scavengers" defaultValue:3];
max_defense_ships = [dict unsignedIntForKey:@"max_defense_ships" defaultValue:3];
max_police = [dict unsignedIntForKey:@"max_police" defaultValue:STATION_MAX_POLICE];
equipment_price_factor = [dict nonNegativeDoubleForKey:@"equipment_price_factor" defaultValue:1.0];
equipment_price_factor = [dict nonNegativeFloatForKey:@"equipment_price_factor" defaultValue:1.0];
equipment_price_factor = MAX(equipment_price_factor, 0.5f);
if ([self isRotatingStation])
{
docked_shuttles = ranrot_rand() & 3; // 0..3;

View File

@ -90,8 +90,14 @@ id OOPropertyListFromData(NSData *data, NSString *whereFrom)
result = [NSPropertyListSerialization propertyListFromData:data mutabilityOption:NSPropertyListImmutable format:NULL errorDescription:&error];
if (result == nil) // Foundation parser failed
{
[error autorelease]; // Note: it is a documented design wart that this string needs releasing.
{
#if OOLITE_MAC_OS_X
/* Documented wart: this is caller responsibility in Cocoa (but not GNUstep?)
TODO: verify that it is correct to not do this in GNUstep.
In the mean time, not doing it in GNUstep seems to be avoiding a crash.
*/
[error autorelease];
#endif
// Ensure we can say something sensible...
if (error == nil) error = @"<no error message>";
if (whereFrom == nil) whereFrom = @"<data in memory>";

View File

@ -273,6 +273,8 @@ typedef enum
typedef uint32_t OOCargoQuantity;
typedef int32_t OOCargoQuantityDelta;
typedef uint16_t OOFuelQuantity;
typedef uint32_t OOCreditsQuantity;

View File

@ -26,6 +26,7 @@ MA 02110-1301, USA.
*/
#import "OOTextureVerifierStage.h"
#import "OOPListSchemaVerifier.h"
#if OO_OXP_VERIFIER_ENABLED
@ -37,6 +38,7 @@ MA 02110-1301, USA.
*_stationKeys,
*_playerKeys,
*_allKeys;
OOPListSchemaVerifier *_schemaVerifier;
// Info about ship currently being checked. None of these are retained!
NSString *_name;

View File

@ -42,9 +42,12 @@ static NSString * const kStageName = @"Checking shipdata.plist";
- (void)verifyShipInfo:(NSDictionary *)info withName:(NSString *)name;
- (void)message:(NSString *)format, ...;
- (void)verboseMessage:(NSString *)format, ...;
- (void)getRoles;
- (void)checkKeys;
- (void)checkSchema;
- (void)checkModel;
- (NSSet *)rolesFromString:(NSString *)string;
@ -129,6 +132,9 @@ static NSString * const kStageName = @"Checking shipdata.plist";
[mergeSet unionSet:_stationKeys];
_allKeys = mergeSet;
_schemaVerifier = [OOPListSchemaVerifier verifierWithSchema:[settings dictionaryForKey:@"entrySchema"]];
[_schemaVerifier setDelegate:self];
shipList = [[_shipdataPList allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
for (shipEnum = [shipList objectEnumerator]; (shipKey = [shipEnum nextObject]); )
{
@ -168,6 +174,8 @@ static NSString * const kStageName = @"Checking shipdata.plist";
[self getRoles];
[self checkKeys];
[self checkSchema];
[self checkModel];
OOLogPopIndent();
if (!_havePrintedMessage)
@ -198,6 +206,25 @@ static NSString * const kStageName = @"Checking shipdata.plist";
}
- (void)verboseMessage:(NSString *)format, ...
{
va_list args;
if (!OOLogWillDisplayMessagesInClass(@"verifyOXP.verbose.shipData")) return;
if (!_havePrintedMessage)
{
OOLog(@"verifyOXP.shipData.firstMessage", @"Ship \"%@\":", _name);
OOLogIndent();
_havePrintedMessage = YES;
}
va_start(args, format);
OOLogWithFunctionFileAndLineAndArguments(@"verifyOXP.verbose.shipData", NULL, NULL, 0, format, args);
va_end(args);
}
- (void)getRoles
{
NSString *rolesString = nil;
@ -244,6 +271,30 @@ static NSString * const kStageName = @"Checking shipdata.plist";
}
- (void)checkSchema
{
[_schemaVerifier validatePropertyList:_info named:_name];
}
- (void)checkModel
{
id model = nil,
materials = nil,
shaders = nil;
model = [_info stringForKey:@"model"];
materials = [_info dictionaryForKey:@"materials"];
shaders = [_info dictionaryForKey:@"shaders"];
[[[self verifier] modelVerifierStage] modelNamed:model
usedForEntry:_name
inFile:@"shipdata.plist"
withMaterials:materials
andShaders:shaders];
}
// Convert a roles string to a set of role names, discarding probabilities.
- (NSSet *)rolesFromString:(NSString *)string
{
@ -274,6 +325,19 @@ static NSString * const kStageName = @"Checking shipdata.plist";
return result;
}
- (BOOL)verifier:(OOPListSchemaVerifier *)verifier withPropertyList:(id)rootPList named:(NSString *)name testProperty:(id)subPList atPath:(NSArray *)keyPath againstType:(NSString *)typeKey
{
[self verboseMessage:@"- Skipping verification for type %@ at %@.%@.", typeKey, _name, [OOPListSchemaVerifier descriptionForKeyPath:keyPath]];
return YES;
}
- (BOOL)verifier:(OOPListSchemaVerifier *)verifier withPropertyList:(id)rootPList named:(NSString *)name failedForProperty:(id)subPList atPath:(NSArray *)keyPath expectedType:(NSDictionary *)localSchema
{
[self message:@"ERROR: wrong type (%@) in shipdata.plist at %@.%@.", [subPList class], _name, [OOPListSchemaVerifier descriptionForKeyPath:keyPath]];
return YES;
}
@end
#endif

View File

@ -280,7 +280,14 @@ static BOOL CheckNameConflict(NSString *lcName, NSDictionary *directoryCases, NS
mutabilityOption:NSPropertyListImmutable
format:&format
errorDescription:&errorString];
[errorString autorelease]; // Documented wart: this is caller responsibility
#if OOLITE_MAC_OS_X
/* Documented wart: this is caller responsibility in Cocoa (but not GNUstep?)
TODO: verify that it is correct to not do this in GNUstep.
In the mean time, not doing it in GNUstep seems to be avoiding a crash.
*/
[errorString autorelease];
#endif
if (plist != nil)
{

View File

@ -32,18 +32,25 @@ MA 02110-1301, USA.
@interface OOModelVerifierStage: OOTextureHandlingStage
{
NSMutableSet *_usedModels;
NSMutableSet *_modelsToCheck;
}
// Returns name to be used in -dependents by other stages; also registers stage.
+ (NSString *)nameForReverseDependencyForVerifier:(OOOXPVerifier *)verifier;
/* These can be called by other stages *before* the model stage runs.
The context specifies where the model is used; something like
"fooShip.dat" or "shipdata.plist materials dictionary for ship \"foo\"".
It should make sense with "Model \"foo\" referenced in " in front of it.
*/
- (void) modelNamed:(NSString *)name usedInContext:(NSString *)context;
// This can be called by other stages *before* the model stage runs.
- (void) modelNamed:(NSString *)name
usedForEntry:(NSString *)entryName
inFile:(NSString *)fileName
withMaterials:(NSDictionary *)materials
andShaders:(NSDictionary *)shaders;
@end
@interface OOOXPVerifier(OOModelVerifierStage)
- (OOModelVerifierStage *)modelVerifierStage;
@end

View File

@ -31,10 +31,15 @@ MA 02110-1301, USA.
static NSString * const kStageName = @"Testing models";
static id NSNULL = nil;
@interface OOModelVerifierStage (OOPrivate)
- (void)checkModelNamed:(NSString *)name inFolder:(NSString *)folder;
- (void)checkModel:(NSString *)name
context:(NSString *)context
materials:(NSDictionary *)materials
shaders:(NSDictionary *)shaders;
@end
@ -46,7 +51,8 @@ static NSString * const kStageName = @"Testing models";
self = [super init];
if (self != nil)
{
_usedModels = [[NSMutableSet alloc] init];
NSNULL = [[NSNull null] retain];
_modelsToCheck = [[NSMutableSet alloc] init];
}
return self;
}
@ -54,7 +60,7 @@ static NSString * const kStageName = @"Testing models";
- (void)dealloc
{
[_usedModels release];
[_modelsToCheck release];
[super dealloc];
}
@ -82,35 +88,60 @@ static NSString * const kStageName = @"Testing models";
- (BOOL)shouldRun
{
return [_usedModels count] != 0;
return [_modelsToCheck count] != 0;
}
- (void)run
{
NSEnumerator *nameEnum = nil;
NSString *name = nil;
NSDictionary *info = nil;
NSAutoreleasePool *pool = nil;
NSString *name = nil,
*context = nil;
NSDictionary *materials = nil,
*shaders = nil;
OOLog(@"verifyOXP.models.unimplemented", @"TODO: implement model verifier.");
for (nameEnum = [_usedModels objectEnumerator]; (name = [nameEnum nextObject]); )
for (nameEnum = [_modelsToCheck objectEnumerator]; (info = [nameEnum nextObject]); )
{
pool = [[NSAutoreleasePool alloc] init];
[self checkModelNamed:name inFolder:@"Models"];
name = [info objectForKey:@"name"];
context = [info objectForKey:@"context"];
if (context == NSNULL) context = nil;
materials = [info objectForKey:@"materials"];
if (materials == NSNULL) materials = nil;
shaders = [info objectForKey:@"shaders"];
if (shaders == NSNULL) shaders = nil;
[self checkModel:name
context:context
materials:materials
shaders:shaders];
[pool release];
}
[_usedModels release];
_usedModels = nil;
[_modelsToCheck release];
_modelsToCheck = nil;
}
- (void) modelNamed:(NSString *)name usedInContext:(NSString *)context
- (void) modelNamed:(NSString *)name
usedForEntry:(NSString *)entryName
inFile:(NSString *)fileName
withMaterials:(NSDictionary *)materials
andShaders:(NSDictionary *)shaders
{
OOFileScannerVerifierStage *fileScanner = nil;
NSDictionary *info = nil;
NSString *context = nil;
if ([_usedModels member:name] != nil) return;
[_usedModels addObject:name];
if (name == nil) return;
if (entryName != nil) context = [NSString stringWithFormat:@"entry \"%@\" of %@", entryName, fileName];
else context = fileName;
fileScanner = [[self verifier] fileScannerStage];
if (![fileScanner fileExists:name
@ -120,6 +151,19 @@ static NSString * const kStageName = @"Testing models";
{
OOLog(@"verifyOXP.model.notFound", @"WARNING: model \"%@\" referenced in %@ could not be found in %@ or in Oolite.", name, context, [[self verifier] oxpDisplayName]);
}
if (context == nil) context = NSNULL;
if (materials == nil) materials = NSNULL;
if (shaders == nil) shaders = NSNULL;
info = [NSDictionary dictionaryWithObjectsAndKeys:
name, @"name",
context, @"context",
materials, @"materials",
shaders, @"shaders",
nil];
[_modelsToCheck addObject:info];
}
@end
@ -127,11 +171,26 @@ static NSString * const kStageName = @"Testing models";
@implementation OOModelVerifierStage (OOPrivate)
- (void)checkModelNamed:(NSString *)name inFolder:(NSString *)folder
- (void)checkModel:(NSString *)name
context:(NSString *)context
materials:(NSDictionary *)materials
shaders:(NSDictionary *)shaders
{
OOLog(@"verifyOXP.verbose.model.unimp", @"- Pretending to verify model %@ referenced in %@.", name, context);
// FIXME: this should check DAT files.
}
@end
@implementation OOOXPVerifier(OOModelVerifierStage)
- (OOModelVerifierStage *)modelVerifierStage
{
return [self stageWithName:kStageName];
}
@end
#endif

View File

@ -527,7 +527,7 @@ static void OpenLogFile(NSString *name);
}
else
{
OOLog(@"verifyOXP.verbose.skipStage", @"- Skipping stage: %@", stageName);
OOLog(@"verifyOXP.verbose.skipStage", @"- Skipping stage: %@.", stageName);
[stageToRun noteSkipped];
}
@ -713,7 +713,10 @@ static void OpenLogFile(NSString *name)
{
// Open log file in appropriate application.
[[NSWorkspace sharedWorkspace] openFile:OOLogHandlerGetLogPath()];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"oxp-verifier-open-log" defaultValue:YES])
{
[[NSWorkspace sharedWorkspace] openFile:OOLogHandlerGetLogPath()];
}
}
#endif // OOLITE_HAVE_APPKIT

View File

@ -0,0 +1,143 @@
/*
OOPListSchemaVerifier.h
Utility class to verify the structure of a property list based on a schema
(which is itself a property list).
Oolite
Copyright (C) 2004-2007 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) 2007 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 "OOOxpVerifier.h"
#if OO_OXP_VERIFIER_ENABLED
#import <Foundation/Foundation.h>
@interface OOPListSchemaVerifier: NSObject
{
NSDictionary *_schema;
id _delegate;
uint32_t _badDelegateWarning: 1;
}
+ (id)verifierWithSchema:(id)schema;
- (id)initWithSchema:(id)schema;
- (void)setDelegate:(id)delegate;
- (id)delegate;
- (BOOL)validatePropertyList:(id)plist named:(NSString *)name;
/* Convert a key path (such as provided to the delegate method
-verifier:withPropertyList:failedForProperty:atPath:expectedType:) to a
human-readable string. Strings are separated by dots and numbers are give
brackets. For instance, the key path ( "adder-player", "custom_views", 0,
"view_description" ) is transfomed to
"adder-player.custom_views[0].view_description".
*/
+ (NSString *)descriptionForKeyPath:(NSArray *)keyPath;
@end
@interface NSObject (OOPListSchemaVerifierDelegate)
// Handle "delegated types". Return YES for valid, NO for invalid.
- (BOOL)verifier:(OOPListSchemaVerifier *)verifier withPropertyList:(id)rootPList named:(NSString *)name testProperty:(id)subPList atPath:(NSArray *)keyPath againstType:(NSString *)typeKey;
/* Method notifying of validation failure.
Return YES to continue validating, NO to stop.
*/
- (BOOL)verifier:(OOPListSchemaVerifier *)verifier withPropertyList:(id)rootPList named:(NSString *)name failedForProperty:(id)subPList atPath:(NSArray *)keyPath expectedType:(NSDictionary *)localSchema;
@end
// NSError domain and codes used to report schema verifier errors.
extern NSString * const kOOPListSchemaVerifierErrorDomain;
extern NSString * const kPListKeyPathErrorKey;
extern NSString * const kSchemaKeyPathErrorKey;
extern NSString * const kMissingRequiredKeysErrorKey;
extern NSString * const kUnknownTypeErrorKey;
// All plist verifier errors have a short error description in their -localizedDescription. Generally this is something that would be more suitable to -localizedFailureReason, but we need Mac OS X 10.3 compatibility.
typedef enum
{
kPListErrorNone,
// Validation errors -- property list doesn't match schema.
kPListErrorTypeMismatch, // Basic type mismatch -- array instead of number, for instance.
kPListErrorMinimumConstraintNotMet, // minimum/minCount/minLength constraint violated
kPListErrorNumberIsNegative, // Negative number in positiveInteger/positiveFloat
kPListErrorStringPrefixMissing, // String does not match requiredPrefix rule.
kPListErrorStringSuffixMissing, // String does not match requiredSuffix rule.
kPListErrorStringSubstringMissing, // String does not match requiredSuffix rule.
kPListErrorDictionaryUnknownKey, // Unknown key for dictionary with allowOthers = NO.
kPListErrorDictionaryMissingRequiredKeys, // requiredKeys rule is not fulfilled. The missing keys are listed in kMissingRequiredKeysErrorKey.
kPListErrorEnumerationBadValue, // Enumeration type contains string that isn't in permitted set.
kPListDelegatedTypeError, // Delegate's verification method failed. If it returned an error, this will be in NSUnderlyingErrorKey.
// Schema errors -- schema is broken.
kPListErrorSchemaMacroRecursion, // Macro reference recursion limit hit (currently, recursion limit is 32). This can only happen on init.
kPListErrorSchemaTypeMismatch, // Bad type in schema.
kPListErrorSchemaUndefinedMacro, // Reference to undefined macro.
kPListErrorSchemaNoType, // No type specified in type specifier.
kPListErrorSchemaUnkownType, // Unknown type specified in type specifier. kUnknownTypeErrorKey is set.
kPListErrorSchemaNoOneOfOptions, // OneOf clause has no options array.
kPListErrorSchemaNoEnumerationValues // Enumeration clause has no values array.
} OOPListSchemaVerifierErrorCode;
#endif // OO_OXP_VERIFIER_ENABLED

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,7 @@ MA 02110-1301, USA.
// Returns name to be used in -dependents by other stages; also registers stage.
+ (NSString *)nameForReverseDependencyForVerifier:(OOOXPVerifier *)verifier;
/* These can be called by other stages *before* the texture stage runs.
/* This can be called by other stages *before* the texture stage runs.
The context specifies where the texture is used; something like
"fooShip.dat" or "shipdata.plist materials dictionary for ship \"foo\"".
It should make sense with "Texture \"foo\" referenced in " in front of it.
@ -53,4 +53,11 @@ MA 02110-1301, USA.
@end
@interface OOOXPVerifier(OOTextureVerifierStage)
- (OOTextureVerifierStage *)textureVerifierStage;
@end
#endif

View File

@ -119,6 +119,7 @@ static NSString * const kStageName = @"Testing textures and images";
{
OOFileScannerVerifierStage *fileScanner = nil;
if (name == nil) return;
if ([_usedTextures member:name] != nil) return;
[_usedTextures addObject:name];
@ -198,4 +199,14 @@ static NSString * const kStageName = @"Testing textures and images";
@end
@implementation OOOXPVerifier(OOTextureVerifierStage)
- (OOTextureVerifierStage *)textureVerifierStage
{
return [self stageWithName:kStageName];
}
@end
#endif

View File

@ -0,0 +1,42 @@
String filters:
lowerCase
upperCase
truncFront:#
truncBack:#
Can be chained using array.
Strings:
filters applied first.
requiredPrefix (may be array)
requiredSuffix (may be array)
requiredSubString (may be array)
minLength
maxLength
Numerical types:
minimum
maximum
Enumerations:
filters applied before test.
values
Dictionary:
minCount
maxCount
valueType
schema
allowOthers (default:YES)
requiredKeys
Array:
minCount
maxCount
valueType
oneOf:
options
delegatedType:
baseType
key