author | terom |
Tue, 18 Nov 2008 22:58:50 +0000 | |
branch | no-netsession |
changeset 35 | e21cfda0edde |
parent 26 | 5685602aeb9c |
child 36 | 785d220fc6b7 |
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: |
|
35 | 41 |
NetworkClientLocalPlayer (NetworkClient &client, CL_NetObject_Client &obj, Vector initial_position); |
24 | 42 |
|
35 | 43 |
virtual void applyForce (Vector force, uint16_t dt); |
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: |
35 | 58 |
NetworkClientRemotePlayer (NetworkClient &client, CL_NetObject_Client &obj, Vector initial_position); |
24 | 59 |
|
60 |
private: |
|
61 |
void on_position (CL_NetPacket &pkt); |
|
62 |
||
63 |
void on_quit (CL_NetPacket &pkt); |
|
5 | 64 |
}; |
65 |
||
66 |
#endif |