5 #include "GameState.hh" |
5 #include "GameState.hh" |
6 |
6 |
7 #include <ClanLib/network.h> |
7 #include <ClanLib/network.h> |
8 |
8 |
9 class NetworkCore { |
9 class NetworkCore { |
10 protected: |
10 protected: |
11 GameState &state; |
11 GameState &state; |
12 |
12 |
13 CL_SlotContainer slots; |
13 CL_SlotContainer slots; |
14 |
14 |
15 CL_NetSession netsession; |
15 CL_NetSession netsession; |
16 |
16 |
17 CL_NetObject_Controller netobjs; |
17 CL_NetObject_Controller netobjs; |
18 |
18 |
19 // constructor |
19 // constructor |
20 NetworkCore (GameState &state) : state(state), netsession(NETWORK_APP_NAME), netobjs(&netsession, NETWORK_NETOBJ_CHAN) { } |
20 NetworkCore (GameState &state) : state(state), netsession(NETWORK_APP_NAME), netobjs(&netsession, NETWORK_NETOBJ_CHAN) { } |
21 }; |
21 }; |
22 |
22 |
23 enum NetworkMessage { |
23 enum NetworkMessage { |
24 NETMSG_PACKET_INVALID = 0x00, |
24 NETMSG_PACKET_INVALID = 0x00, |
25 |
25 |
26 /* |
26 /* |
27 * You have joined the game: |
27 * You have joined the game: |
28 * |
28 * |
29 * uint32_t x |
29 * uint32_t x |
30 * uint32_t y |
30 * uint32_t y |
31 */ |
31 */ |
32 NETMSG_SERVER_HELLO = 0x0100, |
32 NETMSG_SERVER_HELLO = 0x0100, |
33 |
33 |
34 /* |
34 /* |
35 * New client has connected to server: |
35 * New client has connected to server: |
36 * |
36 * |
37 * uint32_t x |
37 * uint32_t x |
38 * uint32_t y |
38 * uint32_t y |
39 */ |
39 */ |
40 NETMSG_PLAYER_JOIN = 0x0101, |
40 NETMSG_PLAYER_JOIN = 0x0101, |
41 |
41 |
42 /* |
42 /* |
43 * Client has left server: |
43 * Client has left server: |
44 * |
44 * |
45 */ |
45 */ |
46 NETMSG_PLAYER_QUIT = 0x0102, |
46 NETMSG_PLAYER_QUIT = 0x0102, |
47 |
47 |
48 /* |
48 /* |
49 * Client has moved |
49 * Client has moved |
50 * |
50 * |
51 * uint32_t dx |
51 * uint32_t dx |
52 * uint32_t dy |
52 * uint32_t dy |
53 */ |
53 */ |
54 NETMSG_CLIENT_MOVE = 0x0201, |
54 NETMSG_CLIENT_MOVE = 0x0201, |
55 |
55 |
56 /* |
56 /* |
57 * Initial player info |
57 * Initial player info |
58 * |
58 * |
59 * uint32_t x |
59 * uint32_t x |
60 * uint32_t y |
60 * uint32_t y |
61 */ |
61 */ |
62 NETMSG_PLAYER_INFO = 0x0300, |
62 NETMSG_PLAYER_INFO = 0x0300, |
63 |
63 |
64 /* |
64 /* |
65 * Player position update |
65 * Player position update |
66 * |
66 * |
67 * uint32_t x |
67 * uint32_t x |
68 * uint32_t y |
68 * uint32_t y |
69 */ |
69 */ |
70 NETMSG_PLAYER_POSITION = 0x0301, |
70 NETMSG_PLAYER_POSITION = 0x0301, |
71 }; |
71 }; |
72 |
72 |
73 #endif |
73 #endif |