author | terom |
Sun, 09 Nov 2008 22:02:03 +0000 | |
changeset 26 | 5685602aeb9c |
parent 25 | af75a1894a32 |
child 35 | e21cfda0edde |
child 54 | b8b043ba0abd |
permissions | -rw-r--r-- |
5 | 1 |
#ifndef NETWORKCLIENT_HH |
2 |
#define NETWORKCLIENT_HH |
|
3 |
||
21 | 4 |
#include "Network.hh" |
5 |
#include "GameState.hh" |
|
6 |
||
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
7 |
// forward-declare |
26 | 8 |
class NetworkClientLocalPlayer; |
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
9 |
class NetworkClientRemotePlayer; |
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
10 |
|
21 | 11 |
class NetworkClient : public NetworkCore { |
26 | 12 |
friend class NetworkClientLocalPlayer; |
13 |
friend class NetworkClientRemotePlayer; |
|
14 |
||
24 | 15 |
private: |
16 |
CL_NetComputer server; |
|
17 |
||
18 |
public: |
|
19 |
NetworkClient (GameState &state, const CL_IPAddress &connect_to); |
|
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
20 |
|
24 | 21 |
private: |
22 |
void on_create_object (CL_NetObject_Client &obj, int msg_type, CL_NetPacket &pkt); |
|
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
23 |
|
24 | 24 |
void on_server_hello (CL_NetObject_Client &obj, CL_NetPacket &pkt); |
25 |
void on_player_info (CL_NetObject_Client &obj, CL_NetPacket &pkt); |
|
26 |
void on_player_join (CL_NetObject_Client &obj, CL_NetPacket &pkt); |
|
27 |
||
28 |
public: |
|
29 |
void player_quit (NetworkClientRemotePlayer *player); |
|
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
30 |
}; |
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
31 |
|
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
32 |
class NetworkClientLocalPlayer : public LocalPlayer { |
24 | 33 |
private: |
34 |
NetworkClient &client; |
|
21 | 35 |
|
24 | 36 |
CL_SlotContainer slots; |
37 |
||
38 |
CL_NetObject_Client obj; |
|
39 |
||
40 |
public: |
|
41 |
NetworkClientLocalPlayer (NetworkClient &client, CL_NetObject_Client &obj, Coordinate initial_position); |
|
42 |
||
25 | 43 |
virtual bool move (PositionDelta d); |
24 | 44 |
|
45 |
private: |
|
46 |
void on_position (CL_NetPacket &pkt); |
|
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
47 |
}; |
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
48 |
|
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
49 |
class NetworkClientRemotePlayer : public RemotePlayer { |
24 | 50 |
private: |
51 |
NetworkClient &client; |
|
52 |
||
53 |
CL_SlotContainer slots; |
|
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
54 |
|
24 | 55 |
CL_NetObject_Client obj; |
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
56 |
|
24 | 57 |
public: |
58 |
NetworkClientRemotePlayer (NetworkClient &client, CL_NetObject_Client &obj, Coordinate initial_position); |
|
59 |
||
60 |
private: |
|
61 |
void on_position (CL_NetPacket &pkt); |
|
62 |
||
63 |
void on_quit (CL_NetPacket &pkt); |
|
5 | 64 |
}; |
65 |
||
66 |
#endif |