Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings and analyzer issues #270

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
3 changes: 1 addition & 2 deletions src/Cocoa/MyOpenGLView.m
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ - (id) initWithFrame:(NSRect)frameRect
}
#endif

matrixManager = [[OOOpenGLMatrixManager alloc] init];

// Pixel Format Attributes for the View-based (non-FullScreen) NSOpenGLContext
NSOpenGLPixelFormatAttribute attrs[] =
{
Expand Down Expand Up @@ -137,6 +135,7 @@ - (id) initWithFrame:(NSRect)frameRect
[self setWantsBestResolutionOpenGLSurface:YES];
}

matrixManager = [[OOOpenGLMatrixManager alloc] init];
_pixelFormatAttributes = [[NSData alloc] initWithBytes:attrs length:sizeof attrs];
virtualJoystickPosition = NSMakePoint(0.0,0.0);

Expand Down
2 changes: 1 addition & 1 deletion src/Core/Entities/OOPlanetEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ MA 02110-1301, USA.
Quaternion _atmosphereOrientation;
float _atmosphereRotationalVelocity;

unsigned _shuttlesOnGround;
NSUInteger _shuttlesOnGround;
OOTimeDelta _lastLaunchTime;
OOTimeDelta _shuttleLaunchInterval;

Expand Down
10 changes: 5 additions & 5 deletions src/Core/Entities/PlayerEntity.m
Original file line number Diff line number Diff line change
Expand Up @@ -5404,7 +5404,7 @@ - (void) cycleMultiFunctionDisplay:(NSUInteger) index
}
JSContext *context = OOJSAcquireContext();
jsval keyVal = OOJSValueFromNativeObject(context,key);
ShipScriptEvent(context, self, "mfdKeyChanged", INT_TO_JSVAL(activeMFD), keyVal);
ShipScriptEvent(context, self, "mfdKeyChanged", INT_TO_JSVAL((int32)activeMFD), keyVal);
OOJSRelinquishContext(context);
}

Expand All @@ -5415,7 +5415,7 @@ - (void) selectNextMultiFunctionDisplay
NSUInteger mfdID = activeMFD + 1;
[UNIVERSE addMessage:OOExpandKey(@"mfd-N-selected", mfdID) forCount:3.0 ];
JSContext *context = OOJSAcquireContext();
ShipScriptEvent(context, self, "selectedMFDChanged", INT_TO_JSVAL(activeMFD));
ShipScriptEvent(context, self, "selectedMFDChanged", INT_TO_JSVAL((int32)activeMFD));
OOJSRelinquishContext(context);
}

Expand Down Expand Up @@ -6558,20 +6558,20 @@ - (int) legalStatus
}


- (void) markAsOffender:(int)offence_value
- (void) markAsOffender:(OOCreditsQuantity)offence_value
{
[self markAsOffender:offence_value withReason:kOOLegalStatusReasonUnknown];
}


- (void) markAsOffender:(int)offence_value withReason:(OOLegalStatusReason)reason
- (void) markAsOffender:(OOCreditsQuantity)offence_value withReason:(OOLegalStatusReason)reason
{
if (![self isCloaked])
{
JSContext *context = OOJSAcquireContext();

jsval amountVal = JSVAL_VOID;
int amountVal2 = (legalStatus | offence_value) - legalStatus;
OOCreditsQuantity amountVal2 = (legalStatus | offence_value) - legalStatus;
JS_NewNumberValue(context, amountVal2, &amountVal);

legalStatus |= offence_value; // can't set the new bounty until the size of the change is known
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Entities/ShipEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -1163,8 +1163,8 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
Mark this ship as an offender, this is different to setBounty as some ships such as police
are not markable. The final bounty may not be equal to existing bounty plus offence_value.
*/
- (void) markAsOffender:(int)offence_value;
- (void) markAsOffender:(int)offence_value withReason:(OOLegalStatusReason)reason;
- (void) markAsOffender:(OOCreditsQuantity)offence_value;
- (void) markAsOffender:(OOCreditsQuantity)offence_value withReason:(OOLegalStatusReason)reason;

- (void) switchLightsOn;
- (void) switchLightsOff;
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Entities/ShipEntity.m
Original file line number Diff line number Diff line change
Expand Up @@ -13564,13 +13564,13 @@ - (BOOL) witchspaceLeavingEffects
}


- (void) markAsOffender:(int)offence_value
- (void) markAsOffender:(OOCreditsQuantity)offence_value
{
[self markAsOffender:offence_value withReason:kOOLegalStatusReasonUnknown];
}


- (void) markAsOffender:(int)offence_value withReason:(OOLegalStatusReason)reason
- (void) markAsOffender:(OOCreditsQuantity)offence_value withReason:(OOLegalStatusReason)reason
{
if (![self isPolice] && ![self isCloaked] && self != [UNIVERSE station])
{
Expand Down
6 changes: 2 additions & 4 deletions src/Core/GuiDisplayGen.m
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,6 @@ - (void) drawStarChart:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha :(BOO
(textRow-1) * MAIN_GUI_ROW_HEIGHT * pixelRatio);

OOSystemID target = [PLAYER targetSystemID];
NSString *targetName = [UNIVERSE getSystemName:target];
double dx, dy;

// get a list of systems marked as contract destinations
Expand Down Expand Up @@ -1893,10 +1892,9 @@ - (void) drawStarChart:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha :(BOO
{
[self drawAdvancedNavArrayAtX:x+hoffset y:y+voffset z:z alpha:alpha usingRoute:nil optimizedBy:OPTIMIZED_BY_NONE zoom: zoom];
}
NSPoint targetCoordinates = (NSPoint){0,0};
if (!routeExists)
{
targetCoordinates = [systemManager getCoordinatesForSystem:target inGalaxy:galaxy_id];
NSPoint targetCoordinates = [systemManager getCoordinatesForSystem:target inGalaxy:galaxy_id];

distance = distanceBetweenPlanetPositions(targetCoordinates.x,targetCoordinates.y,galaxy_coordinates.x,galaxy_coordinates.y);
if (distance == 0.0)
Expand Down Expand Up @@ -2234,7 +2232,7 @@ - (void) drawStarChart:(GLfloat)x :(GLfloat)y :(GLfloat)z :(GLfloat) alpha :(BOO
tab_stops[2] = 288;
[self overrideTabs:tab_stops from:kGuiChartTraveltimeTabs length:3];
[self setTabStops:tab_stops];
targetName = [[UNIVERSE getSystemName:target] retain];
NSString *targetName = [[UNIVERSE getSystemName:target] retain];

// distance-f & est-travel-time-f are identical between short & long range charts in standard Oolite, however can be alterered separately via OXPs
NSString *travelDistLine = @"";
Expand Down
8 changes: 2 additions & 6 deletions src/Core/HeadUpDisplay.m
Original file line number Diff line number Diff line change
Expand Up @@ -1182,8 +1182,6 @@ - (void) drawScanner:(NSDictionary *)info
GLfloat scanner_color[4] = { 1.0, 0.0, 0.0, 1.0 };

BOOL emptyDial = ([info oo_floatForKey:ALPHA_KEY] == 0.0f);

BOOL isHostile = NO;

if (emptyDial)
{
Expand Down Expand Up @@ -1344,11 +1342,10 @@ - (void) drawScanner:(NSDictionary *)info
y1 = z_factor * relativePosition.z;
y2 = y1 + y_factor * relativePosition.y;

isHostile = NO;
if ([scannedEntity isShip])
{
ShipEntity *ship = (ShipEntity *)scannedEntity;
isHostile = (([ship hasHostileTarget])&&([ship primaryTarget] == PLAYER));
BOOL isHostile = (([ship hasHostileTarget])&&([ship primaryTarget] == PLAYER));
GLfloat *base_col = [ship scannerDisplayColorForShip:PLAYER :isHostile :flash
:[ship scannerDisplayColor1] :[ship scannerDisplayColor2]
:[ship scannerDisplayColorHostile1] :[ship scannerDisplayColorHostile2]
Expand Down Expand Up @@ -3030,7 +3027,6 @@ - (void) drawWeaponsOfflineText:(NSDictionary *)info
{
int x, y;
NSSize siz;
GLfloat alpha = overallAlpha;
struct CachedInfo cached;

[(NSValue *)[sCurrentDrawItem objectAtIndex:WIDGET_CACHE] getValue:&cached];
Expand All @@ -3039,8 +3035,8 @@ - (void) drawWeaponsOfflineText:(NSDictionary *)info
y = useDefined(cached.y, WEAPONSOFFLINETEXT_DISPLAY_Y) + [[UNIVERSE gameView] y_offset] * cached.y0;
siz.width = useDefined(cached.width, WEAPONSOFFLINETEXT_WIDTH);
siz.height = useDefined(cached.height, WEAPONSOFFLINETEXT_HEIGHT);
alpha *= cached.alpha;

textColor[3] = cached.alpha;
GetRGBAArrayFromInfo(info, textColor);
textColor[3] *= overallAlpha;

Expand Down
2 changes: 0 additions & 2 deletions src/Core/Materials/OOShaderProgram.m
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,6 @@ - (id)initWithVertexShaderSource:(NSString *)vertexSource
self = [super init];
if (self == nil) OK = NO;

standardMatrixUniformLocations = nil;

if (OK && vertexSource == nil && fragmentSource == nil) OK = NO; // Must have at least one shader!

if (OK && prefixString != nil)
Expand Down
9 changes: 6 additions & 3 deletions src/Core/OOALSoundChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ - (id) init
[self release];
self = nil;
}
// sources are all relative to listener, defaulting to zero vector
OOAL(alSourcei(_source, AL_SOURCE_RELATIVE, AL_TRUE));
OOAL(alSource3f(_source, AL_POSITION, 0.0f, 0.0f, 0.0f));
else
{
// sources are all relative to listener, defaulting to zero vector
OOAL(alSourcei(_source, AL_SOURCE_RELATIVE, AL_TRUE));
OOAL(alSource3f(_source, AL_POSITION, 0.0f, 0.0f, 0.0f));
}
}
return self;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Core/OOJoystickManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ typedef struct
- (double) getSensitivity;

// Axis profile handling
- (void) setProfile: (OOJoystickAxisProfile *) profile forAxis:(int) axis;
- (OOJoystickAxisProfile *) getProfileForAxis: (int) axis;
- (void) saveProfileForAxis: (int) axis;
- (void) loadProfileForAxis: (int) axis;
- (void) setProfile: (OOJoystickAxisProfile *) profile forAxis:(NSUInteger) axis;
- (OOJoystickAxisProfile *) getProfileForAxis: (NSUInteger) axis;
- (void) saveProfileForAxis: (NSUInteger) axis;
- (void) loadProfileForAxis: (NSUInteger) axis;

// This one just returns a pointer to the entire state array to
// allow for multiple lookups with only one objc_sendMsg
Expand Down
8 changes: 4 additions & 4 deletions src/Core/OOJoystickManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ - (double) getSensitivity
return precisionMode ? STICK_PRECISIONFAC : 1.0;
}

- (void) setProfile: (OOJoystickAxisProfile *) profile forAxis: (int) axis
- (void) setProfile: (OOJoystickAxisProfile *) profile forAxis: (NSUInteger) axis
{
switch (axis)
{
Expand All @@ -186,7 +186,7 @@ - (void) setProfile: (OOJoystickAxisProfile *) profile forAxis: (int) axis
return;
}

- (OOJoystickAxisProfile *) getProfileForAxis: (int) axis
- (OOJoystickAxisProfile *) getProfileForAxis: (NSUInteger) axis
{
switch (axis)
{
Expand All @@ -201,7 +201,7 @@ - (OOJoystickAxisProfile *) getProfileForAxis: (int) axis
}


- (void) saveProfileForAxis: (int) axis
- (void) saveProfileForAxis: (NSUInteger) axis
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
Expand Down Expand Up @@ -260,7 +260,7 @@ - (void) saveProfileForAxis: (int) axis



- (void) loadProfileForAxis: (int) axis
- (void) loadProfileForAxis: (NSUInteger) axis
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *dict;
Expand Down
4 changes: 2 additions & 2 deletions src/Core/OOJoystickProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ MA 02110-1301, USA.
- (id) init;
- (void) dealloc;
- (id) copyWithZone: (NSZone *) zone;
- (int) addControl: (NSPoint) point;
- (NSInteger) addControl: (NSPoint) point;
- (NSPoint) pointAtIndex: (NSInteger) index;
- (int) countPoints;
- (NSInteger) countPoints;
- (void) removeControl: (NSInteger) index;
- (void) clearControlPoints;
- (void) moveControl: (NSInteger) index point: (NSPoint) point;
Expand Down
4 changes: 2 additions & 2 deletions src/Core/OOJoystickProfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ - (id) copyWithZone: (NSZone *) zone
}


- (int) addControl: (NSPoint) point
- (NSInteger) addControl: (NSPoint) point
{
NSPoint left, right;
NSUInteger i;
Expand Down Expand Up @@ -438,7 +438,7 @@ - (NSPoint) pointAtIndex: (NSInteger) index
return point;
}

- (int) countPoints
- (NSInteger) countPoints
{
return [controlPoints count];
}
Expand Down