This week's monster submit:
* Changed required.plist version parsing to treat version strings as series of integers separated by points. This allows: - correct parsing of bug-fix versions like 1.67.1 - correctly sorting 1.100 after 1.99. * Deleted just about all commented-out NSLog()s (several hundred), and some other commented-out code. (commented-out or #ifdefed-out code with no indication of when you might want to reinstate it is worse than useless.) * Ensured that most NSLog()s will at least include their class/module in their message class. * Renamed Universe's -recycledOrNew:, -getShipWithRole: and -getShip: to -allocRecycledOrNewEntity:, -newShipWithRole: and -newShipWithName: to better match Objective-C coding conventions. (Methods whose result needs releasing should always be called alloc*, copy*, retain* or new*.) * Replaced -[Universe generateSystemDescription] with DescriptionForSystem(). * Replaced -[Universe getRandomDigrams] with RandomDigrams(). * Replaced +[Universe systemSeedString] with StringFromRandomSeed(). * Replaced [Universe entityZero] with [PlayerEntity sharedPlayer]. * Replaced scriptedUniverse in ScriptEngine with [Universe sharedUniverse]. * Removed HAVE_SOUND. If you're porting to a platform without sound, use a no-op implementation of OOSound. * Removed all (commented-out) NSBeep()s. * Made settings caching in OOLog actually work. Doing complete message class setting resolution every time OOLog() was called was around 2% of our per-frame cost. (With this fixed, cache hit rate is well over 99% after a few seconds of play.) *headdesk* (It may also be worth moving the settings-check into the macro, to avoid evaluating parameters for log messages that are never seen, but this might cause obscure bugs due to the parameters having side effects.) Stuff that should have been in revision 859: * Replaced all occurrences of -[Universe expandDescription:forSystem:] with ExpandDescriptionForSeed() and ExpandDescriptionForCurrentSystem(). * Replaced -[Universe expandDescriptionWithLocals:forSystem:withLocalVariables:] with ExpandDescriptionsWithLocalsForSystemSeed() and ExpandDescriptionsWithLocalsForCurrentSystem(). git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@872 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
0cdc0f3a35
commit
6345c35592
@ -9,13 +9,13 @@ ifeq ($(GNUSTEP_HOST_OS),mingw32)
|
|||||||
ADDITIONAL_OBJC_LIBS = -lglu32 -lopengl32 -lmingw32 -lSDLmain -lSDL -lSDL_mixer -lSDL_image -lgnustep-base -ljs32
|
ADDITIONAL_OBJC_LIBS = -lglu32 -lopengl32 -lmingw32 -lSDLmain -lSDL -lSDL_mixer -lSDL_image -lgnustep-base -ljs32
|
||||||
ADDITIONAL_CFLAGS = -DLINUX -DWIN32 -DNEED_STRLCPY `sdl-config --cflags`
|
ADDITIONAL_CFLAGS = -DLINUX -DWIN32 -DNEED_STRLCPY `sdl-config --cflags`
|
||||||
# note the vpath stuff above isn't working for me, so adding src/SDL and src/Core explicitly
|
# note the vpath stuff above isn't working for me, so adding src/SDL and src/Core explicitly
|
||||||
ADDITIONAL_OBJCFLAGS = -DLOADSAVEGUI -DLINUX -DWIN32 -DXP_WIN -DHAVE_SOUND -Wno-import `sdl-config --cflags` -Isrc/SDL -Isrc/Core -Isrc/Core/JavaScript
|
ADDITIONAL_OBJCFLAGS = -DLOADSAVEGUI -DLINUX -DWIN32 -DXP_WIN -Wno-import `sdl-config --cflags` -Isrc/SDL -Isrc/Core -Isrc/Core/JavaScript
|
||||||
oolite_LIB_DIRS += -L$(GNUSTEP_LOCAL_ROOT)/lib -Ldeps/Windows-x86-deps/lib
|
oolite_LIB_DIRS += -L$(GNUSTEP_LOCAL_ROOT)/lib -Ldeps/Windows-x86-deps/lib
|
||||||
else
|
else
|
||||||
ADDITIONAL_INCLUDE_DIRS = -Isrc/SDL -Isrc/Core -Isrc/BSDCompat
|
ADDITIONAL_INCLUDE_DIRS = -Isrc/SDL -Isrc/Core -Isrc/BSDCompat
|
||||||
ADDITIONAL_OBJC_LIBS = -lGLU -lGL -lSDL -lpthread -lSDL_mixer -lSDL_image -lgnustep-base
|
ADDITIONAL_OBJC_LIBS = -lGLU -lGL -lSDL -lpthread -lSDL_mixer -lSDL_image -lgnustep-base
|
||||||
ADDITIONAL_CFLAGS = -DLINUX -DNEED_STRLCPY `sdl-config --cflags`
|
ADDITIONAL_CFLAGS = -DLINUX -DNEED_STRLCPY `sdl-config --cflags`
|
||||||
ADDITIONAL_OBJCFLAGS = -DLOADSAVEGUI -DLINUX -DHAVE_SOUND -Wno-import `sdl-config --cflags`
|
ADDITIONAL_OBJCFLAGS = -DLOADSAVEGUI -DLINUX -Wno-import `sdl-config --cflags`
|
||||||
oolite_LIB_DIRS += -L/usr/X11R6/lib/
|
oolite_LIB_DIRS += -L/usr/X11R6/lib/
|
||||||
endif
|
endif
|
||||||
OBJC_PROGRAM_NAME = oolite
|
OBJC_PROGRAM_NAME = oolite
|
||||||
|
@ -730,7 +730,7 @@
|
|||||||
083325DC09DDBCDE00F5B8E4 /* OOColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOColor.m; sourceTree = "<group>"; };
|
083325DC09DDBCDE00F5B8E4 /* OOColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOColor.m; sourceTree = "<group>"; };
|
||||||
083DB4D30A70E51E00B419B2 /* OOBrain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOBrain.h; sourceTree = "<group>"; };
|
083DB4D30A70E51E00B419B2 /* OOBrain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOBrain.h; sourceTree = "<group>"; };
|
||||||
083DB4D40A70E51E00B419B2 /* OOBrain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOBrain.m; sourceTree = "<group>"; };
|
083DB4D40A70E51E00B419B2 /* OOBrain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOBrain.m; sourceTree = "<group>"; };
|
||||||
0865432206B8447D000CA0AB /* Oolite.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Oolite.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
0865432206B8447D000CA0AB /* OoliteDev.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OoliteDev.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
0878FD2F086EF845004CB752 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
|
0878FD2F086EF845004CB752 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
|
||||||
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
|
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
|
||||||
1A23154E0B9C778400EF0852 /* solar.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = solar.png; sourceTree = "<group>"; };
|
1A23154E0B9C778400EF0852 /* solar.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = solar.png; sourceTree = "<group>"; };
|
||||||
@ -1194,7 +1194,7 @@
|
|||||||
19C28FACFE9D520D11CA2CBB /* Products */ = {
|
19C28FACFE9D520D11CA2CBB /* Products */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
0865432206B8447D000CA0AB /* Oolite.app */,
|
0865432206B8447D000CA0AB /* OoliteDev.app */,
|
||||||
);
|
);
|
||||||
name = Products;
|
name = Products;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -1987,7 +1987,7 @@
|
|||||||
name = Oolite;
|
name = Oolite;
|
||||||
productInstallPath = "$(HOME)/Applications";
|
productInstallPath = "$(HOME)/Applications";
|
||||||
productName = Oolite;
|
productName = Oolite;
|
||||||
productReference = 0865432206B8447D000CA0AB /* Oolite.app */;
|
productReference = 0865432206B8447D000CA0AB /* OoliteDev.app */;
|
||||||
productType = "com.apple.product-type.application";
|
productType = "com.apple.product-type.application";
|
||||||
};
|
};
|
||||||
/* End PBXNativeTarget section */
|
/* End PBXNativeTarget section */
|
||||||
|
@ -124,6 +124,9 @@ mesh.load.error.tooManyVertices = inherit;
|
|||||||
mesh.load.error.tooManyFaces = inherit;
|
mesh.load.error.tooManyFaces = inherit;
|
||||||
|
|
||||||
|
|
||||||
|
oxp.versionMismatch = $error;
|
||||||
|
|
||||||
|
|
||||||
$plistError = $error;
|
$plistError = $error;
|
||||||
plist.parse.foundation.failed = $plistError;
|
plist.parse.foundation.failed = $plistError;
|
||||||
plist.wrongType = $plistError;
|
plist.wrongType = $plistError;
|
||||||
@ -199,6 +202,9 @@ script.debug.syntax.addShips = inherit;
|
|||||||
script.debug.syntax.set = inherit;
|
script.debug.syntax.set = inherit;
|
||||||
script.debug.syntax.reset = inherit;
|
script.debug.syntax.reset = inherit;
|
||||||
|
|
||||||
|
script.javascript.compile.success = inherit;
|
||||||
|
script.javascript.compile.failed = $scriptError;
|
||||||
|
|
||||||
|
|
||||||
searchPaths.dumpAll = $troubleShootingDump;
|
searchPaths.dumpAll = $troubleShootingDump;
|
||||||
|
|
||||||
@ -249,3 +255,4 @@ sound.streaming.loop = $soundDebug;
|
|||||||
sound.streaming.underflow = $soundError;
|
sound.streaming.underflow = $soundError;
|
||||||
sound.virtualringbuffer = $soundError;
|
sound.virtualringbuffer = $soundError;
|
||||||
sound.streaming.releaseContext = $soundDebug;
|
sound.streaming.releaseContext = $soundDebug;
|
||||||
|
sound.invalidBeep = inherit;
|
||||||
|
@ -68,7 +68,7 @@ static NSString * const kOOLogGrooliteDebug = @"growl.debug";
|
|||||||
NSString *displayString;
|
NSString *displayString;
|
||||||
|
|
||||||
universe = [gameController universe];
|
universe = [gameController universe];
|
||||||
player = (PlayerEntity *)[universe entityZero];
|
player = [PlayerEntity sharedPlayer];
|
||||||
|
|
||||||
if (!inTitle)
|
if (!inTitle)
|
||||||
return; // catch blank messages
|
return; // catch blank messages
|
||||||
|
@ -49,8 +49,6 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
|||||||
|
|
||||||
- (id) initWithFrame:(NSRect)frameRect
|
- (id) initWithFrame:(NSRect)frameRect
|
||||||
{
|
{
|
||||||
//NSLog(@"-- initWithFrame MyOpenGLView");
|
|
||||||
|
|
||||||
// Pixel Format Attributes for the View-based (non-FullScreen) NSOpenGLContext
|
// Pixel Format Attributes for the View-based (non-FullScreen) NSOpenGLContext
|
||||||
NSOpenGLPixelFormatAttribute attrs[] = {
|
NSOpenGLPixelFormatAttribute attrs[] = {
|
||||||
|
|
||||||
@ -85,7 +83,6 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
|||||||
// Just as a diagnostic, report the renderer ID that this pixel format binds to. CGLRenderers.h contains a list of known renderers
|
// Just as a diagnostic, report the renderer ID that this pixel format binds to. CGLRenderers.h contains a list of known renderers
|
||||||
// and their corresponding RendererID codes.
|
// and their corresponding RendererID codes.
|
||||||
[pixelFormat getValues:&rendererID forAttribute:NSOpenGLPFARendererID forVirtualScreen:0];
|
[pixelFormat getValues:&rendererID forAttribute:NSOpenGLPFARendererID forVirtualScreen:0];
|
||||||
//NSLog(@" init! NSOpenGLView pixelFormat RendererID = %08x", (unsigned)rendererID);
|
|
||||||
|
|
||||||
self = [super initWithFrame:frameRect pixelFormat:pixelFormat];
|
self = [super initWithFrame:frameRect pixelFormat:pixelFormat];
|
||||||
|
|
||||||
@ -137,7 +134,6 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
|||||||
|
|
||||||
- (void) setTypedString:(NSString*) value
|
- (void) setTypedString:(NSString*) value
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG setTypedString:%@",value);
|
|
||||||
[typedString setString:value];
|
[typedString setString:value];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,8 +167,6 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
|||||||
{
|
{
|
||||||
m_glContextInitialized = NO;
|
m_glContextInitialized = NO;
|
||||||
viewSize = [self frame].size;
|
viewSize = [self frame].size;
|
||||||
|
|
||||||
//NSLog(@"DEBUG resized to %.0f x %.0f", viewSize.width, viewSize.height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_glContextInitialized)
|
if (!m_glContextInitialized)
|
||||||
@ -300,7 +294,7 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
|||||||
|
|
||||||
NSString *pathToPng = [[pathToPic stringByDeletingPathExtension] stringByAppendingPathExtension:@"png"];
|
NSString *pathToPng = [[pathToPic stringByDeletingPathExtension] stringByAppendingPathExtension:@"png"];
|
||||||
|
|
||||||
NSLog(@">>>>> Snapshot %d x %d file path chosen = %@", w, h, pathToPic);
|
NSLog(@"snapshot", @">>>>> Snapshot %d x %d file path chosen = %@", w, h, pathToPic);
|
||||||
|
|
||||||
NSBitmapImageRep* bitmapRep =
|
NSBitmapImageRep* bitmapRep =
|
||||||
[[NSBitmapImageRep alloc]
|
[[NSBitmapImageRep alloc]
|
||||||
@ -403,7 +397,6 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
|||||||
isAlphabetKeyDown = YES;
|
isAlphabetKeyDown = YES;
|
||||||
// convert to lowercase
|
// convert to lowercase
|
||||||
[typedString appendFormat:@"%c", (key | 64)];
|
[typedString appendFormat:@"%c", (key | 64)];
|
||||||
//NSLog(@"accumulated string '%@'",typedString);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
isAlphabetKeyDown = NO;
|
isAlphabetKeyDown = NO;
|
||||||
@ -423,7 +416,6 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
|||||||
isAlphabetKeyDown = YES;
|
isAlphabetKeyDown = YES;
|
||||||
// convert to lowercase
|
// convert to lowercase
|
||||||
[typedString appendFormat:@"%c", key];
|
[typedString appendFormat:@"%c", key];
|
||||||
//NSLog(@"accumulated string '%@'",typedString);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
isAlphabetKeyDown = NO;
|
isAlphabetKeyDown = NO;
|
||||||
@ -473,8 +465,6 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
|||||||
{
|
{
|
||||||
doubleClick = (timeBetweenClicks < MOUSE_DOUBLE_CLICK_INTERVAL); // One fifth of a second
|
doubleClick = (timeBetweenClicks < MOUSE_DOUBLE_CLICK_INTERVAL); // One fifth of a second
|
||||||
keys[gvMouseDoubleClick] = doubleClick;
|
keys[gvMouseDoubleClick] = doubleClick;
|
||||||
// if (doubleClick)
|
|
||||||
// NSLog(@"DEBUG registering a double-click!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
keys[gvMouseLeftButton] = NO; // 'a' up
|
keys[gvMouseLeftButton] = NO; // 'a' up
|
||||||
|
@ -26,10 +26,6 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
#ifndef HAVE_SOUND
|
|
||||||
#define HAVE_SOUND
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
@interface OOSound: NSObject
|
@interface OOSound: NSObject
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ extern NSLock *gOOCASoundSyncLock;
|
|||||||
extern NSString * const kOOLogDeprecatedMethodOOCASound;
|
extern NSString * const kOOLogDeprecatedMethodOOCASound;
|
||||||
extern NSString * const kOOLogSoundInitError;
|
extern NSString * const kOOLogSoundInitError;
|
||||||
|
|
||||||
#define kOOLogUnconvertedNSLog @"unclassified.sound"
|
#define kOOLogUnconvertedNSLog @"unclassified.OOCASound"
|
||||||
|
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
|
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include <mach/mach_error.h>
|
#include <mach/mach_error.h>
|
||||||
|
|
||||||
|
|
||||||
#define kOOLogUnconvertedNSLog @"sound.virtualringbuffer"
|
#define kOOLogUnconvertedNSLog @"unclassified.VirtualRingBuffer"
|
||||||
|
|
||||||
|
|
||||||
@implementation VirtualRingBuffer
|
@implementation VirtualRingBuffer
|
||||||
|
@ -29,6 +29,8 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
#import "ShipEntity.h"
|
#import "ShipEntity.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.AI"
|
||||||
|
|
||||||
|
|
||||||
static NSString * const kOOLogAIReceiveMessage = @"ai.message.receive";
|
static NSString * const kOOLogAIReceiveMessage = @"ai.message.receive";
|
||||||
static NSString * const kOOLogAITakeAction = @"ai.takeAction.takeAction";
|
static NSString * const kOOLogAITakeAction = @"ai.takeAction.takeAction";
|
||||||
|
@ -31,6 +31,8 @@ MA 02110-1301, USA.
|
|||||||
#import "StationEntity.h"
|
#import "StationEntity.h"
|
||||||
#import "PlayerEntity.h"
|
#import "PlayerEntity.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.CollisionRegion"
|
||||||
|
|
||||||
|
|
||||||
@implementation CollisionRegion
|
@implementation CollisionRegion
|
||||||
|
|
||||||
|
@ -50,8 +50,7 @@ MA 02110-1301, USA.
|
|||||||
vertices[vi].y = (ranrot_rand() % DUST_SCALE) - DUST_SCALE / 2;
|
vertices[vi].y = (ranrot_rand() % DUST_SCALE) - DUST_SCALE / 2;
|
||||||
vertices[vi].z = (ranrot_rand() % DUST_SCALE) - DUST_SCALE / 2;
|
vertices[vi].z = (ranrot_rand() % DUST_SCALE) - DUST_SCALE / 2;
|
||||||
}
|
}
|
||||||
//NSLog(@"DustEntity vertices set");
|
|
||||||
//
|
|
||||||
dust_color = [[OOColor colorWithCalibratedRed:0.5 green:1.0 blue:1.0 alpha:1.0] retain];
|
dust_color = [[OOColor colorWithCalibratedRed:0.5 green:1.0 blue:1.0 alpha:1.0] retain];
|
||||||
//
|
//
|
||||||
displayListName = 0;
|
displayListName = 0;
|
||||||
@ -86,7 +85,7 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
- (void) update:(double) delta_t
|
- (void) update:(double) delta_t
|
||||||
{
|
{
|
||||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||||
if (!player) return; // DON'T UPDATE
|
if (!player) return; // DON'T UPDATE
|
||||||
// do nowt!
|
// do nowt!
|
||||||
zero_distance = 0.0;
|
zero_distance = 0.0;
|
||||||
@ -116,7 +115,7 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
- (void) drawEntity:(BOOL) immediate :(BOOL) translucent
|
- (void) drawEntity:(BOOL) immediate :(BOOL) translucent
|
||||||
{
|
{
|
||||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||||
if (!player)
|
if (!player)
|
||||||
return; // DON'T DRAW
|
return; // DON'T DRAW
|
||||||
//
|
//
|
||||||
|
@ -23,6 +23,7 @@ MA 02110-1301, USA.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#import "Entity.h"
|
#import "Entity.h"
|
||||||
|
#import "PlayerEntity.h"
|
||||||
|
|
||||||
#import "OOMaths.h"
|
#import "OOMaths.h"
|
||||||
#import "Geometry.h"
|
#import "Geometry.h"
|
||||||
@ -35,6 +36,8 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
#import "NSScannerOOExtensions.h"
|
#import "NSScannerOOExtensions.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.Entity"
|
||||||
|
|
||||||
|
|
||||||
static NSString * const kOOLogEntityAddToList = @"entity.linkedList.add";
|
static NSString * const kOOLogEntityAddToList = @"entity.linkedList.add";
|
||||||
static NSString * const kOOLogEntityAddToListError = @"entity.linkedList.add.error";
|
static NSString * const kOOLogEntityAddToListError = @"entity.linkedList.add.error";
|
||||||
@ -515,8 +518,7 @@ BOOL global_testForVAR;
|
|||||||
//
|
//
|
||||||
collision_radius = [self findCollisionRadius];
|
collision_radius = [self findCollisionRadius];
|
||||||
actual_radius = collision_radius;
|
actual_radius = collision_radius;
|
||||||
//NSLog(@"Entity with model '%@' collision radius set to %f",modelName, collision_radius);
|
|
||||||
//
|
|
||||||
[mypool release];
|
[mypool release];
|
||||||
}
|
}
|
||||||
- (NSString *) getModel
|
- (NSString *) getModel
|
||||||
@ -540,7 +542,6 @@ BOOL global_testForVAR;
|
|||||||
|
|
||||||
- (double) getZeroDistance
|
- (double) getZeroDistance
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG %@ %.1f", self, zero_distance);
|
|
||||||
return zero_distance;
|
return zero_distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -821,7 +822,6 @@ BOOL global_testForVAR;
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
OOLog(kOOLogFileNotLoaded, @"ERROR no basefile for entity %@");
|
OOLog(kOOLogFileNotLoaded, @"ERROR no basefile for entity %@");
|
||||||
// NSBeep(); // appkit dependency
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glShadeModel(GL_SMOOTH);
|
glShadeModel(GL_SMOOTH);
|
||||||
@ -850,7 +850,6 @@ BOOL global_testForVAR;
|
|||||||
zero_distance = my_owner->zero_distance;
|
zero_distance = my_owner->zero_distance;
|
||||||
if (zero_distance > no_draw_distance)
|
if (zero_distance > no_draw_distance)
|
||||||
{
|
{
|
||||||
//NSLog(@"DEBUG - sub entity '%@' too far away to draw", self);
|
|
||||||
return; // TOO FAR AWAY
|
return; // TOO FAR AWAY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -896,8 +895,6 @@ BOOL global_testForVAR;
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
int fi;
|
int fi;
|
||||||
|
|
||||||
//NSLog(@"Entity::reloadTextures called on [%@]", [self description]);
|
|
||||||
|
|
||||||
// Force the entity to reload the textures for each face by clearing the face's texture name.
|
// Force the entity to reload the textures for each face by clearing the face's texture name.
|
||||||
for (fi = 0; fi < n_faces; fi++)
|
for (fi = 0; fi < n_faces; fi++)
|
||||||
faces[fi].texName = 0;
|
faces[fi].texName = 0;
|
||||||
@ -931,7 +928,6 @@ BOOL global_testForVAR;
|
|||||||
if (!texture_name[ti])
|
if (!texture_name[ti])
|
||||||
{
|
{
|
||||||
texture_name[ti] = [TextureStore getTextureNameFor: [NSString stringWithUTF8String: (char*)texture_file[ti]]];
|
texture_name[ti] = [TextureStore getTextureNameFor: [NSString stringWithUTF8String: (char*)texture_file[ti]]];
|
||||||
// NSLog(@"DEBUG (initialiseTextures) Processed textureFile : %@ to texName : %d", entityData[ti].textureFile, entityData[ti].texName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -958,7 +954,7 @@ BOOL global_testForVAR;
|
|||||||
|
|
||||||
- (void) update:(double) delta_t
|
- (void) update:(double) delta_t
|
||||||
{
|
{
|
||||||
Entity* player = [universe entityZero];
|
PlayerEntity *player = [PlayerEntity sharedPlayer];
|
||||||
if (player)
|
if (player)
|
||||||
{
|
{
|
||||||
if (status != STATUS_COCKPIT_DISPLAY)
|
if (status != STATUS_COCKPIT_DISPLAY)
|
||||||
@ -1011,8 +1007,6 @@ BOOL global_testForVAR;
|
|||||||
//
|
//
|
||||||
- (void) resetFramesFromFrame:(Frame) resetFrame withVelocity:(Vector) vel1
|
- (void) resetFramesFromFrame:(Frame) resetFrame withVelocity:(Vector) vel1
|
||||||
{
|
{
|
||||||
// if (isPlayer) NSLog(@"DEBUG ** resetting track for %@ **", self);
|
|
||||||
|
|
||||||
Vector v1 = make_vector( 0.1 * vel1.x, 0.1 * vel1.y, 0.1 * vel1.z);
|
Vector v1 = make_vector( 0.1 * vel1.x, 0.1 * vel1.y, 0.1 * vel1.z);
|
||||||
double t_now = [universe getTime];
|
double t_now = [universe getTime];
|
||||||
Vector pos = resetFrame.position;
|
Vector pos = resetFrame.position;
|
||||||
@ -1118,8 +1112,7 @@ BOOL global_testForVAR;
|
|||||||
double period = (moment_in_time - t_frame) - track_time;
|
double period = (moment_in_time - t_frame) - track_time;
|
||||||
double f1 = -t_frame/period;
|
double f1 = -t_frame/period;
|
||||||
double f0 = 1.0 - f1;
|
double f0 = 1.0 - f1;
|
||||||
// NSLog(@"DEBUG m-i-t:%.3f track_time:%.3f t_frame:%.3f period:%.3f f0:f1 %.3f:%.3f",
|
|
||||||
// moment_in_time, track_time, t_frame, period, f0, f1);
|
|
||||||
Vector posn;
|
Vector posn;
|
||||||
posn.x = f0 * result.position.x + f1 * fr1.position.x;
|
posn.x = f0 * result.position.x + f1 * fr1.position.x;
|
||||||
posn.y = f0 * result.position.y + f1 * fr1.position.y;
|
posn.y = f0 * result.position.y + f1 * fr1.position.y;
|
||||||
@ -1149,8 +1142,7 @@ BOOL global_testForVAR;
|
|||||||
double period = track[t0].timeframe - track[t1].timeframe;
|
double period = track[t0].timeframe - track[t1].timeframe;
|
||||||
double f0 = (moment_in_time - track[t1].timeframe)/period;
|
double f0 = (moment_in_time - track[t1].timeframe)/period;
|
||||||
double f1 = 1.0 - f0;
|
double f1 = 1.0 - f0;
|
||||||
// NSLog(@"DEBUG m-i-t:%.3f t0.timeframe:%.3f t1.timeframe:%.3f period:%.3f f0:f1 %.3f:%.3f",
|
|
||||||
// moment_in_time, track[t0].timeframe, track[t1].timeframe, period, f0, f1);
|
|
||||||
Vector posn;
|
Vector posn;
|
||||||
posn.x = f0 * track[t0].position.x + f1 * track[t1].position.x;
|
posn.x = f0 * track[t0].position.x + f1 * track[t1].position.x;
|
||||||
posn.y = f0 * track[t0].position.y + f1 * track[t1].position.y;
|
posn.y = f0 * track[t0].position.y + f1 * track[t1].position.y;
|
||||||
@ -1264,8 +1256,6 @@ BOOL global_testForVAR;
|
|||||||
}
|
}
|
||||||
data = [lines componentsJoinedByString:@"\n"];
|
data = [lines componentsJoinedByString:@"\n"];
|
||||||
|
|
||||||
//NSLog(@"More data:\n%@",data);
|
|
||||||
|
|
||||||
scanner = [NSScanner scannerWithString:data];
|
scanner = [NSScanner scannerWithString:data];
|
||||||
|
|
||||||
// get number of vertices
|
// get number of vertices
|
||||||
@ -1470,7 +1460,6 @@ BOOL global_testForVAR;
|
|||||||
{
|
{
|
||||||
// faces[j].textureFile = [texfile retain];
|
// faces[j].textureFile = [texfile retain];
|
||||||
strlcpy( (char*)faces[j].textureFileStr255, [texfile UTF8String], 256);
|
strlcpy( (char*)faces[j].textureFileStr255, [texfile UTF8String], 256);
|
||||||
// NSLog(@"DEBUG TEST strlcpy of '%@' result = '%s'", texfile, faces[j].textureFileStr255);
|
|
||||||
}
|
}
|
||||||
faces[j].texName = 0;
|
faces[j].texName = 0;
|
||||||
|
|
||||||
@ -1521,19 +1510,13 @@ BOOL global_testForVAR;
|
|||||||
|
|
||||||
if ((failFlag)&&([failString rangeOfString:@"TEXTURES"].location != NSNotFound))
|
if ((failFlag)&&([failString rangeOfString:@"TEXTURES"].location != NSNotFound))
|
||||||
{
|
{
|
||||||
//NSLog(@"Off to make new textures!");
|
|
||||||
[self fakeTexturesWithImageFile:@"metal.png" andMaxSize:NSMakeSize(256.0,256.0)];
|
[self fakeTexturesWithImageFile:@"metal.png" andMaxSize:NSMakeSize(256.0,256.0)];
|
||||||
|
|
||||||
// dump out data for ships with faked textures
|
|
||||||
//if (isShip)
|
|
||||||
// //NSLog(@"Faked Texture coordinates for this model :\n\n%@\n\n", [self toString]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (failFlag)
|
if (failFlag)
|
||||||
NSLog([NSString stringWithFormat:@"%@ ..... from %@ %@", failString, filename, (using_preloaded)? @"(from preloaded data)" : @"(from file)"]);
|
NSLog([NSString stringWithFormat:@"%@ ..... from %@ %@", failString, filename, (using_preloaded)? @"(from preloaded data)" : @"(from file)"]);
|
||||||
|
|
||||||
// check for smooth chading and recalculate normals
|
// check for smooth shading and recalculate normals
|
||||||
//
|
|
||||||
if (is_smooth_shaded)
|
if (is_smooth_shaded)
|
||||||
[self calculateVertexNormals];
|
[self calculateVertexNormals];
|
||||||
//
|
//
|
||||||
@ -1560,6 +1543,8 @@ BOOL global_testForVAR;
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FIXME: this isn't working, we're getting smoothed models with inside-out winding. --ahruman
|
||||||
- (void) checkNormalsAndAdjustWinding
|
- (void) checkNormalsAndAdjustWinding
|
||||||
{
|
{
|
||||||
Vector calculatedNormal;
|
Vector calculatedNormal;
|
||||||
@ -1574,7 +1559,6 @@ BOOL global_testForVAR;
|
|||||||
calculatedNormal = normal_to_surface (v2, v1, v0);
|
calculatedNormal = normal_to_surface (v2, v1, v0);
|
||||||
if ((norm.x == 0.0)&&(norm.y == 0.0)&&(norm.z == 0.0))
|
if ((norm.x == 0.0)&&(norm.y == 0.0)&&(norm.z == 0.0))
|
||||||
{
|
{
|
||||||
//NSLog(@"Using calculated normal for face %d", i);
|
|
||||||
faces[i].normal = normal_to_surface (v0, v1, v2);
|
faces[i].normal = normal_to_surface (v0, v1, v2);
|
||||||
norm = normal_to_surface (v0, v1, v2);
|
norm = normal_to_surface (v0, v1, v2);
|
||||||
}
|
}
|
||||||
@ -1586,10 +1570,6 @@ BOOL global_testForVAR;
|
|||||||
GLfloat s[faces[i].n_verts];
|
GLfloat s[faces[i].n_verts];
|
||||||
GLfloat t[faces[i].n_verts];
|
GLfloat t[faces[i].n_verts];
|
||||||
|
|
||||||
//
|
|
||||||
//NSLog(@"Normal pointing the wrong way for winding on face %d", i);
|
|
||||||
//
|
|
||||||
|
|
||||||
for (j = 0; j < faces[i].n_verts; j++)
|
for (j = 0; j < faces[i].n_verts; j++)
|
||||||
{
|
{
|
||||||
v[j] = faces[i].vertex[faces[i].n_verts - 1 - j];
|
v[j] = faces[i].vertex[faces[i].n_verts - 1 - j];
|
||||||
@ -1745,9 +1725,6 @@ BOOL global_testForVAR;
|
|||||||
}
|
}
|
||||||
triangle_range[texi].length = tri_index - triangle_range[texi].location;
|
triangle_range[texi].length = tri_index - triangle_range[texi].location;
|
||||||
|
|
||||||
// NSLog(@"DEBUG processing %@ texture %@ texName %d triangles %d to %d",
|
|
||||||
// basefile, texture_file[texi], texture_name[texi], triangle_range[texi].location, triangle_range[texi].location + triangle_range[texi].length);
|
|
||||||
|
|
||||||
//finally...
|
//finally...
|
||||||
[texturesProcessed setObject:tex_string forKey:tex_string]; // note this texture done
|
[texturesProcessed setObject:tex_string forKey:tex_string]; // note this texture done
|
||||||
texi++;
|
texi++;
|
||||||
@ -1832,7 +1809,6 @@ BOOL global_testForVAR;
|
|||||||
|
|
||||||
- (BoundingBox) findBoundingBoxRelativeToPosition:(Vector)opv InVectors:(Vector) _i :(Vector) _j :(Vector) _k
|
- (BoundingBox) findBoundingBoxRelativeToPosition:(Vector)opv InVectors:(Vector) _i :(Vector) _j :(Vector) _k
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG ** DEPRECATED [Entity findBoundingBoxRelativeToPosition:(Vector)opv InVectors:(Vector) _i :(Vector) _j :(Vector) _k] CALLED **");
|
|
||||||
|
|
||||||
Vector pv, rv;
|
Vector pv, rv;
|
||||||
Vector rpos = position;
|
Vector rpos = position;
|
||||||
@ -1882,9 +1858,7 @@ BOOL global_testForVAR;
|
|||||||
result = [NSString stringWithFormat:@"%@\n", result];
|
result = [NSString stringWithFormat:@"%@\n", result];
|
||||||
}
|
}
|
||||||
result = [NSString stringWithFormat:@"%@\nFACES\n", result];
|
result = [NSString stringWithFormat:@"%@\nFACES\n", result];
|
||||||
//
|
|
||||||
//NSLog(result);
|
|
||||||
//
|
|
||||||
for (j = 0; j < n_faces; j++)
|
for (j = 0; j < n_faces; j++)
|
||||||
{
|
{
|
||||||
r = (int)(faces[j].red * 255.0); g = (int)(faces[j].green * 255.0); b = (int)(faces[j].blue * 255.0);
|
r = (int)(faces[j].red * 255.0); g = (int)(faces[j].green * 255.0); b = (int)(faces[j].blue * 255.0);
|
||||||
@ -1970,15 +1944,11 @@ BOOL global_testForVAR;
|
|||||||
//
|
//
|
||||||
st_width = max_s - min_s;
|
st_width = max_s - min_s;
|
||||||
st_height = max_t - min_t;
|
st_height = max_t - min_t;
|
||||||
//
|
|
||||||
//NSLog(@"TOP st_width %f st_height %f maxSize.height %f maxSize.width %f", st_width, st_height, maxSize.width, maxSize.height);
|
|
||||||
//
|
|
||||||
for (j = 0; j < nf; j++)
|
for (j = 0; j < nf; j++)
|
||||||
{
|
{
|
||||||
i = fi[j];
|
i = fi[j];
|
||||||
//fa[i] = faces[i];
|
|
||||||
// fa[i].textureFile = [NSString stringWithFormat:@"top_%@", textureFile];
|
|
||||||
// strlcpy( (char*)fa[i].textureFileStr255, [fa[i].textureFile UTF8String], 256);
|
|
||||||
strlcpy( (char*)fa[i].textureFileStr255, [[NSString stringWithFormat:@"top_%@", textureFile] UTF8String], 256);
|
strlcpy( (char*)fa[i].textureFileStr255, [[NSString stringWithFormat:@"top_%@", textureFile] UTF8String], 256);
|
||||||
for (k = 0; k < faces[i].n_verts; k++)
|
for (k = 0; k < faces[i].n_verts; k++)
|
||||||
{
|
{
|
||||||
@ -1991,9 +1961,6 @@ BOOL global_testForVAR;
|
|||||||
// TESTING
|
// TESTING
|
||||||
//
|
//
|
||||||
fa[i].t[k] = maxSize.height - fa[i].t[k]; // REVERSE t locations
|
fa[i].t[k] = maxSize.height - fa[i].t[k]; // REVERSE t locations
|
||||||
//
|
|
||||||
//NSLog(@"%f, %f", fa[i].s[k], fa[i].t[k]);
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2211,26 +2178,21 @@ BOOL global_testForVAR;
|
|||||||
fa[i].t[k] = (t - min_t) * maxSize.height / st_height;
|
fa[i].t[k] = (t - min_t) * maxSize.height / st_height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//NSLog(@"%d / %d faces matched at tolerance: %f", n_faces - faces_to_match, n_faces, tolerance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n_faces; i++)
|
for (i = 0; i < n_faces; i++)
|
||||||
{
|
{
|
||||||
NSString *result;
|
NSString *result;
|
||||||
// faces[i].textureFile = [fa[i].textureFile retain];
|
|
||||||
strlcpy( (char*)faces[i].textureFileStr255, (char*)fa[i].textureFileStr255, 256);
|
strlcpy( (char*)faces[i].textureFileStr255, (char*)fa[i].textureFileStr255, 256);
|
||||||
faces[i].texName = 0;
|
faces[i].texName = 0;
|
||||||
for (j = 0; j < faces[i].n_verts; j++)
|
for (j = 0; j < faces[i].n_verts; j++)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
//NSLog(@"face[%d] %f, %f", i, fa[i].s[j], fa[i].t[j]);
|
|
||||||
//
|
|
||||||
faces[i].s[j] = fa[i].s[j] / maxSize.width;
|
faces[i].s[j] = fa[i].s[j] / maxSize.width;
|
||||||
faces[i].t[j] = fa[i].t[j] / maxSize.height;
|
faces[i].t[j] = fa[i].t[j] / maxSize.height;
|
||||||
}
|
}
|
||||||
// result = [NSString stringWithFormat:@"%@\t%d %d", faces[i].textureFile, (int)maxSize.width, (int)maxSize.height];
|
|
||||||
result = [NSString stringWithFormat:@"%s\t%d %d", faces[i].textureFileStr255, (int)maxSize.width, (int)maxSize.height];
|
result = [NSString stringWithFormat:@"%s\t%d %d", faces[i].textureFileStr255, (int)maxSize.width, (int)maxSize.height];
|
||||||
//NSLog(@"face[%d] : %@", i, result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,16 +31,17 @@ MA 02110-1301, USA.
|
|||||||
#import "OOOpenGL.h"
|
#import "OOOpenGL.h"
|
||||||
#import "PlayerEntity.h"
|
#import "PlayerEntity.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.GameController"
|
||||||
|
|
||||||
|
|
||||||
@implementation GameController
|
@implementation GameController
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
//
|
|
||||||
//NSLog(@"--- init GameController");
|
last_timeInterval = [NSDate timeIntervalSinceReferenceDate];
|
||||||
//
|
delta_t = 0.01; // one hundredth of a second
|
||||||
last_timeInterval = [NSDate timeIntervalSinceReferenceDate];
|
|
||||||
delta_t = 0.01; // one hundredth of a second
|
|
||||||
//
|
//
|
||||||
my_mouse_x = my_mouse_y = 0;
|
my_mouse_x = my_mouse_y = 0;
|
||||||
//
|
//
|
||||||
@ -49,13 +50,10 @@ MA 02110-1301, USA.
|
|||||||
expansionPathsToInclude = nil;
|
expansionPathsToInclude = nil;
|
||||||
pauseSelector = (SEL)nil;
|
pauseSelector = (SEL)nil;
|
||||||
pauseTarget = nil;
|
pauseTarget = nil;
|
||||||
//
|
|
||||||
game_is_paused = NO;
|
game_is_paused = NO;
|
||||||
|
|
||||||
//
|
|
||||||
debug = 0;
|
debug = 0;
|
||||||
// debug = DEBUG_COLLISIONS;
|
|
||||||
//
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,14 +63,14 @@ MA 02110-1301, USA.
|
|||||||
[[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:universe];
|
[[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:universe];
|
||||||
#endif
|
#endif
|
||||||
//
|
//
|
||||||
if (timer) [timer release];
|
[timer release];
|
||||||
if (gameView) [gameView release];
|
[gameView release];
|
||||||
if (universe) [universe release];
|
[universe release];
|
||||||
//
|
|
||||||
if (playerFileToLoad) [playerFileToLoad release];
|
[playerFileToLoad release];
|
||||||
if (playerFileDirectory) [playerFileDirectory release];
|
[playerFileDirectory release];
|
||||||
if (expansionPathsToInclude) [expansionPathsToInclude release];
|
[expansionPathsToInclude release];
|
||||||
//
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +94,6 @@ MA 02110-1301, USA.
|
|||||||
NSDictionary *d_mode = [self findDisplayModeForWidth: d_width Height: d_height Refresh: d_refresh];
|
NSDictionary *d_mode = [self findDisplayModeForWidth: d_width Height: d_height Refresh: d_refresh];
|
||||||
if (d_mode)
|
if (d_mode)
|
||||||
{
|
{
|
||||||
// do stuff
|
|
||||||
width = d_width;
|
width = d_width;
|
||||||
height = d_height;
|
height = d_height;
|
||||||
refresh = d_refresh;
|
refresh = d_refresh;
|
||||||
@ -121,8 +118,6 @@ MA 02110-1301, USA.
|
|||||||
{
|
{
|
||||||
NSDictionary *mode;
|
NSDictionary *mode;
|
||||||
|
|
||||||
//NSLog(@"looking for a display mode that's %d x %d %dHz",width, height, refresh);
|
|
||||||
|
|
||||||
mode = [self findDisplayModeForWidth: width Height: height Refresh: refresh];
|
mode = [self findDisplayModeForWidth: width Height: height Refresh: refresh];
|
||||||
if (mode == nil)
|
if (mode == nil)
|
||||||
return NSNotFound;
|
return NSNotFound;
|
||||||
@ -149,7 +144,6 @@ MA 02110-1301, USA.
|
|||||||
modeRefresh = [[mode objectForKey: (NSString *)kCGDisplayRefreshRate] intValue];
|
modeRefresh = [[mode objectForKey: (NSString *)kCGDisplayRefreshRate] intValue];
|
||||||
if ((modeWidth == d_width)&&(modeHeight == d_height)&&(modeRefresh == d_refresh))
|
if ((modeWidth == d_width)&&(modeHeight == d_height)&&(modeRefresh == d_refresh))
|
||||||
{
|
{
|
||||||
// NSLog(@"Found mode %@", mode);
|
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -256,8 +250,7 @@ static int _compareModes(id arg1, id arg2, void *context)
|
|||||||
|
|
||||||
// Fill the popup with the resulting modes
|
// Fill the popup with the resulting modes
|
||||||
modeCount = [displayModes count];
|
modeCount = [displayModes count];
|
||||||
|
|
||||||
//NSLog(@"displayModes = %@", displayModes);
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < modeCount; i++)
|
for (i = 0; i < modeCount; i++)
|
||||||
{
|
{
|
||||||
@ -265,7 +258,6 @@ static int _compareModes(id arg1, id arg2, void *context)
|
|||||||
modeWidth = [[mode objectForKey: (NSString *)kCGDisplayWidth] intValue];
|
modeWidth = [[mode objectForKey: (NSString *)kCGDisplayWidth] intValue];
|
||||||
modeHeight = [[mode objectForKey: (NSString *)kCGDisplayHeight] intValue];
|
modeHeight = [[mode objectForKey: (NSString *)kCGDisplayHeight] intValue];
|
||||||
modeRefresh = [[mode objectForKey: (NSString *)kCGDisplayRefreshRate] intValue];
|
modeRefresh = [[mode objectForKey: (NSString *)kCGDisplayRefreshRate] intValue];
|
||||||
//NSLog(@"()=> %d x %d at %dHz", modeWidth, modeHeight, modeRefresh);
|
|
||||||
}
|
}
|
||||||
#else // ifndef GNUSTEP
|
#else // ifndef GNUSTEP
|
||||||
// SDL code all lives in the gameview.
|
// SDL code all lives in the gameview.
|
||||||
@ -378,9 +370,7 @@ static int _compareModes(id arg1, id arg2, void *context)
|
|||||||
width = 640; // standard screen is 640x480 pixels, 32 bit color, 32 bit z-buffer, refresh rate 75Hz
|
width = 640; // standard screen is 640x480 pixels, 32 bit color, 32 bit z-buffer, refresh rate 75Hz
|
||||||
height = 480;
|
height = 480;
|
||||||
refresh = 75;
|
refresh = 75;
|
||||||
//
|
|
||||||
//NSLog(@"--- loading userdefaults");
|
|
||||||
//
|
|
||||||
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
||||||
//
|
//
|
||||||
if ([userDefaults objectForKey:@"display_width"])
|
if ([userDefaults objectForKey:@"display_width"])
|
||||||
@ -447,7 +437,7 @@ static int _compareModes(id arg1, id arg2, void *context)
|
|||||||
{
|
{
|
||||||
if (playerFileToLoad)
|
if (playerFileToLoad)
|
||||||
{
|
{
|
||||||
PlayerEntity *player = [universe entityZero];
|
PlayerEntity *player = [PlayerEntity sharedPlayer];
|
||||||
[player loadPlayerFromFile:playerFileToLoad];
|
[player loadPlayerFromFile:playerFileToLoad];
|
||||||
[player setStatus:STATUS_DOCKED];
|
[player setStatus:STATUS_DOCKED];
|
||||||
[player setGuiToStatusScreen];
|
[player setGuiToStatusScreen];
|
||||||
@ -465,10 +455,9 @@ static int _compareModes(id arg1, id arg2, void *context)
|
|||||||
|
|
||||||
- (void) logProgress:(NSString*) message
|
- (void) logProgress:(NSString*) message
|
||||||
{
|
{
|
||||||
// NSLog(@"progress: %@", message);
|
|
||||||
#ifndef GNUSTEP
|
#ifndef GNUSTEP
|
||||||
[splashProgressTextField setStringValue:message];
|
[splashProgressTextField setStringValue:message];
|
||||||
[splashProgressTextField display]; // **thanks Jens Ayton **
|
[splashProgressTextField display];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -585,7 +574,6 @@ static int _compareModes(id arg1, id arg2, void *context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
originalDisplayMode = (NSDictionary *)CGDisplayCurrentMode(kCGDirectMainDisplay);
|
originalDisplayMode = (NSDictionary *)CGDisplayCurrentMode(kCGDirectMainDisplay);
|
||||||
//NSLog(@"originalDisplayMode = %@", originalDisplayMode);
|
|
||||||
|
|
||||||
// Pixel Format Attributes for the FullScreen NSOpenGLContext
|
// Pixel Format Attributes for the FullScreen NSOpenGLContext
|
||||||
NSOpenGLPixelFormatAttribute attrs[] = {
|
NSOpenGLPixelFormatAttribute attrs[] = {
|
||||||
@ -620,7 +608,6 @@ static int _compareModes(id arg1, id arg2, void *context)
|
|||||||
|
|
||||||
// Just as a diagnostic, report the renderer ID that this pixel format binds to. CGLRenderers.h contains a list of known renderers and their corresponding RendererID codes.
|
// Just as a diagnostic, report the renderer ID that this pixel format binds to. CGLRenderers.h contains a list of known renderers and their corresponding RendererID codes.
|
||||||
[pixelFormat getValues:&rendererID forAttribute:NSOpenGLPFARendererID forVirtualScreen:0];
|
[pixelFormat getValues:&rendererID forAttribute:NSOpenGLPFARendererID forVirtualScreen:0];
|
||||||
//NSLog(@"FullScreen pixelFormat RendererID = %08x", (unsigned)rendererID);
|
|
||||||
|
|
||||||
// Create an NSOpenGLContext with the FullScreen pixel format. By specifying the non-FullScreen context as our "shareContext", we automatically inherit all of the textures, display lists, and other OpenGL objects it has defined.
|
// Create an NSOpenGLContext with the FullScreen pixel format. By specifying the non-FullScreen context as our "shareContext", we automatically inherit all of the textures, display lists, and other OpenGL objects it has defined.
|
||||||
fullScreenContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:[gameView openGLContext]];
|
fullScreenContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:[gameView openGLContext]];
|
||||||
@ -716,9 +703,8 @@ static int _compareModes(id arg1, id arg2, void *context)
|
|||||||
my_mouse_x += mouse_dx;
|
my_mouse_x += mouse_dx;
|
||||||
my_mouse_y += mouse_dy;
|
my_mouse_y += mouse_dy;
|
||||||
}
|
}
|
||||||
else
|
else past_first_mouse_delta =YES;
|
||||||
past_first_mouse_delta =YES;
|
|
||||||
//NSLog(@".. %d, %d ..",my_mouse_x, my_mouse_y);
|
|
||||||
[gameView setVirtualJoystick:(double)my_mouse_x/width :(double)my_mouse_y/height];
|
[gameView setVirtualJoystick:(double)my_mouse_x/width :(double)my_mouse_y/height];
|
||||||
CGDisplayMoveCursorToPoint(kCGDirectMainDisplay,centerOfScreen);
|
CGDisplayMoveCursorToPoint(kCGDirectMainDisplay,centerOfScreen);
|
||||||
break;
|
break;
|
||||||
@ -800,7 +786,6 @@ static int _compareModes(id arg1, id arg2, void *context)
|
|||||||
|
|
||||||
- (void) exitFullScreenMode
|
- (void) exitFullScreenMode
|
||||||
{
|
{
|
||||||
//NSLog(@"in gameController exitFullScreenMode");
|
|
||||||
stayInFullScreenMode = NO;
|
stayInFullScreenMode = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -840,7 +825,6 @@ static int _compareModes(id arg1, id arg2, void *context)
|
|||||||
|
|
||||||
- (void)windowDidResize:(NSNotification *)aNotification
|
- (void)windowDidResize:(NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
// NSLog(@"Mwahhahaha");
|
|
||||||
[gameView drawRect:[gameView bounds]];
|
[gameView drawRect:[gameView bounds]];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -860,7 +844,6 @@ static int _compareModes(id arg1, id arg2, void *context)
|
|||||||
[[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:&dir_test];
|
[[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:&dir_test];
|
||||||
if (dir_test)
|
if (dir_test)
|
||||||
{
|
{
|
||||||
// NSLog(@"Including expansion pack : %@", filename);
|
|
||||||
if (!expansionPathsToInclude)
|
if (!expansionPathsToInclude)
|
||||||
expansionPathsToInclude = [[NSMutableArray alloc] initWithCapacity: 4]; // retained
|
expansionPathsToInclude = [[NSMutableArray alloc] initWithCapacity: 4]; // retained
|
||||||
[expansionPathsToInclude addObject: filename];
|
[expansionPathsToInclude addObject: filename];
|
||||||
|
@ -95,7 +95,7 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
if (!new_triangles) // couldn't allocate space
|
if (!new_triangles) // couldn't allocate space
|
||||||
{
|
{
|
||||||
NSLog(@" --- ran out of memory to allocate more geometry!");
|
OOLog(kOOLogAllocationFailure, @" --- ran out of memory to allocate more geometry!");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,8 +206,6 @@ static float volumecount;
|
|||||||
//
|
//
|
||||||
NSObject* foundOctree = [self octreeWithinRadius:foundRadius toDepth:depth];
|
NSObject* foundOctree = [self octreeWithinRadius:foundRadius toDepth:depth];
|
||||||
//
|
//
|
||||||
// NSLog(@"octree found has %d leafs - object has volume %.2f mass %.2f", leafcount, volumecount, volumecount * 8.0);
|
|
||||||
//
|
|
||||||
Octree* octreeRepresentation = [[Octree alloc] initWithRepresentationOfOctree:foundRadius :foundOctree :leafcount];
|
Octree* octreeRepresentation = [[Octree alloc] initWithRepresentationOfOctree:foundRadius :foundOctree :leafcount];
|
||||||
//
|
//
|
||||||
return [octreeRepresentation autorelease];
|
return [octreeRepresentation autorelease];
|
||||||
|
@ -194,7 +194,7 @@ MA 02110-1301, USA.
|
|||||||
pixel_text_size = NSMakeSize( csize, csize);
|
pixel_text_size = NSMakeSize( csize, csize);
|
||||||
pixel_title_size = NSMakeSize( csize * 1.75, csize * 1.5);
|
pixel_title_size = NSMakeSize( csize * 1.75, csize * 1.5);
|
||||||
|
|
||||||
NSLog(@"gui %@ reset to rows:%d columns:%d start:%d", self, n_rows, n_columns, pixel_row_start);
|
OOLog(@"gui.reset", @"gui %@ reset to rows:%d columns:%d start:%d", self, n_rows, n_columns, pixel_row_start);
|
||||||
|
|
||||||
rowRange = NSMakeRange(0,n_rows);
|
rowRange = NSMakeRange(0,n_rows);
|
||||||
[self clear];
|
[self clear];
|
||||||
@ -298,11 +298,8 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
- (void) click
|
- (void) click
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SOUND
|
if ([guiclick isPlaying]) [guiclick stop];
|
||||||
if ([guiclick isPlaying])
|
|
||||||
[guiclick stop];
|
|
||||||
[guiclick play];
|
[guiclick play];
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setShowAdvancedNavArray:(BOOL)inFlag
|
- (void)setShowAdvancedNavArray:(BOOL)inFlag
|
||||||
@ -532,8 +529,6 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
- (void) printLongText: (NSString *) str Align:(int) alignment Color:(OOColor*) text_color FadeTime:(float) text_fade Key:(NSString*) text_key AddToArray:(NSMutableArray*) text_array
|
- (void) printLongText: (NSString *) str Align:(int) alignment Color:(OOColor*) text_color FadeTime:(float) text_fade Key:(NSString*) text_key AddToArray:(NSMutableArray*) text_array
|
||||||
{
|
{
|
||||||
// NSLog(@"GUI printing text '%@'", str);
|
|
||||||
|
|
||||||
// print a multi-line message
|
// print a multi-line message
|
||||||
//
|
//
|
||||||
if ([str rangeOfString:@"\n"].location != NSNotFound)
|
if ([str rangeOfString:@"\n"].location != NSNotFound)
|
||||||
@ -716,7 +711,7 @@ MA 02110-1301, USA.
|
|||||||
GLfloat z1 = [[universe gameView] display_z];
|
GLfloat z1 = [[universe gameView] display_z];
|
||||||
if (alpha > 0.05)
|
if (alpha > 0.05)
|
||||||
{
|
{
|
||||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||||
|
|
||||||
[self drawGLDisplay: drawPosition.x - 0.5 * size_in_pixels.width :drawPosition.y - 0.5 * size_in_pixels.height :z1 :alpha forUniverse:universe];
|
[self drawGLDisplay: drawPosition.x - 0.5 * size_in_pixels.width :drawPosition.y - 0.5 * size_in_pixels.height :z1 :alpha forUniverse:universe];
|
||||||
|
|
||||||
@ -787,7 +782,7 @@ MA 02110-1301, USA.
|
|||||||
if (alpha > 0.05)
|
if (alpha > 0.05)
|
||||||
{
|
{
|
||||||
|
|
||||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||||
|
|
||||||
[self drawGLDisplay:x - 0.5 * size_in_pixels.width :y - 0.5 * size_in_pixels.height :z :alpha forUniverse:universe];
|
[self drawGLDisplay:x - 0.5 * size_in_pixels.width :y - 0.5 * size_in_pixels.height :z :alpha forUniverse:universe];
|
||||||
|
|
||||||
@ -856,7 +851,7 @@ MA 02110-1301, USA.
|
|||||||
if (alpha < 0.05)
|
if (alpha < 0.05)
|
||||||
return; // too dim to see!
|
return; // too dim to see!
|
||||||
|
|
||||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||||
|
|
||||||
[self drawGLDisplay:x - 0.5 * size_in_pixels.width :y - 0.5 * size_in_pixels.height :z :alpha forUniverse:universe];
|
[self drawGLDisplay:x - 0.5 * size_in_pixels.width :y - 0.5 * size_in_pixels.height :z :alpha forUniverse:universe];
|
||||||
|
|
||||||
@ -1047,7 +1042,7 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
- (void) drawStarChart:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha forUniverse:(Universe*)universe
|
- (void) drawStarChart:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha forUniverse:(Universe*)universe
|
||||||
{
|
{
|
||||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||||
|
|
||||||
if (!player)
|
if (!player)
|
||||||
return;
|
return;
|
||||||
@ -1182,7 +1177,7 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
- (void) drawGalaxyChart:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha forUniverse:(Universe*)universe
|
- (void) drawGalaxyChart:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha forUniverse:(Universe*)universe
|
||||||
{
|
{
|
||||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||||
|
|
||||||
NSPoint galaxy_coordinates = [player galaxy_coordinates];
|
NSPoint galaxy_coordinates = [player galaxy_coordinates];
|
||||||
NSPoint cursor_coordinates = [player cursor_coordinates];
|
NSPoint cursor_coordinates = [player cursor_coordinates];
|
||||||
@ -1322,7 +1317,7 @@ MA 02110-1301, USA.
|
|||||||
// Advanced Navigation Array -- galactic chart route mapping - contributed by Nikos Barkas (another_commander).
|
// Advanced Navigation Array -- galactic chart route mapping - contributed by Nikos Barkas (another_commander).
|
||||||
- (void) drawAdvancedNavArrayAtX:(float)x y:(float)y z:(float)z alpha:(float)alpha forUniverse:(Universe*)universe;
|
- (void) drawAdvancedNavArrayAtX:(float)x y:(float)y z:(float)z alpha:(float)alpha forUniverse:(Universe*)universe;
|
||||||
{
|
{
|
||||||
PlayerEntity *player = (PlayerEntity*)[universe entityZero];
|
PlayerEntity *player = [PlayerEntity sharedPlayer];
|
||||||
NSPoint galaxy_coordinates = [player galaxy_coordinates];
|
NSPoint galaxy_coordinates = [player galaxy_coordinates];
|
||||||
NSPoint cursor_coordinates = [player cursor_coordinates];
|
NSPoint cursor_coordinates = [player cursor_coordinates];
|
||||||
Random_Seed galaxy_seed = [player galaxy_seed];
|
Random_Seed galaxy_seed = [player galaxy_seed];
|
||||||
|
@ -33,6 +33,8 @@ MA 02110-1301, USA.
|
|||||||
#import "OOColor.h"
|
#import "OOColor.h"
|
||||||
#import "GuiDisplayGen.h"
|
#import "GuiDisplayGen.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.HeadUpDisplay"
|
||||||
|
|
||||||
static const char *toAscii(unsigned inCodePoint);
|
static const char *toAscii(unsigned inCodePoint);
|
||||||
|
|
||||||
@implementation HeadUpDisplay
|
@implementation HeadUpDisplay
|
||||||
@ -83,8 +85,6 @@ float char_widths[128] = {
|
|||||||
}
|
}
|
||||||
if (!areTrumblesToBeDrawn) // naughty - a hud with no built-in drawTrumbles: - one must be added!
|
if (!areTrumblesToBeDrawn) // naughty - a hud with no built-in drawTrumbles: - one must be added!
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG // naughty - a hud with no built-in drawTrumbles: - one must be added!");
|
|
||||||
//
|
|
||||||
NSDictionary* trumble_dial_info = [NSDictionary dictionaryWithObjectsAndKeys: @"drawTrumbles:", SELECTOR_KEY, nil];
|
NSDictionary* trumble_dial_info = [NSDictionary dictionaryWithObjectsAndKeys: @"drawTrumbles:", SELECTOR_KEY, nil];
|
||||||
[self addDial: trumble_dial_info];
|
[self addDial: trumble_dial_info];
|
||||||
}
|
}
|
||||||
@ -240,12 +240,8 @@ GLuint ascii_texture_name;
|
|||||||
{
|
{
|
||||||
if ([info objectForKey:SELECTOR_KEY])
|
if ([info objectForKey:SELECTOR_KEY])
|
||||||
{
|
{
|
||||||
//NSLog(@"DEBUG adding Dial for %@",[info objectForKey:SELECTOR_KEY]);
|
|
||||||
SEL _selector = NSSelectorFromString((NSString *)[info objectForKey:SELECTOR_KEY]);
|
SEL _selector = NSSelectorFromString((NSString *)[info objectForKey:SELECTOR_KEY]);
|
||||||
if ([self respondsToSelector:_selector])
|
if ([self respondsToSelector:_selector]) [dialArray addObject:info];
|
||||||
[dialArray addObject:info];
|
|
||||||
//else
|
|
||||||
// NSLog(@"DEBUG HeadUpDisplay does not respond to '%@'",[info objectForKey:SELECTOR_KEY]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,6 +258,8 @@ checkGLErrors(@"HeadUpDisplay after drawLegends");
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// SLOW_CODE - HUD drawing is taking up a ridiculous 30%-40% of frame time. Much of this seems to be spent in string processing. String caching is needed. -- ahruman
|
||||||
- (void) drawDials
|
- (void) drawDials
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -306,7 +304,6 @@ checkGLErrors(@"HeadUpDisplay after drawDials");
|
|||||||
|
|
||||||
if ([info objectForKey:SELECTOR_KEY])
|
if ([info objectForKey:SELECTOR_KEY])
|
||||||
{
|
{
|
||||||
//NSLog(@"DEBUG about to '%@'",[info objectForKey:SELECTOR_KEY]);
|
|
||||||
SEL _selector = NSSelectorFromString((NSString *)[info objectForKey:SELECTOR_KEY]);
|
SEL _selector = NSSelectorFromString((NSString *)[info objectForKey:SELECTOR_KEY]);
|
||||||
if ([self respondsToSelector:_selector])
|
if ([self respondsToSelector:_selector])
|
||||||
[self performSelector:_selector withObject:info];
|
[self performSelector:_selector withObject:info];
|
||||||
@ -622,7 +619,6 @@ static BOOL hostiles;
|
|||||||
if ((lt == nil)||(!(lt->isShip)))
|
if ((lt == nil)||(!(lt->isShip)))
|
||||||
return;
|
return;
|
||||||
ShipEntity* st = (ShipEntity*)lt;
|
ShipEntity* st = (ShipEntity*)lt;
|
||||||
// NSLog(@"DEBUG Last Transmitter (%d) == %@ %d", last_transmitter, [st name], [st universal_id]);
|
|
||||||
if ([st message_time] <= 0.0)
|
if ([st message_time] <= 0.0)
|
||||||
[st setMessage_time:2.5];
|
[st setMessage_time:2.5];
|
||||||
}
|
}
|
||||||
@ -2070,8 +2066,6 @@ void hudDrawReticleOnTarget(Entity* target, PlayerEntity* player1, GLfloat z1)
|
|||||||
glVertex2f(-rs0,-rs2); glVertex2f(-rs0,-rs0);
|
glVertex2f(-rs0,-rs2); glVertex2f(-rs0,-rs0);
|
||||||
glVertex2f(-rs0,-rs0); glVertex2f(-rs2,-rs0);
|
glVertex2f(-rs0,-rs0); glVertex2f(-rs2,-rs0);
|
||||||
|
|
||||||
// NSLog(@"DEBUG rs0 %.3f %.3f",rs0, rs2);
|
|
||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
// add text for reticle here
|
// add text for reticle here
|
||||||
@ -2114,7 +2108,6 @@ void drawString(NSString *text, double x, double y, double z, NSSize siz)
|
|||||||
char simple[2] = {0, 0};
|
char simple[2] = {0, 0};
|
||||||
unsigned ch, next, length;
|
unsigned ch, next, length;
|
||||||
|
|
||||||
// NSLog(@"DEBUG drawing string (%@) at %.1f, %.1f, %.1f (%.1f x %.1f)", text, x, y, z, siz.width, siz.height);
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
glBindTexture(GL_TEXTURE_2D, ascii_texture_name);
|
glBindTexture(GL_TEXTURE_2D, ascii_texture_name);
|
||||||
|
@ -44,9 +44,9 @@ JSFunctionSpec Universe_funcs[] = {
|
|||||||
|
|
||||||
JSBool UniverseCheckForShips(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool UniverseCheckForShips(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
// PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
// PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
NSString *role = JSValToNSString(cx, argv[0]);
|
NSString *role = JSValToNSString(cx, argv[0]);
|
||||||
int num = [scriptedUniverse countShipsWithRole:role];
|
int num = [[Universe sharedUniverse] countShipsWithRole:role];
|
||||||
*rval = INT_TO_JSVAL(num);
|
*rval = INT_TO_JSVAL(num);
|
||||||
}
|
}
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
@ -54,12 +54,12 @@ JSBool UniverseCheckForShips(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
|
|||||||
|
|
||||||
JSBool UniverseAddShips(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool UniverseAddShips(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
// PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
// PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
NSString *role = JSValToNSString(cx, argv[0]);
|
NSString *role = JSValToNSString(cx, argv[0]);
|
||||||
int num = JSVAL_TO_INT(argv[1]);
|
int num = JSVAL_TO_INT(argv[1]);
|
||||||
|
|
||||||
while (num--)
|
while (num--)
|
||||||
[scriptedUniverse witchspaceShipWithRole:role];
|
[[Universe sharedUniverse] witchspaceShipWithRole:role];
|
||||||
}
|
}
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
@ -67,12 +67,12 @@ JSBool UniverseAddShips(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
|||||||
JSBool UniverseAddSystemShips(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool UniverseAddSystemShips(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
if (argc == 3) {
|
if (argc == 3) {
|
||||||
jsdouble posn;
|
jsdouble posn;
|
||||||
// PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
// PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
NSString *role = JSValToNSString(cx, argv[0]);
|
NSString *role = JSValToNSString(cx, argv[0]);
|
||||||
int num = JSVAL_TO_INT(argv[1]);
|
int num = JSVAL_TO_INT(argv[1]);
|
||||||
JS_ValueToNumber(cx, argv[2], &posn);
|
JS_ValueToNumber(cx, argv[2], &posn);
|
||||||
while (num--)
|
while (num--)
|
||||||
[scriptedUniverse addShipWithRole:role nearRouteOneAt:posn];
|
[[Universe sharedUniverse] addShipWithRole:role nearRouteOneAt:posn];
|
||||||
}
|
}
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ JSBool UniverseAddSystemShips(JSContext *cx, JSObject *obj, uintN argc, jsval *a
|
|||||||
JSBool UniverseAddShipsAt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool UniverseAddShipsAt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
if (argc == 6) {
|
if (argc == 6) {
|
||||||
jsdouble x, y, z;
|
jsdouble x, y, z;
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
NSString *role = JSValToNSString(cx, argv[0]);
|
NSString *role = JSValToNSString(cx, argv[0]);
|
||||||
int num = JSVAL_TO_INT(argv[1]);
|
int num = JSVAL_TO_INT(argv[1]);
|
||||||
NSString *coordScheme = JSValToNSString(cx, argv[2]);
|
NSString *coordScheme = JSValToNSString(cx, argv[2]);
|
||||||
@ -96,7 +96,7 @@ JSBool UniverseAddShipsAt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||||||
JSBool UniverseAddShipsAtPrecisely(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool UniverseAddShipsAtPrecisely(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
if (argc == 6) {
|
if (argc == 6) {
|
||||||
jsdouble x, y, z;
|
jsdouble x, y, z;
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
NSString *role = JSValToNSString(cx, argv[0]);
|
NSString *role = JSValToNSString(cx, argv[0]);
|
||||||
int num = JSVAL_TO_INT(argv[1]);
|
int num = JSVAL_TO_INT(argv[1]);
|
||||||
NSString *coordScheme = JSValToNSString(cx, argv[2]);
|
NSString *coordScheme = JSValToNSString(cx, argv[2]);
|
||||||
@ -112,7 +112,7 @@ JSBool UniverseAddShipsAtPrecisely(JSContext *cx, JSObject *obj, uintN argc, jsv
|
|||||||
JSBool UniverseAddShipsWithinRadius(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool UniverseAddShipsWithinRadius(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
if (argc == 7) {
|
if (argc == 7) {
|
||||||
jsdouble x, y, z;
|
jsdouble x, y, z;
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
NSString *role = JSValToNSString(cx, argv[0]);
|
NSString *role = JSValToNSString(cx, argv[0]);
|
||||||
int num = JSVAL_TO_INT(argv[1]);
|
int num = JSVAL_TO_INT(argv[1]);
|
||||||
NSString *coordScheme = JSValToNSString(cx, argv[2]);
|
NSString *coordScheme = JSValToNSString(cx, argv[2]);
|
||||||
@ -128,7 +128,7 @@ JSBool UniverseAddShipsWithinRadius(JSContext *cx, JSObject *obj, uintN argc, js
|
|||||||
|
|
||||||
JSBool UniverseSpawn(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool UniverseSpawn(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
NSString *role = JSValToNSString(cx, argv[0]);
|
NSString *role = JSValToNSString(cx, argv[0]);
|
||||||
int num = JSVAL_TO_INT(argv[1]);
|
int num = JSVAL_TO_INT(argv[1]);
|
||||||
NSString *arg = [NSString stringWithFormat:@"%@ %d", role, num];
|
NSString *arg = [NSString stringWithFormat:@"%@ %d", role, num];
|
||||||
@ -139,7 +139,7 @@ JSBool UniverseSpawn(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
|||||||
|
|
||||||
JSBool UniverseSpawnShip(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool UniverseSpawnShip(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
[playerEntity spawnShip:JSValToNSString(cx, argv[0])];
|
[playerEntity spawnShip:JSValToNSString(cx, argv[0])];
|
||||||
}
|
}
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
@ -154,7 +154,7 @@ JSBool UniverseAddMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||||||
|
|
||||||
ok = JS_ValueToInt32(cx, argv[1], &count);
|
ok = JS_ValueToInt32(cx, argv[1], &count);
|
||||||
NSString *str = JSValToNSString(cx, argv[0]);
|
NSString *str = JSValToNSString(cx, argv[0]);
|
||||||
[scriptedUniverse addMessage: str forCount:(int)count];
|
[[Universe sharedUniverse] addMessage: str forCount:(int)count];
|
||||||
//[str dealloc];
|
//[str dealloc];
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ JSBool UniverseAddCommsMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
|||||||
|
|
||||||
ok = JS_ValueToInt32(cx, argv[1], &count);
|
ok = JS_ValueToInt32(cx, argv[1], &count);
|
||||||
NSString *str = JSValToNSString(cx, argv[0]);
|
NSString *str = JSValToNSString(cx, argv[0]);
|
||||||
[scriptedUniverse addCommsMessage: str forCount:(int)count];
|
[[Universe sharedUniverse] addCommsMessage: str forCount:(int)count];
|
||||||
//[str dealloc];
|
//[str dealloc];
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
@ -175,7 +175,7 @@ JSBool UniverseAddCommsMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
|||||||
/*
|
/*
|
||||||
JSBool UniverseGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
|
JSBool UniverseGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
|
||||||
if (JSVAL_IS_INT(id)) {
|
if (JSVAL_IS_INT(id)) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
|
|
||||||
switch (JSVAL_TO_INT(id)) {
|
switch (JSVAL_TO_INT(id)) {
|
||||||
case UNI_PLAYER_ENTITY: {
|
case UNI_PLAYER_ENTITY: {
|
||||||
|
@ -23,6 +23,8 @@ MA 02110-1301, USA.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#import "OXPScript.h"
|
#import "OXPScript.h"
|
||||||
|
#import "OOLogging.h"
|
||||||
|
|
||||||
|
|
||||||
OXPScript *currentOXPScript;
|
OXPScript *currentOXPScript;
|
||||||
|
|
||||||
@ -42,8 +44,7 @@ extern NSString *JSValToNSString(JSContext *cx, jsval val);
|
|||||||
// ...
|
// ...
|
||||||
|
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
//NSLog(@"Attempting to load script: %@", filename);
|
|
||||||
obj = JS_NewObject(context, &OXP_class, 0x00, JS_GetGlobalObject(context));
|
obj = JS_NewObject(context, &OXP_class, 0x00, JS_GetGlobalObject(context));
|
||||||
JS_AddRoot(context, &obj); // note 2nd arg is a pointer-to-pointer
|
JS_AddRoot(context, &obj); // note 2nd arg is a pointer-to-pointer
|
||||||
|
|
||||||
@ -52,35 +53,29 @@ extern NSString *JSValToNSString(JSContext *cx, jsval val);
|
|||||||
jsval rval;
|
jsval rval;
|
||||||
JSBool ok;
|
JSBool ok;
|
||||||
JSScript *script = JS_CompileFile(context, obj, [filename cString]);
|
JSScript *script = JS_CompileFile(context, obj, [filename cString]);
|
||||||
if (script != 0x00) {
|
if (script != NULL) {
|
||||||
ok = JS_ExecuteScript(context, obj, script, &rval);
|
ok = JS_ExecuteScript(context, obj, script, &rval);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
ok = JS_GetProperty(context, obj, "Name", &rval);
|
ok = JS_GetProperty(context, obj, "Name", &rval);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
name = JSValToNSString(context, rval);
|
name = JSValToNSString(context, rval);
|
||||||
//NSLog(@"Found name property: %@", name);
|
|
||||||
} else {
|
} else {
|
||||||
// No name given in the script so use the filename
|
// No name given in the script so use the filename
|
||||||
name = [NSString stringWithString:filename];
|
name = [NSString stringWithString:filename];
|
||||||
//NSLog(@"No name property, defaulting to : %@", name);
|
|
||||||
}
|
}
|
||||||
ok = JS_GetProperty(context, obj, "Description", &rval);
|
ok = JS_GetProperty(context, obj, "Description", &rval);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
description = JSValToNSString(context, rval);
|
description = JSValToNSString(context, rval);
|
||||||
//NSLog(@"Found description : %@", description);
|
|
||||||
} else {
|
} else {
|
||||||
description = @"";
|
description = @"";
|
||||||
//NSLog(@"No description");
|
|
||||||
}
|
}
|
||||||
ok = JS_GetProperty(context, obj, "Version", &rval);
|
ok = JS_GetProperty(context, obj, "Version", &rval);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
version = JSValToNSString(context, rval);
|
version = JSValToNSString(context, rval);
|
||||||
//NSLog(@"Found version: %@", version);
|
|
||||||
} else {
|
} else {
|
||||||
version= @"";
|
version= @"";
|
||||||
//NSLog(@"No version");
|
|
||||||
}
|
}
|
||||||
NSLog(@"Loaded JavaScript OXP: %@ %@ %@", name, description, version);
|
OOLog(@"script.javascript.compile.success", @"Loaded JavaScript OXP: %@ %@ %@", name, description, version);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Example code to read the mission variables.
|
* Example code to read the mission variables.
|
||||||
@ -111,8 +106,8 @@ extern NSString *JSValToNSString(JSContext *cx, jsval val);
|
|||||||
}
|
}
|
||||||
JS_DestroyScript(context, script);
|
JS_DestroyScript(context, script);
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"Script compilation failed");
|
OOLog(@"script.javascript.compile.failed", @"Script compilation failed");
|
||||||
[super dealloc];
|
[self release];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,9 @@ MA 02110-1301, USA.
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
Universe *scriptedUniverse;
|
#define kOOLogUnconvertedNSLog @"unclassified.JSScriptEngine"
|
||||||
|
|
||||||
|
|
||||||
JSObject *xglob, *universeObj, *systemObj, *playerObj, *missionObj;
|
JSObject *xglob, *universeObj, *systemObj, *playerObj, *missionObj;
|
||||||
|
|
||||||
extern OXPScript *currentOXPScript;
|
extern OXPScript *currentOXPScript;
|
||||||
@ -66,7 +68,7 @@ JSClass MissionVars_class = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
JSBool MissionVarsGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
|
JSBool MissionVarsGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
NSDictionary *mission_variables = [playerEntity mission_variables];
|
NSDictionary *mission_variables = [playerEntity mission_variables];
|
||||||
|
|
||||||
if (JSVAL_IS_STRING(id)) {
|
if (JSVAL_IS_STRING(id)) {
|
||||||
@ -104,7 +106,7 @@ JSBool MissionVarsGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSBool MissionVarsSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
|
JSBool MissionVarsSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
NSDictionary *mission_variables = [playerEntity mission_variables];
|
NSDictionary *mission_variables = [playerEntity mission_variables];
|
||||||
|
|
||||||
if (JSVAL_IS_STRING(id)) {
|
if (JSVAL_IS_STRING(id)) {
|
||||||
@ -156,7 +158,7 @@ JSFunctionSpec Global_funcs[] = {
|
|||||||
|
|
||||||
JSBool GlobalListenForKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool GlobalListenForKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
NSString *key = JSValToNSString(cx, argv[0]);
|
NSString *key = JSValToNSString(cx, argv[0]);
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
[playerEntity mapKey:key toOXP:currentOXPScript];
|
[playerEntity mapKey:key toOXP:currentOXPScript];
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
@ -177,7 +179,7 @@ JSBool GlobalGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
|
|||||||
|
|
||||||
if (!JSVAL_IS_INT(id)) return JS_TRUE;
|
if (!JSVAL_IS_INT(id)) return JS_TRUE;
|
||||||
|
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
|
|
||||||
switch (JSVAL_TO_INT(id)) {
|
switch (JSVAL_TO_INT(id)) {
|
||||||
case GLOBAL_GALAXY_NUMBER:
|
case GLOBAL_GALAXY_NUMBER:
|
||||||
@ -269,7 +271,7 @@ JSFunctionSpec Player_funcs[] = {
|
|||||||
|
|
||||||
JSBool PlayerAwardCargo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool PlayerAwardCargo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
NSString *amount_type = [NSString stringWithFormat:@"%@ %@", JSValToNSString(cx, argv[0]), JSValToNSString(cx, argv[1])];
|
NSString *amount_type = [NSString stringWithFormat:@"%@ %@", JSValToNSString(cx, argv[0]), JSValToNSString(cx, argv[1])];
|
||||||
[playerEntity awardCargo:amount_type];
|
[playerEntity awardCargo:amount_type];
|
||||||
}
|
}
|
||||||
@ -277,21 +279,21 @@ JSBool PlayerAwardCargo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSBool PlayerRemoveAllCargo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool PlayerRemoveAllCargo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
[playerEntity removeAllCargo];
|
[playerEntity removeAllCargo];
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSBool PlayerUseSpecialCargo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool PlayerUseSpecialCargo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
[playerEntity useSpecialCargo:JSValToNSString(cx, argv[0])];
|
[playerEntity useSpecialCargo:JSValToNSString(cx, argv[0])];
|
||||||
}
|
}
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSBool PlayerAwardEquipment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool PlayerAwardEquipment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
|
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
|
||||||
JSString *jskey = JS_ValueToString(cx, argv[0]);
|
JSString *jskey = JS_ValueToString(cx, argv[0]);
|
||||||
[playerEntity awardEquipment: [NSString stringWithCString:JS_GetStringBytes(jskey)]];
|
[playerEntity awardEquipment: [NSString stringWithCString:JS_GetStringBytes(jskey)]];
|
||||||
@ -300,7 +302,7 @@ JSBool PlayerAwardEquipment(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSBool PlayerRemoveEquipment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool PlayerRemoveEquipment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
|
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
|
||||||
JSString *jskey = JS_ValueToString(cx, argv[0]);
|
JSString *jskey = JS_ValueToString(cx, argv[0]);
|
||||||
[playerEntity removeEquipment: [NSString stringWithCString:JS_GetStringBytes(jskey)]];
|
[playerEntity removeEquipment: [NSString stringWithCString:JS_GetStringBytes(jskey)]];
|
||||||
@ -309,7 +311,7 @@ JSBool PlayerRemoveEquipment(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSBool PlayerHasEquipment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool PlayerHasEquipment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
|
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
|
||||||
JSString *jskey = JS_ValueToString(cx, argv[0]);
|
JSString *jskey = JS_ValueToString(cx, argv[0]);
|
||||||
BOOLToJSVal(cx, [playerEntity has_extra_equipment: [NSString stringWithCString:JS_GetStringBytes(jskey)]], rval);
|
BOOLToJSVal(cx, [playerEntity has_extra_equipment: [NSString stringWithCString:JS_GetStringBytes(jskey)]], rval);
|
||||||
@ -318,13 +320,13 @@ JSBool PlayerHasEquipment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSBool PlayerLaunch(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool PlayerLaunch(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
[playerEntity launchFromStation];
|
[playerEntity launchFromStation];
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSBool PlayerCall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool PlayerCall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
NSString *selectorString = JSValToNSString(cx, argv[0]);
|
NSString *selectorString = JSValToNSString(cx, argv[0]);
|
||||||
// Check if the selector needs a trailing colon to flag an argument will be sent
|
// Check if the selector needs a trailing colon to flag an argument will be sent
|
||||||
@ -349,7 +351,7 @@ JSBool PlayerGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
|
|||||||
|
|
||||||
if (!JSVAL_IS_INT(id)) return JS_TRUE;
|
if (!JSVAL_IS_INT(id)) return JS_TRUE;
|
||||||
|
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
|
|
||||||
switch (JSVAL_TO_INT(id)) {
|
switch (JSVAL_TO_INT(id)) {
|
||||||
case PE_SHIP_DESCRIPTION:
|
case PE_SHIP_DESCRIPTION:
|
||||||
@ -395,7 +397,7 @@ JSBool PlayerSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
|
|||||||
|
|
||||||
if (!JSVAL_IS_INT(id)) return JS_TRUE;
|
if (!JSVAL_IS_INT(id)) return JS_TRUE;
|
||||||
|
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
|
|
||||||
switch (JSVAL_TO_INT(id)) {
|
switch (JSVAL_TO_INT(id)) {
|
||||||
case PE_SCORE:
|
case PE_SCORE:
|
||||||
@ -469,7 +471,7 @@ JSFunctionSpec System_funcs[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
JSBool SystemAddPlanet(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool SystemAddPlanet(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
|
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
|
||||||
NSString *key = JSValToNSString(cx, argv[0]);
|
NSString *key = JSValToNSString(cx, argv[0]);
|
||||||
[playerEntity addPlanet:key];
|
[playerEntity addPlanet:key];
|
||||||
@ -478,7 +480,7 @@ JSBool SystemAddPlanet(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSBool SystemAddMoon(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool SystemAddMoon(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
|
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
|
||||||
NSString *key = JSValToNSString(cx, argv[0]);
|
NSString *key = JSValToNSString(cx, argv[0]);
|
||||||
[playerEntity addMoon:key];
|
[playerEntity addMoon:key];
|
||||||
@ -487,13 +489,13 @@ JSBool SystemAddMoon(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSBool SystemSendAllShipsAway(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool SystemSendAllShipsAway(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
[playerEntity sendAllShipsAway];
|
[playerEntity sendAllShipsAway];
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSBool SystemSetSunNova(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool SystemSetSunNova(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
NSString *key = JSValToNSString(cx, argv[0]);
|
NSString *key = JSValToNSString(cx, argv[0]);
|
||||||
[playerEntity setSunNovaIn:key];
|
[playerEntity setSunNovaIn:key];
|
||||||
@ -509,14 +511,14 @@ JSBool SystemGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
|
|||||||
if (!JSVAL_IS_INT(id)) return JS_TRUE;
|
if (!JSVAL_IS_INT(id)) return JS_TRUE;
|
||||||
|
|
||||||
NSString *str;
|
NSString *str;
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
if (!equal_seeds(currentSystem, playerEntity->system_seed)) {
|
if (!equal_seeds(currentSystem, playerEntity->system_seed)) {
|
||||||
//fprintf(stdout, "Current system has changed, regenerating local copy of planetinfo\r\n");
|
//fprintf(stdout, "Current system has changed, regenerating local copy of planetinfo\r\n");
|
||||||
currentSystem = playerEntity->system_seed;
|
currentSystem = playerEntity->system_seed;
|
||||||
if (planetinfo)
|
if (planetinfo)
|
||||||
[planetinfo release];
|
[planetinfo release];
|
||||||
|
|
||||||
planetinfo = [[scriptedUniverse generateSystemData:currentSystem] retain];
|
planetinfo = [[[Universe sharedUniverse] generateSystemData:currentSystem] retain];
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (JSVAL_TO_INT(id)) {
|
switch (JSVAL_TO_INT(id)) {
|
||||||
@ -584,29 +586,29 @@ JSBool SystemSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
|
|||||||
|
|
||||||
if (!JSVAL_IS_INT(id)) return JS_TRUE;
|
if (!JSVAL_IS_INT(id)) return JS_TRUE;
|
||||||
|
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
if (!equal_seeds(currentSystem, playerEntity->system_seed)) {
|
if (!equal_seeds(currentSystem, playerEntity->system_seed)) {
|
||||||
//fprintf(stdout, "Current system has changed, regenerating local copy of planetinfo\r\n");
|
//fprintf(stdout, "Current system has changed, regenerating local copy of planetinfo\r\n");
|
||||||
currentSystem = playerEntity->system_seed;
|
currentSystem = playerEntity->system_seed;
|
||||||
if (planetinfo)
|
if (planetinfo)
|
||||||
[planetinfo release];
|
[planetinfo release];
|
||||||
|
|
||||||
planetinfo = [[scriptedUniverse generateSystemData:currentSystem] retain];
|
planetinfo = [[[Universe sharedUniverse] generateSystemData:currentSystem] retain];
|
||||||
}
|
}
|
||||||
int gn = [[playerEntity galaxy_number] intValue];
|
int gn = [[playerEntity galaxy_number] intValue];
|
||||||
int pn = [[playerEntity planet_number] intValue];
|
int pn = [[playerEntity planet_number] intValue];
|
||||||
|
|
||||||
switch (JSVAL_TO_INT(id)) {
|
switch (JSVAL_TO_INT(id)) {
|
||||||
case SYS_NAME:
|
case SYS_NAME:
|
||||||
[scriptedUniverse setSystemDataForGalaxy:gn planet:pn key:KEY_NAME value:JSValToNSString(cx, *vp)];
|
[[Universe sharedUniverse] setSystemDataForGalaxy:gn planet:pn key:KEY_NAME value:JSValToNSString(cx, *vp)];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYS_DESCRIPTION:
|
case SYS_DESCRIPTION:
|
||||||
[scriptedUniverse setSystemDataForGalaxy:gn planet:pn key:KEY_DESCRIPTION value:JSValToNSString(cx, *vp)];
|
[[Universe sharedUniverse] setSystemDataForGalaxy:gn planet:pn key:KEY_DESCRIPTION value:JSValToNSString(cx, *vp)];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYS_INHABITANTS:
|
case SYS_INHABITANTS:
|
||||||
[scriptedUniverse setSystemDataForGalaxy:gn planet:pn key:KEY_INHABITANTS value:JSValToNSString(cx, *vp)];
|
[[Universe sharedUniverse] setSystemDataForGalaxy:gn planet:pn key:KEY_INHABITANTS value:JSValToNSString(cx, *vp)];
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
case SYS_GOING_NOVA:
|
case SYS_GOING_NOVA:
|
||||||
@ -618,23 +620,23 @@ JSBool SystemSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
|
|||||||
break;
|
break;
|
||||||
*/
|
*/
|
||||||
case SYS_GOVT_ID:
|
case SYS_GOVT_ID:
|
||||||
[scriptedUniverse setSystemDataForGalaxy:gn planet:pn key:KEY_GOVERNMENT value:[NSNumber numberWithInt:[JSValToNSString(cx, *vp) intValue]]];
|
[[Universe sharedUniverse] setSystemDataForGalaxy:gn planet:pn key:KEY_GOVERNMENT value:[NSNumber numberWithInt:[JSValToNSString(cx, *vp) intValue]]];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYS_ECONOMY_ID:
|
case SYS_ECONOMY_ID:
|
||||||
[scriptedUniverse setSystemDataForGalaxy:gn planet:pn key:KEY_ECONOMY value:[NSNumber numberWithInt:[JSValToNSString(cx, *vp) intValue]]];
|
[[Universe sharedUniverse] setSystemDataForGalaxy:gn planet:pn key:KEY_ECONOMY value:[NSNumber numberWithInt:[JSValToNSString(cx, *vp) intValue]]];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYS_TECH_LVL:
|
case SYS_TECH_LVL:
|
||||||
[scriptedUniverse setSystemDataForGalaxy:gn planet:pn key:KEY_TECHLEVEL value:[NSNumber numberWithInt:[JSValToNSString(cx, *vp) intValue]]];
|
[[Universe sharedUniverse] setSystemDataForGalaxy:gn planet:pn key:KEY_TECHLEVEL value:[NSNumber numberWithInt:[JSValToNSString(cx, *vp) intValue]]];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYS_POPULATION:
|
case SYS_POPULATION:
|
||||||
[scriptedUniverse setSystemDataForGalaxy:gn planet:pn key:KEY_POPULATION value:[NSNumber numberWithInt:[JSValToNSString(cx, *vp) intValue]]];
|
[[Universe sharedUniverse] setSystemDataForGalaxy:gn planet:pn key:KEY_POPULATION value:[NSNumber numberWithInt:[JSValToNSString(cx, *vp) intValue]]];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYS_PRODUCTIVITY:
|
case SYS_PRODUCTIVITY:
|
||||||
[scriptedUniverse setSystemDataForGalaxy:gn planet:pn key:KEY_PRODUCTIVITY value:[NSNumber numberWithInt:[JSValToNSString(cx, *vp) intValue]]];
|
[[Universe sharedUniverse] setSystemDataForGalaxy:gn planet:pn key:KEY_PRODUCTIVITY value:[NSNumber numberWithInt:[JSValToNSString(cx, *vp) intValue]]];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
@ -687,7 +689,7 @@ JSBool MissionGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
|
|||||||
if (!JSVAL_IS_INT(id)) return JS_TRUE;
|
if (!JSVAL_IS_INT(id)) return JS_TRUE;
|
||||||
|
|
||||||
NSString *str;
|
NSString *str;
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
|
|
||||||
switch (JSVAL_TO_INT(id)) {
|
switch (JSVAL_TO_INT(id)) {
|
||||||
case MISSION_CHOICE:
|
case MISSION_CHOICE:
|
||||||
@ -704,7 +706,7 @@ JSBool MissionSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
|
|||||||
|
|
||||||
if (!JSVAL_IS_INT(id)) return JS_TRUE;
|
if (!JSVAL_IS_INT(id)) return JS_TRUE;
|
||||||
|
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
|
|
||||||
switch (JSVAL_TO_INT(id)) {
|
switch (JSVAL_TO_INT(id)) {
|
||||||
case MISSION_TEXT: {
|
case MISSION_TEXT: {
|
||||||
@ -753,13 +755,13 @@ JSBool MissionSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSBool MissionShowMissionScreen(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool MissionShowMissionScreen(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
[playerEntity setGuiToMissionScreen];
|
[playerEntity setGuiToMissionScreen];
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSBool MissionShowShipModel(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool MissionShowShipModel(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
|
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
|
||||||
JSString *jskey = JS_ValueToString(cx, argv[0]);
|
JSString *jskey = JS_ValueToString(cx, argv[0]);
|
||||||
[playerEntity showShipModel: [NSString stringWithCString:JS_GetStringBytes(jskey)]];
|
[playerEntity showShipModel: [NSString stringWithCString:JS_GetStringBytes(jskey)]];
|
||||||
@ -768,7 +770,7 @@ JSBool MissionShowShipModel(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSBool MissionResetMissionChoice(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
JSBool MissionResetMissionChoice(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||||
[playerEntity resetMissionChoice];
|
[playerEntity resetMissionChoice];
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
@ -795,7 +797,6 @@ void reportJSError(JSContext *cx, const char *message, JSErrorReport *report) {
|
|||||||
- (id) initWithUniverse: (Universe *)universe
|
- (id) initWithUniverse: (Universe *)universe
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
scriptedUniverse = universe;
|
|
||||||
|
|
||||||
/*set up global JS variables, including global and custom objects */
|
/*set up global JS variables, including global and custom objects */
|
||||||
|
|
||||||
|
@ -31,6 +31,9 @@ MA 02110-1301, USA.
|
|||||||
#import "ResourceManager.h"
|
#import "ResourceManager.h"
|
||||||
#import "OOPListParsing.h"
|
#import "OOPListParsing.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.NSFileManagerOOExtensions"
|
||||||
|
|
||||||
|
|
||||||
@implementation NSFileManager (OOExtensions)
|
@implementation NSFileManager (OOExtensions)
|
||||||
|
|
||||||
- (NSArray *)commanderContents
|
- (NSArray *)commanderContents
|
||||||
@ -92,7 +95,6 @@ MA 02110-1301, USA.
|
|||||||
// check file extension
|
// check file extension
|
||||||
if (![[path pathExtension] isEqual:@"oolite-save"])
|
if (![[path pathExtension] isEqual:@"oolite-save"])
|
||||||
{
|
{
|
||||||
// NSLog(@">>>> %@ is not a saved game", path);
|
|
||||||
[contents removeObjectAtIndex: i--];
|
[contents removeObjectAtIndex: i--];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,6 @@ MA 02110-1301, USA.
|
|||||||
return castmember;
|
return castmember;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG ***** couldn't cast character in role '%@'", c_role);
|
|
||||||
return castmember;
|
return castmember;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,7 +139,7 @@ MA 02110-1301, USA.
|
|||||||
// save random seeds for restoration later
|
// save random seeds for restoration later
|
||||||
RNG_Seed saved_seed = currentRandomSeed();
|
RNG_Seed saved_seed = currentRandomSeed();
|
||||||
// set RNG to character seed
|
// set RNG to character seed
|
||||||
seed_for_planet_description( genSeed);
|
seed_for_planet_description(genSeed);
|
||||||
|
|
||||||
// determine the planet of origin
|
// determine the planet of origin
|
||||||
NSDictionary* originInfo = [universe generateSystemData: originSystemSeed];
|
NSDictionary* originInfo = [universe generateSystemData: originSystemSeed];
|
||||||
@ -152,16 +151,16 @@ MA 02110-1301, USA.
|
|||||||
NSString* speciesString = [self species];
|
NSString* speciesString = [self species];
|
||||||
|
|
||||||
// determine the character's name
|
// determine the character's name
|
||||||
seed_RNG_only_for_planet_description( genSeed);
|
seed_RNG_only_for_planet_description(genSeed);
|
||||||
NSString* genName;
|
NSString* genName;
|
||||||
if ([speciesString hasPrefix:@"human"])
|
if ([speciesString hasPrefix:@"human"])
|
||||||
genName = [NSString stringWithFormat:@"%@ %@", [universe expandDescription:@"%R" forSystem: genSeed], [universe expandDescription:@"[nom]" forSystem: genSeed]];
|
genName = [NSString stringWithFormat:@"%@ %@", ExpandDescriptionForSeed(@"%R", genSeed), ExpandDescriptionForSeed(@"[nom]", genSeed)];
|
||||||
else
|
else
|
||||||
genName = [NSString stringWithFormat:@"%@ %@", [universe expandDescription:@"%R" forSystem: genSeed], [universe expandDescription:@"%R" forSystem: genSeed]];
|
genName = [NSString stringWithFormat:@"%@ %@", ExpandDescriptionForSeed(@"%R", genSeed), ExpandDescriptionForSeed(@"%R", genSeed)];
|
||||||
|
|
||||||
[self setName: genName];
|
[self setName: genName];
|
||||||
|
|
||||||
[self setShortDescription: [NSString stringWithFormat:[universe expandDescription:@"[character-a-@-from-@]" forSystem: genSeed], speciesString, planetName]];
|
[self setShortDescription: [NSString stringWithFormat:ExpandDescriptionForSeed(@"[character-a-@-from-@]", genSeed), speciesString, planetName]];
|
||||||
[self setLongDescription: [self shortDescription]];
|
[self setLongDescription: [self shortDescription]];
|
||||||
|
|
||||||
// determine legal_status for a completely random character
|
// determine legal_status for a completely random character
|
||||||
@ -233,11 +232,7 @@ MA 02110-1301, USA.
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
[self setLongDescription:
|
[self setLongDescription:
|
||||||
[universe expandDescription:
|
ExpandDescriptionForSeed([NSString stringWithFormat:@"%@ is a [21] %@ from %@", [self name], legalDesc, [self planetOfOrigin]], genSeed)];
|
||||||
[NSString stringWithFormat:@"%@ is a [21] %@ from %@", [self name], legalDesc, [self planetOfOrigin]]
|
|
||||||
forSystem: genSeed]];
|
|
||||||
|
|
||||||
// NSLog(@">>>>> %@", self);
|
|
||||||
|
|
||||||
specialSetUpDone = YES;
|
specialSetUpDone = YES;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,8 @@ MA 02110-1301, USA.
|
|||||||
#import "Universe.h"
|
#import "Universe.h"
|
||||||
#import "AI.h"
|
#import "AI.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.OOInstinct"
|
||||||
|
|
||||||
|
|
||||||
@implementation OOInstinct
|
@implementation OOInstinct
|
||||||
|
|
||||||
|
@ -141,13 +141,14 @@ BOOL OOLogWillDisplayMessagesInClass(NSString *inMessageClass)
|
|||||||
|
|
||||||
// Look for cached value
|
// Look for cached value
|
||||||
value = [sDerivedSettingsCache objectForKey:inMessageClass];
|
value = [sDerivedSettingsCache objectForKey:inMessageClass];
|
||||||
if (__builtin_expect(value == nil, 0))
|
if (EXPECT_NOT(value == nil))
|
||||||
{
|
{
|
||||||
// No cached value.
|
// No cached value.
|
||||||
value = ResolveDisplaySetting(inMessageClass);
|
value = ResolveDisplaySetting(inMessageClass);
|
||||||
|
|
||||||
if (value != nil)
|
if (value != nil)
|
||||||
{
|
{
|
||||||
|
if (EXPECT_NOT(sDerivedSettingsCache == nil)) sDerivedSettingsCache = [[NSMutableDictionary alloc] init];
|
||||||
[sDerivedSettingsCache setObject:value forKey:inMessageClass];
|
[sDerivedSettingsCache setObject:value forKey:inMessageClass];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ NSString *StringFromPoint(NSPoint point);
|
|||||||
NSPoint PointFromString(NSString *xyString);
|
NSPoint PointFromString(NSString *xyString);
|
||||||
|
|
||||||
Random_Seed RandomSeedFromString(NSString *abcdefString);
|
Random_Seed RandomSeedFromString(NSString *abcdefString);
|
||||||
|
NSString *StringFromRandomSeed(Random_Seed seed);
|
||||||
|
|
||||||
|
|
||||||
NSString *ExpandDescriptionForSeed(NSString *text, Random_Seed seed);
|
NSString *ExpandDescriptionForSeed(NSString *text, Random_Seed seed);
|
||||||
@ -53,9 +54,14 @@ NSString *ExpandDescriptionForCurrentSystem(NSString *text);
|
|||||||
NSString *ExpandDescriptionsWithLocalsForSystemSeed(NSString *text, Random_Seed seed, NSDictionary *locals);
|
NSString *ExpandDescriptionsWithLocalsForSystemSeed(NSString *text, Random_Seed seed, NSDictionary *locals);
|
||||||
NSString *ExpandDescriptionsWithLocalsForCurrentSystem(NSString *text, NSDictionary *locals);
|
NSString *ExpandDescriptionsWithLocalsForCurrentSystem(NSString *text, NSDictionary *locals);
|
||||||
|
|
||||||
|
NSString *DescriptionForSystem(Random_Seed seed);
|
||||||
|
NSString *DescriptionForCurrentSystem(void);
|
||||||
|
|
||||||
// target and localVariables are optional; target will default to the player.
|
// target and localVariables are optional; target will default to the player.
|
||||||
NSString *ReplaceVariables(NSString *string, Entity *target, NSDictionary *localVariables);
|
NSString *ReplaceVariables(NSString *string, Entity *target, NSDictionary *localVariables);
|
||||||
|
|
||||||
|
NSString *RandomDigrams(void);
|
||||||
|
|
||||||
|
|
||||||
@interface NSString (OOUtilities)
|
@interface NSString (OOUtilities)
|
||||||
|
|
||||||
@ -64,3 +70,15 @@ NSString *ReplaceVariables(NSString *string, Entity *target, NSDictionary *local
|
|||||||
- (BOOL)pathHasExtensionInArray:(NSArray *)extensions;
|
- (BOOL)pathHasExtensionInArray:(NSArray *)extensions;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
// Given a string of the form 1.2.3.4 (with arbitrarily many components), return an array of unsigned ints.
|
||||||
|
NSArray *ComponentsFromVersionString(NSString *string);
|
||||||
|
|
||||||
|
/* Compare two arrays of unsigned int NSNumbers, as returned by
|
||||||
|
ComponentsFromVersionString().
|
||||||
|
|
||||||
|
Components are ordered from most to least significant, and a missing
|
||||||
|
component is treated as 0. Thus "1.7" < "1.60", and "1.2.3.0" == "1.2.3".
|
||||||
|
*/
|
||||||
|
NSComparisonResult CompareVersions(NSArray *version1, NSArray *version2);
|
||||||
|
@ -239,6 +239,12 @@ Random_Seed RandomSeedFromString(NSString *abcdefString)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NSString *StringFromRandomSeed(Random_Seed seed)
|
||||||
|
{
|
||||||
|
return [NSString stringWithFormat: @"%d %d %d %d %d %d", seed.a, seed.b, seed.c, seed.d, seed.e, seed.f];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NSString *ExpandDescriptionForSeed(NSString *text, Random_Seed seed)
|
NSString *ExpandDescriptionForSeed(NSString *text, Random_Seed seed)
|
||||||
{
|
{
|
||||||
// to enable variables to return strings that can be expanded (eg. @"[commanderName_string]")
|
// to enable variables to return strings that can be expanded (eg. @"[commanderName_string]")
|
||||||
@ -253,7 +259,7 @@ NSString *ExpandDescriptionForSeed(NSString *text, Random_Seed seed)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
old_desc = result;
|
old_desc = result;
|
||||||
result = ExpandDescriptionsWithLocalsForSystemSeed(text, seed, nil);
|
result = ExpandDescriptionsWithLocalsForSystemSeed(result, seed, nil);
|
||||||
} while (--stack_check && ![result isEqual:old_desc]);
|
} while (--stack_check && ![result isEqual:old_desc]);
|
||||||
|
|
||||||
if (!stack_check)
|
if (!stack_check)
|
||||||
@ -262,7 +268,7 @@ NSString *ExpandDescriptionForSeed(NSString *text, Random_Seed seed)
|
|||||||
#if 0
|
#if 0
|
||||||
// What's the point of breaking? A bad description is better than falling to pieces.
|
// What's the point of breaking? A bad description is better than falling to pieces.
|
||||||
[NSException raise:OOLITE_EXCEPTION_LOOPING
|
[NSException raise:OOLITE_EXCEPTION_LOOPING
|
||||||
format:@"script stack overflow for expandDescription: \"%@\"", text];
|
format:@"script stack overflow for ExpandDescriptionForSeed(\"%@\")", text];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,7 +361,7 @@ NSString *ExpandDescriptionsWithLocalsForSystemSeed(NSString *text, Random_Seed
|
|||||||
options:NSLiteralSearch range:NSMakeRange(0, [partial length])];
|
options:NSLiteralSearch range:NSMakeRange(0, [partial length])];
|
||||||
|
|
||||||
[partial replaceOccurrencesOfString:@"%R"
|
[partial replaceOccurrencesOfString:@"%R"
|
||||||
withString:[universe getRandomDigrams]
|
withString:RandomDigrams()
|
||||||
options:NSLiteralSearch range:NSMakeRange(0, [partial length])];
|
options:NSLiteralSearch range:NSMakeRange(0, [partial length])];
|
||||||
|
|
||||||
return partial;
|
return partial;
|
||||||
@ -368,6 +374,19 @@ NSString *ExpandDescriptionsWithLocalsForCurrentSystem(NSString *text, NSDiction
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NSString *DescriptionForSystem(Random_Seed seed)
|
||||||
|
{
|
||||||
|
seed_RNG_only_for_planet_description(seed);
|
||||||
|
return ExpandDescriptionForSeed(@"[14] is [22].", seed);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NSString *DescriptionForCurrentSystem(void)
|
||||||
|
{
|
||||||
|
return DescriptionForSystem([[PlayerEntity sharedPlayer] system_seed]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NSString *ReplaceVariables(NSString *string, Entity *target, NSDictionary *localVariables)
|
NSString *ReplaceVariables(NSString *string, Entity *target, NSDictionary *localVariables)
|
||||||
{
|
{
|
||||||
NSMutableString *resultString = nil;
|
NSMutableString *resultString = nil;
|
||||||
@ -413,6 +432,21 @@ NSString *ReplaceVariables(NSString *string, Entity *target, NSDictionary *local
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NSString *RandomDigrams(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int len = gen_rnd_number() & 3;
|
||||||
|
NSString* digrams = [[[Universe sharedUniverse] descriptions] objectForKey:@"digrams"];
|
||||||
|
NSMutableString* name = [NSMutableString stringWithCapacity:256];
|
||||||
|
for (i = 0; i <=len; i++)
|
||||||
|
{
|
||||||
|
int x = gen_rnd_number() & 0x3e;
|
||||||
|
[name appendString:[digrams substringWithRange:NSMakeRange(x,2)]];
|
||||||
|
}
|
||||||
|
return [name capitalizedString];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@implementation NSString (OOUtilities)
|
@implementation NSString (OOUtilities)
|
||||||
|
|
||||||
- (BOOL)pathHasExtension:(NSString *)extension
|
- (BOOL)pathHasExtension:(NSString *)extension
|
||||||
@ -435,3 +469,60 @@ NSString *ReplaceVariables(NSString *string, Entity *target, NSDictionary *local
|
|||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
NSArray *ComponentsFromVersionString(NSString *string)
|
||||||
|
{
|
||||||
|
NSArray *stringComponents = nil;
|
||||||
|
NSMutableArray *result = nil;
|
||||||
|
unsigned i, count;
|
||||||
|
int value;
|
||||||
|
id component;
|
||||||
|
|
||||||
|
stringComponents = [string componentsSeparatedByString:@"."];
|
||||||
|
count = [stringComponents count];
|
||||||
|
result = [NSMutableArray arrayWithCapacity:count];
|
||||||
|
|
||||||
|
for (i = 0; i != count; ++i)
|
||||||
|
{
|
||||||
|
component = [stringComponents objectAtIndex:i];
|
||||||
|
if ([component respondsToSelector:@selector(intValue)]) value = MAX([component intValue], 0);
|
||||||
|
else value = 0;
|
||||||
|
|
||||||
|
[result addObject:[NSNumber numberWithUnsignedInt:value]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NSComparisonResult CompareVersions(NSArray *version1, NSArray *version2)
|
||||||
|
{
|
||||||
|
NSEnumerator *leftEnum = nil,
|
||||||
|
*rightEnum = nil;
|
||||||
|
NSNumber *leftComponent = nil,
|
||||||
|
*rightComponent = nil;
|
||||||
|
unsigned leftValue,
|
||||||
|
rightValue;
|
||||||
|
|
||||||
|
leftEnum = [version1 objectEnumerator];
|
||||||
|
rightEnum = [version2 objectEnumerator];
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
leftComponent = [leftEnum nextObject];
|
||||||
|
rightComponent = [rightEnum nextObject];
|
||||||
|
|
||||||
|
if (leftComponent == nil && rightComponent == nil) break; // End of both versions
|
||||||
|
|
||||||
|
// We'll get 0 if the component is nil, which is what we want.
|
||||||
|
leftValue = [leftComponent unsignedIntValue];
|
||||||
|
rightValue = [rightComponent unsignedIntValue];
|
||||||
|
|
||||||
|
if (leftValue < rightValue) return NSOrderedAscending;
|
||||||
|
if (leftValue > rightValue) return NSOrderedDescending;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there was a difference, we'd have returned already.
|
||||||
|
return NSOrderedSame;
|
||||||
|
}
|
||||||
|
@ -375,7 +375,6 @@ MA 02110-1301, USA.
|
|||||||
*/
|
*/
|
||||||
GLfloat wd = 96 * size;
|
GLfloat wd = 96 * size;
|
||||||
GLfloat ht = 96 * size;
|
GLfloat ht = 96 * size;
|
||||||
// NSLog(@"DEBUG drawing Trumble %@ of size %.2f at position %.2fx %.2fy %.2fz", self, size, position.x, position.y, z);
|
|
||||||
glShadeModel(GL_SMOOTH);
|
glShadeModel(GL_SMOOTH);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
@ -614,10 +613,9 @@ MA 02110-1301, USA.
|
|||||||
{
|
{
|
||||||
// eaten all of this cargo!
|
// eaten all of this cargo!
|
||||||
Universe* uni = [player universe];
|
Universe* uni = [player universe];
|
||||||
Random_Seed seed = [uni systemSeed];
|
NSString* ms = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[trumbles-eat-@]"),
|
||||||
NSString* ms = [NSString stringWithFormat:[uni expandDescription:@"[trumbles-eat-@]" forSystem:seed],
|
|
||||||
[uni nameForCommodity:[selectedCargopod getCommodityType]]];
|
[uni nameForCommodity:[selectedCargopod getCommodityType]]];
|
||||||
// NSLog(ms);
|
|
||||||
[uni addMessage: ms forCount: 4.5];
|
[uni addMessage: ms forCount: 4.5];
|
||||||
[cargopods removeObject:selectedCargopod];
|
[cargopods removeObject:selectedCargopod];
|
||||||
trumbleAppetiteAccumulator -= 10.0;
|
trumbleAppetiteAccumulator -= 10.0;
|
||||||
@ -625,7 +623,6 @@ MA 02110-1301, USA.
|
|||||||
// consider breeding - must be full grown and happy
|
// consider breeding - must be full grown and happy
|
||||||
if ((size > 0.95)&&(discomfort < 0.25))
|
if ((size > 0.95)&&(discomfort < 0.25))
|
||||||
{
|
{
|
||||||
// NSLog(@"Trumbles breeding!");
|
|
||||||
readyToSpawn = YES;
|
readyToSpawn = YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -875,7 +872,6 @@ MA 02110-1301, USA.
|
|||||||
if (animationTime > animationDuration)
|
if (animationTime > animationDuration)
|
||||||
{
|
{
|
||||||
// kaputnik!
|
// kaputnik!
|
||||||
// NSLog(@"TRUMBLE DIES!");
|
|
||||||
[player removeTrumble:self];
|
[player removeTrumble:self];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,9 +63,9 @@ OOINLINE GLfloat magnitude(Vector vec) INLINE_CONST_FUNC;
|
|||||||
OOINLINE GLfloat fast_magnitude(Vector vec) INLINE_CONST_FUNC;
|
OOINLINE GLfloat fast_magnitude(Vector vec) INLINE_CONST_FUNC;
|
||||||
|
|
||||||
/* Normalize vector */
|
/* Normalize vector */
|
||||||
OOINLINE Vector vector_normal(Vector vec) CONST_FUNC;
|
OOINLINE Vector vector_normal(Vector vec) INLINE_CONST_FUNC;
|
||||||
OOINLINE Vector fast_vector_normal(Vector vec) CONST_FUNC;
|
OOINLINE Vector fast_vector_normal(Vector vec) INLINE_CONST_FUNC;
|
||||||
OOINLINE Vector unit_vector(const Vector *vec) NONNULL_FUNC CONST_FUNC;
|
OOINLINE Vector unit_vector(const Vector *vec) NONNULL_FUNC INLINE_CONST_FUNC;
|
||||||
|
|
||||||
/* Square of distance between vectors */
|
/* Square of distance between vectors */
|
||||||
OOINLINE GLfloat distance2(Vector v1, Vector v2) INLINE_CONST_FUNC;
|
OOINLINE GLfloat distance2(Vector v1, Vector v2) INLINE_CONST_FUNC;
|
||||||
|
@ -28,6 +28,9 @@ MA 02110-1301, USA.
|
|||||||
#import "OOOpenGL.h"
|
#import "OOOpenGL.h"
|
||||||
#import "legacy_random.h"
|
#import "legacy_random.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.Octree"
|
||||||
|
|
||||||
|
|
||||||
@implementation Octree
|
@implementation Octree
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
|
@ -171,10 +171,6 @@ MA 02110-1301, USA.
|
|||||||
[self makeTextureFromImage:image cropRectangle:NSMakeRect(0, 0, [image size].width, [image size].height) size:[image size]];
|
[self makeTextureFromImage:image cropRectangle:NSMakeRect(0, 0, [image size].width, [image size].height) size:[image size]];
|
||||||
|
|
||||||
[image release];
|
[image release];
|
||||||
|
|
||||||
//
|
|
||||||
//NSLog(@"%@ message sprite [ %f, %f ]", str, [image size].width, [image size].height);
|
|
||||||
//
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,8 +257,7 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
if ((textureRect.size.width != textureSize.width)||(textureRect.size.height != textureSize.height))
|
if ((textureRect.size.width != textureSize.width)||(textureRect.size.height != textureSize.height))
|
||||||
{
|
{
|
||||||
NSLog(@"***** ERROR! replacement texture isn't the same size as original texture");
|
OOLog(@"sprite.badReplacementSize", @"***** ERROR! replacement texture isn't the same size as original texture -- cropRect %f x %f textureSize %f x %f",textureRect.size.width, textureRect.size.height, textureSize.width, textureSize.height);
|
||||||
NSLog(@"***** cropRect %f x %f textureSize %f x %f",textureRect.size.width, textureRect.size.height, textureSize.width, textureSize.height);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,7 +378,6 @@ enum
|
|||||||
|
|
||||||
SDL_Surface *texSurface = [texImage surface];
|
SDL_Surface *texSurface = [texImage surface];
|
||||||
SDL_SetAlpha(texSurface, 0, SDL_ALPHA_OPAQUE);
|
SDL_SetAlpha(texSurface, 0, SDL_ALPHA_OPAQUE);
|
||||||
//NSLog(@"makeTextureFromSurface: texImage dimensions: %d x %d", texSurface->w, texSurface->h);
|
|
||||||
|
|
||||||
size = spriteSize;
|
size = spriteSize;
|
||||||
textureCropRect = cropRect;
|
textureCropRect = cropRect;
|
||||||
@ -397,42 +391,24 @@ enum
|
|||||||
textureCropRect.origin= NSMakePoint(0,0);
|
textureCropRect.origin= NSMakePoint(0,0);
|
||||||
|
|
||||||
textureSize = textureRect.size;
|
textureSize = textureRect.size;
|
||||||
|
|
||||||
//image = [[NSImage alloc] initWithSize:textureRect.size]; // retained
|
|
||||||
//NSLog(@"makeTextureFromSurface: texture surface dimensions: %d x %d", (int)textureRect.size.width, (int)textureRect.size.height);
|
|
||||||
surface = SDL_CreateRGBSurface(SDL_SWSURFACE, (int)textureRect.size.width, (int)textureRect.size.height, 32, rmask, gmask, bmask, amask);
|
surface = SDL_CreateRGBSurface(SDL_SWSURFACE, (int)textureRect.size.width, (int)textureRect.size.height, 32, rmask, gmask, bmask, amask);
|
||||||
|
|
||||||
//[image lockFocus];
|
|
||||||
//[[OOColor clearColor] set];
|
|
||||||
//NSRectFill(textureRect);
|
|
||||||
SDL_FillRect(surface, (SDL_Rect *)0x00, SDL_MapRGBA(surface->format, 0, 0, 0, SDL_ALPHA_TRANSPARENT));
|
SDL_FillRect(surface, (SDL_Rect *)0x00, SDL_MapRGBA(surface->format, 0, 0, 0, SDL_ALPHA_TRANSPARENT));
|
||||||
|
|
||||||
//[texImage drawInRect:textureCropRect fromRect:cropRect operation:NSCompositeSourceOver fraction:1.0];
|
|
||||||
//bitmapImageRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:textureRect]; // retained
|
|
||||||
//[image unlockFocus];
|
|
||||||
|
|
||||||
SDL_Rect srcRect, destRect;
|
SDL_Rect srcRect, destRect;
|
||||||
srcRect.x = (int)cropRect.origin.x; srcRect.y = (int)cropRect.origin.y; srcRect.w = (int)cropRect.size.width; srcRect.h = (int)cropRect.size.height;
|
srcRect.x = (int)cropRect.origin.x; srcRect.y = (int)cropRect.origin.y; srcRect.w = (int)cropRect.size.width; srcRect.h = (int)cropRect.size.height;
|
||||||
destRect.x = 0; destRect.y = 0;
|
destRect.x = 0; destRect.y = 0;
|
||||||
SDL_BlitSurface(texSurface, &srcRect, surface, &destRect);
|
SDL_BlitSurface(texSurface, &srcRect, surface, &destRect);
|
||||||
//NSLog(@"destRect x: %d, y: %d, w: %d, h: %d", destRect.x, destRect.y, destRect.w, destRect.h);
|
|
||||||
|
|
||||||
//[image release]; // released
|
|
||||||
|
|
||||||
// normalise textureCropRect size to 0.0 -> 1.0
|
// normalise textureCropRect size to 0.0 -> 1.0
|
||||||
textureCropRect.size.width /= textureRect.size.width;
|
textureCropRect.size.width /= textureRect.size.width;
|
||||||
textureCropRect.size.height /= textureRect.size.height;
|
textureCropRect.size.height /= textureRect.size.height;
|
||||||
|
|
||||||
// int n_bytes = surface->format->BytesPerPixel * surface->w * surface->h;
|
|
||||||
//unsigned char *buffer = malloc(n_bytes);
|
|
||||||
SDL_LockSurface(surface);
|
SDL_LockSurface(surface);
|
||||||
//memcpy(buffer, surface->pixels, n_bytes);
|
|
||||||
|
|
||||||
if (textureData)
|
if (textureData)
|
||||||
[textureData release];
|
[textureData release];
|
||||||
//textureData = [[NSData dataWithBytes:[bitmapImageRep bitmapData] length:n_bytes] retain];
|
|
||||||
//[bitmapImageRep release]; // released
|
|
||||||
//textureData = [[NSData dataWithBytesNoCopy: buffer length: n_bytes] retain];
|
|
||||||
textureData = [[NSData dataWithBytes:surface->pixels length:surface->w * surface->h * surface->format->BytesPerPixel] retain];
|
textureData = [[NSData dataWithBytes:surface->pixels length:surface->w * surface->h * surface->format->BytesPerPixel] retain];
|
||||||
|
|
||||||
SDL_UnlockSurface(surface);
|
SDL_UnlockSurface(surface);
|
||||||
|
@ -34,6 +34,8 @@ MA 02110-1301, USA.
|
|||||||
#import "PlayerEntity.h"
|
#import "PlayerEntity.h"
|
||||||
#import "PlanetEntity.h"
|
#import "PlanetEntity.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.ParticleEntity"
|
||||||
|
|
||||||
|
|
||||||
static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||||
|
|
||||||
@ -914,7 +916,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
|||||||
case PARTICLE_BURST2 :
|
case PARTICLE_BURST2 :
|
||||||
case PARTICLE_FLASH :
|
case PARTICLE_FLASH :
|
||||||
{
|
{
|
||||||
Entity* player = [universe entityZero];
|
PlayerEntity *player = [PlayerEntity sharedPlayer];
|
||||||
if (!texName)
|
if (!texName)
|
||||||
[self initialiseTexture: textureNameString];
|
[self initialiseTexture: textureNameString];
|
||||||
if (player)
|
if (player)
|
||||||
@ -1037,7 +1039,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
|||||||
- (void) updateEnergyMine:(double) delta_t
|
- (void) updateEnergyMine:(double) delta_t
|
||||||
{
|
{
|
||||||
// new billboard routine (working at last!)
|
// new billboard routine (working at last!)
|
||||||
Entity* player = [universe entityZero];
|
PlayerEntity *player = [PlayerEntity sharedPlayer];
|
||||||
Vector v0 = position;
|
Vector v0 = position;
|
||||||
Vector p0 = (player)? player->position : make_vector( 0.0f, 0.0f, 0.0f);
|
Vector p0 = (player)? player->position : make_vector( 0.0f, 0.0f, 0.0f);
|
||||||
v0.x -= p0.x; v0.y -= p0.y; v0.z -= p0.z; // vector from player to position
|
v0.x -= p0.x; v0.y -= p0.y; v0.z -= p0.z; // vector from player to position
|
||||||
@ -1606,7 +1608,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
|||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
// position and orientation is absolute
|
// position and orientation is absolute
|
||||||
glTranslatef( abspos.x, abspos.y, abspos.z);
|
glTranslatef( abspos.x, abspos.y, abspos.z);
|
||||||
glMultMatrixf([[universe entityZero] drawRotationMatrix]);
|
glMultMatrixf([[PlayerEntity sharedPlayer] drawRotationMatrix]);
|
||||||
|
|
||||||
[self drawEntity:immediate :translucent];
|
[self drawEntity:immediate :translucent];
|
||||||
|
|
||||||
@ -1707,7 +1709,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
|||||||
|
|
||||||
case VIEW_CUSTOM :
|
case VIEW_CUSTOM :
|
||||||
{
|
{
|
||||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
PlayerEntity *player = [PlayerEntity sharedPlayer];
|
||||||
Vector vi = [player customViewRightVector]; vi.x *= xx; vi.y *= xx; vi.z *= xx;
|
Vector vi = [player customViewRightVector]; vi.x *= xx; vi.y *= xx; vi.z *= xx;
|
||||||
Vector vj = [player customViewUpVector]; vj.x *= yy; vj.y *= yy; vj.z *= yy;
|
Vector vj = [player customViewUpVector]; vj.x *= yy; vj.y *= yy; vj.z *= yy;
|
||||||
Vector vk = [player customViewForwardVector]; vk.x *= xx; vk.y *= xx; vk.z *= xx;
|
Vector vk = [player customViewForwardVector]; vk.x *= xx; vk.y *= xx; vk.z *= xx;
|
||||||
@ -1960,7 +1962,7 @@ void drawQuadForView(Universe* universe, GLfloat x, GLfloat y, GLfloat z, GLfloa
|
|||||||
break;
|
break;
|
||||||
case VIEW_CUSTOM :
|
case VIEW_CUSTOM :
|
||||||
{
|
{
|
||||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
PlayerEntity *player = [PlayerEntity sharedPlayer];
|
||||||
Vector vi = [player customViewRightVector]; vi.x *= xx; vi.y *= xx; vi.z *= xx;
|
Vector vi = [player customViewRightVector]; vi.x *= xx; vi.y *= xx; vi.z *= xx;
|
||||||
Vector vj = [player customViewUpVector]; vj.x *= yy; vj.y *= yy; vj.z *= yy;
|
Vector vj = [player customViewUpVector]; vj.x *= yy; vj.y *= yy; vj.z *= yy;
|
||||||
glTexCoord2f(0.0, 1.0); glVertex3f(x - vi.x - vj.x, y - vi.y - vj.y, z - vi.z - vj.z);
|
glTexCoord2f(0.0, 1.0); glVertex3f(x - vi.x - vj.x, y - vi.y - vj.y, z - vi.z - vj.z);
|
||||||
|
@ -35,6 +35,8 @@ MA 02110-1301, USA.
|
|||||||
#import "OOStringParsing.h"
|
#import "OOStringParsing.h"
|
||||||
#import "PlayerEntity.h"
|
#import "PlayerEntity.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.PlanetEntity"
|
||||||
|
|
||||||
|
|
||||||
#define LIM500 500.0*500.0 * NO_DRAW_DISTANCE_FACTOR*NO_DRAW_DISTANCE_FACTOR
|
#define LIM500 500.0*500.0 * NO_DRAW_DISTANCE_FACTOR*NO_DRAW_DISTANCE_FACTOR
|
||||||
#define LIM4K 4000.0*4000.0 * NO_DRAW_DISTANCE_FACTOR*NO_DRAW_DISTANCE_FACTOR
|
#define LIM4K 4000.0*4000.0 * NO_DRAW_DISTANCE_FACTOR*NO_DRAW_DISTANCE_FACTOR
|
||||||
@ -257,8 +259,7 @@ void setUpSinTable()
|
|||||||
self = [super init];
|
self = [super init];
|
||||||
//
|
//
|
||||||
percent_land = 3 + (gen_rnd_number() & 31)+(gen_rnd_number() & 31);
|
percent_land = 3 + (gen_rnd_number() & 31)+(gen_rnd_number() & 31);
|
||||||
//NSLog(@"Atmosphere is %d percent clear.",percent_land);
|
|
||||||
//
|
|
||||||
polar_color_factor = 1.0;
|
polar_color_factor = 1.0;
|
||||||
//
|
//
|
||||||
amb_land[0] = gen_rnd_number() / 256.0;
|
amb_land[0] = gen_rnd_number() / 256.0;
|
||||||
@ -336,18 +337,14 @@ void setUpSinTable()
|
|||||||
[self setModel:(isTextured)? @"icostextured.dat" : @"icosahedron.dat"];
|
[self setModel:(isTextured)? @"icostextured.dat" : @"icosahedron.dat"];
|
||||||
//
|
//
|
||||||
[self rescaleTo:1.0];
|
[self rescaleTo:1.0];
|
||||||
|
|
||||||
// NSLog(@"DEBUG atmosphere testing [PlanetEntity initialiseBaseVertexArray]");
|
|
||||||
[self initialiseBaseVertexArray];
|
[self initialiseBaseVertexArray];
|
||||||
|
|
||||||
// NSLog(@"DEBUG atmosphere testing [PlanetEntity initialiseBaseTerrainArray:%d]", percent_land);
|
|
||||||
[self initialiseBaseTerrainArray:percent_land];
|
[self initialiseBaseTerrainArray:percent_land];
|
||||||
|
|
||||||
// NSLog(@"DEBUG atmosphere painting %d vertices", next_free_vertex);
|
|
||||||
for (i = 0; i < next_free_vertex; i++)
|
for (i = 0; i < next_free_vertex; i++)
|
||||||
[self paintVertex:i :planet_seed];
|
[self paintVertex:i :planet_seed];
|
||||||
|
|
||||||
// NSLog(@"DEBUG atmosphere scaling %d vertices", next_free_vertex);
|
|
||||||
[self scaleVertices];
|
[self scaleVertices];
|
||||||
|
|
||||||
// set speed of rotation
|
// set speed of rotation
|
||||||
@ -428,7 +425,7 @@ void setUpSinTable()
|
|||||||
NSMutableDictionary* planetinfo = [NSMutableDictionary dictionaryWithDictionary:[uni generateSystemData:p_seed]];
|
NSMutableDictionary* planetinfo = [NSMutableDictionary dictionaryWithDictionary:[uni generateSystemData:p_seed]];
|
||||||
int radius_km = [(NSNumber *)[planetinfo objectForKey:KEY_RADIUS] intValue];
|
int radius_km = [(NSNumber *)[planetinfo objectForKey:KEY_RADIUS] intValue];
|
||||||
int techlevel = [(NSNumber *)[planetinfo objectForKey:KEY_TECHLEVEL] intValue];
|
int techlevel = [(NSNumber *)[planetinfo objectForKey:KEY_TECHLEVEL] intValue];
|
||||||
//NSLog(@"Generating planet %@ with radius %dkm",[planetinfo objectForKey:KEY_NAME],radius_km);
|
|
||||||
if ([planetinfo objectForKey:@"texture"])
|
if ([planetinfo objectForKey:@"texture"])
|
||||||
{
|
{
|
||||||
textureName = [TextureStore getTextureNameFor:(NSString*)[planetinfo objectForKey:@"texture"]];
|
textureName = [TextureStore getTextureNameFor:(NSString*)[planetinfo objectForKey:@"texture"]];
|
||||||
@ -441,8 +438,6 @@ void setUpSinTable()
|
|||||||
last_launch_time = -(ranrot_rand() % 60) * shuttle_launch_interval/60.0;
|
last_launch_time = -(ranrot_rand() % 60) * shuttle_launch_interval/60.0;
|
||||||
last_launch_time = 30.0 - shuttle_launch_interval; // debug - launch 30s after player enters universe
|
last_launch_time = 30.0 - shuttle_launch_interval; // debug - launch 30s after player enters universe
|
||||||
|
|
||||||
//NSLog(@"shuttles on ground:%d launch_interval:%.1f minutes", shuttles_on_ground, shuttle_launch_interval/60);
|
|
||||||
|
|
||||||
//collision_radius = 25000.0; // 25km across
|
//collision_radius = 25000.0; // 25km across
|
||||||
collision_radius = radius_km * 10.0; // scale down by a factor of 100 !
|
collision_radius = radius_km * 10.0; // scale down by a factor of 100 !
|
||||||
//
|
//
|
||||||
@ -474,8 +469,7 @@ void setUpSinTable()
|
|||||||
|
|
||||||
// save the current random number generator seed
|
// save the current random number generator seed
|
||||||
RNG_Seed saved_seed = currentRandomSeed();
|
RNG_Seed saved_seed = currentRandomSeed();
|
||||||
|
|
||||||
//NSLog(@"Planet surface is %d percent land.",percent_land);
|
|
||||||
for (i = 0; i < n_vertices; i++)
|
for (i = 0; i < n_vertices; i++)
|
||||||
{
|
{
|
||||||
if (gen_rnd_number() < 256 * percent_land / 100)
|
if (gen_rnd_number() < 256 * percent_land / 100)
|
||||||
@ -560,19 +554,15 @@ void setUpSinTable()
|
|||||||
shader_program = nil;
|
shader_program = nil;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSLog(@"DEBUG testing [PlanetEntity initialiseBaseVertexArray]");
|
|
||||||
[self initialiseBaseVertexArray];
|
[self initialiseBaseVertexArray];
|
||||||
|
|
||||||
// NSLog(@"DEBUG testing [PlanetEntity initialiseBaseTerrainArray:%d]", percent_land);
|
|
||||||
setRandomSeed(saved_seed);
|
setRandomSeed(saved_seed);
|
||||||
[self initialiseBaseTerrainArray:percent_land];
|
[self initialiseBaseTerrainArray:percent_land];
|
||||||
|
|
||||||
// NSLog(@"DEBUG painting %d vertices", next_free_vertex);
|
|
||||||
for (i = 0; i < next_free_vertex; i++)
|
for (i = 0; i < next_free_vertex; i++)
|
||||||
[self paintVertex:i :planet_seed];
|
[self paintVertex:i :planet_seed];
|
||||||
|
|
||||||
// NSLog(@"DEBUG scaling %d vertices", next_free_vertex);
|
|
||||||
[self scaleVertices];
|
[self scaleVertices];
|
||||||
|
|
||||||
// set speed of rotation
|
// set speed of rotation
|
||||||
@ -617,8 +607,6 @@ void setUpSinTable()
|
|||||||
last_launch_time = 8400.0;
|
last_launch_time = 8400.0;
|
||||||
shuttle_launch_interval = 8400.0;
|
shuttle_launch_interval = 8400.0;
|
||||||
|
|
||||||
//NSLog(@"shuttles on ground:%d launch_interval:%.1f minutes", shuttles_on_ground, shuttle_launch_interval/60);
|
|
||||||
|
|
||||||
collision_radius = [planet collisionRadius] * PLANET_MINIATURE_FACTOR; // teeny tiny
|
collision_radius = [planet collisionRadius] * PLANET_MINIATURE_FACTOR; // teeny tiny
|
||||||
//
|
//
|
||||||
scan_class = CLASS_NO_DRAW;
|
scan_class = CLASS_NO_DRAW;
|
||||||
@ -743,8 +731,6 @@ void setUpSinTable()
|
|||||||
shuttle_launch_interval = 3600.0 / shuttles_on_ground; // all are launched in an hour
|
shuttle_launch_interval = 3600.0 / shuttles_on_ground; // all are launched in an hour
|
||||||
last_launch_time = 3600.0;
|
last_launch_time = 3600.0;
|
||||||
|
|
||||||
//NSLog(@"shuttles on ground:%d launch_interval:%.1f minutes", shuttles_on_ground, shuttle_launch_interval/60);
|
|
||||||
|
|
||||||
collision_radius = radius_km * 10.0; // scale down by a factor of 100 !
|
collision_radius = radius_km * 10.0; // scale down by a factor of 100 !
|
||||||
//
|
//
|
||||||
scan_class = CLASS_NO_DRAW;
|
scan_class = CLASS_NO_DRAW;
|
||||||
@ -774,8 +760,7 @@ void setUpSinTable()
|
|||||||
|
|
||||||
// save the current random number generator seed
|
// save the current random number generator seed
|
||||||
RNG_Seed saved_seed = currentRandomSeed();
|
RNG_Seed saved_seed = currentRandomSeed();
|
||||||
|
|
||||||
//NSLog(@"Planet surface is %d percent land.",percent_land);
|
|
||||||
for (i = 0; i < n_vertices; i++)
|
for (i = 0; i < n_vertices; i++)
|
||||||
{
|
{
|
||||||
if (gen_rnd_number() < 256 * percent_land / 100)
|
if (gen_rnd_number() < 256 * percent_land / 100)
|
||||||
@ -829,19 +814,15 @@ void setUpSinTable()
|
|||||||
amb_polar_sea[1] = [[OOColor colorWithCalibratedHue:sea_polar_hsb.x saturation:sea_polar_hsb.y brightness:sea_polar_hsb.z alpha:1.0] blueComponent];
|
amb_polar_sea[1] = [[OOColor colorWithCalibratedHue:sea_polar_hsb.x saturation:sea_polar_hsb.y brightness:sea_polar_hsb.z alpha:1.0] blueComponent];
|
||||||
amb_polar_sea[2] = [[OOColor colorWithCalibratedHue:sea_polar_hsb.x saturation:sea_polar_hsb.y brightness:sea_polar_hsb.z alpha:1.0] greenComponent];
|
amb_polar_sea[2] = [[OOColor colorWithCalibratedHue:sea_polar_hsb.x saturation:sea_polar_hsb.y brightness:sea_polar_hsb.z alpha:1.0] greenComponent];
|
||||||
amb_polar_sea[3] = 1.0;
|
amb_polar_sea[3] = 1.0;
|
||||||
|
|
||||||
// NSLog(@"DEBUG testing [PlanetEntity initialiseBaseVertexArray]");
|
|
||||||
[self initialiseBaseVertexArray];
|
[self initialiseBaseVertexArray];
|
||||||
|
|
||||||
// NSLog(@"DEBUG testing [PlanetEntity initialiseBaseTerrainArray:%d]", percent_land);
|
|
||||||
setRandomSeed(saved_seed);
|
setRandomSeed(saved_seed);
|
||||||
[self initialiseBaseTerrainArray:percent_land];
|
[self initialiseBaseTerrainArray:percent_land];
|
||||||
|
|
||||||
// NSLog(@"DEBUG painting %d vertices", next_free_vertex);
|
|
||||||
for (i = 0; i < next_free_vertex; i++)
|
for (i = 0; i < next_free_vertex; i++)
|
||||||
[self paintVertex:i :planet_seed];
|
[self paintVertex:i :planet_seed];
|
||||||
|
|
||||||
// NSLog(@"DEBUG scaling %d vertices", next_free_vertex);
|
|
||||||
[self scaleVertices];
|
[self scaleVertices];
|
||||||
|
|
||||||
// set speed of rotation
|
// set speed of rotation
|
||||||
@ -923,8 +904,6 @@ void setUpSinTable()
|
|||||||
shuttle_launch_interval = 3600.0 / shuttles_on_ground; // all are launched in an hour
|
shuttle_launch_interval = 3600.0 / shuttles_on_ground; // all are launched in an hour
|
||||||
last_launch_time = 3600.0;
|
last_launch_time = 3600.0;
|
||||||
|
|
||||||
//NSLog(@"shuttles on ground:%d launch_interval:%.1f minutes", shuttles_on_ground, shuttle_launch_interval/60);
|
|
||||||
|
|
||||||
collision_radius = radius_km * 10.0; // scale down by a factor of 100 !
|
collision_radius = radius_km * 10.0; // scale down by a factor of 100 !
|
||||||
//
|
//
|
||||||
scan_class = CLASS_NO_DRAW;
|
scan_class = CLASS_NO_DRAW;
|
||||||
@ -954,8 +933,7 @@ void setUpSinTable()
|
|||||||
|
|
||||||
// save the current random number generator seed
|
// save the current random number generator seed
|
||||||
RNG_Seed saved_seed = currentRandomSeed();
|
RNG_Seed saved_seed = currentRandomSeed();
|
||||||
|
|
||||||
//NSLog(@"Planet surface is %d percent land.",percent_land);
|
|
||||||
for (i = 0; i < n_vertices; i++)
|
for (i = 0; i < n_vertices; i++)
|
||||||
{
|
{
|
||||||
if (gen_rnd_number() < 256 * percent_land / 100)
|
if (gen_rnd_number() < 256 * percent_land / 100)
|
||||||
@ -1009,19 +987,15 @@ void setUpSinTable()
|
|||||||
amb_polar_sea[1] = [[OOColor colorWithCalibratedHue:sea_polar_hsb.x saturation:sea_polar_hsb.y brightness:sea_polar_hsb.z alpha:1.0] blueComponent];
|
amb_polar_sea[1] = [[OOColor colorWithCalibratedHue:sea_polar_hsb.x saturation:sea_polar_hsb.y brightness:sea_polar_hsb.z alpha:1.0] blueComponent];
|
||||||
amb_polar_sea[2] = [[OOColor colorWithCalibratedHue:sea_polar_hsb.x saturation:sea_polar_hsb.y brightness:sea_polar_hsb.z alpha:1.0] greenComponent];
|
amb_polar_sea[2] = [[OOColor colorWithCalibratedHue:sea_polar_hsb.x saturation:sea_polar_hsb.y brightness:sea_polar_hsb.z alpha:1.0] greenComponent];
|
||||||
amb_polar_sea[3] = 1.0;
|
amb_polar_sea[3] = 1.0;
|
||||||
|
|
||||||
// NSLog(@"DEBUG testing [PlanetEntity initialiseBaseVertexArray]");
|
|
||||||
[self initialiseBaseVertexArray];
|
[self initialiseBaseVertexArray];
|
||||||
|
|
||||||
// NSLog(@"DEBUG testing [PlanetEntity initialiseBaseTerrainArray:%d]", percent_land);
|
|
||||||
setRandomSeed(saved_seed);
|
setRandomSeed(saved_seed);
|
||||||
[self initialiseBaseTerrainArray:percent_land];
|
[self initialiseBaseTerrainArray:percent_land];
|
||||||
|
|
||||||
// NSLog(@"DEBUG painting %d vertices", next_free_vertex);
|
|
||||||
for (i = 0; i < next_free_vertex; i++)
|
for (i = 0; i < next_free_vertex; i++)
|
||||||
[self paintVertex:i :planet_seed];
|
[self paintVertex:i :planet_seed];
|
||||||
|
|
||||||
// NSLog(@"DEBUG scaling %d vertices", next_free_vertex);
|
|
||||||
[self scaleVertices];
|
[self scaleVertices];
|
||||||
|
|
||||||
// set speed of rotation
|
// set speed of rotation
|
||||||
@ -1190,7 +1164,7 @@ void setUpSinTable()
|
|||||||
case PLANET_TYPE_SUN :
|
case PLANET_TYPE_SUN :
|
||||||
{
|
{
|
||||||
// new billboard routine (working at last!)
|
// new billboard routine (working at last!)
|
||||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||||
Vector v0 = position;
|
Vector v0 = position;
|
||||||
Vector p0 = (player)? player->position: make_vector( 0.0f, 0.0f, 0.0f);
|
Vector p0 = (player)? player->position: make_vector( 0.0f, 0.0f, 0.0f);
|
||||||
v0.x -= p0.x; v0.y -= p0.y; v0.z -= p0.z; // vector from player to position
|
v0.x -= p0.x; v0.y -= p0.y; v0.z -= p0.z; // vector from player to position
|
||||||
@ -1307,7 +1281,6 @@ void setUpSinTable()
|
|||||||
double old_collision_radius = collision_radius;
|
double old_collision_radius = collision_radius;
|
||||||
[super setModel:modelName];
|
[super setModel:modelName];
|
||||||
collision_radius = old_collision_radius; // preserve the radius
|
collision_radius = old_collision_radius; // preserve the radius
|
||||||
//NSLog(@"Planet collision radius preserved!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1496,7 +1469,6 @@ void setUpSinTable()
|
|||||||
displayListNames[subdivideLevel] = glGenLists(1);
|
displayListNames[subdivideLevel] = glGenLists(1);
|
||||||
if (displayListNames[subdivideLevel] != 0) // sanity check
|
if (displayListNames[subdivideLevel] != 0) // sanity check
|
||||||
{
|
{
|
||||||
//NSLog(@"Generating planet data for subdivide %d",subdivideLevel);
|
|
||||||
glNewList(displayListNames[subdivideLevel], GL_COMPILE);
|
glNewList(displayListNames[subdivideLevel], GL_COMPILE);
|
||||||
//
|
//
|
||||||
glColor4fv(mat1);
|
glColor4fv(mat1);
|
||||||
@ -1672,8 +1644,6 @@ void drawCorona (double inner_radius, double outer_radius, int step, double z_di
|
|||||||
GLfloat r0 = c * x / z;
|
GLfloat r0 = c * x / z;
|
||||||
GLfloat z0 = c * r / z;
|
GLfloat z0 = c * r / z;
|
||||||
|
|
||||||
// NSLog(@"DEBUG r1 = %.4f z1 = %.4f r0 = %.4f z0 = %.4f", r1, z1, r0, z0);
|
|
||||||
|
|
||||||
glBegin(GL_TRIANGLE_STRIP);
|
glBegin(GL_TRIANGLE_STRIP);
|
||||||
for ( i = 0; i < 360; i += step )
|
for ( i = 0; i < 360; i += step )
|
||||||
{
|
{
|
||||||
@ -1714,8 +1684,6 @@ void drawActiveCorona (double inner_radius, double outer_radius, int step, doubl
|
|||||||
GLfloat r0 = c * x / z;
|
GLfloat r0 = c * x / z;
|
||||||
GLfloat z0 = c * r / z;
|
GLfloat z0 = c * r / z;
|
||||||
|
|
||||||
// NSLog(@"DEBUG r1 = %.4f z1 = %.4f r0 = %.4f z0 = %.4f", r1, z1, r0, z0);
|
|
||||||
|
|
||||||
GLfloat rv0, rv1, rv2;
|
GLfloat rv0, rv1, rv2;
|
||||||
|
|
||||||
glBegin(GL_TRIANGLE_STRIP);
|
glBegin(GL_TRIANGLE_STRIP);
|
||||||
@ -1858,7 +1826,7 @@ void drawActiveCorona (double inner_radius, double outer_radius, int step, doubl
|
|||||||
launch_pos.y += start_distance * vf.y;
|
launch_pos.y += start_distance * vf.y;
|
||||||
launch_pos.z += start_distance * vf.z;
|
launch_pos.z += start_distance * vf.z;
|
||||||
|
|
||||||
shuttle_ship = [universe getShipWithRole:@"shuttle"]; // retain count = 1
|
shuttle_ship = [universe newShipWithRole:@"shuttle"]; // retain count = 1
|
||||||
if (shuttle_ship)
|
if (shuttle_ship)
|
||||||
{
|
{
|
||||||
if (![shuttle_ship crew])
|
if (![shuttle_ship crew])
|
||||||
@ -1881,8 +1849,6 @@ void drawActiveCorona (double inner_radius, double outer_radius, int step, doubl
|
|||||||
[universe addEntity:shuttle_ship];
|
[universe addEntity:shuttle_ship];
|
||||||
[[shuttle_ship getAI] setStateMachine:@"risingShuttleAI.plist"]; // must happen after adding to the universe!
|
[[shuttle_ship getAI] setStateMachine:@"risingShuttleAI.plist"]; // must happen after adding to the universe!
|
||||||
|
|
||||||
//NSLog(@"Planet %@ in universe %@ Launching shuttle: %@ %d", self, universe, [shuttle_ship name], [shuttle_ship universal_id]);
|
|
||||||
|
|
||||||
[shuttle_ship release];
|
[shuttle_ship release];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1912,11 +1878,6 @@ static BOOL last_one_was_textured;
|
|||||||
last_one_was_textured = isTextured;
|
last_one_was_textured = isTextured;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (isTextured)
|
|
||||||
// NSLog(@"DEBUG %@ creating textured vertex data texture_uv_array = <%x>", self, texture_uv_array);
|
|
||||||
// else
|
|
||||||
// NSLog(@"DEBUG %@ creating plain vertex data", self);
|
|
||||||
|
|
||||||
if (edge_to_vertex == nil)
|
if (edge_to_vertex == nil)
|
||||||
{
|
{
|
||||||
edge_to_vertex = [[NSMutableDictionary dictionaryWithCapacity:7680] retain]; // make a new one
|
edge_to_vertex = [[NSMutableDictionary dictionaryWithCapacity:7680] retain]; // make a new one
|
||||||
@ -1957,9 +1918,6 @@ static BOOL last_one_was_textured;
|
|||||||
int newlevel = sublevel + 1;
|
int newlevel = sublevel + 1;
|
||||||
triangle_start[newlevel] = triangle_start[sublevel] + n_triangles[sublevel] * 3;
|
triangle_start[newlevel] = triangle_start[sublevel] + n_triangles[sublevel] * 3;
|
||||||
n_triangles[newlevel] = n_triangles[sublevel] * 4;
|
n_triangles[newlevel] = n_triangles[sublevel] * 4;
|
||||||
//
|
|
||||||
|
|
||||||
// NSLog(@"Building new level of subdivision - level %d.", newlevel);
|
|
||||||
|
|
||||||
int tri;
|
int tri;
|
||||||
for (tri = 0; tri < n_triangles[sublevel]; tri++)
|
for (tri = 0; tri < n_triangles[sublevel]; tri++)
|
||||||
@ -1989,13 +1947,9 @@ static BOOL last_one_was_textured;
|
|||||||
vertex_index_array[triangle_start[newlevel] + tri * 12 +11] = v20;
|
vertex_index_array[triangle_start[newlevel] + tri * 12 +11] = v20;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSLog(@"Current total number of vertices %d.", next_free_vertex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSLog(@"edge_to_vertex %@", edge_to_vertex);
|
|
||||||
|
|
||||||
// all done - copy the indices to the instance
|
// all done - copy the indices to the instance
|
||||||
//
|
//
|
||||||
for (i = 0; i < MAX_TRI_INDICES; i++)
|
for (i = 0; i < MAX_TRI_INDICES; i++)
|
||||||
@ -2024,8 +1978,6 @@ int baseVertexIndexForEdge(int va, int vb, BOOL textured)
|
|||||||
base_vertex_array[vindex].z += base_vertex_array[vb].z;
|
base_vertex_array[vindex].z += base_vertex_array[vb].z;
|
||||||
base_vertex_array[vindex] = unit_vector(&base_vertex_array[vindex]); // guaranteed non-zero
|
base_vertex_array[vindex] = unit_vector(&base_vertex_array[vindex]); // guaranteed non-zero
|
||||||
|
|
||||||
// NSLog(@"%d [%@]= (%.3f,%.3f,%.3f)", vindex, key, base_vertex_array[vindex].x, base_vertex_array[vindex].y, base_vertex_array[vindex].z);
|
|
||||||
|
|
||||||
if (textured)
|
if (textured)
|
||||||
{
|
{
|
||||||
//calculate new texture coordinates
|
//calculate new texture coordinates
|
||||||
@ -2221,8 +2173,6 @@ double longitudeFromVector(Vector v)
|
|||||||
// No over-ride of Entity's version of the method is required for non-Win32 platforms.
|
// No over-ride of Entity's version of the method is required for non-Win32 platforms.
|
||||||
- (void) reloadTextures
|
- (void) reloadTextures
|
||||||
{
|
{
|
||||||
//NSLog(@"PlanetEntity::reloadTextures called, clearing planet draw lists and calling super");
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
// Clear out the planet's various detail level display lists.
|
// Clear out the planet's various detail level display lists.
|
||||||
for (i = 0; i < MAX_SUBDIVIDE; i++)
|
for (i = 0; i < MAX_SUBDIVIDE; i++)
|
||||||
|
@ -57,6 +57,9 @@ MA 02110-1301, USA.
|
|||||||
#import "PlayerEntityStickMapper.h"
|
#import "PlayerEntityStickMapper.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.PlayerEntity"
|
||||||
|
|
||||||
|
|
||||||
// 10m/s forward drift
|
// 10m/s forward drift
|
||||||
#define OG_ELITE_FORWARD_DRIFT 10.0f
|
#define OG_ELITE_FORWARD_DRIFT 10.0f
|
||||||
|
|
||||||
@ -270,8 +273,6 @@ static PlayerEntity *sSharedPlayer = nil;
|
|||||||
co_type = [(ShipEntity *)[cargoArray objectAtIndex:i] getCommodityType];
|
co_type = [(ShipEntity *)[cargoArray objectAtIndex:i] getCommodityType];
|
||||||
co_amount = [(ShipEntity *)[cargoArray objectAtIndex:i] getCommodityAmount];
|
co_amount = [(ShipEntity *)[cargoArray objectAtIndex:i] getCommodityAmount];
|
||||||
|
|
||||||
// NSLog(@"unloading a %@ with %@", [(ShipEntity *)[cargoArray objectAtIndex:i] name], [universe describeCommodity:co_type amount:co_amount]);
|
|
||||||
|
|
||||||
commodityInfo = (NSMutableArray *)[manifest objectAtIndex:co_type];
|
commodityInfo = (NSMutableArray *)[manifest objectAtIndex:co_type];
|
||||||
quantity = [(NSNumber *)[commodityInfo objectAtIndex:MARKET_QUANTITY] intValue] + co_amount;
|
quantity = [(NSNumber *)[commodityInfo objectAtIndex:MARKET_QUANTITY] intValue] + co_amount;
|
||||||
|
|
||||||
@ -302,17 +303,14 @@ static PlayerEntity *sSharedPlayer = nil;
|
|||||||
NSMutableArray* commodityInfo = [[NSMutableArray arrayWithArray:(NSArray *)[manifest objectAtIndex:i]] retain]; // retain
|
NSMutableArray* commodityInfo = [[NSMutableArray arrayWithArray:(NSArray *)[manifest objectAtIndex:i]] retain]; // retain
|
||||||
int quantity = [(NSNumber *)[commodityInfo objectAtIndex:MARKET_QUANTITY] intValue];
|
int quantity = [(NSNumber *)[commodityInfo objectAtIndex:MARKET_QUANTITY] intValue];
|
||||||
int units = [universe unitsForCommodity:i];
|
int units = [universe unitsForCommodity:i];
|
||||||
// NSLog(@"DEBUG Commodity index:%d %@ units:%d", i, [commodityInfo objectAtIndex:MARKET_NAME], units);
|
|
||||||
if (quantity > 0)
|
if (quantity > 0)
|
||||||
{
|
{
|
||||||
//NSLog(@"loading containers with %@",[universe describeCommodity:i amount:quantity]);
|
|
||||||
|
|
||||||
if (units == UNITS_TONS)
|
if (units == UNITS_TONS)
|
||||||
{
|
{
|
||||||
// put each ton in a separate container
|
// put each ton in a separate container
|
||||||
for (j = 0; j < quantity; j++)
|
for (j = 0; j < quantity; j++)
|
||||||
{
|
{
|
||||||
ShipEntity* container = [universe getShipWithRole:@"1t-cargopod"];
|
ShipEntity* container = [universe newShipWithRole:@"1t-cargopod"];
|
||||||
if (container)
|
if (container)
|
||||||
{
|
{
|
||||||
[container setUniverse:universe];
|
[container setUniverse:universe];
|
||||||
@ -326,11 +324,8 @@ static PlayerEntity *sSharedPlayer = nil;
|
|||||||
{
|
{
|
||||||
NSLog(@"***** ERROR couldn't find a container while trying to [PlayerEntity loadCargoPods] *****");
|
NSLog(@"***** ERROR couldn't find a container while trying to [PlayerEntity loadCargoPods] *****");
|
||||||
// throw an exception here...
|
// throw an exception here...
|
||||||
NSException* myException = [NSException
|
[NSException raise:OOLITE_EXCEPTION_FATAL
|
||||||
exceptionWithName: OOLITE_EXCEPTION_FATAL
|
format:@"[PlayerEntity loadCargoPods] failed to create a container for cargo with role 'cargopod'"];
|
||||||
reason:@"[PlayerEntity loadCargoPods] failed to create a container for cargo with role 'cargopod'"
|
|
||||||
userInfo:nil];
|
|
||||||
[myException raise];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// zero this commodity
|
// zero this commodity
|
||||||
@ -537,11 +532,6 @@ static PlayerEntity *sSharedPlayer = nil;
|
|||||||
//set checksum
|
//set checksum
|
||||||
[result setObject:[NSNumber numberWithInt:final_checksum] forKey:@"checksum"];
|
[result setObject:[NSNumber numberWithInt:final_checksum] forKey:@"checksum"];
|
||||||
|
|
||||||
//NSLog(@"Player Dictionary :\n%@",[result description]);
|
|
||||||
|
|
||||||
//DEBUG TEST
|
|
||||||
// NSLog(@"DEBUG TESTING OOXML Export Dictionary:-\n%@", [result OOXMLdescription]);
|
|
||||||
|
|
||||||
return [NSDictionary dictionaryWithDictionary:[result autorelease]];
|
return [NSDictionary dictionaryWithDictionary:[result autorelease]];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -879,7 +869,7 @@ static PlayerEntity *sSharedPlayer = nil;
|
|||||||
NSString* missile_desc = (NSString*)[missile_roles objectAtIndex:i];
|
NSString* missile_desc = (NSString*)[missile_roles objectAtIndex:i];
|
||||||
if (![missile_desc isEqual:@"NONE"])
|
if (![missile_desc isEqual:@"NONE"])
|
||||||
{
|
{
|
||||||
ShipEntity* amiss = [universe getShipWithRole:missile_desc];
|
ShipEntity* amiss = [universe newShipWithRole:missile_desc];
|
||||||
if (amiss)
|
if (amiss)
|
||||||
missile_entity[i] = amiss; // retain count = 1
|
missile_entity[i] = amiss; // retain count = 1
|
||||||
else
|
else
|
||||||
@ -898,7 +888,7 @@ static PlayerEntity *sSharedPlayer = nil;
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; i < missiles; i++)
|
for (i = 0; i < missiles; i++)
|
||||||
missile_entity[i] = [universe getShipWithRole:@"EQ_MISSILE"]; // retain count = 1 - should be okay as long as we keep a missile with this role
|
missile_entity[i] = [universe newShipWithRole:@"EQ_MISSILE"]; // retain count = 1 - should be okay as long as we keep a missile with this role
|
||||||
// in the base package.
|
// in the base package.
|
||||||
}
|
}
|
||||||
while ((missiles > 0)&&(missile_entity[active_missile] == nil))
|
while ((missiles > 0)&&(missile_entity[active_missile] == nil))
|
||||||
@ -1168,7 +1158,7 @@ static PlayerEntity *sSharedPlayer = nil;
|
|||||||
{
|
{
|
||||||
if (missile_entity[i])
|
if (missile_entity[i])
|
||||||
[missile_entity[i] release];
|
[missile_entity[i] release];
|
||||||
missile_entity[i] = [universe getShipWithRole:@"EQ_MISSILE"]; // retain count = 1
|
missile_entity[i] = [universe newShipWithRole:@"EQ_MISSILE"]; // retain count = 1
|
||||||
}
|
}
|
||||||
[self safe_all_missiles];
|
[self safe_all_missiles];
|
||||||
|
|
||||||
@ -1225,8 +1215,6 @@ static PlayerEntity *sSharedPlayer = nil;
|
|||||||
if (shipinfoDictionary)
|
if (shipinfoDictionary)
|
||||||
[shipinfoDictionary release];
|
[shipinfoDictionary release];
|
||||||
shipinfoDictionary = [[NSDictionary alloc] initWithDictionary:dict]; // retained
|
shipinfoDictionary = [[NSDictionary alloc] initWithDictionary:dict]; // retained
|
||||||
|
|
||||||
//NSLog(@"DEBUG Playerentity - setUpShipFromDictionary:(NSDictionary *) dict");
|
|
||||||
|
|
||||||
// set things from dictionary from here out
|
// set things from dictionary from here out
|
||||||
|
|
||||||
@ -1337,13 +1325,11 @@ static PlayerEntity *sSharedPlayer = nil;
|
|||||||
|
|
||||||
if ([dict objectForKey:@"max_missiles"])
|
if ([dict objectForKey:@"max_missiles"])
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG setting max_missiles %@",[dict objectForKey:@"max_missiles"]);
|
|
||||||
max_missiles = [(NSNumber *)[dict objectForKey:@"max_missiles"] intValue];
|
max_missiles = [(NSNumber *)[dict objectForKey:@"max_missiles"] intValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([dict objectForKey:@"hud"])
|
if ([dict objectForKey:@"hud"])
|
||||||
{
|
{
|
||||||
//NSLog(@"DEBUG setting hud %@",[dict objectForKey:@"hud"]);
|
|
||||||
NSString *hud_desc = (NSString *)[dict objectForKey:@"hud"];
|
NSString *hud_desc = (NSString *)[dict objectForKey:@"hud"];
|
||||||
NSDictionary *huddict = [ResourceManager dictionaryFromFilesNamed:hud_desc inFolder:@"Config" andMerge:YES];
|
NSDictionary *huddict = [ResourceManager dictionaryFromFilesNamed:hud_desc inFolder:@"Config" andMerge:YES];
|
||||||
if (huddict)
|
if (huddict)
|
||||||
@ -1366,7 +1352,7 @@ static PlayerEntity *sSharedPlayer = nil;
|
|||||||
missile_entity[i] = nil;
|
missile_entity[i] = nil;
|
||||||
}
|
}
|
||||||
for (i = 0; i < missiles; i++)
|
for (i = 0; i < missiles; i++)
|
||||||
missile_entity[i] = [universe getShipWithRole:@"EQ_MISSILE"]; // retain count = 1
|
missile_entity[i] = [universe newShipWithRole:@"EQ_MISSILE"]; // retain count = 1
|
||||||
[self setActive_missile: 0];
|
[self setActive_missile: 0];
|
||||||
|
|
||||||
|
|
||||||
@ -1458,7 +1444,7 @@ static PlayerEntity *sSharedPlayer = nil;
|
|||||||
{
|
{
|
||||||
quaternion_normalise(&sub_q);
|
quaternion_normalise(&sub_q);
|
||||||
|
|
||||||
subent = [universe getShip:subdesc]; // retained
|
subent = [universe newShipWithName:subdesc]; // retained
|
||||||
|
|
||||||
if (subent)
|
if (subent)
|
||||||
{
|
{
|
||||||
@ -1545,14 +1531,10 @@ static PlayerEntity *sSharedPlayer = nil;
|
|||||||
|
|
||||||
- (void) warnAboutHostiles
|
- (void) warnAboutHostiles
|
||||||
{
|
{
|
||||||
// make a warningSound
|
[self playHostileWarning];
|
||||||
// NSLog(@"player warned about hostiles!");
|
|
||||||
#ifdef HAVE_SOUND
|
|
||||||
if (![warningSound isPlaying])
|
|
||||||
[warningSound play];
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (BOOL) canCollide
|
- (BOOL) canCollide
|
||||||
{
|
{
|
||||||
switch (status)
|
switch (status)
|
||||||
@ -1742,9 +1724,9 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
witchspaceCountdown -= delta_t;
|
witchspaceCountdown -= delta_t;
|
||||||
if (witchspaceCountdown < 0.0) witchspaceCountdown = 0.0;
|
if (witchspaceCountdown < 0.0) witchspaceCountdown = 0.0;
|
||||||
if (galactic_witchjump)
|
if (galactic_witchjump)
|
||||||
[universe displayCountdownMessage:[NSString stringWithFormat:[universe expandDescription:@"[witch-galactic-in-f-seconds]" forSystem:system_seed], witchspaceCountdown] forCount:1.0];
|
[universe displayCountdownMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[witch-galactic-in-f-seconds]"), witchspaceCountdown] forCount:1.0];
|
||||||
else
|
else
|
||||||
[universe displayCountdownMessage:[NSString stringWithFormat:[universe expandDescription:@"[witch-to-@-in-f-seconds]" forSystem:system_seed], [universe getSystemName:target_system_seed], witchspaceCountdown] forCount:1.0];
|
[universe displayCountdownMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[witch-to-@-in-f-seconds]"), [universe getSystemName:target_system_seed], witchspaceCountdown] forCount:1.0];
|
||||||
if (witchspaceCountdown == 0.0)
|
if (witchspaceCountdown == 0.0)
|
||||||
{
|
{
|
||||||
BOOL go = YES;
|
BOOL go = YES;
|
||||||
@ -1754,7 +1736,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
if (blocker)
|
if (blocker)
|
||||||
{
|
{
|
||||||
[universe clearPreviousMessage];
|
[universe clearPreviousMessage];
|
||||||
[universe addMessage:[NSString stringWithFormat:[universe expandDescription:@"[witch-blocked-by-@]" forSystem:system_seed], [blocker name]] forCount: 4.5];
|
[universe addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[witch-blocked-by-@]"), [blocker name]] forCount: 4.5];
|
||||||
if (![universe playCustomSound:@"[witch-blocked-by-@]"])
|
if (![universe playCustomSound:@"[witch-blocked-by-@]"])
|
||||||
[witchAbortSound play];
|
[witchAbortSound play];
|
||||||
status = STATUS_IN_FLIGHT;
|
status = STATUS_IN_FLIGHT;
|
||||||
@ -1769,7 +1751,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
if (jump_distance > 7.0)
|
if (jump_distance > 7.0)
|
||||||
{
|
{
|
||||||
[universe clearPreviousMessage];
|
[universe clearPreviousMessage];
|
||||||
[universe addMessage:[universe expandDescription:@"[witch-too-far]" forSystem:system_seed] forCount: 4.5];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[witch-too-far]") forCount: 4.5];
|
||||||
if (![universe playCustomSound:@"[witch-too-far]"])
|
if (![universe playCustomSound:@"[witch-too-far]"])
|
||||||
[witchAbortSound play];
|
[witchAbortSound play];
|
||||||
status = STATUS_IN_FLIGHT;
|
status = STATUS_IN_FLIGHT;
|
||||||
@ -1784,7 +1766,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
if (fuel < fuel_required)
|
if (fuel < fuel_required)
|
||||||
{
|
{
|
||||||
[universe clearPreviousMessage];
|
[universe clearPreviousMessage];
|
||||||
[universe addMessage:[universe expandDescription:@"[witch-no-fuel]" forSystem:system_seed] forCount: 4.5];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[witch-no-fuel]") forCount: 4.5];
|
||||||
if (![universe playCustomSound:@"[witch-no-fuel]"])
|
if (![universe playCustomSound:@"[witch-no-fuel]"])
|
||||||
[witchAbortSound play];
|
[witchAbortSound play];
|
||||||
status = STATUS_IN_FLIGHT;
|
status = STATUS_IN_FLIGHT;
|
||||||
@ -1817,7 +1799,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
if ([universe planet])
|
if ([universe planet])
|
||||||
[universe addMessage:[NSString stringWithFormat:@" %@. ",[universe getSystemName:system_seed]] forCount:3.0];
|
[universe addMessage:[NSString stringWithFormat:@" %@. ",[universe getSystemName:system_seed]] forCount:3.0];
|
||||||
else
|
else
|
||||||
[universe addMessage:[universe expandDescription:@"[witch-engine-malfunction]" forSystem:system_seed] forCount:3.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[witch-engine-malfunction]") forCount:3.0];
|
||||||
|
|
||||||
status = STATUS_IN_FLIGHT;
|
status = STATUS_IN_FLIGHT;
|
||||||
}
|
}
|
||||||
@ -1852,7 +1834,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
{
|
{
|
||||||
if (!suppressTargetLost)
|
if (!suppressTargetLost)
|
||||||
{
|
{
|
||||||
[universe addMessage:[universe expandDescription:@"[target-lost]" forSystem:system_seed] forCount:3.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[target-lost]") forCount:3.0];
|
||||||
if (![universe playCustomSound:@"[target-lost]"])
|
if (![universe playCustomSound:@"[target-lost]"])
|
||||||
[self boop];
|
[self boop];
|
||||||
}
|
}
|
||||||
@ -1880,7 +1862,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
ShipEntity* target_ship = (ShipEntity *)[missile_entity[i] getPrimaryTarget];
|
ShipEntity* target_ship = (ShipEntity *)[missile_entity[i] getPrimaryTarget];
|
||||||
if ((!target_ship)||(target_ship->zero_distance > SCANNER_MAX_RANGE2))
|
if ((!target_ship)||(target_ship->zero_distance > SCANNER_MAX_RANGE2))
|
||||||
{
|
{
|
||||||
[universe addMessage:[universe expandDescription:@"[target-lost]" forSystem:system_seed] forCount:3.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[target-lost]") forCount:3.0];
|
||||||
if (![universe playCustomSound:@"[target-lost]"])
|
if (![universe playCustomSound:@"[target-lost]"])
|
||||||
[self boop];
|
[self boop];
|
||||||
[missile_entity[i] removeTarget:nil];
|
[missile_entity[i] removeTarget:nil];
|
||||||
@ -1905,7 +1887,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
missile_status = MISSILE_STATUS_TARGET_LOCKED;
|
missile_status = MISSILE_STATUS_TARGET_LOCKED;
|
||||||
if ((missile_entity[active_missile])&&(!ident_engaged))
|
if ((missile_entity[active_missile])&&(!ident_engaged))
|
||||||
[missile_entity[active_missile] addTarget:first_target];
|
[missile_entity[active_missile] addTarget:first_target];
|
||||||
[universe addMessage:[NSString stringWithFormat:[universe expandDescription:@"[@-locked-onto-@]" forSystem:system_seed], (ident_engaged)? @"Ident system": @"Missile", [(ShipEntity *)first_target name]] forCount:4.5];
|
[universe addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[@-locked-onto-@]"), (ident_engaged)? @"Ident system": @"Missile", [(ShipEntity *)first_target name]] forCount:4.5];
|
||||||
if (ident_engaged)
|
if (ident_engaged)
|
||||||
{
|
{
|
||||||
if (![universe playCustomSound:@"[ident-locked-on]"])
|
if (![universe playCustomSound:@"[ident-locked-on]"])
|
||||||
@ -2056,8 +2038,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
{
|
{
|
||||||
ecm_in_operation = NO;
|
ecm_in_operation = NO;
|
||||||
[self stopECMSound];
|
[self stopECMSound];
|
||||||
//[universe displayMessage:@"ECM system deactivated (no energy left)." forCount:3.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[ecm-out-of-juice]") forCount:3.0];
|
||||||
[universe addMessage:[universe expandDescription:@"[ecm-out-of-juice]" forSystem:system_seed] forCount:3.0];
|
|
||||||
}
|
}
|
||||||
if ([universe getTime] > ecm_start_time + ECM_DURATION)
|
if ([universe getTime] > ecm_start_time + ECM_DURATION)
|
||||||
{
|
{
|
||||||
@ -2086,7 +2067,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
fuel_accumulator -= 1.0;
|
fuel_accumulator -= 1.0;
|
||||||
}
|
}
|
||||||
if (fuel > PLAYER_MAX_FUEL) fuel = PLAYER_MAX_FUEL;
|
if (fuel > PLAYER_MAX_FUEL) fuel = PLAYER_MAX_FUEL;
|
||||||
[universe displayCountdownMessage:[universe expandDescription:@"[fuel-scoop-active]" forSystem:system_seed] forCount:1.0];
|
[universe displayCountdownMessage:ExpandDescriptionForCurrentSystem(@"[fuel-scoop-active]") forCount:1.0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2115,7 +2096,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
if ([self getPrimaryTarget])
|
if ([self getPrimaryTarget])
|
||||||
{
|
{
|
||||||
// restore player ship
|
// restore player ship
|
||||||
ShipEntity *player_ship = [universe getShip: ship_desc]; // retained
|
ShipEntity *player_ship = [universe newShipWithName: ship_desc]; // retained
|
||||||
if (player_ship)
|
if (player_ship)
|
||||||
{
|
{
|
||||||
[self setModel:[player_ship getModel]];
|
[self setModel:[player_ship getModel]];
|
||||||
@ -2144,7 +2125,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
{
|
{
|
||||||
if (![universe playCustomSound:@"[jump-mass-locked]"])
|
if (![universe playCustomSound:@"[jump-mass-locked]"])
|
||||||
[self boop];
|
[self boop];
|
||||||
[universe addMessage:[universe expandDescription:@"[jump-mass-locked]" forSystem:system_seed] forCount:4.5];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[jump-mass-locked]") forCount:4.5];
|
||||||
hyperspeed_engaged = NO;
|
hyperspeed_engaged = NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2853,13 +2834,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
}
|
}
|
||||||
if ((alert_condition == ALERT_CONDITION_RED)&&(old_alert_condition < ALERT_CONDITION_RED))
|
if ((alert_condition == ALERT_CONDITION_RED)&&(old_alert_condition < ALERT_CONDITION_RED))
|
||||||
{
|
{
|
||||||
// give an audible warning
|
[self playAlertConditionRed];
|
||||||
// NSLog(@"WARNING! %d %x", alert_condition, alert_flags);
|
|
||||||
#ifdef HAVE_SOUND
|
|
||||||
if ([warningSound isPlaying])
|
|
||||||
[warningSound stop];
|
|
||||||
[warningSound play];
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alert_condition != old_alert_condition)
|
if (alert_condition != old_alert_condition)
|
||||||
@ -2877,34 +2852,27 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
{
|
{
|
||||||
if (![universe playCustomSound:@"[hold-full]"])
|
if (![universe playCustomSound:@"[hold-full]"])
|
||||||
[self beep];
|
[self beep];
|
||||||
[universe addMessage:[universe expandDescription:@"[hold-full]" forSystem:system_seed] forCount:4.5];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[hold-full]") forCount:4.5];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([ms isEqual:@"INCOMING_MISSILE"])
|
if ([ms isEqual:@"INCOMING_MISSILE"])
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SOUND
|
if (![universe playCustomSound:@"[incoming-missile]"]) [warningSound play];
|
||||||
if (![universe playCustomSound:@"[incoming-missile]"])
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[incoming-missile]") forCount:4.5];
|
||||||
[warningSound play];
|
|
||||||
#endif
|
|
||||||
[universe addMessage:[universe expandDescription:@"[incoming-missile]" forSystem:system_seed] forCount:4.5];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([ms isEqual:@"ENERGY_LOW"])
|
if ([ms isEqual:@"ENERGY_LOW"])
|
||||||
{
|
{
|
||||||
[universe playCustomSound:@"[energy-low]"];
|
[universe playCustomSound:@"[energy-low]"];
|
||||||
[universe addMessage:[universe expandDescription:@"[energy-low]" forSystem:system_seed] forCount:6.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[energy-low]") forCount:6.0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([ms isEqual:@"ECM"])
|
if ([ms isEqual:@"ECM"]) [self playECMSound];
|
||||||
[self playECMSound];
|
|
||||||
|
|
||||||
if ([ms isEqual:@"DOCKING_REFUSED"]&&(status == STATUS_AUTOPILOT_ENGAGED))
|
if ([ms isEqual:@"DOCKING_REFUSED"]&&(status == STATUS_AUTOPILOT_ENGAGED))
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SOUND
|
if (![universe playCustomSound:@"[autopilot-denied]"]) [warningSound play];
|
||||||
if (![universe playCustomSound:@"[autopilot-denied]"])
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[autopilot-denied]") forCount:4.5];
|
||||||
[warningSound play];
|
|
||||||
#endif
|
|
||||||
[universe addMessage:[universe expandDescription:@"[autopilot-denied]" forSystem:system_seed] forCount:4.5];
|
|
||||||
autopilot_engaged = NO;
|
autopilot_engaged = NO;
|
||||||
primaryTarget = NO_TARGET;
|
primaryTarget = NO_TARGET;
|
||||||
status = STATUS_IN_FLIGHT;
|
status = STATUS_IN_FLIGHT;
|
||||||
@ -3033,8 +3001,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
[missile setReportAImessages:YES];
|
[missile setReportAImessages:YES];
|
||||||
|
|
||||||
[universe addEntity:missile];
|
[universe addEntity:missile];
|
||||||
//NSLog(@"Missile collision radius is %.1f",missile->collision_radius);
|
[missile release];
|
||||||
[missile release]; //release
|
|
||||||
|
|
||||||
[(ShipEntity *)target setPrimaryAggressor:self];
|
[(ShipEntity *)target setPrimaryAggressor:self];
|
||||||
[[(ShipEntity *)target getAI] reactToMessage:@"INCOMING_MISSILE"];
|
[[(ShipEntity *)target getAI] reactToMessage:@"INCOMING_MISSILE"];
|
||||||
@ -3088,10 +3055,9 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
[(ShipEntity *)e2 takeEnergyDamage:1000 from:self becauseOf:self];
|
[(ShipEntity *)e2 takeEnergyDamage:1000 from:self becauseOf:self];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[universe addMessage:[universe expandDescription:@"[energy-bomb-activated]" forSystem:system_seed] forCount:4.5];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[energy-bomb-activated]") forCount:4.5];
|
||||||
#ifdef HAVE_SOUND
|
|
||||||
[destructionSound play];
|
[destructionSound play];
|
||||||
#endif
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3104,7 +3070,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
if (weapon_temp / PLAYER_MAX_WEAPON_TEMP >= 0.85)
|
if (weapon_temp / PLAYER_MAX_WEAPON_TEMP >= 0.85)
|
||||||
{
|
{
|
||||||
[universe playCustomSound:@"[weapon-overheat]"];
|
[universe playCustomSound:@"[weapon-overheat]"];
|
||||||
[universe addMessage:[universe expandDescription:@"[weapon-overheat]" forSystem:system_seed] forCount:3.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[weapon-overheat]") forCount:3.0];
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3153,7 +3119,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
|
|
||||||
if (energy <= weapon_energy_per_shot)
|
if (energy <= weapon_energy_per_shot)
|
||||||
{
|
{
|
||||||
[universe addMessage:[universe expandDescription:@"[weapon-out-of-juice]" forSystem:system_seed] forCount:3.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[weapon-out-of-juice]") forCount:3.0];
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3167,7 +3133,6 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
case VIEW_NONE:
|
case VIEW_NONE:
|
||||||
case VIEW_BREAK_PATTERN:
|
case VIEW_BREAK_PATTERN:
|
||||||
case VIEW_FORWARD:
|
case VIEW_FORWARD:
|
||||||
// NSLog(@"forward weapon offset = ( %.2f, %.2f, %.2f)", forwardWeaponOffset.x, forwardWeaponOffset.y, forwardWeaponOffset.z);
|
|
||||||
forward_weapon_temp += weapon_heat_increment_per_shot;
|
forward_weapon_temp += weapon_heat_increment_per_shot;
|
||||||
break;
|
break;
|
||||||
case VIEW_AFT:
|
case VIEW_AFT:
|
||||||
@ -3180,8 +3145,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
starboard_weapon_temp += weapon_heat_increment_per_shot;
|
starboard_weapon_temp += weapon_heat_increment_per_shot;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//NSLog(@"%@ firing weapon",name);
|
|
||||||
switch (weapon_to_be_fired)
|
switch (weapon_to_be_fired)
|
||||||
{
|
{
|
||||||
case WEAPON_PLASMA_CANNON :
|
case WEAPON_PLASMA_CANNON :
|
||||||
@ -3248,11 +3212,8 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
|
|
||||||
if (damageSound)
|
if (damageSound)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SOUND
|
if ([damageSound isPlaying]) [damageSound stop];
|
||||||
if ([damageSound isPlaying])
|
|
||||||
[damageSound stop];
|
|
||||||
[damageSound play];
|
[damageSound play];
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// firing on an innocent ship is an offence
|
// firing on an innocent ship is an offence
|
||||||
@ -3263,7 +3224,6 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
|
|
||||||
if (d_forward >= 0)
|
if (d_forward >= 0)
|
||||||
{
|
{
|
||||||
//NSLog(@"hit on FORWARD shields");
|
|
||||||
forward_shield -= amount;
|
forward_shield -= amount;
|
||||||
if (forward_shield < 0.0)
|
if (forward_shield < 0.0)
|
||||||
{
|
{
|
||||||
@ -3277,7 +3237,6 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//NSLog(@"hit on AFT shields");
|
|
||||||
aft_shield -= amount;
|
aft_shield -= amount;
|
||||||
if (aft_shield < 0.0)
|
if (aft_shield < 0.0)
|
||||||
{
|
{
|
||||||
@ -3296,11 +3255,8 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
energy -= amount;
|
energy -= amount;
|
||||||
if (scrapeDamageSound)
|
if (scrapeDamageSound)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SOUND
|
if ([scrapeDamageSound isPlaying]) [scrapeDamageSound stop];
|
||||||
if ([scrapeDamageSound isPlaying])
|
|
||||||
[scrapeDamageSound stop];
|
|
||||||
[scrapeDamageSound play];
|
[scrapeDamageSound play];
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
ship_temperature += amount;
|
ship_temperature += amount;
|
||||||
}
|
}
|
||||||
@ -3320,11 +3276,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
[self getDestroyed];
|
[self getDestroyed];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (internal_damage)
|
if (internal_damage) [self takeInternalDamage];
|
||||||
{
|
|
||||||
// NSLog(@"DEBUG ***** triggered chance of internal damage! *****");
|
|
||||||
[self takeInternalDamage];
|
|
||||||
}
|
|
||||||
|
|
||||||
[ent release];
|
[ent release];
|
||||||
[other release];
|
[other release];
|
||||||
@ -3351,11 +3303,8 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
|
|
||||||
if (scrapeDamageSound)
|
if (scrapeDamageSound)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SOUND
|
if ([scrapeDamageSound isPlaying]) [scrapeDamageSound stop];
|
||||||
if ([scrapeDamageSound isPlaying])
|
|
||||||
[scrapeDamageSound stop];
|
|
||||||
[scrapeDamageSound play];
|
[scrapeDamageSound play];
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (d_forward >= 0)
|
if (d_forward >= 0)
|
||||||
{
|
{
|
||||||
@ -3403,11 +3352,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
[self getDestroyed];
|
[self getDestroyed];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (internal_damage)
|
if (internal_damage) [self takeInternalDamage];
|
||||||
{
|
|
||||||
// NSLog(@"DEBUG ***** triggered chance of internal damage! *****");
|
|
||||||
[self takeInternalDamage];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[ent release];
|
[ent release];
|
||||||
@ -3483,7 +3428,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
vel.y = flight_speed * v_forward.y;
|
vel.y = flight_speed * v_forward.y;
|
||||||
vel.z = flight_speed * v_forward.z;
|
vel.z = flight_speed * v_forward.z;
|
||||||
|
|
||||||
doppelganger = [universe getShip: ship_desc]; // retain count = 1
|
doppelganger = [universe newShipWithName: ship_desc]; // retain count = 1
|
||||||
if (doppelganger)
|
if (doppelganger)
|
||||||
{
|
{
|
||||||
[doppelganger setPosition: origin]; // directly below
|
[doppelganger setPosition: origin]; // directly below
|
||||||
@ -3534,7 +3479,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
[cargo removeAllObjects];
|
[cargo removeAllObjects];
|
||||||
|
|
||||||
energy = 25;
|
energy = 25;
|
||||||
[universe addMessage:[universe expandDescription:@"[escape-sequence]" forSystem:system_seed] forCount:4.5];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[escape-sequence]") forCount:4.5];
|
||||||
shot_time = 0.0;
|
shot_time = 0.0;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -3544,14 +3489,14 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
{
|
{
|
||||||
if (flight_speed > 4.0 * max_flight_speed)
|
if (flight_speed > 4.0 * max_flight_speed)
|
||||||
{
|
{
|
||||||
[universe addMessage:[universe expandDescription:@"[hold-locked]" forSystem:system_seed] forCount:3.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[hold-locked]") forCount:3.0];
|
||||||
return CARGO_NOT_CARGO;
|
return CARGO_NOT_CARGO;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = [super dumpCargo];
|
int result = [super dumpCargo];
|
||||||
if (result != CARGO_NOT_CARGO)
|
if (result != CARGO_NOT_CARGO)
|
||||||
{
|
{
|
||||||
[universe addMessage:[NSString stringWithFormat:[universe expandDescription:@"[@-ejected]" forSystem:system_seed],[universe nameForCommodity:result]] forCount:3.0];
|
[universe addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[@-ejected]") ,[universe nameForCommodity:result]] forCount:3.0];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -3576,11 +3521,11 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
[pod release];
|
[pod release];
|
||||||
if (contents != CARGO_NOT_CARGO)
|
if (contents != CARGO_NOT_CARGO)
|
||||||
{
|
{
|
||||||
[universe addMessage:[NSString stringWithFormat:[universe expandDescription:@"[@-ready-to-eject]" forSystem:system_seed],[universe nameForCommodity:contents]] forCount:3.0];
|
[universe addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[@-ready-to-eject]"), [universe nameForCommodity:contents]] forCount:3.0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[universe addMessage:[NSString stringWithFormat:[universe expandDescription:@"[ready-to-eject-@]" forSystem:system_seed],[pod name]] forCount:3.0];
|
[universe addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[ready-to-eject-@]") ,[pod name]] forCount:3.0];
|
||||||
}
|
}
|
||||||
// now scan through the remaining 1..(n_cargo - rotates) places moving similar cargo to the last place
|
// now scan through the remaining 1..(n_cargo - rotates) places moving similar cargo to the last place
|
||||||
// this means the cargo gets to be sorted as it is rotated through
|
// this means the cargo gets to be sorted as it is rotated through
|
||||||
@ -3628,13 +3573,10 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
if (![universe strict]) // only mess with the scores if we're not in 'strict' mode
|
if (![universe strict]) // only mess with the scores if we're not in 'strict' mode
|
||||||
{
|
{
|
||||||
BOOL killIsCargo = ((killClass == CLASS_CARGO)&&([other getCommodityAmount] > 0));
|
BOOL killIsCargo = ((killClass == CLASS_CARGO)&&([other getCommodityAmount] > 0));
|
||||||
// NSLog(@"DEBUG universe not strict killClass is %d", killClass);
|
|
||||||
if ((killIsCargo)||(killClass == CLASS_BUOY)||(killClass == CLASS_ROCK))
|
if ((killIsCargo)||(killClass == CLASS_BUOY)||(killClass == CLASS_ROCK))
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG killClass not suitable for high reward");
|
|
||||||
if (![[other roles] isEqual:@"tharglet"]) // okay, we'll count tharglets as proper kills
|
if (![[other roles] isEqual:@"tharglet"]) // okay, we'll count tharglets as proper kills
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG reducing award");
|
|
||||||
score /= 10; // reduce bounty awarded
|
score /= 10; // reduce bounty awarded
|
||||||
kill_award = 0; // don't award a kill
|
kill_award = 0; // don't award a kill
|
||||||
}
|
}
|
||||||
@ -3645,8 +3587,8 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
|
|
||||||
if (score)
|
if (score)
|
||||||
{
|
{
|
||||||
NSString* bonusMS1 = [NSString stringWithFormat:[universe expandDescription:@"[bounty-d]" forSystem:system_seed], score / 10];
|
NSString* bonusMS1 = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[bounty-d]"), score / 10];
|
||||||
NSString* bonusMS2 = [NSString stringWithFormat:[universe expandDescription:@"[total-f-credits]" forSystem:system_seed], 0.1 * credits];
|
NSString* bonusMS2 = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[total-f-credits]"), 0.1 * credits];
|
||||||
|
|
||||||
if (score > 9)
|
if (score > 9)
|
||||||
[universe addDelayedMessage:bonusMS1 forCount:6 afterDelay:0.15];
|
[universe addDelayedMessage:bonusMS1 forCount:6 afterDelay:0.15];
|
||||||
@ -3660,7 +3602,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
if ((ship_kills % 256) == 0)
|
if ((ship_kills % 256) == 0)
|
||||||
{
|
{
|
||||||
// congratulations method needs to be delayed a fraction of a second
|
// congratulations method needs to be delayed a fraction of a second
|
||||||
NSString* roc = [universe expandDescription:@"[right-on-commander]" forSystem:system_seed];
|
NSString* roc = ExpandDescriptionForCurrentSystem(@"[right-on-commander]");
|
||||||
[universe addDelayedMessage:roc forCount:4 afterDelay:0.2];
|
[universe addDelayedMessage:roc forCount:4 afterDelay:0.2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3680,7 +3622,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
if (!cargo_desc)
|
if (!cargo_desc)
|
||||||
return;
|
return;
|
||||||
[universe clearPreviousMessage];
|
[universe clearPreviousMessage];
|
||||||
[universe addMessage:[NSString stringWithFormat:[universe expandDescription:@"[@-destroyed]" forSystem:system_seed],cargo_desc] forCount:4.5];
|
[universe addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[@-destroyed]"), cargo_desc] forCount:4.5];
|
||||||
[cargo removeObject:pod];
|
[cargo removeObject:pod];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3712,11 +3654,11 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
[self removeEquipment:system_key];
|
[self removeEquipment:system_key];
|
||||||
if (![universe strict])
|
if (![universe strict])
|
||||||
{
|
{
|
||||||
[universe addMessage:[NSString stringWithFormat:[universe expandDescription:@"[@-damaged]" forSystem:system_seed],system_name] forCount:4.5];
|
[universe addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[@-damaged]"), system_name] forCount:4.5];
|
||||||
[self add_extra_equipment:[NSString stringWithFormat:@"%@_DAMAGED", system_key]]; // for possible future repair
|
[self add_extra_equipment:[NSString stringWithFormat:@"%@_DAMAGED", system_key]]; // for possible future repair
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
[universe addMessage:[NSString stringWithFormat:[universe expandDescription:@"[@-destroyed]" forSystem:system_seed],system_name] forCount:4.5];
|
[universe addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[@-destroyed]"), system_name] forCount:4.5];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//cosmetic damage
|
//cosmetic damage
|
||||||
@ -3745,10 +3687,9 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
[self becomeLargeExplosion:4.0];
|
[self becomeLargeExplosion:4.0];
|
||||||
[self moveForward:100.0];
|
[self moveForward:100.0];
|
||||||
|
|
||||||
#ifdef HAVE_SOUND
|
|
||||||
[universe playCustomSound:@"[game-over]"];
|
[universe playCustomSound:@"[game-over]"];
|
||||||
[destructionSound play];
|
[destructionSound play];
|
||||||
#endif
|
|
||||||
flight_speed = 160.0;
|
flight_speed = 160.0;
|
||||||
status = STATUS_DEAD;
|
status = STATUS_DEAD;
|
||||||
[universe displayMessage:@"Game Over" forCount:30.0];
|
[universe displayMessage:@"Game Over" forCount:30.0];
|
||||||
@ -4125,7 +4066,6 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//NSLog(@"---> Witchspace misjump");
|
|
||||||
// move sort of halfway there...
|
// move sort of halfway there...
|
||||||
galaxy_coordinates.x += target_system_seed.d;
|
galaxy_coordinates.x += target_system_seed.d;
|
||||||
galaxy_coordinates.y += target_system_seed.b;
|
galaxy_coordinates.y += target_system_seed.b;
|
||||||
@ -4185,7 +4125,6 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
filename = [[(MyOpenGLView *)[universe gameView] gameController] playerFileToLoad];
|
filename = [[(MyOpenGLView *)[universe gameView] gameController] playerFileToLoad];
|
||||||
if (!filename)
|
if (!filename)
|
||||||
{
|
{
|
||||||
// NSBeep(); // AppKit
|
|
||||||
NSLog(@"ERROR no filename returned by [[(MyOpenGLView *)[universe gameView] gameController] playerFileToLoad]");
|
NSLog(@"ERROR no filename returned by [[(MyOpenGLView *)[universe gameView] gameController] playerFileToLoad]");
|
||||||
NSException* myException = [NSException
|
NSException* myException = [NSException
|
||||||
exceptionWithName:@"GameNotSavedException"
|
exceptionWithName:@"GameNotSavedException"
|
||||||
@ -4196,7 +4135,6 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
}
|
}
|
||||||
if (![[self commanderDataDictionary] writeOOXMLToFile:filename atomically:YES])
|
if (![[self commanderDataDictionary] writeOOXMLToFile:filename atomically:YES])
|
||||||
{
|
{
|
||||||
// NSBeep(); //AppKit
|
|
||||||
NSLog(@"***** ERROR: Save to %@ failed!", filename);
|
NSLog(@"***** ERROR: Save to %@ failed!", filename);
|
||||||
NSException* myException = [NSException
|
NSException* myException = [NSException
|
||||||
exceptionWithName:@"OoliteException"
|
exceptionWithName:@"OoliteException"
|
||||||
@ -4209,7 +4147,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
{
|
{
|
||||||
|
|
||||||
[universe clearPreviousMessage]; // allow this to be given time and again
|
[universe clearPreviousMessage]; // allow this to be given time and again
|
||||||
[universe addMessage:[universe expandDescription:@"[game-saved]" forSystem:system_seed] forCount:2];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[game-saved]") forCount:2];
|
||||||
if (save_path)
|
if (save_path)
|
||||||
[save_path autorelease];
|
[save_path autorelease];
|
||||||
save_path = [filename retain];
|
save_path = [filename retain];
|
||||||
@ -4241,15 +4179,11 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
NSArray* path_components = [[sp filename] pathComponents];
|
NSArray* path_components = [[sp filename] pathComponents];
|
||||||
NSString* new_name = [[path_components objectAtIndex:[path_components count]-1] stringByDeletingPathExtension];
|
NSString* new_name = [[path_components objectAtIndex:[path_components count]-1] stringByDeletingPathExtension];
|
||||||
|
|
||||||
//NSLog(@"Attempting to save to %@",[sp filename]);
|
|
||||||
//NSLog(@"Will set Commander's name to %@", new_name);
|
|
||||||
|
|
||||||
if (player_name) [player_name release];
|
if (player_name) [player_name release];
|
||||||
player_name = [new_name retain];
|
player_name = [new_name retain];
|
||||||
|
|
||||||
if (![[self commanderDataDictionary] writeOOXMLToFile:[sp filename] atomically:YES])
|
if (![[self commanderDataDictionary] writeOOXMLToFile:[sp filename] atomically:YES])
|
||||||
{
|
{
|
||||||
// NSBeep(); // AppKit
|
|
||||||
NSLog(@"***** ERROR: Save to %@ failed!", [sp filename]);
|
NSLog(@"***** ERROR: Save to %@ failed!", [sp filename]);
|
||||||
NSException* myException = [NSException
|
NSException* myException = [NSException
|
||||||
exceptionWithName:@"OoliteException"
|
exceptionWithName:@"OoliteException"
|
||||||
@ -4304,7 +4238,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
loadedOK = NO;
|
loadedOK = NO;
|
||||||
if ([[localException name] isEqual: OOLITE_EXCEPTION_SHIP_NOT_FOUND])
|
if ([[localException name] isEqual: OOLITE_EXCEPTION_SHIP_NOT_FOUND])
|
||||||
{
|
{
|
||||||
NSLog(@"***** Oolite Exception : '%@' in [PlayerEntity loadPlayerFromFile: %@ ] *****", [localException reason], fileToOpen);
|
OOLog(kOOLogException, @"***** Oolite Exception : '%@' in [PlayerEntity loadPlayerFromFile: %@ ] *****", [localException reason], fileToOpen);
|
||||||
fail_reason = @"Couldn't load Commander details for some reason (AddOns folder missing an OXP perhaps?)";
|
fail_reason = @"Couldn't load Commander details for some reason (AddOns folder missing an OXP perhaps?)";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -4325,7 +4259,6 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSLog(@"***** FILE LOADING ERROR!! *****");
|
NSLog(@"***** FILE LOADING ERROR!! *****");
|
||||||
// NSBeep(); AppKit
|
|
||||||
[[universe gameController] setPlayerFileToLoad:nil];
|
[[universe gameController] setPlayerFileToLoad:nil];
|
||||||
[universe game_over];
|
[universe game_over];
|
||||||
[universe clearPreviousMessage];
|
[universe clearPreviousMessage];
|
||||||
@ -4392,8 +4325,6 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
NSString* targetSystemName;
|
NSString* targetSystemName;
|
||||||
NSString* text;
|
NSString* text;
|
||||||
|
|
||||||
//NSLog(@"DEBUG original hold size = %d",original_hold_size);
|
|
||||||
|
|
||||||
system_seed = [universe findSystemAtCoords:galaxy_coordinates withGalaxySeed:galaxy_seed];
|
system_seed = [universe findSystemAtCoords:galaxy_coordinates withGalaxySeed:galaxy_seed];
|
||||||
target_system_seed = [universe findSystemAtCoords:cursor_coordinates withGalaxySeed:galaxy_seed];
|
target_system_seed = [universe findSystemAtCoords:cursor_coordinates withGalaxySeed:galaxy_seed];
|
||||||
|
|
||||||
@ -4475,7 +4406,6 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
}
|
}
|
||||||
/* ends */
|
/* ends */
|
||||||
|
|
||||||
//NSLog(@"gui_screen = GUI_SCREEN_STATUS");
|
|
||||||
if (lastTextKey)
|
if (lastTextKey)
|
||||||
{
|
{
|
||||||
[lastTextKey release];
|
[lastTextKey release];
|
||||||
@ -4561,8 +4491,6 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
NSString *grams = (NSString *)[descriptions objectForKey:@"cargo-grams-symbol"];
|
NSString *grams = (NSString *)[descriptions objectForKey:@"cargo-grams-symbol"];
|
||||||
NSString *kilograms = (NSString *)[descriptions objectForKey:@"cargo-kilograms-symbol"];
|
NSString *kilograms = (NSString *)[descriptions objectForKey:@"cargo-kilograms-symbol"];
|
||||||
|
|
||||||
// NSLog(@"DEBUG ::::: %@", [shipCommodityData description]);
|
|
||||||
|
|
||||||
if (specialCargo)
|
if (specialCargo)
|
||||||
[manifest addObject:specialCargo];
|
[manifest addObject:specialCargo];
|
||||||
|
|
||||||
@ -4591,11 +4519,6 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
[manifest addObject:[NSString stringWithFormat:@"%d%@ x %@", in_hold[i], units, desc]];
|
[manifest addObject:[NSString stringWithFormat:@"%d%@ x %@", in_hold[i], units, desc]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// // debug
|
|
||||||
// NSLog(@"DEBUG shipCommodityData:-\n%@", [shipCommodityData description]);
|
|
||||||
// NSLog(@"DEBUG manifest:-\n%@", [manifest description]);
|
|
||||||
|
|
||||||
|
|
||||||
return [NSArray arrayWithArray:manifest];
|
return [NSArray arrayWithArray:manifest];
|
||||||
}
|
}
|
||||||
@ -4606,8 +4529,6 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
NSString* targetSystemName;
|
NSString* targetSystemName;
|
||||||
NSDictionary* descriptions = [universe descriptions];
|
NSDictionary* descriptions = [universe descriptions];
|
||||||
|
|
||||||
// target_system_seed = [universe findSystemAtCoords:cursor_coordinates withGalaxySeed:galaxy_seed];
|
|
||||||
|
|
||||||
targetSystemData = [[universe generateSystemData:target_system_seed] retain]; // retained
|
targetSystemData = [[universe generateSystemData:target_system_seed] retain]; // retained
|
||||||
targetSystemName = [[universe getSystemName:target_system_seed] retain]; // retained
|
targetSystemName = [[universe getSystemName:target_system_seed] retain]; // retained
|
||||||
|
|
||||||
@ -4643,7 +4564,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
population = 0;
|
population = 0;
|
||||||
productivity = 0;
|
productivity = 0;
|
||||||
radius = 0;
|
radius = 0;
|
||||||
system_desc = [universe expandDescription:@"[nova-system-description]" forSystem:target_system_seed];
|
system_desc = ExpandDescriptionForCurrentSystem(@"[nova-system-description]");
|
||||||
}
|
}
|
||||||
|
|
||||||
[gui clear];
|
[gui clear];
|
||||||
@ -4673,16 +4594,14 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
}
|
}
|
||||||
/* ends */
|
/* ends */
|
||||||
|
|
||||||
//NSLog(@"gui_screen = GUI_SCREEN_SYSTEM_DATA for system %@ at (%d,%d)",targetSystemName,target_system_seed.d,target_system_seed.b);
|
|
||||||
|
|
||||||
if (lastTextKey)
|
if (lastTextKey)
|
||||||
{
|
{
|
||||||
[lastTextKey release];
|
[lastTextKey release];
|
||||||
lastTextKey = nil;
|
lastTextKey = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
[targetSystemData release]; // released
|
[targetSystemData release];
|
||||||
[targetSystemName release]; // released
|
[targetSystemName release];
|
||||||
|
|
||||||
gui_screen = GUI_SCREEN_SYSTEM_DATA;
|
gui_screen = GUI_SCREEN_SYSTEM_DATA;
|
||||||
|
|
||||||
@ -4760,11 +4679,9 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
}
|
}
|
||||||
/* ends */
|
/* ends */
|
||||||
|
|
||||||
//NSLog(@"gui_screen = GUI_SCREEN_LONG_RANGE_CHART");
|
|
||||||
|
|
||||||
gui_screen = GUI_SCREEN_LONG_RANGE_CHART;
|
gui_screen = GUI_SCREEN_LONG_RANGE_CHART;
|
||||||
|
|
||||||
[targetSystemName release]; // released
|
[targetSystemName release];
|
||||||
|
|
||||||
[self setShowDemoShips: NO];
|
[self setShowDemoShips: NO];
|
||||||
[universe setDisplayText: YES];
|
[universe setDisplayText: YES];
|
||||||
@ -4968,8 +4885,6 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
target_system_seed = [universe findSystemAtCoords:cursor_coordinates withGalaxySeed:galaxy_seed];
|
target_system_seed = [universe findSystemAtCoords:cursor_coordinates withGalaxySeed:galaxy_seed];
|
||||||
targetSystemName = [[universe getSystemName:target_system_seed] retain]; // retained
|
targetSystemName = [[universe getSystemName:target_system_seed] retain]; // retained
|
||||||
|
|
||||||
//NSLog(@"found %@ at (%d, %d)",targetSystemName,(int)cursor_coordinates.x,(int)cursor_coordinates.y);
|
|
||||||
|
|
||||||
// GUI stuff
|
// GUI stuff
|
||||||
{
|
{
|
||||||
GuiDisplayGen* gui = [universe gui];
|
GuiDisplayGen* gui = [universe gui];
|
||||||
@ -4988,8 +4903,6 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
}
|
}
|
||||||
/* ends */
|
/* ends */
|
||||||
|
|
||||||
//NSLog(@"gui_screen = GUI_SCREEN_LONG_RANGE_CHART");
|
|
||||||
|
|
||||||
gui_screen = GUI_SCREEN_SHORT_RANGE_CHART;
|
gui_screen = GUI_SCREEN_SHORT_RANGE_CHART;
|
||||||
|
|
||||||
[targetSystemName release]; // released
|
[targetSystemName release]; // released
|
||||||
@ -5193,8 +5106,6 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
}
|
}
|
||||||
/* ends */
|
/* ends */
|
||||||
|
|
||||||
//NSLog(@"gui_screen = GUI_SCREEN_OPTIONS");
|
|
||||||
|
|
||||||
[self setShowDemoShips:NO];
|
[self setShowDemoShips:NO];
|
||||||
gui_screen = GUI_SCREEN_OPTIONS;
|
gui_screen = GUI_SCREEN_OPTIONS;
|
||||||
|
|
||||||
@ -5210,8 +5121,6 @@ static int last_outfitting_index;
|
|||||||
{
|
{
|
||||||
missiles = [self calc_missiles];
|
missiles = [self calc_missiles];
|
||||||
|
|
||||||
// NSLog(@"DEBUG EquipShipScreen missiles = %d", missiles);
|
|
||||||
|
|
||||||
// if skip < 0 then use the last recorded index
|
// if skip < 0 then use the last recorded index
|
||||||
if (skip < 0)
|
if (skip < 0)
|
||||||
{
|
{
|
||||||
@ -5544,15 +5453,15 @@ static int last_outfitting_index;
|
|||||||
[gui clear];
|
[gui clear];
|
||||||
[gui setTitle:@"Oolite"];
|
[gui setTitle:@"Oolite"];
|
||||||
|
|
||||||
text = [universe expandDescription:@"[game-copyright]" forSystem:system_seed];
|
text = ExpandDescriptionForCurrentSystem(@"[game-copyright]");
|
||||||
[gui setText:text forRow:17 align:GUI_ALIGN_CENTER];
|
[gui setText:text forRow:17 align:GUI_ALIGN_CENTER];
|
||||||
[gui setColor:[OOColor whiteColor] forRow:17];
|
[gui setColor:[OOColor whiteColor] forRow:17];
|
||||||
|
|
||||||
text = [universe expandDescription:@"[theme-music-credit]" forSystem:system_seed];
|
text = ExpandDescriptionForCurrentSystem(@"[theme-music-credit]");
|
||||||
[gui setText:text forRow:19 align:GUI_ALIGN_CENTER];
|
[gui setText:text forRow:19 align:GUI_ALIGN_CENTER];
|
||||||
[gui setColor:[OOColor grayColor] forRow:19];
|
[gui setColor:[OOColor grayColor] forRow:19];
|
||||||
|
|
||||||
text = [universe expandDescription:@"[load-previous-commander]" forSystem:system_seed];
|
text = ExpandDescriptionForCurrentSystem(@"[load-previous-commander]");
|
||||||
[gui setText:text forRow:21 align:GUI_ALIGN_CENTER];
|
[gui setText:text forRow:21 align:GUI_ALIGN_CENTER];
|
||||||
[gui setColor:[OOColor yellowColor] forRow:21];
|
[gui setColor:[OOColor yellowColor] forRow:21];
|
||||||
|
|
||||||
@ -5569,7 +5478,6 @@ static int last_outfitting_index;
|
|||||||
|
|
||||||
// check for messages from the command line
|
// check for messages from the command line
|
||||||
NSArray* arguments = [[NSProcessInfo processInfo] arguments];
|
NSArray* arguments = [[NSProcessInfo processInfo] arguments];
|
||||||
//NSLog(@"DEBUG arguments:\n%@",[arguments description]);
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < [arguments count]; i++)
|
for (i = 0; i < [arguments count]; i++)
|
||||||
{
|
{
|
||||||
@ -5616,7 +5524,7 @@ static int last_outfitting_index;
|
|||||||
[gui clear];
|
[gui clear];
|
||||||
[gui setTitle:@"Oolite"];
|
[gui setTitle:@"Oolite"];
|
||||||
|
|
||||||
text = [universe expandDescription:@"[press-space-commander]" forSystem:system_seed];
|
text = ExpandDescriptionForCurrentSystem(@"[press-space-commander]");
|
||||||
[gui setText:text forRow:21 align:GUI_ALIGN_CENTER];
|
[gui setText:text forRow:21 align:GUI_ALIGN_CENTER];
|
||||||
[gui setColor:[OOColor yellowColor] forRow:21];
|
[gui setColor:[OOColor yellowColor] forRow:21];
|
||||||
|
|
||||||
@ -5660,7 +5568,7 @@ static int last_outfitting_index;
|
|||||||
chosen_weapon_facing = WEAPON_FACING_PORT;
|
chosen_weapon_facing = WEAPON_FACING_PORT;
|
||||||
if ([item_text isEqual:STARBOARD_FACING_STRING])
|
if ([item_text isEqual:STARBOARD_FACING_STRING])
|
||||||
chosen_weapon_facing = WEAPON_FACING_STARBOARD;
|
chosen_weapon_facing = WEAPON_FACING_STARBOARD;
|
||||||
//NSLog(@"Try Buying Item %d",item);
|
|
||||||
int old_credits = credits;
|
int old_credits = credits;
|
||||||
if ([self tryBuyingItem:item])
|
if ([self tryBuyingItem:item])
|
||||||
{
|
{
|
||||||
@ -5841,14 +5749,14 @@ static int last_outfitting_index;
|
|||||||
ship_trade_in_factor += 5 + techlevel; // you get better value at high-tech repair bases
|
ship_trade_in_factor += 5 + techlevel; // you get better value at high-tech repair bases
|
||||||
if (ship_trade_in_factor > 100)
|
if (ship_trade_in_factor > 100)
|
||||||
ship_trade_in_factor = 100;
|
ship_trade_in_factor = 100;
|
||||||
// NSLog(@"DEBUG : Ship trade in value now %d\%", ship_trade_in_factor);
|
|
||||||
[self setGuiToEquipShipScreen:-1:-1];
|
[self setGuiToEquipShipScreen:-1:-1];
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([eq_key hasSuffix:@"MISSILE"]||[eq_key hasSuffix:@"MINE"])
|
if ([eq_key hasSuffix:@"MISSILE"]||[eq_key hasSuffix:@"MINE"])
|
||||||
{
|
{
|
||||||
ShipEntity* weapon = [[universe getShipWithRole:eq_key] autorelease];
|
ShipEntity* weapon = [[universe newShipWithRole:eq_key] autorelease];
|
||||||
if (weapon) OOLog(kOOLogBuyMountedOK, @"Got ship for mounted weapon role %@", eq_key);
|
if (weapon) OOLog(kOOLogBuyMountedOK, @"Got ship for mounted weapon role %@", eq_key);
|
||||||
else OOLog(kOOLogBuyMountedFailed, @"Could not find ship for mounted weapon role %@", eq_key);
|
else OOLog(kOOLogBuyMountedFailed, @"Could not find ship for mounted weapon role %@", eq_key);
|
||||||
|
|
||||||
@ -5896,7 +5804,6 @@ static int last_outfitting_index;
|
|||||||
{
|
{
|
||||||
NSString* weapon_key = [weapon roles];
|
NSString* weapon_key = [weapon roles];
|
||||||
int weapon_value = [universe getPriceForWeaponSystemWithKey:weapon_key];
|
int weapon_value = [universe getPriceForWeaponSystemWithKey:weapon_key];
|
||||||
// NSLog(@"..... selling a %@ worth %f", weapon_key, 0.1 * weapon_value);
|
|
||||||
credits += weapon_value;
|
credits += weapon_value;
|
||||||
[universe recycleOrDiscard: weapon];
|
[universe recycleOrDiscard: weapon];
|
||||||
[weapon release];
|
[weapon release];
|
||||||
@ -5913,7 +5820,6 @@ static int last_outfitting_index;
|
|||||||
NSString *w_key = (NSString *)[(NSArray *)[equipdata objectAtIndex:i] objectAtIndex:EQUIPMENT_KEY_INDEX];
|
NSString *w_key = (NSString *)[(NSArray *)[equipdata objectAtIndex:i] objectAtIndex:EQUIPMENT_KEY_INDEX];
|
||||||
if (([eq_key isEqual:w_key])&&(![self has_extra_equipment:eq_key]))
|
if (([eq_key isEqual:w_key])&&(![self has_extra_equipment:eq_key]))
|
||||||
{
|
{
|
||||||
//NSLog(@"adding %@",eq_key);
|
|
||||||
credits -= price;
|
credits -= price;
|
||||||
[self add_extra_equipment:eq_key];
|
[self add_extra_equipment:eq_key];
|
||||||
[self setGuiToEquipShipScreen:-1:-1];
|
[self setGuiToEquipShipScreen:-1:-1];
|
||||||
@ -5970,8 +5876,7 @@ static int last_outfitting_index;
|
|||||||
else
|
else
|
||||||
localMarket = [[universe station] initialiseLocalMarketWithSeed:system_seed andRandomFactor:market_rnd];
|
localMarket = [[universe station] initialiseLocalMarketWithSeed:system_seed andRandomFactor:market_rnd];
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSLog(@"DEBUG local market = %@ [universe station] = %@", [localMarket description], [universe station]);
|
|
||||||
// fix problems with economies in witch-space
|
// fix problems with economies in witch-space
|
||||||
if (![universe station])
|
if (![universe station])
|
||||||
{
|
{
|
||||||
@ -6326,11 +6231,9 @@ OOSound* burnersound;
|
|||||||
burnersound = afterburner2Sound;
|
burnersound = afterburner2Sound;
|
||||||
else
|
else
|
||||||
burnersound = afterburner1Sound;
|
burnersound = afterburner1Sound;
|
||||||
|
|
||||||
// NSLog(@"DEBUG loopAfterburnerSound playing sound %@", burnersound);
|
|
||||||
#ifdef HAVE_SOUND
|
|
||||||
[burnersound play];
|
[burnersound play];
|
||||||
#endif
|
|
||||||
[self performSelector:_loopAfterburnerSoundSelector
|
[self performSelector:_loopAfterburnerSoundSelector
|
||||||
withObject:NULL
|
withObject:NULL
|
||||||
afterDelay:1.25]; // and swap sounds in 1.25s time
|
afterDelay:1.25]; // and swap sounds in 1.25s time
|
||||||
@ -6380,7 +6283,7 @@ OOSound* burnersound;
|
|||||||
credits -= fine;
|
credits -= fine;
|
||||||
}
|
}
|
||||||
fine /= 10; // divide by ten for display
|
fine /= 10; // divide by ten for display
|
||||||
NSString* fined_message = [NSString stringWithFormat:[universe expandDescription:@"[fined]" forSystem:system_seed], fine];
|
NSString* fined_message = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[fined]"), fine];
|
||||||
[universe addMessage:fined_message forCount:6];
|
[universe addMessage:fined_message forCount:6];
|
||||||
ship_clock_adjust = 24 * 3600; // take up a day
|
ship_clock_adjust = 24 * 3600; // take up a day
|
||||||
if (gui_screen != GUI_SCREEN_STATUS)
|
if (gui_screen != GUI_SCREEN_STATUS)
|
||||||
@ -6430,8 +6333,6 @@ OOSound* burnersound;
|
|||||||
|
|
||||||
- (void) setUpTrumbles
|
- (void) setUpTrumbles
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG setting up trumbles for %@%@", player_name, basefile);
|
|
||||||
|
|
||||||
NSMutableString* trumbleDigrams = [NSMutableString stringWithCapacity:256];
|
NSMutableString* trumbleDigrams = [NSMutableString stringWithCapacity:256];
|
||||||
unichar xchar = (unichar)0;
|
unichar xchar = (unichar)0;
|
||||||
unichar digramchars[2];
|
unichar digramchars[2];
|
||||||
@ -6542,7 +6443,6 @@ OOSound* burnersound;
|
|||||||
NSString* namekey = [NSString stringWithFormat:@"%@-humbletrash", player_name];
|
NSString* namekey = [NSString stringWithFormat:@"%@-humbletrash", player_name];
|
||||||
|
|
||||||
[self setUpTrumbles];
|
[self setUpTrumbles];
|
||||||
// NSLog(@"DEBUG setting trumble values from %@", trumbleValue);
|
|
||||||
|
|
||||||
if (trumbleValue)
|
if (trumbleValue)
|
||||||
{
|
{
|
||||||
@ -6618,8 +6518,6 @@ OOSound* burnersound;
|
|||||||
// at this stage we've done the best we can to stop cheaters
|
// at this stage we've done the best we can to stop cheaters
|
||||||
n_trumbles = putativeNTrumbles;
|
n_trumbles = putativeNTrumbles;
|
||||||
|
|
||||||
// NSLog(@"DEBUG putativeTrumbleArray = \n%@", putativeTrumbleArray);
|
|
||||||
|
|
||||||
if ((putativeTrumbleArray != nil) && ([putativeTrumbleArray count] == PLAYER_MAX_TRUMBLES))
|
if ((putativeTrumbleArray != nil) && ([putativeTrumbleArray count] == PLAYER_MAX_TRUMBLES))
|
||||||
{
|
{
|
||||||
for (i = 0; i < PLAYER_MAX_TRUMBLES; i++)
|
for (i = 0; i < PLAYER_MAX_TRUMBLES; i++)
|
||||||
@ -6724,7 +6622,7 @@ OOSound* burnersound;
|
|||||||
{
|
{
|
||||||
[super addTarget:potential_target];
|
[super addTarget:potential_target];
|
||||||
missile_status = MISSILE_STATUS_TARGET_LOCKED;
|
missile_status = MISSILE_STATUS_TARGET_LOCKED;
|
||||||
[universe addMessage:[NSString stringWithFormat:[universe expandDescription:@"[@-locked-onto-@]" forSystem:system_seed], (ident_engaged)? @"Ident system": @"Missile", [(ShipEntity *)potential_target name]] forCount:4.5];
|
[universe addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[@-locked-onto-@]"), (ident_engaged)? @"Ident system": @"Missile", [(ShipEntity *)potential_target name]] forCount:4.5];
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6750,7 +6648,7 @@ OOSound* burnersound;
|
|||||||
{
|
{
|
||||||
[super addTarget:potential_target];
|
[super addTarget:potential_target];
|
||||||
missile_status = MISSILE_STATUS_TARGET_LOCKED;
|
missile_status = MISSILE_STATUS_TARGET_LOCKED;
|
||||||
[universe addMessage:[NSString stringWithFormat:[universe expandDescription:@"[@-locked-onto-@]" forSystem:system_seed], (ident_engaged)? @"Ident system": @"Missile", [(ShipEntity *)potential_target name]] forCount:4.5];
|
[universe addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[@-locked-onto-@]"), (ident_engaged)? @"Ident system": @"Missile", [(ShipEntity *)potential_target name]] forCount:4.5];
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
|||||||
else if ([rescuee insuranceCredits])
|
else if ([rescuee insuranceCredits])
|
||||||
{
|
{
|
||||||
// claim insurance reward
|
// claim insurance reward
|
||||||
[result appendFormat:[universe expandDescription:@"[rescue-reward-for-@@-f-credits]\n" forSystem:system_seed],
|
[result appendFormat:ExpandDescriptionForCurrentSystem(@"[rescue-reward-for-@@-f-credits]\n"),
|
||||||
[rescuee name], [rescuee shortDescription], (float)[rescuee insuranceCredits]];
|
[rescuee name], [rescuee shortDescription], (float)[rescuee insuranceCredits]];
|
||||||
credits += 10 * [rescuee insuranceCredits];
|
credits += 10 * [rescuee insuranceCredits];
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
|||||||
{
|
{
|
||||||
// claim bounty for capture
|
// claim bounty for capture
|
||||||
float reward = (5.0 + government) * [rescuee legalStatus];
|
float reward = (5.0 + government) * [rescuee legalStatus];
|
||||||
[result appendFormat:[universe expandDescription:@"[capture-reward-for-@@-f-credits]\n" forSystem:system_seed],
|
[result appendFormat:ExpandDescriptionForCurrentSystem(@"[capture-reward-for-@@-f-credits]\n"),
|
||||||
[rescuee name], [rescuee shortDescription], 0.1f * reward];
|
[rescuee name], [rescuee shortDescription], 0.1f * reward];
|
||||||
credits += reward;
|
credits += reward;
|
||||||
}
|
}
|
||||||
@ -141,9 +141,9 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
|||||||
}
|
}
|
||||||
credits += 10 * fee;
|
credits += 10 * fee;
|
||||||
if (!result)
|
if (!result)
|
||||||
result = [NSString stringWithFormat:[universe expandDescription:@"[passenger-delivered-okay-@-d-@]" forSystem:system_seed], passenger_name, fee, passenger_dest_name];
|
result = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[passenger-delivered-okay-@-d-@]"), passenger_name, fee, passenger_dest_name];
|
||||||
else
|
else
|
||||||
result = [NSString stringWithFormat:[universe expandDescription:@"%@\n[passenger-delivered-okay-@-d-@]" forSystem:system_seed], result, passenger_name, fee, passenger_dest_name];
|
result = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"%@\n[passenger-delivered-okay-@-d-@]"), result, passenger_name, fee, passenger_dest_name];
|
||||||
[passengers removeObjectAtIndex:i--];
|
[passengers removeObjectAtIndex:i--];
|
||||||
[self increasePassengerReputation];
|
[self increasePassengerReputation];
|
||||||
}
|
}
|
||||||
@ -155,9 +155,9 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
|||||||
fee /= 2;
|
fee /= 2;
|
||||||
credits += 10 * fee;
|
credits += 10 * fee;
|
||||||
if (!result)
|
if (!result)
|
||||||
result = [NSString stringWithFormat:[universe expandDescription:@"[passenger-delivered-late-@-d-@]" forSystem:system_seed], passenger_name, fee, passenger_dest_name];
|
result = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[passenger-delivered-late-@-d-@]"), passenger_name, fee, passenger_dest_name];
|
||||||
else
|
else
|
||||||
result = [NSString stringWithFormat:[universe expandDescription:@"%@\n[passenger-delivered-late-@-d-@]" forSystem:system_seed], result, passenger_name, fee, passenger_dest_name];
|
result = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"%@\n[passenger-delivered-late-@-d-@]"), result, passenger_name, fee, passenger_dest_name];
|
||||||
[passengers removeObjectAtIndex:i--];
|
[passengers removeObjectAtIndex:i--];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,9 +167,9 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
|||||||
{
|
{
|
||||||
// we've run out of time!
|
// we've run out of time!
|
||||||
if (!result)
|
if (!result)
|
||||||
result = [NSString stringWithFormat:[universe expandDescription:@"[passenger-failed-@]" forSystem:system_seed], passenger_name];
|
result = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[passenger-failed-@]"), passenger_name];
|
||||||
else
|
else
|
||||||
result = [NSString stringWithFormat:[universe expandDescription:@"%@\n[passenger-failed-@]" forSystem:system_seed], result, passenger_name];
|
result = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"%@\n[passenger-failed-@]"), result, passenger_name];
|
||||||
[passengers removeObjectAtIndex:i--];
|
[passengers removeObjectAtIndex:i--];
|
||||||
[self decreasePassengerReputation];
|
[self decreasePassengerReputation];
|
||||||
}
|
}
|
||||||
@ -215,9 +215,9 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
|||||||
// pay the premium and fee
|
// pay the premium and fee
|
||||||
credits += fee + premium;
|
credits += fee + premium;
|
||||||
if (!result)
|
if (!result)
|
||||||
result = [NSString stringWithFormat:[universe expandDescription:@"[cargo-delivered-okay-@-f]" forSystem:system_seed], contract_cargo_desc, (float)(fee + premium) / 10.0];
|
result = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[cargo-delivered-okay-@-f]"), contract_cargo_desc, (float)(fee + premium) / 10.0];
|
||||||
else
|
else
|
||||||
result = [NSString stringWithFormat:[universe expandDescription:@"%@\n[cargo-delivered-okay-@-f]" forSystem:system_seed], result, contract_cargo_desc, (float)(fee + premium) / 10.0];
|
result = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"%@\n[cargo-delivered-okay-@-f]"), result, contract_cargo_desc, (float)(fee + premium) / 10.0];
|
||||||
[contracts removeObjectAtIndex:i--];
|
[contracts removeObjectAtIndex:i--];
|
||||||
// repute++
|
// repute++
|
||||||
[self increaseContractReputation];
|
[self increaseContractReputation];
|
||||||
@ -244,18 +244,18 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
|||||||
int payment = percent_delivered * (fee + premium) / 100.0;
|
int payment = percent_delivered * (fee + premium) / 100.0;
|
||||||
credits += payment;
|
credits += payment;
|
||||||
if (!result)
|
if (!result)
|
||||||
result = [NSString stringWithFormat:[universe expandDescription:@"[cargo-delivered-short-@-f-d]" forSystem:system_seed], contract_cargo_desc, (float)payment / 10.0, shortfall];
|
result = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[cargo-delivered-short-@-f-d]"), contract_cargo_desc, (float)payment / 10.0, shortfall];
|
||||||
else
|
else
|
||||||
result = [NSString stringWithFormat:[universe expandDescription:@"%@\n[cargo-delivered-short-@-f-d]" forSystem:system_seed], contract_cargo_desc, (float)payment / 10.0, shortfall];
|
result = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"%@\n[cargo-delivered-short-@-f-d]"), contract_cargo_desc, (float)payment / 10.0, shortfall];
|
||||||
[contracts removeObjectAtIndex:i--];
|
[contracts removeObjectAtIndex:i--];
|
||||||
// repute unchanged
|
// repute unchanged
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!result)
|
if (!result)
|
||||||
result = [NSString stringWithFormat:[universe expandDescription:@"[cargo-refused-short-%@]" forSystem:system_seed], contract_cargo_desc];
|
result = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[cargo-refused-short-%@]"), contract_cargo_desc];
|
||||||
else
|
else
|
||||||
result = [NSString stringWithFormat:[universe expandDescription:@"%@\n[cargo-refused-short-%@]" forSystem:system_seed], contract_cargo_desc];
|
result = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"%@\n[cargo-refused-short-%@]"), contract_cargo_desc];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,9 +263,9 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
|||||||
{
|
{
|
||||||
// but we're late!
|
// but we're late!
|
||||||
if (!result)
|
if (!result)
|
||||||
result = [NSString stringWithFormat:[universe expandDescription:@"[cargo-delivered-late-@]" forSystem:system_seed], contract_cargo_desc];
|
result = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[cargo-delivered-late-@]"), contract_cargo_desc];
|
||||||
else
|
else
|
||||||
result = [NSString stringWithFormat:[universe expandDescription:@"%@\n[cargo-delivered-late-@]" forSystem:system_seed], result, contract_cargo_desc];
|
result = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"%@\n[cargo-delivered-late-@]"), result, contract_cargo_desc];
|
||||||
[contracts removeObjectAtIndex:i--];
|
[contracts removeObjectAtIndex:i--];
|
||||||
// repute--
|
// repute--
|
||||||
[self decreaseContractReputation];
|
[self decreaseContractReputation];
|
||||||
@ -277,9 +277,9 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
|||||||
{
|
{
|
||||||
// we've run out of time!
|
// we've run out of time!
|
||||||
if (!result)
|
if (!result)
|
||||||
result = [NSString stringWithFormat:[universe expandDescription:@"[cargo-failed-@]" forSystem:system_seed], contract_cargo_desc];
|
result = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[cargo-failed-@]"), contract_cargo_desc];
|
||||||
else
|
else
|
||||||
result = [NSString stringWithFormat:[universe expandDescription:@"%@\n[cargo-failed-@]" forSystem:system_seed], result, contract_cargo_desc];
|
result = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"%@\n[cargo-failed-@]"), result, contract_cargo_desc];
|
||||||
[contracts removeObjectAtIndex:i--];
|
[contracts removeObjectAtIndex:i--];
|
||||||
// repute--
|
// repute--
|
||||||
[self decreaseContractReputation];
|
[self decreaseContractReputation];
|
||||||
@ -696,8 +696,6 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
|||||||
[passenger_market removeObject:passenger_info];
|
[passenger_market removeObject:passenger_info];
|
||||||
credits += 10 * passenger_premium;
|
credits += 10 * passenger_premium;
|
||||||
|
|
||||||
// NSLog(@"DEBUG passengers:\n%@", [passengers description]);
|
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -743,8 +741,6 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
|||||||
[contract_record setObject:contract_arrival_time forKey:contract_id];
|
[contract_record setObject:contract_arrival_time forKey:contract_id];
|
||||||
[contract_market removeObject:contract_info];
|
[contract_market removeObject:contract_info];
|
||||||
|
|
||||||
// NSLog(@"DEBUG contracts:\n%@", [contracts description]);
|
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
@ -967,7 +963,7 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
|||||||
// GUI stuff
|
// GUI stuff
|
||||||
{
|
{
|
||||||
[gui clear];
|
[gui clear];
|
||||||
[gui setTitle:[universe expandDescription:@"[arrival-report-title]" forSystem:system_seed]];
|
[gui setTitle:ExpandDescriptionForCurrentSystem(@"[arrival-report-title]")];
|
||||||
//
|
//
|
||||||
|
|
||||||
// report might be a multi-line message
|
// report might be a multi-line message
|
||||||
@ -1017,7 +1013,7 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
|||||||
// GUI stuff
|
// GUI stuff
|
||||||
{
|
{
|
||||||
[gui clear];
|
[gui clear];
|
||||||
[gui setTitle:[universe expandDescription:@"[arrival-report-title]" forSystem:system_seed]];
|
[gui setTitle:ExpandDescriptionForCurrentSystem(@"[arrival-report-title]")];
|
||||||
//
|
//
|
||||||
|
|
||||||
// dockingReport might be a multi-line message
|
// dockingReport might be a multi-line message
|
||||||
@ -1159,9 +1155,6 @@ static NSMutableDictionary* currentShipyard = nil;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSLog(@"DEBUG Ships for sale n_ships:%d MAX_ROWS_SHIPS_FOR_SALE:%d n_rows:%d skip:%d", n_ships, MAX_ROWS_SHIPS_FOR_SALE, n_rows, skip);
|
|
||||||
|
|
||||||
//
|
|
||||||
if (n_ships > 0)
|
if (n_ships > 0)
|
||||||
{
|
{
|
||||||
[gui setColor:[OOColor greenColor] forRow:GUI_ROW_SHIPYARD_LABELS];
|
[gui setColor:[OOColor greenColor] forRow:GUI_ROW_SHIPYARD_LABELS];
|
||||||
@ -1227,8 +1220,6 @@ static NSMutableDictionary* currentShipyard = nil;
|
|||||||
GuiDisplayGen* gui = [universe gui];
|
GuiDisplayGen* gui = [universe gui];
|
||||||
int sel_row = [gui selectedRow];
|
int sel_row = [gui selectedRow];
|
||||||
|
|
||||||
// NSLog(@"-- %d %d %d", sel_row, [gui selectableRange].location, [gui selectableRange].length);
|
|
||||||
|
|
||||||
if (sel_row <= 0)
|
if (sel_row <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1238,7 +1229,6 @@ static NSMutableDictionary* currentShipyard = nil;
|
|||||||
|
|
||||||
NSString* key = [gui keyForRow:sel_row];
|
NSString* key = [gui keyForRow:sel_row];
|
||||||
|
|
||||||
// NSDictionary* info = (NSDictionary *)[[docked_station localShipyard] objectAtIndex:sel_row - GUI_ROW_SHIPYARD_START];
|
|
||||||
NSDictionary* info = (NSDictionary *)[currentShipyard objectForKey:key];
|
NSDictionary* info = (NSDictionary *)[currentShipyard objectForKey:key];
|
||||||
|
|
||||||
if (info)
|
if (info)
|
||||||
@ -1330,12 +1320,8 @@ static NSMutableDictionary* currentShipyard = nil;
|
|||||||
|
|
||||||
if ([key hasPrefix:@"More:"])
|
if ([key hasPrefix:@"More:"])
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG Key is '%@'", key);
|
|
||||||
|
|
||||||
int from_ship = [(NSString*)[[key componentsSeparatedByString:@":"] objectAtIndex:1] intValue];
|
int from_ship = [(NSString*)[[key componentsSeparatedByString:@":"] objectAtIndex:1] intValue];
|
||||||
|
|
||||||
// NSLog(@"DEBUG skipping %d", from_ship);
|
|
||||||
|
|
||||||
[self setGuiToShipyardScreen:from_ship];
|
[self setGuiToShipyardScreen:from_ship];
|
||||||
if ([[universe gui] selectedRow] < 0)
|
if ([[universe gui] selectedRow] < 0)
|
||||||
[[universe gui] setSelectedRow:GUI_ROW_SHIPYARD_START];
|
[[universe gui] setSelectedRow:GUI_ROW_SHIPYARD_START];
|
||||||
@ -1389,8 +1375,6 @@ static NSMutableDictionary* currentShipyard = nil;
|
|||||||
starboard_weapon = WEAPON_NONE;
|
starboard_weapon = WEAPON_NONE;
|
||||||
forward_weapon = [universe weaponForEquipmentKey:(NSString*)[(NSDictionary*)[ship_info objectForKey:SHIPYARD_KEY_SHIP] objectForKey:@"forward_weapon_type"]];
|
forward_weapon = [universe weaponForEquipmentKey:(NSString*)[(NSDictionary*)[ship_info objectForKey:SHIPYARD_KEY_SHIP] objectForKey:@"forward_weapon_type"]];
|
||||||
|
|
||||||
// NSLog(@"%@ (%d) from %@",[(NSDictionary*)[ship_info objectForKey:SHIPYARD_KEY_SHIP] objectForKey:@"forward_weapon_type"],forward_weapon,[[ship_info objectForKey:SHIPYARD_KEY_SHIP] description]);
|
|
||||||
|
|
||||||
// get basic max_cargo
|
// get basic max_cargo
|
||||||
max_cargo = [universe maxCargoForShip:ship_desc];
|
max_cargo = [universe maxCargoForShip:ship_desc];
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
{
|
{
|
||||||
if ((fuel > 0)&&(!afterburner_engaged))
|
if ((fuel > 0)&&(!afterburner_engaged))
|
||||||
{
|
{
|
||||||
[universe addMessage:[universe expandDescription:@"[fuel-inject-on]" forSystem:system_seed] forCount:1.5];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[fuel-inject-on]") forCount:1.5];
|
||||||
afterburner_engaged = YES;
|
afterburner_engaged = YES;
|
||||||
if (!afterburnerSoundLooping)
|
if (!afterburnerSoundLooping)
|
||||||
[self loopAfterburnerSound];
|
[self loopAfterburnerSound];
|
||||||
@ -181,7 +181,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (fuel <= 0.0)
|
if (fuel <= 0.0)
|
||||||
[universe addMessage:[universe expandDescription:@"[fuel-out]" forSystem:system_seed] forCount:1.5];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[fuel-out]") forCount:1.5];
|
||||||
}
|
}
|
||||||
afterburner_engaged = (fuel > 0);
|
afterburner_engaged = (fuel > 0);
|
||||||
}
|
}
|
||||||
@ -268,7 +268,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
{
|
{
|
||||||
if (![universe playCustomSound:@"[jump-mass-locked]"])
|
if (![universe playCustomSound:@"[jump-mass-locked]"])
|
||||||
[self boop];
|
[self boop];
|
||||||
[universe addMessage:[universe expandDescription:@"[jump-mass-locked]" forSystem:system_seed] forCount:1.5];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[jump-mass-locked]") forCount:1.5];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -296,7 +296,6 @@ static NSTimeInterval time_last_frame;
|
|||||||
{
|
{
|
||||||
if (target_laser_hit != NO_TARGET)
|
if (target_laser_hit != NO_TARGET)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SOUND
|
|
||||||
if (weaponHitSound)
|
if (weaponHitSound)
|
||||||
{
|
{
|
||||||
if ([weaponHitSound isPlaying])
|
if ([weaponHitSound isPlaying])
|
||||||
@ -308,11 +307,9 @@ static NSTimeInterval time_last_frame;
|
|||||||
{
|
{
|
||||||
if (weaponSound)
|
if (weaponSound)
|
||||||
{
|
{
|
||||||
if ([weaponSound isPlaying])
|
if ([weaponSound isPlaying]) [weaponSound stop];
|
||||||
[weaponSound stop];
|
|
||||||
[weaponSound play];
|
[weaponSound play];
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -331,10 +328,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
BOOL missile_noise = [[missile_entity[active_missile] roles] hasSuffix:@"MISSILE"];
|
BOOL missile_noise = [[missile_entity[active_missile] roles] hasSuffix:@"MISSILE"];
|
||||||
if ([self fireMissile])
|
if ([self fireMissile])
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SOUND
|
if (missile_noise) [missileSound play];
|
||||||
if (missile_noise)
|
|
||||||
[missileSound play];
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fire_missile_pressed = YES;
|
fire_missile_pressed = YES;
|
||||||
@ -414,7 +408,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
ident_engaged = YES;
|
ident_engaged = YES;
|
||||||
if (![universe playCustomSound:@"[ident-on]"])
|
if (![universe playCustomSound:@"[ident-on]"])
|
||||||
[self beep];
|
[self beep];
|
||||||
[universe addMessage:[universe expandDescription:@"[ident-on]" forSystem:system_seed] forCount:2.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[ident-on]") forCount:2.0];
|
||||||
}
|
}
|
||||||
ident_pressed = YES;
|
ident_pressed = YES;
|
||||||
}
|
}
|
||||||
@ -439,7 +433,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
{
|
{
|
||||||
missile_status = MISSILE_STATUS_TARGET_LOCKED;
|
missile_status = MISSILE_STATUS_TARGET_LOCKED;
|
||||||
[missile_entity[active_missile] addTarget:[self getPrimaryTarget]];
|
[missile_entity[active_missile] addTarget:[self getPrimaryTarget]];
|
||||||
[universe addMessage:[NSString stringWithFormat:[universe expandDescription:@"[missile-locked-onto-@]" forSystem:system_seed], [(ShipEntity *)[self getPrimaryTarget] identFromShip: self]] forCount:4.5];
|
[universe addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[missile-locked-onto-@]"), [(ShipEntity *)[self getPrimaryTarget] identFromShip: self]] forCount:4.5];
|
||||||
if (![universe playCustomSound:@"[missile-locked-on]"])
|
if (![universe playCustomSound:@"[missile-locked-on]"])
|
||||||
[self beep];
|
[self beep];
|
||||||
}
|
}
|
||||||
@ -451,14 +445,14 @@ static NSTimeInterval time_last_frame;
|
|||||||
{
|
{
|
||||||
if (missile_entity[active_missile])
|
if (missile_entity[active_missile])
|
||||||
[missile_entity[active_missile] removeTarget:nil];
|
[missile_entity[active_missile] removeTarget:nil];
|
||||||
[universe addMessage:[universe expandDescription:@"[missile-armed]" forSystem:system_seed] forCount:2.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[missile-armed]") forCount:2.0];
|
||||||
if (![universe playCustomSound:@"[missile-armed]"])
|
if (![universe playCustomSound:@"[missile-armed]"])
|
||||||
[self beep];
|
[self beep];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ([[missile_entity[active_missile] roles] hasSuffix:@"MINE"])
|
if ([[missile_entity[active_missile] roles] hasSuffix:@"MINE"])
|
||||||
{
|
{
|
||||||
[universe addMessage:[universe expandDescription:@"[mine-armed]" forSystem:system_seed] forCount:4.5];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[mine-armed]") forCount:4.5];
|
||||||
if (![universe playCustomSound:@"[mine-armed]"])
|
if (![universe playCustomSound:@"[mine-armed]"])
|
||||||
[self beep];
|
[self beep];
|
||||||
}
|
}
|
||||||
@ -487,7 +481,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
[self safe_all_missiles];
|
[self safe_all_missiles];
|
||||||
if (![universe playCustomSound:@"[missile-safe]"])
|
if (![universe playCustomSound:@"[missile-safe]"])
|
||||||
[self boop];
|
[self boop];
|
||||||
[universe addMessage:[universe expandDescription:@"[missile-safe]" forSystem:system_seed] forCount:2.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[missile-safe]") forCount:2.0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -496,7 +490,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
missile_status = (primaryTarget != NO_TARGET)? MISSILE_STATUS_TARGET_LOCKED : MISSILE_STATUS_SAFE;
|
missile_status = (primaryTarget != NO_TARGET)? MISSILE_STATUS_TARGET_LOCKED : MISSILE_STATUS_SAFE;
|
||||||
if (![universe playCustomSound:@"[ident-off]"])
|
if (![universe playCustomSound:@"[ident-off]"])
|
||||||
[self boop];
|
[self boop];
|
||||||
[universe addMessage:[universe expandDescription:@"[ident-off]" forSystem:system_seed] forCount:2.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[ident-off]") forCount:2.0];
|
||||||
}
|
}
|
||||||
ident_engaged = NO;
|
ident_engaged = NO;
|
||||||
}
|
}
|
||||||
@ -518,7 +512,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
if ([self fireECM])
|
if ([self fireECM])
|
||||||
{
|
{
|
||||||
[self playECMSound];
|
[self playECMSound];
|
||||||
[universe addMessage:[universe expandDescription:@"[ecm-on]" forSystem:system_seed] forCount:3.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[ecm-on]") forCount:3.0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -594,7 +588,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
isOkayToUseAutopilot = NO;
|
isOkayToUseAutopilot = NO;
|
||||||
if (![universe playCustomSound:@"[autopilot-out-of-range]"])
|
if (![universe playCustomSound:@"[autopilot-out-of-range]"])
|
||||||
[self boop];
|
[self boop];
|
||||||
[universe addMessage:[universe expandDescription:@"[autopilot-out-of-range]" forSystem:system_seed] forCount:4.5];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[autopilot-out-of-range]") forCount:4.5];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@ -610,7 +604,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
[shipAI setState:@"GLOBAL"]; // reboot the AI
|
[shipAI setState:@"GLOBAL"]; // reboot the AI
|
||||||
if (![universe playCustomSound:@"[autopilot-on]"])
|
if (![universe playCustomSound:@"[autopilot-on]"])
|
||||||
[self beep];
|
[self beep];
|
||||||
[universe addMessage:[universe expandDescription:@"[autopilot-on]" forSystem:system_seed] forCount:4.5];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[autopilot-on]") forCount:4.5];
|
||||||
//
|
//
|
||||||
if (ootunes_on)
|
if (ootunes_on)
|
||||||
{
|
{
|
||||||
@ -652,7 +646,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
[shipAI setState:@"GLOBAL"]; // restart the AI
|
[shipAI setState:@"GLOBAL"]; // restart the AI
|
||||||
if (![universe playCustomSound:@"[autopilot-on]"])
|
if (![universe playCustomSound:@"[autopilot-on]"])
|
||||||
[self beep];
|
[self beep];
|
||||||
[universe addMessage:[universe expandDescription:@"[autopilot-on]" forSystem:system_seed] forCount:4.5];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[autopilot-on]") forCount:4.5];
|
||||||
//
|
//
|
||||||
if (ootunes_on)
|
if (ootunes_on)
|
||||||
{
|
{
|
||||||
@ -672,7 +666,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
{
|
{
|
||||||
if (![universe playCustomSound:@"[autopilot-cannot-dock-with-target]"])
|
if (![universe playCustomSound:@"[autopilot-cannot-dock-with-target]"])
|
||||||
[self boop];
|
[self boop];
|
||||||
[universe addMessage:[universe expandDescription:@"Target is not capable of autopilot-docking" forSystem:system_seed] forCount:4.5];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"Target is not capable of autopilot-docking") forCount:4.5];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
target_autopilot_key_pressed = YES;
|
target_autopilot_key_pressed = YES;
|
||||||
@ -724,7 +718,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
{
|
{
|
||||||
if (![universe playCustomSound:@"[autopilot-out-of-range]"])
|
if (![universe playCustomSound:@"[autopilot-out-of-range]"])
|
||||||
[self boop];
|
[self boop];
|
||||||
[universe addMessage:[universe expandDescription:@"[autopilot-out-of-range]" forSystem:system_seed] forCount:4.5];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[autopilot-out-of-range]") forCount:4.5];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fast_autopilot_key_pressed = YES;
|
fast_autopilot_key_pressed = YES;
|
||||||
@ -752,7 +746,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
if (![universe playCustomSound:@"[witch-no-target]"])
|
if (![universe playCustomSound:@"[witch-no-target]"])
|
||||||
[self boop];
|
[self boop];
|
||||||
[universe clearPreviousMessage];
|
[universe clearPreviousMessage];
|
||||||
[universe addMessage:[universe expandDescription:@"[witch-no-target]" forSystem:system_seed] forCount:3.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[witch-no-target]") forCount:3.0];
|
||||||
jumpOK = NO;
|
jumpOK = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -761,7 +755,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
if (![universe playCustomSound:@"[witch-no-fuel]"])
|
if (![universe playCustomSound:@"[witch-no-fuel]"])
|
||||||
[self boop];
|
[self boop];
|
||||||
[universe clearPreviousMessage];
|
[universe clearPreviousMessage];
|
||||||
[universe addMessage:[universe expandDescription:@"[witch-no-fuel]" forSystem:system_seed] forCount:3.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[witch-no-fuel]") forCount:3.0];
|
||||||
jumpOK = NO;
|
jumpOK = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -779,7 +773,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
[self boop];
|
[self boop];
|
||||||
// say it!
|
// say it!
|
||||||
[universe clearPreviousMessage];
|
[universe clearPreviousMessage];
|
||||||
[universe addMessage:[universe expandDescription:@"[witch-user-abort]" forSystem:system_seed] forCount:3.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[witch-user-abort]") forCount:3.0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jumpOK)
|
if (jumpOK)
|
||||||
@ -791,7 +785,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
[self beep];
|
[self beep];
|
||||||
// say it!
|
// say it!
|
||||||
[universe clearPreviousMessage];
|
[universe clearPreviousMessage];
|
||||||
[universe addMessage:[NSString stringWithFormat:[universe expandDescription:@"[witch-to-@-in-f-seconds]" forSystem:system_seed], [universe getSystemName:target_system_seed], witchspaceCountdown] forCount:1.0];
|
[universe addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[witch-to-@-in-f-seconds]"), [universe getSystemName:target_system_seed], witchspaceCountdown] forCount:1.0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hyperspace_pressed = YES;
|
hyperspace_pressed = YES;
|
||||||
@ -825,7 +819,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
[self boop];
|
[self boop];
|
||||||
// say it!
|
// say it!
|
||||||
[universe clearPreviousMessage];
|
[universe clearPreviousMessage];
|
||||||
[universe addMessage:[universe expandDescription:@"[witch-user-abort]" forSystem:system_seed] forCount:3.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[witch-user-abort]") forCount:3.0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jumpOK)
|
if (jumpOK)
|
||||||
@ -837,7 +831,7 @@ static NSTimeInterval time_last_frame;
|
|||||||
if (![universe playCustomSound:@"[hyperspace-countdown-begun]"])
|
if (![universe playCustomSound:@"[hyperspace-countdown-begun]"])
|
||||||
[self beep];
|
[self beep];
|
||||||
// say it!
|
// say it!
|
||||||
[universe addMessage:[NSString stringWithFormat:[universe expandDescription:@"[witch-galactic-in-f-seconds]" forSystem:system_seed], witchspaceCountdown] forCount:1.0];
|
[universe addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[witch-galactic-in-f-seconds]"), witchspaceCountdown] forCount:1.0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
galhyperspace_pressed = YES;
|
galhyperspace_pressed = YES;
|
||||||
@ -858,14 +852,14 @@ static NSTimeInterval time_last_frame;
|
|||||||
if (!cloaking_device_active)
|
if (!cloaking_device_active)
|
||||||
{
|
{
|
||||||
if ([self activateCloakingDevice])
|
if ([self activateCloakingDevice])
|
||||||
[universe addMessage:[universe expandDescription:@"[cloak-on]" forSystem:system_seed] forCount:2];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[cloak-on]") forCount:2];
|
||||||
else
|
else
|
||||||
[universe addMessage:[universe expandDescription:@"[cloak-low-juice]" forSystem:system_seed] forCount:3];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[cloak-low-juice]") forCount:3];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[self deactivateCloakingDevice];
|
[self deactivateCloakingDevice];
|
||||||
[universe addMessage:[universe expandDescription:@"[cloak-off]" forSystem:system_seed] forCount:2];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[cloak-off]") forCount:2];
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
if (cloaking_device_active)
|
if (cloaking_device_active)
|
||||||
@ -994,8 +988,8 @@ static NSTimeInterval time_last_frame;
|
|||||||
{
|
{
|
||||||
saved_view_direction = [universe viewDir];
|
saved_view_direction = [universe viewDir];
|
||||||
saved_script_time = script_time;
|
saved_script_time = script_time;
|
||||||
[universe addMessage:[universe expandDescription:@"[game-paused]" forSystem:system_seed] forCount:1.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[game-paused]") forCount:1.0];
|
||||||
[universe addMessage:[universe expandDescription:@"[game-paused-options]" forSystem:system_seed] forCount:1.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[game-paused-options]") forCount:1.0];
|
||||||
[[gameView gameController] pause_game];
|
[[gameView gameController] pause_game];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1030,7 +1024,7 @@ static BOOL taking_snapshot;
|
|||||||
{
|
{
|
||||||
[[gameView gameController] exitFullScreenMode];
|
[[gameView gameController] exitFullScreenMode];
|
||||||
if (mouse_control_on)
|
if (mouse_control_on)
|
||||||
[universe addMessage:[universe expandDescription:@"[mouse-off]" forSystem:system_seed] forCount:3.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[mouse-off]") forCount:3.0];
|
||||||
mouse_control_on = NO;
|
mouse_control_on = NO;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@ -1065,7 +1059,7 @@ static BOOL taking_snapshot;
|
|||||||
//
|
//
|
||||||
if ([gameView isDown: 64]) // '@'
|
if ([gameView isDown: 64]) // '@'
|
||||||
{
|
{
|
||||||
NSLog(@"%@ status==%@ guiscreen==%@", self, [self status_string], [self gui_screen_string]);
|
OOLog(@"debug.atKey", @"%@ status==%@ guiscreen==%@", self, [self status_string], [self gui_screen_string]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -1108,13 +1102,13 @@ static BOOL taking_snapshot;
|
|||||||
mouse_control_on = !mouse_control_on;
|
mouse_control_on = !mouse_control_on;
|
||||||
if (mouse_control_on)
|
if (mouse_control_on)
|
||||||
{
|
{
|
||||||
[universe addMessage:[universe expandDescription:@"[mouse-on]" forSystem:system_seed] forCount:3.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[mouse-on]") forCount:3.0];
|
||||||
// ensure the keyboard pitch override (intended to lock out the joystick if the
|
// ensure the keyboard pitch override (intended to lock out the joystick if the
|
||||||
// player runs to the keyboard) is reset
|
// player runs to the keyboard) is reset
|
||||||
keyboardRollPitchOverride = NO;
|
keyboardRollPitchOverride = NO;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
[universe addMessage:[universe expandDescription:@"[mouse-off]" forSystem:system_seed] forCount:3.0];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[mouse-off]") forCount:3.0];
|
||||||
}
|
}
|
||||||
m_key_pressed = YES;
|
m_key_pressed = YES;
|
||||||
}
|
}
|
||||||
@ -1447,7 +1441,6 @@ static BOOL spacePressed;
|
|||||||
double vscale = 4.0 * MAIN_GUI_PIXEL_HEIGHT / 512.0;
|
double vscale = 4.0 * MAIN_GUI_PIXEL_HEIGHT / 512.0;
|
||||||
cursor_coordinates.x = galaxy_coordinates.x + (maus.x * MAIN_GUI_PIXEL_WIDTH) / hscale;
|
cursor_coordinates.x = galaxy_coordinates.x + (maus.x * MAIN_GUI_PIXEL_WIDTH) / hscale;
|
||||||
cursor_coordinates.y = galaxy_coordinates.y + (maus.y * MAIN_GUI_PIXEL_HEIGHT + vadjust) / vscale;
|
cursor_coordinates.y = galaxy_coordinates.y + (maus.y * MAIN_GUI_PIXEL_HEIGHT + vadjust) / vscale;
|
||||||
//NSLog(@"DEBUG mouse (%.3f,%.3f), coordinates (%.3f,%.3f) vadjust %.1f", maus.x, maus.y, cursor_coordinates.x, cursor_coordinates.y, vadjust);
|
|
||||||
}
|
}
|
||||||
if (gui_screen == GUI_SCREEN_LONG_RANGE_CHART)
|
if (gui_screen == GUI_SCREEN_LONG_RANGE_CHART)
|
||||||
{
|
{
|
||||||
@ -1457,7 +1450,6 @@ static BOOL spacePressed;
|
|||||||
double vscale = MAIN_GUI_PIXEL_HEIGHT / 512.0;
|
double vscale = MAIN_GUI_PIXEL_HEIGHT / 512.0;
|
||||||
cursor_coordinates.x = (maus.x * MAIN_GUI_PIXEL_WIDTH + hadjust)/ hscale;
|
cursor_coordinates.x = (maus.x * MAIN_GUI_PIXEL_WIDTH + hadjust)/ hscale;
|
||||||
cursor_coordinates.y = (maus.y * MAIN_GUI_PIXEL_HEIGHT + vadjust) / vscale;
|
cursor_coordinates.y = (maus.y * MAIN_GUI_PIXEL_HEIGHT + vadjust) / vscale;
|
||||||
//NSLog(@"DEBUG mouse (%.3f,%.3f), coordinates (%.3f,%.3f) vadjust %.1f", maus.x, maus.y, cursor_coordinates.x, cursor_coordinates.y, vadjust);
|
|
||||||
}
|
}
|
||||||
[gameView resetTypedString];
|
[gameView resetTypedString];
|
||||||
moving = YES;
|
moving = YES;
|
||||||
@ -1594,10 +1586,10 @@ static BOOL spacePressed;
|
|||||||
disc_operation_in_progress = YES;
|
disc_operation_in_progress = YES;
|
||||||
[self quicksavePlayer];
|
[self quicksavePlayer];
|
||||||
NS_HANDLER
|
NS_HANDLER
|
||||||
NSLog(@"\n\n***** Handling localException: %@ : %@ *****\n\n",[localException name], [localException reason]);
|
OOLog(kOOLogException, @"\n\n***** Handling localException: %@ : %@ *****\n\n",[localException name], [localException reason]);
|
||||||
if ([[localException name] isEqual:@"GameNotSavedException"]) // try saving game instead
|
if ([[localException name] isEqual:@"GameNotSavedException"]) // try saving game instead
|
||||||
{
|
{
|
||||||
NSLog(@"\n\n***** Trying a normal save instead *****\n\n");
|
OOLog(kOOLogException, @"\n\n***** Trying a normal save instead *****\n\n");
|
||||||
if ([[universe gameController] inFullScreenMode])
|
if ([[universe gameController] inFullScreenMode])
|
||||||
[[universe gameController] pauseFullScreenModeToPerform:@selector(savePlayer) onTarget:self];
|
[[universe gameController] pauseFullScreenModeToPerform:@selector(savePlayer) onTarget:self];
|
||||||
else
|
else
|
||||||
@ -1663,7 +1655,7 @@ static BOOL spacePressed;
|
|||||||
int displayModeIndex = [controller indexOfCurrentDisplayMode];
|
int displayModeIndex = [controller indexOfCurrentDisplayMode];
|
||||||
if (displayModeIndex == NSNotFound)
|
if (displayModeIndex == NSNotFound)
|
||||||
{
|
{
|
||||||
NSLog(@"***** couldn't find current display mode switching to basic 640x480");
|
OOLog(@"graphics.mode.notFound", @"***** couldn't find current display mode switching to basic 640x480");
|
||||||
displayModeIndex = 0;
|
displayModeIndex = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1902,7 +1894,6 @@ static BOOL spacePressed;
|
|||||||
if (!wait_for_key_up)
|
if (!wait_for_key_up)
|
||||||
{
|
{
|
||||||
int item = [(NSString *)[gui selectedRowKey] intValue];
|
int item = [(NSString *)[gui selectedRowKey] intValue];
|
||||||
//NSLog(@"Try Buying Commodity %d",item);
|
|
||||||
if ([self tryBuyingCommodity:item])
|
if ([self tryBuyingCommodity:item])
|
||||||
[self setGuiToMarketScreen];
|
[self setGuiToMarketScreen];
|
||||||
else
|
else
|
||||||
@ -1915,7 +1906,6 @@ static BOOL spacePressed;
|
|||||||
if (!wait_for_key_up)
|
if (!wait_for_key_up)
|
||||||
{
|
{
|
||||||
int item = [(NSString *)[gui selectedRowKey] intValue];
|
int item = [(NSString *)[gui selectedRowKey] intValue];
|
||||||
//NSLog(@"Try Selling Commodity %d",item);
|
|
||||||
if ([self trySellingCommodity:item])
|
if ([self trySellingCommodity:item])
|
||||||
[self setGuiToMarketScreen];
|
[self setGuiToMarketScreen];
|
||||||
else
|
else
|
||||||
@ -1934,13 +1924,11 @@ static BOOL spacePressed;
|
|||||||
{
|
{
|
||||||
int item = [(NSString *)[gui selectedRowKey] intValue];
|
int item = [(NSString *)[gui selectedRowKey] intValue];
|
||||||
int yours = [(NSNumber *)[(NSArray *)[shipCommodityData objectAtIndex:item] objectAtIndex:1] intValue];
|
int yours = [(NSNumber *)[(NSArray *)[shipCommodityData objectAtIndex:item] objectAtIndex:1] intValue];
|
||||||
//NSLog(@"buy/sell all of item %d (you have %d)",item,yours);
|
|
||||||
if ((yours > 0)&&(![self marketFlooded:item])) // sell all you can
|
if ((yours > 0)&&(![self marketFlooded:item])) // sell all you can
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < yours; i++)
|
for (i = 0; i < yours; i++)
|
||||||
[self trySellingCommodity:item];
|
[self trySellingCommodity:item];
|
||||||
//NSLog(@"... you sold %d.", yours);
|
|
||||||
[self playInterfaceBeep:kInterfaceBeep_Sell];
|
[self playInterfaceBeep:kInterfaceBeep_Sell];
|
||||||
[self setGuiToMarketScreen];
|
[self setGuiToMarketScreen];
|
||||||
}
|
}
|
||||||
@ -1949,7 +1937,6 @@ static BOOL spacePressed;
|
|||||||
int amount_bought = 0;
|
int amount_bought = 0;
|
||||||
while ([self tryBuyingCommodity:item])
|
while ([self tryBuyingCommodity:item])
|
||||||
amount_bought++;
|
amount_bought++;
|
||||||
//NSLog(@"... you bought %d.", amount_bought);
|
|
||||||
[self setGuiToMarketScreen];
|
[self setGuiToMarketScreen];
|
||||||
if (amount_bought == 0)
|
if (amount_bought == 0)
|
||||||
{
|
{
|
||||||
@ -2442,7 +2429,7 @@ static BOOL toggling_music;
|
|||||||
status = STATUS_IN_FLIGHT;
|
status = STATUS_IN_FLIGHT;
|
||||||
if (![universe playCustomSound:@"[autopilot-off]"])
|
if (![universe playCustomSound:@"[autopilot-off]"])
|
||||||
[self beep];
|
[self beep];
|
||||||
[universe addMessage:[universe expandDescription:@"[autopilot-off]" forSystem:system_seed] forCount:4.5];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[autopilot-off]") forCount:4.5];
|
||||||
//
|
//
|
||||||
if (ootunes_on)
|
if (ootunes_on)
|
||||||
{
|
{
|
||||||
@ -2487,7 +2474,6 @@ static BOOL toggling_music;
|
|||||||
[universe set_up_universe_from_station]; // launch!
|
[universe set_up_universe_from_station]; // launch!
|
||||||
if (!docked_station)
|
if (!docked_station)
|
||||||
docked_station = [universe station];
|
docked_station = [universe station];
|
||||||
//NSLog(@"Leaving dock (%@)...%@",docked_station,[docked_station name]);
|
|
||||||
[self leaveDock:docked_station];
|
[self leaveDock:docked_station];
|
||||||
[universe setDisplayCursor:NO];
|
[universe setDisplayCursor:NO];
|
||||||
}
|
}
|
||||||
@ -2583,7 +2569,6 @@ static BOOL toggling_music;
|
|||||||
case GUI_SCREEN_MISSION :
|
case GUI_SCREEN_MISSION :
|
||||||
if ([[gui keyForRow:21] isEqual:@"spacebar"])
|
if ([[gui keyForRow:21] isEqual:@"spacebar"])
|
||||||
{
|
{
|
||||||
// NSLog(@"GUI_SCREEN_MISSION looking for spacebar");
|
|
||||||
if ([gameView isDown:32]) // '<space>'
|
if ([gameView isDown:32]) // '<space>'
|
||||||
{
|
{
|
||||||
if (!spacePressed)
|
if (!spacePressed)
|
||||||
@ -2602,7 +2587,6 @@ static BOOL toggling_music;
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// NSLog(@"GUI_SCREEN_MISSION looking for up/down/select");
|
|
||||||
if ([gameView isDown:gvArrowKeyDown])
|
if ([gameView isDown:gvArrowKeyDown])
|
||||||
{
|
{
|
||||||
if ((!upDownKeyPressed)||(script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
|
if ((!upDownKeyPressed)||(script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
|
||||||
|
@ -39,6 +39,8 @@ MA 02110-1301, USA.
|
|||||||
#import "ResourceManager.h"
|
#import "ResourceManager.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.PlayerEntityLoadSave"
|
||||||
|
|
||||||
@implementation PlayerEntity (LoadSave)
|
@implementation PlayerEntity (LoadSave)
|
||||||
|
|
||||||
- (void) setGuiToLoadCommanderScreen
|
- (void) setGuiToLoadCommanderScreen
|
||||||
@ -510,7 +512,6 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
if(![[self commanderDataDictionary] writeOOXMLToFile:savePath atomically:YES])
|
if(![[self commanderDataDictionary] writeOOXMLToFile:savePath atomically:YES])
|
||||||
{
|
{
|
||||||
//NSBeep(); // appkit dependency
|
|
||||||
NSLog(@"***** ERROR: Save to %@ failed!", savePath);
|
NSLog(@"***** ERROR: Save to %@ failed!", savePath);
|
||||||
NSException *myException = [NSException
|
NSException *myException = [NSException
|
||||||
exceptionWithName:@"OoliteException"
|
exceptionWithName:@"OoliteException"
|
||||||
@ -529,7 +530,7 @@ MA 02110-1301, USA.
|
|||||||
[[universe gameController] setPlayerFileDirectory:save_path];
|
[[universe gameController] setPlayerFileDirectory:save_path];
|
||||||
|
|
||||||
[universe clearPreviousMessage]; // allow this to be given time and again
|
[universe clearPreviousMessage]; // allow this to be given time and again
|
||||||
[universe addMessage:[universe expandDescription:@"[game-saved]" forSystem:system_seed] forCount:2];
|
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[game-saved]") forCount:2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for an existing saved game...
|
// check for an existing saved game...
|
||||||
@ -607,7 +608,7 @@ MA 02110-1301, USA.
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSLog(@"\n\n***** Encountered localException in [PlayerEntity (LoadSave) showCommanderShip:] : %@ : %@ *****\n\n", [localException name], [localException reason]);
|
OOLog(kOOLogException, @"***** Exception in [PlayerEntity (LoadSave) showCommanderShip:] : %@ : %@ *****", [localException name], [localException reason]);
|
||||||
[localException raise];
|
[localException raise];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,8 @@ MA 02110-1301, USA.
|
|||||||
#import "Comparison.h"
|
#import "Comparison.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.PlayerEntityScripting"
|
||||||
|
|
||||||
static NSString * const kOOLogScriptAddShipsFailed = @"script.addShips.failed";
|
static NSString * const kOOLogScriptAddShipsFailed = @"script.addShips.failed";
|
||||||
static NSString * const kOOLogScriptMissionDescNoText = @"script.missionDescription.noMissionText";
|
static NSString * const kOOLogScriptMissionDescNoText = @"script.missionDescription.noMissionText";
|
||||||
static NSString * const kOOLogScriptMissionDescNoKey = @"script.missionDescription.noMissionKey";
|
static NSString * const kOOLogScriptMissionDescNoKey = @"script.missionDescription.noMissionKey";
|
||||||
@ -123,7 +125,7 @@ static NSString * mission_key;
|
|||||||
|
|
||||||
- (void) scriptActions:(NSArray*) some_actions forTarget:(ShipEntity*) a_target
|
- (void) scriptActions:(NSArray*) some_actions forTarget:(ShipEntity*) a_target
|
||||||
{
|
{
|
||||||
PlayerEntity* player = (PlayerEntity *)[universe entityZero];
|
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < [some_actions count]; i++)
|
for (i = 0; i < [some_actions count]; i++)
|
||||||
{
|
{
|
||||||
@ -227,7 +229,7 @@ static NSString * mission_key;
|
|||||||
{
|
{
|
||||||
[tokens removeObjectAtIndex:0];
|
[tokens removeObjectAtIndex:0];
|
||||||
valueString = [[tokens componentsJoinedByString:@" "] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
valueString = [[tokens componentsJoinedByString:@" "] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
||||||
valueString = [universe expandDescriptionWithLocals:valueString forSystem:[self system_seed] withLocalVariables:locals];
|
valueString = ExpandDescriptionsWithLocalsForCurrentSystem(valueString, locals);
|
||||||
OOLog(kOOLogNoteScriptAction, @"scriptAction after expansion: \"%@ %@\"", selectorString, valueString);
|
OOLog(kOOLogNoteScriptAction, @"scriptAction after expansion: \"%@ %@\"", selectorString, valueString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,7 +508,7 @@ static NSString * mission_key;
|
|||||||
OOLog(kOOLogScriptMissionDescNoKey, @"SCRIPT ERROR ***** mission_key not set");
|
OOLog(kOOLogScriptMissionDescNoKey, @"SCRIPT ERROR ***** mission_key not set");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
text = [universe expandDescription:text forSystem:system_seed];
|
text = ExpandDescriptionForCurrentSystem(text);
|
||||||
text = [self replaceVariablesInString: text];
|
text = [self replaceVariablesInString: text];
|
||||||
|
|
||||||
[mission_variables setObject:text forKey:mission_key];
|
[mission_variables setObject:text forKey:mission_key];
|
||||||
@ -850,7 +852,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
|||||||
very_random_seed.e = rand() & 255;
|
very_random_seed.e = rand() & 255;
|
||||||
very_random_seed.f = rand() & 255;
|
very_random_seed.f = rand() & 255;
|
||||||
seed_RNG_only_for_planet_description(very_random_seed);
|
seed_RNG_only_for_planet_description(very_random_seed);
|
||||||
NSString* expandedMessage = [universe expandDescription:valueString forSystem:[universe systemSeed]];
|
NSString* expandedMessage = ExpandDescriptionForCurrentSystem(valueString);
|
||||||
expandedMessage = [self replaceVariablesInString: expandedMessage];
|
expandedMessage = [self replaceVariablesInString: expandedMessage];
|
||||||
|
|
||||||
[universe addCommsMessage:expandedMessage forCount:4.5];
|
[universe addCommsMessage:expandedMessage forCount:4.5];
|
||||||
@ -867,7 +869,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
|||||||
very_random_seed.e = rand() & 255;
|
very_random_seed.e = rand() & 255;
|
||||||
very_random_seed.f = rand() & 255;
|
very_random_seed.f = rand() & 255;
|
||||||
seed_RNG_only_for_planet_description(very_random_seed);
|
seed_RNG_only_for_planet_description(very_random_seed);
|
||||||
NSString* expandedMessage = [universe expandDescription:valueString forSystem:[universe systemSeed]];
|
NSString* expandedMessage = ExpandDescriptionForCurrentSystem(valueString);
|
||||||
expandedMessage = [self replaceVariablesInString: expandedMessage];
|
expandedMessage = [self replaceVariablesInString: expandedMessage];
|
||||||
|
|
||||||
[universe addMessage: expandedMessage forCount: 3];
|
[universe addMessage: expandedMessage forCount: 3];
|
||||||
@ -883,7 +885,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
|||||||
very_random_seed.e = rand() & 255;
|
very_random_seed.e = rand() & 255;
|
||||||
very_random_seed.f = rand() & 255;
|
very_random_seed.f = rand() & 255;
|
||||||
seed_RNG_only_for_planet_description(very_random_seed);
|
seed_RNG_only_for_planet_description(very_random_seed);
|
||||||
NSString* expandedMessage = [universe expandDescription:valueString forSystem:[universe systemSeed]];
|
NSString* expandedMessage = ExpandDescriptionForCurrentSystem(valueString);
|
||||||
expandedMessage = [self replaceVariablesInString: expandedMessage];
|
expandedMessage = [self replaceVariablesInString: expandedMessage];
|
||||||
|
|
||||||
[universe addMessage: expandedMessage forCount: 6];
|
[universe addMessage: expandedMessage forCount: 6];
|
||||||
@ -928,7 +930,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
|||||||
|
|
||||||
if ([eq_type hasSuffix:@"MISSILE"]||[eq_type hasSuffix:@"MINE"])
|
if ([eq_type hasSuffix:@"MISSILE"]||[eq_type hasSuffix:@"MINE"])
|
||||||
{
|
{
|
||||||
if ([self mountMissile:[[universe getShipWithRole:eq_type] autorelease]])
|
if ([self mountMissile:[[universe newShipWithRole:eq_type] autorelease]])
|
||||||
missiles++;
|
missiles++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1049,7 +1051,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
|||||||
int smaller_quantity = 1 + ((amount - 1) % amount_per_container);
|
int smaller_quantity = 1 + ((amount - 1) % amount_per_container);
|
||||||
if ([cargo count] < max_cargo)
|
if ([cargo count] < max_cargo)
|
||||||
{
|
{
|
||||||
ShipEntity* container = [universe getShipWithRole:@"cargopod"];
|
ShipEntity* container = [universe newShipWithRole:@"cargopod"];
|
||||||
if (container)
|
if (container)
|
||||||
{
|
{
|
||||||
[container setUniverse:universe];
|
[container setUniverse:universe];
|
||||||
@ -1069,7 +1071,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
|||||||
{
|
{
|
||||||
if ([cargo count] < max_cargo)
|
if ([cargo count] < max_cargo)
|
||||||
{
|
{
|
||||||
ShipEntity* container = [universe getShipWithRole:@"cargopod"];
|
ShipEntity* container = [universe newShipWithRole:@"cargopod"];
|
||||||
if (container)
|
if (container)
|
||||||
{
|
{
|
||||||
[container setUniverse:universe];
|
[container setUniverse:universe];
|
||||||
@ -1139,7 +1141,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
[self removeAllCargo];
|
[self removeAllCargo];
|
||||||
specialCargo = [[universe expandDescription:descriptionString forSystem:system_seed] retain];
|
specialCargo = [ExpandDescriptionForCurrentSystem(descriptionString) retain];
|
||||||
//
|
//
|
||||||
OOLog(kOOLogNoteUseSpecialCargo, @"Going to useSpecialCargo:'%@'", specialCargo);
|
OOLog(kOOLogNoteUseSpecialCargo, @"Going to useSpecialCargo:'%@'", specialCargo);
|
||||||
}
|
}
|
||||||
@ -1179,7 +1181,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
|||||||
|
|
||||||
- (void) ejectItem:(NSString *)item_key
|
- (void) ejectItem:(NSString *)item_key
|
||||||
{
|
{
|
||||||
ShipEntity* item = [universe getShip:item_key];
|
ShipEntity* item = [universe newShipWithName:item_key];
|
||||||
if (script_target == nil)
|
if (script_target == nil)
|
||||||
script_target = self;
|
script_target = self;
|
||||||
if (item)
|
if (item)
|
||||||
@ -1559,9 +1561,9 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
|||||||
//
|
//
|
||||||
GuiDisplayGen *gui = [universe gui];
|
GuiDisplayGen *gui = [universe gui];
|
||||||
NSString *text = (NSString *)[[universe missiontext] objectForKey:textKey];
|
NSString *text = (NSString *)[[universe missiontext] objectForKey:textKey];
|
||||||
text = [universe expandDescription:text forSystem:system_seed];
|
text = ExpandDescriptionForCurrentSystem(text);
|
||||||
text = [self replaceVariablesInString: text];
|
text = [self replaceVariablesInString: text];
|
||||||
//NSLog(@"::::: Adding text '%@':\n'%@'", textKey, text);
|
|
||||||
NSArray *paras = [text componentsSeparatedByString:@"\\n"];
|
NSArray *paras = [text componentsSeparatedByString:@"\\n"];
|
||||||
if (text)
|
if (text)
|
||||||
{
|
{
|
||||||
@ -1602,7 +1604,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
|||||||
{
|
{
|
||||||
NSString* choice_key = (NSString *)[choice_keys objectAtIndex:i];
|
NSString* choice_key = (NSString *)[choice_keys objectAtIndex:i];
|
||||||
NSString* choice_text = [NSString stringWithFormat:@" %@ ",[choices_dict objectForKey:choice_key]];
|
NSString* choice_text = [NSString stringWithFormat:@" %@ ",[choices_dict objectForKey:choice_key]];
|
||||||
choice_text = [universe expandDescription:choice_text forSystem:system_seed];
|
choice_text = ExpandDescriptionForCurrentSystem(choice_text);
|
||||||
choice_text = [self replaceVariablesInString: choice_text];
|
choice_text = [self replaceVariablesInString: choice_text];
|
||||||
[gui setText:choice_text forRow:choices_row align: GUI_ALIGN_CENTER];
|
[gui setText:choice_text forRow:choices_row align: GUI_ALIGN_CENTER];
|
||||||
[gui setKey:choice_key forRow:choices_row];
|
[gui setKey:choice_key forRow:choices_row];
|
||||||
@ -1697,7 +1699,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
|||||||
|
|
||||||
Quaternion q2 = { (GLfloat)0.707, (GLfloat)0.707, (GLfloat)0.0, (GLfloat)0.0};
|
Quaternion q2 = { (GLfloat)0.707, (GLfloat)0.707, (GLfloat)0.0, (GLfloat)0.0};
|
||||||
|
|
||||||
ship = [universe getShipWithRole: shipKey]; // retain count = 1
|
ship = [universe newShipWithRole: shipKey]; // retain count = 1
|
||||||
if (ship)
|
if (ship)
|
||||||
{
|
{
|
||||||
double cr = ship->collision_radius;
|
double cr = ship->collision_radius;
|
||||||
@ -1954,7 +1956,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
|||||||
}
|
}
|
||||||
else if ([valueString hasPrefix:@"["]&&[valueString hasSuffix:@"]"])
|
else if ([valueString hasPrefix:@"["]&&[valueString hasSuffix:@"]"])
|
||||||
{
|
{
|
||||||
NSString* replaceString = [universe expandDescription:valueString forSystem:system_seed];
|
NSString* replaceString = ExpandDescriptionForCurrentSystem(valueString);
|
||||||
[resultString replaceOccurrencesOfString:valueString withString:replaceString options:NSLiteralSearch range:NSMakeRange(0, [resultString length])];
|
[resultString replaceOccurrencesOfString:valueString withString:replaceString options:NSLiteralSearch range:NSMakeRange(0, [resultString length])];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2069,7 +2071,6 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
|||||||
if (![conditions isKindOfClass:[NSArray class]])
|
if (![conditions isKindOfClass:[NSArray class]])
|
||||||
{
|
{
|
||||||
NSLog(@"SCENE ERROR \"conditions = %@\" is not an array - returning NO.", [conditions description]);
|
NSLog(@"SCENE ERROR \"conditions = %@\" is not an array - returning NO.", [conditions description]);
|
||||||
// NSBeep(); AppKit
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2135,9 +2136,9 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
|||||||
return NO; // 0... 1... 2 3 4 5 6 7 8 9....
|
return NO; // 0... 1... 2 3 4 5 6 7 8 9....
|
||||||
ShipEntity* ship = nil;
|
ShipEntity* ship = nil;
|
||||||
if ([i_key isEqual:@"ship"]||[i_key isEqual:@"model"])
|
if ([i_key isEqual:@"ship"]||[i_key isEqual:@"model"])
|
||||||
ship = [universe getShip:(NSString*)[i_info objectAtIndex: 1]];
|
ship = [universe newShipWithName:(NSString*)[i_info objectAtIndex: 1]];
|
||||||
if ([i_key isEqual:@"role"])
|
if ([i_key isEqual:@"role"])
|
||||||
ship = [universe getShipWithRole:(NSString*)[i_info objectAtIndex: 1]];
|
ship = [universe newShipWithRole:(NSString*)[i_info objectAtIndex: 1]];
|
||||||
if (!ship)
|
if (!ship)
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
@ -2171,7 +2172,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
|||||||
if ([i_info count] != 9) // must be player_x_y_z_W_X_Y_Z_align
|
if ([i_info count] != 9) // must be player_x_y_z_W_X_Y_Z_align
|
||||||
return NO; // 0..... 1 2 3 4 5 6 7 8....
|
return NO; // 0..... 1 2 3 4 5 6 7 8....
|
||||||
|
|
||||||
ShipEntity* doppelganger = [universe getShip: ship_desc]; // retain count = 1
|
ShipEntity* doppelganger = [universe newShipWithName: ship_desc]; // retain count = 1
|
||||||
if (!doppelganger)
|
if (!doppelganger)
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
|
@ -49,4 +49,7 @@ enum
|
|||||||
|
|
||||||
- (void)playBreakPattern;
|
- (void)playBreakPattern;
|
||||||
|
|
||||||
|
- (void)playHostileWarning;
|
||||||
|
- (void)playAlertConditionRed;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -40,98 +40,94 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
- (void)setUpSound
|
- (void)setUpSound
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SOUND
|
[self destroySound];
|
||||||
[self destroySound];
|
|
||||||
|
beepSound = [[ResourceManager ooSoundNamed:@"beep.ogg" inFolder:@"Sounds"] retain];
|
||||||
beepSound = [[ResourceManager ooSoundNamed:@"beep.ogg" inFolder:@"Sounds"] retain];
|
boopSound = [[ResourceManager ooSoundNamed:@"boop.ogg" inFolder:@"Sounds"] retain];
|
||||||
boopSound = [[ResourceManager ooSoundNamed:@"boop.ogg" inFolder:@"Sounds"] retain];
|
weaponSound = [[ResourceManager ooSoundNamed:@"laser.ogg" inFolder:@"Sounds"] retain];
|
||||||
weaponSound = [[ResourceManager ooSoundNamed:@"laser.ogg" inFolder:@"Sounds"] retain];
|
weaponHitSound = [[ResourceManager ooSoundNamed:@"laserhits.ogg" inFolder:@"Sounds"] retain];
|
||||||
weaponHitSound = [[ResourceManager ooSoundNamed:@"laserhits.ogg" inFolder:@"Sounds"] retain];
|
missileSound = [[ResourceManager ooSoundNamed:@"missile.ogg" inFolder:@"Sounds"] retain];
|
||||||
missileSound = [[ResourceManager ooSoundNamed:@"missile.ogg" inFolder:@"Sounds"] retain];
|
damageSound = [[ResourceManager ooSoundNamed:@"hit.ogg" inFolder:@"Sounds"] retain];
|
||||||
damageSound = [[ResourceManager ooSoundNamed:@"hit.ogg" inFolder:@"Sounds"] retain];
|
scrapeDamageSound = [[ResourceManager ooSoundNamed:@"hullbang.ogg" inFolder:@"Sounds"] retain];
|
||||||
scrapeDamageSound = [[ResourceManager ooSoundNamed:@"hullbang.ogg" inFolder:@"Sounds"] retain];
|
destructionSound = [[ResourceManager ooSoundNamed:@"bigbang.ogg" inFolder:@"Sounds"] retain];
|
||||||
destructionSound = [[ResourceManager ooSoundNamed:@"bigbang.ogg" inFolder:@"Sounds"] retain];
|
breakPatternSound = [[ResourceManager ooSoundNamed:@"breakpattern.ogg" inFolder:@"Sounds"] retain];
|
||||||
breakPatternSound = [[ResourceManager ooSoundNamed:@"breakpattern.ogg" inFolder:@"Sounds"] retain];
|
//
|
||||||
//
|
ecmSound = [[ResourceManager ooSoundNamed:@"ecm.ogg" inFolder:@"Sounds"] retain];
|
||||||
ecmSound = [[ResourceManager ooSoundNamed:@"ecm.ogg" inFolder:@"Sounds"] retain];
|
buySound = [[ResourceManager ooSoundNamed:@"buy.ogg" inFolder:@"Sounds"] retain];
|
||||||
buySound = [[ResourceManager ooSoundNamed:@"buy.ogg" inFolder:@"Sounds"] retain];
|
sellSound = [[ResourceManager ooSoundNamed:@"sell.ogg" inFolder:@"Sounds"] retain];
|
||||||
sellSound = [[ResourceManager ooSoundNamed:@"sell.ogg" inFolder:@"Sounds"] retain];
|
warningSound = [[ResourceManager ooSoundNamed:@"warning.ogg" inFolder:@"Sounds"] retain];
|
||||||
warningSound = [[ResourceManager ooSoundNamed:@"warning.ogg" inFolder:@"Sounds"] retain];
|
afterburner1Sound = [[ResourceManager ooSoundNamed:@"afterburner1.ogg" inFolder:@"Sounds"] retain];
|
||||||
afterburner1Sound = [[ResourceManager ooSoundNamed:@"afterburner1.ogg" inFolder:@"Sounds"] retain];
|
afterburner2Sound = [[ResourceManager ooSoundNamed:@"afterburner2.ogg" inFolder:@"Sounds"] retain];
|
||||||
afterburner2Sound = [[ResourceManager ooSoundNamed:@"afterburner2.ogg" inFolder:@"Sounds"] retain];
|
//
|
||||||
//
|
witchAbortSound = [[ResourceManager ooSoundNamed:@"witchabort.ogg" inFolder:@"Sounds"] retain];
|
||||||
witchAbortSound = [[ResourceManager ooSoundNamed:@"witchabort.ogg" inFolder:@"Sounds"] retain];
|
//
|
||||||
//
|
fuelScoopSound = [[ResourceManager ooSoundNamed:@"scoop.ogg" inFolder:@"Sounds"] retain];
|
||||||
fuelScoopSound = [[ResourceManager ooSoundNamed:@"scoop.ogg" inFolder:@"Sounds"] retain];
|
|
||||||
|
themeMusic = [[ResourceManager ooMusicNamed:@"OoliteTheme.ogg" inFolder:@"Music"] retain];
|
||||||
themeMusic = [[ResourceManager ooMusicNamed:@"OoliteTheme.ogg" inFolder:@"Music"] retain];
|
missionMusic = [[ResourceManager ooMusicNamed:@"OoliteTheme.ogg" inFolder:@"Music"] retain];
|
||||||
missionMusic = [[ResourceManager ooMusicNamed:@"OoliteTheme.ogg" inFolder:@"Music"] retain];
|
dockingMusic = [[ResourceManager ooMusicNamed:@"BlueDanube.ogg" inFolder:@"Music"] retain];
|
||||||
dockingMusic = [[ResourceManager ooMusicNamed:@"BlueDanube.ogg" inFolder:@"Music"] retain];
|
|
||||||
|
refPoint = [[OOSoundReferencePoint alloc] init];
|
||||||
refPoint = [[OOSoundReferencePoint alloc] init];
|
interfaceBeepSource = [[OOSoundSource alloc] init];
|
||||||
interfaceBeepSource = [[OOSoundSource alloc] init];
|
breakPatternSource = [[OOSoundSource alloc] init];
|
||||||
breakPatternSource = [[OOSoundSource alloc] init];
|
ecmSource = [[OOSoundSource alloc] init];
|
||||||
ecmSource = [[OOSoundSource alloc] init];
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)destroySound
|
- (void)destroySound
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SOUND
|
[beepSound release];
|
||||||
[beepSound release];
|
beepSound = nil;
|
||||||
beepSound = nil;
|
[boopSound release];
|
||||||
[boopSound release];
|
boopSound = nil;
|
||||||
boopSound = nil;
|
[weaponSound release];
|
||||||
[weaponSound release];
|
weaponSound = nil;
|
||||||
weaponSound = nil;
|
[weaponHitSound release];
|
||||||
[weaponHitSound release];
|
weaponHitSound = nil;
|
||||||
weaponHitSound = nil;
|
[damageSound release];
|
||||||
[damageSound release];
|
damageSound = nil;
|
||||||
damageSound = nil;
|
[scrapeDamageSound release];
|
||||||
[scrapeDamageSound release];
|
scrapeDamageSound = nil;
|
||||||
scrapeDamageSound = nil;
|
[destructionSound release];
|
||||||
[destructionSound release];
|
destructionSound = nil;
|
||||||
destructionSound = nil;
|
[breakPatternSound release];
|
||||||
[breakPatternSound release];
|
breakPatternSound = nil;
|
||||||
breakPatternSound = nil;
|
|
||||||
|
[ecmSound release];
|
||||||
[ecmSound release];
|
ecmSound = nil;
|
||||||
ecmSound = nil;
|
[buySound release];
|
||||||
[buySound release];
|
buySound = nil;
|
||||||
buySound = nil;
|
[sellSound release];
|
||||||
[sellSound release];
|
sellSound = nil;
|
||||||
sellSound = nil;
|
[warningSound release];
|
||||||
[warningSound release];
|
warningSound = nil;
|
||||||
warningSound = nil;
|
[afterburner1Sound release];
|
||||||
[afterburner1Sound release];
|
afterburner1Sound = nil;
|
||||||
afterburner1Sound = nil;
|
[afterburner2Sound release];
|
||||||
[afterburner2Sound release];
|
afterburner2Sound = nil;
|
||||||
afterburner2Sound = nil;
|
|
||||||
|
[witchAbortSound release];
|
||||||
[witchAbortSound release];
|
witchAbortSound = nil;
|
||||||
witchAbortSound = nil;
|
|
||||||
|
[fuelScoopSound release];
|
||||||
[fuelScoopSound release];
|
fuelScoopSound = nil;
|
||||||
fuelScoopSound = nil;
|
|
||||||
|
|
||||||
|
[themeMusic release];
|
||||||
[themeMusic release];
|
themeMusic = nil;
|
||||||
themeMusic = nil;
|
[missionMusic release];
|
||||||
[missionMusic release];
|
missionMusic = nil;
|
||||||
missionMusic = nil;
|
[dockingMusic release];
|
||||||
[dockingMusic release];
|
dockingMusic = nil;
|
||||||
dockingMusic = nil;
|
|
||||||
|
[refPoint release];
|
||||||
[refPoint release];
|
refPoint = nil;
|
||||||
refPoint = nil;
|
[interfaceBeepSource release];
|
||||||
[interfaceBeepSource release];
|
interfaceBeepSource = nil;
|
||||||
interfaceBeepSource = nil;
|
[ecmSource release];
|
||||||
[ecmSource release];
|
ecmSource = nil;
|
||||||
ecmSource = nil;
|
[breakPatternSource release];
|
||||||
[breakPatternSource release];
|
breakPatternSource = nil;
|
||||||
breakPatternSource = nil;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -149,75 +145,76 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
- (void)playInterfaceBeep:(unsigned)inInterfaceBeep
|
- (void)playInterfaceBeep:(unsigned)inInterfaceBeep
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SOUND
|
OOSound *sound = nil;
|
||||||
OOSound *sound = nil;
|
|
||||||
|
switch (inInterfaceBeep)
|
||||||
|
{
|
||||||
|
case kInterfaceBeep_Beep:
|
||||||
|
sound = beepSound;
|
||||||
|
break;
|
||||||
|
|
||||||
switch (inInterfaceBeep)
|
case kInterfaceBeep_Boop:
|
||||||
{
|
sound = boopSound;
|
||||||
case kInterfaceBeep_Beep:
|
break;
|
||||||
sound = beepSound;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kInterfaceBeep_Boop:
|
|
||||||
sound = boopSound;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kInterfaceBeep_Buy:
|
|
||||||
sound = buySound;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kInterfaceBeep_Sell:
|
|
||||||
sound = sellSound;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
NSLog(@"Invalid beep selector: %u", inInterfaceBeep);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if BEEP_MODE == 0
|
case kInterfaceBeep_Buy:
|
||||||
[interfaceBeepSource playOrRepeatSound:sound];
|
sound = buySound;
|
||||||
#elif BEEP_MODE == 1
|
break;
|
||||||
[interfaceBeepSource playSound:sound];
|
|
||||||
#elif BEEP_MODE == 2
|
case kInterfaceBeep_Sell:
|
||||||
[sound play];
|
sound = sellSound;
|
||||||
#else
|
break;
|
||||||
#error Unknown BEEP_MODE
|
|
||||||
#endif
|
default:
|
||||||
|
OOLog(@"sound.invalidBeep", @"Invalid beep selector: %u", inInterfaceBeep);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if BEEP_MODE == 0
|
||||||
|
[interfaceBeepSource playOrRepeatSound:sound];
|
||||||
|
#elif BEEP_MODE == 1
|
||||||
|
[interfaceBeepSource playSound:sound];
|
||||||
|
#elif BEEP_MODE == 2
|
||||||
|
[sound play];
|
||||||
|
#else
|
||||||
|
#error Unknown BEEP_MODE
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (BOOL)isBeeping
|
- (BOOL)isBeeping
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SOUND
|
return [interfaceBeepSource isPlaying];
|
||||||
return [interfaceBeepSource isPlaying];
|
|
||||||
#else
|
|
||||||
return NO;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)playECMSound
|
- (void)playECMSound
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SOUND
|
if (![ecmSource isPlaying]) [ecmSource playSound:ecmSound];
|
||||||
if (![ecmSource isPlaying]) [ecmSource playSound:ecmSound];
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)stopECMSound
|
- (void)stopECMSound
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SOUND
|
[ecmSource stop];
|
||||||
[ecmSource stop];
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)playBreakPattern
|
- (void)playBreakPattern
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SOUND
|
|
||||||
[breakPatternSource playSound:breakPatternSound];
|
[breakPatternSource playSound:breakPatternSound];
|
||||||
#endif
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)playHostileWarning
|
||||||
|
{
|
||||||
|
if (![warningSound isPlaying]) [warningSound play];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)playAlertConditionRed
|
||||||
|
{
|
||||||
|
if ([warningSound isPlaying]) [warningSound stop];
|
||||||
|
[warningSound play];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -50,7 +50,6 @@ BOOL always_include_addons;
|
|||||||
+ (NSString *) errors;
|
+ (NSString *) errors;
|
||||||
+ (NSMutableArray *) paths;
|
+ (NSMutableArray *) paths;
|
||||||
+ (NSMutableArray *) pathsUsingAddOns:(BOOL) include_addons;
|
+ (NSMutableArray *) pathsUsingAddOns:(BOOL) include_addons;
|
||||||
+ (BOOL) areRequirementsFulfilled:(NSDictionary*) requirements;
|
|
||||||
+ (void) addExternalPath:(NSString *)filename;
|
+ (void) addExternalPath:(NSString *)filename;
|
||||||
|
|
||||||
+ (NSDictionary *) dictionaryFromFilesNamed:(NSString *)filename inFolder:(NSString *)foldername andMerge:(BOOL) mergeFiles;
|
+ (NSDictionary *) dictionaryFromFilesNamed:(NSString *)filename inFolder:(NSString *)foldername andMerge:(BOOL) mergeFiles;
|
||||||
|
@ -31,6 +31,8 @@ MA 02110-1301, USA.
|
|||||||
#import "OOStringParsing.h"
|
#import "OOStringParsing.h"
|
||||||
#import "OOPListParsing.h"
|
#import "OOPListParsing.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.ResourceManager"
|
||||||
|
|
||||||
|
|
||||||
static NSString * const kOOLogDumpSearchPaths = @"searchPaths.dumpAll";
|
static NSString * const kOOLogDumpSearchPaths = @"searchPaths.dumpAll";
|
||||||
static NSString * const kOOLogCacheUpToDate = @"dataCache.upToDate";
|
static NSString * const kOOLogCacheUpToDate = @"dataCache.upToDate";
|
||||||
@ -43,6 +45,14 @@ static NSString * const kOOCacheKeyModificationDates = @"modification dates";
|
|||||||
|
|
||||||
extern NSDictionary* parseScripts(NSString* script);
|
extern NSDictionary* parseScripts(NSString* script);
|
||||||
|
|
||||||
|
|
||||||
|
@interface ResourceManager (OOPrivate)
|
||||||
|
|
||||||
|
+ (BOOL) areRequirementsFulfilled:(NSDictionary*)requirements forOXP:(NSString *)path;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
@implementation ResourceManager
|
@implementation ResourceManager
|
||||||
|
|
||||||
static NSMutableArray* saved_paths;
|
static NSMutableArray* saved_paths;
|
||||||
@ -185,11 +195,9 @@ NSMutableDictionary* surface_cache;
|
|||||||
int i;
|
int i;
|
||||||
if (saved_paths)
|
if (saved_paths)
|
||||||
return saved_paths;
|
return saved_paths;
|
||||||
if (errors)
|
|
||||||
{
|
[errors release];
|
||||||
[errors release];
|
errors = nil;
|
||||||
errors = nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
NSFileManager *fmgr = [NSFileManager defaultManager];
|
NSFileManager *fmgr = [NSFileManager defaultManager];
|
||||||
|
|
||||||
@ -261,7 +269,7 @@ NSMutableDictionary* surface_cache;
|
|||||||
NSDictionary* requires_dic = OODictionaryFromFile(requiresPath);
|
NSDictionary* requires_dic = OODictionaryFromFile(requiresPath);
|
||||||
if (requires_dic != nil)
|
if (requires_dic != nil)
|
||||||
{
|
{
|
||||||
require_test = [ResourceManager areRequirementsFulfilled:requires_dic];
|
require_test = [ResourceManager areRequirementsFulfilled:requires_dic forOXP:possibleExpansionPath];
|
||||||
}
|
}
|
||||||
if (require_test)
|
if (require_test)
|
||||||
{
|
{
|
||||||
@ -269,24 +277,30 @@ NSMutableDictionary* surface_cache;
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSString* version = (NSString *)[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
|
NSString *errorString = nil;
|
||||||
// NSBeep(); // AppKit
|
|
||||||
if (!failed_parsing)
|
if (failed_parsing)
|
||||||
{
|
{
|
||||||
NSString* old_errors = errors;
|
errorString = [NSString stringWithFormat:@"\t'%@' requirements property list could not be parsed.", [possibleExpansionPath lastPathComponent]];
|
||||||
errors = [[NSString alloc] initWithFormat:@"%@\n\t'%@' requirements property list could not be parsed",old_errors, [possibleExpansionPath lastPathComponent]];
|
|
||||||
[old_errors release];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSLog(@"ERROR %@ is incompatible with this version %@ of Oolite",possibleExpansionPath,version);
|
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
|
||||||
if (!errors)
|
OOLog(@"oxp.versionMismatch", @"ERROR: OXP %@ is incompatible with version %@ of Oolite",possibleExpansionPath,version);
|
||||||
errors = [[NSString alloc] initWithFormat:@"\t'%@' is incompatible with version %@ of Oolite",[possibleExpansionPath lastPathComponent],version];
|
errorString = [NSString stringWithFormat:@"\t'%@' is incompatible with version %@ of Oolite", [possibleExpansionPath lastPathComponent], version];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorString != nil)
|
||||||
|
{
|
||||||
|
if (errors)
|
||||||
|
{
|
||||||
|
errorString = [[NSString alloc] initWithFormat:@"%@\n%@", errors, errorString];
|
||||||
|
[errors release];
|
||||||
|
errors = errorString;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSString* old_errors = errors;
|
errors = [errorString retain];
|
||||||
errors = [[NSString alloc] initWithFormat:@"%@\n\t'%@' is incompatible with version %@ of Oolite",old_errors,[possibleExpansionPath lastPathComponent],version];
|
|
||||||
[old_errors release];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,17 +317,38 @@ NSMutableDictionary* surface_cache;
|
|||||||
return file_paths;
|
return file_paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (BOOL) areRequirementsFulfilled:(NSDictionary*) requirements
|
+ (BOOL) areRequirementsFulfilled:(NSDictionary*)requirements forOXP:(NSString *)path
|
||||||
{
|
{
|
||||||
if (!requirements)
|
BOOL result = YES;
|
||||||
return YES;
|
NSString *requiredVersion;
|
||||||
if ([requirements objectForKey:@"version"])
|
|
||||||
|
if (result)
|
||||||
{
|
{
|
||||||
NSString* version = (NSString *)[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
|
requiredVersion = [requirements objectForKey:@"version"];
|
||||||
if ([version isLessThan:[requirements objectForKey:@"version"]])
|
if (requiredVersion != nil)
|
||||||
return NO;
|
{
|
||||||
|
if ([requiredVersion isKindOfClass:[NSString class]])
|
||||||
|
{
|
||||||
|
static NSArray *ooVersionComponents = nil;
|
||||||
|
NSArray *oxpVersionComponents = nil;
|
||||||
|
|
||||||
|
if (ooVersionComponents == nil)
|
||||||
|
{
|
||||||
|
ooVersionComponents = ComponentsFromVersionString([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
oxpVersionComponents = ComponentsFromVersionString([requirements objectForKey:@"version"]);
|
||||||
|
if (NSOrderedAscending == CompareVersions(ooVersionComponents, oxpVersionComponents)) result = NO;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OOLog(@"plist.wrongType", @"Expected requires.plist entry \"version\" to be string, but got %@ in OXP %@.", [requirements class], [path lastPathComponent]);
|
||||||
|
result = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return YES;
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void) addExternalPath:(NSString *)filename
|
+ (void) addExternalPath:(NSString *)filename
|
||||||
@ -332,7 +367,6 @@ NSMutableDictionary* surface_cache;
|
|||||||
}
|
}
|
||||||
if (!paths_to_load)
|
if (!paths_to_load)
|
||||||
paths_to_load = [saved_paths retain];
|
paths_to_load = [saved_paths retain];
|
||||||
// NSLog(@"DEBUG HERE:::: paths_to_load = %@", paths_to_load);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSDictionary *) dictionaryFromFilesNamed:(NSString *)filename inFolder:(NSString *)foldername andMerge:(BOOL) mergeFiles
|
+ (NSDictionary *) dictionaryFromFilesNamed:(NSString *)filename inFolder:(NSString *)foldername andMerge:(BOOL) mergeFiles
|
||||||
@ -390,10 +424,7 @@ NSMutableDictionary* surface_cache;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
if (result)
|
if (result) [dictionary_cache setObject:result forKey:dict_key];
|
||||||
[dictionary_cache setObject:result forKey:dict_key];
|
|
||||||
|
|
||||||
// NSLog(@"DEBUG ResourceManager dictionary_cache keys:\n%@", [dictionary_cache allKeys]);
|
|
||||||
|
|
||||||
return [NSDictionary dictionaryWithDictionary:result];
|
return [NSDictionary dictionaryWithDictionary:result];
|
||||||
}
|
}
|
||||||
@ -432,7 +463,6 @@ NSMutableDictionary* surface_cache;
|
|||||||
|
|
||||||
// got results we may want to cache
|
// got results we may want to cache
|
||||||
//
|
//
|
||||||
//NSLog(@"---> ResourceManager found %d file(s) with name '%@' (in folder '%@')", [results count], filename, foldername);
|
|
||||||
NSMutableArray *result = [NSMutableArray arrayWithCapacity:128];
|
NSMutableArray *result = [NSMutableArray arrayWithCapacity:128];
|
||||||
if (!mergeFiles)
|
if (!mergeFiles)
|
||||||
{
|
{
|
||||||
@ -621,22 +651,17 @@ NSMutableDictionary* surface_cache;
|
|||||||
|
|
||||||
filepath = [[filepath stringByDeletingPathExtension] stringByAppendingPathExtension:@"oos"];
|
filepath = [[filepath stringByDeletingPathExtension] stringByAppendingPathExtension:@"oos"];
|
||||||
|
|
||||||
//NSLog(@"looking for oos file: %@", filepath);
|
|
||||||
if ([[NSFileManager defaultManager] fileExistsAtPath:filepath])
|
if ([[NSFileManager defaultManager] fileExistsAtPath:filepath])
|
||||||
{
|
{
|
||||||
// load and compile oos script
|
// load and compile oos script
|
||||||
NSLog(@"trying to load and parse %@", filepath);
|
NSLog(@"trying to load and parse %@", filepath);
|
||||||
NSString *script = [NSString stringWithContentsOfFile:filepath];
|
NSString *script = [NSString stringWithContentsOfFile:filepath];
|
||||||
NSDictionary *scriptDict = parseScripts(script);
|
NSDictionary *scriptDict = parseScripts(script);
|
||||||
if (scriptDict) {
|
if (scriptDict) [results addObject:scriptDict];
|
||||||
//NSLog(@"parsed ok, adding to results");
|
|
||||||
[results addObject:scriptDict];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
filepath = [[filepath stringByDeletingPathExtension] stringByAppendingPathExtension:@"plist"];
|
filepath = [[filepath stringByDeletingPathExtension] stringByAppendingPathExtension:@"plist"];
|
||||||
//NSLog(@"oos not found, looking for plist file: %@", filepath);
|
|
||||||
// All this code replicated from dictionaryFromFileNamed because that method
|
// All this code replicated from dictionaryFromFileNamed because that method
|
||||||
// will traverse all possible locations and any oos files that co-exist with
|
// will traverse all possible locations and any oos files that co-exist with
|
||||||
// plist files will probably get their entries overwritten.
|
// plist files will probably get their entries overwritten.
|
||||||
@ -651,7 +676,6 @@ NSMutableDictionary* surface_cache;
|
|||||||
{
|
{
|
||||||
xfilepath = [[(NSString *)[fpaths objectAtIndex:i] stringByAppendingPathComponent:foldername] stringByAppendingPathComponent:filename];
|
xfilepath = [[(NSString *)[fpaths objectAtIndex:i] stringByAppendingPathComponent:foldername] stringByAppendingPathComponent:filename];
|
||||||
filepath = [[xfilepath stringByDeletingPathExtension] stringByAppendingPathExtension:@"oos"];
|
filepath = [[xfilepath stringByDeletingPathExtension] stringByAppendingPathExtension:@"oos"];
|
||||||
//NSLog(@"looking for oos file: %@", filepath);
|
|
||||||
if ([[NSFileManager defaultManager] fileExistsAtPath:filepath])
|
if ([[NSFileManager defaultManager] fileExistsAtPath:filepath])
|
||||||
{
|
{
|
||||||
// load and compile oos script
|
// load and compile oos script
|
||||||
@ -659,7 +683,6 @@ NSMutableDictionary* surface_cache;
|
|||||||
NSString *script = [NSString stringWithContentsOfFile:filepath];
|
NSString *script = [NSString stringWithContentsOfFile:filepath];
|
||||||
NSDictionary *scriptDict = parseScripts(script);
|
NSDictionary *scriptDict = parseScripts(script);
|
||||||
if (scriptDict) {
|
if (scriptDict) {
|
||||||
//NSLog(@"parsed ok, adding to results");
|
|
||||||
[results addObject:scriptDict];
|
[results addObject:scriptDict];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -686,8 +709,6 @@ NSMutableDictionary* surface_cache;
|
|||||||
[dictionary_cache setObject:result forKey:dict_key];
|
[dictionary_cache setObject:result forKey:dict_key];
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSLog(@"DEBUG ResourceManager dictionary_cache keys:\n%@", [dictionary_cache allKeys]);
|
|
||||||
|
|
||||||
return [NSDictionary dictionaryWithDictionary:result];
|
return [NSDictionary dictionaryWithDictionary:result];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,6 @@ Ringdata ringentity;
|
|||||||
lifetime -= movement;
|
lifetime -= movement;
|
||||||
if (lifetime < 0.0)
|
if (lifetime < 0.0)
|
||||||
{
|
{
|
||||||
//NSLog(@"removing ring %@ movement %.3f delta_t %.3f",self,movement,delta_t);
|
|
||||||
[universe removeEntity:self];
|
[universe removeEntity:self];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,7 +126,6 @@ Ringdata ringentity;
|
|||||||
{
|
{
|
||||||
if (basefile)
|
if (basefile)
|
||||||
{
|
{
|
||||||
//NSLog(@"Drawing ring : %@ n_faces %d, n_vertices %d", basefile, n_faces, n_vertices);
|
|
||||||
if (immediate)
|
if (immediate)
|
||||||
{
|
{
|
||||||
#ifdef GNUSTEP
|
#ifdef GNUSTEP
|
||||||
|
@ -25,6 +25,9 @@ MA 02110-1301, USA.
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "StringTokeniser.h"
|
#import "StringTokeniser.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.OOSCompiler"
|
||||||
|
|
||||||
|
|
||||||
@interface NSMutableString (OOScript)
|
@interface NSMutableString (OOScript)
|
||||||
|
|
||||||
- (void) replaceString:(NSString*)aString withString:(NSString*)otherString;
|
- (void) replaceString:(NSString*)aString withString:(NSString*)otherString;
|
||||||
|
@ -48,6 +48,8 @@ MA 02110-1301, USA.
|
|||||||
#import "WormholeEntity.h"
|
#import "WormholeEntity.h"
|
||||||
#import "GuiDisplayGen.h"
|
#import "GuiDisplayGen.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.ShipEntity"
|
||||||
|
|
||||||
|
|
||||||
extern NSString * const kOOLogNoteAddShips;
|
extern NSString * const kOOLogNoteAddShips;
|
||||||
extern NSString * const kOOLogSyntaxAddShips;
|
extern NSString * const kOOLogSyntaxAddShips;
|
||||||
@ -414,7 +416,7 @@ NSString* describeStatus(int some_status)
|
|||||||
NS_HANDLER
|
NS_HANDLER
|
||||||
if ([[localException name] isEqual: OOLITE_EXCEPTION_DATA_NOT_FOUND])
|
if ([[localException name] isEqual: OOLITE_EXCEPTION_DATA_NOT_FOUND])
|
||||||
{
|
{
|
||||||
NSLog(@"***** Oolite Data Not Found Exception : '%@' in [ShipEntity setModel:] *****", [localException reason]);
|
OOLog(kOOLogException, @"***** Oolite Data Not Found Exception : '%@' in [ShipEntity setModel:] *****", [localException reason]);
|
||||||
}
|
}
|
||||||
[localException raise];
|
[localException raise];
|
||||||
NS_ENDHANDLER
|
NS_ENDHANDLER
|
||||||
@ -596,14 +598,14 @@ NSString* describeStatus(int some_status)
|
|||||||
if ([shipinfoDictionary objectForKey:@"escort-role"])
|
if ([shipinfoDictionary objectForKey:@"escort-role"])
|
||||||
{
|
{
|
||||||
escortRole = (NSString*)[shipinfoDictionary objectForKey:@"escort-role"];
|
escortRole = (NSString*)[shipinfoDictionary objectForKey:@"escort-role"];
|
||||||
if (![[universe getShipWithRole:escortRole] autorelease])
|
if (![[universe newShipWithRole:escortRole] autorelease])
|
||||||
escortRole = @"escort";
|
escortRole = @"escort";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([shipinfoDictionary objectForKey:@"escort-ship"])
|
if ([shipinfoDictionary objectForKey:@"escort-ship"])
|
||||||
{
|
{
|
||||||
escortShipKey = (NSString*)[shipinfoDictionary objectForKey:@"escort-ship"];
|
escortShipKey = (NSString*)[shipinfoDictionary objectForKey:@"escort-ship"];
|
||||||
if (![[universe getShip:escortShipKey] autorelease])
|
if (![[universe newShipWithName:escortShipKey] autorelease])
|
||||||
escortShipKey = nil;
|
escortShipKey = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,9 +618,9 @@ NSString* describeStatus(int some_status)
|
|||||||
ShipEntity *escorter;
|
ShipEntity *escorter;
|
||||||
|
|
||||||
if (escortShipKey)
|
if (escortShipKey)
|
||||||
escorter = [universe getShip:escortShipKey]; // retained
|
escorter = [universe newShipWithName:escortShipKey]; // retained
|
||||||
else
|
else
|
||||||
escorter = [universe getShipWithRole:escortRole]; // retained
|
escorter = [universe newShipWithRole:escortRole]; // retained
|
||||||
|
|
||||||
if (!escorter)
|
if (!escorter)
|
||||||
break;
|
break;
|
||||||
@ -984,7 +986,7 @@ NSString* describeStatus(int some_status)
|
|||||||
NS_HANDLER
|
NS_HANDLER
|
||||||
if ([[localException name] isEqual: OOLITE_EXCEPTION_SHIP_NOT_FOUND])
|
if ([[localException name] isEqual: OOLITE_EXCEPTION_SHIP_NOT_FOUND])
|
||||||
{
|
{
|
||||||
NSLog(@"***** Oolite Exception : '%@' in [ShipEntity setUpShipFromDictionary:] while basing a ship upon '%@' *****", [localException reason], other_shipdesc);
|
OOLog(kOOLogException, @"***** Oolite Exception : '%@' in [ShipEntity setUpShipFromDictionary:] while basing a ship upon '%@' *****", [localException reason], other_shipdesc);
|
||||||
other_shipdict = nil;
|
other_shipdict = nil;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1270,7 +1272,7 @@ NSString* describeStatus(int some_status)
|
|||||||
{
|
{
|
||||||
quaternion_normalise(&sub_q);
|
quaternion_normalise(&sub_q);
|
||||||
|
|
||||||
subent = [universe getShip:subdesc]; // retained
|
subent = [universe newShipWithName:subdesc]; // retained
|
||||||
|
|
||||||
if ((self->isStation)&&([subdesc rangeOfString:@"dock"].location != NSNotFound))
|
if ((self->isStation)&&([subdesc rangeOfString:@"dock"].location != NSNotFound))
|
||||||
[(StationEntity*)self setDockingPortModel:(ShipEntity*)subent :sub_pos :sub_q];
|
[(StationEntity*)self setDockingPortModel:(ShipEntity*)subent :sub_pos :sub_q];
|
||||||
@ -1372,7 +1374,7 @@ NSString* describeStatus(int some_status)
|
|||||||
{
|
{
|
||||||
if (universe)
|
if (universe)
|
||||||
{
|
{
|
||||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||||
[player setScript_target:self];
|
[player setScript_target:self];
|
||||||
NSArray * setup_actions = (NSArray *)[shipdict objectForKey:KEY_SETUP_ACTIONS];
|
NSArray * setup_actions = (NSArray *)[shipdict objectForKey:KEY_SETUP_ACTIONS];
|
||||||
|
|
||||||
@ -2104,8 +2106,8 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
|||||||
//scripting
|
//scripting
|
||||||
if ((status == STATUS_IN_FLIGHT)&&([launch_actions count]))
|
if ((status == STATUS_IN_FLIGHT)&&([launch_actions count]))
|
||||||
{
|
{
|
||||||
[(PlayerEntity *)[universe entityZero] setScript_target:self];
|
[[PlayerEntity sharedPlayer] setScript_target:self];
|
||||||
[(PlayerEntity *)[universe entityZero] scriptActions: launch_actions forTarget: self];
|
[[PlayerEntity sharedPlayer] scriptActions: launch_actions forTarget: self];
|
||||||
[launch_actions removeAllObjects];
|
[launch_actions removeAllObjects];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3556,7 +3558,7 @@ void testForShaders()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSLog(@"ERROR no basefile for entity %@");
|
OOLog(kOOLogFileNotFound, @"ERROR no basefile for entity %@");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glShadeModel(GL_SMOOTH);
|
glShadeModel(GL_SMOOTH);
|
||||||
@ -3564,8 +3566,8 @@ void testForShaders()
|
|||||||
|
|
||||||
NS_HANDLER
|
NS_HANDLER
|
||||||
|
|
||||||
NSLog(@"***** [Entity drawEntity::] encountered exception: %@ : %@ *****",[localException name], [localException reason]);
|
OOLog(kOOLogException, @"***** [Entity drawEntity::] encountered exception: %@ : %@ *****",[localException name], [localException reason]);
|
||||||
NSLog(@"***** Removing entity %@ from universe *****", self);
|
OOLog(kOOLogException, @"***** Removing entity %@ from universe *****", self);
|
||||||
[universe removeEntity:self];
|
[universe removeEntity:self];
|
||||||
if ([[localException name] hasPrefix:@"Oolite"])
|
if ([[localException name] hasPrefix:@"Oolite"])
|
||||||
[universe handleOoliteException:localException]; // handle these ourself
|
[universe handleOoliteException:localException]; // handle these ourself
|
||||||
@ -3624,7 +3626,6 @@ void testForShaders()
|
|||||||
zero_distance = my_owner->zero_distance;
|
zero_distance = my_owner->zero_distance;
|
||||||
if (zero_distance > no_draw_distance)
|
if (zero_distance > no_draw_distance)
|
||||||
{
|
{
|
||||||
//NSLog(@"DEBUG - sub entity '%@' too far away to draw", self);
|
|
||||||
return; // TOO FAR AWAY
|
return; // TOO FAR AWAY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3651,8 +3652,6 @@ void testForShaders()
|
|||||||
glMultMatrixf(rotMatrix);
|
glMultMatrixf(rotMatrix);
|
||||||
|
|
||||||
[self drawEntity:immediate :translucent];
|
[self drawEntity:immediate :translucent];
|
||||||
|
|
||||||
// NSLog(@"drawn active entity : %@", basefile);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -3847,22 +3846,13 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
{
|
{
|
||||||
if (scan_class == CLASS_MISSILE)
|
if (scan_class == CLASS_MISSILE)
|
||||||
return; // missiles are SUPPOSED to collide!
|
return; // missiles are SUPPOSED to collide!
|
||||||
|
|
||||||
// NSLog(@"DEBUG ***** %@ in AVOID COLLISION!", self);
|
|
||||||
|
|
||||||
|
|
||||||
ShipEntity* prox_ship = [self proximity_alert];
|
ShipEntity* prox_ship = [self proximity_alert];
|
||||||
|
|
||||||
if (prox_ship)
|
if (prox_ship)
|
||||||
{
|
{
|
||||||
// if (self == [universe entityZero])
|
|
||||||
// NSLog(@"DEBUG ***** proximity alert for %@ %d against target %d", name, universal_id, proximity_alert);
|
|
||||||
|
|
||||||
if (previousCondition)
|
if (previousCondition)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
// NSLog(@"DEBUG ***** avoidCollision dropping previousCondition");
|
|
||||||
//
|
|
||||||
[previousCondition release];
|
[previousCondition release];
|
||||||
previousCondition = nil;
|
previousCondition = nil;
|
||||||
}
|
}
|
||||||
@ -3891,9 +3881,7 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
{
|
{
|
||||||
if (!previousCondition)
|
if (!previousCondition)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// NSLog(@"DEBUG ***** proximity alert for %@ %d over", name, universal_id, proximity_alert);
|
|
||||||
|
|
||||||
behaviour = [(NSNumber*)[previousCondition objectForKey:@"behaviour"] intValue];
|
behaviour = [(NSNumber*)[previousCondition objectForKey:@"behaviour"] intValue];
|
||||||
primaryTarget = [(NSNumber*)[previousCondition objectForKey:@"primaryTarget"] intValue];
|
primaryTarget = [(NSNumber*)[previousCondition objectForKey:@"primaryTarget"] intValue];
|
||||||
desired_range = [(NSNumber*)[previousCondition objectForKey:@"desired_range"] floatValue];
|
desired_range = [(NSNumber*)[previousCondition objectForKey:@"desired_range"] floatValue];
|
||||||
@ -3982,16 +3970,11 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
// check which subtends the greatest angle
|
// check which subtends the greatest angle
|
||||||
GLfloat sa_prox = prox->collision_radius * prox->collision_radius / distance2(position, prox->position);
|
GLfloat sa_prox = prox->collision_radius * prox->collision_radius / distance2(position, prox->position);
|
||||||
GLfloat sa_other = other->collision_radius * other->collision_radius / distance2(position, other->position);
|
GLfloat sa_other = other->collision_radius * other->collision_radius / distance2(position, other->position);
|
||||||
if (sa_prox < sa_other)
|
if (sa_prox < sa_other) return;
|
||||||
{
|
|
||||||
// NSLog(@"DEBUG %@ is already avoiding %@", self, prox);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
proximity_alert = [other universal_id];
|
proximity_alert = [other universal_id];
|
||||||
other->proximity_alert = universal_id;
|
other->proximity_alert = universal_id;
|
||||||
// NSLog(@"DEBUG PROXIMITY ALERT FOR %@ VS %@ == %d", self, other, proximity_alert);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) name
|
- (NSString *) name
|
||||||
@ -4145,10 +4128,8 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
int result = AEGIS_NONE;
|
int result = AEGIS_NONE;
|
||||||
p1.x -= position.x; p1.y -= position.y; p1.z -= position.z;
|
p1.x -= position.x; p1.y -= position.y; p1.z -= position.z;
|
||||||
double d2 = p1.x*p1.x + p1.y*p1.y + p1.z*p1.z;
|
double d2 = p1.x*p1.x + p1.y*p1.y + p1.z*p1.z;
|
||||||
|
|
||||||
// check if nearing surface
|
// check if nearing surface
|
||||||
//
|
|
||||||
// if (reportAImessages)
|
|
||||||
// NSLog(@"DEBUG reporting altitude d2(%.2f) - cr2(%.2f) = %.2f", d2, cr2, d2 - cr2);
|
|
||||||
BOOL wasNearPlanetSurface = isNearPlanetSurface;
|
BOOL wasNearPlanetSurface = isNearPlanetSurface;
|
||||||
isNearPlanetSurface = (d2 - cr2 < 3600000.0);
|
isNearPlanetSurface = (d2 - cr2 < 3600000.0);
|
||||||
if ((!wasNearPlanetSurface)&&(isNearPlanetSurface))
|
if ((!wasNearPlanetSurface)&&(isNearPlanetSurface))
|
||||||
@ -4477,9 +4458,6 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
double d2 = p2.x*p2.x + p2.y*p2.y + p2.z*p2.z - ecr*ecr;
|
double d2 = p2.x*p2.x + p2.y*p2.y + p2.z*p2.z - ecr*ecr;
|
||||||
double damage = weapon_energy*desired_range/d2;
|
double damage = weapon_energy*desired_range/d2;
|
||||||
[e2 takeEnergyDamage:damage from:self becauseOf:[self owner]];
|
[e2 takeEnergyDamage:damage from:self becauseOf:[self owner]];
|
||||||
|
|
||||||
// if ((e2)&&(e2->isShip))
|
|
||||||
// NSLog(@"DEBUG Doing %.1f damage to %@ %d",damage,[(ShipEntity *)e2 name],[(ShipEntity *)e2 universal_id]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4585,9 +4563,6 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
ShipEntity *group_leader = (ShipEntity *)[universe entityForUniversalID:group_id];
|
ShipEntity *group_leader = (ShipEntity *)[universe entityForUniversalID:group_id];
|
||||||
if ((group_leader)&&(group_leader->isShip))
|
if ((group_leader)&&(group_leader->isShip))
|
||||||
{
|
{
|
||||||
//NSLog(@"DEBUG %@ %d informs group leader %@ %d of attack by %@ %d", name, universal_id, [group_leader name], [group_leader universal_id], [hunter name], [hunter universal_id]);
|
|
||||||
|
|
||||||
//[group_leader setReportAImessages:YES];
|
|
||||||
[group_leader setFound_target:hunter];
|
[group_leader setFound_target:hunter];
|
||||||
[group_leader setPrimaryAggressor:hunter];
|
[group_leader setPrimaryAggressor:hunter];
|
||||||
[[group_leader getAI] reactToMessage:@"ATTACKED"];
|
[[group_leader getAI] reactToMessage:@"ATTACKED"];
|
||||||
@ -4665,7 +4640,7 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
if ((energy < max_energy *0.125)&&(has_escape_pod)&&((ranrot_rand() & 3) == 0)) // 25% chance he gets to an escape pod
|
if ((energy < max_energy *0.125)&&(has_escape_pod)&&((ranrot_rand() & 3) == 0)) // 25% chance he gets to an escape pod
|
||||||
{
|
{
|
||||||
has_escape_pod = NO;
|
has_escape_pod = NO;
|
||||||
//NSLog(@"Escape Pod launched");
|
|
||||||
[shipAI setStateMachine:@"nullAI.plist"];
|
[shipAI setStateMachine:@"nullAI.plist"];
|
||||||
[shipAI setState:@"GLOBAL"];
|
[shipAI setState:@"GLOBAL"];
|
||||||
behaviour = BEHAVIOUR_IDLE;
|
behaviour = BEHAVIOUR_IDLE;
|
||||||
@ -4721,7 +4696,7 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
//scripting
|
//scripting
|
||||||
if ([death_actions count])
|
if ([death_actions count])
|
||||||
{
|
{
|
||||||
PlayerEntity* player = (PlayerEntity *)[universe entityZero];
|
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||||
|
|
||||||
[player setScript_target:self];
|
[player setScript_target:self];
|
||||||
[player scriptActions: death_actions forTarget: self];
|
[player scriptActions: death_actions forTarget: self];
|
||||||
@ -4858,7 +4833,7 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
//
|
//
|
||||||
for (i = 0; i < n_rocks; i++)
|
for (i = 0; i < n_rocks; i++)
|
||||||
{
|
{
|
||||||
ShipEntity* rock = [universe getShipWithRole:@"boulder"]; // retain count = 1
|
ShipEntity* rock = [universe newShipWithRole:@"boulder"]; // retain count = 1
|
||||||
if (rock)
|
if (rock)
|
||||||
{
|
{
|
||||||
Vector rpos = xposition;
|
Vector rpos = xposition;
|
||||||
@ -4894,7 +4869,7 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
//
|
//
|
||||||
for (i = 0; i < n_rocks; i++)
|
for (i = 0; i < n_rocks; i++)
|
||||||
{
|
{
|
||||||
ShipEntity* rock = [universe getShipWithRole:@"splinter"]; // retain count = 1
|
ShipEntity* rock = [universe newShipWithRole:@"splinter"]; // retain count = 1
|
||||||
if (rock)
|
if (rock)
|
||||||
{
|
{
|
||||||
Vector rpos = xposition;
|
Vector rpos = xposition;
|
||||||
@ -4940,7 +4915,7 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
|
|
||||||
for (i = 0; i < n_wreckage; i++)
|
for (i = 0; i < n_wreckage; i++)
|
||||||
{
|
{
|
||||||
ShipEntity* wreck = [universe getShipWithRole:@"wreckage"]; // retain count = 1
|
ShipEntity* wreck = [universe newShipWithRole:@"wreckage"]; // retain count = 1
|
||||||
if (wreck)
|
if (wreck)
|
||||||
{
|
{
|
||||||
GLfloat expected_mass = 0.1f * mass * (0.75 + 0.5 * randf());
|
GLfloat expected_mass = 0.1f * mass * (0.75 + 0.5 * randf());
|
||||||
@ -4979,7 +4954,7 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
//
|
//
|
||||||
for (i = 0; i < n_alloys; i++)
|
for (i = 0; i < n_alloys; i++)
|
||||||
{
|
{
|
||||||
ShipEntity* plate = [universe getShipWithRole:@"alloy"]; // retain count = 1
|
ShipEntity* plate = [universe newShipWithRole:@"alloy"]; // retain count = 1
|
||||||
if (plate)
|
if (plate)
|
||||||
{
|
{
|
||||||
Vector rpos = xposition;
|
Vector rpos = xposition;
|
||||||
@ -5029,7 +5004,7 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
[self dealMomentumWithinDesiredRange: 0.125 * mass];
|
[self dealMomentumWithinDesiredRange: 0.125 * mass];
|
||||||
|
|
||||||
//
|
//
|
||||||
if (self != [universe entityZero]) // was if !isPlayer - but I think this may cause ghosts
|
if (self != [PlayerEntity sharedPlayer]) // was if !isPlayer - but I think this may cause ghosts
|
||||||
[universe removeEntity:self];
|
[universe removeEntity:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5160,7 +5135,7 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
|
|||||||
//scripting
|
//scripting
|
||||||
if ([death_actions count])
|
if ([death_actions count])
|
||||||
{
|
{
|
||||||
PlayerEntity* player = (PlayerEntity *)[universe entityZero];
|
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||||
|
|
||||||
[player setScript_target:self];
|
[player setScript_target:self];
|
||||||
[player scriptActions: death_actions forTarget: self];
|
[player scriptActions: death_actions forTarget: self];
|
||||||
@ -5206,7 +5181,6 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
|
|||||||
int cargo_to_go = max_cargo / 10;
|
int cargo_to_go = max_cargo / 10;
|
||||||
while (cargo_to_go > 15)
|
while (cargo_to_go > 15)
|
||||||
cargo_to_go = ranrot_rand() % cargo_to_go;
|
cargo_to_go = ranrot_rand() % cargo_to_go;
|
||||||
//NSLog(@"explosion in %@ %d will launch %d pieces of cargo (max_cargo = %d)", name, universal_id, cargo_to_go, max_cargo);
|
|
||||||
[self setCargo:[universe getContainersOfPlentifulGoods:cargo_to_go]];
|
[self setCargo:[universe getContainersOfPlentifulGoods:cargo_to_go]];
|
||||||
cargo_chance = 100;
|
cargo_chance = 100;
|
||||||
}
|
}
|
||||||
@ -5215,7 +5189,6 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
|
|||||||
int cargo_to_go = max_cargo / 10;
|
int cargo_to_go = max_cargo / 10;
|
||||||
while (cargo_to_go > 15)
|
while (cargo_to_go > 15)
|
||||||
cargo_to_go = ranrot_rand() % cargo_to_go;
|
cargo_to_go = ranrot_rand() % cargo_to_go;
|
||||||
//NSLog(@"explosion in %@ %d will launch %d pieces of cargo (max_cargo = %d)", name, universal_id, cargo_to_go, max_cargo);
|
|
||||||
[self setCargo:[universe getContainersOfScarceGoods:cargo_to_go]];
|
[self setCargo:[universe getContainersOfScarceGoods:cargo_to_go]];
|
||||||
cargo_chance = 100;
|
cargo_chance = 100;
|
||||||
}
|
}
|
||||||
@ -5454,11 +5427,9 @@ BOOL class_masslocks(int some_class)
|
|||||||
Vector my_aim = vector_forward_from_quaternion(q_rotation);
|
Vector my_aim = vector_forward_from_quaternion(q_rotation);
|
||||||
Vector my_ref = reference;
|
Vector my_ref = reference;
|
||||||
double aim_cos, ref_cos;
|
double aim_cos, ref_cos;
|
||||||
//
|
|
||||||
Entity* targent = [self getPrimaryTarget];
|
Entity* targent = [self getPrimaryTarget];
|
||||||
//
|
|
||||||
//
|
|
||||||
//NSLog(@"DEBUG ball_tracking (before rotation) my_aim (%.2f,%.2f,%.2f) my_ref (%.2f,%.2f,%.2f)", my_aim.x, my_aim.y, my_aim.z, my_ref.x, my_ref.y, my_ref.z);
|
|
||||||
Entity* last = nil;
|
Entity* last = nil;
|
||||||
Entity* father = [self owner];
|
Entity* father = [self owner];
|
||||||
GLfloat* r_mat = [father drawRotationMatrix];
|
GLfloat* r_mat = [father drawRotationMatrix];
|
||||||
@ -5492,9 +5463,6 @@ BOOL class_masslocks(int some_class)
|
|||||||
aim_cos = 0.0;
|
aim_cos = 0.0;
|
||||||
ref_cos = -1.0;
|
ref_cos = -1.0;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
//NSLog(@"DEBUG ball_tracking vtt (%.2f,%.2f,%.2f)", vector_to_target.x, vector_to_target.y, vector_to_target.z);
|
|
||||||
//NSLog(@"DEBUG ball_tracking target %@ aim_cos = %.3f ref_cos = %.3f", [(ShipEntity *)targent name], aim_cos, ref_cos);
|
|
||||||
|
|
||||||
if (ref_cos > TURRET_MINIMUM_COS) // target is forward of self
|
if (ref_cos > TURRET_MINIMUM_COS) // target is forward of self
|
||||||
{
|
{
|
||||||
@ -5563,10 +5531,7 @@ BOOL class_masslocks(int some_class)
|
|||||||
Entity* targent = [self getPrimaryTarget];
|
Entity* targent = [self getPrimaryTarget];
|
||||||
//
|
//
|
||||||
Vector leading = [targent getVelocity];
|
Vector leading = [targent getVelocity];
|
||||||
// leading.x *= lead_t; leading.y *= lead_t; leading.z *= lead_t;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//NSLog(@"DEBUG ball_tracking (before rotation) my_aim (%.2f,%.2f,%.2f) my_ref (%.2f,%.2f,%.2f)", my_aim.x, my_aim.y, my_aim.z, my_ref.x, my_ref.y, my_ref.z);
|
|
||||||
Entity* last = nil;
|
Entity* last = nil;
|
||||||
Entity* father = [self owner];
|
Entity* father = [self owner];
|
||||||
GLfloat* r_mat = [father drawRotationMatrix];
|
GLfloat* r_mat = [father drawRotationMatrix];
|
||||||
@ -5604,9 +5569,6 @@ BOOL class_masslocks(int some_class)
|
|||||||
aim_cos = 0.0;
|
aim_cos = 0.0;
|
||||||
ref_cos = -1.0;
|
ref_cos = -1.0;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
//NSLog(@"DEBUG ball_tracking vtt (%.2f,%.2f,%.2f)", vector_to_target.x, vector_to_target.y, vector_to_target.z);
|
|
||||||
//NSLog(@"DEBUG ball_tracking target %@ aim_cos = %.3f ref_cos = %.3f", [(ShipEntity *)targent name], aim_cos, ref_cos);
|
|
||||||
|
|
||||||
if (ref_cos > TURRET_MINIMUM_COS) // target is forward of self
|
if (ref_cos > TURRET_MINIMUM_COS) // target is forward of self
|
||||||
{
|
{
|
||||||
@ -5945,10 +5907,7 @@ BOOL class_masslocks(int some_class)
|
|||||||
// begin rule-of-thumb manoeuvres
|
// begin rule-of-thumb manoeuvres
|
||||||
stick_pitch = 0.0;
|
stick_pitch = 0.0;
|
||||||
stick_roll = 0.0;
|
stick_roll = 0.0;
|
||||||
|
|
||||||
// if (isPlayer)
|
|
||||||
// NSLog(@"DEBUG trackDestination:: max_cos %.4f, d_forward %.4f, we_are_docking %@", max_cos, d_forward, (we_are_docking)? @":YES:" : @":NO:");
|
|
||||||
|
|
||||||
// check if we are flying toward the destination..
|
// check if we are flying toward the destination..
|
||||||
if ((d_forward < max_cos)||(retreat)) // not on course so we must adjust controls..
|
if ((d_forward < max_cos)||(retreat)) // not on course so we must adjust controls..
|
||||||
{
|
{
|
||||||
@ -5994,42 +5953,11 @@ BOOL class_masslocks(int some_class)
|
|||||||
if (we_are_docking && docking_match_rotation && (d_forward > max_cos))
|
if (we_are_docking && docking_match_rotation && (d_forward > max_cos))
|
||||||
{
|
{
|
||||||
/* we are docking and need to consider the rotation/orientation of the docking port */
|
/* we are docking and need to consider the rotation/orientation of the docking port */
|
||||||
|
|
||||||
// NSLog(@"DEBUG DOCKING MATCH ROTATION %@ targetStation = %d %@ primaryTarget = %d %@",
|
|
||||||
// self, targetStation, [universe entityForUniversalID:targetStation], primaryTarget, [universe entityForUniversalID:primaryTarget]);
|
|
||||||
StationEntity* station_for_docking = (StationEntity*)[universe entityForUniversalID:targetStation];
|
StationEntity* station_for_docking = (StationEntity*)[universe entityForUniversalID:targetStation];
|
||||||
|
|
||||||
if ((station_for_docking)&&(station_for_docking->isStation))
|
if ((station_for_docking)&&(station_for_docking->isStation))
|
||||||
{
|
{
|
||||||
stick_roll = [self rollToMatchUp:[station_for_docking portUpVectorForShipsBoundingBox: boundingBox] rotating:[station_for_docking flight_roll]];
|
stick_roll = [self rollToMatchUp:[station_for_docking portUpVectorForShipsBoundingBox: boundingBox] rotating:[station_for_docking flight_roll]];
|
||||||
// Vector up_vec = [station_for_docking portUpVectorForShipsBoundingBox: boundingBox];
|
|
||||||
// double cosTheta = dot_product(up_vec, v_up); // == cos of angle between up vectors
|
|
||||||
// double sinTheta = dot_product(up_vec, v_right);
|
|
||||||
//
|
|
||||||
// double station_roll = [station_for_docking flight_roll];
|
|
||||||
//
|
|
||||||
// if (!isPlayer)
|
|
||||||
// {
|
|
||||||
// station_roll = -station_roll; // make necessary corrections for a different viewpoint
|
|
||||||
// sinTheta = -sinTheta;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (cosTheta < 0)
|
|
||||||
// {
|
|
||||||
// cosTheta = -cosTheta;
|
|
||||||
// sinTheta = -sinTheta;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (sinTheta > 0.0)
|
|
||||||
// {
|
|
||||||
// // increase roll rate
|
|
||||||
// stick_roll = cosTheta * cosTheta * station_roll + sinTheta * sinTheta * max_flight_roll;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// // decrease roll rate
|
|
||||||
// stick_roll = cosTheta * cosTheta * station_roll - sinTheta * sinTheta * max_flight_roll;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6224,10 +6152,6 @@ BOOL class_masslocks(int some_class)
|
|||||||
// set new values from aft_weapon_type
|
// set new values from aft_weapon_type
|
||||||
//
|
//
|
||||||
[self set_weapon_data_from_type:aft_weapon_type];
|
[self set_weapon_data_from_type:aft_weapon_type];
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
//NSLog(@"DEBUG %@ should fire aft weapon",name);
|
|
||||||
|
|
||||||
if (shot_time < weapon_recharge_rate)
|
if (shot_time < weapon_recharge_rate)
|
||||||
return NO;
|
return NO;
|
||||||
@ -6236,8 +6160,6 @@ BOOL class_masslocks(int some_class)
|
|||||||
if (range > randf() * weapon_range)
|
if (range > randf() * weapon_range)
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
//NSLog(@"DEBUG %@ firing aft weapon",name);
|
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
switch (aft_weapon_type)
|
switch (aft_weapon_type)
|
||||||
@ -6351,8 +6273,6 @@ BOOL class_masslocks(int some_class)
|
|||||||
hit_at_range = weapon_range;
|
hit_at_range = weapon_range;
|
||||||
target_laser_hit = [universe getFirstEntityHitByLaserFromEntity:self inView:direction offset: make_vector(0,0,0) rangeFound: &hit_at_range];
|
target_laser_hit = [universe getFirstEntityHitByLaserFromEntity:self inView:direction offset: make_vector(0,0,0) rangeFound: &hit_at_range];
|
||||||
|
|
||||||
// NSLog(@"DEBUG target hit by SubEntityLaserShot: %d %@", target_laser_hit, [universe entityForUniversalID:target_laser_hit]);
|
|
||||||
|
|
||||||
shot = [[ParticleEntity alloc] initLaserFromSubentity:self view:direction]; // alloc retains!
|
shot = [[ParticleEntity alloc] initLaserFromSubentity:self view:direction]; // alloc retains!
|
||||||
[shot setColor:laser_color];
|
[shot setColor:laser_color];
|
||||||
[shot setScanClass: CLASS_NO_DRAW];
|
[shot setScanClass: CLASS_NO_DRAW];
|
||||||
@ -6394,8 +6314,6 @@ BOOL class_masslocks(int some_class)
|
|||||||
|
|
||||||
- (BOOL) fireDirectLaserShot
|
- (BOOL) fireDirectLaserShot
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG %@ %d laser fired direct shot on %@ %d", name, universal_id, [(ShipEntity*)[self getPrimaryTarget] name], primaryTarget);
|
|
||||||
|
|
||||||
GLfloat hit_at_range;
|
GLfloat hit_at_range;
|
||||||
Entity* my_target = [self getPrimaryTarget];
|
Entity* my_target = [self getPrimaryTarget];
|
||||||
if (!my_target)
|
if (!my_target)
|
||||||
@ -6409,8 +6327,6 @@ BOOL class_masslocks(int some_class)
|
|||||||
else
|
else
|
||||||
r_pos.z = 1.0;
|
r_pos.z = 1.0;
|
||||||
|
|
||||||
// target_laser_hit = primaryTarget;
|
|
||||||
|
|
||||||
Quaternion q_laser = quaternion_rotation_between(r_pos, make_vector(0.0f,0.0f,1.0f));
|
Quaternion q_laser = quaternion_rotation_between(r_pos, make_vector(0.0f,0.0f,1.0f));
|
||||||
q_laser.x += 0.01 * (randf() - 0.5); // randomise aim a little (+/- 0.005)
|
q_laser.x += 0.01 * (randf() - 0.5); // randomise aim a little (+/- 0.005)
|
||||||
q_laser.y += 0.01 * (randf() - 0.5);
|
q_laser.y += 0.01 * (randf() - 0.5);
|
||||||
@ -6501,10 +6417,7 @@ BOOL class_masslocks(int some_class)
|
|||||||
}
|
}
|
||||||
|
|
||||||
target_laser_hit = [universe getFirstEntityHitByLaserFromEntity:self inView:direction offset:laserPortOffset rangeFound: &hit_at_range];
|
target_laser_hit = [universe getFirstEntityHitByLaserFromEntity:self inView:direction offset:laserPortOffset rangeFound: &hit_at_range];
|
||||||
|
|
||||||
// if (isPlayer)
|
|
||||||
// NSLog(@"DEBUG target double-check range = %.2f victim = %d --> %@\n\n", hit_at_range, target_laser_hit, [universe entityForUniversalID:target_laser_hit]);
|
|
||||||
|
|
||||||
shot = [[ParticleEntity alloc] initLaserFromShip:self view:direction offset:laserPortOffset]; // alloc retains!
|
shot = [[ParticleEntity alloc] initLaserFromShip:self view:direction offset:laserPortOffset]; // alloc retains!
|
||||||
|
|
||||||
[shot setColor:laser_color];
|
[shot setColor:laser_color];
|
||||||
@ -6697,13 +6610,13 @@ BOOL class_masslocks(int some_class)
|
|||||||
|
|
||||||
// custom missiles
|
// custom missiles
|
||||||
if ([shipinfoDictionary objectForKey:@"missile_role"])
|
if ([shipinfoDictionary objectForKey:@"missile_role"])
|
||||||
missile = [universe getShipWithRole:(NSString*)[shipinfoDictionary objectForKey:@"missile_role"]];
|
missile = [universe newShipWithRole:(NSString*)[shipinfoDictionary objectForKey:@"missile_role"]];
|
||||||
if (!missile) // no custom role
|
if (!missile) // no custom role
|
||||||
{
|
{
|
||||||
if (randf() < 0.90) // choose a standard missile 90% of the time
|
if (randf() < 0.90) // choose a standard missile 90% of the time
|
||||||
missile = [universe getShipWithRole:@"EQ_MISSILE"]; // retained
|
missile = [universe newShipWithRole:@"EQ_MISSILE"]; // retained
|
||||||
else // otherwise choose any with the role 'missile' - which may include alternative weapons
|
else // otherwise choose any with the role 'missile' - which may include alternative weapons
|
||||||
missile = [universe getShipWithRole:@"missile"]; // retained
|
missile = [universe newShipWithRole:@"missile"]; // retained
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!missile)
|
if (!missile)
|
||||||
@ -6793,7 +6706,7 @@ BOOL class_masslocks(int some_class)
|
|||||||
return NO;
|
return NO;
|
||||||
has_energy_bomb = NO;
|
has_energy_bomb = NO;
|
||||||
[self setSpeed: max_flight_speed + 300];
|
[self setSpeed: max_flight_speed + 300];
|
||||||
ShipEntity* bomb = [universe getShipWithRole:@"energy-bomb"];
|
ShipEntity* bomb = [universe newShipWithRole:@"energy-bomb"];
|
||||||
if (!bomb)
|
if (!bomb)
|
||||||
return NO;
|
return NO;
|
||||||
double start = collision_radius + bomb->collision_radius;
|
double start = collision_radius + bomb->collision_radius;
|
||||||
@ -6831,7 +6744,7 @@ BOOL class_masslocks(int some_class)
|
|||||||
[universe addEntity:bomb];
|
[universe addEntity:bomb];
|
||||||
[[bomb getAI] setState:@"GLOBAL"];
|
[[bomb getAI] setState:@"GLOBAL"];
|
||||||
[bomb release];
|
[bomb release];
|
||||||
if (self != [universe entityZero]) // get the heck out of here
|
if (self != [PlayerEntity sharedPlayer]) // get the heck out of here
|
||||||
{
|
{
|
||||||
[self addTarget:bomb];
|
[self addTarget:bomb];
|
||||||
behaviour = BEHAVIOUR_FLEE_TARGET;
|
behaviour = BEHAVIOUR_FLEE_TARGET;
|
||||||
@ -6854,12 +6767,12 @@ BOOL class_masslocks(int some_class)
|
|||||||
// check for custom escape pod
|
// check for custom escape pod
|
||||||
//
|
//
|
||||||
if ([shipinfoDictionary objectForKey:@"escape_pod_model"])
|
if ([shipinfoDictionary objectForKey:@"escape_pod_model"])
|
||||||
pod = [universe getShipWithRole: (NSString*)[shipinfoDictionary objectForKey:@"escape_pod_model"]];
|
pod = [universe newShipWithRole: (NSString*)[shipinfoDictionary objectForKey:@"escape_pod_model"]];
|
||||||
//
|
//
|
||||||
// if not found - use standard escape pod
|
// if not found - use standard escape pod
|
||||||
//
|
//
|
||||||
if (!pod)
|
if (!pod)
|
||||||
pod = [universe getShipWithRole:@"escape-capsule"]; // retain count = 1
|
pod = [universe newShipWithRole:@"escape-capsule"]; // retain count = 1
|
||||||
|
|
||||||
if (pod)
|
if (pod)
|
||||||
{
|
{
|
||||||
@ -6888,7 +6801,7 @@ BOOL class_masslocks(int some_class)
|
|||||||
int i;
|
int i;
|
||||||
for (i = 1; i < n_pods; i++)
|
for (i = 1; i < n_pods; i++)
|
||||||
{
|
{
|
||||||
pod = [universe getShipWithRole:@"escape-capsule"];
|
pod = [universe newShipWithRole:@"escape-capsule"];
|
||||||
if (pod)
|
if (pod)
|
||||||
{
|
{
|
||||||
Random_Seed orig = [universe systemSeedForSystemNumber:gen_rnd_number()];
|
Random_Seed orig = [universe systemSeedForSystemNumber:gen_rnd_number()];
|
||||||
@ -7048,9 +6961,6 @@ BOOL class_masslocks(int some_class)
|
|||||||
|
|
||||||
if (!other)
|
if (!other)
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
// if ((self->isPlayer)||(other->isPlayer))
|
|
||||||
// NSLog(@"DEBUG %@ %d colliding with other %@ %d", name, universal_id, [other name], [other universal_id]);
|
|
||||||
|
|
||||||
ShipEntity* otherParent = (ShipEntity*)[other owner];
|
ShipEntity* otherParent = (ShipEntity*)[other owner];
|
||||||
BOOL otherIsSubentity = ((otherParent)&&(otherParent != other)&&([otherParent->sub_entities containsObject:other]));
|
BOOL otherIsSubentity = ((otherParent)&&(otherParent != other)&&([otherParent->sub_entities containsObject:other]));
|
||||||
@ -7123,23 +7033,13 @@ BOOL class_masslocks(int some_class)
|
|||||||
// are they moving apart at over 1m/s already?
|
// are they moving apart at over 1m/s already?
|
||||||
if (v2b < 0.0f)
|
if (v2b < 0.0f)
|
||||||
{
|
{
|
||||||
if (v2b < -1.0f)
|
if (v2b < -1.0f) return NO;
|
||||||
{
|
|
||||||
// NSLog(@"MOVING APART! %@ >%.3f %.3f< %@", self, sqrt(distance2(position, opos)), v2b, other);
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// NSLog(@"MOVING APART TOO SLOW! %@ >%.3f %.3f< %@", self, sqrt(distance2(position, opos)), v2b, other);
|
|
||||||
position = make_vector( position.x - loc.x, position.y - loc.y, position.z - loc.z); // adjust self position
|
position = make_vector( position.x - loc.x, position.y - loc.y, position.z - loc.z); // adjust self position
|
||||||
v = make_vector( 0.0f, 0.0f, 0.0f); // go for the 1m/s solution
|
v = make_vector( 0.0f, 0.0f, 0.0f); // go for the 1m/s solution
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// NSLog(@"MOVING CLOSER %@ >%.3f %.3f< %@", self, sqrt(distance2(position, opos)), v2b, other);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
|
|
||||||
// convert change in velocity into damage energy (KE)
|
// convert change in velocity into damage energy (KE)
|
||||||
//
|
//
|
||||||
@ -7190,9 +7090,7 @@ BOOL class_masslocks(int some_class)
|
|||||||
[other adjustVelocity:vel1a];
|
[other adjustVelocity:vel1a];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSLog(@"DEBUG back-off distance is %.3fm\n\n", back_dist);
|
|
||||||
//
|
|
||||||
if ((!selfDestroyed)&&(!otherDestroyed))
|
if ((!selfDestroyed)&&(!otherDestroyed))
|
||||||
{
|
{
|
||||||
float t = 10.0 * [universe getTimeDelta]; // 10 ticks
|
float t = 10.0 * [universe getTimeDelta]; // 10 ticks
|
||||||
@ -7242,18 +7140,12 @@ BOOL class_masslocks(int some_class)
|
|||||||
|
|
||||||
- (BOOL) canScoop:(ShipEntity*)other
|
- (BOOL) canScoop:(ShipEntity*)other
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG Checking if %@ %d can scoop %@ %d", name, universal_id, [other name], [other universal_id]);
|
|
||||||
if (!other) return NO;
|
if (!other) return NO;
|
||||||
//
|
|
||||||
if (!has_scoop) return NO;
|
if (!has_scoop) return NO;
|
||||||
// NSLog(@"DEBUG scoop okay");
|
|
||||||
if ([cargo count] >= max_cargo) return NO;
|
if ([cargo count] >= max_cargo) return NO;
|
||||||
// NSLog(@"DEBUG cargo space okay");
|
|
||||||
if (scan_class == CLASS_CARGO) return NO; // we have no power so we can't scoop
|
if (scan_class == CLASS_CARGO) return NO; // we have no power so we can't scoop
|
||||||
if (other->scan_class != CLASS_CARGO) return NO;
|
if (other->scan_class != CLASS_CARGO) return NO;
|
||||||
// NSLog(@"DEBUG other scan class is CLASS_CARGO okay");
|
|
||||||
if ([other getCargoType] == CARGO_NOT_CARGO) return NO;
|
if ([other getCargoType] == CARGO_NOT_CARGO) return NO;
|
||||||
// NSLog(@"DEBUG other cargo type is not CARGO_NOT_CARGO okay");
|
|
||||||
|
|
||||||
if (other->isStation)
|
if (other->isStation)
|
||||||
return NO;
|
return NO;
|
||||||
@ -7320,7 +7212,7 @@ BOOL class_masslocks(int some_class)
|
|||||||
//scripting
|
//scripting
|
||||||
if ([actions count])
|
if ([actions count])
|
||||||
{
|
{
|
||||||
PlayerEntity* player = (PlayerEntity *)[universe entityZero];
|
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||||
|
|
||||||
[player setScript_target:self];
|
[player setScript_target:self];
|
||||||
[player scriptActions: actions forTarget: other];
|
[player scriptActions: actions forTarget: other];
|
||||||
@ -7341,9 +7233,8 @@ BOOL class_masslocks(int some_class)
|
|||||||
if (co_amount > 0)
|
if (co_amount > 0)
|
||||||
{
|
{
|
||||||
[other setCommodity:co_type andAmount:co_amount]; // belt and braces setting this!
|
[other setCommodity:co_type andAmount:co_amount]; // belt and braces setting this!
|
||||||
if (cargo_flag !=CARGO_FLAG_CANISTERS)
|
cargo_flag = CARGO_FLAG_CANISTERS;
|
||||||
cargo_flag = CARGO_FLAG_CANISTERS;
|
|
||||||
//NSLog(@"---> %@ %d scooped %@", name, universal_id, [universe describeCommodity:co_type amount:co_amount]);
|
|
||||||
if (isPlayer)
|
if (isPlayer)
|
||||||
{
|
{
|
||||||
[universe clearPreviousMessage];
|
[universe clearPreviousMessage];
|
||||||
@ -7536,8 +7427,6 @@ int w_space_seed = 1234567;
|
|||||||
[shipAI message:@"EXITED_WITCHSPACE"];
|
[shipAI message:@"EXITED_WITCHSPACE"];
|
||||||
[universe addEntity:self];
|
[universe addEntity:self];
|
||||||
|
|
||||||
// NSLog(@"DEBUG Ship: %@ exiting witchspace at %.2f %.2f %.2f", self, position.x, position.y, position.z);
|
|
||||||
|
|
||||||
// witchspace exit effects here
|
// witchspace exit effects here
|
||||||
ParticleEntity *ring1 = [[ParticleEntity alloc] initHyperringFromShip:self]; // retained
|
ParticleEntity *ring1 = [[ParticleEntity alloc] initHyperringFromShip:self]; // retained
|
||||||
[universe addEntity:ring1];
|
[universe addEntity:ring1];
|
||||||
@ -7550,9 +7439,7 @@ int w_space_seed = 1234567;
|
|||||||
|
|
||||||
- (void) markAsOffender:(int)offence_value
|
- (void) markAsOffender:(int)offence_value
|
||||||
{
|
{
|
||||||
// if (![roles isEqual:@"police"])
|
if (scan_class != CLASS_POLICE) bounty |= offence_value;
|
||||||
if (scan_class != CLASS_POLICE)
|
|
||||||
bounty |= offence_value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) switchLightsOn
|
- (void) switchLightsOn
|
||||||
@ -7598,25 +7485,18 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
|
|||||||
pairing_okay |= (![my_role isEqual:@"escort"] && ![my_role isEqual:@"wingman"] && [their_role isEqual:@"escort"]);
|
pairing_okay |= (![my_role isEqual:@"escort"] && ![my_role isEqual:@"wingman"] && [their_role isEqual:@"escort"]);
|
||||||
pairing_okay |= (([my_role isEqual:@"police"]||[my_role isEqual:@"interceptor"]) && [their_role isEqual:@"wingman"]);
|
pairing_okay |= (([my_role isEqual:@"police"]||[my_role isEqual:@"interceptor"]) && [their_role isEqual:@"wingman"]);
|
||||||
|
|
||||||
// NSLog(@"checking if pairOK for ( %@, %@) >> %@", my_role, their_role, (pairing_okay)? @"YES":@"NO");
|
|
||||||
|
|
||||||
return pairing_okay;
|
return pairing_okay;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) acceptAsEscort:(ShipEntity *) other_ship
|
- (BOOL) acceptAsEscort:(ShipEntity *) other_ship
|
||||||
{
|
{
|
||||||
// can't pair with self
|
// can't pair with self
|
||||||
if (self == other_ship)
|
if (self == other_ship) return NO;
|
||||||
return NO;
|
|
||||||
|
|
||||||
// NSLog(@"DEBUG %@ %d asked to accept %@ %d as escort when ai_stack_depth is %d", name, universal_id, [other_ship name], [other_ship universal_id], [shipAI ai_stack_depth]);
|
|
||||||
|
|
||||||
// if not in standard ai mode reject approach
|
// if not in standard ai mode reject approach
|
||||||
if ([shipAI ai_stack_depth] > 1)
|
if ([shipAI ai_stack_depth] > 1)
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
// NSLog(@"DEBUG pairOK( %@, %@) = %@", roles, [other_ship roles], (pairOK( roles, [other_ship roles]))? @"YES":@"NO");
|
|
||||||
|
|
||||||
if (pairOK( roles, [other_ship roles]))
|
if (pairOK( roles, [other_ship roles]))
|
||||||
{
|
{
|
||||||
// check total number acceptable
|
// check total number acceptable
|
||||||
@ -7641,9 +7521,6 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
|
|||||||
[self setGroup_id:universal_id]; // make self part of same group
|
[self setGroup_id:universal_id]; // make self part of same group
|
||||||
n_escorts++;
|
n_escorts++;
|
||||||
|
|
||||||
//debug
|
|
||||||
// NSLog(@"DEBUG ::YES:: %@ accepts escort %@", self, other_ship);
|
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7680,7 +7557,6 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
|
|||||||
if (primaryTarget == last_escort_target)
|
if (primaryTarget == last_escort_target)
|
||||||
{
|
{
|
||||||
// already deployed escorts onto this target!
|
// already deployed escorts onto this target!
|
||||||
// NSLog(@"DEBUG attempting to deploy more escorts onto same target - denied");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7690,8 +7566,6 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
|
|||||||
if (n_deploy == 0)
|
if (n_deploy == 0)
|
||||||
n_deploy = 1;
|
n_deploy = 1;
|
||||||
|
|
||||||
//NSLog(@"DEBUG %@ %d deploying %d escorts", name, universal_id, n_deploy);
|
|
||||||
|
|
||||||
int i_deploy = n_escorts - 1;
|
int i_deploy = n_escorts - 1;
|
||||||
while ((n_deploy > 0)&&(n_escorts > 0))
|
while ((n_deploy > 0)&&(n_escorts > 0))
|
||||||
{
|
{
|
||||||
@ -7714,9 +7588,6 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
|
|||||||
i_deploy--;
|
i_deploy--;
|
||||||
n_deploy--;
|
n_deploy--;
|
||||||
n_escorts--;
|
n_escorts--;
|
||||||
//debug
|
|
||||||
//NSLog(@"DEBUG trader %@ %d deploys escort %@ %d", name, universal_id, [escorter name], [escorter universal_id]);
|
|
||||||
//[escorter setReportAImessages:YES];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -7901,7 +7772,6 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
|
|||||||
- (void) broadcastHitByLaserFrom:(ShipEntity*) aggressor_ship
|
- (void) broadcastHitByLaserFrom:(ShipEntity*) aggressor_ship
|
||||||
{
|
{
|
||||||
/*-- If you're clean, locates all police and stations in range and tells them OFFENCE_COMMITTED --*/
|
/*-- If you're clean, locates all police and stations in range and tells them OFFENCE_COMMITTED --*/
|
||||||
// NSLog(@"DEBUG IN [%@ broadcastHitByLaserFrom:%@]", self, aggressor_ship);
|
|
||||||
if (!universe)
|
if (!universe)
|
||||||
return;
|
return;
|
||||||
if (bounty)
|
if (bounty)
|
||||||
@ -7915,7 +7785,6 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
|
|||||||
(scan_class == CLASS_MILITARY)||
|
(scan_class == CLASS_MILITARY)||
|
||||||
(scan_class == CLASS_PLAYER)) // only for active ships...
|
(scan_class == CLASS_PLAYER)) // only for active ships...
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG IN [%@ broadcastHitByLaserFrom:%@]", self, aggressor_ship);
|
|
||||||
int ent_count = universe->n_entities;
|
int ent_count = universe->n_entities;
|
||||||
Entity** uni_entities = universe->sortedEntities; // grab the public sorted list
|
Entity** uni_entities = universe->sortedEntities; // grab the public sorted list
|
||||||
Entity* my_entities[ent_count];
|
Entity* my_entities[ent_count];
|
||||||
@ -7931,7 +7800,6 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
|
|||||||
ShipEntity* ship = (ShipEntity *)my_entities[i];
|
ShipEntity* ship = (ShipEntity *)my_entities[i];
|
||||||
if (((ship == mainStation) && (within_station_aegis)) || (distance2( position, ship->position) < SCANNER_MAX_RANGE2))
|
if (((ship == mainStation) && (within_station_aegis)) || (distance2( position, ship->position) < SCANNER_MAX_RANGE2))
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG SENDING %@'s AI \"OFFENCE_COMMITTED\"", ship);
|
|
||||||
[ship setFound_target: aggressor_ship];
|
[ship setFound_target: aggressor_ship];
|
||||||
[[ship getAI] reactToMessage: @"OFFENCE_COMMITTED"];
|
[[ship getAI] reactToMessage: @"OFFENCE_COMMITTED"];
|
||||||
}
|
}
|
||||||
@ -7993,7 +7861,7 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
|
|||||||
very_random_seed.e = rand() & 255;
|
very_random_seed.e = rand() & 255;
|
||||||
very_random_seed.f = rand() & 255;
|
very_random_seed.f = rand() & 255;
|
||||||
seed_RNG_only_for_planet_description(very_random_seed);
|
seed_RNG_only_for_planet_description(very_random_seed);
|
||||||
NSString* expandedMessage = [universe expandDescription:localExpandedMessage forSystem:[universe systemSeed]];
|
NSString* expandedMessage = ExpandDescriptionForCurrentSystem(localExpandedMessage);
|
||||||
[self setCommsMessageColor];
|
[self setCommsMessageColor];
|
||||||
[other_ship receiveCommsMessage:[NSString stringWithFormat:@"%@:\n %@", name, expandedMessage]];
|
[other_ship receiveCommsMessage:[NSString stringWithFormat:@"%@:\n %@", name, expandedMessage]];
|
||||||
if (other_ship->isPlayer)
|
if (other_ship->isPlayer)
|
||||||
@ -8306,12 +8174,10 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
|
|||||||
// No over-ride of Entity's version of the method is required for non-Win32 platforms.
|
// No over-ride of Entity's version of the method is required for non-Win32 platforms.
|
||||||
- (void) reloadTextures
|
- (void) reloadTextures
|
||||||
{
|
{
|
||||||
//NSLog(@"ShipEntity::reloadTextures called, resetting subentities and calling super");
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < [sub_entities count]; i++)
|
for (i = 0; i < [sub_entities count]; i++)
|
||||||
{
|
{
|
||||||
Entity *e = (Entity *)[sub_entities objectAtIndex:i];
|
Entity *e = (Entity *)[sub_entities objectAtIndex:i];
|
||||||
//NSLog(@"ShipEntity::reloadTextures calling reloadTextures on: %@", [e description]);
|
|
||||||
[e reloadTextures];
|
[e reloadTextures];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,8 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
#import "OOStringParsing.h"
|
#import "OOStringParsing.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.ShipEntityAI"
|
||||||
|
|
||||||
|
|
||||||
@implementation ShipEntity (AI)
|
@implementation ShipEntity (AI)
|
||||||
|
|
||||||
@ -384,7 +386,6 @@ MA 02110-1301, USA.
|
|||||||
{
|
{
|
||||||
flight_roll = max_flight_roll*2.0*(randf() - 0.5);
|
flight_roll = max_flight_roll*2.0*(randf() - 0.5);
|
||||||
flight_pitch = max_flight_pitch*2.0*(randf() - 0.5);
|
flight_pitch = max_flight_pitch*2.0*(randf() - 0.5);
|
||||||
// velocity = make_vector( flight_speed*2.0*(randf() - 0.5), flight_speed*2.0*(randf() - 0.5), flight_speed*2.0*(randf() - 0.5));
|
|
||||||
behaviour = BEHAVIOUR_TUMBLE;
|
behaviour = BEHAVIOUR_TUMBLE;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
}
|
}
|
||||||
@ -655,8 +656,6 @@ MA 02110-1301, USA.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSLog(@"DEBUG %@'s scanForOffenders found %@ with legal_factor %.1f", self, [universe entityForUniversalID:found_target], worst_legal_factor);
|
|
||||||
|
|
||||||
if (found_target != NO_TARGET)
|
if (found_target != NO_TARGET)
|
||||||
[shipAI message:@"TARGET_FOUND"];
|
[shipAI message:@"TARGET_FOUND"];
|
||||||
else
|
else
|
||||||
@ -882,8 +881,7 @@ WormholeEntity* whole;
|
|||||||
// scared - ignore the request;
|
// scared - ignore the request;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
default:
|
||||||
//NSLog(@"%@ %d responding to distress message from %@ %d", name, universal_id, [other name], [other universal_id]);
|
|
||||||
if ((scan_class == CLASS_POLICE)||[roles isEqual:@"police"]||[roles isEqual:@"interceptor"]||[roles isEqual:@"wingman"])
|
if ((scan_class == CLASS_POLICE)||[roles isEqual:@"police"]||[roles isEqual:@"interceptor"]||[roles isEqual:@"wingman"])
|
||||||
[(ShipEntity *)[universe entityForUniversalID:found_target] markAsOffender:8]; // you have been warned!!
|
[(ShipEntity *)[universe entityForUniversalID:found_target] markAsOffender:8]; // you have been warned!!
|
||||||
[shipAI reactToMessage:@"ACCEPT_DISTRESS_CALL"];
|
[shipAI reactToMessage:@"ACCEPT_DISTRESS_CALL"];
|
||||||
@ -1025,31 +1023,15 @@ WormholeEntity* whole;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found_target != NO_TARGET)
|
if (found_target != NO_TARGET) [shipAI message:@"TARGET_FOUND"];
|
||||||
{
|
else [shipAI message:@"NOTHING_FOUND"];
|
||||||
//NSLog(@"DEBUG %@ %d scanForHostiles ----> found %@ %@ %d", name, universal_id, [(ShipEntity *)[universe entityForUniversalID:found_target] roles], [(ShipEntity *)[universe entityForUniversalID:found_target] name], found_target);
|
|
||||||
//[self setReportAImessages:YES];
|
|
||||||
|
|
||||||
[shipAI message:@"TARGET_FOUND"];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
[shipAI message:@"NOTHING_FOUND"];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) fightOrFleeHostiles
|
- (void) fightOrFleeHostiles
|
||||||
{
|
{
|
||||||
//NSLog(@"DEBUG %@ %d considers fightOrFleeHostiles", name, universal_id);
|
|
||||||
// consider deploying escorts
|
|
||||||
//if ([escorts count] > 0)
|
|
||||||
if (n_escorts > 0)
|
if (n_escorts > 0)
|
||||||
{
|
{
|
||||||
if (found_target == last_escort_target)
|
if (found_target == last_escort_target) return;
|
||||||
{
|
|
||||||
//NSLog(@"DEBUG exit fightOrFleeHostiles because found_target == last_escort_target == %d", found_target);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//NSLog(@"DEBUG %@ %d decides to deploy escorts and flee", name, universal_id);
|
|
||||||
|
|
||||||
primaryAggressor = found_target;
|
primaryAggressor = found_target;
|
||||||
primaryTarget = found_target;
|
primaryTarget = found_target;
|
||||||
@ -1064,8 +1046,6 @@ WormholeEntity* whole;
|
|||||||
{
|
{
|
||||||
if (randf() < 0.50)
|
if (randf() < 0.50)
|
||||||
{
|
{
|
||||||
//NSLog(@"DEBUG %@ %d decides to launch missile and flee", name, universal_id);
|
|
||||||
|
|
||||||
primaryAggressor = found_target;
|
primaryAggressor = found_target;
|
||||||
primaryTarget = found_target;
|
primaryTarget = found_target;
|
||||||
[self fireMissile];
|
[self fireMissile];
|
||||||
@ -1077,15 +1057,12 @@ WormholeEntity* whole;
|
|||||||
// consider fighting
|
// consider fighting
|
||||||
if (energy > max_energy * 0.80)
|
if (energy > max_energy * 0.80)
|
||||||
{
|
{
|
||||||
//NSLog(@"DEBUG %@ %d decides to fight hostiles", name, universal_id);
|
|
||||||
|
|
||||||
primaryAggressor = found_target;
|
primaryAggressor = found_target;
|
||||||
//[self performAttack];
|
//[self performAttack];
|
||||||
[shipAI message:@"FIGHTING"];
|
[shipAI message:@"FIGHTING"];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//NSLog(@"DEBUG %@ %d decides to flee hostiles", name, universal_id);
|
|
||||||
[shipAI message:@"FLEEING"];
|
[shipAI message:@"FLEEING"];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1105,7 +1082,6 @@ WormholeEntity* whole;
|
|||||||
int extra = 1 | (ranrot_rand() & 15);
|
int extra = 1 | (ranrot_rand() & 15);
|
||||||
[mother setBounty: [mother legal_status] + extra];
|
[mother setBounty: [mother legal_status] + extra];
|
||||||
bounty += extra; // obviously we're dodgier than we thought!
|
bounty += extra; // obviously we're dodgier than we thought!
|
||||||
// NSLog(@"DEBUG setting new bounty for %@ escorting %@ to %d", self, mother, extra);
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
[self setOwner:mother];
|
[self setOwner:mother];
|
||||||
@ -1158,9 +1134,6 @@ WormholeEntity* whole;
|
|||||||
int own_group_numbers = [self numberOfShipsInGroup:own_group_id] + (ranrot_rand() & 3); // add a random fudge factor
|
int own_group_numbers = [self numberOfShipsInGroup:own_group_id] + (ranrot_rand() & 3); // add a random fudge factor
|
||||||
int target_group_numbers = [self numberOfShipsInGroup:target_group_id] + (ranrot_rand() & 3); // add a random fudge factor
|
int target_group_numbers = [self numberOfShipsInGroup:target_group_id] + (ranrot_rand() & 3); // add a random fudge factor
|
||||||
|
|
||||||
//debug
|
|
||||||
//NSLog(@"DEBUG pirates of group %d (%d ships) considering an attack on group %d (%d ships)", own_group_id, own_group_numbers, target_group_id, target_group_numbers);
|
|
||||||
|
|
||||||
if (own_group_numbers == target_group_numbers)
|
if (own_group_numbers == target_group_numbers)
|
||||||
{
|
{
|
||||||
[shipAI message:@"ODDS_LEVEL"];
|
[shipAI message:@"ODDS_LEVEL"];
|
||||||
@ -1177,17 +1150,12 @@ WormholeEntity* whole;
|
|||||||
{
|
{
|
||||||
if (group_id == NO_TARGET) // ship is alone!
|
if (group_id == NO_TARGET) // ship is alone!
|
||||||
{
|
{
|
||||||
//debug
|
|
||||||
//NSLog(@"DEBUG Lone ship %@ %d attacking target %d", name, universal_id, found_target);
|
|
||||||
|
|
||||||
found_target = primaryTarget;
|
found_target = primaryTarget;
|
||||||
[shipAI reactToMessage:@"GROUP_ATTACK_TARGET"];
|
[shipAI reactToMessage:@"GROUP_ATTACK_TARGET"];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSArray* fellow_ships = [self shipsInGroup:group_id];
|
NSArray* fellow_ships = [self shipsInGroup:group_id];
|
||||||
//debug
|
|
||||||
//NSLog(@"DEBUG %d %@ ships of group %d attacking target %d", [fellow_ships count], roles, group_id, found_target);
|
|
||||||
ShipEntity* target_ship = (ShipEntity*) [universe entityForUniversalID:primaryTarget];
|
ShipEntity* target_ship = (ShipEntity*) [universe entityForUniversalID:primaryTarget];
|
||||||
|
|
||||||
if ((!target_ship)||(target_ship->isShip != YES))
|
if ((!target_ship)||(target_ship->isShip != YES))
|
||||||
@ -1730,8 +1698,6 @@ WormholeEntity* whole;
|
|||||||
}
|
}
|
||||||
[wh release]; // released
|
[wh release]; // released
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSLog(@"DEBUG %@ told to enter wormhole %@", self, whole);
|
|
||||||
|
|
||||||
if (!whole)
|
if (!whole)
|
||||||
return;
|
return;
|
||||||
@ -1743,7 +1709,7 @@ WormholeEntity* whole;
|
|||||||
|
|
||||||
- (void) scriptActionOnTarget:(NSString*) action
|
- (void) scriptActionOnTarget:(NSString*) action
|
||||||
{
|
{
|
||||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||||
Entity* targEnt = [universe entityForUniversalID:primaryTarget];
|
Entity* targEnt = [universe entityForUniversalID:primaryTarget];
|
||||||
if ((targEnt)&&(player))
|
if ((targEnt)&&(player))
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,6 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
#import "Entity.h"
|
#import "Entity.h"
|
||||||
|
|
||||||
#define SKY_POINTS 2
|
|
||||||
#define SKY_BILLBOARDS 3
|
#define SKY_BILLBOARDS 3
|
||||||
|
|
||||||
#define BILLBOARD_DEPTH 50000.0
|
#define BILLBOARD_DEPTH 50000.0
|
||||||
|
@ -26,6 +26,7 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
#import "Entity.h"
|
#import "Entity.h"
|
||||||
#import "SkyEntity.h"
|
#import "SkyEntity.h"
|
||||||
|
#import "PlayerEntity.h"
|
||||||
|
|
||||||
#import "OOMaths.h"
|
#import "OOMaths.h"
|
||||||
#import "Universe.h"
|
#import "Universe.h"
|
||||||
@ -442,7 +443,7 @@ MA 02110-1301, USA.
|
|||||||
{
|
{
|
||||||
if (usingVAR)
|
if (usingVAR)
|
||||||
[self OGL_UpdateVAR];
|
[self OGL_UpdateVAR];
|
||||||
Entity* player = [universe entityZero];
|
PlayerEntity *player = [PlayerEntity sharedPlayer];
|
||||||
zero_distance = MAX_CLEAR_DEPTH * MAX_CLEAR_DEPTH;
|
zero_distance = MAX_CLEAR_DEPTH * MAX_CLEAR_DEPTH;
|
||||||
position = (player)? player->position : position;
|
position = (player)? player->position : position;
|
||||||
}
|
}
|
||||||
@ -471,10 +472,6 @@ MA 02110-1301, USA.
|
|||||||
{
|
{
|
||||||
switch (sky_type)
|
switch (sky_type)
|
||||||
{
|
{
|
||||||
case SKY_POINTS :
|
|
||||||
NSLog(@"ERROR: SkyEntity SKY_POINTS deprecated");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKY_BILLBOARDS :
|
case SKY_BILLBOARDS :
|
||||||
|
|
||||||
if ((star_textureName == 0)&&(universe))
|
if ((star_textureName == 0)&&(universe))
|
||||||
@ -492,10 +489,6 @@ MA 02110-1301, USA.
|
|||||||
if (usingVAR)
|
if (usingVAR)
|
||||||
glBindVertexArrayAPPLE(gVertexArrayRangeObjects[0]);
|
glBindVertexArrayAPPLE(gVertexArrayRangeObjects[0]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// if (usingVAR)
|
|
||||||
// NSLog(@"DEBUG using accelerated memory technique to draw %@ (%@)", self, basefile);
|
|
||||||
//
|
|
||||||
glBindTexture(GL_TEXTURE_2D, star_textureName);
|
glBindTexture(GL_TEXTURE_2D, star_textureName);
|
||||||
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
@ -594,8 +587,6 @@ MA 02110-1301, USA.
|
|||||||
// No over-ride of Entity's version of the method is required for non-Win32 platforms.
|
// No over-ride of Entity's version of the method is required for non-Win32 platforms.
|
||||||
- (void) reloadTextures
|
- (void) reloadTextures
|
||||||
{
|
{
|
||||||
//NSLog(@"SkyEntity::reloadTextures called, calling super and resetTextureNames");
|
|
||||||
|
|
||||||
// Force the sky textures to be reloaded next time a frame is drawn.
|
// Force the sky textures to be reloaded next time a frame is drawn.
|
||||||
star_textureName = 0;
|
star_textureName = 0;
|
||||||
blob_textureName = 0;
|
blob_textureName = 0;
|
||||||
|
@ -36,16 +36,14 @@ MA 02110-1301, USA.
|
|||||||
#import "AI.h"
|
#import "AI.h"
|
||||||
#import "OOCharacter.h"
|
#import "OOCharacter.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.StationEntity"
|
||||||
|
|
||||||
|
|
||||||
@implementation StationEntity
|
@implementation StationEntity
|
||||||
|
|
||||||
- (void) acceptDistressMessageFrom:(ShipEntity *)other
|
- (void) acceptDistressMessageFrom:(ShipEntity *)other
|
||||||
{
|
{
|
||||||
if (self != [universe station])
|
if (self != [universe station]) return;
|
||||||
{
|
|
||||||
//NSLog(@"DEBUG acceptDistressMessageFrom rejected from sub-station '%@'", name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int old_target = primaryTarget;
|
int old_target = primaryTarget;
|
||||||
primaryTarget = [[other getPrimaryTarget] universal_id];
|
primaryTarget = [[other getPrimaryTarget] universal_id];
|
||||||
@ -147,7 +145,6 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
- (NSMutableArray *) initialiseLocalMarketWithSeed: (Random_Seed) s_seed andRandomFactor: (int) random_factor
|
- (NSMutableArray *) initialiseLocalMarketWithSeed: (Random_Seed) s_seed andRandomFactor: (int) random_factor
|
||||||
{
|
{
|
||||||
//NSLog(@"///// Initialising local market for station %@ with roles %@",self,[self roles]);
|
|
||||||
int rf = (random_factor ^ universal_id) & 0xff;
|
int rf = (random_factor ^ universal_id) & 0xff;
|
||||||
int economy = [(NSNumber *)[[universe generateSystemData:s_seed] objectForKey:KEY_ECONOMY] intValue];
|
int economy = [(NSNumber *)[[universe generateSystemData:s_seed] objectForKey:KEY_ECONOMY] intValue];
|
||||||
if (localMarket)
|
if (localMarket)
|
||||||
@ -158,19 +155,17 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
- (NSMutableArray *) initialiseLocalPassengersWithSeed: (Random_Seed) s_seed andRandomFactor: (int) random_factor
|
- (NSMutableArray *) initialiseLocalPassengersWithSeed: (Random_Seed) s_seed andRandomFactor: (int) random_factor
|
||||||
{
|
{
|
||||||
//NSLog(@"///// Initialising local market for station %@ with roles %@",self,[self roles]);
|
|
||||||
if (localPassengers)
|
if (localPassengers)
|
||||||
[localPassengers release];
|
[localPassengers release];
|
||||||
localPassengers = [[NSMutableArray alloc] initWithArray:[universe passengersForSystem:s_seed atTime:[[(PlayerEntity*)[universe entityZero] clock_number] intValue]]];
|
localPassengers = [[NSMutableArray alloc] initWithArray:[universe passengersForSystem:s_seed atTime:[[[PlayerEntity sharedPlayer] clock_number] intValue]]];
|
||||||
return localPassengers;
|
return localPassengers;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMutableArray *) initialiseLocalContractsWithSeed: (Random_Seed) s_seed andRandomFactor: (int) random_factor
|
- (NSMutableArray *) initialiseLocalContractsWithSeed: (Random_Seed) s_seed andRandomFactor: (int) random_factor
|
||||||
{
|
{
|
||||||
//NSLog(@"///// Initialising local market for station %@ with roles %@",self,[self roles]);
|
|
||||||
if (localContracts)
|
if (localContracts)
|
||||||
[localContracts release];
|
[localContracts release];
|
||||||
localContracts = [[NSMutableArray alloc] initWithArray:[universe contractsForSystem:s_seed atTime:[[(PlayerEntity*)[universe entityZero] clock_number] intValue]]];
|
localContracts = [[NSMutableArray alloc] initWithArray:[universe contractsForSystem:s_seed atTime:[[[PlayerEntity sharedPlayer] clock_number] intValue]]];
|
||||||
return localContracts;
|
return localContracts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,10 +418,6 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
Vector delta = ship->position;
|
Vector delta = ship->position;
|
||||||
delta.x -= coords.x; delta.y -= coords.y; delta.z -= coords.z;
|
delta.x -= coords.x; delta.y -= coords.y; delta.z -= coords.z;
|
||||||
|
|
||||||
// if (ship->isPlayer)
|
|
||||||
// NSLog(@"DEBUG docking_stage %d: ship is %.2fm from control point ( %.2f, %.2f, %.2f)",
|
|
||||||
// docking_stage, sqrt(magnitude2(delta)), coords.x, coords.y, coords.z);
|
|
||||||
|
|
||||||
if (magnitude2(delta) > max_allowed_range * max_allowed_range) // too far from the coordinates - do not remove them from the stack!
|
if (magnitude2(delta) > max_allowed_range * max_allowed_range) // too far from the coordinates - do not remove them from the stack!
|
||||||
{
|
{
|
||||||
if ((docking_stage == 1) &&(magnitude2(delta) < 1000000.0)) // 1km*1km
|
if ((docking_stage == 1) &&(magnitude2(delta) < 1000000.0)) // 1km*1km
|
||||||
@ -509,8 +500,6 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
int corridor_count = 9;
|
int corridor_count = 9;
|
||||||
int corridor_final_approach = 3;
|
int corridor_final_approach = 3;
|
||||||
|
|
||||||
// NSLog(@"DEBUG adding %@ to shipsOnApproach", ship);
|
|
||||||
|
|
||||||
int ship_id = [ship universal_id];
|
int ship_id = [ship universal_id];
|
||||||
NSString* shipID = [NSString stringWithFormat:@"%d", ship_id];
|
NSString* shipID = [NSString stringWithFormat:@"%d", ship_id];
|
||||||
|
|
||||||
@ -621,16 +610,12 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
|
|
||||||
- (Vector) portUpVector
|
- (Vector) portUpVector
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG docking port for %@ is %@ dimensions ( %.2f, %.2f, %.2f)", self, port_model,
|
|
||||||
// port_dimensions.x, port_dimensions.y, port_dimensions.z);
|
|
||||||
if (port_dimensions.x > port_dimensions.y)
|
if (port_dimensions.x > port_dimensions.y)
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG returning UP !");
|
|
||||||
return vector_up_from_quaternion( quaternion_multiply( port_qrotation, q_rotation));
|
return vector_up_from_quaternion( quaternion_multiply( port_qrotation, q_rotation));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG returning RIGHT !");
|
|
||||||
return vector_right_from_quaternion( quaternion_multiply( port_qrotation, q_rotation));
|
return vector_right_from_quaternion( quaternion_multiply( port_qrotation, q_rotation));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -639,8 +624,6 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
{
|
{
|
||||||
BOOL twist = ((port_dimensions.x < port_dimensions.y) ^ (bb.max.x - bb.min.x < bb.max.y - bb.min.y));
|
BOOL twist = ((port_dimensions.x < port_dimensions.y) ^ (bb.max.x - bb.min.x < bb.max.y - bb.min.y));
|
||||||
|
|
||||||
// NSLog(@"DEBUG docking: port_twist:%@ ship_twist:%@ twist:%@", (port_dimensions.x < port_dimensions.y)?@"YES":@"NO", (bb.max.x - bb.min.x < bb.max.y - bb.min.y)?@"YES":@"NO", twist?@"YES":@"NO");
|
|
||||||
|
|
||||||
if (!twist)
|
if (!twist)
|
||||||
{
|
{
|
||||||
return vector_up_from_quaternion( quaternion_multiply( port_qrotation, q_rotation));
|
return vector_up_from_quaternion( quaternion_multiply( port_qrotation, q_rotation));
|
||||||
@ -750,8 +733,6 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
{
|
{
|
||||||
self = [super initWithDictionary:dict];
|
self = [super initWithDictionary:dict];
|
||||||
|
|
||||||
//NSLog(@"DEBUG setting up station '%@' from dict:%@",name,[dict description]);
|
|
||||||
|
|
||||||
if ([dict objectForKey:@"equivalent_tech_level"])
|
if ([dict objectForKey:@"equivalent_tech_level"])
|
||||||
equivalent_tech_level = [(NSNumber *)[dict objectForKey:@"equivalent_tech_level"] intValue];
|
equivalent_tech_level = [(NSNumber *)[dict objectForKey:@"equivalent_tech_level"] intValue];
|
||||||
else
|
else
|
||||||
@ -1043,7 +1024,6 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
if (vdp > 0.86)
|
if (vdp > 0.86)
|
||||||
{
|
{
|
||||||
isEmpty = NO;
|
isEmpty = NO;
|
||||||
// NSLog(@"DEBUG %@ is blocking %@ launch corridor distance = %.0f (%.0f).", ship, self, sqrt(d2), d2);
|
|
||||||
last_launch_time = unitime;
|
last_launch_time = unitime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1101,8 +1081,8 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
if (vdp > 0.86)
|
if (vdp > 0.86)
|
||||||
{
|
{
|
||||||
isClear = NO;
|
isClear = NO;
|
||||||
|
|
||||||
// okay it's in the way .. give it a wee nudge (0.25s)
|
// okay it's in the way .. give it a wee nudge (0.25s)
|
||||||
// NSLog(@"DEBUG [StationEntity clearDockingCorridor] nudging %@", ship);
|
|
||||||
[ship update: 0.25];
|
[ship update: 0.25];
|
||||||
time_out += 0.25;
|
time_out += 0.25;
|
||||||
}
|
}
|
||||||
@ -1131,9 +1111,6 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
|
|
||||||
double unitime = [universe getTime];
|
double unitime = [universe getTime];
|
||||||
|
|
||||||
// if (sub_entities)
|
|
||||||
// NSLog(@"DEBUG %@ sub_entities %@", [self name], [sub_entities description]);
|
|
||||||
|
|
||||||
[super update:delta_t];
|
[super update:delta_t];
|
||||||
|
|
||||||
if (([launchQueue count] > 0)&&([shipsOnApproach count] == 0)&&[self dockingCorridorIsEmpty])
|
if (([launchQueue count] > 0)&&([shipsOnApproach count] == 0)&&[self dockingCorridorIsEmpty])
|
||||||
@ -1160,10 +1137,8 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
|
|
||||||
if ((docked_traders > 0)&&(!isRockHermit))
|
if ((docked_traders > 0)&&(!isRockHermit))
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG1 %f %f", unitime, last_trader_launch_time + trader_launch_interval);
|
|
||||||
if (unitime > last_trader_launch_time + trader_launch_interval)
|
if (unitime > last_trader_launch_time + trader_launch_interval)
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG O ---> %d docked traders at %.1f (%.1f and every %.1f)", docked_traders, [universe getTime], last_trader_launch_time + trader_launch_interval, trader_launch_interval);
|
|
||||||
[self launchTrader];
|
[self launchTrader];
|
||||||
docked_traders--;
|
docked_traders--;
|
||||||
last_trader_launch_time = unitime;
|
last_trader_launch_time = unitime;
|
||||||
@ -1173,7 +1148,6 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
// testing patrols
|
// testing patrols
|
||||||
if ((unitime > last_patrol_report_time + patrol_launch_interval)&&(isMainStation))
|
if ((unitime > last_patrol_report_time + patrol_launch_interval)&&(isMainStation))
|
||||||
{
|
{
|
||||||
// NSLog(@"%@ %d (%@) launching a patrol...", name, universal_id, roles);
|
|
||||||
if (![self launchPatrol])
|
if (![self launchPatrol])
|
||||||
last_patrol_report_time = unitime;
|
last_patrol_report_time = unitime;
|
||||||
}
|
}
|
||||||
@ -1277,7 +1251,7 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
if ((id_lock[i] == ship_id)||([universe entityForUniversalID:id_lock[i]] == nil))
|
if ((id_lock[i] == ship_id)||([universe entityForUniversalID:id_lock[i]] == nil))
|
||||||
id_lock[i] = NO_TARGET;
|
id_lock[i] = NO_TARGET;
|
||||||
|
|
||||||
if (ship == [universe entityZero]) // ie. the player
|
if (ship == [PlayerEntity sharedPlayer]) // ie. the player
|
||||||
{
|
{
|
||||||
//scripting
|
//scripting
|
||||||
if ([script_actions count])
|
if ([script_actions count])
|
||||||
@ -1286,10 +1260,6 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
[(PlayerEntity *)ship scriptActions: script_actions forTarget: ship];
|
[(PlayerEntity *)ship scriptActions: script_actions forTarget: ship];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSLog(@"DEBUG ::::: %d :: %d :: %d :: %d :: %d :: %d :: %d :: %d :: %d :: %d <<",
|
|
||||||
// id_lock[10],id_lock[9],id_lock[8],id_lock[7],id_lock[6],id_lock[5],id_lock[4],id_lock[3],id_lock[2],id_lock[1]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1359,13 +1329,11 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
[shipAI reactToMessage:@"TARGET_LOST"];
|
[shipAI reactToMessage:@"TARGET_LOST"];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//NSLog(@"Launching Police Ship to intercept %@",[universe entityForUniversalID:police_target]);
|
|
||||||
|
|
||||||
if ((ranrot_rand() & 7) + 6 <= techlevel)
|
if ((ranrot_rand() & 7) + 6 <= techlevel)
|
||||||
police_ship = [universe getShipWithRole:@"interceptor"]; // retain count = 1
|
police_ship = [universe newShipWithRole:@"interceptor"]; // retain count = 1
|
||||||
else
|
else
|
||||||
police_ship = [universe getShipWithRole:@"police"]; // retain count = 1
|
police_ship = [universe newShipWithRole:@"police"]; // retain count = 1
|
||||||
if (police_ship)
|
if (police_ship)
|
||||||
{
|
{
|
||||||
if (![police_ship crew])
|
if (![police_ship crew])
|
||||||
@ -1415,29 +1383,23 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
|
|
||||||
if ([shipinfoDictionary objectForKey:@"defense_ship"])
|
if ([shipinfoDictionary objectForKey:@"defense_ship"])
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG Defense ship key found: %@", [shipinfoDictionary objectForKey:@"defense_ship"]);
|
|
||||||
defense_ship_key = (NSString*)[shipinfoDictionary objectForKey:@"defense_ship"];
|
defense_ship_key = (NSString*)[shipinfoDictionary objectForKey:@"defense_ship"];
|
||||||
defense_ship_ai = nil;
|
defense_ship_ai = nil;
|
||||||
}
|
}
|
||||||
if ([shipinfoDictionary objectForKey:@"defense_ship_role"])
|
if ([shipinfoDictionary objectForKey:@"defense_ship_role"])
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG Defense ship role key found: %@", [shipinfoDictionary objectForKey:@"defense_ship_role"]);
|
|
||||||
defense_ship_role_key = (NSString*)[shipinfoDictionary objectForKey:@"defense_ship_role"];
|
defense_ship_role_key = (NSString*)[shipinfoDictionary objectForKey:@"defense_ship_role"];
|
||||||
defense_ship_ai = nil;
|
defense_ship_ai = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSLog(@"DEBUG Launching defense ship to intercept %@",[(ShipEntity *)[universe entityForUniversalID:defense_target] name]);
|
|
||||||
|
|
||||||
if (defense_ship_key)
|
if (defense_ship_key)
|
||||||
{
|
{
|
||||||
defense_ship = [universe getShip:defense_ship_key];
|
defense_ship = [universe newShipWithName:defense_ship_key];
|
||||||
// NSLog(@"DEBUG launchDefenseShip Got ship with defense_ship '%@' : %@", defense_ship_key, defense_ship);
|
|
||||||
[defense_ship setRoles:@"defense_ship"];
|
[defense_ship setRoles:@"defense_ship"];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
defense_ship = [universe getShipWithRole:defense_ship_role_key];
|
defense_ship = [universe newShipWithRole:defense_ship_role_key];
|
||||||
// NSLog(@"DEBUG launchDefenseShip Got ship with defense_ship_role '%@' : %@", defense_ship_role_key, defense_ship);
|
|
||||||
[defense_ship setRoles:@"defense_ship"];
|
[defense_ship setRoles:@"defense_ship"];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1461,18 +1423,12 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
|
|
||||||
if ((scan_class != CLASS_ROCK)&&(scan_class != CLASS_STATION))
|
if ((scan_class != CLASS_ROCK)&&(scan_class != CLASS_STATION))
|
||||||
[defense_ship setScanClass: scan_class]; // same as self
|
[defense_ship setScanClass: scan_class]; // same as self
|
||||||
|
|
||||||
//[defense_ship setReportAImessages:YES]; // debug
|
|
||||||
|
|
||||||
// NSLog(@"DEBUG Launching defense ship %@ %@", defense_ship, [defense_ship name]);
|
|
||||||
|
|
||||||
[self addShipToLaunchQueue:defense_ship];
|
[self addShipToLaunchQueue:defense_ship];
|
||||||
[defense_ship release];
|
[defense_ship release];
|
||||||
no_docking_while_launching = YES;
|
no_docking_while_launching = YES;
|
||||||
[self abortAllDockings];
|
[self abortAllDockings];
|
||||||
|
|
||||||
// NSLog(@"DEBUG Launchqueue : %@",[launchQueue description]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) launchScavenger
|
- (void) launchScavenger
|
||||||
@ -1481,17 +1437,12 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
|
|
||||||
int scavs = [universe countShipsWithRole:@"scavenger" inRange:SCANNER_MAX_RANGE ofEntity:self] + [self countShipsInLaunchQueueWithRole:@"scavenger"];
|
int scavs = [universe countShipsWithRole:@"scavenger" inRange:SCANNER_MAX_RANGE ofEntity:self] + [self countShipsInLaunchQueueWithRole:@"scavenger"];
|
||||||
|
|
||||||
if (scavs >= max_scavengers)
|
if (scavs >= max_scavengers) return;
|
||||||
return;
|
if (scavengers_launched >= max_scavengers) return;
|
||||||
|
|
||||||
if (scavengers_launched >= max_scavengers)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//NSLog(@"Launching Scavenger");
|
|
||||||
|
|
||||||
scavengers_launched++;
|
scavengers_launched++;
|
||||||
|
|
||||||
scavenger_ship = [universe getShipWithRole:@"scavenger"]; // retain count = 1
|
scavenger_ship = [universe newShipWithRole:@"scavenger"]; // retain count = 1
|
||||||
if (scavenger_ship)
|
if (scavenger_ship)
|
||||||
{
|
{
|
||||||
if (![scavenger_ship crew])
|
if (![scavenger_ship crew])
|
||||||
@ -1518,13 +1469,9 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// count miners as scavengers...
|
// count miners as scavengers...
|
||||||
//
|
if (scavengers_launched >= max_scavengers) return;
|
||||||
if (scavengers_launched >= max_scavengers)
|
|
||||||
return;
|
miner_ship = [universe newShipWithRole:@"miner"]; // retain count = 1
|
||||||
//
|
|
||||||
// NSLog(@"Launching Miner");
|
|
||||||
//
|
|
||||||
miner_ship = [universe getShipWithRole:@"miner"]; // retain count = 1
|
|
||||||
if (miner_ship)
|
if (miner_ship)
|
||||||
{
|
{
|
||||||
if (![miner_ship crew])
|
if (![miner_ship crew])
|
||||||
@ -1557,12 +1504,10 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//NSLog(@"Launching pirate Ship to intercept %@",[(ShipEntity *)[universe entityForUniversalID:defense_target] name]); //debug
|
|
||||||
|
|
||||||
police_launched++;
|
police_launched++;
|
||||||
|
|
||||||
// Yep! The standard hermit defence ships, even if they're the aggressor.
|
// Yep! The standard hermit defence ships, even if they're the aggressor.
|
||||||
pirate_ship = [universe getShipWithRole:@"pirate"]; // retain count = 1
|
pirate_ship = [universe newShipWithRole:@"pirate"]; // retain count = 1
|
||||||
// Nope, use standard pirates in a generic method.
|
// Nope, use standard pirates in a generic method.
|
||||||
|
|
||||||
if (pirate_ship)
|
if (pirate_ship)
|
||||||
@ -1594,7 +1539,7 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
{
|
{
|
||||||
ShipEntity *shuttle_ship;
|
ShipEntity *shuttle_ship;
|
||||||
|
|
||||||
shuttle_ship = [universe getShipWithRole:@"shuttle"]; // retain count = 1
|
shuttle_ship = [universe newShipWithRole:@"shuttle"]; // retain count = 1
|
||||||
|
|
||||||
if (shuttle_ship)
|
if (shuttle_ship)
|
||||||
{
|
{
|
||||||
@ -1608,9 +1553,6 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
[shuttle_ship setCargoFlag:CARGO_FLAG_FULL_SCARCE];
|
[shuttle_ship setCargoFlag:CARGO_FLAG_FULL_SCARCE];
|
||||||
[[shuttle_ship getAI] setStateMachine:@"fallingShuttleAI.plist"];
|
[[shuttle_ship getAI] setStateMachine:@"fallingShuttleAI.plist"];
|
||||||
[self addShipToLaunchQueue:shuttle_ship];
|
[self addShipToLaunchQueue:shuttle_ship];
|
||||||
|
|
||||||
// NSLog(@"%@ Prepping shuttle: %@ %d for launch.", [self name], [shuttle_ship name], [shuttle_ship universal_id]);
|
|
||||||
// [shuttle_ship setReportAImessages:YES]; //DEBUG
|
|
||||||
|
|
||||||
[shuttle_ship release];
|
[shuttle_ship release];
|
||||||
}
|
}
|
||||||
@ -1621,19 +1563,8 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
BOOL sunskimmer = (randf() < 0.1); // 10%
|
BOOL sunskimmer = (randf() < 0.1); // 10%
|
||||||
ShipEntity *trader_ship = nil;
|
ShipEntity *trader_ship = nil;
|
||||||
|
|
||||||
// NSLog(@"DEBUG %@ [StationEntity launchTrader]", self);
|
if (!sunskimmer) trader_ship = [universe newShipWithRole:@"trader"]; // retain count = 1
|
||||||
|
else trader_ship = [universe newShipWithRole:@"sunskim-trader"]; // retain count = 1
|
||||||
// do {
|
|
||||||
// [trader_ship release];
|
|
||||||
//
|
|
||||||
if (!sunskimmer)
|
|
||||||
trader_ship = [universe getShipWithRole:@"trader"]; // retain count = 1
|
|
||||||
else
|
|
||||||
trader_ship = [universe getShipWithRole:@"sunskim-trader"]; // retain count = 1
|
|
||||||
//
|
|
||||||
// } while (![trader_ship n_escorts]); // DEBUG we NEED escorts
|
|
||||||
|
|
||||||
// NSLog(@"DEBUG [StationEntity launchTrader] ---> %@ ", trader_ship);
|
|
||||||
|
|
||||||
if (trader_ship)
|
if (trader_ship)
|
||||||
{
|
{
|
||||||
@ -1663,8 +1594,6 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
[trader_ship setN_escorts:0];
|
[trader_ship setN_escorts:0];
|
||||||
while (escorts--)
|
while (escorts--)
|
||||||
[self launchEscort];
|
[self launchEscort];
|
||||||
|
|
||||||
// NSLog(@"%@ Prepping trader: %@ %d for launch.", [self name], [trader_ship name], [trader_ship universal_id]);
|
|
||||||
|
|
||||||
[trader_ship release];
|
[trader_ship release];
|
||||||
}
|
}
|
||||||
@ -1674,7 +1603,7 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
{
|
{
|
||||||
ShipEntity *escort_ship;
|
ShipEntity *escort_ship;
|
||||||
|
|
||||||
escort_ship = [universe getShipWithRole:@"escort"]; // retain count = 1
|
escort_ship = [universe newShipWithRole:@"escort"]; // retain count = 1
|
||||||
|
|
||||||
if (escort_ship)
|
if (escort_ship)
|
||||||
{
|
{
|
||||||
@ -1689,8 +1618,6 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
[[escort_ship getAI] setStateMachine:@"escortAI.plist"];
|
[[escort_ship getAI] setStateMachine:@"escortAI.plist"];
|
||||||
[self addShipToLaunchQueue:escort_ship];
|
[self addShipToLaunchQueue:escort_ship];
|
||||||
|
|
||||||
// [escort_ship setReportAImessages: YES];
|
|
||||||
|
|
||||||
[escort_ship release];
|
[escort_ship release];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1708,9 +1635,9 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
police_launched++;
|
police_launched++;
|
||||||
|
|
||||||
if ((ranrot_rand() & 7) + 6 <= techlevel)
|
if ((ranrot_rand() & 7) + 6 <= techlevel)
|
||||||
patrol_ship = [universe getShipWithRole:@"interceptor"]; // retain count = 1
|
patrol_ship = [universe newShipWithRole:@"interceptor"]; // retain count = 1
|
||||||
else
|
else
|
||||||
patrol_ship = [universe getShipWithRole:@"police"]; // retain count = 1
|
patrol_ship = [universe newShipWithRole:@"police"]; // retain count = 1
|
||||||
if (patrol_ship)
|
if (patrol_ship)
|
||||||
{
|
{
|
||||||
if (![patrol_ship crew])
|
if (![patrol_ship crew])
|
||||||
@ -1736,7 +1663,7 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
|
|
||||||
- (void) launchShipWithRole:(NSString*) role
|
- (void) launchShipWithRole:(NSString*) role
|
||||||
{
|
{
|
||||||
ShipEntity *ship = [universe getShipWithRole: role]; // retain count = 1
|
ShipEntity *ship = [universe newShipWithRole: role]; // retain count = 1
|
||||||
if (ship)
|
if (ship)
|
||||||
{
|
{
|
||||||
if (![ship crew])
|
if (![ship crew])
|
||||||
@ -1754,7 +1681,7 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
- (void) becomeExplosion
|
- (void) becomeExplosion
|
||||||
{
|
{
|
||||||
// launch docked ships if possible
|
// launch docked ships if possible
|
||||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||||
if ((player)&&(player->status == STATUS_DOCKED)&&([player docked_station] == self))
|
if ((player)&&(player->status == STATUS_DOCKED)&&([player docked_station] == self))
|
||||||
{
|
{
|
||||||
// undock the player!
|
// undock the player!
|
||||||
@ -1778,19 +1705,13 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
- (void) acceptPatrolReportFrom:(ShipEntity*) patrol_ship
|
- (void) acceptPatrolReportFrom:(ShipEntity*) patrol_ship
|
||||||
{
|
{
|
||||||
last_patrol_report_time = [universe getTime];
|
last_patrol_report_time = [universe getTime];
|
||||||
// NSLog(@"..... patrol report received from %@ %d at %3.2f", [patrol_ship name], [patrol_ship universal_id], [universe getTime]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) acceptDockingClearanceRequestFrom:(ShipEntity *)other
|
- (void) acceptDockingClearanceRequestFrom:(ShipEntity *)other
|
||||||
{
|
{
|
||||||
if (self != [universe station])
|
if (self != [universe station]) return;
|
||||||
{
|
|
||||||
//NSLog(@"DEBUG acceptDistressMessageFrom rejected from sub-station '%@'", name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check
|
// check
|
||||||
//
|
|
||||||
if ([shipsOnApproach count])
|
if ([shipsOnApproach count])
|
||||||
{
|
{
|
||||||
[self sendExpandedMessage:@"Please wait until all ships have completed their approach." toShip:other];
|
[self sendExpandedMessage:@"Please wait until all ships have completed their approach." toShip:other];
|
||||||
@ -1836,7 +1757,7 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
return YES;
|
return YES;
|
||||||
if ([shipinfoDictionary objectForKey:@"hasShipyard"])
|
if ([shipinfoDictionary objectForKey:@"hasShipyard"])
|
||||||
{
|
{
|
||||||
PlayerEntity *player = (PlayerEntity*)[universe entityZero];
|
PlayerEntity *player = [PlayerEntity sharedPlayer];
|
||||||
NSObject *determinant = [shipinfoDictionary objectForKey:@"hasShipyard"];
|
NSObject *determinant = [shipinfoDictionary objectForKey:@"hasShipyard"];
|
||||||
if ([determinant isKindOfClass:[NSArray class]])
|
if ([determinant isKindOfClass:[NSArray class]])
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,8 @@ MA 02110-1301, USA.
|
|||||||
#import "OOTextureScaling.h"
|
#import "OOTextureScaling.h"
|
||||||
#import "OOStringParsing.h"
|
#import "OOStringParsing.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.TextureStore"
|
||||||
|
|
||||||
|
|
||||||
static NSString * const kOOLogPlanetTextureGen = @"texture.planet.generate";
|
static NSString * const kOOLogPlanetTextureGen = @"texture.planet.generate";
|
||||||
static NSString * const kOOLogShaderInitSuccess = @"rendering.opengl.shader.init.success";
|
static NSString * const kOOLogShaderInitSuccess = @"rendering.opengl.shader.init.success";
|
||||||
@ -58,7 +60,6 @@ GLuint max_texture_dimension = 512; // conservative start
|
|||||||
glGetIntegerv( GL_MAX_TEXTURE_SIZE, &result);
|
glGetIntegerv( GL_MAX_TEXTURE_SIZE, &result);
|
||||||
max_texture_dimension = result;
|
max_texture_dimension = result;
|
||||||
done_maxsize_test = YES;
|
done_maxsize_test = YES;
|
||||||
// NSLog(@"TESTING: GL_MAX_TEXTURE_SIZE = %d", max_texture_dimension);
|
|
||||||
return max_texture_dimension;
|
return max_texture_dimension;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,8 +123,6 @@ GLuint max_texture_dimension = 512; // conservative start
|
|||||||
#ifndef GNUSTEP
|
#ifndef GNUSTEP
|
||||||
NSArray* reps = [texImage representations];
|
NSArray* reps = [texImage representations];
|
||||||
|
|
||||||
// NSLog(@"DEBUG texture %@ representations:\n%@", filename, reps);
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; ((i < [reps count]) && !bitmapImageRep); i++)
|
for (i = 0; ((i < [reps count]) && !bitmapImageRep); i++)
|
||||||
{
|
{
|
||||||
@ -177,7 +176,6 @@ GLuint max_texture_dimension = 512; // conservative start
|
|||||||
|
|
||||||
if (([filename hasPrefix:@"blur"])&&(texture_w == image_w)&&(texture_h == image_h))
|
if (([filename hasPrefix:@"blur"])&&(texture_w == image_w)&&(texture_h == image_h))
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG filling image data for %@ (%d x %d) with special sauce!", filename, texture_w, texture_h);
|
|
||||||
fillSquareImageDataWithBlur(imageBuffer, texture_w, n_planes);
|
fillSquareImageDataWithBlur(imageBuffer, texture_w, n_planes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,7 +362,7 @@ GLuint max_texture_dimension = 512; // conservative start
|
|||||||
GLhandleARB shader_object = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); // a fragment shader
|
GLhandleARB shader_object = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); // a fragment shader
|
||||||
if (!shader_object)
|
if (!shader_object)
|
||||||
{
|
{
|
||||||
NSLog(kOOLogShaderInitFailed, @"GLSL ERROR: could not create a fragment shader with glCreateShaderObjectARB()");
|
OOLog(kOOLogShaderInitFailed, @"GLSL ERROR: could not create a fragment shader with glCreateShaderObjectARB()");
|
||||||
OK = NO;
|
OK = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +383,7 @@ GLuint max_texture_dimension = 512; // conservative start
|
|||||||
char log[1024];
|
char log[1024];
|
||||||
GLsizei log_length;
|
GLsizei log_length;
|
||||||
glGetInfoLogARB( shader_object, 1024, &log_length, log);
|
glGetInfoLogARB( shader_object, 1024, &log_length, log);
|
||||||
NSLog(kOOLogShaderInitFailed, @"GLSL ERROR: shader code would not compile:\n%s\n\n%@\n\n", log, fragmentSource);
|
OOLog(kOOLogShaderInitFailed, @"GLSL ERROR: shader code would not compile:\n%s\n\n%@\n\n", log, fragmentSource);
|
||||||
OK = NO;
|
OK = NO;
|
||||||
}
|
}
|
||||||
fragment_shader_object = shader_object;
|
fragment_shader_object = shader_object;
|
||||||
@ -398,7 +396,7 @@ GLuint max_texture_dimension = 512; // conservative start
|
|||||||
GLhandleARB shader_object = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); // a vertex shader
|
GLhandleARB shader_object = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); // a vertex shader
|
||||||
if (!shader_object)
|
if (!shader_object)
|
||||||
{
|
{
|
||||||
NSLog(kOOLogShaderInitFailed, @"GLSL ERROR: could not create a fragment shader with glCreateShaderObjectARB()");
|
OOLog(kOOLogShaderInitFailed, @"GLSL ERROR: could not create a fragment shader with glCreateShaderObjectARB()");
|
||||||
OK = NO;
|
OK = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -644,7 +642,6 @@ void fillSquareImageDataWithBlur(unsigned char * imageBuffer, int width, int npl
|
|||||||
|
|
||||||
if ((i_error > 1.0)&&(i < 255))
|
if ((i_error > 1.0)&&(i < 255))
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG err correct");
|
|
||||||
i_error -= 1.0;
|
i_error -= 1.0;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,6 @@ extern int debug;
|
|||||||
StationEntity* cachedStation;
|
StationEntity* cachedStation;
|
||||||
PlanetEntity* cachedPlanet;
|
PlanetEntity* cachedPlanet;
|
||||||
PlanetEntity* cachedSun;
|
PlanetEntity* cachedSun;
|
||||||
Entity* cachedEntityZero;
|
|
||||||
|
|
||||||
BOOL strict;
|
BOOL strict;
|
||||||
|
|
||||||
@ -324,10 +323,10 @@ extern int debug;
|
|||||||
- (BOOL) breakPatternHide;
|
- (BOOL) breakPatternHide;
|
||||||
|
|
||||||
- (id) recycleOrDiscard:(Entity *) entity;
|
- (id) recycleOrDiscard:(Entity *) entity;
|
||||||
- (Entity *) recycledOrNew:(NSString *) classname;
|
- (Entity *) allocRecycledOrNewEntity:(NSString *) classname;
|
||||||
|
|
||||||
- (ShipEntity *) getShipWithRole:(NSString *) desc;
|
- (ShipEntity *) newShipWithRole:(NSString *) desc;
|
||||||
- (ShipEntity *) getShip:(NSString *) desc;
|
- (ShipEntity *) newShipWithName:(NSString *) desc;
|
||||||
- (NSDictionary *) getDictionaryForShip:(NSString *) desc;
|
- (NSDictionary *) getDictionaryForShip:(NSString *) desc;
|
||||||
|
|
||||||
- (int) maxCargoForShip:(NSString *) desc;
|
- (int) maxCargoForShip:(NSString *) desc;
|
||||||
@ -357,7 +356,6 @@ extern int debug;
|
|||||||
- (void) drawCrosshairs;
|
- (void) drawCrosshairs;
|
||||||
- (void) drawMessage;
|
- (void) drawMessage;
|
||||||
|
|
||||||
- (id)entityZero;
|
|
||||||
- (id)entityForUniversalID:(int)u_id;
|
- (id)entityForUniversalID:(int)u_id;
|
||||||
|
|
||||||
BOOL maintainLinkedLists(Universe* uni);
|
BOOL maintainLinkedLists(Universe* uni);
|
||||||
@ -435,7 +433,6 @@ BOOL maintainLinkedLists(Universe* uni);
|
|||||||
- (NSString *) generateSystemInhabitants:(Random_Seed) s_seed plural:(BOOL)plural;
|
- (NSString *) generateSystemInhabitants:(Random_Seed) s_seed plural:(BOOL)plural;
|
||||||
- (Random_Seed) findSystemAtCoords:(NSPoint) coords withGalaxySeed:(Random_Seed) gal_seed;
|
- (Random_Seed) findSystemAtCoords:(NSPoint) coords withGalaxySeed:(Random_Seed) gal_seed;
|
||||||
|
|
||||||
+ (NSString*) systemSeedString:(Random_Seed) s;
|
|
||||||
- (NSArray*) nearbyDestinationsWithinRange:(double) range;
|
- (NSArray*) nearbyDestinationsWithinRange:(double) range;
|
||||||
- (Random_Seed) findNeighbouringSystemToCoords:(NSPoint) coords withGalaxySeed:(Random_Seed) gal_seed;
|
- (Random_Seed) findNeighbouringSystemToCoords:(NSPoint) coords withGalaxySeed:(Random_Seed) gal_seed;
|
||||||
- (Random_Seed) findConnectedSystemAtCoords:(NSPoint) coords withGalaxySeed:(Random_Seed) gal_seed;
|
- (Random_Seed) findConnectedSystemAtCoords:(NSPoint) coords withGalaxySeed:(Random_Seed) gal_seed;
|
||||||
@ -471,11 +468,6 @@ double estimatedTimeForJourney(double distance, int hops);
|
|||||||
- (NSString*) equipmentKeyForWeapon:(int) weapon;
|
- (NSString*) equipmentKeyForWeapon:(int) weapon;
|
||||||
- (NSString*) brochureDescriptionWithDictionary:(NSDictionary*) dict standardEquipment:(NSArray*) extras optionalEquipment:(NSArray*) options;
|
- (NSString*) brochureDescriptionWithDictionary:(NSDictionary*) dict standardEquipment:(NSArray*) extras optionalEquipment:(NSArray*) options;
|
||||||
|
|
||||||
- (NSString *) generateSystemDescription:(Random_Seed) s_seed;
|
|
||||||
- (NSString *) expandDescription:(NSString *) desc forSystem:(Random_Seed)s_seed;
|
|
||||||
- (NSString *) expandDescriptionWithLocals:(NSString *) desc forSystem:(Random_Seed)s_seed withLocalVariables:(NSDictionary *)locals;
|
|
||||||
- (NSString *) getRandomDigrams;
|
|
||||||
|
|
||||||
- (Vector) getWitchspaceExitPosition;
|
- (Vector) getWitchspaceExitPosition;
|
||||||
- (Quaternion) getWitchspaceExitRotation;
|
- (Quaternion) getWitchspaceExitRotation;
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -27,10 +27,12 @@ MA 02110-1301, USA.
|
|||||||
#import "ParticleEntity.h"
|
#import "ParticleEntity.h"
|
||||||
#import "ShipEntity.h"
|
#import "ShipEntity.h"
|
||||||
#import "PlanetEntity.h"
|
#import "PlanetEntity.h"
|
||||||
|
#import "PlayerEntity.h"
|
||||||
|
|
||||||
#import "Universe.h"
|
#import "Universe.h"
|
||||||
#import "AI.h"
|
#import "AI.h"
|
||||||
#import "TextureStore.h"
|
#import "TextureStore.h"
|
||||||
|
#import "OOStringParsing.h"
|
||||||
|
|
||||||
|
|
||||||
@implementation WormholeEntity
|
@implementation WormholeEntity
|
||||||
@ -61,14 +63,12 @@ MA 02110-1301, USA.
|
|||||||
//
|
//
|
||||||
position = [ship getPosition];
|
position = [ship getPosition];
|
||||||
//
|
//
|
||||||
Entity* player = [universe entityZero];
|
PlayerEntity *player = [PlayerEntity sharedPlayer];
|
||||||
if (player)
|
if (player)
|
||||||
zero_distance = distance2( player->position, position);
|
zero_distance = distance2( player->position, position);
|
||||||
//
|
//
|
||||||
isWormhole = YES;
|
isWormhole = YES;
|
||||||
//
|
|
||||||
// NSLog(@"DEBUG %@ created!", self);
|
|
||||||
//
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,8 +87,6 @@ MA 02110-1301, USA.
|
|||||||
expiry_time = time_counter + WORMHOLE_EXPIRES_TIMEINTERVAL;
|
expiry_time = time_counter + WORMHOLE_EXPIRES_TIMEINTERVAL;
|
||||||
collision_radius = 0.5 * PI * pow( witch_mass, 1.0/3.0);
|
collision_radius = 0.5 * PI * pow( witch_mass, 1.0/3.0);
|
||||||
|
|
||||||
// NSLog(@"DEBUG %@ sucks in %@", self, ship);
|
|
||||||
|
|
||||||
// witchspace entry effects here
|
// witchspace entry effects here
|
||||||
ParticleEntity *ring = [[ParticleEntity alloc] initHyperringFromShip:ship]; // retained
|
ParticleEntity *ring = [[ParticleEntity alloc] initHyperringFromShip:ship]; // retained
|
||||||
[universe addEntity:ring];
|
[universe addEntity:ring];
|
||||||
@ -112,8 +110,6 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
- (void) disgorgeShips
|
- (void) disgorgeShips
|
||||||
{
|
{
|
||||||
// NSLog(@"disgorging %@", shipsInTransit);
|
|
||||||
|
|
||||||
int n_ships = [shipsInTransit count];
|
int n_ships = [shipsInTransit count];
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
@ -147,10 +143,6 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
[[ship getAI] reactToMessage:@"EXITED WITCHSPACE"];
|
[[ship getAI] reactToMessage:@"EXITED WITCHSPACE"];
|
||||||
|
|
||||||
// [ship setReportAImessages:YES]; // DEBUG
|
|
||||||
|
|
||||||
// NSLog(@"DEBUG %@ disgorged %@", self, ship);
|
|
||||||
|
|
||||||
// update the ships's position
|
// update the ships's position
|
||||||
[ship update: time_passed];
|
[ship update: time_passed];
|
||||||
}
|
}
|
||||||
@ -170,7 +162,7 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
- (NSString*) description
|
- (NSString*) description
|
||||||
{
|
{
|
||||||
NSString* whereto = (universe)? [universe getSystemName: destination] : [Universe systemSeedString: destination];
|
NSString* whereto = (universe) ? [universe getSystemName:destination] : StringFromRandomSeed(destination);
|
||||||
return [NSString stringWithFormat:@"<WormholeEntity to %@ ttl: %.2fs>", whereto, WORMHOLE_EXPIRES_TIMEINTERVAL - time_counter];
|
return [NSString stringWithFormat:@"<WormholeEntity to %@ ttl: %.2fs>", whereto, WORMHOLE_EXPIRES_TIMEINTERVAL - time_counter];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +182,7 @@ MA 02110-1301, USA.
|
|||||||
{
|
{
|
||||||
[super update:delta_t];
|
[super update:delta_t];
|
||||||
|
|
||||||
Entity* player = [universe entityZero];
|
Entity* player = [PlayerEntity sharedPlayer];
|
||||||
if (player)
|
if (player)
|
||||||
{
|
{
|
||||||
// new billboard routine (from Planetentity.m)
|
// new billboard routine (from Planetentity.m)
|
||||||
|
@ -24,6 +24,10 @@ MA 02110-1301, USA.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#import "JoystickHandler.h"
|
#import "JoystickHandler.h"
|
||||||
|
#import "OOLogging.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.JoystickHandler"
|
||||||
|
|
||||||
|
|
||||||
@implementation JoystickHandler
|
@implementation JoystickHandler
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@ MA 02110-1301, USA.
|
|||||||
#import "TextureStore.h"
|
#import "TextureStore.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.MyOpenGLView"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
@implementation MyOpenGLView
|
@implementation MyOpenGLView
|
||||||
|
@ -23,6 +23,9 @@ MA 02110-1301, USA.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SDLMusic.h"
|
#include "SDLMusic.h"
|
||||||
|
#import "OOLogging.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.SDLMusic"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is used by instances of OOMusic to check if they are currently playing
|
* This is used by instances of OOMusic to check if they are currently playing
|
||||||
|
@ -25,6 +25,8 @@ MA 02110-1301, USA.
|
|||||||
#import "SDLSound.h"
|
#import "SDLSound.h"
|
||||||
#import "OOBasicSoundSource.h"
|
#import "OOBasicSoundSource.h"
|
||||||
|
|
||||||
|
#define kOOLogUnconvertedNSLog @"unclassified.SDLSound"
|
||||||
|
|
||||||
|
|
||||||
static int mixChan=0;
|
static int mixChan=0;
|
||||||
static float masterVol=1.0;
|
static float masterVol=1.0;
|
||||||
@ -148,7 +150,6 @@ static BOOL isSetUp=NO;
|
|||||||
[super init];
|
[super init];
|
||||||
if(!isSetUp) [OOSound setUp];
|
if(!isSetUp) [OOSound setUp];
|
||||||
|
|
||||||
//NSLog(@"loading sample: %s", [filepath cString]);
|
|
||||||
sample = Mix_LoadWAV([filepath cString]);
|
sample = Mix_LoadWAV([filepath cString]);
|
||||||
if (!sample) {
|
if (!sample) {
|
||||||
NSLog(@"Mix_LoadWAV: %s\n", Mix_GetError());
|
NSLog(@"Mix_LoadWAV: %s\n", Mix_GetError());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user