Estranged nephew of more truncation fixes.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@5265 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
a2a5b0f8b8
commit
d7850617d5
@ -505,7 +505,7 @@ typedef struct
|
|||||||
for (texEnum = [allTextures objectEnumerator]; (tex = [texEnum nextObject]); )
|
for (texEnum = [allTextures objectEnumerator]; (tex = [texEnum nextObject]); )
|
||||||
{
|
{
|
||||||
// We subtract one because allTextures retains the textures.
|
// We subtract one because allTextures retains the textures.
|
||||||
[textureRefCounts setObject:[NSNumber numberWithUnsignedInt:[tex retainCount] - 1] forKey:[NSValue valueWithNonretainedObject:tex]];
|
[textureRefCounts setObject:[NSNumber numberWithUnsignedInteger:[tex retainCount] - 1] forKey:[NSValue valueWithNonretainedObject:tex]];
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t totalSize = 0;
|
size_t totalSize = 0;
|
||||||
|
@ -242,8 +242,8 @@ OOINLINE BOOL StatusIsSendable(OOTCPClientConnectionStatus status)
|
|||||||
if (emphasisRange.length != 0)
|
if (emphasisRange.length != 0)
|
||||||
{
|
{
|
||||||
range = [NSArray arrayWithObjects:
|
range = [NSArray arrayWithObjects:
|
||||||
[NSNumber numberWithUnsignedInt:emphasisRange.location],
|
[NSNumber numberWithUnsignedInteger:emphasisRange.location],
|
||||||
[NSNumber numberWithUnsignedInt:emphasisRange.length],
|
[NSNumber numberWithUnsignedInteger:emphasisRange.length],
|
||||||
nil];
|
nil];
|
||||||
[parameters setObject:range forKey:kOOTCPEmphasisRanges];
|
[parameters setObject:range forKey:kOOTCPEmphasisRanges];
|
||||||
}
|
}
|
||||||
@ -338,14 +338,12 @@ noteChangedConfigrationValue:(in id)newValue
|
|||||||
|
|
||||||
- (BOOL) sendBytes:(const void *)bytes count:(size_t)count
|
- (BOOL) sendBytes:(const void *)bytes count:(size_t)count
|
||||||
{
|
{
|
||||||
int written;
|
|
||||||
|
|
||||||
if (bytes == NULL || count == 0) return YES;
|
if (bytes == NULL || count == 0) return YES;
|
||||||
if (!StatusIsSendable(_status) || _outStream == nil) return NO;
|
if (!StatusIsSendable(_status) || _outStream == nil) return NO;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
written = [_outStream write:bytes maxLength:count];
|
OOInteger written = [_outStream write:bytes maxLength:count];
|
||||||
if (written < 1) return NO;
|
if (written < 1) return NO;
|
||||||
|
|
||||||
count -= written;
|
count -= written;
|
||||||
@ -471,24 +469,12 @@ noteChangedConfigrationValue:(in id)newValue
|
|||||||
enum { kBufferSize = 16 << 10 };
|
enum { kBufferSize = 16 << 10 };
|
||||||
|
|
||||||
uint8_t buffer[kBufferSize];
|
uint8_t buffer[kBufferSize];
|
||||||
int length;
|
OOInteger length;
|
||||||
NSData *data;
|
NSData *data;
|
||||||
|
|
||||||
length = [_inStream read:buffer maxLength:kBufferSize];
|
length = [_inStream read:buffer maxLength:kBufferSize];
|
||||||
while( length > 0 )
|
while (length > 0)
|
||||||
{
|
{
|
||||||
/* This test is superfluous after the rewrite to fix Bug#014643
|
|
||||||
* TODO: Put the BadStream test back into the code
|
|
||||||
if (length < 1)
|
|
||||||
{
|
|
||||||
// Under GNUstep, but not OS X (currently), -hasBytesAvailable will return YES when the buffer is in fact empty.
|
|
||||||
if ([_inStream streamStatus] == NSStreamStatusReading) break;
|
|
||||||
|
|
||||||
[self breakConnectionWithBadStream:_inStream];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
data = [NSData dataWithBytesNoCopy:buffer length:length freeWhenDone:NO];
|
data = [NSData dataWithBytesNoCopy:buffer length:length freeWhenDone:NO];
|
||||||
OOTCPStreamDecoderReceiveData(_decoder, data);
|
OOTCPStreamDecoderReceiveData(_decoder, data);
|
||||||
length = [_inStream read:buffer maxLength:kBufferSize];
|
length = [_inStream read:buffer maxLength:kBufferSize];
|
||||||
|
@ -315,7 +315,7 @@ static JSBool ConsoleGetProperty(JSContext *context, JSObject *this, jsid propID
|
|||||||
{
|
{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
case kConsole_debugFlags:
|
case kConsole_debugFlags:
|
||||||
*value = INT_TO_JSVAL(gDebugFlags);
|
*value = INT_TO_JSVAL((uint32_t)gDebugFlags);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -372,11 +372,11 @@ static JSBool ConsoleGetProperty(JSContext *context, JSObject *this, jsid propID
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kConsole_glFixedFunctionTextureUnitCount:
|
case kConsole_glFixedFunctionTextureUnitCount:
|
||||||
*value = INT_TO_JSVAL([[OOOpenGLExtensionManager sharedManager] textureUnitCount]);
|
*value = INT_TO_JSVAL((uint32_t)[[OOOpenGLExtensionManager sharedManager] textureUnitCount]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kConsole_glFragmentShaderTextureUnitCount:
|
case kConsole_glFragmentShaderTextureUnitCount:
|
||||||
*value = INT_TO_JSVAL([[OOOpenGLExtensionManager sharedManager] textureImageUnitCount]);
|
*value = INT_TO_JSVAL((uint32_t)[[OOOpenGLExtensionManager sharedManager] textureImageUnitCount]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#define DEBUG_FLAG_CASE(x) case kConsole_##x: *value = INT_TO_JSVAL(x); break;
|
#define DEBUG_FLAG_CASE(x) case kConsole_##x: *value = INT_TO_JSVAL(x); break;
|
||||||
|
@ -298,8 +298,6 @@ static GLfloat sBaseMass = 0.0;
|
|||||||
[shipCommodityData release];
|
[shipCommodityData release];
|
||||||
shipCommodityData = manifest;
|
shipCommodityData = manifest;
|
||||||
|
|
||||||
//[cargo removeAllObjects]; // empty the hold - not needed, done individually inside unloadAllCargoPodsForType
|
|
||||||
|
|
||||||
[self calculateCurrentCargo]; // work out the correct value for current_cargo
|
[self calculateCurrentCargo]; // work out the correct value for current_cargo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -736,7 +736,7 @@ OOINLINE float Hermite(float q)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if __BIG_ENDIAN_
|
#if __BIG_ENDIAN__
|
||||||
#define iman_ 1
|
#define iman_ 1
|
||||||
#else
|
#else
|
||||||
#define iman_ 0
|
#define iman_ 0
|
||||||
@ -744,10 +744,10 @@ OOINLINE float Hermite(float q)
|
|||||||
|
|
||||||
// (same behaviour as, but faster than, FLOAT->INT)
|
// (same behaviour as, but faster than, FLOAT->INT)
|
||||||
//Works OK for -32728 to 32727.99999236688
|
//Works OK for -32728 to 32727.99999236688
|
||||||
OOINLINE long fast_floor(double val)
|
OOINLINE int32_t fast_floor(double val)
|
||||||
{
|
{
|
||||||
val += 68719476736.0 * 1.5;
|
val += 68719476736.0 * 1.5;
|
||||||
return (((long*)&val)[iman_] >> 16);
|
return (((int32_t*)&val)[iman_] >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ OOINLINE BOOL ValidBindingType(OOShaderUniformType type)
|
|||||||
{
|
{
|
||||||
BOOL OK = YES;
|
BOOL OK = YES;
|
||||||
NSMethodSignature *signature = nil;
|
NSMethodSignature *signature = nil;
|
||||||
unsigned argCount;
|
OOUInteger argCount;
|
||||||
NSString *methodProblem = nil;
|
NSString *methodProblem = nil;
|
||||||
id<OOWeakReferenceSupport> superCandidate = nil;
|
id<OOWeakReferenceSupport> superCandidate = nil;
|
||||||
|
|
||||||
@ -496,7 +496,7 @@ OOINLINE BOOL ValidBindingType(OOShaderUniformType type)
|
|||||||
case kOOShaderUniformTypeUnsignedInt:
|
case kOOShaderUniformTypeUnsignedInt:
|
||||||
case kOOShaderUniformTypeLong:
|
case kOOShaderUniformTypeLong:
|
||||||
case kOOShaderUniformTypeUnsignedLong:
|
case kOOShaderUniformTypeUnsignedLong:
|
||||||
iVal = OOCallIntegerMethod(object, value.binding.selector, value.binding.method, type);
|
iVal = (GLint)OOCallIntegerMethod(object, value.binding.selector, value.binding.method, type);
|
||||||
isInt = YES;
|
isInt = YES;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ void OOCPUInfoInit(void);
|
|||||||
/* Number of processors (whether they be individual or cores), used to select
|
/* Number of processors (whether they be individual or cores), used to select
|
||||||
number of threads to use for things like texture loading.
|
number of threads to use for things like texture loading.
|
||||||
*/
|
*/
|
||||||
unsigned OOCPUCount(void);
|
OOUInteger OOCPUCount(void);
|
||||||
|
|
||||||
|
|
||||||
/* Set up OOLITE_BIG_ENDIAN and OOLITE_LITTLE_ENDIAN macros. Exactly one must
|
/* Set up OOLITE_BIG_ENDIAN and OOLITE_LITTLE_ENDIAN macros. Exactly one must
|
||||||
|
@ -98,7 +98,7 @@ void OOCPUInfoInit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned OOCPUCount(void)
|
OOUInteger OOCPUCount(void)
|
||||||
{
|
{
|
||||||
if (!sInited) OOCPUInfoInit();
|
if (!sInited) OOCPUInfoInit();
|
||||||
return (sNumberOfCPUs != 0) ? sNumberOfCPUs : 1;
|
return (sNumberOfCPUs != 0) ? sNumberOfCPUs : 1;
|
||||||
|
@ -186,7 +186,7 @@ NSArray *OOConvertSystemDescriptionsToArrayFormat(NSDictionary *descriptionsInDi
|
|||||||
realResult = [NSMutableArray arrayWithCapacity:count];
|
realResult = [NSMutableArray arrayWithCapacity:count];
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
entry = [result objectForKey:[NSNumber numberWithUnsignedInt:i]];
|
entry = [result objectForKey:[NSNumber numberWithUnsignedInteger:i]];
|
||||||
if (entry == nil) entry = [NSArray array];
|
if (entry == nil) entry = [NSArray array];
|
||||||
[realResult addObject:entry];
|
[realResult addObject:entry];
|
||||||
}
|
}
|
||||||
@ -323,7 +323,7 @@ static NSNumber *KeyToIndex(NSString *key, NSMutableDictionary *ioKeysToIndices,
|
|||||||
// Search for free index
|
// Search for free index
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
result = [NSNumber numberWithUnsignedInt:(*ioSlotCache)++];
|
result = [NSNumber numberWithUnsignedInteger:(*ioSlotCache)++];
|
||||||
}
|
}
|
||||||
while ([ioUsedIndicies containsObject:result]);
|
while ([ioUsedIndicies containsObject:result]);
|
||||||
|
|
||||||
|
@ -2235,7 +2235,7 @@ static void VFRAddFace(VertexFaceRef *vfr, OOUInteger index)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (vfr->extra == nil) vfr->extra = [NSMutableArray array];
|
if (vfr->extra == nil) vfr->extra = [NSMutableArray array];
|
||||||
[vfr->extra addObject:[NSNumber numberWithInt:index]];
|
[vfr->extra addObject:[NSNumber numberWithInteger:index]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,8 +261,8 @@ static NSArray *ArrayOfExtensions(NSString *extensionString)
|
|||||||
maximumShaderSetting = SHADERS_NOT_SUPPORTED;
|
maximumShaderSetting = SHADERS_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLint texImageUnitOverride = [gpuConfig oo_unsignedIntegerForKey:@"texture_image_units" defaultValue:textureImageUnitCount];
|
GLint texImageUnitOverride = [gpuConfig oo_intForKey:@"texture_image_units" defaultValue:textureImageUnitCount];
|
||||||
if (texImageUnitOverride < textureImageUnitCount) textureImageUnitCount = texImageUnitOverride;
|
if (texImageUnitOverride < textureImageUnitCount) textureImageUnitCount = MAX(texImageUnitOverride, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if OO_USE_VBO
|
#if OO_USE_VBO
|
||||||
@ -273,8 +273,8 @@ static NSArray *ArrayOfExtensions(NSString *extensionString)
|
|||||||
#endif
|
#endif
|
||||||
#if OO_MULTITEXTURE
|
#if OO_MULTITEXTURE
|
||||||
[self checkTextureCombinersSupported];
|
[self checkTextureCombinersSupported];
|
||||||
GLint texUnitOverride = [gpuConfig oo_unsignedIntegerForKey:@"texture_units" defaultValue:textureUnitCount];
|
GLint texUnitOverride = [gpuConfig oo_intForKey:@"texture_units" defaultValue:textureUnitCount];
|
||||||
if (texUnitOverride < textureUnitCount) textureUnitCount = texUnitOverride;
|
if (texUnitOverride < textureUnitCount) textureUnitCount = MAX(texUnitOverride, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
usePointSmoothing = [gpuConfig oo_boolForKey:@"smooth_points" defaultValue:YES];
|
usePointSmoothing = [gpuConfig oo_boolForKey:@"smooth_points" defaultValue:YES];
|
||||||
|
@ -54,7 +54,7 @@ SOFTWARE.
|
|||||||
{
|
{
|
||||||
BOOL OK = YES;
|
BOOL OK = YES;
|
||||||
NSArray *config = nil;
|
NSArray *config = nil;
|
||||||
unsigned i, count;
|
OOUInteger i, count;
|
||||||
id entry = nil;
|
id entry = nil;
|
||||||
NSString *name = nil;
|
NSString *name = nil;
|
||||||
float probability;
|
float probability;
|
||||||
|
@ -316,7 +316,7 @@ NSDictionary *OOParseRolesFromString(NSString *string)
|
|||||||
{
|
{
|
||||||
NSMutableDictionary *result = nil;
|
NSMutableDictionary *result = nil;
|
||||||
NSArray *tokens = nil;
|
NSArray *tokens = nil;
|
||||||
unsigned i, count;
|
OOUInteger i, count;
|
||||||
NSString *role = nil;
|
NSString *role = nil;
|
||||||
float probability;
|
float probability;
|
||||||
NSScanner *scanner = nil;
|
NSScanner *scanner = nil;
|
||||||
|
@ -485,7 +485,7 @@ static NSString * const kVisualEffectDataCacheKey = @"visual effect data";
|
|||||||
NSString *parentKey = nil;
|
NSString *parentKey = nil;
|
||||||
NSDictionary *shipEntry = nil;
|
NSDictionary *shipEntry = nil;
|
||||||
NSDictionary *parentEntry = nil;
|
NSDictionary *parentEntry = nil;
|
||||||
unsigned count, lastCount;
|
OOUInteger count, lastCount;
|
||||||
NSMutableArray *reportedBadShips = nil;
|
NSMutableArray *reportedBadShips = nil;
|
||||||
|
|
||||||
// Build set of ships with like_ship references
|
// Build set of ships with like_ship references
|
||||||
|
@ -96,7 +96,7 @@ static NSString * const kStageName = @"Checking equipment.plist";
|
|||||||
NSEnumerator *entryEnum = nil;
|
NSEnumerator *entryEnum = nil;
|
||||||
NSArray *entry = nil;
|
NSArray *entry = nil;
|
||||||
unsigned entryIndex = 0;
|
unsigned entryIndex = 0;
|
||||||
unsigned elemCount;
|
OOUInteger elemCount;
|
||||||
NSString *name = nil;
|
NSString *name = nil;
|
||||||
NSString *entryDesc = nil;
|
NSString *entryDesc = nil;
|
||||||
|
|
||||||
@ -123,12 +123,12 @@ static NSString * const kStageName = @"Checking equipment.plist";
|
|||||||
// Check that the entry has an acceptable number of elements.
|
// Check that the entry has an acceptable number of elements.
|
||||||
if (elemCount < 5)
|
if (elemCount < 5)
|
||||||
{
|
{
|
||||||
OOLog(@"verifyOXP.equipmentPList.badEntrySize", @"***** ERROR: equipment.plist entry %@ has too few elements (%u, should be 5 or 6).", entryDesc, elemCount);
|
OOLog(@"verifyOXP.equipmentPList.badEntrySize", @"***** ERROR: equipment.plist entry %@ has too few elements (%lu, should be 5 or 6).", entryDesc, elemCount);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (6 < elemCount)
|
if (6 < elemCount)
|
||||||
{
|
{
|
||||||
OOLog(@"verifyOXP.equipmentPList.badEntrySize", @"----- WARNING: equipment.plist entry %@ has too many elements (%u, should be 5 or 6).", entryDesc, elemCount);
|
OOLog(@"verifyOXP.equipmentPList.badEntrySize", @"----- WARNING: equipment.plist entry %@ has too many elements (%lu, should be 5 or 6).", entryDesc, elemCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check element types. The numbers are required to be unsigned
|
/* Check element types. The numbers are required to be unsigned
|
||||||
|
@ -326,7 +326,7 @@ static NSString * const kStageName = @"Checking shipdata.plist";
|
|||||||
{
|
{
|
||||||
NSArray *parts = nil;
|
NSArray *parts = nil;
|
||||||
NSMutableSet *result = nil;
|
NSMutableSet *result = nil;
|
||||||
unsigned i, count;
|
OOUInteger i, count;
|
||||||
NSString *role = nil;
|
NSString *role = nil;
|
||||||
NSRange parenRange;
|
NSRange parenRange;
|
||||||
|
|
||||||
|
@ -121,9 +121,9 @@ OOINLINE BackLinkChain BackLink(BackLinkChain *link, id element)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
OOINLINE BackLinkChain BackLinkIndex(BackLinkChain *link, unsigned index)
|
OOINLINE BackLinkChain BackLinkIndex(BackLinkChain *link, OOUInteger index)
|
||||||
{
|
{
|
||||||
BackLinkChain result = { link, [NSNumber numberWithInt:index] };
|
BackLinkChain result = { link, [NSNumber numberWithInteger:index] };
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -761,7 +761,7 @@ static NSString *ArrayForErrorReport(NSArray *array)
|
|||||||
{
|
{
|
||||||
NSString *result = nil;
|
NSString *result = nil;
|
||||||
NSString *string = nil;
|
NSString *string = nil;
|
||||||
unsigned i, count;
|
OOUInteger i, count;
|
||||||
NSAutoreleasePool *pool = nil;
|
NSAutoreleasePool *pool = nil;
|
||||||
|
|
||||||
count = [array count];
|
count = [array count];
|
||||||
@ -830,8 +830,8 @@ static NSError *Verify_String(OOPListSchemaVerifier *verifier, id value, NSDicti
|
|||||||
{
|
{
|
||||||
NSString *filteredString = nil;
|
NSString *filteredString = nil;
|
||||||
id testValue = nil;
|
id testValue = nil;
|
||||||
unsigned length;
|
OOUInteger length;
|
||||||
unsigned lengthConstraint;
|
OOUInteger lengthConstraint;
|
||||||
NSError *error = nil;
|
NSError *error = nil;
|
||||||
|
|
||||||
REQUIRE_TYPE(NSString, @"string");
|
REQUIRE_TYPE(NSString, @"string");
|
||||||
@ -875,13 +875,13 @@ static NSError *Verify_String(OOPListSchemaVerifier *verifier, id value, NSDicti
|
|||||||
|
|
||||||
// Apply length bounds.
|
// Apply length bounds.
|
||||||
length = [filteredString length];
|
length = [filteredString length];
|
||||||
lengthConstraint = [params oo_unsignedIntForKey:@"minLength"];
|
lengthConstraint = [params oo_unsignedIntegerForKey:@"minLength"];
|
||||||
if (length < lengthConstraint)
|
if (length < lengthConstraint)
|
||||||
{
|
{
|
||||||
return Error(kPListErrorMinimumConstraintNotMet, &keyPath, @"String \"%@\" is too short (%u bytes, minimum is %u).", StringForErrorReport(filteredString), length, lengthConstraint);
|
return Error(kPListErrorMinimumConstraintNotMet, &keyPath, @"String \"%@\" is too short (%u bytes, minimum is %u).", StringForErrorReport(filteredString), length, lengthConstraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
lengthConstraint = [params oo_unsignedIntForKey:@"maxLength" defaultValue:UINT_MAX];
|
lengthConstraint = [params oo_unsignedIntegerForKey:@"maxLength" defaultValue:NSUIntegerMax];
|
||||||
if (lengthConstraint < length)
|
if (lengthConstraint < length)
|
||||||
{
|
{
|
||||||
return Error(kPListErrorMaximumConstraintNotMet, &keyPath, @"String \"%@\" is too long (%u bytes, maximum is %u).", StringForErrorReport(filteredString), length, lengthConstraint);
|
return Error(kPListErrorMaximumConstraintNotMet, &keyPath, @"String \"%@\" is too long (%u bytes, maximum is %u).", StringForErrorReport(filteredString), length, lengthConstraint);
|
||||||
@ -896,9 +896,9 @@ static NSError *Verify_Array(OOPListSchemaVerifier *verifier, id value, NSDictio
|
|||||||
{
|
{
|
||||||
id valueType = nil;
|
id valueType = nil;
|
||||||
BOOL OK = YES, stop = NO;
|
BOOL OK = YES, stop = NO;
|
||||||
unsigned i, count;
|
OOUInteger i, count;
|
||||||
id subProperty = nil;
|
id subProperty = nil;
|
||||||
unsigned constraint;
|
OOUInteger constraint;
|
||||||
|
|
||||||
REQUIRE_TYPE(NSArray, @"array");
|
REQUIRE_TYPE(NSArray, @"array");
|
||||||
|
|
||||||
@ -906,13 +906,13 @@ static NSError *Verify_Array(OOPListSchemaVerifier *verifier, id value, NSDictio
|
|||||||
|
|
||||||
// Apply count bounds.
|
// Apply count bounds.
|
||||||
count = [value count];
|
count = [value count];
|
||||||
constraint = [params oo_unsignedIntForKey:@"minCount" defaultValue:0];
|
constraint = [params oo_unsignedIntegerForKey:@"minCount" defaultValue:0];
|
||||||
if (count < constraint)
|
if (count < constraint)
|
||||||
{
|
{
|
||||||
return Error(kPListErrorMinimumConstraintNotMet, &keyPath, @"Array has too few members (%u, minimum is %u).", count, constraint);
|
return Error(kPListErrorMinimumConstraintNotMet, &keyPath, @"Array has too few members (%u, minimum is %u).", count, constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
constraint = [params oo_unsignedIntForKey:@"maxCount" defaultValue:UINT_MAX];
|
constraint = [params oo_unsignedIntegerForKey:@"maxCount" defaultValue:NSUIntegerMax];
|
||||||
if (constraint < count)
|
if (constraint < count)
|
||||||
{
|
{
|
||||||
return Error(kPListErrorMaximumConstraintNotMet, &keyPath, @"Array has too many members (%u, maximum is %u).", count, constraint);
|
return Error(kPListErrorMaximumConstraintNotMet, &keyPath, @"Array has too many members (%u, maximum is %u).", count, constraint);
|
||||||
@ -961,7 +961,7 @@ static NSError *Verify_Dictionary(OOPListSchemaVerifier *verifier, id value, NSD
|
|||||||
BOOL allowOthers;
|
BOOL allowOthers;
|
||||||
NSMutableSet *requiredKeys = nil;
|
NSMutableSet *requiredKeys = nil;
|
||||||
NSArray *requiredKeyList = nil;
|
NSArray *requiredKeyList = nil;
|
||||||
unsigned count, constraint;
|
OOUInteger count, constraint;
|
||||||
|
|
||||||
REQUIRE_TYPE(NSDictionary, @"dictionary");
|
REQUIRE_TYPE(NSDictionary, @"dictionary");
|
||||||
|
|
||||||
@ -969,12 +969,12 @@ static NSError *Verify_Dictionary(OOPListSchemaVerifier *verifier, id value, NSD
|
|||||||
|
|
||||||
// Apply count bounds.
|
// Apply count bounds.
|
||||||
count = [value count];
|
count = [value count];
|
||||||
constraint = [params oo_unsignedIntForKey:@"minCount" defaultValue:0];
|
constraint = [params oo_unsignedIntegerForKey:@"minCount" defaultValue:0];
|
||||||
if (count < constraint)
|
if (count < constraint)
|
||||||
{
|
{
|
||||||
return Error(kPListErrorMinimumConstraintNotMet, &keyPath, @"Dictionary has too few pairs (%u, minimum is %u).", count, constraint);
|
return Error(kPListErrorMinimumConstraintNotMet, &keyPath, @"Dictionary has too few pairs (%u, minimum is %u).", count, constraint);
|
||||||
}
|
}
|
||||||
constraint = [params oo_unsignedIntForKey:@"maxCount" defaultValue:UINT_MAX];
|
constraint = [params oo_unsignedIntegerForKey:@"maxCount" defaultValue:NSUIntegerMax];
|
||||||
if (constraint < count)
|
if (constraint < count)
|
||||||
{
|
{
|
||||||
return Error(kPListErrorMaximumConstraintNotMet, &keyPath, @"Dictionary has too manu pairs (%u, maximum is %u).", count, constraint);
|
return Error(kPListErrorMaximumConstraintNotMet, &keyPath, @"Dictionary has too manu pairs (%u, maximum is %u).", count, constraint);
|
||||||
|
@ -164,8 +164,8 @@ static NSString * const kStageName = @"Testing textures and images";
|
|||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
rWidth = OORoundUpToPowerOf2((2 * pixmap.width) / 3);
|
rWidth = (uint32_t)OORoundUpToPowerOf2((2 * pixmap.width) / 3);
|
||||||
rHeight = OORoundUpToPowerOf2((2 * pixmap.height) / 3);
|
rHeight = (uint32_t)OORoundUpToPowerOf2((2 * pixmap.height) / 3);
|
||||||
if (pixmap.width != rWidth || pixmap.height != rHeight)
|
if (pixmap.width != rWidth || pixmap.height != rHeight)
|
||||||
{
|
{
|
||||||
OOLog(@"verifyOXP.texture.notPOT", @"----- WARNING: image %@ has non-power-of-two dimensions; it will have to be rescaled (from %ux%u pixels to %ux%u pixels) at runtime.", displayName, pixmap.width, pixmap.height, rWidth, rHeight);
|
OOLog(@"verifyOXP.texture.notPOT", @"----- WARNING: image %@ has non-power-of-two dimensions; it will have to be rescaled (from %ux%u pixels to %ux%u pixels) at runtime.", displayName, pixmap.width, pixmap.height, rWidth, rHeight);
|
||||||
|
@ -35,7 +35,7 @@ static void AppendNewLineAndIndent(NSMutableString *ioString, unsigned indentDep
|
|||||||
NSRange foundRange, searchRange;
|
NSRange foundRange, searchRange;
|
||||||
NSString *foundString;
|
NSString *foundString;
|
||||||
NSMutableString *newString;
|
NSMutableString *newString;
|
||||||
unsigned length;
|
NSUInteger length;
|
||||||
|
|
||||||
length = [self length];
|
length = [self length];
|
||||||
if (0 != length
|
if (0 != length
|
||||||
|
@ -263,16 +263,15 @@ static JSBool EquipmentInfoGetProperty(JSContext *context, JSObject *this, jsid
|
|||||||
return JS_NewNumberValue(context, [eqType damageProbability], value);
|
return JS_NewNumberValue(context, [eqType damageProbability], value);
|
||||||
|
|
||||||
case kEquipmentInfo_techLevel:
|
case kEquipmentInfo_techLevel:
|
||||||
*value = INT_TO_JSVAL([eqType techLevel]);
|
*value = INT_TO_JSVAL((int32_t)[eqType techLevel]);
|
||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
case kEquipmentInfo_effectiveTechLevel:
|
case kEquipmentInfo_effectiveTechLevel:
|
||||||
*value = INT_TO_JSVAL([eqType effectiveTechLevel]);
|
*value = INT_TO_JSVAL((int32_t)[eqType effectiveTechLevel]);
|
||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
case kEquipmentInfo_price:
|
case kEquipmentInfo_price:
|
||||||
*value = INT_TO_JSVAL([eqType price]);
|
return JS_NewNumberValue(context, [eqType price], value);
|
||||||
return YES;
|
|
||||||
|
|
||||||
case kEquipmentInfo_isAvailableToAll:
|
case kEquipmentInfo_isAvailableToAll:
|
||||||
*value = OOJSValueFromBOOL([eqType isAvailableToAll]);
|
*value = OOJSValueFromBOOL([eqType isAvailableToAll]);
|
||||||
|
@ -92,9 +92,11 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
if (OK)
|
if (OK)
|
||||||
{
|
{
|
||||||
|
assert(argCount < UINT32_MAX);
|
||||||
|
|
||||||
[code getCharacters:buffer];
|
[code getCharacters:buffer];
|
||||||
|
|
||||||
function = JS_CompileUCFunction(context, scope, [name UTF8String], argCount, argNames, buffer, length, [fileName UTF8String], lineNumber);
|
function = JS_CompileUCFunction(context, scope, [name UTF8String], (uint32_t)argCount, argNames, buffer, length, [fileName UTF8String], (uint32_t)lineNumber);
|
||||||
if (function == NULL) OK = NO;
|
if (function == NULL) OK = NO;
|
||||||
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@ -196,6 +198,7 @@ MA 02110-1301, USA.
|
|||||||
result:(jsval *)result
|
result:(jsval *)result
|
||||||
{
|
{
|
||||||
OOUInteger i, argc = [arguments count];
|
OOUInteger i, argc = [arguments count];
|
||||||
|
assert(argc < UINT32_MAX);
|
||||||
jsval argv[argc];
|
jsval argv[argc];
|
||||||
|
|
||||||
for (i = 0; i < argc; i++)
|
for (i = 0; i < argc; i++)
|
||||||
@ -209,7 +212,7 @@ MA 02110-1301, USA.
|
|||||||
if (jsThis != nil) OK = JS_ValueToObject(context, [jsThis oo_jsValueInContext:context], &scopeObj);
|
if (jsThis != nil) OK = JS_ValueToObject(context, [jsThis oo_jsValueInContext:context], &scopeObj);
|
||||||
if (OK) OK = [self evaluateWithContext:context
|
if (OK) OK = [self evaluateWithContext:context
|
||||||
scope:scopeObj
|
scope:scopeObj
|
||||||
argc:argc
|
argc:(uint32_t)argc
|
||||||
argv:argv
|
argv:argv
|
||||||
result:result];
|
result:result];
|
||||||
|
|
||||||
|
@ -175,7 +175,9 @@ static JSBool MissionVariablesEnumerate(JSContext *context, JSObject *object, JS
|
|||||||
enumerator = [[mvars objectEnumerator] retain];
|
enumerator = [[mvars objectEnumerator] retain];
|
||||||
*state = PRIVATE_TO_JSVAL(enumerator);
|
*state = PRIVATE_TO_JSVAL(enumerator);
|
||||||
|
|
||||||
if (idp != NULL) *idp = INT_TO_JSID([mvars count]);
|
OOUInteger count = [mvars count];
|
||||||
|
assert(count <= INT32_MAX);
|
||||||
|
if (idp != NULL) *idp = INT_TO_JSID((uint32_t)count);
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ static JSBool OoliteCompareVersion(JSContext *context, uintN argc, jsval *vp)
|
|||||||
|
|
||||||
if (components != nil)
|
if (components != nil)
|
||||||
{
|
{
|
||||||
OOJS_RETURN_INT(CompareVersions(components, VersionComponents()));
|
OOJS_RETURN_INT((int32_t)CompareVersions(components, VersionComponents()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -200,7 +200,7 @@ static JSBool PlayerGetProperty(JSContext *context, JSObject *this, jsid propID,
|
|||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
case kPlayer_legalStatus:
|
case kPlayer_legalStatus:
|
||||||
*value = OOJSValueFromNativeObject(context, OODisplayStringFromLegalStatus([player bounty]));
|
*value = OOJSValueFromNativeObject(context, OODisplayStringFromLegalStatus([player legalStatus]));
|
||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
case kPlayer_alertCondition:
|
case kPlayer_alertCondition:
|
||||||
@ -517,7 +517,7 @@ static JSBool PlayerSetEscapePodDestination(JSContext *context, uintN argc, jsva
|
|||||||
rescueRange = [UNIVERSE strict] ? MAX_JUMP_RANGE / 3.0 : MAX_JUMP_RANGE / 2.0;
|
rescueRange = [UNIVERSE strict] ? MAX_JUMP_RANGE / 3.0 : MAX_JUMP_RANGE / 2.0;
|
||||||
}
|
}
|
||||||
NSMutableArray *sDests = [UNIVERSE nearbyDestinationsWithinRange:rescueRange];
|
NSMutableArray *sDests = [UNIVERSE nearbyDestinationsWithinRange:rescueRange];
|
||||||
int i = 0, nDests = [sDests count];
|
OOUInteger i = 0, nDests = [sDests count];
|
||||||
|
|
||||||
if (nDests > 0) for (i = --nDests; i > 0; i--)
|
if (nDests > 0) for (i = --nDests; i > 0; i--)
|
||||||
{
|
{
|
||||||
|
@ -477,7 +477,7 @@ static JSBool ShipGetProperty(JSContext *context, JSObject *this, jsid propID, j
|
|||||||
return JS_NewNumberValue(context, [entity fuelChargeRate], value);
|
return JS_NewNumberValue(context, [entity fuelChargeRate], value);
|
||||||
|
|
||||||
case kShip_bounty:
|
case kShip_bounty:
|
||||||
*value = INT_TO_JSVAL([entity bounty]);
|
return JS_NewNumberValue(context, [entity bounty], value);
|
||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
case kShip_subEntities:
|
case kShip_subEntities:
|
||||||
@ -485,7 +485,7 @@ static JSBool ShipGetProperty(JSContext *context, JSObject *this, jsid propID, j
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kShip_subEntityCapacity:
|
case kShip_subEntityCapacity:
|
||||||
*value = INT_TO_JSVAL([entity maxShipSubEntities]);
|
return JS_NewNumberValue(context, [entity maxShipSubEntities], value);
|
||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
case kShip_hasSuspendedAI:
|
case kShip_hasSuspendedAI:
|
||||||
@ -1996,8 +1996,12 @@ static JSBool ShipRestoreSubEntities(JSContext *context, uintN argc, jsval *vp)
|
|||||||
|
|
||||||
if ([[thisEnt subEntitiesForScript] count] - subCount > 0) numSubEntitiesRestored = [[thisEnt subEntitiesForScript] count] - subCount;
|
if ([[thisEnt subEntitiesForScript] count] - subCount > 0) numSubEntitiesRestored = [[thisEnt subEntitiesForScript] count] - subCount;
|
||||||
|
|
||||||
// for each subentitiy restored, slightly increase the trade-in factor
|
// for each subentity restored, slightly increase the trade-in factor
|
||||||
if ([thisEnt isPlayer]) [(PlayerEntity *)thisEnt adjustTradeInFactorBy:(PLAYER_SHIP_SUBENTITY_TRADE_IN_VALUE * numSubEntitiesRestored)];
|
if ([thisEnt isPlayer])
|
||||||
|
{
|
||||||
|
int tradeInFactorChange = (int)MAX(PLAYER_SHIP_SUBENTITY_TRADE_IN_VALUE * numSubEntitiesRestored, 25U);
|
||||||
|
[(PlayerEntity *)thisEnt adjustTradeInFactorBy:tradeInFactorChange];
|
||||||
|
}
|
||||||
|
|
||||||
OOJS_RETURN_BOOL(numSubEntitiesRestored > 0);
|
OOJS_RETURN_BOOL(numSubEntitiesRestored > 0);
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ static JSBool StationGetProperty(JSContext *context, JSObject *this, jsid propID
|
|||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
case kStation_equivalentTechLevel:
|
case kStation_equivalentTechLevel:
|
||||||
*value = INT_TO_JSVAL([entity equivalentTechLevel]);
|
*value = INT_TO_JSVAL((int32_t)[entity equivalentTechLevel]);
|
||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
case kStation_equipmentPriceFactor:
|
case kStation_equipmentPriceFactor:
|
||||||
|
@ -350,7 +350,9 @@ static JSBool SystemInfoEnumerate(JSContext *context, JSObject *this, JSIterateO
|
|||||||
enumerator = [[keys objectEnumerator] retain];
|
enumerator = [[keys objectEnumerator] retain];
|
||||||
*state = PRIVATE_TO_JSVAL(enumerator);
|
*state = PRIVATE_TO_JSVAL(enumerator);
|
||||||
|
|
||||||
if (idp != NULL) *idp = INT_TO_JSID([keys count]);
|
OOUInteger count = [keys count];
|
||||||
|
assert(count <= INT32_MAX);
|
||||||
|
if (idp != NULL) *idp = INT_TO_JSID((int32_t)count);
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user