36 |
@implementation HgPlayer |
@implementation HgPlayer |
37 |
|
|
38 |
/** |
/** |
39 |
* Initialize a new player, with a given name, user and host. |
* Initialize a new player, with a given name, user, host, and the game. |
40 |
*/ |
*/ |
41 |
-(id) initWithName: (NSString *)name |
-(id) initWithName: (NSString *)name |
42 |
user: (NSString *)user |
user: (NSString *)user |
43 |
host: (NSString *)host |
host: (NSString *)host |
44 |
|
game: (HgGame *) game |
45 |
{ |
{ |
46 |
/* |
/* |
47 |
* FIXME - overflow risk |
* FIXME - overflow risk |
54 |
NSParameterAssert ([user length] != 0); |
NSParameterAssert ([user length] != 0); |
55 |
NSParameterAssert (host); |
NSParameterAssert (host); |
56 |
NSParameterAssert ([host length] != 0); |
NSParameterAssert ([host length] != 0); |
57 |
|
NSParameterAssert (game); |
58 |
|
|
59 |
self = [super init]; |
self = [super init]; |
60 |
if (self != nil) |
if (self != nil) |
65 |
_team = nil; |
_team = nil; |
66 |
_ship = nil; |
_ship = nil; |
67 |
_score = 0; |
_score = 0; |
68 |
|
_game = game; |
69 |
} |
} |
70 |
|
|
71 |
return self; |
return self; |
79 |
RELEASE(_userAtHost); |
RELEASE(_userAtHost); |
80 |
TEST_RELEASE(_team); |
TEST_RELEASE(_team); |
81 |
TEST_RELEASE(_ship); |
TEST_RELEASE(_ship); |
82 |
|
RELEASE(_game); |
83 |
|
|
84 |
[super dealloc]; |
[super dealloc]; |
85 |
} |
} |
86 |
|
|
204 |
[decoder decodeValueOfObjCType: "I" at: &_identifier]; |
[decoder decodeValueOfObjCType: "I" at: &_identifier]; |
205 |
NSNumber *numIdent = [NSNumber numberWithInt: _identifier]; |
NSNumber *numIdent = [NSNumber numberWithInt: _identifier]; |
206 |
|
|
207 |
HgGame *current = [HgGame currentGame]; |
HgPlayer *playerObject = [[_game players] objectForKey: numIdent]; |
|
HgPlayer *playerObject = [[current players] objectForKey: numIdent]; |
|
208 |
if (playerObject != nil) |
if (playerObject != nil) |
209 |
{ |
{ |
210 |
DESTROY(self); |
DESTROY(self); |