| author | terom |
| Sun, 07 Dec 2008 20:07:28 +0000 | |
| changeset 255 | 99431fdb0dc8 |
| parent 241 | e95b1602d836 |
| child 263 | 8c999cf4c182 |
| permissions | -rw-r--r-- |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
1 |
#ifndef NETWORKSERVER_HH |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
2 |
#define NETWORKSERVER_HH |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
3 |
|
| 186 | 4 |
#include "../GameState.hh" |
5 |
#include "Session.hh" |
|
6 |
#include "Object.hh" |
|
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
7 |
|
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
8 |
#include <list> |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
9 |
#include <map> |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
10 |
#include <ClanLib/core.h> |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
11 |
|
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
12 |
// forward-declare |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
13 |
class NetworkServerPlayer; |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
14 |
|
| 187 | 15 |
class NetworkServer {
|
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
16 |
friend class NetworkServerPlayer; |
| 223 | 17 |
friend class NetworkServerProjectile; |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
18 |
|
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
19 |
protected: |
| 187 | 20 |
GameState &state; |
21 |
CL_SlotContainer slots; |
|
22 |
||
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
23 |
NetworkSession netsession; |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
24 |
NetworkObject_ServerController netobjs; |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
25 |
std::list<NetworkServerPlayer *> players; |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
26 |
|
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
27 |
public: |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
28 |
NetworkServer (GameState &state, const NetworkAddress &listen_addr); |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
29 |
|
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
30 |
protected: |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
31 |
void handle_disconnect (NetworkServerPlayer *player); |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
32 |
|
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
33 |
private: |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
34 |
void on_node_connected (NetworkNode *node); |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
35 |
}; |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
36 |
|
|
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
203
diff
changeset
|
37 |
class NetworkServerPlayer : public LocalPlayer {
|
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
38 |
private: |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
39 |
NetworkServer &server; |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
40 |
NetworkObject_Server obj; |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
41 |
NetworkNode *node; |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
42 |
|
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
43 |
CL_SlotContainer slots; |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
44 |
|
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
45 |
public: |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
46 |
NetworkServerPlayer (NetworkServer &server, NetworkNode *node); |
|
239
550397d9d479
implement network weapon changes and fix weapon firing
terom
parents:
224
diff
changeset
|
47 |
|
|
550397d9d479
implement network weapon changes and fix weapon firing
terom
parents:
224
diff
changeset
|
48 |
protected: |
| 223 | 49 |
// override from Player to replicate side effects of events to clients |
|
200
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
50 |
virtual void handleDig (Vector position, float radius); |
|
239
550397d9d479
implement network weapon changes and fix weapon firing
terom
parents:
224
diff
changeset
|
51 |
virtual void handleCreateProjectile (Weapon *weapon, Vector position, Vector velocity); |
|
550397d9d479
implement network weapon changes and fix weapon firing
terom
parents:
224
diff
changeset
|
52 |
virtual void handleChangeWeapon (unsigned int weaponIndex); |
| 241 | 53 |
virtual void handleRopeState (RopeState state); |
54 |
virtual void handleRopeLength (float length); |
|
|
200
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
55 |
|
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
56 |
private: |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
57 |
void on_disconnected (void); |
| 223 | 58 |
void on_input (NetworkNode *node, NetworkPacketInput &pkt); |
|
203
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
59 |
|
|
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
60 |
void send_terrain_data (void); |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
61 |
void send_position_update (void); |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
62 |
}; |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
63 |
|
| 223 | 64 |
class NetworkServerProjectile : public Projectile {
|
65 |
private: |
|
66 |
NetworkServer &server; |
|
67 |
NetworkObject_Server obj; |
|
68 |
||
69 |
public: |
|
70 |
NetworkServerProjectile (NetworkServer &server, Vector position, Vector velocity, float explosionRadius, TickCount age); |
|
|
224
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
71 |
|
|
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
72 |
protected: |
|
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
73 |
virtual void onDestroy (Vector position, bool removeGround); |
| 223 | 74 |
}; |
75 |
||
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
76 |
#endif |