author | terom |
Sun, 09 Nov 2008 21:51:13 +0000 | |
changeset 25 | af75a1894a32 |
parent 24 | b81cb670e6b2 |
child 32 | 2ff929186c90 |
child 66 | 1415a2d45686 |
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 |
|
21 | 9 |
class NetworkCore { |
24 | 10 |
protected: |
11 |
GameState &state; |
|
5 | 12 |
|
24 | 13 |
CL_SlotContainer slots; |
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
14 |
|
24 | 15 |
CL_NetSession netsession; |
16 |
||
17 |
CL_NetObject_Controller netobjs; |
|
18 |
||
19 |
// constructor |
|
20 |
NetworkCore (GameState &state) : state(state), netsession(NETWORK_APP_NAME), netobjs(&netsession, NETWORK_NETOBJ_CHAN) { } |
|
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 |
|
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
23 |
enum NetworkMessage { |
24 | 24 |
NETMSG_PACKET_INVALID = 0x00, |
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
25 |
|
24 | 26 |
/* |
27 |
* You have joined the game: |
|
28 |
* |
|
29 |
* uint32_t x |
|
30 |
* uint32_t y |
|
31 |
*/ |
|
32 |
NETMSG_SERVER_HELLO = 0x0100, |
|
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
33 |
|
24 | 34 |
/* |
35 |
* New client has connected to server: |
|
36 |
* |
|
37 |
* uint32_t x |
|
38 |
* uint32_t y |
|
39 |
*/ |
|
40 |
NETMSG_PLAYER_JOIN = 0x0101, |
|
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
41 |
|
24 | 42 |
/* |
43 |
* Client has left server: |
|
44 |
* |
|
45 |
*/ |
|
46 |
NETMSG_PLAYER_QUIT = 0x0102, |
|
47 |
||
48 |
/* |
|
49 |
* Client has moved |
|
50 |
* |
|
25 | 51 |
* int32_t dx |
52 |
* int32_t dy |
|
24 | 53 |
*/ |
54 |
NETMSG_CLIENT_MOVE = 0x0201, |
|
55 |
||
56 |
/* |
|
57 |
* Initial player info |
|
58 |
* |
|
59 |
* uint32_t x |
|
60 |
* uint32_t y |
|
61 |
*/ |
|
62 |
NETMSG_PLAYER_INFO = 0x0300, |
|
63 |
||
64 |
/* |
|
65 |
* Player position update |
|
66 |
* |
|
67 |
* uint32_t x |
|
68 |
* uint32_t y |
|
69 |
*/ |
|
70 |
NETMSG_PLAYER_POSITION = 0x0301, |
|
5 | 71 |
}; |
72 |
||
73 |
#endif |