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_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
|
||||
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
|
||||
else
|
||||
ADDITIONAL_INCLUDE_DIRS = -Isrc/SDL -Isrc/Core -Isrc/BSDCompat
|
||||
ADDITIONAL_OBJC_LIBS = -lGLU -lGL -lSDL -lpthread -lSDL_mixer -lSDL_image -lgnustep-base
|
||||
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/
|
||||
endif
|
||||
OBJC_PROGRAM_NAME = oolite
|
||||
|
@ -730,7 +730,7 @@
|
||||
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>"; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
@ -1194,7 +1194,7 @@
|
||||
19C28FACFE9D520D11CA2CBB /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0865432206B8447D000CA0AB /* Oolite.app */,
|
||||
0865432206B8447D000CA0AB /* OoliteDev.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@ -1987,7 +1987,7 @@
|
||||
name = Oolite;
|
||||
productInstallPath = "$(HOME)/Applications";
|
||||
productName = Oolite;
|
||||
productReference = 0865432206B8447D000CA0AB /* Oolite.app */;
|
||||
productReference = 0865432206B8447D000CA0AB /* OoliteDev.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
@ -124,6 +124,9 @@ mesh.load.error.tooManyVertices = inherit;
|
||||
mesh.load.error.tooManyFaces = inherit;
|
||||
|
||||
|
||||
oxp.versionMismatch = $error;
|
||||
|
||||
|
||||
$plistError = $error;
|
||||
plist.parse.foundation.failed = $plistError;
|
||||
plist.wrongType = $plistError;
|
||||
@ -199,6 +202,9 @@ script.debug.syntax.addShips = inherit;
|
||||
script.debug.syntax.set = inherit;
|
||||
script.debug.syntax.reset = inherit;
|
||||
|
||||
script.javascript.compile.success = inherit;
|
||||
script.javascript.compile.failed = $scriptError;
|
||||
|
||||
|
||||
searchPaths.dumpAll = $troubleShootingDump;
|
||||
|
||||
@ -249,3 +255,4 @@ sound.streaming.loop = $soundDebug;
|
||||
sound.streaming.underflow = $soundError;
|
||||
sound.virtualringbuffer = $soundError;
|
||||
sound.streaming.releaseContext = $soundDebug;
|
||||
sound.invalidBeep = inherit;
|
||||
|
@ -68,7 +68,7 @@ static NSString * const kOOLogGrooliteDebug = @"growl.debug";
|
||||
NSString *displayString;
|
||||
|
||||
universe = [gameController universe];
|
||||
player = (PlayerEntity *)[universe entityZero];
|
||||
player = [PlayerEntity sharedPlayer];
|
||||
|
||||
if (!inTitle)
|
||||
return; // catch blank messages
|
||||
|
@ -49,8 +49,6 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
||||
|
||||
- (id) initWithFrame:(NSRect)frameRect
|
||||
{
|
||||
//NSLog(@"-- initWithFrame MyOpenGLView");
|
||||
|
||||
// Pixel Format Attributes for the View-based (non-FullScreen) NSOpenGLContext
|
||||
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
|
||||
// and their corresponding RendererID codes.
|
||||
[pixelFormat getValues:&rendererID forAttribute:NSOpenGLPFARendererID forVirtualScreen:0];
|
||||
//NSLog(@" init! NSOpenGLView pixelFormat RendererID = %08x", (unsigned)rendererID);
|
||||
|
||||
self = [super initWithFrame:frameRect pixelFormat:pixelFormat];
|
||||
|
||||
@ -137,7 +134,6 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
||||
|
||||
- (void) setTypedString:(NSString*) value
|
||||
{
|
||||
// NSLog(@"DEBUG setTypedString:%@",value);
|
||||
[typedString setString:value];
|
||||
}
|
||||
|
||||
@ -171,8 +167,6 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
||||
{
|
||||
m_glContextInitialized = NO;
|
||||
viewSize = [self frame].size;
|
||||
|
||||
//NSLog(@"DEBUG resized to %.0f x %.0f", viewSize.width, viewSize.height);
|
||||
}
|
||||
|
||||
if (!m_glContextInitialized)
|
||||
@ -300,7 +294,7 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
||||
|
||||
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 alloc]
|
||||
@ -403,7 +397,6 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
||||
isAlphabetKeyDown = YES;
|
||||
// convert to lowercase
|
||||
[typedString appendFormat:@"%c", (key | 64)];
|
||||
//NSLog(@"accumulated string '%@'",typedString);
|
||||
}
|
||||
else
|
||||
isAlphabetKeyDown = NO;
|
||||
@ -423,7 +416,6 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
||||
isAlphabetKeyDown = YES;
|
||||
// convert to lowercase
|
||||
[typedString appendFormat:@"%c", key];
|
||||
//NSLog(@"accumulated string '%@'",typedString);
|
||||
}
|
||||
else
|
||||
isAlphabetKeyDown = NO;
|
||||
@ -473,8 +465,6 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
||||
{
|
||||
doubleClick = (timeBetweenClicks < MOUSE_DOUBLE_CLICK_INTERVAL); // One fifth of a second
|
||||
keys[gvMouseDoubleClick] = doubleClick;
|
||||
// if (doubleClick)
|
||||
// NSLog(@"DEBUG registering a double-click!");
|
||||
}
|
||||
|
||||
keys[gvMouseLeftButton] = NO; // 'a' up
|
||||
|
@ -26,10 +26,6 @@ MA 02110-1301, USA.
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#ifndef HAVE_SOUND
|
||||
#define HAVE_SOUND
|
||||
#endif
|
||||
|
||||
|
||||
@interface OOSound: NSObject
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ extern NSLock *gOOCASoundSyncLock;
|
||||
extern NSString * const kOOLogDeprecatedMethodOOCASound;
|
||||
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
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <mach/mach_error.h>
|
||||
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"sound.virtualringbuffer"
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.VirtualRingBuffer"
|
||||
|
||||
|
||||
@implementation VirtualRingBuffer
|
||||
|
@ -29,6 +29,8 @@ MA 02110-1301, USA.
|
||||
|
||||
#import "ShipEntity.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.AI"
|
||||
|
||||
|
||||
static NSString * const kOOLogAIReceiveMessage = @"ai.message.receive";
|
||||
static NSString * const kOOLogAITakeAction = @"ai.takeAction.takeAction";
|
||||
|
@ -31,6 +31,8 @@ MA 02110-1301, USA.
|
||||
#import "StationEntity.h"
|
||||
#import "PlayerEntity.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.CollisionRegion"
|
||||
|
||||
|
||||
@implementation CollisionRegion
|
||||
|
||||
|
@ -50,8 +50,7 @@ MA 02110-1301, USA.
|
||||
vertices[vi].y = (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];
|
||||
//
|
||||
displayListName = 0;
|
||||
@ -86,7 +85,7 @@ MA 02110-1301, USA.
|
||||
|
||||
- (void) update:(double) delta_t
|
||||
{
|
||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
||||
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||
if (!player) return; // DON'T UPDATE
|
||||
// do nowt!
|
||||
zero_distance = 0.0;
|
||||
@ -116,7 +115,7 @@ MA 02110-1301, USA.
|
||||
|
||||
- (void) drawEntity:(BOOL) immediate :(BOOL) translucent
|
||||
{
|
||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
||||
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||
if (!player)
|
||||
return; // DON'T DRAW
|
||||
//
|
||||
|
@ -23,6 +23,7 @@ MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#import "Entity.h"
|
||||
#import "PlayerEntity.h"
|
||||
|
||||
#import "OOMaths.h"
|
||||
#import "Geometry.h"
|
||||
@ -35,6 +36,8 @@ MA 02110-1301, USA.
|
||||
|
||||
#import "NSScannerOOExtensions.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.Entity"
|
||||
|
||||
|
||||
static NSString * const kOOLogEntityAddToList = @"entity.linkedList.add";
|
||||
static NSString * const kOOLogEntityAddToListError = @"entity.linkedList.add.error";
|
||||
@ -515,8 +518,7 @@ BOOL global_testForVAR;
|
||||
//
|
||||
collision_radius = [self findCollisionRadius];
|
||||
actual_radius = collision_radius;
|
||||
//NSLog(@"Entity with model '%@' collision radius set to %f",modelName, collision_radius);
|
||||
//
|
||||
|
||||
[mypool release];
|
||||
}
|
||||
- (NSString *) getModel
|
||||
@ -540,7 +542,6 @@ BOOL global_testForVAR;
|
||||
|
||||
- (double) getZeroDistance
|
||||
{
|
||||
// NSLog(@"DEBUG %@ %.1f", self, zero_distance);
|
||||
return zero_distance;
|
||||
}
|
||||
|
||||
@ -821,7 +822,6 @@ BOOL global_testForVAR;
|
||||
else
|
||||
{
|
||||
OOLog(kOOLogFileNotLoaded, @"ERROR no basefile for entity %@");
|
||||
// NSBeep(); // appkit dependency
|
||||
}
|
||||
}
|
||||
glShadeModel(GL_SMOOTH);
|
||||
@ -850,7 +850,6 @@ BOOL global_testForVAR;
|
||||
zero_distance = my_owner->zero_distance;
|
||||
if (zero_distance > no_draw_distance)
|
||||
{
|
||||
//NSLog(@"DEBUG - sub entity '%@' too far away to draw", self);
|
||||
return; // TOO FAR AWAY
|
||||
}
|
||||
}
|
||||
@ -896,8 +895,6 @@ BOOL global_testForVAR;
|
||||
#ifdef WIN32
|
||||
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.
|
||||
for (fi = 0; fi < n_faces; fi++)
|
||||
faces[fi].texName = 0;
|
||||
@ -931,7 +928,6 @@ BOOL global_testForVAR;
|
||||
if (!texture_name[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
|
||||
{
|
||||
Entity* player = [universe entityZero];
|
||||
PlayerEntity *player = [PlayerEntity sharedPlayer];
|
||||
if (player)
|
||||
{
|
||||
if (status != STATUS_COCKPIT_DISPLAY)
|
||||
@ -1011,8 +1007,6 @@ BOOL global_testForVAR;
|
||||
//
|
||||
- (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);
|
||||
double t_now = [universe getTime];
|
||||
Vector pos = resetFrame.position;
|
||||
@ -1118,8 +1112,7 @@ BOOL global_testForVAR;
|
||||
double period = (moment_in_time - t_frame) - track_time;
|
||||
double f1 = -t_frame/period;
|
||||
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;
|
||||
posn.x = f0 * result.position.x + f1 * fr1.position.x;
|
||||
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 f0 = (moment_in_time - track[t1].timeframe)/period;
|
||||
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;
|
||||
posn.x = f0 * track[t0].position.x + f1 * track[t1].position.x;
|
||||
posn.y = f0 * track[t0].position.y + f1 * track[t1].position.y;
|
||||
@ -1264,8 +1256,6 @@ BOOL global_testForVAR;
|
||||
}
|
||||
data = [lines componentsJoinedByString:@"\n"];
|
||||
|
||||
//NSLog(@"More data:\n%@",data);
|
||||
|
||||
scanner = [NSScanner scannerWithString:data];
|
||||
|
||||
// get number of vertices
|
||||
@ -1470,7 +1460,6 @@ BOOL global_testForVAR;
|
||||
{
|
||||
// faces[j].textureFile = [texfile retain];
|
||||
strlcpy( (char*)faces[j].textureFileStr255, [texfile UTF8String], 256);
|
||||
// NSLog(@"DEBUG TEST strlcpy of '%@' result = '%s'", texfile, faces[j].textureFileStr255);
|
||||
}
|
||||
faces[j].texName = 0;
|
||||
|
||||
@ -1521,19 +1510,13 @@ BOOL global_testForVAR;
|
||||
|
||||
if ((failFlag)&&([failString rangeOfString:@"TEXTURES"].location != NSNotFound))
|
||||
{
|
||||
//NSLog(@"Off to make new textures!");
|
||||
[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)
|
||||
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)
|
||||
[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
|
||||
{
|
||||
Vector calculatedNormal;
|
||||
@ -1574,7 +1559,6 @@ BOOL global_testForVAR;
|
||||
calculatedNormal = normal_to_surface (v2, v1, v0);
|
||||
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);
|
||||
norm = normal_to_surface (v0, v1, v2);
|
||||
}
|
||||
@ -1586,10 +1570,6 @@ BOOL global_testForVAR;
|
||||
GLfloat s[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++)
|
||||
{
|
||||
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;
|
||||
|
||||
// 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...
|
||||
[texturesProcessed setObject:tex_string forKey:tex_string]; // note this texture done
|
||||
texi++;
|
||||
@ -1832,7 +1809,6 @@ BOOL global_testForVAR;
|
||||
|
||||
- (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 rpos = position;
|
||||
@ -1882,9 +1858,7 @@ BOOL global_testForVAR;
|
||||
result = [NSString stringWithFormat:@"%@\n", result];
|
||||
}
|
||||
result = [NSString stringWithFormat:@"%@\nFACES\n", result];
|
||||
//
|
||||
//NSLog(result);
|
||||
//
|
||||
|
||||
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);
|
||||
@ -1970,15 +1944,11 @@ BOOL global_testForVAR;
|
||||
//
|
||||
st_width = max_s - min_s;
|
||||
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++)
|
||||
{
|
||||
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);
|
||||
for (k = 0; k < faces[i].n_verts; k++)
|
||||
{
|
||||
@ -1991,9 +1961,6 @@ BOOL global_testForVAR;
|
||||
// TESTING
|
||||
//
|
||||
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;
|
||||
}
|
||||
}
|
||||
//NSLog(@"%d / %d faces matched at tolerance: %f", n_faces - faces_to_match, n_faces, tolerance);
|
||||
}
|
||||
|
||||
for (i = 0; i < n_faces; i++)
|
||||
{
|
||||
NSString *result;
|
||||
// faces[i].textureFile = [fa[i].textureFile retain];
|
||||
|
||||
strlcpy( (char*)faces[i].textureFileStr255, (char*)fa[i].textureFileStr255, 256);
|
||||
faces[i].texName = 0;
|
||||
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].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];
|
||||
//NSLog(@"face[%d] : %@", i, result);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,16 +31,17 @@ MA 02110-1301, USA.
|
||||
#import "OOOpenGL.h"
|
||||
#import "PlayerEntity.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.GameController"
|
||||
|
||||
|
||||
@implementation GameController
|
||||
|
||||
- (id) 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;
|
||||
//
|
||||
@ -49,13 +50,10 @@ MA 02110-1301, USA.
|
||||
expansionPathsToInclude = nil;
|
||||
pauseSelector = (SEL)nil;
|
||||
pauseTarget = nil;
|
||||
//
|
||||
game_is_paused = NO;
|
||||
|
||||
//
|
||||
debug = 0;
|
||||
// debug = DEBUG_COLLISIONS;
|
||||
//
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -65,14 +63,14 @@ MA 02110-1301, USA.
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:universe];
|
||||
#endif
|
||||
//
|
||||
if (timer) [timer release];
|
||||
if (gameView) [gameView release];
|
||||
if (universe) [universe release];
|
||||
//
|
||||
if (playerFileToLoad) [playerFileToLoad release];
|
||||
if (playerFileDirectory) [playerFileDirectory release];
|
||||
if (expansionPathsToInclude) [expansionPathsToInclude release];
|
||||
//
|
||||
[timer release];
|
||||
[gameView release];
|
||||
[universe release];
|
||||
|
||||
[playerFileToLoad release];
|
||||
[playerFileDirectory release];
|
||||
[expansionPathsToInclude release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@ -96,7 +94,6 @@ MA 02110-1301, USA.
|
||||
NSDictionary *d_mode = [self findDisplayModeForWidth: d_width Height: d_height Refresh: d_refresh];
|
||||
if (d_mode)
|
||||
{
|
||||
// do stuff
|
||||
width = d_width;
|
||||
height = d_height;
|
||||
refresh = d_refresh;
|
||||
@ -121,8 +118,6 @@ MA 02110-1301, USA.
|
||||
{
|
||||
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];
|
||||
if (mode == nil)
|
||||
return NSNotFound;
|
||||
@ -149,7 +144,6 @@ MA 02110-1301, USA.
|
||||
modeRefresh = [[mode objectForKey: (NSString *)kCGDisplayRefreshRate] intValue];
|
||||
if ((modeWidth == d_width)&&(modeHeight == d_height)&&(modeRefresh == d_refresh))
|
||||
{
|
||||
// NSLog(@"Found mode %@", mode);
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
@ -256,8 +250,7 @@ static int _compareModes(id arg1, id arg2, void *context)
|
||||
|
||||
// Fill the popup with the resulting modes
|
||||
modeCount = [displayModes count];
|
||||
|
||||
//NSLog(@"displayModes = %@", displayModes);
|
||||
|
||||
int 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];
|
||||
modeHeight = [[mode objectForKey: (NSString *)kCGDisplayHeight] intValue];
|
||||
modeRefresh = [[mode objectForKey: (NSString *)kCGDisplayRefreshRate] intValue];
|
||||
//NSLog(@"()=> %d x %d at %dHz", modeWidth, modeHeight, modeRefresh);
|
||||
}
|
||||
#else // ifndef GNUSTEP
|
||||
// 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
|
||||
height = 480;
|
||||
refresh = 75;
|
||||
//
|
||||
//NSLog(@"--- loading userdefaults");
|
||||
//
|
||||
|
||||
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
||||
//
|
||||
if ([userDefaults objectForKey:@"display_width"])
|
||||
@ -447,7 +437,7 @@ static int _compareModes(id arg1, id arg2, void *context)
|
||||
{
|
||||
if (playerFileToLoad)
|
||||
{
|
||||
PlayerEntity *player = [universe entityZero];
|
||||
PlayerEntity *player = [PlayerEntity sharedPlayer];
|
||||
[player loadPlayerFromFile:playerFileToLoad];
|
||||
[player setStatus:STATUS_DOCKED];
|
||||
[player setGuiToStatusScreen];
|
||||
@ -465,10 +455,9 @@ static int _compareModes(id arg1, id arg2, void *context)
|
||||
|
||||
- (void) logProgress:(NSString*) message
|
||||
{
|
||||
// NSLog(@"progress: %@", message);
|
||||
#ifndef GNUSTEP
|
||||
[splashProgressTextField setStringValue:message];
|
||||
[splashProgressTextField display]; // **thanks Jens Ayton **
|
||||
[splashProgressTextField display];
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -585,7 +574,6 @@ static int _compareModes(id arg1, id arg2, void *context)
|
||||
}
|
||||
|
||||
originalDisplayMode = (NSDictionary *)CGDisplayCurrentMode(kCGDirectMainDisplay);
|
||||
//NSLog(@"originalDisplayMode = %@", originalDisplayMode);
|
||||
|
||||
// Pixel Format Attributes for the FullScreen NSOpenGLContext
|
||||
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.
|
||||
[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.
|
||||
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_y += mouse_dy;
|
||||
}
|
||||
else
|
||||
past_first_mouse_delta =YES;
|
||||
//NSLog(@".. %d, %d ..",my_mouse_x, my_mouse_y);
|
||||
else past_first_mouse_delta =YES;
|
||||
|
||||
[gameView setVirtualJoystick:(double)my_mouse_x/width :(double)my_mouse_y/height];
|
||||
CGDisplayMoveCursorToPoint(kCGDirectMainDisplay,centerOfScreen);
|
||||
break;
|
||||
@ -800,7 +786,6 @@ static int _compareModes(id arg1, id arg2, void *context)
|
||||
|
||||
- (void) exitFullScreenMode
|
||||
{
|
||||
//NSLog(@"in gameController exitFullScreenMode");
|
||||
stayInFullScreenMode = NO;
|
||||
}
|
||||
|
||||
@ -840,7 +825,6 @@ static int _compareModes(id arg1, id arg2, void *context)
|
||||
|
||||
- (void)windowDidResize:(NSNotification *)aNotification
|
||||
{
|
||||
// NSLog(@"Mwahhahaha");
|
||||
[gameView drawRect:[gameView bounds]];
|
||||
}
|
||||
|
||||
@ -860,7 +844,6 @@ static int _compareModes(id arg1, id arg2, void *context)
|
||||
[[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:&dir_test];
|
||||
if (dir_test)
|
||||
{
|
||||
// NSLog(@"Including expansion pack : %@", filename);
|
||||
if (!expansionPathsToInclude)
|
||||
expansionPathsToInclude = [[NSMutableArray alloc] initWithCapacity: 4]; // retained
|
||||
[expansionPathsToInclude addObject: filename];
|
||||
|
@ -95,7 +95,7 @@ MA 02110-1301, USA.
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -206,8 +206,6 @@ static float volumecount;
|
||||
//
|
||||
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];
|
||||
//
|
||||
return [octreeRepresentation autorelease];
|
||||
|
@ -194,7 +194,7 @@ MA 02110-1301, USA.
|
||||
pixel_text_size = NSMakeSize( csize, csize);
|
||||
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);
|
||||
[self clear];
|
||||
@ -298,11 +298,8 @@ MA 02110-1301, USA.
|
||||
|
||||
- (void) click
|
||||
{
|
||||
#ifdef HAVE_SOUND
|
||||
if ([guiclick isPlaying])
|
||||
[guiclick stop];
|
||||
if ([guiclick isPlaying]) [guiclick stop];
|
||||
[guiclick play];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (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
|
||||
{
|
||||
// NSLog(@"GUI printing text '%@'", str);
|
||||
|
||||
// print a multi-line message
|
||||
//
|
||||
if ([str rangeOfString:@"\n"].location != NSNotFound)
|
||||
@ -716,7 +711,7 @@ MA 02110-1301, USA.
|
||||
GLfloat z1 = [[universe gameView] display_z];
|
||||
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];
|
||||
|
||||
@ -787,7 +782,7 @@ MA 02110-1301, USA.
|
||||
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];
|
||||
|
||||
@ -856,7 +851,7 @@ MA 02110-1301, USA.
|
||||
if (alpha < 0.05)
|
||||
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];
|
||||
|
||||
@ -1047,7 +1042,7 @@ MA 02110-1301, USA.
|
||||
|
||||
- (void) drawStarChart:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha forUniverse:(Universe*)universe
|
||||
{
|
||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
||||
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||
|
||||
if (!player)
|
||||
return;
|
||||
@ -1182,7 +1177,7 @@ MA 02110-1301, USA.
|
||||
|
||||
- (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 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).
|
||||
- (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 cursor_coordinates = [player cursor_coordinates];
|
||||
Random_Seed galaxy_seed = [player galaxy_seed];
|
||||
|
@ -33,6 +33,8 @@ MA 02110-1301, USA.
|
||||
#import "OOColor.h"
|
||||
#import "GuiDisplayGen.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.HeadUpDisplay"
|
||||
|
||||
static const char *toAscii(unsigned inCodePoint);
|
||||
|
||||
@implementation HeadUpDisplay
|
||||
@ -83,8 +85,6 @@ float char_widths[128] = {
|
||||
}
|
||||
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];
|
||||
[self addDial: trumble_dial_info];
|
||||
}
|
||||
@ -240,12 +240,8 @@ GLuint ascii_texture_name;
|
||||
{
|
||||
if ([info objectForKey:SELECTOR_KEY])
|
||||
{
|
||||
//NSLog(@"DEBUG adding Dial for %@",[info objectForKey:SELECTOR_KEY]);
|
||||
SEL _selector = NSSelectorFromString((NSString *)[info objectForKey:SELECTOR_KEY]);
|
||||
if ([self respondsToSelector:_selector])
|
||||
[dialArray addObject:info];
|
||||
//else
|
||||
// NSLog(@"DEBUG HeadUpDisplay does not respond to '%@'",[info objectForKey:SELECTOR_KEY]);
|
||||
if ([self respondsToSelector:_selector]) [dialArray addObject:info];
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
{
|
||||
int i;
|
||||
@ -306,7 +304,6 @@ checkGLErrors(@"HeadUpDisplay after drawDials");
|
||||
|
||||
if ([info objectForKey:SELECTOR_KEY])
|
||||
{
|
||||
//NSLog(@"DEBUG about to '%@'",[info objectForKey:SELECTOR_KEY]);
|
||||
SEL _selector = NSSelectorFromString((NSString *)[info objectForKey:SELECTOR_KEY]);
|
||||
if ([self respondsToSelector:_selector])
|
||||
[self performSelector:_selector withObject:info];
|
||||
@ -622,7 +619,6 @@ static BOOL hostiles;
|
||||
if ((lt == nil)||(!(lt->isShip)))
|
||||
return;
|
||||
ShipEntity* st = (ShipEntity*)lt;
|
||||
// NSLog(@"DEBUG Last Transmitter (%d) == %@ %d", last_transmitter, [st name], [st universal_id]);
|
||||
if ([st message_time] <= 0.0)
|
||||
[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,-rs0); glVertex2f(-rs2,-rs0);
|
||||
|
||||
// NSLog(@"DEBUG rs0 %.3f %.3f",rs0, rs2);
|
||||
|
||||
glEnd();
|
||||
|
||||
// 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};
|
||||
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);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
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) {
|
||||
if (argc == 1) {
|
||||
// PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
// PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
NSString *role = JSValToNSString(cx, argv[0]);
|
||||
int num = [scriptedUniverse countShipsWithRole:role];
|
||||
int num = [[Universe sharedUniverse] countShipsWithRole:role];
|
||||
*rval = INT_TO_JSVAL(num);
|
||||
}
|
||||
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) {
|
||||
if (argc == 2) {
|
||||
// PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
// PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
NSString *role = JSValToNSString(cx, argv[0]);
|
||||
int num = JSVAL_TO_INT(argv[1]);
|
||||
|
||||
while (num--)
|
||||
[scriptedUniverse witchspaceShipWithRole:role];
|
||||
[[Universe sharedUniverse] witchspaceShipWithRole:role];
|
||||
}
|
||||
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) {
|
||||
if (argc == 3) {
|
||||
jsdouble posn;
|
||||
// PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
// PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
NSString *role = JSValToNSString(cx, argv[0]);
|
||||
int num = JSVAL_TO_INT(argv[1]);
|
||||
JS_ValueToNumber(cx, argv[2], &posn);
|
||||
while (num--)
|
||||
[scriptedUniverse addShipWithRole:role nearRouteOneAt:posn];
|
||||
[[Universe sharedUniverse] addShipWithRole:role nearRouteOneAt:posn];
|
||||
}
|
||||
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) {
|
||||
if (argc == 6) {
|
||||
jsdouble x, y, z;
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
NSString *role = JSValToNSString(cx, argv[0]);
|
||||
int num = JSVAL_TO_INT(argv[1]);
|
||||
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) {
|
||||
if (argc == 6) {
|
||||
jsdouble x, y, z;
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
NSString *role = JSValToNSString(cx, argv[0]);
|
||||
int num = JSVAL_TO_INT(argv[1]);
|
||||
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) {
|
||||
if (argc == 7) {
|
||||
jsdouble x, y, z;
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
NSString *role = JSValToNSString(cx, argv[0]);
|
||||
int num = JSVAL_TO_INT(argv[1]);
|
||||
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) {
|
||||
if (argc == 2) {
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
NSString *role = JSValToNSString(cx, argv[0]);
|
||||
int num = JSVAL_TO_INT(argv[1]);
|
||||
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) {
|
||||
if (argc == 1) {
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
[playerEntity spawnShip:JSValToNSString(cx, argv[0])];
|
||||
}
|
||||
return JS_TRUE;
|
||||
@ -154,7 +154,7 @@ JSBool UniverseAddMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
|
||||
ok = JS_ValueToInt32(cx, argv[1], &count);
|
||||
NSString *str = JSValToNSString(cx, argv[0]);
|
||||
[scriptedUniverse addMessage: str forCount:(int)count];
|
||||
[[Universe sharedUniverse] addMessage: str forCount:(int)count];
|
||||
//[str dealloc];
|
||||
return JS_TRUE;
|
||||
}
|
||||
@ -167,7 +167,7 @@ JSBool UniverseAddCommsMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
||||
|
||||
ok = JS_ValueToInt32(cx, argv[1], &count);
|
||||
NSString *str = JSValToNSString(cx, argv[0]);
|
||||
[scriptedUniverse addCommsMessage: str forCount:(int)count];
|
||||
[[Universe sharedUniverse] addCommsMessage: str forCount:(int)count];
|
||||
//[str dealloc];
|
||||
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) {
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
|
||||
switch (JSVAL_TO_INT(id)) {
|
||||
case UNI_PLAYER_ENTITY: {
|
||||
|
@ -23,6 +23,8 @@ MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#import "OXPScript.h"
|
||||
#import "OOLogging.h"
|
||||
|
||||
|
||||
OXPScript *currentOXPScript;
|
||||
|
||||
@ -42,8 +44,7 @@ extern NSString *JSValToNSString(JSContext *cx, jsval val);
|
||||
// ...
|
||||
|
||||
self = [super init];
|
||||
|
||||
//NSLog(@"Attempting to load script: %@", filename);
|
||||
|
||||
obj = JS_NewObject(context, &OXP_class, 0x00, JS_GetGlobalObject(context));
|
||||
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;
|
||||
JSBool ok;
|
||||
JSScript *script = JS_CompileFile(context, obj, [filename cString]);
|
||||
if (script != 0x00) {
|
||||
if (script != NULL) {
|
||||
ok = JS_ExecuteScript(context, obj, script, &rval);
|
||||
if (ok) {
|
||||
ok = JS_GetProperty(context, obj, "Name", &rval);
|
||||
if (ok) {
|
||||
name = JSValToNSString(context, rval);
|
||||
//NSLog(@"Found name property: %@", name);
|
||||
} else {
|
||||
// No name given in the script so use the filename
|
||||
name = [NSString stringWithString:filename];
|
||||
//NSLog(@"No name property, defaulting to : %@", name);
|
||||
}
|
||||
ok = JS_GetProperty(context, obj, "Description", &rval);
|
||||
if (ok) {
|
||||
description = JSValToNSString(context, rval);
|
||||
//NSLog(@"Found description : %@", description);
|
||||
} else {
|
||||
description = @"";
|
||||
//NSLog(@"No description");
|
||||
}
|
||||
ok = JS_GetProperty(context, obj, "Version", &rval);
|
||||
if (ok) {
|
||||
version = JSValToNSString(context, rval);
|
||||
//NSLog(@"Found version: %@", version);
|
||||
} else {
|
||||
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.
|
||||
@ -111,8 +106,8 @@ extern NSString *JSValToNSString(JSContext *cx, jsval val);
|
||||
}
|
||||
JS_DestroyScript(context, script);
|
||||
} else {
|
||||
NSLog(@"Script compilation failed");
|
||||
[super dealloc];
|
||||
OOLog(@"script.javascript.compile.failed", @"Script compilation failed");
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,9 @@ MA 02110-1301, USA.
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
Universe *scriptedUniverse;
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.JSScriptEngine"
|
||||
|
||||
|
||||
JSObject *xglob, *universeObj, *systemObj, *playerObj, *missionObj;
|
||||
|
||||
extern OXPScript *currentOXPScript;
|
||||
@ -66,7 +68,7 @@ JSClass MissionVars_class = {
|
||||
};
|
||||
|
||||
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];
|
||||
|
||||
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) {
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
NSDictionary *mission_variables = [playerEntity mission_variables];
|
||||
|
||||
if (JSVAL_IS_STRING(id)) {
|
||||
@ -156,7 +158,7 @@ JSFunctionSpec Global_funcs[] = {
|
||||
|
||||
JSBool GlobalListenForKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||
NSString *key = JSValToNSString(cx, argv[0]);
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
[playerEntity mapKey:key toOXP:currentOXPScript];
|
||||
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;
|
||||
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
|
||||
switch (JSVAL_TO_INT(id)) {
|
||||
case GLOBAL_GALAXY_NUMBER:
|
||||
@ -269,7 +271,7 @@ JSFunctionSpec Player_funcs[] = {
|
||||
|
||||
JSBool PlayerAwardCargo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||
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])];
|
||||
[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) {
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
[playerEntity removeAllCargo];
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool PlayerUseSpecialCargo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||
if (argc == 1) {
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
[playerEntity useSpecialCargo:JSValToNSString(cx, argv[0])];
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
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])) {
|
||||
JSString *jskey = JS_ValueToString(cx, argv[0]);
|
||||
[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) {
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
|
||||
JSString *jskey = JS_ValueToString(cx, argv[0]);
|
||||
[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) {
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
|
||||
JSString *jskey = JS_ValueToString(cx, argv[0]);
|
||||
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) {
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
[playerEntity launchFromStation];
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool PlayerCall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
if (argc > 0) {
|
||||
NSString *selectorString = JSValToNSString(cx, argv[0]);
|
||||
// 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;
|
||||
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
|
||||
switch (JSVAL_TO_INT(id)) {
|
||||
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;
|
||||
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
|
||||
switch (JSVAL_TO_INT(id)) {
|
||||
case PE_SCORE:
|
||||
@ -469,7 +471,7 @@ JSFunctionSpec System_funcs[] = {
|
||||
};
|
||||
|
||||
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])) {
|
||||
NSString *key = JSValToNSString(cx, argv[0]);
|
||||
[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) {
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
|
||||
NSString *key = JSValToNSString(cx, argv[0]);
|
||||
[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) {
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
[playerEntity sendAllShipsAway];
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool SystemSetSunNova(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
if (argc > 0) {
|
||||
NSString *key = JSValToNSString(cx, argv[0]);
|
||||
[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;
|
||||
|
||||
NSString *str;
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
if (!equal_seeds(currentSystem, playerEntity->system_seed)) {
|
||||
//fprintf(stdout, "Current system has changed, regenerating local copy of planetinfo\r\n");
|
||||
currentSystem = playerEntity->system_seed;
|
||||
if (planetinfo)
|
||||
[planetinfo release];
|
||||
|
||||
planetinfo = [[scriptedUniverse generateSystemData:currentSystem] retain];
|
||||
planetinfo = [[[Universe sharedUniverse] generateSystemData:currentSystem] retain];
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
if (!equal_seeds(currentSystem, playerEntity->system_seed)) {
|
||||
//fprintf(stdout, "Current system has changed, regenerating local copy of planetinfo\r\n");
|
||||
currentSystem = playerEntity->system_seed;
|
||||
if (planetinfo)
|
||||
[planetinfo release];
|
||||
|
||||
planetinfo = [[scriptedUniverse generateSystemData:currentSystem] retain];
|
||||
planetinfo = [[[Universe sharedUniverse] generateSystemData:currentSystem] retain];
|
||||
}
|
||||
int gn = [[playerEntity galaxy_number] intValue];
|
||||
int pn = [[playerEntity planet_number] intValue];
|
||||
|
||||
switch (JSVAL_TO_INT(id)) {
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
/*
|
||||
case SYS_GOING_NOVA:
|
||||
@ -618,23 +620,23 @@ JSBool SystemSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
|
||||
break;
|
||||
*/
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
|
||||
NSString *str;
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
|
||||
switch (JSVAL_TO_INT(id)) {
|
||||
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;
|
||||
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
|
||||
switch (JSVAL_TO_INT(id)) {
|
||||
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) {
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
[playerEntity setGuiToMissionScreen];
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
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])) {
|
||||
JSString *jskey = JS_ValueToString(cx, argv[0]);
|
||||
[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) {
|
||||
PlayerEntity *playerEntity = (PlayerEntity *)[scriptedUniverse entityZero];
|
||||
PlayerEntity *playerEntity = [PlayerEntity sharedPlayer];
|
||||
[playerEntity resetMissionChoice];
|
||||
return JS_TRUE;
|
||||
}
|
||||
@ -795,7 +797,6 @@ void reportJSError(JSContext *cx, const char *message, JSErrorReport *report) {
|
||||
- (id) initWithUniverse: (Universe *)universe
|
||||
{
|
||||
self = [super init];
|
||||
scriptedUniverse = universe;
|
||||
|
||||
/*set up global JS variables, including global and custom objects */
|
||||
|
||||
|
@ -31,6 +31,9 @@ MA 02110-1301, USA.
|
||||
#import "ResourceManager.h"
|
||||
#import "OOPListParsing.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.NSFileManagerOOExtensions"
|
||||
|
||||
|
||||
@implementation NSFileManager (OOExtensions)
|
||||
|
||||
- (NSArray *)commanderContents
|
||||
@ -92,7 +95,6 @@ MA 02110-1301, USA.
|
||||
// check file extension
|
||||
if (![[path pathExtension] isEqual:@"oolite-save"])
|
||||
{
|
||||
// NSLog(@">>>> %@ is not a saved game", path);
|
||||
[contents removeObjectAtIndex: i--];
|
||||
continue;
|
||||
}
|
||||
|
@ -106,7 +106,6 @@ MA 02110-1301, USA.
|
||||
return castmember;
|
||||
else
|
||||
{
|
||||
// NSLog(@"DEBUG ***** couldn't cast character in role '%@'", c_role);
|
||||
return castmember;
|
||||
}
|
||||
}
|
||||
@ -140,7 +139,7 @@ MA 02110-1301, USA.
|
||||
// save random seeds for restoration later
|
||||
RNG_Seed saved_seed = currentRandomSeed();
|
||||
// set RNG to character seed
|
||||
seed_for_planet_description( genSeed);
|
||||
seed_for_planet_description(genSeed);
|
||||
|
||||
// determine the planet of origin
|
||||
NSDictionary* originInfo = [universe generateSystemData: originSystemSeed];
|
||||
@ -152,16 +151,16 @@ MA 02110-1301, USA.
|
||||
NSString* speciesString = [self species];
|
||||
|
||||
// determine the character's name
|
||||
seed_RNG_only_for_planet_description( genSeed);
|
||||
seed_RNG_only_for_planet_description(genSeed);
|
||||
NSString* genName;
|
||||
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
|
||||
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 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]];
|
||||
|
||||
// determine legal_status for a completely random character
|
||||
@ -233,11 +232,7 @@ MA 02110-1301, USA.
|
||||
break;
|
||||
}
|
||||
[self setLongDescription:
|
||||
[universe expandDescription:
|
||||
[NSString stringWithFormat:@"%@ is a [21] %@ from %@", [self name], legalDesc, [self planetOfOrigin]]
|
||||
forSystem: genSeed]];
|
||||
|
||||
// NSLog(@">>>>> %@", self);
|
||||
ExpandDescriptionForSeed([NSString stringWithFormat:@"%@ is a [21] %@ from %@", [self name], legalDesc, [self planetOfOrigin]], genSeed)];
|
||||
|
||||
specialSetUpDone = YES;
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ MA 02110-1301, USA.
|
||||
#import "Universe.h"
|
||||
#import "AI.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.OOInstinct"
|
||||
|
||||
|
||||
@implementation OOInstinct
|
||||
|
||||
|
@ -141,13 +141,14 @@ BOOL OOLogWillDisplayMessagesInClass(NSString *inMessageClass)
|
||||
|
||||
// Look for cached value
|
||||
value = [sDerivedSettingsCache objectForKey:inMessageClass];
|
||||
if (__builtin_expect(value == nil, 0))
|
||||
if (EXPECT_NOT(value == nil))
|
||||
{
|
||||
// No cached value.
|
||||
value = ResolveDisplaySetting(inMessageClass);
|
||||
|
||||
if (value != nil)
|
||||
{
|
||||
if (EXPECT_NOT(sDerivedSettingsCache == nil)) sDerivedSettingsCache = [[NSMutableDictionary alloc] init];
|
||||
[sDerivedSettingsCache setObject:value forKey:inMessageClass];
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ NSString *StringFromPoint(NSPoint point);
|
||||
NSPoint PointFromString(NSString *xyString);
|
||||
|
||||
Random_Seed RandomSeedFromString(NSString *abcdefString);
|
||||
NSString *StringFromRandomSeed(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 *ExpandDescriptionsWithLocalsForCurrentSystem(NSString *text, NSDictionary *locals);
|
||||
|
||||
NSString *DescriptionForSystem(Random_Seed seed);
|
||||
NSString *DescriptionForCurrentSystem(void);
|
||||
|
||||
// target and localVariables are optional; target will default to the player.
|
||||
NSString *ReplaceVariables(NSString *string, Entity *target, NSDictionary *localVariables);
|
||||
|
||||
NSString *RandomDigrams(void);
|
||||
|
||||
|
||||
@interface NSString (OOUtilities)
|
||||
|
||||
@ -64,3 +70,15 @@ NSString *ReplaceVariables(NSString *string, Entity *target, NSDictionary *local
|
||||
- (BOOL)pathHasExtensionInArray:(NSArray *)extensions;
|
||||
|
||||
@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)
|
||||
{
|
||||
// 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
|
||||
{
|
||||
old_desc = result;
|
||||
result = ExpandDescriptionsWithLocalsForSystemSeed(text, seed, nil);
|
||||
result = ExpandDescriptionsWithLocalsForSystemSeed(result, seed, nil);
|
||||
} while (--stack_check && ![result isEqual:old_desc]);
|
||||
|
||||
if (!stack_check)
|
||||
@ -262,7 +268,7 @@ NSString *ExpandDescriptionForSeed(NSString *text, Random_Seed seed)
|
||||
#if 0
|
||||
// What's the point of breaking? A bad description is better than falling to pieces.
|
||||
[NSException raise:OOLITE_EXCEPTION_LOOPING
|
||||
format:@"script stack overflow for expandDescription: \"%@\"", text];
|
||||
format:@"script stack overflow for ExpandDescriptionForSeed(\"%@\")", text];
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -355,7 +361,7 @@ NSString *ExpandDescriptionsWithLocalsForSystemSeed(NSString *text, Random_Seed
|
||||
options:NSLiteralSearch range:NSMakeRange(0, [partial length])];
|
||||
|
||||
[partial replaceOccurrencesOfString:@"%R"
|
||||
withString:[universe getRandomDigrams]
|
||||
withString:RandomDigrams()
|
||||
options:NSLiteralSearch range:NSMakeRange(0, [partial length])];
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
|
||||
- (BOOL)pathHasExtension:(NSString *)extension
|
||||
@ -435,3 +469,60 @@ NSString *ReplaceVariables(NSString *string, Entity *target, NSDictionary *local
|
||||
}
|
||||
|
||||
@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 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);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
@ -614,10 +613,9 @@ MA 02110-1301, USA.
|
||||
{
|
||||
// eaten all of this cargo!
|
||||
Universe* uni = [player universe];
|
||||
Random_Seed seed = [uni systemSeed];
|
||||
NSString* ms = [NSString stringWithFormat:[uni expandDescription:@"[trumbles-eat-@]" forSystem:seed],
|
||||
NSString* ms = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[trumbles-eat-@]"),
|
||||
[uni nameForCommodity:[selectedCargopod getCommodityType]]];
|
||||
// NSLog(ms);
|
||||
|
||||
[uni addMessage: ms forCount: 4.5];
|
||||
[cargopods removeObject:selectedCargopod];
|
||||
trumbleAppetiteAccumulator -= 10.0;
|
||||
@ -625,7 +623,6 @@ MA 02110-1301, USA.
|
||||
// consider breeding - must be full grown and happy
|
||||
if ((size > 0.95)&&(discomfort < 0.25))
|
||||
{
|
||||
// NSLog(@"Trumbles breeding!");
|
||||
readyToSpawn = YES;
|
||||
}
|
||||
}
|
||||
@ -875,7 +872,6 @@ MA 02110-1301, USA.
|
||||
if (animationTime > animationDuration)
|
||||
{
|
||||
// kaputnik!
|
||||
// NSLog(@"TRUMBLE DIES!");
|
||||
[player removeTrumble:self];
|
||||
}
|
||||
}
|
||||
|
@ -63,9 +63,9 @@ OOINLINE GLfloat magnitude(Vector vec) INLINE_CONST_FUNC;
|
||||
OOINLINE GLfloat fast_magnitude(Vector vec) INLINE_CONST_FUNC;
|
||||
|
||||
/* Normalize vector */
|
||||
OOINLINE Vector vector_normal(Vector vec) CONST_FUNC;
|
||||
OOINLINE Vector fast_vector_normal(Vector vec) CONST_FUNC;
|
||||
OOINLINE Vector unit_vector(const Vector *vec) NONNULL_FUNC CONST_FUNC;
|
||||
OOINLINE Vector vector_normal(Vector vec) INLINE_CONST_FUNC;
|
||||
OOINLINE Vector fast_vector_normal(Vector vec) INLINE_CONST_FUNC;
|
||||
OOINLINE Vector unit_vector(const Vector *vec) NONNULL_FUNC INLINE_CONST_FUNC;
|
||||
|
||||
/* Square of distance between vectors */
|
||||
OOINLINE GLfloat distance2(Vector v1, Vector v2) INLINE_CONST_FUNC;
|
||||
|
@ -28,6 +28,9 @@ MA 02110-1301, USA.
|
||||
#import "OOOpenGL.h"
|
||||
#import "legacy_random.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.Octree"
|
||||
|
||||
|
||||
@implementation Octree
|
||||
|
||||
- (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]];
|
||||
|
||||
[image release];
|
||||
|
||||
//
|
||||
//NSLog(@"%@ message sprite [ %f, %f ]", str, [image size].width, [image size].height);
|
||||
//
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -261,8 +257,7 @@ MA 02110-1301, USA.
|
||||
|
||||
if ((textureRect.size.width != textureSize.width)||(textureRect.size.height != textureSize.height))
|
||||
{
|
||||
NSLog(@"***** ERROR! replacement texture isn't the same size as original texture");
|
||||
NSLog(@"***** cropRect %f x %f textureSize %f x %f",textureRect.size.width, textureRect.size.height, textureSize.width, textureSize.height);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -383,7 +378,6 @@ enum
|
||||
|
||||
SDL_Surface *texSurface = [texImage surface];
|
||||
SDL_SetAlpha(texSurface, 0, SDL_ALPHA_OPAQUE);
|
||||
//NSLog(@"makeTextureFromSurface: texImage dimensions: %d x %d", texSurface->w, texSurface->h);
|
||||
|
||||
size = spriteSize;
|
||||
textureCropRect = cropRect;
|
||||
@ -397,42 +391,24 @@ enum
|
||||
textureCropRect.origin= NSMakePoint(0,0);
|
||||
|
||||
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);
|
||||
|
||||
//[image lockFocus];
|
||||
//[[OOColor clearColor] set];
|
||||
//NSRectFill(textureRect);
|
||||
|
||||
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;
|
||||
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;
|
||||
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
|
||||
textureCropRect.size.width /= textureRect.size.width;
|
||||
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);
|
||||
//memcpy(buffer, surface->pixels, n_bytes);
|
||||
|
||||
if (textureData)
|
||||
[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];
|
||||
|
||||
SDL_UnlockSurface(surface);
|
||||
|
@ -34,6 +34,8 @@ MA 02110-1301, USA.
|
||||
#import "PlayerEntity.h"
|
||||
#import "PlanetEntity.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.ParticleEntity"
|
||||
|
||||
|
||||
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_FLASH :
|
||||
{
|
||||
Entity* player = [universe entityZero];
|
||||
PlayerEntity *player = [PlayerEntity sharedPlayer];
|
||||
if (!texName)
|
||||
[self initialiseTexture: textureNameString];
|
||||
if (player)
|
||||
@ -1037,7 +1039,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
- (void) updateEnergyMine:(double) delta_t
|
||||
{
|
||||
// new billboard routine (working at last!)
|
||||
Entity* player = [universe entityZero];
|
||||
PlayerEntity *player = [PlayerEntity sharedPlayer];
|
||||
Vector v0 = position;
|
||||
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
|
||||
@ -1606,7 +1608,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
glPushMatrix();
|
||||
// position and orientation is absolute
|
||||
glTranslatef( abspos.x, abspos.y, abspos.z);
|
||||
glMultMatrixf([[universe entityZero] drawRotationMatrix]);
|
||||
glMultMatrixf([[PlayerEntity sharedPlayer] drawRotationMatrix]);
|
||||
|
||||
[self drawEntity:immediate :translucent];
|
||||
|
||||
@ -1707,7 +1709,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
|
||||
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 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;
|
||||
@ -1960,7 +1962,7 @@ void drawQuadForView(Universe* universe, GLfloat x, GLfloat y, GLfloat z, GLfloa
|
||||
break;
|
||||
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 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);
|
||||
|
@ -35,6 +35,8 @@ MA 02110-1301, USA.
|
||||
#import "OOStringParsing.h"
|
||||
#import "PlayerEntity.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.PlanetEntity"
|
||||
|
||||
|
||||
#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
|
||||
@ -257,8 +259,7 @@ void setUpSinTable()
|
||||
self = [super init];
|
||||
//
|
||||
percent_land = 3 + (gen_rnd_number() & 31)+(gen_rnd_number() & 31);
|
||||
//NSLog(@"Atmosphere is %d percent clear.",percent_land);
|
||||
//
|
||||
|
||||
polar_color_factor = 1.0;
|
||||
//
|
||||
amb_land[0] = gen_rnd_number() / 256.0;
|
||||
@ -336,18 +337,14 @@ void setUpSinTable()
|
||||
[self setModel:(isTextured)? @"icostextured.dat" : @"icosahedron.dat"];
|
||||
//
|
||||
[self rescaleTo:1.0];
|
||||
|
||||
// NSLog(@"DEBUG atmosphere testing [PlanetEntity initialiseBaseVertexArray]");
|
||||
|
||||
[self initialiseBaseVertexArray];
|
||||
|
||||
// NSLog(@"DEBUG atmosphere testing [PlanetEntity initialiseBaseTerrainArray:%d]", percent_land);
|
||||
|
||||
[self initialiseBaseTerrainArray:percent_land];
|
||||
|
||||
// NSLog(@"DEBUG atmosphere painting %d vertices", next_free_vertex);
|
||||
|
||||
for (i = 0; i < next_free_vertex; i++)
|
||||
[self paintVertex:i :planet_seed];
|
||||
|
||||
// NSLog(@"DEBUG atmosphere scaling %d vertices", next_free_vertex);
|
||||
|
||||
[self scaleVertices];
|
||||
|
||||
// set speed of rotation
|
||||
@ -428,7 +425,7 @@ void setUpSinTable()
|
||||
NSMutableDictionary* planetinfo = [NSMutableDictionary dictionaryWithDictionary:[uni generateSystemData:p_seed]];
|
||||
int radius_km = [(NSNumber *)[planetinfo objectForKey:KEY_RADIUS] 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"])
|
||||
{
|
||||
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 = 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 = radius_km * 10.0; // scale down by a factor of 100 !
|
||||
//
|
||||
@ -474,8 +469,7 @@ void setUpSinTable()
|
||||
|
||||
// save the current random number generator seed
|
||||
RNG_Seed saved_seed = currentRandomSeed();
|
||||
|
||||
//NSLog(@"Planet surface is %d percent land.",percent_land);
|
||||
|
||||
for (i = 0; i < n_vertices; i++)
|
||||
{
|
||||
if (gen_rnd_number() < 256 * percent_land / 100)
|
||||
@ -560,19 +554,15 @@ void setUpSinTable()
|
||||
shader_program = nil;
|
||||
#endif
|
||||
}
|
||||
|
||||
// NSLog(@"DEBUG testing [PlanetEntity initialiseBaseVertexArray]");
|
||||
|
||||
[self initialiseBaseVertexArray];
|
||||
|
||||
// NSLog(@"DEBUG testing [PlanetEntity initialiseBaseTerrainArray:%d]", percent_land);
|
||||
|
||||
setRandomSeed(saved_seed);
|
||||
[self initialiseBaseTerrainArray:percent_land];
|
||||
|
||||
// NSLog(@"DEBUG painting %d vertices", next_free_vertex);
|
||||
|
||||
for (i = 0; i < next_free_vertex; i++)
|
||||
[self paintVertex:i :planet_seed];
|
||||
|
||||
// NSLog(@"DEBUG scaling %d vertices", next_free_vertex);
|
||||
|
||||
[self scaleVertices];
|
||||
|
||||
// set speed of rotation
|
||||
@ -617,8 +607,6 @@ void setUpSinTable()
|
||||
last_launch_time = 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
|
||||
//
|
||||
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
|
||||
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 !
|
||||
//
|
||||
scan_class = CLASS_NO_DRAW;
|
||||
@ -774,8 +760,7 @@ void setUpSinTable()
|
||||
|
||||
// save the current random number generator seed
|
||||
RNG_Seed saved_seed = currentRandomSeed();
|
||||
|
||||
//NSLog(@"Planet surface is %d percent land.",percent_land);
|
||||
|
||||
for (i = 0; i < n_vertices; i++)
|
||||
{
|
||||
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[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;
|
||||
|
||||
// NSLog(@"DEBUG testing [PlanetEntity initialiseBaseVertexArray]");
|
||||
|
||||
[self initialiseBaseVertexArray];
|
||||
|
||||
// NSLog(@"DEBUG testing [PlanetEntity initialiseBaseTerrainArray:%d]", percent_land);
|
||||
|
||||
setRandomSeed(saved_seed);
|
||||
[self initialiseBaseTerrainArray:percent_land];
|
||||
|
||||
// NSLog(@"DEBUG painting %d vertices", next_free_vertex);
|
||||
|
||||
for (i = 0; i < next_free_vertex; i++)
|
||||
[self paintVertex:i :planet_seed];
|
||||
|
||||
// NSLog(@"DEBUG scaling %d vertices", next_free_vertex);
|
||||
|
||||
[self scaleVertices];
|
||||
|
||||
// set speed of rotation
|
||||
@ -923,8 +904,6 @@ void setUpSinTable()
|
||||
shuttle_launch_interval = 3600.0 / shuttles_on_ground; // all are launched in an hour
|
||||
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 !
|
||||
//
|
||||
scan_class = CLASS_NO_DRAW;
|
||||
@ -954,8 +933,7 @@ void setUpSinTable()
|
||||
|
||||
// save the current random number generator seed
|
||||
RNG_Seed saved_seed = currentRandomSeed();
|
||||
|
||||
//NSLog(@"Planet surface is %d percent land.",percent_land);
|
||||
|
||||
for (i = 0; i < n_vertices; i++)
|
||||
{
|
||||
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[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;
|
||||
|
||||
// NSLog(@"DEBUG testing [PlanetEntity initialiseBaseVertexArray]");
|
||||
|
||||
[self initialiseBaseVertexArray];
|
||||
|
||||
// NSLog(@"DEBUG testing [PlanetEntity initialiseBaseTerrainArray:%d]", percent_land);
|
||||
|
||||
setRandomSeed(saved_seed);
|
||||
[self initialiseBaseTerrainArray:percent_land];
|
||||
|
||||
// NSLog(@"DEBUG painting %d vertices", next_free_vertex);
|
||||
|
||||
for (i = 0; i < next_free_vertex; i++)
|
||||
[self paintVertex:i :planet_seed];
|
||||
|
||||
// NSLog(@"DEBUG scaling %d vertices", next_free_vertex);
|
||||
|
||||
[self scaleVertices];
|
||||
|
||||
// set speed of rotation
|
||||
@ -1190,7 +1164,7 @@ void setUpSinTable()
|
||||
case PLANET_TYPE_SUN :
|
||||
{
|
||||
// new billboard routine (working at last!)
|
||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
||||
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||
Vector v0 = position;
|
||||
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
|
||||
@ -1307,7 +1281,6 @@ void setUpSinTable()
|
||||
double old_collision_radius = collision_radius;
|
||||
[super setModel:modelName];
|
||||
collision_radius = old_collision_radius; // preserve the radius
|
||||
//NSLog(@"Planet collision radius preserved!");
|
||||
}
|
||||
|
||||
|
||||
@ -1496,7 +1469,6 @@ void setUpSinTable()
|
||||
displayListNames[subdivideLevel] = glGenLists(1);
|
||||
if (displayListNames[subdivideLevel] != 0) // sanity check
|
||||
{
|
||||
//NSLog(@"Generating planet data for subdivide %d",subdivideLevel);
|
||||
glNewList(displayListNames[subdivideLevel], GL_COMPILE);
|
||||
//
|
||||
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 z0 = c * r / z;
|
||||
|
||||
// NSLog(@"DEBUG r1 = %.4f z1 = %.4f r0 = %.4f z0 = %.4f", r1, z1, r0, z0);
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
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 z0 = c * r / z;
|
||||
|
||||
// NSLog(@"DEBUG r1 = %.4f z1 = %.4f r0 = %.4f z0 = %.4f", r1, z1, r0, z0);
|
||||
|
||||
GLfloat rv0, rv1, rv2;
|
||||
|
||||
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.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 crew])
|
||||
@ -1881,8 +1849,6 @@ void drawActiveCorona (double inner_radius, double outer_radius, int step, doubl
|
||||
[universe addEntity:shuttle_ship];
|
||||
[[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];
|
||||
}
|
||||
}
|
||||
@ -1912,11 +1878,6 @@ static BOOL last_one_was_textured;
|
||||
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)
|
||||
{
|
||||
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;
|
||||
triangle_start[newlevel] = triangle_start[sublevel] + n_triangles[sublevel] * 3;
|
||||
n_triangles[newlevel] = n_triangles[sublevel] * 4;
|
||||
//
|
||||
|
||||
// NSLog(@"Building new level of subdivision - level %d.", newlevel);
|
||||
|
||||
int 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;
|
||||
|
||||
}
|
||||
|
||||
// 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
|
||||
//
|
||||
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] = 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)
|
||||
{
|
||||
//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.
|
||||
- (void) reloadTextures
|
||||
{
|
||||
//NSLog(@"PlanetEntity::reloadTextures called, clearing planet draw lists and calling super");
|
||||
|
||||
int i;
|
||||
// Clear out the planet's various detail level display lists.
|
||||
for (i = 0; i < MAX_SUBDIVIDE; i++)
|
||||
|
@ -57,6 +57,9 @@ MA 02110-1301, USA.
|
||||
#import "PlayerEntityStickMapper.h"
|
||||
#endif
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.PlayerEntity"
|
||||
|
||||
|
||||
// 10m/s forward drift
|
||||
#define OG_ELITE_FORWARD_DRIFT 10.0f
|
||||
|
||||
@ -270,8 +273,6 @@ static PlayerEntity *sSharedPlayer = nil;
|
||||
co_type = [(ShipEntity *)[cargoArray objectAtIndex:i] getCommodityType];
|
||||
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];
|
||||
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
|
||||
int quantity = [(NSNumber *)[commodityInfo objectAtIndex:MARKET_QUANTITY] intValue];
|
||||
int units = [universe unitsForCommodity:i];
|
||||
// NSLog(@"DEBUG Commodity index:%d %@ units:%d", i, [commodityInfo objectAtIndex:MARKET_NAME], units);
|
||||
if (quantity > 0)
|
||||
{
|
||||
//NSLog(@"loading containers with %@",[universe describeCommodity:i amount:quantity]);
|
||||
|
||||
if (units == UNITS_TONS)
|
||||
{
|
||||
// put each ton in a separate container
|
||||
for (j = 0; j < quantity; j++)
|
||||
{
|
||||
ShipEntity* container = [universe getShipWithRole:@"1t-cargopod"];
|
||||
ShipEntity* container = [universe newShipWithRole:@"1t-cargopod"];
|
||||
if (container)
|
||||
{
|
||||
[container setUniverse:universe];
|
||||
@ -326,11 +324,8 @@ static PlayerEntity *sSharedPlayer = nil;
|
||||
{
|
||||
NSLog(@"***** ERROR couldn't find a container while trying to [PlayerEntity loadCargoPods] *****");
|
||||
// throw an exception here...
|
||||
NSException* myException = [NSException
|
||||
exceptionWithName: OOLITE_EXCEPTION_FATAL
|
||||
reason:@"[PlayerEntity loadCargoPods] failed to create a container for cargo with role 'cargopod'"
|
||||
userInfo:nil];
|
||||
[myException raise];
|
||||
[NSException raise:OOLITE_EXCEPTION_FATAL
|
||||
format:@"[PlayerEntity loadCargoPods] failed to create a container for cargo with role 'cargopod'"];
|
||||
}
|
||||
}
|
||||
// zero this commodity
|
||||
@ -537,11 +532,6 @@ static PlayerEntity *sSharedPlayer = nil;
|
||||
//set 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]];
|
||||
}
|
||||
|
||||
@ -879,7 +869,7 @@ static PlayerEntity *sSharedPlayer = nil;
|
||||
NSString* missile_desc = (NSString*)[missile_roles objectAtIndex:i];
|
||||
if (![missile_desc isEqual:@"NONE"])
|
||||
{
|
||||
ShipEntity* amiss = [universe getShipWithRole:missile_desc];
|
||||
ShipEntity* amiss = [universe newShipWithRole:missile_desc];
|
||||
if (amiss)
|
||||
missile_entity[i] = amiss; // retain count = 1
|
||||
else
|
||||
@ -898,7 +888,7 @@ static PlayerEntity *sSharedPlayer = nil;
|
||||
else
|
||||
{
|
||||
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.
|
||||
}
|
||||
while ((missiles > 0)&&(missile_entity[active_missile] == nil))
|
||||
@ -1168,7 +1158,7 @@ static PlayerEntity *sSharedPlayer = nil;
|
||||
{
|
||||
if (missile_entity[i])
|
||||
[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];
|
||||
|
||||
@ -1225,8 +1215,6 @@ static PlayerEntity *sSharedPlayer = nil;
|
||||
if (shipinfoDictionary)
|
||||
[shipinfoDictionary release];
|
||||
shipinfoDictionary = [[NSDictionary alloc] initWithDictionary:dict]; // retained
|
||||
|
||||
//NSLog(@"DEBUG Playerentity - setUpShipFromDictionary:(NSDictionary *) dict");
|
||||
|
||||
// set things from dictionary from here out
|
||||
|
||||
@ -1337,13 +1325,11 @@ static PlayerEntity *sSharedPlayer = nil;
|
||||
|
||||
if ([dict objectForKey:@"max_missiles"])
|
||||
{
|
||||
// NSLog(@"DEBUG setting max_missiles %@",[dict objectForKey:@"max_missiles"]);
|
||||
max_missiles = [(NSNumber *)[dict objectForKey:@"max_missiles"] intValue];
|
||||
}
|
||||
|
||||
if ([dict objectForKey:@"hud"])
|
||||
{
|
||||
//NSLog(@"DEBUG setting hud %@",[dict objectForKey:@"hud"]);
|
||||
NSString *hud_desc = (NSString *)[dict objectForKey:@"hud"];
|
||||
NSDictionary *huddict = [ResourceManager dictionaryFromFilesNamed:hud_desc inFolder:@"Config" andMerge:YES];
|
||||
if (huddict)
|
||||
@ -1366,7 +1352,7 @@ static PlayerEntity *sSharedPlayer = nil;
|
||||
missile_entity[i] = nil;
|
||||
}
|
||||
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];
|
||||
|
||||
|
||||
@ -1458,7 +1444,7 @@ static PlayerEntity *sSharedPlayer = nil;
|
||||
{
|
||||
quaternion_normalise(&sub_q);
|
||||
|
||||
subent = [universe getShip:subdesc]; // retained
|
||||
subent = [universe newShipWithName:subdesc]; // retained
|
||||
|
||||
if (subent)
|
||||
{
|
||||
@ -1545,14 +1531,10 @@ static PlayerEntity *sSharedPlayer = nil;
|
||||
|
||||
- (void) warnAboutHostiles
|
||||
{
|
||||
// make a warningSound
|
||||
// NSLog(@"player warned about hostiles!");
|
||||
#ifdef HAVE_SOUND
|
||||
if (![warningSound isPlaying])
|
||||
[warningSound play];
|
||||
#endif
|
||||
[self playHostileWarning];
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) canCollide
|
||||
{
|
||||
switch (status)
|
||||
@ -1742,9 +1724,9 @@ double scoopSoundPlayTime = 0.0;
|
||||
witchspaceCountdown -= delta_t;
|
||||
if (witchspaceCountdown < 0.0) witchspaceCountdown = 0.0;
|
||||
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
|
||||
[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)
|
||||
{
|
||||
BOOL go = YES;
|
||||
@ -1754,7 +1736,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
if (blocker)
|
||||
{
|
||||
[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-@]"])
|
||||
[witchAbortSound play];
|
||||
status = STATUS_IN_FLIGHT;
|
||||
@ -1769,7 +1751,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
if (jump_distance > 7.0)
|
||||
{
|
||||
[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]"])
|
||||
[witchAbortSound play];
|
||||
status = STATUS_IN_FLIGHT;
|
||||
@ -1784,7 +1766,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
if (fuel < fuel_required)
|
||||
{
|
||||
[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]"])
|
||||
[witchAbortSound play];
|
||||
status = STATUS_IN_FLIGHT;
|
||||
@ -1817,7 +1799,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
if ([universe planet])
|
||||
[universe addMessage:[NSString stringWithFormat:@" %@. ",[universe getSystemName:system_seed]] forCount:3.0];
|
||||
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;
|
||||
}
|
||||
@ -1852,7 +1834,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
{
|
||||
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]"])
|
||||
[self boop];
|
||||
}
|
||||
@ -1880,7 +1862,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
ShipEntity* target_ship = (ShipEntity *)[missile_entity[i] getPrimaryTarget];
|
||||
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]"])
|
||||
[self boop];
|
||||
[missile_entity[i] removeTarget:nil];
|
||||
@ -1905,7 +1887,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
missile_status = MISSILE_STATUS_TARGET_LOCKED;
|
||||
if ((missile_entity[active_missile])&&(!ident_engaged))
|
||||
[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 (![universe playCustomSound:@"[ident-locked-on]"])
|
||||
@ -2056,8 +2038,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
{
|
||||
ecm_in_operation = NO;
|
||||
[self stopECMSound];
|
||||
//[universe displayMessage:@"ECM system deactivated (no energy left)." forCount:3.0];
|
||||
[universe addMessage:[universe expandDescription:@"[ecm-out-of-juice]" forSystem:system_seed] forCount:3.0];
|
||||
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[ecm-out-of-juice]") forCount:3.0];
|
||||
}
|
||||
if ([universe getTime] > ecm_start_time + ECM_DURATION)
|
||||
{
|
||||
@ -2086,7 +2067,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
fuel_accumulator -= 1.0;
|
||||
}
|
||||
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])
|
||||
{
|
||||
// restore player ship
|
||||
ShipEntity *player_ship = [universe getShip: ship_desc]; // retained
|
||||
ShipEntity *player_ship = [universe newShipWithName: ship_desc]; // retained
|
||||
if (player_ship)
|
||||
{
|
||||
[self setModel:[player_ship getModel]];
|
||||
@ -2144,7 +2125,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
{
|
||||
if (![universe playCustomSound:@"[jump-mass-locked]"])
|
||||
[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;
|
||||
}
|
||||
}
|
||||
@ -2853,13 +2834,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
}
|
||||
if ((alert_condition == ALERT_CONDITION_RED)&&(old_alert_condition < ALERT_CONDITION_RED))
|
||||
{
|
||||
// give an audible warning
|
||||
// NSLog(@"WARNING! %d %x", alert_condition, alert_flags);
|
||||
#ifdef HAVE_SOUND
|
||||
if ([warningSound isPlaying])
|
||||
[warningSound stop];
|
||||
[warningSound play];
|
||||
#endif
|
||||
[self playAlertConditionRed];
|
||||
}
|
||||
|
||||
if (alert_condition != old_alert_condition)
|
||||
@ -2877,34 +2852,27 @@ double scoopSoundPlayTime = 0.0;
|
||||
{
|
||||
if (![universe playCustomSound:@"[hold-full]"])
|
||||
[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"])
|
||||
{
|
||||
#ifdef HAVE_SOUND
|
||||
if (![universe playCustomSound:@"[incoming-missile]"])
|
||||
[warningSound play];
|
||||
#endif
|
||||
[universe addMessage:[universe expandDescription:@"[incoming-missile]" forSystem:system_seed] forCount:4.5];
|
||||
if (![universe playCustomSound:@"[incoming-missile]"]) [warningSound play];
|
||||
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[incoming-missile]") forCount:4.5];
|
||||
}
|
||||
|
||||
if ([ms isEqual:@"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"])
|
||||
[self playECMSound];
|
||||
if ([ms isEqual:@"ECM"]) [self playECMSound];
|
||||
|
||||
if ([ms isEqual:@"DOCKING_REFUSED"]&&(status == STATUS_AUTOPILOT_ENGAGED))
|
||||
{
|
||||
#ifdef HAVE_SOUND
|
||||
if (![universe playCustomSound:@"[autopilot-denied]"])
|
||||
[warningSound play];
|
||||
#endif
|
||||
[universe addMessage:[universe expandDescription:@"[autopilot-denied]" forSystem:system_seed] forCount:4.5];
|
||||
if (![universe playCustomSound:@"[autopilot-denied]"]) [warningSound play];
|
||||
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[autopilot-denied]") forCount:4.5];
|
||||
autopilot_engaged = NO;
|
||||
primaryTarget = NO_TARGET;
|
||||
status = STATUS_IN_FLIGHT;
|
||||
@ -3033,8 +3001,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
[missile setReportAImessages:YES];
|
||||
|
||||
[universe addEntity:missile];
|
||||
//NSLog(@"Missile collision radius is %.1f",missile->collision_radius);
|
||||
[missile release]; //release
|
||||
[missile release];
|
||||
|
||||
[(ShipEntity *)target setPrimaryAggressor:self];
|
||||
[[(ShipEntity *)target getAI] reactToMessage:@"INCOMING_MISSILE"];
|
||||
@ -3088,10 +3055,9 @@ double scoopSoundPlayTime = 0.0;
|
||||
[(ShipEntity *)e2 takeEnergyDamage:1000 from:self becauseOf:self];
|
||||
}
|
||||
}
|
||||
[universe addMessage:[universe expandDescription:@"[energy-bomb-activated]" forSystem:system_seed] forCount:4.5];
|
||||
#ifdef HAVE_SOUND
|
||||
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[energy-bomb-activated]") forCount:4.5];
|
||||
[destructionSound play];
|
||||
#endif
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@ -3104,7 +3070,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
if (weapon_temp / PLAYER_MAX_WEAPON_TEMP >= 0.85)
|
||||
{
|
||||
[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;
|
||||
}
|
||||
|
||||
@ -3153,7 +3119,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -3167,7 +3133,6 @@ double scoopSoundPlayTime = 0.0;
|
||||
case VIEW_NONE:
|
||||
case VIEW_BREAK_PATTERN:
|
||||
case VIEW_FORWARD:
|
||||
// NSLog(@"forward weapon offset = ( %.2f, %.2f, %.2f)", forwardWeaponOffset.x, forwardWeaponOffset.y, forwardWeaponOffset.z);
|
||||
forward_weapon_temp += weapon_heat_increment_per_shot;
|
||||
break;
|
||||
case VIEW_AFT:
|
||||
@ -3180,8 +3145,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
starboard_weapon_temp += weapon_heat_increment_per_shot;
|
||||
break;
|
||||
}
|
||||
|
||||
//NSLog(@"%@ firing weapon",name);
|
||||
|
||||
switch (weapon_to_be_fired)
|
||||
{
|
||||
case WEAPON_PLASMA_CANNON :
|
||||
@ -3248,11 +3212,8 @@ double scoopSoundPlayTime = 0.0;
|
||||
|
||||
if (damageSound)
|
||||
{
|
||||
#ifdef HAVE_SOUND
|
||||
if ([damageSound isPlaying])
|
||||
[damageSound stop];
|
||||
if ([damageSound isPlaying]) [damageSound stop];
|
||||
[damageSound play];
|
||||
#endif
|
||||
}
|
||||
|
||||
// firing on an innocent ship is an offence
|
||||
@ -3263,7 +3224,6 @@ double scoopSoundPlayTime = 0.0;
|
||||
|
||||
if (d_forward >= 0)
|
||||
{
|
||||
//NSLog(@"hit on FORWARD shields");
|
||||
forward_shield -= amount;
|
||||
if (forward_shield < 0.0)
|
||||
{
|
||||
@ -3277,7 +3237,6 @@ double scoopSoundPlayTime = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//NSLog(@"hit on AFT shields");
|
||||
aft_shield -= amount;
|
||||
if (aft_shield < 0.0)
|
||||
{
|
||||
@ -3296,11 +3255,8 @@ double scoopSoundPlayTime = 0.0;
|
||||
energy -= amount;
|
||||
if (scrapeDamageSound)
|
||||
{
|
||||
#ifdef HAVE_SOUND
|
||||
if ([scrapeDamageSound isPlaying])
|
||||
[scrapeDamageSound stop];
|
||||
if ([scrapeDamageSound isPlaying]) [scrapeDamageSound stop];
|
||||
[scrapeDamageSound play];
|
||||
#endif
|
||||
}
|
||||
ship_temperature += amount;
|
||||
}
|
||||
@ -3320,11 +3276,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
[self getDestroyed];
|
||||
}
|
||||
|
||||
if (internal_damage)
|
||||
{
|
||||
// NSLog(@"DEBUG ***** triggered chance of internal damage! *****");
|
||||
[self takeInternalDamage];
|
||||
}
|
||||
if (internal_damage) [self takeInternalDamage];
|
||||
|
||||
[ent release];
|
||||
[other release];
|
||||
@ -3351,11 +3303,8 @@ double scoopSoundPlayTime = 0.0;
|
||||
|
||||
if (scrapeDamageSound)
|
||||
{
|
||||
#ifdef HAVE_SOUND
|
||||
if ([scrapeDamageSound isPlaying])
|
||||
[scrapeDamageSound stop];
|
||||
if ([scrapeDamageSound isPlaying]) [scrapeDamageSound stop];
|
||||
[scrapeDamageSound play];
|
||||
#endif
|
||||
}
|
||||
if (d_forward >= 0)
|
||||
{
|
||||
@ -3403,11 +3352,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
[self getDestroyed];
|
||||
}
|
||||
|
||||
if (internal_damage)
|
||||
{
|
||||
// NSLog(@"DEBUG ***** triggered chance of internal damage! *****");
|
||||
[self takeInternalDamage];
|
||||
}
|
||||
if (internal_damage) [self takeInternalDamage];
|
||||
|
||||
|
||||
[ent release];
|
||||
@ -3483,7 +3428,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
vel.y = flight_speed * v_forward.y;
|
||||
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)
|
||||
{
|
||||
[doppelganger setPosition: origin]; // directly below
|
||||
@ -3534,7 +3479,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
[cargo removeAllObjects];
|
||||
|
||||
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;
|
||||
|
||||
return result;
|
||||
@ -3544,14 +3489,14 @@ double scoopSoundPlayTime = 0.0;
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
int result = [super dumpCargo];
|
||||
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;
|
||||
}
|
||||
@ -3576,11 +3521,11 @@ double scoopSoundPlayTime = 0.0;
|
||||
[pod release];
|
||||
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
|
||||
{
|
||||
[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
|
||||
// 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
|
||||
{
|
||||
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))
|
||||
{
|
||||
// NSLog(@"DEBUG killClass not suitable for high reward");
|
||||
if (![[other roles] isEqual:@"tharglet"]) // okay, we'll count tharglets as proper kills
|
||||
{
|
||||
// NSLog(@"DEBUG reducing award");
|
||||
score /= 10; // reduce bounty awarded
|
||||
kill_award = 0; // don't award a kill
|
||||
}
|
||||
@ -3645,8 +3587,8 @@ double scoopSoundPlayTime = 0.0;
|
||||
|
||||
if (score)
|
||||
{
|
||||
NSString* bonusMS1 = [NSString stringWithFormat:[universe expandDescription:@"[bounty-d]" forSystem:system_seed], score / 10];
|
||||
NSString* bonusMS2 = [NSString stringWithFormat:[universe expandDescription:@"[total-f-credits]" forSystem:system_seed], 0.1 * credits];
|
||||
NSString* bonusMS1 = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[bounty-d]"), score / 10];
|
||||
NSString* bonusMS2 = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[total-f-credits]"), 0.1 * credits];
|
||||
|
||||
if (score > 9)
|
||||
[universe addDelayedMessage:bonusMS1 forCount:6 afterDelay:0.15];
|
||||
@ -3660,7 +3602,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
if ((ship_kills % 256) == 0)
|
||||
{
|
||||
// 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];
|
||||
}
|
||||
}
|
||||
@ -3680,7 +3622,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
if (!cargo_desc)
|
||||
return;
|
||||
[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];
|
||||
return;
|
||||
}
|
||||
@ -3712,11 +3654,11 @@ double scoopSoundPlayTime = 0.0;
|
||||
[self removeEquipment:system_key];
|
||||
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
|
||||
}
|
||||
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;
|
||||
}
|
||||
//cosmetic damage
|
||||
@ -3745,10 +3687,9 @@ double scoopSoundPlayTime = 0.0;
|
||||
[self becomeLargeExplosion:4.0];
|
||||
[self moveForward:100.0];
|
||||
|
||||
#ifdef HAVE_SOUND
|
||||
[universe playCustomSound:@"[game-over]"];
|
||||
[destructionSound play];
|
||||
#endif
|
||||
|
||||
flight_speed = 160.0;
|
||||
status = STATUS_DEAD;
|
||||
[universe displayMessage:@"Game Over" forCount:30.0];
|
||||
@ -4125,7 +4066,6 @@ double scoopSoundPlayTime = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//NSLog(@"---> Witchspace misjump");
|
||||
// move sort of halfway there...
|
||||
galaxy_coordinates.x += target_system_seed.d;
|
||||
galaxy_coordinates.y += target_system_seed.b;
|
||||
@ -4185,7 +4125,6 @@ double scoopSoundPlayTime = 0.0;
|
||||
filename = [[(MyOpenGLView *)[universe gameView] gameController] playerFileToLoad];
|
||||
if (!filename)
|
||||
{
|
||||
// NSBeep(); // AppKit
|
||||
NSLog(@"ERROR no filename returned by [[(MyOpenGLView *)[universe gameView] gameController] playerFileToLoad]");
|
||||
NSException* myException = [NSException
|
||||
exceptionWithName:@"GameNotSavedException"
|
||||
@ -4196,7 +4135,6 @@ double scoopSoundPlayTime = 0.0;
|
||||
}
|
||||
if (![[self commanderDataDictionary] writeOOXMLToFile:filename atomically:YES])
|
||||
{
|
||||
// NSBeep(); //AppKit
|
||||
NSLog(@"***** ERROR: Save to %@ failed!", filename);
|
||||
NSException* myException = [NSException
|
||||
exceptionWithName:@"OoliteException"
|
||||
@ -4209,7 +4147,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
{
|
||||
|
||||
[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)
|
||||
[save_path autorelease];
|
||||
save_path = [filename retain];
|
||||
@ -4241,15 +4179,11 @@ double scoopSoundPlayTime = 0.0;
|
||||
NSArray* path_components = [[sp filename] pathComponents];
|
||||
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];
|
||||
player_name = [new_name retain];
|
||||
|
||||
if (![[self commanderDataDictionary] writeOOXMLToFile:[sp filename] atomically:YES])
|
||||
{
|
||||
// NSBeep(); // AppKit
|
||||
NSLog(@"***** ERROR: Save to %@ failed!", [sp filename]);
|
||||
NSException* myException = [NSException
|
||||
exceptionWithName:@"OoliteException"
|
||||
@ -4304,7 +4238,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
loadedOK = NO;
|
||||
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?)";
|
||||
}
|
||||
else
|
||||
@ -4325,7 +4259,6 @@ double scoopSoundPlayTime = 0.0;
|
||||
else
|
||||
{
|
||||
NSLog(@"***** FILE LOADING ERROR!! *****");
|
||||
// NSBeep(); AppKit
|
||||
[[universe gameController] setPlayerFileToLoad:nil];
|
||||
[universe game_over];
|
||||
[universe clearPreviousMessage];
|
||||
@ -4392,8 +4325,6 @@ double scoopSoundPlayTime = 0.0;
|
||||
NSString* targetSystemName;
|
||||
NSString* text;
|
||||
|
||||
//NSLog(@"DEBUG original hold size = %d",original_hold_size);
|
||||
|
||||
system_seed = [universe findSystemAtCoords:galaxy_coordinates withGalaxySeed:galaxy_seed];
|
||||
target_system_seed = [universe findSystemAtCoords:cursor_coordinates withGalaxySeed:galaxy_seed];
|
||||
|
||||
@ -4475,7 +4406,6 @@ double scoopSoundPlayTime = 0.0;
|
||||
}
|
||||
/* ends */
|
||||
|
||||
//NSLog(@"gui_screen = GUI_SCREEN_STATUS");
|
||||
if (lastTextKey)
|
||||
{
|
||||
[lastTextKey release];
|
||||
@ -4561,8 +4491,6 @@ double scoopSoundPlayTime = 0.0;
|
||||
NSString *grams = (NSString *)[descriptions objectForKey:@"cargo-grams-symbol"];
|
||||
NSString *kilograms = (NSString *)[descriptions objectForKey:@"cargo-kilograms-symbol"];
|
||||
|
||||
// NSLog(@"DEBUG ::::: %@", [shipCommodityData description]);
|
||||
|
||||
if (specialCargo)
|
||||
[manifest addObject:specialCargo];
|
||||
|
||||
@ -4591,11 +4519,6 @@ double scoopSoundPlayTime = 0.0;
|
||||
[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];
|
||||
}
|
||||
@ -4606,8 +4529,6 @@ double scoopSoundPlayTime = 0.0;
|
||||
NSString* targetSystemName;
|
||||
NSDictionary* descriptions = [universe descriptions];
|
||||
|
||||
// target_system_seed = [universe findSystemAtCoords:cursor_coordinates withGalaxySeed:galaxy_seed];
|
||||
|
||||
targetSystemData = [[universe generateSystemData:target_system_seed] retain]; // retained
|
||||
targetSystemName = [[universe getSystemName:target_system_seed] retain]; // retained
|
||||
|
||||
@ -4643,7 +4564,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
population = 0;
|
||||
productivity = 0;
|
||||
radius = 0;
|
||||
system_desc = [universe expandDescription:@"[nova-system-description]" forSystem:target_system_seed];
|
||||
system_desc = ExpandDescriptionForCurrentSystem(@"[nova-system-description]");
|
||||
}
|
||||
|
||||
[gui clear];
|
||||
@ -4673,16 +4594,14 @@ double scoopSoundPlayTime = 0.0;
|
||||
}
|
||||
/* ends */
|
||||
|
||||
//NSLog(@"gui_screen = GUI_SCREEN_SYSTEM_DATA for system %@ at (%d,%d)",targetSystemName,target_system_seed.d,target_system_seed.b);
|
||||
|
||||
if (lastTextKey)
|
||||
{
|
||||
[lastTextKey release];
|
||||
lastTextKey = nil;
|
||||
}
|
||||
|
||||
[targetSystemData release]; // released
|
||||
[targetSystemName release]; // released
|
||||
[targetSystemData release];
|
||||
[targetSystemName release];
|
||||
|
||||
gui_screen = GUI_SCREEN_SYSTEM_DATA;
|
||||
|
||||
@ -4760,11 +4679,9 @@ double scoopSoundPlayTime = 0.0;
|
||||
}
|
||||
/* ends */
|
||||
|
||||
//NSLog(@"gui_screen = GUI_SCREEN_LONG_RANGE_CHART");
|
||||
|
||||
gui_screen = GUI_SCREEN_LONG_RANGE_CHART;
|
||||
|
||||
[targetSystemName release]; // released
|
||||
[targetSystemName release];
|
||||
|
||||
[self setShowDemoShips: NO];
|
||||
[universe setDisplayText: YES];
|
||||
@ -4968,8 +4885,6 @@ double scoopSoundPlayTime = 0.0;
|
||||
target_system_seed = [universe findSystemAtCoords:cursor_coordinates withGalaxySeed:galaxy_seed];
|
||||
targetSystemName = [[universe getSystemName:target_system_seed] retain]; // retained
|
||||
|
||||
//NSLog(@"found %@ at (%d, %d)",targetSystemName,(int)cursor_coordinates.x,(int)cursor_coordinates.y);
|
||||
|
||||
// GUI stuff
|
||||
{
|
||||
GuiDisplayGen* gui = [universe gui];
|
||||
@ -4988,8 +4903,6 @@ double scoopSoundPlayTime = 0.0;
|
||||
}
|
||||
/* ends */
|
||||
|
||||
//NSLog(@"gui_screen = GUI_SCREEN_LONG_RANGE_CHART");
|
||||
|
||||
gui_screen = GUI_SCREEN_SHORT_RANGE_CHART;
|
||||
|
||||
[targetSystemName release]; // released
|
||||
@ -5193,8 +5106,6 @@ double scoopSoundPlayTime = 0.0;
|
||||
}
|
||||
/* ends */
|
||||
|
||||
//NSLog(@"gui_screen = GUI_SCREEN_OPTIONS");
|
||||
|
||||
[self setShowDemoShips:NO];
|
||||
gui_screen = GUI_SCREEN_OPTIONS;
|
||||
|
||||
@ -5210,8 +5121,6 @@ static int last_outfitting_index;
|
||||
{
|
||||
missiles = [self calc_missiles];
|
||||
|
||||
// NSLog(@"DEBUG EquipShipScreen missiles = %d", missiles);
|
||||
|
||||
// if skip < 0 then use the last recorded index
|
||||
if (skip < 0)
|
||||
{
|
||||
@ -5544,15 +5453,15 @@ static int last_outfitting_index;
|
||||
[gui clear];
|
||||
[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 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 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 setColor:[OOColor yellowColor] forRow:21];
|
||||
|
||||
@ -5569,7 +5478,6 @@ static int last_outfitting_index;
|
||||
|
||||
// check for messages from the command line
|
||||
NSArray* arguments = [[NSProcessInfo processInfo] arguments];
|
||||
//NSLog(@"DEBUG arguments:\n%@",[arguments description]);
|
||||
int i;
|
||||
for (i = 0; i < [arguments count]; i++)
|
||||
{
|
||||
@ -5616,7 +5524,7 @@ static int last_outfitting_index;
|
||||
[gui clear];
|
||||
[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 setColor:[OOColor yellowColor] forRow:21];
|
||||
|
||||
@ -5660,7 +5568,7 @@ static int last_outfitting_index;
|
||||
chosen_weapon_facing = WEAPON_FACING_PORT;
|
||||
if ([item_text isEqual:STARBOARD_FACING_STRING])
|
||||
chosen_weapon_facing = WEAPON_FACING_STARBOARD;
|
||||
//NSLog(@"Try Buying Item %d",item);
|
||||
|
||||
int old_credits = credits;
|
||||
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
|
||||
if (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];
|
||||
return YES;
|
||||
}
|
||||
|
||||
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);
|
||||
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];
|
||||
int weapon_value = [universe getPriceForWeaponSystemWithKey:weapon_key];
|
||||
// NSLog(@"..... selling a %@ worth %f", weapon_key, 0.1 * weapon_value);
|
||||
credits += weapon_value;
|
||||
[universe recycleOrDiscard: weapon];
|
||||
[weapon release];
|
||||
@ -5913,7 +5820,6 @@ static int last_outfitting_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]))
|
||||
{
|
||||
//NSLog(@"adding %@",eq_key);
|
||||
credits -= price;
|
||||
[self add_extra_equipment:eq_key];
|
||||
[self setGuiToEquipShipScreen:-1:-1];
|
||||
@ -5970,8 +5876,7 @@ static int last_outfitting_index;
|
||||
else
|
||||
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
|
||||
if (![universe station])
|
||||
{
|
||||
@ -6326,11 +6231,9 @@ OOSound* burnersound;
|
||||
burnersound = afterburner2Sound;
|
||||
else
|
||||
burnersound = afterburner1Sound;
|
||||
|
||||
// NSLog(@"DEBUG loopAfterburnerSound playing sound %@", burnersound);
|
||||
#ifdef HAVE_SOUND
|
||||
|
||||
[burnersound play];
|
||||
#endif
|
||||
|
||||
[self performSelector:_loopAfterburnerSoundSelector
|
||||
withObject:NULL
|
||||
afterDelay:1.25]; // and swap sounds in 1.25s time
|
||||
@ -6380,7 +6283,7 @@ OOSound* burnersound;
|
||||
credits -= fine;
|
||||
}
|
||||
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];
|
||||
ship_clock_adjust = 24 * 3600; // take up a day
|
||||
if (gui_screen != GUI_SCREEN_STATUS)
|
||||
@ -6430,8 +6333,6 @@ OOSound* burnersound;
|
||||
|
||||
- (void) setUpTrumbles
|
||||
{
|
||||
// NSLog(@"DEBUG setting up trumbles for %@%@", player_name, basefile);
|
||||
|
||||
NSMutableString* trumbleDigrams = [NSMutableString stringWithCapacity:256];
|
||||
unichar xchar = (unichar)0;
|
||||
unichar digramchars[2];
|
||||
@ -6542,7 +6443,6 @@ OOSound* burnersound;
|
||||
NSString* namekey = [NSString stringWithFormat:@"%@-humbletrash", player_name];
|
||||
|
||||
[self setUpTrumbles];
|
||||
// NSLog(@"DEBUG setting trumble values from %@", trumbleValue);
|
||||
|
||||
if (trumbleValue)
|
||||
{
|
||||
@ -6618,8 +6518,6 @@ OOSound* burnersound;
|
||||
// at this stage we've done the best we can to stop cheaters
|
||||
n_trumbles = putativeNTrumbles;
|
||||
|
||||
// NSLog(@"DEBUG putativeTrumbleArray = \n%@", putativeTrumbleArray);
|
||||
|
||||
if ((putativeTrumbleArray != nil) && ([putativeTrumbleArray count] == PLAYER_MAX_TRUMBLES))
|
||||
{
|
||||
for (i = 0; i < PLAYER_MAX_TRUMBLES; i++)
|
||||
@ -6724,7 +6622,7 @@ OOSound* burnersound;
|
||||
{
|
||||
[super addTarget:potential_target];
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -6750,7 +6648,7 @@ OOSound* burnersound;
|
||||
{
|
||||
[super addTarget:potential_target];
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
||||
else if ([rescuee insuranceCredits])
|
||||
{
|
||||
// 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]];
|
||||
credits += 10 * [rescuee insuranceCredits];
|
||||
}
|
||||
@ -88,7 +88,7 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
||||
{
|
||||
// claim bounty for capture
|
||||
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];
|
||||
credits += reward;
|
||||
}
|
||||
@ -141,9 +141,9 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
||||
}
|
||||
credits += 10 * fee;
|
||||
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
|
||||
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--];
|
||||
[self increasePassengerReputation];
|
||||
}
|
||||
@ -155,9 +155,9 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
||||
fee /= 2;
|
||||
credits += 10 * fee;
|
||||
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
|
||||
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--];
|
||||
}
|
||||
}
|
||||
@ -167,9 +167,9 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
||||
{
|
||||
// we've run out of time!
|
||||
if (!result)
|
||||
result = [NSString stringWithFormat:[universe expandDescription:@"[passenger-failed-@]" forSystem:system_seed], passenger_name];
|
||||
result = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[passenger-failed-@]"), passenger_name];
|
||||
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--];
|
||||
[self decreasePassengerReputation];
|
||||
}
|
||||
@ -215,9 +215,9 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
||||
// pay the premium and fee
|
||||
credits += fee + premium;
|
||||
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
|
||||
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--];
|
||||
// repute++
|
||||
[self increaseContractReputation];
|
||||
@ -244,18 +244,18 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
||||
int payment = percent_delivered * (fee + premium) / 100.0;
|
||||
credits += payment;
|
||||
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
|
||||
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--];
|
||||
// repute unchanged
|
||||
}
|
||||
else
|
||||
{
|
||||
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
|
||||
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!
|
||||
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
|
||||
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--];
|
||||
// repute--
|
||||
[self decreaseContractReputation];
|
||||
@ -277,9 +277,9 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
||||
{
|
||||
// we've run out of time!
|
||||
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
|
||||
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--];
|
||||
// repute--
|
||||
[self decreaseContractReputation];
|
||||
@ -696,8 +696,6 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
||||
[passenger_market removeObject:passenger_info];
|
||||
credits += 10 * passenger_premium;
|
||||
|
||||
// NSLog(@"DEBUG passengers:\n%@", [passengers description]);
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@ -743,8 +741,6 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
||||
[contract_record setObject:contract_arrival_time forKey:contract_id];
|
||||
[contract_market removeObject:contract_info];
|
||||
|
||||
// NSLog(@"DEBUG contracts:\n%@", [contracts description]);
|
||||
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
@ -967,7 +963,7 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
||||
// GUI stuff
|
||||
{
|
||||
[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
|
||||
@ -1017,7 +1013,7 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
||||
// GUI stuff
|
||||
{
|
||||
[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
|
||||
@ -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)
|
||||
{
|
||||
[gui setColor:[OOColor greenColor] forRow:GUI_ROW_SHIPYARD_LABELS];
|
||||
@ -1227,8 +1220,6 @@ static NSMutableDictionary* currentShipyard = nil;
|
||||
GuiDisplayGen* gui = [universe gui];
|
||||
int sel_row = [gui selectedRow];
|
||||
|
||||
// NSLog(@"-- %d %d %d", sel_row, [gui selectableRange].location, [gui selectableRange].length);
|
||||
|
||||
if (sel_row <= 0)
|
||||
return;
|
||||
|
||||
@ -1238,7 +1229,6 @@ static NSMutableDictionary* currentShipyard = nil;
|
||||
|
||||
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];
|
||||
|
||||
if (info)
|
||||
@ -1330,12 +1320,8 @@ static NSMutableDictionary* currentShipyard = nil;
|
||||
|
||||
if ([key hasPrefix:@"More:"])
|
||||
{
|
||||
// NSLog(@"DEBUG Key is '%@'", key);
|
||||
|
||||
int from_ship = [(NSString*)[[key componentsSeparatedByString:@":"] objectAtIndex:1] intValue];
|
||||
|
||||
// NSLog(@"DEBUG skipping %d", from_ship);
|
||||
|
||||
|
||||
[self setGuiToShipyardScreen:from_ship];
|
||||
if ([[universe gui] selectedRow] < 0)
|
||||
[[universe gui] setSelectedRow:GUI_ROW_SHIPYARD_START];
|
||||
@ -1389,8 +1375,6 @@ static NSMutableDictionary* currentShipyard = nil;
|
||||
starboard_weapon = WEAPON_NONE;
|
||||
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
|
||||
max_cargo = [universe maxCargoForShip:ship_desc];
|
||||
|
||||
|
@ -173,7 +173,7 @@ static NSTimeInterval time_last_frame;
|
||||
{
|
||||
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;
|
||||
if (!afterburnerSoundLooping)
|
||||
[self loopAfterburnerSound];
|
||||
@ -181,7 +181,7 @@ static NSTimeInterval time_last_frame;
|
||||
else
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -268,7 +268,7 @@ static NSTimeInterval time_last_frame;
|
||||
{
|
||||
if (![universe playCustomSound:@"[jump-mass-locked]"])
|
||||
[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
|
||||
@ -296,7 +296,6 @@ static NSTimeInterval time_last_frame;
|
||||
{
|
||||
if (target_laser_hit != NO_TARGET)
|
||||
{
|
||||
#ifdef HAVE_SOUND
|
||||
if (weaponHitSound)
|
||||
{
|
||||
if ([weaponHitSound isPlaying])
|
||||
@ -308,11 +307,9 @@ static NSTimeInterval time_last_frame;
|
||||
{
|
||||
if (weaponSound)
|
||||
{
|
||||
if ([weaponSound isPlaying])
|
||||
[weaponSound stop];
|
||||
if ([weaponSound isPlaying]) [weaponSound stop];
|
||||
[weaponSound play];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -331,10 +328,7 @@ static NSTimeInterval time_last_frame;
|
||||
BOOL missile_noise = [[missile_entity[active_missile] roles] hasSuffix:@"MISSILE"];
|
||||
if ([self fireMissile])
|
||||
{
|
||||
#ifdef HAVE_SOUND
|
||||
if (missile_noise)
|
||||
[missileSound play];
|
||||
#endif
|
||||
if (missile_noise) [missileSound play];
|
||||
}
|
||||
}
|
||||
fire_missile_pressed = YES;
|
||||
@ -414,7 +408,7 @@ static NSTimeInterval time_last_frame;
|
||||
ident_engaged = YES;
|
||||
if (![universe playCustomSound:@"[ident-on]"])
|
||||
[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;
|
||||
}
|
||||
@ -439,7 +433,7 @@ static NSTimeInterval time_last_frame;
|
||||
{
|
||||
missile_status = MISSILE_STATUS_TARGET_LOCKED;
|
||||
[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]"])
|
||||
[self beep];
|
||||
}
|
||||
@ -451,14 +445,14 @@ static NSTimeInterval time_last_frame;
|
||||
{
|
||||
if (missile_entity[active_missile])
|
||||
[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]"])
|
||||
[self beep];
|
||||
}
|
||||
}
|
||||
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]"])
|
||||
[self beep];
|
||||
}
|
||||
@ -487,7 +481,7 @@ static NSTimeInterval time_last_frame;
|
||||
[self safe_all_missiles];
|
||||
if (![universe playCustomSound:@"[missile-safe]"])
|
||||
[self boop];
|
||||
[universe addMessage:[universe expandDescription:@"[missile-safe]" forSystem:system_seed] forCount:2.0];
|
||||
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[missile-safe]") forCount:2.0];
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -496,7 +490,7 @@ static NSTimeInterval time_last_frame;
|
||||
missile_status = (primaryTarget != NO_TARGET)? MISSILE_STATUS_TARGET_LOCKED : MISSILE_STATUS_SAFE;
|
||||
if (![universe playCustomSound:@"[ident-off]"])
|
||||
[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;
|
||||
}
|
||||
@ -518,7 +512,7 @@ static NSTimeInterval time_last_frame;
|
||||
if ([self fireECM])
|
||||
{
|
||||
[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;
|
||||
if (![universe playCustomSound:@"[autopilot-out-of-range]"])
|
||||
[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
|
||||
if (![universe playCustomSound:@"[autopilot-on]"])
|
||||
[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)
|
||||
{
|
||||
@ -652,7 +646,7 @@ static NSTimeInterval time_last_frame;
|
||||
[shipAI setState:@"GLOBAL"]; // restart the AI
|
||||
if (![universe playCustomSound:@"[autopilot-on]"])
|
||||
[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)
|
||||
{
|
||||
@ -672,7 +666,7 @@ static NSTimeInterval time_last_frame;
|
||||
{
|
||||
if (![universe playCustomSound:@"[autopilot-cannot-dock-with-target]"])
|
||||
[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;
|
||||
@ -724,7 +718,7 @@ static NSTimeInterval time_last_frame;
|
||||
{
|
||||
if (![universe playCustomSound:@"[autopilot-out-of-range]"])
|
||||
[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;
|
||||
@ -752,7 +746,7 @@ static NSTimeInterval time_last_frame;
|
||||
if (![universe playCustomSound:@"[witch-no-target]"])
|
||||
[self boop];
|
||||
[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;
|
||||
}
|
||||
|
||||
@ -761,7 +755,7 @@ static NSTimeInterval time_last_frame;
|
||||
if (![universe playCustomSound:@"[witch-no-fuel]"])
|
||||
[self boop];
|
||||
[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;
|
||||
}
|
||||
|
||||
@ -779,7 +773,7 @@ static NSTimeInterval time_last_frame;
|
||||
[self boop];
|
||||
// say it!
|
||||
[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)
|
||||
@ -791,7 +785,7 @@ static NSTimeInterval time_last_frame;
|
||||
[self beep];
|
||||
// say it!
|
||||
[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;
|
||||
@ -825,7 +819,7 @@ static NSTimeInterval time_last_frame;
|
||||
[self boop];
|
||||
// say it!
|
||||
[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)
|
||||
@ -837,7 +831,7 @@ static NSTimeInterval time_last_frame;
|
||||
if (![universe playCustomSound:@"[hyperspace-countdown-begun]"])
|
||||
[self beep];
|
||||
// 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;
|
||||
@ -858,14 +852,14 @@ static NSTimeInterval time_last_frame;
|
||||
if (!cloaking_device_active)
|
||||
{
|
||||
if ([self activateCloakingDevice])
|
||||
[universe addMessage:[universe expandDescription:@"[cloak-on]" forSystem:system_seed] forCount:2];
|
||||
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[cloak-on]") forCount:2];
|
||||
else
|
||||
[universe addMessage:[universe expandDescription:@"[cloak-low-juice]" forSystem:system_seed] forCount:3];
|
||||
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[cloak-low-juice]") forCount:3];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self deactivateCloakingDevice];
|
||||
[universe addMessage:[universe expandDescription:@"[cloak-off]" forSystem:system_seed] forCount:2];
|
||||
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[cloak-off]") forCount:2];
|
||||
}
|
||||
//
|
||||
if (cloaking_device_active)
|
||||
@ -994,8 +988,8 @@ static NSTimeInterval time_last_frame;
|
||||
{
|
||||
saved_view_direction = [universe viewDir];
|
||||
saved_script_time = script_time;
|
||||
[universe addMessage:[universe expandDescription:@"[game-paused]" forSystem:system_seed] forCount:1.0];
|
||||
[universe addMessage:[universe expandDescription:@"[game-paused-options]" forSystem:system_seed] forCount:1.0];
|
||||
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[game-paused]") forCount:1.0];
|
||||
[universe addMessage:ExpandDescriptionForCurrentSystem(@"[game-paused-options]") forCount:1.0];
|
||||
[[gameView gameController] pause_game];
|
||||
}
|
||||
}
|
||||
@ -1030,7 +1024,7 @@ static BOOL taking_snapshot;
|
||||
{
|
||||
[[gameView gameController] exitFullScreenMode];
|
||||
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;
|
||||
}
|
||||
//
|
||||
@ -1065,7 +1059,7 @@ static BOOL taking_snapshot;
|
||||
//
|
||||
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;
|
||||
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
|
||||
// player runs to the keyboard) is reset
|
||||
keyboardRollPitchOverride = NO;
|
||||
}
|
||||
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;
|
||||
}
|
||||
@ -1447,7 +1441,6 @@ static BOOL spacePressed;
|
||||
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.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)
|
||||
{
|
||||
@ -1457,7 +1450,6 @@ static BOOL spacePressed;
|
||||
double vscale = MAIN_GUI_PIXEL_HEIGHT / 512.0;
|
||||
cursor_coordinates.x = (maus.x * MAIN_GUI_PIXEL_WIDTH + hadjust)/ hscale;
|
||||
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];
|
||||
moving = YES;
|
||||
@ -1594,10 +1586,10 @@ static BOOL spacePressed;
|
||||
disc_operation_in_progress = YES;
|
||||
[self quicksavePlayer];
|
||||
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
|
||||
{
|
||||
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])
|
||||
[[universe gameController] pauseFullScreenModeToPerform:@selector(savePlayer) onTarget:self];
|
||||
else
|
||||
@ -1663,7 +1655,7 @@ static BOOL spacePressed;
|
||||
int displayModeIndex = [controller indexOfCurrentDisplayMode];
|
||||
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;
|
||||
}
|
||||
else
|
||||
@ -1902,7 +1894,6 @@ static BOOL spacePressed;
|
||||
if (!wait_for_key_up)
|
||||
{
|
||||
int item = [(NSString *)[gui selectedRowKey] intValue];
|
||||
//NSLog(@"Try Buying Commodity %d",item);
|
||||
if ([self tryBuyingCommodity:item])
|
||||
[self setGuiToMarketScreen];
|
||||
else
|
||||
@ -1915,7 +1906,6 @@ static BOOL spacePressed;
|
||||
if (!wait_for_key_up)
|
||||
{
|
||||
int item = [(NSString *)[gui selectedRowKey] intValue];
|
||||
//NSLog(@"Try Selling Commodity %d",item);
|
||||
if ([self trySellingCommodity:item])
|
||||
[self setGuiToMarketScreen];
|
||||
else
|
||||
@ -1934,13 +1924,11 @@ static BOOL spacePressed;
|
||||
{
|
||||
int item = [(NSString *)[gui selectedRowKey] 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
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < yours; i++)
|
||||
[self trySellingCommodity:item];
|
||||
//NSLog(@"... you sold %d.", yours);
|
||||
[self playInterfaceBeep:kInterfaceBeep_Sell];
|
||||
[self setGuiToMarketScreen];
|
||||
}
|
||||
@ -1949,7 +1937,6 @@ static BOOL spacePressed;
|
||||
int amount_bought = 0;
|
||||
while ([self tryBuyingCommodity:item])
|
||||
amount_bought++;
|
||||
//NSLog(@"... you bought %d.", amount_bought);
|
||||
[self setGuiToMarketScreen];
|
||||
if (amount_bought == 0)
|
||||
{
|
||||
@ -2442,7 +2429,7 @@ static BOOL toggling_music;
|
||||
status = STATUS_IN_FLIGHT;
|
||||
if (![universe playCustomSound:@"[autopilot-off]"])
|
||||
[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)
|
||||
{
|
||||
@ -2487,7 +2474,6 @@ static BOOL toggling_music;
|
||||
[universe set_up_universe_from_station]; // launch!
|
||||
if (!docked_station)
|
||||
docked_station = [universe station];
|
||||
//NSLog(@"Leaving dock (%@)...%@",docked_station,[docked_station name]);
|
||||
[self leaveDock:docked_station];
|
||||
[universe setDisplayCursor:NO];
|
||||
}
|
||||
@ -2583,7 +2569,6 @@ static BOOL toggling_music;
|
||||
case GUI_SCREEN_MISSION :
|
||||
if ([[gui keyForRow:21] isEqual:@"spacebar"])
|
||||
{
|
||||
// NSLog(@"GUI_SCREEN_MISSION looking for spacebar");
|
||||
if ([gameView isDown:32]) // '<space>'
|
||||
{
|
||||
if (!spacePressed)
|
||||
@ -2602,7 +2587,6 @@ static BOOL toggling_music;
|
||||
}
|
||||
else
|
||||
{
|
||||
// NSLog(@"GUI_SCREEN_MISSION looking for up/down/select");
|
||||
if ([gameView isDown:gvArrowKeyDown])
|
||||
{
|
||||
if ((!upDownKeyPressed)||(script_time > timeLastKeyPress + KEY_REPEAT_INTERVAL))
|
||||
|
@ -39,6 +39,8 @@ MA 02110-1301, USA.
|
||||
#import "ResourceManager.h"
|
||||
#endif
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.PlayerEntityLoadSave"
|
||||
|
||||
@implementation PlayerEntity (LoadSave)
|
||||
|
||||
- (void) setGuiToLoadCommanderScreen
|
||||
@ -510,7 +512,6 @@ MA 02110-1301, USA.
|
||||
|
||||
if(![[self commanderDataDictionary] writeOOXMLToFile:savePath atomically:YES])
|
||||
{
|
||||
//NSBeep(); // appkit dependency
|
||||
NSLog(@"***** ERROR: Save to %@ failed!", savePath);
|
||||
NSException *myException = [NSException
|
||||
exceptionWithName:@"OoliteException"
|
||||
@ -529,7 +530,7 @@ MA 02110-1301, USA.
|
||||
[[universe gameController] setPlayerFileDirectory:save_path];
|
||||
|
||||
[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...
|
||||
@ -607,7 +608,7 @@ MA 02110-1301, USA.
|
||||
}
|
||||
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];
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,8 @@ MA 02110-1301, USA.
|
||||
#import "Comparison.h"
|
||||
#endif
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.PlayerEntityScripting"
|
||||
|
||||
static NSString * const kOOLogScriptAddShipsFailed = @"script.addShips.failed";
|
||||
static NSString * const kOOLogScriptMissionDescNoText = @"script.missionDescription.noMissionText";
|
||||
static NSString * const kOOLogScriptMissionDescNoKey = @"script.missionDescription.noMissionKey";
|
||||
@ -123,7 +125,7 @@ static NSString * mission_key;
|
||||
|
||||
- (void) scriptActions:(NSArray*) some_actions forTarget:(ShipEntity*) a_target
|
||||
{
|
||||
PlayerEntity* player = (PlayerEntity *)[universe entityZero];
|
||||
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||
int i;
|
||||
for (i = 0; i < [some_actions count]; i++)
|
||||
{
|
||||
@ -227,7 +229,7 @@ static NSString * mission_key;
|
||||
{
|
||||
[tokens removeObjectAtIndex:0];
|
||||
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);
|
||||
}
|
||||
|
||||
@ -506,7 +508,7 @@ static NSString * mission_key;
|
||||
OOLog(kOOLogScriptMissionDescNoKey, @"SCRIPT ERROR ***** mission_key not set");
|
||||
return;
|
||||
}
|
||||
text = [universe expandDescription:text forSystem:system_seed];
|
||||
text = ExpandDescriptionForCurrentSystem(text);
|
||||
text = [self replaceVariablesInString: text];
|
||||
|
||||
[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.f = rand() & 255;
|
||||
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];
|
||||
|
||||
[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.f = rand() & 255;
|
||||
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];
|
||||
|
||||
[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.f = rand() & 255;
|
||||
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];
|
||||
|
||||
[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 ([self mountMissile:[[universe getShipWithRole:eq_type] autorelease]])
|
||||
if ([self mountMissile:[[universe newShipWithRole:eq_type] autorelease]])
|
||||
missiles++;
|
||||
return;
|
||||
}
|
||||
@ -1049,7 +1051,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
||||
int smaller_quantity = 1 + ((amount - 1) % amount_per_container);
|
||||
if ([cargo count] < max_cargo)
|
||||
{
|
||||
ShipEntity* container = [universe getShipWithRole:@"cargopod"];
|
||||
ShipEntity* container = [universe newShipWithRole:@"cargopod"];
|
||||
if (container)
|
||||
{
|
||||
[container setUniverse:universe];
|
||||
@ -1069,7 +1071,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
||||
{
|
||||
if ([cargo count] < max_cargo)
|
||||
{
|
||||
ShipEntity* container = [universe getShipWithRole:@"cargopod"];
|
||||
ShipEntity* container = [universe newShipWithRole:@"cargopod"];
|
||||
if (container)
|
||||
{
|
||||
[container setUniverse:universe];
|
||||
@ -1139,7 +1141,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
||||
return;
|
||||
|
||||
[self removeAllCargo];
|
||||
specialCargo = [[universe expandDescription:descriptionString forSystem:system_seed] retain];
|
||||
specialCargo = [ExpandDescriptionForCurrentSystem(descriptionString) retain];
|
||||
//
|
||||
OOLog(kOOLogNoteUseSpecialCargo, @"Going to useSpecialCargo:'%@'", specialCargo);
|
||||
}
|
||||
@ -1179,7 +1181,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
||||
|
||||
- (void) ejectItem:(NSString *)item_key
|
||||
{
|
||||
ShipEntity* item = [universe getShip:item_key];
|
||||
ShipEntity* item = [universe newShipWithName:item_key];
|
||||
if (script_target == nil)
|
||||
script_target = self;
|
||||
if (item)
|
||||
@ -1559,9 +1561,9 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
||||
//
|
||||
GuiDisplayGen *gui = [universe gui];
|
||||
NSString *text = (NSString *)[[universe missiontext] objectForKey:textKey];
|
||||
text = [universe expandDescription:text forSystem:system_seed];
|
||||
text = ExpandDescriptionForCurrentSystem(text);
|
||||
text = [self replaceVariablesInString: text];
|
||||
//NSLog(@"::::: Adding text '%@':\n'%@'", textKey, text);
|
||||
|
||||
NSArray *paras = [text componentsSeparatedByString:@"\\n"];
|
||||
if (text)
|
||||
{
|
||||
@ -1602,7 +1604,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
||||
{
|
||||
NSString* choice_key = (NSString *)[choice_keys objectAtIndex:i];
|
||||
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];
|
||||
[gui setText:choice_text forRow:choices_row align: GUI_ALIGN_CENTER];
|
||||
[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};
|
||||
|
||||
ship = [universe getShipWithRole: shipKey]; // retain count = 1
|
||||
ship = [universe newShipWithRole: shipKey]; // retain count = 1
|
||||
if (ship)
|
||||
{
|
||||
double cr = ship->collision_radius;
|
||||
@ -1954,7 +1956,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
||||
}
|
||||
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])];
|
||||
}
|
||||
}
|
||||
@ -2069,7 +2071,6 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
||||
if (![conditions isKindOfClass:[NSArray class]])
|
||||
{
|
||||
NSLog(@"SCENE ERROR \"conditions = %@\" is not an array - returning NO.", [conditions description]);
|
||||
// NSBeep(); AppKit
|
||||
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....
|
||||
ShipEntity* ship = nil;
|
||||
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"])
|
||||
ship = [universe getShipWithRole:(NSString*)[i_info objectAtIndex: 1]];
|
||||
ship = [universe newShipWithRole:(NSString*)[i_info objectAtIndex: 1]];
|
||||
if (!ship)
|
||||
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
|
||||
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)
|
||||
return NO;
|
||||
|
||||
|
@ -49,4 +49,7 @@ enum
|
||||
|
||||
- (void)playBreakPattern;
|
||||
|
||||
- (void)playHostileWarning;
|
||||
- (void)playAlertConditionRed;
|
||||
|
||||
@end
|
||||
|
@ -40,98 +40,94 @@ MA 02110-1301, USA.
|
||||
|
||||
- (void)setUpSound
|
||||
{
|
||||
#ifdef HAVE_SOUND
|
||||
[self destroySound];
|
||||
|
||||
beepSound = [[ResourceManager ooSoundNamed:@"beep.ogg" inFolder:@"Sounds"] retain];
|
||||
boopSound = [[ResourceManager ooSoundNamed:@"boop.ogg" inFolder:@"Sounds"] retain];
|
||||
weaponSound = [[ResourceManager ooSoundNamed:@"laser.ogg" inFolder:@"Sounds"] retain];
|
||||
weaponHitSound = [[ResourceManager ooSoundNamed:@"laserhits.ogg" inFolder:@"Sounds"] retain];
|
||||
missileSound = [[ResourceManager ooSoundNamed:@"missile.ogg" inFolder:@"Sounds"] retain];
|
||||
damageSound = [[ResourceManager ooSoundNamed:@"hit.ogg" inFolder:@"Sounds"] retain];
|
||||
scrapeDamageSound = [[ResourceManager ooSoundNamed:@"hullbang.ogg" inFolder:@"Sounds"] retain];
|
||||
destructionSound = [[ResourceManager ooSoundNamed:@"bigbang.ogg" inFolder:@"Sounds"] retain];
|
||||
breakPatternSound = [[ResourceManager ooSoundNamed:@"breakpattern.ogg" inFolder:@"Sounds"] retain];
|
||||
//
|
||||
ecmSound = [[ResourceManager ooSoundNamed:@"ecm.ogg" inFolder:@"Sounds"] retain];
|
||||
buySound = [[ResourceManager ooSoundNamed:@"buy.ogg" inFolder:@"Sounds"] retain];
|
||||
sellSound = [[ResourceManager ooSoundNamed:@"sell.ogg" inFolder:@"Sounds"] retain];
|
||||
warningSound = [[ResourceManager ooSoundNamed:@"warning.ogg" inFolder:@"Sounds"] retain];
|
||||
afterburner1Sound = [[ResourceManager ooSoundNamed:@"afterburner1.ogg" inFolder:@"Sounds"] retain];
|
||||
afterburner2Sound = [[ResourceManager ooSoundNamed:@"afterburner2.ogg" inFolder:@"Sounds"] retain];
|
||||
//
|
||||
witchAbortSound = [[ResourceManager ooSoundNamed:@"witchabort.ogg" inFolder:@"Sounds"] retain];
|
||||
//
|
||||
fuelScoopSound = [[ResourceManager ooSoundNamed:@"scoop.ogg" inFolder:@"Sounds"] retain];
|
||||
|
||||
themeMusic = [[ResourceManager ooMusicNamed:@"OoliteTheme.ogg" inFolder:@"Music"] retain];
|
||||
missionMusic = [[ResourceManager ooMusicNamed:@"OoliteTheme.ogg" inFolder:@"Music"] retain];
|
||||
dockingMusic = [[ResourceManager ooMusicNamed:@"BlueDanube.ogg" inFolder:@"Music"] retain];
|
||||
|
||||
refPoint = [[OOSoundReferencePoint alloc] init];
|
||||
interfaceBeepSource = [[OOSoundSource alloc] init];
|
||||
breakPatternSource = [[OOSoundSource alloc] init];
|
||||
ecmSource = [[OOSoundSource alloc] init];
|
||||
#endif
|
||||
[self destroySound];
|
||||
|
||||
beepSound = [[ResourceManager ooSoundNamed:@"beep.ogg" inFolder:@"Sounds"] retain];
|
||||
boopSound = [[ResourceManager ooSoundNamed:@"boop.ogg" inFolder:@"Sounds"] retain];
|
||||
weaponSound = [[ResourceManager ooSoundNamed:@"laser.ogg" inFolder:@"Sounds"] retain];
|
||||
weaponHitSound = [[ResourceManager ooSoundNamed:@"laserhits.ogg" inFolder:@"Sounds"] retain];
|
||||
missileSound = [[ResourceManager ooSoundNamed:@"missile.ogg" inFolder:@"Sounds"] retain];
|
||||
damageSound = [[ResourceManager ooSoundNamed:@"hit.ogg" inFolder:@"Sounds"] retain];
|
||||
scrapeDamageSound = [[ResourceManager ooSoundNamed:@"hullbang.ogg" inFolder:@"Sounds"] retain];
|
||||
destructionSound = [[ResourceManager ooSoundNamed:@"bigbang.ogg" inFolder:@"Sounds"] retain];
|
||||
breakPatternSound = [[ResourceManager ooSoundNamed:@"breakpattern.ogg" inFolder:@"Sounds"] retain];
|
||||
//
|
||||
ecmSound = [[ResourceManager ooSoundNamed:@"ecm.ogg" inFolder:@"Sounds"] retain];
|
||||
buySound = [[ResourceManager ooSoundNamed:@"buy.ogg" inFolder:@"Sounds"] retain];
|
||||
sellSound = [[ResourceManager ooSoundNamed:@"sell.ogg" inFolder:@"Sounds"] retain];
|
||||
warningSound = [[ResourceManager ooSoundNamed:@"warning.ogg" inFolder:@"Sounds"] retain];
|
||||
afterburner1Sound = [[ResourceManager ooSoundNamed:@"afterburner1.ogg" inFolder:@"Sounds"] retain];
|
||||
afterburner2Sound = [[ResourceManager ooSoundNamed:@"afterburner2.ogg" inFolder:@"Sounds"] retain];
|
||||
//
|
||||
witchAbortSound = [[ResourceManager ooSoundNamed:@"witchabort.ogg" inFolder:@"Sounds"] retain];
|
||||
//
|
||||
fuelScoopSound = [[ResourceManager ooSoundNamed:@"scoop.ogg" inFolder:@"Sounds"] retain];
|
||||
|
||||
themeMusic = [[ResourceManager ooMusicNamed:@"OoliteTheme.ogg" inFolder:@"Music"] retain];
|
||||
missionMusic = [[ResourceManager ooMusicNamed:@"OoliteTheme.ogg" inFolder:@"Music"] retain];
|
||||
dockingMusic = [[ResourceManager ooMusicNamed:@"BlueDanube.ogg" inFolder:@"Music"] retain];
|
||||
|
||||
refPoint = [[OOSoundReferencePoint alloc] init];
|
||||
interfaceBeepSource = [[OOSoundSource alloc] init];
|
||||
breakPatternSource = [[OOSoundSource alloc] init];
|
||||
ecmSource = [[OOSoundSource alloc] init];
|
||||
}
|
||||
|
||||
|
||||
- (void)destroySound
|
||||
{
|
||||
#ifdef HAVE_SOUND
|
||||
[beepSound release];
|
||||
beepSound = nil;
|
||||
[boopSound release];
|
||||
boopSound = nil;
|
||||
[weaponSound release];
|
||||
weaponSound = nil;
|
||||
[weaponHitSound release];
|
||||
weaponHitSound = nil;
|
||||
[damageSound release];
|
||||
damageSound = nil;
|
||||
[scrapeDamageSound release];
|
||||
scrapeDamageSound = nil;
|
||||
[destructionSound release];
|
||||
destructionSound = nil;
|
||||
[breakPatternSound release];
|
||||
breakPatternSound = nil;
|
||||
|
||||
[ecmSound release];
|
||||
ecmSound = nil;
|
||||
[buySound release];
|
||||
buySound = nil;
|
||||
[sellSound release];
|
||||
sellSound = nil;
|
||||
[warningSound release];
|
||||
warningSound = nil;
|
||||
[afterburner1Sound release];
|
||||
afterburner1Sound = nil;
|
||||
[afterburner2Sound release];
|
||||
afterburner2Sound = nil;
|
||||
|
||||
[witchAbortSound release];
|
||||
witchAbortSound = nil;
|
||||
|
||||
[fuelScoopSound release];
|
||||
fuelScoopSound = nil;
|
||||
|
||||
|
||||
[themeMusic release];
|
||||
themeMusic = nil;
|
||||
[missionMusic release];
|
||||
missionMusic = nil;
|
||||
[dockingMusic release];
|
||||
dockingMusic = nil;
|
||||
|
||||
[refPoint release];
|
||||
refPoint = nil;
|
||||
[interfaceBeepSource release];
|
||||
interfaceBeepSource = nil;
|
||||
[ecmSource release];
|
||||
ecmSource = nil;
|
||||
[breakPatternSource release];
|
||||
breakPatternSource = nil;
|
||||
#endif
|
||||
[beepSound release];
|
||||
beepSound = nil;
|
||||
[boopSound release];
|
||||
boopSound = nil;
|
||||
[weaponSound release];
|
||||
weaponSound = nil;
|
||||
[weaponHitSound release];
|
||||
weaponHitSound = nil;
|
||||
[damageSound release];
|
||||
damageSound = nil;
|
||||
[scrapeDamageSound release];
|
||||
scrapeDamageSound = nil;
|
||||
[destructionSound release];
|
||||
destructionSound = nil;
|
||||
[breakPatternSound release];
|
||||
breakPatternSound = nil;
|
||||
|
||||
[ecmSound release];
|
||||
ecmSound = nil;
|
||||
[buySound release];
|
||||
buySound = nil;
|
||||
[sellSound release];
|
||||
sellSound = nil;
|
||||
[warningSound release];
|
||||
warningSound = nil;
|
||||
[afterburner1Sound release];
|
||||
afterburner1Sound = nil;
|
||||
[afterburner2Sound release];
|
||||
afterburner2Sound = nil;
|
||||
|
||||
[witchAbortSound release];
|
||||
witchAbortSound = nil;
|
||||
|
||||
[fuelScoopSound release];
|
||||
fuelScoopSound = nil;
|
||||
|
||||
|
||||
[themeMusic release];
|
||||
themeMusic = nil;
|
||||
[missionMusic release];
|
||||
missionMusic = nil;
|
||||
[dockingMusic release];
|
||||
dockingMusic = nil;
|
||||
|
||||
[refPoint release];
|
||||
refPoint = nil;
|
||||
[interfaceBeepSource release];
|
||||
interfaceBeepSource = nil;
|
||||
[ecmSource release];
|
||||
ecmSource = nil;
|
||||
[breakPatternSource release];
|
||||
breakPatternSource = nil;
|
||||
}
|
||||
|
||||
|
||||
@ -149,75 +145,76 @@ MA 02110-1301, USA.
|
||||
|
||||
- (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_Beep:
|
||||
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);
|
||||
}
|
||||
case kInterfaceBeep_Boop:
|
||||
sound = boopSound;
|
||||
break;
|
||||
|
||||
#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
|
||||
case kInterfaceBeep_Buy:
|
||||
sound = buySound;
|
||||
break;
|
||||
|
||||
case kInterfaceBeep_Sell:
|
||||
sound = sellSound;
|
||||
break;
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)isBeeping
|
||||
{
|
||||
#ifdef HAVE_SOUND
|
||||
return [interfaceBeepSource isPlaying];
|
||||
#else
|
||||
return NO;
|
||||
#endif
|
||||
return [interfaceBeepSource isPlaying];
|
||||
}
|
||||
|
||||
|
||||
- (void)playECMSound
|
||||
{
|
||||
#ifdef HAVE_SOUND
|
||||
if (![ecmSource isPlaying]) [ecmSource playSound:ecmSound];
|
||||
#endif
|
||||
if (![ecmSource isPlaying]) [ecmSource playSound:ecmSound];
|
||||
}
|
||||
|
||||
|
||||
- (void)stopECMSound
|
||||
{
|
||||
#ifdef HAVE_SOUND
|
||||
[ecmSource stop];
|
||||
#endif
|
||||
[ecmSource stop];
|
||||
}
|
||||
|
||||
|
||||
- (void)playBreakPattern
|
||||
{
|
||||
#ifdef HAVE_SOUND
|
||||
[breakPatternSource playSound:breakPatternSound];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
- (void)playHostileWarning
|
||||
{
|
||||
if (![warningSound isPlaying]) [warningSound play];
|
||||
}
|
||||
|
||||
|
||||
- (void)playAlertConditionRed
|
||||
{
|
||||
if ([warningSound isPlaying]) [warningSound stop];
|
||||
[warningSound play];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -50,7 +50,6 @@ BOOL always_include_addons;
|
||||
+ (NSString *) errors;
|
||||
+ (NSMutableArray *) paths;
|
||||
+ (NSMutableArray *) pathsUsingAddOns:(BOOL) include_addons;
|
||||
+ (BOOL) areRequirementsFulfilled:(NSDictionary*) requirements;
|
||||
+ (void) addExternalPath:(NSString *)filename;
|
||||
|
||||
+ (NSDictionary *) dictionaryFromFilesNamed:(NSString *)filename inFolder:(NSString *)foldername andMerge:(BOOL) mergeFiles;
|
||||
|
@ -31,6 +31,8 @@ MA 02110-1301, USA.
|
||||
#import "OOStringParsing.h"
|
||||
#import "OOPListParsing.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.ResourceManager"
|
||||
|
||||
|
||||
static NSString * const kOOLogDumpSearchPaths = @"searchPaths.dumpAll";
|
||||
static NSString * const kOOLogCacheUpToDate = @"dataCache.upToDate";
|
||||
@ -43,6 +45,14 @@ static NSString * const kOOCacheKeyModificationDates = @"modification dates";
|
||||
|
||||
extern NSDictionary* parseScripts(NSString* script);
|
||||
|
||||
|
||||
@interface ResourceManager (OOPrivate)
|
||||
|
||||
+ (BOOL) areRequirementsFulfilled:(NSDictionary*)requirements forOXP:(NSString *)path;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation ResourceManager
|
||||
|
||||
static NSMutableArray* saved_paths;
|
||||
@ -185,11 +195,9 @@ NSMutableDictionary* surface_cache;
|
||||
int i;
|
||||
if (saved_paths)
|
||||
return saved_paths;
|
||||
if (errors)
|
||||
{
|
||||
[errors release];
|
||||
errors = nil;
|
||||
}
|
||||
|
||||
[errors release];
|
||||
errors = nil;
|
||||
|
||||
NSFileManager *fmgr = [NSFileManager defaultManager];
|
||||
|
||||
@ -261,7 +269,7 @@ NSMutableDictionary* surface_cache;
|
||||
NSDictionary* requires_dic = OODictionaryFromFile(requiresPath);
|
||||
if (requires_dic != nil)
|
||||
{
|
||||
require_test = [ResourceManager areRequirementsFulfilled:requires_dic];
|
||||
require_test = [ResourceManager areRequirementsFulfilled:requires_dic forOXP:possibleExpansionPath];
|
||||
}
|
||||
if (require_test)
|
||||
{
|
||||
@ -269,24 +277,30 @@ NSMutableDictionary* surface_cache;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString* version = (NSString *)[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
|
||||
// NSBeep(); // AppKit
|
||||
if (!failed_parsing)
|
||||
NSString *errorString = nil;
|
||||
|
||||
if (failed_parsing)
|
||||
{
|
||||
NSString* old_errors = errors;
|
||||
errors = [[NSString alloc] initWithFormat:@"%@\n\t'%@' requirements property list could not be parsed",old_errors, [possibleExpansionPath lastPathComponent]];
|
||||
[old_errors release];
|
||||
errorString = [NSString stringWithFormat:@"\t'%@' requirements property list could not be parsed.", [possibleExpansionPath lastPathComponent]];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"ERROR %@ is incompatible with this version %@ of Oolite",possibleExpansionPath,version);
|
||||
if (!errors)
|
||||
errors = [[NSString alloc] initWithFormat:@"\t'%@' is incompatible with version %@ of Oolite",[possibleExpansionPath lastPathComponent],version];
|
||||
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
|
||||
OOLog(@"oxp.versionMismatch", @"ERROR: OXP %@ is incompatible with version %@ of Oolite",possibleExpansionPath,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
|
||||
{
|
||||
NSString* old_errors = errors;
|
||||
errors = [[NSString alloc] initWithFormat:@"%@\n\t'%@' is incompatible with version %@ of Oolite",old_errors,[possibleExpansionPath lastPathComponent],version];
|
||||
[old_errors release];
|
||||
errors = [errorString retain];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -303,17 +317,38 @@ NSMutableDictionary* surface_cache;
|
||||
return file_paths;
|
||||
}
|
||||
|
||||
+ (BOOL) areRequirementsFulfilled:(NSDictionary*) requirements
|
||||
+ (BOOL) areRequirementsFulfilled:(NSDictionary*)requirements forOXP:(NSString *)path
|
||||
{
|
||||
if (!requirements)
|
||||
return YES;
|
||||
if ([requirements objectForKey:@"version"])
|
||||
BOOL result = YES;
|
||||
NSString *requiredVersion;
|
||||
|
||||
if (result)
|
||||
{
|
||||
NSString* version = (NSString *)[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
|
||||
if ([version isLessThan:[requirements objectForKey:@"version"]])
|
||||
return NO;
|
||||
requiredVersion = [requirements objectForKey:@"version"];
|
||||
if (requiredVersion != nil)
|
||||
{
|
||||
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
|
||||
@ -332,7 +367,6 @@ NSMutableDictionary* surface_cache;
|
||||
}
|
||||
if (!paths_to_load)
|
||||
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
|
||||
@ -390,10 +424,7 @@ NSMutableDictionary* surface_cache;
|
||||
}
|
||||
}
|
||||
//
|
||||
if (result)
|
||||
[dictionary_cache setObject:result forKey:dict_key];
|
||||
|
||||
// NSLog(@"DEBUG ResourceManager dictionary_cache keys:\n%@", [dictionary_cache allKeys]);
|
||||
if (result) [dictionary_cache setObject:result forKey:dict_key];
|
||||
|
||||
return [NSDictionary dictionaryWithDictionary:result];
|
||||
}
|
||||
@ -432,7 +463,6 @@ NSMutableDictionary* surface_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];
|
||||
if (!mergeFiles)
|
||||
{
|
||||
@ -621,22 +651,17 @@ NSMutableDictionary* surface_cache;
|
||||
|
||||
filepath = [[filepath stringByDeletingPathExtension] stringByAppendingPathExtension:@"oos"];
|
||||
|
||||
//NSLog(@"looking for oos file: %@", filepath);
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:filepath])
|
||||
{
|
||||
// load and compile oos script
|
||||
NSLog(@"trying to load and parse %@", filepath);
|
||||
NSString *script = [NSString stringWithContentsOfFile:filepath];
|
||||
NSDictionary *scriptDict = parseScripts(script);
|
||||
if (scriptDict) {
|
||||
//NSLog(@"parsed ok, adding to results");
|
||||
[results addObject:scriptDict];
|
||||
}
|
||||
if (scriptDict) [results addObject:scriptDict];
|
||||
}
|
||||
else
|
||||
{
|
||||
filepath = [[filepath stringByDeletingPathExtension] stringByAppendingPathExtension:@"plist"];
|
||||
//NSLog(@"oos not found, looking for plist file: %@", filepath);
|
||||
// All this code replicated from dictionaryFromFileNamed because that method
|
||||
// will traverse all possible locations and any oos files that co-exist with
|
||||
// plist files will probably get their entries overwritten.
|
||||
@ -651,7 +676,6 @@ NSMutableDictionary* surface_cache;
|
||||
{
|
||||
xfilepath = [[(NSString *)[fpaths objectAtIndex:i] stringByAppendingPathComponent:foldername] stringByAppendingPathComponent:filename];
|
||||
filepath = [[xfilepath stringByDeletingPathExtension] stringByAppendingPathExtension:@"oos"];
|
||||
//NSLog(@"looking for oos file: %@", filepath);
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:filepath])
|
||||
{
|
||||
// load and compile oos script
|
||||
@ -659,7 +683,6 @@ NSMutableDictionary* surface_cache;
|
||||
NSString *script = [NSString stringWithContentsOfFile:filepath];
|
||||
NSDictionary *scriptDict = parseScripts(script);
|
||||
if (scriptDict) {
|
||||
//NSLog(@"parsed ok, adding to results");
|
||||
[results addObject:scriptDict];
|
||||
}
|
||||
}
|
||||
@ -686,8 +709,6 @@ NSMutableDictionary* surface_cache;
|
||||
[dictionary_cache setObject:result forKey:dict_key];
|
||||
}
|
||||
|
||||
// NSLog(@"DEBUG ResourceManager dictionary_cache keys:\n%@", [dictionary_cache allKeys]);
|
||||
|
||||
return [NSDictionary dictionaryWithDictionary:result];
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,6 @@ Ringdata ringentity;
|
||||
lifetime -= movement;
|
||||
if (lifetime < 0.0)
|
||||
{
|
||||
//NSLog(@"removing ring %@ movement %.3f delta_t %.3f",self,movement,delta_t);
|
||||
[universe removeEntity:self];
|
||||
}
|
||||
}
|
||||
@ -127,7 +126,6 @@ Ringdata ringentity;
|
||||
{
|
||||
if (basefile)
|
||||
{
|
||||
//NSLog(@"Drawing ring : %@ n_faces %d, n_vertices %d", basefile, n_faces, n_vertices);
|
||||
if (immediate)
|
||||
{
|
||||
#ifdef GNUSTEP
|
||||
|
@ -25,6 +25,9 @@ MA 02110-1301, USA.
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "StringTokeniser.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.OOSCompiler"
|
||||
|
||||
|
||||
@interface NSMutableString (OOScript)
|
||||
|
||||
- (void) replaceString:(NSString*)aString withString:(NSString*)otherString;
|
||||
|
@ -48,6 +48,8 @@ MA 02110-1301, USA.
|
||||
#import "WormholeEntity.h"
|
||||
#import "GuiDisplayGen.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.ShipEntity"
|
||||
|
||||
|
||||
extern NSString * const kOOLogNoteAddShips;
|
||||
extern NSString * const kOOLogSyntaxAddShips;
|
||||
@ -414,7 +416,7 @@ NSString* describeStatus(int some_status)
|
||||
NS_HANDLER
|
||||
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];
|
||||
NS_ENDHANDLER
|
||||
@ -596,14 +598,14 @@ NSString* describeStatus(int some_status)
|
||||
if ([shipinfoDictionary objectForKey:@"escort-role"])
|
||||
{
|
||||
escortRole = (NSString*)[shipinfoDictionary objectForKey:@"escort-role"];
|
||||
if (![[universe getShipWithRole:escortRole] autorelease])
|
||||
if (![[universe newShipWithRole:escortRole] autorelease])
|
||||
escortRole = @"escort";
|
||||
}
|
||||
|
||||
if ([shipinfoDictionary objectForKey:@"escort-ship"])
|
||||
{
|
||||
escortShipKey = (NSString*)[shipinfoDictionary objectForKey:@"escort-ship"];
|
||||
if (![[universe getShip:escortShipKey] autorelease])
|
||||
if (![[universe newShipWithName:escortShipKey] autorelease])
|
||||
escortShipKey = nil;
|
||||
}
|
||||
|
||||
@ -616,9 +618,9 @@ NSString* describeStatus(int some_status)
|
||||
ShipEntity *escorter;
|
||||
|
||||
if (escortShipKey)
|
||||
escorter = [universe getShip:escortShipKey]; // retained
|
||||
escorter = [universe newShipWithName:escortShipKey]; // retained
|
||||
else
|
||||
escorter = [universe getShipWithRole:escortRole]; // retained
|
||||
escorter = [universe newShipWithRole:escortRole]; // retained
|
||||
|
||||
if (!escorter)
|
||||
break;
|
||||
@ -984,7 +986,7 @@ NSString* describeStatus(int some_status)
|
||||
NS_HANDLER
|
||||
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;
|
||||
}
|
||||
else
|
||||
@ -1270,7 +1272,7 @@ NSString* describeStatus(int some_status)
|
||||
{
|
||||
quaternion_normalise(&sub_q);
|
||||
|
||||
subent = [universe getShip:subdesc]; // retained
|
||||
subent = [universe newShipWithName:subdesc]; // retained
|
||||
|
||||
if ((self->isStation)&&([subdesc rangeOfString:@"dock"].location != NSNotFound))
|
||||
[(StationEntity*)self setDockingPortModel:(ShipEntity*)subent :sub_pos :sub_q];
|
||||
@ -1372,7 +1374,7 @@ NSString* describeStatus(int some_status)
|
||||
{
|
||||
if (universe)
|
||||
{
|
||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
||||
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||
[player setScript_target:self];
|
||||
NSArray * setup_actions = (NSArray *)[shipdict objectForKey:KEY_SETUP_ACTIONS];
|
||||
|
||||
@ -2104,8 +2106,8 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
//scripting
|
||||
if ((status == STATUS_IN_FLIGHT)&&([launch_actions count]))
|
||||
{
|
||||
[(PlayerEntity *)[universe entityZero] setScript_target:self];
|
||||
[(PlayerEntity *)[universe entityZero] scriptActions: launch_actions forTarget: self];
|
||||
[[PlayerEntity sharedPlayer] setScript_target:self];
|
||||
[[PlayerEntity sharedPlayer] scriptActions: launch_actions forTarget: self];
|
||||
[launch_actions removeAllObjects];
|
||||
}
|
||||
|
||||
@ -3556,7 +3558,7 @@ void testForShaders()
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"ERROR no basefile for entity %@");
|
||||
OOLog(kOOLogFileNotFound, @"ERROR no basefile for entity %@");
|
||||
}
|
||||
}
|
||||
glShadeModel(GL_SMOOTH);
|
||||
@ -3564,8 +3566,8 @@ void testForShaders()
|
||||
|
||||
NS_HANDLER
|
||||
|
||||
NSLog(@"***** [Entity drawEntity::] encountered exception: %@ : %@ *****",[localException name], [localException reason]);
|
||||
NSLog(@"***** Removing entity %@ from universe *****", self);
|
||||
OOLog(kOOLogException, @"***** [Entity drawEntity::] encountered exception: %@ : %@ *****",[localException name], [localException reason]);
|
||||
OOLog(kOOLogException, @"***** Removing entity %@ from universe *****", self);
|
||||
[universe removeEntity:self];
|
||||
if ([[localException name] hasPrefix:@"Oolite"])
|
||||
[universe handleOoliteException:localException]; // handle these ourself
|
||||
@ -3624,7 +3626,6 @@ void testForShaders()
|
||||
zero_distance = my_owner->zero_distance;
|
||||
if (zero_distance > no_draw_distance)
|
||||
{
|
||||
//NSLog(@"DEBUG - sub entity '%@' too far away to draw", self);
|
||||
return; // TOO FAR AWAY
|
||||
}
|
||||
}
|
||||
@ -3651,8 +3652,6 @@ void testForShaders()
|
||||
glMultMatrixf(rotMatrix);
|
||||
|
||||
[self drawEntity:immediate :translucent];
|
||||
|
||||
// NSLog(@"drawn active entity : %@", basefile);
|
||||
|
||||
}
|
||||
else
|
||||
@ -3847,22 +3846,13 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
||||
{
|
||||
if (scan_class == CLASS_MISSILE)
|
||||
return; // missiles are SUPPOSED to collide!
|
||||
|
||||
// NSLog(@"DEBUG ***** %@ in AVOID COLLISION!", self);
|
||||
|
||||
|
||||
|
||||
ShipEntity* prox_ship = [self proximity_alert];
|
||||
|
||||
if (prox_ship)
|
||||
{
|
||||
// if (self == [universe entityZero])
|
||||
// NSLog(@"DEBUG ***** proximity alert for %@ %d against target %d", name, universal_id, proximity_alert);
|
||||
|
||||
if (previousCondition)
|
||||
{
|
||||
//
|
||||
// NSLog(@"DEBUG ***** avoidCollision dropping previousCondition");
|
||||
//
|
||||
[previousCondition release];
|
||||
previousCondition = nil;
|
||||
}
|
||||
@ -3891,9 +3881,7 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
||||
{
|
||||
if (!previousCondition)
|
||||
return;
|
||||
|
||||
// NSLog(@"DEBUG ***** proximity alert for %@ %d over", name, universal_id, proximity_alert);
|
||||
|
||||
|
||||
behaviour = [(NSNumber*)[previousCondition objectForKey:@"behaviour"] intValue];
|
||||
primaryTarget = [(NSNumber*)[previousCondition objectForKey:@"primaryTarget"] intValue];
|
||||
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
|
||||
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);
|
||||
if (sa_prox < sa_other)
|
||||
{
|
||||
// NSLog(@"DEBUG %@ is already avoiding %@", self, prox);
|
||||
return;
|
||||
}
|
||||
if (sa_prox < sa_other) return;
|
||||
}
|
||||
}
|
||||
proximity_alert = [other universal_id];
|
||||
other->proximity_alert = universal_id;
|
||||
// NSLog(@"DEBUG PROXIMITY ALERT FOR %@ VS %@ == %d", self, other, proximity_alert);
|
||||
}
|
||||
|
||||
- (NSString *) name
|
||||
@ -4145,10 +4128,8 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
||||
int result = AEGIS_NONE;
|
||||
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;
|
||||
|
||||
// check if nearing surface
|
||||
//
|
||||
// if (reportAImessages)
|
||||
// NSLog(@"DEBUG reporting altitude d2(%.2f) - cr2(%.2f) = %.2f", d2, cr2, d2 - cr2);
|
||||
BOOL wasNearPlanetSurface = isNearPlanetSurface;
|
||||
isNearPlanetSurface = (d2 - cr2 < 3600000.0);
|
||||
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 damage = weapon_energy*desired_range/d2;
|
||||
[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];
|
||||
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 setPrimaryAggressor:hunter];
|
||||
[[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
|
||||
{
|
||||
has_escape_pod = NO;
|
||||
//NSLog(@"Escape Pod launched");
|
||||
|
||||
[shipAI setStateMachine:@"nullAI.plist"];
|
||||
[shipAI setState:@"GLOBAL"];
|
||||
behaviour = BEHAVIOUR_IDLE;
|
||||
@ -4721,7 +4696,7 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
||||
//scripting
|
||||
if ([death_actions count])
|
||||
{
|
||||
PlayerEntity* player = (PlayerEntity *)[universe entityZero];
|
||||
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||
|
||||
[player setScript_target: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++)
|
||||
{
|
||||
ShipEntity* rock = [universe getShipWithRole:@"boulder"]; // retain count = 1
|
||||
ShipEntity* rock = [universe newShipWithRole:@"boulder"]; // retain count = 1
|
||||
if (rock)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
ShipEntity* rock = [universe getShipWithRole:@"splinter"]; // retain count = 1
|
||||
ShipEntity* rock = [universe newShipWithRole:@"splinter"]; // retain count = 1
|
||||
if (rock)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
ShipEntity* wreck = [universe getShipWithRole:@"wreckage"]; // retain count = 1
|
||||
ShipEntity* wreck = [universe newShipWithRole:@"wreckage"]; // retain count = 1
|
||||
if (wreck)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
ShipEntity* plate = [universe getShipWithRole:@"alloy"]; // retain count = 1
|
||||
ShipEntity* plate = [universe newShipWithRole:@"alloy"]; // retain count = 1
|
||||
if (plate)
|
||||
{
|
||||
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];
|
||||
|
||||
//
|
||||
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];
|
||||
}
|
||||
|
||||
@ -5160,7 +5135,7 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
|
||||
//scripting
|
||||
if ([death_actions count])
|
||||
{
|
||||
PlayerEntity* player = (PlayerEntity *)[universe entityZero];
|
||||
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||
|
||||
[player setScript_target:self];
|
||||
[player scriptActions: death_actions forTarget: self];
|
||||
@ -5206,7 +5181,6 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
|
||||
int cargo_to_go = max_cargo / 10;
|
||||
while (cargo_to_go > 15)
|
||||
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]];
|
||||
cargo_chance = 100;
|
||||
}
|
||||
@ -5215,7 +5189,6 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
|
||||
int cargo_to_go = max_cargo / 10;
|
||||
while (cargo_to_go > 15)
|
||||
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]];
|
||||
cargo_chance = 100;
|
||||
}
|
||||
@ -5454,11 +5427,9 @@ BOOL class_masslocks(int some_class)
|
||||
Vector my_aim = vector_forward_from_quaternion(q_rotation);
|
||||
Vector my_ref = reference;
|
||||
double aim_cos, ref_cos;
|
||||
//
|
||||
|
||||
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* father = [self owner];
|
||||
GLfloat* r_mat = [father drawRotationMatrix];
|
||||
@ -5492,9 +5463,6 @@ BOOL class_masslocks(int some_class)
|
||||
aim_cos = 0.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
|
||||
{
|
||||
@ -5563,10 +5531,7 @@ BOOL class_masslocks(int some_class)
|
||||
Entity* targent = [self getPrimaryTarget];
|
||||
//
|
||||
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* father = [self owner];
|
||||
GLfloat* r_mat = [father drawRotationMatrix];
|
||||
@ -5604,9 +5569,6 @@ BOOL class_masslocks(int some_class)
|
||||
aim_cos = 0.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
|
||||
{
|
||||
@ -5945,10 +5907,7 @@ BOOL class_masslocks(int some_class)
|
||||
// begin rule-of-thumb manoeuvres
|
||||
stick_pitch = 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..
|
||||
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))
|
||||
{
|
||||
/* 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];
|
||||
|
||||
if ((station_for_docking)&&(station_for_docking->isStation))
|
||||
{
|
||||
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
|
||||
//
|
||||
[self set_weapon_data_from_type:aft_weapon_type];
|
||||
//
|
||||
//
|
||||
|
||||
//NSLog(@"DEBUG %@ should fire aft weapon",name);
|
||||
|
||||
if (shot_time < weapon_recharge_rate)
|
||||
return NO;
|
||||
@ -6236,8 +6160,6 @@ BOOL class_masslocks(int some_class)
|
||||
if (range > randf() * weapon_range)
|
||||
return NO;
|
||||
|
||||
//NSLog(@"DEBUG %@ firing aft weapon",name);
|
||||
|
||||
if (result)
|
||||
{
|
||||
switch (aft_weapon_type)
|
||||
@ -6351,8 +6273,6 @@ BOOL class_masslocks(int some_class)
|
||||
hit_at_range = weapon_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 setColor:laser_color];
|
||||
[shot setScanClass: CLASS_NO_DRAW];
|
||||
@ -6394,8 +6314,6 @@ BOOL class_masslocks(int some_class)
|
||||
|
||||
- (BOOL) fireDirectLaserShot
|
||||
{
|
||||
// NSLog(@"DEBUG %@ %d laser fired direct shot on %@ %d", name, universal_id, [(ShipEntity*)[self getPrimaryTarget] name], primaryTarget);
|
||||
|
||||
GLfloat hit_at_range;
|
||||
Entity* my_target = [self getPrimaryTarget];
|
||||
if (!my_target)
|
||||
@ -6409,8 +6327,6 @@ BOOL class_masslocks(int some_class)
|
||||
else
|
||||
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));
|
||||
q_laser.x += 0.01 * (randf() - 0.5); // randomise aim a little (+/- 0.005)
|
||||
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];
|
||||
|
||||
// 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 setColor:laser_color];
|
||||
@ -6697,13 +6610,13 @@ BOOL class_masslocks(int some_class)
|
||||
|
||||
// custom missiles
|
||||
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 (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
|
||||
missile = [universe getShipWithRole:@"missile"]; // retained
|
||||
missile = [universe newShipWithRole:@"missile"]; // retained
|
||||
}
|
||||
|
||||
if (!missile)
|
||||
@ -6793,7 +6706,7 @@ BOOL class_masslocks(int some_class)
|
||||
return NO;
|
||||
has_energy_bomb = NO;
|
||||
[self setSpeed: max_flight_speed + 300];
|
||||
ShipEntity* bomb = [universe getShipWithRole:@"energy-bomb"];
|
||||
ShipEntity* bomb = [universe newShipWithRole:@"energy-bomb"];
|
||||
if (!bomb)
|
||||
return NO;
|
||||
double start = collision_radius + bomb->collision_radius;
|
||||
@ -6831,7 +6744,7 @@ BOOL class_masslocks(int some_class)
|
||||
[universe addEntity:bomb];
|
||||
[[bomb getAI] setState:@"GLOBAL"];
|
||||
[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];
|
||||
behaviour = BEHAVIOUR_FLEE_TARGET;
|
||||
@ -6854,12 +6767,12 @@ BOOL class_masslocks(int some_class)
|
||||
// check for custom escape pod
|
||||
//
|
||||
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 (!pod)
|
||||
pod = [universe getShipWithRole:@"escape-capsule"]; // retain count = 1
|
||||
pod = [universe newShipWithRole:@"escape-capsule"]; // retain count = 1
|
||||
|
||||
if (pod)
|
||||
{
|
||||
@ -6888,7 +6801,7 @@ BOOL class_masslocks(int some_class)
|
||||
int i;
|
||||
for (i = 1; i < n_pods; i++)
|
||||
{
|
||||
pod = [universe getShipWithRole:@"escape-capsule"];
|
||||
pod = [universe newShipWithRole:@"escape-capsule"];
|
||||
if (pod)
|
||||
{
|
||||
Random_Seed orig = [universe systemSeedForSystemNumber:gen_rnd_number()];
|
||||
@ -7048,9 +6961,6 @@ BOOL class_masslocks(int some_class)
|
||||
|
||||
if (!other)
|
||||
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];
|
||||
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?
|
||||
if (v2b < 0.0f)
|
||||
{
|
||||
if (v2b < -1.0f)
|
||||
{
|
||||
// NSLog(@"MOVING APART! %@ >%.3f %.3f< %@", self, sqrt(distance2(position, opos)), v2b, other);
|
||||
return NO;
|
||||
}
|
||||
if (v2b < -1.0f) return NO;
|
||||
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
|
||||
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)
|
||||
//
|
||||
@ -7190,9 +7090,7 @@ BOOL class_masslocks(int some_class)
|
||||
[other adjustVelocity:vel1a];
|
||||
}
|
||||
}
|
||||
|
||||
// NSLog(@"DEBUG back-off distance is %.3fm\n\n", back_dist);
|
||||
//
|
||||
|
||||
if ((!selfDestroyed)&&(!otherDestroyed))
|
||||
{
|
||||
float t = 10.0 * [universe getTimeDelta]; // 10 ticks
|
||||
@ -7242,18 +7140,12 @@ BOOL class_masslocks(int some_class)
|
||||
|
||||
- (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 (!has_scoop) return NO;
|
||||
// NSLog(@"DEBUG scoop okay");
|
||||
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 (other->scan_class != CLASS_CARGO) return NO;
|
||||
// NSLog(@"DEBUG other scan class is CLASS_CARGO okay");
|
||||
if ([other getCargoType] == CARGO_NOT_CARGO) return NO;
|
||||
// NSLog(@"DEBUG other cargo type is not CARGO_NOT_CARGO okay");
|
||||
|
||||
if (other->isStation)
|
||||
return NO;
|
||||
@ -7320,7 +7212,7 @@ BOOL class_masslocks(int some_class)
|
||||
//scripting
|
||||
if ([actions count])
|
||||
{
|
||||
PlayerEntity* player = (PlayerEntity *)[universe entityZero];
|
||||
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||
|
||||
[player setScript_target:self];
|
||||
[player scriptActions: actions forTarget: other];
|
||||
@ -7341,9 +7233,8 @@ BOOL class_masslocks(int some_class)
|
||||
if (co_amount > 0)
|
||||
{
|
||||
[other setCommodity:co_type andAmount:co_amount]; // belt and braces setting this!
|
||||
if (cargo_flag !=CARGO_FLAG_CANISTERS)
|
||||
cargo_flag = CARGO_FLAG_CANISTERS;
|
||||
//NSLog(@"---> %@ %d scooped %@", name, universal_id, [universe describeCommodity:co_type amount:co_amount]);
|
||||
cargo_flag = CARGO_FLAG_CANISTERS;
|
||||
|
||||
if (isPlayer)
|
||||
{
|
||||
[universe clearPreviousMessage];
|
||||
@ -7536,8 +7427,6 @@ int w_space_seed = 1234567;
|
||||
[shipAI message:@"EXITED_WITCHSPACE"];
|
||||
[universe addEntity:self];
|
||||
|
||||
// NSLog(@"DEBUG Ship: %@ exiting witchspace at %.2f %.2f %.2f", self, position.x, position.y, position.z);
|
||||
|
||||
// witchspace exit effects here
|
||||
ParticleEntity *ring1 = [[ParticleEntity alloc] initHyperringFromShip:self]; // retained
|
||||
[universe addEntity:ring1];
|
||||
@ -7550,9 +7439,7 @@ int w_space_seed = 1234567;
|
||||
|
||||
- (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
|
||||
@ -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:@"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;
|
||||
}
|
||||
|
||||
- (BOOL) acceptAsEscort:(ShipEntity *) other_ship
|
||||
{
|
||||
// can't pair with self
|
||||
if (self == other_ship)
|
||||
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 (self == other_ship) return NO;
|
||||
|
||||
// if not in standard ai mode reject approach
|
||||
if ([shipAI ai_stack_depth] > 1)
|
||||
return NO;
|
||||
|
||||
// NSLog(@"DEBUG pairOK( %@, %@) = %@", roles, [other_ship roles], (pairOK( roles, [other_ship roles]))? @"YES":@"NO");
|
||||
|
||||
if (pairOK( roles, [other_ship roles]))
|
||||
{
|
||||
// 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
|
||||
n_escorts++;
|
||||
|
||||
//debug
|
||||
// NSLog(@"DEBUG ::YES:: %@ accepts escort %@", self, other_ship);
|
||||
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
@ -7680,7 +7557,6 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
|
||||
if (primaryTarget == last_escort_target)
|
||||
{
|
||||
// already deployed escorts onto this target!
|
||||
// NSLog(@"DEBUG attempting to deploy more escorts onto same target - denied");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -7690,8 +7566,6 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
|
||||
if (n_deploy == 0)
|
||||
n_deploy = 1;
|
||||
|
||||
//NSLog(@"DEBUG %@ %d deploying %d escorts", name, universal_id, n_deploy);
|
||||
|
||||
int i_deploy = n_escorts - 1;
|
||||
while ((n_deploy > 0)&&(n_escorts > 0))
|
||||
{
|
||||
@ -7714,9 +7588,6 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
|
||||
i_deploy--;
|
||||
n_deploy--;
|
||||
n_escorts--;
|
||||
//debug
|
||||
//NSLog(@"DEBUG trader %@ %d deploys escort %@ %d", name, universal_id, [escorter name], [escorter universal_id]);
|
||||
//[escorter setReportAImessages:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -7901,7 +7772,6 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
|
||||
- (void) broadcastHitByLaserFrom:(ShipEntity*) aggressor_ship
|
||||
{
|
||||
/*-- 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)
|
||||
return;
|
||||
if (bounty)
|
||||
@ -7915,7 +7785,6 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
|
||||
(scan_class == CLASS_MILITARY)||
|
||||
(scan_class == CLASS_PLAYER)) // only for active ships...
|
||||
{
|
||||
// NSLog(@"DEBUG IN [%@ broadcastHitByLaserFrom:%@]", self, aggressor_ship);
|
||||
int ent_count = universe->n_entities;
|
||||
Entity** uni_entities = universe->sortedEntities; // grab the public sorted list
|
||||
Entity* my_entities[ent_count];
|
||||
@ -7931,7 +7800,6 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
|
||||
ShipEntity* ship = (ShipEntity *)my_entities[i];
|
||||
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 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.f = rand() & 255;
|
||||
seed_RNG_only_for_planet_description(very_random_seed);
|
||||
NSString* expandedMessage = [universe expandDescription:localExpandedMessage forSystem:[universe systemSeed]];
|
||||
NSString* expandedMessage = ExpandDescriptionForCurrentSystem(localExpandedMessage);
|
||||
[self setCommsMessageColor];
|
||||
[other_ship receiveCommsMessage:[NSString stringWithFormat:@"%@:\n %@", name, expandedMessage]];
|
||||
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.
|
||||
- (void) reloadTextures
|
||||
{
|
||||
//NSLog(@"ShipEntity::reloadTextures called, resetting subentities and calling super");
|
||||
int i;
|
||||
for (i = 0; i < [sub_entities count]; i++)
|
||||
{
|
||||
Entity *e = (Entity *)[sub_entities objectAtIndex:i];
|
||||
//NSLog(@"ShipEntity::reloadTextures calling reloadTextures on: %@", [e description]);
|
||||
[e reloadTextures];
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,8 @@ MA 02110-1301, USA.
|
||||
|
||||
#import "OOStringParsing.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.ShipEntityAI"
|
||||
|
||||
|
||||
@implementation ShipEntity (AI)
|
||||
|
||||
@ -384,7 +386,6 @@ MA 02110-1301, USA.
|
||||
{
|
||||
flight_roll = max_flight_roll*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;
|
||||
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)
|
||||
[shipAI message:@"TARGET_FOUND"];
|
||||
else
|
||||
@ -882,8 +881,7 @@ WormholeEntity* whole;
|
||||
// scared - ignore the request;
|
||||
break;
|
||||
|
||||
default :
|
||||
//NSLog(@"%@ %d responding to distress message from %@ %d", name, universal_id, [other name], [other universal_id]);
|
||||
default:
|
||||
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!!
|
||||
[shipAI reactToMessage:@"ACCEPT_DISTRESS_CALL"];
|
||||
@ -1025,31 +1023,15 @@ WormholeEntity* whole;
|
||||
}
|
||||
}
|
||||
|
||||
if (found_target != NO_TARGET)
|
||||
{
|
||||
//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"];
|
||||
if (found_target != NO_TARGET) [shipAI message:@"TARGET_FOUND"];
|
||||
else [shipAI message:@"NOTHING_FOUND"];
|
||||
}
|
||||
|
||||
- (void) fightOrFleeHostiles
|
||||
{
|
||||
//NSLog(@"DEBUG %@ %d considers fightOrFleeHostiles", name, universal_id);
|
||||
// consider deploying escorts
|
||||
//if ([escorts count] > 0)
|
||||
if (n_escorts > 0)
|
||||
{
|
||||
if (found_target == last_escort_target)
|
||||
{
|
||||
//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);
|
||||
if (found_target == last_escort_target) return;
|
||||
|
||||
primaryAggressor = found_target;
|
||||
primaryTarget = found_target;
|
||||
@ -1064,8 +1046,6 @@ WormholeEntity* whole;
|
||||
{
|
||||
if (randf() < 0.50)
|
||||
{
|
||||
//NSLog(@"DEBUG %@ %d decides to launch missile and flee", name, universal_id);
|
||||
|
||||
primaryAggressor = found_target;
|
||||
primaryTarget = found_target;
|
||||
[self fireMissile];
|
||||
@ -1077,15 +1057,12 @@ WormholeEntity* whole;
|
||||
// consider fighting
|
||||
if (energy > max_energy * 0.80)
|
||||
{
|
||||
//NSLog(@"DEBUG %@ %d decides to fight hostiles", name, universal_id);
|
||||
|
||||
primaryAggressor = found_target;
|
||||
//[self performAttack];
|
||||
[shipAI message:@"FIGHTING"];
|
||||
return;
|
||||
}
|
||||
|
||||
//NSLog(@"DEBUG %@ %d decides to flee hostiles", name, universal_id);
|
||||
|
||||
[shipAI message:@"FLEEING"];
|
||||
}
|
||||
|
||||
@ -1105,7 +1082,6 @@ WormholeEntity* whole;
|
||||
int extra = 1 | (ranrot_rand() & 15);
|
||||
[mother setBounty: [mother legal_status] + extra];
|
||||
bounty += extra; // obviously we're dodgier than we thought!
|
||||
// NSLog(@"DEBUG setting new bounty for %@ escorting %@ to %d", self, mother, extra);
|
||||
}
|
||||
//
|
||||
[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 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)
|
||||
{
|
||||
[shipAI message:@"ODDS_LEVEL"];
|
||||
@ -1177,17 +1150,12 @@ WormholeEntity* whole;
|
||||
{
|
||||
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;
|
||||
[shipAI reactToMessage:@"GROUP_ATTACK_TARGET"];
|
||||
return;
|
||||
}
|
||||
|
||||
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];
|
||||
|
||||
if ((!target_ship)||(target_ship->isShip != YES))
|
||||
@ -1730,8 +1698,6 @@ WormholeEntity* whole;
|
||||
}
|
||||
[wh release]; // released
|
||||
}
|
||||
|
||||
// NSLog(@"DEBUG %@ told to enter wormhole %@", self, whole);
|
||||
|
||||
if (!whole)
|
||||
return;
|
||||
@ -1743,7 +1709,7 @@ WormholeEntity* whole;
|
||||
|
||||
- (void) scriptActionOnTarget:(NSString*) action
|
||||
{
|
||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
||||
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||
Entity* targEnt = [universe entityForUniversalID:primaryTarget];
|
||||
if ((targEnt)&&(player))
|
||||
{
|
||||
|
@ -28,7 +28,6 @@ MA 02110-1301, USA.
|
||||
|
||||
#import "Entity.h"
|
||||
|
||||
#define SKY_POINTS 2
|
||||
#define SKY_BILLBOARDS 3
|
||||
|
||||
#define BILLBOARD_DEPTH 50000.0
|
||||
|
@ -26,6 +26,7 @@ MA 02110-1301, USA.
|
||||
|
||||
#import "Entity.h"
|
||||
#import "SkyEntity.h"
|
||||
#import "PlayerEntity.h"
|
||||
|
||||
#import "OOMaths.h"
|
||||
#import "Universe.h"
|
||||
@ -442,7 +443,7 @@ MA 02110-1301, USA.
|
||||
{
|
||||
if (usingVAR)
|
||||
[self OGL_UpdateVAR];
|
||||
Entity* player = [universe entityZero];
|
||||
PlayerEntity *player = [PlayerEntity sharedPlayer];
|
||||
zero_distance = MAX_CLEAR_DEPTH * MAX_CLEAR_DEPTH;
|
||||
position = (player)? player->position : position;
|
||||
}
|
||||
@ -471,10 +472,6 @@ MA 02110-1301, USA.
|
||||
{
|
||||
switch (sky_type)
|
||||
{
|
||||
case SKY_POINTS :
|
||||
NSLog(@"ERROR: SkyEntity SKY_POINTS deprecated");
|
||||
break;
|
||||
|
||||
case SKY_BILLBOARDS :
|
||||
|
||||
if ((star_textureName == 0)&&(universe))
|
||||
@ -492,10 +489,6 @@ MA 02110-1301, USA.
|
||||
if (usingVAR)
|
||||
glBindVertexArrayAPPLE(gVertexArrayRangeObjects[0]);
|
||||
#endif
|
||||
|
||||
// if (usingVAR)
|
||||
// NSLog(@"DEBUG using accelerated memory technique to draw %@ (%@)", self, basefile);
|
||||
//
|
||||
glBindTexture(GL_TEXTURE_2D, star_textureName);
|
||||
|
||||
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.
|
||||
- (void) reloadTextures
|
||||
{
|
||||
//NSLog(@"SkyEntity::reloadTextures called, calling super and resetTextureNames");
|
||||
|
||||
// Force the sky textures to be reloaded next time a frame is drawn.
|
||||
star_textureName = 0;
|
||||
blob_textureName = 0;
|
||||
|
@ -36,16 +36,14 @@ MA 02110-1301, USA.
|
||||
#import "AI.h"
|
||||
#import "OOCharacter.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.StationEntity"
|
||||
|
||||
|
||||
@implementation StationEntity
|
||||
|
||||
- (void) acceptDistressMessageFrom:(ShipEntity *)other
|
||||
{
|
||||
if (self != [universe station])
|
||||
{
|
||||
//NSLog(@"DEBUG acceptDistressMessageFrom rejected from sub-station '%@'", name);
|
||||
return;
|
||||
}
|
||||
if (self != [universe station]) return;
|
||||
|
||||
int old_target = primaryTarget;
|
||||
primaryTarget = [[other getPrimaryTarget] universal_id];
|
||||
@ -147,7 +145,6 @@ MA 02110-1301, USA.
|
||||
|
||||
- (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 economy = [(NSNumber *)[[universe generateSystemData:s_seed] objectForKey:KEY_ECONOMY] intValue];
|
||||
if (localMarket)
|
||||
@ -158,19 +155,17 @@ MA 02110-1301, USA.
|
||||
|
||||
- (NSMutableArray *) initialiseLocalPassengersWithSeed: (Random_Seed) s_seed andRandomFactor: (int) random_factor
|
||||
{
|
||||
//NSLog(@"///// Initialising local market for station %@ with roles %@",self,[self roles]);
|
||||
if (localPassengers)
|
||||
[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;
|
||||
}
|
||||
|
||||
- (NSMutableArray *) initialiseLocalContractsWithSeed: (Random_Seed) s_seed andRandomFactor: (int) random_factor
|
||||
{
|
||||
//NSLog(@"///// Initialising local market for station %@ with roles %@",self,[self roles]);
|
||||
if (localContracts)
|
||||
[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;
|
||||
}
|
||||
|
||||
@ -423,10 +418,6 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
||||
Vector delta = ship->position;
|
||||
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 ((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_final_approach = 3;
|
||||
|
||||
// NSLog(@"DEBUG adding %@ to shipsOnApproach", ship);
|
||||
|
||||
int ship_id = [ship universal_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
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
// NSLog(@"DEBUG returning UP !");
|
||||
return vector_up_from_quaternion( quaternion_multiply( port_qrotation, q_rotation));
|
||||
}
|
||||
else
|
||||
{
|
||||
// NSLog(@"DEBUG returning RIGHT !");
|
||||
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));
|
||||
|
||||
// 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)
|
||||
{
|
||||
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];
|
||||
|
||||
//NSLog(@"DEBUG setting up station '%@' from dict:%@",name,[dict description]);
|
||||
|
||||
if ([dict objectForKey:@"equivalent_tech_level"])
|
||||
equivalent_tech_level = [(NSNumber *)[dict objectForKey:@"equivalent_tech_level"] intValue];
|
||||
else
|
||||
@ -1043,7 +1024,6 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
||||
if (vdp > 0.86)
|
||||
{
|
||||
isEmpty = NO;
|
||||
// NSLog(@"DEBUG %@ is blocking %@ launch corridor distance = %.0f (%.0f).", ship, self, sqrt(d2), d2);
|
||||
last_launch_time = unitime;
|
||||
}
|
||||
}
|
||||
@ -1101,8 +1081,8 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
||||
if (vdp > 0.86)
|
||||
{
|
||||
isClear = NO;
|
||||
|
||||
// okay it's in the way .. give it a wee nudge (0.25s)
|
||||
// NSLog(@"DEBUG [StationEntity clearDockingCorridor] nudging %@", ship);
|
||||
[ship update: 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];
|
||||
|
||||
// if (sub_entities)
|
||||
// NSLog(@"DEBUG %@ sub_entities %@", [self name], [sub_entities description]);
|
||||
|
||||
[super update:delta_t];
|
||||
|
||||
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))
|
||||
{
|
||||
// NSLog(@"DEBUG1 %f %f", 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];
|
||||
docked_traders--;
|
||||
last_trader_launch_time = unitime;
|
||||
@ -1173,7 +1148,6 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
||||
// testing patrols
|
||||
if ((unitime > last_patrol_report_time + patrol_launch_interval)&&(isMainStation))
|
||||
{
|
||||
// NSLog(@"%@ %d (%@) launching a patrol...", name, universal_id, roles);
|
||||
if (![self launchPatrol])
|
||||
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))
|
||||
id_lock[i] = NO_TARGET;
|
||||
|
||||
if (ship == [universe entityZero]) // ie. the player
|
||||
if (ship == [PlayerEntity sharedPlayer]) // ie. the player
|
||||
{
|
||||
//scripting
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
// 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"];
|
||||
return;
|
||||
}
|
||||
|
||||
//NSLog(@"Launching Police Ship to intercept %@",[universe entityForUniversalID:police_target]);
|
||||
|
||||
if ((ranrot_rand() & 7) + 6 <= techlevel)
|
||||
police_ship = [universe getShipWithRole:@"interceptor"]; // retain count = 1
|
||||
police_ship = [universe newShipWithRole:@"interceptor"]; // retain count = 1
|
||||
else
|
||||
police_ship = [universe getShipWithRole:@"police"]; // retain count = 1
|
||||
police_ship = [universe newShipWithRole:@"police"]; // retain count = 1
|
||||
if (police_ship)
|
||||
{
|
||||
if (![police_ship crew])
|
||||
@ -1415,29 +1383,23 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
||||
|
||||
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_ai = nil;
|
||||
}
|
||||
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_ai = nil;
|
||||
}
|
||||
|
||||
// NSLog(@"DEBUG Launching defense ship to intercept %@",[(ShipEntity *)[universe entityForUniversalID:defense_target] name]);
|
||||
|
||||
if (defense_ship_key)
|
||||
{
|
||||
defense_ship = [universe getShip:defense_ship_key];
|
||||
// NSLog(@"DEBUG launchDefenseShip Got ship with defense_ship '%@' : %@", defense_ship_key, defense_ship);
|
||||
defense_ship = [universe newShipWithName:defense_ship_key];
|
||||
[defense_ship setRoles:@"defense_ship"];
|
||||
}
|
||||
else
|
||||
{
|
||||
defense_ship = [universe getShipWithRole:defense_ship_role_key];
|
||||
// NSLog(@"DEBUG launchDefenseShip Got ship with defense_ship_role '%@' : %@", defense_ship_role_key, defense_ship);
|
||||
defense_ship = [universe newShipWithRole:defense_ship_role_key];
|
||||
[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))
|
||||
[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];
|
||||
[defense_ship release];
|
||||
no_docking_while_launching = YES;
|
||||
[self abortAllDockings];
|
||||
|
||||
// NSLog(@"DEBUG Launchqueue : %@",[launchQueue description]);
|
||||
|
||||
}
|
||||
|
||||
- (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"];
|
||||
|
||||
if (scavs >= max_scavengers)
|
||||
return;
|
||||
|
||||
if (scavengers_launched >= max_scavengers)
|
||||
return;
|
||||
|
||||
//NSLog(@"Launching Scavenger");
|
||||
if (scavs >= max_scavengers) return;
|
||||
if (scavengers_launched >= max_scavengers) return;
|
||||
|
||||
scavengers_launched++;
|
||||
|
||||
scavenger_ship = [universe getShipWithRole:@"scavenger"]; // retain count = 1
|
||||
scavenger_ship = [universe newShipWithRole:@"scavenger"]; // retain count = 1
|
||||
if (scavenger_ship)
|
||||
{
|
||||
if (![scavenger_ship crew])
|
||||
@ -1518,13 +1469,9 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
||||
return;
|
||||
|
||||
// count miners as scavengers...
|
||||
//
|
||||
if (scavengers_launched >= max_scavengers)
|
||||
return;
|
||||
//
|
||||
// NSLog(@"Launching Miner");
|
||||
//
|
||||
miner_ship = [universe getShipWithRole:@"miner"]; // retain count = 1
|
||||
if (scavengers_launched >= max_scavengers) return;
|
||||
|
||||
miner_ship = [universe newShipWithRole:@"miner"]; // retain count = 1
|
||||
if (miner_ship)
|
||||
{
|
||||
if (![miner_ship crew])
|
||||
@ -1557,12 +1504,10 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
||||
return;
|
||||
}
|
||||
|
||||
//NSLog(@"Launching pirate Ship to intercept %@",[(ShipEntity *)[universe entityForUniversalID:defense_target] name]); //debug
|
||||
|
||||
police_launched++;
|
||||
|
||||
// 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.
|
||||
|
||||
if (pirate_ship)
|
||||
@ -1594,7 +1539,7 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
||||
{
|
||||
ShipEntity *shuttle_ship;
|
||||
|
||||
shuttle_ship = [universe getShipWithRole:@"shuttle"]; // retain count = 1
|
||||
shuttle_ship = [universe newShipWithRole:@"shuttle"]; // retain count = 1
|
||||
|
||||
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 getAI] setStateMachine:@"fallingShuttleAI.plist"];
|
||||
[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];
|
||||
}
|
||||
@ -1621,19 +1563,8 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
||||
BOOL sunskimmer = (randf() < 0.1); // 10%
|
||||
ShipEntity *trader_ship = nil;
|
||||
|
||||
// NSLog(@"DEBUG %@ [StationEntity launchTrader]", self);
|
||||
|
||||
// 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 (!sunskimmer) trader_ship = [universe newShipWithRole:@"trader"]; // retain count = 1
|
||||
else trader_ship = [universe newShipWithRole:@"sunskim-trader"]; // retain count = 1
|
||||
|
||||
if (trader_ship)
|
||||
{
|
||||
@ -1663,8 +1594,6 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
||||
[trader_ship setN_escorts:0];
|
||||
while (escorts--)
|
||||
[self launchEscort];
|
||||
|
||||
// NSLog(@"%@ Prepping trader: %@ %d for launch.", [self name], [trader_ship name], [trader_ship universal_id]);
|
||||
|
||||
[trader_ship release];
|
||||
}
|
||||
@ -1674,7 +1603,7 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
||||
{
|
||||
ShipEntity *escort_ship;
|
||||
|
||||
escort_ship = [universe getShipWithRole:@"escort"]; // retain count = 1
|
||||
escort_ship = [universe newShipWithRole:@"escort"]; // retain count = 1
|
||||
|
||||
if (escort_ship)
|
||||
{
|
||||
@ -1689,8 +1618,6 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
||||
[[escort_ship getAI] setStateMachine:@"escortAI.plist"];
|
||||
[self addShipToLaunchQueue:escort_ship];
|
||||
|
||||
// [escort_ship setReportAImessages: YES];
|
||||
|
||||
[escort_ship release];
|
||||
}
|
||||
}
|
||||
@ -1708,9 +1635,9 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
||||
police_launched++;
|
||||
|
||||
if ((ranrot_rand() & 7) + 6 <= techlevel)
|
||||
patrol_ship = [universe getShipWithRole:@"interceptor"]; // retain count = 1
|
||||
patrol_ship = [universe newShipWithRole:@"interceptor"]; // retain count = 1
|
||||
else
|
||||
patrol_ship = [universe getShipWithRole:@"police"]; // retain count = 1
|
||||
patrol_ship = [universe newShipWithRole:@"police"]; // retain count = 1
|
||||
if (patrol_ship)
|
||||
{
|
||||
if (![patrol_ship crew])
|
||||
@ -1736,7 +1663,7 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
||||
|
||||
- (void) launchShipWithRole:(NSString*) role
|
||||
{
|
||||
ShipEntity *ship = [universe getShipWithRole: role]; // retain count = 1
|
||||
ShipEntity *ship = [universe newShipWithRole: role]; // retain count = 1
|
||||
if (ship)
|
||||
{
|
||||
if (![ship crew])
|
||||
@ -1754,7 +1681,7 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
||||
- (void) becomeExplosion
|
||||
{
|
||||
// launch docked ships if possible
|
||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
||||
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||
if ((player)&&(player->status == STATUS_DOCKED)&&([player docked_station] == self))
|
||||
{
|
||||
// undock the player!
|
||||
@ -1778,19 +1705,13 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
||||
- (void) acceptPatrolReportFrom:(ShipEntity*) patrol_ship
|
||||
{
|
||||
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
|
||||
{
|
||||
if (self != [universe station])
|
||||
{
|
||||
//NSLog(@"DEBUG acceptDistressMessageFrom rejected from sub-station '%@'", name);
|
||||
return;
|
||||
}
|
||||
if (self != [universe station]) return;
|
||||
|
||||
// check
|
||||
//
|
||||
if ([shipsOnApproach count])
|
||||
{
|
||||
[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;
|
||||
if ([shipinfoDictionary objectForKey:@"hasShipyard"])
|
||||
{
|
||||
PlayerEntity *player = (PlayerEntity*)[universe entityZero];
|
||||
PlayerEntity *player = [PlayerEntity sharedPlayer];
|
||||
NSObject *determinant = [shipinfoDictionary objectForKey:@"hasShipyard"];
|
||||
if ([determinant isKindOfClass:[NSArray class]])
|
||||
{
|
||||
|
@ -34,6 +34,8 @@ MA 02110-1301, USA.
|
||||
#import "OOTextureScaling.h"
|
||||
#import "OOStringParsing.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.TextureStore"
|
||||
|
||||
|
||||
static NSString * const kOOLogPlanetTextureGen = @"texture.planet.generate";
|
||||
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);
|
||||
max_texture_dimension = result;
|
||||
done_maxsize_test = YES;
|
||||
// NSLog(@"TESTING: GL_MAX_TEXTURE_SIZE = %d", max_texture_dimension);
|
||||
return max_texture_dimension;
|
||||
}
|
||||
|
||||
@ -122,8 +123,6 @@ GLuint max_texture_dimension = 512; // conservative start
|
||||
#ifndef GNUSTEP
|
||||
NSArray* reps = [texImage representations];
|
||||
|
||||
// NSLog(@"DEBUG texture %@ representations:\n%@", filename, reps);
|
||||
|
||||
int 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))
|
||||
{
|
||||
// NSLog(@"DEBUG filling image data for %@ (%d x %d) with special sauce!", filename, texture_w, texture_h);
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
@ -385,7 +383,7 @@ GLuint max_texture_dimension = 512; // conservative start
|
||||
char log[1024];
|
||||
GLsizei log_length;
|
||||
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;
|
||||
}
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
@ -644,7 +642,6 @@ void fillSquareImageDataWithBlur(unsigned char * imageBuffer, int width, int npl
|
||||
|
||||
if ((i_error > 1.0)&&(i < 255))
|
||||
{
|
||||
// NSLog(@"DEBUG err correct");
|
||||
i_error -= 1.0;
|
||||
i++;
|
||||
}
|
||||
|
@ -234,7 +234,6 @@ extern int debug;
|
||||
StationEntity* cachedStation;
|
||||
PlanetEntity* cachedPlanet;
|
||||
PlanetEntity* cachedSun;
|
||||
Entity* cachedEntityZero;
|
||||
|
||||
BOOL strict;
|
||||
|
||||
@ -324,10 +323,10 @@ extern int debug;
|
||||
- (BOOL) breakPatternHide;
|
||||
|
||||
- (id) recycleOrDiscard:(Entity *) entity;
|
||||
- (Entity *) recycledOrNew:(NSString *) classname;
|
||||
- (Entity *) allocRecycledOrNewEntity:(NSString *) classname;
|
||||
|
||||
- (ShipEntity *) getShipWithRole:(NSString *) desc;
|
||||
- (ShipEntity *) getShip:(NSString *) desc;
|
||||
- (ShipEntity *) newShipWithRole:(NSString *) desc;
|
||||
- (ShipEntity *) newShipWithName:(NSString *) desc;
|
||||
- (NSDictionary *) getDictionaryForShip:(NSString *) desc;
|
||||
|
||||
- (int) maxCargoForShip:(NSString *) desc;
|
||||
@ -357,7 +356,6 @@ extern int debug;
|
||||
- (void) drawCrosshairs;
|
||||
- (void) drawMessage;
|
||||
|
||||
- (id)entityZero;
|
||||
- (id)entityForUniversalID:(int)u_id;
|
||||
|
||||
BOOL maintainLinkedLists(Universe* uni);
|
||||
@ -435,7 +433,6 @@ BOOL maintainLinkedLists(Universe* uni);
|
||||
- (NSString *) generateSystemInhabitants:(Random_Seed) s_seed plural:(BOOL)plural;
|
||||
- (Random_Seed) findSystemAtCoords:(NSPoint) coords withGalaxySeed:(Random_Seed) gal_seed;
|
||||
|
||||
+ (NSString*) systemSeedString:(Random_Seed) s;
|
||||
- (NSArray*) nearbyDestinationsWithinRange:(double) range;
|
||||
- (Random_Seed) findNeighbouringSystemToCoords:(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*) 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;
|
||||
- (Quaternion) getWitchspaceExitRotation;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -27,10 +27,12 @@ MA 02110-1301, USA.
|
||||
#import "ParticleEntity.h"
|
||||
#import "ShipEntity.h"
|
||||
#import "PlanetEntity.h"
|
||||
#import "PlayerEntity.h"
|
||||
|
||||
#import "Universe.h"
|
||||
#import "AI.h"
|
||||
#import "TextureStore.h"
|
||||
#import "OOStringParsing.h"
|
||||
|
||||
|
||||
@implementation WormholeEntity
|
||||
@ -61,14 +63,12 @@ MA 02110-1301, USA.
|
||||
//
|
||||
position = [ship getPosition];
|
||||
//
|
||||
Entity* player = [universe entityZero];
|
||||
PlayerEntity *player = [PlayerEntity sharedPlayer];
|
||||
if (player)
|
||||
zero_distance = distance2( player->position, position);
|
||||
//
|
||||
isWormhole = YES;
|
||||
//
|
||||
// NSLog(@"DEBUG %@ created!", self);
|
||||
//
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -87,8 +87,6 @@ MA 02110-1301, USA.
|
||||
expiry_time = time_counter + WORMHOLE_EXPIRES_TIMEINTERVAL;
|
||||
collision_radius = 0.5 * PI * pow( witch_mass, 1.0/3.0);
|
||||
|
||||
// NSLog(@"DEBUG %@ sucks in %@", self, ship);
|
||||
|
||||
// witchspace entry effects here
|
||||
ParticleEntity *ring = [[ParticleEntity alloc] initHyperringFromShip:ship]; // retained
|
||||
[universe addEntity:ring];
|
||||
@ -112,8 +110,6 @@ MA 02110-1301, USA.
|
||||
|
||||
- (void) disgorgeShips
|
||||
{
|
||||
// NSLog(@"disgorging %@", shipsInTransit);
|
||||
|
||||
int n_ships = [shipsInTransit count];
|
||||
|
||||
int i;
|
||||
@ -147,10 +143,6 @@ MA 02110-1301, USA.
|
||||
|
||||
[[ship getAI] reactToMessage:@"EXITED WITCHSPACE"];
|
||||
|
||||
// [ship setReportAImessages:YES]; // DEBUG
|
||||
|
||||
// NSLog(@"DEBUG %@ disgorged %@", self, ship);
|
||||
|
||||
// update the ships's position
|
||||
[ship update: time_passed];
|
||||
}
|
||||
@ -170,7 +162,7 @@ MA 02110-1301, USA.
|
||||
|
||||
- (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];
|
||||
}
|
||||
|
||||
@ -190,7 +182,7 @@ MA 02110-1301, USA.
|
||||
{
|
||||
[super update:delta_t];
|
||||
|
||||
Entity* player = [universe entityZero];
|
||||
Entity* player = [PlayerEntity sharedPlayer];
|
||||
if (player)
|
||||
{
|
||||
// new billboard routine (from Planetentity.m)
|
||||
|
@ -24,6 +24,10 @@ MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#import "JoystickHandler.h"
|
||||
#import "OOLogging.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.JoystickHandler"
|
||||
|
||||
|
||||
@implementation JoystickHandler
|
||||
|
||||
|
@ -38,6 +38,8 @@ MA 02110-1301, USA.
|
||||
#import "TextureStore.h"
|
||||
#endif
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.MyOpenGLView"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
@implementation MyOpenGLView
|
||||
|
@ -23,6 +23,9 @@ MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "SDLMusic.h"
|
||||
#import "OOLogging.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.SDLMusic"
|
||||
|
||||
/*
|
||||
* 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 "OOBasicSoundSource.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.SDLSound"
|
||||
|
||||
|
||||
static int mixChan=0;
|
||||
static float masterVol=1.0;
|
||||
@ -148,7 +150,6 @@ static BOOL isSetUp=NO;
|
||||
[super init];
|
||||
if(!isSetUp) [OOSound setUp];
|
||||
|
||||
//NSLog(@"loading sample: %s", [filepath cString]);
|
||||
sample = Mix_LoadWAV([filepath cString]);
|
||||
if (!sample) {
|
||||
NSLog(@"Mix_LoadWAV: %s\n", Mix_GetError());
|
||||
|
Loading…
x
Reference in New Issue
Block a user