Merge branch 'master' of github.com:OoliteProject/oolite into javascript-populator
Conflicts: src/Core/Entities/ShipEntityAI.m
This commit is contained in:
commit
8ca8e8a46f
@ -1 +1 @@
|
||||
Subproject commit c63e20de5341f5b59cbe55fce2e295b0344cc0e3
|
||||
Subproject commit 78e78821865f8751378e695ccd37598c0e0f31b8
|
14
Makefile
14
Makefile
@ -6,8 +6,8 @@ VER_MAJ := $(shell echo "${VERSION}" | cut -d '.' -f 1)
|
||||
VER_MIN := $(shell echo "${VERSION}" | cut -d '.' -f 2)
|
||||
VER_REV := $(shell echo "${VERSION}" | cut -d '.' -f 3)
|
||||
VER_REV := $(if ${VER_REV},${VER_REV},0)
|
||||
SVNREVISION := $(shell svn info | grep Revision | cut -d ' ' -f 2)
|
||||
VER := $(shell echo "${VER_MAJ}.${VER_MIN}.${VER_REV}.${SVNREVISION}")
|
||||
VER_DATE := $(shell date +%y%m%d)
|
||||
VER := $(shell echo "${VER_MAJ}.${VER_MIN}.${VER_REV}-${VER_DATE}")
|
||||
BUILDTIME := $(shell date "+%Y.%m.%d %H:%M")
|
||||
DEB_BUILDTIME := $(shell date "+%a, %d %b %Y %H:%M:%S %z")
|
||||
ifeq (${VER_REV},0)
|
||||
@ -17,11 +17,11 @@ DEB_VER := $(shell echo "${VER_MAJ}.${VER_MIN}.${VER_REV}")
|
||||
endif
|
||||
DEB_REV := $(shell cat debian/revision)
|
||||
# Ubuntu versions are: <upstream version>-<deb ver>ubuntu<build ver>
|
||||
# eg: oolite1.74.4.2755-0ubuntu1
|
||||
# Oolite versions are: MAJ.min.rev.svn
|
||||
# eg. 1.74.0.3275
|
||||
# Our .deb versions are: MAJ.min.rev.svn-<pkg rev>[~<type>]
|
||||
# eg. 1.74.0.3275-0, 1.74.0.3275-0~test
|
||||
# eg: oolite1.74.4-130706-0ubuntu1
|
||||
# Oolite versions are: MAJ.min.rev-date (yymmdd)
|
||||
# eg. 1.74.0-130706
|
||||
# Our .deb versions are: MAJ.min.rev-datestring-<pkg rev>[~<type>]
|
||||
# eg. 1.74.0.3275-0, 1.74.0-130706-0~test
|
||||
pkg-debtest: DEB_REV := $(shell echo "0~test${DEB_REV}")
|
||||
pkg-debsnapshot: DEB_REV := $(shell echo "0~trunk${DEB_REV}")
|
||||
|
||||
|
@ -1347,6 +1347,7 @@
|
||||
1A0729D80EF56D1200B0F925 /* OOConvertSystemDescriptions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOConvertSystemDescriptions.m; sourceTree = "<group>"; };
|
||||
1A0729FC0EF5796500B0F925 /* OldSchoolPropertyListWriting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OldSchoolPropertyListWriting.h; sourceTree = "<group>"; };
|
||||
1A0729FD0EF5796500B0F925 /* OldSchoolPropertyListWriting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OldSchoolPropertyListWriting.m; sourceTree = "<group>"; };
|
||||
1A0730E817888C44008A1829 /* oolite-warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "oolite-warnings.xcconfig"; path = "src/Cocoa/oolite-warnings.xcconfig"; sourceTree = "<group>"; };
|
||||
1A0942C712D7C011003B6273 /* OOJSFrameCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOJSFrameCallbacks.h; sourceTree = "<group>"; };
|
||||
1A0942C812D7C011003B6273 /* OOJSFrameCallbacks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOJSFrameCallbacks.m; sourceTree = "<group>"; };
|
||||
1A0C3EDD1193306B007935E5 /* oolite-dust.vertex */ = {isa = PBXFileReference; explicitFileType = sourcecode.glsl; fileEncoding = 4; path = "oolite-dust.vertex"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.glsl; };
|
||||
@ -3167,11 +3168,12 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1A9407BF0BAF7032005F6CF3 /* GNUmakefile */,
|
||||
1A846BA90D79F9570081280D /* oolite-version.xcconfig */,
|
||||
1A45BCC9104AB46900A89324 /* oolite-targets.xcconfig */,
|
||||
1AD88FAF103F29D300AA36F4 /* oolite-options.xcconfig */,
|
||||
1ABFEE2110507987005AA752 /* oolite-nonshared.xcconfig */,
|
||||
1AD88FAF103F29D300AA36F4 /* oolite-options.xcconfig */,
|
||||
1A6A3A7E1135E0F200697AF8 /* oolite-snapshot.xcconfig */,
|
||||
1A45BCC9104AB46900A89324 /* oolite-targets.xcconfig */,
|
||||
1A846BA90D79F9570081280D /* oolite-version.xcconfig */,
|
||||
1A0730E817888C44008A1829 /* oolite-warnings.xcconfig */,
|
||||
1AD5A81A12D3A9FD00B62503 /* exports-debug-32.exp */,
|
||||
1AD5A81B12D3A9FD00B62503 /* exports-debug-64.exp */,
|
||||
1A1B24C313293ED2007A0940 /* exports-release.exp */,
|
||||
@ -4131,7 +4133,6 @@
|
||||
);
|
||||
GCC_REUSE_STRINGS = YES;
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
|
||||
HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/include/libkern/";
|
||||
HEADER_SEARCH_PATHS_QUOTED_2 = "\"$(SRCROOT)/src/Core/\"";
|
||||
HEADER_SEARCH_PATHS_QUOTED_3 = "\"$(SRCROOT)/src/Core/Entites/\"";
|
||||
@ -4181,7 +4182,6 @@
|
||||
);
|
||||
GCC_REUSE_STRINGS = YES;
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
|
||||
HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/include/libkern/";
|
||||
HEADER_SEARCH_PATHS_QUOTED_2 = "\"$(SRCROOT)/src/Core/\"";
|
||||
HEADER_SEARCH_PATHS_QUOTED_3 = "\"$(SRCROOT)/src/Core/Entites/\"";
|
||||
@ -4245,7 +4245,6 @@
|
||||
);
|
||||
GCC_REUSE_STRINGS = YES;
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
|
||||
HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/include/libkern/";
|
||||
HEADER_SEARCH_PATHS_QUOTED_2 = "\"$(SRCROOT)/src/Core/\"";
|
||||
HEADER_SEARCH_PATHS_QUOTED_3 = "\"$(SRCROOT)/src/Core/Entites/\"";
|
||||
|
@ -505,6 +505,8 @@
|
||||
// equipment usage
|
||||
"equipment-primed-@" = "Equipment primed: %@.";
|
||||
"equipment-primed-none" = "Equipment primed: none.";
|
||||
"equipment-primed-none-hud-label" = "None";
|
||||
"equipment-primed-hud-@" = "Primed: %@";
|
||||
"equipment-primed-none-available" = "No equipment can be primed.";
|
||||
|
||||
// Assorted messages sent out by ships etc..
|
||||
|
@ -59,6 +59,13 @@
|
||||
x = -48;
|
||||
y = -172;
|
||||
},
|
||||
{ // primed equipment, x and y give the location, the size defines the character size, n_bars is the number of items to show (default 1)
|
||||
selector = "drawPrimedEquipment:";
|
||||
x = -48;
|
||||
y = -160;
|
||||
width = 10;
|
||||
height = 10;
|
||||
},
|
||||
{ // weapons systems offline text, x and y give the location, the size defines the character size
|
||||
height = 8;
|
||||
selector = "drawWeaponsOfflineText:";
|
||||
|
@ -184,6 +184,14 @@
|
||||
y = 6;
|
||||
y_origin = -1;
|
||||
},
|
||||
{ // primed equipment, x and y give the location, the size defines the character size, n_bars is the number of items to show (default 1)
|
||||
selector = "drawPrimedEquipment:";
|
||||
y_origin = -1;
|
||||
x = 156;
|
||||
y = -2;
|
||||
width = 10;
|
||||
height = 10;
|
||||
},
|
||||
{ // weapons systems offline text, x and y give the location, the size defines the character size
|
||||
height = 8;
|
||||
selector = "drawWeaponsOfflineText:";
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -99,7 +99,6 @@
|
||||
"performHold",
|
||||
"setTargetToPrimaryAggressor",
|
||||
"performAttack",
|
||||
"performBroadside",
|
||||
"scanForNearestMerchantman",
|
||||
"scanForRandomMerchantman",
|
||||
"scanForLoot",
|
||||
@ -337,6 +336,7 @@
|
||||
"drawMissileDisplay:",
|
||||
"drawStatusLight:",
|
||||
"drawClock:",
|
||||
"drawPrimedEquipment:",
|
||||
"drawWeaponsOfflineText:",
|
||||
"drawFPSInfoCounter:"
|
||||
);
|
||||
|
@ -533,7 +533,7 @@ static BOOL PortWait(mach_port_t inPort, PortMessage *outMessage);
|
||||
|
||||
- (NSString *)description
|
||||
{
|
||||
NSString *result, *stateString;
|
||||
NSString *result, *stateString = nil;
|
||||
|
||||
[gOOCASoundSyncLock lock];
|
||||
switch ((States)_state)
|
||||
@ -557,9 +557,10 @@ static BOOL PortWait(mach_port_t inPort, PortMessage *outMessage);
|
||||
case kState_Broken:
|
||||
stateString = [NSString stringWithFormat:@"broken (%@)", AudioErrorShortNSString(_error)];
|
||||
break;
|
||||
|
||||
default:
|
||||
stateString = [NSString stringWithFormat:@"unknown (%u)", _state];
|
||||
}
|
||||
if (stateString == nil)
|
||||
{
|
||||
stateString = [NSString stringWithFormat:@"unknown (%u)", _state];
|
||||
}
|
||||
|
||||
result = [NSString stringWithFormat:@"<%@ %p>{ID=%u, state=%@, sound=%@}", [self className], self, _id, stateString, _sound];
|
||||
|
@ -209,7 +209,7 @@ enum
|
||||
}
|
||||
|
||||
|
||||
+ (void)feederThread:ignored
|
||||
+ (void)feederThread:(id)ignored
|
||||
{
|
||||
uintptr_t msgID;
|
||||
void *param1, *param2;
|
||||
|
@ -18,7 +18,9 @@ This file is hereby placed in the public domain.
|
||||
#import <Carbon/Carbon.h>
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define CASE(foo) case foo: return @#foo
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
@ -39,11 +39,6 @@ MA 02110-1301, USA.
|
||||
#endif
|
||||
|
||||
|
||||
#define kFullScreenPresentationMode ( NSApplicationPresentationFullScreen | \
|
||||
NSApplicationPresentationAutoHideDock | \
|
||||
NSApplicationPresentationAutoHideMenuBar )
|
||||
|
||||
|
||||
@implementation OOMacSystemStandardFullScreenController
|
||||
|
||||
+ (BOOL) shouldUseSystemStandardFullScreenController
|
||||
|
@ -22,7 +22,9 @@
|
||||
#include <mach/mach_error.h>
|
||||
|
||||
|
||||
#if DEBUG
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.VirtualRingBuffer"
|
||||
#endif
|
||||
|
||||
|
||||
@implementation VirtualRingBuffer
|
||||
|
@ -1,20 +1,8 @@
|
||||
#include "oolite-warnings.xcconfig"
|
||||
|
||||
ARCHS = x86_64
|
||||
SDKROOT = macosx10.8
|
||||
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.6
|
||||
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0
|
||||
|
||||
|
||||
|
||||
// The vast majority of format warnings in 32-bit will be using %l{diux} for
|
||||
// NS[U]Integer, which is perfectly safe. It's possible suppressing this will
|
||||
// miss some real bugs, but not too likely, and casting everywhere is too ugly.
|
||||
OO_ARCH_WARNING_FLAGS =
|
||||
OO_ARCH_WARNING_FLAGS[arch=i386] = -Wno-format
|
||||
|
||||
OO_LOTS_OF_WARNINGS = -Wall -Wextra -Wshorten-64-to-32
|
||||
OO_WARNING_EXCEPTIONS = -Wno-unused-parameter -Wno-missing-field-initializers
|
||||
OO_WARNING_NO_ERROR = -Wno-error=shorten-64-to-32 -Wno-error=deprecated-declarations -Wno-error=semicolon-before-method-body
|
||||
|
||||
OO_WARNING_FLAGS = $OO_LOTS_OF_WARNINGS $OO_WARNING_EXCEPTIONS $OO_WARNING_NO_ERROR $OO_ARCH_WARNING_FLAGS
|
||||
|
43
src/Cocoa/oolite-warnings.xcconfig
Normal file
43
src/Cocoa/oolite-warnings.xcconfig
Normal file
@ -0,0 +1,43 @@
|
||||
// The vast majority of format warnings in 32-bit will be using %l{diux} for
|
||||
// NS[U]Integer, which is perfectly safe. It's possible suppressing this will
|
||||
// miss some real bugs, but not too likely, and casting everywhere is too ugly.
|
||||
OO_ARCH_WARNING_FLAGS =
|
||||
OO_ARCH_WARNING_FLAGS[arch=i386] = -Wno-format
|
||||
|
||||
|
||||
// Start off with all possible warnings, and make a stable subset errors.
|
||||
OO_LOTS_OF_WARNINGS = -Weverything -Werror=all -Werror=extra
|
||||
|
||||
// Trim off stylistic warnings from -Wall or -Wextra that we don't want.
|
||||
OO_WARNING_EXCEPTIONS = -Wno-unused-parameter -Wno-missing-field-initializers
|
||||
|
||||
// Disable stuff from -Weverything that we don't want.
|
||||
// -Wpedantic: Even I can't be bothered to conform to -Wpedantic. Yet.
|
||||
// -Wgnu: We use GNU extensions freely.
|
||||
// -Wundef: Warns about legal and normal use of the preprocessor.
|
||||
// -Wobjc-interface-ivars, Wdirect-ivar-access, -Wno-receiver-forward-class:
|
||||
// Newfangled Objective-C style stuff we can't adopt while being
|
||||
// compatible with old versions of GNUstep and GCC.
|
||||
// -Wpadded: Points out normal and exepected compiler behaviour.
|
||||
// -Wfloat-equal: Would be a good warning if it ignored comparison to 0.
|
||||
// -Wswitch-enum: Extra-pedantic version of -Wswitch which complains about
|
||||
// missed enum cases even if there's a default case.
|
||||
// -Wcast-align: rarely a real problem.
|
||||
// -Wunused-exception-parameter: Who cares?
|
||||
// -Wmissing-noreturn: Bad analysis for a micro-optimization.
|
||||
// -Wunreachable-code: Lies.
|
||||
// -Wused-but-marked-unused: This is compatible with the semantics of unused.
|
||||
// -Wformat-nonliteral: Good warning, but we currently use DESC for format
|
||||
// strings rather a lot.
|
||||
// -Wconditional-uninitialized: Too many false positives, use static analyizer
|
||||
// instead.
|
||||
// -Wbad-function-cast: Warns about explicit casts of integers to other integer
|
||||
// types. That's what explict casts are for.
|
||||
// -Wassign-enum: Correctly warns about Cocoa's abuse of enum types for bit
|
||||
// masks, which we can't do anything sensible about.
|
||||
OO_EXTRA_WARNING_EXCEPTIONS = -Wno-pedantic -Wno-gnu -Wno-undef -Wno-objc-interface-ivars -Wno-direct-ivar-access -Wno-receiver-forward-class -Wno-padded -Wno-float-equal -Wno-switch-enum -Wno-cast-align -Wno-unused-exception-parameter -Wno-missing-noreturn -Wno-unreachable-code -Wno-used-but-marked-unused -Wno-format-nonliteral -Wno-conditional-uninitialized -Wno-bad-function-cast -Wno-assign-enum
|
||||
|
||||
// Things we don't want to break the build when they're introduced by devs on other platforms.
|
||||
OO_WARNING_NO_ERROR = -Wno-error=deprecated-declarations -Wno-error=semicolon-before-method-body
|
||||
|
||||
OO_WARNING_FLAGS = $OO_LOTS_OF_WARNINGS $OO_WARNING_EXCEPTIONS $OO_EXTRA_WARNING_EXCEPTIONS $OO_WARNING_NO_ERROR $OO_ARCH_WARNING_FLAGS
|
@ -31,8 +31,6 @@ MA 02110-1301, USA.
|
||||
|
||||
#import "ShipEntity.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.AI"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -390,7 +390,7 @@ static NSString *SizeString(size_t size)
|
||||
magnitude = 1;
|
||||
suffix = @"KiB";
|
||||
}
|
||||
else if (size < (size_t)(kThreshold << 30))
|
||||
else if (size < ((size_t)kThreshold << 30))
|
||||
{
|
||||
magnitude = 2;
|
||||
suffix = @"MiB";
|
||||
|
@ -39,8 +39,6 @@ MA 02110-1301, USA.
|
||||
#import "OODebugFlags.h"
|
||||
#import "NSObjectOOExtensions.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.Entity"
|
||||
|
||||
#ifndef NDEBUG
|
||||
uint32_t gLiveEntityCount = 0;
|
||||
size_t gTotalEntityMemory = 0;
|
||||
|
@ -37,8 +37,6 @@ MA 02110-1301, USA.
|
||||
#import "OOCollectionExtractors.h"
|
||||
#import "OODebugFlags.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.SunEntity"
|
||||
|
||||
|
||||
@interface OOSunEntity (Private)
|
||||
|
||||
|
@ -44,8 +44,6 @@ MA 02110-1301, USA.
|
||||
#import "OODebugFlags.h"
|
||||
#import "OOGraphicsResetManager.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.PlanetEntity"
|
||||
|
||||
|
||||
#if !OOLITE_MAC_OS_X
|
||||
#define NSIntegerMapKeyCallBacks NSIntMapKeyCallBacks
|
||||
|
@ -743,6 +743,8 @@ typedef enum
|
||||
|
||||
- (void) setGuiToStatusScreen;
|
||||
- (NSArray *) equipmentList; // Each entry is an array with a string followed by a boolean indicating availability (NO = damaged).
|
||||
- (NSString *) primedEquipmentName:(NSInteger)offset;
|
||||
- (NSUInteger) primedEquipmentCount;
|
||||
- (NSArray *) cargoList;
|
||||
- (NSArray *) cargoListForScripting;
|
||||
- (void) setGuiToSystemDataScreen;
|
||||
|
@ -80,10 +80,6 @@ MA 02110-1301, USA.
|
||||
#import "PlayerEntityStickMapper.h"
|
||||
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.PlayerEntity"
|
||||
|
||||
// 10m/s forward drift
|
||||
#define OG_ELITE_FORWARD_DRIFT 10.0f
|
||||
#define PLAYER_DEFAULT_NAME @"Jameson"
|
||||
|
||||
enum
|
||||
@ -5044,7 +5040,7 @@ static GLfloat sBaseMass = 0.0;
|
||||
}
|
||||
// equipment damage
|
||||
NSEnumerator *eqEnum = [self equipmentEnumerator];
|
||||
OOEquipmentType *eqType;
|
||||
OOEquipmentType *eqType = nil;
|
||||
NSString *system_key;
|
||||
unsigned damageableCounter = 0;
|
||||
GLfloat damageableOdds = 0.0;
|
||||
@ -6019,6 +6015,27 @@ static GLfloat sBaseMass = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (NSUInteger) primedEquipmentCount
|
||||
{
|
||||
return [eqScripts count];
|
||||
}
|
||||
|
||||
|
||||
- (NSString *) primedEquipmentName:(NSInteger)offset
|
||||
{
|
||||
NSUInteger c = [self primedEquipmentCount];
|
||||
NSUInteger idx = (primedEquipment+offset)%(c+1);
|
||||
if (idx == c)
|
||||
{
|
||||
return DESC(@"equipment-primed-none-hud-label");
|
||||
}
|
||||
else
|
||||
{
|
||||
return [[OOEquipmentType equipmentTypeWithIdentifier:[[eqScripts oo_arrayAtIndex:idx] oo_stringAtIndex:0]] name];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (OOEquipmentType *) weaponTypeForFacing:(OOWeaponFacing)facing
|
||||
{
|
||||
OOWeaponType weaponType = WEAPON_NONE;
|
||||
|
@ -46,7 +46,9 @@
|
||||
|
||||
|
||||
// Name of modifier key used to issue commands. See also -isCommandModifierKeyDown.
|
||||
#if OO_USE_CUSTOM_LOAD_SAVE
|
||||
#define COMMAND_MODIFIER_KEY "Ctrl"
|
||||
#endif
|
||||
|
||||
|
||||
static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
|
||||
|
@ -1043,6 +1043,7 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
|
||||
- (void) landOnPlanet:(OOPlanetEntity *)planet;
|
||||
|
||||
- (void) abortDocking;
|
||||
- (NSDictionary *) dockingInstructions;
|
||||
|
||||
- (void) broadcastThargoidDestroyed;
|
||||
|
||||
|
@ -91,8 +91,6 @@ MA 02110-1301, USA.
|
||||
#import "OOJSEngineTimeManagement.h"
|
||||
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.ShipEntity"
|
||||
|
||||
#define USEMASC 1
|
||||
|
||||
|
||||
@ -158,6 +156,8 @@ static GLfloat calcFuelChargeRate (GLfloat myMass)
|
||||
|
||||
- (void) setShipHitByLaser:(ShipEntity *)ship;
|
||||
|
||||
- (void) noteFrustration:(NSString *)context;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@ -2501,9 +2501,17 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
[self applyAttitudeChanges:delta_t];
|
||||
[self applyThrust:delta_t];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// called when behaviour is unable to improve position
|
||||
- (void)noteFrustration:(NSString *)context
|
||||
{
|
||||
[shipAI reactToMessage:@"FRUSTRATED" context:context];
|
||||
[self doScriptEvent:OOJSID("shipAIFrustrated") withArgument:context];
|
||||
}
|
||||
|
||||
|
||||
- (void)respondToAttackFrom:(Entity *)from becauseOf:(Entity *)other
|
||||
{
|
||||
Entity *source = nil;
|
||||
@ -2879,7 +2887,7 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
{
|
||||
JSContext *JScontext = OOJSAcquireContext();
|
||||
BOOL OK;
|
||||
JSBool allow_addition;
|
||||
JSBool allow_addition = false;
|
||||
jsval result;
|
||||
jsval args[] = { OOJSValueFromNativeObject(JScontext, equipmentKey) , OOJSValueFromNativeObject(JScontext, self) , OOJSValueFromNativeObject(JScontext, context)};
|
||||
|
||||
@ -3722,7 +3730,7 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
frustration += delta_t * 0.9;
|
||||
if (frustration > 10.0) // 10s of frustration
|
||||
{
|
||||
[shipAI reactToMessage:@"FRUSTRATED" context:@"BEHAVIOUR_INTERCEPT_TARGET"];
|
||||
[self noteFrustration:@"BEHAVIOUR_INTERCEPT_TARGET"];
|
||||
frustration -= 5.0; //repeat after another five seconds' frustration
|
||||
}
|
||||
}
|
||||
@ -4290,7 +4298,8 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
frustration += delta_t;
|
||||
if (frustration > 3.0) // 3s of frustration
|
||||
{
|
||||
[shipAI reactToMessage:@"FRUSTRATED" context:@"BEHAVIOUR_ATTACK_BROADSIDE"];
|
||||
|
||||
[self noteFrustration:@"BEHAVIOUR_ATTACK_BROADSIDE"];
|
||||
[self setEvasiveJink:1000.0];
|
||||
behaviour = BEHAVIOUR_ATTACK_FLY_FROM_TARGET;
|
||||
frustration = 0.0;
|
||||
@ -4440,7 +4449,7 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
frustration += delta_t;
|
||||
if (frustration > 3.0) // 3s of frustration
|
||||
{
|
||||
[shipAI reactToMessage:@"FRUSTRATED" context:@"BEHAVIOUR_ATTACK_SNIPER"];
|
||||
[self noteFrustration:@"BEHAVIOUR_ATTACK_SNIPER"];
|
||||
[self setEvasiveJink:1000.0];
|
||||
behaviour = BEHAVIOUR_ATTACK_TARGET;
|
||||
frustration = 0.0;
|
||||
@ -4731,7 +4740,7 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
frustration += delta_t;
|
||||
if (frustration > 3.0) // 3s of frustration
|
||||
{
|
||||
[shipAI reactToMessage:@"FRUSTRATED" context:@"BEHAVIOUR_ATTACK_FLY_TO_TARGET"];
|
||||
[self noteFrustration:@"BEHAVIOUR_ATTACK_FLY_TO_TARGET"];
|
||||
[self setEvasiveJink:1000.0];
|
||||
behaviour = BEHAVIOUR_ATTACK_TARGET;
|
||||
frustration = 0.0;
|
||||
@ -4933,7 +4942,7 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
frustration += delta_t;
|
||||
if (frustration > 15.0) // 15s of frustration
|
||||
{
|
||||
[shipAI reactToMessage:@"FRUSTRATED" context:@"BEHAVIOUR_FLEE_TARGET"];
|
||||
[self noteFrustration:@"BEHAVIOUR_FLEE_TARGET"];
|
||||
frustration = 0.0;
|
||||
}
|
||||
}
|
||||
@ -5012,6 +5021,7 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
{
|
||||
// desired facing achieved and movement stabilised.
|
||||
[shipAI message:@"FACING_DESTINATION"];
|
||||
[self doScriptEvent:OOJSID("shipNowFacingDestination")];
|
||||
frustration = 0.0;
|
||||
if(docking_match_rotation) // IDLE stops rotating while docking
|
||||
{
|
||||
@ -5027,7 +5037,7 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
if (frustration > 15.0 / max_flight_pitch) // allow more time for slow ships.
|
||||
{
|
||||
frustration = 0.0;
|
||||
[shipAI reactToMessage:@"FRUSTRATED" context:@"BEHAVIOUR_FACE_DESTINATION"];
|
||||
[self noteFrustration:@"BEHAVIOUR_FACE_DESTINATION"];
|
||||
if(flightPitch == old_pitch) flightPitch = 0.5 * max_flight_pitch; // hack to get out of frustration.
|
||||
}
|
||||
|
||||
@ -5129,7 +5139,7 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
frustration += delta_t;
|
||||
if (frustration > 15.0)
|
||||
{
|
||||
if (!leadShip) [shipAI reactToMessage:@"FRUSTRATED" context:@"BEHAVIOUR_FORMATION_FORM_UP"]; // escorts never reach their destination when following leader.
|
||||
if (!leadShip) [self noteFrustration:@"BEHAVIOUR_FORMATION_FORM_UP"]; // escorts never reach their destination when following leader.
|
||||
else if (distance > 0.5 * scannerRange && !pitching_over)
|
||||
{
|
||||
pitching_over = YES; // Force the ship in a 180 degree turn. Do it here to allow escorts to break out formation for some seconds.
|
||||
@ -5201,7 +5211,7 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
frustration += delta_t;
|
||||
if ((frustration > slowdownTime * 10.0 && slowdownTime > 0)||(frustration > 15.0)) // 10x slowdownTime or 15s of frustration
|
||||
{
|
||||
[shipAI reactToMessage:@"FRUSTRATED" context:@"BEHAVIOUR_FLY_TO_DESTINATION"];
|
||||
[self noteFrustration:@"BEHAVIOUR_FLY_TO_DESTINATION"];
|
||||
frustration -= slowdownTime * 5.0; //repeat after another five units of frustration
|
||||
}
|
||||
}
|
||||
@ -5397,7 +5407,7 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
frustration += delta_t;
|
||||
if (frustration > 15.0) // 15s of frustration
|
||||
{
|
||||
[shipAI reactToMessage:@"FRUSTRATED" context:@"BEHAVIOUR_FLY_THRU_NAVPOINTS"];
|
||||
[self noteFrustration:@"BEHAVIOUR_FLY_THRU_NAVPOINTS"];
|
||||
frustration -= 15.0; //repeat after another 15s of frustration
|
||||
}
|
||||
}
|
||||
@ -9677,14 +9687,14 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
|
||||
_defenseTargets = [[OOWeakSet alloc] init];
|
||||
}
|
||||
|
||||
[_defenseTargets addObject:[target weakSelf]];
|
||||
[_defenseTargets addObject:target];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) isDefenseTarget:(Entity *)target
|
||||
{
|
||||
return [_defenseTargets containsObject:[target weakSelf]];
|
||||
return [_defenseTargets containsObject:target];
|
||||
}
|
||||
|
||||
|
||||
@ -9697,7 +9707,7 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
|
||||
|
||||
- (void) removeDefenseTarget:(Entity *)target
|
||||
{
|
||||
[_defenseTargets removeObject:[target weakSelf]];
|
||||
[_defenseTargets removeObject:target];
|
||||
}
|
||||
|
||||
|
||||
@ -12342,6 +12352,13 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
|
||||
}
|
||||
|
||||
|
||||
- (NSDictionary *) dockingInstructions
|
||||
{
|
||||
OOLog(@"docking.debug",@"%@",dockingInstructions);
|
||||
return dockingInstructions;
|
||||
}
|
||||
|
||||
|
||||
- (void) broadcastThargoidDestroyed
|
||||
{
|
||||
[[UNIVERSE findShipsMatchingPredicate:HasRolePredicate
|
||||
|
@ -37,8 +37,6 @@ MA 02110-1301, USA.
|
||||
- (void) switchAITo:(NSString *)aiString;
|
||||
|
||||
- (void) scanForHostiles;
|
||||
- (void) performTumble;
|
||||
- (void) performStop;
|
||||
- (BOOL) performHyperSpaceToSpecificSystem:(OOSystemID)systemID;
|
||||
- (void) scanForNearestIncomingMissile;
|
||||
|
||||
@ -49,4 +47,28 @@ MA 02110-1301, USA.
|
||||
|
||||
- (BOOL) suggestEscortTo:(ShipEntity *)mother;
|
||||
|
||||
- (void) groupAttackTarget;
|
||||
|
||||
- (void) performAttack;
|
||||
- (void) performCollect;
|
||||
- (void) performEscort;
|
||||
- (void) performFaceDestination;
|
||||
- (void) performFlee;
|
||||
- (void) performFlyToRangeFromDestination;
|
||||
- (void) performHold;
|
||||
- (void) performIdle;
|
||||
- (void) performIntercept;
|
||||
- (void) performLandOnPlanet;
|
||||
- (void) performMining;
|
||||
- (void) performScriptedAI;
|
||||
- (void) performScriptedAttackAI;
|
||||
- (void) performStop;
|
||||
- (void) performTumble;
|
||||
|
||||
- (void) broadcastDistressMessage;
|
||||
|
||||
- (void) requestDockingCoordinates;
|
||||
- (void) recallDockingInstructions;
|
||||
|
||||
|
||||
@end
|
||||
|
@ -44,8 +44,6 @@
|
||||
#import "OOConstToJSString.h"
|
||||
#import "OOCollectionExtractors.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.ShipEntityAI"
|
||||
|
||||
|
||||
@interface ShipEntity (OOAIPrivate)
|
||||
|
||||
@ -97,16 +95,9 @@
|
||||
|
||||
- (void) setThrustFactorTo:(NSString *)thrustFactorString;
|
||||
|
||||
- (void) performFlyToRangeFromDestination;
|
||||
|
||||
- (void) performIdle;
|
||||
|
||||
- (void) performHold;
|
||||
|
||||
- (void) setTargetToPrimaryAggressor;
|
||||
|
||||
- (void) performAttack;
|
||||
|
||||
- (void) scanForNearestMerchantman;
|
||||
- (void) scanForRandomMerchantman;
|
||||
|
||||
@ -118,28 +109,14 @@
|
||||
|
||||
- (void) checkForFullHold;
|
||||
|
||||
- (void) performCollect;
|
||||
|
||||
- (void) performIntercept;
|
||||
|
||||
- (void) performFlee;
|
||||
|
||||
- (void) performScriptedAI;
|
||||
- (void) performScriptedAttackAI;
|
||||
|
||||
- (void) requestDockingCoordinates;
|
||||
|
||||
- (void) getWitchspaceEntryCoordinates;
|
||||
|
||||
- (void) setDestinationFromCoordinates;
|
||||
- (void) setCoordinatesFromPosition;
|
||||
|
||||
- (void) performFaceDestination;
|
||||
|
||||
- (void) fightOrFleeMissile;
|
||||
|
||||
- (void) setCourseToPlanet;
|
||||
- (void) performLandOnPlanet;
|
||||
- (void) setTakeOffFromPlanet;
|
||||
- (void) landOnPlanet;
|
||||
|
||||
@ -172,7 +149,6 @@
|
||||
|
||||
- (void) commsMessage:(NSString *)valueString;
|
||||
- (void) commsMessageByUnpiloted:(NSString *)valueString;
|
||||
- (void) broadcastDistressMessage;
|
||||
|
||||
- (void) ejectCargo;
|
||||
|
||||
@ -189,12 +165,8 @@
|
||||
|
||||
- (void) escortCheckMother;
|
||||
|
||||
- (void) performEscort;
|
||||
|
||||
- (void) checkGroupOddsVersusTarget;
|
||||
|
||||
- (void) groupAttackTarget;
|
||||
|
||||
- (void) scanForFormationLeader;
|
||||
|
||||
- (void) messageMother:(NSString *)msgString;
|
||||
@ -222,8 +194,6 @@
|
||||
|
||||
- (void) scanForRocks;
|
||||
|
||||
- (void) performMining;
|
||||
|
||||
- (void) setDestinationToDockingAbort;
|
||||
|
||||
- (void) requestNewTarget;
|
||||
@ -248,7 +218,6 @@
|
||||
|
||||
- (void) setTargetToRandomStation;
|
||||
- (void) setTargetToLastStation;
|
||||
- (void) recallDockingInstructions;
|
||||
|
||||
- (void) addFuel:(NSString *) fuel_number;
|
||||
|
||||
@ -317,11 +286,163 @@
|
||||
}
|
||||
|
||||
|
||||
- (void) performTumble
|
||||
- (void) groupAttackTarget
|
||||
{
|
||||
stick_roll = max_flight_roll*2.0*(randf() - 0.5);
|
||||
stick_pitch = max_flight_pitch*2.0*(randf() - 0.5);
|
||||
behaviour = BEHAVIOUR_TUMBLE;
|
||||
NSEnumerator *shipEnum = nil;
|
||||
ShipEntity *target = nil, *ship = nil;
|
||||
|
||||
target = [self primaryTarget];
|
||||
|
||||
if (target == nil) return;
|
||||
|
||||
if ([self group] == nil) // ship is alone!
|
||||
{
|
||||
[self setFoundTarget:target];
|
||||
[shipAI reactToMessage:@"GROUP_ATTACK_TARGET" context:@"groupAttackTarget"];
|
||||
[self doScriptEvent:OOJSID("helpRequestReceived") withArgument:self andArgument:target];
|
||||
return;
|
||||
}
|
||||
|
||||
// -memberArray creates a new collection, which is needed because the group might be mutated by the members' AIs.
|
||||
NSArray *groupMembers = [[self group] memberArray];
|
||||
for (shipEnum = [groupMembers objectEnumerator]; (ship = [shipEnum nextObject]); )
|
||||
{
|
||||
[ship setFoundTarget:target];
|
||||
[ship reactToAIMessage:@"GROUP_ATTACK_TARGET" context:@"groupAttackTarget"];
|
||||
[ship doScriptEvent:OOJSID("helpRequestReceived") withArgument:self andArgument:target];
|
||||
|
||||
if ([ship escortGroup] != [ship group] && [[ship escortGroup] count] > 1) // Ship has a seperate escort group.
|
||||
{
|
||||
ShipEntity *escort = nil;
|
||||
NSEnumerator *shipEnum = nil;
|
||||
NSArray *escortMembers = [[ship escortGroup] memberArrayExcludingLeader];
|
||||
for (shipEnum = [escortMembers objectEnumerator]; (escort = [shipEnum nextObject]); )
|
||||
{
|
||||
[escort setFoundTarget:target];
|
||||
[escort reactToAIMessage:@"GROUP_ATTACK_TARGET" context:@"groupAttackTarget"];
|
||||
[escort doScriptEvent:OOJSID("helpRequestReceived") withArgument:self andArgument:target];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) performAttack
|
||||
{
|
||||
behaviour = BEHAVIOUR_ATTACK_TARGET;
|
||||
desired_range = 1250 * randf() + 750; // 750 til 2000
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) performCollect
|
||||
{
|
||||
behaviour = BEHAVIOUR_COLLECT_TARGET;
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) performEscort
|
||||
{
|
||||
if(behaviour != BEHAVIOUR_FORMATION_FORM_UP)
|
||||
{
|
||||
behaviour = BEHAVIOUR_FORMATION_FORM_UP;
|
||||
frustration = 0.0; // behavior changed, reset frustration.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) performFaceDestination
|
||||
{
|
||||
behaviour = BEHAVIOUR_FACE_DESTINATION;
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) performFlee
|
||||
{
|
||||
behaviour = BEHAVIOUR_FLEE_TARGET;
|
||||
|
||||
[self setEvasiveJink:400.0];
|
||||
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) performFlyToRangeFromDestination
|
||||
{
|
||||
behaviour = BEHAVIOUR_FLY_RANGE_FROM_DESTINATION;
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) performHold
|
||||
{
|
||||
desired_speed = 0.0;
|
||||
behaviour = BEHAVIOUR_TRACK_TARGET;
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) performIdle
|
||||
{
|
||||
behaviour = BEHAVIOUR_IDLE;
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) performIntercept
|
||||
{
|
||||
behaviour = BEHAVIOUR_INTERCEPT_TARGET;
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) performLandOnPlanet
|
||||
{
|
||||
OOPlanetEntity *nearest = [self findNearestPlanet];
|
||||
if (isNearPlanetSurface)
|
||||
{
|
||||
destination = [nearest position];
|
||||
behaviour = BEHAVIOUR_LAND_ON_PLANET;
|
||||
planetForLanding = [nearest universalID];
|
||||
}
|
||||
else
|
||||
{
|
||||
behaviour = BEHAVIOUR_IDLE;
|
||||
[shipAI message:@"NO_PLANET_NEARBY"];
|
||||
}
|
||||
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) performMining
|
||||
{
|
||||
Entity *target = [self primaryTarget];
|
||||
// mining is not seen as hostile behaviour, so ensure it is only used against rocks.
|
||||
if (target && [target scanClass] == CLASS_ROCK)
|
||||
{
|
||||
behaviour = BEHAVIOUR_ATTACK_MINING_TARGET;
|
||||
frustration = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
[self noteLostTargetAndGoIdle];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) performScriptedAI
|
||||
{
|
||||
behaviour = BEHAVIOUR_SCRIPTED_AI;
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) performScriptedAttackAI
|
||||
{
|
||||
behaviour = BEHAVIOUR_SCRIPTED_ATTACK_AI;
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
@ -343,12 +464,104 @@
|
||||
}
|
||||
|
||||
|
||||
- (void) performTumble
|
||||
{
|
||||
stick_roll = max_flight_roll*2.0*(randf() - 0.5);
|
||||
stick_pitch = max_flight_pitch*2.0*(randf() - 0.5);
|
||||
behaviour = BEHAVIOUR_TUMBLE;
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) performHyperSpaceToSpecificSystem:(OOSystemID)systemID
|
||||
{
|
||||
return [self performHyperSpaceExitReplace:NO toSystem:systemID];
|
||||
}
|
||||
|
||||
|
||||
- (void) requestDockingCoordinates
|
||||
{
|
||||
/*- requests coordinates from the target station
|
||||
if the target station can't be found
|
||||
then use the nearest it can find (which may be a rock hermit) -*/
|
||||
|
||||
StationEntity *station = nil;
|
||||
Entity *targStation = nil;
|
||||
NSString *message = nil;
|
||||
double distanceToStation2 = 0.0;
|
||||
|
||||
targStation = [self targetStation];
|
||||
if ([targStation isStation])
|
||||
{
|
||||
station = (StationEntity*)targStation;
|
||||
}
|
||||
else
|
||||
{
|
||||
station = [UNIVERSE nearestShipMatchingPredicate:IsStationPredicate
|
||||
parameter:nil
|
||||
relativeToEntity:self];
|
||||
}
|
||||
|
||||
distanceToStation2 = HPdistance2([station position], [self position]);
|
||||
|
||||
// Player check for being inside the aegis already exists in PlayerEntityControls. We just
|
||||
// check here that distance to station is less than 2.5 times scanner range to avoid problems with
|
||||
// NPC ships getting stuck with a dockingAI while just outside the aegis - Nikos 20090630, as proposed by Eric
|
||||
// On very busy systems (> 50 docking ships) docking ships can be sent to a hold position outside the range,
|
||||
// so also test for presence of dockingInstructions. - Eric 20091130
|
||||
if (station != nil && (distanceToStation2 < SCANNER_MAX_RANGE2 * 6.25 || dockingInstructions != nil))
|
||||
{
|
||||
// remember the instructions
|
||||
[dockingInstructions release];
|
||||
dockingInstructions = [[station dockingInstructionsForShip:self] retain];
|
||||
if (dockingInstructions != nil)
|
||||
{
|
||||
[self recallDockingInstructions];
|
||||
|
||||
message = [dockingInstructions objectForKey:@"ai_message"];
|
||||
if (message != nil) [shipAI message:message];
|
||||
message = [dockingInstructions objectForKey:@"comms_message"];
|
||||
if (message != nil) [station sendExpandedMessage:message toShip:self];
|
||||
}
|
||||
OOLog(@"docking.debug",@"%@",dockingInstructions);
|
||||
}
|
||||
else
|
||||
{
|
||||
DESTROY(dockingInstructions);
|
||||
}
|
||||
|
||||
if (dockingInstructions == nil)
|
||||
{
|
||||
[shipAI message:@"NO_STATION_FOUND"];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) recallDockingInstructions
|
||||
{
|
||||
if (dockingInstructions != nil)
|
||||
{
|
||||
destination = [dockingInstructions oo_vectorForKey:@"destination"];
|
||||
desired_speed = fmin([dockingInstructions oo_floatForKey:@"speed"], maxFlightSpeed);
|
||||
desired_range = [dockingInstructions oo_floatForKey:@"range"];
|
||||
if ([dockingInstructions objectForKey:@"station"])
|
||||
{
|
||||
StationEntity *targetStation = [[dockingInstructions objectForKey:@"station"] weakRefUnderlyingObject];
|
||||
if (targetStation != nil)
|
||||
{
|
||||
[self addTarget:targetStation];
|
||||
[self setTargetStation:targetStation];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self removeTarget:[self primaryTarget]];
|
||||
}
|
||||
}
|
||||
docking_match_rotation = [dockingInstructions oo_boolForKey:@"match_rotation"];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) scanForNearestIncomingMissile
|
||||
{
|
||||
BinaryOperationPredicateParameter param =
|
||||
@ -480,6 +693,70 @@
|
||||
}
|
||||
|
||||
|
||||
- (void) broadcastDistressMessage
|
||||
{
|
||||
/*-- Locates all the stations, bounty hunters and police ships in range and tells them that you are under attack --*/
|
||||
|
||||
[self checkScanner];
|
||||
DESTROY(_foundTarget);
|
||||
|
||||
ShipEntity *aggressor_ship = (ShipEntity*)[self primaryAggressor];
|
||||
if (aggressor_ship == nil) return;
|
||||
|
||||
// don't send too many distress messages at once, space them out semi-randomly
|
||||
if (messageTime > 2.0 * randf()) return;
|
||||
|
||||
NSString *distress_message = nil;
|
||||
BOOL is_buoy = (scanClass == CLASS_BUOY);
|
||||
if (is_buoy) distress_message = @"[buoy-distress-call]";
|
||||
else distress_message = @"[distress-call]";
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < n_scanned_ships; i++)
|
||||
{
|
||||
ShipEntity* ship = scanned_ships[i];
|
||||
|
||||
// dump cargo if energy is low
|
||||
if (!is_buoy && [self primaryAggressor] == ship && energy < 0.375 * maxEnergy)
|
||||
{
|
||||
[self ejectCargo];
|
||||
[self performFlee];
|
||||
}
|
||||
|
||||
// tell it!
|
||||
if (ship->isPlayer)
|
||||
{
|
||||
if (!is_buoy && [self primaryAggressor] == ship && energy < 0.375 * maxEnergy)
|
||||
{
|
||||
[self sendExpandedMessage:@"[beg-for-mercy]" toShip:ship];
|
||||
}
|
||||
else if ([self bounty] == 0)
|
||||
{
|
||||
// only send distress message to player if plausibly sending
|
||||
// one more generally
|
||||
[self sendExpandedMessage:distress_message toShip:ship];
|
||||
}
|
||||
|
||||
// reset the thanked_ship_id
|
||||
DESTROY(_thankedShip);
|
||||
}
|
||||
else if ([self bounty] == 0 && [ship crew]) // Only clean ships can have their distress calls accepted
|
||||
{
|
||||
[ship doScriptEvent:OOJSID("distressMessageReceived") withArgument:aggressor_ship andArgument:self];
|
||||
|
||||
// we only can send distressMessages to ships that are known to have a "ACCEPT_DISTRESS_CALL" reaction
|
||||
// in their AI, or they might react wrong on the added found_target.
|
||||
|
||||
// FIXME: this test only works with core AIs
|
||||
if (ship->isStation || [ship hasPrimaryRole:@"police"] || [ship hasPrimaryRole:@"hunter"])
|
||||
{
|
||||
[ship acceptDistressMessageFrom:self];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@ -561,13 +838,6 @@
|
||||
desired_range = fmax(maxFlightSpeed / max_flight_pitch / 6, 50.0); // some ships need a longer range to reach a waypoint.
|
||||
}
|
||||
|
||||
- (void) performFlyToRangeFromDestination
|
||||
{
|
||||
behaviour = BEHAVIOUR_FLY_RANGE_FROM_DESTINATION;
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) setSpeedTo:(NSString *)speedString
|
||||
{
|
||||
desired_speed = [speedString doubleValue];
|
||||
@ -590,21 +860,6 @@
|
||||
}
|
||||
|
||||
|
||||
- (void) performIdle
|
||||
{
|
||||
behaviour = BEHAVIOUR_IDLE;
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) performHold
|
||||
{
|
||||
desired_speed = 0.0;
|
||||
behaviour = BEHAVIOUR_TRACK_TARGET;
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) setTargetToPrimaryAggressor
|
||||
{
|
||||
Entity *primeAggressor = [self primaryAggressor];
|
||||
@ -655,22 +910,6 @@
|
||||
}
|
||||
|
||||
|
||||
- (void) performAttack
|
||||
{
|
||||
behaviour = BEHAVIOUR_ATTACK_TARGET;
|
||||
desired_range = 1250 * randf() + 750; // 750 til 2000
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) performBroadside
|
||||
{
|
||||
behaviour = BEHAVIOUR_ATTACK_BROADSIDE;
|
||||
desired_range = 1250 * randf() + 750; // 750 til 2000
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) scanForNearestMerchantman
|
||||
{
|
||||
float d2, found_d2;
|
||||
@ -861,43 +1100,8 @@
|
||||
}
|
||||
|
||||
|
||||
- (void) performCollect
|
||||
{
|
||||
behaviour = BEHAVIOUR_COLLECT_TARGET;
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) performIntercept
|
||||
{
|
||||
behaviour = BEHAVIOUR_INTERCEPT_TARGET;
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) performFlee
|
||||
{
|
||||
behaviour = BEHAVIOUR_FLEE_TARGET;
|
||||
|
||||
[self setEvasiveJink:400.0];
|
||||
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) performScriptedAI
|
||||
{
|
||||
behaviour = BEHAVIOUR_SCRIPTED_AI;
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) performScriptedAttackAI
|
||||
{
|
||||
behaviour = BEHAVIOUR_SCRIPTED_ATTACK_AI;
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) getWitchspaceEntryCoordinates
|
||||
{
|
||||
@ -943,13 +1147,6 @@
|
||||
}
|
||||
|
||||
|
||||
- (void) performFaceDestination
|
||||
{
|
||||
behaviour = BEHAVIOUR_FACE_DESTINATION;
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) fightOrFleeMissile
|
||||
{
|
||||
// find an incoming missile...
|
||||
@ -1072,25 +1269,6 @@
|
||||
}
|
||||
|
||||
|
||||
- (void) performLandOnPlanet
|
||||
{
|
||||
OOPlanetEntity *nearest = [self findNearestPlanet];
|
||||
if (isNearPlanetSurface)
|
||||
{
|
||||
destination = [nearest position];
|
||||
behaviour = BEHAVIOUR_LAND_ON_PLANET;
|
||||
planetForLanding = [nearest universalID];
|
||||
}
|
||||
else
|
||||
{
|
||||
behaviour = BEHAVIOUR_IDLE;
|
||||
[shipAI message:@"NO_PLANET_NEARBY"];
|
||||
}
|
||||
|
||||
frustration = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (void) landOnPlanet
|
||||
{
|
||||
// Selects the nearest planet it can find.
|
||||
@ -1206,13 +1384,13 @@
|
||||
|
||||
- (void) checkAegis
|
||||
{
|
||||
switch(aegis_status)
|
||||
switch (aegis_status)
|
||||
{
|
||||
case AEGIS_CLOSE_TO_MAIN_PLANET:
|
||||
[shipAI message:@"AEGIS_CLOSE_TO_MAIN_PLANET"];
|
||||
// It's been a few years since 1.71 - it should be safe enough to comment out the line below for 1.77/1.78 -- Kaks 20120917
|
||||
//[shipAI message:@"AEGIS_CLOSE_TO_PLANET"]; // fires only for main planets, kept for compatibility with pre-1.72 AI plists.
|
||||
break;
|
||||
return;
|
||||
case AEGIS_CLOSE_TO_ANY_PLANET:
|
||||
{
|
||||
Entity<OOStellarBody> *nearest = [self findNearestStellarBody];
|
||||
@ -1233,16 +1411,19 @@
|
||||
[shipAI message:@"CLOSE_TO_SECONDARY_PLANET"];
|
||||
}
|
||||
}
|
||||
break;
|
||||
return;
|
||||
}
|
||||
case AEGIS_IN_DOCKING_RANGE:
|
||||
[shipAI message:@"AEGIS_IN_DOCKING_RANGE"];
|
||||
break;
|
||||
return;
|
||||
case AEGIS_NONE:
|
||||
default:
|
||||
[shipAI message:@"AEGIS_NONE"];
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
NSLog(@"Aegis status for %@ has taken on invalid value %i. This is an internal error, please report it.", self, aegis_status);
|
||||
aegis_status = AEGIS_NONE;
|
||||
[shipAI message:@"AEGIS_NONE"];
|
||||
}
|
||||
|
||||
|
||||
@ -1419,70 +1600,6 @@
|
||||
}
|
||||
|
||||
|
||||
- (void) broadcastDistressMessage
|
||||
{
|
||||
/*-- Locates all the stations, bounty hunters and police ships in range and tells them that you are under attack --*/
|
||||
|
||||
[self checkScanner];
|
||||
DESTROY(_foundTarget);
|
||||
|
||||
ShipEntity *aggressor_ship = (ShipEntity*)[self primaryAggressor];
|
||||
if (aggressor_ship == nil) return;
|
||||
|
||||
// don't send too many distress messages at once, space them out semi-randomly
|
||||
if (messageTime > 2.0 * randf()) return;
|
||||
|
||||
NSString *distress_message = nil;
|
||||
BOOL is_buoy = (scanClass == CLASS_BUOY);
|
||||
if (is_buoy) distress_message = @"[buoy-distress-call]";
|
||||
else distress_message = @"[distress-call]";
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < n_scanned_ships; i++)
|
||||
{
|
||||
ShipEntity* ship = scanned_ships[i];
|
||||
|
||||
// dump cargo if energy is low
|
||||
if (!is_buoy && [self primaryAggressor] == ship && energy < 0.375 * maxEnergy)
|
||||
{
|
||||
[self ejectCargo];
|
||||
[self performFlee];
|
||||
}
|
||||
|
||||
// tell it!
|
||||
if (ship->isPlayer)
|
||||
{
|
||||
if (!is_buoy && [self primaryAggressor] == ship && energy < 0.375 * maxEnergy)
|
||||
{
|
||||
[self sendExpandedMessage:@"[beg-for-mercy]" toShip:ship];
|
||||
}
|
||||
else if ([self bounty] == 0)
|
||||
{
|
||||
// only send distress message to player if plausibly sending
|
||||
// one more generally
|
||||
[self sendExpandedMessage:distress_message toShip:ship];
|
||||
}
|
||||
|
||||
// reset the thanked_ship_id
|
||||
DESTROY(_thankedShip);
|
||||
}
|
||||
else if ([self bounty] == 0 && [ship crew]) // Only clean ships can have their distress calls accepted
|
||||
{
|
||||
[ship doScriptEvent:OOJSID("distressMessageReceived") withArgument:aggressor_ship andArgument:self];
|
||||
|
||||
// we only can send distressMessages to ships that are known to have a "ACCEPT_DISTRESS_CALL" reaction
|
||||
// in their AI, or they might react wrong on the added found_target.
|
||||
|
||||
// FIXME: this test only works with core AIs
|
||||
if (ship->isStation || [ship hasPrimaryRole:@"police"] || [ship hasPrimaryRole:@"hunter"])
|
||||
{
|
||||
[ship acceptDistressMessageFrom:self];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) ejectCargo
|
||||
{
|
||||
unsigned i;
|
||||
@ -1680,16 +1797,6 @@
|
||||
}
|
||||
|
||||
|
||||
- (void) performEscort
|
||||
{
|
||||
if(behaviour != BEHAVIOUR_FORMATION_FORM_UP)
|
||||
{
|
||||
behaviour = BEHAVIOUR_FORMATION_FORM_UP;
|
||||
frustration = 0.0; // behavior changed, reset frustration.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) checkGroupOddsVersusTarget
|
||||
{
|
||||
NSUInteger ownGroupCount = [[self group] count] + (ranrot_rand() & 3); // add a random fudge factor
|
||||
@ -1710,41 +1817,6 @@
|
||||
}
|
||||
|
||||
|
||||
- (void) groupAttackTarget
|
||||
{
|
||||
NSEnumerator *shipEnum = nil;
|
||||
ShipEntity *target = nil, *ship = nil;
|
||||
|
||||
if ([self primaryTarget] == nil) return;
|
||||
|
||||
if ([self group] == nil) // ship is alone!
|
||||
{
|
||||
[self setFoundTarget:[self primaryTarget]];
|
||||
[shipAI reactToMessage:@"GROUP_ATTACK_TARGET" context:@"groupAttackTarget"];
|
||||
return;
|
||||
}
|
||||
|
||||
target = [self primaryTarget];
|
||||
|
||||
// -memberArray creates a new collection, which is needed because the group might be mutated by the members' AIs.
|
||||
NSArray *groupMembers = [[self group] memberArray];
|
||||
for (shipEnum = [groupMembers objectEnumerator]; (ship = [shipEnum nextObject]); )
|
||||
{
|
||||
[ship setFoundTarget:target];
|
||||
[ship reactToAIMessage:@"GROUP_ATTACK_TARGET" context:@"groupAttackTarget"];
|
||||
if ([ship escortGroup] != [ship group] && [[ship escortGroup] count] > 1) // Ship has a seperate escort group.
|
||||
{
|
||||
ShipEntity *escort = nil;
|
||||
NSEnumerator *shipEnum = nil;
|
||||
NSArray *escortMembers = [[ship escortGroup] memberArrayExcludingLeader];
|
||||
for (shipEnum = [escortMembers objectEnumerator]; (escort = [shipEnum nextObject]); )
|
||||
{
|
||||
[escort setFoundTarget:target];
|
||||
[escort reactToAIMessage:@"GROUP_ATTACK_TARGET" context:@"groupAttackTarget"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) scanForFormationLeader
|
||||
@ -2077,22 +2149,6 @@
|
||||
}
|
||||
|
||||
|
||||
- (void) performMining
|
||||
{
|
||||
Entity *target = [self primaryTarget];
|
||||
// mining is not seen as hostile behaviour, so ensure it is only used against rocks.
|
||||
if (target && [target scanClass] == CLASS_ROCK)
|
||||
{
|
||||
behaviour = BEHAVIOUR_ATTACK_MINING_TARGET;
|
||||
frustration = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
[self noteLostTargetAndGoIdle];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) setDestinationToDockingAbort
|
||||
{
|
||||
Entity *the_target = [self targetStation];
|
||||
@ -2436,88 +2492,6 @@
|
||||
|
||||
}
|
||||
|
||||
- (void) requestDockingCoordinates
|
||||
{
|
||||
/*- requests coordinates from the target station
|
||||
if the target station can't be found
|
||||
then use the nearest it can find (which may be a rock hermit) -*/
|
||||
|
||||
StationEntity *station = nil;
|
||||
Entity *targStation = nil;
|
||||
NSString *message = nil;
|
||||
double distanceToStation2 = 0.0;
|
||||
|
||||
targStation = [self targetStation];
|
||||
if ([targStation isStation])
|
||||
{
|
||||
station = (StationEntity*)targStation;
|
||||
}
|
||||
else
|
||||
{
|
||||
station = [UNIVERSE nearestShipMatchingPredicate:IsStationPredicate
|
||||
parameter:nil
|
||||
relativeToEntity:self];
|
||||
}
|
||||
|
||||
distanceToStation2 = HPdistance2([station position], [self position]);
|
||||
|
||||
// Player check for being inside the aegis already exists in PlayerEntityControls. We just
|
||||
// check here that distance to station is less than 2.5 times scanner range to avoid problems with
|
||||
// NPC ships getting stuck with a dockingAI while just outside the aegis - Nikos 20090630, as proposed by Eric
|
||||
// On very busy systems (> 50 docking ships) docking ships can be sent to a hold position outside the range,
|
||||
// so also test for presence of dockingInstructions. - Eric 20091130
|
||||
if (station != nil && (distanceToStation2 < SCANNER_MAX_RANGE2 * 6.25 || dockingInstructions != nil))
|
||||
{
|
||||
// remember the instructions
|
||||
[dockingInstructions release];
|
||||
dockingInstructions = [[station dockingInstructionsForShip:self] retain];
|
||||
if (dockingInstructions != nil)
|
||||
{
|
||||
[self recallDockingInstructions];
|
||||
|
||||
message = [dockingInstructions objectForKey:@"ai_message"];
|
||||
if (message != nil) [shipAI message:message];
|
||||
message = [dockingInstructions objectForKey:@"comms_message"];
|
||||
if (message != nil) [station sendExpandedMessage:message toShip:self];
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
DESTROY(dockingInstructions);
|
||||
}
|
||||
|
||||
if (dockingInstructions == nil)
|
||||
{
|
||||
[shipAI message:@"NO_STATION_FOUND"];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) recallDockingInstructions
|
||||
{
|
||||
if (dockingInstructions != nil)
|
||||
{
|
||||
destination = [dockingInstructions oo_hpvectorForKey:@"destination"];
|
||||
desired_speed = fmin([dockingInstructions oo_floatForKey:@"speed"], maxFlightSpeed);
|
||||
desired_range = [dockingInstructions oo_floatForKey:@"range"];
|
||||
if ([dockingInstructions objectForKey:@"station"])
|
||||
{
|
||||
StationEntity *targetStation = [[dockingInstructions objectForKey:@"station"] weakRefUnderlyingObject];
|
||||
if (targetStation != nil)
|
||||
{
|
||||
[self addTarget:targetStation];
|
||||
[self setTargetStation:targetStation];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self removeTarget:[self primaryTarget]];
|
||||
}
|
||||
}
|
||||
docking_match_rotation = [dockingInstructions oo_boolForKey:@"match_rotation"];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) addFuel:(NSString*) fuel_number
|
||||
{
|
||||
|
@ -465,7 +465,6 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, HPVector coords,
|
||||
[acc oo_setFloat:speed forKey:@"speed"];
|
||||
[acc oo_setFloat:range forKey:@"range"];
|
||||
[acc setObject:[[station weakRetain] autorelease] forKey:@"station"];
|
||||
[acc oo_setInteger:[station universalID] forKey:@"station_id"]; // TODO: remove
|
||||
[acc oo_setBool:match_rotation forKey:@"match_rotation"];
|
||||
if (ai_message)
|
||||
{
|
||||
@ -2365,7 +2364,7 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, HPVector coords,
|
||||
{
|
||||
NSMutableArray *flags = nil;
|
||||
NSString *flagsString = nil;
|
||||
NSString *alertString = nil;
|
||||
NSString *alertString = @"*** ERROR: UNKNOWN ALERT LEVEL ***";
|
||||
|
||||
[super dumpSelfState];
|
||||
|
||||
@ -2382,9 +2381,6 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, HPVector coords,
|
||||
case STATION_ALERT_LEVEL_RED:
|
||||
alertString = @"red";
|
||||
break;
|
||||
|
||||
default:
|
||||
alertString = @"*** ERROR: UNKNOWN ALERT LEVEL ***";
|
||||
}
|
||||
|
||||
OOLog(@"dumpState.stationEntity", @"Alert level: %@", alertString);
|
||||
|
@ -39,8 +39,6 @@ MA 02110-1301, USA.
|
||||
#import "OOJSFrameCallbacks.h"
|
||||
#import "OOOpenGLExtensionManager.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.GameController"
|
||||
|
||||
#if OOLITE_MAC_OS_X
|
||||
#import "JAPersistentFileReference.h"
|
||||
#import <Sparkle/Sparkle.h>
|
||||
|
@ -129,6 +129,11 @@ MA 02110-1301, USA.
|
||||
#define MISSILE_ICON_WIDTH 12
|
||||
#define MISSILE_ICON_HEIGHT MISSILE_ICON_WIDTH
|
||||
|
||||
#define PRIMED_DISPLAY_X -144
|
||||
#define PRIMED_DISPLAY_Y -256
|
||||
#define PRIMED_DISPLAY_WIDTH 12
|
||||
#define PRIMED_DISPLAY_HEIGHT 12
|
||||
|
||||
#define CLOCK_DISPLAY_X -44
|
||||
#define CLOCK_DISPLAY_Y -234
|
||||
#define CLOCK_DISPLAY_WIDTH 12
|
||||
|
@ -46,9 +46,6 @@ MA 02110-1301, USA.
|
||||
#import "OOJavaScriptEngine.h"
|
||||
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.HeadUpDisplay"
|
||||
|
||||
|
||||
#define ONE_SIXTEENTH 0.0625
|
||||
#define ONE_SIXTYFOURTH 0.015625
|
||||
#define DEFAULT_OVERALL_ALPHA 0.75
|
||||
@ -135,6 +132,7 @@ enum
|
||||
- (void) drawStatusLight:(NSDictionary *)info;
|
||||
- (void) drawDirectionCue:(NSDictionary *)info;
|
||||
- (void) drawClock:(NSDictionary *)info;
|
||||
- (void) drawPrimedEquipmentText:(NSDictionary *)info;
|
||||
- (void) drawWeaponsOfflineText:(NSDictionary *)info;
|
||||
- (void) drawFPSInfoCounter:(NSDictionary *)info;
|
||||
- (void) drawScoopStatus:(NSDictionary *)info;
|
||||
@ -1147,8 +1145,7 @@ static void prefetchData(NSDictionary *info, struct CachedInfo *data)
|
||||
if ([scannedEntity isShip])
|
||||
{
|
||||
ShipEntity *ship = (ShipEntity *)scannedEntity;
|
||||
GLfloat wr = [ship weaponRange];
|
||||
isHostile = (([ship hasHostileTarget])&&([ship primaryTarget] == PLAYER)&&(scannedEntity->zero_distance < wr*wr));
|
||||
isHostile = (([ship hasHostileTarget])&&([ship primaryTarget] == PLAYER));
|
||||
GLfloat *base_col = [ship scannerDisplayColorForShip:PLAYER :isHostile :flash :[ship scannerDisplayColor1] :[ship scannerDisplayColor2]];
|
||||
col[0] = base_col[0]; col[1] = base_col[1]; col[2] = base_col[2]; col[3] = alpha * base_col[3];
|
||||
}
|
||||
@ -2442,6 +2439,65 @@ static OOPolygonSprite *IconForMissileRole(NSString *role)
|
||||
}
|
||||
|
||||
|
||||
- (void) drawPrimedEquipment:(NSDictionary *)info
|
||||
{
|
||||
if ([PLAYER status] == STATUS_DOCKED)
|
||||
{
|
||||
// Can't activate equipment while docked
|
||||
return;
|
||||
}
|
||||
|
||||
GLfloat itemColor[4] = { 0.0f, 1.0f, 0.0f, 1.0f };
|
||||
struct CachedInfo cached;
|
||||
|
||||
NSUInteger lines = [info oo_intForKey:@"n_bars" defaultValue:1];
|
||||
NSInteger pec = (NSInteger)[PLAYER primedEquipmentCount];
|
||||
|
||||
[(NSValue *)[sCurrentDrawItem objectAtIndex:WIDGET_CACHE] getValue:&cached];
|
||||
|
||||
NSInteger x = useDefined(cached.x, PRIMED_DISPLAY_X) + [[UNIVERSE gameView] x_offset] * cached.x0;
|
||||
NSInteger y = useDefined(cached.y, PRIMED_DISPLAY_Y) + [[UNIVERSE gameView] y_offset] * cached.y0;
|
||||
|
||||
NSSize size =
|
||||
{
|
||||
.width = useDefined(cached.width, PRIMED_DISPLAY_WIDTH),
|
||||
.height = useDefined(cached.height, PRIMED_DISPLAY_HEIGHT)
|
||||
};
|
||||
|
||||
if (pec == 0)
|
||||
{
|
||||
// Don't display if no primed equipment fitted
|
||||
return;
|
||||
}
|
||||
|
||||
GetRGBAArrayFromInfo(info, itemColor);
|
||||
itemColor[3] *= overallAlpha;
|
||||
|
||||
if (lines == 1)
|
||||
{
|
||||
OOGL(glColor4f(itemColor[0], itemColor[1], itemColor[2], itemColor[3]));
|
||||
OODrawString([NSString stringWithFormat:DESC(@"equipment-primed-hud-@"), [PLAYER primedEquipmentName:0]], x, y, z1, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSInteger negative = (lines % 2) ? (lines - 1) / 2 : lines / 2;
|
||||
NSInteger positive = lines / 2;
|
||||
for (NSInteger i = -negative; i <= positive; i++)
|
||||
{
|
||||
if (i >= -(pec) / 2 && i <= (pec + 1) / 2)
|
||||
{
|
||||
// don't display loops if we have more equipment than lines
|
||||
// instead compact the display towards its centre
|
||||
GLfloat alphaScale = 1.0/((i<0)?(1.0-i):(1.0+i));
|
||||
OOGL(glColor4f(itemColor[0], itemColor[1], itemColor[2], itemColor[3]*alphaScale));
|
||||
OODrawString([PLAYER primedEquipmentName:i], x, y, z1, size);
|
||||
}
|
||||
y -= size.height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) drawWeaponsOfflineText:(NSDictionary *)info
|
||||
{
|
||||
if (![PLAYER weaponsOnline])
|
||||
|
@ -32,8 +32,6 @@ MA 02110-1301, USA.
|
||||
#import "GameController.h"
|
||||
#import "NSFileManagerOOExtensions.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.NSFileManagerOOExtensions"
|
||||
|
||||
|
||||
@implementation NSFileManager (OOExtensions)
|
||||
|
||||
|
@ -29,9 +29,6 @@ MA 02110-1301, USA.
|
||||
#import "OOCollectionExtractors.h"
|
||||
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.JoystickHandler"
|
||||
|
||||
|
||||
static Class sStickHandlerClass = Nil;
|
||||
static id sSharedStickHandler = nil;
|
||||
|
||||
|
@ -28,7 +28,6 @@ SOFTWARE.
|
||||
|
||||
|
||||
#define OOLOG_POISON_NSLOG 0
|
||||
#define DLOPEN_NO_WARN
|
||||
|
||||
#import "OOLogOutputHandler.h"
|
||||
#import "OOLogging.h"
|
||||
|
@ -41,9 +41,6 @@ SOFTWARE.
|
||||
|
||||
|
||||
#define PER_THREAD_INDENTATION 1
|
||||
#ifndef APPNAME
|
||||
#define APPNAME @"Oolite"
|
||||
#endif
|
||||
|
||||
|
||||
#if PER_THREAD_INDENTATION
|
||||
@ -65,7 +62,6 @@ SOFTWARE.
|
||||
#define OOLOG_NOT_INITED 1
|
||||
#define OOLOG_SETTING_SET 0
|
||||
#define OOLOG_SETTING_RETRIEVE 0
|
||||
#define OOLOG_METACLASS_LOOP 1
|
||||
#define OOLOG_UNDEFINED_METACLASS 1
|
||||
#define OOLOG_BAD_SETTING 1
|
||||
#define OOLOG_BAD_DEFAULT_SETTING 1
|
||||
|
@ -39,9 +39,6 @@ static NSString * const kOOLogPListFoundationParseError = @"plist.parse.failed"
|
||||
static NSString * const kOOLogPListWrongType = @"plist.wrongType";
|
||||
|
||||
|
||||
#define OOLITE_EXCEPTION_XML_PARSING_FAILURE @"OOXMLException"
|
||||
|
||||
|
||||
#ifndef NO_DYNAMIC_PLIST_DTD_CHANGE
|
||||
static NSData *ChangeDTDIfApplicable(NSData *data);
|
||||
#endif
|
||||
|
@ -98,7 +98,6 @@ static void SVGDumpBeginPrimitive(TessPolygonData *data);
|
||||
static void SVGDumpEndPrimitive(TessPolygonData *data);
|
||||
static void SVGDumpAppendTriangle(TessPolygonData *data, NSPoint v0, NSPoint v1, NSPoint v2);
|
||||
#else
|
||||
#define SVGDumpBegin(data) do {} while (0)
|
||||
#define SVGDumpEnd(data) do {} while (0)
|
||||
#define SVGDumpBeginGroup(data, name) do {} while (0)
|
||||
#define SVGDumpEndGroup(data) do {} while (0)
|
||||
|
@ -37,7 +37,9 @@ MA 02110-1301, USA.
|
||||
#import "OOJSEngineTimeManagement.h"
|
||||
|
||||
|
||||
#if DEBUG_GRAPHVIZ
|
||||
#define NSMakeRange(loc, len) ((NSRange){loc, len})
|
||||
#endif
|
||||
|
||||
|
||||
static NSString * const kOOLogStringVectorConversion = @"strings.conversion.vector";
|
||||
|
@ -37,7 +37,6 @@ MA 02110-1301, USA.
|
||||
#define OctreeDebugLog(format, ...) do { if (EXPECT_NOT(gDebugFlags & DEBUG_OCTREE_LOGGING)) OOLog(@"octree.debug", format, ## __VA_ARGS__); } while (0)
|
||||
#else
|
||||
#define OctreeDebugLog(...) do {} while (0)
|
||||
#define OctreeDebugLog(...) do {} while (0)
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -40,8 +40,6 @@ MA 02110-1301, USA.
|
||||
#import "OOJSScript.h"
|
||||
#import "OOPListScript.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.ResourceManager"
|
||||
|
||||
|
||||
static NSString * const kOOLogCacheUpToDate = @"dataCache.upToDate";
|
||||
static NSString * const kOOLogCacheExplicitFlush = @"dataCache.rebuild.explicitFlush";
|
||||
@ -533,10 +531,11 @@ static NSMutableDictionary *sStringCache;
|
||||
case MERGE_SMART:
|
||||
mergeType = @"smart";
|
||||
break;
|
||||
|
||||
default:
|
||||
OOLog(kOOLogParameterError, @"Unknown dictionary merge mode %u for %@. (This is an internal programming error, please report it.)", mergeMode, fileName);
|
||||
return nil;
|
||||
}
|
||||
if (mergeType == nil)
|
||||
{
|
||||
OOLog(kOOLogParameterError, @"Unknown dictionary merge mode %u for %@. (This is an internal programming error, please report it.)", mergeMode, fileName);
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (cache)
|
||||
|
@ -74,6 +74,7 @@ static JSBool ShipFireECM(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipAbandonShip(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipCanAwardEquipment(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipAwardEquipment(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipRequestHelpFromGroup(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipRemoveEquipment(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipRestoreSubEntities(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipEquipmentStatus(JSContext *context, uintN argc, jsval *vp);
|
||||
@ -92,10 +93,31 @@ static JSBool ShipGetMaterials(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipGetShaders(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipBecomeCascadeExplosion(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipBroadcastCascadeImminent(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipBroadcastDistressMessage(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipOfferToEscort(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipMarkTargetForFines(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipEnterWormhole(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipThrowSpark(JSContext *context, uintN argc, jsval *vp);
|
||||
|
||||
static JSBool ShipPerformAttack(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipPerformCollect(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipPerformEscort(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipPerformFaceDestination(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipPerformFlee(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipPerformFlyToRangeFromDestination(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipPerformHold(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipPerformIdle(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipPerformIntercept(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipPerformLandOnPlanet(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipPerformMining(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipPerformScriptedAI(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipPerformScriptedAttackAI(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipPerformStop(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipPerformTumble(JSContext *context, uintN argc, jsval *vp);
|
||||
|
||||
static JSBool ShipRequestDockingInstructions(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ShipRecallDockingInstructions(JSContext *context, uintN argc, jsval *vp);
|
||||
|
||||
static BOOL RemoveOrExplodeShip(JSContext *context, uintN argc, jsval *vp, BOOL explode);
|
||||
static JSBool ShipSetMaterialsInternal(JSContext *context, uintN argc, jsval *vp, ShipEntity *thisEnt, BOOL fromShaders);
|
||||
|
||||
@ -149,6 +171,7 @@ enum
|
||||
kShip_desiredSpeed, // AI desired flight speed, double, read/write
|
||||
kShip_destination, // flight destination, Vector, read/write
|
||||
kShip_displayName, // name displayed on screen, string, read/write
|
||||
kShip_dockingInstructions, // name displayed on screen, string, read/write
|
||||
kShip_energyRechargeRate, // energy recharge rate, float, read-only
|
||||
kShip_entityPersonality, // per-ship random number, int, read-only
|
||||
kShip_equipment, // the ship's equipment, array of EquipmentInfo, read only
|
||||
@ -271,6 +294,7 @@ static JSPropertySpec sShipProperties[] =
|
||||
{ "desiredSpeed", kShip_desiredSpeed, OOJS_PROP_READWRITE_CB },
|
||||
{ "destination", kShip_destination, OOJS_PROP_READWRITE_CB },
|
||||
{ "displayName", kShip_displayName, OOJS_PROP_READWRITE_CB },
|
||||
{ "dockingInstructions", kShip_dockingInstructions, OOJS_PROP_READONLY_CB },
|
||||
{ "energyRechargeRate", kShip_energyRechargeRate, OOJS_PROP_READONLY_CB },
|
||||
{ "entityPersonality", kShip_entityPersonality, OOJS_PROP_READONLY_CB },
|
||||
{ "equipment", kShip_equipment, OOJS_PROP_READONLY_CB },
|
||||
@ -372,6 +396,7 @@ static JSFunctionSpec sShipMethods[] =
|
||||
{ "awardEquipment", ShipAwardEquipment, 1 },
|
||||
{ "becomeCascadeExplosion", ShipBecomeCascadeExplosion, 0 },
|
||||
{ "broadcastCascadeImminent", ShipBroadcastCascadeImminent, 0 },
|
||||
{ "broadcastDistressMessage", ShipBroadcastDistressMessage, 0 },
|
||||
{ "canAwardEquipment", ShipCanAwardEquipment, 1 },
|
||||
{ "clearDefenseTargets", ShipClearDefenseTargets, 0 },
|
||||
{ "commsMessage", ShipCommsMessage, 1 },
|
||||
@ -391,10 +416,30 @@ static JSFunctionSpec sShipMethods[] =
|
||||
{ "getMaterials", ShipGetMaterials, 0 },
|
||||
{ "getShaders", ShipGetShaders, 0 },
|
||||
{ "hasRole", ShipHasRole, 1 },
|
||||
{ "markTargetForFines", ShipMarkTargetForFines, 0 },
|
||||
{ "offerToEscort", ShipOfferToEscort, 1 },
|
||||
{ "performAttack", ShipPerformAttack, 0 },
|
||||
{ "performCollect", ShipPerformCollect, 0 },
|
||||
{ "performEscort", ShipPerformEscort, 0 },
|
||||
{ "performFaceDestination", ShipPerformFaceDestination, 0 },
|
||||
{ "performFlee", ShipPerformFlee, 0 },
|
||||
{ "performFlyToRangeFromDestination", ShipPerformFlyToRangeFromDestination, 0 },
|
||||
{ "performHold", ShipPerformHold, 0 },
|
||||
{ "performIdle", ShipPerformIdle, 0 },
|
||||
{ "performIntercept", ShipPerformIntercept, 0 },
|
||||
{ "performLandOnPlanet", ShipPerformLandOnPlanet, 0 },
|
||||
{ "performMining", ShipPerformMining, 0 },
|
||||
{ "performScriptedAI", ShipPerformScriptedAI, 0 },
|
||||
{ "performScriptedAttackAI", ShipPerformScriptedAttackAI, 0 },
|
||||
{ "performStop", ShipPerformStop, 0 },
|
||||
{ "performTumble", ShipPerformTumble, 0 },
|
||||
|
||||
{ "reactToAIMessage", ShipReactToAIMessage, 1 },
|
||||
{ "remove", ShipRemove, 0 },
|
||||
{ "removeEquipment", ShipRemoveEquipment, 1 },
|
||||
{ "requestHelpFromGroup", ShipRequestHelpFromGroup, 1},
|
||||
{ "requestDockingInstructions", ShipRequestDockingInstructions, 0},
|
||||
{ "recallDockingInstructions", ShipRecallDockingInstructions, 0},
|
||||
{ "restoreSubEntities", ShipRestoreSubEntities, 0 },
|
||||
{ "__runLegacyScriptActions", ShipRunLegacyScriptActions, 2 }, // Deliberately not documented
|
||||
{ "selectNewMissile", ShipSelectNewMissile, 0 },
|
||||
@ -653,7 +698,7 @@ static JSBool ShipGetProperty(JSContext *context, JSObject *this, jsid propID, j
|
||||
return YES;
|
||||
|
||||
case kShip_extraCargo:
|
||||
*value = INT_TO_JSVAL([entity extraCargo]);
|
||||
return JS_NewNumberValue(context, [entity extraCargo], value);
|
||||
return YES;
|
||||
|
||||
case kShip_commodity:
|
||||
@ -846,6 +891,10 @@ static JSBool ShipGetProperty(JSContext *context, JSObject *this, jsid propID, j
|
||||
result = [entity contractListForScripting];
|
||||
break;
|
||||
|
||||
case kShip_dockingInstructions:
|
||||
result = [entity dockingInstructions];
|
||||
break;
|
||||
|
||||
case kShip_scannerDisplayColor1:
|
||||
result = [[entity scannerDisplayColor1] normalizedArray];
|
||||
break;
|
||||
@ -2669,6 +2718,44 @@ static JSBool ShipOfferToEscort(JSContext *context, uintN argc, jsval *vp)
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipRequestHelpFromGroup(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
|
||||
[thisEnt groupAttackTarget];
|
||||
|
||||
OOJS_RETURN_VOID;
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipMarkTargetForFines(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
|
||||
ShipEntity *ship = [thisEnt primaryTarget];
|
||||
BOOL ok = NO;
|
||||
if ((ship != nil) && ([ship status] != STATUS_DEAD) && ([ship status] != STATUS_DOCKED))
|
||||
{
|
||||
ok = [ship markForFines];
|
||||
}
|
||||
|
||||
OOJS_RETURN_BOOL(ok);
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipEnterWormhole(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
@ -2718,6 +2805,259 @@ static JSBool ShipThrowSpark(JSContext *context, uintN argc, jsval *vp)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static JSBool ShipPerformAttack(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt performAttack];
|
||||
|
||||
OOJS_RETURN_VOID;
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipPerformCollect(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt performCollect];
|
||||
|
||||
OOJS_RETURN_VOID;
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipPerformEscort(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt performEscort];
|
||||
|
||||
OOJS_RETURN_VOID;
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipPerformFaceDestination(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt performFaceDestination];
|
||||
|
||||
OOJS_RETURN_VOID;
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipPerformFlee(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt performFlee];
|
||||
|
||||
OOJS_RETURN_VOID;
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipPerformFlyToRangeFromDestination(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt performFlyToRangeFromDestination];
|
||||
|
||||
OOJS_RETURN_VOID;
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipPerformHold(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt performHold];
|
||||
|
||||
OOJS_RETURN_VOID;
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipPerformIdle(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt performIdle];
|
||||
|
||||
OOJS_RETURN_VOID;
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipPerformIntercept(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt performIntercept];
|
||||
|
||||
OOJS_RETURN_VOID;
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipPerformLandOnPlanet(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt performLandOnPlanet];
|
||||
|
||||
OOJS_RETURN_VOID;
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipPerformMining(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt performMining];
|
||||
|
||||
OOJS_RETURN_VOID;
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipPerformScriptedAI(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt performScriptedAI];
|
||||
|
||||
OOJS_RETURN_VOID;
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipPerformScriptedAttackAI(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt performScriptedAttackAI];
|
||||
|
||||
OOJS_RETURN_VOID;
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipPerformStop(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt performStop];
|
||||
|
||||
OOJS_RETURN_VOID;
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipPerformTumble(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt performTumble];
|
||||
|
||||
OOJS_RETURN_VOID;
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipRequestDockingInstructions(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt requestDockingCoordinates];
|
||||
|
||||
OOJS_RETURN_OBJECT([thisEnt dockingInstructions]);
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipRecallDockingInstructions(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt recallDockingInstructions];
|
||||
|
||||
OOJS_RETURN_OBJECT([thisEnt dockingInstructions]);
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ShipBroadcastDistressMessage(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_PROFILE_ENTER
|
||||
|
||||
ShipEntity *thisEnt = nil;
|
||||
GET_THIS_SHIP(thisEnt);
|
||||
[thisEnt broadcastDistressMessage];
|
||||
|
||||
OOJS_RETURN_VOID;
|
||||
|
||||
OOJS_PROFILE_EXIT
|
||||
}
|
||||
|
||||
|
||||
/** Static methods */
|
||||
|
||||
static JSBool ShipStaticKeys(JSContext *context, uintN argc, jsval *vp)
|
||||
|
@ -203,11 +203,3 @@ static JSBool WormholeSetProperty(JSContext *context, JSObject *this, jsid propI
|
||||
|
||||
|
||||
// *** Methods ***
|
||||
|
||||
#define GET_THIS_WORMHOLE(THISENT) do { \
|
||||
if (EXPECT_NOT(!JSWormholeGetWormholeEntity(context, OOJS_THIS, &THISENT))) return NO; /* Exception */ \
|
||||
if (OOIsStaleEntity(THISENT)) OOJS_RETURN_VOID; \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
|
@ -103,7 +103,6 @@ enum
|
||||
|
||||
|
||||
#define MAX_NUMBER_OF_ENTITIES 200
|
||||
#define MAX_NUMBER_OF_SOLAR_SYSTEM_ENTITIES 20
|
||||
#define STANDARD_STATION_ROLL 0.4
|
||||
#define WOLFPACK_SHIPS_DISTANCE 0.1
|
||||
#define FIXED_ASTEROID_FIELDS 0
|
||||
@ -136,18 +135,18 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void * context);
|
||||
double _cost, _distance, _time;
|
||||
}
|
||||
|
||||
+ (id) newElementWithLocation:(OOSystemID) location parent:(OOSystemID)parent cost:(double) cost distance:(double) distance time:(double) time;
|
||||
- (OOSystemID) getParent;
|
||||
- (OOSystemID) getLocation;
|
||||
- (double) getCost;
|
||||
- (double) getDistance;
|
||||
- (double) getTime;
|
||||
+ (instancetype) elementWithLocation:(OOSystemID) location parent:(OOSystemID)parent cost:(double) cost distance:(double) distance time:(double) time;
|
||||
- (OOSystemID) parent;
|
||||
- (OOSystemID) location;
|
||||
- (double) cost;
|
||||
- (double) distance;
|
||||
- (double) time;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RouteElement
|
||||
|
||||
+ (id) newElementWithLocation:(OOSystemID) location parent:(OOSystemID) parent cost:(double) cost distance:(double) distance time:(double) time
|
||||
+ (instancetype) elementWithLocation:(OOSystemID) location parent:(OOSystemID) parent cost:(double) cost distance:(double) distance time:(double) time
|
||||
{
|
||||
RouteElement *r = [[RouteElement alloc] init];
|
||||
|
||||
@ -157,14 +156,14 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void * context);
|
||||
r->_distance = distance;
|
||||
r->_time = time;
|
||||
|
||||
return r;
|
||||
return [r autorelease];
|
||||
}
|
||||
|
||||
- (OOSystemID) getParent { return _parent; }
|
||||
- (OOSystemID) getLocation { return _location; }
|
||||
- (double) getCost { return _cost; }
|
||||
- (double) getDistance { return _distance; }
|
||||
- (double) getTime { return _time; }
|
||||
- (OOSystemID) parent { return _parent; }
|
||||
- (OOSystemID) location { return _location; }
|
||||
- (double) cost { return _cost; }
|
||||
- (double) distance { return _distance; }
|
||||
- (double) time { return _time; }
|
||||
|
||||
@end
|
||||
|
||||
@ -2555,7 +2554,14 @@ GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEVEL, DOC
|
||||
|
||||
- (void) handleGameOver
|
||||
{
|
||||
[[self gameController] loadPlayerIfRequired];
|
||||
if ([[self gameController] playerFileToLoad])
|
||||
{
|
||||
[[self gameController] loadPlayerIfRequired];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self reinitAndShowDemo:NO];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7602,36 +7608,39 @@ static NSDictionary *sCachedSystemData = nil;
|
||||
if (start > 255 || goal > 255) return nil;
|
||||
|
||||
NSArray *neighbours[256];
|
||||
for (i = 0; i < 256; i++) neighbours[i] = [self neighboursToSystem:i];
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
neighbours[i] = [self neighboursToSystem:i];
|
||||
}
|
||||
|
||||
RouteElement *cheapest[256];
|
||||
for (i = 0; i < 256; i++) cheapest[i] = nil;
|
||||
RouteElement *cheapest[256] = {0};
|
||||
|
||||
double maxCost = optimizeBy == OPTIMIZED_BY_TIME ? 256 * (7 * 7) : 256 * (7 * 256 + 7);
|
||||
|
||||
NSMutableArray *curr = [NSMutableArray arrayWithCapacity:256];
|
||||
[curr addObject:cheapest[start] = [RouteElement newElementWithLocation:start parent:-1 cost:0 distance:0 time:0]];
|
||||
[curr addObject:cheapest[start] = [RouteElement elementWithLocation:start parent:-1 cost:0 distance:0 time:0]];
|
||||
|
||||
NSMutableArray *next = [NSMutableArray arrayWithCapacity:256];
|
||||
while ([curr count] != 0)
|
||||
{
|
||||
for (i = 0; i < [curr count]; i++) {
|
||||
NSArray *ns = neighbours[[[curr objectAtIndex:i] getLocation]];
|
||||
RouteElement *elemI = [curr objectAtIndex:i];
|
||||
NSArray *ns = neighbours[[elemI location]];
|
||||
for (j = 0; j < [ns count]; j++)
|
||||
{
|
||||
RouteElement *ce = cheapest[[[curr objectAtIndex:i] getLocation]];
|
||||
RouteElement *ce = cheapest[[elemI location]];
|
||||
OOSystemID n = [ns oo_intAtIndex:j];
|
||||
OOSystemID c = [ce getLocation];
|
||||
OOSystemID c = [ce location];
|
||||
|
||||
double lastDistance = distanceBetweenPlanetPositions(systems[c].d, systems[c].b, systems[n].d, systems[n].b);
|
||||
double lastTime = lastDistance * lastDistance;
|
||||
|
||||
double distance = [ce getDistance] + lastDistance;
|
||||
double time = [ce getTime] + lastTime;
|
||||
double cost = [ce getCost] + (optimizeBy == OPTIMIZED_BY_TIME ? lastTime : 7 * 256 + lastDistance);
|
||||
double distance = [ce distance] + lastDistance;
|
||||
double time = [ce time] + lastTime;
|
||||
double cost = [ce cost] + (optimizeBy == OPTIMIZED_BY_TIME ? lastTime : 7 * 256 + lastDistance);
|
||||
|
||||
if (cost < maxCost && (cheapest[n] == nil || [cheapest[n] getCost] > cost)) {
|
||||
RouteElement *e = [RouteElement newElementWithLocation:n parent:c cost:cost distance:distance time:time];
|
||||
if (cost < maxCost && (cheapest[n] == nil || [cheapest[n] cost] > cost)) {
|
||||
RouteElement *e = [RouteElement elementWithLocation:n parent:c cost:cost distance:distance time:time];
|
||||
cheapest[n] = e;
|
||||
[next addObject:e];
|
||||
|
||||
@ -7651,23 +7660,24 @@ static NSDictionary *sCachedSystemData = nil;
|
||||
RouteElement *e = cheapest[goal];
|
||||
for (;;)
|
||||
{
|
||||
[route insertObject:[NSNumber numberWithInt:[e getLocation]] atIndex:0];
|
||||
if ([e getParent] == -1) break;
|
||||
e = cheapest[[e getParent]];
|
||||
[route insertObject:[NSNumber numberWithInt:[e location]] atIndex:0];
|
||||
if ([e parent] == -1) break;
|
||||
e = cheapest[[e parent]];
|
||||
}
|
||||
|
||||
#ifdef CACHE_ROUTE_FROM_SYSTEM_RESULTS
|
||||
c_start = start;
|
||||
c_goal = goal;
|
||||
c_optimizeBy = optimizeBy;
|
||||
c_route = [NSDictionary dictionaryWithObjectsAndKeys: route, @"route", [NSNumber numberWithDouble:[cheapest[goal] getDistance]], @"distance", nil];
|
||||
[c_route release];
|
||||
c_route = [[NSDictionary alloc] initWithObjectsAndKeys: route, @"route", [NSNumber numberWithDouble:[cheapest[goal] distance]], @"distance", nil];
|
||||
|
||||
return c_route;
|
||||
#else
|
||||
return [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
route, @"route",
|
||||
[NSNumber numberWithDouble:[cheapest[goal] getDistance]], @"distance",
|
||||
[NSNumber numberWithDouble:[cheapest[goal] getTime]], @"time",
|
||||
[NSNumber numberWithDouble:[cheapest[goal] distance]], @"distance",
|
||||
[NSNumber numberWithDouble:[cheapest[goal] time]], @"time",
|
||||
nil];
|
||||
#endif
|
||||
}
|
||||
|
@ -1,41 +1,54 @@
|
||||
#! /bin/bash
|
||||
|
||||
VAR_DIR_NAME=var
|
||||
REPO_DIR_NAME=trunk
|
||||
CONFIGURATION=TestRelease
|
||||
REPOSITORY="https://github.com/OoliteProject/oolite.git"
|
||||
BRANCH="maintenance/1.77"
|
||||
CONFIGURATION="TestRelease"
|
||||
|
||||
if [ -z "$SVN" ]
|
||||
then
|
||||
SVN=`which svn`
|
||||
fi
|
||||
VAR_DIR_NAME="var"
|
||||
REPO_DIR_NAME="working_copy"
|
||||
|
||||
VAR=../$VAR_DIR_NAME/
|
||||
LOG=$VAR/log/
|
||||
LOG_OLD=$VAR/log-old/
|
||||
LOG_SUCCESS=$VAR/log-success/
|
||||
COCOA_SRC_DIR=src/Cocoa/
|
||||
SNAPSHOT_MACRO_FILE=$COCOA_SRC_DIR/oolite-snapshot.xcconfig
|
||||
BUILD_DIR=build/$CONFIGURATION/
|
||||
VAR="`pwd`/$VAR_DIR_NAME/"
|
||||
LOG="$VAR/log/"
|
||||
LOG_OLD="$VAR/log-old/"
|
||||
LOG_SUCCESS="$VAR/log-success/"
|
||||
COCOA_SRC_DIR="src/Cocoa/"
|
||||
SNAPSHOT_MACRO_FILE="$COCOA_SRC_DIR/oolite-snapshot.xcconfig"
|
||||
BUILD_DIR="build/$CONFIGURATION/"
|
||||
|
||||
LAST_REVISION_FILE=$VAR/revision
|
||||
SUCCESS_REVISION_FILE=$VAR/success_revision
|
||||
PREVIOUS_SUCCESS_REVISION_FILE=$VAR/previous_success_revision
|
||||
LATEST_NAME_FILE=$VAR/latest
|
||||
CHANGELOG_FILE=$LOG/change_log
|
||||
DIAGNOSTICS_FILE=$LOG/diagnostics
|
||||
STDERR_FILE=$LOG/xcb_stderr.txt
|
||||
STDOUT_FILE=$LOG/xcb_stdout.txt
|
||||
STATUS_FILE=$LOG/build_log
|
||||
SVNUP_FILE=$LOG/svnup.txt
|
||||
LAST_REVISION_FILE="$VAR/revision"
|
||||
SUCCESS_REVISION_FILE="$VAR/success_revision"
|
||||
PREVIOUS_SUCCESS_REVISION_FILE="$VAR/previous_success_revision"
|
||||
LATEST_NAME_FILE="$VAR/latest"
|
||||
CHANGELOG_FILE="$LOG/change_log"
|
||||
DIAGNOSTICS_FILE="$LOG/diagnostics"
|
||||
STDERR_FILE="$LOG/xcb_stderr.txt"
|
||||
STDOUT_FILE="$LOG/xcb_stdout.txt"
|
||||
STATUS_FILE="$LOG/build_log.txt"
|
||||
GIT_LOG_FILE="$LOG/git_log.txt"
|
||||
LAST_UPDATED_FILE="$VAR/last_updated"
|
||||
|
||||
OOLITE_APP_PKG=$BUILD_DIR/Oolite.app
|
||||
DEBUG_OXP_PKG=$BUILD_DIR/Debug.oxp
|
||||
OOLITE_APP_PKG="$BUILD_DIR/Oolite.app"
|
||||
DEBUG_OXP_PKG="$BUILD_DIR/Debug.oxp"
|
||||
|
||||
FTP_URL_FILE=../config/ftp_url
|
||||
FTP_CREDENTIALS_FILE=../config/ftp_credentials
|
||||
FTP_URL_FILE="`pwd`/config/ftp_url"
|
||||
FTP_CREDENTIALS_FILE="`pwd`/config/ftp_credentials"
|
||||
FTP_INFO_SET=0
|
||||
|
||||
if [ ! "$GIT" ]
|
||||
then
|
||||
GIT="git"
|
||||
fi
|
||||
|
||||
if [ ! "$CURL" ]
|
||||
then
|
||||
CURL="curl"
|
||||
fi
|
||||
|
||||
if [ ! "$DITTO" ]
|
||||
then
|
||||
DITTO="ditto"
|
||||
fi
|
||||
|
||||
|
||||
function report
|
||||
{
|
||||
@ -49,7 +62,7 @@ function report
|
||||
|
||||
function fail
|
||||
{
|
||||
if [ $FTP_INFO_SET -eq 1 ] && [ -e $LAST_REVISION_FILE ]
|
||||
if [ $FTP_INFO_SET -eq 1 ] && [ -e "$LAST_REVISION_FILE" ]
|
||||
then
|
||||
curl --silent $FTP_CREDENTIALS -T "$LAST_REVISION_FILE" "$FTP_URL/revision"
|
||||
fi
|
||||
@ -58,57 +71,6 @@ function fail
|
||||
}
|
||||
|
||||
|
||||
if [ ! -e $REPO_DIR_NAME ]
|
||||
then
|
||||
# Check out repo if necessary.
|
||||
CLEAN_CHECKOUT=1
|
||||
|
||||
echo "Checking out Oolite..."
|
||||
$SVN checkout --quiet svn://svn.berlios.de/oolite-linux/trunk $REPO_DIR_NAME
|
||||
if [ ! $? ]
|
||||
then
|
||||
fail "Failed to check out."
|
||||
fi
|
||||
|
||||
if [ -e $REPO_DIR_NAME/$LAST_REVISION_FILE ]
|
||||
then
|
||||
rm $REPO_DIR_NAME/$LAST_REVISION_FILE
|
||||
fi
|
||||
|
||||
# Run update-mozilla script up front so there's a bit of feedback.
|
||||
pushd $REPO_DIR_NAME/deps/Cocoa-deps/scripts > /dev/null
|
||||
./update-mozilla.sh
|
||||
UPDATE_RESULT=$1
|
||||
popd > /dev/null
|
||||
|
||||
if [ ! $UPDATE_RESULT ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
CLEAN_CHECKOUT=0
|
||||
fi
|
||||
|
||||
|
||||
cd $REPO_DIR_NAME
|
||||
|
||||
|
||||
# ftp_url should contain a URL to an upload directory.
|
||||
# ftp_credentials should contain command line arguments for curl authentication,
|
||||
# such as -u user:password.
|
||||
if [ -e $FTP_URL_FILE ] && [ -e $FTP_CREDENTIALS_FILE ]
|
||||
then
|
||||
FTP_URL=`head -n 1 "$FTP_URL_FILE"`
|
||||
FTP_CREDENTIALS=`head -n 1 "$FTP_CREDENTIALS_FILE"`
|
||||
FTP_INFO_SET=1
|
||||
else
|
||||
FTP_INFO_SET=0
|
||||
fi
|
||||
|
||||
# Get $OOLITE_VERSION
|
||||
source $COCOA_SRC_DIR/oolite-version.xcconfig
|
||||
|
||||
|
||||
# Ensure output directories exist.
|
||||
if [ ! -e $VAR ]
|
||||
then
|
||||
@ -125,10 +87,65 @@ then
|
||||
mv $LOG $LOG_OLD
|
||||
fi
|
||||
|
||||
|
||||
mkdir $LOG
|
||||
|
||||
|
||||
# Clear git log so we can append to it freely
|
||||
touch "$GIT_LOG_FILE"
|
||||
echo "" > "$GIT_LOG_FILE"
|
||||
|
||||
|
||||
if [ ! -e "$REPO_DIR_NAME" ]
|
||||
then
|
||||
# Clone repo if necessary.
|
||||
CLEAN_CHECKOUT=1
|
||||
|
||||
echo "Cloning Oolite..."
|
||||
"$GIT" clone --quiet "$REPOSITORY" "$REPO_DIR_NAME" >> "$GIT_LOG_FILE"
|
||||
if [ ! $? ]
|
||||
then
|
||||
fail "Failed to clone repository."
|
||||
fi
|
||||
|
||||
STATUS=0
|
||||
|
||||
cd "$REPO_DIR_NAME"
|
||||
"$GIT" checkout "$BRANCH"
|
||||
else
|
||||
# Revert the file we manipulate for watermarking, then update repo.
|
||||
CLEAN_CHECKOUT=0
|
||||
cd "$REPO_DIR_NAME"
|
||||
|
||||
echo "Updating..."
|
||||
"$GIT" checkout -- "$SNAPSHOT_MACRO_FILE" >> "$GIT_LOG_FILE"
|
||||
|
||||
"$GIT" pull --quiet --ff-only >> "$GIT_LOG_FILE"
|
||||
STATUS=$?
|
||||
fi
|
||||
|
||||
# Get $OOLITE_VERSION
|
||||
source $COCOA_SRC_DIR/oolite-version.xcconfig
|
||||
|
||||
|
||||
# Make sure we're on the right branch, and update submodules.
|
||||
"$GIT" checkout "$BRANCH"
|
||||
STATUS=$?
|
||||
|
||||
if [ $STATUS ]
|
||||
then
|
||||
"$GIT" submodule update --quiet --init --recursive >> "$GIT_LOG_FILE"
|
||||
STATUS=$?
|
||||
fi
|
||||
|
||||
if [ ! $STATUS ]
|
||||
then
|
||||
echo "Update failed: " > $DIAGNOSTICS_FILE
|
||||
cat $GIT_LOG_FILE >> $DIAGNOSTICS_FILE
|
||||
echo $STATUS
|
||||
fail "Code update failed."
|
||||
fi
|
||||
|
||||
|
||||
# Get last revision.
|
||||
if [ ! -e $LAST_REVISION_FILE ]
|
||||
then
|
||||
@ -138,29 +155,14 @@ else
|
||||
fi
|
||||
|
||||
|
||||
if [ $CLEAN_CHECKOUT -eq 0 ]
|
||||
then
|
||||
# Revert the file we manipulate for watermarking, then update repo.
|
||||
echo "Updating..."
|
||||
$SVN revert --quiet $SNAPSHOT_MACRO_FILE
|
||||
$SVN update > $SVNUP_FILE
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "Update failed: " > $DIAGNOSTICS_FILE
|
||||
cat $SVNUP_FILE >> $DIAGNOSTICS_FILE
|
||||
fail "SVN update failed."
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Get current revision.
|
||||
CURRENT_REVISION=`$SVN info 2> /dev/null | grep "Revision:" | cut -f 2 -d " "`
|
||||
CURRENT_REVISION=`"$GIT" rev-parse --short HEAD`
|
||||
if [ ! $? ]
|
||||
then
|
||||
fail "Could not get revision number."
|
||||
fail "Could not get revision hash."
|
||||
fi
|
||||
|
||||
if [ $LAST_REVISION -eq $CURRENT_REVISION ]
|
||||
if [ $LAST_REVISION == $CURRENT_REVISION ]
|
||||
then
|
||||
report "Oolite nightly unchanged" "No change, still at revision $LAST_REVISION."
|
||||
exit 0
|
||||
@ -181,16 +183,16 @@ fi
|
||||
|
||||
|
||||
# Nastytacular: overwrite the oolite-snapshot.xcconfig file to generate the nightly watermark macros.
|
||||
# The backslash jungle builds a string like -DOOLITE_SNAPSHOT_VERSION="\"1.74-3040\"".
|
||||
echo "SNAPSHOT_MACROS= -DSNAPSHOT_BUILD=1 -DOOLITE_SNAPSHOT_VERSION=\"\\\"$OOLITE_VERSION-$CURRENT_REVISION\\\"\"" > src/Cocoa/oolite-snapshot.xcconfig
|
||||
# The backslash jungle builds a string like -DOOLITE_SNAPSHOT_VERSION="\"1.77.1-130705\"".
|
||||
DATESTAMP=`date "+%y%m%d"`
|
||||
echo "SNAPSHOT_MACROS= -DSNAPSHOT_BUILD=1 -DOOLITE_SNAPSHOT_VERSION=\"\\\"$OOLITE_VERSION-$DATESTAMP\\\"\"" > src/Cocoa/oolite-snapshot.xcconfig
|
||||
|
||||
# Buildez la vache!
|
||||
xcodebuild clean build -project Oolite.xcodeproj -target "Build All" -configuration $CONFIGURATION RUN_CLANG_STATIC_ANALYZER=NO >$STDOUT_FILE 2>$STDERR_FILE
|
||||
|
||||
# Generate status and diagnostics files. The -mlong-branch bit filters out
|
||||
# an unimportant warning generated by a bug in the 10.4 SDK for Xcode 3.2.
|
||||
# Generate status and diagnostics files.
|
||||
grep "^[^\ ]" $STDOUT_FILE > $STATUS_FILE
|
||||
grep -e "warning:" -e "error:" $STDOUT_FILE | grep -v -e "-mlong-branch" > $DIAGNOSTICS_FILE
|
||||
grep -e "warning:" -e "error:" $STDOUT_FILE > $DIAGNOSTICS_FILE
|
||||
|
||||
|
||||
# Set last revision regardless of success or failure, on the basis that a
|
||||
@ -209,9 +211,9 @@ fi
|
||||
|
||||
|
||||
# Write changelog.
|
||||
if [ $LAST_REVISION -ne 0 ]
|
||||
if [ $LAST_REVISION != 0 ]
|
||||
then
|
||||
$SVN log -r$CURRENT_REVISION:$[$LAST_REVISION + 1] > $CHANGELOG_FILE
|
||||
"$GIT" log $LAST_REVISION..$CURRENT_REVISION > $CHANGELOG_FILE
|
||||
else
|
||||
echo "Initial checkout." > $CHANGELOG_FILE
|
||||
fi
|
||||
@ -234,7 +236,7 @@ then
|
||||
OOLITE_VERSION="$OOLITE_VERSION.0"
|
||||
fi
|
||||
|
||||
FULLVERSION=$OOLITE_VERSION.$CURRENT_REVISION-dev
|
||||
FULLVERSION=$OOLITE_VERSION.$DATESTAMP-dev
|
||||
echo "Packaging nightly $FULLVERSION..."
|
||||
|
||||
PACKAGE_NAME=Oolite-nightly-$FULLVERSION
|
||||
@ -249,7 +251,7 @@ mkdir $ADDONS_DIR
|
||||
cp -R $DEBUG_OXP_PKG $ADDONS_DIR
|
||||
|
||||
pushd $VAR > /dev/null
|
||||
ditto -ck --noqtn --noacl --nocache --zlibCompressionLevel 9 $PACKAGE_NAME $ZIP_NAME
|
||||
"$DITTO" -ck --noqtn --noacl --nocache --zlibCompressionLevel 9 "$PACKAGE_NAME" "$ZIP_NAME"
|
||||
if [ ! $? ]
|
||||
then
|
||||
fail "Could not create zip archive (ditto failed with exit code $?)."
|
||||
@ -258,6 +260,19 @@ rm -rf $PACKAGE_NAME
|
||||
popd > /dev/null
|
||||
|
||||
|
||||
# ftp_url should contain a URL to an upload directory.
|
||||
# ftp_credentials should contain command line arguments for curl authentication,
|
||||
# such as -u user:password.
|
||||
if [ -e $FTP_URL_FILE ] && [ -e $FTP_CREDENTIALS_FILE ]
|
||||
then
|
||||
FTP_URL=`head -n 1 "$FTP_URL_FILE"`
|
||||
FTP_CREDENTIALS=`head -n 1 "$FTP_CREDENTIALS_FILE"`
|
||||
FTP_INFO_SET=1
|
||||
else
|
||||
FTP_INFO_SET=0
|
||||
fi
|
||||
|
||||
|
||||
# Record date of this momentous event.
|
||||
date > $LAST_UPDATED_FILE
|
||||
|
||||
@ -274,7 +289,7 @@ fi
|
||||
|
||||
|
||||
echo "Uploading $ZIP_NAME..."
|
||||
curl "-#" $FTP_CREDENTIALS -T "$VAR/$ZIP_NAME" "$FTP_URL/$ZIP_NAME"
|
||||
"$CURL" "-#" $FTP_CREDENTIALS -T "$VAR/$ZIP_NAME" "$FTP_URL/$ZIP_NAME"
|
||||
if [ ! $? ]
|
||||
then
|
||||
echo ""
|
||||
@ -283,14 +298,14 @@ fi
|
||||
|
||||
echo ""
|
||||
echo "Uploading metadata..."
|
||||
curl --silent $FTP_CREDENTIALS -T "$LAST_UPDATED_FILE" "$FTP_URL/last_updated"
|
||||
curl --silent $FTP_CREDENTIALS -T "$CHANGELOG_FILE" "$FTP_URL/change_log"
|
||||
curl --silent $FTP_CREDENTIALS -T "$DIAGNOSTICS_FILE" "$FTP_URL/diagnostics"
|
||||
curl --silent $FTP_CREDENTIALS -T "$STATUS_FILE" "$FTP_URL/build_log"
|
||||
curl --silent $FTP_CREDENTIALS -T "$LAST_REVISION_FILE" "$FTP_URL/revision"
|
||||
curl --silent $FTP_CREDENTIALS -T "$PREVIOUS_SUCCESS_REVISION_FILE" "$FTP_URL/previous_successful"
|
||||
curl --silent $FTP_CREDENTIALS -T "$LATEST_NAME_FILE" "$FTP_URL/latest"
|
||||
"$CURL" --silent $FTP_CREDENTIALS -T "$LAST_UPDATED_FILE" "$FTP_URL/last_updated"
|
||||
"$CURL" --silent $FTP_CREDENTIALS -T "$CHANGELOG_FILE" "$FTP_URL/change_log"
|
||||
"$CURL" --silent $FTP_CREDENTIALS -T "$DIAGNOSTICS_FILE" "$FTP_URL/diagnostics"
|
||||
"$CURL" --silent $FTP_CREDENTIALS -T "$STATUS_FILE" "$FTP_URL/build_log"
|
||||
"$CURL" --silent $FTP_CREDENTIALS -T "$LAST_REVISION_FILE" "$FTP_URL/revision"
|
||||
"$CURL" --silent $FTP_CREDENTIALS -T "$PREVIOUS_SUCCESS_REVISION_FILE" "$FTP_URL/previous_successful"
|
||||
"$CURL" --silent $FTP_CREDENTIALS -T "$LATEST_NAME_FILE" "$FTP_URL/latest"
|
||||
|
||||
|
||||
rm $VAR/$ZIP_NAME
|
||||
report $"Oolite nightly success" "Successfully built r$CURRENT_REVISION and uploaded as $ZIP_NAME."
|
||||
report $"Oolite nightly success" "Successfully built commit $CURRENT_REVISION and uploaded as $ZIP_NAME."
|
||||
|
Loading…
x
Reference in New Issue
Block a user