21 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22 |
*/ |
*/ |
23 |
|
|
24 |
|
#include <Foundation/NSHost.h> |
25 |
#include <Foundation/NSPort.h> |
#include <Foundation/NSPort.h> |
26 |
#include <Foundation/NSString.h> |
#include <Foundation/NSString.h> |
27 |
#include <Foundation/NSDictionary.h> |
#include <Foundation/NSDictionary.h> |
36 |
#include "GameEngine/HgGame.h" |
#include "GameEngine/HgGame.h" |
37 |
#include "GameEngine/HgPlayer.h" |
#include "GameEngine/HgPlayer.h" |
38 |
|
|
39 |
|
|
40 |
/** |
/** |
41 |
* This class represents a game on the server with the clients connected |
* This class represents a game on the server with the clients connected |
42 |
*/ |
*/ |
131 |
} |
} |
132 |
|
|
133 |
/** |
/** |
134 |
* Returns the number of players in the party (ie: number of clients). |
* Returns the number of clients in the party |
135 |
*/ |
*/ |
136 |
- (unsigned) nbPlayers |
- (unsigned) nbClients |
137 |
{ |
{ |
138 |
return [_clients count]; |
return [_clients count]; |
139 |
} |
} |
140 |
|
|
141 |
/** |
/** |
142 |
|
* Returns an array with the clients name. |
143 |
|
*/ |
144 |
|
- (NSArray *) allClientName |
145 |
|
{ |
146 |
|
return [_clients allKeys]; |
147 |
|
} |
148 |
|
|
149 |
|
/** |
150 |
* Connects the player named playerName to the NetParty |
* Connects the player named playerName to the NetParty |
151 |
* and returns the receive port on the server. |
* and returns the receive port on the server. |
152 |
* If the name is already in use, returns nil. |
* If the name is already in use, returns nil. |
158 |
NSParameterAssert (playerName); |
NSParameterAssert (playerName); |
159 |
NSParameterAssert ([playerName length] != 0); |
NSParameterAssert ([playerName length] != 0); |
160 |
|
|
161 |
if (([playerName length] != 0) |
if ([_clients objectForKey: playerName] == nil) |
|
&& ([_clients objectForKey: playerName] == nil)) |
|
162 |
{ |
{ |
163 |
/* FIXME - error message without cast */ |
NSPort *receivePort = [NSPort port]; |
|
NSPort *receivePort = (NSPort *)[NSPort port]; |
|
164 |
|
|
165 |
NetConnection *conn = [NetConnection |
NetConnection *conn = [NetConnection |
166 |
connectionWithReceivePort: receivePort |
connectionWithReceivePort: receivePort |