- Applied pv4's patch to trunk, with modifications.
* ship.target = null now works as expected. * adding trumbles to a ship has now got variable chance of working, depending on how many trumbles are already on board. Always works with 0 or very few trumbles. - more cleanup: removed a windows compile warning, added a possible freeBSD bugfix, updated a js comment & autoindented Universe.m git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@2720 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
b5315d49e8
commit
03a1728895
@ -46,7 +46,7 @@ this.missionOffers = function ()
|
||||
{
|
||||
if (guiScreen === "GUI_SCREEN_MISSION" || guiScreen === "GUI_SCREEN_REPORT" || (mission.choice && mission.choice !== "") || !player.ship.docked) { return; }
|
||||
|
||||
// there will be a "missionScreenEnded" or a "missionChoiceWasReset" in future to react to.
|
||||
// Choices are handled inside the missionScreenEnded and missionChoiceWasReset events.
|
||||
if (player.ship.dockedStation.isMainStation)
|
||||
{
|
||||
if (galaxyNumber === 3)
|
||||
|
@ -4758,7 +4758,6 @@ static PlayerEntity *sSharedPlayer = nil;
|
||||
[UNIVERSE setDisplayText: YES];
|
||||
[UNIVERSE setDisplayCursor: NO];
|
||||
[UNIVERSE setViewDirection: VIEW_GUI_DISPLAY];
|
||||
|
||||
|
||||
// if the system has gone nova, display the sun instead of the planet
|
||||
if (sunGoneNova)
|
||||
@ -4813,8 +4812,6 @@ static PlayerEntity *sSharedPlayer = nil;
|
||||
- (void) setGuiToLongRangeChartScreen
|
||||
{
|
||||
NSString *targetSystemName;
|
||||
double distance = distanceBetweenPlanetPositions(target_system_seed.d,target_system_seed.b,galaxy_coordinates.x,galaxy_coordinates.y);
|
||||
double estimatedTravelTime = distance * distance;
|
||||
|
||||
if ((target_system_seed.d != cursor_coordinates.x)||(target_system_seed.b != cursor_coordinates.y))
|
||||
target_system_seed = [UNIVERSE findSystemAtCoords:cursor_coordinates withGalaxySeed:galaxy_seed];
|
||||
@ -4828,8 +4825,6 @@ static PlayerEntity *sSharedPlayer = nil;
|
||||
[gui setTitle:[NSString stringWithFormat:DESC(@"long-range-chart-title-d"), galaxy_number+1]];
|
||||
|
||||
[gui setText:targetSystemName forRow:17];
|
||||
[gui setText:[NSString stringWithFormat:DESC(@"long-range-chart-distance-f"), distance] forRow:18];
|
||||
[gui setText:(distance <= (fuel/10.0f) ? [NSString stringWithFormat:DESC(@"long-range-chart-est-travel-time-f"), estimatedTravelTime] : (id)@"") forRow:19];
|
||||
|
||||
NSString *displaySearchString = planetSearchString ? [planetSearchString capitalizedString] : (NSString *)@"";
|
||||
[gui setText:[NSString stringWithFormat:DESC(@"long-range-chart-find-planet-@"), displaySearchString] forRow:16];
|
||||
@ -6344,9 +6339,10 @@ static NSString *last_outfitting_key=nil;
|
||||
details.
|
||||
-- Ahruman 2008-12-04
|
||||
*/
|
||||
if (trumbleCount < 1)
|
||||
// the old trumbles will kill the new one if there are enough of them.
|
||||
if ((trumbleCount < PLAYER_MAX_TRUMBLES / 4) || (trumbleCount < PLAYER_MAX_TRUMBLES / 2 && ranrot_rand() % 2 > 0))
|
||||
{
|
||||
[self addTrumble:trumble[ranrot_rand() % PLAYER_MAX_TRUMBLES]]; // first one!
|
||||
[self addTrumble:trumble[ranrot_rand() % PLAYER_MAX_TRUMBLES]]; // first/new one
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ OOINLINE BOOL RowInRange(OOGUIRow row, NSRange range)
|
||||
- (void) drawStarChart:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha;
|
||||
- (void) drawGalaxyChart:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha;
|
||||
- (void) drawEqptList: (NSArray *)eqptList z:(GLfloat)z;
|
||||
- (void) drawAdvancedNavArrayAtX:(float)x y:(float)y z:(float)z alpha:(float)alpha optimizedFor:(unsigned)distanceOrTime;
|
||||
- (void) drawAdvancedNavArrayAtX:(float)x y:(float)y z:(float)z alpha:(float)alpha usingRoute:(NSDictionary *) route optimizedBy:(OORouteType) optimizeBy;
|
||||
|
||||
@end
|
||||
|
||||
@ -1328,10 +1328,10 @@ OOINLINE BOOL RowInRange(OOGUIRow row, NSRange range)
|
||||
|
||||
- (void) drawGalaxyChart:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha
|
||||
{
|
||||
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||
|
||||
NSPoint galaxy_coordinates = [player galaxy_coordinates];
|
||||
NSPoint cursor_coordinates = [player cursor_coordinates];
|
||||
PlayerEntity* player = [PlayerEntity sharedPlayer];
|
||||
NSPoint galaxy_coordinates = [player galaxy_coordinates];
|
||||
NSPoint cursor_coordinates = [player cursor_coordinates];
|
||||
Random_Seed galaxy_seed = [player galaxy_seed];
|
||||
|
||||
double fuel = 35.0 * [player dialFuel];
|
||||
|
||||
@ -1347,12 +1347,33 @@ OOINLINE BOOL RowInRange(OOGUIRow row, NSRange range)
|
||||
double vscale = -1.0 * size_in_pixels.height / 512.0;
|
||||
double hoffset = 0.0f;
|
||||
double voffset = size_in_pixels.height - pixel_title_size.height - 5;
|
||||
int i;
|
||||
OORouteType advancedNavArrayMode = OPTIMIZED_BY_NONE;
|
||||
|
||||
if (showAdvancedNavArray && ![UNIVERSE strict] && [player hasEquipmentItem:@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
|
||||
int i;
|
||||
double distance, time;
|
||||
|
||||
if (showAdvancedNavArray) advancedNavArrayMode = [[UNIVERSE gameView] isCtrlDown] ? OPTIMIZED_BY_TIME : OPTIMIZED_BY_JUMPS;
|
||||
|
||||
if (advancedNavArrayMode != OPTIMIZED_BY_NONE && ![UNIVERSE strict] && [player hasEquipmentItem:@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
|
||||
{
|
||||
[self drawAdvancedNavArrayAtX:x y:y z:z alpha:alpha optimizedFor:[[UNIVERSE gameView] isCtrlDown] ? ROUTE_OPT_TIME : ROUTE_OPT_DISTANCE];
|
||||
int planetNumber = [UNIVERSE findSystemNumberAtCoords:galaxy_coordinates withGalaxySeed:galaxy_seed];
|
||||
int destNumber = [UNIVERSE findSystemNumberAtCoords:cursor_coordinates withGalaxySeed:galaxy_seed];
|
||||
NSDictionary* routeInfo = [UNIVERSE routeFromSystem:planetNumber toSystem:destNumber optimizedBy:advancedNavArrayMode];
|
||||
|
||||
[self drawAdvancedNavArrayAtX:x y:y z:z alpha:alpha usingRoute: (planetNumber != destNumber ? routeInfo : nil) optimizedBy:advancedNavArrayMode];
|
||||
distance = [routeInfo oo_doubleForKey:@"distance"];
|
||||
time = [routeInfo oo_doubleForKey:@"time"];
|
||||
}
|
||||
else
|
||||
{
|
||||
Random_Seed dest = [UNIVERSE findSystemAtCoords:cursor_coordinates withGalaxySeed:galaxy_seed];
|
||||
distance = distanceBetweenPlanetPositions(dest.d,dest.b,galaxy_coordinates.x,galaxy_coordinates.y);
|
||||
time = distance * distance;
|
||||
}
|
||||
|
||||
[self setText:[NSString stringWithFormat:DESC(@"long-range-chart-distance-f"), distance] forRow:18];
|
||||
[self setText:(advancedNavArrayMode != OPTIMIZED_BY_NONE ?
|
||||
[NSString stringWithFormat:DESC(@"long-range-chart-est-travel-time-f"), time] : @"") forRow:19];
|
||||
|
||||
// draw fuel range circle
|
||||
//
|
||||
@ -1490,12 +1511,9 @@ OOINLINE BOOL RowInRange(OOGUIRow row, NSRange range)
|
||||
|
||||
|
||||
// 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 optimizedFor:(unsigned)distanceOrTime
|
||||
- (void) drawAdvancedNavArrayAtX:(float)x y:(float)y z:(float)z alpha:(float)alpha usingRoute:(NSDictionary *) routeInfo optimizedBy:(OORouteType) optimizeBy
|
||||
{
|
||||
PlayerEntity *player = [PlayerEntity sharedPlayer];
|
||||
NSPoint galaxy_coordinates = [player galaxy_coordinates];
|
||||
NSPoint cursor_coordinates = [player cursor_coordinates];
|
||||
Random_Seed galaxy_seed = [player galaxy_seed];
|
||||
Random_Seed g_seed, g_seed2;
|
||||
int i, j;
|
||||
double hscale = size_in_pixels.width / 256.0;
|
||||
@ -1526,16 +1544,11 @@ OOINLINE BOOL RowInRange(OOGUIRow row, NSRange range)
|
||||
}
|
||||
glEnd();
|
||||
|
||||
// Draw route from player position to currently selected destination.
|
||||
int planetNumber = [UNIVERSE findSystemNumberAtCoords:galaxy_coordinates withGalaxySeed:galaxy_seed];
|
||||
int destNumber = [UNIVERSE findSystemNumberAtCoords:cursor_coordinates withGalaxySeed:galaxy_seed];
|
||||
NSDictionary* routeInfo = [UNIVERSE routeFromSystem:planetNumber toSystem:destNumber optimizedFor:distanceOrTime];
|
||||
|
||||
if ((destNumber != planetNumber) && routeInfo)
|
||||
if (routeInfo)
|
||||
{
|
||||
int route_hops = [(NSArray *)[routeInfo objectForKey:@"route"] count] -1;
|
||||
|
||||
if (distanceOrTime == ROUTE_OPT_DISTANCE)
|
||||
if (optimizeBy == OPTIMIZED_BY_JUMPS)
|
||||
{
|
||||
glColor4f (1.0f, 1.0f, 0.0f, alpha); // Yellow for plotting routes optimized for distance.
|
||||
}
|
||||
@ -1543,13 +1556,13 @@ OOINLINE BOOL RowInRange(OOGUIRow row, NSRange range)
|
||||
{
|
||||
glColor4f (0.0f, 1.0f, 1.0f, alpha); // Cyan for plotting routes optimized for time.
|
||||
}
|
||||
int loc;
|
||||
for (i = 0; i < route_hops; i++)
|
||||
{
|
||||
int loc = [(NSNumber *)[[routeInfo objectForKey:@"route"] objectAtIndex:i] intValue];
|
||||
int loc2 = [(NSNumber *)[[routeInfo objectForKey:@"route"] objectAtIndex:(i+1)] intValue];
|
||||
loc = [[routeInfo objectForKey:@"route"] oo_intAtIndex:i];
|
||||
|
||||
g_seed = [UNIVERSE systemSeedForSystemNumber:loc];
|
||||
g_seed2 = [UNIVERSE systemSeedForSystemNumber:(loc2)];
|
||||
g_seed2 = [UNIVERSE systemSeedForSystemNumber:[[routeInfo objectForKey:@"route"] oo_intAtIndex:(i+1)]];
|
||||
star.x = (float)(g_seed.d * hscale + hoffset);
|
||||
star.y = (float)(g_seed.b * vscale + voffset);
|
||||
star2.x = (float)(g_seed2.d * hscale + hoffset);
|
||||
@ -1561,10 +1574,11 @@ OOINLINE BOOL RowInRange(OOGUIRow row, NSRange range)
|
||||
glEnd();
|
||||
|
||||
// Label the route.
|
||||
OODrawString([UNIVERSE systemNameIndex:loc] , x + star.x + 2.0, y + star.y - 8.0, z, NSMakeSize(8,8));
|
||||
OODrawString([UNIVERSE systemNameIndex:loc], x + star.x + 2.0, y + star.y - 8.0, z, NSMakeSize(8,8));
|
||||
}
|
||||
// Label the destination, which was not included in the above loop.
|
||||
OODrawString([UNIVERSE systemNameIndex:destNumber] , x + star2.x + 2.0, y + star2.y - 10.0, z, NSMakeSize(10,10));
|
||||
loc = [[routeInfo objectForKey:@"route"] oo_intAtIndex:i];
|
||||
OODrawString([UNIVERSE systemNameIndex:loc], x + star2.x + 2.0, y + star2.y - 10.0, z, NSMakeSize(10,10));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ void GLRecycleTextureName(GLuint name, GLuint mipLevels)
|
||||
for (i = 0; i != mipLevels; ++i)
|
||||
{
|
||||
OOGL(glBindTexture(GL_TEXTURE_2D, name));
|
||||
OOGL(glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, junk));
|
||||
OOGL(glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, junk));
|
||||
}
|
||||
|
||||
sTextureNameCache[sTextureNameCacheSize++] = name;
|
||||
|
@ -116,7 +116,7 @@ SOFTWARE.
|
||||
|
||||
+ (id)sharedManager;
|
||||
|
||||
- (BOOL)haveExtension:(const NSString *)extension;
|
||||
- (BOOL)haveExtension:(NSString *)extension;
|
||||
|
||||
- (BOOL)shadersSupported;
|
||||
- (BOOL)vboSupported; // Vertex buffer objects
|
||||
|
@ -210,7 +210,7 @@ static unsigned IntegerFromString(const GLubyte **ioString);
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)haveExtension:(const NSString *)extension
|
||||
- (BOOL)haveExtension:(NSString *)extension
|
||||
{
|
||||
// NSSet is documented as thread-safe under OS X, but I'm not sure about GNUstep. -- Ahruman
|
||||
#if OOOPENGLEXTMGR_LOCK_SET_ACCESS
|
||||
|
@ -96,6 +96,14 @@ typedef enum
|
||||
} OOAlertCondition;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
OPTIMIZED_BY_NONE,
|
||||
OPTIMIZED_BY_JUMPS,
|
||||
OPTIMIZED_BY_TIME
|
||||
} OORouteType;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GUI_SCREEN_MAIN,
|
||||
|
@ -689,7 +689,12 @@ static JSBool ShipSetProperty(JSContext *context, JSObject *this, jsval name, js
|
||||
break;
|
||||
|
||||
case kShip_target:
|
||||
if (JSValueToEntity(context, *value, &target) && [target isKindOfClass:[ShipEntity class]])
|
||||
if (JSVAL_IS_NULL(*value))
|
||||
{
|
||||
[entity setTargetForScript:nil];
|
||||
OK = YES;
|
||||
}
|
||||
else if (JSValueToEntity(context, *value, &target) && [target isKindOfClass:[ShipEntity class]])
|
||||
{
|
||||
[entity setTargetForScript:target];
|
||||
OK = YES;
|
||||
|
@ -73,13 +73,6 @@ enum
|
||||
};
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
ROUTE_OPT_DISTANCE = 0,
|
||||
ROUTE_OPT_TIME = 1
|
||||
};
|
||||
|
||||
|
||||
#define MAX_MESSAGES 5
|
||||
|
||||
#define PROXIMITY_WARN_DISTANCE 20.0
|
||||
@ -521,7 +514,7 @@ enum
|
||||
- (NSPoint) findSystemCoordinatesWithPrefix:(NSString *) p_fix exactMatch:(BOOL) exactMatch;
|
||||
- (BOOL*) systems_found;
|
||||
- (NSString*) systemNameIndex:(OOSystemID) index;
|
||||
- (NSDictionary *) routeFromSystem:(OOSystemID) start toSystem:(OOSystemID) goal optimizedFor:(unsigned) distanceOrTime;
|
||||
- (NSDictionary *) routeFromSystem:(OOSystemID) start toSystem:(OOSystemID) goal optimizedBy:(OORouteType) optimizeBy;
|
||||
- (NSArray *) neighboursToSystem:(OOSystemID) system_number;
|
||||
|
||||
- (NSMutableDictionary *) localPlanetInfoOverrides;
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user