~ubuntu-branches/ubuntu/wily/oolite/wily-proposed

« back to all changes in this revision

Viewing changes to src/Core/OOShipGroup.m

  • Committer: Package Import Robot
  • Author(s): Nicolas Boulenguez
  • Date: 2011-12-22 00:22:39 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20111222002239-pr3upeupp4jw1psp
Tags: 1.76-1
* New upstream.
* watch: scan upstream stable releases instead of dev snapshots.
* control: use default gobjc instead of explicit 4.6.
* rules: use dpkg-dev build flags.

Show diffs side-by-side

added added

removed removed

Lines of Context:
338
338
#endif
339
339
 
340
340
 
341
 
- (void) addShip:(ShipEntity *)ship
 
341
- (BOOL) addShip:(ShipEntity *)ship
342
342
{
343
343
        _updateCount++;
344
344
        
345
 
        if ([self containsShip:ship])  return;
 
345
        if ([self containsShip:ship])  return YES;      // it's in the group already, result!
346
346
        
347
347
        // Ensure there's space.
348
348
        if (_count == _capacity)
351
351
                {
352
352
                        if (![self resizeTo:_capacity + 1])
353
353
                        {
354
 
                                // Out of memory? Fail silently, groups are non-critical.
355
 
                                return;
 
354
                                // Out of memory?
 
355
                                return NO;
356
356
                        }
357
357
                }
358
358
        }
359
359
        
360
360
        _members[_count++] = [ship weakRetain];
 
361
        return YES;
361
362
}
362
363
 
363
364
 
364
 
- (void) removeShip:(ShipEntity *)ship
 
365
- (BOOL) removeShip:(ShipEntity *)ship
365
366
{
366
367
        OOShipGroupEnumerator   *shipEnum = nil;
367
368
        ShipEntity                              *containedShip = nil;
368
369
        OOUInteger                              index;
 
370
        BOOL                                    foundIt = NO;
369
371
        
370
372
        _updateCount++;
371
373
        
379
381
                {
380
382
                        index = [shipEnum index] - 1;
381
383
                        _members[index] = _members[--_count];
 
384
                        foundIt = YES;
382
385
                        
383
386
                        // Clean up
 
387
                        [ship setGroup:nil];
 
388
                        [ship setOwner:ship];
384
389
                        [self cleanUp];
385
390
                        break;
386
391
                }
387
392
        }
 
393
        return foundIt;
388
394
}
389
395
 
390
396