1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
// server.cpp: little more than enhanced multicaster
// runs dedicated or as client coroutine
#include "cube.h"
enum { ST_EMPTY, ST_LOCAL, ST_TCPIP };
// server side version of "dynent" type
@interface Client: OFObject
@property (nonatomic) int type;
@property (nonatomic) ENetPeer *peer;
@property (copy, nonatomic) OFString *hostname;
@property (copy, nonatomic) OFString *mapvote;
@property (copy, nonatomic) OFString *name;
@property (nonatomic) int modevote;
@end
@implementation Client
@end
static OFMutableArray<Client *> *clients;
int maxclients = 8;
static OFString *smapname;
// server side version of "entity" type
struct server_entity {
|
>
>
<
<
<
<
<
<
<
<
<
<
<
<
<
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
// server.cpp: little more than enhanced multicaster
// runs dedicated or as client coroutine
#include "cube.h"
#import "Client.h"
enum { ST_EMPTY, ST_LOCAL, ST_TCPIP };
static OFMutableArray<Client *> *clients;
int maxclients = 8;
static OFString *smapname;
// server side version of "entity" type
struct server_entity {
|
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
Client *
addclient()
{
for (Client *client in clients)
if (client.type == ST_EMPTY)
return client;
Client *client = [[Client alloc] init];
if (clients == nil)
clients = [[OFMutableArray alloc] init];
[clients addObject:client];
return client;
|
|
|
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
|
Client *
addclient()
{
for (Client *client in clients)
if (client.type == ST_EMPTY)
return client;
Client *client = [Client client];
if (clients == nil)
clients = [[OFMutableArray alloc] init];
[clients addObject:client];
return client;
|