# HG changeset patch # User Jens Alfke # Date 1215574372 25200 # Node ID 4585c74d809cd08644f420ed4a6f45d1dd07ccd4 # Parent db7bb080c3d5d6d7ece5e37cf32917e4fde17c8d Minor fixes. diff -r db7bb080c3d5 -r 4585c74d809c Source/BoardView.m --- a/Source/BoardView.m Tue Jul 08 13:12:01 2008 -0700 +++ b/Source/BoardView.m Tue Jul 08 20:32:52 2008 -0700 @@ -86,6 +86,7 @@ - (void) setGame: (Game*)game { if( game!=_game ) { + _game.board = nil; setObj(&_game,game); [self createGameBoard]; } diff -r db7bb080c3d5 -r 4585c74d809c Source/GGBLayer.m --- a/Source/GGBLayer.m Tue Jul 08 13:12:01 2008 -0700 +++ b/Source/GGBLayer.m Tue Jul 08 20:32:52 2008 -0700 @@ -56,10 +56,14 @@ _curAnimation = (id)[self animationForKey: @"animateAndBlock:"]; [self setValue: to forKeyPath: keyPath]; // animation doesn't update the property value - // Now wait for it to finish: - while( _curAnimation ) { - [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode//NSEventTrackingRunLoopMode - beforeDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]]; + if( self.presentationLayer ) { + // Now wait for it to finish: + while( _curAnimation ) { + [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode//NSEventTrackingRunLoopMode + beforeDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]]; + } + } else { + _curAnimation = nil; } } diff -r db7bb080c3d5 -r 4585c74d809c Source/Game.m --- a/Source/Game.m Tue Jul 08 13:12:01 2008 -0700 +++ b/Source/Game.m Tue Jul 08 20:32:52 2008 -0700 @@ -125,20 +125,22 @@ - (void) setBoard: (GGBLayer*)board { setObj(&_board,board); - // Store a pointer to myself as the value of the "Game" property - // of my root layer. (CALayers can have arbitrary KV properties stored into them.) - // This is used by the -[CALayer game] category method defined below, to find the Game. - [_board setValue: self forKey: @"Game"]; - - BeginDisableAnimations(); - - // Tell the game to add the necessary bits to the board: - [self setUpBoard]; - - // Re-apply the current state to set up the pieces/cards: - self.stateString = [[_turns objectAtIndex: _currentTurnNo] boardState]; - - EndDisableAnimations(); + if( board ) { + // Store a pointer to myself as the value of the "Game" property + // of my root layer. (CALayers can have arbitrary KV properties stored into them.) + // This is used by the -[CALayer game] category method defined below, to find the Game. + [_board setValue: self forKey: @"Game"]; + + BeginDisableAnimations(); + + // Tell the game to add the necessary bits to the board: + [self setUpBoard]; + + // Re-apply the current state to set up the pieces/cards: + self.stateString = [[_turns objectAtIndex: _currentTurnNo] boardState]; + + EndDisableAnimations(); + } } diff -r db7bb080c3d5 -r 4585c74d809c Source/Player.h --- a/Source/Player.h Tue Jul 08 13:12:01 2008 -0700 +++ b/Source/Player.h Tue Jul 08 20:32:52 2008 -0700 @@ -35,6 +35,9 @@ @property (readonly, getter=isFriendly) BOOL friendly; // Is this player the current player or an ally? @property (readonly, getter=isUnfriendly) BOOL unfriendly; // Is this player an opponent of the current player? @property (readonly) Player *nextPlayer, *previousPlayer; // The next/previous player in sequence + +/** Copy all of the player's attributes (name, local...) into myself. */ +- (void) copyFrom: (Player*)player; @end diff -r db7bb080c3d5 -r 4585c74d809c Source/Player.m --- a/Source/Player.m Tue Jul 08 13:12:01 2008 -0700 +++ b/Source/Player.m Tue Jul 08 20:32:52 2008 -0700 @@ -78,6 +78,14 @@ } +- (void) copyFrom: (Player*)player +{ + self.local = player.local; + self.name = player.name; + setObj(&_extraValues, [[player->_extraValues mutableCopy] autorelease]); +} + + @synthesize game=_game, name=_name, local=_local; - (BOOL) isCurrent {return self == _game.currentPlayer;}