Implemented auto_ai ship attribute. Clamped laser head values for shaders. Tweaked logging to avoid sporadic 'logging not inited' message while quitting.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1074 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Jens Ayton 2007-07-12 11:33:26 +00:00
parent 43cb23d54d
commit 78275bee85
10 changed files with 115 additions and 21 deletions

View File

@ -399,6 +399,7 @@
1AC775E30C2DD4E900ECFF3B /* OODebugGLDrawing.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AC775E10C2DD4E900ECFF3B /* OODebugGLDrawing.m */; };
1AD0C1C30C44DF230070BD23 /* TextureStore.m in Sources */ = {isa = PBXBuildFile; fileRef = 25161145099544390037C2E1 /* TextureStore.m */; };
1AD0C1C40C44DF240070BD23 /* TextureStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 25161134099544390037C2E1 /* TextureStore.h */; };
1AD0C3300C463FCC0070BD23 /* autoAImap.plist in Copy Config */ = {isa = PBXBuildFile; fileRef = 1AD0C32F0C463FCB0070BD23 /* autoAImap.plist */; };
1ADBA5500BD0F173008FC99C /* OOBasicMaterial.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ADBA54E0BD0F173008FC99C /* OOBasicMaterial.h */; };
1ADBA5510BD0F173008FC99C /* OOBasicMaterial.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ADBA54F0BD0F173008FC99C /* OOBasicMaterial.m */; };
1ADF5CEC0B9DF59A00FDB2A3 /* OOCacheManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A231A170B9D8B1B00EF0852 /* OOCacheManager.m */; };
@ -564,6 +565,7 @@
dstPath = Config;
dstSubfolderSpec = 7;
files = (
1AD0C3300C463FCC0070BD23 /* autoAImap.plist in Copy Config */,
1A3591830C1C382700E52220 /* nebulatextures.plist in Copy Config */,
1A3591840C1C382700E52220 /* startextures.plist in Copy Config */,
1A34912A0BC25EAA00802DA7 /* world-scripts.plist in Copy Config */,
@ -1263,6 +1265,7 @@
1AC0E94B0B974DC200C46994 /* README_LINUX.TXT */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README_LINUX.TXT; sourceTree = "<group>"; };
1AC775E00C2DD4E900ECFF3B /* OODebugGLDrawing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OODebugGLDrawing.h; sourceTree = "<group>"; };
1AC775E10C2DD4E900ECFF3B /* OODebugGLDrawing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OODebugGLDrawing.m; sourceTree = "<group>"; };
1AD0C32F0C463FCB0070BD23 /* autoAImap.plist */ = {isa = PBXFileReference; fileEncoding = 4; languageSpecificationIdentifier = plist; lastKnownFileType = text.xml; path = autoAImap.plist; sourceTree = "<group>"; };
1ADBA54E0BD0F173008FC99C /* OOBasicMaterial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOBasicMaterial.h; sourceTree = "<group>"; };
1ADBA54F0BD0F173008FC99C /* OOBasicMaterial.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOBasicMaterial.m; sourceTree = "<group>"; };
1ADF5F110B9E374B00FDB2A3 /* JoystickHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JoystickHandler.h; sourceTree = "<group>"; };
@ -1500,6 +1503,7 @@
1A2316DD0B9CFAD700EF0852 /* Config */ = {
isa = PBXGroup;
children = (
1AD0C32F0C463FCB0070BD23 /* autoAImap.plist */,
1A2316DE0B9CFAD700EF0852 /* characters.plist */,
1A2316DF0B9CFAD700EF0852 /* commodities.plist */,
1A2316E00B9CFAD700EF0852 /* customsounds.plist */,

View File

@ -0,0 +1,28 @@
/* autoAImap.plist
This file specifies the AIs to use for certain roles for ships with the
auto_AI property. It is possible to expand this in OXPsto handle custom
roles, but don't forget to prefix your custom roles with a unique
identifier (such as your name), like all global symbols and file names.
The effect of auto_AI is this: when a ship with auto_AI is added by role,
its role is looked up in autoAImap.plist. If a match is found, the ship's
AI is changed to the result. Normal system set-up, station launches and so
on override this, so it mainly applies to ships generated by scripts. This
is primarily useful when generating ships with basic roles like "trader"
and "pirate", since a single ship may be used in multiple roles.
*/
{
"asteroid" = "dumbAI.plist";
"escort" = "escortAI.plist";
"hunter" = "route1patrolAI.plist";
"interceptor" = "route1patrolAI.plist";
"miner" = "minerAI.plist";
"pirate" = "pirateAI.plist";
"police" = "route1patrolAI.plist";
"trader" = "route1traderAI.plist";
"scavenger" = "scavengerAI.plist";
"shuttle" = "fallingShuttleAI.plist";
"sunskim-trader" = "route2sunskimAI.plist";
}

View File

@ -4,6 +4,8 @@
<dict>
<key>adder</key>
<dict>
<key>auto_ai</key>
<true/>
<key>aft_eject_position</key>
<string>0.0 -4.5 -23.0</string>
<key>ai_type</key>
@ -246,6 +248,8 @@
</dict>
<key>anaconda</key>
<dict>
<key>auto_ai</key>
<true/>
<key>aft_eject_position</key>
<string>0.0 -20.0 -67.0</string>
<key>aft_weapon_type</key>
@ -468,6 +472,8 @@
<string>0.0 -8.0 -21.5</string>
<key>ai_type</key>
<string>pirateAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -842,6 +848,8 @@
<string>WEAPON_BEAM_LASER</string>
<key>ai_type</key>
<string>route1traderAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -915,6 +923,8 @@
<string>WEAPON_BEAM_LASER</string>
<key>ai_type</key>
<string>route1traderAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -1476,6 +1486,8 @@
<string>0.0 15.5 -33.0</string>
<key>ai_type</key>
<string>route1traderAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -1538,6 +1550,8 @@
<string>0.0 15.5 -33.0</string>
<key>ai_type</key>
<string>pirateAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>50</integer>
<key>cargo_type</key>
@ -1741,6 +1755,8 @@
<string>0.0 15.5 -33.0</string>
<key>ai_type</key>
<string>route1traderAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -1801,6 +1817,8 @@
<string>0.0 7.5 -21.0</string>
<key>ai_type</key>
<string>route1traderAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -1857,6 +1875,8 @@
<string>0.0 7.5 -21.0</string>
<key>ai_type</key>
<string>pirateAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -1921,6 +1941,8 @@
<string>0.0 7.5 -21.0</string>
<key>ai_type</key>
<string>minerAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -2424,6 +2446,8 @@
<string>0.0 3.0 -38.0</string>
<key>ai_type</key>
<string>pirateAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -2631,6 +2655,8 @@
<string>0.0 4.5 -11.0</string>
<key>ai_type</key>
<string>pirateAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -2787,6 +2813,8 @@
<string>0.0 7.5 -16.5</string>
<key>ai_type</key>
<string>pirateAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -2859,6 +2887,8 @@
<string>0.0 5.5 -17.0</string>
<key>ai_type</key>
<string>pirateAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -2924,6 +2954,8 @@
<string>0.0 5.5 -17.0</string>
<key>ai_type</key>
<string>pirateAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -3032,6 +3064,8 @@
<string>0.0 5.75 -8.0</string>
<key>ai_type</key>
<string>pirateAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -3229,6 +3263,8 @@
<string>0.0 5.75 -8.0</string>
<key>ai_type</key>
<string>route1traderAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -3424,6 +3460,8 @@
<string>0.0 15.5 -50.0</string>
<key>ai_type</key>
<string>route1traderAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -3485,6 +3523,8 @@
<string>0.0 15.5 -50.0</string>
<key>ai_type</key>
<string>pirateAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -3688,6 +3728,8 @@
<string>0.0 15.5 -50.0</string>
<key>ai_type</key>
<string>route1traderAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -3941,6 +3983,8 @@
<string>0.0 7.5 -18.0</string>
<key>ai_type</key>
<string>pirateAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
@ -4002,6 +4046,8 @@
<string>0.0 7.5 -18.0</string>
<key>ai_type</key>
<string>pirateAI.plist</string>
<key>auto_ai</key>
<true/>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>

View File

@ -133,6 +133,9 @@ void OOLogOutputHandlerClose(void)
{
if (sInited)
{
sWriteToStderr = YES;
sInited = NO;
[sLogger endLogging];
[sLogger release];
sLogger = nil;
@ -142,9 +145,6 @@ void OOLogOutputHandlerClose(void)
_NSSetLogCStringFunction(sDefaultLogCStringFunction);
sDefaultLogCStringFunction = NULL;
}
sInited = NO;
sWriteToStderr = YES;
}
}

View File

@ -2227,9 +2227,7 @@ double scoopSoundPlayTime = 0.0;
- (GLfloat) laserHeatLevel
{
GLfloat result = (GLfloat)weapon_temp / (GLfloat)PLAYER_MAX_WEAPON_TEMP;
if (result < 1.0)
return result;
return 1.0;
return OOClamp_0_1_f(result);
}

View File

@ -3947,7 +3947,7 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
- (float)laserHeatLevel
{
float result = (weapon_recharge_rate - shot_time) / weapon_recharge_rate;
return result;
return OOClamp_0_1_f(result);
}
@ -7172,12 +7172,6 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
ADD_FLAG_IF_SET(proximity_alert);
flagsString = [flags count] ? [flags componentsJoinedByString:@", "] : @"none";
OOLog(@"dumpState.shipEntity", @"Flags: %@", flagsString);
OOLog(@"dumpState.shipEntity.glsl", @"engine_level: %g", [self speedFactor]);
OOLog(@"dumpState.shipEntity.glsl", @"laser_heat_level: %g", OOClamp_0_1_f([self laserHeatLevel]));
OOLog(@"dumpState.shipEntity.glsl", @"hull_heat_level: %g", [self hullHeatLevel]);
OOLog(@"dumpState.shipEntity.glsl", @"entity_personality: %g", entity_personality / (float)0x7FFF);
OOLog(@"dumpState.shipEntity.glsl", @"entity_personality_int: %i", entity_personality);
}

View File

@ -116,7 +116,6 @@ static NSString *MacrosToString(NSDictionary *macros);
self = [super initWithName:name configuration:configuration];
if (self == nil) OK = NO;
if (OK && configuration == nil) OK = NO;
if (OK)
{
modifiedMacros = macros ? [macros mutableCopy] : [[NSMutableDictionary alloc] init];

View File

@ -286,6 +286,8 @@ static BOOL GetShaderSource(NSString *fileName, NSString *shaderType, NSString *
NSString *extension = nil;
NSString *nameWithExtension = nil;
if (fileName == nil) return YES; // It's OK for one or the other of the shaders to be undefined.
result = [ResourceManager stringFromFilesNamed:fileName inFolder:@"Shaders"];
if (result == nil)
{

View File

@ -617,7 +617,11 @@ void OOLoggingTerminate(void)
OOLogOutputHandlerClose();
sInited = NO;
/* We do not set sInited to NO. Instead, the output handler is required
to be able to handle working even after being closed. Under OS X, this
is done by writing to stderr in this case; on other platforms, NSLog()
is used and OOLogOutputHandlerClose() is a no-op.
*/
}

View File

@ -57,6 +57,7 @@ MA 02110-1301, USA.
#import "WormholeEntity.h"
#import "RingEntity.h"
#import "ParticleEntity.h"
#import "ShipEntityAI.h"
#define kOOLogUnconvertedNSLog @"unclassified.Universe"
@ -731,7 +732,7 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
/*--*/
/*- the dust particle system -*/
thing = [[DustEntity alloc] init]; // alloc retains!
thing = [[DustEntity alloc] init];
[thing setScanClass: CLASS_NO_DRAW];
[self addEntity:thing];
[thing release];
@ -758,7 +759,7 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
n_thargs = 2; // just to be sure
int i;
int thargoid_group = NO_TARGET;
Vector tharg_start_pos = [self getWitchspaceExitPosition];
ranrot_srand([[NSDate date] timeIntervalSince1970]); // reset randomiser with current time
@ -2753,6 +2754,10 @@ GLfloat docked_light_specular[] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5,
NSMutableArray *foundShips = nil;
NSMutableArray *foundChance = nil;
float foundf = 0.0, selectedf;
NSDictionary *shipDict = nil;
NSArray *shipRoles = nil;
NSString *autoAI = nil;
NSDictionary *autoAIMap = nil;
pool = [[NSAutoreleasePool alloc] init];
@ -2771,8 +2776,8 @@ GLfloat docked_light_specular[] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5,
for (shipEnum = [shipdata keyEnumerator]; (shipKey = [shipEnum nextObject]); )
{
NSDictionary* shipDict = [shipdata objectForKey:shipKey];
NSArray* shipRoles = ScanTokensFromString([shipDict objectForKey:@"roles"]);
shipDict = [shipdata objectForKey:shipKey];
shipRoles = ScanTokensFromString([shipDict objectForKey:@"roles"]);
if ([shipDict objectForKey:@"conditions"])
{
@ -2828,8 +2833,22 @@ GLfloat docked_light_specular[] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5,
if (found)
{
ship = [self newShipWithName:(NSString *)[foundShips objectAtIndex:i]]; // may return nil if not found!
[ship setRoles:search]; // set its roles to this one particular chosen role
shipKey = [foundShips objectAtIndex:i];
ship = [self newShipWithName:shipKey]; // may return nil if not found!
[ship setRoles:search]; // set its roles to this one particular chosen role
shipDict = [shipdata objectForKey:shipKey];
if ([shipDict fuzzyBooleanForKey:@"auto_ai"])
{
// Set AI based on role
autoAIMap = [ResourceManager dictionaryFromFilesNamed:@"autoAImap.plist" inFolder:@"Config" andMerge:YES];
autoAI = [autoAIMap stringForKey:search];
if (autoAI != nil)
{
[ship setAITo:autoAI];
}
}
}
else
{