author | terom |
Tue, 18 Nov 2008 22:58:50 +0000 | |
branch | no-netsession |
changeset 35 | e21cfda0edde |
parent 32 | 2ff929186c90 |
child 36 | 785d220fc6b7 |
permissions | -rw-r--r-- |
5 | 1 |
#ifndef NETWORK_HH |
2 |
#define NETWORK_HH |
|
3 |
||
21 | 4 |
#include "NetworkConfig.hh" |
5 |
#include "GameState.hh" |
|
6 |
||
13 | 7 |
#include <ClanLib/network.h> |
5 | 8 |
|
35 | 9 |
const int32_t COORDINATE_MAX = 1 << 30; |
10 |
||
21 | 11 |
class NetworkCore { |
24 | 12 |
protected: |
13 |
GameState &state; |
|
5 | 14 |
|
24 | 15 |
CL_SlotContainer slots; |
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
16 |
|
24 | 17 |
// constructor |
32 | 18 |
NetworkCore (GameState &state) : state(state) { } |
35 | 19 |
|
20 |
||
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
21 |
}; |
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
22 |
|
35 | 23 |
// XXX: util methods |
24 |
void writeVector (CL_NetPacket &pkt, const Vector &vec); |
|
25 |
Vector readVector (CL_NetPacket &pkt); |
|
26 |
||
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
27 |
enum NetworkMessage { |
24 | 28 |
NETMSG_PACKET_INVALID = 0x00, |
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
29 |
|
24 | 30 |
/* |
31 |
* You have joined the game: |
|
32 |
* |
|
35 | 33 |
* Vector initial_position |
24 | 34 |
*/ |
35 |
NETMSG_SERVER_HELLO = 0x0100, |
|
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
36 |
|
24 | 37 |
/* |
38 |
* New client has connected to server: |
|
35 | 39 |
* |
40 |
* Vector initial_position |
|
24 | 41 |
*/ |
42 |
NETMSG_PLAYER_JOIN = 0x0101, |
|
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
43 |
|
24 | 44 |
/* |
45 |
* Client has left server: |
|
46 |
* |
|
47 |
*/ |
|
48 |
NETMSG_PLAYER_QUIT = 0x0102, |
|
49 |
||
50 |
/* |
|
51 |
* Client has moved |
|
52 |
* |
|
35 | 53 |
* Vector impulse_force |
54 |
* uint16_t impulse_ms |
|
24 | 55 |
*/ |
56 |
NETMSG_CLIENT_MOVE = 0x0201, |
|
57 |
||
58 |
/* |
|
59 |
* Initial player info |
|
60 |
* |
|
35 | 61 |
* Vector initial_position |
24 | 62 |
*/ |
63 |
NETMSG_PLAYER_INFO = 0x0300, |
|
64 |
||
65 |
/* |
|
66 |
* Player position update |
|
67 |
* |
|
35 | 68 |
* Vector position |
69 |
* Vector velocity |
|
24 | 70 |
*/ |
71 |
NETMSG_PLAYER_POSITION = 0x0301, |
|
5 | 72 |
}; |
73 |
||
74 |
#endif |