1 #ifndef NETWORKCLIENT_HH |
1 #ifndef NETWORKCLIENT_HH |
2 #define NETWORKCLIENT_HH |
2 #define NETWORKCLIENT_HH |
3 |
3 |
4 #include "Network.hh" |
4 #include "Network.hh" |
5 #include "GameState.hh" |
5 #include "GameState.hh" |
|
6 #include "NetworkSession.hh" |
|
7 #include "NetworkObject.hh" |
6 |
8 |
7 // forward-declare |
9 // forward-declare |
8 class NetworkClientLocalPlayer; |
10 class NetworkClientLocalPlayer; |
9 class NetworkClientRemotePlayer; |
11 class NetworkClientRemotePlayer; |
10 |
12 |
11 class NetworkClient : public NetworkCore { |
13 class NetworkClient : public NetworkCore { |
12 friend class NetworkClientLocalPlayer; |
14 friend class NetworkClientLocalPlayer; |
13 friend class NetworkClientRemotePlayer; |
15 friend class NetworkClientRemotePlayer; |
14 |
16 |
15 private: |
17 private: |
16 CL_NetComputer server; |
18 NetworkSession netsession; |
|
19 NetworkNode *server; |
|
20 |
|
21 NetworkObject_ClientController netobjs; |
17 |
22 |
18 public: |
23 public: |
19 NetworkClient (GameState &state, const CL_IPAddress &connect_to); |
24 NetworkClient (GameState &state, const NetworkAddress &connect_to); |
20 |
25 |
21 private: |
26 private: |
22 void on_create_object (CL_NetObject_Client &obj, int msg_type, CL_NetPacket &pkt); |
27 void on_create (NetworkObject_Client *obj, NetworkMessageID msg_id, NetworkPacket &pkt); |
23 |
28 |
24 void on_server_hello (CL_NetObject_Client &obj, CL_NetPacket &pkt); |
29 void on_server_hello (NetworkObject_Client *obj, NetworkPacket &pkt); |
25 void on_player_info (CL_NetObject_Client &obj, CL_NetPacket &pkt); |
30 void on_player_info (NetworkObject_Client *obj, NetworkPacket &pkt); |
26 void on_player_join (CL_NetObject_Client &obj, CL_NetPacket &pkt); |
31 void on_player_join (NetworkObject_Client *obj, NetworkPacket &pkt); |
27 |
32 |
28 public: |
33 public: |
29 void player_quit (NetworkClientRemotePlayer *player); |
34 void player_quit (NetworkClientRemotePlayer *player); |
30 }; |
35 }; |
31 |
36 |
32 class NetworkClientLocalPlayer : public LocalPlayer { |
37 class NetworkClientLocalPlayer : public LocalPlayer { |
33 private: |
38 private: |
34 NetworkClient &client; |
39 NetworkClient &client; |
35 |
40 |
36 CL_SlotContainer slots; |
41 CL_SlotContainer slots; |
37 |
42 |
38 CL_NetObject_Client obj; |
43 NetworkObject_Client *obj; |
39 |
44 |
40 public: |
45 public: |
41 NetworkClientLocalPlayer (NetworkClient &client, CL_NetObject_Client &obj, Vector initial_position); |
46 NetworkClientLocalPlayer (NetworkClient &client, NetworkObject_Client *obj, Vector position); |
42 |
47 |
43 virtual void applyForce (Vector force, uint16_t dt); |
48 virtual void applyForce (Vector force, uint16_t dt); |
44 |
49 |
45 private: |
50 private: |
46 void on_position (CL_NetPacket &pkt); |
51 void on_position (NetworkPacket &pkt); |
47 }; |
52 }; |
48 |
53 |
49 class NetworkClientRemotePlayer : public RemotePlayer { |
54 class NetworkClientRemotePlayer : public RemotePlayer { |
50 private: |
55 private: |
51 NetworkClient &client; |
56 NetworkClient &client; |
52 |
57 |
53 CL_SlotContainer slots; |
58 CL_SlotContainer slots; |
54 |
59 |
55 CL_NetObject_Client obj; |
60 NetworkObject_Client *obj; |
56 |
61 |
57 public: |
62 public: |
58 NetworkClientRemotePlayer (NetworkClient &client, CL_NetObject_Client &obj, Vector initial_position); |
63 NetworkClientRemotePlayer (NetworkClient &client, NetworkObject_Client *obj, Vector position); |
59 |
64 |
60 private: |
65 private: |
61 void on_position (CL_NetPacket &pkt); |
66 void on_position (NetworkPacket &pkt); |
62 |
67 |
63 void on_quit (CL_NetPacket &pkt); |
68 void on_quit (NetworkPacket &pkt); |
64 }; |
69 }; |
65 |
70 |
66 #endif |
71 #endif |