Skip to content
Permalink
Browse files

Make certain we don't try to load AIs until after worldscripts - issue

  • Loading branch information...
cim-- committed Jun 12, 2014
1 parent 6f8dc2d commit 5dc7327c44422c2bd1efa413d154f97655402f6c
@@ -29,16 +29,6 @@ MA 02110-1301, USA.
this.name = "Oolite Main Station AI";

this.aiStarted = function() {
/* This AI, unlike the others, can end up being started outside of
* the game when worldscripts are not loaded. If it's in that
* position, it can just act like the nullAI. OXP AIs which might
* end up as a main station AI for Lave should also do this
* check. */
if (!worldScripts["oolite-libPriorityAI"])
{
return;
}

var ai = new worldScripts["oolite-libPriorityAI"].PriorityAIController(this.ship);

ai.setParameter("oolite_flag_listenForDistressCall",true);
@@ -967,6 +967,7 @@ typedef enum
- (NSDictionary *) equipScreenBackgroundDescriptor;
- (void) setEquipScreenBackgroundDescriptor:(NSDictionary *)descriptor;

- (BOOL) scriptsLoaded;
- (NSArray *) worldScriptNames;
- (NSDictionary *) worldScriptsByName;

@@ -10552,6 +10552,12 @@ - (void) setEquipScreenBackgroundDescriptor:(NSDictionary *)descriptor
}


- (BOOL) scriptsLoaded
{
return worldScripts != nil && [worldScripts count] > 0;
}


- (NSArray *) worldScriptNames
{
return [worldScripts allKeys];
@@ -251,6 +251,11 @@ @implementation ShipEntity (AI)

- (void) setAITo:(NSString *)aiString
{
// don't try to load real AIs if the game hasn't started yet
if (![PLAYER scriptsLoaded])
{
aiString = @"oolite-nullAI.js";
}
if ([aiString hasSuffix:@".plist"])
{
[[self getAI] setStateMachine:aiString withJSScript:@"oolite-nullAI.js"];

0 comments on commit 5dc7327

Please sign in to comment.
You can’t perform that action at this time.